Skip to content

Commit 82ed3f5

Browse files
committed
lib: libc: arcmwdt: update headers for posix compatibility
Additional workarounds for POSIX compatibility with the arcmwdt toolchain. This commit addresses issues described in the comment linked below. https://github.com/zephyrproject-rtos/zephyr/pull/97152#\ issuecomment-3409956230 Signed-off-by: Chris Friedt <[email protected]>
1 parent bb725b9 commit 82ed3f5

File tree

11 files changed

+178
-0
lines changed

11 files changed

+178
-0
lines changed

lib/libc/arcmwdt/include/aio.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright The Zephyr Project Contributors
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_AIO_H_
8+
#define ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_AIO_H_
9+
10+
#include <zephyr/posix/aio.h>
11+
12+
#endif /* ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_AIO_H_ */
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright The Zephyr Project Contributors
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_ARPA_INET_H_
8+
#define ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_ARPA_INET_H_
9+
10+
#include <zephyr/posix/arpa/inet.h>
11+
12+
#endif /* ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_ARPA_INET_H_ */

lib/libc/arcmwdt/include/net/if.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright The Zephyr Project Contributors
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_NET_IF_H_
8+
#define ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_NET_IF_H_
9+
10+
#include <zephyr/posix/net/if.h>
11+
12+
#endif /* ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_NET_IF_H_ */
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright The Zephyr Project Contributors
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_IF_ARP_H_
8+
#define ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_IF_ARP_H_
9+
10+
#include <zephyr/posix/net/if_arp.h>
11+
12+
#endif /* ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_IF_ARP_H_ */
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright The Zephyr Project Contributors
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_NETINET_IN_H_
8+
#define ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_NETINET_IN_H_
9+
10+
#include <zephyr/posix/netinet/in.h>
11+
12+
#endif /* ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_NETINET_IN_H_ */
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright The Zephyr Project Contributors
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_NETINET_TCP_H_
8+
#define ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_NETINET_TCP_H_
9+
10+
#include <zephyr/posix/netinet/tcp.h>
11+
12+
#endif /* ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_NETINET_TCP_H_ */

lib/libc/arcmwdt/include/pthread.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright The Zephyr Project Contributors
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_PTHREAD_H_
8+
#define ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_PTHREAD_H_
9+
10+
#if defined(_POSIX_THREADS)
11+
#undef __dead2
12+
#define __dead2
13+
14+
#include_next <pthread.h>
15+
16+
#define _PTHREAD_ATTR_T_DECLARED
17+
18+
#undef PTHREAD_ONCE_INIT
19+
#define PTHREAD_ONCE_INIT \
20+
{ \
21+
0 \
22+
}
23+
24+
/* The minimum allowable stack size */
25+
#define PTHREAD_STACK_MIN K_KERNEL_STACK_LEN(0)
26+
27+
void __z_pthread_cleanup_push(void *cleanup[3], void (*routine)(void *arg), void *arg);
28+
void __z_pthread_cleanup_pop(int execute);
29+
30+
#undef pthread_cleanup_push
31+
#define pthread_cleanup_push(_rtn, _arg) \
32+
do /* enforce '{'-like behaviour */ { \
33+
void *_z_pthread_cleanup[3]; \
34+
__z_pthread_cleanup_push(_z_pthread_cleanup, _rtn, _arg)
35+
36+
#undef pthread_cleanup_pop
37+
#define pthread_cleanup_pop(_ex) \
38+
__z_pthread_cleanup_pop(_ex); \
39+
} /* enforce '}'-like behaviour */ \
40+
while (0)
41+
42+
#endif
43+
44+
#endif /* ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_PTHREAD_H_ */

lib/libc/arcmwdt/include/sys/types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define _NLINK_T_DECLARED
1818
#define _UID_T_DECLARED
1919
#define _GID_T_DECLARED
20+
#define _PID_T_DECLARED
2021

2122
#ifndef _SSIZE_T_DEFINED
2223
#define _SSIZE_T_DEFINED

lib/libc/arcmwdt/include/time.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,24 @@
99

1010
#include_next <time.h>
1111

12+
#if defined(_POSIX_C_SOURCE)
13+
/*
14+
* POSIX requires time.h to define pid_t and clockid_t
15+
* https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/time.h.html
16+
*/
17+
#if !defined(_PID_T_DECLARED)
18+
typedef long pid_t;
19+
#define _PID_T_DECLARED
20+
#endif
21+
22+
#if !defined(_CLOCKID_T_DECLARED)
23+
typedef int clockid_t;
24+
#define _CLOCKID_T_DECLARED
25+
#endif
26+
#endif
27+
28+
#define _TIMESPEC_DECLARED
29+
1230
#include <zephyr/posix/posix_time.h>
1331

1432
#ifdef __cplusplus

lib/libc/arcmwdt/include/unistd.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright The Zephyr Project Contributors
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_UNISTD_H_
8+
#define ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_UNISTD_H_
9+
10+
#include_next <unistd.h>
11+
12+
#ifdef __cplusplus
13+
extern "C" {
14+
#endif
15+
16+
int getentropy(void *buffer, size_t length);
17+
18+
#if _POSIX_C_SOURCE >= 2
19+
#include <zephyr/posix/sys/confstr.h>
20+
#endif
21+
22+
/* Note: usleep() was declared obsolescent as of POSIX.1-2001 and removed from POSIX.1-2008 */
23+
int usleep(__useconds_t __useconds);
24+
25+
#ifdef __cplusplus
26+
}
27+
#endif
28+
29+
#endif /* ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_UNISTD_H_ */

0 commit comments

Comments
 (0)