commit cd1a44ab3b299dca30de68e4e2c6cdd81a75c1bf
parent bebcb0290c7dfadf956878cdb4d92e673a5f2c8b
Author: vaplv <vaplv@free.fr>
Date: Fri, 25 Apr 2025 15:23:48 +0200
Restrict support to POSIX systems only
Removal of support for the Win32 platform, and partial support for
macOS. Only UNIX is now explicitly supported. Support for the
proprietary CL compiler has also been removed.
This is not a major change, since UNIX (in fact GNU/Linux) is the only
system on which the library has been compiled and tested for several
years now. So this commit simply removes obsolete code.
Diffstat:
12 files changed, 4 insertions(+), 365 deletions(-)
diff --git a/src/clock_time.c b/src/clock_time.c
@@ -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/endianness.h b/src/endianness.h
@@ -23,44 +23,14 @@
#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);
-}
-
-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);
-}
-
-static FINLINE uint64_t
-byte_swap_64(const uint64_t ui)
-{
- return _byteswap_uint64(ui);
-}
-#endif
-
static FINLINE uint16_t
little_endian_16(const uint16_t ui)
{
diff --git a/src/image.c b/src/image.c
@@ -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 {
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/logger.c b/src/logger.c
@@ -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
diff --git a/src/mem_lifo_allocator.c b/src/mem_lifo_allocator.c
@@ -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
@@ -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/realXY.h b/src/realXY.h
@@ -328,4 +328,3 @@ REALXY_REALXY_FUNC__(mul)
#ifdef COMPILER_GCC
#pragma GCC pop_options
#endif
-
diff --git a/src/rsys.h b/src/rsys.h
@@ -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) \
@@ -290,23 +239,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 +296,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 +315,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 +365,3 @@ typedef int res_T;
#endif
#endif /* RSYS_H */
-
diff --git a/src/str.c b/src/str.c
@@ -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/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");
-}
-