Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!keith From: keith@Apple.COM (Keith Rollin) Newsgroups: comp.sys.mac.programmer Subject: Re: StripAddress... Message-ID: <38276@apple.Apple.COM> Date: 2 Feb 90 03:33:51 GMT References: <1990Feb2.010425.28126@oracle.com> Organization: Apple Computer Inc, Cupertino, CA Lines: 52 In article <1990Feb2.010425.28126@oracle.com> gstein@oracle.uucp (Gregory Stein) writes: > >Geez, it seems like StripAddress needs to be called *everywhere* if >you want to be 32-bit clean. If you maintain any kind of information >within a handle, it appears that you are required to call StripAddress >to access that information. Now, sure, I can dereference, strip it, >and store it so that I don't have to call StripAddress again (say, in >a sequence of stores), but as soon as I call a routine that moves >memory, I'll have to do it again. > >I've been programming the Mac for almost six years now, but this whole >issue has me kind of stymied. Am I missing something here? For a >concrete example, let's define a structure like this: > > struct foo { > int a, b, c; > } **bar; > bar = (struct foo **) NewHandle(sizeof(struct foo)); > >Now, when I say "(*bar)->a" is this 32-bit clean? For this example >and the current system software it is because the flag bits in the >handle represented by bar are zero, so there is no problem (the object >is not locked, purgable, or a resource). What happens if I do >something like: > > HLock((Handle)bar); > (*bar)->a = f(); /* f() and g() move memory */ > (*bar)->b = g(); > HUnlock((Handle)bar); > >Now, is this fragment still 32-bit clean? I would assume it isn't >because when the dereference (*bar) occurs, I pick up the flag bit in >the master pointer. Of course it's 32-bit clean. In 24-bit mode, the hardware effectively ignores the high bits, so we used them for tag bits. In 32-bit mode, we naturally can't use the high byte for flags, or you would still be limited to a 24-bit address space. So when you are in 32-bit mode, the Memory Manager puts the bits elsewhere, freeing up the upper byte for address lines (there's actually a parallel 512 megabyte space in machines with the 32-bit Memory Manager, so that we can store the tag bits there :-) You only have to use StripAddress if you need to do master pointer comparisons or pointer arithmetic (e.g. subtract two pointers to find the size of data between them). -- ------------------------------------------------------------------------------ Keith Rollin --- Apple Computer, Inc. --- Developer Technical Support INTERNET: keith@apple.com UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith "Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions