diff --git a/_ptw32.h b/_ptw32.h index 34ed4131..3e7ba36b 100644 --- a/_ptw32.h +++ b/_ptw32.h @@ -19,17 +19,17 @@ * code distribution. The list can also be seen at the * following World Wide Web location: * http://sources.redhat.com/pthreads-win32/contributors.html - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. - * + * * This 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 * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library in the file COPYING.LIB; * if not, write to the Free Software Foundation, Inc., @@ -51,7 +51,7 @@ #define PTW32_VERSION 3,0,3,1 #define PTW32_VERSION_STRING "3, 0, 3, 1\0" -// skip the rest when running this through the Microsoft Resource Compiler, which is a VERY brittle piece of machinery! -> RC2188 & RC1116 cryptic failures will be your part! +// skip the rest when running this through the Microsoft Resource Compiler, which is a VERY brittle piece of machinery! -> RC2188 & RC1116 cryptic failures will be your part! #ifndef RC_INVOKED #if defined(__GNUC__) @@ -160,8 +160,13 @@ # define int64_t LONGLONG # define uint64_t ULONGLONG #elif !defined(__MINGW32__) - typedef _int64 int64_t; - typedef unsigned _int64 uint64_t; +#if defined(__TINYC__) +typedef long long int64_t; +typedef unsigned long long uint64_t; +#else +typedef _int64 int64_t; +typedef unsigned _int64 uint64_t; +#endif # if defined (PTW32_CONFIG_MSVC6) typedef long intptr_t; # endif diff --git a/build_dll.tcc b/build_dll.tcc new file mode 100644 index 00000000..ee174ef0 --- /dev/null +++ b/build_dll.tcc @@ -0,0 +1 @@ +-shared -w -Ox -fPIC -fno-omit-frame-pointer -Wno-unused-function -Wno-unused-variable -DHAVE_CONFIG_H -D_REENTRANT -isystem "\Program Files\tcc\include\winapi" -v -bench pthread-JMP.c diff --git a/build_obj.tcc b/build_obj.tcc new file mode 100644 index 00000000..1f8b2792 --- /dev/null +++ b/build_obj.tcc @@ -0,0 +1 @@ +-static -w -Ox -fPIC -fno-omit-frame-pointer -Wno-unused-function -Wno-unused-variable -DHAVE_CONFIG_H -D_REENTRANT -isystem "\Program Files\tcc\include\winapi" -v -bench -c pthread-JMP.c diff --git a/config.h b/config.h index 4c6d0985..3267b68b 100644 --- a/config.h +++ b/config.h @@ -7,7 +7,7 @@ * Defaults: see target specific redefinitions below. *********************************************************************/ -/* We're building the pthreads-win32 library */ + /* We're building the pthreads-win32 library */ #define PTW32_BUILD /* CPU affinity */ @@ -54,7 +54,7 @@ */ #undef HAVE_GCC_ATOMIC_BUILTINS -/* Define if you have the timespec struct */ + /* Define if you have the timespec struct */ #undef HAVE_STRUCT_TIMESPEC /* Define if you don't have the GetProcessAffinityMask() */ @@ -66,48 +66,48 @@ */ #undef RETAIN_WSALASTERROR -/* -# ---------------------------------------------------------------------- -# The library can be built with some alternative behaviour to better -# facilitate development of applications on Win32 that will be ported -# to other POSIX systems. -# -# Nothing described here will make the library non-compliant and strictly -# compliant applications will not be affected in any way, but -# applications that make assumptions that POSIX does not guarantee are -# not strictly compliant and may fail or misbehave with some settings. -# -# PTW32_THREAD_ID_REUSE_INCREMENT -# Purpose: -# POSIX says that applications should assume that thread IDs can be -# recycled. However, Solaris (and some other systems) use a [very large] -# sequence number as the thread ID, which provides virtual uniqueness. -# This provides a very high but finite level of safety for applications -# that are not meticulous in tracking thread lifecycles e.g. applications -# that call functions which target detached threads without some form of -# thread exit synchronisation. -# -# Usage: -# Set to any value in the range: 0 <= value < 2^wordsize. -# Set to 0 to emulate reusable thread ID behaviour like Linux or *BSD. -# Set to 1 for unique thread IDs like Solaris (this is the default). -# Set to some factor of 2^wordsize to emulate smaller word size types -# (i.e. will wrap sooner). This might be useful to emulate some embedded -# systems. -# -# define PTW32_THREAD_ID_REUSE_INCREMENT 0 -# -# ---------------------------------------------------------------------- - */ + /* + # ---------------------------------------------------------------------- + # The library can be built with some alternative behaviour to better + # facilitate development of applications on Win32 that will be ported + # to other POSIX systems. + # + # Nothing described here will make the library non-compliant and strictly + # compliant applications will not be affected in any way, but + # applications that make assumptions that POSIX does not guarantee are + # not strictly compliant and may fail or misbehave with some settings. + # + # PTW32_THREAD_ID_REUSE_INCREMENT + # Purpose: + # POSIX says that applications should assume that thread IDs can be + # recycled. However, Solaris (and some other systems) use a [very large] + # sequence number as the thread ID, which provides virtual uniqueness. + # This provides a very high but finite level of safety for applications + # that are not meticulous in tracking thread lifecycles e.g. applications + # that call functions which target detached threads without some form of + # thread exit synchronisation. + # + # Usage: + # Set to any value in the range: 0 <= value < 2^wordsize. + # Set to 0 to emulate reusable thread ID behaviour like Linux or *BSD. + # Set to 1 for unique thread IDs like Solaris (this is the default). + # Set to some factor of 2^wordsize to emulate smaller word size types + # (i.e. will wrap sooner). This might be useful to emulate some embedded + # systems. + # + # define PTW32_THREAD_ID_REUSE_INCREMENT 0 + # + # ---------------------------------------------------------------------- + */ #undef PTW32_THREAD_ID_REUSE_INCREMENT -/********************************************************************* - * Target specific groups - * - * If you find that these are incorrect or incomplete please report it - * to the pthreads-win32 maintainer. Thanks. - *********************************************************************/ + /********************************************************************* + * Target specific groups + * + * If you find that these are incorrect or incomplete please report it + * to the pthreads-win32 maintainer. Thanks. + *********************************************************************/ #if defined(WINCE) # undef HAVE_CPU_AFFINITY # define NEED_DUPLICATEHANDLE @@ -115,7 +115,7 @@ # define NEED_ERRNO # define NEED_CALLOC # define NEED_FTIME -/* # define NEED_SEM */ + /* # define NEED_SEM */ # define NEED_UNICODE_CONSTS # define NEED_PROCESS_AFFINITY_MASK /* This may not be needed */ @@ -154,5 +154,169 @@ #if defined(_MSC_VER) && _MSC_VER >= 1900 #define HAVE_STRUCT_TIMESPEC #endif +#define __PTW32_CONFIG_MSVC7 +#endif /* __PTW32_CONFIG_H */ + +#if defined(__TINYC__) +#define NO_OLDNAMES 1 + +#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE +#ifdef LIBFFI_ASM +#ifdef __APPLE__ +#define FFI_HIDDEN(name) .private_extern name +#else +#define FFI_HIDDEN(name) .hidden name +#endif +#else +#define FFI_HIDDEN __attribute__ ((visibility ("hidden"))) +#endif +#else +#ifdef LIBFFI_ASM +#define FFI_HIDDEN(name) +#else +#define FFI_HIDDEN +#undef FFI_BAD_ABI +#endif +#endif + +#ifndef FFI_WIN64 +#define FFI_WIN64 1 +#endif +#ifndef __ILP32__ +#define __ILP32__ +#endif +#ifndef FFI_UNIX64 +#define FFI_UNIX64 +#endif + +typedef long long int64_t; +typedef unsigned long long uint64_t; +#if defined(__TINYC__) && (defined(WIN64) || defined(_WIN64)) +#include +#endif + +#ifdef __TINY_LIBC +#undef NO_OLDNAMES + +#define USE_POSIX_THREADS_WEAK 1 + +#ifndef EOVERFLOW +#define EOVERFLOW 132 +#endif +#include + +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 + +#define ssize_t ptrdiff_t + +#define _GL_INLINE_HEADER_BEGIN +#define _GL_INLINE_HEADER_END +#define _GL_EXTERN_INLINE inline +#define _GL_ATTRIBUTE_PURE +#define _GL_ATTRIBUTE_CONST +#define _GL_UNUSED +#define _GL_ATTRIBUTE_NODISCARD +#define _GL_ATTRIBUTE_MAYBE_UNUSED +#define HAVE_LONG_LONG_INT 1 +# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ +#define HAVE_DECL_STRERROR_R 1 +#define HAVE_DECL___ARGV 1 +#define _GL_ARG_NONNULL(a) +#define _GL_ATTRIBUTE_FORMAT_PRINTF(a, b) +#define _GL_ATTRIBUTE_DEPRECATED +#define _GL_ATTRIBUTE_FALLTHROUGH +#define GNULIB_XALLOC 1 +#define _GL_ATTRIBUTE_MALLOC +#define _GL_ATTRIBUTE_ALLOC_SIZE(a) +#define _GL_ATTRIBUTE_DEALLOC_FREE +#define _GL_ATTRIBUTE_DEALLOC(f, i) +#define _GL_ATTRIBUTE_RETURNS_NONNULL +#define _GL_ATTRIBUTE_COLD +#define _GL_ASYNC_SAFE +#define GNULIB_XALLOC_DIE 1 +#define _GL_HAVE__STATIC_ASSERT 1 +#define _Static_assert(a, b) +#define __PGI + +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +#define MIN min +#define _GL_CMP(a, b) (a) == (b) + +#define __getopt_argv_const + +#ifndef _GL_INLINE +#define _GL_INLINE inline +#endif + +/* should be set by including "filename.h" +#ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE +#define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1 +#endif */ + + +#define __NO_ISOCEXT +#define __MINGW_ATTRIB_DEPRECATED_SEC_WARN + +#define RENAME_OPEN_FILE_WORKS 1 + +#define _SH_COMPAT 0x00 +#define _SH_DENYRW 0x10 +#define _SH_DENYWR 0x20 +#define _SH_DENYRD 0x30 +#define _SH_DENYNO 0x40 +#define _SH_SECURE 0x80 + +extern char *_stpcpy(char *yydest, const char *yysrc); +extern int obstack_printf(struct obstack *obs, const char *format, ...); +extern char *_stpcpy(char *yydest, const char *yysrc); +extern int strverscmp(const char *s1, const char *s2); + +#define ssize_t ptrdiff_t +#include +#define fopen(n,m) _fsopen(n,m,_SH_DENYNO) +#define snprintf _snprintf +#define fseeko _fseeki64 + +size_t __cdecl strnlen(const char *_Str, size_t _MaxCount); +int timespec_get(struct timespec *__ts, int __base); +int getdtablesize(void); +int fcntl(int fd, int action, /* arg */...); +int integer_length(unsigned int x); +int ffs(int i); -#endif /* PTW32_CONFIG_H */ +#ifndef F_DUPFD +# define F_DUPFD 1 +#endif + +#ifndef F_GETFD +# define F_GETFD 2 +#endif + +#ifndef O_CLOEXEC +# define O_CLOEXEC 0x40000000 /* Try to not collide with system O_* flags. */ +#endif + +#ifndef F_DUPFD_CLOEXEC +# define F_DUPFD_CLOEXEC 0x40000000 +/* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */ +#endif + +#ifndef FD_CLOEXEC +# define FD_CLOEXEC 1 +#endif + +# if !GNULIB_defined_TIME_UTC +# define TIME_UTC 1 +# define GNULIB_defined_TIME_UTC 1 +# endif +#endif /* __TINY_LIBC */ + +#endif diff --git a/pthread_kill.c b/pthread_kill.c index fd713d24..c6a55d56 100644 --- a/pthread_kill.c +++ b/pthread_kill.c @@ -18,17 +18,17 @@ * code distribution. The list can also be seen at the * following World Wide Web location: * http://sources.redhat.com/pthreads-win32/contributors.html - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. - * + * * This 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 * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library in the file COPYING.LIB; * if not, write to the Free Software Foundation, Inc., @@ -111,20 +111,23 @@ pthread_kill (pthread_t thread, int sig) break; #ifdef SIGINT case SIGINT: -#endif +#endif #ifdef SIGTERM case SIGTERM: -#endif +#endif #ifdef SIGBREAK case SIGBREAK: -#endif +#endif #ifdef SIGABRT case SIGABRT: #endif + +#ifndef __TINYC__ #ifdef SIGABRT_COMPAT case SIGABRT_COMPAT: #endif - { +#endif + { ptw32_mcs_local_node_t stateLock; /* diff --git a/pthread_win32_attach_detach_np.c b/pthread_win32_attach_detach_np.c index d6d5023f..22624ee4 100644 --- a/pthread_win32_attach_detach_np.c +++ b/pthread_win32_attach_detach_np.c @@ -18,17 +18,17 @@ * code distribution. The list can also be seen at the * following World Wide Web location: * http://sources.redhat.com/pthreads-win32/contributors.html - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. - * + * * This 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 * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library in the file COPYING.LIB; * if not, write to the Free Software Foundation, Inc., @@ -86,7 +86,7 @@ pthread_win32_process_attach_np () #if !defined(WINCE) gsd_res = GetSystemDirectory(QuserExDLLPathBuf, QuserExDLLPathBufSize); -#if defined(__GNUC__) || defined(PTW32_CONFIG_MSVC7) +#if defined(__GNUC__) || defined(PTW32_CONFIG_MSVC7) || defined(__TINYC__) if(gsd_res && gsd_res < QuserExDLLPathBufSize) { (void) strncat(QuserExDLLPathBuf,