(file) Return to IPCWindows.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  1 mday  1.1.2.3 //%////////////-*-c++-*-///////////////////////////////////////////////////////////
  2               //
  3               // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
  4               //
  5               // Permission is hereby granted, free of charge, to any person obtaining a copy
  6               // of this software and associated documentation files (the "Software"), to 
  7               // deal in the Software without restriction, including without limitation the 
  8               // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 
  9               // sell copies of the Software, and to permit persons to whom the Software is
 10               // furnished to do so, subject to the following conditions:
 11               // 
 12               // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN 
 13               // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 14               // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 15               // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
 16               // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
 17               // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
 18               // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 19               // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 20               //
 21               //==============================================================================
 22 mday  1.1.2.3 //
 23               // Author: Mike Day (mdday@us.ibm.com)
 24               //
 25               // Modified By: 
 26               //
 27               //%/////////////////////////////////////////////////////////////////////////////
 28               
 29               #include <process.h>  
 30 mday  1.1.2.5 #include <windows.h>
 31 mday  1.1.2.4 #include <stdlib.h>
 32 mday  1.1.2.3 #include <sys/types.h>
 33               #include <sys/timeb.h> 
 34               #include <errno.h>
 35 mday  1.1.2.11 #include <Pegasus/Common/Config.h>
 36 mday  1.1.2.10 
 37 mday  1.1.2.6  
 38 mday  1.1.2.3  typedef CRITICAL_SECTION  PEGASUS_CRIT_TYPE;
 39                typedef HANDLE  PEGASUS_SEMAPHORE_TYPE;
 40 mday  1.1.2.5  typedef HANDLE  PEGASUS_THREAD_TYPE;
 41 mday  1.1.2.3  typedef HANDLE  PEGASUS_MUTEX_TYPE;
 42                
 43                typedef struct {
 44                      PEGASUS_SEMAPHORE_TYPE  sem;
 45                      PEGASUS_THREAD_TYPE  owner;
 46                } PEGASUS_SEM_HANDLE ;
 47                
 48                typedef struct {
 49                      HANDLE  mut;
 50                      PEGASUS_THREAD_TYPE owner;
 51                } PEGASUS_MUTEX_HANDLE ;
 52                
 53                
 54 mday  1.1.2.5  typedef void *PEGASUS_CLEANUP_HANDLE;
 55                
 56 mday  1.1.2.3  typedef DWORD PEGASUS_THREAD_RETURN;
 57                
 58 mday  1.1.2.12 #define PTHREAD_MUTEX_TIMED_NP
 59                
 60 mday  1.1.2.5  #define PEGASUS_THREAD_CDECL __stdcall
 61 mday  1.1.2.3  
 62                typedef struct {
 63                      PEGASUS_THREAD_TYPE thid;
 64                      void * thatt;
 65                } PEGASUS_THREAD_HANDLE ;
 66                
 67 mday  1.1.2.4  
 68 mday  1.1.2.3  //-----------------------------------------------------------------
 69 mday  1.1.2.4  /// Conditionals to support native conditional semaphore object
 70 mday  1.1.2.3  //-----------------------------------------------------------------
 71 mday  1.1.2.4  
 72 mday  1.1.2.3  #if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)
 73                
 74 mday  1.1.2.4  // windows uses the generic conditional semaphore defined in
 75                // IPC.ccp
 76 mday  1.1.2.3  
 77 mday  1.1.2.4  #endif // platform conditional  type
 78 mday  1.1.2.3  
 79                //-----------------------------------------------------------------
 80                /// Conditionals to support native or generic atomic variables
 81                //-----------------------------------------------------------------
 82                
 83                #if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)
 84                #define PEGASUS_ATOMIC_INT_NATIVE = 1
 85                
 86                typedef LONG  PEGASUS_ATOMIC_TYPE ;
 87                
 88                #endif // platform atomic type
 89                
 90                //-----------------------------------------------------------------
 91                /// Conditionals to support native or generic read/write semaphores
 92                //-----------------------------------------------------------------
 93                
 94                #if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)
 95                
 96                // no native rw lock for windows -- use the generic one 
 97                
 98                #endif // platform read/write type
 99 mday  1.1.2.3  
100 mday  1.1.2.9  
101                //struct timeval 
102                //{
103                //      long int tv_sec;      long int tv_usec;
104                //};
105 mday  1.1.2.7  
106                struct timezone
107                {
108                      int tz_minuteswest;
109                      int tz_dsttime;
110                };
111 mike  1.1.2.2  
112 mday  1.1.2.12 
113                inline int pegasus_gettimeofday(struct timeval *tv)
114                {
115                	struct _timeb timebuffer;   
116                	if (tv == NULL)
117                		return(-1);
118                	_ftime( &timebuffer );
119                	tv->tv_sec = timebuffer.time;
120                	tv->tv_usec = ( timebuffer.millitm / 1000 );
121                	return(0);
122                }
123                	
124                inline int PEGASUS_EXPORT gettimeofday(struct timeval *tv, struct timezone *tz)
125                {
126                  return(pegasus_gettimeofday(tv));
127                }
128                
129                PEGASUS_NAMESPACE_BEGIN
130                
131                inline PEGASUS_EXPORT void pegasus_yield(void)
132                {
133 mday  1.1.2.12   Sleep(0);
134                }
135                
136                // pthreads cancellation calls 
137                inline  PEGASUS_EXPORT void disable_cancel(void)
138                {
139                  ;
140                }
141                
142                inline  PEGASUS_EXPORT void enable_cancel(void)
143                {
144                  ;
145                }
146                
147                
148                // Windows does not have equivalent functionality with Unix-like
149                // operating systems. Be careful using these next two 
150                // macros. There is no pop routine in windows. Further, windows
151                // does not allow passing parameters to exit functions. !!
152                inline PEGASUS_EXPORT void native_cleanup_push( void (*)(void *), void *) { ; }
153                
154 mday  1.1.2.12 inline PEGASUS_EXPORT void native_cleanup_pop(Boolean) { ; }
155                
156                inline void PEGASUS_EXPORT init_crit(PEGASUS_CRIT_TYPE *crit)
157                {
158                   InitializeCriticalSection(crit);
159                }
160                
161                inline void PEGASUS_EXPORT enter_crit(PEGASUS_CRIT_TYPE *crit)
162                {
163                   EnterCriticalSection(crit);
164                }
165                
166                inline void PEGASUS_EXPORT try_crit(PEGASUS_CRIT_TYPE *crit)
167                {
168                  EnterCriticalSection(crit); 
169                }
170                
171                inline void PEGASUS_EXPORT exit_crit(PEGASUS_CRIT_TYPE *crit)
172                {
173                   LeaveCriticalSection(crit);
174                }
175 mday  1.1.2.12 
176                inline void PEGASUS_EXPORT destroy_crit(PEGASUS_CRIT_TYPE *crit)
177                {
178                   DeleteCriticalSection(crit);
179                }
180                
181                inline PEGASUS_THREAD_TYPE PEGASUS_EXPORT pegasus_thread_self(void) 
182                { 
183                   return((PEGASUS_THREAD_TYPE)GetCurrentThreadId());
184                }
185                
186                inline void PEGASUS_EXPORT exit_thread(PEGASUS_THREAD_RETURN rc)
187                {
188                  _endthreadex(rc);
189                }
190                
191 mday  1.1.2.15 inline void PEGASUS_EXPORT pegasus_sleep(int ms)
192 mday  1.1.2.12 {
193                  Sleep(ms);
194                }
195                
196 mday  1.1.2.14 inline void PEGASUS_EXPORT destroy_thread(PEGASUS_THREAD_TYPE th, PEGASUS_THREAD_RETURN rc)
197 mday  1.1.2.13 {
198                   TerminateThread(th, rc);
199                }
200                
201                
202 mday  1.1.2.12 PEGASUS_NAMESPACE_END
203                
204                
205                

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2