public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] code to keep you on your toes..
@ 2000-10-25  5:05 Dave Airlie
  2000-10-25  6:30 ` Hugo 'NOx' Tyson
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Airlie @ 2000-10-25  5:05 UTC (permalink / raw)
  To: ecos-discuss

While trawling eCos code I found this nice one 

#define HAL_THREAD_SWITCH_CONTEXT(_fspptr_,_tspptr_)                    \
        hal_thread_switch_context((CYG_ADDRESS)_tspptr_,                \
                                  (CYG_ADDRESS)_fspptr_);

now that code is just plain evil... I'm assuming it is right as nothing
should work if it isn't, but having a function take args backwards to the
macro.. uggh...

I'd like to see that making it through a code review alive.

Dave.

-- 
      David Airlie, Software Engineer, Parthus Technologies plc.,
       Mary Rosse Centre, National Tech Park, Limerick, Ireland.
   t: +353-61-508116 / f: +353-61-508101 / David.Airlie@parthus.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ECOS] code to keep you on your toes..
  2000-10-25  5:05 [ECOS] code to keep you on your toes Dave Airlie
@ 2000-10-25  6:30 ` Hugo 'NOx' Tyson
  0 siblings, 0 replies; 2+ messages in thread
From: Hugo 'NOx' Tyson @ 2000-10-25  6:30 UTC (permalink / raw)
  To: ecos-discuss


"Dave Airlie" <airlied@parthus.com> writes:
> While trawling eCos code I found this nice one 
> 
> #define HAL_THREAD_SWITCH_CONTEXT(_fspptr_,_tspptr_)                    \
>         hal_thread_switch_context((CYG_ADDRESS)_tspptr_,                \
>                                   (CYG_ADDRESS)_fspptr_);
> 
> now that code is just plain evil... I'm assuming it is right as nothing
> should work if it isn't, but having a function take args backwards to the
> macro.. uggh...
> 
> I'd like to see that making it through a code review alive.

;-)  But...

There is a good reason for this, *given* the externally
defined standard HAL API for HAL_THREAD_SWITCH_CONTEXT(old,new)

The routine drops through to hal_thread_load_context( new-thread ), so you
want the new context in the first argument position.  Hence the old context
is placed in the 2nd argument position.

But the exported API (the macro) has (old,new) sematics which are thought
to be more friendly.  Or maybe this was arbitrarily chosen.  Don't
remember. ;-)  I think (old,new) reads more naturally.

My point is, this might argue for the external supported HAL API to be
reversed, but it's too late for that, since it's an external supported API.
But there is a good reason for the internal ABI to be the way it is, so we
won't change that.

	- Huge

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-10-25  6:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-10-25  5:05 [ECOS] code to keep you on your toes Dave Airlie
2000-10-25  6:30 ` Hugo 'NOx' Tyson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).