Skip to content

posix: Kconfig: Allow to enable individual components, POSIX_API just enables all #18780

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
merged 4 commits into from
Sep 26, 2019
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
33 changes: 7 additions & 26 deletions include/posix/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#ifdef __NEWLIB__
/* Newever Newlib 3.x+ */
#include <sys/_timespec.h>
#include <sys/timespec.h>
#else /* __NEWLIB__ */
/* Workaround for older Newlib 2.x, as used by Xtensa. It lacks sys/_timeval.h,
* so mimic it here.
Expand All @@ -29,6 +29,11 @@ struct timespec {
long tv_nsec;
};

struct itimerspec {
struct timespec it_interval; /* Timer interval */
struct timespec it_value; /* Timer expiration */
};

#ifdef __cplusplus
}
#endif
Expand All @@ -38,33 +43,9 @@ struct timespec {

#else /* CONFIG_NEWLIB_LIBC */
/* Not Newlib */
#include <sys/_timespec.h>
#include <sys/timespec.h>
#endif /* CONFIG_NEWLIB_LIBC */

/* Older newlib's like 2.{0-2}.0 don't define any newlib version defines, only
* __NEWLIB_H__ so we use that to decide if itimerspec was defined in
* sys/types.h w/o any protection. It appears sometime in the 2.3.0 version
* of newlib did itimerspec move out of sys/types.h, however version 2.3.0
* seems to report itself as __NEWLIB_MINOR__ == 2, where as 2.2.0 doesn't
* even define __NEWLIB_MINOR__ or __NEWLIB__
*/
#if !defined(__NEWLIB_H__) || (__NEWLIB__ >= 3) || \
(__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 2)

#ifdef __cplusplus
extern "C" {
#endif

struct itimerspec {
struct timespec it_interval; /* Timer interval */
struct timespec it_value; /* Timer expiration */
};
#ifdef __cplusplus
}
#endif

#endif

#include <kernel.h>
#include <errno.h>
#include "posix_types.h"
Expand Down
2 changes: 1 addition & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

if(NOT CONFIG_NATIVE_APPLICATION)
add_subdirectory(libc)
add_subdirectory(posix)
endif()
add_subdirectory_ifdef(CONFIG_POSIX_API posix)
add_subdirectory_ifdef(CONFIG_CMSIS_RTOS_V1 cmsis_rtos_v1)
add_subdirectory_ifdef(CONFIG_CMSIS_RTOS_V2 cmsis_rtos_v2)
add_subdirectory(gui)
Expand Down
17 changes: 17 additions & 0 deletions lib/libc/minimal/include/sys/timespec.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (c) 2019 Linaro Limited
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SYS_TIMESPEC_H_
#define ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SYS_TIMESPEC_H_

#include <sys/_timespec.h>

struct itimerspec {
struct timespec it_interval; /* Timer interval */
struct timespec it_value; /* Timer expiration */
};

#endif /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SYS_TIMESPEC_H_ */
12 changes: 7 additions & 5 deletions lib/posix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@

zephyr_interface_library_named(posix_subsys)

target_include_directories(posix_subsys INTERFACE ${ZEPHYR_BASE}/include/posix)
if(CONFIG_POSIX_API)
target_include_directories(posix_subsys INTERFACE ${ZEPHYR_BASE}/include/posix)
endif()

zephyr_library()
zephyr_library_sources(pthread_common.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC pthread_cond.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC pthread_mutex.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC pthread_barrier.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC 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_ifdef(CONFIG_PTHREAD_IPC pthread_sched.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK clock.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK sleep.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK timer.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC pthread_rwlock.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC semaphore.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC pthread_key.c)
Expand Down
14 changes: 12 additions & 2 deletions lib/posix/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ config POSIX_API
Enable mostly-standards-compliant implementations of
various POSIX (IEEE 1003.1) APIs.

if POSIX_API

config PTHREAD_IPC
bool "POSIX pthread IPC API"
default y if POSIX_API
help
This enables a mostly-standards-compliant implementation of
the pthread mutex, condition variable and barrier IPC
Expand All @@ -45,6 +44,13 @@ config SEM_VALUE_MAX

endif # PTHREAD_IPC

config POSIX_CLOCK
bool "POSIX clock, timer, and sleep APIs"
default y if POSIX_API
help
This enables POSIX clock\_\*(), timer\_\*(), and \*sleep()
functions.

config MAX_TIMER_COUNT
int "Maximum timer count in POSIX application"
default 5
Expand All @@ -54,6 +60,7 @@ config MAX_TIMER_COUNT

config POSIX_MQUEUE
bool "Enable POSIX message queue"
default y if POSIX_API
help
This enabled POSIX message queue related APIs.

Expand Down Expand Up @@ -83,6 +90,7 @@ endif
if FILE_SYSTEM
config POSIX_FS
bool "Enable POSIX file system API support"
default y if POSIX_API
help
This enables POSIX style file system related APIs.

Expand All @@ -96,6 +104,8 @@ config POSIX_MAX_OPEN_FILES
endif
endif # FILE_SYSTEM

if POSIX_API

# The name of this option is mandated by zephyr_interface_library_named
# cmake directive.
config APP_LINK_WITH_POSIX_SUBSYS
Expand Down
2 changes: 1 addition & 1 deletion modules/Kconfig.simplelink
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ config SIMPLELINK_HOST_DRIVER
depends on MULTITHREADING
select NEWLIB_LIBC
select ERRNO
select POSIX_API
select PTHREAD_IPC
select POSIX_CLOCK
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for grouping my commit with yours. You may want to update the commit message to include clock and sleep:

PR #18780 introduces a way to decouple pthread support from the general
CONFIG_POSIX_API global switch. This commit modifies the build of
SimpleLink components to take advantage of it, since SimpleLink
libraries only require pthread, sem, clock, and sleep support, not
entire POSIX.

This fixes the build errors in the http_get sample introduced
by the merge of #18736.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, used this message. We also should remove that "platform_exclude: cc3220sf_launchxl" from http_get now, and to not go too detailed, I squashed that into this commit too.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pfalcon . LGTM

help
Build the SimpleLink host driver

Expand Down
1 change: 0 additions & 1 deletion samples/net/sockets/http_get/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ tests:
- CONFIG_NET_SOCKETS_POSIX_NAMES=y
# Forcibly defines CONFIG_POSIX_API, which is incompatible with
# CONFIG_NET_SOCKETS_POSIX_NAMES.
platform_exclude: cc3220sf_launchxl cc3235sf_launchxl
sample.net.sockets.http_get.posix:
filter: and not CONFIG_NET_SOCKETS_OFFLOAD
extra_configs:
Expand Down
1 change: 0 additions & 1 deletion tests/subsys/jwt/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ CONFIG_MBEDTLS_USER_CONFIG_FILE="user-tls.conf"

CONFIG_DEBUG_OPTIMIZATIONS=y

CONFIG_PTHREAD_IPC=y
CONFIG_NET_SOCKETS=y

CONFIG_NEWLIB_LIBC=y
Expand Down