This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: processor type defines: __PPC403__, __PPC750__ would be nice?


Am Sam, 2002-04-20 um 19.00 schrieb Dan Kegel:
> Today I needed to check for the processor type in
> a program that compiles on ppc403, ppc750, sh4, and generic pentium.
> The tests, judging from the specs files of my gccs, would be
> 
> #ifdef __SH4__
> #if CPU==PPC403
> #if CPU==PPC750
> #ifdef __i386__
> 
> Hmm.  That's not very uniform.  Is there a more uniform scheme
> I could use?  A URL where I could RTFM would be greatly appreciated.
Yes, it is covered by some POSIX/ANSI specs (I don't have them so I
can't point you to them), which I think is mentioned somewhere in
gcc.info (IIRC, POSIX/ANSI mandates the __DEFINE__ form for
system-provided defines).

A remark mentioning this in passing can be found in gcc3's manuals/infos
(cf. -ansi in 
http://gcc.gnu.org/onlinedocs/gcc-3.0.4/gcc_3.html#SEC7 )

> Or am I right in thinking that the symbols
> __PPC403__ and __PPC750__ should be added to the specs file
> for gcc on those platforms to make processor type detection
> a little more similar in the ppc world to how it's done elsewhere?
Yes, the specs files would be appropriate, but ..

.. the specs file is generated from gcc's sources 
(In the ppc case from gcc/config/rs6000/*).

I.e. the "clean" approach would be to patch gcc, a "hack" would be to
patch the specs file directly, another "less unclean" hack would be to
use a custem specs and let this specs include gcc's specs. (It's
mentioned somewhere in gcc >= 3.0.x's infos)

> Then my programs could do
> 
> #ifdef __SH4__
> #ifdef __PPC403__
> #ifdef __PPC750__
> #ifdef __i386__
> 
> which is a bit more pleasing.
Yep, but all this is gcc-configuration dependent, esp. from all gcc
configurations, the PPC403 and PPC750 defines are only provided for
VxWorks (cf. gcc/config/sysv4.h), which lets me assume you to use
VxWorks, so this probably is VxWorks's custom conventions => you
probably will have to sort this out with the VxWorks' folks.

(__SH4__ and __i386__ are part of gcc's defaults for these cpus).

Ralf



------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]