aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/a_embedfilesdir.c44
-rw-r--r--src/c_lex.c4
2 files changed, 39 insertions, 9 deletions
diff --git a/src/a_embedfilesdir.c b/src/a_embedfilesdir.c
index 407a4f2..2e1edd9 100644
--- a/src/a_embedfilesdir.c
+++ b/src/a_embedfilesdir.c
@@ -117,6 +117,35 @@ typedef __builtin_va_list __gnuc_va_list;\n\
{"limits.h", S("\
#pragma once\n\
+/* Tell glibc not to try to recursively #include_next gcc's <limits.h> */\n\
+#if defined __GNUC__ && !defined _GCC_LIMITS_H\n\
+#define _GCC_LIMITS_H_\n\
+#endif\n\
+/* We want the system libc header for POSIX constants */\n\
+#ifdef __STDC_HOSTED__\n\
+#include_next <limits.h>\n\
+#endif\n\
+\n\
+#undef CHAR_BIT\n\
+#undef CHAR_MAX\n\
+#undef CHAR_MIN\n\
+#undef UCHAR_MAX\n\
+#undef SCHAR_MAX\n\
+#undef SCHAR_MIN\n\
+#undef USHRT_MAX\n\
+#undef SHRT_MAX\n\
+#undef SHRT_MIN\n\
+#undef MB_LEN_MAX\n\
+#undef UINT_MAX\n\
+#undef INT_MAX\n\
+#undef INT_MIN\n\
+#undef ULONG_MAX\n\
+#undef LONG_MAX\n\
+#undef LONG_MIN\n\
+#undef ULLONG_MAX\n\
+#undef LLONG_MAX\n\
+#undef LLONG_MIN\n\
+\n\
#define CHAR_BIT 8\n\
#ifdef __CHAR_UNSIGNED__\n\
#define CHAR_MAX UCHAR_MAX\n\
@@ -126,24 +155,23 @@ typedef __builtin_va_list __gnuc_va_list;\n\
#define CHAR_MIN SCHAR_MIN\n\
#endif\n\
#define UCHAR_MAX 255\n\
-#define SCHAR_MAX +127\n\
+#define SCHAR_MAX 127\n\
#define SCHAR_MIN (-128)\n\
#define USHRT_MAX 65535\n\
#define SHRT_MAX 32767\n\
#define SHRT_MIN (-32768)\n\
#define MB_LEN_MAX 16\n\
-#define UINT_MAX 4294967295\n\
+#define UINT_MAX 4294967295U\n\
#define INT_MAX 2147483647\n\
#define INT_MIN (-INT_MAX - 1)\n\
#if __SIZEOF_LONG__ == __SIZEOF__INT__\n\
-#define ULONG_MAX UINT_MAX\n\
-#define LONG_MAX INT_MAX\n\
-#define LONG_MIN INT_MIN\n\
+#define ULONG_MAX 4294967295UL\n\
+#define LONG_MAX 2147483647L\n\
#else\n\
-#define ULONG_MAX ULLONG_MAX\n\
-#define LONG_MAX LLONG_MAX\n\
-#define LONG_MIN LLONG_MIN\n\
+#define ULONG_MAX 18446744073709551615UL\n\
+#define LONG_MAX 9223372036854775807L\n\
#endif\n\
+#define LONG_MIN (-LONG_MAX - 1L)\n\
#define ULLONG_MAX 18446744073709551615ULL\n\
#define LLONG_MAX 9223372036854775807LL\n\
#define LLONG_MIN (-LLONG_MAX-1)\n\
diff --git a/src/c_lex.c b/src/c_lex.c
index d1cbd55..7ff13bd 100644
--- a/src/c_lex.c
+++ b/src/c_lex.c
@@ -1850,9 +1850,11 @@ doinclude(Lexer *lx, const Span *span, bool quote, const char *str, size_t slen,
*/
for (int i = quote ? CINCL_iquote : CINCL_I; i < countof(cinclpaths); ++i) {
incdiridx = 2 + 1000*i;
+ bool triedembed = 0;
for (CInclPath *p = cinclpaths[i]; p; p = p->next) {
- if (i == CINCLsys) {
+ if (i == CINCLsys && !triedembed) {
/* try embedded files pseudo-path */
+ triedembed = 1;
if (incdiridx >= req_incdiridx) {
xbgrow(&path, slen + 3);
path[0] = '@', path[1] = ':';