Experimental Physics and Industrial Control System
On 6/11/2012 12:06 PM, Andrew Johnson wrote:
On 2012-06-11 Michael Davidsaver wrote:
I used 'unsigned long' in the example, but the formal specification
would be:
typedef<unspecified> epicsSpinKey;
Unfortunately the header does have to fully define the key type, since the
user code has to instantiate one of these to be able to take a lock.
By unspecified I mean only that the type aliased to epicsSpinKey is not
part of the API and users should consider that it may change.
#define epicsSLLocalFlag(name) epicsSLFlag name = 0
...
It's quite valid to call a function to initialize something one of its
arguments points at; we do that all the time with calls to sscanf() for
example without it generating warnings. I don't think the macro is necessary.
Sorry, wrong warning... You are correct that the '=0' isn't needed
When I firsted implemented this with macros I was getting "usused
variable" warnings so I wanted a way to make the flag variable disappear
when not needed.
The current implementation for the thread pool:
#if defined(vxWorks) || defined(__rtems__)
#include "epicsInterrupt.h"
#define POOLFLAG(flag) int flag
#define LOCKPOOL(pP, pFlag) do{ *(pFlag) = epicsInterruptLock(); }while(0)
#define UNLOCKPOOL(pP, pFlag) do{ epicsInterruptUnlock(*(pFlag));
}while(0)
#else
#include "epicsMutex.h"
#define POOLFLAG(flag) do{}while(0)
#define LOCKPOOL(pP, pFlag) epicsMutexMustLock((pP)->guard)
#define UNLOCKPOOL(pP, pFlag) epicsMutexUnlock((pP)->guard)
#define POOLUSEMUTEX 1
#endif
where POOLUSEMUTEX is used like
#ifdef POOLUSEMUTEX
epicsMutexId guard;
#endif
A better thing to do might be
#if defined(vxWorks) || defined(__rtems__)
typedef void* epicsSpinId
#else
typedef epicsMutexID* epicsSpinId
#endif
I have a revised preference about names, to match other OSI APIs:
typedef struct epicsSpin * epicsSpinId;
Then replace all instances of epicsSpin * with epicsSpinId.
Ok.
Michael
- Replies:
- Re: "spinlock" API Andrew Johnson
- References:
- "spinlock" API Michael Davidsaver
- Re: "spinlock" API Andrew Johnson
- Re: "spinlock" API Michael Davidsaver
- Re: "spinlock" API Andrew Johnson
- Navigate by Date:
- Prev:
Re: "spinlock" API Andrew Johnson
- Next:
Re: "spinlock" API Andrew Johnson
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
<2012>
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: "spinlock" API Andrew Johnson
- Next:
Re: "spinlock" API Andrew Johnson
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
<2012>
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024