ISSUE: INT64_MAX undefined in InstrSelectionSupport.cpp and InstructionCombining.cpp. I'm not completely sure where INT64_MAX comes from on Solaris, but C99 says that INT64_MAX is defined in stdint.h, but, for C++, only if __STDC_LIMIT_MACROS is #defined. Solaris (at least in CSIL) unfortunately does not have stdint.h, but it does have the old inttypes.h - and so does Linux.
ACTION: In files that refer to INT64_MAX, ensure that inttypes.h is #included and that __STD_LIMIT_MACROS is #defined before _any_ #include (you never know which header includes what header on whatever system, so paranoia is good).
PATCH: Apply from llvm top level directory with "patch -p0."
patch (1.37 KB)
ISSUE: INT64_MAX undefined in InstrSelectionSupport.cpp and
InstructionCombining.cpp. I'm not completely sure where INT64_MAX comes
from on Solaris, but C99 says that INT64_MAX is defined in stdint.h,
but, for C++, only if __STDC_LIMIT_MACROS is #defined. Solaris (at
least in CSIL) unfortunately does not have stdint.h, but it does have
the old inttypes.h - and so does Linux.
Interesting. INT64_MAX is supposed to be provided by
include/Support/DataTypes.h. Do you know of a reliable preprocessor
symbol that can be used to determine whether we're on a linux box, or
(better yet) whether the system has a valid <stdint.h>?
Thanks,
-Chris
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/
Chris Lattner wrote:
ISSUE: INT64_MAX undefined in InstrSelectionSupport.cpp and
InstructionCombining.cpp. I'm not completely sure where INT64_MAX comes
from on Solaris, but C99 says that INT64_MAX is defined in stdint.h,
but, for C++, only if __STDC_LIMIT_MACROS is #defined. Solaris (at
least in CSIL) unfortunately does not have stdint.h, but it does have
the old inttypes.h - and so does Linux.
Interesting. INT64_MAX is supposed to be provided by
include/Support/DataTypes.h. Do you know of a reliable preprocessor
symbol that can be used to determine whether we're on a linux box, or
Well, there is always __linux__, but that doesn't necessarily imply that we are on a Linux box with stdint.h.
(better yet) whether the system has a valid <stdint.h>?
Nope. Autoconf is definitely the way to go here (even though converting is a pain).
>Interesting. INT64_MAX is supposed to be provided by
>include/Support/DataTypes.h. Do you know of a reliable preprocessor
>symbol that can be used to determine whether we're on a linux box, or
Well, there is always __linux__, but that doesn't necessarily imply that
we are on a Linux box with stdint.h.
Ok, I'll switch to that from the placeholder "LINUX".
>(better yet) whether the system has a valid <stdint.h>?
Nope. Autoconf is definitely the way to go here (even though converting
is a pain).
Agreed. We plan to autoconfiscate LLVM eventually, but it won't get
started for quite some time. In the meantime, the #ifdef __linux__ hack
should be sufficient.
Thanks for the help,
-Chris
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/
Is the #include <endian.h> necessary for Linux or is that a leftover
artifact from before? I'm trying to get this code to compile on MacOS
(which is based on BSD), and stdint.h exists there, but not endian.h.
--Vikram
Chris Lattner wrote:
Interesting. INT64_MAX is supposed to be provided by
include/Support/DataTypes.h. Do you know of a reliable preprocessor
symbol that can be used to determine whether we're on a linux box, or
Well, there is always __linux__, but that doesn't necessarily imply that
we are on a Linux box with stdint.h.s
Ok, I'll switch to that from the placeholder "LINUX".
Inspection of DataTypes.h shows that inttypes.h is included before the 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.
Is the #include <endian.h> necessary for Linux or is that a leftover
artifact from before? I'm trying to get this code to compile on MacOS
(which is based on BSD), and stdint.h exists there, but not endian.h.
I think that it was required under linux to get the LITTLE_ENDIAN #define.
Alternatively, under linux, #including ctype.h will work (because it
includes endian.h).
Do you know how to figure out endianness on BSD?
-Chris
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.
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
#endif /* LLVM_SUPPORT_DATATYPES_H */
-Chris
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/
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
#ifndef LITTLE_ENDIAN
#ifndef BIG_ENDIAN
#error Ooops. Fix include/llvm/Bytecode/Primitive.h for your endianness.
#endif
#ifndef LITTLE_ENDIAN
#ifndef BIG_ENDIAN
#error Ooops. Fix include/llvm/Bytecode/Primitive.h for your endianness.
#endif
#endif
Ok, this is what I committed:
http://mail.cs.uiuc.edu/pipermail/llvm-commits/2002-September/000172.html
-Chris
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/