aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt1
-rw-r--r--cmake/OSDep.cmake2
-rw-r--r--config.h.in1
-rw-r--r--src/libutil/str_util.c9
-rw-r--r--src/libutil/str_util.h6
5 files changed, 14 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0af33f1fe..b794b9dbd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -345,6 +345,7 @@ CHECK_SYMBOL_EXISTS(getaddrinfo "sys/types.h;sys/socket.h;netdb.h" HAVE_GETADDRI
CHECK_SYMBOL_EXISTS(sched_yield "sched.h" HAVE_SCHED_YIELD)
CHECK_SYMBOL_EXISTS(__get_cpuid "cpuid.h" HAVE_GET_CPUID)
CHECK_SYMBOL_EXISTS(nftw "sys/types.h;ftw.h" HAVE_NFTW)
+CHECK_SYMBOL_EXISTS(memrchr "string.h" HAVE_MEMRCHR)
IF(ENABLE_PCRE2 MATCHES "ON")
LIST(APPEND CMAKE_REQUIRED_INCLUDES "${PCRE_INCLUDE}")
CHECK_SYMBOL_EXISTS(PCRE2_CONFIG_JIT "pcre2.h" HAVE_PCRE_JIT)
diff --git a/cmake/OSDep.cmake b/cmake/OSDep.cmake
index a48f9d17b..ce90ebb02 100644
--- a/cmake/OSDep.cmake
+++ b/cmake/OSDep.cmake
@@ -1,6 +1,7 @@
# Platform specific configuration
IF(CMAKE_SYSTEM_NAME MATCHES "^.*BSD$|DragonFly")
ADD_COMPILE_OPTIONS(-DFREEBSD -D_BSD_SOURCE)
+ SET(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_BSD_SOURCE")
CONFIGURE_FILE(freebsd/rspamd.sh.in freebsd/rspamd @ONLY)
MESSAGE(STATUS "Configuring for BSD system")
# Find util library
@@ -32,6 +33,7 @@ ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
ADD_COMPILE_OPTIONS(-D_GNU_SOURCE -DLINUX)
+ SET(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_GNU_SOURCE")
# Workaround with architecture specific includes
#IF(IS_DIRECTORY "/usr/include/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/")
# INCLUDE_DIRECTORIES("/usr/include/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/")
diff --git a/config.h.in b/config.h.in
index b4e16ead9..85a1fe829 100644
--- a/config.h.in
+++ b/config.h.in
@@ -52,6 +52,7 @@
#cmakedefine HAVE_MACHINE_ENDIAN_H 1
#cmakedefine HAVE_MAXPATHLEN 1
#cmakedefine HAVE_FMEMOPEN 1
+#cmakedefine HAVE_MEMRCHR 1
#cmakedefine HAVE_MEMSET_S 1
#cmakedefine HAVE_MKSTEMP 1
#cmakedefine HAVE_MMAP_ANON 1
diff --git a/src/libutil/str_util.c b/src/libutil/str_util.c
index c503396a2..88f757659 100644
--- a/src/libutil/str_util.c
+++ b/src/libutil/str_util.c
@@ -2898,20 +2898,21 @@ rspamd_ucl_emit_fstring_comments (const ucl_object_t *obj,
ucl_object_emit_full (obj, emit_type, &func, comments);
}
-const void *
+#ifndef HAVE_MEMRCHR
+void *
rspamd_memrchr (const void *m, gint c, gsize len)
{
const guint8 *p = m;
- gsize i;
- for (i = len; i > 0; i --) {
+ for (gsize i = len; i > 0; i --) {
if (p[i - 1] == c) {
- return p + i - 1;
+ return (void *)(p + i - 1);
}
}
return NULL;
}
+#endif
struct UConverter *
rspamd_get_utf8_converter (void)
diff --git a/src/libutil/str_util.h b/src/libutil/str_util.h
index f6c2a1389..bc7b4f4b5 100644
--- a/src/libutil/str_util.h
+++ b/src/libutil/str_util.h
@@ -429,7 +429,11 @@ extern const guchar lc_map[256];
* @param len
* @return pointer to the last occurrence or NULL
*/
-const void *rspamd_memrchr (const void *m, gint c, gsize len);
+#ifdef HAVE_MEMRCHR
+#define rspamd_memrchr memrchr
+#else
+void *rspamd_memrchr (const void *m, gint c, gsize len);
+#endif
/**
* Return length of memory segment starting in `s` that contains no chars from `e`