From 6a6509b69a3b948e64730d0ceab6fa17e231ff93 Mon Sep 17 00:00:00 2001 From: William Brown Date: Jan 10 2017 00:24:16 +0000 Subject: Ticket 73, 67, 40 - Replace lfds wrapper Bug Description: For nunc-stans to be portable and adopted by Directory Server more broadly, we need to be able to run it on a variety of platforms and architectures. Additionally, the lfds build integration we have is messy and generally causes portability issues. Fix Description: This removes LFDS directly from nunc-stans, instead opting to use it from the SDS wrapper that is able to correctly manage garbage collection and platform abstraction. https://pagure.io/nunc-stans/issue/73 https://pagure.io/nunc-stans/issue/67 https://pagure.io/nunc-stans/issue/40 See also: https://pagure.io/libsds Author: wibrown Review by: mreynolds (Thanks!) --- diff --git a/COPYING.liblfds b/COPYING.liblfds deleted file mode 100644 index 7850b89..0000000 --- a/COPYING.liblfds +++ /dev/null @@ -1,2 +0,0 @@ -There is no license for liblfds. -You are free to use the code for liblfds in any way. diff --git a/Makefile.am b/Makefile.am index a505032..62ca511 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,5 @@ # look for included m4 files in the ./m4/ directory ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = @lfds_subdir@ DOXYGEN = doxygen TESTS = cmocka_test @@ -10,14 +9,13 @@ TESTS = cmocka_test #------------------------ DEBUG_DEFINES = @debug_defs@ NS_DEFINES = -NS_INCLUDES = -I$(srcdir)/include @lfds_inc@ @nspr_inc@ @sds_inc@ +NS_INCLUDES = -I$(srcdir)/include @nspr_inc@ @sds_inc@ AM_CPPFLAGS = $(PLATFORM_DEFINES) $(DEBUG_DEFINES) $(NS_DEFINES) $(NS_INCLUDES) #------------------------ # Linker Flags #------------------------ NSPR_LINK = @nspr_lib@ -lplc4 -lnspr4 -LFDS_LINK = @lfds_lib@ -llfds710 SDS_LINK = @sds_lib@ LIBEVENT_LINK = -levent LIBTEVENT_LINK = -ltevent -ltalloc @@ -28,7 +26,7 @@ LIBTEVENT_LINK = -ltevent -ltalloc #------------------------ # Build Products #------------------------ -lib_LTLIBRARIES = libnunc-stans.la liblfds710.la +lib_LTLIBRARIES = libnunc-stans.la #------------------------ # Installed Files @@ -56,9 +54,6 @@ libnunc_stans_la_SOURCES = ns_thrpool.c \ libnunc_stans_la_CPPFLAGS = $(AM_CPPFLAGS) libnunc_stans_la_LIBADD = $(NSPR_LINK) $(LFDS_LINK) $(LIBEVENT_LINK) $(LIBTEVENT_LINK) $(SDS_LINK) -liblfds710_la_SOURCES = "" -liblfds710_la_LIBADD = @lfds_libdir@/liblfds710.a - #//////////////////////////////////////////////////////////////// # diff --git a/configure.ac b/configure.ac index ff7c82c..7db52e0 100644 --- a/configure.ac +++ b/configure.ac @@ -57,10 +57,7 @@ AC_ARG_ENABLE(rpath, AS_HELP_STRING([--enable-rpath], [Allow libtool to add an r AC_MSG_RESULT($enable_rpath) m4_include(m4/nspr.m4) -#m4_include(m4/nss.m4) -#m4_include(m4/openssl.m4) m4_include(m4/fhs.m4) -m4_include(m4/lfds.m4) m4_include(m4/sds.m4) # installation paths - by default, configure will just @@ -80,14 +77,6 @@ fi AC_SUBST(nspr_inc) AC_SUBST(nspr_lib) AC_SUBST(nspr_libdir) -AC_SUBST(lfds_inc) -AC_SUBST(lfds_lib) -AC_SUBST(lfds_libdir) -AC_SUBST(lfds_subdir) -AC_SUBST(lfds_make_target) -#AC_SUBST(nss_inc) -#AC_SUBST(nss_lib) -#AC_SUBST(nss_libdir) AC_SUBST(sds_inc) AC_SUBST(sds_lib) diff --git a/liblfds710/build/gcc_gnumake/Makefile b/liblfds710/build/gcc_gnumake/Makefile deleted file mode 100644 index 5a4255f..0000000 --- a/liblfds710/build/gcc_gnumake/Makefile +++ /dev/null @@ -1,176 +0,0 @@ -##### notes ##### -# TRD : -fno-strict-aliasing is needed because GCC has messed up type punning and __may_alias__ does absolutely nothing -# -Wno-unused-but-set-variable and -Wno-uninitialized are needed because GCC seems confused by the atomic intrinsics -# the code base for release has been compiled with those warnings enabled, to show any valid errors - -##### paths ##### -BINDIR := ../../bin -INCDIR := ../../inc -OBJDIR := ../../obj -SRCDIR := ../../src -INSINCDIR := /usr/local/include/ -INSLIBDIR := /usr/local/lib/ - -##### misc ##### -QUIETLY := 1>/dev/null 2>/dev/null -VERSION_NUMBER := 1 -MINOR_NUMBER := 0 -RELEASE_NUMBER := 0 - -##### sources, objects and libraries ##### -BINNAME := liblfds710 -ARFILENAME := $(BINNAME).a -ARPATHNAME := $(BINDIR)/$(ARFILENAME) -SOBASENAME := $(BINNAME).so -SONAME := $(SOBASENAME).$(VERSION_NUMBER) -SOFILENAME := $(SONAME).$(MINOR_NUMBER).$(RELEASE_NUMBER) -SOPATHNAME := $(BINDIR)/$(SOFILENAME) -INCNAME := $(INCDIR)/$(BINNAME).h -SRCDIRS := lfds710_btree_addonly_unbalanced lfds710_freelist lfds710_hash_addonly lfds710_list_addonly_singlylinked_ordered lfds710_list_addonly_singlylinked_unordered lfds710_misc lfds710_prng lfds710_queue_bounded_manyproducer_manyconsumer lfds710_queue_bounded_singleproducer_singleconsumer lfds710_queue_unbounded_manyproducer_manyconsumer lfds710_ringbuffer lfds710_stack -SOURCES := lfds710_hash_addonly_cleanup.c lfds710_hash_addonly_get.c lfds710_hash_addonly_init.c lfds710_hash_addonly_insert.c lfds710_hash_addonly_iterate.c lfds710_hash_addonly_query.c \ - lfds710_list_addonly_singlylinked_ordered_cleanup.c lfds710_list_addonly_singlylinked_ordered_get.c lfds710_list_addonly_singlylinked_ordered_init.c lfds710_list_addonly_singlylinked_ordered_insert.c lfds710_list_addonly_singlylinked_ordered_query.c \ - lfds710_list_addonly_singlylinked_unordered_cleanup.c lfds710_list_addonly_singlylinked_unordered_get.c lfds710_list_addonly_singlylinked_unordered_init.c lfds710_list_addonly_singlylinked_unordered_insert.c lfds710_list_addonly_singlylinked_unordered_query.c \ - lfds710_btree_addonly_unbalanced_cleanup.c lfds710_btree_addonly_unbalanced_get.c lfds710_btree_addonly_unbalanced_init.c lfds710_btree_addonly_unbalanced_insert.c lfds710_btree_addonly_unbalanced_query.c \ - lfds710_freelist_cleanup.c lfds710_freelist_init.c lfds710_freelist_pop.c lfds710_freelist_push.c lfds710_freelist_query.c \ - lfds710_misc_internal_backoff_init.c lfds710_misc_globals.c lfds710_misc_query.c \ - lfds710_prng_init.c \ - lfds710_queue_bounded_manyproducer_manyconsumer_cleanup.c lfds710_queue_bounded_manyproducer_manyconsumer_dequeue.c lfds710_queue_bounded_manyproducer_manyconsumer_enqueue.c lfds710_queue_bounded_manyproducer_manyconsumer_init.c lfds710_queue_bounded_manyproducer_manyconsumer_query.c \ - lfds710_queue_bounded_singleproducer_singleconsumer_cleanup.c lfds710_queue_bounded_singleproducer_singleconsumer_dequeue.c lfds710_queue_bounded_singleproducer_singleconsumer_enqueue.c lfds710_queue_bounded_singleproducer_singleconsumer_init.c lfds710_queue_bounded_singleproducer_singleconsumer_query.c \ - lfds710_queue_unbounded_manyproducer_manyconsumer_cleanup.c lfds710_queue_unbounded_manyproducer_manyconsumer_dequeue.c lfds710_queue_unbounded_manyproducer_manyconsumer_enqueue.c lfds710_queue_unbounded_manyproducer_manyconsumer_init.c lfds710_queue_unbounded_manyproducer_manyconsumer_query.c \ - lfds710_ringbuffer_cleanup.c lfds710_ringbuffer_init.c lfds710_ringbuffer_query.c lfds710_ringbuffer_read.c lfds710_ringbuffer_write.c \ - lfds710_stack_cleanup.c lfds710_stack_init.c lfds710_stack_pop.c lfds710_stack_push.c lfds710_stack_query.c -OBJECTS := $(patsubst %.c,$(OBJDIR)/%.o,$(notdir $(SOURCES))) -SYSLIBS := -lgcc - -##### tools ##### -DG := gcc -DGFLAGS_MANDATORY := -MM -DGFLAGS_OPTIONAL := -std=gnu89 - -CC ?= gcc -CFLAGS_MANDATORY := -c -fno-strict-aliasing -CFLAGS_OPTIONAL := -ffreestanding -nostdinc -std=gnu89 -Wall -Werror -Wno-unknown-pragmas -Wno-unused-but-set-variable -Wno-uninitialized -CFLAGS_MANDATORY_COV := -O0 -ggdb -DCOVERAGE -fprofile-arcs -ftest-coverage -CFLAGS_MANDATORY_DBG := -O0 -ggdb -D_DEBUG -CFLAGS_MANDATORY_PROF := -O0 -ggdb -DPROF -pg -CFLAGS_MANDATORY_REL := -O2 -DNDEBUG -CFLAGS_MANDATORY_TSAN := -O0 -ggdb -DTSAN -fsanitize=thread -fPIC - -AR := ar -ARFLAGS := -ARFLAGS_MANDATORY := rcs -ARFLAGS_OPTIONAL := - -LD := gcc -LDFLAGS_MANDATORY := -shared -Wl,-soname,$(SONAME) -o $(SOPATHNAME) -LDFLAGS_OPTIONAL := -nodefaultlibs -nostdlib -std=gnu89 -Wall -Werror -LDFLAGS_MANDATORY_COV := -O0 -fprofile-arcs -ftest-coverage -LDFLAGS_MANDATORY_DBG := -O0 -ggdb -LDFLAGS_MANDATORY_PROF := -O0 -pg -LDFLAGS_MANDATORY_REL := -O2 -s -LDFLAGS_MANDATORY_TSAN := -O0 -fsanitize=thread -fPIC - -##### build variants ##### -ifeq ($(findstring so,$(MAKECMDGOALS)),so) - CFLAGS_MANDATORY += -fPIC -endif - -# TRD : default to debug -ifeq ($(MAKECMDGOALS),) - CFLAGS_MANDATORY += $(CFLAGS_MANDATORY_DBG) - LDFLAGS_MANDATORY += $(LDFLAGS_MANDATORY_DBG) -endif - -ifeq ($(findstring cov,$(MAKECMDGOALS)),cov) - CFLAGS_MANDATORY += $(CFLAGS_MANDATORY_COV) - LDFLAGS_MANDATORY += $(LDFLAGS_MANDATORY_COV) - SYSLIBS += -lgcov -endif - -ifeq ($(findstring dbg,$(MAKECMDGOALS)),dbg) - CFLAGS_MANDATORY += $(CFLAGS_MANDATORY_DBG) - LDFLAGS_MANDATORY += $(LDFLAGS_MANDATORY_DBG) -endif - -ifeq ($(findstring prof,$(MAKECMDGOALS)),prof) - CFLAGS_MANDATORY += $(CFLAGS_MANDATORY_PROF) - LDFLAGS_MANDATORY += $(LDFLAGS_MANDATORY_PROF) -endif - -ifeq ($(findstring rel,$(MAKECMDGOALS)),rel) - CFLAGS_MANDATORY += $(CFLAGS_MANDATORY_REL) - LDFLAGS_MANDATORY += $(LDFLAGS_MANDATORY_REL) -endif - -ifeq ($(findstring tsan,$(MAKECMDGOALS)),tsan) - CFLAGS_MANDATORY += $(CFLAGS_MANDATORY_TSAN) - LDFLAGS_MANDATORY += $(LDFLAGS_MANDATORY_TSAN) -endif - -##### search paths ##### -vpath %.c $(patsubst %,$(SRCDIR)/%:,$(SRCDIRS)) - -##### implicit rules ##### -$(OBJDIR)/%.o : %.c - $(DG) $(DGFLAGS_OPTIONAL) $(DGFLAGS) $(DGFLAGS_MANDATORY) $< >$(OBJDIR)/$*.d - $(CC) $(CFLAGS_OPTIONAL) $(CFLAGS) $(CFLAGS_MANDATORY) -o $@ $< - -##### explicit rules ##### -$(ARPATHNAME) : $(OBJECTS) - $(AR) $(ARFLAGS_OPTIONAL) $(ARFLAGS) $(ARFLAGS_MANDATORY) $(ARPATHNAME) $(OBJECTS) - -$(SOPATHNAME) : $(OBJECTS) - $(LD) $(LDFLAGS_OPTIONAL) $(LDFLAGS) $(LDFLAGS_MANDATORY) $(OBJECTS) -lgcov -lgcc -o $(SOPATHNAME) - @ln -fs $(SOFILENAME) $(BINDIR)/$(SONAME) - @ln -fs $(SOFILENAME) $(BINDIR)/$(SOBASENAME) - -##### phony ##### -.PHONY : clean ar_cov ar_dbg ar_prof ar_rel ar_tsan ar_vanilla ar_install ar_uninstall so_dbg so_prof so_rel so_tsan so_vanilla so_install so_uninstall - -clean : - @rm -f $(BINDIR)/* $(OBJDIR)/* - -ar_cov : $(ARPATHNAME) # archive (.a), coverage -ar_dbg : $(ARPATHNAME) # archive (.a), debug -ar_prof : $(ARPATHNAME) # archive (.a), profiling -ar_rel : $(ARPATHNAME) # archive (.a), release -ar_tsan : $(ARPATHNAME) # archive (.a), thread sanitizer -ar_vanilla : $(ARPATHNAME) # archive (.a), no specific-build arguments -ar_install : - # TRD : leading backslash to use command rather than alias - # as many Linux distros have a built-in alias to force - # a prompt ("y/n?") on file overwrite - silent and - # unexpected interference which breaks a makefile - @mkdir -p $(INSLIBDIR) - @\cp $(ARPATHNAME) $(INSLIBDIR) - @mkdir -p $(INSINCDIR) - @\cp -r $(INCDIR)/* $(INSINCDIR) -ar_uninstall : - @rm $(INSLIBDIR)/$(ARFILENAME) - @rm -r $(INSINCDIR)/$(BINNAME) - @rm -r $(INSINCDIR)/$(BINNAME).h - -# TRD : so_cov currently disabled as it cannot work with -nostdlib -nodefaultlibs -# so_cov : $(SOPATHNAME) # shared (.so), coverage -so_dbg : $(SOPATHNAME) # shared (.so), debug -so_prof : $(SOPATHNAME) # shared (.so), profiling -so_rel : $(SOPATHNAME) # shared (.so), release -so_tsan : $(SOPATHNAME) # shared (.so), thread sanitizer -so_vanilla : $(SOPATHNAME) # shared (.so), no specific-build arguments -so_install : - @mkdir -p $(INSINCDIR) - @\cp $(SOPATHNAME) $(INSLIBDIR) - @ldconfig -vn $(INSLIBDIR) - @ln -s $(SONAME) $(INSLIBDIR)/$(SOBASENAME) - @mkdir -p $(INSLIBDIR) - @\cp -r $(INCDIR)/* $(INSINCDIR) -so_uninstall : - @rm -f $(INSLIBDIR)/$(SOFILENAME) - @rm -f $(INSLIBDIR)/$(SOBASENAME) - @rm -f $(INSLIBDIR)/$(SONAME) - @rm -r $(INSINCDIR)/$(BINNAME) - @rm -r $(INSINCDIR)/$(BINNAME).h - -##### dependencies ##### --include $(DEPENDS) - diff --git a/liblfds710/build/gcc_gnumake_kbuild/Kbuild b/liblfds710/build/gcc_gnumake_kbuild/Kbuild deleted file mode 100644 index 18701f3..0000000 --- a/liblfds710/build/gcc_gnumake_kbuild/Kbuild +++ /dev/null @@ -1,86 +0,0 @@ -lib-y := - -lib-y += ../../src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_cleanup.o -lib-y += ../../src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_get.o -lib-y += ../../src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_init.o -lib-y += ../../src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_insert.o -lib-y += ../../src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_query.o - -lib-y += ../../src/lfds710_freelist/lfds710_freelist_cleanup.o -lib-y += ../../src/lfds710_freelist/lfds710_freelist_init.o -lib-y += ../../src/lfds710_freelist/lfds710_freelist_pop.o -lib-y += ../../src/lfds710_freelist/lfds710_freelist_push.o -lib-y += ../../src/lfds710_freelist/lfds710_freelist_query.o - -lib-y += ../../src/lfds710_hash_addonly/lfds710_hash_addonly_cleanup.o -lib-y += ../../src/lfds710_hash_addonly/lfds710_hash_addonly_get.o -lib-y += ../../src/lfds710_hash_addonly/lfds710_hash_addonly_init.o -lib-y += ../../src/lfds710_hash_addonly/lfds710_hash_addonly_insert.o -lib-y += ../../src/lfds710_hash_addonly/lfds710_hash_addonly_iterate.o -lib-y += ../../src/lfds710_hash_addonly/lfds710_hash_addonly_query.o - -lib-y += ../../src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_cleanup.o -lib-y += ../../src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_get.o -lib-y += ../../src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_init.o -lib-y += ../../src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_insert.o -lib-y += ../../src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_query.o - -lib-y += ../../src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_cleanup.o -lib-y += ../../src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_get.o -lib-y += ../../src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_init.o -lib-y += ../../src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_insert.o -lib-y += ../../src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_query.o - -lib-y += ../../src/lfds710_misc/lfds710_misc_internal_backoff_init.o -lib-y += ../../src/lfds710_misc/lfds710_misc_globals.o -lib-y += ../../src/lfds710_misc/lfds710_misc_query.o - -lib-y += ../../src/lfds710_prng/lfds710_prng_init.o - -lib-y += ../../src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_cleanup.o -lib-y += ../../src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_dequeue.o -lib-y += ../../src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_enqueue.o -lib-y += ../../src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_init.o -lib-y += ../../src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_query.o - -lib-y += ../../src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_cleanup.o -lib-y += ../../src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_dequeue.o -lib-y += ../../src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_enqueue.o -lib-y += ../../src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_init.o -lib-y += ../../src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_query.o - -lib-y += ../../src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_cleanup.o -lib-y += ../../src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_dequeue.o -lib-y += ../../src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_enqueue.o -lib-y += ../../src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_init.o -lib-y += ../../src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_query.o - -lib-y += ../../src/lfds710_ringbuffer/lfds710_ringbuffer_cleanup.o -lib-y += ../../src/lfds710_ringbuffer/lfds710_ringbuffer_init.o -lib-y += ../../src/lfds710_ringbuffer/lfds710_ringbuffer_query.o -lib-y += ../../src/lfds710_ringbuffer/lfds710_ringbuffer_read.o -lib-y += ../../src/lfds710_ringbuffer/lfds710_ringbuffer_write.o - -lib-y += ../../src/lfds710_stack/lfds710_stack_cleanup.o -lib-y += ../../src/lfds710_stack/lfds710_stack_init.o -lib-y += ../../src/lfds710_stack/lfds710_stack_pop.o -lib-y += ../../src/lfds710_stack/lfds710_stack_push.o -lib-y += ../../src/lfds710_stack/lfds710_stack_query.o - -libs-y := ../../bin/ - -ccflags-y := -I$(src)/../../inc -ccflags-y += -I$(src)/../../inc/liblfds710 -ccflags-y += -DKERNEL_MODE -ccflags-y += -DNDEBUG -ccflags-y += -fno-strict-aliasing -ccflags-y += -std=gnu89 -ccflags-y += -Wall -ccflags-y += -Werror -ccflags-y += -Wno-unknown-pragmas -ccflags-y += -Wno-unused-but-set-variable -ccflags-y += -Wno-uninitialized - - - - diff --git a/liblfds710/build/gcc_gnumake_kbuild/Makefile b/liblfds710/build/gcc_gnumake_kbuild/Makefile deleted file mode 100644 index d6de5f4..0000000 --- a/liblfds710/build/gcc_gnumake_kbuild/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -default: - $(MAKE) -C /lib/modules/`uname -r`/build M=$(PWD) - -clean: - $(MAKE) -C /lib/modules/`uname -r`/build M=$(PWD) clean - find ../../src/ -name "*.o" -type f -delete - -help: - $(MAKE) -C /lib/modules/`uname -r`/build M=$(PWD) help - -modules: - $(MAKE) -C /lib/modules/`uname -r`/build M=$(PWD) modules - - diff --git a/liblfds710/build/msvc_gnumake/liblfds710.def b/liblfds710/build/msvc_gnumake/liblfds710.def deleted file mode 100644 index b5f20d2..0000000 --- a/liblfds710/build/msvc_gnumake/liblfds710.def +++ /dev/null @@ -1,75 +0,0 @@ -EXPORTS - -lfds710_btree_au_init_valid_on_current_logical_core = lfds710_btree_au_init_valid_on_current_logical_core -lfds710_btree_au_cleanup = lfds710_btree_au_cleanup -lfds710_btree_au_insert = lfds710_btree_au_insert -lfds710_btree_au_get_by_key = lfds710_btree_au_get_by_key -lfds710_btree_au_get_by_absolute_position_and_then_by_relative_position = lfds710_btree_au_get_by_absolute_position_and_then_by_relative_position -lfds710_btree_au_get_by_absolute_position = lfds710_btree_au_get_by_absolute_position -lfds710_btree_au_get_by_relative_position = lfds710_btree_au_get_by_relative_position -lfds710_btree_au_query = lfds710_btree_au_query - -lfds710_freelist_init_valid_on_current_logical_core = lfds710_freelist_init_valid_on_current_logical_core -lfds710_freelist_cleanup = lfds710_freelist_cleanup -lfds710_freelist_push = lfds710_freelist_push -lfds710_freelist_pop = lfds710_freelist_pop -lfds710_freelist_query = lfds710_freelist_query - -lfds710_hash_a_init_valid_on_current_logical_core = lfds710_hash_a_init_valid_on_current_logical_core -lfds710_hash_a_cleanup = lfds710_hash_a_cleanup -lfds710_hash_a_insert = lfds710_hash_a_insert -lfds710_hash_a_get_by_key = lfds710_hash_a_get_by_key -lfds710_hash_a_iterate_init = lfds710_hash_a_iterate_init -lfds710_hash_a_iterate = lfds710_hash_a_iterate -lfds710_hash_a_query = lfds710_hash_a_query - -lfds710_list_aso_init_valid_on_current_logical_core = lfds710_list_aso_init_valid_on_current_logical_core -lfds710_list_aso_cleanup = lfds710_list_aso_cleanup -lfds710_list_aso_insert = lfds710_list_aso_insert -lfds710_list_aso_get_by_key = lfds710_list_aso_get_by_key -lfds710_list_aso_query = lfds710_list_aso_query - -lfds710_list_asu_init_valid_on_current_logical_core = lfds710_list_asu_init_valid_on_current_logical_core -lfds710_list_asu_cleanup = lfds710_list_asu_cleanup -lfds710_list_asu_insert_at_position = lfds710_list_asu_insert_at_position -lfds710_list_asu_insert_at_start = lfds710_list_asu_insert_at_start -lfds710_list_asu_insert_at_end = lfds710_list_asu_insert_at_end -lfds710_list_asu_insert_after_element = lfds710_list_asu_insert_after_element -lfds710_list_asu_get_by_key = lfds710_list_asu_get_by_key -lfds710_list_asu_query = lfds710_list_asu_query - -lfds710_misc_query = lfds710_misc_query - -lfds710_prng_init_valid_on_current_logical_core = lfds710_prng_init_valid_on_current_logical_core -lfds710_prng_st_init = lfds710_prng_st_init - -lfds710_queue_bmm_init_valid_on_current_logical_core = lfds710_queue_bmm_init_valid_on_current_logical_core -lfds710_queue_bmm_cleanup = lfds710_queue_bmm_cleanup -lfds710_queue_bmm_enqueue = lfds710_queue_bmm_enqueue -lfds710_queue_bmm_dequeue = lfds710_queue_bmm_dequeue -lfds710_queue_bmm_query = lfds710_queue_bmm_query - -lfds710_queue_bss_init_valid_on_current_logical_core = lfds710_queue_bss_init_valid_on_current_logical_core -lfds710_queue_bss_cleanup = lfds710_queue_bss_cleanup -lfds710_queue_bss_enqueue = lfds710_queue_bss_enqueue -lfds710_queue_bss_dequeue = lfds710_queue_bss_dequeue -lfds710_queue_bss_query = lfds710_queue_bss_query - -lfds710_queue_umm_init_valid_on_current_logical_core = lfds710_queue_umm_init_valid_on_current_logical_core -lfds710_queue_umm_cleanup = lfds710_queue_umm_cleanup -lfds710_queue_umm_enqueue = lfds710_queue_umm_enqueue -lfds710_queue_umm_dequeue = lfds710_queue_umm_dequeue -lfds710_queue_umm_query = lfds710_queue_umm_query - -lfds710_ringbuffer_init_valid_on_current_logical_core = lfds710_ringbuffer_init_valid_on_current_logical_core -lfds710_ringbuffer_cleanup = lfds710_ringbuffer_cleanup -lfds710_ringbuffer_read = lfds710_ringbuffer_read -lfds710_ringbuffer_write = lfds710_ringbuffer_write -lfds710_ringbuffer_query = lfds710_ringbuffer_query - -lfds710_stack_init_valid_on_current_logical_core = lfds710_stack_init_valid_on_current_logical_core -lfds710_stack_cleanup = lfds710_stack_cleanup -lfds710_stack_push = lfds710_stack_push -lfds710_stack_pop = lfds710_stack_pop -lfds710_stack_query = lfds710_stack_query - diff --git a/liblfds710/build/msvc_gnumake/makefile b/liblfds710/build/msvc_gnumake/makefile deleted file mode 100644 index f62b40e..0000000 --- a/liblfds710/build/msvc_gnumake/makefile +++ /dev/null @@ -1,113 +0,0 @@ -##### paths ##### -BINDIR := ..\..\bin -INCDIR := ..\..\inc -OBJDIR := ..\..\obj -SRCDIR := ..\..\src - -##### misc ##### -QUIETLY := 1>nul 2>nul -NULL := -SPACE := $(NULL) # TRD : with a trailing space - -##### sources, objects and libraries ##### -BINNAME := liblfds710 -LIB_BINARY := $(BINDIR)\$(BINNAME).lib -DLL_BINARY := $(BINDIR)\$(BINNAME).dll -SRCDIRS := lfds710_btree_addonly_unbalanced lfds710_freelist lfds710_hash_addonly lfds710_list_addonly_singlylinked_ordered lfds710_list_addonly_singlylinked_unordered lfds710_misc lfds710_prng lfds710_queue_bounded_manyproducer_manyconsumer lfds710_queue_bounded_singleproducer_singleconsumer lfds710_queue_unbounded_manyproducer_manyconsumer lfds710_ringbuffer lfds710_stack -SOURCES := lfds710_hash_addonly_cleanup.c lfds710_hash_addonly_get.c lfds710_hash_addonly_init.c lfds710_hash_addonly_insert.c lfds710_hash_addonly_iterate.c lfds710_hash_addonly_query.c \ - lfds710_list_addonly_singlylinked_ordered_cleanup.c lfds710_list_addonly_singlylinked_ordered_get.c lfds710_list_addonly_singlylinked_ordered_init.c lfds710_list_addonly_singlylinked_ordered_insert.c lfds710_list_addonly_singlylinked_ordered_query.c \ - lfds710_list_addonly_singlylinked_unordered_cleanup.c lfds710_list_addonly_singlylinked_unordered_get.c lfds710_list_addonly_singlylinked_unordered_init.c lfds710_list_addonly_singlylinked_unordered_insert.c lfds710_list_addonly_singlylinked_unordered_query.c \ - lfds710_btree_addonly_unbalanced_cleanup.c lfds710_btree_addonly_unbalanced_get.c lfds710_btree_addonly_unbalanced_init.c lfds710_btree_addonly_unbalanced_insert.c lfds710_btree_addonly_unbalanced_query.c \ - lfds710_freelist_cleanup.c lfds710_freelist_init.c lfds710_freelist_pop.c lfds710_freelist_push.c lfds710_freelist_query.c \ - lfds710_misc_internal_backoff_init.c lfds710_misc_globals.c lfds710_misc_query.c \ - lfds710_prng_init.c \ - lfds710_queue_bounded_manyproducer_manyconsumer_cleanup.c lfds710_queue_bounded_manyproducer_manyconsumer_dequeue.c lfds710_queue_bounded_manyproducer_manyconsumer_enqueue.c lfds710_queue_bounded_manyproducer_manyconsumer_init.c lfds710_queue_bounded_manyproducer_manyconsumer_query.c \ - lfds710_queue_bounded_singleproducer_singleconsumer_cleanup.c lfds710_queue_bounded_singleproducer_singleconsumer_dequeue.c lfds710_queue_bounded_singleproducer_singleconsumer_enqueue.c lfds710_queue_bounded_singleproducer_singleconsumer_init.c lfds710_queue_bounded_singleproducer_singleconsumer_query.c \ - lfds710_queue_unbounded_manyproducer_manyconsumer_cleanup.c lfds710_queue_unbounded_manyproducer_manyconsumer_dequeue.c lfds710_queue_unbounded_manyproducer_manyconsumer_enqueue.c lfds710_queue_unbounded_manyproducer_manyconsumer_init.c lfds710_queue_unbounded_manyproducer_manyconsumer_query.c \ - lfds710_ringbuffer_cleanup.c lfds710_ringbuffer_init.c lfds710_ringbuffer_query.c lfds710_ringbuffer_read.c lfds710_ringbuffer_write.c \ - lfds710_stack_cleanup.c lfds710_stack_init.c lfds710_stack_pop.c lfds710_stack_push.c lfds710_stack_query.c -OBJECTS := $(patsubst %.c,$(OBJDIR)/%.obj,$(notdir $(SOURCES))) -SYSLIBS := kernel32.lib - -##### default paths fix up ##### -INCDIRS := $(patsubst %,%;,$(INCDIR)) -INCLUDE += $(subst $(SPACE),,$(INCDIRS)) - -##### tools ##### -CC := cl -CFLAGS_MANDATORY := /c "/Fd$(BINDIR)\$(BINNAME).pdb" /wd 4068 -CFLAGS_OPTIONAL := /DWIN32_LEAN_AND_MEAN /DUNICODE /D_UNICODE /nologo /W4 /WX -CFLAGS_MANDATORY_DBG := /Od /Gm /Zi /D_DEBUG -CFLAGS_MANDATORY_REL := /Ox /DNDEBUG - -AR := lib -ARFLAGS := -ARFLAGS_MANDATORY := /subsystem:console -ARFLAGS_OPTIONAL := /nologo /wx /verbose - -LD := link -LDFLAGS_MANDATORY := /def:$(BINNAME).def /dll /nodefaultlib /subsystem:console -LDFLAGS_OPTIONAL := /nologo /nxcompat /wx -LDFLAGS_MANDATORY_DBG := /debug "/pdb:$(BINDIR)\$(BINNAME).pdb" -LDFLAGS_MANDATORY_REL := /incremental:no - -##### variants ##### -ifeq ($(MAKECMDGOALS),) # TRD : default to debug lib - CFLAGS_MANDATORY += $(CFLAGS_MANDATORY_DBG) - LDFLAGS_MANDATORY += $(LDFLAGS_MANDATORY_DBG) - CLIB := libcmtd.lib -endif - -ifeq ($(MAKECMDGOALS),libdbg) - CFLAGS_MANDATORY += $(CFLAGS_MANDATORY_DBG) - LDFLAGS_MANDATORY += $(LDFLAGS_MANDATORY_DBG) - CLIB := libcmtd.lib -endif - -ifeq ($(MAKECMDGOALS),librel) - CFLAGS_MANDATORY += $(CFLAGS_MANDATORY_REL) - LDFLAGS_MANDATORY += $(LDFLAGS_MANDATORY_REL) - CLIB := libcmt.lib -endif - -ifeq ($(MAKECMDGOALS),dlldbg) - CFLAGS_MANDATORY += $(CFLAGS_MANDATORY_DBG) - LDFLAGS_MANDATORY += $(LDFLAGS_MANDATORY_DBG) - CLIB := msvcrtd.lib -endif - -ifeq ($(MAKECMDGOALS),dllrel) - CFLAGS_MANDATORY += $(CFLAGS_MANDATORY_REL) - LDFLAGS_MANDATORY += $(LDFLAGS_MANDATORY_REL) - CLIB := msvcrt.lib -endif - -##### search paths ##### -vpath %.c $(patsubst %,$(SRCDIR)/%;,$(SRCDIRS)) - -##### implicit rules ##### -$(OBJDIR)/%.obj : %.c - $(CC) $(CFLAGS_OPTIONAL) $(CFLAGS) $(CFLAGS_MANDATORY) "/Fo$@" $< - -##### explicit rules ##### -$(LIB_BINARY) : $(OBJECTS) - $(AR) $(ARFLAGS_OPTIONAL) $(ARFLAGS) $(ARFLAGS_MANDATORY) $(OBJECTS) /out:$(LIB_BINARY) - -$(DLL_BINARY) : $(OBJECTS) - $(LD) $(LDFLAGS_OPTIONAL) $(LDFLAGS) $(LDFLAGS_MANDATORY) $(CLIB) $(SYSLIBS) $(OBJECTS) /out:$(DLL_BINARY) - -##### phony ##### -.PHONY : clean librel libdbg dllrel dlldbg - -clean : - @erase /Q $(BINDIR)\$(BINNAME).* $(OBJDIR)\*.obj $(QUIETLY) - -dllrel : $(DLL_BINARY) -dlldbg : $(DLL_BINARY) - -librel : $(LIB_BINARY) -libdbg : $(LIB_BINARY) - -##### notes ##### -# /wd 4068 : turn off "unknown pragma" warning - diff --git a/liblfds710/build/wdk_7.1/dirs b/liblfds710/build/wdk_7.1/dirs deleted file mode 100644 index 64e002c..0000000 --- a/liblfds710/build/wdk_7.1/dirs +++ /dev/null @@ -1,3 +0,0 @@ -DIRS = single_dir_for_windows_kernel - - diff --git a/liblfds710/build/wdk_7.1/driver_entry_renamed_to_avoid_compiler_warning.c b/liblfds710/build/wdk_7.1/driver_entry_renamed_to_avoid_compiler_warning.c deleted file mode 100644 index cddedc7..0000000 --- a/liblfds710/build/wdk_7.1/driver_entry_renamed_to_avoid_compiler_warning.c +++ /dev/null @@ -1,23 +0,0 @@ -#include "liblfds710_internal.h" - - - - - -/****************************************************************************/ -DRIVER_INITIALIZE DriverEntry; - - - - - -/****************************************************************************/ -#pragma warning( disable : 4100 ) - -NTSTATUS DriverEntry( struct _DRIVER_OBJECT *DriverObject, PUNICODE_STRING RegistryPath ) -{ - return STATUS_SUCCESS; -} - -#pragma warning( default : 4100 ) - diff --git a/liblfds710/build/wdk_7.1/liblfds710.def b/liblfds710/build/wdk_7.1/liblfds710.def deleted file mode 100644 index b5f20d2..0000000 --- a/liblfds710/build/wdk_7.1/liblfds710.def +++ /dev/null @@ -1,75 +0,0 @@ -EXPORTS - -lfds710_btree_au_init_valid_on_current_logical_core = lfds710_btree_au_init_valid_on_current_logical_core -lfds710_btree_au_cleanup = lfds710_btree_au_cleanup -lfds710_btree_au_insert = lfds710_btree_au_insert -lfds710_btree_au_get_by_key = lfds710_btree_au_get_by_key -lfds710_btree_au_get_by_absolute_position_and_then_by_relative_position = lfds710_btree_au_get_by_absolute_position_and_then_by_relative_position -lfds710_btree_au_get_by_absolute_position = lfds710_btree_au_get_by_absolute_position -lfds710_btree_au_get_by_relative_position = lfds710_btree_au_get_by_relative_position -lfds710_btree_au_query = lfds710_btree_au_query - -lfds710_freelist_init_valid_on_current_logical_core = lfds710_freelist_init_valid_on_current_logical_core -lfds710_freelist_cleanup = lfds710_freelist_cleanup -lfds710_freelist_push = lfds710_freelist_push -lfds710_freelist_pop = lfds710_freelist_pop -lfds710_freelist_query = lfds710_freelist_query - -lfds710_hash_a_init_valid_on_current_logical_core = lfds710_hash_a_init_valid_on_current_logical_core -lfds710_hash_a_cleanup = lfds710_hash_a_cleanup -lfds710_hash_a_insert = lfds710_hash_a_insert -lfds710_hash_a_get_by_key = lfds710_hash_a_get_by_key -lfds710_hash_a_iterate_init = lfds710_hash_a_iterate_init -lfds710_hash_a_iterate = lfds710_hash_a_iterate -lfds710_hash_a_query = lfds710_hash_a_query - -lfds710_list_aso_init_valid_on_current_logical_core = lfds710_list_aso_init_valid_on_current_logical_core -lfds710_list_aso_cleanup = lfds710_list_aso_cleanup -lfds710_list_aso_insert = lfds710_list_aso_insert -lfds710_list_aso_get_by_key = lfds710_list_aso_get_by_key -lfds710_list_aso_query = lfds710_list_aso_query - -lfds710_list_asu_init_valid_on_current_logical_core = lfds710_list_asu_init_valid_on_current_logical_core -lfds710_list_asu_cleanup = lfds710_list_asu_cleanup -lfds710_list_asu_insert_at_position = lfds710_list_asu_insert_at_position -lfds710_list_asu_insert_at_start = lfds710_list_asu_insert_at_start -lfds710_list_asu_insert_at_end = lfds710_list_asu_insert_at_end -lfds710_list_asu_insert_after_element = lfds710_list_asu_insert_after_element -lfds710_list_asu_get_by_key = lfds710_list_asu_get_by_key -lfds710_list_asu_query = lfds710_list_asu_query - -lfds710_misc_query = lfds710_misc_query - -lfds710_prng_init_valid_on_current_logical_core = lfds710_prng_init_valid_on_current_logical_core -lfds710_prng_st_init = lfds710_prng_st_init - -lfds710_queue_bmm_init_valid_on_current_logical_core = lfds710_queue_bmm_init_valid_on_current_logical_core -lfds710_queue_bmm_cleanup = lfds710_queue_bmm_cleanup -lfds710_queue_bmm_enqueue = lfds710_queue_bmm_enqueue -lfds710_queue_bmm_dequeue = lfds710_queue_bmm_dequeue -lfds710_queue_bmm_query = lfds710_queue_bmm_query - -lfds710_queue_bss_init_valid_on_current_logical_core = lfds710_queue_bss_init_valid_on_current_logical_core -lfds710_queue_bss_cleanup = lfds710_queue_bss_cleanup -lfds710_queue_bss_enqueue = lfds710_queue_bss_enqueue -lfds710_queue_bss_dequeue = lfds710_queue_bss_dequeue -lfds710_queue_bss_query = lfds710_queue_bss_query - -lfds710_queue_umm_init_valid_on_current_logical_core = lfds710_queue_umm_init_valid_on_current_logical_core -lfds710_queue_umm_cleanup = lfds710_queue_umm_cleanup -lfds710_queue_umm_enqueue = lfds710_queue_umm_enqueue -lfds710_queue_umm_dequeue = lfds710_queue_umm_dequeue -lfds710_queue_umm_query = lfds710_queue_umm_query - -lfds710_ringbuffer_init_valid_on_current_logical_core = lfds710_ringbuffer_init_valid_on_current_logical_core -lfds710_ringbuffer_cleanup = lfds710_ringbuffer_cleanup -lfds710_ringbuffer_read = lfds710_ringbuffer_read -lfds710_ringbuffer_write = lfds710_ringbuffer_write -lfds710_ringbuffer_query = lfds710_ringbuffer_query - -lfds710_stack_init_valid_on_current_logical_core = lfds710_stack_init_valid_on_current_logical_core -lfds710_stack_cleanup = lfds710_stack_cleanup -lfds710_stack_push = lfds710_stack_push -lfds710_stack_pop = lfds710_stack_pop -lfds710_stack_query = lfds710_stack_query - diff --git a/liblfds710/build/wdk_7.1/readme_before_win_kernel_build.txt b/liblfds710/build/wdk_7.1/readme_before_win_kernel_build.txt deleted file mode 100644 index 1481c8d..0000000 --- a/liblfds710/build/wdk_7.1/readme_before_win_kernel_build.txt +++ /dev/null @@ -1,32 +0,0 @@ -The Windows kernel build environment is primitive and has a number -of severe limitations; in particular, all source files must be in -one directory and it is not possible to choose the output binary type -(static or dynamic library) from the build command line; rather, -a string has to be modified in a text file used by the build (!) - -To deal with these limitations, it is necessary for a Windows kernel -build to run a batch file prior to building. - -There are two batch files, one for static library builds and the other -for dynamic library builds. - -They are both idempotent; you can run them as often as you like and -switch between them as often as you want. It's all fine; whenever -you run one of them, it will take you from whatever state you were -previously in, into the state you want to be in. - -Both batch files copy all the sources file into a single directory, -"/src/single_dir_for_windows_kernel/". - -The static library batch file will then copy "/sources.static" into -"/src/single_dir_for_windows_kernel/", which will cause a static -library to be built. - -The dynamic library batch file will then copy "/sources.dynamic" into -"/src/single_dir_for_windows_kernel/", which will cause a dynamic -library to be built. It will also copy "src/driver_entry.c" into -"/src/single_dir_for_windows_kernel/", since the linker requires -the DriverEntry function to exist for dynamic libraries, even -though it's not used. - - diff --git a/liblfds710/build/wdk_7.1/runme_before_win_kernel_dynamic_lib_build.bat b/liblfds710/build/wdk_7.1/runme_before_win_kernel_dynamic_lib_build.bat deleted file mode 100644 index 3de69b1..0000000 --- a/liblfds710/build/wdk_7.1/runme_before_win_kernel_dynamic_lib_build.bat +++ /dev/null @@ -1,24 +0,0 @@ -@echo off -rmdir /q /s single_dir_for_windows_kernel 1>nul 2>nul -mkdir single_dir_for_windows_kernel 1>nul 2>nul - -copy /y ..\..\src\lfds710_btree_addonly_unbalanced\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_freelist\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_hash_addonly\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_list_addonly_singlylinked_ordered\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_list_addonly_singlylinked_unordered\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_misc\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_prng\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_queue_bounded_manyproducer_manyconsumer\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_queue_bounded_singleproducer_singleconsumer\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_queue_unbounded_manyproducer_manyconsumer\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_ringbuffer\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_stack\* single_dir_for_windows_kernel\ 1>nul 2>nul - -copy /y ..\..\src\liblfds710_internal.h single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y driver_entry_renamed_to_avoid_compiler_warning.c single_dir_for_windows_kernel\driver_entry.c 1>nul 2>nul -copy /y sources.dynamic single_dir_for_windows_kernel\sources 1>nul 2>nul - -echo Windows kernel dynamic library build directory structure created. -echo (Note the effects of this batch file are idempotent). - diff --git a/liblfds710/build/wdk_7.1/runme_before_win_kernel_static_lib_build.bat b/liblfds710/build/wdk_7.1/runme_before_win_kernel_static_lib_build.bat deleted file mode 100644 index aa69343..0000000 --- a/liblfds710/build/wdk_7.1/runme_before_win_kernel_static_lib_build.bat +++ /dev/null @@ -1,23 +0,0 @@ -@echo off -rmdir /q /s single_dir_for_windows_kernel 1>nul 2>nul -mkdir single_dir_for_windows_kernel 1>nul 2>nul - -copy /y ..\..\src\lfds710_btree_addonly_unbalanced\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_freelist\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_hash_addonly\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_list_addonly_singlylinked_ordered\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_list_addonly_singlylinked_unordered\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_misc\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_prng\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_queue_bounded_manyproducer_manyconsumer\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_queue_bounded_singleproducer_singleconsumer\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_queue_unbounded_manyproducer_manyconsumer\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_ringbuffer\* single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y ..\..\src\lfds710_stack\* single_dir_for_windows_kernel\ 1>nul 2>nul - -copy /y ..\..\src\liblfds710_internal.h single_dir_for_windows_kernel\ 1>nul 2>nul -copy /y sources.static single_dir_for_windows_kernel\sources 1>nul 2>nul - -echo Windows kernel static library build directory structure created. -echo (Note the effects of this batch file are idempotent). - diff --git a/liblfds710/build/wdk_7.1/sources.dynamic b/liblfds710/build/wdk_7.1/sources.dynamic deleted file mode 100644 index 8f19574..0000000 --- a/liblfds710/build/wdk_7.1/sources.dynamic +++ /dev/null @@ -1,66 +0,0 @@ -MSC_WARNING_LEVEL = /WX /wd4127 /W4 -DLLDEF = ../liblfds710.def -TARGETNAME = liblfds710 -TARGETPATH = ../../../bin/ -TARGETTYPE = EXPORT_DRIVER -UMTYPE = nt -USER_C_FLAGS = /DKERNEL_MODE /DNDEBUG - -INCLUDES = ../../../inc/ -SOURCES = lfds710_btree_addonly_unbalanced_cleanup.c \ - lfds710_btree_addonly_unbalanced_get.c \ - lfds710_btree_addonly_unbalanced_init.c \ - lfds710_btree_addonly_unbalanced_insert.c \ - lfds710_btree_addonly_unbalanced_query.c \ - lfds710_freelist_cleanup.c \ - lfds710_freelist_init.c \ - lfds710_freelist_pop.c \ - lfds710_freelist_push.c \ - lfds710_freelist_query.c \ - lfds710_hash_addonly_cleanup.c \ - lfds710_hash_addonly_get.c \ - lfds710_hash_addonly_init.c \ - lfds710_hash_addonly_insert.c \ - lfds710_hash_addonly_iterate.c \ - lfds710_hash_addonly_query.c \ - lfds710_list_addonly_singlylinked_ordered_cleanup.c \ - lfds710_list_addonly_singlylinked_ordered_get.c \ - lfds710_list_addonly_singlylinked_ordered_init.c \ - lfds710_list_addonly_singlylinked_ordered_insert.c \ - lfds710_list_addonly_singlylinked_ordered_query.c \ - lfds710_list_addonly_singlylinked_unordered_cleanup.c \ - lfds710_list_addonly_singlylinked_unordered_get.c \ - lfds710_list_addonly_singlylinked_unordered_init.c \ - lfds710_list_addonly_singlylinked_unordered_insert.c \ - lfds710_list_addonly_singlylinked_unordered_query.c \ - lfds710_misc_globals.c \ - lfds710_misc_internal_backoff_init.c \ - lfds710_misc_query.c \ - lfds710_prng_init.c \ - lfds710_queue_bounded_manyproducer_manyconsumer_cleanup.c \ - lfds710_queue_bounded_manyproducer_manyconsumer_dequeue.c \ - lfds710_queue_bounded_manyproducer_manyconsumer_enqueue.c \ - lfds710_queue_bounded_manyproducer_manyconsumer_init.c \ - lfds710_queue_bounded_manyproducer_manyconsumer_query.c \ - lfds710_queue_bounded_singleproducer_singleconsumer_cleanup.c \ - lfds710_queue_bounded_singleproducer_singleconsumer_dequeue.c \ - lfds710_queue_bounded_singleproducer_singleconsumer_enqueue.c \ - lfds710_queue_bounded_singleproducer_singleconsumer_init.c \ - lfds710_queue_bounded_singleproducer_singleconsumer_query.c \ - lfds710_queue_unbounded_manyproducer_manyconsumer_cleanup.c \ - lfds710_queue_unbounded_manyproducer_manyconsumer_dequeue.c \ - lfds710_queue_unbounded_manyproducer_manyconsumer_enqueue.c \ - lfds710_queue_unbounded_manyproducer_manyconsumer_init.c \ - lfds710_queue_unbounded_manyproducer_manyconsumer_query.c \ - lfds710_ringbuffer_cleanup.c \ - lfds710_ringbuffer_init.c \ - lfds710_ringbuffer_query.c \ - lfds710_ringbuffer_read.c \ - lfds710_ringbuffer_write.c \ - lfds710_stack_cleanup.c \ - lfds710_stack_init.c \ - lfds710_stack_pop.c \ - lfds710_stack_push.c \ - lfds710_stack_query.c \ - driver_entry.c - diff --git a/liblfds710/build/wdk_7.1/sources.static b/liblfds710/build/wdk_7.1/sources.static deleted file mode 100644 index c9724d4..0000000 --- a/liblfds710/build/wdk_7.1/sources.static +++ /dev/null @@ -1,64 +0,0 @@ -MSC_WARNING_LEVEL = /WX /wd4127 /W4 -TARGETNAME = liblfds710 -TARGETPATH = ../../../bin/ -TARGETTYPE = DRIVER_LIBRARY -UMTYPE = nt -USER_C_FLAGS = /DKERNEL_MODE /DNDEBUG - -INCLUDES = ../../../inc/ -SOURCES = lfds710_btree_addonly_unbalanced_cleanup.c \ - lfds710_btree_addonly_unbalanced_get.c \ - lfds710_btree_addonly_unbalanced_init.c \ - lfds710_btree_addonly_unbalanced_insert.c \ - lfds710_btree_addonly_unbalanced_query.c \ - lfds710_freelist_cleanup.c \ - lfds710_freelist_init.c \ - lfds710_freelist_pop.c \ - lfds710_freelist_push.c \ - lfds710_freelist_query.c \ - lfds710_hash_addonly_cleanup.c \ - lfds710_hash_addonly_get.c \ - lfds710_hash_addonly_init.c \ - lfds710_hash_addonly_insert.c \ - lfds710_hash_addonly_iterate.c \ - lfds710_hash_addonly_query.c \ - lfds710_list_addonly_singlylinked_ordered_cleanup.c \ - lfds710_list_addonly_singlylinked_ordered_get.c \ - lfds710_list_addonly_singlylinked_ordered_init.c \ - lfds710_list_addonly_singlylinked_ordered_insert.c \ - lfds710_list_addonly_singlylinked_ordered_query.c \ - lfds710_list_addonly_singlylinked_unordered_cleanup.c \ - lfds710_list_addonly_singlylinked_unordered_get.c \ - lfds710_list_addonly_singlylinked_unordered_init.c \ - lfds710_list_addonly_singlylinked_unordered_insert.c \ - lfds710_list_addonly_singlylinked_unordered_query.c \ - lfds710_misc_globals.c \ - lfds710_misc_internal_backoff_init.c \ - lfds710_misc_query.c \ - lfds710_prng_init.c \ - lfds710_queue_bounded_manyproducer_manyconsumer_cleanup.c \ - lfds710_queue_bounded_manyproducer_manyconsumer_dequeue.c \ - lfds710_queue_bounded_manyproducer_manyconsumer_enqueue.c \ - lfds710_queue_bounded_manyproducer_manyconsumer_init.c \ - lfds710_queue_bounded_manyproducer_manyconsumer_query.c \ - lfds710_queue_bounded_singleproducer_singleconsumer_cleanup.c \ - lfds710_queue_bounded_singleproducer_singleconsumer_dequeue.c \ - lfds710_queue_bounded_singleproducer_singleconsumer_enqueue.c \ - lfds710_queue_bounded_singleproducer_singleconsumer_init.c \ - lfds710_queue_bounded_singleproducer_singleconsumer_query.c \ - lfds710_queue_unbounded_manyproducer_manyconsumer_cleanup.c \ - lfds710_queue_unbounded_manyproducer_manyconsumer_dequeue.c \ - lfds710_queue_unbounded_manyproducer_manyconsumer_enqueue.c \ - lfds710_queue_unbounded_manyproducer_manyconsumer_init.c \ - lfds710_queue_unbounded_manyproducer_manyconsumer_query.c \ - lfds710_ringbuffer_cleanup.c \ - lfds710_ringbuffer_init.c \ - lfds710_ringbuffer_query.c \ - lfds710_ringbuffer_read.c \ - lfds710_ringbuffer_write.c \ - lfds710_stack_cleanup.c \ - lfds710_stack_init.c \ - lfds710_stack_pop.c \ - lfds710_stack_push.c \ - lfds710_stack_query.c - diff --git a/liblfds710/inc/liblfds710.h b/liblfds710/inc/liblfds710.h deleted file mode 100644 index 367c8fc..0000000 --- a/liblfds710/inc/liblfds710.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef LIBLFDS710_H - - /***** defines *****/ - #define LIBLFDS710_H - - /***** pragmas on *****/ - #pragma warning( push ) - #pragma warning( disable : 4324 ) // TRD : 4324 disables MSVC warnings for structure alignment padding due to alignment specifiers - #pragma prefast( disable : 28113 28182 28183, "blah" ) - - /***** includes *****/ - #include "liblfds710/lfds710_porting_abstraction_layer_compiler.h" - #include "liblfds710/lfds710_porting_abstraction_layer_operating_system.h" - #include "liblfds710/lfds710_porting_abstraction_layer_processor.h" - - #include "liblfds710/lfds710_prng.h" // TRD : misc requires prng - #include "liblfds710/lfds710_misc.h" // TRD : everything after depends on misc - #include "liblfds710/lfds710_btree_addonly_unbalanced.h" // TRD : hash_addonly depends on btree_addonly_unbalanced - #include "liblfds710/lfds710_freelist.h" - #include "liblfds710/lfds710_hash_addonly.h" - #include "liblfds710/lfds710_list_addonly_singlylinked_ordered.h" - #include "liblfds710/lfds710_list_addonly_singlylinked_unordered.h" - #include "liblfds710/lfds710_queue_bounded_manyproducer_manyconsumer.h" - #include "liblfds710/lfds710_queue_bounded_singleproducer_singleconsumer.h" - #include "liblfds710/lfds710_queue_unbounded_manyproducer_manyconsumer.h" - #include "liblfds710/lfds710_ringbuffer.h" - #include "liblfds710/lfds710_stack.h" - - /***** pragmas off *****/ - #pragma warning( pop ) - -#endif - diff --git a/liblfds710/inc/liblfds710/lfds710_btree_addonly_unbalanced.h b/liblfds710/inc/liblfds710/lfds710_btree_addonly_unbalanced.h deleted file mode 100644 index 5984928..0000000 --- a/liblfds710/inc/liblfds710/lfds710_btree_addonly_unbalanced.h +++ /dev/null @@ -1,121 +0,0 @@ -/***** defines *****/ -#define LFDS710_BTREE_AU_GET_KEY_FROM_ELEMENT( btree_au_element ) ( (btree_au_element).key ) -#define LFDS710_BTREE_AU_SET_KEY_IN_ELEMENT( btree_au_element, new_key ) ( (btree_au_element).key = (void *) (lfds710_pal_uint_t) (new_key) ) -#define LFDS710_BTREE_AU_GET_VALUE_FROM_ELEMENT( btree_au_element ) ( LFDS710_MISC_BARRIER_LOAD, (btree_au_element).value ) -#define LFDS710_BTREE_AU_SET_VALUE_IN_ELEMENT( btree_au_element, new_value ) { LFDS710_PAL_ATOMIC_SET( &(btree_au_element).value, new_value ); } -#define LFDS710_BTREE_AU_GET_USER_STATE_FROM_STATE( btree_au_state ) ( (btree_au_state).user_state ) - -/***** enums *****/ -enum lfds710_btree_au_absolute_position -{ - LFDS710_BTREE_AU_ABSOLUTE_POSITION_ROOT, - LFDS710_BTREE_AU_ABSOLUTE_POSITION_SMALLEST_IN_TREE, - LFDS710_BTREE_AU_ABSOLUTE_POSITION_LARGEST_IN_TREE -}; - -enum lfds710_btree_au_existing_key -{ - LFDS710_BTREE_AU_EXISTING_KEY_OVERWRITE, - LFDS710_BTREE_AU_EXISTING_KEY_FAIL -}; - -enum lfds710_btree_au_insert_result -{ - LFDS710_BTREE_AU_INSERT_RESULT_FAILURE_EXISTING_KEY, - LFDS710_BTREE_AU_INSERT_RESULT_SUCCESS_OVERWRITE, - LFDS710_BTREE_AU_INSERT_RESULT_SUCCESS -}; - -enum lfds710_btree_au_query -{ - LFDS710_BTREE_AU_QUERY_GET_POTENTIALLY_INACCURATE_COUNT, - LFDS710_BTREE_AU_QUERY_SINGLETHREADED_VALIDATE -}; - -enum lfds710_btree_au_relative_position -{ - LFDS710_BTREE_AU_RELATIVE_POSITION_UP, - LFDS710_BTREE_AU_RELATIVE_POSITION_LEFT, - LFDS710_BTREE_AU_RELATIVE_POSITION_RIGHT, - LFDS710_BTREE_AU_RELATIVE_POSITION_SMALLEST_ELEMENT_BELOW_CURRENT_ELEMENT, - LFDS710_BTREE_AU_RELATIVE_POSITION_LARGEST_ELEMENT_BELOW_CURRENT_ELEMENT, - LFDS710_BTREE_AU_RELATIVE_POSITION_NEXT_SMALLER_ELEMENT_IN_ENTIRE_TREE, - LFDS710_BTREE_AU_RELATIVE_POSITION_NEXT_LARGER_ELEMENT_IN_ENTIRE_TREE -}; - -/***** structs *****/ -struct lfds710_btree_au_element -{ - /* TRD : we are add-only, so these elements are only written once - as such, the write is wholly negligible - we are only concerned with getting as many structs in one cache line as we can - */ - - struct lfds710_btree_au_element LFDS710_PAL_ALIGN(LFDS710_PAL_ALIGN_SINGLE_POINTER) - *volatile left, - *volatile right, - *volatile up; - - void LFDS710_PAL_ALIGN(LFDS710_PAL_ALIGN_SINGLE_POINTER) - *volatile value; - - void - *key; -}; - -struct lfds710_btree_au_state -{ - struct lfds710_btree_au_element LFDS710_PAL_ALIGN(LFDS710_PAL_ALIGN_SINGLE_POINTER) - *volatile root; - - int - (*key_compare_function)( void const *new_key, void const *existing_key ); - - enum lfds710_btree_au_existing_key - existing_key; - - void - *user_state; - - struct lfds710_misc_backoff_state - insert_backoff; -}; - -/***** public prototypes *****/ -void lfds710_btree_au_init_valid_on_current_logical_core( struct lfds710_btree_au_state *baus, - int (*key_compare_function)(void const *new_key, void const *existing_key), - enum lfds710_btree_au_existing_key existing_key, - void *user_state ); - // TRD : used in conjunction with the #define LFDS710_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE - -void lfds710_btree_au_cleanup( struct lfds710_btree_au_state *baus, - void (*element_cleanup_callback)(struct lfds710_btree_au_state *baus, struct lfds710_btree_au_element *baue) ); - -enum lfds710_btree_au_insert_result lfds710_btree_au_insert( struct lfds710_btree_au_state *baus, - struct lfds710_btree_au_element *baue, - struct lfds710_btree_au_element **existing_baue ); - // TRD : if a link collides with an existing key and existing_baue is non-NULL, existing_baue is set to the existing element - -int lfds710_btree_au_get_by_key( struct lfds710_btree_au_state *baus, - int (*key_compare_function)(void const *new_key, void const *existing_key), - void *key, - struct lfds710_btree_au_element **baue ); - -int lfds710_btree_au_get_by_absolute_position_and_then_by_relative_position( struct lfds710_btree_au_state *baus, - struct lfds710_btree_au_element **baue, - enum lfds710_btree_au_absolute_position absolute_position, - enum lfds710_btree_au_relative_position relative_position ); - // TRD : if *baue is NULL, we get the element at position, otherwise we move from *baue according to direction - -int lfds710_btree_au_get_by_absolute_position( struct lfds710_btree_au_state *baus, - struct lfds710_btree_au_element **baue, - enum lfds710_btree_au_absolute_position absolute_position ); - -int lfds710_btree_au_get_by_relative_position( struct lfds710_btree_au_element **baue, - enum lfds710_btree_au_relative_position relative_position ); - -void lfds710_btree_au_query( struct lfds710_btree_au_state *baus, - enum lfds710_btree_au_query query_type, - void *query_input, - void *query_output ); - diff --git a/liblfds710/inc/liblfds710/lfds710_freelist.h b/liblfds710/inc/liblfds710/lfds710_freelist.h deleted file mode 100644 index 73c3315..0000000 --- a/liblfds710/inc/liblfds710/lfds710_freelist.h +++ /dev/null @@ -1,70 +0,0 @@ -/***** defines *****/ -#define LFDS710_FREELIST_GET_KEY_FROM_ELEMENT( freelist_element ) ( (freelist_element).key ) -#define LFDS710_FREELIST_SET_KEY_IN_ELEMENT( freelist_element, new_key ) ( (freelist_element).key = (void *) (lfds710_pal_uint_t) (new_key) ) -#define LFDS710_FREELIST_GET_VALUE_FROM_ELEMENT( freelist_element ) ( (freelist_element).value ) -#define LFDS710_FREELIST_SET_VALUE_IN_ELEMENT( freelist_element, new_value ) ( (freelist_element).value = (void *) (lfds710_pal_uint_t) (new_value) ) -#define LFDS710_FREELIST_GET_USER_STATE_FROM_STATE( freelist_state ) ( (freelist_state).user_state ) - -#define LFDS710_FREELIST_ELIMINATION_ARRAY_ELEMENT_SIZE_IN_FREELIST_ELEMENTS ( LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES / sizeof(struct lfds710_freelist_element *) ) - -/***** enums *****/ -enum lfds710_freelist_query -{ - LFDS710_FREELIST_QUERY_SINGLETHREADED_GET_COUNT, - LFDS710_FREELIST_QUERY_SINGLETHREADED_VALIDATE, - LFDS710_FREELIST_QUERY_GET_ELIMINATION_ARRAY_EXTRA_ELEMENTS_IN_FREELIST_ELEMENTS -}; - -/***** structures *****/ -struct lfds710_freelist_element -{ - struct lfds710_freelist_element - *next; - - void - *key, - *value; -}; - -struct lfds710_freelist_state -{ - struct lfds710_freelist_element LFDS710_PAL_ALIGN(LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES) - *volatile top[PAC_SIZE]; - - lfds710_pal_uint_t LFDS710_PAL_ALIGN(LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES) - elimination_array_size_in_elements; - - struct lfds710_freelist_element * volatile - (*elimination_array)[LFDS710_FREELIST_ELIMINATION_ARRAY_ELEMENT_SIZE_IN_FREELIST_ELEMENTS]; - - void - *user_state; - - struct lfds710_misc_backoff_state - pop_backoff, - push_backoff; -}; - -/***** public prototypes *****/ -void lfds710_freelist_init_valid_on_current_logical_core( struct lfds710_freelist_state *fs, - struct lfds710_freelist_element * volatile (*elimination_array)[LFDS710_FREELIST_ELIMINATION_ARRAY_ELEMENT_SIZE_IN_FREELIST_ELEMENTS], - lfds710_pal_uint_t elimination_array_size_in_elements, - void *user_state ); - // TRD : used in conjunction with the #define LFDS710_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE - -void lfds710_freelist_cleanup( struct lfds710_freelist_state *fs, - void (*element_cleanup_callback)(struct lfds710_freelist_state *fs, struct lfds710_freelist_element *fe) ); - -void lfds710_freelist_push( struct lfds710_freelist_state *fs, - struct lfds710_freelist_element *fe, - struct lfds710_prng_st_state *psts ); - -int lfds710_freelist_pop( struct lfds710_freelist_state *fs, - struct lfds710_freelist_element **fe, - struct lfds710_prng_st_state *psts ); - -void lfds710_freelist_query( struct lfds710_freelist_state *fs, - enum lfds710_freelist_query query_type, - void *query_input, - void *query_output ); - diff --git a/liblfds710/inc/liblfds710/lfds710_hash_addonly.h b/liblfds710/inc/liblfds710/lfds710_hash_addonly.h deleted file mode 100644 index ea60bfa..0000000 --- a/liblfds710/inc/liblfds710/lfds710_hash_addonly.h +++ /dev/null @@ -1,136 +0,0 @@ -/***** defines *****/ -#define LFDS710_HASH_A_GET_KEY_FROM_ELEMENT( hash_a_element ) ( (hash_a_element).key ) -#define LFDS710_HASH_A_SET_KEY_IN_ELEMENT( hash_a_element, new_key ) ( (hash_a_element).key = (void *) (lfds710_pal_uint_t) (new_key) ) -#define LFDS710_HASH_A_GET_VALUE_FROM_ELEMENT( hash_a_element ) ( LFDS710_MISC_BARRIER_LOAD, (hash_a_element).value ) -#define LFDS710_HASH_A_SET_VALUE_IN_ELEMENT( hash_a_element, new_value ) { LFDS710_PAL_ATOMIC_SET( &(hash_a_element).value, new_value ); } -#define LFDS710_HASH_A_GET_USER_STATE_FROM_STATE( hash_a_state ) ( (hash_a_state).user_state ) - -// TRD : a quality hash function, provided for user convenience - note hash must be initialized to 0 before the first call by the user - -#if( LFDS710_PAL_ALIGN_SINGLE_POINTER == 4 ) - // TRD : void *data, lfds710_pal_uint_t data_length_in_bytes, lfds710_pal_uint_t hash - #define LFDS710_HASH_A_HASH_FUNCTION( data, data_length_in_bytes, hash ) { \ - lfds710_pal_uint_t \ - loop; \ - \ - for( loop = 0 ; loop < (data_length_in_bytes) ; loop++ ) \ - { \ - (hash) += *( (char unsigned *) (data) + loop ); \ - (hash) = ((hash) ^ ((hash) >> 16)) * 0x85ebca6bUL; \ - (hash) = ((hash) ^ ((hash) >> 13)) * 0xc2b2ae35UL; \ - (hash) = (hash ^ (hash >> 16)); \ - } \ - } -#endif - -#if( LFDS710_PAL_ALIGN_SINGLE_POINTER == 8 ) - // TRD : void *data, lfds710_pal_uint_t data_length_in_bytes, lfds710_pal_uint_t hash - #define LFDS710_HASH_A_HASH_FUNCTION( data, data_length_in_bytes, hash ) { \ - lfds710_pal_uint_t \ - loop; \ - \ - for( loop = 0 ; loop < (data_length_in_bytes) ; loop++ ) \ - { \ - (hash) += *( (char unsigned *) (data) + loop ); \ - (hash) = ((hash) ^ ((hash) >> 30)) * 0xBF58476D1CE4E5B9ULL; \ - (hash) = ((hash) ^ ((hash) >> 27)) * 0x94D049BB133111EBULL; \ - (hash) = (hash ^ (hash >> 31)); \ - } \ - } -#endif - -/***** enums *****/ -enum lfds710_hash_a_existing_key -{ - LFDS710_HASH_A_EXISTING_KEY_OVERWRITE, - LFDS710_HASH_A_EXISTING_KEY_FAIL -}; - -enum lfds710_hash_a_insert_result -{ - LFDS710_HASH_A_PUT_RESULT_FAILURE_EXISTING_KEY, - LFDS710_HASH_A_PUT_RESULT_SUCCESS_OVERWRITE, - LFDS710_HASH_A_PUT_RESULT_SUCCESS -}; - -enum lfds710_hash_a_query -{ - LFDS710_HASH_A_QUERY_GET_POTENTIALLY_INACCURATE_COUNT, - LFDS710_HASH_A_QUERY_SINGLETHREADED_VALIDATE -}; - -/***** structs *****/ -struct lfds710_hash_a_element -{ - struct lfds710_btree_au_element - baue; - - void - *key; - - void LFDS710_PAL_ALIGN(LFDS710_PAL_ALIGN_SINGLE_POINTER) - *volatile value; -}; - -struct lfds710_hash_a_iterate -{ - struct lfds710_btree_au_element - *baue; - - struct lfds710_btree_au_state - *baus, - *baus_end; -}; - -struct lfds710_hash_a_state -{ - enum lfds710_hash_a_existing_key - existing_key; - - int - (*key_compare_function)( void const *new_key, void const *existing_key ); - - lfds710_pal_uint_t - array_size; - - struct lfds710_btree_au_state - *baus_array; - - void - (*element_cleanup_callback)( struct lfds710_hash_a_state *has, struct lfds710_hash_a_element *hae ), - (*key_hash_function)( void const *key, lfds710_pal_uint_t *hash ), - *user_state; -}; - -/***** public prototypes *****/ -void lfds710_hash_a_init_valid_on_current_logical_core( struct lfds710_hash_a_state *has, - struct lfds710_btree_au_state *baus_array, - lfds710_pal_uint_t array_size, - int (*key_compare_function)(void const *new_key, void const *existing_key), - void (*key_hash_function)(void const *key, lfds710_pal_uint_t *hash), - enum lfds710_hash_a_existing_key existing_key, - void *user_state ); - // TRD : used in conjunction with the #define LFDS710_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE - -void lfds710_hash_a_cleanup( struct lfds710_hash_a_state *has, - void (*element_cleanup_function)(struct lfds710_hash_a_state *has, struct lfds710_hash_a_element *hae) ); - -enum lfds710_hash_a_insert_result lfds710_hash_a_insert( struct lfds710_hash_a_state *has, - struct lfds710_hash_a_element *hae, - struct lfds710_hash_a_element **existing_hae ); - // TRD : if existing_value is not NULL and the key exists, existing_hae is set to the hash element of the existing key - -int lfds710_hash_a_get_by_key( struct lfds710_hash_a_state *has, - int (*key_compare_function)(void const *new_key, void const *existing_key), - void (*key_hash_function)(void const *key, lfds710_pal_uint_t *hash), - void *key, - struct lfds710_hash_a_element **hae ); - -void lfds710_hash_a_iterate_init( struct lfds710_hash_a_state *has, struct lfds710_hash_a_iterate *hai ); -int lfds710_hash_a_iterate( struct lfds710_hash_a_iterate *hai, struct lfds710_hash_a_element **hae ); - -void lfds710_hash_a_query( struct lfds710_hash_a_state *has, - enum lfds710_hash_a_query query_type, - void *query_input, - void *query_output ); - diff --git a/liblfds710/inc/liblfds710/lfds710_list_addonly_singlylinked_ordered.h b/liblfds710/inc/liblfds710/lfds710_list_addonly_singlylinked_ordered.h deleted file mode 100644 index 8b540a1..0000000 --- a/liblfds710/inc/liblfds710/lfds710_list_addonly_singlylinked_ordered.h +++ /dev/null @@ -1,87 +0,0 @@ -/***** defines *****/ -#define LFDS710_LIST_ASO_GET_START( list_aso_state ) ( LFDS710_MISC_BARRIER_LOAD, (list_aso_state).start->next ) -#define LFDS710_LIST_ASO_GET_NEXT( list_aso_element ) ( LFDS710_MISC_BARRIER_LOAD, (list_aso_element).next ) -#define LFDS710_LIST_ASO_GET_START_AND_THEN_NEXT( list_aso_state, pointer_to_list_aso_element ) ( (pointer_to_list_aso_element) == NULL ? ( (pointer_to_list_aso_element) = LFDS710_LIST_ASO_GET_START(list_aso_state) ) : ( (pointer_to_list_aso_element) = LFDS710_LIST_ASO_GET_NEXT(*(pointer_to_list_aso_element)) ) ) -#define LFDS710_LIST_ASO_GET_KEY_FROM_ELEMENT( list_aso_element ) ( (list_aso_element).key ) -#define LFDS710_LIST_ASO_SET_KEY_IN_ELEMENT( list_aso_element, new_key ) ( (list_aso_element).key = (void *) (lfds710_pal_uint_t) (new_key) ) -#define LFDS710_LIST_ASO_GET_VALUE_FROM_ELEMENT( list_aso_element ) ( LFDS710_MISC_BARRIER_LOAD, (list_aso_element).value ) -#define LFDS710_LIST_ASO_SET_VALUE_IN_ELEMENT( list_aso_element, new_value ) { LFDS710_PAL_ATOMIC_SET( &(list_aso_element).value, new_value ); } -#define LFDS710_LIST_ASO_GET_USER_STATE_FROM_STATE( list_aso_state ) ( (list_aso_state).user_state ) - -/***** enums *****/ -enum lfds710_list_aso_existing_key -{ - LFDS710_LIST_ASO_EXISTING_KEY_OVERWRITE, - LFDS710_LIST_ASO_EXISTING_KEY_FAIL -}; - -enum lfds710_list_aso_insert_result -{ - LFDS710_LIST_ASO_INSERT_RESULT_FAILURE_EXISTING_KEY, - LFDS710_LIST_ASO_INSERT_RESULT_SUCCESS_OVERWRITE, - LFDS710_LIST_ASO_INSERT_RESULT_SUCCESS -}; - -enum lfds710_list_aso_query -{ - LFDS710_LIST_ASO_QUERY_GET_POTENTIALLY_INACCURATE_COUNT, - LFDS710_LIST_ASO_QUERY_SINGLETHREADED_VALIDATE -}; - -/***** structures *****/ -struct lfds710_list_aso_element -{ - struct lfds710_list_aso_element LFDS710_PAL_ALIGN(LFDS710_PAL_ALIGN_SINGLE_POINTER) - *volatile next; - - void LFDS710_PAL_ALIGN(LFDS710_PAL_ALIGN_SINGLE_POINTER) - *volatile value; - - void - *key; -}; - -struct lfds710_list_aso_state -{ - struct lfds710_list_aso_element LFDS710_PAL_ALIGN(LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES) - dummy_element; - - struct lfds710_list_aso_element LFDS710_PAL_ALIGN(LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES) - *start; - - int - (*key_compare_function)( void const *new_key, void const *existing_key ); - - enum lfds710_list_aso_existing_key - existing_key; - - void - *user_state; - - struct lfds710_misc_backoff_state - insert_backoff; -}; - -/***** public prototypes *****/ -void lfds710_list_aso_init_valid_on_current_logical_core( struct lfds710_list_aso_state *lasos, - int (*key_compare_function)(void const *new_key, void const *existing_key), - enum lfds710_list_aso_existing_key existing_key, - void *user_state ); - // TRD : used in conjunction with the #define LFDS710_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE - -void lfds710_list_aso_cleanup( struct lfds710_list_aso_state *lasos, - void (*element_cleanup_callback)(struct lfds710_list_aso_state *lasos, struct lfds710_list_aso_element *lasoe) ); - -enum lfds710_list_aso_insert_result lfds710_list_aso_insert( struct lfds710_list_aso_state *lasos, - struct lfds710_list_aso_element *lasoe, - struct lfds710_list_aso_element **existing_lasoe ); - -int lfds710_list_aso_get_by_key( struct lfds710_list_aso_state *lasos, - void *key, - struct lfds710_list_aso_element **lasoe ); - -void lfds710_list_aso_query( struct lfds710_list_aso_state *lasos, - enum lfds710_list_aso_query query_type, - void *query_input, - void *query_output ); - diff --git a/liblfds710/inc/liblfds710/lfds710_list_addonly_singlylinked_unordered.h b/liblfds710/inc/liblfds710/lfds710_list_addonly_singlylinked_unordered.h deleted file mode 100644 index 5bb32c4..0000000 --- a/liblfds710/inc/liblfds710/lfds710_list_addonly_singlylinked_unordered.h +++ /dev/null @@ -1,90 +0,0 @@ -/***** defines *****/ -#define LFDS710_LIST_ASU_GET_START( list_asu_state ) ( LFDS710_MISC_BARRIER_LOAD, (list_asu_state).start->next ) -#define LFDS710_LIST_ASU_GET_NEXT( list_asu_element ) ( LFDS710_MISC_BARRIER_LOAD, (list_asu_element).next ) -#define LFDS710_LIST_ASU_GET_START_AND_THEN_NEXT( list_asu_state, pointer_to_list_asu_element ) ( (pointer_to_list_asu_element) == NULL ? ( (pointer_to_list_asu_element) = LFDS710_LIST_ASU_GET_START(list_asu_state) ) : ( (pointer_to_list_asu_element) = LFDS710_LIST_ASU_GET_NEXT(*(pointer_to_list_asu_element)) ) ) -#define LFDS710_LIST_ASU_GET_KEY_FROM_ELEMENT( list_asu_element ) ( (list_asu_element).key ) -#define LFDS710_LIST_ASU_SET_KEY_IN_ELEMENT( list_asu_element, new_key ) ( (list_asu_element).key = (void *) (lfds710_pal_uint_t) (new_key) ) -#define LFDS710_LIST_ASU_GET_VALUE_FROM_ELEMENT( list_asu_element ) ( LFDS710_MISC_BARRIER_LOAD, (list_asu_element).value ) -#define LFDS710_LIST_ASU_SET_VALUE_IN_ELEMENT( list_asu_element, new_value ) { LFDS710_PAL_ATOMIC_SET( &(list_asu_element).value, new_value ); } -#define LFDS710_LIST_ASU_GET_USER_STATE_FROM_STATE( list_asu_state ) ( (list_asu_state).user_state ) - -/***** enums *****/ -enum lfds710_list_asu_position -{ - LFDS710_LIST_ASU_POSITION_START, - LFDS710_LIST_ASU_POSITION_END, - LFDS710_LIST_ASU_POSITION_AFTER -}; - -enum lfds710_list_asu_query -{ - LFDS710_LIST_ASU_QUERY_GET_POTENTIALLY_INACCURATE_COUNT, - LFDS710_LIST_ASU_QUERY_SINGLETHREADED_VALIDATE -}; - -/***** structures *****/ -struct lfds710_list_asu_element -{ - struct lfds710_list_asu_element LFDS710_PAL_ALIGN(LFDS710_PAL_ALIGN_SINGLE_POINTER) - *volatile next; - - void LFDS710_PAL_ALIGN(LFDS710_PAL_ALIGN_SINGLE_POINTER) - *volatile value; - - void - *key; -}; - -struct lfds710_list_asu_state -{ - struct lfds710_list_asu_element LFDS710_PAL_ALIGN(LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES) - dummy_element; - - struct lfds710_list_asu_element LFDS710_PAL_ALIGN(LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES) - *volatile end; - - struct lfds710_list_asu_element LFDS710_PAL_ALIGN(LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES) - *start; - - void - *user_state; - - struct lfds710_misc_backoff_state - after_backoff, - end_backoff, - start_backoff; -}; - -/***** public prototypes *****/ -void lfds710_list_asu_init_valid_on_current_logical_core( struct lfds710_list_asu_state *lasus, - void *user_state ); - // TRD : used in conjunction with the #define LFDS710_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE - -void lfds710_list_asu_cleanup( struct lfds710_list_asu_state *lasus, - void (*element_cleanup_callback)(struct lfds710_list_asu_state *lasus, struct lfds710_list_asu_element *lasue) ); - -void lfds710_list_asu_insert_at_position( struct lfds710_list_asu_state *lasus, - struct lfds710_list_asu_element *lasue, - struct lfds710_list_asu_element *lasue_predecessor, - enum lfds710_list_asu_position position ); - -void lfds710_list_asu_insert_at_start( struct lfds710_list_asu_state *lasus, - struct lfds710_list_asu_element *lasue ); - -void lfds710_list_asu_insert_at_end( struct lfds710_list_asu_state *lasus, - struct lfds710_list_asu_element *lasue ); - -void lfds710_list_asu_insert_after_element( struct lfds710_list_asu_state *lasus, - struct lfds710_list_asu_element *lasue, - struct lfds710_list_asu_element *lasue_predecessor ); - -int lfds710_list_asu_get_by_key( struct lfds710_list_asu_state *lasus, - int (*key_compare_function)(void const *new_key, void const *existing_key), - void *key, - struct lfds710_list_asu_element **lasue ); - -void lfds710_list_asu_query( struct lfds710_list_asu_state *lasus, - enum lfds710_list_asu_query query_type, - void *query_input, - void *query_output ); - diff --git a/liblfds710/inc/liblfds710/lfds710_misc.h b/liblfds710/inc/liblfds710/lfds710_misc.h deleted file mode 100644 index 929b85d..0000000 --- a/liblfds710/inc/liblfds710/lfds710_misc.h +++ /dev/null @@ -1,233 +0,0 @@ -/***** defines *****/ -#define LFDS710_MISC_VERSION_STRING "7.1.0" -#define LFDS710_MISC_VERSION_INTEGER 710 - -#ifndef NULL - #define NULL ( (void *) 0 ) -#endif - -#define POINTER 0 -#define COUNTER 1 -#define PAC_SIZE 2 - -#define LFDS710_MISC_DELIBERATELY_CRASH { char *c = 0; *c = 0; } - -#if( !defined LFDS710_PAL_ATOMIC_ADD ) - #define LFDS710_PAL_NO_ATOMIC_ADD - #define LFDS710_MISC_ATOMIC_SUPPORT_ADD 0 - #define LFDS710_PAL_ATOMIC_ADD( pointer_to_target, value, result, result_type ) \ - { \ - LFDS710_PAL_ASSERT( !"LFDS710_PAL_ATOMIC_ADD not implemented for this platform." ); \ - LFDS710_MISC_DELIBERATELY_CRASH; \ - } -#else - #define LFDS710_MISC_ATOMIC_SUPPORT_ADD 1 -#endif - -#if( !defined LFDS710_PAL_ATOMIC_CAS ) - #define LFDS710_PAL_NO_ATOMIC_CAS - #define LFDS710_MISC_ATOMIC_SUPPORT_CAS 0 - #define LFDS710_PAL_ATOMIC_CAS( pointer_to_destination, pointer_to_compare, new_destination, cas_strength, result ) \ - { \ - LFDS710_PAL_ASSERT( !"LFDS710_PAL_ATOMIC_CAS not implemented for this platform." ); \ - (result) = 0; \ - LFDS710_MISC_DELIBERATELY_CRASH; \ - } -#else - #define LFDS710_MISC_ATOMIC_SUPPORT_CAS 1 -#endif - -#if( !defined LFDS710_PAL_ATOMIC_DWCAS ) - #define LFDS710_PAL_NO_ATOMIC_DWCAS - #define LFDS710_MISC_ATOMIC_SUPPORT_DWCAS 0 - #define LFDS710_PAL_ATOMIC_DWCAS( pointer_to_destination, pointer_to_compare, pointer_to_new_destination, cas_strength, result ) \ - { \ - LFDS710_PAL_ASSERT( !"LFDS710_PAL_ATOMIC_DWCAS not implemented for this platform." ); \ - (result) = 0; \ - LFDS710_MISC_DELIBERATELY_CRASH; \ - } -#else - #define LFDS710_MISC_ATOMIC_SUPPORT_DWCAS 1 -#endif - -#if( !defined LFDS710_PAL_ATOMIC_EXCHANGE ) - #define LFDS710_PAL_NO_ATOMIC_EXCHANGE - #define LFDS710_MISC_ATOMIC_SUPPORT_EXCHANGE 0 - #define LFDS710_PAL_ATOMIC_EXCHANGE( pointer_to_destination, new_value, original_value, value_type ) \ - { \ - LFDS710_PAL_ASSERT( !"LFDS710_PAL_ATOMIC_EXCHANGE not implemented for this platform." ); \ - LFDS710_MISC_DELIBERATELY_CRASH; \ - } -#else - #define LFDS710_MISC_ATOMIC_SUPPORT_EXCHANGE 1 -#endif - -#if( !defined LFDS710_PAL_ATOMIC_SET ) - #define LFDS710_PAL_NO_ATOMIC_SET - #define LFDS710_MISC_ATOMIC_SUPPORT_SET 0 - #define LFDS710_PAL_ATOMIC_SET( pointer_to_destination, new_value ) \ - { \ - LFDS710_PAL_ASSERT( !"LFDS710_PAL_ATOMIC_SET not implemented for this platform." ); \ - LFDS710_MISC_DELIBERATELY_CRASH; \ - } -#else - #define LFDS710_MISC_ATOMIC_SUPPORT_SET 1 -#endif - -#if( defined LFDS710_PAL_BARRIER_COMPILER_LOAD && defined LFDS710_PAL_BARRIER_PROCESSOR_LOAD ) - #define LFDS710_MISC_BARRIER_LOAD ( LFDS710_PAL_BARRIER_COMPILER_LOAD, LFDS710_PAL_BARRIER_PROCESSOR_LOAD, LFDS710_PAL_BARRIER_COMPILER_LOAD ) -#endif - -#if( (!defined LFDS710_PAL_BARRIER_COMPILER_LOAD || defined LFDS710_PAL_COMPILER_BARRIERS_MISSING_PRESUMED_HAVING_A_GOOD_TIME) && defined LFDS710_PAL_BARRIER_PROCESSOR_LOAD ) - #define LFDS710_MISC_BARRIER_LOAD LFDS710_PAL_BARRIER_PROCESSOR_LOAD -#endif - -#if( defined LFDS710_PAL_BARRIER_COMPILER_LOAD && !defined LFDS710_PAL_BARRIER_PROCESSOR_LOAD ) - #define LFDS710_MISC_BARRIER_LOAD LFDS710_PAL_BARRIER_COMPILER_LOAD -#endif - -#if( !defined LFDS710_PAL_BARRIER_COMPILER_LOAD && !defined LFDS710_PAL_BARRIER_PROCESSOR_LOAD ) - #define LFDS710_MISC_BARRIER_LOAD -#endif - -#if( defined LFDS710_PAL_BARRIER_COMPILER_STORE && defined LFDS710_PAL_BARRIER_PROCESSOR_STORE ) - #define LFDS710_MISC_BARRIER_STORE ( LFDS710_PAL_BARRIER_COMPILER_STORE, LFDS710_PAL_BARRIER_PROCESSOR_STORE, LFDS710_PAL_BARRIER_COMPILER_STORE ) -#endif - -#if( (!defined LFDS710_PAL_BARRIER_COMPILER_STORE || defined LFDS710_PAL_COMPILER_BARRIERS_MISSING_PRESUMED_HAVING_A_GOOD_TIME) && defined LFDS710_PAL_BARRIER_PROCESSOR_STORE ) - #define LFDS710_MISC_BARRIER_STORE LFDS710_PAL_BARRIER_PROCESSOR_STORE -#endif - -#if( defined LFDS710_PAL_BARRIER_COMPILER_STORE && !defined LFDS710_PAL_BARRIER_PROCESSOR_STORE ) - #define LFDS710_MISC_BARRIER_STORE LFDS710_PAL_BARRIER_COMPILER_STORE -#endif - -#if( !defined LFDS710_PAL_BARRIER_COMPILER_STORE && !defined LFDS710_PAL_BARRIER_PROCESSOR_STORE ) - #define LFDS710_MISC_BARRIER_STORE -#endif - -#if( defined LFDS710_PAL_BARRIER_COMPILER_FULL && defined LFDS710_PAL_BARRIER_PROCESSOR_FULL ) - #define LFDS710_MISC_BARRIER_FULL ( LFDS710_PAL_BARRIER_COMPILER_FULL, LFDS710_PAL_BARRIER_PROCESSOR_FULL, LFDS710_PAL_BARRIER_COMPILER_FULL ) -#endif - -#if( (!defined LFDS710_PAL_BARRIER_COMPILER_FULL || defined LFDS710_PAL_COMPILER_BARRIERS_MISSING_PRESUMED_HAVING_A_GOOD_TIME) && defined LFDS710_PAL_BARRIER_PROCESSOR_FULL ) - #define LFDS710_MISC_BARRIER_FULL LFDS710_PAL_BARRIER_PROCESSOR_FULL -#endif - -#if( defined LFDS710_PAL_BARRIER_COMPILER_FULL && !defined LFDS710_PAL_BARRIER_PROCESSOR_FULL ) - #define LFDS710_MISC_BARRIER_FULL LFDS710_PAL_BARRIER_COMPILER_FULL -#endif - -#if( !defined LFDS710_PAL_BARRIER_COMPILER_FULL && !defined LFDS710_PAL_BARRIER_PROCESSOR_FULL ) - #define LFDS710_MISC_BARRIER_FULL -#endif - -#if( (defined LFDS710_PAL_BARRIER_COMPILER_LOAD && defined LFDS710_PAL_BARRIER_COMPILER_STORE && defined LFDS710_PAL_BARRIER_COMPILER_FULL) || (defined LFDS710_PAL_COMPILER_BARRIERS_MISSING_PRESUMED_HAVING_A_GOOD_TIME) ) - #define LFDS710_MISC_ATOMIC_SUPPORT_COMPILER_BARRIERS 1 -#else - #define LFDS710_MISC_ATOMIC_SUPPORT_COMPILER_BARRIERS 0 -#endif - -#if( defined LFDS710_PAL_BARRIER_PROCESSOR_LOAD && defined LFDS710_PAL_BARRIER_PROCESSOR_STORE && defined LFDS710_PAL_BARRIER_PROCESSOR_FULL ) - #define LFDS710_MISC_ATOMIC_SUPPORT_PROCESSOR_BARRIERS 1 -#else - #define LFDS710_MISC_ATOMIC_SUPPORT_PROCESSOR_BARRIERS 0 -#endif - -#define LFDS710_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE LFDS710_MISC_BARRIER_LOAD -#define LFDS710_MISC_FLUSH { LFDS710_MISC_BARRIER_STORE; lfds710_misc_force_store(); } - -/***** enums *****/ -enum lfds710_misc_cas_strength -{ - // TRD : GCC defined values - LFDS710_MISC_CAS_STRENGTH_STRONG = 0, - LFDS710_MISC_CAS_STRENGTH_WEAK = 1, -}; - -enum lfds710_misc_validity -{ - LFDS710_MISC_VALIDITY_UNKNOWN, - LFDS710_MISC_VALIDITY_VALID, - LFDS710_MISC_VALIDITY_INVALID_LOOP, - LFDS710_MISC_VALIDITY_INVALID_MISSING_ELEMENTS, - LFDS710_MISC_VALIDITY_INVALID_ADDITIONAL_ELEMENTS, - LFDS710_MISC_VALIDITY_INVALID_TEST_DATA, - LFDS710_MISC_VALIDITY_INVALID_ORDER, - LFDS710_MISC_VALIDITY_INVALID_ATOMIC_FAILED, - LFDS710_MISC_VALIDITY_INDETERMINATE_NONATOMIC_PASSED, -}; - -enum lfds710_misc_flag -{ - LFDS710_MISC_FLAG_LOWERED, - LFDS710_MISC_FLAG_RAISED -}; - -enum lfds710_misc_query -{ - LFDS710_MISC_QUERY_GET_BUILD_AND_VERSION_STRING -}; - -enum lfds710_misc_data_structure -{ - LFDS710_MISC_DATA_STRUCTURE_BTREE_AU, - LFDS710_MISC_DATA_STRUCTURE_FREELIST, - LFDS710_MISC_DATA_STRUCTURE_HASH_A, - LFDS710_MISC_DATA_STRUCTURE_LIST_AOS, - LFDS710_MISC_DATA_STRUCTURE_LIST_ASU, - LFDS710_MISC_DATA_STRUCTURE_QUEUE_BMM, - LFDS710_MISC_DATA_STRUCTURE_QUEUE_BSS, - LFDS710_MISC_DATA_STRUCTURE_QUEUE_UMM, - LFDS710_MISC_DATA_STRUCTURE_RINGBUFFER, - LFDS710_MISC_DATA_STRUCTURE_STACK, - LFDS710_MISC_DATA_STRUCTURE_COUNT -}; - -/***** struct *****/ -struct lfds710_misc_backoff_state -{ - lfds710_pal_uint_t volatile LFDS710_PAL_ALIGN(LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES) - lock; - - lfds710_pal_uint_t - backoff_iteration_frequency_counters[2], - metric, - total_operations; -}; - -struct lfds710_misc_globals -{ - struct lfds710_prng_state - ps; -}; - -struct lfds710_misc_validation_info -{ - lfds710_pal_uint_t - min_elements, - max_elements; -}; - -/***** externs *****/ -extern struct lfds710_misc_globals - lfds710_misc_globals; - -/***** public prototypes *****/ -static LFDS710_PAL_INLINE void lfds710_misc_force_store( void ); - -void lfds710_misc_query( enum lfds710_misc_query query_type, void *query_input, void *query_output ); - -/***** public in-line functions *****/ -#pragma prefast( disable : 28112, "blah" ) - -static LFDS710_PAL_INLINE void lfds710_misc_force_store() -{ - lfds710_pal_uint_t volatile LFDS710_PAL_ALIGN(LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES) - destination; - - LFDS710_PAL_ATOMIC_SET( &destination, 0 ); - - return; -} - diff --git a/liblfds710/inc/liblfds710/lfds710_porting_abstraction_layer_compiler.h b/liblfds710/inc/liblfds710/lfds710_porting_abstraction_layer_compiler.h deleted file mode 100644 index 674aff9..0000000 --- a/liblfds710/inc/liblfds710/lfds710_porting_abstraction_layer_compiler.h +++ /dev/null @@ -1,446 +0,0 @@ -/****************************************************************************/ -#if( defined __GNUC__ ) - // TRD : makes checking GCC versions much tidier - #define LFDS710_PAL_GCC_VERSION ( __GNUC__ * 100 + __GNUC_MINOR__ * 10 + __GNUC_PATCHLEVEL__ ) -#endif - - - - - -/****************************************************************************/ -#if( defined _MSC_VER && _MSC_VER >= 1400 ) - - #ifdef LFDS710_PAL_COMPILER - #error More than one porting abstraction layer matches the current platform in lfds710_porting_abstraction_layer_compiler.h - #endif - - #define LFDS710_PAL_COMPILER - - #define LFDS710_PAL_COMPILER_STRING "MSVC" - - #define LFDS710_PAL_ALIGN(alignment) __declspec( align(alignment) ) - #define LFDS710_PAL_INLINE __forceinline - - #define LFDS710_PAL_BARRIER_COMPILER_LOAD _ReadBarrier() - #define LFDS710_PAL_BARRIER_COMPILER_STORE _WriteBarrier() - #define LFDS710_PAL_BARRIER_COMPILER_FULL _ReadWriteBarrier() - - /* TRD : there are four processors to consider; - - . ARM32 (32 bit, ADD, CAS, DWCAS, EXCHANGE, SET) (defined _M_ARM) - . Itanium (64 bit, ADD, CAS, EXCHANGE, SET) (defined _M_IA64) - . x64 (64 bit, ADD, CAS, DWCAS, EXCHANGE, SET) (defined _M_X64 || defined _M_AMD64) - . x86 (32 bit, ADD, CAS, DWCAS, EXCHANGE, SET) (defined _M_IX86) - - can't find any indications of 64-bit ARM support yet - - ARM has better intrinsics than the others, as there are no-fence variants - - in theory we also have to deal with 32-bit Windows on a 64-bit platform, - and I presume we'd see the compiler properly indicate this in its macros, - but this would require that we use 32-bit atomics on the 64-bit platforms, - while keeping 64-bit cache line lengths and so on, and this is just so - wierd a thing to do these days that it's not supported - */ - - #if( defined _M_ARM ) - #define LFDS710_PAL_BARRIER_PROCESSOR_LOAD __dmb( _ARM_BARRIER_ISH ) - #define LFDS710_PAL_BARRIER_PROCESSOR_STORE __dmb( _ARM_BARRIER_ISHST ) - #define LFDS710_PAL_BARRIER_PROCESSOR_FULL __dmb( _ARM_BARRIER_ISH ) - - #define LFDS710_PAL_ATOMIC_ADD( pointer_to_target, value, result, result_type ) \ - { \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - (result) = (result_type) _InterlockedAdd_nf( (int long volatile *) (pointer_to_target), (int long) (value) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - } - - #define LFDS710_PAL_ATOMIC_CAS( pointer_to_destination, pointer_to_compare, new_destination, cas_strength, result ) \ - { \ - lfds710_pal_uint_t \ - original_compare; \ - \ - original_compare = (lfds710_pal_uint_t) *(pointer_to_compare); \ - \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - *(lfds710_pal_uint_t *) (pointer_to_compare) = (lfds710_pal_uint_t) _InterlockedCompareExchange_nf( (long volatile *) (pointer_to_destination), (long) (new_destination), (long) *(pointer_to_compare) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - \ - result = (char unsigned) ( original_compare == (lfds710_pal_uint_t) *(pointer_to_compare) ); \ - } - - #define LFDS710_PAL_ATOMIC_DWCAS( pointer_to_destination, pointer_to_compare, pointer_to_new_destination, cas_strength, result ) \ - { \ - __int64 \ - original_compare; \ - \ - original_compare = *(__int64 *) (pointer_to_compare); \ - \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - *(__int64 *) (pointer_to_compare) = _InterlockedCompareExchange64_nf( (__int64 volatile *) (pointer_to_destination), *(__int64 *) (pointer_to_new_destination), *(__int64 *) (pointer_to_compare) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - \ - (result) = (char unsigned) ( *(__int64 *) (pointer_to_compare) == original_compare ); \ - } - - #define LFDS710_PAL_ATOMIC_EXCHANGE( pointer_to_destination, exchange, exchange_type ) \ - { \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - (exchange) = (exchange_type) _InterlockedExchange_nf( (int long volatile *) (pointer_to_destination), (int long) (exchange) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - } - - #define LFDS710_PAL_ATOMIC_SET( pointer_to_destination, new_value ) \ - { \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - (void) _InterlockedExchange_nf( (int long volatile *) (pointer_to_destination), (int long) (new_value) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - } - #endif - - #if( defined _M_IA64 ) - #define LFDS710_PAL_BARRIER_PROCESSOR_LOAD __mf() - #define LFDS710_PAL_BARRIER_PROCESSOR_STORE __mf() - #define LFDS710_PAL_BARRIER_PROCESSOR_FULL __mf() - - #define LFDS710_PAL_ATOMIC_ADD( pointer_to_target, value, result, result_type ) \ - { \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - (result) = (result_type) _InterlockedAdd64_acq( (__int64 volatile *) (pointer_to_target), (__int64) (value) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - } - - #define LFDS710_PAL_ATOMIC_CAS( pointer_to_destination, pointer_to_compare, new_destination, cas_strength, result ) \ - { \ - lfds710_pal_uint_t \ - original_compare; \ - \ - original_compare = (lfds710_pal_uint_t) *(pointer_to_compare); \ - \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - *(lfds710_pal_uint_t *) (pointer_to_compare) = (lfds710_pal_uint_t) _InterlockedCompareExchange64_acq( (__int64 volatile *) (pointer_to_destination), (__int64) (new_destination), (__int64) *(pointer_to_compare) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - \ - result = (char unsigned) ( original_compare == (lfds710_pal_uint_t) *(pointer_to_compare) ); \ - } - - #define LFDS710_PAL_ATOMIC_EXCHANGE( pointer_to_destination, exchange, exchange_type ) \ - { \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - (exchange) = (exchange_type) _InterlockedExchange64_acq( (__int64 volatile *) (pointer_to_destination), (__int64) (exchange) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - } - - #define LFDS710_PAL_ATOMIC_SET( pointer_to_destination, new_value ) \ - { \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - (void) _InterlockedExchange64_acq( (__int64 volatile *) (pointer_to_destination), (__int64) (new_value) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - } - #endif - - #if( defined _M_X64 || defined _M_AMD64 ) - #define LFDS710_PAL_BARRIER_PROCESSOR_LOAD _mm_lfence() - #define LFDS710_PAL_BARRIER_PROCESSOR_STORE _mm_sfence() - #define LFDS710_PAL_BARRIER_PROCESSOR_FULL _mm_mfence() - - // TRD : no _InterlockedAdd64 for x64 - only the badly named _InterlockedExchangeAdd64, which is the same as _InterlockedAdd64 but returns the *original* value (which we must then add to before we return) - #define LFDS710_PAL_ATOMIC_ADD( pointer_to_target, value, result, result_type ) \ - { \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - (result) = (result_type) _InterlockedExchangeAdd64( (__int64 volatile *) (pointer_to_target), (__int64) (value) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - result += value; \ - } - - #define LFDS710_PAL_ATOMIC_CAS( pointer_to_destination, pointer_to_compare, new_destination, cas_strength, result ) \ - { \ - lfds710_pal_uint_t \ - original_compare; \ - \ - original_compare = (lfds710_pal_uint_t) *(pointer_to_compare); \ - \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - *(lfds710_pal_uint_t *) (pointer_to_compare) = (lfds710_pal_uint_t) _InterlockedCompareExchange64( (__int64 volatile *) (pointer_to_destination), (__int64) (new_destination), (__int64) *(pointer_to_compare) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - \ - result = (char unsigned) ( original_compare == (lfds710_pal_uint_t) *(pointer_to_compare) ); \ - } - - #if( _MSC_VER >= 1500 ) - #define LFDS710_PAL_ATOMIC_DWCAS( pointer_to_destination, pointer_to_compare, pointer_to_new_destination, cas_strength, result ) \ - { \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - (result) = (char unsigned) _InterlockedCompareExchange128( (__int64 volatile *) (pointer_to_destination), (__int64) (pointer_to_new_destination[1]), (__int64) (pointer_to_new_destination[0]), (__int64 *) (pointer_to_compare) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - } - #endif - - #define LFDS710_PAL_ATOMIC_EXCHANGE( pointer_to_destination, exchange, exchange_type ) \ - { \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - (exchange) = (exchange_type) _InterlockedExchange64( (__int64 volatile *) (pointer_to_destination), (__int64) (exchange) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - } - - #define LFDS710_PAL_ATOMIC_SET( pointer_to_destination, new_value ) \ - { \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - (void) _InterlockedExchange64( (__int64 volatile *) (pointer_to_destination), (__int64) (new_value) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - } - #endif - - #if( defined _M_IX86 ) - #define LFDS710_PAL_BARRIER_PROCESSOR_LOAD lfds710_misc_force_store() - #define LFDS710_PAL_BARRIER_PROCESSOR_STORE lfds710_misc_force_store() - #define LFDS710_PAL_BARRIER_PROCESSOR_FULL lfds710_misc_force_store() - - // TRD : no _InterlockedAdd for x86 - only the badly named _InterlockedExchangeAdd, which is the same as _InterlockedAdd but returns the *original* value (which we must then add to before we return) - #define LFDS710_PAL_ATOMIC_ADD( pointer_to_target, value, result, result_type ) \ - { \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - (result) = (result_type) _InterlockedExchangeAdd( (__int64 volatile *) (pointer_to_target), (__int64) (value) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - result += value; \ - } - - #define LFDS710_PAL_ATOMIC_CAS( pointer_to_destination, pointer_to_compare, new_destination, cas_strength, result ) \ - { \ - lfds710_pal_uint_t \ - original_compare; \ - \ - /* LFDS710_PAL_ASSERT( (pointer_to_destination) != NULL ); */ \ - /* LFDS710_PAL_ASSERT( (pointer_to_compare) != NULL ); */ \ - /* TRD : new_destination can be any value in its range */ \ - /* TRD : cas_strength can be any value in its range */ \ - /* TRD : result can be any value in its range */ \ - \ - original_compare = (lfds710_pal_uint_t) *(pointer_to_compare); \ - \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - *(lfds710_pal_uint_t *) (pointer_to_compare) = (lfds710_pal_uint_t) _InterlockedCompareExchange( (long volatile *) (pointer_to_destination), (long) (new_destination), (long) *(pointer_to_compare) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - \ - result = (char unsigned) ( original_compare == (lfds710_pal_uint_t) *(pointer_to_compare) ); \ - } - - #define LFDS710_PAL_ATOMIC_DWCAS( pointer_to_destination, pointer_to_compare, pointer_to_new_destination, cas_strength, result ) \ - { \ - __int64 \ - original_compare; \ - \ - original_compare = *(__int64 *) (pointer_to_compare); \ - \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - *(__int64 *) (pointer_to_compare) = _InterlockedCompareExchange64( (__int64 volatile *) (pointer_to_destination), *(__int64 *) (pointer_to_new_destination), *(__int64 *) (pointer_to_compare) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - \ - (result) = (char unsigned) ( *(__int64 *) (pointer_to_compare) == original_compare ); \ - } - - #define LFDS710_PAL_ATOMIC_EXCHANGE( pointer_to_destination, exchange, exchange_type ) \ - { \ - /* LFDS710_PAL_ASSERT( (pointer_to_destination) != NULL ); */ \ - /* LFDS710_PAL_ASSERT( (pointer_to_exchange) != NULL ); */ \ - \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - (exchange) = (exchange_type) _InterlockedExchange( (int long volatile *) (pointer_to_destination), (int long) (exchange) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - } - - #define LFDS710_PAL_ATOMIC_SET( pointer_to_destination, new_value ) \ - { \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - (void) _InterlockedExchange( (int long volatile *) (pointer_to_destination), (int long) (new_value) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - } - #endif - -#endif - - - - - -/****************************************************************************/ -#if( defined __GNUC__ && LFDS710_PAL_GCC_VERSION >= 412 && LFDS710_PAL_GCC_VERSION < 473 ) - - #ifdef LFDS710_PAL_COMPILER - #error More than one porting abstraction layer matches the current platform in lfds710_porting_abstraction_layer_compiler.h - #endif - - #define LFDS710_PAL_COMPILER - - #define LFDS710_PAL_COMPILER_STRING "GCC < 4.7.3" - - #define LFDS710_PAL_ALIGN(alignment) __attribute__( (aligned(alignment)) ) - #define LFDS710_PAL_INLINE inline - - static LFDS710_PAL_INLINE void lfds710_pal_barrier_compiler( void ) - { - __asm__ __volatile__ ( "" : : : "memory" ); - } - - #define LFDS710_PAL_BARRIER_COMPILER_LOAD lfds710_pal_barrier_compiler() - #define LFDS710_PAL_BARRIER_COMPILER_STORE lfds710_pal_barrier_compiler() - #define LFDS710_PAL_BARRIER_COMPILER_FULL lfds710_pal_barrier_compiler() - - #define LFDS710_PAL_BARRIER_PROCESSOR_LOAD __sync_synchronize() - #define LFDS710_PAL_BARRIER_PROCESSOR_STORE __sync_synchronize() - #define LFDS710_PAL_BARRIER_PROCESSOR_FULL __sync_synchronize() - - #define LFDS710_PAL_ATOMIC_ADD( pointer_to_target, value, result, result_type ) \ - { \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - (result) = (result_type) __sync_add_and_fetch( (lfds710_pal_uint_t *) (pointer_to_target), (lfds710_pal_uint_t) (value) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - } - - #define LFDS710_PAL_ATOMIC_CAS( pointer_to_destination, pointer_to_compare, new_destination, cas_strength, result ) \ - { \ - lfds710_pal_uint_t \ - original_compare; \ - \ - original_compare = (lfds710_pal_uint_t) *(pointer_to_compare); \ - \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - *(pointer_to_compare) = __sync_val_compare_and_swap( pointer_to_destination, *(pointer_to_compare), new_destination ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - \ - result = (unsigned char) ( original_compare == (lfds710_pal_uint_t) *(pointer_to_compare) ); \ - } - - // TRD : ARM and x86 have DWCAS which we can get via GCC intrinsics - #if( defined __arm__ || defined __i686__ || defined __i586__ || defined __i486__ ) - #define LFDS710_PAL_ATOMIC_DWCAS( pointer_to_destination, pointer_to_compare, pointer_to_new_destination, cas_strength, result ) \ - { \ - int long long unsigned \ - original_destination; \ - \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - original_destination = __sync_val_compare_and_swap( (int long long unsigned volatile *) (pointer_to_destination), *(int long long unsigned *) (pointer_to_compare), *(int long long unsigned *) (pointer_to_new_destination) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - \ - (result) = (char unsigned) ( original_destination == *(int long long unsigned *) (pointer_to_compare) ); \ - \ - *(int long long unsigned *) (pointer_to_compare) = original_destination; \ - } - #endif - - #define LFDS710_PAL_ATOMIC_EXCHANGE( pointer_to_destination, exchange, exchange_type ) \ - { \ - /* LFDS710_PAL_ASSERT( (pointer_to_destination) != NULL ); */ \ - /* TRD : exchange can be any value in its range */ \ - /* TRD : exchange_type can be any value in its range */ \ - \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - (exchange) = (exchange_type) __sync_lock_test_and_set( pointer_to_destination, (exchange) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - } - - #define LFDS710_PAL_ATOMIC_SET( pointer_to_destination, new_value ) \ - { \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - (void) __sync_lock_test_and_set( pointer_to_destination, (new_value) ); \ - LFDS710_PAL_BARRIER_COMPILER_FULL; \ - } - -#endif - - - - - -/****************************************************************************/ -#if( defined __GNUC__ && LFDS710_PAL_GCC_VERSION >= 473 ) - - #ifdef LFDS710_PAL_COMPILER - #error More than one porting abstraction layer matches the current platform in lfds710_porting_abstraction_layer_compiler.h - #endif - - #define LFDS710_PAL_COMPILER - - #define LFDS710_PAL_COMPILER_STRING "GCC >= 4.7.3" - - #define LFDS710_PAL_ALIGN(alignment) __attribute__( (aligned(alignment)) ) - #define LFDS710_PAL_INLINE inline - - // TRD : GCC >= 4.7.3 compiler barriers are built into the intrinsics - #define LFDS710_PAL_COMPILER_BARRIERS_MISSING_PRESUMED_HAVING_A_GOOD_TIME - - #define LFDS710_PAL_BARRIER_PROCESSOR_LOAD __atomic_thread_fence( __ATOMIC_ACQUIRE ) - #define LFDS710_PAL_BARRIER_PROCESSOR_STORE __atomic_thread_fence( __ATOMIC_RELEASE ) - #define LFDS710_PAL_BARRIER_PROCESSOR_FULL __atomic_thread_fence( __ATOMIC_ACQ_REL ) - - #define LFDS710_PAL_ATOMIC_ADD( pointer_to_target, value, result, result_type ) \ - { \ - (result) = (result_type) __atomic_add_fetch( (pointer_to_target), (value), __ATOMIC_RELAXED ); \ - } - - #define LFDS710_PAL_ATOMIC_CAS( pointer_to_destination, pointer_to_compare, new_destination, cas_strength, result ) \ - { \ - result = (char unsigned) __atomic_compare_exchange_n( pointer_to_destination, pointer_to_compare, new_destination, cas_strength, __ATOMIC_RELAXED, __ATOMIC_RELAXED ); \ - } - - // TRD : ARM and x86 have DWCAS which we can get via GCC intrinsics - #if( defined __arm__ || defined __i686__ || defined __i586__ || defined __i486__ ) - #define LFDS710_PAL_ATOMIC_DWCAS( pointer_to_destination, pointer_to_compare, pointer_to_new_destination, cas_strength, result ) \ - { \ - (result) = (char unsigned) __atomic_compare_exchange_n( (int long long unsigned volatile *) (pointer_to_destination), (int long long unsigned *) (pointer_to_compare), *(int long long unsigned *) (pointer_to_new_destination), (cas_strength), __ATOMIC_RELAXED, __ATOMIC_RELAXED ); \ - } - #endif - - #if( defined __x86_64__ ) - /* TRD : On 64 bit platforms, unsigned long long int is 64 bit, so we must manually use cmpxchg16b, - as __sync_val_compare_and_swap() will only emit cmpxchg8b - */ - - // TRD : lfds710_pal_uint_t volatile (*destination)[2], lfds710_pal_uint_t (*compare)[2], lfds710_pal_uint_t (*new_destination)[2], enum lfds710_misc_cas_strength cas_strength, char unsigned result - - #define LFDS710_PAL_ATOMIC_DWCAS( pointer_to_destination, pointer_to_compare, pointer_to_new_destination, cas_strength, result ) \ - { \ - (result) = 0; \ - \ - __asm__ __volatile__ \ - ( \ - "lock;" /* make cmpxchg16b atomic */ \ - "cmpxchg16b %0;" /* cmpxchg16b sets ZF on success */ \ - "setz %4;" /* if ZF set, set result to 1 */ \ - \ - /* output */ \ - : "+m" ((pointer_to_destination)[0]), "+m" ((pointer_to_destination)[1]), "+a" ((pointer_to_compare)[0]), "+d" ((pointer_to_compare)[1]), "=q" (result) \ - \ - /* input */ \ - : "b" ((pointer_to_new_destination)[0]), "c" ((pointer_to_new_destination)[1]) \ - \ - /* clobbered */ \ - : \ - ); \ - } - #endif - - #define LFDS710_PAL_ATOMIC_EXCHANGE( pointer_to_destination, exchange, exchange_type ) \ - { \ - (exchange) = (exchange_type) __atomic_exchange_n( (pointer_to_destination), (exchange), __ATOMIC_RELAXED ); \ - } - - #define LFDS710_PAL_ATOMIC_SET( pointer_to_destination, new_value ) \ - { \ - (void) __atomic_exchange_n( (pointer_to_destination), (new_value), __ATOMIC_RELAXED ); \ - } - -#endif - - - - - -/****************************************************************************/ -#if( !defined LFDS710_PAL_COMPILER ) - - #error No matching porting abstraction layer in lfds710_porting_abstraction_layer_compiler.h - -#endif - diff --git a/liblfds710/inc/liblfds710/lfds710_porting_abstraction_layer_operating_system.h b/liblfds710/inc/liblfds710/lfds710_porting_abstraction_layer_operating_system.h deleted file mode 100644 index 47ffe78..0000000 --- a/liblfds710/inc/liblfds710/lfds710_porting_abstraction_layer_operating_system.h +++ /dev/null @@ -1,86 +0,0 @@ -/****************************************************************************/ -#if( defined _WIN32 && !defined KERNEL_MODE ) - - #ifdef LFDS710_PAL_OPERATING_SYSTEM - #error More than one porting abstraction layer matches the current platform in "lfds710_porting_abstraction_layer_operating_system.h". - #endif - - #define LFDS710_PAL_OPERATING_SYSTEM - - #include - - #define LFDS710_PAL_OS_STRING "Windows" - #define LFDS710_PAL_ASSERT( expression ) if( !(expression) ) LFDS710_MISC_DELIBERATELY_CRASH; - -#endif - - - - - -/****************************************************************************/ -#if( defined _WIN32 && defined KERNEL_MODE ) - - #ifdef LFDS710_PAL_OPERATING_SYSTEM - #error More than one porting abstraction layer matches the current platform in "lfds710_porting_abstraction_layer_operating_system.h". - #endif - - #define LFDS710_PAL_OPERATING_SYSTEM - - #include - #include - - #define LFDS710_PAL_OS_STRING "Windows" - #define LFDS710_PAL_ASSERT( expression ) if( !(expression) ) LFDS710_MISC_DELIBERATELY_CRASH; - -#endif - - - - - -/****************************************************************************/ -#if( defined __linux__ && !defined KERNEL_MODE ) - - #ifdef LFDS710_PAL_OPERATING_SYSTEM - #error More than one porting abstraction layer matches the current platform in "lfds710_porting_abstraction_layer_operating_system.h". - #endif - - #define LFDS710_PAL_OPERATING_SYSTEM - - #define LFDS710_PAL_OS_STRING "Linux" - #define LFDS710_PAL_ASSERT( expression ) if( !(expression) ) LFDS710_MISC_DELIBERATELY_CRASH; - -#endif - - - - - -/****************************************************************************/ -#if( defined __linux__ && defined KERNEL_MODE ) - - #ifdef LFDS710_PAL_OPERATING_SYSTEM - #error More than one porting abstraction layer matches the current platform in "lfds710_porting_abstraction_layer_operating_system.h". - #endif - - #define LFDS710_PAL_OPERATING_SYSTEM - - #include - - #define LFDS710_PAL_OS_STRING "Linux" - #define LFDS710_PAL_ASSERT( expression ) BUG_ON( expression ) - -#endif - - - - - -/****************************************************************************/ -#if( !defined LFDS710_PAL_OPERATING_SYSTEM ) - - #error No matching porting abstraction layer in lfds710_porting_abstraction_layer_operating_system.h - -#endif - diff --git a/liblfds710/inc/liblfds710/lfds710_porting_abstraction_layer_processor.h b/liblfds710/inc/liblfds710/lfds710_porting_abstraction_layer_processor.h deleted file mode 100644 index 567d43c..0000000 --- a/liblfds710/inc/liblfds710/lfds710_porting_abstraction_layer_processor.h +++ /dev/null @@ -1,459 +0,0 @@ -/****************************************************************************/ -#if( defined _MSC_VER && defined _M_IX86 ) - - #ifdef LFDS710_PAL_PROCESSOR - #error More than one porting abstraction layer matches the current platform in "lfds710_porting_abstraction_layer_processor.h". - #endif - - #define LFDS710_PAL_PROCESSOR - - typedef int long lfds710_pal_int_t; - typedef int long unsigned lfds710_pal_uint_t; - - #define LFDS710_PAL_PROCESSOR_STRING "x86" - - #define LFDS710_PAL_ALIGN_SINGLE_POINTER 4 - #define LFDS710_PAL_ALIGN_DOUBLE_POINTER 8 - - #define LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES 32 - -#endif - - - - - -/****************************************************************************/ -#if( defined _MSC_VER && (defined _M_X64 || defined _M_AMD64) ) - - #ifdef LFDS710_PAL_PROCESSOR - #error More than one porting abstraction layer matches the current platform in "lfds710_porting_abstraction_layer_processor.h". - #endif - - #define LFDS710_PAL_PROCESSOR - - typedef int long long lfds710_pal_int_t; - typedef int long long unsigned lfds710_pal_uint_t; - - #define LFDS710_PAL_PROCESSOR_STRING "x64" - - #define LFDS710_PAL_ALIGN_SINGLE_POINTER 8 - #define LFDS710_PAL_ALIGN_DOUBLE_POINTER 16 - - // TRD : Intel bring over two cache lines at once, always, unless disabled in BIOS - #define LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES 128 - -#endif - - - - - -/****************************************************************************/ -#if( defined _MSC_VER && defined _M_IA64 ) - - #ifdef LFDS710_PAL_PROCESSOR - #error More than one porting abstraction layer matches the current platform in "lfds710_porting_abstraction_layer_processor.h". - #endif - - #define LFDS710_PAL_PROCESSOR - - typedef int long long lfds710_pal_int_t; - typedef int long long unsigned lfds710_pal_uint_t; - - #define LFDS710_PAL_PROCESSOR_STRING "IA64" - - #define LFDS710_PAL_ALIGN_SINGLE_POINTER 8 - #define LFDS710_PAL_ALIGN_DOUBLE_POINTER 16 - - #define LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES 64 - -#endif - - - - - -/****************************************************************************/ -#if( defined _MSC_VER && defined _M_ARM ) - - #ifdef LFDS710_PAL_PROCESSOR - #error More than one porting abstraction layer matches the current platform in "lfds710_porting_abstraction_layer_processor.h". - #endif - - #define LFDS710_PAL_PROCESSOR - - typedef int long lfds710_pal_int_t; - typedef int long unsigned lfds710_pal_uint_t; - - #define LFDS710_PAL_PROCESSOR_STRING "ARM (32-bit)" - - #define LFDS710_PAL_ALIGN_SINGLE_POINTER 4 - #define LFDS710_PAL_ALIGN_DOUBLE_POINTER 8 - - /* TRD : ARM is LL/SC and uses a reservation granule of 8 to 2048 bytes - so the isolation value used here is worst-case - be sure to set - this correctly, otherwise structures are painfully large - - the test application has an argument, "-e", which attempts to - determine the ERG length - */ - - #define LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES 2048 - -#endif - - - - - -/****************************************************************************/ -#if( defined __GNUC__ && defined __arm__ ) - - #ifdef LFDS710_PAL_PROCESSOR - #error More than one porting abstraction layer matches the current platform in "lfds710_porting_abstraction_layer_processor.h". - #endif - - #define LFDS710_PAL_PROCESSOR - - typedef int long lfds710_pal_int_t; - typedef int long unsigned lfds710_pal_uint_t; - - #define LFDS710_PAL_PROCESSOR_STRING "ARM (32-bit)" - - #define LFDS710_PAL_ALIGN_SINGLE_POINTER 4 - #define LFDS710_PAL_ALIGN_DOUBLE_POINTER 8 - - /* TRD : ARM is LL/SC and uses a reservation granule of 8 to 2048 bytes - so the isolation value used here is worst-case - be sure to set - this correctly, otherwise structures are painfully large - - the test application has an argument, "-e", which attempts to - determine the ERG length - */ - - #define LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES 2048 - -#endif - - - - - -/****************************************************************************/ -#if( defined __GNUC__ && defined __aarch64__ ) - - #ifdef LFDS710_PAL_PROCESSOR - #error More than one porting abstraction layer matches the current platform in "lfds710_porting_abstraction_layer_processor.h". - #endif - - #define LFDS710_PAL_PROCESSOR - - typedef int long long lfds710_pal_int_t; - typedef int long long unsigned lfds710_pal_uint_t; - - #define LFDS710_PAL_PROCESSOR_STRING "ARM (64-bit)" - - #define LFDS710_PAL_ALIGN_SINGLE_POINTER 8 - #define LFDS710_PAL_ALIGN_DOUBLE_POINTER 16 - - /* TRD : ARM is LL/SC and uses a reservation granule of 8 to 2048 bytes - so the isolation value used here is worst-case - be sure to set - this correctly, otherwise structures are painfully large - - the test application has an argument, "-e", which attempts to - determine the ERG length - */ - - #define LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES 2048 - -#endif - - - - - -/****************************************************************************/ -#if( defined __GNUC__ && (defined __i686__ || defined __i586__ || defined __i486__) ) - - #ifdef LFDS710_PAL_PROCESSOR - #error More than one porting abstraction layer matches the current platform in "lfds710_porting_abstraction_layer_processor.h". - #endif - - #define LFDS710_PAL_PROCESSOR - - typedef int long lfds710_pal_int_t; - typedef int long unsigned lfds710_pal_uint_t; - - #define LFDS710_PAL_PROCESSOR_STRING "x86" - - #define LFDS710_PAL_ALIGN_SINGLE_POINTER 4 - #define LFDS710_PAL_ALIGN_DOUBLE_POINTER 8 - - #define LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES 32 - -#endif - - - - - -/****************************************************************************/ -#if( defined __GNUC__ && defined __x86_64__ ) - - #ifdef LFDS710_PAL_PROCESSOR - #error More than one porting abstraction layer matches the current platform in "lfds710_porting_abstraction_layer_processor.h". - #endif - - #define LFDS710_PAL_PROCESSOR - - typedef int long long lfds710_pal_int_t; - typedef int long long unsigned lfds710_pal_uint_t; - - #define LFDS710_PAL_PROCESSOR_STRING "x64" - - #define LFDS710_PAL_ALIGN_SINGLE_POINTER 8 - #define LFDS710_PAL_ALIGN_DOUBLE_POINTER 16 - - #define LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES 128 - -#endif - - - - - -/****************************************************************************/ -#if( defined __GNUC__ && defined __alpha__ ) - - #ifdef LFDS710_PAL_PROCESSOR - #error More than one porting abstraction layer matches the current platform in "lfds710_porting_abstraction_layer_processor.h". - #endif - - #define LFDS710_PAL_PROCESSOR - - typedef int long lfds710_pal_int_t; - typedef int long unsigned lfds710_pal_uint_t; - - #define LFDS710_PAL_PROCESSOR_STRING "alpha" - - #define LFDS710_PAL_ALIGN_SINGLE_POINTER 8 - #define LFDS710_PAL_ALIGN_DOUBLE_POINTER 16 - - #define LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES 64 - -#endif - - - - - -/****************************************************************************/ -#if( defined __GNUC__ && defined __ia64__ ) - - #ifdef LFDS710_PAL_PROCESSOR - #error More than one porting abstraction layer matches the current platform in "lfds710_porting_abstraction_layer_processor.h". - #endif - - #define LFDS710_PAL_PROCESSOR - - typedef int long long lfds710_pal_int_t; - typedef int long long unsigned lfds710_pal_uint_t; - - #define LFDS710_PAL_PROCESSOR_STRING "IA64" - - #define LFDS710_PAL_ALIGN_SINGLE_POINTER 8 - #define LFDS710_PAL_ALIGN_DOUBLE_POINTER 16 - - #define LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES 64 - -#endif - - - - - -/****************************************************************************/ -#if( defined __GNUC__ && defined __mips__ ) - - #ifdef LFDS710_PAL_PROCESSOR - #error More than one porting abstraction layer matches the current platform in "lfds710_porting_abstraction_layer_processor.h". - #endif - - #define LFDS710_PAL_PROCESSOR - - typedef int long lfds710_pal_int_t; - typedef int long unsigned lfds710_pal_uint_t; - - #define LFDS710_PAL_PROCESSOR_STRING "MIPS (32-bit)" - - #define LFDS710_PAL_ALIGN_SINGLE_POINTER 4 - #define LFDS710_PAL_ALIGN_DOUBLE_POINTER 8 - - #define LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES 32 - -#endif - - - - - -/****************************************************************************/ -#if( defined __GNUC__ && defined __mips64 ) - - #ifdef LFDS710_PAL_PROCESSOR - #error More than one porting abstraction layer matches the current platform in "lfds710_porting_abstraction_layer_processor.h". - #endif - - #define LFDS710_PAL_PROCESSOR - - typedef int long long lfds710_pal_int_t; - typedef int long long unsigned lfds710_pal_uint_t; - - #define LFDS710_PAL_PROCESSOR_STRING "MIPS (64-bit)" - - #define LFDS710_PAL_ALIGN_SINGLE_POINTER 8 - #define LFDS710_PAL_ALIGN_DOUBLE_POINTER 16 - - #define LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES 64 - -#endif - - - - - -/****************************************************************************/ -#if( defined __GNUC__ && defined __ppc__ ) - - #ifdef LFDS710_PAL_PROCESSOR - #error More than one porting abstraction layer matches the current platform in "lfds710_porting_abstraction_layer_processor.h". - #endif - - #define LFDS710_PAL_PROCESSOR - - typedef int long lfds710_pal_int_t; - typedef int long unsigned lfds710_pal_uint_t; - - #define LFDS710_PAL_PROCESSOR_STRING "POWERPC (32-bit)" - - #define LFDS710_PAL_ALIGN_SINGLE_POINTER 4 - #define LFDS710_PAL_ALIGN_DOUBLE_POINTER 8 - - // TRD : this value is not very certain - #define LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES 128 - -#endif - - - - - -/****************************************************************************/ -#if( defined __GNUC__ && defined __ppc64__ ) - - #ifdef LFDS710_PAL_PROCESSOR - #error More than one porting abstraction layer matches the current platform in "lfds710_porting_abstraction_layer_processor.h". - #endif - - #define LFDS710_PAL_PROCESSOR - - typedef int long long lfds710_pal_int_t; - typedef int long long unsigned lfds710_pal_uint_t; - - #define LFDS710_PAL_PROCESSOR_STRING "POWERPC (64-bit)" - - #define LFDS710_PAL_ALIGN_SINGLE_POINTER 8 - #define LFDS710_PAL_ALIGN_DOUBLE_POINTER 16 - - // TRD : this value is not very certain - #define LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES 128 - -#endif - - - - - -/****************************************************************************/ -#if( defined __GNUC__ && defined __sparc__ && !defined __sparc_v9__ ) - - #ifdef LFDS710_PAL_PROCESSOR - #error More than one porting abstraction layer matches the current platform in "lfds710_porting_abstraction_layer_processor.h". - #endif - - #define LFDS710_PAL_PROCESSOR - - typedef int long lfds710_pal_int_t; - typedef int long unsigned lfds710_pal_uint_t; - - #define LFDS710_PAL_PROCESSOR_STRING "SPARC (32-bit)" - - #define LFDS710_PAL_ALIGN_SINGLE_POINTER 4 - #define LFDS710_PAL_ALIGN_DOUBLE_POINTER 8 - - #define LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES 32 - -#endif - - - - - -/****************************************************************************/ -#if( defined __GNUC__ && defined __sparc__ && defined __sparc_v9__ ) - - #ifdef LFDS710_PAL_PROCESSOR - #error More than one porting abstraction layer matches the current platform in "lfds710_porting_abstraction_layer_processor.h". - #endif - - #define LFDS710_PAL_PROCESSOR - - typedef int long long lfds710_pal_int_t; - typedef int long long unsigned lfds710_pal_uint_t; - - #define LFDS710_PAL_PROCESSOR_STRING "SPARC (64-bit)" - - #define LFDS710_PAL_ALIGN_SINGLE_POINTER 8 - #define LFDS710_PAL_ALIGN_DOUBLE_POINTER 16 - - #define LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES 64 - -#endif - - - - - -/****************************************************************************/ -#if( defined __GNUC__ && defined __m68k__ ) - - #ifdef LFDS710_PAL_PROCESSOR - #error More than one porting abstraction layer matches the current platform in "lfds710_porting_abstraction_layer_processor.h". - #endif - - #define LFDS710_PAL_PROCESSOR - - typedef int long lfds710_pal_int_t; - typedef int long unsigned lfds710_pal_uint_t; - - #define LFDS710_PAL_PROCESSOR_STRING "680x0" - - #define LFDS710_PAL_ALIGN_SINGLE_POINTER 4 - #define LFDS710_PAL_ALIGN_DOUBLE_POINTER 8 - - #define LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES 32 - -#endif - - - - - -/****************************************************************************/ -#if( !defined LFDS710_PAL_PROCESSOR ) - - #error No matching porting abstraction layer in "lfds710_porting_abstraction_layer_processor.h". - -#endif - diff --git a/liblfds710/inc/liblfds710/lfds710_prng.h b/liblfds710/inc/liblfds710/lfds710_prng.h deleted file mode 100644 index 95e0b27..0000000 --- a/liblfds710/inc/liblfds710/lfds710_prng.h +++ /dev/null @@ -1,74 +0,0 @@ -/***** defines *****/ -#define LFDS710_PRNG_MAX ( (lfds710_pal_uint_t) -1 ) - -/* TRD : the seed is from an on-line hardware RNG, using atmospheric noise - the URL below will generate another 16 random hex digits (e.g. a 64-bit number) and is - the RNG used to generate the number above (0x0a34655d34c092fe) - - http://www.random.org/integers/?num=16&min=0&max=15&col=1&base=16&format=plain&rnd=new - - the 32 bit seed is the upper half of the 64 bit seed - - the "SplitMix" PRNG is from from Sebastiano vigna's site, CC0 license, http://xorshift.di.unimi.it/splitmix64.c - the 64-bit constants come directly from the source, the 32-bt constants are in fact the 32-bit murmurhash3 constants -*/ - -#if( LFDS710_PAL_ALIGN_SINGLE_POINTER == 4 ) - #define LFDS710_PRNG_SEED 0x0a34655dUL - #define LFDS710_PRNG_SPLITMIX_MAGIC_RATIO 0x9E3779B9UL - #define LFDS710_PRNG_SPLITMIX_SHIFT_CONSTANT_ONE 16 - #define LFDS710_PRNG_SPLITMIX_SHIFT_CONSTANT_TWO 13 - #define LFDS710_PRNG_SPLITMIX_SHIFT_CONSTANT_THREE 16 - #define LFDS710_PRNG_SPLITMIX_MULTIPLY_CONSTANT_ONE 0x85ebca6bUL - #define LFDS710_PRNG_SPLITMIX_MULTIPLY_CONSTANT_TWO 0xc2b2ae35UL -#endif - -#if( LFDS710_PAL_ALIGN_SINGLE_POINTER == 8 ) - #define LFDS710_PRNG_SEED 0x0a34655d34c092feULL - #define LFDS710_PRNG_SPLITMIX_MAGIC_RATIO 0x9E3779B97F4A7C15ULL - #define LFDS710_PRNG_SPLITMIX_SHIFT_CONSTANT_ONE 30 - #define LFDS710_PRNG_SPLITMIX_SHIFT_CONSTANT_TWO 27 - #define LFDS710_PRNG_SPLITMIX_SHIFT_CONSTANT_THREE 31 - #define LFDS710_PRNG_SPLITMIX_MULTIPLY_CONSTANT_ONE 0xBF58476D1CE4E5B9ULL - #define LFDS710_PRNG_SPLITMIX_MULTIPLY_CONSTANT_TWO 0x94D049BB133111EBULL -#endif - -// TRD : struct lfds710_prng_state prng_state, lfds710_pal_uint_t random_value -#define LFDS710_PRNG_GENERATE( prng_state, random_value ) \ -{ \ - LFDS710_PAL_ATOMIC_ADD( &(prng_state).entropy, LFDS710_PRNG_SPLITMIX_MAGIC_RATIO, (random_value), lfds710_pal_uint_t ); \ - LFDS710_PRNG_ST_MIXING_FUNCTION( random_value ); \ -} - -// TRD : struct lfds710_prng_state prng_st_state, lfds710_pal_uint_t random_value -#define LFDS710_PRNG_ST_GENERATE( prng_st_state, random_value ) \ -{ \ - (random_value) = ( (prng_st_state).entropy += LFDS710_PRNG_SPLITMIX_MAGIC_RATIO ); \ - LFDS710_PRNG_ST_MIXING_FUNCTION( random_value ); \ -} - -// TRD : lfds710_pal_uint_t random_value -#define LFDS710_PRNG_ST_MIXING_FUNCTION( random_value ) \ -{ \ - (random_value) = ((random_value) ^ ((random_value) >> LFDS710_PRNG_SPLITMIX_SHIFT_CONSTANT_ONE)) * LFDS710_PRNG_SPLITMIX_MULTIPLY_CONSTANT_ONE; \ - (random_value) = ((random_value) ^ ((random_value) >> LFDS710_PRNG_SPLITMIX_SHIFT_CONSTANT_TWO)) * LFDS710_PRNG_SPLITMIX_MULTIPLY_CONSTANT_TWO; \ - (random_value) = (random_value ^ (random_value >> LFDS710_PRNG_SPLITMIX_SHIFT_CONSTANT_THREE)); \ -} - -/***** structs *****/ -struct lfds710_prng_state -{ - lfds710_pal_uint_t volatile LFDS710_PAL_ALIGN(LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES) - entropy; -}; - -struct lfds710_prng_st_state -{ - lfds710_pal_uint_t - entropy; -}; - -/***** public prototypes *****/ -void lfds710_prng_init_valid_on_current_logical_core( struct lfds710_prng_state *ps, lfds710_pal_uint_t seed ); -void lfds710_prng_st_init( struct lfds710_prng_st_state *psts, lfds710_pal_uint_t seed ); - diff --git a/liblfds710/inc/liblfds710/lfds710_queue_bounded_manyproducer_manyconsumer.h b/liblfds710/inc/liblfds710/lfds710_queue_bounded_manyproducer_manyconsumer.h deleted file mode 100644 index f5be220..0000000 --- a/liblfds710/inc/liblfds710/lfds710_queue_bounded_manyproducer_manyconsumer.h +++ /dev/null @@ -1,66 +0,0 @@ -/***** defines *****/ -#define LFDS710_QUEUE_BMM_GET_USER_STATE_FROM_STATE( queue_bmm_state ) ( (queue_bmm_state).user_state ) - -/***** enums *****/ -enum lfds710_queue_bmm_query -{ - LFDS710_QUEUE_BMM_QUERY_GET_POTENTIALLY_INACCURATE_COUNT, - LFDS710_QUEUE_BMM_QUERY_SINGLETHREADED_VALIDATE -}; - -/***** structures *****/ -struct lfds710_queue_bmm_element -{ - lfds710_pal_uint_t volatile - sequence_number; - - void - *volatile key, - *volatile value; -}; - -struct lfds710_queue_bmm_state -{ - lfds710_pal_uint_t - number_elements, - mask; - - lfds710_pal_uint_t volatile LFDS710_PAL_ALIGN(LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES) - read_index, - write_index; - - struct lfds710_queue_bmm_element - *element_array; - - void - *user_state; - - struct lfds710_misc_backoff_state - dequeue_backoff, - enqueue_backoff; -}; - -/***** public prototypes *****/ -void lfds710_queue_bmm_init_valid_on_current_logical_core( struct lfds710_queue_bmm_state *qbmms, - struct lfds710_queue_bmm_element *element_array, - lfds710_pal_uint_t number_elements, - void *user_state ); - -void lfds710_queue_bmm_cleanup( struct lfds710_queue_bmm_state *qbmms, - void (*element_cleanup_callback)(struct lfds710_queue_bmm_state *qbmms, - void *key, - void *value) ); - -int lfds710_queue_bmm_enqueue( struct lfds710_queue_bmm_state *qbmms, - void *key, - void *value ); - -int lfds710_queue_bmm_dequeue( struct lfds710_queue_bmm_state *qbmms, - void **key, - void **value ); - -void lfds710_queue_bmm_query( struct lfds710_queue_bmm_state *qbmms, - enum lfds710_queue_bmm_query query_type, - void *query_input, - void *query_output ); - diff --git a/liblfds710/inc/liblfds710/lfds710_queue_bounded_singleproducer_singleconsumer.h b/liblfds710/inc/liblfds710/lfds710_queue_bounded_singleproducer_singleconsumer.h deleted file mode 100644 index e0d90ac..0000000 --- a/liblfds710/inc/liblfds710/lfds710_queue_bounded_singleproducer_singleconsumer.h +++ /dev/null @@ -1,59 +0,0 @@ -/***** defines *****/ -#define LFDS710_QUEUE_BSS_GET_USER_STATE_FROM_STATE( queue_bss_state ) ( (queue_bss_state).user_state ) - -/***** enums *****/ -enum lfds710_queue_bss_query -{ - LFDS710_QUEUE_BSS_QUERY_GET_POTENTIALLY_INACCURATE_COUNT, - LFDS710_QUEUE_BSS_QUERY_VALIDATE -}; - -/***** structures *****/ -struct lfds710_queue_bss_element -{ - void - *volatile key, - *volatile value; -}; - -struct lfds710_queue_bss_state -{ - lfds710_pal_uint_t - number_elements, - mask; - - lfds710_pal_uint_t volatile - read_index, - write_index; - - struct lfds710_queue_bss_element - *element_array; - - void - *user_state; -}; - -/***** public prototypes *****/ -void lfds710_queue_bss_init_valid_on_current_logical_core( struct lfds710_queue_bss_state *qbsss, - struct lfds710_queue_bss_element *element_array, - lfds710_pal_uint_t number_elements, - void *user_state ); - // TRD : number_elements must be a positive integer power of 2 - // TRD : used in conjunction with the #define LFDS710_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE - -void lfds710_queue_bss_cleanup( struct lfds710_queue_bss_state *qbsss, - void (*element_cleanup_callback)(struct lfds710_queue_bss_state *qbsss, void *key, void *value) ); - -int lfds710_queue_bss_enqueue( struct lfds710_queue_bss_state *qbsss, - void *key, - void *value ); - -int lfds710_queue_bss_dequeue( struct lfds710_queue_bss_state *qbsss, - void **key, - void **value ); - -void lfds710_queue_bss_query( struct lfds710_queue_bss_state *qbsss, - enum lfds710_queue_bss_query query_type, - void *query_input, - void *query_output ); - diff --git a/liblfds710/inc/liblfds710/lfds710_queue_unbounded_manyproducer_manyconsumer.h b/liblfds710/inc/liblfds710/lfds710_queue_unbounded_manyproducer_manyconsumer.h deleted file mode 100644 index e7a3613..0000000 --- a/liblfds710/inc/liblfds710/lfds710_queue_unbounded_manyproducer_manyconsumer.h +++ /dev/null @@ -1,62 +0,0 @@ -/***** defines *****/ -#define LFDS710_QUEUE_UMM_GET_KEY_FROM_ELEMENT( queue_umm_element ) ( (queue_umm_element).key ) -#define LFDS710_QUEUE_UMM_SET_KEY_IN_ELEMENT( queue_umm_element, new_key ) ( (queue_umm_element).key = (void *) (lfds710_pal_uint_t) (new_key) ) -#define LFDS710_QUEUE_UMM_GET_VALUE_FROM_ELEMENT( queue_umm_element ) ( (queue_umm_element).value ) -#define LFDS710_QUEUE_UMM_SET_VALUE_IN_ELEMENT( queue_umm_element, new_value ) ( (queue_umm_element).value = (void *) (lfds710_pal_uint_t) (new_value) ) -#define LFDS710_QUEUE_UMM_GET_USER_STATE_FROM_STATE( queue_umm_state ) ( (queue_umm_state).user_state ) - -/***** enums *****/ -enum lfds710_queue_umm_query -{ - LFDS710_QUEUE_UMM_QUERY_SINGLETHREADED_GET_COUNT, - LFDS710_QUEUE_UMM_QUERY_SINGLETHREADED_VALIDATE -}; - -/***** structures *****/ -struct lfds710_queue_umm_element -{ - struct lfds710_queue_umm_element LFDS710_PAL_ALIGN(LFDS710_PAL_ALIGN_DOUBLE_POINTER) - *volatile next[PAC_SIZE]; - - void - *key, - *value; -}; - -struct lfds710_queue_umm_state -{ - struct lfds710_queue_umm_element LFDS710_PAL_ALIGN(LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES) - *volatile enqueue[PAC_SIZE], - *volatile dequeue[PAC_SIZE]; - - lfds710_pal_uint_t volatile LFDS710_PAL_ALIGN(LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES) - aba_counter; - - void LFDS710_PAL_ALIGN(LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES) - *user_state; - - struct lfds710_misc_backoff_state - dequeue_backoff, - enqueue_backoff; -}; - -/***** public prototypes *****/ -void lfds710_queue_umm_init_valid_on_current_logical_core( struct lfds710_queue_umm_state *qumms, - struct lfds710_queue_umm_element *qumme_dummy, - void *user_state ); - // TRD : used in conjunction with the #define LFDS710_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE - -void lfds710_queue_umm_cleanup( struct lfds710_queue_umm_state *qumms, - void (*element_cleanup_callback)(struct lfds710_queue_umm_state *qumms, struct lfds710_queue_umm_element *qumme, enum lfds710_misc_flag dummy_element_flag) ); - -void lfds710_queue_umm_enqueue( struct lfds710_queue_umm_state *qumms, - struct lfds710_queue_umm_element *qumme ); - -int lfds710_queue_umm_dequeue( struct lfds710_queue_umm_state *qumms, - struct lfds710_queue_umm_element **qumme ); - -void lfds710_queue_umm_query( struct lfds710_queue_umm_state *qumms, - enum lfds710_queue_umm_query query_type, - void *query_input, - void *query_output ); - diff --git a/liblfds710/inc/liblfds710/lfds710_ringbuffer.h b/liblfds710/inc/liblfds710/lfds710_ringbuffer.h deleted file mode 100644 index 60bf0ca..0000000 --- a/liblfds710/inc/liblfds710/lfds710_ringbuffer.h +++ /dev/null @@ -1,66 +0,0 @@ -/***** enums *****/ -#define LFDS710_RINGBUFFER_GET_USER_STATE_FROM_STATE( ringbuffer_state ) ( (ringbuffer_state).user_state ) - -/***** enums *****/ -enum lfds710_ringbuffer_query -{ - LFDS710_RINGBUFFER_QUERY_SINGLETHREADED_GET_COUNT, - LFDS710_RINGBUFFER_QUERY_SINGLETHREADED_VALIDATE -}; - -/***** structures *****/ -struct lfds710_ringbuffer_element -{ - struct lfds710_freelist_element - fe; - - struct lfds710_queue_umm_element - qumme; - - struct lfds710_queue_umm_element - *qumme_use; // TRD : hack; we need a new queue with no dummy element - - void - *key, - *value; -}; - -struct lfds710_ringbuffer_state -{ - struct lfds710_freelist_state - fs; - - struct lfds710_queue_umm_state - qumms; - - void - (*element_cleanup_callback)( struct lfds710_ringbuffer_state *rs, void *key, void *value, enum lfds710_misc_flag unread_flag ), - *user_state; -}; - -/***** public prototypes *****/ -void lfds710_ringbuffer_init_valid_on_current_logical_core( struct lfds710_ringbuffer_state *rs, - struct lfds710_ringbuffer_element *re_array_inc_dummy, - lfds710_pal_uint_t number_elements_inc_dummy, - void *user_state ); - // TRD : used in conjunction with the #define LFDS710_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE - -void lfds710_ringbuffer_cleanup( struct lfds710_ringbuffer_state *rs, - void (*element_cleanup_callback)(struct lfds710_ringbuffer_state *rs, void *key, void *value, enum lfds710_misc_flag unread_flag) ); - -int lfds710_ringbuffer_read( struct lfds710_ringbuffer_state *rs, - void **key, - void **value ); - -void lfds710_ringbuffer_write( struct lfds710_ringbuffer_state *rs, - void *key, - void *value, - enum lfds710_misc_flag *overwrite_occurred_flag, - void **overwritten_key, - void **overwritten_value ); - -void lfds710_ringbuffer_query( struct lfds710_ringbuffer_state *rs, - enum lfds710_ringbuffer_query query_type, - void *query_input, - void *query_output ); - diff --git a/liblfds710/inc/liblfds710/lfds710_stack.h b/liblfds710/inc/liblfds710/lfds710_stack.h deleted file mode 100644 index e14aa02..0000000 --- a/liblfds710/inc/liblfds710/lfds710_stack.h +++ /dev/null @@ -1,58 +0,0 @@ -/***** defines *****/ -#define LFDS710_STACK_GET_KEY_FROM_ELEMENT( stack_element ) ( (stack_element).key ) -#define LFDS710_STACK_SET_KEY_IN_ELEMENT( stack_element, new_key ) ( (stack_element).key = (void *) (lfds710_pal_uint_t) (new_key) ) -#define LFDS710_STACK_GET_VALUE_FROM_ELEMENT( stack_element ) ( (stack_element).value ) -#define LFDS710_STACK_SET_VALUE_IN_ELEMENT( stack_element, new_value ) ( (stack_element).value = (void *) (lfds710_pal_uint_t) (new_value) ) -#define LFDS710_STACK_GET_USER_STATE_FROM_STATE( stack_state ) ( (stack_state).user_state ) - -/***** enums *****/ -enum lfds710_stack_query -{ - LFDS710_STACK_QUERY_SINGLETHREADED_GET_COUNT, - LFDS710_STACK_QUERY_SINGLETHREADED_VALIDATE -}; - -/***** structures *****/ -struct lfds710_stack_element -{ - struct lfds710_stack_element - *next; - - void - *key, - *value; -}; - -struct lfds710_stack_state -{ - struct lfds710_stack_element LFDS710_PAL_ALIGN(LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES) - *volatile top[PAC_SIZE]; - - void LFDS710_PAL_ALIGN(LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES) - *user_state; - - struct lfds710_misc_backoff_state - pop_backoff, - push_backoff; -}; - -/***** public prototypes *****/ -void lfds710_stack_init_valid_on_current_logical_core( struct lfds710_stack_state *ss, - void *user_state ); - // TRD : used in conjunction with the #define LFDS710_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE - -void lfds710_stack_cleanup( struct lfds710_stack_state *ss, - void (*element_cleanup_callback)(struct lfds710_stack_state *ss, struct lfds710_stack_element *se) ); - -void lfds710_stack_push( struct lfds710_stack_state *ss, - struct lfds710_stack_element *se ); - -int lfds710_stack_pop( struct lfds710_stack_state *ss, - struct lfds710_stack_element **se ); - -void lfds710_stack_query( struct lfds710_stack_state *ss, - enum lfds710_stack_query query_type, - void *query_input, - void *query_output ); - - diff --git a/liblfds710/src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_cleanup.c b/liblfds710/src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_cleanup.c deleted file mode 100644 index ec00e7b..0000000 --- a/liblfds710/src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_cleanup.c +++ /dev/null @@ -1,117 +0,0 @@ -/***** includes *****/ -#include "lfds710_btree_addonly_unbalanced_internal.h" - - - - - -/****************************************************************************/ -void lfds710_btree_au_cleanup( struct lfds710_btree_au_state *baus, - void (*element_cleanup_callback)(struct lfds710_btree_au_state *baus, struct lfds710_btree_au_element *baue) ) -{ - enum lfds710_btree_au_delete_action - delete_action = LFDS710_BTREE_AU_DELETE_SELF; // TRD : to remove compiler warning - - struct lfds710_btree_au_element - *baue; - - struct lfds710_btree_au_element - *temp; - - LFDS710_PAL_ASSERT( baus != NULL ); - // TRD : element_delete_function can be NULL - - /* TRD : we're not lock-free now, so delete at will - but be iterative, so can be used in kernels (where there's little stack) - and be performant, since the user may be - creating/destroying many of these trees - also remember the user may be deallocating user data - so we cannot visit an element twice - - we start at the root and iterate till we go to NULL - if the element has zero children, we delete it and move up to its parent - if the element has one child, we delete it, move its child into its place, and continue from its child - if the element has two children, we move left - - the purpose of this is to minimize walking around the tree - to prevent visiting an element twice - while also minimizing code complexity - */ - - if( element_cleanup_callback == NULL ) - return; - - LFDS710_MISC_BARRIER_LOAD; - - lfds710_btree_au_get_by_absolute_position( baus, &baue, LFDS710_BTREE_AU_ABSOLUTE_POSITION_ROOT ); - - while( baue != NULL ) - { - if( baue->left == NULL and baue->right == NULL ) - delete_action = LFDS710_BTREE_AU_DELETE_SELF; - - if( baue->left != NULL and baue->right == NULL ) - delete_action = LFDS710_BTREE_AU_DELETE_SELF_REPLACE_WITH_LEFT_CHILD; - - if( baue->left == NULL and baue->right != NULL ) - delete_action = LFDS710_BTREE_AU_DELETE_SELF_REPLACE_WITH_RIGHT_CHILD; - - if( baue->left != NULL and baue->right != NULL ) - delete_action = LFDS710_BTREE_AU_DELETE_MOVE_LEFT; - - switch( delete_action ) - { - case LFDS710_BTREE_AU_DELETE_SELF: - // TRD : if we have a parent (we could be root) set his point to us to NULL - if( baue->up != NULL ) - { - if( baue->up->left == baue ) - baue->up->left = NULL; - if( baue->up->right == baue ) - baue->up->right = NULL; - } - - temp = baue; - lfds710_btree_au_get_by_relative_position( &baue, LFDS710_BTREE_AU_RELATIVE_POSITION_UP ); - element_cleanup_callback( baus, temp ); - break; - - case LFDS710_BTREE_AU_DELETE_SELF_REPLACE_WITH_LEFT_CHILD: - baue->left->up = baue->up; - if( baue->up != NULL ) - { - if( baue->up->left == baue ) - baue->up->left = baue->left; - if( baue->up->right == baue ) - baue->up->right = baue->left; - } - - temp = baue; - lfds710_btree_au_get_by_relative_position( &baue, LFDS710_BTREE_AU_RELATIVE_POSITION_LEFT ); - element_cleanup_callback( baus, temp ); - break; - - case LFDS710_BTREE_AU_DELETE_SELF_REPLACE_WITH_RIGHT_CHILD: - baue->right->up = baue->up; - if( baue->up != NULL ) - { - if( baue->up->left == baue ) - baue->up->left = baue->right; - if( baue->up->right == baue ) - baue->up->right = baue->right; - } - - temp = baue; - lfds710_btree_au_get_by_relative_position( &baue, LFDS710_BTREE_AU_RELATIVE_POSITION_RIGHT ); - element_cleanup_callback( baus, temp ); - break; - - case LFDS710_BTREE_AU_DELETE_MOVE_LEFT: - lfds710_btree_au_get_by_relative_position( &baue, LFDS710_BTREE_AU_RELATIVE_POSITION_LEFT ); - break; - } - } - - return; -} - diff --git a/liblfds710/src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_get.c b/liblfds710/src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_get.c deleted file mode 100644 index 51e0600..0000000 --- a/liblfds710/src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_get.c +++ /dev/null @@ -1,482 +0,0 @@ -/***** includes *****/ -#include "lfds710_btree_addonly_unbalanced_internal.h" - -/***** private prototypes *****/ -static void lfds710_btree_au_internal_inorder_walk_from_largest_get_next_smallest_element( struct lfds710_btree_au_element **baue ); -static void lfds710_btree_au_internal_inorder_walk_from_smallest_get_next_largest_element( struct lfds710_btree_au_element **baue ); - - - - - -/****************************************************************************/ -int lfds710_btree_au_get_by_key( struct lfds710_btree_au_state *baus, - int (*key_compare_function)(void const *new_key, void const *existing_key), - void *key, - struct lfds710_btree_au_element **baue ) -{ - int - compare_result = !0, - rv = 1; - - LFDS710_PAL_ASSERT( baus != NULL ); - // TRD : key_compare_function can be NULL - // TRD : key can be NULL - LFDS710_PAL_ASSERT( baue != NULL ); - - if( key_compare_function == NULL ) - key_compare_function = baus->key_compare_function; - - LFDS710_MISC_BARRIER_LOAD; - - *baue = baus->root; - - LFDS710_MISC_BARRIER_LOAD; - - while( *baue != NULL and compare_result != 0 ) - { - compare_result = key_compare_function( key, (*baue)->key ); - - if( compare_result < 0 ) - { - *baue = (*baue)->left; - LFDS710_MISC_BARRIER_LOAD; - } - - if( compare_result > 0 ) - { - *baue = (*baue)->right; - LFDS710_MISC_BARRIER_LOAD; - } - } - - if( *baue == NULL ) - rv = 0; - - return rv; -} - - - - - -/****************************************************************************/ -int lfds710_btree_au_get_by_absolute_position( struct lfds710_btree_au_state *baus, - struct lfds710_btree_au_element **baue, - enum lfds710_btree_au_absolute_position absolute_position ) -{ - int - rv = 1; - - LFDS710_PAL_ASSERT( baus != NULL ); - LFDS710_PAL_ASSERT( baue != NULL ); - // TRD : absolute_position can be any value in its range - - LFDS710_MISC_BARRIER_LOAD; - - *baue = baus->root; - - LFDS710_MISC_BARRIER_LOAD; - - switch( absolute_position ) - { - case LFDS710_BTREE_AU_ABSOLUTE_POSITION_ROOT: - break; - - case LFDS710_BTREE_AU_ABSOLUTE_POSITION_LARGEST_IN_TREE: - if( *baue != NULL ) - while( (*baue)->right != NULL ) - { - *baue = (*baue)->right; - LFDS710_MISC_BARRIER_LOAD; - } - break; - - case LFDS710_BTREE_AU_ABSOLUTE_POSITION_SMALLEST_IN_TREE: - if( *baue != NULL ) - while( (*baue)->left != NULL ) - { - *baue = (*baue)->left; - LFDS710_MISC_BARRIER_LOAD; - } - break; - } - - if( *baue == NULL ) - rv = 0; - - return rv; -} - - - - - -/****************************************************************************/ -int lfds710_btree_au_get_by_relative_position( struct lfds710_btree_au_element **baue, - enum lfds710_btree_au_relative_position relative_position ) -{ - int - rv = 1; - - LFDS710_PAL_ASSERT( baue != NULL ); - // TRD : relative_position can baue any value in its range - - if( *baue == NULL ) - return 0; - - LFDS710_MISC_BARRIER_LOAD; - - switch( relative_position ) - { - case LFDS710_BTREE_AU_RELATIVE_POSITION_UP: - *baue = (*baue)->up; - // TRD : no load barrier - up already existed, so is known to be safely propagated - break; - - case LFDS710_BTREE_AU_RELATIVE_POSITION_LEFT: - *baue = (*baue)->left; - LFDS710_MISC_BARRIER_LOAD; - break; - - case LFDS710_BTREE_AU_RELATIVE_POSITION_RIGHT: - *baue = (*baue)->right; - LFDS710_MISC_BARRIER_LOAD; - break; - - case LFDS710_BTREE_AU_RELATIVE_POSITION_SMALLEST_ELEMENT_BELOW_CURRENT_ELEMENT: - *baue = (*baue)->left; - if( *baue != NULL ) - { - LFDS710_MISC_BARRIER_LOAD; - while( (*baue)->right != NULL ) - { - *baue = (*baue)->right; - LFDS710_MISC_BARRIER_LOAD; - } - } - break; - - case LFDS710_BTREE_AU_RELATIVE_POSITION_LARGEST_ELEMENT_BELOW_CURRENT_ELEMENT: - *baue = (*baue)->right; - if( *baue != NULL ) - { - LFDS710_MISC_BARRIER_LOAD; - while( (*baue)->left != NULL ) - { - *baue = (*baue)->left; - LFDS710_MISC_BARRIER_LOAD; - } - } - break; - - case LFDS710_BTREE_AU_RELATIVE_POSITION_NEXT_SMALLER_ELEMENT_IN_ENTIRE_TREE: - lfds710_btree_au_internal_inorder_walk_from_largest_get_next_smallest_element( baue ); - break; - - case LFDS710_BTREE_AU_RELATIVE_POSITION_NEXT_LARGER_ELEMENT_IN_ENTIRE_TREE: - lfds710_btree_au_internal_inorder_walk_from_smallest_get_next_largest_element( baue ); - break; - } - - if( *baue == NULL ) - rv = 0; - - return rv; -} - - - - - -/****************************************************************************/ -static void lfds710_btree_au_internal_inorder_walk_from_largest_get_next_smallest_element( struct lfds710_btree_au_element **baue ) -{ - enum lfds710_btree_au_move - action = LFDS710_BTREE_AU_MOVE_INVALID; - - enum lfds710_misc_flag - finished_flag = LFDS710_MISC_FLAG_LOWERED, - load_finished_flag = LFDS710_MISC_FLAG_LOWERED; - - struct lfds710_btree_au_element - *left = NULL, - *right = NULL, - *up = NULL, - *up_left = NULL, - *up_right = NULL; - - LFDS710_PAL_ASSERT( baue != NULL ); - - /* TRD : from any given element, the next smallest element is; - 1. if we have a left, it's the largest element on the right branch of our left child - 2. if we don't have a left, and we're on the right of our parent, then it's our parent - 3. if we don't have a left, and we're on the left of our parent or we have no parent, - iterative up the tree until we find the first child who is on the right of its parent; then it's the parent - */ - - /* TRD : we need to ensure the variables we use to decide our action are self-consistent - to do this, we make local copies of them all - then, if they are all not NULL, we can know they cannot change and we can continue - if however any of them are NULL, they could have changed while we were reading - and so our variables could be non-self-consistent - to check for this, we issue another processor read barrier - and then compare our local variables with the values in the tree - if they all match, then we know our variable set is self-consistent - (even though it may now be wrong - but we will discover this when we try the atomic operation) - */ - - LFDS710_MISC_BARRIER_LOAD; - - while( load_finished_flag == LFDS710_MISC_FLAG_LOWERED ) - { - left = (*baue)->left; - right = (*baue)->right; - up = (*baue)->up; - if( up != NULL ) - { - up_left = (*baue)->up->left; - up_right = (*baue)->up->right; - } - - // TRD : optimization - if all already not NULL, given we're add-only, they won't change - if( left != NULL and right != NULL and (up == NULL or (up != NULL and up_left != NULL and up_right != NULL)) ) - break; - - LFDS710_MISC_BARRIER_LOAD; - - if( left == (*baue)->left and right == (*baue)->right and (up == NULL or (up != NULL and up == (*baue)->up and up_left == (*baue)->up->left and up_right == (*baue)->up->right)) ) - load_finished_flag = LFDS710_MISC_FLAG_RAISED; - } - - if( left != NULL ) - action = LFDS710_BTREE_AU_MOVE_LARGEST_FROM_LEFT_CHILD; - - if( left == NULL and up != NULL and up_right == *baue ) - action = LFDS710_BTREE_AU_MOVE_GET_PARENT; - - if( (left == NULL and up == NULL) or (up != NULL and up_left == *baue and left == NULL) ) - action = LFDS710_BTREE_AU_MOVE_MOVE_UP_TREE; - - switch( action ) - { - case LFDS710_BTREE_AU_MOVE_INVALID: - case LFDS710_BTREE_AU_MOVE_SMALLEST_FROM_RIGHT_CHILD: - // TRD : eliminates a compiler warning - break; - - case LFDS710_BTREE_AU_MOVE_LARGEST_FROM_LEFT_CHILD: - *baue = left; - if( *baue != NULL ) - { - LFDS710_MISC_BARRIER_LOAD; - while( (*baue)->right != NULL ) - { - *baue = (*baue)->right; - LFDS710_MISC_BARRIER_LOAD; - } - } - break; - - case LFDS710_BTREE_AU_MOVE_GET_PARENT: - *baue = up; - break; - - case LFDS710_BTREE_AU_MOVE_MOVE_UP_TREE: - while( finished_flag == LFDS710_MISC_FLAG_LOWERED ) - { - load_finished_flag = LFDS710_MISC_FLAG_LOWERED; - - while( load_finished_flag == LFDS710_MISC_FLAG_LOWERED ) - { - up = (*baue)->up; - if( up != NULL ) - up_left = (*baue)->up->left; - - // TRD : optimization - if all already not NULL, given we're add-only, they won't change - if( up == NULL or (up != NULL and up_left != NULL) ) - break; - - LFDS710_MISC_BARRIER_LOAD; - - if( up == (*baue)->up and up_left == (*baue)->up->left ) - load_finished_flag = LFDS710_MISC_FLAG_RAISED; - } - - if( *baue != NULL and up != NULL and *baue == up_left ) - *baue = up; - else - finished_flag = LFDS710_MISC_FLAG_RAISED; - } - - *baue = up; - - /* - - while( *baue != NULL and (*baue)->up != NULL and *baue == (*baue)->up->left ) - *baue = (*baue)->up; - - *baue = (*baue)->up; - - */ - break; - } - - return; -} - - - - - -/****************************************************************************/ -static void lfds710_btree_au_internal_inorder_walk_from_smallest_get_next_largest_element( struct lfds710_btree_au_element **baue ) -{ - enum lfds710_btree_au_move - action = LFDS710_BTREE_AU_MOVE_INVALID; - - enum lfds710_misc_flag - finished_flag = LFDS710_MISC_FLAG_LOWERED, - load_finished_flag = LFDS710_MISC_FLAG_LOWERED; - - struct lfds710_btree_au_element - *left = NULL, - *right = NULL, - *up = NULL, - *up_left = NULL, - *up_right = NULL; - - LFDS710_PAL_ASSERT( baue != NULL ); - - /* TRD : from any given element, the next largest element is; - 1. if we have a right, it's the smallest element on the left branch of our right child - 2. if we don't have a right, and we're on the left of our parent, then it's our parent - 3. if we don't have a right, and we're on the right of our parent or we have no parent, - iterate up the tree until we find the first child who is on the left of its parent; then it's the parent - */ - - LFDS710_MISC_BARRIER_LOAD; - - while( load_finished_flag == LFDS710_MISC_FLAG_LOWERED ) - { - left = (*baue)->left; - right = (*baue)->right; - up = (*baue)->up; - if( up != NULL ) - { - up_left = (*baue)->up->left; - up_right = (*baue)->up->right; - } - - // TRD : optimization - if all already not NULL, given we're add-only, they won't change - if( left != NULL and right != NULL and (up == NULL or (up != NULL and up_left != NULL and up_right != NULL)) ) - break; - - LFDS710_MISC_BARRIER_LOAD; - - if( left == (*baue)->left and right == (*baue)->right and (up == NULL or (up != NULL and up == (*baue)->up and up_left == (*baue)->up->left and up_right == (*baue)->up->right)) ) - load_finished_flag = LFDS710_MISC_FLAG_RAISED; - } - - if( right != NULL ) - action = LFDS710_BTREE_AU_MOVE_SMALLEST_FROM_RIGHT_CHILD; - - if( right == NULL and up != NULL and up_left == *baue ) - action = LFDS710_BTREE_AU_MOVE_GET_PARENT; - - if( (right == NULL and up == NULL) or (up != NULL and up_right == *baue and right == NULL) ) - action = LFDS710_BTREE_AU_MOVE_MOVE_UP_TREE; - - switch( action ) - { - case LFDS710_BTREE_AU_MOVE_INVALID: - case LFDS710_BTREE_AU_MOVE_LARGEST_FROM_LEFT_CHILD: - // TRD : remove compiler warning - break; - - case LFDS710_BTREE_AU_MOVE_SMALLEST_FROM_RIGHT_CHILD: - *baue = right; - if( *baue != NULL ) - { - LFDS710_MISC_BARRIER_LOAD; - while( (*baue)->left != NULL ) - { - *baue = (*baue)->left; - LFDS710_MISC_BARRIER_LOAD; - } - } - break; - - case LFDS710_BTREE_AU_MOVE_GET_PARENT: - *baue = up; - break; - - case LFDS710_BTREE_AU_MOVE_MOVE_UP_TREE: - while( finished_flag == LFDS710_MISC_FLAG_LOWERED ) - { - load_finished_flag = LFDS710_MISC_FLAG_LOWERED; - - while( load_finished_flag == LFDS710_MISC_FLAG_LOWERED ) - { - up = (*baue)->up; - if( up != NULL ) - up_right = (*baue)->up->right; - - // TRD : optimization - if all already not NULL, given we're add-only, they won't change - if( up == NULL or (up != NULL and up_right != NULL) ) - break; - - LFDS710_MISC_BARRIER_LOAD; - - if( up == (*baue)->up and up_right == (*baue)->up->right ) - load_finished_flag = LFDS710_MISC_FLAG_RAISED; - } - - if( *baue != NULL and up != NULL and *baue == up_right ) - *baue = up; - else - finished_flag = LFDS710_MISC_FLAG_RAISED; - } - - *baue = up; - - /* - - while( *baue != NULL and (*baue)->up != NULL and *baue == (*baue)->up->right ) - *baue = (*baue)->up; - - *baue = (*baue)->up; - - */ - break; - } - - return; -} - - - - - -/****************************************************************************/ -int lfds710_btree_au_get_by_absolute_position_and_then_by_relative_position( struct lfds710_btree_au_state *baus, - struct lfds710_btree_au_element **baue, - enum lfds710_btree_au_absolute_position absolute_position, - enum lfds710_btree_au_relative_position relative_position ) -{ - int - rv; - - LFDS710_PAL_ASSERT( baus != NULL ); - LFDS710_PAL_ASSERT( baue != NULL ); - // TRD: absolute_position can be any value in its range - // TRD: relative_position can be any value in its range - - if( *baue == NULL ) - rv = lfds710_btree_au_get_by_absolute_position( baus, baue, absolute_position ); - else - rv = lfds710_btree_au_get_by_relative_position( baue, relative_position ); - - return rv; -} - diff --git a/liblfds710/src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_init.c b/liblfds710/src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_init.c deleted file mode 100644 index 17da718..0000000 --- a/liblfds710/src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_init.c +++ /dev/null @@ -1,33 +0,0 @@ -/***** includes *****/ -#include "lfds710_btree_addonly_unbalanced_internal.h" - - - - - -/****************************************************************************/ -void lfds710_btree_au_init_valid_on_current_logical_core( struct lfds710_btree_au_state *baus, - int (*key_compare_function)(void const *new_key, void const *existing_key), - enum lfds710_btree_au_existing_key existing_key, - void *user_state ) -{ - LFDS710_PAL_ASSERT( baus != NULL ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &baus->root % LFDS710_PAL_ALIGN_SINGLE_POINTER == 0 ); - LFDS710_PAL_ASSERT( key_compare_function != NULL ); - // TRD : existing_key can be any value in its range - // TRD : user_state can be NULL - - baus->root = NULL; - baus->key_compare_function = key_compare_function; - baus->existing_key = existing_key; - baus->user_state = user_state; - - lfds710_misc_internal_backoff_init( &baus->insert_backoff ); - - LFDS710_MISC_BARRIER_STORE; - - lfds710_misc_force_store(); - - return; -} - diff --git a/liblfds710/src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_insert.c b/liblfds710/src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_insert.c deleted file mode 100644 index 48c5098..0000000 --- a/liblfds710/src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_insert.c +++ /dev/null @@ -1,158 +0,0 @@ -/***** includes *****/ -#include "lfds710_btree_addonly_unbalanced_internal.h" - - - - - -/****************************************************************************/ -enum lfds710_btree_au_insert_result lfds710_btree_au_insert( struct lfds710_btree_au_state *baus, - struct lfds710_btree_au_element *baue, - struct lfds710_btree_au_element **existing_baue ) -{ - char unsigned - result = 0; - - int - compare_result = 0; - - lfds710_pal_uint_t - backoff_iteration = LFDS710_BACKOFF_INITIAL_VALUE; - - struct lfds710_btree_au_element - *compare = NULL, - *volatile baue_next = NULL, - *volatile baue_parent = NULL, - *volatile baue_temp; - - LFDS710_PAL_ASSERT( baus != NULL ); - LFDS710_PAL_ASSERT( baue != NULL ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &baue->left % LFDS710_PAL_ALIGN_SINGLE_POINTER == 0 ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &baue->right % LFDS710_PAL_ALIGN_SINGLE_POINTER == 0 ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &baue->up % LFDS710_PAL_ALIGN_SINGLE_POINTER == 0 ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &baue->value % LFDS710_PAL_ALIGN_SINGLE_POINTER == 0 ); - // TRD : existing_baue can be NULL - - /* TRD : we follow a normal search for the insert node and which side to insert - - the difference is that insertion may fail because someone else inserts - there before we do - - in this case, we resume searching for the insert node from the node - we were attempting to insert upon - - (if we attempted to insert the root node and this failed, i.e. we thought - the tree was empty but then it wasn't, then we start searching from the - new root) - */ - - baue->up = baue->left = baue->right = NULL; - - LFDS710_MISC_BARRIER_LOAD; - - baue_temp = baus->root; - - LFDS710_MISC_BARRIER_LOAD; - - while( result == 0 ) - { - // TRD : first we find where to insert - while( baue_temp != NULL ) - { - compare_result = baus->key_compare_function( baue->key, baue_temp->key ); - - if( compare_result == 0 ) - { - if( existing_baue != NULL ) - *existing_baue = baue_temp; - - switch( baus->existing_key ) - { - case LFDS710_BTREE_AU_EXISTING_KEY_OVERWRITE: - LFDS710_BTREE_AU_SET_VALUE_IN_ELEMENT( *baue_temp, baue->value ); - return LFDS710_BTREE_AU_INSERT_RESULT_SUCCESS_OVERWRITE; - break; - - case LFDS710_BTREE_AU_EXISTING_KEY_FAIL: - return LFDS710_BTREE_AU_INSERT_RESULT_FAILURE_EXISTING_KEY; - break; - } - } - - if( compare_result < 0 ) - baue_next = baue_temp->left; - - if( compare_result > 0 ) - baue_next = baue_temp->right; - - baue_parent = baue_temp; - baue_temp = baue_next; - if( baue_temp != NULL ) - LFDS710_MISC_BARRIER_LOAD; - } - - /* TRD : second, we actually insert - - at this point baue_temp has come to NULL - and baue_parent is the element to insert at - and result of the last compare indicates - the direction of insertion - - it may be that another tree has already inserted an element with - the same key as ourselves, or other elements which mean our position - is now wrong - - in this case, it is either inserted in the position we're trying - to insert in now, in which case our insert will fail - - or, similarly, other elements will have come in where we are, - and our insert will fail - */ - - if( baue_parent == NULL ) - { - compare = NULL; - baue->up = baus->root; - LFDS710_MISC_BARRIER_STORE; - LFDS710_PAL_ATOMIC_CAS( &baus->root, &compare, baue, LFDS710_MISC_CAS_STRENGTH_WEAK, result ); - - if( result == 0 ) - baue_temp = baus->root; - } - - if( baue_parent != NULL ) - { - if( compare_result <= 0 ) - { - compare = NULL; - baue->up = baue_parent; - LFDS710_MISC_BARRIER_STORE; - LFDS710_PAL_ATOMIC_CAS( &baue_parent->left, &compare, baue, LFDS710_MISC_CAS_STRENGTH_WEAK, result ); - } - - if( compare_result > 0 ) - { - compare = NULL; - baue->up = baue_parent; - LFDS710_MISC_BARRIER_STORE; - LFDS710_PAL_ATOMIC_CAS( &baue_parent->right, &compare, baue, LFDS710_MISC_CAS_STRENGTH_WEAK, result ); - } - - // TRD : if the insert fails, then resume searching at the insert node - if( result == 0 ) - baue_temp = baue_parent; - } - - if( result == 0 ) - LFDS710_BACKOFF_EXPONENTIAL_BACKOFF( baus->insert_backoff, backoff_iteration ); - } - - LFDS710_BACKOFF_AUTOTUNE( baus->insert_backoff, backoff_iteration ); - - // TRD : if we get to here, we added (not failed or overwrite on exist) a new element - if( existing_baue != NULL ) - *existing_baue = NULL; - - return LFDS710_BTREE_AU_INSERT_RESULT_SUCCESS; -} - diff --git a/liblfds710/src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_internal.h b/liblfds710/src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_internal.h deleted file mode 100644 index c4badeb..0000000 --- a/liblfds710/src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_internal.h +++ /dev/null @@ -1,23 +0,0 @@ -/***** the library-wide header file *****/ -#include "../liblfds710_internal.h" - -/***** enums *****/ -enum lfds710_btree_au_move -{ - LFDS710_BTREE_AU_MOVE_INVALID, - LFDS710_BTREE_AU_MOVE_SMALLEST_FROM_RIGHT_CHILD, - LFDS710_BTREE_AU_MOVE_LARGEST_FROM_LEFT_CHILD, - LFDS710_BTREE_AU_MOVE_GET_PARENT, - LFDS710_BTREE_AU_MOVE_MOVE_UP_TREE -}; - -enum lfds710_btree_au_delete_action -{ - LFDS710_BTREE_AU_DELETE_SELF, - LFDS710_BTREE_AU_DELETE_SELF_REPLACE_WITH_LEFT_CHILD, - LFDS710_BTREE_AU_DELETE_SELF_REPLACE_WITH_RIGHT_CHILD, - LFDS710_BTREE_AU_DELETE_MOVE_LEFT -}; - -/***** private prototypes *****/ - diff --git a/liblfds710/src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_query.c b/liblfds710/src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_query.c deleted file mode 100644 index 1401732..0000000 --- a/liblfds710/src/lfds710_btree_addonly_unbalanced/lfds710_btree_addonly_unbalanced_query.c +++ /dev/null @@ -1,126 +0,0 @@ -/***** includes *****/ -#include "lfds710_btree_addonly_unbalanced_internal.h" - -/***** private prototypes *****/ -static void lfds710_btree_au_internal_validate( struct lfds710_btree_au_state *abs, struct lfds710_misc_validation_info *vi, enum lfds710_misc_validity *lfds710_btree_au_validity ); - - - - - -/****************************************************************************/ -void lfds710_btree_au_query( struct lfds710_btree_au_state *baus, - enum lfds710_btree_au_query query_type, - void *query_input, - void *query_output ) -{ - LFDS710_PAL_ASSERT( baus != NULL ); - // TRD : query_type can be any value in its range - - LFDS710_MISC_BARRIER_LOAD; - - switch( query_type ) - { - case LFDS710_BTREE_AU_QUERY_GET_POTENTIALLY_INACCURATE_COUNT: - { - struct lfds710_btree_au_element - *baue = NULL; - - LFDS710_PAL_ASSERT( query_input == NULL ); - LFDS710_PAL_ASSERT( query_output != NULL ); - - *(lfds710_pal_uint_t *) query_output = 0; - - while( lfds710_btree_au_get_by_absolute_position_and_then_by_relative_position(baus, &baue, LFDS710_BTREE_AU_ABSOLUTE_POSITION_SMALLEST_IN_TREE, LFDS710_BTREE_AU_RELATIVE_POSITION_NEXT_LARGER_ELEMENT_IN_ENTIRE_TREE) ) - ( *(lfds710_pal_uint_t *) query_output )++; - } - break; - - case LFDS710_BTREE_AU_QUERY_SINGLETHREADED_VALIDATE: - // TRD : query_input can be NULL - LFDS710_PAL_ASSERT( query_output != NULL ); - - lfds710_btree_au_internal_validate( baus, (struct lfds710_misc_validation_info *) query_input, (enum lfds710_misc_validity *) query_output ); - break; - } - - return; -} - - - - - -/****************************************************************************/ -static void lfds710_btree_au_internal_validate( struct lfds710_btree_au_state *baus, - struct lfds710_misc_validation_info *vi, - enum lfds710_misc_validity *lfds710_btree_au_validity ) -{ - lfds710_pal_uint_t - number_elements_from_query_tree = 0, - number_elements_from_walk = 0; - - struct lfds710_btree_au_element - *baue = NULL, - *baue_prev = NULL; - - LFDS710_PAL_ASSERT( baus!= NULL ); - // TRD : vi can be NULL - LFDS710_PAL_ASSERT( lfds710_btree_au_validity != NULL ); - - *lfds710_btree_au_validity = LFDS710_MISC_VALIDITY_VALID; - - /* TRD : validation is performed by; - - performing an in-order walk - we should see every element is larger than the preceeding element - we count elements as we go along (visited elements, that is) - and check our tally equals the expected count - */ - - LFDS710_MISC_BARRIER_LOAD; - - while( lfds710_btree_au_get_by_absolute_position_and_then_by_relative_position(baus, &baue, LFDS710_BTREE_AU_ABSOLUTE_POSITION_SMALLEST_IN_TREE, LFDS710_BTREE_AU_RELATIVE_POSITION_NEXT_LARGER_ELEMENT_IN_ENTIRE_TREE) ) - { - // TRD : baue_prev should always be smaller than or equal to baue - if( baue_prev != NULL ) - if( baus->key_compare_function(baue_prev->key, baue->key) > 0 ) - { - *lfds710_btree_au_validity = LFDS710_MISC_VALIDITY_INVALID_ORDER; - return; - } - - baue_prev = baue; - number_elements_from_walk++; - } - - if( *lfds710_btree_au_validity == LFDS710_MISC_VALIDITY_VALID ) - { - lfds710_btree_au_query( (struct lfds710_btree_au_state *) baus, LFDS710_BTREE_AU_QUERY_GET_POTENTIALLY_INACCURATE_COUNT, NULL, &number_elements_from_query_tree ); - - if( number_elements_from_walk > number_elements_from_query_tree ) - *lfds710_btree_au_validity = LFDS710_MISC_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - - if( number_elements_from_walk < number_elements_from_query_tree ) - *lfds710_btree_au_validity = LFDS710_MISC_VALIDITY_INVALID_MISSING_ELEMENTS; - } - - /* TRD : now check for expected number of elements - vi can be NULL, in which case we do not check - we know we don't have a loop from our earlier check - */ - - if( *lfds710_btree_au_validity == LFDS710_MISC_VALIDITY_VALID and vi != NULL ) - { - lfds710_btree_au_query( (struct lfds710_btree_au_state *) baus, LFDS710_BTREE_AU_QUERY_GET_POTENTIALLY_INACCURATE_COUNT, NULL, &number_elements_from_query_tree ); - - if( number_elements_from_query_tree < vi->min_elements ) - *lfds710_btree_au_validity = LFDS710_MISC_VALIDITY_INVALID_MISSING_ELEMENTS; - - if( number_elements_from_query_tree > vi->max_elements ) - *lfds710_btree_au_validity = LFDS710_MISC_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - } - - return; -} - diff --git a/liblfds710/src/lfds710_freelist/lfds710_freelist_cleanup.c b/liblfds710/src/lfds710_freelist/lfds710_freelist_cleanup.c deleted file mode 100644 index 07fb5ca..0000000 --- a/liblfds710/src/lfds710_freelist/lfds710_freelist_cleanup.c +++ /dev/null @@ -1,36 +0,0 @@ -/***** includes *****/ -#include "lfds710_freelist_internal.h" - - - - - -/****************************************************************************/ -void lfds710_freelist_cleanup( struct lfds710_freelist_state *fs, - void (*element_cleanup_callback)(struct lfds710_freelist_state *fs, struct lfds710_freelist_element *fe) ) -{ - struct lfds710_freelist_element - *fe, - *fe_temp; - - LFDS710_PAL_ASSERT( fs != NULL ); - // TRD : element_cleanup_callback can be NULL - - LFDS710_MISC_BARRIER_LOAD; - - if( element_cleanup_callback != NULL ) - { - fe = fs->top[POINTER]; - - while( fe != NULL ) - { - fe_temp = fe; - fe = fe->next; - - element_cleanup_callback( fs, fe_temp ); - } - } - - return; -} - diff --git a/liblfds710/src/lfds710_freelist/lfds710_freelist_init.c b/liblfds710/src/lfds710_freelist/lfds710_freelist_init.c deleted file mode 100644 index fad177a..0000000 --- a/liblfds710/src/lfds710_freelist/lfds710_freelist_init.c +++ /dev/null @@ -1,48 +0,0 @@ -/***** includes *****/ -#include "lfds710_freelist_internal.h" - - - - - -/****************************************************************************/ -void lfds710_freelist_init_valid_on_current_logical_core( struct lfds710_freelist_state *fs, - struct lfds710_freelist_element * volatile (*elimination_array)[LFDS710_FREELIST_ELIMINATION_ARRAY_ELEMENT_SIZE_IN_FREELIST_ELEMENTS], - lfds710_pal_uint_t elimination_array_size_in_elements, - void *user_state ) -{ - lfds710_pal_uint_t - loop, - subloop; - - LFDS710_PAL_ASSERT( fs != NULL ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) fs->top % LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES == 0 ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &fs->elimination_array_size_in_elements % LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES == 0 ); - // TRD : elimination_array can be NULL - LFDS710_PAL_ASSERT( (elimination_array == NULL) or - ( (elimination_array != NULL) and (lfds710_pal_uint_t) elimination_array % LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES == 0 ) ); - LFDS710_PAL_ASSERT( (elimination_array == NULL and elimination_array_size_in_elements == 0) or - (elimination_array != NULL and elimination_array_size_in_elements >= 2 and (elimination_array_size_in_elements & (elimination_array_size_in_elements-1)) == 0) ); - // TRD : user_state can be NULL - - fs->top[POINTER] = NULL; - fs->top[COUNTER] = 0; - - fs->elimination_array = elimination_array; - fs->elimination_array_size_in_elements = elimination_array_size_in_elements; - fs->user_state = user_state; - - for( loop = 0 ; loop < elimination_array_size_in_elements ; loop++ ) - for( subloop = 0 ; subloop < LFDS710_FREELIST_ELIMINATION_ARRAY_ELEMENT_SIZE_IN_FREELIST_ELEMENTS ; subloop++ ) - fs->elimination_array[loop][subloop] = NULL; - - lfds710_misc_internal_backoff_init( &fs->pop_backoff ); - lfds710_misc_internal_backoff_init( &fs->push_backoff ); - - LFDS710_MISC_BARRIER_STORE; - - lfds710_misc_force_store(); - - return; -} - diff --git a/liblfds710/src/lfds710_freelist/lfds710_freelist_internal.h b/liblfds710/src/lfds710_freelist/lfds710_freelist_internal.h deleted file mode 100644 index ee0bf97..0000000 --- a/liblfds710/src/lfds710_freelist/lfds710_freelist_internal.h +++ /dev/null @@ -1,7 +0,0 @@ -/***** the library wide include file *****/ -#include "../liblfds710_internal.h" - -/***** private prototypes *****/ -void lfds710_freelist_internal_push_without_ea( struct lfds710_freelist_state *fs, - struct lfds710_freelist_element *fe ); - diff --git a/liblfds710/src/lfds710_freelist/lfds710_freelist_pop.c b/liblfds710/src/lfds710_freelist/lfds710_freelist_pop.c deleted file mode 100644 index a40253b..0000000 --- a/liblfds710/src/lfds710_freelist/lfds710_freelist_pop.c +++ /dev/null @@ -1,89 +0,0 @@ -/***** includes *****/ -#include "lfds710_freelist_internal.h" - - - - - -/****************************************************************************/ -int lfds710_freelist_pop( struct lfds710_freelist_state *fs, - struct lfds710_freelist_element **fe, - struct lfds710_prng_st_state *psts ) -{ - char unsigned - result; - - lfds710_pal_uint_t - backoff_iteration = LFDS710_BACKOFF_INITIAL_VALUE, - elimination_array_index, - loop, - random_value; - - struct lfds710_freelist_element LFDS710_PAL_ALIGN(LFDS710_PAL_ALIGN_DOUBLE_POINTER) - *new_top[PAC_SIZE], - *volatile original_top[PAC_SIZE]; - - LFDS710_PAL_ASSERT( fs != NULL ); - LFDS710_PAL_ASSERT( fe != NULL ); - // TRD : psts can be NULL - - LFDS710_MISC_BARRIER_LOAD; - - if( fs->elimination_array_size_in_elements > 0 ) - { - if( psts != NULL ) - { - LFDS710_PRNG_ST_GENERATE( *psts, random_value ); - elimination_array_index = ( random_value & (fs->elimination_array_size_in_elements-1) ); - } - else - { - elimination_array_index = (lfds710_pal_uint_t) fe; - LFDS710_PRNG_ST_MIXING_FUNCTION( elimination_array_index ); - elimination_array_index = ( elimination_array_index & (fs->elimination_array_size_in_elements-1) ); - } - - // TRD : full scan of one cache line, max pointers per cache line - - *fe = NULL; - - for( loop = 0 ; loop < LFDS710_FREELIST_ELIMINATION_ARRAY_ELEMENT_SIZE_IN_FREELIST_ELEMENTS ; loop++ ) - if( fs->elimination_array[elimination_array_index][loop] != NULL ) - { - LFDS710_PAL_ATOMIC_EXCHANGE( &fs->elimination_array[elimination_array_index][loop], *fe, struct lfds710_freelist_element * ); - if( *fe != NULL ) - return 1; - } - } - - original_top[COUNTER] = fs->top[COUNTER]; - original_top[POINTER] = fs->top[POINTER]; - - do - { - if( original_top[POINTER] == NULL ) - { - *fe = NULL; - return 0; - } - - new_top[COUNTER] = original_top[COUNTER] + 1; - new_top[POINTER] = original_top[POINTER]->next; - - LFDS710_PAL_ATOMIC_DWCAS( fs->top, original_top, new_top, LFDS710_MISC_CAS_STRENGTH_WEAK, result ); - - if( result == 0 ) - { - LFDS710_BACKOFF_EXPONENTIAL_BACKOFF( fs->pop_backoff, backoff_iteration ); - LFDS710_MISC_BARRIER_LOAD; - } - } - while( result == 0 ); - - *fe = original_top[POINTER]; - - LFDS710_BACKOFF_AUTOTUNE( fs->pop_backoff, backoff_iteration ); - - return 1; -} - diff --git a/liblfds710/src/lfds710_freelist/lfds710_freelist_push.c b/liblfds710/src/lfds710_freelist/lfds710_freelist_push.c deleted file mode 100644 index c9cfca9..0000000 --- a/liblfds710/src/lfds710_freelist/lfds710_freelist_push.c +++ /dev/null @@ -1,123 +0,0 @@ -/***** includes *****/ -#include "lfds710_freelist_internal.h" - - - - - -/****************************************************************************/ -void lfds710_freelist_push( struct lfds710_freelist_state *fs, - struct lfds710_freelist_element *fe, - struct lfds710_prng_st_state *psts ) -{ - char unsigned - result; - - lfds710_pal_uint_t - backoff_iteration = LFDS710_BACKOFF_INITIAL_VALUE, - elimination_array_index, - loop, - random_value; - - struct lfds710_freelist_element LFDS710_PAL_ALIGN(LFDS710_PAL_ALIGN_DOUBLE_POINTER) - *new_top[PAC_SIZE], - *volatile original_top[PAC_SIZE]; - - LFDS710_PAL_ASSERT( fs != NULL ); - LFDS710_PAL_ASSERT( fe != NULL ); - // TRD : psts can be NULL - - LFDS710_MISC_BARRIER_LOAD; - - if( fs->elimination_array_size_in_elements > 0 ) - { - if( psts != NULL ) - { - LFDS710_PRNG_ST_GENERATE( *psts, random_value ); - elimination_array_index = ( random_value & (fs->elimination_array_size_in_elements-1) ); - } - else - { - elimination_array_index = (lfds710_pal_uint_t) fe; - LFDS710_PRNG_ST_MIXING_FUNCTION( elimination_array_index ); - elimination_array_index = ( elimination_array_index & (fs->elimination_array_size_in_elements-1) ); - } - - // TRD : full scan of one cache line, max pointers per cache line - - for( loop = 0 ; loop < LFDS710_FREELIST_ELIMINATION_ARRAY_ELEMENT_SIZE_IN_FREELIST_ELEMENTS ; loop++ ) - if( fs->elimination_array[elimination_array_index][loop] == NULL ) - { - LFDS710_PAL_ATOMIC_EXCHANGE( &fs->elimination_array[elimination_array_index][loop], fe, struct lfds710_freelist_element * ); - if( fe == NULL ) - return; - } - } - - new_top[POINTER] = fe; - - original_top[COUNTER] = fs->top[COUNTER]; - original_top[POINTER] = fs->top[POINTER]; - - do - { - fe->next = original_top[POINTER]; - LFDS710_MISC_BARRIER_STORE; - - new_top[COUNTER] = original_top[COUNTER] + 1; - LFDS710_PAL_ATOMIC_DWCAS( fs->top, original_top, new_top, LFDS710_MISC_CAS_STRENGTH_WEAK, result ); - - if( result == 0 ) - LFDS710_BACKOFF_EXPONENTIAL_BACKOFF( fs->push_backoff, backoff_iteration ); - } - while( result == 0 ); - - LFDS710_BACKOFF_AUTOTUNE( fs->push_backoff, backoff_iteration ); - - return; -} - - - - - -/****************************************************************************/ -void lfds710_freelist_internal_push_without_ea( struct lfds710_freelist_state *fs, - struct lfds710_freelist_element *fe ) -{ - char unsigned - result; - - lfds710_pal_uint_t - backoff_iteration = LFDS710_BACKOFF_INITIAL_VALUE; - - struct lfds710_freelist_element LFDS710_PAL_ALIGN(LFDS710_PAL_ALIGN_DOUBLE_POINTER) - *new_top[PAC_SIZE], - *volatile original_top[PAC_SIZE]; - - LFDS710_PAL_ASSERT( fs != NULL ); - LFDS710_PAL_ASSERT( fe != NULL ); - - new_top[POINTER] = fe; - - original_top[COUNTER] = fs->top[COUNTER]; - original_top[POINTER] = fs->top[POINTER]; - - do - { - fe->next = original_top[POINTER]; - LFDS710_MISC_BARRIER_STORE; - - new_top[COUNTER] = original_top[COUNTER] + 1; - LFDS710_PAL_ATOMIC_DWCAS( fs->top, original_top, new_top, LFDS710_MISC_CAS_STRENGTH_WEAK, result ); - - if( result == 0 ) - LFDS710_BACKOFF_EXPONENTIAL_BACKOFF( fs->push_backoff, backoff_iteration ); - } - while( result == 0 ); - - LFDS710_BACKOFF_AUTOTUNE( fs->push_backoff, backoff_iteration ); - - return; -} - diff --git a/liblfds710/src/lfds710_freelist/lfds710_freelist_query.c b/liblfds710/src/lfds710_freelist/lfds710_freelist_query.c deleted file mode 100644 index ffb7bb4..0000000 --- a/liblfds710/src/lfds710_freelist/lfds710_freelist_query.c +++ /dev/null @@ -1,152 +0,0 @@ -/***** includes *****/ -#include "lfds710_freelist_internal.h" - -/***** private prototypes *****/ -static void lfds710_freelist_internal_freelist_validate( struct lfds710_freelist_state *fs, - struct lfds710_misc_validation_info *vi, - enum lfds710_misc_validity *lfds710_freelist_validity ); - - - - - -/****************************************************************************/ -void lfds710_freelist_query( struct lfds710_freelist_state *fs, - enum lfds710_freelist_query query_type, - void *query_input, - void *query_output ) -{ - struct lfds710_freelist_element - *fe; - - LFDS710_PAL_ASSERT( fs != NULL ); - // TRD : query_type can be any value in its range - - LFDS710_MISC_BARRIER_LOAD; - - switch( query_type ) - { - case LFDS710_FREELIST_QUERY_SINGLETHREADED_GET_COUNT: - { - lfds710_pal_uint_t - loop, - subloop; - - LFDS710_PAL_ASSERT( query_input == NULL ); - LFDS710_PAL_ASSERT( query_output != NULL ); - - *(lfds710_pal_uint_t *) query_output = 0; - - // TRD : count the elements in the elimination array - for( loop = 0 ; loop < fs->elimination_array_size_in_elements ; loop++ ) - for( subloop = 0 ; subloop < LFDS710_FREELIST_ELIMINATION_ARRAY_ELEMENT_SIZE_IN_FREELIST_ELEMENTS ; subloop++ ) - if( fs->elimination_array[loop][subloop] != NULL ) - ( *(lfds710_pal_uint_t *) query_output )++; - - // TRD : count the elements on the freelist - fe = (struct lfds710_freelist_element *) fs->top[POINTER]; - - while( fe != NULL ) - { - ( *(lfds710_pal_uint_t *) query_output )++; - fe = (struct lfds710_freelist_element *) fe->next; - } - } - break; - - case LFDS710_FREELIST_QUERY_SINGLETHREADED_VALIDATE: - // TRD : query_input can be NULL - LFDS710_PAL_ASSERT( query_output != NULL ); - - lfds710_freelist_internal_freelist_validate( fs, (struct lfds710_misc_validation_info *) query_input, (enum lfds710_misc_validity *) query_output ); - break; - - case LFDS710_FREELIST_QUERY_GET_ELIMINATION_ARRAY_EXTRA_ELEMENTS_IN_FREELIST_ELEMENTS: - { - LFDS710_PAL_ASSERT( query_input == NULL ); - LFDS710_PAL_ASSERT( query_output != NULL ); - - ( *(lfds710_pal_uint_t *) query_output ) = (fs->elimination_array_size_in_elements-1) * LFDS710_FREELIST_ELIMINATION_ARRAY_ELEMENT_SIZE_IN_FREELIST_ELEMENTS; - } - break; - } - - return; -} - - - - - -/****************************************************************************/ -static void lfds710_freelist_internal_freelist_validate( struct lfds710_freelist_state *fs, - struct lfds710_misc_validation_info *vi, - enum lfds710_misc_validity *lfds710_freelist_validity ) -{ - lfds710_pal_uint_t - number_elements = 0; - - struct lfds710_freelist_element - *fe_slow, - *fe_fast; - - LFDS710_PAL_ASSERT( fs != NULL ); - // TRD : vi can be NULL - LFDS710_PAL_ASSERT( lfds710_freelist_validity != NULL ); - - *lfds710_freelist_validity = LFDS710_MISC_VALIDITY_VALID; - - fe_slow = fe_fast = (struct lfds710_freelist_element *) fs->top[POINTER]; - - /* TRD : first, check for a loop - we have two pointers - both of which start at the top of the freelist - we enter a loop - and on each iteration - we advance one pointer by one element - and the other by two - - we exit the loop when both pointers are NULL - (have reached the end of the freelist) - - or - - if we fast pointer 'sees' the slow pointer - which means we have a loop - */ - - if( fe_slow != NULL ) - do - { - fe_slow = fe_slow->next; - - if( fe_fast != NULL ) - fe_fast = fe_fast->next; - - if( fe_fast != NULL ) - fe_fast = fe_fast->next; - } - while( fe_slow != NULL and fe_fast != fe_slow ); - - if( fe_fast != NULL and fe_slow != NULL and fe_fast == fe_slow ) - *lfds710_freelist_validity = LFDS710_MISC_VALIDITY_INVALID_LOOP; - - /* TRD : now check for expected number of elements - vi can be NULL, in which case we do not check - we know we don't have a loop from our earlier check - */ - - if( *lfds710_freelist_validity == LFDS710_MISC_VALIDITY_VALID and vi != NULL ) - { - lfds710_freelist_query( fs, LFDS710_FREELIST_QUERY_SINGLETHREADED_GET_COUNT, NULL, (void *) &number_elements ); - - if( number_elements < vi->min_elements ) - *lfds710_freelist_validity = LFDS710_MISC_VALIDITY_INVALID_MISSING_ELEMENTS; - - if( number_elements > vi->max_elements ) - *lfds710_freelist_validity = LFDS710_MISC_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - } - - return; -} - diff --git a/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_cleanup.c b/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_cleanup.c deleted file mode 100644 index 4d39bd5..0000000 --- a/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_cleanup.c +++ /dev/null @@ -1,63 +0,0 @@ -/***** includes *****/ -#include "lfds710_hash_addonly_internal.h" - -/***** private prototypes*****/ -static void btree_au_element_cleanup_function( struct lfds710_btree_au_state *baus, - struct lfds710_btree_au_element *baue ); - - - - - -/****************************************************************************/ -void lfds710_hash_a_cleanup( struct lfds710_hash_a_state *has, - void (*element_cleanup_callback)(struct lfds710_hash_a_state *has, struct lfds710_hash_a_element *hae) ) -{ - lfds710_pal_uint_t - loop; - - LFDS710_PAL_ASSERT( has != NULL ); - // TRD : element_cleanup_callback can be NULL - - if( element_cleanup_callback == NULL ) - return; - - LFDS710_MISC_BARRIER_LOAD; - - has->element_cleanup_callback = element_cleanup_callback; - - for( loop = 0 ; loop < has->array_size ; loop++ ) - lfds710_btree_au_cleanup( has->baus_array+loop, btree_au_element_cleanup_function ); - - return; -} - - - - - -/****************************************************************************/ -#pragma warning( disable : 4100 ) - -static void btree_au_element_cleanup_function( struct lfds710_btree_au_state *baus, - struct lfds710_btree_au_element *baue ) -{ - struct lfds710_hash_a_state - *has; - - struct lfds710_hash_a_element - *hae; - - LFDS710_PAL_ASSERT( baus != NULL ); - LFDS710_PAL_ASSERT( baue != NULL ); - - hae = (struct lfds710_hash_a_element *) LFDS710_BTREE_AU_GET_VALUE_FROM_ELEMENT( *baue ); - has = (struct lfds710_hash_a_state *) LFDS710_BTREE_AU_GET_USER_STATE_FROM_STATE( *baus ); - - has->element_cleanup_callback( has, hae ); - - return; -} - -#pragma warning( default : 4100 ) - diff --git a/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_get.c b/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_get.c deleted file mode 100644 index 1b3bc87..0000000 --- a/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_get.c +++ /dev/null @@ -1,47 +0,0 @@ -/***** includes *****/ -#include "lfds710_hash_addonly_internal.h" - - - - - -/****************************************************************************/ -int lfds710_hash_a_get_by_key( struct lfds710_hash_a_state *has, - int (*key_compare_function)(void const *new_key, void const *existing_key), - void (*key_hash_function)(void const *key, lfds710_pal_uint_t *hash), - void *key, - struct lfds710_hash_a_element **hae ) -{ - int - rv; - - lfds710_pal_uint_t - hash = 0; - - struct lfds710_btree_au_element - *baue; - - LFDS710_PAL_ASSERT( has != NULL ); - // TRD : key_compare_function can be NULL - // TRD : key_hash_function can be NULL - // TRD : key can be NULL - LFDS710_PAL_ASSERT( hae != NULL ); - - if( key_compare_function == NULL ) - key_compare_function = has->key_compare_function; - - if( key_hash_function == NULL ) - key_hash_function = has->key_hash_function; - - key_hash_function( key, &hash ); - - rv = lfds710_btree_au_get_by_key( has->baus_array + (hash % has->array_size), key_compare_function, key, &baue ); - - if( rv == 1 ) - *hae = LFDS710_BTREE_AU_GET_VALUE_FROM_ELEMENT( *baue ); - else - *hae = NULL; - - return rv; -} - diff --git a/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_init.c b/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_init.c deleted file mode 100644 index 3a8bf04..0000000 --- a/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_init.c +++ /dev/null @@ -1,54 +0,0 @@ -/***** includes *****/ -#include "lfds710_hash_addonly_internal.h" - - - - - -/****************************************************************************/ -void lfds710_hash_a_init_valid_on_current_logical_core( struct lfds710_hash_a_state *has, - struct lfds710_btree_au_state *baus_array, - lfds710_pal_uint_t array_size, - int (*key_compare_function)(void const *new_key, void const *existing_key), - void (*key_hash_function)(void const *key, lfds710_pal_uint_t *hash), - enum lfds710_hash_a_existing_key existing_key, - void *user_state ) -{ - enum lfds710_btree_au_existing_key - btree_au_existing_key = LFDS710_BTREE_AU_EXISTING_KEY_OVERWRITE; // TRD : for compiler warning - - lfds710_pal_uint_t - loop; - - LFDS710_PAL_ASSERT( has != NULL ); - LFDS710_PAL_ASSERT( baus_array != NULL ); - LFDS710_PAL_ASSERT( array_size > 0 ); - LFDS710_PAL_ASSERT( key_compare_function != NULL ); - LFDS710_PAL_ASSERT( key_hash_function != NULL ); - // TRD : existing_key can be any value in its range - // TRD : user_state can be NULL - - has->array_size = array_size; - has->key_compare_function = key_compare_function; - has->key_hash_function = key_hash_function; - has->existing_key = existing_key; - has->baus_array = baus_array; - has->user_state = user_state; - - if( has->existing_key == LFDS710_HASH_A_EXISTING_KEY_OVERWRITE ) - btree_au_existing_key = LFDS710_BTREE_AU_EXISTING_KEY_OVERWRITE; - - if( has->existing_key == LFDS710_HASH_A_EXISTING_KEY_FAIL ) - btree_au_existing_key = LFDS710_BTREE_AU_EXISTING_KEY_FAIL; - - // TRD : since the addonly_hash atomic counts, if that flag is set, the btree_addonly_unbalanceds don't have to - for( loop = 0 ; loop < array_size ; loop++ ) - lfds710_btree_au_init_valid_on_current_logical_core( has->baus_array+loop, key_compare_function, btree_au_existing_key, user_state ); - - LFDS710_MISC_BARRIER_STORE; - - lfds710_misc_force_store(); - - return; -} - diff --git a/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_insert.c b/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_insert.c deleted file mode 100644 index 04f65d5..0000000 --- a/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_insert.c +++ /dev/null @@ -1,60 +0,0 @@ -/***** includes *****/ -#include "lfds710_hash_addonly_internal.h" - - - - - -/****************************************************************************/ -enum lfds710_hash_a_insert_result lfds710_hash_a_insert( struct lfds710_hash_a_state *has, - struct lfds710_hash_a_element *hae, - struct lfds710_hash_a_element **existing_hae ) -{ - enum lfds710_hash_a_insert_result - apr = LFDS710_HASH_A_PUT_RESULT_SUCCESS; - - enum lfds710_btree_au_insert_result - alr; - - lfds710_pal_uint_t - hash = 0; - - struct lfds710_btree_au_element - *existing_baue; - - LFDS710_PAL_ASSERT( has != NULL ); - LFDS710_PAL_ASSERT( hae != NULL ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &hae->value % LFDS710_PAL_ALIGN_SINGLE_POINTER == 0 ); - // TRD : existing_hae can be NULL - - // TRD : alignment checks - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &hae->baue % LFDS710_PAL_ALIGN_SINGLE_POINTER == 0 ); - - has->key_hash_function( hae->key, &hash ); - - LFDS710_BTREE_AU_SET_KEY_IN_ELEMENT( hae->baue, hae->key ); - LFDS710_BTREE_AU_SET_VALUE_IN_ELEMENT( hae->baue, hae ); - - alr = lfds710_btree_au_insert( has->baus_array + (hash % has->array_size), &hae->baue, &existing_baue ); - - switch( alr ) - { - case LFDS710_BTREE_AU_INSERT_RESULT_FAILURE_EXISTING_KEY: - if( existing_hae != NULL ) - *existing_hae = LFDS710_BTREE_AU_GET_VALUE_FROM_ELEMENT( *existing_baue ); - - apr = LFDS710_HASH_A_PUT_RESULT_FAILURE_EXISTING_KEY; - break; - - case LFDS710_BTREE_AU_INSERT_RESULT_SUCCESS_OVERWRITE: - apr = LFDS710_HASH_A_PUT_RESULT_SUCCESS_OVERWRITE; - break; - - case LFDS710_BTREE_AU_INSERT_RESULT_SUCCESS: - apr = LFDS710_HASH_A_PUT_RESULT_SUCCESS; - break; - } - - return apr; -} - diff --git a/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_internal.h b/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_internal.h deleted file mode 100644 index 7db9158..0000000 --- a/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_internal.h +++ /dev/null @@ -1,5 +0,0 @@ -/***** the library wide include file *****/ -#include "../liblfds710_internal.h" - -/***** private prototypes *****/ - diff --git a/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_iterate.c b/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_iterate.c deleted file mode 100644 index 0a861f6..0000000 --- a/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_iterate.c +++ /dev/null @@ -1,60 +0,0 @@ -/***** includes *****/ -#include "lfds710_hash_addonly_internal.h" - - - - - -/****************************************************************************/ -void lfds710_hash_a_iterate_init( struct lfds710_hash_a_state *has, - struct lfds710_hash_a_iterate *hai ) -{ - LFDS710_PAL_ASSERT( has != NULL ); - LFDS710_PAL_ASSERT( hai != NULL ); - - hai->baus = has->baus_array; - hai->baus_end = has->baus_array + has->array_size; - hai->baue = NULL; - - return; -} - - - - - -/****************************************************************************/ -int lfds710_hash_a_iterate( struct lfds710_hash_a_iterate *hai, - struct lfds710_hash_a_element **hae ) -{ - enum lfds710_misc_flag - finished_flag = LFDS710_MISC_FLAG_LOWERED; - - int - rv = 0; - - LFDS710_PAL_ASSERT( hai != NULL ); - LFDS710_PAL_ASSERT( hae != NULL ); - - while( finished_flag == LFDS710_MISC_FLAG_LOWERED ) - { - lfds710_btree_au_get_by_absolute_position_and_then_by_relative_position( hai->baus, &hai->baue, LFDS710_BTREE_AU_ABSOLUTE_POSITION_SMALLEST_IN_TREE, LFDS710_BTREE_AU_RELATIVE_POSITION_NEXT_LARGER_ELEMENT_IN_ENTIRE_TREE ); - - if( hai->baue != NULL ) - { - *hae = LFDS710_BTREE_AU_GET_VALUE_FROM_ELEMENT( *hai->baue ); - finished_flag = LFDS710_MISC_FLAG_RAISED; - rv = 1; - } - - if( hai->baue == NULL ) - if( ++hai->baus == hai->baus_end ) - { - *hae = NULL; - finished_flag = LFDS710_MISC_FLAG_RAISED; - } - } - - return rv; -} - diff --git a/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_query.c b/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_query.c deleted file mode 100644 index 66e5897..0000000 --- a/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_query.c +++ /dev/null @@ -1,119 +0,0 @@ -/***** includes *****/ -#include "lfds710_hash_addonly_internal.h" - -/***** private prototypes *****/ -static void lfds710_hash_a_internal_validate( struct lfds710_hash_a_state *has, - struct lfds710_misc_validation_info *vi, - enum lfds710_misc_validity *lfds710_hash_a_validity ); - - - - - -/****************************************************************************/ -void lfds710_hash_a_query( struct lfds710_hash_a_state *has, - enum lfds710_hash_a_query query_type, - void *query_input, - void *query_output ) -{ - LFDS710_PAL_ASSERT( has != NULL ); - // TRD : query_type can be any value in its range - - LFDS710_MISC_BARRIER_LOAD; - - switch( query_type ) - { - case LFDS710_HASH_A_QUERY_GET_POTENTIALLY_INACCURATE_COUNT: - { - struct lfds710_hash_a_iterate - ai; - - struct lfds710_hash_a_element - *hae; - - LFDS710_PAL_ASSERT( query_input == NULL ); - LFDS710_PAL_ASSERT( query_output != NULL ); - - *(lfds710_pal_uint_t *) query_output = 0; - - lfds710_hash_a_iterate_init( has, &ai ); - - while( lfds710_hash_a_iterate(&ai, &hae) ) - ( *(lfds710_pal_uint_t *) query_output )++; - } - break; - - case LFDS710_HASH_A_QUERY_SINGLETHREADED_VALIDATE: - // TRD: query_input can be any value in its range - LFDS710_PAL_ASSERT( query_output != NULL ); - - lfds710_hash_a_internal_validate( has, (struct lfds710_misc_validation_info *) query_input, (enum lfds710_misc_validity *) query_output ); - break; - } - - return; -} - - - - - -/****************************************************************************/ -static void lfds710_hash_a_internal_validate( struct lfds710_hash_a_state *has, - struct lfds710_misc_validation_info *vi, - enum lfds710_misc_validity *lfds710_hash_a_validity ) -{ - lfds710_pal_uint_t - lfds710_hash_a_total_number_elements = 0, - lfds710_btree_au_total_number_elements = 0, - number_elements; - - lfds710_pal_uint_t - loop; - - LFDS710_PAL_ASSERT( has!= NULL ); - // TRD : vi can be NULL - LFDS710_PAL_ASSERT( lfds710_hash_a_validity != NULL ); - - /* TRD : validate every btree_addonly_unbalanced in the addonly_hash - sum elements in each btree_addonly_unbalanced - check matches expected element counts (if vi is provided) - */ - - *lfds710_hash_a_validity = LFDS710_MISC_VALIDITY_VALID; - - for( loop = 0 ; *lfds710_hash_a_validity == LFDS710_MISC_VALIDITY_VALID and loop < has->array_size ; loop++ ) - lfds710_btree_au_query( has->baus_array+loop, LFDS710_BTREE_AU_QUERY_SINGLETHREADED_VALIDATE, NULL, (void *) lfds710_hash_a_validity ); - - if( *lfds710_hash_a_validity == LFDS710_MISC_VALIDITY_VALID ) - { - for( loop = 0 ; loop < has->array_size ; loop++ ) - { - lfds710_btree_au_query( has->baus_array+loop, LFDS710_BTREE_AU_QUERY_GET_POTENTIALLY_INACCURATE_COUNT, NULL, (void *) &number_elements ); - lfds710_btree_au_total_number_elements += number_elements; - } - - // TRD : first, check btree_addonly_unbalanced total vs the addonly_hash total - lfds710_hash_a_query( has, LFDS710_HASH_A_QUERY_GET_POTENTIALLY_INACCURATE_COUNT, NULL, &lfds710_hash_a_total_number_elements ); - - // TRD : the btree_addonly_unbalanceds are assumed to speak the truth - if( lfds710_hash_a_total_number_elements < lfds710_btree_au_total_number_elements ) - *lfds710_hash_a_validity = LFDS710_MISC_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - - if( lfds710_hash_a_total_number_elements > lfds710_btree_au_total_number_elements ) - *lfds710_hash_a_validity = LFDS710_MISC_VALIDITY_INVALID_MISSING_ELEMENTS; - - // TRD : second, if we're still valid and vi is provided, check the btree_addonly_unbalanced total against vi - if( *lfds710_hash_a_validity == LFDS710_MISC_VALIDITY_VALID and vi != NULL ) - { - if( lfds710_btree_au_total_number_elements < vi->min_elements ) - *lfds710_hash_a_validity = LFDS710_MISC_VALIDITY_INVALID_MISSING_ELEMENTS; - - if( lfds710_btree_au_total_number_elements > vi->max_elements ) - *lfds710_hash_a_validity = LFDS710_MISC_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - } - } - - return; -} - diff --git a/liblfds710/src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_cleanup.c b/liblfds710/src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_cleanup.c deleted file mode 100644 index 9a5cad7..0000000 --- a/liblfds710/src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_cleanup.c +++ /dev/null @@ -1,37 +0,0 @@ -/***** includes *****/ -#include "lfds710_list_addonly_singlylinked_ordered_internal.h" - - - - - -/****************************************************************************/ -void lfds710_list_aso_cleanup( struct lfds710_list_aso_state *lasos, - void (*element_cleanup_callback)(struct lfds710_list_aso_state *lasos, struct lfds710_list_aso_element *lasoe) ) -{ - struct lfds710_list_aso_element - *lasoe, - *temp; - - LFDS710_PAL_ASSERT( lasos != NULL ); - // TRD : element_cleanup_callback can be NULL - - LFDS710_MISC_BARRIER_LOAD; - - if( element_cleanup_callback == NULL ) - return; - - lasoe = LFDS710_LIST_ASO_GET_START( *lasos ); - - while( lasoe != NULL ) - { - temp = lasoe; - - lasoe = LFDS710_LIST_ASO_GET_NEXT( *lasoe ); - - element_cleanup_callback( lasos, temp ); - } - - return; -} - diff --git a/liblfds710/src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_get.c b/liblfds710/src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_get.c deleted file mode 100644 index 2f87131..0000000 --- a/liblfds710/src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_get.c +++ /dev/null @@ -1,29 +0,0 @@ -/***** includes *****/ -#include "lfds710_list_addonly_singlylinked_ordered_internal.h" - - - - - -/****************************************************************************/ -int lfds710_list_aso_get_by_key( struct lfds710_list_aso_state *lasos, - void *key, - struct lfds710_list_aso_element **lasoe ) -{ - int - cr = !0, - rv = 1; - - LFDS710_PAL_ASSERT( lasos != NULL ); - // TRD : key can be NULL - LFDS710_PAL_ASSERT( lasoe != NULL ); - - while( cr != 0 and LFDS710_LIST_ASO_GET_START_AND_THEN_NEXT(*lasos, *lasoe) ) - cr = lasos->key_compare_function( key, (*lasoe)->key ); - - if( *lasoe == NULL ) - rv = 0; - - return rv; -} - diff --git a/liblfds710/src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_init.c b/liblfds710/src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_init.c deleted file mode 100644 index 4eba59a..0000000 --- a/liblfds710/src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_init.c +++ /dev/null @@ -1,38 +0,0 @@ -/***** includes *****/ -#include "lfds710_list_addonly_singlylinked_ordered_internal.h" - - - - - -/****************************************************************************/ -void lfds710_list_aso_init_valid_on_current_logical_core( struct lfds710_list_aso_state *lasos, - int (*key_compare_function)(void const *new_key, void const *existing_key), - enum lfds710_list_aso_existing_key existing_key, - void *user_state ) -{ - LFDS710_PAL_ASSERT( lasos != NULL ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &lasos->dummy_element % LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES == 0 ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &lasos->start % LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES == 0 ); - LFDS710_PAL_ASSERT( key_compare_function != NULL ); - // TRD : existing_key can be any value in its range - // TRD : user_state can be NULL - - // TRD : dummy start element - makes code easier when you can always use ->next - lasos->start = &lasos->dummy_element; - - lasos->start->next = NULL; - lasos->start->value = NULL; - lasos->key_compare_function = key_compare_function; - lasos->existing_key = existing_key; - lasos->user_state = user_state; - - lfds710_misc_internal_backoff_init( &lasos->insert_backoff ); - - LFDS710_MISC_BARRIER_STORE; - - lfds710_misc_force_store(); - - return; -} - diff --git a/liblfds710/src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_insert.c b/liblfds710/src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_insert.c deleted file mode 100644 index 9b8c2e7..0000000 --- a/liblfds710/src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_insert.c +++ /dev/null @@ -1,136 +0,0 @@ -/***** includes *****/ -#include "lfds710_list_addonly_singlylinked_ordered_internal.h" - - - - - -/****************************************************************************/ -enum lfds710_list_aso_insert_result lfds710_list_aso_insert( struct lfds710_list_aso_state *lasos, - struct lfds710_list_aso_element *lasoe, - struct lfds710_list_aso_element **existing_lasoe ) -{ - char unsigned - result; - - enum lfds710_misc_flag - finished_flag = LFDS710_MISC_FLAG_LOWERED; - - int - compare_result = 0; - - lfds710_pal_uint_t - backoff_iteration = LFDS710_BACKOFF_INITIAL_VALUE; - - struct lfds710_list_aso_element - *volatile lasoe_temp = NULL, - *volatile lasoe_trailing; - - LFDS710_PAL_ASSERT( lasos != NULL ); - LFDS710_PAL_ASSERT( lasoe != NULL ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &lasoe->next % LFDS710_PAL_ALIGN_SINGLE_POINTER == 0 ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &lasoe->value % LFDS710_PAL_ALIGN_SINGLE_POINTER == 0 ); - // TRD : existing_lasoe can be NULL - - /* TRD : imagine a list, sorted small to large - - we arrive at an element - we obtain its next pointer - we check we are greater than the current element and smaller than the next element - this means we have found the correct location to insert - we try to CAS ourselves in; in the meantime, - someone else has *aready* swapped in an element which is smaller than we are - - e.g. - - the list is { 1, 10 } and we are the value 5 - - we arrive at 1; we check the next element and see it is 10 - so we are larger than the current element and smaller than the next - we are in the correct location to insert and we go to insert... - - in the meantime, someone else with the value 3 comes along - he too finds this is the correct location and inserts before we do - the list is now { 1, 3, 10 } and we are trying to insert now after - 1 and before 3! - - our insert CAS fails, because the next pointer of 1 has changed aready; - but we see we are in the wrong location - we need to move forward an - element - */ - - LFDS710_MISC_BARRIER_LOAD; - - /* TRD : we need to begin with the leading dummy element - as the element to be inserted - may be smaller than all elements in the list - */ - - lasoe_trailing = lasos->start; - lasoe_temp = lasos->start->next; - - while( finished_flag == LFDS710_MISC_FLAG_LOWERED ) - { - if( lasoe_temp == NULL ) - compare_result = -1; - - if( lasoe_temp != NULL ) - { - LFDS710_MISC_BARRIER_LOAD; - compare_result = lasos->key_compare_function( lasoe->key, lasoe_temp->key ); - } - - if( compare_result == 0 ) - { - if( existing_lasoe != NULL ) - *existing_lasoe = lasoe_temp; - - switch( lasos->existing_key ) - { - case LFDS710_LIST_ASO_EXISTING_KEY_OVERWRITE: - LFDS710_LIST_ASO_SET_VALUE_IN_ELEMENT( *lasoe_temp, lasoe->value ); - return LFDS710_LIST_ASO_INSERT_RESULT_SUCCESS_OVERWRITE; - break; - - case LFDS710_LIST_ASO_EXISTING_KEY_FAIL: - return LFDS710_LIST_ASO_INSERT_RESULT_FAILURE_EXISTING_KEY; - break; - } - - finished_flag = LFDS710_MISC_FLAG_RAISED; - } - - if( compare_result < 0 ) - { - lasoe->next = lasoe_temp; - LFDS710_MISC_BARRIER_STORE; - LFDS710_PAL_ATOMIC_CAS( &lasoe_trailing->next, (struct lfds710_list_aso_element **) &lasoe->next, lasoe, LFDS710_MISC_CAS_STRENGTH_WEAK, result ); - - if( result == 1 ) - finished_flag = LFDS710_MISC_FLAG_RAISED; - else - { - LFDS710_BACKOFF_EXPONENTIAL_BACKOFF( lasos->insert_backoff, backoff_iteration ); - // TRD : if we fail to link, someone else has linked and so we need to redetermine our position is correct - lasoe_temp = lasoe_trailing->next; - } - } - - if( compare_result > 0 ) - { - // TRD : move trailing along by one element - lasoe_trailing = lasoe_trailing->next; - - /* TRD : set temp as the element after trailing - if the new element we're linking is larger than all elements in the list, - lasoe_temp will now go to NULL and we'll link at the end - */ - lasoe_temp = lasoe_trailing->next; - } - } - - LFDS710_BACKOFF_AUTOTUNE( lasos->insert_backoff, backoff_iteration ); - - return LFDS710_LIST_ASO_INSERT_RESULT_SUCCESS; -} - diff --git a/liblfds710/src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_internal.h b/liblfds710/src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_internal.h deleted file mode 100644 index 7db9158..0000000 --- a/liblfds710/src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_internal.h +++ /dev/null @@ -1,5 +0,0 @@ -/***** the library wide include file *****/ -#include "../liblfds710_internal.h" - -/***** private prototypes *****/ - diff --git a/liblfds710/src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_query.c b/liblfds710/src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_query.c deleted file mode 100644 index b982654..0000000 --- a/liblfds710/src/lfds710_list_addonly_singlylinked_ordered/lfds710_list_addonly_singlylinked_ordered_query.c +++ /dev/null @@ -1,128 +0,0 @@ -/***** includes *****/ -#include "lfds710_list_addonly_singlylinked_ordered_internal.h" - -/***** private prototypes *****/ -static void lfds710_list_aso_internal_validate( struct lfds710_list_aso_state *lasos, - struct lfds710_misc_validation_info *vi, - enum lfds710_misc_validity *lfds710_list_aso_validity ); - - - - - -/****************************************************************************/ -void lfds710_list_aso_query( struct lfds710_list_aso_state *lasos, - enum lfds710_list_aso_query query_type, - void *query_input, - void *query_output ) -{ - LFDS710_PAL_ASSERT( lasos != NULL ); - // TRD : query_type can be any value in its range - - LFDS710_MISC_BARRIER_LOAD; - - switch( query_type ) - { - case LFDS710_LIST_ASO_QUERY_GET_POTENTIALLY_INACCURATE_COUNT: - { - struct lfds710_list_aso_element - *lasoe = NULL; - - LFDS710_PAL_ASSERT( query_input == NULL ); - LFDS710_PAL_ASSERT( query_output != NULL ); - - *(lfds710_pal_uint_t *) query_output = 0; - - while( LFDS710_LIST_ASO_GET_START_AND_THEN_NEXT(*lasos, lasoe) ) - ( *(lfds710_pal_uint_t *) query_output )++; - } - break; - - case LFDS710_LIST_ASO_QUERY_SINGLETHREADED_VALIDATE: - // TRD : query_input can be NULL - LFDS710_PAL_ASSERT( query_output != NULL ); - - lfds710_list_aso_internal_validate( lasos, (struct lfds710_misc_validation_info *) query_input, (enum lfds710_misc_validity *) query_output ); - break; - } - - return; -} - - - - - - -/****************************************************************************/ -static void lfds710_list_aso_internal_validate( struct lfds710_list_aso_state *lasos, - struct lfds710_misc_validation_info *vi, - enum lfds710_misc_validity *lfds710_list_aso_validity ) -{ - lfds710_pal_uint_t - number_elements = 0; - - struct lfds710_list_aso_element - *lasoe_fast, - *lasoe_slow; - - LFDS710_PAL_ASSERT( lasos!= NULL ); - // TRD : vi can be NULL - LFDS710_PAL_ASSERT( lfds710_list_aso_validity != NULL ); - - *lfds710_list_aso_validity = LFDS710_MISC_VALIDITY_VALID; - - lasoe_slow = lasoe_fast = lasos->start->next; - - /* TRD : first, check for a loop - we have two pointers - both of which start at the start of the list - we enter a loop - and on each iteration - we advance one pointer by one element - and the other by two - - we exit the loop when both pointers are NULL - (have reached the end of the queue) - - or - - if we fast pointer 'sees' the slow pointer - which means we have a loop - */ - - if( lasoe_slow != NULL ) - do - { - lasoe_slow = lasoe_slow->next; - - if( lasoe_fast != NULL ) - lasoe_fast = lasoe_fast->next; - - if( lasoe_fast != NULL ) - lasoe_fast = lasoe_fast->next; - } - while( lasoe_slow != NULL and lasoe_fast != lasoe_slow ); - - if( lasoe_fast != NULL and lasoe_slow != NULL and lasoe_fast == lasoe_slow ) - *lfds710_list_aso_validity = LFDS710_MISC_VALIDITY_INVALID_LOOP; - - /* TRD : now check for expected number of elements - vi can be NULL, in which case we do not check - we know we don't have a loop from our earlier check - */ - - if( *lfds710_list_aso_validity == LFDS710_MISC_VALIDITY_VALID and vi != NULL ) - { - lfds710_list_aso_query( lasos, LFDS710_LIST_ASO_QUERY_GET_POTENTIALLY_INACCURATE_COUNT, NULL, &number_elements ); - - if( number_elements < vi->min_elements ) - *lfds710_list_aso_validity = LFDS710_MISC_VALIDITY_INVALID_MISSING_ELEMENTS; - - if( number_elements > vi->max_elements ) - *lfds710_list_aso_validity = LFDS710_MISC_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - } - - return; -} - diff --git a/liblfds710/src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_cleanup.c b/liblfds710/src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_cleanup.c deleted file mode 100644 index 78969dc..0000000 --- a/liblfds710/src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_cleanup.c +++ /dev/null @@ -1,37 +0,0 @@ -/***** includes *****/ -#include "lfds710_list_addonly_singlylinked_unordered_internal.h" - - - - - -/****************************************************************************/ -void lfds710_list_asu_cleanup( struct lfds710_list_asu_state *lasus, - void (*element_cleanup_callback)(struct lfds710_list_asu_state *lasus, struct lfds710_list_asu_element *lasue) ) -{ - struct lfds710_list_asu_element - *lasue, - *temp; - - LFDS710_PAL_ASSERT( lasus != NULL ); - // TRD : element_cleanup_callback can be NULL - - LFDS710_MISC_BARRIER_LOAD; - - if( element_cleanup_callback == NULL ) - return; - - lasue = LFDS710_LIST_ASU_GET_START( *lasus ); - - while( lasue != NULL ) - { - temp = lasue; - - lasue = LFDS710_LIST_ASU_GET_NEXT( *lasue ); - - element_cleanup_callback( lasus, temp ); - } - - return; -} - diff --git a/liblfds710/src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_get.c b/liblfds710/src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_get.c deleted file mode 100644 index f36483c..0000000 --- a/liblfds710/src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_get.c +++ /dev/null @@ -1,33 +0,0 @@ -/***** includes *****/ -#include "lfds710_list_addonly_singlylinked_unordered_internal.h" - - - - - -/****************************************************************************/ -int lfds710_list_asu_get_by_key( struct lfds710_list_asu_state *lasus, - int (*key_compare_function)(void const *new_key, void const *existing_key), - void *key, - struct lfds710_list_asu_element **lasue ) -{ - int - cr = !0, - rv = 1; - - LFDS710_PAL_ASSERT( lasus != NULL ); - LFDS710_PAL_ASSERT( key_compare_function != NULL ); - // TRD : key can be NULL - LFDS710_PAL_ASSERT( lasue != NULL ); - - *lasue = NULL; - - while( cr != 0 and LFDS710_LIST_ASU_GET_START_AND_THEN_NEXT(*lasus, *lasue) ) - cr = key_compare_function( key, (*lasue)->key ); - - if( *lasue == NULL ) - rv = 0; - - return rv; -} - diff --git a/liblfds710/src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_init.c b/liblfds710/src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_init.c deleted file mode 100644 index cce71db..0000000 --- a/liblfds710/src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_init.c +++ /dev/null @@ -1,35 +0,0 @@ -/***** includes *****/ -#include "lfds710_list_addonly_singlylinked_unordered_internal.h" - - - - - -/****************************************************************************/ -void lfds710_list_asu_init_valid_on_current_logical_core( struct lfds710_list_asu_state *lasus, - void *user_state ) -{ - LFDS710_PAL_ASSERT( lasus != NULL ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &lasus->dummy_element % LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES == 0 ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &lasus->end % LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES == 0 ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &lasus->start % LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES == 0 ); - // TRD : user_state can be NULL - - // TRD : dummy start element - makes code easier when you can always use ->next - lasus->start = lasus->end = &lasus->dummy_element; - - lasus->start->next = NULL; - lasus->start->value = NULL; - lasus->user_state = user_state; - - lfds710_misc_internal_backoff_init( &lasus->after_backoff ); - lfds710_misc_internal_backoff_init( &lasus->start_backoff ); - lfds710_misc_internal_backoff_init( &lasus->end_backoff ); - - LFDS710_MISC_BARRIER_STORE; - - lfds710_misc_force_store(); - - return; -} - diff --git a/liblfds710/src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_insert.c b/liblfds710/src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_insert.c deleted file mode 100644 index ba42d1f..0000000 --- a/liblfds710/src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_insert.c +++ /dev/null @@ -1,193 +0,0 @@ -/***** includes *****/ -#include "lfds710_list_addonly_singlylinked_unordered_internal.h" - - - - - -/****************************************************************************/ -void lfds710_list_asu_insert_at_position( struct lfds710_list_asu_state *lasus, - struct lfds710_list_asu_element *lasue, - struct lfds710_list_asu_element *lasue_predecessor, - enum lfds710_list_asu_position position ) -{ - LFDS710_PAL_ASSERT( lasus != NULL ); - LFDS710_PAL_ASSERT( lasue != NULL ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &lasue->next % LFDS710_PAL_ALIGN_SINGLE_POINTER == 0 ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &lasue->value % LFDS710_PAL_ALIGN_SINGLE_POINTER == 0 ); - // TRD : lasue_predecessor asserted in the switch - // TRD : position can be any value in its range - - switch( position ) - { - case LFDS710_LIST_ASU_POSITION_START: - lfds710_list_asu_insert_at_start( lasus, lasue ); - break; - - case LFDS710_LIST_ASU_POSITION_END: - lfds710_list_asu_insert_at_end( lasus, lasue ); - break; - - case LFDS710_LIST_ASU_POSITION_AFTER: - lfds710_list_asu_insert_after_element( lasus, lasue, lasue_predecessor ); - break; - } - - return; -} - - - - - -/****************************************************************************/ -void lfds710_list_asu_insert_at_start( struct lfds710_list_asu_state *lasus, - struct lfds710_list_asu_element *lasue ) -{ - char unsigned - result; - - lfds710_pal_uint_t - backoff_iteration = LFDS710_BACKOFF_INITIAL_VALUE; - - LFDS710_PAL_ASSERT( lasus != NULL ); - LFDS710_PAL_ASSERT( lasue != NULL ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &lasue->next % LFDS710_PAL_ALIGN_SINGLE_POINTER == 0 ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &lasue->value % LFDS710_PAL_ALIGN_SINGLE_POINTER == 0 ); - - LFDS710_MISC_BARRIER_LOAD; - - lasue->next = lasus->start->next; - - do - { - LFDS710_MISC_BARRIER_STORE; - LFDS710_PAL_ATOMIC_CAS( &lasus->start->next, (struct lfds710_list_asu_element **) &lasue->next, lasue, LFDS710_MISC_CAS_STRENGTH_WEAK, result ); - if( result == 0 ) - LFDS710_BACKOFF_EXPONENTIAL_BACKOFF( lasus->start_backoff, backoff_iteration ); - } - while( result == 0 ); - - LFDS710_BACKOFF_AUTOTUNE( lasus->start_backoff, backoff_iteration ); - - return; -} - - - - - -/****************************************************************************/ -void lfds710_list_asu_insert_at_end( struct lfds710_list_asu_state *lasus, - struct lfds710_list_asu_element *lasue ) -{ - char unsigned - result; - - enum lfds710_misc_flag - finished_flag = LFDS710_MISC_FLAG_LOWERED; - - lfds710_pal_uint_t - backoff_iteration = LFDS710_BACKOFF_INITIAL_VALUE; - - struct lfds710_list_asu_element LFDS710_PAL_ALIGN(LFDS710_PAL_ALIGN_SINGLE_POINTER) - *compare; - - struct lfds710_list_asu_element - *volatile lasue_next, - *volatile lasue_end; - - LFDS710_PAL_ASSERT( lasus != NULL ); - LFDS710_PAL_ASSERT( lasue != NULL ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &lasue->next % LFDS710_PAL_ALIGN_SINGLE_POINTER == 0 ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &lasue->value % LFDS710_PAL_ALIGN_SINGLE_POINTER == 0 ); - - /* TRD : begin by assuming end is correctly pointing to the final element - try to link (comparing for next being NULL) - if we fail, move down list till we find last element - and retry - when successful, update end to ourselves - - note there's a leading dummy element - so lasus->end always points to an element - */ - - LFDS710_MISC_BARRIER_LOAD; - - lasue->next = NULL; - lasue_end = lasus->end; - - while( finished_flag == LFDS710_MISC_FLAG_LOWERED ) - { - compare = NULL; - - LFDS710_MISC_BARRIER_STORE; - LFDS710_PAL_ATOMIC_CAS( &lasue_end->next, &compare, lasue, LFDS710_MISC_CAS_STRENGTH_STRONG, result ); - - if( result == 1 ) - finished_flag = LFDS710_MISC_FLAG_RAISED; - else - { - LFDS710_BACKOFF_EXPONENTIAL_BACKOFF( lasus->end_backoff, backoff_iteration ); - - lasue_end = compare; - lasue_next = LFDS710_LIST_ASU_GET_NEXT( *lasue_end ); - - while( lasue_next != NULL ) - { - lasue_end = lasue_next; - lasue_next = LFDS710_LIST_ASU_GET_NEXT( *lasue_end ); - } - } - } - - lasus->end = lasue; - - LFDS710_BACKOFF_AUTOTUNE( lasus->end_backoff, backoff_iteration ); - - return; -} - - - - - -/****************************************************************************/ -#pragma warning( disable : 4100 ) - -void lfds710_list_asu_insert_after_element( struct lfds710_list_asu_state *lasus, - struct lfds710_list_asu_element *lasue, - struct lfds710_list_asu_element *lasue_predecessor ) -{ - char unsigned - result; - - lfds710_pal_uint_t - backoff_iteration = LFDS710_BACKOFF_INITIAL_VALUE; - - LFDS710_PAL_ASSERT( lasus != NULL ); - LFDS710_PAL_ASSERT( lasue != NULL ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &lasue->next % LFDS710_PAL_ALIGN_SINGLE_POINTER == 0 ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &lasue->value % LFDS710_PAL_ALIGN_SINGLE_POINTER == 0 ); - LFDS710_PAL_ASSERT( lasue_predecessor != NULL ); - - LFDS710_MISC_BARRIER_LOAD; - - lasue->next = lasue_predecessor->next; - - do - { - LFDS710_MISC_BARRIER_STORE; - LFDS710_PAL_ATOMIC_CAS( &lasue_predecessor->next, (struct lfds710_list_asu_element **) &lasue->next, lasue, LFDS710_MISC_CAS_STRENGTH_WEAK, result ); - if( result == 0 ) - LFDS710_BACKOFF_EXPONENTIAL_BACKOFF( lasus->after_backoff, backoff_iteration ); - } - while( result == 0 ); - - LFDS710_BACKOFF_AUTOTUNE( lasus->after_backoff, backoff_iteration ); - - return; -} - -#pragma warning( default : 4100 ) - diff --git a/liblfds710/src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_internal.h b/liblfds710/src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_internal.h deleted file mode 100644 index 7db9158..0000000 --- a/liblfds710/src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_internal.h +++ /dev/null @@ -1,5 +0,0 @@ -/***** the library wide include file *****/ -#include "../liblfds710_internal.h" - -/***** private prototypes *****/ - diff --git a/liblfds710/src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_query.c b/liblfds710/src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_query.c deleted file mode 100644 index 2277422..0000000 --- a/liblfds710/src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_query.c +++ /dev/null @@ -1,128 +0,0 @@ -/***** includes *****/ -#include "lfds710_list_addonly_singlylinked_unordered_internal.h" - -/***** private prototypes *****/ -static void lfds710_list_asu_internal_validate( struct lfds710_list_asu_state *lasus, - struct lfds710_misc_validation_info *vi, - enum lfds710_misc_validity *lfds710_list_asu_validity ); - - - - - -/****************************************************************************/ -void lfds710_list_asu_query( struct lfds710_list_asu_state *lasus, - enum lfds710_list_asu_query query_type, - void *query_input, - void *query_output ) -{ - LFDS710_PAL_ASSERT( lasus != NULL ); - // TRD : query_type can be any value in its range - - LFDS710_MISC_BARRIER_LOAD; - - switch( query_type ) - { - case LFDS710_LIST_ASU_QUERY_GET_POTENTIALLY_INACCURATE_COUNT: - { - struct lfds710_list_asu_element - *lasue = NULL; - - LFDS710_PAL_ASSERT( query_input == NULL ); - LFDS710_PAL_ASSERT( query_output != NULL ); - - *(lfds710_pal_uint_t *) query_output = 0; - - while( LFDS710_LIST_ASU_GET_START_AND_THEN_NEXT(*lasus, lasue) ) - ( *(lfds710_pal_uint_t *) query_output )++; - } - break; - - case LFDS710_LIST_ASU_QUERY_SINGLETHREADED_VALIDATE: - // TRD : query_input can be NULL - LFDS710_PAL_ASSERT( query_output != NULL ); - - lfds710_list_asu_internal_validate( lasus, (struct lfds710_misc_validation_info *) query_input, (enum lfds710_misc_validity *) query_output ); - break; - } - - return; -} - - - - - - -/****************************************************************************/ -static void lfds710_list_asu_internal_validate( struct lfds710_list_asu_state *lasus, - struct lfds710_misc_validation_info *vi, - enum lfds710_misc_validity *lfds710_list_asu_validity ) -{ - lfds710_pal_uint_t - number_elements = 0; - - struct lfds710_list_asu_element - *lasue_fast, - *lasue_slow; - - LFDS710_PAL_ASSERT( lasus!= NULL ); - // TRD : vi can be NULL - LFDS710_PAL_ASSERT( lfds710_list_asu_validity != NULL ); - - *lfds710_list_asu_validity = LFDS710_MISC_VALIDITY_VALID; - - lasue_slow = lasue_fast = lasus->start->next; - - /* TRD : first, check for a loop - we have two pointers - both of which start at the start of the list - we enter a loop - and on each iteration - we advance one pointer by one element - and the other by two - - we exit the loop when both pointers are NULL - (have reached the end of the queue) - - or - - if we fast pointer 'sees' the slow pointer - which means we have a loop - */ - - if( lasue_slow != NULL ) - do - { - lasue_slow = lasue_slow->next; - - if( lasue_fast != NULL ) - lasue_fast = lasue_fast->next; - - if( lasue_fast != NULL ) - lasue_fast = lasue_fast->next; - } - while( lasue_slow != NULL and lasue_fast != lasue_slow ); - - if( lasue_fast != NULL and lasue_slow != NULL and lasue_fast == lasue_slow ) - *lfds710_list_asu_validity = LFDS710_MISC_VALIDITY_INVALID_LOOP; - - /* TRD : now check for expected number of elements - vi can be NULL, in which case we do not check - we know we don't have a loop from our earlier check - */ - - if( *lfds710_list_asu_validity == LFDS710_MISC_VALIDITY_VALID and vi != NULL ) - { - lfds710_list_asu_query( lasus, LFDS710_LIST_ASU_QUERY_GET_POTENTIALLY_INACCURATE_COUNT, NULL, &number_elements ); - - if( number_elements < vi->min_elements ) - *lfds710_list_asu_validity = LFDS710_MISC_VALIDITY_INVALID_MISSING_ELEMENTS; - - if( number_elements > vi->max_elements ) - *lfds710_list_asu_validity = LFDS710_MISC_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - } - - return; -} - diff --git a/liblfds710/src/lfds710_misc/lfds710_misc_globals.c b/liblfds710/src/lfds710_misc/lfds710_misc_globals.c deleted file mode 100644 index cc80cf7..0000000 --- a/liblfds710/src/lfds710_misc/lfds710_misc_globals.c +++ /dev/null @@ -1,14 +0,0 @@ -/***** includes *****/ -#include "lfds710_misc_internal.h" - - - - - -/****************************************************************************/ -struct lfds710_misc_globals - lfds710_misc_globals = - { - { LFDS710_PRNG_SEED } - }; - diff --git a/liblfds710/src/lfds710_misc/lfds710_misc_internal.h b/liblfds710/src/lfds710_misc/lfds710_misc_internal.h deleted file mode 100644 index 6b06f56..0000000 --- a/liblfds710/src/lfds710_misc/lfds710_misc_internal.h +++ /dev/null @@ -1,5 +0,0 @@ -/***** the library wide include file *****/ -#include "../liblfds710_internal.h" - -/***** private prototypes *****/ -void lfds710_misc_prng_internal_big_slow_high_quality_init( int long long unsigned seed ); diff --git a/liblfds710/src/lfds710_misc/lfds710_misc_internal_backoff_init.c b/liblfds710/src/lfds710_misc/lfds710_misc_internal_backoff_init.c deleted file mode 100644 index 7a2256c..0000000 --- a/liblfds710/src/lfds710_misc/lfds710_misc_internal_backoff_init.c +++ /dev/null @@ -1,22 +0,0 @@ -/***** includes *****/ -#include "lfds710_misc_internal.h" - - - - - -/****************************************************************************/ -void lfds710_misc_internal_backoff_init( struct lfds710_misc_backoff_state *bs ) -{ - LFDS710_PAL_ASSERT( bs != NULL ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &bs->lock % LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES == 0 ); - - bs->lock = LFDS710_MISC_FLAG_LOWERED; - bs->backoff_iteration_frequency_counters[0] = 0; - bs->backoff_iteration_frequency_counters[1] = 0; - bs->metric = 1; - bs->total_operations = 0; - - return; -} - diff --git a/liblfds710/src/lfds710_misc/lfds710_misc_query.c b/liblfds710/src/lfds710_misc/lfds710_misc_query.c deleted file mode 100644 index 8009de8..0000000 --- a/liblfds710/src/lfds710_misc/lfds710_misc_query.c +++ /dev/null @@ -1,38 +0,0 @@ -/***** includes *****/ -#include "lfds710_misc_internal.h" - - - - - -/****************************************************************************/ -#pragma warning( disable : 4100 ) - -void lfds710_misc_query( enum lfds710_misc_query query_type, - void *query_input, - void *query_output ) -{ - // TRD : query type can be any value in its range - // TRD : query_input can be NULL in some cases - // TRD : query_outputput can be NULL in some cases - - switch( query_type ) - { - case LFDS710_MISC_QUERY_GET_BUILD_AND_VERSION_STRING: - { - static char const - * const build_and_version_string = "liblfds " LFDS710_MISC_VERSION_STRING " (" BUILD_TYPE_STRING ", " LFDS710_PAL_OS_STRING ", " MODE_TYPE_STRING ", " LFDS710_PAL_PROCESSOR_STRING ", " LFDS710_PAL_COMPILER_STRING ")"; - - LFDS710_PAL_ASSERT( query_input == NULL ); - LFDS710_PAL_ASSERT( query_output != NULL ); - - *(char const **) query_output = build_and_version_string; - } - break; - } - - return; -} - -#pragma warning( default : 4100 ) - diff --git a/liblfds710/src/lfds710_prng/lfds710_prng_init.c b/liblfds710/src/lfds710_prng/lfds710_prng_init.c deleted file mode 100644 index aa6ea42..0000000 --- a/liblfds710/src/lfds710_prng/lfds710_prng_init.c +++ /dev/null @@ -1,42 +0,0 @@ -/***** includes *****/ -#include "lfds710_prng_internal.h" - - - - - -/****************************************************************************/ -void lfds710_prng_init_valid_on_current_logical_core( struct lfds710_prng_state *ps, lfds710_pal_uint_t seed ) -{ - LFDS710_PAL_ASSERT( ps != NULL ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &ps->entropy % LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES == 0 ); - // TRD : seed can be any value in its range (unlike for the mixing function) - - LFDS710_PRNG_ST_MIXING_FUNCTION( seed ); - - ps->entropy = seed; - - LFDS710_MISC_BARRIER_STORE; - - lfds710_misc_force_store(); - - return; -} - - - - - -/****************************************************************************/ -void lfds710_prng_st_init( struct lfds710_prng_st_state *psts, lfds710_pal_uint_t seed ) -{ - LFDS710_PAL_ASSERT( psts != NULL ); - LFDS710_PAL_ASSERT( seed != 0 ); - - LFDS710_PRNG_ST_MIXING_FUNCTION( seed ); - - psts->entropy = seed; - - return; -} - diff --git a/liblfds710/src/lfds710_prng/lfds710_prng_internal.h b/liblfds710/src/lfds710_prng/lfds710_prng_internal.h deleted file mode 100644 index 7db9158..0000000 --- a/liblfds710/src/lfds710_prng/lfds710_prng_internal.h +++ /dev/null @@ -1,5 +0,0 @@ -/***** the library wide include file *****/ -#include "../liblfds710_internal.h" - -/***** private prototypes *****/ - diff --git a/liblfds710/src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_cleanup.c b/liblfds710/src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_cleanup.c deleted file mode 100644 index ff9cea1..0000000 --- a/liblfds710/src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_cleanup.c +++ /dev/null @@ -1,27 +0,0 @@ -/***** includes *****/ -#include "lfds710_queue_bounded_manyproducer_manyconsumer_internal.h" - - - - - -/****************************************************************************/ -void lfds710_queue_bmm_cleanup( struct lfds710_queue_bmm_state *qbmms, - void (*element_cleanup_callback)(struct lfds710_queue_bmm_state *qbmms, void *key, void *value) ) -{ - void - *key, - *value; - - LFDS710_PAL_ASSERT( qbmms != NULL ); - // TRD : element_cleanup_callback can be NULL - - LFDS710_MISC_BARRIER_LOAD; - - if( element_cleanup_callback != NULL ) - while( lfds710_queue_bmm_dequeue(qbmms,&key,&value) ) - element_cleanup_callback( qbmms, key, value ); - - return; -} - diff --git a/liblfds710/src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_dequeue.c b/liblfds710/src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_dequeue.c deleted file mode 100644 index 1e9486e..0000000 --- a/liblfds710/src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_dequeue.c +++ /dev/null @@ -1,86 +0,0 @@ -/***** includes *****/ -#include "lfds710_queue_bounded_manyproducer_manyconsumer_internal.h" - - - - - -/****************************************************************************/ -int lfds710_queue_bmm_dequeue( struct lfds710_queue_bmm_state *qbmms, - void **key, - void **value ) -{ - char unsigned - result; - - enum lfds710_misc_flag - finished_flag = LFDS710_MISC_FLAG_LOWERED; - - int - rv = 1; - - lfds710_pal_uint_t - read_index, - sequence_number; - - lfds710_pal_int_t - difference; - - lfds710_pal_uint_t - backoff_iteration = LFDS710_BACKOFF_INITIAL_VALUE; - - struct lfds710_queue_bmm_element - *qbmme = NULL; - - LFDS710_PAL_ASSERT( qbmms != NULL ); - // TRD : key can be NULL - // TRD : value can be NULL - - LFDS710_MISC_BARRIER_LOAD; - - read_index = qbmms->read_index; - - while( finished_flag == LFDS710_MISC_FLAG_LOWERED ) - { - qbmme = &qbmms->element_array[ read_index & qbmms->mask ]; - LFDS710_MISC_BARRIER_LOAD; - sequence_number = qbmme->sequence_number; - difference = (lfds710_pal_int_t) sequence_number - (lfds710_pal_int_t) (read_index + 1); - - if( difference == 0 ) - { - LFDS710_PAL_ATOMIC_CAS( &qbmms->read_index, &read_index, read_index + 1, LFDS710_MISC_CAS_STRENGTH_WEAK, result ); - if( result == 0 ) - LFDS710_BACKOFF_EXPONENTIAL_BACKOFF( qbmms->dequeue_backoff, backoff_iteration ); - if( result == 1 ) - finished_flag = LFDS710_MISC_FLAG_RAISED; - } - - if( difference < 0 ) - { - rv = 0; - finished_flag = LFDS710_MISC_FLAG_RAISED; - } - - if( difference > 0 ) - { - LFDS710_MISC_BARRIER_LOAD; - read_index = qbmms->read_index; - } - } - - if( rv == 1 ) - { - if( key != NULL ) - *key = qbmme->key; - if( value != NULL ) - *value = qbmme->value; - LFDS710_MISC_BARRIER_STORE; - qbmme->sequence_number = read_index + qbmms->mask + 1; - } - - LFDS710_BACKOFF_AUTOTUNE( qbmms->dequeue_backoff, backoff_iteration ); - - return rv; -} - diff --git a/liblfds710/src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_enqueue.c b/liblfds710/src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_enqueue.c deleted file mode 100644 index d666c8d..0000000 --- a/liblfds710/src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_enqueue.c +++ /dev/null @@ -1,84 +0,0 @@ -/***** includes *****/ -#include "lfds710_queue_bounded_manyproducer_manyconsumer_internal.h" - - - - - -/****************************************************************************/ -int lfds710_queue_bmm_enqueue( struct lfds710_queue_bmm_state *qbmms, - void *key, - void *value ) -{ - char unsigned - result; - - enum lfds710_misc_flag - finished_flag = LFDS710_MISC_FLAG_LOWERED; - - int - rv = 1; - - lfds710_pal_uint_t - sequence_number, - write_index; - - lfds710_pal_int_t - difference; - - lfds710_pal_uint_t - backoff_iteration = LFDS710_BACKOFF_INITIAL_VALUE; - - struct lfds710_queue_bmm_element - *qbmme = NULL; - - LFDS710_PAL_ASSERT( qbmms != NULL ); - // TRD : key can be NULL - // TRD : value can be NULL - - LFDS710_MISC_BARRIER_LOAD; - - write_index = qbmms->write_index; - - while( finished_flag == LFDS710_MISC_FLAG_LOWERED ) - { - qbmme = &qbmms->element_array[ write_index & qbmms->mask ]; - LFDS710_MISC_BARRIER_LOAD; - sequence_number = qbmme->sequence_number; - difference = (lfds710_pal_int_t) sequence_number - (lfds710_pal_int_t) write_index; - - if( difference == 0 ) - { - LFDS710_PAL_ATOMIC_CAS( &qbmms->write_index, &write_index, write_index + 1, LFDS710_MISC_CAS_STRENGTH_WEAK, result ); - if( result == 0 ) - LFDS710_BACKOFF_EXPONENTIAL_BACKOFF( qbmms->enqueue_backoff, backoff_iteration ); - if( result == 1 ) - finished_flag = LFDS710_MISC_FLAG_RAISED; - } - - if( difference < 0 ) - { - rv = 0; - finished_flag = LFDS710_MISC_FLAG_RAISED; - } - - if( difference > 0 ) - { - LFDS710_MISC_BARRIER_LOAD; - write_index = qbmms->write_index; - } - } - - if( rv == 1 ) - { - qbmme->key = key; - qbmme->value = value; - LFDS710_MISC_BARRIER_STORE; - qbmme->sequence_number = write_index + 1; - } - - LFDS710_BACKOFF_AUTOTUNE( qbmms->enqueue_backoff, backoff_iteration ); - - return rv; -} - diff --git a/liblfds710/src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_init.c b/liblfds710/src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_init.c deleted file mode 100644 index 76743e5..0000000 --- a/liblfds710/src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_init.c +++ /dev/null @@ -1,42 +0,0 @@ -/***** includes *****/ -#include "lfds710_queue_bounded_manyproducer_manyconsumer_internal.h" - - - - - -/****************************************************************************/ -void lfds710_queue_bmm_init_valid_on_current_logical_core( struct lfds710_queue_bmm_state *qbmms, - struct lfds710_queue_bmm_element *element_array, - lfds710_pal_uint_t number_elements, - void *user_state ) -{ - lfds710_pal_uint_t - loop; - - LFDS710_PAL_ASSERT( qbmms != NULL ); - LFDS710_PAL_ASSERT( element_array != NULL ); - LFDS710_PAL_ASSERT( number_elements >= 2 ); - LFDS710_PAL_ASSERT( ( number_elements & (number_elements-1) ) == 0 ); // TRD : number_elements must be a positive integer power of 2 - // TRD : user_state can be NULL - - qbmms->number_elements = number_elements; - qbmms->mask = qbmms->number_elements - 1; - qbmms->read_index = 0; - qbmms->write_index = 0; - qbmms->element_array = element_array; - qbmms->user_state = user_state; - - for( loop = 0 ; loop < qbmms->number_elements ; loop++ ) - qbmms->element_array[loop].sequence_number = loop; - - lfds710_misc_internal_backoff_init( &qbmms->dequeue_backoff ); - lfds710_misc_internal_backoff_init( &qbmms->enqueue_backoff ); - - LFDS710_MISC_BARRIER_STORE; - - lfds710_misc_force_store(); - - return; -} - diff --git a/liblfds710/src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_internal.h b/liblfds710/src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_internal.h deleted file mode 100644 index 7db9158..0000000 --- a/liblfds710/src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_internal.h +++ /dev/null @@ -1,5 +0,0 @@ -/***** the library wide include file *****/ -#include "../liblfds710_internal.h" - -/***** private prototypes *****/ - diff --git a/liblfds710/src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_query.c b/liblfds710/src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_query.c deleted file mode 100644 index 792a44b..0000000 --- a/liblfds710/src/lfds710_queue_bounded_manyproducer_manyconsumer/lfds710_queue_bounded_manyproducer_manyconsumer_query.c +++ /dev/null @@ -1,129 +0,0 @@ -/***** includes *****/ -#include "lfds710_queue_bounded_manyproducer_manyconsumer_internal.h" - -/***** private prototypes *****/ -static void lfds710_queue_bmm_internal_validate( struct lfds710_queue_bmm_state *qbmms, - struct lfds710_misc_validation_info *vi, - enum lfds710_misc_validity *lfds710_validity ); - - - - - -/****************************************************************************/ -void lfds710_queue_bmm_query( struct lfds710_queue_bmm_state *qbmms, - enum lfds710_queue_bmm_query query_type, - void *query_input, - void *query_output ) -{ - LFDS710_PAL_ASSERT( qbmms != NULL ); - // TRD : query_type can be any value in its range - - switch( query_type ) - { - case LFDS710_QUEUE_BMM_QUERY_GET_POTENTIALLY_INACCURATE_COUNT: - { - lfds710_pal_uint_t - local_read_index, - local_write_index; - - LFDS710_PAL_ASSERT( query_input == NULL ); - LFDS710_PAL_ASSERT( query_output != NULL ); - - LFDS710_MISC_BARRIER_LOAD; - - local_read_index = qbmms->read_index; - local_write_index = qbmms->write_index; - - *(lfds710_pal_uint_t *) query_output = +( local_write_index - local_read_index ); - - if( local_read_index > local_write_index ) - *(lfds710_pal_uint_t *) query_output = ((lfds710_pal_uint_t) -1) - *(lfds710_pal_uint_t *) query_output; - } - break; - - case LFDS710_QUEUE_BMM_QUERY_SINGLETHREADED_VALIDATE: - // TRD : query_input can be NULL - LFDS710_PAL_ASSERT( query_output != NULL ); - - lfds710_queue_bmm_internal_validate( qbmms, (struct lfds710_misc_validation_info *) query_input, (enum lfds710_misc_validity *) query_output ); - break; - } - - return; -} - - - - - -/****************************************************************************/ -static void lfds710_queue_bmm_internal_validate( struct lfds710_queue_bmm_state *qbmms, - struct lfds710_misc_validation_info *vi, - enum lfds710_misc_validity *lfds710_validity ) -{ - lfds710_pal_uint_t - expected_sequence_number, - loop, - number_elements, - sequence_number; - - LFDS710_PAL_ASSERT( qbmms != NULL ); - // TRD : vi can be NULL - LFDS710_PAL_ASSERT( lfds710_validity != NULL ); - - *lfds710_validity = LFDS710_MISC_VALIDITY_VALID; - - /* TRD : starting from the read_index, we should find number_elements of incrementing sequence numbers - we then perform a second scan from the write_index onwards, which should have (max elements in queue - number_elements) incrementing sequence numbers - */ - - lfds710_queue_bmm_query( qbmms, LFDS710_QUEUE_BMM_QUERY_GET_POTENTIALLY_INACCURATE_COUNT, NULL, (void *) &number_elements ); - - expected_sequence_number = qbmms->element_array[ qbmms->read_index & qbmms->mask ].sequence_number; - - for( loop = 0 ; loop < number_elements ; loop++ ) - { - sequence_number = qbmms->element_array[ (qbmms->read_index + loop) & qbmms->mask ].sequence_number; - - if( sequence_number != expected_sequence_number ) - *lfds710_validity = LFDS710_MISC_VALIDITY_INVALID_ORDER; - - if( sequence_number == expected_sequence_number ) - expected_sequence_number = sequence_number + 1; - } - - // TRD : now the write_index onwards - - expected_sequence_number = qbmms->element_array[ qbmms->write_index & qbmms->mask ].sequence_number; - - for( loop = 0 ; loop < qbmms->number_elements - number_elements ; loop++ ) - { - sequence_number = qbmms->element_array[ (qbmms->write_index + loop) & qbmms->mask ].sequence_number; - - if( sequence_number != expected_sequence_number ) - *lfds710_validity = LFDS710_MISC_VALIDITY_INVALID_ORDER; - - if( sequence_number == expected_sequence_number ) - expected_sequence_number = sequence_number + 1; - } - - // TRD : now check against the expected number of elements - - if( *lfds710_validity == LFDS710_MISC_VALIDITY_VALID and vi != NULL ) - { - lfds710_pal_uint_t - number_elements; - - lfds710_queue_bmm_query( qbmms, LFDS710_QUEUE_BMM_QUERY_GET_POTENTIALLY_INACCURATE_COUNT, NULL, (void *) &number_elements ); - - if( number_elements < vi->min_elements ) - *lfds710_validity = LFDS710_MISC_VALIDITY_INVALID_MISSING_ELEMENTS; - - if( number_elements > vi->max_elements ) - *lfds710_validity = LFDS710_MISC_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - } - - return; -} - diff --git a/liblfds710/src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_cleanup.c b/liblfds710/src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_cleanup.c deleted file mode 100644 index 0531038..0000000 --- a/liblfds710/src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_cleanup.c +++ /dev/null @@ -1,30 +0,0 @@ -/***** includes *****/ -#include "lfds710_queue_bounded_singleproducer_singleconsumer_internal.h" - - - - - -/****************************************************************************/ -void lfds710_queue_bss_cleanup( struct lfds710_queue_bss_state *qbsss, - void (*element_cleanup_callback)(struct lfds710_queue_bss_state *qbsss, void *key, void *value) ) -{ - lfds710_pal_uint_t - loop; - - struct lfds710_queue_bss_element - *qbsse; - - LFDS710_PAL_ASSERT( qbsss != NULL ); - // TRD : element_cleanup_callback can be NULL - - if( element_cleanup_callback != NULL ) - for( loop = qbsss->read_index ; loop < qbsss->read_index + qbsss->number_elements ; loop++ ) - { - qbsse = qbsss->element_array + (loop % qbsss->number_elements); - element_cleanup_callback( qbsss, qbsse->key, qbsse->value ); - } - - return; -} - diff --git a/liblfds710/src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_dequeue.c b/liblfds710/src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_dequeue.c deleted file mode 100644 index 2c5174e..0000000 --- a/liblfds710/src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_dequeue.c +++ /dev/null @@ -1,41 +0,0 @@ -/***** includes *****/ -#include "lfds710_queue_bounded_singleproducer_singleconsumer_internal.h" - - - - - -/****************************************************************************/ -int lfds710_queue_bss_dequeue( struct lfds710_queue_bss_state *qbsss, - void **key, - void **value ) -{ - struct lfds710_queue_bss_element - *qbsse; - - LFDS710_PAL_ASSERT( qbsss != NULL ); - // TRD : key can be NULL - // TRD : value can be NULL - - LFDS710_MISC_BARRIER_LOAD; - - if( qbsss->read_index != qbsss->write_index ) - { - qbsse = qbsss->element_array + qbsss->read_index; - - if( key != NULL ) - *key = qbsse->key; - - if( value != NULL ) - *value = qbsse->value; - - qbsss->read_index = (qbsss->read_index + 1) & qbsss->mask; - - LFDS710_MISC_BARRIER_STORE; - - return 1; - } - - return 0; -} - diff --git a/liblfds710/src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_enqueue.c b/liblfds710/src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_enqueue.c deleted file mode 100644 index aaaae41..0000000 --- a/liblfds710/src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_enqueue.c +++ /dev/null @@ -1,38 +0,0 @@ -/***** includes *****/ -#include "lfds710_queue_bounded_singleproducer_singleconsumer_internal.h" - - - - - -/****************************************************************************/ -int lfds710_queue_bss_enqueue( struct lfds710_queue_bss_state *qbsss, - void *key, - void *value ) -{ - struct lfds710_queue_bss_element - *qbsse; - - LFDS710_PAL_ASSERT( qbsss != NULL ); - // TRD : key can be NULL - // TRD : value can be NULL - - LFDS710_MISC_BARRIER_LOAD; - - if( ( (qbsss->write_index+1) & qbsss->mask ) != qbsss->read_index ) - { - qbsse = qbsss->element_array + qbsss->write_index; - - qbsse->key = key; - qbsse->value = value; - - LFDS710_MISC_BARRIER_STORE; - - qbsss->write_index = (qbsss->write_index + 1) & qbsss->mask; - - return 1; - } - - return 0; -} - diff --git a/liblfds710/src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_init.c b/liblfds710/src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_init.c deleted file mode 100644 index 276d0a7..0000000 --- a/liblfds710/src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_init.c +++ /dev/null @@ -1,63 +0,0 @@ -/***** includes *****/ -#include "lfds710_queue_bounded_singleproducer_singleconsumer_internal.h" - - - - - -/****************************************************************************/ -void lfds710_queue_bss_init_valid_on_current_logical_core( struct lfds710_queue_bss_state *qbsss, - struct lfds710_queue_bss_element *element_array, - lfds710_pal_uint_t number_elements, - void *user_state ) -{ - LFDS710_PAL_ASSERT( qbsss != NULL ); - LFDS710_PAL_ASSERT( element_array != NULL ); - LFDS710_PAL_ASSERT( number_elements >= 2 ); - LFDS710_PAL_ASSERT( ( number_elements & (number_elements-1) ) == 0 ); // TRD : number_elements must be a positive integer power of 2 - // TRD : user_state can be NULL - - /* TRD : the use of mask and the restriction on a power of two - upon the number of elements bears some remark - - in this queue, there are a fixed number of elements - we have a read index and a write index - when we write, and thre is space to write, we increment the write index - (if no space to write, we just return) - when we read, and there are elements to be read, we after reading increment the read index - (if no elements to read, we just return) - the problem is - how do we handle wrap around? - e.g. when I write, but my write index is now equal to the number of elements - the usual solution is to modulus the write index by the nunmber of elements - problem is modulus is slow - there is a better way - first, we restrict the number of elements to be a power of two - so imagine we have a 64-bit system and we set the number of elements to be 2^64 - this gives us a bit pattern of 1000 0000 0000 0000 (...etc, lots of zeros) - now (just roll with this for a bit) subtract one from this - this gives us a mask (on a two's compliment machine) - 0111 1111 1111 1111 (...etc, lots of ones) - so what we do now, when we increment an index (think of the write index as the example) - we bitwise and it with the mask - now think about thwt happens - all the numbers up to 2^64 will be unchanged - their MSB is never set, and we and with all the other bits - but when we finally hit 2^64 and need to roll over... bingo! - we drop MSB (which we finally have) and have the value 0! - this is exactly what we want - bitwise and is much faster than modulus - */ - - qbsss->number_elements = number_elements; - qbsss->mask = qbsss->number_elements - 1; - qbsss->read_index = 0; - qbsss->write_index = 0; - qbsss->element_array = element_array; - qbsss->user_state = user_state; - - LFDS710_MISC_BARRIER_STORE; - - lfds710_misc_force_store(); - - return; -} - diff --git a/liblfds710/src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_internal.h b/liblfds710/src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_internal.h deleted file mode 100644 index 7db9158..0000000 --- a/liblfds710/src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_internal.h +++ /dev/null @@ -1,5 +0,0 @@ -/***** the library wide include file *****/ -#include "../liblfds710_internal.h" - -/***** private prototypes *****/ - diff --git a/liblfds710/src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_query.c b/liblfds710/src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_query.c deleted file mode 100644 index 741834c..0000000 --- a/liblfds710/src/lfds710_queue_bounded_singleproducer_singleconsumer/lfds710_queue_bounded_singleproducer_singleconsumer_query.c +++ /dev/null @@ -1,87 +0,0 @@ -/***** includes *****/ -#include "lfds710_queue_bounded_singleproducer_singleconsumer_internal.h" - -/***** private prototypes *****/ -static void lfds710_queue_bss_internal_validate( struct lfds710_queue_bss_state *qbsss, - struct lfds710_misc_validation_info *vi, - enum lfds710_misc_validity *lfds710_validity ); - - - - - -/****************************************************************************/ -void lfds710_queue_bss_query( struct lfds710_queue_bss_state *qbsss, - enum lfds710_queue_bss_query query_type, - void *query_input, - void *query_output ) -{ - LFDS710_PAL_ASSERT( qbsss != NULL ); - // TRD : query_type can be any value in its range - - switch( query_type ) - { - case LFDS710_QUEUE_BSS_QUERY_GET_POTENTIALLY_INACCURATE_COUNT: - { - lfds710_pal_uint_t - local_read_index, - local_write_index; - - LFDS710_PAL_ASSERT( query_input == NULL ); - LFDS710_PAL_ASSERT( query_output != NULL ); - - LFDS710_MISC_BARRIER_LOAD; - - local_read_index = qbsss->read_index; - local_write_index = qbsss->write_index; - - *(lfds710_pal_uint_t *) query_output = +( local_write_index - local_read_index ); - - if( local_read_index > local_write_index ) - *(lfds710_pal_uint_t *) query_output = qbsss->number_elements - *(lfds710_pal_uint_t *) query_output; - } - break; - - case LFDS710_QUEUE_BSS_QUERY_VALIDATE: - // TRD : query_input can be NULL - LFDS710_PAL_ASSERT( query_output != NULL ); - - lfds710_queue_bss_internal_validate( qbsss, (struct lfds710_misc_validation_info *) query_input, (enum lfds710_misc_validity *) query_output ); - break; - } - - return; -} - - - - - -/****************************************************************************/ -static void lfds710_queue_bss_internal_validate( struct lfds710_queue_bss_state *qbsss, - struct lfds710_misc_validation_info *vi, - enum lfds710_misc_validity *lfds710_validity ) -{ - LFDS710_PAL_ASSERT( qbsss != NULL ); - // TRD : vi can be NULL - LFDS710_PAL_ASSERT( lfds710_validity != NULL ); - - *lfds710_validity = LFDS710_MISC_VALIDITY_VALID; - - if( vi != NULL ) - { - lfds710_pal_uint_t - number_elements; - - lfds710_queue_bss_query( qbsss, LFDS710_QUEUE_BSS_QUERY_GET_POTENTIALLY_INACCURATE_COUNT, NULL, (void *) &number_elements ); - - if( number_elements < vi->min_elements ) - *lfds710_validity = LFDS710_MISC_VALIDITY_INVALID_MISSING_ELEMENTS; - - if( number_elements > vi->max_elements ) - *lfds710_validity = LFDS710_MISC_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - } - - return; -} - diff --git a/liblfds710/src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_cleanup.c b/liblfds710/src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_cleanup.c deleted file mode 100644 index 93dd24f..0000000 --- a/liblfds710/src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_cleanup.c +++ /dev/null @@ -1,48 +0,0 @@ -/***** includes *****/ -#include "lfds710_queue_unbounded_manyproducer_manyconsumer_internal.h" - - - - - -/****************************************************************************/ -void lfds710_queue_umm_cleanup( struct lfds710_queue_umm_state *qumms, - void (*element_cleanup_callback)(struct lfds710_queue_umm_state *qumms, struct lfds710_queue_umm_element *qumme, enum lfds710_misc_flag dummy_element_flag) ) -{ - struct lfds710_queue_umm_element - *qumme; - - void - *value; - - LFDS710_PAL_ASSERT( qumms != NULL ); - // TRD : element_cleanup_callback can be NULL - - LFDS710_MISC_BARRIER_LOAD; - - if( element_cleanup_callback != NULL ) - { - while( qumms->dequeue[POINTER] != qumms->enqueue[POINTER] ) - { - // TRD : trailing dummy element, so the first real value is in the next element - value = qumms->dequeue[POINTER]->next[POINTER]->value; - - // TRD : user is given back *an* element, but not the one his user data was in - qumme = qumms->dequeue[POINTER]; - - // TRD : remove the element from queue - qumms->dequeue[POINTER] = qumms->dequeue[POINTER]->next[POINTER]; - - // TRD : write value into the qumme we're going to give the user - qumme->value = value; - - element_cleanup_callback( qumms, qumme, LFDS710_MISC_FLAG_LOWERED ); - } - - // TRD : and now the final element - element_cleanup_callback( qumms, (struct lfds710_queue_umm_element *) qumms->dequeue[POINTER], LFDS710_MISC_FLAG_RAISED ); - } - - return; -} - diff --git a/liblfds710/src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_dequeue.c b/liblfds710/src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_dequeue.c deleted file mode 100644 index 5728967..0000000 --- a/liblfds710/src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_dequeue.c +++ /dev/null @@ -1,128 +0,0 @@ -/***** includes *****/ -#include "lfds710_queue_unbounded_manyproducer_manyconsumer_internal.h" - - - - - -/****************************************************************************/ -int lfds710_queue_umm_dequeue( struct lfds710_queue_umm_state *qumms, - struct lfds710_queue_umm_element **qumme ) -{ - char unsigned - result = 0; - - enum lfds710_misc_flag - finished_flag = LFDS710_MISC_FLAG_LOWERED; - - enum lfds710_queue_umm_queue_state - state = LFDS710_QUEUE_UMM_QUEUE_STATE_UNKNOWN; - - int - rv = 1; - - lfds710_pal_uint_t - backoff_iteration = LFDS710_BACKOFF_INITIAL_VALUE; - - struct lfds710_queue_umm_element LFDS710_PAL_ALIGN(LFDS710_PAL_ALIGN_DOUBLE_POINTER) - *dequeue[PAC_SIZE], - *enqueue[PAC_SIZE], - *next[PAC_SIZE]; - - void - *key = NULL, - *value = NULL; - - LFDS710_PAL_ASSERT( qumms != NULL ); - LFDS710_PAL_ASSERT( qumme != NULL ); - - LFDS710_MISC_BARRIER_LOAD; - - do - { - /* TRD : note here the deviation from the white paper - in the white paper, next is loaded from dequeue, not from qumms->dequeue - what concerns me is that between the load of dequeue and the load of - enqueue->next, the element can be dequeued by another thread *and freed* - - by ordering the loads (load barriers), and loading both from qumms, - the following if(), which checks dequeue is still the same as qumms->enqueue - still continues to ensure next belongs to enqueue, while avoiding the - problem with free - */ - - dequeue[COUNTER] = qumms->dequeue[COUNTER]; - dequeue[POINTER] = qumms->dequeue[POINTER]; - - LFDS710_MISC_BARRIER_LOAD; - - enqueue[COUNTER] = qumms->enqueue[COUNTER]; - enqueue[POINTER] = qumms->enqueue[POINTER]; - - next[COUNTER] = qumms->dequeue[POINTER]->next[COUNTER]; - next[POINTER] = qumms->dequeue[POINTER]->next[POINTER]; - - LFDS710_MISC_BARRIER_LOAD; - - if( qumms->dequeue[COUNTER] == dequeue[COUNTER] and qumms->dequeue[POINTER] == dequeue[POINTER] ) - { - if( enqueue[POINTER] == dequeue[POINTER] and next[POINTER] == NULL ) - state = LFDS710_QUEUE_UMM_QUEUE_STATE_EMPTY; - - if( enqueue[POINTER] == dequeue[POINTER] and next[POINTER] != NULL ) - state = LFDS710_QUEUE_UMM_QUEUE_STATE_ENQUEUE_OUT_OF_PLACE; - - if( enqueue[POINTER] != dequeue[POINTER] ) - state = LFDS710_QUEUE_UMM_QUEUE_STATE_ATTEMPT_DEQUEUE; - - switch( state ) - { - case LFDS710_QUEUE_UMM_QUEUE_STATE_UNKNOWN: - // TRD : eliminates compiler warning - break; - - case LFDS710_QUEUE_UMM_QUEUE_STATE_EMPTY: - rv = 0; - *qumme = NULL; - result = 1; - finished_flag = LFDS710_MISC_FLAG_RAISED; - break; - - case LFDS710_QUEUE_UMM_QUEUE_STATE_ENQUEUE_OUT_OF_PLACE: - next[COUNTER] = enqueue[COUNTER] + 1; - LFDS710_PAL_ATOMIC_DWCAS( qumms->enqueue, enqueue, next, LFDS710_MISC_CAS_STRENGTH_WEAK, result ); - // TRD : in fact if result is 1 (successful) I think we can now simply drop down into the dequeue attempt - break; - - case LFDS710_QUEUE_UMM_QUEUE_STATE_ATTEMPT_DEQUEUE: - key = next[POINTER]->key; - value = next[POINTER]->value; - - next[COUNTER] = dequeue[COUNTER] + 1; - LFDS710_PAL_ATOMIC_DWCAS( qumms->dequeue, dequeue, next, LFDS710_MISC_CAS_STRENGTH_WEAK, result ); - - if( result == 1 ) - finished_flag = LFDS710_MISC_FLAG_RAISED; - break; - } - } - else - result = 0; - - if( result == 0 ) - LFDS710_BACKOFF_EXPONENTIAL_BACKOFF( qumms->dequeue_backoff, backoff_iteration ); - } - while( finished_flag == LFDS710_MISC_FLAG_LOWERED ); - - if( result == 1 ) - { - *qumme = dequeue[POINTER]; - (*qumme)->key = key; - (*qumme)->value = value; - } - - LFDS710_BACKOFF_AUTOTUNE( qumms->dequeue_backoff, backoff_iteration ); - - return rv; -} - diff --git a/liblfds710/src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_enqueue.c b/liblfds710/src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_enqueue.c deleted file mode 100644 index cd65a57..0000000 --- a/liblfds710/src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_enqueue.c +++ /dev/null @@ -1,96 +0,0 @@ -/***** includes *****/ -#include "lfds710_queue_unbounded_manyproducer_manyconsumer_internal.h" - - - - - -/****************************************************************************/ -void lfds710_queue_umm_enqueue( struct lfds710_queue_umm_state *qumms, - struct lfds710_queue_umm_element *qumme ) -{ - char unsigned - result = 0; - - enum lfds710_misc_flag - finished_flag = LFDS710_MISC_FLAG_LOWERED; - - lfds710_pal_uint_t - backoff_iteration = LFDS710_BACKOFF_INITIAL_VALUE; - - struct lfds710_queue_umm_element LFDS710_PAL_ALIGN(LFDS710_PAL_ALIGN_DOUBLE_POINTER) - *volatile enqueue[PAC_SIZE], - *new_enqueue[PAC_SIZE], - *volatile next[PAC_SIZE]; - - LFDS710_PAL_ASSERT( qumms != NULL ); - LFDS710_PAL_ASSERT( qumme != NULL ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) qumme->next % LFDS710_PAL_ALIGN_DOUBLE_POINTER == 0 ); - - qumme->next[POINTER] = NULL; - LFDS710_PAL_ATOMIC_ADD( &qumms->aba_counter, 1, qumme->next[COUNTER], struct lfds710_queue_umm_element * ); - LFDS710_MISC_BARRIER_STORE; - - new_enqueue[POINTER] = qumme; - - LFDS710_MISC_BARRIER_LOAD; - - do - { - /* TRD : note here the deviation from the white paper - in the white paper, next is loaded from enqueue, not from qumms->enqueue - what concerns me is that between the load of enqueue and the load of - enqueue->next, the element can be dequeued by another thread *and freed* - - by ordering the loads (load barriers), and loading both from qumms, - the following if(), which checks enqueue is still the same as qumms->enqueue - still continues to ensure next belongs to enqueue, while avoiding the - problem with free - */ - - enqueue[COUNTER] = qumms->enqueue[COUNTER]; - enqueue[POINTER] = qumms->enqueue[POINTER]; - - LFDS710_MISC_BARRIER_LOAD; - - next[COUNTER] = qumms->enqueue[POINTER]->next[COUNTER]; - next[POINTER] = qumms->enqueue[POINTER]->next[POINTER]; - - LFDS710_MISC_BARRIER_LOAD; - - if( qumms->enqueue[COUNTER] == enqueue[COUNTER] and qumms->enqueue[POINTER] == enqueue[POINTER] ) - { - if( next[POINTER] == NULL ) - { - new_enqueue[COUNTER] = next[COUNTER] + 1; - LFDS710_PAL_ATOMIC_DWCAS( enqueue[POINTER]->next, next, new_enqueue, LFDS710_MISC_CAS_STRENGTH_WEAK, result ); - if( result == 1 ) - finished_flag = LFDS710_MISC_FLAG_RAISED; - } - else - { - next[COUNTER] = enqueue[COUNTER] + 1; - // TRD : strictly, this is a weak CAS, but we do an extra iteration of the main loop on a fake failure, so we set it to be strong - LFDS710_PAL_ATOMIC_DWCAS( qumms->enqueue, enqueue, next, LFDS710_MISC_CAS_STRENGTH_STRONG, result ); - } - } - else - result = 0; - - if( result == 0 ) - LFDS710_BACKOFF_EXPONENTIAL_BACKOFF( qumms->enqueue_backoff, backoff_iteration ); - } - while( finished_flag == LFDS710_MISC_FLAG_LOWERED ); - - // TRD : move enqueue along; only a weak CAS as the dequeue will solve this if it's out of place - new_enqueue[COUNTER] = enqueue[COUNTER] + 1; - LFDS710_PAL_ATOMIC_DWCAS( qumms->enqueue, enqueue, new_enqueue, LFDS710_MISC_CAS_STRENGTH_WEAK, result ); - - if( result == 0 ) - LFDS710_BACKOFF_EXPONENTIAL_BACKOFF( qumms->enqueue_backoff, backoff_iteration ); - - LFDS710_BACKOFF_AUTOTUNE( qumms->enqueue_backoff, backoff_iteration ); - - return; -} - diff --git a/liblfds710/src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_init.c b/liblfds710/src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_init.c deleted file mode 100644 index 8cfc0d8..0000000 --- a/liblfds710/src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_init.c +++ /dev/null @@ -1,50 +0,0 @@ -/***** includes *****/ -#include "lfds710_queue_unbounded_manyproducer_manyconsumer_internal.h" - - - - - -/****************************************************************************/ -void lfds710_queue_umm_init_valid_on_current_logical_core( struct lfds710_queue_umm_state *qumms, - struct lfds710_queue_umm_element *qumme_dummy, - void *user_state ) -{ - LFDS710_PAL_ASSERT( qumms != NULL ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &qumms->enqueue % LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES == 0 ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &qumms->dequeue % LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES == 0 ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &qumms->user_state % LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES == 0 ); - LFDS710_PAL_ASSERT( qumme_dummy != NULL ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) qumme_dummy->next % LFDS710_PAL_ALIGN_DOUBLE_POINTER == 0 ); - // TRD : user_state can be NULL - - /* TRD : qumme_dummy is a dummy element, needed for init - the qumms->enqueue and qumms->dequeue counters do not need to be initialized - but it does no harm to do so, and stops a valgrind complaint - */ - - LFDS710_PRNG_GENERATE( lfds710_misc_globals.ps, qumms->aba_counter ); - - qumms->enqueue[POINTER] = qumme_dummy; - qumms->enqueue[COUNTER] = (struct lfds710_queue_umm_element *) 0; - qumms->dequeue[POINTER] = qumme_dummy; - qumms->dequeue[COUNTER] = (struct lfds710_queue_umm_element *) 0; - - qumme_dummy->next[POINTER] = NULL; - // TRD : no need here for an atomic add as we have a store barrier and force store below - qumme_dummy->next[COUNTER] = (struct lfds710_queue_umm_element *) qumms->aba_counter++; - qumme_dummy->key = NULL; - qumme_dummy->value = NULL; - - qumms->user_state = user_state; - - lfds710_misc_internal_backoff_init( &qumms->dequeue_backoff ); - lfds710_misc_internal_backoff_init( &qumms->enqueue_backoff ); - - LFDS710_MISC_BARRIER_STORE; - - lfds710_misc_force_store(); - - return; -} - diff --git a/liblfds710/src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_internal.h b/liblfds710/src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_internal.h deleted file mode 100644 index c38f6d5..0000000 --- a/liblfds710/src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_internal.h +++ /dev/null @@ -1,14 +0,0 @@ -/***** the library wide include file *****/ -#include "../liblfds710_internal.h" - -/***** enums *****/ -enum lfds710_queue_umm_queue_state -{ - LFDS710_QUEUE_UMM_QUEUE_STATE_UNKNOWN, - LFDS710_QUEUE_UMM_QUEUE_STATE_EMPTY, - LFDS710_QUEUE_UMM_QUEUE_STATE_ENQUEUE_OUT_OF_PLACE, - LFDS710_QUEUE_UMM_QUEUE_STATE_ATTEMPT_DEQUEUE -}; - -/***** private prototypes *****/ - diff --git a/liblfds710/src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_query.c b/liblfds710/src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_query.c deleted file mode 100644 index 1ae9ee1..0000000 --- a/liblfds710/src/lfds710_queue_unbounded_manyproducer_manyconsumer/lfds710_queue_unbounded_manyproducer_manyconsumer_query.c +++ /dev/null @@ -1,133 +0,0 @@ -/***** includes *****/ -#include "lfds710_queue_unbounded_manyproducer_manyconsumer_internal.h" - -/***** private prototypes *****/ -static void lfds710_queue_umm_internal_validate( struct lfds710_queue_umm_state *qumms, - struct lfds710_misc_validation_info *vi, - enum lfds710_misc_validity *lfds710_queue_umm_validity ); - - - - - -/****************************************************************************/ -void lfds710_queue_umm_query( struct lfds710_queue_umm_state *qumms, - enum lfds710_queue_umm_query query_type, - void *query_input, - void *query_output ) -{ - struct lfds710_queue_umm_element - *qumme; - - LFDS710_MISC_BARRIER_LOAD; - - LFDS710_PAL_ASSERT( qumms != NULL ); - // TRD : query_type can be any value in its range - - switch( query_type ) - { - case LFDS710_QUEUE_UMM_QUERY_SINGLETHREADED_GET_COUNT: - LFDS710_PAL_ASSERT( query_input == NULL ); - LFDS710_PAL_ASSERT( query_output != NULL ); - - *(lfds710_pal_uint_t *) query_output = 0; - - qumme = (struct lfds710_queue_umm_element *) qumms->dequeue[POINTER]; - - while( qumme != NULL ) - { - ( *(lfds710_pal_uint_t *) query_output )++; - qumme = (struct lfds710_queue_umm_element *) qumme->next[POINTER]; - } - - // TRD : remember there is a dummy element in the queue - ( *(lfds710_pal_uint_t *) query_output )--; - break; - - case LFDS710_QUEUE_UMM_QUERY_SINGLETHREADED_VALIDATE: - // TRD : query_input can be NULL - LFDS710_PAL_ASSERT( query_output != NULL ); - - lfds710_queue_umm_internal_validate( qumms, (struct lfds710_misc_validation_info *) query_input, (enum lfds710_misc_validity *) query_output ); - break; - } - - return; -} - - - - - -/****************************************************************************/ -static void lfds710_queue_umm_internal_validate( struct lfds710_queue_umm_state *qumms, - struct lfds710_misc_validation_info *vi, - enum lfds710_misc_validity *lfds710_queue_umm_validity ) -{ - lfds710_pal_uint_t - number_elements = 0; - - struct lfds710_queue_umm_element - *qumme_fast, - *qumme_slow; - - LFDS710_PAL_ASSERT( qumms != NULL ); - // TRD : vi can be NULL - LFDS710_PAL_ASSERT( lfds710_queue_umm_validity != NULL ); - - *lfds710_queue_umm_validity = LFDS710_MISC_VALIDITY_VALID; - - qumme_slow = qumme_fast = (struct lfds710_queue_umm_element *) qumms->dequeue[POINTER]; - - /* TRD : first, check for a loop - we have two pointers - both of which start at the dequeue end of the queue - we enter a loop - and on each iteration - we advance one pointer by one element - and the other by two - - we exit the loop when both pointers are NULL - (have reached the end of the queue) - - or - - if we fast pointer 'sees' the slow pointer - which means we have a loop - */ - - if( qumme_slow != NULL ) - do - { - qumme_slow = qumme_slow->next[POINTER]; - - if( qumme_fast != NULL ) - qumme_fast = qumme_fast->next[POINTER]; - - if( qumme_fast != NULL ) - qumme_fast = qumme_fast->next[POINTER]; - } - while( qumme_slow != NULL and qumme_fast != qumme_slow ); - - if( qumme_fast != NULL and qumme_slow != NULL and qumme_fast == qumme_slow ) - *lfds710_queue_umm_validity = LFDS710_MISC_VALIDITY_INVALID_LOOP; - - /* TRD : now check for expected number of elements - vi can be NULL, in which case we do not check - we know we don't have a loop from our earlier check - */ - - if( *lfds710_queue_umm_validity == LFDS710_MISC_VALIDITY_VALID and vi != NULL ) - { - lfds710_queue_umm_query( qumms, LFDS710_QUEUE_UMM_QUERY_SINGLETHREADED_GET_COUNT, NULL, (void *) &number_elements ); - - if( number_elements < vi->min_elements ) - *lfds710_queue_umm_validity = LFDS710_MISC_VALIDITY_INVALID_MISSING_ELEMENTS; - - if( number_elements > vi->max_elements ) - *lfds710_queue_umm_validity = LFDS710_MISC_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - } - - return; -} - diff --git a/liblfds710/src/lfds710_ringbuffer/lfds710_ringbuffer_cleanup.c b/liblfds710/src/lfds710_ringbuffer/lfds710_ringbuffer_cleanup.c deleted file mode 100644 index 6ec6f57..0000000 --- a/liblfds710/src/lfds710_ringbuffer/lfds710_ringbuffer_cleanup.c +++ /dev/null @@ -1,92 +0,0 @@ -/***** includes *****/ -#include "lfds710_ringbuffer_internal.h" - -/***** private prototypes *****/ -static void lfds710_ringbuffer_internal_queue_umm_element_cleanup_callback( struct lfds710_queue_umm_state *qumms, - struct lfds710_queue_umm_element *qumme, - enum lfds710_misc_flag dummy_element_flag ); -static void lfds710_ringbuffer_internal_freelist_element_cleanup_callback( struct lfds710_freelist_state *fs, - struct lfds710_freelist_element *fe ); - - - - - -/****************************************************************************/ -void lfds710_ringbuffer_cleanup( struct lfds710_ringbuffer_state *rs, - void (*element_cleanup_callback)(struct lfds710_ringbuffer_state *rs, void *key, void *value, enum lfds710_misc_flag unread_flag) ) -{ - LFDS710_PAL_ASSERT( rs != NULL ); - // TRD : element_cleanup_callback can be NULL - - if( element_cleanup_callback != NULL ) - { - rs->element_cleanup_callback = element_cleanup_callback; - lfds710_queue_umm_cleanup( &rs->qumms, lfds710_ringbuffer_internal_queue_umm_element_cleanup_callback ); - lfds710_freelist_cleanup( &rs->fs, lfds710_ringbuffer_internal_freelist_element_cleanup_callback ); - } - - return; -} - - - - - -/****************************************************************************/ -#pragma warning( disable : 4100 ) - -static void lfds710_ringbuffer_internal_queue_umm_element_cleanup_callback( struct lfds710_queue_umm_state *qumms, - struct lfds710_queue_umm_element *qumme, - enum lfds710_misc_flag dummy_element_flag ) -{ - struct lfds710_ringbuffer_element - *re; - - struct lfds710_ringbuffer_state - *rs; - - LFDS710_PAL_ASSERT( qumms != NULL ); - LFDS710_PAL_ASSERT( qumme != NULL ); - // TRD : dummy_element can be any value in its range - - rs = (struct lfds710_ringbuffer_state *) LFDS710_QUEUE_UMM_GET_USER_STATE_FROM_STATE( *qumms ); - re = (struct lfds710_ringbuffer_element *) LFDS710_QUEUE_UMM_GET_VALUE_FROM_ELEMENT( *qumme ); - - if( dummy_element_flag == LFDS710_MISC_FLAG_LOWERED ) - rs->element_cleanup_callback( rs, re->key, re->value, LFDS710_MISC_FLAG_RAISED ); - - return; -} - -#pragma warning( default : 4100 ) - - - - - -/****************************************************************************/ -#pragma warning( disable : 4100 ) - -static void lfds710_ringbuffer_internal_freelist_element_cleanup_callback( struct lfds710_freelist_state *fs, - struct lfds710_freelist_element *fe ) -{ - struct lfds710_ringbuffer_element - *re; - - struct lfds710_ringbuffer_state - *rs; - - LFDS710_PAL_ASSERT( fs != NULL ); - LFDS710_PAL_ASSERT( fe != NULL ); - - rs = (struct lfds710_ringbuffer_state *) LFDS710_FREELIST_GET_USER_STATE_FROM_STATE( *fs ); - re = (struct lfds710_ringbuffer_element *) LFDS710_FREELIST_GET_VALUE_FROM_ELEMENT( *fe ); - - rs->element_cleanup_callback( rs, re->key, re->value, LFDS710_MISC_FLAG_LOWERED ); - - return; -} - -#pragma warning( default : 4100 ) - diff --git a/liblfds710/src/lfds710_ringbuffer/lfds710_ringbuffer_init.c b/liblfds710/src/lfds710_ringbuffer/lfds710_ringbuffer_init.c deleted file mode 100644 index a0a1be7..0000000 --- a/liblfds710/src/lfds710_ringbuffer/lfds710_ringbuffer_init.c +++ /dev/null @@ -1,42 +0,0 @@ -/***** includes *****/ -#include "lfds710_ringbuffer_internal.h" - - - - - -/****************************************************************************/ -void lfds710_ringbuffer_init_valid_on_current_logical_core( struct lfds710_ringbuffer_state *rs, - struct lfds710_ringbuffer_element *re_array_inc_dummy, - lfds710_pal_uint_t number_elements_inc_dummy, - void *user_state ) -{ - lfds710_pal_uint_t - loop; - - LFDS710_PAL_ASSERT( rs != NULL ); - LFDS710_PAL_ASSERT( re_array_inc_dummy != NULL ); - LFDS710_PAL_ASSERT( number_elements_inc_dummy >= 2 ); - // TRD : user_state can be NULL - - rs->user_state = user_state; - - re_array_inc_dummy[0].qumme_use = &re_array_inc_dummy[0].qumme; - - lfds710_freelist_init_valid_on_current_logical_core( &rs->fs, NULL, 0, rs ); - lfds710_queue_umm_init_valid_on_current_logical_core( &rs->qumms, &re_array_inc_dummy[0].qumme, rs ); - - for( loop = 1 ; loop < number_elements_inc_dummy ; loop++ ) - { - re_array_inc_dummy[loop].qumme_use = &re_array_inc_dummy[loop].qumme; - LFDS710_FREELIST_SET_VALUE_IN_ELEMENT( re_array_inc_dummy[loop].fe, &re_array_inc_dummy[loop] ); - lfds710_freelist_push( &rs->fs, &re_array_inc_dummy[loop].fe, NULL ); - } - - LFDS710_MISC_BARRIER_STORE; - - lfds710_misc_force_store(); - - return; -} - diff --git a/liblfds710/src/lfds710_ringbuffer/lfds710_ringbuffer_internal.h b/liblfds710/src/lfds710_ringbuffer/lfds710_ringbuffer_internal.h deleted file mode 100644 index 7db9158..0000000 --- a/liblfds710/src/lfds710_ringbuffer/lfds710_ringbuffer_internal.h +++ /dev/null @@ -1,5 +0,0 @@ -/***** the library wide include file *****/ -#include "../liblfds710_internal.h" - -/***** private prototypes *****/ - diff --git a/liblfds710/src/lfds710_ringbuffer/lfds710_ringbuffer_query.c b/liblfds710/src/lfds710_ringbuffer/lfds710_ringbuffer_query.c deleted file mode 100644 index 4da1624..0000000 --- a/liblfds710/src/lfds710_ringbuffer/lfds710_ringbuffer_query.c +++ /dev/null @@ -1,81 +0,0 @@ -/***** includes *****/ -#include "lfds710_ringbuffer_internal.h" - -/***** private prototypes *****/ -static void lfds710_ringbuffer_internal_validate( struct lfds710_ringbuffer_state *rs, - struct lfds710_misc_validation_info *vi, - enum lfds710_misc_validity *lfds710_queue_umm_validity, - enum lfds710_misc_validity *lfds710_freelist_validity ); - - - -/****************************************************************************/ -void lfds710_ringbuffer_query( struct lfds710_ringbuffer_state *rs, - enum lfds710_ringbuffer_query query_type, - void *query_input, - void *query_output ) -{ - LFDS710_PAL_ASSERT( rs != NULL ); - // TRD : query_type can be any value in its range - - LFDS710_MISC_BARRIER_LOAD; - - switch( query_type ) - { - case LFDS710_RINGBUFFER_QUERY_SINGLETHREADED_GET_COUNT: - LFDS710_PAL_ASSERT( query_input == NULL ); - LFDS710_PAL_ASSERT( query_output != NULL ); - - lfds710_queue_umm_query( &rs->qumms, LFDS710_QUEUE_UMM_QUERY_SINGLETHREADED_GET_COUNT, NULL, query_output ); - break; - - case LFDS710_RINGBUFFER_QUERY_SINGLETHREADED_VALIDATE: - // TRD : query_input can be NULL - LFDS710_PAL_ASSERT( query_output != NULL ); - - lfds710_ringbuffer_internal_validate( rs, (struct lfds710_misc_validation_info *) query_input, (enum lfds710_misc_validity *) query_output, ((enum lfds710_misc_validity *) query_output)+1 ); - break; - } - - return; -} - - - - - -/****************************************************************************/ -static void lfds710_ringbuffer_internal_validate( struct lfds710_ringbuffer_state *rs, - struct lfds710_misc_validation_info *vi, - enum lfds710_misc_validity *lfds710_queue_umm_validity, - enum lfds710_misc_validity *lfds710_freelist_validity ) -{ - LFDS710_PAL_ASSERT( rs != NULL ); - // TRD : vi can be NULL - LFDS710_PAL_ASSERT( lfds710_queue_umm_validity != NULL ); - LFDS710_PAL_ASSERT( lfds710_freelist_validity != NULL ); - - if( vi == NULL ) - { - lfds710_queue_umm_query( &rs->qumms, LFDS710_QUEUE_UMM_QUERY_SINGLETHREADED_VALIDATE, NULL, lfds710_queue_umm_validity ); - lfds710_freelist_query( &rs->fs, LFDS710_FREELIST_QUERY_SINGLETHREADED_VALIDATE, NULL, lfds710_freelist_validity ); - } - - if( vi != NULL ) - { - struct lfds710_misc_validation_info - freelist_vi, - queue_vi; - - queue_vi.min_elements = 0; - freelist_vi.min_elements = 0; - queue_vi.max_elements = vi->max_elements; - freelist_vi.max_elements = vi->max_elements; - - lfds710_queue_umm_query( &rs->qumms, LFDS710_QUEUE_UMM_QUERY_SINGLETHREADED_VALIDATE, &queue_vi, lfds710_queue_umm_validity ); - lfds710_freelist_query( &rs->fs, LFDS710_FREELIST_QUERY_SINGLETHREADED_VALIDATE, &freelist_vi, lfds710_freelist_validity ); - } - - return; -} - diff --git a/liblfds710/src/lfds710_ringbuffer/lfds710_ringbuffer_read.c b/liblfds710/src/lfds710_ringbuffer/lfds710_ringbuffer_read.c deleted file mode 100644 index 3bf739e..0000000 --- a/liblfds710/src/lfds710_ringbuffer/lfds710_ringbuffer_read.c +++ /dev/null @@ -1,43 +0,0 @@ -/***** includes *****/ -#include "lfds710_ringbuffer_internal.h" - - - - - -/****************************************************************************/ -int lfds710_ringbuffer_read( struct lfds710_ringbuffer_state *rs, - void **key, - void **value ) -{ - int - rv; - - struct lfds710_queue_umm_element - *qumme; - - struct lfds710_ringbuffer_element - *re; - - LFDS710_PAL_ASSERT( rs != NULL ); - // TRD : key can be NULL - // TRD : value can be NULL - // TRD : psts can be NULL - - rv = lfds710_queue_umm_dequeue( &rs->qumms, &qumme ); - - if( rv == 1 ) - { - re = LFDS710_QUEUE_UMM_GET_VALUE_FROM_ELEMENT( *qumme ); - re->qumme_use = (struct lfds710_queue_umm_element *) qumme; - if( key != NULL ) - *key = re->key; - if( value != NULL ) - *value = re->value; - LFDS710_FREELIST_SET_VALUE_IN_ELEMENT( re->fe, re ); - lfds710_freelist_push( &rs->fs, &re->fe, NULL ); - } - - return rv; -} - diff --git a/liblfds710/src/lfds710_ringbuffer/lfds710_ringbuffer_write.c b/liblfds710/src/lfds710_ringbuffer/lfds710_ringbuffer_write.c deleted file mode 100644 index 4aedd18..0000000 --- a/liblfds710/src/lfds710_ringbuffer/lfds710_ringbuffer_write.c +++ /dev/null @@ -1,77 +0,0 @@ -/***** includes *****/ -#include "lfds710_ringbuffer_internal.h" - - - - - -/****************************************************************************/ -void lfds710_ringbuffer_write( struct lfds710_ringbuffer_state *rs, - void *key, - void *value, - enum lfds710_misc_flag *overwrite_occurred_flag, - void **overwritten_key, - void **overwritten_value ) -{ - int - rv = 0; - - struct lfds710_freelist_element - *fe; - - struct lfds710_queue_umm_element - *qumme; - - struct lfds710_ringbuffer_element - *re = NULL; - - LFDS710_PAL_ASSERT( rs != NULL ); - // TRD : key can be NULL - // TRD : value can be NULL - // TRD : overwrite_occurred_flag can be NULL - // TRD : overwritten_key can be NULL - // TRD : overwritten_value can be NULL - // TRD : psts can be NULL - - if( overwrite_occurred_flag != NULL ) - *overwrite_occurred_flag = LFDS710_MISC_FLAG_LOWERED; - - do - { - rv = lfds710_freelist_pop( &rs->fs, &fe, NULL ); - - if( rv == 1 ) - re = LFDS710_FREELIST_GET_VALUE_FROM_ELEMENT( *fe ); - - if( rv == 0 ) - { - // TRD : the queue can return empty as well - remember, we're lock-free; anything could have happened since the previous instruction - rv = lfds710_queue_umm_dequeue( &rs->qumms, &qumme ); - - if( rv == 1 ) - { - re = LFDS710_QUEUE_UMM_GET_VALUE_FROM_ELEMENT( *qumme ); - re->qumme_use = (struct lfds710_queue_umm_element *) qumme; - - if( overwrite_occurred_flag != NULL ) - *overwrite_occurred_flag = LFDS710_MISC_FLAG_RAISED; - - if( overwritten_key != NULL ) - *overwritten_key = re->key; - - if( overwritten_value != NULL ) - *overwritten_value = re->value; - } - } - } - while( rv == 0 ); - - re->key = key; - re->value = value; - - LFDS710_QUEUE_UMM_SET_VALUE_IN_ELEMENT( *re->qumme_use, re ); - lfds710_queue_umm_enqueue( &rs->qumms, re->qumme_use ); - - return; -} - diff --git a/liblfds710/src/lfds710_stack/lfds710_stack_cleanup.c b/liblfds710/src/lfds710_stack/lfds710_stack_cleanup.c deleted file mode 100644 index fdcf288..0000000 --- a/liblfds710/src/lfds710_stack/lfds710_stack_cleanup.c +++ /dev/null @@ -1,36 +0,0 @@ -/***** includes *****/ -#include "lfds710_stack_internal.h" - - - - - -/****************************************************************************/ -void lfds710_stack_cleanup( struct lfds710_stack_state *ss, - void (*element_cleanup_callback)(struct lfds710_stack_state *ss, struct lfds710_stack_element *se) ) -{ - struct lfds710_stack_element - *se, - *se_temp; - - LFDS710_PAL_ASSERT( ss != NULL ); - // TRD : element_cleanup_callback can be NULL - - LFDS710_MISC_BARRIER_LOAD; - - if( element_cleanup_callback != NULL ) - { - se = ss->top[POINTER]; - - while( se != NULL ) - { - se_temp = se; - se = se->next; - - element_cleanup_callback( ss, se_temp ); - } - } - - return; -} - diff --git a/liblfds710/src/lfds710_stack/lfds710_stack_init.c b/liblfds710/src/lfds710_stack/lfds710_stack_init.c deleted file mode 100644 index b159b4b..0000000 --- a/liblfds710/src/lfds710_stack/lfds710_stack_init.c +++ /dev/null @@ -1,31 +0,0 @@ -/***** includes *****/ -#include "lfds710_stack_internal.h" - - - - - -/****************************************************************************/ -void lfds710_stack_init_valid_on_current_logical_core( struct lfds710_stack_state *ss, - void *user_state ) -{ - LFDS710_PAL_ASSERT( ss != NULL ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) ss->top % LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES == 0 ); - LFDS710_PAL_ASSERT( (lfds710_pal_uint_t) &ss->user_state % LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES == 0 ); - // TRD : user_state can be NULL - - ss->top[POINTER] = NULL; - ss->top[COUNTER] = 0; - - ss->user_state = user_state; - - lfds710_misc_internal_backoff_init( &ss->pop_backoff ); - lfds710_misc_internal_backoff_init( &ss->push_backoff ); - - LFDS710_MISC_BARRIER_STORE; - - lfds710_misc_force_store(); - - return; -} - diff --git a/liblfds710/src/lfds710_stack/lfds710_stack_internal.h b/liblfds710/src/lfds710_stack/lfds710_stack_internal.h deleted file mode 100644 index 7db9158..0000000 --- a/liblfds710/src/lfds710_stack/lfds710_stack_internal.h +++ /dev/null @@ -1,5 +0,0 @@ -/***** the library wide include file *****/ -#include "../liblfds710_internal.h" - -/***** private prototypes *****/ - diff --git a/liblfds710/src/lfds710_stack/lfds710_stack_pop.c b/liblfds710/src/lfds710_stack/lfds710_stack_pop.c deleted file mode 100644 index eded13e..0000000 --- a/liblfds710/src/lfds710_stack/lfds710_stack_pop.c +++ /dev/null @@ -1,57 +0,0 @@ -/***** includes *****/ -#include "lfds710_stack_internal.h" - - - - - -/****************************************************************************/ -int lfds710_stack_pop( struct lfds710_stack_state *ss, - struct lfds710_stack_element **se ) -{ - char unsigned - result; - - lfds710_pal_uint_t - backoff_iteration = LFDS710_BACKOFF_INITIAL_VALUE; - - struct lfds710_stack_element LFDS710_PAL_ALIGN(LFDS710_PAL_ALIGN_DOUBLE_POINTER) - *new_top[PAC_SIZE], - *volatile original_top[PAC_SIZE]; - - LFDS710_PAL_ASSERT( ss != NULL ); - LFDS710_PAL_ASSERT( se != NULL ); - - LFDS710_MISC_BARRIER_LOAD; - - original_top[COUNTER] = ss->top[COUNTER]; - original_top[POINTER] = ss->top[POINTER]; - - do - { - if( original_top[POINTER] == NULL ) - { - *se = NULL; - return 0; - } - - new_top[COUNTER] = original_top[COUNTER] + 1; - new_top[POINTER] = original_top[POINTER]->next; - - LFDS710_PAL_ATOMIC_DWCAS( ss->top, original_top, new_top, LFDS710_MISC_CAS_STRENGTH_WEAK, result ); - - if( result == 0 ) - { - LFDS710_BACKOFF_EXPONENTIAL_BACKOFF( ss->pop_backoff, backoff_iteration ); - LFDS710_MISC_BARRIER_LOAD; - } - } - while( result == 0 ); - - *se = original_top[POINTER]; - - LFDS710_BACKOFF_AUTOTUNE( ss->pop_backoff, backoff_iteration ); - - return 1; -} - diff --git a/liblfds710/src/lfds710_stack/lfds710_stack_push.c b/liblfds710/src/lfds710_stack/lfds710_stack_push.c deleted file mode 100644 index 7aa12bb..0000000 --- a/liblfds710/src/lfds710_stack/lfds710_stack_push.c +++ /dev/null @@ -1,47 +0,0 @@ -/***** includes *****/ -#include "lfds710_stack_internal.h" - - - - - -/****************************************************************************/ -void lfds710_stack_push( struct lfds710_stack_state *ss, - struct lfds710_stack_element *se ) -{ - char unsigned - result; - - lfds710_pal_uint_t - backoff_iteration = LFDS710_BACKOFF_INITIAL_VALUE; - - struct lfds710_stack_element LFDS710_PAL_ALIGN(LFDS710_PAL_ALIGN_DOUBLE_POINTER) - *new_top[PAC_SIZE], - *volatile original_top[PAC_SIZE]; - - LFDS710_PAL_ASSERT( ss != NULL ); - LFDS710_PAL_ASSERT( se != NULL ); - - new_top[POINTER] = se; - - original_top[COUNTER] = ss->top[COUNTER]; - original_top[POINTER] = ss->top[POINTER]; - - do - { - se->next = original_top[POINTER]; - LFDS710_MISC_BARRIER_STORE; - - new_top[COUNTER] = original_top[COUNTER] + 1; - LFDS710_PAL_ATOMIC_DWCAS( ss->top, original_top, new_top, LFDS710_MISC_CAS_STRENGTH_WEAK, result ); - - if( result == 0 ) - LFDS710_BACKOFF_EXPONENTIAL_BACKOFF( ss->push_backoff, backoff_iteration ); - } - while( result == 0 ); - - LFDS710_BACKOFF_AUTOTUNE( ss->push_backoff, backoff_iteration ); - - return; -} - diff --git a/liblfds710/src/lfds710_stack/lfds710_stack_query.c b/liblfds710/src/lfds710_stack/lfds710_stack_query.c deleted file mode 100644 index 1cf8579..0000000 --- a/liblfds710/src/lfds710_stack/lfds710_stack_query.c +++ /dev/null @@ -1,130 +0,0 @@ -/***** includes *****/ -#include "lfds710_stack_internal.h" - -/***** private prototypes *****/ -static void lfds710_stack_internal_stack_validate( struct lfds710_stack_state *ss, - struct lfds710_misc_validation_info *vi, - enum lfds710_misc_validity *lfds710_stack_validity ); - - - - - -/****************************************************************************/ -void lfds710_stack_query( struct lfds710_stack_state *ss, - enum lfds710_stack_query query_type, - void *query_input, - void *query_output ) -{ - struct lfds710_stack_element - *se; - - LFDS710_MISC_BARRIER_LOAD; - - LFDS710_PAL_ASSERT( ss != NULL ); - // TRD : query_type can be any value in its range - - switch( query_type ) - { - case LFDS710_STACK_QUERY_SINGLETHREADED_GET_COUNT: - LFDS710_PAL_ASSERT( query_input == NULL ); - LFDS710_PAL_ASSERT( query_output != NULL ); - - *(lfds710_pal_uint_t *) query_output = 0; - - se = (struct lfds710_stack_element *) ss->top[POINTER]; - - while( se != NULL ) - { - ( *(lfds710_pal_uint_t *) query_output )++; - se = (struct lfds710_stack_element *) se->next; - } - break; - - case LFDS710_STACK_QUERY_SINGLETHREADED_VALIDATE: - // TRD : query_input can be NULL - LFDS710_PAL_ASSERT( query_output != NULL ); - - lfds710_stack_internal_stack_validate( ss, (struct lfds710_misc_validation_info *) query_input, (enum lfds710_misc_validity *) query_output ); - break; - } - - return; -} - - - - - -/****************************************************************************/ -static void lfds710_stack_internal_stack_validate( struct lfds710_stack_state *ss, - struct lfds710_misc_validation_info *vi, - enum lfds710_misc_validity *lfds710_stack_validity ) -{ - lfds710_pal_uint_t - number_elements = 0; - - struct lfds710_stack_element - *se_fast, - *se_slow; - - LFDS710_PAL_ASSERT( ss != NULL ); - // TRD : vi can be NULL - LFDS710_PAL_ASSERT( lfds710_stack_validity != NULL ); - - *lfds710_stack_validity = LFDS710_MISC_VALIDITY_VALID; - - se_slow = se_fast = (struct lfds710_stack_element *) ss->top[POINTER]; - - /* TRD : first, check for a loop - we have two pointers - both of which start at the top of the stack - we enter a loop - and on each iteration - we advance one pointer by one element - and the other by two - - we exit the loop when both pointers are NULL - (have reached the end of the stack) - - or - - if we fast pointer 'sees' the slow pointer - which means we have a loop - */ - - if( se_slow != NULL ) - do - { - se_slow = se_slow->next; - - if( se_fast != NULL ) - se_fast = se_fast->next; - - if( se_fast != NULL ) - se_fast = se_fast->next; - } - while( se_slow != NULL and se_fast != se_slow ); - - if( se_fast != NULL and se_slow != NULL and se_fast == se_slow ) - *lfds710_stack_validity = LFDS710_MISC_VALIDITY_INVALID_LOOP; - - /* TRD : now check for expected number of elements - vi can be NULL, in which case we do not check - we know we don't have a loop from our earlier check - */ - - if( *lfds710_stack_validity == LFDS710_MISC_VALIDITY_VALID and vi != NULL ) - { - lfds710_stack_query( ss, LFDS710_STACK_QUERY_SINGLETHREADED_GET_COUNT, NULL, (void *) &number_elements ); - - if( number_elements < vi->min_elements ) - *lfds710_stack_validity = LFDS710_MISC_VALIDITY_INVALID_MISSING_ELEMENTS; - - if( number_elements > vi->max_elements ) - *lfds710_stack_validity = LFDS710_MISC_VALIDITY_INVALID_ADDITIONAL_ELEMENTS; - } - - return; -} - diff --git a/liblfds710/src/liblfds710_internal.h b/liblfds710/src/liblfds710_internal.h deleted file mode 100644 index 655a1bd..0000000 --- a/liblfds710/src/liblfds710_internal.h +++ /dev/null @@ -1,102 +0,0 @@ -/***** public prototypes *****/ -#include "../inc/liblfds710.h" - -/***** defines *****/ -#define and && -#define or || - -#define NO_FLAGS 0x0 - -#define LFDS710_VERSION_STRING "7.1.0" -#define LFDS710_VERSION_INTEGER 710 - -#if( defined KERNEL_MODE ) - #define MODE_TYPE_STRING "kernel-mode" -#endif - -#if( !defined KERNEL_MODE ) - #define MODE_TYPE_STRING "user-mode" -#endif - -#if( defined NDEBUG && !defined COVERAGE && !defined TSAN && !defined PROF ) - #define BUILD_TYPE_STRING "release" -#endif - -#if( !defined NDEBUG && !defined COVERAGE && !defined TSAN && !defined PROF ) - #define BUILD_TYPE_STRING "debug" -#endif - -#if( !defined NDEBUG && defined COVERAGE && !defined TSAN && !defined PROF ) - #define BUILD_TYPE_STRING "coverage" -#endif - -#if( !defined NDEBUG && !defined COVERAGE && defined TSAN && !defined PROF ) - #define BUILD_TYPE_STRING "threadsanitizer" -#endif - -#if( !defined NDEBUG && !defined COVERAGE && !defined TSAN && defined PROF ) - #define BUILD_TYPE_STRING "profiling" -#endif - -#define LFDS710_BACKOFF_INITIAL_VALUE 0 -#define LFDS710_BACKOFF_LIMIT 10 - -#define LFDS710_BACKOFF_EXPONENTIAL_BACKOFF( backoff_state, backoff_iteration ) \ -{ \ - lfds710_pal_uint_t volatile \ - loop; \ - \ - lfds710_pal_uint_t \ - endloop; \ - \ - if( (backoff_iteration) == LFDS710_BACKOFF_LIMIT ) \ - (backoff_iteration) = LFDS710_BACKOFF_INITIAL_VALUE; \ - else \ - { \ - endloop = ( ((lfds710_pal_uint_t) 0x1) << (backoff_iteration) ) * (backoff_state).metric; \ - for( loop = 0 ; loop < endloop ; loop++ ); \ - } \ - \ - (backoff_iteration)++; \ -} - -#define LFDS710_BACKOFF_AUTOTUNE( bs, backoff_iteration ) \ -{ \ - if( (backoff_iteration) < 2 ) \ - (bs).backoff_iteration_frequency_counters[(backoff_iteration)]++; \ - \ - if( ++(bs).total_operations >= 10000 and (bs).lock == LFDS710_MISC_FLAG_LOWERED ) \ - { \ - char unsigned \ - result; \ - \ - lfds710_pal_uint_t LFDS710_PAL_ALIGN(LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES) \ - compare = LFDS710_MISC_FLAG_LOWERED; \ - \ - LFDS710_PAL_ATOMIC_CAS( &(bs).lock, &compare, LFDS710_MISC_FLAG_RAISED, LFDS710_MISC_CAS_STRENGTH_WEAK, result ); \ - \ - if( result == 1 ) \ - { \ - /* TRD : if E[1] is less than 1/100th of E[0], decrease the metric, to increase E[1] */ \ - if( (bs).backoff_iteration_frequency_counters[1] < (bs).backoff_iteration_frequency_counters[0] / 100 ) \ - { \ - if( (bs).metric >= 11 ) \ - (bs).metric -= 10; \ - } \ - else \ - (bs).metric += 10; \ - \ - (bs).backoff_iteration_frequency_counters[0] = 0; \ - (bs).backoff_iteration_frequency_counters[1] = 0; \ - (bs).total_operations = 0; \ - \ - LFDS710_MISC_BARRIER_STORE; \ - \ - LFDS710_PAL_ATOMIC_SET( &(bs).lock, LFDS710_MISC_FLAG_LOWERED ); \ - } \ - } \ -} - -/***** library-wide prototypes *****/ -void lfds710_misc_internal_backoff_init( struct lfds710_misc_backoff_state *bs ); - diff --git a/m4/lfds.m4 b/m4/lfds.m4 deleted file mode 100644 index cca4d40..0000000 --- a/m4/lfds.m4 +++ /dev/null @@ -1,143 +0,0 @@ -# BEGIN COPYRIGHT BLOCK -# Copyright (C) 2015 Red Hat -# see files 'COPYING' and 'COPYING.openssl' for use and warranty -# information -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# Additional permission under GPLv3 section 7: -# -# If you modify this Program, or any covered work, by linking or -# combining it with OpenSSL, or a modified version of OpenSSL licensed -# under the OpenSSL license -# (https://www.openssl.org/source/license.html), the licensors of this -# Program grant you additional permission to convey the resulting -# work. Corresponding Source for a non-source form of such a -# combination shall include the source code for the parts that are -# licensed under the OpenSSL license as well as that of the covered -# work. -# END COPYRIGHT BLOCK -if test -z "$with_lfds_src" ; then - # by default, look for liblfds subdir of nunc-stans source dir - with_lfds_src=$srcdir/liblfds710 -fi - -AC_CHECKING(for lfds) -AC_MSG_CHECKING(for --with-lfds-src) -AC_ARG_WITH(lfds-src, AS_HELP_STRING([--with-lfds-src@<:@=PATH@:>@],[LFDS source directory]), -[ - if test "$withval" = "yes"; then - AC_MSG_RESULT(yes) - elif test "$withval" = "no"; then - AC_MSG_RESULT(no) - elif test -d "$withval"; then - AC_MSG_RESULT([using $withval]) - dnl - check the user provided location - lfds_lib="-L$withval/bin" - lfds_libdir="$withval/bin" - lfds_incdir="$withval/inc" - if ! test -e "$lfds_incdir/liblfds710.h" ; then - AC_MSG_ERROR([$withval include dir not found]) - fi - lfds_inc="-I$lfds_incdir" - lfds_subdir="$withval" - if test "$enable_debug" = "yes" ; then - lfds_make_target=ar_dbg - else - lfds_make_target=ar_rel - fi - dnl - we need a GNU style makefile in that directory - if test -f $lfds_subdir/GNUmakefile ; then - AC_MSG_WARN([$lfds_subdir/GNUmakefile exists - will overwrite]) - fi - cat > $lfds_subdir/GNUmakefile <@],[LFDS directory]), -[ - if test "$withval" = "yes"; then - AC_MSG_RESULT(yes) - elif test "$withval" = "no"; then - AC_MSG_RESULT(no) - elif test -d "$withval"/inc -a -d "$withval"/bin; then - AC_MSG_RESULT([using $withval]) - dnl - check the user provided location - lfds_lib="-L$withval/bin" - lfds_libdir="$withval/lib" - lfds_incdir="$withval/inc" - if ! test -e "$lfds_incdir/liblfds.h" ; then - AC_MSG_ERROR([$withval include dir not found]) - fi - lfds_inc="-I$lfds_incdir" - else - echo - AC_MSG_ERROR([$withval not found]) - fi -], -AC_MSG_RESULT(no)) - -# check for --with-lfds-inc -AC_MSG_CHECKING(for --with-lfds-inc) -AC_ARG_WITH(lfds-inc, AS_HELP_STRING([--with-lfds-inc=PATH],[LFDS include file directory]), -[ - if test -e "$withval"/liblfds.h - then - AC_MSG_RESULT([using $withval]) - lfds_incdir="$withval" - lfds_inc="-I$withval" - else - echo - AC_MSG_ERROR([$withval not found]) - fi -], -AC_MSG_RESULT(no)) - -# check for --with-lfds-lib -AC_MSG_CHECKING(for --with-lfds-lib) -AC_ARG_WITH(lfds-lib, AS_HELP_STRING([--with-lfds-lib=PATH],[LFDS library directory]), -[ - if test -d "$withval" - then - AC_MSG_RESULT([using $withval]) - lfds_lib="-L$withval" - lfds_libdir="$withval" - else - echo - AC_MSG_ERROR([$withval not found]) - fi -], -AC_MSG_RESULT(no)) diff --git a/ns_thrpool.c b/ns_thrpool.c index d4a1d7c..04b4693 100644 --- a/ns_thrpool.c +++ b/ns_thrpool.c @@ -57,47 +57,21 @@ #include "private/pprio.h" #include "ns_event_fw.h" -#define WITH_SDS 1 - -#ifdef WITH_SDS +/* SDS contains the lock free queue wrapper */ #include -#else - -/* Data structure definitions */ -#include "liblfds710.h" - -struct ns_thr_stack_t { - struct lfds710_stack_state stack; -}; - -struct ns_job_queue_t { - struct lfds710_queue_umm_state queue; -}; - -#endif /* with_sds */ /* * Threadpool */ struct ns_thrpool_t { -#ifdef WITH_SDS sds_lqueue *work_q; sds_lqueue *event_q; -#else - struct ns_job_queue_t *work_q; /* queue of jobs to be executed by the thread pool */ - struct ns_job_queue_t *event_q; /* queue of jobs to return to the event loop */ - struct queue_gc *event_gc; -#endif /* with_sds */ PRInt32 shutdown; PRInt32 shutdown_event_loop; PRLock *work_q_lock; PRCondVar *work_q_cv; -#ifdef WITH_SDS sds_queue *thread_stack; -#else - struct ns_thr_stack_t *thread_stack; /* stack of ns_thread_t */ -#endif PRThread *event_thread; /* the event loop thread */ PRFileDesc *event_q_wakeup_pipe_read; PRFileDesc *event_q_wakeup_pipe_write; @@ -110,9 +84,6 @@ struct ns_thrpool_t { struct ns_thread_t { PRThread *thr; /* the thread */ struct ns_thrpool_t *tp; /* pointer back to thread pool */ -#ifndef WITH_SDS - struct lfds710_stack_element se; /* This will self reference ourselves. */ -#endif }; #define ERRNO_WOULD_BLOCK(iii) (iii == EWOULDBLOCK) || (iii == EAGAIN) @@ -136,56 +107,6 @@ static void *(*calloc_fct)(size_t, size_t) = NULL; static void *(*realloc_fct)(void *, size_t) = NULL; static void (*free_fct)(void *) = NULL; -#ifndef WITH_SDS - -/* Thread local storage for last dequeued element */ -/* - * How and why does this work? - * LFDS710 claims: - * "Unusually, once a queue element has been dequeued, it can be deallocated. " - * http://liblfds.org/mediawiki/index.php?title=r7.1.0:Queue_%28unbounded,_many_producer,_many_consumer%29#Lock-free_Specific_Behaviour - * - * However, during testing, this is not the case: - * AddressSanitizer: heap-use-after-free on address 0x60300006cc58 - * ... - * #4 0x7fcf7e00bfc4 in job_queue_dequeue /home/william/development/389ds/nunc-stans/ns_thrpool.c:248 - * - * We have the following issue. - * Thread A will attempt to dequeue the pointer at HEAD. Thread B is *also* - * about to attempt the same dequeue. When Thread B issues the load barrier - * Thread A has not yet dequeue, so element E1 is still the HEAD. - * - * Thread A now atomically dequeues the item E1. However, Thread B *still* - * has not checked the value. Thread A now frees E1. Thread B in umpmc at line - * 99 now does the check of next -> value. This causes the heap use after free - * - * This means that lfds isn't quite safe for this! - * - * The queue itself is stable and correct, the element isn't dequeued twice, it's - * just that it's possible for a dequeued and freed value to be reffered to by - * another thread. The solution I have for this issue is somewhat inspired by - * https://aturon.github.io/blog/2015/08/27/epoch/ - * - * In thread local storage, we keep the last few elements we have dequeued - * with a flag to point between A/B. This gives us a small generation - * ring buffer in essence. When we dequeue an element E1, we store the ptr - * into the TLS. Then, we dequeue E2, and store it also into TLS. When we dequeue - * E3, we now free E1, and store E3 in the TLS. E4 will free E2 and store E4. - * - * The benefit of this is that when we go to free E1, we can *guarantee* that - * Nothing should still be using it, or reffering to it, since we have taken - * The next element out of the queue also! - */ - -struct queue_gc { - PRUint64 current_generation; - struct lfds710_queue_umm_element **garbage; -}; - -static size_t queue_generations = 32; /* The number of generations to keep */ - -#endif - /* syslog functions */ static void ns_syslog(int priority, const char *fmt, va_list varg) @@ -255,8 +176,6 @@ ns_thrpool_is_event_shutdown(struct ns_thrpool_t *tp) } -#ifdef WITH_SDS - static void job_queue_cleanup(void *arg) { struct ns_job_t *job = (ns_job_t *)arg; @@ -268,164 +187,6 @@ job_queue_cleanup(void *arg) { } } -#else - -/* - * Datastructure manipulation functions. - * This is to abstract some of the issues with them, make it a bit easier to replace - */ -/* Stack */ - -struct ns_thr_stack_t * -thr_stack_create() -{ - struct ns_thr_stack_t *s = ns_memalign(sizeof(struct ns_thr_stack_t), LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES); - lfds710_stack_init_valid_on_current_logical_core(&(s->stack), NULL); - return s; -} - -void -thr_stack_push(struct ns_thr_stack_t *s, ns_thread_t **thr) -{ - struct lfds710_stack_element *se = ns_malloc(sizeof(struct lfds710_stack_element)); - LFDS710_STACK_SET_VALUE_IN_ELEMENT(*se, (void *)*thr); - lfds710_stack_push(&(s->stack), se); - /* Kill the reference */ - thr = NULL; -} - -PRStatus -thr_stack_pop(struct ns_thr_stack_t *s, ns_thread_t **thr) -{ - struct lfds710_stack_element *se; - if (lfds710_stack_pop(&(s->stack), &se) && se) { - /* Macro doesn't deref, we need to. */ - *thr = LFDS710_STACK_GET_VALUE_FROM_ELEMENT(*se); - ns_free(se); - PR_ASSERT(*thr); - return PR_SUCCESS; - } - return PR_FAILURE; -} - -void -thr_stack_cleanup(struct ns_thr_stack_t *s) -{ - lfds710_stack_cleanup(&(s->stack), NULL); - ns_free(s); -} - -/* Queue */ - -static struct ns_job_queue_t * -job_queue_create() -{ - struct lfds710_queue_umm_element *qe_dummy = ns_malloc(sizeof(struct lfds710_queue_umm_element)); - struct ns_job_queue_t *q = ns_memalign(sizeof(struct ns_job_queue_t), LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES); - lfds710_queue_umm_init_valid_on_current_logical_core(&(q->queue), qe_dummy, NULL); - - return q; -} - -static struct queue_gc * -job_queue_thread_prep() -{ - /* Get ready to use lock free ds */ - LFDS710_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE; - /* Setup the gc for the queue */ - struct queue_gc *gc = ns_malloc(sizeof(struct queue_gc)); - /* Set the first generation for this thread */ - gc->current_generation = 1; - /* Create the array for the thread to keep the values in. */ - gc->garbage = ns_malloc(sizeof(struct lfds710_queue_umm_element *) * queue_generations); - for (size_t i = 0; i < queue_generations; i++) { - gc->garbage[i] = NULL; - } - return gc; -} - -static void -job_queue_thread_cleanup(struct queue_gc *gc) -{ - /* if the TLS has a queue element in it, free it. */ - if (gc->garbage != NULL) { - for (size_t i = 0; i < queue_generations; i++) { - if (gc->garbage[i] != NULL) { - ns_free(gc->garbage[i]); - } - } - ns_free(gc->garbage); - } - ns_free(gc); -} - -static PRStatus -job_queue_dequeue(struct ns_job_queue_t *q, struct queue_gc *gc, ns_job_t **job) -{ - struct lfds710_queue_umm_element *qe = NULL; - *job = NULL; - if (lfds710_queue_umm_dequeue(&(q->queue), &qe) && qe) { - /* If this pulls the dummy should be NULL */ - *job = LFDS710_QUEUE_UMM_GET_VALUE_FROM_ELEMENT( *qe ); - PR_ASSERT(*job); - /* Put the qe into the TLS for us to free next loop */ - /* We get out the oldest element next for us to free */ - PR_ASSERT(gc != NULL); - PR_ASSERT(gc->garbage != NULL); - if (gc->garbage[gc->current_generation] != NULL) { - ns_free(gc->garbage[gc->current_generation]); - } - gc->garbage[gc->current_generation] = qe; - gc->current_generation = (gc->current_generation + 1) % queue_generations; - return PR_SUCCESS; - } - return PR_FAILURE; -} - -static void -job_queue_enqueue(struct ns_job_queue_t *q, ns_job_t **job) -{ - struct lfds710_queue_umm_element *qe = ns_malloc(sizeof(struct lfds710_queue_umm_element)); - LFDS710_QUEUE_UMM_SET_VALUE_IN_ELEMENT(*qe, *job); - lfds710_queue_umm_enqueue(&(q->queue), qe); - /* Kill the reference */ - job = NULL; -} - -/* - * WB - We need to use this, rather than loop over queue and close, else we - * miss the dummy element - */ -static void -ns_queue_job_cleanup(struct lfds710_queue_umm_state *qs, struct lfds710_queue_umm_element *qe, enum lfds710_misc_flag dummy_element_flag) -{ - if (qe != NULL && dummy_element_flag == LFDS710_MISC_FLAG_LOWERED) { - struct ns_job_t *job = NULL; - job = NULL; - job = LFDS710_QUEUE_UMM_GET_VALUE_FROM_ELEMENT( *qe ); - if (job != NULL) { -#ifdef DEBUG_FSM - ns_log(LOG_DEBUG, "ns_queue_job_cleanup: destroying job %x\n", job); -#endif - internal_ns_job_done(job); - } - } - if (qe != NULL) { - ns_free(qe); - } -} - - -void -job_queue_cleanup(struct ns_job_queue_t *q) -{ - lfds710_queue_umm_cleanup(&(q->queue), ns_queue_job_cleanup); - ns_free(q); - q = NULL; -} - -#endif /* without_sds */ - static void internal_ns_job_done(ns_job_t *job) { @@ -578,11 +339,7 @@ work_q_notify(ns_job_t *job) /* MUST NOT ACCESS job after enqueue. So we stash tp.*/ ns_thrpool_t *ltp = job->tp; PR_ExitMonitor(job->monitor); -#ifdef WITH_SDS sds_lqueue_enqueue(ltp->work_q, (void *)job); -#else - job_queue_enqueue(ltp->work_q, &job); -#endif PR_Lock(ltp->work_q_lock); PR_NotifyCondVar(ltp->work_q_cv); PR_Unlock(ltp->work_q_lock); @@ -599,11 +356,7 @@ worker_thread_func(void *arg) ns_thrpool_t *tp = thr->tp; /* Get ready to use lock free ds */ -#ifdef WITH_SDS sds_lqueue_tprep(tp->work_q); -#else - struct queue_gc *gc = job_queue_thread_prep(); -#endif /* * Execute jobs until shutdown is set and the queues are empty. @@ -611,11 +364,7 @@ worker_thread_func(void *arg) while (!ns_thrpool_is_shutdown(tp)) { ns_job_t *job = NULL; /* Don't need monitor here, job_dequeue barriers the memory for us. Job will be valid */ -#ifdef WITH_SDS while(sds_lqueue_dequeue(tp->work_q, (void **)&job) == SDS_LIST_EXHAUSTED && !ns_thrpool_is_shutdown(tp)) -#else - while(job_queue_dequeue(tp->work_q, gc, &job) != PR_SUCCESS && !ns_thrpool_is_shutdown(tp)) -#endif { work_q_wait(tp); } @@ -627,10 +376,6 @@ worker_thread_func(void *arg) } /* With sds, it cleans the thread on join automatically. */ -#ifndef WITH_SDS - /* We are done, remove any excess! */ - job_queue_thread_cleanup(gc); -#endif } /* @@ -744,11 +489,7 @@ event_q_notify(ns_job_t *job) ns_log(LOG_DEBUG, "event_q_notify enqueuing %x with state %d\n", job, job->state); #endif -#ifdef WITH_SDS sds_lqueue_enqueue(tp->event_q, (void *)job); -#else - job_queue_enqueue(tp->event_q, &job); -#endif event_q_wake(tp); } } @@ -763,11 +504,7 @@ static void get_new_event_requests(ns_thrpool_t *tp) { ns_job_t *job = NULL; -#ifdef WITH_SDS while (sds_lqueue_dequeue(tp->event_q, (void **)&job) == SDS_SUCCESS) -#else - while (job_queue_dequeue(tp->event_q, tp->event_gc, &job) == PR_SUCCESS) -#endif { if (job != NULL) { #ifdef DEBUG_FSM @@ -787,12 +524,7 @@ event_loop_thread_func(void *arg) { struct ns_thrpool_t *tp = (struct ns_thrpool_t *)arg; -#ifdef WITH_SDS sds_lqueue_tprep(tp->event_q); -#else - /* In order to make queue_gc work, we have to put the gc into the TP */ - tp->event_gc = job_queue_thread_prep(); -#endif while (!ns_thrpool_is_event_shutdown(tp)) { int rc; @@ -807,11 +539,6 @@ event_loop_thread_func(void *arg) event_q_wait(tp); } } - -#ifndef WITH_SDS - /* We are leaving the event loop. */ - job_queue_thread_cleanup(tp->event_gc); -#endif } /* @@ -1577,17 +1304,9 @@ ns_thrpool_new(struct ns_thrpool_config *tp_config) tp->stacksize = tp_config->stacksize; -#ifdef WITH_SDS if (sds_queue_init(&(tp->thread_stack), NULL) != SDS_SUCCESS) { goto failed; } -#else - /* - * Get the stack ready to use. Replaces "new()" - * http://liblfds.org/mediawiki/index.php?title=r7.1.0:Stack - */ - tp->thread_stack = thr_stack_create(); -#endif if (!(tp->work_q_lock = PR_NewLock())) { goto failed; @@ -1596,21 +1315,12 @@ ns_thrpool_new(struct ns_thrpool_config *tp_config) goto failed; } -#ifdef WITH_SDS if (sds_lqueue_init(&(tp->work_q), job_queue_cleanup) != SDS_SUCCESS) { goto failed; } if (sds_lqueue_init(&(tp->event_q), job_queue_cleanup) != SDS_SUCCESS) { goto failed; } -#else - /* - * http://liblfds.org/mediawiki/index.php?title=r7.1.0:Queue_%28unbounded,_many_producer,_many_consumer%29 - * We need to push in, and dequeue the dummy element to start up the queue. - */ - tp->work_q = job_queue_create(); - tp->event_q = job_queue_create(); -#endif /* NGK TODO - add tevent vs. libevent switch */ /* tp->ns_event_fw = get_event_framework_tevent(); */ @@ -1627,11 +1337,7 @@ ns_thrpool_new(struct ns_thrpool_config *tp_config) thr, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, tp_config->stacksize); PR_ASSERT(thr->thr); -#ifdef WITH_SDS sds_queue_enqueue(tp->thread_stack, thr); -#else - thr_stack_push(tp->thread_stack, &thr); -#endif } event_thr = PR_CreateThread(PR_USER_THREAD, event_loop_thread_func, @@ -1682,7 +1388,6 @@ ns_thrpool_destroy(struct ns_thrpool_t *tp) * internals of tp. */ PR_JoinThread(tp->event_thread); -#ifdef WITH_SDS if (tp->work_q) { sds_lqueue_destroy(tp->work_q); } @@ -1690,19 +1395,6 @@ ns_thrpool_destroy(struct ns_thrpool_t *tp) if (tp->thread_stack) { sds_queue_destroy(tp->thread_stack); } -#else - /* Free the work queue. */ - if (tp->work_q) { - job_queue_cleanup(tp->work_q); - } - - /* Free the thread stack. */ - if (tp->thread_stack) { - /* The stack should be empty if ns_thrpool_wait() returned successfully - * already. For this reason, we don't need to supply a data delete callback. */ - thr_stack_cleanup(tp->thread_stack); - } -#endif /* Free the work queue lock. */ if (tp->work_q_lock) { @@ -1716,16 +1408,9 @@ ns_thrpool_destroy(struct ns_thrpool_t *tp) tp->work_q_cv = NULL; } -#ifdef WITH_SDS if (tp->event_q) { sds_lqueue_destroy(tp->event_q); } -#else - /* Free the event queue. */ - if (tp->event_q) { - job_queue_cleanup(tp->event_q); - } -#endif /* Free the event queue wakeup pipe/job. */ if (tp->event_q_wakeup_pipe_read) { @@ -1783,11 +1468,7 @@ ns_thrpool_wait(ns_thrpool_t *tp) PRStatus retval = PR_SUCCESS; ns_thread_t *thr; -#ifdef WITH_SDS while (sds_queue_dequeue(tp->thread_stack, (void **)&thr) == SDS_SUCCESS) -#else - while (thr_stack_pop(tp->thread_stack, &thr) == PR_SUCCESS) -#endif { PRStatus rc = PR_JoinThread(thr->thr); #ifdef DEBUG_FSM