[llvm-commits] [compiler-rt] r151159 - in /compiler-rt/trunk/lib/asan: asan_interceptors.cc asan_internal.h
Alexey Samsonov
samsonov at google.com
Wed Feb 22 04:54:05 PST 2012
Author: samsonov
Date: Wed Feb 22 06:54:04 2012
New Revision: 151159
URL: http://llvm.org/viewvc/llvm-project?rev=151159&view=rev
Log:
AddressSanitizer: get rid of limits.h, use constants for fixed size integral types instead.
Modified:
compiler-rt/trunk/lib/asan/asan_interceptors.cc
compiler-rt/trunk/lib/asan/asan_internal.h
Modified: compiler-rt/trunk/lib/asan/asan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.cc?rev=151159&r1=151158&r2=151159&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Wed Feb 22 06:54:04 2012
@@ -24,7 +24,6 @@
#include "interception/interception.h"
#include <new>
-#include <limits.h>
#if defined(_WIN32)
// FIXME: remove when we start intercepting on Windows. Currently it's needed to
@@ -132,9 +131,9 @@
nptr++;
}
while (IsDigit(*nptr)) {
- res = (res <= ULLONG_MAX / 10) ? res * 10 : ULLONG_MAX;
+ res = (res <= UINT64_MAX / 10) ? res * 10 : UINT64_MAX;
int digit = ((*nptr) - '0');
- res = (res <= ULLONG_MAX - digit) ? res + digit : ULLONG_MAX;
+ res = (res <= UINT64_MAX - digit) ? res + digit : UINT64_MAX;
have_digits = true;
nptr++;
}
@@ -142,9 +141,9 @@
*endptr = (have_digits) ? (char*)nptr : old_nptr;
}
if (sgn > 0) {
- return (int64_t)(Min((uint64_t)LLONG_MAX, res));
+ return (int64_t)(Min((uint64_t)INT64_MAX, res));
} else {
- return (res > LLONG_MAX) ? LLONG_MIN : ((int64_t)res * -1);
+ return (res > INT64_MAX) ? INT64_MIN : ((int64_t)res * -1);
}
}
Modified: compiler-rt/trunk/lib/asan/asan_internal.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=151159&r1=151158&r2=151159&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_internal.h (original)
+++ compiler-rt/trunk/lib/asan/asan_internal.h Wed Feb 22 06:54:04 2012
@@ -59,6 +59,22 @@
#endif
#endif
+// Limits for integral types. We have to redefine it in case we don't
+// have stdint.h (like in Visual Studio 9).
+#if __WORDSIZE == 64
+# define __INT64_C(c) c ## L
+# define __UINT64_C(c) c ## UL
+#else
+# define __INT64_C(c) c ## LL
+# define __UINT64_C(c) c ## ULL
+#endif // __WORDSIZE == 64
+# define INT32_MIN (-2147483647-1)
+# define INT32_MAX (2147483647)
+# define UINT32_MAX (4294967295U)
+# define INT64_MIN (-__INT64_C(9223372036854775807)-1)
+# define INT64_MAX (__INT64_C(9223372036854775807))
+# define UINT64_MAX (__UINT64_C(18446744073709551615))
+
#if defined(__linux__)
# define ASAN_LINUX 1
#else
More information about the llvm-commits
mailing list