Message ID | 4FD73306.1080301@verizon.net |
---|---|
State | New |
Headers | show |
On 06/12/2012 08:16 AM, rbmj wrote: > On 06/11/2012 08:01 AM, Paolo Bonzini wrote: >> VxWorks should define TARGET_POSIX_IO if it has both access and >> mkdir. Please add it to gcc/config/vxworks.h if this is the case. > > I misspoke in my earlier email - sorry for my lack of attention to > detail. The issue is that > VxWorks does *not* have a two argument mkdir(). It does have > TARGET_POSIX_IO. Undefing TARGET_POSIX_IO seems non-optimal as it > disables some functionality that can still be implemented, just > omitting the mode argument. With this in mind, I defined > MKDIR_SINGLE_ARG in gcc/config/vxworks.h, and then added a check for > this define. This is a slightly less ugly solution than I had earlier. > > An updated patch is attached. It's in git format-patch format, so the > commit message is at the top. There is an alternate solution- I could use fixincludes to add a macro to wrap over mkdir on VxWorks. A couple of possible ways to do this: 1. Define a normal macro to posix-ify it, i.e. #define mkdir(a, b) ((mkdir)(a)). Since this would hide single-argument mkdir, it would probably be best to wrap it in #ifdef IN_GCC in order to avoid breaking existing vxWorks code. 2. Make a variadic macro to allow for posix compatibility, i.e. #define mkdir(a, ...) ((mkdir)(a)). I'm not sure if this works outside of C99 mode - I know GCC supports it as an extension in C89 mode, but AFAIK the semantics are slightly different. I'm also not sure about g++. This does have the advantage though that it doesn't break any existing code. However, it does allow nonsensical 20 argument mkdir as well. Either of these or the one in my previous email should work. Which (or a different one entirely) would be preferred? Thanks, Robert
On Wed, 20 Jun 2012, rbmj wrote: > There is an alternate solution- I could use fixincludes to add a macro to wrap > over mkdir on VxWorks. A couple of possible ways to do this: > > 1. Define a normal macro to posix-ify it, i.e. #define mkdir(a, b) > ((mkdir)(a)). Since this would hide single-argument mkdir, it would probably > be best to wrap it in #ifdef IN_GCC in order to avoid breaking existing > vxWorks code. Beware, if you go this route, I think you need to evaluate the "mode" argument (b above), i.e. something like "#define mkdir(a, b) ((b), (mkdir) (a))". brgds, H-P
On 06/21/2012 09:40 PM, Hans-Peter Nilsson wrote: > On Wed, 20 Jun 2012, rbmj wrote: >> There is an alternate solution- I could use fixincludes to add a macro to wrap >> over mkdir on VxWorks. A couple of possible ways to do this: >> >> 1. Define a normal macro to posix-ify it, i.e. #define mkdir(a, b) >> ((mkdir)(a)). Since this would hide single-argument mkdir, it would probably >> be best to wrap it in #ifdef IN_GCC in order to avoid breaking existing >> vxWorks code. > Beware, if you go this route, I think you need to evaluate the > "mode" argument (b above), i.e. something like "#define mkdir(a, > b) ((b), (mkdir) (a))". > > Yes, you're correct. I think then that this makes the normal macro a better option than the variadic macro, even though the variadic is more compatible. Wrapping the mkdir macro in IN_GCC should provide an adequate guard to prevent the macro from expanding in code that relies on the non-compliant signature. I would ask who in the world puts expressions with side effects in as the mode argument and then relies on those side effects for something other than the (ignored) mode, but I know better :-P. I think this is better than the previous solution as it doesn't require touching GCC itself per-se, and instead deals with header incompatibilities where they should be dealt with in fixincludes. I'll write up a patch and put that with the other fixincludes patches I've submitted. Thanks, Robert
From 61de9bcf6c0dc60185a84b07e0f8ad2f870b6799 Mon Sep 17 00:00:00 2001 From: rbmj <rbmj@verizon.net> Date: Tue, 12 Jun 2012 07:54:20 -0400 Subject: [PATCH] Fixed compilation on VxWorks because of open()/mkdir() VxWorks only has a single arg mkdir(), and kernel modules only have a (fixed) three argument open() instead of the compliant variadic version. For open(), pass the mode argument unconditionally so that we always use three arguments. This shouldn't break other platforms, as it will just be ignored. For mkdir(), added MKDIR_SINGLE_ARG (similarly to TARGET_POSIX_IO) in order to only use one argument to maintain compatibility. Modified: *gcc/config/vxworks.h: Added define for MKDIR_SINGLE_ARG *gcc/gcov-io.c (gcov_open): Pass in mode to open() unconditionally to support non-variadic open() *libgcc/libgcov.c (create_file_directory): Add check for MKDIR_SINGLE_ARG to support single-argument mkdir() --- gcc/config/vxworks.h | 2 ++ gcc/gcov-io.c | 2 +- libgcc/libgcov.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gcc/config/vxworks.h b/gcc/config/vxworks.h index 000de36..cd57f1a 100644 --- a/gcc/config/vxworks.h +++ b/gcc/config/vxworks.h @@ -117,6 +117,8 @@ extern void vxworks_asm_out_destructor (rtx symbol, int priority); /* Both kernels and RTPs have the facilities required by this macro. */ #define TARGET_POSIX_IO +#define MKDIR_SINGLE_ARG + /* A VxWorks implementation of TARGET_OS_CPP_BUILTINS. */ #define VXWORKS_OS_CPP_BUILTINS() \ diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c index 37c1c3e..13c1aa8 100644 --- a/gcc/gcov-io.c +++ b/gcc/gcov-io.c @@ -92,7 +92,7 @@ gcov_open (const char *name, int mode) { /* Read-only mode - acquire a read-lock. */ s_flock.l_type = F_RDLCK; - fd = open (name, O_RDONLY); + fd = open (name, O_RDONLY, S_IRUSR | S_IWUSR); } else { diff --git a/libgcc/libgcov.c b/libgcc/libgcov.c index 8ed8971..5c4fa1c 100644 --- a/libgcc/libgcov.c +++ b/libgcc/libgcov.c @@ -133,7 +133,7 @@ create_file_directory (char *filename) /* Try to make directory if it doesn't already exist. */ if (access (filename, F_OK) == -1 -#ifdef TARGET_POSIX_IO +#if defined(TARGET_POSIX_IO) && !defined(MKDIR_SINGLE_ARG) && mkdir (filename, 0755) == -1 #else && mkdir (filename) == -1 -- 1.7.5.4