Patchwork fix up fixincludes for VxWorks and fix testing

login
register
mail settings
Submitter rbmj
Date Oct. 2, 2012, 6:11 p.m.
Message ID <506B2E35.8010101@verizon.net>
Download mbox | patch
Permalink /patch/188593/
State New
Headers show

Comments

rbmj - Oct. 2, 2012, 6:11 p.m.
Forgot to attach.

On 10/2/2012 2:09 PM, rbmj wrote:
> Patch 1:  [fixincludes] Fixes for VxWorks
>
> TODO Prior to commit:
>
> * fixincl.x: Regenerate
>
> ChangeLog [fixincludes]:
>
> 2012-06-19  Robert Mason  <rbmj@verizon.net>
>
>      * fixinc.in: Check to see if the machine_name fix needs to be
> disabled.
>      viz. vxworks must not check the machine name for fix applicability.
>      * inclhack.def (AAB_vxworks_assert): New replacement fix
>      (AAB_vxworks_regs_vxtypes): likewise
>      (AAB_vxworks_stdint): and again
>      (AAB_vxworks_unistd) and yet again
>      (vxworks_ioctl_macro): wrap ioctl function in macro
>      (vxworks_mkdir_macro): remove mkdir() args vxworks doesn't support
>      (vxworks_regs): make sure regs.h comes from above arch directory.
>      (vxworks_write_const): add "const" attribute to data argument
>      * mkfixinc.sh: remove "vxworks" from list of platforms skipped by
>      fixincludes
>
> 2012-09-23  Bruce Korb  <bkorb@gnu.org>
>
>      * tests/base/ioLib.h: new test header for new vxworks fix.
>      * tests/base/math.h: fix results movement
>      * tests/base/sys/stat.h: vxworks test
>      * tests/base/testing.h: vxworks test
>
>

Patch

From 5da04a0758548288d5f004ed294ac3e903e229a8 Mon Sep 17 00:00:00 2001
From: rbmj <rbmj@verizon.net>
Date: Tue, 2 Oct 2012 13:51:18 -0400
Subject: [PATCH 1/4] [fixincludes] Add fixes for VxWorks

---
 fixincludes/fixinc.in                          |   16 ++
 fixincludes/inclhack.def                       |  266 ++++++++++++++++++++++++
 fixincludes/mkfixinc.sh                        |    1 -
 fixincludes/tests/base/ioLib.h                 |   19 ++
 fixincludes/tests/base/math.h                  |   10 +-
 fixincludes/tests/base/sys/stat.h              |    7 +
 fixincludes/tests/base/testing.h               |    6 +
 8 files changed, 324 insertions(+), 85 deletions(-)
 create mode 100644 fixincludes/tests/base/ioLib.h

diff --git a/fixincludes/fixinc.in b/fixincludes/fixinc.in
index e73aed9..f7b8d8f 100755
--- a/fixincludes/fixinc.in
+++ b/fixincludes/fixinc.in
@@ -128,6 +128,22 @@  fi
 
 # # # # # # # # # # # # # # # # # # # # #
 #
+#  Check to see if the machine_name fix needs to be disabled.
+#
+#  On some platforms, machine_name doesn't work properly and
+#  breaks some of the header files.  Since everything works
+#  properly without it, just wipe the macro list to
+#  disable the fix.
+
+case "${target_canonical}" in
+    *-*-vxworks*)
+	test -f ${MACRO_LIST} &&  echo > ${MACRO_LIST}
+        ;;
+esac
+
+
+# # # # # # # # # # # # # # # # # # # # #
+#
 #  In the file macro_list are listed all the predefined
 #  macros that are not in the C89 reserved namespace (the reserved
 #  namespace is all identifiers beginnning with two underscores or one
diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
index 82792af..c5ae854 100644
--- a/fixincludes/inclhack.def
+++ b/fixincludes/inclhack.def
@@ -354,6 +354,206 @@  fix = {
 	_EndOfHeader_;
 };
 
+/*
+ * Fix assert.h on VxWorks:
+ */
+fix = {
+    hackname    = AAB_vxworks_assert;
+    files       = assert.h;
+    mach        = "*-*-vxworks*";
+        
+    replace     = <<- _EndOfHeader_
+	#ifndef _ASSERT_H
+	#define _ASSERT_H
+
+	#ifdef assert
+	#undef assert
+	#endif
+
+	#if defined(__STDC__) || defined(__cplusplus)
+	extern void __assert (const char*);
+	#else
+	extern void __assert ();
+	#endif
+
+	#ifdef NDEBUG
+	#define assert(ign) ((void)0)
+	#else
+
+	#define ASSERT_STRINGIFY(str) ASSERT_STRINGIFY_HELPER(str)
+	#define ASSERT_STRINGIFY_HELPER(str) #str
+
+	#define assert(test) ((void) \
+	        ((test) ? ((void)0) : \
+	        __assert("Assertion failed: " ASSERT_STRINGIFY(test) ", file " \
+	        __FILE__ ", line " ASSERT_STRINGIFY(__LINE__) "\n")))
+
+	#endif
+
+	#endif
+	_EndOfHeader_;
+};
+
+/*
+ * Add needed include to regs.h (NOT the gcc header) on VxWorks
+ */
+
+fix = {
+    hackname    = AAB_vxworks_regs_vxtypes;
+    files       = regs.h;
+    mach        = "*-*-vxworks*";
+
+    replace     = <<- _EndOfHeader_
+	#ifndef _REGS_H
+	#define _REGS_H
+	#include <types/vxTypesOld.h>
+	#include_next <arch/../regs.h>
+	#endif
+	_EndOfHeader_;
+};
+
+/*
+ * Make VxWorks stdint.h a bit more compliant - add typedefs
+ */
+fix = {
+    hackname    = AAB_vxworks_stdint;
+    files       = stdint.h;
+    mach        = "*-*-vxworks*";
+        
+    replace     = <<- _EndOfHeader_
+	#ifndef _STDINT_H
+	#define _STDINT_H
+	/* get int*_t, uint*_t */
+	#include <types/vxTypes.h>
+	
+	/* get legacy vxworks types for compatibility */
+	#include <types/vxTypesOld.h>
+	
+	typedef long intptr_t;
+	typedef unsigned long uintptr_t;
+	
+	typedef int64_t intmax_t;
+	typedef uint64_t uintmax_t;
+	
+	typedef int8_t int_least8_t;
+	typedef int16_t int_least16_t;
+	typedef int32_t int_least32_t;
+	typedef int64_t int_least64_t;
+	
+	typedef uint8_t uint_least8_t;
+	typedef uint16_t uint_least16_t;
+	typedef uint32_t uint_least32_t;
+	typedef uint64_t uint_least64_t;
+	
+	typedef int8_t int_fast8_t;
+	typedef int int_fast16_t;
+	typedef int32_t int_fast32_t;
+	typedef int64_t int_fast64_t;
+	
+	typedef uint8_t uint_fast8_t;
+	typedef unsigned int uint_fast16_t;
+	typedef uint32_t uint_fast32_t;
+	typedef uint64_t uint_fast64_t;
+	
+	/* Ranges */
+	#define UINT8_MAX (~(uint8_t)0)
+	#define UINT8_MIN 0
+	#define UINT16_MAX (~(uint16_t)0)
+	#define UINT16_MIN 0
+	#define UINT32_MAX (~(uint32_t)0)
+	#define UINT32_MIN 0
+	#define UINT64_MAX (~(uint64_t)0)
+	#define UINT64_MIN 0
+	
+	#define UINTPTR_MAX (~(uintptr_t)0)
+	#define UINTPTR_MIN 0
+	
+	/* Need to do int_fast16_t as well, as type
+	   size may be architecture dependent */
+	#define UINT_FAST16_MAX (~(uint_fast16_t)0)
+	#define UINT_FAST16_MAX 0
+	
+	#define INT8_MAX (UINT8_MAX>>1)
+	#define INT8_MIN (INT8_MAX+1)
+	#define INT16_MAX (UINT16_MAX>>1)
+	#define INT16_MIN (INT16_MAX+1)
+	#define INT32_MAX (UINT32_MAX>>1)
+	#define INT32_MIN (INT32_MAX+1)
+	#define INT64_MAX (UINT64_MAX>>1)
+	#define INT64_MIN (INT64_MAX+1)
+	
+	#define INTPTR_MAX (UINTPTR_MAX>>1)
+	#define INTPTR_MIN (INTPTR_MAX+1)	
+	
+	#define INT_FAST16_MAX (UINT_FAST16_MAX>>1)
+	#define INT_FAST16_MIN (INT_FAST16_MAX+1)
+	
+	/* now define equiv. constants */
+	#define UINT_FAST8_MAX UINT8_MAX
+	#define UINT_FAST8_MIN UINT_FAST8_MIN
+	#define INT_FAST8_MAX INT8_MAX
+	#define INT_FAST8_MIN INT8_MIN
+	#define UINT_FAST32_MAX UINT32_MAX
+	#define UINT_FAST32_MIN UINT32_MIN
+	#define INT_FAST32_MAX INT32_MAX
+	#define INT_FAST32_MIN INT32_MIN
+	#define UINT_FAST64_MAX UINT64_MAX
+	#define UINT_FAST64_MIN UINT64_MIN
+	#define INT_FAST64_MAX INT64_MAX
+	#define INT_FAST64_MIN INT64_MIN
+	
+	#define UINT_LEAST8_MAX UINT8_MAX
+	#define UINT_LEAST8_MIN UINT8_MIN
+	#define INT_LEAST8_MAX INT8_MAX
+	#define INT_LEAST8_MIN INT8_MIN
+	#define UINT_LEAST16_MAX UINT16_MAX
+	#define UINT_LEAST16_MIN UINT16_MIN
+	#define INT_LEAST16_MAX INT16_MAX
+	#define INT_LEAST16_MIN INT16_MIN
+	#define UINT_LEAST32_MAX UINT32_MAX
+	#define UINT_LEAST32_MIN UINT32_MIN
+	#define INT_LEAST32_MAX INT32_MAX
+	#define INT_LEAST32_MIN INT32_MIN
+	#define UINT_LEAST64_MAX UINT64_MAX
+	#define UINT_LEAST64_MIN UINT64_MIN
+	#define INT_LEAST64_MAX INT64_MAX
+	#define INT_LEAST64_MIN INT64_MIN
+	
+	#define UINTMAX_MAX UINT64_MAX
+	#define UINTMAX_MIN UINT64_MIN
+	#define INTMAX_MAX INT64_MAX
+	#define INTMAX_MIN INT64_MIN
+	
+	#endif
+	_EndOfHeader_;
+};
+
+/*
+ *  This hack makes makes unistd.h more POSIX-compliant on VxWorks
+ */
+fix = {
+    hackname    = AAB_vxworks_unistd;
+    files       = unistd.h;
+    mach        = "*-*-vxworks*";
+        
+    replace     = <<- _EndOfHeader_
+	#ifndef _UNISTD_H
+	#define _UNISTD_H
+	#include_next <unistd.h>
+	#include <ioLib.h>
+	#ifndef STDIN_FILENO
+	#define STDIN_FILENO 0
+	#endif
+	#ifndef STDOUT_FILENO
+	#define STDOUT_FILENO 1
+	#endif
+	#ifndef STDERR_FILENO
+	#define STDERR_FILENO 2
+	#endif
+	#endif /* _UNISTD_H */
+	_EndOfHeader_;
+};
+
 
 /*
  * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
@@ -4371,6 +4571,41 @@  fix = {
     "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
 };
 
+/*
+ *  Wrap VxWorks ioctl to keep everything pretty
+ */
+fix = {
+    hackname    = vxworks_ioctl_macro;
+    files       = ioLib.h;
+    mach        = "*-*-vxworks*";
+
+    c_fix       = format;
+    c_fix_arg   = "%0\n"
+        "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n";
+    c_fix_arg   = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
+        
+    test_text   = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
+};
+
+/*
+ *  Wrap VxWorks mkdir to be posix compliant
+ */
+fix = {
+    hackname    = vxworks_mkdir_macro;
+    files       = sys/stat.h;
+    mach        = "*-*-vxworks*";
+
+    c_fix       = format;
+    c_fix_arg   = "%0\n"
+                "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
+    c_fix_arg   = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
+                "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
+                "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
+                "\\)[\t ]*;";
+        
+    test_text   = "extern STATUS mkdir (const char * _qwerty) ;";
+};
+
 
 /*
  *  Fix VxWorks <time.h> to not require including <vxTypes.h>.
@@ -4404,6 +4639,20 @@  fix = {
     "# define\t__INCstath <sys/stat.h>";
 };
 
+/*
+ *  Make it so VxWorks does not include gcc/regs.h accidentally
+ */
+fix = {
+    hackname    = vxworks_regs;
+    mach        = "*-*-vxworks*";
+
+    select      = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
+    c_fix       = format;
+    c_fix_arg   = "#include <arch/../regs.h>";
+        
+    test_text   = "#include <regs.h>\n";
+};
+
 
 /*
  *  Another bad dependency in VxWorks 5.2 <time.h>.
@@ -4431,6 +4680,23 @@  fix = {
                 "#define VOIDFUNCPTR (void(*)())";
 };
 
+/*
+ *  This hack makes write const-correct on VxWorks
+ */
+fix = {
+    hackname    = vxworks_write_const;
+    files       = ioLib.h;
+    mach        = "*-*-vxworks*";
+
+    c_fix       = format;
+    c_fix_arg   = "extern int  write (int, const char*, size_t);";
+    c_fix_arg   = "extern[\t ]+int[\t ]+write[\t ]*\\("
+                "[\t ]*int[\t ]*,"
+                "[\t ]*char[\t ]*\\*[\t ]*,"
+                "[\t ]*size_t[\t ]*\\)[\t ]*;";
+
+    test_text       = "extern int write ( int , char * , size_t ) ;";
+};
 
 /*
  *  There are several name conflicts with C++ reserved words in X11 header
diff --git a/fixincludes/mkfixinc.sh b/fixincludes/mkfixinc.sh
index 89e8ab7..6653fed 100755
--- a/fixincludes/mkfixinc.sh
+++ b/fixincludes/mkfixinc.sh
@@ -15,7 +15,6 @@  case $machine in
     i?86-*-mingw32* | \
     x86_64-*-mingw32* | \
     i?86-*-interix* | \
-    *-*-vxworks* | \
     powerpc-*-eabisim* | \
     powerpc-*-eabi*    | \
     powerpc-*-rtems*   | \
diff --git a/fixincludes/tests/base/ioLib.h b/fixincludes/tests/base/ioLib.h
new file mode 100644
index 0000000..d570c89
--- /dev/null
+++ b/fixincludes/tests/base/ioLib.h
@@ -0,0 +1,19 @@ 
+/*  DO NOT EDIT THIS FILE.
+
+    It has been auto-edited by fixincludes from:
+
+	"fixinc/tests/inc/ioLib.h"
+
+    This had to be done to correct non-standard usages in the
+    original, manufacturer supplied header file.  */
+
+
+
+#if defined( VXWORKS_IOCTL_MACRO_CHECK )
+extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;
+#endif  /* VXWORKS_IOCTL_MACRO_CHECK */
+
+
+#if defined( VXWORKS_WRITE_CONST_CHECK )
+extern int  write (int, const char*, size_t);
+#endif  /* VXWORKS_WRITE_CONST_CHECK */
diff --git a/fixincludes/tests/base/math.h b/fixincludes/tests/base/math.h
index a97e88b..7660172 100644
--- a/fixincludes/tests/base/math.h
+++ b/fixincludes/tests/base/math.h
@@ -15,11 +15,6 @@ 
 #endif
 
 
-#if defined( AAB_DARWIN7_9_LONG_DOUBLE_FUNCS_2_CHECK )
-#include <architecture/ppc/math.h>
-#endif  /* AAB_DARWIN7_9_LONG_DOUBLE_FUNCS_2_CHECK */
-
-
 #if defined( BROKEN_CABS_CHECK )
 #ifdef __STDC__
 
@@ -30,6 +25,11 @@ 
 #endif  /* BROKEN_CABS_CHECK */
 
 
+#if defined( DARWIN_9_LONG_DOUBLE_FUNCS_2_CHECK )
+#include <architecture/ppc/math.h>
+#endif  /* DARWIN_9_LONG_DOUBLE_FUNCS_2_CHECK */
+
+
 #if defined( HPPA_HPUX_FP_MACROS_CHECK )
 #endif /* _INCLUDE_HPUX_SOURCE */
 
diff --git a/fixincludes/tests/base/sys/stat.h b/fixincludes/tests/base/sys/stat.h
index 240c308..9c81cff 100644
--- a/fixincludes/tests/base/sys/stat.h
+++ b/fixincludes/tests/base/sys/stat.h
@@ -28,6 +28,13 @@  extern int fchmod(int, mode_t);
 #endif  /* RS6000_FCHMOD_CHECK */
 
 
+#if defined( VXWORKS_MKDIR_MACRO_CHECK )
+extern STATUS mkdir (const char * _qwerty) ;
+#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))
+
+#endif  /* VXWORKS_MKDIR_MACRO_CHECK */
+
+
 #if defined( VXWORKS_NEEDS_VXWORKS_CHECK )
 #include </dev/null> /* ULONG */
 # define	__INCstath <sys/stat.h>
diff --git a/fixincludes/tests/base/testing.h b/fixincludes/tests/base/testing.h
index f1ffeff..cf95321 100644
--- a/fixincludes/tests/base/testing.h
+++ b/fixincludes/tests/base/testing.h
@@ -114,3 +114,9 @@  extern size_t
 #endif
 
 #endif  /* VMS_USE_PRAGMA_EXTERN_MODEL_CHECK */
+
+
+#if defined( VXWORKS_REGS_CHECK )
+#include <arch/../regs.h>
+
+#endif  /* VXWORKS_REGS_CHECK */
-- 
1.7.10.4