wthread.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           wthread.h  -  description
00003                              -------------------
00004     begin                : Sun Nov 12 2000
00005     copyright            : (C) 2000 by Rainer Lehrig
00006     email                : lehrig@t-online.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 /***********************************************************************************
00018 
00019 Wrapper for posix threads (UNIX,VMS,windows)
00020 
00021 (C) Rainer Lehrig 2000                                       lehrig@t-online.de
00022 
00023 ***********************************************************************************/
00024 
00025 #ifndef _WTHREAD_H_
00026 #define _WTHREAD_H_
00027 
00028 #ifdef _WIN32
00029 
00030 #include <windows.h>
00031 #include <winbase.h>
00032 #include <stddef.h>
00033 #include <string.h>
00034 
00035 #ifndef _WRAPTHREAD_
00036 #ifndef _RL_WTHREAD_H_
00037 typedef unsigned long int pthread_t;
00038 
00039 /* Attributes for threads */
00040 struct __sched_param
00041 {
00042   int sched_priority;
00043 };
00044 
00045 typedef struct
00046 {
00047   int     __detachstate;
00048   int     __schedpolicy;
00049   struct  __sched_param __schedparam;
00050   int     __inheritsched;
00051   int     __scope;
00052   size_t  __guardsize;
00053   int     __stackaddr_set;
00054   void   *__stackaddr;
00055   size_t  __stacksize;
00056 }pthread_attr_t;
00057 
00058 typedef HANDLE pthread_mutex_t;
00059 //old typedef CRITICAL_SECTION pthread_mutex_t;
00060 typedef long             pthread_mutexattr_t;
00061 #endif
00062 #endif
00063 
00064 #else  /* VMS or UNIX */
00065 #include <pthread.h>
00066 #endif /* end of MSWINDOWS */
00067 
00068 #ifndef _WRAPTHREAD_
00069 #ifndef _RL_WTHREAD_H_
00070 typedef struct
00071 {
00072 #ifdef _WIN32
00073   int    cmax;
00074   HANDLE hSemaphore;
00075 #else
00076   int              cmax;
00077   int              nready;
00078   pthread_mutex_t  mutex;
00079   pthread_cond_t   cond;
00080 #endif
00081 }WSEMAPHORE;
00082 #endif
00083 #endif
00084 
00085 /* function prototypes */
00086 #ifndef __VMS
00087 #ifdef __cplusplus
00088 extern "C" {
00089 #endif
00090 #endif
00091 int  pvthread_attr_init(pthread_attr_t *attr);
00092 int  pvthread_create(pthread_t *tid, const pthread_attr_t *attr,
00093                       void *(*func)(void*), void *arg);
00094 void pvthread_close_handle(pthread_t *tid);
00095 void pvthread_exit(void *status);
00096 int  pvthread_join(pthread_t tid, void **status);
00097 int  pvthread_mutex_init(pthread_mutex_t *mptr, const pthread_mutexattr_t *attr);
00098 int  pvthread_mutex_destroy(pthread_mutex_t *mptr);
00099 int  pvthread_mutex_lock(pthread_mutex_t *mptr);
00100 int  pvthread_mutex_trylock(pthread_mutex_t *mptr);
00101 int  pvthread_mutex_unlock(pthread_mutex_t *mptr);
00102 int  pvthread_cancel(pthread_t tid);
00103 int  pvinit_semaphore(WSEMAPHORE *s, int cmax);
00104 int  pvincrement_semaphore(WSEMAPHORE *s);
00105 int  pvwait_semaphore(WSEMAPHORE *s);
00106 int  pvthread_sleep(long msec);
00107 #ifndef __VMS
00108 #ifdef __cplusplus
00109 };
00110 #endif
00111 #endif
00112 
00113 #endif

Generated on Mon Jun 5 08:33:36 2006 for ProcessViewBrowser-ServerProgramming by  doxygen 1.4.6