Skip to content

Commit 9384cc5

Browse files
fabiobaltiericfriedt
authored andcommitted
Revert "posix: switch to using posix_time.h and posix_signal.h"
This reverts commit 1eb5c97. Signed-off-by: Fabio Baltieri <[email protected]>
1 parent 376ca57 commit 9384cc5

File tree

30 files changed

+379
-315
lines changed

30 files changed

+379
-315
lines changed

include/zephyr/posix/mqueue.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
#ifndef ZEPHYR_INCLUDE_POSIX_MESSAGE_PASSING_H_
88
#define ZEPHYR_INCLUDE_POSIX_MESSAGE_PASSING_H_
99

10-
#include <time.h>
11-
#include <signal.h>
12-
1310
#include <zephyr/kernel.h>
11+
#include <zephyr/posix/time.h>
1412
#include <zephyr/posix/fcntl.h>
13+
#include <zephyr/posix/signal.h>
1514
#include <zephyr/posix/sys/stat.h>
1615
#include <zephyr/posix/posix_types.h>
1716

include/zephyr/posix/posix_features.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@
5252
#define _POSIX_BARRIERS _POSIX_VERSION
5353
#endif
5454

55+
#ifdef CONFIG_POSIX_CLOCK_SELECTION
56+
#define _POSIX_CLOCK_SELECTION _POSIX_VERSION
57+
#endif
58+
59+
#ifdef CONFIG_POSIX_CPUTIME
60+
#define _POSIX_CPUTIME _POSIX_VERSION
61+
#endif
62+
5563
#ifdef CONFIG_POSIX_FSYNC
5664
#define _POSIX_FSYNC _POSIX_VERSION
5765
#endif
@@ -82,6 +90,10 @@
8290
#define _POSIX_MESSAGE_PASSING _POSIX_VERSION
8391
#endif
8492

93+
#ifdef CONFIG_POSIX_MONOTONIC_CLOCK
94+
#define _POSIX_MONOTONIC_CLOCK _POSIX_VERSION
95+
#endif
96+
8597
/* #define _POSIX_PRIORITIZED_IO (-1L) */
8698

8799
#ifdef CONFIG_POSIX_PRIORITY_SCHEDULING
@@ -96,6 +108,7 @@
96108
#define _POSIX_READER_WRITER_LOCKS _POSIX_VERSION
97109
#endif
98110

111+
/* #define _POSIX_REALTIME_SIGNALS (-1L) */
99112
/* #define _POSIX_REGEXP (-1L) */
100113
/* #define _POSIX_SAVED_IDS (-1L) */
101114

@@ -148,6 +161,10 @@
148161
/* #define _POSIX_THREAD_ROBUST_PRIO_INHERIT (-1L) */
149162
/* #define _POSIX_THREAD_ROBUST_PRIO_PROTECT (-1L) */
150163

164+
#ifdef CONFIG_POSIX_THREAD_SAFE_FUNCTIONS
165+
#define _POSIX_THREAD_SAFE_FUNCTIONS _POSIX_VERSION
166+
#endif
167+
151168
/* #define _POSIX_THREAD_SPORADIC_SERVER (-1L) */
152169

153170
#ifdef CONFIG_POSIX_THREADS
@@ -160,6 +177,10 @@
160177
#define _POSIX_TIMEOUTS _POSIX_VERSION
161178
#endif
162179

180+
#ifdef CONFIG_POSIX_TIMERS
181+
#define _POSIX_TIMERS _POSIX_VERSION
182+
#endif
183+
163184
/* #define _POSIX_TRACE (-1L) */
164185
/* #define _POSIX_TRACE_EVENT_FILTER (-1L) */
165186
/* #define _POSIX_TRACE_INHERIT (-1L) */

include/zephyr/posix/pthread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
#include <stdlib.h>
1111
#include <string.h>
12-
#include <time.h>
1312

1413
#include <zephyr/kernel.h>
14+
#include <zephyr/posix/time.h>
1515
#include <zephyr/posix/unistd.h>
1616
#include <zephyr/posix/sched.h>
1717

include/zephyr/posix/semaphore.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
#ifndef ZEPHYR_INCLUDE_POSIX_SEMAPHORE_H_
77
#define ZEPHYR_INCLUDE_POSIX_SEMAPHORE_H_
88

9-
#include <time.h>
10-
9+
#include <zephyr/posix/time.h>
1110
#include <zephyr/posix/posix_types.h>
1211

1312
#ifdef __cplusplus

include/zephyr/posix/signal.h

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
/*
2+
* Copyright (c) 2018 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#ifndef ZEPHYR_INCLUDE_POSIX_SIGNAL_H_
7+
#define ZEPHYR_INCLUDE_POSIX_SIGNAL_H_
8+
9+
/* include posix_types.h before posix_features.h (here) to avoid build errors against newlib */
10+
#include <zephyr/posix/posix_types.h>
11+
#include "posix_features.h"
12+
13+
#ifdef __cplusplus
14+
extern "C" {
15+
#endif
16+
17+
#define SIGHUP 1 /**< Hangup */
18+
#define SIGINT 2 /**< Interrupt */
19+
#define SIGQUIT 3 /**< Quit */
20+
#define SIGILL 4 /**< Illegal instruction */
21+
#define SIGTRAP 5 /**< Trace/breakpoint trap */
22+
#define SIGABRT 6 /**< Aborted */
23+
#define SIGBUS 7 /**< Bus error */
24+
#define SIGFPE 8 /**< Arithmetic exception */
25+
#define SIGKILL 9 /**< Killed */
26+
#define SIGUSR1 10 /**< User-defined signal 1 */
27+
#define SIGSEGV 11 /**< Invalid memory reference */
28+
#define SIGUSR2 12 /**< User-defined signal 2 */
29+
#define SIGPIPE 13 /**< Broken pipe */
30+
#define SIGALRM 14 /**< Alarm clock */
31+
#define SIGTERM 15 /**< Terminated */
32+
/* 16 not used */
33+
#define SIGCHLD 17 /**< Child status changed */
34+
#define SIGCONT 18 /**< Continued */
35+
#define SIGSTOP 19 /**< Stop executing */
36+
#define SIGTSTP 20 /**< Stopped */
37+
#define SIGTTIN 21 /**< Stopped (read) */
38+
#define SIGTTOU 22 /**< Stopped (write) */
39+
#define SIGURG 23 /**< Urgent I/O condition */
40+
#define SIGXCPU 24 /**< CPU time limit exceeded */
41+
#define SIGXFSZ 25 /**< File size limit exceeded */
42+
#define SIGVTALRM 26 /**< Virtual timer expired */
43+
#define SIGPROF 27 /**< Profiling timer expired */
44+
/* 28 not used */
45+
#define SIGPOLL 29 /**< Pollable event occurred */
46+
/* 30 not used */
47+
#define SIGSYS 31 /**< Bad system call */
48+
49+
#define SIGRTMIN 32
50+
#if defined(CONFIG_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__)
51+
BUILD_ASSERT(CONFIG_POSIX_RTSIG_MAX >= 0);
52+
#define SIGRTMAX (SIGRTMIN + CONFIG_POSIX_RTSIG_MAX)
53+
#else
54+
#define SIGRTMAX SIGRTMIN
55+
#endif
56+
57+
typedef struct {
58+
unsigned long sig[DIV_ROUND_UP(SIGRTMAX + 1, BITS_PER_LONG)];
59+
} sigset_t;
60+
61+
#ifndef SIGEV_NONE
62+
#define SIGEV_NONE 1
63+
#endif
64+
65+
#ifndef SIGEV_SIGNAL
66+
#define SIGEV_SIGNAL 2
67+
#endif
68+
69+
#ifndef SIGEV_THREAD
70+
#define SIGEV_THREAD 3
71+
#endif
72+
73+
#ifndef SIG_BLOCK
74+
#define SIG_BLOCK 0
75+
#endif
76+
#ifndef SIG_SETMASK
77+
#define SIG_SETMASK 1
78+
#endif
79+
#ifndef SIG_UNBLOCK
80+
#define SIG_UNBLOCK 2
81+
#endif
82+
83+
#define SIG_DFL ((void *)0)
84+
#define SIG_IGN ((void *)1)
85+
#define SIG_ERR ((void *)-1)
86+
87+
#define SI_USER 1
88+
#define SI_QUEUE 2
89+
#define SI_TIMER 3
90+
#define SI_ASYNCIO 4
91+
#define SI_MESGQ 5
92+
93+
typedef int sig_atomic_t; /* Atomic entity type (ANSI) */
94+
95+
union sigval {
96+
void *sival_ptr;
97+
int sival_int;
98+
};
99+
100+
struct sigevent {
101+
void (*sigev_notify_function)(union sigval val);
102+
pthread_attr_t *sigev_notify_attributes;
103+
union sigval sigev_value;
104+
int sigev_notify;
105+
int sigev_signo;
106+
};
107+
108+
typedef struct {
109+
int si_signo;
110+
int si_code;
111+
union sigval si_value;
112+
} siginfo_t;
113+
114+
struct sigaction {
115+
void (*sa_handler)(int signno);
116+
sigset_t sa_mask;
117+
int sa_flags;
118+
void (*sa_sigaction)(int signo, siginfo_t *info, void *context);
119+
};
120+
121+
typedef void (*sighandler_t)(int signo);
122+
123+
unsigned int alarm(unsigned int seconds);
124+
int kill(pid_t pid, int sig);
125+
int pause(void);
126+
int raise(int signo);
127+
TOOLCHAIN_DISABLE_WARNING(TOOLCHAIN_WARNING_SHADOW);
128+
int sigaction(int sig, const struct sigaction *ZRESTRICT act, struct sigaction *ZRESTRICT oact);
129+
TOOLCHAIN_ENABLE_WARNING(TOOLCHAIN_WARNING_SHADOW);
130+
int sigpending(sigset_t *set);
131+
int sigsuspend(const sigset_t *sigmask);
132+
int sigwait(const sigset_t *ZRESTRICT set, int *ZRESTRICT signo);
133+
char *strsignal(int signum);
134+
int sigemptyset(sigset_t *set);
135+
int sigfillset(sigset_t *set);
136+
int sigaddset(sigset_t *set, int signo);
137+
int sigdelset(sigset_t *set, int signo);
138+
int sigismember(const sigset_t *set, int signo);
139+
sighandler_t signal(int signo, sighandler_t handler);
140+
int sigprocmask(int how, const sigset_t *ZRESTRICT set, sigset_t *ZRESTRICT oset);
141+
142+
int pthread_sigmask(int how, const sigset_t *ZRESTRICT set, sigset_t *ZRESTRICT oset);
143+
144+
#ifdef __cplusplus
145+
}
146+
#endif
147+
148+
#endif /* ZEPHYR_INCLUDE_POSIX_SIGNAL_H_ */

include/zephyr/posix/time.h

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*
2+
* Copyright (c) 2018 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#ifndef ZEPHYR_INCLUDE_POSIX_TIME_H_
7+
#define ZEPHYR_INCLUDE_POSIX_TIME_H_
8+
9+
/* Read standard header. This may find <posix/time.h> since they
10+
* refer to the same file when include/posix is in the search path.
11+
*/
12+
#include <time.h>
13+
14+
#ifdef CONFIG_NEWLIB_LIBC
15+
/* Kludge to support outdated newlib version as used in SDK 0.10 for Xtensa */
16+
#include <newlib.h>
17+
18+
#ifdef __NEWLIB__
19+
/* Newever Newlib 3.x+ */
20+
#include <sys/timespec.h>
21+
#else /* __NEWLIB__ */
22+
/* Workaround for older Newlib 2.x, as used by Xtensa. It lacks sys/_timeval.h,
23+
* so mimic it here.
24+
*/
25+
#include <sys/types.h>
26+
#ifndef __timespec_defined
27+
28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
32+
struct timespec {
33+
time_t tv_sec;
34+
long tv_nsec;
35+
};
36+
37+
struct itimerspec {
38+
struct timespec it_interval; /* Timer interval */
39+
struct timespec it_value; /* Timer expiration */
40+
};
41+
42+
#ifdef __cplusplus
43+
}
44+
#endif
45+
46+
#endif /* __timespec_defined */
47+
#endif /* __NEWLIB__ */
48+
49+
#else /* CONFIG_NEWLIB_LIBC */
50+
/* Not Newlib */
51+
# if defined(CONFIG_ARCH_POSIX) && defined(CONFIG_EXTERNAL_LIBC)
52+
# include <bits/types/struct_timespec.h>
53+
# include <bits/types/struct_itimerspec.h>
54+
# else
55+
# include <sys/timespec.h>
56+
# endif
57+
#endif /* CONFIG_NEWLIB_LIBC */
58+
59+
#include <zephyr/kernel.h>
60+
#include <errno.h>
61+
#include <zephyr/posix/posix_types.h>
62+
#include <zephyr/posix/signal.h>
63+
#include <zephyr/sys/clock.h>
64+
65+
#ifdef __cplusplus
66+
extern "C" {
67+
#endif
68+
69+
#ifndef CLOCK_REALTIME
70+
#define CLOCK_REALTIME SYS_CLOCK_REALTIME
71+
#endif
72+
73+
#ifndef CLOCK_PROCESS_CPUTIME_ID
74+
#define CLOCK_PROCESS_CPUTIME_ID 2
75+
#endif
76+
77+
#ifndef CLOCK_THREAD_CPUTIME_ID
78+
#define CLOCK_THREAD_CPUTIME_ID 3
79+
#endif
80+
81+
#ifndef CLOCK_MONOTONIC
82+
#define CLOCK_MONOTONIC SYS_CLOCK_MONOTONIC
83+
#endif
84+
85+
#ifndef TIMER_ABSTIME
86+
#define TIMER_ABSTIME SYS_TIMER_ABSTIME
87+
#endif
88+
89+
int clock_gettime(clockid_t clock_id, struct timespec *ts);
90+
int clock_getres(clockid_t clock_id, struct timespec *ts);
91+
int clock_settime(clockid_t clock_id, const struct timespec *ts);
92+
int clock_getcpuclockid(pid_t pid, clockid_t *clock_id);
93+
/* Timer APIs */
94+
int timer_create(clockid_t clockId, struct sigevent *evp, timer_t *timerid);
95+
int timer_delete(timer_t timerid);
96+
struct itimerspec;
97+
int timer_gettime(timer_t timerid, struct itimerspec *its);
98+
int timer_settime(timer_t timerid, int flags, const struct itimerspec *value,
99+
struct itimerspec *ovalue);
100+
int timer_getoverrun(timer_t timerid);
101+
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
102+
int clock_nanosleep(clockid_t clock_id, int flags,
103+
const struct timespec *rqtp, struct timespec *rmtp);
104+
105+
#ifdef __cplusplus
106+
}
107+
#endif
108+
109+
#else /* ZEPHYR_INCLUDE_POSIX_TIME_H_ */
110+
/* Read the toolchain header when <posix/time.h> finds itself on the
111+
* first attempt.
112+
*/
113+
#include_next <time.h>
114+
#endif /* ZEPHYR_INCLUDE_POSIX_TIME_H_ */

include/zephyr/posix/unistd.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#ifndef ZEPHYR_INCLUDE_POSIX_UNISTD_H_
77
#define ZEPHYR_INCLUDE_POSIX_UNISTD_H_
88

9-
#include <time.h>
10-
119
#include <zephyr/posix/posix_types.h>
1210

1311
#ifdef CONFIG_POSIX_API

0 commit comments

Comments
 (0)