Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
analyzer: off
sanitizer: address,undefined
- os: macos-14
packages: automake
packages: autoconf automake libtool
build_type: Debug
build_tool_options: -j 4
analyzer: off
Expand Down Expand Up @@ -127,6 +127,6 @@ jobs:
run: |
set -e -x
echo $PATH
autoreconf -i
autoreconf -fi
./configure
make -j 2
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
*.o
*.lo
*.d
/.libs/
/aclocal.m4
/autom4te.cache
/build
/config.guess
Expand All @@ -11,7 +14,11 @@
/config.sub
/configure
/configure~
/install-sh
/libtool
/libzone.a
/libzone.la
/ltmain.sh
/make.dep
/.depend
/Makefile
Expand Down
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ if(architecture STREQUAL "x86_64" OR architecture STREQUAL "amd64")
unset(CMAKE_REQUIRED_FLAGS)
if (HAVE_WESTMERE)
set_source_files_properties(
src/westmere/parser.c PROPERTIES COMPILE_FLAGS "-march=westmere")
target_sources(zone PRIVATE src/westmere/parser.c)
src/westmere/wmparser.c PROPERTIES COMPILE_FLAGS "-march=westmere")
target_sources(zone PRIVATE src/westmere/wmparser.c)
set_source_files_properties(
src/westmere/bench.c PROPERTIES COMPILE_FLAGS "-march=westmere")
target_sources(zone-bench PRIVATE src/westmere/bench.c)
Expand All @@ -233,8 +233,8 @@ if(architecture STREQUAL "x86_64" OR architecture STREQUAL "amd64")
unset(CMAKE_REQUIRED_FLAGS)
if (HAVE_HASWELL)
set_source_files_properties(
src/haswell/parser.c PROPERTIES COMPILE_FLAGS "-march=haswell")
target_sources(zone PRIVATE src/haswell/parser.c)
src/haswell/hwparser.c PROPERTIES COMPILE_FLAGS "-march=haswell")
target_sources(zone PRIVATE src/haswell/hwparser.c)
set_source_files_properties(
src/haswell/bench.c PROPERTIES COMPILE_FLAGS "-march=haswell")
target_sources(zone-bench PRIVATE src/haswell/bench.c)
Expand Down
44 changes: 33 additions & 11 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,25 @@ CC = @CC@
CPPFLAGS = @CPPFLAGS@ -Iinclude -I$(SOURCE)/include -I$(SOURCE)/src -I.
CFLAGS = @CFLAGS@
DEPFLAGS = @DEPFLAGS@
LDFLAGS=@LDFLAGS@
LIBS=@LIBS@
VPATH = @srcdir@

libtool=@libtool@
LIBTOOL=$(libtool)
srcdir=@srcdir@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
SOURCE = @srcdir@
version_info=@version_info@

SOURCES = src/zone.c src/fallback/parser.c
OBJECTS = $(SOURCES:.c=.o)

WESTMERE_SOURCES = src/westmere/parser.c
WESTMERE_SOURCES = src/westmere/wmparser.c
WESTMERE_OBJECTS = $(WESTMERE_SOURCES:.c=.o)

HASWELL_SOURCES = src/haswell/parser.c
HASWELL_SOURCES = src/haswell/hwparser.c
HASWELL_OBJECTS = $(HASWELL_SOURCES:.c=.o)

NO_OBJECTS =
Expand All @@ -36,13 +44,13 @@ DEPENDS = $(SOURCES:.c=.d) $(WESTMERE_SOURCES:.c=.d) $(HASWELL_SOURCES:.c=.d)
# macros for compatibility.
EXPORT_HEADER = include/zone/export.h

.PHONY: all clean
.PHONY: all clean lib

all: libzone.a
all: lib

clean:
@rm -f .depend
@rm -f libzone.a $(OBJECTS) $(EXPORT_HEADER)
@rm -f libzone.a libzone.la $(OBJECTS) $(EXPORT_HEADER)
@rm -f $($(WESTMERE)_OBJECTS) $($(HASWELL)_OBJECTS)

distclean: clean
Expand All @@ -56,24 +64,38 @@ maintainer-clean: realclean
devclean: realclean
@rm -rf config.h.in configure

libzone.a: $(OBJECTS) $($(WESTMERE)_OBJECTS) $($(HASWELL)_OBJECTS) Makefile
$(AR) rcs libzone.a $(OBJECTS) $($(WESTMERE)_OBJECTS) $($(HASWELL)_OBJECTS)
#libzone.a: $(OBJECTS) $($(WESTMERE)_OBJECTS) $($(HASWELL)_OBJECTS) Makefile
#$(AR) rcs libzone.a $(OBJECTS) $($(WESTMERE)_OBJECTS) $($(HASWELL)_OBJECTS)

libzone.la: $(OBJECTS) $($(WESTMERE)_OBJECTS) $($(HASWELL)_OBJECTS) Makefile
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -version-info $(version_info) -no-undefined -export-symbols $(srcdir)/lzonesyms.def -o $@ $(OBJECTS:.o=.lo) $($(WESTMERE)_OBJECTS:.o=.lo) $($(HASWELL)_OBJECTS:.o=.lo) $(LIBS) -rpath $(libdir)
if test -f .libs/libzone.a; then cp .libs/libzone.a .; fi

libzone.a: libzone.la

# The copy to the main directory is because that is where (NSD) picks up
# the static library to link to.
# The shared object files are listed to link with.
lib: libzone.la

list_objs:
@echo $(OBJECTS:.o=.lo) $($(WESTMERE)_OBJECTS:.o=.lo) $($(HASWELL)_OBJECTS:.o=.lo)

$(EXPORT_HEADER):
@mkdir -p include/zone
@echo "#define ZONE_EXPORT" > $(EXPORT_HEADER)

$(WESTMERE_OBJECTS): $(EXPORT_HEADER) .depend Makefile
@mkdir -p src/westmere
$(CC) $(DEPFLAGS) $(CPPFLAGS) $(CFLAGS) -march=westmere -o $@ -c $(SOURCE)/$(@:.o=.c)
$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEPFLAGS) $(CPPFLAGS) $(CFLAGS) -march=westmere -o $@ -c $(SOURCE)/$(@:.o=.c)

$(HASWELL_OBJECTS): $(EXPORT_HEADER) .depend Makefile
@mkdir -p src/haswell
$(CC) $(DEPFLAGS) $(CPPFLAGS) $(CFLAGS) -march=haswell -o $@ -c $(SOURCE)/$(@:.o=.c)
$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEPFLAGS) $(CPPFLAGS) $(CFLAGS) -march=haswell -o $@ -c $(SOURCE)/$(@:.o=.c)

$(OBJECTS): $(EXPORT_HEADER) .depend Makefile
@mkdir -p src/fallback
$(CC) $(DEPFLAGS) $(CPPFLAGS) $(CFLAGS) -o $@ -c $(SOURCE)/$(@:.o=.c)
$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEPFLAGS) $(CPPFLAGS) $(CFLAGS) -o $@ -c $(SOURCE)/$(@:.o=.c)
@touch $@

.depend:
Expand Down
71 changes: 59 additions & 12 deletions acx_nlnetlabs.m4
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
# Copyright 2009, Wouter Wijngaards, NLnet Labs.
# BSD licensed.
#
# Version 48
# Version 50
# 2025-09-29 add ac_cv_func_malloc_0_nonnull as a cache value for the malloc(0)
# check by ACX_FUNC_MALLOC.
# 2025-09-29 add ACX_CHECK_NONSTRING_ATTRIBUTE, AHX_CONFIG_NONSTRING_ATTRIBUTE.
# 2024-01-16 fix to add -l:libssp.a to -lcrypto link check.
# and check for getaddrinfo with only header.
# 2024-01-15 fix to add crypt32 to -lcrypto link check when checking for gdi32.
Expand Down Expand Up @@ -71,6 +74,7 @@
# ACX_DEPFLAG - find cc dependency flags.
# ACX_DETERMINE_EXT_FLAGS_UNBOUND - find out which flags enable BSD and POSIX.
# ACX_CHECK_FORMAT_ATTRIBUTE - find cc printf format syntax.
# ACX_CHECK_NONSTRING_ATTRIBUTE - find cc nonstring attribute syntax.
# ACX_CHECK_UNUSED_ATTRIBUTE - find cc variable unused syntax.
# ACX_CHECK_FLTO - see if cc supports -flto and use it if so.
# ACX_LIBTOOL_C_ONLY - create libtool for C only, improved.
Expand All @@ -92,6 +96,7 @@
# ACX_FUNC_IOCTLSOCKET - find ioctlsocket, portably.
# ACX_FUNC_MALLOC - check malloc, define replacement .
# AHX_CONFIG_FORMAT_ATTRIBUTE - config.h text for format.
# AHX_CONFIG_NONSTRING_ATTRIBUTE - config.h text for nonstring.
# AHX_CONFIG_UNUSED_ATTRIBUTE - config.h text for unused.
# AHX_CONFIG_FSEEKO - define fseeko, ftello fallback.
# AHX_CONFIG_RAND_MAX - define RAND_MAX if needed.
Expand Down Expand Up @@ -490,7 +495,7 @@ AC_DEFUN([AHX_CONFIG_FORMAT_ATTRIBUTE],
])

dnl Check how to mark function arguments as unused.
dnl result in HAVE_ATTR_UNUSED.
dnl result in HAVE_ATTR_UNUSED.
dnl Make sure you include AHX_CONFIG_UNUSED_ATTRIBUTE also.
AC_DEFUN([ACX_CHECK_UNUSED_ATTRIBUTE],
[AC_REQUIRE([AC_PROG_CC])
Expand Down Expand Up @@ -525,6 +530,45 @@ if test $ac_cv_c_unused_attribute = yes; then
fi
])dnl

dnl Check how to mark function arguments as nonstring.
dnl result in HAVE_ATTR_NONSTRING.
dnl Make sure you include AHX_CONFIG_NONSTRING_ATTRIBUTE also.
AC_DEFUN([ACX_CHECK_NONSTRING_ATTRIBUTE],
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "nonstring" attribute)
AC_CACHE_VAL(ac_cv_c_nonstring_attribute,
[ac_cv_c_nonstring_attribute=no
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
struct test {
char __attribute__((nonstring)) s[1];
};
]], [[
struct test t = { "1" };
(void) t;
]])],[ac_cv_c_nonstring_attribute="yes"],[ac_cv_c_nonstring_attribute="no"])
])

dnl Setup ATTR_NONSTRING config.h parts.
dnl make sure you call ACX_CHECK_NONSTRING_ATTRIBUTE also.
AC_DEFUN([AHX_CONFIG_NONSTRING_ATTRIBUTE],
[
#if defined(DOXYGEN)
# define ATTR_NONSTRING(x) x
#elif defined(__cplusplus)
# define ATTR_NONSTRING(x) __attribute__((nonstring)) x
#elif defined(HAVE_ATTR_NONSTRING)
# define ATTR_NONSTRING(x) __attribute__((nonstring)) x
#else /* !HAVE_ATTR_NONSTRING */
# define ATTR_NONSTRING(x) x
#endif /* !HAVE_ATTR_NONSTRING */
])

AC_MSG_RESULT($ac_cv_c_nonstring_attribute)
if test $ac_cv_c_nonstring_attribute = yes; then
AC_DEFINE(HAVE_ATTR_NONSTRING, 1, [Whether the C compiler accepts the "nonstring" attribute])
fi
])dnl

dnl Pre-fun for ACX_LIBTOOL_C_ONLY
AC_DEFUN([ACX_LIBTOOL_C_PRE], [
# skip these tests, we do not need them.
Expand Down Expand Up @@ -1190,23 +1234,26 @@ dnl detect malloc and provide malloc compat prototype.
dnl $1: unique name for compat code
AC_DEFUN([ACX_FUNC_MALLOC],
[
AC_MSG_CHECKING([for GNU libc compatible malloc])
AC_RUN_IFELSE([AC_LANG_PROGRAM(
AC_CACHE_CHECK([for GNU libc compatible malloc],[ac_cv_func_malloc_0_nonnull],
[
AC_RUN_IFELSE([AC_LANG_PROGRAM(
[[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
#include <stdlib.h>
#else
char *malloc ();
#endif
]], [ if(malloc(0) != 0) return 1;])
],
[AC_MSG_RESULT([no])
AC_LIBOBJ(malloc)
AC_DEFINE_UNQUOTED([malloc], [rpl_malloc_$1], [Define if replacement function should be used.])] ,
[AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_MALLOC], 1, [If have GNU libc compatible malloc])],
[AC_MSG_RESULT([no (crosscompile)])
AC_LIBOBJ(malloc)
AC_DEFINE_UNQUOTED([malloc], [rpl_malloc_$1], [Define if replacement function should be used.])] )
[ac_cv_func_malloc_0_nonnull=no],
[ac_cv_func_malloc_0_nonnull=yes],
[ac_cv_func_malloc_0_nonnull="no (crosscompile)"])
])
AS_IF([test "$ac_cv_func_malloc_0_nonnull" = yes],
[AC_DEFINE([HAVE_MALLOC], 1, [If have GNU libc compatible malloc])],
[
AC_LIBOBJ(malloc)
AC_DEFINE_UNQUOTED([malloc], [rpl_malloc_$1], [Define if replacement function should be used.])
])
])

dnl Define fallback for fseeko and ftello if needed.
Expand Down
48 changes: 47 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,61 @@ AC_INIT([simdzone],[0.2.4],[https://github.com/NLnetLabs/simdzone/issues])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile])

version_info=0:1:0
# This is current:revision:age
# 0.2.4 had 0:1:0
#
#
# Current -- the number of the binary API that we're implementing
# Revision -- which iteration of the implementation of the binary
# API are we supplying?
# Age -- How many previous binary API versions do we also
# support?
#
# If we release a new version that does not change the binary API,
# increment Revision.
#
# If we release a new version that changes the binary API, but does
# not break programs compiled against the old binary API, increment
# Current and Age. Set Revision to 0, since this is the first
# implementation of the new API.
#
# Otherwise, we're changing the binary API and breaking backward
# compatibility with old binaries. Increment Current. Set Age to 0,
# since we're backward compatible with no previous APIs. Set Revision
# to 0 too.
AC_SUBST(version_info)

sinclude(acx_nlnetlabs.m4)
m4_include(m4/ax_check_compile_flag.m4)

CFLAGS="$CFLAGS"
m4_version_prereq([2.70], [AC_PROG_CC], [AC_PROG_CC_STDC])

# are we on MinGW?
if uname -s 2>&1 | grep MINGW >/dev/null; then on_mingw="yes"
else
if echo $host | grep mingw >/dev/null; then on_mingw="yes"
else on_mingw="no"; fi
fi
if test "$on_mingw" = "yes"; then
if echo "$host" | $GREP -i -e linux >/dev/null; then
# link with libssp for the stack protector functions on the windows
# compile, for the static compile -l:libssp.a could be used.
# But there is no static option right now for simdzone.
if test -z "$LIBS"; then LIBS="-lssp"; else LIBS="$LIBS -lssp"; fi
fi
fi

# allow user to override the -g -O2 flags.
if test "x$CFLAGS" = "x" ; then
ACX_CHECK_COMPILER_FLAG(g, [CFLAGS="$CFLAGS -g"])
ACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="$CFLAGS -O2"])
ACX_CHECK_PIE
fi

ACX_LIBTOOL_C_ONLY

AC_CHECK_HEADERS([endian.h sys/endian.h],,, [AC_INCLUDES_DEFAULT])
AC_CHECK_DECLS([bswap16,bswap32,bswap64], [], [], [
AC_INCLUDES_DEFAULT
Expand Down Expand Up @@ -140,7 +182,11 @@ int main(int argc, char *argv[])
fi
fi

AC_CHECK_FUNCS([realpath],,[AC_MSG_ERROR([realpath is not available])])
AC_CHECK_FUNCS([realpath],,[
AC_CHECK_FUNCS([_fullpath],,[
AC_MSG_ERROR([realpath and _fullpath are not available])
])
])

AC_SUBST([HAVE_ENDIAN_H])
AC_SUBST([HAVE_WESTMERE])
Expand Down
3 changes: 3 additions & 0 deletions lzonesyms.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
zone_log
zone_parse
zone_parse_string
File renamed without changes.
File renamed without changes.