Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Phil Carmody Newsgroups: comp.os.linux.advocacy,comp.os.linux.embedded Subject: Re: Reading the Riot Act To ARM's developers Date: 03 Mar 2012 02:04:38 +0200 Organization: A noiseless patient Spider Lines: 52 Sender: phil@bazspaz.fatphil.org Message-ID: <87aa3ymtwp.fsf@bazspaz.fatphil.org> References: <4iah09-1p2.ln1@spankydtr.localhost.net> <87fwdzpbqe.fsf@bazspaz.fatphil.org> <87zkc4mlho.fsf@bazspaz.fatphil.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx04.eternal-september.org; posting-host="kmQHh6axDrldsweXtgGGFg"; logging-data="9238"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/+tsA2W2atgY6my4NC0b3u" User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 Cancel-Lock: sha1:D92ET+Ej0DdXan+S4cSm1bBmOd4= Xref: csiph.com comp.os.linux.advocacy:93436 comp.os.linux.embedded:182 David Brown writes: > On 27/02/12 14:52, Phil Carmody wrote: > > 7 writes: > >> Phil Carmody wrote: > >>>> #define INT_XMA (1<< 4) > >>>> #define ENABLE_RS232 SYSCON->INT |= INT_XMA > >>> > >>> Ewwww! Don't do that. > >>> > >>>> The problem I am having is what does that '4' mean. Is it 4 or 14 or > >>>> something else? I need a datasheet. Thats just crap programming. > >>>> > >>>> What I want to be able to do is > >>>> > >>>> #define ENABLED 1 > >>>> #define ENABLE_RS232_INTERRUPT SYSCON.INT.INT_XMA = ENABLED > >>> > >>> Ewww! Don't do that either. > >>> > >>> NACKed. > >> > >> By all means save us the laughs and > >> write one line of code to say what you would do. > > > > Well, even the mindless robotic conversion to > > > > #define ENABLE_RS232_INTERRUPT() do { SYSCON.INT.INT_XMA = ENABLED; } while(0) > > > > would be better than what you had. > > > > Phil > > I would prefer three lines: > > static inline void enable_rs232_interrupt(void) { > SYSCON.INT.INT_XMA = ENABLED; > } Whilst it is a sensible assumption to presume that SYSCON is visible at the point of definition of the helper, it is by no means guaranteed, as it's not obvious from the above, nor necessary for the macro to work - you have to bear in mind the kind of code we're already dealing with. > Be daring - learn C99! I'd rather not have to forget the C11 things, thank you. Phil -- > I'd argue that there is much evidence for the existence of a God. Pics or it didn't happen. -- Tom (/. uid 822)