示例#1
0
int EstEID_loadCertInfo(EstEID_Certs *certs, int index) {
	CK_SLOT_ID slotID = certs->slotIDs[index];

	CK_SLOT_INFO slotInfo;
	FAIL_IF(EstEID_CK_failure("C_GetSlotInfo", fl->C_GetSlotInfo(slotID, &slotInfo)));

	if (!(slotInfo.flags & CKF_TOKEN_PRESENT)) return SUCCESS;

	CK_TOKEN_INFO tokenInfo;
	FAIL_IF(EstEID_CK_failure("C_GetTokenInfo", fl->C_GetTokenInfo(slotID, &tokenInfo)));

	certs->certs[index] = EstEID_createCertMap(tokenInfo);

	FAIL_UNLESS(EstEID_loadCertInfoEntries(certs, index));

	return SUCCESS;
}
示例#2
0
static bool
DUMMY_INSTALL_COMPONENT (gcs_backend_t* backend, const gcs_comp_msg_t* comp)
{
    bool primary = gcs_comp_msg_primary (comp);
    long my_idx  = gcs_comp_msg_self    (comp);
    long members = gcs_comp_msg_num     (comp);

    action_t act;

    FAIL_IF (gcs_dummy_set_component(Backend, comp), "", NULL);
    FAIL_IF (DUMMY_INJECT_COMPONENT (Backend, comp), "", NULL);
    FAIL_IF (CORE_RECV_ACT (&act, NULL, UNKNOWN_SIZE, GCS_ACT_CONF), "", NULL);
    FAIL_IF (core_test_check_conf(act.out, primary, my_idx, members),
             "", NULL);
    free (act.out);
    return false;
}
static int test_bug33831(MYSQL *mysql)
{
  FAIL_IF(mysql_real_connect(mysql, hostname, username,
                             password, schema, port, socketname, 0), 
         "Error expected");
  
  return OK;
}
示例#4
0
文件: lib.c 项目: 020gzh/linux
int notify_parent_of_error(union pipe write_pipe)
{
	char c = ~CHILD_TOKEN;

	FAIL_IF(write(write_pipe.write_fd, &c, 1) != 1);

	return 0;
}
示例#5
0
static int create_dyncol_num(MYSQL *mysql)
{
  DYNAMIC_COLUMN dyncol;
  DYNAMIC_COLUMN_VALUE vals[5];
  uint i, column_count= 5;
  uint my_count;
  MYSQL_LEX_STRING *my_keys;
  DYNAMIC_COLUMN_VALUE *my_vals;
  int rc;
  char *strval[]= {"Val1", "Val2", "Val3", "Val4", "Val5"};

  uint keys1[5]= {1,2,3,4,5},
       keys2[5]= {1,2,2,4,5};
  MYSQL_LEX_STRING key1= {"1",1};

  for (i=0; i < column_count; i++)
  {
    vals[i].type= DYN_COL_STRING;
    vals[i].x.string.value.str= strval[i];
    vals[i].x.string.value.length= strlen(strval[i]);
    vals[i].x.string.charset= (CHARSET_INFO *)mysql->charset;
  }
  FAIL_IF(mariadb_dyncol_create_many_num(&dyncol, column_count, keys1, vals, 1) <0, "Error (keys1)");

  vals[0].x.string.value.str= strval[1];
  rc= mariadb_dyncol_update_many_named(&dyncol,1, &key1, vals);
  diag("update: %d", rc);

  rc= mariadb_dyncol_unpack(&dyncol, &my_count, &my_keys, &my_vals);
  diag("unpack: %d %d", rc, my_count);

  diag("---------------__");
  for(i=0; i < 5; i++)
  {
    diag("%s %d", my_keys[i].str, my_keys[i].length);
  }
  free(my_keys);
  free(my_vals);

  FAIL_IF(mariadb_dyncol_column_count(&dyncol, &column_count) < 0, "Error");
  FAIL_IF(column_count != 5, "5 columns expected");
  mariadb_dyncol_free(&dyncol);
  FAIL_IF(mariadb_dyncol_create_many_num(&dyncol, column_count, keys2, vals, 1) >=0, "Error expected (keys2)");
  mariadb_dyncol_free(&dyncol);
  return OK;
}
static int DetectAppLayerProtocolTest14(void)
{
    DetectAppLayerProtocolData *data = NULL;
    DetectEngineCtx *de_ctx = DetectEngineCtxInit();
    FAIL_IF_NULL(de_ctx);
    de_ctx->flags |= DE_QUIET;

    Signature *s1 = DetectEngineAppendSig(de_ctx, "alert tcp any any -> any any "
            "(app-layer-protocol:http; flowbits:set,blah; sid:1;)");
    FAIL_IF_NULL(s1);
    FAIL_IF(s1->alproto != ALPROTO_UNKNOWN);
    FAIL_IF_NULL(s1->sm_lists[DETECT_SM_LIST_MATCH]);
    FAIL_IF_NULL(s1->sm_lists[DETECT_SM_LIST_MATCH]->ctx);
    data = (DetectAppLayerProtocolData *)s1->sm_lists[DETECT_SM_LIST_MATCH]->ctx;
    FAIL_IF(data->alproto != ALPROTO_HTTP);
    FAIL_IF(data->negated);

    Signature *s2 = DetectEngineAppendSig(de_ctx, "alert tcp any any -> any any "
            "(app-layer-protocol:http; flow:to_client; sid:2;)");
    FAIL_IF_NULL(s2);
    FAIL_IF(s2->alproto != ALPROTO_UNKNOWN);
    FAIL_IF_NULL(s2->sm_lists[DETECT_SM_LIST_MATCH]);
    FAIL_IF_NULL(s2->sm_lists[DETECT_SM_LIST_MATCH]->ctx);
    data = (DetectAppLayerProtocolData *)s2->sm_lists[DETECT_SM_LIST_MATCH]->ctx;
    FAIL_IF(data->alproto != ALPROTO_HTTP);
    FAIL_IF(data->negated);

    /* flow:established and other options not supported for PD-only */
    Signature *s3 = DetectEngineAppendSig(de_ctx, "alert tcp any any -> any any "
            "(app-layer-protocol:http; flow:to_client,established; sid:3;)");
    FAIL_IF_NULL(s3);
    FAIL_IF(s3->alproto != ALPROTO_UNKNOWN);
    FAIL_IF_NULL(s3->sm_lists[DETECT_SM_LIST_MATCH]);
    FAIL_IF_NULL(s3->sm_lists[DETECT_SM_LIST_MATCH]->ctx);
    data = (DetectAppLayerProtocolData *)s3->sm_lists[DETECT_SM_LIST_MATCH]->ctx;
    FAIL_IF(data->alproto != ALPROTO_HTTP);
    FAIL_IF(data->negated);

    SigGroupBuild(de_ctx);
    FAIL_IF_NOT(s1->flags & SIG_FLAG_PDONLY);
    FAIL_IF_NOT(s2->flags & SIG_FLAG_PDONLY);
    FAIL_IF(s3->flags & SIG_FLAG_PDONLY); // failure now

    DetectEngineCtxFree(de_ctx);
    PASS;
}
static int test_conc70(MYSQL *my)
{
  int rc;
  MYSQL_RES *res;
  MYSQL_ROW row;
  MYSQL *mysql= mysql_init(NULL);

  rc= mysql_query(my, "SET @a:=@@max_allowed_packet");
  check_mysql_rc(rc, my);

  mysql_query(my, "SET global max_allowed_packet=1024*1024*22");

  mysql_options(mysql, MYSQL_OPT_COMPRESS, (void *)1);
  FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
                         port, socketname, 0), mysql_error(my));

  rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
  check_mysql_rc(rc, mysql);

  rc= mysql_query(mysql, "CREATE TABLE t1 (a LONGBLOB) engine=MyISAM");
  check_mysql_rc(rc, mysql);

  rc= mysql_query(mysql, "INSERT INTO t1 VALUES (REPEAT('A', 1024 * 1024 * 20))");
  check_mysql_rc(rc, mysql); 

  rc= mysql_query(mysql, "SELECT a FROM t1");
  check_mysql_rc(rc, mysql);

  if (!(res= mysql_store_result(mysql)))
  {
    diag("Error: %s", mysql_error(mysql));
    return FAIL;
  }

  row= mysql_fetch_row(res);
  diag("Length: %ld", strlen(row[0]));
  FAIL_IF(strlen(row[0]) != 1024 * 1024 * 20, "Wrong length");

  mysql_free_result(res);
  mysql_close(mysql);

  rc= mysql_query(my, "SET global max_allowed_packet=@a");
  check_mysql_rc(rc, my);

  return OK;
}
示例#8
0
static int DetectTemplateParseTest01 (void)
{
    DetectTemplateData *templated = DetectTemplateParse("1,10");
    FAIL_IF_NULL(templated);
    FAIL_IF(!(templated->arg1 == 1 && templated->arg2 == 10));
    DetectTemplateFree(templated);
    PASS;
}
示例#9
0
文件: prog.c 项目: tigros/HookTools
/* create_prog_store()
Create a program store and its descendants or die.

The program store holds some basic program and system info.
*/
void create_prog_store( 
	struct prog **const out   // out deref
)
{
	struct prog *prog = NULL;
	
	FAIL_IF( !out );
	FAIL_IF( *out );
	
	
	/* allocate a prog store */
	prog = must_calloc( 1, sizeof( *prog ) );
	
	
	*out = prog;
	return;
}
示例#10
0
static int
test_newfree(void){
	struct disassembler *dis;

	dis = new_disassembler(0);
	FAIL_IF(dis == NULL);
	free_disassembler(dis);
	return 0;
}
示例#11
0
static int bug_conc1(MYSQL *mysql)
{
  mysql_real_connect(mysql, hostname, username, password, schema,
                     port, socketname, 0);
  diag("errno: %d", mysql_errno(mysql));
  FAIL_IF(mysql_errno(mysql) != CR_ALREADY_CONNECTED,
          "Expected errno=CR_ALREADY_CONNECTED");
  return OK;
}
示例#12
0
/*
 * Test basic access to the EBB regs, they should be user accessible with no
 * kernel interaction required.
 */
int reg_access(void)
{
	uint64_t val, expected;

	expected = 0x8000000100000000ull;
	mtspr(SPRN_BESCR, expected);
	val = mfspr(SPRN_BESCR);

	FAIL_IF(val != expected);

	expected = 0x0000000001000000ull;
	mtspr(SPRN_EBBHR, expected);
	val = mfspr(SPRN_EBBHR);

	FAIL_IF(val != expected);

	return 0;
}
示例#13
0
void Test_ParseStringTwoTables(void)
{
	struct CfgParser * parser;
	char * string = \
		"TestTable0:\n"  \
		"    - TestValue0:  yes\n" \
		"TestTable1:\n"  \
		"    - TestValue1:  no\n";

	struct CfgTable table, table0, table1;
	bool b0 = false, b1 = true;

	struct CfgItem	items[2] =
	{
		{TYPE_TABLE, "TestTable0", &table0},
		{TYPE_TABLE, "TestTable1", &table1},
	};
	struct CfgItem	items0[1] =
	{
		{TYPE_BOOL, "TestValue0", &b0},
	};
	struct CfgItem	items1[1] =
	{
		{TYPE_BOOL, "TestValue1", &b1},
	};

	table1.count = 1;
	table1.items = items1;

	table0.count = 1;
	table0.items = items0;

	table.count = 2;
	table.items = items;

	parser = YamlCfgParser_Create();
	YamlCfgParser_SetTable(parser, &table);
	YamlCfgParser_ParseString(parser, string);

	FAIL_IF (b0 != true);
	FAIL_IF (b1 != false);

	PASS();
}
示例#14
0
static int test_bug19671(MYSQL *mysql)
{
  MYSQL_RES *result;
  MYSQL_FIELD *field;
  int rc, retcode= OK;


  rc= mysql_query(mysql, "set sql_mode=''");
  check_mysql_rc(rc, mysql);
  rc= mysql_query(mysql, "drop table if exists t1");
  check_mysql_rc(rc, mysql);

  rc= mysql_query(mysql, "drop view if exists v1");
  check_mysql_rc(rc, mysql);

  rc= mysql_query(mysql, "create table t1(f1 int)");
  check_mysql_rc(rc, mysql);

  rc= mysql_query(mysql, "create view v1 as select va.* from t1 va");
  check_mysql_rc(rc, mysql);

  rc= mysql_query(mysql, "SELECT * FROM v1");
  check_mysql_rc(rc, mysql);

  result= mysql_store_result(mysql);
  FAIL_IF(!result, "Invalid result set");

  field= mysql_fetch_field(result);
  FAIL_IF(!field, "Can't fetch field");

  if (strcmp(field->table, "v1") != 0) {
    diag("Wrong value '%s' for field_table. Expected 'v1'. (%s: %d)", field->table, __FILE__, __LINE__);
    retcode= FAIL;
  }

  mysql_free_result(result);

  rc= mysql_query(mysql, "drop view v1");
  check_mysql_rc(rc, mysql);
  rc= mysql_query(mysql, "drop table t1");
  check_mysql_rc(rc, mysql);

  return retcode;
}
示例#15
0
文件: sp.c 项目: dparnell/MariaDB
static int test_bug15752(MYSQL *mysql)
{
  int rc, i;
  const int ITERATION_COUNT= 100;
  const char *query= "CALL p1()";


  rc= mysql_query(mysql, "drop procedure if exists p1");
  check_mysql_rc(rc, mysql);
  rc= mysql_query(mysql, "create procedure p1() select 1");
  check_mysql_rc(rc, mysql);

  rc= mysql_real_query(mysql, query, strlen(query));
  check_mysql_rc(rc, mysql);
  mysql_free_result(mysql_store_result(mysql));

  rc= mysql_real_query(mysql, query, strlen(query));
  FAIL_UNLESS(rc && mysql_errno(mysql) == CR_COMMANDS_OUT_OF_SYNC, "Error expected");

  rc= mysql_next_result(mysql);
  check_mysql_rc(rc, mysql);

  mysql_free_result(mysql_store_result(mysql));

  rc= mysql_next_result(mysql);
  FAIL_IF(rc != -1, "rc != -1");

  for (i = 0; i < ITERATION_COUNT; i++)
  {
    rc= mysql_real_query(mysql, query, strlen(query));
    check_mysql_rc(rc, mysql);
    mysql_free_result(mysql_store_result(mysql));
    rc= mysql_next_result(mysql);
    check_mysql_rc(rc, mysql);
    mysql_free_result(mysql_store_result(mysql));
    rc= mysql_next_result(mysql);
    FAIL_IF(rc != -1, "rc != -1");

  }
  rc= mysql_query(mysql, "drop procedure p1");
  check_mysql_rc(rc, mysql);

  return OK;
}
示例#16
0
int test_connection_timeout3(MYSQL *my)
{
  unsigned int timeout= 5;
  unsigned int read_write_timeout= 10;
  int rc;
  time_t start, elapsed;
  MYSQL *mysql= mysql_init(NULL);
  mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (unsigned int *)&timeout);
  mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, (unsigned int *)&read_write_timeout);
  mysql_options(mysql, MYSQL_OPT_WRITE_TIMEOUT, (unsigned int *)&read_write_timeout);
  mysql_options(mysql, MYSQL_INIT_COMMAND, "set @a:=SLEEP(6)");
  start= time(NULL);
  if (mysql_real_connect(mysql, hostname, username, password, schema, port, NULL, CLIENT_REMEMBER_OPTIONS))
  {
    diag("timeout error expected");
    elapsed= time(NULL) - start;
    diag("elapsed: %lu", (unsigned long)elapsed);
    return FAIL;
  }
  elapsed= time(NULL) - start;
  diag("elapsed: %lu", (unsigned long)elapsed);
  FAIL_IF(elapsed > timeout + 1, "timeout ignored")

  mysql_close(mysql);
  mysql= mysql_init(NULL);
  mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (unsigned int *)&timeout);
  mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, (unsigned int *)&read_write_timeout);
  mysql_options(mysql, MYSQL_OPT_WRITE_TIMEOUT, (unsigned int *)&read_write_timeout);

  if (!mysql_real_connect(mysql, hostname, username, password, schema, port, NULL, CLIENT_REMEMBER_OPTIONS))
  {
    diag("Error: %s", mysql_error(mysql));
    return FAIL;
  }

  start= time(NULL);
  rc= mysql_query(mysql, "SET @a:=SLEEP(12)");
  elapsed= time(NULL) - start;
  diag("elapsed: %lu", (unsigned long)elapsed);
  FAIL_IF(!rc, "timeout expected");
  mysql_close(mysql);
  return OK;
}
示例#17
0
static int no_handler_test(void)
{
	struct event event;
	u64 val;
	int i;

	SKIP_IF(!ebb_is_supported());

	event_init_named(&event, 0x1001e, "cycles");
	event_leader_ebb_init(&event);

	event.attr.exclude_kernel = 1;
	event.attr.exclude_hv = 1;
	event.attr.exclude_idle = 1;

	FAIL_IF(event_open(&event));
	FAIL_IF(ebb_event_enable(&event));

	val = mfspr(SPRN_EBBHR);
	FAIL_IF(val != 0);

	/* Make sure it overflows quickly */
	sample_period = 1000;
	mtspr(SPRN_PMC1, pmc_sample_period(sample_period));

	/* Spin to make sure the event has time to overflow */
	for (i = 0; i < 1000; i++)
		mb();

	dump_ebb_state();

	/* We expect to see the PMU frozen & PMAO set */
	val = mfspr(SPRN_MMCR0);
	FAIL_IF(val != 0x0000000080000080);

	event_close(&event);

	dump_ebb_state();

	/* The real test is that we never took an EBB at 0x0 */

	return 0;
}
示例#18
0
static int
test_disassemble_instruction_x86(void){
	struct disassembler *dis;
	uint8_t inst[8];
	char line[512];
	size_t inst_size;

	dis = new_disassembler(0);
	FAIL_IF(dis == NULL);

	inst[0] = 0x90;
	disassemble_instruction(dis, inst, sizeof(inst), 0x100,
			line, sizeof(line),
			&inst_size);
	FAIL_IF(inst_size != 1);
	FAIL_IF(strncmp(line, "nop", 3) != 0);
	free_disassembler(dis);
	return 0;
}
示例#19
0
static bool
DUMMY_INJECT_COMPONENT (gcs_backend_t* backend, const gcs_comp_msg_t* comp)
{
    long ret = gcs_dummy_inject_msg (Backend, comp,
                                     gcs_comp_msg_size(comp),
                                     GCS_MSG_COMPONENT, GCS_SENDER_NONE);
    FAIL_IF (ret <= 0, "gcs_dummy_inject_msg(): %ld (%s)", ret, strerror(ret));

    return false;
}
示例#20
0
static int test_conc129(MYSQL *my)
{
  MYSQL *mysql;
  
  if (skip_async)
    return SKIP;

  mysql= mysql_init(NULL);
  FAIL_IF(mysql_close_start(mysql), "No error expected");
  return OK;
}
示例#21
0
static sljit_si emit_do_imm(struct sljit_compiler *compiler, sljit_ub opcode, sljit_sw imm)
{
	sljit_ub *inst;

	inst = (sljit_ub*)ensure_buf(compiler, 1 + 1 + sizeof(sljit_sw));
	FAIL_IF(!inst);
	INC_SIZE(1 + sizeof(sljit_sw));
	*inst++ = opcode;
	*(sljit_sw*)inst = imm;
	return SLJIT_SUCCESS;
}
示例#22
0
/*
 * server doesn't reset sql_mode after COM_CHANGE_USER
 */
int bug_41785(MYSQL *mysql)
{
  char out[10];
  int rc, len;

  len= mysql_real_escape_string(mysql, out, "\\", 1);
  FAIL_IF(len != 2, "len != 2");

  rc= mysql_query(mysql, "SET SQL_MODE=NO_BACKSLASH_ESCAPES");
  check_mysql_rc(rc, mysql);
  rc= mysql_query(mysql, "SET sql_mode=''");
  check_mysql_rc(rc, mysql);

  mysql_change_user(mysql, "root", "", "test");

  len= mysql_real_escape_string(mysql, out, "\\", 1);
  FAIL_IF(len != 2, "len != 2");

  return OK;
}
示例#23
0
int test_conc26(MYSQL *my)
{
  MYSQL *mysql= mysql_init(NULL);
  mysql_options(mysql, MYSQL_SET_CHARSET_NAME, "utf8");

  FAIL_IF(mysql_real_connect(mysql, hostname, "notexistinguser", "password", schema, port, NULL, CLIENT_REMEMBER_OPTIONS), 
          "Error expected");

  FAIL_IF(!mysql->options.charset_name || strcmp(mysql->options.charset_name, "utf8") != 0, 
          "expected charsetname=utf8");
  mysql_close(mysql);

  mysql= mysql_init(NULL);
  FAIL_IF(mysql_real_connect(mysql, hostname, "notexistinguser", "password", schema, port, NULL, 0), 
          "Error expected");
  FAIL_IF(mysql->options.charset_name, "Error: options not freed");
  mysql_close(mysql);

  return OK;
}
示例#24
0
static int emit_do_imm(struct sljit_compiler *compiler, sljit_ub opcode, sljit_w imm)
{
	sljit_ub *buf;

	buf = (sljit_ub*)ensure_buf(compiler, 1 + 1 + sizeof(sljit_w));
	FAIL_IF(!buf);
	INC_SIZE(1 + sizeof(sljit_w));
	*buf++ = opcode;
	*(sljit_w*)buf = imm;
	return SLJIT_SUCCESS;
}
示例#25
0
static int test_server_errors(MYSQL *mysql)
{
  int        rc;
  MYSQL_RES  *result;

  mysql_query(mysql, "DROP TABLE if exists test_non_exists");
  check_mysql_rc(rc, mysql); 

  rc= mysql_query(mysql, "DROP TABLE test_non_exists");

  mysql_query(mysql, "SHOW ERRORS");
  check_mysql_rc(rc, mysql); 

  result= mysql_store_result(mysql);
  FAIL_IF(!result, mysql_error(mysql));
  FAIL_IF(!mysql_num_rows(result), "Empty resultset");
  mysql_free_result(result);

  return OK;
}
示例#26
0
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw)
{
    sljit_ub *inst;

    CHECK_ERROR();
    CHECK(check_sljit_emit_fast_return(compiler, src, srcw));
    ADJUST_LOCAL_OFFSET(src, srcw);

    CHECK_EXTRA_REGS(src, srcw, (void)0);

    if (FAST_IS_REG(src)) {
        inst = (sljit_ub*)ensure_buf(compiler, 1 + 1 + 1);
        FAIL_IF(!inst);

        INC_SIZE(1 + 1);
        PUSH_REG(reg_map[src]);
    }
    else if (src & SLJIT_MEM) {
        inst = emit_x86_instruction(compiler, 1, 0, 0, src, srcw);
        FAIL_IF(!inst);
        *inst++ = GROUP_FF;
        *inst |= PUSH_rm;

        inst = (sljit_ub*)ensure_buf(compiler, 1 + 1);
        FAIL_IF(!inst);
        INC_SIZE(1);
    }
    else {
        /* SLJIT_IMM. */
        inst = (sljit_ub*)ensure_buf(compiler, 1 + 5 + 1);
        FAIL_IF(!inst);

        INC_SIZE(5 + 1);
        *inst++ = PUSH_i32;
        *(sljit_sw*)inst = srcw;
        inst += sizeof(sljit_sw);
    }

    RET();
    return SLJIT_SUCCESS;
}
示例#27
0
/**
 * \test Test only_frag matching.
 */
static int DetectFlowTestOnlyFragMatch(void)
{
    uint32_t pflags = 0;
    DetectFlowData *fd = DetectFlowParse("only_frag");
    FAIL_IF_NULL(fd);
    FAIL_IF_NOT(fd->flags & DETECT_FLOW_FLAG_ONLY_FRAG);
    FAIL_IF_NOT(fd->match_cnt == 1);
    FAIL_IF(FlowMatch(pflags, 0, 0, fd->flags, fd->match_cnt));
    pflags |= PKT_REBUILT_FRAGMENT;
    FAIL_IF_NOT(FlowMatch(pflags, 0, 0, fd->flags, fd->match_cnt));
    PASS;
}
示例#28
0
static sljit_si emit_load_imm64(struct sljit_compiler *compiler, sljit_si reg, sljit_sw imm)
{
    sljit_ub *inst;

    inst = (sljit_ub*)ensure_buf(compiler, 1 + 2 + sizeof(sljit_sw));
    FAIL_IF(!inst);
    INC_SIZE(2 + sizeof(sljit_sw));
    *inst++ = REX_W | ((reg_map[reg] <= 7) ? 0 : REX_B);
    *inst++ = MOV_r_i32 + (reg_map[reg] & 0x7);
    *(sljit_sw*)inst = imm;
    return SLJIT_SUCCESS;
}
示例#29
0
static sljit_s32 emit_load_imm64(struct sljit_compiler *compiler, sljit_s32 reg, sljit_sw imm)
{
	sljit_u8 *inst;

	inst = (sljit_u8*)ensure_buf(compiler, 1 + 2 + sizeof(sljit_sw));
	FAIL_IF(!inst);
	INC_SIZE(2 + sizeof(sljit_sw));
	*inst++ = REX_W | ((reg_map[reg] <= 7) ? 0 : REX_B);
	*inst++ = MOV_r_i32 + (reg_map[reg] & 0x7);
	sljit_unaligned_store_sw(inst, imm);
	return SLJIT_SUCCESS;
}
示例#30
0
int test_sp_reset(MYSQL *mysql)
{
 int i, rc;
  MYSQL_STMT *stmt;
  int a[] = {10,20,30};
  MYSQL_BIND bind[3];
  char *stmtstr= "CALL P1(?,?,?)";

  rc= mysql_query(mysql, "DROP PROCEDURE IF EXISTS p1");
  check_mysql_rc(rc, mysql);

  rc= mysql_query(mysql, "CREATE PROCEDURE p1(OUT p_out VARCHAR(19), IN p_in INT, INOUT p_inout INT)" 
                         "BEGIN "
                          "  SET p_in = 300, p_out := 'This is OUT param', p_inout = 200; "
                          "  SELECT p_inout, p_in, substring(p_out, 9);"
                         "END");
  check_mysql_rc(rc, mysql);

  stmt= mysql_stmt_init(mysql);
  check_mysql_rc(rc, mysql);

  rc= mysql_stmt_prepare(stmt, stmtstr, strlen(stmtstr));
  check_stmt_rc(rc, stmt);

  FAIL_IF(mysql_stmt_param_count(stmt) != 3, "expected param_count=3");

  memset(bind, 0, sizeof(MYSQL_BIND) * 3);
  for (i=0; i < 3; i++)
  {
    bind[i].buffer= &a[i];
    bind[i].buffer_type= MYSQL_TYPE_LONG;
  }
  bind[0].buffer_type= MYSQL_TYPE_NULL;
  rc= mysql_stmt_bind_param(stmt, bind);
  check_stmt_rc(rc, stmt);

  rc= mysql_stmt_execute(stmt);
  check_stmt_rc(rc, stmt);

  rc= mysql_stmt_fetch(stmt);
  check_stmt_rc(rc, stmt);

  rc= mysql_stmt_reset(stmt);
  check_stmt_rc(rc, stmt);

  /*connection shouldn't be blocked now */

  rc= mysql_query(mysql, "DROP PROCEDURE p1");
  check_mysql_rc(rc, mysql);

  rc= mysql_stmt_close(stmt);
  return OK;
}