Slade Maurer smaurer at teja.com
Mon Jan 3 17:44:46 GMT 2005
- Previous message: Retrace register on EP9315
- Next message: what is the purpose of __ASSEMBLY__?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Let's keep in mind that we are discussing header files specifically. __ASSEMBLY__ allows them to be shared between C and assembly code so all the useful data is in the same place -- as Ho Lee said. The CPP does process typedef and #defines as Rainer Weikusat states. However, __ASSEMBLY__ is still required to solve problems with symbols that gas can't understand but cc1 can. For example, this section of code from a header file uses it to solve a problem: #ifdef __ASSEMBLY__ #define __PAGE_OFFSET (0xB0000000) #else #define __PAGE_OFFSET (0xB0000000UL) #endif /* __ASSEMBLY__ */ Now, what is it doing? Well, cleary the developer thought gas would choke on casting the constant as an unsigned long for cc1 and so uses the __ASSEMBLY__ directive to allow __PAGE_OFFSET to be handled by gas and by cc1. More precisely, CPP would use __ASSEMBLY__ to pick the correct __PAGE_OFFSET token. Then, it would substitute occurances in the file(s) it is pre-processing before they are passed to the assembler or compiler. The assembler sees 0xB0000000 and the C compiler sees 0xB0000000UL so they are both happy! Hope this helps. -Slade Rainer Weikusat wrote: >"Ho Lee" <flylist at linuxkernel.net> writes: > > >>It is useful when assembly codes and C codes share the header files. >>Assembler can preprocess #define macros but does not recognize most of >>C syntaxes such as typedef or function prototypes. >> >> > >This is bullshit. 'gcc' runs .S files through the C preprocessor >(either standlone cpp or something integrated), which means that you >can use everything the preprocessors knows how to deal with in >assembly sources files as long as you use gcc as a frontend. The >assembler (gas) knows nothing about all that (and doesn't understand C >syntax, of course). > > > >------------------------------------------------------------------- >Subscription options: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel >FAQ: http://www.arm.linux.org.uk/armlinux/mlfaq.php >Etiquette: http://www.arm.linux.org.uk/armlinux/mletiquette.php >