Skip to content

Commit 64854d1

Browse files
committed
posix: limits: de-duplicate limit logic
Rather than duplicating limit logic in several places, de-duplicate it and centralize preprocessor checks in posix_limits.h . Signed-off-by: Chris Friedt <[email protected]>
1 parent f5cc5d8 commit 64854d1

File tree

4 files changed

+8
-43
lines changed

4 files changed

+8
-43
lines changed

include/zephyr/posix/posix_limits.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#ifndef ZEPHYR_INCLUDE_ZEPHYR_POSIX_POSIX_LIMITS_H_
88
#define ZEPHYR_INCLUDE_ZEPHYR_POSIX_POSIX_LIMITS_H_
99

10+
#if defined(_POSIX_C_SOURCE) || defined(__DOXYGEN__)
11+
1012
/*
1113
* clang-format and checkpatch disagree on formatting here, so rely on checkpatch and disable
1214
* clang-format since checkpatch cannot be selectively disabled.
@@ -122,4 +124,6 @@
122124

123125
/* clang-format on */
124126

127+
#endif
128+
125129
#endif /* ZEPHYR_INCLUDE_ZEPHYR_POSIX_POSIX_LIMITS_H_ */

lib/libc/arcmwdt/include/limits.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,10 @@
88
#define LIB_LIBC_ARCMWDT_INCLUDE_LIMITS_H_
99

1010
#include_next <limits.h>
11-
12-
#ifdef __cplusplus
13-
extern "C" {
14-
#endif
15-
16-
#if defined(_POSIX_C_SOURCE) || defined(__DOXYGEN__)
17-
1811
#include <zephyr/posix/posix_limits.h>
1912

20-
#else
21-
13+
#ifndef PATH_MAX
2214
#define PATH_MAX 256
23-
24-
#endif
25-
26-
#ifdef __cplusplus
27-
}
2815
#endif
2916

30-
#endif /* ZEPHYR_LIB_LIBC_ARMSTDC_INCLUDE_LIMITS_H_ */
17+
#endif /* LIB_LIBC_ARCMWDT_INCLUDE_LIMITS_H_ */

lib/libc/armstdc/include/limits.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,10 @@
88
#define ZEPHYR_LIB_LIBC_ARMSTDC_INCLUDE_LIMITS_H_
99

1010
#include_next <limits.h>
11-
12-
#ifdef __cplusplus
13-
extern "C" {
14-
#endif
15-
16-
#if defined(_POSIX_C_SOURCE) || defined(__DOXYGEN__)
17-
1811
#include <zephyr/posix/posix_limits.h>
1912

20-
#else
21-
13+
#ifndef PATH_MAX
2214
#define PATH_MAX 256
23-
24-
#endif
25-
26-
#ifdef __cplusplus
27-
}
2815
#endif
2916

3017
#endif /* ZEPHYR_LIB_LIBC_ARMSTDC_INCLUDE_LIMITS_H_ */

lib/libc/iar/include/limits.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,10 @@
88
#define ZEPHYR_LIB_LIBC_IAR_INCLUDE_LIMITS_H_
99

1010
#include_next <limits.h>
11-
12-
#ifdef __cplusplus
13-
extern "C" {
14-
#endif
15-
16-
#if defined(_POSIX_C_SOURCE) || defined(__DOXYGEN__)
17-
1811
#include <zephyr/posix/posix_limits.h>
1912

20-
#else
21-
13+
#ifndef PATH_MAX
2214
#define PATH_MAX 256
23-
24-
#endif
25-
26-
#ifdef __cplusplus
27-
}
2815
#endif
2916

3017
#endif /* ZEPHYR_LIB_LIBC_IAR_INCLUDE_LIMITS_H_ */

0 commit comments

Comments
 (0)