diff options
author | thegeorg <thegeorg@yandex-team.com> | 2022-07-22 10:26:06 +0300 |
---|---|---|
committer | thegeorg <thegeorg@yandex-team.com> | 2022-07-22 10:26:06 +0300 |
commit | 6b275e9a993167b6c66418e4bcf1b7f557d011e5 (patch) | |
tree | b5f392fe9468be17c0363d900c289a64ee50693d /contrib/libs | |
parent | c178dc74ea9d590af4bd804d76bec5db47ddcb33 (diff) | |
download | ydb-6b275e9a993167b6c66418e4bcf1b7f557d011e5.tar.gz |
libc_compat: Utilize #include_next to avoid contrib patching
Diffstat (limited to 'contrib/libs')
-rw-r--r-- | contrib/libs/libc_compat/CMakeLists.darwin.txt | 5 | ||||
-rw-r--r-- | contrib/libs/libc_compat/CMakeLists.linux.txt | 3 | ||||
-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.h | 20 |
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 |