release the pen in MUIM_Hide
[AROS.git] / compiler / pthread / pthread_intern.h
blobee8096cb2f47d104aa3ad52797da952129975d8a
1 /*
2 Copyright (C) 2014 Szilard Biro
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
21 #include <setjmp.h>
23 #ifdef __AROS__
24 #include <aros/symbolsets.h>
25 #define TIMESPEC_TO_TIMEVAL(tv, ts) { \
26 (tv)->tv_sec = (ts)->tv_sec; \
27 (tv)->tv_usec = (ts)->tv_nsec / 1000; }
28 #else
29 #include <constructor.h>
30 #define StackSwapArgs PPCStackSwapArgs
31 #define NewStackSwap NewPPCStackSwap
32 #endif
34 #include "pthread.h"
36 #define SIGB_PARENT SIGBREAKB_CTRL_F
37 #define SIGF_PARENT (1 << SIGB_PARENT)
38 #define SIGB_COND_FALLBACK SIGBREAKB_CTRL_E
39 #define SIGF_COND_FALLBACK (1 << SIGB_COND_FALLBACK)
40 #define SIGB_TIMER_FALLBACK SIGBREAKB_CTRL_D
41 #define SIGF_TIMER_FALLBACK (1 << SIGB_TIMER_FALLBACK)
43 #define NAMELEN 32
44 #define PTHREAD_FIRST_THREAD_ID (1)
45 #define PTHREAD_BARRIER_FLAG (1UL << 31)
47 typedef struct
49 struct MinNode node;
50 struct Task *task;
51 ULONG sigmask;
52 } CondWaiter;
54 typedef struct
56 void (*destructor)(void *);
57 BOOL used;
58 } TLSKey;
60 typedef struct
62 struct MinNode node;
63 void (*routine)(void *);
64 void *arg;
65 } CleanupHandler;
67 typedef struct
69 void *(*start)(void *);
70 void *arg;
71 struct Task *parent;
72 int finished;
73 struct Task *task;
74 void *ret;
75 jmp_buf jmp;
76 pthread_attr_t attr;
77 void *tlsvalues[PTHREAD_KEYS_MAX];
78 struct MinList cleanup;
79 int cancelstate;
80 int canceltype;
81 int canceled;
82 int detached;
83 } ThreadInfo;
85 extern ThreadInfo threads[PTHREAD_THREADS_MAX];
86 extern struct SignalSemaphore thread_sem;
87 extern TLSKey tlskeys[PTHREAD_KEYS_MAX];
88 extern struct SignalSemaphore tls_sem;
90 /* .c */
91 extern pthread_t GetThreadId(struct Task *task);
92 extern ThreadInfo *GetThreadInfo(pthread_t thread);
93 extern int SemaphoreIsInvalid(struct SignalSemaphore *sem);
94 extern int SemaphoreIsMine(struct SignalSemaphore *sem);
96 /* .c */
97 extern int _pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime, BOOL relative);
99 /* .c */
100 extern int _pthread_cond_broadcast(pthread_cond_t *cond, BOOL onlyfirst);
102 /* .c */
103 extern int _pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr, BOOL staticinit);