Skip to content

Commit abc94b8

Browse files
youvedeep-singhAnas Nashif
authored andcommitted
kernel: POSIX: moving POSIX related typedef into sys/types.h file.
As per POSIX standard typedef should be part of sys/types.h file. So moving typedef from pthread.h to sys/types.h file. Signed-off-by: Youvedeep Singh <[email protected]>
1 parent 325abfb commit abc94b8

File tree

2 files changed

+58
-27
lines changed

2 files changed

+58
-27
lines changed

include/posix/pthread.h

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,15 @@ struct timespec {
1717
s32_t tv_sec;
1818
s32_t tv_nsec;
1919
};
20-
#endif
20+
#endif /* CONFIG_NEWLIB_LIBC */
21+
22+
#include "sys/types.h"
2123

2224
static inline s32_t _ts_to_ms(const struct timespec *to)
2325
{
2426
return (to->tv_sec * 1000) + (to->tv_nsec / 1000000);
2527
}
2628

27-
typedef struct pthread_mutex {
28-
struct k_sem *sem;
29-
} pthread_mutex_t;
30-
31-
typedef struct pthread_mutexattr {
32-
int unused;
33-
} pthread_mutexattr_t;
34-
35-
typedef struct pthread_cond {
36-
_wait_q_t wait_q;
37-
} pthread_cond_t;
38-
39-
typedef struct pthread_condattr {
40-
int unused;
41-
} pthread_condattr_t;
42-
4329
/**
4430
* @brief Declare a pthread condition variable
4531
*
@@ -260,16 +246,6 @@ static inline int pthread_mutexattr_destroy(pthread_mutexattr_t *m)
260246
/* #define PTHREAD_MUTEX_INITIALIZER */
261247
/* #define PTHREAD_COND_INITIALIZER */
262248

263-
typedef struct pthread_barrier {
264-
_wait_q_t wait_q;
265-
int max;
266-
int count;
267-
} pthread_barrier_t;
268-
269-
typedef struct pthread_barrierattr {
270-
int unused;
271-
} pthread_barrierattr_t;
272-
273249
/**
274250
* @brief Declare a pthread barrier
275251
*

include/posix/sys/types.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (c) 2018 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef __POSIX_TYPES_H__
8+
#define __POSIX_TYPES_H__
9+
10+
11+
#ifdef __cplusplus
12+
extern "C" {
13+
#endif
14+
15+
#ifdef CONFIG_NEWLIB_LIBC
16+
#include_next <sys/types.h>
17+
#endif /* CONFIG_NEWLIB_LIBC */
18+
19+
#ifdef CONFIG_PTHREAD_IPC
20+
/* Mutex */
21+
typedef struct pthread_mutex {
22+
struct k_sem *sem;
23+
} pthread_mutex_t;
24+
25+
typedef struct pthread_mutexattr {
26+
int unused;
27+
} pthread_mutexattr_t;
28+
29+
/* Confition Variables */
30+
typedef struct pthread_cond {
31+
_wait_q_t wait_q;
32+
} pthread_cond_t;
33+
34+
typedef struct pthread_condattr {
35+
int unused;
36+
} pthread_condattr_t;
37+
38+
/* Barrier */
39+
typedef struct pthread_barrier {
40+
_wait_q_t wait_q;
41+
int max;
42+
int count;
43+
} pthread_barrier_t;
44+
45+
typedef struct pthread_barrierattr {
46+
int unused;
47+
} pthread_barrierattr_t;
48+
49+
#endif /* CONFIG_PTHREAD_IPC */
50+
51+
#ifdef __cplusplus
52+
}
53+
#endif
54+
55+
#endif /* __POSIX_TYPES_H__ */

0 commit comments

Comments
 (0)