🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #1372

Re: MutualExclude for Gadgets

#1372
From: Chuck McManis
Date: Thu, 21 Sep 1989 19:35
40 lines
2662 bytes
In article <7964@cbmvax.UUCP> mks@cbmvax.UUCP (Michael Sinz - CATS) writes:
>Gee, Chuck, you didn't really say that did you?  Location 0 is undefined
>and can contain any value, including ODD values.  (In fact, early A590
>drives placed an odd value at location 0)  ;-)

Actually I did say it, and what's really funny is that Commodore dug the
exact same hole that the VAX implementation of UNIX had. *0 == 0. And
what is one of the reccommended *diagnostics* of the Amiga ? Hmmm? It's
MemWatch trying to guarantee that *nothing* ever writes to low memory.
Endorsed by none other than C/A itself. And even your comment above
about how the 590 *used* to write to location 0, but doesn't now implies
that someone convinced you it was a bug too. 

#define RATIONAL_PROGRAMMING_FOR_A_LIVING_MODE
Depending on implementation peculiarities in any C program
(especially that dereferencing a NULL pointer will point at a 0) is a
major no-no. 
#endif

(Also, my code would dereference '0' as a pointer, *not* what was stored
at 0, so it doesn't matter if the value in 0 is odd, it would just be
returned as a long word with an odd value.) The equivalent "safe" define
for the GADGET_MAGIC define is something like :

#define GADGET_MAGIC(g)	(((struct Gadget *)(g)->UserData != NULL) ? \
		*(unsigned long *)((struct Gadget *)(g)->UserData) : 0)

Your mileage may vary. Or of course you can initialize your gadgets to
have the UserData pointer point at a constant 0 in your code and that would
fix the problem without generating an additional implicit if-then clause with
each testing of the magic number.

So in summary, everyone may agree that looking at *0 is a bug but you will
have a difficult time justifying breaking programs that might depend on 
this behaviour in the future given your implicit support in the past.

--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
These opinions are my own and no one elses, but you knew that didn't you.
"If I were driving a Macintosh, I'd have to stop before I could turn the wheel."
Technical Details
Message-ID: <125083@sun.Eng.Sun.COM>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!sun-barr!newstop!sun!pepper!cmcmanis
References: <1849@cbnewsd.ATT.COM> <125013@sun.Eng.Sun.COM> <7964@cbmvax.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!sun-barr!newstop!sun!pepper!cmcmanis
From: cmcmanis%pepper@Sun.COM (Chuck McManis)
Newsgroups: comp.sys.amiga.tech
Subject: Re: MutualExclude for Gadgets
Keywords: Amiga MutualExclude
Message-ID: <125083@sun.Eng.Sun.COM>
Date: 21 Sep 89 19:35:49 GMT
References: <1849@cbnewsd.ATT.COM> <125013@sun.Eng.Sun.COM> <7964@cbmvax.UUCP>
Sender: news@sun.Eng.Sun.COM
Reply-To: cmcmanis@sun.UUCP (Chuck McManis)
Distribution: usa
Organization: Sun Microsystems, Mountain View
Lines: 40