diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2020-06-19 06:29:45 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-06-19 06:29:45 -0700 |
commit | 09091bedcc6dd570262de4a72c362b161a492df7 (patch) | |
tree | 5d68d965c3a7b28a7908254cbe3e9e3e9b9589aa | |
parent | 2f2d654c20c75a7cc6e5c1c28803f475c929abba (diff) | |
download | txr-09091bedcc6dd570262de4a72c362b161a492df7.tar.gz txr-09091bedcc6dd570262de4a72c362b161a492df7.tar.bz2 txr-09091bedcc6dd570262de4a72c362b161a492df7.zip |
itypes: remove silly itypes_little_endian.
Curiously, the itypes_little_endian variable was introduced in
April 2017, in a the first commit implementing buffers. The
variable was initialized, but never referenced. About a month
after that, I introduced HAVE_LITTLE_ENDIAN config.h macro,
which is always present and defined as 0 or 1. This was used
right away in the implementation of FFI bitfields, and later
on in other FFI work. In spite of HAVE_LITTLE_ENDIAN, almost
exactly a year after itypes_little_endian was introduced, I
mistakenly put that variable to use instead of recognizing it
as superfluous and removing it in favor of using
HAVE_LITTLE_ENDIAN. That is what I'm doing now.
* itypes.c (itypes_little_endian): Variable removed.
(itypes_init): Function removed, since its only job is to
initialize this variable.
* itypesl.h (itypes_little_endian, itypes_init): Declarations
removed.
* lib.c (init): Call to itypes_init removed.
* parser.c (read_file_common): Instead of
itypes_little_indian, use HAVE_LITTLE_ENDIAN, which
the configuration script always exists and is defined
as 0 or 1.
-rw-r--r-- | itypes.c | 15 | ||||
-rw-r--r-- | itypes.h | 3 | ||||
-rw-r--r-- | lib.c | 1 | ||||
-rw-r--r-- | parser.c | 4 |
4 files changed, 2 insertions, 21 deletions
@@ -35,8 +35,6 @@ #include "arith.h" #include "itypes.h" -int itypes_little_endian; - #if HAVE_I8 i8_t c_i8(val n, val self) { @@ -263,16 +261,3 @@ unsigned long c_ulong(val n, val self) #error portme #endif } - -extern int itypes_little_endian; -void itypes_init(void); - -void itypes_init() -{ - union u { - volatile unsigned ui; - volatile unsigned char uc[sizeof (unsigned)]; - } u = { 0xff }; - - itypes_little_endian = (u.uc[0] == 0xff); -} @@ -116,6 +116,3 @@ unsigned int c_uint(val, val self); long c_long(val, val self); unsigned long c_ulong(val, val self); - -extern int itypes_little_endian; -void itypes_init(void); @@ -13086,7 +13086,6 @@ void init(val *stack_bottom) hash_init(); struct_init(); tree_init(); - itypes_init(); buf_init(); ffi_init(); sysif_init(); @@ -753,8 +753,8 @@ static val read_file_common(val self, val stream, val error_stream, val compiled val datavec = pop(&item); val funvec = car(item); val desc = vm_make_desc(nlevels, nregs, bytecode, datavec, funvec); - if ((big_endian && itypes_little_endian) || - (!big_endian && !itypes_little_endian)) + if ((big_endian && HAVE_LITTLE_ENDIAN) || + (!big_endian && !HAVE_LITTLE_ENDIAN)) buf_swap32(bytecode); (void) vm_execute_toplevel(desc); gc_hint(desc); |