summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* buffers: doc: put-buf, fill-buf.Kaz Kylheku2017-06-051-0/+78
| | | | * txr.1: Documented put-buf and fill-buf.
* ffi: doc: endian typesKaz Kylheku2017-06-051-0/+69
| | | | * txr.1: Documented the endian types.
* ffi: doc: align operator.Kaz Kylheku2017-06-051-0/+45
| | | | * txr.1: Documented align type operator.
* itypes: fix broken u64_t range check.Kaz Kylheku2017-06-051-2/+2
| | | | | * itypes.c (c_u64): Replace copy and pasted signed check with the unsigned check.
* itypes: avoid out of range literal.Kaz Kylheku2017-06-051-2/+2
| | | | | | | * itypes.c (c_i32): Avoid the troublesome expressions -0x80000000. Instead, cast 0x7FFFFFFF to the cnum type, then invert, and subtract one. (c_i64): Similarly for -0x8000000000000000.
* ffi: handle endian types as return values.Kaz Kylheku2017-06-051-8/+120
| | | | | | | | | | | * ffi.c (ffi_be_i16_rput, ffi_be_i16_rget, ffi_be_u16_rput, ffi_be_u16_rget, ffi_be_i32_rput, ffi_be_i32_rget, ffi_be_u32_rput, ffi_be_u32_rget, ffi_le_i16_rput, ffi_le_i16_rget, ffi_le_u16_rput, ffi_le_u16_rget, ffi_le_i32_rput, ffi_le_i32_rget, ffi_le_u32_rput, ffi_le_u32_rget): New static functions, on big endian. (ffi_init_types): Wire in these functions for their corresponding types, on big endian.
* ffi: handle misaligned access for arith types.Kaz Kylheku2017-06-051-16/+81
| | | | | | | | | | | | | | | | | | The align feature won't work properly on some machines, since the underlying get and put routines don't handle misaligned access. We address that here. * ffi.c (align_sw_get, align_sw_end, align_sw_put_end, align_sw_put): New macros. (ffi_i16_put, ffi_i16_get, ffi_u16_put, ffi_u16_get, ffi_i32_put, ffi_i32_get, ffi_u32_put, ffi_u32_get, ffi_i64_put, ffi_i64_get, ffi_u64_put, ffi_u64_get, ffi_short_put, ffi_short_get, ffi_ushort_put, ffi_ushort_get, ffi_int_get, ffi_uint_put, ffi_uint_get, ffi_long_put, ffi_long_get, ffi_ulong_put, ffi_ulong_get, ffi_float_put, ffi_float_get, ffi_double_put, ffi_double_get, ffi_val_put, ffi_val_get, ffi_wchar_put, ffi_wchar_get, ffi_sbit_put, ffi_sbit_get, ffi_ubit_put, ffi_ubit_get): Insert macros to redirect the transfer to a temporary aligned buffer if the pointer is misaligned.
* ffi: big and little endian types.Kaz Kylheku2017-06-042-0/+679
| | | | | | | | | | | | | | | | | | | | | | | | | | * ffi.c (be_uint16_s, be_int16_s, be_uint32_s, be_int32_s, be_uint64_s, be_int64_s, be_float_s, be_double_s, le_uint16_s, le_int16_s, le_uint32_s, le_int32_s, le_uint64_s, le_int64_s, le_float_s, le_double_s): New symbol variables. (ffi_be_i16_put, ffi_be_i16_get, ffi_be_u16_put, ffi_be_u16_get, ffi_le_i16_put, ffi_le_i16_get, ffi_le_u16_put, ffi_le_u16_get, ffi_be_i32_put, ffi_be_i32_get, ffi_be_u32_put, ffi_be_u32_get, ffi_le_i32_put, ffi_le_i32_get, ffi_le_u32_put, ffi_le_u32_get, ffi_be_i64_put, ffi_be_i64_get, ffi_be_u64_put, ffi_be_u64_get, ffi_le_i64_put, ffi_le_i64_get, ffi_le_u64_put, ffi_le_u64_get, ffi_be_float_put, ffi_be_float_get, ffi_le_float_put, ffi_le_float_get, ffi_be_double_put, ffi_be_double_get, ffi_le_double_put, ffi_le_double_get): New static functions. (ffi_init_types): Register new type symbols via typedef mechanism. (ffi_init): Initialize new symbol variables. * ffi.c (be_uint16_s, be_int16_s, be_uint32_s, be_int32_s, be_uint64_s, be_int64_s, be_float_s, be_double_s, le_uint16_s, le_int16_s, le_uint32_s, le_int32_s, le_uint64_s, le_int64_s, le_float_s, le_double_s): Declared.
* ffi: new type operator align for customizing alignment.Kaz Kylheku2017-06-042-0/+75
| | | | | | | | | | | | | | | | | | | | | | | * ffi.c (align_s): New symbol variable. (struct txr_ffi_type): New function pointer member, clone. (ffi_simple_clone): New static function. (make_ffi_type_builtin, make_ffi_type_pointer, make_ffi_type_enum): Wire in ffi_simple_clone as the clone function. (ffi_struct_clone): New static function. (make_ffi_type_struct): Wire in ffi_struct_clone as the clone function for struct types. (ffi_array_clone): New static function. (make_ffi_type_array): Wire in ffi_array_clone as the clone function for array types. (ffi_type_copy): New static function. (ffi_type_compile): Recognize new (align <num> <type>) syntax. This works by cloning <type>, and then punching in the specified alignment. The align syntax then denotes this modified type. (ffi_init): Initialize align_s. * ffi.h (align_s): Declared.
* streams: put-buf and fill-buf functions.Kaz Kylheku2017-06-044-9/+129
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * stream.h (struct strm_ops): New function pointer members, put_buf and fill_buf. (strm_ops_init): Two new parameters in macro. (put_buf, fill_buf): Declared. * stream.c (unimpl_put_buf, unimpl_fill_buf, generic_put_buf, generic_fill_buf): New static functions. (fill_stream_ops): Default new fill_buf and fill_buf virtual functions intelligently based on whether get_byte and put_byte are available. (stdio_put_buf, stdio_fill_buf): New static functions. (stdio_ops, tail_ops, pipe_ops, dir_ops, string_in_ops, byte_in_ops, strlist_in_ops, string_out_ops, strlist_out_ops, cat_stream_ops): Add arguments to strm_ops_init macro for get_buf and fill_buf. (delegate_put_buf, delegate_fill_buf): New static functions. (record_adapter_ops): Add arguments to strm_ops_init macro for get_buf and fill_buf. (put_buf, fill_buf): New functions. (stream_init): Register put-buf and fill-buf intrinsics. * socket.c (dgram_strm_ops): Add arguments to strm_ops_init macro call. * syslog.c (syslog_strm_ops): Likewise.
* ffi: use expressions for bit field width also.Kaz Kylheku2017-06-032-5/+6
| | | | | | | * ffi.c (ffi_type_compile): Evaluate width argument of sbit and ubit type as as expression. * txr.1: Documented.
* ffi: evaluate expressions in type notation.Kaz Kylheku2017-06-023-25/+59
| | | | | | | | | | | | | | | | | | | | | | | | | Places where an integer constant was previously allowed now allow an expression. The way enum syntax works is now different. A temporary lexical environment is created, and each enumeration is bound in that environment. The value expressions are evaluated in that environment. The decision to allow keyword symbols to be enumeration contants is retracted. * eval.h (special_s): Declared. * ffi.c (ffi_eval_expr): New static function. (make_ffi_type_enum): Enums are introduced into a temporary environment, in which the value expressions are evaluated. By this means, the expressions can refer can refer to previous enums and do arbitrary computation. Also, we drop the requirement that enums can be keyword symbols. (ffi_type_compile): Array dimension and buf size are evaluated as expresions. Array and buffer syntax is transformed by substitution of the evaluated size. * txr.1: Documented use of expressions in FFI type notation.
* ffi: wrong indentation.Kaz Kylheku2017-06-021-2/+2
| | | | | * ffi.c (ffi_type_compile): Fix bad indentation brought about by refactoring.
* ffi: functions and macros for basic type properties.Kaz Kylheku2017-06-025-12/+349
| | | | | | | | | | | | | | | | | | * ffi.c (ffi_alignof, ffi_offsetof, ffi_arraysize, ffi_elemsize, ffi_elemtype): New functions. (ffi_init): Registered intrinsics ffi-alignof, ffi-offsetof, ffi-arraysize, ffi-elemsize, ffi-elemtype. * ffi.h (ffi_alignof, ffi_offsetof, ffi_arraysize, ffi_elemsize, ffi_elemtype): Declared. * lisplib.c (ffi_set_entries): New autoload entries alignof, offsetof, arraysize, elemsize, elemtype. * share/txr/stdlib/ffi.tl (alignof, offsetof, arraysize, elemsize, elemtype): New macros. * txr.1: Documented new functions and macros.
* ffi: don't allow size calculation of bitfield type.Kaz Kylheku2017-06-021-0/+4
| | | | | * ffi.c (ffi_size): Check for a bitfield type and diagnose.
* mkstring char argument is optional.Kaz Kylheku2017-06-013-3/+8
| | | | | | | | | * eval.c (eval_init): Update registration of mkstring intrinsic to make second argument optional. * lib.c (mkstring): Default second argument to space. * txr.1: Documentation of mkstring updated.
* ffi: new feature: enums.Kaz Kylheku2017-05-313-0/+213
| | | | | | | | | | | | | | | | * ffi.c (enum_s): New symbol variable. (struct txr_ffi_type): New member, sym_num, num_sym. (ffi_enum_type_mark): New static function. (ffi_type_enum_ops): New static structure. (ffi_enum_put, ffi_enum_get, ffi_enum_rput, ffi_enum_rget): New static functions. (make_ffi_type_enum): New static function. (ffi_type_compile): Extend with enum syntax. (ffi_init): Initialize enum_s with new interned symbol. * ffi.c (enum_s): Declared. * txr.1: Documented.
* ffi: bugfix: basic type needs proper mark function.Kaz Kylheku2017-05-311-5/+15
| | | | | | | | * ffi.c (ffi_type_common_mark, ffi_type_mark): New static function (ffi_struct_type_mark, ffi_ptr_type_mark): Use new ffi_type_common_mark function for common members. (ffi_type_builtin_ops): Wire in ffi_type_mark.
* Refactoring hash bang support; hash bang null hack.Kaz Kylheku2017-05-306-83/+252
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The hash bang mechanism is handled in one place, and disentangled from all parsing logic. It is also endowed with special powers. * eval.c (load): Pass one less argument to read_eval_stream. * match.c (v_load): Likewise. * parser.c (read_eval_stream): hash_bang_support Boolean argument removed. Hash bang logic removed. (load_rcfile): Pass only two arguments to read_eval_stream. * parser.h (read_eval_stream): Declaration updated. * txr.c (remove_hash_bang_line): Function removed. (check_hash_bang): New static function. (txr_main): Recognize the script file name while still inside the argument processing loop. Open the file, and check for a hash bang line, doing the special processing which can generate more arguments from material after a null byte in the hash bang line. The parse_stream variable is now initialized to nil and doubles as a Boolean indicating whether a stream has been opened. After the loop, we remove the script file from the arguments, if we have an open stream and the spec_file_str matches. read_eval_stream is called only with two arguments. * txr.1: Revised existing documentation and described new features.
* command line: --eargs semantics change.Kaz Kylheku2017-05-304-14/+30
| | | | | | | | | | | | | | | | | The --eargs mechanism won't perform a blind substring replacement of {} with the following argument. Only arguments which match {} exactly are replaced. * eval.c (retf): Static function becomes extern. * eval.h (retf): Declared. * txr.c (txr_main): Replace the filtering logic on the split eargs argument list to just look for items equal to the string "{}" and replace with the following argument. * txr.1: Updated --eargs documentation.
* New variable: *args-eff*.Kaz Kylheku2017-05-302-10/+52
| | | | | | | | | | | | * txr.c (txr_main): As arguments are processed, collect them into a list called the effective arg list, which is eventually visible as the *args-eff* variable. This is the argument list which reflects the expansions that have been applied by --args or --eargs. Those two options take special care to remove themselves from that list. * txr.1: Documented *args-eff*.
* ffi: pad retval to ffi_arg size on all platforms.Kaz Kylheku2017-05-291-4/+5
| | | | | | | | | | * ffi.c (pad_retval): Define same way regardless of big or little endian. For instance, we don't want to call alloca(1) for a char return value. It could be the case on little endian targets that libffi prepares an entire ffi_arg return value. Even though we just read the low order byte, we still have to prepare enough space for the whole thing.
* ffi: bugfix: null out return value to padded size.Kaz Kylheku2017-05-281-1/+1
| | | | | | | * ffi.c (ffi_closure_dispatch_safe): In the abort case when we put zeros in the return value, we must overwrite the entire ffi_arg cell, in adherence with the special return value quirk of libffi.
* ffi: adapt to return value braindamage in libffi.Kaz Kylheku2017-05-281-41/+301
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change gets TXR FFI working on Power PC 64, big endian. Many thanks to the GCC Compile Farm. Turns out, the libffi API has changed some years ago, with outdated documentation lingering. Return values for the basic integral types must all be handled with a buffer of type ffi_arg and casting. This is true in both ffi_call and closures: in both directions. For instance, if a foreign function returns char, we must retrieve a ffi_arg value (which might be as large as 64 bits). Then we must cast this value to char. In actual fact, on a big endian system with an 8 byte ffi_arg, the char value may be located in byte 7 of the 8 byte buffer, not in byte 0. FFI's own test suite got this wrong and had to be patched back in 2013: it was doing things the way we are doing them: https://sourceware.org/ml/libffi-discuss/2013/msg00199.html The doc was updated at the same time to tell the truth: https://sourceware.org/ml/libffi-discuss/2013/msg00200.html Luckily, we can fix TXR's ffi module without damaging its framework. The object model is flexible enough to absorb the change. Basically, we add two new methods to the txr_ffi_type objects: virtual functions rget and rput. We only add these when targetting big endian. These have the same type signature as get and put, but are specialized for handling return values. For all integer types smaller than 64 bits, these functions are separately implemented with distinct semanics which handle the FFI API requirements with ffi_arg and casting and all. For all other types, rget and rput are identical to get and put. * ffi.c (pad_retval, ifbe, ifbe2): New macros, conditionally defined for big and little endian. (struct txr_ffi_type): New members rput and rget. (ffi_i8_rput, ffi_i8_rget, ffi_u8_rput, ffi_u8_rget, ffi_i16_rput, ffi_i16_rget, ffi_u16_rput, ffi_u16_rget, ffi_i32_rput, ffi_i32_rget, ffi_u32_rput, ffi_u32_rget, ffi_char_rput, ffi_char_rget, ffi_uchar_rput, ffi_uchar_rget, ffi_bchar_rget, ffi_short_rput, ffi_short_rget, ffi_ushort_rput, ffi_ushort_rget, ffi_int_rput, ffi_int_rget, ffi_uint_rput, ffi_uint_rget, ffi_long_rput, ffi_long_rget, ffi_ulong_rput, ffi_ulong_rget, ffi_wchar_rput): New functions. (make_ffi_type_builtin): Take rput and rget arguments, regardless of platform. On big endian, store these in the corresponding members. If they are null, duplicate get and put instead. (ffi_type_compile, ffi_init_types): Specify the rput and rget functions for the basic types, using the ifbe macro which nullifies the references to functions when they don't exist on little endian. For all other types, pass the new arguments as null. (ffi_call_wrap): Pad the return vaue buffer size to a minimum size on big endian; it must be at least sizeof (ffi_alloc). Use the rget method for the return value on big endian. (ffi_closure_dispatch, ffi_closure_dispatch_safe): Use rput on big endian for storing return value.
* make tests: remove failed .out.Kaz Kylheku2017-05-271-1/+4
| | | | | | | | * Makefile (%.ok): If the .out file differs from .expected, don't just fail this rule. Remove the .out file also, so that when "make tests" is repeated, the test is re-run to regenerate it. Otherwise "make tests" will only run diff again on the previously generated .out file.
* ffi: remove redundant flag calc in call wrapper.Kaz Kylheku2017-05-261-1/+0
| | | | | | * ffi.c (ffi_call_wrap): Don't calculate in_pass_needed in put loop, since we already calculated it in the argument buffer allocation loop.
* doc: grammar in ffi.Kaz Kylheku2017-05-261-6/+7
| | | | * txr.1: Smattering of grammar fixes in ffi section.
* doc: wrong word under ffi buf description.Kaz Kylheku2017-05-261-1/+1
| | | | * txr.1: buf and buf-d are "types" not "parts".
* ffi: bitfield support.Kaz Kylheku2017-05-253-26/+341
| | | | | | | | | | | | | | | | | | | | | | | * ffi.c (sbit_s, ubit_s): New symbol variables. (struct txr_ffi_type): New members, shift and mask. (ffi_sbit_put, ffi_sbit_get, ffi_ubit_put, ffi_ubit_get, bitfield_syntax_p): New static functions. (make_ffi_type_pointer): Disallow pointers to bitfields. (make_ffi_type_struct): Process bitfield members and set up shifts and masks accordingly. Recently introduced bug fixed here at the same time: the alignment calculation for each member must be done top-of-loop. (ffi_struct_compile): Exclude bitfields from the check against members with zero type. Compile the bitfield syntax. (ffi_typedef): Do not allow typedefs of bitfield type. Not only doesn't this make sense, but bitfield types are destructively modified in make_ffi_type_struct: they are imbued with a mask and offset tied to their position in a particular struct. * ffi.h (sbit_s, ubit_s): Delared. * txr.1: Documented bitfields.
* configure: detect endianness.Kaz Kylheku2017-05-251-0/+37
| | | | | | * configure: New test for endianness of the compile target. Produces HAVE_LITTLE_ENDIAN in config.h with a value of either 1 or 0.
* ffi: bugfix: remove nil slots when making struct.Kaz Kylheku2017-05-251-1/+2
| | | | | | | | | * ffi.c (ffi_type_compile): In the case when a struct type is compiled and the Lisp struct doesn't exist, the function creates the struct type. However, the FFI struct type syntax allows nil as a slot name, indicating a padding field. These nils must be scrubbed from the slot list when making the Lisp struct type, or else an error occurs.
* ffi: bugfix: gc-correct handling of memb array.Kaz Kylheku2017-05-251-2/+2
| | | | | | | | | | * ffi.c (make_ffi_type_struct): Use calloc for allocating memb, so all the Lisp objects in it are initially nil. Then install it into the structure upfront. Afterward, as we iterate over the slots and types and install them into the array, we lose references to them. But now since the array is now wired into the FFI struct type structure, these objects are now visible to GC.
* ffi: don't compile struct member type twice.Kaz Kylheku2017-05-251-1/+1
| | | | | | * ffi.c (ffi_struct_compile): Eliminate redundant call to ffi_type_compile, replacing it with the compiled type we already have.
* ffi: bugfix: incorrect error throws in buf ops.Kaz Kylheku2017-05-251-4/+4
| | | | | * ffi.c (ffi_put_into, ffi_in, ffi_get, ffi_out): Add missing error symbol argument in uw_throwf calls.
* ffi: precompute member offsets in struct type.Kaz Kylheku2017-05-251-26/+14
| | | | | | | | | | | | | | This change will make bitfield support easier. * ffi.c (struct smemb): New member, offs. (ffi_struct_in, ffi_struct_put, ffi_struct_out, ffi_struct_get, ffi_struct_release): For each member, refer to the offset in the memb array, rather than calculating it on-the-fly. (make_ffi_type_struct): Calculate the offset for each member. This is exactly the same as the total_size calculation before; just the name is changed to offs, and bit operations are used for the alignment calculations.
* ffi: use array for struct member description.Kaz Kylheku2017-05-241-40/+56
| | | | | | | | | | | | | | | | | * ffi.c (struct smemb): New struct type. (struct txr_ffi_type): Removed members mnames and mtypes. New member memb. (ffi_type_struct_destroy_op): Free the new memb descriptor array, and overwrite with null pointer. (ffi_struct_type_mark): Mark eltype only if not nil. If memb pointer is not nil, walk the array and mark it. Remove marking of removed mtypes and mnames members. (ffi_ptr_in_release, ffi_struct_in, ffi_struct_put, ffi_struct_out, ffi_struct_get, ffi_struct_release): Walk the struct members using the new array descriptor. (make_ffi_type_struct): Allocate the memb array, and initialize it. Remove initialization of mnames and mtypes. (make_ffi_type_array): Remove initialization of mnames.
* ffi: bugfix: gc issue affecting cptr and carray.Kaz Kylheku2017-05-241-15/+7
| | | | | | | | | * ffi.c (ffi_type_compile): The problem here is using make_ffi_type_builtin and then installing an eltype. That type has no gc function that will mark tft->eltype, exposing the eltype to premature reclamation. We must change these to use make_ffi_type_pointer. That constructor takes the element type too, so the code gets simplified.
* ffi: buffix: alignment still wrong for ptr types.Kaz Kylheku2017-05-241-9/+4
| | | | | | | | | | | | For pointers, the code still reflects the wrong assumption that the size and alignment are the same. * ffi.c (make_ffi_type_pointer): Remove the size argument; it's always passed as sizeof (mem_t *), which is pointless. Just initialize the size and align members in a fixed way. Use sizeof and alignof to do this right. (ffi_type_compile): Remove size argument from all make_ffi_type_pointer calls.
* ffi: eliminate overloading of mtypes member.Kaz Kylheku2017-05-241-31/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * ffi.c (struct txr_ffi_type): New member, eltype. Represents element type of arrays and target type of pointers, so that the mtypes member isn't overloaded for this purpose, and will only represent the list of types of a struct. (ffi_struct_type_mark): Mark eltype, since this function is used by arrays also. (ffi_ptr_type_mark): Mark eltype. Do not mark mtypes, since the ptr types don't use it any more. (ffi_varray_alloc, ffi_wchar_get, ffi_cptr_get, ffi_cptr_alloc, ffi_ptr_in_in, ffi_ptr_in_d_in, ffi_ptr_in_out, ffi_ptr_out_in, ffi_ptr_out_put, ffi_ptr_out_out, ffi_ptr_get, ffi_ptr_d_get, ffi_ptr_in_put, ffi_ptr_out_s_in, ffi_ptr_in_release, ffi_array_in_common, ffi_array_put_common, ffi_array_out_common, ffi_array_get_common, ffi_array_release_comon, ffi_array_null_term_in, ffi_array_null_term_get, ffi_varray_release, ffi_carray_get, ffi_carray_put): Access eltype instead of mtypes. (make_ffi_type_builtin): Don't initialize mnames and mtypes to nil, since we are using calloc. (make_ffi_type_pointer): Don't initialize mnames or mtypes to nil. Do initialize eltype to the target type. (make_ffi_type_array): Initialize eltype instead of mtypes. (ffi_type_compile): For cptr and carray, initialize eltype instead of mtypes.
* doc: clean up description of bident and lident.Kaz Kylheku2017-05-241-7/+20
| | | | | | | | * txr.1: Fix false, contradictory text claiming that an underscore may be part of a bident but not sident. (Reported by user "death" on Reddit). Add clarifying text explaining that only the slash character may be in a lident but not bident, and improve some surrounding text.
* ffi: sanity check on object in ffi_val_get.Kaz Kylheku2017-05-244-1/+27
| | | | | | | | | | | | | | | | | * ffi.c (ffi_val_get): Throw an exception if the object doesn't appear valid. * gc.c (valid_object_p): New function. Invalid objects are those that are pointers, but either not into a heap, or else to a freed object or to an object that is marked by the garbage collector (should only be seen while GC is running). All others are valid. There can be false positives here: a value with the LIT tag is in fact a pointer, but we don't check whether that is valid. * gc.c (valid_object_p): Declared. * txr.1: Remarks added to documentation of FFI val type.
* bits: external linkage.Kaz Kylheku2017-05-242-2/+2
| | | | | | | * arith.c (bits): Change the linkage from internal to external. * arith.h (bits): Declared.
* doc: point out relationship between juxt and callf.Kaz Kylheku2017-05-241-0/+22
| | | | | * txr.1: Under callf, give equivalence to juxt. Also refer to callf from juxt.
* doc: C code formatting issue.Kaz Kylheku2017-05-231-2/+6
| | | | | * txr.1: typeset couple of example printf calls properly in discussion of variadic FFI call descriptors.
* ffi: val type.Kaz Kylheku2017-05-233-1/+39
| | | | | | | | | | | * ffi.c (val_s): New symbol variable. (ffi_val_put, ffi_val_get): New functions. (ffi_init_types): Register val type. (ffi_init): Initialize val_s. * ffi.h (val_s): Declared. * txr.1: Documented.
* Version 176.txr-176Kaz Kylheku2017-05-217-972/+1096
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* ffi: glob test: struct size on Linux and Cygwin.Kaz Kylheku2017-05-212-22/+40
| | | | | | | | | * tests/017/glob-carray.tl (glob-t): Restructure to case statement. Add padding to struct based on looking at the glibc definition. Add FFI definition based on Cygwin header. * tests/017/glob-zarray.tl (glob-t): Likewise.
* ffi: bugfix: revisit alignment.Kaz Kylheku2017-05-211-30/+62
| | | | | | | | | | | | Replace the incorrect alignment assumption for the basic types (size == alignment) with the true calculation obtained from the compiler. * ffi.c (alignof): New macro. (make_ffi_type_builtin): Take alignment as separate argument. (ffi_type_compile, ffi_init_types): Using alignof macro, calculate alignment of each type that is created using make_ffi_type_builtin, and pass to that function.
* ffi: port glob tests to Darwin.Kaz Kylheku2017-05-212-10/+28
| | | | | | | | | * tests/017/glob-carray.tl (glob-t): Initialize reserve member to 0. Since it doesn't exist on Darwin, it will stay nil, and change the the test output. A Darwin variant of the corresponding FFI type is provided. * tests/017/glob-zarray.tl (glob-t): Likewise.
* Adding realpath function.Kaz Kylheku2017-05-213-0/+60
| | | | | | | | | * configure: New test for realpath. * sysif.c (realpath_wrap): New static function. (sysif_init): Registered realpath intrinsic. * txr.1: Documented.