Re: Possible poor use of __ppc__, __ppc64__ and __i386__ in CFRuntime.h
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com typedef struct __CFRuntimeBase { void *_isa; uint16_t _rc; uint16_t _info; } CFRuntimeBase; And the INIT macro for PPC: #define INIT_CFRUNTIME_BASE(isa, info, rc) { isa, info, rc } Emil On 21 nov 2005, at 22.29, Kevin Van Vechten wrote: Agreed, this is really a big/little endian check. - Kevin On Nov 21, 2005, at 12:41 PM, Shawn Erickson wrote: I was poking around in Core Foundation for unrelated reasons and came across the following code in CFRuntime.h [1] in the 10.4.3 version of things (CF-368.18). typedef struct __CFRuntimeBase { void *_isa; #if defined(__ppc__) || defined(__ppc64__) uint16_t _rc; uint16_t _info; #elif defined(__i386__) uint16_t _info; uint16_t _rc; #else #error unknown architecture #endif } CFRuntimeBase; #if defined(__ppc__) || defined(__ppc64__) #define INIT_CFRUNTIME_BASE(isa, info, rc) { isa, info, rc } #elif defined(__i386__) #define INIT_CFRUNTIME_BASE(isa, info, rc) { isa, rc, info } #else #error unknown architecture #endif -Shawn _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... Also, the INIT macro seems to initialize the members out of order (if the code below is correct). On PPC the structure would become: Seems wrong to me. Can't say if the error is in the struct or the macro though. It looks like an endian specific compile time check... if so I believe it is better to check for __BIG_ENDIAN__ (and possibly also __LITTLE_ENDIAN__) in the above instead of checking processor type macros. If others agree I will file a defect. [1] <http://darwinsource.opendarwin.org/10.4.3/CF-368.18/ Base.subproj/CFRuntime.h> This email sent to site_archiver@lists.apple.com
participants (1)
-
Emil Petersson