Skip to content

Commit

Permalink
build,fwd: Fix building issues on MSYS2
Browse files Browse the repository at this point in the history
  • Loading branch information
lhmouse committed Nov 1, 2024
1 parent ed8bd1b commit cc73a97
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
21 changes: 20 additions & 1 deletion mcfgthread/fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,26 @@ __MCF_CXX(extern "C" {)
#define __MCF_0_INIT { __MCF_C(0) }
#define __MCF_SET_IF(x, ...) ((void) ((x) && (*(x) = (__VA_ARGS__))))

/* These are necessary when the header is compiled as C89 or C++98. */
/* These are necessary when the header is compiled as C89 or C++98. The check
* for `_LP64` is for Cygwin and MSYS2. */
#ifdef _LP64
# define __MCF_INT64 long
# define __MCF_INTPTR long
#else
# define __MCF_INT64 long long
# define __MCF_INTPTR __MCF_64_32(long long, int)
#endif

#if !defined LLONG_MAX
typedef __MCF_INT64 int64_t;
typedef __MCF_INTPTR intptr_t;
typedef unsigned __MCF_INT64 uint64_t;
typedef unsigned __MCF_INTPTR uintptr_t;
# define LLONG_MAX 0x7FFFFFFFFFFFFFFFL
# define LLONG_MIN (-0x7FFFFFFFFFFFFFFFL-1)
# define ULLONG_MAX 0xFFFFFFFFFFFFFFFFUL
#endif

#define __MCF_PTR_BITS __MCF_64_32(64, 32)
#define __MCF_IPTR_MIN __MCF_64_32(LLONG_MIN, INT_MIN)
#define __MCF_IPTR_0 __MCF_64_32(0LL, 0)
Expand Down
17 changes: 11 additions & 6 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,17 @@ lib_mcfgthread_dll = shared_library('mcfgthread',
version: '.'.join([ ver.get('abi_major'), ver.get('abi_minor'), '0' ]),
install: true)

lib_mcfgthread_a = static_library('mcfgthread',
c_pch: 'mcfgthread/xprecompiled.h',
c_args: [ '-ffreestanding', '-fasynchronous-unwind-tables' ],
sources: [ mcfgthread_src_min, mcfgthread_src_ex, ],
dependencies: [ dep_kernel32, dep_ntdll ],
install: true)
if host_machine.system() == 'cygwin'
warning('Static linking is not supported on Cygwin or MSYS2.')
lib_mcfgthread_a = lib_mcfgthread_dll
else
lib_mcfgthread_a = static_library('mcfgthread',
c_pch: 'mcfgthread/xprecompiled.h',
c_args: [ '-ffreestanding', '-fasynchronous-unwind-tables' ],
sources: [ mcfgthread_src_min, mcfgthread_src_ex, ],
dependencies: [ dep_kernel32, dep_ntdll ],
install: true)
endif

import('pkgconfig').generate(lib_mcfgthread_dll,
name: 'mcfgthread',
Expand Down
2 changes: 1 addition & 1 deletion setup_meson.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -e

if ! grep -Eoi '^mingw' /proc/version &>/dev/null
if ! grep -Eoi '^(mingw|msys|cygwin)' /proc/version &>/dev/null
then
_cross_file='--cross-file meson.cross.x86_64-w64-mingw32'
fi
Expand Down
2 changes: 2 additions & 0 deletions test/self_oom.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define NTHREADS 64U
static HANDLE threads[NTHREADS];

#if !defined __CYGWIN__
static
DWORD
__stdcall
Expand All @@ -25,6 +26,7 @@ thread_proc(void* arg)
fprintf(stderr, "thread %d quitting\n", _MCF_thread_self_tid());
return 0;
}
#endif

int
main(void)
Expand Down

0 comments on commit cc73a97

Please sign in to comment.