summaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-07-20 16:39:12 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-07-20 16:39:12 -0700
commit54adf777ed9e1ce358848b4477a69dd59b5f0753 (patch)
tree688c0f29e4928b4c2b930ee1b2958801c2fa6a43 /socket.c
parenta07d183cf7215271fcc5ca60ec55273607419e3b (diff)
downloadtxr-54adf777ed9e1ce358848b4477a69dd59b5f0753.tar.gz
txr-54adf777ed9e1ce358848b4477a69dd59b5f0753.tar.bz2
txr-54adf777ed9e1ce358848b4477a69dd59b5f0753.zip
ffi: support flexible structures.
This commit adds support for working with foreign structures which use the C99 "flexible array member", or possibly the old "C struct hack". Some improvements are made in the FFI code the area of incomplete types and bitfields. * ffi.c (struct txr_ffi_type): New flag members incomplete and bitfield. (ffi_varray_dynsize): Check incomplete type flag rather than for zero size. (ffi_flex_dynsize, ffi_flex_alloc, ffi_flex_struct_in): New static functions. (ffi_struct_in): Call ffi_flex_struct_in when doing by-value semantics on a flexible structure, just before converting last member. This checks for the length method, calls it, and adjusts the last member object as documented. (ffi_struct_get): Likewise. (bitfield_syntax_p): Static function removed; there is a flag for this now in the type, so no need to parse its syntax. (make_ffi_type_pointer): Test bitfield flag rather than using bitfield_syntax_p. (make_ffi_type_struct): Take new argument indicating that the struct is flexible. Wire in appropriate virtual functions based on this flag, and set the type's incomplete flag accordingly. Check bitfield flag rather than using bitfield_syntax_p for detecting bitfield members. Calculate the size of flexible struct differently: it is the offset of the last member. (make_ffi_type_union): Test bitfield flag rather than using bitfield_syntax_p. (ffi_struct_compile): Renamed to ffi_membs_compile. (ffi_membs_compile): New pointer parameter for returning an indication whether the member list specifies a flexible struct. Test the incomplete flag of a member type rather than size being zero. (ffi_type_compile): Follow rename of ffi_struct_compile to ffi_membs_compile. Pass down the flag obtained from ffi_membs_compile into make_ffi_type_struct so that a flexible struct type is created when necessary. Disallow arrays of bitfields. Set bitfield flag on bitfield types. (ffi_init_types): Set incomplete flag on void type. (ffi_make_call_desc): Test for incomplete and bitfield types using new flags. (ffi_typedef, ffi_size, ffi_alignof): Test for bitfield type using new bitfield flag. (carray_elem_check): New static function. (carray_buf, carray_pun, carray_unum, carray_num): Use new carray_elem_check to check for bad array element type. This uses the incomplete flag rather than checking for zero size, and also disallows bitfields. * lib.h (length_s): Declared. * txr.1: Flexible structs documented in new section. Also section on incomplete types. Description of sizeof operator gives more detaild about incomplete types including flexible structs.
Diffstat (limited to 'socket.c')
0 files changed, 0 insertions, 0 deletions