Example #1
0
static int run_annexb_sets( const uint8_t *p_set, const uint8_t *p_end,
                            const struct results_s *p_results, size_t i_results,
                            ssize_t i_results_offset )
{
    int i_ret;

    printf("checking bits code:\n");
    i_ret = check_set( p_set, p_end, p_results, i_results, i_results_offset,
                       startcode_FindAnnexB_Bits );
    if( i_ret != 0 )
        return i_ret;

    /* Perform same tests on simd optimized code */
    if( startcode_FindAnnexB_Bits != startcode_FindAnnexB )
    {
        printf("checking asm:\n");
        i_ret = check_set( p_set, p_end, p_results, i_results, i_results_offset,
                           startcode_FindAnnexB );
        if( i_ret != 0 )
            return i_ret;
    }
    else printf("asm not built in, skipping test:\n");

    return 0;
}
Example #2
0
int are_enemy(int x,int y)
{
     int p,q;
     q=check_set(v);
     p=check_set(u);
     if(p==q && arr[u].group!=arr[v].group)
	  return 1;
     else 
	  return 0;
}
Example #3
0
int are_friend(int x,int y)
{ 
     int p,q;
     p=check_set(u);
     q=check_set(v);
     if(p==q && arr[u].group==arr[v].group)
	  return 1;
     else 
	  return 0;
}
Example #4
0
void set_friend(int x,int y)
{
     int p,q;

     q=check_set(v);
     p=check_set(u);
     if(arr[u].parent==arr[v].parent && arr[u].group!=arr[v].group)
	  printf("-1\n");
     else
     {
	  JOIN_IT(p,q);
	  arr[p].group=(arr[u].group+arr[v].group)&1;
     }   

}
Example #5
0
void set_enemy(int x,int y)
{ 
     int p,q;
     p=check_set(u);
     q=check_set(v);
     if(arr[u].group==arr[v].group && arr[u].parent==arr[v].parent)
	  printf("-1\n");
     else
     {
	  JOIN_IT(p,q);
	  arr[p].group=(arr[u].group+arr[v].group+1)&1;
     }


}
static void stop_after_song_toggled (void * hook_data, void * user_data)
{
    mainwin_enable_status_message (FALSE);
    check_set (toggleaction_group_others, "stop after current song",
     aud_get_bool (NULL, "stop_after_current_song"));
    mainwin_enable_status_message (TRUE);
}
Example #7
0
STATIC mp_obj_t set_intersect_int(mp_obj_t self_in, mp_obj_t other, bool update) {
    if (update) {
        check_set(self_in);
    } else {
        check_set_or_frozenset(self_in);
    }

    if (self_in == other) {
        return update ? mp_const_none : set_copy(self_in);
    }

    mp_obj_set_t *self = self_in;
    mp_obj_set_t *out = mp_obj_new_set(0, NULL);

    mp_obj_t iter = mp_getiter(other);
    mp_obj_t next;
    while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) {
        if (mp_set_lookup(&self->set, next, MP_MAP_LOOKUP)) {
            set_add(out, next);
        }
    }

    if (update) {
        m_del(mp_obj_t, self->set.table, self->set.alloc);
        self->set.alloc = out->set.alloc;
        self->set.used = out->set.used;
        self->set.table = out->set.table;
    }

    return update ? mp_const_none : out;
}
Example #8
0
bool Board::isThereASet() { //iterates through the board
    for (int i=0; i<length; i++) {
        for (int j=0; j<width; j++) { //first card
            
            for(int k=0; k<length; k++) {
                for (int l=0; l<width; l++) {//second card
                    
                    for (int m=0; m<length; m++) {
                        for (int n=0; n<width; n++) {//third card
                            
                            if (board[i][j]!=board[k][l] && board[k][l]!=board[m][n] && board[i][j]!=board[m][n]) {
                                //if the cards picked are not the same
                                if (check_set(board[i][j], board[k][l], board[m][n])) {
                                    return true;
                                }
                                
                            }
                        }
                    }
                }
            }
        }

    }
return false;
}
Example #9
0
STATIC mp_obj_t set_diff_int(size_t n_args, const mp_obj_t *args, bool update) {
    mp_obj_t self;
    if (update) {
        check_set(args[0]);
        self = args[0];
    } else {
        self = set_copy(args[0]);
    }

    for (size_t i = 1; i < n_args; i++) {
        mp_obj_t other = args[i];
        if (self == other) {
            set_clear(self);
        } else {
            mp_set_t *self_set = &((mp_obj_set_t*)MP_OBJ_TO_PTR(self))->set;
            mp_obj_t iter = mp_getiter(other, NULL);
            mp_obj_t next;
            while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) {
                mp_set_lookup(self_set, next, MP_MAP_LOOKUP_REMOVE_IF_FOUND);
            }
        }
    }

    return self;
}
Example #10
0
STATIC mp_obj_t set_diff_int(int n_args, const mp_obj_t *args, bool update) {
    assert(n_args > 0);

    mp_obj_set_t *self;
    if (update) {
        check_set(args[0]);
        self = args[0];
    } else {
        check_set_or_frozenset(args[0]);
        self = set_copy_as_mutable(args[0]);
    }


    for (int i = 1; i < n_args; i++) {
        mp_obj_t other = args[i];
        if (self == other) {
            set_clear(self);
        } else {
            mp_obj_t iter = mp_getiter(other);
            mp_obj_t next;
            while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) {
                set_discard(self, next);
            }
        }
    }

    self->base.type = ((mp_obj_set_t*)args[0])->base.type;
    return self;
}
Example #11
0
void initialise_map ( op_map * mapping, op_set * from, op_set * to, int dim, int * map, char const * name )
{
  assert( mapping && from && to && map );

  if ( check_set( from ) ) {
    printf(" op_decl_map error -- invalid 'from' set for map %s\n",name);
    exit(-1);
  }

  if ( check_set( to ) ) {
    printf("op_decl_map error -- invalid 'to' set for map %s\n",name);
    exit(-1);
  }

  if (dim<=0) {
    printf("op_decl_map error -- negative/zero dimension for map %s\n",name);
    exit(-1);
  }

  for (int d=0; d<dim; d++) {
    for (int n=0; n<from->size; n++) {
      if (map[d+n*dim]<0 || map[d+n*dim]>=to->size) {
        printf("op_decl_map error -- invalid data for map %s\n",name);
        printf("element = %d, dimension = %d, map = %d\n",n,d,map[d+n*dim]);
        exit(-1);
      }
    }
  }

  mapping->from = from;
  mapping->to   = to;
  mapping->dim  = dim;
  mapping->index = OP_map_index;
  mapping->map  = map;
  mapping->name = name;

  if (OP_map_index==OP_map_max) {
    OP_map_max += 10;
    OP_map_list = (op_map **) realloc(OP_map_list,OP_map_max*sizeof(op_map *));
    if (OP_map_list==NULL) {
      printf(" op_decl_map error -- error reallocating memory\n");
      exit(-1);
    }
  }

  OP_map_list[OP_map_index++] = mapping;
}
Example #12
0
void initialise_dat ( op_dat * data,
                      int rank,
                      op_set * set0,
                      op_set * set1,
                      int dim,
                      int type_size,
                      void *dat,
                      char const * name )
{
  assert( data );

  if ( rank < 0 || rank > 2 ) {
    printf("op_decl_dat error -- invalid rank for data: %s (0 <= rank <= 2)\n",name);
    exit(-1);
  }

  if ( rank > 0 && check_set(set0) || rank > 1 && check_set(set1) ) {
    printf("op_decl_dat error -- invalid set for data: %s\n",name);
    exit(-1);
  }

  if (dim<=0) {
    printf("op_decl_dat error -- negative/zero dimension for data: %s\n",name);
    exit(-1);
  }

  data->rank = rank;
  data->set[0]= set0;
  data->set[1]= set1;
  data->dim   = dim;
  data->index = OP_dat_index;
  data->dat   = dat;
  data->dat_d = NULL;
  data->size  = dim*type_size;
	data->name = name;

  if (OP_dat_index==OP_dat_max) {
    OP_dat_max += 10;
    OP_dat_list = (op_dat **) realloc(OP_dat_list,OP_dat_max*sizeof(op_dat *));
    if (OP_dat_list==NULL) {
      printf(" op_decl_dat error -- error reallocating memory\n");
      exit(-1);
    }
  }

  OP_dat_list[OP_dat_index++] = data;
}
Example #13
0
STATIC mp_obj_t set_clear(mp_obj_t self_in) {
    check_set(self_in);
    mp_obj_set_t *self = self_in;

    mp_set_clear(&self->set);

    return mp_const_none;
}
Example #14
0
STATIC mp_obj_t set_remove(mp_obj_t self_in, mp_obj_t item) {
    check_set(self_in);
    mp_obj_set_t *self = self_in;
    if (mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_REMOVE_IF_FOUND) == MP_OBJ_NULL) {
        nlr_raise(mp_obj_new_exception(&mp_type_KeyError));
    }
    return mp_const_none;
}
Example #15
0
STATIC mp_obj_t set_update(size_t n_args, const mp_obj_t *args) {
    check_set(args[0]);
    for (size_t i = 1; i < n_args; i++) {
        set_update_int(MP_OBJ_TO_PTR(args[0]), args[i]);
    }

    return mp_const_none;
}
Example #16
0
STATIC mp_obj_t set_pop(mp_obj_t self_in) {
    check_set(self_in);
    mp_obj_set_t *self = self_in;
    mp_obj_t obj = mp_set_remove_first(&self->set);
    if (obj == MP_OBJ_NULL) {
        nlr_raise(mp_obj_new_exception_msg(&mp_type_KeyError, "pop from an empty set"));
    }
    return obj;
}
Example #17
0
STATIC mp_obj_t set_pop(mp_obj_t self_in) {
    check_set(self_in);
    mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
    mp_obj_t obj = mp_set_remove_first(&self->set);
    if (obj == MP_OBJ_NULL) {
        mp_raise_msg(&mp_type_KeyError, "pop from an empty set");
    }
    return obj;
}
Example #18
0
STATIC mp_obj_t set_symmetric_difference_update(mp_obj_t self_in, mp_obj_t other_in) {
    check_set(self_in);
    mp_obj_set_t *self = self_in;
    mp_obj_t iter = mp_getiter(other_in);
    mp_obj_t next;
    while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) {
        mp_set_lookup(&self->set, next, MP_MAP_LOOKUP_REMOVE_IF_FOUND | MP_MAP_LOOKUP_ADD_IF_NOT_FOUND);
    }
    return mp_const_none;
}
Example #19
0
/*=================================
 * check_nodes -- Check all nodes in database
 * (as selected in struct work)
 *================================*/
static void
check_nodes (void)
{
    seq_indis = create_indiseq_null();
    seq_fams = create_indiseq_null();
    seq_sours = create_indiseq_null();
    seq_evens = create_indiseq_null();
    seq_othes = create_indiseq_null();
    traverse_db_key_recs(nodes_callback, NULL);
    /* check what we saw against delete sets */
    check_set(seq_indis, 'I');
    check_set(seq_fams, 'F');
    check_set(seq_sours, 'S');
    check_set(seq_evens, 'E');
    check_set(seq_othes, 'X');
    remove_indiseq(seq_indis);
    remove_indiseq(seq_fams);
    remove_indiseq(seq_sours);
    remove_indiseq(seq_evens);
    remove_indiseq(seq_othes);
}
int
main (void)
{
  test_start ();

  check_set ();
  check_set_str (1024);

  test_end ();

  return 0;
}
Example #21
0
static int scsi_scan(struct Scsi_Host *shost, const char *str)
{
	char s1[15], s2[15], s3[15], junk;
	unsigned int channel, id, lun;
	int res;

	res = sscanf(str, "%10s %10s %10s %c", s1, s2, s3, &junk);
	if (res != 3)
		return -EINVAL;
	if (check_set(&channel, s1))
		return -EINVAL;
	if (check_set(&id, s2))
		return -EINVAL;
	if (check_set(&lun, s3))
		return -EINVAL;
	if (shost->transportt->user_scan)
		res = shost->transportt->user_scan(shost, channel, id, lun);
	else
		res = scsi_scan_host_selected(shost, channel, id, lun, 1);
	return res;
}
Example #22
0
int check_set(int i)
{
     int ans;
     int temp;
     if(arr[i].parent==i)
	  return i;
     temp=arr[i].parent;
     ans=check_set(arr[i].parent);
     arr[i].parent=ans;
     arr[i].group=(arr[i].group+arr[temp].group)&1;
    
     return ans;
}
Example #23
0
bool Board::check_deck() //checks to see if there are any sets left with the remaining cards
{
    for(unsigned int i=0; i < deck.size(); i++){
        for(unsigned int j=0; j < deck.size(); j++){
            for(unsigned int k=0; k < deck.size(); k++){
               if((i != j) && (j != k))
               {
                   if (check_set(deck[i], deck[j], deck[k]))
                   {
                       return true;
                   }
               }
            }
        }
    }
    return false;
}
// test program:
// sah_validate file1 ... filen
//
int main(int argc, char** argv) {
    vector<RESULT> results;
    double credit, test_credit=5.5;
    int i, canonical, retval;
    RESULT r;

    memset(&validate_stats, 0, sizeof(validate_stats));

    for (i=1; i<argc; i++) {
        memset(&r, 0, sizeof(r));
        r.claimed_credit = (test_credit += 3);
        r.id = i;
        sprintf(r.xml_doc_out,
                "<file_info>\n"
                "    <name>%s</name>\n"
                "</file_info>\n",
                argv[i]
               );
        results.push_back(r);
    }

    retval = check_set(results, canonical, credit);
    if (retval) {
        printf("error: %d\n", retval);
    }

    for (i=0; i < results.size(); i++) {
        printf("validate_state of %s is %d\n", argv[i+1], results[i].validate_state);
    }

    if (canonical) {
        printf("canonical result is %d; credit is %f\n", canonical, credit);
    } else {
        printf("no canonical result found\n");
    }
    validate_stats.print();
}
static void repeat_toggled (void * data, void * user)
{
    bool_t repeat = aud_get_bool (NULL, "repeat");
    check_set (toggleaction_group_others, "playback repeat", repeat);
}
static void no_advance_toggled (void * data, void * user)
{
    bool_t no_advance = aud_get_bool (NULL, "no_playlist_advance");
    check_set (toggleaction_group_others, "playback no playlist advance", no_advance);
}
static void shuffle_toggled (void * data, void * user)
{
    bool_t shuffle = aud_get_bool (NULL, "shuffle");
    check_set (toggleaction_group_others, "playback shuffle", shuffle);
}
Example #28
0
/*
 * Display current configuration parameters in a human readable format.
 */
void
display_config(struct mic_info *miclist)
{
	struct mic_info *mic;
	struct mbridge *br;
	char netmask[16];
	char micmac[64];
	char hostmac[64];
	int err = 0;
	int ret = 0;

	putchar('\n');
	mic = miclist;
	while (mic != NULL) {
		printf("%s:\n", mic->name);
		printf("=============================================================\n");

		if ((ret = micctrl_parse_config(&mpssenv, mic, &brlist, &mpssperr, PINFO))) {
			err++;

			if (ret < MIC_PARSE_ERRORS) {
				display(PERROR, "Not configured\n");
				goto nextmic;
			}
		}

		printf("    Config Version: %d.%d\n\n", (mic->config.version >> 16) & 0xff, mic->config.version & 0xff);
		printf("    Linux Kernel:   %s\n", check_set(mic->config.boot.osimage));
		printf("    Map File:       %s\n", check_set(mic->config.boot.systemmap));
		printf("    Family:         %s\n", family_to_str(mic->config.family));
		printf("    MPSSVersion:    %s\n", mpss_version_to_str(mic->config.mpss_version));

		printf("    BootOnStart:    %s\n",
			(mic->config.boot.onstart == TRUE)? "Enabled" : "Disabled");
		printf("    Shutdowntimeout: %s seconds\n", check_set(mic->config.misc.shutdowntimeout));

		printf("\n    ExtraCommandLine: %s\n", check_set(mic->config.boot.extraCmdline));
		printf("    PowerManagment: %s\n", check_set(mic->config.boot.pm));

		printf("\n    ");
		report_rootdev(mic);

		get_mac_strings(mic, micmac, hostmac, 64);

		switch (mic->config.net.type) {
		case NETWORK_TYPE_STATPAIR:
			printf("\n    Network:       Static Pair\n");
			printf("        Hostname:  %s\n", check_set(mic->config.net.hostname));
			printf("        MIC IP:    %s\n", check_set(mic->config.net.micIP));
			printf("        Host IP:   %s\n", check_set(mic->config.net.hostIP));

			if (mic->config.net.prefix == NULL)
				mic->config.net.prefix = "24";

			mpssnet_genmask(mic->config.net.prefix, netmask);
			printf("        Net Bits:  %s\n", check_set(mic->config.net.prefix));
			printf("        NetMask:   %s\n", netmask);

			if (mic->config.net.mtu)
				printf("        MtuSize:   %s\n", check_set(mic->config.net.mtu));

			break;

		case NETWORK_TYPE_STATBRIDGE:
			printf("\n    Network:       Static bridge %s\n", check_set(mic->config.net.bridge));
			printf("        MIC IP:    %s\n", check_set(mic->config.net.micIP));

			if ((br = mpss_bridge_byname(mic->config.net.bridge, brlist)) != NULL) {
				printf("        Host IP:   %s\n", check_set(br->ip));

				mpssnet_genmask(br->prefix, netmask);
				printf("        Net Bits:  %s\n", check_set(br->prefix));
				printf("        NetMask:   %s\n", netmask);
				printf("        MtuSize:   %s\n", check_set(br->mtu));
			}

			printf("        Hostname:  %s\n", check_set(mic->config.net.hostname));
			break;
		case NETWORK_TYPE_BRIDGE:
			printf("\n    Network:       Bridge %s with DHCP\n", check_set(mic->config.net.bridge));

			if ((br = mpss_bridge_byname(mic->config.net.bridge, brlist)) != NULL) {
				mpssnet_genmask(br->prefix, netmask);
				printf("        Net Bits:  %s\n", check_set(br->prefix));
				printf("        NetMask:   %s\n", netmask);
				printf("        MtuSize:   %s\n", check_set(br->mtu));
			}

			printf("        Hostname:  %s\n", check_set(mic->config.net.hostname));
			break;
		default:
			printf("%s: Unknown network configuration type\n", mic->name);
		}
		printf("        MIC MAC:   %s\n", micmac);
		printf("        Host MAC:  %s\n", hostmac);

		printf("\n    ");
		display_ldap(mic, TRUE);
		printf("     ");
		display_nis(mic, TRUE);

		printf("\n    Cgroup:\n");
		printf("        Memory:    %s\n", (mic->config.cgroup.memory == TRUE)? "Enabled" : "Disabled");

		printf("\n    Console:        %s\n", check_set(mic->config.boot.console));

		printf("    VerboseLogging: %s\n",
			(mic->config.boot.verbose == TRUE)? "Enabled" : "Disabled");

		if (mic->config.misc.crashdumpDir != NULL) 
			printf("    CrashDump:      %s %sGB\n", check_set(mic->config.misc.crashdumpDir),
								check_set(mic->config.misc.crashdumplimitgb));
		else
			printf("    CrashDump:      Not Enabled\n");
nextmic:
		putchar('\n');
		mic = mic->next;
	}

	exit(err);
}
Example #29
0
STATIC mp_obj_t set_add(mp_obj_t self_in, mp_obj_t item) {
    check_set(self_in);
    mp_obj_set_t *self = self_in;
    mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND);
    return mp_const_none;
}
Example #30
0
STATIC mp_obj_t set_discard(mp_obj_t self_in, mp_obj_t item) {
    check_set(self_in);
    mp_obj_set_t *self = self_in;
    mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_REMOVE_IF_FOUND);
    return mp_const_none;
}