ObjFW  Diff

Differences From Artifact [2b66252a9f]:

To Artifact [00cdbb5121]:


22
23
24
25
26
27
28
29

30
31
32

33
34
35
36
37
38
39
40
41
42
43
44

45
46
47

48
49
50

51
52



53
54








55



56
57








58
59
60


61
62
63
64
65
66
67
68
69
70
71






72
73
74
22
23
24
25
26
27
28

29
30
31

32
33
34
35
36
37
38
39
40
41
42
43

44
45
46

47
48
49

50
51
52
53
54
55


56
57
58
59
60
61
62
63
64
65
66
67


68
69
70
71
72
73
74
75
76


77
78
79
80
81
82
83






84
85
86
87
88
89
90
91
92







-
+


-
+











-
+


-
+


-
+


+
+
+
-
-
+
+
+
+
+
+
+
+

+
+
+
-
-
+
+
+
+
+
+
+
+

-
-
+
+





-
-
-
-
-
-
+
+
+
+
+
+



# error No threads available!
#endif

#import "macros.h"

#if defined(OF_HAVE_PTHREADS)
# include <pthread.h>
typedef pthread_t of_thread_t;
typedef pthread_t OFPlainThread;
#elif defined(OF_WINDOWS)
# include <windows.h>
typedef HANDLE of_thread_t;
typedef HANDLE OFPlainThread;
#elif defined(OF_AMIGAOS)
# include <exec/tasks.h>
# include <exec/semaphores.h>
typedef struct {
	struct Task *task;
	void (*function)(id);
	id object;
	struct SignalSemaphore semaphore;
	struct Task *joinTask;
	unsigned char joinSigBit;
	bool detached, done;
} *of_thread_t;
} *OFPlainThread;
#endif

typedef struct of_thread_attr_t {
typedef struct {
	float priority;
	size_t stackSize;
} of_thread_attr_t;
} OFPlainThreadAttributes;

#if defined(OF_HAVE_PTHREADS)
static OF_INLINE OFPlainThread
OFCurrentPlainThread(void)
{
# define of_thread_is_current(t) pthread_equal(t, pthread_self())
# define of_thread_current() pthread_self()
	return pthread_self();
}

static OF_INLINE bool
OFPlainThreadIsCurrent(OFPlainThread thread)
{
	return pthread_equal(thread, pthread_self());
}
#elif defined(OF_WINDOWS)
static OF_INLINE OFPlainThread
OFCurrentPlainThread(void)
{
# define of_thread_is_current(t) (t == GetCurrentThread())
# define of_thread_current() GetCurrentThread()
	return GetCurrentThread();
}

static OF_INLINE bool
OFPlainThreadIsCurrent(OFPlainThread thread)
{
	return (thread == GetCurrentThread());
}
#elif defined(OF_AMIGAOS)
# define of_thread_is_current(t) (t->thread == FindTask(NULL))
extern of_thread_t of_thread_current(void);
extern OFPlainThread OFCurrentPlainThread(void);
extern bool OFPlainThreadIsCurrent(OFPlainThread);
#endif

#ifdef __cplusplus
extern "C" {
#endif
extern int of_thread_attr_init(of_thread_attr_t *attr);
extern int of_thread_new(of_thread_t *thread, const char *name,
    void (*function)(id), id object, const of_thread_attr_t *attr);
extern void of_thread_set_name(const char *name);
extern int of_thread_join(of_thread_t thread);
extern int of_thread_detach(of_thread_t thread);
extern int OFPlainThreadAttributesInit(OFPlainThreadAttributes *attr);
extern int OFPlainThreadNew(OFPlainThread *thread, const char *name,
    void (*function)(id), id object, const OFPlainThreadAttributes *attr);
extern void OFSetThreadName(const char *name);
extern int OFPlainThreadJoin(OFPlainThread thread);
extern int OFPlainThreadDetach(OFPlainThread thread);
#ifdef __cplusplus
}
#endif