public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: including <stdlib.h>
@ 1998-02-11 11:23 Kaveh R. Ghazi
  1998-02-11 11:23 ` Robert Lipe
  1998-02-11 17:22 ` Ross Smith
  0 siblings, 2 replies; 15+ messages in thread
From: Kaveh R. Ghazi @ 1998-02-11 11:23 UTC (permalink / raw)
  To: jfc, robertl; +Cc: egcs

 > From: John Carr <jfc@mit.edu>
 > 
 > The *config.h files I referred to are the autoconf-generated config.h,
 > hconfig.h, tconfig.h, and auto-config.h in the gcc build directory.
 > 
 > For example, in auto-config.h replace
 > 	#define HAVE_STDLIB_H 1
 > with
 > 	#include <stdlib.h>

John,

	This approach removes some of the control one might want since,
if you include auto-config.h, you are forced to include the header file
rather than being able to check a macro.  It also removes the ability of
a config/ directory file from being able to override what autoconf tells
us. 

	Another approach would be to supply a "system.h" file which
includes various headers (eg stdlib.h), provides possibly missing system
prototypes (eg bcopy) and possibly missing system macros (eg R_OK),
etc., and each gcc source file could then include this file if desired
to get default stuff.  (Or the source file could instead enumerate these
things manually if the default system.h is not appropriate.)

	I've submitted a draft version of this to Jeff, mostly copied
from the same approach used in the fileutils package.

	Hmmm, I just checked the list archive and for some reason the
file I submitted seems to have stripped all the include statements so
they appear without the file its trying to include inside <>.  Wierd... 

		Thanks,
		--Kaveh
--
Kaveh R. Ghazi			Project Manager / Custom Development
ghazi@caip.rutgers.edu		ICon CMT Corp.

^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: including <stdlib.h>
@ 1998-02-13 10:31 Kaveh R. Ghazi
  0 siblings, 0 replies; 15+ messages in thread
From: Kaveh R. Ghazi @ 1998-02-13 10:31 UTC (permalink / raw)
  To: law; +Cc: egcs, jfc, robertl

 > From: Jeffrey A Law <law@hurl.cygnus.com>
 >  
 >   > On pre-ANSI systems, I think varargs was present on svr3.  I don't know
 >   > about older BSD.  (Did they use _doprnt?)
 >  
 > I don't think we need to worry too much about that -- 4.2BSD had varargs
 > if I remember correctly (it used _doprnt internally in the C library,
 > but I believe it still had a varargs.h include file).
 > jeff 

	The only system I ever had access to on which configure decided
to use _doprnt was an old Tektronix 4300 running a variant of BSD 4.2
called UTek 4.?.  When building meyering's *utils packages, configure
would punt down to _doprnt which was used by *utils/lib/error.c because
vprintf wasn't present.  I don't recall if varargs.h was available or
not. 

	I don't think it matters because to my knowledge gcc never
officially worked on that system, though I think an unofficial port was
floating around. 

	Other BSD 4.2 systems may or may not be an issue.  Anyone
remember what Pyramid OSx 4.x had in its BSD universe?  Hmm, maybe this
doesn't matter? :-)

		--Kaveh
--
Kaveh R. Ghazi			Project Manager / Custom Development
ghazi@caip.rutgers.edu		ICon CMT Corp.

^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: including <stdlib.h>
@ 1998-02-12 19:36 Kaveh R. Ghazi
  1998-02-13  2:04 ` Jeffrey A Law
  0 siblings, 1 reply; 15+ messages in thread
From: Kaveh R. Ghazi @ 1998-02-12 19:36 UTC (permalink / raw)
  To: law; +Cc: egcs, jfc, robertl

 >   >   18 <stdarg.h>
 >   >   17 <varargs.h>
 >  
 > Odd -- that means something in the tree won't be compilable with a non
 > ANSI compiler.  Maybe its something in libgcc2 where this wouldn't be
 > an issue.
 > jeff

	I've found the following scattered all over the gcc source (eg
in calls.c):

#ifdef __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif

So if they're not ANSI, currently they at least need varargs.h.  On
pre-ANSI systems, I think varargs was present on svr3.  I don't know
about older BSD.  (Did they use _doprnt?)

		--Kaveh
--
Kaveh R. Ghazi			Project Manager / Custom Development
ghazi@caip.rutgers.edu		ICon CMT Corp.

^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: including <stdlib.h>
@ 1998-02-11 11:23 Kaveh R. Ghazi
  1998-02-12  4:26 ` Jeffrey A Law
  0 siblings, 1 reply; 15+ messages in thread
From: Kaveh R. Ghazi @ 1998-02-11 11:23 UTC (permalink / raw)
  To: jfc, robertl; +Cc: egcs

 > From: Robert Lipe <robertl@dgii.com>
 > 
 > > 	Another approach would be to supply a "system.h" file which
 > > includes various headers (eg stdlib.h), provides possibly missing system
 > > prototypes (eg bcopy) and possibly missing system macros (eg R_OK),
 > > etc., and each gcc source file could then include this file if desired
 > > to get default stuff.  (Or the source file could instead enumerate these
 > > things manually if the default system.h is not appropriate.)
 > 
 > This would ease maintenance costs, but would presumably cost us
 > something during the compilation phase becuase then everything that
 > includes systems.h also picks up a presumably non-small amount of header
 > stuff that it now gets to preprocess.  I don't know what that cost
 > actually is in measureable terms, and we might decide it's worth it.
 > I just wanted to throw it out for discussion.
 > 

	Yes depending on the cost, that point could be valid.  Perhaps
we only want to include the most frequently used system headers?  I
did a survey using the following shell command (get ready for a
mouthful):

  grep '^#.*include.*<' {.,cp,objc,f,config/*}/*.[ch] | sed 's/.*</</' | \
	awk '{print$1}' | sort | uniq -c | sort -nr

I've appended the results at the end of this message.  I think its
clear that we probably want "system.h" to include <stdio.h> and not
bother with <float.h>. :-) But exactly where the cutoff should be I
don't know.  Maybe we can start with what I submitted and see if it
actually affects compilation time in a noticeable way.  It turns out
that the files in my draft system.h are typically the more frequently
included by the gcc source.



 > Personally, if the cost is anything less than horrible, I'm inclined
 > to support a migration to it.


	Agreed, centralizing this stuff is a win from a maintenance
point of view.  Programmer time is at a higher premium than cpu time.


 > > 	Hmmm, I just checked the list archive and for some reason the
 > > file I submitted seems to have stripped all the include statements so
 > > they appear without the file its trying to include inside <>.  Wierd... 
 > 
 > I've noticed that on the web archives.  I assumed it was the
 > html-ification process not correctly replacing those characters with &lt
 > and &gt so as to escape them from tags.

	Ah, that makes sense.  Thanks.

		--Kaveh



 198 <stdio.h>
  64 <stdlib.h>
  56 <ctype.h>
  47 <string.h>
  30 <sys/types.h>
  26 <errno.h>
  22 <unistd.h>
  18 <stdarg.h>
  17 <varargs.h>
  16 <time.h>
  16 <strings.h>
  15 <sys/stat.h>
  14 <signal.h>
  13 <stddef.h>
  13 <setjmp.h>
  13 <limits.h>
  10 <sys/time.h>
  10 <objc/thr.h>
  10 <malloc.h>
  10 <fcntl.h>
  10 <alloca.h>
   9 <sys/param.h>
   7 <sys/file.h>
   6 <locale.h>
   5 <sys/resource.h>
   5 <stab.h>
   5 <pthread.h>
   5 <netbsd.h>
   5 <m68k/m68k.h>
   5 <i386/gstabs.h>
   4 <xm-netbsd.h>
   4 <xm-lynx.h>
   4 <xm-linux.h>
   4 <windows.h>
   4 <sys/mman.h>
   4 <sparc/sparc.h>
   4 <process.h>
   4 <lynx.h>
   4 <linux-aout.h>
   4 <inttypes.h>
   4 <i386/xm-i386.h>
   4 <dirent.h>
   4 <config.h>
   4 <a.out.h>
   3 <lynx-ng.h>
   3 <gnu-versions.h>
   2 <thread.h>
   2 <sys/wait.h>
   2 <sys/times.h>
   2 <sys/dir.h>
   2 <sparc/xm-sparc.h>
   2 <sparc/sysv4.h>
   2 <objc/objc.h>
   2 <mon.h>
   2 <math.h>
   2 <m68k/xm-m68k.h>
   2 <m68k/coff.h>
   2 <linux.h>
   2 <libintl.h>
   2 <io.h>
   2 <i386/perform.h>
   2 <gnu.h>
   2 <descrip.h>
   2 <arm/xm-arm.h>
   2 <ansidecl.h>
   1 <xm-gnu.h>
   1 <xm-freebsd.h>
   1 <unixlib.h>
   1 <ulocks.h>
   1 <syscall.h>
   1 <sys/vmparam.h>
   1 <sys/vmmac.h>
   1 <sys/varargs.h>
   1 <sys/sysmp.h>
   1 <sys/signal.h>
   1 <sys/prctl.h>
   1 <sys/m88kbcs.h>
   1 <synch.h>
   1 <syms.h>
   1 <syidef.h>
   1 <svr4.h>
   1 <string.h>
   1 <stdio.h>
   1 <stamp.h>
   1 <ssdef.h>
   1 <sgs.h>
   1 <rs6000/rs6000.h>
   1 <pcthread.h>
   1 <os2.h>
   1 <objc/typedstream.h>
   1 <ns32k/xm-ns32k.h>
   1 <ns32k/ns32k.h>
   1 <nam.h>
   1 <mips/mips.h>
   1 <machine/sysnews.h>
   1 <machine/machparam.h>
   1 <mach_o_vals.h>
   1 <mach_o_types.h>
   1 <mach_o_header.h>
   1 <mach_o_format.h>
   1 <mach/mach.h>
   1 <mach/cthreads.h>
   1 <link.h>
   1 <ldfcn.h>
   1 <i386/linux.h>
   1 <i386/i386.h>
   1 <i386/gas.h>
   1 <i386/att.h>
   1 <float.h>
   1 <fab.h>
   1 <dirent.h>
   1 <demangle.h>
   1 <dbxstclass.h>
   1 <assert.h>
   1 <ar.h>
   1 <aoutos.h>
   1 <alloc.h>
--
Kaveh R. Ghazi			Project Manager / Custom Development
ghazi@caip.rutgers.edu		ICon CMT Corp.

^ permalink raw reply	[flat|nested] 15+ messages in thread
* including <stdlib.h>
@ 1998-02-11  4:23 John Carr
  1998-02-11  6:50 ` Robert Lipe
  1998-02-11 11:23 ` Jeffrey A Law
  0 siblings, 2 replies; 15+ messages in thread
From: John Carr @ 1998-02-11  4:23 UTC (permalink / raw)
  To: egcs

Since almost every part of the compiler needs <stdlib.h>, for the
abort prototype if nothing else, it should be included by *config.h
instead of individual files.


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~1998-02-13 10:31 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-02-11 11:23 including <stdlib.h> Kaveh R. Ghazi
1998-02-11 11:23 ` Robert Lipe
1998-02-11 17:22 ` Ross Smith
1998-02-12  4:26   ` Mark Mitchell
1998-02-12 20:07     ` HTML archives (was: Re: including <stdlib.h>) Ross Smith
1998-02-13  2:04       ` Richard Henderson
  -- strict thread matches above, loose matches on Subject: below --
1998-02-13 10:31 including <stdlib.h> Kaveh R. Ghazi
1998-02-12 19:36 Kaveh R. Ghazi
1998-02-13  2:04 ` Jeffrey A Law
1998-02-11 11:23 Kaveh R. Ghazi
1998-02-12  4:26 ` Jeffrey A Law
1998-02-11  4:23 John Carr
1998-02-11  6:50 ` Robert Lipe
1998-02-11  6:50   ` John Carr
1998-02-11 11:23 ` Jeffrey A Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).