summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-06-19 06:29:45 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-06-19 06:29:45 -0700
commit09091bedcc6dd570262de4a72c362b161a492df7 (patch)
tree5d68d965c3a7b28a7908254cbe3e9e3e9b9589aa
parent2f2d654c20c75a7cc6e5c1c28803f475c929abba (diff)
downloadtxr-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.c15
-rw-r--r--itypes.h3
-rw-r--r--lib.c1
-rw-r--r--parser.c4
4 files changed, 2 insertions, 21 deletions
diff --git a/itypes.c b/itypes.c
index ba8705e2..51cbb7cd 100644
--- a/itypes.c
+++ b/itypes.c
@@ -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);
-}
diff --git a/itypes.h b/itypes.h
index 0991b1cd..5cbc3ea1 100644
--- a/itypes.h
+++ b/itypes.h
@@ -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);
diff --git a/lib.c b/lib.c
index 486ceee8..c2180abb 100644
--- a/lib.c
+++ b/lib.c
@@ -13086,7 +13086,6 @@ void init(val *stack_bottom)
hash_init();
struct_init();
tree_init();
- itypes_init();
buf_init();
ffi_init();
sysif_init();
diff --git a/parser.c b/parser.c
index 7698ac24..c1984a07 100644
--- a/parser.c
+++ b/parser.c
@@ -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);