aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/libc_compat
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.com>2022-07-22 10:26:06 +0300
committerthegeorg <thegeorg@yandex-team.com>2022-07-22 10:26:06 +0300
commit6b275e9a993167b6c66418e4bcf1b7f557d011e5 (patch)
treeb5f392fe9468be17c0363d900c289a64ee50693d /contrib/libs/libc_compat
parentc178dc74ea9d590af4bd804d76bec5db47ddcb33 (diff)
downloadydb-6b275e9a993167b6c66418e4bcf1b7f557d011e5.tar.gz
libc_compat: Utilize #include_next to avoid contrib patching
Diffstat (limited to 'contrib/libs/libc_compat')
-rw-r--r--contrib/libs/libc_compat/CMakeLists.darwin.txt5
-rw-r--r--contrib/libs/libc_compat/CMakeLists.linux.txt3
-rw-r--r--contrib/libs/libc_compat/reallocarray/reallocarray.c (renamed from contrib/libs/libc_compat/reallocarray.c)0
-rw-r--r--contrib/libs/libc_compat/reallocarray/stdlib.h20
4 files changed, 26 insertions, 2 deletions
diff --git a/contrib/libs/libc_compat/CMakeLists.darwin.txt b/contrib/libs/libc_compat/CMakeLists.darwin.txt
index 896c352d25..092baa2cd3 100644
--- a/contrib/libs/libc_compat/CMakeLists.darwin.txt
+++ b/contrib/libs/libc_compat/CMakeLists.darwin.txt
@@ -11,9 +11,12 @@ add_library(contrib-libs-libc_compat)
target_compile_options(contrib-libs-libc_compat PRIVATE
-Wno-everything
)
+target_include_directories(contrib-libs-libc_compat PUBLIC
+ ${CMAKE_SOURCE_DIR}/contrib/libs/libc_compat/reallocarray
+)
target_sources(contrib-libs-libc_compat PRIVATE
${CMAKE_SOURCE_DIR}/contrib/libs/libc_compat/string.c
${CMAKE_SOURCE_DIR}/contrib/libs/libc_compat/memrchr.c
${CMAKE_SOURCE_DIR}/contrib/libs/libc_compat/explicit_bzero.c
- ${CMAKE_SOURCE_DIR}/contrib/libs/libc_compat/reallocarray.c
+ ${CMAKE_SOURCE_DIR}/contrib/libs/libc_compat/reallocarray/reallocarray.c
)
diff --git a/contrib/libs/libc_compat/CMakeLists.linux.txt b/contrib/libs/libc_compat/CMakeLists.linux.txt
index 745d623c48..a43ee74fe5 100644
--- a/contrib/libs/libc_compat/CMakeLists.linux.txt
+++ b/contrib/libs/libc_compat/CMakeLists.linux.txt
@@ -14,6 +14,7 @@ target_compile_options(contrib-libs-libc_compat PRIVATE
target_include_directories(contrib-libs-libc_compat PUBLIC
${CMAKE_SOURCE_DIR}/contrib/libs/libc_compat/include/readpassphrase
${CMAKE_SOURCE_DIR}/contrib/libs/libc_compat/include/random
+ ${CMAKE_SOURCE_DIR}/contrib/libs/libc_compat/reallocarray
)
target_sources(contrib-libs-libc_compat PRIVATE
${CMAKE_SOURCE_DIR}/contrib/libs/libc_compat/string.c
@@ -21,7 +22,7 @@ target_sources(contrib-libs-libc_compat PRIVATE
${CMAKE_SOURCE_DIR}/contrib/libs/libc_compat/explicit_bzero.c
${CMAKE_SOURCE_DIR}/contrib/libs/libc_compat/getrandom.c
${CMAKE_SOURCE_DIR}/contrib/libs/libc_compat/memfd_create.c
- ${CMAKE_SOURCE_DIR}/contrib/libs/libc_compat/reallocarray.c
${CMAKE_SOURCE_DIR}/contrib/libs/libc_compat/strlcat.c
${CMAKE_SOURCE_DIR}/contrib/libs/libc_compat/strlcpy.c
+ ${CMAKE_SOURCE_DIR}/contrib/libs/libc_compat/reallocarray/reallocarray.c
)
diff --git a/contrib/libs/libc_compat/reallocarray.c b/contrib/libs/libc_compat/reallocarray/reallocarray.c
index 21b0914fe4..21b0914fe4 100644
--- a/contrib/libs/libc_compat/reallocarray.c
+++ b/contrib/libs/libc_compat/reallocarray/reallocarray.c
diff --git a/contrib/libs/libc_compat/reallocarray/stdlib.h b/contrib/libs/libc_compat/reallocarray/stdlib.h
new file mode 100644
index 0000000000..4b27573a37
--- /dev/null
+++ b/contrib/libs/libc_compat/reallocarray/stdlib.h
@@ -0,0 +1,20 @@
+// The lack of #pragma once is intentional:
+// its presence breaks compilation of contrib/tools/unbound somehow.
+
+#if defined(__GNUC__) || defined(__clang__)
+ #include_next <stdlib.h>
+#else
+ #define Y_MSVC_INCLUDE_NEXT(x) <Y_UCRT_INCLUDE/x>
+ #include Y_MSVC_INCLUDE_NEXT(stdlib.h)
+ #undef Y_MSVC_INCLUDE_NEXT
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void* reallocarray(void*, size_t, size_t);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif