本文整理汇总了C++中FLAG函数的典型用法代码示例。如果您正苦于以下问题:C++ FLAG函数的具体用法?C++ FLAG怎么用?C++ FLAG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FLAG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bst_add
bool_t bst_add(bst_key_t k, node_t* root, int id){
//fprintf(stderr, "bst add\n");
// node_t* pred;
// node_t* curr;
node_t* new_node;
// operation_t* pred_op;
// operation_t* curr_op;
operation_t* cas_op;
// search_res_t result;
bst_search_result_t* my_result;
while(TRUE) {
//root is now a global pointer to a node, not a node
my_result = bst_find(k, /*&pred, &pred_op, &curr, &curr_op, */root, root, id);
if (my_result->result == FOUND) {
return FALSE;
}
// allocate memory
// new_node = new Node(k);
new_node = (node_t*) ssalloc(sizeof(node_t));
new_node->key = k;
new_node->op = NULL;
new_node->left = NULL;
new_node->right = NULL;
// fprintf(stderr, "new_node address: %p, 64bit aligned: %d key address %p, left node addr: %p, right node addr: %p, op addr: %p\n", new_node, ((unsigned long)new_node & 7) == 0,&(new_node->key), &(new_node->left), &(new_node->right), &(new_node->op)
// );
bool_t is_left = (my_result->result == NOT_FOUND_L);
node_t* old;
if (is_left) {
old = my_result->curr->left;
} else {
old = my_result->curr->right;
}
// allocate memory
//cas_op = new child_cas_op_t(is_left, old, new_node)
cas_op = (operation_t*) ssalloc_alloc(1, sizeof(operation_t));
cas_op->child_cas_op.is_left = is_left;
cas_op->child_cas_op.expected = old;
cas_op->child_cas_op.update = new_node;
// fprintf(stderr, "cas_op address: %p, is_left address: %p, expected addr: %p, update addr: %p\n", (unsigned long)cas_op, &(cas_op->child_cas_op.is_left), &(cas_op->child_cas_op.expected), &(cas_op->child_cas_op.update)
// );
if (CAS_PTR(&(my_result->curr->op), my_result->curr_op, FLAG(cas_op, STATE_OP_CHILDCAS)) == my_result->curr_op) {
// legit cast? YES!! verif
bst_help_child_cas(cas_op, my_result->curr/*, root*/);
return TRUE;
}
}
}
示例2: check_dirent
static void check_dirent(struct dirent *ent, t_array *dirs, t_file *file,
t_args *args)
{
t_file *tmp;
if (args->args_count < 2)
args->args_count = 2;
if (FLAG(FLAG_RR) && ent->d_type == DT_DIR && !ft_strequ(file->real, ".") &&
!ft_strequ(file->real, "..") && (!FLAG(FLAG_L) ||
(file->stats->st_mode & S_IFMT) != S_IFLNK))
{
tmp = MAL1(t_file);
tmp->name = ft_stringdup(file->name);
tmp->path = ft_stringdup(file->path);
tmp->dir = NULL;
tmp->real = ent->d_name;
tmp->err = 0;
tmp->stats = MAL1(struct stat);
ft_memmove(tmp->stats, file->stats, sizeof(struct stat));
ft_arrayadd(dirs, tmp);
}
示例3: mm_init
/*
* Initialize: return -1 on error, 0 on success.
*/
int mm_init(void) {
/* Create the initial empty heap */
if ((heap_listp = mem_sbrk(WSIZE + SEG_LEVLL * DSIZE)) == (void *)-1)
return -1;
flist_tbl = heap_listp;
init_free_list();
int table_off = 2 * SEG_LEVLL * WSIZE;
PUT(heap_listp + table_off, PACK(4, 1)); /* Prologue header */
PUT(heap_listp + table_off + 4, PACK(0, 1)); /* Epilogue header */
FLAG(heap_listp + table_off);
FLAG(heap_listp + table_off + 4); /* set the alloc FLAG in next block */
heap_listp += table_off + 4;
/* Extend the empty heap with a free block of CHUNKSIZE bytes */
char *freeb = extend_heap(CHUNKSIZE/WSIZE);
if (freeb == NULL) {
return -1;
}
return 0;
}
示例4: main
int main(int argc, char **argv)
{
int flag_all = 0;
int flag_debug = 0;
char *input_file = "";
char *log_level = "";
int i;
program = argv[0];
parse_options(&argc, &argv, OPTIONS(
FLAG('a', "all", flag_all, 1),
FLAG('d', "debug", flag_debug, 1),
PARAMETER('i', "input-file", input_file),
PARAMETER_DEFAULT('l', "log-level", log_level, "error"),
FLAG_CALLBACK('h', "help", help),
FLAG_CALLBACK('v', 0, verbose)
));
for (i = 0; i <= argc; ++i) {
if (argv[i])
printf("argv[%d] = \"%s\";\n", i, argv[i]);
else
printf("argv[%d] = 0;\n", i);
}
printf(
" All: %s\n"
" Debug: %s\n"
"Verbosity: %d\n"
" Input: '%s'\n"
"Log Level: '%s'\n",
ON(flag_all),
ON(flag_debug),
verbosity,
input_file,
log_level
);
return 0;
}
示例5: bst_help_relocate
bool_t bst_help_relocate(operation_t* op, node_t* pred, operation_t* pred_op, node_t* curr/*, node_t* root*/){
//fprintf(stderr, "bst help relocate\n");
int seen_state = op->relocate_op.state;
if (seen_state == STATE_OP_ONGOING) {
//VCAS in original implementation
operation_t* seen_op = CAS_PTR(&(op->relocate_op.dest->op), op->relocate_op.dest_op, FLAG(op, STATE_OP_RELOCATE));
if ((seen_op == op->relocate_op.dest_op) || (seen_op == (operation_t *)FLAG(op, STATE_OP_RELOCATE))){
CAS_PTR(&(op->relocate_op.state), STATE_OP_ONGOING, STATE_OP_SUCCESSFUL);
seen_state = STATE_OP_SUCCESSFUL;
} else {
// VCAS
seen_state = CAS_PTR(&(op->relocate_op.state), STATE_OP_ONGOING, STATE_OP_FAILED);
}
}
if (seen_state == STATE_OP_SUCCESSFUL) {
// TODO not clear in the paper code
CAS_PTR(&(op->relocate_op.dest->key), op->relocate_op.remove_key, op->relocate_op.replace_key);
CAS_PTR(&(op->relocate_op.dest->op), FLAG(op, STATE_OP_RELOCATE), FLAG(op, STATE_OP_NONE));
}
bool_t result = (seen_state == STATE_OP_SUCCESSFUL);
if (op->relocate_op.dest == curr) {
return result;
}
CAS_PTR(&(curr->op), FLAG(op, STATE_OP_RELOCATE), FLAG(op, result ? STATE_OP_MARK : STATE_OP_NONE));
if (result) {
if (op->relocate_op.dest == pred) {
pred_op = (operation_t *)FLAG(op, STATE_OP_NONE);
}
bst_help_marked(pred, pred_op, curr/*, root*/);
}
return result;
}
示例6: strcpy
static char *cr4_str(u32_t e)
{
static char str[80];
strcpy(str, "");
FLAG(I386_CR4_VME);
FLAG(I386_CR4_PVI);
FLAG(I386_CR4_TSD);
FLAG(I386_CR4_DE);
FLAG(I386_CR4_PSE);
FLAG(I386_CR4_PAE);
FLAG(I386_CR4_MCE);
FLAG(I386_CR4_PGE);
if(e) { strcat(str, " (++)"); }
return str;
}
示例7: aftol
long aftol(char *str)
{
char ch;
size_t c=0;
ulong l=0UL;
while(str[c]) {
ch=toupper(str[c]);
if(ch>='A' && ch<='Z')
l|=FLAG(ch);
c++;
}
return(l);
}
示例8: letter
/*!
Returns true if the character is a letter (Letter_* categories);
otherwise returns false.
*/
bool QChar::isLetter() const
{
const int test = FLAG(Letter_Uppercase) |
FLAG(Letter_Lowercase) |
FLAG(Letter_Titlecase) |
FLAG(Letter_Modifier) |
FLAG(Letter_Other);
return FLAG(qGetProp(ucs)->category) & test;
}
示例9: bst_remove
sval_t bst_remove(skey_t key, node_t* node_r) {
bool_t injecting = TRUE;
node_t* leaf;
sval_t val = 0;
while (1) {
UPDATE_TRY();
bst_seek(key, node_r);
val = seek_record->leaf->value;
node_t* parent = seek_record->parent;
node_t** child_addr;
if (key < parent->key) {
child_addr = (node_t**) &(parent->left);
} else {
child_addr = (node_t**) &(parent->right);
}
if (injecting == TRUE) {
leaf = seek_record->leaf;
if (leaf->key != key) {
return 0;
}
node_t* lf = ADDRESS(leaf);
node_t* result = CAS_PTR(child_addr, lf, FLAG(lf));
if (result == ADDRESS(leaf)) {
injecting = FALSE;
bool_t done = bst_cleanup(key);
if (done == TRUE) {
return val;
}
} else {
node_t* chld = *child_addr;
if ( (ADDRESS(chld) == leaf) && (GETFLAG(chld) || GETTAG(chld)) ) {
bst_cleanup(key);
}
}
} else {
if (seek_record->leaf != leaf) {
return val;
} else {
bool_t done = bst_cleanup(key);
if (done == TRUE) {
return val;
}
}
}
}
}
示例10: madwifi_real_init
static int madwifi_real_init(void) {
size_t max = STATIC_ARRAY_SIZE(specs);
for (size_t i = 0; i < STATIC_ARRAY_SIZE(bounds); i++)
bounds[i] = 0;
watchlist_set(watch_items, 0);
watchlist_set(misc_items, 0);
for (size_t i = 0; i < max; i++) {
bounds[specs[i].flags & SRC_MASK] = i;
if (specs[i].flags & LOG)
watch_items[i / 32] |= FLAG(i);
if (specs[i].flags & SU)
misc_items[i / 32] |= FLAG(i);
}
for (size_t i = 0; i < STATIC_ARRAY_SIZE(bounds); i++)
bounds[i]++;
return (0);
}
示例11: YeloPrepareDefinitions
// Process a blam scenario for the current operating mode (editing or cache building).
// Returns the blam scenario's handle or datum_index::null
Yelo::datum_index YeloPrepareDefinitions(cstring scenario_name, const bool for_build_cache)
{
// If we're not building a cache file, just load the scenario into memory without any of its references
datum_index scenario_index = tag_load<TagGroups::scenario>(scenario_name, for_build_cache ?
FLAG(Flags::_tag_load_verify_exist_first_bit) :
FLAG(Flags::_tag_load_non_resolving_references_bit));
if(!scenario_index.IsNull())
{
TagGroups::scenario* scenario = tag_get<TagGroups::scenario>(scenario_index);
datum_index yelo = YeloPrepareDefinitionsYeloScenario(
scenario->GetYeloReferenceHack(), for_build_cache);
// if we're not building a cache, then this is sapien and we want it to load
// the scenario and all of it's dependencies after we return the code flow
// back to it
if(!for_build_cache) tag_unload(scenario_index);
return yelo;
}
return datum_index::null;
}
示例12: HT4C_THROW_ARGUMENT
void Cells::add( const char* row, const char* columnFamily, const char* columnQualifier, uint64_t timestamp, const void* value, uint32_t valueLength, uint8_t flag ) {
if( valueLength > Cell::MaxSize ) {
HT4C_THROW_ARGUMENT("cell value exceeds the limit", "valueLength");
}
flag = FLAG( columnFamily, columnQualifier, flag );
Cell cell( row
, CF(columnFamily)
, columnQualifier
, TIMESTAMP(timestamp, flag)
, value
, valueLength
, flag);
cellsBuilder->add( cell.get(), true );
}
示例13: bst_add
bool_t bst_add(bst_key_t k, node_t* root){
node_t* pred;
node_t* curr;
node_t* new_node;
operation_t* pred_op;
operation_t* curr_op;
operation_t* cas_op;
search_res_t result;
while(TRUE) {
result = bst_find(k, &pred, &pred_op, &curr, &curr_op, root, root);
if (result == FOUND) {
return FALSE;
}
new_node = (node_t*) ssalloc(sizeof(node_t));
new_node->key = k;
new_node->op = NULL;
new_node->left = NULL;
new_node->right = NULL;
bool_t is_left = (result == NOT_FOUND_L);
node_t* old;
if (is_left) {
old = curr->left;
} else {
old = curr->right;
}
cas_op = (operation_t*) ssalloc_alloc(1, sizeof(operation_t));
cas_op->child_cas_op.is_left = is_left;
cas_op->child_cas_op.expected = old;
cas_op->child_cas_op.update = new_node;
#if defined(__tile__)
MEM_BARRIER;
#endif
if (CAS_PTR(&curr->op, curr_op, FLAG(cas_op, STATE_OP_CHILDCAS)) == curr_op) {
bst_help_child_cas(cas_op, curr, root);
return TRUE;
}
}
}
示例14: borg_build_inn
/* Get food and rest at the inn */
static bool borg_build_inn(void)
{
int i;
list_item *l_ptr;
bool rest = TRUE;
/* Is it light outside */
rest &= (bp_ptr->hour < 6 || bp_ptr->hour > 17);
/* This is a respectable place */
rest &= !bp_ptr->status.cut && !bp_ptr->status.poisoned;
/* Check the vampire flag */
rest &= !FLAG(bp_ptr, TR_HURT_LITE);
/* Loop through the equipment */
for (i = 0; i < equip_num; i++)
{
l_ptr = look_up_equip_slot(i);
/* Check the equipment for that flag */
if (l_ptr) rest &= !KN_FLAG(l_ptr, TR_HURT_LITE);
}
/* If the borg wants a rest */
if (rest && borg_gold > 25)
{
/* Wait for daybreak */
borg_keypress('R');
}
/* Can the borg use more food? */
if (!bp_ptr->status.full && borg_gold > 25)
{
/* Have dinner */
borg_keypress('E');
}
/* One pass takes care of all needs */
return (FALSE);
}
示例15: param
cell_t *parse_word(seg_t w, cell_t *module, unsigned int n, cell_t *entry) {
cell_t *c;
cell_t *data = NULL;
csize_t in = 0, out = 1;
if(w.s[0] == '?' && w.n == 1) {
c = param(T_ANY, entry);
} else if(in = 1, out = 1, match_param_word("ap", w, &in, &out)) {
c = func(OP_ap, ++in, ++out);
} else if(in = 1, out = 1, match_param_word("comp", w, &in, &out)) {
in += 2;
c = func(OP_compose, in, ++out);
} else if(in = 1, out = 1, match_param_word("external", w, &in, &out)) {
c = func(OP_external, ++in, out);
} else {
cell_t *e = lookup_word(w);
if(!e) e = module_lookup_compiled(w, &module);
if(e) {
in = e->entry.in;
out = e->entry.out;
if(FLAG(*e, entry, PRIMITIVE)) {
if(e->op == OP_placeholder) {
c = func(OP_placeholder, n + 1, 1);
int x = trace_alloc(entry, n + 2);
in = n;
out = 1;
data = var_create(T_LIST, tc_get(entry, x), 0, 0);
} else {
c = func(e->op, e->entry.in, e->entry.out);
}
} else {
c = func(OP_exec, e->entry.in + 1, e->entry.out);
data = e;
}
} else {
return NULL;
}
}
if(in) c->expr.arg[0] = (cell_t *)(intptr_t)(in - 1);
TRAVERSE(c, out) {
*p = dep(c);
}