[ECOS] What's the meaning of those C++ code? Thanks.
QiangHuang
jameshq@liverpool.ac.uk
Wed Apr 23 13:28:00 GMT 2003
Hi all:
I have tried to understand the following C++ code in eCOS but I can't
find the way out. Could anybody help me on this? Thanks a lot.
//==========================================================================
===============================
file: kapidata.h
struct cyg_mutex_t
{
cyg_atomic locked; /* true if locked */
cyg_thread *owner; /* Current locking thread */
cyg_threadqueue queue; /* Queue of waiting threads */
#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC
cyg_mutex_protocol_t protocol; /* this mutex's protocol */
#endif
#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING
cyg_priority_t ceiling; /* mutex priority ceiling */
#endif
};
//==========================================================================
===============================
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++
file: kapi.cxx
inline void *operator new(size_t size, void *ptr)
{
CYG_CHECK_DATA_PTR( ptr, "Bad pointer" );
return ptr;
}
externC void cyg_mutex_init(
cyg_mutex_t *mutex /* Mutex to init
*/
)
{
CYG_ASSERT_SIZES( cyg_mutex_t, Cyg_Mutex );
Cyg_Mutex *m = new((void *)mutex) Cyg_Mutex;
m=m;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++
so when declares:
cyg_mutex_t mutex1;
cyg_mutex_init(&mutex1);
what's the meaning of "(1). Cyg_Mutex *m = new((void *)mutex) Cyg_Mutex;
(2). m=m;" here? Thanks a lot.
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss
More information about the Ecos-discuss
mailing list