For useage in other places besides lavc. Needed after commit
90f9a5830b5d332de7ebb1ab45589f1870cbd65d
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,162 @@ |
0 |
+/* |
|
1 |
+ * Copyright (c) 2011 KO Myung-Hun <komh@chollian.net> |
|
2 |
+ * |
|
3 |
+ * This file is part of FFmpeg. |
|
4 |
+ * |
|
5 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
6 |
+ * modify it under the terms of the GNU Lesser General Public |
|
7 |
+ * License as published by the Free Software Foundation; either |
|
8 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
9 |
+ * |
|
10 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
11 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 |
+ * Lesser General Public License for more details. |
|
14 |
+ * |
|
15 |
+ * You should have received a copy of the GNU Lesser General Public |
|
16 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
17 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
18 |
+ */ |
|
19 |
+ |
|
20 |
+/** |
|
21 |
+ * @file |
|
22 |
+ * os2threads to pthreads wrapper |
|
23 |
+ */ |
|
24 |
+ |
|
25 |
+#ifndef AVCODEC_OS2PTHREADS_H |
|
26 |
+#define AVCODEC_OS2PTHREADS_H |
|
27 |
+ |
|
28 |
+#define INCL_DOS |
|
29 |
+#include <os2.h> |
|
30 |
+ |
|
31 |
+#undef __STRICT_ANSI__ /* for _beginthread() */ |
|
32 |
+#include <stdlib.h> |
|
33 |
+ |
|
34 |
+typedef TID pthread_t; |
|
35 |
+typedef void pthread_attr_t; |
|
36 |
+ |
|
37 |
+typedef HMTX pthread_mutex_t; |
|
38 |
+typedef void pthread_mutexattr_t; |
|
39 |
+ |
|
40 |
+typedef struct { |
|
41 |
+ HEV event_sem; |
|
42 |
+ int wait_count; |
|
43 |
+} pthread_cond_t; |
|
44 |
+ |
|
45 |
+typedef void pthread_condattr_t; |
|
46 |
+ |
|
47 |
+struct thread_arg { |
|
48 |
+ void *(*start_routine)(void *); |
|
49 |
+ void *arg; |
|
50 |
+}; |
|
51 |
+ |
|
52 |
+static void thread_entry(void *arg) |
|
53 |
+{ |
|
54 |
+ struct thread_arg *thread_arg = arg; |
|
55 |
+ |
|
56 |
+ thread_arg->start_routine(thread_arg->arg); |
|
57 |
+ |
|
58 |
+ av_free(thread_arg); |
|
59 |
+} |
|
60 |
+ |
|
61 |
+static av_always_inline int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg) |
|
62 |
+{ |
|
63 |
+ struct thread_arg *thread_arg; |
|
64 |
+ |
|
65 |
+ thread_arg = av_mallocz(sizeof(struct thread_arg)); |
|
66 |
+ |
|
67 |
+ thread_arg->start_routine = start_routine; |
|
68 |
+ thread_arg->arg = arg; |
|
69 |
+ |
|
70 |
+ *thread = _beginthread(thread_entry, NULL, 256 * 1024, thread_arg); |
|
71 |
+ |
|
72 |
+ return 0; |
|
73 |
+} |
|
74 |
+ |
|
75 |
+static av_always_inline int pthread_join(pthread_t thread, void **value_ptr) |
|
76 |
+{ |
|
77 |
+ DosWaitThread((PTID)&thread, DCWW_WAIT); |
|
78 |
+ |
|
79 |
+ return 0; |
|
80 |
+} |
|
81 |
+ |
|
82 |
+static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) |
|
83 |
+{ |
|
84 |
+ DosCreateMutexSem(NULL, (PHMTX)mutex, 0, FALSE); |
|
85 |
+ |
|
86 |
+ return 0; |
|
87 |
+} |
|
88 |
+ |
|
89 |
+static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex) |
|
90 |
+{ |
|
91 |
+ DosCloseMutexSem(*(PHMTX)mutex); |
|
92 |
+ |
|
93 |
+ return 0; |
|
94 |
+} |
|
95 |
+ |
|
96 |
+static av_always_inline int pthread_mutex_lock(pthread_mutex_t *mutex) |
|
97 |
+{ |
|
98 |
+ DosRequestMutexSem(*(PHMTX)mutex, SEM_INDEFINITE_WAIT); |
|
99 |
+ |
|
100 |
+ return 0; |
|
101 |
+} |
|
102 |
+ |
|
103 |
+static av_always_inline int pthread_mutex_unlock(pthread_mutex_t *mutex) |
|
104 |
+{ |
|
105 |
+ DosReleaseMutexSem(*(PHMTX)mutex); |
|
106 |
+ |
|
107 |
+ return 0; |
|
108 |
+} |
|
109 |
+ |
|
110 |
+static av_always_inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) |
|
111 |
+{ |
|
112 |
+ DosCreateEventSem(NULL, &cond->event_sem, DCE_POSTONE, FALSE); |
|
113 |
+ |
|
114 |
+ cond->wait_count = 0; |
|
115 |
+ |
|
116 |
+ return 0; |
|
117 |
+} |
|
118 |
+ |
|
119 |
+static av_always_inline int pthread_cond_destroy(pthread_cond_t *cond) |
|
120 |
+{ |
|
121 |
+ DosCloseEventSem(cond->event_sem); |
|
122 |
+ |
|
123 |
+ return 0; |
|
124 |
+} |
|
125 |
+ |
|
126 |
+static av_always_inline int pthread_cond_signal(pthread_cond_t *cond) |
|
127 |
+{ |
|
128 |
+ if (cond->wait_count > 0) { |
|
129 |
+ DosPostEventSem(cond->event_sem); |
|
130 |
+ |
|
131 |
+ cond->wait_count--; |
|
132 |
+ } |
|
133 |
+ |
|
134 |
+ return 0; |
|
135 |
+} |
|
136 |
+ |
|
137 |
+static av_always_inline int pthread_cond_broadcast(pthread_cond_t *cond) |
|
138 |
+{ |
|
139 |
+ while (cond->wait_count > 0) { |
|
140 |
+ DosPostEventSem(cond->event_sem); |
|
141 |
+ |
|
142 |
+ cond->wait_count--; |
|
143 |
+ } |
|
144 |
+ |
|
145 |
+ return 0; |
|
146 |
+} |
|
147 |
+ |
|
148 |
+static av_always_inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) |
|
149 |
+{ |
|
150 |
+ cond->wait_count++; |
|
151 |
+ |
|
152 |
+ pthread_mutex_unlock(mutex); |
|
153 |
+ |
|
154 |
+ DosWaitEventSem(cond->event_sem, SEM_INDEFINITE_WAIT); |
|
155 |
+ |
|
156 |
+ pthread_mutex_lock(mutex); |
|
157 |
+ |
|
158 |
+ return 0; |
|
159 |
+} |
|
160 |
+ |
|
161 |
+#endif /* AVCODEC_OS2PTHREADS_H */ |
... | ... |
@@ -803,7 +803,6 @@ SKIPHEADERS-$(CONFIG_MPEG_XVMC_DECODER) += xvmc.h |
803 | 803 |
SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_internal.h |
804 | 804 |
SKIPHEADERS-$(CONFIG_VDA) += vda.h |
805 | 805 |
SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h |
806 |
-SKIPHEADERS-$(HAVE_OS2THREADS) += os2threads.h |
|
807 | 806 |
|
808 | 807 |
TESTPROGS = cabac \ |
809 | 808 |
dct \ |
39 | 39 |
deleted file mode 100644 |
... | ... |
@@ -1,162 +0,0 @@ |
1 |
-/* |
|
2 |
- * Copyright (c) 2011 KO Myung-Hun <komh@chollian.net> |
|
3 |
- * |
|
4 |
- * This file is part of FFmpeg. |
|
5 |
- * |
|
6 |
- * FFmpeg is free software; you can redistribute it and/or |
|
7 |
- * modify it under the terms of the GNU Lesser General Public |
|
8 |
- * License as published by the Free Software Foundation; either |
|
9 |
- * version 2.1 of the License, or (at your option) any later version. |
|
10 |
- * |
|
11 |
- * FFmpeg is distributed in the hope that it will be useful, |
|
12 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
- * Lesser General Public License for more details. |
|
15 |
- * |
|
16 |
- * You should have received a copy of the GNU Lesser General Public |
|
17 |
- * License along with FFmpeg; if not, write to the Free Software |
|
18 |
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
- */ |
|
20 |
- |
|
21 |
-/** |
|
22 |
- * @file |
|
23 |
- * os2threads to pthreads wrapper |
|
24 |
- */ |
|
25 |
- |
|
26 |
-#ifndef AVCODEC_OS2PTHREADS_H |
|
27 |
-#define AVCODEC_OS2PTHREADS_H |
|
28 |
- |
|
29 |
-#define INCL_DOS |
|
30 |
-#include <os2.h> |
|
31 |
- |
|
32 |
-#undef __STRICT_ANSI__ /* for _beginthread() */ |
|
33 |
-#include <stdlib.h> |
|
34 |
- |
|
35 |
-typedef TID pthread_t; |
|
36 |
-typedef void pthread_attr_t; |
|
37 |
- |
|
38 |
-typedef HMTX pthread_mutex_t; |
|
39 |
-typedef void pthread_mutexattr_t; |
|
40 |
- |
|
41 |
-typedef struct { |
|
42 |
- HEV event_sem; |
|
43 |
- int wait_count; |
|
44 |
-} pthread_cond_t; |
|
45 |
- |
|
46 |
-typedef void pthread_condattr_t; |
|
47 |
- |
|
48 |
-struct thread_arg { |
|
49 |
- void *(*start_routine)(void *); |
|
50 |
- void *arg; |
|
51 |
-}; |
|
52 |
- |
|
53 |
-static void thread_entry(void *arg) |
|
54 |
-{ |
|
55 |
- struct thread_arg *thread_arg = arg; |
|
56 |
- |
|
57 |
- thread_arg->start_routine(thread_arg->arg); |
|
58 |
- |
|
59 |
- av_free(thread_arg); |
|
60 |
-} |
|
61 |
- |
|
62 |
-static av_always_inline int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg) |
|
63 |
-{ |
|
64 |
- struct thread_arg *thread_arg; |
|
65 |
- |
|
66 |
- thread_arg = av_mallocz(sizeof(struct thread_arg)); |
|
67 |
- |
|
68 |
- thread_arg->start_routine = start_routine; |
|
69 |
- thread_arg->arg = arg; |
|
70 |
- |
|
71 |
- *thread = _beginthread(thread_entry, NULL, 256 * 1024, thread_arg); |
|
72 |
- |
|
73 |
- return 0; |
|
74 |
-} |
|
75 |
- |
|
76 |
-static av_always_inline int pthread_join(pthread_t thread, void **value_ptr) |
|
77 |
-{ |
|
78 |
- DosWaitThread((PTID)&thread, DCWW_WAIT); |
|
79 |
- |
|
80 |
- return 0; |
|
81 |
-} |
|
82 |
- |
|
83 |
-static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) |
|
84 |
-{ |
|
85 |
- DosCreateMutexSem(NULL, (PHMTX)mutex, 0, FALSE); |
|
86 |
- |
|
87 |
- return 0; |
|
88 |
-} |
|
89 |
- |
|
90 |
-static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex) |
|
91 |
-{ |
|
92 |
- DosCloseMutexSem(*(PHMTX)mutex); |
|
93 |
- |
|
94 |
- return 0; |
|
95 |
-} |
|
96 |
- |
|
97 |
-static av_always_inline int pthread_mutex_lock(pthread_mutex_t *mutex) |
|
98 |
-{ |
|
99 |
- DosRequestMutexSem(*(PHMTX)mutex, SEM_INDEFINITE_WAIT); |
|
100 |
- |
|
101 |
- return 0; |
|
102 |
-} |
|
103 |
- |
|
104 |
-static av_always_inline int pthread_mutex_unlock(pthread_mutex_t *mutex) |
|
105 |
-{ |
|
106 |
- DosReleaseMutexSem(*(PHMTX)mutex); |
|
107 |
- |
|
108 |
- return 0; |
|
109 |
-} |
|
110 |
- |
|
111 |
-static av_always_inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) |
|
112 |
-{ |
|
113 |
- DosCreateEventSem(NULL, &cond->event_sem, DCE_POSTONE, FALSE); |
|
114 |
- |
|
115 |
- cond->wait_count = 0; |
|
116 |
- |
|
117 |
- return 0; |
|
118 |
-} |
|
119 |
- |
|
120 |
-static av_always_inline int pthread_cond_destroy(pthread_cond_t *cond) |
|
121 |
-{ |
|
122 |
- DosCloseEventSem(cond->event_sem); |
|
123 |
- |
|
124 |
- return 0; |
|
125 |
-} |
|
126 |
- |
|
127 |
-static av_always_inline int pthread_cond_signal(pthread_cond_t *cond) |
|
128 |
-{ |
|
129 |
- if (cond->wait_count > 0) { |
|
130 |
- DosPostEventSem(cond->event_sem); |
|
131 |
- |
|
132 |
- cond->wait_count--; |
|
133 |
- } |
|
134 |
- |
|
135 |
- return 0; |
|
136 |
-} |
|
137 |
- |
|
138 |
-static av_always_inline int pthread_cond_broadcast(pthread_cond_t *cond) |
|
139 |
-{ |
|
140 |
- while (cond->wait_count > 0) { |
|
141 |
- DosPostEventSem(cond->event_sem); |
|
142 |
- |
|
143 |
- cond->wait_count--; |
|
144 |
- } |
|
145 |
- |
|
146 |
- return 0; |
|
147 |
-} |
|
148 |
- |
|
149 |
-static av_always_inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) |
|
150 |
-{ |
|
151 |
- cond->wait_count++; |
|
152 |
- |
|
153 |
- pthread_mutex_unlock(mutex); |
|
154 |
- |
|
155 |
- DosWaitEventSem(cond->event_sem, SEM_INDEFINITE_WAIT); |
|
156 |
- |
|
157 |
- pthread_mutex_lock(mutex); |
|
158 |
- |
|
159 |
- return 0; |
|
160 |
-} |
|
161 |
- |
|
162 |
-#endif /* AVCODEC_OS2PTHREADS_H */ |