Patchwork : Add include hacks for VMS headers

login
register
mail settings
Submitter Tristan Gingold
Date March 12, 2012, 10:05 a.m.
Message ID <67DFA492-9995-4C03-8B0B-5F87B4AE8F64@adacore.com>
Download mbox | patch
Permalink /patch/146053/
State New
Headers show

Comments

Tristan Gingold - March 12, 2012, 10:05 a.m.
Hi,

this patch adds a few fix include entries for VMS so that:
* it is possible to use a gcc for VMS to compile gcc (collisions between system and gcc headers),
* no warnings when signal.h is included,
* no warnings when resolv.h is included,
* avoid the use of DEC-C built-ins in some standard macros,
* disable getopt/optinf/opterr/optopt in 64 bit modes,
* declare some structure tag outside of argument list,
* use the more portable version of setjmp.

Tested for a while to build gcc for ia64 and alpha VMS.
'make check' is clean.

Comments are welcome!

Ok for trunk ?

Tristan.

fixincludes/
2012-03-12  Tristan Gingold  <gingold@adacore.com>

	* inclhack.def (vms_use_quoted_include,vms_add_missing_braces)
	(vms_do_not_redeclare_hostalias, vms_decc_builtin)
	(vms_no_64bit_getopt, vms_forward_declare_struct)
	(vms_use_fast_setjmp): New fixes.
	* fixincl.x: Regenerate.
	* tests/base/rtldef/string.h: Update.
	* tests/base/rtldef/if.h, tests/base/rtldef/resolv.h,
	* tests/base/rtldef/setjmp.h, tests/base/rtldef/signal.h,
	* tests/base/rtldef/stdio.h, tests/base/rtldef/wait.h: New files.
Bruce Korb - March 12, 2012, 2 p.m.
On Mon, Mar 12, 2012 at 3:05 AM, Tristan Gingold <gingold@adacore.com> wrote:
> Hi,
>
> this patch adds a few fix include entries for VMS so that:

[things work]

Looks good to me.
Tristan Gingold - March 12, 2012, 2:23 p.m.
On Mar 12, 2012, at 3:00 PM, Bruce Korb wrote:

> On Mon, Mar 12, 2012 at 3:05 AM, Tristan Gingold <gingold@adacore.com> wrote:
>> Hi,
>> 
>> this patch adds a few fix include entries for VMS so that:
> 
> [things work]
> 
> Looks good to me.

Thank you, now committed.

Tristan.

Patch

diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
index 40e7805..1a5cd8d 100644
--- a/fixincludes/inclhack.def
+++ b/fixincludes/inclhack.def
@@ -4611,6 +4611,129 @@  fix = {
 };
 
 /*
+ * On VMS, change <resource.h> to <sys/resource.h> to avoid a
+ * conflict while building gcc.  Likewise for <builtins.h>
+ */
+fix = {
+    hackname  = vms_use_quoted_include;
+    select    = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
+    mach      = "*-*-*vms*";
+    files     = rtldef/wait.h, starlet_c/pthread.h;
+    c_fix     = format;
+
+    c_fix_arg = '%1<sys/%2.h>';
+
+    test_text = "#   include <resource.h>";
+};
+
+/*
+ * On VMS, add missing braces around sigset_t constants.
+ */
+fix = {
+    hackname  = vms_add_missing_braces;
+    select    = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
+    mach      = "*-*-*vms*";
+    files     = "rtldef/signal.h";
+    c_fix     = format;
+
+    c_fix_arg = '%1 {%2} ';
+
+    test_text = "static const __sigset_t _SIG_EMPTY_SET  = "
+                "{0x00000000, 0x00000000},\n"
+                " _SIG_FULL_SET   = {0xFFFFFFFF, 0xFFFFFFFF};\n";
+};
+
+/*
+ * On VMS, fix incompatible redeclaration of hostalias.
+ */
+fix = {
+    hackname  = vms_do_not_redeclare_hostalias;
+    select    = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
+                "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
+    mach      = "*-*-*vms*";
+    files     = "rtldef/resolv.h";
+    c_fix     = format;
+
+    c_fix_arg = "%1\n"
+                "/* %2 */";
+
+    test_text = "void		fp_nquery (const u_char *, int, FILE *);\n"
+                "__char_ptr32	hostalias (const char *);\n";
+};
+
+/*
+ * On VMS, some DEC-C builtins are directly used.
+ */
+fix = {
+    hackname  = vms_decc_builtin;
+    select    = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
+    mach      = "*-*-*vms*";
+    files     = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
+                rtldef/socket.h;
+    sed       = "s@__MEMSET@memset@";
+    sed       = "s@__MEMMOVE@memmove@";
+    sed       = "s@__MEMCPY@memcpy@";
+    sed       = "s@__STRLEN@strlen@";
+    sed       = "s@__STRCPY@strcpy@";
+
+    test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
+};
+
+/*
+ * On VMS, do not declare getopt and al if pointers are 64 bit.
+ */
+fix = {
+    hackname  = vms_no_64bit_getopt;
+    select    = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
+    /*    select    = "^[ \t](extern[ \t))?(int[ \t](getopt|optind|opterr|optopt))|(char *optarg).*;\n"; */
+    mach      = "*-*-*vms*";
+    files     = rtldef/stdio.h, rtldef/unistd.h;
+    c_fix     = format;
+
+    c_fix_arg = "#if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only.  */\n"
+                "%0"
+                "#endif\n";
+
+    test_text = "int getopt (int, char * const [], const char *);";
+};
+
+/*
+ * On VMS, forward declare structure before referencing them in prototypes.
+ */
+fix = {
+    hackname  = vms_forward_declare_struct;
+    select    = "(/\\* forward decls for C\\+\\+ \\*/\n)"
+                "#ifdef __cplusplus\n";
+    mach      = "*-*-*vms*";
+    files     = rtldef/if.h;
+    c_fix     = format;
+
+    c_fix_arg = "%1"
+                "#if defined (__cplusplus) || defined (__GNUC__)\n";
+
+    test_text = "/* forward decls for C++ */\n"
+                "#ifdef __cplusplus\n"
+                "struct foo;\n"
+                "#endif\n";
+};
+
+/*
+ * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
+ * which is not yet fully supported by gcc.
+ */
+fix = {
+    hackname  = vms_use_fast_setjmp;
+    select    = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
+    mach      = "*-*-*vms*";
+    files     = rtldef/setjmp.h;
+    c_fix     = format;
+
+    c_fix_arg = "%0 defined (__GNUC__) ||";
+
+    test_text = "#   if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
+};
+
+/*
  *  AIX and Interix headers define NULL to be cast to a void pointer,
  *  which is illegal in ANSI C++.
  */
diff --git a/fixincludes/tests/base/rtldef/if.h b/fixincludes/tests/base/rtldef/if.h
new file mode 100644
index 0000000..836ff27
--- /dev/null
+++ b/fixincludes/tests/base/rtldef/if.h
@@ -0,0 +1,18 @@ 
+/*  DO NOT EDIT THIS FILE.
+
+    It has been auto-edited by fixincludes from:
+
+	"fixinc/tests/inc/rtldef/if.h"
+
+    This had to be done to correct non-standard usages in the
+    original, manufacturer supplied header file.  */
+
+
+
+#if defined( VMS_FORWARD_DECLARE_STRUCT_CHECK )
+/* forward decls for C++ */
+#if defined (__cplusplus) || defined (__GNUC__)
+struct foo;
+#endif
+
+#endif  /* VMS_FORWARD_DECLARE_STRUCT_CHECK */
diff --git a/fixincludes/tests/base/rtldef/resolv.h b/fixincludes/tests/base/rtldef/resolv.h
new file mode 100644
index 0000000..0b5b248
--- /dev/null
+++ b/fixincludes/tests/base/rtldef/resolv.h
@@ -0,0 +1,16 @@ 
+/*  DO NOT EDIT THIS FILE.
+
+    It has been auto-edited by fixincludes from:
+
+	"fixinc/tests/inc/rtldef/resolv.h"
+
+    This had to be done to correct non-standard usages in the
+    original, manufacturer supplied header file.  */
+
+
+
+#if defined( VMS_DO_NOT_REDECLARE_HOSTALIAS_CHECK )
+void		fp_nquery (const u_char *, int, FILE *);
+/* __char_ptr32	hostalias (const char *); */
+
+#endif  /* VMS_DO_NOT_REDECLARE_HOSTALIAS_CHECK */
diff --git a/fixincludes/tests/base/rtldef/setjmp.h b/fixincludes/tests/base/rtldef/setjmp.h
new file mode 100644
index 0000000..5414efc
--- /dev/null
+++ b/fixincludes/tests/base/rtldef/setjmp.h
@@ -0,0 +1,14 @@ 
+/*  DO NOT EDIT THIS FILE.
+
+    It has been auto-edited by fixincludes from:
+
+	"fixinc/tests/inc/rtldef/setjmp.h"
+
+    This had to be done to correct non-standard usages in the
+    original, manufacturer supplied header file.  */
+
+
+
+#if defined( VMS_USE_FAST_SETJMP_CHECK )
+#   if defined(__FAST_SETJMP) || defined (__GNUC__) || defined(__UNIX_SETJMP)
+#endif  /* VMS_USE_FAST_SETJMP_CHECK */
diff --git a/fixincludes/tests/base/rtldef/signal.h b/fixincludes/tests/base/rtldef/signal.h
new file mode 100644
index 0000000..3b5a2b8
--- /dev/null
+++ b/fixincludes/tests/base/rtldef/signal.h
@@ -0,0 +1,16 @@ 
+/*  DO NOT EDIT THIS FILE.
+
+    It has been auto-edited by fixincludes from:
+
+	"fixinc/tests/inc/rtldef/signal.h"
+
+    This had to be done to correct non-standard usages in the
+    original, manufacturer supplied header file.  */
+
+
+
+#if defined( VMS_ADD_MISSING_BRACES_CHECK )
+static const __sigset_t _SIG_EMPTY_SET  = { {0x00000000, 0x00000000} },
+ _SIG_FULL_SET   = { {0xFFFFFFFF, 0xFFFFFFFF} };
+
+#endif  /* VMS_ADD_MISSING_BRACES_CHECK */
diff --git a/fixincludes/tests/base/rtldef/stdio.h b/fixincludes/tests/base/rtldef/stdio.h
new file mode 100644
index 0000000..4835d0f
--- /dev/null
+++ b/fixincludes/tests/base/rtldef/stdio.h
@@ -0,0 +1,16 @@ 
+/*  DO NOT EDIT THIS FILE.
+
+    It has been auto-edited by fixincludes from:
+
+	"fixinc/tests/inc/rtldef/stdio.h"
+
+    This had to be done to correct non-standard usages in the
+    original, manufacturer supplied header file.  */
+
+
+
+#if defined( VMS_NO_64BIT_GETOPT_CHECK )
+#if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only.  */
+int getopt (int, char * const [], const char *);
+#endif
+#endif  /* VMS_NO_64BIT_GETOPT_CHECK */
diff --git a/fixincludes/tests/base/rtldef/string.h b/fixincludes/tests/base/rtldef/string.h
index 1ac9b2a..6249b0c 100644
--- a/fixincludes/tests/base/rtldef/string.h
+++ b/fixincludes/tests/base/rtldef/string.h
@@ -13,3 +13,9 @@ 
 #if !defined(__VAX) && !defined(__GNUC__)
 
 #endif  /* VMS_DISABLE_DECC_STRING_BUILTINS_CHECK */
+
+
+#if defined( VMS_DECC_BUILTIN_CHECK )
+define FD_ZERO(__p) memset((__p), 0, sizeof(*(__p)))
+
+#endif  /* VMS_DECC_BUILTIN_CHECK */
diff --git a/fixincludes/tests/base/rtldef/wait.h b/fixincludes/tests/base/rtldef/wait.h
new file mode 100644
index 0000000..0587834
--- /dev/null
+++ b/fixincludes/tests/base/rtldef/wait.h
@@ -0,0 +1,14 @@ 
+/*  DO NOT EDIT THIS FILE.
+
+    It has been auto-edited by fixincludes from:
+
+	"fixinc/tests/inc/rtldef/wait.h"
+
+    This had to be done to correct non-standard usages in the
+    original, manufacturer supplied header file.  */
+
+
+
+#if defined( VMS_USE_QUOTED_INCLUDE_CHECK )
+#   include <sys/resource.h>
+#endif  /* VMS_USE_QUOTED_INCLUDE_CHECK */