예제 #1
0
int main(int argc, char *argv[])
{
    int i, size = 100, *x;
    struct set *s, *t, *u;
    
    if (argc > 1)
	size = atoi(argv[1]);
    
    srand(time(NULL));

    s = set_create(size, sizeof(int), cmpint);
    t = set_create(size, sizeof(int), cmpint);
    if (s == NULL || t == NULL){
	printf("Unable to create the test set\n");
	return 1;
    }

    printf("Inserting into first set...\n");
    for (i = 0; i < size; i++){
	int y = rand() % size;

	printf("%d ", y);
	set_insert(s, &y);
    }
    printf("\n\n");

    printf("The set contains:\n");
    for (set_reset(s), x = set_next(s); x != NULL; x = set_next(s)) 
	printf("%d ", *x);
    printf("\n\n");

    printf("Inserting into second set...\n");
    for (i = 0; i < size; i++){
	int y = rand() % size;

	printf("%d ", y);
	set_insert(t, &y);
    }
    printf("\n\n");

    printf("The set contains:\n");
    for (set_reset(t), x = set_next(t); x != NULL; x = set_next(t)) 
	printf("%d ", *x);
    printf("\n\n");

    u = set_union(s, t);
    printf("The union of the two sets is:\n");
    for (set_reset(u), x = set_next(u); x != NULL; x = set_next(u)) 
	printf("%d ", *x);
    printf("\n\n");
    set_destroy(u);

    u = set_diff(s, t);
    printf("The difference of the two sets is:\n");
    for (set_reset(u), x = set_next(u); x != NULL; x = set_next(u)) 
	printf("%d ", *x);
    printf("\n\n");
    
    return 0;
}
예제 #2
0
// write '1' to turn on power, '0' to turn it off
// write 'w' to set BT WAKE to 0,  'W' to set BT WAKE to 1
// write 'a' to trigger A2DP mode transition to send broadcom VSC for BT prioritization [disabled, built-in to FroYo]
int bt_power_write_proc(struct file *file, const char *buffer, unsigned long count, void *data)
{
  //  extern int A2DP_prioritization_trigger;
  
  if(copy_from_user(proc_buf, buffer, 1)) {return(-EFAULT);}
  
  //  if('a' == *proc_buf)
  //    {
  //      printk(KERN_INFO "BLUETOOTH: A2DP VSC for BT prioritization triggered (was %d)\n",
  //	     A2DP_prioritization_trigger);
  //      A2DP_prioritization_trigger = 2;
  //      return(0);
  //    }
  
  if('w' == *proc_buf)
    {
      set_bt_wake(0);
      printk(KERN_INFO "BLUETOOTH: BT_WAKE: low\n");
      return(0);
    }
  
  if('W' == *proc_buf)
    {
      set_bt_wake(1);
      printk(KERN_INFO "BLUETOOTH: BT_WAKE: high\n");
      return(0);
    }
  
  if('1' == *proc_buf)
    {
      if(!power_is_on)
	{
	  set_power(1);  // turn power on to BT module
	  set_reset(1);  // take BT out of reset
	  
	  power_is_on = 1;
	  printk(KERN_INFO "BLUETOOTH: bt_power: ON\n");
	}
    }
  else
    {
      if(power_is_on)
	{
	  set_reset(0);  // put BT into reset
	  set_power(0);  // turn off internal BT VREG
	  
	  power_is_on = 0;
	  printk(KERN_INFO "BLUETOOTH: bt_power: OFF\n");
	}
    }

  return(0);
}
예제 #3
0
/*@ 
   set_equals - compare two sets

Input arguments:
- s,t - The sets

Output arguments:
None

Returns:
0 if the sets are not equal, 1 if they are equal
@*/
int set_equals(struct set *s, struct set *t)
{
	if ((s->size != t->size) || (s->elemsize != t->elemsize))
		return 0;

	set_reset(s);
	set_reset(t);
	
	if (memcmp(s->buf, t->buf, s->size * s->elemsize) == 0)
		return 1;

	return 0;
}
예제 #4
0
/*
 * issue the 'program enable' command to the AVR device
 */
static int ft245r_program_enable(PROGRAMMER * pgm, AVRPART * p) {
    int retry_count = 0;
    unsigned char cmd[4];
    unsigned char res[4];
    int i,reset_ok;

    ft245r_set_bitclock(pgm);

retry:
    reset_ok = 0;
    set_reset(pgm, 0);
    usleep(5000); // 5ms
    set_reset(pgm, 1);
    usleep(5000); // 5ms
    set_reset(pgm, 0);
    usleep(5000); // 5ms

    cmd[0] = 0xAC;
    cmd[1] = 0x53;
    cmd[2] = 0;
    cmd[3] = 0;
    ft245r_cmd(pgm, cmd, res);
    if (res[2] == 0x53 ) reset_ok = 1;
    for (i=0; i<3; i++) {
        cmd[0] = 0x30;
        cmd[1] = 0;
        cmd[2] = i;
        cmd[3] = 0;
        ft245r_cmd(pgm, cmd, res);
        saved_signature[i] = res[3];
    }
    if (reset_ok && (saved_signature[0] == 0x1e)) // success
        return 0;

    if (retry_count < 5) {
        if (retry_count == 3) {
            ft245r_drain (pgm, 0);
            tail = head;
        }
        retry_count++;
        goto retry;
    }
    if ((verbose>=1) || FT245R_DEBUG) {
        fprintf(stderr,
                "%s: ft245r_program_enable: failed\n", progname);
        fflush(stderr);
    }
    return -1;
}
예제 #5
0
/*@ 
   set_union - find the union of two sets

Input arguments:
+ s - The first set
- t - The second set

Output arguments:
None

Returns:
A new set that is the union of the two input sets if successful,
NULL otherwise.

Notes:
s and t must contain the same types of elements
@*/
struct set *set_union(struct set *s, struct set *t)
{
    void * e;
    struct set *tmp, *u, *v; 

    /* Try to make sure that these two sets contain the same types */
    if (s->cmp != t->cmp || s->elemsize != t->elemsize)
	return NULL;
    
    /* Whichever set we iterate over should be smaller because iteration is O(n) */
    /* while bsearch is O(log n) */
    if (s->size < t->size)
	u = s, v = t;
    else 
	u = t, v = s;

    tmp = set_copy(v);
    if (tmp == NULL)
	return NULL;
    
    /* Insert all the elements of u not in v */
    for (set_reset(u), e = set_next(u); e != NULL; e = set_next(u)){
	if (!set_exists(v, e))
	    set_insert(tmp, e);
    }

    return tmp;
}
예제 #6
0
static int cmd_set_real(irc_t *irc, char **cmd, set_t **head, cmd_set_checkflags checkflags)
{
	char *set_name = NULL, *value = NULL;
	gboolean del = FALSE;

	if (cmd[1] && g_strncasecmp(cmd[1], "-del", 4) == 0) {
		MIN_ARGS(2, 0);
		set_name = cmd[2];
		del = TRUE;
	} else {
		set_name = cmd[1];
		value = cmd[2];
	}

	if (set_name && (value || del)) {
		set_t *s = set_find(head, set_name);
		int st;

		if (s && s->flags & SET_LOCKED) {
			irc_rootmsg(irc, "This setting can not be changed");
			return 0;
		}
		if (s && checkflags && checkflags(irc, s) == 0) {
			return 0;
		}

		if (del) {
			st = set_reset(head, set_name);
		} else {
			st = set_setstr(head, set_name, value);
		}

		if (set_getstr(head, set_name) == NULL &&
		    set_find(head, set_name)) {
			/* This happens when changing the passwd, for example.
			   Showing these msgs instead gives slightly clearer
			   feedback. */
			if (st) {
				irc_rootmsg(irc, "Setting changed successfully");
			} else {
				irc_rootmsg(irc, "Failed to change setting");
			}
		} else {
			cmd_showset(irc, head, set_name);
		}
	} else if (set_name) {
		cmd_showset(irc, head, set_name);
	} else {
		set_t *s = *head;
		while (s) {
			if (set_isvisible(s)) {
				cmd_showset(irc, &s, s->key);
			}
			s = s->next;
		}
	}

	return 1;
}
예제 #7
0
void
reset_option_to_default(const char name[])
{
	opt_t *opt = find_option(name);
	if(opt != NULL)
	{
		set_reset(opt);
	}
}
예제 #8
0
static int __init bt_power_init(void)
{
  bluetooth_gpio_init();

  //  if (create_proc_read_entry("bt_power", 0, NULL, bt_power_read_proc,NULL) == 0) 
  proc_entry = create_proc_entry("bt_power", 0666, NULL);
  if(!proc_entry)
    {
      printk(KERN_ERR "BLUETOOTH: Registration of proc \"bt_power\" file failed\n");
      return(-ENOMEM);
    }

  proc_entry->read_proc  = bt_power_read_proc;
  proc_entry->write_proc = bt_power_write_proc;

  printk(KERN_INFO "BLUETOOTH: /proc/bt_power created\n");

  {
    proc_entry = create_proc_entry("bt_stat", 0666, NULL);
    if(!proc_entry)
      {
	printk(KERN_ERR "BLUETOOTH: Registration of proc \"bt_stat\" file failed\n");
	return(-ENOMEM);
      }
    
    proc_entry->read_proc  = bt_stat_read_proc;
    proc_entry->write_proc = 0;
    
    printk(KERN_INFO "BLUETOOTH: /proc/bt_stat created\n");
  }

  {
    proc_entry = create_proc_entry("bt_status", 0666, NULL);
    if(!proc_entry)
      {
	printk(KERN_ERR "BLUETOOTH: Registration of proc \"bt_status\" file failed\n");
	return(-ENOMEM);
      }
    
    proc_entry->read_proc  = bt_status_read_proc;
    proc_entry->write_proc = 0;
    
    printk(KERN_INFO "BLUETOOTH: /proc/bt_status created\n");
  }

  { // turn off power to BT and hold it in reset
    set_reset(0);  // put BT into reset
    set_power(0);  // turn off internal BT VREG
    printk(KERN_INFO "BLUETOOTH: bt_power: Bluetooth power is off, and BT module is in reset.\n");
    
    power_is_on = 0;
  }
  
  return 0;
}
예제 #9
0
void
reset_options_to_default(void)
{
	int i;
	for(i = 0; i < options_count; i++)
	{
		if(options[i].full != NULL)
			continue;
		set_reset(&options[i]);
	}
}
예제 #10
0
파일: ft245r.c 프로젝트: dreimers/avrdude
/*
 * initialize the AVR device and prepare it to accept commands
 */
static int ft245r_initialize(PROGRAMMER * pgm, AVRPART * p) {

    /* Apply power between VCC and GND while RESET and SCK are set to “0”. In some systems,
     * the programmer can not guarantee that SCK is held low during power-up. In this
     * case, RESET must be given a positive pulse of at least two CPU clock cycles duration
     * after SCK has been set to “0”.
     */
    set_sck(pgm, OFF);
    ft245r_powerup(pgm);

    set_reset(pgm, OFF);
    usleep(5000); // 5ms
    set_reset(pgm, ON);
    usleep(5000); // 5ms
    set_reset(pgm, OFF);

    /* Wait for at least 20 ms and enable serial programming by sending the Programming
     * Enable serial instruction to pin MOSI.
     */
    usleep(20000); // 20ms

    return ft245r_program_enable(pgm, p);
}
예제 #11
0
파일: ft245r.c 프로젝트: dreimers/avrdude
static void ft245r_enable(PROGRAMMER * pgm) {
  /*
   * Prepare to start talking to the connected device - pull reset low
   * first, delay a few milliseconds, then enable the buffer.  This
   * sequence allows the AVR to be reset before the buffer is enabled
   * to avoid a short period of time where the AVR may be driving the
   * programming lines at the same time the programmer tries to.  Of
   * course, if a buffer is being used, then the /RESET line from the
   * programmer needs to be directly connected to the AVR /RESET line
   * and not via the buffer chip.
   */
    set_reset(pgm, OFF);
    usleep(1);
    set_buff(pgm, ON);
}
예제 #12
0
/**
 * Implemented #set_eval for the set of password. If the account is on,
 * this disables the account, and resets the token. Then the plugin
 * will force the authentication process with the new password.
 *
 * @param set   The #set_t.
 * @param value The set value.
 *
 * @return The resulting set value.
 **/
static char *steam_eval_password(set_t *set, char *value)
{
    account_t *acc = set->data;

    value = set_eval_account(set, value);
    set_reset(&acc->set, "token");

    if (acc->ic != NULL) {
        account_off(acc->bee, acc);
        account_on(acc->bee, acc);
    } else if (acc->reconnect != 0) {
        account_on(acc->bee, acc);
    }

    return value;
}
예제 #13
0
/*@ 
   set_union - find the difference of two sets

Input arguments:
+ s - The first set
- t - The second set

Output arguments:
None

Returns:
A new set that contains all the elements of s not in t,
NULL otherwise.

Notes:
s and t must contain the same types of elements
@*/
struct set *set_diff(struct set *s, struct set *t)
{
    void * e;
    struct set *tmp;

    /* Try to make sure that these two sets contain the same types */
    if (s->cmp != t->cmp || s->elemsize != t->elemsize)
	return NULL;
    
    tmp = set_create(s->maxsize+t->maxsize, s->elemsize, s->cmp);
    if (tmp == NULL)
	return NULL;

    /* Insert all the elements of s not in t */
    for (set_reset(s), e = set_next(s); e != NULL; e = set_next(s)){
	if (!set_exists(t, e))
	    set_insert(tmp, e);
    }

    return tmp;
}
예제 #14
0
파일: serial.c 프로젝트: jcmfernandes/ck
int
main(int argc, char *argv[])
{
	FILE *fp;
	char buffer[512];
	size_t i, j, r;
	unsigned int d = 0;
	uint64_t s, e, a, ri, si, ai, sr, rg, sg, ag, sd, ng;
	struct ck_hs_stat st;
	char **t;

	r = 20;
	s = 8;
	srand(time(NULL));

	if (argc < 2) {
		ck_error("Usage: ck_hs <dictionary> [<repetitions> <initial size>]\n");
	}

	if (argc >= 3)
		r = atoi(argv[2]);

	if (argc >= 4)
		s = (uint64_t)atoi(argv[3]);

	keys = malloc(sizeof(char *) * keys_capacity);
	assert(keys != NULL);

	fp = fopen(argv[1], "r");
	assert(fp != NULL);

	while (fgets(buffer, sizeof(buffer), fp) != NULL) {
		buffer[strlen(buffer) - 1] = '\0';
		keys[keys_length++] = strdup(buffer);
		assert(keys[keys_length - 1] != NULL);

		if (keys_length == keys_capacity) {
			t = realloc(keys, sizeof(char *) * (keys_capacity *= 2));
			assert(t != NULL);
			keys = t;
		}
	}

	t = realloc(keys, sizeof(char *) * keys_length);
	assert(t != NULL);
	keys = t;

	set_init();
	for (i = 0; i < keys_length; i++)
		d += set_insert(keys[i]) == false;
	ck_hs_stat(&hs, &st);

	fprintf(stderr, "# %zu entries stored, %u duplicates, %u probe.\n",
	    set_count(), d, st.probe_maximum);

	fprintf(stderr, "#    reverse_insertion serial_insertion random_insertion serial_replace reverse_get serial_get random_get serial_remove negative_get\n\n");

	a = 0;
	for (j = 0; j < r; j++) {
		if (set_reset() == false) {
			ck_error("ERROR: Failed to reset hash table.\n");
		}

		s = rdtsc();
		for (i = keys_length; i > 0; i--)
			d += set_insert(keys[i - 1]) == false;
		e = rdtsc();
		a += e - s;
	}
	ri = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		if (set_reset() == false) {
			ck_error("ERROR: Failed to reset hash table.\n");
		}

		s = rdtsc();
		for (i = 0; i < keys_length; i++)
			d += set_insert(keys[i]) == false;
		e = rdtsc();
		a += e - s;
	}
	si = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		keys_shuffle(keys);

		if (set_reset() == false) {
			ck_error("ERROR: Failed to reset hash table.\n");
		}

		s = rdtsc();
		for (i = 0; i < keys_length; i++)
			d += set_insert(keys[i]) == false;
		e = rdtsc();
		a += e - s;
	}
	ai = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		for (i = 0; i < keys_length; i++)
			set_replace(keys[i]);
		e = rdtsc();
		a += e - s;
	}
	sr = a / (r * keys_length);

	set_reset();
	for (i = 0; i < keys_length; i++)
		set_insert(keys[i]);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		for (i = keys_length; i > 0; i--) {
			if (set_get(keys[i - 1]) == NULL) {
				ck_error("ERROR: Unexpected NULL value.\n");
			}
		}
		e = rdtsc();
		a += e - s;
	}
	rg = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		for (i = 0; i < keys_length; i++) {
			if (set_get(keys[i]) == NULL) {
				ck_error("ERROR: Unexpected NULL value.\n");
			}
		}
		e = rdtsc();
		a += e - s;
	}
	sg = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		keys_shuffle(keys);

		s = rdtsc();
		for (i = 0; i < keys_length; i++) {
			if (set_get(keys[i]) == NULL) {
				ck_error("ERROR: Unexpected NULL value.\n");
			}
		}
		e = rdtsc();
		a += e - s;
	}
	ag = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		for (i = 0; i < keys_length; i++)
			set_remove(keys[i]);
		e = rdtsc();
		a += e - s;

		for (i = 0; i < keys_length; i++)
			set_insert(keys[i]);
	}
	sd = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		for (i = 0; i < keys_length; i++) {
			set_get("\x50\x03\x04\x05\x06\x10");
		}
		e = rdtsc();
		a += e - s;
	}
	ng = a / (r * keys_length);

	printf("%zu "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 "\n",
	    keys_length, ri, si, ai, sr, rg, sg, ag, sd, ng);

	return 0;
}
예제 #15
0
/* Processes one :set statement.  Returns zero on success. */
static int
process_option(const char arg[])
{
	char option[OPTION_NAME_MAX + 1];
	int err;
	const char *p;
	opt_t *opt;

	p = skip_alphas(arg);

	snprintf(option, p - arg + 1, "%s", arg);

	if(strcmp(option, "all") == 0)
	{
		print_options();
		return 0;
	}

	opt = get_option(option);
	if(opt == NULL)
	{
		text_buffer_addf("%s: %s", "Unknown option", arg);
		return 1;
	}

	err = 0;
	if(*p == '\0')
	{
		opt_t *o = find_option(option);
		if(o != NULL)
		{
			if(o->type == OPT_BOOL)
				err = set_on(opt);
			else
				err = set_print(o);
		}
		else if(strncmp(option, "no", 2) == 0)
		{
			err = set_off(opt);
		}
		else if(strncmp(option, "inv", 3) == 0)
		{
			err = set_inv(opt);
		}
	}
	else if(char_is_one_of(ENDING_CHARS, *p))
	{
		if(*(p + 1) != '\0')
		{
			text_buffer_addf("%s: %s", "Trailing characters", arg);
			return 1;
		}
		if(*p == '!')
			err = set_inv(opt);
		else if(*p == '?')
			err = set_print(opt);
		else
			err = set_reset(opt);
	}
	else if(strncmp(p, "+=", 2) == 0)
	{
		err = set_add(opt, p + 2);
	}
	else if(strncmp(p, "-=", 2) == 0)
	{
		err = set_remove(opt, p + 2);
	}
	else if(*p == '=' || *p == ':')
	{
		err = set_set(opt, p + 1);
	}
	else
	{
		text_buffer_addf("%s: %s", "Trailing characters", arg);
	}

	if(err)
	{
		text_buffer_addf("%s: %s", "Invalid argument", arg);
	}
	return err;
}
예제 #16
0
파일: serial.c 프로젝트: aerospike/ck
static void
run_test(const char *file, size_t r, unsigned int size, unsigned int mode)
{
	FILE *fp;
	char buffer[512];
	size_t i, j;
	unsigned int d = 0;
	uint64_t s, e, a, ri, si, ai, sr, rg, sg, ag, sd, ng, ss, sts, su, sgc, sb;
	struct ck_hs_stat st;
	char **t;

	keys = malloc(sizeof(char *) * keys_capacity);
	assert(keys != NULL);

	fp = fopen(file, "r");
	assert(fp != NULL);

	while (fgets(buffer, sizeof(buffer), fp) != NULL) {
		buffer[strlen(buffer) - 1] = '\0';
		keys[keys_length++] = strdup(buffer);
		assert(keys[keys_length - 1] != NULL);

		if (keys_length == keys_capacity) {
			t = realloc(keys, sizeof(char *) * (keys_capacity *= 2));
			assert(t != NULL);
			keys = t;
		}
	}

	t = realloc(keys, sizeof(char *) * keys_length);
	assert(t != NULL);
	keys = t;

	set_init(size, mode);
	for (i = 0; i < keys_length; i++)
		d += set_insert(keys[i]) == false;
	ck_hs_stat(&hs, &st);

	fprintf(stderr, "# %zu entries stored, %u duplicates, %u probe.\n",
	    set_count(), d, st.probe_maximum);

	a = 0;
	for (j = 0; j < r; j++) {
		if (set_reset() == false) {
			ck_error("ERROR: Failed to reset hash table.\n");
		}

		s = rdtsc();
		for (i = keys_length; i > 0; i--)
			d += set_insert(keys[i - 1]) == false;
		e = rdtsc();
		a += e - s;
	}
	ri = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		if (set_reset() == false) {
			ck_error("ERROR: Failed to reset hash table.\n");
		}

		s = rdtsc();
		for (i = 0; i < keys_length; i++)
			d += set_insert(keys[i]) == false;
		e = rdtsc();
		a += e - s;
	}
	si = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		keys_shuffle(keys);

		if (set_reset() == false) {
			ck_error("ERROR: Failed to reset hash table.\n");
		}

		s = rdtsc();
		for (i = 0; i < keys_length; i++)
			d += set_insert(keys[i]) == false;
		e = rdtsc();
		a += e - s;
	}
	ai = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		for (i = 0; i < keys_length; i++)
			set_swap(keys[i]);
		e = rdtsc();
		a += e - s;
	}
	ss = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		for (i = 0; i < keys_length; i++)
			set_replace(keys[i]);
		e = rdtsc();
		a += e - s;
	}
	sr = a / (r * keys_length);

	set_reset();
	for (i = 0; i < keys_length; i++)
		set_insert(keys[i]);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		for (i = keys_length; i > 0; i--) {
			if (set_get(keys[i - 1]) == NULL) {
				ck_error("ERROR: Unexpected NULL value.\n");
			}
		}
		e = rdtsc();
		a += e - s;
	}
	rg = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		for (i = 0; i < keys_length; i++) {
			if (set_get(keys[i]) == NULL) {
				ck_error("ERROR: Unexpected NULL value.\n");
			}
		}
		e = rdtsc();
		a += e - s;
	}
	sg = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		keys_shuffle(keys);

		s = rdtsc();
		for (i = 0; i < keys_length; i++) {
			if (set_get(keys[i]) == NULL) {
				ck_error("ERROR: Unexpected NULL value.\n");
			}
		}
		e = rdtsc();
		a += e - s;
	}
	ag = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		for (i = 0; i < keys_length; i++)
			set_remove(keys[i]);
		e = rdtsc();
		a += e - s;

		for (i = 0; i < keys_length; i++)
			set_insert(keys[i]);
	}
	sd = a / (r * keys_length);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		for (i = 0; i < keys_length; i++) {
			set_get("\x50\x03\x04\x05\x06\x10");
		}
		e = rdtsc();
		a += e - s;
	}
	ng = a / (r * keys_length);

	set_reset();
	for (i = 0; i < keys_length; i++)
		set_insert(keys[i]);
	for (i = 0; i < keys_length; i++)
		set_remove(keys[i]);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		for (i = 0; i < keys_length; i++)
			set_insert(keys[i]);
		e = rdtsc();
		a += e - s;

		for (i = 0; i < keys_length; i++)
			set_remove(keys[i]);
	}
	sts = a / (r * keys_length);

	set_reset();

	/* Prune duplicates. */
	for (i = 0; i < keys_length; i++) {
		if (set_insert(keys[i]) == true)
			continue;

		free(keys[i]);
		keys[i] = keys[--keys_length];
	}

	for (i = 0; i < keys_length; i++)
		set_remove(keys[i]);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		for (i = 0; i < keys_length; i++)
			set_insert_unique(keys[i]);
		e = rdtsc();
		a += e - s;

		for (i = 0; i < keys_length; i++)
			set_remove(keys[i]);
	}
	su = a / (r * keys_length);

	for (i = 0; i < keys_length; i++)
		set_insert_unique(keys[i]);

	for (i = 0; i < keys_length / 2; i++)
		set_remove(keys[i]);

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		set_gc();
		e = rdtsc();
		a += e - s;
	}
	sgc = a / r;

	a = 0;
	for (j = 0; j < r; j++) {
		s = rdtsc();
		set_rebuild();
		e = rdtsc();
		a += e - s;
	}
	sb = a / r;

	printf("%zu "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 " "
	    "%" PRIu64 "\n",
	    keys_length, ri, si, ai, ss, sr, rg, sg, ag, sd, ng, sts, su, sgc, sb);

	fclose(fp);

	for (i = 0; i < keys_length; i++) {
		free(keys[i]);
	}

	free(keys);
	keys_length = 0;
	set_destroy();
	return;
}