Skip to content

Commit

Permalink
Applied Keith Marshall mingw32 patches
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Johnson committed Mar 30, 2016
1 parent 4a88b67 commit 4fdbeb6
Show file tree
Hide file tree
Showing 18 changed files with 2,931 additions and 2,614 deletions.
1,648 changes: 824 additions & 824 deletions README.NONPORTABLE

Large diffs are not rendered by default.

107 changes: 107 additions & 0 deletions _ptw32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
* Module: _ptw32.h
*
* Purpose:
* Pthreads-win32 internal macros, to be shared by other headers
* comprising the pthreads-win32 package.
*
* --------------------------------------------------------------------------
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
* Copyright(C) 1999-2012, 2016, Pthreads-win32 contributors
*
* Homepage1: http://sourceware.org/pthreads-win32/
* Homepage2: http://sourceforge.net/projects/pthreads4w/
*
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* 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.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
*/
#ifndef __PTW32_H
#define __PTW32_H

#if defined __GNUC__
# pragma GCC system_header
# if ! defined __declspec
# error "Please upgrade your GNU compiler to one that supports __declspec."
# endif
#endif

#if defined (__cplusplus)
# define __PTW32_BEGIN_C_DECLS extern "C" {
# define __PTW32_END_C_DECLS }
#else
# define __PTW32_BEGIN_C_DECLS
# define __PTW32_END_C_DECLS
#endif

#if defined (PTW32_STATIC_LIB) && _MSC_VER >= 1400
# undef PTW32_STATIC_LIB
# define PTW32_STATIC_TLSLIB
#endif

/* When building the library, you should define PTW32_BUILD so that
* the variables/functions are exported correctly. When using the library,
* do NOT define PTW32_BUILD, and then the variables/functions will
* be imported correctly.
*
* FIXME: Used defined feature test macros, such as PTW32_STATIC_LIB, (and
* maybe even PTW32_BUILD), should be renamed with one initial underscore;
* internally defined macros, such as PTW32_DLLPORT, should be renamed with
* two initial underscores ... perhaps __PTW32_DECLSPEC is nicer anyway?
*/
#if defined PTW32_STATIC_LIB || defined PTW32_STATIC_TLSLIB
# define PTW32_DLLPORT

#elif defined PTW32_BUILD
# define PTW32_DLLPORT __declspec (dllexport)
#else
# define PTW32_DLLPORT /*__declspec (dllimport)*/
#endif

#ifndef PTW32_CDECL
/* FIXME: another internal macro; should have two initial underscores;
* Nominally, we prefer to use __cdecl calling convention for all our
* functions, but we map it through this macro alias to facilitate the
* possible choice of alternatives; for example:
*/
# ifdef _OPEN_WATCOM_SOURCE
/* The Open Watcom C/C++ compiler uses a non-standard default calling
* convention, (similar to __fastcall), which passes function arguments
* in registers, unless the __cdecl convention is explicitly specified
* in exposed function prototypes.
*
* Our preference is to specify the __cdecl convention for all calls,
* even though this could slow Watcom code down slightly. If you know
* that the Watcom compiler will be used to build both the DLL and your
* application, then you may #define _OPEN_WATCOM_SOURCE, so disabling
* the forced specification of __cdecl for all function declarations;
* remember that this must be defined consistently, for both the DLL
* build, and the application build.
*/
# define PTW32_CDECL
# else
# define PTW32_CDECL __cdecl
# endif
#endif

#endif /* !__PTW32_H */
119 changes: 119 additions & 0 deletions aclocal.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
## aclocal.m4
## --------------------------------------------------------------------------
##
## Pthreads-win32 - POSIX Threads Library for Win32
## Copyright(C) 1998 John E. Bossom
## Copyright(C) 1999-2012, 2016, Pthreads-win32 contributors
##
## The current list of contributors is contained
## in the file CONTRIBUTORS included with the source
## 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.,
## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
##
#
# PTW32_AC_CHECK_TYPEDEF( TYPENAME, [HEADER] )
# --------------------------------------------
# Set HAVE_TYPENAME in config.h, if either HEADER, or any default
# header which autoconf checks automatically, defines TYPENAME.
#
AC_DEFUN([PTW32_AC_CHECK_TYPEDEF],dnl
[m4_ifnblank([$2],[AC_CHECK_HEADERS_ONCE([$2])])
AC_CHECK_TYPE([$1],dnl
[AC_DEFINE(AS_TR_CPP([HAVE_$1]),[1],[Define if your compiler knows about $1])],,dnl
[AC_INCLUDES_DEFAULT
m4_ifnblank([$2],[[
#ifdef ]AS_TR_CPP([HAVE_$2])[
# include <$2>
#endif
]])])dnl
])

# PTW32_AC_NEED_FUNC( WITNESS, FUNCNAME )
# ---------------------------------------
# Add a WITNESS definition in config.h, if FUNCNAME is not provided
# by the standard library, and a replacement must be provided.
#
AC_DEFUN([PTW32_AC_NEED_FUNC],dnl
[AC_CHECK_FUNCS([$2],,[AC_DEFINE([$1],[1],[Define if you do not have $2])])dnl
])

# PTW32_AC_NEED_ERRNO
# -------------------
# Check if the host provides the <errno.h> header, and supports the
# errno global symbol, otherwise, add a NEED_ERRNO request in config.h
#
AC_DEFUN([PTW32_AC_NEED_ERRNO],[dnl
AC_CHECK_HEADERS_ONCE([errno.h])
AC_MSG_CHECKING([for errno])
AC_LINK_IFELSE([AC_LANG_SOURCE([[
#ifdef HAVE_ERRNO_H
# include <errno.h>
#endif
int main(){ return errno; }
]])],dnl
[AC_MSG_RESULT([yes])],dnl
[AC_DEFINE([NEED_ERRNO],[1],[Define if you do not have errno])
AC_MSG_RESULT([no])dnl
])
])

# PTW32_AC_CHECK_WINAPI_FUNC( FUNCNAME, ARGUMENTS, ... )
# ------------------------------------------------------
# Check if the WinAPI function FUNCNAME is available on the host;
# unlike __cdecl functions, which can be detected by AC_CHECK_FUNCS,
# WinAPI functions need a full argument list specification in the
# function call. (Additional 3rd and 4th arguments provide for
# qualification of the yes/no messages, respectively; they may
# be exploited, for example, to add config.h annotations).
#
AC_DEFUN([PTW32_AC_CHECK_WINAPI_FUNC],
[AC_MSG_CHECKING([for $1])
AC_LINK_IFELSE([AC_LANG_SOURCE([[
#include <windows.h>
int APIENTRY WinMain(HINSTANCE curr, HINSTANCE prev, LPSTR argv, int mode)
{ (void)($1($2)); return 0; }
]])],dnl
[AC_MSG_RESULT([yes])$3],
[AC_MSG_RESULT([no])$4
])
])

# PTW32_AC_NEED_WINAPI_FUNC( FUNCNAME, ARGUMENTS )
# ------------------------------------------------
# Check if WinAPI function FUNCNAME is available on the host; add a
# NEED_FUNCNAME annotation in config.h, if it is not.
#
AC_DEFUN([PTW32_AC_NEED_WINAPI_FUNC],
[PTW32_AC_CHECK_WINAPI_FUNC([$1],[$2],,dnl
[AC_DEFINE(AS_TR_CPP([NEED_$1]),[1],[Define if $1 is unsupported])dnl
])
])

# PTW32_AC_CHECK_CPU_AFFINITY
# ---------------------------
# Check if the host supports the GetProcessAffinityMask() WinAPI
# function; (all Windows versions since Win95 should, but WinCE may
# not). Add the HAVE_CPU_AFFINITY annotation in config.h, for hosts
# which do have this support.
#
AC_DEFUN([PTW32_AC_CHECK_CPU_AFFINITY],
[PTW32_AC_CHECK_WINAPI_FUNC([GetProcessAffinityMask],[NULL,NULL,NULL],dnl
[AC_DEFINE([HAVE_CPU_AFFINITY],[1],[Define if CPU_AFFINITY is supported])dnl
])
])
1 change: 0 additions & 1 deletion common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ STATIC_OBJS = \
sem_trywait.$(OBJEXT) \
sem_unlink.$(OBJEXT) \
sem_wait.$(OBJEXT) \
signal.$(OBJEXT) \
w32_CancelableWait.$(OBJEXT)

PTHREAD_SRCS = \
Expand Down
86 changes: 86 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# configure.ac
# --------------------------------------------------------------------------
#
# Pthreads-win32 - POSIX Threads Library for Win32
# Copyright(C) 1998 John E. Bossom
# Copyright(C) 1999-2012, 2016, Pthreads-win32 contributors
#
# The current list of contributors is contained
# in the file CONTRIBUTORS included with the source
# 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.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
AC_INIT([pthreads-win32],[git])
AC_CONFIG_HEADERS([config.h])

# Checks for build tools.
#
AC_PROG_CC
AC_PROG_CXX
AC_CHECK_TOOLS([AR],[ar],[ar])
AC_CHECK_TOOLS([DLLTOOL],[dlltool],[dlltool])
AC_CHECK_TOOLS([OBJDUMP],[objdump],[objdump])
AC_CHECK_TOOLS([RC],[windres],[windres])
AC_PROG_RANLIB

# Autoconf doesn't normally guard config.h, but we prefer it so;
# this is also a convenient place to force HAVE_C_INLINE, because
# AC_C_INLINE makes it available, even if the build compiler does
# not normally support it.
#
AH_TOP(dnl
[#ifndef PTW32_CONFIG_H]
[#define PTW32_CONFIG_H]dnl
)
# FIXME: AC_C_INLINE defines 'inline' to work with any C compiler,
# whether or not it supports inline code expansion, but it does NOT
# define HAVE_C_INLINE; can we use this standard autoconf feature,
# without also needing to define HAVE_C_INLINE?
#
AC_C_INLINE
AH_BOTTOM([#define HAVE_C_INLINE])
AH_BOTTOM([#endif])

# Checks for data types and structures.
#
PTW32_AC_CHECK_TYPEDEF([mode_t])
PTW32_AC_CHECK_TYPEDEF([sigset_t],[signal.h])
PTW32_AC_CHECK_TYPEDEF([struct timespec],[time.h])

# Checks for __cdecl functions.
#
PTW32_AC_NEED_ERRNO
PTW32_AC_NEED_FUNC([NEED_CALLOC],[calloc])
PTW32_AC_NEED_FUNC([NEED_FTIME],[ftime])
PTW32_AC_NEED_FUNC([NEED_CREATETHREAD],[_beginthreadex])
PTW32_AC_CHECK_CPU_AFFINITY

# WinAPI functions need a full argument list for detection.
#
PTW32_AC_NEED_WINAPI_FUNC([DuplicateHandle],[NULL,NULL,NULL,NULL,0,0,0])

# Checks for installation tools.
#
AC_PROG_MKDIR_P
AC_PROG_INSTALL

# Build system generation, as configured.
#
AC_CONFIG_FILES([GNUmakefile tests/GNUmakefile])
AC_OUTPUT
Loading

0 comments on commit 4fdbeb6

Please sign in to comment.