This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH to libiberty: declare errno for portability
- To: gcc-patches at gcc dot gnu dot org
- Subject: Re: PATCH to libiberty: declare errno for portability
- From: msokolov at ivan dot Harhan dot ORG (Michael Sokolov)
- Date: Sat, 22 Jul 00 11:53:59 CDT
Zack Weinberg <zack@wolery.cumb.org> wrote:
> What is the purpose of the "|| defined(_MSC_VER) && defined(_INC_ERRNO)" bit?
As I said, I just stole it from bfd in binutils.
> and if we're going to do any more than that then I would prefer you go
> all the way and use an autoconf test.
>
> [test skipped]
So how about this new patch then?
--
Michael Sokolov Harhan Engineering Laboratory
Public Service Agent International Free Computing Task Force
International Engineering and Science Task Force
615 N GOOD LATIMER EXPY STE #4
DALLAS TX 75204-5852 USA
Phone: +1-214-824-7693 (Harhan Eng Lab office)
E-mail: msokolov@ivan.Harhan.ORG (ARPA TCP/SMTP) (UUCP coming soon)
2000-07-22 Michael Sokolov <msokolov@ivan.Harhan.ORG>
* aclocal.m4 (libiberty_AC_DECLARE_ERRNO): New macro.
* configure.in (libiberty_AC_DECLARE_ERRNO): Add check.
* configure, config.in: Regenerate.
* pexecute.c, strtol.c, strtoul.c: Declare errno if necessary.
*** aclocal.m4.orig Sat Jul 22 11:44:45 2000
--- aclocal.m4 Sat Jul 22 10:58:53 2000
***************
*** 69,71 ****
--- 69,85 ----
LIBOBJS="$LIBOBJS strncmp.o"
fi
])
+
+ dnl See if errno must be declared even when <errno.h> is included.
+ AC_DEFUN(libiberty_AC_DECLARE_ERRNO,
+ [AC_CACHE_CHECK(whether errno must be declared, libiberty_cv_declare_errno,
+ [AC_TRY_COMPILE(
+ [#include <errno.h>],
+ [int x = errno;],
+ libiberty_cv_declare_errno=no,
+ libiberty_cv_declare_errno=yes)])
+ if test $libiberty_cv_declare_errno = yes
+ then AC_DEFINE(NEED_DECLARATION_ERRNO, 1,
+ [Define if errno must be declared even when <errno.h> is included.])
+ fi
+ ])
*** configure.in.orig Sat Jul 22 11:44:17 2000
--- configure.in Sat Jul 22 10:59:43 2000
***************
*** 113,118 ****
--- 113,120 ----
AC_HEADER_SYS_WAIT
AC_HEADER_TIME
+ libiberty_AC_DECLARE_ERRNO
+
# This is the list of functions which libiberty will provide if they
# are not available on the host.
*** pexecute.c.orig Sat Jul 22 11:45:13 2000
--- pexecute.c Sat Jul 22 11:06:52 2000
***************
*** 29,34 ****
--- 29,37 ----
#include <stdio.h>
#include <errno.h>
+ #ifdef NEED_DECLARATION_ERRNO
+ extern int errno;
+ #endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
*** strtol.c.orig Sat Jul 22 11:45:36 2000
--- strtol.c Sat Jul 22 11:07:13 2000
***************
*** 39,44 ****
--- 39,47 ----
#endif
#include <ctype.h>
#include <errno.h>
+ #ifdef NEED_DECLARATION_ERRNO
+ extern int errno;
+ #endif
#if 0
#include <stdlib.h>
#endif
*** strtoul.c.orig Sat Jul 22 11:45:57 2000
--- strtoul.c Sat Jul 22 11:07:32 2000
***************
*** 39,44 ****
--- 39,47 ----
#endif
#include <ctype.h>
#include <errno.h>
+ #ifdef NEED_DECLARATION_ERRNO
+ extern int errno;
+ #endif
#if 0
#include <stdlib.h>
#endif