lib: posix: Move posix layer from 'kernel' to 'lib'
Move posix layer from 'kernel' to 'lib' folder as it is not a core kernel feature. Fixed posix header file dependencies as part of the move and also removed NEWLIBC related macros from posix headers. Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
This commit is contained in:
parent
cd05a630c8
commit
f603e603bb
24 changed files with 130 additions and 123 deletions
|
@ -8,7 +8,7 @@
|
|||
#define __MQUEUE_H__
|
||||
|
||||
#include <kernel.h>
|
||||
#include <time.h>
|
||||
#include <posix/time.h>
|
||||
#include "sys/types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
#define __PTHREAD_H__
|
||||
|
||||
#include <kernel.h>
|
||||
#include <time.h>
|
||||
#include <posix/time.h>
|
||||
#include <posix/unistd.h>
|
||||
#include "sys/types.h"
|
||||
#include "posix_sched.h"
|
||||
#include "unistd.h"
|
||||
|
||||
enum pthread_state {
|
||||
/* The thread is running and joinable. */
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <posix/time.h>
|
||||
#include "sys/types.h"
|
||||
#include <time.h>
|
||||
|
||||
int sem_destroy(sem_t *semaphore);
|
||||
int sem_getvalue(sem_t *restrict semaphore, int *restrict value);
|
||||
|
|
|
@ -10,9 +10,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NEWLIB_LIBC
|
||||
#include_next <time.h>
|
||||
#else
|
||||
struct timespec {
|
||||
signed int tv_sec;
|
||||
signed int tv_nsec;
|
||||
|
@ -22,7 +19,6 @@ struct itimerspec {
|
|||
struct timespec it_interval; /* Timer interval */
|
||||
struct timespec it_value; /* Timer expiration */
|
||||
};
|
||||
#endif /* CONFIG_NEWLIB_LIBC */
|
||||
|
||||
#include <kernel.h>
|
||||
#include <errno.h>
|
||||
|
|
|
@ -12,10 +12,6 @@ extern "C" {
|
|||
|
||||
#include "sys/types.h"
|
||||
|
||||
#ifndef __ZEPHYR__
|
||||
#include_next <unistd.h>
|
||||
#endif
|
||||
|
||||
unsigned sleep(unsigned int seconds);
|
||||
int usleep(useconds_t useconds);
|
||||
|
||||
|
|
|
@ -25,15 +25,11 @@ add_library(kernel
|
|||
smp.c
|
||||
)
|
||||
|
||||
if (CONFIG_PTHREAD_IPC)
|
||||
target_include_directories(kernel PRIVATE ${PROJECT_SOURCE_DIR}/include/posix)
|
||||
endif (CONFIG_PTHREAD_IPC)
|
||||
target_sources_ifdef(CONFIG_INT_LATENCY_BENCHMARK kernel PRIVATE int_latency_bench.c)
|
||||
target_sources_ifdef(CONFIG_STACK_CANARIES kernel PRIVATE compiler_stack_protect.c)
|
||||
target_sources_ifdef(CONFIG_SYS_CLOCK_EXISTS kernel PRIVATE timer.c)
|
||||
target_sources_ifdef(CONFIG_ATOMIC_OPERATIONS_C kernel PRIVATE atomic_c.c)
|
||||
target_sources_if_kconfig( kernel PRIVATE poll.c)
|
||||
add_subdirectory_ifdef(CONFIG_PTHREAD_IPC posix)
|
||||
|
||||
# The last 2 files inside the target_sources_ifdef should be
|
||||
# userspace_handler.c and userspace.c. If not the linker would complain.
|
||||
|
|
|
@ -487,76 +487,6 @@ config APPLICATION_INIT_PRIORITY
|
|||
|
||||
endmenu
|
||||
|
||||
menu "POSIX Layer"
|
||||
config PTHREAD_IPC
|
||||
bool
|
||||
prompt "POSIX pthread IPC API"
|
||||
default n
|
||||
help
|
||||
This enables a mostly-standards-compliant implementation of
|
||||
the pthread mutex, condition variable and barrier IPC
|
||||
mechanisms.
|
||||
|
||||
if PTHREAD_IPC
|
||||
config MAX_PTHREAD_COUNT
|
||||
int
|
||||
prompt "Maximum pthread count in POSIX application"
|
||||
default 5
|
||||
range 0 255
|
||||
help
|
||||
Mention maximum number of threads in POSIX compliant application.
|
||||
|
||||
config SEM_VALUE_MAX
|
||||
int
|
||||
prompt "Maximum semaphore limit"
|
||||
default 32767
|
||||
range 1 32767
|
||||
help
|
||||
Maximum semaphore count in POSIX compliant Application.
|
||||
|
||||
config MAX_TIMER_COUNT
|
||||
int
|
||||
prompt "Maximum timer count in POSIX application"
|
||||
default 5
|
||||
range 0 255
|
||||
help
|
||||
Mention maximum number of timers in POSIX compliant application.
|
||||
|
||||
config POSIX_MQUEUE
|
||||
bool
|
||||
prompt "Enable POSIX message queue"
|
||||
default n
|
||||
help
|
||||
This enabled POSIX message queue related APIs.
|
||||
|
||||
if POSIX_MQUEUE
|
||||
config MSG_COUNT_MAX
|
||||
int
|
||||
prompt "Maximum number of messages in message queue"
|
||||
default 16
|
||||
help
|
||||
Mention maximum number of messages in message queue in POSIX compliant
|
||||
application.
|
||||
|
||||
config MSG_SIZE_MAX
|
||||
int
|
||||
prompt "Maximum size of a message"
|
||||
default 16
|
||||
help
|
||||
Mention maximum size of message in bytes.
|
||||
|
||||
config MQUEUE_NAMELEN_MAX
|
||||
int
|
||||
prompt "Maximum size of a name length"
|
||||
default 16
|
||||
range 2 255
|
||||
help
|
||||
Mention length of message queue name in number of characters.
|
||||
|
||||
endif
|
||||
endif
|
||||
endmenu
|
||||
|
||||
menu "Security Options"
|
||||
|
||||
config STACK_CANARIES
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
target_sources(kernel PRIVATE posix/pthread_common.c)
|
||||
target_sources(kernel PRIVATE posix/pthread_cond.c)
|
||||
target_sources(kernel PRIVATE posix/pthread_mutex.c)
|
||||
target_sources(kernel PRIVATE posix/pthread_barrier.c)
|
||||
target_sources(kernel PRIVATE posix/pthread.c)
|
||||
target_sources(kernel PRIVATE posix/pthread_sched.c)
|
||||
target_sources(kernel PRIVATE posix/clock.c)
|
||||
target_sources(kernel PRIVATE posix/sleep.c)
|
||||
target_sources(kernel PRIVATE posix/timer.c)
|
||||
target_sources(kernel PRIVATE posix/pthread_rwlock.c)
|
||||
target_sources(kernel PRIVATE posix/semaphore.c)
|
||||
target_sources_ifdef(CONFIG_POSIX_MQUEUE kernel PRIVATE posix/mqueue.c)
|
|
@ -6,3 +6,4 @@ endif()
|
|||
add_subdirectory_if_kconfig(ring_buffer)
|
||||
add_subdirectory_if_kconfig(base64)
|
||||
add_subdirectory(mempool)
|
||||
add_subdirectory_ifdef(CONFIG_PTHREAD_IPC posix)
|
||||
|
|
|
@ -31,4 +31,7 @@ config BASE64
|
|||
default n
|
||||
help
|
||||
Enable base64 encoding and decoding functionality
|
||||
|
||||
source "lib/posix/Kconfig"
|
||||
|
||||
endmenu
|
||||
|
|
21
lib/posix/CMakeLists.txt
Normal file
21
lib/posix/CMakeLists.txt
Normal file
|
@ -0,0 +1,21 @@
|
|||
|
||||
add_library(PTHREAD INTERFACE)
|
||||
|
||||
target_include_directories(PTHREAD INTERFACE ${PROJECT_SOURCE_DIR}/include/posix)
|
||||
|
||||
zephyr_library()
|
||||
zephyr_library_sources(pthread_common.c)
|
||||
zephyr_library_sources(pthread_cond.c)
|
||||
zephyr_library_sources(pthread_mutex.c)
|
||||
zephyr_library_sources(pthread_barrier.c)
|
||||
zephyr_library_sources(pthread.c)
|
||||
zephyr_library_sources(pthread_sched.c)
|
||||
zephyr_library_sources(clock.c)
|
||||
zephyr_library_sources(sleep.c)
|
||||
zephyr_library_sources(timer.c)
|
||||
zephyr_library_sources(pthread_rwlock.c)
|
||||
zephyr_library_sources(semaphore.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_POSIX_MQUEUE mqueue.c)
|
||||
|
||||
zephyr_library_link_libraries(PTHREAD)
|
||||
target_link_libraries(PTHREAD INTERFACE zephyr_interface)
|
73
lib/posix/Kconfig
Normal file
73
lib/posix/Kconfig
Normal file
|
@ -0,0 +1,73 @@
|
|||
#
|
||||
# Copyright (c) 2018 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
config PTHREAD_IPC
|
||||
bool
|
||||
prompt "POSIX pthread IPC API"
|
||||
default n
|
||||
help
|
||||
This enables a mostly-standards-compliant implementation of
|
||||
the pthread mutex, condition variable and barrier IPC
|
||||
mechanisms.
|
||||
|
||||
if PTHREAD_IPC
|
||||
config MAX_PTHREAD_COUNT
|
||||
int
|
||||
prompt "Maximum pthread count in POSIX application"
|
||||
default 5
|
||||
range 0 255
|
||||
help
|
||||
Mention maximum number of threads in POSIX compliant application.
|
||||
|
||||
config SEM_VALUE_MAX
|
||||
int
|
||||
prompt "Maximum semaphore limit"
|
||||
default 32767
|
||||
range 1 32767
|
||||
help
|
||||
Maximum semaphore count in POSIX compliant Application.
|
||||
|
||||
config MAX_TIMER_COUNT
|
||||
int
|
||||
prompt "Maximum timer count in POSIX application"
|
||||
default 5
|
||||
range 0 255
|
||||
help
|
||||
Mention maximum number of timers in POSIX compliant application.
|
||||
|
||||
config POSIX_MQUEUE
|
||||
bool
|
||||
prompt "Enable POSIX message queue"
|
||||
default n
|
||||
help
|
||||
This enabled POSIX message queue related APIs.
|
||||
|
||||
if POSIX_MQUEUE
|
||||
config MSG_COUNT_MAX
|
||||
int
|
||||
prompt "Maximum number of messages in message queue"
|
||||
default 16
|
||||
help
|
||||
Mention maximum number of messages in message queue in POSIX compliant
|
||||
application.
|
||||
|
||||
config MSG_SIZE_MAX
|
||||
int
|
||||
prompt "Maximum size of a message"
|
||||
default 16
|
||||
help
|
||||
Mention maximum size of message in bytes.
|
||||
|
||||
config MQUEUE_NAMELEN_MAX
|
||||
int
|
||||
prompt "Maximum size of a name length"
|
||||
default 16
|
||||
range 2 255
|
||||
help
|
||||
Mention length of message queue name in number of characters.
|
||||
|
||||
endif
|
||||
endif
|
|
@ -4,8 +4,9 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <kernel.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <posix/time.h>
|
||||
#include <posix/sys/types.h>
|
||||
|
||||
/**
|
||||
* @brief Get clock time specified by clock_id.
|
|
@ -4,11 +4,11 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <kernel.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <mqueue.h>
|
||||
#include <string.h>
|
||||
#include <atomic.h>
|
||||
#include <posix/time.h>
|
||||
#include <posix/mqueue.h>
|
||||
|
||||
typedef struct mqueue_object {
|
||||
sys_snode_t snode;
|
|
@ -5,11 +5,11 @@
|
|||
*/
|
||||
|
||||
#include <kernel.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <atomic.h>
|
||||
#include "ksched.h"
|
||||
#include "wait_q.h"
|
||||
#include <ksched.h>
|
||||
#include <wait_q.h>
|
||||
#include <posix/pthread.h>
|
||||
|
||||
#define PTHREAD_INIT_FLAGS PTHREAD_CANCEL_ENABLE
|
||||
#define PTHREAD_CANCELED ((void *) -1)
|
|
@ -5,9 +5,9 @@
|
|||
*/
|
||||
|
||||
#include <kernel.h>
|
||||
#include <pthread.h>
|
||||
#include "ksched.h"
|
||||
#include "wait_q.h"
|
||||
#include <posix/pthread.h>
|
||||
#include <ksched.h>
|
||||
#include <wait_q.h>
|
||||
#include <kswap.h>
|
||||
|
||||
void ready_one_thread(_wait_q_t *wq);
|
|
@ -5,10 +5,10 @@
|
|||
*/
|
||||
|
||||
#include <kernel.h>
|
||||
#include <pthread.h>
|
||||
#include "ksched.h"
|
||||
#include "wait_q.h"
|
||||
#include "time.h"
|
||||
#include <ksched.h>
|
||||
#include <wait_q.h>
|
||||
#include <posix/pthread.h>
|
||||
#include <posix/time.h>
|
||||
|
||||
void ready_one_thread(_wait_q_t *wq)
|
||||
{
|
|
@ -5,10 +5,10 @@
|
|||
*/
|
||||
|
||||
#include <kernel.h>
|
||||
#include <pthread.h>
|
||||
#include "ksched.h"
|
||||
#include "wait_q.h"
|
||||
#include <ksched.h>
|
||||
#include <wait_q.h>
|
||||
#include <kswap.h>
|
||||
#include <posix/pthread.h>
|
||||
|
||||
void ready_one_thread(_wait_q_t *wq);
|
||||
|
|
@ -5,9 +5,9 @@
|
|||
*/
|
||||
|
||||
#include <kernel.h>
|
||||
#include <pthread.h>
|
||||
#include "ksched.h"
|
||||
#include "wait_q.h"
|
||||
#include <ksched.h>
|
||||
#include <wait_q.h>
|
||||
#include <posix/pthread.h>
|
||||
|
||||
int pthread_mutex_trylock(pthread_mutex_t *m)
|
||||
{
|
|
@ -4,9 +4,9 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <kernel.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <posix/time.h>
|
||||
#include <posix/sys/types.h>
|
||||
|
||||
#define INITIALIZED 1
|
||||
#define NOT_INITIALIZED 0
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <kernel.h>
|
||||
#include <posix_sched.h>
|
||||
#include <posix/posix_sched.h>
|
||||
|
||||
static bool valid_posix_policy(int policy)
|
||||
{
|
|
@ -4,8 +4,8 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include <posix/pthread.h>
|
||||
|
||||
/**
|
||||
* @brief Destroy semaphore.
|
|
@ -3,7 +3,9 @@
|
|||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <unistd.h>
|
||||
|
||||
#include <kernel.h>
|
||||
#include <posix/unistd.h>
|
||||
|
||||
/**
|
||||
* @brief Sleep for a specified number of seconds.
|
|
@ -4,10 +4,10 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <kernel.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <misc/printk.h>
|
||||
#include <posix/time.h>
|
||||
|
||||
#define ACTIVE 1
|
||||
#define NOT_ACTIVE 0
|
Loading…
Add table
Add a link
Reference in a new issue