这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ check_function_exists(strerror HAVE_STRERROR)
if(NOT HAVE_STRERROR)
add_definitions(-DNO_STRERROR)
endif()
set(CMAKE_REQUIRED_DEFINITIONS -D _POSIX_C_SOURCE=200112L)
check_function_exists(posix_memalign HAVE_POSIX_MEMALIGN)
if(HAVE_POSIX_MEMALIGN)
add_definitions(-DHAVE_POSIX_MEMALIGN)
endif()
set(CMAKE_REQUIRED_DEFINITIONS)

if(WITH_SANITIZER STREQUAL "Address")
add_address_sanitizer()
Expand Down
19 changes: 19 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,26 @@ EOF
echo "Checking for fseeko... No." | tee -a configure.log
fi
fi
echo >> configure.log

cat > $test.c <<EOF
#define _POSIX_C_SOURCE 200112L
#include <stdlib.h>
int main(void) {
void *ptr = 0;
int ret = posix_memalign(&ptr, 64, 10);
if (ptr)
free(ptr);
return ret;
}
EOF
if try $CC $CFLAGS -o $test $test.c $LDSHAREDLIBC; then
echo "Checking for posix_memalign... Yes." | tee -a configure.log
CFLAGS="${CFLAGS} -DHAVE_POSIX_MEMALIGN"
SFLAGS="${SFLAGS} -DHAVE_POSIX_MEMALIGN"
else
echo "Checking for posix_memalign... No." | tee -a configure.log
fi
echo >> configure.log

# check for strerror() for use by gz* functions
Expand Down
2 changes: 1 addition & 1 deletion zbuild.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* Determine compiler support for TLS */
#ifndef Z_TLS
# if __STDC_VERSION__ >= 201112 && !defined __STDC_NO_THREADS__
# if defined(STDC11) && !defined(__STDC_NO_THREADS__)
# define Z_TLS _Thread_local
# elif defined(__GNUC__) || defined(__SUNPRO_C)
# define Z_TLS __thread
Expand Down
2 changes: 1 addition & 1 deletion zutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

#include "zbuild.h"
#include "zutil.h"
#include "zutil_p.h"
#include "zutil.h"

z_const char * const PREFIX(z_errmsg)[10] = {
(z_const char *)"need dictionary", /* Z_NEED_DICT 2 */
Expand Down
8 changes: 6 additions & 2 deletions zutil_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
#ifndef ZUTIL_P_H
#define ZUTIL_P_H

#if defined(__APPLE__) || defined(__OpenBSD__)
#if defined(HAVE_POSIX_MEMALIGN) && !defined(_POSIX_C_SOURCE)
# define _POSIX_C_SOURCE 200112L /* For posix_memalign(). */
#endif

#if defined(__APPLE__) || defined(HAVE_POSIX_MEMALIGN)
# include <stdlib.h>
#elif defined(__FreeBSD__)
# include <stdlib.h>
Expand All @@ -16,7 +20,7 @@

/* Function to allocate 16 or 64-byte aligned memory */
static inline void *zng_alloc(size_t size) {
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#ifdef HAVE_POSIX_MEMALIGN
void *ptr;
return posix_memalign(&ptr, 64, size) ? NULL : ptr;
#elif defined(_WIN32)
Expand Down