[comp.sys.atari.st] Patch for Gnu programs under RTX

david@doe.utoronto.ca (David Megginson) (10/08/90)

A few days ago, I posted my suspicion that it was the freopen()
function which keeps gcc-cpp.ttp from running with MT C-Shell
(under Micro RTX). I still have not seen the gcc-cpp.ttp source,
but I did try out this test program:

	#include <stdio.h>

	main()
	{
		FILE * fp;

		fp = freopen("hack.txt","w",stdout);
		if( fp )
			fclose(fp);
		else
			fprintf(stderr,"Cannot open hack.txt\n");
	}

The program runs under TOS and MiNT, but not under RTX (which prints the
error message). The reason is that the Gnu freopen() function in this case
attempts to close the standard handle associated with stdout, which
(correctly) causes an error under RTX, while TOS and MiNT are a little
more lenient.

NOTE: compress.ttp also suffers from this problem (the one from
	atari.archive in atari/gnustuff/tos).

PATCH:

Here is a little patch for the close() function in a compiled GCC 1.37
program. Note that this may not work for you, and may even cause the
program to malfunction! Use with care, and back up your originals. What
the patch does is simply have close() return no error even when there is
one.

Search for the following bytes with your binary editor:

3f 3c 00 3e 4e 41 58 4f 34 00 48 c2 6c 0a
                        |
                        74

Change the byte indicated from 34 to 74 (make sure that the _entire_ string
is correct first). Instead of copying the return value from Fclose() from
a0 to a2, this patch has the function set a2 to 0 (success) in all
circumstances.

MIXED SUCCESS:

compress.ttp does not complain about errors opening files when this patch
is applied, but I have not tested it past there.

gcc-cpp.ttp now works with the following command line, which previously
failed under RTX:

	gcc-cpp hello.c hello.cpp

the result is a file hello.cpp. gcc-cc1.ttp can deal with that file.
Unfortunately, using the gcc.ttp driver, there are still problems, and
the error message

	gcc: cannot open ./cc100000.s

appears (where ./cc100000.s is the output file which gcc-cc1 is supposed
to create). I have tried applying this same patch to gcc.ttp, but the
problem persists.

GOOD LUCK, and USE WITH CAUTION.


David Megginson


-- 
////////////////////////////////////////////////////////////////////////
/  David Megginson                      david@doe.utoronto.ca          /
/  Centre for Medieval Studies          meggin@vm.epas.utoronto.ca     /
////////////////////////////////////////////////////////////////////////