Exemplo n.º 1
0
void foo()
{
	int a;

#pragma scop
	a = add_one(add_one(5));
#pragma endscop
}
void test() {
 register struct entry *p;
 add_one(&p->value);
 struct entry pvalue;
 add_one(&p->bitf);  // expected-error {{address of bit-field requested}}
 add_one(&pvalue.bitf); // expected-error {{address of bit-field requested}}
 add_one(&p->whatever->bitf); // expected-error {{address of bit-field requested}}
}
Exemplo n.º 3
0
Arquivo: inf_div.c Projeto: k6s/tek1
char		do_div(t_nb *res, t_nb *n1, t_nb *n2, t_base *s_base)
{
  t_nb		*tmp;
  t_nb		*to_free;
  int		cmp;

  if (!(tmp = mk_zero(s_base->base[0])))
    return (-1);
  cmp = 0;
  while (n1->len > tmp->len
	 || (tmp->len == n1->len
	     && (cmp = my_memcmp(tmp->nb, n1->nb, n1->len)) < 0))
    {
      add_one(res, n1->len, s_base->base_len);
      to_free = tmp;
      if (!(tmp = inf_add(tmp, n2, s_base, 0)))
	return (-1);
      free(to_free->nb);
      free(to_free);
    }
  if (n1->len < tmp->len || cmp > 0)
    sub_one(res, n1->len, s_base->base_len);
  free(tmp->nb);
  free(tmp);
  return (0);
}
Exemplo n.º 4
0
void test_transform_async(ExPolicy p, IteratorTag)
{
    typedef std::vector<int>::iterator base_iterator;
    typedef test::test_iterator<base_iterator, IteratorTag> iterator;

    std::vector<int> c(10007);
    std::vector<int> d(c.size());
    std::iota(std::begin(c), std::end(c), std::rand());

    auto f =
        hpx::parallel::transform(p,
            iterator(std::begin(c)), iterator(std::end(c)),
            std::begin(d),
            add_one());
    f.wait();

    hpx::util::tuple<iterator, base_iterator> result = f.get();
    HPX_TEST(hpx::util::get<0>(result) == iterator(std::end(c)));
    HPX_TEST(hpx::util::get<1>(result) == std::end(d));

    // verify values
    std::size_t count = 0;
    HPX_TEST(std::equal(std::begin(c), std::end(c), std::begin(d),
        [&count](std::size_t v1, std::size_t v2) -> bool {
            HPX_TEST_EQ(v1 + 1, v2);
            ++count;
            return v1 + 1 == v2;
        }));
    HPX_TEST_EQ(count, d.size());
}
Exemplo n.º 5
0
void test_transform(ExPolicy policy, IteratorTag)
{
    static_assert(
        hpx::parallel::execution::is_execution_policy<ExPolicy>::value,
        "hpx::parallel::execution::is_execution_policy<ExPolicy>::value");

    typedef std::vector<int>::iterator base_iterator;
    typedef test::test_iterator<base_iterator, IteratorTag> iterator;

    std::vector<int> c(10007);
    std::vector<int> d(c.size());
    std::iota(std::begin(c), std::end(c), std::rand());

    auto result =
        hpx::parallel::transform(policy,
            iterator(std::begin(c)), iterator(std::end(c)),
            std::begin(d),
            add_one());

    HPX_TEST(hpx::util::get<0>(result) == iterator(std::end(c)));
    HPX_TEST(hpx::util::get<1>(result) == std::end(d));

    // verify values
    std::size_t count = 0;
    HPX_TEST(std::equal(std::begin(c), std::end(c), std::begin(d),
        [&count](std::size_t v1, std::size_t v2) -> bool {
            HPX_TEST_EQ(v1 + 1, v2);
            ++count;
            return v1 + 1 == v2;
        }));
    HPX_TEST_EQ(count, d.size());
}
Exemplo n.º 6
0
static void add_half(struct ififo *fifo, int value)
{
    int i;
    int l = ififo_len(fifo) / 2;
    
    for (i = 0; i < l; i++, value++)
        add_one(fifo, value);
}
Exemplo n.º 7
0
int main()
{
    S<int> i;
    // S<char*> s; //doesn't compile

    add_one(1.f);
    // add_one("hi there"); //doesn't compile
}
Exemplo n.º 8
0
static int __init seq_init(void)
{
        struct proc_dir_entry *entry;

        mutex_init(&lock);
        INIT_LIST_HEAD(&head);

        add_one("aaaa");
        add_one("bbbb");

        entry = create_proc_entry("my_data", S_IWUGO | S_IRUGO, NULL);
        if (entry == NULL) {
                clean_all(&head);
                return -ENOMEM;
        }
        entry->proc_fops = &list_seq_fops;

        return 0;
}
Exemplo n.º 9
0
static int
get_null (const struct addrinfo *hints,
	  int port, int protocol, int socktype,
	  struct addrinfo **res)
{
    struct in_addr v4_addr;
#ifdef HAVE_IPV6
    struct in6_addr v6_addr;
#endif
    struct addrinfo *first = NULL;
    struct addrinfo **current = &first;
    int family = PF_UNSPEC;
    int ret;

    if (hints != NULL)
	family = hints->ai_family;

    if (hints && hints->ai_flags & AI_PASSIVE) {
	v4_addr.s_addr = INADDR_ANY;
#ifdef HAVE_IPV6
	v6_addr        = in6addr_any;
#endif
    } else {
	v4_addr.s_addr = htonl(INADDR_LOOPBACK);
#ifdef HAVE_IPV6
	v6_addr        = in6addr_loopback;
#endif
    }

#ifdef HAVE_IPV6
    if (family == PF_INET6 || family == PF_UNSPEC) {
	ret = add_one (port, protocol, socktype,
		       &current, const_v6, &v6_addr, NULL);
    }
#endif
    if (family == PF_INET || family == PF_UNSPEC) {
	ret = add_one (port, protocol, socktype,
		       &current, const_v4, &v4_addr, NULL);
    }
    *res = first;
    return 0;
}
Exemplo n.º 10
0
int main() {
	int my_val = 5;

	printf("Val before function: %d\n", my_val);

	add_one(&my_val);

	printf("Val after function: %d\n", my_val);

	return 0;
}
Exemplo n.º 11
0
/* encrypt/decrypt a block of ctr */
void stream_ctr_AES(AES_CTR_CTX *const ctx, const uint8_t *const in, const size_t len, uint8_t *const out) {
	size_t i;
	
	for(i = 0; i < len; i++) {
		if(ctx->count % 16 == 0) {
			encrypt_block_AES(ctx->nonce, ctx->stream, &ctx->key);
			add_one(ctx->nonce);
		}
		out[i] = in[i] ^ ctx->stream[ctx->count%16];
		ctx->count++;
	}
}
Exemplo n.º 12
0
int main()
{
    int x = 1;
    int y = 2;
    printf("sum_num(x,y) = %d\n", sum_num(x, y));
    printf("sum_num(NUM,10) = %d\n", sum_num(NUM, 10));
    printf("add_one(&x) = %d\n", add_one(&x));
    /* Not allowed: the parameter has to be an address 
    printf("add_one(NUM) = %d\n", add_one(NUM));
    */
    return 0;
}
Exemplo n.º 13
0
int key_inkey_time(fix * time)
{
	int key = 0;

	key_poll();
	if (key_data.keytail!=key_data.keyhead)	{
		key = key_data.keybuffer[key_data.keyhead];
		*time = key_data.time_pressed[key_data.keyhead];
		key_data.keyhead = add_one(key_data.keyhead);
	}
	return key;
}
Exemplo n.º 14
0
int move_right(int *values) {
	int rows[4][4] = {
		{3, 2, 1, 0},
		{7, 6, 5, 4},
		{11, 10, 9, 8},
		{15, 14, 13, 12}
	};
	if (move(values, rows) == 1) {
		add_one(values);
		return 0;
	}
	return -1;
}
Exemplo n.º 15
0
static int
get_number (const char *nodename,
	    const struct addrinfo *hints,
	    int port, int protocol, int socktype,
	    struct addrinfo **res)
{
    struct addrinfo *first = NULL;
    struct addrinfo **current = &first;
    int family = PF_UNSPEC;
    int ret;

    if (hints != NULL) {
	family = hints->ai_family;
    }

#ifdef HAVE_IPV6
    if (family == PF_INET6 || family == PF_UNSPEC) {
	struct in6_addr v6_addr;

	if (inet_pton (PF_INET6, nodename, &v6_addr) == 1) {
	    ret = add_one (port, protocol, socktype,
			   &current, const_v6, &v6_addr, NULL);
	    *res = first;
	    return ret;
	}
    }
#endif
    if (family == PF_INET || family == PF_UNSPEC) {
	struct in_addr v4_addr;

	if (inet_pton (PF_INET, nodename, &v4_addr) == 1) {
	    ret = add_one (port, protocol, socktype,
			   &current, const_v4, &v4_addr, NULL);
	    *res = first;
	    return ret;
	}
    }
    return EAI_NONAME;
}
Exemplo n.º 16
0
int move_up(int *values) {
	int rows[4][4] = {
		{0, 4, 8, 12},
		{1, 5, 9, 13},
		{2, 6, 10, 14},
		{3, 7, 11, 15}
	};
	if (move(values, rows) == 1) {
		add_one(values);
		return 0;
	}
	return -1;
}
Exemplo n.º 17
0
int move_left(int *values) {
	int rows[4][4] = {
		{0, 1, 2, 3},
		{4, 5, 6, 7},
		{8, 9, 10, 11},
		{12, 13, 14, 15}
	};
	if (move(values, rows) == 1) {
		add_one(values);
		return 0;
	}
	return -1;
}
Exemplo n.º 18
0
int move_down(int *values) {
	int rows[4][4] = {
		{12, 8, 4, 0},
		{13, 9, 5, 1},
		{14, 10, 6, 2},
		{15, 11, 7, 3}
	};
	if (move(values, rows) == 1) {
		add_one(values);
		return 0;
	}
	return -1;
}
Exemplo n.º 19
0
Arquivo: key.c Projeto: paud/d2x-xl
int KeyInKeyTime(fix * time)
{
	int key = 0;

	if (!Installed)
		key_init();
        event_poll();
	if (key_data.keytail!=key_data.keyhead)	{
		key = key_data.keybuffer[key_data.keyhead];
		*time = key_data.time_pressed[key_data.keyhead];
		key_data.keyhead = add_one(key_data.keyhead);
	}
	return key;
}
Exemplo n.º 20
0
static ssize_t list_seq_write(struct file *file, const char __user * buffer,
                       size_t count, loff_t *ppos)
{
        char info[SIZE];
     
        memset(info, 0, SIZE);
        if (count > SIZE)
                return -EFBIG;
        copy_from_user(info, buffer, count - 1);
        
        add_one(info);

        return count;
}
Exemplo n.º 21
0
int main (void) {

	int i, result;

    	for (i = 0; i < 10000; i++) {
		add_one(i, &result);
        	if (result != (i+1)) {
            		printf("[ERROR ] Unexpected Output...\n");
            		exit(EXIT_FAILURE);
        	}
    	}

    	return 0;
}
Exemplo n.º 22
0
Arquivo: key.c Projeto: paud/d2x-xl
int KeyInKey()
{
	int key = 0;
	if (!Installed)
		key_init();
        event_poll();
	if (key_data.keytail!=key_data.keyhead) {
		key = key_data.keybuffer[key_data.keyhead];
		key_data.keyhead = add_one(key_data.keyhead);
	}
//added 9/3/98 by Matt Mueller to D2_FREE cpu time instead of hogging during menus and such
//	else timer_delay(1);
//end addition - Matt Mueller
        return key;
}
Exemplo n.º 23
0
int key_inkey()
{
	int key = 0;

	_disable();

	key_clear_bios_buffer();

	if (key_data.keytail!=key_data.keyhead)	{
		key = key_data.keybuffer[key_data.keyhead];
		key_data.keyhead = add_one(key_data.keyhead);
	}
	_enable();
	return key;
}
Exemplo n.º 24
0
Arquivo: key.c Projeto: paud/d2x-xl
int KeyInKeyTime(fix * time)
{
	int key = 0;

	if (!bInstalled)
		key_init();
        event_poll(SDL_KEYDOWNMASK | SDL_KEYUPMASK);
	if (key_data.keytail!=key_data.keyhead)	{
		key = key_data.keybuffer[key_data.keyhead];
		*time = key_data.time_pressed[key_data.keyhead];
		key_data.keyhead = add_one(key_data.keyhead);
	}
	if (key == KEY_CTRLED+KEY_ALTED+KEY_ENTER)
		exit (0);
	return key;
}
Exemplo n.º 25
0
int key_inkey_time(fix * time)
{
	int key = 0;

	_disable();

	key_clear_bios_buffer();

	if (key_data.keytail!=key_data.keyhead)	{
		key = key_data.keybuffer[key_data.keyhead];
		*time = key_data.time_pressed[key_data.keyhead];
		key_data.keyhead = add_one(key_data.keyhead);
	}
	_enable();
	return key;
}
Exemplo n.º 26
0
static int
add_hostent (int port, int protocol, int socktype,
	     struct addrinfo ***current,
	     int (*func)(struct addrinfo *, void *data, int port),
	     struct hostent *he, int *flags)
{
    int ret;
    char *canonname = NULL;
    char **h;

    if (*flags & AI_CANONNAME) {
	struct hostent *he2 = NULL;
	const char *tmp_canon;

	tmp_canon = hostent_find_fqdn (he);
	if (strchr (tmp_canon, '.') == NULL) {
	    int error;

	    he2 = getipnodebyaddr (he->h_addr_list[0], he->h_length,
				   he->h_addrtype, &error);
	    if (he2 != NULL) {
		const char *tmp = hostent_find_fqdn (he2);

		if (strchr (tmp, '.') != NULL)
		    tmp_canon = tmp;
	    }
	}

	canonname = strdup (tmp_canon);
	if (he2 != NULL)
	    freehostent (he2);
	if (canonname == NULL)
	    return EAI_MEMORY;
    }

    for (h = he->h_addr_list; *h != NULL; ++h) {
	ret = add_one (port, protocol, socktype,
		       current, func, *h, canonname);
	if (ret)
	    return ret;
	if (*flags & AI_CANONNAME) {
	    *flags &= ~AI_CANONNAME;
	    canonname = NULL;
	}
    }
    return 0;
}
Exemplo n.º 27
0
static int __init fifo_init(void)
{
    int i, val, ret;

    ret = ififo_alloc(&fifo, size, GFP_KERNEL);
    if (ret)
        return ret;

    printk("%s: populating fifo\n", MODNAME);
    for (i = 0; ififo_put(fifo, i + 1); i++);

    printk("%s: initial fifo state\n", MODNAME);
    print_fifo(fifo);

    printk("%s: COPY -- initial fifo state\n", MODNAME);
    print_fifo(fifo);

    /* try to enqueue one more item */
    if (!ififo_put(fifo, size + 1)) 
        printk("unsuccessful attempt to insert to full fifo\n");

    add_one(fifo, size + 1);
    printk("%s: added 1 item\n", MODNAME);
    print_fifo(fifo);

    printk("%s: COPY -- after adding one\n", MODNAME);
    print_fifo_copy(fifo);   

    /* add another half items */
    add_half(fifo, size + 2);
    printk("%s: added half\n", MODNAME);
    print_fifo(fifo);   

    printk("%s: COPY -- after adding half\n", MODNAME);
    print_fifo_copy(fifo);   

    printk("printing -- draining the queue\n");
    i = 1;
    while (ififo_get(fifo, &val)) 
        printk("item[%d] = %d\n", i++, val);
    
    printk("queue size now is %d\n", ififo_len(fifo));
 
    printk("%s: init complete\n", MODNAME);
    return 0;
}
Exemplo n.º 28
0
static void
queue_requests(void)
{
    /* we want to try to let outstanding get down to 0, to test global 
     * init/uninit
     */
    if (outstanding == 0) {
        while (total > 0 && outstanding < 8) {
            add_one();
        }
        g_print("%d more to queue, %d outstanding now\n", total, outstanding);
    }
    
    if (total == 0 && outstanding == 0) {
        g_main_loop_quit(loop);
    }
}
Exemplo n.º 29
0
int key_inkey()
{
	int key = 0;

	key_poll();
	if (key_data.keytail!=key_data.keyhead) {
		key = key_data.keybuffer[key_data.keyhead];
		key_data.keyhead = add_one(key_data.keyhead);
	}
#ifdef SUPPORTS_NICEFPS
	//added 9/3/98 by Matt Mueller to free cpu time instead of hogging during menus and such
	else d_delay(1);
	//end addition - Matt Mueller
#endif

	return key;
}
int
main (int argc, char **argv)
{
	int number, i;
	uint32_t val1=0, val2=0;
	if (argc < 2) {
		printf("Sorry use %s num-of-times\n", argv[0]);
		return (-1);
	}
	number = strtol(argv[1], NULL, 0);
	for (i=0; i<number; i++) {
		add_one(&val1);
		add_one_atomic(&val2);
	}
	printf("Val 1 is %u Val 2 is %u\n", val1, val2);
	return (0);

}