diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-10-15 00:13:58 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-10-15 00:13:58 -0700 |
commit | db49aeca0b8cdf6695c3fc0754274398da0234d5 (patch) | |
tree | 126a5c227ec88b0649730aa5e4466279d7fb52dc /sysif.c | |
parent | 227d89b5ec4b967c87cd24d7074ec71e8aad0448 (diff) | |
download | txr-db49aeca0b8cdf6695c3fc0754274398da0234d5.tar.gz txr-db49aeca0b8cdf6695c3fc0754274398da0234d5.tar.bz2 txr-db49aeca0b8cdf6695c3fc0754274398da0234d5.zip |
args: don't use alloca for const size cases.
* args.h (args_decl_list): This macro now handles only
constant values of N. It declares an anonyous container
struct type which juxtaposes the struc args header
with exactly N values. This is simply defined as a local
variable without alloca.
(args_decl_constsize): Like args_decl, but requiring a
constant N; implemented via args_decl_list.
(args_decl_list_dyn): New name for the old args_decl_list
which calls alloca. No places in the code depend on this
at all, except the definition of args_decl.
(args_decl): Retargeted to args_decl_list_dyn.
There is some inconsistency in the macro naming in that
args_decl_constsize depends on args_decl_list, and
args_decl depends on arg_decl_list_dyn. This was done
to minimize diffs. Most direct uses of args_decl_list
have a constant size, but a large number of args_decl
uses do not have a constant size.
* eval.c (op_catch): Use args_decl_constsize.
* ffi.c (ffi_struct_in, ffi_struct_get, union_out):
Likewise.
* ftw.c (ftw_callback): Likewise.
* lib.c (funcall, funcall1, funcall2, funcall3,
funcall4, uniq, relate): Likewise.
* socket.c (sockaddr_in_unpack, sockaddr_in6_unpack,
sockaddr_un_unpack):
Likewise.
* stream.c (formatv): Likewise.
* struct.c (struct_from_plist, struct_from_args,
make_struct_lit): Likewise.
* sysif.c (termios_unpack): Likewise.
* time.c (broken_time_struct): Likewise.
Diffstat (limited to 'sysif.c')
-rw-r--r-- | sysif.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -1263,7 +1263,7 @@ static val stat_to_list(struct stat st) val stat_to_struct(struct stat st, val path, val stat_opt) { - args_decl(args, ARGS_MIN); + args_decl_constsize(args, ARGS_MIN); val strct = default_arg(stat_opt, make_struct(stat_s, nil, args)); slotset(strct, dev_s, num(st.st_dev)); slotset(strct, ino_s, num(st.st_ino)); @@ -1905,7 +1905,7 @@ static void fill_passwd(val to, struct passwd *from) static val make_pwstruct(struct passwd *p) { - args_decl(args, ARGS_MIN); + args_decl_constsize(args, ARGS_MIN); val out = make_struct(passwd_s, nil, args); fill_passwd(out, p); return out; @@ -2003,7 +2003,7 @@ static void fill_group(val to, struct group *from) static val make_grstruct(struct group *g) { - args_decl(args, ARGS_MIN); + args_decl_constsize(args, ARGS_MIN); val out = make_struct(group_s, nil, args); fill_group(out, g); return out; @@ -2221,7 +2221,7 @@ static val fnmatch_wrap(val pattern, val string, val flags) #if HAVE_UNAME static val uname_wrap(void) { - args_decl(args, ARGS_MIN); + args_decl_constsize(args, ARGS_MIN); struct utsname un; int res; if ((res = uname(&un)) >= 0) { @@ -2459,7 +2459,7 @@ static val readdir_wrap(val dirobj, val dirent_in) dent = readdir(d->dir); continue; } else { - args_decl(args, ARGS_MIN); + args_decl_constsize(args, ARGS_MIN); val dirent = default_arg(dirent_in, make_struct(dirent_st, nil, args)); slotset(dirent, name_s, if3(d->path, @@ -2519,7 +2519,7 @@ val getrlimit_wrap(val resource, val rlim_opt) self, resource, num(errno), errno_to_str(errno), nao); if (missingp(rlim)) { - args_decl(args, ARGS_MIN); + args_decl_constsize(args, ARGS_MIN); rlim = make_struct(rlim_st, nil, args); } |