Changeset View
Changeset View
Standalone View
Standalone View
sys/tools/makesyscalls.lua
Show First 20 Lines • Show All 642 Lines • ▼ Show 20 Lines | ]], funcname, sysnum)) | ||||
case %d: | case %d: | ||||
]], funcname, sysnum)) | ]], funcname, sysnum)) | ||||
write_line("systraceret", string.format([[ | write_line("systraceret", string.format([[ | ||||
/* %s */ | /* %s */ | ||||
case %d: | case %d: | ||||
]], funcname, sysnum)) | ]], funcname, sysnum)) | ||||
if #funcargs > 0 then | if #funcargs > 0 then | ||||
write_line("systracetmp", "\t\tswitch(ndx) {\n") | write_line("systracetmp", "\t\tswitch (ndx) {\n") | ||||
write_line("systrace", string.format( | write_line("systrace", string.format( | ||||
"\t\tstruct %s *p = params;\n", argalias)) | "\t\tstruct %s *p = params;\n", argalias)) | ||||
local argtype, argname | local argtype, argname | ||||
for idx, arg in ipairs(funcargs) do | for idx, arg in ipairs(funcargs) do | ||||
argtype = arg["type"] | argtype = arg["type"] | ||||
argname = arg["name"] | argname = arg["name"] | ||||
argtype = trim(argtype:gsub("__restrict$", ""), nil) | argtype = trim(argtype:gsub("__restrict$", ""), nil) | ||||
-- Pointer arg? | -- Pointer arg? | ||||
if argtype:find("*") then | if argtype:find("*") then | ||||
write_line("systracetmp", string.format( | write_line("systracetmp", string.format( | ||||
"\t\tcase %d:\n\t\t\tp = \"userland %s\";\n\t\t\tbreak;\n", | "\t\tcase %d:\n\t\t\tp = \"userland %s\";\n\t\t\tbreak;\n", | ||||
idx - 1, argtype)) | idx - 1, argtype)) | ||||
else | else | ||||
write_line("systracetmp", string.format( | write_line("systracetmp", string.format( | ||||
"\t\tcase %d:\n\t\t\tp = \"%s\";\n\t\t\tbreak;\n", | "\t\tcase %d:\n\t\t\tp = \"%s\";\n\t\t\tbreak;\n", | ||||
idx - 1, argtype)) | idx - 1, argtype)) | ||||
end | end | ||||
if isptrtype(argtype) then | if isptrtype(argtype) then | ||||
write_line("systrace", string.format( | write_line("systrace", string.format( | ||||
"\t\tuarg[%d] = (%s) p->%s; /* %s */\n", | "\t\tuarg[%d] = (%s)p->%s; /* %s */\n", | ||||
idx - 1, config["ptr_intptr_t_cast"], | idx - 1, config["ptr_intptr_t_cast"], | ||||
argname, argtype)) | argname, argtype)) | ||||
elseif argtype == "union l_semun" then | elseif argtype == "union l_semun" then | ||||
write_line("systrace", string.format( | write_line("systrace", string.format( | ||||
"\t\tuarg[%d] = p->%s.buf; /* %s */\n", | "\t\tuarg[%d] = p->%s.buf; /* %s */\n", | ||||
idx - 1, argname, argtype)) | idx - 1, argname, argtype)) | ||||
elseif argtype:sub(1,1) == "u" or argtype == "size_t" then | elseif argtype:sub(1,1) == "u" or argtype == "size_t" then | ||||
write_line("systrace", string.format( | write_line("systrace", string.format( | ||||
▲ Show 20 Lines • Show All 597 Lines • ▼ Show 20 Lines | |||||
* DO NOT EDIT-- this file is automatically %s. | * DO NOT EDIT-- this file is automatically %s. | ||||
* $%s$ | * $%s$ | ||||
* This file is part of the DTrace syscall provider. | * This file is part of the DTrace syscall provider. | ||||
*/ | */ | ||||
static void | static void | ||||
systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) | systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) | ||||
{ | { | ||||
int64_t *iarg = (int64_t *) uarg; | int64_t *iarg = (int64_t *)uarg; | ||||
switch (sysnum) { | switch (sysnum) { | ||||
]], generated_tag, config['os_id_keyword'])) | ]], generated_tag, config['os_id_keyword'])) | ||||
write_line("systracetmp", [[static void | write_line("systracetmp", [[static void | ||||
systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) | systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) | ||||
{ | { | ||||
const char *p = NULL; | const char *p = NULL; | ||||
switch (sysnum) { | switch (sysnum) { | ||||
]]) | ]]) | ||||
write_line("systraceret", [[static void | write_line("systraceret", [[static void | ||||
systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) | systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) | ||||
{ | { | ||||
const char *p = NULL; | const char *p = NULL; | ||||
switch (sysnum) { | switch (sysnum) { | ||||
]]) | ]]) | ||||
-- Processing the sysfile will parse out the preprocessor bits and put them into | -- Processing the sysfile will parse out the preprocessor bits and put them into | ||||
-- the appropriate place. Any syscall-looking lines get thrown into the sysfile | -- the appropriate place. Any syscall-looking lines get thrown into the sysfile | ||||
-- buffer, one per line, for later processing once they're all glued together. | -- buffer, one per line, for later processing once they're all glued together. | ||||
process_sysfile(sysfile) | process_sysfile(sysfile) | ||||
write_line("sysinc", | write_line("sysinc", | ||||
"\n#define AS(name) (sizeof(struct name) / sizeof(register_t))\n") | "\n#define AS(name) (sizeof(struct name) / sizeof(register_t))\n") | ||||
kevans: Tab after `#define` | |||||
Done Inline ActionsDespite style(9) it seems #define<space> is a lot more common in sys/, and clang-format does the same so I plan to leave these two unchanged for now. emaste: Despite style(9) it seems `#define<space>` is a lot more common in sys/, and clang-format does… | |||||
for _, v in pairs(compat_options) do | for _, v in pairs(compat_options) do | ||||
if v["count"] > 0 then | if v["count"] > 0 then | ||||
write_line("sysinc", string.format([[ | write_line("sysinc", string.format([[ | ||||
#ifdef %s | #ifdef %s | ||||
#define %s(n, name) .sy_narg = n, .sy_call = (sy_call_t *)__CONCAT(%s,name) | #define %s(n, name) .sy_narg = n, .sy_call = (sy_call_t *)__CONCAT(%s,name) | ||||
Not Done Inline ActionsDitto, and for the #else #define kevans: Ditto, and for the `#else #define` | |||||
#else | #else | ||||
#define %s(n, name) .sy_narg = 0, .sy_call = (sy_call_t *)nosys | #define %s(n, name) .sy_narg = 0, .sy_call = (sy_call_t *)nosys | ||||
#endif | #endif | ||||
]], v["definition"], v["flag"]:lower(), v["prefix"], v["flag"]:lower())) | ]], v["definition"], v["flag"]:lower(), v["prefix"], v["flag"]:lower())) | ||||
end | end | ||||
write_line(v["dcltmp"], string.format("\n#endif /* %s */\n\n", | write_line(v["dcltmp"], string.format("\n#endif /* %s */\n\n", | ||||
v["definition"])) | v["definition"])) | ||||
▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines |
Tab after #define