[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 18/86: Add endian.h
From: |
Andy Wingo |
Subject: |
[Guile-commits] 18/86: Add endian.h |
Date: |
Wed, 3 Apr 2019 11:38:51 -0400 (EDT) |
wingo pushed a commit to branch lightening
in repository guile.
commit 17a38ffd9c02a938726d8bb7154d8991704ed8cf
Author: Andy Wingo <address@hidden>
Date: Tue Oct 30 13:54:48 2018 +0100
Add endian.h
---
jit/endian.h | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 110 insertions(+)
diff --git a/jit/endian.h b/jit/endian.h
new file mode 100644
index 0000000..b9b1a91
--- /dev/null
+++ b/jit/endian.h
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2012-2018 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU lightning.
+ *
+ * GNU lightning is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU lightning is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * Authors:
+ * Paulo Cesar Pereira de Andrade
+ * Andy Wingo
+ */
+
+#ifndef _jit_endian_h
+#define _jit_endian_h
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <stddef.h>
+
+#if defined(__hpux) && defined(__hppa__)
+# include <machine/param.h>
+#endif
+#if defined(__alpha__) && defined(__osf__)
+# include <machine/endian.h>
+#endif
+
+#ifndef __WORDSIZE
+# if defined(WORDSIZE) /* ppc darwin */
+# define __WORDSIZE WORDSIZE
+# elif defined(__SIZEOF_POINTER__) /* ppc aix */
+# define __WORDSIZE (__SIZEOF_POINTER__ << 3)
+# elif defined(_ILP32) /* hppa hp-ux */
+# define __WORDSIZE 32
+# elif defined(_LP64) /* ia64 hp-ux (with cc +DD64) */
+# define __WORDSIZE 64
+# elif defined(_MIPS_SZPTR) /* mips irix */
+# if _MIPS_SZPTR == 32
+# define __WORDSIZE 32
+# else
+# define __WORDSIZE 64
+# endif
+# else /* From FreeBSD 9.1
stdint.h */
+# if defined(UINTPTR_MAX) && defined(UINT64_MAX) && \
+ (UINTPTR_MAX == UINT64_MAX)
+# define __WORDSIZE 64
+# else
+# define __WORDSIZE 32
+# endif
+# endif
+#endif
+#ifndef __LITTLE_ENDIAN
+# if defined(LITTLE_ENDIAN) /* ppc darwin */
+# define __LITTLE_ENDIAN LITTLE_ENDIAN
+# elif defined(__ORDER_LITTLE_ENDIAN__) /* ppc aix */
+# define __LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
+# else
+# define __LITTLE_ENDIAN 1234
+# endif
+#endif
+#ifndef __BIG_ENDIAN
+# if defined(BIG_ENDIAN) /* ppc darwin */
+# define __BIG_ENDIAN BIG_ENDIAN
+# elif defined(__ORDER_BIG_ENDIAN__) /* ppc aix */
+# define __BIG_ENDIAN __ORDER_BIG_ENDIAN__
+# else
+# define __BIG_ENDIAN 4321
+# endif
+#endif
+#ifndef __BYTE_ORDER
+# if defined(BYTE_ORDER) /* ppc darwin */
+# define __BYTE_ORDER BYTE_ORDER
+# elif defined(__BYTE_ORDER__) /* ppc aix */
+# define __BYTE_ORDER __BYTE_ORDER__
+# elif defined(_BIG_ENDIAN) /* hppa hp-ux */
+# define __BYTE_ORDER __BIG_ENDIAN
+# elif defined(__BIG_ENDIAN__) /* ia64 hp-ux */
+# define __BYTE_ORDER __BIG_ENDIAN
+# elif defined(__i386__) /* 32 bit x86 solaris */
+# define __BYTE_ORDER __LITTLE_ENDIAN
+# elif defined(__x86_64__) /* 64 bit x86 solaris */
+# define __BYTE_ORDER __LITTLE_ENDIAN
+# elif defined(__MIPSEB) /* mips irix */
+# define __BYTE_ORDER __BIG_ENDIAN
+# else
+# error cannot figure __BYTE_ORDER
+# endif
+#endif
+
+#if __WORDSIZE == 32
+#define CHOOSE_32_64(x, y) x
+#elif __WORDSIZE == 64
+#define CHOOSE_32_64(x, y) y
+#else
+#error unhandled __WORDSIZE
+#endif
+
+#define WHEN_64(x) CHOOSE_32_64(/**/, x)
+
+
+#endif /* _jit_endian_h */
- [Guile-commits] 23/86: Update gitignore, (continued)
- [Guile-commits] 23/86: Update gitignore, Andy Wingo, 2019/04/03
- [Guile-commits] 03/86: Strip "get-jit-size" feature from lightning., Andy Wingo, 2019/04/03
- [Guile-commits] 25/86: Remove needless PUBLIC/HIDDEN definitions, Andy Wingo, 2019/04/03
- [Guile-commits] 19/86: Update call/receive machinery, Andy Wingo, 2019/04/03
- [Guile-commits] 10/86: Remove autotools, Andy Wingo, 2019/04/03
- [Guile-commits] 21/86: "extern"-related cleanup, and further implementation, Andy Wingo, 2019/04/03
- [Guile-commits] 27/86: Make _rvs array static-const, Andy Wingo, 2019/04/03
- [Guile-commits] 11/86: Rename include to jit.h, move all files to jit/, Andy Wingo, 2019/04/03
- [Guile-commits] 33/86: Flesh out README, Andy Wingo, 2019/04/03
- [Guile-commits] 36/86: Add more tests, Andy Wingo, 2019/04/03
- [Guile-commits] 18/86: Add endian.h,
Andy Wingo <=
- [Guile-commits] 30/86: Add "addi" test, Andy Wingo, 2019/04/03
- [Guile-commits] 31/86: Better loading of args to registers; add tests, Andy Wingo, 2019/04/03
- [Guile-commits] 26/86: Inline private.h into jit.c, Andy Wingo, 2019/04/03
- [Guile-commits] 32/86: Convert tests to jit_load_args, Andy Wingo, 2019/04/03
- [Guile-commits] 34/86: Add note about current status, Andy Wingo, 2019/04/03
- [Guile-commits] 14/86: Simplify file names, Andy Wingo, 2019/04/03
- [Guile-commits] 39/86: Add remr tests, Andy Wingo, 2019/04/03
- [Guile-commits] 37/86: Tests for some div operations, Andy Wingo, 2019/04/03
- [Guile-commits] 35/86: Add new tests, Andy Wingo, 2019/04/03
- [Guile-commits] 28/86: Beginnings of port of x86 to new design, Andy Wingo, 2019/04/03