Skip to content

Commit cb9b1a0

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 058a465 commit cb9b1a0

File tree

5 files changed

+68
-0
lines changed

5 files changed

+68
-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/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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@
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+
/* pull in sys/timespec.h for struct timespec and _TIMESPEC_DECLARED */
29+
#include "sys/timespec.h"
30+
1231
#include <zephyr/posix/posix_time.h>
1332

1433
#ifdef __cplusplus

lib/libc/arcmwdt/include/unistd.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
#if defined(_XOPEN_SOURCE)
17+
long gethostid(void);
18+
#endif
19+
20+
#ifdef __cplusplus
21+
}
22+
#endif
23+
24+
#endif /* ZEPHYR_LIB_LIBC_ARCMWDT_INCLUDE_UNISTD_H_ */

0 commit comments

Comments
 (0)