瀏覽代碼

limits.h: support gcc's -funsigned-char

some software apparently uses this and breaks with musl due to
mismatching definitions...
Rich Felker 13 年之前
父節點
當前提交
80949ccdc6
共有 1 個文件被更改,包括 10 次插入2 次删除
  1. 10 2
      include/limits.h

+ 10 - 2
include/limits.h

@@ -5,14 +5,22 @@
 
 
 #include <bits/limits.h>
 #include <bits/limits.h>
 
 
+/* Support signed or unsigned plain-char */
+
+#ifdef __CHAR_UNSIGNED__
+#define CHAR_MIN 0
+#define CHAR_MAX 255
+#else
+#define CHAR_MIN (-128)
+#define CHAR_MAX 127
+#endif
+
 /* Some universal constants... */
 /* Some universal constants... */
 
 
 #define CHAR_BIT 8
 #define CHAR_BIT 8
 #define SCHAR_MIN (-128)
 #define SCHAR_MIN (-128)
 #define SCHAR_MAX 127
 #define SCHAR_MAX 127
 #define UCHAR_MAX 255
 #define UCHAR_MAX 255
-#define CHAR_MIN (-128)
-#define CHAR_MAX 127
 #define SHRT_MIN  (-1-0x7fff)
 #define SHRT_MIN  (-1-0x7fff)
 #define SHRT_MAX  0x7fff
 #define SHRT_MAX  0x7fff
 #define USHRT_MAX 0xffff
 #define USHRT_MAX 0xffff