Rev 270 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 270 | Rev 800 | ||
|---|---|---|---|
| 1 | /*************************************************************************** |
1 | /*************************************************************************** |
| 2 | wthread.h - description |
2 | wthread.h - description |
| 3 | ------------------- |
3 | ------------------- |
| 4 | begin : Sun Jan 02 2000 |
4 | begin : Sun Jan 02 2000 |
| 5 | copyright : (C) 2001 by Rainer Lehrig |
5 | copyright : (C) 2001 by Rainer Lehrig |
| 6 | email : lehrig@t-online.de |
6 | email : lehrig@t-online.de |
| 7 | ***************************************************************************/ |
7 | ***************************************************************************/ |
| 8 | 8 | ||
| 9 | /*************************************************************************** |
9 | /*************************************************************************** |
| 10 | * * |
10 | * * |
| 11 | * This library is free software; you can redistribute it and/or modify * |
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 * |
12 | * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as * |
| 13 | * published by the Free Software Foundation * |
13 | * published by the Free Software Foundation * |
| 14 | * * |
14 | * * |
| 15 | ***************************************************************************/ |
15 | ***************************************************************************/ |
| 16 | /*********************************************************************************** |
16 | /*********************************************************************************** |
| 17 | |
17 | |
| 18 | Wrapper for posix threads (UNIX,VMS,windows) |
18 | Wrapper for posix threads (UNIX,VMS,windows) |
| 19 | |
19 | |
| 20 | (C) Rainer Lehrig 2001 lehrig@t-online.de |
20 | (C) Rainer Lehrig 2001 lehrig@t-online.de |
| 21 | |
21 | |
| 22 | ***********************************************************************************/ |
22 | ***********************************************************************************/ |
| 23 | 23 | ||
| 24 | #ifndef _RL_WTHREAD_H_ |
24 | #ifndef _RL_WTHREAD_H_ |
| 25 | #define _RL_WTHREAD_H_ |
25 | #define _RL_WTHREAD_H_ |
| 26 | 26 | ||
| 27 | #include "rldefine.h" |
27 | #include "rldefine.h" |
| 28 | 28 | ||
| 29 | #ifdef _WIN32 |
29 | #ifdef _WIN32 |
| 30 | 30 | ||
| 31 | #include <windows.h> |
31 | #include <windows.h> |
| 32 | #include <winbase.h> |
32 | #include <winbase.h> |
| 33 | #include <stddef.h> |
33 | #include <stddef.h> |
| 34 | #include <string.h> |
34 | #include <string.h> |
| 35 | 35 | ||
| 36 | #ifndef _WRAPTHREAD_ |
36 | #ifndef _WRAPTHREAD_ |
| 37 | #ifndef _WTHREAD_H_ |
37 | #ifndef _WTHREAD_H_ |
| 38 | typedef unsigned long int pthread_t; |
38 | typedef unsigned long int pthread_t; |
| 39 | 39 | ||
| 40 | /* Attributes for threads */ |
40 | /* Attributes for threads */ |
| 41 | struct __sched_param |
41 | struct __sched_param |
| 42 | { |
42 | { |
| 43 | int sched_priority; |
43 | int sched_priority; |
| 44 | }; |
44 | }; |
| 45 | 45 | ||
| 46 | typedef struct |
46 | typedef struct |
| 47 | { |
47 | { |
| 48 | int __detachstate; |
48 | int __detachstate; |
| 49 | int __schedpolicy; |
49 | int __schedpolicy; |
| 50 | struct __sched_param __schedparam; |
50 | struct __sched_param __schedparam; |
| 51 | int __inheritsched; |
51 | int __inheritsched; |
| 52 | int __scope; |
52 | int __scope; |
| 53 | size_t __guardsize; |
53 | size_t __guardsize; |
| 54 | int __stackaddr_set; |
54 | int __stackaddr_set; |
| 55 | void *__stackaddr; |
55 | void *__stackaddr; |
| 56 | size_t __stacksize; |
56 | size_t __stacksize; |
| 57 | }pthread_attr_t; |
57 | }pthread_attr_t; |
| 58 | 58 | ||
| 59 | typedef HANDLE pthread_mutex_t; |
59 | typedef HANDLE pthread_mutex_t; |
| 60 | //old typedef CRITICAL_SECTION pthread_mutex_t; |
60 | //old typedef CRITICAL_SECTION pthread_mutex_t; |
| 61 | typedef long pthread_mutexattr_t; |
61 | typedef long pthread_mutexattr_t; |
| 62 | #endif |
62 | #endif |
| 63 | #endif |
63 | #endif |
| 64 | 64 | ||
| 65 | #else /* VMS or UNIX */ |
65 | #else /* VMS or UNIX */ |
| 66 | #include <pthread.h> |
66 | #include <pthread.h> |
| 67 | #endif /* end of MSWINDOWS */ |
67 | #endif /* end of MSWINDOWS */ |
| 68 | 68 | ||
| 69 | #ifndef _WRAPTHREAD_ |
69 | #ifndef _WRAPTHREAD_ |
| 70 | #ifndef _WTHREAD_H_ |
70 | #ifndef _WTHREAD_H_ |
| 71 | typedef struct |
71 | typedef struct |
| 72 | { |
72 | { |
| 73 | #ifdef _WIN32 |
73 | #ifdef _WIN32 |
| 74 | int cmax; |
74 | int cmax; |
| 75 | HANDLE hSemaphore; |
75 | HANDLE hSemaphore; |
| 76 | #else |
76 | #else |
| 77 | int cmax; |
77 | int cmax; |
| 78 | int nready; |
78 | int nready; |
| 79 | pthread_mutex_t mutex; |
79 | pthread_mutex_t mutex; |
| 80 | pthread_cond_t cond; |
80 | pthread_cond_t cond; |
| 81 | #endif |
81 | #endif |
| 82 | }WSEMAPHORE; |
82 | }WSEMAPHORE; |
| 83 | #endif |
83 | #endif |
| 84 | #endif |
84 | #endif |
| 85 | 85 | ||
| 86 | /* function prototypes */ |
86 | /* function prototypes */ |
| 87 | //#ifdef __cplusplus |
87 | //#ifdef __cplusplus |
| 88 | //extern "C" { |
88 | //extern "C" { |
| 89 | //#endif |
89 | //#endif |
| 90 | int rlwthread_attr_init(pthread_attr_t *attr); |
90 | int rlwthread_attr_init(pthread_attr_t *attr); |
| 91 | int rlwthread_create(pthread_t *tid, const pthread_attr_t *attr, |
91 | int rlwthread_create(pthread_t *tid, const pthread_attr_t *attr, |
| 92 | void *(*func)(void*), void *arg); |
92 | void *(*func)(void*), void *arg); |
| 93 | void rlwthread_close_handle(pthread_t *tid); |
93 | void rlwthread_close_handle(pthread_t *tid); |
| 94 | void rlwthread_exit(void *status); |
94 | void rlwthread_exit(void *status); |
| 95 | int rlwthread_join(pthread_t tid, void **status); |
95 | int rlwthread_join(pthread_t tid, void **status); |
| 96 | int rlwthread_mutex_init(pthread_mutex_t *mptr, const pthread_mutexattr_t *attr); |
96 | int rlwthread_mutex_init(pthread_mutex_t *mptr, const pthread_mutexattr_t *attr); |
| 97 | int rlwthread_mutex_destroy(pthread_mutex_t *mptr); |
97 | int rlwthread_mutex_destroy(pthread_mutex_t *mptr); |
| 98 | int rlwthread_mutex_lock(pthread_mutex_t *mptr); |
98 | int rlwthread_mutex_lock(pthread_mutex_t *mptr); |
| 99 | int rlwthread_mutex_trylock(pthread_mutex_t *mptr); |
99 | int rlwthread_mutex_trylock(pthread_mutex_t *mptr); |
| 100 | int rlwthread_mutex_unlock(pthread_mutex_t *mptr); |
100 | int rlwthread_mutex_unlock(pthread_mutex_t *mptr); |
| 101 | int rlwthread_cancel(pthread_t tid); |
101 | int rlwthread_cancel(pthread_t tid); |
| 102 | int rlwrapinit_semaphore(WSEMAPHORE *s, int cmax); |
102 | int rlwrapinit_semaphore(WSEMAPHORE *s, int cmax); |
| 103 | int rlwrapdestroy_semaphore(WSEMAPHORE *s); |
103 | int rlwrapdestroy_semaphore(WSEMAPHORE *s); |
| 104 | int rlwrapincrement_semaphore(WSEMAPHORE *s); |
104 | int rlwrapincrement_semaphore(WSEMAPHORE *s); |
| 105 | int rlwrapwait_semaphore(WSEMAPHORE *s); |
105 | int rlwrapwait_semaphore(WSEMAPHORE *s); |
| 106 | int rlwthread_sleep(long msec); |
106 | int rlwthread_sleep(long msec); |
| 107 | void rlsleep(long msec); |
107 | void rlsleep(long msec); |
| 108 | //#ifdef __cplusplus |
108 | //#ifdef __cplusplus |
| 109 | //}; |
109 | //}; |
| 110 | //#endif |
110 | //#endif |
| 111 | 111 | ||
| 112 | #endif |
112 | #endif |
| 113 | 113 | ||