From patchwork Tue Oct 2 18:11:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: rbmj X-Patchwork-Id: 188593 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 4E7212C0088 for ; Wed, 3 Oct 2012 04:12:02 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1349806322; h=Comment: DomainKey-Signature:Received:Received:Received:Received: Message-id:Date:From:User-Agent:MIME-version:To:Cc:Subject: References:In-reply-to:Content-type:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=7KB3qNJhpjt0hoqnZSugNHoo+Uc=; b=PzKH5MyZvxAd1pp Ki2eTZDpb54SjUhiqtHn+ROJZNZI00vEjBIP02HzTmH3O3fXHCvf6FweTUDDRKc3 1reAGPdgI2IVoFPS++XnYUf7DkuDi9JGTSYAU6133Tbn2k2CXOW+ZOdCtlJiaQ2U 2S5tCWCio8olVfHk42EmK2RJNPkw= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Message-id:Date:From:User-Agent:MIME-version:To:Cc:Subject:References:In-reply-to:Content-type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=aqrAwrY9lzbmEwfH8Y0iwR/L4eZW3PvxZczwIMwKod7ASV7urhSLV5f+Y1G1Zz 8nxoJytd3jpvlhe2kbnSog48+Rzcn1Qc8tBP984Pv8JVFqJxaBq3S5YwvwpsOSGG /NSXMFJQgQwnk2B7tlmqzoXA8V/d+kKh1A5qWT9h4oSpI=; Received: (qmail 1299 invoked by alias); 2 Oct 2012 18:11:47 -0000 Received: (qmail 1248 invoked by uid 22791); 2 Oct 2012 18:11:42 -0000 X-SWARE-Spam-Status: No, hits=1.9 required=5.0 tests=AWL, BAYES_50, BOTNET, KHOP_THREADED, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from vms173019pub.verizon.net (HELO vms173019pub.verizon.net) (206.46.173.19) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 02 Oct 2012 18:11:33 +0000 Received: from [10.16.147.104] ([unknown] [131.121.225.22]) by vms173019.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0MBA00K0V2IDJ8I0@vms173019.mailsrvcs.net> for gcc-patches@gcc.gnu.org; Tue, 02 Oct 2012 13:11:06 -0500 (CDT) Message-id: <506B2E35.8010101@verizon.net> Date: Tue, 02 Oct 2012 14:11:01 -0400 From: rbmj User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 MIME-version: 1.0 To: Bruce Korb Cc: GCC Patches Subject: Re: [PATCH] fix up fixincludes for VxWorks and fix testing References: <505F9918.2070102@gmail.com> <506B2C25.6010401@verizon.net> <506B2DE0.6060001@verizon.net> In-reply-to: <506B2DE0.6060001@verizon.net> Content-type: multipart/mixed; boundary=------------040608090009060903030401 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 > > * 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 > > * 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 > > From 5da04a0758548288d5f004ed294ac3e903e229a8 Mon Sep 17 00:00:00 2001 From: rbmj 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 + #include_next + #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 + + /* get legacy vxworks types for compatibility */ + #include + + 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 + #include + #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 to not require including . @@ -4404,6 +4639,20 @@ fix = { "# define\t__INCstath "; }; +/* + * 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 "; + + test_text = "#include \n"; +}; + /* * Another bad dependency in VxWorks 5.2 . @@ -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 -#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 +#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 /* ULONG */ # define __INCstath 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 + +#endif /* VXWORKS_REGS_CHECK */ -- 1.7.10.4