zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

pthread_compat.h (5202B) - Raw


      1 /*
      2    Copyright (c) 2011-2016  mingw-w64 project
      3 
      4    Permission is hereby granted, free of charge, to any person obtaining a
      5    copy of this software and associated documentation files (the "Software"),
      6    to deal in the Software without restriction, including without limitation
      7    the rights to use, copy, modify, merge, publish, distribute, sublicense,
      8    and/or sell copies of the Software, and to permit persons to whom the
      9    Software is furnished to do so, subject to the following conditions:
     10 
     11    The above copyright notice and this permission notice shall be included in
     12    all copies or substantial portions of the Software.
     13 
     14    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     15    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     16    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     17    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     18    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     19    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
     20    DEALINGS IN THE SOFTWARE.
     21 */
     22 
     23 /*
     24  * Parts of this library are derived by:
     25  *
     26  * Posix Threads library for Microsoft Windows
     27  *
     28  * Use at own risk, there is no implied warranty to this code.
     29  * It uses undocumented features of Microsoft Windows that can change
     30  * at any time in the future.
     31  *
     32  * (C) 2010 Lockless Inc.
     33  * All rights reserved.
     34  *
     35  * Redistribution and use in source and binary forms, with or without modification,
     36  * are permitted provided that the following conditions are met:
     37  *
     38  *
     39  *  * Redistributions of source code must retain the above copyright notice,
     40  *    this list of conditions and the following disclaimer.
     41  *  * Redistributions in binary form must reproduce the above copyright notice,
     42  *    this list of conditions and the following disclaimer in the documentation
     43  *    and/or other materials provided with the distribution.
     44  *  * Neither the name of Lockless Inc. nor the names of its contributors may be
     45  *    used to endorse or promote products derived from this software without
     46  *    specific prior written permission.
     47  *
     48  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AN
     49  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     50  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     51  * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     52  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     53  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     54  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
     55  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     56  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     57  * OF THE POSSIBILITY OF SUCH DAMAGE.
     58  */
     59 
     60 #ifndef WIN_PTHREADS_PTHREAD_COMPAT_H
     61 #define WIN_PTHREADS_PTHREAD_COMPAT_H
     62 
     63 #if defined(_USE_32BIT_TIME_T) || (defined(_TIME_BITS) && _TIME_BITS == 32)
     64 #define WINPTHREADS_TIME_BITS 32
     65 #else
     66 #define WINPTHREADS_TIME_BITS 64
     67 #endif
     68 
     69 #if defined(IN_WINPTHREAD)
     70 #  if defined(DLL_EXPORT)
     71 #    define WINPTHREAD_API  __declspec(dllexport)  /* building the DLL  */
     72 #  else
     73 #    define WINPTHREAD_API  /* building the static library  */
     74 #  endif
     75 #else
     76 #  if defined(WINPTHREADS_USE_DLLIMPORT)
     77 #    define WINPTHREAD_API  __declspec(dllimport)  /* user wants explicit `dllimport`  */
     78 #  else
     79 #    define WINPTHREAD_API  /* the default; auto imported in case of DLL  */
     80 #  endif
     81 #endif
     82 
     83 #ifndef __clockid_t_defined
     84 typedef int clockid_t;
     85 #define __clockid_t_defined 1
     86 #endif  /* __clockid_t_defined */
     87 
     88 #ifndef _MODE_T_
     89 #define	_MODE_T_
     90 typedef unsigned short mode_t;
     91 #endif
     92 
     93 /* Error-codes.  */
     94 #ifndef ETIMEDOUT
     95 #define ETIMEDOUT	138
     96 #endif
     97 #ifndef ENOTSUP
     98 #define ENOTSUP		129
     99 #endif
    100 #ifndef EWOULDBLOCK
    101 #define EWOULDBLOCK	140
    102 #endif
    103 
    104 #ifdef __GNUC__
    105 
    106 #define WINPTHREADS_INLINE __inline__
    107 #define WINPTHREADS_ALWAYS_INLINE __inline__ __attribute__((__always_inline__))
    108 #define WINPTHREADS_ATTRIBUTE(X) __attribute__(X)
    109 #define WINPTHREADS_SECTION(X) __section__(X)
    110 
    111 #elif _MSC_VER
    112 
    113 #ifdef _WIN64
    114 typedef __int64 pid_t;
    115 #else
    116 typedef int     pid_t;
    117 #endif
    118 
    119 #define WINPTHREADS_INLINE __inline
    120 #define WINPTHREADS_ALWAYS_INLINE __inline __forceinline
    121 #define WINPTHREADS_ATTRIBUTE(X) __declspec X
    122 #define WINPTHREADS_SECTION(X) allocate(X)
    123 
    124 #endif
    125 
    126 #ifndef WINPTHREAD_CLOCK_DECL
    127 #define WINPTHREAD_CLOCK_DECL static WINPTHREADS_ALWAYS_INLINE
    128 #endif
    129 #ifndef WINPTHREAD_COND_DECL
    130 #define WINPTHREAD_COND_DECL static WINPTHREADS_ALWAYS_INLINE
    131 #endif
    132 #ifndef WINPTHREAD_MUTEX_DECL
    133 #define WINPTHREAD_MUTEX_DECL static WINPTHREADS_ALWAYS_INLINE
    134 #endif
    135 #ifndef WINPTHREAD_NANOSLEEP_DECL
    136 #define WINPTHREAD_NANOSLEEP_DECL static WINPTHREADS_ALWAYS_INLINE
    137 #endif
    138 #ifndef WINPTHREAD_RWLOCK_DECL
    139 #define WINPTHREAD_RWLOCK_DECL static WINPTHREADS_ALWAYS_INLINE
    140 #endif
    141 #ifndef WINPTHREAD_SEM_DECL
    142 #define WINPTHREAD_SEM_DECL static WINPTHREADS_ALWAYS_INLINE
    143 #endif
    144 #ifndef WINPTHREAD_THREAD_DECL
    145 #define WINPTHREAD_THREAD_DECL static WINPTHREADS_ALWAYS_INLINE
    146 #endif
    147 
    148 #endif