• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Possible poor use of __ppc__, __ppc64__ and __i386__ in CFRuntime.h
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Possible poor use of __ppc__, __ppc64__ and __i386__ in CFRuntime.h


  • Subject: Re: Possible poor use of __ppc__, __ppc64__ and __i386__ in CFRuntime.h
  • From: Emil Petersson <email@hidden>
  • Date: Mon, 21 Nov 2005 22:49:28 +0100

Also, the INIT macro seems to initialize the members out of order (if the code below is correct). On PPC the structure would become:

	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 }

Seems wrong to me. Can't say if the error is in the struct or the macro though.

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

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.


-Shawn

[1] <http://darwinsource.opendarwin.org/10.4.3/CF-368.18/ Base.subproj/CFRuntime.h>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Possible poor use of __ppc__, __ppc64__ and __i386__ in CFRuntime.h (From: Shawn Erickson <email@hidden>)
 >Re: Possible poor use of __ppc__, __ppc64__ and __i386__ in CFRuntime.h (From: Kevin Van Vechten <email@hidden>)

  • Prev by Date: Re: Possible poor use of __ppc__, __ppc64__ and __i386__ in CFRuntime.h
  • Next by Date: yep
  • Previous by thread: Re: Possible poor use of __ppc__, __ppc64__ and __i386__ in CFRuntime.h
  • Next by thread: yep
  • Index(es):
    • Date
    • Thread