First cut at the Code Generator using the TableGen methodology.
[oota-llvm.git] / include / Support / DataTypes.h
index b1b88790ac6bf89e89e3ace367109261e9c9dc4c..3d377bebe69d505a1fe05ba23fb65de6692a4034 100644 (file)
@@ -7,6 +7,7 @@
 //   LITTLE_ENDIAN: is #define'd if the host is little endian
 //   int64_t      : is a typedef for the signed 64 bit system type
 //   uint64_t     : is a typedef for the unsigned 64 bit system type
+//   INT64_MAX    : is a #define specifying the max value for int64_t's
 //
 // No library is required when using these functinons.
 //
 // TODO: This file sucks.  Not only does it not work, but this stuff should be
 // autoconfiscated anyways. Major FIXME
 
-
 #ifndef LLVM_SUPPORT_DATATYPES_H
 #define LLVM_SUPPORT_DATATYPES_H
 
+#define __STDC_LIMIT_MACROS 1
 #include <inttypes.h>
 
 #ifdef __linux__
-#define __STDC_LIMIT_MACROS 1
-#include <stdint.h>       // Defined by ISO C 99
-#include <endian.h>
-
+#  include <endian.h>
+#  if BYTE_ORDER == LITTLE_ENDIAN
+#    undef BIG_ENDIAN
+#  else
+#    undef LITTLE_ENDIAN
+#  endif
 #else
-#include <sys/types.h>
-#ifdef _LITTLE_ENDIAN
-#define LITTLE_ENDIAN 1
+#  if (BSD >= 199103)
+#    include <machine/endian.h>
+#  endif
 #endif
+
+#ifdef __sparc__
+#  include <sys/types.h>
+#  ifdef _LITTLE_ENDIAN
+#    define LITTLE_ENDIAN 1
+#  else
+#    define BIG_ENDIAN 1
+#  endif
+#endif
+
+#if (defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN))
+#error "Cannot define both LITTLE_ENDIAN and BIG_ENDIAN!"
 #endif
 
+#if (!defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)) || !defined(INT64_MAX)
+#error "include/Support/DataTypes.h could not determine endianness!"
 #endif
+
+#endif  /* LLVM_SUPPORT_DATATYPES_H */