Skip to content

Commit 77135fc

Browse files
Christopher Friedtcfriedt
authored andcommitted
posix: pthread: embed posix_thread_attr inside of posix_thread
Rather than shadowing most of the fields from pthread_attr_t (struct posix_thread_attr) inside of struct posix_thread, just embed the structure itself. Additionally, use pthread_attr_init() to allocate a thread stack and pthread_attr_destroy() to destroy a thread stack, dramatically simplifying pthread_create(). A fair bit of rework was needed already to mitigate bitrot issues in the testsuite. More should probably be done later. Signed-off-by: Christopher Friedt <[email protected]>
1 parent dbcba2f commit 77135fc

File tree

4 files changed

+215
-139
lines changed

4 files changed

+215
-139
lines changed

lib/posix/posix_internal.h

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@ struct posix_thread_attr {
2929
uint16_t guardsize : CONFIG_POSIX_PTHREAD_ATTR_GUARDSIZE_BITS;
3030
int8_t priority;
3131
uint8_t schedpolicy: 2;
32-
bool initialized: 1;
32+
union {
33+
bool caller_destroys: 1;
34+
bool initialized: 1;
35+
};
36+
bool cancelpending: 1;
3337
bool cancelstate: 1;
38+
bool canceltype: 1;
3439
bool detachstate: 1;
3540
};
3641

@@ -46,23 +51,15 @@ struct posix_thread {
4651
/* List of keys that thread has called pthread_setspecific() on */
4752
sys_slist_t key_list;
4853

49-
/* Dynamic stack */
50-
k_thread_stack_t *dynamic_stack;
54+
/* pthread_attr_t */
55+
struct posix_thread_attr attr;
5156

5257
/* Exit status */
5358
void *retval;
5459

5560
/* Signal mask */
5661
sigset_t sigset;
5762

58-
/* Pthread cancellation */
59-
uint8_t cancel_state;
60-
uint8_t cancel_type;
61-
bool cancel_pending;
62-
63-
/* Detach state */
64-
uint8_t detachstate;
65-
6663
/* Queue ID (internal-only) */
6764
uint8_t qid;
6865
};

0 commit comments

Comments
 (0)