aboutsummaryrefslogtreecommitdiff
path: root/fixincludes
diff options
context:
space:
mode:
Diffstat (limited to 'fixincludes')
-rw-r--r--fixincludes/ChangeLog21
-rw-r--r--fixincludes/fixfixes.c45
-rw-r--r--fixincludes/fixincl.x74
-rw-r--r--fixincludes/inclhack.def40
-rw-r--r--fixincludes/tests/base/inttypes.h22
-rw-r--r--fixincludes/tests/base/sys/socket.h1
-rw-r--r--fixincludes/tests/base/testing.h2
7 files changed, 191 insertions, 14 deletions
diff --git a/fixincludes/ChangeLog b/fixincludes/ChangeLog
index cc1fbe7..b57d9f1 100644
--- a/fixincludes/ChangeLog
+++ b/fixincludes/ChangeLog
@@ -1,3 +1,24 @@
+2021-08-30 John David Anglin <danglin@gcc.gnu.org>
+
+ * inclhack.def (hpux_c99_inttypes5): New hack to define PRIdPTR, etc.
+ * fixincl.x: Regenerate.
+ * tests/base/inttypes.h: Update.
+
+2021-07-06 Clément Chigot <clement.chigot@atos.net>
+
+ * inclhack.def (aix_externcpp1): Improve select regexp.
+ * fixincl.x: Regenerate.
+ * tests/base/sys/socket.h: Update.
+
+2021-06-30 Xi Ruoyao <xry111@mengyan1223.wang>
+
+ PR other/91085
+ * fixfixes.c (check_has_inc): New static function.
+ (machine_name_fix): Don't replace header names in
+ __has_include(...).
+ * inclhack.def (machine_name): Adjust test.
+ * tests/base/testing.h: Update.
+
2020-12-14 Ilya Leoshkevich <iii@linux.ibm.com>
* fixincl.x: Rerun genfixes.
diff --git a/fixincludes/fixfixes.c b/fixincludes/fixfixes.c
index 5b23a8b..404b420 100644
--- a/fixincludes/fixfixes.c
+++ b/fixincludes/fixfixes.c
@@ -477,6 +477,39 @@ FIX_PROC_HEAD( char_macro_def_fix )
fputs (text, stdout);
}
+/* Check if the pattern at pos is actually in a "__has_include(...)"
+ directive. Return the pointer to the ')' of this
+ "__has_include(...)" if it is, NULL otherwise. */
+static const char *
+check_has_inc (const char *begin, const char *pos, const char *end)
+{
+ static const char has_inc[] = "__has_include";
+ const size_t has_inc_len = sizeof (has_inc) - 1;
+ const char *p;
+
+ for (p = memmem (begin, pos - begin, has_inc, has_inc_len);
+ p != NULL;
+ p = memmem (p, pos - p, has_inc, has_inc_len))
+ {
+ p += has_inc_len;
+ while (p < end && ISSPACE (*p))
+ p++;
+
+ /* "__has_include" may appear as "defined(__has_include)",
+ search for the next appearance then. */
+ if (*p != '(')
+ continue;
+
+ /* To avoid too much complexity, just hope there is never a
+ ')' in a header name. */
+ p = memchr (p, ')', end - p);
+ if (p == NULL || p > pos)
+ return p;
+ }
+
+ return NULL;
+}
+
/* Fix for machine name #ifdefs that are not in the namespace reserved
by the C standard. They won't be defined if compiling with -ansi,
and the headers will break. We go to some trouble to only change
@@ -524,7 +557,7 @@ FIX_PROC_HEAD( machine_name_fix )
/* If the 'name_pat' matches in between base and limit, we have
a bogon. It is not worth the hassle of excluding comments
because comments on #if/#ifdef lines are rare, and strings on
- such lines are illegal.
+ such lines are only legal in a "__has_include" directive.
REG_NOTBOL means 'base' is not at the beginning of a line, which
shouldn't matter since the name_re has no ^ anchor, but let's
@@ -544,8 +577,16 @@ FIX_PROC_HEAD( machine_name_fix )
break;
p = base + match[0].rm_so;
- base += match[0].rm_eo;
+ /* Check if the match is in __has_include(...) (PR 91085). */
+ q = check_has_inc (base, p, limit);
+ if (q)
+ {
+ base = q + 1;
+ goto again;
+ }
+
+ base += match[0].rm_eo;
/* One more test: if on the same line we have the same string
with the appropriate underscores, then leave it alone.
We want exactly two leading and trailing underscores. */
diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x
index cc17edf..bc2fcd2 100644
--- a/fixincludes/fixincl.x
+++ b/fixincludes/fixincl.x
@@ -2,11 +2,11 @@
*
* DO NOT EDIT THIS FILE (fixincl.x)
*
- * It has been AutoGen-ed December 9, 2020 at 11:16:08 AM by AutoGen 5.18.16
+ * It has been AutoGen-ed August 30, 2021 at 07:31:11 PM by AutoGen 5.18.16
* From the definitions inclhack.def
* and the template file fixincl
*/
-/* DO NOT SVN-MERGE THIS FILE, EITHER Wed Dec 9 11:16:08 EST 2020
+/* DO NOT SVN-MERGE THIS FILE, EITHER Mon Aug 30 19:31:11 UTC 2021
*
* You must regenerate it. Use the ./genfixes script.
*
@@ -15,7 +15,7 @@
* certain ANSI-incompatible system header files which are fixed to work
* correctly with ANSI C and placed in a directory that GNU C will search.
*
- * This file contains 260 fixup descriptions.
+ * This file contains 261 fixup descriptions.
*
* See README for more information.
*
@@ -827,7 +827,8 @@ tSCC* apzAix_Externcpp1Machs[] = {
*/
tSCC zAix_Externcpp1Select0[] =
"#ifndef _KERNEL\n\
-#ifdef __cplusplus";
+#ifdef __cplusplus\n\
+extern \"C\" int naccept\\(int, struct sockaddr \\*, socklen_t \\*\\);";
#define AIX_EXTERNCPP1_TEST_CT 1
static tTestDesc aAix_Externcpp1Tests[] = {
@@ -840,7 +841,8 @@ static const char* apzAix_Externcpp1Patch[] = {
"format",
"#ifndef _KERNEL\n\
#ifdef __cplusplus\n\
-extern \"C++\" {",
+extern \"C++\" {\n\
+extern \"C\" int naccept(int, struct sockaddr *, socklen_t *);",
(char*)NULL };
/* * * * * * * * * * * * * * * * * * * * * * * * * *
@@ -5311,6 +5313,58 @@ static const char* apzHpux_C99_Inttypes4Patch[] = { sed_cmd_z,
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
+ * Description of Hpux_C99_Inttypes5 fix
+ */
+tSCC zHpux_C99_Inttypes5Name[] =
+ "hpux_c99_inttypes5";
+
+/*
+ * File name selection pattern
+ */
+tSCC zHpux_C99_Inttypes5List[] =
+ "inttypes.h\0";
+/*
+ * Machine/OS name selection pattern
+ */
+tSCC* apzHpux_C99_Inttypes5Machs[] = {
+ "hppa*-hp-hpux11.[01]*",
+ (const char*)NULL };
+
+/*
+ * content selection pattern - do fix if pattern found
+ */
+tSCC zHpux_C99_Inttypes5Select0[] =
+ "#ifndef[ \t]_KERNEL[ \t]*\n";
+
+#define HPUX_C99_INTTYPES5_TEST_CT 1
+static tTestDesc aHpux_C99_Inttypes5Tests[] = {
+ { TT_EGREP, zHpux_C99_Inttypes5Select0, (regex_t*)NULL }, };
+
+/*
+ * Fix Command Arguments for Hpux_C99_Inttypes5
+ */
+static const char* apzHpux_C99_Inttypes5Patch[] = {
+ "format",
+ "#ifndef __LP64__\n\
+#define PRIdPTR\t\tPRId32\n\
+#define PRIiPTR\t\tPRIi32\n\
+#define PRIoPTR\t\tPRIo32\n\
+#define PRIuPTR\t\tPRIu32\n\
+#define PRIxPTR\t\tPRIx32\n\
+#define PRIXPTR\t\tPRIX32\n\
+#else\n\
+#define PRIdPTR\t\tPRId64\n\
+#define PRIiPTR\t\tPRIi64\n\
+#define PRIoPTR\t\tPRIo64\n\
+#define PRIuPTR\t\tPRIu64\n\
+#define PRIxPTR\t\tPRIx64\n\
+#define PRIXPTR\t\tPRIX64\n\
+#endif\n\n\
+#ifndef _KERNEL\n",
+ (char*)NULL };
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
* Description of Hpux_Ctype_Macros fix
*/
tSCC zHpux_Ctype_MacrosName[] =
@@ -10558,9 +10612,9 @@ static const char* apzX11_SprintfPatch[] = {
*
* List of all fixes
*/
-#define REGEX_COUNT 298
+#define REGEX_COUNT 299
#define MACH_LIST_SIZE_LIMIT 187
-#define FIX_COUNT 260
+#define FIX_COUNT 261
/*
* Enumerate the fixes
@@ -10693,6 +10747,7 @@ typedef enum {
HPUX_C99_INTTYPES2_FIXIDX,
HPUX_C99_INTTYPES3_FIXIDX,
HPUX_C99_INTTYPES4_FIXIDX,
+ HPUX_C99_INTTYPES5_FIXIDX,
HPUX_CTYPE_MACROS_FIXIDX,
HPUX_EXTERN_ERRNO_FIXIDX,
HPUX_HTONL_FIXIDX,
@@ -11464,6 +11519,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
HPUX_C99_INTTYPES4_TEST_CT, FD_MACH_ONLY,
aHpux_C99_Inttypes4Tests, apzHpux_C99_Inttypes4Patch, 0 },
+ { zHpux_C99_Inttypes5Name, zHpux_C99_Inttypes5List,
+ apzHpux_C99_Inttypes5Machs,
+ HPUX_C99_INTTYPES5_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+ aHpux_C99_Inttypes5Tests, apzHpux_C99_Inttypes5Patch, 0 },
+
{ zHpux_Ctype_MacrosName, zHpux_Ctype_MacrosList,
apzHpux_Ctype_MacrosMachs,
HPUX_CTYPE_MACROS_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
index 3a4cfe0..46e3b8c 100644
--- a/fixincludes/inclhack.def
+++ b/fixincludes/inclhack.def
@@ -554,13 +554,16 @@ fix = {
mach = "*-*-aix*";
files = "sys/socket.h";
select = "#ifndef _KERNEL\n"
- "#ifdef __cplusplus";
+ "#ifdef __cplusplus\n"
+ "extern \"C\" int naccept\\(int, struct sockaddr \\*, socklen_t \\*\\);";
c_fix = format;
c_fix_arg = "#ifndef _KERNEL\n"
"#ifdef __cplusplus\n"
- "extern \"C++\" {";
+ "extern \"C++\" {\n"
+ "extern \"C\" int naccept(int, struct sockaddr *, socklen_t *);";
test_text = "#ifndef _KERNEL\n"
- "#ifdef __cplusplus";
+ "#ifdef __cplusplus\n"
+ "extern \"C\" int naccept(int, struct sockaddr *, socklen_t *);";
};
fix = {
@@ -2666,6 +2669,34 @@ fix = {
};
/*
+ * Fix missing PRIdPTR defines in inttypes.h
+ */
+fix = {
+ hackname = hpux_c99_inttypes5;
+ mach = "hppa*-hp-hpux11.[01]*";
+ files = inttypes.h;
+ select = "#ifndef[ \t]_KERNEL[ \t]*\n";
+ c_fix = format;
+ c_fix_arg = "#ifndef __LP64__\n"
+ "#define PRIdPTR\t\tPRId32\n"
+ "#define PRIiPTR\t\tPRIi32\n"
+ "#define PRIoPTR\t\tPRIo32\n"
+ "#define PRIuPTR\t\tPRIu32\n"
+ "#define PRIxPTR\t\tPRIx32\n"
+ "#define PRIXPTR\t\tPRIX32\n"
+ "#else\n"
+ "#define PRIdPTR\t\tPRId64\n"
+ "#define PRIiPTR\t\tPRIi64\n"
+ "#define PRIoPTR\t\tPRIo64\n"
+ "#define PRIuPTR\t\tPRIu64\n"
+ "#define PRIxPTR\t\tPRIx64\n"
+ "#define PRIXPTR\t\tPRIX64\n"
+ "#endif\n\n"
+ "#ifndef _KERNEL\n";
+ test_text = "#ifndef _KERNEL\n";
+};
+
+/*
* Fix hpux broken ctype macros
*/
fix = {
@@ -3151,7 +3182,8 @@ fix = {
c_fix = machine_name;
test_text = "/* MACH_DIFF: */\n"
- "#if defined( i386 ) || defined( sparc ) || defined( vax )"
+ "#if defined( i386 ) || defined( sparc ) || defined( vax ) || "
+ "defined( linux ) || __has_include ( <linux.h> )"
"\n/* no uniform test, so be careful :-) */";
};
diff --git a/fixincludes/tests/base/inttypes.h b/fixincludes/tests/base/inttypes.h
index 144ea65..9c1f93e 100644
--- a/fixincludes/tests/base/inttypes.h
+++ b/fixincludes/tests/base/inttypes.h
@@ -42,3 +42,25 @@
#define SCNuMAX SCNu32
#endif /* HPUX_C99_INTTYPES4_CHECK */
+
+
+#if defined( HPUX_C99_INTTYPES5_CHECK )
+#ifndef __LP64__
+#define PRIdPTR PRId32
+#define PRIiPTR PRIi32
+#define PRIoPTR PRIo32
+#define PRIuPTR PRIu32
+#define PRIxPTR PRIx32
+#define PRIXPTR PRIX32
+#else
+#define PRIdPTR PRId64
+#define PRIiPTR PRIi64
+#define PRIoPTR PRIo64
+#define PRIuPTR PRIu64
+#define PRIxPTR PRIx64
+#define PRIXPTR PRIX64
+#endif
+
+#ifndef _KERNEL
+
+#endif /* HPUX_C99_INTTYPES5_CHECK */
diff --git a/fixincludes/tests/base/sys/socket.h b/fixincludes/tests/base/sys/socket.h
index c1e2b42..588a378 100644
--- a/fixincludes/tests/base/sys/socket.h
+++ b/fixincludes/tests/base/sys/socket.h
@@ -13,6 +13,7 @@
#ifndef _KERNEL
#ifdef __cplusplus
extern "C++" {
+extern "C" int naccept(int, struct sockaddr *, socklen_t *);
#endif /* AIX_EXTERNCPP1_CHECK */
diff --git a/fixincludes/tests/base/testing.h b/fixincludes/tests/base/testing.h
index cf95321..8b3acca 100644
--- a/fixincludes/tests/base/testing.h
+++ b/fixincludes/tests/base/testing.h
@@ -64,7 +64,7 @@ BSD43__IOWR('T', 1) /* Some are multi-line */
#if defined( MACHINE_NAME_CHECK )
/* MACH_DIFF: */
-#if defined( i386 ) || defined( sparc ) || defined( vax )
+#if defined( i386 ) || defined( sparc ) || defined( vax ) || defined( linux ) || __has_include ( <linux.h> )
/* no uniform test, so be careful :-) */
#endif /* MACHINE_NAME_CHECK */