Re: [PATCH] [cygwin|mingw] cwrapper cleanups.

2009-01-24 Thread Ralf Wildenhues
Hi Charles,

* Charles Wilson wrote on Wed, Jan 21, 2009 at 10:14:22PM CET:
 libltdl/config/ltmain.m4sh (func_emit_cwrapperexe_src)
 [file scope]: re-organized includes and portability
 macros. Avoid oldnames on MINGW32 and MSVC for
 setmode/stat/chmod/getcwd/putenv. Declare _putenv on
 MINGW32 when -ansi.

OK, thanks.  The only part that looks arbitrary is this one:

 Use namespaced macro LT_DEBUGWRAPPER.

It is not accompanied by any documentation change or testsuite change.
This of course isn't this patch's fault, but shows that there is some
documentation and some test missing.  It would be nice if this were
addressed in another patch.  :-)

 It's interesting that on mingw, when -std=c89, there is no declaration
 of putenv (or _putenv) in the system headers. However, with -Werror the
 compilation of the wrapper succeeds even without this patch -- but there
 is an error:
   if (putenv (str) != EXIT_SUCCESS)
 You have to turn on -Wall (with -std=c89) to get mingw gcc to complain:
   In function `lt_setenv':
   warning: implicit declaration of function `putenv'
 However, in -std=c99 mode, this warning is printed /without/ -Wall.

If you want to add a round using -Wall to the cwrapper test (or add
-Wall to one of the current rounds), consider such a change preapproved.

Cheers,
Ralf




[PATCH] [cygwin|mingw] cwrapper cleanups.

2009-01-22 Thread Charles Wilson
libltdl/config/ltmain.m4sh (func_emit_cwrapperexe_src)
[file scope]: re-organized includes and portability
macros. Avoid oldnames on MINGW32 and MSVC for
setmode/stat/chmod/getcwd/putenv. Declare _putenv on
MINGW32 when -ansi. Use namespaced macro LT_DEBUGWRAPPER.
---
This patch contains the parts excluded from
http://lists.gnu.org/archive/html/libtool-patches/2009-01/msg4.html
as described here:
http://lists.gnu.org/archive/html/libtool-patches/2009-01/msg00105.html
(with some additional modifications).

For discussion of the motivation of this patch, see
http://lists.gnu.org/archive/html/libtool-patches/2009-01/msg00101.html
and look for Part (2) is a bit unobvious when merely looking about
one-third down.

It's interesting that on mingw, when -std=c89, there is no declaration
of putenv (or _putenv) in the system headers. However, with -Werror the
compilation of the wrapper succeeds even without this patch -- but there
is an error:
  if (putenv (str) != EXIT_SUCCESS)
You have to turn on -Wall (with -std=c89) to get mingw gcc to complain:
  In function `lt_setenv':
  warning: implicit declaration of function `putenv'
However, in -std=c99 mode, this warning is printed /without/ -Wall.

So, the cwrapper.at tests (which exercise both '-std=c89 -Werror'
and '-std=c99 -Werror', will fail on mingw without this patch or 
something like it.


 libltdl/config/ltmain.m4sh |   60 +--
 1 files changed, 40 insertions(+), 20 deletions(-)

diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 3f1a30c..d525893 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -2716,18 +2716,11 @@ EOF
 # include direct.h
 # include process.h
 # include io.h
-# define setmode _setmode
 #else
 # include unistd.h
 # include stdint.h
 # ifdef __CYGWIN__
 #  include io.h
-#  define HAVE_SETENV
-#  ifdef __STRICT_ANSI__
-char *realpath (const char *, char *);
-int putenv (char *);
-int setenv (const char *, const char *, int);
-#  endif
 # endif
 #endif
 #include malloc.h
@@ -2741,6 +2734,44 @@ int setenv (const char *, const char *, int);
 #include fcntl.h
 #include sys/stat.h
 
+/* declarations of non-ANSI functions */
+#if defined(__MINGW32__)
+# ifdef __STRICT_ANSI__
+int _putenv (const char *);
+# endif
+#elif defined(__CYGWIN__)
+# ifdef __STRICT_ANSI__
+char *realpath (const char *, char *);
+int putenv (char *);
+int setenv (const char *, const char *, int);
+# endif
+/* #elif defined (other platforms) ... */
+#endif
+
+/* portability defines, excluding path handling macros */
+#if defined(_MSC_VER)
+# define setmode _setmode
+# define stat_stat
+# define chmod   _chmod
+# define getcwd  _getcwd
+# define putenv  _putenv
+# define S_IXUSR _S_IEXEC
+# ifndef _INTPTR_T_DEFINED
+#  define _INTPTR_T_DEFINED
+#  define intptr_t int
+# endif
+#elif defined(__MINGW32__)  !defined(__MINGW32CE__)
+# define setmode _setmode
+# define stat_stat
+# define chmod   _chmod
+# define getcwd  _getcwd
+# define putenv  _putenv
+#elif defined(__CYGWIN__)
+# define HAVE_SETENV
+# define FOPEN_WB wb
+/* #elif defined (other platforms) ... */
+#endif
+
 #if defined(PATH_MAX)
 # define LT_PATHMAX PATH_MAX
 #elif defined(MAXPATHLEN)
@@ -2756,19 +2787,12 @@ int setenv (const char *, const char *, int);
 # define S_IXGRP 0
 #endif
 
-#ifdef _MSC_VER
-# define S_IXUSR _S_IEXEC
-# define stat _stat
-# ifndef _INTPTR_T_DEFINED
-#  define intptr_t int
-# endif
-#endif
-
 #ifndef DIR_SEPARATOR
 # define DIR_SEPARATOR '/'
 # define PATH_SEPARATOR ':'
 #endif
 
+/* path handling portability macros */
 #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
   defined (__OS2__)
 # define HAVE_DOS_BASED_FILE_SYSTEM
@@ -2794,10 +2818,6 @@ int setenv (const char *, const char *, int);
 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
 #endif /* PATH_SEPARATOR_2 */
 
-#ifdef __CYGWIN__
-# define FOPEN_WB wb
-#endif
-
 #ifndef FOPEN_WB
 # define FOPEN_WB w
 #endif
@@ -2811,7 +2831,7 @@ int setenv (const char *, const char *, int);
 } while (0)
 
 #undef LTWRAPPER_DEBUGPRINTF
-#if defined DEBUGWRAPPER
+#if defined LT_DEBUGWRAPPER
 # define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
 static void
 ltwrapper_debugprintf (const char *fmt, ...)
-- 
1.6.0.4