Sfoglia il codice sorgente

Check for strnlen and provide it if it is not found.

tags/v0.15.1
Pavel Janík 7 anni fa
parent
commit
494f6e7d35
4 ha cambiato i file con 25 aggiunte e 0 eliminazioni
  1. 2
    0
      configure.ac
  2. 1
    0
      src/Makefile.am
  3. 4
    0
      src/compat.h
  4. 18
    0
      src/compat/strnlen.cpp

+ 2
- 0
configure.ac Vedi File

@@ -421,6 +421,8 @@ AC_CHECK_HEADERS([endian.h stdio.h stdlib.h unistd.h strings.h sys/types.h sys/s
AC_SEARCH_LIBS([getaddrinfo_a], [anl], [AC_DEFINE(HAVE_GETADDRINFO_A, 1, [Define this symbol if you have getaddrinfo_a])])
AC_SEARCH_LIBS([inet_pton], [nsl resolv], [AC_DEFINE(HAVE_INET_PTON, 1, [Define this symbol if you have inet_pton])])

AC_CHECK_DECLS([strnlen])

AC_CHECK_DECLS([le32toh, le64toh, htole32, htole64, be32toh, be64toh, htobe32, htobe64],,,
[#if HAVE_ENDIAN_H
#include <endian.h>

+ 1
- 0
src/Makefile.am Vedi File

@@ -251,6 +251,7 @@ libbitcoin_common_a_SOURCES = \
# backward-compatibility objects and their sanity checks are linked.
libbitcoin_util_a_CPPFLAGS = $(BITCOIN_INCLUDES)
libbitcoin_util_a_SOURCES = \
compat/strnlen.cpp \
compat/glibc_sanity.cpp \
compat/glibcxx_sanity.cpp \
chainparamsbase.cpp \

+ 4
- 0
src/compat.h Vedi File

@@ -84,4 +84,8 @@ typedef u_int SOCKET;
#define THREAD_PRIORITY_ABOVE_NORMAL (-2)
#endif

#if HAVE_DECL_STRNLEN == 0
size_t strnlen( const char *start, size_t max_len);
#endif // HAVE_DECL_STRNLEN

#endif // BITCOIN_COMPAT_H

+ 18
- 0
src/compat/strnlen.cpp Vedi File

@@ -0,0 +1,18 @@
// Copyright (c) 2009-2014 The Bitcoin developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#if defined(HAVE_CONFIG_H)
#include "config/bitcoin-config.h"
#endif

#include <cstring>

#if HAVE_DECL_STRNLEN == 0
size_t strnlen( const char *start, size_t max_len)
{
const char *end = (const char *)memchr(start, '\0', max_len);

return end ? (size_t)(end - start) : max_len;
}
#endif // HAVE_DECL_STRNLEN

Loading…
Annulla
Salva