add new function
[oota-llvm.git] / include / Support / DataTypes.h
index 8a8952fb4ed3fcbfa489d9b637b195268f079c58..4904bb31daa9d0243637896ec022d0d96ca3fa76 100644 (file)
@@ -1,4 +1,11 @@
-//===-- include/Support/DataTypes.h - Define fixed size types ----*- C++ -*--=//
+//===-- include/Support/DataTypes.h - Define fixed size types ---*- C++ -*-===//
+// 
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// 
+//===----------------------------------------------------------------------===//
 //
 // This file contains definitions to figure out the size of _HOST_ data types.
 // This file is important because different host OS's define different macros,
 //
 //===----------------------------------------------------------------------===//
 
-// TODO: This file sucks.  Not only does it not work, but this stuff should be
-// autoconfiscated anyways. Major FIXME
+#ifndef SUPPORT_DATATYPES_H
+#define SUPPORT_DATATYPES_H
 
-#ifndef LLVM_SUPPORT_DATATYPES_H
-#define LLVM_SUPPORT_DATATYPES_H
-
-#define __STDC_LIMIT_MACROS 1
-#include <inttypes.h>
-
-#ifdef __linux__
-#  include <endian.h>
-#  if BYTE_ORDER == LITTLE_ENDIAN
-#    undef BIG_ENDIAN
-#  else
-#    undef LITTLE_ENDIAN
-#  endif
-#endif
+#include "Config/config.h"
 
-#ifdef __FreeBSD__
-#  include <machine/endian.h>
-#  if _BYTE_ORDER == _LITTLE_ENDIAN
-#    ifndef LITTLE_ENDIAN
-#      define LITTLE_ENDIAN 1
-#    endif
-#    ifdef BIG_ENDIAN
-#      undef BIG_ENDIAN
-#    endif
-#  else
-#    ifndef BIG_ENDIAN
-#      define BIG_ENDIAN 1
-#    endif
-#    ifdef LITTLE_ENDIAN
-#      undef LITTLE_ENDIAN
-#    endif
-#  endif
-#endif
+// Note that this header's correct operation depends on __STDC_LIMIT_MACROS
+// being defined.  We would define it here, but in order to prevent Bad Things
+// happening when system headers or C++ STL headers include stdint.h before
+// we define it here, we define it on the g++ command line (in Makefile.rules).
 
-#ifdef __sparc__
-#  include <sys/types.h>
-#  ifdef _LITTLE_ENDIAN
-#    define LITTLE_ENDIAN 1
-#  else
-#    define BIG_ENDIAN 1
-#  endif
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
 #endif
 
-//
-// Convert the information from the header files into our own local
-// endian macros.  We do this because various strange systems define both
-// BIG_ENDIAN and LITTLE_ENDIAN, and we don't want to conflict with them.
-//
-// Don't worry; once we introduce autoconf, this will look a lot nicer.
-// 
-#ifdef LITTLE_ENDIAN
-#define ENDIAN_LITTLE
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
 #endif
 
-#ifdef BIG_ENDIAN
-#define ENDIAN_BIG
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
 #endif
 
 #if (defined(ENDIAN_LITTLE) && defined(ENDIAN_BIG))
 #error "Cannot define both ENDIAN_LITTLE and ENDIAN_BIG!"
 #endif
 
-#if (!defined(ENDIAN_LITTLE) && !defined(ENDIAN_BIG)) || !defined(INT64_MAX)
+#if (!defined(ENDIAN_LITTLE) && !defined(ENDIAN_BIG))
 #error "include/Support/DataTypes.h could not determine endianness!"
 #endif
 
-#endif  /* LLVM_SUPPORT_DATATYPES_H */
+#if !defined(INT64_MAX)
+/* We couldn't determine INT64_MAX; default it. */
+#define INT64_MAX 9223372036854775807LL
+#endif
+#if !defined(UINT64_MAX)
+#define UINT64_MAX 0xffffffffffffffffULL
+#endif
+
+#endif  /* SUPPORT_DATATYPES_H */