ProcessViewBrowser-ServerProgramming
wthread.h
Go to the documentation of this file.
1 /***************************************************************************
2  wthread.h - description
3  -------------------
4  begin : Sun Nov 12 2000
5  copyright : (C) 2000 by R. Lehrig
6  email : lehrig@t-online.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This library is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as *
13  * published by the Free Software Foundation *
14  * *
15  ***************************************************************************/
16 /***********************************************************************************
17 
18 Wrapper for posix threads (UNIX,VMS,windows)
19 
20 (C) R. Lehrig 2000 lehrig@t-online.de
21 
22 ***********************************************************************************/
23 
24 #ifndef _WTHREAD_H_
25 #define _WTHREAD_H_
26 
27 #include "processviewserver.h"
28 
29 #ifdef PVWIN32
30 #define WTREAD_GNUC1 ( __GNUC__ * 1000 ) + __GNUC_MINOR__
31 #if WTREAD_GNUC1 < 4008
32 #define PVWIN32THREAD
33 #endif
34 #include <windows.h>
35 #include <winbase.h>
36 #endif
37 
38 #include <stddef.h>
39 #include <string.h>
40 
41 #ifdef PVWIN32THREAD
42 #ifndef _WRAPTHREAD_
43 #ifndef _RL_WTHREAD_H_
44 typedef unsigned long int pthread_t;
45 
46 /* Attributes for threads */
47 struct __sched_param
48 {
49  int sched_priority;
50 };
51 
52 typedef struct
53 {
54  int __detachstate;
55  int __schedpolicy;
56  struct __sched_param __schedparam;
57  int __inheritsched;
58  int __scope;
59  size_t __guardsize;
60  int __stackaddr_set;
61  void *__stackaddr;
62  size_t __stacksize;
63 }pthread_attr_t;
64 
65 typedef HANDLE pthread_mutex_t;
66 //old typedef CRITICAL_SECTION pthread_mutex_t;
67 typedef long pthread_mutexattr_t;
68 #endif
69 #endif
70 
71 #else /* VMS or UNIX or new GCC on Windows*/
72 #ifndef WIN_PTHREADS_H
73 #include <pthread.h>
74 #endif
75 #endif /* end of MSWINDOWS */
76 
77 #ifndef _WRAPTHREAD_
78 #ifndef _RL_WTHREAD_H_
79 typedef struct
80 {
81 #ifdef PVWIN32THREAD
82  int cmax;
83  HANDLE hSemaphore;
84 #else
85  int cmax;
86  int nready;
87  pthread_mutex_t mutex;
88  pthread_cond_t cond;
89 #endif
90 }WSEMAPHORE;
91 #endif
92 #endif
93 
94 /* function prototypes */
95 #ifndef __VMS
96 #ifdef __cplusplus
97 extern "C" {
98 #endif
99 #endif
100 int pvthread_attr_init(pthread_attr_t *attr);
101 int pvthread_create(pthread_t *tid, const pthread_attr_t *attr,
102  void *(*func)(void*), void *arg);
103 void pvthread_close_handle(pthread_t *tid);
104 void pvthread_exit(void *status);
105 int pvthread_join(pthread_t tid, void **status);
106 int pvthread_mutex_init(pthread_mutex_t *mptr, const pthread_mutexattr_t *attr);
107 int pvthread_mutex_destroy(pthread_mutex_t *mptr);
108 int pvthread_mutex_lock(pthread_mutex_t *mptr);
109 int pvthread_mutex_trylock(pthread_mutex_t *mptr);
110 int pvthread_mutex_unlock(pthread_mutex_t *mptr);
111 int pvthread_cancel(pthread_t tid);
112 int pvinit_semaphore(WSEMAPHORE *s, int cmax);
115 int pvthread_sleep(long msec);
116 #ifndef __VMS
117 #ifdef __cplusplus
118 };
119 #endif
120 #endif
121 
122 #endif
int pvwait_semaphore(WSEMAPHORE *s)
int pvthread_join(pthread_t tid, void **status)
pthread_cond_t cond
Definition: wthread.h:88
int pvincrement_semaphore(WSEMAPHORE *s)
int nready
Definition: wthread.h:86
int cmax
Definition: wthread.h:85
int pvthread_mutex_lock(pthread_mutex_t *mptr)
int pvinit_semaphore(WSEMAPHORE *s, int cmax)
pthread_mutex_t mutex
Definition: wthread.h:87
int pvthread_mutex_unlock(pthread_mutex_t *mptr)
int pvthread_attr_init(pthread_attr_t *attr)
int pvthread_mutex_init(pthread_mutex_t *mptr, const pthread_mutexattr_t *attr)
int pvthread_cancel(pthread_t tid)
Definition: wthread.h:79
int pvthread_mutex_destroy(pthread_mutex_t *mptr)
void pvthread_close_handle(pthread_t *tid)
int pvthread_sleep(long msec)
void pvthread_exit(void *status)
int pvthread_mutex_trylock(pthread_mutex_t *mptr)
int pvthread_create(pthread_t *tid, const pthread_attr_t *attr, void *(*func)(void *), void *arg)