Skip to content

Commit f603e60

Browse files
Ramakrishna PallalaAnas Nashif
authored andcommitted
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 <[email protected]>
1 parent cd05a63 commit f603e60

24 files changed

+130
-123
lines changed

include/posix/mqueue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define __MQUEUE_H__
99

1010
#include <kernel.h>
11-
#include <time.h>
11+
#include <posix/time.h>
1212
#include "sys/types.h"
1313

1414
#ifdef __cplusplus

include/posix/pthread.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
#define __PTHREAD_H__
99

1010
#include <kernel.h>
11-
#include <time.h>
11+
#include <posix/time.h>
12+
#include <posix/unistd.h>
1213
#include "sys/types.h"
1314
#include "posix_sched.h"
14-
#include "unistd.h"
1515

1616
enum pthread_state {
1717
/* The thread is running and joinable. */

include/posix/semaphore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
extern "C" {
1111
#endif
1212

13+
#include <posix/time.h>
1314
#include "sys/types.h"
14-
#include <time.h>
1515

1616
int sem_destroy(sem_t *semaphore);
1717
int sem_getvalue(sem_t *restrict semaphore, int *restrict value);

include/posix/time.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
extern "C" {
1111
#endif
1212

13-
#ifdef CONFIG_NEWLIB_LIBC
14-
#include_next <time.h>
15-
#else
1613
struct timespec {
1714
signed int tv_sec;
1815
signed int tv_nsec;
@@ -22,7 +19,6 @@ struct itimerspec {
2219
struct timespec it_interval; /* Timer interval */
2320
struct timespec it_value; /* Timer expiration */
2421
};
25-
#endif /* CONFIG_NEWLIB_LIBC */
2622

2723
#include <kernel.h>
2824
#include <errno.h>

include/posix/unistd.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ extern "C" {
1212

1313
#include "sys/types.h"
1414

15-
#ifndef __ZEPHYR__
16-
#include_next <unistd.h>
17-
#endif
18-
1915
unsigned sleep(unsigned int seconds);
2016
int usleep(useconds_t useconds);
2117

kernel/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,11 @@ add_library(kernel
2525
smp.c
2626
)
2727

28-
if (CONFIG_PTHREAD_IPC)
29-
target_include_directories(kernel PRIVATE ${PROJECT_SOURCE_DIR}/include/posix)
30-
endif (CONFIG_PTHREAD_IPC)
3128
target_sources_ifdef(CONFIG_INT_LATENCY_BENCHMARK kernel PRIVATE int_latency_bench.c)
3229
target_sources_ifdef(CONFIG_STACK_CANARIES kernel PRIVATE compiler_stack_protect.c)
3330
target_sources_ifdef(CONFIG_SYS_CLOCK_EXISTS kernel PRIVATE timer.c)
3431
target_sources_ifdef(CONFIG_ATOMIC_OPERATIONS_C kernel PRIVATE atomic_c.c)
3532
target_sources_if_kconfig( kernel PRIVATE poll.c)
36-
add_subdirectory_ifdef(CONFIG_PTHREAD_IPC posix)
3733

3834
# The last 2 files inside the target_sources_ifdef should be
3935
# userspace_handler.c and userspace.c. If not the linker would complain.

kernel/Kconfig

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -487,76 +487,6 @@ config APPLICATION_INIT_PRIORITY
487487

488488
endmenu
489489

490-
menu "POSIX Layer"
491-
config PTHREAD_IPC
492-
bool
493-
prompt "POSIX pthread IPC API"
494-
default n
495-
help
496-
This enables a mostly-standards-compliant implementation of
497-
the pthread mutex, condition variable and barrier IPC
498-
mechanisms.
499-
500-
if PTHREAD_IPC
501-
config MAX_PTHREAD_COUNT
502-
int
503-
prompt "Maximum pthread count in POSIX application"
504-
default 5
505-
range 0 255
506-
help
507-
Mention maximum number of threads in POSIX compliant application.
508-
509-
config SEM_VALUE_MAX
510-
int
511-
prompt "Maximum semaphore limit"
512-
default 32767
513-
range 1 32767
514-
help
515-
Maximum semaphore count in POSIX compliant Application.
516-
517-
config MAX_TIMER_COUNT
518-
int
519-
prompt "Maximum timer count in POSIX application"
520-
default 5
521-
range 0 255
522-
help
523-
Mention maximum number of timers in POSIX compliant application.
524-
525-
config POSIX_MQUEUE
526-
bool
527-
prompt "Enable POSIX message queue"
528-
default n
529-
help
530-
This enabled POSIX message queue related APIs.
531-
532-
if POSIX_MQUEUE
533-
config MSG_COUNT_MAX
534-
int
535-
prompt "Maximum number of messages in message queue"
536-
default 16
537-
help
538-
Mention maximum number of messages in message queue in POSIX compliant
539-
application.
540-
541-
config MSG_SIZE_MAX
542-
int
543-
prompt "Maximum size of a message"
544-
default 16
545-
help
546-
Mention maximum size of message in bytes.
547-
548-
config MQUEUE_NAMELEN_MAX
549-
int
550-
prompt "Maximum size of a name length"
551-
default 16
552-
range 2 255
553-
help
554-
Mention length of message queue name in number of characters.
555-
556-
endif
557-
endif
558-
endmenu
559-
560490
menu "Security Options"
561491

562492
config STACK_CANARIES

kernel/posix/CMakeLists.txt

Lines changed: 0 additions & 12 deletions
This file was deleted.

lib/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ endif()
66
add_subdirectory_if_kconfig(ring_buffer)
77
add_subdirectory_if_kconfig(base64)
88
add_subdirectory(mempool)
9+
add_subdirectory_ifdef(CONFIG_PTHREAD_IPC posix)

lib/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,7 @@ config BASE64
3131
default n
3232
help
3333
Enable base64 encoding and decoding functionality
34+
35+
source "lib/posix/Kconfig"
36+
3437
endmenu

0 commit comments

Comments
 (0)