ObjFW  Check-in [c75596237e]

Overview
Comment:Use OS-native TLS keys on MorphOS
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c75596237eac40bfe4d09eb2e3e0d386190c4d35e14319a93a40324c68f91bab
User & Date: js on 2020-12-06 01:54:02
Other Links: manifest | tags
Context
2020-12-06
17:49
Use a single global socket base on MorphOS check-in: b45a563f2b user: js tags: trunk
01:54
Use OS-native TLS keys on MorphOS check-in: c75596237e user: js tags: trunk
2020-12-02
00:22
README.md: Remove Gitter check-in: d998e3c492 user: js tags: trunk
Changes

Modified src/platform/amiga/thread.m from [de7e15e20a] to [1416763f86].

25
26
27
28
29
30
31

32

33
34
35
36
37
38
39
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41







+

+







#import "thread.h"
#import "tlskey.h"

#include <dos/dostags.h>
#include <proto/dos.h>
#include <proto/exec.h>

#ifndef OF_MORPHOS
extern void of_tlskey_thread_exited(void);
#endif
static of_tlskey_t threadKey;

OF_CONSTRUCTOR()
{
	OF_ENSURE(of_tlskey_new(&threadKey));
}

47
48
49
50
51
52
53

54

55
56
57
58
59
60
61
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65







+

+








	thread->function(thread->object);

	ObtainSemaphore(&thread->semaphore);
	@try {
		thread->done = true;

#ifndef OF_MORPHOS
		of_tlskey_thread_exited();
#endif

		if (thread->detached)
			detached = true;
		else if (thread->joinTask != NULL)
			Signal(thread->joinTask, (1ul << thread->joinSigBit));
	} @finally {
		ReleaseSemaphore(&thread->semaphore);

Added src/platform/morphos/tlskey.m version [b6a6f32a2b].

































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
 *               2018, 2019, 2020
 *   Jonathan Schleifer <js@nil.im>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "tlskey.h"

bool
of_tlskey_new(of_tlskey_t *key)
{
	return ((*key = TLSAllocA(NULL)) != TLS_INVALID_INDEX);
}

bool
of_tlskey_free(of_tlskey_t key)
{
	return TLSFree(key);
}

Modified src/tlskey.h from [32bd25a13e] to [19e6f1fad4].

28
29
30
31
32
33
34



35
36
37
38
39
40
41
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44







+
+
+








#if defined(OF_HAVE_PTHREADS)
# include <pthread.h>
typedef pthread_key_t of_tlskey_t;
#elif defined(OF_WINDOWS)
# include <windows.h>
typedef DWORD of_tlskey_t;
#elif defined(OF_MORPHOS)
# include <proto/exec.h>
typedef ULONG of_tlskey_t;
#elif defined(OF_AMIGAOS)
typedef struct of_tlskey {
	struct objc_hashtable *table;
	struct of_tlskey *next, *previous;
} *of_tlskey_t;
#endif

70
71
72
73
74
75
76












77
78
79
80
81
82
83
84
85
86
87
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102







+
+
+
+
+
+
+
+
+
+
+
+











}

static OF_INLINE bool
of_tlskey_set(of_tlskey_t key, void *ptr)
{
	return TlsSetValue(key, ptr);
}
#elif defined(OF_MORPHOS)
static OF_INLINE void *
of_tlskey_get(of_tlskey_t key)
{
	return (void *)TLSGetValue(key);
}

static OF_INLINE bool
of_tlskey_set(of_tlskey_t key, void *ptr)
{
	return TLSSetValue(key, (APTR)ptr);
}
#elif defined(OF_AMIGAOS)
/* Those are too big too inline. */
# ifdef __cplusplus
extern "C" {
# endif
extern void *of_tlskey_get(of_tlskey_t key);
extern bool of_tlskey_set(of_tlskey_t key, void *ptr);
# ifdef __cplusplus
}
# endif
#endif

Modified src/tlskey.m from [abedce4e93] to [6e9b57ccc9].

19
20
21
22
23
24
25


26
27
28
19
20
21
22
23
24
25
26
27
28
29
30







+
+




#include "platform.h"

#if defined(OF_HAVE_PTHREADS)
# include "platform/posix/tlskey.m"
#elif defined(OF_WINDOWS)
# include "platform/windows/tlskey.m"
#elif defined(OF_MORPHOS)
# include "platform/morphos/tlskey.m"
#elif defined(OF_AMIGAOS)
# include "platform/amiga/tlskey.m"
#endif