diff options
-rw-r--r-- | args.h | 8 | ||||
-rw-r--r-- | ffi.c | 6 | ||||
-rw-r--r-- | lib.h | 6 | ||||
-rw-r--r-- | struct.c | 6 |
4 files changed, 19 insertions, 7 deletions
@@ -30,7 +30,7 @@ struct args { cnum argc; cnum fill; val list; - val arg[1]; + val arg[FLEX_ARRAY]; }; typedef int arg_index; @@ -38,6 +38,12 @@ typedef int arg_index; #define ARGS_MAX 32 #define ARGS_MIN 4 +#if FLEX_ARRAY + 0 == 1 +#define ARGS_ABS_MIN 1 +#else +#define ARGS_ABS_MIN 0 +#endif + struct args_bool_key { val key; val arg_p; @@ -2300,7 +2300,7 @@ static val ffi_struct_in(struct txr_ffi_type *tft, int copy, mem_t *src, return strct; if (strct == nil) { - args_decl(args, 0); + args_decl(args, ARGS_ABS_MIN); strct = make_struct(tft->lt, nil, args); } @@ -2367,7 +2367,7 @@ static val ffi_struct_get(struct txr_ffi_type *tft, mem_t *src, val self) { cnum i, nmemb = tft->nelem; struct smemb *memb = tft->memb; - args_decl(args, 0); + args_decl(args, ARGS_ABS_MIN); val strct = make_struct(tft->lt, nil, args); int flexp = tft->flexible; @@ -6485,7 +6485,7 @@ val make_zstruct(val type, struct args *args) val self = lit("make-zstruct"); struct txr_ffi_type *tft = ffi_type_struct_checked(self, type); val pairs = args_get_list(args); - args_decl(ms_args, 0); + args_decl(ms_args, ARGS_ABS_MIN); val strct = make_struct(tft->lt, nil, ms_args); mem_t *zbuf; char *inited = coerce(char *, zalloca(tft->nelem)); @@ -46,6 +46,12 @@ typedef double_uintptr_t dbl_ucnum; #define coerce(TYPE, EXPR) ((TYPE) (EXPR)) #endif +#if __STDC_VERSION__ >= 199901L +#define FLEX_ARRAY +#else +#define FLEX_ARRAY 1 +#endif + #define TAG_SHIFT 2 #define TAG_MASK ((convert(cnum, 1) << TAG_SHIFT) - 1) #define TAG_PTR 0 @@ -846,13 +846,13 @@ val make_struct(val type, val plist, struct args *boa) val struct_from_plist(val type, struct args *plist) { - args_decl(boa, 0); + args_decl(boa, ARGS_ABS_MIN); return make_struct_impl(lit("struct-from-plist"), type, plist, boa); } val struct_from_args(val type, struct args *boa) { - args_decl(pargs, 0); + args_decl(pargs, ARGS_ABS_MIN); return make_struct_impl(lit("struct-from-args"), type, pargs, boa); } @@ -933,7 +933,7 @@ val make_lazy_struct(val type, val argfun) val make_struct_lit(val type, val plist) { - args_decl(args, 0); + args_decl(args, ARGS_ABS_MIN); val strct; if (opt_compat && opt_compat <= 154) { |