summaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-10-15 00:13:58 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-10-15 00:13:58 -0700
commitdb49aeca0b8cdf6695c3fc0754274398da0234d5 (patch)
tree126a5c227ec88b0649730aa5e4466279d7fb52dc /socket.c
parent227d89b5ec4b967c87cd24d7074ec71e8aad0448 (diff)
downloadtxr-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 'socket.c')
-rw-r--r--socket.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/socket.c b/socket.c
index dfa6cff0..e82fb96f 100644
--- a/socket.c
+++ b/socket.c
@@ -134,7 +134,7 @@ static void ipv6_scope_id_from_num(struct sockaddr_in6 *dst, val scope)
static val sockaddr_in_unpack(struct sockaddr_in *src)
{
- args_decl(args, ARGS_MIN);
+ args_decl_constsize(args, ARGS_MIN);
val out = make_struct(sockaddr_in_s, nil, args);
slotset(out, addr_s, ipv4_addr_to_num(&src->sin_addr));
slotset(out, port_s, num_fast(ntohs(src->sin_port)));
@@ -143,7 +143,7 @@ static val sockaddr_in_unpack(struct sockaddr_in *src)
static val sockaddr_in6_unpack(struct sockaddr_in6 *src)
{
- args_decl(args, ARGS_MIN);
+ args_decl_constsize(args, ARGS_MIN);
val out = make_struct(sockaddr_in6_s, nil, args);
slotset(out, addr_s, ipv6_addr_to_num(&src->sin6_addr));
slotset(out, port_s, num_fast(ntohs(src->sin6_port)));
@@ -152,7 +152,7 @@ static val sockaddr_in6_unpack(struct sockaddr_in6 *src)
static val sockaddr_un_unpack(struct sockaddr_un *src)
{
- args_decl(args, ARGS_MIN);
+ args_decl_constsize(args, ARGS_MIN);
val out = make_struct(sockaddr_un_s, nil, args);
slotset(out, path_s, string_utf8(src->sun_path));
return out;