1 #ifndef __VXTHREAD_H__
  2 #define __VXTHREAD_H__
  3 /*
  4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  5 %% Project:     omniORB
  6 %% Filename:    $Filename$
  7 %% Author:      Guillaume/Bill ARRECKX
  8 %%              Copyright Wavetek Wandel & Goltermann, Plymouth.
  9 %% Description: OMNI thread implementation classes for VxWorks threads
 10 %% Notes:
 11 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 12 %% $Log: VxThread.h,v $
 13 %% Revision 1.1  2003/12/16 17:03:16  ruff
 14 %% Updated to omniORB-4.0.3
 15 %%
 16 %% Revision 1.1.2.2  2003/11/05 15:42:39  dgrisby
 17 %% vxWorks omnithread fixes from Jochen Gern.
 18 %%
 19 %% Revision 1.2  2003/11/05 11:09:05  gernjo
 20 %% In omni_condition implementation, removed waiters_ and waiters_lock_
 21 %%
 22 %% Revision 1.1.1.1  2003/10/20 10:15:20  gernjo
 23 %% Original distribution
 24 %%
 25 %% Revision 1.1.2.1  2003/02/17 02:03:07  dgrisby
 26 %% vxWorks port. (Thanks Michael Sturm / Acterna Eningen GmbH).
 27 %%
 28 %% Revision 1.1.1.1  2002/11/19 14:55:21  sokcevti
 29 %% OmniOrb4.0.0 VxWorks port
 30 %%
 31 %% Revision 1.2  2002/06/14 12:45:50  engeln
 32 %% unnecessary members in condition removed.
 33 %% ---
 34 %%
 35 %% Revision 1.1.1.1  2002/04/02 10:08:49  sokcevti
 36 %% omniORB4 initial realease
 37 %%
 38 %% Revision 1.1  2001/03/23 16:50:23  hartmut
 39 %% Initial Version 2.8
 40 %%
 41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 42 */
 43 
 44 
 45 ///////////////////////////////////////////////////////////////////////////
 46 // Includes
 47 ///////////////////////////////////////////////////////////////////////////
 48 #include <vxWorks.h>
 49 #include <semLib.h>
 50 #include <taskLib.h>
 51 
 52 
 53 ///////////////////////////////////////////////////////////////////////////
 54 // Externs prototypes
 55 ///////////////////////////////////////////////////////////////////////////
 56 extern "C" void omni_thread_wrapper(void* ptr);
 57 
 58 
 59 ///////////////////////////////////////////////////////////////////////////
 60 // Exported macros
 61 // Note: These are added as private members in each class implementation.
 62 ///////////////////////////////////////////////////////////////////////////
 63 #define OMNI_MUTEX_IMPLEMENTATION \
 64    SEM_ID mutexID;   \
 65    bool m_bConstructed;
 66 
 67 #define OMNI_CONDITION_IMPLEMENTATION \
 68    SEM_ID sema_;
 69 
 70 #define OMNI_SEMAPHORE_IMPLEMENTATION \
 71    SEM_ID semID;
 72 
 73 #define OMNI_MUTEX_LOCK_IMPLEMENTATION                  \
 74    if(semTake(mutexID, WAIT_FOREVER) != OK)  \
 75    {  \
 76       throw omni_thread_fatal(errno);  \
 77    }
 78 
 79 #define OMNI_MUTEX_UNLOCK_IMPLEMENTATION                \
 80    if(semGive(mutexID) != OK) \
 81    {  \
 82       throw omni_thread_fatal(errno);  \
 83    }
 84 
 85 #define OMNI_THREAD_IMPLEMENTATION \
 86    friend void omni_thread_wrapper(void* ptr); \
 87    static int vxworks_priority(priority_t); \
 88    omni_condition *running_cond; \
 89    void* return_val; \
 90    int tid; \
 91    public: \
 92    static void attach(void); \
 93    static void detach(void); \
 94    static void show(void);
 95 
 96 
 97 ///////////////////////////////////////////////////////////////////////////
 98 // Porting macros
 99 ///////////////////////////////////////////////////////////////////////////
100 // This is a wrapper function for the 'main' function which does not exists
101 //  as such in VxWorks. The wrapper creates a launch function instead,
102 //  which spawns the application wrapped in a omni_thread.
103 // Argc will always be null.
104 ///////////////////////////////////////////////////////////////////////////
105 #define main( discarded_argc, discarded_argv ) \
106         omni_discard_retval() \
107           { \
108           throw; \
109           } \
110         int omni_main( int argc, char **argv ); \
111         void launch( ) \
112           { \
113           omni_thread* th = new omni_thread( (void(*)(void*))omni_main );\
114           th->start();\
115           }\
116         int omni_main( int argc, char **argv )
117 
118 
119 #endif // ndef __VXTHREAD_H__


syntax highlighted by Code2HTML, v. 0.9.1