[patch] to libiberty for 2.95.3: backport 4.3BSD fixes

Michael Sokolov msokolov@ivan.Harhan.ORG
Wed Dec 13 19:36:00 GMT 2000


Hi there,

Last July I've made the following changes to libiberty (with some fixes by
Jeff):

: 2000-07-23  Michael Sokolov  <msokolov@ivan.Harhan.ORG>
:             Jeff Law <law@cygnus.com>
:
:         * configure.in (AC_CHECK_HEADERS): Add time.h.
:         (AC_HEADER_TIME): Add check.
:         * configure, config.in: Regenerate.
:         * getruntime.c: Portably #include <sys/time.h> and/or <time.h>.
:
:         * configure.in (AC_CHECK_HEADERS): Add limits.h.
:         * configure, config.in: Regenerate.
:         * sort.c: Portably #include <limits.h> and/or <sys/param.h>.
:         * strtol.c, strtoul.c: #include "config.h". Portably #include
:         <limits.h> and/or <sys/param.h>.
:         * Makefile.in (strtol.o, strtoul.o): Update dependencies.
:
:         * 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.
:
:         * cp-demangle.c, mkstemps.c: #include <sys/types.h>.

to fix it for 4.3BSD, which was badly broken.

Bernd, would it be possible to include these fixes in 2.95.3 so that it doesn't
break on 4.3BSD in libiberty? On the branch aclocal.m4 must be added as a new
file, because it didn't exist yet back then, and ignore the sort.c and and
cp-demangle.c patches, because those files weren't there either, but the rest
applies to the branch correctly without changing a single line.

You could merge the changes from the trunk, but to save you the work, I have
included the diff below that applies cleanly to the branch. It's one big diff
as there are no new not-approved-yet changes, just a merge from the trunk. I
have also provided the ChangeLog entry, taken from the trunk except for
adjusting the aclocal.m4 entry and removing sort.c and cp-demangle.c.

--
Michael Sokolov
Public Service Agent
International Engineering and Science Task Force

1351 VINE AVE APT 27		Phone: +1-714-738-5409
FULLERTON CA 92833-4291 USA	(home office)

E-mail: msokolov@ivan.Harhan.ORG (ARPA TCP/SMTP)

Wed Dec 13 19:30:51 PST 2000  Michael Sokolov  <msokolov@ivan.Harhan.ORG>

	from HEAD 2000-07-23  Michael Sokolov  <msokolov@ivan.Harhan.ORG>
			      Jeff Law <law@cygnus.com>

	* configure.in (AC_CHECK_HEADERS): Add time.h.
	(AC_HEADER_TIME): Add check.
	* configure, config.in: Regenerate.
	* getruntime.c: Portably #include <sys/time.h> and/or <time.h>.

	* configure.in (AC_CHECK_HEADERS): Add limits.h.
	* configure, config.in: Regenerate.
	* strtol.c, strtoul.c: #include "config.h". Portably #include
	<limits.h> and/or <sys/param.h>.
	* Makefile.in (strtol.o, strtoul.o): Update dependencies.

	* aclocal.m4: New file.
	* configure.in (libiberty_AC_DECLARE_ERRNO): Add check.
	* configure, config.in: Regenerate.
	* pexecute.c, strtol.c, strtoul.c: Declare errno if necessary.

	* mkstemps.c: #include <sys/types.h>.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/libiberty/Makefile.in,v
retrieving revision 1.22.4.6
diff -c -r1.22.4.6 Makefile.in
*** Makefile.in	1999/08/07 05:36:11	1.22.4.6
--- Makefile.in	2000/07/30 01:46:41
***************
*** 266,271 ****
--- 266,273 ----
  splay-tree.o: config.h $(INCDIR)/libiberty.h $(INCDIR)/splay-tree.h $(INCDIR)/ansidecl.h
  strerror.o: config.h $(INCDIR)/libiberty.h
  strsignal.o: config.h $(INCDIR)/libiberty.h
+ strtol.o: config.h
+ strtoul.o: config.h
  xatexit.o: $(INCDIR)/libiberty.h
  xexit.o: $(INCDIR)/libiberty.h
  xmalloc.o: $(INCDIR)/libiberty.h
*** /dev/null	Sat Jul 29 20:27:57 2000
--- aclocal.m4	Sat Jul 29 19:59:22 2000
***************
*** 0 ****
--- 1,13 ----
+ 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
+ ])
Index: configure.in
===================================================================
RCS file: /cvs/gcc/egcs/libiberty/configure.in,v
retrieving revision 1.18.4.3
diff -c -r1.18.4.3 configure.in
*** configure.in	1999/06/21 05:00:24	1.18.4.3
--- configure.in	2000/07/30 01:47:35
***************
*** 106,113 ****
  # It's OK to check for header files.  Although the compiler may not be
  # able to link anything, it had better be able to at least compile
  # something.
! AC_CHECK_HEADERS(sys/file.h sys/param.h stdlib.h string.h unistd.h strings.h sys/time.h sys/resource.h)
  AC_HEADER_SYS_WAIT
  
  # This is the list of functions which libiberty will provide if they
  # are not available on the host.
--- 106,116 ----
  # It's OK to check for header files.  Although the compiler may not be
  # able to link anything, it had better be able to at least compile
  # something.
! AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h)
  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.
Index: getruntime.c
===================================================================
RCS file: /cvs/gcc/egcs/libiberty/getruntime.c,v
retrieving revision 1.5
diff -c -r1.5 getruntime.c
*** getruntime.c	1999/05/06 20:57:01	1.5
--- getruntime.c	2000/07/30 01:47:35
***************
*** 26,35 ****
     single way is available for all host systems, nor are there reliable
     ways to find out which way is correct for a given host. */
  
! #include <time.h>
  
  #if defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H)
- #include <sys/time.h>
  #include <sys/resource.h>
  #endif
  
--- 26,45 ----
     single way is available for all host systems, nor are there reliable
     ways to find out which way is correct for a given host. */
  
! #ifdef TIME_WITH_SYS_TIME
! # include <sys/time.h>
! # include <time.h>
! #else
! # if HAVE_SYS_TIME_H
! #  include <sys/time.h>
! # else
! #  ifdef HAVE_TIME_H
! #   include <time.h>
! #  endif
! # endif
! #endif
  
  #if defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H)
  #include <sys/resource.h>
  #endif
  
Index: mkstemps.c
===================================================================
RCS file: /cvs/gcc/egcs/libiberty/mkstemps.c,v
retrieving revision 1.1
diff -c -r1.1 mkstemps.c
*** mkstemps.c	1999/02/09 00:17:32	1.1
--- mkstemps.c	2000/07/30 01:47:36
***************
*** 20,25 ****
--- 20,26 ----
  #include "config.h"
  #endif
  
+ #include <sys/types.h>
  #ifdef HAVE_STDLIB_H
  #include <stdlib.h>
  #endif
Index: pexecute.c
===================================================================
RCS file: /cvs/gcc/egcs/libiberty/pexecute.c,v
retrieving revision 1.13
diff -c -r1.13 pexecute.c
*** pexecute.c	1999/04/11 22:21:27	1.13
--- pexecute.c	2000/07/30 01:47:39
***************
*** 29,34 ****
--- 29,37 ----
  
  #include <stdio.h>
  #include <errno.h>
+ #ifdef NEED_DECLARATION_ERRNO
+ extern int errno;
+ #endif
  #ifdef HAVE_UNISTD_H
  #include <unistd.h>
  #endif
Index: strtol.c
===================================================================
RCS file: /cvs/gcc/egcs/libiberty/strtol.c,v
retrieving revision 1.3
diff -c -r1.3 strtol.c
*** strtol.c	1998/12/14 07:01:02	1.3
--- strtol.c	2000/07/30 01:47:40
***************
*** 31,39 ****
--- 31,50 ----
   * SUCH DAMAGE.
   */
  
+ #ifdef HAVE_CONFIG_H
+ #include "config.h"
+ #endif
+ #ifdef HAVE_LIMITS_H
  #include <limits.h>
+ #endif
+ #ifdef HAVE_SYS_PARAM_H
+ #include <sys/param.h>
+ #endif
  #include <ctype.h>
  #include <errno.h>
+ #ifdef NEED_DECLARATION_ERRNO
+ extern int errno;
+ #endif
  #if 0
  #include <stdlib.h>
  #endif
Index: strtoul.c
===================================================================
RCS file: /cvs/gcc/egcs/libiberty/strtoul.c,v
retrieving revision 1.3
diff -c -r1.3 strtoul.c
*** strtoul.c	1998/12/14 07:01:03	1.3
--- strtoul.c	2000/07/30 01:47:41
***************
*** 31,39 ****
--- 31,50 ----
   * SUCH DAMAGE.
   */
  
+ #ifdef HAVE_CONFIG_H
+ #include "config.h"
+ #endif
+ #ifdef HAVE_LIMITS_H
  #include <limits.h>
+ #endif
+ #ifdef HAVE_SYS_PARAM_H
+ #include <sys/param.h>
+ #endif
  #include <ctype.h>
  #include <errno.h>
+ #ifdef NEED_DECLARATION_ERRNO
+ extern int errno;
+ #endif
  #if 0
  #include <stdlib.h>
  #endif


More information about the Gcc-patches mailing list