[cfe-commits] r130618 - in /cfe/trunk: lib/Headers/stdint.h test/Preprocessor/stdint.c
Eli Friedman
eli.friedman at gmail.com
Sat Apr 30 12:02:59 PDT 2011
Author: efriedma
Date: Sat Apr 30 14:02:59 2011
New Revision: 130618
URL: http://llvm.org/viewvc/llvm-project?rev=130618&view=rev
Log:
Some small improvements to the builtin (-ffreestanding) stdint.h; in
particular, make sure to handle WCHAR_MIN correctly.
Modified:
cfe/trunk/lib/Headers/stdint.h
cfe/trunk/test/Preprocessor/stdint.c
Modified: cfe/trunk/lib/Headers/stdint.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/stdint.h?rev=130618&r1=130617&r2=130618&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/stdint.h (original)
+++ cfe/trunk/lib/Headers/stdint.h Sat Apr 30 14:02:59 2011
@@ -609,11 +609,15 @@
# define UINT_FAST8_MAX __UINT_LEAST8_MAX
#endif /* __INT_LEAST8_MIN */
+/* Some utility macros */
+#define __INTN_MIN(n) __stdint_join3( INT, n, _MIN)
+#define __INTN_MAX(n) __stdint_join3( INT, n, _MAX)
+#define __UINTN_MAX(n) __stdint_join3(UINT, n, _MAX)
+#define __INTN_C(n, v) __stdint_join3( INT, n, _C(v))
+#define __UINTN_C(n, v) __stdint_join3(UINT, n, _C(v))
+
/* C99 7.18.2.4 Limits of integer types capable of holding object pointers. */
/* C99 7.18.3 Limits of other integer types. */
-#define __INTN_MIN(n) __stdint_join3( INT, n, _MIN)
-#define __INTN_MAX(n) __stdint_join3( INT, n, _MAX)
-#define __UINTN_MAX(n) __stdint_join3(UINT, n, _MAX)
#define INTPTR_MIN __INTN_MIN(__INTPTR_WIDTH__)
#define INTPTR_MAX __INTN_MAX(__INTPTR_WIDTH__)
@@ -631,27 +635,25 @@
#define SIG_ATOMIC_MIN __INTN_MIN(__SIG_ATOMIC_WIDTH__)
#define SIG_ATOMIC_MAX __INTN_MAX(__SIG_ATOMIC_WIDTH__)
#ifdef __WINT_UNSIGNED__
-# define WINT_MIN 0
+# define WINT_MIN __UINTN_C(__WINT_WIDTH__, 0)
# define WINT_MAX __UINTN_MAX(__WINT_WIDTH__)
#else
# define WINT_MIN __INTN_MIN(__WINT_WIDTH__)
# define WINT_MAX __INTN_MAX(__WINT_WIDTH__)
#endif
-/* FIXME: if we ever support a target with unsigned wchar_t, this should be
- * 0 .. Max.
- */
#ifndef WCHAR_MAX
-#define WCHAR_MAX __INTN_MAX(__WCHAR_WIDTH__)
+# define WCHAR_MAX __WCHAR_MAX__
#endif
#ifndef WCHAR_MIN
-#define WCHAR_MIN __INTN_MIN(__WCHAR_WIDTH__)
+# if __WCHAR_MAX__ == __INTN_MAX(__WCHAR_WIDTH__)
+# define WCHAR_MIN __INTN_MIN(__WCHAR_WIDTH__)
+# else
+# define WCHAR_MIN __UINTN_C(__WCHAR_WIDTH__, 0)
+# endif
#endif
/* 7.18.4.2 Macros for greatest-width integer constants. */
-#define __INTN_C(n, v) __stdint_join3( INT, n, _C(v))
-#define __UINTN_C(n, v) __stdint_join3(UINT, n, _C(v))
-
#define INTMAX_C(v) __INTN_C(__INTMAX_WIDTH__, v)
#define UINTMAX_C(v) __UINTN_C(__INTMAX_WIDTH__, v)
Modified: cfe/trunk/test/Preprocessor/stdint.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/stdint.c?rev=130618&r1=130617&r2=130618&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/stdint.c (original)
+++ cfe/trunk/test/Preprocessor/stdint.c Sat Apr 30 14:02:59 2011
@@ -1061,10 +1061,16 @@
//
// RUN: %clang_cc1 -E -ffreestanding -triple=x86_64-pc-linux-gnu %s | FileCheck -check-prefix X86_64_LINUX %s
//
-// X86_64_LINUX:WINT_MIN_ 0
+// X86_64_LINUX:WINT_MIN_ 0U
// X86_64_LINUX:WINT_MAX_ 4294967295U
//
//
+// RUN: %clang_cc1 -E -ffreestanding -triple=i386-mingw32 %s | FileCheck -check-prefix I386_MINGW32 %s
+//
+// I386_MINGW32:WCHAR_MAX_ 65535U
+// I386_MINGW32:WCHAR_MIN_ 0U
+//
+//
// stdint.h forms several macro definitions by pasting together identifiers
// to form names (eg. int32_t is formed from int ## 32 ## _t). The following
// case tests that these joining operations are performed correctly even if
More information about the cfe-commits
mailing list