[LLVMdev] Linux-x86 Compatability

Casey Carter ccarter at cs.uiuc.edu
Fri Sep 13 12:01:02 PDT 2002


Chris Lattner wrote:

>>test for linux / definition of __STDC_LIMIT_MACROS.  This will not work,
>>since stdint.h is implemented by including inttypes.h, which was already
>>included the first time with __STDC_LIMIT_MACROS not defined.  I think
>>the best solution to this problem is to change DataTypes.h to simply:
>>
>>  #define __STDC_LIMIT_MACROS
>>  #include <inttypes.h>
>>
>>Which will work on both Linux and Solaris without requiring platform detection.
>>    
>>
I forgot about endianness.

>Ok, how about this:?
>
>#ifndef LLVM_SUPPORT_DATATYPES_H
>#define LLVM_SUPPORT_DATATYPES_H
>
>#define __STDC_LIMIT_MACROS 1
>#include <inttypes.h>
>
>#ifdef __linux__
>#include <endian.h>
>#endif
>
>#ifdef __sparc__
>#include <sys/types.h>
>#ifdef _LITTLE_ENDIAN
>#define LITTLE_ENDIAN 1
>#endif
>#endif
>
>  
>
#ifndef LITTLE_ENDIAN
#ifndef BIG_ENDIAN
#error Ooops.  Fix include/llvm/Bytecode/Primitive.h for your endianness.
#endif
#endif

>#endif  /* LLVM_SUPPORT_DATATYPES_H */
>
>-Chris
>
>http://llvm.cs.uiuc.edu/
>http://www.nondot.org/~sabre/Projects/
>  
>


-- 
Casey Carter
Casey at Carter.net
ccarter at uiuc.edu
AIM: cartec69






More information about the llvm-dev mailing list