Skip to content

Commit 4bae4f4

Browse files
committed
include: posix: move pthread impl detail to posix_internal.h
The `struct pthread` and `enum pthread_state` are actually implementation details specific to Zephyr. Let's limit the scope where that level of detail is visible. Signed-off-by: Chris Friedt <[email protected]>
1 parent 2812f61 commit 4bae4f4

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

include/zephyr/posix/pthread.h

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,40 +21,9 @@
2121
extern "C" {
2222
#endif
2323

24-
enum pthread_state {
25-
/* The thread structure is unallocated and available for reuse. */
26-
PTHREAD_TERMINATED = 0,
27-
/* The thread is running and joinable. */
28-
PTHREAD_JOINABLE,
29-
/* The thread is running and detached. */
30-
PTHREAD_DETACHED,
31-
/* A joinable thread exited and its return code is available. */
32-
PTHREAD_EXITED
33-
};
34-
35-
struct posix_thread {
36-
struct k_thread thread;
37-
38-
/* List of keys that thread has called pthread_setspecific() on */
39-
sys_slist_t key_list;
40-
41-
/* Exit status */
42-
void *retval;
43-
44-
/* Pthread cancellation */
45-
int cancel_state;
46-
int cancel_pending;
47-
pthread_mutex_t cancel_lock;
48-
49-
/* Pthread State */
50-
enum pthread_state state;
51-
pthread_mutex_t state_lock;
52-
pthread_cond_t state_cond;
53-
};
54-
5524
/* Pthread detach/joinable */
56-
#define PTHREAD_CREATE_JOINABLE PTHREAD_JOINABLE
57-
#define PTHREAD_CREATE_DETACHED PTHREAD_DETACHED
25+
#define PTHREAD_CREATE_JOINABLE 1
26+
#define PTHREAD_CREATE_DETACHED 2
5827

5928
/* Pthread cancellation */
6029
#define _PTHREAD_CANCEL_POS 0

lib/posix/posix_internal.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,37 @@
77
#ifndef ZEPHYR_LIB_POSIX_POSIX_INTERNAL_H_
88
#define ZEPHYR_LIB_POSIX_POSIX_INTERNAL_H_
99

10+
enum pthread_state {
11+
/* The thread structure is unallocated and available for reuse. */
12+
PTHREAD_TERMINATED = 0,
13+
/* The thread is running and joinable. */
14+
PTHREAD_JOINABLE = PTHREAD_CREATE_JOINABLE,
15+
/* The thread is running and detached. */
16+
PTHREAD_DETACHED = PTHREAD_CREATE_DETACHED,
17+
/* A joinable thread exited and its return code is available. */
18+
PTHREAD_EXITED
19+
};
20+
21+
struct posix_thread {
22+
struct k_thread thread;
23+
24+
/* List of keys that thread has called pthread_setspecific() on */
25+
sys_slist_t key_list;
26+
27+
/* Exit status */
28+
void *retval;
29+
30+
/* Pthread cancellation */
31+
int cancel_state;
32+
int cancel_pending;
33+
pthread_mutex_t cancel_lock;
34+
35+
/* Pthread State */
36+
enum pthread_state state;
37+
pthread_mutex_t state_lock;
38+
pthread_cond_t state_cond;
39+
};
40+
1041
struct posix_thread *to_posix_thread(pthread_t pthread);
1142

1243
#endif

0 commit comments

Comments
 (0)