Skip to content

Commit e8326cf

Browse files
committed
libstdc++-v3: include zephyr bits to support cross-compilation
This change adds a zephyr-bits.h header file which includes the basic definitions required to support ISO C++ thread, mutex, condition variables, and more via POSIX. For additional details see libgcc/gthr-posix.h . Note: this header should not be exported; it is solely for the purpose of enabling C++ threads in the Zephyr SDK when building against newlib or picolibc. Signed-off-by: Chris Friedt <[email protected]>
1 parent 2633d31 commit e8326cf

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

libstdc++-v3/configure.ac

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ else
5858
GLIBCXX_IS_NATIVE=true
5959
fi
6060

61+
case ${target} in
62+
*zephyr*)
63+
CXXFLAGS="$CXXFLAGS -include ${abs_top_srcdir}/include/bits/zephyr-bits.h"
64+
;;
65+
esac
66+
6167
# Sets up automake. Must come after AC_CANONICAL_SYSTEM. Each of the
6268
# following is magically included in AUTOMAKE_OPTIONS in each Makefile.am.
6369
# 1.x: minimum required version
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#ifndef GCC_LIBSTDCXX_V3_INCLUDE_BITS_ZEPHYR_BITS_H_
2+
#define GCC_LIBSTDCXX_V3_INCLUDE_BITS_ZEPHYR_BITS_H_
3+
4+
#define _POSIX_THREADS 200809L
5+
#define _POSIX_TIMERS 200809L
6+
#define _POSIX_MONOTONIC_CLOCK 200809L
7+
#define _UNIX98_THREAD_MUTEX_ATTRIBUTES 1
8+
9+
#define _PTHREAD_MUTEX_INITIALIZER (-1)
10+
#define _PTHREAD_COND_INITIALIZER (-1)
11+
#define _PTHREAD_ONCE_INIT {1,0}
12+
13+
#endif /* GCC_LIBSTDCXX_V3_INCLUDE_BITS_ZEPHYR_BITS_H_ */

0 commit comments

Comments
 (0)