This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

FWIW: gcc-2.95.3 strtol fix


Hi there,

I know that nobody cares and that the door for 2.95.3 patches is long shut, but
still those poor souls who have to use 2.95.x (e.g., because they use large
third-party patches against it) and who need to build it on host systems like
mine will find the patch below useful.

This patch fixes a strtol problem in 2.95.x identical to the strstr problem in
2.97 I've produced a patch for at the end of the previous millennium. (The
latter patch for the mainline was approved by Alexandre Oliva and I'll check it
in when I get my write access.) This patch is based on the one for the
mainline, with strstr changed to strtol, converted to the 2.95.x conventions
for M4 macro names, and has the errno declaration bit added because libiberty's
strtol.c needs it (strstr.c doesn't, so this is not an issue for the mainline).

--
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)

2001-01-08  Michael Sokolov  <msokolov@ivan.Harhan.ORG>

	* aclocal.m4 (GCC_FUNC_STRTOL): New macro.
	(GCC_DECLARE_ERRNO): New macro.
	* configure.in (GCC_FUNC_STRTOL): Add invokation.
	(GCC_DECLARE_ERRNO): Add invokation.
	* configure, config.in: Regenerate.
	* Makefile.in (STRTOL, HOST_STRTOL, USE_HOST_STRTOL): New variables.
	(LIBDEPS, HOST_LIBDEPS, LIBS, HOST_LIBS): Add strtol handling.
	(strtol.o, $(HOST_PREFIX_1)strtol.o): New rules.
	(doprint.o): New rule.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/Makefile.in,v
retrieving revision 1.264.4.7
diff -p -r1.264.4.7 Makefile.in
*** Makefile.in	2000/12/18 14:18:13	1.264.4.7
--- Makefile.in	2001/01/08 17:58:38
*************** OBSTACK=obstack.o
*** 328,333 ****
--- 328,334 ----
  # Configure will set these if you need vfprintf and possibly _doprnt support.
  VFPRINTF=@vfprintf@
  DOPRINT=@doprint@
+ STRTOL=@strtol@
  
  # Specify the rule for actually making libgcc.a,
  LIBGCC = libgcc.a
*************** HOST_MALLOC=$(MALLOC)
*** 474,479 ****
--- 475,481 ----
  HOST_OBSTACK=$(OBSTACK)
  HOST_VFPRINTF=$(VFPRINTF)
  HOST_DOPRINT=$(DOPRINT)
+ HOST_STRTOL=$(STRTOL)
  
  # Actual name to use when installing a native compiler.
  GCC_INSTALL_NAME = `t='$(program_transform_name)'; echo gcc | sed -e $$t`
*************** USE_HOST_MALLOC= ` case "${HOST_MALLOC}"
*** 563,588 ****
  USE_HOST_OBSTACK= ` case "${HOST_OBSTACK}" in ?*) echo ${HOST_PREFIX}${HOST_OBSTACK} ;; esac `
  USE_HOST_VFPRINTF= ` case "${HOST_VFPRINTF}" in ?*) echo ${HOST_PREFIX}${HOST_VFPRINTF} ;; esac `
  USE_HOST_DOPRINT= ` case "${HOST_DOPRINT}" in ?*) echo ${HOST_PREFIX}${HOST_DOPRINT} ;; esac `
  
  # Dependency on obstack, alloca, malloc or whatever library facilities
  # are not installed in the system libraries.
  # We don't use USE_ALLOCA because backquote expansion doesn't work in deps.
! LIBDEPS= $(INTLLIBS) $(OBSTACK) $(ALLOCA) $(MALLOC) $(VFPRINTF) $(DOPRINT)
  
  # Likewise, for use in the tools that must run on this machine
  # even if we are cross-building GCC.
  # We don't use USE_ALLOCA because backquote expansion doesn't work in deps.
! HOST_LIBDEPS= $(HOST_PREFIX)$(HOST_INTLLIBS) $(HOST_PREFIX)$(HOST_OBSTACK) $(HOST_PREFIX)$(HOST_ALLOCA) $(HOST_PREFIX)$(HOST_MALLOC) $(HOST_PREFIX)$(HOST_VFPRINTF) $(HOST_PREFIX)$(HOST_DOPRINT)
  
  # How to link with both our special library facilities
  # and the system's installed libraries.
! LIBS = $(OBSTACK) $(USE_ALLOCA) $(MALLOC) $(INTLLIBS) @LIBS@ $(VFPRINTF) $(DOPRINT) $(CLIB) ../libiberty/libiberty.a
  
  # Likewise, for use in the tools that must run on this machine
  # even if we are cross-building GCC.
  HOST_LIBS = $(USE_HOST_OBSTACK) $(USE_HOST_ALLOCA) $(USE_HOST_MALLOC)  \
  	    $(HOST_INTLLIBS) $(USE_HOST_VFPRINTF) $(USE_HOST_DOPRINT) \
! 	    $(HOST_CLIB)
  
  HOST_RTL = $(HOST_PREFIX)rtl.o $(HOST_PREFIX)bitmap.o
  HOST_RTLANAL = $(HOST_PREFIX)rtlanal.o
--- 565,591 ----
  USE_HOST_OBSTACK= ` case "${HOST_OBSTACK}" in ?*) echo ${HOST_PREFIX}${HOST_OBSTACK} ;; esac `
  USE_HOST_VFPRINTF= ` case "${HOST_VFPRINTF}" in ?*) echo ${HOST_PREFIX}${HOST_VFPRINTF} ;; esac `
  USE_HOST_DOPRINT= ` case "${HOST_DOPRINT}" in ?*) echo ${HOST_PREFIX}${HOST_DOPRINT} ;; esac `
+ USE_HOST_STRTOL= ` case "${HOST_STRTOL}" in ?*) echo ${HOST_PREFIX}${HOST_STRTOL} ;; esac `
  
  # Dependency on obstack, alloca, malloc or whatever library facilities
  # are not installed in the system libraries.
  # We don't use USE_ALLOCA because backquote expansion doesn't work in deps.
! LIBDEPS= $(INTLLIBS) $(OBSTACK) $(ALLOCA) $(MALLOC) $(VFPRINTF) $(DOPRINT) $(STRTOL)
  
  # Likewise, for use in the tools that must run on this machine
  # even if we are cross-building GCC.
  # We don't use USE_ALLOCA because backquote expansion doesn't work in deps.
! HOST_LIBDEPS= $(HOST_PREFIX)$(HOST_INTLLIBS) $(HOST_PREFIX)$(HOST_OBSTACK) $(HOST_PREFIX)$(HOST_ALLOCA) $(HOST_PREFIX)$(HOST_MALLOC) $(HOST_PREFIX)$(HOST_VFPRINTF) $(HOST_PREFIX)$(HOST_DOPRINT) $(HOST_PREFIX)$(HOST_STRTOL)
  
  # How to link with both our special library facilities
  # and the system's installed libraries.
! LIBS = $(OBSTACK) $(USE_ALLOCA) $(MALLOC) $(INTLLIBS) @LIBS@ $(VFPRINTF) $(DOPRINT) $(STRTOL) $(CLIB) ../libiberty/libiberty.a
  
  # Likewise, for use in the tools that must run on this machine
  # even if we are cross-building GCC.
  HOST_LIBS = $(USE_HOST_OBSTACK) $(USE_HOST_ALLOCA) $(USE_HOST_MALLOC)  \
  	    $(HOST_INTLLIBS) $(USE_HOST_VFPRINTF) $(USE_HOST_DOPRINT) \
! 	    $(USE_HOST_STRTOL) $(HOST_CLIB)
  
  HOST_RTL = $(HOST_PREFIX)rtl.o $(HOST_PREFIX)bitmap.o
  HOST_RTLANAL = $(HOST_PREFIX)rtlanal.o
*************** vfprintf.o: $(srcdir)/../libiberty/vfpri
*** 1378,1383 ****
--- 1381,1394 ----
  	$(LN_S) $(srcdir)/../libiberty/vfprintf.c vfprintf.c
  	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) vfprintf.c
  
+ doprint.o: $(srcdir)/doprint.c $(CONFIG_H) system.h
+ 	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(srcdir)/doprint.c
+ 
+ strtol.o: $(srcdir)/../libiberty/strtol.c $(CONFIG_H) system.h
+ 	rm -f strtol.c
+ 	$(LN_S) $(srcdir)/../libiberty/strtol.c strtol.c
+ 	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) strtol.c
+ 
  splay-tree.o: $(srcdir)/../libiberty/splay-tree.c \
    $(srcdir)/../include/splay-tree.h $(srcdir)/../include/libiberty.h
  	rm -f splay-tree.c
*************** $(HOST_PREFIX_1)doprint.o: doprint.c
*** 1905,1910 ****
--- 1916,1926 ----
  	sed -e 's/config[.]h/hconfig.h/' $(srcdir)/doprint.c > $(HOST_PREFIX)doprint.c
  	$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)doprint.c
  
+ $(HOST_PREFIX_1)strtol.o: $(srcdir)/../libiberty/strtol.c
+ 	rm -f $(HOST_PREFIX)strtol.c
+ 	sed -e 's/config[.]h/hconfig.h/' $(srcdir)/../libiberty/strtol.c > $(HOST_PREFIX)strtol.c
+ 	$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)strtol.c
+ 
  $(HOST_PREFIX_1)malloc.o: malloc.c
  	rm -f $(HOST_PREFIX)malloc.c
  	sed -e 's/config[.]h/hconfig.h/' $(srcdir)/malloc.c > $(HOST_PREFIX)malloc.c
Index: aclocal.m4
===================================================================
RCS file: /cvs/gcc/egcs/gcc/aclocal.m4,v
retrieving revision 1.17
diff -p -r1.17 aclocal.m4
*** aclocal.m4	1999/04/15 01:50:45	1.17
--- aclocal.m4	2001/01/08 17:58:40
*************** AC_SUBST(vfprintf)
*** 77,82 ****
--- 77,87 ----
  AC_SUBST(doprint)
  ])    
  
+ dnl Check if we have strtol.
+ AC_DEFUN([GCC_FUNC_STRTOL],
+   [AC_CHECK_FUNCS([strtol], [strtol=], [strtol=strtol.o])
+    AC_SUBST([strtol])])
+ 
  dnl See if the printf functions in libc support %p in format strings.
  AC_DEFUN(GCC_FUNC_PRINTF_PTR,
  [AC_CACHE_CHECK(whether the printf functions support %p,
*************** main()
*** 95,100 ****
--- 100,119 ----
  rm -f core core.* *.core])
  if test $gcc_cv_func_printf_ptr = yes ; then
    AC_DEFINE(HAVE_PRINTF_PTR)
+ fi
+ ])
+ 
+ dnl See if errno must be declared even when <errno.h> is included.
+ AC_DEFUN(GCC_DECLARE_ERRNO,
+ [AC_CACHE_CHECK(whether errno must be declared, gcc_cv_declare_errno,
+ [AC_TRY_COMPILE(
+ [#include <errno.h>],
+ [int x = errno;],
+ gcc_cv_declare_errno=no,
+ gcc_cv_declare_errno=yes)])
+ if test $gcc_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/gcc/configure.in,v
retrieving revision 1.246.4.16
diff -p -r1.246.4.16 configure.in
*** configure.in	2001/01/01 17:27:55	1.246.4.16
--- configure.in	2001/01/08 17:58:48
*************** AC_CHECK_FUNCS(strtoul bsearch strerror 
*** 392,398 ****
--- 392,400 ----
  #AC_CHECK_TYPE(wchar_t, unsigned int)
  
  GCC_FUNC_VFPRINTF_DOPRNT
+ GCC_FUNC_STRTOL
  GCC_FUNC_PRINTF_PTR
+ GCC_DECLARE_ERRNO
  
  case "${host}" in
  *-*-uwin*)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]