Skip to content

Commit 6e940c5

Browse files
Nikolay Agishevnashif
authored andcommitted
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 <[email protected]>
1 parent f8f8fa2 commit 6e940c5

File tree

6 files changed

+49
-5
lines changed

6 files changed

+49
-5
lines changed

include/zephyr/posix/posix_types.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ struct pthread_attr {
4747
int32_t detachstate;
4848
uint32_t initialized;
4949
};
50-
#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC)
50+
#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC) \
51+
|| defined(CONFIG_ARCMWDT_LIBC)
5152
typedef struct pthread_attr pthread_attr_t;
5253
#endif
54+
5355
BUILD_ASSERT(sizeof(pthread_attr_t) >= sizeof(struct pthread_attr));
5456

5557
typedef uint32_t pthread_t;
@@ -63,7 +65,8 @@ typedef uint32_t pthread_mutex_t;
6365
struct pthread_mutexattr {
6466
int type;
6567
};
66-
#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC)
68+
#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC) \
69+
|| defined(CONFIG_ARCMWDT_LIBC)
6770
typedef struct pthread_mutexattr pthread_mutexattr_t;
6871
#endif
6972
BUILD_ASSERT(sizeof(pthread_mutexattr_t) >= sizeof(struct pthread_mutexattr));
@@ -74,7 +77,8 @@ typedef uint32_t pthread_cond_t;
7477
struct pthread_condattr {
7578
};
7679

77-
#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC)
80+
#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC) \
81+
|| defined(CONFIG_ARCMWDT_LIBC)
7882
typedef struct pthread_condattr pthread_condattr_t;
7983
#endif
8084
BUILD_ASSERT(sizeof(pthread_condattr_t) >= sizeof(struct pthread_condattr));

include/zephyr/posix/pthread_key.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
extern "C" {
1414
#endif
1515

16+
#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC) \
17+
|| defined(CONFIG_ARCMWDT_LIBC)
18+
1619
#ifdef CONFIG_PTHREAD_IPC
1720

18-
#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC)
1921
typedef struct {
2022
int is_initialized;
2123
int init_executed;

include/zephyr/posix/sched.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ extern "C" {
2525
/* Priority based preemptive scheduling policy */
2626
#define SCHED_RR 2
2727

28-
#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC)
28+
#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC) \
29+
|| defined(CONFIG_ARCMWDT_LIBC)
2930
struct sched_param {
3031
int sched_priority;
3132
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* Copyright (c) 2023 Synopsys.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/* MWDT has no it's own cdefs. Add this one for satisfy dependencies */
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2023 Synopsys.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef LIB_LIBC_ARCMWDT_INCLUDE_SYS_TYPES_H_
8+
#define LIB_LIBC_ARCMWDT_INCLUDE_SYS_TYPES_H_
9+
10+
#include_next "sys/types.h"
11+
12+
#define _DEV_T_DECLARED
13+
#define _INO_T_DECLARED
14+
#define _NLINK_T_DECLARED
15+
#define _UID_T_DECLARED
16+
#define _GID_T_DECLARED
17+
18+
#endif /* LIB_LIBC_ARCMWDT_INCLUDE_SYS_TYPES_H_ */

lib/libc/arcmwdt/libc-hooks.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
1313
#include <unistd.h>
1414
#include <errno.h>
1515

16+
#ifndef STDIN_FILENO
17+
#define STDIN_FILENO 0
18+
#endif
19+
20+
#ifndef STDOUT_FILENO
21+
#define STDOUT_FILENO 1
22+
#endif
23+
24+
#ifndef STDERR_FILENO
25+
#define STDERR_FILENO 2
26+
#endif
27+
1628
static int _stdout_hook_default(int c)
1729
{
1830
ARG_UNUSED(c);

0 commit comments

Comments
 (0)