[gnu.gcc.bug] Little known fix to use dbm & gcc together

rms@WHEATIES.AI.MIT.EDU (Richard Stallman) (12/23/88)

That fix will work on machines where PCC uses its traditional
nonreentrant calling convention: the 68k, the vax, and probably the
32k.  It won't work on the 386 or the sparc, since there PCC uses a
different convention, and returning a structure does not look like
returning a pointer.

On the 386, PCC and GCC use the same convention except for 1, 2, 4 or
8 byte structures.  Alas, this structure is 8 bytes.  You might be
able to win by declaring `datum' to have a third int field, so that
would be more than 8 bytes long.

I don't know what would work on the sparc.  Perhaps that same technique
would work.


If anyone can design a clean piece of shell script to add to the
fixincludes file, which would automatically determine which machine
you are on (perhaps by looking at the names or contents of files made
by config.gcc) and make the right changes to a copy of dbm.h, I would
be glad to install it.

Note there is no need for this copy to contain any #ifdef's for GNU
CC, since a file in the gcc-include directory is used only with GNU CC
in the first place.

ado@elsie.UUCP (Arthur David Olson) (12/25/88)

> . . .there is no need for this copy to contain any #ifdef's for GNU
> CC, since a file in the gcc-include directory is used only with GNU CC
> in the first place.

The file may need to be attentive to whether "-traditional" has been used
(perhaps by checking __STDC__).  With the Gene Spafford changes in place:

	Script started on Sat Dec 24 18:45:31 1988
	elsie$ cat try.c
	#include <dbm.h>
	main(){fetch();}
	elsie$ /usr/local/bin/gcc -v try.c -ldbm
	gcc version 1.32
	 /usr/local/lib/gcc-cpp -v -undef -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 try.c /tmp/cca07721.cpp
	GNU CPP version 1.32
	 /usr/local/lib/gcc-cc1 /tmp/cca07721.cpp -quiet -dumpbase try.c -version -o /tmp/cca07721.s
	GNU C version 1.32 (68k, MIT syntax) compiled by GNU C version 1.32.
	 as -mc68020 /tmp/cca07721.s -o try.o
	 ld -e start -dc -dp /lib/crt0.o /lib/Mcrt1.o try.o -ldbm /usr/local/lib/gcc-gnulib -lc
	elsie$ /usr/local/bin/gcc -v -traditional try.c -ldbm
	gcc version 1.32
	 /usr/local/lib/gcc-cpp -v -undef -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -traditional -D__HAVE_68881__ -Dmc68020 try.c /tmp/cca07800.cpp
	GNU CPP version 1.32
>>>>	try.c:2: recursive use of macro `fetch'
	elsie$ exit

	script done on Sat Dec 24 18:46:10 1988
-- 
	Arthur David Olson    ado@ncifcrf.gov    ADO is a trademark of Ampex.