From 747a495e2417f8c2e95cf707597aee53bebc9f55 Mon Sep 17 00:00:00 2001 From: LIU Hao Date: Wed, 13 Nov 2024 12:57:26 +0800 Subject: [PATCH] build: Merge standard string functions into xglobals, but for DLL only --- mcfgthread/memcmp.c | 20 -------------------- mcfgthread/memcpy.c | 20 -------------------- mcfgthread/memmove.c | 26 -------------------------- mcfgthread/memset.c | 20 -------------------- mcfgthread/xglobals.c | 34 ++++++++++++++++++++++++++++++++++ meson.build | 22 ++++++++++------------ 6 files changed, 44 insertions(+), 98 deletions(-) delete mode 100644 mcfgthread/memcmp.c delete mode 100644 mcfgthread/memcpy.c delete mode 100644 mcfgthread/memmove.c delete mode 100644 mcfgthread/memset.c diff --git a/mcfgthread/memcmp.c b/mcfgthread/memcmp.c deleted file mode 100644 index cb8c39e80..000000000 --- a/mcfgthread/memcmp.c +++ /dev/null @@ -1,20 +0,0 @@ -/* This file is part of MCF Gthread. - * Copyright (C) 2022-2024 LH_Mouse. All wrongs reserved. - * - * MCF Gthread is free software. Licensing information is included in - * LICENSE.TXT as a whole. The GCC Runtime Library Exception applies - * to this file. */ - -#include "xprecompiled.h" - -int -__cdecl -__MCF_mcompare(const void* src, const void* cmp, size_t size); - -__MCF_DLLEXPORT -int -__cdecl -memcmp(const void* src, const void* cmp, size_t size) - { - return __MCF_mcompare(src, cmp, size); - } diff --git a/mcfgthread/memcpy.c b/mcfgthread/memcpy.c deleted file mode 100644 index 51945a7e5..000000000 --- a/mcfgthread/memcpy.c +++ /dev/null @@ -1,20 +0,0 @@ -/* This file is part of MCF Gthread. - * Copyright (C) 2022-2024 LH_Mouse. All wrongs reserved. - * - * MCF Gthread is free software. Licensing information is included in - * LICENSE.TXT as a whole. The GCC Runtime Library Exception applies - * to this file. */ - -#include "xprecompiled.h" - -void* -__cdecl -__MCF_mcopy(void* dst, const void* src, size_t size); - -__MCF_DLLEXPORT -void* -__cdecl -memcpy(void* dst, const void* src, size_t size) - { - return __MCF_mcopy(dst, src, size); - } diff --git a/mcfgthread/memmove.c b/mcfgthread/memmove.c deleted file mode 100644 index 585a36737..000000000 --- a/mcfgthread/memmove.c +++ /dev/null @@ -1,26 +0,0 @@ -/* This file is part of MCF Gthread. - * Copyright (C) 2022-2024 LH_Mouse. All wrongs reserved. - * - * MCF Gthread is free software. Licensing information is included in - * LICENSE.TXT as a whole. The GCC Runtime Library Exception applies - * to this file. */ - -#include "xprecompiled.h" - -void* -__cdecl -__MCF_mcopy(void* dst, const void* src, size_t size); - -void* -__cdecl -__MCF_mcopy_backward(void* dst, const void* src, size_t size); - -__MCF_DLLEXPORT -void* -__cdecl -memmove(void* dst, const void* src, size_t size) - { - return ((uintptr_t) dst - (uintptr_t) src >= size) - ? __MCF_mcopy(dst, src, size) - : __MCF_mcopy_backward(dst, src, size); - } diff --git a/mcfgthread/memset.c b/mcfgthread/memset.c deleted file mode 100644 index fb934124b..000000000 --- a/mcfgthread/memset.c +++ /dev/null @@ -1,20 +0,0 @@ -/* This file is part of MCF Gthread. - * Copyright (C) 2022-2024 LH_Mouse. All wrongs reserved. - * - * MCF Gthread is free software. Licensing information is included in - * LICENSE.TXT as a whole. The GCC Runtime Library Exception applies - * to this file. */ - -#include "xprecompiled.h" - -void* -__cdecl -__MCF_mfill(void* dst, int val, size_t size); - -__MCF_DLLEXPORT -void* -__cdecl -memset(void* dst, int val, size_t size) - { - return __MCF_mfill(dst, val, size); - } diff --git a/mcfgthread/xglobals.c b/mcfgthread/xglobals.c index e283a0b5b..b38faa69c 100644 --- a/mcfgthread/xglobals.c +++ b/mcfgthread/xglobals.c @@ -328,6 +328,40 @@ __MCF_dll_startup(PVOID instance, ULONG reason, PVOID reserved) } } +__declspec(dllexport) +void* +__cdecl +memcpy(void* dst, const void* src, size_t size) + { + return __MCF_mcopy(dst, src, size); + } + +__declspec(dllexport) +void* +__cdecl +memmove(void* dst, const void* src, size_t size) + { + return ((uintptr_t) dst - (uintptr_t) src >= size) + ? __MCF_mcopy(dst, src, size) + : __MCF_mcopy_backward(dst, src, size); + } + +__declspec(dllexport) +int +__cdecl +memcmp(const void* src, const void* cmp, size_t size) + { + return __MCF_mcompare(src, cmp, size); + } + +__declspec(dllexport) +void* +__cdecl +memset(void* dst, int val, size_t size) + { + return __MCF_mfill(dst, val, size); + } + #else /* __MCF_BUILDING_DLL */ /* When building the static library, invoke common routines from a TLS diff --git a/meson.build b/meson.build index fa27cd3d1..da127fd43 100644 --- a/meson.build +++ b/meson.build @@ -25,20 +25,18 @@ project('mcfgthread', mcfgthread_include = [ 'mcfgthread/fwd.h', 'mcfgthread/atomic.h', 'mcfgthread/clock.h', 'mcfgthread/mutex.h', 'mcfgthread/shared_mutex.h', 'mcfgthread/cond.h', - 'mcfgthread/once.h', 'mcfgthread/sem.h', 'mcfgthread/event.h', - 'mcfgthread/thread.h', 'mcfgthread/cxa.h', 'mcfgthread/dtor_queue.h', - 'mcfgthread/exit.h', 'mcfgthread/tls.h', 'mcfgthread/gthr_aux.h', - 'mcfgthread/gthr.h', 'mcfgthread/gthr_libobjc.h', 'mcfgthread/c11.h', - 'mcfgthread/libcxx.h', 'mcfgthread/cxx11.hpp' ] + 'mcfgthread/once.h', 'mcfgthread/sem.h', 'mcfgthread/event.h', 'mcfgthread/thread.h', + 'mcfgthread/cxa.h', 'mcfgthread/dtor_queue.h', 'mcfgthread/exit.h', + 'mcfgthread/tls.h', 'mcfgthread/gthr_aux.h', 'mcfgthread/gthr.h', + 'mcfgthread/gthr_libobjc.h', 'mcfgthread/c11.h', 'mcfgthread/libcxx.h', + 'mcfgthread/cxx11.hpp' ] mcfgthread_src_min = [ - 'mcfgthread/memcpy.c', 'mcfgthread/memmove.c', 'mcfgthread/memcmp.c', - 'mcfgthread/memset.c', 'mcfgthread/xglobals.c', 'mcfgthread/fwd.c', - 'mcfgthread/atomic.c', 'mcfgthread/clock.c', 'mcfgthread/mutex.c', - 'mcfgthread/shared_mutex.c', 'mcfgthread/cond.c', 'mcfgthread/once.c', - 'mcfgthread/sem.c', 'mcfgthread/event.c', 'mcfgthread/thread.c', - 'mcfgthread/cxa.c', 'mcfgthread/dtor_queue.c', 'mcfgthread/exit.c', - 'mcfgthread/tls.c', 'mcfgthread/gthr_aux.c' ] + 'mcfgthread/xglobals.c', 'mcfgthread/fwd.c', 'mcfgthread/atomic.c', + 'mcfgthread/clock.c', 'mcfgthread/mutex.c', 'mcfgthread/shared_mutex.c', + 'mcfgthread/cond.c', 'mcfgthread/once.c', 'mcfgthread/sem.c', 'mcfgthread/event.c', + 'mcfgthread/thread.c', 'mcfgthread/cxa.c', 'mcfgthread/dtor_queue.c', + 'mcfgthread/exit.c', 'mcfgthread/tls.c', 'mcfgthread/gthr_aux.c' ] mcfgthread_src_ex = [ 'mcfgthread/gthr.c', 'mcfgthread/gthr_libobjc.c', 'mcfgthread/c11.c',