From 6e940c513cb665a70fb57c2dd409d0bbdba734f2 Mon Sep 17 00:00:00 2001 From: Nikolay Agishev Date: Wed, 7 Jun 2023 15:02:39 +0400 Subject: [PATCH] ARC: Fix portability.posix.common.arcmwdtlib test portability.posix.common.arcmwdtlib test fails with ARCMWDT libc. This path fixes the test. STDIN_FILENO and others macroses are used in libc-hooks.c only. So they defined localy. Signed-off-by: Nikolay Agishev --- include/zephyr/posix/posix_types.h | 10 +++++++--- include/zephyr/posix/pthread_key.h | 4 +++- include/zephyr/posix/sched.h | 3 ++- lib/libc/arcmwdt/include/sys/cdefs.h | 7 +++++++ lib/libc/arcmwdt/include/sys/types.h | 18 ++++++++++++++++++ lib/libc/arcmwdt/libc-hooks.c | 12 ++++++++++++ 6 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 lib/libc/arcmwdt/include/sys/cdefs.h create mode 100644 lib/libc/arcmwdt/include/sys/types.h diff --git a/include/zephyr/posix/posix_types.h b/include/zephyr/posix/posix_types.h index d34102a06de..511697cfab9 100644 --- a/include/zephyr/posix/posix_types.h +++ b/include/zephyr/posix/posix_types.h @@ -47,9 +47,11 @@ struct pthread_attr { int32_t detachstate; uint32_t initialized; }; -#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC) +#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC) \ + || defined(CONFIG_ARCMWDT_LIBC) typedef struct pthread_attr pthread_attr_t; #endif + BUILD_ASSERT(sizeof(pthread_attr_t) >= sizeof(struct pthread_attr)); typedef uint32_t pthread_t; @@ -63,7 +65,8 @@ typedef uint32_t pthread_mutex_t; struct pthread_mutexattr { int type; }; -#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC) +#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC) \ + || defined(CONFIG_ARCMWDT_LIBC) typedef struct pthread_mutexattr pthread_mutexattr_t; #endif BUILD_ASSERT(sizeof(pthread_mutexattr_t) >= sizeof(struct pthread_mutexattr)); @@ -74,7 +77,8 @@ typedef uint32_t pthread_cond_t; struct pthread_condattr { }; -#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC) +#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC) \ + || defined(CONFIG_ARCMWDT_LIBC) typedef struct pthread_condattr pthread_condattr_t; #endif BUILD_ASSERT(sizeof(pthread_condattr_t) >= sizeof(struct pthread_condattr)); diff --git a/include/zephyr/posix/pthread_key.h b/include/zephyr/posix/pthread_key.h index 025f29c6d33..6b89c8f9818 100644 --- a/include/zephyr/posix/pthread_key.h +++ b/include/zephyr/posix/pthread_key.h @@ -13,9 +13,11 @@ extern "C" { #endif +#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC) \ + || defined(CONFIG_ARCMWDT_LIBC) + #ifdef CONFIG_PTHREAD_IPC -#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC) typedef struct { int is_initialized; int init_executed; diff --git a/include/zephyr/posix/sched.h b/include/zephyr/posix/sched.h index 6a376fb4958..10cfc666c66 100644 --- a/include/zephyr/posix/sched.h +++ b/include/zephyr/posix/sched.h @@ -25,7 +25,8 @@ extern "C" { /* Priority based preemptive scheduling policy */ #define SCHED_RR 2 -#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC) +#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC) \ + || defined(CONFIG_ARCMWDT_LIBC) struct sched_param { int sched_priority; }; diff --git a/lib/libc/arcmwdt/include/sys/cdefs.h b/lib/libc/arcmwdt/include/sys/cdefs.h new file mode 100644 index 00000000000..ff8eecfb1c1 --- /dev/null +++ b/lib/libc/arcmwdt/include/sys/cdefs.h @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2023 Synopsys. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* MWDT has no it's own cdefs. Add this one for satisfy dependencies */ diff --git a/lib/libc/arcmwdt/include/sys/types.h b/lib/libc/arcmwdt/include/sys/types.h new file mode 100644 index 00000000000..1024f22834c --- /dev/null +++ b/lib/libc/arcmwdt/include/sys/types.h @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2023 Synopsys. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef LIB_LIBC_ARCMWDT_INCLUDE_SYS_TYPES_H_ +#define LIB_LIBC_ARCMWDT_INCLUDE_SYS_TYPES_H_ + +#include_next "sys/types.h" + +#define _DEV_T_DECLARED +#define _INO_T_DECLARED +#define _NLINK_T_DECLARED +#define _UID_T_DECLARED +#define _GID_T_DECLARED + +#endif /* LIB_LIBC_ARCMWDT_INCLUDE_SYS_TYPES_H_ */ diff --git a/lib/libc/arcmwdt/libc-hooks.c b/lib/libc/arcmwdt/libc-hooks.c index 1ffb607dfe7..b7ee5f90a81 100644 --- a/lib/libc/arcmwdt/libc-hooks.c +++ b/lib/libc/arcmwdt/libc-hooks.c @@ -13,6 +13,18 @@ #include #include +#ifndef STDIN_FILENO + #define STDIN_FILENO 0 +#endif + +#ifndef STDOUT_FILENO + #define STDOUT_FILENO 1 +#endif + +#ifndef STDERR_FILENO + #define STDERR_FILENO 2 +#endif + static int _stdout_hook_default(int c) { ARG_UNUSED(c);