hexsha
stringlengths
40
40
repo
stringlengths
5
105
path
stringlengths
3
173
license
sequence
language
stringclasses
1 value
identifier
stringlengths
1
438
return_type
stringlengths
1
106
original_string
stringlengths
21
40.7k
original_docstring
stringlengths
18
13.4k
docstring
stringlengths
11
3.24k
docstring_tokens
sequence
code
stringlengths
14
20.4k
code_tokens
sequence
short_docstring
stringlengths
0
4.36k
short_docstring_tokens
sequence
comment
sequence
parameters
list
docstring_params
dict
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/block/cfq-iosched.c
[ "Apache-2.0" ]
C
cfq_rb_first
null
static struct cfq_queue *cfq_rb_first(struct cfq_rb_root *root) { /* Service tree is empty */ if (!root->count) return NULL; if (!root->left) root->left = rb_first(&root->rb); //if (root->left) //return rb_entry(root->left, struct cfq_queue, rb_node); return NULL; }
/* * The below is leftmost cache rbtree addon */
The below is leftmost cache rbtree addon
[ "The", "below", "is", "leftmost", "cache", "rbtree", "addon" ]
static struct cfq_queue *cfq_rb_first(struct cfq_rb_root *root) { if (!root->count) return NULL; if (!root->left) root->left = rb_first(&root->rb); return NULL; }
[ "static", "struct", "cfq_queue", "*", "cfq_rb_first", "(", "struct", "cfq_rb_root", "*", "root", ")", "{", "if", "(", "!", "root", "->", "count", ")", "return", "NULL", ";", "if", "(", "!", "root", "->", "left", ")", "root", "->", "left", "=", "rb_first", "(", "&", "root", "->", "rb", ")", ";", "return", "NULL", ";", "}" ]
The below is leftmost cache rbtree addon
[ "The", "below", "is", "leftmost", "cache", "rbtree", "addon" ]
[ "/* Service tree is empty */", "//if (root->left)", "//return rb_entry(root->left, struct cfq_queue, rb_node);" ]
[ { "param": "root", "type": "struct cfq_rb_root" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root", "type": "struct cfq_rb_root", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/block/cfq-iosched.c
[ "Apache-2.0" ]
C
cfq_find_next_rq
null
static struct request * cfq_find_next_rq(struct cfq_data *cfqd, struct cfq_queue *cfqq, struct request *last) { struct rb_node *rbnext = rb_next(&last->rb_node); struct rb_node *rbprev = rb_prev(&last->rb_node); struct request *next = NULL, *prev = NULL; BUG_ON(RB_EMPTY_NODE(&last->rb_node)); if (rbprev) prev = rb_entry_rq(rbprev); if (rbnext) next = rb_entry_rq(rbnext); else { rbnext = rb_first(&cfqq->sort_list); if (rbnext && rbnext != &last->rb_node) next = rb_entry_rq(rbnext); } return cfq_choose_req(cfqd, next, prev, blk_rq_pos(last)); }
/* * would be nice to take fifo expire time into account as well */
would be nice to take fifo expire time into account as well
[ "would", "be", "nice", "to", "take", "fifo", "expire", "time", "into", "account", "as", "well" ]
static struct request * cfq_find_next_rq(struct cfq_data *cfqd, struct cfq_queue *cfqq, struct request *last) { struct rb_node *rbnext = rb_next(&last->rb_node); struct rb_node *rbprev = rb_prev(&last->rb_node); struct request *next = NULL, *prev = NULL; BUG_ON(RB_EMPTY_NODE(&last->rb_node)); if (rbprev) prev = rb_entry_rq(rbprev); if (rbnext) next = rb_entry_rq(rbnext); else { rbnext = rb_first(&cfqq->sort_list); if (rbnext && rbnext != &last->rb_node) next = rb_entry_rq(rbnext); } return cfq_choose_req(cfqd, next, prev, blk_rq_pos(last)); }
[ "static", "struct", "request", "*", "cfq_find_next_rq", "(", "struct", "cfq_data", "*", "cfqd", ",", "struct", "cfq_queue", "*", "cfqq", ",", "struct", "request", "*", "last", ")", "{", "struct", "rb_node", "*", "rbnext", "=", "rb_next", "(", "&", "last", "->", "rb_node", ")", ";", "struct", "rb_node", "*", "rbprev", "=", "rb_prev", "(", "&", "last", "->", "rb_node", ")", ";", "struct", "request", "*", "next", "=", "NULL", ",", "*", "prev", "=", "NULL", ";", "BUG_ON", "(", "RB_EMPTY_NODE", "(", "&", "last", "->", "rb_node", ")", ")", ";", "if", "(", "rbprev", ")", "prev", "=", "rb_entry_rq", "(", "rbprev", ")", ";", "if", "(", "rbnext", ")", "next", "=", "rb_entry_rq", "(", "rbnext", ")", ";", "else", "{", "rbnext", "=", "rb_first", "(", "&", "cfqq", "->", "sort_list", ")", ";", "if", "(", "rbnext", "&&", "rbnext", "!=", "&", "last", "->", "rb_node", ")", "next", "=", "rb_entry_rq", "(", "rbnext", ")", ";", "}", "return", "cfq_choose_req", "(", "cfqd", ",", "next", ",", "prev", ",", "blk_rq_pos", "(", "last", ")", ")", ";", "}" ]
would be nice to take fifo expire time into account as well
[ "would", "be", "nice", "to", "take", "fifo", "expire", "time", "into", "account", "as", "well" ]
[]
[ { "param": "cfqd", "type": "struct cfq_data" }, { "param": "cfqq", "type": "struct cfq_queue" }, { "param": "last", "type": "struct request" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cfqd", "type": "struct cfq_data", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cfqq", "type": "struct cfq_queue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "last", "type": "struct request", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/block/cfq-iosched.c
[ "Apache-2.0" ]
C
cfq_init_cfqg_base
void
static void cfq_init_cfqg_base(struct cfq_group *cfqg) { struct cfq_rb_root *st; int i, j; for_each_cfqg_st(cfqg, i, j, st) *st = CFQ_RB_ROOT; RB_CLEAR_NODE(&cfqg->rb_node); cfqg->ttime.last_end_request = jiffies; }
/** * cfq_init_cfqg_base - initialize base part of a cfq_group * @cfqg: cfq_group to initialize * * Initialize the base part which is used whether %CFQ_GROUP_IOSCHED * is enabled or not. */
initialize base part of a cfq_group @cfqg: cfq_group to initialize Initialize the base part which is used whether %CFQ_GROUP_IOSCHED is enabled or not.
[ "initialize", "base", "part", "of", "a", "cfq_group", "@cfqg", ":", "cfq_group", "to", "initialize", "Initialize", "the", "base", "part", "which", "is", "used", "whether", "%CFQ_GROUP_IOSCHED", "is", "enabled", "or", "not", "." ]
static void cfq_init_cfqg_base(struct cfq_group *cfqg) { struct cfq_rb_root *st; int i, j; for_each_cfqg_st(cfqg, i, j, st) *st = CFQ_RB_ROOT; RB_CLEAR_NODE(&cfqg->rb_node); cfqg->ttime.last_end_request = jiffies; }
[ "static", "void", "cfq_init_cfqg_base", "(", "struct", "cfq_group", "*", "cfqg", ")", "{", "struct", "cfq_rb_root", "*", "st", ";", "int", "i", ",", "j", ";", "for_each_cfqg_st", "(", "cfqg", ",", "i", ",", "j", ",", "st", ")", "*", "st", "=", "CFQ_RB_ROOT", ";", "RB_CLEAR_NODE", "(", "&", "cfqg", "->", "rb_node", ")", ";", "cfqg", "->", "ttime", ".", "last_end_request", "=", "jiffies", ";", "}" ]
cfq_init_cfqg_base - initialize base part of a cfq_group @cfqg: cfq_group to initialize
[ "cfq_init_cfqg_base", "-", "initialize", "base", "part", "of", "a", "cfq_group", "@cfqg", ":", "cfq_group", "to", "initialize" ]
[]
[ { "param": "cfqg", "type": "struct cfq_group" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cfqg", "type": "struct cfq_group", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/block/cfq-iosched.c
[ "Apache-2.0" ]
C
cfq_lookup_create_cfqg
null
static struct cfq_group *cfq_lookup_create_cfqg(struct cfq_data *cfqd, struct blkio_cgroup *blkcg) { struct request_queue *q = cfqd->queue; struct cfq_group *cfqg = NULL; /* avoid lookup for the common case where there's no blkio cgroup */ if (blkcg == &blkio_root_cgroup) { cfqg = cfqd->root_group; } else { struct blkio_group *blkg; blkg = blkg_lookup_create(blkcg, q, false); if (!IS_ERR(blkg)) cfqg = blkg_to_cfqg(blkg); } return cfqg; }
/* * Search for the cfq group current task belongs to. request_queue lock must * be held. */
Search for the cfq group current task belongs to. request_queue lock must be held.
[ "Search", "for", "the", "cfq", "group", "current", "task", "belongs", "to", ".", "request_queue", "lock", "must", "be", "held", "." ]
static struct cfq_group *cfq_lookup_create_cfqg(struct cfq_data *cfqd, struct blkio_cgroup *blkcg) { struct request_queue *q = cfqd->queue; struct cfq_group *cfqg = NULL; if (blkcg == &blkio_root_cgroup) { cfqg = cfqd->root_group; } else { struct blkio_group *blkg; blkg = blkg_lookup_create(blkcg, q, false); if (!IS_ERR(blkg)) cfqg = blkg_to_cfqg(blkg); } return cfqg; }
[ "static", "struct", "cfq_group", "*", "cfq_lookup_create_cfqg", "(", "struct", "cfq_data", "*", "cfqd", ",", "struct", "blkio_cgroup", "*", "blkcg", ")", "{", "struct", "request_queue", "*", "q", "=", "cfqd", "->", "queue", ";", "struct", "cfq_group", "*", "cfqg", "=", "NULL", ";", "if", "(", "blkcg", "==", "&", "blkio_root_cgroup", ")", "{", "cfqg", "=", "cfqd", "->", "root_group", ";", "}", "else", "{", "struct", "blkio_group", "*", "blkg", ";", "blkg", "=", "blkg_lookup_create", "(", "blkcg", ",", "q", ",", "false", ")", ";", "if", "(", "!", "IS_ERR", "(", "blkg", ")", ")", "cfqg", "=", "blkg_to_cfqg", "(", "blkg", ")", ";", "}", "return", "cfqg", ";", "}" ]
Search for the cfq group current task belongs to.
[ "Search", "for", "the", "cfq", "group", "current", "task", "belongs", "to", "." ]
[ "/* avoid lookup for the common case where there's no blkio cgroup */" ]
[ { "param": "cfqd", "type": "struct cfq_data" }, { "param": "blkcg", "type": "struct blkio_cgroup" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cfqd", "type": "struct cfq_data", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "blkcg", "type": "struct blkio_cgroup", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/block/cfq-iosched.c
[ "Apache-2.0" ]
C
cfq_add_cfqq_rr
void
static void cfq_add_cfqq_rr(struct cfq_data *cfqd, struct cfq_queue *cfqq) { cfq_log_cfqq(cfqd, cfqq, "add_to_rr"); BUG_ON(cfq_cfqq_on_rr(cfqq)); cfq_mark_cfqq_on_rr(cfqq); cfqd->busy_queues++; if (cfq_cfqq_sync(cfqq)) cfqd->busy_sync_queues++; cfq_resort_rr_list(cfqd, cfqq); }
/* * add to busy list of queues for service, trying to be fair in ordering * the pending list according to last request service */
add to busy list of queues for service, trying to be fair in ordering the pending list according to last request service
[ "add", "to", "busy", "list", "of", "queues", "for", "service", "trying", "to", "be", "fair", "in", "ordering", "the", "pending", "list", "according", "to", "last", "request", "service" ]
static void cfq_add_cfqq_rr(struct cfq_data *cfqd, struct cfq_queue *cfqq) { cfq_log_cfqq(cfqd, cfqq, "add_to_rr"); BUG_ON(cfq_cfqq_on_rr(cfqq)); cfq_mark_cfqq_on_rr(cfqq); cfqd->busy_queues++; if (cfq_cfqq_sync(cfqq)) cfqd->busy_sync_queues++; cfq_resort_rr_list(cfqd, cfqq); }
[ "static", "void", "cfq_add_cfqq_rr", "(", "struct", "cfq_data", "*", "cfqd", ",", "struct", "cfq_queue", "*", "cfqq", ")", "{", "cfq_log_cfqq", "(", "cfqd", ",", "cfqq", ",", "\"", "\"", ")", ";", "BUG_ON", "(", "cfq_cfqq_on_rr", "(", "cfqq", ")", ")", ";", "cfq_mark_cfqq_on_rr", "(", "cfqq", ")", ";", "cfqd", "->", "busy_queues", "++", ";", "if", "(", "cfq_cfqq_sync", "(", "cfqq", ")", ")", "cfqd", "->", "busy_sync_queues", "++", ";", "cfq_resort_rr_list", "(", "cfqd", ",", "cfqq", ")", ";", "}" ]
add to busy list of queues for service, trying to be fair in ordering the pending list according to last request service
[ "add", "to", "busy", "list", "of", "queues", "for", "service", "trying", "to", "be", "fair", "in", "ordering", "the", "pending", "list", "according", "to", "last", "request", "service" ]
[]
[ { "param": "cfqd", "type": "struct cfq_data" }, { "param": "cfqq", "type": "struct cfq_queue" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cfqd", "type": "struct cfq_data", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cfqq", "type": "struct cfq_queue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/block/cfq-iosched.c
[ "Apache-2.0" ]
C
cfq_del_cfqq_rr
void
static void cfq_del_cfqq_rr(struct cfq_data *cfqd, struct cfq_queue *cfqq) { cfq_log_cfqq(cfqd, cfqq, "del_from_rr"); BUG_ON(!cfq_cfqq_on_rr(cfqq)); cfq_clear_cfqq_on_rr(cfqq); if (!RB_EMPTY_NODE(&cfqq->rb_node)) { cfq_rb_erase(&cfqq->rb_node, cfqq->service_tree); cfqq->service_tree = NULL; } if (cfqq->p_root) { rb_erase(&cfqq->p_node, cfqq->p_root); cfqq->p_root = NULL; } cfq_group_notify_queue_del(cfqd, cfqq->cfqg); BUG_ON(!cfqd->busy_queues); cfqd->busy_queues--; if (cfq_cfqq_sync(cfqq)) cfqd->busy_sync_queues--; }
/* * Called when the cfqq no longer has requests pending, remove it from * the service tree. */
Called when the cfqq no longer has requests pending, remove it from the service tree.
[ "Called", "when", "the", "cfqq", "no", "longer", "has", "requests", "pending", "remove", "it", "from", "the", "service", "tree", "." ]
static void cfq_del_cfqq_rr(struct cfq_data *cfqd, struct cfq_queue *cfqq) { cfq_log_cfqq(cfqd, cfqq, "del_from_rr"); BUG_ON(!cfq_cfqq_on_rr(cfqq)); cfq_clear_cfqq_on_rr(cfqq); if (!RB_EMPTY_NODE(&cfqq->rb_node)) { cfq_rb_erase(&cfqq->rb_node, cfqq->service_tree); cfqq->service_tree = NULL; } if (cfqq->p_root) { rb_erase(&cfqq->p_node, cfqq->p_root); cfqq->p_root = NULL; } cfq_group_notify_queue_del(cfqd, cfqq->cfqg); BUG_ON(!cfqd->busy_queues); cfqd->busy_queues--; if (cfq_cfqq_sync(cfqq)) cfqd->busy_sync_queues--; }
[ "static", "void", "cfq_del_cfqq_rr", "(", "struct", "cfq_data", "*", "cfqd", ",", "struct", "cfq_queue", "*", "cfqq", ")", "{", "cfq_log_cfqq", "(", "cfqd", ",", "cfqq", ",", "\"", "\"", ")", ";", "BUG_ON", "(", "!", "cfq_cfqq_on_rr", "(", "cfqq", ")", ")", ";", "cfq_clear_cfqq_on_rr", "(", "cfqq", ")", ";", "if", "(", "!", "RB_EMPTY_NODE", "(", "&", "cfqq", "->", "rb_node", ")", ")", "{", "cfq_rb_erase", "(", "&", "cfqq", "->", "rb_node", ",", "cfqq", "->", "service_tree", ")", ";", "cfqq", "->", "service_tree", "=", "NULL", ";", "}", "if", "(", "cfqq", "->", "p_root", ")", "{", "rb_erase", "(", "&", "cfqq", "->", "p_node", ",", "cfqq", "->", "p_root", ")", ";", "cfqq", "->", "p_root", "=", "NULL", ";", "}", "cfq_group_notify_queue_del", "(", "cfqd", ",", "cfqq", "->", "cfqg", ")", ";", "BUG_ON", "(", "!", "cfqd", "->", "busy_queues", ")", ";", "cfqd", "->", "busy_queues", "--", ";", "if", "(", "cfq_cfqq_sync", "(", "cfqq", ")", ")", "cfqd", "->", "busy_sync_queues", "--", ";", "}" ]
Called when the cfqq no longer has requests pending, remove it from the service tree.
[ "Called", "when", "the", "cfqq", "no", "longer", "has", "requests", "pending", "remove", "it", "from", "the", "service", "tree", "." ]
[]
[ { "param": "cfqd", "type": "struct cfq_data" }, { "param": "cfqq", "type": "struct cfq_queue" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cfqd", "type": "struct cfq_data", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cfqq", "type": "struct cfq_queue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/block/cfq-iosched.c
[ "Apache-2.0" ]
C
__cfq_slice_expired
void
static void __cfq_slice_expired(struct cfq_data *cfqd, struct cfq_queue *cfqq, bool timed_out) { cfq_log_cfqq(cfqd, cfqq, "slice expired t=%d", timed_out); if (cfq_cfqq_wait_request(cfqq)) cfq_del_timer(cfqd, cfqq); cfq_clear_cfqq_wait_request(cfqq); cfq_clear_cfqq_wait_busy(cfqq); /* * If this cfqq is shared between multiple processes, check to * make sure that those processes are still issuing I/Os within * the mean seek distance. If not, it may be time to break the * queues apart again. */ if (cfq_cfqq_coop(cfqq) && CFQQ_SEEKY(cfqq)) cfq_mark_cfqq_split_coop(cfqq); /* * store what was left of this slice, if the queue idled/timed out */ if (timed_out) { if (cfq_cfqq_slice_new(cfqq)) cfqq->slice_resid = cfq_scaled_cfqq_slice(cfqd, cfqq); else cfqq->slice_resid = cfqq->slice_end - jiffies; cfq_log_cfqq(cfqd, cfqq, "resid=%ld", cfqq->slice_resid); } cfq_group_served(cfqd, cfqq->cfqg, cfqq); if (cfq_cfqq_on_rr(cfqq) && RB_EMPTY_ROOT(&cfqq->sort_list)) cfq_del_cfqq_rr(cfqd, cfqq); cfq_resort_rr_list(cfqd, cfqq); if (cfqq == cfqd->active_queue) cfqd->active_queue = NULL; if (cfqd->active_cic) { put_io_context(cfqd->active_cic->icq.ioc); cfqd->active_cic = NULL; } }
/* * current cfqq expired its slice (or was too idle), select new one */
current cfqq expired its slice (or was too idle), select new one
[ "current", "cfqq", "expired", "its", "slice", "(", "or", "was", "too", "idle", ")", "select", "new", "one" ]
static void __cfq_slice_expired(struct cfq_data *cfqd, struct cfq_queue *cfqq, bool timed_out) { cfq_log_cfqq(cfqd, cfqq, "slice expired t=%d", timed_out); if (cfq_cfqq_wait_request(cfqq)) cfq_del_timer(cfqd, cfqq); cfq_clear_cfqq_wait_request(cfqq); cfq_clear_cfqq_wait_busy(cfqq); if (cfq_cfqq_coop(cfqq) && CFQQ_SEEKY(cfqq)) cfq_mark_cfqq_split_coop(cfqq); if (timed_out) { if (cfq_cfqq_slice_new(cfqq)) cfqq->slice_resid = cfq_scaled_cfqq_slice(cfqd, cfqq); else cfqq->slice_resid = cfqq->slice_end - jiffies; cfq_log_cfqq(cfqd, cfqq, "resid=%ld", cfqq->slice_resid); } cfq_group_served(cfqd, cfqq->cfqg, cfqq); if (cfq_cfqq_on_rr(cfqq) && RB_EMPTY_ROOT(&cfqq->sort_list)) cfq_del_cfqq_rr(cfqd, cfqq); cfq_resort_rr_list(cfqd, cfqq); if (cfqq == cfqd->active_queue) cfqd->active_queue = NULL; if (cfqd->active_cic) { put_io_context(cfqd->active_cic->icq.ioc); cfqd->active_cic = NULL; } }
[ "static", "void", "__cfq_slice_expired", "(", "struct", "cfq_data", "*", "cfqd", ",", "struct", "cfq_queue", "*", "cfqq", ",", "bool", "timed_out", ")", "{", "cfq_log_cfqq", "(", "cfqd", ",", "cfqq", ",", "\"", "\"", ",", "timed_out", ")", ";", "if", "(", "cfq_cfqq_wait_request", "(", "cfqq", ")", ")", "cfq_del_timer", "(", "cfqd", ",", "cfqq", ")", ";", "cfq_clear_cfqq_wait_request", "(", "cfqq", ")", ";", "cfq_clear_cfqq_wait_busy", "(", "cfqq", ")", ";", "if", "(", "cfq_cfqq_coop", "(", "cfqq", ")", "&&", "CFQQ_SEEKY", "(", "cfqq", ")", ")", "cfq_mark_cfqq_split_coop", "(", "cfqq", ")", ";", "if", "(", "timed_out", ")", "{", "if", "(", "cfq_cfqq_slice_new", "(", "cfqq", ")", ")", "cfqq", "->", "slice_resid", "=", "cfq_scaled_cfqq_slice", "(", "cfqd", ",", "cfqq", ")", ";", "else", "cfqq", "->", "slice_resid", "=", "cfqq", "->", "slice_end", "-", "jiffies", ";", "cfq_log_cfqq", "(", "cfqd", ",", "cfqq", ",", "\"", "\"", ",", "cfqq", "->", "slice_resid", ")", ";", "}", "cfq_group_served", "(", "cfqd", ",", "cfqq", "->", "cfqg", ",", "cfqq", ")", ";", "if", "(", "cfq_cfqq_on_rr", "(", "cfqq", ")", "&&", "RB_EMPTY_ROOT", "(", "&", "cfqq", "->", "sort_list", ")", ")", "cfq_del_cfqq_rr", "(", "cfqd", ",", "cfqq", ")", ";", "cfq_resort_rr_list", "(", "cfqd", ",", "cfqq", ")", ";", "if", "(", "cfqq", "==", "cfqd", "->", "active_queue", ")", "cfqd", "->", "active_queue", "=", "NULL", ";", "if", "(", "cfqd", "->", "active_cic", ")", "{", "put_io_context", "(", "cfqd", "->", "active_cic", "->", "icq", ".", "ioc", ")", ";", "cfqd", "->", "active_cic", "=", "NULL", ";", "}", "}" ]
current cfqq expired its slice (or was too idle), select new one
[ "current", "cfqq", "expired", "its", "slice", "(", "or", "was", "too", "idle", ")", "select", "new", "one" ]
[ "/*\n\t * If this cfqq is shared between multiple processes, check to\n\t * make sure that those processes are still issuing I/Os within\n\t * the mean seek distance. If not, it may be time to break the\n\t * queues apart again.\n\t */", "/*\n\t * store what was left of this slice, if the queue idled/timed out\n\t */" ]
[ { "param": "cfqd", "type": "struct cfq_data" }, { "param": "cfqq", "type": "struct cfq_queue" }, { "param": "timed_out", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cfqd", "type": "struct cfq_data", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cfqq", "type": "struct cfq_queue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "timed_out", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/block/cfq-iosched.c
[ "Apache-2.0" ]
C
cfq_get_next_queue
null
static struct cfq_queue *cfq_get_next_queue(struct cfq_data *cfqd) { struct cfq_rb_root *service_tree = service_tree_for(cfqd->serving_group, cfqd->serving_prio, cfqd->serving_type); if (!cfqd->rq_queued) return NULL; /* There is nothing to dispatch */ if (!service_tree) return NULL; if (RB_EMPTY_ROOT(&service_tree->rb)) return NULL; return cfq_rb_first(service_tree); }
/* * Get next queue for service. Unless we have a queue preemption, * we'll simply select the first cfqq in the service tree. */
Get next queue for service. Unless we have a queue preemption, we'll simply select the first cfqq in the service tree.
[ "Get", "next", "queue", "for", "service", ".", "Unless", "we", "have", "a", "queue", "preemption", "we", "'", "ll", "simply", "select", "the", "first", "cfqq", "in", "the", "service", "tree", "." ]
static struct cfq_queue *cfq_get_next_queue(struct cfq_data *cfqd) { struct cfq_rb_root *service_tree = service_tree_for(cfqd->serving_group, cfqd->serving_prio, cfqd->serving_type); if (!cfqd->rq_queued) return NULL; if (!service_tree) return NULL; if (RB_EMPTY_ROOT(&service_tree->rb)) return NULL; return cfq_rb_first(service_tree); }
[ "static", "struct", "cfq_queue", "*", "cfq_get_next_queue", "(", "struct", "cfq_data", "*", "cfqd", ")", "{", "struct", "cfq_rb_root", "*", "service_tree", "=", "service_tree_for", "(", "cfqd", "->", "serving_group", ",", "cfqd", "->", "serving_prio", ",", "cfqd", "->", "serving_type", ")", ";", "if", "(", "!", "cfqd", "->", "rq_queued", ")", "return", "NULL", ";", "if", "(", "!", "service_tree", ")", "return", "NULL", ";", "if", "(", "RB_EMPTY_ROOT", "(", "&", "service_tree", "->", "rb", ")", ")", "return", "NULL", ";", "return", "cfq_rb_first", "(", "service_tree", ")", ";", "}" ]
Get next queue for service.
[ "Get", "next", "queue", "for", "service", "." ]
[ "/* There is nothing to dispatch */" ]
[ { "param": "cfqd", "type": "struct cfq_data" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cfqd", "type": "struct cfq_data", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/block/cfq-iosched.c
[ "Apache-2.0" ]
C
cfq_set_active_queue
null
static struct cfq_queue *cfq_set_active_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq) { if (!cfqq) cfqq = cfq_get_next_queue(cfqd); __cfq_set_active_queue(cfqd, cfqq); return cfqq; }
/* * Get and set a new active queue for service. */
Get and set a new active queue for service.
[ "Get", "and", "set", "a", "new", "active", "queue", "for", "service", "." ]
static struct cfq_queue *cfq_set_active_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq) { if (!cfqq) cfqq = cfq_get_next_queue(cfqd); __cfq_set_active_queue(cfqd, cfqq); return cfqq; }
[ "static", "struct", "cfq_queue", "*", "cfq_set_active_queue", "(", "struct", "cfq_data", "*", "cfqd", ",", "struct", "cfq_queue", "*", "cfqq", ")", "{", "if", "(", "!", "cfqq", ")", "cfqq", "=", "cfq_get_next_queue", "(", "cfqd", ")", ";", "__cfq_set_active_queue", "(", "cfqd", ",", "cfqq", ")", ";", "return", "cfqq", ";", "}" ]
Get and set a new active queue for service.
[ "Get", "and", "set", "a", "new", "active", "queue", "for", "service", "." ]
[]
[ { "param": "cfqd", "type": "struct cfq_data" }, { "param": "cfqq", "type": "struct cfq_queue" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cfqd", "type": "struct cfq_data", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cfqq", "type": "struct cfq_queue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/block/cfq-iosched.c
[ "Apache-2.0" ]
C
cfq_dispatch_insert
void
static void cfq_dispatch_insert(struct request_queue *q, struct request *rq) { struct cfq_data *cfqd = q->elevator->elevator_data; struct cfq_queue *cfqq = RQ_CFQQ(rq); cfq_log_cfqq(cfqd, cfqq, "dispatch_insert"); cfqq->next_rq = cfq_find_next_rq(cfqd, cfqq, rq); cfq_remove_request(rq); cfqq->dispatched++; (RQ_CFQG(rq))->dispatched++; elv_dispatch_sort(q, rq); cfqd->rq_in_flight[cfq_cfqq_sync(cfqq)]++; cfqq->nr_sectors += blk_rq_sectors(rq); cfqg_stats_update_dispatch(cfqq->cfqg, blk_rq_bytes(rq), rq->cmd_flags); }
/* * Move request from internal lists to the request queue dispatch list. */
Move request from internal lists to the request queue dispatch list.
[ "Move", "request", "from", "internal", "lists", "to", "the", "request", "queue", "dispatch", "list", "." ]
static void cfq_dispatch_insert(struct request_queue *q, struct request *rq) { struct cfq_data *cfqd = q->elevator->elevator_data; struct cfq_queue *cfqq = RQ_CFQQ(rq); cfq_log_cfqq(cfqd, cfqq, "dispatch_insert"); cfqq->next_rq = cfq_find_next_rq(cfqd, cfqq, rq); cfq_remove_request(rq); cfqq->dispatched++; (RQ_CFQG(rq))->dispatched++; elv_dispatch_sort(q, rq); cfqd->rq_in_flight[cfq_cfqq_sync(cfqq)]++; cfqq->nr_sectors += blk_rq_sectors(rq); cfqg_stats_update_dispatch(cfqq->cfqg, blk_rq_bytes(rq), rq->cmd_flags); }
[ "static", "void", "cfq_dispatch_insert", "(", "struct", "request_queue", "*", "q", ",", "struct", "request", "*", "rq", ")", "{", "struct", "cfq_data", "*", "cfqd", "=", "q", "->", "elevator", "->", "elevator_data", ";", "struct", "cfq_queue", "*", "cfqq", "=", "RQ_CFQQ", "(", "rq", ")", ";", "cfq_log_cfqq", "(", "cfqd", ",", "cfqq", ",", "\"", "\"", ")", ";", "cfqq", "->", "next_rq", "=", "cfq_find_next_rq", "(", "cfqd", ",", "cfqq", ",", "rq", ")", ";", "cfq_remove_request", "(", "rq", ")", ";", "cfqq", "->", "dispatched", "++", ";", "(", "RQ_CFQG", "(", "rq", ")", ")", "->", "dispatched", "++", ";", "elv_dispatch_sort", "(", "q", ",", "rq", ")", ";", "cfqd", "->", "rq_in_flight", "[", "cfq_cfqq_sync", "(", "cfqq", ")", "]", "++", ";", "cfqq", "->", "nr_sectors", "+=", "blk_rq_sectors", "(", "rq", ")", ";", "cfqg_stats_update_dispatch", "(", "cfqq", "->", "cfqg", ",", "blk_rq_bytes", "(", "rq", ")", ",", "rq", "->", "cmd_flags", ")", ";", "}" ]
Move request from internal lists to the request queue dispatch list.
[ "Move", "request", "from", "internal", "lists", "to", "the", "request", "queue", "dispatch", "list", "." ]
[]
[ { "param": "q", "type": "struct request_queue" }, { "param": "rq", "type": "struct request" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "q", "type": "struct request_queue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rq", "type": "struct request", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/block/cfq-iosched.c
[ "Apache-2.0" ]
C
cfq_check_fifo
null
static struct request *cfq_check_fifo(struct cfq_queue *cfqq) { struct request *rq = NULL; if (cfq_cfqq_fifo_expire(cfqq)) return NULL; cfq_mark_cfqq_fifo_expire(cfqq); if (list_empty(&cfqq->fifo)) return NULL; rq = rq_entry_fifo(cfqq->fifo.next); if (time_before(jiffies, rq_fifo_time(rq))) rq = NULL; cfq_log_cfqq(cfqq->cfqd, cfqq, "fifo=%p", rq); return rq; }
/* * return expired entry, or NULL to just start from scratch in rbtree */
return expired entry, or NULL to just start from scratch in rbtree
[ "return", "expired", "entry", "or", "NULL", "to", "just", "start", "from", "scratch", "in", "rbtree" ]
static struct request *cfq_check_fifo(struct cfq_queue *cfqq) { struct request *rq = NULL; if (cfq_cfqq_fifo_expire(cfqq)) return NULL; cfq_mark_cfqq_fifo_expire(cfqq); if (list_empty(&cfqq->fifo)) return NULL; rq = rq_entry_fifo(cfqq->fifo.next); if (time_before(jiffies, rq_fifo_time(rq))) rq = NULL; cfq_log_cfqq(cfqq->cfqd, cfqq, "fifo=%p", rq); return rq; }
[ "static", "struct", "request", "*", "cfq_check_fifo", "(", "struct", "cfq_queue", "*", "cfqq", ")", "{", "struct", "request", "*", "rq", "=", "NULL", ";", "if", "(", "cfq_cfqq_fifo_expire", "(", "cfqq", ")", ")", "return", "NULL", ";", "cfq_mark_cfqq_fifo_expire", "(", "cfqq", ")", ";", "if", "(", "list_empty", "(", "&", "cfqq", "->", "fifo", ")", ")", "return", "NULL", ";", "rq", "=", "rq_entry_fifo", "(", "cfqq", "->", "fifo", ".", "next", ")", ";", "if", "(", "time_before", "(", "jiffies", ",", "rq_fifo_time", "(", "rq", ")", ")", ")", "rq", "=", "NULL", ";", "cfq_log_cfqq", "(", "cfqq", "->", "cfqd", ",", "cfqq", ",", "\"", "\"", ",", "rq", ")", ";", "return", "rq", ";", "}" ]
return expired entry, or NULL to just start from scratch in rbtree
[ "return", "expired", "entry", "or", "NULL", "to", "just", "start", "from", "scratch", "in", "rbtree" ]
[]
[ { "param": "cfqq", "type": "struct cfq_queue" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cfqq", "type": "struct cfq_queue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/block/cfq-iosched.c
[ "Apache-2.0" ]
C
cfqq_process_refs
int
static int cfqq_process_refs(struct cfq_queue *cfqq) { int process_refs, io_refs; io_refs = cfqq->allocated[READ] + cfqq->allocated[WRITE]; process_refs = cfqq->ref - io_refs; BUG_ON(process_refs < 0); return process_refs; }
/* * Must be called with the queue_lock held. */
Must be called with the queue_lock held.
[ "Must", "be", "called", "with", "the", "queue_lock", "held", "." ]
static int cfqq_process_refs(struct cfq_queue *cfqq) { int process_refs, io_refs; io_refs = cfqq->allocated[READ] + cfqq->allocated[WRITE]; process_refs = cfqq->ref - io_refs; BUG_ON(process_refs < 0); return process_refs; }
[ "static", "int", "cfqq_process_refs", "(", "struct", "cfq_queue", "*", "cfqq", ")", "{", "int", "process_refs", ",", "io_refs", ";", "io_refs", "=", "cfqq", "->", "allocated", "[", "READ", "]", "+", "cfqq", "->", "allocated", "[", "WRITE", "]", ";", "process_refs", "=", "cfqq", "->", "ref", "-", "io_refs", ";", "BUG_ON", "(", "process_refs", "<", "0", ")", ";", "return", "process_refs", ";", "}" ]
Must be called with the queue_lock held.
[ "Must", "be", "called", "with", "the", "queue_lock", "held", "." ]
[]
[ { "param": "cfqq", "type": "struct cfq_queue" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cfqq", "type": "struct cfq_queue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/block/cfq-iosched.c
[ "Apache-2.0" ]
C
cfq_update_idle_window
void
static void cfq_update_idle_window(struct cfq_data *cfqd, struct cfq_queue *cfqq, struct cfq_io_cq *cic) { int old_idle, enable_idle; /* * Don't idle for async or idle io prio class */ if (!cfq_cfqq_sync(cfqq) || cfq_class_idle(cfqq)) return; enable_idle = old_idle = cfq_cfqq_idle_window(cfqq); if (cfqq->queued[0] + cfqq->queued[1] >= 4) cfq_mark_cfqq_deep(cfqq); if (cfqq->next_rq && (cfqq->next_rq->cmd_flags & REQ_NOIDLE)) enable_idle = 0; else if (!atomic_read(&cic->icq.ioc->active_ref) || !cfqd->cfq_slice_idle || (!cfq_cfqq_deep(cfqq) && CFQQ_SEEKY(cfqq))) enable_idle = 0; else if (sample_valid(cic->ttime.ttime_samples)) { if (cic->ttime.ttime_mean > cfqd->cfq_slice_idle) enable_idle = 0; else enable_idle = 1; } if (old_idle != enable_idle) { cfq_log_cfqq(cfqd, cfqq, "idle=%d", enable_idle); if (enable_idle) cfq_mark_cfqq_idle_window(cfqq); else cfq_clear_cfqq_idle_window(cfqq); } }
/* * Disable idle window if the process thinks too long or seeks so much that * it doesn't matter */
Disable idle window if the process thinks too long or seeks so much that it doesn't matter
[ "Disable", "idle", "window", "if", "the", "process", "thinks", "too", "long", "or", "seeks", "so", "much", "that", "it", "doesn", "'", "t", "matter" ]
static void cfq_update_idle_window(struct cfq_data *cfqd, struct cfq_queue *cfqq, struct cfq_io_cq *cic) { int old_idle, enable_idle; if (!cfq_cfqq_sync(cfqq) || cfq_class_idle(cfqq)) return; enable_idle = old_idle = cfq_cfqq_idle_window(cfqq); if (cfqq->queued[0] + cfqq->queued[1] >= 4) cfq_mark_cfqq_deep(cfqq); if (cfqq->next_rq && (cfqq->next_rq->cmd_flags & REQ_NOIDLE)) enable_idle = 0; else if (!atomic_read(&cic->icq.ioc->active_ref) || !cfqd->cfq_slice_idle || (!cfq_cfqq_deep(cfqq) && CFQQ_SEEKY(cfqq))) enable_idle = 0; else if (sample_valid(cic->ttime.ttime_samples)) { if (cic->ttime.ttime_mean > cfqd->cfq_slice_idle) enable_idle = 0; else enable_idle = 1; } if (old_idle != enable_idle) { cfq_log_cfqq(cfqd, cfqq, "idle=%d", enable_idle); if (enable_idle) cfq_mark_cfqq_idle_window(cfqq); else cfq_clear_cfqq_idle_window(cfqq); } }
[ "static", "void", "cfq_update_idle_window", "(", "struct", "cfq_data", "*", "cfqd", ",", "struct", "cfq_queue", "*", "cfqq", ",", "struct", "cfq_io_cq", "*", "cic", ")", "{", "int", "old_idle", ",", "enable_idle", ";", "if", "(", "!", "cfq_cfqq_sync", "(", "cfqq", ")", "||", "cfq_class_idle", "(", "cfqq", ")", ")", "return", ";", "enable_idle", "=", "old_idle", "=", "cfq_cfqq_idle_window", "(", "cfqq", ")", ";", "if", "(", "cfqq", "->", "queued", "[", "0", "]", "+", "cfqq", "->", "queued", "[", "1", "]", ">=", "4", ")", "cfq_mark_cfqq_deep", "(", "cfqq", ")", ";", "if", "(", "cfqq", "->", "next_rq", "&&", "(", "cfqq", "->", "next_rq", "->", "cmd_flags", "&", "REQ_NOIDLE", ")", ")", "enable_idle", "=", "0", ";", "else", "if", "(", "!", "atomic_read", "(", "&", "cic", "->", "icq", ".", "ioc", "->", "active_ref", ")", "||", "!", "cfqd", "->", "cfq_slice_idle", "||", "(", "!", "cfq_cfqq_deep", "(", "cfqq", ")", "&&", "CFQQ_SEEKY", "(", "cfqq", ")", ")", ")", "enable_idle", "=", "0", ";", "else", "if", "(", "sample_valid", "(", "cic", "->", "ttime", ".", "ttime_samples", ")", ")", "{", "if", "(", "cic", "->", "ttime", ".", "ttime_mean", ">", "cfqd", "->", "cfq_slice_idle", ")", "enable_idle", "=", "0", ";", "else", "enable_idle", "=", "1", ";", "}", "if", "(", "old_idle", "!=", "enable_idle", ")", "{", "cfq_log_cfqq", "(", "cfqd", ",", "cfqq", ",", "\"", "\"", ",", "enable_idle", ")", ";", "if", "(", "enable_idle", ")", "cfq_mark_cfqq_idle_window", "(", "cfqq", ")", ";", "else", "cfq_clear_cfqq_idle_window", "(", "cfqq", ")", ";", "}", "}" ]
Disable idle window if the process thinks too long or seeks so much that it doesn't matter
[ "Disable", "idle", "window", "if", "the", "process", "thinks", "too", "long", "or", "seeks", "so", "much", "that", "it", "doesn", "'", "t", "matter" ]
[ "/*\n\t * Don't idle for async or idle io prio class\n\t */" ]
[ { "param": "cfqd", "type": "struct cfq_data" }, { "param": "cfqq", "type": "struct cfq_queue" }, { "param": "cic", "type": "struct cfq_io_cq" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cfqd", "type": "struct cfq_data", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cfqq", "type": "struct cfq_queue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cic", "type": "struct cfq_io_cq", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/block/cfq-iosched.c
[ "Apache-2.0" ]
C
cfq_should_preempt
bool
static bool cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq, struct request *rq) { struct cfq_queue *cfqq; cfqq = cfqd->active_queue; if (!cfqq) return false; if (cfq_class_idle(new_cfqq)) return false; if (cfq_class_idle(cfqq)) return true; /* * Don't allow a non-RT request to preempt an ongoing RT cfqq timeslice. */ if (cfq_class_rt(cfqq) && !cfq_class_rt(new_cfqq)) return false; /* * if the new request is sync, but the currently running queue is * not, let the sync request have priority. */ if (rq_is_sync(rq) && !cfq_cfqq_sync(cfqq)) return true; if (new_cfqq->cfqg != cfqq->cfqg) return false; if (cfq_slice_used(cfqq)) return true; /* Allow preemption only if we are idling on sync-noidle tree */ if (cfqd->serving_type == SYNC_NOIDLE_WORKLOAD && cfqq_type(new_cfqq) == SYNC_NOIDLE_WORKLOAD && new_cfqq->service_tree->count == 2 && RB_EMPTY_ROOT(&cfqq->sort_list)) return true; /* * So both queues are sync. Let the new request get disk time if * it's a metadata request and the current queue is doing regular IO. */ if ((rq->cmd_flags & REQ_PRIO) && !cfqq->prio_pending) return true; /* * Allow an RT request to pre-empt an ongoing non-RT cfqq timeslice. */ if (cfq_class_rt(new_cfqq) && !cfq_class_rt(cfqq)) return true; /* An idle queue should not be idle now for some reason */ if (RB_EMPTY_ROOT(&cfqq->sort_list) && !cfq_should_idle(cfqd, cfqq)) return true; if (!cfqd->active_cic || !cfq_cfqq_wait_request(cfqq)) return false; /* * if this request is as-good as one we would expect from the * current cfqq, let it preempt */ if (cfq_rq_close(cfqd, cfqq, rq)) return true; return false; }
/* * Check if new_cfqq should preempt the currently active queue. Return 0 for * no or if we aren't sure, a 1 will cause a preempt. */
Check if new_cfqq should preempt the currently active queue. Return 0 for no or if we aren't sure, a 1 will cause a preempt.
[ "Check", "if", "new_cfqq", "should", "preempt", "the", "currently", "active", "queue", ".", "Return", "0", "for", "no", "or", "if", "we", "aren", "'", "t", "sure", "a", "1", "will", "cause", "a", "preempt", "." ]
static bool cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq, struct request *rq) { struct cfq_queue *cfqq; cfqq = cfqd->active_queue; if (!cfqq) return false; if (cfq_class_idle(new_cfqq)) return false; if (cfq_class_idle(cfqq)) return true; if (cfq_class_rt(cfqq) && !cfq_class_rt(new_cfqq)) return false; if (rq_is_sync(rq) && !cfq_cfqq_sync(cfqq)) return true; if (new_cfqq->cfqg != cfqq->cfqg) return false; if (cfq_slice_used(cfqq)) return true; if (cfqd->serving_type == SYNC_NOIDLE_WORKLOAD && cfqq_type(new_cfqq) == SYNC_NOIDLE_WORKLOAD && new_cfqq->service_tree->count == 2 && RB_EMPTY_ROOT(&cfqq->sort_list)) return true; if ((rq->cmd_flags & REQ_PRIO) && !cfqq->prio_pending) return true; if (cfq_class_rt(new_cfqq) && !cfq_class_rt(cfqq)) return true; if (RB_EMPTY_ROOT(&cfqq->sort_list) && !cfq_should_idle(cfqd, cfqq)) return true; if (!cfqd->active_cic || !cfq_cfqq_wait_request(cfqq)) return false; if (cfq_rq_close(cfqd, cfqq, rq)) return true; return false; }
[ "static", "bool", "cfq_should_preempt", "(", "struct", "cfq_data", "*", "cfqd", ",", "struct", "cfq_queue", "*", "new_cfqq", ",", "struct", "request", "*", "rq", ")", "{", "struct", "cfq_queue", "*", "cfqq", ";", "cfqq", "=", "cfqd", "->", "active_queue", ";", "if", "(", "!", "cfqq", ")", "return", "false", ";", "if", "(", "cfq_class_idle", "(", "new_cfqq", ")", ")", "return", "false", ";", "if", "(", "cfq_class_idle", "(", "cfqq", ")", ")", "return", "true", ";", "if", "(", "cfq_class_rt", "(", "cfqq", ")", "&&", "!", "cfq_class_rt", "(", "new_cfqq", ")", ")", "return", "false", ";", "if", "(", "rq_is_sync", "(", "rq", ")", "&&", "!", "cfq_cfqq_sync", "(", "cfqq", ")", ")", "return", "true", ";", "if", "(", "new_cfqq", "->", "cfqg", "!=", "cfqq", "->", "cfqg", ")", "return", "false", ";", "if", "(", "cfq_slice_used", "(", "cfqq", ")", ")", "return", "true", ";", "if", "(", "cfqd", "->", "serving_type", "==", "SYNC_NOIDLE_WORKLOAD", "&&", "cfqq_type", "(", "new_cfqq", ")", "==", "SYNC_NOIDLE_WORKLOAD", "&&", "new_cfqq", "->", "service_tree", "->", "count", "==", "2", "&&", "RB_EMPTY_ROOT", "(", "&", "cfqq", "->", "sort_list", ")", ")", "return", "true", ";", "if", "(", "(", "rq", "->", "cmd_flags", "&", "REQ_PRIO", ")", "&&", "!", "cfqq", "->", "prio_pending", ")", "return", "true", ";", "if", "(", "cfq_class_rt", "(", "new_cfqq", ")", "&&", "!", "cfq_class_rt", "(", "cfqq", ")", ")", "return", "true", ";", "if", "(", "RB_EMPTY_ROOT", "(", "&", "cfqq", "->", "sort_list", ")", "&&", "!", "cfq_should_idle", "(", "cfqd", ",", "cfqq", ")", ")", "return", "true", ";", "if", "(", "!", "cfqd", "->", "active_cic", "||", "!", "cfq_cfqq_wait_request", "(", "cfqq", ")", ")", "return", "false", ";", "if", "(", "cfq_rq_close", "(", "cfqd", ",", "cfqq", ",", "rq", ")", ")", "return", "true", ";", "return", "false", ";", "}" ]
Check if new_cfqq should preempt the currently active queue.
[ "Check", "if", "new_cfqq", "should", "preempt", "the", "currently", "active", "queue", "." ]
[ "/*\n\t * Don't allow a non-RT request to preempt an ongoing RT cfqq timeslice.\n\t */", "/*\n\t * if the new request is sync, but the currently running queue is\n\t * not, let the sync request have priority.\n\t */", "/* Allow preemption only if we are idling on sync-noidle tree */", "/*\n\t * So both queues are sync. Let the new request get disk time if\n\t * it's a metadata request and the current queue is doing regular IO.\n\t */", "/*\n\t * Allow an RT request to pre-empt an ongoing non-RT cfqq timeslice.\n\t */", "/* An idle queue should not be idle now for some reason */", "/*\n\t * if this request is as-good as one we would expect from the\n\t * current cfqq, let it preempt\n\t */" ]
[ { "param": "cfqd", "type": "struct cfq_data" }, { "param": "new_cfqq", "type": "struct cfq_queue" }, { "param": "rq", "type": "struct request" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cfqd", "type": "struct cfq_data", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "new_cfqq", "type": "struct cfq_queue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rq", "type": "struct request", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/block/cfq-iosched.c
[ "Apache-2.0" ]
C
cfq_preempt_queue
void
static void cfq_preempt_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq) { enum wl_type_t old_type = cfqq_type(cfqd->active_queue); cfq_log_cfqq(cfqd, cfqq, "preempt"); cfq_slice_expired(cfqd, 1); /* * workload type is changed, don't save slice, otherwise preempt * doesn't happen */ if (old_type != cfqq_type(cfqq)) cfqq->cfqg->saved_workload_slice = 0; /* * Put the new queue at the front of the of the current list, * so we know that it will be selected next. */ BUG_ON(!cfq_cfqq_on_rr(cfqq)); cfq_service_tree_add(cfqd, cfqq, 1); cfqq->slice_end = 0; cfq_mark_cfqq_slice_new(cfqq); }
/* * cfqq preempts the active queue. if we allowed preempt with no slice left, * let it have half of its nominal slice. */
cfqq preempts the active queue. if we allowed preempt with no slice left, let it have half of its nominal slice.
[ "cfqq", "preempts", "the", "active", "queue", ".", "if", "we", "allowed", "preempt", "with", "no", "slice", "left", "let", "it", "have", "half", "of", "its", "nominal", "slice", "." ]
static void cfq_preempt_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq) { enum wl_type_t old_type = cfqq_type(cfqd->active_queue); cfq_log_cfqq(cfqd, cfqq, "preempt"); cfq_slice_expired(cfqd, 1); if (old_type != cfqq_type(cfqq)) cfqq->cfqg->saved_workload_slice = 0; BUG_ON(!cfq_cfqq_on_rr(cfqq)); cfq_service_tree_add(cfqd, cfqq, 1); cfqq->slice_end = 0; cfq_mark_cfqq_slice_new(cfqq); }
[ "static", "void", "cfq_preempt_queue", "(", "struct", "cfq_data", "*", "cfqd", ",", "struct", "cfq_queue", "*", "cfqq", ")", "{", "enum", "wl_type_t", "old_type", "=", "cfqq_type", "(", "cfqd", "->", "active_queue", ")", ";", "cfq_log_cfqq", "(", "cfqd", ",", "cfqq", ",", "\"", "\"", ")", ";", "cfq_slice_expired", "(", "cfqd", ",", "1", ")", ";", "if", "(", "old_type", "!=", "cfqq_type", "(", "cfqq", ")", ")", "cfqq", "->", "cfqg", "->", "saved_workload_slice", "=", "0", ";", "BUG_ON", "(", "!", "cfq_cfqq_on_rr", "(", "cfqq", ")", ")", ";", "cfq_service_tree_add", "(", "cfqd", ",", "cfqq", ",", "1", ")", ";", "cfqq", "->", "slice_end", "=", "0", ";", "cfq_mark_cfqq_slice_new", "(", "cfqq", ")", ";", "}" ]
cfqq preempts the active queue.
[ "cfqq", "preempts", "the", "active", "queue", "." ]
[ "/*\n\t * workload type is changed, don't save slice, otherwise preempt\n\t * doesn't happen\n\t */", "/*\n\t * Put the new queue at the front of the of the current list,\n\t * so we know that it will be selected next.\n\t */" ]
[ { "param": "cfqd", "type": "struct cfq_data" }, { "param": "cfqq", "type": "struct cfq_queue" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cfqd", "type": "struct cfq_data", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cfqq", "type": "struct cfq_queue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/block/cfq-iosched.c
[ "Apache-2.0" ]
C
cfq_rq_enqueued
void
static void cfq_rq_enqueued(struct cfq_data *cfqd, struct cfq_queue *cfqq, struct request *rq) { struct cfq_io_cq *cic = RQ_CIC(rq); cfqd->rq_queued++; if (rq->cmd_flags & REQ_PRIO) cfqq->prio_pending++; cfq_update_io_thinktime(cfqd, cfqq, cic); cfq_update_io_seektime(cfqd, cfqq, rq); cfq_update_idle_window(cfqd, cfqq, cic); cfqq->last_request_pos = blk_rq_pos(rq) + blk_rq_sectors(rq); if (cfqq == cfqd->active_queue) { /* * Remember that we saw a request from this process, but * don't start queuing just yet. Otherwise we risk seeing lots * of tiny requests, because we disrupt the normal plugging * and merging. If the request is already larger than a single * page, let it rip immediately. For that case we assume that * merging is already done. Ditto for a busy system that * has other work pending, don't risk delaying until the * idle timer unplug to continue working. */ if (cfq_cfqq_wait_request(cfqq)) { if (blk_rq_bytes(rq) > PAGE_CACHE_SIZE || cfqd->busy_queues > 1) { cfq_del_timer(cfqd, cfqq); cfq_clear_cfqq_wait_request(cfqq); __blk_run_queue(cfqd->queue); } else { cfqg_stats_update_idle_time(cfqq->cfqg); cfq_mark_cfqq_must_dispatch(cfqq); } } } else if (cfq_should_preempt(cfqd, cfqq, rq)) { /* * not the active queue - expire current slice if it is * idle and has expired it's mean thinktime or this new queue * has some old slice time left and is of higher priority or * this new queue is RT and the current one is BE */ cfq_preempt_queue(cfqd, cfqq); __blk_run_queue(cfqd->queue); } }
/* * Called when a new fs request (rq) is added (to cfqq). Check if there's * something we should do about it */
Called when a new fs request (rq) is added (to cfqq). Check if there's something we should do about it
[ "Called", "when", "a", "new", "fs", "request", "(", "rq", ")", "is", "added", "(", "to", "cfqq", ")", ".", "Check", "if", "there", "'", "s", "something", "we", "should", "do", "about", "it" ]
static void cfq_rq_enqueued(struct cfq_data *cfqd, struct cfq_queue *cfqq, struct request *rq) { struct cfq_io_cq *cic = RQ_CIC(rq); cfqd->rq_queued++; if (rq->cmd_flags & REQ_PRIO) cfqq->prio_pending++; cfq_update_io_thinktime(cfqd, cfqq, cic); cfq_update_io_seektime(cfqd, cfqq, rq); cfq_update_idle_window(cfqd, cfqq, cic); cfqq->last_request_pos = blk_rq_pos(rq) + blk_rq_sectors(rq); if (cfqq == cfqd->active_queue) { if (cfq_cfqq_wait_request(cfqq)) { if (blk_rq_bytes(rq) > PAGE_CACHE_SIZE || cfqd->busy_queues > 1) { cfq_del_timer(cfqd, cfqq); cfq_clear_cfqq_wait_request(cfqq); __blk_run_queue(cfqd->queue); } else { cfqg_stats_update_idle_time(cfqq->cfqg); cfq_mark_cfqq_must_dispatch(cfqq); } } } else if (cfq_should_preempt(cfqd, cfqq, rq)) { cfq_preempt_queue(cfqd, cfqq); __blk_run_queue(cfqd->queue); } }
[ "static", "void", "cfq_rq_enqueued", "(", "struct", "cfq_data", "*", "cfqd", ",", "struct", "cfq_queue", "*", "cfqq", ",", "struct", "request", "*", "rq", ")", "{", "struct", "cfq_io_cq", "*", "cic", "=", "RQ_CIC", "(", "rq", ")", ";", "cfqd", "->", "rq_queued", "++", ";", "if", "(", "rq", "->", "cmd_flags", "&", "REQ_PRIO", ")", "cfqq", "->", "prio_pending", "++", ";", "cfq_update_io_thinktime", "(", "cfqd", ",", "cfqq", ",", "cic", ")", ";", "cfq_update_io_seektime", "(", "cfqd", ",", "cfqq", ",", "rq", ")", ";", "cfq_update_idle_window", "(", "cfqd", ",", "cfqq", ",", "cic", ")", ";", "cfqq", "->", "last_request_pos", "=", "blk_rq_pos", "(", "rq", ")", "+", "blk_rq_sectors", "(", "rq", ")", ";", "if", "(", "cfqq", "==", "cfqd", "->", "active_queue", ")", "{", "if", "(", "cfq_cfqq_wait_request", "(", "cfqq", ")", ")", "{", "if", "(", "blk_rq_bytes", "(", "rq", ")", ">", "PAGE_CACHE_SIZE", "||", "cfqd", "->", "busy_queues", ">", "1", ")", "{", "cfq_del_timer", "(", "cfqd", ",", "cfqq", ")", ";", "cfq_clear_cfqq_wait_request", "(", "cfqq", ")", ";", "__blk_run_queue", "(", "cfqd", "->", "queue", ")", ";", "}", "else", "{", "cfqg_stats_update_idle_time", "(", "cfqq", "->", "cfqg", ")", ";", "cfq_mark_cfqq_must_dispatch", "(", "cfqq", ")", ";", "}", "}", "}", "else", "if", "(", "cfq_should_preempt", "(", "cfqd", ",", "cfqq", ",", "rq", ")", ")", "{", "cfq_preempt_queue", "(", "cfqd", ",", "cfqq", ")", ";", "__blk_run_queue", "(", "cfqd", "->", "queue", ")", ";", "}", "}" ]
Called when a new fs request (rq) is added (to cfqq).
[ "Called", "when", "a", "new", "fs", "request", "(", "rq", ")", "is", "added", "(", "to", "cfqq", ")", "." ]
[ "/*\n\t\t * Remember that we saw a request from this process, but\n\t\t * don't start queuing just yet. Otherwise we risk seeing lots\n\t\t * of tiny requests, because we disrupt the normal plugging\n\t\t * and merging. If the request is already larger than a single\n\t\t * page, let it rip immediately. For that case we assume that\n\t\t * merging is already done. Ditto for a busy system that\n\t\t * has other work pending, don't risk delaying until the\n\t\t * idle timer unplug to continue working.\n\t\t */", "/*\n\t\t * not the active queue - expire current slice if it is\n\t\t * idle and has expired it's mean thinktime or this new queue\n\t\t * has some old slice time left and is of higher priority or\n\t\t * this new queue is RT and the current one is BE\n\t\t */" ]
[ { "param": "cfqd", "type": "struct cfq_data" }, { "param": "cfqq", "type": "struct cfq_queue" }, { "param": "rq", "type": "struct request" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cfqd", "type": "struct cfq_data", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cfqq", "type": "struct cfq_queue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rq", "type": "struct request", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/block/cfq-iosched.c
[ "Apache-2.0" ]
C
cfq_update_hw_tag
void
static void cfq_update_hw_tag(struct cfq_data *cfqd) { struct cfq_queue *cfqq = cfqd->active_queue; if (cfqd->rq_in_driver > cfqd->hw_tag_est_depth) cfqd->hw_tag_est_depth = cfqd->rq_in_driver; if (cfqd->hw_tag == 1) return; if (cfqd->rq_queued <= CFQ_HW_QUEUE_MIN && cfqd->rq_in_driver <= CFQ_HW_QUEUE_MIN) return; /* * If active queue hasn't enough requests and can idle, cfq might not * dispatch sufficient requests to hardware. Don't zero hw_tag in this * case */ if (cfqq && cfq_cfqq_idle_window(cfqq) && cfqq->dispatched + cfqq->queued[0] + cfqq->queued[1] < CFQ_HW_QUEUE_MIN && cfqd->rq_in_driver < CFQ_HW_QUEUE_MIN) return; if (cfqd->hw_tag_samples++ < 50) return; if (cfqd->hw_tag_est_depth >= CFQ_HW_QUEUE_MIN) cfqd->hw_tag = 1; else cfqd->hw_tag = 0; }
/* * Update hw_tag based on peak queue depth over 50 samples under * sufficient load. */
Update hw_tag based on peak queue depth over 50 samples under sufficient load.
[ "Update", "hw_tag", "based", "on", "peak", "queue", "depth", "over", "50", "samples", "under", "sufficient", "load", "." ]
static void cfq_update_hw_tag(struct cfq_data *cfqd) { struct cfq_queue *cfqq = cfqd->active_queue; if (cfqd->rq_in_driver > cfqd->hw_tag_est_depth) cfqd->hw_tag_est_depth = cfqd->rq_in_driver; if (cfqd->hw_tag == 1) return; if (cfqd->rq_queued <= CFQ_HW_QUEUE_MIN && cfqd->rq_in_driver <= CFQ_HW_QUEUE_MIN) return; if (cfqq && cfq_cfqq_idle_window(cfqq) && cfqq->dispatched + cfqq->queued[0] + cfqq->queued[1] < CFQ_HW_QUEUE_MIN && cfqd->rq_in_driver < CFQ_HW_QUEUE_MIN) return; if (cfqd->hw_tag_samples++ < 50) return; if (cfqd->hw_tag_est_depth >= CFQ_HW_QUEUE_MIN) cfqd->hw_tag = 1; else cfqd->hw_tag = 0; }
[ "static", "void", "cfq_update_hw_tag", "(", "struct", "cfq_data", "*", "cfqd", ")", "{", "struct", "cfq_queue", "*", "cfqq", "=", "cfqd", "->", "active_queue", ";", "if", "(", "cfqd", "->", "rq_in_driver", ">", "cfqd", "->", "hw_tag_est_depth", ")", "cfqd", "->", "hw_tag_est_depth", "=", "cfqd", "->", "rq_in_driver", ";", "if", "(", "cfqd", "->", "hw_tag", "==", "1", ")", "return", ";", "if", "(", "cfqd", "->", "rq_queued", "<=", "CFQ_HW_QUEUE_MIN", "&&", "cfqd", "->", "rq_in_driver", "<=", "CFQ_HW_QUEUE_MIN", ")", "return", ";", "if", "(", "cfqq", "&&", "cfq_cfqq_idle_window", "(", "cfqq", ")", "&&", "cfqq", "->", "dispatched", "+", "cfqq", "->", "queued", "[", "0", "]", "+", "cfqq", "->", "queued", "[", "1", "]", "<", "CFQ_HW_QUEUE_MIN", "&&", "cfqd", "->", "rq_in_driver", "<", "CFQ_HW_QUEUE_MIN", ")", "return", ";", "if", "(", "cfqd", "->", "hw_tag_samples", "++", "<", "50", ")", "return", ";", "if", "(", "cfqd", "->", "hw_tag_est_depth", ">=", "CFQ_HW_QUEUE_MIN", ")", "cfqd", "->", "hw_tag", "=", "1", ";", "else", "cfqd", "->", "hw_tag", "=", "0", ";", "}" ]
Update hw_tag based on peak queue depth over 50 samples under sufficient load.
[ "Update", "hw_tag", "based", "on", "peak", "queue", "depth", "over", "50", "samples", "under", "sufficient", "load", "." ]
[ "/*\n\t * If active queue hasn't enough requests and can idle, cfq might not\n\t * dispatch sufficient requests to hardware. Don't zero hw_tag in this\n\t * case\n\t */" ]
[ { "param": "cfqd", "type": "struct cfq_data" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cfqd", "type": "struct cfq_data", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9c5d21a70ab4f6050fe6d3f3d5fe0c82716527c2
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/block/cfq-iosched.c
[ "Apache-2.0" ]
C
split_cfqq
null
static struct cfq_queue * split_cfqq(struct cfq_io_cq *cic, struct cfq_queue *cfqq) { if (cfqq_process_refs(cfqq) == 1) { cfqq->pid = current->pid; cfq_clear_cfqq_coop(cfqq); cfq_clear_cfqq_split_coop(cfqq); return cfqq; } cic_set_cfqq(cic, NULL, 1); cfq_put_cooperator(cfqq); cfq_put_queue(cfqq); return NULL; }
/* * Returns NULL if a new cfqq should be allocated, or the old cfqq if this * was the last process referring to said cfqq. */
Returns NULL if a new cfqq should be allocated, or the old cfqq if this was the last process referring to said cfqq.
[ "Returns", "NULL", "if", "a", "new", "cfqq", "should", "be", "allocated", "or", "the", "old", "cfqq", "if", "this", "was", "the", "last", "process", "referring", "to", "said", "cfqq", "." ]
static struct cfq_queue * split_cfqq(struct cfq_io_cq *cic, struct cfq_queue *cfqq) { if (cfqq_process_refs(cfqq) == 1) { cfqq->pid = current->pid; cfq_clear_cfqq_coop(cfqq); cfq_clear_cfqq_split_coop(cfqq); return cfqq; } cic_set_cfqq(cic, NULL, 1); cfq_put_cooperator(cfqq); cfq_put_queue(cfqq); return NULL; }
[ "static", "struct", "cfq_queue", "*", "split_cfqq", "(", "struct", "cfq_io_cq", "*", "cic", ",", "struct", "cfq_queue", "*", "cfqq", ")", "{", "if", "(", "cfqq_process_refs", "(", "cfqq", ")", "==", "1", ")", "{", "cfqq", "->", "pid", "=", "current", "->", "pid", ";", "cfq_clear_cfqq_coop", "(", "cfqq", ")", ";", "cfq_clear_cfqq_split_coop", "(", "cfqq", ")", ";", "return", "cfqq", ";", "}", "cic_set_cfqq", "(", "cic", ",", "NULL", ",", "1", ")", ";", "cfq_put_cooperator", "(", "cfqq", ")", ";", "cfq_put_queue", "(", "cfqq", ")", ";", "return", "NULL", ";", "}" ]
Returns NULL if a new cfqq should be allocated, or the old cfqq if this was the last process referring to said cfqq.
[ "Returns", "NULL", "if", "a", "new", "cfqq", "should", "be", "allocated", "or", "the", "old", "cfqq", "if", "this", "was", "the", "last", "process", "referring", "to", "said", "cfqq", "." ]
[]
[ { "param": "cic", "type": "struct cfq_io_cq" }, { "param": "cfqq", "type": "struct cfq_queue" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cic", "type": "struct cfq_io_cq", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cfqq", "type": "struct cfq_queue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c9386cdeab7094ed6cdeadedb7a7272ab4dd0fc9
Gu-Youngfeng/TenSamplingStudy2
bugs/busybox/networking/httpd.c
[ "Apache-2.0" ]
C
encodeString
char
static char *encodeString(const char *string) { /* take the simple route and encode everything */ /* could possibly scan once to get length. */ int len = strlen(string); char *out = xmalloc(len * 6 + 1); char *p = out; char ch; while ((ch = *string++) != '\0') { /* very simple check for what to encode */ if (isalnum(ch)) *p++ = ch; else p += sprintf(p, "&#%d;", (unsigned char) ch); } *p = '\0'; return out; }
/* * Given a string, html-encode special characters. * This is used for the -e command line option to provide an easy way * for scripts to encode result data without confusing browsers. The * returned string pointer is memory allocated by malloc(). * * Returns a pointer to the encoded string (malloced). */
Given a string, html-encode special characters. This is used for the -e command line option to provide an easy way for scripts to encode result data without confusing browsers. The returned string pointer is memory allocated by malloc(). Returns a pointer to the encoded string (malloced).
[ "Given", "a", "string", "html", "-", "encode", "special", "characters", ".", "This", "is", "used", "for", "the", "-", "e", "command", "line", "option", "to", "provide", "an", "easy", "way", "for", "scripts", "to", "encode", "result", "data", "without", "confusing", "browsers", ".", "The", "returned", "string", "pointer", "is", "memory", "allocated", "by", "malloc", "()", ".", "Returns", "a", "pointer", "to", "the", "encoded", "string", "(", "malloced", ")", "." ]
static char *encodeString(const char *string) { int len = strlen(string); char *out = xmalloc(len * 6 + 1); char *p = out; char ch; while ((ch = *string++) != '\0') { if (isalnum(ch)) *p++ = ch; else p += sprintf(p, "&#%d;", (unsigned char) ch); } *p = '\0'; return out; }
[ "static", "char", "*", "encodeString", "(", "const", "char", "*", "string", ")", "{", "int", "len", "=", "strlen", "(", "string", ")", ";", "char", "*", "out", "=", "xmalloc", "(", "len", "*", "6", "+", "1", ")", ";", "char", "*", "p", "=", "out", ";", "char", "ch", ";", "while", "(", "(", "ch", "=", "*", "string", "++", ")", "!=", "'", "\\0", "'", ")", "{", "if", "(", "isalnum", "(", "ch", ")", ")", "*", "p", "++", "=", "ch", ";", "else", "p", "+=", "sprintf", "(", "p", ",", "\"", "\"", ",", "(", "unsigned", "char", ")", "ch", ")", ";", "}", "*", "p", "=", "'", "\\0", "'", ";", "return", "out", ";", "}" ]
Given a string, html-encode special characters.
[ "Given", "a", "string", "html", "-", "encode", "special", "characters", "." ]
[ "/* take the simple route and encode everything */", "/* could possibly scan once to get length. */", "/* very simple check for what to encode */" ]
[ { "param": "string", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "string", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c9386cdeab7094ed6cdeadedb7a7272ab4dd0fc9
Gu-Youngfeng/TenSamplingStudy2
bugs/busybox/networking/httpd.c
[ "Apache-2.0" ]
C
send_headers
void
static void send_headers(int responseNum) { static const char RFC1123FMT[] = "%a, %d %b %Y %H:%M:%S GMT"; const char *responseString = ""; const char *infoString = NULL; const char *mime_type; #if ENABLE_FEATURE_HTTPD_ERROR_PAGES const char *error_page = NULL; #endif unsigned i; time_t timer = time(NULL); char tmp_str[80]; int len; for (i = 0; i < ARRAY_SIZE(http_response_type); i++) { if (http_response_type[i] == responseNum) { responseString = http_response[i].name; infoString = http_response[i].info; #if ENABLE_FEATURE_HTTPD_ERROR_PAGES error_page = http_error_page[i]; #endif break; } } /* error message is HTML */ mime_type = responseNum == HTTP_OK ? found_mime_type : "text/html"; if (verbose) bb_error_msg("response:%u", responseNum); /* emit the current date */ strftime(tmp_str, sizeof(tmp_str), RFC1123FMT, gmtime(&timer)); len = sprintf(iobuf, "HTTP/1.0 %d %s\r\nContent-type: %s\r\n" "Date: %s\r\nConnection: close\r\n", responseNum, responseString, mime_type, tmp_str); #if ENABLE_FEATURE_HTTPD_BASIC_AUTH len += sprintf(iobuf); #endif len += sprintf(iobuf); #if ENABLE_FEATURE_HTTPD_ERROR_PAGES return send_file_and_exit(error_page, SEND_BODY); #endif if (file_size != -1) { /* file */ strftime(tmp_str, sizeof(tmp_str), RFC1123FMT, gmtime(&last_mod)); #if ENABLE_FEATURE_HTTPD_RANGES len += sprintf(iobuf); #endif #if ENABLE_FEATURE_HTTPD_RANGES len += sprintf(iobuf); #endif } if (content_gzip) len += sprintf(iobuf + len, "Content-Encoding: gzip\r\n"); iobuf[len++] = '\r'; iobuf[len++] = '\n'; if (infoString) { len += sprintf(iobuf + len, "<HTML><HEAD><TITLE>%d %s</TITLE></HEAD>\n" "<BODY><H1>%d %s</H1>\n%s\n</BODY></HTML>\n", responseNum, responseString, responseNum, responseString, infoString); } if (DEBUG) fprintf(stderr, "headers: '%s'\n", iobuf); if (full_write(STDOUT_FILENO, iobuf, len) != len) { if (verbose > 1) bb_perror_msg("error"); log_and_exit(); } }
/* * Create and send HTTP response headers. * The arguments are combined and sent as one write operation. Note that * IE will puke big-time if the headers are not sent in one packet and the * second packet is delayed for any reason. * responseNum - the result code to send. */
Create and send HTTP response headers. The arguments are combined and sent as one write operation. Note that IE will puke big-time if the headers are not sent in one packet and the second packet is delayed for any reason. responseNum - the result code to send.
[ "Create", "and", "send", "HTTP", "response", "headers", ".", "The", "arguments", "are", "combined", "and", "sent", "as", "one", "write", "operation", ".", "Note", "that", "IE", "will", "puke", "big", "-", "time", "if", "the", "headers", "are", "not", "sent", "in", "one", "packet", "and", "the", "second", "packet", "is", "delayed", "for", "any", "reason", ".", "responseNum", "-", "the", "result", "code", "to", "send", "." ]
static void send_headers(int responseNum) { static const char RFC1123FMT[] = "%a, %d %b %Y %H:%M:%S GMT"; const char *responseString = ""; const char *infoString = NULL; const char *mime_type; #if ENABLE_FEATURE_HTTPD_ERROR_PAGES const char *error_page = NULL; #endif unsigned i; time_t timer = time(NULL); char tmp_str[80]; int len; for (i = 0; i < ARRAY_SIZE(http_response_type); i++) { if (http_response_type[i] == responseNum) { responseString = http_response[i].name; infoString = http_response[i].info; #if ENABLE_FEATURE_HTTPD_ERROR_PAGES error_page = http_error_page[i]; #endif break; } } mime_type = responseNum == HTTP_OK ? found_mime_type : "text/html"; if (verbose) bb_error_msg("response:%u", responseNum); strftime(tmp_str, sizeof(tmp_str), RFC1123FMT, gmtime(&timer)); len = sprintf(iobuf, "HTTP/1.0 %d %s\r\nContent-type: %s\r\n" "Date: %s\r\nConnection: close\r\n", responseNum, responseString, mime_type, tmp_str); #if ENABLE_FEATURE_HTTPD_BASIC_AUTH len += sprintf(iobuf); #endif len += sprintf(iobuf); #if ENABLE_FEATURE_HTTPD_ERROR_PAGES return send_file_and_exit(error_page, SEND_BODY); #endif if (file_size != -1) { strftime(tmp_str, sizeof(tmp_str), RFC1123FMT, gmtime(&last_mod)); #if ENABLE_FEATURE_HTTPD_RANGES len += sprintf(iobuf); #endif #if ENABLE_FEATURE_HTTPD_RANGES len += sprintf(iobuf); #endif } if (content_gzip) len += sprintf(iobuf + len, "Content-Encoding: gzip\r\n"); iobuf[len++] = '\r'; iobuf[len++] = '\n'; if (infoString) { len += sprintf(iobuf + len, "<HTML><HEAD><TITLE>%d %s</TITLE></HEAD>\n" "<BODY><H1>%d %s</H1>\n%s\n</BODY></HTML>\n", responseNum, responseString, responseNum, responseString, infoString); } if (DEBUG) fprintf(stderr, "headers: '%s'\n", iobuf); if (full_write(STDOUT_FILENO, iobuf, len) != len) { if (verbose > 1) bb_perror_msg("error"); log_and_exit(); } }
[ "static", "void", "send_headers", "(", "int", "responseNum", ")", "{", "static", "const", "char", "RFC1123FMT", "[", "]", "=", "\"", "\"", ";", "const", "char", "*", "responseString", "=", "\"", "\"", ";", "const", "char", "*", "infoString", "=", "NULL", ";", "const", "char", "*", "mime_type", ";", "#if", "ENABLE_FEATURE_HTTPD_ERROR_PAGES", "\n", "const", "char", "*", "error_page", "=", "NULL", ";", "#endif", "unsigned", "i", ";", "time_t", "timer", "=", "time", "(", "NULL", ")", ";", "char", "tmp_str", "[", "80", "]", ";", "int", "len", ";", "for", "(", "i", "=", "0", ";", "i", "<", "ARRAY_SIZE", "(", "http_response_type", ")", ";", "i", "++", ")", "{", "if", "(", "http_response_type", "[", "i", "]", "==", "responseNum", ")", "{", "responseString", "=", "http_response", "[", "i", "]", ".", "name", ";", "infoString", "=", "http_response", "[", "i", "]", ".", "info", ";", "#if", "ENABLE_FEATURE_HTTPD_ERROR_PAGES", "\n", "error_page", "=", "http_error_page", "[", "i", "]", ";", "#endif", "break", ";", "}", "}", "mime_type", "=", "responseNum", "==", "HTTP_OK", "?", "found_mime_type", ":", "\"", "\"", ";", "if", "(", "verbose", ")", "bb_error_msg", "(", "\"", "\"", ",", "responseNum", ")", ";", "strftime", "(", "tmp_str", ",", "sizeof", "(", "tmp_str", ")", ",", "RFC1123FMT", ",", "gmtime", "(", "&", "timer", ")", ")", ";", "len", "=", "sprintf", "(", "iobuf", ",", "\"", "\\r", "\\n", "\\r", "\\n", "\"", "\"", "\\r", "\\n", "\\r", "\\n", "\"", ",", "responseNum", ",", "responseString", ",", "mime_type", ",", "tmp_str", ")", ";", "#if", "ENABLE_FEATURE_HTTPD_BASIC_AUTH", "\n", "len", "+=", "sprintf", "(", "iobuf", ")", ";", "#endif", "len", "+=", "sprintf", "(", "iobuf", ")", ";", "#if", "ENABLE_FEATURE_HTTPD_ERROR_PAGES", "\n", "return", "send_file_and_exit", "(", "error_page", ",", "SEND_BODY", ")", ";", "#endif", "if", "(", "file_size", "!=", "-1", ")", "{", "strftime", "(", "tmp_str", ",", "sizeof", "(", "tmp_str", ")", ",", "RFC1123FMT", ",", "gmtime", "(", "&", "last_mod", ")", ")", ";", "#if", "ENABLE_FEATURE_HTTPD_RANGES", "\n", "len", "+=", "sprintf", "(", "iobuf", ")", ";", "#endif", "#if", "ENABLE_FEATURE_HTTPD_RANGES", "\n", "len", "+=", "sprintf", "(", "iobuf", ")", ";", "#endif", "}", "if", "(", "content_gzip", ")", "len", "+=", "sprintf", "(", "iobuf", "+", "len", ",", "\"", "\\r", "\\n", "\"", ")", ";", "iobuf", "[", "len", "++", "]", "=", "'", "\\r", "'", ";", "iobuf", "[", "len", "++", "]", "=", "'", "\\n", "'", ";", "if", "(", "infoString", ")", "{", "len", "+=", "sprintf", "(", "iobuf", "+", "len", ",", "\"", "\\n", "\"", "\"", "\\n", "\\n", "\\n", "\"", ",", "responseNum", ",", "responseString", ",", "responseNum", ",", "responseString", ",", "infoString", ")", ";", "}", "if", "(", "DEBUG", ")", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "iobuf", ")", ";", "if", "(", "full_write", "(", "STDOUT_FILENO", ",", "iobuf", ",", "len", ")", "!=", "len", ")", "{", "if", "(", "verbose", ">", "1", ")", "bb_perror_msg", "(", "\"", "\"", ")", ";", "log_and_exit", "(", ")", ";", "}", "}" ]
Create and send HTTP response headers.
[ "Create", "and", "send", "HTTP", "response", "headers", "." ]
[ "/* error message is HTML */", "/* emit the current date */", "/* file */" ]
[ { "param": "responseNum", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "responseNum", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
71bed5cd06d8f96e606895f9344c2eb4e5f8df58
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/kernel/sched/rt.c
[ "Apache-2.0" ]
C
update_curr_rt
void
static void update_curr_rt(struct rq *rq) { struct task_struct *curr = rq->curr; struct sched_rt_entity *rt_se = &curr->rt; struct rt_rq *rt_rq = rt_rq_of_se(rt_se); u64 delta_exec; if (curr->sched_class != &rt_sched_class) return; delta_exec = rq_clock_task(rq) - curr->se.exec_start; if (unlikely((s64)delta_exec <= 0)) return; schedstat_set(curr->se.statistics.exec_max, max(curr->se.statistics.exec_max, delta_exec)); curr->se.sum_exec_runtime += delta_exec; account_group_exec_runtime(curr, delta_exec); curr->se.exec_start = rq_clock_task(rq); cpuacct_charge(curr, delta_exec); sched_rt_avg_update(rq, delta_exec); if (!rt_bandwidth_enabled()) return; //for_each_sched_rt_entity(rt_se) { rt_rq = rt_rq_of_se(rt_se); if (sched_rt_runtime(rt_rq) != RUNTIME_INF) { raw_spin_lock(&rt_rq->rt_runtime_lock); rt_rq->rt_time += delta_exec; if (sched_rt_runtime_exceeded(rt_rq)) resched_task(curr); raw_spin_unlock(&rt_rq->rt_runtime_lock); } //} }
/* * Update the current task's runtime statistics. Skip current tasks that * are not in our scheduling class. */
Update the current task's runtime statistics. Skip current tasks that are not in our scheduling class.
[ "Update", "the", "current", "task", "'", "s", "runtime", "statistics", ".", "Skip", "current", "tasks", "that", "are", "not", "in", "our", "scheduling", "class", "." ]
static void update_curr_rt(struct rq *rq) { struct task_struct *curr = rq->curr; struct sched_rt_entity *rt_se = &curr->rt; struct rt_rq *rt_rq = rt_rq_of_se(rt_se); u64 delta_exec; if (curr->sched_class != &rt_sched_class) return; delta_exec = rq_clock_task(rq) - curr->se.exec_start; if (unlikely((s64)delta_exec <= 0)) return; schedstat_set(curr->se.statistics.exec_max, max(curr->se.statistics.exec_max, delta_exec)); curr->se.sum_exec_runtime += delta_exec; account_group_exec_runtime(curr, delta_exec); curr->se.exec_start = rq_clock_task(rq); cpuacct_charge(curr, delta_exec); sched_rt_avg_update(rq, delta_exec); if (!rt_bandwidth_enabled()) return; rt_rq = rt_rq_of_se(rt_se); if (sched_rt_runtime(rt_rq) != RUNTIME_INF) { raw_spin_lock(&rt_rq->rt_runtime_lock); rt_rq->rt_time += delta_exec; if (sched_rt_runtime_exceeded(rt_rq)) resched_task(curr); raw_spin_unlock(&rt_rq->rt_runtime_lock); } }
[ "static", "void", "update_curr_rt", "(", "struct", "rq", "*", "rq", ")", "{", "struct", "task_struct", "*", "curr", "=", "rq", "->", "curr", ";", "struct", "sched_rt_entity", "*", "rt_se", "=", "&", "curr", "->", "rt", ";", "struct", "rt_rq", "*", "rt_rq", "=", "rt_rq_of_se", "(", "rt_se", ")", ";", "u64", "delta_exec", ";", "if", "(", "curr", "->", "sched_class", "!=", "&", "rt_sched_class", ")", "return", ";", "delta_exec", "=", "rq_clock_task", "(", "rq", ")", "-", "curr", "->", "se", ".", "exec_start", ";", "if", "(", "unlikely", "(", "(", "s64", ")", "delta_exec", "<=", "0", ")", ")", "return", ";", "schedstat_set", "(", "curr", "->", "se", ".", "statistics", ".", "exec_max", ",", "max", "(", "curr", "->", "se", ".", "statistics", ".", "exec_max", ",", "delta_exec", ")", ")", ";", "curr", "->", "se", ".", "sum_exec_runtime", "+=", "delta_exec", ";", "account_group_exec_runtime", "(", "curr", ",", "delta_exec", ")", ";", "curr", "->", "se", ".", "exec_start", "=", "rq_clock_task", "(", "rq", ")", ";", "cpuacct_charge", "(", "curr", ",", "delta_exec", ")", ";", "sched_rt_avg_update", "(", "rq", ",", "delta_exec", ")", ";", "if", "(", "!", "rt_bandwidth_enabled", "(", ")", ")", "return", ";", "rt_rq", "=", "rt_rq_of_se", "(", "rt_se", ")", ";", "if", "(", "sched_rt_runtime", "(", "rt_rq", ")", "!=", "RUNTIME_INF", ")", "{", "raw_spin_lock", "(", "&", "rt_rq", "->", "rt_runtime_lock", ")", ";", "rt_rq", "->", "rt_time", "+=", "delta_exec", ";", "if", "(", "sched_rt_runtime_exceeded", "(", "rt_rq", ")", ")", "resched_task", "(", "curr", ")", ";", "raw_spin_unlock", "(", "&", "rt_rq", "->", "rt_runtime_lock", ")", ";", "}", "}" ]
Update the current task's runtime statistics.
[ "Update", "the", "current", "task", "'", "s", "runtime", "statistics", "." ]
[ "//for_each_sched_rt_entity(rt_se) {", "//}" ]
[ { "param": "rq", "type": "struct rq" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rq", "type": "struct rq", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
71bed5cd06d8f96e606895f9344c2eb4e5f8df58
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/kernel/sched/rt.c
[ "Apache-2.0" ]
C
task_woken_rt
void
static void task_woken_rt(struct rq *rq, struct task_struct *p) { if (!task_running(rq, p) && !test_tsk_need_resched(rq->curr) && has_pushable_tasks(rq) && p->nr_cpus_allowed > 1 && (dl_task(rq->curr) || rt_task(rq->curr)) && (rq->curr->nr_cpus_allowed < 2 || rq->curr->prio <= p->prio)) push_rt_tasks(rq); }
/* * If we are not running and we are not going to reschedule soon, we should * try to push tasks away now */
If we are not running and we are not going to reschedule soon, we should try to push tasks away now
[ "If", "we", "are", "not", "running", "and", "we", "are", "not", "going", "to", "reschedule", "soon", "we", "should", "try", "to", "push", "tasks", "away", "now" ]
static void task_woken_rt(struct rq *rq, struct task_struct *p) { if (!task_running(rq, p) && !test_tsk_need_resched(rq->curr) && has_pushable_tasks(rq) && p->nr_cpus_allowed > 1 && (dl_task(rq->curr) || rt_task(rq->curr)) && (rq->curr->nr_cpus_allowed < 2 || rq->curr->prio <= p->prio)) push_rt_tasks(rq); }
[ "static", "void", "task_woken_rt", "(", "struct", "rq", "*", "rq", ",", "struct", "task_struct", "*", "p", ")", "{", "if", "(", "!", "task_running", "(", "rq", ",", "p", ")", "&&", "!", "test_tsk_need_resched", "(", "rq", "->", "curr", ")", "&&", "has_pushable_tasks", "(", "rq", ")", "&&", "p", "->", "nr_cpus_allowed", ">", "1", "&&", "(", "dl_task", "(", "rq", "->", "curr", ")", "||", "rt_task", "(", "rq", "->", "curr", ")", ")", "&&", "(", "rq", "->", "curr", "->", "nr_cpus_allowed", "<", "2", "||", "rq", "->", "curr", "->", "prio", "<=", "p", "->", "prio", ")", ")", "push_rt_tasks", "(", "rq", ")", ";", "}" ]
If we are not running and we are not going to reschedule soon, we should try to push tasks away now
[ "If", "we", "are", "not", "running", "and", "we", "are", "not", "going", "to", "reschedule", "soon", "we", "should", "try", "to", "push", "tasks", "away", "now" ]
[]
[ { "param": "rq", "type": "struct rq" }, { "param": "p", "type": "struct task_struct" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rq", "type": "struct rq", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p", "type": "struct task_struct", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fcb711a9ebf036039321516554b46525193943a4
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/drivers/extcon/extcon-class.c
[ "Apache-2.0" ]
C
check_mutually_exclusive
int
static int check_mutually_exclusive(struct WEXT_CORE_dev *edev, u32 new_state) { int i = 0; if (!edev->mutually_exclusive) return 0; for (i = 0; edev->mutually_exclusive[i]; i++) { int weight; u32 correspondants = new_state & edev->mutually_exclusive[i]; /* calculate the total number of bits set */ #ifdef WEXT_CORE #ifdef SYSFS weight = hweight32(correspondants); if (weight > 1) return i + 1; #endif #endif } return 0; }
/** * check_mutually_exclusive - Check if new_state violates mutually_exclusive * condition. * @edev: the WEXT_CORE device * @new_state: new cable attach status for @edev * * Returns 0 if nothing violates. Returns the index + 1 for the first * violated condition. */
Returns 0 if nothing violates. Returns the index + 1 for the first violated condition.
[ "Returns", "0", "if", "nothing", "violates", ".", "Returns", "the", "index", "+", "1", "for", "the", "first", "violated", "condition", "." ]
static int check_mutually_exclusive(struct WEXT_CORE_dev *edev, u32 new_state) { int i = 0; if (!edev->mutually_exclusive) return 0; for (i = 0; edev->mutually_exclusive[i]; i++) { int weight; u32 correspondants = new_state & edev->mutually_exclusive[i]; #ifdef WEXT_CORE #ifdef SYSFS weight = hweight32(correspondants); if (weight > 1) return i + 1; #endif #endif } return 0; }
[ "static", "int", "check_mutually_exclusive", "(", "struct", "WEXT_CORE_dev", "*", "edev", ",", "u32", "new_state", ")", "{", "int", "i", "=", "0", ";", "if", "(", "!", "edev", "->", "mutually_exclusive", ")", "return", "0", ";", "for", "(", "i", "=", "0", ";", "edev", "->", "mutually_exclusive", "[", "i", "]", ";", "i", "++", ")", "{", "int", "weight", ";", "u32", "correspondants", "=", "new_state", "&", "edev", "->", "mutually_exclusive", "[", "i", "]", ";", "#ifdef", "WEXT_CORE", "#ifdef", "SYSFS", "weight", "=", "hweight32", "(", "correspondants", ")", ";", "if", "(", "weight", ">", "1", ")", "return", "i", "+", "1", ";", "#endif", "#endif", "}", "return", "0", ";", "}" ]
check_mutually_exclusive - Check if new_state violates mutually_exclusive condition.
[ "check_mutually_exclusive", "-", "Check", "if", "new_state", "violates", "mutually_exclusive", "condition", "." ]
[ "/* calculate the total number of bits set */" ]
[ { "param": "edev", "type": "struct WEXT_CORE_dev" }, { "param": "new_state", "type": "u32" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "edev", "type": "struct WEXT_CORE_dev", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "new_state", "type": "u32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fcb711a9ebf036039321516554b46525193943a4
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/drivers/extcon/extcon-class.c
[ "Apache-2.0" ]
C
WEXT_CORE_update_state
int
int WEXT_CORE_update_state(struct WEXT_CORE_dev *edev, u32 mask, u32 state) { char name_buf[120]; char state_buf[120]; char *prop_buf; char *envp[3]; int env_offset = 0; int length; unsigned long flags; spin_lock_irqsave(&edev->lock, flags); if (edev->state != ((edev->state & ~mask) | (state & mask))) { u32 old_state = edev->state; if (check_mutually_exclusive(edev, (edev->state & ~mask) | (state & mask))) { spin_unlock_irqrestore(&edev->lock, flags); return -EPERM; } edev->state &= ~mask; edev->state |= state & mask; raw_notifier_call_chain(&edev->nh, old_state, edev); /* This could be in interrupt handler */ prop_buf = (char *)get_zeroed_page(GFP_ATOMIC); if (prop_buf) { length = name_show(edev->dev, NULL, prop_buf); if (length > 0) { if (prop_buf[length - 1] == '\n') prop_buf[length - 1] = 0; snprintf(name_buf, sizeof(name_buf), "NAME=%s", prop_buf); envp[env_offset++] = name_buf; } length = state_show(edev->dev, NULL, prop_buf); if (length > 0) { if (prop_buf[length - 1] == '\n') prop_buf[length - 1] = 0; snprintf(state_buf, sizeof(state_buf), "STATE=%s", prop_buf); envp[env_offset++] = state_buf; } envp[env_offset] = NULL; /* Unlock early before uevent */ spin_unlock_irqrestore(&edev->lock, flags); kobject_uevent_env(&edev->dev->kobj, KOBJ_CHANGE, envp); free_page((unsigned long)prop_buf); } else { /* Unlock early before uevent */ spin_unlock_irqrestore(&edev->lock, flags); dev_err(edev->dev, "out of memory in WEXT_CORE_set_state\n"); kobject_uevent(&edev->dev->kobj, KOBJ_CHANGE); } } else { /* No changes */ spin_unlock_irqrestore(&edev->lock, flags); } return 0; }
/** * WEXT_CORE_update_state() - Update the cable attach states of the WEXT_CORE device * only for the masked bits. * @edev: the WEXT_CORE device * @mask: the bit mask to designate updated bits. * @state: new cable attach status for @edev * * Changing the state sends uevent with environment variable containing * the name of WEXT_CORE device (envp[0]) and the state output (envp[1]). * Tizen uses this format for WEXT_CORE device to get events from ports. * Android uses this format as well. * * Note that the notifier provides which bits are changed in the state * variable with the val parameter (second) to the callback. */
Update the cable attach states of the WEXT_CORE device only for the masked bits. @edev: the WEXT_CORE device @mask: the bit mask to designate updated bits. @state: new cable attach status for @edev Changing the state sends uevent with environment variable containing the name of WEXT_CORE device (envp[0]) and the state output (envp[1]). Tizen uses this format for WEXT_CORE device to get events from ports. Android uses this format as well. Note that the notifier provides which bits are changed in the state variable with the val parameter (second) to the callback.
[ "Update", "the", "cable", "attach", "states", "of", "the", "WEXT_CORE", "device", "only", "for", "the", "masked", "bits", ".", "@edev", ":", "the", "WEXT_CORE", "device", "@mask", ":", "the", "bit", "mask", "to", "designate", "updated", "bits", ".", "@state", ":", "new", "cable", "attach", "status", "for", "@edev", "Changing", "the", "state", "sends", "uevent", "with", "environment", "variable", "containing", "the", "name", "of", "WEXT_CORE", "device", "(", "envp", "[", "0", "]", ")", "and", "the", "state", "output", "(", "envp", "[", "1", "]", ")", ".", "Tizen", "uses", "this", "format", "for", "WEXT_CORE", "device", "to", "get", "events", "from", "ports", ".", "Android", "uses", "this", "format", "as", "well", ".", "Note", "that", "the", "notifier", "provides", "which", "bits", "are", "changed", "in", "the", "state", "variable", "with", "the", "val", "parameter", "(", "second", ")", "to", "the", "callback", "." ]
int WEXT_CORE_update_state(struct WEXT_CORE_dev *edev, u32 mask, u32 state) { char name_buf[120]; char state_buf[120]; char *prop_buf; char *envp[3]; int env_offset = 0; int length; unsigned long flags; spin_lock_irqsave(&edev->lock, flags); if (edev->state != ((edev->state & ~mask) | (state & mask))) { u32 old_state = edev->state; if (check_mutually_exclusive(edev, (edev->state & ~mask) | (state & mask))) { spin_unlock_irqrestore(&edev->lock, flags); return -EPERM; } edev->state &= ~mask; edev->state |= state & mask; raw_notifier_call_chain(&edev->nh, old_state, edev); prop_buf = (char *)get_zeroed_page(GFP_ATOMIC); if (prop_buf) { length = name_show(edev->dev, NULL, prop_buf); if (length > 0) { if (prop_buf[length - 1] == '\n') prop_buf[length - 1] = 0; snprintf(name_buf, sizeof(name_buf), "NAME=%s", prop_buf); envp[env_offset++] = name_buf; } length = state_show(edev->dev, NULL, prop_buf); if (length > 0) { if (prop_buf[length - 1] == '\n') prop_buf[length - 1] = 0; snprintf(state_buf, sizeof(state_buf), "STATE=%s", prop_buf); envp[env_offset++] = state_buf; } envp[env_offset] = NULL; spin_unlock_irqrestore(&edev->lock, flags); kobject_uevent_env(&edev->dev->kobj, KOBJ_CHANGE, envp); free_page((unsigned long)prop_buf); } else { spin_unlock_irqrestore(&edev->lock, flags); dev_err(edev->dev, "out of memory in WEXT_CORE_set_state\n"); kobject_uevent(&edev->dev->kobj, KOBJ_CHANGE); } } else { spin_unlock_irqrestore(&edev->lock, flags); } return 0; }
[ "int", "WEXT_CORE_update_state", "(", "struct", "WEXT_CORE_dev", "*", "edev", ",", "u32", "mask", ",", "u32", "state", ")", "{", "char", "name_buf", "[", "120", "]", ";", "char", "state_buf", "[", "120", "]", ";", "char", "*", "prop_buf", ";", "char", "*", "envp", "[", "3", "]", ";", "int", "env_offset", "=", "0", ";", "int", "length", ";", "unsigned", "long", "flags", ";", "spin_lock_irqsave", "(", "&", "edev", "->", "lock", ",", "flags", ")", ";", "if", "(", "edev", "->", "state", "!=", "(", "(", "edev", "->", "state", "&", "~", "mask", ")", "|", "(", "state", "&", "mask", ")", ")", ")", "{", "u32", "old_state", "=", "edev", "->", "state", ";", "if", "(", "check_mutually_exclusive", "(", "edev", ",", "(", "edev", "->", "state", "&", "~", "mask", ")", "|", "(", "state", "&", "mask", ")", ")", ")", "{", "spin_unlock_irqrestore", "(", "&", "edev", "->", "lock", ",", "flags", ")", ";", "return", "-", "EPERM", ";", "}", "edev", "->", "state", "&=", "~", "mask", ";", "edev", "->", "state", "|=", "state", "&", "mask", ";", "raw_notifier_call_chain", "(", "&", "edev", "->", "nh", ",", "old_state", ",", "edev", ")", ";", "prop_buf", "=", "(", "char", "*", ")", "get_zeroed_page", "(", "GFP_ATOMIC", ")", ";", "if", "(", "prop_buf", ")", "{", "length", "=", "name_show", "(", "edev", "->", "dev", ",", "NULL", ",", "prop_buf", ")", ";", "if", "(", "length", ">", "0", ")", "{", "if", "(", "prop_buf", "[", "length", "-", "1", "]", "==", "'", "\\n", "'", ")", "prop_buf", "[", "length", "-", "1", "]", "=", "0", ";", "snprintf", "(", "name_buf", ",", "sizeof", "(", "name_buf", ")", ",", "\"", "\"", ",", "prop_buf", ")", ";", "envp", "[", "env_offset", "++", "]", "=", "name_buf", ";", "}", "length", "=", "state_show", "(", "edev", "->", "dev", ",", "NULL", ",", "prop_buf", ")", ";", "if", "(", "length", ">", "0", ")", "{", "if", "(", "prop_buf", "[", "length", "-", "1", "]", "==", "'", "\\n", "'", ")", "prop_buf", "[", "length", "-", "1", "]", "=", "0", ";", "snprintf", "(", "state_buf", ",", "sizeof", "(", "state_buf", ")", ",", "\"", "\"", ",", "prop_buf", ")", ";", "envp", "[", "env_offset", "++", "]", "=", "state_buf", ";", "}", "envp", "[", "env_offset", "]", "=", "NULL", ";", "spin_unlock_irqrestore", "(", "&", "edev", "->", "lock", ",", "flags", ")", ";", "kobject_uevent_env", "(", "&", "edev", "->", "dev", "->", "kobj", ",", "KOBJ_CHANGE", ",", "envp", ")", ";", "free_page", "(", "(", "unsigned", "long", ")", "prop_buf", ")", ";", "}", "else", "{", "spin_unlock_irqrestore", "(", "&", "edev", "->", "lock", ",", "flags", ")", ";", "dev_err", "(", "edev", "->", "dev", ",", "\"", "\\n", "\"", ")", ";", "kobject_uevent", "(", "&", "edev", "->", "dev", "->", "kobj", ",", "KOBJ_CHANGE", ")", ";", "}", "}", "else", "{", "spin_unlock_irqrestore", "(", "&", "edev", "->", "lock", ",", "flags", ")", ";", "}", "return", "0", ";", "}" ]
WEXT_CORE_update_state() - Update the cable attach states of the WEXT_CORE device only for the masked bits.
[ "WEXT_CORE_update_state", "()", "-", "Update", "the", "cable", "attach", "states", "of", "the", "WEXT_CORE", "device", "only", "for", "the", "masked", "bits", "." ]
[ "/* This could be in interrupt handler */", "/* Unlock early before uevent */", "/* Unlock early before uevent */", "/* No changes */" ]
[ { "param": "edev", "type": "struct WEXT_CORE_dev" }, { "param": "mask", "type": "u32" }, { "param": "state", "type": "u32" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "edev", "type": "struct WEXT_CORE_dev", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mask", "type": "u32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "state", "type": "u32", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fcb711a9ebf036039321516554b46525193943a4
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/drivers/extcon/extcon-class.c
[ "Apache-2.0" ]
C
WEXT_CORE_find_cable_index
int
int WEXT_CORE_find_cable_index(struct WEXT_CORE_dev *edev, const char *cable_name) { int i; if (edev->supported_cable) { for (i = 0; edev->supported_cable[i]; i++) { if (!strncmp(edev->supported_cable[i], cable_name, CABLE_NAME_MAX)) return i; } } return -EINVAL; }
/** * WEXT_CORE_find_cable_index() - Get the cable index based on the cable name. * @edev: the WEXT_CORE device that has the cable. * @cable_name: cable name to be searched. * * Note that accessing a cable state based on cable_index is faster than * cable_name because using cable_name induces a loop with strncmp(). * Thus, when get/set_cable_state is repeatedly used, using cable_index * is recommended. */
Get the cable index based on the cable name. @edev: the WEXT_CORE device that has the cable. @cable_name: cable name to be searched. Note that accessing a cable state based on cable_index is faster than cable_name because using cable_name induces a loop with strncmp(). Thus, when get/set_cable_state is repeatedly used, using cable_index is recommended.
[ "Get", "the", "cable", "index", "based", "on", "the", "cable", "name", ".", "@edev", ":", "the", "WEXT_CORE", "device", "that", "has", "the", "cable", ".", "@cable_name", ":", "cable", "name", "to", "be", "searched", ".", "Note", "that", "accessing", "a", "cable", "state", "based", "on", "cable_index", "is", "faster", "than", "cable_name", "because", "using", "cable_name", "induces", "a", "loop", "with", "strncmp", "()", ".", "Thus", "when", "get", "/", "set_cable_state", "is", "repeatedly", "used", "using", "cable_index", "is", "recommended", "." ]
int WEXT_CORE_find_cable_index(struct WEXT_CORE_dev *edev, const char *cable_name) { int i; if (edev->supported_cable) { for (i = 0; edev->supported_cable[i]; i++) { if (!strncmp(edev->supported_cable[i], cable_name, CABLE_NAME_MAX)) return i; } } return -EINVAL; }
[ "int", "WEXT_CORE_find_cable_index", "(", "struct", "WEXT_CORE_dev", "*", "edev", ",", "const", "char", "*", "cable_name", ")", "{", "int", "i", ";", "if", "(", "edev", "->", "supported_cable", ")", "{", "for", "(", "i", "=", "0", ";", "edev", "->", "supported_cable", "[", "i", "]", ";", "i", "++", ")", "{", "if", "(", "!", "strncmp", "(", "edev", "->", "supported_cable", "[", "i", "]", ",", "cable_name", ",", "CABLE_NAME_MAX", ")", ")", "return", "i", ";", "}", "}", "return", "-", "EINVAL", ";", "}" ]
WEXT_CORE_find_cable_index() - Get the cable index based on the cable name.
[ "WEXT_CORE_find_cable_index", "()", "-", "Get", "the", "cable", "index", "based", "on", "the", "cable", "name", "." ]
[]
[ { "param": "edev", "type": "struct WEXT_CORE_dev" }, { "param": "cable_name", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "edev", "type": "struct WEXT_CORE_dev", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cable_name", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fcb711a9ebf036039321516554b46525193943a4
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/drivers/extcon/extcon-class.c
[ "Apache-2.0" ]
C
WEXT_CORE_register_interest
int
int WEXT_CORE_register_interest(struct WEXT_CORE_specific_cable_nb *obj, const char *WEXT_CORE_name, const char *cable_name, struct notifier_block *nb) { if (!obj || !WEXT_CORE_name || !cable_name || !nb) return -EINVAL; obj->edev = WEXT_CORE_get_WEXT_CORE_dev(WEXT_CORE_name); if (!obj->edev) return -ENODEV; obj->cable_index = WEXT_CORE_find_cable_index(obj->edev, cable_name); if (obj->cable_index < 0) return -ENODEV; obj->user_nb = nb; obj->internal_nb.notifier_call = _call_per_cable; return raw_notifier_chain_register(&obj->edev->nh, &obj->internal_nb); }
/** * WEXT_CORE_register_interest() - Register a notifier for a state change of a * specific cable, not an entier set of cables of a * WEXT_CORE device. * @obj: an empty WEXT_CORE_specific_cable_nb object to be returned. * @WEXT_CORE_name: the name of WEXT_CORE device. * @cable_name: the target cable name. * @nb: the notifier block to get notified. * * Provide an empty WEXT_CORE_specific_cable_nb. WEXT_CORE_register_interest() sets * the struct for you. * * WEXT_CORE_register_interest is a helper function for those who want to get * notification for a single specific cable's status change. If a user wants * to get notification for any changes of all cables of a WEXT_CORE device, * he/she should use the general WEXT_CORE_register_notifier(). * * Note that the second parameter given to the callback of nb (val) is * "old_state", not the current state. The current state can be retrieved * by looking at the third pameter (edev pointer)'s state value. */
Register a notifier for a state change of a specific cable, not an entier set of cables of a WEXT_CORE device. @obj: an empty WEXT_CORE_specific_cable_nb object to be returned. Provide an empty WEXT_CORE_specific_cable_nb. WEXT_CORE_register_interest() sets the struct for you. WEXT_CORE_register_interest is a helper function for those who want to get notification for a single specific cable's status change. If a user wants to get notification for any changes of all cables of a WEXT_CORE device, he/she should use the general WEXT_CORE_register_notifier(). Note that the second parameter given to the callback of nb (val) is "old_state", not the current state. The current state can be retrieved by looking at the third pameter (edev pointer)'s state value.
[ "Register", "a", "notifier", "for", "a", "state", "change", "of", "a", "specific", "cable", "not", "an", "entier", "set", "of", "cables", "of", "a", "WEXT_CORE", "device", ".", "@obj", ":", "an", "empty", "WEXT_CORE_specific_cable_nb", "object", "to", "be", "returned", ".", "Provide", "an", "empty", "WEXT_CORE_specific_cable_nb", ".", "WEXT_CORE_register_interest", "()", "sets", "the", "struct", "for", "you", ".", "WEXT_CORE_register_interest", "is", "a", "helper", "function", "for", "those", "who", "want", "to", "get", "notification", "for", "a", "single", "specific", "cable", "'", "s", "status", "change", ".", "If", "a", "user", "wants", "to", "get", "notification", "for", "any", "changes", "of", "all", "cables", "of", "a", "WEXT_CORE", "device", "he", "/", "she", "should", "use", "the", "general", "WEXT_CORE_register_notifier", "()", ".", "Note", "that", "the", "second", "parameter", "given", "to", "the", "callback", "of", "nb", "(", "val", ")", "is", "\"", "old_state", "\"", "not", "the", "current", "state", ".", "The", "current", "state", "can", "be", "retrieved", "by", "looking", "at", "the", "third", "pameter", "(", "edev", "pointer", ")", "'", "s", "state", "value", "." ]
int WEXT_CORE_register_interest(struct WEXT_CORE_specific_cable_nb *obj, const char *WEXT_CORE_name, const char *cable_name, struct notifier_block *nb) { if (!obj || !WEXT_CORE_name || !cable_name || !nb) return -EINVAL; obj->edev = WEXT_CORE_get_WEXT_CORE_dev(WEXT_CORE_name); if (!obj->edev) return -ENODEV; obj->cable_index = WEXT_CORE_find_cable_index(obj->edev, cable_name); if (obj->cable_index < 0) return -ENODEV; obj->user_nb = nb; obj->internal_nb.notifier_call = _call_per_cable; return raw_notifier_chain_register(&obj->edev->nh, &obj->internal_nb); }
[ "int", "WEXT_CORE_register_interest", "(", "struct", "WEXT_CORE_specific_cable_nb", "*", "obj", ",", "const", "char", "*", "WEXT_CORE_name", ",", "const", "char", "*", "cable_name", ",", "struct", "notifier_block", "*", "nb", ")", "{", "if", "(", "!", "obj", "||", "!", "WEXT_CORE_name", "||", "!", "cable_name", "||", "!", "nb", ")", "return", "-", "EINVAL", ";", "obj", "->", "edev", "=", "WEXT_CORE_get_WEXT_CORE_dev", "(", "WEXT_CORE_name", ")", ";", "if", "(", "!", "obj", "->", "edev", ")", "return", "-", "ENODEV", ";", "obj", "->", "cable_index", "=", "WEXT_CORE_find_cable_index", "(", "obj", "->", "edev", ",", "cable_name", ")", ";", "if", "(", "obj", "->", "cable_index", "<", "0", ")", "return", "-", "ENODEV", ";", "obj", "->", "user_nb", "=", "nb", ";", "obj", "->", "internal_nb", ".", "notifier_call", "=", "_call_per_cable", ";", "return", "raw_notifier_chain_register", "(", "&", "obj", "->", "edev", "->", "nh", ",", "&", "obj", "->", "internal_nb", ")", ";", "}" ]
WEXT_CORE_register_interest() - Register a notifier for a state change of a specific cable, not an entier set of cables of a WEXT_CORE device.
[ "WEXT_CORE_register_interest", "()", "-", "Register", "a", "notifier", "for", "a", "state", "change", "of", "a", "specific", "cable", "not", "an", "entier", "set", "of", "cables", "of", "a", "WEXT_CORE", "device", "." ]
[]
[ { "param": "obj", "type": "struct WEXT_CORE_specific_cable_nb" }, { "param": "WEXT_CORE_name", "type": "char" }, { "param": "cable_name", "type": "char" }, { "param": "nb", "type": "struct notifier_block" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "obj", "type": "struct WEXT_CORE_specific_cable_nb", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "WEXT_CORE_name", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cable_name", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "nb", "type": "struct notifier_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fcb711a9ebf036039321516554b46525193943a4
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/drivers/extcon/extcon-class.c
[ "Apache-2.0" ]
C
WEXT_CORE_register_notifier
int
int WEXT_CORE_register_notifier(struct WEXT_CORE_dev *edev, struct notifier_block *nb) { return raw_notifier_chain_register(&edev->nh, nb); }
/** * WEXT_CORE_register_notifier() - Register a notifiee to get notified by * any attach status changes from the WEXT_CORE. * @edev: the WEXT_CORE device. * @nb: a notifier block to be registered. * * Note that the second parameter given to the callback of nb (val) is * "old_state", not the current state. The current state can be retrieved * by looking at the third pameter (edev pointer)'s state value. */
Register a notifiee to get notified by any attach status changes from the WEXT_CORE. @edev: the WEXT_CORE device. @nb: a notifier block to be registered. Note that the second parameter given to the callback of nb (val) is "old_state", not the current state. The current state can be retrieved by looking at the third pameter (edev pointer)'s state value.
[ "Register", "a", "notifiee", "to", "get", "notified", "by", "any", "attach", "status", "changes", "from", "the", "WEXT_CORE", ".", "@edev", ":", "the", "WEXT_CORE", "device", ".", "@nb", ":", "a", "notifier", "block", "to", "be", "registered", ".", "Note", "that", "the", "second", "parameter", "given", "to", "the", "callback", "of", "nb", "(", "val", ")", "is", "\"", "old_state", "\"", "not", "the", "current", "state", ".", "The", "current", "state", "can", "be", "retrieved", "by", "looking", "at", "the", "third", "pameter", "(", "edev", "pointer", ")", "'", "s", "state", "value", "." ]
int WEXT_CORE_register_notifier(struct WEXT_CORE_dev *edev, struct notifier_block *nb) { return raw_notifier_chain_register(&edev->nh, nb); }
[ "int", "WEXT_CORE_register_notifier", "(", "struct", "WEXT_CORE_dev", "*", "edev", ",", "struct", "notifier_block", "*", "nb", ")", "{", "return", "raw_notifier_chain_register", "(", "&", "edev", "->", "nh", ",", "nb", ")", ";", "}" ]
WEXT_CORE_register_notifier() - Register a notifiee to get notified by any attach status changes from the WEXT_CORE.
[ "WEXT_CORE_register_notifier", "()", "-", "Register", "a", "notifiee", "to", "get", "notified", "by", "any", "attach", "status", "changes", "from", "the", "WEXT_CORE", "." ]
[]
[ { "param": "edev", "type": "struct WEXT_CORE_dev" }, { "param": "nb", "type": "struct notifier_block" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "edev", "type": "struct WEXT_CORE_dev", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "nb", "type": "struct notifier_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fcb711a9ebf036039321516554b46525193943a4
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/drivers/extcon/extcon-class.c
[ "Apache-2.0" ]
C
WEXT_CORE_unregister_notifier
int
int WEXT_CORE_unregister_notifier(struct WEXT_CORE_dev *edev, struct notifier_block *nb) { return raw_notifier_chain_unregister(&edev->nh, nb); }
/** * WEXT_CORE_unregister_notifier() - Unregister a notifiee from the WEXT_CORE device. * @edev: the WEXT_CORE device. * @nb: a registered notifier block to be unregistered. */
Unregister a notifiee from the WEXT_CORE device. @edev: the WEXT_CORE device. @nb: a registered notifier block to be unregistered.
[ "Unregister", "a", "notifiee", "from", "the", "WEXT_CORE", "device", ".", "@edev", ":", "the", "WEXT_CORE", "device", ".", "@nb", ":", "a", "registered", "notifier", "block", "to", "be", "unregistered", "." ]
int WEXT_CORE_unregister_notifier(struct WEXT_CORE_dev *edev, struct notifier_block *nb) { return raw_notifier_chain_unregister(&edev->nh, nb); }
[ "int", "WEXT_CORE_unregister_notifier", "(", "struct", "WEXT_CORE_dev", "*", "edev", ",", "struct", "notifier_block", "*", "nb", ")", "{", "return", "raw_notifier_chain_unregister", "(", "&", "edev", "->", "nh", ",", "nb", ")", ";", "}" ]
WEXT_CORE_unregister_notifier() - Unregister a notifiee from the WEXT_CORE device.
[ "WEXT_CORE_unregister_notifier", "()", "-", "Unregister", "a", "notifiee", "from", "the", "WEXT_CORE", "device", "." ]
[]
[ { "param": "edev", "type": "struct WEXT_CORE_dev" }, { "param": "nb", "type": "struct notifier_block" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "edev", "type": "struct WEXT_CORE_dev", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "nb", "type": "struct notifier_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6d6dfc3e8961b330d8d3d02dd8d1c396912c5fd7
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/arch/x86/kernel/smpboot.c
[ "Apache-2.0" ]
C
map_cpu_to_node
void
static void map_cpu_to_node(int cpu, int node) { printk("Mapping cpu %d to node %d\n", cpu, node); cpumask_set_cpu(cpu, node_to_cpumask_map[node]); cpu_to_node_map[cpu] = node; }
/* set up a mapping between cpu and node. */
set up a mapping between cpu and node.
[ "set", "up", "a", "mapping", "between", "cpu", "and", "node", "." ]
static void map_cpu_to_node(int cpu, int node) { printk("Mapping cpu %d to node %d\n", cpu, node); cpumask_set_cpu(cpu, node_to_cpumask_map[node]); cpu_to_node_map[cpu] = node; }
[ "static", "void", "map_cpu_to_node", "(", "int", "cpu", ",", "int", "node", ")", "{", "printk", "(", "\"", "\\n", "\"", ",", "cpu", ",", "node", ")", ";", "cpumask_set_cpu", "(", "cpu", ",", "node_to_cpumask_map", "[", "node", "]", ")", ";", "cpu_to_node_map", "[", "cpu", "]", "=", "node", ";", "}" ]
set up a mapping between cpu and node.
[ "set", "up", "a", "mapping", "between", "cpu", "and", "node", "." ]
[]
[ { "param": "cpu", "type": "int" }, { "param": "node", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cpu", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "node", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6d6dfc3e8961b330d8d3d02dd8d1c396912c5fd7
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/arch/x86/kernel/smpboot.c
[ "Apache-2.0" ]
C
unmap_cpu_to_node
void
static void unmap_cpu_to_node(int cpu) { int node; printk( "Unmapping cpu %d from all nodes\n", cpu); for (node = 0; node < MAX_NUMNODES; node++) cpumask_clear_cpu(cpu, node_to_cpumask_map[node]); cpu_to_node_map[cpu] = 0; }
/* undo a mapping between cpu and node. */
undo a mapping between cpu and node.
[ "undo", "a", "mapping", "between", "cpu", "and", "node", "." ]
static void unmap_cpu_to_node(int cpu) { int node; printk( "Unmapping cpu %d from all nodes\n", cpu); for (node = 0; node < MAX_NUMNODES; node++) cpumask_clear_cpu(cpu, node_to_cpumask_map[node]); cpu_to_node_map[cpu] = 0; }
[ "static", "void", "unmap_cpu_to_node", "(", "int", "cpu", ")", "{", "int", "node", ";", "printk", "(", "\"", "\\n", "\"", ",", "cpu", ")", ";", "for", "(", "node", "=", "0", ";", "node", "<", "MAX_NUMNODES", ";", "node", "++", ")", "cpumask_clear_cpu", "(", "cpu", ",", "node_to_cpumask_map", "[", "node", "]", ")", ";", "cpu_to_node_map", "[", "cpu", "]", "=", "0", ";", "}" ]
undo a mapping between cpu and node.
[ "undo", "a", "mapping", "between", "cpu", "and", "node", "." ]
[]
[ { "param": "cpu", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cpu", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6d6dfc3e8961b330d8d3d02dd8d1c396912c5fd7
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/arch/x86/kernel/smpboot.c
[ "Apache-2.0" ]
C
smp_callin
void
static void smp_callin(void) { int cpuid, phys_id; unsigned long timeout; /* * If waken up by an INIT in an 82489DX configuration * we may get here before an INIT-deassert IPI reaches * our local APIC. We have to wait for the IPI or we'll * lock up on an APIC access. */ if (apic->wait_for_init_deassert) apic->wait_for_init_deassert(&init_deasserted); /* * (This works even if the APIC is not enabled.) */ phys_id = read_apic_id(); cpuid = smp_processor_id(); if (cpumask_test_cpu(cpuid, cpu_callin_mask)) { panic("%s: phys CPU#%d, CPU#%d already present??\n", __func__, phys_id, cpuid); } pr_debug("CPU#%d (phys ID: %d) waiting for CALLOUT\n", cpuid, phys_id); /* * STARTUP IPIs are fragile beasts as they might sometimes * trigger some glue motherboard logic. Complete APIC bus * silence for 1 second, this overestimates the time the * boot CPU is spending to send the up to 2 STARTUP IPIs * by a factor of two. This should be enough. */ /* * Waiting 2s total for startup (udelay is not yet working) */ timeout = jiffies + 2*HZ; while (time_before(jiffies, timeout)) { /* * Has the boot CPU finished it's STARTUP sequence? */ if (cpumask_test_cpu(cpuid, cpu_callout_mask)) break; cpu_relax(); } if (!time_before(jiffies, timeout)) { panic("%s: CPU%d started up but did not get a callout!\n", __func__, cpuid); } /* * the boot CPU has finished the init stage and is spinning * on callin_map until we finish. We are free to set up this * CPU, first the APIC. (this is probably redundant on most * boards) */ pr_debug("CALLIN, before setup_local_APIC().\n"); if (apic->smp_callin_clear_local_apic) apic->smp_callin_clear_local_apic(); setup_local_APIC(); end_local_APIC_setup(); map_cpu_to_logical_apicid(); notify_cpu_starting(cpuid); /* * Need to setup vector mappings before we enable interrupts. */ setup_vector_irq(smp_processor_id()); /* * Get our bogomips. * * Need to enable IRQs because it can take longer and then * the NMI watchdog might kill us. */ local_irq_enable(); calibrate_delay(); local_irq_disable(); pr_debug("Stack at about %p\n", &cpuid); /* * Save our processor parameters */ smp_store_cpu_info(cpuid); /* * Allow the master to continue. */ cpumask_set_cpu(cpuid, cpu_callin_mask); }
/* * Report back to the Boot Processor. * Running on AP. */
Report back to the Boot Processor. Running on AP.
[ "Report", "back", "to", "the", "Boot", "Processor", ".", "Running", "on", "AP", "." ]
static void smp_callin(void) { int cpuid, phys_id; unsigned long timeout; if (apic->wait_for_init_deassert) apic->wait_for_init_deassert(&init_deasserted); phys_id = read_apic_id(); cpuid = smp_processor_id(); if (cpumask_test_cpu(cpuid, cpu_callin_mask)) { panic("%s: phys CPU#%d, CPU#%d already present??\n", __func__, phys_id, cpuid); } pr_debug("CPU#%d (phys ID: %d) waiting for CALLOUT\n", cpuid, phys_id); timeout = jiffies + 2*HZ; while (time_before(jiffies, timeout)) { if (cpumask_test_cpu(cpuid, cpu_callout_mask)) break; cpu_relax(); } if (!time_before(jiffies, timeout)) { panic("%s: CPU%d started up but did not get a callout!\n", __func__, cpuid); } pr_debug("CALLIN, before setup_local_APIC().\n"); if (apic->smp_callin_clear_local_apic) apic->smp_callin_clear_local_apic(); setup_local_APIC(); end_local_APIC_setup(); map_cpu_to_logical_apicid(); notify_cpu_starting(cpuid); setup_vector_irq(smp_processor_id()); local_irq_enable(); calibrate_delay(); local_irq_disable(); pr_debug("Stack at about %p\n", &cpuid); smp_store_cpu_info(cpuid); cpumask_set_cpu(cpuid, cpu_callin_mask); }
[ "static", "void", "smp_callin", "(", "void", ")", "{", "int", "cpuid", ",", "phys_id", ";", "unsigned", "long", "timeout", ";", "if", "(", "apic", "->", "wait_for_init_deassert", ")", "apic", "->", "wait_for_init_deassert", "(", "&", "init_deasserted", ")", ";", "phys_id", "=", "read_apic_id", "(", ")", ";", "cpuid", "=", "smp_processor_id", "(", ")", ";", "if", "(", "cpumask_test_cpu", "(", "cpuid", ",", "cpu_callin_mask", ")", ")", "{", "panic", "(", "\"", "\\n", "\"", ",", "__func__", ",", "phys_id", ",", "cpuid", ")", ";", "}", "pr_debug", "(", "\"", "\\n", "\"", ",", "cpuid", ",", "phys_id", ")", ";", "timeout", "=", "jiffies", "+", "2", "*", "HZ", ";", "while", "(", "time_before", "(", "jiffies", ",", "timeout", ")", ")", "{", "if", "(", "cpumask_test_cpu", "(", "cpuid", ",", "cpu_callout_mask", ")", ")", "break", ";", "cpu_relax", "(", ")", ";", "}", "if", "(", "!", "time_before", "(", "jiffies", ",", "timeout", ")", ")", "{", "panic", "(", "\"", "\\n", "\"", ",", "__func__", ",", "cpuid", ")", ";", "}", "pr_debug", "(", "\"", "\\n", "\"", ")", ";", "if", "(", "apic", "->", "smp_callin_clear_local_apic", ")", "apic", "->", "smp_callin_clear_local_apic", "(", ")", ";", "setup_local_APIC", "(", ")", ";", "end_local_APIC_setup", "(", ")", ";", "map_cpu_to_logical_apicid", "(", ")", ";", "notify_cpu_starting", "(", "cpuid", ")", ";", "setup_vector_irq", "(", "smp_processor_id", "(", ")", ")", ";", "local_irq_enable", "(", ")", ";", "calibrate_delay", "(", ")", ";", "local_irq_disable", "(", ")", ";", "pr_debug", "(", "\"", "\\n", "\"", ",", "&", "cpuid", ")", ";", "smp_store_cpu_info", "(", "cpuid", ")", ";", "cpumask_set_cpu", "(", "cpuid", ",", "cpu_callin_mask", ")", ";", "}" ]
Report back to the Boot Processor.
[ "Report", "back", "to", "the", "Boot", "Processor", "." ]
[ "/*\n\t * If waken up by an INIT in an 82489DX configuration\n\t * we may get here before an INIT-deassert IPI reaches\n\t * our local APIC. We have to wait for the IPI or we'll\n\t * lock up on an APIC access.\n\t */", "/*\n\t * (This works even if the APIC is not enabled.)\n\t */", "/*\n\t * STARTUP IPIs are fragile beasts as they might sometimes\n\t * trigger some glue motherboard logic. Complete APIC bus\n\t * silence for 1 second, this overestimates the time the\n\t * boot CPU is spending to send the up to 2 STARTUP IPIs\n\t * by a factor of two. This should be enough.\n\t */", "/*\n\t * Waiting 2s total for startup (udelay is not yet working)\n\t */", "/*\n\t\t * Has the boot CPU finished it's STARTUP sequence?\n\t\t */", "/*\n\t * the boot CPU has finished the init stage and is spinning\n\t * on callin_map until we finish. We are free to set up this\n\t * CPU, first the APIC. (this is probably redundant on most\n\t * boards)\n\t */", "/*\n\t * Need to setup vector mappings before we enable interrupts.\n\t */", "/*\n\t * Get our bogomips.\n\t *\n\t * Need to enable IRQs because it can take longer and then\n\t * the NMI watchdog might kill us.\n\t */", "/*\n\t * Save our processor parameters\n\t */", "/*\n\t * Allow the master to continue.\n\t */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
6d6dfc3e8961b330d8d3d02dd8d1c396912c5fd7
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/arch/x86/kernel/smpboot.c
[ "Apache-2.0" ]
C
smp_store_cpu_info
void
void smp_store_cpu_info(int id) { struct cpuinfo_x86 *c = &cpu_data(id); copy_cpuinfo_x86(c, &boot_cpu_data); c->cpu_index = id; if (id != 0) identify_secondary_cpu(c); }
/* * The bootstrap kernel entry code has set these up. Save them for * a given CPU */
The bootstrap kernel entry code has set these up. Save them for a given CPU
[ "The", "bootstrap", "kernel", "entry", "code", "has", "set", "these", "up", ".", "Save", "them", "for", "a", "given", "CPU" ]
void smp_store_cpu_info(int id) { struct cpuinfo_x86 *c = &cpu_data(id); copy_cpuinfo_x86(c, &boot_cpu_data); c->cpu_index = id; if (id != 0) identify_secondary_cpu(c); }
[ "void", "smp_store_cpu_info", "(", "int", "id", ")", "{", "struct", "cpuinfo_x86", "*", "c", "=", "&", "cpu_data", "(", "id", ")", ";", "copy_cpuinfo_x86", "(", "c", ",", "&", "boot_cpu_data", ")", ";", "c", "->", "cpu_index", "=", "id", ";", "if", "(", "id", "!=", "0", ")", "identify_secondary_cpu", "(", "c", ")", ";", "}" ]
The bootstrap kernel entry code has set these up.
[ "The", "bootstrap", "kernel", "entry", "code", "has", "set", "these", "up", "." ]
[]
[ { "param": "id", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "id", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6d6dfc3e8961b330d8d3d02dd8d1c396912c5fd7
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/arch/x86/kernel/smpboot.c
[ "Apache-2.0" ]
C
wakeup_secondary_cpu_via_nmi
int
int wakeup_secondary_cpu_via_nmi(int logical_apicid, unsigned long start_eip) { unsigned long send_status, accept_status = 0; int maxlvt; /* Target chip */ /* Boot on the stack */ /* Kick the second */ apic_icr_write(APIC_DM_NMI | apic->dest_logical, logical_apicid); pr_debug("Waiting for send to finish...\n"); send_status = safe_apic_wait_icr_idle(); /* * Give the other CPU some time to accept the IPI. */ udelay(200); if (APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid])) { maxlvt = lapic_get_maxlvt(); if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */ apic_write(APIC_ESR, 0); accept_status = (apic_read(APIC_ESR) & 0xEF); } pr_debug("NMI sent.\n"); if (send_status) printk("APIC never delivered???\n"); if (accept_status) printk( "APIC delivery error (%lx).\n", accept_status); return (send_status | accept_status); }
/* * Poke the other CPU in the eye via NMI to wake it up. Remember that the normal * INIT, INIT, STARTUP sequence will reset the chip hard for us, and this * won't ... remember to clear down the APIC, etc later. */
Poke the other CPU in the eye via NMI to wake it up. Remember that the normal INIT, INIT, STARTUP sequence will reset the chip hard for us, and this won't ... remember to clear down the APIC, etc later.
[ "Poke", "the", "other", "CPU", "in", "the", "eye", "via", "NMI", "to", "wake", "it", "up", ".", "Remember", "that", "the", "normal", "INIT", "INIT", "STARTUP", "sequence", "will", "reset", "the", "chip", "hard", "for", "us", "and", "this", "won", "'", "t", "...", "remember", "to", "clear", "down", "the", "APIC", "etc", "later", "." ]
int wakeup_secondary_cpu_via_nmi(int logical_apicid, unsigned long start_eip) { unsigned long send_status, accept_status = 0; int maxlvt; apic_icr_write(APIC_DM_NMI | apic->dest_logical, logical_apicid); pr_debug("Waiting for send to finish...\n"); send_status = safe_apic_wait_icr_idle(); udelay(200); if (APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid])) { maxlvt = lapic_get_maxlvt(); if (maxlvt > 3) apic_write(APIC_ESR, 0); accept_status = (apic_read(APIC_ESR) & 0xEF); } pr_debug("NMI sent.\n"); if (send_status) printk("APIC never delivered???\n"); if (accept_status) printk( "APIC delivery error (%lx).\n", accept_status); return (send_status | accept_status); }
[ "int", "wakeup_secondary_cpu_via_nmi", "(", "int", "logical_apicid", ",", "unsigned", "long", "start_eip", ")", "{", "unsigned", "long", "send_status", ",", "accept_status", "=", "0", ";", "int", "maxlvt", ";", "apic_icr_write", "(", "APIC_DM_NMI", "|", "apic", "->", "dest_logical", ",", "logical_apicid", ")", ";", "pr_debug", "(", "\"", "\\n", "\"", ")", ";", "send_status", "=", "safe_apic_wait_icr_idle", "(", ")", ";", "udelay", "(", "200", ")", ";", "if", "(", "APIC_INTEGRATED", "(", "apic_version", "[", "boot_cpu_physical_apicid", "]", ")", ")", "{", "maxlvt", "=", "lapic_get_maxlvt", "(", ")", ";", "if", "(", "maxlvt", ">", "3", ")", "apic_write", "(", "APIC_ESR", ",", "0", ")", ";", "accept_status", "=", "(", "apic_read", "(", "APIC_ESR", ")", "&", "0xEF", ")", ";", "}", "pr_debug", "(", "\"", "\\n", "\"", ")", ";", "if", "(", "send_status", ")", "printk", "(", "\"", "\\n", "\"", ")", ";", "if", "(", "accept_status", ")", "printk", "(", "\"", "\\n", "\"", ",", "accept_status", ")", ";", "return", "(", "send_status", "|", "accept_status", ")", ";", "}" ]
Poke the other CPU in the eye via NMI to wake it up.
[ "Poke", "the", "other", "CPU", "in", "the", "eye", "via", "NMI", "to", "wake", "it", "up", "." ]
[ "/* Target chip */", "/* Boot on the stack */", "/* Kick the second */", "/*\n\t * Give the other CPU some time to accept the IPI.\n\t */", "/* Due to the Pentium erratum 3AP. */" ]
[ { "param": "logical_apicid", "type": "int" }, { "param": "start_eip", "type": "unsigned long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "logical_apicid", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "start_eip", "type": "unsigned long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6d6dfc3e8961b330d8d3d02dd8d1c396912c5fd7
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/arch/x86/kernel/smpboot.c
[ "Apache-2.0" ]
C
do_boot_cpu
int
static int do_boot_cpu(int apicid, int cpu) { unsigned long boot_error = 0; unsigned long start_ip; int timeout; INIT_WORK_ON_STACK(&c_idle.work, do_fork_idle); alternatives_smp_switch(1); c_idle.idle = get_idle_for_cpu(cpu); /* * We can't use kernel_thread since we must avoid to * reschedule the child. */ if (c_idle.idle) { c_idle.idle->thread.sp = (unsigned long) (((struct pt_regs *) (THREAD_SIZE + task_stack_page(c_idle.idle))) - 1); init_idle(c_idle.idle, cpu); goto do_rest; } if (!keventd_up() || current_is_keventd()) c_idle.work.func(&c_idle.work); else { schedule_work(&c_idle.work); wait_for_completion(&c_idle.done); } if (IS_ERR(c_idle.idle)) { printk("failed fork for CPU %d\n", cpu); destroy_work_on_stack(&c_idle.work); return PTR_ERR(c_idle.idle); } set_idle_for_cpu(cpu, c_idle.idle); do_rest: per_cpu(current_task, cpu) = c_idle.idle; #ifdef X86_32 /* Stack for startup_32 can be just as for start_secondary onwards */ irq_ctx_init(cpu); #else clear_tsk_thread_flag(c_idle.idle, TIF_FORK); initial_gs = per_cpu_offset(cpu); per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(c_idle.idle) - KERNEL_STACK_OFFSET + THREAD_SIZE; #endif early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu); initial_code = (unsigned long)start_secondary; stack_start.sp = (void *) c_idle.idle->thread.sp; /* start_ip had better be page-aligned! */ start_ip = setup_trampoline(); /* So we see what's up */ announce_cpu(cpu, apicid); /* * This grunge runs the startup process for * the targeted processor. */ atomic_set(&init_deasserted, 0); if (get_uv_system_type() != UV_NON_UNIQUE_APIC) { pr_debug("Setting warm reset code and vector.\n"); smpboot_setup_warm_reset_vector(start_ip); /* * Be paranoid about clearing APIC errors. */ if (APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid])) { apic_write(APIC_ESR, 0); apic_read(APIC_ESR); } } /* * Kick the secondary CPU. Use the method in the APIC driver * if it's defined - or use an INIT boot APIC message otherwise: */ if (apic->wakeup_secondary_cpu) boot_error = apic->wakeup_secondary_cpu(apicid, start_ip); else boot_error = wakeup_secondary_cpu_via_init(apicid, start_ip); if (!boot_error) { /* * allow APs to start initializing. */ pr_debug("Before Callout %d.\n", cpu); cpumask_set_cpu(cpu, cpu_callout_mask); pr_debug("After Callout %d.\n", cpu); /* * Wait 5s total for a response */ for (timeout = 0; timeout < 50000; timeout++) { if (cpumask_test_cpu(cpu, cpu_callin_mask)) break; /* It has booted */ udelay(100); } if (cpumask_test_cpu(cpu, cpu_callin_mask)) pr_debug("CPU%d: has booted.\n", cpu); else { boot_error = 1; if (*((volatile unsigned char *)trampoline_base) == 0xA5) /* trampoline started but...? */ pr_err("CPU%d: Stuck ??\n", cpu); else /* trampoline code not run */ pr_err("CPU%d: Not responding.\n", cpu); if (apic->inquire_remote_apic) apic->inquire_remote_apic(apicid); } } if (boot_error) { /* Try to put things back the way they were before ... */ numa_remove_cpu(cpu); /* was set by numa_add_cpu */ /* was set by do_boot_cpu() */ cpumask_clear_cpu(cpu, cpu_callout_mask); /* was set by cpu_init() */ cpumask_clear_cpu(cpu, cpu_initialized_mask); set_cpu_present(cpu, false); per_cpu(x86_cpu_to_apicid, cpu) = BAD_APICID; } /* mark "stuck" area as not stuck */ *((volatile unsigned long *)trampoline_base) = 0; if (get_uv_system_type() != UV_NON_UNIQUE_APIC) { /* * Cleanup possible dangling ends... */ smpboot_restore_warm_reset_vector(); } destroy_work_on_stack(&c_idle.work); return boot_error; }
/* * NOTE - on most systems this is a PHYSICAL apic ID, but on multiquad * (ie clustered apic addressing mode), this is a LOGICAL apic ID. * Returns zero if CPU booted OK, else error code from * ->wakeup_secondary_cpu. */
on most systems this is a PHYSICAL apic ID, but on multiquad , this is a LOGICAL apic ID. Returns zero if CPU booted OK, else error code from ->wakeup_secondary_cpu.
[ "on", "most", "systems", "this", "is", "a", "PHYSICAL", "apic", "ID", "but", "on", "multiquad", "this", "is", "a", "LOGICAL", "apic", "ID", ".", "Returns", "zero", "if", "CPU", "booted", "OK", "else", "error", "code", "from", "-", ">", "wakeup_secondary_cpu", "." ]
static int do_boot_cpu(int apicid, int cpu) { unsigned long boot_error = 0; unsigned long start_ip; int timeout; INIT_WORK_ON_STACK(&c_idle.work, do_fork_idle); alternatives_smp_switch(1); c_idle.idle = get_idle_for_cpu(cpu); if (c_idle.idle) { c_idle.idle->thread.sp = (unsigned long) (((struct pt_regs *) (THREAD_SIZE + task_stack_page(c_idle.idle))) - 1); init_idle(c_idle.idle, cpu); goto do_rest; } if (!keventd_up() || current_is_keventd()) c_idle.work.func(&c_idle.work); else { schedule_work(&c_idle.work); wait_for_completion(&c_idle.done); } if (IS_ERR(c_idle.idle)) { printk("failed fork for CPU %d\n", cpu); destroy_work_on_stack(&c_idle.work); return PTR_ERR(c_idle.idle); } set_idle_for_cpu(cpu, c_idle.idle); do_rest: per_cpu(current_task, cpu) = c_idle.idle; #ifdef X86_32 irq_ctx_init(cpu); #else clear_tsk_thread_flag(c_idle.idle, TIF_FORK); initial_gs = per_cpu_offset(cpu); per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(c_idle.idle) - KERNEL_STACK_OFFSET + THREAD_SIZE; #endif early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu); initial_code = (unsigned long)start_secondary; stack_start.sp = (void *) c_idle.idle->thread.sp; start_ip = setup_trampoline(); announce_cpu(cpu, apicid); atomic_set(&init_deasserted, 0); if (get_uv_system_type() != UV_NON_UNIQUE_APIC) { pr_debug("Setting warm reset code and vector.\n"); smpboot_setup_warm_reset_vector(start_ip); if (APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid])) { apic_write(APIC_ESR, 0); apic_read(APIC_ESR); } } if (apic->wakeup_secondary_cpu) boot_error = apic->wakeup_secondary_cpu(apicid, start_ip); else boot_error = wakeup_secondary_cpu_via_init(apicid, start_ip); if (!boot_error) { pr_debug("Before Callout %d.\n", cpu); cpumask_set_cpu(cpu, cpu_callout_mask); pr_debug("After Callout %d.\n", cpu); for (timeout = 0; timeout < 50000; timeout++) { if (cpumask_test_cpu(cpu, cpu_callin_mask)) break; udelay(100); } if (cpumask_test_cpu(cpu, cpu_callin_mask)) pr_debug("CPU%d: has booted.\n", cpu); else { boot_error = 1; if (*((volatile unsigned char *)trampoline_base) == 0xA5) pr_err("CPU%d: Stuck ??\n", cpu); else pr_err("CPU%d: Not responding.\n", cpu); if (apic->inquire_remote_apic) apic->inquire_remote_apic(apicid); } } if (boot_error) { numa_remove_cpu(cpu); cpumask_clear_cpu(cpu, cpu_callout_mask); cpumask_clear_cpu(cpu, cpu_initialized_mask); set_cpu_present(cpu, false); per_cpu(x86_cpu_to_apicid, cpu) = BAD_APICID; } *((volatile unsigned long *)trampoline_base) = 0; if (get_uv_system_type() != UV_NON_UNIQUE_APIC) { smpboot_restore_warm_reset_vector(); } destroy_work_on_stack(&c_idle.work); return boot_error; }
[ "static", "int", "do_boot_cpu", "(", "int", "apicid", ",", "int", "cpu", ")", "{", "unsigned", "long", "boot_error", "=", "0", ";", "unsigned", "long", "start_ip", ";", "int", "timeout", ";", "INIT_WORK_ON_STACK", "(", "&", "c_idle", ".", "work", ",", "do_fork_idle", ")", ";", "alternatives_smp_switch", "(", "1", ")", ";", "c_idle", ".", "idle", "=", "get_idle_for_cpu", "(", "cpu", ")", ";", "if", "(", "c_idle", ".", "idle", ")", "{", "c_idle", ".", "idle", "->", "thread", ".", "sp", "=", "(", "unsigned", "long", ")", "(", "(", "(", "struct", "pt_regs", "*", ")", "(", "THREAD_SIZE", "+", "task_stack_page", "(", "c_idle", ".", "idle", ")", ")", ")", "-", "1", ")", ";", "init_idle", "(", "c_idle", ".", "idle", ",", "cpu", ")", ";", "goto", "do_rest", ";", "}", "if", "(", "!", "keventd_up", "(", ")", "||", "current_is_keventd", "(", ")", ")", "c_idle", ".", "work", ".", "func", "(", "&", "c_idle", ".", "work", ")", ";", "else", "{", "schedule_work", "(", "&", "c_idle", ".", "work", ")", ";", "wait_for_completion", "(", "&", "c_idle", ".", "done", ")", ";", "}", "if", "(", "IS_ERR", "(", "c_idle", ".", "idle", ")", ")", "{", "printk", "(", "\"", "\\n", "\"", ",", "cpu", ")", ";", "destroy_work_on_stack", "(", "&", "c_idle", ".", "work", ")", ";", "return", "PTR_ERR", "(", "c_idle", ".", "idle", ")", ";", "}", "set_idle_for_cpu", "(", "cpu", ",", "c_idle", ".", "idle", ")", ";", "do_rest", ":", "per_cpu", "(", "current_task", ",", "cpu", ")", "=", "c_idle", ".", "idle", ";", "#ifdef", "X86_32", "irq_ctx_init", "(", "cpu", ")", ";", "#else", "clear_tsk_thread_flag", "(", "c_idle", ".", "idle", ",", "TIF_FORK", ")", ";", "initial_gs", "=", "per_cpu_offset", "(", "cpu", ")", ";", "per_cpu", "(", "kernel_stack", ",", "cpu", ")", "=", "(", "unsigned", "long", ")", "task_stack_page", "(", "c_idle", ".", "idle", ")", "-", "KERNEL_STACK_OFFSET", "+", "THREAD_SIZE", ";", "#endif", "early_gdt_descr", ".", "address", "=", "(", "unsigned", "long", ")", "get_cpu_gdt_table", "(", "cpu", ")", ";", "initial_code", "=", "(", "unsigned", "long", ")", "start_secondary", ";", "stack_start", ".", "sp", "=", "(", "void", "*", ")", "c_idle", ".", "idle", "->", "thread", ".", "sp", ";", "start_ip", "=", "setup_trampoline", "(", ")", ";", "announce_cpu", "(", "cpu", ",", "apicid", ")", ";", "atomic_set", "(", "&", "init_deasserted", ",", "0", ")", ";", "if", "(", "get_uv_system_type", "(", ")", "!=", "UV_NON_UNIQUE_APIC", ")", "{", "pr_debug", "(", "\"", "\\n", "\"", ")", ";", "smpboot_setup_warm_reset_vector", "(", "start_ip", ")", ";", "if", "(", "APIC_INTEGRATED", "(", "apic_version", "[", "boot_cpu_physical_apicid", "]", ")", ")", "{", "apic_write", "(", "APIC_ESR", ",", "0", ")", ";", "apic_read", "(", "APIC_ESR", ")", ";", "}", "}", "if", "(", "apic", "->", "wakeup_secondary_cpu", ")", "boot_error", "=", "apic", "->", "wakeup_secondary_cpu", "(", "apicid", ",", "start_ip", ")", ";", "else", "boot_error", "=", "wakeup_secondary_cpu_via_init", "(", "apicid", ",", "start_ip", ")", ";", "if", "(", "!", "boot_error", ")", "{", "pr_debug", "(", "\"", "\\n", "\"", ",", "cpu", ")", ";", "cpumask_set_cpu", "(", "cpu", ",", "cpu_callout_mask", ")", ";", "pr_debug", "(", "\"", "\\n", "\"", ",", "cpu", ")", ";", "for", "(", "timeout", "=", "0", ";", "timeout", "<", "50000", ";", "timeout", "++", ")", "{", "if", "(", "cpumask_test_cpu", "(", "cpu", ",", "cpu_callin_mask", ")", ")", "break", ";", "udelay", "(", "100", ")", ";", "}", "if", "(", "cpumask_test_cpu", "(", "cpu", ",", "cpu_callin_mask", ")", ")", "pr_debug", "(", "\"", "\\n", "\"", ",", "cpu", ")", ";", "else", "{", "boot_error", "=", "1", ";", "if", "(", "*", "(", "(", "volatile", "unsigned", "char", "*", ")", "trampoline_base", ")", "==", "0xA5", ")", "pr_err", "(", "\"", "\\n", "\"", ",", "cpu", ")", ";", "else", "pr_err", "(", "\"", "\\n", "\"", ",", "cpu", ")", ";", "if", "(", "apic", "->", "inquire_remote_apic", ")", "apic", "->", "inquire_remote_apic", "(", "apicid", ")", ";", "}", "}", "if", "(", "boot_error", ")", "{", "numa_remove_cpu", "(", "cpu", ")", ";", "cpumask_clear_cpu", "(", "cpu", ",", "cpu_callout_mask", ")", ";", "cpumask_clear_cpu", "(", "cpu", ",", "cpu_initialized_mask", ")", ";", "set_cpu_present", "(", "cpu", ",", "false", ")", ";", "per_cpu", "(", "x86_cpu_to_apicid", ",", "cpu", ")", "=", "BAD_APICID", ";", "}", "*", "(", "(", "volatile", "unsigned", "long", "*", ")", "trampoline_base", ")", "=", "0", ";", "if", "(", "get_uv_system_type", "(", ")", "!=", "UV_NON_UNIQUE_APIC", ")", "{", "smpboot_restore_warm_reset_vector", "(", ")", ";", "}", "destroy_work_on_stack", "(", "&", "c_idle", ".", "work", ")", ";", "return", "boot_error", ";", "}" ]
NOTE - on most systems this is a PHYSICAL apic ID, but on multiquad (ie clustered apic addressing mode), this is a LOGICAL apic ID.
[ "NOTE", "-", "on", "most", "systems", "this", "is", "a", "PHYSICAL", "apic", "ID", "but", "on", "multiquad", "(", "ie", "clustered", "apic", "addressing", "mode", ")", "this", "is", "a", "LOGICAL", "apic", "ID", "." ]
[ "/*\n\t * We can't use kernel_thread since we must avoid to\n\t * reschedule the child.\n\t */", "/* Stack for startup_32 can be just as for start_secondary onwards */", "/* start_ip had better be page-aligned! */", "/* So we see what's up */", "/*\n\t * This grunge runs the startup process for\n\t * the targeted processor.\n\t */", "/*\n\t\t * Be paranoid about clearing APIC errors.\n\t\t*/", "/*\n\t * Kick the secondary CPU. Use the method in the APIC driver\n\t * if it's defined - or use an INIT boot APIC message otherwise:\n\t */", "/*\n\t\t * allow APs to start initializing.\n\t\t */", "/*\n\t\t * Wait 5s total for a response\n\t\t */", "/* It has booted */", "/* trampoline started but...? */", "/* trampoline code not run */", "/* Try to put things back the way they were before ... */", "/* was set by numa_add_cpu */", "/* was set by do_boot_cpu() */", "/* was set by cpu_init() */", "/* mark \"stuck\" area as not stuck */", "/*\n\t\t * Cleanup possible dangling ends...\n\t\t */" ]
[ { "param": "apicid", "type": "int" }, { "param": "cpu", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "apicid", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cpu", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6d6dfc3e8961b330d8d3d02dd8d1c396912c5fd7
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/arch/x86/kernel/smpboot.c
[ "Apache-2.0" ]
C
disable_smp
void
static void disable_smp(void) { init_cpu_present(cpumask_of(0)); init_cpu_possible(cpumask_of(0)); smpboot_clear_io_apic_irqs(); if (smp_found_config) physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map); else physid_set_mask_of_physid(0, &phys_cpu_present_map); map_cpu_to_logical_apicid(); cpumask_set_cpu(0, cpu_sibling_mask(0)); cpumask_set_cpu(0, cpu_core_mask(0)); }
/* * Fall back to non SMP mode after errors. * * RED-PEN audit/test this more. I bet there is more state messed up here. */
Fall back to non SMP mode after errors. RED-PEN audit/test this more. I bet there is more state messed up here.
[ "Fall", "back", "to", "non", "SMP", "mode", "after", "errors", ".", "RED", "-", "PEN", "audit", "/", "test", "this", "more", ".", "I", "bet", "there", "is", "more", "state", "messed", "up", "here", "." ]
static void disable_smp(void) { init_cpu_present(cpumask_of(0)); init_cpu_possible(cpumask_of(0)); smpboot_clear_io_apic_irqs(); if (smp_found_config) physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map); else physid_set_mask_of_physid(0, &phys_cpu_present_map); map_cpu_to_logical_apicid(); cpumask_set_cpu(0, cpu_sibling_mask(0)); cpumask_set_cpu(0, cpu_core_mask(0)); }
[ "static", "void", "disable_smp", "(", "void", ")", "{", "init_cpu_present", "(", "cpumask_of", "(", "0", ")", ")", ";", "init_cpu_possible", "(", "cpumask_of", "(", "0", ")", ")", ";", "smpboot_clear_io_apic_irqs", "(", ")", ";", "if", "(", "smp_found_config", ")", "physid_set_mask_of_physid", "(", "boot_cpu_physical_apicid", ",", "&", "phys_cpu_present_map", ")", ";", "else", "physid_set_mask_of_physid", "(", "0", ",", "&", "phys_cpu_present_map", ")", ";", "map_cpu_to_logical_apicid", "(", ")", ";", "cpumask_set_cpu", "(", "0", ",", "cpu_sibling_mask", "(", "0", ")", ")", ";", "cpumask_set_cpu", "(", "0", ",", "cpu_core_mask", "(", "0", ")", ")", ";", "}" ]
Fall back to non SMP mode after errors.
[ "Fall", "back", "to", "non", "SMP", "mode", "after", "errors", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
6d6dfc3e8961b330d8d3d02dd8d1c396912c5fd7
Gu-Youngfeng/TenSamplingStudy2
bugs/linux/arch/x86/kernel/smpboot.c
[ "Apache-2.0" ]
C
native_smp_prepare_cpus
void
void native_smp_prepare_cpus(unsigned int max_cpus) { unsigned int i; preempt_disable(); smp_cpu_index_default(); current_cpu_data = boot_cpu_data; cpumask_copy(cpu_callin_mask, cpumask_of(0)); mb(); /* * Setup boot CPU information */ smp_store_cpu_info(0); /* Final full version of the data */ #ifdef X86_32 boot_cpu_logical_apicid = logical_smp_processor_id(); #endif current_thread_info()->cpu = 0; /* needed? */ for_each_possible_cpu(i) { zalloc_cpumask_var(&per_cpu(cpu_sibling_map, i), GFP_KERNEL); zalloc_cpumask_var(&per_cpu(cpu_core_map, i), GFP_KERNEL); zalloc_cpumask_var(&cpu_data(i).llc_shared_map, GFP_KERNEL); } set_cpu_sibling_map(0); enable_IR_x2apic(); default_setup_apic_routing(); if (smp_sanity_check(max_cpus) < 0) { printk( "SMP disabled\n"); disable_smp(); goto out; } preempt_disable(); if (read_apic_id() != boot_cpu_physical_apicid) { panic("Boot APIC ID in local APIC unexpected (%d vs %d)", read_apic_id(), boot_cpu_physical_apicid); /* Or can we switch back to PIC here? */ } preempt_enable(); connect_bsp_APIC(); /* * Switch from PIC to APIC mode. */ setup_local_APIC(); /* * Enable IO APIC before setting up error vector */ if (!skip_ioapic_setup && nr_ioapics) enable_IO_APIC(); end_local_APIC_setup(); map_cpu_to_logical_apicid(); if (apic->setup_portio_remap) apic->setup_portio_remap(); smpboot_setup_io_apic(); /* * Set up local APIC timer on boot CPU. */ printk( "CPU%d: ", 0); print_cpu_info(&cpu_data(0)); x86_init.timers.setup_percpu_clockev(); if (is_uv_system()) uv_system_init(); set_mtrr_aps_delayed_init(); out: preempt_enable(); }
/* * Prepare for SMP bootup. The MP table or ACPI has been read * earlier. Just do some sanity checking here and enable APIC mode. */
Prepare for SMP bootup. The MP table or ACPI has been read earlier. Just do some sanity checking here and enable APIC mode.
[ "Prepare", "for", "SMP", "bootup", ".", "The", "MP", "table", "or", "ACPI", "has", "been", "read", "earlier", ".", "Just", "do", "some", "sanity", "checking", "here", "and", "enable", "APIC", "mode", "." ]
void native_smp_prepare_cpus(unsigned int max_cpus) { unsigned int i; preempt_disable(); smp_cpu_index_default(); current_cpu_data = boot_cpu_data; cpumask_copy(cpu_callin_mask, cpumask_of(0)); mb(); smp_store_cpu_info(0); #ifdef X86_32 boot_cpu_logical_apicid = logical_smp_processor_id(); #endif current_thread_info()->cpu = 0; for_each_possible_cpu(i) { zalloc_cpumask_var(&per_cpu(cpu_sibling_map, i), GFP_KERNEL); zalloc_cpumask_var(&per_cpu(cpu_core_map, i), GFP_KERNEL); zalloc_cpumask_var(&cpu_data(i).llc_shared_map, GFP_KERNEL); } set_cpu_sibling_map(0); enable_IR_x2apic(); default_setup_apic_routing(); if (smp_sanity_check(max_cpus) < 0) { printk( "SMP disabled\n"); disable_smp(); goto out; } preempt_disable(); if (read_apic_id() != boot_cpu_physical_apicid) { panic("Boot APIC ID in local APIC unexpected (%d vs %d)", read_apic_id(), boot_cpu_physical_apicid); } preempt_enable(); connect_bsp_APIC(); setup_local_APIC(); if (!skip_ioapic_setup && nr_ioapics) enable_IO_APIC(); end_local_APIC_setup(); map_cpu_to_logical_apicid(); if (apic->setup_portio_remap) apic->setup_portio_remap(); smpboot_setup_io_apic(); printk( "CPU%d: ", 0); print_cpu_info(&cpu_data(0)); x86_init.timers.setup_percpu_clockev(); if (is_uv_system()) uv_system_init(); set_mtrr_aps_delayed_init(); out: preempt_enable(); }
[ "void", "native_smp_prepare_cpus", "(", "unsigned", "int", "max_cpus", ")", "{", "unsigned", "int", "i", ";", "preempt_disable", "(", ")", ";", "smp_cpu_index_default", "(", ")", ";", "current_cpu_data", "=", "boot_cpu_data", ";", "cpumask_copy", "(", "cpu_callin_mask", ",", "cpumask_of", "(", "0", ")", ")", ";", "mb", "(", ")", ";", "smp_store_cpu_info", "(", "0", ")", ";", "#ifdef", "X86_32", "boot_cpu_logical_apicid", "=", "logical_smp_processor_id", "(", ")", ";", "#endif", "current_thread_info", "(", ")", "->", "cpu", "=", "0", ";", "for_each_possible_cpu", "(", "i", ")", "{", "zalloc_cpumask_var", "(", "&", "per_cpu", "(", "cpu_sibling_map", ",", "i", ")", ",", "GFP_KERNEL", ")", ";", "zalloc_cpumask_var", "(", "&", "per_cpu", "(", "cpu_core_map", ",", "i", ")", ",", "GFP_KERNEL", ")", ";", "zalloc_cpumask_var", "(", "&", "cpu_data", "(", "i", ")", ".", "llc_shared_map", ",", "GFP_KERNEL", ")", ";", "}", "set_cpu_sibling_map", "(", "0", ")", ";", "enable_IR_x2apic", "(", ")", ";", "default_setup_apic_routing", "(", ")", ";", "if", "(", "smp_sanity_check", "(", "max_cpus", ")", "<", "0", ")", "{", "printk", "(", "\"", "\\n", "\"", ")", ";", "disable_smp", "(", ")", ";", "goto", "out", ";", "}", "preempt_disable", "(", ")", ";", "if", "(", "read_apic_id", "(", ")", "!=", "boot_cpu_physical_apicid", ")", "{", "panic", "(", "\"", "\"", ",", "read_apic_id", "(", ")", ",", "boot_cpu_physical_apicid", ")", ";", "}", "preempt_enable", "(", ")", ";", "connect_bsp_APIC", "(", ")", ";", "setup_local_APIC", "(", ")", ";", "if", "(", "!", "skip_ioapic_setup", "&&", "nr_ioapics", ")", "enable_IO_APIC", "(", ")", ";", "end_local_APIC_setup", "(", ")", ";", "map_cpu_to_logical_apicid", "(", ")", ";", "if", "(", "apic", "->", "setup_portio_remap", ")", "apic", "->", "setup_portio_remap", "(", ")", ";", "smpboot_setup_io_apic", "(", ")", ";", "printk", "(", "\"", "\"", ",", "0", ")", ";", "print_cpu_info", "(", "&", "cpu_data", "(", "0", ")", ")", ";", "x86_init", ".", "timers", ".", "setup_percpu_clockev", "(", ")", ";", "if", "(", "is_uv_system", "(", ")", ")", "uv_system_init", "(", ")", ";", "set_mtrr_aps_delayed_init", "(", ")", ";", "out", ":", "preempt_enable", "(", ")", ";", "}" ]
Prepare for SMP bootup.
[ "Prepare", "for", "SMP", "bootup", "." ]
[ "/*\n\t * Setup boot CPU information\n\t */", "/* Final full version of the data */", "/* needed? */", "/* Or can we switch back to PIC here? */", "/*\n\t * Switch from PIC to APIC mode.\n\t */", "/*\n\t * Enable IO APIC before setting up error vector\n\t */", "/*\n\t * Set up local APIC timer on boot CPU.\n\t */" ]
[ { "param": "max_cpus", "type": "unsigned int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "max_cpus", "type": "unsigned int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ef90545efcf381d9d10d9a5ce20ff1b5e76edfdd
cryptomilk/SVT-AV1
Source/Lib/Encoder/Codec/EbTransforms.c
[ "BSD-2-Clause" ]
C
av1_estimate_transform
EbErrorType
EbErrorType av1_estimate_transform(int16_t *residual_buffer, uint32_t residual_stride, int32_t *coeff_buffer, uint32_t coeff_stride, TxSize transform_size, uint64_t *three_quad_energy, uint32_t bit_depth, TxType transform_type, PlaneType component_type, EB_TRANS_COEFF_SHAPE trans_coeff_shape) { (void)trans_coeff_shape; EbErrorType return_error = EB_ErrorNone; (void)coeff_stride; (void)component_type; switch (transform_size) { case TX_64X32: if (transform_type == DCT_DCT) svt_av1_fwd_txfm2d_64x32( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); else svt_av1_fwd_txfm2d_64x32_c( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); *three_quad_energy = svt_handle_transform64x32(coeff_buffer); break; case TX_32X64: if (transform_type == DCT_DCT) svt_av1_fwd_txfm2d_32x64( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); else svt_av1_fwd_txfm2d_32x64_c( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); *three_quad_energy = svt_handle_transform32x64(coeff_buffer); break; case TX_64X16: if (transform_type == DCT_DCT) svt_av1_fwd_txfm2d_64x16( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); else svt_av1_fwd_txfm2d_64x16_c( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); *three_quad_energy = svt_handle_transform64x16(coeff_buffer); break; case TX_16X64: if (transform_type == DCT_DCT) svt_av1_fwd_txfm2d_16x64( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); else svt_av1_fwd_txfm2d_16x64_c( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); *three_quad_energy = svt_handle_transform16x64(coeff_buffer); break; case TX_32X16: // TTK if ((transform_type == DCT_DCT) || (transform_type == IDTX)) svt_av1_fwd_txfm2d_32x16( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); else svt_av1_fwd_txfm2d_32x16_c( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_16X32: if ((transform_type == DCT_DCT) || (transform_type == IDTX)) svt_av1_fwd_txfm2d_16x32( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); else svt_av1_fwd_txfm2d_16x32_c( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_16X8: svt_av1_fwd_txfm2d_16x8( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_8X16: svt_av1_fwd_txfm2d_8x16( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_32X8: if ((transform_type == DCT_DCT) || (transform_type == IDTX)) svt_av1_fwd_txfm2d_32x8( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); else svt_av1_fwd_txfm2d_32x8_c( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_8X32: if ((transform_type == DCT_DCT) || (transform_type == IDTX)) svt_av1_fwd_txfm2d_8x32( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); else svt_av1_fwd_txfm2d_8x32_c( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_16X4: svt_av1_fwd_txfm2d_16x4( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_4X16: svt_av1_fwd_txfm2d_4x16( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_8X4: svt_av1_fwd_txfm2d_8x4( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_4X8: svt_av1_fwd_txfm2d_4x8( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_64X64: svt_av1_fwd_txfm2d_64x64( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); *three_quad_energy = svt_handle_transform64x64(coeff_buffer); break; case TX_32X32: if (transform_type == V_DCT || transform_type == H_DCT || transform_type == V_ADST || transform_type == H_ADST || transform_type == V_FLIPADST || transform_type == H_FLIPADST) // Tahani: I believe those cases are never hit svt_av1_transform_two_d_32x32_c( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); else { svt_av1_fwd_txfm2d_32x32( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); } break; case TX_16X16: svt_av1_fwd_txfm2d_16x16( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_8X8: svt_av1_fwd_txfm2d_8x8( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_4X4: svt_av1_fwd_txfm2d_4x4( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; default: assert(0); break; } return return_error; }
/********************************************************************* * Transform * Note there is an implicit assumption that TU Size <= PU Size, * which is different than the HEVC requirements. *********************************************************************/
Transform Note there is an implicit assumption that TU Size <= PU Size, which is different than the HEVC requirements.
[ "Transform", "Note", "there", "is", "an", "implicit", "assumption", "that", "TU", "Size", "<", "=", "PU", "Size", "which", "is", "different", "than", "the", "HEVC", "requirements", "." ]
EbErrorType av1_estimate_transform(int16_t *residual_buffer, uint32_t residual_stride, int32_t *coeff_buffer, uint32_t coeff_stride, TxSize transform_size, uint64_t *three_quad_energy, uint32_t bit_depth, TxType transform_type, PlaneType component_type, EB_TRANS_COEFF_SHAPE trans_coeff_shape) { (void)trans_coeff_shape; EbErrorType return_error = EB_ErrorNone; (void)coeff_stride; (void)component_type; switch (transform_size) { case TX_64X32: if (transform_type == DCT_DCT) svt_av1_fwd_txfm2d_64x32( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); else svt_av1_fwd_txfm2d_64x32_c( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); *three_quad_energy = svt_handle_transform64x32(coeff_buffer); break; case TX_32X64: if (transform_type == DCT_DCT) svt_av1_fwd_txfm2d_32x64( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); else svt_av1_fwd_txfm2d_32x64_c( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); *three_quad_energy = svt_handle_transform32x64(coeff_buffer); break; case TX_64X16: if (transform_type == DCT_DCT) svt_av1_fwd_txfm2d_64x16( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); else svt_av1_fwd_txfm2d_64x16_c( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); *three_quad_energy = svt_handle_transform64x16(coeff_buffer); break; case TX_16X64: if (transform_type == DCT_DCT) svt_av1_fwd_txfm2d_16x64( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); else svt_av1_fwd_txfm2d_16x64_c( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); *three_quad_energy = svt_handle_transform16x64(coeff_buffer); break; case TX_32X16: if ((transform_type == DCT_DCT) || (transform_type == IDTX)) svt_av1_fwd_txfm2d_32x16( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); else svt_av1_fwd_txfm2d_32x16_c( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_16X32: if ((transform_type == DCT_DCT) || (transform_type == IDTX)) svt_av1_fwd_txfm2d_16x32( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); else svt_av1_fwd_txfm2d_16x32_c( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_16X8: svt_av1_fwd_txfm2d_16x8( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_8X16: svt_av1_fwd_txfm2d_8x16( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_32X8: if ((transform_type == DCT_DCT) || (transform_type == IDTX)) svt_av1_fwd_txfm2d_32x8( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); else svt_av1_fwd_txfm2d_32x8_c( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_8X32: if ((transform_type == DCT_DCT) || (transform_type == IDTX)) svt_av1_fwd_txfm2d_8x32( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); else svt_av1_fwd_txfm2d_8x32_c( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_16X4: svt_av1_fwd_txfm2d_16x4( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_4X16: svt_av1_fwd_txfm2d_4x16( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_8X4: svt_av1_fwd_txfm2d_8x4( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_4X8: svt_av1_fwd_txfm2d_4x8( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_64X64: svt_av1_fwd_txfm2d_64x64( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); *three_quad_energy = svt_handle_transform64x64(coeff_buffer); break; case TX_32X32: if (transform_type == V_DCT || transform_type == H_DCT || transform_type == V_ADST || transform_type == H_ADST || transform_type == V_FLIPADST || transform_type == H_FLIPADST) svt_av1_transform_two_d_32x32_c( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); else { svt_av1_fwd_txfm2d_32x32( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); } break; case TX_16X16: svt_av1_fwd_txfm2d_16x16( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_8X8: svt_av1_fwd_txfm2d_8x8( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; case TX_4X4: svt_av1_fwd_txfm2d_4x4( residual_buffer, coeff_buffer, residual_stride, transform_type, bit_depth); break; default: assert(0); break; } return return_error; }
[ "EbErrorType", "av1_estimate_transform", "(", "int16_t", "*", "residual_buffer", ",", "uint32_t", "residual_stride", ",", "int32_t", "*", "coeff_buffer", ",", "uint32_t", "coeff_stride", ",", "TxSize", "transform_size", ",", "uint64_t", "*", "three_quad_energy", ",", "uint32_t", "bit_depth", ",", "TxType", "transform_type", ",", "PlaneType", "component_type", ",", "EB_TRANS_COEFF_SHAPE", "trans_coeff_shape", ")", "{", "(", "void", ")", "trans_coeff_shape", ";", "EbErrorType", "return_error", "=", "EB_ErrorNone", ";", "(", "void", ")", "coeff_stride", ";", "(", "void", ")", "component_type", ";", "switch", "(", "transform_size", ")", "{", "case", "TX_64X32", ":", "if", "(", "transform_type", "==", "DCT_DCT", ")", "svt_av1_fwd_txfm2d_64x32", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "else", "svt_av1_fwd_txfm2d_64x32_c", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "*", "three_quad_energy", "=", "svt_handle_transform64x32", "(", "coeff_buffer", ")", ";", "break", ";", "case", "TX_32X64", ":", "if", "(", "transform_type", "==", "DCT_DCT", ")", "svt_av1_fwd_txfm2d_32x64", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "else", "svt_av1_fwd_txfm2d_32x64_c", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "*", "three_quad_energy", "=", "svt_handle_transform32x64", "(", "coeff_buffer", ")", ";", "break", ";", "case", "TX_64X16", ":", "if", "(", "transform_type", "==", "DCT_DCT", ")", "svt_av1_fwd_txfm2d_64x16", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "else", "svt_av1_fwd_txfm2d_64x16_c", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "*", "three_quad_energy", "=", "svt_handle_transform64x16", "(", "coeff_buffer", ")", ";", "break", ";", "case", "TX_16X64", ":", "if", "(", "transform_type", "==", "DCT_DCT", ")", "svt_av1_fwd_txfm2d_16x64", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "else", "svt_av1_fwd_txfm2d_16x64_c", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "*", "three_quad_energy", "=", "svt_handle_transform16x64", "(", "coeff_buffer", ")", ";", "break", ";", "case", "TX_32X16", ":", "if", "(", "(", "transform_type", "==", "DCT_DCT", ")", "||", "(", "transform_type", "==", "IDTX", ")", ")", "svt_av1_fwd_txfm2d_32x16", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "else", "svt_av1_fwd_txfm2d_32x16_c", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "break", ";", "case", "TX_16X32", ":", "if", "(", "(", "transform_type", "==", "DCT_DCT", ")", "||", "(", "transform_type", "==", "IDTX", ")", ")", "svt_av1_fwd_txfm2d_16x32", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "else", "svt_av1_fwd_txfm2d_16x32_c", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "break", ";", "case", "TX_16X8", ":", "svt_av1_fwd_txfm2d_16x8", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "break", ";", "case", "TX_8X16", ":", "svt_av1_fwd_txfm2d_8x16", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "break", ";", "case", "TX_32X8", ":", "if", "(", "(", "transform_type", "==", "DCT_DCT", ")", "||", "(", "transform_type", "==", "IDTX", ")", ")", "svt_av1_fwd_txfm2d_32x8", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "else", "svt_av1_fwd_txfm2d_32x8_c", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "break", ";", "case", "TX_8X32", ":", "if", "(", "(", "transform_type", "==", "DCT_DCT", ")", "||", "(", "transform_type", "==", "IDTX", ")", ")", "svt_av1_fwd_txfm2d_8x32", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "else", "svt_av1_fwd_txfm2d_8x32_c", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "break", ";", "case", "TX_16X4", ":", "svt_av1_fwd_txfm2d_16x4", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "break", ";", "case", "TX_4X16", ":", "svt_av1_fwd_txfm2d_4x16", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "break", ";", "case", "TX_8X4", ":", "svt_av1_fwd_txfm2d_8x4", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "break", ";", "case", "TX_4X8", ":", "svt_av1_fwd_txfm2d_4x8", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "break", ";", "case", "TX_64X64", ":", "svt_av1_fwd_txfm2d_64x64", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "*", "three_quad_energy", "=", "svt_handle_transform64x64", "(", "coeff_buffer", ")", ";", "break", ";", "case", "TX_32X32", ":", "if", "(", "transform_type", "==", "V_DCT", "||", "transform_type", "==", "H_DCT", "||", "transform_type", "==", "V_ADST", "||", "transform_type", "==", "H_ADST", "||", "transform_type", "==", "V_FLIPADST", "||", "transform_type", "==", "H_FLIPADST", ")", "svt_av1_transform_two_d_32x32_c", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "else", "{", "svt_av1_fwd_txfm2d_32x32", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "}", "break", ";", "case", "TX_16X16", ":", "svt_av1_fwd_txfm2d_16x16", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "break", ";", "case", "TX_8X8", ":", "svt_av1_fwd_txfm2d_8x8", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "break", ";", "case", "TX_4X4", ":", "svt_av1_fwd_txfm2d_4x4", "(", "residual_buffer", ",", "coeff_buffer", ",", "residual_stride", ",", "transform_type", ",", "bit_depth", ")", ";", "break", ";", "default", ":", "assert", "(", "0", ")", ";", "break", ";", "}", "return", "return_error", ";", "}" ]
Transform Note there is an implicit assumption that TU Size <= PU Size, which is different than the HEVC requirements.
[ "Transform", "Note", "there", "is", "an", "implicit", "assumption", "that", "TU", "Size", "<", "=", "PU", "Size", "which", "is", "different", "than", "the", "HEVC", "requirements", "." ]
[ "// TTK", "// Tahani: I believe those cases are never hit" ]
[ { "param": "residual_buffer", "type": "int16_t" }, { "param": "residual_stride", "type": "uint32_t" }, { "param": "coeff_buffer", "type": "int32_t" }, { "param": "coeff_stride", "type": "uint32_t" }, { "param": "transform_size", "type": "TxSize" }, { "param": "three_quad_energy", "type": "uint64_t" }, { "param": "bit_depth", "type": "uint32_t" }, { "param": "transform_type", "type": "TxType" }, { "param": "component_type", "type": "PlaneType" }, { "param": "trans_coeff_shape", "type": "EB_TRANS_COEFF_SHAPE" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "residual_buffer", "type": "int16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "residual_stride", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "coeff_buffer", "type": "int32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "coeff_stride", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "transform_size", "type": "TxSize", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "three_quad_energy", "type": "uint64_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bit_depth", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "transform_type", "type": "TxType", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "component_type", "type": "PlaneType", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "trans_coeff_shape", "type": "EB_TRANS_COEFF_SHAPE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6d65a224de70cf438619f21859dee7cc1fbbbb16
cryptomilk/SVT-AV1
Source/Lib/Encoder/Codec/EbReferenceObject.c
[ "BSD-2-Clause" ]
C
svt_reference_object_ctor
EbErrorType
EbErrorType svt_reference_object_ctor(EbReferenceObject *reference_object, EbPtr object_init_data_ptr) { EbReferenceObjectDescInitData* ref_init_ptr = (EbReferenceObjectDescInitData*)object_init_data_ptr; EbPictureBufferDescInitData *picture_buffer_desc_init_data_ptr = &ref_init_ptr->reference_picture_desc_init_data; EbPictureBufferDescInitData picture_buffer_desc_init_data_16bit_ptr = *picture_buffer_desc_init_data_ptr; reference_object->dctor = svt_reference_object_dctor; //TODO:12bit if (picture_buffer_desc_init_data_16bit_ptr.bit_depth == EB_10BIT) { // Hsan: set split_mode to 0 to construct the packed reference buffer (used @ EP) picture_buffer_desc_init_data_16bit_ptr.split_mode = EB_FALSE; EB_NEW(reference_object->reference_picture16bit, svt_picture_buffer_desc_ctor, (EbPtr)&picture_buffer_desc_init_data_16bit_ptr); initialize_samples_neighboring_reference_picture( reference_object, &picture_buffer_desc_init_data_16bit_ptr, picture_buffer_desc_init_data_16bit_ptr.bit_depth); // Use 8bit here to use in MD picture_buffer_desc_init_data_16bit_ptr.split_mode = EB_FALSE; picture_buffer_desc_init_data_16bit_ptr.bit_depth = EB_8BIT; // if hbd_md = 1, and we only use 8bit luma for obmc_motion_refine if (ref_init_ptr->hbd_mode_decision == EB_10_BIT_MD) { picture_buffer_desc_init_data_16bit_ptr.buffer_enable_mask = PICTURE_BUFFER_DESC_LUMA_MASK; } EB_NEW(reference_object->reference_picture, svt_picture_buffer_desc_ctor, (EbPtr)&picture_buffer_desc_init_data_16bit_ptr); } else { // Hsan: set split_mode to 0 to as 8BIT input picture_buffer_desc_init_data_ptr->split_mode = EB_FALSE; EB_NEW(reference_object->reference_picture, svt_picture_buffer_desc_ctor, (EbPtr)picture_buffer_desc_init_data_ptr); initialize_samples_neighboring_reference_picture( reference_object, picture_buffer_desc_init_data_ptr, picture_buffer_desc_init_data_16bit_ptr.bit_depth); if (picture_buffer_desc_init_data_ptr->is_16bit_pipeline) { picture_buffer_desc_init_data_16bit_ptr.split_mode = EB_FALSE; picture_buffer_desc_init_data_16bit_ptr.bit_depth = EB_10BIT; EB_NEW(reference_object->reference_picture16bit, svt_picture_buffer_desc_ctor, (EbPtr)&picture_buffer_desc_init_data_16bit_ptr); initialize_samples_neighboring_reference_picture( reference_object, picture_buffer_desc_init_data_ptr, picture_buffer_desc_init_data_16bit_ptr.bit_depth); reference_object->reference_picture16bit->bit_depth = EB_8BIT; } } uint32_t mi_rows = reference_object->reference_picture->height >> MI_SIZE_LOG2; uint32_t mi_cols = reference_object->reference_picture->width >> MI_SIZE_LOG2; if (picture_buffer_desc_init_data_ptr->mfmv) { //MFMV map is 8x8 based. const int mem_size = ((mi_rows + 1) >> 1) * ((mi_cols + 1) >> 1); EB_CALLOC_ALIGNED_ARRAY(reference_object->mvs, mem_size); } memset(&reference_object->film_grain_params, 0, sizeof(reference_object->film_grain_params)); EB_CREATE_MUTEX(reference_object->referenced_area_mutex); // set all supplemental downscaled reference picture pointers to NULL for(uint8_t down_idx = 0; down_idx < NUM_SCALES; down_idx++){ reference_object->downscaled_reference_picture[down_idx] = NULL; reference_object->downscaled_reference_picture16bit[down_idx] = NULL; } reference_object->mi_rows = mi_rows; reference_object->mi_cols = mi_cols; return EB_ErrorNone; }
/***************************************** * svt_picture_buffer_desc_ctor * Initializes the Buffer Descriptor's * values that are fixed for the life of * the descriptor. *****************************************/
svt_picture_buffer_desc_ctor Initializes the Buffer Descriptor's values that are fixed for the life of the descriptor.
[ "svt_picture_buffer_desc_ctor", "Initializes", "the", "Buffer", "Descriptor", "'", "s", "values", "that", "are", "fixed", "for", "the", "life", "of", "the", "descriptor", "." ]
EbErrorType svt_reference_object_ctor(EbReferenceObject *reference_object, EbPtr object_init_data_ptr) { EbReferenceObjectDescInitData* ref_init_ptr = (EbReferenceObjectDescInitData*)object_init_data_ptr; EbPictureBufferDescInitData *picture_buffer_desc_init_data_ptr = &ref_init_ptr->reference_picture_desc_init_data; EbPictureBufferDescInitData picture_buffer_desc_init_data_16bit_ptr = *picture_buffer_desc_init_data_ptr; reference_object->dctor = svt_reference_object_dctor; if (picture_buffer_desc_init_data_16bit_ptr.bit_depth == EB_10BIT) { picture_buffer_desc_init_data_16bit_ptr.split_mode = EB_FALSE; EB_NEW(reference_object->reference_picture16bit, svt_picture_buffer_desc_ctor, (EbPtr)&picture_buffer_desc_init_data_16bit_ptr); initialize_samples_neighboring_reference_picture( reference_object, &picture_buffer_desc_init_data_16bit_ptr, picture_buffer_desc_init_data_16bit_ptr.bit_depth); picture_buffer_desc_init_data_16bit_ptr.split_mode = EB_FALSE; picture_buffer_desc_init_data_16bit_ptr.bit_depth = EB_8BIT; if (ref_init_ptr->hbd_mode_decision == EB_10_BIT_MD) { picture_buffer_desc_init_data_16bit_ptr.buffer_enable_mask = PICTURE_BUFFER_DESC_LUMA_MASK; } EB_NEW(reference_object->reference_picture, svt_picture_buffer_desc_ctor, (EbPtr)&picture_buffer_desc_init_data_16bit_ptr); } else { picture_buffer_desc_init_data_ptr->split_mode = EB_FALSE; EB_NEW(reference_object->reference_picture, svt_picture_buffer_desc_ctor, (EbPtr)picture_buffer_desc_init_data_ptr); initialize_samples_neighboring_reference_picture( reference_object, picture_buffer_desc_init_data_ptr, picture_buffer_desc_init_data_16bit_ptr.bit_depth); if (picture_buffer_desc_init_data_ptr->is_16bit_pipeline) { picture_buffer_desc_init_data_16bit_ptr.split_mode = EB_FALSE; picture_buffer_desc_init_data_16bit_ptr.bit_depth = EB_10BIT; EB_NEW(reference_object->reference_picture16bit, svt_picture_buffer_desc_ctor, (EbPtr)&picture_buffer_desc_init_data_16bit_ptr); initialize_samples_neighboring_reference_picture( reference_object, picture_buffer_desc_init_data_ptr, picture_buffer_desc_init_data_16bit_ptr.bit_depth); reference_object->reference_picture16bit->bit_depth = EB_8BIT; } } uint32_t mi_rows = reference_object->reference_picture->height >> MI_SIZE_LOG2; uint32_t mi_cols = reference_object->reference_picture->width >> MI_SIZE_LOG2; if (picture_buffer_desc_init_data_ptr->mfmv) { const int mem_size = ((mi_rows + 1) >> 1) * ((mi_cols + 1) >> 1); EB_CALLOC_ALIGNED_ARRAY(reference_object->mvs, mem_size); } memset(&reference_object->film_grain_params, 0, sizeof(reference_object->film_grain_params)); EB_CREATE_MUTEX(reference_object->referenced_area_mutex); for(uint8_t down_idx = 0; down_idx < NUM_SCALES; down_idx++){ reference_object->downscaled_reference_picture[down_idx] = NULL; reference_object->downscaled_reference_picture16bit[down_idx] = NULL; } reference_object->mi_rows = mi_rows; reference_object->mi_cols = mi_cols; return EB_ErrorNone; }
[ "EbErrorType", "svt_reference_object_ctor", "(", "EbReferenceObject", "*", "reference_object", ",", "EbPtr", "object_init_data_ptr", ")", "{", "EbReferenceObjectDescInitData", "*", "ref_init_ptr", "=", "(", "EbReferenceObjectDescInitData", "*", ")", "object_init_data_ptr", ";", "EbPictureBufferDescInitData", "*", "picture_buffer_desc_init_data_ptr", "=", "&", "ref_init_ptr", "->", "reference_picture_desc_init_data", ";", "EbPictureBufferDescInitData", "picture_buffer_desc_init_data_16bit_ptr", "=", "*", "picture_buffer_desc_init_data_ptr", ";", "reference_object", "->", "dctor", "=", "svt_reference_object_dctor", ";", "if", "(", "picture_buffer_desc_init_data_16bit_ptr", ".", "bit_depth", "==", "EB_10BIT", ")", "{", "picture_buffer_desc_init_data_16bit_ptr", ".", "split_mode", "=", "EB_FALSE", ";", "EB_NEW", "(", "reference_object", "->", "reference_picture16bit", ",", "svt_picture_buffer_desc_ctor", ",", "(", "EbPtr", ")", "&", "picture_buffer_desc_init_data_16bit_ptr", ")", ";", "initialize_samples_neighboring_reference_picture", "(", "reference_object", ",", "&", "picture_buffer_desc_init_data_16bit_ptr", ",", "picture_buffer_desc_init_data_16bit_ptr", ".", "bit_depth", ")", ";", "picture_buffer_desc_init_data_16bit_ptr", ".", "split_mode", "=", "EB_FALSE", ";", "picture_buffer_desc_init_data_16bit_ptr", ".", "bit_depth", "=", "EB_8BIT", ";", "if", "(", "ref_init_ptr", "->", "hbd_mode_decision", "==", "EB_10_BIT_MD", ")", "{", "picture_buffer_desc_init_data_16bit_ptr", ".", "buffer_enable_mask", "=", "PICTURE_BUFFER_DESC_LUMA_MASK", ";", "}", "EB_NEW", "(", "reference_object", "->", "reference_picture", ",", "svt_picture_buffer_desc_ctor", ",", "(", "EbPtr", ")", "&", "picture_buffer_desc_init_data_16bit_ptr", ")", ";", "}", "else", "{", "picture_buffer_desc_init_data_ptr", "->", "split_mode", "=", "EB_FALSE", ";", "EB_NEW", "(", "reference_object", "->", "reference_picture", ",", "svt_picture_buffer_desc_ctor", ",", "(", "EbPtr", ")", "picture_buffer_desc_init_data_ptr", ")", ";", "initialize_samples_neighboring_reference_picture", "(", "reference_object", ",", "picture_buffer_desc_init_data_ptr", ",", "picture_buffer_desc_init_data_16bit_ptr", ".", "bit_depth", ")", ";", "if", "(", "picture_buffer_desc_init_data_ptr", "->", "is_16bit_pipeline", ")", "{", "picture_buffer_desc_init_data_16bit_ptr", ".", "split_mode", "=", "EB_FALSE", ";", "picture_buffer_desc_init_data_16bit_ptr", ".", "bit_depth", "=", "EB_10BIT", ";", "EB_NEW", "(", "reference_object", "->", "reference_picture16bit", ",", "svt_picture_buffer_desc_ctor", ",", "(", "EbPtr", ")", "&", "picture_buffer_desc_init_data_16bit_ptr", ")", ";", "initialize_samples_neighboring_reference_picture", "(", "reference_object", ",", "picture_buffer_desc_init_data_ptr", ",", "picture_buffer_desc_init_data_16bit_ptr", ".", "bit_depth", ")", ";", "reference_object", "->", "reference_picture16bit", "->", "bit_depth", "=", "EB_8BIT", ";", "}", "}", "uint32_t", "mi_rows", "=", "reference_object", "->", "reference_picture", "->", "height", ">>", "MI_SIZE_LOG2", ";", "uint32_t", "mi_cols", "=", "reference_object", "->", "reference_picture", "->", "width", ">>", "MI_SIZE_LOG2", ";", "if", "(", "picture_buffer_desc_init_data_ptr", "->", "mfmv", ")", "{", "const", "int", "mem_size", "=", "(", "(", "mi_rows", "+", "1", ")", ">>", "1", ")", "*", "(", "(", "mi_cols", "+", "1", ")", ">>", "1", ")", ";", "EB_CALLOC_ALIGNED_ARRAY", "(", "reference_object", "->", "mvs", ",", "mem_size", ")", ";", "}", "memset", "(", "&", "reference_object", "->", "film_grain_params", ",", "0", ",", "sizeof", "(", "reference_object", "->", "film_grain_params", ")", ")", ";", "EB_CREATE_MUTEX", "(", "reference_object", "->", "referenced_area_mutex", ")", ";", "for", "(", "uint8_t", "down_idx", "=", "0", ";", "down_idx", "<", "NUM_SCALES", ";", "down_idx", "++", ")", "{", "reference_object", "->", "downscaled_reference_picture", "[", "down_idx", "]", "=", "NULL", ";", "reference_object", "->", "downscaled_reference_picture16bit", "[", "down_idx", "]", "=", "NULL", ";", "}", "reference_object", "->", "mi_rows", "=", "mi_rows", ";", "reference_object", "->", "mi_cols", "=", "mi_cols", ";", "return", "EB_ErrorNone", ";", "}" ]
svt_picture_buffer_desc_ctor Initializes the Buffer Descriptor's values that are fixed for the life of the descriptor.
[ "svt_picture_buffer_desc_ctor", "Initializes", "the", "Buffer", "Descriptor", "'", "s", "values", "that", "are", "fixed", "for", "the", "life", "of", "the", "descriptor", "." ]
[ "//TODO:12bit", "// Hsan: set split_mode to 0 to construct the packed reference buffer (used @ EP)", "// Use 8bit here to use in MD", "// if hbd_md = 1, and we only use 8bit luma for obmc_motion_refine", "// Hsan: set split_mode to 0 to as 8BIT input", "//MFMV map is 8x8 based.", "// set all supplemental downscaled reference picture pointers to NULL" ]
[ { "param": "reference_object", "type": "EbReferenceObject" }, { "param": "object_init_data_ptr", "type": "EbPtr" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "reference_object", "type": "EbReferenceObject", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "object_init_data_ptr", "type": "EbPtr", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6d65a224de70cf438619f21859dee7cc1fbbbb16
cryptomilk/SVT-AV1
Source/Lib/Encoder/Codec/EbReferenceObject.c
[ "BSD-2-Clause" ]
C
svt_pa_reference_object_ctor
EbErrorType
EbErrorType svt_pa_reference_object_ctor(EbPaReferenceObject *pa_ref_obj_, EbPtr object_init_data_ptr) { EbPictureBufferDescInitData *picture_buffer_desc_init_data_ptr = (EbPictureBufferDescInitData *)object_init_data_ptr; pa_ref_obj_->dctor = svt_pa_reference_object_dctor; // Reference picture constructor EB_NEW(pa_ref_obj_->input_padded_picture_ptr, svt_picture_buffer_desc_ctor, (EbPtr)picture_buffer_desc_init_data_ptr); // Quarter Decim reference picture constructor EB_NEW(pa_ref_obj_->quarter_decimated_picture_ptr, svt_picture_buffer_desc_ctor, (EbPtr)(picture_buffer_desc_init_data_ptr + 1)); EB_NEW(pa_ref_obj_->sixteenth_decimated_picture_ptr, svt_picture_buffer_desc_ctor, (EbPtr)(picture_buffer_desc_init_data_ptr + 2)); // Quarter Filtered reference picture constructor if ((picture_buffer_desc_init_data_ptr + 1)->down_sampled_filtered) { EB_NEW(pa_ref_obj_->quarter_filtered_picture_ptr, svt_picture_buffer_desc_ctor, (EbPtr)(picture_buffer_desc_init_data_ptr + 1)); } // Sixteenth Filtered reference picture constructor if ((picture_buffer_desc_init_data_ptr + 2)->down_sampled_filtered) { EB_NEW(pa_ref_obj_->sixteenth_filtered_picture_ptr, svt_picture_buffer_desc_ctor, (EbPtr)(picture_buffer_desc_init_data_ptr + 2)); } // set all supplemental downscaled reference picture pointers to NULL for(uint8_t down_idx = 0; down_idx < NUM_SCALES; down_idx++){ pa_ref_obj_->downscaled_input_padded_picture_ptr[down_idx] = NULL; pa_ref_obj_->downscaled_quarter_decimated_picture_ptr[down_idx] = NULL; pa_ref_obj_->downscaled_quarter_filtered_picture_ptr[down_idx] = NULL; pa_ref_obj_->downscaled_sixteenth_decimated_picture_ptr[down_idx] = NULL; pa_ref_obj_->downscaled_sixteenth_filtered_picture_ptr[down_idx] = NULL; } return EB_ErrorNone; }
/***************************************** * svt_pa_reference_object_ctor * Initializes the Buffer Descriptor's * values that are fixed for the life of * the descriptor. *****************************************/
svt_pa_reference_object_ctor Initializes the Buffer Descriptor's values that are fixed for the life of the descriptor.
[ "svt_pa_reference_object_ctor", "Initializes", "the", "Buffer", "Descriptor", "'", "s", "values", "that", "are", "fixed", "for", "the", "life", "of", "the", "descriptor", "." ]
EbErrorType svt_pa_reference_object_ctor(EbPaReferenceObject *pa_ref_obj_, EbPtr object_init_data_ptr) { EbPictureBufferDescInitData *picture_buffer_desc_init_data_ptr = (EbPictureBufferDescInitData *)object_init_data_ptr; pa_ref_obj_->dctor = svt_pa_reference_object_dctor; EB_NEW(pa_ref_obj_->input_padded_picture_ptr, svt_picture_buffer_desc_ctor, (EbPtr)picture_buffer_desc_init_data_ptr); EB_NEW(pa_ref_obj_->quarter_decimated_picture_ptr, svt_picture_buffer_desc_ctor, (EbPtr)(picture_buffer_desc_init_data_ptr + 1)); EB_NEW(pa_ref_obj_->sixteenth_decimated_picture_ptr, svt_picture_buffer_desc_ctor, (EbPtr)(picture_buffer_desc_init_data_ptr + 2)); if ((picture_buffer_desc_init_data_ptr + 1)->down_sampled_filtered) { EB_NEW(pa_ref_obj_->quarter_filtered_picture_ptr, svt_picture_buffer_desc_ctor, (EbPtr)(picture_buffer_desc_init_data_ptr + 1)); } if ((picture_buffer_desc_init_data_ptr + 2)->down_sampled_filtered) { EB_NEW(pa_ref_obj_->sixteenth_filtered_picture_ptr, svt_picture_buffer_desc_ctor, (EbPtr)(picture_buffer_desc_init_data_ptr + 2)); } for(uint8_t down_idx = 0; down_idx < NUM_SCALES; down_idx++){ pa_ref_obj_->downscaled_input_padded_picture_ptr[down_idx] = NULL; pa_ref_obj_->downscaled_quarter_decimated_picture_ptr[down_idx] = NULL; pa_ref_obj_->downscaled_quarter_filtered_picture_ptr[down_idx] = NULL; pa_ref_obj_->downscaled_sixteenth_decimated_picture_ptr[down_idx] = NULL; pa_ref_obj_->downscaled_sixteenth_filtered_picture_ptr[down_idx] = NULL; } return EB_ErrorNone; }
[ "EbErrorType", "svt_pa_reference_object_ctor", "(", "EbPaReferenceObject", "*", "pa_ref_obj_", ",", "EbPtr", "object_init_data_ptr", ")", "{", "EbPictureBufferDescInitData", "*", "picture_buffer_desc_init_data_ptr", "=", "(", "EbPictureBufferDescInitData", "*", ")", "object_init_data_ptr", ";", "pa_ref_obj_", "->", "dctor", "=", "svt_pa_reference_object_dctor", ";", "EB_NEW", "(", "pa_ref_obj_", "->", "input_padded_picture_ptr", ",", "svt_picture_buffer_desc_ctor", ",", "(", "EbPtr", ")", "picture_buffer_desc_init_data_ptr", ")", ";", "EB_NEW", "(", "pa_ref_obj_", "->", "quarter_decimated_picture_ptr", ",", "svt_picture_buffer_desc_ctor", ",", "(", "EbPtr", ")", "(", "picture_buffer_desc_init_data_ptr", "+", "1", ")", ")", ";", "EB_NEW", "(", "pa_ref_obj_", "->", "sixteenth_decimated_picture_ptr", ",", "svt_picture_buffer_desc_ctor", ",", "(", "EbPtr", ")", "(", "picture_buffer_desc_init_data_ptr", "+", "2", ")", ")", ";", "if", "(", "(", "picture_buffer_desc_init_data_ptr", "+", "1", ")", "->", "down_sampled_filtered", ")", "{", "EB_NEW", "(", "pa_ref_obj_", "->", "quarter_filtered_picture_ptr", ",", "svt_picture_buffer_desc_ctor", ",", "(", "EbPtr", ")", "(", "picture_buffer_desc_init_data_ptr", "+", "1", ")", ")", ";", "}", "if", "(", "(", "picture_buffer_desc_init_data_ptr", "+", "2", ")", "->", "down_sampled_filtered", ")", "{", "EB_NEW", "(", "pa_ref_obj_", "->", "sixteenth_filtered_picture_ptr", ",", "svt_picture_buffer_desc_ctor", ",", "(", "EbPtr", ")", "(", "picture_buffer_desc_init_data_ptr", "+", "2", ")", ")", ";", "}", "for", "(", "uint8_t", "down_idx", "=", "0", ";", "down_idx", "<", "NUM_SCALES", ";", "down_idx", "++", ")", "{", "pa_ref_obj_", "->", "downscaled_input_padded_picture_ptr", "[", "down_idx", "]", "=", "NULL", ";", "pa_ref_obj_", "->", "downscaled_quarter_decimated_picture_ptr", "[", "down_idx", "]", "=", "NULL", ";", "pa_ref_obj_", "->", "downscaled_quarter_filtered_picture_ptr", "[", "down_idx", "]", "=", "NULL", ";", "pa_ref_obj_", "->", "downscaled_sixteenth_decimated_picture_ptr", "[", "down_idx", "]", "=", "NULL", ";", "pa_ref_obj_", "->", "downscaled_sixteenth_filtered_picture_ptr", "[", "down_idx", "]", "=", "NULL", ";", "}", "return", "EB_ErrorNone", ";", "}" ]
svt_pa_reference_object_ctor Initializes the Buffer Descriptor's values that are fixed for the life of the descriptor.
[ "svt_pa_reference_object_ctor", "Initializes", "the", "Buffer", "Descriptor", "'", "s", "values", "that", "are", "fixed", "for", "the", "life", "of", "the", "descriptor", "." ]
[ "// Reference picture constructor", "// Quarter Decim reference picture constructor", "// Quarter Filtered reference picture constructor", "// Sixteenth Filtered reference picture constructor", "// set all supplemental downscaled reference picture pointers to NULL" ]
[ { "param": "pa_ref_obj_", "type": "EbPaReferenceObject" }, { "param": "object_init_data_ptr", "type": "EbPtr" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pa_ref_obj_", "type": "EbPaReferenceObject", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "object_init_data_ptr", "type": "EbPtr", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
644bb031ead695a1a85205b0c3eb364ec1c26638
MemeTao/webrtc-release
third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.h
[ "MIT" ]
C
ResolveBfcBlockOffset
bool
bool ResolveBfcBlockOffset(NGPreviousInflowPosition* previous_inflow_position, LayoutUnit bfc_block_offset) { return ResolveBfcBlockOffset(previous_inflow_position, bfc_block_offset, ConstraintSpace().ForcedBfcBlockOffset()); }
// This passes in the |forced_bfc_block_offset| from the input constraints, // which is almost always desired.
This passes in the |forced_bfc_block_offset| from the input constraints, which is almost always desired.
[ "This", "passes", "in", "the", "|forced_bfc_block_offset|", "from", "the", "input", "constraints", "which", "is", "almost", "always", "desired", "." ]
bool ResolveBfcBlockOffset(NGPreviousInflowPosition* previous_inflow_position, LayoutUnit bfc_block_offset) { return ResolveBfcBlockOffset(previous_inflow_position, bfc_block_offset, ConstraintSpace().ForcedBfcBlockOffset()); }
[ "bool", "ResolveBfcBlockOffset", "(", "NGPreviousInflowPosition", "*", "previous_inflow_position", ",", "LayoutUnit", "bfc_block_offset", ")", "{", "return", "ResolveBfcBlockOffset", "(", "previous_inflow_position", ",", "bfc_block_offset", ",", "ConstraintSpace", "(", ")", ".", "ForcedBfcBlockOffset", "(", ")", ")", ";", "}" ]
This passes in the |forced_bfc_block_offset| from the input constraints, which is almost always desired.
[ "This", "passes", "in", "the", "|forced_bfc_block_offset|", "from", "the", "input", "constraints", "which", "is", "almost", "always", "desired", "." ]
[]
[ { "param": "previous_inflow_position", "type": "NGPreviousInflowPosition" }, { "param": "bfc_block_offset", "type": "LayoutUnit" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "previous_inflow_position", "type": "NGPreviousInflowPosition", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bfc_block_offset", "type": "LayoutUnit", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
644bb031ead695a1a85205b0c3eb364ec1c26638
MemeTao/webrtc-release
third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.h
[ "MIT" ]
C
ResolveBfcBlockOffset
bool
bool ResolveBfcBlockOffset( NGPreviousInflowPosition* previous_inflow_position) { return ResolveBfcBlockOffset(previous_inflow_position, NextBorderEdge(*previous_inflow_position)); }
// A very common way to resolve the BFC block offset is to simply commit the // pending margin, so here's a convenience overload for that.
A very common way to resolve the BFC block offset is to simply commit the pending margin, so here's a convenience overload for that.
[ "A", "very", "common", "way", "to", "resolve", "the", "BFC", "block", "offset", "is", "to", "simply", "commit", "the", "pending", "margin", "so", "here", "'", "s", "a", "convenience", "overload", "for", "that", "." ]
bool ResolveBfcBlockOffset( NGPreviousInflowPosition* previous_inflow_position) { return ResolveBfcBlockOffset(previous_inflow_position, NextBorderEdge(*previous_inflow_position)); }
[ "bool", "ResolveBfcBlockOffset", "(", "NGPreviousInflowPosition", "*", "previous_inflow_position", ")", "{", "return", "ResolveBfcBlockOffset", "(", "previous_inflow_position", ",", "NextBorderEdge", "(", "*", "previous_inflow_position", ")", ")", ";", "}" ]
A very common way to resolve the BFC block offset is to simply commit the pending margin, so here's a convenience overload for that.
[ "A", "very", "common", "way", "to", "resolve", "the", "BFC", "block", "offset", "is", "to", "simply", "commit", "the", "pending", "margin", "so", "here", "'", "s", "a", "convenience", "overload", "for", "that", "." ]
[]
[ { "param": "previous_inflow_position", "type": "NGPreviousInflowPosition" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "previous_inflow_position", "type": "NGPreviousInflowPosition", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3692bd4aa1721efaea97e745d26b71e9cf83695d
mutalisk999/pycron
pycron/cron/rbtree.c
[ "MIT" ]
C
lpr_rbtree_create
lpr_rbtree_t
lpr_rbtree_t *lpr_rbtree_create(lpr_malloc_func_t mallocf, lpr_cmp_func_t cmpf, lpr_free_func_t freekey, lpr_free_func_t freedata) { lpr_rbtree_t *rbtree; /* Allocate memory for it */ if((rbtree = (lpr_rbtree_t *)mallocf(sizeof(lpr_rbtree_t))) == NULL) { return NULL; } /* Initialize it */ rbtree->root = LPR_RBTREE_NULL; rbtree->count = 0; rbtree->mallocf = mallocf; rbtree->cmp = cmpf; rbtree->freekeyf = freekey; rbtree->freedataf = freedata; return rbtree; }
/* * Creates a new red black tree, intializes and returns a pointer to it. * * Return NULL if mallocf() fails. * */
Creates a new red black tree, intializes and returns a pointer to it. Return NULL if mallocf() fails.
[ "Creates", "a", "new", "red", "black", "tree", "intializes", "and", "returns", "a", "pointer", "to", "it", ".", "Return", "NULL", "if", "mallocf", "()", "fails", "." ]
lpr_rbtree_t *lpr_rbtree_create(lpr_malloc_func_t mallocf, lpr_cmp_func_t cmpf, lpr_free_func_t freekey, lpr_free_func_t freedata) { lpr_rbtree_t *rbtree; if((rbtree = (lpr_rbtree_t *)mallocf(sizeof(lpr_rbtree_t))) == NULL) { return NULL; } rbtree->root = LPR_RBTREE_NULL; rbtree->count = 0; rbtree->mallocf = mallocf; rbtree->cmp = cmpf; rbtree->freekeyf = freekey; rbtree->freedataf = freedata; return rbtree; }
[ "lpr_rbtree_t", "*", "lpr_rbtree_create", "(", "lpr_malloc_func_t", "mallocf", ",", "lpr_cmp_func_t", "cmpf", ",", "lpr_free_func_t", "freekey", ",", "lpr_free_func_t", "freedata", ")", "{", "lpr_rbtree_t", "*", "rbtree", ";", "if", "(", "(", "rbtree", "=", "(", "lpr_rbtree_t", "*", ")", "mallocf", "(", "sizeof", "(", "lpr_rbtree_t", ")", ")", ")", "==", "NULL", ")", "{", "return", "NULL", ";", "}", "rbtree", "->", "root", "=", "LPR_RBTREE_NULL", ";", "rbtree", "->", "count", "=", "0", ";", "rbtree", "->", "mallocf", "=", "mallocf", ";", "rbtree", "->", "cmp", "=", "cmpf", ";", "rbtree", "->", "freekeyf", "=", "freekey", ";", "rbtree", "->", "freedataf", "=", "freedata", ";", "return", "rbtree", ";", "}" ]
Creates a new red black tree, intializes and returns a pointer to it.
[ "Creates", "a", "new", "red", "black", "tree", "intializes", "and", "returns", "a", "pointer", "to", "it", "." ]
[ "/* Allocate memory for it */", "/* Initialize it */" ]
[ { "param": "mallocf", "type": "lpr_malloc_func_t" }, { "param": "cmpf", "type": "lpr_cmp_func_t" }, { "param": "freekey", "type": "lpr_free_func_t" }, { "param": "freedata", "type": "lpr_free_func_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mallocf", "type": "lpr_malloc_func_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cmpf", "type": "lpr_cmp_func_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "freekey", "type": "lpr_free_func_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "freedata", "type": "lpr_free_func_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3692bd4aa1721efaea97e745d26b71e9cf83695d
mutalisk999/pycron
pycron/cron/rbtree.c
[ "MIT" ]
C
lpr_rbtree_rotate_left
void
static void lpr_rbtree_rotate_left(lpr_rbtree_t *rbtree, lpr_rbnode_t *node) { lpr_rbnode_t *_right = node->_right; node->_right = _right->_left; if(_right->_left != LPR_RBTREE_NULL) _right->_left->_parent = node; _right->_parent = node->_parent; if(node->_parent != LPR_RBTREE_NULL) { if(node == node->_parent->_left) { node->_parent->_left = _right; } else { node->_parent->_right = _right; } } else { rbtree->root = _right; } _right->_left = node; node->_parent = _right; }
/* * Rotates the node to the _left. * */
Rotates the node to the _left.
[ "Rotates", "the", "node", "to", "the", "_left", "." ]
static void lpr_rbtree_rotate_left(lpr_rbtree_t *rbtree, lpr_rbnode_t *node) { lpr_rbnode_t *_right = node->_right; node->_right = _right->_left; if(_right->_left != LPR_RBTREE_NULL) _right->_left->_parent = node; _right->_parent = node->_parent; if(node->_parent != LPR_RBTREE_NULL) { if(node == node->_parent->_left) { node->_parent->_left = _right; } else { node->_parent->_right = _right; } } else { rbtree->root = _right; } _right->_left = node; node->_parent = _right; }
[ "static", "void", "lpr_rbtree_rotate_left", "(", "lpr_rbtree_t", "*", "rbtree", ",", "lpr_rbnode_t", "*", "node", ")", "{", "lpr_rbnode_t", "*", "_right", "=", "node", "->", "_right", ";", "node", "->", "_right", "=", "_right", "->", "_left", ";", "if", "(", "_right", "->", "_left", "!=", "LPR_RBTREE_NULL", ")", "_right", "->", "_left", "->", "_parent", "=", "node", ";", "_right", "->", "_parent", "=", "node", "->", "_parent", ";", "if", "(", "node", "->", "_parent", "!=", "LPR_RBTREE_NULL", ")", "{", "if", "(", "node", "==", "node", "->", "_parent", "->", "_left", ")", "{", "node", "->", "_parent", "->", "_left", "=", "_right", ";", "}", "else", "{", "node", "->", "_parent", "->", "_right", "=", "_right", ";", "}", "}", "else", "{", "rbtree", "->", "root", "=", "_right", ";", "}", "_right", "->", "_left", "=", "node", ";", "node", "->", "_parent", "=", "_right", ";", "}" ]
Rotates the node to the _left.
[ "Rotates", "the", "node", "to", "the", "_left", "." ]
[]
[ { "param": "rbtree", "type": "lpr_rbtree_t" }, { "param": "node", "type": "lpr_rbnode_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rbtree", "type": "lpr_rbtree_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "node", "type": "lpr_rbnode_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3692bd4aa1721efaea97e745d26b71e9cf83695d
mutalisk999/pycron
pycron/cron/rbtree.c
[ "MIT" ]
C
rbtree_rotate_right
void
static void rbtree_rotate_right(lpr_rbtree_t *rbtree, lpr_rbnode_t *node) { lpr_rbnode_t *_left = node->_left; node->_left = _left->_right; if(_left->_right != LPR_RBTREE_NULL) _left->_right->_parent = node; _left->_parent = node->_parent; if(node->_parent != LPR_RBTREE_NULL) { if(node == node->_parent->_right) { node->_parent->_right = _left; } else { node->_parent->_left = _left; } } else { rbtree->root = _left; } _left->_right = node; node->_parent = _left; }
/* * Rotates the node to the _right. * */
Rotates the node to the _right.
[ "Rotates", "the", "node", "to", "the", "_right", "." ]
static void rbtree_rotate_right(lpr_rbtree_t *rbtree, lpr_rbnode_t *node) { lpr_rbnode_t *_left = node->_left; node->_left = _left->_right; if(_left->_right != LPR_RBTREE_NULL) _left->_right->_parent = node; _left->_parent = node->_parent; if(node->_parent != LPR_RBTREE_NULL) { if(node == node->_parent->_right) { node->_parent->_right = _left; } else { node->_parent->_left = _left; } } else { rbtree->root = _left; } _left->_right = node; node->_parent = _left; }
[ "static", "void", "rbtree_rotate_right", "(", "lpr_rbtree_t", "*", "rbtree", ",", "lpr_rbnode_t", "*", "node", ")", "{", "lpr_rbnode_t", "*", "_left", "=", "node", "->", "_left", ";", "node", "->", "_left", "=", "_left", "->", "_right", ";", "if", "(", "_left", "->", "_right", "!=", "LPR_RBTREE_NULL", ")", "_left", "->", "_right", "->", "_parent", "=", "node", ";", "_left", "->", "_parent", "=", "node", "->", "_parent", ";", "if", "(", "node", "->", "_parent", "!=", "LPR_RBTREE_NULL", ")", "{", "if", "(", "node", "==", "node", "->", "_parent", "->", "_right", ")", "{", "node", "->", "_parent", "->", "_right", "=", "_left", ";", "}", "else", "{", "node", "->", "_parent", "->", "_left", "=", "_left", ";", "}", "}", "else", "{", "rbtree", "->", "root", "=", "_left", ";", "}", "_left", "->", "_right", "=", "node", ";", "node", "->", "_parent", "=", "_left", ";", "}" ]
Rotates the node to the _right.
[ "Rotates", "the", "node", "to", "the", "_right", "." ]
[]
[ { "param": "rbtree", "type": "lpr_rbtree_t" }, { "param": "node", "type": "lpr_rbnode_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rbtree", "type": "lpr_rbtree_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "node", "type": "lpr_rbnode_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3692bd4aa1721efaea97e745d26b71e9cf83695d
mutalisk999/pycron
pycron/cron/rbtree.c
[ "MIT" ]
C
lpr_rbtree_insert
void
void *lpr_rbtree_insert(lpr_rbtree_t *rbtree, void *key, void *data, int overwrite) { /* XXX Not necessary, but keeps compiler quiet... */ int r = 0; /* We start at the root of the tree */ lpr_rbnode_t *node = rbtree->root; lpr_rbnode_t *_parent = LPR_RBTREE_NULL; /* Lets find the new _parent... */ while(node != LPR_RBTREE_NULL) { /* Compare two keys, do we have a duplicate? */ if((r = rbtree->cmp(key, node->key)) == 0) { if(overwrite) { if(rbtree->freekeyf) rbtree->freekeyf(node->key); if(rbtree->freedataf) rbtree->freedataf(node->data); node->key = key; node->data = data; } return node->data; } _parent = node; if(r < 0) { node = node->_left; } else { node = node->_right; } } /* Create the new node */ if((node = (lpr_rbnode_t *)rbtree->mallocf(sizeof(lpr_rbnode_t))) == NULL) { return NULL; } node->_parent = _parent; node->_left = node->_right = LPR_RBTREE_NULL; node->_color = RED; node->key = key; node->data = data; rbtree->count++; /* Insert it into the tree... */ if(_parent != LPR_RBTREE_NULL) { if(r < 0) { _parent->_left = node; } else { _parent->_right = node; } } else { rbtree->root = node; } /* Fix up the red-black properties... */ rbtree_insert_fixup(rbtree, node); return node->data; }
/* * Inserts a node into a red black tree. * * Returns if rbtree->mallocf() fails or the pointer to the newly added * data otherwise. * * If told to overwrite will replace the duplicate key and data with * the new values (thus will NOT destroy the existing node first), * otherwise will return the pointer to the data of already existing * data. * */
Inserts a node into a red black tree. Returns if rbtree->mallocf() fails or the pointer to the newly added data otherwise. If told to overwrite will replace the duplicate key and data with the new values (thus will NOT destroy the existing node first), otherwise will return the pointer to the data of already existing data.
[ "Inserts", "a", "node", "into", "a", "red", "black", "tree", ".", "Returns", "if", "rbtree", "-", ">", "mallocf", "()", "fails", "or", "the", "pointer", "to", "the", "newly", "added", "data", "otherwise", ".", "If", "told", "to", "overwrite", "will", "replace", "the", "duplicate", "key", "and", "data", "with", "the", "new", "values", "(", "thus", "will", "NOT", "destroy", "the", "existing", "node", "first", ")", "otherwise", "will", "return", "the", "pointer", "to", "the", "data", "of", "already", "existing", "data", "." ]
void *lpr_rbtree_insert(lpr_rbtree_t *rbtree, void *key, void *data, int overwrite) { int r = 0; lpr_rbnode_t *node = rbtree->root; lpr_rbnode_t *_parent = LPR_RBTREE_NULL; while(node != LPR_RBTREE_NULL) { if((r = rbtree->cmp(key, node->key)) == 0) { if(overwrite) { if(rbtree->freekeyf) rbtree->freekeyf(node->key); if(rbtree->freedataf) rbtree->freedataf(node->data); node->key = key; node->data = data; } return node->data; } _parent = node; if(r < 0) { node = node->_left; } else { node = node->_right; } } if((node = (lpr_rbnode_t *)rbtree->mallocf(sizeof(lpr_rbnode_t))) == NULL) { return NULL; } node->_parent = _parent; node->_left = node->_right = LPR_RBTREE_NULL; node->_color = RED; node->key = key; node->data = data; rbtree->count++; if(_parent != LPR_RBTREE_NULL) { if(r < 0) { _parent->_left = node; } else { _parent->_right = node; } } else { rbtree->root = node; } rbtree_insert_fixup(rbtree, node); return node->data; }
[ "void", "*", "lpr_rbtree_insert", "(", "lpr_rbtree_t", "*", "rbtree", ",", "void", "*", "key", ",", "void", "*", "data", ",", "int", "overwrite", ")", "{", "int", "r", "=", "0", ";", "lpr_rbnode_t", "*", "node", "=", "rbtree", "->", "root", ";", "lpr_rbnode_t", "*", "_parent", "=", "LPR_RBTREE_NULL", ";", "while", "(", "node", "!=", "LPR_RBTREE_NULL", ")", "{", "if", "(", "(", "r", "=", "rbtree", "->", "cmp", "(", "key", ",", "node", "->", "key", ")", ")", "==", "0", ")", "{", "if", "(", "overwrite", ")", "{", "if", "(", "rbtree", "->", "freekeyf", ")", "rbtree", "->", "freekeyf", "(", "node", "->", "key", ")", ";", "if", "(", "rbtree", "->", "freedataf", ")", "rbtree", "->", "freedataf", "(", "node", "->", "data", ")", ";", "node", "->", "key", "=", "key", ";", "node", "->", "data", "=", "data", ";", "}", "return", "node", "->", "data", ";", "}", "_parent", "=", "node", ";", "if", "(", "r", "<", "0", ")", "{", "node", "=", "node", "->", "_left", ";", "}", "else", "{", "node", "=", "node", "->", "_right", ";", "}", "}", "if", "(", "(", "node", "=", "(", "lpr_rbnode_t", "*", ")", "rbtree", "->", "mallocf", "(", "sizeof", "(", "lpr_rbnode_t", ")", ")", ")", "==", "NULL", ")", "{", "return", "NULL", ";", "}", "node", "->", "_parent", "=", "_parent", ";", "node", "->", "_left", "=", "node", "->", "_right", "=", "LPR_RBTREE_NULL", ";", "node", "->", "_color", "=", "RED", ";", "node", "->", "key", "=", "key", ";", "node", "->", "data", "=", "data", ";", "rbtree", "->", "count", "++", ";", "if", "(", "_parent", "!=", "LPR_RBTREE_NULL", ")", "{", "if", "(", "r", "<", "0", ")", "{", "_parent", "->", "_left", "=", "node", ";", "}", "else", "{", "_parent", "->", "_right", "=", "node", ";", "}", "}", "else", "{", "rbtree", "->", "root", "=", "node", ";", "}", "rbtree_insert_fixup", "(", "rbtree", ",", "node", ")", ";", "return", "node", "->", "data", ";", "}" ]
Inserts a node into a red black tree.
[ "Inserts", "a", "node", "into", "a", "red", "black", "tree", "." ]
[ "/* XXX Not necessary, but keeps compiler quiet... */", "/* We start at the root of the tree */", "/* Lets find the new _parent... */", "/* Compare two keys, do we have a duplicate? */", "/* Create the new node */", "/* Insert it into the tree... */", "/* Fix up the red-black properties... */" ]
[ { "param": "rbtree", "type": "lpr_rbtree_t" }, { "param": "key", "type": "void" }, { "param": "data", "type": "void" }, { "param": "overwrite", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rbtree", "type": "lpr_rbtree_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "key", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "overwrite", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3692bd4aa1721efaea97e745d26b71e9cf83695d
mutalisk999/pycron
pycron/cron/rbtree.c
[ "MIT" ]
C
lpr_rbtree_lower_bound
lpr_rbnode_t
lpr_rbnode_t *lpr_rbtree_lower_bound(lpr_rbtree_t *rbtree, const void *key) { int r; lpr_rbnode_t *node; /* We start at root... */ node = rbtree->root; /* While there are children... */ while(node != LPR_RBTREE_NULL) { if((r = rbtree->cmp((void *)key, node->key)) == 0) { return node; } if(r < 0) { if(node->_left == LPR_RBTREE_NULL) { return node; } node = node->_left; } else { if(node->_right == LPR_RBTREE_NULL) { lpr_rbnode_t * parent = node->_parent; lpr_rbnode_t * ch = node; while (parent != LPR_RBTREE_NULL && ch == parent->_right) { ch = parent; parent = parent->_parent; } return parent; } node = node->_right; } } return LPR_RBTREE_NULL; }
/* * Searches the red black tree, returns the rbnode->key >= key or NULL otherwise. * */
Searches the red black tree, returns the rbnode->key >= key or NULL otherwise.
[ "Searches", "the", "red", "black", "tree", "returns", "the", "rbnode", "-", ">", "key", ">", "=", "key", "or", "NULL", "otherwise", "." ]
lpr_rbnode_t *lpr_rbtree_lower_bound(lpr_rbtree_t *rbtree, const void *key) { int r; lpr_rbnode_t *node; node = rbtree->root; while(node != LPR_RBTREE_NULL) { if((r = rbtree->cmp((void *)key, node->key)) == 0) { return node; } if(r < 0) { if(node->_left == LPR_RBTREE_NULL) { return node; } node = node->_left; } else { if(node->_right == LPR_RBTREE_NULL) { lpr_rbnode_t * parent = node->_parent; lpr_rbnode_t * ch = node; while (parent != LPR_RBTREE_NULL && ch == parent->_right) { ch = parent; parent = parent->_parent; } return parent; } node = node->_right; } } return LPR_RBTREE_NULL; }
[ "lpr_rbnode_t", "*", "lpr_rbtree_lower_bound", "(", "lpr_rbtree_t", "*", "rbtree", ",", "const", "void", "*", "key", ")", "{", "int", "r", ";", "lpr_rbnode_t", "*", "node", ";", "node", "=", "rbtree", "->", "root", ";", "while", "(", "node", "!=", "LPR_RBTREE_NULL", ")", "{", "if", "(", "(", "r", "=", "rbtree", "->", "cmp", "(", "(", "void", "*", ")", "key", ",", "node", "->", "key", ")", ")", "==", "0", ")", "{", "return", "node", ";", "}", "if", "(", "r", "<", "0", ")", "{", "if", "(", "node", "->", "_left", "==", "LPR_RBTREE_NULL", ")", "{", "return", "node", ";", "}", "node", "=", "node", "->", "_left", ";", "}", "else", "{", "if", "(", "node", "->", "_right", "==", "LPR_RBTREE_NULL", ")", "{", "lpr_rbnode_t", "*", "parent", "=", "node", "->", "_parent", ";", "lpr_rbnode_t", "*", "ch", "=", "node", ";", "while", "(", "parent", "!=", "LPR_RBTREE_NULL", "&&", "ch", "==", "parent", "->", "_right", ")", "{", "ch", "=", "parent", ";", "parent", "=", "parent", "->", "_parent", ";", "}", "return", "parent", ";", "}", "node", "=", "node", "->", "_right", ";", "}", "}", "return", "LPR_RBTREE_NULL", ";", "}" ]
Searches the red black tree, returns the rbnode->key >= key or NULL otherwise.
[ "Searches", "the", "red", "black", "tree", "returns", "the", "rbnode", "-", ">", "key", ">", "=", "key", "or", "NULL", "otherwise", "." ]
[ "/* We start at root... */", "/* While there are children... */" ]
[ { "param": "rbtree", "type": "lpr_rbtree_t" }, { "param": "key", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rbtree", "type": "lpr_rbtree_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "key", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3692bd4aa1721efaea97e745d26b71e9cf83695d
mutalisk999/pycron
pycron/cron/rbtree.c
[ "MIT" ]
C
lpr_rbtree_search
void
void *lpr_rbtree_search(lpr_rbtree_t *rbtree, const void *key) { int r; lpr_rbnode_t *node; /* We start at root... */ node = rbtree->root; /* While there are children... */ while(node != LPR_RBTREE_NULL) { if((r = rbtree->cmp((void *)key, node->key)) == 0) { return node->data; } if(r < 0) { node = node->_left; } else { node = node->_right; } } return NULL; }
/* * Searches the red black tree, returns the data if key is found or NULL otherwise. * */
Searches the red black tree, returns the data if key is found or NULL otherwise.
[ "Searches", "the", "red", "black", "tree", "returns", "the", "data", "if", "key", "is", "found", "or", "NULL", "otherwise", "." ]
void *lpr_rbtree_search(lpr_rbtree_t *rbtree, const void *key) { int r; lpr_rbnode_t *node; node = rbtree->root; while(node != LPR_RBTREE_NULL) { if((r = rbtree->cmp((void *)key, node->key)) == 0) { return node->data; } if(r < 0) { node = node->_left; } else { node = node->_right; } } return NULL; }
[ "void", "*", "lpr_rbtree_search", "(", "lpr_rbtree_t", "*", "rbtree", ",", "const", "void", "*", "key", ")", "{", "int", "r", ";", "lpr_rbnode_t", "*", "node", ";", "node", "=", "rbtree", "->", "root", ";", "while", "(", "node", "!=", "LPR_RBTREE_NULL", ")", "{", "if", "(", "(", "r", "=", "rbtree", "->", "cmp", "(", "(", "void", "*", ")", "key", ",", "node", "->", "key", ")", ")", "==", "0", ")", "{", "return", "node", "->", "data", ";", "}", "if", "(", "r", "<", "0", ")", "{", "node", "=", "node", "->", "_left", ";", "}", "else", "{", "node", "=", "node", "->", "_right", ";", "}", "}", "return", "NULL", ";", "}" ]
Searches the red black tree, returns the data if key is found or NULL otherwise.
[ "Searches", "the", "red", "black", "tree", "returns", "the", "data", "if", "key", "is", "found", "or", "NULL", "otherwise", "." ]
[ "/* We start at root... */", "/* While there are children... */" ]
[ { "param": "rbtree", "type": "lpr_rbtree_t" }, { "param": "key", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rbtree", "type": "lpr_rbtree_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "key", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3692bd4aa1721efaea97e745d26b71e9cf83695d
mutalisk999/pycron
pycron/cron/rbtree.c
[ "MIT" ]
C
lpr_rbtree_first
lpr_rbnode_t
lpr_rbnode_t *lpr_rbtree_first(lpr_rbtree_t *rbtree) { lpr_rbnode_t *node; for(node = rbtree->root; node->_left != LPR_RBTREE_NULL; node = node->_left) ; return node; }
/* * Finds the first element in the red black tree * */
Finds the first element in the red black tree
[ "Finds", "the", "first", "element", "in", "the", "red", "black", "tree" ]
lpr_rbnode_t *lpr_rbtree_first(lpr_rbtree_t *rbtree) { lpr_rbnode_t *node; for(node = rbtree->root; node->_left != LPR_RBTREE_NULL; node = node->_left) ; return node; }
[ "lpr_rbnode_t", "*", "lpr_rbtree_first", "(", "lpr_rbtree_t", "*", "rbtree", ")", "{", "lpr_rbnode_t", "*", "node", ";", "for", "(", "node", "=", "rbtree", "->", "root", ";", "node", "->", "_left", "!=", "LPR_RBTREE_NULL", ";", "node", "=", "node", "->", "_left", ")", ";", "return", "node", ";", "}" ]
Finds the first element in the red black tree
[ "Finds", "the", "first", "element", "in", "the", "red", "black", "tree" ]
[]
[ { "param": "rbtree", "type": "lpr_rbtree_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rbtree", "type": "lpr_rbtree_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
38fde98a0969b4c54084fa4c504ce758876cd80e
mutalisk999/pycron
pycron/pycron.c
[ "MIT" ]
C
next_cronexpr_time
time_t
time_t next_cronexpr_time(const char* expr, time_t baseTime) { cronexpr_t * cron = cronexpr_create(expr); if(cron) { time_t next = cronexpr_after(cron, baseTime); cronexpr_destroy(cron); return next; } return 0; }
/* add interface next_cronexpr_time for python module */
add interface next_cronexpr_time for python module
[ "add", "interface", "next_cronexpr_time", "for", "python", "module" ]
time_t next_cronexpr_time(const char* expr, time_t baseTime) { cronexpr_t * cron = cronexpr_create(expr); if(cron) { time_t next = cronexpr_after(cron, baseTime); cronexpr_destroy(cron); return next; } return 0; }
[ "time_t", "next_cronexpr_time", "(", "const", "char", "*", "expr", ",", "time_t", "baseTime", ")", "{", "cronexpr_t", "*", "cron", "=", "cronexpr_create", "(", "expr", ")", ";", "if", "(", "cron", ")", "{", "time_t", "next", "=", "cronexpr_after", "(", "cron", ",", "baseTime", ")", ";", "cronexpr_destroy", "(", "cron", ")", ";", "return", "next", ";", "}", "return", "0", ";", "}" ]
add interface next_cronexpr_time for python module
[ "add", "interface", "next_cronexpr_time", "for", "python", "module" ]
[]
[ { "param": "expr", "type": "char" }, { "param": "baseTime", "type": "time_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "expr", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "baseTime", "type": "time_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
38fde98a0969b4c54084fa4c504ce758876cd80e
mutalisk999/pycron
pycron/pycron.c
[ "MIT" ]
C
last_cronexpr_time
time_t
time_t last_cronexpr_time(const char* expr, time_t baseTime) { cronexpr_t * cron = cronexpr_create(expr); if(cron) { time_t last = cronexpr_before(cron, baseTime); cronexpr_destroy(cron); return last; } return 0; }
/* add interface last_cronexpr_time for python module */
add interface last_cronexpr_time for python module
[ "add", "interface", "last_cronexpr_time", "for", "python", "module" ]
time_t last_cronexpr_time(const char* expr, time_t baseTime) { cronexpr_t * cron = cronexpr_create(expr); if(cron) { time_t last = cronexpr_before(cron, baseTime); cronexpr_destroy(cron); return last; } return 0; }
[ "time_t", "last_cronexpr_time", "(", "const", "char", "*", "expr", ",", "time_t", "baseTime", ")", "{", "cronexpr_t", "*", "cron", "=", "cronexpr_create", "(", "expr", ")", ";", "if", "(", "cron", ")", "{", "time_t", "last", "=", "cronexpr_before", "(", "cron", ",", "baseTime", ")", ";", "cronexpr_destroy", "(", "cron", ")", ";", "return", "last", ";", "}", "return", "0", ";", "}" ]
add interface last_cronexpr_time for python module
[ "add", "interface", "last_cronexpr_time", "for", "python", "module" ]
[]
[ { "param": "expr", "type": "char" }, { "param": "baseTime", "type": "time_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "expr", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "baseTime", "type": "time_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3db8658d438f0b31c4dccda15ad4d10df4287209
thrillerqin/qb_esp32_aliiot
components/qinbao_i2c/src/i2c_example_main.c
[ "CC0-1.0" ]
C
i2c_master_read_slave
esp_err_t
static esp_err_t i2c_master_read_slave(i2c_port_t i2c_num, uint8_t *data_rd, size_t size) { if (size == 0) { return ESP_OK; } i2c_cmd_handle_t cmd = i2c_cmd_link_create(); i2c_master_start(cmd); i2c_master_write_byte(cmd, (ESP_SLAVE_ADDR << 1) | READ_BIT, ACK_CHECK_EN); if (size > 1) { i2c_master_read(cmd, data_rd, size - 1, ACK_VAL); } i2c_master_read_byte(cmd, data_rd + size - 1, NACK_VAL); i2c_master_stop(cmd); esp_err_t ret = i2c_master_cmd_begin(i2c_num, cmd, 1000 / portTICK_RATE_MS); i2c_cmd_link_delete(cmd); return ret; }
/** * @brief test code to read esp-i2c-slave * We need to fill the buffer of esp slave device, then master can read them out. * * _______________________________________________________________________________________ * | start | slave_addr + rd_bit +ack | read n-1 bytes + ack | read 1 byte + nack | stop | * --------|--------------------------|----------------------|--------------------|------| * */
@brief test code to read esp-i2c-slave We need to fill the buffer of esp slave device, then master can read them out.
[ "@brief", "test", "code", "to", "read", "esp", "-", "i2c", "-", "slave", "We", "need", "to", "fill", "the", "buffer", "of", "esp", "slave", "device", "then", "master", "can", "read", "them", "out", "." ]
static esp_err_t i2c_master_read_slave(i2c_port_t i2c_num, uint8_t *data_rd, size_t size) { if (size == 0) { return ESP_OK; } i2c_cmd_handle_t cmd = i2c_cmd_link_create(); i2c_master_start(cmd); i2c_master_write_byte(cmd, (ESP_SLAVE_ADDR << 1) | READ_BIT, ACK_CHECK_EN); if (size > 1) { i2c_master_read(cmd, data_rd, size - 1, ACK_VAL); } i2c_master_read_byte(cmd, data_rd + size - 1, NACK_VAL); i2c_master_stop(cmd); esp_err_t ret = i2c_master_cmd_begin(i2c_num, cmd, 1000 / portTICK_RATE_MS); i2c_cmd_link_delete(cmd); return ret; }
[ "static", "esp_err_t", "i2c_master_read_slave", "(", "i2c_port_t", "i2c_num", ",", "uint8_t", "*", "data_rd", ",", "size_t", "size", ")", "{", "if", "(", "size", "==", "0", ")", "{", "return", "ESP_OK", ";", "}", "i2c_cmd_handle_t", "cmd", "=", "i2c_cmd_link_create", "(", ")", ";", "i2c_master_start", "(", "cmd", ")", ";", "i2c_master_write_byte", "(", "cmd", ",", "(", "ESP_SLAVE_ADDR", "<<", "1", ")", "|", "READ_BIT", ",", "ACK_CHECK_EN", ")", ";", "if", "(", "size", ">", "1", ")", "{", "i2c_master_read", "(", "cmd", ",", "data_rd", ",", "size", "-", "1", ",", "ACK_VAL", ")", ";", "}", "i2c_master_read_byte", "(", "cmd", ",", "data_rd", "+", "size", "-", "1", ",", "NACK_VAL", ")", ";", "i2c_master_stop", "(", "cmd", ")", ";", "esp_err_t", "ret", "=", "i2c_master_cmd_begin", "(", "i2c_num", ",", "cmd", ",", "1000", "/", "portTICK_RATE_MS", ")", ";", "i2c_cmd_link_delete", "(", "cmd", ")", ";", "return", "ret", ";", "}" ]
@brief test code to read esp-i2c-slave We need to fill the buffer of esp slave device, then master can read them out.
[ "@brief", "test", "code", "to", "read", "esp", "-", "i2c", "-", "slave", "We", "need", "to", "fill", "the", "buffer", "of", "esp", "slave", "device", "then", "master", "can", "read", "them", "out", "." ]
[]
[ { "param": "i2c_num", "type": "i2c_port_t" }, { "param": "data_rd", "type": "uint8_t" }, { "param": "size", "type": "size_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "i2c_num", "type": "i2c_port_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data_rd", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8b08700ac185a98daf9f5b0b8a1aa7eb3d45f17a
rmleme/mac-2166
ep3/ep3a.c
[ "MIT" ]
C
potencia
double
double potencia(double x, int n) { double produto = 1; int indice; for (indice = 1; indice <= n; indice++) produto *= x; return produto; }
// Funcao: potencia // Entrada: a base x e o expoente n. // Saida: o resultado de x elevado a n. // Descricao: exponencia um numero real.
potencia Entrada: a base x e o expoente n. Saida: o resultado de x elevado a n. Descricao: exponencia um numero real.
[ "potencia", "Entrada", ":", "a", "base", "x", "e", "o", "expoente", "n", ".", "Saida", ":", "o", "resultado", "de", "x", "elevado", "a", "n", ".", "Descricao", ":", "exponencia", "um", "numero", "real", "." ]
double potencia(double x, int n) { double produto = 1; int indice; for (indice = 1; indice <= n; indice++) produto *= x; return produto; }
[ "double", "potencia", "(", "double", "x", ",", "int", "n", ")", "{", "double", "produto", "=", "1", ";", "int", "indice", ";", "for", "(", "indice", "=", "1", ";", "indice", "<=", "n", ";", "indice", "++", ")", "produto", "*=", "x", ";", "return", "produto", ";", "}" ]
Funcao: potencia Entrada: a base x e o expoente n. Saida: o resultado de x elevado a n. Descricao: exponencia um numero real.
[ "Funcao", ":", "potencia", "Entrada", ":", "a", "base", "x", "e", "o", "expoente", "n", ".", "Saida", ":", "o", "resultado", "de", "x", "elevado", "a", "n", ".", "Descricao", ":", "exponencia", "um", "numero", "real", "." ]
[]
[ { "param": "x", "type": "double" }, { "param": "n", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "x", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "n", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
bd0e3138a0e14fc11564193f50056ccdf0906fe1
Roninkoi/Scicodes
eigenroot.c
[ "MIT" ]
C
eigenroots
complex
complex *eigenroots(int n, double *p) { int n1 = n + 1; complex *A = (complex *) calloc(sizeof(complex), n1 * n1); for (int ii = 0; ii < n - 1; ++ii) A[(ii + 1) + ii * n] = 1.0; // transpose for (int i = 0; i < n; ++i) { // assign polynomial coefficients to top row A[i * n] = -p[n1 - i - 2] / p[n1 - 1]; // transpose } complex *roots = (complex *) malloc(sizeof(complex) * n); // eigenvalues complex *work = (complex *) malloc(sizeof(complex) * 2 * n); char jn = 'N'; // no eigenvectors int ok; int n2 = 2 * n; // use LAPACK to compute complex eigenvalues zgeev_(&jn, &jn, &n, A, &n, roots, NULL, &n, NULL, &n, work, &n2, work, &ok); free(work); free(A); return roots; }
/* * Calculates roots of nth degree real polynomial p using * the eigenvalue method. * Roots returned as a complex array, which is allocated. */
Calculates roots of nth degree real polynomial p using the eigenvalue method. Roots returned as a complex array, which is allocated.
[ "Calculates", "roots", "of", "nth", "degree", "real", "polynomial", "p", "using", "the", "eigenvalue", "method", ".", "Roots", "returned", "as", "a", "complex", "array", "which", "is", "allocated", "." ]
complex *eigenroots(int n, double *p) { int n1 = n + 1; complex *A = (complex *) calloc(sizeof(complex), n1 * n1); for (int ii = 0; ii < n - 1; ++ii) A[(ii + 1) + ii * n] = 1.0; for (int i = 0; i < n; ++i) { A[i * n] = -p[n1 - i - 2] / p[n1 - 1]; } complex *roots = (complex *) malloc(sizeof(complex) * n); complex *work = (complex *) malloc(sizeof(complex) * 2 * n); char jn = 'N'; int ok; int n2 = 2 * n; zgeev_(&jn, &jn, &n, A, &n, roots, NULL, &n, NULL, &n, work, &n2, work, &ok); free(work); free(A); return roots; }
[ "complex", "*", "eigenroots", "(", "int", "n", ",", "double", "*", "p", ")", "{", "int", "n1", "=", "n", "+", "1", ";", "complex", "*", "A", "=", "(", "complex", "*", ")", "calloc", "(", "sizeof", "(", "complex", ")", ",", "n1", "*", "n1", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "n", "-", "1", ";", "++", "ii", ")", "A", "[", "(", "ii", "+", "1", ")", "+", "ii", "*", "n", "]", "=", "1.0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "n", ";", "++", "i", ")", "{", "A", "[", "i", "*", "n", "]", "=", "-", "p", "[", "n1", "-", "i", "-", "2", "]", "/", "p", "[", "n1", "-", "1", "]", ";", "}", "complex", "*", "roots", "=", "(", "complex", "*", ")", "malloc", "(", "sizeof", "(", "complex", ")", "*", "n", ")", ";", "complex", "*", "work", "=", "(", "complex", "*", ")", "malloc", "(", "sizeof", "(", "complex", ")", "*", "2", "*", "n", ")", ";", "char", "jn", "=", "'", "'", ";", "int", "ok", ";", "int", "n2", "=", "2", "*", "n", ";", "zgeev_", "(", "&", "jn", ",", "&", "jn", ",", "&", "n", ",", "A", ",", "&", "n", ",", "roots", ",", "NULL", ",", "&", "n", ",", "NULL", ",", "&", "n", ",", "work", ",", "&", "n2", ",", "work", ",", "&", "ok", ")", ";", "free", "(", "work", ")", ";", "free", "(", "A", ")", ";", "return", "roots", ";", "}" ]
Calculates roots of nth degree real polynomial p using the eigenvalue method.
[ "Calculates", "roots", "of", "nth", "degree", "real", "polynomial", "p", "using", "the", "eigenvalue", "method", "." ]
[ "// transpose", "// assign polynomial coefficients to top row", "// transpose", "// eigenvalues", "// no eigenvectors", "// use LAPACK to compute complex eigenvalues" ]
[ { "param": "n", "type": "int" }, { "param": "p", "type": "double" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "n", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
72e8d4d20d66b826dd9eef0a8caa6c411eb6e044
Roninkoi/Scicodes
richardson.c
[ "MIT" ]
C
richardson
double
double richardson(double x, int n, double h) { double *dj = calloc(sizeof(double), n+1); // row j double *djj = calloc(sizeof(double), n+1); // new row j double dij = 0.0; double hh = h; // step size for (int i = 0; i <= n; ++i) { dij = central_difference(x, hh); djj[0] = dij; // first in row always CD for(int j = 0; j < i; ++j) { dij += (dij - dj[j]) / (pow(4.0, j + 1) - 1.0); // d(i, j + 1) djj[j+1] = dij; // calculate new row } for (int jj = 0; jj < n; ++jj) dj[jj] = djj[jj]; // copy new row hh /= 2.0; // h / 2^i } free(dj); free(djj); return dij; }
/* * Derivative f'(x) using Richardson extrapolation * with parameters n and h. */
Derivative f'(x) using Richardson extrapolation with parameters n and h.
[ "Derivative", "f", "'", "(", "x", ")", "using", "Richardson", "extrapolation", "with", "parameters", "n", "and", "h", "." ]
double richardson(double x, int n, double h) { double *dj = calloc(sizeof(double), n+1); double *djj = calloc(sizeof(double), n+1); double dij = 0.0; double hh = h; for (int i = 0; i <= n; ++i) { dij = central_difference(x, hh); djj[0] = dij; for(int j = 0; j < i; ++j) { dij += (dij - dj[j]) / (pow(4.0, j + 1) - 1.0); djj[j+1] = dij; } for (int jj = 0; jj < n; ++jj) dj[jj] = djj[jj]; hh /= 2.0; } free(dj); free(djj); return dij; }
[ "double", "richardson", "(", "double", "x", ",", "int", "n", ",", "double", "h", ")", "{", "double", "*", "dj", "=", "calloc", "(", "sizeof", "(", "double", ")", ",", "n", "+", "1", ")", ";", "double", "*", "djj", "=", "calloc", "(", "sizeof", "(", "double", ")", ",", "n", "+", "1", ")", ";", "double", "dij", "=", "0.0", ";", "double", "hh", "=", "h", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<=", "n", ";", "++", "i", ")", "{", "dij", "=", "central_difference", "(", "x", ",", "hh", ")", ";", "djj", "[", "0", "]", "=", "dij", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "i", ";", "++", "j", ")", "{", "dij", "+=", "(", "dij", "-", "dj", "[", "j", "]", ")", "/", "(", "pow", "(", "4.0", ",", "j", "+", "1", ")", "-", "1.0", ")", ";", "djj", "[", "j", "+", "1", "]", "=", "dij", ";", "}", "for", "(", "int", "jj", "=", "0", ";", "jj", "<", "n", ";", "++", "jj", ")", "dj", "[", "jj", "]", "=", "djj", "[", "jj", "]", ";", "hh", "/=", "2.0", ";", "}", "free", "(", "dj", ")", ";", "free", "(", "djj", ")", ";", "return", "dij", ";", "}" ]
Derivative f'(x) using Richardson extrapolation with parameters n and h.
[ "Derivative", "f", "'", "(", "x", ")", "using", "Richardson", "extrapolation", "with", "parameters", "n", "and", "h", "." ]
[ "// row j", "// new row j", "// step size", "// first in row always CD", "// d(i, j + 1)", "// calculate new row", "// copy new row", "// h / 2^i" ]
[ { "param": "x", "type": "double" }, { "param": "n", "type": "int" }, { "param": "h", "type": "double" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "x", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "n", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "h", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
560bb8dc01998106b8572304ec83823fd3deecae
Roninkoi/Scicodes
sh.c
[ "MIT" ]
C
Pgn
float
float Pgn(int l, int m, float x) { float p0 = 0.; float p1 = 0.; float p2 = 0.; for (int k = l; k >= 0; --k) { float k1 = (float) (k + 1); float m1 = (float) (2 * m) + k1; float m2 = (float) (2 * (m + k) + 1); p2 = p1; p1 = p0; p0 = 0.; if (l == m + k) p0 += 1.; float u0 = sqrt( (m2 * (m2 + 2.0)) / (k1 * m1) ); float u1 = sqrt( (k1 * m1 * (m2 + 4.0)) / ((k1 + 1.0) * (m1 + 1.0) * m2) ); p0 += p1 * u0 * x; p0 += -u1 * p2; } for (int k = 1; k <= m; ++k) { p0 *= sqrt( (1.0 - 0.5/(float) k) * (1.0 - x) * (1.0 + x) ); } p0 *= sqrt((0.5 * (float) m + 0.25)/PI); return p0; }
// Clenshaw Legendre normalized (Spherical harmonics)
Clenshaw Legendre normalized (Spherical harmonics)
[ "Clenshaw", "Legendre", "normalized", "(", "Spherical", "harmonics", ")" ]
float Pgn(int l, int m, float x) { float p0 = 0.; float p1 = 0.; float p2 = 0.; for (int k = l; k >= 0; --k) { float k1 = (float) (k + 1); float m1 = (float) (2 * m) + k1; float m2 = (float) (2 * (m + k) + 1); p2 = p1; p1 = p0; p0 = 0.; if (l == m + k) p0 += 1.; float u0 = sqrt( (m2 * (m2 + 2.0)) / (k1 * m1) ); float u1 = sqrt( (k1 * m1 * (m2 + 4.0)) / ((k1 + 1.0) * (m1 + 1.0) * m2) ); p0 += p1 * u0 * x; p0 += -u1 * p2; } for (int k = 1; k <= m; ++k) { p0 *= sqrt( (1.0 - 0.5/(float) k) * (1.0 - x) * (1.0 + x) ); } p0 *= sqrt((0.5 * (float) m + 0.25)/PI); return p0; }
[ "float", "Pgn", "(", "int", "l", ",", "int", "m", ",", "float", "x", ")", "{", "float", "p0", "=", "0.", ";", "float", "p1", "=", "0.", ";", "float", "p2", "=", "0.", ";", "for", "(", "int", "k", "=", "l", ";", "k", ">=", "0", ";", "--", "k", ")", "{", "float", "k1", "=", "(", "float", ")", "(", "k", "+", "1", ")", ";", "float", "m1", "=", "(", "float", ")", "(", "2", "*", "m", ")", "+", "k1", ";", "float", "m2", "=", "(", "float", ")", "(", "2", "*", "(", "m", "+", "k", ")", "+", "1", ")", ";", "p2", "=", "p1", ";", "p1", "=", "p0", ";", "p0", "=", "0.", ";", "if", "(", "l", "==", "m", "+", "k", ")", "p0", "+=", "1.", ";", "float", "u0", "=", "sqrt", "(", "(", "m2", "*", "(", "m2", "+", "2.0", ")", ")", "/", "(", "k1", "*", "m1", ")", ")", ";", "float", "u1", "=", "sqrt", "(", "(", "k1", "*", "m1", "*", "(", "m2", "+", "4.0", ")", ")", "/", "(", "(", "k1", "+", "1.0", ")", "*", "(", "m1", "+", "1.0", ")", "*", "m2", ")", ")", ";", "p0", "+=", "p1", "*", "u0", "*", "x", ";", "p0", "+=", "-", "u1", "*", "p2", ";", "}", "for", "(", "int", "k", "=", "1", ";", "k", "<=", "m", ";", "++", "k", ")", "{", "p0", "*=", "sqrt", "(", "(", "1.0", "-", "0.5", "/", "(", "float", ")", "k", ")", "*", "(", "1.0", "-", "x", ")", "*", "(", "1.0", "+", "x", ")", ")", ";", "}", "p0", "*=", "sqrt", "(", "(", "0.5", "*", "(", "float", ")", "m", "+", "0.25", ")", "/", "PI", ")", ";", "return", "p0", ";", "}" ]
Clenshaw Legendre normalized (Spherical harmonics)
[ "Clenshaw", "Legendre", "normalized", "(", "Spherical", "harmonics", ")" ]
[]
[ { "param": "l", "type": "int" }, { "param": "m", "type": "int" }, { "param": "x", "type": "float" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "l", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "m", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d8761fb46e235e51704660828f1c278b4c57f5f3
Roninkoi/Scicodes
newbiroot.c
[ "MIT" ]
C
newton_f
double
double newton_f(double x0) { double x = x0; int conv = 0; for (int i = 0; i < NEWTON_MAXIT; ++i) { double y = f(x); double dy = fp(x); if (fabs(dy) <= NEWTON_EPS) { fprintf(stderr, "Newton error: Small f'(x)!\n"); break; } double x1 = x - y / dy; // advance if (fabs(x1 - x) <= NEWTON_TOL) { conv = 1; // converged break; } x = x1; // new value of x } if (!conv) fprintf(stderr, "Newton error: Didn't converge!\n"); return x; }
/* * Calculates root of f(x) using Newton's method * based on initial guess x0. */
Calculates root of f(x) using Newton's method based on initial guess x0.
[ "Calculates", "root", "of", "f", "(", "x", ")", "using", "Newton", "'", "s", "method", "based", "on", "initial", "guess", "x0", "." ]
double newton_f(double x0) { double x = x0; int conv = 0; for (int i = 0; i < NEWTON_MAXIT; ++i) { double y = f(x); double dy = fp(x); if (fabs(dy) <= NEWTON_EPS) { fprintf(stderr, "Newton error: Small f'(x)!\n"); break; } double x1 = x - y / dy; if (fabs(x1 - x) <= NEWTON_TOL) { conv = 1; break; } x = x1; } if (!conv) fprintf(stderr, "Newton error: Didn't converge!\n"); return x; }
[ "double", "newton_f", "(", "double", "x0", ")", "{", "double", "x", "=", "x0", ";", "int", "conv", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "NEWTON_MAXIT", ";", "++", "i", ")", "{", "double", "y", "=", "f", "(", "x", ")", ";", "double", "dy", "=", "fp", "(", "x", ")", ";", "if", "(", "fabs", "(", "dy", ")", "<=", "NEWTON_EPS", ")", "{", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ")", ";", "break", ";", "}", "double", "x1", "=", "x", "-", "y", "/", "dy", ";", "if", "(", "fabs", "(", "x1", "-", "x", ")", "<=", "NEWTON_TOL", ")", "{", "conv", "=", "1", ";", "break", ";", "}", "x", "=", "x1", ";", "}", "if", "(", "!", "conv", ")", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ")", ";", "return", "x", ";", "}" ]
Calculates root of f(x) using Newton's method based on initial guess x0.
[ "Calculates", "root", "of", "f", "(", "x", ")", "using", "Newton", "'", "s", "method", "based", "on", "initial", "guess", "x0", "." ]
[ "// advance", "// converged", "// new value of x" ]
[ { "param": "x0", "type": "double" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "x0", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
eac1551c6af1c498d85475c066e9ad18b8c374fa
Roninkoi/Scicodes
spline.c
[ "MIT" ]
C
cubic_spline
void
void cubic_spline(double *x, double *y, double bc, int n, double *z) { double *h = malloc(sizeof(double) * n); double *b = malloc(sizeof(double) * n); double *u = malloc(sizeof(double) * n); double *v = malloc(sizeof(double) * n); // solve system of equations for (int i = 0; i < n - 1; ++i) { h[i] = x[i+1] - x[i]; b[i] = (y[i+1] - y[i]) / h[i]; } u[1] = 2.0 * (h[1] + h[0]); v[1] = 6.0 * (b[1] - b[0]); for (int i = 2; i < n - 1; ++i) { u[i] = 2.0 * (h[i] + h[i-1]) - h[i-1] * h[i-1] / u[i-1]; v[i] = 6.0 * (b[i] - b[i-1]) - h[i-1] * v[i-1] / u[i-1]; } z[0] = bc; // set boundary conditions z[n-1] = bc; for (int i = n - 2; i >= 1; --i) { z[i] = (v[i] - h[i] * z[i+1]) / u[i]; // calculate coefficients } free(h); free(b); free(u); free(v); }
/* * Does cubic spline interpolation for n points (x, y) with * the boundary condition bc at x0 and xn. Returns coeffients z. */
Does cubic spline interpolation for n points (x, y) with the boundary condition bc at x0 and xn. Returns coeffients z.
[ "Does", "cubic", "spline", "interpolation", "for", "n", "points", "(", "x", "y", ")", "with", "the", "boundary", "condition", "bc", "at", "x0", "and", "xn", ".", "Returns", "coeffients", "z", "." ]
void cubic_spline(double *x, double *y, double bc, int n, double *z) { double *h = malloc(sizeof(double) * n); double *b = malloc(sizeof(double) * n); double *u = malloc(sizeof(double) * n); double *v = malloc(sizeof(double) * n); for (int i = 0; i < n - 1; ++i) { h[i] = x[i+1] - x[i]; b[i] = (y[i+1] - y[i]) / h[i]; } u[1] = 2.0 * (h[1] + h[0]); v[1] = 6.0 * (b[1] - b[0]); for (int i = 2; i < n - 1; ++i) { u[i] = 2.0 * (h[i] + h[i-1]) - h[i-1] * h[i-1] / u[i-1]; v[i] = 6.0 * (b[i] - b[i-1]) - h[i-1] * v[i-1] / u[i-1]; } z[0] = bc; z[n-1] = bc; for (int i = n - 2; i >= 1; --i) { z[i] = (v[i] - h[i] * z[i+1]) / u[i]; } free(h); free(b); free(u); free(v); }
[ "void", "cubic_spline", "(", "double", "*", "x", ",", "double", "*", "y", ",", "double", "bc", ",", "int", "n", ",", "double", "*", "z", ")", "{", "double", "*", "h", "=", "malloc", "(", "sizeof", "(", "double", ")", "*", "n", ")", ";", "double", "*", "b", "=", "malloc", "(", "sizeof", "(", "double", ")", "*", "n", ")", ";", "double", "*", "u", "=", "malloc", "(", "sizeof", "(", "double", ")", "*", "n", ")", ";", "double", "*", "v", "=", "malloc", "(", "sizeof", "(", "double", ")", "*", "n", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "n", "-", "1", ";", "++", "i", ")", "{", "h", "[", "i", "]", "=", "x", "[", "i", "+", "1", "]", "-", "x", "[", "i", "]", ";", "b", "[", "i", "]", "=", "(", "y", "[", "i", "+", "1", "]", "-", "y", "[", "i", "]", ")", "/", "h", "[", "i", "]", ";", "}", "u", "[", "1", "]", "=", "2.0", "*", "(", "h", "[", "1", "]", "+", "h", "[", "0", "]", ")", ";", "v", "[", "1", "]", "=", "6.0", "*", "(", "b", "[", "1", "]", "-", "b", "[", "0", "]", ")", ";", "for", "(", "int", "i", "=", "2", ";", "i", "<", "n", "-", "1", ";", "++", "i", ")", "{", "u", "[", "i", "]", "=", "2.0", "*", "(", "h", "[", "i", "]", "+", "h", "[", "i", "-", "1", "]", ")", "-", "h", "[", "i", "-", "1", "]", "*", "h", "[", "i", "-", "1", "]", "/", "u", "[", "i", "-", "1", "]", ";", "v", "[", "i", "]", "=", "6.0", "*", "(", "b", "[", "i", "]", "-", "b", "[", "i", "-", "1", "]", ")", "-", "h", "[", "i", "-", "1", "]", "*", "v", "[", "i", "-", "1", "]", "/", "u", "[", "i", "-", "1", "]", ";", "}", "z", "[", "0", "]", "=", "bc", ";", "z", "[", "n", "-", "1", "]", "=", "bc", ";", "for", "(", "int", "i", "=", "n", "-", "2", ";", "i", ">=", "1", ";", "--", "i", ")", "{", "z", "[", "i", "]", "=", "(", "v", "[", "i", "]", "-", "h", "[", "i", "]", "*", "z", "[", "i", "+", "1", "]", ")", "/", "u", "[", "i", "]", ";", "}", "free", "(", "h", ")", ";", "free", "(", "b", ")", ";", "free", "(", "u", ")", ";", "free", "(", "v", ")", ";", "}" ]
Does cubic spline interpolation for n points (x, y) with the boundary condition bc at x0 and xn.
[ "Does", "cubic", "spline", "interpolation", "for", "n", "points", "(", "x", "y", ")", "with", "the", "boundary", "condition", "bc", "at", "x0", "and", "xn", "." ]
[ "// solve system of equations", "// set boundary conditions", "// calculate coefficients" ]
[ { "param": "x", "type": "double" }, { "param": "y", "type": "double" }, { "param": "bc", "type": "double" }, { "param": "n", "type": "int" }, { "param": "z", "type": "double" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "x", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bc", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "n", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "z", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
eac1551c6af1c498d85475c066e9ad18b8c374fa
Roninkoi/Scicodes
spline.c
[ "MIT" ]
C
cubic_spline_eval
double
double cubic_spline_eval(double *xi, double *yi, double x, double *z, int n) { int i = n - 1; for (; i >= 0; --i) { // search for point if (xi[i] <= x) break; } double h = xi[i+1] - xi[i]; // coeffs double b = -h * z[i+1] / 6.0 - h * z[i] / 3.0 + (yi[i+1] - yi[i]) / h; double xd = x - xi[i]; // x diff return yi[i] + xd * (b + xd * (z[i] / 2.0 + xd * (z[i+1]-z[i]) / (6.0 * h))); }
/* * Evaluates cubic spline interpolation for n points (xi, yi) at x * using coefficients z. */
Evaluates cubic spline interpolation for n points (xi, yi) at x using coefficients z.
[ "Evaluates", "cubic", "spline", "interpolation", "for", "n", "points", "(", "xi", "yi", ")", "at", "x", "using", "coefficients", "z", "." ]
double cubic_spline_eval(double *xi, double *yi, double x, double *z, int n) { int i = n - 1; for (; i >= 0; --i) { if (xi[i] <= x) break; } double h = xi[i+1] - xi[i]; double b = -h * z[i+1] / 6.0 - h * z[i] / 3.0 + (yi[i+1] - yi[i]) / h; double xd = x - xi[i]; return yi[i] + xd * (b + xd * (z[i] / 2.0 + xd * (z[i+1]-z[i]) / (6.0 * h))); }
[ "double", "cubic_spline_eval", "(", "double", "*", "xi", ",", "double", "*", "yi", ",", "double", "x", ",", "double", "*", "z", ",", "int", "n", ")", "{", "int", "i", "=", "n", "-", "1", ";", "for", "(", ";", "i", ">=", "0", ";", "--", "i", ")", "{", "if", "(", "xi", "[", "i", "]", "<=", "x", ")", "break", ";", "}", "double", "h", "=", "xi", "[", "i", "+", "1", "]", "-", "xi", "[", "i", "]", ";", "double", "b", "=", "-", "h", "*", "z", "[", "i", "+", "1", "]", "/", "6.0", "-", "h", "*", "z", "[", "i", "]", "/", "3.0", "+", "(", "yi", "[", "i", "+", "1", "]", "-", "yi", "[", "i", "]", ")", "/", "h", ";", "double", "xd", "=", "x", "-", "xi", "[", "i", "]", ";", "return", "yi", "[", "i", "]", "+", "xd", "*", "(", "b", "+", "xd", "*", "(", "z", "[", "i", "]", "/", "2.0", "+", "xd", "*", "(", "z", "[", "i", "+", "1", "]", "-", "z", "[", "i", "]", ")", "/", "(", "6.0", "*", "h", ")", ")", ")", ";", "}" ]
Evaluates cubic spline interpolation for n points (xi, yi) at x using coefficients z.
[ "Evaluates", "cubic", "spline", "interpolation", "for", "n", "points", "(", "xi", "yi", ")", "at", "x", "using", "coefficients", "z", "." ]
[ "// search for point", "// coeffs", "// x diff" ]
[ { "param": "xi", "type": "double" }, { "param": "yi", "type": "double" }, { "param": "x", "type": "double" }, { "param": "z", "type": "double" }, { "param": "n", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "xi", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "yi", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "z", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "n", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
392efb98f6af6c7d2d729279aae98d44ece316d9
Roninkoi/Scicodes
simpson.c
[ "MIT" ]
C
simpson1
double
double simpson1(double (*f)(double), double a, double b) { return (b - a) / 6. * ((*f)(a) + 4. * (*f)((a + b) / 2.) + (*f)(b) ); }
/* * Simpson's rule for numerical integration of interval [a, b] */
Simpson's rule for numerical integration of interval [a, b]
[ "Simpson", "'", "s", "rule", "for", "numerical", "integration", "of", "interval", "[", "a", "b", "]" ]
double simpson1(double (*f)(double), double a, double b) { return (b - a) / 6. * ((*f)(a) + 4. * (*f)((a + b) / 2.) + (*f)(b) ); }
[ "double", "simpson1", "(", "double", "(", "*", "f", ")", "(", "double", ")", ",", "double", "a", ",", "double", "b", ")", "{", "return", "(", "b", "-", "a", ")", "/", "6.", "*", "(", "(", "*", "f", ")", "(", "a", ")", "+", "4.", "*", "(", "*", "f", ")", "(", "(", "a", "+", "b", ")", "/", "2.", ")", "+", "(", "*", "f", ")", "(", "b", ")", ")", ";", "}" ]
Simpson's rule for numerical integration of interval [a, b]
[ "Simpson", "'", "s", "rule", "for", "numerical", "integration", "of", "interval", "[", "a", "b", "]" ]
[]
[ { "param": "f", "type": "double" }, { "param": "a", "type": "double" }, { "param": "b", "type": "double" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "f", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "a", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "b", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
392efb98f6af6c7d2d729279aae98d44ece316d9
Roninkoi/Scicodes
simpson.c
[ "MIT" ]
C
rsimpson
double
double rsimpson(double (*f)(double), double a, double b, double tol, int rd) { double s1 = simpson1(f, a, b); // one Simpson's rule double s2 = simpson2(f, a, b); // two Simpson's rules if (rd >= SIMPSON_MAX) // max level reached? return s2; if (fabs(s2 - s1) < 15. * tol) // tolerance reached? return s2 + (s2 - s1) / 15.; // left division double left = rsimpson(f, a, (a + b) / 2., tol / 2., rd + 1); // right division double right = rsimpson(f, (a + b) / 2., b, tol / 2., rd + 1); return left + right; }
/* * Recursive Simpson's method. Current recursion depth is rd. */
Recursive Simpson's method. Current recursion depth is rd.
[ "Recursive", "Simpson", "'", "s", "method", ".", "Current", "recursion", "depth", "is", "rd", "." ]
double rsimpson(double (*f)(double), double a, double b, double tol, int rd) { double s1 = simpson1(f, a, b); double s2 = simpson2(f, a, b); if (rd >= SIMPSON_MAX) return s2; if (fabs(s2 - s1) < 15. * tol) return s2 + (s2 - s1) / 15.; double left = rsimpson(f, a, (a + b) / 2., tol / 2., rd + 1); double right = rsimpson(f, (a + b) / 2., b, tol / 2., rd + 1); return left + right; }
[ "double", "rsimpson", "(", "double", "(", "*", "f", ")", "(", "double", ")", ",", "double", "a", ",", "double", "b", ",", "double", "tol", ",", "int", "rd", ")", "{", "double", "s1", "=", "simpson1", "(", "f", ",", "a", ",", "b", ")", ";", "double", "s2", "=", "simpson2", "(", "f", ",", "a", ",", "b", ")", ";", "if", "(", "rd", ">=", "SIMPSON_MAX", ")", "return", "s2", ";", "if", "(", "fabs", "(", "s2", "-", "s1", ")", "<", "15.", "*", "tol", ")", "return", "s2", "+", "(", "s2", "-", "s1", ")", "/", "15.", ";", "double", "left", "=", "rsimpson", "(", "f", ",", "a", ",", "(", "a", "+", "b", ")", "/", "2.", ",", "tol", "/", "2.", ",", "rd", "+", "1", ")", ";", "double", "right", "=", "rsimpson", "(", "f", ",", "(", "a", "+", "b", ")", "/", "2.", ",", "b", ",", "tol", "/", "2.", ",", "rd", "+", "1", ")", ";", "return", "left", "+", "right", ";", "}" ]
Recursive Simpson's method.
[ "Recursive", "Simpson", "'", "s", "method", "." ]
[ "// one Simpson's rule", "// two Simpson's rules", "// max level reached?", "// tolerance reached?", "// left division", "// right division" ]
[ { "param": "f", "type": "double" }, { "param": "a", "type": "double" }, { "param": "b", "type": "double" }, { "param": "tol", "type": "double" }, { "param": "rd", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "f", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "a", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "b", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "tol", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rd", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
eda3c8b7a072e3a3e071a58badbaf1a25efe4991
JacobMillner/SmashTrainingBot
Arduino/include/Descriptors.h
[ "MIT" ]
C
CALLBACK_USB_GetDescriptor
uint16_t
uint16_t CALLBACK_USB_GetDescriptor( const uint16_t wValue, const uint16_t wIndex, const void** const DescriptorAddress ) { const uint8_t DescriptorType = (wValue >> 8); const uint8_t DescriptorNumber = (wValue & 0xFF); const void* Address = NULL; uint16_t Size = NO_DESCRIPTOR; switch (DescriptorType) { case DTYPE_Device: Address = &DeviceDescriptor; Size = sizeof(USB_Descriptor_Device_t); break; case DTYPE_Configuration: Address = &ConfigurationDescriptor; Size = sizeof(USB_Descriptor_Configuration_t); break; case DTYPE_String: switch (DescriptorNumber) { case STRING_ID_Language: Address = &LanguageString; Size = pgm_read_byte(&LanguageString.Header.Size); break; case STRING_ID_Manufacturer: Address = &ManufacturerString; Size = pgm_read_byte(&ManufacturerString.Header.Size); break; case STRING_ID_Product: Address = &ProductString; Size = pgm_read_byte(&ProductString.Header.Size); break; } break; case DTYPE_HID: Address = &ConfigurationDescriptor.HID_JoystickHID; Size = sizeof(USB_HID_Descriptor_HID_t); break; case DTYPE_Report: Address = &JoystickReport; Size = sizeof(JoystickReport); break; } *DescriptorAddress = Address; return Size; }
// USB Device Callback - Get Descriptor
USB Device Callback - Get Descriptor
[ "USB", "Device", "Callback", "-", "Get", "Descriptor" ]
uint16_t CALLBACK_USB_GetDescriptor( const uint16_t wValue, const uint16_t wIndex, const void** const DescriptorAddress ) { const uint8_t DescriptorType = (wValue >> 8); const uint8_t DescriptorNumber = (wValue & 0xFF); const void* Address = NULL; uint16_t Size = NO_DESCRIPTOR; switch (DescriptorType) { case DTYPE_Device: Address = &DeviceDescriptor; Size = sizeof(USB_Descriptor_Device_t); break; case DTYPE_Configuration: Address = &ConfigurationDescriptor; Size = sizeof(USB_Descriptor_Configuration_t); break; case DTYPE_String: switch (DescriptorNumber) { case STRING_ID_Language: Address = &LanguageString; Size = pgm_read_byte(&LanguageString.Header.Size); break; case STRING_ID_Manufacturer: Address = &ManufacturerString; Size = pgm_read_byte(&ManufacturerString.Header.Size); break; case STRING_ID_Product: Address = &ProductString; Size = pgm_read_byte(&ProductString.Header.Size); break; } break; case DTYPE_HID: Address = &ConfigurationDescriptor.HID_JoystickHID; Size = sizeof(USB_HID_Descriptor_HID_t); break; case DTYPE_Report: Address = &JoystickReport; Size = sizeof(JoystickReport); break; } *DescriptorAddress = Address; return Size; }
[ "uint16_t", "CALLBACK_USB_GetDescriptor", "(", "const", "uint16_t", "wValue", ",", "const", "uint16_t", "wIndex", ",", "const", "void", "*", "*", "const", "DescriptorAddress", ")", "{", "const", "uint8_t", "DescriptorType", "=", "(", "wValue", ">>", "8", ")", ";", "const", "uint8_t", "DescriptorNumber", "=", "(", "wValue", "&", "0xFF", ")", ";", "const", "void", "*", "Address", "=", "NULL", ";", "uint16_t", "Size", "=", "NO_DESCRIPTOR", ";", "switch", "(", "DescriptorType", ")", "{", "case", "DTYPE_Device", ":", "Address", "=", "&", "DeviceDescriptor", ";", "Size", "=", "sizeof", "(", "USB_Descriptor_Device_t", ")", ";", "break", ";", "case", "DTYPE_Configuration", ":", "Address", "=", "&", "ConfigurationDescriptor", ";", "Size", "=", "sizeof", "(", "USB_Descriptor_Configuration_t", ")", ";", "break", ";", "case", "DTYPE_String", ":", "switch", "(", "DescriptorNumber", ")", "{", "case", "STRING_ID_Language", ":", "Address", "=", "&", "LanguageString", ";", "Size", "=", "pgm_read_byte", "(", "&", "LanguageString", ".", "Header", ".", "Size", ")", ";", "break", ";", "case", "STRING_ID_Manufacturer", ":", "Address", "=", "&", "ManufacturerString", ";", "Size", "=", "pgm_read_byte", "(", "&", "ManufacturerString", ".", "Header", ".", "Size", ")", ";", "break", ";", "case", "STRING_ID_Product", ":", "Address", "=", "&", "ProductString", ";", "Size", "=", "pgm_read_byte", "(", "&", "ProductString", ".", "Header", ".", "Size", ")", ";", "break", ";", "}", "break", ";", "case", "DTYPE_HID", ":", "Address", "=", "&", "ConfigurationDescriptor", ".", "HID_JoystickHID", ";", "Size", "=", "sizeof", "(", "USB_HID_Descriptor_HID_t", ")", ";", "break", ";", "case", "DTYPE_Report", ":", "Address", "=", "&", "JoystickReport", ";", "Size", "=", "sizeof", "(", "JoystickReport", ")", ";", "break", ";", "}", "*", "DescriptorAddress", "=", "Address", ";", "return", "Size", ";", "}" ]
USB Device Callback - Get Descriptor
[ "USB", "Device", "Callback", "-", "Get", "Descriptor" ]
[]
[ { "param": "wValue", "type": "uint16_t" }, { "param": "wIndex", "type": "uint16_t" }, { "param": "DescriptorAddress", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "wValue", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "wIndex", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "DescriptorAddress", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
468189b07970dd7857040f656804a237f6805f14
JacobMillner/SmashTrainingBot
Arduino/src/Joystick.c
[ "MIT" ]
C
SetupHardware
void
void SetupHardware(void) { // We need to disable watchdog if enabled by bootloader/fuses. disable_watchdog(); // We need to disable clock division before initializing the USB hardware. clock_prescale_set(clock_div_1); // We can then initialize our hardware and peripherals, including the USB stack. USART_Init(19200); // The USB stack should be initialized last. USB_Init(); }
// Configures hardware and peripherals, such as the USB peripherals.
Configures hardware and peripherals, such as the USB peripherals.
[ "Configures", "hardware", "and", "peripherals", "such", "as", "the", "USB", "peripherals", "." ]
void SetupHardware(void) { disable_watchdog(); clock_prescale_set(clock_div_1); USART_Init(19200); USB_Init(); }
[ "void", "SetupHardware", "(", "void", ")", "{", "disable_watchdog", "(", ")", ";", "clock_prescale_set", "(", "clock_div_1", ")", ";", "USART_Init", "(", "19200", ")", ";", "USB_Init", "(", ")", ";", "}" ]
Configures hardware and peripherals, such as the USB peripherals.
[ "Configures", "hardware", "and", "peripherals", "such", "as", "the", "USB", "peripherals", "." ]
[ "// We need to disable watchdog if enabled by bootloader/fuses.", "// We need to disable clock division before initializing the USB hardware.", "// We can then initialize our hardware and peripherals, including the USB stack.", "// The USB stack should be initialized last." ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
468189b07970dd7857040f656804a237f6805f14
JacobMillner/SmashTrainingBot
Arduino/src/Joystick.c
[ "MIT" ]
C
EVENT_USB_Device_ConfigurationChanged
void
void EVENT_USB_Device_ConfigurationChanged(void) { bool ConfigSuccess = true; // We setup the HID report endpoints. ConfigSuccess &= Endpoint_ConfigureEndpoint(JOYSTICK_OUT_EPADDR, EP_TYPE_INTERRUPT, JOYSTICK_EPSIZE, 1); ConfigSuccess &= Endpoint_ConfigureEndpoint(JOYSTICK_IN_EPADDR, EP_TYPE_INTERRUPT, JOYSTICK_EPSIZE, 1); // We can read ConfigSuccess to indicate a success or failure at this point. }
// Fired when the host set the current configuration of the USB device after enumeration.
Fired when the host set the current configuration of the USB device after enumeration.
[ "Fired", "when", "the", "host", "set", "the", "current", "configuration", "of", "the", "USB", "device", "after", "enumeration", "." ]
void EVENT_USB_Device_ConfigurationChanged(void) { bool ConfigSuccess = true; ConfigSuccess &= Endpoint_ConfigureEndpoint(JOYSTICK_OUT_EPADDR, EP_TYPE_INTERRUPT, JOYSTICK_EPSIZE, 1); ConfigSuccess &= Endpoint_ConfigureEndpoint(JOYSTICK_IN_EPADDR, EP_TYPE_INTERRUPT, JOYSTICK_EPSIZE, 1); }
[ "void", "EVENT_USB_Device_ConfigurationChanged", "(", "void", ")", "{", "bool", "ConfigSuccess", "=", "true", ";", "ConfigSuccess", "&=", "Endpoint_ConfigureEndpoint", "(", "JOYSTICK_OUT_EPADDR", ",", "EP_TYPE_INTERRUPT", ",", "JOYSTICK_EPSIZE", ",", "1", ")", ";", "ConfigSuccess", "&=", "Endpoint_ConfigureEndpoint", "(", "JOYSTICK_IN_EPADDR", ",", "EP_TYPE_INTERRUPT", ",", "JOYSTICK_EPSIZE", ",", "1", ")", ";", "}" ]
Fired when the host set the current configuration of the USB device after enumeration.
[ "Fired", "when", "the", "host", "set", "the", "current", "configuration", "of", "the", "USB", "device", "after", "enumeration", "." ]
[ "// We setup the HID report endpoints.", "// We can read ConfigSuccess to indicate a success or failure at this point." ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
468189b07970dd7857040f656804a237f6805f14
JacobMillner/SmashTrainingBot
Arduino/src/Joystick.c
[ "MIT" ]
C
HID_Task
void
void HID_Task(void) { // If the device isn't connected and properly configured, we can't do anything here. if (USB_DeviceState != DEVICE_STATE_Configured) return; // We'll start with the OUT endpoint. Endpoint_SelectEndpoint(JOYSTICK_OUT_EPADDR); // We'll check to see if we received something on the OUT endpoint. if (Endpoint_IsOUTReceived()) { // If we did, and the packet has data, we'll react to it. if (Endpoint_IsReadWriteAllowed()) { // We'll create a place to store our data received from the host. USB_JoystickReport_Output_t JoystickOutputData; // We'll then take in that data, setting it up in our storage. while(Endpoint_Read_Stream_LE(&JoystickOutputData, sizeof(JoystickOutputData), NULL) != ENDPOINT_RWSTREAM_NoError); // At this point, we can react to this data. // However, since we're not doing anything with this data, we abandon it. } // Regardless of whether we reacted to the data, we acknowledge an OUT packet on this endpoint. Endpoint_ClearOUT(); } // We'll then move on to the IN endpoint. Endpoint_SelectEndpoint(JOYSTICK_IN_EPADDR); // We first check to see if the host is ready to accept data. if (Endpoint_IsINReady()) { // We'll create an empty report. USB_JoystickReport_Input_t JoystickInputData; // We'll then populate this report with what we want to send to the host. disable_rx_isr(); if (state == SYNCED) { memcpy(&JoystickInputData, &buffer, sizeof(USB_JoystickReport_Input_t)); send_byte(RESP_USB_ACK); } else { memcpy(&JoystickInputData, &defaultBuf, sizeof(USB_JoystickReport_Input_t)); } enable_rx_isr(); // Once populated, we can output this data to the host. We do this by first writing the data to the control stream. while(Endpoint_Write_Stream_LE(&JoystickInputData, sizeof(JoystickInputData), NULL) != ENDPOINT_RWSTREAM_NoError); // We then send an IN packet on this endpoint. Endpoint_ClearIN(); } }
// Process and deliver data from IN and OUT endpoints.
Process and deliver data from IN and OUT endpoints.
[ "Process", "and", "deliver", "data", "from", "IN", "and", "OUT", "endpoints", "." ]
void HID_Task(void) { if (USB_DeviceState != DEVICE_STATE_Configured) return; Endpoint_SelectEndpoint(JOYSTICK_OUT_EPADDR); if (Endpoint_IsOUTReceived()) { if (Endpoint_IsReadWriteAllowed()) { USB_JoystickReport_Output_t JoystickOutputData; while(Endpoint_Read_Stream_LE(&JoystickOutputData, sizeof(JoystickOutputData), NULL) != ENDPOINT_RWSTREAM_NoError); } Endpoint_ClearOUT(); } Endpoint_SelectEndpoint(JOYSTICK_IN_EPADDR); if (Endpoint_IsINReady()) { USB_JoystickReport_Input_t JoystickInputData; disable_rx_isr(); if (state == SYNCED) { memcpy(&JoystickInputData, &buffer, sizeof(USB_JoystickReport_Input_t)); send_byte(RESP_USB_ACK); } else { memcpy(&JoystickInputData, &defaultBuf, sizeof(USB_JoystickReport_Input_t)); } enable_rx_isr(); while(Endpoint_Write_Stream_LE(&JoystickInputData, sizeof(JoystickInputData), NULL) != ENDPOINT_RWSTREAM_NoError); Endpoint_ClearIN(); } }
[ "void", "HID_Task", "(", "void", ")", "{", "if", "(", "USB_DeviceState", "!=", "DEVICE_STATE_Configured", ")", "return", ";", "Endpoint_SelectEndpoint", "(", "JOYSTICK_OUT_EPADDR", ")", ";", "if", "(", "Endpoint_IsOUTReceived", "(", ")", ")", "{", "if", "(", "Endpoint_IsReadWriteAllowed", "(", ")", ")", "{", "USB_JoystickReport_Output_t", "JoystickOutputData", ";", "while", "(", "Endpoint_Read_Stream_LE", "(", "&", "JoystickOutputData", ",", "sizeof", "(", "JoystickOutputData", ")", ",", "NULL", ")", "!=", "ENDPOINT_RWSTREAM_NoError", ")", ";", "}", "Endpoint_ClearOUT", "(", ")", ";", "}", "Endpoint_SelectEndpoint", "(", "JOYSTICK_IN_EPADDR", ")", ";", "if", "(", "Endpoint_IsINReady", "(", ")", ")", "{", "USB_JoystickReport_Input_t", "JoystickInputData", ";", "disable_rx_isr", "(", ")", ";", "if", "(", "state", "==", "SYNCED", ")", "{", "memcpy", "(", "&", "JoystickInputData", ",", "&", "buffer", ",", "sizeof", "(", "USB_JoystickReport_Input_t", ")", ")", ";", "send_byte", "(", "RESP_USB_ACK", ")", ";", "}", "else", "{", "memcpy", "(", "&", "JoystickInputData", ",", "&", "defaultBuf", ",", "sizeof", "(", "USB_JoystickReport_Input_t", ")", ")", ";", "}", "enable_rx_isr", "(", ")", ";", "while", "(", "Endpoint_Write_Stream_LE", "(", "&", "JoystickInputData", ",", "sizeof", "(", "JoystickInputData", ")", ",", "NULL", ")", "!=", "ENDPOINT_RWSTREAM_NoError", ")", ";", "Endpoint_ClearIN", "(", ")", ";", "}", "}" ]
Process and deliver data from IN and OUT endpoints.
[ "Process", "and", "deliver", "data", "from", "IN", "and", "OUT", "endpoints", "." ]
[ "// If the device isn't connected and properly configured, we can't do anything here.", "// We'll start with the OUT endpoint.", "// We'll check to see if we received something on the OUT endpoint.", "// If we did, and the packet has data, we'll react to it.", "// We'll create a place to store our data received from the host.", "// We'll then take in that data, setting it up in our storage.", "// At this point, we can react to this data.", "// However, since we're not doing anything with this data, we abandon it.", "// Regardless of whether we reacted to the data, we acknowledge an OUT packet on this endpoint.", "// We'll then move on to the IN endpoint.", "// We first check to see if the host is ready to accept data.", "// We'll create an empty report.", "// We'll then populate this report with what we want to send to the host.", "// Once populated, we can output this data to the host. We do this by first writing the data to the control stream.", "// We then send an IN packet on this endpoint." ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
7a9606b987382ed337fc8d15c4a6b6d6e4a51070
airbus-seclab/pok
kernel/core/sched.c
[ "BSD-2-Clause" ]
C
pok_sched_context_switch
void
void pok_sched_context_switch (const uint32_t elected_id) { uint32_t *current_sp; uint32_t new_sp; if (POK_SCHED_CURRENT_THREAD == elected_id) { return; } current_sp = &POK_CURRENT_THREAD.sp; new_sp = pok_threads[elected_id].sp; /* FIXME : current debug session about exceptions-handled */ #ifdef POK_NEEDS_DEBUG_SCHED printf("THRD-Switch %d, sp=0x%x to %d, sp=0x%x\n", POK_SCHED_CURRENT_THREAD, current_sp, elected_id, new_sp); #endif pok_space_switch(POK_CURRENT_THREAD.partition, pok_threads[elected_id].partition); current_thread = elected_id; pok_context_switch(current_sp, new_sp); }
/* * Context-switch function to switch from one thread to another * Rely on architecture-dependent functionnalities (must include arch.h) */
Context-switch function to switch from one thread to another Rely on architecture-dependent functionnalities (must include arch.h)
[ "Context", "-", "switch", "function", "to", "switch", "from", "one", "thread", "to", "another", "Rely", "on", "architecture", "-", "dependent", "functionnalities", "(", "must", "include", "arch", ".", "h", ")" ]
void pok_sched_context_switch (const uint32_t elected_id) { uint32_t *current_sp; uint32_t new_sp; if (POK_SCHED_CURRENT_THREAD == elected_id) { return; } current_sp = &POK_CURRENT_THREAD.sp; new_sp = pok_threads[elected_id].sp; #ifdef POK_NEEDS_DEBUG_SCHED printf("THRD-Switch %d, sp=0x%x to %d, sp=0x%x\n", POK_SCHED_CURRENT_THREAD, current_sp, elected_id, new_sp); #endif pok_space_switch(POK_CURRENT_THREAD.partition, pok_threads[elected_id].partition); current_thread = elected_id; pok_context_switch(current_sp, new_sp); }
[ "void", "pok_sched_context_switch", "(", "const", "uint32_t", "elected_id", ")", "{", "uint32_t", "*", "current_sp", ";", "uint32_t", "new_sp", ";", "if", "(", "POK_SCHED_CURRENT_THREAD", "==", "elected_id", ")", "{", "return", ";", "}", "current_sp", "=", "&", "POK_CURRENT_THREAD", ".", "sp", ";", "new_sp", "=", "pok_threads", "[", "elected_id", "]", ".", "sp", ";", "#ifdef", "POK_NEEDS_DEBUG_SCHED", "printf", "(", "\"", "\\n", "\"", ",", "POK_SCHED_CURRENT_THREAD", ",", "current_sp", ",", "elected_id", ",", "new_sp", ")", ";", "#endif", "pok_space_switch", "(", "POK_CURRENT_THREAD", ".", "partition", ",", "pok_threads", "[", "elected_id", "]", ".", "partition", ")", ";", "current_thread", "=", "elected_id", ";", "pok_context_switch", "(", "current_sp", ",", "new_sp", ")", ";", "}" ]
Context-switch function to switch from one thread to another Rely on architecture-dependent functionnalities (must include arch.h)
[ "Context", "-", "switch", "function", "to", "switch", "from", "one", "thread", "to", "another", "Rely", "on", "architecture", "-", "dependent", "functionnalities", "(", "must", "include", "arch", ".", "h", ")" ]
[ "/* FIXME : current debug session about exceptions-handled */" ]
[ { "param": "elected_id", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "elected_id", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
af6d7b9a653ebaa8f527ee010a51919c97126a58
jtbattle/wangemu
src/i8080.c
[ "MIT" ]
C
i8080_destroy
void
void i8080_destroy(i8080 *cpu) { free(cpu); i8080_log_close(); }
/* destroy a cpu instance */ /* if there is user data, it is the caller's responsibility to free it */
destroy a cpu instance if there is user data, it is the caller's responsibility to free it
[ "destroy", "a", "cpu", "instance", "if", "there", "is", "user", "data", "it", "is", "the", "caller", "'", "s", "responsibility", "to", "free", "it" ]
void i8080_destroy(i8080 *cpu) { free(cpu); i8080_log_close(); }
[ "void", "i8080_destroy", "(", "i8080", "*", "cpu", ")", "{", "free", "(", "cpu", ")", ";", "i8080_log_close", "(", ")", ";", "}" ]
destroy a cpu instance if there is user data, it is the caller's responsibility to free it
[ "destroy", "a", "cpu", "instance", "if", "there", "is", "user", "data", "it", "is", "the", "caller", "'", "s", "responsibility", "to", "free", "it" ]
[]
[ { "param": "cpu", "type": "i8080" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cpu", "type": "i8080", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
af6d7b9a653ebaa8f527ee010a51919c97126a58
jtbattle/wangemu
src/i8080.c
[ "MIT" ]
C
i8080_interrupt
void
void i8080_interrupt(i8080 *cpu, uint8_t op) { if (!INTE) { return; } assert((op & 0xC7) == 0xC7); /* rst n */ INTE = 0; HALT = 0; PUSH(PC); PC = (op & 0x38); /* 00000000 000nnn000 */ }
/* the 8080 can accept any one byte instruction, but traditionally it is * one of the eight RST opcodes. the emulator asserts if it isn't one. */
the 8080 can accept any one byte instruction, but traditionally it is one of the eight RST opcodes. the emulator asserts if it isn't one.
[ "the", "8080", "can", "accept", "any", "one", "byte", "instruction", "but", "traditionally", "it", "is", "one", "of", "the", "eight", "RST", "opcodes", ".", "the", "emulator", "asserts", "if", "it", "isn", "'", "t", "one", "." ]
void i8080_interrupt(i8080 *cpu, uint8_t op) { if (!INTE) { return; } assert((op & 0xC7) == 0xC7); INTE = 0; HALT = 0; PUSH(PC); PC = (op & 0x38); }
[ "void", "i8080_interrupt", "(", "i8080", "*", "cpu", ",", "uint8_t", "op", ")", "{", "if", "(", "!", "INTE", ")", "{", "return", ";", "}", "assert", "(", "(", "op", "&", "0xC7", ")", "==", "0xC7", ")", ";", "INTE", "=", "0", ";", "HALT", "=", "0", ";", "PUSH", "(", "PC", ")", ";", "PC", "=", "(", "op", "&", "0x38", ")", ";", "}" ]
the 8080 can accept any one byte instruction, but traditionally it is one of the eight RST opcodes.
[ "the", "8080", "can", "accept", "any", "one", "byte", "instruction", "but", "traditionally", "it", "is", "one", "of", "the", "eight", "RST", "opcodes", "." ]
[ "/* rst n */", "/* 00000000 000nnn000 */" ]
[ { "param": "cpu", "type": "i8080" }, { "param": "op", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cpu", "type": "i8080", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "op", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
605c3524766b83ba6fd2d2fa13ac61a54eca923f
jtbattle/wangemu
src/i8080_dasm.c
[ "MIT" ]
C
i8080_disassemble
int
int i8080_disassemble(i8080 *cpu, char *buff, int addr, int annotate) { int byte0 = RD_BYTE(addr); int byte1 = RD_BYTE(addr+1); int byte2 = RD_BYTE(addr+2); int op = byte0; int imm8 = byte1; int imm16 = (byte2 << 8) + byte1; int stack[2]; int sp = 0; // stack pointer int len = mnemonics[op].len; const char *src = mnemonics[op].op_str; char *dst = buff; char hex[10], ch; // scan opcode string, expanding escapes while copying while ((ch = *src++)) { switch (ch) { case '#': if (*src == '#') { // insert immediate 16b value sprintf(hex, "%04X", imm16); strcpy(dst,hex); dst += 4; src++; } else { // insert immediate 8b value sprintf(hex, "%02X", imm8); strcpy(dst,hex); dst += 2; } break; default: // literal copy *dst++ = ch; break; } // switch } // while // space over to a consistent column before adding value fields while (dst-buff < 16) { *dst++ = ' '; } *dst++ = ';'; *dst++ = ' '; // add informational fields // TODO: maybe just print all registers? src = mnemonics[op].value_str; while (annotate && (ch = *src++)) { assert(sp >= 0 && sp <= 2); switch (ch) { case 'r': // push register or register pair on stack switch (*src++) { case 'b': stack[sp++] = B; break; case 'c': stack[sp++] = C; break; case 'd': stack[sp++] = D; break; case 'e': stack[sp++] = E; break; case 'h': stack[sp++] = H; break; case 'l': stack[sp++] = L; break; case 'a': stack[sp++] = A; break; case 'B': stack[sp++] = BC; break; case 'D': stack[sp++] = DE; break; case 'H': stack[sp++] = HL; break; case 'S': stack[sp++] = SP; break; default: assert(0); } break; case '#': stack[sp++] = imm16; break; case '@': { // indirection assert(sp > 0); int tos = stack[--sp]; int val = 0; switch (*src++) { case 'b': val = RD_BYTE(tos); break; case 'w': val = RD_WORD(tos); break; default: assert(0); } stack[sp++] = val; } break; case 'p': { // print assert(sp > 0); int tos = stack[--sp]; switch (*src++) { case 'b': sprintf(hex, "%02X", tos); strcpy(dst, hex); dst += 2; break; case 'w': sprintf(hex, "%04X", tos); strcpy(dst, hex); dst += 4; break; default: assert(0); } } break; default: // literal copy *dst++ = ch; break; } // switch } // while assert(sp == 0); // terminate string *dst = '\0'; return len; }
// disassemble the instruction at the given address into a pre-allocated // character array (to avoid lots of dynamic memory activity). // it returns the number of bytes in the instruction.
disassemble the instruction at the given address into a pre-allocated character array (to avoid lots of dynamic memory activity). it returns the number of bytes in the instruction.
[ "disassemble", "the", "instruction", "at", "the", "given", "address", "into", "a", "pre", "-", "allocated", "character", "array", "(", "to", "avoid", "lots", "of", "dynamic", "memory", "activity", ")", ".", "it", "returns", "the", "number", "of", "bytes", "in", "the", "instruction", "." ]
int i8080_disassemble(i8080 *cpu, char *buff, int addr, int annotate) { int byte0 = RD_BYTE(addr); int byte1 = RD_BYTE(addr+1); int byte2 = RD_BYTE(addr+2); int op = byte0; int imm8 = byte1; int imm16 = (byte2 << 8) + byte1; int stack[2]; int sp = 0; int len = mnemonics[op].len; const char *src = mnemonics[op].op_str; char *dst = buff; char hex[10], ch; while ((ch = *src++)) { switch (ch) { case '#': if (*src == '#') { sprintf(hex, "%04X", imm16); strcpy(dst,hex); dst += 4; src++; } else { sprintf(hex, "%02X", imm8); strcpy(dst,hex); dst += 2; } break; default: *dst++ = ch; break; } } while (dst-buff < 16) { *dst++ = ' '; } *dst++ = ';'; *dst++ = ' '; src = mnemonics[op].value_str; while (annotate && (ch = *src++)) { assert(sp >= 0 && sp <= 2); switch (ch) { case 'r': switch (*src++) { case 'b': stack[sp++] = B; break; case 'c': stack[sp++] = C; break; case 'd': stack[sp++] = D; break; case 'e': stack[sp++] = E; break; case 'h': stack[sp++] = H; break; case 'l': stack[sp++] = L; break; case 'a': stack[sp++] = A; break; case 'B': stack[sp++] = BC; break; case 'D': stack[sp++] = DE; break; case 'H': stack[sp++] = HL; break; case 'S': stack[sp++] = SP; break; default: assert(0); } break; case '#': stack[sp++] = imm16; break; case '@': { assert(sp > 0); int tos = stack[--sp]; int val = 0; switch (*src++) { case 'b': val = RD_BYTE(tos); break; case 'w': val = RD_WORD(tos); break; default: assert(0); } stack[sp++] = val; } break; case 'p': { assert(sp > 0); int tos = stack[--sp]; switch (*src++) { case 'b': sprintf(hex, "%02X", tos); strcpy(dst, hex); dst += 2; break; case 'w': sprintf(hex, "%04X", tos); strcpy(dst, hex); dst += 4; break; default: assert(0); } } break; default: *dst++ = ch; break; } } assert(sp == 0); *dst = '\0'; return len; }
[ "int", "i8080_disassemble", "(", "i8080", "*", "cpu", ",", "char", "*", "buff", ",", "int", "addr", ",", "int", "annotate", ")", "{", "int", "byte0", "=", "RD_BYTE", "(", "addr", ")", ";", "int", "byte1", "=", "RD_BYTE", "(", "addr", "+", "1", ")", ";", "int", "byte2", "=", "RD_BYTE", "(", "addr", "+", "2", ")", ";", "int", "op", "=", "byte0", ";", "int", "imm8", "=", "byte1", ";", "int", "imm16", "=", "(", "byte2", "<<", "8", ")", "+", "byte1", ";", "int", "stack", "[", "2", "]", ";", "int", "sp", "=", "0", ";", "int", "len", "=", "mnemonics", "[", "op", "]", ".", "len", ";", "const", "char", "*", "src", "=", "mnemonics", "[", "op", "]", ".", "op_str", ";", "char", "*", "dst", "=", "buff", ";", "char", "hex", "[", "10", "]", ",", "ch", ";", "while", "(", "(", "ch", "=", "*", "src", "++", ")", ")", "{", "switch", "(", "ch", ")", "{", "case", "'", "'", ":", "if", "(", "*", "src", "==", "'", "'", ")", "{", "sprintf", "(", "hex", ",", "\"", "\"", ",", "imm16", ")", ";", "strcpy", "(", "dst", ",", "hex", ")", ";", "dst", "+=", "4", ";", "src", "++", ";", "}", "else", "{", "sprintf", "(", "hex", ",", "\"", "\"", ",", "imm8", ")", ";", "strcpy", "(", "dst", ",", "hex", ")", ";", "dst", "+=", "2", ";", "}", "break", ";", "default", ":", "*", "dst", "++", "=", "ch", ";", "break", ";", "}", "}", "while", "(", "dst", "-", "buff", "<", "16", ")", "{", "*", "dst", "++", "=", "'", "'", ";", "}", "*", "dst", "++", "=", "'", "'", ";", "*", "dst", "++", "=", "'", "'", ";", "src", "=", "mnemonics", "[", "op", "]", ".", "value_str", ";", "while", "(", "annotate", "&&", "(", "ch", "=", "*", "src", "++", ")", ")", "{", "assert", "(", "sp", ">=", "0", "&&", "sp", "<=", "2", ")", ";", "switch", "(", "ch", ")", "{", "case", "'", "'", ":", "switch", "(", "*", "src", "++", ")", "{", "case", "'", "'", ":", "stack", "[", "sp", "++", "]", "=", "B", ";", "break", ";", "case", "'", "'", ":", "stack", "[", "sp", "++", "]", "=", "C", ";", "break", ";", "case", "'", "'", ":", "stack", "[", "sp", "++", "]", "=", "D", ";", "break", ";", "case", "'", "'", ":", "stack", "[", "sp", "++", "]", "=", "E", ";", "break", ";", "case", "'", "'", ":", "stack", "[", "sp", "++", "]", "=", "H", ";", "break", ";", "case", "'", "'", ":", "stack", "[", "sp", "++", "]", "=", "L", ";", "break", ";", "case", "'", "'", ":", "stack", "[", "sp", "++", "]", "=", "A", ";", "break", ";", "case", "'", "'", ":", "stack", "[", "sp", "++", "]", "=", "BC", ";", "break", ";", "case", "'", "'", ":", "stack", "[", "sp", "++", "]", "=", "DE", ";", "break", ";", "case", "'", "'", ":", "stack", "[", "sp", "++", "]", "=", "HL", ";", "break", ";", "case", "'", "'", ":", "stack", "[", "sp", "++", "]", "=", "SP", ";", "break", ";", "default", ":", "assert", "(", "0", ")", ";", "}", "break", ";", "case", "'", "'", ":", "stack", "[", "sp", "++", "]", "=", "imm16", ";", "break", ";", "case", "'", "'", ":", "{", "assert", "(", "sp", ">", "0", ")", ";", "int", "tos", "=", "stack", "[", "--", "sp", "]", ";", "int", "val", "=", "0", ";", "switch", "(", "*", "src", "++", ")", "{", "case", "'", "'", ":", "val", "=", "RD_BYTE", "(", "tos", ")", ";", "break", ";", "case", "'", "'", ":", "val", "=", "RD_WORD", "(", "tos", ")", ";", "break", ";", "default", ":", "assert", "(", "0", ")", ";", "}", "stack", "[", "sp", "++", "]", "=", "val", ";", "}", "break", ";", "case", "'", "'", ":", "{", "assert", "(", "sp", ">", "0", ")", ";", "int", "tos", "=", "stack", "[", "--", "sp", "]", ";", "switch", "(", "*", "src", "++", ")", "{", "case", "'", "'", ":", "sprintf", "(", "hex", ",", "\"", "\"", ",", "tos", ")", ";", "strcpy", "(", "dst", ",", "hex", ")", ";", "dst", "+=", "2", ";", "break", ";", "case", "'", "'", ":", "sprintf", "(", "hex", ",", "\"", "\"", ",", "tos", ")", ";", "strcpy", "(", "dst", ",", "hex", ")", ";", "dst", "+=", "4", ";", "break", ";", "default", ":", "assert", "(", "0", ")", ";", "}", "}", "break", ";", "default", ":", "*", "dst", "++", "=", "ch", ";", "break", ";", "}", "}", "assert", "(", "sp", "==", "0", ")", ";", "*", "dst", "=", "'", "\\0", "'", ";", "return", "len", ";", "}" ]
disassemble the instruction at the given address into a pre-allocated character array (to avoid lots of dynamic memory activity).
[ "disassemble", "the", "instruction", "at", "the", "given", "address", "into", "a", "pre", "-", "allocated", "character", "array", "(", "to", "avoid", "lots", "of", "dynamic", "memory", "activity", ")", "." ]
[ "// stack pointer", "// scan opcode string, expanding escapes while copying", "// insert immediate 16b value", "// insert immediate 8b value", "// literal copy", "// switch", "// while", "// space over to a consistent column before adding value fields", "// add informational fields", "// TODO: maybe just print all registers?", "// push register or register pair on stack", "// indirection", "// print", "// literal copy", "// switch", "// while", "// terminate string" ]
[ { "param": "cpu", "type": "i8080" }, { "param": "buff", "type": "char" }, { "param": "addr", "type": "int" }, { "param": "annotate", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cpu", "type": "i8080", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buff", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "addr", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "annotate", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
af482ae9c6cfb0554f59d1231785a57b9c292fa9
aoloe/cpp-md4c
md2html/cmdline.c
[ "MIT" ]
C
readoptions
int
int readoptions(option const* list, int argc, char **argv, int (*callback)(int, char const*, void*), void *data) { char argstring[] = "--"; option const *opt; char const *val; char const *p; int stop = 0; int argi, len, r; if (!list || !callback) return -1; for (argi = 1 ; argi < argc ; ++argi) { /* First, check for "--", which forces all remaining arguments * to be treated as non-options. */ if (!stop && argv[argi][0] == '-' && argv[argi][1] == '-' && argv[argi][2] == '\0') { stop = 1; continue; } /* Arguments that do not begin with '-' (or are only "-") are * not options. */ if (stop || argv[argi][0] != '-' || argv[argi][1] == '\0') { docallback(0, argv[argi]); continue; } if (argv[argi][1] == '-') { /* Arguments that begin with a double-dash are long * options. */ p = argv[argi] + 2; val = strchr(p, '='); if (val) len = val++ - p; else len = strlen(p); /* Is it on the list of valid options? If so, does it * expect a parameter? */ for (opt = list ; opt->optval ; ++opt) if (opt->name && !strncmp(p, opt->name, len) && !opt->name[len]) break; if (!opt->optval) { docallback('?', argv[argi]); } else if (!val && opt->arg == 1) { docallback(':', argv[argi]); } else if (val && opt->arg == 0) { docallback('=', argv[argi]); } else { docallback(opt->optval, val); } } else { /* Arguments that begin with a single dash contain one or * more short options. Each character in the argument is * examined in turn, unless a parameter consumes the rest * of the argument (or possibly even the following * argument). */ for (p = argv[argi] + 1 ; *p ; ++p) { for (opt = list ; opt->optval ; ++opt) if (opt->chname == *p) break; if (!opt->optval) { argstring[1] = *p; docallback('?', argstring); continue; } else if (opt->arg == 0) { docallback(opt->optval, NULL); continue; } else if (p[1]) { docallback(opt->optval, p + 1); break; } else if (argi + 1 < argc && strcmp(argv[argi + 1], "--")) { ++argi; docallback(opt->optval, argv[argi]); break; } else if (opt->arg == 2) { docallback(opt->optval, NULL); continue; } else { argstring[1] = *p; docallback(':', argstring); break; } } } } return 0; }
/* Parse the given cmdline arguments. */
Parse the given cmdline arguments.
[ "Parse", "the", "given", "cmdline", "arguments", "." ]
int readoptions(option const* list, int argc, char **argv, int (*callback)(int, char const*, void*), void *data) { char argstring[] = "--"; option const *opt; char const *val; char const *p; int stop = 0; int argi, len, r; if (!list || !callback) return -1; for (argi = 1 ; argi < argc ; ++argi) { if (!stop && argv[argi][0] == '-' && argv[argi][1] == '-' && argv[argi][2] == '\0') { stop = 1; continue; } if (stop || argv[argi][0] != '-' || argv[argi][1] == '\0') { docallback(0, argv[argi]); continue; } if (argv[argi][1] == '-') { p = argv[argi] + 2; val = strchr(p, '='); if (val) len = val++ - p; else len = strlen(p); for (opt = list ; opt->optval ; ++opt) if (opt->name && !strncmp(p, opt->name, len) && !opt->name[len]) break; if (!opt->optval) { docallback('?', argv[argi]); } else if (!val && opt->arg == 1) { docallback(':', argv[argi]); } else if (val && opt->arg == 0) { docallback('=', argv[argi]); } else { docallback(opt->optval, val); } } else { for (p = argv[argi] + 1 ; *p ; ++p) { for (opt = list ; opt->optval ; ++opt) if (opt->chname == *p) break; if (!opt->optval) { argstring[1] = *p; docallback('?', argstring); continue; } else if (opt->arg == 0) { docallback(opt->optval, NULL); continue; } else if (p[1]) { docallback(opt->optval, p + 1); break; } else if (argi + 1 < argc && strcmp(argv[argi + 1], "--")) { ++argi; docallback(opt->optval, argv[argi]); break; } else if (opt->arg == 2) { docallback(opt->optval, NULL); continue; } else { argstring[1] = *p; docallback(':', argstring); break; } } } } return 0; }
[ "int", "readoptions", "(", "option", "const", "*", "list", ",", "int", "argc", ",", "char", "*", "*", "argv", ",", "int", "(", "*", "callback", ")", "(", "int", ",", "char", "const", "*", ",", "void", "*", ")", ",", "void", "*", "data", ")", "{", "char", "argstring", "[", "]", "=", "\"", "\"", ";", "option", "const", "*", "opt", ";", "char", "const", "*", "val", ";", "char", "const", "*", "p", ";", "int", "stop", "=", "0", ";", "int", "argi", ",", "len", ",", "r", ";", "if", "(", "!", "list", "||", "!", "callback", ")", "return", "-1", ";", "for", "(", "argi", "=", "1", ";", "argi", "<", "argc", ";", "++", "argi", ")", "{", "if", "(", "!", "stop", "&&", "argv", "[", "argi", "]", "[", "0", "]", "==", "'", "'", "&&", "argv", "[", "argi", "]", "[", "1", "]", "==", "'", "'", "&&", "argv", "[", "argi", "]", "[", "2", "]", "==", "'", "\\0", "'", ")", "{", "stop", "=", "1", ";", "continue", ";", "}", "if", "(", "stop", "||", "argv", "[", "argi", "]", "[", "0", "]", "!=", "'", "'", "||", "argv", "[", "argi", "]", "[", "1", "]", "==", "'", "\\0", "'", ")", "{", "docallback", "(", "0", ",", "argv", "[", "argi", "]", ")", ";", "continue", ";", "}", "if", "(", "argv", "[", "argi", "]", "[", "1", "]", "==", "'", "'", ")", "{", "p", "=", "argv", "[", "argi", "]", "+", "2", ";", "val", "=", "strchr", "(", "p", ",", "'", "'", ")", ";", "if", "(", "val", ")", "len", "=", "val", "++", "-", "p", ";", "else", "len", "=", "strlen", "(", "p", ")", ";", "for", "(", "opt", "=", "list", ";", "opt", "->", "optval", ";", "++", "opt", ")", "if", "(", "opt", "->", "name", "&&", "!", "strncmp", "(", "p", ",", "opt", "->", "name", ",", "len", ")", "&&", "!", "opt", "->", "name", "[", "len", "]", ")", "break", ";", "if", "(", "!", "opt", "->", "optval", ")", "{", "docallback", "(", "'", "'", ",", "argv", "[", "argi", "]", ")", ";", "}", "else", "if", "(", "!", "val", "&&", "opt", "->", "arg", "==", "1", ")", "{", "docallback", "(", "'", "'", ",", "argv", "[", "argi", "]", ")", ";", "}", "else", "if", "(", "val", "&&", "opt", "->", "arg", "==", "0", ")", "{", "docallback", "(", "'", "'", ",", "argv", "[", "argi", "]", ")", ";", "}", "else", "{", "docallback", "(", "opt", "->", "optval", ",", "val", ")", ";", "}", "}", "else", "{", "for", "(", "p", "=", "argv", "[", "argi", "]", "+", "1", ";", "*", "p", ";", "++", "p", ")", "{", "for", "(", "opt", "=", "list", ";", "opt", "->", "optval", ";", "++", "opt", ")", "if", "(", "opt", "->", "chname", "==", "*", "p", ")", "break", ";", "if", "(", "!", "opt", "->", "optval", ")", "{", "argstring", "[", "1", "]", "=", "*", "p", ";", "docallback", "(", "'", "'", ",", "argstring", ")", ";", "continue", ";", "}", "else", "if", "(", "opt", "->", "arg", "==", "0", ")", "{", "docallback", "(", "opt", "->", "optval", ",", "NULL", ")", ";", "continue", ";", "}", "else", "if", "(", "p", "[", "1", "]", ")", "{", "docallback", "(", "opt", "->", "optval", ",", "p", "+", "1", ")", ";", "break", ";", "}", "else", "if", "(", "argi", "+", "1", "<", "argc", "&&", "strcmp", "(", "argv", "[", "argi", "+", "1", "]", ",", "\"", "\"", ")", ")", "{", "++", "argi", ";", "docallback", "(", "opt", "->", "optval", ",", "argv", "[", "argi", "]", ")", ";", "break", ";", "}", "else", "if", "(", "opt", "->", "arg", "==", "2", ")", "{", "docallback", "(", "opt", "->", "optval", ",", "NULL", ")", ";", "continue", ";", "}", "else", "{", "argstring", "[", "1", "]", "=", "*", "p", ";", "docallback", "(", "'", "'", ",", "argstring", ")", ";", "break", ";", "}", "}", "}", "}", "return", "0", ";", "}" ]
Parse the given cmdline arguments.
[ "Parse", "the", "given", "cmdline", "arguments", "." ]
[ "/* First, check for \"--\", which forces all remaining arguments\n\t * to be treated as non-options.\n\t */", "/* Arguments that do not begin with '-' (or are only \"-\") are\n\t * not options.\n\t */", "/* Arguments that begin with a double-dash are long\n\t * options.\n\t */", "/* Is it on the list of valid options? If so, does it\n\t * expect a parameter?\n\t */", "/* Arguments that begin with a single dash contain one or\n\t * more short options. Each character in the argument is\n\t * examined in turn, unless a parameter consumes the rest\n\t * of the argument (or possibly even the following\n\t * argument).\n\t */" ]
[ { "param": "list", "type": "option" }, { "param": "argc", "type": "int" }, { "param": "argv", "type": "char" }, { "param": "callback", "type": "int" }, { "param": "data", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "list", "type": "option", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "argc", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "argv", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "callback", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
af482ae9c6cfb0554f59d1231785a57b9c292fa9
aoloe/cpp-md4c
md2html/cmdline.c
[ "MIT" ]
C
readboolvalue
int
static int readboolvalue(char const *str) { char d; while (isspace(*str)) ++str; if (!*str) return -1; d = *str++; while (isspace(*str)) ++str; if (*str) return -1; if (d == '0') return 0; else if (d == '1') return 1; else return -1; }
/* Verify that str points to an ASCII zero or one (optionally with * whitespace) and return the value present, or -1 if str's contents * are anything else. */
Verify that str points to an ASCII zero or one (optionally with whitespace) and return the value present, or -1 if str's contents are anything else.
[ "Verify", "that", "str", "points", "to", "an", "ASCII", "zero", "or", "one", "(", "optionally", "with", "whitespace", ")", "and", "return", "the", "value", "present", "or", "-", "1", "if", "str", "'", "s", "contents", "are", "anything", "else", "." ]
static int readboolvalue(char const *str) { char d; while (isspace(*str)) ++str; if (!*str) return -1; d = *str++; while (isspace(*str)) ++str; if (*str) return -1; if (d == '0') return 0; else if (d == '1') return 1; else return -1; }
[ "static", "int", "readboolvalue", "(", "char", "const", "*", "str", ")", "{", "char", "d", ";", "while", "(", "isspace", "(", "*", "str", ")", ")", "++", "str", ";", "if", "(", "!", "*", "str", ")", "return", "-1", ";", "d", "=", "*", "str", "++", ";", "while", "(", "isspace", "(", "*", "str", ")", ")", "++", "str", ";", "if", "(", "*", "str", ")", "return", "-1", ";", "if", "(", "d", "==", "'", "'", ")", "return", "0", ";", "else", "if", "(", "d", "==", "'", "'", ")", "return", "1", ";", "else", "return", "-1", ";", "}" ]
Verify that str points to an ASCII zero or one (optionally with whitespace) and return the value present, or -1 if str's contents are anything else.
[ "Verify", "that", "str", "points", "to", "an", "ASCII", "zero", "or", "one", "(", "optionally", "with", "whitespace", ")", "and", "return", "the", "value", "present", "or", "-", "1", "if", "str", "'", "s", "contents", "are", "anything", "else", "." ]
[]
[ { "param": "str", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "str", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
af482ae9c6cfb0554f59d1231785a57b9c292fa9
aoloe/cpp-md4c
md2html/cmdline.c
[ "MIT" ]
C
makecmdline
int
int makecmdline(char const *cmdline, int *argcp, char ***argvp) { char **argv; int argc; char const *s; int n, quoted; if (!cmdline) return 0; /* Calcuate argc by counting the number of "clumps" of non-spaces. */ for (s = cmdline ; isspace(*s) ; ++s) ; if (!*s) { *argcp = 1; if (argvp) { *argvp = malloc(2 * sizeof(char*)); if (!*argvp) return 0; (*argvp)[0] = NULL; (*argvp)[1] = NULL; } return 1; } for (argc = 2, quoted = 0 ; *s ; ++s) { if (quoted == '"') { if (*s == '"') quoted = 0; else if (*s == '\\' && s[1]) ++s; } else if (quoted == '\'') { if (*s == '\'') quoted = 0; } else { if (isspace(*s)) { for ( ; isspace(s[1]) ; ++s) ; if (!s[1]) break; ++argc; } else if (*s == '"' || *s == '\'') { quoted = *s; } } } *argcp = argc; if (!argvp) return 1; /* Allocate space for all the arguments and their pointers. */ argv = malloc((argc + 1) * sizeof(char*) + strlen(cmdline) + 1); *argvp = argv; if (!argv) return 0; argv[0] = NULL; argv[1] = (char*)(argv + argc + 1); /* Copy the string into the allocated memory immediately after the * argv array. Where spaces immediately follows a nonspace, * replace it with a \0. Where a nonspace immediately follows * spaces, store a pointer to it. (Except, of course, when the * space-nonspace transitions occur within quotes.) */ for (s = cmdline ; isspace(*s) ; ++s) ; for (argc = 1, n = 0, quoted = 0 ; *s ; ++s) { if (quoted == '"') { if (*s == '"') { quoted = 0; } else { if (*s == '\\' && s[1]) ++s; argv[argc][n++] = *s; } } else if (quoted == '\'') { if (*s == '\'') quoted = 0; else argv[argc][n++] = *s; } else { if (isspace(*s)) { argv[argc][n] = '\0'; for ( ; isspace(s[1]) ; ++s) ; if (!s[1]) break; argv[argc + 1] = argv[argc] + n + 1; ++argc; n = 0; } else { if (*s == '"' || *s == '\'') quoted = *s; else argv[argc][n++] = *s; } } } argv[argc + 1] = NULL; return 1; }
/* Turn a string containing a cmdline into an argc-argv pair. */
Turn a string containing a cmdline into an argc-argv pair.
[ "Turn", "a", "string", "containing", "a", "cmdline", "into", "an", "argc", "-", "argv", "pair", "." ]
int makecmdline(char const *cmdline, int *argcp, char ***argvp) { char **argv; int argc; char const *s; int n, quoted; if (!cmdline) return 0; for (s = cmdline ; isspace(*s) ; ++s) ; if (!*s) { *argcp = 1; if (argvp) { *argvp = malloc(2 * sizeof(char*)); if (!*argvp) return 0; (*argvp)[0] = NULL; (*argvp)[1] = NULL; } return 1; } for (argc = 2, quoted = 0 ; *s ; ++s) { if (quoted == '"') { if (*s == '"') quoted = 0; else if (*s == '\\' && s[1]) ++s; } else if (quoted == '\'') { if (*s == '\'') quoted = 0; } else { if (isspace(*s)) { for ( ; isspace(s[1]) ; ++s) ; if (!s[1]) break; ++argc; } else if (*s == '"' || *s == '\'') { quoted = *s; } } } *argcp = argc; if (!argvp) return 1; argv = malloc((argc + 1) * sizeof(char*) + strlen(cmdline) + 1); *argvp = argv; if (!argv) return 0; argv[0] = NULL; argv[1] = (char*)(argv + argc + 1); for (s = cmdline ; isspace(*s) ; ++s) ; for (argc = 1, n = 0, quoted = 0 ; *s ; ++s) { if (quoted == '"') { if (*s == '"') { quoted = 0; } else { if (*s == '\\' && s[1]) ++s; argv[argc][n++] = *s; } } else if (quoted == '\'') { if (*s == '\'') quoted = 0; else argv[argc][n++] = *s; } else { if (isspace(*s)) { argv[argc][n] = '\0'; for ( ; isspace(s[1]) ; ++s) ; if (!s[1]) break; argv[argc + 1] = argv[argc] + n + 1; ++argc; n = 0; } else { if (*s == '"' || *s == '\'') quoted = *s; else argv[argc][n++] = *s; } } } argv[argc + 1] = NULL; return 1; }
[ "int", "makecmdline", "(", "char", "const", "*", "cmdline", ",", "int", "*", "argcp", ",", "char", "*", "*", "*", "argvp", ")", "{", "char", "*", "*", "argv", ";", "int", "argc", ";", "char", "const", "*", "s", ";", "int", "n", ",", "quoted", ";", "if", "(", "!", "cmdline", ")", "return", "0", ";", "for", "(", "s", "=", "cmdline", ";", "isspace", "(", "*", "s", ")", ";", "++", "s", ")", ";", "if", "(", "!", "*", "s", ")", "{", "*", "argcp", "=", "1", ";", "if", "(", "argvp", ")", "{", "*", "argvp", "=", "malloc", "(", "2", "*", "sizeof", "(", "char", "*", ")", ")", ";", "if", "(", "!", "*", "argvp", ")", "return", "0", ";", "(", "*", "argvp", ")", "[", "0", "]", "=", "NULL", ";", "(", "*", "argvp", ")", "[", "1", "]", "=", "NULL", ";", "}", "return", "1", ";", "}", "for", "(", "argc", "=", "2", ",", "quoted", "=", "0", ";", "*", "s", ";", "++", "s", ")", "{", "if", "(", "quoted", "==", "'", "'", ")", "{", "if", "(", "*", "s", "==", "'", "'", ")", "quoted", "=", "0", ";", "else", "if", "(", "*", "s", "==", "'", "\\\\", "'", "&&", "s", "[", "1", "]", ")", "++", "s", ";", "}", "else", "if", "(", "quoted", "==", "'", "\\'", "'", ")", "{", "if", "(", "*", "s", "==", "'", "\\'", "'", ")", "quoted", "=", "0", ";", "}", "else", "{", "if", "(", "isspace", "(", "*", "s", ")", ")", "{", "for", "(", ";", "isspace", "(", "s", "[", "1", "]", ")", ";", "++", "s", ")", ";", "if", "(", "!", "s", "[", "1", "]", ")", "break", ";", "++", "argc", ";", "}", "else", "if", "(", "*", "s", "==", "'", "'", "||", "*", "s", "==", "'", "\\'", "'", ")", "{", "quoted", "=", "*", "s", ";", "}", "}", "}", "*", "argcp", "=", "argc", ";", "if", "(", "!", "argvp", ")", "return", "1", ";", "argv", "=", "malloc", "(", "(", "argc", "+", "1", ")", "*", "sizeof", "(", "char", "*", ")", "+", "strlen", "(", "cmdline", ")", "+", "1", ")", ";", "*", "argvp", "=", "argv", ";", "if", "(", "!", "argv", ")", "return", "0", ";", "argv", "[", "0", "]", "=", "NULL", ";", "argv", "[", "1", "]", "=", "(", "char", "*", ")", "(", "argv", "+", "argc", "+", "1", ")", ";", "for", "(", "s", "=", "cmdline", ";", "isspace", "(", "*", "s", ")", ";", "++", "s", ")", ";", "for", "(", "argc", "=", "1", ",", "n", "=", "0", ",", "quoted", "=", "0", ";", "*", "s", ";", "++", "s", ")", "{", "if", "(", "quoted", "==", "'", "'", ")", "{", "if", "(", "*", "s", "==", "'", "'", ")", "{", "quoted", "=", "0", ";", "}", "else", "{", "if", "(", "*", "s", "==", "'", "\\\\", "'", "&&", "s", "[", "1", "]", ")", "++", "s", ";", "argv", "[", "argc", "]", "[", "n", "++", "]", "=", "*", "s", ";", "}", "}", "else", "if", "(", "quoted", "==", "'", "\\'", "'", ")", "{", "if", "(", "*", "s", "==", "'", "\\'", "'", ")", "quoted", "=", "0", ";", "else", "argv", "[", "argc", "]", "[", "n", "++", "]", "=", "*", "s", ";", "}", "else", "{", "if", "(", "isspace", "(", "*", "s", ")", ")", "{", "argv", "[", "argc", "]", "[", "n", "]", "=", "'", "\\0", "'", ";", "for", "(", ";", "isspace", "(", "s", "[", "1", "]", ")", ";", "++", "s", ")", ";", "if", "(", "!", "s", "[", "1", "]", ")", "break", ";", "argv", "[", "argc", "+", "1", "]", "=", "argv", "[", "argc", "]", "+", "n", "+", "1", ";", "++", "argc", ";", "n", "=", "0", ";", "}", "else", "{", "if", "(", "*", "s", "==", "'", "'", "||", "*", "s", "==", "'", "\\'", "'", ")", "quoted", "=", "*", "s", ";", "else", "argv", "[", "argc", "]", "[", "n", "++", "]", "=", "*", "s", ";", "}", "}", "}", "argv", "[", "argc", "+", "1", "]", "=", "NULL", ";", "return", "1", ";", "}" ]
Turn a string containing a cmdline into an argc-argv pair.
[ "Turn", "a", "string", "containing", "a", "cmdline", "into", "an", "argc", "-", "argv", "pair", "." ]
[ "/* Calcuate argc by counting the number of \"clumps\" of non-spaces.\n */", "/* Allocate space for all the arguments and their pointers.\n */", "/* Copy the string into the allocated memory immediately after the\n * argv array. Where spaces immediately follows a nonspace,\n * replace it with a \\0. Where a nonspace immediately follows\n * spaces, store a pointer to it. (Except, of course, when the\n * space-nonspace transitions occur within quotes.)\n */" ]
[ { "param": "cmdline", "type": "char" }, { "param": "argcp", "type": "int" }, { "param": "argvp", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cmdline", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "argcp", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "argvp", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a8bb148cc79fe415fccfdd17dcc28afdb4624136
akivawerner/XscHelp
src/base/Cue.c
[ "MIT" ]
C
_XscCuePopdown
void
void _XscCuePopdown( XscCue self ) { Widget object_widget = _XscObjectGetWidget( self->object ); XscDisplay hpt_display = _XscDisplayDeriveFromWidget( object_widget ); /*----------------------------------------------------------------------- -- Verify that this object is the object recorded in the display record -----------------------------------------------------------------------*/ if (self == _XscDisplayGetActiveCue( hpt_display )) { XscScreen hpt_screen = _XscScreenDeriveFromWidget( object_widget ); /*------------------------------------------------------ -- Stop all the (potential) timers and popdown the cue ------------------------------------------------------*/ _XscScreenPopdownCue( hpt_screen ); _XscDisplaySetActiveCue( hpt_display, NULL ); } }
/*------------------------------------------------------------------------------ -- This function forces a cue to pop-down ------------------------------------------------------------------------------*/
This function forces a cue to pop-down
[ "This", "function", "forces", "a", "cue", "to", "pop", "-", "down" ]
void _XscCuePopdown( XscCue self ) { Widget object_widget = _XscObjectGetWidget( self->object ); XscDisplay hpt_display = _XscDisplayDeriveFromWidget( object_widget ); if (self == _XscDisplayGetActiveCue( hpt_display )) { XscScreen hpt_screen = _XscScreenDeriveFromWidget( object_widget ); _XscScreenPopdownCue( hpt_screen ); _XscDisplaySetActiveCue( hpt_display, NULL ); } }
[ "void", "_XscCuePopdown", "(", "XscCue", "self", ")", "{", "Widget", "object_widget", "=", "_XscObjectGetWidget", "(", "self", "->", "object", ")", ";", "XscDisplay", "hpt_display", "=", "_XscDisplayDeriveFromWidget", "(", "object_widget", ")", ";", "if", "(", "self", "==", "_XscDisplayGetActiveCue", "(", "hpt_display", ")", ")", "{", "XscScreen", "hpt_screen", "=", "_XscScreenDeriveFromWidget", "(", "object_widget", ")", ";", "_XscScreenPopdownCue", "(", "hpt_screen", ")", ";", "_XscDisplaySetActiveCue", "(", "hpt_display", ",", "NULL", ")", ";", "}", "}" ]
This function forces a cue to pop-down
[ "This", "function", "forces", "a", "cue", "to", "pop", "-", "down" ]
[ "/*-----------------------------------------------------------------------\n -- Verify that this object is the object recorded in the display record\n -----------------------------------------------------------------------*/", "/*------------------------------------------------------\n -- Stop all the (potential) timers and popdown the cue\n ------------------------------------------------------*/" ]
[ { "param": "self", "type": "XscCue" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": "XscCue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
_XscObjectInitialize
void
void _XscObjectInitialize( XContext context ) { if (!_objectContextId) { if (context) { _objectContextId = context; } else { _objectContextId = XUniqueContext(); } } }
/*------------------------------------------------- -- This function is used to initialize the module -------------------------------------------------*/
This function is used to initialize the module
[ "This", "function", "is", "used", "to", "initialize", "the", "module" ]
void _XscObjectInitialize( XContext context ) { if (!_objectContextId) { if (context) { _objectContextId = context; } else { _objectContextId = XUniqueContext(); } } }
[ "void", "_XscObjectInitialize", "(", "XContext", "context", ")", "{", "if", "(", "!", "_objectContextId", ")", "{", "if", "(", "context", ")", "{", "_objectContextId", "=", "context", ";", "}", "else", "{", "_objectContextId", "=", "XUniqueContext", "(", ")", ";", "}", "}", "}" ]
This function is used to initialize the module
[ "This", "function", "is", "used", "to", "initialize", "the", "module" ]
[]
[ { "param": "context", "type": "XContext" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "context", "type": "XContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
_XscObjectCreate
XscObject
XscObject _XscObjectCreate( Widget obj ) { XscObject self; Display* x_display = XtDisplayOfObject( obj ); /*------------------------------------ -- Make a Help ToolKit object record ------------------------------------*/ self = XtNew( XscObjectRec ); /*---------------------- -- Initialize ----------------------*/ self->object = obj; self->gadgetChildCount = 0; self->gadgetProcessing = True; self->activeGadget = NULL; self->cue = NULL; self->cueSubstitute = NULL; self->hint = NULL; self->tip = NULL; self->tipGroupId = XmXSC_TIP_GROUP_NULL; self->hasGroupLeader = False; /*------------------------------------------------- -- Load object members from the resource database -------------------------------------------------*/ _setupObject( self ); /*---------------------------------------------------------------------- -- Determine if this object has an associated tip and/or hint. If so, -- create and populate the associated data structures. The new -- structures are bound to the object structure via the hint/tip -- members. ----------------------------------------------------------------------*/ _setupCue ( self, NULL ); _setupHint( self, NULL ); _setupTip ( self, NULL ); /*------------------------------------------------------ -- The library needs to track when the pointer moves -- in and out of widgets even if the widget does not -- currently have a hint and tip. There are several -- reasons for this, but here's one: the widget could -- be a Composite that has gadgets. ------------------------------------------------------*/ if (XtIsWidget( obj )) { XtAddEventHandler( obj, EnterWindowMask | LeaveWindowMask, False, _enterOrLeaveObjectEH, (XtPointer) self ); XtAddEventHandler( obj, FocusChangeMask, False, _focusChangeEH, (XtPointer) self ); } XSaveContext( x_display, (XID)obj, _objectContextId, (XPointer)self ); /*--------------------------------------------------------------------- -- All non-shell widgets need a destroy callback for resource cleanup ---------------------------------------------------------------------*/ XtAddCallback( obj, XmNdestroyCallback, _destroyObjectCB, NULL ); /*-------------------------------------------------------------------- -- Keep track of the number of gadgets maintained by each composite. -- This is used to activate gadget managment only when gadgets are -- present. -- -- In some cases, a gadget may be "created" before its parent. This -- will happen when gadgets are used to create a single "compound" -- widget. Therefore, the gadget counting works like this: -- a) When a composite is created, its gadget count is set to zero -- and all of its gadget children are counted -- b) When a gadget is created, its parent's gadget count is -- incremented iff it has been installed (has a HtkObject record) ---------------------------------------------------------------------*/ if (XtIsComposite( obj )) { CompositeWidget mgr = (CompositeWidget) obj; int i; int original_gadget_count = self->gadgetChildCount; self->gadgetChildCount = 0; for (i = mgr->composite.num_children - 1; i >= 0; i--) { Widget child = mgr->composite.children[ i ]; if (child) { if (!XtIsWidget( child )) { if (XtIsRectObj( child )) { self->gadgetChildCount += 1; } } } } /*--------------------------------------------------------- -- If there are gadgets, install a pointer motion handler ---------------------------------------------------------*/ if ((original_gadget_count==0) && (self->gadgetChildCount)) { XtAddEventHandler( obj, PointerMotionMask, False, _motionInObjectEH, (XtPointer) self ); } } else if (!XtIsWidget( obj )) { Widget parent = XtParent( obj ); XscObject obj_parent = _XscObjectDeriveFromWidget( parent ); if (obj_parent) { obj_parent->gadgetChildCount += 1; /*--------------------------------------------------------- -- Install a pointer motion handler when the first gadget -- is located ---------------------------------------------------------*/ if (obj_parent->gadgetChildCount == 1) { XtAddEventHandler( parent, PointerMotionMask, False, _motionInObjectEH, (XtPointer) obj_parent ); } } } return self; }
/*------------------------------------------------------------------------------ -- Every object needs a light-weight record for generic information ------------------------------------------------------------------------------*/
Every object needs a light-weight record for generic information
[ "Every", "object", "needs", "a", "light", "-", "weight", "record", "for", "generic", "information" ]
XscObject _XscObjectCreate( Widget obj ) { XscObject self; Display* x_display = XtDisplayOfObject( obj ); self = XtNew( XscObjectRec ); self->object = obj; self->gadgetChildCount = 0; self->gadgetProcessing = True; self->activeGadget = NULL; self->cue = NULL; self->cueSubstitute = NULL; self->hint = NULL; self->tip = NULL; self->tipGroupId = XmXSC_TIP_GROUP_NULL; self->hasGroupLeader = False; _setupObject( self ); _setupCue ( self, NULL ); _setupHint( self, NULL ); _setupTip ( self, NULL ); if (XtIsWidget( obj )) { XtAddEventHandler( obj, EnterWindowMask | LeaveWindowMask, False, _enterOrLeaveObjectEH, (XtPointer) self ); XtAddEventHandler( obj, FocusChangeMask, False, _focusChangeEH, (XtPointer) self ); } XSaveContext( x_display, (XID)obj, _objectContextId, (XPointer)self ); XtAddCallback( obj, XmNdestroyCallback, _destroyObjectCB, NULL ); if (XtIsComposite( obj )) { CompositeWidget mgr = (CompositeWidget) obj; int i; int original_gadget_count = self->gadgetChildCount; self->gadgetChildCount = 0; for (i = mgr->composite.num_children - 1; i >= 0; i--) { Widget child = mgr->composite.children[ i ]; if (child) { if (!XtIsWidget( child )) { if (XtIsRectObj( child )) { self->gadgetChildCount += 1; } } } } if ((original_gadget_count==0) && (self->gadgetChildCount)) { XtAddEventHandler( obj, PointerMotionMask, False, _motionInObjectEH, (XtPointer) self ); } } else if (!XtIsWidget( obj )) { Widget parent = XtParent( obj ); XscObject obj_parent = _XscObjectDeriveFromWidget( parent ); if (obj_parent) { obj_parent->gadgetChildCount += 1; if (obj_parent->gadgetChildCount == 1) { XtAddEventHandler( parent, PointerMotionMask, False, _motionInObjectEH, (XtPointer) obj_parent ); } } } return self; }
[ "XscObject", "_XscObjectCreate", "(", "Widget", "obj", ")", "{", "XscObject", "self", ";", "Display", "*", "x_display", "=", "XtDisplayOfObject", "(", "obj", ")", ";", "self", "=", "XtNew", "(", "XscObjectRec", ")", ";", "self", "->", "object", "=", "obj", ";", "self", "->", "gadgetChildCount", "=", "0", ";", "self", "->", "gadgetProcessing", "=", "True", ";", "self", "->", "activeGadget", "=", "NULL", ";", "self", "->", "cue", "=", "NULL", ";", "self", "->", "cueSubstitute", "=", "NULL", ";", "self", "->", "hint", "=", "NULL", ";", "self", "->", "tip", "=", "NULL", ";", "self", "->", "tipGroupId", "=", "XmXSC_TIP_GROUP_NULL", ";", "self", "->", "hasGroupLeader", "=", "False", ";", "_setupObject", "(", "self", ")", ";", "_setupCue", "(", "self", ",", "NULL", ")", ";", "_setupHint", "(", "self", ",", "NULL", ")", ";", "_setupTip", "(", "self", ",", "NULL", ")", ";", "if", "(", "XtIsWidget", "(", "obj", ")", ")", "{", "XtAddEventHandler", "(", "obj", ",", "EnterWindowMask", "|", "LeaveWindowMask", ",", "False", ",", "_enterOrLeaveObjectEH", ",", "(", "XtPointer", ")", "self", ")", ";", "XtAddEventHandler", "(", "obj", ",", "FocusChangeMask", ",", "False", ",", "_focusChangeEH", ",", "(", "XtPointer", ")", "self", ")", ";", "}", "XSaveContext", "(", "x_display", ",", "(", "XID", ")", "obj", ",", "_objectContextId", ",", "(", "XPointer", ")", "self", ")", ";", "XtAddCallback", "(", "obj", ",", "XmNdestroyCallback", ",", "_destroyObjectCB", ",", "NULL", ")", ";", "if", "(", "XtIsComposite", "(", "obj", ")", ")", "{", "CompositeWidget", "mgr", "=", "(", "CompositeWidget", ")", "obj", ";", "int", "i", ";", "int", "original_gadget_count", "=", "self", "->", "gadgetChildCount", ";", "self", "->", "gadgetChildCount", "=", "0", ";", "for", "(", "i", "=", "mgr", "->", "composite", ".", "num_children", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "Widget", "child", "=", "mgr", "->", "composite", ".", "children", "[", "i", "]", ";", "if", "(", "child", ")", "{", "if", "(", "!", "XtIsWidget", "(", "child", ")", ")", "{", "if", "(", "XtIsRectObj", "(", "child", ")", ")", "{", "self", "->", "gadgetChildCount", "+=", "1", ";", "}", "}", "}", "}", "if", "(", "(", "original_gadget_count", "==", "0", ")", "&&", "(", "self", "->", "gadgetChildCount", ")", ")", "{", "XtAddEventHandler", "(", "obj", ",", "PointerMotionMask", ",", "False", ",", "_motionInObjectEH", ",", "(", "XtPointer", ")", "self", ")", ";", "}", "}", "else", "if", "(", "!", "XtIsWidget", "(", "obj", ")", ")", "{", "Widget", "parent", "=", "XtParent", "(", "obj", ")", ";", "XscObject", "obj_parent", "=", "_XscObjectDeriveFromWidget", "(", "parent", ")", ";", "if", "(", "obj_parent", ")", "{", "obj_parent", "->", "gadgetChildCount", "+=", "1", ";", "if", "(", "obj_parent", "->", "gadgetChildCount", "==", "1", ")", "{", "XtAddEventHandler", "(", "parent", ",", "PointerMotionMask", ",", "False", ",", "_motionInObjectEH", ",", "(", "XtPointer", ")", "obj_parent", ")", ";", "}", "}", "}", "return", "self", ";", "}" ]
Every object needs a light-weight record for generic information
[ "Every", "object", "needs", "a", "light", "-", "weight", "record", "for", "generic", "information" ]
[ "/*------------------------------------\n -- Make a Help ToolKit object record\n ------------------------------------*/", "/*----------------------\n -- Initialize \n ----------------------*/", "/*-------------------------------------------------\n -- Load object members from the resource database\n -------------------------------------------------*/", "/*----------------------------------------------------------------------\n -- Determine if this object has an associated tip and/or hint. If so,\n -- create and populate the associated data structures. The new\n -- structures are bound to the object structure via the hint/tip\n -- members.\n ----------------------------------------------------------------------*/", "/*------------------------------------------------------\n -- The library needs to track when the pointer moves \n -- in and out of widgets even if the widget does not\n -- currently have a hint and tip. There are several\n -- reasons for this, but here's one: the widget could\n -- be a Composite that has gadgets.\n ------------------------------------------------------*/", "/*---------------------------------------------------------------------\n -- All non-shell widgets need a destroy callback for resource cleanup\n ---------------------------------------------------------------------*/", "/*--------------------------------------------------------------------\n -- Keep track of the number of gadgets maintained by each composite.\n -- This is used to activate gadget managment only when gadgets are\n -- present.\n --\n -- In some cases, a gadget may be \"created\" before its parent. This\n -- will happen when gadgets are used to create a single \"compound\"\n -- widget. Therefore, the gadget counting works like this:\n -- a) When a composite is created, its gadget count is set to zero\n -- and all of its gadget children are counted\n -- b) When a gadget is created, its parent's gadget count is \n -- incremented iff it has been installed (has a HtkObject record)\n ---------------------------------------------------------------------*/", "/*---------------------------------------------------------\n -- If there are gadgets, install a pointer motion handler\n ---------------------------------------------------------*/", "/*---------------------------------------------------------\n -- Install a pointer motion handler when the first gadget\n -- is located\n ---------------------------------------------------------*/" ]
[ { "param": "obj", "type": "Widget" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "obj", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
_XscObjectDeriveFromWidget
XscObject
XscObject _XscObjectDeriveFromWidget( Widget obj ) { Display* x_display; XscObject self; XPointer data; int not_found; x_display = XtDisplayOfObject( obj ); not_found = XFindContext( x_display, (XID)obj, _objectContextId, &data ); if (not_found) { self = NULL; } else { self = (XscObject) data; } return self; }
/*------------------------------------------------------------------------------ -- This function retrieves the object structure associated with an object -- from the context manager ------------------------------------------------------------------------------*/
This function retrieves the object structure associated with an object from the context manager
[ "This", "function", "retrieves", "the", "object", "structure", "associated", "with", "an", "object", "from", "the", "context", "manager" ]
XscObject _XscObjectDeriveFromWidget( Widget obj ) { Display* x_display; XscObject self; XPointer data; int not_found; x_display = XtDisplayOfObject( obj ); not_found = XFindContext( x_display, (XID)obj, _objectContextId, &data ); if (not_found) { self = NULL; } else { self = (XscObject) data; } return self; }
[ "XscObject", "_XscObjectDeriveFromWidget", "(", "Widget", "obj", ")", "{", "Display", "*", "x_display", ";", "XscObject", "self", ";", "XPointer", "data", ";", "int", "not_found", ";", "x_display", "=", "XtDisplayOfObject", "(", "obj", ")", ";", "not_found", "=", "XFindContext", "(", "x_display", ",", "(", "XID", ")", "obj", ",", "_objectContextId", ",", "&", "data", ")", ";", "if", "(", "not_found", ")", "{", "self", "=", "NULL", ";", "}", "else", "{", "self", "=", "(", "XscObject", ")", "data", ";", "}", "return", "self", ";", "}" ]
This function retrieves the object structure associated with an object from the context manager
[ "This", "function", "retrieves", "the", "object", "structure", "associated", "with", "an", "object", "from", "the", "context", "manager" ]
[]
[ { "param": "obj", "type": "Widget" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "obj", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
_destroyObjectCB
void
static void _destroyObjectCB( Widget w, XtPointer cd, XtPointer cbd ) { XscObject self = _XscObjectDeriveFromWidget( w ); if (self) { /*-------------------------------------- -- If it has a tip structure delete it --------------------------------------*/ if (self->cue) { _XscCueDestroy( self->cue ); } /*-------------------------------------- -- If it has a tip structure delete it --------------------------------------*/ if (self->tip) { _XscTipDestroy( self->tip ); } /*--------------------------------------- -- If it has a hint structure delete it ---------------------------------------*/ if (self->hint) { _XscHintDestroy( self->hint ); } /*-------------------------------------------------------------- -- Remove the structure from the context manager and delete it --------------------------------------------------------------*/ XDeleteContext( XtDisplayOfObject( w ), (XID)self->object, _objectContextId ); XtFree( (char*) self ); } /*-------------------------------------------------------------------------- -- If the object beings destroyed is a gadget, update its parent's record! --------------------------------------------------------------------------*/ if (!XtIsWidget( w )) { Widget w_parent = XtParent( w ); XscObject obj_parent = _XscObjectDeriveFromWidget( w_parent ); if (obj_parent) { /*------------------------------------------------------------ -- If this is the last gadget, then it is safe to remove the -- pointer motion event handler ------------------------------------------------------------*/ if (obj_parent->gadgetChildCount == 1) { XtRemoveEventHandler( w_parent, PointerMotionMask, False, _motionInObjectEH, (XtPointer) obj_parent ); } /*---------------------------------------- -- Decrement the parent's gadget counter ----------------------------------------*/ obj_parent->gadgetChildCount -= 1; } } }
/*------------------------------------------------------------------------------ -- This callback is called to clean-up the structures associated with an -- object when its being destroyed ------------------------------------------------------------------------------*/
This callback is called to clean-up the structures associated with an object when its being destroyed
[ "This", "callback", "is", "called", "to", "clean", "-", "up", "the", "structures", "associated", "with", "an", "object", "when", "its", "being", "destroyed" ]
static void _destroyObjectCB( Widget w, XtPointer cd, XtPointer cbd ) { XscObject self = _XscObjectDeriveFromWidget( w ); if (self) { if (self->cue) { _XscCueDestroy( self->cue ); } if (self->tip) { _XscTipDestroy( self->tip ); } if (self->hint) { _XscHintDestroy( self->hint ); } XDeleteContext( XtDisplayOfObject( w ), (XID)self->object, _objectContextId ); XtFree( (char*) self ); } if (!XtIsWidget( w )) { Widget w_parent = XtParent( w ); XscObject obj_parent = _XscObjectDeriveFromWidget( w_parent ); if (obj_parent) { if (obj_parent->gadgetChildCount == 1) { XtRemoveEventHandler( w_parent, PointerMotionMask, False, _motionInObjectEH, (XtPointer) obj_parent ); } obj_parent->gadgetChildCount -= 1; } } }
[ "static", "void", "_destroyObjectCB", "(", "Widget", "w", ",", "XtPointer", "cd", ",", "XtPointer", "cbd", ")", "{", "XscObject", "self", "=", "_XscObjectDeriveFromWidget", "(", "w", ")", ";", "if", "(", "self", ")", "{", "if", "(", "self", "->", "cue", ")", "{", "_XscCueDestroy", "(", "self", "->", "cue", ")", ";", "}", "if", "(", "self", "->", "tip", ")", "{", "_XscTipDestroy", "(", "self", "->", "tip", ")", ";", "}", "if", "(", "self", "->", "hint", ")", "{", "_XscHintDestroy", "(", "self", "->", "hint", ")", ";", "}", "XDeleteContext", "(", "XtDisplayOfObject", "(", "w", ")", ",", "(", "XID", ")", "self", "->", "object", ",", "_objectContextId", ")", ";", "XtFree", "(", "(", "char", "*", ")", "self", ")", ";", "}", "if", "(", "!", "XtIsWidget", "(", "w", ")", ")", "{", "Widget", "w_parent", "=", "XtParent", "(", "w", ")", ";", "XscObject", "obj_parent", "=", "_XscObjectDeriveFromWidget", "(", "w_parent", ")", ";", "if", "(", "obj_parent", ")", "{", "if", "(", "obj_parent", "->", "gadgetChildCount", "==", "1", ")", "{", "XtRemoveEventHandler", "(", "w_parent", ",", "PointerMotionMask", ",", "False", ",", "_motionInObjectEH", ",", "(", "XtPointer", ")", "obj_parent", ")", ";", "}", "obj_parent", "->", "gadgetChildCount", "-=", "1", ";", "}", "}", "}" ]
This callback is called to clean-up the structures associated with an object when its being destroyed
[ "This", "callback", "is", "called", "to", "clean", "-", "up", "the", "structures", "associated", "with", "an", "object", "when", "its", "being", "destroyed" ]
[ "/*--------------------------------------\n -- If it has a tip structure delete it\n --------------------------------------*/", "/*--------------------------------------\n -- If it has a tip structure delete it\n --------------------------------------*/", "/*---------------------------------------\n -- If it has a hint structure delete it\n ---------------------------------------*/", "/*--------------------------------------------------------------\n -- Remove the structure from the context manager and delete it\n --------------------------------------------------------------*/", "/*--------------------------------------------------------------------------\n -- If the object beings destroyed is a gadget, update its parent's record!\n --------------------------------------------------------------------------*/", "/*------------------------------------------------------------\n -- If this is the last gadget, then it is safe to remove the\n -- pointer motion event handler\n ------------------------------------------------------------*/", "/*----------------------------------------\n -- Decrement the parent's gadget counter\n ----------------------------------------*/" ]
[ { "param": "w", "type": "Widget" }, { "param": "cd", "type": "XtPointer" }, { "param": "cbd", "type": "XtPointer" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "w", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cd", "type": "XtPointer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cbd", "type": "XtPointer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
_enterObjectCue
void
static void _enterObjectCue( XscObject self, int detail ) { if (detail == NotifyAncestor) { if (self->cue) { _XscCueActivate( self->cue ); } else if (!XtIsWMShell( self->object )) { Widget parent = XtParent( self->object ); for(;;) { XscObject parent_obj = _XscObjectDeriveFromWidget( parent ); if (parent_obj && parent_obj->cue) { /*------------------------------------ -- Thsi is a good Cue to use instead ------------------------------------*/ self->cueSubstitute = parent_obj->cue; _XscCueActivate( self->cueSubstitute ); break; } if (XtIsWMShell( parent )) break; parent = XtParent( parent ); } } } }
/*------------------------------------------------------------------------------ -- This function specifies the actions to take when the pointer enters an -- object that has an associated hint ------------------------------------------------------------------------------*/
This function specifies the actions to take when the pointer enters an object that has an associated hint
[ "This", "function", "specifies", "the", "actions", "to", "take", "when", "the", "pointer", "enters", "an", "object", "that", "has", "an", "associated", "hint" ]
static void _enterObjectCue( XscObject self, int detail ) { if (detail == NotifyAncestor) { if (self->cue) { _XscCueActivate( self->cue ); } else if (!XtIsWMShell( self->object )) { Widget parent = XtParent( self->object ); for(;;) { XscObject parent_obj = _XscObjectDeriveFromWidget( parent ); if (parent_obj && parent_obj->cue) { self->cueSubstitute = parent_obj->cue; _XscCueActivate( self->cueSubstitute ); break; } if (XtIsWMShell( parent )) break; parent = XtParent( parent ); } } } }
[ "static", "void", "_enterObjectCue", "(", "XscObject", "self", ",", "int", "detail", ")", "{", "if", "(", "detail", "==", "NotifyAncestor", ")", "{", "if", "(", "self", "->", "cue", ")", "{", "_XscCueActivate", "(", "self", "->", "cue", ")", ";", "}", "else", "if", "(", "!", "XtIsWMShell", "(", "self", "->", "object", ")", ")", "{", "Widget", "parent", "=", "XtParent", "(", "self", "->", "object", ")", ";", "for", "(", ";", ";", ")", "{", "XscObject", "parent_obj", "=", "_XscObjectDeriveFromWidget", "(", "parent", ")", ";", "if", "(", "parent_obj", "&&", "parent_obj", "->", "cue", ")", "{", "self", "->", "cueSubstitute", "=", "parent_obj", "->", "cue", ";", "_XscCueActivate", "(", "self", "->", "cueSubstitute", ")", ";", "break", ";", "}", "if", "(", "XtIsWMShell", "(", "parent", ")", ")", "break", ";", "parent", "=", "XtParent", "(", "parent", ")", ";", "}", "}", "}", "}" ]
This function specifies the actions to take when the pointer enters an object that has an associated hint
[ "This", "function", "specifies", "the", "actions", "to", "take", "when", "the", "pointer", "enters", "an", "object", "that", "has", "an", "associated", "hint" ]
[ "/*------------------------------------\n -- Thsi is a good Cue to use instead\n ------------------------------------*/" ]
[ { "param": "self", "type": "XscObject" }, { "param": "detail", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": "XscObject", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "detail", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
_enterObjectHint
void
static void _enterObjectHint( XscObject self, int detail ) { XscDisplay display = _XscDisplayDeriveFromWidget( self->object ); XscObject prev_hint_object; assert( display ); /*-------------------------------------------------------- -- If the old hint object is still active, check if it is -- flagged as compound (it better be) and keep it --------------------------------------------------------*/ prev_hint_object = _XscDisplayGetActiveHint( display ); if (prev_hint_object) { if (XscHintGetCompound( prev_hint_object->hint )) return; _leaveObject( prev_hint_object, True ); } if (self->hint) { XscHint hint = self->hint; Boolean doit = False; switch( detail ) { case NotifyAncestor: doit = True; break; case NotifyInferior: doit = True; break; case NotifyVirtual: doit = XscHintGetCompound( hint ); break; case NotifyNonlinear: doit = True; break; case NotifyNonlinearVirtual: doit = XscHintGetCompound( hint ); break; } if (doit) { _XscHintActivate( hint ); } } }
/*------------------------------------------------------------------------------ -- This function specifies the actions to take when the pointer enters an -- object that has an associated hint ------------------------------------------------------------------------------*/
This function specifies the actions to take when the pointer enters an object that has an associated hint
[ "This", "function", "specifies", "the", "actions", "to", "take", "when", "the", "pointer", "enters", "an", "object", "that", "has", "an", "associated", "hint" ]
static void _enterObjectHint( XscObject self, int detail ) { XscDisplay display = _XscDisplayDeriveFromWidget( self->object ); XscObject prev_hint_object; assert( display ); prev_hint_object = _XscDisplayGetActiveHint( display ); if (prev_hint_object) { if (XscHintGetCompound( prev_hint_object->hint )) return; _leaveObject( prev_hint_object, True ); } if (self->hint) { XscHint hint = self->hint; Boolean doit = False; switch( detail ) { case NotifyAncestor: doit = True; break; case NotifyInferior: doit = True; break; case NotifyVirtual: doit = XscHintGetCompound( hint ); break; case NotifyNonlinear: doit = True; break; case NotifyNonlinearVirtual: doit = XscHintGetCompound( hint ); break; } if (doit) { _XscHintActivate( hint ); } } }
[ "static", "void", "_enterObjectHint", "(", "XscObject", "self", ",", "int", "detail", ")", "{", "XscDisplay", "display", "=", "_XscDisplayDeriveFromWidget", "(", "self", "->", "object", ")", ";", "XscObject", "prev_hint_object", ";", "assert", "(", "display", ")", ";", "prev_hint_object", "=", "_XscDisplayGetActiveHint", "(", "display", ")", ";", "if", "(", "prev_hint_object", ")", "{", "if", "(", "XscHintGetCompound", "(", "prev_hint_object", "->", "hint", ")", ")", "return", ";", "_leaveObject", "(", "prev_hint_object", ",", "True", ")", ";", "}", "if", "(", "self", "->", "hint", ")", "{", "XscHint", "hint", "=", "self", "->", "hint", ";", "Boolean", "doit", "=", "False", ";", "switch", "(", "detail", ")", "{", "case", "NotifyAncestor", ":", "doit", "=", "True", ";", "break", ";", "case", "NotifyInferior", ":", "doit", "=", "True", ";", "break", ";", "case", "NotifyVirtual", ":", "doit", "=", "XscHintGetCompound", "(", "hint", ")", ";", "break", ";", "case", "NotifyNonlinear", ":", "doit", "=", "True", ";", "break", ";", "case", "NotifyNonlinearVirtual", ":", "doit", "=", "XscHintGetCompound", "(", "hint", ")", ";", "break", ";", "}", "if", "(", "doit", ")", "{", "_XscHintActivate", "(", "hint", ")", ";", "}", "}", "}" ]
This function specifies the actions to take when the pointer enters an object that has an associated hint
[ "This", "function", "specifies", "the", "actions", "to", "take", "when", "the", "pointer", "enters", "an", "object", "that", "has", "an", "associated", "hint" ]
[ "/*--------------------------------------------------------\n -- If the old hint object is still active, check if it is \n -- flagged as compound (it better be) and keep it\n --------------------------------------------------------*/" ]
[ { "param": "self", "type": "XscObject" }, { "param": "detail", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": "XscObject", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "detail", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
_enterObjectTip
void
static void _enterObjectTip( XscObject self, int detail ) { XscDisplay display = _XscDisplayDeriveFromWidget( self->object ); XscObject prev_tip_object; assert( display ); /*-------------------------------------------------------- -- If the old tip object is still active, check if it is -- flagged as compound (it better be) and keep it --------------------------------------------------------*/ prev_tip_object = _XscDisplayGetActiveTip( display ); if (prev_tip_object) { if (XscTipGetCompound( prev_tip_object->tip )) { return; } _leaveObject( prev_tip_object, True ); } if (self->tip == NULL) { /*-------------------------------------------------------------- -- Even though this object has no tip, it may have a group id. -- If the group id is different than the recorded id, then -- cancel the group effect. --------------------------------------------------------------*/ _XscDisplayCheckForTipGroupIdMatch( display, self->tipGroupId ); } else { XscTip tip = self->tip; Boolean doit = False; switch( detail ) { case NotifyAncestor: doit = True; break; case NotifyInferior: doit = True; break; case NotifyVirtual: doit = XscTipGetCompound( tip ); break; case NotifyNonlinear: doit = True; break; case NotifyNonlinearVirtual: doit = XscTipGetCompound( tip ); break; } /*---------------------------------------------------------------------- -- No need to worry about the group id here since this test is -- concerned about the direction of motion (inside vs. outside) that -- caused this enter event to fire ----------------------------------------------------------------------*/ if (doit) { _XscTipActivate( tip ); } } }
/*------------------------------------------------------------------------------ -- This function specifies the actions to take when the pointer enters an -- object that has an associated tip ------------------------------------------------------------------------------*/
This function specifies the actions to take when the pointer enters an object that has an associated tip
[ "This", "function", "specifies", "the", "actions", "to", "take", "when", "the", "pointer", "enters", "an", "object", "that", "has", "an", "associated", "tip" ]
static void _enterObjectTip( XscObject self, int detail ) { XscDisplay display = _XscDisplayDeriveFromWidget( self->object ); XscObject prev_tip_object; assert( display ); prev_tip_object = _XscDisplayGetActiveTip( display ); if (prev_tip_object) { if (XscTipGetCompound( prev_tip_object->tip )) { return; } _leaveObject( prev_tip_object, True ); } if (self->tip == NULL) { _XscDisplayCheckForTipGroupIdMatch( display, self->tipGroupId ); } else { XscTip tip = self->tip; Boolean doit = False; switch( detail ) { case NotifyAncestor: doit = True; break; case NotifyInferior: doit = True; break; case NotifyVirtual: doit = XscTipGetCompound( tip ); break; case NotifyNonlinear: doit = True; break; case NotifyNonlinearVirtual: doit = XscTipGetCompound( tip ); break; } if (doit) { _XscTipActivate( tip ); } } }
[ "static", "void", "_enterObjectTip", "(", "XscObject", "self", ",", "int", "detail", ")", "{", "XscDisplay", "display", "=", "_XscDisplayDeriveFromWidget", "(", "self", "->", "object", ")", ";", "XscObject", "prev_tip_object", ";", "assert", "(", "display", ")", ";", "prev_tip_object", "=", "_XscDisplayGetActiveTip", "(", "display", ")", ";", "if", "(", "prev_tip_object", ")", "{", "if", "(", "XscTipGetCompound", "(", "prev_tip_object", "->", "tip", ")", ")", "{", "return", ";", "}", "_leaveObject", "(", "prev_tip_object", ",", "True", ")", ";", "}", "if", "(", "self", "->", "tip", "==", "NULL", ")", "{", "_XscDisplayCheckForTipGroupIdMatch", "(", "display", ",", "self", "->", "tipGroupId", ")", ";", "}", "else", "{", "XscTip", "tip", "=", "self", "->", "tip", ";", "Boolean", "doit", "=", "False", ";", "switch", "(", "detail", ")", "{", "case", "NotifyAncestor", ":", "doit", "=", "True", ";", "break", ";", "case", "NotifyInferior", ":", "doit", "=", "True", ";", "break", ";", "case", "NotifyVirtual", ":", "doit", "=", "XscTipGetCompound", "(", "tip", ")", ";", "break", ";", "case", "NotifyNonlinear", ":", "doit", "=", "True", ";", "break", ";", "case", "NotifyNonlinearVirtual", ":", "doit", "=", "XscTipGetCompound", "(", "tip", ")", ";", "break", ";", "}", "if", "(", "doit", ")", "{", "_XscTipActivate", "(", "tip", ")", ";", "}", "}", "}" ]
This function specifies the actions to take when the pointer enters an object that has an associated tip
[ "This", "function", "specifies", "the", "actions", "to", "take", "when", "the", "pointer", "enters", "an", "object", "that", "has", "an", "associated", "tip" ]
[ "/*--------------------------------------------------------\n -- If the old tip object is still active, check if it is \n -- flagged as compound (it better be) and keep it\n --------------------------------------------------------*/", "/*--------------------------------------------------------------\n -- Even though this object has no tip, it may have a group id.\n -- If the group id is different than the recorded id, then\n -- cancel the group effect.\n --------------------------------------------------------------*/", "/*----------------------------------------------------------------------\n -- No need to worry about the group id here since this test is \n -- concerned about the direction of motion (inside vs. outside) that \n -- caused this enter event to fire\n ----------------------------------------------------------------------*/" ]
[ { "param": "self", "type": "XscObject" }, { "param": "detail", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": "XscObject", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "detail", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
_enterOrLeaveObjectEH
void
static void _enterOrLeaveObjectEH( Widget w, XtPointer cd, XEvent* event, Boolean* cont ) { XscObject self = (XscObject) cd; assert( self ); if (event->type == EnterNotify) { XCrossingEvent* enter_event = &(event->xcrossing); /*------------------------------------------------------------- -- Always enter the object even if we are logically entering -- a gadget. This matches how the events are sent for widget -------------------------------------------------------------*/ _enterObjectHint( self, enter_event->detail ); _enterObjectTip ( self, enter_event->detail ); /*------------------------------------------------------------- -- Don't bother looking for gadgets in non-manager widget and -- ignore gadgets if gadget_processing is false -------------------------------------------------------------*/ if (XtIsComposite( w ) && self->gadgetProcessing) { /*------------------------------------------------ -- See if there is a gadget at this x,y location ------------------------------------------------*/ Widget gadget = _XscHelpGetGadgetChild( w, enter_event->x, enter_event->y ); if (gadget) { if (XtIsSensitive( gadget )) { XscObject gadget_object = _XscObjectDeriveFromWidget( gadget ); /*---------------------------------------------------------- -- Make the gadget act like it received the event directly ----------------------------------------------------------*/ if (gadget_object) { _enterObjectHint( gadget_object, NotifyAncestor ); _enterObjectTip ( gadget_object, NotifyAncestor ); /*------------------------------------------------- -- Record which of the object's gadgets is active -------------------------------------------------*/ self->activeGadget = gadget_object; } } } } } else if (event->type == LeaveNotify) { XCrossingEvent* leave_event = &(event->xcrossing); /*----------------------------------------------------------------- -- If there is an active gadget associated with this widget, then -- release the gadget; then release this widget -----------------------------------------------------------------*/ if (self->activeGadget) { _leaveObject( self->activeGadget, True ); self->activeGadget = NULL; } _leaveObject( self, leave_event->detail != NotifyInferior ); } }
/*------------------------------------------------------------------------------ -- This function monitores when the pointer moves into or out of a widget ------------------------------------------------------------------------------*/
This function monitores when the pointer moves into or out of a widget
[ "This", "function", "monitores", "when", "the", "pointer", "moves", "into", "or", "out", "of", "a", "widget" ]
static void _enterOrLeaveObjectEH( Widget w, XtPointer cd, XEvent* event, Boolean* cont ) { XscObject self = (XscObject) cd; assert( self ); if (event->type == EnterNotify) { XCrossingEvent* enter_event = &(event->xcrossing); _enterObjectHint( self, enter_event->detail ); _enterObjectTip ( self, enter_event->detail ); if (XtIsComposite( w ) && self->gadgetProcessing) { Widget gadget = _XscHelpGetGadgetChild( w, enter_event->x, enter_event->y ); if (gadget) { if (XtIsSensitive( gadget )) { XscObject gadget_object = _XscObjectDeriveFromWidget( gadget ); if (gadget_object) { _enterObjectHint( gadget_object, NotifyAncestor ); _enterObjectTip ( gadget_object, NotifyAncestor ); self->activeGadget = gadget_object; } } } } } else if (event->type == LeaveNotify) { XCrossingEvent* leave_event = &(event->xcrossing); if (self->activeGadget) { _leaveObject( self->activeGadget, True ); self->activeGadget = NULL; } _leaveObject( self, leave_event->detail != NotifyInferior ); } }
[ "static", "void", "_enterOrLeaveObjectEH", "(", "Widget", "w", ",", "XtPointer", "cd", ",", "XEvent", "*", "event", ",", "Boolean", "*", "cont", ")", "{", "XscObject", "self", "=", "(", "XscObject", ")", "cd", ";", "assert", "(", "self", ")", ";", "if", "(", "event", "->", "type", "==", "EnterNotify", ")", "{", "XCrossingEvent", "*", "enter_event", "=", "&", "(", "event", "->", "xcrossing", ")", ";", "_enterObjectHint", "(", "self", ",", "enter_event", "->", "detail", ")", ";", "_enterObjectTip", "(", "self", ",", "enter_event", "->", "detail", ")", ";", "if", "(", "XtIsComposite", "(", "w", ")", "&&", "self", "->", "gadgetProcessing", ")", "{", "Widget", "gadget", "=", "_XscHelpGetGadgetChild", "(", "w", ",", "enter_event", "->", "x", ",", "enter_event", "->", "y", ")", ";", "if", "(", "gadget", ")", "{", "if", "(", "XtIsSensitive", "(", "gadget", ")", ")", "{", "XscObject", "gadget_object", "=", "_XscObjectDeriveFromWidget", "(", "gadget", ")", ";", "if", "(", "gadget_object", ")", "{", "_enterObjectHint", "(", "gadget_object", ",", "NotifyAncestor", ")", ";", "_enterObjectTip", "(", "gadget_object", ",", "NotifyAncestor", ")", ";", "self", "->", "activeGadget", "=", "gadget_object", ";", "}", "}", "}", "}", "}", "else", "if", "(", "event", "->", "type", "==", "LeaveNotify", ")", "{", "XCrossingEvent", "*", "leave_event", "=", "&", "(", "event", "->", "xcrossing", ")", ";", "if", "(", "self", "->", "activeGadget", ")", "{", "_leaveObject", "(", "self", "->", "activeGadget", ",", "True", ")", ";", "self", "->", "activeGadget", "=", "NULL", ";", "}", "_leaveObject", "(", "self", ",", "leave_event", "->", "detail", "!=", "NotifyInferior", ")", ";", "}", "}" ]
This function monitores when the pointer moves into or out of a widget
[ "This", "function", "monitores", "when", "the", "pointer", "moves", "into", "or", "out", "of", "a", "widget" ]
[ "/*-------------------------------------------------------------\n -- Always enter the object even if we are logically entering\n -- a gadget. This matches how the events are sent for widget\n -------------------------------------------------------------*/", "/*-------------------------------------------------------------\n -- Don't bother looking for gadgets in non-manager widget and\n -- ignore gadgets if gadget_processing is false\n -------------------------------------------------------------*/", "/*------------------------------------------------\n -- See if there is a gadget at this x,y location\n ------------------------------------------------*/", "/*----------------------------------------------------------\n -- Make the gadget act like it received the event directly\n ----------------------------------------------------------*/", "/*-------------------------------------------------\n -- Record which of the object's gadgets is active\n -------------------------------------------------*/", "/*-----------------------------------------------------------------\n -- If there is an active gadget associated with this widget, then\n -- release the gadget; then release this widget\n -----------------------------------------------------------------*/" ]
[ { "param": "w", "type": "Widget" }, { "param": "cd", "type": "XtPointer" }, { "param": "event", "type": "XEvent" }, { "param": "cont", "type": "Boolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "w", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cd", "type": "XtPointer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "event", "type": "XEvent", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cont", "type": "Boolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
_focusChangeEH
void
static void _focusChangeEH( Widget w, XtPointer cd, XEvent* event, Boolean* cont ) { XscObject self = (XscObject) cd; XFocusChangeEvent* focus = &(event->xfocus); if (focus->mode != NotifyNormal) return; if (event->type == FocusIn) { /*------------------------------------------------------------- -- Always enter the object even if we are logically entering -- a gadget. This matches how the events are sent for widget -------------------------------------------------------------*/ _enterObjectCue( self, focus->detail ); } else if (event->type == FocusOut) { _leaveObjectCue( self, focus->detail ); } }
/*------------------------------------------------------------------------------ -- This function monitores when the pointer moves into or out of a widget ------------------------------------------------------------------------------*/
This function monitores when the pointer moves into or out of a widget
[ "This", "function", "monitores", "when", "the", "pointer", "moves", "into", "or", "out", "of", "a", "widget" ]
static void _focusChangeEH( Widget w, XtPointer cd, XEvent* event, Boolean* cont ) { XscObject self = (XscObject) cd; XFocusChangeEvent* focus = &(event->xfocus); if (focus->mode != NotifyNormal) return; if (event->type == FocusIn) { _enterObjectCue( self, focus->detail ); } else if (event->type == FocusOut) { _leaveObjectCue( self, focus->detail ); } }
[ "static", "void", "_focusChangeEH", "(", "Widget", "w", ",", "XtPointer", "cd", ",", "XEvent", "*", "event", ",", "Boolean", "*", "cont", ")", "{", "XscObject", "self", "=", "(", "XscObject", ")", "cd", ";", "XFocusChangeEvent", "*", "focus", "=", "&", "(", "event", "->", "xfocus", ")", ";", "if", "(", "focus", "->", "mode", "!=", "NotifyNormal", ")", "return", ";", "if", "(", "event", "->", "type", "==", "FocusIn", ")", "{", "_enterObjectCue", "(", "self", ",", "focus", "->", "detail", ")", ";", "}", "else", "if", "(", "event", "->", "type", "==", "FocusOut", ")", "{", "_leaveObjectCue", "(", "self", ",", "focus", "->", "detail", ")", ";", "}", "}" ]
This function monitores when the pointer moves into or out of a widget
[ "This", "function", "monitores", "when", "the", "pointer", "moves", "into", "or", "out", "of", "a", "widget" ]
[ "/*-------------------------------------------------------------\n -- Always enter the object even if we are logically entering\n -- a gadget. This matches how the events are sent for widget\n -------------------------------------------------------------*/" ]
[ { "param": "w", "type": "Widget" }, { "param": "cd", "type": "XtPointer" }, { "param": "event", "type": "XEvent" }, { "param": "cont", "type": "Boolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "w", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cd", "type": "XtPointer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "event", "type": "XEvent", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cont", "type": "Boolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
_leaveObject
void
static void _leaveObject( XscObject self, Boolean drop_compound ) { XscDisplay display = _XscDisplayDeriveFromWidget( self->object ); /*----------------------------- -- If the object has a tip... -----------------------------*/ if (self->tip) { /*---------------------------------------------------------- -- If the current tip is "compound", release it _only_ if -- the pointer moved to an exterior window ----------------------------------------------------------*/ if (!XscTipGetCompound( self->tip ) || drop_compound) { _XscTipPopdown( self->tip ); } } /*------------------------------- -- If there is a hint record... -------------------------------*/ if (self->hint) { /*------------------------------------------------- -- Verify that it is active in the display record -------------------------------------------------*/ if (self == _XscDisplayGetActiveHint( display )) { /*---------------------------------------------------------- -- If the current hint is "compound", release it _only_ if -- the pointer moved to an exterior window ----------------------------------------------------------*/ if (!XscHintGetCompound( self->hint ) || drop_compound) { XscShell shell =_XscShellDeriveFromWidget( self->object ); /*------------------------------------------------------------ -- Set the timer to unmap the hint. The hint could be -- unmapped right away; however, this would lead to flashing -- and blinking if the pointer was quickly moved from object -- to object (e.g., in a menu). By delaying the unmap, -- it can sometimes be avoided all together. ------------------------------------------------------------*/ if (shell) { _XscShellEraseHint( shell ); } _XscDisplaySetActiveHint( display, NULL ); } } } }
/*------------------------------------------------------------------------------ -- This function is called whenever the pointer moves off of a screen object. ------------------------------------------------------------------------------*/
This function is called whenever the pointer moves off of a screen object.
[ "This", "function", "is", "called", "whenever", "the", "pointer", "moves", "off", "of", "a", "screen", "object", "." ]
static void _leaveObject( XscObject self, Boolean drop_compound ) { XscDisplay display = _XscDisplayDeriveFromWidget( self->object ); if (self->tip) { if (!XscTipGetCompound( self->tip ) || drop_compound) { _XscTipPopdown( self->tip ); } } if (self->hint) { if (self == _XscDisplayGetActiveHint( display )) { if (!XscHintGetCompound( self->hint ) || drop_compound) { XscShell shell =_XscShellDeriveFromWidget( self->object ); if (shell) { _XscShellEraseHint( shell ); } _XscDisplaySetActiveHint( display, NULL ); } } } }
[ "static", "void", "_leaveObject", "(", "XscObject", "self", ",", "Boolean", "drop_compound", ")", "{", "XscDisplay", "display", "=", "_XscDisplayDeriveFromWidget", "(", "self", "->", "object", ")", ";", "if", "(", "self", "->", "tip", ")", "{", "if", "(", "!", "XscTipGetCompound", "(", "self", "->", "tip", ")", "||", "drop_compound", ")", "{", "_XscTipPopdown", "(", "self", "->", "tip", ")", ";", "}", "}", "if", "(", "self", "->", "hint", ")", "{", "if", "(", "self", "==", "_XscDisplayGetActiveHint", "(", "display", ")", ")", "{", "if", "(", "!", "XscHintGetCompound", "(", "self", "->", "hint", ")", "||", "drop_compound", ")", "{", "XscShell", "shell", "=", "_XscShellDeriveFromWidget", "(", "self", "->", "object", ")", ";", "if", "(", "shell", ")", "{", "_XscShellEraseHint", "(", "shell", ")", ";", "}", "_XscDisplaySetActiveHint", "(", "display", ",", "NULL", ")", ";", "}", "}", "}", "}" ]
This function is called whenever the pointer moves off of a screen object.
[ "This", "function", "is", "called", "whenever", "the", "pointer", "moves", "off", "of", "a", "screen", "object", "." ]
[ "/*-----------------------------\n -- If the object has a tip...\n -----------------------------*/", "/*----------------------------------------------------------\n -- If the current tip is \"compound\", release it _only_ if\n -- the pointer moved to an exterior window\n ----------------------------------------------------------*/", "/*-------------------------------\n -- If there is a hint record...\n -------------------------------*/", "/*-------------------------------------------------\n -- Verify that it is active in the display record\n -------------------------------------------------*/", "/*----------------------------------------------------------\n -- If the current hint is \"compound\", release it _only_ if\n -- the pointer moved to an exterior window\n ----------------------------------------------------------*/", "/*------------------------------------------------------------\n -- Set the timer to unmap the hint. The hint could be\n -- unmapped right away; however, this would lead to flashing\n -- and blinking if the pointer was quickly moved from object\n -- to object (e.g., in a menu). By delaying the unmap,\n -- it can sometimes be avoided all together.\n ------------------------------------------------------------*/" ]
[ { "param": "self", "type": "XscObject" }, { "param": "drop_compound", "type": "Boolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": "XscObject", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "drop_compound", "type": "Boolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
_motionInObjectEH
void
static void _motionInObjectEH( Widget w, XtPointer cd, XEvent* event, Boolean* not_used ) { Widget gadget = NULL; XscObject self = (XscObject) cd; assert( self ); /*---------------------------------------------------------- -- If gadget processing is not desired, return immediately ----------------------------------------------------------*/ if (!self->gadgetProcessing) { return; } if (event->type == MotionNotify) { if (event->xmotion.subwindow != 0) return; /*-------------------------------------- -- See if the pointer is over a gadget --------------------------------------*/ gadget = _XscHelpGetGadgetChild( w, event->xmotion.x, event->xmotion.y ); /*----------------------------------------- -- If the pointer is over a gadget and... -----------------------------------------*/ if (gadget) { /*------------------------------- -- If there is an active gadget -------------------------------*/ if (self->activeGadget) { /*------------------------------------------------------------- -- If the new gadget is different then the active gadget, -- then release the active gadget; however, if the pointer is -- still over the active gadget, then just forget about it -------------------------------------------------------------*/ if (gadget != self->activeGadget->object) { _leaveObject( self->activeGadget, True ); self->activeGadget = NULL; } else { gadget = NULL; } } /*------------------------------------------------------------ -- If a new gadget needs to be activated, first make sure it -- is sensitive. ------------------------------------------------------------*/ if (gadget) { if (XtIsSensitive( gadget )) { XscObject gadget_object = _XscObjectDeriveFromWidget( gadget ); if (gadget_object) { _enterObjectHint( gadget_object, NotifyAncestor ); _enterObjectTip ( gadget_object, NotifyAncestor ); self->activeGadget = gadget_object; } } } } else { /*---------------------------------------------------------------- -- If the pointer is not over a gadget and if there is a gadget -- recorded as active, then the pointer must have just moved off -- of it; therfore, it needs to be released and the widget -- itself should be activated. ----------------------------------------------------------------*/ if (self->activeGadget) { _leaveObject( self->activeGadget, True ); self->activeGadget = NULL; _enterObjectHint( self, NotifyAncestor ); _enterObjectTip ( self, NotifyAncestor ); } } } }
/*------------------------------------------------------------------------------ -- This event handler is called when the pointer is moved within a Composite -- widget that has one or more gadgets. This function controls the gadget -- processing logic. ------------------------------------------------------------------------------*/
This event handler is called when the pointer is moved within a Composite widget that has one or more gadgets. This function controls the gadget processing logic.
[ "This", "event", "handler", "is", "called", "when", "the", "pointer", "is", "moved", "within", "a", "Composite", "widget", "that", "has", "one", "or", "more", "gadgets", ".", "This", "function", "controls", "the", "gadget", "processing", "logic", "." ]
static void _motionInObjectEH( Widget w, XtPointer cd, XEvent* event, Boolean* not_used ) { Widget gadget = NULL; XscObject self = (XscObject) cd; assert( self ); if (!self->gadgetProcessing) { return; } if (event->type == MotionNotify) { if (event->xmotion.subwindow != 0) return; gadget = _XscHelpGetGadgetChild( w, event->xmotion.x, event->xmotion.y ); if (gadget) { if (self->activeGadget) { if (gadget != self->activeGadget->object) { _leaveObject( self->activeGadget, True ); self->activeGadget = NULL; } else { gadget = NULL; } } if (gadget) { if (XtIsSensitive( gadget )) { XscObject gadget_object = _XscObjectDeriveFromWidget( gadget ); if (gadget_object) { _enterObjectHint( gadget_object, NotifyAncestor ); _enterObjectTip ( gadget_object, NotifyAncestor ); self->activeGadget = gadget_object; } } } } else { if (self->activeGadget) { _leaveObject( self->activeGadget, True ); self->activeGadget = NULL; _enterObjectHint( self, NotifyAncestor ); _enterObjectTip ( self, NotifyAncestor ); } } } }
[ "static", "void", "_motionInObjectEH", "(", "Widget", "w", ",", "XtPointer", "cd", ",", "XEvent", "*", "event", ",", "Boolean", "*", "not_used", ")", "{", "Widget", "gadget", "=", "NULL", ";", "XscObject", "self", "=", "(", "XscObject", ")", "cd", ";", "assert", "(", "self", ")", ";", "if", "(", "!", "self", "->", "gadgetProcessing", ")", "{", "return", ";", "}", "if", "(", "event", "->", "type", "==", "MotionNotify", ")", "{", "if", "(", "event", "->", "xmotion", ".", "subwindow", "!=", "0", ")", "return", ";", "gadget", "=", "_XscHelpGetGadgetChild", "(", "w", ",", "event", "->", "xmotion", ".", "x", ",", "event", "->", "xmotion", ".", "y", ")", ";", "if", "(", "gadget", ")", "{", "if", "(", "self", "->", "activeGadget", ")", "{", "if", "(", "gadget", "!=", "self", "->", "activeGadget", "->", "object", ")", "{", "_leaveObject", "(", "self", "->", "activeGadget", ",", "True", ")", ";", "self", "->", "activeGadget", "=", "NULL", ";", "}", "else", "{", "gadget", "=", "NULL", ";", "}", "}", "if", "(", "gadget", ")", "{", "if", "(", "XtIsSensitive", "(", "gadget", ")", ")", "{", "XscObject", "gadget_object", "=", "_XscObjectDeriveFromWidget", "(", "gadget", ")", ";", "if", "(", "gadget_object", ")", "{", "_enterObjectHint", "(", "gadget_object", ",", "NotifyAncestor", ")", ";", "_enterObjectTip", "(", "gadget_object", ",", "NotifyAncestor", ")", ";", "self", "->", "activeGadget", "=", "gadget_object", ";", "}", "}", "}", "}", "else", "{", "if", "(", "self", "->", "activeGadget", ")", "{", "_leaveObject", "(", "self", "->", "activeGadget", ",", "True", ")", ";", "self", "->", "activeGadget", "=", "NULL", ";", "_enterObjectHint", "(", "self", ",", "NotifyAncestor", ")", ";", "_enterObjectTip", "(", "self", ",", "NotifyAncestor", ")", ";", "}", "}", "}", "}" ]
This event handler is called when the pointer is moved within a Composite widget that has one or more gadgets.
[ "This", "event", "handler", "is", "called", "when", "the", "pointer", "is", "moved", "within", "a", "Composite", "widget", "that", "has", "one", "or", "more", "gadgets", "." ]
[ "/*----------------------------------------------------------\n -- If gadget processing is not desired, return immediately\n ----------------------------------------------------------*/", "/*--------------------------------------\n -- See if the pointer is over a gadget\n --------------------------------------*/", "/*-----------------------------------------\n -- If the pointer is over a gadget and...\n -----------------------------------------*/", "/*-------------------------------\n \t -- If there is an active gadget\n \t -------------------------------*/", "/*-------------------------------------------------------------\n -- If the new gadget is different then the active gadget,\n -- then release the active gadget; however, if the pointer is \n -- still over the active gadget, then just forget about it\n -------------------------------------------------------------*/", "/*------------------------------------------------------------\n \t -- If a new gadget needs to be activated, first make sure it\n \t -- is sensitive.\n \t ------------------------------------------------------------*/", "/*----------------------------------------------------------------\n -- If the pointer is not over a gadget and if there is a gadget\n -- recorded as active, then the pointer must have just moved off\n -- of it; therfore, it needs to be released and the widget \n -- itself should be activated.\n ----------------------------------------------------------------*/" ]
[ { "param": "w", "type": "Widget" }, { "param": "cd", "type": "XtPointer" }, { "param": "event", "type": "XEvent" }, { "param": "not_used", "type": "Boolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "w", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cd", "type": "XtPointer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "event", "type": "XEvent", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "not_used", "type": "Boolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
_setupHint
void
static void _setupHint( XscObject self, const char* default_topic ) { XscText text = _XscTextCreate(); _XscTextLoadHintResources( text, self->object, default_topic ); /*---------------------------------------------------------------- -- If no text.str value was found, then, by definition, there is -- no hint currently associated with this object. ----------------------------------------------------------------*/ if (_XscTextStringExists( text )) { /*-------------------------------------------- -- If there is no hint record, then make one --------------------------------------------*/ if (self->hint == NULL) { self->hint = _XscHintCreate( self ); } _XscHintLoadResources( self->hint, text ); } else { /*------------------------------------------------------------- -- If there is an old hint record, destroy it since there are -- no hints currently defined in the resource database -------------------------------------------------------------*/ if (self->hint) { _XscHintDestroy( self->hint ); self->hint = NULL; } _XscTextDestroy( text ); } }
/*------------------------------------------------------------------------------ -- This function is used to retrieve hint attributes from the resource db ------------------------------------------------------------------------------*/
This function is used to retrieve hint attributes from the resource db
[ "This", "function", "is", "used", "to", "retrieve", "hint", "attributes", "from", "the", "resource", "db" ]
static void _setupHint( XscObject self, const char* default_topic ) { XscText text = _XscTextCreate(); _XscTextLoadHintResources( text, self->object, default_topic ); if (_XscTextStringExists( text )) { if (self->hint == NULL) { self->hint = _XscHintCreate( self ); } _XscHintLoadResources( self->hint, text ); } else { if (self->hint) { _XscHintDestroy( self->hint ); self->hint = NULL; } _XscTextDestroy( text ); } }
[ "static", "void", "_setupHint", "(", "XscObject", "self", ",", "const", "char", "*", "default_topic", ")", "{", "XscText", "text", "=", "_XscTextCreate", "(", ")", ";", "_XscTextLoadHintResources", "(", "text", ",", "self", "->", "object", ",", "default_topic", ")", ";", "if", "(", "_XscTextStringExists", "(", "text", ")", ")", "{", "if", "(", "self", "->", "hint", "==", "NULL", ")", "{", "self", "->", "hint", "=", "_XscHintCreate", "(", "self", ")", ";", "}", "_XscHintLoadResources", "(", "self", "->", "hint", ",", "text", ")", ";", "}", "else", "{", "if", "(", "self", "->", "hint", ")", "{", "_XscHintDestroy", "(", "self", "->", "hint", ")", ";", "self", "->", "hint", "=", "NULL", ";", "}", "_XscTextDestroy", "(", "text", ")", ";", "}", "}" ]
This function is used to retrieve hint attributes from the resource db
[ "This", "function", "is", "used", "to", "retrieve", "hint", "attributes", "from", "the", "resource", "db" ]
[ "/*----------------------------------------------------------------\n -- If no text.str value was found, then, by definition, there is\n -- no hint currently associated with this object. \n ----------------------------------------------------------------*/", "/*--------------------------------------------\n -- If there is no hint record, then make one\n --------------------------------------------*/", "/*-------------------------------------------------------------\n -- If there is an old hint record, destroy it since there are\n -- no hints currently defined in the resource database\n -------------------------------------------------------------*/" ]
[ { "param": "self", "type": "XscObject" }, { "param": "default_topic", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": "XscObject", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "default_topic", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
_setupObject
void
static void _setupObject( XscObject self ) { typedef struct _ObjectResources { Boolean gadget_processing; int tip_group_id; unsigned char tip_group_override; XFontStruct* font; } ObjectResources; ObjectResources object_resources; XscObject _parentObj = NULL; Widget _parent = NULL; # define OFFSET_OF( mem ) XtOffsetOf( ObjectResources, mem ) static XtResource resource[] = { { XmNxscFont, XmCXscFont, XtRFontStruct, sizeof( XFontStruct* ), OFFSET_OF( font ), XtRString, XscHelpDefaultFont },{ XmNxscGadgetProcessing, XmCXscGadgetProcessing, XmRBoolean, sizeof( Boolean ), OFFSET_OF( gadget_processing ), XtRImmediate, (XtPointer) (Boolean) True },{ XmNxscTipGroupId, XmCXscTipGroupId, XmRXscTipGroupId, sizeof( int ), OFFSET_OF( tip_group_id ), XtRImmediate, (XtPointer) (int) XmXSC_TIP_GROUP_PARENT },{ XmNxscTipGroupOverride, XmCXscTipGroupOverride, XmRXscTipGroup, sizeof( unsigned char ), OFFSET_OF(tip_group_override), XtRImmediate, (XtPointer) (unsigned char) XmXSC_TIP_GROUP_NULL } }; # undef OFFSET_OF memset( (char*) &object_resources, '\0', sizeof( ObjectResources ) ); XtGetApplicationResources( self->object, &object_resources, resource, (Cardinal) XtNumber( resource ), NULL, (Cardinal) 0 ); self->gadgetProcessing = object_resources.gadget_processing; self->font = object_resources.font; /*--------------------------- -- This block is deprecated ---------------------------*/ switch ((int) (signed char) object_resources.tip_group_override) { case XmXSC_TIP_GROUP_SELF: case XmXSC_TIP_GROUP_PARENT: self->tipGroupId = (int) (signed char)object_resources.tip_group_override; break; default: self->tipGroupId = object_resources.tip_group_id; break; } _parent = XtParent( self->object ); if (_parent) { _parentObj = _XscObjectDeriveFromWidget( _parent ); if (_parentObj) { self->hasGroupLeader = _parentObj->hasGroupLeader; } } if (self->tipGroupId == XmXSC_TIP_GROUP_NULL) { if (__smartGroupDefault) { if (_parentObj && _parentObj->hasGroupLeader) { self->tipGroupId = XmXSC_TIP_GROUP_PARENT; } else { self->tipGroupId = XmXSC_TIP_GROUP_SELF; } } else { self->tipGroupId = XmXSC_TIP_GROUP_PARENT; } } else { /*-------------------------------------------------------------------- -- Once this happens, by default, all children inherit group id from -- the parent instead of from self --------------------------------------------------------------------*/ self->hasGroupLeader = True; } if (self->tipGroupId == XmXSC_TIP_GROUP_PARENT) { if (_parent && !XtIsWMShell( _parent )) { if (_parentObj) { self->tipGroupId = _parentObj->tipGroupId; } else { self->tipGroupId = - ((int) self->object); } } else { self->tipGroupId = - ((int) self->object); } } else if (self->tipGroupId == XmXSC_TIP_GROUP_SELF) { self->tipGroupId = - ((int) self->object); } }
/*------------------------------------------------------------------------------ -- This function is used to retrieve object attributes from the resource db ------------------------------------------------------------------------------*/
This function is used to retrieve object attributes from the resource db
[ "This", "function", "is", "used", "to", "retrieve", "object", "attributes", "from", "the", "resource", "db" ]
static void _setupObject( XscObject self ) { typedef struct _ObjectResources { Boolean gadget_processing; int tip_group_id; unsigned char tip_group_override; XFontStruct* font; } ObjectResources; ObjectResources object_resources; XscObject _parentObj = NULL; Widget _parent = NULL; # define OFFSET_OF( mem ) XtOffsetOf( ObjectResources, mem ) static XtResource resource[] = { { XmNxscFont, XmCXscFont, XtRFontStruct, sizeof( XFontStruct* ), OFFSET_OF( font ), XtRString, XscHelpDefaultFont },{ XmNxscGadgetProcessing, XmCXscGadgetProcessing, XmRBoolean, sizeof( Boolean ), OFFSET_OF( gadget_processing ), XtRImmediate, (XtPointer) (Boolean) True },{ XmNxscTipGroupId, XmCXscTipGroupId, XmRXscTipGroupId, sizeof( int ), OFFSET_OF( tip_group_id ), XtRImmediate, (XtPointer) (int) XmXSC_TIP_GROUP_PARENT },{ XmNxscTipGroupOverride, XmCXscTipGroupOverride, XmRXscTipGroup, sizeof( unsigned char ), OFFSET_OF(tip_group_override), XtRImmediate, (XtPointer) (unsigned char) XmXSC_TIP_GROUP_NULL } }; # undef OFFSET_OF memset( (char*) &object_resources, '\0', sizeof( ObjectResources ) ); XtGetApplicationResources( self->object, &object_resources, resource, (Cardinal) XtNumber( resource ), NULL, (Cardinal) 0 ); self->gadgetProcessing = object_resources.gadget_processing; self->font = object_resources.font; switch ((int) (signed char) object_resources.tip_group_override) { case XmXSC_TIP_GROUP_SELF: case XmXSC_TIP_GROUP_PARENT: self->tipGroupId = (int) (signed char)object_resources.tip_group_override; break; default: self->tipGroupId = object_resources.tip_group_id; break; } _parent = XtParent( self->object ); if (_parent) { _parentObj = _XscObjectDeriveFromWidget( _parent ); if (_parentObj) { self->hasGroupLeader = _parentObj->hasGroupLeader; } } if (self->tipGroupId == XmXSC_TIP_GROUP_NULL) { if (__smartGroupDefault) { if (_parentObj && _parentObj->hasGroupLeader) { self->tipGroupId = XmXSC_TIP_GROUP_PARENT; } else { self->tipGroupId = XmXSC_TIP_GROUP_SELF; } } else { self->tipGroupId = XmXSC_TIP_GROUP_PARENT; } } else { self->hasGroupLeader = True; } if (self->tipGroupId == XmXSC_TIP_GROUP_PARENT) { if (_parent && !XtIsWMShell( _parent )) { if (_parentObj) { self->tipGroupId = _parentObj->tipGroupId; } else { self->tipGroupId = - ((int) self->object); } } else { self->tipGroupId = - ((int) self->object); } } else if (self->tipGroupId == XmXSC_TIP_GROUP_SELF) { self->tipGroupId = - ((int) self->object); } }
[ "static", "void", "_setupObject", "(", "XscObject", "self", ")", "{", "typedef", "struct", "_ObjectResources", "{", "Boolean", "gadget_processing", ";", "int", "tip_group_id", ";", "unsigned", "char", "tip_group_override", ";", "XFontStruct", "*", "font", ";", "}", "ObjectResources", ";", "ObjectResources", "object_resources", ";", "XscObject", "_parentObj", "=", "NULL", ";", "Widget", "_parent", "=", "NULL", ";", "# define", "OFFSET_OF", "(", "mem", ")", " XtOffsetOf( ObjectResources, mem )", "\n", "static", "XtResource", "resource", "[", "]", "=", "{", "{", "XmNxscFont", ",", "XmCXscFont", ",", "XtRFontStruct", ",", "sizeof", "(", "XFontStruct", "*", ")", ",", "OFFSET_OF", "(", "font", ")", ",", "XtRString", ",", "XscHelpDefaultFont", "}", ",", "{", "XmNxscGadgetProcessing", ",", "XmCXscGadgetProcessing", ",", "XmRBoolean", ",", "sizeof", "(", "Boolean", ")", ",", "OFFSET_OF", "(", "gadget_processing", ")", ",", "XtRImmediate", ",", "(", "XtPointer", ")", "(", "Boolean", ")", "True", "}", ",", "{", "XmNxscTipGroupId", ",", "XmCXscTipGroupId", ",", "XmRXscTipGroupId", ",", "sizeof", "(", "int", ")", ",", "OFFSET_OF", "(", "tip_group_id", ")", ",", "XtRImmediate", ",", "(", "XtPointer", ")", "(", "int", ")", "XmXSC_TIP_GROUP_PARENT", "}", ",", "{", "XmNxscTipGroupOverride", ",", "XmCXscTipGroupOverride", ",", "XmRXscTipGroup", ",", "sizeof", "(", "unsigned", "char", ")", ",", "OFFSET_OF", "(", "tip_group_override", ")", ",", "XtRImmediate", ",", "(", "XtPointer", ")", "(", "unsigned", "char", ")", "XmXSC_TIP_GROUP_NULL", "}", "}", ";", "# undef", " OFFSET_OF", "\n", "memset", "(", "(", "char", "*", ")", "&", "object_resources", ",", "'", "\\0", "'", ",", "sizeof", "(", "ObjectResources", ")", ")", ";", "XtGetApplicationResources", "(", "self", "->", "object", ",", "&", "object_resources", ",", "resource", ",", "(", "Cardinal", ")", "XtNumber", "(", "resource", ")", ",", "NULL", ",", "(", "Cardinal", ")", "0", ")", ";", "self", "->", "gadgetProcessing", "=", "object_resources", ".", "gadget_processing", ";", "self", "->", "font", "=", "object_resources", ".", "font", ";", "switch", "(", "(", "int", ")", "(", "signed", "char", ")", "object_resources", ".", "tip_group_override", ")", "{", "case", "XmXSC_TIP_GROUP_SELF", ":", "case", "XmXSC_TIP_GROUP_PARENT", ":", "self", "->", "tipGroupId", "=", "(", "int", ")", "(", "signed", "char", ")", "object_resources", ".", "tip_group_override", ";", "break", ";", "default", ":", "self", "->", "tipGroupId", "=", "object_resources", ".", "tip_group_id", ";", "break", ";", "}", "_parent", "=", "XtParent", "(", "self", "->", "object", ")", ";", "if", "(", "_parent", ")", "{", "_parentObj", "=", "_XscObjectDeriveFromWidget", "(", "_parent", ")", ";", "if", "(", "_parentObj", ")", "{", "self", "->", "hasGroupLeader", "=", "_parentObj", "->", "hasGroupLeader", ";", "}", "}", "if", "(", "self", "->", "tipGroupId", "==", "XmXSC_TIP_GROUP_NULL", ")", "{", "if", "(", "__smartGroupDefault", ")", "{", "if", "(", "_parentObj", "&&", "_parentObj", "->", "hasGroupLeader", ")", "{", "self", "->", "tipGroupId", "=", "XmXSC_TIP_GROUP_PARENT", ";", "}", "else", "{", "self", "->", "tipGroupId", "=", "XmXSC_TIP_GROUP_SELF", ";", "}", "}", "else", "{", "self", "->", "tipGroupId", "=", "XmXSC_TIP_GROUP_PARENT", ";", "}", "}", "else", "{", "self", "->", "hasGroupLeader", "=", "True", ";", "}", "if", "(", "self", "->", "tipGroupId", "==", "XmXSC_TIP_GROUP_PARENT", ")", "{", "if", "(", "_parent", "&&", "!", "XtIsWMShell", "(", "_parent", ")", ")", "{", "if", "(", "_parentObj", ")", "{", "self", "->", "tipGroupId", "=", "_parentObj", "->", "tipGroupId", ";", "}", "else", "{", "self", "->", "tipGroupId", "=", "-", "(", "(", "int", ")", "self", "->", "object", ")", ";", "}", "}", "else", "{", "self", "->", "tipGroupId", "=", "-", "(", "(", "int", ")", "self", "->", "object", ")", ";", "}", "}", "else", "if", "(", "self", "->", "tipGroupId", "==", "XmXSC_TIP_GROUP_SELF", ")", "{", "self", "->", "tipGroupId", "=", "-", "(", "(", "int", ")", "self", "->", "object", ")", ";", "}", "}" ]
This function is used to retrieve object attributes from the resource db
[ "This", "function", "is", "used", "to", "retrieve", "object", "attributes", "from", "the", "resource", "db" ]
[ "/*---------------------------\n -- This block is deprecated\n ---------------------------*/", "/*--------------------------------------------------------------------\n -- Once this happens, by default, all children inherit group id from\n -- the parent instead of from self\n --------------------------------------------------------------------*/" ]
[ { "param": "self", "type": "XscObject" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": "XscObject", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
_setupTip
void
static void _setupTip( XscObject self, const char* default_topic ) { XscText text = _XscTextCreate(); _XscTextLoadTipResources( text, self->object, default_topic ); /*---------------------------------------------------------------- -- If no text.str value was found, then, by definition, there is -- no tip currently associated with this object. ----------------------------------------------------------------*/ if (_XscTextStringExists( text )) { /*-------------------------------------------- -- If there is no hint record, then make one --------------------------------------------*/ if (self->tip == NULL) { self->tip = _XscTipCreate( self ); } _XscTipLoadResources( self->tip, text ); } else { /*------------------------------------------------------------- -- If there is an old tip record, destroy it since there are -- no tips currently defined in the resource database -------------------------------------------------------------*/ if (self->tip) { _XscTipDestroy( self->tip ); self->tip = NULL; } _XscTextDestroy( text ); } }
/*------------------------------------------------------------------------------ -- This function is used to retrieve tip attributes from the resource db ------------------------------------------------------------------------------*/
This function is used to retrieve tip attributes from the resource db
[ "This", "function", "is", "used", "to", "retrieve", "tip", "attributes", "from", "the", "resource", "db" ]
static void _setupTip( XscObject self, const char* default_topic ) { XscText text = _XscTextCreate(); _XscTextLoadTipResources( text, self->object, default_topic ); if (_XscTextStringExists( text )) { if (self->tip == NULL) { self->tip = _XscTipCreate( self ); } _XscTipLoadResources( self->tip, text ); } else { if (self->tip) { _XscTipDestroy( self->tip ); self->tip = NULL; } _XscTextDestroy( text ); } }
[ "static", "void", "_setupTip", "(", "XscObject", "self", ",", "const", "char", "*", "default_topic", ")", "{", "XscText", "text", "=", "_XscTextCreate", "(", ")", ";", "_XscTextLoadTipResources", "(", "text", ",", "self", "->", "object", ",", "default_topic", ")", ";", "if", "(", "_XscTextStringExists", "(", "text", ")", ")", "{", "if", "(", "self", "->", "tip", "==", "NULL", ")", "{", "self", "->", "tip", "=", "_XscTipCreate", "(", "self", ")", ";", "}", "_XscTipLoadResources", "(", "self", "->", "tip", ",", "text", ")", ";", "}", "else", "{", "if", "(", "self", "->", "tip", ")", "{", "_XscTipDestroy", "(", "self", "->", "tip", ")", ";", "self", "->", "tip", "=", "NULL", ";", "}", "_XscTextDestroy", "(", "text", ")", ";", "}", "}" ]
This function is used to retrieve tip attributes from the resource db
[ "This", "function", "is", "used", "to", "retrieve", "tip", "attributes", "from", "the", "resource", "db" ]
[ "/*----------------------------------------------------------------\n -- If no text.str value was found, then, by definition, there is\n -- no tip currently associated with this object. \n ----------------------------------------------------------------*/", "/*--------------------------------------------\n -- If there is no hint record, then make one\n --------------------------------------------*/", "/*-------------------------------------------------------------\n -- If there is an old tip record, destroy it since there are\n -- no tips currently defined in the resource database\n -------------------------------------------------------------*/" ]
[ { "param": "self", "type": "XscObject" }, { "param": "default_topic", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": "XscObject", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "default_topic", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
_updateCue
void
static void _updateCue( XscObject self, XscDisplay display ) { if (self->cue) { if (self->cue == _XscDisplayGetActiveCue( display )) { if (XscCueHasValidTopic( self->cue )) { XscScreen screen; _XscCueUpdate( self->cue ); screen = _XscScreenDeriveFromWidget( self->object ); assert( screen ); _XscScreenRedrawCue( screen ); } } } }
/*----------------------------------------------- -- This function updates the display of a Tip -----------------------------------------------*/
This function updates the display of a Tip
[ "This", "function", "updates", "the", "display", "of", "a", "Tip" ]
static void _updateCue( XscObject self, XscDisplay display ) { if (self->cue) { if (self->cue == _XscDisplayGetActiveCue( display )) { if (XscCueHasValidTopic( self->cue )) { XscScreen screen; _XscCueUpdate( self->cue ); screen = _XscScreenDeriveFromWidget( self->object ); assert( screen ); _XscScreenRedrawCue( screen ); } } } }
[ "static", "void", "_updateCue", "(", "XscObject", "self", ",", "XscDisplay", "display", ")", "{", "if", "(", "self", "->", "cue", ")", "{", "if", "(", "self", "->", "cue", "==", "_XscDisplayGetActiveCue", "(", "display", ")", ")", "{", "if", "(", "XscCueHasValidTopic", "(", "self", "->", "cue", ")", ")", "{", "XscScreen", "screen", ";", "_XscCueUpdate", "(", "self", "->", "cue", ")", ";", "screen", "=", "_XscScreenDeriveFromWidget", "(", "self", "->", "object", ")", ";", "assert", "(", "screen", ")", ";", "_XscScreenRedrawCue", "(", "screen", ")", ";", "}", "}", "}", "}" ]
This function updates the display of a Tip
[ "This", "function", "updates", "the", "display", "of", "a", "Tip" ]
[]
[ { "param": "self", "type": "XscObject" }, { "param": "display", "type": "XscDisplay" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": "XscObject", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "display", "type": "XscDisplay", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
_updateHint
void
static void _updateHint( XscObject self, XscDisplay display ) { if (self == _XscDisplayGetActiveHint( display )) { if (_XscObjectHasValidHint( self )) { XscShell shell = _XscShellDeriveFromWidget( self->object ); if (shell) _XscShellUpdateHint( shell ); } } }
/*----------------------------------------------- -- This function updates the display of a Hint -----------------------------------------------*/
This function updates the display of a Hint
[ "This", "function", "updates", "the", "display", "of", "a", "Hint" ]
static void _updateHint( XscObject self, XscDisplay display ) { if (self == _XscDisplayGetActiveHint( display )) { if (_XscObjectHasValidHint( self )) { XscShell shell = _XscShellDeriveFromWidget( self->object ); if (shell) _XscShellUpdateHint( shell ); } } }
[ "static", "void", "_updateHint", "(", "XscObject", "self", ",", "XscDisplay", "display", ")", "{", "if", "(", "self", "==", "_XscDisplayGetActiveHint", "(", "display", ")", ")", "{", "if", "(", "_XscObjectHasValidHint", "(", "self", ")", ")", "{", "XscShell", "shell", "=", "_XscShellDeriveFromWidget", "(", "self", "->", "object", ")", ";", "if", "(", "shell", ")", "_XscShellUpdateHint", "(", "shell", ")", ";", "}", "}", "}" ]
This function updates the display of a Hint
[ "This", "function", "updates", "the", "display", "of", "a", "Hint" ]
[]
[ { "param": "self", "type": "XscObject" }, { "param": "display", "type": "XscDisplay" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": "XscObject", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "display", "type": "XscDisplay", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
_updateTip
void
static void _updateTip( XscObject self, XscDisplay display ) { if (self == _XscDisplayGetActiveTip( display )) { if (_XscObjectHasValidTip( self )) { XscScreen screen; _XscTipUpdate( self->tip ); screen = _XscScreenDeriveFromWidget( self->object ); assert( screen ); _XscScreenRedrawTip( screen ); } } }
/*----------------------------------------------- -- This function updates the display of a Tip -----------------------------------------------*/
This function updates the display of a Tip
[ "This", "function", "updates", "the", "display", "of", "a", "Tip" ]
static void _updateTip( XscObject self, XscDisplay display ) { if (self == _XscDisplayGetActiveTip( display )) { if (_XscObjectHasValidTip( self )) { XscScreen screen; _XscTipUpdate( self->tip ); screen = _XscScreenDeriveFromWidget( self->object ); assert( screen ); _XscScreenRedrawTip( screen ); } } }
[ "static", "void", "_updateTip", "(", "XscObject", "self", ",", "XscDisplay", "display", ")", "{", "if", "(", "self", "==", "_XscDisplayGetActiveTip", "(", "display", ")", ")", "{", "if", "(", "_XscObjectHasValidTip", "(", "self", ")", ")", "{", "XscScreen", "screen", ";", "_XscTipUpdate", "(", "self", "->", "tip", ")", ";", "screen", "=", "_XscScreenDeriveFromWidget", "(", "self", "->", "object", ")", ";", "assert", "(", "screen", ")", ";", "_XscScreenRedrawTip", "(", "screen", ")", ";", "}", "}", "}" ]
This function updates the display of a Tip
[ "This", "function", "updates", "the", "display", "of", "a", "Tip" ]
[]
[ { "param": "self", "type": "XscObject" }, { "param": "display", "type": "XscDisplay" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": "XscObject", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "display", "type": "XscDisplay", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
XscHelpDbReload
void
void XscHelpDbReload( Widget obj ) { XscObject object = _XscObjectDeriveFromWidget( obj ); /*---------------------------------------------------------- -- If the object is known, then just update the attributes ----------------------------------------------------------*/ if (object) { _setupCue ( object, NULL ); _setupTip ( object, NULL ); _setupHint( object, NULL ); } else { /*------------------------------------------------------------------ -- Notify the library about this "new" widget. If it is a gadget, -- make sure the library knowns about its parent as well. Install -- a gadget before its parent so the gadget counters stay in sync. ------------------------------------------------------------------*/ _XscHelpInstallOnWidget( obj ); if (!XtIsWidget( obj )) { Widget parent = XtParent( obj ); XscObject parent_object = _XscObjectDeriveFromWidget( parent ); if (!parent_object) { _XscHelpInstallOnWidget( parent ); } } } }
/*------------------------------------------------------------------------------ -- This function is used to force an object's tip/hint attributes to be -- updated from the respource database ------------------------------------------------------------------------------*/
This function is used to force an object's tip/hint attributes to be updated from the respource database
[ "This", "function", "is", "used", "to", "force", "an", "object", "'", "s", "tip", "/", "hint", "attributes", "to", "be", "updated", "from", "the", "respource", "database" ]
void XscHelpDbReload( Widget obj ) { XscObject object = _XscObjectDeriveFromWidget( obj ); if (object) { _setupCue ( object, NULL ); _setupTip ( object, NULL ); _setupHint( object, NULL ); } else { _XscHelpInstallOnWidget( obj ); if (!XtIsWidget( obj )) { Widget parent = XtParent( obj ); XscObject parent_object = _XscObjectDeriveFromWidget( parent ); if (!parent_object) { _XscHelpInstallOnWidget( parent ); } } } }
[ "void", "XscHelpDbReload", "(", "Widget", "obj", ")", "{", "XscObject", "object", "=", "_XscObjectDeriveFromWidget", "(", "obj", ")", ";", "if", "(", "object", ")", "{", "_setupCue", "(", "object", ",", "NULL", ")", ";", "_setupTip", "(", "object", ",", "NULL", ")", ";", "_setupHint", "(", "object", ",", "NULL", ")", ";", "}", "else", "{", "_XscHelpInstallOnWidget", "(", "obj", ")", ";", "if", "(", "!", "XtIsWidget", "(", "obj", ")", ")", "{", "Widget", "parent", "=", "XtParent", "(", "obj", ")", ";", "XscObject", "parent_object", "=", "_XscObjectDeriveFromWidget", "(", "parent", ")", ";", "if", "(", "!", "parent_object", ")", "{", "_XscHelpInstallOnWidget", "(", "parent", ")", ";", "}", "}", "}", "}" ]
This function is used to force an object's tip/hint attributes to be updated from the respource database
[ "This", "function", "is", "used", "to", "force", "an", "object", "'", "s", "tip", "/", "hint", "attributes", "to", "be", "updated", "from", "the", "respource", "database" ]
[ "/*----------------------------------------------------------\n -- If the object is known, then just update the attributes\n ----------------------------------------------------------*/", "/*------------------------------------------------------------------\n -- Notify the library about this \"new\" widget. If it is a gadget,\n -- make sure the library knowns about its parent as well. Install\n -- a gadget before its parent so the gadget counters stay in sync.\n ------------------------------------------------------------------*/" ]
[ { "param": "obj", "type": "Widget" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "obj", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
XscHelpUpdate
void
void XscHelpUpdate( Widget obj ) { XscObject object = _XscObjectDeriveFromWidget( obj ); if (object) { XscDisplay display = _XscDisplayDeriveFromWidget( obj ); _updateTip ( object, display ); _updateCue ( object, display ); _updateHint( object, display ); } }
/*-------------------------------------------------------------- -- This function updates everything associated with the widget --------------------------------------------------------------*/
This function updates everything associated with the widget
[ "This", "function", "updates", "everything", "associated", "with", "the", "widget" ]
void XscHelpUpdate( Widget obj ) { XscObject object = _XscObjectDeriveFromWidget( obj ); if (object) { XscDisplay display = _XscDisplayDeriveFromWidget( obj ); _updateTip ( object, display ); _updateCue ( object, display ); _updateHint( object, display ); } }
[ "void", "XscHelpUpdate", "(", "Widget", "obj", ")", "{", "XscObject", "object", "=", "_XscObjectDeriveFromWidget", "(", "obj", ")", ";", "if", "(", "object", ")", "{", "XscDisplay", "display", "=", "_XscDisplayDeriveFromWidget", "(", "obj", ")", ";", "_updateTip", "(", "object", ",", "display", ")", ";", "_updateCue", "(", "object", ",", "display", ")", ";", "_updateHint", "(", "object", ",", "display", ")", ";", "}", "}" ]
This function updates everything associated with the widget
[ "This", "function", "updates", "everything", "associated", "with", "the", "widget" ]
[]
[ { "param": "obj", "type": "Widget" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "obj", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
XscHelpCueUpdate
void
void XscHelpCueUpdate( Widget obj ) { XscObject object = _XscObjectDeriveFromWidget ( obj ); if (object) { _updateCue( object, _XscDisplayDeriveFromWidget( obj ) ); } }
/*------------------------------------------- -- This function updates the Cue if active --------------------------------------------*/
This function updates the Cue if active
[ "This", "function", "updates", "the", "Cue", "if", "active" ]
void XscHelpCueUpdate( Widget obj ) { XscObject object = _XscObjectDeriveFromWidget ( obj ); if (object) { _updateCue( object, _XscDisplayDeriveFromWidget( obj ) ); } }
[ "void", "XscHelpCueUpdate", "(", "Widget", "obj", ")", "{", "XscObject", "object", "=", "_XscObjectDeriveFromWidget", "(", "obj", ")", ";", "if", "(", "object", ")", "{", "_updateCue", "(", "object", ",", "_XscDisplayDeriveFromWidget", "(", "obj", ")", ")", ";", "}", "}" ]
This function updates the Cue if active
[ "This", "function", "updates", "the", "Cue", "if", "active" ]
[]
[ { "param": "obj", "type": "Widget" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "obj", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
XscHelpHintUpdate
void
void XscHelpHintUpdate( Widget obj ) { XscObject object = _XscObjectDeriveFromWidget ( obj ); if (object) { _updateHint( object, _XscDisplayDeriveFromWidget( obj ) ); } }
/*------------------------------------------- -- This function updates the Hint if active --------------------------------------------*/
This function updates the Hint if active
[ "This", "function", "updates", "the", "Hint", "if", "active" ]
void XscHelpHintUpdate( Widget obj ) { XscObject object = _XscObjectDeriveFromWidget ( obj ); if (object) { _updateHint( object, _XscDisplayDeriveFromWidget( obj ) ); } }
[ "void", "XscHelpHintUpdate", "(", "Widget", "obj", ")", "{", "XscObject", "object", "=", "_XscObjectDeriveFromWidget", "(", "obj", ")", ";", "if", "(", "object", ")", "{", "_updateHint", "(", "object", ",", "_XscDisplayDeriveFromWidget", "(", "obj", ")", ")", ";", "}", "}" ]
This function updates the Hint if active
[ "This", "function", "updates", "the", "Hint", "if", "active" ]
[]
[ { "param": "obj", "type": "Widget" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "obj", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
XscHelpTipUpdate
void
void XscHelpTipUpdate( Widget obj ) { XscObject object = _XscObjectDeriveFromWidget ( obj ); if (object) { _updateTip( object, _XscDisplayDeriveFromWidget( obj ) ); } }
/*------------------------------------------- -- This function updates the Tip if active --------------------------------------------*/
This function updates the Tip if active
[ "This", "function", "updates", "the", "Tip", "if", "active" ]
void XscHelpTipUpdate( Widget obj ) { XscObject object = _XscObjectDeriveFromWidget ( obj ); if (object) { _updateTip( object, _XscDisplayDeriveFromWidget( obj ) ); } }
[ "void", "XscHelpTipUpdate", "(", "Widget", "obj", ")", "{", "XscObject", "object", "=", "_XscObjectDeriveFromWidget", "(", "obj", ")", ";", "if", "(", "object", ")", "{", "_updateTip", "(", "object", ",", "_XscDisplayDeriveFromWidget", "(", "obj", ")", ")", ";", "}", "}" ]
This function updates the Tip if active
[ "This", "function", "updates", "the", "Tip", "if", "active" ]
[]
[ { "param": "obj", "type": "Widget" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "obj", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
XscHelpCueExists
Boolean
Boolean XscHelpCueExists( Widget w ) { XscObject object = _XscObjectDeriveFromWidget( w ); Boolean result = False; if (object) { result = _XscObjectHasValidCue( object ); } return result; }
/*------------------------------------------------------------------------- -- This function get a handle to a Widget help object for later get/set -- operations -------------------------------------------------------------------------*/
This function get a handle to a Widget help object for later get/set operations
[ "This", "function", "get", "a", "handle", "to", "a", "Widget", "help", "object", "for", "later", "get", "/", "set", "operations" ]
Boolean XscHelpCueExists( Widget w ) { XscObject object = _XscObjectDeriveFromWidget( w ); Boolean result = False; if (object) { result = _XscObjectHasValidCue( object ); } return result; }
[ "Boolean", "XscHelpCueExists", "(", "Widget", "w", ")", "{", "XscObject", "object", "=", "_XscObjectDeriveFromWidget", "(", "w", ")", ";", "Boolean", "result", "=", "False", ";", "if", "(", "object", ")", "{", "result", "=", "_XscObjectHasValidCue", "(", "object", ")", ";", "}", "return", "result", ";", "}" ]
This function get a handle to a Widget help object for later get/set operations
[ "This", "function", "get", "a", "handle", "to", "a", "Widget", "help", "object", "for", "later", "get", "/", "set", "operations" ]
[]
[ { "param": "w", "type": "Widget" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "w", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
941222e22b6e72869005fe4bbb9a7733ca47bb23
akivawerner/XscHelp
src/base/Object.c
[ "MIT" ]
C
XscCvtStringToTipGroupId
Boolean
Boolean XscCvtStringToTipGroupId( Display* d, XrmValue* args, /* not used */ Cardinal* numArgs, /* not used */ XrmValue* from, XrmValue* toVal, XtPointer* data ) /* not used */ { char* str = (char*) from->addr; int value = XmXSC_TIP_GROUP_NULL; Boolean result = True; if (!str) return False; /*--------------------------------------------------------- -- If the first character is a digit, assume they all are ---------------------------------------------------------*/ if (isdigit( *str ) || *str == '-' || *str == '+') { value = atoi( str ); } else { char* tmp; char* ptr; /*--------------------------------------------------------- -- The symbol _must_ be at least 18 charcters to be valid ---------------------------------------------------------*/ if (strlen( str ) < 18) return False; tmp = XtNewString( str ); /*----------------------------------------------------------------- -- the string being converted must be a symbol, see if we can -- get a match. The rules are: -- 1) If it starts with Xm, then the symbol must be all uppercase -- 2) If not, then it can be mixed case -----------------------------------------------------------------*/ if (str[0] == 'X' && str[1] == 'm') { ptr = &tmp[2]; } else { /*----------------------------------------------------------------- -- Convert it to upper case only for symbols not starting with Xm -----------------------------------------------------------------*/ for (ptr = tmp; *ptr; ptr++) *ptr = toupper( *ptr ); ptr = tmp; } if (strcmp( ptr, "XSC_TIP_GROUP_SELF" ) == 0) { value = XmXSC_TIP_GROUP_SELF; } else if (strcmp( ptr, "XSC_TIP_GROUP_PARENT" ) == 0) { value = XmXSC_TIP_GROUP_PARENT; } else if (strcmp( ptr, "XSC_TIP_GROUP_NULL" ) == 0) { value = XmXSC_TIP_GROUP_NULL; } else { result = False; } XtFree( (void*) tmp ); } if (result) { if (toVal->addr != NULL) { if (toVal->size < sizeof( int )) { toVal->size = sizeof( int ); return False; } *(int*)(toVal->addr) = value; } else { static int static_val; static_val = value; toVal->addr = (XtPointer)&static_val; } toVal->size = sizeof( int ); return True; } XtDisplayStringConversionWarning( d, (char*)from->addr, XmRXscTipGroupId ); return False; }
/*--------------------------------------------------------------------------- -- This function is a resource converter that converts from a string to -- a tip group id field. It will convert numbers as well as the symbolic -- values XmXSC_TIP_GROUP_NULL, XmXSC_TIP_GROUP_SELF, -- and XmXSC_TIP_GROUP_PARENT. ---------------------------------------------------------------------------*/
This function is a resource converter that converts from a string to a tip group id field. It will convert numbers as well as the symbolic values XmXSC_TIP_GROUP_NULL, XmXSC_TIP_GROUP_SELF, and XmXSC_TIP_GROUP_PARENT.
[ "This", "function", "is", "a", "resource", "converter", "that", "converts", "from", "a", "string", "to", "a", "tip", "group", "id", "field", ".", "It", "will", "convert", "numbers", "as", "well", "as", "the", "symbolic", "values", "XmXSC_TIP_GROUP_NULL", "XmXSC_TIP_GROUP_SELF", "and", "XmXSC_TIP_GROUP_PARENT", "." ]
Boolean XscCvtStringToTipGroupId( Display* d, XrmValue* args, Cardinal* numArgs, XrmValue* from, XrmValue* toVal, XtPointer* data ) { char* str = (char*) from->addr; int value = XmXSC_TIP_GROUP_NULL; Boolean result = True; if (!str) return False; if (isdigit( *str ) || *str == '-' || *str == '+') { value = atoi( str ); } else { char* tmp; char* ptr; if (strlen( str ) < 18) return False; tmp = XtNewString( str ); if (str[0] == 'X' && str[1] == 'm') { ptr = &tmp[2]; } else { for (ptr = tmp; *ptr; ptr++) *ptr = toupper( *ptr ); ptr = tmp; } if (strcmp( ptr, "XSC_TIP_GROUP_SELF" ) == 0) { value = XmXSC_TIP_GROUP_SELF; } else if (strcmp( ptr, "XSC_TIP_GROUP_PARENT" ) == 0) { value = XmXSC_TIP_GROUP_PARENT; } else if (strcmp( ptr, "XSC_TIP_GROUP_NULL" ) == 0) { value = XmXSC_TIP_GROUP_NULL; } else { result = False; } XtFree( (void*) tmp ); } if (result) { if (toVal->addr != NULL) { if (toVal->size < sizeof( int )) { toVal->size = sizeof( int ); return False; } *(int*)(toVal->addr) = value; } else { static int static_val; static_val = value; toVal->addr = (XtPointer)&static_val; } toVal->size = sizeof( int ); return True; } XtDisplayStringConversionWarning( d, (char*)from->addr, XmRXscTipGroupId ); return False; }
[ "Boolean", "XscCvtStringToTipGroupId", "(", "Display", "*", "d", ",", "XrmValue", "*", "args", ",", "Cardinal", "*", "numArgs", ",", "XrmValue", "*", "from", ",", "XrmValue", "*", "toVal", ",", "XtPointer", "*", "data", ")", "{", "char", "*", "str", "=", "(", "char", "*", ")", "from", "->", "addr", ";", "int", "value", "=", "XmXSC_TIP_GROUP_NULL", ";", "Boolean", "result", "=", "True", ";", "if", "(", "!", "str", ")", "return", "False", ";", "if", "(", "isdigit", "(", "*", "str", ")", "||", "*", "str", "==", "'", "'", "||", "*", "str", "==", "'", "'", ")", "{", "value", "=", "atoi", "(", "str", ")", ";", "}", "else", "{", "char", "*", "tmp", ";", "char", "*", "ptr", ";", "if", "(", "strlen", "(", "str", ")", "<", "18", ")", "return", "False", ";", "tmp", "=", "XtNewString", "(", "str", ")", ";", "if", "(", "str", "[", "0", "]", "==", "'", "'", "&&", "str", "[", "1", "]", "==", "'", "'", ")", "{", "ptr", "=", "&", "tmp", "[", "2", "]", ";", "}", "else", "{", "for", "(", "ptr", "=", "tmp", ";", "*", "ptr", ";", "ptr", "++", ")", "*", "ptr", "=", "toupper", "(", "*", "ptr", ")", ";", "ptr", "=", "tmp", ";", "}", "if", "(", "strcmp", "(", "ptr", ",", "\"", "\"", ")", "==", "0", ")", "{", "value", "=", "XmXSC_TIP_GROUP_SELF", ";", "}", "else", "if", "(", "strcmp", "(", "ptr", ",", "\"", "\"", ")", "==", "0", ")", "{", "value", "=", "XmXSC_TIP_GROUP_PARENT", ";", "}", "else", "if", "(", "strcmp", "(", "ptr", ",", "\"", "\"", ")", "==", "0", ")", "{", "value", "=", "XmXSC_TIP_GROUP_NULL", ";", "}", "else", "{", "result", "=", "False", ";", "}", "XtFree", "(", "(", "void", "*", ")", "tmp", ")", ";", "}", "if", "(", "result", ")", "{", "if", "(", "toVal", "->", "addr", "!=", "NULL", ")", "{", "if", "(", "toVal", "->", "size", "<", "sizeof", "(", "int", ")", ")", "{", "toVal", "->", "size", "=", "sizeof", "(", "int", ")", ";", "return", "False", ";", "}", "*", "(", "int", "*", ")", "(", "toVal", "->", "addr", ")", "=", "value", ";", "}", "else", "{", "static", "int", "static_val", ";", "static_val", "=", "value", ";", "toVal", "->", "addr", "=", "(", "XtPointer", ")", "&", "static_val", ";", "}", "toVal", "->", "size", "=", "sizeof", "(", "int", ")", ";", "return", "True", ";", "}", "XtDisplayStringConversionWarning", "(", "d", ",", "(", "char", "*", ")", "from", "->", "addr", ",", "XmRXscTipGroupId", ")", ";", "return", "False", ";", "}" ]
This function is a resource converter that converts from a string to a tip group id field.
[ "This", "function", "is", "a", "resource", "converter", "that", "converts", "from", "a", "string", "to", "a", "tip", "group", "id", "field", "." ]
[ "/* not used */", "/* not used */", "/* not used */", "/*---------------------------------------------------------\n -- If the first character is a digit, assume they all are\n ---------------------------------------------------------*/", "/*---------------------------------------------------------\n -- The symbol _must_ be at least 18 charcters to be valid\n ---------------------------------------------------------*/", "/*-----------------------------------------------------------------\n -- the string being converted must be a symbol, see if we can\n -- get a match. The rules are:\n -- 1) If it starts with Xm, then the symbol must be all uppercase\n -- 2) If not, then it can be mixed case\n -----------------------------------------------------------------*/", "/*-----------------------------------------------------------------\n \t -- Convert it to upper case only for symbols not starting with Xm\n\t -----------------------------------------------------------------*/" ]
[ { "param": "d", "type": "Display" }, { "param": "args", "type": "XrmValue" }, { "param": "numArgs", "type": "Cardinal" }, { "param": "from", "type": "XrmValue" }, { "param": "toVal", "type": "XrmValue" }, { "param": "data", "type": "XtPointer" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "d", "type": "Display", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "args", "type": "XrmValue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "numArgs", "type": "Cardinal", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "from", "type": "XrmValue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "toVal", "type": "XrmValue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "XtPointer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c6cb0d3a2497637890f37801539a11cfa8d9a783
akivawerner/XscHelp
src/base/Screen.c
[ "MIT" ]
C
_XscScreenDeriveFromWidget
XscScreen
XscScreen _XscScreenDeriveFromWidget( Widget obj ) { XscScreen self; Display* x_display; Screen* x_screen; XPointer data; int not_found; x_display = XtDisplayOfObject( obj ); x_screen = XtScreenOfObject ( obj ); not_found = XFindContext( x_display,(XID)x_screen,_screenContextId,&data ); if (not_found) { self = NULL; } else { self = (XscScreen) data; } return self; }
/*------------------------------------------------------------------------------ -- This function retrieves the screen structure associated with an object -- from the context manager ------------------------------------------------------------------------------*/
This function retrieves the screen structure associated with an object from the context manager
[ "This", "function", "retrieves", "the", "screen", "structure", "associated", "with", "an", "object", "from", "the", "context", "manager" ]
XscScreen _XscScreenDeriveFromWidget( Widget obj ) { XscScreen self; Display* x_display; Screen* x_screen; XPointer data; int not_found; x_display = XtDisplayOfObject( obj ); x_screen = XtScreenOfObject ( obj ); not_found = XFindContext( x_display,(XID)x_screen,_screenContextId,&data ); if (not_found) { self = NULL; } else { self = (XscScreen) data; } return self; }
[ "XscScreen", "_XscScreenDeriveFromWidget", "(", "Widget", "obj", ")", "{", "XscScreen", "self", ";", "Display", "*", "x_display", ";", "Screen", "*", "x_screen", ";", "XPointer", "data", ";", "int", "not_found", ";", "x_display", "=", "XtDisplayOfObject", "(", "obj", ")", ";", "x_screen", "=", "XtScreenOfObject", "(", "obj", ")", ";", "not_found", "=", "XFindContext", "(", "x_display", ",", "(", "XID", ")", "x_screen", ",", "_screenContextId", ",", "&", "data", ")", ";", "if", "(", "not_found", ")", "{", "self", "=", "NULL", ";", "}", "else", "{", "self", "=", "(", "XscScreen", ")", "data", ";", "}", "return", "self", ";", "}" ]
This function retrieves the screen structure associated with an object from the context manager
[ "This", "function", "retrieves", "the", "screen", "structure", "associated", "with", "an", "object", "from", "the", "context", "manager" ]
[]
[ { "param": "obj", "type": "Widget" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "obj", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c6cb0d3a2497637890f37801539a11cfa8d9a783
akivawerner/XscHelp
src/base/Screen.c
[ "MIT" ]
C
_destroyScreenCB
void
static void _destroyScreenCB( Widget w, XtPointer cd, XtPointer cbd ) { XscScreen screen = _XscScreenDeriveFromWidget( w ); if (screen) { /*---------------------------------- -- Don't forget to clean up the GC ----------------------------------*/ XFreeGC( XtDisplayOfObject( w ), screen->gc ); /*-------------------------------------------------------------- -- Remove the structure from the context manager and delete it --------------------------------------------------------------*/ XDeleteContext( XtDisplayOfObject( w ), (XID) screen->xScreen, _screenContextId ); XtFree( (char*) screen ); } }
/*------------------------------------------------------------------------------ -- This callback is called to clean-up the screen structure when the last -- widget on that screen is destroyed ------------------------------------------------------------------------------*/
This callback is called to clean-up the screen structure when the last widget on that screen is destroyed
[ "This", "callback", "is", "called", "to", "clean", "-", "up", "the", "screen", "structure", "when", "the", "last", "widget", "on", "that", "screen", "is", "destroyed" ]
static void _destroyScreenCB( Widget w, XtPointer cd, XtPointer cbd ) { XscScreen screen = _XscScreenDeriveFromWidget( w ); if (screen) { XFreeGC( XtDisplayOfObject( w ), screen->gc ); XDeleteContext( XtDisplayOfObject( w ), (XID) screen->xScreen, _screenContextId ); XtFree( (char*) screen ); } }
[ "static", "void", "_destroyScreenCB", "(", "Widget", "w", ",", "XtPointer", "cd", ",", "XtPointer", "cbd", ")", "{", "XscScreen", "screen", "=", "_XscScreenDeriveFromWidget", "(", "w", ")", ";", "if", "(", "screen", ")", "{", "XFreeGC", "(", "XtDisplayOfObject", "(", "w", ")", ",", "screen", "->", "gc", ")", ";", "XDeleteContext", "(", "XtDisplayOfObject", "(", "w", ")", ",", "(", "XID", ")", "screen", "->", "xScreen", ",", "_screenContextId", ")", ";", "XtFree", "(", "(", "char", "*", ")", "screen", ")", ";", "}", "}" ]
This callback is called to clean-up the screen structure when the last widget on that screen is destroyed
[ "This", "callback", "is", "called", "to", "clean", "-", "up", "the", "screen", "structure", "when", "the", "last", "widget", "on", "that", "screen", "is", "destroyed" ]
[ "/*----------------------------------\n -- Don't forget to clean up the GC\n ----------------------------------*/", "/*--------------------------------------------------------------\n -- Remove the structure from the context manager and delete it\n --------------------------------------------------------------*/" ]
[ { "param": "w", "type": "Widget" }, { "param": "cd", "type": "XtPointer" }, { "param": "cbd", "type": "XtPointer" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "w", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cd", "type": "XtPointer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cbd", "type": "XtPointer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c6cb0d3a2497637890f37801539a11cfa8d9a783
akivawerner/XscHelp
src/base/Screen.c
[ "MIT" ]
C
_renderCueEH
void
static void _renderCueEH( Widget cue_widget, XtPointer not_used1, XEvent* event, Boolean* not_used2 ) { XscDisplay display = _XscDisplayDeriveFromWidget( cue_widget ); XscCue cue; assert( display ); cue = _XscDisplayGetActiveCue( display ); if ((event->type == Expose) && (cue)) { XscScreen screen = _XscScreenDeriveFromWidget( cue_widget ); _XscCueRender( cue, cue_widget, screen->gc ); } }
/*------------------------------------------------------------------------------ -- This event handler is called when the cue needs to be rendered ------------------------------------------------------------------------------*/
This event handler is called when the cue needs to be rendered
[ "This", "event", "handler", "is", "called", "when", "the", "cue", "needs", "to", "be", "rendered" ]
static void _renderCueEH( Widget cue_widget, XtPointer not_used1, XEvent* event, Boolean* not_used2 ) { XscDisplay display = _XscDisplayDeriveFromWidget( cue_widget ); XscCue cue; assert( display ); cue = _XscDisplayGetActiveCue( display ); if ((event->type == Expose) && (cue)) { XscScreen screen = _XscScreenDeriveFromWidget( cue_widget ); _XscCueRender( cue, cue_widget, screen->gc ); } }
[ "static", "void", "_renderCueEH", "(", "Widget", "cue_widget", ",", "XtPointer", "not_used1", ",", "XEvent", "*", "event", ",", "Boolean", "*", "not_used2", ")", "{", "XscDisplay", "display", "=", "_XscDisplayDeriveFromWidget", "(", "cue_widget", ")", ";", "XscCue", "cue", ";", "assert", "(", "display", ")", ";", "cue", "=", "_XscDisplayGetActiveCue", "(", "display", ")", ";", "if", "(", "(", "event", "->", "type", "==", "Expose", ")", "&&", "(", "cue", ")", ")", "{", "XscScreen", "screen", "=", "_XscScreenDeriveFromWidget", "(", "cue_widget", ")", ";", "_XscCueRender", "(", "cue", ",", "cue_widget", ",", "screen", "->", "gc", ")", ";", "}", "}" ]
This event handler is called when the cue needs to be rendered
[ "This", "event", "handler", "is", "called", "when", "the", "cue", "needs", "to", "be", "rendered" ]
[]
[ { "param": "cue_widget", "type": "Widget" }, { "param": "not_used1", "type": "XtPointer" }, { "param": "event", "type": "XEvent" }, { "param": "not_used2", "type": "Boolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cue_widget", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "not_used1", "type": "XtPointer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "event", "type": "XEvent", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "not_used2", "type": "Boolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c6cb0d3a2497637890f37801539a11cfa8d9a783
akivawerner/XscHelp
src/base/Screen.c
[ "MIT" ]
C
_renderTipEH
void
static void _renderTipEH( Widget tip_widget, XtPointer not_used1, XEvent* event, Boolean* not_used2 ) { XscDisplay display = _XscDisplayDeriveFromWidget( tip_widget ); XscObject object; assert( display ); object = _XscDisplayGetActiveTip( display ); if ((event->type == Expose) && (object)) { XscScreen screen = _XscScreenDeriveFromWidget( tip_widget ); _XscTipRender( _XscObjectGetTip( object ), tip_widget, screen->gc ); } }
/*------------------------------------------------------------------------------ -- This event handler is called when the tip needs to be rendered ------------------------------------------------------------------------------*/
This event handler is called when the tip needs to be rendered
[ "This", "event", "handler", "is", "called", "when", "the", "tip", "needs", "to", "be", "rendered" ]
static void _renderTipEH( Widget tip_widget, XtPointer not_used1, XEvent* event, Boolean* not_used2 ) { XscDisplay display = _XscDisplayDeriveFromWidget( tip_widget ); XscObject object; assert( display ); object = _XscDisplayGetActiveTip( display ); if ((event->type == Expose) && (object)) { XscScreen screen = _XscScreenDeriveFromWidget( tip_widget ); _XscTipRender( _XscObjectGetTip( object ), tip_widget, screen->gc ); } }
[ "static", "void", "_renderTipEH", "(", "Widget", "tip_widget", ",", "XtPointer", "not_used1", ",", "XEvent", "*", "event", ",", "Boolean", "*", "not_used2", ")", "{", "XscDisplay", "display", "=", "_XscDisplayDeriveFromWidget", "(", "tip_widget", ")", ";", "XscObject", "object", ";", "assert", "(", "display", ")", ";", "object", "=", "_XscDisplayGetActiveTip", "(", "display", ")", ";", "if", "(", "(", "event", "->", "type", "==", "Expose", ")", "&&", "(", "object", ")", ")", "{", "XscScreen", "screen", "=", "_XscScreenDeriveFromWidget", "(", "tip_widget", ")", ";", "_XscTipRender", "(", "_XscObjectGetTip", "(", "object", ")", ",", "tip_widget", ",", "screen", "->", "gc", ")", ";", "}", "}" ]
This event handler is called when the tip needs to be rendered
[ "This", "event", "handler", "is", "called", "when", "the", "tip", "needs", "to", "be", "rendered" ]
[]
[ { "param": "tip_widget", "type": "Widget" }, { "param": "not_used1", "type": "XtPointer" }, { "param": "event", "type": "XEvent" }, { "param": "not_used2", "type": "Boolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tip_widget", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "not_used1", "type": "XtPointer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "event", "type": "XEvent", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "not_used2", "type": "Boolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }