summaryrefslogtreecommitdiff
path: root/ldso/util/bswap.h
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-08-08 14:28:47 +0000
committerEric Andersen <andersen@codepoet.org>2002-08-08 14:28:47 +0000
commit4c69b9f793fc1eae9190d8ba26dba25db616272f (patch)
tree0029a765f3402cdbef9bb2f384c8a067e1ed17c0 /ldso/util/bswap.h
parente3787b675f1a369697d97ba8e65bf6ba80ace51d (diff)
Patch from Stefan Allius and Edie C. Dost to let ldd and
readelf compile under solaris.
Diffstat (limited to 'ldso/util/bswap.h')
-rw-r--r--ldso/util/bswap.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/ldso/util/bswap.h b/ldso/util/bswap.h
new file mode 100644
index 000000000..71867885e
--- /dev/null
+++ b/ldso/util/bswap.h
@@ -0,0 +1,56 @@
+#ifndef _BSWAP_H
+#define _BSWAP_H 1
+
+#if !defined(__BYTE_ORDER) && defined(BYTE_ORDER)
+# define __BYTE_ORDER = BYTE_ORDER
+#endif
+
+#ifndef __BYTE_ORDER
+#ifdef linux
+#include <endian.h>
+#else
+#define __LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
+#define __BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
+#define __PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */
+
+#if defined(sun386) || defined(i386)
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#endif
+
+#if defined(sparc)
+#define __BYTE_ORDER __BIG_ENDIAN
+#endif
+
+#endif /* linux */
+#endif /* __BYTE_ORDER */
+
+
+#ifndef __BYTE_ORDER
+# error "Undefined __BYTE_ORDER"
+#endif
+
+#ifdef linux
+#include <byteswap.h>
+#else
+#include <string.h>
+static __inline__ uint32_t bswap_32(uint32_t x)
+ {
+ uint32_t res;
+
+ swab((void*)&x, (void*)&res, sizeof(uint32_t));
+ printf ("bswap_32: %x > %x\n",x,res);
+
+ return res;
+ }
+
+static __inline__ uint16_t bswap_16(uint16_t x)
+ {
+ uint16_t res;
+
+ swab((void*)&x, (void*)&res, sizeof(uint16_t));
+ printf ("bswap_32: %x > %x\n",x,res);
+ return res;
+ }
+#endif
+
+#endif