[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Fix compilation warning on Solaris 2.5.1
From: |
Bruno Haible |
Subject: |
Re: [PATCH] Fix compilation warning on Solaris 2.5.1 |
Date: |
Fri, 27 Jun 2003 14:23:31 +0200 |
User-agent: |
KMail/1.5 |
Eric Botcazou wrote:
> As you may (or not) know, GCC aims to be warning-free as of the 3.4
> release, including within its imported subdirectories. I had, therefore, to
> patch intl/localealias.c for Solaris 2.5.1 because the *_unlocked functions
> in stdio.h are guarded by _REENTRANT on this particular release of Solaris.
>
> The complete patch is here:
> http://gcc.gnu.org/ml/gcc-patches/2003-06/msg00782.html
>
> So I'm submitting the intl/ bits hereunder.
Thanks for reporting this. Your patch, however, is wrong:
1) It does not address the reason of the warning. Namely, at the
times of Solaris 2.5.1, this *_unlocked API was not stable; in
fact these functions were removed in Solaris 2.6. So if you use
them in Solaris 2.5.1, you create binaries that don't work on
Solaris 2.6 !
2) Defining _REENTRANT is a dangerous global switch. It might require
that you link to a thread library, or maybe on FreeBSD that you
link with libc_r instead of libc.
Please use this patch instead (resolving possible rejects manually).
Bruno
2003-06-27 Bruno Haible <address@hidden>
Avoid use of *_unlocked functions on Solaris 2.5.1.
* gettext.m4 (AM_INTL_SUBDIR): Don't test for the functions
feof_unlocked, fgets_unlocked, getc_unlocked. Test for their
declaration instead.
(gt_CHECK_DECL): New macro.
Reported by Eric Botcazou <address@hidden>.
2003-06-27 Bruno Haible <address@hidden>
Avoid use of *_unlocked functions on Solaris 2.5.1.
* localcharset.c: Test HAVE_DECL_GETC_UNLOCKED, not HAVE_GETC_UNLOCKED.
* localealias.c: Test HAVE_DECL_*_UNLOCKED, not HAVE_*_UNLOCKED.
Reported by Eric Botcazou <address@hidden>.
*** m4/gettext.m4 19 Jun 2003 12:45:06 -0000 1.9
--- m4/gettext.m4 27 Jun 2003 12:10:06 -0000
***************
*** 377,386 ****
AC_CHECK_TYPES([ptrdiff_t])
AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
stdlib.h string.h unistd.h sys/param.h])
! AC_CHECK_FUNCS([asprintf feof_unlocked fgets_unlocked getc_unlocked getcwd \
! getegid geteuid getgid getuid mempcpy munmap putenv setenv setlocale snprintf
\
! stpcpy strcasecmp strdup strtoul tsearch wprintf __argz_count \
! __argz_stringify __argz_next __fsetlocking])
case $gt_cv_func_printf_posix in
*yes) HAVE_POSIX_PRINTF=1 ;;
--- 377,394 ----
AC_CHECK_TYPES([ptrdiff_t])
AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
stdlib.h string.h unistd.h sys/param.h])
! AC_CHECK_FUNCS([asprintf getcwd getegid geteuid getgid getuid mempcpy \
! munmap putenv setenv setlocale snprintf stpcpy strcasecmp strdup strtoul \
! tsearch wprintf __argz_count __argz_stringify __argz_next __fsetlocking])
!
! dnl Use the *_unlocked functions only if they are declared.
! dnl (because some of them were declared in Solaris 2.5.1 but were removed
! dnl in Solaris 2.6, whereas we want binaries built on Solaris 2.5.1 to run
! dnl on Solaris 2.6).
! dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13.
! gt_CHECK_DECL(feof_unlocked, [#include <stdio.h>])
! gt_CHECK_DECL(fgets_unlocked, [#include <stdio.h>])
! gt_CHECK_DECL(getc_unlocked, [#include <stdio.h>])
case $gt_cv_func_printf_posix in
*yes) HAVE_POSIX_PRINTF=1 ;;
***************
*** 442,447 ****
--- 450,475 ----
if test $ac_verc_fail = yes; then
INTLBISON=:
fi
+ ])
+
+
+ dnl gt_CHECK_DECL(FUNC, INCLUDES)
+ dnl Check whether a function is declared.
+ AC_DEFUN([gt_CHECK_DECL],
+ [
+ AC_CACHE_CHECK([whether $1 is declared], ac_cv_have_decl_$1,
+ [AC_TRY_COMPILE([$2], [
+ #ifndef $1
+ char *p = (char *) $1;
+ #endif
+ ], ac_cv_have_decl_$1=yes, ac_cv_have_decl_$1=no)])
+ if test $ac_cv_have_decl_$1 = yes; then
+ gt_value=1
+ else
+ gt_value=0
+ fi
+ AC_DEFINE_UNQUOTED([HAVE_DECL_]translit($1, [a-z], [A-Z]), [$gt_value],
+ [Define to 1 if you have the declaration of `$1', and to 0 if you don't.])
])
*** intl/localcharset.c 14 Apr 2003 13:39:21 -0000 1.4
--- intl/localcharset.c 27 Jun 2003 12:10:06 -0000
***************
*** 86,92 ****
# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
#endif
! #ifdef HAVE_GETC_UNLOCKED
# undef getc
# define getc getc_unlocked
#endif
--- 86,92 ----
# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
#endif
! #if HAVE_DECL_GETC_UNLOCKED
# undef getc
# define getc getc_unlocked
#endif
*** intl/localealias.c 31 Mar 2003 20:02:54 -0000 1.3
--- intl/localealias.c 27 Jun 2003 12:10:06 -0000
***************
*** 110,120 ****
# define freea(p) free (p)
#endif
! #if defined _LIBC_REENTRANT || defined HAVE_FGETS_UNLOCKED
# undef fgets
# define fgets(buf, len, s) fgets_unlocked (buf, len, s)
#endif
! #if defined _LIBC_REENTRANT || defined HAVE_FEOF_UNLOCKED
# undef feof
# define feof(s) feof_unlocked (s)
#endif
--- 110,120 ----
# define freea(p) free (p)
#endif
! #if defined _LIBC_REENTRANT || HAVE_DECL_FGETS_UNLOCKED
# undef fgets
# define fgets(buf, len, s) fgets_unlocked (buf, len, s)
#endif
! #if defined _LIBC_REENTRANT || HAVE_DECL_FEOF_UNLOCKED
# undef feof
# define feof(s) feof_unlocked (s)
#endif