Exemple #1
0
static unsigned char *
dump_envelope(ENVELOPE * e, unsigned char *d, int *off, int convert)
{
  d = dump_address(e->return_path, d, off, convert);
  d = dump_address(e->from, d, off, convert);
  d = dump_address(e->to, d, off, convert);
  d = dump_address(e->cc, d, off, convert);
  d = dump_address(e->bcc, d, off, convert);
  d = dump_address(e->sender, d, off, convert);
  d = dump_address(e->reply_to, d, off, convert);
  d = dump_address(e->mail_followup_to, d, off, convert);

  d = dump_char(e->list_post, d, off, convert);
  d = dump_char(e->subject, d, off, convert);

  if (e->real_subj)
    d = dump_int(e->real_subj - e->subject, d, off);
  else
    d = dump_int(-1, d, off);

  d = dump_char(e->message_id, d, off, 0);
  d = dump_char(e->supersedes, d, off, 0);
  d = dump_char(e->date, d, off, 0);
  d = dump_char(e->x_label, d, off, convert);

  d = dump_buffer(e->spam, d, off, convert);

  d = dump_list(e->references, d, off, 0);
  d = dump_list(e->in_reply_to, d, off, 0);
  d = dump_list(e->userhdrs, d, off, convert);

  return d;
}
static idn_result_t
additem_to_top(idn__aliaslist_t list,
	       const char *pattern, const char *encoding) {
	aliasitem_t new_item;
	idn_result_t r;

	TRACE(("additem_to_top()\n"));

	assert(list != NULL);
	assert(pattern != NULL);
	assert(encoding != NULL);

	if ((r = create_item(pattern, encoding, &new_item))
	    != idn_success) {
		WARNING(("additem_to_top: malloc failed\n"));
		return (r);
	}

	new_item->next = list->first_item;
	list->first_item = new_item;

#ifdef DEBUG
	dump_list(list);
#endif

	return (idn_success);
}
Exemple #3
0
static
#ifdef KMP_INLINE_SUBR
__forceinline
#endif
struct private_common *
__kmp_threadprivate_find_task_common( struct common_table *tbl, int gtid, void *pc_addr )

{
    struct private_common *tn;

#ifdef KMP_TASK_COMMON_DEBUG
    KC_TRACE( 10, ( "__kmp_threadprivate_find_task_common: thread#%d, called with address %p\n",
                    gtid, pc_addr ) );
    dump_list();
#endif

    for (tn = tbl->data[ KMP_HASH(pc_addr) ]; tn; tn = tn->next) {
        if (tn->gbl_addr == pc_addr) {
#ifdef KMP_TASK_COMMON_DEBUG
            KC_TRACE( 10, ( "__kmp_threadprivate_find_task_common: thread#%d, found node %p on list\n",
                            gtid, pc_addr ) );
#endif
            return tn;
        }
    }
    return 0;
}
Exemple #4
0
/* dump the checkers_queue */
void
dump_checkers_queue(void)
{
	if (!LIST_ISEMPTY(checkers_queue)) {
		log_message(LOG_INFO, "------< Health checkers >------");
		dump_list(checkers_queue);
	}
}
Exemple #5
0
static gint
idle_dump_callback (gpointer unused_data)
{
	dump_list ();
	idle_dump_id = 0;

	return FALSE;
}
Exemple #6
0
/*
 * Callback for whenever we've been requested to dump our
 * configuration.
 */
static void
dump_smtp_check(void *data)
{
	smtp_checker_t *smtp_checker = CHECKER_DATA(data);
	log_message(LOG_INFO, "   Keepalive method = SMTP_CHECK");
	log_message(LOG_INFO, "           helo = %s", smtp_checker->helo_name);
	log_message(LOG_INFO, "           retry = %d", smtp_checker->retry);
	log_message(LOG_INFO, "           delay before retry = %ld", smtp_checker->db_retry/TIMER_HZ);
	dump_list(smtp_checker->host);
}
Exemple #7
0
/*
 *  Do some basic list manipulations and output to log for
 *  script comparison. Only testing the macros we use.
 */
int
main(int argc, char *argv[])
{
	PTEST_NODE pNode = NULL;

	START(argc, argv, "win_lists");

	LIST_INIT(&TestListHead);
	UT_ASSERT_rt(LIST_EMPTY(&TestListHead));

	pNode = allocNode();
	pNode->dummy = 0;
	LIST_INSERT_HEAD(&TestListHead, pNode, ListEntry);
	UT_ASSERTeq_rt(1, getListCount());
	dump_list();

	/* Remove one node */
	LIST_REMOVE(pNode, ListEntry);
	UT_ASSERTeq_rt(0, getListCount());
	dump_list();
	free(pNode);

	/* Add a bunch of nodes */
	for (int i = 1; i < 10; i++) {
		pNode = allocNode();
		pNode->dummy = i;
		LIST_INSERT_HEAD(&TestListHead, pNode, ListEntry);
	}
	UT_ASSERTeq_rt(9, getListCount());
	dump_list();

	/* Remove all of them */
	while (!LIST_EMPTY(&TestListHead)) {
		PTEST_NODE pNode = (PTEST_NODE)LIST_FIRST(&TestListHead);
		LIST_REMOVE(pNode, ListEntry);
		free(pNode);
	}
	UT_ASSERTeq_rt(0, getListCount());
	dump_list();

	DONE(NULL);
}
// checks if there are elements in the list that should be merged
static void check_consistency(struct memory_list* region)
{
    struct memory_ele* ele = region->buffers;
    while (ele->next != NULL) {
        if (ele->offset + ele->length == ele->next->offset) {
            printf("offset=%lu length=%lu \n", ele->offset, ele->length);
            dump_list(region);
            USER_PANIC("Found entry that should be merged \n");
        }
        ele = ele->next;
    }   
}
Exemple #9
0
//- Remove the data member's entry in the tree. Returns CUBIT_TRUE
//- if item removed, CUBIT_FALSE if item not in tree.
template <class Z> CubitBoolean KDDTree<Z>::remove (Z data)
{
  //// If the Add List is not empty, action must be taken
  if (myAddList.size() > 0)
  {
    if (mySelfBalancingOn == CUBIT_TRUE) // self-balancing is on, so rebalance the tree
    {
      balance ();
    }
    else // self-balancing is off, so put everything in the Add List onto the tree
    {
      dump_list ();
    }
  }

  //// Tree is empty
  if (root == NULL)
  {
    return CUBIT_FALSE;
  }
  //// Tree is not empty
  else
  {
    KDDTreeNode<Z> *P = find_node_containing_data (root, data);

    if (P == NULL) // no matching node was found
    {
      return CUBIT_FALSE;
    }
    else // mark the matching node for deletion
    {
      if (P->valid == CUBIT_FALSE)
      {
        return CUBIT_FALSE; // this node was already deleted
      }

      P->valid = CUBIT_FALSE; // set the node to be deleted

      myMarkedNodes++;
      if (myDeletionTolerance != 0)
      {
        if ( (( static_cast<double>(myMarkedNodes) / myNodeList.size()) > myDeletionTolerance) &&
             (myMarkedNodes > 1)
           )
        {
          balance ();
        }
      }

      return CUBIT_TRUE;
    }
  }
}
Exemple #10
0
/*
 * test_list - Do some basic list manipulations and output to log for
 * script comparison. Only testing the macros we use.
 */
static void
test_list(void)
{
	PTEST_LIST_NODE pNode = NULL;
	struct TestList head = LIST_HEAD_INITIALIZER(head);

	LIST_INIT(&head);
	UT_ASSERT_rt(LIST_EMPTY(&head));

	pNode = MALLOC(sizeof(struct TEST_LIST_NODE));
	pNode->dummy = 0;
	LIST_INSERT_HEAD(&head, pNode, ListEntry);
	UT_ASSERTeq_rt(1, get_list_count(&head));
	dump_list(&head);

	/* Remove one node */
	LIST_REMOVE(pNode, ListEntry);
	UT_ASSERTeq_rt(0, get_list_count(&head));
	dump_list(&head);
	free(pNode);

	/* Add a bunch of nodes */
	for (int i = 1; i < 10; i++) {
		pNode = MALLOC(sizeof(struct TEST_LIST_NODE));
		pNode->dummy = i;
		LIST_INSERT_HEAD(&head, pNode, ListEntry);
	}
	UT_ASSERTeq_rt(9, get_list_count(&head));
	dump_list(&head);

	/* Remove all of them */
	while (!LIST_EMPTY(&head)) {
		pNode = (PTEST_LIST_NODE)LIST_FIRST(&head);
		LIST_REMOVE(pNode, ListEntry);
		free(pNode);
	}
	UT_ASSERTeq_rt(0, get_list_count(&head));
	dump_list(&head);
}
errval_t debug_dump_region(struct debug_q* que, regionid_t rid) 
{
    errval_t err;
    // find region
    struct memory_list* region = NULL;

    err = find_region(que, &region, rid);
    if (err_is_fail(err)){
        return err;
    }

    dump_list(region);
    return SYS_ERR_OK;
}
Exemple #12
0
static void
dump_http_get_check(void *data)
{
	http_checker_t *http_get_chk = CHECKER_DATA(data);

	if (http_get_chk->proto == PROTO_HTTP)
		log_message(LOG_INFO, "   Keepalive method = HTTP_GET");
	else
		log_message(LOG_INFO, "   Keepalive method = SSL_GET");
	dump_conn_opts(CHECKER_CO(data));
	log_message(LOG_INFO, "   Nb get retry = %u", http_get_chk->nb_get_retry);
	log_message(LOG_INFO, "   Delay before retry = %lu",
	       http_get_chk->delay_before_retry/TIMER_HZ);
	dump_list(http_get_chk->url);
}
Exemple #13
0
int main (int argc, char *argv[])
{
	ssize_t	size;

	punyopt(argc, argv, NULL, NULL);

	size = listxattr(Option.file, List, sizeof(List));
	if (size == -1) {
		perror(Option.file);
		exit(2);
	}

	printf("xattrs for %s:\n", Option.file);
	dump_list(List, size);

	return 0;
}
Exemple #14
0
void dump_value_state (Value_State *value)
{
	fprintf (sim.fout, "\tvalue %s is %s\n", g_values[value->value_index], 
			 value->present ? "present" : "not present");

	if (sim.verbose)
	{	
		fprintf (sim.fout, "\t\tpresent csn: %d\n", value->presense_csn);
		fprintf (sim.fout, "\t\tdistinguished csn: %d\n", value->distinguished_csn);
		fprintf (sim.fout, "\t\tdelete value csn: %d\n", value->delete_csn);
		fprintf (sim.fout, "\t\tnon distinguished csns: ");

		dump_list (value->non_distinguished_csns);

		fprintf (sim.fout, "\n");	
	}
}
idn_result_t
idn__aliaslist_aliasfile(idn__aliaslist_t list, const char *path) {
	FILE *fp;
	int line_no;
	idn_result_t r = idn_success;
	char line[200], alias[200], real[200];

	assert(path != NULL);

	TRACE(("idn__aliaslist_aliasfile(path=%s)\n", path));

	if ((fp = fopen(path, "r")) == NULL) {
		return (idn_nofile);
	}
	for (line_no = 1; fgets(line, sizeof(line), fp) != NULL; line_no++) {
		unsigned char *p = (unsigned char *)line;

		while (isascii(*p) && isspace(*p))
			p++;
		if (*p == '#' || *p == '\n')
			continue;
		if (sscanf((char *)p, "%s %s", alias, real) == 2) {
			r = additem_to_bottom(list, alias, real);
			if (r != idn_success)
				break;
		} else {
			INFO(("idn__aliaslist_aliasfile: file %s has "
			      "invalid contents at line %d\n",
			      path, line_no));
			r = idn_invalid_syntax;
			break;
		}
	}
	fclose(fp);

#ifdef DEBUG
	dump_list(list);
#endif

	return (r);
}
Exemple #16
0
//- Find members intersecting this range box
template <class Z> CubitStatus KDDTree<Z>::find (const CubitBox &range_box, DLIList <Z> &range_members)
{
  //// If the Add List is not empty, action must be taken
  if (myAddList.size() > 0)
  {
    if (mySelfBalancingOn == CUBIT_TRUE) // self-balancing is on, so rebalance the tree
    {
      balance ();
    }
    else // self-balancing is off, so put everything in the Add List onto the tree
    {
      dump_list ();
    }
  }

  //// Find all of the members of the tree that intersect this range_box
  if (root != NULL)
  {
    recursive_find (root, range_box, range_members);
  }

  return CUBIT_SUCCESS;
}
Exemple #17
0
int main()
{
    ngx_pool_t *pool;
    int i;

    printf("--------------------------------\n");
    printf("create a new pool:\n");
    printf("--------------------------------\n");
    pool = ngx_create_pool(1024, NULL);
    dump_pool(pool);

    printf("--------------------------------\n");
    printf("alloc an list from the pool:\n");
    printf("--------------------------------\n");
    ngx_list_t *list = ngx_list_create(pool, 5, sizeof(int));
    dump_pool(pool);

    for (i = 0; i < 15; i++)
    {
        int *ptr = ngx_list_push(list);
        *ptr = i + 1;
    }

    printf("--------------------------------\n");
    printf("the list information:\n");
    printf("--------------------------------\n");
    dump_list(list);

    printf("--------------------------------\n");
    printf("the pool at the end:\n");
    printf("--------------------------------\n");
    dump_pool(pool);

    ngx_destroy_pool(pool);
    return 0;
}
Exemple #18
0
void dump(void* storage) {
    switch(*(char*)storage) {
        case 'd': {
            Dictionary* dict = (Dictionary*)storage;
            dump_dict(dict);
            break;
        }
        case 'l': {
            List* list = (List*)storage;
            dump_list(list);
            break;
        }
        case 's': {
            Value* val = (Value*)storage;
            printf("%s", (char*)val->value);
            break;
        }
        case 'i': {
            Value* val = (Value*)storage;
            printf("%d", *(int*)val->value);
            break;
        }
    }
}
Exemple #19
0
/* y = ax^b + c 
 * 	return 0 if success, -1 otherwise
 * 	if success, a, b and c are modified
 * */
int _starpu_regression_non_linear_power(struct starpu_history_list_t *ptr, double *a, double *b, double *c)
{
	unsigned n = find_list_size(ptr);

	unsigned *x = malloc(n*sizeof(unsigned));
	STARPU_ASSERT(x);

	double *y = malloc(n*sizeof(double));
	STARPU_ASSERT(y);

	dump_list(x, y, ptr);

	double cmin = 0.0;
	double cmax = find_list_min(y, n);
	
	unsigned iter;

	double err = 100000.0;

	for (iter = 0; iter < MAXREGITER; iter++)
	{
		double c1, c2;
		double r1, r2;
		
		double radius = 0.01;

		c1 = cmin + (0.5-radius)*(cmax - cmin);
		c2 = cmin + (0.5+radius)*(cmax - cmin);

		r1 = test_r(c1, n, x, y);
		r2 = test_r(c2, n, x, y);

		double err1, err2;
		err1 = fabs(1.0 - r1);
		err2 = fabs(1.0 - r2);

		if (err1 < err2)
		{
			cmax = (cmin + cmax)/2;
		}
		else {
			/* 2 is better */
			cmin = (cmin + cmax)/2;
		}

		if (fabs(err - STARPU_MIN(err1, err2)) < EPS)
		{
			err = STARPU_MIN(err1, err2);
			break;
		}

		err = STARPU_MIN(err1, err2);
	}

	*c = (cmin + cmax)/2;

	*b = compute_b(*c, n, x, y); 
	*a = exp(compute_a(*c, *b, n, x, y));

	free(x);
	free(y);

	return 0;
}
static errval_t debug_enqueue(struct devq* q, regionid_t rid, 
                              genoffset_t offset, genoffset_t length,
                              genoffset_t valid_data, genoffset_t valid_length,
                              uint64_t flags)
{
    assert(length > 0);
    DEBUG("enqueue offset %"PRIu64" \n", offset);
    errval_t err;
    struct debug_q* que = (struct debug_q*) q;

    // find region
    struct memory_list* region = NULL;

    err = find_region(que, &region, rid);
    if (err_is_fail(err)){
        return err;
    }
    
    check_consistency(region);

    // find the buffer 
    struct memory_ele* buffer = region->buffers;
    
    if (region->buffers == NULL) {
        return DEVQ_ERR_BUFFER_ALREADY_IN_USE;
    }    

    // the only buffer
    if (buffer->next == NULL) {
        if (buffer_in_bounds(offset, length,
                             buffer->offset, buffer->length)) {
            err = que->q->f.enq(que->q, rid, offset, length, valid_data,
                                valid_length, flags);
            if (err_is_fail(err)) {
                return err;
            }   

            remove_split_buffer(que, region, buffer, offset, length);
            return SYS_ERR_OK;          
        } else {
            printf("Bounds check failed only buffer offset=%lu length=%lu " 
                  " buf->offset=%lu buf->len=%lu\n", offset, length,
                  buffer->offset, buffer->length);
            dump_history(que);
            dump_list(region);
            return DEVQ_ERR_INVALID_BUFFER_ARGS;
        }
    }


    // more than one buffer
    while (buffer != NULL) {
        if (buffer_in_bounds(offset, length, 
                             buffer->offset, buffer->length)){
            err = que->q->f.enq(que->q, rid, offset, length, valid_data,
                                valid_length, flags);
            if (err_is_fail(err)) {
                return err;
            }   

            remove_split_buffer(que, region, buffer, offset, length);
            return SYS_ERR_OK;          
        }
        buffer = buffer->next;
    }  
    
    printf("Did not find region offset=%ld length=%ld \n", offset, length);
    dump_history(que);
    dump_list(region);

    return DEVQ_ERR_INVALID_BUFFER_ARGS;
}
static errval_t debug_deregister(struct devq* q, regionid_t rid) 
{
    DEBUG("Deregister \n");
    struct debug_q* que = (struct debug_q*) q;
    errval_t err;

    struct memory_list* ele = que->regions;
    if (ele == NULL) {
        return DEVQ_ERR_INVALID_REGION_ID;
    }    

    // remove head
    if (ele->rid == rid) {
        // there should only be a single element in the list
        // i.e. the whole region
        if (ele->buffers->offset == 0 &&
            ele->buffers->length == ele->length &&
            ele->buffers->next == NULL) {

            err = que->q->f.dereg(que->q, rid);
            if (err_is_fail(err)) {
                return err;
            }
            que->regions = ele->next;
        
            DEBUG("removed region rid=%"PRIu32" size=%"PRIu64" \n", rid, 
                  ele->length);

            slab_free(&que->alloc, ele->buffers);
            slab_free(&que->alloc_list, ele);

            return SYS_ERR_OK;
        } else {

            DEBUG("Destroy error rid=%d offset=%"PRIu64" length=%"PRIu64" "
                       "should be offset=0 length=%"PRIu64"\n",
                       ele->rid, ele->buffers->offset, 
                       ele->buffers->length, ele->length);
            dump_list(ele);
            return DEVQ_ERR_REGION_DESTROY;
        }   
    }
    
    while (ele->next != NULL) {
        if (ele->next->rid == rid) {
            if (ele->next->buffers->offset == 0 &&
                ele->next->buffers->length == ele->next->length &&
                ele->next->buffers->next == NULL) {
            
                err = que->q->f.dereg(que->q, rid);
                if (err_is_fail(err)) {
                    return err;
                }
                // remove from queue
                struct memory_list* next = ele->next;
                ele->next = ele->next->next;    

                DEBUG("removed region rid=%"PRIu32" size=%"PRIu64" \n", rid, 
                      next->length);
            
                slab_free(&que->alloc, next->buffers);
                slab_free(&que->alloc_list, next);

                return SYS_ERR_OK;
            } else {
                DEBUG("Destroy error rid=%d offset=%"PRIu64" length=%"PRIu64" "
                       "should be offset=0 length=%"PRIu64"\n",
                       ele->next->rid, ele->next->buffers->offset, 
                       ele->next->buffers->length, ele->next->length);
    
                dump_list(ele);
                return DEVQ_ERR_REGION_DESTROY;
            }   
        } else {
            ele = ele->next;
        }
    }
    

    return DEVQ_ERR_INVALID_REGION_ID;
}
Exemple #22
0
/* Daemon init sequence */
static void
start_vrrp(void)
{
	/* Initialize sub-system */
	init_interface_queue();
	kernel_netlink_init();
	gratuitous_arp_init();
	ndisc_init();

	global_data = alloc_global_data();

#ifdef _HAVE_LIBIPTC_
	iptables_init();
#endif

	/* Parse configuration file */
	vrrp_data = alloc_vrrp_data();
	init_data(conf_file, vrrp_init_keywords);
	if (!vrrp_data) {
		stop_vrrp();
		return;
	}
	init_global_data(global_data);

	/* Set the process priority and non swappable if configured */
	if (global_data->vrrp_process_priority)
		set_process_priority(global_data->vrrp_process_priority);

	if (global_data->vrrp_no_swap)
		set_process_dont_swap(4096);	/* guess a stack size to reserve */

#ifdef _WITH_SNMP_
	if (!reload && (global_data->enable_snmp_keepalived || global_data->enable_snmp_rfcv2 || global_data->enable_snmp_rfcv3)) {
		vrrp_snmp_agent_init(global_data->snmp_socket);
#ifdef _WITH_SNMP_RFC_
		vrrp_start_time = timer_now();
#endif
	}
#endif

#ifdef _WITH_LVS_
	if (vrrp_ipvs_needed()) {
		/* Initialize ipvs related */
		if (ipvs_start() != IPVS_SUCCESS) {
			stop_vrrp();
			return;
		}

#ifdef _HAVE_IPVS_SYNCD_
		/* If we are managing the sync daemon, then stop any
		 * instances of it that may have been running if
		 * we terminated abnormally */
		ipvs_syncd_cmd(IPVS_STOPDAEMON, NULL, IPVS_MASTER, 0, true);
		ipvs_syncd_cmd(IPVS_STOPDAEMON, NULL, IPVS_BACKUP, 0, true);
#endif
	}
#endif

	if (reload) {
		clear_diff_saddresses();
#ifdef _HAVE_FIB_ROUTING_
		clear_diff_srules();
		clear_diff_sroutes();
#endif
		clear_diff_vrrp();
		clear_diff_script();
	}
	else {
		/* Clear leftover static entries */
		netlink_iplist(vrrp_data->static_addresses, IPADDRESS_DEL);
#ifdef _HAVE_FIB_ROUTING_
		netlink_rtlist(vrrp_data->static_routes, IPROUTE_DEL);
		netlink_error_ignore = ENOENT;
		netlink_rulelist(vrrp_data->static_rules, IPRULE_DEL, true);
		netlink_error_ignore = 0;
#endif
	}

	/* Complete VRRP initialization */
	if (!vrrp_complete_init()) {
		if (vrrp_ipvs_needed()) {
			stop_vrrp();
		}
		return;
	}

#ifdef _HAVE_LIBIPTC_
	iptables_startup();
#endif

	/* Post initializations */
#ifdef _DEBUG_
	log_message(LOG_INFO, "Configuration is using : %lu Bytes", mem_allocated);
#endif

	/* Set static entries */
	netlink_iplist(vrrp_data->static_addresses, IPADDRESS_ADD);
#ifdef _HAVE_FIB_ROUTING_
	netlink_rtlist(vrrp_data->static_routes, IPROUTE_ADD);
	netlink_rulelist(vrrp_data->static_rules, IPRULE_ADD, false);
#endif

	/* Dump configuration */
	if (__test_bit(DUMP_CONF_BIT, &debug)) {
		list ifl;

		dump_global_data(global_data);
		dump_vrrp_data(vrrp_data);
		ifl = get_if_list();
		if (!LIST_ISEMPTY(ifl))
			dump_list(ifl);
	}

	/* Initialize linkbeat */
	init_interface_linkbeat();

	/* Init & start the VRRP packet dispatcher */
	thread_add_event(master, vrrp_dispatcher_init, NULL,
			 VRRP_DISPATCHER);
}
Exemple #23
0
static gint
on_idle_do_stuff (gpointer unused_data)
{
	GConfClient *client = gconf_client_get_default ();
	ESourceGroup *new_group = NULL;
	ESource *new_source = NULL;

	list = e_source_list_new_for_gconf (client, key_arg);
	g_object_unref (client);

	if (add_group_arg != NULL) {
		if (group_arg != NULL) {
			fprintf (stderr, "--add-group and --group cannot be used at the same time.\n");
			exit (1);
		}
		if (set_base_uri_arg == NULL) {
			fprintf (stderr, "When using --add-group, you need to specify a base URI using --set-base-uri.\n");
			exit (1);
		}

		new_group = e_source_group_new (add_group_arg, set_base_uri_arg);
		e_source_list_add_group (list, new_group, -1);
		g_object_unref (new_group);

		e_source_list_sync (list, NULL);
	}

	if (remove_group_arg != NULL) {
		ESourceGroup *group;

		group = e_source_list_peek_group_by_uid (list, remove_group_arg);
		if (group == NULL) {
			fprintf (stderr, "No such group \"%s\".\n", remove_group_arg);
			exit (1);
		}

		e_source_list_remove_group (list, group);
		e_source_list_sync (list, NULL);
	}

	if (add_source_arg != NULL) {
		ESourceGroup *group;

		if (group_arg == NULL && new_group == NULL) {
			fprintf (stderr,
				 "When using --add-source, you need to specify a group using either --group\n"
				 "or --add-group.\n");
			exit (1);
		}
		if (set_relative_uri_arg == NULL) {
			fprintf (stderr,
				 "When using --add-source, you need to specify a relative URI using\n"
				 "--set-relative-uri.\n");
			exit (1);
		}

		if (group_arg == NULL) {
			group = new_group;
		} else {
			group = e_source_list_peek_group_by_uid (list, group_arg);
			if (group == NULL) {
				fprintf (stderr, "No such group \"%s\".\n", group_arg == NULL ? add_group_arg : group_arg);
				exit (1);
			}
		}

		new_source = e_source_new (add_source_arg, set_relative_uri_arg);
		e_source_group_add_source (group, new_source, -1);
		e_source_list_sync (list, NULL);
	}

	if (remove_source_arg != NULL) {
		ESource *source;

		source = e_source_list_peek_source_by_uid (list, remove_source_arg);
		if (source == NULL) {
			fprintf (stderr, "No such source \"%s\".\n", remove_source_arg);
			exit (1);
		}

		e_source_list_remove_source_by_uid (list, remove_source_arg);
		e_source_list_sync (list, NULL);
	}

	if (set_name_arg != NULL) {
		if (group_arg == NULL && source_arg == NULL) {
			fprintf (stderr,
				 "When using --set-name, you need to specify a source (using --source"
				 "alone) or a group (using --group alone).\n");
			exit (1);
		}

		if (source_arg != NULL) {
			ESource *source = e_source_list_peek_source_by_uid (list, source_arg);

			if (source != NULL) {
				e_source_set_name (source, set_name_arg);
			} else {
				fprintf (stderr, "No such source \"%s\".\n", source_arg);
				exit (1);
			}
		} else {
			ESourceGroup *group = e_source_list_peek_group_by_uid (list, group_arg);

			if (group != NULL) {
				e_source_group_set_name (group, set_name_arg);
			} else {
				fprintf (stderr, "No such group \"%s\".\n", group_arg);
				exit (1);
			}
		}

		e_source_list_sync (list, NULL);
	}

	if (set_relative_uri_arg != NULL && add_source_arg == NULL) {
		ESource *source;

		if (source_arg == NULL) {
			fprintf (stderr,
				 "When using --set-relative-uri, you need to specify a source using "
				 "--source.\n");
			exit (1);
		}

		source = e_source_list_peek_source_by_uid (list, source_arg);
		e_source_set_relative_uri (source, set_relative_uri_arg);
		e_source_list_sync (list, NULL);
	}

	if (set_color_arg != NULL) {
		ESource *source;

		if (add_source_arg == NULL && source_arg == NULL) {
			fprintf (stderr,
				 "When using --set-color, you need to specify a source using --source\n");
			exit (1);
		}

		if (add_source_arg != NULL)
			source = new_source;
		else
			source = e_source_list_peek_source_by_uid (list, source_arg);

		e_source_set_color_spec (source, set_color_arg);
		e_source_list_sync (list, NULL);
	}

	if (unset_color) {
		ESource *source;

		if (add_source_arg == NULL && source_arg == NULL) {
			fprintf (stderr,
				 "When using --unset-color, you need to specify a source using --source\n");
			exit (1);
		}

		if (add_source_arg != NULL)
			source = new_source;
		else
			source = e_source_list_peek_source_by_uid (list, source_arg);

		e_source_set_color_spec (source, NULL);
		e_source_list_sync (list, NULL);
	}

	if (set_base_uri_arg != NULL && add_group_arg == NULL) {
		ESourceGroup *group;

		if (group_arg == NULL) {
			fprintf (stderr,
				 "When using --set-base-uri, you need to specify a group using --group.\n");
			exit (1);
		}

		group = e_source_list_peek_group_by_uid (list, group_arg);
		e_source_group_set_base_uri (group, set_base_uri_arg);
		e_source_list_sync (list, NULL);
	}

	if (set_value_arg != NULL) {
		ESource *source;

		if (add_source_arg == NULL && source_arg == NULL) {
			fprintf (stderr,
				 "When using --set-value, you need to specify a source using --source\n");
			exit (1);
		}

		if (property_arg == NULL) {
			fprintf (stderr,
				 "When using --set-value, you need to specify a property using --property\n");
			exit (1);
		}

		if (add_source_arg != NULL)
			source = new_source;
		else
			source = e_source_list_peek_source_by_uid (list, source_arg);

		e_source_set_property (source, property_arg, set_value_arg);
		e_source_list_sync (list, NULL);
	}

	if (unset_value) {
		ESource *source;

		if (add_source_arg == NULL && source_arg == NULL) {
			fprintf (stderr,
				 "When using --unset-value, you need to specify a source using --source\n");
			exit (1);
		}

		if (property_arg == NULL) {
			fprintf (stderr,
				 "When using --unset-value, you need to specify a property using --property\n");
			exit (1);
		}

		if (add_source_arg != NULL)
			source = new_source;
		else
			source = e_source_list_peek_source_by_uid (list, source_arg);

		e_source_set_property (source, property_arg, NULL);
		e_source_list_sync (list, NULL);
	}

	connect_list ();

	if (dump)
		dump_list ();

	if (!listen)
		g_main_loop_quit (main_loop);

	return FALSE;
}
Exemple #24
0
int compare_entry_state (Entry_State *entry1, Entry_State *entry2, int run)
{
	int j;
	int error = 0;

	/* first - quick check for present / not present */
	for (j = 0; j < sim.value_count; j++)
	{
		if (entry1->values[j].present != entry2->values[j].present)
		{
			fprintf (sim.fout, 
				"value %s is %s present in the first run but %s present in the %d run\n",
					 g_values[j], entry1->values[j].present ? "" : "not",	
					 entry2->values[j].present ? "" : "not", run);
			error = 1;
		}					 
	}

	if (error)
		return 3;

	/* compare value state */
	error = 0;
	if (entry1->attr_delete_csn != entry2->attr_delete_csn)
	{
		fprintf (sim.fout, "attribute delete csn is %d for run 1 "
				 "but is %d for run %d\n", entry1->attr_delete_csn, 
				 entry2->attr_delete_csn, run);
		error = 1;
	}

	for (j = 0; j < sim.value_count; j++)
	{
		if (entry1->values[j].presense_csn != entry2->values[j].presense_csn)
		{
			fprintf (sim.fout, "presence csn for value %s is %d in run 1 "
					 "but is %d in run %d\n", g_values[j], entry1->values[j].presense_csn, 
					 entry2->values[j].presense_csn, run);
			error = 1;
		}

		if (entry1->values[j].distinguished_csn != entry2->values[j].distinguished_csn)
		{
			fprintf (sim.fout, "distinguished csn for value %s is %d in run 1 "
					 "but is %d in run %d\n", g_values[j], entry1->values[j].distinguished_csn, 
					 entry2->values[j].distinguished_csn, run);
			error = 1;
		}

		if (entry1->values[j].delete_csn != entry2->values[j].delete_csn)
		{
			fprintf (sim.fout, "delete csn for value %s is %d in run 1 "
					 "but is %d in run %d\n", g_values[j], entry1->values[j].delete_csn, 
					 entry2->values[j].delete_csn, run);
			error = 1;
		}
		
		if (!list_equal (entry1->values[j].non_distinguished_csns,
						 entry2->values[j].non_distinguished_csns))
		{
			fprintf (sim.fout, "pending list mismatch for valye %s in runs 1 and %d\n", 
					 g_values[j], run);
			dump_list (entry1->values[j].non_distinguished_csns);
			dump_list (entry2->values[j].non_distinguished_csns);			
		}			 
	}

	if (error != 0)
	{
		return 1;
	}
	else
		return 0;
}
Exemple #25
0
struct private_common *
kmp_threadprivate_insert( int gtid, void *pc_addr, void *data_addr, size_t pc_size )
{
    struct private_common *tn, **tt;
    struct shared_common  *d_tn;

    /* +++++++++ START OF CRITICAL SECTION +++++++++ */

    __kmp_acquire_lock( & __kmp_global_lock, gtid );

    tn = (struct private_common *) __kmp_allocate( sizeof (struct private_common) );

    tn->gbl_addr = pc_addr;

    d_tn = __kmp_find_shared_task_common( &__kmp_threadprivate_d_table,
                                          gtid, pc_addr );     /* Only the MASTER data table exists. */

    if (d_tn != 0) {
        /* This threadprivate variable has already been seen. */

        if ( d_tn->pod_init == 0 && d_tn->obj_init == 0 ) {
            d_tn->cmn_size = pc_size;

            if (d_tn->is_vec) {
                if (d_tn->ct.ctorv != 0) {
                    /* Construct from scratch so no prototype exists */
                    d_tn->obj_init = 0;
                }
                else if (d_tn->cct.cctorv != 0) {
                    /* Now data initialize the prototype since it was previously registered */
                    d_tn->obj_init = (void *) __kmp_allocate( d_tn->cmn_size );
                    (void) (*d_tn->cct.cctorv) (d_tn->obj_init, pc_addr, d_tn->vec_len);
                }
                else {
                    d_tn->pod_init = __kmp_init_common_data( data_addr, d_tn->cmn_size );
                }
            } else {
                if (d_tn->ct.ctor != 0) {
                    /* Construct from scratch so no prototype exists */
                    d_tn->obj_init = 0;
                }
                else if (d_tn->cct.cctor != 0) {
                    /* Now data initialize the prototype since it was previously registered */
                    d_tn->obj_init = (void *) __kmp_allocate( d_tn->cmn_size );
                    (void) (*d_tn->cct.cctor) (d_tn->obj_init, pc_addr);
                }
                else {
                    d_tn->pod_init = __kmp_init_common_data( data_addr, d_tn->cmn_size );
                }
            }
        }
    }
    else {
        struct shared_common **lnk_tn;

        d_tn = (struct shared_common *) __kmp_allocate( sizeof( struct shared_common ) );
        d_tn->gbl_addr = pc_addr;
        d_tn->cmn_size = pc_size;
        d_tn->pod_init = __kmp_init_common_data( data_addr, pc_size );
/*
        d_tn->obj_init = 0;  // AC: commented out because __kmp_allocate zeroes the memory
        d_tn->ct.ctor = 0;
        d_tn->cct.cctor = 0;
        d_tn->dt.dtor = 0;
        d_tn->is_vec = FALSE;
        d_tn->vec_len = 0L;
*/
        lnk_tn = &(__kmp_threadprivate_d_table.data[ KMP_HASH(pc_addr) ]);

        d_tn->next = *lnk_tn;
        *lnk_tn = d_tn;
    }

    tn->cmn_size = d_tn->cmn_size;

    if ( (__kmp_foreign_tp) ? (KMP_INITIAL_GTID (gtid)) : (KMP_UBER_GTID (gtid)) ) {
        tn->par_addr = (void *) pc_addr;
    }
    else {
        tn->par_addr = (void *) __kmp_allocate( tn->cmn_size );
    }

    __kmp_release_lock( & __kmp_global_lock, gtid );

    /* +++++++++ END OF CRITICAL SECTION +++++++++ */

#ifdef USE_CHECKS_COMMON
        if (pc_size > d_tn->cmn_size) {
            KC_TRACE( 10, ( "__kmp_threadprivate_insert: THREADPRIVATE: %p (%"
                            KMP_UINTPTR_SPEC " ,%" KMP_UINTPTR_SPEC ")\n",
                            pc_addr, pc_size, d_tn->cmn_size ) );
            KMP_FATAL( TPCommonBlocksInconsist );
        }
#endif /* USE_CHECKS_COMMON */

    tt = &(__kmp_threads[ gtid ]->th.th_pri_common->data[ KMP_HASH(pc_addr) ]);

#ifdef KMP_TASK_COMMON_DEBUG
    if (*tt != 0) {
        KC_TRACE( 10, ( "__kmp_threadprivate_insert: WARNING! thread#%d: collision on %p\n",
                        gtid, pc_addr ) );
    }
#endif
    tn->next = *tt;
    *tt = tn;

#ifdef KMP_TASK_COMMON_DEBUG
    KC_TRACE( 10, ( "__kmp_threadprivate_insert: thread#%d, inserted node %p on list\n",
                    gtid, pc_addr ) );
    dump_list( );
#endif

    /* Link the node into a simple list */

    tn->link = __kmp_threads[ gtid ]->th.th_pri_head;
    __kmp_threads[ gtid ]->th.th_pri_head = tn;

#ifdef BUILD_TV
    __kmp_tv_threadprivate_store( __kmp_threads[ gtid ], tn->gbl_addr, tn->par_addr );
#endif

    if( (__kmp_foreign_tp) ? (KMP_INITIAL_GTID (gtid)) : (KMP_UBER_GTID (gtid)) )
        return tn;

    /*
     * if C++ object with copy constructor, use it;
     * else if C++ object with constructor, use it for the non-master copies only;
     * else use pod_init and memcpy
     *
     * C++ constructors need to be called once for each non-master thread on allocate
     * C++ copy constructors need to be called once for each thread on allocate
     */

    /*
     * C++ object with constructors/destructors;
     * don't call constructors for master thread though
     */
    if (d_tn->is_vec) {
        if ( d_tn->ct.ctorv != 0) {
            (void) (*d_tn->ct.ctorv) (tn->par_addr, d_tn->vec_len);
        } else if (d_tn->cct.cctorv != 0) {
            (void) (*d_tn->cct.cctorv) (tn->par_addr, d_tn->obj_init, d_tn->vec_len);
        } else if (tn->par_addr != tn->gbl_addr) {
            __kmp_copy_common_data( tn->par_addr, d_tn->pod_init );
        }
    } else {
        if ( d_tn->ct.ctor != 0 ) {
            (void) (*d_tn->ct.ctor) (tn->par_addr);
        } else if (d_tn->cct.cctor != 0) {
            (void) (*d_tn->cct.cctor) (tn->par_addr, d_tn->obj_init);
        } else if (tn->par_addr != tn->gbl_addr) {
            __kmp_copy_common_data( tn->par_addr, d_tn->pod_init );
        }
    }
/* !BUILD_OPENMP_C
    if (tn->par_addr != tn->gbl_addr)
        __kmp_copy_common_data( tn->par_addr, d_tn->pod_init ); */

    return tn;
}
Exemple #26
0
int
main(int argc, char **argv)
{
  /*
   * initialize the list heads
   */
  LIST_INIT(&tl);
  LIST_INIT(&tl2);

  dump_list("tl", &tl);
  dump_list("tl2", &tl2);

  /*
   * add the elements in the order a1, a2, a3.  Since each is inserted at
   * the list head, walking the list forward will generate "a3, a2, a1"
   * ordering.
   */

  printf("TL:   a1\n");
  printf("TL2:  a3\n");

  LIST_INSERT_HEAD(&tl, &a1, ent);
  LIST_INSERT_HEAD(&tl2, &a3, ent2);

  dump_list("tl", &tl);
  dump_list("tl2", &tl2);

  printf("TL:   a2 a1\n");
  printf("TL2:  a2 a3\n");

  LIST_INSERT_HEAD(&tl, &a2, ent);
  LIST_INSERT_HEAD(&tl2, &a2, ent2);

  dump_list("tl", &tl);
  dump_list("tl2", &tl2);

  printf("TL:   a3 a2 a1\n");
  printf("TL2:  a1 a2 a3\n");

  LIST_INSERT_HEAD(&tl, &a3, ent);
  LIST_INSERT_HEAD(&tl2, &a1, ent2);

  dump_list("tl", &tl);
  dump_list("tl2", &tl2);

  /*
   * remove the middle element, list 2
   */

  LIST_REMOVE(&a2, ent2);

  dump_list("tl", &tl);
  dump_list("tl2", &tl2);

  /*
   * remove the list head, list 2
   */

  LIST_REMOVE(&a1, ent2);

  dump_list("tl", &tl);
  dump_list("tl2", &tl2);

  /*
   * remove the only member.  This sets the head to NULL as well, list 2
   */

  LIST_REMOVE(&a3, ent2);

  dump_list("tl", &tl);
  dump_list("tl2", &tl2);

  /*
   * remove the middle element.
   */

  LIST_REMOVE(&a2, ent);

  dump_list("tl", &tl);
  dump_list("tl2", &tl2);

  /*
   * remove the list head
   */

  LIST_REMOVE(&a3, ent);

  dump_list("tl", &tl);
  dump_list("tl2", &tl2);

  /*
   * remove the only member.  This sets the head to NULL as well.
   */

  LIST_REMOVE(&a1, ent);

  dump_list("tl", &tl);
  dump_list("tl2", &tl2);

  return 0;
}