rsys

Basic data structures and low-level features
git clone git://git.meso-star.fr/rsys.git
Log | Files | Refs | README | LICENSE

commit 092e00c91458058c82e47ed58de15f15f81434e8
parent a230e68cc26bedbfc2b645771f38a5a2e555353f
Author: vaplv <vaplv@free.fr>
Date:   Wed, 30 Apr 2025 09:49:19 +0200

Merge branch 'release_0.15'

Diffstat:
MMakefile | 224+++++++++++++++++++++++++++++++++++--------------------------------------------
MREADME.md | 18+++++++++++++++++-
Mconfig.mk | 5++++-
Dmake.sh | 68--------------------------------------------------------------------
Msrc/algorithm.h | 3+--
Msrc/binary_heap.h | 3+--
Msrc/clock_time.c | 48+++---------------------------------------------
Msrc/clock_time.h | 3+--
Msrc/condition.h | 3+--
Msrc/cstr.c | 2+-
Msrc/cstr.h | 3+--
Msrc/cstr_to_list.h | 3+--
Msrc/double2.h | 3+--
Msrc/double22.h | 3+--
Msrc/double3.h | 3+--
Msrc/double33.h | 3+--
Msrc/double4.h | 3+--
Msrc/double44.h | 3+--
Msrc/dynamic_array.h | 3+--
Msrc/dynamic_array_char.h | 2+-
Msrc/dynamic_array_double.h | 3+--
Msrc/dynamic_array_float.h | 3+--
Msrc/dynamic_array_int.h | 3+--
Msrc/dynamic_array_size_t.h | 3+--
Msrc/dynamic_array_str.h | 3+--
Msrc/dynamic_array_u32.h | 3+--
Msrc/dynamic_array_u64.h | 3+--
Msrc/dynamic_array_uchar.h | 2+-
Msrc/dynamic_array_uint.h | 3+--
Msrc/endianness.h | 108++++++++++++++++++++++++++++++++++++++++++-------------------------------------
Msrc/float2.h | 3+--
Msrc/float22.h | 3+--
Msrc/float3.h | 3+--
Msrc/float33.h | 3+--
Msrc/float4.h | 3+--
Msrc/float44.h | 3+--
Msrc/free_list.h | 3+--
Msrc/hash.c | 3+--
Msrc/hash.h | 3+--
Msrc/hash_table.h | 3+--
Msrc/image.c | 96+------------------------------------------------------------------------------
Msrc/image.h | 19+------------------
Dsrc/io_c99.h | 56--------------------------------------------------------
Msrc/library.c | 3+--
Msrc/library.h | 5++---
Msrc/list.h | 3+--
Msrc/logger.c | 6++----
Msrc/logger.h | 3+--
Msrc/math.h | 2+-
Msrc/mem_allocator.c | 2+-
Msrc/mem_allocator.h | 3+--
Msrc/mem_lifo_allocator.c | 3+--
Msrc/mem_proxy_allocator.c | 4+---
Msrc/morton.h | 3+--
Msrc/mutex.h | 3+--
Msrc/pthread/pthread_condition.c | 3+--
Msrc/pthread/pthread_mutex.c | 3+--
Msrc/quaternion.c | 3+--
Msrc/quaternion.h | 3+--
Msrc/real2.h | 3+--
Msrc/real22.h | 3+--
Msrc/real3.h | 3+--
Msrc/real33.h | 3+--
Msrc/real44.h | 3+--
Msrc/realX.h | 2+-
Msrc/realXY.h | 3+--
Msrc/realXY_begin.h | 3+--
Msrc/realXY_end.h | 3+--
Msrc/realX_begin.h | 3+--
Msrc/realX_end.h | 3+--
Msrc/ref_count.h | 3+--
Msrc/rsys.h | 84+++----------------------------------------------------------------------------
Msrc/signal.h | 3+--
Msrc/str.c | 3+--
Msrc/str.h | 3+--
Msrc/stretchy_array.h | 3+--
Msrc/test_algorithm.c | 3+--
Msrc/test_atomic.c | 3+--
Msrc/test_binary_heap.c | 3+--
Msrc/test_condition.c | 32++++++++++++++++++--------------
Msrc/test_cstr.c | 14+++++++-------
Msrc/test_double2.c | 3+--
Msrc/test_double22.c | 3+--
Msrc/test_double3.c | 3+--
Msrc/test_double33.c | 3+--
Msrc/test_double4.c | 3+--
Msrc/test_double44.c | 3+--
Msrc/test_dynamic_array.c | 3+--
Msrc/test_endianness.c | 2+-
Msrc/test_float2.c | 3+--
Msrc/test_float22.c | 3+--
Msrc/test_float3.c | 3+--
Msrc/test_float33.c | 3+--
Msrc/test_float4.c | 3+--
Msrc/test_float44.c | 3+--
Msrc/test_free_list.c | 2+-
Msrc/test_func_name.c | 9++++-----
Msrc/test_hash_sha256.c | 2+-
Msrc/test_hash_table.c | 3+--
Msrc/test_image.c | 2+-
Msrc/test_library.c | 4++--
Msrc/test_list.c | 3+--
Msrc/test_logger.c | 3+--
Msrc/test_math.c | 3+--
Msrc/test_mem_allocator.c | 3+--
Msrc/test_misc.c | 4++--
Msrc/test_morton.c | 2+-
Msrc/test_mutex.c | 51++++++++++++++++++++++++++++++++-------------------
Msrc/test_quaternion.c | 2+-
Msrc/test_real2.h | 3+--
Msrc/test_real22.h | 2+-
Msrc/test_real3.h | 3+--
Msrc/test_real33.h | 3+--
Msrc/test_real4.h | 3+--
Msrc/test_real44.h | 2+-
Msrc/test_ref.c | 4++--
Msrc/test_signal.c | 3+--
Msrc/test_str.c | 2+-
Msrc/test_text_reader.c | 3+--
Msrc/test_time.c | 2+-
Msrc/test_utils.h | 1-
Msrc/test_vmacros.c | 2+-
Msrc/text_reader.c | 2+-
Msrc/text_reader.h | 2+-
Dsrc/win32/win32_condition.c | 60------------------------------------------------------------
Dsrc/win32/win32_mutex.c | 91-------------------------------------------------------------------------------
126 files changed, 361 insertions(+), 940 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +# Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) # # 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 @@ -22,6 +22,9 @@ LIBNAME_STATIC = librsys.a LIBNAME_SHARED = librsys.so LIBNAME = $(LIBNAME_$(LIB_TYPE)) +default: library +all: library tests + ################################################################################ # RSys building ################################################################################ @@ -43,7 +46,10 @@ SRC =\ OBJ = $(SRC:.c=.o) DEP = $(SRC:.c=.d) -build_library: $(DEP) +CFLAGS_LIB = $(CFLAGS_SO) -DRSYS_SHARED_BUILD +LDFLAGS_LIB = $(LDFLAGS_SO) $(LIBS) + +library: $(DEP) @$(MAKE) -fMakefile $$(for i in $(DEP); do echo -f $${i}; done) \ $$(if [ -n "$(LIBNAME)" ]; then\ echo "$(LIBNAME)";\ @@ -54,7 +60,7 @@ build_library: $(DEP) $(DEP) $(OBJ): config.mk $(LIBNAME_SHARED): $(OBJ) - $(CC) $(CFLAGS_SO) -o $@ $(OBJ) $(LDFLAGS_SO) $(LIBS) + $(CC) $(CFLAGS_LIB) -o $@ $(OBJ) $(LDFLAGS_LIB) $(LIBNAME_STATIC): librsys.o $(AR) -rc $@ $? @@ -66,10 +72,10 @@ librsys.o: $(OBJ) .SUFFIXES: .c .d .o .c.d: - @$(CC) $(CFLAGS_SO) -MM -MT "$(@:.d=.o) $@" $< -MF $@ + @$(CC) $(CFLAGS_LIB) -MM -MT "$(@:.d=.o) $@" $< -MF $@ .c.o: - $(CC) $(CFLAGS_SO) -DRSYS_SHARED_BUILD -c $< -o $@ + $(CC) $(CFLAGS_LIB) -c $< -o $@ ################################################################################ # Installation @@ -135,8 +141,8 @@ API =\ src/text_reader.h pkg: - sed -e 's#@PREFIX@#$(PREFIX)#g'\ - -e 's#@VERSION@#$(VERSION)#g'\ + sed -e 's,@PREFIX@,$(PREFIX),g'\ + -e 's,@VERSION@,$(VERSION),g'\ rsys.pc.in > rsys.pc # Remove the include directive rather than setting it to "./src". to prevent @@ -149,42 +155,40 @@ pkg: # library rsys-local.pc: rsys.pc.in sed -e '1,2d'\ - -e 's#^libdir=.*#libdir=./#'\ - -e 's#@PREFIX@#$(PREFIX)#g'\ - -e 's#@VERSION@#$(VERSION)#g'\ - -e 's#-I$${includedir}##g'\ + -e 's,^libdir=.*,libdir=./,'\ + -e 's,@PREFIX@,$(PREFIX),g'\ + -e 's,@VERSION@,$(VERSION),g'\ + -e 's,-I$${includedir},,g'\ rsys.pc.in > $@ -install: build_library pkg - @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib/" $(LIBNAME) - @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/doc/rsys" COPYING README.md - @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib/pkgconfig" rsys.pc - @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/include/rsys" $(API) +install: library pkg + install() { mode="$$1"; prefix="$$2"; shift 2; \ + mkdir -p "$${prefix}"; \ + for i in "$$@"; do \ + if ! cmp -s "$${i}" "$${prefix}/$${i##*/}"; then \ + cp "$$@" "$${prefix}"; \ + chmod "$${mode}" "$$@"; \ + fi; \ + done; \ + }; \ + install 755 "$(DESTDIR)$(LIBPREFIX)" $(LIBNAME); \ + install 644 "$(DESTDIR)$(LIBPREFIX)/pkgconfig" rsys.pc; \ + install 644 "$(DESTDIR)$(INCPREFIX)/rsys" $(API); \ + install 644 "$(DESTDIR)$(PREFIX)/share/doc/rsys" COPYING README.md uninstall: - rm -f "$(DESTDIR)$(PREFIX)/lib/$(LIBNAME)" - rm -f "$(DESTDIR)$(PREFIX)/lib/pkgconfig/rsys.pc" + rm -f "$(DESTDIR)$(LIBPREFIX)/$(LIBNAME)" + rm -f "$(DESTDIR)$(LIBPREFIX)/pkgconfig/rsys.pc" rm -f "$(DESTDIR)$(PREFIX)/share/doc/rsys/COPYING" rm -f "$(DESTDIR)$(PREFIX)/share/doc/rsys/README.md" - rm -f $$(echo $(API) | sed 's,src\/,$(DESTDIR)$(PREFIX)\/include\/rsys\/,g') - -################################################################################ -# Miscellaneous targets -################################################################################ -all: build_library build_tests + rm -f $$(echo $(API) | sed 's,src/,$(DESTDIR)$(INCPREFIX)/rsys/,g') clean: clean_test - rm -f $(OBJ) $(TEST_OBJ) $(LIBNAME) librsys.o + rm -f $(OBJ) $(DEP) $(LIBNAME) librsys.o rm -f rsys.pc rsys-local.pc rm -f libtest_lib.so test_lib.o rm -f .test rsys.pc .test.ppm test_text_reader.txt test.ppm -distclean: clean - rm -f $(DEP) $(TEST_DEP) - -lint: - shellcheck -o all make.sh - ################################################################################ # Tests ################################################################################ @@ -231,129 +235,101 @@ TEST_SRC =\ src/test_vmacros.c TEST_OBJ = $(TEST_SRC:.c=.o) TEST_DEP = $(TEST_SRC:.c=.d) +TEST_TGT = $(TEST_SRC:.c=.t) PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./:$${PKG_CONFIG_PATH}" $(PKG_CONFIG) -RSYS_CFLAGS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags rsys-local.pc) -RSYS_LIBS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs rsys-local.pc) -build_tests: build_library $(TEST_DEP) .test - @$(MAKE) -fMakefile -f.test $$(for i in $(TEST_DEP); do echo -f"$${i}"; done) test_bin +INCS_TEST = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags rsys-local.pc) +LIBS_TEST = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs rsys-local.pc) -lm -$(TEST_DEP) $(TEST_OBJ): config.mk +CFLAGS_TEST = $(CFLAGS_EXE) $(INCS_TEST) +LDFLAGS_TEST = $(LDFLAGS_EXE) $(LIBS_TEST) -test: build_tests - @$(SHELL) make.sh run_test $(TEST_SRC) +tests: library $(TEST_DEP) $(TEST_TGT) + @$(MAKE) -fMakefile \ + $$(for i in $(TEST_DEP); do echo -f"$${i}"; done) \ + $$(for i in $(TEST_TGT); do echo -f"$${i}"; done) \ + test_all -.test: Makefile - @echo "Setup tests" - @$(SHELL) make.sh config_test $(TEST_SRC) > .test +$(TEST_TGT): + @{ \ + exe="$$(basename "$@" ".t")"; \ + printf '%s: %s\n' "$${exe}" $(@:.t=.o); \ + printf 'test_all: %s\n' "$${exe}"; \ + } > $@ -clean_test: - @rm -f libtest_lib.so test_lib.o .test .test.ppm test_text_reader.txt test.ppm - @$(SHELL) make.sh clean_test $(TEST_SRC) - -src/test_algorithm.o \ -src/test_atomic.o \ -src/test_binary_heap.o \ -src/test_double22.o \ -src/test_double2.o \ -src/test_double33.o \ -src/test_double3.o \ -src/test_double44.o \ -src/test_double4.o \ -src/test_dynamic_array.o \ -src/test_endianness.o \ -src/test_float22.o \ -src/test_float2.o \ -src/test_float33.o \ -src/test_float3.o \ -src/test_float44.o \ -src/test_float4.o \ -src/test_free_list.o \ -src/test_func_name.o \ -src/test_hash_sha256.o \ -src/test_hash_table.o \ -src/test_image.o \ -src/test_library.o \ -src/test_list.o \ -src/test_logger.o \ -src/test_math.o \ -src/test_mem_allocator.o \ -src/test_misc.o \ -src/test_morton.o \ -src/test_quaternion.o \ -src/test_ref.o \ -src/test_signal.o \ -src/test_str.o \ -src/test_stretchy_array.o \ -src/test_text_reader.o \ -src/test_time.o \ -src/test_vmacros.o \ -: config.mk rsys-local.pc $(LIBNAME) - $(CC) $(CFLAGS_EXE) $(RSYS_CFLAGS) -c $(@:.o=.c) -o $@ +test_lib.o: src/test_library.c src/rsys.h config.mk + $(CC) $(CFLAGS_SO) -c src/test_library.c -DTEST_LIBRARY_BUILD_LIB -o $@ -src/test_cstr.o: config.mk rsys-local.pc $(LIBNAME) - $(CC) $(CFLAGS_EXE) $(RSYS_CFLAGS) -Wno-long-long -c $(@:.o=.c) -o $@ +libtest_lib.so: test_lib.o config.mk + $(CC) $(CFLAGS_SO) -o $@ test_lib.o $(LDFLAGS_SO) + +test_library: libtest_lib.so -src/test_condition.o src/test_mutex.o: config.mk rsys-local.pc $(LIBNAME) - $(CC) $(CFLAGS_EXE) $(RSYS_CFLAGS) -fopenmp -c $(@:.o=.c) -o $@ +$(TEST_DEP): config.mk rsys-local.pc + @$(CC) $(CFLAGS_TEST) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ + +$(TEST_OBJ): config.mk rsys-local.pc + $(CC) $(CFLAGS_TEST) -c $(@:.o=.c) -o $@ test_algorithm \ test_atomic \ -test_endianness \ -test_func_name \ -test_misc \ -test_morton \ -test_ref \ -test_vmacros \ -: config.mk - $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) - -test_double22 \ +test_binary_heap \ +test_condition \ +test_cstr \ test_double2 \ -test_double33 \ +test_double22 \ test_double3 \ -test_double44 \ +test_double33 \ test_double4 \ -test_float22 \ +test_double44 \ +test_dynamic_array \ +test_endianness \ test_float2 \ -test_float33 \ +test_float22 \ test_float3 \ -test_float44 \ +test_float33 \ test_float4 \ -test_math \ -: config.mk - $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) -lm - -test_binary_heap\ -test_cstr \ -test_dynamic_array \ +test_float44 \ test_free_list \ +test_func_name \ test_hash_sha256 \ test_hash_table \ test_image \ test_library \ test_list \ test_logger \ +test_math \ test_mem_allocator \ +test_misc \ +test_morton \ +test_mutex \ +test_quaternion \ +test_ref \ test_signal \ test_str \ test_stretchy_array \ test_text_reader \ test_time \ +test_vmacros \ : config.mk rsys-local.pc $(LIBNAME) - $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS) $(RSYS_LIBS) - -test_quaternion: config.mk rsys-local.pc $(LIBNAME) - $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS) $(RSYS_LIBS) -lm - -test_condition test_mutex: config.mk rsys-local.pc $(LIBNAME) - $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS) $(RSYS_LIBS) -lm -fopenmp - -test_lib.o: src/test_library.c src/rsys.h config.mk - $(CC) $(CFLAGS_SO) -c src/test_library.c -DTEST_LIBRARY_BUILD_LIB -o $@ + $(CC) $(CFLAGS_TEST) -o $@ src/$@.o $(LDFLAGS_TEST) -libtest_lib.so: test_lib.o config.mk - $(CC) $(CFLAGS_SO) -o $@ test_lib.o $(LDFLAGS_SO) - -test_library: libtest_lib.so +clean_test: + rm -f $(TEST_DEP) $(TEST_OBJ) $(TEST_TGT) + rm -f libtest_lib.so test_lib.o test_text_reader.txt test.ppm + for i in $(TEST_SRC); do rm -f "$$(basename "$${i}" ".c")"; done + +test: tests + @err=0; \ + for i in $(TEST_SRC); do \ + test="$$(basename "$${i}" ".c")"; \ + printf '%s' "$${test}"; \ + if "./$${test}" > /dev/null 2>&1; then \ + printf '\n'; \ + else \ + printf ': error %s\n' "$$?"; \ + err=$$((err+1)); \ + fi \ + done; \ + [ "$${err}" -eq 0 ] diff --git a/README.md b/README.md @@ -22,6 +22,22 @@ Edit config.mk as needed, then run: ## Release notes +### Version 0.15 + +- Improve the building system. Simplify it by doing everything in one + place (the Makefile) and building all the tests in the same way. + Provide additional macros to control installation subdirectories. +- Remove (deprecated) support from Windows system and partial + (deprecated) support from macOS. The library now targets portability + of POSIX systems. +- Remove (deprecated) support from the CL compiler. +- Delete the code notified as obsolete for 8 years. +- Improve the portability of the endiannes functions by relying solely + on the C language and thus being independent of the order of bytes of + the machine, alignment, or anything else. +- Remove the OpenMP dependency. Only the tests used it. They now use + POSIX threads and therefore depend only on the C compiler. + ### Version 0.14 This version marks the replacement of CMake by Makefile as the build @@ -194,7 +210,7 @@ simplifying its portability and support while being much lighter. ## License -Copyright © 2013-2023 Vincent Forest (vaplv@free.fr) +Copyright © 2013-2023, 2025 Vincent Forest (vaplv@free.fr) RSys is free software released under the GPL v3+ license: GNU GPL version 3 or later. You are welcome to redistribute it under certain diff --git a/config.mk b/config.mk @@ -1,4 +1,4 @@ -VERSION = 0.14.0 +VERSION = 0.15.0 PREFIX = /usr/local LIB_TYPE = SHARED @@ -7,6 +7,9 @@ LIB_TYPE = SHARED BUILD_TYPE = RELEASE #BUILD_TYPE = DEBUG +LIBPREFIX = $(PREFIX)/lib +INCPREFIX = $(PREFIX)/include + ################################################################################ # Tools ################################################################################ diff --git a/make.sh b/make.sh @@ -1,68 +0,0 @@ -#!/bin/sh -e - -# Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) -# -# 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 <http://www.gnu.org/licenses/>. - -config_test() -{ - for i in "$@"; do - test=$(basename "${i}" ".c") - test_list="${test_list} ${test}" - printf "%s: %s\n" "${test}" "src/${test}.o" - done - printf "test_bin: %s\n" "${test_list}" -} - -run_test() -{ - for i in "$@"; do - test=$(basename "${i}" ".c") - - printf "%s " "${test}" - if ./"${test}" > /dev/null 2>&1; then - printf "\033[1;32mOK\033[m\n" - else - printf "\033[1;31mError\033[m\n" - fi - done 2> /dev/null -} - -clean_test() -{ - for i in "$@"; do - rm -f "$(basename "${i}" ".c")" - done -} - -install() -{ - prefix=$1 - shift 1 - - mkdir -p "${prefix}" - - for i in "$@"; do - dst="${prefix}/${i##*/}" - - if cmp -s "${i}" "${dst}"; then - printf "Up to date %s\n" "${dst}" - else - printf "Installing %s\n" "${dst}" - cp "${i}" "${prefix}" - fi - done -} - -"$@" diff --git a/src/algorithm.h b/src/algorithm.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -50,4 +50,3 @@ search_lower_bound } #endif /* ALGORITHM_H */ - diff --git a/src/binary_heap.h b/src/binary_heap.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -242,4 +242,3 @@ exit: #undef BHEAP_NODES_FUNC__ #endif /* !BHEAP_NAME || !BHEAP_DATA */ - diff --git a/src/clock_time.c b/src/clock_time.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -16,20 +16,7 @@ #define _POSIX_C_SOURCE 200112L /* snprintf support */ #include "rsys.h" -#if defined(COMPILER_CL) || (defined(MINGW) && defined(ARCH_32BITS)) - #define CLOCK_TIME_WINDOWS -#elif defined(OS_MACH) - #define CLOCK_TIME_MACH -#endif - -#ifdef CLOCK_TIME_WINDOWS - #include "io_c99.h" /* snprintf support */ - #include <Windows.h> -#elif defined(CLOCK_TIME_MACH) - #include <mach/mach_time.h> -#else - #include <time.h> -#endif +#include <time.h> #include "clock_time.h" #include <string.h> @@ -45,34 +32,6 @@ struct time* time_current(struct time* t) { -#ifdef CLOCK_TIME_WINDOWS - LARGE_INTEGER time, tmp; - BOOL b ; - ASSERT(t); - - QueryPerformanceCounter(&time); - b = QueryPerformanceFrequency(&tmp); - (void)b; - ASSERT(b); - - t->nsec = (int64_t)((double)time.QuadPart*1000000000.0/(double)tmp.QuadPart); - t->sec = t->nsec / 1000000000; - t->nsec = t->nsec - t->sec * 1000000000; -#elif defined(CLOCK_TIME_MACH) - static double orwl_timebase = 0.0; - static uint64_t orwl_timestart = 0; - double diff; - if (!orwl_timestart) { - mach_timebase_info_data_t tb = { 0 }; - mach_timebase_info(&tb); - orwl_timebase = tb.numer; - orwl_timebase /= tb.denom; - orwl_timestart = mach_absolute_time(); - } - diff = (double)(mach_absolute_time() - orwl_timestart) * orwl_timebase; - t->sec = (int64_t)diff / 1000000000; - t->nsec = (int64_t)diff - t->sec * 1000000000; -#else struct timespec time; int err = 0; (void)err; ASSERT(t); @@ -81,7 +40,6 @@ time_current(struct time* t) ASSERT(err == 0); t->sec = (int64_t)time.tv_sec; t->nsec = (int64_t)time.tv_nsec; -#endif return t; } @@ -237,10 +195,10 @@ time_dump #undef DUMP } +#undef TIME_TO_NSEC #undef NSEC_PER_USEC__ #undef NSEC_PER_MSEC__ #undef NSEC_PER_SEC__ #undef NSEC_PER_MIN__ #undef NSEC_PER_HOUR__ #undef NSEC_PER_DAY__ - diff --git a/src/clock_time.h b/src/clock_time.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -79,4 +79,3 @@ time_dump END_DECLS #endif /* TIME_H */ - diff --git a/src/condition.h b/src/condition.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -29,4 +29,3 @@ RSYS_API void cond_signal(struct cond* cond); RSYS_API void cond_broadcast(struct cond* cond); #endif /* CONDITION_H */ - diff --git a/src/cstr.c b/src/cstr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published diff --git a/src/cstr.h b/src/cstr.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -208,4 +208,3 @@ size_to_cstr END_DECLS #endif /* CSTR_H */ - diff --git a/src/cstr_to_list.h b/src/cstr_to_list.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -96,4 +96,3 @@ error: #undef CSTR_LIST_SUFFIX #endif /* defined(CSTR_LIST_TYPE) */ - diff --git a/src/double2.h b/src/double2.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -20,4 +20,3 @@ #include "real2.h" #endif /* DOUBLE2_H */ - diff --git a/src/double22.h b/src/double22.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -22,4 +22,3 @@ #include "real22.h" #endif /* DOUBLE22_H */ - diff --git a/src/double3.h b/src/double3.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -20,4 +20,3 @@ #include "real3.h" #endif /* DOUBLE3_H */ - diff --git a/src/double33.h b/src/double33.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -22,4 +22,3 @@ #include "real33.h" #endif /* DOUBLE33_H */ - diff --git a/src/double4.h b/src/double4.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -24,4 +24,3 @@ #include "realX_end.h" #endif /* DOUBLE4_H */ - diff --git a/src/double44.h b/src/double44.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -23,4 +23,3 @@ #include "real44.h" #endif /* DOUBLE44_H */ - diff --git a/src/dynamic_array.h b/src/dynamic_array.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -415,4 +415,3 @@ DARRAY_FUNC__(swap)(struct DARRAY_TYPE__* a, struct DARRAY_TYPE__* b) #undef DARRAY_TYPE__ #endif /* !DARRAY_NAME || !DARRAY_TYPE */ - diff --git a/src/dynamic_array_char.h b/src/dynamic_array_char.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published diff --git a/src/dynamic_array_double.h b/src/dynamic_array_double.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -23,4 +23,3 @@ #include "dynamic_array.h" #endif /* DYNAMIC_ARRRAY_DOUBLE_H */ - diff --git a/src/dynamic_array_float.h b/src/dynamic_array_float.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -23,4 +23,3 @@ #include "dynamic_array.h" #endif /* DYNAMIC_ARRRAY_FLOAT_H */ - diff --git a/src/dynamic_array_int.h b/src/dynamic_array_int.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -23,4 +23,3 @@ #include "dynamic_array.h" #endif /* DYNAMIC_ARRRAY_INT_H */ - diff --git a/src/dynamic_array_size_t.h b/src/dynamic_array_size_t.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -23,4 +23,3 @@ #include "dynamic_array.h" #endif /* DYNAMIC_ARRRAY_SIZE_T_H */ - diff --git a/src/dynamic_array_str.h b/src/dynamic_array_str.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -28,4 +28,3 @@ #include "dynamic_array.h" #endif /* DYNAMIC_ARRAY_STR_H */ - diff --git a/src/dynamic_array_u32.h b/src/dynamic_array_u32.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -23,4 +23,3 @@ #include "dynamic_array.h" #endif /* DYNAMIC_ARRRAY_U32_H */ - diff --git a/src/dynamic_array_u64.h b/src/dynamic_array_u64.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -23,4 +23,3 @@ #include "dynamic_array.h" #endif /* DYNAMIC_ARRRAY_U64_H */ - diff --git a/src/dynamic_array_uchar.h b/src/dynamic_array_uchar.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published diff --git a/src/dynamic_array_uint.h b/src/dynamic_array_uint.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -23,4 +23,3 @@ #include "dynamic_array.h" #endif /* DYNAMIC_ARRRAY_UINT_H */ - diff --git a/src/endianness.h b/src/endianness.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -23,102 +23,108 @@ #define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__ #define BIG_ENDIAN __ORDER_BIG_ENDIAN__ #include <byteswap.h> -#elif defined(COMPILER_CL) - #include <Windows.h> - #define BYTE_ORDER REG_DWORD - #define LITTLE_ENDIAN REG_DWORD_LITTLE_ENDIAN - #define BIG_ENDIAN REG_DWORD_BIG_ENDIAN #else #error "Undefined byte ordering macros" #endif -#ifdef COMPILER_GCC -static FINLINE uint16_t byte_swap_16(const uint16_t ui) { return bswap_16(ui); } -static FINLINE uint32_t byte_swap_32(const uint32_t ui) { return bswap_32(ui); } -static FINLINE uint64_t byte_swap_64(const uint64_t ui) { return bswap_64(ui); } - -#elif defined COMPILER_CL static FINLINE uint16_t byte_swap_16(const uint16_t ui) { - STATIC_ASSERT(sizeof(unsigned short) == sizeof(uint16_t), - Unexpected_sizeof_ushort); - return _byteswap_ushort(ui); + union { uint16_t ui; uint8_t bytes[2]; } ucast; + ucast.ui = ui; + SWAP(uint8_t, ucast.bytes[0], ucast.bytes[1]); + return ucast.ui; } static FINLINE uint32_t byte_swap_32(const uint32_t ui) { - STATIC_ASSERT(sizeof(unsigned long) == sizeof(uint32_t), - Unexpected_sizeof_ushort); - return _byteswap_ulong(ui); + union { uint32_t ui; uint8_t bytes[4]; } ucast; + ucast.ui = ui; + SWAP(uint8_t, ucast.bytes[0], ucast.bytes[3]); + SWAP(uint8_t, ucast.bytes[1], ucast.bytes[2]); + return ucast.ui; } - static FINLINE uint64_t byte_swap_64(const uint64_t ui) { - return _byteswap_uint64(ui); + union { uint64_t ui; uint8_t bytes[8]; } ucast; + ucast.ui = ui; + SWAP(uint8_t, ucast.bytes[0], ucast.bytes[7]); + SWAP(uint8_t, ucast.bytes[1], ucast.bytes[6]); + SWAP(uint8_t, ucast.bytes[2], ucast.bytes[5]); + SWAP(uint8_t, ucast.bytes[3], ucast.bytes[4]); + return ucast.ui; } -#endif static FINLINE uint16_t little_endian_16(const uint16_t ui) { -#if BYTE_ORDER == LITTLE_ENDIAN - return ui; -#elif BYTE_ORDER == BIG_ENDIAN - return byte_swap_16(ui); -#endif + union { uint16_t ui; uint8_t bytes[2]; } ucast; + ucast.ui = ui; + return ((uint16_t)ucast.bytes[0] << 0) + | ((uint16_t)ucast.bytes[1] << 8); } static FINLINE uint32_t little_endian_32(const uint32_t ui) { -#if BYTE_ORDER == LITTLE_ENDIAN - return ui; -#elif BYTE_ORDER == BIG_ENDIAN - return byte_swap_32(ui); -#endif + union { uint32_t ui; uint8_t bytes[4]; } ucast; + ucast.ui = ui; + return ((uint32_t)ucast.bytes[0] << 0) + | ((uint32_t)ucast.bytes[1] << 8) + | ((uint32_t)ucast.bytes[2] << 16) + | ((uint32_t)ucast.bytes[3] << 24); } static FINLINE uint64_t little_endian_64(const uint64_t ui) { -#if BYTE_ORDER == LITTLE_ENDIAN - return ui; -#elif BYTE_ORDER == BIG_ENDIAN - return byte_swap_64(ui); -#endif + union { uint64_t ui; uint8_t bytes[8]; } ucast; + ucast.ui = ui; + return ((uint64_t)ucast.bytes[0] << 0) + | ((uint64_t)ucast.bytes[1] << 8) + | ((uint64_t)ucast.bytes[2] << 16) + | ((uint64_t)ucast.bytes[3] << 24) + | ((uint64_t)ucast.bytes[4] << 32) + | ((uint64_t)ucast.bytes[5] << 40) + | ((uint64_t)ucast.bytes[6] << 48) + | ((uint64_t)ucast.bytes[7] << 56); } static FINLINE uint16_t big_endian_16(const uint16_t ui) { -#if BYTE_ORDER == LITTLE_ENDIAN - return byte_swap_16(ui); -#elif BYTE_ORDER == BIG_ENDIAN - return ui; -#endif + union { uint16_t ui; uint8_t bytes[2]; } ucast; + ucast.ui = ui; + return ((uint16_t)ucast.bytes[0] << 8) + | ((uint16_t)ucast.bytes[1] << 0); } static FINLINE uint32_t big_endian_32(const uint32_t ui) { -#if BYTE_ORDER == LITTLE_ENDIAN - return byte_swap_32(ui); -#elif BYTE_ORDER == BIG_ENDIAN - return ui; -#endif + union { uint32_t ui; uint8_t bytes[2]; } ucast; + ucast.ui = ui; + return ((uint32_t)ucast.bytes[0] << 24) + | ((uint32_t)ucast.bytes[1] << 16) + | ((uint32_t)ucast.bytes[2] << 8) + | ((uint32_t)ucast.bytes[3] << 0); } static FINLINE uint64_t big_endian_64(const uint64_t ui) { -#if BYTE_ORDER == LITTLE_ENDIAN - return byte_swap_64(ui); -#elif BYTE_ORDER == BIG_ENDIAN - return ui; -#endif + union { uint64_t ui; uint8_t bytes[8]; } ucast; + ucast.ui = ui; + return ((uint64_t)ucast.bytes[0] << 56) + | ((uint64_t)ucast.bytes[1] << 48) + | ((uint64_t)ucast.bytes[2] << 40) + | ((uint64_t)ucast.bytes[3] << 32) + | ((uint64_t)ucast.bytes[4] << 24) + | ((uint64_t)ucast.bytes[5] << 16) + | ((uint64_t)ucast.bytes[6] << 8) + | ((uint64_t)ucast.bytes[7] << 0); } #endif /* ENDIANNESS_H */ diff --git a/src/float2.h b/src/float2.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -20,4 +20,3 @@ #include "real2.h" #endif /* FLOAT2_H */ - diff --git a/src/float22.h b/src/float22.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -22,4 +22,3 @@ #include "real22.h" #endif /* FLOAT22_H */ - diff --git a/src/float3.h b/src/float3.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -20,4 +20,3 @@ #include "real3.h" #endif /* FLOAT3_H */ - diff --git a/src/float33.h b/src/float33.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -22,4 +22,3 @@ #include "real33.h" #endif /* FLOAT33_H */ - diff --git a/src/float4.h b/src/float4.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -24,4 +24,3 @@ #include "realX_end.h" #endif /* FLOAT4_H */ - diff --git a/src/float44.h b/src/float44.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -23,4 +23,3 @@ #include "real44.h" #endif /* FLOAT44_H */ - diff --git a/src/free_list.h b/src/free_list.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -226,4 +226,3 @@ FLIST_FUNC__(is_empty)(struct FLIST_TYPE__* list) #undef FITEM_TYPE #endif /* ifdef FITEM_TYPE */ - diff --git a/src/hash.c b/src/hash.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -288,4 +288,3 @@ hash256_eq(const hash256_T hash0, const hash256_T hash1) { return memcmp(hash0, hash1, sizeof(hash256_T)) == 0; } - diff --git a/src/hash.h b/src/hash.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -117,4 +117,3 @@ hash256_eq END_DECLS #endif /* HASH_H */ - diff --git a/src/hash_table.h b/src/hash_table.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -707,4 +707,3 @@ HTABLE_FUNC__(iterator_data_get)(const struct HTABLE_ITERATOR__* it) #undef HTABLE_DATA_FUNC__ #endif /* !HTABLE_NAME || !HTABLE_KEY || !HTABLE_DATA */ - diff --git a/src/image.c b/src/image.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -20,10 +20,6 @@ #include <stdio.h> #include <string.h> -#ifdef COMPILER_CL - #include "io_c99.h" -#endif - enum ppm_id { P3, P6 }; struct parser { @@ -378,93 +374,3 @@ exit: error: goto exit; } - -/******************************************************************************* - * Deprecated functions - ******************************************************************************/ -static res_T -deprecated_image_ppm_write_stream - (FILE* fp, - const int width, - const int height, - const int Bpp, - const unsigned char* buffer) -{ - int i; - res_T res = RES_OK; - - if(!width || !height || !Bpp || !buffer || !fp) { - res = RES_BAD_ARG; - goto error; - } - - i = fprintf(fp, "P3\n\n%i %i\n%i\n", width, height, 255); - if(i < 0) { - res = RES_IO_ERR; - goto error; - } - - if(Bpp) { - const long pitch = width * Bpp; - int x, y; - for(y = 0; y < height; ++y) { - const unsigned char* row = buffer + y * pitch; - for(x = 0; x < width; ++x) { - const unsigned char* pixel = row + x * Bpp; - i = fprintf(fp, "%u %u %u\n", - pixel[0], - Bpp > 1 ? pixel[1] : pixel[0], - Bpp > 2 ? pixel[2] : pixel[0]); - if(i < 0) { - res = RES_IO_ERR; - goto error; - } - } - fprintf(fp, "\n"); - } - } - -exit: - return res; -error: - goto exit; -} - -res_T -image_ppm_write - (const char* path, - const int width, - const int height, - const int Bpp, - const unsigned char* buffer) -{ - FILE* fp = NULL; - res_T res = RES_OK; - - fp = fopen(path, "w"); - if(NULL == fp) { - res = RES_IO_ERR; - goto error; - } - - res = deprecated_image_ppm_write_stream(fp, width, height, Bpp, buffer); - if(res != RES_OK) goto error; - -exit: - if(fp) fclose(fp); - return res; -error: - goto exit; -} - -res_T -image_ppm_write_stream - (FILE* fp, - const int width, - const int height, - const int Bpp, - const unsigned char* buffer) -{ - return deprecated_image_ppm_write_stream(fp, width, height, Bpp, buffer); -} - diff --git a/src/image.h b/src/image.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -88,23 +88,6 @@ image_write_ppm_stream const int binary, FILE* stream); -DEPRECATED RSYS_API res_T -image_ppm_write - (const char* path, - const int width, - const int height, - const int bytes_per_pixel, - const unsigned char* buffer); - -DEPRECATED RSYS_API res_T -image_ppm_write_stream - (FILE* stream, - const int width, - const int height, - const int bytes_per_pixel, - const unsigned char* buffer); - END_DECLS #endif /* IMAGE_H */ - diff --git a/src/io_c99.h b/src/io_c99.h @@ -1,56 +0,0 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) - * - * The RSys library 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. - * - * The RSys library 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 the RSys library. If not, see <http://www.gnu.org/licenses/>. */ - -#ifndef IO_C99_H -#define IO_C99_H - -#include "rsys.h" - -#ifdef COMPILER_CL - -#include <stdarg.h> - -#define snprintf snprintf_c99__ -#define vsnprintf vsnprint_c99__ - -static INLINE int -vsnprint_c99__(char* str, size_t sz, const char* fmt, va_list arg_lst) -{ - int count = -1; - - if(sz) - count = _vsnprintf_s(str, sz, _TRUNCATE, fmt, arg_lst); - if(count == -1) - count = _vscprintf(fmt, arg_lst); - - return count; -} - -static INLINE int -snprintf_c99__(char* str, size_t sz, const char* fmt, ...) -{ - int count; - va_list arg_lst; - - va_start(arg_lst, fmt); - count = vsnprint_c99__(str, sz, fmt, arg_lst); - va_end(arg_lst); - - return count; -} - -#endif /* COMPILER_CL */ - -#endif /* IO_C99_H */ diff --git a/src/library.c b/src/library.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -78,4 +78,3 @@ library_close(void* handle) return RES_OK; } #endif /* OS_<XXX> */ - diff --git a/src/library.h b/src/library.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -19,7 +19,7 @@ #include "rsys.h" BEGIN_DECLS - + RSYS_API void* /* Library handle */ library_open (const char* filename); @@ -36,4 +36,3 @@ library_close END_DECLS #endif /* LIBRARY_H */ - diff --git a/src/list.h b/src/list.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -139,4 +139,3 @@ list_move_tail(struct list_node* node, struct list_node* list) } #endif /* LIST_H */ - diff --git a/src/logger.c b/src/logger.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -14,7 +14,6 @@ * along with the RSys library. If not, see <http://www.gnu.org/licenses/>. */ #define _POSIX_C_SOURCE 200112L /* vsnprintf support */ -#include "io_c99.h" #include "logger.h" res_T @@ -42,7 +41,7 @@ logger_vprint ASSERT(logger && log && (unsigned)type < LOG_TYPES_COUNT__); if(logger == LOGGER_DEFAULT) { - FILE* stream = LOG_OUTPUT ? stdout : stderr; + FILE* stream = type == LOG_OUTPUT ? stdout : stderr; vfprintf(stream, log, vargs_list); fflush(stream); return RES_OK; @@ -83,4 +82,3 @@ logger_vprint (darray_char_cdata_get(&logger->buffer), logger->streams[type].ctx); return RES_OK; } - diff --git a/src/logger.h b/src/logger.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -140,4 +140,3 @@ logger_vprint END_DECLS #endif /* LOGGER_H */ - diff --git a/src/math.h b/src/math.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published diff --git a/src/mem_allocator.c b/src/mem_allocator.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published diff --git a/src/mem_allocator.h b/src/mem_allocator.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -157,4 +157,3 @@ mem_shutdown_lifo_allocator END_DECLS #endif /* MEM_ALLOCATOR_H */ - diff --git a/src/mem_lifo_allocator.c b/src/mem_lifo_allocator.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -15,7 +15,6 @@ #define _POSIX_C_SOURCE 200112L /* snprintf support */ -#include "io_c99.h" #include "math.h" #include "mem_allocator.h" #include "mutex.h" diff --git a/src/mem_proxy_allocator.c b/src/mem_proxy_allocator.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -15,7 +15,6 @@ #define _POSIX_C_SOURCE 200112L /* snprintf support */ -#include "io_c99.h" #include "math.h" #include "mem_allocator.h" #include "mutex.h" @@ -316,4 +315,3 @@ mem_shutdown_proxy_allocator(struct mem_allocator* proxy) } memset(proxy, 0, sizeof(struct mem_allocator)); } - diff --git a/src/morton.h b/src/morton.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -101,4 +101,3 @@ morton_xyz_decode_u21(const uint64_t code, uint32_t xyz[3]) } #endif /* MORTON_H */ - diff --git a/src/mutex.h b/src/mutex.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -36,4 +36,3 @@ RSYS_API void mutex_rw_unlock(struct mutex_rw* mutex); END_DECLS #endif /* MUTEX_H */ - diff --git a/src/pthread/pthread_condition.c b/src/pthread/pthread_condition.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -62,4 +62,3 @@ cond_broadcast(struct cond* cond) } #undef PTHREAD - diff --git a/src/pthread/pthread_mutex.c b/src/pthread/pthread_mutex.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -100,4 +100,3 @@ mutex_rw_unlock(struct mutex_rw* mutex) } #undef PTHREAD - diff --git a/src/quaternion.c b/src/quaternion.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -74,4 +74,3 @@ quat_to_f33(float mat33[9], const float quat[4]) return mat33; } - diff --git a/src/quaternion.h b/src/quaternion.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -91,4 +91,3 @@ quat_to_f33 const float quat[4]); #endif /* QUATERNION_H */ - diff --git a/src/real2.h b/src/real2.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -30,4 +30,3 @@ REALX_FUNC__(cross)(const REAL_TYPE__ a[2], const REAL_TYPE__ b[2]) } #include "realX_end.h" - diff --git a/src/real22.h b/src/real22.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -84,4 +84,3 @@ REALXY_FUNC__(rotation) } #include "realXY_end.h" - diff --git a/src/real3.h b/src/real3.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -37,4 +37,3 @@ REALX_FUNC__(cross) } #include "realX_end.h" - diff --git a/src/real33.h b/src/real33.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -191,4 +191,3 @@ REALXY_FUNC__(basis)(REAL_TYPE__ dst[9], const REAL_TYPE__ N[3]) } #include "realXY_end.h" - diff --git a/src/real44.h b/src/real44.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -155,4 +155,3 @@ REALXY_FUNC__(invtrans)(REAL_TYPE__* dst, const REAL_TYPE__* mat) #undef REAL33_FUNC__ #include "realXY_end.h" - diff --git a/src/realX.h b/src/realX.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published diff --git a/src/realXY.h b/src/realXY.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -328,4 +328,3 @@ REALXY_REALXY_FUNC__(mul) #ifdef COMPILER_GCC #pragma GCC pop_options #endif - diff --git a/src/realXY_begin.h b/src/realXY_begin.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -76,4 +76,3 @@ STATIC_ASSERT (REALX_DIMENSION__ > 1 && REALY_DIMENSION__ > 1, Unexpected_value); #include "realX_begin.h" - diff --git a/src/realXY_end.h b/src/realXY_end.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -31,4 +31,3 @@ #undef REALXY_BEGIN_H #include "realX_end.h" - diff --git a/src/realX_begin.h b/src/realX_begin.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -89,4 +89,3 @@ /* Check the validity of the vector dimension */ #include "rsys.h" STATIC_ASSERT(REALX_DIMENSION__ > 1, Unexpected_value); - diff --git a/src/realX_end.h b/src/realX_end.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -39,4 +39,3 @@ #undef SIZEOF_REALX__ #undef REALX_BEGIN_H - diff --git a/src/ref_count.h b/src/ref_count.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -52,4 +52,3 @@ ref_put(ref_T* ref, void (*release)(ref_T*)) } #endif /* REF_COUNT_H */ - diff --git a/src/rsys.h b/src/rsys.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -16,10 +16,6 @@ #ifndef RSYS_H #define RSYS_H -#if !defined(__GNUC__) && !defined(_MSC_VER) - #error "Unsupported compiler" -#endif - /* In C99 standard, C++ defines some macros (eg UINT32_MAX) only when * __STDC_LIMIT_MACROS or __STDC_CONSTANT_MACROS are defined before <stdint.h> * is included. The C11 standard removes this constraint. The following work @@ -56,13 +52,6 @@ ******************************************************************************/ #if defined(__unix__) || defined(__unix) || defined(unix) #define OS_UNIX -#elif defined(_WIN32) - #define OS_WINDOWS - #if defined(__MINGW32__) - #define MINGW - #endif -#elif defined(__APPLE__) && defined(__MACH__) - #define OS_MACH #else #error "Unsupported OS" #endif @@ -72,8 +61,6 @@ ******************************************************************************/ #if defined(__GNUC__) #define COMPILER_GCC -#elif defined(_MSC_VER) - #define COMPILER_CL #else #error "Unsupported compiler" #endif @@ -94,10 +81,6 @@ #define EXPORT_SYM __attribute__((visibility("default"))) #define IMPORT_SYM #define LOCAL_SYM __attribute__((visibility("hidden"))) -#elif defined(COMPILER_CL) - #define EXPORT_SYM __declspec(dllexport) - #define IMPORT_SYM __declspec(dllimport) - #define LOCAL_SYM #else #error "Undefined symbol visibility macros" #endif @@ -105,16 +88,6 @@ #if defined(OS_UNIX) #define SHARED_LIBRARY_PREFIX "lib" #define SHARED_LIBRARY_SUFFIX ".so" -#elif defined(OS_WINDOWS) - #if defined(MINGW) - #define SHARED_LIBRARY_PREFIX "lib" - #elif defined(COMPILER_CL) - #define SHARED_LIBRARY_PREFIX - #endif - #define SHARED_LIBRARY_SUFFIX ".dll" -#elif defined(OS_MACH) - #define SHARED_LIBRARY_PREFIX "lib" - #define SHARED_LIBRARY_SUFFIX ".dylib" #endif #if !defined(SHARED_LIBRARY_PREFIX) || !defined(SHARED_LIBRARY_SUFFIX) @@ -136,10 +109,6 @@ #define FINLINE __inline__ __attribute__((always_inline)) #define INLINE __inline__ #define NOINLINE __attribute__((noinline)) -#elif defined(COMPILER_CL) - #define FINLINE __forceinline - #define INLINE __inline - #define NOINLINE __declspec(noinline) #else #error "Undefined inlining macros" #endif @@ -150,9 +119,6 @@ #if defined(COMPILER_GCC) #define ALIGN(Size) __attribute__((aligned(Size))) #define ALIGNOF(Type) __alignof__(Type) -#elif defined(COMPILER_CL) - #define ALIGN(Size) __declspec(align(Size)) - #define ALIGNOF(Type) __alignof(Type) #else #error "Undefined alignment macros" #endif @@ -171,17 +137,6 @@ #define ATOMIC_SUB(A, V) __sync_sub_and_fetch((A), V) #define ATOMIC_CAS(Atom, NewVal, Comparand) /* Return the initial value */ \ __sync_val_compare_and_swap((Atom), (Comparand), (NewVal)) -#elif defined(COMPILER_CL) - #include <Windows.h> - #define ATOMIC LONGLONG - #define ATOMIC_INCR(A) InterlockedIncrement64((A)) - #define ATOMIC_DECR(A) InterlockedDecrement64((A)) - #define ATOMIC_ADD(A, V) \ - (InterlockedExchangeAdd64((A), (LONGLONG)(V)) + (LONGLONG)(V)) - #define ATOMIC_SUB(A, V) \ - (InterlockedExchangeAdd64((A),-(LONGLONG)(V)) - (LONGLONG)(V)) - #define ATOMIC_CAS(Atom, NewVal, Comparand) /* Return the initial value */ \ - (InterlockedCompareExchange64(Atom, NewVal, Comparand)) #else #error "Undefined atomic operations" #endif @@ -192,9 +147,7 @@ /******************************************************************************* * Function deprecation ******************************************************************************/ -#ifdef COMPILER_CL - #define DEPRECATED __declspec(deprecated) -#elif defined COMPILER_GCC +#if defined COMPILER_GCC #define DEPRECATED __attribute__((deprecated)) #else #define DEPRECATED @@ -214,10 +167,6 @@ #define STATIC_ASSERT(Cond, Msg) \ static char CONCAT(CONCAT(CONCAT(STATIC_ASSERT_, COUNTER), _), Msg) \ [1 - 2*(!(Cond))] __attribute__((unused)) -#else - #define STATIC_ASSERT(Cond, Msg) \ - static char CONCAT(CONCAT(CONCAT(STATIC_ASSERT_, COUNTER), _), Msg) \ - [1 - 2*(!(Cond))]; #endif #define VFATAL(Fmt, Args) \ @@ -235,11 +184,6 @@ FATAL("error:" STR(__FILE__) ":" STR(__LINE__)"\n"); \ } (void)0 -static INLINE DEPRECATED void macro_CHECK(void) { (void)0; } -static INLINE DEPRECATED void macro_NCHECK(void) { (void)0; } -#define CHECK(A, B) { macro_CHECK(); CHK((A) == (B)); } (void)0 -#define NCHECK(A, B) { macro_NCHECK(); CHK((A) != (B)); } (void)0 - /******************************************************************************* * Branch prediction information ******************************************************************************/ @@ -290,23 +234,6 @@ static INLINE DEPRECATED void macro_NCHECK(void) { (void)0; } #ifdef __FMA__ #define FMADD #endif -#elif defined(COMPILER_CL) - #ifdef ARCH_64BITS - #define SIMD_SSE - #define SIMD_SSE2 - - #else /* 32-bits */ - #if _M_IX86_FP >= 1 - #define SIMD_SSE - #endif - #if _M_IX86_FP >= 2 - #define SIMD_SSE2 - #endif - #endif - - #ifdef __AVX__ - #define SIMD_AVX - #endif #endif /******************************************************************************* @@ -364,8 +291,6 @@ typedef int res_T; /* On GCC compiler we follow the C-89 standard that does not support the * va_copy macro. We thus use the built-in __va_copy GCC extension */ #define VA_COPY(VArgs, Args) __va_copy((VArgs), (Args)) -#else - #define VA_COPY(VArgs, Args) va_copy((VArgs), (Args)) #endif #define BIT(Num) (1 << (Num)) @@ -385,9 +310,7 @@ typedef int res_T; #define CONTAINER_OF(Ptr, Type, Member) \ ((Type*)((uintptr_t)Ptr - offsetof(Type, Member))) -#ifdef COMPILER_CL - #define RESTRICT __restrict -#elif defined COMPILER_GCC +#if defined COMPILER_GCC #define RESTRICT __restrict__ #else #define RESTRICT @@ -437,4 +360,3 @@ typedef int res_T; #endif #endif /* RSYS_H */ - diff --git a/src/signal.h b/src/signal.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -74,4 +74,3 @@ typedef struct list_node signal_T; } (void)0 #endif /* SIGNAL_H */ - diff --git a/src/str.c b/src/str.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -14,7 +14,6 @@ * along with the RSys library. If not, see <http://www.gnu.org/licenses/>. */ #define _POSIX_C_SOURCE 200112L /* vsnprintf support */ -#include "io_c99.h" #include "str.h" #include <string.h> diff --git a/src/str.h b/src/str.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -207,4 +207,3 @@ str_hash(const struct str* str) } #endif /* STR_H */ - diff --git a/src/stretchy_array.h b/src/stretchy_array.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -97,4 +97,3 @@ sa_grow_func__(void* array, const size_t increment, const size_t itemsize) } #endif /* STRETCHY_ARRAY_H */ - diff --git a/src/test_algorithm.c b/src/test_algorithm.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -125,4 +125,3 @@ main(int argc, char** argv) return 0; } - diff --git a/src/test_atomic.c b/src/test_atomic.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -49,4 +49,3 @@ main(int argc, char** argv) return 0; } - diff --git a/src/test_binary_heap.c b/src/test_binary_heap.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -182,4 +182,3 @@ main(int argc, char** argv) CHK(mem_allocated_size() == 0); return 0; } - diff --git a/src/test_condition.c b/src/test_condition.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -13,10 +13,13 @@ * You should have received a copy of the GNU General Public License * along with the RSys library. If not, see <http://www.gnu.org/licenses/>. */ +#define _POSIX_C_SOURCE 199506L /* POSIX threads */ + #include "condition.h" #include "list.h" -#include <omp.h> + #include <string.h> +#include <pthread.h> static const char* src_str[] = { "Rcvfbqr 1, XARR-QRRC VA GUR QRNQ:\n\ @@ -90,9 +93,10 @@ struct buff char scratch[1024]; }; -static void -read(struct stream* stream) +static void* +read(void* arg) { + struct stream* stream = arg; size_t i = 0; ASSERT(stream); @@ -117,11 +121,13 @@ read(struct stream* stream) cond_broadcast(stream->cond_fill); } + return NULL; } -static void -write(struct stream* stream) +static void* +write(void* arg) { + struct stream* stream = arg; size_t i = 0; ASSERT(stream); @@ -147,6 +153,7 @@ write(struct stream* stream) cond_broadcast(stream->cond_flush); } + return NULL; } int @@ -154,6 +161,7 @@ main(int argc, char** argv) { struct buff buff[2]; struct stream stream; + pthread_t thread; (void)argc, (void)argv; list_init(&stream.list_fill); @@ -170,16 +178,12 @@ main(int argc, char** argv) list_add(&stream.list_fill, &buff[0].node); list_add(&stream.list_fill, &buff[1].node); - #pragma omp parallel sections shared(stream) num_threads(2) - { - #pragma omp section - read(&stream); - #pragma omp section - write(&stream); - } + CHK(pthread_create(&thread, NULL, read, &stream) == 0); /* Sub thread */ + write(&stream); + CHK(pthread_join(thread, NULL) == 0); + mutex_destroy(stream.mutex); cond_destroy(stream.cond_flush); cond_destroy(stream.cond_fill); return 0; } - diff --git a/src/test_cstr.c b/src/test_cstr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -102,9 +102,9 @@ test_int(void) sprintf(buf, "%d", INT_MIN); CHK(cstr_to_int(buf, &i) == RES_OK); CHK(i == INT_MIN); - sprintf(buf, "%lld", (long long)INT_MAX+1); + sprintf(buf, "%ld", (int64_t)INT_MAX+1); CHK(cstr_to_int(buf, &i) == RES_BAD_ARG); - sprintf(buf, "%lld", (long long)INT_MIN-1); + sprintf(buf, "%ld", (int64_t)INT_MIN-1); CHK(cstr_to_int(buf, &i) == RES_BAD_ARG); } @@ -128,7 +128,7 @@ test_uint(void) sprintf(buf, "%u", UINT_MAX); CHK(cstr_to_uint(buf, &u) == RES_OK); CHK(u == UINT_MAX); - sprintf(buf, "%llu", (unsigned long long)UINT_MAX+1); + sprintf(buf, "%lu", (uint64_t)UINT_MAX+1); CHK(cstr_to_uint(buf, &u) == RES_BAD_ARG); } @@ -309,9 +309,9 @@ test_list_uint(void) unsigned ulist[4]; size_t len; - CHK(cstr_to_list_uint(NULL, ':', ulist, NULL, 3) == RES_BAD_ARG); - CHK(cstr_to_list_uint("a", ':', ulist, NULL, 3) == RES_BAD_ARG); - CHK(cstr_to_list_uint("1:4:-1", ':', ulist, NULL, 3) == RES_OK); + CHK(cstr_to_list_uint(NULL, ':', ulist, NULL, 3) == RES_BAD_ARG); + CHK(cstr_to_list_uint("a", ':', ulist, NULL, 3) == RES_BAD_ARG); + CHK(cstr_to_list_uint("1:4:-1", ':', ulist, NULL, 3) == RES_OK); CHK(ulist[0] == 1); CHK(ulist[1] == 4); CHK(ulist[2] == (unsigned)-1); diff --git a/src/test_double2.c b/src/test_double2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -16,4 +16,3 @@ #include "double2.h" #define REAL_TYPE__ double #include "test_real2.h" - diff --git a/src/test_double22.c b/src/test_double22.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -16,4 +16,3 @@ #include "double22.h" #define REAL_TYPE__ double #include "test_real22.h" - diff --git a/src/test_double3.c b/src/test_double3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -16,4 +16,3 @@ #include "double3.h" #define REAL_TYPE__ double #include "test_real3.h" - diff --git a/src/test_double33.c b/src/test_double33.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -16,4 +16,3 @@ #include "double33.h" #define REAL_TYPE__ double #include "test_real33.h" - diff --git a/src/test_double4.c b/src/test_double4.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -16,4 +16,3 @@ #include "double4.h" #define REAL_TYPE__ double #include "test_real4.h" - diff --git a/src/test_double44.c b/src/test_double44.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -16,4 +16,3 @@ #include "double44.h" #define REAL_TYPE__ double #include "test_real44.h" - diff --git a/src/test_dynamic_array.c b/src/test_dynamic_array.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -520,4 +520,3 @@ main(int argc, char** argv) CHK(mem_allocated_size() == 0); return 0; } - diff --git a/src/test_endianness.c b/src/test_endianness.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published diff --git a/src/test_float2.c b/src/test_float2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -16,4 +16,3 @@ #include "float2.h" #define REAL_TYPE__ float #include "test_real2.h" - diff --git a/src/test_float22.c b/src/test_float22.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -16,4 +16,3 @@ #include "float22.h" #define REAL_TYPE__ float #include "test_real22.h" - diff --git a/src/test_float3.c b/src/test_float3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -16,4 +16,3 @@ #include "float3.h" #define REAL_TYPE__ float #include "test_real3.h" - diff --git a/src/test_float33.c b/src/test_float33.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -16,4 +16,3 @@ #include "float33.h" #define REAL_TYPE__ float #include "test_real33.h" - diff --git a/src/test_float4.c b/src/test_float4.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -16,4 +16,3 @@ #include "float4.h" #define REAL_TYPE__ float #include "test_real4.h" - diff --git a/src/test_float44.c b/src/test_float44.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -16,4 +16,3 @@ #include "float44.h" #define REAL_TYPE__ float #include "test_real44.h" - diff --git a/src/test_free_list.c b/src/test_free_list.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published diff --git a/src/test_func_name.c b/src/test_func_name.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -18,9 +18,9 @@ static void foo(void) { CHK(strcmp(FUNC_NAME, "foo") == 0); } static void bar(void) { CHK(strcmp(FUNC_NAME, "bar") == 0); } -static void foo_bar(int i) -{ - (void)i; +static void foo_bar(int i) +{ + (void)i; CHK(strcmp(FUNC_NAME, "foo_bar") == 0); } @@ -34,4 +34,3 @@ main(int argc, char** argv) foo_bar(0); return 0; } - diff --git a/src/test_hash_sha256.c b/src/test_hash_sha256.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published diff --git a/src/test_hash_table.c b/src/test_hash_table.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -615,4 +615,3 @@ main(int argc, char** argv) test_htbl_str_darray(); return 0; } - diff --git a/src/test_image.c b/src/test_image.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published diff --git a/src/test_library.c b/src/test_library.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -20,7 +20,7 @@ extern EXPORT_SYM void exported_func(void); -void +void exported_func(void) { printf("exported_func\n"); diff --git a/src/test_list.c b/src/test_list.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -209,4 +209,3 @@ main(int argc, char** argv) return 0; } - diff --git a/src/test_logger.c b/src/test_logger.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -227,4 +227,3 @@ ENCCRY QBJA GB GUR FHESNPR BS URYY.\n\n", CHK(mem_allocated_size() == 0); return 0; } - diff --git a/src/test_math.c b/src/test_math.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -133,4 +133,3 @@ main(int argc, char** argv) return 0; } - diff --git a/src/test_mem_allocator.c b/src/test_mem_allocator.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -195,4 +195,3 @@ main(int argc, char** argv) return 0; } - diff --git a/src/test_misc.c b/src/test_misc.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -22,7 +22,7 @@ main(int argc, char** argv) (void)argv; #ifdef COMPILER_GCC - printf("GCC version: %d.%d.%d\n", + printf("GCC version: %d.%d.%d\n", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); #endif diff --git a/src/test_morton.c b/src/test_morton.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published diff --git a/src/test_mutex.c b/src/test_mutex.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -13,11 +13,13 @@ * You should have received a copy of the GNU General Public License * along with the RSys library. If not, see <http://www.gnu.org/licenses/>. */ +#define _POSIX_C_SOURCE 199506L /* POSIX threads and nanosleep */ + #include "clock_time.h" #include "mutex.h" #include <string.h> -#include <omp.h> +#include <pthread.h> static const char src_str[] = { 'R','c','v','f','b','q','r',' ','1',',',' ','X','A','R','R', @@ -172,23 +174,38 @@ struct string int i; }; -static void -string_write(struct string* string) +#include <unistd.h> + +static void* +string_write(void* arg) { + struct string* string = arg; + struct timespec time; ASSERT(string); + time.tv_sec = 0; + time.tv_nsec = 10; + for(;;) { + int i = 0; mutex_lock(string->mutex); - if((unsigned)string->i >= sizeof(src_str)/sizeof(char) + 1) { + + i = string->i; + + /* Forcing thread interleaving */ + CHK(nanosleep(&time, NULL) == 0); + + if((unsigned)i >= sizeof(src_str)/sizeof(char) + 1) { mutex_unlock(string->mutex); break; } - string->str[string->i] = src_str[string->i]; - ++string->i; + string->str[string->i] = src_str[i]; + string->i = i+1; mutex_unlock(string->mutex); } + return NULL; } static void @@ -196,6 +213,7 @@ test_mutex(void) { struct string string; struct time time_start, time_end, time_res; + pthread_t thread; char dump[32]; string.str[0] = '\0'; @@ -203,19 +221,15 @@ test_mutex(void) string.mutex = mutex_create(); CHK(string.mutex != NULL); - + time_current(&time_start); - #pragma omp parallel - { - #pragma omp sections - { - #pragma omp section - string_write(&string); - #pragma omp section - string_write(&string); - } - } + /* Run a sub-thread */ + CHK(pthread_create(&thread, NULL, string_write, &string) == 0); + string_write(&string); + + CHK(pthread_join(thread, NULL) == 0); + time_current(&time_end); time_sub(&time_res, &time_end, &time_start); @@ -240,4 +254,3 @@ main(int argc, char** argv) test_mutex(); return 0; } - diff --git a/src/test_quaternion.c b/src/test_quaternion.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published diff --git a/src/test_real2.h b/src/test_real2.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -112,4 +112,3 @@ main(int argc, char** argv) CHECK_REAL2(dst, REALX_CTOR__(c, -3.0, -2.0)); return 0; } - diff --git a/src/test_real22.h b/src/test_real22.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published diff --git a/src/test_real3.h b/src/test_real3.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -125,4 +125,3 @@ main(int argc, char** argv) CHECK_REAL3(dst, REALX_CTOR__(c, -3.0, -2.0, -1.5)); return 0; } - diff --git a/src/test_real33.h b/src/test_real33.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -228,4 +228,3 @@ main(int argc, char** argv) return 0; } - diff --git a/src/test_real4.h b/src/test_real4.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -127,4 +127,3 @@ main(int argc, char** argv) CHECK_REAL4(dst, REALX_CTOR__(c, -1.0, 3.0, (REAL)-2.1, (REAL)0.1)); return 0; } - diff --git a/src/test_real44.h b/src/test_real44.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published diff --git a/src/test_ref.c b/src/test_ref.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -30,7 +30,7 @@ release(ref_T* ref) int main(int argc, char** argv) { - struct test test; + struct test test; (void)argc, (void)argv; ref_init(&test.ref); diff --git a/src/test_signal.c b/src/test_signal.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -172,4 +172,3 @@ main(int argc, char** argv) return 0; } - diff --git a/src/test_str.c b/src/test_str.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published diff --git a/src/test_text_reader.c b/src/test_text_reader.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -142,4 +142,3 @@ main(int argc, char** argv) CHK(mem_allocated_size() == 0); return 0; } - diff --git a/src/test_time.c b/src/test_time.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published diff --git a/src/test_utils.h b/src/test_utils.h @@ -16,4 +16,3 @@ check_memory_allocator(struct mem_allocator* allocator) } #endif /* TEST_UTILS_H */ - diff --git a/src/test_vmacros.c b/src/test_vmacros.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published diff --git a/src/text_reader.c b/src/text_reader.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published diff --git a/src/text_reader.h b/src/text_reader.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2023, 2025 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published diff --git a/src/win32/win32_condition.c b/src/win32/win32_condition.c @@ -1,60 +0,0 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) - * - * The RSys library 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. - * - * The RSys library 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 the RSys library. If not, see <http://www.gnu.org/licenses/>. */ - -#include "../condition.h" -#include "../mem_allocator.h" -#include <Windows.h> - -struct cond* -cond_create(void) -{ - PCONDITION_VARIABLE cond = mem_alloc(sizeof(CONDITION_VARIABLE)); - if(cond) - InitializeConditionVariable(cond); - return (struct cond*)cond; -} - -void -cond_destroy(struct cond* cond) -{ - ASSERT(cond); - mem_rm(cond); -} - -void -cond_wait(struct cond* cond, struct mutex* mutex) -{ - BOOL b; - (void)b; - ASSERT(cond); - b = SleepConditionVariableCS - ((PCONDITION_VARIABLE)cond, (PCRITICAL_SECTION)mutex, INFINITE); - ASSERT(b != 0); -} - -void -cond_signal(struct cond* cond) -{ - ASSERT(cond); - WakeConditionVariable((PCONDITION_VARIABLE)cond); -} - -void -cond_broadcast(struct cond* cond) -{ - ASSERT(cond); - WakeAllConditionVariable((PCONDITION_VARIABLE)cond); -} - diff --git a/src/win32/win32_mutex.c b/src/win32/win32_mutex.c @@ -1,91 +0,0 @@ -/* Copyright (C) 2013-2023 Vincent Forest (vaplv@free.fr) - * - * The RSys library 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. - * - * The RSys library 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 the RSys library. If not, see <http://www.gnu.org/licenses/>. */ - -#include "../mem_allocator.h" -#include "../mutex.h" -#include <Windows.h> - -/******************************************************************************* - * Mutex - ******************************************************************************/ -struct mutex* -mutex_create(void) -{ - LPCRITICAL_SECTION mutex = mem_alloc(sizeof(CRITICAL_SECTION)); - if(mutex) - InitializeCriticalSection(mutex); - return (struct mutex*)mutex; -} - -void -mutex_destroy(struct mutex* mutex) -{ - ASSERT(mutex); - DeleteCriticalSection((LPCRITICAL_SECTION)mutex); - mem_rm(mutex); -} - -void -mutex_lock(struct mutex* mutex) -{ - ASSERT(mutex); - EnterCriticalSection((LPCRITICAL_SECTION)mutex); -} - -void -mutex_unlock(struct mutex* mutex) -{ - ASSERT(mutex); - LeaveCriticalSection((LPCRITICAL_SECTION)mutex); -} - -/******************************************************************************* - * Read Write mutex - ******************************************************************************/ -struct mutex_rw* -mutex_rw_create(void) -{ - FATAL("Missing Read/Write mutex implementation with Win32 thread API.\n"); - return NULL; -} - -void -mutex_rw_destroy(struct mutex_rw* mutex) -{ - (void)mutex; - FATAL("Missing Read/Write mutex implementation with Win32 thread API.\n"); -} - -void -mutex_rw_rlock(struct mutex_rw* mutex) -{ - (void)mutex; - FATAL("Missing Read/Write mutex implementation with Win32 thread API.\n"); -} - -void -mutex_rw_wlock(struct mutex_rw* mutex) -{ - (void)mutex; - FATAL("Missing Read/Write mutex implementation with Win32 thread API.\n"); -} - -void -mutex_rw_unlock(struct mutex_rw* mutex) -{ - (void)mutex; - FATAL("Missing Read/Write mutex implementation with Win32 thread API.\n"); -} -