Skip to content
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
2 changes: 1 addition & 1 deletion drivers/wifi/simplelink/simplelink_sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LOG_MODULE_DECLARE(LOG_MODULE_NAME);

#include <stdlib.h>
#include <limits.h>
#include <fcntl.h>
#include <zephyr/posix/fcntl.h>

#include <zephyr/kernel.h>
/* Define sockaddr, etc, before simplelink.h */
Expand Down
33 changes: 33 additions & 0 deletions include/zephyr/posix/fcntl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2018 Linaro Limited
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef ZEPHYR_POSIX_FCNTL_H_
#define ZEPHYR_POSIX_FCNTL_H_

#ifdef CONFIG_PICOLIBC
#define O_CREAT 0x0040
#else
#define O_CREAT 0x0200
#endif

#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)

#define O_RDONLY 00
#define O_WRONLY 01
#define O_RDWR 02

#define O_APPEND 0x0400
#define O_EXCL 0x0800
#define O_NONBLOCK 0x4000

#define F_DUPFD 0
#define F_GETFL 3
#define F_SETFL 4

int open(const char *name, int flags, ...);
int fcntl(int fildes, int cmd, ...);

#endif /* ZEPHYR_POSIX_FCNTL_H_ */
10 changes: 4 additions & 6 deletions include/zephyr/posix/posix_sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@ extern "C" {
#endif

/* Cooperative scheduling policy */
#ifndef SCHED_FIFO
#define SCHED_FIFO 0
#endif /* SCHED_FIFO */
#define SCHED_FIFO 1

/* Priority based preemptive scheduling policy */
#ifndef SCHED_RR
#define SCHED_RR 1
#endif /* SCHED_RR */
#define SCHED_RR 2

#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC)
struct sched_param {
int sched_priority;
};
#endif

/**
* @brief Yield the processor
Expand Down
37 changes: 27 additions & 10 deletions include/zephyr/posix/posix_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef ZEPHYR_INCLUDE_POSIX_SYS_TYPES_H_
#define ZEPHYR_INCLUDE_POSIX_SYS_TYPES_H_
#ifndef ZEPHYR_INCLUDE_POSIX_TYPES_H_
#define ZEPHYR_INCLUDE_POSIX_TYPES_H_

#ifndef CONFIG_ARCH_POSIX
#include <sys/types.h>
#endif

#ifdef CONFIG_NEWLIB_LIBC
#include <sys/_pthreadtypes.h>
#endif

#include <zephyr/kernel.h>

#ifdef __cplusplus
Expand All @@ -33,16 +37,20 @@ typedef unsigned long timer_t;

#ifdef CONFIG_PTHREAD_IPC
/* Thread attributes */
typedef struct pthread_attr {
struct pthread_attr {
int priority;
void *stack;
size_t stacksize;
uint32_t stacksize;
uint32_t flags;
uint32_t delayedstart;
uint32_t schedpolicy;
int32_t detachstate;
uint32_t initialized;
} pthread_attr_t;
};
#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC)
typedef struct pthread_attr pthread_attr_t;
#endif
BUILD_ASSERT(sizeof(pthread_attr_t) >= sizeof(struct pthread_attr));

typedef uint32_t pthread_t;

Expand All @@ -52,15 +60,24 @@ typedef struct k_sem sem_t;
/* Mutex */
typedef uint32_t pthread_mutex_t;

typedef struct pthread_mutexattr {
struct pthread_mutexattr {
int type;
} pthread_mutexattr_t;
};
#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC)
typedef struct pthread_mutexattr pthread_mutexattr_t;
#endif
BUILD_ASSERT(sizeof(pthread_mutexattr_t) >= sizeof(struct pthread_mutexattr));

/* Condition variables */
typedef uint32_t pthread_cond_t;

typedef struct pthread_condattr {
} pthread_condattr_t;
struct pthread_condattr {
};

#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC)
typedef struct pthread_condattr pthread_condattr_t;
#endif
BUILD_ASSERT(sizeof(pthread_condattr_t) >= sizeof(struct pthread_condattr));

/* Barrier */
typedef struct pthread_barrier {
Expand Down Expand Up @@ -88,4 +105,4 @@ typedef struct pthread_rwlock_obj {
}
#endif

#endif /* ZEPHYR_INCLUDE_POSIX_SYS_TYPES_H_ */
#endif /* ZEPHYR_INCLUDE_POSIX_TYPES_H_ */
9 changes: 6 additions & 3 deletions include/zephyr/posix/pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,19 @@ extern "C" {
#endif

/* Pthread detach/joinable */
#define PTHREAD_CREATE_JOINABLE 1
#define PTHREAD_CREATE_DETACHED 2
#define PTHREAD_CREATE_DETACHED 0
#define PTHREAD_CREATE_JOINABLE 1

/* Pthread cancellation */
#define _PTHREAD_CANCEL_POS 0
#define PTHREAD_CANCEL_ENABLE (0U << _PTHREAD_CANCEL_POS)
#define PTHREAD_CANCEL_DISABLE BIT(_PTHREAD_CANCEL_POS)

/* Passed to pthread_once */
#define PTHREAD_ONCE_INIT 1
#define PTHREAD_ONCE_INIT \
{ \
1, 0 \
}

/* The minimum allowable stack size */
#define PTHREAD_STACK_MIN Z_KERNEL_STACK_SIZE_ADJUST(0)
Expand Down
7 changes: 6 additions & 1 deletion include/zephyr/posix/pthread_key.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
extern "C" {
#endif

typedef uint32_t pthread_once_t;
#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC)
typedef struct {
int is_initialized;
int init_executed;
} pthread_once_t;
#endif

/* pthread_key */
typedef uint32_t pthread_key_t;
Expand Down
2 changes: 1 addition & 1 deletion include/zephyr/posix/signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ typedef struct sigevent {
}
#endif

#endif /* POSIX__SIGNAL_H */
#endif /* ZEPHYR_INCLUDE_POSIX_SIGNAL_H_ */
2 changes: 1 addition & 1 deletion include/zephyr/posix/sys/eventfd.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <zephyr/sys/fdtable.h>
#include <sys/types.h>

#include <fcntl.h>
#include <zephyr/posix/fcntl.h>

#ifdef __cplusplus
extern "C" {
Expand Down
Loading