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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
63de22cb844d708236d11a73ba1896767044fa0a | SKGleba/broombroom | tz.c | [
"MIT"
] | C | tz_init | int | int tz_init(k_root* kroot) {
if (!kroot)
return -1;
kroot->printf("[SNS][TZ] tz_init, adding peek/poke\n");
int ret = patch_tz_peekpoke(kroot);
kroot->printf("[SNS][TZ] patch_tz_peekpoke() 0x%X\n", ret);
if (ret < 0)
return ret;
kroot->printf("[SNS][TZ] making new SMCs\n");
xsmc(TZ_SYSCALL + ((SMC_FLUSH - 0x100) * 4), TZ_FLUSH, 0, 0, SMC_POKE);
xsmc(TZ_SYSCALL + ((SMC_DACROFF_MEMCPY - 0x100) * 4), 0xcdeb1, 0, 0, SMC_POKE);
xsmc(TZ_SYSCALL + ((SMC_FUDRESET - 0x100) * 4), 0xD2739, 0, 0, SMC_POKE);
xsmc(TZ_SYSCALL + ((SMC_PEEK - 0x100) * 4), 0x100, 0, 0, SMC_FLUSH);
kroot->printf("[SNS][TZ] adding fudreset\n");
ret = tz_dacroff_copyto(kroot, 0xD2738, (void *)tz_fudreset_sigma, sizeof(tz_fudreset_sigma));
kroot->printf("[SNS][TZ] tz_dacroff_copyto() 0x%X\n", ret);
if (ret < 0)
return ret;
return 0;
} | // hack tz, add custom smcs, copy the tz payload | hack tz, add custom smcs, copy the tz payload | [
"hack",
"tz",
"add",
"custom",
"smcs",
"copy",
"the",
"tz",
"payload"
] | int tz_init(k_root* kroot) {
if (!kroot)
return -1;
kroot->printf("[SNS][TZ] tz_init, adding peek/poke\n");
int ret = patch_tz_peekpoke(kroot);
kroot->printf("[SNS][TZ] patch_tz_peekpoke() 0x%X\n", ret);
if (ret < 0)
return ret;
kroot->printf("[SNS][TZ] making new SMCs\n");
xsmc(TZ_SYSCALL + ((SMC_FLUSH - 0x100) * 4), TZ_FLUSH, 0, 0, SMC_POKE);
xsmc(TZ_SYSCALL + ((SMC_DACROFF_MEMCPY - 0x100) * 4), 0xcdeb1, 0, 0, SMC_POKE);
xsmc(TZ_SYSCALL + ((SMC_FUDRESET - 0x100) * 4), 0xD2739, 0, 0, SMC_POKE);
xsmc(TZ_SYSCALL + ((SMC_PEEK - 0x100) * 4), 0x100, 0, 0, SMC_FLUSH);
kroot->printf("[SNS][TZ] adding fudreset\n");
ret = tz_dacroff_copyto(kroot, 0xD2738, (void *)tz_fudreset_sigma, sizeof(tz_fudreset_sigma));
kroot->printf("[SNS][TZ] tz_dacroff_copyto() 0x%X\n", ret);
if (ret < 0)
return ret;
return 0;
} | [
"int",
"tz_init",
"(",
"k_root",
"*",
"kroot",
")",
"{",
"if",
"(",
"!",
"kroot",
")",
"return",
"-1",
";",
"kroot",
"->",
"printf",
"(",
"\"",
"\\n",
"\"",
")",
";",
"int",
"ret",
"=",
"patch_tz_peekpoke",
"(",
"kroot",
")",
";",
"kroot",
"->",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"ret",
")",
";",
"if",
"(",
"ret",
"<",
"0",
")",
"return",
"ret",
";",
"kroot",
"->",
"printf",
"(",
"\"",
"\\n",
"\"",
")",
";",
"xsmc",
"(",
"TZ_SYSCALL",
"+",
"(",
"(",
"SMC_FLUSH",
"-",
"0x100",
")",
"*",
"4",
")",
",",
"TZ_FLUSH",
",",
"0",
",",
"0",
",",
"SMC_POKE",
")",
";",
"xsmc",
"(",
"TZ_SYSCALL",
"+",
"(",
"(",
"SMC_DACROFF_MEMCPY",
"-",
"0x100",
")",
"*",
"4",
")",
",",
"0xcdeb1",
",",
"0",
",",
"0",
",",
"SMC_POKE",
")",
";",
"xsmc",
"(",
"TZ_SYSCALL",
"+",
"(",
"(",
"SMC_FUDRESET",
"-",
"0x100",
")",
"*",
"4",
")",
",",
"0xD2739",
",",
"0",
",",
"0",
",",
"SMC_POKE",
")",
";",
"xsmc",
"(",
"TZ_SYSCALL",
"+",
"(",
"(",
"SMC_PEEK",
"-",
"0x100",
")",
"*",
"4",
")",
",",
"0x100",
",",
"0",
",",
"0",
",",
"SMC_FLUSH",
")",
";",
"kroot",
"->",
"printf",
"(",
"\"",
"\\n",
"\"",
")",
";",
"ret",
"=",
"tz_dacroff_copyto",
"(",
"kroot",
",",
"0xD2738",
",",
"(",
"void",
"*",
")",
"tz_fudreset_sigma",
",",
"sizeof",
"(",
"tz_fudreset_sigma",
")",
")",
";",
"kroot",
"->",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"ret",
")",
";",
"if",
"(",
"ret",
"<",
"0",
")",
"return",
"ret",
";",
"return",
"0",
";",
"}"
] | hack tz, add custom smcs, copy the tz payload | [
"hack",
"tz",
"add",
"custom",
"smcs",
"copy",
"the",
"tz",
"payload"
] | [] | [
{
"param": "kroot",
"type": "k_root"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "kroot",
"type": "k_root",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
53c8bb5de665b46fca2b74d49de86d24d9a427d1 | SKGleba/broombroom | utils.c | [
"MIT"
] | C | siofix | int | int siofix(void* func) {
int (*create_thread)(const char* name, void* func, int a2, int a3, int a4, int a5, int a6) = KFUN("SceKernelThreadMgr", 0x7d10 | 1);
int (*start_thread)(int id, int argsz, void* argv) = KFUN("SceKernelThreadMgr", 0x3514 | 1);
int (*wait_thread)(int id, int* ret, void* argv) = KFUN("SceKernelThreadMgr", 0x3008 | 1);
int (*delete_thread)(int id) = KFUN("SceKernelThreadMgr", 0x3394 | 1);
int ret, res, uid;
ret = uid = create_thread("siofix", func, 0x10000100, 0x4000, 0, 0x10000, 0);
if (ret < 0) { ret = -1; goto cleanup; }
if ((ret = start_thread(uid, 0, NULL)) < 0) { ret = -1; goto cleanup; }
if ((ret = wait_thread(uid, &res, NULL)) < 0) { ret = -1; goto cleanup; }
ret = res;
cleanup:
if (uid > 0) delete_thread(uid);
return ret;
} | // i/o fix when system is running | i/o fix when system is running | [
"i",
"/",
"o",
"fix",
"when",
"system",
"is",
"running"
] | int siofix(void* func) {
int (*create_thread)(const char* name, void* func, int a2, int a3, int a4, int a5, int a6) = KFUN("SceKernelThreadMgr", 0x7d10 | 1);
int (*start_thread)(int id, int argsz, void* argv) = KFUN("SceKernelThreadMgr", 0x3514 | 1);
int (*wait_thread)(int id, int* ret, void* argv) = KFUN("SceKernelThreadMgr", 0x3008 | 1);
int (*delete_thread)(int id) = KFUN("SceKernelThreadMgr", 0x3394 | 1);
int ret, res, uid;
ret = uid = create_thread("siofix", func, 0x10000100, 0x4000, 0, 0x10000, 0);
if (ret < 0) { ret = -1; goto cleanup; }
if ((ret = start_thread(uid, 0, NULL)) < 0) { ret = -1; goto cleanup; }
if ((ret = wait_thread(uid, &res, NULL)) < 0) { ret = -1; goto cleanup; }
ret = res;
cleanup:
if (uid > 0) delete_thread(uid);
return ret;
} | [
"int",
"siofix",
"(",
"void",
"*",
"func",
")",
"{",
"int",
"(",
"*",
"create_thread",
")",
"(",
"const",
"char",
"*",
"name",
",",
"void",
"*",
"func",
",",
"int",
"a2",
",",
"int",
"a3",
",",
"int",
"a4",
",",
"int",
"a5",
",",
"int",
"a6",
")",
"=",
"KFUN",
"(",
"\"",
"\"",
",",
"0x7d10",
"|",
"1",
")",
";",
"int",
"(",
"*",
"start_thread",
")",
"(",
"int",
"id",
",",
"int",
"argsz",
",",
"void",
"*",
"argv",
")",
"=",
"KFUN",
"(",
"\"",
"\"",
",",
"0x3514",
"|",
"1",
")",
";",
"int",
"(",
"*",
"wait_thread",
")",
"(",
"int",
"id",
",",
"int",
"*",
"ret",
",",
"void",
"*",
"argv",
")",
"=",
"KFUN",
"(",
"\"",
"\"",
",",
"0x3008",
"|",
"1",
")",
";",
"int",
"(",
"*",
"delete_thread",
")",
"(",
"int",
"id",
")",
"=",
"KFUN",
"(",
"\"",
"\"",
",",
"0x3394",
"|",
"1",
")",
";",
"int",
"ret",
",",
"res",
",",
"uid",
";",
"ret",
"=",
"uid",
"=",
"create_thread",
"(",
"\"",
"\"",
",",
"func",
",",
"0x10000100",
",",
"0x4000",
",",
"0",
",",
"0x10000",
",",
"0",
")",
";",
"if",
"(",
"ret",
"<",
"0",
")",
"{",
"ret",
"=",
"-1",
";",
"goto",
"cleanup",
";",
"}",
"if",
"(",
"(",
"ret",
"=",
"start_thread",
"(",
"uid",
",",
"0",
",",
"NULL",
")",
")",
"<",
"0",
")",
"{",
"ret",
"=",
"-1",
";",
"goto",
"cleanup",
";",
"}",
"if",
"(",
"(",
"ret",
"=",
"wait_thread",
"(",
"uid",
",",
"&",
"res",
",",
"NULL",
")",
")",
"<",
"0",
")",
"{",
"ret",
"=",
"-1",
";",
"goto",
"cleanup",
";",
"}",
"ret",
"=",
"res",
";",
"cleanup",
":",
"if",
"(",
"uid",
">",
"0",
")",
"delete_thread",
"(",
"uid",
")",
";",
"return",
"ret",
";",
"}"
] | i/o fix when system is running | [
"i",
"/",
"o",
"fix",
"when",
"system",
"is",
"running"
] | [] | [
{
"param": "func",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "func",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6b151d610cf73b2bc42cff6833c5e1d00430cf32 | pingidentity/pa-agent-c-sdk-sample-apache | mod_paa.c | [
"Apache-2.0"
] | C | paa_header_parser | int | static
int paa_header_parser(request_rec *r)
{
apache_client_req req_wrapper;
req_wrapper.rec = r;
req_wrapper.eos_reached = 0;
req_wrapper.full_normalized_uri = NULL;
paa_client_request client_req;
apache_client_req_init(&client_req, &req_wrapper);
apache_client_resp resp_wrapper;
resp_wrapper.rec = r;
paa_client_response client_resp;
apache_client_resp_init(&client_resp, &resp_wrapper);
int hook_result;
do {
apr_status_t result;
paa_server_config *server_config =
(paa_server_config *)ap_get_module_config(r->server->module_config, &paa_module);
paa_dir_config *dir_config =
(paa_dir_config *)ap_get_module_config(r->per_dir_config, &paa_module);
if (server_config == NULL) {
paa_log(r->pool, APACHE_MSGID, PAA_ERROR, "failed to obtain PAA server configuration");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
if (dir_config == NULL) {
paa_log(r->pool, APACHE_MSGID, PAA_ERROR, "failed to obtain PAA directory configuration");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
apr_table_t *notes = r->notes;
const char *paa_enable_note_value = apr_table_get(notes, server_config->paa_enabled_note_name);
int enable_note = -1;
if(paa_enable_note_value != NULL){
enable_note = parse_enable_note(paa_enable_note_value);
}
// In order to log the request context, paa_pa_log_rerror must be used.
if((enable_note == 0) || (enable_note == -1 && !dir_config->paa_enabled)){
paa_ap_log_rerror(__FILE__, __LINE__, APLOG_DEBUG, APR_SUCCESS, r,
NORMAL_MSG_FORMAT, "agent not enabled");
hook_result = OK;
break;
}
if (cache == NULL) {
paa_log(r->pool, APACHE_MSGID, PAA_ERROR,
"PAA cache unavailable, refusing to process request");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
if (server_config->http_client == NULL) {
paa_log(r->pool, APACHE_MSGID, PAA_ERROR,
"PAA HTTP client was not initialized, refusing to process request");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
if (thread_key == NULL) {
paa_log(r->pool, APACHE_MSGID, PAA_ERROR, "thread private key unavailable");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
result = apr_threadkey_private_set(r, thread_key);
if (result != APR_SUCCESS) {
paa_log_error(r->pool, APACHE_MSGID, PAA_ERROR, result,
"failed to set thread private key");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
// create the normalized uri and store it for later use
char *normalized_uri = apr_psprintf(r->pool, "%s", r->parsed_uri.path);
if (normalized_uri == NULL) {
paa_log_error(r->pool, APACHE_MSGID, PAA_ERROR, APR_ENOMEM,
"failed to create normalized uri");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
ap_no2slash(normalized_uri);
req_wrapper.full_normalized_uri = normalized_uri;
const paa_agent_response *agent_resp = NULL;
result = paa_submit_agent_request(r->pool,
server_config->http_client,
server_config->config,
cache,
&client_req,
&client_resp,
&agent_resp);
if (result != APR_SUCCESS) {
paa_log_error(r->pool, APACHE_MSGID, PAA_ERROR,
result, "failed to submit agent request");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
if (paa_agent_response_req_allowed(agent_resp)) {
result = paa_client_request_modify(r->pool, &client_req, agent_resp);
if (result != APR_SUCCESS) {
paa_log_error(r->pool, APACHE_MSGID, PAA_ERROR,
result, "failed to modify client request");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
// Attach the agent response to the request to modify the response headers later on
paa_req_config *req_config = (paa_req_config *)
apr_palloc(r->pool, sizeof(paa_req_config));
if (req_config == NULL) {
paa_log_error(r->pool, APACHE_MSGID, PAA_ERROR,
APR_ENOMEM, "failed to allocate request config");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
req_config->agent_resp = agent_resp;
ap_set_module_config(r->request_config, &paa_module, req_config);
}else{
// sanity check for an issue where the response wasn't sent
if (r->status == 0) {
paa_log(r->pool, APACHE_MSGID, PAA_ERROR, "response from PingAccess not injected");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
// submit_agent_request internally has modified the client response
paa_log(r->pool, APACHE_MSGID, PAA_DEBUG, "agent response sent verbatim to client");
hook_result = DONE;
break;
}
hook_result = OK;
}while(0);
apr_threadkey_private_set(NULL, thread_key);
return hook_result;
} | /**
* The header_parser hook for the PAA module--essentially the "main" function for the module.
*
* @param r the request record for the current request
*
* @return the standard result of the hook
*/ | The header_parser hook for the PAA module--essentially the "main" function for the module.
@param r the request record for the current request
@return the standard result of the hook | [
"The",
"header_parser",
"hook",
"for",
"the",
"PAA",
"module",
"--",
"essentially",
"the",
"\"",
"main",
"\"",
"function",
"for",
"the",
"module",
".",
"@param",
"r",
"the",
"request",
"record",
"for",
"the",
"current",
"request",
"@return",
"the",
"standard",
"result",
"of",
"the",
"hook"
] | static
int paa_header_parser(request_rec *r)
{
apache_client_req req_wrapper;
req_wrapper.rec = r;
req_wrapper.eos_reached = 0;
req_wrapper.full_normalized_uri = NULL;
paa_client_request client_req;
apache_client_req_init(&client_req, &req_wrapper);
apache_client_resp resp_wrapper;
resp_wrapper.rec = r;
paa_client_response client_resp;
apache_client_resp_init(&client_resp, &resp_wrapper);
int hook_result;
do {
apr_status_t result;
paa_server_config *server_config =
(paa_server_config *)ap_get_module_config(r->server->module_config, &paa_module);
paa_dir_config *dir_config =
(paa_dir_config *)ap_get_module_config(r->per_dir_config, &paa_module);
if (server_config == NULL) {
paa_log(r->pool, APACHE_MSGID, PAA_ERROR, "failed to obtain PAA server configuration");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
if (dir_config == NULL) {
paa_log(r->pool, APACHE_MSGID, PAA_ERROR, "failed to obtain PAA directory configuration");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
apr_table_t *notes = r->notes;
const char *paa_enable_note_value = apr_table_get(notes, server_config->paa_enabled_note_name);
int enable_note = -1;
if(paa_enable_note_value != NULL){
enable_note = parse_enable_note(paa_enable_note_value);
}
if((enable_note == 0) || (enable_note == -1 && !dir_config->paa_enabled)){
paa_ap_log_rerror(__FILE__, __LINE__, APLOG_DEBUG, APR_SUCCESS, r,
NORMAL_MSG_FORMAT, "agent not enabled");
hook_result = OK;
break;
}
if (cache == NULL) {
paa_log(r->pool, APACHE_MSGID, PAA_ERROR,
"PAA cache unavailable, refusing to process request");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
if (server_config->http_client == NULL) {
paa_log(r->pool, APACHE_MSGID, PAA_ERROR,
"PAA HTTP client was not initialized, refusing to process request");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
if (thread_key == NULL) {
paa_log(r->pool, APACHE_MSGID, PAA_ERROR, "thread private key unavailable");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
result = apr_threadkey_private_set(r, thread_key);
if (result != APR_SUCCESS) {
paa_log_error(r->pool, APACHE_MSGID, PAA_ERROR, result,
"failed to set thread private key");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
char *normalized_uri = apr_psprintf(r->pool, "%s", r->parsed_uri.path);
if (normalized_uri == NULL) {
paa_log_error(r->pool, APACHE_MSGID, PAA_ERROR, APR_ENOMEM,
"failed to create normalized uri");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
ap_no2slash(normalized_uri);
req_wrapper.full_normalized_uri = normalized_uri;
const paa_agent_response *agent_resp = NULL;
result = paa_submit_agent_request(r->pool,
server_config->http_client,
server_config->config,
cache,
&client_req,
&client_resp,
&agent_resp);
if (result != APR_SUCCESS) {
paa_log_error(r->pool, APACHE_MSGID, PAA_ERROR,
result, "failed to submit agent request");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
if (paa_agent_response_req_allowed(agent_resp)) {
result = paa_client_request_modify(r->pool, &client_req, agent_resp);
if (result != APR_SUCCESS) {
paa_log_error(r->pool, APACHE_MSGID, PAA_ERROR,
result, "failed to modify client request");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
paa_req_config *req_config = (paa_req_config *)
apr_palloc(r->pool, sizeof(paa_req_config));
if (req_config == NULL) {
paa_log_error(r->pool, APACHE_MSGID, PAA_ERROR,
APR_ENOMEM, "failed to allocate request config");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
req_config->agent_resp = agent_resp;
ap_set_module_config(r->request_config, &paa_module, req_config);
}else{
if (r->status == 0) {
paa_log(r->pool, APACHE_MSGID, PAA_ERROR, "response from PingAccess not injected");
hook_result = HTTP_INTERNAL_SERVER_ERROR;
break;
}
paa_log(r->pool, APACHE_MSGID, PAA_DEBUG, "agent response sent verbatim to client");
hook_result = DONE;
break;
}
hook_result = OK;
}while(0);
apr_threadkey_private_set(NULL, thread_key);
return hook_result;
} | [
"static",
"int",
"paa_header_parser",
"(",
"request_rec",
"*",
"r",
")",
"{",
"apache_client_req",
"req_wrapper",
";",
"req_wrapper",
".",
"rec",
"=",
"r",
";",
"req_wrapper",
".",
"eos_reached",
"=",
"0",
";",
"req_wrapper",
".",
"full_normalized_uri",
"=",
"NULL",
";",
"paa_client_request",
"client_req",
";",
"apache_client_req_init",
"(",
"&",
"client_req",
",",
"&",
"req_wrapper",
")",
";",
"apache_client_resp",
"resp_wrapper",
";",
"resp_wrapper",
".",
"rec",
"=",
"r",
";",
"paa_client_response",
"client_resp",
";",
"apache_client_resp_init",
"(",
"&",
"client_resp",
",",
"&",
"resp_wrapper",
")",
";",
"int",
"hook_result",
";",
"do",
"{",
"apr_status_t",
"result",
";",
"paa_server_config",
"*",
"server_config",
"=",
"(",
"paa_server_config",
"*",
")",
"ap_get_module_config",
"(",
"r",
"->",
"server",
"->",
"module_config",
",",
"&",
"paa_module",
")",
";",
"paa_dir_config",
"*",
"dir_config",
"=",
"(",
"paa_dir_config",
"*",
")",
"ap_get_module_config",
"(",
"r",
"->",
"per_dir_config",
",",
"&",
"paa_module",
")",
";",
"if",
"(",
"server_config",
"==",
"NULL",
")",
"{",
"paa_log",
"(",
"r",
"->",
"pool",
",",
"APACHE_MSGID",
",",
"PAA_ERROR",
",",
"\"",
"\"",
")",
";",
"hook_result",
"=",
"HTTP_INTERNAL_SERVER_ERROR",
";",
"break",
";",
"}",
"if",
"(",
"dir_config",
"==",
"NULL",
")",
"{",
"paa_log",
"(",
"r",
"->",
"pool",
",",
"APACHE_MSGID",
",",
"PAA_ERROR",
",",
"\"",
"\"",
")",
";",
"hook_result",
"=",
"HTTP_INTERNAL_SERVER_ERROR",
";",
"break",
";",
"}",
"apr_table_t",
"*",
"notes",
"=",
"r",
"->",
"notes",
";",
"const",
"char",
"*",
"paa_enable_note_value",
"=",
"apr_table_get",
"(",
"notes",
",",
"server_config",
"->",
"paa_enabled_note_name",
")",
";",
"int",
"enable_note",
"=",
"-1",
";",
"if",
"(",
"paa_enable_note_value",
"!=",
"NULL",
")",
"{",
"enable_note",
"=",
"parse_enable_note",
"(",
"paa_enable_note_value",
")",
";",
"}",
"if",
"(",
"(",
"enable_note",
"==",
"0",
")",
"||",
"(",
"enable_note",
"==",
"-1",
"&&",
"!",
"dir_config",
"->",
"paa_enabled",
")",
")",
"{",
"paa_ap_log_rerror",
"(",
"__FILE__",
",",
"__LINE__",
",",
"APLOG_DEBUG",
",",
"APR_SUCCESS",
",",
"r",
",",
"NORMAL_MSG_FORMAT",
",",
"\"",
"\"",
")",
";",
"hook_result",
"=",
"OK",
";",
"break",
";",
"}",
"if",
"(",
"cache",
"==",
"NULL",
")",
"{",
"paa_log",
"(",
"r",
"->",
"pool",
",",
"APACHE_MSGID",
",",
"PAA_ERROR",
",",
"\"",
"\"",
")",
";",
"hook_result",
"=",
"HTTP_INTERNAL_SERVER_ERROR",
";",
"break",
";",
"}",
"if",
"(",
"server_config",
"->",
"http_client",
"==",
"NULL",
")",
"{",
"paa_log",
"(",
"r",
"->",
"pool",
",",
"APACHE_MSGID",
",",
"PAA_ERROR",
",",
"\"",
"\"",
")",
";",
"hook_result",
"=",
"HTTP_INTERNAL_SERVER_ERROR",
";",
"break",
";",
"}",
"if",
"(",
"thread_key",
"==",
"NULL",
")",
"{",
"paa_log",
"(",
"r",
"->",
"pool",
",",
"APACHE_MSGID",
",",
"PAA_ERROR",
",",
"\"",
"\"",
")",
";",
"hook_result",
"=",
"HTTP_INTERNAL_SERVER_ERROR",
";",
"break",
";",
"}",
"result",
"=",
"apr_threadkey_private_set",
"(",
"r",
",",
"thread_key",
")",
";",
"if",
"(",
"result",
"!=",
"APR_SUCCESS",
")",
"{",
"paa_log_error",
"(",
"r",
"->",
"pool",
",",
"APACHE_MSGID",
",",
"PAA_ERROR",
",",
"result",
",",
"\"",
"\"",
")",
";",
"hook_result",
"=",
"HTTP_INTERNAL_SERVER_ERROR",
";",
"break",
";",
"}",
"char",
"*",
"normalized_uri",
"=",
"apr_psprintf",
"(",
"r",
"->",
"pool",
",",
"\"",
"\"",
",",
"r",
"->",
"parsed_uri",
".",
"path",
")",
";",
"if",
"(",
"normalized_uri",
"==",
"NULL",
")",
"{",
"paa_log_error",
"(",
"r",
"->",
"pool",
",",
"APACHE_MSGID",
",",
"PAA_ERROR",
",",
"APR_ENOMEM",
",",
"\"",
"\"",
")",
";",
"hook_result",
"=",
"HTTP_INTERNAL_SERVER_ERROR",
";",
"break",
";",
"}",
"ap_no2slash",
"(",
"normalized_uri",
")",
";",
"req_wrapper",
".",
"full_normalized_uri",
"=",
"normalized_uri",
";",
"const",
"paa_agent_response",
"*",
"agent_resp",
"=",
"NULL",
";",
"result",
"=",
"paa_submit_agent_request",
"(",
"r",
"->",
"pool",
",",
"server_config",
"->",
"http_client",
",",
"server_config",
"->",
"config",
",",
"cache",
",",
"&",
"client_req",
",",
"&",
"client_resp",
",",
"&",
"agent_resp",
")",
";",
"if",
"(",
"result",
"!=",
"APR_SUCCESS",
")",
"{",
"paa_log_error",
"(",
"r",
"->",
"pool",
",",
"APACHE_MSGID",
",",
"PAA_ERROR",
",",
"result",
",",
"\"",
"\"",
")",
";",
"hook_result",
"=",
"HTTP_INTERNAL_SERVER_ERROR",
";",
"break",
";",
"}",
"if",
"(",
"paa_agent_response_req_allowed",
"(",
"agent_resp",
")",
")",
"{",
"result",
"=",
"paa_client_request_modify",
"(",
"r",
"->",
"pool",
",",
"&",
"client_req",
",",
"agent_resp",
")",
";",
"if",
"(",
"result",
"!=",
"APR_SUCCESS",
")",
"{",
"paa_log_error",
"(",
"r",
"->",
"pool",
",",
"APACHE_MSGID",
",",
"PAA_ERROR",
",",
"result",
",",
"\"",
"\"",
")",
";",
"hook_result",
"=",
"HTTP_INTERNAL_SERVER_ERROR",
";",
"break",
";",
"}",
"paa_req_config",
"*",
"req_config",
"=",
"(",
"paa_req_config",
"*",
")",
"apr_palloc",
"(",
"r",
"->",
"pool",
",",
"sizeof",
"(",
"paa_req_config",
")",
")",
";",
"if",
"(",
"req_config",
"==",
"NULL",
")",
"{",
"paa_log_error",
"(",
"r",
"->",
"pool",
",",
"APACHE_MSGID",
",",
"PAA_ERROR",
",",
"APR_ENOMEM",
",",
"\"",
"\"",
")",
";",
"hook_result",
"=",
"HTTP_INTERNAL_SERVER_ERROR",
";",
"break",
";",
"}",
"req_config",
"->",
"agent_resp",
"=",
"agent_resp",
";",
"ap_set_module_config",
"(",
"r",
"->",
"request_config",
",",
"&",
"paa_module",
",",
"req_config",
")",
";",
"}",
"else",
"{",
"if",
"(",
"r",
"->",
"status",
"==",
"0",
")",
"{",
"paa_log",
"(",
"r",
"->",
"pool",
",",
"APACHE_MSGID",
",",
"PAA_ERROR",
",",
"\"",
"\"",
")",
";",
"hook_result",
"=",
"HTTP_INTERNAL_SERVER_ERROR",
";",
"break",
";",
"}",
"paa_log",
"(",
"r",
"->",
"pool",
",",
"APACHE_MSGID",
",",
"PAA_DEBUG",
",",
"\"",
"\"",
")",
";",
"hook_result",
"=",
"DONE",
";",
"break",
";",
"}",
"hook_result",
"=",
"OK",
";",
"}",
"while",
"(",
"0",
")",
";",
"apr_threadkey_private_set",
"(",
"NULL",
",",
"thread_key",
")",
";",
"return",
"hook_result",
";",
"}"
] | The header_parser hook for the PAA module--essentially the "main" function for the module. | [
"The",
"header_parser",
"hook",
"for",
"the",
"PAA",
"module",
"--",
"essentially",
"the",
"\"",
"main",
"\"",
"function",
"for",
"the",
"module",
"."
] | [
"// In order to log the request context, paa_pa_log_rerror must be used.",
"// create the normalized uri and store it for later use",
"// Attach the agent response to the request to modify the response headers later on",
"// sanity check for an issue where the response wasn't sent",
"// submit_agent_request internally has modified the client response"
] | [
{
"param": "r",
"type": "request_rec"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "r",
"type": "request_rec",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4a3a54b3e7c4ae0eff7527e0ad1d795eff4120e3 | bioinform/fermi-lite | bfc.c | [
"MIT"
] | C | kmer_correct | void | void kmer_correct(ec_step_t * es, int mode, bfc_ch_t * ch) {
int i = 0;
es->e = (bfc_ec1buf_t**)calloc(es->opt->n_threads, sizeof(void*)); //jwala added cast
for (i = 0; i < es->opt->n_threads; ++i)
es->e[i] = ec1buf_init(es->opt, ch), es->e[i]->mode = mode;
kt_for(es->opt->n_threads, worker_ec, es, es->n_seqs);
for (i = 0; i < es->opt->n_threads; ++i)
ec1buf_destroy(es->e[i]);
free(es->e);
} | //jwala added here (linker issues)
// copied from fml_correct_core | jwala added here (linker issues)
copied from fml_correct_core | [
"jwala",
"added",
"here",
"(",
"linker",
"issues",
")",
"copied",
"from",
"fml_correct_core"
] | void kmer_correct(ec_step_t * es, int mode, bfc_ch_t * ch) {
int i = 0;
es->e = (bfc_ec1buf_t**)calloc(es->opt->n_threads, sizeof(void*));
for (i = 0; i < es->opt->n_threads; ++i)
es->e[i] = ec1buf_init(es->opt, ch), es->e[i]->mode = mode;
kt_for(es->opt->n_threads, worker_ec, es, es->n_seqs);
for (i = 0; i < es->opt->n_threads; ++i)
ec1buf_destroy(es->e[i]);
free(es->e);
} | [
"void",
"kmer_correct",
"(",
"ec_step_t",
"*",
"es",
",",
"int",
"mode",
",",
"bfc_ch_t",
"*",
"ch",
")",
"{",
"int",
"i",
"=",
"0",
";",
"es",
"->",
"e",
"=",
"(",
"bfc_ec1buf_t",
"*",
"*",
")",
"calloc",
"(",
"es",
"->",
"opt",
"->",
"n_threads",
",",
"sizeof",
"(",
"void",
"*",
")",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"es",
"->",
"opt",
"->",
"n_threads",
";",
"++",
"i",
")",
"es",
"->",
"e",
"[",
"i",
"]",
"=",
"ec1buf_init",
"(",
"es",
"->",
"opt",
",",
"ch",
")",
",",
"es",
"->",
"e",
"[",
"i",
"]",
"->",
"mode",
"=",
"mode",
";",
"kt_for",
"(",
"es",
"->",
"opt",
"->",
"n_threads",
",",
"worker_ec",
",",
"es",
",",
"es",
"->",
"n_seqs",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"es",
"->",
"opt",
"->",
"n_threads",
";",
"++",
"i",
")",
"ec1buf_destroy",
"(",
"es",
"->",
"e",
"[",
"i",
"]",
")",
";",
"free",
"(",
"es",
"->",
"e",
")",
";",
"}"
] | jwala added here (linker issues)
copied from fml_correct_core | [
"jwala",
"added",
"here",
"(",
"linker",
"issues",
")",
"copied",
"from",
"fml_correct_core"
] | [
"//jwala added cast"
] | [
{
"param": "es",
"type": "ec_step_t"
},
{
"param": "mode",
"type": "int"
},
{
"param": "ch",
"type": "bfc_ch_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "es",
"type": "ec_step_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mode",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ch",
"type": "bfc_ch_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a71d79fac681032319aba97da38506ae517192f9 | gawen947/libgawen | htable.c | [
"BSD-2-Clause"
] | C | ht_lookup | void | void * ht_lookup(htable_t ht, const void *key,
void * (*retrieve)(const void *, void *),
void *optarg)
{
struct entry *entry;
uint32_t index = IDX(ht->hash(key), ht->nbuckets);
for(entry = ht->buckets[index] ; entry ; entry = entry->next)
if(ht->compare(entry->key, key))
return entry->data;
entry = malloc(sizeof(struct entry));
entry->key = key;
entry->data = retrieve(key, optarg);
entry->next = ht->buckets[index];
ht->buckets[index] = entry;
return entry->data;
} | /* FIXME: In a future MAJOR version, the name of this function
should probably be replaced with something more appropriate. */ | In a future MAJOR version, the name of this function
should probably be replaced with something more appropriate. | [
"In",
"a",
"future",
"MAJOR",
"version",
"the",
"name",
"of",
"this",
"function",
"should",
"probably",
"be",
"replaced",
"with",
"something",
"more",
"appropriate",
"."
] | void * ht_lookup(htable_t ht, const void *key,
void * (*retrieve)(const void *, void *),
void *optarg)
{
struct entry *entry;
uint32_t index = IDX(ht->hash(key), ht->nbuckets);
for(entry = ht->buckets[index] ; entry ; entry = entry->next)
if(ht->compare(entry->key, key))
return entry->data;
entry = malloc(sizeof(struct entry));
entry->key = key;
entry->data = retrieve(key, optarg);
entry->next = ht->buckets[index];
ht->buckets[index] = entry;
return entry->data;
} | [
"void",
"*",
"ht_lookup",
"(",
"htable_t",
"ht",
",",
"const",
"void",
"*",
"key",
",",
"void",
"*",
"(",
"*",
"retrieve",
")",
"(",
"const",
"void",
"*",
",",
"void",
"*",
")",
",",
"void",
"*",
"optarg",
")",
"{",
"struct",
"entry",
"*",
"entry",
";",
"uint32_t",
"index",
"=",
"IDX",
"(",
"ht",
"->",
"hash",
"(",
"key",
")",
",",
"ht",
"->",
"nbuckets",
")",
";",
"for",
"(",
"entry",
"=",
"ht",
"->",
"buckets",
"[",
"index",
"]",
";",
"entry",
";",
"entry",
"=",
"entry",
"->",
"next",
")",
"if",
"(",
"ht",
"->",
"compare",
"(",
"entry",
"->",
"key",
",",
"key",
")",
")",
"return",
"entry",
"->",
"data",
";",
"entry",
"=",
"malloc",
"(",
"sizeof",
"(",
"struct",
"entry",
")",
")",
";",
"entry",
"->",
"key",
"=",
"key",
";",
"entry",
"->",
"data",
"=",
"retrieve",
"(",
"key",
",",
"optarg",
")",
";",
"entry",
"->",
"next",
"=",
"ht",
"->",
"buckets",
"[",
"index",
"]",
";",
"ht",
"->",
"buckets",
"[",
"index",
"]",
"=",
"entry",
";",
"return",
"entry",
"->",
"data",
";",
"}"
] | FIXME: In a future MAJOR version, the name of this function
should probably be replaced with something more appropriate. | [
"FIXME",
":",
"In",
"a",
"future",
"MAJOR",
"version",
"the",
"name",
"of",
"this",
"function",
"should",
"probably",
"be",
"replaced",
"with",
"something",
"more",
"appropriate",
"."
] | [] | [
{
"param": "ht",
"type": "htable_t"
},
{
"param": "key",
"type": "void"
},
{
"param": "retrieve",
"type": "void"
},
{
"param": "optarg",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ht",
"type": "htable_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "retrieve",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "optarg",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3da71f2402753753024061d0cc43e74fb6a2a376 | gawen947/libgawen | daemon.c | [
"BSD-2-Clause"
] | C | daemon | int | int daemon(int nochdir, int noclose)
{
int fd;
switch(fork()) {
case -1: /* error */
return -1;
case 0: /* child */
break;
default: /* parent */
exit(0);
}
if(setsid() == -1)
return -1;
if(!nochdir)
chdir("/");
if(!noclose && (fd = open("/dev/null", O_RDWR, 0)) != -1) {
dup2(fd, STDIN_FILENO);
dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);
if(fd > 2)
close(fd);
}
return 0;
} | /* for targets that do not implement daemon() */ | for targets that do not implement daemon() | [
"for",
"targets",
"that",
"do",
"not",
"implement",
"daemon",
"()"
] | int daemon(int nochdir, int noclose)
{
int fd;
switch(fork()) {
case -1:
return -1;
case 0:
break;
default:
exit(0);
}
if(setsid() == -1)
return -1;
if(!nochdir)
chdir("/");
if(!noclose && (fd = open("/dev/null", O_RDWR, 0)) != -1) {
dup2(fd, STDIN_FILENO);
dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);
if(fd > 2)
close(fd);
}
return 0;
} | [
"int",
"daemon",
"(",
"int",
"nochdir",
",",
"int",
"noclose",
")",
"{",
"int",
"fd",
";",
"switch",
"(",
"fork",
"(",
")",
")",
"{",
"case",
"-1",
":",
"return",
"-1",
";",
"case",
"0",
":",
"break",
";",
"default",
":",
"exit",
"(",
"0",
")",
";",
"}",
"if",
"(",
"setsid",
"(",
")",
"==",
"-1",
")",
"return",
"-1",
";",
"if",
"(",
"!",
"nochdir",
")",
"chdir",
"(",
"\"",
"\"",
")",
";",
"if",
"(",
"!",
"noclose",
"&&",
"(",
"fd",
"=",
"open",
"(",
"\"",
"\"",
",",
"O_RDWR",
",",
"0",
")",
")",
"!=",
"-1",
")",
"{",
"dup2",
"(",
"fd",
",",
"STDIN_FILENO",
")",
";",
"dup2",
"(",
"fd",
",",
"STDOUT_FILENO",
")",
";",
"dup2",
"(",
"fd",
",",
"STDERR_FILENO",
")",
";",
"if",
"(",
"fd",
">",
"2",
")",
"close",
"(",
"fd",
")",
";",
"}",
"return",
"0",
";",
"}"
] | for targets that do not implement daemon() | [
"for",
"targets",
"that",
"do",
"not",
"implement",
"daemon",
"()"
] | [
"/* error */",
"/* child */",
"/* parent */"
] | [
{
"param": "nochdir",
"type": "int"
},
{
"param": "noclose",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "nochdir",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "noclose",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d2d7c0c8c8a641b8ad538b48f7c468e81a453a1f | gabrieledarrigo/ducky | src/cache.c | [
"MIT"
] | C | hash | int | int hash(const char *string, int prime, int size) {
long hash = 0;
int len = (int) strlen(string);
for (int i = 0; i < len; i++) {
hash += (long) pow(prime, len - (i + 1)) * string[i]; // Compute a large integer number
hash = hash % size; // Get the reminder
}
return (int) hash;
} | /**
* Takes a string as an input and:
* Converts it into a large integer number.
* Reduces the size of the integer to a fixed range, by taking its remainder mod m, where m is the number of buckets of the hash table.
*
* @param string the string from which the hash is computed
* @param prime a prime number that is used to calculate the large integer
* @param size the number of nodes in the cache
* @return an
*/ | Takes a string as an input and:
Converts it into a large integer number.
Reduces the size of the integer to a fixed range, by taking its remainder mod m, where m is the number of buckets of the hash table.
@param string the string from which the hash is computed
@param prime a prime number that is used to calculate the large integer
@param size the number of nodes in the cache
@return an | [
"Takes",
"a",
"string",
"as",
"an",
"input",
"and",
":",
"Converts",
"it",
"into",
"a",
"large",
"integer",
"number",
".",
"Reduces",
"the",
"size",
"of",
"the",
"integer",
"to",
"a",
"fixed",
"range",
"by",
"taking",
"its",
"remainder",
"mod",
"m",
"where",
"m",
"is",
"the",
"number",
"of",
"buckets",
"of",
"the",
"hash",
"table",
".",
"@param",
"string",
"the",
"string",
"from",
"which",
"the",
"hash",
"is",
"computed",
"@param",
"prime",
"a",
"prime",
"number",
"that",
"is",
"used",
"to",
"calculate",
"the",
"large",
"integer",
"@param",
"size",
"the",
"number",
"of",
"nodes",
"in",
"the",
"cache",
"@return",
"an"
] | int hash(const char *string, int prime, int size) {
long hash = 0;
int len = (int) strlen(string);
for (int i = 0; i < len; i++) {
hash += (long) pow(prime, len - (i + 1)) * string[i];
hash = hash % size;
}
return (int) hash;
} | [
"int",
"hash",
"(",
"const",
"char",
"*",
"string",
",",
"int",
"prime",
",",
"int",
"size",
")",
"{",
"long",
"hash",
"=",
"0",
";",
"int",
"len",
"=",
"(",
"int",
")",
"strlen",
"(",
"string",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"hash",
"+=",
"(",
"long",
")",
"pow",
"(",
"prime",
",",
"len",
"-",
"(",
"i",
"+",
"1",
")",
")",
"*",
"string",
"[",
"i",
"]",
";",
"hash",
"=",
"hash",
"%",
"size",
";",
"}",
"return",
"(",
"int",
")",
"hash",
";",
"}"
] | Takes a string as an input and:
Converts it into a large integer number. | [
"Takes",
"a",
"string",
"as",
"an",
"input",
"and",
":",
"Converts",
"it",
"into",
"a",
"large",
"integer",
"number",
"."
] | [
"// Compute a large integer number\r",
"// Get the reminder\r"
] | [
{
"param": "string",
"type": "char"
},
{
"param": "prime",
"type": "int"
},
{
"param": "size",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "string",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "prime",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "size",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d2d7c0c8c8a641b8ad538b48f7c468e81a453a1f | gabrieledarrigo/ducky | src/cache.c | [
"MIT"
] | C | cache_new_sized | cache | static cache *cache_new_sized(int size) {
cache *c = malloc(sizeof(cache));
if (c == NULL) {
logs(LOG_FATAL, "Cannot allocate to create new cache data structure: %s", strerror(errno));
exit(EXIT_FAILURE);
}
c->size = next_prime(size);
c->count = 0;
c->load = 0;
c->nodes = calloc((size_t) c->size, sizeof(node *));
if (c->nodes == NULL) {
free(c);
logs(LOG_FATAL, "Cannot allocate to create cache nodes: %s", strerror(errno));
exit(EXIT_FAILURE);
}
return c;
} | /**
* Create a new cache of the desired size.
*
* @param size the size of the cache; ie: the initial number of nodes tha it has.
* @return the created cache
*/ | Create a new cache of the desired size.
@param size the size of the cache; ie: the initial number of nodes tha it has.
@return the created cache | [
"Create",
"a",
"new",
"cache",
"of",
"the",
"desired",
"size",
".",
"@param",
"size",
"the",
"size",
"of",
"the",
"cache",
";",
"ie",
":",
"the",
"initial",
"number",
"of",
"nodes",
"tha",
"it",
"has",
".",
"@return",
"the",
"created",
"cache"
] | static cache *cache_new_sized(int size) {
cache *c = malloc(sizeof(cache));
if (c == NULL) {
logs(LOG_FATAL, "Cannot allocate to create new cache data structure: %s", strerror(errno));
exit(EXIT_FAILURE);
}
c->size = next_prime(size);
c->count = 0;
c->load = 0;
c->nodes = calloc((size_t) c->size, sizeof(node *));
if (c->nodes == NULL) {
free(c);
logs(LOG_FATAL, "Cannot allocate to create cache nodes: %s", strerror(errno));
exit(EXIT_FAILURE);
}
return c;
} | [
"static",
"cache",
"*",
"cache_new_sized",
"(",
"int",
"size",
")",
"{",
"cache",
"*",
"c",
"=",
"malloc",
"(",
"sizeof",
"(",
"cache",
")",
")",
";",
"if",
"(",
"c",
"==",
"NULL",
")",
"{",
"logs",
"(",
"LOG_FATAL",
",",
"\"",
"\"",
",",
"strerror",
"(",
"errno",
")",
")",
";",
"exit",
"(",
"EXIT_FAILURE",
")",
";",
"}",
"c",
"->",
"size",
"=",
"next_prime",
"(",
"size",
")",
";",
"c",
"->",
"count",
"=",
"0",
";",
"c",
"->",
"load",
"=",
"0",
";",
"c",
"->",
"nodes",
"=",
"calloc",
"(",
"(",
"size_t",
")",
"c",
"->",
"size",
",",
"sizeof",
"(",
"node",
"*",
")",
")",
";",
"if",
"(",
"c",
"->",
"nodes",
"==",
"NULL",
")",
"{",
"free",
"(",
"c",
")",
";",
"logs",
"(",
"LOG_FATAL",
",",
"\"",
"\"",
",",
"strerror",
"(",
"errno",
")",
")",
";",
"exit",
"(",
"EXIT_FAILURE",
")",
";",
"}",
"return",
"c",
";",
"}"
] | Create a new cache of the desired size. | [
"Create",
"a",
"new",
"cache",
"of",
"the",
"desired",
"size",
"."
] | [] | [
{
"param": "size",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "size",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d2d7c0c8c8a641b8ad538b48f7c468e81a453a1f | gabrieledarrigo/ducky | src/cache.c | [
"MIT"
] | C | delete_node | void | static void delete_node(node *n) {
free(n->key);
free(n->value);
free(n);
} | /**
* Free a node from the memory.
*
* @param n the node that must be deleted
*/ | Free a node from the memory.
@param n the node that must be deleted | [
"Free",
"a",
"node",
"from",
"the",
"memory",
".",
"@param",
"n",
"the",
"node",
"that",
"must",
"be",
"deleted"
] | static void delete_node(node *n) {
free(n->key);
free(n->value);
free(n);
} | [
"static",
"void",
"delete_node",
"(",
"node",
"*",
"n",
")",
"{",
"free",
"(",
"n",
"->",
"key",
")",
";",
"free",
"(",
"n",
"->",
"value",
")",
";",
"free",
"(",
"n",
")",
";",
"}"
] | Free a node from the memory. | [
"Free",
"a",
"node",
"from",
"the",
"memory",
"."
] | [] | [
{
"param": "n",
"type": "node"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "n",
"type": "node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d2d7c0c8c8a641b8ad538b48f7c468e81a453a1f | gabrieledarrigo/ducky | src/cache.c | [
"MIT"
] | C | cache_delete | void | void cache_delete(cache *c) {
for (int i = 0; i < c->size; i++) {
node *n = c->nodes[i];
if (n != NULL) {
delete_node(n);
}
}
free(c->nodes);
free(c);
} | /**
* Delete all nodes from the cache and then free the cache itself from the memory.
*
* @param c the cache to be deleted
*/ | Delete all nodes from the cache and then free the cache itself from the memory.
@param c the cache to be deleted | [
"Delete",
"all",
"nodes",
"from",
"the",
"cache",
"and",
"then",
"free",
"the",
"cache",
"itself",
"from",
"the",
"memory",
".",
"@param",
"c",
"the",
"cache",
"to",
"be",
"deleted"
] | void cache_delete(cache *c) {
for (int i = 0; i < c->size; i++) {
node *n = c->nodes[i];
if (n != NULL) {
delete_node(n);
}
}
free(c->nodes);
free(c);
} | [
"void",
"cache_delete",
"(",
"cache",
"*",
"c",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"c",
"->",
"size",
";",
"i",
"++",
")",
"{",
"node",
"*",
"n",
"=",
"c",
"->",
"nodes",
"[",
"i",
"]",
";",
"if",
"(",
"n",
"!=",
"NULL",
")",
"{",
"delete_node",
"(",
"n",
")",
";",
"}",
"}",
"free",
"(",
"c",
"->",
"nodes",
")",
";",
"free",
"(",
"c",
")",
";",
"}"
] | Delete all nodes from the cache and then free the cache itself from the memory. | [
"Delete",
"all",
"nodes",
"from",
"the",
"cache",
"and",
"then",
"free",
"the",
"cache",
"itself",
"from",
"the",
"memory",
"."
] | [] | [
{
"param": "c",
"type": "cache"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "c",
"type": "cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d2d7c0c8c8a641b8ad538b48f7c468e81a453a1f | gabrieledarrigo/ducky | src/cache.c | [
"MIT"
] | C | resize | void | static void resize(cache *c, int size) {
if (size < INITIAL_CACHE_SIZE) {
return;
}
// Create a new temporary cache for the resizing
cache *tmp_cache = cache_new_sized(size);
// Insert all nodes into the new cache
for (int i = 0; i < c->size; i++) {
node *n = c->nodes[i];
if (n != NULL) {
set(tmp_cache, n->key, n->value);
}
}
// Set new count and load value
c->count = tmp_cache->count;
c->load = tmp_cache->load;
// Swap between temp and actual cache
int tmp_size = c->size;
c->size = tmp_cache->size;
tmp_cache->size = tmp_size;
node **tmp_nodes = c->nodes;
c->nodes = tmp_cache->nodes;
tmp_cache->nodes = tmp_nodes;
// Delete the temporary cache
cache_delete(tmp_cache);
} | /**
* Resize the cache to the new size.
* First create a temporary cache where all old cache nodes are stored.
* Then create a new cache of the desired size, copy all nodes from the temp cache to the new one, and delete the old cache.
*
* @param c the cache that needs to be resize
* @param size the new cache size
*/ | Resize the cache to the new size.
First create a temporary cache where all old cache nodes are stored.
Then create a new cache of the desired size, copy all nodes from the temp cache to the new one, and delete the old cache.
@param c the cache that needs to be resize
@param size the new cache size | [
"Resize",
"the",
"cache",
"to",
"the",
"new",
"size",
".",
"First",
"create",
"a",
"temporary",
"cache",
"where",
"all",
"old",
"cache",
"nodes",
"are",
"stored",
".",
"Then",
"create",
"a",
"new",
"cache",
"of",
"the",
"desired",
"size",
"copy",
"all",
"nodes",
"from",
"the",
"temp",
"cache",
"to",
"the",
"new",
"one",
"and",
"delete",
"the",
"old",
"cache",
".",
"@param",
"c",
"the",
"cache",
"that",
"needs",
"to",
"be",
"resize",
"@param",
"size",
"the",
"new",
"cache",
"size"
] | static void resize(cache *c, int size) {
if (size < INITIAL_CACHE_SIZE) {
return;
}
cache *tmp_cache = cache_new_sized(size);
for (int i = 0; i < c->size; i++) {
node *n = c->nodes[i];
if (n != NULL) {
set(tmp_cache, n->key, n->value);
}
}
c->count = tmp_cache->count;
c->load = tmp_cache->load;
int tmp_size = c->size;
c->size = tmp_cache->size;
tmp_cache->size = tmp_size;
node **tmp_nodes = c->nodes;
c->nodes = tmp_cache->nodes;
tmp_cache->nodes = tmp_nodes;
cache_delete(tmp_cache);
} | [
"static",
"void",
"resize",
"(",
"cache",
"*",
"c",
",",
"int",
"size",
")",
"{",
"if",
"(",
"size",
"<",
"INITIAL_CACHE_SIZE",
")",
"{",
"return",
";",
"}",
"cache",
"*",
"tmp_cache",
"=",
"cache_new_sized",
"(",
"size",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"c",
"->",
"size",
";",
"i",
"++",
")",
"{",
"node",
"*",
"n",
"=",
"c",
"->",
"nodes",
"[",
"i",
"]",
";",
"if",
"(",
"n",
"!=",
"NULL",
")",
"{",
"set",
"(",
"tmp_cache",
",",
"n",
"->",
"key",
",",
"n",
"->",
"value",
")",
";",
"}",
"}",
"c",
"->",
"count",
"=",
"tmp_cache",
"->",
"count",
";",
"c",
"->",
"load",
"=",
"tmp_cache",
"->",
"load",
";",
"int",
"tmp_size",
"=",
"c",
"->",
"size",
";",
"c",
"->",
"size",
"=",
"tmp_cache",
"->",
"size",
";",
"tmp_cache",
"->",
"size",
"=",
"tmp_size",
";",
"node",
"*",
"*",
"tmp_nodes",
"=",
"c",
"->",
"nodes",
";",
"c",
"->",
"nodes",
"=",
"tmp_cache",
"->",
"nodes",
";",
"tmp_cache",
"->",
"nodes",
"=",
"tmp_nodes",
";",
"cache_delete",
"(",
"tmp_cache",
")",
";",
"}"
] | Resize the cache to the new size. | [
"Resize",
"the",
"cache",
"to",
"the",
"new",
"size",
"."
] | [
"// Create a new temporary cache for the resizing\r",
"// Insert all nodes into the new cache\r",
"// Set new count and load value\r",
"// Swap between temp and actual cache\r",
"// Delete the temporary cache\r"
] | [
{
"param": "c",
"type": "cache"
},
{
"param": "size",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "c",
"type": "cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "size",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ade40cc1cd195f0ab32b27393116050a6f85f532 | gabrieledarrigo/ducky | src/ducky.c | [
"MIT"
] | C | make_socket | int | int make_socket(int port, int reuse) {
int sockfd;
struct sockaddr_in sockaddr;
bzero(&sockaddr, sizeof(sockaddr));
sockaddr.sin_family = AF_INET;
sockaddr.sin_port = htons(port);
sockaddr.sin_addr.s_addr = htons(INADDR_ANY);
// Create the socket
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
logs(LOG_FATAL, "Cannot create the socket: ", strerror(errno));
exit(EXIT_FAILURE);
}
if (reuse == 1) {
setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(int));
setsockopt(sockfd, SOL_SOCKET, SO_REUSEPORT, &reuse, sizeof(int));
}
// Bind the socket to the port
if (bind(sockfd, (struct sockaddr *) &sockaddr, sizeof(sockaddr)) == -1) {
logs(LOG_FATAL, "Cannot bind the address to the socket: ", strerror(errno));
exit(EXIT_FAILURE);
}
logs(LOG_INFO, "Ducky up and running, listening on port %i", port);
return sockfd;
} | /**
* Create a an AF_INET socket and bind it to the specified port.
*
* @param port the port number
* @param reuse an integer that state if the socket must be reused. 1 to reuse the socket
* @return the created socket.
*/ | Create a an AF_INET socket and bind it to the specified port.
@param port the port number
@param reuse an integer that state if the socket must be reused. 1 to reuse the socket
@return the created socket. | [
"Create",
"a",
"an",
"AF_INET",
"socket",
"and",
"bind",
"it",
"to",
"the",
"specified",
"port",
".",
"@param",
"port",
"the",
"port",
"number",
"@param",
"reuse",
"an",
"integer",
"that",
"state",
"if",
"the",
"socket",
"must",
"be",
"reused",
".",
"1",
"to",
"reuse",
"the",
"socket",
"@return",
"the",
"created",
"socket",
"."
] | int make_socket(int port, int reuse) {
int sockfd;
struct sockaddr_in sockaddr;
bzero(&sockaddr, sizeof(sockaddr));
sockaddr.sin_family = AF_INET;
sockaddr.sin_port = htons(port);
sockaddr.sin_addr.s_addr = htons(INADDR_ANY);
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
logs(LOG_FATAL, "Cannot create the socket: ", strerror(errno));
exit(EXIT_FAILURE);
}
if (reuse == 1) {
setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(int));
setsockopt(sockfd, SOL_SOCKET, SO_REUSEPORT, &reuse, sizeof(int));
}
if (bind(sockfd, (struct sockaddr *) &sockaddr, sizeof(sockaddr)) == -1) {
logs(LOG_FATAL, "Cannot bind the address to the socket: ", strerror(errno));
exit(EXIT_FAILURE);
}
logs(LOG_INFO, "Ducky up and running, listening on port %i", port);
return sockfd;
} | [
"int",
"make_socket",
"(",
"int",
"port",
",",
"int",
"reuse",
")",
"{",
"int",
"sockfd",
";",
"struct",
"sockaddr_in",
"sockaddr",
";",
"bzero",
"(",
"&",
"sockaddr",
",",
"sizeof",
"(",
"sockaddr",
")",
")",
";",
"sockaddr",
".",
"sin_family",
"=",
"AF_INET",
";",
"sockaddr",
".",
"sin_port",
"=",
"htons",
"(",
"port",
")",
";",
"sockaddr",
".",
"sin_addr",
".",
"s_addr",
"=",
"htons",
"(",
"INADDR_ANY",
")",
";",
"if",
"(",
"(",
"sockfd",
"=",
"socket",
"(",
"AF_INET",
",",
"SOCK_DGRAM",
",",
"0",
")",
")",
"==",
"-1",
")",
"{",
"logs",
"(",
"LOG_FATAL",
",",
"\"",
"\"",
",",
"strerror",
"(",
"errno",
")",
")",
";",
"exit",
"(",
"EXIT_FAILURE",
")",
";",
"}",
"if",
"(",
"reuse",
"==",
"1",
")",
"{",
"setsockopt",
"(",
"sockfd",
",",
"SOL_SOCKET",
",",
"SO_REUSEADDR",
",",
"&",
"reuse",
",",
"sizeof",
"(",
"int",
")",
")",
";",
"setsockopt",
"(",
"sockfd",
",",
"SOL_SOCKET",
",",
"SO_REUSEPORT",
",",
"&",
"reuse",
",",
"sizeof",
"(",
"int",
")",
")",
";",
"}",
"if",
"(",
"bind",
"(",
"sockfd",
",",
"(",
"struct",
"sockaddr",
"*",
")",
"&",
"sockaddr",
",",
"sizeof",
"(",
"sockaddr",
")",
")",
"==",
"-1",
")",
"{",
"logs",
"(",
"LOG_FATAL",
",",
"\"",
"\"",
",",
"strerror",
"(",
"errno",
")",
")",
";",
"exit",
"(",
"EXIT_FAILURE",
")",
";",
"}",
"logs",
"(",
"LOG_INFO",
",",
"\"",
"\"",
",",
"port",
")",
";",
"return",
"sockfd",
";",
"}"
] | Create a an AF_INET socket and bind it to the specified port. | [
"Create",
"a",
"an",
"AF_INET",
"socket",
"and",
"bind",
"it",
"to",
"the",
"specified",
"port",
"."
] | [
"// Create the socket",
"// Bind the socket to the port"
] | [
{
"param": "port",
"type": "int"
},
{
"param": "reuse",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "port",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reuse",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ade40cc1cd195f0ab32b27393116050a6f85f532 | gabrieledarrigo/ducky | src/ducky.c | [
"MIT"
] | C | receive | int | int receive(int sockfd, char *buffer, size_t size, struct sockaddr *sockaddr, socklen_t *sockaddr_len) {
int received = recvfrom(sockfd, buffer, size, 0, sockaddr, sockaddr_len);
if (received == -1) {
return -1;
}
buffer[received] = '\0';
logs(LOG_INFO, "Received buffer with len: %lu, %s", strlen(buffer), buffer);
return received;
} | /**
* Read N bytes from the socket and store them in the buffer array.
*
* @param sockfd the socket that is used to read data
* @param buffer the buffer that stores data sent from the client
* @param size the size of the buffer
* @param sockaddr the client address
* @param sockaddr_len the length of the client address
* @return the number of byte received
*/ | Read N bytes from the socket and store them in the buffer array. | [
"Read",
"N",
"bytes",
"from",
"the",
"socket",
"and",
"store",
"them",
"in",
"the",
"buffer",
"array",
"."
] | int receive(int sockfd, char *buffer, size_t size, struct sockaddr *sockaddr, socklen_t *sockaddr_len) {
int received = recvfrom(sockfd, buffer, size, 0, sockaddr, sockaddr_len);
if (received == -1) {
return -1;
}
buffer[received] = '\0';
logs(LOG_INFO, "Received buffer with len: %lu, %s", strlen(buffer), buffer);
return received;
} | [
"int",
"receive",
"(",
"int",
"sockfd",
",",
"char",
"*",
"buffer",
",",
"size_t",
"size",
",",
"struct",
"sockaddr",
"*",
"sockaddr",
",",
"socklen_t",
"*",
"sockaddr_len",
")",
"{",
"int",
"received",
"=",
"recvfrom",
"(",
"sockfd",
",",
"buffer",
",",
"size",
",",
"0",
",",
"sockaddr",
",",
"sockaddr_len",
")",
";",
"if",
"(",
"received",
"==",
"-1",
")",
"{",
"return",
"-1",
";",
"}",
"buffer",
"[",
"received",
"]",
"=",
"'",
"\\0",
"'",
";",
"logs",
"(",
"LOG_INFO",
",",
"\"",
"\"",
",",
"strlen",
"(",
"buffer",
")",
",",
"buffer",
")",
";",
"return",
"received",
";",
"}"
] | Read N bytes from the socket and store them in the buffer array. | [
"Read",
"N",
"bytes",
"from",
"the",
"socket",
"and",
"store",
"them",
"in",
"the",
"buffer",
"array",
"."
] | [] | [
{
"param": "sockfd",
"type": "int"
},
{
"param": "buffer",
"type": "char"
},
{
"param": "size",
"type": "size_t"
},
{
"param": "sockaddr",
"type": "struct sockaddr"
},
{
"param": "sockaddr_len",
"type": "socklen_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sockfd",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "buffer",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "size",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sockaddr",
"type": "struct sockaddr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sockaddr_len",
"type": "socklen_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ade40cc1cd195f0ab32b27393116050a6f85f532 | gabrieledarrigo/ducky | src/ducky.c | [
"MIT"
] | C | send_response | int | int send_response(int sockfd, struct sockaddr *sockaddr, socklen_t sockaddr_len, response res) {
int sent;
char *str = response_to_string(res);
if ((sent = sendto(sockfd, str, strlen(str), 0, sockaddr, sockaddr_len)) == -1) {
logs(LOG_ERROR, "Cannot send a response: ", strerror(errno));
}
logs(LOG_INFO, "Sent %i byte, response is %s", sent, res.data);
return sent;
} | /**
* Send a response to the client.
*
* @param sockfd the socket that is used to send the data to the client
* @param sockaddr the client address
* @param sockaddr_len the length of the client address
* @param res a response struct with the related status code and data
* @return
*/ | Send a response to the client. | [
"Send",
"a",
"response",
"to",
"the",
"client",
"."
] | int send_response(int sockfd, struct sockaddr *sockaddr, socklen_t sockaddr_len, response res) {
int sent;
char *str = response_to_string(res);
if ((sent = sendto(sockfd, str, strlen(str), 0, sockaddr, sockaddr_len)) == -1) {
logs(LOG_ERROR, "Cannot send a response: ", strerror(errno));
}
logs(LOG_INFO, "Sent %i byte, response is %s", sent, res.data);
return sent;
} | [
"int",
"send_response",
"(",
"int",
"sockfd",
",",
"struct",
"sockaddr",
"*",
"sockaddr",
",",
"socklen_t",
"sockaddr_len",
",",
"response",
"res",
")",
"{",
"int",
"sent",
";",
"char",
"*",
"str",
"=",
"response_to_string",
"(",
"res",
")",
";",
"if",
"(",
"(",
"sent",
"=",
"sendto",
"(",
"sockfd",
",",
"str",
",",
"strlen",
"(",
"str",
")",
",",
"0",
",",
"sockaddr",
",",
"sockaddr_len",
")",
")",
"==",
"-1",
")",
"{",
"logs",
"(",
"LOG_ERROR",
",",
"\"",
"\"",
",",
"strerror",
"(",
"errno",
")",
")",
";",
"}",
"logs",
"(",
"LOG_INFO",
",",
"\"",
"\"",
",",
"sent",
",",
"res",
".",
"data",
")",
";",
"return",
"sent",
";",
"}"
] | Send a response to the client. | [
"Send",
"a",
"response",
"to",
"the",
"client",
"."
] | [] | [
{
"param": "sockfd",
"type": "int"
},
{
"param": "sockaddr",
"type": "struct sockaddr"
},
{
"param": "sockaddr_len",
"type": "socklen_t"
},
{
"param": "res",
"type": "response"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sockfd",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sockaddr",
"type": "struct sockaddr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sockaddr_len",
"type": "socklen_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "res",
"type": "response",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ade40cc1cd195f0ab32b27393116050a6f85f532 | gabrieledarrigo/ducky | src/ducky.c | [
"MIT"
] | C | handle_connection | void | void handle_connection(int sockfd, cache *memory) {
char buffer[BUFFER_SIZE] = {0};
struct sockaddr_in client_address;
socklen_t client_address_len = sizeof(client_address);
bzero(&client_address, client_address_len);
int received = receive(sockfd, buffer, BUFFER_SIZE, (struct sockaddr *) &client_address, &client_address_len);
if (received == -1) {
logs(LOG_ERROR, "Error while receiving data: ", strerror(errno));
error_t err = get_error_t(ERR_CANNOT_RECV);
send_response(sockfd, (struct sockaddr *) &client_address, client_address_len, errort_to_response(err));
return;
}
command c;
bzero(&c, sizeof(c));
// Parse the command
int parse_result;
if ((parse_result = parse_command(buffer, &c)) < 0) {
logs(LOG_ERROR, "Error, cannot parse format: %i", parse_result);
error_t err = get_error_t(parse_result);
send_response(sockfd, (struct sockaddr *) &client_address, client_address_len, errort_to_response(err));
return;
}
// Handle GET command
if (c.command_type == GET) {
char *data = get(memory, c.key);
if (data == NULL) {
error_t err = get_error_t(ERR_NOT_FOUND);
send_response(sockfd, (struct sockaddr *) &client_address, client_address_len, errort_to_response(err));
return;
}
response res = {STATUS_SUCCESS, data};
send_response(sockfd, (struct sockaddr *) &client_address, client_address_len, res);
return;
}
// Handle SET command
if (c.command_type == SET) {
set(memory, c.key, c.data);
response res = {STATUS_CREATED, "CREATED"};
send_response(sockfd, (struct sockaddr *) &client_address, client_address_len, res);
return;
}
} | /**
* Handle client connections.
*
* @param sockfd the socket that is used to receive and send data from/to the client
* @param memory Ducky's internal cache
*/ | Handle client connections.
@param sockfd the socket that is used to receive and send data from/to the client
@param memory Ducky's internal cache | [
"Handle",
"client",
"connections",
".",
"@param",
"sockfd",
"the",
"socket",
"that",
"is",
"used",
"to",
"receive",
"and",
"send",
"data",
"from",
"/",
"to",
"the",
"client",
"@param",
"memory",
"Ducky",
"'",
"s",
"internal",
"cache"
] | void handle_connection(int sockfd, cache *memory) {
char buffer[BUFFER_SIZE] = {0};
struct sockaddr_in client_address;
socklen_t client_address_len = sizeof(client_address);
bzero(&client_address, client_address_len);
int received = receive(sockfd, buffer, BUFFER_SIZE, (struct sockaddr *) &client_address, &client_address_len);
if (received == -1) {
logs(LOG_ERROR, "Error while receiving data: ", strerror(errno));
error_t err = get_error_t(ERR_CANNOT_RECV);
send_response(sockfd, (struct sockaddr *) &client_address, client_address_len, errort_to_response(err));
return;
}
command c;
bzero(&c, sizeof(c));
int parse_result;
if ((parse_result = parse_command(buffer, &c)) < 0) {
logs(LOG_ERROR, "Error, cannot parse format: %i", parse_result);
error_t err = get_error_t(parse_result);
send_response(sockfd, (struct sockaddr *) &client_address, client_address_len, errort_to_response(err));
return;
}
if (c.command_type == GET) {
char *data = get(memory, c.key);
if (data == NULL) {
error_t err = get_error_t(ERR_NOT_FOUND);
send_response(sockfd, (struct sockaddr *) &client_address, client_address_len, errort_to_response(err));
return;
}
response res = {STATUS_SUCCESS, data};
send_response(sockfd, (struct sockaddr *) &client_address, client_address_len, res);
return;
}
if (c.command_type == SET) {
set(memory, c.key, c.data);
response res = {STATUS_CREATED, "CREATED"};
send_response(sockfd, (struct sockaddr *) &client_address, client_address_len, res);
return;
}
} | [
"void",
"handle_connection",
"(",
"int",
"sockfd",
",",
"cache",
"*",
"memory",
")",
"{",
"char",
"buffer",
"[",
"BUFFER_SIZE",
"]",
"=",
"{",
"0",
"}",
";",
"struct",
"sockaddr_in",
"client_address",
";",
"socklen_t",
"client_address_len",
"=",
"sizeof",
"(",
"client_address",
")",
";",
"bzero",
"(",
"&",
"client_address",
",",
"client_address_len",
")",
";",
"int",
"received",
"=",
"receive",
"(",
"sockfd",
",",
"buffer",
",",
"BUFFER_SIZE",
",",
"(",
"struct",
"sockaddr",
"*",
")",
"&",
"client_address",
",",
"&",
"client_address_len",
")",
";",
"if",
"(",
"received",
"==",
"-1",
")",
"{",
"logs",
"(",
"LOG_ERROR",
",",
"\"",
"\"",
",",
"strerror",
"(",
"errno",
")",
")",
";",
"error_t",
"err",
"=",
"get_error_t",
"(",
"ERR_CANNOT_RECV",
")",
";",
"send_response",
"(",
"sockfd",
",",
"(",
"struct",
"sockaddr",
"*",
")",
"&",
"client_address",
",",
"client_address_len",
",",
"errort_to_response",
"(",
"err",
")",
")",
";",
"return",
";",
"}",
"command",
"c",
";",
"bzero",
"(",
"&",
"c",
",",
"sizeof",
"(",
"c",
")",
")",
";",
"int",
"parse_result",
";",
"if",
"(",
"(",
"parse_result",
"=",
"parse_command",
"(",
"buffer",
",",
"&",
"c",
")",
")",
"<",
"0",
")",
"{",
"logs",
"(",
"LOG_ERROR",
",",
"\"",
"\"",
",",
"parse_result",
")",
";",
"error_t",
"err",
"=",
"get_error_t",
"(",
"parse_result",
")",
";",
"send_response",
"(",
"sockfd",
",",
"(",
"struct",
"sockaddr",
"*",
")",
"&",
"client_address",
",",
"client_address_len",
",",
"errort_to_response",
"(",
"err",
")",
")",
";",
"return",
";",
"}",
"if",
"(",
"c",
".",
"command_type",
"==",
"GET",
")",
"{",
"char",
"*",
"data",
"=",
"get",
"(",
"memory",
",",
"c",
".",
"key",
")",
";",
"if",
"(",
"data",
"==",
"NULL",
")",
"{",
"error_t",
"err",
"=",
"get_error_t",
"(",
"ERR_NOT_FOUND",
")",
";",
"send_response",
"(",
"sockfd",
",",
"(",
"struct",
"sockaddr",
"*",
")",
"&",
"client_address",
",",
"client_address_len",
",",
"errort_to_response",
"(",
"err",
")",
")",
";",
"return",
";",
"}",
"response",
"res",
"=",
"{",
"STATUS_SUCCESS",
",",
"data",
"}",
";",
"send_response",
"(",
"sockfd",
",",
"(",
"struct",
"sockaddr",
"*",
")",
"&",
"client_address",
",",
"client_address_len",
",",
"res",
")",
";",
"return",
";",
"}",
"if",
"(",
"c",
".",
"command_type",
"==",
"SET",
")",
"{",
"set",
"(",
"memory",
",",
"c",
".",
"key",
",",
"c",
".",
"data",
")",
";",
"response",
"res",
"=",
"{",
"STATUS_CREATED",
",",
"\"",
"\"",
"}",
";",
"send_response",
"(",
"sockfd",
",",
"(",
"struct",
"sockaddr",
"*",
")",
"&",
"client_address",
",",
"client_address_len",
",",
"res",
")",
";",
"return",
";",
"}",
"}"
] | Handle client connections. | [
"Handle",
"client",
"connections",
"."
] | [
"// Parse the command",
"// Handle GET command",
"// Handle SET command"
] | [
{
"param": "sockfd",
"type": "int"
},
{
"param": "memory",
"type": "cache"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sockfd",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "memory",
"type": "cache",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
77e0245af98e9f2e34c229ae484a3e7f21252167 | gabrieledarrigo/ducky | src/command.c | [
"MIT"
] | C | parse_command | int | int parse_command(char *buffer, command *c) {
char *delimiter = " ";
char *token = strtok(buffer, delimiter);
char **arr = calloc(3, sizeof(char *));
// Iterate 3 times (a command is made of a maximum of 3 tokens)
for (int i = 0; i < 3; i++) {
if (token != NULL) {
// if i > 1 the next token that we are parsing is data;
// it should not be split by a white space since data can contains white spaces
char *new_delimiter = i < 1 ? delimiter : "";
if (strlen(token) > MAX_DATA_SIZE) {
return ERR_MAX_DATA_SIZE;
}
token[strcspn(token, "\n")] = '\0'; // Remove trailing new lines
arr[i] = calloc(1, strlen(token) + 1);
strcpy(arr[i], token);
token = strtok(NULL, new_delimiter); // Next token
}
}
if (strcmp(arr[0], "SET") != 0 && strcmp(arr[0], "GET") != 0) {
return ERR_COMMAND_NOT_RECOGNIZED;
}
// Validate the key
if (arr[1] == NULL) {
return ERR_NO_KEY;
}
// Validate key length
if (strlen(arr[1]) > MAX_KEY_LENGTH) {
return ERR_KEY_LENGTH;
}
c->key = arr[1];
// Parse SET command
if (strcmp(arr[0], "SET") == 0) {
// Validate data
if (arr[2] == NULL) {
return ERR_NO_DATA;
}
c->command_type = SET;
c->data = arr[2];
}
// Parse GET command
if (strcmp(arr[0], "GET") == 0) {
c->command_type = GET;
}
return 0;
} | /**
* Try to parse the buffer parameter into a command that can be recognized by Ducky.
* A command is made up of the command name, optional command parameters, and the structured data that clients want to store or retrieve from Ducky.
* For example a GET command is the following:
*
* GET key
*
* While a SET command has this form:
*
* SET key data
*
* If the function is unable to parse the input buffer returns an error code.
*
* @param buffer the string the must be parsed into a valid Ducky command
* @param c the command struct
* @return a parsed command or an error code if the buffer cannot be parsed
*/ | Try to parse the buffer parameter into a command that can be recognized by Ducky.
A command is made up of the command name, optional command parameters, and the structured data that clients want to store or retrieve from Ducky.
For example a GET command is the following.
GET key
While a SET command has this form.
SET key data
If the function is unable to parse the input buffer returns an error code.
@param buffer the string the must be parsed into a valid Ducky command
@param c the command struct
@return a parsed command or an error code if the buffer cannot be parsed | [
"Try",
"to",
"parse",
"the",
"buffer",
"parameter",
"into",
"a",
"command",
"that",
"can",
"be",
"recognized",
"by",
"Ducky",
".",
"A",
"command",
"is",
"made",
"up",
"of",
"the",
"command",
"name",
"optional",
"command",
"parameters",
"and",
"the",
"structured",
"data",
"that",
"clients",
"want",
"to",
"store",
"or",
"retrieve",
"from",
"Ducky",
".",
"For",
"example",
"a",
"GET",
"command",
"is",
"the",
"following",
".",
"GET",
"key",
"While",
"a",
"SET",
"command",
"has",
"this",
"form",
".",
"SET",
"key",
"data",
"If",
"the",
"function",
"is",
"unable",
"to",
"parse",
"the",
"input",
"buffer",
"returns",
"an",
"error",
"code",
".",
"@param",
"buffer",
"the",
"string",
"the",
"must",
"be",
"parsed",
"into",
"a",
"valid",
"Ducky",
"command",
"@param",
"c",
"the",
"command",
"struct",
"@return",
"a",
"parsed",
"command",
"or",
"an",
"error",
"code",
"if",
"the",
"buffer",
"cannot",
"be",
"parsed"
] | int parse_command(char *buffer, command *c) {
char *delimiter = " ";
char *token = strtok(buffer, delimiter);
char **arr = calloc(3, sizeof(char *));
for (int i = 0; i < 3; i++) {
if (token != NULL) {
char *new_delimiter = i < 1 ? delimiter : "";
if (strlen(token) > MAX_DATA_SIZE) {
return ERR_MAX_DATA_SIZE;
}
token[strcspn(token, "\n")] = '\0';
arr[i] = calloc(1, strlen(token) + 1);
strcpy(arr[i], token);
token = strtok(NULL, new_delimiter);
}
}
if (strcmp(arr[0], "SET") != 0 && strcmp(arr[0], "GET") != 0) {
return ERR_COMMAND_NOT_RECOGNIZED;
}
if (arr[1] == NULL) {
return ERR_NO_KEY;
}
if (strlen(arr[1]) > MAX_KEY_LENGTH) {
return ERR_KEY_LENGTH;
}
c->key = arr[1];
if (strcmp(arr[0], "SET") == 0) {
if (arr[2] == NULL) {
return ERR_NO_DATA;
}
c->command_type = SET;
c->data = arr[2];
}
if (strcmp(arr[0], "GET") == 0) {
c->command_type = GET;
}
return 0;
} | [
"int",
"parse_command",
"(",
"char",
"*",
"buffer",
",",
"command",
"*",
"c",
")",
"{",
"char",
"*",
"delimiter",
"=",
"\"",
"\"",
";",
"char",
"*",
"token",
"=",
"strtok",
"(",
"buffer",
",",
"delimiter",
")",
";",
"char",
"*",
"*",
"arr",
"=",
"calloc",
"(",
"3",
",",
"sizeof",
"(",
"char",
"*",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"i",
"++",
")",
"{",
"if",
"(",
"token",
"!=",
"NULL",
")",
"{",
"char",
"*",
"new_delimiter",
"=",
"i",
"<",
"1",
"?",
"delimiter",
":",
"\"",
"\"",
";",
"if",
"(",
"strlen",
"(",
"token",
")",
">",
"MAX_DATA_SIZE",
")",
"{",
"return",
"ERR_MAX_DATA_SIZE",
";",
"}",
"token",
"[",
"strcspn",
"(",
"token",
",",
"\"",
"\\n",
"\"",
")",
"]",
"=",
"'",
"\\0",
"'",
";",
"arr",
"[",
"i",
"]",
"=",
"calloc",
"(",
"1",
",",
"strlen",
"(",
"token",
")",
"+",
"1",
")",
";",
"strcpy",
"(",
"arr",
"[",
"i",
"]",
",",
"token",
")",
";",
"token",
"=",
"strtok",
"(",
"NULL",
",",
"new_delimiter",
")",
";",
"}",
"}",
"if",
"(",
"strcmp",
"(",
"arr",
"[",
"0",
"]",
",",
"\"",
"\"",
")",
"!=",
"0",
"&&",
"strcmp",
"(",
"arr",
"[",
"0",
"]",
",",
"\"",
"\"",
")",
"!=",
"0",
")",
"{",
"return",
"ERR_COMMAND_NOT_RECOGNIZED",
";",
"}",
"if",
"(",
"arr",
"[",
"1",
"]",
"==",
"NULL",
")",
"{",
"return",
"ERR_NO_KEY",
";",
"}",
"if",
"(",
"strlen",
"(",
"arr",
"[",
"1",
"]",
")",
">",
"MAX_KEY_LENGTH",
")",
"{",
"return",
"ERR_KEY_LENGTH",
";",
"}",
"c",
"->",
"key",
"=",
"arr",
"[",
"1",
"]",
";",
"if",
"(",
"strcmp",
"(",
"arr",
"[",
"0",
"]",
",",
"\"",
"\"",
")",
"==",
"0",
")",
"{",
"if",
"(",
"arr",
"[",
"2",
"]",
"==",
"NULL",
")",
"{",
"return",
"ERR_NO_DATA",
";",
"}",
"c",
"->",
"command_type",
"=",
"SET",
";",
"c",
"->",
"data",
"=",
"arr",
"[",
"2",
"]",
";",
"}",
"if",
"(",
"strcmp",
"(",
"arr",
"[",
"0",
"]",
",",
"\"",
"\"",
")",
"==",
"0",
")",
"{",
"c",
"->",
"command_type",
"=",
"GET",
";",
"}",
"return",
"0",
";",
"}"
] | Try to parse the buffer parameter into a command that can be recognized by Ducky. | [
"Try",
"to",
"parse",
"the",
"buffer",
"parameter",
"into",
"a",
"command",
"that",
"can",
"be",
"recognized",
"by",
"Ducky",
"."
] | [
"// Iterate 3 times (a command is made of a maximum of 3 tokens)\r",
"// if i > 1 the next token that we are parsing is data;\r",
"// it should not be split by a white space since data can contains white spaces\r",
"// Remove trailing new lines\r",
"// Next token\r",
"// Validate the key\r",
"// Validate key length\r",
"// Parse SET command\r",
"// Validate data\r",
"// Parse GET command\r"
] | [
{
"param": "buffer",
"type": "char"
},
{
"param": "c",
"type": "command"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "buffer",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "c",
"type": "command",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1bd47ce55dd1130ebb7d466aa77838bfe4bb0373 | gabrieledarrigo/ducky | src/logger.c | [
"MIT"
] | C | logs | void | void logs(log_level level, const char *fmt, ...) {
char buffer[100];
time_t t = time(NULL);
size_t len = strftime(buffer, sizeof(buffer), "%H:%M:%S", localtime(&t));
buffer[len] = '\0';
va_list ap;
va_start(ap, fmt);
fprintf(stderr, "%s %-5s ", buffer, log_levels[level]);
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
fflush(stderr);
va_end(ap);
} | /**
* A variadic function that logs to stderr.
*
* @param level the desired log level
* @param fmt a C string that contains the text to be written to stderr. It can optionally contain embedded format specifiers
* @param ...
*/ | A variadic function that logs to stderr.
@param level the desired log level
@param fmt a C string that contains the text to be written to stderr. It can optionally contain embedded format specifiers
@param | [
"A",
"variadic",
"function",
"that",
"logs",
"to",
"stderr",
".",
"@param",
"level",
"the",
"desired",
"log",
"level",
"@param",
"fmt",
"a",
"C",
"string",
"that",
"contains",
"the",
"text",
"to",
"be",
"written",
"to",
"stderr",
".",
"It",
"can",
"optionally",
"contain",
"embedded",
"format",
"specifiers",
"@param"
] | void logs(log_level level, const char *fmt, ...) {
char buffer[100];
time_t t = time(NULL);
size_t len = strftime(buffer, sizeof(buffer), "%H:%M:%S", localtime(&t));
buffer[len] = '\0';
va_list ap;
va_start(ap, fmt);
fprintf(stderr, "%s %-5s ", buffer, log_levels[level]);
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
fflush(stderr);
va_end(ap);
} | [
"void",
"logs",
"(",
"log_level",
"level",
",",
"const",
"char",
"*",
"fmt",
",",
"...",
")",
"{",
"char",
"buffer",
"[",
"100",
"]",
";",
"time_t",
"t",
"=",
"time",
"(",
"NULL",
")",
";",
"size_t",
"len",
"=",
"strftime",
"(",
"buffer",
",",
"sizeof",
"(",
"buffer",
")",
",",
"\"",
"\"",
",",
"localtime",
"(",
"&",
"t",
")",
")",
";",
"buffer",
"[",
"len",
"]",
"=",
"'",
"\\0",
"'",
";",
"va_list",
"ap",
";",
"va_start",
"(",
"ap",
",",
"fmt",
")",
";",
"fprintf",
"(",
"stderr",
",",
"\"",
"\"",
",",
"buffer",
",",
"log_levels",
"[",
"level",
"]",
")",
";",
"vfprintf",
"(",
"stderr",
",",
"fmt",
",",
"ap",
")",
";",
"fprintf",
"(",
"stderr",
",",
"\"",
"\\n",
"\"",
")",
";",
"fflush",
"(",
"stderr",
")",
";",
"va_end",
"(",
"ap",
")",
";",
"}"
] | A variadic function that logs to stderr. | [
"A",
"variadic",
"function",
"that",
"logs",
"to",
"stderr",
"."
] | [] | [
{
"param": "level",
"type": "log_level"
},
{
"param": "fmt",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "level",
"type": "log_level",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "fmt",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fc1b0f8465f5143d6fa876621fea593fd9dd41a6 | gabrieledarrigo/ducky | src/prime.c | [
"MIT"
] | C | is_prime | int | int is_prime(int n) {
if (n <= 1) {
return 0;
}
if (n == 2) {
return 1;
}
if (n % 2 == 0) {
return 0;
}
for (int i = 2; i < n; i++) {
if ((n % i) == 0) {
return 0;
}
}
return 1;
} | /**
* Check if the integer n is a prime number.
*
* @param n the number to check
* @return 1 if n is a prime number, 0 otherwise
*/ | Check if the integer n is a prime number.
@param n the number to check
@return 1 if n is a prime number, 0 otherwise | [
"Check",
"if",
"the",
"integer",
"n",
"is",
"a",
"prime",
"number",
".",
"@param",
"n",
"the",
"number",
"to",
"check",
"@return",
"1",
"if",
"n",
"is",
"a",
"prime",
"number",
"0",
"otherwise"
] | int is_prime(int n) {
if (n <= 1) {
return 0;
}
if (n == 2) {
return 1;
}
if (n % 2 == 0) {
return 0;
}
for (int i = 2; i < n; i++) {
if ((n % i) == 0) {
return 0;
}
}
return 1;
} | [
"int",
"is_prime",
"(",
"int",
"n",
")",
"{",
"if",
"(",
"n",
"<=",
"1",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"n",
"==",
"2",
")",
"{",
"return",
"1",
";",
"}",
"if",
"(",
"n",
"%",
"2",
"==",
"0",
")",
"{",
"return",
"0",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"2",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"if",
"(",
"(",
"n",
"%",
"i",
")",
"==",
"0",
")",
"{",
"return",
"0",
";",
"}",
"}",
"return",
"1",
";",
"}"
] | Check if the integer n is a prime number. | [
"Check",
"if",
"the",
"integer",
"n",
"is",
"a",
"prime",
"number",
"."
] | [] | [
{
"param": "n",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "n",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fc1b0f8465f5143d6fa876621fea593fd9dd41a6 | gabrieledarrigo/ducky | src/prime.c | [
"MIT"
] | C | next_prime | int | int next_prime(int n) {
while (is_prime(n) != 1) {
n++;
}
return n;
} | /**
* Compute the next prime number after n.
*
* @param n the integer from which the search for the next prime number starts
* @return the next prime after n
*/ | Compute the next prime number after n.
@param n the integer from which the search for the next prime number starts
@return the next prime after n | [
"Compute",
"the",
"next",
"prime",
"number",
"after",
"n",
".",
"@param",
"n",
"the",
"integer",
"from",
"which",
"the",
"search",
"for",
"the",
"next",
"prime",
"number",
"starts",
"@return",
"the",
"next",
"prime",
"after",
"n"
] | int next_prime(int n) {
while (is_prime(n) != 1) {
n++;
}
return n;
} | [
"int",
"next_prime",
"(",
"int",
"n",
")",
"{",
"while",
"(",
"is_prime",
"(",
"n",
")",
"!=",
"1",
")",
"{",
"n",
"++",
";",
"}",
"return",
"n",
";",
"}"
] | Compute the next prime number after n. | [
"Compute",
"the",
"next",
"prime",
"number",
"after",
"n",
"."
] | [] | [
{
"param": "n",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "n",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b2f894781a10897d8c2d6f68dd0d86e7b4391b56 | gabrieledarrigo/ducky | src/response.c | [
"MIT"
] | C | response_to_string | char | char *response_to_string(response res) {
// Allocate the len of data + 3 for the status code + 1 white space + 1 \n + 1 for the null terminator
size_t to_allocate = (strlen(res.data) + 6) * sizeof(char);
char *buffer = malloc(to_allocate);
if (buffer == NULL) {
logs(LOG_ERROR, "Cannot allocate for string response: ", strerror(errno));
}
snprintf(buffer, to_allocate, "%i %s\n", res.status_code, res.data);
return buffer;
} | /**
* Convert a response struct into a C string of the following shape:
*
* STATUS_CODE DATA \n
*
* @param res the response struct that must be converted
* @return a C string with representing the response
*/ | Convert a response struct into a C string of the following shape.
@param res the response struct that must be converted
@return a C string with representing the response | [
"Convert",
"a",
"response",
"struct",
"into",
"a",
"C",
"string",
"of",
"the",
"following",
"shape",
".",
"@param",
"res",
"the",
"response",
"struct",
"that",
"must",
"be",
"converted",
"@return",
"a",
"C",
"string",
"with",
"representing",
"the",
"response"
] | char *response_to_string(response res) {
size_t to_allocate = (strlen(res.data) + 6) * sizeof(char);
char *buffer = malloc(to_allocate);
if (buffer == NULL) {
logs(LOG_ERROR, "Cannot allocate for string response: ", strerror(errno));
}
snprintf(buffer, to_allocate, "%i %s\n", res.status_code, res.data);
return buffer;
} | [
"char",
"*",
"response_to_string",
"(",
"response",
"res",
")",
"{",
"size_t",
"to_allocate",
"=",
"(",
"strlen",
"(",
"res",
".",
"data",
")",
"+",
"6",
")",
"*",
"sizeof",
"(",
"char",
")",
";",
"char",
"*",
"buffer",
"=",
"malloc",
"(",
"to_allocate",
")",
";",
"if",
"(",
"buffer",
"==",
"NULL",
")",
"{",
"logs",
"(",
"LOG_ERROR",
",",
"\"",
"\"",
",",
"strerror",
"(",
"errno",
")",
")",
";",
"}",
"snprintf",
"(",
"buffer",
",",
"to_allocate",
",",
"\"",
"\\n",
"\"",
",",
"res",
".",
"status_code",
",",
"res",
".",
"data",
")",
";",
"return",
"buffer",
";",
"}"
] | Convert a response struct into a C string of the following shape: | [
"Convert",
"a",
"response",
"struct",
"into",
"a",
"C",
"string",
"of",
"the",
"following",
"shape",
":"
] | [
"// Allocate the len of data + 3 for the status code + 1 white space + 1 \\n + 1 for the null terminator\r"
] | [
{
"param": "res",
"type": "response"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "res",
"type": "response",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b2f894781a10897d8c2d6f68dd0d86e7b4391b56 | gabrieledarrigo/ducky | src/response.c | [
"MIT"
] | C | errort_to_response | response | response errort_to_response(error_t error) {
response res;
switch (error.code) {
case ERR_UNKNOWN:
res.status_code = STATUS_ERR_UNKNOWN;
break;
case ERR_CANNOT_RECV:
res.status_code = STATUS_ERR_CANNOT_RECV;
break;
case ERR_CANNOT_SEND:
res.status_code = STATUS_ERR_CANNOT_SEND;
break;
case ERR_COMMAND_NOT_RECOGNIZED:
res.status_code = STATUS_ERR_COMMAND_NOT_RECOGNIZED;
break;
case ERR_MAX_DATA_SIZE:
res.status_code = STATUS_ERR_MAX_DATA_SIZE;
break;
case ERR_KEY_LENGTH:
res.status_code = STATUS_ERR_KEY_LENGTH;
break;
case ERR_NO_KEY:
res.status_code = STATUS_ERR_NO_KEY;
break;
case ERR_NO_DATA:
res.status_code = STATUS_ERR_NO_DATA;
break;
case ERR_NOT_FOUND:
res.status_code = STATUS_ERR_NOT_FOUND;
break;
default:
res.status_code = STATUS_ERR_UNKNOWN;
}
res.data = error.message;
return res;
} | /**
* Convert an error_t struct into a response
*
* @param error the error that must be converted
* @return a response struct
*/ | Convert an error_t struct into a response
@param error the error that must be converted
@return a response struct | [
"Convert",
"an",
"error_t",
"struct",
"into",
"a",
"response",
"@param",
"error",
"the",
"error",
"that",
"must",
"be",
"converted",
"@return",
"a",
"response",
"struct"
] | response errort_to_response(error_t error) {
response res;
switch (error.code) {
case ERR_UNKNOWN:
res.status_code = STATUS_ERR_UNKNOWN;
break;
case ERR_CANNOT_RECV:
res.status_code = STATUS_ERR_CANNOT_RECV;
break;
case ERR_CANNOT_SEND:
res.status_code = STATUS_ERR_CANNOT_SEND;
break;
case ERR_COMMAND_NOT_RECOGNIZED:
res.status_code = STATUS_ERR_COMMAND_NOT_RECOGNIZED;
break;
case ERR_MAX_DATA_SIZE:
res.status_code = STATUS_ERR_MAX_DATA_SIZE;
break;
case ERR_KEY_LENGTH:
res.status_code = STATUS_ERR_KEY_LENGTH;
break;
case ERR_NO_KEY:
res.status_code = STATUS_ERR_NO_KEY;
break;
case ERR_NO_DATA:
res.status_code = STATUS_ERR_NO_DATA;
break;
case ERR_NOT_FOUND:
res.status_code = STATUS_ERR_NOT_FOUND;
break;
default:
res.status_code = STATUS_ERR_UNKNOWN;
}
res.data = error.message;
return res;
} | [
"response",
"errort_to_response",
"(",
"error_t",
"error",
")",
"{",
"response",
"res",
";",
"switch",
"(",
"error",
".",
"code",
")",
"{",
"case",
"ERR_UNKNOWN",
":",
"res",
".",
"status_code",
"=",
"STATUS_ERR_UNKNOWN",
";",
"break",
";",
"case",
"ERR_CANNOT_RECV",
":",
"res",
".",
"status_code",
"=",
"STATUS_ERR_CANNOT_RECV",
";",
"break",
";",
"case",
"ERR_CANNOT_SEND",
":",
"res",
".",
"status_code",
"=",
"STATUS_ERR_CANNOT_SEND",
";",
"break",
";",
"case",
"ERR_COMMAND_NOT_RECOGNIZED",
":",
"res",
".",
"status_code",
"=",
"STATUS_ERR_COMMAND_NOT_RECOGNIZED",
";",
"break",
";",
"case",
"ERR_MAX_DATA_SIZE",
":",
"res",
".",
"status_code",
"=",
"STATUS_ERR_MAX_DATA_SIZE",
";",
"break",
";",
"case",
"ERR_KEY_LENGTH",
":",
"res",
".",
"status_code",
"=",
"STATUS_ERR_KEY_LENGTH",
";",
"break",
";",
"case",
"ERR_NO_KEY",
":",
"res",
".",
"status_code",
"=",
"STATUS_ERR_NO_KEY",
";",
"break",
";",
"case",
"ERR_NO_DATA",
":",
"res",
".",
"status_code",
"=",
"STATUS_ERR_NO_DATA",
";",
"break",
";",
"case",
"ERR_NOT_FOUND",
":",
"res",
".",
"status_code",
"=",
"STATUS_ERR_NOT_FOUND",
";",
"break",
";",
"default",
":",
"res",
".",
"status_code",
"=",
"STATUS_ERR_UNKNOWN",
";",
"}",
"res",
".",
"data",
"=",
"error",
".",
"message",
";",
"return",
"res",
";",
"}"
] | Convert an error_t struct into a response | [
"Convert",
"an",
"error_t",
"struct",
"into",
"a",
"response"
] | [] | [
{
"param": "error",
"type": "error_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "error",
"type": "error_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7ca002040a19978790eb3d3dc3c33685a7cffe56 | Jackistang/mysh | command.c | [
"MIT"
] | C | restore_sigint_in_child | void | void restore_sigint_in_child()
{
if (signalset)
signal(SIGINT, SIGINT_handler);
} | // restore Ctrl-C signal in the child process | restore Ctrl-C signal in the child process | [
"restore",
"Ctrl",
"-",
"C",
"signal",
"in",
"the",
"child",
"process"
] | void restore_sigint_in_child()
{
if (signalset)
signal(SIGINT, SIGINT_handler);
} | [
"void",
"restore_sigint_in_child",
"(",
")",
"{",
"if",
"(",
"signalset",
")",
"signal",
"(",
"SIGINT",
",",
"SIGINT_handler",
")",
";",
"}"
] | restore Ctrl-C signal in the child process | [
"restore",
"Ctrl",
"-",
"C",
"signal",
"in",
"the",
"child",
"process"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
1e67a013904e282a8ec89be96d15630c8e2c4eea | gpauusa/madn | src/madn_routing.c | [
"Apache-2.0"
] | C | service_thread | void | void service_thread(MADN_INSTANCE *env)
{
//printf("s");
// Refer 6.12
// Remove entry from service queue
// Encode a data packet, if same packet already sent, re-encode
// Put it in the output queue
// Decrease packet count from the corresponding req table entry
// If 0, remove entry from req table and also from service queue
// Push entry back into queue if req table count not 0
uint32_t count = 0;
while (!is_empty_sq(env) && count < env->globals->MAX_DATA_PKT_SERVE)
{
MADN_DATAID* id = remove_entry_sq(env);
assert(id != NULL);
REQUEST_ENTRY* entry = check_entry_rt(env, *id);
if (entry == NULL)
{
free_dataid(&id);
continue;
}
MADN_PKT_DATA* pkt = create_data_pkt();
set_packet_node((MADN_PTR) pkt, env->globals->NODE_ID);
copy_dataid(&pkt->id, id);
pthread_mutex_lock(&env->bloomLock);
copy_bloom(&pkt->bloom, &env->bloom);
pthread_mutex_unlock(&env->bloomLock);
entry->counter--;
if (entry->counter == 0)
{
remove_entry_rt(env, *id);
}
else
{
add_entry_sq(env, *id);
free_dataid(&id);
}
time(&entry->lfwrd); //TODO: here?
//this automatically checks if the encoded packet was already sent
encode_packet(env, pkt);
//XXX: Potential race condition, if the decoded packets get evicted from cache
addToOutputQueue(env, (MADN_PTR*) pkt, sizeof(MADN_PKT_DATA));
count++;
}
} | /** ACTIVE THREADS */
//These are only the procedures inside the threads.
//Thread API specific code will call these functions to do the actual processing | ACTIVE THREADS
These are only the procedures inside the threads.
Thread API specific code will call these functions to do the actual processing | [
"ACTIVE",
"THREADS",
"These",
"are",
"only",
"the",
"procedures",
"inside",
"the",
"threads",
".",
"Thread",
"API",
"specific",
"code",
"will",
"call",
"these",
"functions",
"to",
"do",
"the",
"actual",
"processing"
] | void service_thread(MADN_INSTANCE *env)
{
uint32_t count = 0;
while (!is_empty_sq(env) && count < env->globals->MAX_DATA_PKT_SERVE)
{
MADN_DATAID* id = remove_entry_sq(env);
assert(id != NULL);
REQUEST_ENTRY* entry = check_entry_rt(env, *id);
if (entry == NULL)
{
free_dataid(&id);
continue;
}
MADN_PKT_DATA* pkt = create_data_pkt();
set_packet_node((MADN_PTR) pkt, env->globals->NODE_ID);
copy_dataid(&pkt->id, id);
pthread_mutex_lock(&env->bloomLock);
copy_bloom(&pkt->bloom, &env->bloom);
pthread_mutex_unlock(&env->bloomLock);
entry->counter--;
if (entry->counter == 0)
{
remove_entry_rt(env, *id);
}
else
{
add_entry_sq(env, *id);
free_dataid(&id);
}
time(&entry->lfwrd);
encode_packet(env, pkt);
addToOutputQueue(env, (MADN_PTR*) pkt, sizeof(MADN_PKT_DATA));
count++;
}
} | [
"void",
"service_thread",
"(",
"MADN_INSTANCE",
"*",
"env",
")",
"{",
"uint32_t",
"count",
"=",
"0",
";",
"while",
"(",
"!",
"is_empty_sq",
"(",
"env",
")",
"&&",
"count",
"<",
"env",
"->",
"globals",
"->",
"MAX_DATA_PKT_SERVE",
")",
"{",
"MADN_DATAID",
"*",
"id",
"=",
"remove_entry_sq",
"(",
"env",
")",
";",
"assert",
"(",
"id",
"!=",
"NULL",
")",
";",
"REQUEST_ENTRY",
"*",
"entry",
"=",
"check_entry_rt",
"(",
"env",
",",
"*",
"id",
")",
";",
"if",
"(",
"entry",
"==",
"NULL",
")",
"{",
"free_dataid",
"(",
"&",
"id",
")",
";",
"continue",
";",
"}",
"MADN_PKT_DATA",
"*",
"pkt",
"=",
"create_data_pkt",
"(",
")",
";",
"set_packet_node",
"(",
"(",
"MADN_PTR",
")",
"pkt",
",",
"env",
"->",
"globals",
"->",
"NODE_ID",
")",
";",
"copy_dataid",
"(",
"&",
"pkt",
"->",
"id",
",",
"id",
")",
";",
"pthread_mutex_lock",
"(",
"&",
"env",
"->",
"bloomLock",
")",
";",
"copy_bloom",
"(",
"&",
"pkt",
"->",
"bloom",
",",
"&",
"env",
"->",
"bloom",
")",
";",
"pthread_mutex_unlock",
"(",
"&",
"env",
"->",
"bloomLock",
")",
";",
"entry",
"->",
"counter",
"--",
";",
"if",
"(",
"entry",
"->",
"counter",
"==",
"0",
")",
"{",
"remove_entry_rt",
"(",
"env",
",",
"*",
"id",
")",
";",
"}",
"else",
"{",
"add_entry_sq",
"(",
"env",
",",
"*",
"id",
")",
";",
"free_dataid",
"(",
"&",
"id",
")",
";",
"}",
"time",
"(",
"&",
"entry",
"->",
"lfwrd",
")",
";",
"encode_packet",
"(",
"env",
",",
"pkt",
")",
";",
"addToOutputQueue",
"(",
"env",
",",
"(",
"MADN_PTR",
"*",
")",
"pkt",
",",
"sizeof",
"(",
"MADN_PKT_DATA",
")",
")",
";",
"count",
"++",
";",
"}",
"}"
] | ACTIVE THREADS
These are only the procedures inside the threads. | [
"ACTIVE",
"THREADS",
"These",
"are",
"only",
"the",
"procedures",
"inside",
"the",
"threads",
"."
] | [
"//printf(\"s\");",
"// Refer 6.12",
"// Remove entry from service queue",
"// Encode a data packet, if same packet already sent, re-encode",
"// Put it in the output queue",
"// Decrease packet count from the corresponding req table entry",
"// If 0, remove entry from req table and also from service queue",
"// Push entry back into queue if req table count not 0",
"//TODO: here?",
"//this automatically checks if the encoded packet was already sent",
"//XXX: Potential race condition, if the decoded packets get evicted from cache"
] | [
{
"param": "env",
"type": "MADN_INSTANCE"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "env",
"type": "MADN_INSTANCE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
90119027944d11d962dc48b807feab18b5224da0 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/c-family/c-opts.c | [
"BSD-3-Clause"
] | C | defer_opt | void | static void
defer_opt (enum opt_code code, const char *arg)
{
deferred_opts[deferred_count].code = code;
deferred_opts[deferred_count].arg = arg;
deferred_count++;
} | /* Defer option CODE with argument ARG. */ | Defer option CODE with argument ARG. | [
"Defer",
"option",
"CODE",
"with",
"argument",
"ARG",
"."
] | static void
defer_opt (enum opt_code code, const char *arg)
{
deferred_opts[deferred_count].code = code;
deferred_opts[deferred_count].arg = arg;
deferred_count++;
} | [
"static",
"void",
"defer_opt",
"(",
"enum",
"opt_code",
"code",
",",
"const",
"char",
"*",
"arg",
")",
"{",
"deferred_opts",
"[",
"deferred_count",
"]",
".",
"code",
"=",
"code",
";",
"deferred_opts",
"[",
"deferred_count",
"]",
".",
"arg",
"=",
"arg",
";",
"deferred_count",
"++",
";",
"}"
] | Defer option CODE with argument ARG. | [
"Defer",
"option",
"CODE",
"with",
"argument",
"ARG",
"."
] | [] | [
{
"param": "code",
"type": "enum opt_code"
},
{
"param": "arg",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "code",
"type": "enum opt_code",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "arg",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
90119027944d11d962dc48b807feab18b5224da0 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/c-family/c-opts.c | [
"BSD-3-Clause"
] | C | c_common_option_lang_mask | null | unsigned int
c_common_option_lang_mask (void)
{
static const unsigned int lang_flags[] = {CL_C, CL_ObjC, CL_CXX, CL_ObjCXX};
return lang_flags[c_language];
} | /* Return language mask for option parsing. */ | Return language mask for option parsing. | [
"Return",
"language",
"mask",
"for",
"option",
"parsing",
"."
] | unsigned int
c_common_option_lang_mask (void)
{
static const unsigned int lang_flags[] = {CL_C, CL_ObjC, CL_CXX, CL_ObjCXX};
return lang_flags[c_language];
} | [
"unsigned",
"int",
"c_common_option_lang_mask",
"(",
"void",
")",
"{",
"static",
"const",
"unsigned",
"int",
"lang_flags",
"[",
"]",
"=",
"{",
"CL_C",
",",
"CL_ObjC",
",",
"CL_CXX",
",",
"CL_ObjCXX",
"}",
";",
"return",
"lang_flags",
"[",
"c_language",
"]",
";",
"}"
] | Return language mask for option parsing. | [
"Return",
"language",
"mask",
"for",
"option",
"parsing",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
90119027944d11d962dc48b807feab18b5224da0 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/c-family/c-opts.c | [
"BSD-3-Clause"
] | C | c_common_diagnostics_set_defaults | void | void
c_common_diagnostics_set_defaults (diagnostic_context *context)
{
diagnostic_finalizer (context) = c_diagnostic_finalizer;
context->opt_permissive = OPT_fpermissive;
} | /* Common default settings for diagnostics. */ | Common default settings for diagnostics. | [
"Common",
"default",
"settings",
"for",
"diagnostics",
"."
] | void
c_common_diagnostics_set_defaults (diagnostic_context *context)
{
diagnostic_finalizer (context) = c_diagnostic_finalizer;
context->opt_permissive = OPT_fpermissive;
} | [
"void",
"c_common_diagnostics_set_defaults",
"(",
"diagnostic_context",
"*",
"context",
")",
"{",
"diagnostic_finalizer",
"(",
"context",
")",
"=",
"c_diagnostic_finalizer",
";",
"context",
"->",
"opt_permissive",
"=",
"OPT_fpermissive",
";",
"}"
] | Common default settings for diagnostics. | [
"Common",
"default",
"settings",
"for",
"diagnostics",
"."
] | [] | [
{
"param": "context",
"type": "diagnostic_context"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "context",
"type": "diagnostic_context",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
90119027944d11d962dc48b807feab18b5224da0 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/c-family/c-opts.c | [
"BSD-3-Clause"
] | C | c_common_complain_wrong_lang_p | bool | bool
c_common_complain_wrong_lang_p (const struct cl_option *option)
{
if (accept_all_c_family_options
&& (option->flags & c_family_lang_mask))
return false;
return true;
} | /* Return whether to complain about a wrong-language option. */ | Return whether to complain about a wrong-language option. | [
"Return",
"whether",
"to",
"complain",
"about",
"a",
"wrong",
"-",
"language",
"option",
"."
] | bool
c_common_complain_wrong_lang_p (const struct cl_option *option)
{
if (accept_all_c_family_options
&& (option->flags & c_family_lang_mask))
return false;
return true;
} | [
"bool",
"c_common_complain_wrong_lang_p",
"(",
"const",
"struct",
"cl_option",
"*",
"option",
")",
"{",
"if",
"(",
"accept_all_c_family_options",
"&&",
"(",
"option",
"->",
"flags",
"&",
"c_family_lang_mask",
")",
")",
"return",
"false",
";",
"return",
"true",
";",
"}"
] | Return whether to complain about a wrong-language option. | [
"Return",
"whether",
"to",
"complain",
"about",
"a",
"wrong",
"-",
"language",
"option",
"."
] | [] | [
{
"param": "option",
"type": "struct cl_option"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "option",
"type": "struct cl_option",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
90119027944d11d962dc48b807feab18b5224da0 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/c-family/c-opts.c | [
"BSD-3-Clause"
] | C | c_common_init | bool | bool
c_common_init (void)
{
/* Set up preprocessor arithmetic. Must be done after call to
c_common_nodes_and_builtins for type nodes to be good. */
cpp_opts->precision = TYPE_PRECISION (intmax_type_node);
cpp_opts->char_precision = TYPE_PRECISION (char_type_node);
cpp_opts->int_precision = TYPE_PRECISION (integer_type_node);
cpp_opts->wchar_precision = TYPE_PRECISION (wchar_type_node);
cpp_opts->unsigned_wchar = TYPE_UNSIGNED (wchar_type_node);
cpp_opts->bytes_big_endian = BYTES_BIG_ENDIAN;
/* This can't happen until after wchar_precision and bytes_big_endian
are known. */
cpp_init_iconv (parse_in);
if (version_flag)
{
int i;
fputs ("Compiler executable checksum: ", stderr);
for (i = 0; i < 16; i++)
fprintf (stderr, "%02x", executable_checksum[i]);
putc ('\n', stderr);
}
/* Has to wait until now so that cpplib has its hash table. */
init_pragma ();
if (flag_preprocess_only)
{
c_finish_options ();
preprocess_file (parse_in);
return false;
}
return true;
} | /* Front end initialization common to C, ObjC and C++. */ | Front end initialization common to C, ObjC and C++. | [
"Front",
"end",
"initialization",
"common",
"to",
"C",
"ObjC",
"and",
"C",
"++",
"."
] | bool
c_common_init (void)
{
cpp_opts->precision = TYPE_PRECISION (intmax_type_node);
cpp_opts->char_precision = TYPE_PRECISION (char_type_node);
cpp_opts->int_precision = TYPE_PRECISION (integer_type_node);
cpp_opts->wchar_precision = TYPE_PRECISION (wchar_type_node);
cpp_opts->unsigned_wchar = TYPE_UNSIGNED (wchar_type_node);
cpp_opts->bytes_big_endian = BYTES_BIG_ENDIAN;
cpp_init_iconv (parse_in);
if (version_flag)
{
int i;
fputs ("Compiler executable checksum: ", stderr);
for (i = 0; i < 16; i++)
fprintf (stderr, "%02x", executable_checksum[i]);
putc ('\n', stderr);
}
init_pragma ();
if (flag_preprocess_only)
{
c_finish_options ();
preprocess_file (parse_in);
return false;
}
return true;
} | [
"bool",
"c_common_init",
"(",
"void",
")",
"{",
"cpp_opts",
"->",
"precision",
"=",
"TYPE_PRECISION",
"(",
"intmax_type_node",
")",
";",
"cpp_opts",
"->",
"char_precision",
"=",
"TYPE_PRECISION",
"(",
"char_type_node",
")",
";",
"cpp_opts",
"->",
"int_precision",
"=",
"TYPE_PRECISION",
"(",
"integer_type_node",
")",
";",
"cpp_opts",
"->",
"wchar_precision",
"=",
"TYPE_PRECISION",
"(",
"wchar_type_node",
")",
";",
"cpp_opts",
"->",
"unsigned_wchar",
"=",
"TYPE_UNSIGNED",
"(",
"wchar_type_node",
")",
";",
"cpp_opts",
"->",
"bytes_big_endian",
"=",
"BYTES_BIG_ENDIAN",
";",
"cpp_init_iconv",
"(",
"parse_in",
")",
";",
"if",
"(",
"version_flag",
")",
"{",
"int",
"i",
";",
"fputs",
"(",
"\"",
"\"",
",",
"stderr",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"16",
";",
"i",
"++",
")",
"fprintf",
"(",
"stderr",
",",
"\"",
"\"",
",",
"executable_checksum",
"[",
"i",
"]",
")",
";",
"putc",
"(",
"'",
"\\n",
"'",
",",
"stderr",
")",
";",
"}",
"init_pragma",
"(",
")",
";",
"if",
"(",
"flag_preprocess_only",
")",
"{",
"c_finish_options",
"(",
")",
";",
"preprocess_file",
"(",
"parse_in",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Front end initialization common to C, ObjC and C++. | [
"Front",
"end",
"initialization",
"common",
"to",
"C",
"ObjC",
"and",
"C",
"++",
"."
] | [
"/* Set up preprocessor arithmetic. Must be done after call to\n c_common_nodes_and_builtins for type nodes to be good. */",
"/* This can't happen until after wchar_precision and bytes_big_endian\n are known. */",
"/* Has to wait until now so that cpplib has its hash table. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
90119027944d11d962dc48b807feab18b5224da0 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/c-family/c-opts.c | [
"BSD-3-Clause"
] | C | c_common_parse_file | void | void
c_common_parse_file (void)
{
unsigned int i;
i = 0;
for (;;)
{
c_finish_options ();
/* Open the dump file to use for the original dump output
here, to be used during parsing for the current file. */
original_dump_file = dump_begin (TDI_original, &original_dump_flags);
pch_init ();
push_file_scope ();
c_parse_file ();
pop_file_scope ();
/* And end the main input file, if the debug writer wants it */
if (debug_hooks->start_end_main_source_file)
(*debug_hooks->end_source_file) (0);
if (++i >= num_in_fnames)
break;
cpp_undef_all (parse_in);
cpp_clear_file_cache (parse_in);
this_input_filename
= cpp_read_main_file (parse_in, in_fnames[i]);
if (original_dump_file)
{
dump_end (TDI_original, original_dump_file);
original_dump_file = NULL;
}
/* If an input file is missing, abandon further compilation.
cpplib has issued a diagnostic. */
if (!this_input_filename)
break;
}
c_parse_final_cleanups ();
} | /* Initialize the integrated preprocessor after debug output has been
initialized; loop over each input file. */ | Initialize the integrated preprocessor after debug output has been
initialized; loop over each input file. | [
"Initialize",
"the",
"integrated",
"preprocessor",
"after",
"debug",
"output",
"has",
"been",
"initialized",
";",
"loop",
"over",
"each",
"input",
"file",
"."
] | void
c_common_parse_file (void)
{
unsigned int i;
i = 0;
for (;;)
{
c_finish_options ();
original_dump_file = dump_begin (TDI_original, &original_dump_flags);
pch_init ();
push_file_scope ();
c_parse_file ();
pop_file_scope ();
if (debug_hooks->start_end_main_source_file)
(*debug_hooks->end_source_file) (0);
if (++i >= num_in_fnames)
break;
cpp_undef_all (parse_in);
cpp_clear_file_cache (parse_in);
this_input_filename
= cpp_read_main_file (parse_in, in_fnames[i]);
if (original_dump_file)
{
dump_end (TDI_original, original_dump_file);
original_dump_file = NULL;
}
if (!this_input_filename)
break;
}
c_parse_final_cleanups ();
} | [
"void",
"c_common_parse_file",
"(",
"void",
")",
"{",
"unsigned",
"int",
"i",
";",
"i",
"=",
"0",
";",
"for",
"(",
";",
";",
")",
"{",
"c_finish_options",
"(",
")",
";",
"original_dump_file",
"=",
"dump_begin",
"(",
"TDI_original",
",",
"&",
"original_dump_flags",
")",
";",
"pch_init",
"(",
")",
";",
"push_file_scope",
"(",
")",
";",
"c_parse_file",
"(",
")",
";",
"pop_file_scope",
"(",
")",
";",
"if",
"(",
"debug_hooks",
"->",
"start_end_main_source_file",
")",
"(",
"*",
"debug_hooks",
"->",
"end_source_file",
")",
"(",
"0",
")",
";",
"if",
"(",
"++",
"i",
">=",
"num_in_fnames",
")",
"break",
";",
"cpp_undef_all",
"(",
"parse_in",
")",
";",
"cpp_clear_file_cache",
"(",
"parse_in",
")",
";",
"this_input_filename",
"=",
"cpp_read_main_file",
"(",
"parse_in",
",",
"in_fnames",
"[",
"i",
"]",
")",
";",
"if",
"(",
"original_dump_file",
")",
"{",
"dump_end",
"(",
"TDI_original",
",",
"original_dump_file",
")",
";",
"original_dump_file",
"=",
"NULL",
";",
"}",
"if",
"(",
"!",
"this_input_filename",
")",
"break",
";",
"}",
"c_parse_final_cleanups",
"(",
")",
";",
"}"
] | Initialize the integrated preprocessor after debug output has been
initialized; loop over each input file. | [
"Initialize",
"the",
"integrated",
"preprocessor",
"after",
"debug",
"output",
"has",
"been",
"initialized",
";",
"loop",
"over",
"each",
"input",
"file",
"."
] | [
"/* Open the dump file to use for the original dump output\n here, to be used during parsing for the current file. */",
"/* And end the main input file, if the debug writer wants it */",
"/* If an input file is missing, abandon further compilation.\n\t cpplib has issued a diagnostic. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
90119027944d11d962dc48b807feab18b5224da0 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/c-family/c-opts.c | [
"BSD-3-Clause"
] | C | c_common_finish | void | void
c_common_finish (void)
{
FILE *deps_stream = NULL;
/* Note that we write the dependencies even if there are errors. This is
useful for handling outdated generated headers that now trigger errors
(for example, with #error) which would be resolved by re-generating
them. In a sense, this complements -MG. */
if (cpp_opts->deps.style != DEPS_NONE)
{
/* If -M or -MM was seen without -MF, default output to the
output stream. */
if (!deps_file)
deps_stream = out_stream;
else if (deps_file[0] == '-' && deps_file[1] == '\0')
deps_stream = stdout;
else
{
deps_stream = fopen (deps_file, deps_append ? "a": "w");
if (!deps_stream)
fatal_error (input_location, "opening dependency file %s: %m",
deps_file);
}
}
/* For performance, avoid tearing down cpplib's internal structures
with cpp_destroy (). */
cpp_finish (parse_in, deps_stream);
if (deps_stream && deps_stream != out_stream && deps_stream != stdout
&& (ferror (deps_stream) || fclose (deps_stream)))
fatal_error (input_location, "closing dependency file %s: %m", deps_file);
if (out_stream && (ferror (out_stream) || fclose (out_stream)))
fatal_error (input_location, "when writing output to %s: %m", out_fname);
} | /* Common finish hook for the C, ObjC and C++ front ends. */ | Common finish hook for the C, ObjC and C++ front ends. | [
"Common",
"finish",
"hook",
"for",
"the",
"C",
"ObjC",
"and",
"C",
"++",
"front",
"ends",
"."
] | void
c_common_finish (void)
{
FILE *deps_stream = NULL;
if (cpp_opts->deps.style != DEPS_NONE)
{
if (!deps_file)
deps_stream = out_stream;
else if (deps_file[0] == '-' && deps_file[1] == '\0')
deps_stream = stdout;
else
{
deps_stream = fopen (deps_file, deps_append ? "a": "w");
if (!deps_stream)
fatal_error (input_location, "opening dependency file %s: %m",
deps_file);
}
}
cpp_finish (parse_in, deps_stream);
if (deps_stream && deps_stream != out_stream && deps_stream != stdout
&& (ferror (deps_stream) || fclose (deps_stream)))
fatal_error (input_location, "closing dependency file %s: %m", deps_file);
if (out_stream && (ferror (out_stream) || fclose (out_stream)))
fatal_error (input_location, "when writing output to %s: %m", out_fname);
} | [
"void",
"c_common_finish",
"(",
"void",
")",
"{",
"FILE",
"*",
"deps_stream",
"=",
"NULL",
";",
"if",
"(",
"cpp_opts",
"->",
"deps",
".",
"style",
"!=",
"DEPS_NONE",
")",
"{",
"if",
"(",
"!",
"deps_file",
")",
"deps_stream",
"=",
"out_stream",
";",
"else",
"if",
"(",
"deps_file",
"[",
"0",
"]",
"==",
"'",
"'",
"&&",
"deps_file",
"[",
"1",
"]",
"==",
"'",
"\\0",
"'",
")",
"deps_stream",
"=",
"stdout",
";",
"else",
"{",
"deps_stream",
"=",
"fopen",
"(",
"deps_file",
",",
"deps_append",
"?",
"\"",
"\"",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"!",
"deps_stream",
")",
"fatal_error",
"(",
"input_location",
",",
"\"",
"\"",
",",
"deps_file",
")",
";",
"}",
"}",
"cpp_finish",
"(",
"parse_in",
",",
"deps_stream",
")",
";",
"if",
"(",
"deps_stream",
"&&",
"deps_stream",
"!=",
"out_stream",
"&&",
"deps_stream",
"!=",
"stdout",
"&&",
"(",
"ferror",
"(",
"deps_stream",
")",
"||",
"fclose",
"(",
"deps_stream",
")",
")",
")",
"fatal_error",
"(",
"input_location",
",",
"\"",
"\"",
",",
"deps_file",
")",
";",
"if",
"(",
"out_stream",
"&&",
"(",
"ferror",
"(",
"out_stream",
")",
"||",
"fclose",
"(",
"out_stream",
")",
")",
")",
"fatal_error",
"(",
"input_location",
",",
"\"",
"\"",
",",
"out_fname",
")",
";",
"}"
] | Common finish hook for the C, ObjC and C++ front ends. | [
"Common",
"finish",
"hook",
"for",
"the",
"C",
"ObjC",
"and",
"C",
"++",
"front",
"ends",
"."
] | [
"/* Note that we write the dependencies even if there are errors. This is\n useful for handling outdated generated headers that now trigger errors\n (for example, with #error) which would be resolved by re-generating\n them. In a sense, this complements -MG. */",
"/* If -M or -MM was seen without -MF, default output to the\n\t output stream. */",
"/* For performance, avoid tearing down cpplib's internal structures\n with cpp_destroy (). */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
90119027944d11d962dc48b807feab18b5224da0 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/c-family/c-opts.c | [
"BSD-3-Clause"
] | C | check_deps_environment_vars | void | static void
check_deps_environment_vars (void)
{
char *spec;
spec = getenv ("DEPENDENCIES_OUTPUT");
if (spec)
cpp_opts->deps.style = DEPS_USER;
else
{
spec = getenv ("SUNPRO_DEPENDENCIES");
if (spec)
{
cpp_opts->deps.style = DEPS_SYSTEM;
cpp_opts->deps.ignore_main_file = true;
}
}
if (spec)
{
/* Find the space before the DEPS_TARGET, if there is one. */
char *s = strchr (spec, ' ');
if (s)
{
/* Let the caller perform MAKE quoting. */
defer_opt (OPT_MT, s + 1);
*s = '\0';
}
/* Command line -MF overrides environment variables and default. */
if (!deps_file)
deps_file = spec;
deps_append = 1;
deps_seen = true;
}
} | /* Either of two environment variables can specify output of
dependencies. Their value is either "OUTPUT_FILE" or "OUTPUT_FILE
DEPS_TARGET", where OUTPUT_FILE is the file to write deps info to
and DEPS_TARGET is the target to mention in the deps. They also
result in dependency information being appended to the output file
rather than overwriting it, and like Sun's compiler
SUNPRO_DEPENDENCIES suppresses the dependency on the main file. */ | Either of two environment variables can specify output of
dependencies. Their value is either "OUTPUT_FILE" or "OUTPUT_FILE
DEPS_TARGET", where OUTPUT_FILE is the file to write deps info to
and DEPS_TARGET is the target to mention in the deps. They also
result in dependency information being appended to the output file
rather than overwriting it, and like Sun's compiler
SUNPRO_DEPENDENCIES suppresses the dependency on the main file. | [
"Either",
"of",
"two",
"environment",
"variables",
"can",
"specify",
"output",
"of",
"dependencies",
".",
"Their",
"value",
"is",
"either",
"\"",
"OUTPUT_FILE",
"\"",
"or",
"\"",
"OUTPUT_FILE",
"DEPS_TARGET",
"\"",
"where",
"OUTPUT_FILE",
"is",
"the",
"file",
"to",
"write",
"deps",
"info",
"to",
"and",
"DEPS_TARGET",
"is",
"the",
"target",
"to",
"mention",
"in",
"the",
"deps",
".",
"They",
"also",
"result",
"in",
"dependency",
"information",
"being",
"appended",
"to",
"the",
"output",
"file",
"rather",
"than",
"overwriting",
"it",
"and",
"like",
"Sun",
"'",
"s",
"compiler",
"SUNPRO_DEPENDENCIES",
"suppresses",
"the",
"dependency",
"on",
"the",
"main",
"file",
"."
] | static void
check_deps_environment_vars (void)
{
char *spec;
spec = getenv ("DEPENDENCIES_OUTPUT");
if (spec)
cpp_opts->deps.style = DEPS_USER;
else
{
spec = getenv ("SUNPRO_DEPENDENCIES");
if (spec)
{
cpp_opts->deps.style = DEPS_SYSTEM;
cpp_opts->deps.ignore_main_file = true;
}
}
if (spec)
{
char *s = strchr (spec, ' ');
if (s)
{
defer_opt (OPT_MT, s + 1);
*s = '\0';
}
if (!deps_file)
deps_file = spec;
deps_append = 1;
deps_seen = true;
}
} | [
"static",
"void",
"check_deps_environment_vars",
"(",
"void",
")",
"{",
"char",
"*",
"spec",
";",
"spec",
"=",
"getenv",
"(",
"\"",
"\"",
")",
";",
"if",
"(",
"spec",
")",
"cpp_opts",
"->",
"deps",
".",
"style",
"=",
"DEPS_USER",
";",
"else",
"{",
"spec",
"=",
"getenv",
"(",
"\"",
"\"",
")",
";",
"if",
"(",
"spec",
")",
"{",
"cpp_opts",
"->",
"deps",
".",
"style",
"=",
"DEPS_SYSTEM",
";",
"cpp_opts",
"->",
"deps",
".",
"ignore_main_file",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"spec",
")",
"{",
"char",
"*",
"s",
"=",
"strchr",
"(",
"spec",
",",
"'",
"'",
")",
";",
"if",
"(",
"s",
")",
"{",
"defer_opt",
"(",
"OPT_MT",
",",
"s",
"+",
"1",
")",
";",
"*",
"s",
"=",
"'",
"\\0",
"'",
";",
"}",
"if",
"(",
"!",
"deps_file",
")",
"deps_file",
"=",
"spec",
";",
"deps_append",
"=",
"1",
";",
"deps_seen",
"=",
"true",
";",
"}",
"}"
] | Either of two environment variables can specify output of
dependencies. | [
"Either",
"of",
"two",
"environment",
"variables",
"can",
"specify",
"output",
"of",
"dependencies",
"."
] | [
"/* Find the space before the DEPS_TARGET, if there is one. */",
"/* Let the caller perform MAKE quoting. */",
"/* Command line -MF overrides environment variables and default. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
90119027944d11d962dc48b807feab18b5224da0 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/c-family/c-opts.c | [
"BSD-3-Clause"
] | C | handle_deferred_opts | void | static void
handle_deferred_opts (void)
{
size_t i;
struct deps *deps;
/* Avoid allocating the deps buffer if we don't need it.
(This flag may be true without there having been -MT or -MQ
options, but we'll still need the deps buffer.) */
if (!deps_seen)
return;
deps = cpp_get_deps (parse_in);
for (i = 0; i < deferred_count; i++)
{
struct deferred_opt *opt = &deferred_opts[i];
if (opt->code == OPT_MT || opt->code == OPT_MQ)
deps_add_target (deps, opt->arg, opt->code == OPT_MQ);
}
} | /* Handle deferred command line switches. */ | Handle deferred command line switches. | [
"Handle",
"deferred",
"command",
"line",
"switches",
"."
] | static void
handle_deferred_opts (void)
{
size_t i;
struct deps *deps;
if (!deps_seen)
return;
deps = cpp_get_deps (parse_in);
for (i = 0; i < deferred_count; i++)
{
struct deferred_opt *opt = &deferred_opts[i];
if (opt->code == OPT_MT || opt->code == OPT_MQ)
deps_add_target (deps, opt->arg, opt->code == OPT_MQ);
}
} | [
"static",
"void",
"handle_deferred_opts",
"(",
"void",
")",
"{",
"size_t",
"i",
";",
"struct",
"deps",
"*",
"deps",
";",
"if",
"(",
"!",
"deps_seen",
")",
"return",
";",
"deps",
"=",
"cpp_get_deps",
"(",
"parse_in",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"deferred_count",
";",
"i",
"++",
")",
"{",
"struct",
"deferred_opt",
"*",
"opt",
"=",
"&",
"deferred_opts",
"[",
"i",
"]",
";",
"if",
"(",
"opt",
"->",
"code",
"==",
"OPT_MT",
"||",
"opt",
"->",
"code",
"==",
"OPT_MQ",
")",
"deps_add_target",
"(",
"deps",
",",
"opt",
"->",
"arg",
",",
"opt",
"->",
"code",
"==",
"OPT_MQ",
")",
";",
"}",
"}"
] | Handle deferred command line switches. | [
"Handle",
"deferred",
"command",
"line",
"switches",
"."
] | [
"/* Avoid allocating the deps buffer if we don't need it.\n (This flag may be true without there having been -MT or -MQ\n options, but we'll still need the deps buffer.) */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
90119027944d11d962dc48b807feab18b5224da0 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/c-family/c-opts.c | [
"BSD-3-Clause"
] | C | sanitize_cpp_opts | void | static void
sanitize_cpp_opts (void)
{
/* If we don't know what style of dependencies to output, complain
if any other dependency switches have been given. */
if (deps_seen && cpp_opts->deps.style == DEPS_NONE)
error ("to generate dependencies you must specify either -M or -MM");
/* -dM and dependencies suppress normal output; do it here so that
the last -d[MDN] switch overrides earlier ones. */
if (flag_dump_macros == 'M')
flag_no_output = 1;
/* By default, -fdirectives-only implies -dD. This allows subsequent phases
to perform proper macro expansion. */
if (cpp_opts->directives_only && !cpp_opts->preprocessed && !flag_dump_macros)
flag_dump_macros = 'D';
/* Disable -dD, -dN and -dI if normal output is suppressed. Allow
-dM since at least glibc relies on -M -dM to work. */
/* Also, flag_no_output implies flag_no_line_commands, always. */
if (flag_no_output)
{
if (flag_dump_macros != 'M')
flag_dump_macros = 0;
flag_dump_includes = 0;
flag_no_line_commands = 1;
}
else if (cpp_opts->deps.missing_files)
error ("-MG may only be used with -M or -MM");
cpp_opts->unsigned_char = !flag_signed_char;
cpp_opts->stdc_0_in_system_headers = STDC_0_IN_SYSTEM_HEADERS;
/* Wlong-long is disabled by default. It is enabled by:
[-Wpedantic | -Wtraditional] -std=[gnu|c]++98 ; or
[-Wpedantic | -Wtraditional] -std=non-c99
Either -Wlong-long or -Wno-long-long override any other settings.
??? These conditions should be handled in c.opt. */
if (warn_long_long == -1)
{
warn_long_long = ((pedantic || warn_traditional)
&& (c_dialect_cxx () ? cxx_dialect == cxx98 : !flag_isoc99));
cpp_opts->cpp_warn_long_long = warn_long_long;
}
/* If we're generating preprocessor output, emit current directory
if explicitly requested or if debugging information is enabled.
??? Maybe we should only do it for debugging formats that
actually output the current directory? */
if (flag_working_directory == -1)
flag_working_directory = (debug_info_level != DINFO_LEVEL_NONE);
if (warn_implicit_fallthrough < 5)
cpp_opts->cpp_warn_implicit_fallthrough = warn_implicit_fallthrough;
else
cpp_opts->cpp_warn_implicit_fallthrough = 0;
if (cpp_opts->directives_only)
{
if (cpp_warn_unused_macros)
error ("-fdirectives-only is incompatible with -Wunused_macros");
if (cpp_opts->traditional)
error ("-fdirectives-only is incompatible with -traditional");
}
} | /* These settings are appropriate for GCC, but not necessarily so for
cpplib as a library. */ | These settings are appropriate for GCC, but not necessarily so for
cpplib as a library. | [
"These",
"settings",
"are",
"appropriate",
"for",
"GCC",
"but",
"not",
"necessarily",
"so",
"for",
"cpplib",
"as",
"a",
"library",
"."
] | static void
sanitize_cpp_opts (void)
{
if (deps_seen && cpp_opts->deps.style == DEPS_NONE)
error ("to generate dependencies you must specify either -M or -MM");
if (flag_dump_macros == 'M')
flag_no_output = 1;
if (cpp_opts->directives_only && !cpp_opts->preprocessed && !flag_dump_macros)
flag_dump_macros = 'D';
if (flag_no_output)
{
if (flag_dump_macros != 'M')
flag_dump_macros = 0;
flag_dump_includes = 0;
flag_no_line_commands = 1;
}
else if (cpp_opts->deps.missing_files)
error ("-MG may only be used with -M or -MM");
cpp_opts->unsigned_char = !flag_signed_char;
cpp_opts->stdc_0_in_system_headers = STDC_0_IN_SYSTEM_HEADERS;
if (warn_long_long == -1)
{
warn_long_long = ((pedantic || warn_traditional)
&& (c_dialect_cxx () ? cxx_dialect == cxx98 : !flag_isoc99));
cpp_opts->cpp_warn_long_long = warn_long_long;
}
if (flag_working_directory == -1)
flag_working_directory = (debug_info_level != DINFO_LEVEL_NONE);
if (warn_implicit_fallthrough < 5)
cpp_opts->cpp_warn_implicit_fallthrough = warn_implicit_fallthrough;
else
cpp_opts->cpp_warn_implicit_fallthrough = 0;
if (cpp_opts->directives_only)
{
if (cpp_warn_unused_macros)
error ("-fdirectives-only is incompatible with -Wunused_macros");
if (cpp_opts->traditional)
error ("-fdirectives-only is incompatible with -traditional");
}
} | [
"static",
"void",
"sanitize_cpp_opts",
"(",
"void",
")",
"{",
"if",
"(",
"deps_seen",
"&&",
"cpp_opts",
"->",
"deps",
".",
"style",
"==",
"DEPS_NONE",
")",
"error",
"(",
"\"",
"\"",
")",
";",
"if",
"(",
"flag_dump_macros",
"==",
"'",
"'",
")",
"flag_no_output",
"=",
"1",
";",
"if",
"(",
"cpp_opts",
"->",
"directives_only",
"&&",
"!",
"cpp_opts",
"->",
"preprocessed",
"&&",
"!",
"flag_dump_macros",
")",
"flag_dump_macros",
"=",
"'",
"'",
";",
"if",
"(",
"flag_no_output",
")",
"{",
"if",
"(",
"flag_dump_macros",
"!=",
"'",
"'",
")",
"flag_dump_macros",
"=",
"0",
";",
"flag_dump_includes",
"=",
"0",
";",
"flag_no_line_commands",
"=",
"1",
";",
"}",
"else",
"if",
"(",
"cpp_opts",
"->",
"deps",
".",
"missing_files",
")",
"error",
"(",
"\"",
"\"",
")",
";",
"cpp_opts",
"->",
"unsigned_char",
"=",
"!",
"flag_signed_char",
";",
"cpp_opts",
"->",
"stdc_0_in_system_headers",
"=",
"STDC_0_IN_SYSTEM_HEADERS",
";",
"if",
"(",
"warn_long_long",
"==",
"-1",
")",
"{",
"warn_long_long",
"=",
"(",
"(",
"pedantic",
"||",
"warn_traditional",
")",
"&&",
"(",
"c_dialect_cxx",
"(",
")",
"?",
"cxx_dialect",
"==",
"cxx98",
":",
"!",
"flag_isoc99",
")",
")",
";",
"cpp_opts",
"->",
"cpp_warn_long_long",
"=",
"warn_long_long",
";",
"}",
"if",
"(",
"flag_working_directory",
"==",
"-1",
")",
"flag_working_directory",
"=",
"(",
"debug_info_level",
"!=",
"DINFO_LEVEL_NONE",
")",
";",
"if",
"(",
"warn_implicit_fallthrough",
"<",
"5",
")",
"cpp_opts",
"->",
"cpp_warn_implicit_fallthrough",
"=",
"warn_implicit_fallthrough",
";",
"else",
"cpp_opts",
"->",
"cpp_warn_implicit_fallthrough",
"=",
"0",
";",
"if",
"(",
"cpp_opts",
"->",
"directives_only",
")",
"{",
"if",
"(",
"cpp_warn_unused_macros",
")",
"error",
"(",
"\"",
"\"",
")",
";",
"if",
"(",
"cpp_opts",
"->",
"traditional",
")",
"error",
"(",
"\"",
"\"",
")",
";",
"}",
"}"
] | These settings are appropriate for GCC, but not necessarily so for
cpplib as a library. | [
"These",
"settings",
"are",
"appropriate",
"for",
"GCC",
"but",
"not",
"necessarily",
"so",
"for",
"cpplib",
"as",
"a",
"library",
"."
] | [
"/* If we don't know what style of dependencies to output, complain\n if any other dependency switches have been given. */",
"/* -dM and dependencies suppress normal output; do it here so that\n the last -d[MDN] switch overrides earlier ones. */",
"/* By default, -fdirectives-only implies -dD. This allows subsequent phases\n to perform proper macro expansion. */",
"/* Disable -dD, -dN and -dI if normal output is suppressed. Allow\n -dM since at least glibc relies on -M -dM to work. */",
"/* Also, flag_no_output implies flag_no_line_commands, always. */",
"/* Wlong-long is disabled by default. It is enabled by:\n [-Wpedantic | -Wtraditional] -std=[gnu|c]++98 ; or\n [-Wpedantic | -Wtraditional] -std=non-c99 \n\n Either -Wlong-long or -Wno-long-long override any other settings.\n ??? These conditions should be handled in c.opt. */",
"/* If we're generating preprocessor output, emit current directory\n if explicitly requested or if debugging information is enabled.\n ??? Maybe we should only do it for debugging formats that\n actually output the current directory? */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
90119027944d11d962dc48b807feab18b5224da0 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/c-family/c-opts.c | [
"BSD-3-Clause"
] | C | add_prefixed_path | void | static void
add_prefixed_path (const char *suffix, incpath_kind chain)
{
char *path;
const char *prefix;
size_t prefix_len, suffix_len;
suffix_len = strlen (suffix);
prefix = iprefix ? iprefix : cpp_GCC_INCLUDE_DIR;
prefix_len = iprefix ? strlen (iprefix) : cpp_GCC_INCLUDE_DIR_len;
path = (char *) xmalloc (prefix_len + suffix_len + 1);
memcpy (path, prefix, prefix_len);
memcpy (path + prefix_len, suffix, suffix_len);
path[prefix_len + suffix_len] = '\0';
add_path (path, chain, 0, false);
} | /* Add include path with a prefix at the front of its name. */ | Add include path with a prefix at the front of its name. | [
"Add",
"include",
"path",
"with",
"a",
"prefix",
"at",
"the",
"front",
"of",
"its",
"name",
"."
] | static void
add_prefixed_path (const char *suffix, incpath_kind chain)
{
char *path;
const char *prefix;
size_t prefix_len, suffix_len;
suffix_len = strlen (suffix);
prefix = iprefix ? iprefix : cpp_GCC_INCLUDE_DIR;
prefix_len = iprefix ? strlen (iprefix) : cpp_GCC_INCLUDE_DIR_len;
path = (char *) xmalloc (prefix_len + suffix_len + 1);
memcpy (path, prefix, prefix_len);
memcpy (path + prefix_len, suffix, suffix_len);
path[prefix_len + suffix_len] = '\0';
add_path (path, chain, 0, false);
} | [
"static",
"void",
"add_prefixed_path",
"(",
"const",
"char",
"*",
"suffix",
",",
"incpath_kind",
"chain",
")",
"{",
"char",
"*",
"path",
";",
"const",
"char",
"*",
"prefix",
";",
"size_t",
"prefix_len",
",",
"suffix_len",
";",
"suffix_len",
"=",
"strlen",
"(",
"suffix",
")",
";",
"prefix",
"=",
"iprefix",
"?",
"iprefix",
":",
"cpp_GCC_INCLUDE_DIR",
";",
"prefix_len",
"=",
"iprefix",
"?",
"strlen",
"(",
"iprefix",
")",
":",
"cpp_GCC_INCLUDE_DIR_len",
";",
"path",
"=",
"(",
"char",
"*",
")",
"xmalloc",
"(",
"prefix_len",
"+",
"suffix_len",
"+",
"1",
")",
";",
"memcpy",
"(",
"path",
",",
"prefix",
",",
"prefix_len",
")",
";",
"memcpy",
"(",
"path",
"+",
"prefix_len",
",",
"suffix",
",",
"suffix_len",
")",
";",
"path",
"[",
"prefix_len",
"+",
"suffix_len",
"]",
"=",
"'",
"\\0",
"'",
";",
"add_path",
"(",
"path",
",",
"chain",
",",
"0",
",",
"false",
")",
";",
"}"
] | Add include path with a prefix at the front of its name. | [
"Add",
"include",
"path",
"with",
"a",
"prefix",
"at",
"the",
"front",
"of",
"its",
"name",
"."
] | [] | [
{
"param": "suffix",
"type": "char"
},
{
"param": "chain",
"type": "incpath_kind"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "suffix",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "chain",
"type": "incpath_kind",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
90119027944d11d962dc48b807feab18b5224da0 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/c-family/c-opts.c | [
"BSD-3-Clause"
] | C | push_command_line_include | void | static void
push_command_line_include (void)
{
/* This can happen if disabled by -imacros for example.
Punt so that we don't set "<command-line>" as the filename for
the header. */
if (include_cursor > deferred_count)
return;
if (!done_preinclude)
{
done_preinclude = true;
if (flag_hosted && std_inc && !cpp_opts->preprocessed)
{
const char *preinc = targetcm.c_preinclude ();
if (preinc && cpp_push_default_include (parse_in, preinc))
return;
}
}
pch_cpp_save_state ();
while (include_cursor < deferred_count)
{
struct deferred_opt *opt = &deferred_opts[include_cursor++];
if (!cpp_opts->preprocessed && opt->code == OPT_include
&& cpp_push_include (parse_in, opt->arg))
return;
}
if (include_cursor == deferred_count)
{
include_cursor++;
/* -Wunused-macros should only warn about macros defined hereafter. */
cpp_opts->warn_unused_macros = cpp_warn_unused_macros;
/* Restore the line map from <command line>. */
if (!cpp_opts->preprocessed)
cpp_change_file (parse_in, LC_RENAME, this_input_filename);
/* Set this here so the client can change the option if it wishes,
and after stacking the main file so we don't trace the main file. */
line_table->trace_includes = cpp_opts->print_include_names;
}
} | /* Give CPP the next file given by -include, if any. */ | Give CPP the next file given by -include, if any. | [
"Give",
"CPP",
"the",
"next",
"file",
"given",
"by",
"-",
"include",
"if",
"any",
"."
] | static void
push_command_line_include (void)
{
if (include_cursor > deferred_count)
return;
if (!done_preinclude)
{
done_preinclude = true;
if (flag_hosted && std_inc && !cpp_opts->preprocessed)
{
const char *preinc = targetcm.c_preinclude ();
if (preinc && cpp_push_default_include (parse_in, preinc))
return;
}
}
pch_cpp_save_state ();
while (include_cursor < deferred_count)
{
struct deferred_opt *opt = &deferred_opts[include_cursor++];
if (!cpp_opts->preprocessed && opt->code == OPT_include
&& cpp_push_include (parse_in, opt->arg))
return;
}
if (include_cursor == deferred_count)
{
include_cursor++;
cpp_opts->warn_unused_macros = cpp_warn_unused_macros;
if (!cpp_opts->preprocessed)
cpp_change_file (parse_in, LC_RENAME, this_input_filename);
line_table->trace_includes = cpp_opts->print_include_names;
}
} | [
"static",
"void",
"push_command_line_include",
"(",
"void",
")",
"{",
"if",
"(",
"include_cursor",
">",
"deferred_count",
")",
"return",
";",
"if",
"(",
"!",
"done_preinclude",
")",
"{",
"done_preinclude",
"=",
"true",
";",
"if",
"(",
"flag_hosted",
"&&",
"std_inc",
"&&",
"!",
"cpp_opts",
"->",
"preprocessed",
")",
"{",
"const",
"char",
"*",
"preinc",
"=",
"targetcm",
".",
"c_preinclude",
"(",
")",
";",
"if",
"(",
"preinc",
"&&",
"cpp_push_default_include",
"(",
"parse_in",
",",
"preinc",
")",
")",
"return",
";",
"}",
"}",
"pch_cpp_save_state",
"(",
")",
";",
"while",
"(",
"include_cursor",
"<",
"deferred_count",
")",
"{",
"struct",
"deferred_opt",
"*",
"opt",
"=",
"&",
"deferred_opts",
"[",
"include_cursor",
"++",
"]",
";",
"if",
"(",
"!",
"cpp_opts",
"->",
"preprocessed",
"&&",
"opt",
"->",
"code",
"==",
"OPT_include",
"&&",
"cpp_push_include",
"(",
"parse_in",
",",
"opt",
"->",
"arg",
")",
")",
"return",
";",
"}",
"if",
"(",
"include_cursor",
"==",
"deferred_count",
")",
"{",
"include_cursor",
"++",
";",
"cpp_opts",
"->",
"warn_unused_macros",
"=",
"cpp_warn_unused_macros",
";",
"if",
"(",
"!",
"cpp_opts",
"->",
"preprocessed",
")",
"cpp_change_file",
"(",
"parse_in",
",",
"LC_RENAME",
",",
"this_input_filename",
")",
";",
"line_table",
"->",
"trace_includes",
"=",
"cpp_opts",
"->",
"print_include_names",
";",
"}",
"}"
] | Give CPP the next file given by -include, if any. | [
"Give",
"CPP",
"the",
"next",
"file",
"given",
"by",
"-",
"include",
"if",
"any",
"."
] | [
"/* This can happen if disabled by -imacros for example.\n Punt so that we don't set \"<command-line>\" as the filename for\n the header. */",
"/* -Wunused-macros should only warn about macros defined hereafter. */",
"/* Restore the line map from <command line>. */",
"/* Set this here so the client can change the option if it wishes,\n\t and after stacking the main file so we don't trace the main file. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
90119027944d11d962dc48b807feab18b5224da0 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/c-family/c-opts.c | [
"BSD-3-Clause"
] | C | handle_OPT_d | void | static void
handle_OPT_d (const char *arg)
{
char c;
while ((c = *arg++) != '\0')
switch (c)
{
case 'M': /* Dump macros only. */
case 'N': /* Dump names. */
case 'D': /* Dump definitions. */
case 'U': /* Dump used macros. */
flag_dump_macros = c;
break;
case 'I':
flag_dump_includes = 1;
break;
}
} | /* Args to -d specify what to dump. Silently ignore
unrecognized options; they may be aimed at toplev.c. */ | Args to -d specify what to dump. Silently ignore
unrecognized options; they may be aimed at toplev.c. | [
"Args",
"to",
"-",
"d",
"specify",
"what",
"to",
"dump",
".",
"Silently",
"ignore",
"unrecognized",
"options",
";",
"they",
"may",
"be",
"aimed",
"at",
"toplev",
".",
"c",
"."
] | static void
handle_OPT_d (const char *arg)
{
char c;
while ((c = *arg++) != '\0')
switch (c)
{
case 'M':
case 'N':
case 'D':
case 'U':
flag_dump_macros = c;
break;
case 'I':
flag_dump_includes = 1;
break;
}
} | [
"static",
"void",
"handle_OPT_d",
"(",
"const",
"char",
"*",
"arg",
")",
"{",
"char",
"c",
";",
"while",
"(",
"(",
"c",
"=",
"*",
"arg",
"++",
")",
"!=",
"'",
"\\0",
"'",
")",
"switch",
"(",
"c",
")",
"{",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"flag_dump_macros",
"=",
"c",
";",
"break",
";",
"case",
"'",
"'",
":",
"flag_dump_includes",
"=",
"1",
";",
"break",
";",
"}",
"}"
] | Args to -d specify what to dump. | [
"Args",
"to",
"-",
"d",
"specify",
"what",
"to",
"dump",
"."
] | [
"/* Dump macros only. */",
"/* Dump names. */",
"/* Dump definitions. */",
"/* Dump used macros. */"
] | [
{
"param": "arg",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "arg",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
87060831a4511b29d59662b9c0f2ac4dc19fedc9 | atrens/DragonFlyBSD-src | lib/libstand/rarp.c | [
"BSD-3-Clause"
] | C | rarp_getipaddress | int | int
rarp_getipaddress(int sock)
{
struct iodesc *d;
struct ether_arp *ap;
struct {
u_char header[ETHER_SIZE];
struct {
struct ether_arp arp;
u_char pad[18]; /* 60 - sizeof(arp) */
} data;
} wbuf;
struct {
u_char header[ETHER_SIZE];
struct {
struct ether_arp arp;
u_char pad[24]; /* extra space */
} data;
} rbuf;
#ifdef RARP_DEBUG
if (debug)
printf("rarp: socket=%d\n", sock);
#endif
if (!(d = socktodesc(sock))) {
printf("rarp: bad socket. %d\n", sock);
return (-1);
}
#ifdef RARP_DEBUG
if (debug)
printf("rarp: d=%x\n", (u_int)d);
#endif
bzero((char*)&wbuf.data, sizeof(wbuf.data));
ap = &wbuf.data.arp;
ap->arp_hrd = htons(ARPHRD_ETHER);
ap->arp_pro = htons(ETHERTYPE_IP);
ap->arp_hln = sizeof(ap->arp_sha); /* hardware address length */
ap->arp_pln = sizeof(ap->arp_spa); /* protocol address length */
ap->arp_op = htons(ARPOP_REVREQUEST);
bcopy(d->myea, ap->arp_sha, 6);
bcopy(d->myea, ap->arp_tha, 6);
if (sendrecv(d,
rarpsend, &wbuf.data, sizeof(wbuf.data),
rarprecv, &rbuf.data, sizeof(rbuf.data)) < 0)
{
printf("No response for RARP request\n");
return (-1);
}
ap = &rbuf.data.arp;
bcopy(ap->arp_tpa, (char *)&myip, sizeof(myip));
#if 0
/* XXX - Can NOT assume this is our root server! */
bcopy(ap->arp_spa, (char *)&rootip, sizeof(rootip));
#endif
/* Compute our "natural" netmask. */
if (IN_CLASSA(myip.s_addr))
netmask = IN_CLASSA_NET;
else if (IN_CLASSB(myip.s_addr))
netmask = IN_CLASSB_NET;
else
netmask = IN_CLASSC_NET;
d->myip = myip;
return (0);
} | /*
* Ethernet (Reverse) Address Resolution Protocol (see RFC 903, and 826).
*/ | Ethernet (Reverse) Address Resolution Protocol . | [
"Ethernet",
"(",
"Reverse",
")",
"Address",
"Resolution",
"Protocol",
"."
] | int
rarp_getipaddress(int sock)
{
struct iodesc *d;
struct ether_arp *ap;
struct {
u_char header[ETHER_SIZE];
struct {
struct ether_arp arp;
u_char pad[18];
} data;
} wbuf;
struct {
u_char header[ETHER_SIZE];
struct {
struct ether_arp arp;
u_char pad[24];
} data;
} rbuf;
#ifdef RARP_DEBUG
if (debug)
printf("rarp: socket=%d\n", sock);
#endif
if (!(d = socktodesc(sock))) {
printf("rarp: bad socket. %d\n", sock);
return (-1);
}
#ifdef RARP_DEBUG
if (debug)
printf("rarp: d=%x\n", (u_int)d);
#endif
bzero((char*)&wbuf.data, sizeof(wbuf.data));
ap = &wbuf.data.arp;
ap->arp_hrd = htons(ARPHRD_ETHER);
ap->arp_pro = htons(ETHERTYPE_IP);
ap->arp_hln = sizeof(ap->arp_sha);
ap->arp_pln = sizeof(ap->arp_spa);
ap->arp_op = htons(ARPOP_REVREQUEST);
bcopy(d->myea, ap->arp_sha, 6);
bcopy(d->myea, ap->arp_tha, 6);
if (sendrecv(d,
rarpsend, &wbuf.data, sizeof(wbuf.data),
rarprecv, &rbuf.data, sizeof(rbuf.data)) < 0)
{
printf("No response for RARP request\n");
return (-1);
}
ap = &rbuf.data.arp;
bcopy(ap->arp_tpa, (char *)&myip, sizeof(myip));
#if 0
bcopy(ap->arp_spa, (char *)&rootip, sizeof(rootip));
#endif
if (IN_CLASSA(myip.s_addr))
netmask = IN_CLASSA_NET;
else if (IN_CLASSB(myip.s_addr))
netmask = IN_CLASSB_NET;
else
netmask = IN_CLASSC_NET;
d->myip = myip;
return (0);
} | [
"int",
"rarp_getipaddress",
"(",
"int",
"sock",
")",
"{",
"struct",
"iodesc",
"*",
"d",
";",
"struct",
"ether_arp",
"*",
"ap",
";",
"struct",
"{",
"u_char",
"header",
"[",
"ETHER_SIZE",
"]",
";",
"struct",
"{",
"struct",
"ether_arp",
"arp",
";",
"u_char",
"pad",
"[",
"18",
"]",
";",
"}",
"data",
";",
"}",
"wbuf",
";",
"struct",
"{",
"u_char",
"header",
"[",
"ETHER_SIZE",
"]",
";",
"struct",
"{",
"struct",
"ether_arp",
"arp",
";",
"u_char",
"pad",
"[",
"24",
"]",
";",
"}",
"data",
";",
"}",
"rbuf",
";",
"#ifdef",
"RARP_DEBUG",
"if",
"(",
"debug",
")",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"sock",
")",
";",
"#endif",
"if",
"(",
"!",
"(",
"d",
"=",
"socktodesc",
"(",
"sock",
")",
")",
")",
"{",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"sock",
")",
";",
"return",
"(",
"-1",
")",
";",
"}",
"#ifdef",
"RARP_DEBUG",
"if",
"(",
"debug",
")",
"printf",
"(",
"\"",
"\\n",
"\"",
",",
"(",
"u_int",
")",
"d",
")",
";",
"#endif",
"bzero",
"(",
"(",
"char",
"*",
")",
"&",
"wbuf",
".",
"data",
",",
"sizeof",
"(",
"wbuf",
".",
"data",
")",
")",
";",
"ap",
"=",
"&",
"wbuf",
".",
"data",
".",
"arp",
";",
"ap",
"->",
"arp_hrd",
"=",
"htons",
"(",
"ARPHRD_ETHER",
")",
";",
"ap",
"->",
"arp_pro",
"=",
"htons",
"(",
"ETHERTYPE_IP",
")",
";",
"ap",
"->",
"arp_hln",
"=",
"sizeof",
"(",
"ap",
"->",
"arp_sha",
")",
";",
"ap",
"->",
"arp_pln",
"=",
"sizeof",
"(",
"ap",
"->",
"arp_spa",
")",
";",
"ap",
"->",
"arp_op",
"=",
"htons",
"(",
"ARPOP_REVREQUEST",
")",
";",
"bcopy",
"(",
"d",
"->",
"myea",
",",
"ap",
"->",
"arp_sha",
",",
"6",
")",
";",
"bcopy",
"(",
"d",
"->",
"myea",
",",
"ap",
"->",
"arp_tha",
",",
"6",
")",
";",
"if",
"(",
"sendrecv",
"(",
"d",
",",
"rarpsend",
",",
"&",
"wbuf",
".",
"data",
",",
"sizeof",
"(",
"wbuf",
".",
"data",
")",
",",
"rarprecv",
",",
"&",
"rbuf",
".",
"data",
",",
"sizeof",
"(",
"rbuf",
".",
"data",
")",
")",
"<",
"0",
")",
"{",
"printf",
"(",
"\"",
"\\n",
"\"",
")",
";",
"return",
"(",
"-1",
")",
";",
"}",
"ap",
"=",
"&",
"rbuf",
".",
"data",
".",
"arp",
";",
"bcopy",
"(",
"ap",
"->",
"arp_tpa",
",",
"(",
"char",
"*",
")",
"&",
"myip",
",",
"sizeof",
"(",
"myip",
")",
")",
";",
"#if",
"0",
"\n",
"bcopy",
"(",
"ap",
"->",
"arp_spa",
",",
"(",
"char",
"*",
")",
"&",
"rootip",
",",
"sizeof",
"(",
"rootip",
")",
")",
";",
"#endif",
"if",
"(",
"IN_CLASSA",
"(",
"myip",
".",
"s_addr",
")",
")",
"netmask",
"=",
"IN_CLASSA_NET",
";",
"else",
"if",
"(",
"IN_CLASSB",
"(",
"myip",
".",
"s_addr",
")",
")",
"netmask",
"=",
"IN_CLASSB_NET",
";",
"else",
"netmask",
"=",
"IN_CLASSC_NET",
";",
"d",
"->",
"myip",
"=",
"myip",
";",
"return",
"(",
"0",
")",
";",
"}"
] | Ethernet (Reverse) Address Resolution Protocol (see RFC 903, and 826). | [
"Ethernet",
"(",
"Reverse",
")",
"Address",
"Resolution",
"Protocol",
"(",
"see",
"RFC",
"903",
"and",
"826",
")",
"."
] | [
"/* 60 - sizeof(arp) */",
"/* extra space */",
"/* hardware address length */",
"/* protocol address length */",
"/* XXX - Can NOT assume this is our root server! */",
"/* Compute our \"natural\" netmask. */"
] | [
{
"param": "sock",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sock",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8beb302e7c85551e05fbc9d19a0ec461c2aef5cf | atrens/DragonFlyBSD-src | sys/netgraph7/ng_sample.c | [
"BSD-3-Clause"
] | C | ng_xxx_newhook | int | static int
ng_xxx_newhook(node_p node, hook_p hook, const char *name)
{
const xxx_p xxxp = NG_NODE_PRIVATE(node);
const char *cp;
int dlci = 0;
int chan;
#if 0
/* Possibly start up the device if it's not already going */
if ((xxxp->flags & SCF_RUNNING) == 0) {
ng_xxx_start_hardware(xxxp);
}
#endif
/* Example of how one might use hooks with embedded numbers: All
* hooks start with 'dlci' and have a decimal trailing channel
* number up to 4 digits Use the leadin defined int he associated .h
* file. */
if (strncmp(name,
NG_XXX_HOOK_DLCI_LEADIN, strlen(NG_XXX_HOOK_DLCI_LEADIN)) == 0) {
char *eptr;
cp = name + strlen(NG_XXX_HOOK_DLCI_LEADIN);
if (!isdigit(*cp) || (cp[0] == '0' && cp[1] != '\0'))
return (EINVAL);
dlci = (int)strtoul(cp, &eptr, 10);
if (*eptr != '\0' || dlci < 0 || dlci > 1023)
return (EINVAL);
/* We have a dlci, now either find it, or allocate it */
for (chan = 0; chan < XXX_NUM_DLCIS; chan++)
if (xxxp->channel[chan].dlci == dlci)
break;
if (chan == XXX_NUM_DLCIS) {
for (chan = 0; chan < XXX_NUM_DLCIS; chan++)
if (xxxp->channel[chan].dlci == -2)
break;
if (chan == XXX_NUM_DLCIS)
return (ENOBUFS);
xxxp->channel[chan].dlci = dlci;
}
if (xxxp->channel[chan].hook != NULL)
return (EADDRINUSE);
NG_HOOK_SET_PRIVATE(hook, xxxp->channel + chan);
xxxp->channel[chan].hook = hook;
return (0);
} else if (strcmp(name, NG_XXX_HOOK_DOWNSTREAM) == 0) {
/* Example of simple predefined hooks. */
/* do something specific to the downstream connection */
xxxp->downstream_hook.hook = hook;
NG_HOOK_SET_PRIVATE(hook, &xxxp->downstream_hook);
} else if (strcmp(name, NG_XXX_HOOK_DEBUG) == 0) {
/* do something specific to a debug connection */
xxxp->debughook = hook;
NG_HOOK_SET_PRIVATE(hook, NULL);
} else
return (EINVAL); /* not a hook we know about */
return(0);
} | /*
* Give our ok for a hook to be added...
* If we are not running this might kick a device into life.
* Possibly decode information out of the hook name.
* Add the hook's private info to the hook structure.
* (if we had some). In this example, we assume that there is a
* an array of structs, called 'channel' in the private info,
* one for each active channel. The private
* pointer of each hook points to the appropriate XXX_hookinfo struct
* so that the source of an input packet is easily identified.
* (a dlci is a frame relay channel)
*/ | Give our ok for a hook to be added
If we are not running this might kick a device into life.
Possibly decode information out of the hook name.
Add the hook's private info to the hook structure.
(if we had some). In this example, we assume that there is a
an array of structs, called 'channel' in the private info,
one for each active channel. The private
pointer of each hook points to the appropriate XXX_hookinfo struct
so that the source of an input packet is easily identified.
(a dlci is a frame relay channel) | [
"Give",
"our",
"ok",
"for",
"a",
"hook",
"to",
"be",
"added",
"If",
"we",
"are",
"not",
"running",
"this",
"might",
"kick",
"a",
"device",
"into",
"life",
".",
"Possibly",
"decode",
"information",
"out",
"of",
"the",
"hook",
"name",
".",
"Add",
"the",
"hook",
"'",
"s",
"private",
"info",
"to",
"the",
"hook",
"structure",
".",
"(",
"if",
"we",
"had",
"some",
")",
".",
"In",
"this",
"example",
"we",
"assume",
"that",
"there",
"is",
"a",
"an",
"array",
"of",
"structs",
"called",
"'",
"channel",
"'",
"in",
"the",
"private",
"info",
"one",
"for",
"each",
"active",
"channel",
".",
"The",
"private",
"pointer",
"of",
"each",
"hook",
"points",
"to",
"the",
"appropriate",
"XXX_hookinfo",
"struct",
"so",
"that",
"the",
"source",
"of",
"an",
"input",
"packet",
"is",
"easily",
"identified",
".",
"(",
"a",
"dlci",
"is",
"a",
"frame",
"relay",
"channel",
")"
] | static int
ng_xxx_newhook(node_p node, hook_p hook, const char *name)
{
const xxx_p xxxp = NG_NODE_PRIVATE(node);
const char *cp;
int dlci = 0;
int chan;
#if 0
if ((xxxp->flags & SCF_RUNNING) == 0) {
ng_xxx_start_hardware(xxxp);
}
#endif
if (strncmp(name,
NG_XXX_HOOK_DLCI_LEADIN, strlen(NG_XXX_HOOK_DLCI_LEADIN)) == 0) {
char *eptr;
cp = name + strlen(NG_XXX_HOOK_DLCI_LEADIN);
if (!isdigit(*cp) || (cp[0] == '0' && cp[1] != '\0'))
return (EINVAL);
dlci = (int)strtoul(cp, &eptr, 10);
if (*eptr != '\0' || dlci < 0 || dlci > 1023)
return (EINVAL);
for (chan = 0; chan < XXX_NUM_DLCIS; chan++)
if (xxxp->channel[chan].dlci == dlci)
break;
if (chan == XXX_NUM_DLCIS) {
for (chan = 0; chan < XXX_NUM_DLCIS; chan++)
if (xxxp->channel[chan].dlci == -2)
break;
if (chan == XXX_NUM_DLCIS)
return (ENOBUFS);
xxxp->channel[chan].dlci = dlci;
}
if (xxxp->channel[chan].hook != NULL)
return (EADDRINUSE);
NG_HOOK_SET_PRIVATE(hook, xxxp->channel + chan);
xxxp->channel[chan].hook = hook;
return (0);
} else if (strcmp(name, NG_XXX_HOOK_DOWNSTREAM) == 0) {
xxxp->downstream_hook.hook = hook;
NG_HOOK_SET_PRIVATE(hook, &xxxp->downstream_hook);
} else if (strcmp(name, NG_XXX_HOOK_DEBUG) == 0) {
xxxp->debughook = hook;
NG_HOOK_SET_PRIVATE(hook, NULL);
} else
return (EINVAL);
return(0);
} | [
"static",
"int",
"ng_xxx_newhook",
"(",
"node_p",
"node",
",",
"hook_p",
"hook",
",",
"const",
"char",
"*",
"name",
")",
"{",
"const",
"xxx_p",
"xxxp",
"=",
"NG_NODE_PRIVATE",
"(",
"node",
")",
";",
"const",
"char",
"*",
"cp",
";",
"int",
"dlci",
"=",
"0",
";",
"int",
"chan",
";",
"#if",
"0",
"\n",
"if",
"(",
"(",
"xxxp",
"->",
"flags",
"&",
"SCF_RUNNING",
")",
"==",
"0",
")",
"{",
"ng_xxx_start_hardware",
"(",
"xxxp",
")",
";",
"}",
"#endif",
"if",
"(",
"strncmp",
"(",
"name",
",",
"NG_XXX_HOOK_DLCI_LEADIN",
",",
"strlen",
"(",
"NG_XXX_HOOK_DLCI_LEADIN",
")",
")",
"==",
"0",
")",
"{",
"char",
"*",
"eptr",
";",
"cp",
"=",
"name",
"+",
"strlen",
"(",
"NG_XXX_HOOK_DLCI_LEADIN",
")",
";",
"if",
"(",
"!",
"isdigit",
"(",
"*",
"cp",
")",
"||",
"(",
"cp",
"[",
"0",
"]",
"==",
"'",
"'",
"&&",
"cp",
"[",
"1",
"]",
"!=",
"'",
"\\0",
"'",
")",
")",
"return",
"(",
"EINVAL",
")",
";",
"dlci",
"=",
"(",
"int",
")",
"strtoul",
"(",
"cp",
",",
"&",
"eptr",
",",
"10",
")",
";",
"if",
"(",
"*",
"eptr",
"!=",
"'",
"\\0",
"'",
"||",
"dlci",
"<",
"0",
"||",
"dlci",
">",
"1023",
")",
"return",
"(",
"EINVAL",
")",
";",
"for",
"(",
"chan",
"=",
"0",
";",
"chan",
"<",
"XXX_NUM_DLCIS",
";",
"chan",
"++",
")",
"if",
"(",
"xxxp",
"->",
"channel",
"[",
"chan",
"]",
".",
"dlci",
"==",
"dlci",
")",
"break",
";",
"if",
"(",
"chan",
"==",
"XXX_NUM_DLCIS",
")",
"{",
"for",
"(",
"chan",
"=",
"0",
";",
"chan",
"<",
"XXX_NUM_DLCIS",
";",
"chan",
"++",
")",
"if",
"(",
"xxxp",
"->",
"channel",
"[",
"chan",
"]",
".",
"dlci",
"==",
"-2",
")",
"break",
";",
"if",
"(",
"chan",
"==",
"XXX_NUM_DLCIS",
")",
"return",
"(",
"ENOBUFS",
")",
";",
"xxxp",
"->",
"channel",
"[",
"chan",
"]",
".",
"dlci",
"=",
"dlci",
";",
"}",
"if",
"(",
"xxxp",
"->",
"channel",
"[",
"chan",
"]",
".",
"hook",
"!=",
"NULL",
")",
"return",
"(",
"EADDRINUSE",
")",
";",
"NG_HOOK_SET_PRIVATE",
"(",
"hook",
",",
"xxxp",
"->",
"channel",
"+",
"chan",
")",
";",
"xxxp",
"->",
"channel",
"[",
"chan",
"]",
".",
"hook",
"=",
"hook",
";",
"return",
"(",
"0",
")",
";",
"}",
"else",
"if",
"(",
"strcmp",
"(",
"name",
",",
"NG_XXX_HOOK_DOWNSTREAM",
")",
"==",
"0",
")",
"{",
"xxxp",
"->",
"downstream_hook",
".",
"hook",
"=",
"hook",
";",
"NG_HOOK_SET_PRIVATE",
"(",
"hook",
",",
"&",
"xxxp",
"->",
"downstream_hook",
")",
";",
"}",
"else",
"if",
"(",
"strcmp",
"(",
"name",
",",
"NG_XXX_HOOK_DEBUG",
")",
"==",
"0",
")",
"{",
"xxxp",
"->",
"debughook",
"=",
"hook",
";",
"NG_HOOK_SET_PRIVATE",
"(",
"hook",
",",
"NULL",
")",
";",
"}",
"else",
"return",
"(",
"EINVAL",
")",
";",
"return",
"(",
"0",
")",
";",
"}"
] | Give our ok for a hook to be added... | [
"Give",
"our",
"ok",
"for",
"a",
"hook",
"to",
"be",
"added",
"..."
] | [
"/* Possibly start up the device if it's not already going */",
"/* Example of how one might use hooks with embedded numbers: All\n\t * hooks start with 'dlci' and have a decimal trailing channel\n\t * number up to 4 digits Use the leadin defined int he associated .h\n\t * file. */",
"/* We have a dlci, now either find it, or allocate it */",
"/* Example of simple predefined hooks. */",
"/* do something specific to the downstream connection */",
"/* do something specific to a debug connection */",
"/* not a hook we know about */"
] | [
{
"param": "node",
"type": "node_p"
},
{
"param": "hook",
"type": "hook_p"
},
{
"param": "name",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "node_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "hook",
"type": "hook_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8beb302e7c85551e05fbc9d19a0ec461c2aef5cf | atrens/DragonFlyBSD-src | sys/netgraph7/ng_sample.c | [
"BSD-3-Clause"
] | C | ng_xxx_rcvmsg | int | static int
ng_xxx_rcvmsg(node_p node, item_p item, hook_p lasthook)
{
const xxx_p xxxp = NG_NODE_PRIVATE(node);
struct ng_mesg *resp = NULL;
int error = 0;
struct ng_mesg *msg;
NGI_GET_MSG(item, msg);
/* Deal with message according to cookie and command */
switch (msg->header.typecookie) {
case NGM_XXX_COOKIE:
switch (msg->header.cmd) {
case NGM_XXX_GET_STATUS:
{
struct ngxxxstat *stats;
NG_MKRESPONSE(resp, msg, sizeof(*stats), M_WAITOK | M_NULLOK);
if (!resp) {
error = ENOMEM;
break;
}
stats = (struct ngxxxstat *) resp->data;
stats->packets_in = xxxp->packets_in;
stats->packets_out = xxxp->packets_out;
break;
}
case NGM_XXX_SET_FLAG:
if (msg->header.arglen != sizeof(u_int32_t)) {
error = EINVAL;
break;
}
xxxp->flags = *((u_int32_t *) msg->data);
break;
default:
error = EINVAL; /* unknown command */
break;
}
break;
default:
error = EINVAL; /* unknown cookie type */
break;
}
/* Take care of synchronous response, if any */
NG_RESPOND_MSG(error, node, item, resp);
/* Free the message and return */
NG_FREE_MSG(msg);
return(error);
} | /*
* Get a netgraph control message.
* We actually recieve a queue item that has a pointer to the message.
* If we free the item, the message will be freed too, unless we remove
* it from the item using NGI_GET_MSG();
* The return address is also stored in the item, as an ng_ID_t,
* accessible as NGI_RETADDR(item);
* Check it is one we understand. If needed, send a response.
* We could save the address for an async action later, but don't here.
* Always free the message.
* The response should be in a malloc'd region that the caller can 'free'.
* A response is not required.
* Theoretically you could respond defferently to old message types if
* the cookie in the header didn't match what we consider to be current
* (so that old userland programs could continue to work).
*/ | Get a netgraph control message.
We actually recieve a queue item that has a pointer to the message.
If we free the item, the message will be freed too, unless we remove
it from the item using NGI_GET_MSG();
The return address is also stored in the item, as an ng_ID_t,
accessible as NGI_RETADDR(item);
Check it is one we understand. If needed, send a response.
We could save the address for an async action later, but don't here.
Always free the message.
The response should be in a malloc'd region that the caller can 'free'.
A response is not required.
Theoretically you could respond defferently to old message types if
the cookie in the header didn't match what we consider to be current
(so that old userland programs could continue to work). | [
"Get",
"a",
"netgraph",
"control",
"message",
".",
"We",
"actually",
"recieve",
"a",
"queue",
"item",
"that",
"has",
"a",
"pointer",
"to",
"the",
"message",
".",
"If",
"we",
"free",
"the",
"item",
"the",
"message",
"will",
"be",
"freed",
"too",
"unless",
"we",
"remove",
"it",
"from",
"the",
"item",
"using",
"NGI_GET_MSG",
"()",
";",
"The",
"return",
"address",
"is",
"also",
"stored",
"in",
"the",
"item",
"as",
"an",
"ng_ID_t",
"accessible",
"as",
"NGI_RETADDR",
"(",
"item",
")",
";",
"Check",
"it",
"is",
"one",
"we",
"understand",
".",
"If",
"needed",
"send",
"a",
"response",
".",
"We",
"could",
"save",
"the",
"address",
"for",
"an",
"async",
"action",
"later",
"but",
"don",
"'",
"t",
"here",
".",
"Always",
"free",
"the",
"message",
".",
"The",
"response",
"should",
"be",
"in",
"a",
"malloc",
"'",
"d",
"region",
"that",
"the",
"caller",
"can",
"'",
"free",
"'",
".",
"A",
"response",
"is",
"not",
"required",
".",
"Theoretically",
"you",
"could",
"respond",
"defferently",
"to",
"old",
"message",
"types",
"if",
"the",
"cookie",
"in",
"the",
"header",
"didn",
"'",
"t",
"match",
"what",
"we",
"consider",
"to",
"be",
"current",
"(",
"so",
"that",
"old",
"userland",
"programs",
"could",
"continue",
"to",
"work",
")",
"."
] | static int
ng_xxx_rcvmsg(node_p node, item_p item, hook_p lasthook)
{
const xxx_p xxxp = NG_NODE_PRIVATE(node);
struct ng_mesg *resp = NULL;
int error = 0;
struct ng_mesg *msg;
NGI_GET_MSG(item, msg);
switch (msg->header.typecookie) {
case NGM_XXX_COOKIE:
switch (msg->header.cmd) {
case NGM_XXX_GET_STATUS:
{
struct ngxxxstat *stats;
NG_MKRESPONSE(resp, msg, sizeof(*stats), M_WAITOK | M_NULLOK);
if (!resp) {
error = ENOMEM;
break;
}
stats = (struct ngxxxstat *) resp->data;
stats->packets_in = xxxp->packets_in;
stats->packets_out = xxxp->packets_out;
break;
}
case NGM_XXX_SET_FLAG:
if (msg->header.arglen != sizeof(u_int32_t)) {
error = EINVAL;
break;
}
xxxp->flags = *((u_int32_t *) msg->data);
break;
default:
error = EINVAL;
break;
}
break;
default:
error = EINVAL;
break;
}
NG_RESPOND_MSG(error, node, item, resp);
NG_FREE_MSG(msg);
return(error);
} | [
"static",
"int",
"ng_xxx_rcvmsg",
"(",
"node_p",
"node",
",",
"item_p",
"item",
",",
"hook_p",
"lasthook",
")",
"{",
"const",
"xxx_p",
"xxxp",
"=",
"NG_NODE_PRIVATE",
"(",
"node",
")",
";",
"struct",
"ng_mesg",
"*",
"resp",
"=",
"NULL",
";",
"int",
"error",
"=",
"0",
";",
"struct",
"ng_mesg",
"*",
"msg",
";",
"NGI_GET_MSG",
"(",
"item",
",",
"msg",
")",
";",
"switch",
"(",
"msg",
"->",
"header",
".",
"typecookie",
")",
"{",
"case",
"NGM_XXX_COOKIE",
":",
"switch",
"(",
"msg",
"->",
"header",
".",
"cmd",
")",
"{",
"case",
"NGM_XXX_GET_STATUS",
":",
"{",
"struct",
"ngxxxstat",
"*",
"stats",
";",
"NG_MKRESPONSE",
"(",
"resp",
",",
"msg",
",",
"sizeof",
"(",
"*",
"stats",
")",
",",
"M_WAITOK",
"|",
"M_NULLOK",
")",
";",
"if",
"(",
"!",
"resp",
")",
"{",
"error",
"=",
"ENOMEM",
";",
"break",
";",
"}",
"stats",
"=",
"(",
"struct",
"ngxxxstat",
"*",
")",
"resp",
"->",
"data",
";",
"stats",
"->",
"packets_in",
"=",
"xxxp",
"->",
"packets_in",
";",
"stats",
"->",
"packets_out",
"=",
"xxxp",
"->",
"packets_out",
";",
"break",
";",
"}",
"case",
"NGM_XXX_SET_FLAG",
":",
"if",
"(",
"msg",
"->",
"header",
".",
"arglen",
"!=",
"sizeof",
"(",
"u_int32_t",
")",
")",
"{",
"error",
"=",
"EINVAL",
";",
"break",
";",
"}",
"xxxp",
"->",
"flags",
"=",
"*",
"(",
"(",
"u_int32_t",
"*",
")",
"msg",
"->",
"data",
")",
";",
"break",
";",
"default",
":",
"error",
"=",
"EINVAL",
";",
"break",
";",
"}",
"break",
";",
"default",
":",
"error",
"=",
"EINVAL",
";",
"break",
";",
"}",
"NG_RESPOND_MSG",
"(",
"error",
",",
"node",
",",
"item",
",",
"resp",
")",
";",
"NG_FREE_MSG",
"(",
"msg",
")",
";",
"return",
"(",
"error",
")",
";",
"}"
] | Get a netgraph control message. | [
"Get",
"a",
"netgraph",
"control",
"message",
"."
] | [
"/* Deal with message according to cookie and command */",
"/* unknown command */",
"/* unknown cookie type */",
"/* Take care of synchronous response, if any */",
"/* Free the message and return */"
] | [
{
"param": "node",
"type": "node_p"
},
{
"param": "item",
"type": "item_p"
},
{
"param": "lasthook",
"type": "hook_p"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "node_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "item",
"type": "item_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lasthook",
"type": "hook_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8beb302e7c85551e05fbc9d19a0ec461c2aef5cf | atrens/DragonFlyBSD-src | sys/netgraph7/ng_sample.c | [
"BSD-3-Clause"
] | C | ng_xxx_rcvdata | int | static int
ng_xxx_rcvdata(hook_p hook, item_p item )
{
const xxx_p xxxp = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
int chan = -2;
int dlci = -2;
int error;
struct mbuf *m;
NGI_GET_M(item, m);
if (NG_HOOK_PRIVATE(hook)) {
dlci = ((struct XXX_hookinfo *) NG_HOOK_PRIVATE(hook))->dlci;
chan = ((struct XXX_hookinfo *) NG_HOOK_PRIVATE(hook))->channel;
if (dlci != -1) {
/* If received on a DLCI hook process for this
* channel and pass it to the downstream module.
* Normally one would add a multiplexing header at
* the front here */
/* M_PREPEND(....) ; */
/* mtod(m, xxxxxx)->dlci = dlci; */
NG_FWD_NEW_DATA(error, item,
xxxp->downstream_hook.hook, m);
xxxp->packets_out++;
} else {
/* data came from the multiplexed link */
dlci = 1; /* get dlci from header */
/* madjust(....) *//* chop off header */
for (chan = 0; chan < XXX_NUM_DLCIS; chan++)
if (xxxp->channel[chan].dlci == dlci)
break;
if (chan == XXX_NUM_DLCIS) {
NG_FREE_ITEM(item);
NG_FREE_M(m);
return (ENETUNREACH);
}
/* If we were called at splnet, use the following:
* NG_SEND_DATA_ONLY(error, otherhook, m); if this
* node is running at some SPL other than SPLNET
* then you should use instead: error =
* ng_queueit(otherhook, m, NULL); m = NULL;
* This queues the data using the standard NETISR
* system and schedules the data to be picked
* up again once the system has moved to SPLNET and
* the processing of the data can continue. After
* these are run 'm' should be considered
* as invalid and NG_SEND_DATA actually zaps them. */
NG_FWD_NEW_DATA(error, item,
xxxp->channel[chan].hook, m);
xxxp->packets_in++;
}
} else {
/* It's the debug hook, throw it away.. */
if (hook == xxxp->downstream_hook.hook) {
NG_FREE_ITEM(item);
NG_FREE_M(m);
}
}
return 0;
} | /*
* Receive data, and do something with it.
* Actually we receive a queue item which holds the data.
* If we free the item it will also free the data unless we have
* previously disassociated it using the NGI_GET_M() macro.
* Possibly send it out on another link after processing.
* Possibly do something different if it comes from different
* hooks. The caller will never free m, so if we use up this data or
* abort we must free it.
*
* If we want, we may decide to force this data to be queued and reprocessed
* at the netgraph NETISR time.
* We would do that by setting the HK_QUEUE flag on our hook. We would do that
* in the connect() method.
*/ | Receive data, and do something with it.
Actually we receive a queue item which holds the data.
If we free the item it will also free the data unless we have
previously disassociated it using the NGI_GET_M() macro.
Possibly send it out on another link after processing.
Possibly do something different if it comes from different
hooks. The caller will never free m, so if we use up this data or
abort we must free it.
If we want, we may decide to force this data to be queued and reprocessed
at the netgraph NETISR time.
We would do that by setting the HK_QUEUE flag on our hook. We would do that
in the connect() method. | [
"Receive",
"data",
"and",
"do",
"something",
"with",
"it",
".",
"Actually",
"we",
"receive",
"a",
"queue",
"item",
"which",
"holds",
"the",
"data",
".",
"If",
"we",
"free",
"the",
"item",
"it",
"will",
"also",
"free",
"the",
"data",
"unless",
"we",
"have",
"previously",
"disassociated",
"it",
"using",
"the",
"NGI_GET_M",
"()",
"macro",
".",
"Possibly",
"send",
"it",
"out",
"on",
"another",
"link",
"after",
"processing",
".",
"Possibly",
"do",
"something",
"different",
"if",
"it",
"comes",
"from",
"different",
"hooks",
".",
"The",
"caller",
"will",
"never",
"free",
"m",
"so",
"if",
"we",
"use",
"up",
"this",
"data",
"or",
"abort",
"we",
"must",
"free",
"it",
".",
"If",
"we",
"want",
"we",
"may",
"decide",
"to",
"force",
"this",
"data",
"to",
"be",
"queued",
"and",
"reprocessed",
"at",
"the",
"netgraph",
"NETISR",
"time",
".",
"We",
"would",
"do",
"that",
"by",
"setting",
"the",
"HK_QUEUE",
"flag",
"on",
"our",
"hook",
".",
"We",
"would",
"do",
"that",
"in",
"the",
"connect",
"()",
"method",
"."
] | static int
ng_xxx_rcvdata(hook_p hook, item_p item )
{
const xxx_p xxxp = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
int chan = -2;
int dlci = -2;
int error;
struct mbuf *m;
NGI_GET_M(item, m);
if (NG_HOOK_PRIVATE(hook)) {
dlci = ((struct XXX_hookinfo *) NG_HOOK_PRIVATE(hook))->dlci;
chan = ((struct XXX_hookinfo *) NG_HOOK_PRIVATE(hook))->channel;
if (dlci != -1) {
NG_FWD_NEW_DATA(error, item,
xxxp->downstream_hook.hook, m);
xxxp->packets_out++;
} else {
dlci = 1;
for (chan = 0; chan < XXX_NUM_DLCIS; chan++)
if (xxxp->channel[chan].dlci == dlci)
break;
if (chan == XXX_NUM_DLCIS) {
NG_FREE_ITEM(item);
NG_FREE_M(m);
return (ENETUNREACH);
}
NG_FWD_NEW_DATA(error, item,
xxxp->channel[chan].hook, m);
xxxp->packets_in++;
}
} else {
if (hook == xxxp->downstream_hook.hook) {
NG_FREE_ITEM(item);
NG_FREE_M(m);
}
}
return 0;
} | [
"static",
"int",
"ng_xxx_rcvdata",
"(",
"hook_p",
"hook",
",",
"item_p",
"item",
")",
"{",
"const",
"xxx_p",
"xxxp",
"=",
"NG_NODE_PRIVATE",
"(",
"NG_HOOK_NODE",
"(",
"hook",
")",
")",
";",
"int",
"chan",
"=",
"-2",
";",
"int",
"dlci",
"=",
"-2",
";",
"int",
"error",
";",
"struct",
"mbuf",
"*",
"m",
";",
"NGI_GET_M",
"(",
"item",
",",
"m",
")",
";",
"if",
"(",
"NG_HOOK_PRIVATE",
"(",
"hook",
")",
")",
"{",
"dlci",
"=",
"(",
"(",
"struct",
"XXX_hookinfo",
"*",
")",
"NG_HOOK_PRIVATE",
"(",
"hook",
")",
")",
"->",
"dlci",
";",
"chan",
"=",
"(",
"(",
"struct",
"XXX_hookinfo",
"*",
")",
"NG_HOOK_PRIVATE",
"(",
"hook",
")",
")",
"->",
"channel",
";",
"if",
"(",
"dlci",
"!=",
"-1",
")",
"{",
"NG_FWD_NEW_DATA",
"(",
"error",
",",
"item",
",",
"xxxp",
"->",
"downstream_hook",
".",
"hook",
",",
"m",
")",
";",
"xxxp",
"->",
"packets_out",
"++",
";",
"}",
"else",
"{",
"dlci",
"=",
"1",
";",
"for",
"(",
"chan",
"=",
"0",
";",
"chan",
"<",
"XXX_NUM_DLCIS",
";",
"chan",
"++",
")",
"if",
"(",
"xxxp",
"->",
"channel",
"[",
"chan",
"]",
".",
"dlci",
"==",
"dlci",
")",
"break",
";",
"if",
"(",
"chan",
"==",
"XXX_NUM_DLCIS",
")",
"{",
"NG_FREE_ITEM",
"(",
"item",
")",
";",
"NG_FREE_M",
"(",
"m",
")",
";",
"return",
"(",
"ENETUNREACH",
")",
";",
"}",
"NG_FWD_NEW_DATA",
"(",
"error",
",",
"item",
",",
"xxxp",
"->",
"channel",
"[",
"chan",
"]",
".",
"hook",
",",
"m",
")",
";",
"xxxp",
"->",
"packets_in",
"++",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"hook",
"==",
"xxxp",
"->",
"downstream_hook",
".",
"hook",
")",
"{",
"NG_FREE_ITEM",
"(",
"item",
")",
";",
"NG_FREE_M",
"(",
"m",
")",
";",
"}",
"}",
"return",
"0",
";",
"}"
] | Receive data, and do something with it. | [
"Receive",
"data",
"and",
"do",
"something",
"with",
"it",
"."
] | [
"/* If received on a DLCI hook process for this\n\t\t\t * channel and pass it to the downstream module.\n\t\t\t * Normally one would add a multiplexing header at\n\t\t\t * the front here */",
"/* M_PREPEND(....)\t; */",
"/* mtod(m, xxxxxx)->dlci = dlci; */",
"/* data came from the multiplexed link */",
"/* get dlci from header */",
"/* madjust(....) */",
"/* chop off header */",
"/* If we were called at splnet, use the following:\n\t\t\t * NG_SEND_DATA_ONLY(error, otherhook, m); if this\n\t\t\t * node is running at some SPL other than SPLNET\n\t\t\t * then you should use instead: error =\n\t\t\t * ng_queueit(otherhook, m, NULL); m = NULL;\n\t\t\t * This queues the data using the standard NETISR\n\t\t\t * system and schedules the data to be picked\n\t\t\t * up again once the system has moved to SPLNET and\n\t\t\t * the processing of the data can continue. After\n\t\t\t * these are run 'm' should be considered\n\t\t\t * as invalid and NG_SEND_DATA actually zaps them. */",
"/* It's the debug hook, throw it away.. */"
] | [
{
"param": "hook",
"type": "hook_p"
},
{
"param": "item",
"type": "item_p"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hook",
"type": "hook_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "item",
"type": "item_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8beb302e7c85551e05fbc9d19a0ec461c2aef5cf | atrens/DragonFlyBSD-src | sys/netgraph7/ng_sample.c | [
"BSD-3-Clause"
] | C | ng_xxx_shutdown | int | static int
ng_xxx_shutdown(node_p node)
{
const xxx_p privdata = NG_NODE_PRIVATE(node);
#ifndef PERSISTANT_NODE
NG_NODE_SET_PRIVATE(node, NULL);
NG_NODE_UNREF(node);
kfree(privdata, M_NETGRAPH);
#else
if (node->nd_flags & NGF_REALLY_DIE) {
/*
* WE came here because the widget card is being unloaded,
* so stop being persistant.
* Actually undo all the things we did on creation.
*/
NG_NODE_SET_PRIVATE(node, NULL);
NG_NODE_UNREF(privdata->node);
kfree(privdata, M_NETGRAPH);
return (0);
}
NG_NODE_REVIVE(node); /* tell ng_rmnode() we will persist */
#endif /* PERSISTANT_NODE */
return (0);
} | /*
* Do local shutdown processing..
* All our links and the name have already been removed.
* If we are a persistant device, we might refuse to go away.
* In the case of a persistant node we signal the framework that we
* are still in business by clearing the NGF_INVALID bit. However
* If we find the NGF_REALLY_DIE bit set, this means that
* we REALLY need to die (e.g. hardware removed).
* This would have been set using the NG_NODE_REALLY_DIE(node)
* macro in some device dependent function (not shown here) before
* calling ng_rmnode_self().
*/ | Do local shutdown processing
All our links and the name have already been removed.
If we are a persistant device, we might refuse to go away.
In the case of a persistant node we signal the framework that we
are still in business by clearing the NGF_INVALID bit. However
If we find the NGF_REALLY_DIE bit set, this means that
we REALLY need to die .
This would have been set using the NG_NODE_REALLY_DIE(node)
macro in some device dependent function (not shown here) before
calling ng_rmnode_self(). | [
"Do",
"local",
"shutdown",
"processing",
"All",
"our",
"links",
"and",
"the",
"name",
"have",
"already",
"been",
"removed",
".",
"If",
"we",
"are",
"a",
"persistant",
"device",
"we",
"might",
"refuse",
"to",
"go",
"away",
".",
"In",
"the",
"case",
"of",
"a",
"persistant",
"node",
"we",
"signal",
"the",
"framework",
"that",
"we",
"are",
"still",
"in",
"business",
"by",
"clearing",
"the",
"NGF_INVALID",
"bit",
".",
"However",
"If",
"we",
"find",
"the",
"NGF_REALLY_DIE",
"bit",
"set",
"this",
"means",
"that",
"we",
"REALLY",
"need",
"to",
"die",
".",
"This",
"would",
"have",
"been",
"set",
"using",
"the",
"NG_NODE_REALLY_DIE",
"(",
"node",
")",
"macro",
"in",
"some",
"device",
"dependent",
"function",
"(",
"not",
"shown",
"here",
")",
"before",
"calling",
"ng_rmnode_self",
"()",
"."
] | static int
ng_xxx_shutdown(node_p node)
{
const xxx_p privdata = NG_NODE_PRIVATE(node);
#ifndef PERSISTANT_NODE
NG_NODE_SET_PRIVATE(node, NULL);
NG_NODE_UNREF(node);
kfree(privdata, M_NETGRAPH);
#else
if (node->nd_flags & NGF_REALLY_DIE) {
NG_NODE_SET_PRIVATE(node, NULL);
NG_NODE_UNREF(privdata->node);
kfree(privdata, M_NETGRAPH);
return (0);
}
NG_NODE_REVIVE(node);
#endif
return (0);
} | [
"static",
"int",
"ng_xxx_shutdown",
"(",
"node_p",
"node",
")",
"{",
"const",
"xxx_p",
"privdata",
"=",
"NG_NODE_PRIVATE",
"(",
"node",
")",
";",
"#ifndef",
"PERSISTANT_NODE",
"NG_NODE_SET_PRIVATE",
"(",
"node",
",",
"NULL",
")",
";",
"NG_NODE_UNREF",
"(",
"node",
")",
";",
"kfree",
"(",
"privdata",
",",
"M_NETGRAPH",
")",
";",
"#else",
"if",
"(",
"node",
"->",
"nd_flags",
"&",
"NGF_REALLY_DIE",
")",
"{",
"NG_NODE_SET_PRIVATE",
"(",
"node",
",",
"NULL",
")",
";",
"NG_NODE_UNREF",
"(",
"privdata",
"->",
"node",
")",
";",
"kfree",
"(",
"privdata",
",",
"M_NETGRAPH",
")",
";",
"return",
"(",
"0",
")",
";",
"}",
"NG_NODE_REVIVE",
"(",
"node",
")",
";",
"#endif",
"return",
"(",
"0",
")",
";",
"}"
] | Do local shutdown processing..
All our links and the name have already been removed. | [
"Do",
"local",
"shutdown",
"processing",
"..",
"All",
"our",
"links",
"and",
"the",
"name",
"have",
"already",
"been",
"removed",
"."
] | [
"/*\n\t\t * WE came here because the widget card is being unloaded,\n\t\t * so stop being persistant.\n\t\t * Actually undo all the things we did on creation.\n\t\t */",
"/* tell ng_rmnode() we will persist */",
"/* PERSISTANT_NODE */"
] | [
{
"param": "node",
"type": "node_p"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "node_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8beb302e7c85551e05fbc9d19a0ec461c2aef5cf | atrens/DragonFlyBSD-src | sys/netgraph7/ng_sample.c | [
"BSD-3-Clause"
] | C | ng_xxx_disconnect | int | static int
ng_xxx_disconnect(hook_p hook)
{
if (NG_HOOK_PRIVATE(hook))
((struct XXX_hookinfo *) (NG_HOOK_PRIVATE(hook)))->hook = NULL;
if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
&& (NG_NODE_IS_VALID(NG_HOOK_NODE(hook)))) /* already shutting down? */
ng_rmnode_self(NG_HOOK_NODE(hook));
return (0);
} | /*
* Hook disconnection
*
* For this type, removal of the last link destroys the node
*/ | Hook disconnection
For this type, removal of the last link destroys the node | [
"Hook",
"disconnection",
"For",
"this",
"type",
"removal",
"of",
"the",
"last",
"link",
"destroys",
"the",
"node"
] | static int
ng_xxx_disconnect(hook_p hook)
{
if (NG_HOOK_PRIVATE(hook))
((struct XXX_hookinfo *) (NG_HOOK_PRIVATE(hook)))->hook = NULL;
if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
&& (NG_NODE_IS_VALID(NG_HOOK_NODE(hook))))
ng_rmnode_self(NG_HOOK_NODE(hook));
return (0);
} | [
"static",
"int",
"ng_xxx_disconnect",
"(",
"hook_p",
"hook",
")",
"{",
"if",
"(",
"NG_HOOK_PRIVATE",
"(",
"hook",
")",
")",
"(",
"(",
"struct",
"XXX_hookinfo",
"*",
")",
"(",
"NG_HOOK_PRIVATE",
"(",
"hook",
")",
")",
")",
"->",
"hook",
"=",
"NULL",
";",
"if",
"(",
"(",
"NG_NODE_NUMHOOKS",
"(",
"NG_HOOK_NODE",
"(",
"hook",
")",
")",
"==",
"0",
")",
"&&",
"(",
"NG_NODE_IS_VALID",
"(",
"NG_HOOK_NODE",
"(",
"hook",
")",
")",
")",
")",
"ng_rmnode_self",
"(",
"NG_HOOK_NODE",
"(",
"hook",
")",
")",
";",
"return",
"(",
"0",
")",
";",
"}"
] | Hook disconnection
For this type, removal of the last link destroys the node | [
"Hook",
"disconnection",
"For",
"this",
"type",
"removal",
"of",
"the",
"last",
"link",
"destroys",
"the",
"node"
] | [
"/* already shutting down? */"
] | [
{
"param": "hook",
"type": "hook_p"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hook",
"type": "hook_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
eb5210aef6c1e2ac3c4545ca4041effeb2ede1d9 | atrens/DragonFlyBSD-src | crypto/libressl/crypto/asn1/x_req.c | [
"BSD-3-Clause"
] | C | rinf_cb | int | static int
rinf_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg)
{
X509_REQ_INFO *rinf = (X509_REQ_INFO *)*pval;
if (operation == ASN1_OP_NEW_POST) {
rinf->attributes = sk_X509_ATTRIBUTE_new_null();
if (!rinf->attributes)
return 0;
}
return 1;
} | /* X509_REQ_INFO is handled in an unusual way to get round
* invalid encodings. Some broken certificate requests don't
* encode the attributes field if it is empty. This is in
* violation of PKCS#10 but we need to tolerate it. We do
* this by making the attributes field OPTIONAL then using
* the callback to initialise it to an empty STACK.
*
* This means that the field will be correctly encoded unless
* we NULL out the field.
*
* As a result we no longer need the req_kludge field because
* the information is now contained in the attributes field:
* 1. If it is NULL then it's the invalid omission.
* 2. If it is empty it is the correct encoding.
* 3. If it is not empty then some attributes are present.
*
*/ | X509_REQ_INFO is handled in an unusual way to get round
invalid encodings. Some broken certificate requests don't
encode the attributes field if it is empty. This is in
violation of PKCS#10 but we need to tolerate it. We do
this by making the attributes field OPTIONAL then using
the callback to initialise it to an empty STACK.
This means that the field will be correctly encoded unless
we NULL out the field.
As a result we no longer need the req_kludge field because
the information is now contained in the attributes field:
1. If it is NULL then it's the invalid omission.
2. If it is empty it is the correct encoding.
3. If it is not empty then some attributes are present. | [
"X509_REQ_INFO",
"is",
"handled",
"in",
"an",
"unusual",
"way",
"to",
"get",
"round",
"invalid",
"encodings",
".",
"Some",
"broken",
"certificate",
"requests",
"don",
"'",
"t",
"encode",
"the",
"attributes",
"field",
"if",
"it",
"is",
"empty",
".",
"This",
"is",
"in",
"violation",
"of",
"PKCS#10",
"but",
"we",
"need",
"to",
"tolerate",
"it",
".",
"We",
"do",
"this",
"by",
"making",
"the",
"attributes",
"field",
"OPTIONAL",
"then",
"using",
"the",
"callback",
"to",
"initialise",
"it",
"to",
"an",
"empty",
"STACK",
".",
"This",
"means",
"that",
"the",
"field",
"will",
"be",
"correctly",
"encoded",
"unless",
"we",
"NULL",
"out",
"the",
"field",
".",
"As",
"a",
"result",
"we",
"no",
"longer",
"need",
"the",
"req_kludge",
"field",
"because",
"the",
"information",
"is",
"now",
"contained",
"in",
"the",
"attributes",
"field",
":",
"1",
".",
"If",
"it",
"is",
"NULL",
"then",
"it",
"'",
"s",
"the",
"invalid",
"omission",
".",
"2",
".",
"If",
"it",
"is",
"empty",
"it",
"is",
"the",
"correct",
"encoding",
".",
"3",
".",
"If",
"it",
"is",
"not",
"empty",
"then",
"some",
"attributes",
"are",
"present",
"."
] | static int
rinf_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg)
{
X509_REQ_INFO *rinf = (X509_REQ_INFO *)*pval;
if (operation == ASN1_OP_NEW_POST) {
rinf->attributes = sk_X509_ATTRIBUTE_new_null();
if (!rinf->attributes)
return 0;
}
return 1;
} | [
"static",
"int",
"rinf_cb",
"(",
"int",
"operation",
",",
"ASN1_VALUE",
"*",
"*",
"pval",
",",
"const",
"ASN1_ITEM",
"*",
"it",
",",
"void",
"*",
"exarg",
")",
"{",
"X509_REQ_INFO",
"*",
"rinf",
"=",
"(",
"X509_REQ_INFO",
"*",
")",
"*",
"pval",
";",
"if",
"(",
"operation",
"==",
"ASN1_OP_NEW_POST",
")",
"{",
"rinf",
"->",
"attributes",
"=",
"sk_X509_ATTRIBUTE_new_null",
"(",
")",
";",
"if",
"(",
"!",
"rinf",
"->",
"attributes",
")",
"return",
"0",
";",
"}",
"return",
"1",
";",
"}"
] | X509_REQ_INFO is handled in an unusual way to get round
invalid encodings. | [
"X509_REQ_INFO",
"is",
"handled",
"in",
"an",
"unusual",
"way",
"to",
"get",
"round",
"invalid",
"encodings",
"."
] | [] | [
{
"param": "operation",
"type": "int"
},
{
"param": "pval",
"type": "ASN1_VALUE"
},
{
"param": "it",
"type": "ASN1_ITEM"
},
{
"param": "exarg",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "operation",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pval",
"type": "ASN1_VALUE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "it",
"type": "ASN1_ITEM",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "exarg",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a8e33bdbc3f66eb91fc2517414884080337b1997 | atrens/DragonFlyBSD-src | contrib/tnftp/src/cmds.c | [
"BSD-3-Clause"
] | C | changetype | void | void
changetype(int newtype, int show)
{
struct types *p;
int comret, oldverbose = verbose;
if (newtype == 0)
newtype = TYPE_I;
if (newtype == curtype)
return;
if (ftp_debug == 0 && show == 0)
verbose = 0;
for (p = types; p->t_name; p++)
if (newtype == p->t_type)
break;
if (p->t_name == 0) {
errx(1, "changetype: unknown type %d", newtype);
}
if (newtype == TYPE_L && bytename[0] != '\0')
comret = command("TYPE %s %s", p->t_mode, bytename);
else
comret = command("TYPE %s", p->t_mode);
if (comret == COMPLETE)
curtype = newtype;
verbose = oldverbose;
} | /*
* Internal form of settype; changes current type in use with server
* without changing our notion of the type for data transfers.
* Used to change to and from ascii for listings.
*/ | Internal form of settype; changes current type in use with server
without changing our notion of the type for data transfers.
Used to change to and from ascii for listings. | [
"Internal",
"form",
"of",
"settype",
";",
"changes",
"current",
"type",
"in",
"use",
"with",
"server",
"without",
"changing",
"our",
"notion",
"of",
"the",
"type",
"for",
"data",
"transfers",
".",
"Used",
"to",
"change",
"to",
"and",
"from",
"ascii",
"for",
"listings",
"."
] | void
changetype(int newtype, int show)
{
struct types *p;
int comret, oldverbose = verbose;
if (newtype == 0)
newtype = TYPE_I;
if (newtype == curtype)
return;
if (ftp_debug == 0 && show == 0)
verbose = 0;
for (p = types; p->t_name; p++)
if (newtype == p->t_type)
break;
if (p->t_name == 0) {
errx(1, "changetype: unknown type %d", newtype);
}
if (newtype == TYPE_L && bytename[0] != '\0')
comret = command("TYPE %s %s", p->t_mode, bytename);
else
comret = command("TYPE %s", p->t_mode);
if (comret == COMPLETE)
curtype = newtype;
verbose = oldverbose;
} | [
"void",
"changetype",
"(",
"int",
"newtype",
",",
"int",
"show",
")",
"{",
"struct",
"types",
"*",
"p",
";",
"int",
"comret",
",",
"oldverbose",
"=",
"verbose",
";",
"if",
"(",
"newtype",
"==",
"0",
")",
"newtype",
"=",
"TYPE_I",
";",
"if",
"(",
"newtype",
"==",
"curtype",
")",
"return",
";",
"if",
"(",
"ftp_debug",
"==",
"0",
"&&",
"show",
"==",
"0",
")",
"verbose",
"=",
"0",
";",
"for",
"(",
"p",
"=",
"types",
";",
"p",
"->",
"t_name",
";",
"p",
"++",
")",
"if",
"(",
"newtype",
"==",
"p",
"->",
"t_type",
")",
"break",
";",
"if",
"(",
"p",
"->",
"t_name",
"==",
"0",
")",
"{",
"errx",
"(",
"1",
",",
"\"",
"\"",
",",
"newtype",
")",
";",
"}",
"if",
"(",
"newtype",
"==",
"TYPE_L",
"&&",
"bytename",
"[",
"0",
"]",
"!=",
"'",
"\\0",
"'",
")",
"comret",
"=",
"command",
"(",
"\"",
"\"",
",",
"p",
"->",
"t_mode",
",",
"bytename",
")",
";",
"else",
"comret",
"=",
"command",
"(",
"\"",
"\"",
",",
"p",
"->",
"t_mode",
")",
";",
"if",
"(",
"comret",
"==",
"COMPLETE",
")",
"curtype",
"=",
"newtype",
";",
"verbose",
"=",
"oldverbose",
";",
"}"
] | Internal form of settype; changes current type in use with server
without changing our notion of the type for data transfers. | [
"Internal",
"form",
"of",
"settype",
";",
"changes",
"current",
"type",
"in",
"use",
"with",
"server",
"without",
"changing",
"our",
"notion",
"of",
"the",
"type",
"for",
"data",
"transfers",
"."
] | [] | [
{
"param": "newtype",
"type": "int"
},
{
"param": "show",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "newtype",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "show",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a8e33bdbc3f66eb91fc2517414884080337b1997 | atrens/DragonFlyBSD-src | contrib/tnftp/src/cmds.c | [
"BSD-3-Clause"
] | C | fget | void | void
fget(int argc, char *argv[])
{
const char *gmode;
FILE *fp;
char buf[MAXPATHLEN], cmdbuf[MAX_C_NAME];
if (argc != 2) {
UPRINTF("usage: %s localfile\n", argv[0]);
code = -1;
return;
}
fp = fopen(argv[1], "r");
if (fp == NULL) {
fprintf(ttyout, "Can't open source file %s\n", argv[1]);
code = -1;
return;
}
(void)strlcpy(cmdbuf, "get", sizeof(cmdbuf));
argv[0] = cmdbuf;
gmode = restart_point ? "r+" : "w";
while (get_line(fp, buf, sizeof(buf), NULL) >= 0) {
if (buf[0] == '\0')
continue;
argv[1] = buf;
(void)getit(argc, argv, 0, gmode);
}
fclose(fp);
} | /*
* Read list of filenames from a local file and get those
*/ | Read list of filenames from a local file and get those | [
"Read",
"list",
"of",
"filenames",
"from",
"a",
"local",
"file",
"and",
"get",
"those"
] | void
fget(int argc, char *argv[])
{
const char *gmode;
FILE *fp;
char buf[MAXPATHLEN], cmdbuf[MAX_C_NAME];
if (argc != 2) {
UPRINTF("usage: %s localfile\n", argv[0]);
code = -1;
return;
}
fp = fopen(argv[1], "r");
if (fp == NULL) {
fprintf(ttyout, "Can't open source file %s\n", argv[1]);
code = -1;
return;
}
(void)strlcpy(cmdbuf, "get", sizeof(cmdbuf));
argv[0] = cmdbuf;
gmode = restart_point ? "r+" : "w";
while (get_line(fp, buf, sizeof(buf), NULL) >= 0) {
if (buf[0] == '\0')
continue;
argv[1] = buf;
(void)getit(argc, argv, 0, gmode);
}
fclose(fp);
} | [
"void",
"fget",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
")",
"{",
"const",
"char",
"*",
"gmode",
";",
"FILE",
"*",
"fp",
";",
"char",
"buf",
"[",
"MAXPATHLEN",
"]",
",",
"cmdbuf",
"[",
"MAX_C_NAME",
"]",
";",
"if",
"(",
"argc",
"!=",
"2",
")",
"{",
"UPRINTF",
"(",
"\"",
"\\n",
"\"",
",",
"argv",
"[",
"0",
"]",
")",
";",
"code",
"=",
"-1",
";",
"return",
";",
"}",
"fp",
"=",
"fopen",
"(",
"argv",
"[",
"1",
"]",
",",
"\"",
"\"",
")",
";",
"if",
"(",
"fp",
"==",
"NULL",
")",
"{",
"fprintf",
"(",
"ttyout",
",",
"\"",
"\\n",
"\"",
",",
"argv",
"[",
"1",
"]",
")",
";",
"code",
"=",
"-1",
";",
"return",
";",
"}",
"(",
"void",
")",
"strlcpy",
"(",
"cmdbuf",
",",
"\"",
"\"",
",",
"sizeof",
"(",
"cmdbuf",
")",
")",
";",
"argv",
"[",
"0",
"]",
"=",
"cmdbuf",
";",
"gmode",
"=",
"restart_point",
"?",
"\"",
"\"",
":",
"\"",
"\"",
";",
"while",
"(",
"get_line",
"(",
"fp",
",",
"buf",
",",
"sizeof",
"(",
"buf",
")",
",",
"NULL",
")",
">=",
"0",
")",
"{",
"if",
"(",
"buf",
"[",
"0",
"]",
"==",
"'",
"\\0",
"'",
")",
"continue",
";",
"argv",
"[",
"1",
"]",
"=",
"buf",
";",
"(",
"void",
")",
"getit",
"(",
"argc",
",",
"argv",
",",
"0",
",",
"gmode",
")",
";",
"}",
"fclose",
"(",
"fp",
")",
";",
"}"
] | Read list of filenames from a local file and get those | [
"Read",
"list",
"of",
"filenames",
"from",
"a",
"local",
"file",
"and",
"get",
"those"
] | [] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"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
}
],
"outlier_params": [],
"others": []
} |
a8e33bdbc3f66eb91fc2517414884080337b1997 | atrens/DragonFlyBSD-src | contrib/tnftp/src/cmds.c | [
"BSD-3-Clause"
] | C | cd | void | void
cd(int argc, char *argv[])
{
int r;
if (argc == 0 || argc > 2 ||
(argc == 1 && !another(&argc, &argv, "remote-directory"))) {
UPRINTF("usage: %s remote-directory\n", argv[0]);
code = -1;
return;
}
r = command("CWD %s", argv[1]);
if (r == ERROR && code == 500) {
if (verbose)
fputs("CWD command not recognized, trying XCWD.\n",
ttyout);
r = command("XCWD %s", argv[1]);
}
if (r == COMPLETE) {
dirchange = 1;
updateremotecwd();
}
} | /*
* Set current working directory on remote machine.
*/ | Set current working directory on remote machine. | [
"Set",
"current",
"working",
"directory",
"on",
"remote",
"machine",
"."
] | void
cd(int argc, char *argv[])
{
int r;
if (argc == 0 || argc > 2 ||
(argc == 1 && !another(&argc, &argv, "remote-directory"))) {
UPRINTF("usage: %s remote-directory\n", argv[0]);
code = -1;
return;
}
r = command("CWD %s", argv[1]);
if (r == ERROR && code == 500) {
if (verbose)
fputs("CWD command not recognized, trying XCWD.\n",
ttyout);
r = command("XCWD %s", argv[1]);
}
if (r == COMPLETE) {
dirchange = 1;
updateremotecwd();
}
} | [
"void",
"cd",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
")",
"{",
"int",
"r",
";",
"if",
"(",
"argc",
"==",
"0",
"||",
"argc",
">",
"2",
"||",
"(",
"argc",
"==",
"1",
"&&",
"!",
"another",
"(",
"&",
"argc",
",",
"&",
"argv",
",",
"\"",
"\"",
")",
")",
")",
"{",
"UPRINTF",
"(",
"\"",
"\\n",
"\"",
",",
"argv",
"[",
"0",
"]",
")",
";",
"code",
"=",
"-1",
";",
"return",
";",
"}",
"r",
"=",
"command",
"(",
"\"",
"\"",
",",
"argv",
"[",
"1",
"]",
")",
";",
"if",
"(",
"r",
"==",
"ERROR",
"&&",
"code",
"==",
"500",
")",
"{",
"if",
"(",
"verbose",
")",
"fputs",
"(",
"\"",
"\\n",
"\"",
",",
"ttyout",
")",
";",
"r",
"=",
"command",
"(",
"\"",
"\"",
",",
"argv",
"[",
"1",
"]",
")",
";",
"}",
"if",
"(",
"r",
"==",
"COMPLETE",
")",
"{",
"dirchange",
"=",
"1",
";",
"updateremotecwd",
"(",
")",
";",
"}",
"}"
] | Set current working directory on remote machine. | [
"Set",
"current",
"working",
"directory",
"on",
"remote",
"machine",
"."
] | [] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"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
}
],
"outlier_params": [],
"others": []
} |
a8e33bdbc3f66eb91fc2517414884080337b1997 | atrens/DragonFlyBSD-src | contrib/tnftp/src/cmds.c | [
"BSD-3-Clause"
] | C | lcd | void | void
lcd(int argc, char *argv[])
{
char *locdir;
code = -1;
if (argc == 1) {
argc++;
argv[1] = localhome;
}
if (argc != 2) {
UPRINTF("usage: %s [local-directory]\n", argv[0]);
return;
}
if ((locdir = globulize(argv[1])) == NULL)
return;
if (chdir(locdir) == -1)
warn("Can't chdir `%s'", locdir);
else {
updatelocalcwd();
if (localcwd[0]) {
fprintf(ttyout, "Local directory now: %s\n", localcwd);
code = 0;
} else {
fprintf(ttyout, "Unable to determine local directory\n");
}
}
(void)free(locdir);
} | /*
* Set current working directory on local machine.
*/ | Set current working directory on local machine. | [
"Set",
"current",
"working",
"directory",
"on",
"local",
"machine",
"."
] | void
lcd(int argc, char *argv[])
{
char *locdir;
code = -1;
if (argc == 1) {
argc++;
argv[1] = localhome;
}
if (argc != 2) {
UPRINTF("usage: %s [local-directory]\n", argv[0]);
return;
}
if ((locdir = globulize(argv[1])) == NULL)
return;
if (chdir(locdir) == -1)
warn("Can't chdir `%s'", locdir);
else {
updatelocalcwd();
if (localcwd[0]) {
fprintf(ttyout, "Local directory now: %s\n", localcwd);
code = 0;
} else {
fprintf(ttyout, "Unable to determine local directory\n");
}
}
(void)free(locdir);
} | [
"void",
"lcd",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
")",
"{",
"char",
"*",
"locdir",
";",
"code",
"=",
"-1",
";",
"if",
"(",
"argc",
"==",
"1",
")",
"{",
"argc",
"++",
";",
"argv",
"[",
"1",
"]",
"=",
"localhome",
";",
"}",
"if",
"(",
"argc",
"!=",
"2",
")",
"{",
"UPRINTF",
"(",
"\"",
"\\n",
"\"",
",",
"argv",
"[",
"0",
"]",
")",
";",
"return",
";",
"}",
"if",
"(",
"(",
"locdir",
"=",
"globulize",
"(",
"argv",
"[",
"1",
"]",
")",
")",
"==",
"NULL",
")",
"return",
";",
"if",
"(",
"chdir",
"(",
"locdir",
")",
"==",
"-1",
")",
"warn",
"(",
"\"",
"\"",
",",
"locdir",
")",
";",
"else",
"{",
"updatelocalcwd",
"(",
")",
";",
"if",
"(",
"localcwd",
"[",
"0",
"]",
")",
"{",
"fprintf",
"(",
"ttyout",
",",
"\"",
"\\n",
"\"",
",",
"localcwd",
")",
";",
"code",
"=",
"0",
";",
"}",
"else",
"{",
"fprintf",
"(",
"ttyout",
",",
"\"",
"\\n",
"\"",
")",
";",
"}",
"}",
"(",
"void",
")",
"free",
"(",
"locdir",
")",
";",
"}"
] | Set current working directory on local machine. | [
"Set",
"current",
"working",
"directory",
"on",
"local",
"machine",
"."
] | [] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"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
}
],
"outlier_params": [],
"others": []
} |
a8e33bdbc3f66eb91fc2517414884080337b1997 | atrens/DragonFlyBSD-src | contrib/tnftp/src/cmds.c | [
"BSD-3-Clause"
] | C | mls | void | void
mls(int argc, char *argv[])
{
sigfunc oldintr;
int ointer, i;
int volatile dolist;
char * volatile dest, *odest;
const char *lmode;
if (argc == 0)
goto usage;
if (argc < 2 && !another(&argc, &argv, "remote-files"))
goto usage;
if (argc < 3 && !another(&argc, &argv, "local-file")) {
usage:
UPRINTF("usage: %s remote-files local-file\n", argv[0]);
code = -1;
return;
}
odest = dest = argv[argc - 1];
argv[argc - 1] = NULL;
if (strcmp(dest, "-") && *dest != '|')
if (((dest = globulize(dest)) == NULL) ||
!confirm("output to local-file:", dest)) {
code = -1;
return;
}
dolist = strcmp(argv[0], "mls");
mflag = 1;
oldintr = xsignal(SIGINT, mintr);
if (sigsetjmp(jabort, 1))
mabort(argv[0]);
for (i = 1; mflag && i < argc-1 && connected; i++) {
lmode = (i == 1) ? "w" : "a";
recvrequest(dolist ? "LIST" : "NLST", dest, argv[i], lmode,
0, 0);
if (!mflag && fromatty) {
ointer = interactive;
interactive = 1;
if (confirm(argv[0], NULL)) {
mflag++;
}
interactive = ointer;
}
}
(void)xsignal(SIGINT, oldintr);
mflag = 0;
if (dest != odest) /* free up after globulize() */
free(dest);
} | /*
* Get a directory listing of multiple remote files.
*/ | Get a directory listing of multiple remote files. | [
"Get",
"a",
"directory",
"listing",
"of",
"multiple",
"remote",
"files",
"."
] | void
mls(int argc, char *argv[])
{
sigfunc oldintr;
int ointer, i;
int volatile dolist;
char * volatile dest, *odest;
const char *lmode;
if (argc == 0)
goto usage;
if (argc < 2 && !another(&argc, &argv, "remote-files"))
goto usage;
if (argc < 3 && !another(&argc, &argv, "local-file")) {
usage:
UPRINTF("usage: %s remote-files local-file\n", argv[0]);
code = -1;
return;
}
odest = dest = argv[argc - 1];
argv[argc - 1] = NULL;
if (strcmp(dest, "-") && *dest != '|')
if (((dest = globulize(dest)) == NULL) ||
!confirm("output to local-file:", dest)) {
code = -1;
return;
}
dolist = strcmp(argv[0], "mls");
mflag = 1;
oldintr = xsignal(SIGINT, mintr);
if (sigsetjmp(jabort, 1))
mabort(argv[0]);
for (i = 1; mflag && i < argc-1 && connected; i++) {
lmode = (i == 1) ? "w" : "a";
recvrequest(dolist ? "LIST" : "NLST", dest, argv[i], lmode,
0, 0);
if (!mflag && fromatty) {
ointer = interactive;
interactive = 1;
if (confirm(argv[0], NULL)) {
mflag++;
}
interactive = ointer;
}
}
(void)xsignal(SIGINT, oldintr);
mflag = 0;
if (dest != odest)
free(dest);
} | [
"void",
"mls",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
")",
"{",
"sigfunc",
"oldintr",
";",
"int",
"ointer",
",",
"i",
";",
"int",
"volatile",
"dolist",
";",
"char",
"*",
"volatile",
"dest",
",",
"*",
"odest",
";",
"const",
"char",
"*",
"lmode",
";",
"if",
"(",
"argc",
"==",
"0",
")",
"goto",
"usage",
";",
"if",
"(",
"argc",
"<",
"2",
"&&",
"!",
"another",
"(",
"&",
"argc",
",",
"&",
"argv",
",",
"\"",
"\"",
")",
")",
"goto",
"usage",
";",
"if",
"(",
"argc",
"<",
"3",
"&&",
"!",
"another",
"(",
"&",
"argc",
",",
"&",
"argv",
",",
"\"",
"\"",
")",
")",
"{",
"usage",
":",
"UPRINTF",
"(",
"\"",
"\\n",
"\"",
",",
"argv",
"[",
"0",
"]",
")",
";",
"code",
"=",
"-1",
";",
"return",
";",
"}",
"odest",
"=",
"dest",
"=",
"argv",
"[",
"argc",
"-",
"1",
"]",
";",
"argv",
"[",
"argc",
"-",
"1",
"]",
"=",
"NULL",
";",
"if",
"(",
"strcmp",
"(",
"dest",
",",
"\"",
"\"",
")",
"&&",
"*",
"dest",
"!=",
"'",
"'",
")",
"if",
"(",
"(",
"(",
"dest",
"=",
"globulize",
"(",
"dest",
")",
")",
"==",
"NULL",
")",
"||",
"!",
"confirm",
"(",
"\"",
"\"",
",",
"dest",
")",
")",
"{",
"code",
"=",
"-1",
";",
"return",
";",
"}",
"dolist",
"=",
"strcmp",
"(",
"argv",
"[",
"0",
"]",
",",
"\"",
"\"",
")",
";",
"mflag",
"=",
"1",
";",
"oldintr",
"=",
"xsignal",
"(",
"SIGINT",
",",
"mintr",
")",
";",
"if",
"(",
"sigsetjmp",
"(",
"jabort",
",",
"1",
")",
")",
"mabort",
"(",
"argv",
"[",
"0",
"]",
")",
";",
"for",
"(",
"i",
"=",
"1",
";",
"mflag",
"&&",
"i",
"<",
"argc",
"-",
"1",
"&&",
"connected",
";",
"i",
"++",
")",
"{",
"lmode",
"=",
"(",
"i",
"==",
"1",
")",
"?",
"\"",
"\"",
":",
"\"",
"\"",
";",
"recvrequest",
"(",
"dolist",
"?",
"\"",
"\"",
":",
"\"",
"\"",
",",
"dest",
",",
"argv",
"[",
"i",
"]",
",",
"lmode",
",",
"0",
",",
"0",
")",
";",
"if",
"(",
"!",
"mflag",
"&&",
"fromatty",
")",
"{",
"ointer",
"=",
"interactive",
";",
"interactive",
"=",
"1",
";",
"if",
"(",
"confirm",
"(",
"argv",
"[",
"0",
"]",
",",
"NULL",
")",
")",
"{",
"mflag",
"++",
";",
"}",
"interactive",
"=",
"ointer",
";",
"}",
"}",
"(",
"void",
")",
"xsignal",
"(",
"SIGINT",
",",
"oldintr",
")",
";",
"mflag",
"=",
"0",
";",
"if",
"(",
"dest",
"!=",
"odest",
")",
"free",
"(",
"dest",
")",
";",
"}"
] | Get a directory listing of multiple remote files. | [
"Get",
"a",
"directory",
"listing",
"of",
"multiple",
"remote",
"files",
"."
] | [
"/* free up after globulize() */"
] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"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
}
],
"outlier_params": [],
"others": []
} |
a8e33bdbc3f66eb91fc2517414884080337b1997 | atrens/DragonFlyBSD-src | contrib/tnftp/src/cmds.c | [
"BSD-3-Clause"
] | C | user | void | void
user(int argc, char *argv[])
{
char *password;
char emptypass[] = "";
int n, aflag = 0;
if (argc == 0)
goto usage;
if (argc < 2)
(void)another(&argc, &argv, "username");
if (argc < 2 || argc > 4) {
usage:
UPRINTF("usage: %s username [password [account]]\n",
argv[0]);
code = -1;
return;
}
n = command("USER %s", argv[1]);
if (n == CONTINUE) {
if (argc < 3) {
password = getpass("Password: ");
if (password == NULL)
password = emptypass;
} else {
password = argv[2];
}
n = command("PASS %s", password);
memset(password, 0, strlen(password));
}
if (n == CONTINUE) {
aflag++;
if (argc < 4) {
password = getpass("Account: ");
if (password == NULL)
password = emptypass;
} else {
password = argv[3];
}
n = command("ACCT %s", password);
memset(password, 0, strlen(password));
}
if (n != COMPLETE) {
fputs("Login failed.\n", ttyout);
return;
}
if (!aflag && argc == 4) {
password = argv[3];
(void)command("ACCT %s", password);
memset(password, 0, strlen(password));
}
connected = -1;
getremoteinfo();
} | /*
* Send new user information (re-login)
*/ | Send new user information (re-login) | [
"Send",
"new",
"user",
"information",
"(",
"re",
"-",
"login",
")"
] | void
user(int argc, char *argv[])
{
char *password;
char emptypass[] = "";
int n, aflag = 0;
if (argc == 0)
goto usage;
if (argc < 2)
(void)another(&argc, &argv, "username");
if (argc < 2 || argc > 4) {
usage:
UPRINTF("usage: %s username [password [account]]\n",
argv[0]);
code = -1;
return;
}
n = command("USER %s", argv[1]);
if (n == CONTINUE) {
if (argc < 3) {
password = getpass("Password: ");
if (password == NULL)
password = emptypass;
} else {
password = argv[2];
}
n = command("PASS %s", password);
memset(password, 0, strlen(password));
}
if (n == CONTINUE) {
aflag++;
if (argc < 4) {
password = getpass("Account: ");
if (password == NULL)
password = emptypass;
} else {
password = argv[3];
}
n = command("ACCT %s", password);
memset(password, 0, strlen(password));
}
if (n != COMPLETE) {
fputs("Login failed.\n", ttyout);
return;
}
if (!aflag && argc == 4) {
password = argv[3];
(void)command("ACCT %s", password);
memset(password, 0, strlen(password));
}
connected = -1;
getremoteinfo();
} | [
"void",
"user",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
")",
"{",
"char",
"*",
"password",
";",
"char",
"emptypass",
"[",
"]",
"=",
"\"",
"\"",
";",
"int",
"n",
",",
"aflag",
"=",
"0",
";",
"if",
"(",
"argc",
"==",
"0",
")",
"goto",
"usage",
";",
"if",
"(",
"argc",
"<",
"2",
")",
"(",
"void",
")",
"another",
"(",
"&",
"argc",
",",
"&",
"argv",
",",
"\"",
"\"",
")",
";",
"if",
"(",
"argc",
"<",
"2",
"||",
"argc",
">",
"4",
")",
"{",
"usage",
":",
"UPRINTF",
"(",
"\"",
"\\n",
"\"",
",",
"argv",
"[",
"0",
"]",
")",
";",
"code",
"=",
"-1",
";",
"return",
";",
"}",
"n",
"=",
"command",
"(",
"\"",
"\"",
",",
"argv",
"[",
"1",
"]",
")",
";",
"if",
"(",
"n",
"==",
"CONTINUE",
")",
"{",
"if",
"(",
"argc",
"<",
"3",
")",
"{",
"password",
"=",
"getpass",
"(",
"\"",
"\"",
")",
";",
"if",
"(",
"password",
"==",
"NULL",
")",
"password",
"=",
"emptypass",
";",
"}",
"else",
"{",
"password",
"=",
"argv",
"[",
"2",
"]",
";",
"}",
"n",
"=",
"command",
"(",
"\"",
"\"",
",",
"password",
")",
";",
"memset",
"(",
"password",
",",
"0",
",",
"strlen",
"(",
"password",
")",
")",
";",
"}",
"if",
"(",
"n",
"==",
"CONTINUE",
")",
"{",
"aflag",
"++",
";",
"if",
"(",
"argc",
"<",
"4",
")",
"{",
"password",
"=",
"getpass",
"(",
"\"",
"\"",
")",
";",
"if",
"(",
"password",
"==",
"NULL",
")",
"password",
"=",
"emptypass",
";",
"}",
"else",
"{",
"password",
"=",
"argv",
"[",
"3",
"]",
";",
"}",
"n",
"=",
"command",
"(",
"\"",
"\"",
",",
"password",
")",
";",
"memset",
"(",
"password",
",",
"0",
",",
"strlen",
"(",
"password",
")",
")",
";",
"}",
"if",
"(",
"n",
"!=",
"COMPLETE",
")",
"{",
"fputs",
"(",
"\"",
"\\n",
"\"",
",",
"ttyout",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"aflag",
"&&",
"argc",
"==",
"4",
")",
"{",
"password",
"=",
"argv",
"[",
"3",
"]",
";",
"(",
"void",
")",
"command",
"(",
"\"",
"\"",
",",
"password",
")",
";",
"memset",
"(",
"password",
",",
"0",
",",
"strlen",
"(",
"password",
")",
")",
";",
"}",
"connected",
"=",
"-1",
";",
"getremoteinfo",
"(",
")",
";",
"}"
] | Send new user information (re-login) | [
"Send",
"new",
"user",
"information",
"(",
"re",
"-",
"login",
")"
] | [] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"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
}
],
"outlier_params": [],
"others": []
} |
a8e33bdbc3f66eb91fc2517414884080337b1997 | atrens/DragonFlyBSD-src | contrib/tnftp/src/cmds.c | [
"BSD-3-Clause"
] | C | lpwd | void | void
lpwd(int argc, char *argv[])
{
code = -1;
if (argc != 1) {
UPRINTF("usage: %s\n", argv[0]);
return;
}
if (! localcwd[0])
updatelocalcwd();
if (! localcwd[0])
fprintf(ttyout, "Unable to determine local directory\n");
else {
fprintf(ttyout, "Local directory: %s\n", localcwd);
code = 0;
}
} | /*
* Print working directory on local machine.
*/ | Print working directory on local machine. | [
"Print",
"working",
"directory",
"on",
"local",
"machine",
"."
] | void
lpwd(int argc, char *argv[])
{
code = -1;
if (argc != 1) {
UPRINTF("usage: %s\n", argv[0]);
return;
}
if (! localcwd[0])
updatelocalcwd();
if (! localcwd[0])
fprintf(ttyout, "Unable to determine local directory\n");
else {
fprintf(ttyout, "Local directory: %s\n", localcwd);
code = 0;
}
} | [
"void",
"lpwd",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
")",
"{",
"code",
"=",
"-1",
";",
"if",
"(",
"argc",
"!=",
"1",
")",
"{",
"UPRINTF",
"(",
"\"",
"\\n",
"\"",
",",
"argv",
"[",
"0",
"]",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"localcwd",
"[",
"0",
"]",
")",
"updatelocalcwd",
"(",
")",
";",
"if",
"(",
"!",
"localcwd",
"[",
"0",
"]",
")",
"fprintf",
"(",
"ttyout",
",",
"\"",
"\\n",
"\"",
")",
";",
"else",
"{",
"fprintf",
"(",
"ttyout",
",",
"\"",
"\\n",
"\"",
",",
"localcwd",
")",
";",
"code",
"=",
"0",
";",
"}",
"}"
] | Print working directory on local machine. | [
"Print",
"working",
"directory",
"on",
"local",
"machine",
"."
] | [] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"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
}
],
"outlier_params": [],
"others": []
} |
a8e33bdbc3f66eb91fc2517414884080337b1997 | atrens/DragonFlyBSD-src | contrib/tnftp/src/cmds.c | [
"BSD-3-Clause"
] | C | quote | void | void
quote(int argc, char *argv[])
{
if (argc == 0 ||
(argc == 1 && !another(&argc, &argv, "command line to send"))) {
UPRINTF("usage: %s line-to-send\n", argv[0]);
code = -1;
return;
}
quote1("", argc, argv);
} | /*
* Send a line, verbatim, to the remote machine.
*/ | Send a line, verbatim, to the remote machine. | [
"Send",
"a",
"line",
"verbatim",
"to",
"the",
"remote",
"machine",
"."
] | void
quote(int argc, char *argv[])
{
if (argc == 0 ||
(argc == 1 && !another(&argc, &argv, "command line to send"))) {
UPRINTF("usage: %s line-to-send\n", argv[0]);
code = -1;
return;
}
quote1("", argc, argv);
} | [
"void",
"quote",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
")",
"{",
"if",
"(",
"argc",
"==",
"0",
"||",
"(",
"argc",
"==",
"1",
"&&",
"!",
"another",
"(",
"&",
"argc",
",",
"&",
"argv",
",",
"\"",
"\"",
")",
")",
")",
"{",
"UPRINTF",
"(",
"\"",
"\\n",
"\"",
",",
"argv",
"[",
"0",
"]",
")",
";",
"code",
"=",
"-1",
";",
"return",
";",
"}",
"quote1",
"(",
"\"",
"\"",
",",
"argc",
",",
"argv",
")",
";",
"}"
] | Send a line, verbatim, to the remote machine. | [
"Send",
"a",
"line",
"verbatim",
"to",
"the",
"remote",
"machine",
"."
] | [] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"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
}
],
"outlier_params": [],
"others": []
} |
a8e33bdbc3f66eb91fc2517414884080337b1997 | atrens/DragonFlyBSD-src | contrib/tnftp/src/cmds.c | [
"BSD-3-Clause"
] | C | site | void | void
site(int argc, char *argv[])
{
if (argc == 0 ||
(argc == 1 && !another(&argc, &argv, "arguments to SITE command"))){
UPRINTF("usage: %s line-to-send\n", argv[0]);
code = -1;
return;
}
quote1("SITE ", argc, argv);
} | /*
* Send a SITE command to the remote machine. The line
* is sent verbatim to the remote machine, except that the
* word "SITE" is added at the front.
*/ | Send a SITE command to the remote machine. The line
is sent verbatim to the remote machine, except that the
word "SITE" is added at the front. | [
"Send",
"a",
"SITE",
"command",
"to",
"the",
"remote",
"machine",
".",
"The",
"line",
"is",
"sent",
"verbatim",
"to",
"the",
"remote",
"machine",
"except",
"that",
"the",
"word",
"\"",
"SITE",
"\"",
"is",
"added",
"at",
"the",
"front",
"."
] | void
site(int argc, char *argv[])
{
if (argc == 0 ||
(argc == 1 && !another(&argc, &argv, "arguments to SITE command"))){
UPRINTF("usage: %s line-to-send\n", argv[0]);
code = -1;
return;
}
quote1("SITE ", argc, argv);
} | [
"void",
"site",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
")",
"{",
"if",
"(",
"argc",
"==",
"0",
"||",
"(",
"argc",
"==",
"1",
"&&",
"!",
"another",
"(",
"&",
"argc",
",",
"&",
"argv",
",",
"\"",
"\"",
")",
")",
")",
"{",
"UPRINTF",
"(",
"\"",
"\\n",
"\"",
",",
"argv",
"[",
"0",
"]",
")",
";",
"code",
"=",
"-1",
";",
"return",
";",
"}",
"quote1",
"(",
"\"",
"\"",
",",
"argc",
",",
"argv",
")",
";",
"}"
] | Send a SITE command to the remote machine. | [
"Send",
"a",
"SITE",
"command",
"to",
"the",
"remote",
"machine",
"."
] | [] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"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
}
],
"outlier_params": [],
"others": []
} |
a8e33bdbc3f66eb91fc2517414884080337b1997 | atrens/DragonFlyBSD-src | contrib/tnftp/src/cmds.c | [
"BSD-3-Clause"
] | C | quote1 | void | void
quote1(const char *initial, int argc, char *argv[])
{
int i;
char buf[BUFSIZ]; /* must be >= sizeof(line) */
(void)strlcpy(buf, initial, sizeof(buf));
for (i = 1; i < argc; i++) {
(void)strlcat(buf, argv[i], sizeof(buf));
if (i < (argc - 1))
(void)strlcat(buf, " ", sizeof(buf));
}
if (command("%s", buf) == PRELIM) {
while (getreply(0) == PRELIM)
continue;
}
dirchange = 1;
} | /*
* Turn argv[1..argc) into a space-separated string, then prepend initial text.
* Send the result as a one-line command and get response.
*/ | Turn argv[1..argc) into a space-separated string, then prepend initial text.
Send the result as a one-line command and get response. | [
"Turn",
"argv",
"[",
"1",
"..",
"argc",
")",
"into",
"a",
"space",
"-",
"separated",
"string",
"then",
"prepend",
"initial",
"text",
".",
"Send",
"the",
"result",
"as",
"a",
"one",
"-",
"line",
"command",
"and",
"get",
"response",
"."
] | void
quote1(const char *initial, int argc, char *argv[])
{
int i;
char buf[BUFSIZ];
(void)strlcpy(buf, initial, sizeof(buf));
for (i = 1; i < argc; i++) {
(void)strlcat(buf, argv[i], sizeof(buf));
if (i < (argc - 1))
(void)strlcat(buf, " ", sizeof(buf));
}
if (command("%s", buf) == PRELIM) {
while (getreply(0) == PRELIM)
continue;
}
dirchange = 1;
} | [
"void",
"quote1",
"(",
"const",
"char",
"*",
"initial",
",",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
")",
"{",
"int",
"i",
";",
"char",
"buf",
"[",
"BUFSIZ",
"]",
";",
"(",
"void",
")",
"strlcpy",
"(",
"buf",
",",
"initial",
",",
"sizeof",
"(",
"buf",
")",
")",
";",
"for",
"(",
"i",
"=",
"1",
";",
"i",
"<",
"argc",
";",
"i",
"++",
")",
"{",
"(",
"void",
")",
"strlcat",
"(",
"buf",
",",
"argv",
"[",
"i",
"]",
",",
"sizeof",
"(",
"buf",
")",
")",
";",
"if",
"(",
"i",
"<",
"(",
"argc",
"-",
"1",
")",
")",
"(",
"void",
")",
"strlcat",
"(",
"buf",
",",
"\"",
"\"",
",",
"sizeof",
"(",
"buf",
")",
")",
";",
"}",
"if",
"(",
"command",
"(",
"\"",
"\"",
",",
"buf",
")",
"==",
"PRELIM",
")",
"{",
"while",
"(",
"getreply",
"(",
"0",
")",
"==",
"PRELIM",
")",
"continue",
";",
"}",
"dirchange",
"=",
"1",
";",
"}"
] | Turn argv[1..argc) into a space-separated string, then prepend initial text. | [
"Turn",
"argv",
"[",
"1",
"..",
"argc",
")",
"into",
"a",
"space",
"-",
"separated",
"string",
"then",
"prepend",
"initial",
"text",
"."
] | [
"/* must be >= sizeof(line) */"
] | [
{
"param": "initial",
"type": "char"
},
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "initial",
"type": "char",
"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
}
],
"outlier_params": [],
"others": []
} |
a8e33bdbc3f66eb91fc2517414884080337b1997 | atrens/DragonFlyBSD-src | contrib/tnftp/src/cmds.c | [
"BSD-3-Clause"
] | C | rmthelp | void | void
rmthelp(int argc, char *argv[])
{
int oldverbose = verbose;
if (argc == 0) {
UPRINTF("usage: %s\n", argv[0]);
code = -1;
return;
}
verbose = 1;
COMMAND_1ARG(argc, argv, "HELP");
verbose = oldverbose;
} | /*
* Ask the other side for help.
*/ | Ask the other side for help. | [
"Ask",
"the",
"other",
"side",
"for",
"help",
"."
] | void
rmthelp(int argc, char *argv[])
{
int oldverbose = verbose;
if (argc == 0) {
UPRINTF("usage: %s\n", argv[0]);
code = -1;
return;
}
verbose = 1;
COMMAND_1ARG(argc, argv, "HELP");
verbose = oldverbose;
} | [
"void",
"rmthelp",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
")",
"{",
"int",
"oldverbose",
"=",
"verbose",
";",
"if",
"(",
"argc",
"==",
"0",
")",
"{",
"UPRINTF",
"(",
"\"",
"\\n",
"\"",
",",
"argv",
"[",
"0",
"]",
")",
";",
"code",
"=",
"-1",
";",
"return",
";",
"}",
"verbose",
"=",
"1",
";",
"COMMAND_1ARG",
"(",
"argc",
",",
"argv",
",",
"\"",
"\"",
")",
";",
"verbose",
"=",
"oldverbose",
";",
"}"
] | Ask the other side for help. | [
"Ask",
"the",
"other",
"side",
"for",
"help",
"."
] | [] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"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
}
],
"outlier_params": [],
"others": []
} |
a8e33bdbc3f66eb91fc2517414884080337b1997 | atrens/DragonFlyBSD-src | contrib/tnftp/src/cmds.c | [
"BSD-3-Clause"
] | C | docase | char | static const char *
docase(char *dst, size_t dlen, const char *src)
{
size_t i;
int dochange = 1;
for (i = 0; src[i] != '\0' && i < dlen - 1; i++) {
dst[i] = src[i];
if (islower((unsigned char)dst[i]))
dochange = 0;
}
dst[i] = '\0';
if (dochange) {
for (i = 0; dst[i] != '\0'; i++)
if (isupper((unsigned char)dst[i]))
dst[i] = tolower((unsigned char)dst[i]);
}
return dst;
} | /*
* convert the given name to lower case if it's all upper case, into
* a static buffer which is returned to the caller
*/ | convert the given name to lower case if it's all upper case, into
a static buffer which is returned to the caller | [
"convert",
"the",
"given",
"name",
"to",
"lower",
"case",
"if",
"it",
"'",
"s",
"all",
"upper",
"case",
"into",
"a",
"static",
"buffer",
"which",
"is",
"returned",
"to",
"the",
"caller"
] | static const char *
docase(char *dst, size_t dlen, const char *src)
{
size_t i;
int dochange = 1;
for (i = 0; src[i] != '\0' && i < dlen - 1; i++) {
dst[i] = src[i];
if (islower((unsigned char)dst[i]))
dochange = 0;
}
dst[i] = '\0';
if (dochange) {
for (i = 0; dst[i] != '\0'; i++)
if (isupper((unsigned char)dst[i]))
dst[i] = tolower((unsigned char)dst[i]);
}
return dst;
} | [
"static",
"const",
"char",
"*",
"docase",
"(",
"char",
"*",
"dst",
",",
"size_t",
"dlen",
",",
"const",
"char",
"*",
"src",
")",
"{",
"size_t",
"i",
";",
"int",
"dochange",
"=",
"1",
";",
"for",
"(",
"i",
"=",
"0",
";",
"src",
"[",
"i",
"]",
"!=",
"'",
"\\0",
"'",
"&&",
"i",
"<",
"dlen",
"-",
"1",
";",
"i",
"++",
")",
"{",
"dst",
"[",
"i",
"]",
"=",
"src",
"[",
"i",
"]",
";",
"if",
"(",
"islower",
"(",
"(",
"unsigned",
"char",
")",
"dst",
"[",
"i",
"]",
")",
")",
"dochange",
"=",
"0",
";",
"}",
"dst",
"[",
"i",
"]",
"=",
"'",
"\\0",
"'",
";",
"if",
"(",
"dochange",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"dst",
"[",
"i",
"]",
"!=",
"'",
"\\0",
"'",
";",
"i",
"++",
")",
"if",
"(",
"isupper",
"(",
"(",
"unsigned",
"char",
")",
"dst",
"[",
"i",
"]",
")",
")",
"dst",
"[",
"i",
"]",
"=",
"tolower",
"(",
"(",
"unsigned",
"char",
")",
"dst",
"[",
"i",
"]",
")",
";",
"}",
"return",
"dst",
";",
"}"
] | convert the given name to lower case if it's all upper case, into
a static buffer which is returned to the caller | [
"convert",
"the",
"given",
"name",
"to",
"lower",
"case",
"if",
"it",
"'",
"s",
"all",
"upper",
"case",
"into",
"a",
"static",
"buffer",
"which",
"is",
"returned",
"to",
"the",
"caller"
] | [] | [
{
"param": "dst",
"type": "char"
},
{
"param": "dlen",
"type": "size_t"
},
{
"param": "src",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dst",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dlen",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "src",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a8e33bdbc3f66eb91fc2517414884080337b1997 | atrens/DragonFlyBSD-src | contrib/tnftp/src/cmds.c | [
"BSD-3-Clause"
] | C | modtime | void | void
modtime(int argc, char *argv[])
{
time_t mtime;
if (argc == 0 || argc > 2 ||
(argc == 1 && !another(&argc, &argv, "remote-file"))) {
UPRINTF("usage: %s remote-file\n", argv[0]);
code = -1;
return;
}
mtime = remotemodtime(argv[1], 1);
if (mtime != -1)
fprintf(ttyout, "%s\t%s", argv[1],
rfc2822time(localtime(&mtime)));
code = (mtime > 0);
} | /*
* Get last modification time of file on remote machine
*/ | Get last modification time of file on remote machine | [
"Get",
"last",
"modification",
"time",
"of",
"file",
"on",
"remote",
"machine"
] | void
modtime(int argc, char *argv[])
{
time_t mtime;
if (argc == 0 || argc > 2 ||
(argc == 1 && !another(&argc, &argv, "remote-file"))) {
UPRINTF("usage: %s remote-file\n", argv[0]);
code = -1;
return;
}
mtime = remotemodtime(argv[1], 1);
if (mtime != -1)
fprintf(ttyout, "%s\t%s", argv[1],
rfc2822time(localtime(&mtime)));
code = (mtime > 0);
} | [
"void",
"modtime",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
")",
"{",
"time_t",
"mtime",
";",
"if",
"(",
"argc",
"==",
"0",
"||",
"argc",
">",
"2",
"||",
"(",
"argc",
"==",
"1",
"&&",
"!",
"another",
"(",
"&",
"argc",
",",
"&",
"argv",
",",
"\"",
"\"",
")",
")",
")",
"{",
"UPRINTF",
"(",
"\"",
"\\n",
"\"",
",",
"argv",
"[",
"0",
"]",
")",
";",
"code",
"=",
"-1",
";",
"return",
";",
"}",
"mtime",
"=",
"remotemodtime",
"(",
"argv",
"[",
"1",
"]",
",",
"1",
")",
";",
"if",
"(",
"mtime",
"!=",
"-1",
")",
"fprintf",
"(",
"ttyout",
",",
"\"",
"\\t",
"\"",
",",
"argv",
"[",
"1",
"]",
",",
"rfc2822time",
"(",
"localtime",
"(",
"&",
"mtime",
")",
")",
")",
";",
"code",
"=",
"(",
"mtime",
">",
"0",
")",
";",
"}"
] | Get last modification time of file on remote machine | [
"Get",
"last",
"modification",
"time",
"of",
"file",
"on",
"remote",
"machine"
] | [] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"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
}
],
"outlier_params": [],
"others": []
} |
a8e33bdbc3f66eb91fc2517414884080337b1997 | atrens/DragonFlyBSD-src | contrib/tnftp/src/cmds.c | [
"BSD-3-Clause"
] | C | newer | void | void
newer(int argc, char *argv[])
{
if (getit(argc, argv, -1, "w"))
fprintf(ttyout,
"Local file \"%s\" is newer than remote file \"%s\".\n",
argv[2], argv[1]);
} | /*
* Get file if modtime is more recent than current file
*/ | Get file if modtime is more recent than current file | [
"Get",
"file",
"if",
"modtime",
"is",
"more",
"recent",
"than",
"current",
"file"
] | void
newer(int argc, char *argv[])
{
if (getit(argc, argv, -1, "w"))
fprintf(ttyout,
"Local file \"%s\" is newer than remote file \"%s\".\n",
argv[2], argv[1]);
} | [
"void",
"newer",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
")",
"{",
"if",
"(",
"getit",
"(",
"argc",
",",
"argv",
",",
"-1",
",",
"\"",
"\"",
")",
")",
"fprintf",
"(",
"ttyout",
",",
"\"",
"\\\"",
"\\\"",
"\\\"",
"\\\"",
"\\n",
"\"",
",",
"argv",
"[",
"2",
"]",
",",
"argv",
"[",
"1",
"]",
")",
";",
"}"
] | Get file if modtime is more recent than current file | [
"Get",
"file",
"if",
"modtime",
"is",
"more",
"recent",
"than",
"current",
"file"
] | [] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"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
}
],
"outlier_params": [],
"others": []
} |
a8e33bdbc3f66eb91fc2517414884080337b1997 | atrens/DragonFlyBSD-src | contrib/tnftp/src/cmds.c | [
"BSD-3-Clause"
] | C | lpage | void | void
lpage(int argc, char *argv[])
{
size_t len;
const char *p;
char *pager, *locfile;
if (argc == 0 || argc > 2 ||
(argc == 1 && !another(&argc, &argv, "local-file"))) {
UPRINTF("usage: %s local-file\n", argv[0]);
code = -1;
return;
}
if ((locfile = globulize(argv[1])) == NULL) {
code = -1;
return;
}
p = getoptionvalue("pager");
if (EMPTYSTRING(p))
p = DEFAULTPAGER;
len = strlen(p) + strlen(locfile) + 2;
pager = ftp_malloc(len);
(void)strlcpy(pager, p, len);
(void)strlcat(pager, " ", len);
(void)strlcat(pager, locfile, len);
system(pager);
code = 0;
(void)free(pager);
(void)free(locfile);
} | /*
* Display one local file through $PAGER.
*/ | Display one local file through $PAGER. | [
"Display",
"one",
"local",
"file",
"through",
"$PAGER",
"."
] | void
lpage(int argc, char *argv[])
{
size_t len;
const char *p;
char *pager, *locfile;
if (argc == 0 || argc > 2 ||
(argc == 1 && !another(&argc, &argv, "local-file"))) {
UPRINTF("usage: %s local-file\n", argv[0]);
code = -1;
return;
}
if ((locfile = globulize(argv[1])) == NULL) {
code = -1;
return;
}
p = getoptionvalue("pager");
if (EMPTYSTRING(p))
p = DEFAULTPAGER;
len = strlen(p) + strlen(locfile) + 2;
pager = ftp_malloc(len);
(void)strlcpy(pager, p, len);
(void)strlcat(pager, " ", len);
(void)strlcat(pager, locfile, len);
system(pager);
code = 0;
(void)free(pager);
(void)free(locfile);
} | [
"void",
"lpage",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
")",
"{",
"size_t",
"len",
";",
"const",
"char",
"*",
"p",
";",
"char",
"*",
"pager",
",",
"*",
"locfile",
";",
"if",
"(",
"argc",
"==",
"0",
"||",
"argc",
">",
"2",
"||",
"(",
"argc",
"==",
"1",
"&&",
"!",
"another",
"(",
"&",
"argc",
",",
"&",
"argv",
",",
"\"",
"\"",
")",
")",
")",
"{",
"UPRINTF",
"(",
"\"",
"\\n",
"\"",
",",
"argv",
"[",
"0",
"]",
")",
";",
"code",
"=",
"-1",
";",
"return",
";",
"}",
"if",
"(",
"(",
"locfile",
"=",
"globulize",
"(",
"argv",
"[",
"1",
"]",
")",
")",
"==",
"NULL",
")",
"{",
"code",
"=",
"-1",
";",
"return",
";",
"}",
"p",
"=",
"getoptionvalue",
"(",
"\"",
"\"",
")",
";",
"if",
"(",
"EMPTYSTRING",
"(",
"p",
")",
")",
"p",
"=",
"DEFAULTPAGER",
";",
"len",
"=",
"strlen",
"(",
"p",
")",
"+",
"strlen",
"(",
"locfile",
")",
"+",
"2",
";",
"pager",
"=",
"ftp_malloc",
"(",
"len",
")",
";",
"(",
"void",
")",
"strlcpy",
"(",
"pager",
",",
"p",
",",
"len",
")",
";",
"(",
"void",
")",
"strlcat",
"(",
"pager",
",",
"\"",
"\"",
",",
"len",
")",
";",
"(",
"void",
")",
"strlcat",
"(",
"pager",
",",
"locfile",
",",
"len",
")",
";",
"system",
"(",
"pager",
")",
";",
"code",
"=",
"0",
";",
"(",
"void",
")",
"free",
"(",
"pager",
")",
";",
"(",
"void",
")",
"free",
"(",
"locfile",
")",
";",
"}"
] | Display one local file through $PAGER. | [
"Display",
"one",
"local",
"file",
"through",
"$PAGER",
"."
] | [] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"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
}
],
"outlier_params": [],
"others": []
} |
a8e33bdbc3f66eb91fc2517414884080337b1997 | atrens/DragonFlyBSD-src | contrib/tnftp/src/cmds.c | [
"BSD-3-Clause"
] | C | page | void | void
page(int argc, char *argv[])
{
int ohash, orestart_point, overbose;
size_t len;
const char *p;
char *pager;
if (argc == 0 || argc > 2 ||
(argc == 1 && !another(&argc, &argv, "remote-file"))) {
UPRINTF("usage: %s remote-file\n", argv[0]);
code = -1;
return;
}
p = getoptionvalue("pager");
if (EMPTYSTRING(p))
p = DEFAULTPAGER;
len = strlen(p) + 2;
pager = ftp_malloc(len);
pager[0] = '|';
(void)strlcpy(pager + 1, p, len - 1);
ohash = hash;
orestart_point = restart_point;
overbose = verbose;
hash = restart_point = verbose = 0;
recvrequest("RETR", pager, argv[1], "r+", 1, 0);
hash = ohash;
restart_point = orestart_point;
verbose = overbose;
(void)free(pager);
} | /*
* Display one remote file through $PAGER.
*/ | Display one remote file through $PAGER. | [
"Display",
"one",
"remote",
"file",
"through",
"$PAGER",
"."
] | void
page(int argc, char *argv[])
{
int ohash, orestart_point, overbose;
size_t len;
const char *p;
char *pager;
if (argc == 0 || argc > 2 ||
(argc == 1 && !another(&argc, &argv, "remote-file"))) {
UPRINTF("usage: %s remote-file\n", argv[0]);
code = -1;
return;
}
p = getoptionvalue("pager");
if (EMPTYSTRING(p))
p = DEFAULTPAGER;
len = strlen(p) + 2;
pager = ftp_malloc(len);
pager[0] = '|';
(void)strlcpy(pager + 1, p, len - 1);
ohash = hash;
orestart_point = restart_point;
overbose = verbose;
hash = restart_point = verbose = 0;
recvrequest("RETR", pager, argv[1], "r+", 1, 0);
hash = ohash;
restart_point = orestart_point;
verbose = overbose;
(void)free(pager);
} | [
"void",
"page",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
")",
"{",
"int",
"ohash",
",",
"orestart_point",
",",
"overbose",
";",
"size_t",
"len",
";",
"const",
"char",
"*",
"p",
";",
"char",
"*",
"pager",
";",
"if",
"(",
"argc",
"==",
"0",
"||",
"argc",
">",
"2",
"||",
"(",
"argc",
"==",
"1",
"&&",
"!",
"another",
"(",
"&",
"argc",
",",
"&",
"argv",
",",
"\"",
"\"",
")",
")",
")",
"{",
"UPRINTF",
"(",
"\"",
"\\n",
"\"",
",",
"argv",
"[",
"0",
"]",
")",
";",
"code",
"=",
"-1",
";",
"return",
";",
"}",
"p",
"=",
"getoptionvalue",
"(",
"\"",
"\"",
")",
";",
"if",
"(",
"EMPTYSTRING",
"(",
"p",
")",
")",
"p",
"=",
"DEFAULTPAGER",
";",
"len",
"=",
"strlen",
"(",
"p",
")",
"+",
"2",
";",
"pager",
"=",
"ftp_malloc",
"(",
"len",
")",
";",
"pager",
"[",
"0",
"]",
"=",
"'",
"'",
";",
"(",
"void",
")",
"strlcpy",
"(",
"pager",
"+",
"1",
",",
"p",
",",
"len",
"-",
"1",
")",
";",
"ohash",
"=",
"hash",
";",
"orestart_point",
"=",
"restart_point",
";",
"overbose",
"=",
"verbose",
";",
"hash",
"=",
"restart_point",
"=",
"verbose",
"=",
"0",
";",
"recvrequest",
"(",
"\"",
"\"",
",",
"pager",
",",
"argv",
"[",
"1",
"]",
",",
"\"",
"\"",
",",
"1",
",",
"0",
")",
";",
"hash",
"=",
"ohash",
";",
"restart_point",
"=",
"orestart_point",
";",
"verbose",
"=",
"overbose",
";",
"(",
"void",
")",
"free",
"(",
"pager",
")",
";",
"}"
] | Display one remote file through $PAGER. | [
"Display",
"one",
"remote",
"file",
"through",
"$PAGER",
"."
] | [] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"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
}
],
"outlier_params": [],
"others": []
} |
a8e33bdbc3f66eb91fc2517414884080337b1997 | atrens/DragonFlyBSD-src | contrib/tnftp/src/cmds.c | [
"BSD-3-Clause"
] | C | feat | void | void
feat(int argc, char *argv[])
{
int oldverbose = verbose;
if (argc == 0) {
UPRINTF("usage: %s\n", argv[0]);
code = -1;
return;
}
if (! features[FEAT_FEAT]) {
fprintf(ttyout,
"FEAT is not supported by the remote server.\n");
return;
}
verbose = 1; /* If we aren't verbose, this doesn't do anything! */
(void)command("FEAT");
verbose = oldverbose;
} | /*
* Display features supported by the remote host.
*/ | Display features supported by the remote host. | [
"Display",
"features",
"supported",
"by",
"the",
"remote",
"host",
"."
] | void
feat(int argc, char *argv[])
{
int oldverbose = verbose;
if (argc == 0) {
UPRINTF("usage: %s\n", argv[0]);
code = -1;
return;
}
if (! features[FEAT_FEAT]) {
fprintf(ttyout,
"FEAT is not supported by the remote server.\n");
return;
}
verbose = 1;
(void)command("FEAT");
verbose = oldverbose;
} | [
"void",
"feat",
"(",
"int",
"argc",
",",
"char",
"*",
"argv",
"[",
"]",
")",
"{",
"int",
"oldverbose",
"=",
"verbose",
";",
"if",
"(",
"argc",
"==",
"0",
")",
"{",
"UPRINTF",
"(",
"\"",
"\\n",
"\"",
",",
"argv",
"[",
"0",
"]",
")",
";",
"code",
"=",
"-1",
";",
"return",
";",
"}",
"if",
"(",
"!",
"features",
"[",
"FEAT_FEAT",
"]",
")",
"{",
"fprintf",
"(",
"ttyout",
",",
"\"",
"\\n",
"\"",
")",
";",
"return",
";",
"}",
"verbose",
"=",
"1",
";",
"(",
"void",
")",
"command",
"(",
"\"",
"\"",
")",
";",
"verbose",
"=",
"oldverbose",
";",
"}"
] | Display features supported by the remote host. | [
"Display",
"features",
"supported",
"by",
"the",
"remote",
"host",
"."
] | [
"/* If we aren't verbose, this doesn't do anything! */"
] | [
{
"param": "argc",
"type": "int"
},
{
"param": "argv",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"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
}
],
"outlier_params": [],
"others": []
} |
eb85e7752aeea51ac1092eebdf61e7d2f489f185 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/ira-conflicts.c | [
"BSD-3-Clause"
] | C | record_object_conflict | void | static void
record_object_conflict (ira_object_t obj1, ira_object_t obj2)
{
ira_allocno_t a1 = OBJECT_ALLOCNO (obj1);
ira_allocno_t a2 = OBJECT_ALLOCNO (obj2);
int w1 = OBJECT_SUBWORD (obj1);
int w2 = OBJECT_SUBWORD (obj2);
int id1, id2;
/* Canonicalize the conflict. If two identically-numbered words
conflict, always record this as a conflict between words 0. That
is the only information we need, and it is easier to test for if
it is collected in each allocno's lowest-order object. */
if (w1 == w2 && w1 > 0)
{
obj1 = ALLOCNO_OBJECT (a1, 0);
obj2 = ALLOCNO_OBJECT (a2, 0);
}
id1 = OBJECT_CONFLICT_ID (obj1);
id2 = OBJECT_CONFLICT_ID (obj2);
SET_MINMAX_SET_BIT (conflicts[id1], id2, OBJECT_MIN (obj1),
OBJECT_MAX (obj1));
SET_MINMAX_SET_BIT (conflicts[id2], id1, OBJECT_MIN (obj2),
OBJECT_MAX (obj2));
} | /* Record a conflict between objects OBJ1 and OBJ2. If necessary,
canonicalize the conflict by recording it for lower-order subobjects
of the corresponding allocnos. */ | Record a conflict between objects OBJ1 and OBJ2. If necessary,
canonicalize the conflict by recording it for lower-order subobjects
of the corresponding allocnos. | [
"Record",
"a",
"conflict",
"between",
"objects",
"OBJ1",
"and",
"OBJ2",
".",
"If",
"necessary",
"canonicalize",
"the",
"conflict",
"by",
"recording",
"it",
"for",
"lower",
"-",
"order",
"subobjects",
"of",
"the",
"corresponding",
"allocnos",
"."
] | static void
record_object_conflict (ira_object_t obj1, ira_object_t obj2)
{
ira_allocno_t a1 = OBJECT_ALLOCNO (obj1);
ira_allocno_t a2 = OBJECT_ALLOCNO (obj2);
int w1 = OBJECT_SUBWORD (obj1);
int w2 = OBJECT_SUBWORD (obj2);
int id1, id2;
if (w1 == w2 && w1 > 0)
{
obj1 = ALLOCNO_OBJECT (a1, 0);
obj2 = ALLOCNO_OBJECT (a2, 0);
}
id1 = OBJECT_CONFLICT_ID (obj1);
id2 = OBJECT_CONFLICT_ID (obj2);
SET_MINMAX_SET_BIT (conflicts[id1], id2, OBJECT_MIN (obj1),
OBJECT_MAX (obj1));
SET_MINMAX_SET_BIT (conflicts[id2], id1, OBJECT_MIN (obj2),
OBJECT_MAX (obj2));
} | [
"static",
"void",
"record_object_conflict",
"(",
"ira_object_t",
"obj1",
",",
"ira_object_t",
"obj2",
")",
"{",
"ira_allocno_t",
"a1",
"=",
"OBJECT_ALLOCNO",
"(",
"obj1",
")",
";",
"ira_allocno_t",
"a2",
"=",
"OBJECT_ALLOCNO",
"(",
"obj2",
")",
";",
"int",
"w1",
"=",
"OBJECT_SUBWORD",
"(",
"obj1",
")",
";",
"int",
"w2",
"=",
"OBJECT_SUBWORD",
"(",
"obj2",
")",
";",
"int",
"id1",
",",
"id2",
";",
"if",
"(",
"w1",
"==",
"w2",
"&&",
"w1",
">",
"0",
")",
"{",
"obj1",
"=",
"ALLOCNO_OBJECT",
"(",
"a1",
",",
"0",
")",
";",
"obj2",
"=",
"ALLOCNO_OBJECT",
"(",
"a2",
",",
"0",
")",
";",
"}",
"id1",
"=",
"OBJECT_CONFLICT_ID",
"(",
"obj1",
")",
";",
"id2",
"=",
"OBJECT_CONFLICT_ID",
"(",
"obj2",
")",
";",
"SET_MINMAX_SET_BIT",
"(",
"conflicts",
"[",
"id1",
"]",
",",
"id2",
",",
"OBJECT_MIN",
"(",
"obj1",
")",
",",
"OBJECT_MAX",
"(",
"obj1",
")",
")",
";",
"SET_MINMAX_SET_BIT",
"(",
"conflicts",
"[",
"id2",
"]",
",",
"id1",
",",
"OBJECT_MIN",
"(",
"obj2",
")",
",",
"OBJECT_MAX",
"(",
"obj2",
")",
")",
";",
"}"
] | Record a conflict between objects OBJ1 and OBJ2. | [
"Record",
"a",
"conflict",
"between",
"objects",
"OBJ1",
"and",
"OBJ2",
"."
] | [
"/* Canonicalize the conflict. If two identically-numbered words\n conflict, always record this as a conflict between words 0. That\n is the only information we need, and it is easier to test for if\n it is collected in each allocno's lowest-order object. */"
] | [
{
"param": "obj1",
"type": "ira_object_t"
},
{
"param": "obj2",
"type": "ira_object_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "obj1",
"type": "ira_object_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "obj2",
"type": "ira_object_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
eb85e7752aeea51ac1092eebdf61e7d2f489f185 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/ira-conflicts.c | [
"BSD-3-Clause"
] | C | build_conflict_bit_table | bool | static bool
build_conflict_bit_table (void)
{
int i;
unsigned int j;
enum reg_class aclass;
int object_set_words, allocated_words_num, conflict_bit_vec_words_num;
live_range_t r;
ira_allocno_t allocno;
ira_allocno_iterator ai;
sparseset objects_live;
ira_object_t obj;
ira_allocno_object_iterator aoi;
allocated_words_num = 0;
FOR_EACH_ALLOCNO (allocno, ai)
FOR_EACH_ALLOCNO_OBJECT (allocno, obj, aoi)
{
if (OBJECT_MAX (obj) < OBJECT_MIN (obj))
continue;
conflict_bit_vec_words_num
= ((OBJECT_MAX (obj) - OBJECT_MIN (obj) + IRA_INT_BITS)
/ IRA_INT_BITS);
allocated_words_num += conflict_bit_vec_words_num;
if ((uint64_t) allocated_words_num * sizeof (IRA_INT_TYPE)
> (uint64_t) IRA_MAX_CONFLICT_TABLE_SIZE * 1024 * 1024)
{
if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL)
fprintf
(ira_dump_file,
"+++Conflict table will be too big(>%dMB) -- don't use it\n",
IRA_MAX_CONFLICT_TABLE_SIZE);
return false;
}
}
conflicts = (IRA_INT_TYPE **) ira_allocate (sizeof (IRA_INT_TYPE *)
* ira_objects_num);
allocated_words_num = 0;
FOR_EACH_ALLOCNO (allocno, ai)
FOR_EACH_ALLOCNO_OBJECT (allocno, obj, aoi)
{
int id = OBJECT_CONFLICT_ID (obj);
if (OBJECT_MAX (obj) < OBJECT_MIN (obj))
{
conflicts[id] = NULL;
continue;
}
conflict_bit_vec_words_num
= ((OBJECT_MAX (obj) - OBJECT_MIN (obj) + IRA_INT_BITS)
/ IRA_INT_BITS);
allocated_words_num += conflict_bit_vec_words_num;
conflicts[id]
= (IRA_INT_TYPE *) ira_allocate (sizeof (IRA_INT_TYPE)
* conflict_bit_vec_words_num);
memset (conflicts[id], 0,
sizeof (IRA_INT_TYPE) * conflict_bit_vec_words_num);
}
object_set_words = (ira_objects_num + IRA_INT_BITS - 1) / IRA_INT_BITS;
if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL)
fprintf
(ira_dump_file,
"+++Allocating %ld bytes for conflict table (uncompressed size %ld)\n",
(long) allocated_words_num * sizeof (IRA_INT_TYPE),
(long) object_set_words * ira_objects_num * sizeof (IRA_INT_TYPE));
objects_live = sparseset_alloc (ira_objects_num);
for (i = 0; i < ira_max_point; i++)
{
for (r = ira_start_point_ranges[i]; r != NULL; r = r->start_next)
{
ira_object_t obj = r->object;
ira_allocno_t allocno = OBJECT_ALLOCNO (obj);
int id = OBJECT_CONFLICT_ID (obj);
gcc_assert (id < ira_objects_num);
aclass = ALLOCNO_CLASS (allocno);
EXECUTE_IF_SET_IN_SPARSESET (objects_live, j)
{
ira_object_t live_obj = ira_object_id_map[j];
ira_allocno_t live_a = OBJECT_ALLOCNO (live_obj);
enum reg_class live_aclass = ALLOCNO_CLASS (live_a);
if (ira_reg_classes_intersect_p[aclass][live_aclass]
/* Don't set up conflict for the allocno with itself. */
&& live_a != allocno)
{
record_object_conflict (obj, live_obj);
}
}
sparseset_set_bit (objects_live, id);
}
for (r = ira_finish_point_ranges[i]; r != NULL; r = r->finish_next)
sparseset_clear_bit (objects_live, OBJECT_CONFLICT_ID (r->object));
}
sparseset_free (objects_live);
return true;
} | /* Build allocno conflict table by processing allocno live ranges.
Return true if the table was built. The table is not built if it
is too big. */ | Build allocno conflict table by processing allocno live ranges.
Return true if the table was built. The table is not built if it
is too big. | [
"Build",
"allocno",
"conflict",
"table",
"by",
"processing",
"allocno",
"live",
"ranges",
".",
"Return",
"true",
"if",
"the",
"table",
"was",
"built",
".",
"The",
"table",
"is",
"not",
"built",
"if",
"it",
"is",
"too",
"big",
"."
] | static bool
build_conflict_bit_table (void)
{
int i;
unsigned int j;
enum reg_class aclass;
int object_set_words, allocated_words_num, conflict_bit_vec_words_num;
live_range_t r;
ira_allocno_t allocno;
ira_allocno_iterator ai;
sparseset objects_live;
ira_object_t obj;
ira_allocno_object_iterator aoi;
allocated_words_num = 0;
FOR_EACH_ALLOCNO (allocno, ai)
FOR_EACH_ALLOCNO_OBJECT (allocno, obj, aoi)
{
if (OBJECT_MAX (obj) < OBJECT_MIN (obj))
continue;
conflict_bit_vec_words_num
= ((OBJECT_MAX (obj) - OBJECT_MIN (obj) + IRA_INT_BITS)
/ IRA_INT_BITS);
allocated_words_num += conflict_bit_vec_words_num;
if ((uint64_t) allocated_words_num * sizeof (IRA_INT_TYPE)
> (uint64_t) IRA_MAX_CONFLICT_TABLE_SIZE * 1024 * 1024)
{
if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL)
fprintf
(ira_dump_file,
"+++Conflict table will be too big(>%dMB) -- don't use it\n",
IRA_MAX_CONFLICT_TABLE_SIZE);
return false;
}
}
conflicts = (IRA_INT_TYPE **) ira_allocate (sizeof (IRA_INT_TYPE *)
* ira_objects_num);
allocated_words_num = 0;
FOR_EACH_ALLOCNO (allocno, ai)
FOR_EACH_ALLOCNO_OBJECT (allocno, obj, aoi)
{
int id = OBJECT_CONFLICT_ID (obj);
if (OBJECT_MAX (obj) < OBJECT_MIN (obj))
{
conflicts[id] = NULL;
continue;
}
conflict_bit_vec_words_num
= ((OBJECT_MAX (obj) - OBJECT_MIN (obj) + IRA_INT_BITS)
/ IRA_INT_BITS);
allocated_words_num += conflict_bit_vec_words_num;
conflicts[id]
= (IRA_INT_TYPE *) ira_allocate (sizeof (IRA_INT_TYPE)
* conflict_bit_vec_words_num);
memset (conflicts[id], 0,
sizeof (IRA_INT_TYPE) * conflict_bit_vec_words_num);
}
object_set_words = (ira_objects_num + IRA_INT_BITS - 1) / IRA_INT_BITS;
if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL)
fprintf
(ira_dump_file,
"+++Allocating %ld bytes for conflict table (uncompressed size %ld)\n",
(long) allocated_words_num * sizeof (IRA_INT_TYPE),
(long) object_set_words * ira_objects_num * sizeof (IRA_INT_TYPE));
objects_live = sparseset_alloc (ira_objects_num);
for (i = 0; i < ira_max_point; i++)
{
for (r = ira_start_point_ranges[i]; r != NULL; r = r->start_next)
{
ira_object_t obj = r->object;
ira_allocno_t allocno = OBJECT_ALLOCNO (obj);
int id = OBJECT_CONFLICT_ID (obj);
gcc_assert (id < ira_objects_num);
aclass = ALLOCNO_CLASS (allocno);
EXECUTE_IF_SET_IN_SPARSESET (objects_live, j)
{
ira_object_t live_obj = ira_object_id_map[j];
ira_allocno_t live_a = OBJECT_ALLOCNO (live_obj);
enum reg_class live_aclass = ALLOCNO_CLASS (live_a);
if (ira_reg_classes_intersect_p[aclass][live_aclass]
&& live_a != allocno)
{
record_object_conflict (obj, live_obj);
}
}
sparseset_set_bit (objects_live, id);
}
for (r = ira_finish_point_ranges[i]; r != NULL; r = r->finish_next)
sparseset_clear_bit (objects_live, OBJECT_CONFLICT_ID (r->object));
}
sparseset_free (objects_live);
return true;
} | [
"static",
"bool",
"build_conflict_bit_table",
"(",
"void",
")",
"{",
"int",
"i",
";",
"unsigned",
"int",
"j",
";",
"enum",
"reg_class",
"aclass",
";",
"int",
"object_set_words",
",",
"allocated_words_num",
",",
"conflict_bit_vec_words_num",
";",
"live_range_t",
"r",
";",
"ira_allocno_t",
"allocno",
";",
"ira_allocno_iterator",
"ai",
";",
"sparseset",
"objects_live",
";",
"ira_object_t",
"obj",
";",
"ira_allocno_object_iterator",
"aoi",
";",
"allocated_words_num",
"=",
"0",
";",
"FOR_EACH_ALLOCNO",
"(",
"allocno",
",",
"ai",
")",
"",
"FOR_EACH_ALLOCNO_OBJECT",
"(",
"allocno",
",",
"obj",
",",
"aoi",
")",
"",
"{",
"if",
"(",
"OBJECT_MAX",
"(",
"obj",
")",
"<",
"OBJECT_MIN",
"(",
"obj",
")",
")",
"continue",
";",
"conflict_bit_vec_words_num",
"=",
"(",
"(",
"OBJECT_MAX",
"(",
"obj",
")",
"-",
"OBJECT_MIN",
"(",
"obj",
")",
"+",
"IRA_INT_BITS",
")",
"/",
"IRA_INT_BITS",
")",
";",
"allocated_words_num",
"+=",
"conflict_bit_vec_words_num",
";",
"if",
"(",
"(",
"uint64_t",
")",
"allocated_words_num",
"*",
"sizeof",
"(",
"IRA_INT_TYPE",
")",
">",
"(",
"uint64_t",
")",
"IRA_MAX_CONFLICT_TABLE_SIZE",
"*",
"1024",
"*",
"1024",
")",
"{",
"if",
"(",
"internal_flag_ira_verbose",
">",
"0",
"&&",
"ira_dump_file",
"!=",
"NULL",
")",
"fprintf",
"(",
"ira_dump_file",
",",
"\"",
"\\n",
"\"",
",",
"IRA_MAX_CONFLICT_TABLE_SIZE",
")",
";",
"return",
"false",
";",
"}",
"}",
"conflicts",
"=",
"(",
"IRA_INT_TYPE",
"*",
"*",
")",
"ira_allocate",
"(",
"sizeof",
"(",
"IRA_INT_TYPE",
"*",
")",
"*",
"ira_objects_num",
")",
";",
"allocated_words_num",
"=",
"0",
";",
"FOR_EACH_ALLOCNO",
"(",
"allocno",
",",
"ai",
")",
"",
"FOR_EACH_ALLOCNO_OBJECT",
"(",
"allocno",
",",
"obj",
",",
"aoi",
")",
"",
"{",
"int",
"id",
"=",
"OBJECT_CONFLICT_ID",
"(",
"obj",
")",
";",
"if",
"(",
"OBJECT_MAX",
"(",
"obj",
")",
"<",
"OBJECT_MIN",
"(",
"obj",
")",
")",
"{",
"conflicts",
"[",
"id",
"]",
"=",
"NULL",
";",
"continue",
";",
"}",
"conflict_bit_vec_words_num",
"=",
"(",
"(",
"OBJECT_MAX",
"(",
"obj",
")",
"-",
"OBJECT_MIN",
"(",
"obj",
")",
"+",
"IRA_INT_BITS",
")",
"/",
"IRA_INT_BITS",
")",
";",
"allocated_words_num",
"+=",
"conflict_bit_vec_words_num",
";",
"conflicts",
"[",
"id",
"]",
"=",
"(",
"IRA_INT_TYPE",
"*",
")",
"ira_allocate",
"(",
"sizeof",
"(",
"IRA_INT_TYPE",
")",
"*",
"conflict_bit_vec_words_num",
")",
";",
"memset",
"(",
"conflicts",
"[",
"id",
"]",
",",
"0",
",",
"sizeof",
"(",
"IRA_INT_TYPE",
")",
"*",
"conflict_bit_vec_words_num",
")",
";",
"}",
"object_set_words",
"=",
"(",
"ira_objects_num",
"+",
"IRA_INT_BITS",
"-",
"1",
")",
"/",
"IRA_INT_BITS",
";",
"if",
"(",
"internal_flag_ira_verbose",
">",
"0",
"&&",
"ira_dump_file",
"!=",
"NULL",
")",
"fprintf",
"(",
"ira_dump_file",
",",
"\"",
"\\n",
"\"",
",",
"(",
"long",
")",
"allocated_words_num",
"*",
"sizeof",
"(",
"IRA_INT_TYPE",
")",
",",
"(",
"long",
")",
"object_set_words",
"*",
"ira_objects_num",
"*",
"sizeof",
"(",
"IRA_INT_TYPE",
")",
")",
";",
"objects_live",
"=",
"sparseset_alloc",
"(",
"ira_objects_num",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"ira_max_point",
";",
"i",
"++",
")",
"{",
"for",
"(",
"r",
"=",
"ira_start_point_ranges",
"[",
"i",
"]",
";",
"r",
"!=",
"NULL",
";",
"r",
"=",
"r",
"->",
"start_next",
")",
"{",
"ira_object_t",
"obj",
"=",
"r",
"->",
"object",
";",
"ira_allocno_t",
"allocno",
"=",
"OBJECT_ALLOCNO",
"(",
"obj",
")",
";",
"int",
"id",
"=",
"OBJECT_CONFLICT_ID",
"(",
"obj",
")",
";",
"gcc_assert",
"(",
"id",
"<",
"ira_objects_num",
")",
";",
"aclass",
"=",
"ALLOCNO_CLASS",
"(",
"allocno",
")",
";",
"EXECUTE_IF_SET_IN_SPARSESET",
"(",
"objects_live",
",",
"j",
")",
"",
"{",
"ira_object_t",
"live_obj",
"=",
"ira_object_id_map",
"[",
"j",
"]",
";",
"ira_allocno_t",
"live_a",
"=",
"OBJECT_ALLOCNO",
"(",
"live_obj",
")",
";",
"enum",
"reg_class",
"live_aclass",
"=",
"ALLOCNO_CLASS",
"(",
"live_a",
")",
";",
"if",
"(",
"ira_reg_classes_intersect_p",
"[",
"aclass",
"]",
"[",
"live_aclass",
"]",
"&&",
"live_a",
"!=",
"allocno",
")",
"{",
"record_object_conflict",
"(",
"obj",
",",
"live_obj",
")",
";",
"}",
"}",
"sparseset_set_bit",
"(",
"objects_live",
",",
"id",
")",
";",
"}",
"for",
"(",
"r",
"=",
"ira_finish_point_ranges",
"[",
"i",
"]",
";",
"r",
"!=",
"NULL",
";",
"r",
"=",
"r",
"->",
"finish_next",
")",
"sparseset_clear_bit",
"(",
"objects_live",
",",
"OBJECT_CONFLICT_ID",
"(",
"r",
"->",
"object",
")",
")",
";",
"}",
"sparseset_free",
"(",
"objects_live",
")",
";",
"return",
"true",
";",
"}"
] | Build allocno conflict table by processing allocno live ranges. | [
"Build",
"allocno",
"conflict",
"table",
"by",
"processing",
"allocno",
"live",
"ranges",
"."
] | [
"/* Don't set up conflict for the allocno with itself. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
eb85e7752aeea51ac1092eebdf61e7d2f489f185 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/ira-conflicts.c | [
"BSD-3-Clause"
] | C | allocnos_conflict_for_copy_p | bool | static bool
allocnos_conflict_for_copy_p (ira_allocno_t a1, ira_allocno_t a2)
{
/* Due to the fact that we canonicalize conflicts (see
record_object_conflict), we only need to test for conflicts of
the lowest order words. */
ira_object_t obj1 = ALLOCNO_OBJECT (a1, 0);
ira_object_t obj2 = ALLOCNO_OBJECT (a2, 0);
return OBJECTS_CONFLICT_P (obj1, obj2);
} | /* Return true iff allocnos A1 and A2 cannot be allocated to the same
register due to conflicts. */ | Return true iff allocnos A1 and A2 cannot be allocated to the same
register due to conflicts. | [
"Return",
"true",
"iff",
"allocnos",
"A1",
"and",
"A2",
"cannot",
"be",
"allocated",
"to",
"the",
"same",
"register",
"due",
"to",
"conflicts",
"."
] | static bool
allocnos_conflict_for_copy_p (ira_allocno_t a1, ira_allocno_t a2)
{
ira_object_t obj1 = ALLOCNO_OBJECT (a1, 0);
ira_object_t obj2 = ALLOCNO_OBJECT (a2, 0);
return OBJECTS_CONFLICT_P (obj1, obj2);
} | [
"static",
"bool",
"allocnos_conflict_for_copy_p",
"(",
"ira_allocno_t",
"a1",
",",
"ira_allocno_t",
"a2",
")",
"{",
"ira_object_t",
"obj1",
"=",
"ALLOCNO_OBJECT",
"(",
"a1",
",",
"0",
")",
";",
"ira_object_t",
"obj2",
"=",
"ALLOCNO_OBJECT",
"(",
"a2",
",",
"0",
")",
";",
"return",
"OBJECTS_CONFLICT_P",
"(",
"obj1",
",",
"obj2",
")",
";",
"}"
] | Return true iff allocnos A1 and A2 cannot be allocated to the same
register due to conflicts. | [
"Return",
"true",
"iff",
"allocnos",
"A1",
"and",
"A2",
"cannot",
"be",
"allocated",
"to",
"the",
"same",
"register",
"due",
"to",
"conflicts",
"."
] | [
"/* Due to the fact that we canonicalize conflicts (see\n record_object_conflict), we only need to test for conflicts of\n the lowest order words. */"
] | [
{
"param": "a1",
"type": "ira_allocno_t"
},
{
"param": "a2",
"type": "ira_allocno_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "a1",
"type": "ira_allocno_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "a2",
"type": "ira_allocno_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
eb85e7752aeea51ac1092eebdf61e7d2f489f185 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/ira-conflicts.c | [
"BSD-3-Clause"
] | C | go_through_subreg | rtx | static rtx
go_through_subreg (rtx x, int *offset)
{
rtx reg;
*offset = 0;
if (REG_P (x))
return x;
ira_assert (GET_CODE (x) == SUBREG);
reg = SUBREG_REG (x);
ira_assert (REG_P (reg));
if (REGNO (reg) < FIRST_PSEUDO_REGISTER)
*offset = subreg_regno_offset (REGNO (reg), GET_MODE (reg),
SUBREG_BYTE (x), GET_MODE (x));
else if (!can_div_trunc_p (SUBREG_BYTE (x),
REGMODE_NATURAL_SIZE (GET_MODE (x)), offset))
/* Checked by validate_subreg. We must know at compile time which
inner hard registers are being accessed. */
gcc_unreachable ();
return reg;
} | /* Return X if X is a REG, otherwise it should be SUBREG of REG and
the function returns the reg in this case. *OFFSET will be set to
0 in the first case or the regno offset in the first case. */ | Return X if X is a REG, otherwise it should be SUBREG of REG and
the function returns the reg in this case. *OFFSET will be set to
0 in the first case or the regno offset in the first case. | [
"Return",
"X",
"if",
"X",
"is",
"a",
"REG",
"otherwise",
"it",
"should",
"be",
"SUBREG",
"of",
"REG",
"and",
"the",
"function",
"returns",
"the",
"reg",
"in",
"this",
"case",
".",
"*",
"OFFSET",
"will",
"be",
"set",
"to",
"0",
"in",
"the",
"first",
"case",
"or",
"the",
"regno",
"offset",
"in",
"the",
"first",
"case",
"."
] | static rtx
go_through_subreg (rtx x, int *offset)
{
rtx reg;
*offset = 0;
if (REG_P (x))
return x;
ira_assert (GET_CODE (x) == SUBREG);
reg = SUBREG_REG (x);
ira_assert (REG_P (reg));
if (REGNO (reg) < FIRST_PSEUDO_REGISTER)
*offset = subreg_regno_offset (REGNO (reg), GET_MODE (reg),
SUBREG_BYTE (x), GET_MODE (x));
else if (!can_div_trunc_p (SUBREG_BYTE (x),
REGMODE_NATURAL_SIZE (GET_MODE (x)), offset))
gcc_unreachable ();
return reg;
} | [
"static",
"rtx",
"go_through_subreg",
"(",
"rtx",
"x",
",",
"int",
"*",
"offset",
")",
"{",
"rtx",
"reg",
";",
"*",
"offset",
"=",
"0",
";",
"if",
"(",
"REG_P",
"(",
"x",
")",
")",
"return",
"x",
";",
"ira_assert",
"(",
"GET_CODE",
"(",
"x",
")",
"==",
"SUBREG",
")",
";",
"reg",
"=",
"SUBREG_REG",
"(",
"x",
")",
";",
"ira_assert",
"(",
"REG_P",
"(",
"reg",
")",
")",
";",
"if",
"(",
"REGNO",
"(",
"reg",
")",
"<",
"FIRST_PSEUDO_REGISTER",
")",
"*",
"offset",
"=",
"subreg_regno_offset",
"(",
"REGNO",
"(",
"reg",
")",
",",
"GET_MODE",
"(",
"reg",
")",
",",
"SUBREG_BYTE",
"(",
"x",
")",
",",
"GET_MODE",
"(",
"x",
")",
")",
";",
"else",
"if",
"(",
"!",
"can_div_trunc_p",
"(",
"SUBREG_BYTE",
"(",
"x",
")",
",",
"REGMODE_NATURAL_SIZE",
"(",
"GET_MODE",
"(",
"x",
")",
")",
",",
"offset",
")",
")",
"gcc_unreachable",
"(",
")",
";",
"return",
"reg",
";",
"}"
] | Return X if X is a REG, otherwise it should be SUBREG of REG and
the function returns the reg in this case. | [
"Return",
"X",
"if",
"X",
"is",
"a",
"REG",
"otherwise",
"it",
"should",
"be",
"SUBREG",
"of",
"REG",
"and",
"the",
"function",
"returns",
"the",
"reg",
"in",
"this",
"case",
"."
] | [
"/* Checked by validate_subreg. We must know at compile time which\n inner hard registers are being accessed. */"
] | [
{
"param": "x",
"type": "rtx"
},
{
"param": "offset",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": "rtx",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offset",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
eb85e7752aeea51ac1092eebdf61e7d2f489f185 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/ira-conflicts.c | [
"BSD-3-Clause"
] | C | process_reg_shuffles | void | static void
process_reg_shuffles (rtx reg, int op_num, int freq, bool *bound_p)
{
int i;
rtx another_reg;
gcc_assert (REG_SUBREG_P (reg));
for (i = 0; i < recog_data.n_operands; i++)
{
another_reg = recog_data.operand[i];
if (!REG_SUBREG_P (another_reg) || op_num == i
|| recog_data.operand_type[i] != OP_OUT
|| bound_p[i])
continue;
process_regs_for_copy (reg, another_reg, false, NULL, freq);
}
} | /* Process all of the output registers of the current insn which are
not bound (BOUND_P) and the input register REG (its operand number
OP_NUM) which dies in the insn as if there were a move insn between
them with frequency FREQ. */ | Process all of the output registers of the current insn which are
not bound (BOUND_P) and the input register REG (its operand number
OP_NUM) which dies in the insn as if there were a move insn between
them with frequency FREQ. | [
"Process",
"all",
"of",
"the",
"output",
"registers",
"of",
"the",
"current",
"insn",
"which",
"are",
"not",
"bound",
"(",
"BOUND_P",
")",
"and",
"the",
"input",
"register",
"REG",
"(",
"its",
"operand",
"number",
"OP_NUM",
")",
"which",
"dies",
"in",
"the",
"insn",
"as",
"if",
"there",
"were",
"a",
"move",
"insn",
"between",
"them",
"with",
"frequency",
"FREQ",
"."
] | static void
process_reg_shuffles (rtx reg, int op_num, int freq, bool *bound_p)
{
int i;
rtx another_reg;
gcc_assert (REG_SUBREG_P (reg));
for (i = 0; i < recog_data.n_operands; i++)
{
another_reg = recog_data.operand[i];
if (!REG_SUBREG_P (another_reg) || op_num == i
|| recog_data.operand_type[i] != OP_OUT
|| bound_p[i])
continue;
process_regs_for_copy (reg, another_reg, false, NULL, freq);
}
} | [
"static",
"void",
"process_reg_shuffles",
"(",
"rtx",
"reg",
",",
"int",
"op_num",
",",
"int",
"freq",
",",
"bool",
"*",
"bound_p",
")",
"{",
"int",
"i",
";",
"rtx",
"another_reg",
";",
"gcc_assert",
"(",
"REG_SUBREG_P",
"(",
"reg",
")",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"recog_data",
".",
"n_operands",
";",
"i",
"++",
")",
"{",
"another_reg",
"=",
"recog_data",
".",
"operand",
"[",
"i",
"]",
";",
"if",
"(",
"!",
"REG_SUBREG_P",
"(",
"another_reg",
")",
"||",
"op_num",
"==",
"i",
"||",
"recog_data",
".",
"operand_type",
"[",
"i",
"]",
"!=",
"OP_OUT",
"||",
"bound_p",
"[",
"i",
"]",
")",
"continue",
";",
"process_regs_for_copy",
"(",
"reg",
",",
"another_reg",
",",
"false",
",",
"NULL",
",",
"freq",
")",
";",
"}",
"}"
] | Process all of the output registers of the current insn which are
not bound (BOUND_P) and the input register REG (its operand number
OP_NUM) which dies in the insn as if there were a move insn between
them with frequency FREQ. | [
"Process",
"all",
"of",
"the",
"output",
"registers",
"of",
"the",
"current",
"insn",
"which",
"are",
"not",
"bound",
"(",
"BOUND_P",
")",
"and",
"the",
"input",
"register",
"REG",
"(",
"its",
"operand",
"number",
"OP_NUM",
")",
"which",
"dies",
"in",
"the",
"insn",
"as",
"if",
"there",
"were",
"a",
"move",
"insn",
"between",
"them",
"with",
"frequency",
"FREQ",
"."
] | [] | [
{
"param": "reg",
"type": "rtx"
},
{
"param": "op_num",
"type": "int"
},
{
"param": "freq",
"type": "int"
},
{
"param": "bound_p",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "reg",
"type": "rtx",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "op_num",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "freq",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bound_p",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
eb85e7752aeea51ac1092eebdf61e7d2f489f185 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/ira-conflicts.c | [
"BSD-3-Clause"
] | C | add_insn_allocno_copies | void | static void
add_insn_allocno_copies (rtx_insn *insn)
{
rtx set, operand, dup;
bool bound_p[MAX_RECOG_OPERANDS];
int i, n, freq;
HARD_REG_SET alts;
freq = REG_FREQ_FROM_BB (BLOCK_FOR_INSN (insn));
if (freq == 0)
freq = 1;
if ((set = single_set (insn)) != NULL_RTX
&& REG_SUBREG_P (SET_DEST (set)) && REG_SUBREG_P (SET_SRC (set))
&& ! side_effects_p (set)
&& find_reg_note (insn, REG_DEAD,
REG_P (SET_SRC (set))
? SET_SRC (set)
: SUBREG_REG (SET_SRC (set))) != NULL_RTX)
{
process_regs_for_copy (SET_SRC (set), SET_DEST (set),
false, insn, freq);
return;
}
/* Fast check of possibility of constraint or shuffle copies. If
there are no dead registers, there will be no such copies. */
if (! find_reg_note (insn, REG_DEAD, NULL_RTX))
return;
ira_setup_alts (insn, alts);
for (i = 0; i < recog_data.n_operands; i++)
bound_p[i] = false;
for (i = 0; i < recog_data.n_operands; i++)
{
operand = recog_data.operand[i];
if (! REG_SUBREG_P (operand))
continue;
if ((n = ira_get_dup_out_num (i, alts)) >= 0)
{
bound_p[n] = true;
dup = recog_data.operand[n];
if (REG_SUBREG_P (dup)
&& find_reg_note (insn, REG_DEAD,
REG_P (operand)
? operand
: SUBREG_REG (operand)) != NULL_RTX)
process_regs_for_copy (operand, dup, true, NULL,
freq);
}
}
for (i = 0; i < recog_data.n_operands; i++)
{
operand = recog_data.operand[i];
if (REG_SUBREG_P (operand)
&& find_reg_note (insn, REG_DEAD,
REG_P (operand)
? operand : SUBREG_REG (operand)) != NULL_RTX)
/* If an operand dies, prefer its hard register for the output
operands by decreasing the hard register cost or creating
the corresponding allocno copies. The cost will not
correspond to a real move insn cost, so make the frequency
smaller. */
process_reg_shuffles (operand, i, freq < 8 ? 1 : freq / 8, bound_p);
}
} | /* Process INSN and create allocno copies if necessary. For example,
it might be because INSN is a pseudo-register move or INSN is two
operand insn. */ | Process INSN and create allocno copies if necessary. For example,
it might be because INSN is a pseudo-register move or INSN is two
operand insn. | [
"Process",
"INSN",
"and",
"create",
"allocno",
"copies",
"if",
"necessary",
".",
"For",
"example",
"it",
"might",
"be",
"because",
"INSN",
"is",
"a",
"pseudo",
"-",
"register",
"move",
"or",
"INSN",
"is",
"two",
"operand",
"insn",
"."
] | static void
add_insn_allocno_copies (rtx_insn *insn)
{
rtx set, operand, dup;
bool bound_p[MAX_RECOG_OPERANDS];
int i, n, freq;
HARD_REG_SET alts;
freq = REG_FREQ_FROM_BB (BLOCK_FOR_INSN (insn));
if (freq == 0)
freq = 1;
if ((set = single_set (insn)) != NULL_RTX
&& REG_SUBREG_P (SET_DEST (set)) && REG_SUBREG_P (SET_SRC (set))
&& ! side_effects_p (set)
&& find_reg_note (insn, REG_DEAD,
REG_P (SET_SRC (set))
? SET_SRC (set)
: SUBREG_REG (SET_SRC (set))) != NULL_RTX)
{
process_regs_for_copy (SET_SRC (set), SET_DEST (set),
false, insn, freq);
return;
}
if (! find_reg_note (insn, REG_DEAD, NULL_RTX))
return;
ira_setup_alts (insn, alts);
for (i = 0; i < recog_data.n_operands; i++)
bound_p[i] = false;
for (i = 0; i < recog_data.n_operands; i++)
{
operand = recog_data.operand[i];
if (! REG_SUBREG_P (operand))
continue;
if ((n = ira_get_dup_out_num (i, alts)) >= 0)
{
bound_p[n] = true;
dup = recog_data.operand[n];
if (REG_SUBREG_P (dup)
&& find_reg_note (insn, REG_DEAD,
REG_P (operand)
? operand
: SUBREG_REG (operand)) != NULL_RTX)
process_regs_for_copy (operand, dup, true, NULL,
freq);
}
}
for (i = 0; i < recog_data.n_operands; i++)
{
operand = recog_data.operand[i];
if (REG_SUBREG_P (operand)
&& find_reg_note (insn, REG_DEAD,
REG_P (operand)
? operand : SUBREG_REG (operand)) != NULL_RTX)
process_reg_shuffles (operand, i, freq < 8 ? 1 : freq / 8, bound_p);
}
} | [
"static",
"void",
"add_insn_allocno_copies",
"(",
"rtx_insn",
"*",
"insn",
")",
"{",
"rtx",
"set",
",",
"operand",
",",
"dup",
";",
"bool",
"bound_p",
"[",
"MAX_RECOG_OPERANDS",
"]",
";",
"int",
"i",
",",
"n",
",",
"freq",
";",
"HARD_REG_SET",
"alts",
";",
"freq",
"=",
"REG_FREQ_FROM_BB",
"(",
"BLOCK_FOR_INSN",
"(",
"insn",
")",
")",
";",
"if",
"(",
"freq",
"==",
"0",
")",
"freq",
"=",
"1",
";",
"if",
"(",
"(",
"set",
"=",
"single_set",
"(",
"insn",
")",
")",
"!=",
"NULL_RTX",
"&&",
"REG_SUBREG_P",
"(",
"SET_DEST",
"(",
"set",
")",
")",
"&&",
"REG_SUBREG_P",
"(",
"SET_SRC",
"(",
"set",
")",
")",
"&&",
"!",
"side_effects_p",
"(",
"set",
")",
"&&",
"find_reg_note",
"(",
"insn",
",",
"REG_DEAD",
",",
"REG_P",
"(",
"SET_SRC",
"(",
"set",
")",
")",
"?",
"SET_SRC",
"(",
"set",
")",
":",
"SUBREG_REG",
"(",
"SET_SRC",
"(",
"set",
")",
")",
")",
"!=",
"NULL_RTX",
")",
"{",
"process_regs_for_copy",
"(",
"SET_SRC",
"(",
"set",
")",
",",
"SET_DEST",
"(",
"set",
")",
",",
"false",
",",
"insn",
",",
"freq",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"find_reg_note",
"(",
"insn",
",",
"REG_DEAD",
",",
"NULL_RTX",
")",
")",
"return",
";",
"ira_setup_alts",
"(",
"insn",
",",
"alts",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"recog_data",
".",
"n_operands",
";",
"i",
"++",
")",
"bound_p",
"[",
"i",
"]",
"=",
"false",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"recog_data",
".",
"n_operands",
";",
"i",
"++",
")",
"{",
"operand",
"=",
"recog_data",
".",
"operand",
"[",
"i",
"]",
";",
"if",
"(",
"!",
"REG_SUBREG_P",
"(",
"operand",
")",
")",
"continue",
";",
"if",
"(",
"(",
"n",
"=",
"ira_get_dup_out_num",
"(",
"i",
",",
"alts",
")",
")",
">=",
"0",
")",
"{",
"bound_p",
"[",
"n",
"]",
"=",
"true",
";",
"dup",
"=",
"recog_data",
".",
"operand",
"[",
"n",
"]",
";",
"if",
"(",
"REG_SUBREG_P",
"(",
"dup",
")",
"&&",
"find_reg_note",
"(",
"insn",
",",
"REG_DEAD",
",",
"REG_P",
"(",
"operand",
")",
"?",
"operand",
":",
"SUBREG_REG",
"(",
"operand",
")",
")",
"!=",
"NULL_RTX",
")",
"process_regs_for_copy",
"(",
"operand",
",",
"dup",
",",
"true",
",",
"NULL",
",",
"freq",
")",
";",
"}",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"recog_data",
".",
"n_operands",
";",
"i",
"++",
")",
"{",
"operand",
"=",
"recog_data",
".",
"operand",
"[",
"i",
"]",
";",
"if",
"(",
"REG_SUBREG_P",
"(",
"operand",
")",
"&&",
"find_reg_note",
"(",
"insn",
",",
"REG_DEAD",
",",
"REG_P",
"(",
"operand",
")",
"?",
"operand",
":",
"SUBREG_REG",
"(",
"operand",
")",
")",
"!=",
"NULL_RTX",
")",
"process_reg_shuffles",
"(",
"operand",
",",
"i",
",",
"freq",
"<",
"8",
"?",
"1",
":",
"freq",
"/",
"8",
",",
"bound_p",
")",
";",
"}",
"}"
] | Process INSN and create allocno copies if necessary. | [
"Process",
"INSN",
"and",
"create",
"allocno",
"copies",
"if",
"necessary",
"."
] | [
"/* Fast check of possibility of constraint or shuffle copies. If\n there are no dead registers, there will be no such copies. */",
"/* If an operand dies, prefer its hard register for the output\n\t operands by decreasing the hard register cost or creating\n\t the corresponding allocno copies. The cost will not\n\t correspond to a real move insn cost, so make the frequency\n\t smaller. */"
] | [
{
"param": "insn",
"type": "rtx_insn"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "insn",
"type": "rtx_insn",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
eb85e7752aeea51ac1092eebdf61e7d2f489f185 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/ira-conflicts.c | [
"BSD-3-Clause"
] | C | add_copies | void | static void
add_copies (ira_loop_tree_node_t loop_tree_node)
{
basic_block bb;
rtx_insn *insn;
bb = loop_tree_node->bb;
if (bb == NULL)
return;
FOR_BB_INSNS (bb, insn)
if (NONDEBUG_INSN_P (insn))
add_insn_allocno_copies (insn);
} | /* Add copies originated from BB given by LOOP_TREE_NODE. */ | Add copies originated from BB given by LOOP_TREE_NODE. | [
"Add",
"copies",
"originated",
"from",
"BB",
"given",
"by",
"LOOP_TREE_NODE",
"."
] | static void
add_copies (ira_loop_tree_node_t loop_tree_node)
{
basic_block bb;
rtx_insn *insn;
bb = loop_tree_node->bb;
if (bb == NULL)
return;
FOR_BB_INSNS (bb, insn)
if (NONDEBUG_INSN_P (insn))
add_insn_allocno_copies (insn);
} | [
"static",
"void",
"add_copies",
"(",
"ira_loop_tree_node_t",
"loop_tree_node",
")",
"{",
"basic_block",
"bb",
";",
"rtx_insn",
"*",
"insn",
";",
"bb",
"=",
"loop_tree_node",
"->",
"bb",
";",
"if",
"(",
"bb",
"==",
"NULL",
")",
"return",
";",
"FOR_BB_INSNS",
"(",
"bb",
",",
"insn",
")",
"",
"if",
"(",
"NONDEBUG_INSN_P",
"(",
"insn",
")",
")",
"add_insn_allocno_copies",
"(",
"insn",
")",
";",
"}"
] | Add copies originated from BB given by LOOP_TREE_NODE. | [
"Add",
"copies",
"originated",
"from",
"BB",
"given",
"by",
"LOOP_TREE_NODE",
"."
] | [] | [
{
"param": "loop_tree_node",
"type": "ira_loop_tree_node_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "loop_tree_node",
"type": "ira_loop_tree_node_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
eb85e7752aeea51ac1092eebdf61e7d2f489f185 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/ira-conflicts.c | [
"BSD-3-Clause"
] | C | propagate_copies | void | static void
propagate_copies (void)
{
ira_copy_t cp;
ira_copy_iterator ci;
ira_allocno_t a1, a2, parent_a1, parent_a2;
FOR_EACH_COPY (cp, ci)
{
a1 = cp->first;
a2 = cp->second;
if (ALLOCNO_LOOP_TREE_NODE (a1) == ira_loop_tree_root)
continue;
ira_assert ((ALLOCNO_LOOP_TREE_NODE (a2) != ira_loop_tree_root));
parent_a1 = ira_parent_or_cap_allocno (a1);
parent_a2 = ira_parent_or_cap_allocno (a2);
ira_assert (parent_a1 != NULL && parent_a2 != NULL);
if (! allocnos_conflict_for_copy_p (parent_a1, parent_a2))
ira_add_allocno_copy (parent_a1, parent_a2, cp->freq,
cp->constraint_p, cp->insn, cp->loop_tree_node);
}
} | /* Propagate copies the corresponding allocnos on upper loop tree
level. */ | Propagate copies the corresponding allocnos on upper loop tree
level. | [
"Propagate",
"copies",
"the",
"corresponding",
"allocnos",
"on",
"upper",
"loop",
"tree",
"level",
"."
] | static void
propagate_copies (void)
{
ira_copy_t cp;
ira_copy_iterator ci;
ira_allocno_t a1, a2, parent_a1, parent_a2;
FOR_EACH_COPY (cp, ci)
{
a1 = cp->first;
a2 = cp->second;
if (ALLOCNO_LOOP_TREE_NODE (a1) == ira_loop_tree_root)
continue;
ira_assert ((ALLOCNO_LOOP_TREE_NODE (a2) != ira_loop_tree_root));
parent_a1 = ira_parent_or_cap_allocno (a1);
parent_a2 = ira_parent_or_cap_allocno (a2);
ira_assert (parent_a1 != NULL && parent_a2 != NULL);
if (! allocnos_conflict_for_copy_p (parent_a1, parent_a2))
ira_add_allocno_copy (parent_a1, parent_a2, cp->freq,
cp->constraint_p, cp->insn, cp->loop_tree_node);
}
} | [
"static",
"void",
"propagate_copies",
"(",
"void",
")",
"{",
"ira_copy_t",
"cp",
";",
"ira_copy_iterator",
"ci",
";",
"ira_allocno_t",
"a1",
",",
"a2",
",",
"parent_a1",
",",
"parent_a2",
";",
"FOR_EACH_COPY",
"(",
"cp",
",",
"ci",
")",
"",
"{",
"a1",
"=",
"cp",
"->",
"first",
";",
"a2",
"=",
"cp",
"->",
"second",
";",
"if",
"(",
"ALLOCNO_LOOP_TREE_NODE",
"(",
"a1",
")",
"==",
"ira_loop_tree_root",
")",
"continue",
";",
"ira_assert",
"(",
"(",
"ALLOCNO_LOOP_TREE_NODE",
"(",
"a2",
")",
"!=",
"ira_loop_tree_root",
")",
")",
";",
"parent_a1",
"=",
"ira_parent_or_cap_allocno",
"(",
"a1",
")",
";",
"parent_a2",
"=",
"ira_parent_or_cap_allocno",
"(",
"a2",
")",
";",
"ira_assert",
"(",
"parent_a1",
"!=",
"NULL",
"&&",
"parent_a2",
"!=",
"NULL",
")",
";",
"if",
"(",
"!",
"allocnos_conflict_for_copy_p",
"(",
"parent_a1",
",",
"parent_a2",
")",
")",
"ira_add_allocno_copy",
"(",
"parent_a1",
",",
"parent_a2",
",",
"cp",
"->",
"freq",
",",
"cp",
"->",
"constraint_p",
",",
"cp",
"->",
"insn",
",",
"cp",
"->",
"loop_tree_node",
")",
";",
"}",
"}"
] | Propagate copies the corresponding allocnos on upper loop tree
level. | [
"Propagate",
"copies",
"the",
"corresponding",
"allocnos",
"on",
"upper",
"loop",
"tree",
"level",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
eb85e7752aeea51ac1092eebdf61e7d2f489f185 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/ira-conflicts.c | [
"BSD-3-Clause"
] | C | build_object_conflicts | void | static void
build_object_conflicts (ira_object_t obj)
{
int i, px, parent_num;
ira_allocno_t parent_a, another_parent_a;
ira_object_t parent_obj;
ira_allocno_t a = OBJECT_ALLOCNO (obj);
IRA_INT_TYPE *object_conflicts;
minmax_set_iterator asi;
int parent_min, parent_max ATTRIBUTE_UNUSED;
object_conflicts = conflicts[OBJECT_CONFLICT_ID (obj)];
px = 0;
FOR_EACH_BIT_IN_MINMAX_SET (object_conflicts,
OBJECT_MIN (obj), OBJECT_MAX (obj), i, asi)
{
ira_object_t another_obj = ira_object_id_map[i];
ira_allocno_t another_a = OBJECT_ALLOCNO (obj);
ira_assert (ira_reg_classes_intersect_p
[ALLOCNO_CLASS (a)][ALLOCNO_CLASS (another_a)]);
collected_conflict_objects[px++] = another_obj;
}
if (ira_conflict_vector_profitable_p (obj, px))
{
ira_object_t *vec;
ira_allocate_conflict_vec (obj, px);
vec = OBJECT_CONFLICT_VEC (obj);
memcpy (vec, collected_conflict_objects, sizeof (ira_object_t) * px);
vec[px] = NULL;
OBJECT_NUM_CONFLICTS (obj) = px;
}
else
{
int conflict_bit_vec_words_num;
OBJECT_CONFLICT_ARRAY (obj) = object_conflicts;
if (OBJECT_MAX (obj) < OBJECT_MIN (obj))
conflict_bit_vec_words_num = 0;
else
conflict_bit_vec_words_num
= ((OBJECT_MAX (obj) - OBJECT_MIN (obj) + IRA_INT_BITS)
/ IRA_INT_BITS);
OBJECT_CONFLICT_ARRAY_SIZE (obj)
= conflict_bit_vec_words_num * sizeof (IRA_INT_TYPE);
}
parent_a = ira_parent_or_cap_allocno (a);
if (parent_a == NULL)
return;
ira_assert (ALLOCNO_CLASS (a) == ALLOCNO_CLASS (parent_a));
ira_assert (ALLOCNO_NUM_OBJECTS (a) == ALLOCNO_NUM_OBJECTS (parent_a));
parent_obj = ALLOCNO_OBJECT (parent_a, OBJECT_SUBWORD (obj));
parent_num = OBJECT_CONFLICT_ID (parent_obj);
parent_min = OBJECT_MIN (parent_obj);
parent_max = OBJECT_MAX (parent_obj);
FOR_EACH_BIT_IN_MINMAX_SET (object_conflicts,
OBJECT_MIN (obj), OBJECT_MAX (obj), i, asi)
{
ira_object_t another_obj = ira_object_id_map[i];
ira_allocno_t another_a = OBJECT_ALLOCNO (another_obj);
int another_word = OBJECT_SUBWORD (another_obj);
ira_assert (ira_reg_classes_intersect_p
[ALLOCNO_CLASS (a)][ALLOCNO_CLASS (another_a)]);
another_parent_a = ira_parent_or_cap_allocno (another_a);
if (another_parent_a == NULL)
continue;
ira_assert (ALLOCNO_NUM (another_parent_a) >= 0);
ira_assert (ALLOCNO_CLASS (another_a)
== ALLOCNO_CLASS (another_parent_a));
ira_assert (ALLOCNO_NUM_OBJECTS (another_a)
== ALLOCNO_NUM_OBJECTS (another_parent_a));
SET_MINMAX_SET_BIT (conflicts[parent_num],
OBJECT_CONFLICT_ID (ALLOCNO_OBJECT (another_parent_a,
another_word)),
parent_min, parent_max);
}
} | /* Build conflict vectors or bit conflict vectors (whatever is more
profitable) for object OBJ from the conflict table. */ | Build conflict vectors or bit conflict vectors (whatever is more
profitable) for object OBJ from the conflict table. | [
"Build",
"conflict",
"vectors",
"or",
"bit",
"conflict",
"vectors",
"(",
"whatever",
"is",
"more",
"profitable",
")",
"for",
"object",
"OBJ",
"from",
"the",
"conflict",
"table",
"."
] | static void
build_object_conflicts (ira_object_t obj)
{
int i, px, parent_num;
ira_allocno_t parent_a, another_parent_a;
ira_object_t parent_obj;
ira_allocno_t a = OBJECT_ALLOCNO (obj);
IRA_INT_TYPE *object_conflicts;
minmax_set_iterator asi;
int parent_min, parent_max ATTRIBUTE_UNUSED;
object_conflicts = conflicts[OBJECT_CONFLICT_ID (obj)];
px = 0;
FOR_EACH_BIT_IN_MINMAX_SET (object_conflicts,
OBJECT_MIN (obj), OBJECT_MAX (obj), i, asi)
{
ira_object_t another_obj = ira_object_id_map[i];
ira_allocno_t another_a = OBJECT_ALLOCNO (obj);
ira_assert (ira_reg_classes_intersect_p
[ALLOCNO_CLASS (a)][ALLOCNO_CLASS (another_a)]);
collected_conflict_objects[px++] = another_obj;
}
if (ira_conflict_vector_profitable_p (obj, px))
{
ira_object_t *vec;
ira_allocate_conflict_vec (obj, px);
vec = OBJECT_CONFLICT_VEC (obj);
memcpy (vec, collected_conflict_objects, sizeof (ira_object_t) * px);
vec[px] = NULL;
OBJECT_NUM_CONFLICTS (obj) = px;
}
else
{
int conflict_bit_vec_words_num;
OBJECT_CONFLICT_ARRAY (obj) = object_conflicts;
if (OBJECT_MAX (obj) < OBJECT_MIN (obj))
conflict_bit_vec_words_num = 0;
else
conflict_bit_vec_words_num
= ((OBJECT_MAX (obj) - OBJECT_MIN (obj) + IRA_INT_BITS)
/ IRA_INT_BITS);
OBJECT_CONFLICT_ARRAY_SIZE (obj)
= conflict_bit_vec_words_num * sizeof (IRA_INT_TYPE);
}
parent_a = ira_parent_or_cap_allocno (a);
if (parent_a == NULL)
return;
ira_assert (ALLOCNO_CLASS (a) == ALLOCNO_CLASS (parent_a));
ira_assert (ALLOCNO_NUM_OBJECTS (a) == ALLOCNO_NUM_OBJECTS (parent_a));
parent_obj = ALLOCNO_OBJECT (parent_a, OBJECT_SUBWORD (obj));
parent_num = OBJECT_CONFLICT_ID (parent_obj);
parent_min = OBJECT_MIN (parent_obj);
parent_max = OBJECT_MAX (parent_obj);
FOR_EACH_BIT_IN_MINMAX_SET (object_conflicts,
OBJECT_MIN (obj), OBJECT_MAX (obj), i, asi)
{
ira_object_t another_obj = ira_object_id_map[i];
ira_allocno_t another_a = OBJECT_ALLOCNO (another_obj);
int another_word = OBJECT_SUBWORD (another_obj);
ira_assert (ira_reg_classes_intersect_p
[ALLOCNO_CLASS (a)][ALLOCNO_CLASS (another_a)]);
another_parent_a = ira_parent_or_cap_allocno (another_a);
if (another_parent_a == NULL)
continue;
ira_assert (ALLOCNO_NUM (another_parent_a) >= 0);
ira_assert (ALLOCNO_CLASS (another_a)
== ALLOCNO_CLASS (another_parent_a));
ira_assert (ALLOCNO_NUM_OBJECTS (another_a)
== ALLOCNO_NUM_OBJECTS (another_parent_a));
SET_MINMAX_SET_BIT (conflicts[parent_num],
OBJECT_CONFLICT_ID (ALLOCNO_OBJECT (another_parent_a,
another_word)),
parent_min, parent_max);
}
} | [
"static",
"void",
"build_object_conflicts",
"(",
"ira_object_t",
"obj",
")",
"{",
"int",
"i",
",",
"px",
",",
"parent_num",
";",
"ira_allocno_t",
"parent_a",
",",
"another_parent_a",
";",
"ira_object_t",
"parent_obj",
";",
"ira_allocno_t",
"a",
"=",
"OBJECT_ALLOCNO",
"(",
"obj",
")",
";",
"IRA_INT_TYPE",
"*",
"object_conflicts",
";",
"minmax_set_iterator",
"asi",
";",
"int",
"parent_min",
",",
"parent_max",
"",
"ATTRIBUTE_UNUSED",
";",
"object_conflicts",
"=",
"conflicts",
"[",
"OBJECT_CONFLICT_ID",
"(",
"obj",
")",
"]",
";",
"px",
"=",
"0",
";",
"FOR_EACH_BIT_IN_MINMAX_SET",
"(",
"object_conflicts",
",",
"OBJECT_MIN",
"(",
"obj",
")",
",",
"OBJECT_MAX",
"(",
"obj",
")",
",",
"i",
",",
"asi",
")",
"",
"{",
"ira_object_t",
"another_obj",
"=",
"ira_object_id_map",
"[",
"i",
"]",
";",
"ira_allocno_t",
"another_a",
"=",
"OBJECT_ALLOCNO",
"(",
"obj",
")",
";",
"ira_assert",
"(",
"ira_reg_classes_intersect_p",
"[",
"ALLOCNO_CLASS",
"(",
"a",
")",
"]",
"[",
"ALLOCNO_CLASS",
"(",
"another_a",
")",
"]",
")",
";",
"collected_conflict_objects",
"[",
"px",
"++",
"]",
"=",
"another_obj",
";",
"}",
"if",
"(",
"ira_conflict_vector_profitable_p",
"(",
"obj",
",",
"px",
")",
")",
"{",
"ira_object_t",
"*",
"vec",
";",
"ira_allocate_conflict_vec",
"(",
"obj",
",",
"px",
")",
";",
"vec",
"=",
"OBJECT_CONFLICT_VEC",
"(",
"obj",
")",
";",
"memcpy",
"(",
"vec",
",",
"collected_conflict_objects",
",",
"sizeof",
"(",
"ira_object_t",
")",
"*",
"px",
")",
";",
"vec",
"[",
"px",
"]",
"=",
"NULL",
";",
"OBJECT_NUM_CONFLICTS",
"(",
"obj",
")",
"=",
"px",
";",
"}",
"else",
"{",
"int",
"conflict_bit_vec_words_num",
";",
"OBJECT_CONFLICT_ARRAY",
"(",
"obj",
")",
"=",
"object_conflicts",
";",
"if",
"(",
"OBJECT_MAX",
"(",
"obj",
")",
"<",
"OBJECT_MIN",
"(",
"obj",
")",
")",
"conflict_bit_vec_words_num",
"=",
"0",
";",
"else",
"conflict_bit_vec_words_num",
"=",
"(",
"(",
"OBJECT_MAX",
"(",
"obj",
")",
"-",
"OBJECT_MIN",
"(",
"obj",
")",
"+",
"IRA_INT_BITS",
")",
"/",
"IRA_INT_BITS",
")",
";",
"OBJECT_CONFLICT_ARRAY_SIZE",
"(",
"obj",
")",
"=",
"conflict_bit_vec_words_num",
"*",
"sizeof",
"(",
"IRA_INT_TYPE",
")",
";",
"}",
"parent_a",
"=",
"ira_parent_or_cap_allocno",
"(",
"a",
")",
";",
"if",
"(",
"parent_a",
"==",
"NULL",
")",
"return",
";",
"ira_assert",
"(",
"ALLOCNO_CLASS",
"(",
"a",
")",
"==",
"ALLOCNO_CLASS",
"(",
"parent_a",
")",
")",
";",
"ira_assert",
"(",
"ALLOCNO_NUM_OBJECTS",
"(",
"a",
")",
"==",
"ALLOCNO_NUM_OBJECTS",
"(",
"parent_a",
")",
")",
";",
"parent_obj",
"=",
"ALLOCNO_OBJECT",
"(",
"parent_a",
",",
"OBJECT_SUBWORD",
"(",
"obj",
")",
")",
";",
"parent_num",
"=",
"OBJECT_CONFLICT_ID",
"(",
"parent_obj",
")",
";",
"parent_min",
"=",
"OBJECT_MIN",
"(",
"parent_obj",
")",
";",
"parent_max",
"=",
"OBJECT_MAX",
"(",
"parent_obj",
")",
";",
"FOR_EACH_BIT_IN_MINMAX_SET",
"(",
"object_conflicts",
",",
"OBJECT_MIN",
"(",
"obj",
")",
",",
"OBJECT_MAX",
"(",
"obj",
")",
",",
"i",
",",
"asi",
")",
"",
"{",
"ira_object_t",
"another_obj",
"=",
"ira_object_id_map",
"[",
"i",
"]",
";",
"ira_allocno_t",
"another_a",
"=",
"OBJECT_ALLOCNO",
"(",
"another_obj",
")",
";",
"int",
"another_word",
"=",
"OBJECT_SUBWORD",
"(",
"another_obj",
")",
";",
"ira_assert",
"(",
"ira_reg_classes_intersect_p",
"[",
"ALLOCNO_CLASS",
"(",
"a",
")",
"]",
"[",
"ALLOCNO_CLASS",
"(",
"another_a",
")",
"]",
")",
";",
"another_parent_a",
"=",
"ira_parent_or_cap_allocno",
"(",
"another_a",
")",
";",
"if",
"(",
"another_parent_a",
"==",
"NULL",
")",
"continue",
";",
"ira_assert",
"(",
"ALLOCNO_NUM",
"(",
"another_parent_a",
")",
">=",
"0",
")",
";",
"ira_assert",
"(",
"ALLOCNO_CLASS",
"(",
"another_a",
")",
"==",
"ALLOCNO_CLASS",
"(",
"another_parent_a",
")",
")",
";",
"ira_assert",
"(",
"ALLOCNO_NUM_OBJECTS",
"(",
"another_a",
")",
"==",
"ALLOCNO_NUM_OBJECTS",
"(",
"another_parent_a",
")",
")",
";",
"SET_MINMAX_SET_BIT",
"(",
"conflicts",
"[",
"parent_num",
"]",
",",
"OBJECT_CONFLICT_ID",
"(",
"ALLOCNO_OBJECT",
"(",
"another_parent_a",
",",
"another_word",
")",
")",
",",
"parent_min",
",",
"parent_max",
")",
";",
"}",
"}"
] | Build conflict vectors or bit conflict vectors (whatever is more
profitable) for object OBJ from the conflict table. | [
"Build",
"conflict",
"vectors",
"or",
"bit",
"conflict",
"vectors",
"(",
"whatever",
"is",
"more",
"profitable",
")",
"for",
"object",
"OBJ",
"from",
"the",
"conflict",
"table",
"."
] | [] | [
{
"param": "obj",
"type": "ira_object_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "obj",
"type": "ira_object_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
eb85e7752aeea51ac1092eebdf61e7d2f489f185 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/ira-conflicts.c | [
"BSD-3-Clause"
] | C | build_conflicts | void | static void
build_conflicts (void)
{
int i;
ira_allocno_t a, cap;
collected_conflict_objects
= (ira_object_t *) ira_allocate (sizeof (ira_object_t)
* ira_objects_num);
for (i = max_reg_num () - 1; i >= FIRST_PSEUDO_REGISTER; i--)
for (a = ira_regno_allocno_map[i];
a != NULL;
a = ALLOCNO_NEXT_REGNO_ALLOCNO (a))
{
int j, nregs = ALLOCNO_NUM_OBJECTS (a);
for (j = 0; j < nregs; j++)
{
ira_object_t obj = ALLOCNO_OBJECT (a, j);
build_object_conflicts (obj);
for (cap = ALLOCNO_CAP (a); cap != NULL; cap = ALLOCNO_CAP (cap))
{
ira_object_t cap_obj = ALLOCNO_OBJECT (cap, j);
gcc_assert (ALLOCNO_NUM_OBJECTS (cap) == ALLOCNO_NUM_OBJECTS (a));
build_object_conflicts (cap_obj);
}
}
}
ira_free (collected_conflict_objects);
} | /* Build conflict vectors or bit conflict vectors (whatever is more
profitable) of all allocnos from the conflict table. */ | Build conflict vectors or bit conflict vectors (whatever is more
profitable) of all allocnos from the conflict table. | [
"Build",
"conflict",
"vectors",
"or",
"bit",
"conflict",
"vectors",
"(",
"whatever",
"is",
"more",
"profitable",
")",
"of",
"all",
"allocnos",
"from",
"the",
"conflict",
"table",
"."
] | static void
build_conflicts (void)
{
int i;
ira_allocno_t a, cap;
collected_conflict_objects
= (ira_object_t *) ira_allocate (sizeof (ira_object_t)
* ira_objects_num);
for (i = max_reg_num () - 1; i >= FIRST_PSEUDO_REGISTER; i--)
for (a = ira_regno_allocno_map[i];
a != NULL;
a = ALLOCNO_NEXT_REGNO_ALLOCNO (a))
{
int j, nregs = ALLOCNO_NUM_OBJECTS (a);
for (j = 0; j < nregs; j++)
{
ira_object_t obj = ALLOCNO_OBJECT (a, j);
build_object_conflicts (obj);
for (cap = ALLOCNO_CAP (a); cap != NULL; cap = ALLOCNO_CAP (cap))
{
ira_object_t cap_obj = ALLOCNO_OBJECT (cap, j);
gcc_assert (ALLOCNO_NUM_OBJECTS (cap) == ALLOCNO_NUM_OBJECTS (a));
build_object_conflicts (cap_obj);
}
}
}
ira_free (collected_conflict_objects);
} | [
"static",
"void",
"build_conflicts",
"(",
"void",
")",
"{",
"int",
"i",
";",
"ira_allocno_t",
"a",
",",
"cap",
";",
"collected_conflict_objects",
"=",
"(",
"ira_object_t",
"*",
")",
"ira_allocate",
"(",
"sizeof",
"(",
"ira_object_t",
")",
"*",
"ira_objects_num",
")",
";",
"for",
"(",
"i",
"=",
"max_reg_num",
"(",
")",
"-",
"1",
";",
"i",
">=",
"FIRST_PSEUDO_REGISTER",
";",
"i",
"--",
")",
"for",
"(",
"a",
"=",
"ira_regno_allocno_map",
"[",
"i",
"]",
";",
"a",
"!=",
"NULL",
";",
"a",
"=",
"ALLOCNO_NEXT_REGNO_ALLOCNO",
"(",
"a",
")",
")",
"{",
"int",
"j",
",",
"nregs",
"=",
"ALLOCNO_NUM_OBJECTS",
"(",
"a",
")",
";",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"nregs",
";",
"j",
"++",
")",
"{",
"ira_object_t",
"obj",
"=",
"ALLOCNO_OBJECT",
"(",
"a",
",",
"j",
")",
";",
"build_object_conflicts",
"(",
"obj",
")",
";",
"for",
"(",
"cap",
"=",
"ALLOCNO_CAP",
"(",
"a",
")",
";",
"cap",
"!=",
"NULL",
";",
"cap",
"=",
"ALLOCNO_CAP",
"(",
"cap",
")",
")",
"{",
"ira_object_t",
"cap_obj",
"=",
"ALLOCNO_OBJECT",
"(",
"cap",
",",
"j",
")",
";",
"gcc_assert",
"(",
"ALLOCNO_NUM_OBJECTS",
"(",
"cap",
")",
"==",
"ALLOCNO_NUM_OBJECTS",
"(",
"a",
")",
")",
";",
"build_object_conflicts",
"(",
"cap_obj",
")",
";",
"}",
"}",
"}",
"ira_free",
"(",
"collected_conflict_objects",
")",
";",
"}"
] | Build conflict vectors or bit conflict vectors (whatever is more
profitable) of all allocnos from the conflict table. | [
"Build",
"conflict",
"vectors",
"or",
"bit",
"conflict",
"vectors",
"(",
"whatever",
"is",
"more",
"profitable",
")",
"of",
"all",
"allocnos",
"from",
"the",
"conflict",
"table",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
eb85e7752aeea51ac1092eebdf61e7d2f489f185 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/ira-conflicts.c | [
"BSD-3-Clause"
] | C | print_hard_reg_set | void | static void
print_hard_reg_set (FILE *file, const char *title, HARD_REG_SET set)
{
int i, start;
fputs (title, file);
for (start = -1, i = 0; i < FIRST_PSEUDO_REGISTER; i++)
{
if (TEST_HARD_REG_BIT (set, i))
{
if (i == 0 || ! TEST_HARD_REG_BIT (set, i - 1))
start = i;
}
if (start >= 0
&& (i == FIRST_PSEUDO_REGISTER - 1 || ! TEST_HARD_REG_BIT (set, i)))
{
if (start == i - 1)
fprintf (file, " %d", start);
else if (start == i - 2)
fprintf (file, " %d %d", start, start + 1);
else
fprintf (file, " %d-%d", start, i - 1);
start = -1;
}
}
putc ('\n', file);
} | /* Print hard reg set SET with TITLE to FILE. */ | Print hard reg set SET with TITLE to FILE. | [
"Print",
"hard",
"reg",
"set",
"SET",
"with",
"TITLE",
"to",
"FILE",
"."
] | static void
print_hard_reg_set (FILE *file, const char *title, HARD_REG_SET set)
{
int i, start;
fputs (title, file);
for (start = -1, i = 0; i < FIRST_PSEUDO_REGISTER; i++)
{
if (TEST_HARD_REG_BIT (set, i))
{
if (i == 0 || ! TEST_HARD_REG_BIT (set, i - 1))
start = i;
}
if (start >= 0
&& (i == FIRST_PSEUDO_REGISTER - 1 || ! TEST_HARD_REG_BIT (set, i)))
{
if (start == i - 1)
fprintf (file, " %d", start);
else if (start == i - 2)
fprintf (file, " %d %d", start, start + 1);
else
fprintf (file, " %d-%d", start, i - 1);
start = -1;
}
}
putc ('\n', file);
} | [
"static",
"void",
"print_hard_reg_set",
"(",
"FILE",
"*",
"file",
",",
"const",
"char",
"*",
"title",
",",
"HARD_REG_SET",
"set",
")",
"{",
"int",
"i",
",",
"start",
";",
"fputs",
"(",
"title",
",",
"file",
")",
";",
"for",
"(",
"start",
"=",
"-1",
",",
"i",
"=",
"0",
";",
"i",
"<",
"FIRST_PSEUDO_REGISTER",
";",
"i",
"++",
")",
"{",
"if",
"(",
"TEST_HARD_REG_BIT",
"(",
"set",
",",
"i",
")",
")",
"{",
"if",
"(",
"i",
"==",
"0",
"||",
"!",
"TEST_HARD_REG_BIT",
"(",
"set",
",",
"i",
"-",
"1",
")",
")",
"start",
"=",
"i",
";",
"}",
"if",
"(",
"start",
">=",
"0",
"&&",
"(",
"i",
"==",
"FIRST_PSEUDO_REGISTER",
"-",
"1",
"||",
"!",
"TEST_HARD_REG_BIT",
"(",
"set",
",",
"i",
")",
")",
")",
"{",
"if",
"(",
"start",
"==",
"i",
"-",
"1",
")",
"fprintf",
"(",
"file",
",",
"\"",
"\"",
",",
"start",
")",
";",
"else",
"if",
"(",
"start",
"==",
"i",
"-",
"2",
")",
"fprintf",
"(",
"file",
",",
"\"",
"\"",
",",
"start",
",",
"start",
"+",
"1",
")",
";",
"else",
"fprintf",
"(",
"file",
",",
"\"",
"\"",
",",
"start",
",",
"i",
"-",
"1",
")",
";",
"start",
"=",
"-1",
";",
"}",
"}",
"putc",
"(",
"'",
"\\n",
"'",
",",
"file",
")",
";",
"}"
] | Print hard reg set SET with TITLE to FILE. | [
"Print",
"hard",
"reg",
"set",
"SET",
"with",
"TITLE",
"to",
"FILE",
"."
] | [] | [
{
"param": "file",
"type": "FILE"
},
{
"param": "title",
"type": "char"
},
{
"param": "set",
"type": "HARD_REG_SET"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": "FILE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "title",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "set",
"type": "HARD_REG_SET",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
eb85e7752aeea51ac1092eebdf61e7d2f489f185 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/ira-conflicts.c | [
"BSD-3-Clause"
] | C | print_conflicts | void | static void
print_conflicts (FILE *file, bool reg_p)
{
ira_allocno_t a;
ira_allocno_iterator ai;
FOR_EACH_ALLOCNO (a, ai)
print_allocno_conflicts (file, reg_p, a);
} | /* Print information about allocno or only regno (if REG_P) conflicts
to FILE. */ | Print information about allocno or only regno (if REG_P) conflicts
to FILE. | [
"Print",
"information",
"about",
"allocno",
"or",
"only",
"regno",
"(",
"if",
"REG_P",
")",
"conflicts",
"to",
"FILE",
"."
] | static void
print_conflicts (FILE *file, bool reg_p)
{
ira_allocno_t a;
ira_allocno_iterator ai;
FOR_EACH_ALLOCNO (a, ai)
print_allocno_conflicts (file, reg_p, a);
} | [
"static",
"void",
"print_conflicts",
"(",
"FILE",
"*",
"file",
",",
"bool",
"reg_p",
")",
"{",
"ira_allocno_t",
"a",
";",
"ira_allocno_iterator",
"ai",
";",
"FOR_EACH_ALLOCNO",
"(",
"a",
",",
"ai",
")",
"",
"print_allocno_conflicts",
"(",
"file",
",",
"reg_p",
",",
"a",
")",
";",
"}"
] | Print information about allocno or only regno (if REG_P) conflicts
to FILE. | [
"Print",
"information",
"about",
"allocno",
"or",
"only",
"regno",
"(",
"if",
"REG_P",
")",
"conflicts",
"to",
"FILE",
"."
] | [] | [
{
"param": "file",
"type": "FILE"
},
{
"param": "reg_p",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": "FILE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reg_p",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
eb85e7752aeea51ac1092eebdf61e7d2f489f185 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/ira-conflicts.c | [
"BSD-3-Clause"
] | C | ira_debug_conflicts | void | void
ira_debug_conflicts (bool reg_p)
{
print_conflicts (stderr, reg_p);
} | /* Print information about allocno or only regno (if REG_P) conflicts
to stderr. */ | Print information about allocno or only regno (if REG_P) conflicts
to stderr. | [
"Print",
"information",
"about",
"allocno",
"or",
"only",
"regno",
"(",
"if",
"REG_P",
")",
"conflicts",
"to",
"stderr",
"."
] | void
ira_debug_conflicts (bool reg_p)
{
print_conflicts (stderr, reg_p);
} | [
"void",
"ira_debug_conflicts",
"(",
"bool",
"reg_p",
")",
"{",
"print_conflicts",
"(",
"stderr",
",",
"reg_p",
")",
";",
"}"
] | Print information about allocno or only regno (if REG_P) conflicts
to stderr. | [
"Print",
"information",
"about",
"allocno",
"or",
"only",
"regno",
"(",
"if",
"REG_P",
")",
"conflicts",
"to",
"stderr",
"."
] | [] | [
{
"param": "reg_p",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "reg_p",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
eb85e7752aeea51ac1092eebdf61e7d2f489f185 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/ira-conflicts.c | [
"BSD-3-Clause"
] | C | ira_build_conflicts | void | void
ira_build_conflicts (void)
{
enum reg_class base;
ira_allocno_t a;
ira_allocno_iterator ai;
HARD_REG_SET temp_hard_reg_set;
if (ira_conflicts_p)
{
ira_conflicts_p = build_conflict_bit_table ();
if (ira_conflicts_p)
{
ira_object_t obj;
ira_object_iterator oi;
build_conflicts ();
ira_traverse_loop_tree (true, ira_loop_tree_root, add_copies, NULL);
/* We need finished conflict table for the subsequent call. */
if (flag_ira_region == IRA_REGION_ALL
|| flag_ira_region == IRA_REGION_MIXED)
propagate_copies ();
/* Now we can free memory for the conflict table (see function
build_object_conflicts for details). */
FOR_EACH_OBJECT (obj, oi)
{
if (OBJECT_CONFLICT_ARRAY (obj) != conflicts[OBJECT_CONFLICT_ID (obj)])
ira_free (conflicts[OBJECT_CONFLICT_ID (obj)]);
}
ira_free (conflicts);
}
}
base = base_reg_class (VOIDmode, ADDR_SPACE_GENERIC, ADDRESS, SCRATCH);
if (! targetm.class_likely_spilled_p (base))
CLEAR_HARD_REG_SET (temp_hard_reg_set);
else
{
COPY_HARD_REG_SET (temp_hard_reg_set, reg_class_contents[base]);
AND_COMPL_HARD_REG_SET (temp_hard_reg_set, ira_no_alloc_regs);
AND_HARD_REG_SET (temp_hard_reg_set, call_used_reg_set);
}
FOR_EACH_ALLOCNO (a, ai)
{
int i, n = ALLOCNO_NUM_OBJECTS (a);
for (i = 0; i < n; i++)
{
ira_object_t obj = ALLOCNO_OBJECT (a, i);
machine_mode obj_mode = obj->allocno->mode;
rtx allocno_reg = regno_reg_rtx [ALLOCNO_REGNO (a)];
if ((! flag_caller_saves && ALLOCNO_CALLS_CROSSED_NUM (a) != 0)
/* For debugging purposes don't put user defined variables in
callee-clobbered registers. However, do allow parameters
in callee-clobbered registers to improve debugging. This
is a bit of a fragile hack. */
|| (optimize == 0
&& REG_USERVAR_P (allocno_reg)
&& ! reg_is_parm_p (allocno_reg)))
{
IOR_HARD_REG_SET (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj),
call_used_reg_set);
IOR_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj),
call_used_reg_set);
}
else if (ALLOCNO_CALLS_CROSSED_NUM (a) != 0)
{
IOR_HARD_REG_SET (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj),
no_caller_save_reg_set);
IOR_HARD_REG_SET (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj),
temp_hard_reg_set);
IOR_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj),
no_caller_save_reg_set);
IOR_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj),
temp_hard_reg_set);
}
/* Now we deal with paradoxical subreg cases where certain registers
cannot be accessed in the widest mode. */
machine_mode outer_mode = ALLOCNO_WMODE (a);
machine_mode inner_mode = ALLOCNO_MODE (a);
if (paradoxical_subreg_p (outer_mode, inner_mode))
{
enum reg_class aclass = ALLOCNO_CLASS (a);
for (int j = ira_class_hard_regs_num[aclass] - 1; j >= 0; --j)
{
int inner_regno = ira_class_hard_regs[aclass][j];
int outer_regno = simplify_subreg_regno (inner_regno,
inner_mode, 0,
outer_mode);
if (outer_regno < 0
|| !in_hard_reg_set_p (reg_class_contents[aclass],
outer_mode, outer_regno))
{
SET_HARD_REG_BIT (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj),
inner_regno);
SET_HARD_REG_BIT (OBJECT_CONFLICT_HARD_REGS (obj),
inner_regno);
}
}
}
if (ALLOCNO_CALLS_CROSSED_NUM (a) != 0)
{
int regno;
/* Allocnos bigger than the saved part of call saved
regs must conflict with them. */
for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
if (!TEST_HARD_REG_BIT (call_used_reg_set, regno)
&& targetm.hard_regno_call_part_clobbered (regno,
obj_mode))
{
SET_HARD_REG_BIT (OBJECT_CONFLICT_HARD_REGS (obj), regno);
SET_HARD_REG_BIT (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj),
regno);
}
}
}
}
if (optimize && ira_conflicts_p
&& internal_flag_ira_verbose > 2 && ira_dump_file != NULL)
print_conflicts (ira_dump_file, false);
} | /* Entry function which builds allocno conflicts and allocno copies
and accumulate some allocno info on upper level regions. */ | Entry function which builds allocno conflicts and allocno copies
and accumulate some allocno info on upper level regions. | [
"Entry",
"function",
"which",
"builds",
"allocno",
"conflicts",
"and",
"allocno",
"copies",
"and",
"accumulate",
"some",
"allocno",
"info",
"on",
"upper",
"level",
"regions",
"."
] | void
ira_build_conflicts (void)
{
enum reg_class base;
ira_allocno_t a;
ira_allocno_iterator ai;
HARD_REG_SET temp_hard_reg_set;
if (ira_conflicts_p)
{
ira_conflicts_p = build_conflict_bit_table ();
if (ira_conflicts_p)
{
ira_object_t obj;
ira_object_iterator oi;
build_conflicts ();
ira_traverse_loop_tree (true, ira_loop_tree_root, add_copies, NULL);
if (flag_ira_region == IRA_REGION_ALL
|| flag_ira_region == IRA_REGION_MIXED)
propagate_copies ();
FOR_EACH_OBJECT (obj, oi)
{
if (OBJECT_CONFLICT_ARRAY (obj) != conflicts[OBJECT_CONFLICT_ID (obj)])
ira_free (conflicts[OBJECT_CONFLICT_ID (obj)]);
}
ira_free (conflicts);
}
}
base = base_reg_class (VOIDmode, ADDR_SPACE_GENERIC, ADDRESS, SCRATCH);
if (! targetm.class_likely_spilled_p (base))
CLEAR_HARD_REG_SET (temp_hard_reg_set);
else
{
COPY_HARD_REG_SET (temp_hard_reg_set, reg_class_contents[base]);
AND_COMPL_HARD_REG_SET (temp_hard_reg_set, ira_no_alloc_regs);
AND_HARD_REG_SET (temp_hard_reg_set, call_used_reg_set);
}
FOR_EACH_ALLOCNO (a, ai)
{
int i, n = ALLOCNO_NUM_OBJECTS (a);
for (i = 0; i < n; i++)
{
ira_object_t obj = ALLOCNO_OBJECT (a, i);
machine_mode obj_mode = obj->allocno->mode;
rtx allocno_reg = regno_reg_rtx [ALLOCNO_REGNO (a)];
if ((! flag_caller_saves && ALLOCNO_CALLS_CROSSED_NUM (a) != 0)
|| (optimize == 0
&& REG_USERVAR_P (allocno_reg)
&& ! reg_is_parm_p (allocno_reg)))
{
IOR_HARD_REG_SET (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj),
call_used_reg_set);
IOR_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj),
call_used_reg_set);
}
else if (ALLOCNO_CALLS_CROSSED_NUM (a) != 0)
{
IOR_HARD_REG_SET (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj),
no_caller_save_reg_set);
IOR_HARD_REG_SET (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj),
temp_hard_reg_set);
IOR_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj),
no_caller_save_reg_set);
IOR_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj),
temp_hard_reg_set);
}
machine_mode outer_mode = ALLOCNO_WMODE (a);
machine_mode inner_mode = ALLOCNO_MODE (a);
if (paradoxical_subreg_p (outer_mode, inner_mode))
{
enum reg_class aclass = ALLOCNO_CLASS (a);
for (int j = ira_class_hard_regs_num[aclass] - 1; j >= 0; --j)
{
int inner_regno = ira_class_hard_regs[aclass][j];
int outer_regno = simplify_subreg_regno (inner_regno,
inner_mode, 0,
outer_mode);
if (outer_regno < 0
|| !in_hard_reg_set_p (reg_class_contents[aclass],
outer_mode, outer_regno))
{
SET_HARD_REG_BIT (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj),
inner_regno);
SET_HARD_REG_BIT (OBJECT_CONFLICT_HARD_REGS (obj),
inner_regno);
}
}
}
if (ALLOCNO_CALLS_CROSSED_NUM (a) != 0)
{
int regno;
for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
if (!TEST_HARD_REG_BIT (call_used_reg_set, regno)
&& targetm.hard_regno_call_part_clobbered (regno,
obj_mode))
{
SET_HARD_REG_BIT (OBJECT_CONFLICT_HARD_REGS (obj), regno);
SET_HARD_REG_BIT (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj),
regno);
}
}
}
}
if (optimize && ira_conflicts_p
&& internal_flag_ira_verbose > 2 && ira_dump_file != NULL)
print_conflicts (ira_dump_file, false);
} | [
"void",
"ira_build_conflicts",
"(",
"void",
")",
"{",
"enum",
"reg_class",
"base",
";",
"ira_allocno_t",
"a",
";",
"ira_allocno_iterator",
"ai",
";",
"HARD_REG_SET",
"temp_hard_reg_set",
";",
"if",
"(",
"ira_conflicts_p",
")",
"{",
"ira_conflicts_p",
"=",
"build_conflict_bit_table",
"(",
")",
";",
"if",
"(",
"ira_conflicts_p",
")",
"{",
"ira_object_t",
"obj",
";",
"ira_object_iterator",
"oi",
";",
"build_conflicts",
"(",
")",
";",
"ira_traverse_loop_tree",
"(",
"true",
",",
"ira_loop_tree_root",
",",
"add_copies",
",",
"NULL",
")",
";",
"if",
"(",
"flag_ira_region",
"==",
"IRA_REGION_ALL",
"||",
"flag_ira_region",
"==",
"IRA_REGION_MIXED",
")",
"propagate_copies",
"(",
")",
";",
"FOR_EACH_OBJECT",
"(",
"obj",
",",
"oi",
")",
"",
"{",
"if",
"(",
"OBJECT_CONFLICT_ARRAY",
"(",
"obj",
")",
"!=",
"conflicts",
"[",
"OBJECT_CONFLICT_ID",
"(",
"obj",
")",
"]",
")",
"ira_free",
"(",
"conflicts",
"[",
"OBJECT_CONFLICT_ID",
"(",
"obj",
")",
"]",
")",
";",
"}",
"ira_free",
"(",
"conflicts",
")",
";",
"}",
"}",
"base",
"=",
"base_reg_class",
"(",
"VOIDmode",
",",
"ADDR_SPACE_GENERIC",
",",
"ADDRESS",
",",
"SCRATCH",
")",
";",
"if",
"(",
"!",
"targetm",
".",
"class_likely_spilled_p",
"(",
"base",
")",
")",
"CLEAR_HARD_REG_SET",
"(",
"temp_hard_reg_set",
")",
";",
"else",
"{",
"COPY_HARD_REG_SET",
"(",
"temp_hard_reg_set",
",",
"reg_class_contents",
"[",
"base",
"]",
")",
";",
"AND_COMPL_HARD_REG_SET",
"(",
"temp_hard_reg_set",
",",
"ira_no_alloc_regs",
")",
";",
"AND_HARD_REG_SET",
"(",
"temp_hard_reg_set",
",",
"call_used_reg_set",
")",
";",
"}",
"FOR_EACH_ALLOCNO",
"(",
"a",
",",
"ai",
")",
"",
"{",
"int",
"i",
",",
"n",
"=",
"ALLOCNO_NUM_OBJECTS",
"(",
"a",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"ira_object_t",
"obj",
"=",
"ALLOCNO_OBJECT",
"(",
"a",
",",
"i",
")",
";",
"machine_mode",
"obj_mode",
"=",
"obj",
"->",
"allocno",
"->",
"mode",
";",
"rtx",
"allocno_reg",
"=",
"regno_reg_rtx",
"[",
"ALLOCNO_REGNO",
"(",
"a",
")",
"]",
";",
"if",
"(",
"(",
"!",
"flag_caller_saves",
"&&",
"ALLOCNO_CALLS_CROSSED_NUM",
"(",
"a",
")",
"!=",
"0",
")",
"||",
"(",
"optimize",
"==",
"0",
"&&",
"REG_USERVAR_P",
"(",
"allocno_reg",
")",
"&&",
"!",
"reg_is_parm_p",
"(",
"allocno_reg",
")",
")",
")",
"{",
"IOR_HARD_REG_SET",
"(",
"OBJECT_TOTAL_CONFLICT_HARD_REGS",
"(",
"obj",
")",
",",
"call_used_reg_set",
")",
";",
"IOR_HARD_REG_SET",
"(",
"OBJECT_CONFLICT_HARD_REGS",
"(",
"obj",
")",
",",
"call_used_reg_set",
")",
";",
"}",
"else",
"if",
"(",
"ALLOCNO_CALLS_CROSSED_NUM",
"(",
"a",
")",
"!=",
"0",
")",
"{",
"IOR_HARD_REG_SET",
"(",
"OBJECT_TOTAL_CONFLICT_HARD_REGS",
"(",
"obj",
")",
",",
"no_caller_save_reg_set",
")",
";",
"IOR_HARD_REG_SET",
"(",
"OBJECT_TOTAL_CONFLICT_HARD_REGS",
"(",
"obj",
")",
",",
"temp_hard_reg_set",
")",
";",
"IOR_HARD_REG_SET",
"(",
"OBJECT_CONFLICT_HARD_REGS",
"(",
"obj",
")",
",",
"no_caller_save_reg_set",
")",
";",
"IOR_HARD_REG_SET",
"(",
"OBJECT_CONFLICT_HARD_REGS",
"(",
"obj",
")",
",",
"temp_hard_reg_set",
")",
";",
"}",
"machine_mode",
"outer_mode",
"=",
"ALLOCNO_WMODE",
"(",
"a",
")",
";",
"machine_mode",
"inner_mode",
"=",
"ALLOCNO_MODE",
"(",
"a",
")",
";",
"if",
"(",
"paradoxical_subreg_p",
"(",
"outer_mode",
",",
"inner_mode",
")",
")",
"{",
"enum",
"reg_class",
"aclass",
"=",
"ALLOCNO_CLASS",
"(",
"a",
")",
";",
"for",
"(",
"int",
"j",
"=",
"ira_class_hard_regs_num",
"[",
"aclass",
"]",
"-",
"1",
";",
"j",
">=",
"0",
";",
"--",
"j",
")",
"{",
"int",
"inner_regno",
"=",
"ira_class_hard_regs",
"[",
"aclass",
"]",
"[",
"j",
"]",
";",
"int",
"outer_regno",
"=",
"simplify_subreg_regno",
"(",
"inner_regno",
",",
"inner_mode",
",",
"0",
",",
"outer_mode",
")",
";",
"if",
"(",
"outer_regno",
"<",
"0",
"||",
"!",
"in_hard_reg_set_p",
"(",
"reg_class_contents",
"[",
"aclass",
"]",
",",
"outer_mode",
",",
"outer_regno",
")",
")",
"{",
"SET_HARD_REG_BIT",
"(",
"OBJECT_TOTAL_CONFLICT_HARD_REGS",
"(",
"obj",
")",
",",
"inner_regno",
")",
";",
"SET_HARD_REG_BIT",
"(",
"OBJECT_CONFLICT_HARD_REGS",
"(",
"obj",
")",
",",
"inner_regno",
")",
";",
"}",
"}",
"}",
"if",
"(",
"ALLOCNO_CALLS_CROSSED_NUM",
"(",
"a",
")",
"!=",
"0",
")",
"{",
"int",
"regno",
";",
"for",
"(",
"regno",
"=",
"0",
";",
"regno",
"<",
"FIRST_PSEUDO_REGISTER",
";",
"regno",
"++",
")",
"if",
"(",
"!",
"TEST_HARD_REG_BIT",
"(",
"call_used_reg_set",
",",
"regno",
")",
"&&",
"targetm",
".",
"hard_regno_call_part_clobbered",
"(",
"regno",
",",
"obj_mode",
")",
")",
"{",
"SET_HARD_REG_BIT",
"(",
"OBJECT_CONFLICT_HARD_REGS",
"(",
"obj",
")",
",",
"regno",
")",
";",
"SET_HARD_REG_BIT",
"(",
"OBJECT_TOTAL_CONFLICT_HARD_REGS",
"(",
"obj",
")",
",",
"regno",
")",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"optimize",
"&&",
"ira_conflicts_p",
"&&",
"internal_flag_ira_verbose",
">",
"2",
"&&",
"ira_dump_file",
"!=",
"NULL",
")",
"print_conflicts",
"(",
"ira_dump_file",
",",
"false",
")",
";",
"}"
] | Entry function which builds allocno conflicts and allocno copies
and accumulate some allocno info on upper level regions. | [
"Entry",
"function",
"which",
"builds",
"allocno",
"conflicts",
"and",
"allocno",
"copies",
"and",
"accumulate",
"some",
"allocno",
"info",
"on",
"upper",
"level",
"regions",
"."
] | [
"/* We need finished conflict table for the subsequent call. */",
"/* Now we can free memory for the conflict table (see function\n\t build_object_conflicts for details). */",
"/* For debugging purposes don't put user defined variables in\n\t\t callee-clobbered registers. However, do allow parameters\n\t\t in callee-clobbered registers to improve debugging. This\n\t\t is a bit of a fragile hack. */",
"/* Now we deal with paradoxical subreg cases where certain registers\n\t cannot be accessed in the widest mode. */",
"/* Allocnos bigger than the saved part of call saved\n\t\t regs must conflict with them. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
6b47d4ea8cdeabbef2b1325787abc3a8e31d78a2 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/shrink-wrap.c | [
"BSD-3-Clause"
] | C | requires_stack_frame_p | bool | bool
requires_stack_frame_p (rtx_insn *insn, HARD_REG_SET prologue_used,
HARD_REG_SET set_up_by_prologue)
{
df_ref def, use;
HARD_REG_SET hardregs;
unsigned regno;
if (CALL_P (insn))
return !SIBLING_CALL_P (insn);
/* We need a frame to get the unique CFA expected by the unwinder. */
if (cfun->can_throw_non_call_exceptions && can_throw_internal (insn))
return true;
CLEAR_HARD_REG_SET (hardregs);
FOR_EACH_INSN_DEF (def, insn)
{
rtx dreg = DF_REF_REG (def);
if (!REG_P (dreg))
continue;
add_to_hard_reg_set (&hardregs, GET_MODE (dreg), REGNO (dreg));
}
if (hard_reg_set_intersect_p (hardregs, prologue_used))
return true;
AND_COMPL_HARD_REG_SET (hardregs, call_used_reg_set);
for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
if (TEST_HARD_REG_BIT (hardregs, regno)
&& df_regs_ever_live_p (regno))
return true;
FOR_EACH_INSN_USE (use, insn)
{
rtx reg = DF_REF_REG (use);
if (!REG_P (reg))
continue;
add_to_hard_reg_set (&hardregs, GET_MODE (reg),
REGNO (reg));
}
if (hard_reg_set_intersect_p (hardregs, set_up_by_prologue))
return true;
return false;
} | /* Return true if INSN requires the stack frame to be set up.
PROLOGUE_USED contains the hard registers used in the function
prologue. SET_UP_BY_PROLOGUE is the set of registers we expect the
prologue to set up for the function. */ | Return true if INSN requires the stack frame to be set up.
PROLOGUE_USED contains the hard registers used in the function
prologue. SET_UP_BY_PROLOGUE is the set of registers we expect the
prologue to set up for the function. | [
"Return",
"true",
"if",
"INSN",
"requires",
"the",
"stack",
"frame",
"to",
"be",
"set",
"up",
".",
"PROLOGUE_USED",
"contains",
"the",
"hard",
"registers",
"used",
"in",
"the",
"function",
"prologue",
".",
"SET_UP_BY_PROLOGUE",
"is",
"the",
"set",
"of",
"registers",
"we",
"expect",
"the",
"prologue",
"to",
"set",
"up",
"for",
"the",
"function",
"."
] | bool
requires_stack_frame_p (rtx_insn *insn, HARD_REG_SET prologue_used,
HARD_REG_SET set_up_by_prologue)
{
df_ref def, use;
HARD_REG_SET hardregs;
unsigned regno;
if (CALL_P (insn))
return !SIBLING_CALL_P (insn);
if (cfun->can_throw_non_call_exceptions && can_throw_internal (insn))
return true;
CLEAR_HARD_REG_SET (hardregs);
FOR_EACH_INSN_DEF (def, insn)
{
rtx dreg = DF_REF_REG (def);
if (!REG_P (dreg))
continue;
add_to_hard_reg_set (&hardregs, GET_MODE (dreg), REGNO (dreg));
}
if (hard_reg_set_intersect_p (hardregs, prologue_used))
return true;
AND_COMPL_HARD_REG_SET (hardregs, call_used_reg_set);
for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
if (TEST_HARD_REG_BIT (hardregs, regno)
&& df_regs_ever_live_p (regno))
return true;
FOR_EACH_INSN_USE (use, insn)
{
rtx reg = DF_REF_REG (use);
if (!REG_P (reg))
continue;
add_to_hard_reg_set (&hardregs, GET_MODE (reg),
REGNO (reg));
}
if (hard_reg_set_intersect_p (hardregs, set_up_by_prologue))
return true;
return false;
} | [
"bool",
"requires_stack_frame_p",
"(",
"rtx_insn",
"*",
"insn",
",",
"HARD_REG_SET",
"prologue_used",
",",
"HARD_REG_SET",
"set_up_by_prologue",
")",
"{",
"df_ref",
"def",
",",
"use",
";",
"HARD_REG_SET",
"hardregs",
";",
"unsigned",
"regno",
";",
"if",
"(",
"CALL_P",
"(",
"insn",
")",
")",
"return",
"!",
"SIBLING_CALL_P",
"(",
"insn",
")",
";",
"if",
"(",
"cfun",
"->",
"can_throw_non_call_exceptions",
"&&",
"can_throw_internal",
"(",
"insn",
")",
")",
"return",
"true",
";",
"CLEAR_HARD_REG_SET",
"(",
"hardregs",
")",
";",
"FOR_EACH_INSN_DEF",
"(",
"def",
",",
"insn",
")",
"",
"{",
"rtx",
"dreg",
"=",
"DF_REF_REG",
"(",
"def",
")",
";",
"if",
"(",
"!",
"REG_P",
"(",
"dreg",
")",
")",
"continue",
";",
"add_to_hard_reg_set",
"(",
"&",
"hardregs",
",",
"GET_MODE",
"(",
"dreg",
")",
",",
"REGNO",
"(",
"dreg",
")",
")",
";",
"}",
"if",
"(",
"hard_reg_set_intersect_p",
"(",
"hardregs",
",",
"prologue_used",
")",
")",
"return",
"true",
";",
"AND_COMPL_HARD_REG_SET",
"(",
"hardregs",
",",
"call_used_reg_set",
")",
";",
"for",
"(",
"regno",
"=",
"0",
";",
"regno",
"<",
"FIRST_PSEUDO_REGISTER",
";",
"regno",
"++",
")",
"if",
"(",
"TEST_HARD_REG_BIT",
"(",
"hardregs",
",",
"regno",
")",
"&&",
"df_regs_ever_live_p",
"(",
"regno",
")",
")",
"return",
"true",
";",
"FOR_EACH_INSN_USE",
"(",
"use",
",",
"insn",
")",
"",
"{",
"rtx",
"reg",
"=",
"DF_REF_REG",
"(",
"use",
")",
";",
"if",
"(",
"!",
"REG_P",
"(",
"reg",
")",
")",
"continue",
";",
"add_to_hard_reg_set",
"(",
"&",
"hardregs",
",",
"GET_MODE",
"(",
"reg",
")",
",",
"REGNO",
"(",
"reg",
")",
")",
";",
"}",
"if",
"(",
"hard_reg_set_intersect_p",
"(",
"hardregs",
",",
"set_up_by_prologue",
")",
")",
"return",
"true",
";",
"return",
"false",
";",
"}"
] | Return true if INSN requires the stack frame to be set up. | [
"Return",
"true",
"if",
"INSN",
"requires",
"the",
"stack",
"frame",
"to",
"be",
"set",
"up",
"."
] | [
"/* We need a frame to get the unique CFA expected by the unwinder. */"
] | [
{
"param": "insn",
"type": "rtx_insn"
},
{
"param": "prologue_used",
"type": "HARD_REG_SET"
},
{
"param": "set_up_by_prologue",
"type": "HARD_REG_SET"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "insn",
"type": "rtx_insn",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "prologue_used",
"type": "HARD_REG_SET",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "set_up_by_prologue",
"type": "HARD_REG_SET",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6b47d4ea8cdeabbef2b1325787abc3a8e31d78a2 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/shrink-wrap.c | [
"BSD-3-Clause"
] | C | live_edge_for_reg | edge | static edge
live_edge_for_reg (basic_block bb, int regno, int end_regno)
{
edge e, live_edge;
edge_iterator ei;
bitmap live;
int i;
live_edge = NULL;
FOR_EACH_EDGE (e, ei, bb->succs)
{
live = df_get_live_in (e->dest);
for (i = regno; i < end_regno; i++)
if (REGNO_REG_SET_P (live, i))
{
if (live_edge && live_edge != e)
return NULL;
live_edge = e;
}
}
/* We can sometimes encounter dead code. Don't try to move it
into the exit block. */
if (!live_edge || live_edge->dest == EXIT_BLOCK_PTR_FOR_FN (cfun))
return NULL;
/* Reject targets of abnormal edges. This is needed for correctness
on ports like Alpha and MIPS, whose pic_offset_table_rtx can die on
exception edges even though it is generally treated as call-saved
for the majority of the compilation. Moving across abnormal edges
isn't going to be interesting for shrink-wrap usage anyway. */
if (live_edge->flags & EDGE_ABNORMAL)
return NULL;
/* When live_edge->dest->preds == 2, we can create a new block on
the edge to make it meet the requirement. */
if (EDGE_COUNT (live_edge->dest->preds) > 2)
return NULL;
return live_edge;
} | /* See whether there has a single live edge from BB, which dest uses
[REGNO, END_REGNO). Return the live edge if its dest bb has
one or two predecessors. Otherwise return NULL. */ | See whether there has a single live edge from BB, which dest uses
[REGNO, END_REGNO). Return the live edge if its dest bb has
one or two predecessors. Otherwise return NULL. | [
"See",
"whether",
"there",
"has",
"a",
"single",
"live",
"edge",
"from",
"BB",
"which",
"dest",
"uses",
"[",
"REGNO",
"END_REGNO",
")",
".",
"Return",
"the",
"live",
"edge",
"if",
"its",
"dest",
"bb",
"has",
"one",
"or",
"two",
"predecessors",
".",
"Otherwise",
"return",
"NULL",
"."
] | static edge
live_edge_for_reg (basic_block bb, int regno, int end_regno)
{
edge e, live_edge;
edge_iterator ei;
bitmap live;
int i;
live_edge = NULL;
FOR_EACH_EDGE (e, ei, bb->succs)
{
live = df_get_live_in (e->dest);
for (i = regno; i < end_regno; i++)
if (REGNO_REG_SET_P (live, i))
{
if (live_edge && live_edge != e)
return NULL;
live_edge = e;
}
}
if (!live_edge || live_edge->dest == EXIT_BLOCK_PTR_FOR_FN (cfun))
return NULL;
if (live_edge->flags & EDGE_ABNORMAL)
return NULL;
if (EDGE_COUNT (live_edge->dest->preds) > 2)
return NULL;
return live_edge;
} | [
"static",
"edge",
"live_edge_for_reg",
"(",
"basic_block",
"bb",
",",
"int",
"regno",
",",
"int",
"end_regno",
")",
"{",
"edge",
"e",
",",
"live_edge",
";",
"edge_iterator",
"ei",
";",
"bitmap",
"live",
";",
"int",
"i",
";",
"live_edge",
"=",
"NULL",
";",
"FOR_EACH_EDGE",
"(",
"e",
",",
"ei",
",",
"bb",
"->",
"succs",
")",
"",
"{",
"live",
"=",
"df_get_live_in",
"(",
"e",
"->",
"dest",
")",
";",
"for",
"(",
"i",
"=",
"regno",
";",
"i",
"<",
"end_regno",
";",
"i",
"++",
")",
"if",
"(",
"REGNO_REG_SET_P",
"(",
"live",
",",
"i",
")",
")",
"{",
"if",
"(",
"live_edge",
"&&",
"live_edge",
"!=",
"e",
")",
"return",
"NULL",
";",
"live_edge",
"=",
"e",
";",
"}",
"}",
"if",
"(",
"!",
"live_edge",
"||",
"live_edge",
"->",
"dest",
"==",
"EXIT_BLOCK_PTR_FOR_FN",
"(",
"cfun",
")",
")",
"return",
"NULL",
";",
"if",
"(",
"live_edge",
"->",
"flags",
"&",
"EDGE_ABNORMAL",
")",
"return",
"NULL",
";",
"if",
"(",
"EDGE_COUNT",
"(",
"live_edge",
"->",
"dest",
"->",
"preds",
")",
">",
"2",
")",
"return",
"NULL",
";",
"return",
"live_edge",
";",
"}"
] | See whether there has a single live edge from BB, which dest uses
[REGNO, END_REGNO). | [
"See",
"whether",
"there",
"has",
"a",
"single",
"live",
"edge",
"from",
"BB",
"which",
"dest",
"uses",
"[",
"REGNO",
"END_REGNO",
")",
"."
] | [
"/* We can sometimes encounter dead code. Don't try to move it\n into the exit block. */",
"/* Reject targets of abnormal edges. This is needed for correctness\n on ports like Alpha and MIPS, whose pic_offset_table_rtx can die on\n exception edges even though it is generally treated as call-saved\n for the majority of the compilation. Moving across abnormal edges\n isn't going to be interesting for shrink-wrap usage anyway. */",
"/* When live_edge->dest->preds == 2, we can create a new block on\n the edge to make it meet the requirement. */"
] | [
{
"param": "bb",
"type": "basic_block"
},
{
"param": "regno",
"type": "int"
},
{
"param": "end_regno",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bb",
"type": "basic_block",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "regno",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "end_regno",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6b47d4ea8cdeabbef2b1325787abc3a8e31d78a2 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/shrink-wrap.c | [
"BSD-3-Clause"
] | C | prepare_shrink_wrap | void | static void
prepare_shrink_wrap (basic_block entry_block)
{
rtx_insn *insn, *curr;
rtx x;
HARD_REG_SET uses, defs;
df_ref def, use;
bool split_p = false;
unsigned int i;
struct dead_debug_local debug;
if (JUMP_P (BB_END (entry_block)))
{
/* To have more shrink-wrapping opportunities, prepare_shrink_wrap tries
to sink the copies from parameter to callee saved register out of
entry block. copyprop_hardreg_forward_bb_without_debug_insn is called
to release some dependences. */
copyprop_hardreg_forward_bb_without_debug_insn (entry_block);
}
dead_debug_local_init (&debug, NULL, NULL);
CLEAR_HARD_REG_SET (uses);
CLEAR_HARD_REG_SET (defs);
FOR_BB_INSNS_REVERSE_SAFE (entry_block, insn, curr)
if (NONDEBUG_INSN_P (insn)
&& !move_insn_for_shrink_wrap (entry_block, insn, uses, defs,
&split_p, &debug))
{
/* Add all defined registers to DEFs. */
FOR_EACH_INSN_DEF (def, insn)
{
x = DF_REF_REG (def);
if (REG_P (x) && HARD_REGISTER_P (x))
for (i = REGNO (x); i < END_REGNO (x); i++)
SET_HARD_REG_BIT (defs, i);
}
/* Add all used registers to USESs. */
FOR_EACH_INSN_USE (use, insn)
{
x = DF_REF_REG (use);
if (REG_P (x) && HARD_REGISTER_P (x))
for (i = REGNO (x); i < END_REGNO (x); i++)
SET_HARD_REG_BIT (uses, i);
}
}
dead_debug_local_finish (&debug, NULL);
} | /* Look for register copies in the first block of the function, and move
them down into successor blocks if the register is used only on one
path. This exposes more opportunities for shrink-wrapping. These
kinds of sets often occur when incoming argument registers are moved
to call-saved registers because their values are live across one or
more calls during the function. */ | Look for register copies in the first block of the function, and move
them down into successor blocks if the register is used only on one
path. This exposes more opportunities for shrink-wrapping. These
kinds of sets often occur when incoming argument registers are moved
to call-saved registers because their values are live across one or
more calls during the function. | [
"Look",
"for",
"register",
"copies",
"in",
"the",
"first",
"block",
"of",
"the",
"function",
"and",
"move",
"them",
"down",
"into",
"successor",
"blocks",
"if",
"the",
"register",
"is",
"used",
"only",
"on",
"one",
"path",
".",
"This",
"exposes",
"more",
"opportunities",
"for",
"shrink",
"-",
"wrapping",
".",
"These",
"kinds",
"of",
"sets",
"often",
"occur",
"when",
"incoming",
"argument",
"registers",
"are",
"moved",
"to",
"call",
"-",
"saved",
"registers",
"because",
"their",
"values",
"are",
"live",
"across",
"one",
"or",
"more",
"calls",
"during",
"the",
"function",
"."
] | static void
prepare_shrink_wrap (basic_block entry_block)
{
rtx_insn *insn, *curr;
rtx x;
HARD_REG_SET uses, defs;
df_ref def, use;
bool split_p = false;
unsigned int i;
struct dead_debug_local debug;
if (JUMP_P (BB_END (entry_block)))
{
copyprop_hardreg_forward_bb_without_debug_insn (entry_block);
}
dead_debug_local_init (&debug, NULL, NULL);
CLEAR_HARD_REG_SET (uses);
CLEAR_HARD_REG_SET (defs);
FOR_BB_INSNS_REVERSE_SAFE (entry_block, insn, curr)
if (NONDEBUG_INSN_P (insn)
&& !move_insn_for_shrink_wrap (entry_block, insn, uses, defs,
&split_p, &debug))
{
FOR_EACH_INSN_DEF (def, insn)
{
x = DF_REF_REG (def);
if (REG_P (x) && HARD_REGISTER_P (x))
for (i = REGNO (x); i < END_REGNO (x); i++)
SET_HARD_REG_BIT (defs, i);
}
FOR_EACH_INSN_USE (use, insn)
{
x = DF_REF_REG (use);
if (REG_P (x) && HARD_REGISTER_P (x))
for (i = REGNO (x); i < END_REGNO (x); i++)
SET_HARD_REG_BIT (uses, i);
}
}
dead_debug_local_finish (&debug, NULL);
} | [
"static",
"void",
"prepare_shrink_wrap",
"(",
"basic_block",
"entry_block",
")",
"{",
"rtx_insn",
"*",
"insn",
",",
"*",
"curr",
";",
"rtx",
"x",
";",
"HARD_REG_SET",
"uses",
",",
"defs",
";",
"df_ref",
"def",
",",
"use",
";",
"bool",
"split_p",
"=",
"false",
";",
"unsigned",
"int",
"i",
";",
"struct",
"dead_debug_local",
"debug",
";",
"if",
"(",
"JUMP_P",
"(",
"BB_END",
"(",
"entry_block",
")",
")",
")",
"{",
"copyprop_hardreg_forward_bb_without_debug_insn",
"(",
"entry_block",
")",
";",
"}",
"dead_debug_local_init",
"(",
"&",
"debug",
",",
"NULL",
",",
"NULL",
")",
";",
"CLEAR_HARD_REG_SET",
"(",
"uses",
")",
";",
"CLEAR_HARD_REG_SET",
"(",
"defs",
")",
";",
"FOR_BB_INSNS_REVERSE_SAFE",
"(",
"entry_block",
",",
"insn",
",",
"curr",
")",
"",
"if",
"(",
"NONDEBUG_INSN_P",
"(",
"insn",
")",
"&&",
"!",
"move_insn_for_shrink_wrap",
"(",
"entry_block",
",",
"insn",
",",
"uses",
",",
"defs",
",",
"&",
"split_p",
",",
"&",
"debug",
")",
")",
"{",
"FOR_EACH_INSN_DEF",
"(",
"def",
",",
"insn",
")",
"",
"{",
"x",
"=",
"DF_REF_REG",
"(",
"def",
")",
";",
"if",
"(",
"REG_P",
"(",
"x",
")",
"&&",
"HARD_REGISTER_P",
"(",
"x",
")",
")",
"for",
"(",
"i",
"=",
"REGNO",
"(",
"x",
")",
";",
"i",
"<",
"END_REGNO",
"(",
"x",
")",
";",
"i",
"++",
")",
"SET_HARD_REG_BIT",
"(",
"defs",
",",
"i",
")",
";",
"}",
"FOR_EACH_INSN_USE",
"(",
"use",
",",
"insn",
")",
"",
"{",
"x",
"=",
"DF_REF_REG",
"(",
"use",
")",
";",
"if",
"(",
"REG_P",
"(",
"x",
")",
"&&",
"HARD_REGISTER_P",
"(",
"x",
")",
")",
"for",
"(",
"i",
"=",
"REGNO",
"(",
"x",
")",
";",
"i",
"<",
"END_REGNO",
"(",
"x",
")",
";",
"i",
"++",
")",
"SET_HARD_REG_BIT",
"(",
"uses",
",",
"i",
")",
";",
"}",
"}",
"dead_debug_local_finish",
"(",
"&",
"debug",
",",
"NULL",
")",
";",
"}"
] | Look for register copies in the first block of the function, and move
them down into successor blocks if the register is used only on one
path. | [
"Look",
"for",
"register",
"copies",
"in",
"the",
"first",
"block",
"of",
"the",
"function",
"and",
"move",
"them",
"down",
"into",
"successor",
"blocks",
"if",
"the",
"register",
"is",
"used",
"only",
"on",
"one",
"path",
"."
] | [
"/* To have more shrink-wrapping opportunities, prepare_shrink_wrap tries\n\t to sink the copies from parameter to callee saved register out of\n\t entry block. copyprop_hardreg_forward_bb_without_debug_insn is called\n\t to release some dependences. */",
"/* Add all defined registers to DEFs. */",
"/* Add all used registers to USESs. */"
] | [
{
"param": "entry_block",
"type": "basic_block"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "entry_block",
"type": "basic_block",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6b47d4ea8cdeabbef2b1325787abc3a8e31d78a2 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/shrink-wrap.c | [
"BSD-3-Clause"
] | C | can_get_prologue | bool | static bool
can_get_prologue (basic_block pro, HARD_REG_SET prologue_clobbered)
{
edge e;
edge_iterator ei;
FOR_EACH_EDGE (e, ei, pro->preds)
if (e->flags & (EDGE_COMPLEX | EDGE_CROSSING)
&& !dominated_by_p (CDI_DOMINATORS, e->src, pro))
return false;
HARD_REG_SET live;
REG_SET_TO_HARD_REG_SET (live, df_get_live_in (pro));
if (hard_reg_set_intersect_p (live, prologue_clobbered))
return false;
return true;
} | /* Return whether basic block PRO can get the prologue. It can not if it
has incoming complex edges that need a prologue inserted (we make a new
block for the prologue, so those edges would need to be redirected, which
does not work). It also can not if there exist registers live on entry
to PRO that are clobbered by the prologue. */ | Return whether basic block PRO can get the prologue. It can not if it
has incoming complex edges that need a prologue inserted (we make a new
block for the prologue, so those edges would need to be redirected, which
does not work). It also can not if there exist registers live on entry
to PRO that are clobbered by the prologue. | [
"Return",
"whether",
"basic",
"block",
"PRO",
"can",
"get",
"the",
"prologue",
".",
"It",
"can",
"not",
"if",
"it",
"has",
"incoming",
"complex",
"edges",
"that",
"need",
"a",
"prologue",
"inserted",
"(",
"we",
"make",
"a",
"new",
"block",
"for",
"the",
"prologue",
"so",
"those",
"edges",
"would",
"need",
"to",
"be",
"redirected",
"which",
"does",
"not",
"work",
")",
".",
"It",
"also",
"can",
"not",
"if",
"there",
"exist",
"registers",
"live",
"on",
"entry",
"to",
"PRO",
"that",
"are",
"clobbered",
"by",
"the",
"prologue",
"."
] | static bool
can_get_prologue (basic_block pro, HARD_REG_SET prologue_clobbered)
{
edge e;
edge_iterator ei;
FOR_EACH_EDGE (e, ei, pro->preds)
if (e->flags & (EDGE_COMPLEX | EDGE_CROSSING)
&& !dominated_by_p (CDI_DOMINATORS, e->src, pro))
return false;
HARD_REG_SET live;
REG_SET_TO_HARD_REG_SET (live, df_get_live_in (pro));
if (hard_reg_set_intersect_p (live, prologue_clobbered))
return false;
return true;
} | [
"static",
"bool",
"can_get_prologue",
"(",
"basic_block",
"pro",
",",
"HARD_REG_SET",
"prologue_clobbered",
")",
"{",
"edge",
"e",
";",
"edge_iterator",
"ei",
";",
"FOR_EACH_EDGE",
"(",
"e",
",",
"ei",
",",
"pro",
"->",
"preds",
")",
"",
"if",
"(",
"e",
"->",
"flags",
"&",
"(",
"EDGE_COMPLEX",
"|",
"EDGE_CROSSING",
")",
"&&",
"!",
"dominated_by_p",
"(",
"CDI_DOMINATORS",
",",
"e",
"->",
"src",
",",
"pro",
")",
")",
"return",
"false",
";",
"HARD_REG_SET",
"live",
";",
"REG_SET_TO_HARD_REG_SET",
"(",
"live",
",",
"df_get_live_in",
"(",
"pro",
")",
")",
";",
"if",
"(",
"hard_reg_set_intersect_p",
"(",
"live",
",",
"prologue_clobbered",
")",
")",
"return",
"false",
";",
"return",
"true",
";",
"}"
] | Return whether basic block PRO can get the prologue. | [
"Return",
"whether",
"basic",
"block",
"PRO",
"can",
"get",
"the",
"prologue",
"."
] | [] | [
{
"param": "pro",
"type": "basic_block"
},
{
"param": "prologue_clobbered",
"type": "HARD_REG_SET"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pro",
"type": "basic_block",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "prologue_clobbered",
"type": "HARD_REG_SET",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6b47d4ea8cdeabbef2b1325787abc3a8e31d78a2 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/shrink-wrap.c | [
"BSD-3-Clause"
] | C | can_dup_for_shrink_wrapping | bool | static bool
can_dup_for_shrink_wrapping (basic_block bb, basic_block pro, unsigned max_size)
{
if (!can_duplicate_block_p (bb))
return false;
edge e;
edge_iterator ei;
FOR_EACH_EDGE (e, ei, bb->preds)
if (e->flags & (EDGE_COMPLEX | EDGE_CROSSING)
&& !dominated_by_p (CDI_DOMINATORS, e->src, pro))
return false;
unsigned size = 0;
rtx_insn *insn;
FOR_BB_INSNS (bb, insn)
if (NONDEBUG_INSN_P (insn))
{
size += get_attr_min_length (insn);
if (size > max_size)
return false;
}
return true;
} | /* Return whether we can duplicate basic block BB for shrink wrapping. We
cannot if the block cannot be duplicated at all, or if any of its incoming
edges are complex and come from a block that does not require a prologue
(we cannot redirect such edges), or if the block is too big to copy.
PRO is the basic block before which we would put the prologue, MAX_SIZE is
the maximum size block we allow to be copied. */ | Return whether we can duplicate basic block BB for shrink wrapping. We
cannot if the block cannot be duplicated at all, or if any of its incoming
edges are complex and come from a block that does not require a prologue
(we cannot redirect such edges), or if the block is too big to copy.
PRO is the basic block before which we would put the prologue, MAX_SIZE is
the maximum size block we allow to be copied. | [
"Return",
"whether",
"we",
"can",
"duplicate",
"basic",
"block",
"BB",
"for",
"shrink",
"wrapping",
".",
"We",
"cannot",
"if",
"the",
"block",
"cannot",
"be",
"duplicated",
"at",
"all",
"or",
"if",
"any",
"of",
"its",
"incoming",
"edges",
"are",
"complex",
"and",
"come",
"from",
"a",
"block",
"that",
"does",
"not",
"require",
"a",
"prologue",
"(",
"we",
"cannot",
"redirect",
"such",
"edges",
")",
"or",
"if",
"the",
"block",
"is",
"too",
"big",
"to",
"copy",
".",
"PRO",
"is",
"the",
"basic",
"block",
"before",
"which",
"we",
"would",
"put",
"the",
"prologue",
"MAX_SIZE",
"is",
"the",
"maximum",
"size",
"block",
"we",
"allow",
"to",
"be",
"copied",
"."
] | static bool
can_dup_for_shrink_wrapping (basic_block bb, basic_block pro, unsigned max_size)
{
if (!can_duplicate_block_p (bb))
return false;
edge e;
edge_iterator ei;
FOR_EACH_EDGE (e, ei, bb->preds)
if (e->flags & (EDGE_COMPLEX | EDGE_CROSSING)
&& !dominated_by_p (CDI_DOMINATORS, e->src, pro))
return false;
unsigned size = 0;
rtx_insn *insn;
FOR_BB_INSNS (bb, insn)
if (NONDEBUG_INSN_P (insn))
{
size += get_attr_min_length (insn);
if (size > max_size)
return false;
}
return true;
} | [
"static",
"bool",
"can_dup_for_shrink_wrapping",
"(",
"basic_block",
"bb",
",",
"basic_block",
"pro",
",",
"unsigned",
"max_size",
")",
"{",
"if",
"(",
"!",
"can_duplicate_block_p",
"(",
"bb",
")",
")",
"return",
"false",
";",
"edge",
"e",
";",
"edge_iterator",
"ei",
";",
"FOR_EACH_EDGE",
"(",
"e",
",",
"ei",
",",
"bb",
"->",
"preds",
")",
"",
"if",
"(",
"e",
"->",
"flags",
"&",
"(",
"EDGE_COMPLEX",
"|",
"EDGE_CROSSING",
")",
"&&",
"!",
"dominated_by_p",
"(",
"CDI_DOMINATORS",
",",
"e",
"->",
"src",
",",
"pro",
")",
")",
"return",
"false",
";",
"unsigned",
"size",
"=",
"0",
";",
"rtx_insn",
"*",
"insn",
";",
"FOR_BB_INSNS",
"(",
"bb",
",",
"insn",
")",
"",
"if",
"(",
"NONDEBUG_INSN_P",
"(",
"insn",
")",
")",
"{",
"size",
"+=",
"get_attr_min_length",
"(",
"insn",
")",
";",
"if",
"(",
"size",
">",
"max_size",
")",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Return whether we can duplicate basic block BB for shrink wrapping. | [
"Return",
"whether",
"we",
"can",
"duplicate",
"basic",
"block",
"BB",
"for",
"shrink",
"wrapping",
"."
] | [] | [
{
"param": "bb",
"type": "basic_block"
},
{
"param": "pro",
"type": "basic_block"
},
{
"param": "max_size",
"type": "unsigned"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bb",
"type": "basic_block",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pro",
"type": "basic_block",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "max_size",
"type": "unsigned",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6b47d4ea8cdeabbef2b1325787abc3a8e31d78a2 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/shrink-wrap.c | [
"BSD-3-Clause"
] | C | handle_simple_exit | void | static void
handle_simple_exit (edge e)
{
if (e->flags & EDGE_SIBCALL)
{
/* Tell function.c to take no further action on this edge. */
e->flags |= EDGE_IGNORE;
e->flags &= ~EDGE_FALLTHRU;
emit_barrier_after_bb (e->src);
return;
}
/* If the basic block the edge comes from has multiple successors,
split the edge. */
if (EDGE_COUNT (e->src->succs) > 1)
{
basic_block old_bb = e->src;
rtx_insn *end = BB_END (old_bb);
rtx_note *note = emit_note_after (NOTE_INSN_DELETED, end);
basic_block new_bb = create_basic_block (note, note, old_bb);
BB_COPY_PARTITION (new_bb, old_bb);
BB_END (old_bb) = end;
redirect_edge_succ (e, new_bb);
new_bb->count = e->count ();
e->flags |= EDGE_FALLTHRU;
e = make_single_succ_edge (new_bb, EXIT_BLOCK_PTR_FOR_FN (cfun), 0);
}
e->flags &= ~EDGE_FALLTHRU;
rtx_jump_insn *ret = emit_jump_insn_after (targetm.gen_simple_return (),
BB_END (e->src));
JUMP_LABEL (ret) = simple_return_rtx;
emit_barrier_after_bb (e->src);
if (dump_file)
fprintf (dump_file, "Made simple_return with UID %d in bb %d\n",
INSN_UID (ret), e->src->index);
} | /* Do whatever needs to be done for exits that run without prologue.
Sibcalls need nothing done. Normal exits get a simple_return inserted. */ | Do whatever needs to be done for exits that run without prologue.
Sibcalls need nothing done. Normal exits get a simple_return inserted. | [
"Do",
"whatever",
"needs",
"to",
"be",
"done",
"for",
"exits",
"that",
"run",
"without",
"prologue",
".",
"Sibcalls",
"need",
"nothing",
"done",
".",
"Normal",
"exits",
"get",
"a",
"simple_return",
"inserted",
"."
] | static void
handle_simple_exit (edge e)
{
if (e->flags & EDGE_SIBCALL)
{
e->flags |= EDGE_IGNORE;
e->flags &= ~EDGE_FALLTHRU;
emit_barrier_after_bb (e->src);
return;
}
if (EDGE_COUNT (e->src->succs) > 1)
{
basic_block old_bb = e->src;
rtx_insn *end = BB_END (old_bb);
rtx_note *note = emit_note_after (NOTE_INSN_DELETED, end);
basic_block new_bb = create_basic_block (note, note, old_bb);
BB_COPY_PARTITION (new_bb, old_bb);
BB_END (old_bb) = end;
redirect_edge_succ (e, new_bb);
new_bb->count = e->count ();
e->flags |= EDGE_FALLTHRU;
e = make_single_succ_edge (new_bb, EXIT_BLOCK_PTR_FOR_FN (cfun), 0);
}
e->flags &= ~EDGE_FALLTHRU;
rtx_jump_insn *ret = emit_jump_insn_after (targetm.gen_simple_return (),
BB_END (e->src));
JUMP_LABEL (ret) = simple_return_rtx;
emit_barrier_after_bb (e->src);
if (dump_file)
fprintf (dump_file, "Made simple_return with UID %d in bb %d\n",
INSN_UID (ret), e->src->index);
} | [
"static",
"void",
"handle_simple_exit",
"(",
"edge",
"e",
")",
"{",
"if",
"(",
"e",
"->",
"flags",
"&",
"EDGE_SIBCALL",
")",
"{",
"e",
"->",
"flags",
"|=",
"EDGE_IGNORE",
";",
"e",
"->",
"flags",
"&=",
"~",
"EDGE_FALLTHRU",
";",
"emit_barrier_after_bb",
"(",
"e",
"->",
"src",
")",
";",
"return",
";",
"}",
"if",
"(",
"EDGE_COUNT",
"(",
"e",
"->",
"src",
"->",
"succs",
")",
">",
"1",
")",
"{",
"basic_block",
"old_bb",
"=",
"e",
"->",
"src",
";",
"rtx_insn",
"*",
"end",
"=",
"BB_END",
"(",
"old_bb",
")",
";",
"rtx_note",
"*",
"note",
"=",
"emit_note_after",
"(",
"NOTE_INSN_DELETED",
",",
"end",
")",
";",
"basic_block",
"new_bb",
"=",
"create_basic_block",
"(",
"note",
",",
"note",
",",
"old_bb",
")",
";",
"BB_COPY_PARTITION",
"(",
"new_bb",
",",
"old_bb",
")",
";",
"BB_END",
"(",
"old_bb",
")",
"=",
"end",
";",
"redirect_edge_succ",
"(",
"e",
",",
"new_bb",
")",
";",
"new_bb",
"->",
"count",
"=",
"e",
"->",
"count",
"(",
")",
";",
"e",
"->",
"flags",
"|=",
"EDGE_FALLTHRU",
";",
"e",
"=",
"make_single_succ_edge",
"(",
"new_bb",
",",
"EXIT_BLOCK_PTR_FOR_FN",
"(",
"cfun",
")",
",",
"0",
")",
";",
"}",
"e",
"->",
"flags",
"&=",
"~",
"EDGE_FALLTHRU",
";",
"rtx_jump_insn",
"*",
"ret",
"=",
"emit_jump_insn_after",
"(",
"targetm",
".",
"gen_simple_return",
"(",
")",
",",
"BB_END",
"(",
"e",
"->",
"src",
")",
")",
";",
"JUMP_LABEL",
"(",
"ret",
")",
"=",
"simple_return_rtx",
";",
"emit_barrier_after_bb",
"(",
"e",
"->",
"src",
")",
";",
"if",
"(",
"dump_file",
")",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\\n",
"\"",
",",
"INSN_UID",
"(",
"ret",
")",
",",
"e",
"->",
"src",
"->",
"index",
")",
";",
"}"
] | Do whatever needs to be done for exits that run without prologue. | [
"Do",
"whatever",
"needs",
"to",
"be",
"done",
"for",
"exits",
"that",
"run",
"without",
"prologue",
"."
] | [
"/* Tell function.c to take no further action on this edge. */",
"/* If the basic block the edge comes from has multiple successors,\n split the edge. */"
] | [
{
"param": "e",
"type": "edge"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "e",
"type": "edge",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6b47d4ea8cdeabbef2b1325787abc3a8e31d78a2 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/shrink-wrap.c | [
"BSD-3-Clause"
] | C | dump_components | void | static void
dump_components (const char *label, sbitmap components)
{
if (bitmap_empty_p (components))
return;
fprintf (dump_file, " [%s", label);
for (unsigned int j = 0; j < components->n_bits; j++)
if (bitmap_bit_p (components, j))
fprintf (dump_file, " %u", j);
fprintf (dump_file, "]");
} | /* Print the sbitmap COMPONENTS to the DUMP_FILE if not empty, with the
label LABEL. */ | Print the sbitmap COMPONENTS to the DUMP_FILE if not empty, with the
label LABEL. | [
"Print",
"the",
"sbitmap",
"COMPONENTS",
"to",
"the",
"DUMP_FILE",
"if",
"not",
"empty",
"with",
"the",
"label",
"LABEL",
"."
] | static void
dump_components (const char *label, sbitmap components)
{
if (bitmap_empty_p (components))
return;
fprintf (dump_file, " [%s", label);
for (unsigned int j = 0; j < components->n_bits; j++)
if (bitmap_bit_p (components, j))
fprintf (dump_file, " %u", j);
fprintf (dump_file, "]");
} | [
"static",
"void",
"dump_components",
"(",
"const",
"char",
"*",
"label",
",",
"sbitmap",
"components",
")",
"{",
"if",
"(",
"bitmap_empty_p",
"(",
"components",
")",
")",
"return",
";",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\"",
",",
"label",
")",
";",
"for",
"(",
"unsigned",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"components",
"->",
"n_bits",
";",
"j",
"++",
")",
"if",
"(",
"bitmap_bit_p",
"(",
"components",
",",
"j",
")",
")",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\"",
",",
"j",
")",
";",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\"",
")",
";",
"}"
] | Print the sbitmap COMPONENTS to the DUMP_FILE if not empty, with the
label LABEL. | [
"Print",
"the",
"sbitmap",
"COMPONENTS",
"to",
"the",
"DUMP_FILE",
"if",
"not",
"empty",
"with",
"the",
"label",
"LABEL",
"."
] | [] | [
{
"param": "label",
"type": "char"
},
{
"param": "components",
"type": "sbitmap"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "label",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "components",
"type": "sbitmap",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6b47d4ea8cdeabbef2b1325787abc3a8e31d78a2 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/shrink-wrap.c | [
"BSD-3-Clause"
] | C | init_separate_shrink_wrap | void | static void
init_separate_shrink_wrap (sbitmap components)
{
basic_block bb;
FOR_ALL_BB_FN (bb, cfun)
{
bb->aux = xcalloc (1, sizeof (struct sw));
SW (bb)->needs_components = targetm.shrink_wrap.components_for_bb (bb);
/* Mark all basic blocks without successor as needing all components.
This avoids problems in at least cfgcleanup, sel-sched, and
regrename (largely to do with all paths to such a block still
needing the same dwarf CFI info). */
if (EDGE_COUNT (bb->succs) == 0)
bitmap_copy (SW (bb)->needs_components, components);
if (dump_file)
{
fprintf (dump_file, "bb %d components:", bb->index);
dump_components ("has", SW (bb)->needs_components);
fprintf (dump_file, "\n");
}
SW (bb)->has_components = sbitmap_alloc (SBITMAP_SIZE (components));
SW (bb)->head_components = sbitmap_alloc (SBITMAP_SIZE (components));
SW (bb)->tail_components = sbitmap_alloc (SBITMAP_SIZE (components));
bitmap_clear (SW (bb)->has_components);
}
} | /* Create the pass-specific data structures for separately shrink-wrapping
with components COMPONENTS. */ | Create the pass-specific data structures for separately shrink-wrapping
with components COMPONENTS. | [
"Create",
"the",
"pass",
"-",
"specific",
"data",
"structures",
"for",
"separately",
"shrink",
"-",
"wrapping",
"with",
"components",
"COMPONENTS",
"."
] | static void
init_separate_shrink_wrap (sbitmap components)
{
basic_block bb;
FOR_ALL_BB_FN (bb, cfun)
{
bb->aux = xcalloc (1, sizeof (struct sw));
SW (bb)->needs_components = targetm.shrink_wrap.components_for_bb (bb);
if (EDGE_COUNT (bb->succs) == 0)
bitmap_copy (SW (bb)->needs_components, components);
if (dump_file)
{
fprintf (dump_file, "bb %d components:", bb->index);
dump_components ("has", SW (bb)->needs_components);
fprintf (dump_file, "\n");
}
SW (bb)->has_components = sbitmap_alloc (SBITMAP_SIZE (components));
SW (bb)->head_components = sbitmap_alloc (SBITMAP_SIZE (components));
SW (bb)->tail_components = sbitmap_alloc (SBITMAP_SIZE (components));
bitmap_clear (SW (bb)->has_components);
}
} | [
"static",
"void",
"init_separate_shrink_wrap",
"(",
"sbitmap",
"components",
")",
"{",
"basic_block",
"bb",
";",
"FOR_ALL_BB_FN",
"(",
"bb",
",",
"cfun",
")",
"",
"{",
"bb",
"->",
"aux",
"=",
"xcalloc",
"(",
"1",
",",
"sizeof",
"(",
"struct",
"sw",
")",
")",
";",
"SW",
"(",
"bb",
")",
"->",
"needs_components",
"=",
"targetm",
".",
"shrink_wrap",
".",
"components_for_bb",
"(",
"bb",
")",
";",
"if",
"(",
"EDGE_COUNT",
"(",
"bb",
"->",
"succs",
")",
"==",
"0",
")",
"bitmap_copy",
"(",
"SW",
"(",
"bb",
")",
"->",
"needs_components",
",",
"components",
")",
";",
"if",
"(",
"dump_file",
")",
"{",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\"",
",",
"bb",
"->",
"index",
")",
";",
"dump_components",
"(",
"\"",
"\"",
",",
"SW",
"(",
"bb",
")",
"->",
"needs_components",
")",
";",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\\n",
"\"",
")",
";",
"}",
"SW",
"(",
"bb",
")",
"->",
"has_components",
"=",
"sbitmap_alloc",
"(",
"SBITMAP_SIZE",
"(",
"components",
")",
")",
";",
"SW",
"(",
"bb",
")",
"->",
"head_components",
"=",
"sbitmap_alloc",
"(",
"SBITMAP_SIZE",
"(",
"components",
")",
")",
";",
"SW",
"(",
"bb",
")",
"->",
"tail_components",
"=",
"sbitmap_alloc",
"(",
"SBITMAP_SIZE",
"(",
"components",
")",
")",
";",
"bitmap_clear",
"(",
"SW",
"(",
"bb",
")",
"->",
"has_components",
")",
";",
"}",
"}"
] | Create the pass-specific data structures for separately shrink-wrapping
with components COMPONENTS. | [
"Create",
"the",
"pass",
"-",
"specific",
"data",
"structures",
"for",
"separately",
"shrink",
"-",
"wrapping",
"with",
"components",
"COMPONENTS",
"."
] | [
"/* Mark all basic blocks without successor as needing all components.\n\t This avoids problems in at least cfgcleanup, sel-sched, and\n\t regrename (largely to do with all paths to such a block still\n\t needing the same dwarf CFI info). */"
] | [
{
"param": "components",
"type": "sbitmap"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "components",
"type": "sbitmap",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6b47d4ea8cdeabbef2b1325787abc3a8e31d78a2 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/shrink-wrap.c | [
"BSD-3-Clause"
] | C | place_prologue_for_one_component | void | static void
place_prologue_for_one_component (unsigned int which, basic_block head)
{
/* The block we are currently dealing with. */
basic_block bb = head;
/* Is this the first time we visit this block, i.e. have we just gone
down the tree. */
bool first_visit = true;
/* Walk the dominator tree, visit one block per iteration of this loop.
Each basic block is visited twice: once before visiting any children
of the block, and once after visiting all of them (leaf nodes are
visited only once). As an optimization, we do not visit subtrees
that can no longer influence the prologue placement. */
for (;;)
{
/* First visit of a block: set the (children) cost accumulator to zero;
if the block does not have the component itself, walk down. */
if (first_visit)
{
/* Initialize the cost. The cost is the block execution frequency
that does not come from backedges. Calculating this by simply
adding the cost of all edges that aren't backedges does not
work: this does not always add up to the block frequency at
all, and even if it does, rounding error makes for bad
decisions. */
SW (bb)->own_cost = bb->count.to_frequency (cfun);
edge e;
edge_iterator ei;
FOR_EACH_EDGE (e, ei, bb->preds)
if (dominated_by_p (CDI_DOMINATORS, e->src, bb))
{
if (SW (bb)->own_cost > EDGE_FREQUENCY (e))
SW (bb)->own_cost -= EDGE_FREQUENCY (e);
else
SW (bb)->own_cost = 0;
}
SW (bb)->total_cost = 0;
if (!bitmap_bit_p (SW (bb)->needs_components, which)
&& first_dom_son (CDI_DOMINATORS, bb))
{
bb = first_dom_son (CDI_DOMINATORS, bb);
continue;
}
}
/* If this block does need the component itself, or it is cheaper to
put the prologue here than in all the descendants that need it,
mark it so. If this block's immediate post-dominator is dominated
by this block, and that needs the prologue, we can put it on this
block as well (earlier is better). */
if (bitmap_bit_p (SW (bb)->needs_components, which)
|| SW (bb)->total_cost > SW (bb)->own_cost)
{
SW (bb)->total_cost = SW (bb)->own_cost;
bitmap_set_bit (SW (bb)->has_components, which);
}
else
{
basic_block kid = get_immediate_dominator (CDI_POST_DOMINATORS, bb);
if (dominated_by_p (CDI_DOMINATORS, kid, bb)
&& bitmap_bit_p (SW (kid)->has_components, which))
{
SW (bb)->total_cost = SW (bb)->own_cost;
bitmap_set_bit (SW (bb)->has_components, which);
}
}
/* We are back where we started, so we are done now. */
if (bb == head)
return;
/* We now know the cost of the subtree rooted at the current block.
Accumulate this cost in the parent. */
basic_block parent = get_immediate_dominator (CDI_DOMINATORS, bb);
SW (parent)->total_cost += SW (bb)->total_cost;
/* Don't walk the tree down unless necessary. */
if (next_dom_son (CDI_DOMINATORS, bb)
&& SW (parent)->total_cost <= SW (parent)->own_cost)
{
bb = next_dom_son (CDI_DOMINATORS, bb);
first_visit = true;
}
else
{
bb = parent;
first_visit = false;
}
}
} | /* Place the prologue for component WHICH, in the basic blocks dominated
by HEAD. Do a DFS over the dominator tree, and set bit WHICH in the
HAS_COMPONENTS of a block if either the block has that bit set in
NEEDS_COMPONENTS, or it is cheaper to place the prologue here than in all
dominator subtrees separately. */ | Place the prologue for component WHICH, in the basic blocks dominated
by HEAD. Do a DFS over the dominator tree, and set bit WHICH in the
HAS_COMPONENTS of a block if either the block has that bit set in
NEEDS_COMPONENTS, or it is cheaper to place the prologue here than in all
dominator subtrees separately. | [
"Place",
"the",
"prologue",
"for",
"component",
"WHICH",
"in",
"the",
"basic",
"blocks",
"dominated",
"by",
"HEAD",
".",
"Do",
"a",
"DFS",
"over",
"the",
"dominator",
"tree",
"and",
"set",
"bit",
"WHICH",
"in",
"the",
"HAS_COMPONENTS",
"of",
"a",
"block",
"if",
"either",
"the",
"block",
"has",
"that",
"bit",
"set",
"in",
"NEEDS_COMPONENTS",
"or",
"it",
"is",
"cheaper",
"to",
"place",
"the",
"prologue",
"here",
"than",
"in",
"all",
"dominator",
"subtrees",
"separately",
"."
] | static void
place_prologue_for_one_component (unsigned int which, basic_block head)
{
basic_block bb = head;
bool first_visit = true;
for (;;)
{
if (first_visit)
{
SW (bb)->own_cost = bb->count.to_frequency (cfun);
edge e;
edge_iterator ei;
FOR_EACH_EDGE (e, ei, bb->preds)
if (dominated_by_p (CDI_DOMINATORS, e->src, bb))
{
if (SW (bb)->own_cost > EDGE_FREQUENCY (e))
SW (bb)->own_cost -= EDGE_FREQUENCY (e);
else
SW (bb)->own_cost = 0;
}
SW (bb)->total_cost = 0;
if (!bitmap_bit_p (SW (bb)->needs_components, which)
&& first_dom_son (CDI_DOMINATORS, bb))
{
bb = first_dom_son (CDI_DOMINATORS, bb);
continue;
}
}
if (bitmap_bit_p (SW (bb)->needs_components, which)
|| SW (bb)->total_cost > SW (bb)->own_cost)
{
SW (bb)->total_cost = SW (bb)->own_cost;
bitmap_set_bit (SW (bb)->has_components, which);
}
else
{
basic_block kid = get_immediate_dominator (CDI_POST_DOMINATORS, bb);
if (dominated_by_p (CDI_DOMINATORS, kid, bb)
&& bitmap_bit_p (SW (kid)->has_components, which))
{
SW (bb)->total_cost = SW (bb)->own_cost;
bitmap_set_bit (SW (bb)->has_components, which);
}
}
if (bb == head)
return;
basic_block parent = get_immediate_dominator (CDI_DOMINATORS, bb);
SW (parent)->total_cost += SW (bb)->total_cost;
if (next_dom_son (CDI_DOMINATORS, bb)
&& SW (parent)->total_cost <= SW (parent)->own_cost)
{
bb = next_dom_son (CDI_DOMINATORS, bb);
first_visit = true;
}
else
{
bb = parent;
first_visit = false;
}
}
} | [
"static",
"void",
"place_prologue_for_one_component",
"(",
"unsigned",
"int",
"which",
",",
"basic_block",
"head",
")",
"{",
"basic_block",
"bb",
"=",
"head",
";",
"bool",
"first_visit",
"=",
"true",
";",
"for",
"(",
";",
";",
")",
"{",
"if",
"(",
"first_visit",
")",
"{",
"SW",
"(",
"bb",
")",
"->",
"own_cost",
"=",
"bb",
"->",
"count",
".",
"to_frequency",
"(",
"cfun",
")",
";",
"edge",
"e",
";",
"edge_iterator",
"ei",
";",
"FOR_EACH_EDGE",
"(",
"e",
",",
"ei",
",",
"bb",
"->",
"preds",
")",
"",
"if",
"(",
"dominated_by_p",
"(",
"CDI_DOMINATORS",
",",
"e",
"->",
"src",
",",
"bb",
")",
")",
"{",
"if",
"(",
"SW",
"(",
"bb",
")",
"->",
"own_cost",
">",
"EDGE_FREQUENCY",
"(",
"e",
")",
")",
"SW",
"(",
"bb",
")",
"->",
"own_cost",
"-=",
"EDGE_FREQUENCY",
"(",
"e",
")",
";",
"else",
"SW",
"(",
"bb",
")",
"->",
"own_cost",
"=",
"0",
";",
"}",
"SW",
"(",
"bb",
")",
"->",
"total_cost",
"=",
"0",
";",
"if",
"(",
"!",
"bitmap_bit_p",
"(",
"SW",
"(",
"bb",
")",
"->",
"needs_components",
",",
"which",
")",
"&&",
"first_dom_son",
"(",
"CDI_DOMINATORS",
",",
"bb",
")",
")",
"{",
"bb",
"=",
"first_dom_son",
"(",
"CDI_DOMINATORS",
",",
"bb",
")",
";",
"continue",
";",
"}",
"}",
"if",
"(",
"bitmap_bit_p",
"(",
"SW",
"(",
"bb",
")",
"->",
"needs_components",
",",
"which",
")",
"||",
"SW",
"(",
"bb",
")",
"->",
"total_cost",
">",
"SW",
"(",
"bb",
")",
"->",
"own_cost",
")",
"{",
"SW",
"(",
"bb",
")",
"->",
"total_cost",
"=",
"SW",
"(",
"bb",
")",
"->",
"own_cost",
";",
"bitmap_set_bit",
"(",
"SW",
"(",
"bb",
")",
"->",
"has_components",
",",
"which",
")",
";",
"}",
"else",
"{",
"basic_block",
"kid",
"=",
"get_immediate_dominator",
"(",
"CDI_POST_DOMINATORS",
",",
"bb",
")",
";",
"if",
"(",
"dominated_by_p",
"(",
"CDI_DOMINATORS",
",",
"kid",
",",
"bb",
")",
"&&",
"bitmap_bit_p",
"(",
"SW",
"(",
"kid",
")",
"->",
"has_components",
",",
"which",
")",
")",
"{",
"SW",
"(",
"bb",
")",
"->",
"total_cost",
"=",
"SW",
"(",
"bb",
")",
"->",
"own_cost",
";",
"bitmap_set_bit",
"(",
"SW",
"(",
"bb",
")",
"->",
"has_components",
",",
"which",
")",
";",
"}",
"}",
"if",
"(",
"bb",
"==",
"head",
")",
"return",
";",
"basic_block",
"parent",
"=",
"get_immediate_dominator",
"(",
"CDI_DOMINATORS",
",",
"bb",
")",
";",
"SW",
"(",
"parent",
")",
"->",
"total_cost",
"+=",
"SW",
"(",
"bb",
")",
"->",
"total_cost",
";",
"if",
"(",
"next_dom_son",
"(",
"CDI_DOMINATORS",
",",
"bb",
")",
"&&",
"SW",
"(",
"parent",
")",
"->",
"total_cost",
"<=",
"SW",
"(",
"parent",
")",
"->",
"own_cost",
")",
"{",
"bb",
"=",
"next_dom_son",
"(",
"CDI_DOMINATORS",
",",
"bb",
")",
";",
"first_visit",
"=",
"true",
";",
"}",
"else",
"{",
"bb",
"=",
"parent",
";",
"first_visit",
"=",
"false",
";",
"}",
"}",
"}"
] | Place the prologue for component WHICH, in the basic blocks dominated
by HEAD. | [
"Place",
"the",
"prologue",
"for",
"component",
"WHICH",
"in",
"the",
"basic",
"blocks",
"dominated",
"by",
"HEAD",
"."
] | [
"/* The block we are currently dealing with. */",
"/* Is this the first time we visit this block, i.e. have we just gone\n down the tree. */",
"/* Walk the dominator tree, visit one block per iteration of this loop.\n Each basic block is visited twice: once before visiting any children\n of the block, and once after visiting all of them (leaf nodes are\n visited only once). As an optimization, we do not visit subtrees\n that can no longer influence the prologue placement. */",
"/* First visit of a block: set the (children) cost accumulator to zero;\n\t if the block does not have the component itself, walk down. */",
"/* Initialize the cost. The cost is the block execution frequency\n\t that does not come from backedges. Calculating this by simply\n\t adding the cost of all edges that aren't backedges does not\n\t work: this does not always add up to the block frequency at\n\t all, and even if it does, rounding error makes for bad\n\t decisions. */",
"/* If this block does need the component itself, or it is cheaper to\n\t put the prologue here than in all the descendants that need it,\n\t mark it so. If this block's immediate post-dominator is dominated\n\t by this block, and that needs the prologue, we can put it on this\n\t block as well (earlier is better). */",
"/* We are back where we started, so we are done now. */",
"/* We now know the cost of the subtree rooted at the current block.\n\t Accumulate this cost in the parent. */",
"/* Don't walk the tree down unless necessary. */"
] | [
{
"param": "which",
"type": "unsigned int"
},
{
"param": "head",
"type": "basic_block"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "which",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "head",
"type": "basic_block",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6b47d4ea8cdeabbef2b1325787abc3a8e31d78a2 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/shrink-wrap.c | [
"BSD-3-Clause"
] | C | disqualify_problematic_components | void | static void
disqualify_problematic_components (sbitmap components)
{
auto_sbitmap pro (SBITMAP_SIZE (components));
auto_sbitmap epi (SBITMAP_SIZE (components));
basic_block bb;
FOR_EACH_BB_FN (bb, cfun)
{
edge e;
edge_iterator ei;
FOR_EACH_EDGE (e, ei, bb->succs)
{
/* Find which components we want pro/epilogues for here. */
bitmap_and_compl (epi, SW (e->src)->has_components,
SW (e->dest)->has_components);
bitmap_and_compl (pro, SW (e->dest)->has_components,
SW (e->src)->has_components);
/* Ask the target what it thinks about things. */
if (!bitmap_empty_p (epi))
targetm.shrink_wrap.disqualify_components (components, e, epi,
false);
if (!bitmap_empty_p (pro))
targetm.shrink_wrap.disqualify_components (components, e, pro,
true);
/* If this edge doesn't need splitting, we're fine. */
if (single_pred_p (e->dest)
&& e->dest != EXIT_BLOCK_PTR_FOR_FN (cfun))
continue;
/* If the edge can be split, that is fine too. */
if ((e->flags & EDGE_ABNORMAL) == 0)
continue;
/* We also can handle sibcalls. */
if (e->dest == EXIT_BLOCK_PTR_FOR_FN (cfun))
{
gcc_assert (e->flags & EDGE_SIBCALL);
continue;
}
/* Remove from consideration those components we would need
pro/epilogues for on edges where we cannot insert them. */
bitmap_and_compl (components, components, epi);
bitmap_and_compl (components, components, pro);
if (dump_file && !bitmap_subset_p (epi, components))
{
fprintf (dump_file, " BAD epi %d->%d", e->src->index,
e->dest->index);
if (e->flags & EDGE_EH)
fprintf (dump_file, " for EH");
dump_components ("epi", epi);
fprintf (dump_file, "\n");
}
if (dump_file && !bitmap_subset_p (pro, components))
{
fprintf (dump_file, " BAD pro %d->%d", e->src->index,
e->dest->index);
if (e->flags & EDGE_EH)
fprintf (dump_file, " for EH");
dump_components ("pro", pro);
fprintf (dump_file, "\n");
}
}
}
} | /* If we cannot handle placing some component's prologues or epilogues where
we decided we should place them, unmark that component in COMPONENTS so
that it is not wrapped separately. */ | If we cannot handle placing some component's prologues or epilogues where
we decided we should place them, unmark that component in COMPONENTS so
that it is not wrapped separately. | [
"If",
"we",
"cannot",
"handle",
"placing",
"some",
"component",
"'",
"s",
"prologues",
"or",
"epilogues",
"where",
"we",
"decided",
"we",
"should",
"place",
"them",
"unmark",
"that",
"component",
"in",
"COMPONENTS",
"so",
"that",
"it",
"is",
"not",
"wrapped",
"separately",
"."
] | static void
disqualify_problematic_components (sbitmap components)
{
auto_sbitmap pro (SBITMAP_SIZE (components));
auto_sbitmap epi (SBITMAP_SIZE (components));
basic_block bb;
FOR_EACH_BB_FN (bb, cfun)
{
edge e;
edge_iterator ei;
FOR_EACH_EDGE (e, ei, bb->succs)
{
bitmap_and_compl (epi, SW (e->src)->has_components,
SW (e->dest)->has_components);
bitmap_and_compl (pro, SW (e->dest)->has_components,
SW (e->src)->has_components);
if (!bitmap_empty_p (epi))
targetm.shrink_wrap.disqualify_components (components, e, epi,
false);
if (!bitmap_empty_p (pro))
targetm.shrink_wrap.disqualify_components (components, e, pro,
true);
if (single_pred_p (e->dest)
&& e->dest != EXIT_BLOCK_PTR_FOR_FN (cfun))
continue;
if ((e->flags & EDGE_ABNORMAL) == 0)
continue;
if (e->dest == EXIT_BLOCK_PTR_FOR_FN (cfun))
{
gcc_assert (e->flags & EDGE_SIBCALL);
continue;
}
bitmap_and_compl (components, components, epi);
bitmap_and_compl (components, components, pro);
if (dump_file && !bitmap_subset_p (epi, components))
{
fprintf (dump_file, " BAD epi %d->%d", e->src->index,
e->dest->index);
if (e->flags & EDGE_EH)
fprintf (dump_file, " for EH");
dump_components ("epi", epi);
fprintf (dump_file, "\n");
}
if (dump_file && !bitmap_subset_p (pro, components))
{
fprintf (dump_file, " BAD pro %d->%d", e->src->index,
e->dest->index);
if (e->flags & EDGE_EH)
fprintf (dump_file, " for EH");
dump_components ("pro", pro);
fprintf (dump_file, "\n");
}
}
}
} | [
"static",
"void",
"disqualify_problematic_components",
"(",
"sbitmap",
"components",
")",
"{",
"auto_sbitmap",
"pro",
"(",
"SBITMAP_SIZE",
"(",
"components",
")",
")",
";",
"auto_sbitmap",
"epi",
"(",
"SBITMAP_SIZE",
"(",
"components",
")",
")",
";",
"basic_block",
"bb",
";",
"FOR_EACH_BB_FN",
"(",
"bb",
",",
"cfun",
")",
"",
"{",
"edge",
"e",
";",
"edge_iterator",
"ei",
";",
"FOR_EACH_EDGE",
"(",
"e",
",",
"ei",
",",
"bb",
"->",
"succs",
")",
"",
"{",
"bitmap_and_compl",
"(",
"epi",
",",
"SW",
"(",
"e",
"->",
"src",
")",
"->",
"has_components",
",",
"SW",
"(",
"e",
"->",
"dest",
")",
"->",
"has_components",
")",
";",
"bitmap_and_compl",
"(",
"pro",
",",
"SW",
"(",
"e",
"->",
"dest",
")",
"->",
"has_components",
",",
"SW",
"(",
"e",
"->",
"src",
")",
"->",
"has_components",
")",
";",
"if",
"(",
"!",
"bitmap_empty_p",
"(",
"epi",
")",
")",
"targetm",
".",
"shrink_wrap",
".",
"disqualify_components",
"(",
"components",
",",
"e",
",",
"epi",
",",
"false",
")",
";",
"if",
"(",
"!",
"bitmap_empty_p",
"(",
"pro",
")",
")",
"targetm",
".",
"shrink_wrap",
".",
"disqualify_components",
"(",
"components",
",",
"e",
",",
"pro",
",",
"true",
")",
";",
"if",
"(",
"single_pred_p",
"(",
"e",
"->",
"dest",
")",
"&&",
"e",
"->",
"dest",
"!=",
"EXIT_BLOCK_PTR_FOR_FN",
"(",
"cfun",
")",
")",
"continue",
";",
"if",
"(",
"(",
"e",
"->",
"flags",
"&",
"EDGE_ABNORMAL",
")",
"==",
"0",
")",
"continue",
";",
"if",
"(",
"e",
"->",
"dest",
"==",
"EXIT_BLOCK_PTR_FOR_FN",
"(",
"cfun",
")",
")",
"{",
"gcc_assert",
"(",
"e",
"->",
"flags",
"&",
"EDGE_SIBCALL",
")",
";",
"continue",
";",
"}",
"bitmap_and_compl",
"(",
"components",
",",
"components",
",",
"epi",
")",
";",
"bitmap_and_compl",
"(",
"components",
",",
"components",
",",
"pro",
")",
";",
"if",
"(",
"dump_file",
"&&",
"!",
"bitmap_subset_p",
"(",
"epi",
",",
"components",
")",
")",
"{",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\"",
",",
"e",
"->",
"src",
"->",
"index",
",",
"e",
"->",
"dest",
"->",
"index",
")",
";",
"if",
"(",
"e",
"->",
"flags",
"&",
"EDGE_EH",
")",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\"",
")",
";",
"dump_components",
"(",
"\"",
"\"",
",",
"epi",
")",
";",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\\n",
"\"",
")",
";",
"}",
"if",
"(",
"dump_file",
"&&",
"!",
"bitmap_subset_p",
"(",
"pro",
",",
"components",
")",
")",
"{",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\"",
",",
"e",
"->",
"src",
"->",
"index",
",",
"e",
"->",
"dest",
"->",
"index",
")",
";",
"if",
"(",
"e",
"->",
"flags",
"&",
"EDGE_EH",
")",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\"",
")",
";",
"dump_components",
"(",
"\"",
"\"",
",",
"pro",
")",
";",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\\n",
"\"",
")",
";",
"}",
"}",
"}",
"}"
] | If we cannot handle placing some component's prologues or epilogues where
we decided we should place them, unmark that component in COMPONENTS so
that it is not wrapped separately. | [
"If",
"we",
"cannot",
"handle",
"placing",
"some",
"component",
"'",
"s",
"prologues",
"or",
"epilogues",
"where",
"we",
"decided",
"we",
"should",
"place",
"them",
"unmark",
"that",
"component",
"in",
"COMPONENTS",
"so",
"that",
"it",
"is",
"not",
"wrapped",
"separately",
"."
] | [
"/* Find which components we want pro/epilogues for here. */",
"/* Ask the target what it thinks about things. */",
"/* If this edge doesn't need splitting, we're fine. */",
"/* If the edge can be split, that is fine too. */",
"/* We also can handle sibcalls. */",
"/* Remove from consideration those components we would need\n\t pro/epilogues for on edges where we cannot insert them. */"
] | [
{
"param": "components",
"type": "sbitmap"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "components",
"type": "sbitmap",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6b47d4ea8cdeabbef2b1325787abc3a8e31d78a2 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/shrink-wrap.c | [
"BSD-3-Clause"
] | C | emit_common_heads_for_components | void | static void
emit_common_heads_for_components (sbitmap components)
{
auto_sbitmap pro (SBITMAP_SIZE (components));
auto_sbitmap epi (SBITMAP_SIZE (components));
auto_sbitmap tmp (SBITMAP_SIZE (components));
basic_block bb;
FOR_ALL_BB_FN (bb, cfun)
bitmap_clear (SW (bb)->head_components);
FOR_EACH_BB_FN (bb, cfun)
{
/* Find which prologue resp. epilogue components are needed for all
predecessor edges to this block. */
/* First, select all possible components. */
bitmap_copy (epi, components);
bitmap_copy (pro, components);
edge e;
edge_iterator ei;
FOR_EACH_EDGE (e, ei, bb->preds)
{
if (e->flags & EDGE_ABNORMAL)
{
bitmap_clear (epi);
bitmap_clear (pro);
break;
}
/* Deselect those epilogue components that should not be inserted
for this edge. */
bitmap_and_compl (tmp, SW (e->src)->has_components,
SW (e->dest)->has_components);
bitmap_and (epi, epi, tmp);
/* Similar, for the prologue. */
bitmap_and_compl (tmp, SW (e->dest)->has_components,
SW (e->src)->has_components);
bitmap_and (pro, pro, tmp);
}
if (dump_file && !(bitmap_empty_p (epi) && bitmap_empty_p (pro)))
fprintf (dump_file, " bb %d", bb->index);
if (dump_file && !bitmap_empty_p (epi))
dump_components ("epi", epi);
if (dump_file && !bitmap_empty_p (pro))
dump_components ("pro", pro);
if (dump_file && !(bitmap_empty_p (epi) && bitmap_empty_p (pro)))
fprintf (dump_file, "\n");
/* Place code after the BB note. */
if (!bitmap_empty_p (pro))
{
start_sequence ();
targetm.shrink_wrap.emit_prologue_components (pro);
rtx_insn *seq = get_insns ();
end_sequence ();
record_prologue_seq (seq);
emit_insn_after (seq, bb_note (bb));
bitmap_ior (SW (bb)->head_components, SW (bb)->head_components, pro);
}
if (!bitmap_empty_p (epi))
{
start_sequence ();
targetm.shrink_wrap.emit_epilogue_components (epi);
rtx_insn *seq = get_insns ();
end_sequence ();
record_epilogue_seq (seq);
emit_insn_after (seq, bb_note (bb));
bitmap_ior (SW (bb)->head_components, SW (bb)->head_components, epi);
}
}
} | /* Place code for prologues and epilogues for COMPONENTS where we can put
that code at the start of basic blocks. */ | Place code for prologues and epilogues for COMPONENTS where we can put
that code at the start of basic blocks. | [
"Place",
"code",
"for",
"prologues",
"and",
"epilogues",
"for",
"COMPONENTS",
"where",
"we",
"can",
"put",
"that",
"code",
"at",
"the",
"start",
"of",
"basic",
"blocks",
"."
] | static void
emit_common_heads_for_components (sbitmap components)
{
auto_sbitmap pro (SBITMAP_SIZE (components));
auto_sbitmap epi (SBITMAP_SIZE (components));
auto_sbitmap tmp (SBITMAP_SIZE (components));
basic_block bb;
FOR_ALL_BB_FN (bb, cfun)
bitmap_clear (SW (bb)->head_components);
FOR_EACH_BB_FN (bb, cfun)
{
bitmap_copy (epi, components);
bitmap_copy (pro, components);
edge e;
edge_iterator ei;
FOR_EACH_EDGE (e, ei, bb->preds)
{
if (e->flags & EDGE_ABNORMAL)
{
bitmap_clear (epi);
bitmap_clear (pro);
break;
}
bitmap_and_compl (tmp, SW (e->src)->has_components,
SW (e->dest)->has_components);
bitmap_and (epi, epi, tmp);
bitmap_and_compl (tmp, SW (e->dest)->has_components,
SW (e->src)->has_components);
bitmap_and (pro, pro, tmp);
}
if (dump_file && !(bitmap_empty_p (epi) && bitmap_empty_p (pro)))
fprintf (dump_file, " bb %d", bb->index);
if (dump_file && !bitmap_empty_p (epi))
dump_components ("epi", epi);
if (dump_file && !bitmap_empty_p (pro))
dump_components ("pro", pro);
if (dump_file && !(bitmap_empty_p (epi) && bitmap_empty_p (pro)))
fprintf (dump_file, "\n");
if (!bitmap_empty_p (pro))
{
start_sequence ();
targetm.shrink_wrap.emit_prologue_components (pro);
rtx_insn *seq = get_insns ();
end_sequence ();
record_prologue_seq (seq);
emit_insn_after (seq, bb_note (bb));
bitmap_ior (SW (bb)->head_components, SW (bb)->head_components, pro);
}
if (!bitmap_empty_p (epi))
{
start_sequence ();
targetm.shrink_wrap.emit_epilogue_components (epi);
rtx_insn *seq = get_insns ();
end_sequence ();
record_epilogue_seq (seq);
emit_insn_after (seq, bb_note (bb));
bitmap_ior (SW (bb)->head_components, SW (bb)->head_components, epi);
}
}
} | [
"static",
"void",
"emit_common_heads_for_components",
"(",
"sbitmap",
"components",
")",
"{",
"auto_sbitmap",
"pro",
"(",
"SBITMAP_SIZE",
"(",
"components",
")",
")",
";",
"auto_sbitmap",
"epi",
"(",
"SBITMAP_SIZE",
"(",
"components",
")",
")",
";",
"auto_sbitmap",
"tmp",
"(",
"SBITMAP_SIZE",
"(",
"components",
")",
")",
";",
"basic_block",
"bb",
";",
"FOR_ALL_BB_FN",
"(",
"bb",
",",
"cfun",
")",
"",
"bitmap_clear",
"(",
"SW",
"(",
"bb",
")",
"->",
"head_components",
")",
";",
"FOR_EACH_BB_FN",
"(",
"bb",
",",
"cfun",
")",
"",
"{",
"bitmap_copy",
"(",
"epi",
",",
"components",
")",
";",
"bitmap_copy",
"(",
"pro",
",",
"components",
")",
";",
"edge",
"e",
";",
"edge_iterator",
"ei",
";",
"FOR_EACH_EDGE",
"(",
"e",
",",
"ei",
",",
"bb",
"->",
"preds",
")",
"",
"{",
"if",
"(",
"e",
"->",
"flags",
"&",
"EDGE_ABNORMAL",
")",
"{",
"bitmap_clear",
"(",
"epi",
")",
";",
"bitmap_clear",
"(",
"pro",
")",
";",
"break",
";",
"}",
"bitmap_and_compl",
"(",
"tmp",
",",
"SW",
"(",
"e",
"->",
"src",
")",
"->",
"has_components",
",",
"SW",
"(",
"e",
"->",
"dest",
")",
"->",
"has_components",
")",
";",
"bitmap_and",
"(",
"epi",
",",
"epi",
",",
"tmp",
")",
";",
"bitmap_and_compl",
"(",
"tmp",
",",
"SW",
"(",
"e",
"->",
"dest",
")",
"->",
"has_components",
",",
"SW",
"(",
"e",
"->",
"src",
")",
"->",
"has_components",
")",
";",
"bitmap_and",
"(",
"pro",
",",
"pro",
",",
"tmp",
")",
";",
"}",
"if",
"(",
"dump_file",
"&&",
"!",
"(",
"bitmap_empty_p",
"(",
"epi",
")",
"&&",
"bitmap_empty_p",
"(",
"pro",
")",
")",
")",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\"",
",",
"bb",
"->",
"index",
")",
";",
"if",
"(",
"dump_file",
"&&",
"!",
"bitmap_empty_p",
"(",
"epi",
")",
")",
"dump_components",
"(",
"\"",
"\"",
",",
"epi",
")",
";",
"if",
"(",
"dump_file",
"&&",
"!",
"bitmap_empty_p",
"(",
"pro",
")",
")",
"dump_components",
"(",
"\"",
"\"",
",",
"pro",
")",
";",
"if",
"(",
"dump_file",
"&&",
"!",
"(",
"bitmap_empty_p",
"(",
"epi",
")",
"&&",
"bitmap_empty_p",
"(",
"pro",
")",
")",
")",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\\n",
"\"",
")",
";",
"if",
"(",
"!",
"bitmap_empty_p",
"(",
"pro",
")",
")",
"{",
"start_sequence",
"(",
")",
";",
"targetm",
".",
"shrink_wrap",
".",
"emit_prologue_components",
"(",
"pro",
")",
";",
"rtx_insn",
"*",
"seq",
"=",
"get_insns",
"(",
")",
";",
"end_sequence",
"(",
")",
";",
"record_prologue_seq",
"(",
"seq",
")",
";",
"emit_insn_after",
"(",
"seq",
",",
"bb_note",
"(",
"bb",
")",
")",
";",
"bitmap_ior",
"(",
"SW",
"(",
"bb",
")",
"->",
"head_components",
",",
"SW",
"(",
"bb",
")",
"->",
"head_components",
",",
"pro",
")",
";",
"}",
"if",
"(",
"!",
"bitmap_empty_p",
"(",
"epi",
")",
")",
"{",
"start_sequence",
"(",
")",
";",
"targetm",
".",
"shrink_wrap",
".",
"emit_epilogue_components",
"(",
"epi",
")",
";",
"rtx_insn",
"*",
"seq",
"=",
"get_insns",
"(",
")",
";",
"end_sequence",
"(",
")",
";",
"record_epilogue_seq",
"(",
"seq",
")",
";",
"emit_insn_after",
"(",
"seq",
",",
"bb_note",
"(",
"bb",
")",
")",
";",
"bitmap_ior",
"(",
"SW",
"(",
"bb",
")",
"->",
"head_components",
",",
"SW",
"(",
"bb",
")",
"->",
"head_components",
",",
"epi",
")",
";",
"}",
"}",
"}"
] | Place code for prologues and epilogues for COMPONENTS where we can put
that code at the start of basic blocks. | [
"Place",
"code",
"for",
"prologues",
"and",
"epilogues",
"for",
"COMPONENTS",
"where",
"we",
"can",
"put",
"that",
"code",
"at",
"the",
"start",
"of",
"basic",
"blocks",
"."
] | [
"/* Find which prologue resp. epilogue components are needed for all\n\t predecessor edges to this block. */",
"/* First, select all possible components. */",
"/* Deselect those epilogue components that should not be inserted\n\t for this edge. */",
"/* Similar, for the prologue. */",
"/* Place code after the BB note. */"
] | [
{
"param": "components",
"type": "sbitmap"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "components",
"type": "sbitmap",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6b47d4ea8cdeabbef2b1325787abc3a8e31d78a2 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/shrink-wrap.c | [
"BSD-3-Clause"
] | C | emit_common_tails_for_components | void | static void
emit_common_tails_for_components (sbitmap components)
{
auto_sbitmap pro (SBITMAP_SIZE (components));
auto_sbitmap epi (SBITMAP_SIZE (components));
auto_sbitmap tmp (SBITMAP_SIZE (components));
basic_block bb;
FOR_ALL_BB_FN (bb, cfun)
bitmap_clear (SW (bb)->tail_components);
FOR_EACH_BB_FN (bb, cfun)
{
/* Find which prologue resp. epilogue components are needed for all
successor edges from this block. */
if (EDGE_COUNT (bb->succs) == 0)
continue;
/* First, select all possible components. */
bitmap_copy (epi, components);
bitmap_copy (pro, components);
edge e;
edge_iterator ei;
FOR_EACH_EDGE (e, ei, bb->succs)
{
if (e->flags & EDGE_ABNORMAL)
{
bitmap_clear (epi);
bitmap_clear (pro);
break;
}
/* Deselect those epilogue components that should not be inserted
for this edge, and also those that are already put at the head
of the successor block. */
bitmap_and_compl (tmp, SW (e->src)->has_components,
SW (e->dest)->has_components);
bitmap_and_compl (tmp, tmp, SW (e->dest)->head_components);
bitmap_and (epi, epi, tmp);
/* Similarly, for the prologue. */
bitmap_and_compl (tmp, SW (e->dest)->has_components,
SW (e->src)->has_components);
bitmap_and_compl (tmp, tmp, SW (e->dest)->head_components);
bitmap_and (pro, pro, tmp);
}
/* If the last insn of this block is a control flow insn we cannot
put anything after it. We can put our code before it instead,
but only if that jump insn is a simple jump. */
rtx_insn *last_insn = BB_END (bb);
if (control_flow_insn_p (last_insn) && !simplejump_p (last_insn))
{
bitmap_clear (epi);
bitmap_clear (pro);
}
if (dump_file && !(bitmap_empty_p (epi) && bitmap_empty_p (pro)))
fprintf (dump_file, " bb %d", bb->index);
if (dump_file && !bitmap_empty_p (epi))
dump_components ("epi", epi);
if (dump_file && !bitmap_empty_p (pro))
dump_components ("pro", pro);
if (dump_file && !(bitmap_empty_p (epi) && bitmap_empty_p (pro)))
fprintf (dump_file, "\n");
/* Put the code at the end of the BB, but before any final jump. */
if (!bitmap_empty_p (epi))
{
start_sequence ();
targetm.shrink_wrap.emit_epilogue_components (epi);
rtx_insn *seq = get_insns ();
end_sequence ();
record_epilogue_seq (seq);
if (control_flow_insn_p (last_insn))
emit_insn_before (seq, last_insn);
else
emit_insn_after (seq, last_insn);
bitmap_ior (SW (bb)->tail_components, SW (bb)->tail_components, epi);
}
if (!bitmap_empty_p (pro))
{
start_sequence ();
targetm.shrink_wrap.emit_prologue_components (pro);
rtx_insn *seq = get_insns ();
end_sequence ();
record_prologue_seq (seq);
if (control_flow_insn_p (last_insn))
emit_insn_before (seq, last_insn);
else
emit_insn_after (seq, last_insn);
bitmap_ior (SW (bb)->tail_components, SW (bb)->tail_components, pro);
}
}
} | /* Place code for prologues and epilogues for COMPONENTS where we can put
that code at the end of basic blocks. */ | Place code for prologues and epilogues for COMPONENTS where we can put
that code at the end of basic blocks. | [
"Place",
"code",
"for",
"prologues",
"and",
"epilogues",
"for",
"COMPONENTS",
"where",
"we",
"can",
"put",
"that",
"code",
"at",
"the",
"end",
"of",
"basic",
"blocks",
"."
] | static void
emit_common_tails_for_components (sbitmap components)
{
auto_sbitmap pro (SBITMAP_SIZE (components));
auto_sbitmap epi (SBITMAP_SIZE (components));
auto_sbitmap tmp (SBITMAP_SIZE (components));
basic_block bb;
FOR_ALL_BB_FN (bb, cfun)
bitmap_clear (SW (bb)->tail_components);
FOR_EACH_BB_FN (bb, cfun)
{
if (EDGE_COUNT (bb->succs) == 0)
continue;
bitmap_copy (epi, components);
bitmap_copy (pro, components);
edge e;
edge_iterator ei;
FOR_EACH_EDGE (e, ei, bb->succs)
{
if (e->flags & EDGE_ABNORMAL)
{
bitmap_clear (epi);
bitmap_clear (pro);
break;
}
bitmap_and_compl (tmp, SW (e->src)->has_components,
SW (e->dest)->has_components);
bitmap_and_compl (tmp, tmp, SW (e->dest)->head_components);
bitmap_and (epi, epi, tmp);
bitmap_and_compl (tmp, SW (e->dest)->has_components,
SW (e->src)->has_components);
bitmap_and_compl (tmp, tmp, SW (e->dest)->head_components);
bitmap_and (pro, pro, tmp);
}
rtx_insn *last_insn = BB_END (bb);
if (control_flow_insn_p (last_insn) && !simplejump_p (last_insn))
{
bitmap_clear (epi);
bitmap_clear (pro);
}
if (dump_file && !(bitmap_empty_p (epi) && bitmap_empty_p (pro)))
fprintf (dump_file, " bb %d", bb->index);
if (dump_file && !bitmap_empty_p (epi))
dump_components ("epi", epi);
if (dump_file && !bitmap_empty_p (pro))
dump_components ("pro", pro);
if (dump_file && !(bitmap_empty_p (epi) && bitmap_empty_p (pro)))
fprintf (dump_file, "\n");
if (!bitmap_empty_p (epi))
{
start_sequence ();
targetm.shrink_wrap.emit_epilogue_components (epi);
rtx_insn *seq = get_insns ();
end_sequence ();
record_epilogue_seq (seq);
if (control_flow_insn_p (last_insn))
emit_insn_before (seq, last_insn);
else
emit_insn_after (seq, last_insn);
bitmap_ior (SW (bb)->tail_components, SW (bb)->tail_components, epi);
}
if (!bitmap_empty_p (pro))
{
start_sequence ();
targetm.shrink_wrap.emit_prologue_components (pro);
rtx_insn *seq = get_insns ();
end_sequence ();
record_prologue_seq (seq);
if (control_flow_insn_p (last_insn))
emit_insn_before (seq, last_insn);
else
emit_insn_after (seq, last_insn);
bitmap_ior (SW (bb)->tail_components, SW (bb)->tail_components, pro);
}
}
} | [
"static",
"void",
"emit_common_tails_for_components",
"(",
"sbitmap",
"components",
")",
"{",
"auto_sbitmap",
"pro",
"(",
"SBITMAP_SIZE",
"(",
"components",
")",
")",
";",
"auto_sbitmap",
"epi",
"(",
"SBITMAP_SIZE",
"(",
"components",
")",
")",
";",
"auto_sbitmap",
"tmp",
"(",
"SBITMAP_SIZE",
"(",
"components",
")",
")",
";",
"basic_block",
"bb",
";",
"FOR_ALL_BB_FN",
"(",
"bb",
",",
"cfun",
")",
"",
"bitmap_clear",
"(",
"SW",
"(",
"bb",
")",
"->",
"tail_components",
")",
";",
"FOR_EACH_BB_FN",
"(",
"bb",
",",
"cfun",
")",
"",
"{",
"if",
"(",
"EDGE_COUNT",
"(",
"bb",
"->",
"succs",
")",
"==",
"0",
")",
"continue",
";",
"bitmap_copy",
"(",
"epi",
",",
"components",
")",
";",
"bitmap_copy",
"(",
"pro",
",",
"components",
")",
";",
"edge",
"e",
";",
"edge_iterator",
"ei",
";",
"FOR_EACH_EDGE",
"(",
"e",
",",
"ei",
",",
"bb",
"->",
"succs",
")",
"",
"{",
"if",
"(",
"e",
"->",
"flags",
"&",
"EDGE_ABNORMAL",
")",
"{",
"bitmap_clear",
"(",
"epi",
")",
";",
"bitmap_clear",
"(",
"pro",
")",
";",
"break",
";",
"}",
"bitmap_and_compl",
"(",
"tmp",
",",
"SW",
"(",
"e",
"->",
"src",
")",
"->",
"has_components",
",",
"SW",
"(",
"e",
"->",
"dest",
")",
"->",
"has_components",
")",
";",
"bitmap_and_compl",
"(",
"tmp",
",",
"tmp",
",",
"SW",
"(",
"e",
"->",
"dest",
")",
"->",
"head_components",
")",
";",
"bitmap_and",
"(",
"epi",
",",
"epi",
",",
"tmp",
")",
";",
"bitmap_and_compl",
"(",
"tmp",
",",
"SW",
"(",
"e",
"->",
"dest",
")",
"->",
"has_components",
",",
"SW",
"(",
"e",
"->",
"src",
")",
"->",
"has_components",
")",
";",
"bitmap_and_compl",
"(",
"tmp",
",",
"tmp",
",",
"SW",
"(",
"e",
"->",
"dest",
")",
"->",
"head_components",
")",
";",
"bitmap_and",
"(",
"pro",
",",
"pro",
",",
"tmp",
")",
";",
"}",
"rtx_insn",
"*",
"last_insn",
"=",
"BB_END",
"(",
"bb",
")",
";",
"if",
"(",
"control_flow_insn_p",
"(",
"last_insn",
")",
"&&",
"!",
"simplejump_p",
"(",
"last_insn",
")",
")",
"{",
"bitmap_clear",
"(",
"epi",
")",
";",
"bitmap_clear",
"(",
"pro",
")",
";",
"}",
"if",
"(",
"dump_file",
"&&",
"!",
"(",
"bitmap_empty_p",
"(",
"epi",
")",
"&&",
"bitmap_empty_p",
"(",
"pro",
")",
")",
")",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\"",
",",
"bb",
"->",
"index",
")",
";",
"if",
"(",
"dump_file",
"&&",
"!",
"bitmap_empty_p",
"(",
"epi",
")",
")",
"dump_components",
"(",
"\"",
"\"",
",",
"epi",
")",
";",
"if",
"(",
"dump_file",
"&&",
"!",
"bitmap_empty_p",
"(",
"pro",
")",
")",
"dump_components",
"(",
"\"",
"\"",
",",
"pro",
")",
";",
"if",
"(",
"dump_file",
"&&",
"!",
"(",
"bitmap_empty_p",
"(",
"epi",
")",
"&&",
"bitmap_empty_p",
"(",
"pro",
")",
")",
")",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\\n",
"\"",
")",
";",
"if",
"(",
"!",
"bitmap_empty_p",
"(",
"epi",
")",
")",
"{",
"start_sequence",
"(",
")",
";",
"targetm",
".",
"shrink_wrap",
".",
"emit_epilogue_components",
"(",
"epi",
")",
";",
"rtx_insn",
"*",
"seq",
"=",
"get_insns",
"(",
")",
";",
"end_sequence",
"(",
")",
";",
"record_epilogue_seq",
"(",
"seq",
")",
";",
"if",
"(",
"control_flow_insn_p",
"(",
"last_insn",
")",
")",
"emit_insn_before",
"(",
"seq",
",",
"last_insn",
")",
";",
"else",
"emit_insn_after",
"(",
"seq",
",",
"last_insn",
")",
";",
"bitmap_ior",
"(",
"SW",
"(",
"bb",
")",
"->",
"tail_components",
",",
"SW",
"(",
"bb",
")",
"->",
"tail_components",
",",
"epi",
")",
";",
"}",
"if",
"(",
"!",
"bitmap_empty_p",
"(",
"pro",
")",
")",
"{",
"start_sequence",
"(",
")",
";",
"targetm",
".",
"shrink_wrap",
".",
"emit_prologue_components",
"(",
"pro",
")",
";",
"rtx_insn",
"*",
"seq",
"=",
"get_insns",
"(",
")",
";",
"end_sequence",
"(",
")",
";",
"record_prologue_seq",
"(",
"seq",
")",
";",
"if",
"(",
"control_flow_insn_p",
"(",
"last_insn",
")",
")",
"emit_insn_before",
"(",
"seq",
",",
"last_insn",
")",
";",
"else",
"emit_insn_after",
"(",
"seq",
",",
"last_insn",
")",
";",
"bitmap_ior",
"(",
"SW",
"(",
"bb",
")",
"->",
"tail_components",
",",
"SW",
"(",
"bb",
")",
"->",
"tail_components",
",",
"pro",
")",
";",
"}",
"}",
"}"
] | Place code for prologues and epilogues for COMPONENTS where we can put
that code at the end of basic blocks. | [
"Place",
"code",
"for",
"prologues",
"and",
"epilogues",
"for",
"COMPONENTS",
"where",
"we",
"can",
"put",
"that",
"code",
"at",
"the",
"end",
"of",
"basic",
"blocks",
"."
] | [
"/* Find which prologue resp. epilogue components are needed for all\n\t successor edges from this block. */",
"/* First, select all possible components. */",
"/* Deselect those epilogue components that should not be inserted\n\t for this edge, and also those that are already put at the head\n\t of the successor block. */",
"/* Similarly, for the prologue. */",
"/* If the last insn of this block is a control flow insn we cannot\n\t put anything after it. We can put our code before it instead,\n\t but only if that jump insn is a simple jump. */",
"/* Put the code at the end of the BB, but before any final jump. */"
] | [
{
"param": "components",
"type": "sbitmap"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "components",
"type": "sbitmap",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6b47d4ea8cdeabbef2b1325787abc3a8e31d78a2 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/shrink-wrap.c | [
"BSD-3-Clause"
] | C | insert_prologue_epilogue_for_components | void | static void
insert_prologue_epilogue_for_components (sbitmap components)
{
auto_sbitmap pro (SBITMAP_SIZE (components));
auto_sbitmap epi (SBITMAP_SIZE (components));
basic_block bb;
FOR_EACH_BB_FN (bb, cfun)
{
if (!bb->aux)
continue;
edge e;
edge_iterator ei;
FOR_EACH_EDGE (e, ei, bb->succs)
{
/* Find which pro/epilogue components are needed on this edge. */
bitmap_and_compl (epi, SW (e->src)->has_components,
SW (e->dest)->has_components);
bitmap_and_compl (pro, SW (e->dest)->has_components,
SW (e->src)->has_components);
bitmap_and (epi, epi, components);
bitmap_and (pro, pro, components);
/* Deselect those we already have put at the head or tail of the
edge's dest resp. src. */
bitmap_and_compl (epi, epi, SW (e->dest)->head_components);
bitmap_and_compl (pro, pro, SW (e->dest)->head_components);
bitmap_and_compl (epi, epi, SW (e->src)->tail_components);
bitmap_and_compl (pro, pro, SW (e->src)->tail_components);
if (!bitmap_empty_p (epi) || !bitmap_empty_p (pro))
{
if (dump_file)
{
fprintf (dump_file, " %d->%d", e->src->index,
e->dest->index);
dump_components ("epi", epi);
dump_components ("pro", pro);
if (e->flags & EDGE_SIBCALL)
fprintf (dump_file, " (SIBCALL)");
else if (e->flags & EDGE_ABNORMAL)
fprintf (dump_file, " (ABNORMAL)");
fprintf (dump_file, "\n");
}
/* Put the epilogue components in place. */
start_sequence ();
targetm.shrink_wrap.emit_epilogue_components (epi);
rtx_insn *seq = get_insns ();
end_sequence ();
record_epilogue_seq (seq);
if (e->flags & EDGE_SIBCALL)
{
gcc_assert (e->dest == EXIT_BLOCK_PTR_FOR_FN (cfun));
rtx_insn *insn = BB_END (e->src);
gcc_assert (CALL_P (insn) && SIBLING_CALL_P (insn));
emit_insn_before (seq, insn);
}
else if (e->dest == EXIT_BLOCK_PTR_FOR_FN (cfun))
{
gcc_assert (e->flags & EDGE_FALLTHRU);
basic_block new_bb = split_edge (e);
emit_insn_after (seq, BB_END (new_bb));
}
else
insert_insn_on_edge (seq, e);
/* Put the prologue components in place. */
start_sequence ();
targetm.shrink_wrap.emit_prologue_components (pro);
seq = get_insns ();
end_sequence ();
record_prologue_seq (seq);
insert_insn_on_edge (seq, e);
}
}
}
commit_edge_insertions ();
} | /* Place prologues and epilogues for COMPONENTS on edges, if we haven't already
placed them inside blocks directly. */ | Place prologues and epilogues for COMPONENTS on edges, if we haven't already
placed them inside blocks directly. | [
"Place",
"prologues",
"and",
"epilogues",
"for",
"COMPONENTS",
"on",
"edges",
"if",
"we",
"haven",
"'",
"t",
"already",
"placed",
"them",
"inside",
"blocks",
"directly",
"."
] | static void
insert_prologue_epilogue_for_components (sbitmap components)
{
auto_sbitmap pro (SBITMAP_SIZE (components));
auto_sbitmap epi (SBITMAP_SIZE (components));
basic_block bb;
FOR_EACH_BB_FN (bb, cfun)
{
if (!bb->aux)
continue;
edge e;
edge_iterator ei;
FOR_EACH_EDGE (e, ei, bb->succs)
{
bitmap_and_compl (epi, SW (e->src)->has_components,
SW (e->dest)->has_components);
bitmap_and_compl (pro, SW (e->dest)->has_components,
SW (e->src)->has_components);
bitmap_and (epi, epi, components);
bitmap_and (pro, pro, components);
bitmap_and_compl (epi, epi, SW (e->dest)->head_components);
bitmap_and_compl (pro, pro, SW (e->dest)->head_components);
bitmap_and_compl (epi, epi, SW (e->src)->tail_components);
bitmap_and_compl (pro, pro, SW (e->src)->tail_components);
if (!bitmap_empty_p (epi) || !bitmap_empty_p (pro))
{
if (dump_file)
{
fprintf (dump_file, " %d->%d", e->src->index,
e->dest->index);
dump_components ("epi", epi);
dump_components ("pro", pro);
if (e->flags & EDGE_SIBCALL)
fprintf (dump_file, " (SIBCALL)");
else if (e->flags & EDGE_ABNORMAL)
fprintf (dump_file, " (ABNORMAL)");
fprintf (dump_file, "\n");
}
start_sequence ();
targetm.shrink_wrap.emit_epilogue_components (epi);
rtx_insn *seq = get_insns ();
end_sequence ();
record_epilogue_seq (seq);
if (e->flags & EDGE_SIBCALL)
{
gcc_assert (e->dest == EXIT_BLOCK_PTR_FOR_FN (cfun));
rtx_insn *insn = BB_END (e->src);
gcc_assert (CALL_P (insn) && SIBLING_CALL_P (insn));
emit_insn_before (seq, insn);
}
else if (e->dest == EXIT_BLOCK_PTR_FOR_FN (cfun))
{
gcc_assert (e->flags & EDGE_FALLTHRU);
basic_block new_bb = split_edge (e);
emit_insn_after (seq, BB_END (new_bb));
}
else
insert_insn_on_edge (seq, e);
start_sequence ();
targetm.shrink_wrap.emit_prologue_components (pro);
seq = get_insns ();
end_sequence ();
record_prologue_seq (seq);
insert_insn_on_edge (seq, e);
}
}
}
commit_edge_insertions ();
} | [
"static",
"void",
"insert_prologue_epilogue_for_components",
"(",
"sbitmap",
"components",
")",
"{",
"auto_sbitmap",
"pro",
"(",
"SBITMAP_SIZE",
"(",
"components",
")",
")",
";",
"auto_sbitmap",
"epi",
"(",
"SBITMAP_SIZE",
"(",
"components",
")",
")",
";",
"basic_block",
"bb",
";",
"FOR_EACH_BB_FN",
"(",
"bb",
",",
"cfun",
")",
"",
"{",
"if",
"(",
"!",
"bb",
"->",
"aux",
")",
"continue",
";",
"edge",
"e",
";",
"edge_iterator",
"ei",
";",
"FOR_EACH_EDGE",
"(",
"e",
",",
"ei",
",",
"bb",
"->",
"succs",
")",
"",
"{",
"bitmap_and_compl",
"(",
"epi",
",",
"SW",
"(",
"e",
"->",
"src",
")",
"->",
"has_components",
",",
"SW",
"(",
"e",
"->",
"dest",
")",
"->",
"has_components",
")",
";",
"bitmap_and_compl",
"(",
"pro",
",",
"SW",
"(",
"e",
"->",
"dest",
")",
"->",
"has_components",
",",
"SW",
"(",
"e",
"->",
"src",
")",
"->",
"has_components",
")",
";",
"bitmap_and",
"(",
"epi",
",",
"epi",
",",
"components",
")",
";",
"bitmap_and",
"(",
"pro",
",",
"pro",
",",
"components",
")",
";",
"bitmap_and_compl",
"(",
"epi",
",",
"epi",
",",
"SW",
"(",
"e",
"->",
"dest",
")",
"->",
"head_components",
")",
";",
"bitmap_and_compl",
"(",
"pro",
",",
"pro",
",",
"SW",
"(",
"e",
"->",
"dest",
")",
"->",
"head_components",
")",
";",
"bitmap_and_compl",
"(",
"epi",
",",
"epi",
",",
"SW",
"(",
"e",
"->",
"src",
")",
"->",
"tail_components",
")",
";",
"bitmap_and_compl",
"(",
"pro",
",",
"pro",
",",
"SW",
"(",
"e",
"->",
"src",
")",
"->",
"tail_components",
")",
";",
"if",
"(",
"!",
"bitmap_empty_p",
"(",
"epi",
")",
"||",
"!",
"bitmap_empty_p",
"(",
"pro",
")",
")",
"{",
"if",
"(",
"dump_file",
")",
"{",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\"",
",",
"e",
"->",
"src",
"->",
"index",
",",
"e",
"->",
"dest",
"->",
"index",
")",
";",
"dump_components",
"(",
"\"",
"\"",
",",
"epi",
")",
";",
"dump_components",
"(",
"\"",
"\"",
",",
"pro",
")",
";",
"if",
"(",
"e",
"->",
"flags",
"&",
"EDGE_SIBCALL",
")",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\"",
")",
";",
"else",
"if",
"(",
"e",
"->",
"flags",
"&",
"EDGE_ABNORMAL",
")",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\"",
")",
";",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\\n",
"\"",
")",
";",
"}",
"start_sequence",
"(",
")",
";",
"targetm",
".",
"shrink_wrap",
".",
"emit_epilogue_components",
"(",
"epi",
")",
";",
"rtx_insn",
"*",
"seq",
"=",
"get_insns",
"(",
")",
";",
"end_sequence",
"(",
")",
";",
"record_epilogue_seq",
"(",
"seq",
")",
";",
"if",
"(",
"e",
"->",
"flags",
"&",
"EDGE_SIBCALL",
")",
"{",
"gcc_assert",
"(",
"e",
"->",
"dest",
"==",
"EXIT_BLOCK_PTR_FOR_FN",
"(",
"cfun",
")",
")",
";",
"rtx_insn",
"*",
"insn",
"=",
"BB_END",
"(",
"e",
"->",
"src",
")",
";",
"gcc_assert",
"(",
"CALL_P",
"(",
"insn",
")",
"&&",
"SIBLING_CALL_P",
"(",
"insn",
")",
")",
";",
"emit_insn_before",
"(",
"seq",
",",
"insn",
")",
";",
"}",
"else",
"if",
"(",
"e",
"->",
"dest",
"==",
"EXIT_BLOCK_PTR_FOR_FN",
"(",
"cfun",
")",
")",
"{",
"gcc_assert",
"(",
"e",
"->",
"flags",
"&",
"EDGE_FALLTHRU",
")",
";",
"basic_block",
"new_bb",
"=",
"split_edge",
"(",
"e",
")",
";",
"emit_insn_after",
"(",
"seq",
",",
"BB_END",
"(",
"new_bb",
")",
")",
";",
"}",
"else",
"insert_insn_on_edge",
"(",
"seq",
",",
"e",
")",
";",
"start_sequence",
"(",
")",
";",
"targetm",
".",
"shrink_wrap",
".",
"emit_prologue_components",
"(",
"pro",
")",
";",
"seq",
"=",
"get_insns",
"(",
")",
";",
"end_sequence",
"(",
")",
";",
"record_prologue_seq",
"(",
"seq",
")",
";",
"insert_insn_on_edge",
"(",
"seq",
",",
"e",
")",
";",
"}",
"}",
"}",
"commit_edge_insertions",
"(",
")",
";",
"}"
] | Place prologues and epilogues for COMPONENTS on edges, if we haven't already
placed them inside blocks directly. | [
"Place",
"prologues",
"and",
"epilogues",
"for",
"COMPONENTS",
"on",
"edges",
"if",
"we",
"haven",
"'",
"t",
"already",
"placed",
"them",
"inside",
"blocks",
"directly",
"."
] | [
"/* Find which pro/epilogue components are needed on this edge. */",
"/* Deselect those we already have put at the head or tail of the\n\t edge's dest resp. src. */",
"/* Put the epilogue components in place. */",
"/* Put the prologue components in place. */"
] | [
{
"param": "components",
"type": "sbitmap"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "components",
"type": "sbitmap",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6b47d4ea8cdeabbef2b1325787abc3a8e31d78a2 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/shrink-wrap.c | [
"BSD-3-Clause"
] | C | try_shrink_wrapping_separate | void | void
try_shrink_wrapping_separate (basic_block first_bb)
{
if (HAVE_cc0)
return;
if (!(SHRINK_WRAPPING_ENABLED
&& flag_shrink_wrap_separate
&& optimize_function_for_speed_p (cfun)
&& targetm.shrink_wrap.get_separate_components))
return;
/* We don't handle "strange" functions. */
if (cfun->calls_alloca
|| cfun->calls_setjmp
|| cfun->can_throw_non_call_exceptions
|| crtl->calls_eh_return
|| crtl->has_nonlocal_goto
|| crtl->saves_all_registers)
return;
/* Ask the target what components there are. If it returns NULL, don't
do anything. */
sbitmap components = targetm.shrink_wrap.get_separate_components ();
if (!components)
return;
/* We need LIVE info, not defining anything in the entry block and not
using anything in the exit block. A block then needs a component if
the register for that component is in the IN or GEN or KILL set for
that block. */
df_scan->local_flags |= DF_SCAN_EMPTY_ENTRY_EXIT;
df_update_entry_exit_and_calls ();
df_live_add_problem ();
df_live_set_all_dirty ();
df_analyze ();
calculate_dominance_info (CDI_DOMINATORS);
calculate_dominance_info (CDI_POST_DOMINATORS);
init_separate_shrink_wrap (components);
sbitmap_iterator sbi;
unsigned int j;
EXECUTE_IF_SET_IN_BITMAP (components, 0, j, sbi)
place_prologue_for_one_component (j, first_bb);
spread_components (components);
disqualify_problematic_components (components);
/* Don't separately shrink-wrap anything where the "main" prologue will
go; the target code can often optimize things if it is presented with
all components together (say, if it generates store-multiple insns). */
bitmap_and_compl (components, components, SW (first_bb)->has_components);
if (bitmap_empty_p (components))
{
if (dump_file)
fprintf (dump_file, "Not wrapping anything separately.\n");
}
else
{
if (dump_file)
{
fprintf (dump_file, "The components we wrap separately are");
dump_components ("sep", components);
fprintf (dump_file, "\n");
fprintf (dump_file, "... Inserting common heads...\n");
}
emit_common_heads_for_components (components);
if (dump_file)
fprintf (dump_file, "... Inserting common tails...\n");
emit_common_tails_for_components (components);
if (dump_file)
fprintf (dump_file, "... Inserting the more difficult ones...\n");
insert_prologue_epilogue_for_components (components);
if (dump_file)
fprintf (dump_file, "... Done.\n");
targetm.shrink_wrap.set_handled_components (components);
crtl->shrink_wrapped_separate = true;
}
fini_separate_shrink_wrap ();
sbitmap_free (components);
free_dominance_info (CDI_DOMINATORS);
free_dominance_info (CDI_POST_DOMINATORS);
/* All done. */
df_scan->local_flags &= ~DF_SCAN_EMPTY_ENTRY_EXIT;
df_update_entry_exit_and_calls ();
df_live_set_all_dirty ();
df_analyze ();
} | /* The main entry point to this subpass. FIRST_BB is where the prologue
would be normally put. */ | The main entry point to this subpass. FIRST_BB is where the prologue
would be normally put. | [
"The",
"main",
"entry",
"point",
"to",
"this",
"subpass",
".",
"FIRST_BB",
"is",
"where",
"the",
"prologue",
"would",
"be",
"normally",
"put",
"."
] | void
try_shrink_wrapping_separate (basic_block first_bb)
{
if (HAVE_cc0)
return;
if (!(SHRINK_WRAPPING_ENABLED
&& flag_shrink_wrap_separate
&& optimize_function_for_speed_p (cfun)
&& targetm.shrink_wrap.get_separate_components))
return;
if (cfun->calls_alloca
|| cfun->calls_setjmp
|| cfun->can_throw_non_call_exceptions
|| crtl->calls_eh_return
|| crtl->has_nonlocal_goto
|| crtl->saves_all_registers)
return;
sbitmap components = targetm.shrink_wrap.get_separate_components ();
if (!components)
return;
df_scan->local_flags |= DF_SCAN_EMPTY_ENTRY_EXIT;
df_update_entry_exit_and_calls ();
df_live_add_problem ();
df_live_set_all_dirty ();
df_analyze ();
calculate_dominance_info (CDI_DOMINATORS);
calculate_dominance_info (CDI_POST_DOMINATORS);
init_separate_shrink_wrap (components);
sbitmap_iterator sbi;
unsigned int j;
EXECUTE_IF_SET_IN_BITMAP (components, 0, j, sbi)
place_prologue_for_one_component (j, first_bb);
spread_components (components);
disqualify_problematic_components (components);
bitmap_and_compl (components, components, SW (first_bb)->has_components);
if (bitmap_empty_p (components))
{
if (dump_file)
fprintf (dump_file, "Not wrapping anything separately.\n");
}
else
{
if (dump_file)
{
fprintf (dump_file, "The components we wrap separately are");
dump_components ("sep", components);
fprintf (dump_file, "\n");
fprintf (dump_file, "... Inserting common heads...\n");
}
emit_common_heads_for_components (components);
if (dump_file)
fprintf (dump_file, "... Inserting common tails...\n");
emit_common_tails_for_components (components);
if (dump_file)
fprintf (dump_file, "... Inserting the more difficult ones...\n");
insert_prologue_epilogue_for_components (components);
if (dump_file)
fprintf (dump_file, "... Done.\n");
targetm.shrink_wrap.set_handled_components (components);
crtl->shrink_wrapped_separate = true;
}
fini_separate_shrink_wrap ();
sbitmap_free (components);
free_dominance_info (CDI_DOMINATORS);
free_dominance_info (CDI_POST_DOMINATORS);
df_scan->local_flags &= ~DF_SCAN_EMPTY_ENTRY_EXIT;
df_update_entry_exit_and_calls ();
df_live_set_all_dirty ();
df_analyze ();
} | [
"void",
"try_shrink_wrapping_separate",
"(",
"basic_block",
"first_bb",
")",
"{",
"if",
"(",
"HAVE_cc0",
")",
"return",
";",
"if",
"(",
"!",
"(",
"SHRINK_WRAPPING_ENABLED",
"&&",
"flag_shrink_wrap_separate",
"&&",
"optimize_function_for_speed_p",
"(",
"cfun",
")",
"&&",
"targetm",
".",
"shrink_wrap",
".",
"get_separate_components",
")",
")",
"return",
";",
"if",
"(",
"cfun",
"->",
"calls_alloca",
"||",
"cfun",
"->",
"calls_setjmp",
"||",
"cfun",
"->",
"can_throw_non_call_exceptions",
"||",
"crtl",
"->",
"calls_eh_return",
"||",
"crtl",
"->",
"has_nonlocal_goto",
"||",
"crtl",
"->",
"saves_all_registers",
")",
"return",
";",
"sbitmap",
"components",
"=",
"targetm",
".",
"shrink_wrap",
".",
"get_separate_components",
"(",
")",
";",
"if",
"(",
"!",
"components",
")",
"return",
";",
"df_scan",
"->",
"local_flags",
"|=",
"DF_SCAN_EMPTY_ENTRY_EXIT",
";",
"df_update_entry_exit_and_calls",
"(",
")",
";",
"df_live_add_problem",
"(",
")",
";",
"df_live_set_all_dirty",
"(",
")",
";",
"df_analyze",
"(",
")",
";",
"calculate_dominance_info",
"(",
"CDI_DOMINATORS",
")",
";",
"calculate_dominance_info",
"(",
"CDI_POST_DOMINATORS",
")",
";",
"init_separate_shrink_wrap",
"(",
"components",
")",
";",
"sbitmap_iterator",
"sbi",
";",
"unsigned",
"int",
"j",
";",
"EXECUTE_IF_SET_IN_BITMAP",
"(",
"components",
",",
"0",
",",
"j",
",",
"sbi",
")",
"",
"place_prologue_for_one_component",
"(",
"j",
",",
"first_bb",
")",
";",
"spread_components",
"(",
"components",
")",
";",
"disqualify_problematic_components",
"(",
"components",
")",
";",
"bitmap_and_compl",
"(",
"components",
",",
"components",
",",
"SW",
"(",
"first_bb",
")",
"->",
"has_components",
")",
";",
"if",
"(",
"bitmap_empty_p",
"(",
"components",
")",
")",
"{",
"if",
"(",
"dump_file",
")",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\\n",
"\"",
")",
";",
"}",
"else",
"{",
"if",
"(",
"dump_file",
")",
"{",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\"",
")",
";",
"dump_components",
"(",
"\"",
"\"",
",",
"components",
")",
";",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\\n",
"\"",
")",
";",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\\n",
"\"",
")",
";",
"}",
"emit_common_heads_for_components",
"(",
"components",
")",
";",
"if",
"(",
"dump_file",
")",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\\n",
"\"",
")",
";",
"emit_common_tails_for_components",
"(",
"components",
")",
";",
"if",
"(",
"dump_file",
")",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\\n",
"\"",
")",
";",
"insert_prologue_epilogue_for_components",
"(",
"components",
")",
";",
"if",
"(",
"dump_file",
")",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\\n",
"\"",
")",
";",
"targetm",
".",
"shrink_wrap",
".",
"set_handled_components",
"(",
"components",
")",
";",
"crtl",
"->",
"shrink_wrapped_separate",
"=",
"true",
";",
"}",
"fini_separate_shrink_wrap",
"(",
")",
";",
"sbitmap_free",
"(",
"components",
")",
";",
"free_dominance_info",
"(",
"CDI_DOMINATORS",
")",
";",
"free_dominance_info",
"(",
"CDI_POST_DOMINATORS",
")",
";",
"df_scan",
"->",
"local_flags",
"&=",
"~",
"DF_SCAN_EMPTY_ENTRY_EXIT",
";",
"df_update_entry_exit_and_calls",
"(",
")",
";",
"df_live_set_all_dirty",
"(",
")",
";",
"df_analyze",
"(",
")",
";",
"}"
] | The main entry point to this subpass. | [
"The",
"main",
"entry",
"point",
"to",
"this",
"subpass",
"."
] | [
"/* We don't handle \"strange\" functions. */",
"/* Ask the target what components there are. If it returns NULL, don't\n do anything. */",
"/* We need LIVE info, not defining anything in the entry block and not\n using anything in the exit block. A block then needs a component if\n the register for that component is in the IN or GEN or KILL set for\n that block. */",
"/* Don't separately shrink-wrap anything where the \"main\" prologue will\n go; the target code can often optimize things if it is presented with\n all components together (say, if it generates store-multiple insns). */",
"/* All done. */"
] | [
{
"param": "first_bb",
"type": "basic_block"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "first_bb",
"type": "basic_block",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33bcf4b987279f500c834564b28145b7a5ccb102 | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/cfgloopmanip.c | [
"BSD-3-Clause"
] | C | rpe_enum_p | bool | static bool
rpe_enum_p (const_basic_block bb, const void *data)
{
return dominated_by_p (CDI_DOMINATORS, bb, (const_basic_block) data);
} | /* Checks whether basic block BB is dominated by DATA. */ | Checks whether basic block BB is dominated by DATA. | [
"Checks",
"whether",
"basic",
"block",
"BB",
"is",
"dominated",
"by",
"DATA",
"."
] | static bool
rpe_enum_p (const_basic_block bb, const void *data)
{
return dominated_by_p (CDI_DOMINATORS, bb, (const_basic_block) data);
} | [
"static",
"bool",
"rpe_enum_p",
"(",
"const_basic_block",
"bb",
",",
"const",
"void",
"*",
"data",
")",
"{",
"return",
"dominated_by_p",
"(",
"CDI_DOMINATORS",
",",
"bb",
",",
"(",
"const_basic_block",
")",
"data",
")",
";",
"}"
] | Checks whether basic block BB is dominated by DATA. | [
"Checks",
"whether",
"basic",
"block",
"BB",
"is",
"dominated",
"by",
"DATA",
"."
] | [] | [
{
"param": "bb",
"type": "const_basic_block"
},
{
"param": "data",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bb",
"type": "const_basic_block",
"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": []
} |
33bcf4b987279f500c834564b28145b7a5ccb102 | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/cfgloopmanip.c | [
"BSD-3-Clause"
] | C | remove_bbs | void | static void
remove_bbs (basic_block *bbs, int nbbs)
{
int i;
for (i = 0; i < nbbs; i++)
delete_basic_block (bbs[i]);
} | /* Remove basic blocks BBS. NBBS is the number of the basic blocks. */ | Remove basic blocks BBS. NBBS is the number of the basic blocks. | [
"Remove",
"basic",
"blocks",
"BBS",
".",
"NBBS",
"is",
"the",
"number",
"of",
"the",
"basic",
"blocks",
"."
] | static void
remove_bbs (basic_block *bbs, int nbbs)
{
int i;
for (i = 0; i < nbbs; i++)
delete_basic_block (bbs[i]);
} | [
"static",
"void",
"remove_bbs",
"(",
"basic_block",
"*",
"bbs",
",",
"int",
"nbbs",
")",
"{",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"nbbs",
";",
"i",
"++",
")",
"delete_basic_block",
"(",
"bbs",
"[",
"i",
"]",
")",
";",
"}"
] | Remove basic blocks BBS. | [
"Remove",
"basic",
"blocks",
"BBS",
"."
] | [] | [
{
"param": "bbs",
"type": "basic_block"
},
{
"param": "nbbs",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bbs",
"type": "basic_block",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "nbbs",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33bcf4b987279f500c834564b28145b7a5ccb102 | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/cfgloopmanip.c | [
"BSD-3-Clause"
] | C | fix_bb_placement | bool | static bool
fix_bb_placement (basic_block bb)
{
edge e;
edge_iterator ei;
struct loop *loop = current_loops->tree_root, *act;
FOR_EACH_EDGE (e, ei, bb->succs)
{
if (e->dest == EXIT_BLOCK_PTR)
continue;
act = e->dest->loop_father;
if (act->header == e->dest)
act = loop_outer (act);
if (flow_loop_nested_p (loop, act))
loop = act;
}
if (loop == bb->loop_father)
return false;
remove_bb_from_loops (bb);
add_bb_to_loop (bb, loop);
return true;
} | /* Fix placement of basic block BB inside loop hierarchy --
Let L be a loop to that BB belongs. Then every successor of BB must either
1) belong to some superloop of loop L, or
2) be a header of loop K such that K->outer is superloop of L
Returns true if we had to move BB into other loop to enforce this condition,
false if the placement of BB was already correct (provided that placements
of its successors are correct). */ | Fix placement of basic block BB inside loop hierarchy
Let L be a loop to that BB belongs. Then every successor of BB must either
1) belong to some superloop of loop L, or
2) be a header of loop K such that K->outer is superloop of L
Returns true if we had to move BB into other loop to enforce this condition,
false if the placement of BB was already correct (provided that placements
of its successors are correct). | [
"Fix",
"placement",
"of",
"basic",
"block",
"BB",
"inside",
"loop",
"hierarchy",
"Let",
"L",
"be",
"a",
"loop",
"to",
"that",
"BB",
"belongs",
".",
"Then",
"every",
"successor",
"of",
"BB",
"must",
"either",
"1",
")",
"belong",
"to",
"some",
"superloop",
"of",
"loop",
"L",
"or",
"2",
")",
"be",
"a",
"header",
"of",
"loop",
"K",
"such",
"that",
"K",
"-",
">",
"outer",
"is",
"superloop",
"of",
"L",
"Returns",
"true",
"if",
"we",
"had",
"to",
"move",
"BB",
"into",
"other",
"loop",
"to",
"enforce",
"this",
"condition",
"false",
"if",
"the",
"placement",
"of",
"BB",
"was",
"already",
"correct",
"(",
"provided",
"that",
"placements",
"of",
"its",
"successors",
"are",
"correct",
")",
"."
] | static bool
fix_bb_placement (basic_block bb)
{
edge e;
edge_iterator ei;
struct loop *loop = current_loops->tree_root, *act;
FOR_EACH_EDGE (e, ei, bb->succs)
{
if (e->dest == EXIT_BLOCK_PTR)
continue;
act = e->dest->loop_father;
if (act->header == e->dest)
act = loop_outer (act);
if (flow_loop_nested_p (loop, act))
loop = act;
}
if (loop == bb->loop_father)
return false;
remove_bb_from_loops (bb);
add_bb_to_loop (bb, loop);
return true;
} | [
"static",
"bool",
"fix_bb_placement",
"(",
"basic_block",
"bb",
")",
"{",
"edge",
"e",
";",
"edge_iterator",
"ei",
";",
"struct",
"loop",
"*",
"loop",
"=",
"current_loops",
"->",
"tree_root",
",",
"*",
"act",
";",
"FOR_EACH_EDGE",
"(",
"e",
",",
"ei",
",",
"bb",
"->",
"succs",
")",
"",
"{",
"if",
"(",
"e",
"->",
"dest",
"==",
"EXIT_BLOCK_PTR",
")",
"continue",
";",
"act",
"=",
"e",
"->",
"dest",
"->",
"loop_father",
";",
"if",
"(",
"act",
"->",
"header",
"==",
"e",
"->",
"dest",
")",
"act",
"=",
"loop_outer",
"(",
"act",
")",
";",
"if",
"(",
"flow_loop_nested_p",
"(",
"loop",
",",
"act",
")",
")",
"loop",
"=",
"act",
";",
"}",
"if",
"(",
"loop",
"==",
"bb",
"->",
"loop_father",
")",
"return",
"false",
";",
"remove_bb_from_loops",
"(",
"bb",
")",
";",
"add_bb_to_loop",
"(",
"bb",
",",
"loop",
")",
";",
"return",
"true",
";",
"}"
] | Fix placement of basic block BB inside loop hierarchy
Let L be a loop to that BB belongs. | [
"Fix",
"placement",
"of",
"basic",
"block",
"BB",
"inside",
"loop",
"hierarchy",
"Let",
"L",
"be",
"a",
"loop",
"to",
"that",
"BB",
"belongs",
"."
] | [] | [
{
"param": "bb",
"type": "basic_block"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bb",
"type": "basic_block",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33bcf4b987279f500c834564b28145b7a5ccb102 | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/cfgloopmanip.c | [
"BSD-3-Clause"
] | C | fix_loop_placement | bool | static bool
fix_loop_placement (struct loop *loop)
{
unsigned i;
edge e;
VEC (edge, heap) *exits = get_loop_exit_edges (loop);
struct loop *father = current_loops->tree_root, *act;
bool ret = false;
FOR_EACH_VEC_ELT (edge, exits, i, e)
{
act = find_common_loop (loop, e->dest->loop_father);
if (flow_loop_nested_p (father, act))
father = act;
}
if (father != loop_outer (loop))
{
for (act = loop_outer (loop); act != father; act = loop_outer (act))
act->num_nodes -= loop->num_nodes;
flow_loop_tree_node_remove (loop);
flow_loop_tree_node_add (father, loop);
/* The exit edges of LOOP no longer exits its original immediate
superloops; remove them from the appropriate exit lists. */
FOR_EACH_VEC_ELT (edge, exits, i, e)
rescan_loop_exit (e, false, false);
ret = true;
}
VEC_free (edge, heap, exits);
return ret;
} | /* Fix placement of LOOP inside loop tree, i.e. find the innermost superloop
of LOOP to that leads at least one exit edge of LOOP, and set it
as the immediate superloop of LOOP. Return true if the immediate superloop
of LOOP changed. */ | Fix placement of LOOP inside loop tree, i.e. find the innermost superloop
of LOOP to that leads at least one exit edge of LOOP, and set it
as the immediate superloop of LOOP. Return true if the immediate superloop
of LOOP changed. | [
"Fix",
"placement",
"of",
"LOOP",
"inside",
"loop",
"tree",
"i",
".",
"e",
".",
"find",
"the",
"innermost",
"superloop",
"of",
"LOOP",
"to",
"that",
"leads",
"at",
"least",
"one",
"exit",
"edge",
"of",
"LOOP",
"and",
"set",
"it",
"as",
"the",
"immediate",
"superloop",
"of",
"LOOP",
".",
"Return",
"true",
"if",
"the",
"immediate",
"superloop",
"of",
"LOOP",
"changed",
"."
] | static bool
fix_loop_placement (struct loop *loop)
{
unsigned i;
edge e;
VEC (edge, heap) *exits = get_loop_exit_edges (loop);
struct loop *father = current_loops->tree_root, *act;
bool ret = false;
FOR_EACH_VEC_ELT (edge, exits, i, e)
{
act = find_common_loop (loop, e->dest->loop_father);
if (flow_loop_nested_p (father, act))
father = act;
}
if (father != loop_outer (loop))
{
for (act = loop_outer (loop); act != father; act = loop_outer (act))
act->num_nodes -= loop->num_nodes;
flow_loop_tree_node_remove (loop);
flow_loop_tree_node_add (father, loop);
FOR_EACH_VEC_ELT (edge, exits, i, e)
rescan_loop_exit (e, false, false);
ret = true;
}
VEC_free (edge, heap, exits);
return ret;
} | [
"static",
"bool",
"fix_loop_placement",
"(",
"struct",
"loop",
"*",
"loop",
")",
"{",
"unsigned",
"i",
";",
"edge",
"e",
";",
"VEC",
"(",
"edge",
",",
"heap",
")",
"*",
"exits",
"=",
"get_loop_exit_edges",
"(",
"loop",
")",
";",
"struct",
"loop",
"*",
"father",
"=",
"current_loops",
"->",
"tree_root",
",",
"*",
"act",
";",
"bool",
"ret",
"=",
"false",
";",
"FOR_EACH_VEC_ELT",
"(",
"edge",
",",
"exits",
",",
"i",
",",
"e",
")",
"",
"{",
"act",
"=",
"find_common_loop",
"(",
"loop",
",",
"e",
"->",
"dest",
"->",
"loop_father",
")",
";",
"if",
"(",
"flow_loop_nested_p",
"(",
"father",
",",
"act",
")",
")",
"father",
"=",
"act",
";",
"}",
"if",
"(",
"father",
"!=",
"loop_outer",
"(",
"loop",
")",
")",
"{",
"for",
"(",
"act",
"=",
"loop_outer",
"(",
"loop",
")",
";",
"act",
"!=",
"father",
";",
"act",
"=",
"loop_outer",
"(",
"act",
")",
")",
"act",
"->",
"num_nodes",
"-=",
"loop",
"->",
"num_nodes",
";",
"flow_loop_tree_node_remove",
"(",
"loop",
")",
";",
"flow_loop_tree_node_add",
"(",
"father",
",",
"loop",
")",
";",
"FOR_EACH_VEC_ELT",
"(",
"edge",
",",
"exits",
",",
"i",
",",
"e",
")",
"",
"rescan_loop_exit",
"(",
"e",
",",
"false",
",",
"false",
")",
";",
"ret",
"=",
"true",
";",
"}",
"VEC_free",
"(",
"edge",
",",
"heap",
",",
"exits",
")",
";",
"return",
"ret",
";",
"}"
] | Fix placement of LOOP inside loop tree, i.e. | [
"Fix",
"placement",
"of",
"LOOP",
"inside",
"loop",
"tree",
"i",
".",
"e",
"."
] | [
"/* The exit edges of LOOP no longer exits its original immediate\n\t superloops; remove them from the appropriate exit lists. */"
] | [
{
"param": "loop",
"type": "struct loop"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "loop",
"type": "struct loop",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33bcf4b987279f500c834564b28145b7a5ccb102 | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/cfgloopmanip.c | [
"BSD-3-Clause"
] | C | fix_bb_placements | void | static void
fix_bb_placements (basic_block from,
bool *irred_invalidated)
{
sbitmap in_queue;
basic_block *queue, *qtop, *qbeg, *qend;
struct loop *base_loop, *target_loop;
edge e;
/* We pass through blocks back-reachable from FROM, testing whether some
of their successors moved to outer loop. It may be necessary to
iterate several times, but it is finite, as we stop unless we move
the basic block up the loop structure. The whole story is a bit
more complicated due to presence of subloops, those are moved using
fix_loop_placement. */
base_loop = from->loop_father;
/* If we are already in the outermost loop, the basic blocks cannot be moved
outside of it. If FROM is the header of the base loop, it cannot be moved
outside of it, either. In both cases, we can end now. */
if (base_loop == current_loops->tree_root
|| from == base_loop->header)
return;
in_queue = sbitmap_alloc (last_basic_block);
sbitmap_zero (in_queue);
SET_BIT (in_queue, from->index);
/* Prevent us from going out of the base_loop. */
SET_BIT (in_queue, base_loop->header->index);
queue = XNEWVEC (basic_block, base_loop->num_nodes + 1);
qtop = queue + base_loop->num_nodes + 1;
qbeg = queue;
qend = queue + 1;
*qbeg = from;
while (qbeg != qend)
{
edge_iterator ei;
from = *qbeg;
qbeg++;
if (qbeg == qtop)
qbeg = queue;
RESET_BIT (in_queue, from->index);
if (from->loop_father->header == from)
{
/* Subloop header, maybe move the loop upward. */
if (!fix_loop_placement (from->loop_father))
continue;
target_loop = loop_outer (from->loop_father);
}
else
{
/* Ordinary basic block. */
if (!fix_bb_placement (from))
continue;
target_loop = from->loop_father;
}
FOR_EACH_EDGE (e, ei, from->succs)
{
if (e->flags & EDGE_IRREDUCIBLE_LOOP)
*irred_invalidated = true;
}
/* Something has changed, insert predecessors into queue. */
FOR_EACH_EDGE (e, ei, from->preds)
{
basic_block pred = e->src;
struct loop *nca;
if (e->flags & EDGE_IRREDUCIBLE_LOOP)
*irred_invalidated = true;
if (TEST_BIT (in_queue, pred->index))
continue;
/* If it is subloop, then it either was not moved, or
the path up the loop tree from base_loop do not contain
it. */
nca = find_common_loop (pred->loop_father, base_loop);
if (pred->loop_father != base_loop
&& (nca == base_loop
|| nca != pred->loop_father))
pred = pred->loop_father->header;
else if (!flow_loop_nested_p (target_loop, pred->loop_father))
{
/* If PRED is already higher in the loop hierarchy than the
TARGET_LOOP to that we moved FROM, the change of the position
of FROM does not affect the position of PRED, so there is no
point in processing it. */
continue;
}
if (TEST_BIT (in_queue, pred->index))
continue;
/* Schedule the basic block. */
*qend = pred;
qend++;
if (qend == qtop)
qend = queue;
SET_BIT (in_queue, pred->index);
}
}
free (in_queue);
free (queue);
} | /* Fix placements of basic blocks inside loop hierarchy stored in loops; i.e.
enforce condition condition stated in description of fix_bb_placement. We
start from basic block FROM that had some of its successors removed, so that
his placement no longer has to be correct, and iteratively fix placement of
its predecessors that may change if placement of FROM changed. Also fix
placement of subloops of FROM->loop_father, that might also be altered due
to this change; the condition for them is similar, except that instead of
successors we consider edges coming out of the loops.
If the changes may invalidate the information about irreducible regions,
IRRED_INVALIDATED is set to true. */ | Fix placements of basic blocks inside loop hierarchy stored in loops; i.e.
enforce condition condition stated in description of fix_bb_placement. We
start from basic block FROM that had some of its successors removed, so that
his placement no longer has to be correct, and iteratively fix placement of
its predecessors that may change if placement of FROM changed. Also fix
placement of subloops of FROM->loop_father, that might also be altered due
to this change; the condition for them is similar, except that instead of
successors we consider edges coming out of the loops.
If the changes may invalidate the information about irreducible regions,
IRRED_INVALIDATED is set to true. | [
"Fix",
"placements",
"of",
"basic",
"blocks",
"inside",
"loop",
"hierarchy",
"stored",
"in",
"loops",
";",
"i",
".",
"e",
".",
"enforce",
"condition",
"condition",
"stated",
"in",
"description",
"of",
"fix_bb_placement",
".",
"We",
"start",
"from",
"basic",
"block",
"FROM",
"that",
"had",
"some",
"of",
"its",
"successors",
"removed",
"so",
"that",
"his",
"placement",
"no",
"longer",
"has",
"to",
"be",
"correct",
"and",
"iteratively",
"fix",
"placement",
"of",
"its",
"predecessors",
"that",
"may",
"change",
"if",
"placement",
"of",
"FROM",
"changed",
".",
"Also",
"fix",
"placement",
"of",
"subloops",
"of",
"FROM",
"-",
">",
"loop_father",
"that",
"might",
"also",
"be",
"altered",
"due",
"to",
"this",
"change",
";",
"the",
"condition",
"for",
"them",
"is",
"similar",
"except",
"that",
"instead",
"of",
"successors",
"we",
"consider",
"edges",
"coming",
"out",
"of",
"the",
"loops",
".",
"If",
"the",
"changes",
"may",
"invalidate",
"the",
"information",
"about",
"irreducible",
"regions",
"IRRED_INVALIDATED",
"is",
"set",
"to",
"true",
"."
] | static void
fix_bb_placements (basic_block from,
bool *irred_invalidated)
{
sbitmap in_queue;
basic_block *queue, *qtop, *qbeg, *qend;
struct loop *base_loop, *target_loop;
edge e;
base_loop = from->loop_father;
if (base_loop == current_loops->tree_root
|| from == base_loop->header)
return;
in_queue = sbitmap_alloc (last_basic_block);
sbitmap_zero (in_queue);
SET_BIT (in_queue, from->index);
SET_BIT (in_queue, base_loop->header->index);
queue = XNEWVEC (basic_block, base_loop->num_nodes + 1);
qtop = queue + base_loop->num_nodes + 1;
qbeg = queue;
qend = queue + 1;
*qbeg = from;
while (qbeg != qend)
{
edge_iterator ei;
from = *qbeg;
qbeg++;
if (qbeg == qtop)
qbeg = queue;
RESET_BIT (in_queue, from->index);
if (from->loop_father->header == from)
{
if (!fix_loop_placement (from->loop_father))
continue;
target_loop = loop_outer (from->loop_father);
}
else
{
if (!fix_bb_placement (from))
continue;
target_loop = from->loop_father;
}
FOR_EACH_EDGE (e, ei, from->succs)
{
if (e->flags & EDGE_IRREDUCIBLE_LOOP)
*irred_invalidated = true;
}
FOR_EACH_EDGE (e, ei, from->preds)
{
basic_block pred = e->src;
struct loop *nca;
if (e->flags & EDGE_IRREDUCIBLE_LOOP)
*irred_invalidated = true;
if (TEST_BIT (in_queue, pred->index))
continue;
nca = find_common_loop (pred->loop_father, base_loop);
if (pred->loop_father != base_loop
&& (nca == base_loop
|| nca != pred->loop_father))
pred = pred->loop_father->header;
else if (!flow_loop_nested_p (target_loop, pred->loop_father))
{
continue;
}
if (TEST_BIT (in_queue, pred->index))
continue;
*qend = pred;
qend++;
if (qend == qtop)
qend = queue;
SET_BIT (in_queue, pred->index);
}
}
free (in_queue);
free (queue);
} | [
"static",
"void",
"fix_bb_placements",
"(",
"basic_block",
"from",
",",
"bool",
"*",
"irred_invalidated",
")",
"{",
"sbitmap",
"in_queue",
";",
"basic_block",
"*",
"queue",
",",
"*",
"qtop",
",",
"*",
"qbeg",
",",
"*",
"qend",
";",
"struct",
"loop",
"*",
"base_loop",
",",
"*",
"target_loop",
";",
"edge",
"e",
";",
"base_loop",
"=",
"from",
"->",
"loop_father",
";",
"if",
"(",
"base_loop",
"==",
"current_loops",
"->",
"tree_root",
"||",
"from",
"==",
"base_loop",
"->",
"header",
")",
"return",
";",
"in_queue",
"=",
"sbitmap_alloc",
"(",
"last_basic_block",
")",
";",
"sbitmap_zero",
"(",
"in_queue",
")",
";",
"SET_BIT",
"(",
"in_queue",
",",
"from",
"->",
"index",
")",
";",
"SET_BIT",
"(",
"in_queue",
",",
"base_loop",
"->",
"header",
"->",
"index",
")",
";",
"queue",
"=",
"XNEWVEC",
"(",
"basic_block",
",",
"base_loop",
"->",
"num_nodes",
"+",
"1",
")",
";",
"qtop",
"=",
"queue",
"+",
"base_loop",
"->",
"num_nodes",
"+",
"1",
";",
"qbeg",
"=",
"queue",
";",
"qend",
"=",
"queue",
"+",
"1",
";",
"*",
"qbeg",
"=",
"from",
";",
"while",
"(",
"qbeg",
"!=",
"qend",
")",
"{",
"edge_iterator",
"ei",
";",
"from",
"=",
"*",
"qbeg",
";",
"qbeg",
"++",
";",
"if",
"(",
"qbeg",
"==",
"qtop",
")",
"qbeg",
"=",
"queue",
";",
"RESET_BIT",
"(",
"in_queue",
",",
"from",
"->",
"index",
")",
";",
"if",
"(",
"from",
"->",
"loop_father",
"->",
"header",
"==",
"from",
")",
"{",
"if",
"(",
"!",
"fix_loop_placement",
"(",
"from",
"->",
"loop_father",
")",
")",
"continue",
";",
"target_loop",
"=",
"loop_outer",
"(",
"from",
"->",
"loop_father",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"fix_bb_placement",
"(",
"from",
")",
")",
"continue",
";",
"target_loop",
"=",
"from",
"->",
"loop_father",
";",
"}",
"FOR_EACH_EDGE",
"(",
"e",
",",
"ei",
",",
"from",
"->",
"succs",
")",
"",
"{",
"if",
"(",
"e",
"->",
"flags",
"&",
"EDGE_IRREDUCIBLE_LOOP",
")",
"*",
"irred_invalidated",
"=",
"true",
";",
"}",
"FOR_EACH_EDGE",
"(",
"e",
",",
"ei",
",",
"from",
"->",
"preds",
")",
"",
"{",
"basic_block",
"pred",
"=",
"e",
"->",
"src",
";",
"struct",
"loop",
"*",
"nca",
";",
"if",
"(",
"e",
"->",
"flags",
"&",
"EDGE_IRREDUCIBLE_LOOP",
")",
"*",
"irred_invalidated",
"=",
"true",
";",
"if",
"(",
"TEST_BIT",
"(",
"in_queue",
",",
"pred",
"->",
"index",
")",
")",
"continue",
";",
"nca",
"=",
"find_common_loop",
"(",
"pred",
"->",
"loop_father",
",",
"base_loop",
")",
";",
"if",
"(",
"pred",
"->",
"loop_father",
"!=",
"base_loop",
"&&",
"(",
"nca",
"==",
"base_loop",
"||",
"nca",
"!=",
"pred",
"->",
"loop_father",
")",
")",
"pred",
"=",
"pred",
"->",
"loop_father",
"->",
"header",
";",
"else",
"if",
"(",
"!",
"flow_loop_nested_p",
"(",
"target_loop",
",",
"pred",
"->",
"loop_father",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"TEST_BIT",
"(",
"in_queue",
",",
"pred",
"->",
"index",
")",
")",
"continue",
";",
"*",
"qend",
"=",
"pred",
";",
"qend",
"++",
";",
"if",
"(",
"qend",
"==",
"qtop",
")",
"qend",
"=",
"queue",
";",
"SET_BIT",
"(",
"in_queue",
",",
"pred",
"->",
"index",
")",
";",
"}",
"}",
"free",
"(",
"in_queue",
")",
";",
"free",
"(",
"queue",
")",
";",
"}"
] | Fix placements of basic blocks inside loop hierarchy stored in loops; i.e. | [
"Fix",
"placements",
"of",
"basic",
"blocks",
"inside",
"loop",
"hierarchy",
"stored",
"in",
"loops",
";",
"i",
".",
"e",
"."
] | [
"/* We pass through blocks back-reachable from FROM, testing whether some\n of their successors moved to outer loop. It may be necessary to\n iterate several times, but it is finite, as we stop unless we move\n the basic block up the loop structure. The whole story is a bit\n more complicated due to presence of subloops, those are moved using\n fix_loop_placement. */",
"/* If we are already in the outermost loop, the basic blocks cannot be moved\n outside of it. If FROM is the header of the base loop, it cannot be moved\n outside of it, either. In both cases, we can end now. */",
"/* Prevent us from going out of the base_loop. */",
"/* Subloop header, maybe move the loop upward. */",
"/* Ordinary basic block. */",
"/* Something has changed, insert predecessors into queue. */",
"/* If it is subloop, then it either was not moved, or\n\t the path up the loop tree from base_loop do not contain\n\t it. */",
"/* If PRED is already higher in the loop hierarchy than the\n\t\t TARGET_LOOP to that we moved FROM, the change of the position\n\t\t of FROM does not affect the position of PRED, so there is no\n\t\t point in processing it. */",
"/* Schedule the basic block. */"
] | [
{
"param": "from",
"type": "basic_block"
},
{
"param": "irred_invalidated",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "from",
"type": "basic_block",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "irred_invalidated",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33bcf4b987279f500c834564b28145b7a5ccb102 | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/cfgloopmanip.c | [
"BSD-3-Clause"
] | C | remove_path | bool | bool
remove_path (edge e)
{
edge ae;
basic_block *rem_bbs, *bord_bbs, from, bb;
VEC (basic_block, heap) *dom_bbs;
int i, nrem, n_bord_bbs;
sbitmap seen;
bool irred_invalidated = false;
edge_iterator ei;
struct loop *l, *f;
if (!can_remove_branch_p (e))
return false;
/* Keep track of whether we need to update information about irreducible
regions. This is the case if the removed area is a part of the
irreducible region, or if the set of basic blocks that belong to a loop
that is inside an irreducible region is changed, or if such a loop is
removed. */
if (e->flags & EDGE_IRREDUCIBLE_LOOP)
irred_invalidated = true;
/* We need to check whether basic blocks are dominated by the edge
e, but we only have basic block dominators. This is easy to
fix -- when e->dest has exactly one predecessor, this corresponds
to blocks dominated by e->dest, if not, split the edge. */
if (!single_pred_p (e->dest))
e = single_pred_edge (split_edge (e));
/* It may happen that by removing path we remove one or more loops
we belong to. In this case first unloop the loops, then proceed
normally. We may assume that e->dest is not a header of any loop,
as it now has exactly one predecessor. */
for (l = e->src->loop_father; loop_outer (l); l = f)
{
f = loop_outer (l);
if (dominated_by_p (CDI_DOMINATORS, l->latch, e->dest))
unloop (l, &irred_invalidated);
}
/* Identify the path. */
nrem = find_path (e, &rem_bbs);
n_bord_bbs = 0;
bord_bbs = XCNEWVEC (basic_block, n_basic_blocks);
seen = sbitmap_alloc (last_basic_block);
sbitmap_zero (seen);
/* Find "border" hexes -- i.e. those with predecessor in removed path. */
for (i = 0; i < nrem; i++)
SET_BIT (seen, rem_bbs[i]->index);
if (!irred_invalidated)
FOR_EACH_EDGE (ae, ei, e->src->succs)
if (ae != e && ae->dest != EXIT_BLOCK_PTR && !TEST_BIT (seen, ae->dest->index)
&& ae->flags & EDGE_IRREDUCIBLE_LOOP)
irred_invalidated = true;
for (i = 0; i < nrem; i++)
{
bb = rem_bbs[i];
FOR_EACH_EDGE (ae, ei, rem_bbs[i]->succs)
if (ae->dest != EXIT_BLOCK_PTR && !TEST_BIT (seen, ae->dest->index))
{
SET_BIT (seen, ae->dest->index);
bord_bbs[n_bord_bbs++] = ae->dest;
if (ae->flags & EDGE_IRREDUCIBLE_LOOP)
irred_invalidated = true;
}
}
/* Remove the path. */
from = e->src;
remove_branch (e);
dom_bbs = NULL;
/* Cancel loops contained in the path. */
for (i = 0; i < nrem; i++)
if (rem_bbs[i]->loop_father->header == rem_bbs[i])
cancel_loop_tree (rem_bbs[i]->loop_father);
remove_bbs (rem_bbs, nrem);
free (rem_bbs);
/* Find blocks whose dominators may be affected. */
sbitmap_zero (seen);
for (i = 0; i < n_bord_bbs; i++)
{
basic_block ldom;
bb = get_immediate_dominator (CDI_DOMINATORS, bord_bbs[i]);
if (TEST_BIT (seen, bb->index))
continue;
SET_BIT (seen, bb->index);
for (ldom = first_dom_son (CDI_DOMINATORS, bb);
ldom;
ldom = next_dom_son (CDI_DOMINATORS, ldom))
if (!dominated_by_p (CDI_DOMINATORS, from, ldom))
VEC_safe_push (basic_block, heap, dom_bbs, ldom);
}
free (seen);
/* Recount dominators. */
iterate_fix_dominators (CDI_DOMINATORS, dom_bbs, true);
VEC_free (basic_block, heap, dom_bbs);
free (bord_bbs);
/* Fix placements of basic blocks inside loops and the placement of
loops in the loop tree. */
fix_bb_placements (from, &irred_invalidated);
fix_loop_placements (from->loop_father, &irred_invalidated);
if (irred_invalidated
&& loops_state_satisfies_p (LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS))
mark_irreducible_loops ();
return true;
} | /* Removes path beginning at edge E, i.e. remove basic blocks dominated by E
and update loop structures and dominators. Return true if we were able
to remove the path, false otherwise (and nothing is affected then). */ | Removes path beginning at edge E, i.e. remove basic blocks dominated by E
and update loop structures and dominators. Return true if we were able
to remove the path, false otherwise (and nothing is affected then). | [
"Removes",
"path",
"beginning",
"at",
"edge",
"E",
"i",
".",
"e",
".",
"remove",
"basic",
"blocks",
"dominated",
"by",
"E",
"and",
"update",
"loop",
"structures",
"and",
"dominators",
".",
"Return",
"true",
"if",
"we",
"were",
"able",
"to",
"remove",
"the",
"path",
"false",
"otherwise",
"(",
"and",
"nothing",
"is",
"affected",
"then",
")",
"."
] | bool
remove_path (edge e)
{
edge ae;
basic_block *rem_bbs, *bord_bbs, from, bb;
VEC (basic_block, heap) *dom_bbs;
int i, nrem, n_bord_bbs;
sbitmap seen;
bool irred_invalidated = false;
edge_iterator ei;
struct loop *l, *f;
if (!can_remove_branch_p (e))
return false;
if (e->flags & EDGE_IRREDUCIBLE_LOOP)
irred_invalidated = true;
if (!single_pred_p (e->dest))
e = single_pred_edge (split_edge (e));
for (l = e->src->loop_father; loop_outer (l); l = f)
{
f = loop_outer (l);
if (dominated_by_p (CDI_DOMINATORS, l->latch, e->dest))
unloop (l, &irred_invalidated);
}
nrem = find_path (e, &rem_bbs);
n_bord_bbs = 0;
bord_bbs = XCNEWVEC (basic_block, n_basic_blocks);
seen = sbitmap_alloc (last_basic_block);
sbitmap_zero (seen);
for (i = 0; i < nrem; i++)
SET_BIT (seen, rem_bbs[i]->index);
if (!irred_invalidated)
FOR_EACH_EDGE (ae, ei, e->src->succs)
if (ae != e && ae->dest != EXIT_BLOCK_PTR && !TEST_BIT (seen, ae->dest->index)
&& ae->flags & EDGE_IRREDUCIBLE_LOOP)
irred_invalidated = true;
for (i = 0; i < nrem; i++)
{
bb = rem_bbs[i];
FOR_EACH_EDGE (ae, ei, rem_bbs[i]->succs)
if (ae->dest != EXIT_BLOCK_PTR && !TEST_BIT (seen, ae->dest->index))
{
SET_BIT (seen, ae->dest->index);
bord_bbs[n_bord_bbs++] = ae->dest;
if (ae->flags & EDGE_IRREDUCIBLE_LOOP)
irred_invalidated = true;
}
}
from = e->src;
remove_branch (e);
dom_bbs = NULL;
for (i = 0; i < nrem; i++)
if (rem_bbs[i]->loop_father->header == rem_bbs[i])
cancel_loop_tree (rem_bbs[i]->loop_father);
remove_bbs (rem_bbs, nrem);
free (rem_bbs);
sbitmap_zero (seen);
for (i = 0; i < n_bord_bbs; i++)
{
basic_block ldom;
bb = get_immediate_dominator (CDI_DOMINATORS, bord_bbs[i]);
if (TEST_BIT (seen, bb->index))
continue;
SET_BIT (seen, bb->index);
for (ldom = first_dom_son (CDI_DOMINATORS, bb);
ldom;
ldom = next_dom_son (CDI_DOMINATORS, ldom))
if (!dominated_by_p (CDI_DOMINATORS, from, ldom))
VEC_safe_push (basic_block, heap, dom_bbs, ldom);
}
free (seen);
iterate_fix_dominators (CDI_DOMINATORS, dom_bbs, true);
VEC_free (basic_block, heap, dom_bbs);
free (bord_bbs);
fix_bb_placements (from, &irred_invalidated);
fix_loop_placements (from->loop_father, &irred_invalidated);
if (irred_invalidated
&& loops_state_satisfies_p (LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS))
mark_irreducible_loops ();
return true;
} | [
"bool",
"remove_path",
"(",
"edge",
"e",
")",
"{",
"edge",
"ae",
";",
"basic_block",
"*",
"rem_bbs",
",",
"*",
"bord_bbs",
",",
"from",
",",
"bb",
";",
"VEC",
"(",
"basic_block",
",",
"heap",
")",
"*",
"dom_bbs",
";",
"int",
"i",
",",
"nrem",
",",
"n_bord_bbs",
";",
"sbitmap",
"seen",
";",
"bool",
"irred_invalidated",
"=",
"false",
";",
"edge_iterator",
"ei",
";",
"struct",
"loop",
"*",
"l",
",",
"*",
"f",
";",
"if",
"(",
"!",
"can_remove_branch_p",
"(",
"e",
")",
")",
"return",
"false",
";",
"if",
"(",
"e",
"->",
"flags",
"&",
"EDGE_IRREDUCIBLE_LOOP",
")",
"irred_invalidated",
"=",
"true",
";",
"if",
"(",
"!",
"single_pred_p",
"(",
"e",
"->",
"dest",
")",
")",
"e",
"=",
"single_pred_edge",
"(",
"split_edge",
"(",
"e",
")",
")",
";",
"for",
"(",
"l",
"=",
"e",
"->",
"src",
"->",
"loop_father",
";",
"loop_outer",
"(",
"l",
")",
";",
"l",
"=",
"f",
")",
"{",
"f",
"=",
"loop_outer",
"(",
"l",
")",
";",
"if",
"(",
"dominated_by_p",
"(",
"CDI_DOMINATORS",
",",
"l",
"->",
"latch",
",",
"e",
"->",
"dest",
")",
")",
"unloop",
"(",
"l",
",",
"&",
"irred_invalidated",
")",
";",
"}",
"nrem",
"=",
"find_path",
"(",
"e",
",",
"&",
"rem_bbs",
")",
";",
"n_bord_bbs",
"=",
"0",
";",
"bord_bbs",
"=",
"XCNEWVEC",
"(",
"basic_block",
",",
"n_basic_blocks",
")",
";",
"seen",
"=",
"sbitmap_alloc",
"(",
"last_basic_block",
")",
";",
"sbitmap_zero",
"(",
"seen",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"nrem",
";",
"i",
"++",
")",
"SET_BIT",
"(",
"seen",
",",
"rem_bbs",
"[",
"i",
"]",
"->",
"index",
")",
";",
"if",
"(",
"!",
"irred_invalidated",
")",
"FOR_EACH_EDGE",
"(",
"ae",
",",
"ei",
",",
"e",
"->",
"src",
"->",
"succs",
")",
"",
"if",
"(",
"ae",
"!=",
"e",
"&&",
"ae",
"->",
"dest",
"!=",
"EXIT_BLOCK_PTR",
"&&",
"!",
"TEST_BIT",
"(",
"seen",
",",
"ae",
"->",
"dest",
"->",
"index",
")",
"&&",
"ae",
"->",
"flags",
"&",
"EDGE_IRREDUCIBLE_LOOP",
")",
"irred_invalidated",
"=",
"true",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"nrem",
";",
"i",
"++",
")",
"{",
"bb",
"=",
"rem_bbs",
"[",
"i",
"]",
";",
"FOR_EACH_EDGE",
"(",
"ae",
",",
"ei",
",",
"rem_bbs",
"[",
"i",
"]",
"->",
"succs",
")",
"",
"if",
"(",
"ae",
"->",
"dest",
"!=",
"EXIT_BLOCK_PTR",
"&&",
"!",
"TEST_BIT",
"(",
"seen",
",",
"ae",
"->",
"dest",
"->",
"index",
")",
")",
"{",
"SET_BIT",
"(",
"seen",
",",
"ae",
"->",
"dest",
"->",
"index",
")",
";",
"bord_bbs",
"[",
"n_bord_bbs",
"++",
"]",
"=",
"ae",
"->",
"dest",
";",
"if",
"(",
"ae",
"->",
"flags",
"&",
"EDGE_IRREDUCIBLE_LOOP",
")",
"irred_invalidated",
"=",
"true",
";",
"}",
"}",
"from",
"=",
"e",
"->",
"src",
";",
"remove_branch",
"(",
"e",
")",
";",
"dom_bbs",
"=",
"NULL",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"nrem",
";",
"i",
"++",
")",
"if",
"(",
"rem_bbs",
"[",
"i",
"]",
"->",
"loop_father",
"->",
"header",
"==",
"rem_bbs",
"[",
"i",
"]",
")",
"cancel_loop_tree",
"(",
"rem_bbs",
"[",
"i",
"]",
"->",
"loop_father",
")",
";",
"remove_bbs",
"(",
"rem_bbs",
",",
"nrem",
")",
";",
"free",
"(",
"rem_bbs",
")",
";",
"sbitmap_zero",
"(",
"seen",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"n_bord_bbs",
";",
"i",
"++",
")",
"{",
"basic_block",
"ldom",
";",
"bb",
"=",
"get_immediate_dominator",
"(",
"CDI_DOMINATORS",
",",
"bord_bbs",
"[",
"i",
"]",
")",
";",
"if",
"(",
"TEST_BIT",
"(",
"seen",
",",
"bb",
"->",
"index",
")",
")",
"continue",
";",
"SET_BIT",
"(",
"seen",
",",
"bb",
"->",
"index",
")",
";",
"for",
"(",
"ldom",
"=",
"first_dom_son",
"(",
"CDI_DOMINATORS",
",",
"bb",
")",
";",
"ldom",
";",
"ldom",
"=",
"next_dom_son",
"(",
"CDI_DOMINATORS",
",",
"ldom",
")",
")",
"if",
"(",
"!",
"dominated_by_p",
"(",
"CDI_DOMINATORS",
",",
"from",
",",
"ldom",
")",
")",
"VEC_safe_push",
"(",
"basic_block",
",",
"heap",
",",
"dom_bbs",
",",
"ldom",
")",
";",
"}",
"free",
"(",
"seen",
")",
";",
"iterate_fix_dominators",
"(",
"CDI_DOMINATORS",
",",
"dom_bbs",
",",
"true",
")",
";",
"VEC_free",
"(",
"basic_block",
",",
"heap",
",",
"dom_bbs",
")",
";",
"free",
"(",
"bord_bbs",
")",
";",
"fix_bb_placements",
"(",
"from",
",",
"&",
"irred_invalidated",
")",
";",
"fix_loop_placements",
"(",
"from",
"->",
"loop_father",
",",
"&",
"irred_invalidated",
")",
";",
"if",
"(",
"irred_invalidated",
"&&",
"loops_state_satisfies_p",
"(",
"LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS",
")",
")",
"mark_irreducible_loops",
"(",
")",
";",
"return",
"true",
";",
"}"
] | Removes path beginning at edge E, i.e. | [
"Removes",
"path",
"beginning",
"at",
"edge",
"E",
"i",
".",
"e",
"."
] | [
"/* Keep track of whether we need to update information about irreducible\n regions. This is the case if the removed area is a part of the\n irreducible region, or if the set of basic blocks that belong to a loop\n that is inside an irreducible region is changed, or if such a loop is\n removed. */",
"/* We need to check whether basic blocks are dominated by the edge\n e, but we only have basic block dominators. This is easy to\n fix -- when e->dest has exactly one predecessor, this corresponds\n to blocks dominated by e->dest, if not, split the edge. */",
"/* It may happen that by removing path we remove one or more loops\n we belong to. In this case first unloop the loops, then proceed\n normally. We may assume that e->dest is not a header of any loop,\n as it now has exactly one predecessor. */",
"/* Identify the path. */",
"/* Find \"border\" hexes -- i.e. those with predecessor in removed path. */",
"/* Remove the path. */",
"/* Cancel loops contained in the path. */",
"/* Find blocks whose dominators may be affected. */",
"/* Recount dominators. */",
"/* Fix placements of basic blocks inside loops and the placement of\n loops in the loop tree. */"
] | [
{
"param": "e",
"type": "edge"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "e",
"type": "edge",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33bcf4b987279f500c834564b28145b7a5ccb102 | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/cfgloopmanip.c | [
"BSD-3-Clause"
] | C | place_new_loop | void | static void
place_new_loop (struct loop *loop)
{
loop->num = number_of_loops ();
VEC_safe_push (loop_p, gc, current_loops->larray, loop);
} | /* Creates place for a new LOOP in loops structure. */ | Creates place for a new LOOP in loops structure. | [
"Creates",
"place",
"for",
"a",
"new",
"LOOP",
"in",
"loops",
"structure",
"."
] | static void
place_new_loop (struct loop *loop)
{
loop->num = number_of_loops ();
VEC_safe_push (loop_p, gc, current_loops->larray, loop);
} | [
"static",
"void",
"place_new_loop",
"(",
"struct",
"loop",
"*",
"loop",
")",
"{",
"loop",
"->",
"num",
"=",
"number_of_loops",
"(",
")",
";",
"VEC_safe_push",
"(",
"loop_p",
",",
"gc",
",",
"current_loops",
"->",
"larray",
",",
"loop",
")",
";",
"}"
] | Creates place for a new LOOP in loops structure. | [
"Creates",
"place",
"for",
"a",
"new",
"LOOP",
"in",
"loops",
"structure",
"."
] | [] | [
{
"param": "loop",
"type": "struct loop"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "loop",
"type": "struct loop",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33bcf4b987279f500c834564b28145b7a5ccb102 | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/cfgloopmanip.c | [
"BSD-3-Clause"
] | C | add_loop | void | void
add_loop (struct loop *loop, struct loop *outer)
{
basic_block *bbs;
int i, n;
struct loop *subloop;
edge e;
edge_iterator ei;
/* Add it to loop structure. */
place_new_loop (loop);
flow_loop_tree_node_add (outer, loop);
/* Find its nodes. */
bbs = XNEWVEC (basic_block, n_basic_blocks);
n = get_loop_body_with_size (loop, bbs, n_basic_blocks);
for (i = 0; i < n; i++)
{
if (bbs[i]->loop_father == outer)
{
remove_bb_from_loops (bbs[i]);
add_bb_to_loop (bbs[i], loop);
continue;
}
loop->num_nodes++;
/* If we find a direct subloop of OUTER, move it to LOOP. */
subloop = bbs[i]->loop_father;
if (loop_outer (subloop) == outer
&& subloop->header == bbs[i])
{
flow_loop_tree_node_remove (subloop);
flow_loop_tree_node_add (loop, subloop);
}
}
/* Update the information about loop exit edges. */
for (i = 0; i < n; i++)
{
FOR_EACH_EDGE (e, ei, bbs[i]->succs)
{
rescan_loop_exit (e, false, false);
}
}
free (bbs);
} | /* Given LOOP structure with filled header and latch, find the body of the
corresponding loop and add it to loops tree. Insert the LOOP as a son of
outer. */ | Given LOOP structure with filled header and latch, find the body of the
corresponding loop and add it to loops tree. Insert the LOOP as a son of
outer. | [
"Given",
"LOOP",
"structure",
"with",
"filled",
"header",
"and",
"latch",
"find",
"the",
"body",
"of",
"the",
"corresponding",
"loop",
"and",
"add",
"it",
"to",
"loops",
"tree",
".",
"Insert",
"the",
"LOOP",
"as",
"a",
"son",
"of",
"outer",
"."
] | void
add_loop (struct loop *loop, struct loop *outer)
{
basic_block *bbs;
int i, n;
struct loop *subloop;
edge e;
edge_iterator ei;
place_new_loop (loop);
flow_loop_tree_node_add (outer, loop);
bbs = XNEWVEC (basic_block, n_basic_blocks);
n = get_loop_body_with_size (loop, bbs, n_basic_blocks);
for (i = 0; i < n; i++)
{
if (bbs[i]->loop_father == outer)
{
remove_bb_from_loops (bbs[i]);
add_bb_to_loop (bbs[i], loop);
continue;
}
loop->num_nodes++;
subloop = bbs[i]->loop_father;
if (loop_outer (subloop) == outer
&& subloop->header == bbs[i])
{
flow_loop_tree_node_remove (subloop);
flow_loop_tree_node_add (loop, subloop);
}
}
for (i = 0; i < n; i++)
{
FOR_EACH_EDGE (e, ei, bbs[i]->succs)
{
rescan_loop_exit (e, false, false);
}
}
free (bbs);
} | [
"void",
"add_loop",
"(",
"struct",
"loop",
"*",
"loop",
",",
"struct",
"loop",
"*",
"outer",
")",
"{",
"basic_block",
"*",
"bbs",
";",
"int",
"i",
",",
"n",
";",
"struct",
"loop",
"*",
"subloop",
";",
"edge",
"e",
";",
"edge_iterator",
"ei",
";",
"place_new_loop",
"(",
"loop",
")",
";",
"flow_loop_tree_node_add",
"(",
"outer",
",",
"loop",
")",
";",
"bbs",
"=",
"XNEWVEC",
"(",
"basic_block",
",",
"n_basic_blocks",
")",
";",
"n",
"=",
"get_loop_body_with_size",
"(",
"loop",
",",
"bbs",
",",
"n_basic_blocks",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"if",
"(",
"bbs",
"[",
"i",
"]",
"->",
"loop_father",
"==",
"outer",
")",
"{",
"remove_bb_from_loops",
"(",
"bbs",
"[",
"i",
"]",
")",
";",
"add_bb_to_loop",
"(",
"bbs",
"[",
"i",
"]",
",",
"loop",
")",
";",
"continue",
";",
"}",
"loop",
"->",
"num_nodes",
"++",
";",
"subloop",
"=",
"bbs",
"[",
"i",
"]",
"->",
"loop_father",
";",
"if",
"(",
"loop_outer",
"(",
"subloop",
")",
"==",
"outer",
"&&",
"subloop",
"->",
"header",
"==",
"bbs",
"[",
"i",
"]",
")",
"{",
"flow_loop_tree_node_remove",
"(",
"subloop",
")",
";",
"flow_loop_tree_node_add",
"(",
"loop",
",",
"subloop",
")",
";",
"}",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"FOR_EACH_EDGE",
"(",
"e",
",",
"ei",
",",
"bbs",
"[",
"i",
"]",
"->",
"succs",
")",
"",
"{",
"rescan_loop_exit",
"(",
"e",
",",
"false",
",",
"false",
")",
";",
"}",
"}",
"free",
"(",
"bbs",
")",
";",
"}"
] | Given LOOP structure with filled header and latch, find the body of the
corresponding loop and add it to loops tree. | [
"Given",
"LOOP",
"structure",
"with",
"filled",
"header",
"and",
"latch",
"find",
"the",
"body",
"of",
"the",
"corresponding",
"loop",
"and",
"add",
"it",
"to",
"loops",
"tree",
"."
] | [
"/* Add it to loop structure. */",
"/* Find its nodes. */",
"/* If we find a direct subloop of OUTER, move it to LOOP. */",
"/* Update the information about loop exit edges. */"
] | [
{
"param": "loop",
"type": "struct loop"
},
{
"param": "outer",
"type": "struct loop"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "loop",
"type": "struct loop",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "outer",
"type": "struct loop",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33bcf4b987279f500c834564b28145b7a5ccb102 | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/cfgloopmanip.c | [
"BSD-3-Clause"
] | C | scale_loop_frequencies | void | void
scale_loop_frequencies (struct loop *loop, int num, int den)
{
basic_block *bbs;
bbs = get_loop_body (loop);
scale_bbs_frequencies_int (bbs, loop->num_nodes, num, den);
free (bbs);
} | /* Multiply all frequencies in LOOP by NUM/DEN. */ | Multiply all frequencies in LOOP by NUM/DEN. | [
"Multiply",
"all",
"frequencies",
"in",
"LOOP",
"by",
"NUM",
"/",
"DEN",
"."
] | void
scale_loop_frequencies (struct loop *loop, int num, int den)
{
basic_block *bbs;
bbs = get_loop_body (loop);
scale_bbs_frequencies_int (bbs, loop->num_nodes, num, den);
free (bbs);
} | [
"void",
"scale_loop_frequencies",
"(",
"struct",
"loop",
"*",
"loop",
",",
"int",
"num",
",",
"int",
"den",
")",
"{",
"basic_block",
"*",
"bbs",
";",
"bbs",
"=",
"get_loop_body",
"(",
"loop",
")",
";",
"scale_bbs_frequencies_int",
"(",
"bbs",
",",
"loop",
"->",
"num_nodes",
",",
"num",
",",
"den",
")",
";",
"free",
"(",
"bbs",
")",
";",
"}"
] | Multiply all frequencies in LOOP by NUM/DEN. | [
"Multiply",
"all",
"frequencies",
"in",
"LOOP",
"by",
"NUM",
"/",
"DEN",
"."
] | [] | [
{
"param": "loop",
"type": "struct loop"
},
{
"param": "num",
"type": "int"
},
{
"param": "den",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "loop",
"type": "struct loop",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "num",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "den",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33bcf4b987279f500c834564b28145b7a5ccb102 | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/cfgloopmanip.c | [
"BSD-3-Clause"
] | C | update_dominators_in_loop | void | static void
update_dominators_in_loop (struct loop *loop)
{
VEC (basic_block, heap) *dom_bbs = NULL;
sbitmap seen;
basic_block *body;
unsigned i;
seen = sbitmap_alloc (last_basic_block);
sbitmap_zero (seen);
body = get_loop_body (loop);
for (i = 0; i < loop->num_nodes; i++)
SET_BIT (seen, body[i]->index);
for (i = 0; i < loop->num_nodes; i++)
{
basic_block ldom;
for (ldom = first_dom_son (CDI_DOMINATORS, body[i]);
ldom;
ldom = next_dom_son (CDI_DOMINATORS, ldom))
if (!TEST_BIT (seen, ldom->index))
{
SET_BIT (seen, ldom->index);
VEC_safe_push (basic_block, heap, dom_bbs, ldom);
}
}
iterate_fix_dominators (CDI_DOMINATORS, dom_bbs, false);
free (body);
free (seen);
VEC_free (basic_block, heap, dom_bbs);
} | /* Recompute dominance information for basic blocks outside LOOP. */ | Recompute dominance information for basic blocks outside LOOP. | [
"Recompute",
"dominance",
"information",
"for",
"basic",
"blocks",
"outside",
"LOOP",
"."
] | static void
update_dominators_in_loop (struct loop *loop)
{
VEC (basic_block, heap) *dom_bbs = NULL;
sbitmap seen;
basic_block *body;
unsigned i;
seen = sbitmap_alloc (last_basic_block);
sbitmap_zero (seen);
body = get_loop_body (loop);
for (i = 0; i < loop->num_nodes; i++)
SET_BIT (seen, body[i]->index);
for (i = 0; i < loop->num_nodes; i++)
{
basic_block ldom;
for (ldom = first_dom_son (CDI_DOMINATORS, body[i]);
ldom;
ldom = next_dom_son (CDI_DOMINATORS, ldom))
if (!TEST_BIT (seen, ldom->index))
{
SET_BIT (seen, ldom->index);
VEC_safe_push (basic_block, heap, dom_bbs, ldom);
}
}
iterate_fix_dominators (CDI_DOMINATORS, dom_bbs, false);
free (body);
free (seen);
VEC_free (basic_block, heap, dom_bbs);
} | [
"static",
"void",
"update_dominators_in_loop",
"(",
"struct",
"loop",
"*",
"loop",
")",
"{",
"VEC",
"(",
"basic_block",
",",
"heap",
")",
"*",
"dom_bbs",
"=",
"NULL",
";",
"sbitmap",
"seen",
";",
"basic_block",
"*",
"body",
";",
"unsigned",
"i",
";",
"seen",
"=",
"sbitmap_alloc",
"(",
"last_basic_block",
")",
";",
"sbitmap_zero",
"(",
"seen",
")",
";",
"body",
"=",
"get_loop_body",
"(",
"loop",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"loop",
"->",
"num_nodes",
";",
"i",
"++",
")",
"SET_BIT",
"(",
"seen",
",",
"body",
"[",
"i",
"]",
"->",
"index",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"loop",
"->",
"num_nodes",
";",
"i",
"++",
")",
"{",
"basic_block",
"ldom",
";",
"for",
"(",
"ldom",
"=",
"first_dom_son",
"(",
"CDI_DOMINATORS",
",",
"body",
"[",
"i",
"]",
")",
";",
"ldom",
";",
"ldom",
"=",
"next_dom_son",
"(",
"CDI_DOMINATORS",
",",
"ldom",
")",
")",
"if",
"(",
"!",
"TEST_BIT",
"(",
"seen",
",",
"ldom",
"->",
"index",
")",
")",
"{",
"SET_BIT",
"(",
"seen",
",",
"ldom",
"->",
"index",
")",
";",
"VEC_safe_push",
"(",
"basic_block",
",",
"heap",
",",
"dom_bbs",
",",
"ldom",
")",
";",
"}",
"}",
"iterate_fix_dominators",
"(",
"CDI_DOMINATORS",
",",
"dom_bbs",
",",
"false",
")",
";",
"free",
"(",
"body",
")",
";",
"free",
"(",
"seen",
")",
";",
"VEC_free",
"(",
"basic_block",
",",
"heap",
",",
"dom_bbs",
")",
";",
"}"
] | Recompute dominance information for basic blocks outside LOOP. | [
"Recompute",
"dominance",
"information",
"for",
"basic",
"blocks",
"outside",
"LOOP",
"."
] | [] | [
{
"param": "loop",
"type": "struct loop"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "loop",
"type": "struct loop",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33bcf4b987279f500c834564b28145b7a5ccb102 | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/cfgloopmanip.c | [
"BSD-3-Clause"
] | C | create_empty_if_region_on_edge | edge | edge
create_empty_if_region_on_edge (edge entry_edge, tree condition)
{
basic_block cond_bb, true_bb, false_bb, join_bb;
edge e_true, e_false, exit_edge;
gimple cond_stmt;
tree simple_cond;
gimple_stmt_iterator gsi;
cond_bb = split_edge (entry_edge);
/* Insert condition in cond_bb. */
gsi = gsi_last_bb (cond_bb);
simple_cond =
force_gimple_operand_gsi (&gsi, condition, true, NULL,
false, GSI_NEW_STMT);
cond_stmt = gimple_build_cond_from_tree (simple_cond, NULL_TREE, NULL_TREE);
gsi = gsi_last_bb (cond_bb);
gsi_insert_after (&gsi, cond_stmt, GSI_NEW_STMT);
join_bb = split_edge (single_succ_edge (cond_bb));
e_true = single_succ_edge (cond_bb);
true_bb = split_edge (e_true);
e_false = make_edge (cond_bb, join_bb, 0);
false_bb = split_edge (e_false);
e_true->flags &= ~EDGE_FALLTHRU;
e_true->flags |= EDGE_TRUE_VALUE;
e_false->flags &= ~EDGE_FALLTHRU;
e_false->flags |= EDGE_FALSE_VALUE;
set_immediate_dominator (CDI_DOMINATORS, cond_bb, entry_edge->src);
set_immediate_dominator (CDI_DOMINATORS, true_bb, cond_bb);
set_immediate_dominator (CDI_DOMINATORS, false_bb, cond_bb);
set_immediate_dominator (CDI_DOMINATORS, join_bb, cond_bb);
exit_edge = single_succ_edge (join_bb);
if (single_pred_p (exit_edge->dest))
set_immediate_dominator (CDI_DOMINATORS, exit_edge->dest, join_bb);
return exit_edge;
} | /* Creates an if region as shown above. CONDITION is used to create
the test for the if.
|
| ------------- -------------
| | pred_bb | | pred_bb |
| ------------- -------------
| | |
| | | ENTRY_EDGE
| | ENTRY_EDGE V
| | ====> -------------
| | | cond_bb |
| | | CONDITION |
| | -------------
| V / \
| ------------- e_false / \ e_true
| | succ_bb | V V
| ------------- ----------- -----------
| | false_bb | | true_bb |
| ----------- -----------
| \ /
| \ /
| V V
| -------------
| | join_bb |
| -------------
| | exit_edge (result)
| V
| -----------
| | succ_bb |
| -----------
|
*/ | Creates an if region as shown above. CONDITION is used to create
the test for the if.
| [
"Creates",
"an",
"if",
"region",
"as",
"shown",
"above",
".",
"CONDITION",
"is",
"used",
"to",
"create",
"the",
"test",
"for",
"the",
"if",
"."
] | edge
create_empty_if_region_on_edge (edge entry_edge, tree condition)
{
basic_block cond_bb, true_bb, false_bb, join_bb;
edge e_true, e_false, exit_edge;
gimple cond_stmt;
tree simple_cond;
gimple_stmt_iterator gsi;
cond_bb = split_edge (entry_edge);
gsi = gsi_last_bb (cond_bb);
simple_cond =
force_gimple_operand_gsi (&gsi, condition, true, NULL,
false, GSI_NEW_STMT);
cond_stmt = gimple_build_cond_from_tree (simple_cond, NULL_TREE, NULL_TREE);
gsi = gsi_last_bb (cond_bb);
gsi_insert_after (&gsi, cond_stmt, GSI_NEW_STMT);
join_bb = split_edge (single_succ_edge (cond_bb));
e_true = single_succ_edge (cond_bb);
true_bb = split_edge (e_true);
e_false = make_edge (cond_bb, join_bb, 0);
false_bb = split_edge (e_false);
e_true->flags &= ~EDGE_FALLTHRU;
e_true->flags |= EDGE_TRUE_VALUE;
e_false->flags &= ~EDGE_FALLTHRU;
e_false->flags |= EDGE_FALSE_VALUE;
set_immediate_dominator (CDI_DOMINATORS, cond_bb, entry_edge->src);
set_immediate_dominator (CDI_DOMINATORS, true_bb, cond_bb);
set_immediate_dominator (CDI_DOMINATORS, false_bb, cond_bb);
set_immediate_dominator (CDI_DOMINATORS, join_bb, cond_bb);
exit_edge = single_succ_edge (join_bb);
if (single_pred_p (exit_edge->dest))
set_immediate_dominator (CDI_DOMINATORS, exit_edge->dest, join_bb);
return exit_edge;
} | [
"edge",
"create_empty_if_region_on_edge",
"(",
"edge",
"entry_edge",
",",
"tree",
"condition",
")",
"{",
"basic_block",
"cond_bb",
",",
"true_bb",
",",
"false_bb",
",",
"join_bb",
";",
"edge",
"e_true",
",",
"e_false",
",",
"exit_edge",
";",
"gimple",
"cond_stmt",
";",
"tree",
"simple_cond",
";",
"gimple_stmt_iterator",
"gsi",
";",
"cond_bb",
"=",
"split_edge",
"(",
"entry_edge",
")",
";",
"gsi",
"=",
"gsi_last_bb",
"(",
"cond_bb",
")",
";",
"simple_cond",
"=",
"force_gimple_operand_gsi",
"(",
"&",
"gsi",
",",
"condition",
",",
"true",
",",
"NULL",
",",
"false",
",",
"GSI_NEW_STMT",
")",
";",
"cond_stmt",
"=",
"gimple_build_cond_from_tree",
"(",
"simple_cond",
",",
"NULL_TREE",
",",
"NULL_TREE",
")",
";",
"gsi",
"=",
"gsi_last_bb",
"(",
"cond_bb",
")",
";",
"gsi_insert_after",
"(",
"&",
"gsi",
",",
"cond_stmt",
",",
"GSI_NEW_STMT",
")",
";",
"join_bb",
"=",
"split_edge",
"(",
"single_succ_edge",
"(",
"cond_bb",
")",
")",
";",
"e_true",
"=",
"single_succ_edge",
"(",
"cond_bb",
")",
";",
"true_bb",
"=",
"split_edge",
"(",
"e_true",
")",
";",
"e_false",
"=",
"make_edge",
"(",
"cond_bb",
",",
"join_bb",
",",
"0",
")",
";",
"false_bb",
"=",
"split_edge",
"(",
"e_false",
")",
";",
"e_true",
"->",
"flags",
"&=",
"~",
"EDGE_FALLTHRU",
";",
"e_true",
"->",
"flags",
"|=",
"EDGE_TRUE_VALUE",
";",
"e_false",
"->",
"flags",
"&=",
"~",
"EDGE_FALLTHRU",
";",
"e_false",
"->",
"flags",
"|=",
"EDGE_FALSE_VALUE",
";",
"set_immediate_dominator",
"(",
"CDI_DOMINATORS",
",",
"cond_bb",
",",
"entry_edge",
"->",
"src",
")",
";",
"set_immediate_dominator",
"(",
"CDI_DOMINATORS",
",",
"true_bb",
",",
"cond_bb",
")",
";",
"set_immediate_dominator",
"(",
"CDI_DOMINATORS",
",",
"false_bb",
",",
"cond_bb",
")",
";",
"set_immediate_dominator",
"(",
"CDI_DOMINATORS",
",",
"join_bb",
",",
"cond_bb",
")",
";",
"exit_edge",
"=",
"single_succ_edge",
"(",
"join_bb",
")",
";",
"if",
"(",
"single_pred_p",
"(",
"exit_edge",
"->",
"dest",
")",
")",
"set_immediate_dominator",
"(",
"CDI_DOMINATORS",
",",
"exit_edge",
"->",
"dest",
",",
"join_bb",
")",
";",
"return",
"exit_edge",
";",
"}"
] | Creates an if region as shown above. | [
"Creates",
"an",
"if",
"region",
"as",
"shown",
"above",
"."
] | [
"/* Insert condition in cond_bb. */"
] | [
{
"param": "entry_edge",
"type": "edge"
},
{
"param": "condition",
"type": "tree"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "entry_edge",
"type": "edge",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "condition",
"type": "tree",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33bcf4b987279f500c834564b28145b7a5ccb102 | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/cfgloopmanip.c | [
"BSD-3-Clause"
] | C | create_empty_loop_on_edge | null | struct loop *
create_empty_loop_on_edge (edge entry_edge,
tree initial_value,
tree stride, tree upper_bound,
tree iv,
tree *iv_before,
tree *iv_after,
struct loop *outer)
{
basic_block loop_header, loop_latch, succ_bb, pred_bb;
struct loop *loop;
gimple_stmt_iterator gsi;
gimple_seq stmts;
gimple cond_expr;
tree exit_test;
edge exit_e;
int prob;
gcc_assert (entry_edge && initial_value && stride && upper_bound && iv);
/* Create header, latch and wire up the loop. */
pred_bb = entry_edge->src;
loop_header = split_edge (entry_edge);
loop_latch = split_edge (single_succ_edge (loop_header));
succ_bb = single_succ (loop_latch);
make_edge (loop_header, succ_bb, 0);
redirect_edge_succ_nodup (single_succ_edge (loop_latch), loop_header);
/* Set immediate dominator information. */
set_immediate_dominator (CDI_DOMINATORS, loop_header, pred_bb);
set_immediate_dominator (CDI_DOMINATORS, loop_latch, loop_header);
set_immediate_dominator (CDI_DOMINATORS, succ_bb, loop_header);
/* Initialize a loop structure and put it in a loop hierarchy. */
loop = alloc_loop ();
loop->header = loop_header;
loop->latch = loop_latch;
add_loop (loop, outer);
/* TODO: Fix frequencies and counts. */
prob = REG_BR_PROB_BASE / 2;
scale_loop_frequencies (loop, REG_BR_PROB_BASE - prob, REG_BR_PROB_BASE);
/* Update dominators. */
update_dominators_in_loop (loop);
/* Modify edge flags. */
exit_e = single_exit (loop);
exit_e->flags = EDGE_LOOP_EXIT | EDGE_FALSE_VALUE;
single_pred_edge (loop_latch)->flags = EDGE_TRUE_VALUE;
/* Construct IV code in loop. */
initial_value = force_gimple_operand (initial_value, &stmts, true, iv);
if (stmts)
{
gsi_insert_seq_on_edge (loop_preheader_edge (loop), stmts);
gsi_commit_edge_inserts ();
}
upper_bound = force_gimple_operand (upper_bound, &stmts, true, NULL);
if (stmts)
{
gsi_insert_seq_on_edge (loop_preheader_edge (loop), stmts);
gsi_commit_edge_inserts ();
}
gsi = gsi_last_bb (loop_header);
create_iv (initial_value, stride, iv, loop, &gsi, false,
iv_before, iv_after);
/* Insert loop exit condition. */
cond_expr = gimple_build_cond
(LT_EXPR, *iv_before, upper_bound, NULL_TREE, NULL_TREE);
exit_test = gimple_cond_lhs (cond_expr);
exit_test = force_gimple_operand_gsi (&gsi, exit_test, true, NULL,
false, GSI_NEW_STMT);
gimple_cond_set_lhs (cond_expr, exit_test);
gsi = gsi_last_bb (exit_e->src);
gsi_insert_after (&gsi, cond_expr, GSI_NEW_STMT);
split_block_after_labels (loop_header);
return loop;
} | /* create_empty_loop_on_edge
|
| - pred_bb - ------ pred_bb ------
| | | | iv0 = initial_value |
| -----|----- ---------|-----------
| | ______ | entry_edge
| | entry_edge / | |
| | ====> | -V---V- loop_header -------------
| V | | iv_before = phi (iv0, iv_after) |
| - succ_bb - | ---|-----------------------------
| | | | |
| ----------- | ---V--- loop_body ---------------
| | | iv_after = iv_before + stride |
| | | if (iv_before < upper_bound) |
| | ---|--------------\--------------
| | | \ exit_e
| | V \
| | - loop_latch - V- succ_bb -
| | | | | |
| | /------------- -----------
| \ ___ /
Creates an empty loop as shown above, the IV_BEFORE is the SSA_NAME
that is used before the increment of IV. IV_BEFORE should be used for
adding code to the body that uses the IV. OUTER is the outer loop in
which the new loop should be inserted.
Both INITIAL_VALUE and UPPER_BOUND expressions are gimplified and
inserted on the loop entry edge. This implies that this function
should be used only when the UPPER_BOUND expression is a loop
invariant. */ |
Creates an empty loop as shown above, the IV_BEFORE is the SSA_NAME
that is used before the increment of IV. IV_BEFORE should be used for
adding code to the body that uses the IV. OUTER is the outer loop in
which the new loop should be inserted.
Both INITIAL_VALUE and UPPER_BOUND expressions are gimplified and
inserted on the loop entry edge. This implies that this function
should be used only when the UPPER_BOUND expression is a loop
invariant. | [
"Creates",
"an",
"empty",
"loop",
"as",
"shown",
"above",
"the",
"IV_BEFORE",
"is",
"the",
"SSA_NAME",
"that",
"is",
"used",
"before",
"the",
"increment",
"of",
"IV",
".",
"IV_BEFORE",
"should",
"be",
"used",
"for",
"adding",
"code",
"to",
"the",
"body",
"that",
"uses",
"the",
"IV",
".",
"OUTER",
"is",
"the",
"outer",
"loop",
"in",
"which",
"the",
"new",
"loop",
"should",
"be",
"inserted",
".",
"Both",
"INITIAL_VALUE",
"and",
"UPPER_BOUND",
"expressions",
"are",
"gimplified",
"and",
"inserted",
"on",
"the",
"loop",
"entry",
"edge",
".",
"This",
"implies",
"that",
"this",
"function",
"should",
"be",
"used",
"only",
"when",
"the",
"UPPER_BOUND",
"expression",
"is",
"a",
"loop",
"invariant",
"."
] | struct loop *
create_empty_loop_on_edge (edge entry_edge,
tree initial_value,
tree stride, tree upper_bound,
tree iv,
tree *iv_before,
tree *iv_after,
struct loop *outer)
{
basic_block loop_header, loop_latch, succ_bb, pred_bb;
struct loop *loop;
gimple_stmt_iterator gsi;
gimple_seq stmts;
gimple cond_expr;
tree exit_test;
edge exit_e;
int prob;
gcc_assert (entry_edge && initial_value && stride && upper_bound && iv);
pred_bb = entry_edge->src;
loop_header = split_edge (entry_edge);
loop_latch = split_edge (single_succ_edge (loop_header));
succ_bb = single_succ (loop_latch);
make_edge (loop_header, succ_bb, 0);
redirect_edge_succ_nodup (single_succ_edge (loop_latch), loop_header);
set_immediate_dominator (CDI_DOMINATORS, loop_header, pred_bb);
set_immediate_dominator (CDI_DOMINATORS, loop_latch, loop_header);
set_immediate_dominator (CDI_DOMINATORS, succ_bb, loop_header);
loop = alloc_loop ();
loop->header = loop_header;
loop->latch = loop_latch;
add_loop (loop, outer);
prob = REG_BR_PROB_BASE / 2;
scale_loop_frequencies (loop, REG_BR_PROB_BASE - prob, REG_BR_PROB_BASE);
update_dominators_in_loop (loop);
exit_e = single_exit (loop);
exit_e->flags = EDGE_LOOP_EXIT | EDGE_FALSE_VALUE;
single_pred_edge (loop_latch)->flags = EDGE_TRUE_VALUE;
initial_value = force_gimple_operand (initial_value, &stmts, true, iv);
if (stmts)
{
gsi_insert_seq_on_edge (loop_preheader_edge (loop), stmts);
gsi_commit_edge_inserts ();
}
upper_bound = force_gimple_operand (upper_bound, &stmts, true, NULL);
if (stmts)
{
gsi_insert_seq_on_edge (loop_preheader_edge (loop), stmts);
gsi_commit_edge_inserts ();
}
gsi = gsi_last_bb (loop_header);
create_iv (initial_value, stride, iv, loop, &gsi, false,
iv_before, iv_after);
cond_expr = gimple_build_cond
(LT_EXPR, *iv_before, upper_bound, NULL_TREE, NULL_TREE);
exit_test = gimple_cond_lhs (cond_expr);
exit_test = force_gimple_operand_gsi (&gsi, exit_test, true, NULL,
false, GSI_NEW_STMT);
gimple_cond_set_lhs (cond_expr, exit_test);
gsi = gsi_last_bb (exit_e->src);
gsi_insert_after (&gsi, cond_expr, GSI_NEW_STMT);
split_block_after_labels (loop_header);
return loop;
} | [
"struct",
"loop",
"*",
"create_empty_loop_on_edge",
"(",
"edge",
"entry_edge",
",",
"tree",
"initial_value",
",",
"tree",
"stride",
",",
"tree",
"upper_bound",
",",
"tree",
"iv",
",",
"tree",
"*",
"iv_before",
",",
"tree",
"*",
"iv_after",
",",
"struct",
"loop",
"*",
"outer",
")",
"{",
"basic_block",
"loop_header",
",",
"loop_latch",
",",
"succ_bb",
",",
"pred_bb",
";",
"struct",
"loop",
"*",
"loop",
";",
"gimple_stmt_iterator",
"gsi",
";",
"gimple_seq",
"stmts",
";",
"gimple",
"cond_expr",
";",
"tree",
"exit_test",
";",
"edge",
"exit_e",
";",
"int",
"prob",
";",
"gcc_assert",
"(",
"entry_edge",
"&&",
"initial_value",
"&&",
"stride",
"&&",
"upper_bound",
"&&",
"iv",
")",
";",
"pred_bb",
"=",
"entry_edge",
"->",
"src",
";",
"loop_header",
"=",
"split_edge",
"(",
"entry_edge",
")",
";",
"loop_latch",
"=",
"split_edge",
"(",
"single_succ_edge",
"(",
"loop_header",
")",
")",
";",
"succ_bb",
"=",
"single_succ",
"(",
"loop_latch",
")",
";",
"make_edge",
"(",
"loop_header",
",",
"succ_bb",
",",
"0",
")",
";",
"redirect_edge_succ_nodup",
"(",
"single_succ_edge",
"(",
"loop_latch",
")",
",",
"loop_header",
")",
";",
"set_immediate_dominator",
"(",
"CDI_DOMINATORS",
",",
"loop_header",
",",
"pred_bb",
")",
";",
"set_immediate_dominator",
"(",
"CDI_DOMINATORS",
",",
"loop_latch",
",",
"loop_header",
")",
";",
"set_immediate_dominator",
"(",
"CDI_DOMINATORS",
",",
"succ_bb",
",",
"loop_header",
")",
";",
"loop",
"=",
"alloc_loop",
"(",
")",
";",
"loop",
"->",
"header",
"=",
"loop_header",
";",
"loop",
"->",
"latch",
"=",
"loop_latch",
";",
"add_loop",
"(",
"loop",
",",
"outer",
")",
";",
"prob",
"=",
"REG_BR_PROB_BASE",
"/",
"2",
";",
"scale_loop_frequencies",
"(",
"loop",
",",
"REG_BR_PROB_BASE",
"-",
"prob",
",",
"REG_BR_PROB_BASE",
")",
";",
"update_dominators_in_loop",
"(",
"loop",
")",
";",
"exit_e",
"=",
"single_exit",
"(",
"loop",
")",
";",
"exit_e",
"->",
"flags",
"=",
"EDGE_LOOP_EXIT",
"|",
"EDGE_FALSE_VALUE",
";",
"single_pred_edge",
"(",
"loop_latch",
")",
"->",
"flags",
"=",
"EDGE_TRUE_VALUE",
";",
"initial_value",
"=",
"force_gimple_operand",
"(",
"initial_value",
",",
"&",
"stmts",
",",
"true",
",",
"iv",
")",
";",
"if",
"(",
"stmts",
")",
"{",
"gsi_insert_seq_on_edge",
"(",
"loop_preheader_edge",
"(",
"loop",
")",
",",
"stmts",
")",
";",
"gsi_commit_edge_inserts",
"(",
")",
";",
"}",
"upper_bound",
"=",
"force_gimple_operand",
"(",
"upper_bound",
",",
"&",
"stmts",
",",
"true",
",",
"NULL",
")",
";",
"if",
"(",
"stmts",
")",
"{",
"gsi_insert_seq_on_edge",
"(",
"loop_preheader_edge",
"(",
"loop",
")",
",",
"stmts",
")",
";",
"gsi_commit_edge_inserts",
"(",
")",
";",
"}",
"gsi",
"=",
"gsi_last_bb",
"(",
"loop_header",
")",
";",
"create_iv",
"(",
"initial_value",
",",
"stride",
",",
"iv",
",",
"loop",
",",
"&",
"gsi",
",",
"false",
",",
"iv_before",
",",
"iv_after",
")",
";",
"cond_expr",
"=",
"gimple_build_cond",
"(",
"LT_EXPR",
",",
"*",
"iv_before",
",",
"upper_bound",
",",
"NULL_TREE",
",",
"NULL_TREE",
")",
";",
"exit_test",
"=",
"gimple_cond_lhs",
"(",
"cond_expr",
")",
";",
"exit_test",
"=",
"force_gimple_operand_gsi",
"(",
"&",
"gsi",
",",
"exit_test",
",",
"true",
",",
"NULL",
",",
"false",
",",
"GSI_NEW_STMT",
")",
";",
"gimple_cond_set_lhs",
"(",
"cond_expr",
",",
"exit_test",
")",
";",
"gsi",
"=",
"gsi_last_bb",
"(",
"exit_e",
"->",
"src",
")",
";",
"gsi_insert_after",
"(",
"&",
"gsi",
",",
"cond_expr",
",",
"GSI_NEW_STMT",
")",
";",
"split_block_after_labels",
"(",
"loop_header",
")",
";",
"return",
"loop",
";",
"}"
] | create_empty_loop_on_edge
|
| - pred_bb - ------ pred_bb
| | | | iv0 = initial_value |
| -----|----- ---------|
| | ______ | entry_edge
| | entry_edge / | |
| | ====> | -V---V- loop_header
| V | | iv_before = phi (iv0, iv_after) |
| - succ_bb - | ---|
| | | | |
| ----------- | ---V--- loop_body
| | | iv_after = iv_before + stride |
| | | if (iv_before < upper_bound) |
| | ---|--------------\
| | | \ exit_e
| | V \
| | - loop_latch - V- succ_bb
| | | | | |
| |
| \ ___ | [
"create_empty_loop_on_edge",
"|",
"|",
"-",
"pred_bb",
"-",
"------",
"pred_bb",
"|",
"|",
"|",
"|",
"iv0",
"=",
"initial_value",
"|",
"|",
"-----",
"|",
"-----",
"---------",
"|",
"|",
"|",
"______",
"|",
"entry_edge",
"|",
"|",
"entry_edge",
"/",
"|",
"|",
"|",
"|",
"====",
">",
"|",
"-",
"V",
"---",
"V",
"-",
"loop_header",
"|",
"V",
"|",
"|",
"iv_before",
"=",
"phi",
"(",
"iv0",
"iv_after",
")",
"|",
"|",
"-",
"succ_bb",
"-",
"|",
"---",
"|",
"|",
"|",
"|",
"|",
"|",
"|",
"-----------",
"|",
"---",
"V",
"---",
"loop_body",
"|",
"|",
"|",
"iv_after",
"=",
"iv_before",
"+",
"stride",
"|",
"|",
"|",
"|",
"if",
"(",
"iv_before",
"<",
"upper_bound",
")",
"|",
"|",
"|",
"---",
"|",
"--------------",
"\\",
"|",
"|",
"|",
"\\",
"exit_e",
"|",
"|",
"V",
"\\",
"|",
"|",
"-",
"loop_latch",
"-",
"V",
"-",
"succ_bb",
"|",
"|",
"|",
"|",
"|",
"|",
"|",
"|",
"|",
"\\",
"___"
] | [
"/* Create header, latch and wire up the loop. */",
"/* Set immediate dominator information. */",
"/* Initialize a loop structure and put it in a loop hierarchy. */",
"/* TODO: Fix frequencies and counts. */",
"/* Update dominators. */",
"/* Modify edge flags. */",
"/* Construct IV code in loop. */",
"/* Insert loop exit condition. */"
] | [
{
"param": "entry_edge",
"type": "edge"
},
{
"param": "initial_value",
"type": "tree"
},
{
"param": "stride",
"type": "tree"
},
{
"param": "upper_bound",
"type": "tree"
},
{
"param": "iv",
"type": "tree"
},
{
"param": "iv_before",
"type": "tree"
},
{
"param": "iv_after",
"type": "tree"
},
{
"param": "outer",
"type": "struct loop"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "entry_edge",
"type": "edge",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "initial_value",
"type": "tree",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "stride",
"type": "tree",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "upper_bound",
"type": "tree",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "iv",
"type": "tree",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "iv_before",
"type": "tree",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "iv_after",
"type": "tree",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "outer",
"type": "struct loop",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
Subsets and Splits