]> Git Repo - buildroot-mgba.git/blob - package/zeromq/0001-src-compat.hpp-fix-build-with-libbsd-and-strlcpy.patch
package/zeromq: add libbsd optional dependency
[buildroot-mgba.git] / package / zeromq / 0001-src-compat.hpp-fix-build-with-libbsd-and-strlcpy.patch
1 From 8cb5708829df9eacd58e1215ce7a1c135eb912b1 Mon Sep 17 00:00:00 2001
2 From: Fabrice Fontaine <[email protected]>
3 Date: Mon, 2 Nov 2020 00:04:14 +0100
4 Subject: [PATCH] src/compat.hpp: fix build with libbsd and strlcpy
5
6 Don't include bsd/string.h if strlcpy is also defined in string.h to
7 avoid the following build failure on uclibc:
8
9 In file included from src/compat.hpp:41:0,
10                  from src/ipc_address.cpp:31:
11 /tmp/instance-0/output-1/host/mips64el-buildroot-linux-uclibc/sysroot/usr/include/bsd/string.h:44:54: error: declaration of 'size_t strlcpy(char*, const char*, size_t)' has a different exception specifier
12  size_t strlcpy(char *dst, const char *src, size_t siz);
13                                                       ^
14 In file included from src/compat.hpp:34:0,
15                  from src/ipc_address.cpp:31:
16 /tmp/instance-0/output-1/host/mips64el-buildroot-linux-uclibc/sysroot/usr/include/string.h:424:15: error: from previous declaration 'size_t strlcpy(char*, const char*, size_t) throw ()'
17  extern size_t strlcpy(char *__restrict dst, const char *__restrict src,
18                ^
19
20 Fixes:
21  - http://autobuild.buildroot.org/results/51220b1b82774e8f6f6ed8593c58d2e3c31a1531
22
23 Signed-off-by: Fabrice Fontaine <[email protected]>
24 [Retrieved from:
25 https://github.com/zeromq/libzmq/commit/b2a0842063aaa464ca2d182f9d3fefc6493906d0]
26 ---
27  CMakeLists.txt |  4 +---
28  configure.ac   | 26 ++++++++++++--------------
29  src/compat.hpp |  4 +++-
30  3 files changed, 16 insertions(+), 18 deletions(-)
31
32 diff --git a/CMakeLists.txt b/CMakeLists.txt
33 index 85747f626..74dd99ae0 100644
34 --- a/CMakeLists.txt
35 +++ b/CMakeLists.txt
36 @@ -250,9 +250,7 @@ if(NOT MSVC)
37        set(ZMQ_HAVE_LIBBSD 1)
38      endif()
39    endif()
40 -  if(NOT WITH_LIBBSD OR NOT LIBBSD_FOUND)
41 -    check_cxx_symbol_exists(strlcpy string.h ZMQ_HAVE_STRLCPY)
42 -  endif()
43 +  check_cxx_symbol_exists(strlcpy string.h ZMQ_HAVE_STRLCPY)
44  endif()
45  
46  # Select curve encryption library, defaults to tweetnacl To use libsodium instead, use --with-libsodium(must be
47 diff --git a/configure.ac b/configure.ac
48 index 58a78e75e..a7a1609af 100644
49 --- a/configure.ac
50 +++ b/configure.ac
51 @@ -812,20 +812,18 @@ if test "x$enable_libbsd" != "xno"; then
52              fi
53          ])
54  fi
55 -if test "x$found_libbsd" != "xyes"; then
56 -    AC_MSG_CHECKING([whether strlcpy is available])
57 -    AC_COMPILE_IFELSE(
58 -        [AC_LANG_PROGRAM(
59 -            [[#include <string.h>]],
60 -            [[char buf [100]; size_t bar = strlcpy (buf, "foo", 100); (void)bar; return 0;]])
61 -        ],[
62 -            AC_MSG_RESULT([yes])
63 -            AC_DEFINE(ZMQ_HAVE_STRLCPY, [1],
64 -                [strlcpy is available])
65 -        ],[
66 -            AC_MSG_RESULT([no])
67 -    ])
68 -fi
69 +AC_MSG_CHECKING([whether strlcpy is available])
70 +AC_COMPILE_IFELSE(
71 +    [AC_LANG_PROGRAM(
72 +        [[#include <string.h>]],
73 +        [[char buf [100]; size_t bar = strlcpy (buf, "foo", 100); (void)bar; return 0;]])
74 +    ],[
75 +        AC_MSG_RESULT([yes])
76 +        AC_DEFINE(ZMQ_HAVE_STRLCPY, [1],
77 +            [strlcpy is available])
78 +    ],[
79 +        AC_MSG_RESULT([no])
80 +])
81  
82  # pthread_setname is non-posix, and there are at least 4 different implementations
83  AC_MSG_CHECKING([whether signature of pthread_setname_np() has 1 argument])
84 diff --git a/src/compat.hpp b/src/compat.hpp
85 index 7c7a89275..47744b98e 100644
86 --- a/src/compat.hpp
87 +++ b/src/compat.hpp
88 @@ -37,9 +37,10 @@
89  #define strcasecmp _stricmp
90  #define strtok_r strtok_s
91  #else
92 +#ifndef ZMQ_HAVE_STRLCPY
93  #ifdef ZMQ_HAVE_LIBBSD
94  #include <bsd/string.h>
95 -#elif !defined(ZMQ_HAVE_STRLCPY)
96 +#else
97  static inline size_t
98  strlcpy (char *dest_, const char *src_, const size_t dest_size_)
99  {
100 @@ -50,6 +51,7 @@ strlcpy (char *dest_, const char *src_, const size_t dest_size_)
101      return dest_size_ - remain;
102  }
103  #endif
104 +#endif
105  template <size_t size>
106  static inline int strcpy_s (char (&dest_)[size], const char *const src_)
107  {
This page took 0.03601 seconds and 4 git commands to generate.