Skip to content

include: posix: move pthread impl detail to posix_internal.h #52003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 2 additions & 33 deletions include/zephyr/posix/pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,40 +21,9 @@
extern "C" {
#endif

enum pthread_state {
/* The thread structure is unallocated and available for reuse. */
PTHREAD_TERMINATED = 0,
/* The thread is running and joinable. */
PTHREAD_JOINABLE,
/* The thread is running and detached. */
PTHREAD_DETACHED,
/* A joinable thread exited and its return code is available. */
PTHREAD_EXITED
};

struct posix_thread {
struct k_thread thread;

/* List of keys that thread has called pthread_setspecific() on */
sys_slist_t key_list;

/* Exit status */
void *retval;

/* Pthread cancellation */
int cancel_state;
int cancel_pending;
pthread_mutex_t cancel_lock;

/* Pthread State */
enum pthread_state state;
pthread_mutex_t state_lock;
pthread_cond_t state_cond;
};

/* Pthread detach/joinable */
#define PTHREAD_CREATE_JOINABLE PTHREAD_JOINABLE
#define PTHREAD_CREATE_DETACHED PTHREAD_DETACHED
#define PTHREAD_CREATE_JOINABLE 1
#define PTHREAD_CREATE_DETACHED 2

/* Pthread cancellation */
#define _PTHREAD_CANCEL_POS 0
Expand Down
31 changes: 31 additions & 0 deletions lib/posix/posix_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,37 @@
#ifndef ZEPHYR_LIB_POSIX_POSIX_INTERNAL_H_
#define ZEPHYR_LIB_POSIX_POSIX_INTERNAL_H_

enum pthread_state {
/* The thread structure is unallocated and available for reuse. */
PTHREAD_TERMINATED = 0,
/* The thread is running and joinable. */
PTHREAD_JOINABLE = PTHREAD_CREATE_JOINABLE,
/* The thread is running and detached. */
PTHREAD_DETACHED = PTHREAD_CREATE_DETACHED,
/* A joinable thread exited and its return code is available. */
PTHREAD_EXITED
};

struct posix_thread {
struct k_thread thread;

/* List of keys that thread has called pthread_setspecific() on */
sys_slist_t key_list;

/* Exit status */
void *retval;

/* Pthread cancellation */
int cancel_state;
int cancel_pending;
pthread_mutex_t cancel_lock;

/* Pthread State */
enum pthread_state state;
pthread_mutex_t state_lock;
pthread_cond_t state_cond;
};

struct posix_thread *to_posix_thread(pthread_t pthread);

#endif