rcb@netcom.COM (Roy Bixler) (03/27/91)
I've found a bug (or at least an unintuitive feature :-) ) in the library supplied with GNU C 1.37.1 found on atari.archive. When I make a call to stat(), after the call, the address returned by Fgetdta() is different than it was before the call. Is this a bug? If so, why would it be desirable for stat() to have this side-effect? -- Roy Bixler rcb@netcom.com -or- (UUCP) uunet!apple!netcom!rcb
david@doe.utoronto.ca (David Megginson) (03/27/91)
In <1991Mar27.030421.587@netcom.COM>, Roy Bixler writes: > > I've found a bug (or at least an unintuitive feature :-) ) in the > library supplied with GNU C 1.37.1 found on atari.archive. When I > make a call to stat(), after the call, the address returned by > Fgetdta() is different than it was before the call. Is this a bug? > If so, why would it be desirable for stat() to have this side-effect? > > -- > Roy Bixler > rcb@netcom.com -or- (UUCP) uunet!apple!netcom!rcb That's precisely why you have to call Fgetdta(). Usually, you would not want to mix Unix-type calls (stat()) and TOS-type calls (Fsfirst()/Fsnext()) in the same program anyway, but if you have to, always check. The reason it changes it is that stat() most likely uses Fsfirst()/Fsnext() to check the file's status, and it has to set up its own DTA buffer to do it. In general, you might want to switch to Eric Smith's MiNT library. It is an update and improvement on the standard GCC library, and is also available on atari.archive. -- //////////////////////////////////////////////////////////////////////// / David Megginson david@doe.utoronto.ca / / Centre for Medieval Studies meggin@vm.epas.utoronto.ca / ////////////////////////////////////////////////////////////////////////
rcb@netcom.COM (Roy Bixler) (03/29/91)
In article <1991Mar27.152726.8444@doe.utoronto.ca> david@doe.utoronto.ca (David Megginson) writes: > >In <1991Mar27.030421.587@netcom.COM>, Roy Bixler writes: >> >> I've found a bug (or at least an unintuitive feature :-) ) in the >> library supplied with GNU C 1.37.1 found on atari.archive. When I >> make a call to stat(), after the call, the address returned by >> Fgetdta() is different than it was before the call. Is this a bug? >> If so, why would it be desirable for stat() to have this side-effect? >> >> -- >> Roy Bixler >> rcb@netcom.com -or- (UUCP) uunet!apple!netcom!rcb > >That's precisely why you have to call Fgetdta(). Usually, you would not >want to mix Unix-type calls (stat()) and TOS-type calls (Fsfirst()/Fsnext()) >in the same program anyway, but if you have to, always check. I would argue that the stat() and all other such functions should have an Fgetdta() in the 1st line of their code and an Fsetdta() in the last. That is just good practice. Probably a moot point, since GCC library is free and you get what you pay for. [reasons for stat() et al's unfriendly behavior deleted] >In general, you might want to switch to Eric Smith's MiNT library. It >is an update and improvement on the standard GCC library, and is >also available on atari.archive. Yes, but you need MiNT to run a program compiled with that library, correct? If not, that is definitely a win-win situation! > > >-- >//////////////////////////////////////////////////////////////////////// >/ David Megginson david@doe.utoronto.ca / >/ Centre for Medieval Studies meggin@vm.epas.utoronto.ca / >//////////////////////////////////////////////////////////////////////// -- Roy Bixler rcb@netcom.com -or- (UUCP) uunet!apple!netcom!rcb
david@doe.utoronto.ca (David Megginson) (03/29/91)
In <1991Mar28.194823.2209@netcom.COM>, Roy Bixler writes: > > Yes, but you need MiNT to run a program compiled with that library, > correct? If not, that is definitely a win-win situation! > You don't need MiNT, unless your program is doing stuff that TOS really doesn't support, like forking. -- //////////////////////////////////////////////////////////////////////// / David Megginson david@doe.utoronto.ca / / Centre for Medieval Studies meggin@vm.epas.utoronto.ca / ////////////////////////////////////////////////////////////////////////
apratt@atari.UUCP (Allan Pratt) (04/02/91)
>In <1991Mar27.030421.587@netcom.COM>, Roy Bixler writes: >> >> I've found a bug (or at least an unintuitive feature :-) ) in the >> library supplied with GNU C 1.37.1 found on atari.archive. When I >> make a call to stat(), after the call, the address returned by >> Fgetdta() is different than it was before the call. Is this a bug? Yes. Every library call which changes something like the DTA address should change it back. Most of them do; this one doesn't. I think it only doesn't under some circumstances, like when the file doesn't exist. david@doe.utoronto.ca (David Megginson) writes: >In general, you might want to switch to Eric Smith's MiNT library. It >is an update and improvement on the standard GCC library, and is >also available on atari.archive. And furthermore it incorporates bugfixes which have percolated into both libraries over the time since the 1.37.1 port for the ST was released. ============================================ Opinions expressed above do not necessarily -- Allan Pratt, Atari Corp. reflect those of Atari Corp. or anyone else. ...ames!atari!apratt
7103_2622@uwovax.uwo.ca (Eric Smith) (04/02/91)
>>> I've found a bug (or at least an unintuitive feature :-) ) in the >>> library supplied with GNU C 1.37.1 found on atari.archive. When I >>> make a call to stat(), after the call, the address returned by >>> Fgetdta() is different than it was before the call. Is this a bug? >>> If so, why would it be desirable for stat() to have this side-effect? > I would argue that the stat() and all other such functions should have > an Fgetdta() in the 1st line of their code and an Fsetdta() in the > last. That is just good practice. > You're quite correct. Actually, in the latest version of the GCC library this *is* done, except that the function returns prematurely if the file is not found (i.e. the DTA pointer is messed up if you do a stat() on a file that doesn't exist). The MiNT library also has this bug at patchlevel 7; it (and lots of other bugs) are fixed in patchlevel 8, which is now available at atari.archive. >>In general, you might want to switch to Eric Smith's MiNT library. It >>is an update and improvement on the standard GCC library, and is >>also available on atari.archive. > > Yes, but you need MiNT to run a program compiled with that library, > correct? If not, that is definitely a win-win situation! > No, not correct. The library works under TOS, except that some functions that are MiNT specific (e.g. fork, pipe, spawnve(P_NOWAIT,...)) will fail -- if you avoid those kinds of functions, e.g. by writing standard ANSI C, then your program will work fine under either TOS or MiNT. (NetHack 3.0j was compiled with the MiNT library, for example, and that certainly exercises a lot of functions!) -- Eric R. Smith email: Dept. of Mathematics eric.smith@uwo.ca University of Western Ontario 7103_2622@uwovax.bitnet