diff --git a/deps/blake2/CMakeLists.txt b/deps/blake2/CMakeLists.txt deleted file mode 100644 index 43092d7..0000000 --- a/deps/blake2/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 3.2) - -project(blake2) - -set(BLAKE2_INCLUDE_DIR - "${CMAKE_CURRENT_SOURCE_DIR}/src" - CACHE PATH "blake2 include path") - -include_directories( - ${LIBblake2_INCLUDE_DIRS} - src -) - -if(WIN32) - if(MSVC) - add_compile_options("$<$:/MT>") - endif() - add_definitions( - -Dinline=_inline - -Drestrict=__restrict) -endif() - -set(blake2_SOURCES - src/blake2b-ref.c) - -set(blake2_HEADERS - src/blake2.h - src/blake2-impl.h) - -add_library(blake2 STATIC - ${blake2_SOURCES} - ${blake2_HEADERS}) diff --git a/deps/blake2/src/blake2-impl.h b/deps/blake2/src/blake2-impl.h deleted file mode 100644 index 5dff7fc..0000000 --- a/deps/blake2/src/blake2-impl.h +++ /dev/null @@ -1,160 +0,0 @@ -/* - BLAKE2 reference source code package - reference C implementations - - Copyright 2012, Samuel Neves . You may use this under the - terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at - your option. The terms of these licenses can be found at: - - - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - - OpenSSL license : https://www.openssl.org/source/license.html - - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - - More information about the BLAKE2 hash function can be found at - https://blake2.net. -*/ -#ifndef BLAKE2_IMPL_H -#define BLAKE2_IMPL_H - -#include -#include - -#if !defined(__cplusplus) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) - #if defined(_MSC_VER) - #define BLAKE2_INLINE __inline - #elif defined(__GNUC__) - #define BLAKE2_INLINE __inline__ - #else - #define BLAKE2_INLINE - #endif -#else - #define BLAKE2_INLINE inline -#endif - -static BLAKE2_INLINE uint32_t load32( const void *src ) -{ -#if defined(NATIVE_LITTLE_ENDIAN) - uint32_t w; - memcpy(&w, src, sizeof w); - return w; -#else - const uint8_t *p = ( const uint8_t * )src; - return (( uint32_t )( p[0] ) << 0) | - (( uint32_t )( p[1] ) << 8) | - (( uint32_t )( p[2] ) << 16) | - (( uint32_t )( p[3] ) << 24) ; -#endif -} - -static BLAKE2_INLINE uint64_t load64( const void *src ) -{ -#if defined(NATIVE_LITTLE_ENDIAN) - uint64_t w; - memcpy(&w, src, sizeof w); - return w; -#else - const uint8_t *p = ( const uint8_t * )src; - return (( uint64_t )( p[0] ) << 0) | - (( uint64_t )( p[1] ) << 8) | - (( uint64_t )( p[2] ) << 16) | - (( uint64_t )( p[3] ) << 24) | - (( uint64_t )( p[4] ) << 32) | - (( uint64_t )( p[5] ) << 40) | - (( uint64_t )( p[6] ) << 48) | - (( uint64_t )( p[7] ) << 56) ; -#endif -} - -static BLAKE2_INLINE uint16_t load16( const void *src ) -{ -#if defined(NATIVE_LITTLE_ENDIAN) - uint16_t w; - memcpy(&w, src, sizeof w); - return w; -#else - const uint8_t *p = ( const uint8_t * )src; - return (( uint16_t )( p[0] ) << 0) | - (( uint16_t )( p[1] ) << 8) ; -#endif -} - -static BLAKE2_INLINE void store16( void *dst, uint16_t w ) -{ -#if defined(NATIVE_LITTLE_ENDIAN) - memcpy(dst, &w, sizeof w); -#else - uint8_t *p = ( uint8_t * )dst; - *p++ = ( uint8_t )w; w >>= 8; - *p++ = ( uint8_t )w; -#endif -} - -static BLAKE2_INLINE void store32( void *dst, uint32_t w ) -{ -#if defined(NATIVE_LITTLE_ENDIAN) - memcpy(dst, &w, sizeof w); -#else - uint8_t *p = ( uint8_t * )dst; - p[0] = (uint8_t)(w >> 0); - p[1] = (uint8_t)(w >> 8); - p[2] = (uint8_t)(w >> 16); - p[3] = (uint8_t)(w >> 24); -#endif -} - -static BLAKE2_INLINE void store64( void *dst, uint64_t w ) -{ -#if defined(NATIVE_LITTLE_ENDIAN) - memcpy(dst, &w, sizeof w); -#else - uint8_t *p = ( uint8_t * )dst; - p[0] = (uint8_t)(w >> 0); - p[1] = (uint8_t)(w >> 8); - p[2] = (uint8_t)(w >> 16); - p[3] = (uint8_t)(w >> 24); - p[4] = (uint8_t)(w >> 32); - p[5] = (uint8_t)(w >> 40); - p[6] = (uint8_t)(w >> 48); - p[7] = (uint8_t)(w >> 56); -#endif -} - -static BLAKE2_INLINE uint64_t load48( const void *src ) -{ - const uint8_t *p = ( const uint8_t * )src; - return (( uint64_t )( p[0] ) << 0) | - (( uint64_t )( p[1] ) << 8) | - (( uint64_t )( p[2] ) << 16) | - (( uint64_t )( p[3] ) << 24) | - (( uint64_t )( p[4] ) << 32) | - (( uint64_t )( p[5] ) << 40) ; -} - -static BLAKE2_INLINE void store48( void *dst, uint64_t w ) -{ - uint8_t *p = ( uint8_t * )dst; - p[0] = (uint8_t)(w >> 0); - p[1] = (uint8_t)(w >> 8); - p[2] = (uint8_t)(w >> 16); - p[3] = (uint8_t)(w >> 24); - p[4] = (uint8_t)(w >> 32); - p[5] = (uint8_t)(w >> 40); -} - -static BLAKE2_INLINE uint32_t rotr32( const uint32_t w, const unsigned c ) -{ - return ( w >> c ) | ( w << ( 32 - c ) ); -} - -static BLAKE2_INLINE uint64_t rotr64( const uint64_t w, const unsigned c ) -{ - return ( w >> c ) | ( w << ( 64 - c ) ); -} - -/* prevents compiler optimizing out memset() */ -static BLAKE2_INLINE void secure_zero_memory(void *v, size_t n) -{ - static void *(*const volatile memset_v)(void *, int, size_t) = &memset; - memset_v(v, 0, n); -} - -#endif diff --git a/deps/blake2/src/blake2.h b/deps/blake2/src/blake2.h deleted file mode 100644 index ca39030..0000000 --- a/deps/blake2/src/blake2.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - BLAKE2 reference source code package - reference C implementations - - Copyright 2012, Samuel Neves . You may use this under the - terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at - your option. The terms of these licenses can be found at: - - - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - - OpenSSL license : https://www.openssl.org/source/license.html - - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - - More information about the BLAKE2 hash function can be found at - https://blake2.net. -*/ -#ifndef BLAKE2_H -#define BLAKE2_H - -#include -#include - -#if defined(_MSC_VER) -#define BLAKE2_PACKED(x) __pragma(pack(push, 1)) x __pragma(pack(pop)) -#else -#define BLAKE2_PACKED(x) x __attribute__((packed)) -#endif - -#if defined(__cplusplus) -extern "C" { -#endif - - enum blake2s_constant - { - BLAKE2S_BLOCKBYTES = 64, - BLAKE2S_OUTBYTES = 32, - BLAKE2S_KEYBYTES = 32, - BLAKE2S_SALTBYTES = 8, - BLAKE2S_PERSONALBYTES = 8 - }; - - enum blake2b_constant - { - BLAKE2B_BLOCKBYTES = 128, - BLAKE2B_OUTBYTES = 64, - BLAKE2B_KEYBYTES = 64, - BLAKE2B_SALTBYTES = 16, - BLAKE2B_PERSONALBYTES = 16 - }; - - typedef struct blake2s_state__ - { - uint32_t h[8]; - uint32_t t[2]; - uint32_t f[2]; - uint8_t buf[BLAKE2S_BLOCKBYTES]; - size_t buflen; - size_t outlen; - uint8_t last_node; - } blake2s_state; - - typedef struct blake2b_state__ - { - uint64_t h[8]; - uint64_t t[2]; - uint64_t f[2]; - uint8_t buf[BLAKE2B_BLOCKBYTES]; - size_t buflen; - size_t outlen; - uint8_t last_node; - } blake2b_state; - - typedef struct blake2sp_state__ - { - blake2s_state S[8][1]; - blake2s_state R[1]; - uint8_t buf[8 * BLAKE2S_BLOCKBYTES]; - size_t buflen; - size_t outlen; - } blake2sp_state; - - typedef struct blake2bp_state__ - { - blake2b_state S[4][1]; - blake2b_state R[1]; - uint8_t buf[4 * BLAKE2B_BLOCKBYTES]; - size_t buflen; - size_t outlen; - } blake2bp_state; - - - BLAKE2_PACKED(struct blake2s_param__ - { - uint8_t digest_length; /* 1 */ - uint8_t key_length; /* 2 */ - uint8_t fanout; /* 3 */ - uint8_t depth; /* 4 */ - uint32_t leaf_length; /* 8 */ - uint32_t node_offset; /* 12 */ - uint16_t xof_length; /* 14 */ - uint8_t node_depth; /* 15 */ - uint8_t inner_length; /* 16 */ - /* uint8_t reserved[0]; */ - uint8_t salt[BLAKE2S_SALTBYTES]; /* 24 */ - uint8_t personal[BLAKE2S_PERSONALBYTES]; /* 32 */ - }); - - typedef struct blake2s_param__ blake2s_param; - - BLAKE2_PACKED(struct blake2b_param__ - { - uint8_t digest_length; /* 1 */ - uint8_t key_length; /* 2 */ - uint8_t fanout; /* 3 */ - uint8_t depth; /* 4 */ - uint32_t leaf_length; /* 8 */ - uint32_t node_offset; /* 12 */ - uint32_t xof_length; /* 16 */ - uint8_t node_depth; /* 17 */ - uint8_t inner_length; /* 18 */ - uint8_t reserved[14]; /* 32 */ - uint8_t salt[BLAKE2B_SALTBYTES]; /* 48 */ - uint8_t personal[BLAKE2B_PERSONALBYTES]; /* 64 */ - }); - - typedef struct blake2b_param__ blake2b_param; - - typedef struct blake2xs_state__ - { - blake2s_state S[1]; - blake2s_param P[1]; - } blake2xs_state; - - typedef struct blake2xb_state__ - { - blake2b_state S[1]; - blake2b_param P[1]; - } blake2xb_state; - - /* Padded structs result in a compile-time error */ - enum { - BLAKE2_DUMMY_1 = 1/(int)(sizeof(blake2s_param) == BLAKE2S_OUTBYTES), - BLAKE2_DUMMY_2 = 1/(int)(sizeof(blake2b_param) == BLAKE2B_OUTBYTES) - }; - - /* Streaming API */ - int blake2s_init( blake2s_state *S, size_t outlen ); - int blake2s_init_key( blake2s_state *S, size_t outlen, const void *key, size_t keylen ); - int blake2s_init_param( blake2s_state *S, const blake2s_param *P ); - int blake2s_update( blake2s_state *S, const void *in, size_t inlen ); - int blake2s_final( blake2s_state *S, void *out, size_t outlen ); - - int blake2b_init( blake2b_state *S, size_t outlen ); - int blake2b_init_key( blake2b_state *S, size_t outlen, const void *key, size_t keylen ); - int blake2b_init_param( blake2b_state *S, const blake2b_param *P ); - int blake2b_update( blake2b_state *S, const void *in, size_t inlen ); - int blake2b_final( blake2b_state *S, void *out, size_t outlen ); - - int blake2sp_init( blake2sp_state *S, size_t outlen ); - int blake2sp_init_key( blake2sp_state *S, size_t outlen, const void *key, size_t keylen ); - int blake2sp_update( blake2sp_state *S, const void *in, size_t inlen ); - int blake2sp_final( blake2sp_state *S, void *out, size_t outlen ); - - int blake2bp_init( blake2bp_state *S, size_t outlen ); - int blake2bp_init_key( blake2bp_state *S, size_t outlen, const void *key, size_t keylen ); - int blake2bp_update( blake2bp_state *S, const void *in, size_t inlen ); - int blake2bp_final( blake2bp_state *S, void *out, size_t outlen ); - - /* Variable output length API */ - int blake2xs_init( blake2xs_state *S, const size_t outlen ); - int blake2xs_init_key( blake2xs_state *S, const size_t outlen, const void *key, size_t keylen ); - int blake2xs_update( blake2xs_state *S, const void *in, size_t inlen ); - int blake2xs_final(blake2xs_state *S, void *out, size_t outlen); - - int blake2xb_init( blake2xb_state *S, const size_t outlen ); - int blake2xb_init_key( blake2xb_state *S, const size_t outlen, const void *key, size_t keylen ); - int blake2xb_update( blake2xb_state *S, const void *in, size_t inlen ); - int blake2xb_final(blake2xb_state *S, void *out, size_t outlen); - - /* Simple API */ - int blake2s( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen ); - int blake2b( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen ); - - int blake2sp( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen ); - int blake2bp( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen ); - - int blake2xs( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen ); - int blake2xb( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen ); - - /* This is simply an alias for blake2b */ - int blake2( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen ); - -#if defined(__cplusplus) -} -#endif - -#endif diff --git a/deps/blake2/src/blake2b-ref.c b/deps/blake2/src/blake2b-ref.c deleted file mode 100644 index cd38b1b..0000000 --- a/deps/blake2/src/blake2b-ref.c +++ /dev/null @@ -1,379 +0,0 @@ -/* - BLAKE2 reference source code package - reference C implementations - - Copyright 2012, Samuel Neves . You may use this under the - terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at - your option. The terms of these licenses can be found at: - - - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - - OpenSSL license : https://www.openssl.org/source/license.html - - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - - More information about the BLAKE2 hash function can be found at - https://blake2.net. -*/ - -#include -#include -#include - -#include "blake2.h" -#include "blake2-impl.h" - -static const uint64_t blake2b_IV[8] = -{ - 0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL, - 0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL, - 0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL, - 0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL -}; - -static const uint8_t blake2b_sigma[12][16] = -{ - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } , - { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } , - { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 } , - { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 } , - { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 } , - { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 } , - { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 } , - { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 } , - { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 } , - { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 } , - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } , - { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } -}; - - -static void blake2b_set_lastnode( blake2b_state *S ) -{ - S->f[1] = (uint64_t)-1; -} - -/* Some helper functions, not necessarily useful */ -static int blake2b_is_lastblock( const blake2b_state *S ) -{ - return S->f[0] != 0; -} - -static void blake2b_set_lastblock( blake2b_state *S ) -{ - if( S->last_node ) blake2b_set_lastnode( S ); - - S->f[0] = (uint64_t)-1; -} - -static void blake2b_increment_counter( blake2b_state *S, const uint64_t inc ) -{ - S->t[0] += inc; - S->t[1] += ( S->t[0] < inc ); -} - -static void blake2b_init0( blake2b_state *S ) -{ - size_t i; - memset( S, 0, sizeof( blake2b_state ) ); - - for( i = 0; i < 8; ++i ) S->h[i] = blake2b_IV[i]; -} - -/* init xors IV with input parameter block */ -int blake2b_init_param( blake2b_state *S, const blake2b_param *P ) -{ - const uint8_t *p = ( const uint8_t * )( P ); - size_t i; - - blake2b_init0( S ); - - /* IV XOR ParamBlock */ - for( i = 0; i < 8; ++i ) - S->h[i] ^= load64( p + sizeof( S->h[i] ) * i ); - - S->outlen = P->digest_length; - return 0; -} - - - -int blake2b_init( blake2b_state *S, size_t outlen ) -{ - blake2b_param P[1]; - - if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) return -1; - - P->digest_length = (uint8_t)outlen; - P->key_length = 0; - P->fanout = 1; - P->depth = 1; - store32( &P->leaf_length, 0 ); - store32( &P->node_offset, 0 ); - store32( &P->xof_length, 0 ); - P->node_depth = 0; - P->inner_length = 0; - memset( P->reserved, 0, sizeof( P->reserved ) ); - memset( P->salt, 0, sizeof( P->salt ) ); - memset( P->personal, 0, sizeof( P->personal ) ); - return blake2b_init_param( S, P ); -} - - -int blake2b_init_key( blake2b_state *S, size_t outlen, const void *key, size_t keylen ) -{ - blake2b_param P[1]; - - if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) return -1; - - if ( !key || !keylen || keylen > BLAKE2B_KEYBYTES ) return -1; - - P->digest_length = (uint8_t)outlen; - P->key_length = (uint8_t)keylen; - P->fanout = 1; - P->depth = 1; - store32( &P->leaf_length, 0 ); - store32( &P->node_offset, 0 ); - store32( &P->xof_length, 0 ); - P->node_depth = 0; - P->inner_length = 0; - memset( P->reserved, 0, sizeof( P->reserved ) ); - memset( P->salt, 0, sizeof( P->salt ) ); - memset( P->personal, 0, sizeof( P->personal ) ); - - if( blake2b_init_param( S, P ) < 0 ) return -1; - - { - uint8_t block[BLAKE2B_BLOCKBYTES]; - memset( block, 0, BLAKE2B_BLOCKBYTES ); - memcpy( block, key, keylen ); - blake2b_update( S, block, BLAKE2B_BLOCKBYTES ); - secure_zero_memory( block, BLAKE2B_BLOCKBYTES ); /* Burn the key from stack */ - } - return 0; -} - -#define G(r,i,a,b,c,d) \ - do { \ - a = a + b + m[blake2b_sigma[r][2*i+0]]; \ - d = rotr64(d ^ a, 32); \ - c = c + d; \ - b = rotr64(b ^ c, 24); \ - a = a + b + m[blake2b_sigma[r][2*i+1]]; \ - d = rotr64(d ^ a, 16); \ - c = c + d; \ - b = rotr64(b ^ c, 63); \ - } while(0) - -#define ROUND(r) \ - do { \ - G(r,0,v[ 0],v[ 4],v[ 8],v[12]); \ - G(r,1,v[ 1],v[ 5],v[ 9],v[13]); \ - G(r,2,v[ 2],v[ 6],v[10],v[14]); \ - G(r,3,v[ 3],v[ 7],v[11],v[15]); \ - G(r,4,v[ 0],v[ 5],v[10],v[15]); \ - G(r,5,v[ 1],v[ 6],v[11],v[12]); \ - G(r,6,v[ 2],v[ 7],v[ 8],v[13]); \ - G(r,7,v[ 3],v[ 4],v[ 9],v[14]); \ - } while(0) - -static void blake2b_compress( blake2b_state *S, const uint8_t block[BLAKE2B_BLOCKBYTES] ) -{ - uint64_t m[16]; - uint64_t v[16]; - size_t i; - - for( i = 0; i < 16; ++i ) { - m[i] = load64( block + i * sizeof( m[i] ) ); - } - - for( i = 0; i < 8; ++i ) { - v[i] = S->h[i]; - } - - v[ 8] = blake2b_IV[0]; - v[ 9] = blake2b_IV[1]; - v[10] = blake2b_IV[2]; - v[11] = blake2b_IV[3]; - v[12] = blake2b_IV[4] ^ S->t[0]; - v[13] = blake2b_IV[5] ^ S->t[1]; - v[14] = blake2b_IV[6] ^ S->f[0]; - v[15] = blake2b_IV[7] ^ S->f[1]; - - ROUND( 0 ); - ROUND( 1 ); - ROUND( 2 ); - ROUND( 3 ); - ROUND( 4 ); - ROUND( 5 ); - ROUND( 6 ); - ROUND( 7 ); - ROUND( 8 ); - ROUND( 9 ); - ROUND( 10 ); - ROUND( 11 ); - - for( i = 0; i < 8; ++i ) { - S->h[i] = S->h[i] ^ v[i] ^ v[i + 8]; - } -} - -#undef G -#undef ROUND - -int blake2b_update( blake2b_state *S, const void *pin, size_t inlen ) -{ - const unsigned char * in = (const unsigned char *)pin; - if( inlen > 0 ) - { - size_t left = S->buflen; - size_t fill = BLAKE2B_BLOCKBYTES - left; - if( inlen > fill ) - { - S->buflen = 0; - memcpy( S->buf + left, in, fill ); /* Fill buffer */ - blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES ); - blake2b_compress( S, S->buf ); /* Compress */ - in += fill; inlen -= fill; - while(inlen > BLAKE2B_BLOCKBYTES) { - blake2b_increment_counter(S, BLAKE2B_BLOCKBYTES); - blake2b_compress( S, in ); - in += BLAKE2B_BLOCKBYTES; - inlen -= BLAKE2B_BLOCKBYTES; - } - } - memcpy( S->buf + S->buflen, in, inlen ); - S->buflen += inlen; - } - return 0; -} - -int blake2b_final( blake2b_state *S, void *out, size_t outlen ) -{ - uint8_t buffer[BLAKE2B_OUTBYTES] = {0}; - size_t i; - - if( out == NULL || outlen < S->outlen ) - return -1; - - if( blake2b_is_lastblock( S ) ) - return -1; - - blake2b_increment_counter( S, S->buflen ); - blake2b_set_lastblock( S ); - memset( S->buf + S->buflen, 0, BLAKE2B_BLOCKBYTES - S->buflen ); /* Padding */ - blake2b_compress( S, S->buf ); - - for( i = 0; i < 8; ++i ) /* Output full hash to temp buffer */ - store64( buffer + sizeof( S->h[i] ) * i, S->h[i] ); - - memcpy( out, buffer, S->outlen ); - secure_zero_memory(buffer, sizeof(buffer)); - return 0; -} - -/* inlen, at least, should be uint64_t. Others can be size_t. */ -int blake2b( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen ) -{ - blake2b_state S[1]; - - /* Verify parameters */ - if ( NULL == in && inlen > 0 ) return -1; - - if ( NULL == out ) return -1; - - if( NULL == key && keylen > 0 ) return -1; - - if( !outlen || outlen > BLAKE2B_OUTBYTES ) return -1; - - if( keylen > BLAKE2B_KEYBYTES ) return -1; - - if( keylen > 0 ) - { - if( blake2b_init_key( S, outlen, key, keylen ) < 0 ) return -1; - } - else - { - if( blake2b_init( S, outlen ) < 0 ) return -1; - } - - blake2b_update( S, ( const uint8_t * )in, inlen ); - blake2b_final( S, out, outlen ); - return 0; -} - -int blake2( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen ) { - return blake2b(out, outlen, in, inlen, key, keylen); -} - -#if defined(SUPERCOP) -int crypto_hash( unsigned char *out, unsigned char *in, unsigned long long inlen ) -{ - return blake2b( out, BLAKE2B_OUTBYTES, in, inlen, NULL, 0 ); -} -#endif - -#if defined(BLAKE2B_SELFTEST) -#include -#include "blake2-kat.h" -int main( void ) -{ - uint8_t key[BLAKE2B_KEYBYTES]; - uint8_t buf[BLAKE2_KAT_LENGTH]; - size_t i, step; - - for( i = 0; i < BLAKE2B_KEYBYTES; ++i ) - key[i] = ( uint8_t )i; - - for( i = 0; i < BLAKE2_KAT_LENGTH; ++i ) - buf[i] = ( uint8_t )i; - - /* Test simple API */ - for( i = 0; i < BLAKE2_KAT_LENGTH; ++i ) - { - uint8_t hash[BLAKE2B_OUTBYTES]; - blake2b( hash, BLAKE2B_OUTBYTES, buf, i, key, BLAKE2B_KEYBYTES ); - - if( 0 != memcmp( hash, blake2b_keyed_kat[i], BLAKE2B_OUTBYTES ) ) - { - goto fail; - } - } - - /* Test streaming API */ - for(step = 1; step < BLAKE2B_BLOCKBYTES; ++step) { - for (i = 0; i < BLAKE2_KAT_LENGTH; ++i) { - uint8_t hash[BLAKE2B_OUTBYTES]; - blake2b_state S; - uint8_t * p = buf; - size_t mlen = i; - int err = 0; - - if( (err = blake2b_init_key(&S, BLAKE2B_OUTBYTES, key, BLAKE2B_KEYBYTES)) < 0 ) { - goto fail; - } - - while (mlen >= step) { - if ( (err = blake2b_update(&S, p, step)) < 0 ) { - goto fail; - } - mlen -= step; - p += step; - } - if ( (err = blake2b_update(&S, p, mlen)) < 0) { - goto fail; - } - if ( (err = blake2b_final(&S, hash, BLAKE2B_OUTBYTES)) < 0) { - goto fail; - } - - if (0 != memcmp(hash, blake2b_keyed_kat[i], BLAKE2B_OUTBYTES)) { - goto fail; - } - } - } - - puts( "ok" ); - return 0; -fail: - puts("error"); - return -1; -} -#endif diff --git a/deps/jansson/.gitignore b/deps/jansson/.gitignore deleted file mode 100644 index 9189a93..0000000 --- a/deps/jansson/.gitignore +++ /dev/null @@ -1,28 +0,0 @@ -*~ -*.o -*.a -.libs -.deps -Makefile -Makefile.in -aclocal.m4 -autom4te.cache -config.guess -config.h -config.h.in -config.log -config.status -config.sub -configure -depcomp -install-sh -libtool -ltmain.sh -missing -*.lo -*.la -stamp-h1 -*.pyc -*.pc -/src/jansson_config.h -*.exe diff --git a/deps/jansson/.travis.yml b/deps/jansson/.travis.yml deleted file mode 100644 index 1cca274..0000000 --- a/deps/jansson/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: c -compiler: - - gcc - - clang -script: autoreconf -f -i && CFLAGS=-Werror ./configure && make check diff --git a/deps/jansson/Android.mk b/deps/jansson/Android.mk deleted file mode 100644 index eb4fed7..0000000 --- a/deps/jansson/Android.mk +++ /dev/null @@ -1,29 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_ARM_MODE := arm - -LOCAL_SRC_FILES := \ - src/dump.c \ - src/error.c \ - src/hashtable.c \ - src/load.c \ - src/memory.c \ - src/pack_unpack.c \ - src/strbuffer.c \ - src/strconv.c \ - src/utf.c \ - src/value.c - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH) \ - $(LOCAL_PATH)/android \ - $(LOCAL_PATH)/src - -LOCAL_MODULE_TAGS := optional -LOCAL_SHARED_LIBRARIES := libc -LOCAL_CFLAGS += -O3 - -LOCAL_MODULE:= libjansson - -include $(BUILD_SHARED_LIBRARY) diff --git a/deps/jansson/CHANGES b/deps/jansson/CHANGES deleted file mode 100644 index 7807904..0000000 --- a/deps/jansson/CHANGES +++ /dev/null @@ -1,586 +0,0 @@ -Version 2.6 (in development) -============================ - -Released XXXX-XX-XX - -* New features: - - - `json_pack()` and friends: Add format specifiers ``s%`` and ``+%`` - for a size_t string length. - - - `json_unpack()` and friends: Add format specifier ``s%`` for - unpacking the string length along with the string itself. - - - Add length-aware string constructors `json_stringn()` and - `json_stringn_nocheck()`, length-aware string mutators - `json_string_setn()` and `json_string_setn_nocheck()`, and a - function for getting string's length `json_string_length()`. - - - Support ``\u0000`` escapes in the decoder. The support can be - enabled by using the ``JSON_ALLOW_NUL`` decoding flag. - -* Bug fixes: - - - Some malformed ``\uNNNN`` escapes could crash the decoder with an - assertion failure. - -* Other changes: - - - ``\uNNNN`` escapes are now encoded in upper case for better - readability. - - -Version 2.5 -=========== - -Released 2013-09-19 - -* New features: - - - `json_pack()` and friends: Add format specifiers ``s#``, ``+`` and - ``+#``. - - - Add ``JSON_DECODE_INT_AS_REAL`` decoding flag to treat all numbers - as real in the decoder (#123). - - - Add `json_array_foreach()`, paralleling `json_object_foreach()` - (#118). - -* Bug fixes: - - - `json_dumps()` and friends: Don't crash if json is *NULL* and - ``JSON_ENCODE_ANY`` is set. - - - Fix a theoretical integer overflow in `jsonp_strdup()`. - - - Fix `l_isxdigit()` macro (#97). - - - Fix an off-by-one error in `json_array_remove()`. - -* Build: - - - Support CMake in addition to GNU Autotools (#106, #107, #112, - #115, #120, #127). - - - Support building for Android (#109). - - - Don't use ``-Werror`` by default. - - - Support building and testing with VPATH (#93). - - - Fix compilation when ``NDEBUG`` is defined (#128) - -* Tests: - - - Fix a refleak in ``test/bin/json_process.c``. - -* Documentation: - - - Clarify the return value of `json_load_callback_t`. - - - Document how to circumvent problems with separate heaps on Windows. - - - Fix memory leaks and warnings in ``github_commits.c``. - - - Use `json_decref()` properly in tutorial. - -* Other: - - - Make it possible to forward declare ``struct json_t``. - - -Version 2.4 -=========== - -Released 2012-09-23 - -* New features: - - - Add `json_boolean()` macro that returns the JSON true or false - value based on its argument (#86). - - - Add `json_load_callback()` that calls a callback function - repeatedly to read the JSON input (#57). - - - Add JSON_ESCAPE_SLASH encoding flag to escape all occurences of - ``/`` with ``\/``. - -* Bug fixes: - - - Check for and reject NaN and Inf values for reals. Encoding these - values resulted in invalid JSON. - - - Fix `json_real_set()` to return -1 on error. - -* Build: - - - Jansson now builds on Windows with Visual Studio 2010, and - includes solution and project files in ``win32/vs2010/`` - directory. - - - Fix build warnings (#77, #78). - - - Add ``-no-undefined`` to LDFLAGS (#90). - -* Tests: - - - Fix the symbol exports test on Linux/PPC64 (#88). - -* Documentation: - - - Fix typos (#73, #84). - - -Version 2.3.1 -============= - -Released 2012-04-20 - -* Build issues: - - - Only use ``long long`` if ``strtoll()`` is also available. - -* Documentation: - - - Fix the names of library version constants in documentation. (#52) - - - Change the tutorial to use GitHub API v3. (#65) - -* Tests: - - - Make some tests locale independent. (#51) - - - Distribute the library exports test in the tarball. - - - Make test run on shells that don't support the ``export FOO=bar`` - syntax. - - -Version 2.3 -=========== - -Released 2012-01-27 - -* New features: - - - `json_unpack()` and friends: Add support for optional object keys - with the ``{s?o}`` syntax. - - - Add `json_object_update_existing()` and - `json_object_update_missing()`, for updating only existing keys or - only adding missing keys to an object. (#37) - - - Add `json_object_foreach()` for more convenient iteration over - objects. (#45, #46) - - - When decoding JSON, write the number of bytes that were read from - input to ``error.position`` also on success. This is handy with - ``JSON_DISABLE_EOF_CHECK``. - - - Add support for decoding any JSON value, not just arrays or - objects. The support is enabled with the new ``JSON_DECODE_ANY`` - flag. Patch by Andrea Marchesini. (#4) - -* Bug fixes - - - Avoid problems with object's serial number growing too big. (#40, - #41) - - - Decoding functions now return NULL if the first argument is NULL. - Patch by Andrea Marchesini. - - - Include ``jansson_config.h.win32`` in the distribution tarball. - - - Remove ``+`` and leading zeros from exponents in the encoder. - (#39) - - - Make Jansson build and work on MinGW. (#39, #38) - -* Documentation - - - Note that the same JSON values must not be encoded in parallel by - separate threads. (#42) - - - Document MinGW support. - - -Version 2.2.1 -============= - -Released 2011-10-06 - -* Bug fixes: - - - Fix real number encoding and decoding under non-C locales. (#32) - - - Fix identifier decoding under non-UTF-8 locales. (#35) - - - `json_load_file()`: Open the input file in binary mode for maximum - compatiblity. - -* Documentation: - - - Clarify the lifecycle of the result of the ``s`` fromat of - `json_unpack()`. (#31) - - - Add some portability info. (#36) - - - Little clarifications here and there. - -* Other: - - - Some style fixes, issues detected by static analyzers. - - -Version 2.2 -=========== - -Released 2011-09-03 - -* New features: - - - `json_dump_callback()`: Pass the encoder output to a callback - function in chunks. - -* Bug fixes: - - - `json_string_set()`: Check that target is a string and value is - not NULL. - -* Other: - - - Documentation typo fixes and clarifications. - - -Version 2.1 -=========== - -Released 2011-06-10 - -* New features: - - - `json_loadb()`: Decode a string with a given size, useful if the - string is not null terminated. - - - Add ``JSON_ENCODE_ANY`` encoding flag to allow encoding any JSON - value. By default, only arrays and objects can be encoded. (#19) - - - Add ``JSON_REJECT_DUPLICATES`` decoding flag to issue a decoding - error if any JSON object in the input contins duplicate keys. (#3) - - - Add ``JSON_DISABLE_EOF_CHECK`` decoding flag to stop decoding after a - valid JSON input. This allows other data after the JSON data. - -* Bug fixes: - - - Fix an additional memory leak when memory allocation fails in - `json_object_set()` and friends. - - - Clear errno before calling `strtod()` for better portability. (#27) - -* Building: - - - Avoid set-but-not-used warning/error in a test. (#20) - -* Other: - - - Minor clarifications to documentation. - - -Version 2.0.1 -============= - -Released 2011-03-31 - -* Bug fixes: - - - Replace a few `malloc()` and `free()` calls with their - counterparts that support custom memory management. - - - Fix object key hashing in json_unpack() strict checking mode. - - - Fix the parentheses in ``JANSSON_VERSION_HEX`` macro. - - - Fix `json_object_size()` return value. - - - Fix a few compilation issues. - -* Portability: - - - Enhance portability of `va_copy()`. - - - Test framework portability enhancements. - -* Documentation: - - - Distribute ``doc/upgrading.rst`` with the source tarball. - - - Build documentation in strict mode in ``make distcheck``. - - -Version 2.0 -=========== - -Released 2011-02-28 - -This release is backwards incompatible with the 1.x release series. -See the chapter "Upgrading from older versions" in documentation for -details. - -* Backwards incompatible changes: - - - Unify unsigned integer usage in the API: All occurences of - unsigned int and unsigned long have been replaced with size_t. - - - Change JSON integer's underlying type to the widest signed integer - type available, i.e. long long if it's supported, otherwise long. - Add a typedef json_int_t that defines the type. - - - Change the maximum indentation depth to 31 spaces in encoder. This - frees up bits from the flags parameter of encoding functions - `json_dumpf()`, `json_dumps()` and `json_dump_file()`. - - - For future needs, add a flags parameter to all decoding functions - `json_loadf()`, `json_loads()` and `json_load_file()`. - -* New features - - - `json_pack()`, `json_pack_ex()`, `json_vpack_ex()`: Create JSON - values based on a format string. - - - `json_unpack()`, `json_unpack_ex()`, `json_vunpack_ex()`: Simple - value extraction and validation functionality based on a format - string. - - - Add column, position and source fields to the ``json_error_t`` - struct. - - - Enhance error reporting in the decoder. - - - ``JANSSON_VERSION`` et al.: Preprocessor constants that define the - library version. - - - `json_set_alloc_funcs()`: Set custom memory allocation functions. - -* Fix many portability issues, especially on Windows. - -* Configuration - - - Add file ``jansson_config.h`` that contains site specific - configuration. It's created automatically by the configure script, - or can be created by hand if the configure script cannot be used. - The file ``jansson_config.h.win32`` can be used without - modifications on Windows systems. - - - Add a section to documentation describing how to build Jansson on - Windows. - - - Documentation now requires Sphinx 1.0 or newer. - - -Version 1.3 -=========== - -Released 2010-06-13 - -* New functions: - - - `json_object_iter_set()`, `json_object_iter_set_new()`: Change - object contents while iterating over it. - - - `json_object_iter_at()`: Return an iterator that points to a - specific object item. - -* New encoding flags: - - - ``JSON_PRESERVE_ORDER``: Preserve the insertion order of object - keys. - -* Bug fixes: - - - Fix an error that occured when an array or object was first - encoded as empty, then populated with some data, and then - re-encoded - - - Fix the situation like above, but when the first encoding resulted - in an error - -* Documentation: - - - Clarify the documentation on reference stealing, providing an - example usage pattern - - -Version 1.2.1 -============= - -Released 2010-04-03 - -* Bug fixes: - - - Fix reference counting on ``true``, ``false`` and ``null`` - - Estimate real number underflows in decoder with 0.0 instead of - issuing an error - -* Portability: - - - Make ``int32_t`` available on all systems - - Support compilers that don't have the ``inline`` keyword - - Require Autoconf 2.60 (for ``int32_t``) - -* Tests: - - - Print test names correctly when ``VERBOSE=1`` - - ``test/suites/api``: Fail when a test fails - - Enhance tests for iterators - - Enhance tests for decoding texts that contain null bytes - -* Documentation: - - - Don't remove ``changes.rst`` in ``make clean`` - - Add a chapter on RFC conformance - - -Version 1.2 -=========== - -Released 2010-01-21 - -* New functions: - - - `json_equal()`: Test whether two JSON values are equal - - `json_copy()` and `json_deep_copy()`: Make shallow and deep copies - of JSON values - - Add a version of all functions taking a string argument that - doesn't check for valid UTF-8: `json_string_nocheck()`, - `json_string_set_nocheck()`, `json_object_set_nocheck()`, - `json_object_set_new_nocheck()` - -* New encoding flags: - - - ``JSON_SORT_KEYS``: Sort objects by key - - ``JSON_ENSURE_ASCII``: Escape all non-ASCII Unicode characters - - ``JSON_COMPACT``: Use a compact representation with all unneeded - whitespace stripped - -* Bug fixes: - - - Revise and unify whitespace usage in encoder: Add spaces between - array and object items, never append newline to output. - - Remove const qualifier from the ``json_t`` parameter in - `json_string_set()`, `json_integer_set()` and `json_real_set`. - - Use ``int32_t`` internally for representing Unicode code points - (int is not enough on all platforms) - -* Other changes: - - - Convert ``CHANGES`` (this file) to reStructured text and add it to - HTML documentation - - The test system has been refactored. Python is no longer required - to run the tests. - - Documentation can now be built by invoking ``make html`` - - Support for pkg-config - - -Version 1.1.3 -============= - -Released 2009-12-18 - -* Encode reals correctly, so that first encoding and then decoding a - real always produces the same value -* Don't export private symbols in ``libjansson.so`` - - -Version 1.1.2 -============= - -Released 2009-11-08 - -* Fix a bug where an error message was not produced if the input file - could not be opened in `json_load_file()` -* Fix an assertion failure in decoder caused by a minus sign without a - digit after it -* Remove an unneeded include of ``stdint.h`` in ``jansson.h`` - - -Version 1.1.1 -============= - -Released 2009-10-26 - -* All documentation files were not distributed with v1.1; build - documentation in make distcheck to prevent this in the future -* Fix v1.1 release date in ``CHANGES`` - - -Version 1.1 -=========== - -Released 2009-10-20 - -* API additions and improvements: - - - Extend array and object APIs - - Add functions to modify integer, real and string values - - Improve argument validation - - Use unsigned int instead of ``uint32_t`` for encoding flags - -* Enhance documentation - - - Add getting started guide and tutorial - - Fix some typos - - General clarifications and cleanup - -* Check for integer and real overflows and underflows in decoder -* Make singleton values thread-safe (``true``, ``false`` and ``null``) -* Enhance circular reference handling -* Don't define ``-std=c99`` in ``AM_CFLAGS`` -* Add C++ guards to ``jansson.h`` -* Minor performance and portability improvements -* Expand test coverage - - -Version 1.0.4 -============= - -Released 2009-10-11 - -* Relax Autoconf version requirement to 2.59 -* Make Jansson compile on platforms where plain ``char`` is unsigned -* Fix API tests for object - - -Version 1.0.3 -============= - -Released 2009-09-14 - -* Check for integer and real overflows and underflows in decoder -* Use the Python json module for tests, or simplejson if the json - module is not found -* Distribute changelog (this file) - - -Version 1.0.2 -============= - -Released 2009-09-08 - -* Handle EOF correctly in decoder - - -Version 1.0.1 -============= - -Released 2009-09-04 - -* Fixed broken `json_is_boolean()` - - -Version 1.0 -=========== - -Released 2009-08-25 - -* Initial release diff --git a/deps/jansson/CMakeLists.txt b/deps/jansson/CMakeLists.txt deleted file mode 100644 index fc26dc8..0000000 --- a/deps/jansson/CMakeLists.txt +++ /dev/null @@ -1,476 +0,0 @@ -# Notes: -# -# Author: Paul Harris, June 2012 -# Additions: Joakim Soderberg, Febuary 2013 -# -# Supports: building static/shared, release/debug/etc, can also build html docs -# and some of the tests. -# Note that its designed for out-of-tree builds, so it will not pollute your -# source tree. -# -# TODO 1: Finish implementing tests. api tests are working, but the valgrind -# variants are not flagging problems. -# -# TODO 2: There is a check_exports script that would try and incorporate. -# -# TODO 3: Consolidate version numbers, currently the version number is written -# into: * cmake (here) * autotools (the configure) * source code header files. -# Should not be written directly into header files, autotools/cmake can do -# that job. -# -# Brief intro on how to use cmake: -# > mkdir build (somewhere - we do out-of-tree builds) -# > use cmake, ccmake, or cmake-gui to configure the project. for linux, you -# can only choose one variant: release,debug,etc... and static or shared. -# >> example: -# >> cd build -# >> ccmake -i ../path_to_jansson_dir -# >> inside, configure your options. press C until there are no lines -# with * next to them. -# >> note, I like to configure the 'install' path to ../install, so I get -# self-contained clean installs I can point other projects to. -# >> press G to 'generate' the project files. -# >> make (to build the project) -# >> make install -# >> make test (to run the tests, if you enabled them) -# -# Brief description on how it works: -# There is a small heirachy of CMakeLists.txt files which define how the -# project is built. -# Header file detection etc is done, and the results are written into config.h -# and jansson_config.h, which are generated from the corresponding -# config.h.cmake and jansson_config.h.cmake template files. -# The generated header files end up in the build directory - not in -# the source directory. -# The rest is down to the usual make process. - - - -cmake_minimum_required (VERSION 2.8) -# required for exports? cmake_minimum_required (VERSION 2.8.6) -project (jansson C) - -# Set some nicer output dirs. -SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) -SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) -SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) - -# Give the debug version a different postfix for windows, -# so both the debug and release version can be built in the -# same build-tree on Windows (MSVC). -if (WIN32) - SET (CMAKE_DEBUG_POSTFIX "_d") -else (WIN32) -endif (WIN32) - -# This is how I thought it should go -# set (JANSSON_VERSION "2.3.1") -# set (JANSSON_SOVERSION 2) - -set(JANSSON_DISPLAY_VERSION "2.5") - -# This is what is required to match the same numbers as automake's -set (JANSSON_VERSION "4.5.0") -set (JANSSON_SOVERSION 4) - -# for CheckFunctionKeywords -set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - -include (CheckFunctionExists) -include (CheckFunctionKeywords) -include (CheckIncludeFiles) -include (CheckTypeSize) -include (CheckSymbolExists) - - -if (MSVC) - # Turn off Microsofts "security" warnings. - add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4005 /wd4996 /nologo" ) - - # Disabled by OBS, options already set by top level CMakeLists - if (FALSE) - set(CMAKE_C_FLAGS_RELEASE "/MT") - set(CMAKE_C_FLAGS_DEBUG "/MTd") - endif() - -endif() - -if (NOT WIN32 AND NOT APPLE) - set(CMAKE_C_FLAGS "-fPIC") -endif() - - - -# Check for the int-type includes -check_include_files (sys/types.h HAVE_SYS_TYPES_H) -check_include_files (inttypes.h HAVE_INTTYPES_H) -check_include_files (stdint.h HAVE_STDINT_H) - - -# Check our 64 bit integer sizes -check_type_size (__int64 __INT64) -check_type_size (int64_t INT64_T) -check_type_size ("long long" LONG_LONG_INT) - -# Check our 32 bit integer sizes -check_type_size (int32_t INT32_T) -check_type_size (__int32 __INT32) -check_type_size ("long" LONG_INT) -check_type_size ("int" INT) - -if (HAVE_INT32_T) - set (JSON_INT32 int32_t) -elseif (HAVE___INT32) - set (JSON_INT32 __int32) -elseif (HAVE_LONG AND (${LONG_INT} EQUAL 4)) - set (JSON_INT32 long) -elseif (HAVE_INT AND (${INT} EQUAL 4)) - set (JSON_INT32 int) -else () - message (FATAL_ERROR "Could not detect a valid 32 bit integer type") -endif () - -# Check for ssize_t and SSIZE_T existance. -check_type_size(ssize_t SSIZE_T) -check_type_size(SSIZE_T UPPERCASE_SSIZE_T) -if(NOT HAVE_SSIZE_T) - if(HAVE_UPPERCASE_SSIZE_T) - set(JSON_SSIZE SSIZE_T) - else() - set(JSON_SSIZE int) - endif() -endif() -set(CMAKE_EXTRA_INCLUDE_FILES "") - -# Check for all the variants of strtoll -check_function_exists (strtoll HAVE_STRTOLL) -check_function_exists (strtoq HAVE_STRTOQ) -check_function_exists (_strtoi64 HAVE__STRTOI64) - -# Figure out what variant we should use -if (HAVE_STRTOLL) - set (JSON_STRTOINT strtoll) -elseif (HAVE_STRTOQ) - set (JSON_STRTOINT strtoq) -elseif (HAVE__STRTOI64) - set (JSON_STRTOINT _strtoi64) -else () - # fallback to strtol (32 bit) - # this will set all the required variables - set (JSON_STRTOINT strtol) - set (JSON_INT_T long) - set (JSON_INTEGER_FORMAT "\"ld\"") -endif () - -# if we haven't defined JSON_INT_T, then we have a 64 bit conversion function. -# detect what to use for the 64 bit type. -# Note: I will prefer long long if I can get it, as that is what the automake system aimed for. -if (NOT DEFINED JSON_INT_T) - if (HAVE_LONG_LONG_INT AND (${LONG_LONG_INT} EQUAL 8)) - set (JSON_INT_T "long long") - elseif (HAVE_INT64_T) - set (JSON_INT_T int64_t) - elseif (HAVE___INT64) - set (JSON_INT_T __int64) - else () - message (FATAL_ERROR "Could not detect 64 bit type, although I detected the strtoll equivalent") - endif () - - # Apparently, Borland BCC and MSVC wants I64d, - # Borland BCC could also accept LD - # and gcc wants ldd, - # I am not sure what cygwin will want, so I will assume I64d - - if (WIN32) # matches both msvc and cygwin - set (JSON_INTEGER_FORMAT "\"I64d\"") - else () - set (JSON_INTEGER_FORMAT "\"lld\"") - endif () -endif () - - -# If locale.h and localeconv() are available, define to 1, otherwise to 0. -check_include_files (locale.h HAVE_LOCALE_H) -check_function_exists (localeconv HAVE_LOCALECONV) - -if (HAVE_LOCALECONV AND HAVE_LOCALE_H) - set (JSON_HAVE_LOCALECONV 1) -else () - set (JSON_HAVE_LOCALECONV 0) -endif () - - -# check if we have setlocale -check_function_exists (setlocale HAVE_SETLOCALE) - - -# Check what the inline keyword is. -# Note that the original JSON_INLINE was always set to just 'inline', so this goes further. -check_function_keywords("inline") -check_function_keywords("__inline") -check_function_keywords("__inline__") - -if (HAVE_INLINE) - set (JSON_INLINE inline) -elseif (HAVE___INLINE) - set (JSON_INLINE __inline) -elseif (HAVE___INLINE__) - set (JSON_INLINE __inline__) -else (HAVE_INLINE) - # no inline on this platform - set (JSON_INLINE) -endif (HAVE_INLINE) - -# Find our snprintf -check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF) -check_symbol_exists(_snprintf "stdio.h" HAVE__SNPRINTF) - -if (HAVE_SNPRINTF) - set (JSON_SNPRINTF snprintf) -elseif (HAVE__SNPRINTF) - set (JSON_SNPRINTF _snprintf) -endif () - -# Create pkg-conf file. -# (We use the same files as ./configure does, so we -# have to defined the same variables used there). -if(NOT DEFINED CMAKE_INSTALL_LIBDIR) - set(CMAKE_INSTALL_LIBDIR lib) -endif(NOT DEFINED CMAKE_INSTALL_LIBDIR) -set(prefix ${CMAKE_INSTALL_PREFIX}) -set(exec_prefix ${CMAKE_INSTALL_PREFIX}) -set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) -set(VERSION ${JANSSON_DISPLAY_VERSION}) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/jansson.pc.in - ${CMAKE_CURRENT_BINARY_DIR}/jansson.pc @ONLY) - -# configure the public config file -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/jansson_config.h.cmake - ${CMAKE_CURRENT_BINARY_DIR}/include/jansson_config.h) - -# Copy the jansson.h file to the public include folder -file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/include/) - - -# configure the private config file -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.cmake - ${CMAKE_CURRENT_BINARY_DIR}/private_include/config.h) - -# and tell the source code to include it -add_definitions (-DHAVE_CONFIG_H) - -include_directories (${CMAKE_CURRENT_BINARY_DIR}/include) -include_directories (${CMAKE_CURRENT_BINARY_DIR}/private_include) - -# Add the lib sources. -file (GLOB C_FILES src/*.c) - -# Disabled by OBS, we use it as a static library -if (FALSE) - - add_library (jansson SHARED ${C_FILES} src/jansson.def) - - set_target_properties (jansson PROPERTIES - VERSION ${JANSSON_VERSION} - SOVERSION ${JANSSON_SOVERSION}) - -else () - - add_library (jansson ${C_FILES}) - -endif () - -# LIBRARY for linux -# RUNTIME for windows (when building shared) -#install (TARGETS jansson -# ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} -# LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} -# RUNTIME DESTINATION bin -#) - -#install (FILES -# ${CMAKE_CURRENT_BINARY_DIR}/include/jansson_config.h -# ${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h -# DESTINATION include) - -#install (FILES -# ${CMAKE_CURRENT_BINARY_DIR}/jansson.pc -# DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) - -# For building Documentation (uses Sphinx) -# OPTION (BUILD_DOCS "Build documentation (uses python-sphinx)." ON) -# Disabled by OBS -if (FALSE) - find_package(Sphinx) - - if (NOT SPHINX_FOUND) - message(WARNING "Sphinx not found. Cannot generate documentation! - Set -DBUILD_DOCS=0 to get rid of this message.") - else() - if (Sphinx_VERSION_STRING VERSION_LESS 1.0) - message(WARNING "Your Sphinx version is too old! - This project requires Sphinx v1.0 or above to produce - proper documentation (you have v${Sphinx_VERSION_STRING}). - You will get output but it will have errors.") - endif() - - # configured documentation tools and intermediate build results - set(BINARY_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/_build") - - # Sphinx cache with pickled ReST documents - set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees") - - # CMake could be used to build the conf.py file too, - # eg it could automatically write the version of the program or change the theme. - # if(NOT DEFINED SPHINX_THEME) - # set(SPHINX_THEME default) - # endif() - # - # if(NOT DEFINED SPHINX_THEME_DIR) - # set(SPHINX_THEME_DIR) - # endif() - # - # configure_file( - # "${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in" - # "${BINARY_BUILD_DIR}/conf.py" - # @ONLY) - - # TODO: Add support for all sphinx builders: http://sphinx-doc.org/builders.html - - # Add documentation targets. - set(DOC_TARGETS html) - - OPTION(BUILD_MAN "Create a target for building man pages." ON) - - if (BUILD_MAN) - if (Sphinx_VERSION_STRING VERSION_LESS 1.0) - message(WARNING "Sphinx version 1.0 > is required to build man pages. You have v${Sphinx_VERSION_STRING}.") - else() - list(APPEND DOC_TARGETS man) - endif() - endif() - - OPTION(BUILD_LATEX "Create a target for building latex docs (to create PDF)." OFF) - - if (BUILD_LATEX) - find_package(LATEX) - - if (NOT LATEX_COMPILER) - message("Couldn't find Latex, can't build latex docs using Sphinx") - else() - message("Latex found! If you have problems building, see Sphinx documentation for required Latex packages.") - list(APPEND DOC_TARGETS latex) - endif() - endif() - - # The doc target will build all documentation targets. - add_custom_target(doc) - - foreach (DOC_TARGET ${DOC_TARGETS}) - add_custom_target(${DOC_TARGET} - ${SPHINX_EXECUTABLE} - # -q # Enable for quiet mode - -b ${DOC_TARGET} - -d "${SPHINX_CACHE_DIR}" - # -c "${BINARY_BUILD_DIR}" # enable if using cmake-generated conf.py - "${CMAKE_CURRENT_SOURCE_DIR}/doc" - "${CMAKE_CURRENT_BINARY_DIR}/doc/${DOC_TARGET}" - COMMENT "Building ${DOC_TARGET} documentation with Sphinx") - - add_dependencies(doc ${DOC_TARGET}) - endforeach() - - message("Building documentation enabled for: ${DOC_TARGETS}") - endif() -endif () - -# Disabled by OBS, we don't test this. -if (FALSE) - OPTION (TEST_WITH_VALGRIND "Enable valgrind tests." OFF) - - ENABLE_TESTING() - - if (TEST_WITH_VALGRIND) - # TODO: Add FindValgrind.cmake instead of having a hardcoded path. - - # enable valgrind - set(CMAKE_MEMORYCHECK_COMMAND valgrind) - set(CMAKE_MEMORYCHECK_COMMAND_OPTIONS - "--leak-check=full --show-reachable=yes --track-origins=yes -q") - - set(MEMCHECK_COMMAND - "${CMAKE_MEMORYCHECK_COMMAND} ${CMAKE_MEMORYCHECK_COMMAND_OPTIONS}") - separate_arguments(MEMCHECK_COMMAND) - endif () - - # - # Test suites. - # - if (CMAKE_COMPILER_IS_GNUCC) - add_definitions(-Wall -Wextra -Wdeclaration-after-statement) - endif () - - set(api_tests - test_array - test_copy - test_dump - test_dump_callback - test_equal - test_load - test_loadb - test_number - test_object - test_pack - test_simple - test_unpack) - - # Doing arithmetic on void pointers is not allowed by Microsofts compiler - # such as secure_malloc and secure_free is doing, so exclude it for now. - if (NOT MSVC) - list(APPEND api_tests test_memory_funcs) - endif() - - # Helper macro for building and linking a test program. - macro(build_testprog name dir) - add_executable(${name} ${dir}/${name}.c) - add_dependencies(${name} jansson) - target_link_libraries(${name} jansson) - endmacro(build_testprog) - - # Create executables and tests/valgrind tests for API tests. - foreach (test ${api_tests}) - build_testprog(${test} ${PROJECT_SOURCE_DIR}/test/suites/api) - add_test(${test} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test}) - - if (TEST_WITH_VALGRIND) - add_test(memcheck_${test} ${MEMCHECK_COMMAND} - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test}) - endif () - endforeach () - - # Test harness for the suites tests. - build_testprog(json_process ${PROJECT_SOURCE_DIR}/test/bin) - - set(SUITES encoding-flags valid invalid invalid-unicode) - foreach (SUITE ${SUITES}) - file(GLOB TESTDIRS ${jansson_SOURCE_DIR}/test/suites/${SUITE}/*) - foreach (TESTDIR ${TESTDIRS}) - if (IS_DIRECTORY ${TESTDIR}) - get_filename_component(TNAME ${TESTDIR} NAME) - add_test(${SUITE}__${TNAME} - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/json_process ${TESTDIR}) - if ((${SUITE} STREQUAL "valid" OR ${SUITE} STREQUAL "invalid") AND NOT EXISTS ${TESTDIR}/nostrip) - add_test(${SUITE}__${TNAME}__strip - ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/json_process --strip ${TESTDIR}) - endif () - endif () - endforeach () - endforeach () - - add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} - DEPENDS json_process ${api_tests}) -endif () - -target_include_directories(jansson - PUBLIC src "${CMAKE_CURRENT_BINARY_DIR}/include") diff --git a/deps/jansson/CleanSpec.mk b/deps/jansson/CleanSpec.mk deleted file mode 100644 index b84e1b6..0000000 --- a/deps/jansson/CleanSpec.mk +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright (C) 2007 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# If you don't need to do a full clean build but would like to touch -# a file or delete some intermediate files, add a clean step to the end -# of the list. These steps will only be run once, if they haven't been -# run before. -# -# E.g.: -# $(call add-clean-step, touch -c external/sqlite/sqlite3.h) -# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates) -# -# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with -# files that are missing or have been moved. -# -# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory. -# Use $(OUT_DIR) to refer to the "out" directory. -# -# If you need to re-do something that's already mentioned, just copy -# the command and add it to the bottom of the list. E.g., if a change -# that you made last week required touching a file and a change you -# made today requires touching the same file, just copy the old -# touch step and add it to the end of the list. -# -# ************************************************ -# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST -# ************************************************ - -# For example: -#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates) -#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates) -#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f) -#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*) - -# ************************************************ -# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST -# ************************************************ diff --git a/deps/jansson/LICENSE b/deps/jansson/LICENSE deleted file mode 100644 index a8fb5b8..0000000 --- a/deps/jansson/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2009-2013 Petri Lehtinen - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/deps/jansson/Makefile.am b/deps/jansson/Makefile.am deleted file mode 100644 index 788f9ac..0000000 --- a/deps/jansson/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -EXTRA_DIST = CHANGES LICENSE README.rst win32 CMakeLists.txt cmake -SUBDIRS = doc src test - -# "make distcheck" builds the dvi target, so use it to check that the -# documentation is built correctly. -dvi: - $(MAKE) SPHINXOPTS_EXTRA=-W html - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = jansson.pc - -if GCC -# These flags are gcc specific -export AM_CFLAGS = -Wall -Wextra -Wdeclaration-after-statement -endif diff --git a/deps/jansson/README.rst b/deps/jansson/README.rst deleted file mode 100644 index a01cbc0..0000000 --- a/deps/jansson/README.rst +++ /dev/null @@ -1,63 +0,0 @@ -Jansson README -============== - -.. image:: https://travis-ci.org/akheron/jansson.png - :alt: Build status - :target: https://travis-ci.org/akheron/jansson - -Jansson_ is a C library for encoding, decoding and manipulating JSON -data. Its main features and design principles are: - -- Simple and intuitive API and data model - -- Comprehensive documentation - -- No dependencies on other libraries - -- Full Unicode support (UTF-8) - -- Extensive test suite - -Jansson is licensed under the `MIT license`_; see LICENSE in the -source distribution for details. - - -Compilation and Installation ----------------------------- - -If you obtained a source tarball, just use the standard autotools -commands:: - - $ ./configure - $ make - $ make install - -To run the test suite, invoke:: - - $ make check - -If the source has been checked out from a Git repository, the -./configure script has to be generated first. The easiest way is to -use autoreconf:: - - $ autoreconf -i - - -Documentation -------------- - -Prebuilt HTML documentation is available at -http://www.digip.org/jansson/doc/. - -The documentation source is in the ``doc/`` subdirectory. To generate -HTML documentation, invoke:: - - $ make html - -Then, point your browser to ``doc/_build/html/index.html``. Sphinx_ -1.0 or newer is required to generate the documentation. - - -.. _Jansson: http://www.digip.org/jansson/ -.. _`MIT license`: http://www.opensource.org/licenses/mit-license.php -.. _Sphinx: http://sphinx.pocoo.org/ diff --git a/deps/jansson/android/jansson_config.h b/deps/jansson/android/jansson_config.h deleted file mode 100644 index c76940b..0000000 --- a/deps/jansson/android/jansson_config.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2010-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - * - * - * This file specifies a part of the site-specific configuration for - * Jansson, namely those things that affect the public API in - * jansson.h. - * - * The configure script copies this file to jansson_config.h and - * replaces @var@ substitutions by values that fit your system. If you - * cannot run the configure script, you can do the value substitution - * by hand. - */ - -#ifndef JANSSON_CONFIG_H -#define JANSSON_CONFIG_H - -/* If your compiler supports the inline keyword in C, JSON_INLINE is - defined to `inline', otherwise empty. In C++, the inline is always - supported. */ -#ifdef __cplusplus -#define JSON_INLINE inline -#else -#define JSON_INLINE inline -#endif - -/* If your compiler supports the `long long` type and the strtoll() - library function, JSON_INTEGER_IS_LONG_LONG is defined to 1, - otherwise to 0. */ -#define JSON_INTEGER_IS_LONG_LONG 1 - -/* If locale.h and localeconv() are available, define to 1, - otherwise to 0. */ -#define JSON_HAVE_LOCALECONV 0 - -#endif diff --git a/deps/jansson/cmake/CheckFunctionKeywords.cmake b/deps/jansson/cmake/CheckFunctionKeywords.cmake deleted file mode 100644 index 44601fd..0000000 --- a/deps/jansson/cmake/CheckFunctionKeywords.cmake +++ /dev/null @@ -1,15 +0,0 @@ -include(CheckCSourceCompiles) - -macro(check_function_keywords _wordlist) - set(${_result} "") - foreach(flag ${_wordlist}) - string(REGEX REPLACE "[-+/ ()]" "_" flagname "${flag}") - string(TOUPPER "${flagname}" flagname) - set(have_flag "HAVE_${flagname}") - check_c_source_compiles("${flag} void func(); void func() { } int main() { func(); return 0; }" ${have_flag}) - if(${have_flag} AND NOT ${_result}) - set(${_result} "${flag}") -# break() - endif(${have_flag} AND NOT ${_result}) - endforeach(flag) -endmacro(check_function_keywords) diff --git a/deps/jansson/cmake/FindSphinx.cmake b/deps/jansson/cmake/FindSphinx.cmake deleted file mode 100644 index 55539d4..0000000 --- a/deps/jansson/cmake/FindSphinx.cmake +++ /dev/null @@ -1,301 +0,0 @@ -# -# PART B. DOWNLOADING AGREEMENT - LICENSE FROM SBIA WITH RIGHT TO SUBLICENSE ("SOFTWARE LICENSE"). -# ------------------------------------------------------------------------------------------------ -# -# 1. As used in this Software License, "you" means the individual downloading and/or -# using, reproducing, modifying, displaying and/or distributing the Software and -# the institution or entity which employs or is otherwise affiliated with such -# individual in connection therewith. The Section of Biomedical Image Analysis, -# Department of Radiology at the Universiy of Pennsylvania ("SBIA") hereby grants -# you, with right to sublicense, with respect to SBIA's rights in the software, -# and data, if any, which is the subject of this Software License (collectively, -# the "Software"), a royalty-free, non-exclusive license to use, reproduce, make -# derivative works of, display and distribute the Software, provided that: -# (a) you accept and adhere to all of the terms and conditions of this Software -# License; (b) in connection with any copy of or sublicense of all or any portion -# of the Software, all of the terms and conditions in this Software License shall -# appear in and shall apply to such copy and such sublicense, including without -# limitation all source and executable forms and on any user documentation, -# prefaced with the following words: "All or portions of this licensed product -# (such portions are the "Software") have been obtained under license from the -# Section of Biomedical Image Analysis, Department of Radiology at the University -# of Pennsylvania and are subject to the following terms and conditions:" -# (c) you preserve and maintain all applicable attributions, copyright notices -# and licenses included in or applicable to the Software; (d) modified versions -# of the Software must be clearly identified and marked as such, and must not -# be misrepresented as being the original Software; and (e) you consider making, -# but are under no obligation to make, the source code of any of your modifications -# to the Software freely available to others on an open source basis. -# -# 2. The license granted in this Software License includes without limitation the -# right to (i) incorporate the Software into proprietary programs (subject to -# any restrictions applicable to such programs), (ii) add your own copyright -# statement to your modifications of the Software, and (iii) provide additional -# or different license terms and conditions in your sublicenses of modifications -# of the Software; provided that in each case your use, reproduction or -# distribution of such modifications otherwise complies with the conditions -# stated in this Software License. -# -# 3. This Software License does not grant any rights with respect to third party -# software, except those rights that SBIA has been authorized by a third -# party to grant to you, and accordingly you are solely responsible for -# (i) obtaining any permissions from third parties that you need to use, -# reproduce, make derivative works of, display and distribute the Software, -# and (ii) informing your sublicensees, including without limitation your -# end-users, of their obligations to secure any such required permissions. -# -# 4. The Software has been designed for research purposes only and has not been -# reviewed or approved by the Food and Drug Administration or by any other -# agency. YOU ACKNOWLEDGE AND AGREE THAT CLINICAL APPLICATIONS ARE NEITHER -# RECOMMENDED NOR ADVISED. Any commercialization of the Software is at the -# sole risk of the party or parties engaged in such commercialization. -# You further agree to use, reproduce, make derivative works of, display -# and distribute the Software in compliance with all applicable governmental -# laws, regulations and orders, including without limitation those relating -# to export and import control. -# -# 5. The Software is provided "AS IS" and neither SBIA nor any contributor to -# the software (each a "Contributor") shall have any obligation to provide -# maintenance, support, updates, enhancements or modifications thereto. -# SBIA AND ALL CONTRIBUTORS SPECIFICALLY DISCLAIM ALL EXPRESS AND IMPLIED -# WARRANTIES OF ANY KIND INCLUDING, BUT NOT LIMITED TO, ANY WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -# IN NO EVENT SHALL SBIA OR ANY CONTRIBUTOR BE LIABLE TO ANY PARTY FOR -# DIRECT, INDIRECT, SPECIAL, INCIDENTAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY ARISING IN ANY WAY RELATED -# TO THE SOFTWARE, EVEN IF SBIA OR ANY CONTRIBUTOR HAS BEEN ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGES. TO THE MAXIMUM EXTENT NOT PROHIBITED BY LAW OR -# REGULATION, YOU FURTHER ASSUME ALL LIABILITY FOR YOUR USE, REPRODUCTION, -# MAKING OF DERIVATIVE WORKS, DISPLAY, LICENSE OR DISTRIBUTION OF THE SOFTWARE -# AND AGREE TO INDEMNIFY AND HOLD HARMLESS SBIA AND ALL CONTRIBUTORS FROM -# AND AGAINST ANY AND ALL CLAIMS, SUITS, ACTIONS, DEMANDS AND JUDGMENTS ARISING -# THEREFROM. -# -# 6. None of the names, logos or trademarks of SBIA or any of SBIA's affiliates -# or any of the Contributors, or any funding agency, may be used to endorse -# or promote products produced in whole or in part by operation of the Software -# or derived from or based on the Software without specific prior written -# permission from the applicable party. -# -# 7. Any use, reproduction or distribution of the Software which is not in accordance -# with this Software License shall automatically revoke all rights granted to you -# under this Software License and render Paragraphs 1 and 2 of this Software -# License null and void. -# -# 8. This Software License does not grant any rights in or to any intellectual -# property owned by SBIA or any Contributor except those rights expressly -# granted hereunder. -# -# -# PART C. MISCELLANEOUS -# --------------------- -# -# This Agreement shall be governed by and construed in accordance with the laws -# of The Commonwealth of Pennsylvania without regard to principles of conflicts -# of law. This Agreement shall supercede and replace any license terms that you -# may have agreed to previously with respect to Software from SBIA. -# -############################################################################## -# @file FindSphinx.cmake -# @brief Find Sphinx documentation build tools. -# -# @par Input variables: -# -# -# @tp @b Sphinx_DIR @endtp -# -# -# -# @tp @b SPHINX_DIR @endtp -# -# -# -# @tp @b Sphinx_FIND_COMPONENTS @endtp -# -# -#
Installation directory of Sphinx tools. Can also be set as environment variable.
Alternative environment variable for @c Sphinx_DIR.
Sphinx build tools to look for, i.e., 'apidoc' and/or 'build'.
-# -# @par Output variables: -# -# -# @tp @b Sphinx_FOUND @endtp -# -# -# -# @tp @b SPHINX_FOUND @endtp -# -# -# @tp @b SPHINX_EXECUTABLE @endtp -# -# -# -# @tp @b Sphinx_PYTHON_EXECUTABLE @endtp -# -# -# -# @tp @b Sphinx_PYTHON_OPTIONS @endtp -# -# -# -# @tp @b Sphinx-build_EXECUTABLE @endtp -# -# -# -# @tp @b Sphinx-apidoc_EXECUTABLE @endtp -# -# -# -# @tp @b Sphinx_VERSION_STRING @endtp -# -# -# -# @tp @b Sphinx_VERSION_MAJOR @endtp -# -# -# -# @tp @b Sphinx_VERSION_MINOR @endtp -# -# -# -# @tp @b Sphinx_VERSION_PATCH @endtp -# -# -#
Whether all or only the requested Sphinx build tools were found.
Alias for @c Sphinx_FOUND. -#
Non-cached alias for @c Sphinx-build_EXECUTABLE.
Python executable used to run sphinx-build. This is either the -# by default found Python interpreter or a specific version as -# specified by the shebang (#!) of the sphinx-build script.
A list of Python options extracted from the shebang (#!) of the -# sphinx-build script. The -E option is added by this module -# if the Python executable is not the system default to avoid -# problems with a differing setting of the @c PYTHONHOME.
Absolute path of the found sphinx-build tool.
Absolute path of the found sphinx-apidoc tool.
Sphinx version found e.g. 1.1.2.
Sphinx major version found e.g. 1.
Sphinx minor version found e.g. 1.
Sphinx patch version found e.g. 2.
-# -# @ingroup CMakeFindModules -############################################################################## - -set (_Sphinx_REQUIRED_VARS) - -# ---------------------------------------------------------------------------- -# initialize search -if (NOT Sphinx_DIR) - if (NOT $ENV{Sphinx_DIR} STREQUAL "") - set (Sphinx_DIR "$ENV{Sphinx_DIR}" CACHE PATH "Installation prefix of Sphinx (docutils)." FORCE) - else () - set (Sphinx_DIR "$ENV{SPHINX_DIR}" CACHE PATH "Installation prefix of Sphinx (docutils)." FORCE) - endif () -endif () - -# ---------------------------------------------------------------------------- -# default components to look for -if (NOT Sphinx_FIND_COMPONENTS) - set (Sphinx_FIND_COMPONENTS "build") -elseif (NOT Sphinx_FIND_COMPONENTS MATCHES "^(build|apidoc)$") - message (FATAL_ERROR "Invalid Sphinx component in: ${Sphinx_FIND_COMPONENTS}") -endif () - -# ---------------------------------------------------------------------------- -# find components, i.e., build tools -foreach (_Sphinx_TOOL IN LISTS Sphinx_FIND_COMPONENTS) - if (Sphinx_DIR) - find_program ( - Sphinx-${_Sphinx_TOOL}_EXECUTABLE - NAMES sphinx-${_Sphinx_TOOL} sphinx-${_Sphinx_TOOL}.py - HINTS "${Sphinx_DIR}" - PATH_SUFFIXES bin - DOC "The sphinx-${_Sphinx_TOOL} Python script." - NO_DEFAULT_PATH - ) - else () - find_program ( - Sphinx-${_Sphinx_TOOL}_EXECUTABLE - NAMES sphinx-${_Sphinx_TOOL} sphinx-${_Sphinx_TOOL}.py - DOC "The sphinx-${_Sphinx_TOOL} Python script." - ) - endif () - mark_as_advanced (Sphinx-${_Sphinx_TOOL}_EXECUTABLE) - list (APPEND _Sphinx_REQUIRED_VARS Sphinx-${_Sphinx_TOOL}_EXECUTABLE) -endforeach () - -# ---------------------------------------------------------------------------- -# determine Python executable used by Sphinx -if (Sphinx-build_EXECUTABLE) - # extract python executable from shebang of sphinx-build - find_package (PythonInterp QUIET) - set (Sphinx_PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}") - set (Sphinx_PYTHON_OPTIONS) - file (STRINGS "${Sphinx-build_EXECUTABLE}" FIRST_LINE LIMIT_COUNT 1) - if (FIRST_LINE MATCHES "^#!(.*/python.*)") # does not match "#!/usr/bin/env python" ! - string (REGEX REPLACE "^ +| +$" "" Sphinx_PYTHON_EXECUTABLE "${CMAKE_MATCH_1}") - if (Sphinx_PYTHON_EXECUTABLE MATCHES "([^ ]+) (.*)") - set (Sphinx_PYTHON_EXECUTABLE "${CMAKE_MATCH_1}") - string (REGEX REPLACE " +" ";" Sphinx_PYTHON_OPTIONS "${CMAKE_MATCH_2}") - endif () - endif () - # this is done to avoid problems with multiple Python versions being installed - # remember: CMake command if(STR EQUAL STR) is bad and may cause many troubles ! - string (REGEX REPLACE "([.+*?^$])" "\\\\\\1" _Sphinx_PYTHON_EXECUTABLE_RE "${PYTHON_EXECUTABLE}") - list (FIND Sphinx_PYTHON_OPTIONS -E IDX) - if (IDX EQUAL -1 AND NOT Sphinx_PYTHON_EXECUTABLE MATCHES "^${_Sphinx_PYTHON_EXECUTABLE_RE}$") - list (INSERT Sphinx_PYTHON_OPTIONS 0 -E) - endif () - unset (_Sphinx_PYTHON_EXECUTABLE_RE) -endif () - -# ---------------------------------------------------------------------------- -# determine Sphinx version -if (Sphinx-build_EXECUTABLE) - # intentionally use invalid -h option here as the help that is shown then - # will include the Sphinx version information - if (Sphinx_PYTHON_EXECUTABLE) - execute_process ( - COMMAND "${Sphinx_PYTHON_EXECUTABLE}" ${Sphinx_PYTHON_OPTIONS} "${Sphinx-build_EXECUTABLE}" -h - OUTPUT_VARIABLE _Sphinx_VERSION - ERROR_VARIABLE _Sphinx_VERSION - ) - elseif (UNIX) - execute_process ( - COMMAND "${Sphinx-build_EXECUTABLE}" -h - OUTPUT_VARIABLE _Sphinx_VERSION - ERROR_VARIABLE _Sphinx_VERSION - ) - endif () - - # The sphinx version can also contain a "b" instead of the last dot. - # For example "Sphinx v1.2b1" so we cannot just split on "." - if (_Sphinx_VERSION MATCHES "Sphinx v([0-9]+\\.[0-9]+(\\.|b)[0-9]+)") - set (Sphinx_VERSION_STRING "${CMAKE_MATCH_1}") - string(REGEX REPLACE "([0-9]+)\\.[0-9]+(\\.|b)[0-9]+" "\\1" Sphinx_VERSION_MAJOR ${Sphinx_VERSION_STRING}) - string(REGEX REPLACE "[0-9]+\\.([0-9]+)(\\.|b)[0-9]+" "\\1" Sphinx_VERSION_MINOR ${Sphinx_VERSION_STRING}) - string(REGEX REPLACE "[0-9]+\\.[0-9]+(\\.|b)([0-9]+)" "\\1" Sphinx_VERSION_PATCH ${Sphinx_VERSION_STRING}) - - # v1.2.0 -> v1.2 - if (Sphinx_VERSION_PATCH EQUAL 0) - string (REGEX REPLACE "\\.0$" "" Sphinx_VERSION_STRING "${Sphinx_VERSION_STRING}") - endif () - endif() -endif () - -# ---------------------------------------------------------------------------- -# compatibility with FindPythonInterp.cmake and FindPerl.cmake -set (SPHINX_EXECUTABLE "${Sphinx-build_EXECUTABLE}") - -# ---------------------------------------------------------------------------- -# handle the QUIETLY and REQUIRED arguments and set SPHINX_FOUND to TRUE if -# all listed variables are TRUE -include (FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS ( - Sphinx - REQUIRED_VARS - ${_Sphinx_REQUIRED_VARS} -# VERSION_VAR # This isn't available until CMake 2.8.8 so don't use it. - Sphinx_VERSION_STRING -) - -# ---------------------------------------------------------------------------- -# set Sphinx_DIR -if (NOT Sphinx_DIR AND Sphinx-build_EXECUTABLE) - get_filename_component (Sphinx_DIR "${Sphinx-build_EXECUTABLE}" PATH) - string (REGEX REPLACE "/bin/?" "" Sphinx_DIR "${Sphinx_DIR}") - set (Sphinx_DIR "${Sphinx_DIR}" CACHE PATH "Installation directory of Sphinx tools." FORCE) -endif () - -unset (_Sphinx_VERSION) -unset (_Sphinx_REQUIRED_VARS) \ No newline at end of file diff --git a/deps/jansson/cmake/config.h.cmake b/deps/jansson/cmake/config.h.cmake deleted file mode 100644 index bc81178..0000000 --- a/deps/jansson/cmake/config.h.cmake +++ /dev/null @@ -1,45 +0,0 @@ -/* Reduced down to the defines that are actually used in the code */ - -/* Define to 1 if you have the (and friends) header file. */ -#cmakedefine HAVE_INTTYPES_H 1 -#cmakedefine HAVE_STDINT_H 1 -#cmakedefine HAVE_SYS_TYPES_H 1 - -/* We must include this here, as in (eg) utf.h it will want to use - the integer type, which in MSVC2010 will be in stdint.h - (there is no inttypes.h in MSVC2010) */ -#if defined(HAVE_STDINT_H) -# include -#elif defined(HAVE_INTTYPES_H) -# include -#elif defined(HAVE_SYS_TYPES_H) -# include -#endif - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_LOCALE_H 1 - -/* Define to 1 if you have the 'setlocale' function. */ -#cmakedefine HAVE_SETLOCALE 1 - -/* Define to the type of a signed integer type of width exactly 32 bits if - such a type exists and the standard includes do not define it. */ -#cmakedefine HAVE_INT32_T 1 - -#ifndef HAVE_INT32_T -# define int32_t @JSON_INT32@ -#endif - -#cmakedefine HAVE_SSIZE_T 1 - -#ifndef HAVE_SSIZE_T -# define ssize_t @JSON_SSIZE@ -#endif - -#cmakedefine HAVE_SNPRINTF 1 - -#ifndef HAVE_SNPRINTF -# define snprintf @JSON_SNPRINTF@ -#endif - -#cmakedefine HAVE_VSNPRINTF diff --git a/deps/jansson/cmake/jansson_config.h.cmake b/deps/jansson/cmake/jansson_config.h.cmake deleted file mode 100644 index 8c500b5..0000000 --- a/deps/jansson/cmake/jansson_config.h.cmake +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2010-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - * - * - * This file specifies a part of the site-specific configuration for - * Jansson, namely those things that affect the public API in - * jansson.h. - * - * The CMake system will generate the jansson_config.h file and - * copy it to the build and install directories. - */ - -#ifndef JANSSON_CONFIG_H -#define JANSSON_CONFIG_H - -/* Define this so that we can disable scattered automake configuration in source files */ -#define JANSSON_USING_CMAKE - -/* Note: when using cmake, JSON_INTEGER_IS_LONG_LONG is not defined nor used, - * as we will also check for __int64 etc types. - * (the definition was used in the automake system) */ - -/* Bring in the cmake-detected defines */ -#cmakedefine HAVE_STDINT_H 1 -#cmakedefine HAVE_INTTYPES_H 1 -#cmakedefine HAVE_SYS_TYPES_H 1 - -/* Include our standard type header for the integer typedef */ - -#if defined(HAVE_STDINT_H) -# include -#elif defined(HAVE_INTTYPES_H) -# include -#elif defined(HAVE_SYS_TYPES_H) -# include -#endif - - -/* If your compiler supports the inline keyword in C, JSON_INLINE is - defined to `inline', otherwise empty. In C++, the inline is always - supported. */ -#ifdef __cplusplus -#define JSON_INLINE inline -#else -#define JSON_INLINE @JSON_INLINE@ -#endif - - -#define json_int_t @JSON_INT_T@ -#define json_strtoint @JSON_STRTOINT@ -#define JSON_INTEGER_FORMAT @JSON_INTEGER_FORMAT@ - - -/* If locale.h and localeconv() are available, define to 1, otherwise to 0. */ -#define JSON_HAVE_LOCALECONV @JSON_HAVE_LOCALECONV@ - - - -#endif diff --git a/deps/jansson/configure.ac b/deps/jansson/configure.ac deleted file mode 100644 index 24ba37d..0000000 --- a/deps/jansson/configure.ac +++ /dev/null @@ -1,57 +0,0 @@ -AC_PREREQ([2.60]) -AC_INIT([jansson], [2.5], [petri@digip.org]) - -AM_INIT_AUTOMAKE([1.10 foreign]) - -AC_CONFIG_SRCDIR([src/value.c]) -AC_CONFIG_HEADERS([config.h]) - -# Checks for programs. -AC_PROG_CC -AC_PROG_LIBTOOL -AM_CONDITIONAL([GCC], [test x$GCC = xyes]) - -# Checks for libraries. - -# Checks for header files. -AC_CHECK_HEADERS([locale.h]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_TYPE_INT32_T -AC_TYPE_LONG_LONG_INT - -AC_C_INLINE -case $ac_cv_c_inline in - yes) json_inline=inline;; - no) json_inline=;; - *) json_inline=$ac_cv_c_inline;; -esac -AC_SUBST([json_inline]) - -# Checks for library functions. -AC_CHECK_FUNCS([strtoll localeconv]) - -case "$ac_cv_type_long_long_int$ac_cv_func_strtoll" in - yesyes) json_have_long_long=1;; - *) json_have_long_long=0;; -esac -AC_SUBST([json_have_long_long]) - -case "$ac_cv_header_locale_h$ac_cv_func_localeconv" in - yesyes) json_have_localeconv=1;; - *) json_have_localeconv=0;; -esac -AC_SUBST([json_have_localeconv]) - -AC_CONFIG_FILES([ - jansson.pc - Makefile - doc/Makefile - src/Makefile - src/jansson_config.h - test/Makefile - test/bin/Makefile - test/suites/Makefile - test/suites/api/Makefile -]) -AC_OUTPUT diff --git a/deps/jansson/doc/.gitignore b/deps/jansson/doc/.gitignore deleted file mode 100644 index 69fa449..0000000 --- a/deps/jansson/doc/.gitignore +++ /dev/null @@ -1 +0,0 @@ -_build/ diff --git a/deps/jansson/doc/Makefile.am b/deps/jansson/doc/Makefile.am deleted file mode 100644 index 5069623..0000000 --- a/deps/jansson/doc/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -EXTRA_DIST = conf.py apiref.rst changes.rst conformance.rst \ - gettingstarted.rst github_commits.c index.rst portability.rst \ - tutorial.rst upgrading.rst ext/refcounting.py - -SPHINXBUILD = sphinx-build -SPHINXOPTS = -d _build/doctrees $(SPHINXOPTS_EXTRA) - -html-local: - $(SPHINXBUILD) -b html $(SPHINXOPTS) $(srcdir) _build/html - -install-html-local: html - mkdir -p $(DESTDIR)$(htmldir) - cp -r _build/html $(DESTDIR)$(htmldir) - -uninstall-local: - rm -rf $(DESTDIR)$(htmldir) - -clean-local: - rm -rf _build - rm -f ext/refcounting.pyc diff --git a/deps/jansson/doc/README b/deps/jansson/doc/README deleted file mode 100644 index 930b3bf..0000000 --- a/deps/jansson/doc/README +++ /dev/null @@ -1,5 +0,0 @@ -To build the documentation, invoke - - make html - -Then point your browser to _build/html/index.html. diff --git a/deps/jansson/doc/apiref.rst b/deps/jansson/doc/apiref.rst deleted file mode 100644 index 717e140..0000000 --- a/deps/jansson/doc/apiref.rst +++ /dev/null @@ -1,1560 +0,0 @@ -.. _apiref: - -************* -API Reference -************* - -.. highlight:: c - -Preliminaries -============= - -All declarations are in :file:`jansson.h`, so it's enough to - -:: - - #include - -in each source file. - -All constants are prefixed with ``JSON_`` (except for those describing -the library version, prefixed with ``JANSSON_``). Other identifiers -are prefixed with ``json_``. Type names are suffixed with ``_t`` and -``typedef``\ 'd so that the ``struct`` keyword need not be used. - - -Library Version -=============== - -The Jansson version is of the form *A.B.C*, where *A* is the major -version, *B* is the minor version and *C* is the micro version. If the -micro version is zero, it's omitted from the version string, i.e. the -version string is just *A.B*. - -When a new release only fixes bugs and doesn't add new features or -functionality, the micro version is incremented. When new features are -added in a backwards compatible way, the minor version is incremented -and the micro version is set to zero. When there are backwards -incompatible changes, the major version is incremented and others are -set to zero. - -The following preprocessor constants specify the current version of -the library: - -``JANSSON_MAJOR_VERSION``, ``JANSSON_MINOR_VERSION``, ``JANSSON_MICRO_VERSION`` - Integers specifying the major, minor and micro versions, - respectively. - -``JANSSON_VERSION`` - A string representation of the current version, e.g. ``"1.2.1"`` or - ``"1.3"``. - -``JANSSON_VERSION_HEX`` - A 3-byte hexadecimal representation of the version, e.g. - ``0x010201`` for version 1.2.1 and ``0x010300`` for version 1.3. - This is useful in numeric comparisions, e.g.:: - - #if JANSSON_VERSION_HEX >= 0x010300 - /* Code specific to version 1.3 and above */ - #endif - - -Value Representation -==================== - -The JSON specification (:rfc:`4627`) defines the following data types: -*object*, *array*, *string*, *number*, *boolean*, and *null*. JSON -types are used dynamically; arrays and objects can hold any other data -type, including themselves. For this reason, Jansson's type system is -also dynamic in nature. There's one C type to represent all JSON -values, and this structure knows the type of the JSON value it holds. - -.. type:: json_t - - This data structure is used throughout the library to represent all - JSON values. It always contains the type of the JSON value it holds - and the value's reference count. The rest depends on the type of the - value. - -Objects of :type:`json_t` are always used through a pointer. There -are APIs for querying the type, manipulating the reference count, and -for constructing and manipulating values of different types. - -Unless noted otherwise, all API functions return an error value if an -error occurs. Depending on the function's signature, the error value -is either *NULL* or -1. Invalid arguments or invalid input are -apparent sources for errors. Memory allocation and I/O operations may -also cause errors. - - -Type ----- - -The type of a JSON value is queried and tested using the following -functions: - -.. type:: enum json_type - - The type of a JSON value. The following members are defined: - - +--------------------+ - | ``JSON_OBJECT`` | - +--------------------+ - | ``JSON_ARRAY`` | - +--------------------+ - | ``JSON_STRING`` | - +--------------------+ - | ``JSON_INTEGER`` | - +--------------------+ - | ``JSON_REAL`` | - +--------------------+ - | ``JSON_TRUE`` | - +--------------------+ - | ``JSON_FALSE`` | - +--------------------+ - | ``JSON_NULL`` | - +--------------------+ - - These correspond to JSON object, array, string, number, boolean and - null. A number is represented by either a value of the type - ``JSON_INTEGER`` or of the type ``JSON_REAL``. A true boolean value - is represented by a value of the type ``JSON_TRUE`` and false by a - value of the type ``JSON_FALSE``. - -.. function:: int json_typeof(const json_t *json) - - Return the type of the JSON value (a :type:`json_type` cast to - :type:`int`). *json* MUST NOT be *NULL*. This function is actually - implemented as a macro for speed. - -.. function:: json_is_object(const json_t *json) - json_is_array(const json_t *json) - json_is_string(const json_t *json) - json_is_integer(const json_t *json) - json_is_real(const json_t *json) - json_is_true(const json_t *json) - json_is_false(const json_t *json) - json_is_null(const json_t *json) - - These functions (actually macros) return true (non-zero) for values - of the given type, and false (zero) for values of other types and - for *NULL*. - -.. function:: json_is_number(const json_t *json) - - Returns true for values of types ``JSON_INTEGER`` and - ``JSON_REAL``, and false for other types and for *NULL*. - -.. function:: json_is_boolean(const json_t *json) - - Returns true for types ``JSON_TRUE`` and ``JSON_FALSE``, and false - for values of other types and for *NULL*. - -.. function:: json_boolean_value(const json_t *json) - - Alias of :func:`json_is_true()`, i.e. returns 1 for ``JSON_TRUE`` - and 0 otherwise. - - -.. _apiref-reference-count: - -Reference Count ---------------- - -The reference count is used to track whether a value is still in use -or not. When a value is created, it's reference count is set to 1. If -a reference to a value is kept (e.g. a value is stored somewhere for -later use), its reference count is incremented, and when the value is -no longer needed, the reference count is decremented. When the -reference count drops to zero, there are no references left, and the -value can be destroyed. - -The following functions are used to manipulate the reference count. - -.. function:: json_t *json_incref(json_t *json) - - Increment the reference count of *json* if it's not *NULL*. - Returns *json*. - -.. function:: void json_decref(json_t *json) - - Decrement the reference count of *json*. As soon as a call to - :func:`json_decref()` drops the reference count to zero, the value - is destroyed and it can no longer be used. - -Functions creating new JSON values set the reference count to 1. These -functions are said to return a **new reference**. Other functions -returning (existing) JSON values do not normally increase the -reference count. These functions are said to return a **borrowed -reference**. So, if the user will hold a reference to a value returned -as a borrowed reference, he must call :func:`json_incref`. As soon as -the value is no longer needed, :func:`json_decref` should be called -to release the reference. - -Normally, all functions accepting a JSON value as an argument will -manage the reference, i.e. increase and decrease the reference count -as needed. However, some functions **steal** the reference, i.e. they -have the same result as if the user called :func:`json_decref()` on -the argument right after calling the function. These functions are -suffixed with ``_new`` or have ``_new_`` somewhere in their name. - -For example, the following code creates a new JSON array and appends -an integer to it:: - - json_t *array, *integer; - - array = json_array(); - integer = json_integer(42); - - json_array_append(array, integer); - json_decref(integer); - -Note how the caller has to release the reference to the integer value -by calling :func:`json_decref()`. By using a reference stealing -function :func:`json_array_append_new()` instead of -:func:`json_array_append()`, the code becomes much simpler:: - - json_t *array = json_array(); - json_array_append_new(array, json_integer(42)); - -In this case, the user doesn't have to explicitly release the -reference to the integer value, as :func:`json_array_append_new()` -steals the reference when appending the value to the array. - -In the following sections it is clearly documented whether a function -will return a new or borrowed reference or steal a reference to its -argument. - - -Circular References -------------------- - -A circular reference is created when an object or an array is, -directly or indirectly, inserted inside itself. The direct case is -simple:: - - json_t *obj = json_object(); - json_object_set(obj, "foo", obj); - -Jansson will refuse to do this, and :func:`json_object_set()` (and -all the other such functions for objects and arrays) will return with -an error status. The indirect case is the dangerous one:: - - json_t *arr1 = json_array(), *arr2 = json_array(); - json_array_append(arr1, arr2); - json_array_append(arr2, arr1); - -In this example, the array ``arr2`` is contained in the array -``arr1``, and vice versa. Jansson cannot check for this kind of -indirect circular references without a performance hit, so it's up to -the user to avoid them. - -If a circular reference is created, the memory consumed by the values -cannot be freed by :func:`json_decref()`. The reference counts never -drops to zero because the values are keeping the references to each -other. Moreover, trying to encode the values with any of the encoding -functions will fail. The encoder detects circular references and -returns an error status. - - -True, False and Null -==================== - -These three values are implemented as singletons, so the returned -pointers won't change between invocations of these functions. - -.. function:: json_t *json_true(void) - - .. refcounting:: new - - Returns the JSON true value. - -.. function:: json_t *json_false(void) - - .. refcounting:: new - - Returns the JSON false value. - -.. function:: json_t *json_boolean(val) - - .. refcounting:: new - - Returns JSON false if ``val`` is zero, and JSON true otherwise. - This is a macro, and equivalent to ``val ? json_true() : - json_false()``. - - .. versionadded:: 2.4 - - -.. function:: json_t *json_null(void) - - .. refcounting:: new - - Returns the JSON null value. - - -String -====== - -Jansson uses UTF-8 as the character encoding. All JSON strings must be -valid UTF-8 (or ASCII, as it's a subset of UTF-8). Normal null -terminated C strings are used, so JSON strings may not contain -embedded null characters. All other Unicode codepoints U+0000 through -U+10FFFF are allowed, but you must use length-aware functions if you -wish to embed NUL bytes in strings. - -.. function:: json_t *json_string(const char *value) - - .. refcounting:: new - - Returns a new JSON string, or *NULL* on error. *value* must be a - valid UTF-8 encoded Unicode string. - -.. function:: json_t *json_stringn(const char *value, size_t len) - - .. refcounting:: new - - Like :func:`json_string`, but with explicit length, so *value* may - contain null characters or not be null terminated. - -.. function:: json_t *json_string_nocheck(const char *value) - - .. refcounting:: new - - Like :func:`json_string`, but doesn't check that *value* is valid - UTF-8. Use this function only if you are certain that this really - is the case (e.g. you have already checked it by other means). - -.. function:: json_t *json_stringn_nocheck(const char *value, size_t len) - - .. refcounting:: new - - Like :func:`json_string_nocheck`, but with explicit length, so - *value* may contain null characters or not be null terminated. - -.. function:: const char *json_string_value(const json_t *string) - - Returns the associated value of *string* as a null terminated UTF-8 - encoded string, or *NULL* if *string* is not a JSON string. - - The retuned value is read-only and must not be modified or freed by - the user. It is valid as long as *string* exists, i.e. as long as - its reference count has not dropped to zero. - -.. function:: size_t json_string_length(const json_t *string) - - Returns the length of *string* in its UTF-8 presentation, or zero - if *string* is not a JSON string. - -.. function:: int json_string_set(const json_t *string, const char *value) - - Sets the associated value of *string* to *value*. *value* must be a - valid UTF-8 encoded Unicode string. Returns 0 on success and -1 on - error. - -.. function:: int json_string_setn(json_t *string, const char *value, size_t len) - - Like :func:`json_string_set`, but with explicit length, so *value* - may contain null characters or not be null terminated. - -.. function:: int json_string_set_nocheck(const json_t *string, const char *value) - - Like :func:`json_string_set`, but doesn't check that *value* is - valid UTF-8. Use this function only if you are certain that this - really is the case (e.g. you have already checked it by other - means). - -.. function:: int json_string_setn_nocheck(json_t *string, const char *value, size_t len) - - Like :func:`json_string_set_nocheck`, but with explicit length, - so *value* may contain null characters or not be null terminated. - - -Number -====== - -The JSON specification only contains one numeric type, "number". The C -programming language has distinct types for integer and floating-point -numbers, so for practical reasons Jansson also has distinct types for -the two. They are called "integer" and "real", respectively. For more -information, see :ref:`rfc-conformance`. - -.. type:: json_int_t - - This is the C type that is used to store JSON integer values. It - represents the widest integer type available on your system. In - practice it's just a typedef of ``long long`` if your compiler - supports it, otherwise ``long``. - - Usually, you can safely use plain ``int`` in place of - ``json_int_t``, and the implicit C integer conversion handles the - rest. Only when you know that you need the full 64-bit range, you - should use ``json_int_t`` explicitly. - -``JSON_INTEGER_IS_LONG_LONG`` - This is a preprocessor variable that holds the value 1 if - :type:`json_int_t` is ``long long``, and 0 if it's ``long``. It - can be used as follows:: - - #if JSON_INTEGER_IS_LONG_LONG - /* Code specific for long long */ - #else - /* Code specific for long */ - #endif - -``JSON_INTEGER_FORMAT`` - This is a macro that expands to a :func:`printf()` conversion - specifier that corresponds to :type:`json_int_t`, without the - leading ``%`` sign, i.e. either ``"lld"`` or ``"ld"``. This macro - is required because the actual type of :type:`json_int_t` can be - either ``long`` or ``long long``, and :func:`printf()` reuiqres - different length modifiers for the two. - - Example:: - - json_int_t x = 123123123; - printf("x is %" JSON_INTEGER_FORMAT "\n", x); - - -.. function:: json_t *json_integer(json_int_t value) - - .. refcounting:: new - - Returns a new JSON integer, or *NULL* on error. - -.. function:: json_int_t json_integer_value(const json_t *integer) - - Returns the associated value of *integer*, or 0 if *json* is not a - JSON integer. - -.. function:: int json_integer_set(const json_t *integer, json_int_t value) - - Sets the associated value of *integer* to *value*. Returns 0 on - success and -1 if *integer* is not a JSON integer. - -.. function:: json_t *json_real(double value) - - .. refcounting:: new - - Returns a new JSON real, or *NULL* on error. - -.. function:: double json_real_value(const json_t *real) - - Returns the associated value of *real*, or 0.0 if *real* is not a - JSON real. - -.. function:: int json_real_set(const json_t *real, double value) - - Sets the associated value of *real* to *value*. Returns 0 on - success and -1 if *real* is not a JSON real. - -In addition to the functions above, there's a common query function -for integers and reals: - -.. function:: double json_number_value(const json_t *json) - - Returns the associated value of the JSON integer or JSON real - *json*, cast to double regardless of the actual type. If *json* is - neither JSON real nor JSON integer, 0.0 is returned. - - -Array -===== - -A JSON array is an ordered collection of other JSON values. - -.. function:: json_t *json_array(void) - - .. refcounting:: new - - Returns a new JSON array, or *NULL* on error. Initially, the array - is empty. - -.. function:: size_t json_array_size(const json_t *array) - - Returns the number of elements in *array*, or 0 if *array* is NULL - or not a JSON array. - -.. function:: json_t *json_array_get(const json_t *array, size_t index) - - .. refcounting:: borrow - - Returns the element in *array* at position *index*. The valid range - for *index* is from 0 to the return value of - :func:`json_array_size()` minus 1. If *array* is not a JSON array, - if *array* is *NULL*, or if *index* is out of range, *NULL* is - returned. - -.. function:: int json_array_set(json_t *array, size_t index, json_t *value) - - Replaces the element in *array* at position *index* with *value*. - The valid range for *index* is from 0 to the return value of - :func:`json_array_size()` minus 1. Returns 0 on success and -1 on - error. - -.. function:: int json_array_set_new(json_t *array, size_t index, json_t *value) - - Like :func:`json_array_set()` but steals the reference to *value*. - This is useful when *value* is newly created and not used after - the call. - -.. function:: int json_array_append(json_t *array, json_t *value) - - Appends *value* to the end of *array*, growing the size of *array* - by 1. Returns 0 on success and -1 on error. - -.. function:: int json_array_append_new(json_t *array, json_t *value) - - Like :func:`json_array_append()` but steals the reference to - *value*. This is useful when *value* is newly created and not used - after the call. - -.. function:: int json_array_insert(json_t *array, size_t index, json_t *value) - - Inserts *value* to *array* at position *index*, shifting the - elements at *index* and after it one position towards the end of - the array. Returns 0 on success and -1 on error. - -.. function:: int json_array_insert_new(json_t *array, size_t index, json_t *value) - - Like :func:`json_array_insert()` but steals the reference to - *value*. This is useful when *value* is newly created and not used - after the call. - -.. function:: int json_array_remove(json_t *array, size_t index) - - Removes the element in *array* at position *index*, shifting the - elements after *index* one position towards the start of the array. - Returns 0 on success and -1 on error. The reference count of the - removed value is decremented. - -.. function:: int json_array_clear(json_t *array) - - Removes all elements from *array*. Returns 0 on sucess and -1 on - error. The reference count of all removed values are decremented. - -.. function:: int json_array_extend(json_t *array, json_t *other_array) - - Appends all elements in *other_array* to the end of *array*. - Returns 0 on success and -1 on error. - -The following macro can be used to iterate through all elements -in an array. - -.. function:: json_array_foreach(array, index, value) - - Iterate over every element of ``array``, running the block - of code that follows each time with the proper values set to - variables ``index`` and ``value``, of types :type:`size_t` and - :type:`json_t *` respectively. Example:: - - /* array is a JSON array */ - size_t index; - json_t *value; - - json_array_foreach(array, index, value) { - /* block of code that uses index and value */ - } - - The items are returned in increasing index order. - - This macro expands to an ordinary ``for`` statement upon - preprocessing, so its performance is equivalent to that of - hand-written code using the array access functions. - The main advantage of this macro is that it abstracts - away the complexity, and makes for shorter, more - concise code. - - .. versionadded:: 2.5 - - -Object -====== - -A JSON object is a dictionary of key-value pairs, where the key is a -Unicode string and the value is any JSON value. - -Even though NUL bytes are allowed in string values, they are not -allowed in object keys. - -.. function:: json_t *json_object(void) - - .. refcounting:: new - - Returns a new JSON object, or *NULL* on error. Initially, the - object is empty. - -.. function:: size_t json_object_size(const json_t *object) - - Returns the number of elements in *object*, or 0 if *object* is not - a JSON object. - -.. function:: json_t *json_object_get(const json_t *object, const char *key) - - .. refcounting:: borrow - - Get a value corresponding to *key* from *object*. Returns *NULL* if - *key* is not found and on error. - -.. function:: int json_object_set(json_t *object, const char *key, json_t *value) - - Set the value of *key* to *value* in *object*. *key* must be a - valid null terminated UTF-8 encoded Unicode string. If there - already is a value for *key*, it is replaced by the new value. - Returns 0 on success and -1 on error. - -.. function:: int json_object_set_nocheck(json_t *object, const char *key, json_t *value) - - Like :func:`json_object_set`, but doesn't check that *key* is - valid UTF-8. Use this function only if you are certain that this - really is the case (e.g. you have already checked it by other - means). - -.. function:: int json_object_set_new(json_t *object, const char *key, json_t *value) - - Like :func:`json_object_set()` but steals the reference to - *value*. This is useful when *value* is newly created and not used - after the call. - -.. function:: int json_object_set_new_nocheck(json_t *object, const char *key, json_t *value) - - Like :func:`json_object_set_new`, but doesn't check that *key* is - valid UTF-8. Use this function only if you are certain that this - really is the case (e.g. you have already checked it by other - means). - -.. function:: int json_object_del(json_t *object, const char *key) - - Delete *key* from *object* if it exists. Returns 0 on success, or - -1 if *key* was not found. The reference count of the removed value - is decremented. - -.. function:: int json_object_clear(json_t *object) - - Remove all elements from *object*. Returns 0 on success and -1 if - *object* is not a JSON object. The reference count of all removed - values are decremented. - -.. function:: int json_object_update(json_t *object, json_t *other) - - Update *object* with the key-value pairs from *other*, overwriting - existing keys. Returns 0 on success or -1 on error. - -.. function:: int json_object_update_existing(json_t *object, json_t *other) - - Like :func:`json_object_update()`, but only the values of existing - keys are updated. No new keys are created. Returns 0 on success or - -1 on error. - - .. versionadded:: 2.3 - -.. function:: int json_object_update_missing(json_t *object, json_t *other) - - Like :func:`json_object_update()`, but only new keys are created. - The value of any existing key is not changed. Returns 0 on success - or -1 on error. - - .. versionadded:: 2.3 - -The following macro can be used to iterate through all key-value pairs -in an object. - -.. function:: json_object_foreach(object, key, value) - - Iterate over every key-value pair of ``object``, running the block - of code that follows each time with the proper values set to - variables ``key`` and ``value``, of types :type:`const char *` and - :type:`json_t *` respectively. Example:: - - /* obj is a JSON object */ - const char *key; - json_t *value; - - json_object_foreach(obj, key, value) { - /* block of code that uses key and value */ - } - - The items are not returned in any particular order. - - This macro expands to an ordinary ``for`` statement upon - preprocessing, so its performance is equivalent to that of - hand-written iteration code using the object iteration protocol - (see below). The main advantage of this macro is that it abstracts - away the complexity behind iteration, and makes for shorter, more - concise code. - - .. versionadded:: 2.3 - - -The following functions implement an iteration protocol for objects, -allowing to iterate through all key-value pairs in an object. The -items are not returned in any particular order, as this would require -sorting due to the internal hashtable implementation. - -.. function:: void *json_object_iter(json_t *object) - - Returns an opaque iterator which can be used to iterate over all - key-value pairs in *object*, or *NULL* if *object* is empty. - -.. function:: void *json_object_iter_at(json_t *object, const char *key) - - Like :func:`json_object_iter()`, but returns an iterator to the - key-value pair in *object* whose key is equal to *key*, or NULL if - *key* is not found in *object*. Iterating forward to the end of - *object* only yields all key-value pairs of the object if *key* - happens to be the first key in the underlying hash table. - -.. function:: void *json_object_iter_next(json_t *object, void *iter) - - Returns an iterator pointing to the next key-value pair in *object* - after *iter*, or *NULL* if the whole object has been iterated - through. - -.. function:: const char *json_object_iter_key(void *iter) - - Extract the associated key from *iter*. - -.. function:: json_t *json_object_iter_value(void *iter) - - .. refcounting:: borrow - - Extract the associated value from *iter*. - -.. function:: int json_object_iter_set(json_t *object, void *iter, json_t *value) - - Set the value of the key-value pair in *object*, that is pointed to - by *iter*, to *value*. - -.. function:: int json_object_iter_set_new(json_t *object, void *iter, json_t *value) - - Like :func:`json_object_iter_set()`, but steals the reference to - *value*. This is useful when *value* is newly created and not used - after the call. - -.. function:: void *json_object_key_to_iter(const char *key) - - Like :func:`json_object_iter_at()`, but much faster. Only works for - values returned by :func:`json_object_iter_key()`. Using other keys - will lead to segfaults. This function is used internally to - implement :func:`json_object_foreach`. - - .. versionadded:: 2.3 - -The iteration protocol can be used for example as follows:: - - /* obj is a JSON object */ - const char *key; - json_t *value; - - void *iter = json_object_iter(obj); - while(iter) - { - key = json_object_iter_key(iter); - value = json_object_iter_value(iter); - /* use key and value ... */ - iter = json_object_iter_next(obj, iter); - } - - -Error reporting -=============== - -Jansson uses a single struct type to pass error information to the -user. See sections :ref:`apiref-decoding`, :ref:`apiref-pack` and -:ref:`apiref-unpack` for functions that pass error information using -this struct. - -.. type:: json_error_t - - .. member:: char text[] - - The error message (in UTF-8), or an empty string if a message is - not available. - - .. member:: char source[] - - Source of the error. This can be (a part of) the file name or a - special identifier in angle brackers (e.g. ````). - - .. member:: int line - - The line number on which the error occurred. - - .. member:: int column - - The column on which the error occurred. Note that this is the - *character column*, not the byte column, i.e. a multibyte UTF-8 - character counts as one column. - - .. member:: size_t position - - The position in bytes from the start of the input. This is - useful for debugging Unicode encoding problems. - -The normal use of :type:`json_error_t` is to allocate it on the stack, -and pass a pointer to a function. Example:: - - int main() { - json_t *json; - json_error_t error; - - json = json_load_file("/path/to/file.json", 0, &error); - if(!json) { - /* the error variable contains error information */ - } - ... - } - -Also note that if the call succeeded (``json != NULL`` in the above -example), the contents of ``error`` are generally left unspecified. -The decoding functions write to the ``position`` member also on -success. See :ref:`apiref-decoding` for more info. - -All functions also accept *NULL* as the :type:`json_error_t` pointer, -in which case no error information is returned to the caller. - - -Encoding -======== - -This sections describes the functions that can be used to encode -values to JSON. By default, only objects and arrays can be encoded -directly, since they are the only valid *root* values of a JSON text. -To encode any JSON value, use the ``JSON_ENCODE_ANY`` flag (see -below). - -By default, the output has no newlines, and spaces are used between -array and object elements for a readable output. This behavior can be -altered by using the ``JSON_INDENT`` and ``JSON_COMPACT`` flags -described below. A newline is never appended to the end of the encoded -JSON data. - -Each function takes a *flags* parameter that controls some aspects of -how the data is encoded. Its default value is 0. The following macros -can be ORed together to obtain *flags*. - -``JSON_INDENT(n)`` - Pretty-print the result, using newlines between array and object - items, and indenting with *n* spaces. The valid range for *n* is - between 0 and 31 (inclusive), other values result in an undefined - output. If ``JSON_INDENT`` is not used or *n* is 0, no newlines are - inserted between array and object items. - -``JSON_COMPACT`` - This flag enables a compact representation, i.e. sets the separator - between array and object items to ``","`` and between object keys - and values to ``":"``. Without this flag, the corresponding - separators are ``", "`` and ``": "`` for more readable output. - -``JSON_ENSURE_ASCII`` - If this flag is used, the output is guaranteed to consist only of - ASCII characters. This is achived by escaping all Unicode - characters outside the ASCII range. - -``JSON_SORT_KEYS`` - If this flag is used, all the objects in output are sorted by key. - This is useful e.g. if two JSON texts are diffed or visually - compared. - -``JSON_PRESERVE_ORDER`` - If this flag is used, object keys in the output are sorted into the - same order in which they were first inserted to the object. For - example, decoding a JSON text and then encoding with this flag - preserves the order of object keys. - -``JSON_ENCODE_ANY`` - Specifying this flag makes it possible to encode any JSON value on - its own. Without it, only objects and arrays can be passed as the - *root* value to the encoding functions. - - **Note:** Encoding any value may be useful in some scenarios, but - it's generally discouraged as it violates strict compatiblity with - :rfc:`4627`. If you use this flag, don't expect interoperatibility - with other JSON systems. - - .. versionadded:: 2.1 - -``JSON_ESCAPE_SLASH`` - Escape the ``/`` characters in strings with ``\/``. - - .. versionadded:: 2.4 - -The following functions perform the actual JSON encoding. The result -is in UTF-8. - -.. function:: char *json_dumps(const json_t *root, size_t flags) - - Returns the JSON representation of *root* as a string, or *NULL* on - error. *flags* is described above. The return value must be freed - by the caller using :func:`free()`. - -.. function:: int json_dumpf(const json_t *root, FILE *output, size_t flags) - - Write the JSON representation of *root* to the stream *output*. - *flags* is described above. Returns 0 on success and -1 on error. - If an error occurs, something may have already been written to - *output*. In this case, the output is undefined and most likely not - valid JSON. - -.. function:: int json_dump_file(const json_t *json, const char *path, size_t flags) - - Write the JSON representation of *root* to the file *path*. If - *path* already exists, it is overwritten. *flags* is described - above. Returns 0 on success and -1 on error. - -.. type:: json_dump_callback_t - - A typedef for a function that's called by - :func:`json_dump_callback()`:: - - typedef int (*json_dump_callback_t)(const char *buffer, size_t size, void *data); - - *buffer* points to a buffer containing a chunk of output, *size* is - the length of the buffer, and *data* is the corresponding - :func:`json_dump_callback()` argument passed through. - - On error, the function should return -1 to stop the encoding - process. On success, it should return 0. - - .. versionadded:: 2.2 - -.. function:: int json_dump_callback(const json_t *json, json_dump_callback_t callback, void *data, size_t flags) - - Call *callback* repeatedly, passing a chunk of the JSON - representation of *root* each time. *flags* is described above. - Returns 0 on success and -1 on error. - - .. versionadded:: 2.2 - - -.. _apiref-decoding: - -Decoding -======== - -This sections describes the functions that can be used to decode JSON -text to the Jansson representation of JSON data. The JSON -specification requires that a JSON text is either a serialized array -or object, and this requirement is also enforced with the following -functions. In other words, the top level value in the JSON text being -decoded must be either array or object. To decode any JSON value, use -the ``JSON_DECODE_ANY`` flag (see below). - -See :ref:`rfc-conformance` for a discussion on Jansson's conformance -to the JSON specification. It explains many design decisions that -affect especially the behavior of the decoder. - -Each function takes a *flags* parameter that can be used to control -the behavior of the decoder. Its default value is 0. The following -macros can be ORed together to obtain *flags*. - -``JSON_REJECT_DUPLICATES`` - Issue a decoding error if any JSON object in the input text - contains duplicate keys. Without this flag, the value of the last - occurence of each key ends up in the result. Key equivalence is - checked byte-by-byte, without special Unicode comparison - algorithms. - - .. versionadded:: 2.1 - -``JSON_DECODE_ANY`` - By default, the decoder expects an array or object as the input. - With this flag enabled, the decoder accepts any valid JSON value. - - **Note:** Decoding any value may be useful in some scenarios, but - it's generally discouraged as it violates strict compatiblity with - :rfc:`4627`. If you use this flag, don't expect interoperatibility - with other JSON systems. - - .. versionadded:: 2.3 - -``JSON_DISABLE_EOF_CHECK`` - By default, the decoder expects that its whole input constitutes a - valid JSON text, and issues an error if there's extra data after - the otherwise valid JSON input. With this flag enabled, the decoder - stops after decoding a valid JSON array or object, and thus allows - extra data after the JSON text. - - Normally, reading will stop when the last ``]`` or ``}`` in the - JSON input is encountered. If both ``JSON_DISABLE_EOF_CHECK`` and - ``JSON_DECODE_ANY`` flags are used, the decoder may read one extra - UTF-8 code unit (up to 4 bytes of input). For example, decoding - ``4true`` correctly decodes the integer 4, but also reads the - ``t``. For this reason, if reading multiple consecutive values that - are not arrays or objects, they should be separated by at least one - whitespace character. - - .. versionadded:: 2.1 - -``JSON_DECODE_INT_AS_REAL`` - JSON defines only one number type. Jansson distinguishes between - ints and reals. For more information see :ref:`real-vs-integer`. - With this flag enabled the decoder interprets all numbers as real - values. Integers that do not have an exact double representation - will silently result in a loss of precision. Integers that cause - a double overflow will cause an error. - - .. versionadded:: 2.5 - -``JSON_ALLOW_NUL`` - Allow ``\u0000`` escape inside string values. This is a safety - measure; If you know your input can contain NUL bytes, use this - flag. If you don't use this flag, you don't have to worry about NUL - bytes inside strings unless you explicitly create themselves by - using e.g. :func:`json_stringn()` or ``s#`` format specifier for - :func:`json_pack()`. - - Object keys cannot have embedded NUL bytes even if this flag is - used. - - .. versionadded:: 2.6 - -Each function also takes an optional :type:`json_error_t` parameter -that is filled with error information if decoding fails. It's also -updated on success; the number of bytes of input read is written to -its ``position`` field. This is especially useful when using -``JSON_DISABLE_EOF_CHECK`` to read multiple consecutive JSON texts. - -.. versionadded:: 2.3 - Number of bytes of input read is written to the ``position`` field - of the :type:`json_error_t` structure. - -If no error or position information is needed, you can pass *NULL*. - -The following functions perform the actual JSON decoding. - -.. function:: json_t *json_loads(const char *input, size_t flags, json_error_t *error) - - .. refcounting:: new - - Decodes the JSON string *input* and returns the array or object it - contains, or *NULL* on error, in which case *error* is filled with - information about the error. *flags* is described above. - -.. function:: json_t *json_loadb(const char *buffer, size_t buflen, size_t flags, json_error_t *error) - - .. refcounting:: new - - Decodes the JSON string *buffer*, whose length is *buflen*, and - returns the array or object it contains, or *NULL* on error, in - which case *error* is filled with information about the error. This - is similar to :func:`json_loads()` except that the string doesn't - need to be null-terminated. *flags* is described above. - - .. versionadded:: 2.1 - -.. function:: json_t *json_loadf(FILE *input, size_t flags, json_error_t *error) - - .. refcounting:: new - - Decodes the JSON text in stream *input* and returns the array or - object it contains, or *NULL* on error, in which case *error* is - filled with information about the error. *flags* is described - above. - - This function will start reading the input from whatever position - the input file was, without attempting to seek first. If an error - occurs, the file position will be left indeterminate. On success, - the file position will be at EOF, unless ``JSON_DISABLE_EOF_CHECK`` - flag was used. In this case, the file position will be at the first - character after the last ``]`` or ``}`` in the JSON input. This - allows calling :func:`json_loadf()` on the same ``FILE`` object - multiple times, if the input consists of consecutive JSON texts, - possibly separated by whitespace. - -.. function:: json_t *json_load_file(const char *path, size_t flags, json_error_t *error) - - .. refcounting:: new - - Decodes the JSON text in file *path* and returns the array or - object it contains, or *NULL* on error, in which case *error* is - filled with information about the error. *flags* is described - above. - -.. type:: json_load_callback_t - - A typedef for a function that's called by - :func:`json_load_callback()` to read a chunk of input data:: - - typedef size_t (*json_load_callback_t)(void *buffer, size_t buflen, void *data); - - *buffer* points to a buffer of *buflen* bytes, and *data* is the - corresponding :func:`json_load_callback()` argument passed through. - - On success, the function should return the number of bytes read; a - returned value of 0 indicates that no data was read and that the - end of file has been reached. On error, the function should return - ``(size_t)-1`` to abort the decoding process. - - .. versionadded:: 2.4 - -.. function:: json_t *json_load_callback(json_load_callback_t callback, void *data, size_t flags, json_error_t *error) - - .. refcounting:: new - - Decodes the JSON text produced by repeated calls to *callback*, and - returns the array or object it contains, or *NULL* on error, in - which case *error* is filled with information about the error. - *data* is passed through to *callback* on each call. *flags* is - described above. - - .. versionadded:: 2.4 - - -.. _apiref-pack: - -Building Values -=============== - -This section describes functions that help to create, or *pack*, -complex JSON values, especially nested objects and arrays. Value -building is based on a *format string* that is used to tell the -functions about the expected arguments. - -For example, the format string ``"i"`` specifies a single integer -value, while the format string ``"[ssb]"`` or the equivalent ``"[s, s, -b]"`` specifies an array value with two strings and a boolean as its -items:: - - /* Create the JSON integer 42 */ - json_pack("i", 42); - - /* Create the JSON array ["foo", "bar", true] */ - json_pack("[ssb]", "foo", "bar", 1); - -Here's the full list of format specifiers. The type in parentheses -denotes the resulting JSON type, and the type in brackets (if any) -denotes the C type that is expected as the corresponding argument or -arguments. - -``s`` (string) [const char \*] - Convert a NULL terminated UTF-8 string to a JSON string. - -``s#`` (string) [const char \*, int] - Convert a UTF-8 buffer of a given length to a JSON string. - - .. versionadded:: 2.5 - -``s%`` (string) [const char \*, size_t] - Like ``s#`` but the length argument is of type :type:`size_t`. - - .. versionadded:: 2.6 - -``+`` [const char \*] - Like ``s``, but concatenate to the previous string. Only valid - after ``s``, ``s#``, ``+`` or ``+#``. - - .. versionadded:: 2.5 - -``+#`` [const char \*, int] - Like ``s#``, but concatenate to the previous string. Only valid - after ``s``, ``s#``, ``+`` or ``+#``. - - .. versionadded:: 2.5 - -``+%`` (string) [const char \*, size_t] - Like ``+#`` but the length argument is of type :type:`size_t`. - - .. versionadded:: 2.6 - -``n`` (null) - Output a JSON null value. No argument is consumed. - -``b`` (boolean) [int] - Convert a C :type:`int` to JSON boolean value. Zero is converted - to ``false`` and non-zero to ``true``. - -``i`` (integer) [int] - Convert a C :type:`int` to JSON integer. - -``I`` (integer) [json_int_t] - Convert a C :type:`json_int_t` to JSON integer. - -``f`` (real) [double] - Convert a C :type:`double` to JSON real. - -``o`` (any value) [json_t \*] - Output any given JSON value as-is. If the value is added to an - array or object, the reference to the value passed to ``o`` is - stolen by the container. - -``O`` (any value) [json_t \*] - Like ``o``, but the argument's reference count is incremented. - This is useful if you pack into an array or object and want to - keep the reference for the JSON value consumed by ``O`` to - yourself. - -``[fmt]`` (array) - Build an array with contents from the inner format string. ``fmt`` - may contain objects and arrays, i.e. recursive value building is - supported. - -``{fmt}`` (object) - Build an object with contents from the inner format string - ``fmt``. The first, third, etc. format specifier represent a key, - and must be a string (see ``s``, ``s#``, ``+`` and ``+#`` above), - as object keys are always strings. The second, fourth, etc. format - specifier represent a value. Any value may be an object or array, - i.e. recursive value building is supported. - -Whitespace, ``:`` and ``,`` are ignored. - -The following functions compose the value building API: - -.. function:: json_t *json_pack(const char *fmt, ...) - - .. refcounting:: new - - Build a new JSON value according to the format string *fmt*. For - each format specifier (except for ``{}[]n``), one or more arguments - are consumed and used to build the corresponding value. Returns - *NULL* on error. - -.. function:: json_t *json_pack_ex(json_error_t *error, size_t flags, const char *fmt, ...) - json_t *json_vpack_ex(json_error_t *error, size_t flags, const char *fmt, va_list ap) - - .. refcounting:: new - - Like :func:`json_pack()`, but an in the case of an error, an error - message is written to *error*, if it's not *NULL*. The *flags* - parameter is currently unused and should be set to 0. - - As only the errors in format string (and out-of-memory errors) can - be caught by the packer, these two functions are most likely only - useful for debugging format strings. - -More examples:: - - /* Build an empty JSON object */ - json_pack("{}"); - - /* Build the JSON object {"foo": 42, "bar": 7} */ - json_pack("{sisi}", "foo", 42, "bar", 7); - - /* Like above, ':', ',' and whitespace are ignored */ - json_pack("{s:i, s:i}", "foo", 42, "bar", 7); - - /* Build the JSON array [[1, 2], {"cool": true}] */ - json_pack("[[i,i],{s:b}]", 1, 2, "cool", 1); - - /* Build a string from a non-NUL terminated buffer */ - char buffer[4] = {'t', 'e', 's', 't'}; - json_pack("s#", buffer, 4); - - /* Concatentate strings together to build the JSON string "foobarbaz" */ - json_pack("s++", "foo", "bar", "baz"); - - -.. _apiref-unpack: - -Parsing and Validating Values -============================= - -This section describes functions that help to validate complex values -and extract, or *unpack*, data from them. Like :ref:`building values -`, this is also based on format strings. - -While a JSON value is unpacked, the type specified in the format -string is checked to match that of the JSON value. This is the -validation part of the process. In addition to this, the unpacking -functions can also check that all items of arrays and objects are -unpacked. This check be enabled with the format specifier ``!`` or by -using the flag ``JSON_STRICT``. See below for details. - -Here's the full list of format specifiers. The type in parentheses -denotes the JSON type, and the type in brackets (if any) denotes the C -type whose address should be passed. - -``s`` (string) [const char \*] - Convert a JSON string to a pointer to a NULL terminated UTF-8 - string. The resulting string is extracted by using - :func:`json_string_value()` internally, so it exists as long as - there are still references to the corresponding JSON string. - -``s%`` (string) [const char \*, size_t *] - Convert a JSON string to a pointer to a NULL terminated UTF-8 - string and its length. - - .. versionadded:: 2.6 - -``n`` (null) - Expect a JSON null value. Nothing is extracted. - -``b`` (boolean) [int] - Convert a JSON boolean value to a C :type:`int`, so that ``true`` - is converted to 1 and ``false`` to 0. - -``i`` (integer) [int] - Convert a JSON integer to C :type:`int`. - -``I`` (integer) [json_int_t] - Convert a JSON integer to C :type:`json_int_t`. - -``f`` (real) [double] - Convert a JSON real to C :type:`double`. - -``F`` (integer or real) [double] - Convert a JSON number (integer or real) to C :type:`double`. - -``o`` (any value) [json_t \*] - Store a JSON value with no conversion to a :type:`json_t` pointer. - -``O`` (any value) [json_t \*] - Like ``O``, but the JSON value's reference count is incremented. - -``[fmt]`` (array) - Convert each item in the JSON array according to the inner format - string. ``fmt`` may contain objects and arrays, i.e. recursive - value extraction is supporetd. - -``{fmt}`` (object) - Convert each item in the JSON object according to the inner format - string ``fmt``. The first, third, etc. format specifier represent - a key, and must be ``s``. The corresponding argument to unpack - functions is read as the object key. The second fourth, etc. - format specifier represent a value and is written to the address - given as the corresponding argument. **Note** that every other - argument is read from and every other is written to. - - ``fmt`` may contain objects and arrays as values, i.e. recursive - value extraction is supporetd. - - .. versionadded:: 2.3 - Any ``s`` representing a key may be suffixed with a ``?`` to - make the key optional. If the key is not found, nothing is - extracted. See below for an example. - -``!`` - This special format specifier is used to enable the check that - all object and array items are accessed, on a per-value basis. It - must appear inside an array or object as the last format specifier - before the closing bracket or brace. To enable the check globally, - use the ``JSON_STRICT`` unpacking flag. - -``*`` - This special format specifier is the opposite of ``!``. If the - ``JSON_STRICT`` flag is used, ``*`` can be used to disable the - strict check on a per-value basis. It must appear inside an array - or object as the last format specifier before the closing bracket - or brace. - -Whitespace, ``:`` and ``,`` are ignored. - -The following functions compose the parsing and validation API: - -.. function:: int json_unpack(json_t *root, const char *fmt, ...) - - Validate and unpack the JSON value *root* according to the format - string *fmt*. Returns 0 on success and -1 on failure. - -.. function:: int json_unpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt, ...) - int json_vunpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt, va_list ap) - - Validate and unpack the JSON value *root* according to the format - string *fmt*. If an error occurs and *error* is not *NULL*, write - error information to *error*. *flags* can be used to control the - behaviour of the unpacker, see below for the flags. Returns 0 on - success and -1 on failure. - -.. note:: - - The first argument of all unpack functions is ``json_t *root`` - instead of ``const json_t *root``, because the use of ``O`` format - specifier causes the reference count of ``root``, or some value - reachable from ``root``, to be increased. Furthermore, the ``o`` - format specifier may be used to extract a value as-is, which allows - modifying the structure or contents of a value reachable from - ``root``. - - If the ``O`` and ``o`` format specifiers are not used, it's - perfectly safe to cast a ``const json_t *`` variable to plain - ``json_t *`` when used with these functions. - -The following unpacking flags are available: - -``JSON_STRICT`` - Enable the extra validation step checking that all object and - array items are unpacked. This is equivalent to appending the - format specifier ``!`` to the end of every array and object in the - format string. - -``JSON_VALIDATE_ONLY`` - Don't extract any data, just validate the JSON value against the - given format string. Note that object keys must still be specified - after the format string. - -Examples:: - - /* root is the JSON integer 42 */ - int myint; - json_unpack(root, "i", &myint); - assert(myint == 42); - - /* root is the JSON object {"foo": "bar", "quux": true} */ - const char *str; - int boolean; - json_unpack(root, "{s:s, s:b}", "foo", &str, "quux", &boolean); - assert(strcmp(str, "bar") == 0 && boolean == 1); - - /* root is the JSON array [[1, 2], {"baz": null} */ - json_error_t error; - json_unpack_ex(root, &error, JSON_VALIDATE_ONLY, "[[i,i], {s:n}]", "baz"); - /* returns 0 for validation success, nothing is extracted */ - - /* root is the JSON array [1, 2, 3, 4, 5] */ - int myint1, myint2; - json_unpack(root, "[ii!]", &myint1, &myint2); - /* returns -1 for failed validation */ - - /* root is an empty JSON object */ - int myint = 0, myint2 = 0; - json_unpack(root, "{s?i, s?[ii]}", - "foo", &myint1, - "bar", &myint2, &myint3); - /* myint1, myint2 or myint3 is no touched as "foo" and "bar" don't exist */ - - -Equality -======== - -Testing for equality of two JSON values cannot, in general, be -achieved using the ``==`` operator. Equality in the terms of the -``==`` operator states that the two :type:`json_t` pointers point to -exactly the same JSON value. However, two JSON values can be equal not -only if they are exactly the same value, but also if they have equal -"contents": - -* Two integer or real values are equal if their contained numeric - values are equal. An integer value is never equal to a real value, - though. - -* Two strings are equal if their contained UTF-8 strings are equal, - byte by byte. Unicode comparison algorithms are not implemented. - -* Two arrays are equal if they have the same number of elements and - each element in the first array is equal to the corresponding - element in the second array. - -* Two objects are equal if they have exactly the same keys and the - value for each key in the first object is equal to the value of the - corresponding key in the second object. - -* Two true, false or null values have no "contents", so they are equal - if their types are equal. (Because these values are singletons, - their equality can actually be tested with ``==``.) - -The following function can be used to test whether two JSON values are -equal. - -.. function:: int json_equal(json_t *value1, json_t *value2) - - Returns 1 if *value1* and *value2* are equal, as defined above. - Returns 0 if they are inequal or one or both of the pointers are - *NULL*. - - -Copying -======= - -Because of reference counting, passing JSON values around doesn't -require copying them. But sometimes a fresh copy of a JSON value is -needed. For example, if you need to modify an array, but still want to -use the original afterwards, you should take a copy of it first. - -Jansson supports two kinds of copying: shallow and deep. There is a -difference between these methods only for arrays and objects. Shallow -copying only copies the first level value (array or object) and uses -the same child values in the copied value. Deep copying makes a fresh -copy of the child values, too. Moreover, all the child values are deep -copied in a recursive fashion. - -.. function:: json_t *json_copy(json_t *value) - - .. refcounting:: new - - Returns a shallow copy of *value*, or *NULL* on error. - -.. function:: json_t *json_deep_copy(const json_t *value) - - .. refcounting:: new - - Returns a deep copy of *value*, or *NULL* on error. - - -.. _apiref-custom-memory-allocation: - -Custom Memory Allocation -======================== - -By default, Jansson uses :func:`malloc()` and :func:`free()` for -memory allocation. These functions can be overridden if custom -behavior is needed. - -.. type:: json_malloc_t - - A typedef for a function pointer with :func:`malloc()`'s - signature:: - - typedef void *(*json_malloc_t)(size_t); - -.. type:: json_free_t - - A typedef for a function pointer with :func:`free()`'s - signature:: - - typedef void (*json_free_t)(void *); - -.. function:: void json_set_alloc_funcs(json_malloc_t malloc_fn, json_free_t free_fn) - - Use *malloc_fn* instead of :func:`malloc()` and *free_fn* instead - of :func:`free()`. This function has to be called before any other - Jansson's API functions to ensure that all memory operations use - the same functions. - -**Examples:** - -Circumvent problems with different CRT heaps on Windows by using -application's :func:`malloc()` and :func:`free()`:: - - json_set_alloc_funcs(malloc, free); - -Use the `Boehm's conservative garbage collector`_ for memory -operations:: - - json_set_alloc_funcs(GC_malloc, GC_free); - -.. _Boehm's conservative garbage collector: http://www.hpl.hp.com/personal/Hans_Boehm/gc/ - -Allow storing sensitive data (e.g. passwords or encryption keys) in -JSON structures by zeroing all memory when freed:: - - static void *secure_malloc(size_t size) - { - /* Store the memory area size in the beginning of the block */ - void *ptr = malloc(size + 8); - *((size_t *)ptr) = size; - return ptr + 8; - } - - static void secure_free(void *ptr) - { - size_t size; - - ptr -= 8; - size = *((size_t *)ptr); - - guaranteed_memset(ptr, 0, size + 8); - free(ptr); - } - - int main() - { - json_set_alloc_funcs(secure_malloc, secure_free); - /* ... */ - } - -For more information about the issues of storing sensitive data in -memory, see -http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO/protect-secrets.html. -The page also explains the :func:`guaranteed_memset()` function used -in the example and gives a sample implementation for it. diff --git a/deps/jansson/doc/changes.rst b/deps/jansson/doc/changes.rst deleted file mode 100644 index ea56843..0000000 --- a/deps/jansson/doc/changes.rst +++ /dev/null @@ -1,5 +0,0 @@ -****************** -Changes in Jansson -****************** - -.. include:: ../CHANGES diff --git a/deps/jansson/doc/conf.py b/deps/jansson/doc/conf.py deleted file mode 100644 index ddf5833..0000000 --- a/deps/jansson/doc/conf.py +++ /dev/null @@ -1,217 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Jansson documentation build configuration file, created by -# sphinx-quickstart on Sun Sep 5 21:47:20 2010. -# -# This file is execfile()d with the current directory set to its containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys, os - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath('ext')) - -# -- General configuration ----------------------------------------------------- - -# If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['refcounting'] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix of source filenames. -source_suffix = '.rst' - -# The encoding of source files. -#source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'Jansson' -copyright = u'2009-2013, Petri Lehtinen' - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = '2.5' -# The full version, including alpha/beta/rc tags. -release = version - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -#language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -#today = '' -# Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ['_build'] - -# The reST default role (used for this markup: `text`) to use for all documents. -default_role = 'c:func' -primary_domain = 'c' - -# If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -#add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -#show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] - - -# -- Options for HTML output --------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -#html_theme = 'default' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -#html_theme_options = {} - -# Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -#html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -#html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -#html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -#html_static_path = ['_static'] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -#html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -#html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -#html_additional_pages = {} - -# If false, no module index is generated. -#html_domain_indices = True - -# If false, no index is generated. -#html_use_index = True - -# If true, the index is split into individual pages for each letter. -#html_split_index = False - -# If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -#html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None - -# Output file base name for HTML help builder. -htmlhelp_basename = 'Janssondoc' - - -# -- Options for LaTeX output -------------------------------------------------- - -# The paper size ('letter' or 'a4'). -#latex_paper_size = 'letter' - -# The font size ('10pt', '11pt' or '12pt'). -#latex_font_size = '10pt' - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto/manual]). -latex_documents = [ - ('index', 'Jansson.tex', u'Jansson Documentation', - u'Petri Lehtinen', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -#latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -#latex_use_parts = False - -# If true, show page references after internal links. -#latex_show_pagerefs = False - -# If true, show URL addresses after external links. -#latex_show_urls = False - -# Additional stuff for the LaTeX preamble. -#latex_preamble = '' - -# Documents to append as an appendix to all manuals. -#latex_appendices = [] - -# If false, no module index is generated. -#latex_domain_indices = True - - -# -- Options for manual page output -------------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'jansson', u'Jansson Documentation', - [u'Petri Lehtinen'], 1) -] diff --git a/deps/jansson/doc/conformance.rst b/deps/jansson/doc/conformance.rst deleted file mode 100644 index de3947d..0000000 --- a/deps/jansson/doc/conformance.rst +++ /dev/null @@ -1,110 +0,0 @@ -.. _rfc-conformance: - -*************** -RFC Conformance -*************** - -JSON is specified in :rfc:`4627`, *"The application/json Media Type -for JavaScript Object Notation (JSON)"*. - -Character Encoding -================== - -Jansson only supports UTF-8 encoded JSON texts. It does not support or -auto-detect any of the other encodings mentioned in the RFC, namely -UTF-16LE, UTF-16BE, UTF-32LE or UTF-32BE. Pure ASCII is supported, as -it's a subset of UTF-8. - -Strings -======= - -JSON strings are mapped to C-style null-terminated character arrays, -and UTF-8 encoding is used internally. - -All Unicode codepoints U+0000 through U+10FFFF are allowed in string -values. However, U+0000 is not allowed in object keys because of API -restrictions. - -Unicode normalization or any other transformation is never performed -on any strings (string values or object keys). When checking for -equivalence of strings or object keys, the comparison is performed -byte by byte between the original UTF-8 representations of the -strings. - -Numbers -======= - -.. _real-vs-integer: - -Real vs. Integer ----------------- - -JSON makes no distinction between real and integer numbers; Jansson -does. Real numbers are mapped to the ``double`` type and integers to -the ``json_int_t`` type, which is a typedef of ``long long`` or -``long``, depending on whether ``long long`` is supported by your -compiler or not. - -A JSON number is considered to be a real number if its lexical -representation includes one of ``e``, ``E``, or ``.``; regardless if -its actual numeric value is a true integer (e.g., all of ``1E6``, -``3.0``, ``400E-2``, and ``3.14E3`` are mathematical integers, but -will be treated as real values). With the ``JSON_DECODE_INT_AS_REAL`` -decoder flag set all numbers are interpreted as real. - -All other JSON numbers are considered integers. - -When encoding to JSON, real values are always represented -with a fractional part; e.g., the ``double`` value 3.0 will be -represented in JSON as ``3.0``, not ``3``. - -Overflow, Underflow & Precision -------------------------------- - -Real numbers whose absolute values are too small to be represented in -a C ``double`` will be silently estimated with 0.0. Thus, depending on -platform, JSON numbers very close to zero such as 1E-999 may result in -0.0. - -Real numbers whose absolute values are too large to be represented in -a C ``double`` will result in an overflow error (a JSON decoding -error). Thus, depending on platform, JSON numbers like 1E+999 or --1E+999 may result in a parsing error. - -Likewise, integer numbers whose absolute values are too large to be -represented in the ``json_int_t`` type (see above) will result in an -overflow error (a JSON decoding error). Thus, depending on platform, -JSON numbers like 1000000000000000 may result in parsing error. - -Parsing JSON real numbers may result in a loss of precision. As long -as overflow does not occur (i.e. a total loss of precision), the -rounded approximate value is silently used. Thus the JSON number -1.000000000000000005 may, depending on platform, result in the -``double`` value 1.0. - -Signed zeros ------------- - -JSON makes no statement about what a number means; however Javascript -(ECMAscript) does state that +0.0 and -0.0 must be treated as being -distinct values, i.e. -0.0 |not-equal| 0.0. Jansson relies on the -underlying floating point library in the C environment in which it is -compiled. Therefore it is platform-dependent whether 0.0 and -0.0 will -be distinct values. Most platforms that use the IEEE 754 -floating-point standard will support signed zeros. - -Note that this only applies to floating-point; neither JSON, C, or -IEEE support the concept of signed integer zeros. - -.. |not-equal| unicode:: U+2260 - -Types ------ - -No support is provided in Jansson for any C numeric types other than -``json_int_t`` and ``double``. This excludes things such as unsigned -types, ``long double``, etc. Obviously, shorter types like ``short``, -``int``, ``long`` (if ``json_int_t`` is ``long long``) and ``float`` -are implicitly handled via the ordinary C type coercion rules (subject -to overflow semantics). Also, no support or hooks are provided for any -supplemental "bignum" type add-on packages. diff --git a/deps/jansson/doc/ext/refcounting.py b/deps/jansson/doc/ext/refcounting.py deleted file mode 100644 index 4af3084..0000000 --- a/deps/jansson/doc/ext/refcounting.py +++ /dev/null @@ -1,59 +0,0 @@ -""" - refcounting - ~~~~~~~~~~~ - - Reference count annotations for C API functions. Has the same - result as the sphinx.ext.refcounting extension but works for all - functions regardless of the signature, and the reference counting - information is written inline with the documentation instead of a - separate file. - - Adds a new directive "refcounting". The directive has no content - and one required positional parameter:: "new" or "borrow". - - Example: - - .. cfunction:: json_t *json_object(void) - - .. refcounting:: new - - - - :copyright: Copyright (c) 2009-2013 Petri Lehtinen - :license: MIT, see LICENSE for details. -""" - -from docutils import nodes - -class refcounting(nodes.emphasis): pass - -def visit(self, node): - self.visit_emphasis(node) - -def depart(self, node): - self.depart_emphasis(node) - -def html_visit(self, node): - self.body.append(self.starttag(node, 'em', '', CLASS='refcount')) - -def html_depart(self, node): - self.body.append('') - - -def refcounting_directive(name, arguments, options, content, lineno, - content_offset, block_text, state, state_machine): - if arguments[0] == 'borrow': - text = 'Return value: Borrowed reference.' - elif arguments[0] == 'new': - text = 'Return value: New reference.' - else: - raise Error('Valid arguments: new, borrow') - - return [refcounting(text, text)] - -def setup(app): - app.add_node(refcounting, - html=(html_visit, html_depart), - latex=(visit, depart), - text=(visit, depart)) - app.add_directive('refcounting', refcounting_directive, 0, (1, 0, 0)) diff --git a/deps/jansson/doc/gettingstarted.rst b/deps/jansson/doc/gettingstarted.rst deleted file mode 100644 index 4e59e51..0000000 --- a/deps/jansson/doc/gettingstarted.rst +++ /dev/null @@ -1,237 +0,0 @@ -*************** -Getting Started -*************** - -.. highlight:: c - -Compiling and Installing Jansson -================================ - -The Jansson source is available at -http://www.digip.org/jansson/releases/. - -Unix-like systems (including MinGW) ------------------------------------ - -Unpack the source tarball and change to the source directory: - -.. parsed-literal:: - - bunzip2 -c jansson-|release|.tar.bz2 | tar xf - - cd jansson-|release| - -The source uses GNU Autotools (autoconf_, automake_, libtool_), so -compiling and installing is extremely simple:: - - ./configure - make - make check - make install - -To change the destination directory (``/usr/local`` by default), use -the ``--prefix=DIR`` argument to ``./configure``. See ``./configure ---help`` for the list of all possible installation options. (There are -no options to customize the resulting Jansson binary.) - -The command ``make check`` runs the test suite distributed with -Jansson. This step is not strictly necessary, but it may find possible -problems that Jansson has on your platform. If any problems are found, -please report them. - -If you obtained the source from a Git repository (or any other source -control system), there's no ``./configure`` script as it's not kept in -version control. To create the script, the build system needs to be -bootstrapped. There are many ways to do this, but the easiest one is -to use ``autoreconf``:: - - autoreconf -vi - -This command creates the ``./configure`` script, which can then be -used as described above. - -.. _autoconf: http://www.gnu.org/software/autoconf/ -.. _automake: http://www.gnu.org/software/automake/ -.. _libtool: http://www.gnu.org/software/libtool/ - - -.. _build-cmake: - -CMake (various platforms, including Windows) --------------------------------------------- - -Jansson can be built using CMake_. Create a build directory for an -out-of-tree build, change to that directory, and run ``cmake`` (or ``ccmake``, -``cmake-gui``, or similar) to configure the project. - -See the examples below for more detailed information. - -.. note:: In the below examples ``..`` is used as an argument for ``cmake``. - This is simply the path to the jansson project root directory. - In the example it is assumed you've created a sub-directory ``build`` - and are using that. You could use any path you want. - -.. _build-cmake-unix: - -Unix (Make files) -^^^^^^^^^^^^^^^^^ -Generating make files on unix: - -.. parsed-literal:: - - bunzip2 -c jansson-|release|.tar.bz2 | tar xf - - cd jansson-|release| - - mkdir build - cd build - cmake .. # or `ccmake ..` for a GUI. - -Then to build:: - - make - make check - make install - -Windows (Visual Studio) -^^^^^^^^^^^^^^^^^^^^^^^ -Creating Visual Studio project files from the command line: - -.. parsed-literal:: - - - cd jansson-|release| - - md build - cd build - cmake -G "Visual Studio 10" .. - -You will now have a *Visual Studio Solution* in your build directory. -To run the unit tests build the ``RUN_TESTS`` project. - -If you prefer a GUI the ``cmake`` line in the above example can -be replaced with:: - - cmake-gui .. - -For command line help (including a list of available generators) -for CMake_ simply run:: - - cmake - -To list available CMake_ settings (and what they are currently set to) -for the project, run:: - - cmake -LH .. - -Mac OSX (Xcode) -^^^^^^^^^^^^^^^ -If you prefer using Xcode instead of make files on OSX, -do the following. (Use the same steps as -for :ref:`Unix `):: - - ... - cmake -G "Xcode" .. - -Additional CMake settings -^^^^^^^^^^^^^^^^^^^^^^^^^ - -Shared library -"""""""""""""" -By default the CMake_ project will generate build files for building the -static library. To build the shared version use:: - - ... - cmake -DBUILD_SHARED=1 .. - -Changing install directory (same as autoconf --prefix) -"""""""""""""""""""""""""""""""""""""""""""""""""""""" -Just as with the autoconf_ project you can change the destination directory -for ``make install``. The equivalent for autoconfs ``./configure --prefix`` -in CMake_ is:: - - ... - cmake -DCMAKE_INSTALL_PREFIX:PATH=/some/other/path .. - make install - -.. _CMake: http://www.cmake.org - -Android -------- - -Jansson can be built for Android platforms. Android.mk is in the -source root directory. The configuration header file is located in the -``android`` directory in the source distribution. - - -Windows -------- - -**This method is deprecated**. Using :ref:`CMake ` is now -preferred. - -Jansson can be built with Visual Studio 2010 (and probably newer -versions, too). The solution and project files are in the -``win32/vs2010/`` directory in the source distribution. - - -Other Systems -------------- - -On non Unix-like systems, you may be unable to run the ``./configure`` -script. In this case, follow these steps. All the files mentioned can -be found in the ``src/`` directory. - -1. Create ``jansson_config.h`` (which has some platform-specific - parameters that are normally filled in by the ``./configure`` - script). Edit ``jansson_config.h.in``, replacing all ``@variable@`` - placeholders, and rename the file to ``jansson_config.h``. - -2. Make ``jansson.h`` and ``jansson_config.h`` available to the - compiler, so that they can be found when compiling programs that - use Jansson. - -3. Compile all the ``.c`` files (in the ``src/`` directory) into a - library file. Make the library available to the compiler, as in - step 2. - - -Building the Documentation --------------------------- - -(This subsection describes how to build the HTML documentation you are -currently reading, so it can be safely skipped.) - -Documentation is in the ``doc/`` subdirectory. It's written in -reStructuredText_ with Sphinx_ annotations. To generate the HTML -documentation, invoke:: - - make html - -and point your browser to ``doc/_build/html/index.html``. Sphinx_ 1.0 -or newer is required to generate the documentation. - -.. _reStructuredText: http://docutils.sourceforge.net/rst.html -.. _Sphinx: http://sphinx.pocoo.org/ - - -Compiling Programs that Use Jansson -=================================== - -Jansson involves one C header file, :file:`jansson.h`, so it's enough -to put the line - -:: - - #include - -in the beginning of every source file that uses Jansson. - -There's also just one library to link with, ``libjansson``. Compile and -link the program as follows:: - - cc -o prog prog.c -ljansson - -Starting from version 1.2, there's also support for pkg-config_:: - - cc -o prog prog.c `pkg-config --cflags --libs jansson` - -.. _pkg-config: http://pkg-config.freedesktop.org/ diff --git a/deps/jansson/doc/github_commits.c b/deps/jansson/doc/github_commits.c deleted file mode 100644 index 94fb8b7..0000000 --- a/deps/jansson/doc/github_commits.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#include -#include - -#include -#include - -#define BUFFER_SIZE (256 * 1024) /* 256 KB */ - -#define URL_FORMAT "https://api.github.com/repos/%s/%s/commits" -#define URL_SIZE 256 - -/* Return the offset of the first newline in text or the length of - text if there's no newline */ -static int newline_offset(const char *text) -{ - const char *newline = strchr(text, '\n'); - if(!newline) - return strlen(text); - else - return (int)(newline - text); -} - -struct write_result -{ - char *data; - int pos; -}; - -static size_t write_response(void *ptr, size_t size, size_t nmemb, void *stream) -{ - struct write_result *result = (struct write_result *)stream; - - if(result->pos + size * nmemb >= BUFFER_SIZE - 1) - { - fprintf(stderr, "error: too small buffer\n"); - return 0; - } - - memcpy(result->data + result->pos, ptr, size * nmemb); - result->pos += size * nmemb; - - return size * nmemb; -} - -static char *request(const char *url) -{ - CURL *curl = NULL; - CURLcode status; - struct curl_slist *headers = NULL; - char *data = NULL; - long code; - - curl_global_init(CURL_GLOBAL_ALL); - curl = curl_easy_init(); - if(!curl) - goto error; - - data = malloc(BUFFER_SIZE); - if(!data) - goto error; - - struct write_result write_result = { - .data = data, - .pos = 0 - }; - - curl_easy_setopt(curl, CURLOPT_URL, url); - - /* GitHub commits API v3 requires a User-Agent header */ - headers = curl_slist_append(headers, "User-Agent: Jansson-Tutorial"); - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); - - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_response); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, &write_result); - - status = curl_easy_perform(curl); - if(status != 0) - { - fprintf(stderr, "error: unable to request data from %s:\n", url); - fprintf(stderr, "%s\n", curl_easy_strerror(status)); - goto error; - } - - curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code); - if(code != 200) - { - fprintf(stderr, "error: server responded with code %ld\n", code); - goto error; - } - - curl_easy_cleanup(curl); - curl_slist_free_all(headers); - curl_global_cleanup(); - - /* zero-terminate the result */ - data[write_result.pos] = '\0'; - - return data; - -error: - if(data) - free(data); - if(curl) - curl_easy_cleanup(curl); - if(headers) - curl_slist_free_all(headers); - curl_global_cleanup(); - return NULL; -} - -int main(int argc, char *argv[]) -{ - size_t i; - char *text; - char url[URL_SIZE]; - - json_t *root; - json_error_t error; - - if(argc != 3) - { - fprintf(stderr, "usage: %s USER REPOSITORY\n\n", argv[0]); - fprintf(stderr, "List commits at USER's REPOSITORY.\n\n"); - return 2; - } - - snprintf(url, URL_SIZE, URL_FORMAT, argv[1], argv[2]); - - text = request(url); - if(!text) - return 1; - - root = json_loads(text, 0, &error); - free(text); - - if(!root) - { - fprintf(stderr, "error: on line %d: %s\n", error.line, error.text); - return 1; - } - - if(!json_is_array(root)) - { - fprintf(stderr, "error: root is not an array\n"); - json_decref(root); - return 1; - } - - for(i = 0; i < json_array_size(root); i++) - { - json_t *data, *sha, *commit, *message; - const char *message_text; - - data = json_array_get(root, i); - if(!json_is_object(data)) - { - fprintf(stderr, "error: commit data %d is not an object\n", (int)(i + 1)); - json_decref(root); - return 1; - } - - sha = json_object_get(data, "sha"); - if(!json_is_string(sha)) - { - fprintf(stderr, "error: commit %d: sha is not a string\n", (int)(i + 1)); - return 1; - } - - commit = json_object_get(data, "commit"); - if(!json_is_object(commit)) - { - fprintf(stderr, "error: commit %d: commit is not an object\n", (int)(i + 1)); - json_decref(root); - return 1; - } - - message = json_object_get(commit, "message"); - if(!json_is_string(message)) - { - fprintf(stderr, "error: commit %d: message is not a string\n", (int)(i + 1)); - json_decref(root); - return 1; - } - - message_text = json_string_value(message); - printf("%.8s %.*s\n", - json_string_value(sha), - newline_offset(message_text), - message_text); - } - - json_decref(root); - return 0; -} diff --git a/deps/jansson/doc/index.rst b/deps/jansson/doc/index.rst deleted file mode 100644 index 1f3f8ef..0000000 --- a/deps/jansson/doc/index.rst +++ /dev/null @@ -1,53 +0,0 @@ -Jansson Documentation -===================== - -This is the documentation for Jansson_ |release|, last updated |today|. - -Introduction ------------- - -Jansson_ is a C library for encoding, decoding and manipulating JSON -data. Its main features and design principles are: - -- Simple and intuitive API and data model - -- Comprehensive documentation - -- No dependencies on other libraries - -- Full Unicode support (UTF-8) - -- Extensive test suite - -Jansson is licensed under the `MIT license`_; see LICENSE in the -source distribution for details. - -Jansson is used in production and its API is stable. It works on -numerous platforms, including numerous Unix like systems and Windows. -It's suitable for use on any system, including desktop, server, and -small embedded systems. - - -.. _`MIT license`: http://www.opensource.org/licenses/mit-license.php -.. _Jansson: http://www.digip.org/jansson/ - -Contents --------- - -.. toctree:: - :maxdepth: 2 - - gettingstarted - upgrading - tutorial - conformance - portability - apiref - changes - - -Indices and Tables -================== - -* :ref:`genindex` -* :ref:`search` diff --git a/deps/jansson/doc/portability.rst b/deps/jansson/doc/portability.rst deleted file mode 100644 index dc6c5eb..0000000 --- a/deps/jansson/doc/portability.rst +++ /dev/null @@ -1,52 +0,0 @@ -*********** -Portability -*********** - -Thread safety -------------- - -Jansson is thread safe and has no mutable global state. The only -exception are the memory allocation functions, that should be set at -most once, and only on program startup. See -:ref:`apiref-custom-memory-allocation`. - -There's no locking performed inside Jansson's code, so a multithreaded -program must perform its own locking if JSON values are shared by -multiple threads. Jansson's reference counting semantics may make this -a bit harder than it seems, as it's possible to have a reference to a -value that's also stored inside a list or object. Modifying the -container (adding or removing values) may trigger concurrent access to -such values, as containers manage the reference count of their -contained values. Bugs involving concurrent incrementing or -decrementing of deference counts may be hard to track. - -The encoding functions (:func:`json_dumps()` and friends) track -reference loops by modifying the internal state of objects and arrays. -For this reason, encoding functions must not be run on the same JSON -values in two separate threads at the same time. As already noted -above, be especially careful if two arrays or objects share their -contained values with another array or object. - -If you want to make sure that two JSON value hierarchies do not -contain shared values, use :func:`json_deep_copy()` to make copies. - -Locale ------- - -Jansson works fine under any locale. - -However, if the host program is multithreaded and uses ``setlocale()`` -to switch the locale in one thread while Jansson is currently encoding -or decoding JSON data in another thread, the result may be wrong or -the program may even crash. - -Jansson uses locale specific functions for certain string conversions -in the encoder and decoder, and then converts the locale specific -values to/from the JSON representation. This fails if the locale -changes between the string conversion and the locale-to-JSON -conversion. This can only happen in multithreaded programs that use -``setlocale()``, because ``setlocale()`` switches the locale for all -running threads, not only the thread that calls ``setlocale()``. - -If your program uses ``setlocale()`` as described above, consider -using the thread-safe ``uselocale()`` instead. diff --git a/deps/jansson/doc/tutorial.rst b/deps/jansson/doc/tutorial.rst deleted file mode 100644 index c2df081..0000000 --- a/deps/jansson/doc/tutorial.rst +++ /dev/null @@ -1,286 +0,0 @@ -.. _tutorial: - -******** -Tutorial -******** - -.. highlight:: c - -In this tutorial, we create a program that fetches the latest commits -of a repository in GitHub_ over the web. `GitHub API`_ uses JSON, so -the result can be parsed using Jansson. - -To stick to the the scope of this tutorial, we will only cover the the -parts of the program related to handling JSON data. For the best user -experience, the full source code is available: -:download:`github_commits.c`. To compile it (on Unix-like systems with -gcc), use the following command:: - - gcc -o github_commits github_commits.c -ljansson -lcurl - -libcurl_ is used to communicate over the web, so it is required to -compile the program. - -The command line syntax is:: - - github_commits USER REPOSITORY - -``USER`` is a GitHub user ID and ``REPOSITORY`` is the repository -name. Please note that the GitHub API is rate limited, so if you run -the program too many times within a short period of time, the sever -starts to respond with an error. - -.. _GitHub: https://github.com/ -.. _GitHub API: http://developer.github.com/ -.. _libcurl: http://curl.haxx.se/ - - -.. _tutorial-github-commits-api: - -The GitHub Repo Commits API -=========================== - -The `GitHub Repo Commits API`_ is used by sending HTTP requests to -URLs like ``https://api.github.com/repos/USER/REPOSITORY/commits``, -where ``USER`` and ``REPOSITORY`` are the GitHub user ID and the name -of the repository whose commits are to be listed, respectively. - -GitHub responds with a JSON array of the following form: - -.. code-block:: none - - [ - { - "sha": "", - "commit": { - "message": "", - - }, - - }, - { - "sha": "", - "commit": { - "message": "", - - }, - - }, - - ] - -In our program, the HTTP request is sent using the following -function:: - - static char *request(const char *url); - -It takes the URL as a parameter, preforms a HTTP GET request, and -returns a newly allocated string that contains the response body. If -the request fails, an error message is printed to stderr and the -return value is *NULL*. For full details, refer to :download:`the code -`, as the actual implementation is not important -here. - -.. _GitHub Repo Commits API: http://developer.github.com/v3/repos/commits/ - -.. _tutorial-the-program: - -The Program -=========== - -First the includes:: - - #include - #include - -Like all the programs using Jansson, we need to include -:file:`jansson.h`. - -The following definitions are used to build the GitHub API request -URL:: - - #define URL_FORMAT "https://api.github.com/repos/%s/%s/commits" - #define URL_SIZE 256 - -The following function is used when formatting the result to find the -first newline in the commit message:: - - /* Return the offset of the first newline in text or the length of - text if there's no newline */ - static int newline_offset(const char *text) - { - const char *newline = strchr(text, '\n'); - if(!newline) - return strlen(text); - else - return (int)(newline - text); - } - -The main function follows. In the beginning, we first declare a bunch -of variables and check the command line parameters:: - - int main(int argc, char *argv[]) - { - size_t i; - char *text; - char url[URL_SIZE]; - - json_t *root; - json_error_t error; - - if(argc != 3) - { - fprintf(stderr, "usage: %s USER REPOSITORY\n\n", argv[0]); - fprintf(stderr, "List commits at USER's REPOSITORY.\n\n"); - return 2; - } - -Then we build the request URL using the user and repository names -given as command line parameters:: - - snprintf(url, URL_SIZE, URL_FORMAT, argv[1], argv[2]); - -This uses the ``URL_SIZE`` and ``URL_FORMAT`` constants defined above. -Now we're ready to actually request the JSON data over the web:: - - text = request(url); - if(!text) - return 1; - -If an error occurs, our function ``request`` prints the error and -returns *NULL*, so it's enough to just return 1 from the main -function. - -Next we'll call :func:`json_loads()` to decode the JSON text we got -as a response:: - - root = json_loads(text, 0, &error); - free(text); - - if(!root) - { - fprintf(stderr, "error: on line %d: %s\n", error.line, error.text); - return 1; - } - -We don't need the JSON text anymore, so we can free the ``text`` -variable right after decoding it. If :func:`json_loads()` fails, it -returns *NULL* and sets error information to the :type:`json_error_t` -structure given as the second parameter. In this case, our program -prints the error information out and returns 1 from the main function. - -Now we're ready to extract the data out of the decoded JSON response. -The structure of the response JSON was explained in section -:ref:`tutorial-github-commits-api`. - -We check that the returned value really is an array:: - - if(!json_is_array(root)) - { - fprintf(stderr, "error: root is not an array\n"); - json_decref(root); - return 1; - } - -Then we proceed to loop over all the commits in the array:: - - for(i = 0; i < json_array_size(root); i++) - { - json_t *data, *sha, *commit, *message; - const char *message_text; - - data = json_array_get(root, i); - if(!json_is_object(data)) - { - fprintf(stderr, "error: commit data %d is not an object\n", i + 1); - json_decref(root); - return 1; - } - ... - -The function :func:`json_array_size()` returns the size of a JSON -array. First, we again declare some variables and then extract the -i'th element of the ``root`` array using :func:`json_array_get()`. -We also check that the resulting value is a JSON object. - -Next we'll extract the commit ID (a hexadecimal SHA-1 sum), -intermediate commit info object, and the commit message from that -object. We also do proper type checks:: - - sha = json_object_get(data, "sha"); - if(!json_is_string(sha)) - { - fprintf(stderr, "error: commit %d: sha is not a string\n", i + 1); - json_decref(root); - return 1; - } - - commit = json_object_get(data, "commit"); - if(!json_is_object(commit)) - { - fprintf(stderr, "error: commit %d: commit is not an object\n", i + 1); - json_decref(root); - return 1; - } - - message = json_object_get(commit, "message"); - if(!json_is_string(message)) - { - fprintf(stderr, "error: commit %d: message is not a string\n", i + 1); - json_decref(root); - return 1; - } - ... - -And finally, we'll print the first 8 characters of the commit ID and -the first line of the commit message. A C-style string is extracted -from a JSON string using :func:`json_string_value()`:: - - message_text = json_string_value(message); - printf("%.8s %.*s\n", - json_string_value(id), - newline_offset(message_text), - message_text); - } - -After sending the HTTP request, we decoded the JSON text using -:func:`json_loads()`, remember? It returns a *new reference* to the -JSON value it decodes. When we're finished with the value, we'll need -to decrease the reference count using :func:`json_decref()`. This way -Jansson can release the resources:: - - json_decref(root); - return 0; - -For a detailed explanation of reference counting in Jansson, see -:ref:`apiref-reference-count` in :ref:`apiref`. - -The program's ready, let's test it and view the latest commits in -Jansson's repository:: - - $ ./github_commits akheron jansson - 1581f26a Merge branch '2.3' - aabfd493 load: Change buffer_pos to be a size_t - bd72efbd load: Avoid unexpected behaviour in macro expansion - e8fd3e30 Document and tweak json_load_callback() - 873eddaf Merge pull request #60 from rogerz/contrib - bd2c0c73 Ignore the binary test_load_callback - 17a51a4b Merge branch '2.3' - 09c39adc Add json_load_callback to the list of exported symbols - cbb80baf Merge pull request #57 from rogerz/contrib - 040bd7b0 Add json_load_callback() - 2637faa4 Make test stripping locale independent - <...> - - -Conclusion -========== - -In this tutorial, we implemented a program that fetches the latest -commits of a GitHub repository using the GitHub Repo Commits API. -Jansson was used to decode the JSON response and to extract the commit -data. - -This tutorial only covered a small part of Jansson. For example, we -did not create or manipulate JSON values at all. Proceed to -:ref:`apiref` to explore all features of Jansson. diff --git a/deps/jansson/doc/upgrading.rst b/deps/jansson/doc/upgrading.rst deleted file mode 100644 index 9b49046..0000000 --- a/deps/jansson/doc/upgrading.rst +++ /dev/null @@ -1,76 +0,0 @@ -.. highlight:: c - -****************** -Upgrading from 1.x -****************** - -This chapter lists the backwards incompatible changes introduced in -Jansson 2.0, and the steps that are needed for upgrading your code. - -**The incompatibilities are not dramatic.** The biggest change is that -all decoding functions now require and extra parameter. Most programs -can be modified to work with 2.0 by adding a ``0`` as the second -parameter to all calls of :func:`json_loads()`, :func:`json_loadf()` -and :func:`json_load_file()`. - - -Compatibility -============= - -Jansson 2.0 is backwards incompatible with the Jansson 1.x releases. -It is ABI incompatible, i.e. all programs dynamically linking to the -Jansson library need to be recompiled. It's also API incompatible, -i.e. the source code of programs using Jansson 1.x may need -modifications to make them compile against Jansson 2.0. - -All the 2.x releases are guaranteed to be backwards compatible for -both ABI and API, so no recompilation or source changes are needed -when upgrading from 2.x to 2.y. - - -List of Incompatible Changes -============================ - -**Decoding flags** - For future needs, a ``flags`` parameter was added as the second - parameter to all decoding functions, i.e. :func:`json_loads()`, - :func:`json_loadf()` and :func:`json_load_file()`. All calls to - these functions need to be changed by adding a ``0`` as the second - argument. For example:: - - /* old code */ - json_loads(input, &error); - - /* new code */ - json_loads(input, 0, &error); - - -**Underlying type of JSON integers** - The underlying C type of JSON integers has been changed from - :type:`int` to the widest available signed integer type, i.e. - :type:`long long` or :type:`long`, depending on whether - :type:`long long` is supported on your system or not. This makes - the whole 64-bit integer range available on most modern systems. - - ``jansson.h`` has a typedef :type:`json_int_t` to the underlying - integer type. :type:`int` should still be used in most cases when - dealing with smallish JSON integers, as the compiler handles - implicit type coercion. Only when the full 64-bit range is needed, - :type:`json_int_t` should be explicitly used. - - -**Maximum encoder indentation depth** - The maximum argument of the ``JSON_INDENT()`` macro has been - changed from 255 to 31, to free up bits from the ``flags`` - parameter of :func:`json_dumps()`, :func:`json_dumpf()` and - :func:`json_dump_file()`. If your code uses a bigger indentation - than 31, it needs to be changed. - - -**Unsigned integers in API functions** - Version 2.0 unifies unsigned integer usage in the API. All uses of - :type:`unsigned int` and :type:`unsigned long` have been replaced - with :type:`size_t`. This includes flags, container sizes, etc. - This should not require source code changes, as both - :type:`unsigned int` and :type:`unsigned long` are usually - compatible with :type:`size_t`. diff --git a/deps/jansson/jansson.pc.in b/deps/jansson/jansson.pc.in deleted file mode 100644 index d9bf4da..0000000 --- a/deps/jansson/jansson.pc.in +++ /dev/null @@ -1,10 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=${prefix}/include - -Name: Jansson -Description: Library for encoding, decoding and manipulating JSON data -Version: @VERSION@ -Libs: -L${libdir} -ljansson -Cflags: -I${includedir} diff --git a/deps/jansson/release.sh b/deps/jansson/release.sh deleted file mode 100755 index c2551f8..0000000 --- a/deps/jansson/release.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/sh -# -# Use this script to easily make releases of Jansson. It configures -# the source tree, and builds and signs all tarballs. - -die() { - echo $1 >&2 - exit 1 -} - -confirm() { - local answer - read -p "$1 [yN]: " answer - [ "$answer" = "Y" -o "$answer" = "y" ] || exit 0 -} - -set -e -[ -f configure.ac ] || die "Must be run at project root directory" - -# Determine version -v=$(grep AC_INIT configure.ac | sed -r 's/.*, \[(.+?)\],.*/\1/') -[ -n "$v" ] || die "Unable to determine version" -confirm "Version is $v, proceed?" - -# Sanity checks -vi=$(grep version-info src/Makefile.am | sed 's/^[ \t]*//g' | cut -d" " -f2) -confirm "Libtool version-info is $vi, proceed?" - -r=$(grep 'Released ' CHANGES | head -n 1) -confirm "Last CHANGES entry says \"$r\", proceed??" - -dv=$(grep ^version doc/conf.py | sed -r "s/.*'(.*)'.*/\1/") -if [ "$dv" != "$v" ]; then - die "Documentation version ($dv) doesn't match library version" -fi - -[ -f Makefile ] && make distclean || true -rm -f jansson-$v.tar.* -rm -rf jansson-$v-doc -rm -f jansson-$v-doc.tar.* - -autoreconf -fi -./configure - -# Run tests and make gz source tarball -: ${VALGRIND:=1} -export VALGRIND -make distcheck - -# Make bzip2 source tarball -make dist-bzip2 - -# Sign source tarballs -for s in gz bz2; do - gpg --detach-sign --armor jansson-$v.tar.$s -done - -# Build documentation -make html -mv doc/_build/html jansson-$v-doc - -# Make and sign documentation tarballs -for s in gz bz2; do - [ $s = gz ] && compress=gzip - [ $s = bz2 ] && compress=bzip2 - tar cf - jansson-$v-doc | $compress -9 -c > jansson-$v-doc.tar.$s - gpg --detach-sign --armor jansson-$v-doc.tar.$s -done - -echo "All done" diff --git a/deps/jansson/src/Makefile.am b/deps/jansson/src/Makefile.am deleted file mode 100644 index e1a5493..0000000 --- a/deps/jansson/src/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -EXTRA_DIST = jansson.def - -include_HEADERS = jansson.h jansson_config.h - -lib_LTLIBRARIES = libjansson.la -libjansson_la_SOURCES = \ - dump.c \ - error.c \ - hashtable.c \ - hashtable.h \ - jansson_private.h \ - load.c \ - memory.c \ - pack_unpack.c \ - strbuffer.c \ - strbuffer.h \ - strconv.c \ - utf.c \ - utf.h \ - value.c -libjansson_la_LDFLAGS = \ - -no-undefined \ - -export-symbols-regex '^json_' \ - -version-info 9:0:5 diff --git a/deps/jansson/src/dump.c b/deps/jansson/src/dump.c deleted file mode 100644 index 26a1906..0000000 --- a/deps/jansson/src/dump.c +++ /dev/null @@ -1,458 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include -#include -#include -#include - -#include "jansson.h" -#include "jansson_private.h" -#include "strbuffer.h" -#include "utf.h" - -#define MAX_INTEGER_STR_LENGTH 100 -#define MAX_REAL_STR_LENGTH 100 - -struct object_key { - size_t serial; - const char *key; -}; - -static int dump_to_strbuffer(const char *buffer, size_t size, void *data) -{ - return strbuffer_append_bytes((strbuffer_t *)data, buffer, size); -} - -static int dump_to_file(const char *buffer, size_t size, void *data) -{ - FILE *dest = (FILE *)data; - if(fwrite(buffer, size, 1, dest) != 1) - return -1; - return 0; -} - -/* 32 spaces (the maximum indentation size) */ -static const char whitespace[] = " "; - -static int dump_indent(size_t flags, int depth, int space, json_dump_callback_t dump, void *data) -{ - if(JSON_INDENT(flags) > 0) - { - int i, ws_count = JSON_INDENT(flags); - - if(dump("\n", 1, data)) - return -1; - - for(i = 0; i < depth; i++) - { - if(dump(whitespace, ws_count, data)) - return -1; - } - } - else if(space && !(flags & JSON_COMPACT)) - { - return dump(" ", 1, data); - } - return 0; -} - -static int dump_string(const char *str, size_t len, json_dump_callback_t dump, void *data, size_t flags) -{ - const char *pos, *end, *lim; - int32_t codepoint; - - if(dump("\"", 1, data)) - return -1; - - end = pos = str; - lim = str + len; - while(1) - { - const char *text; - char seq[13]; - int length; - - while(end < lim) - { - end = utf8_iterate(pos, lim - pos, &codepoint); - if(!end) - return -1; - - /* mandatory escape or control char */ - if(codepoint == '\\' || codepoint == '"' || codepoint < 0x20) - break; - - /* slash */ - if((flags & JSON_ESCAPE_SLASH) && codepoint == '/') - break; - - /* non-ASCII */ - if((flags & JSON_ENSURE_ASCII) && codepoint > 0x7F) - break; - - pos = end; - } - - if(pos != str) { - if(dump(str, pos - str, data)) - return -1; - } - - if(end == pos) - break; - - /* handle \, /, ", and control codes */ - length = 2; - switch(codepoint) - { - case '\\': text = "\\\\"; break; - case '\"': text = "\\\""; break; - case '\b': text = "\\b"; break; - case '\f': text = "\\f"; break; - case '\n': text = "\\n"; break; - case '\r': text = "\\r"; break; - case '\t': text = "\\t"; break; - case '/': text = "\\/"; break; - default: - { - /* codepoint is in BMP */ - if(codepoint < 0x10000) - { - sprintf(seq, "\\u%04X", codepoint); - length = 6; - } - - /* not in BMP -> construct a UTF-16 surrogate pair */ - else - { - int32_t first, last; - - codepoint -= 0x10000; - first = 0xD800 | ((codepoint & 0xffc00) >> 10); - last = 0xDC00 | (codepoint & 0x003ff); - - sprintf(seq, "\\u%04X\\u%04X", first, last); - length = 12; - } - - text = seq; - break; - } - } - - if(dump(text, length, data)) - return -1; - - str = pos = end; - } - - return dump("\"", 1, data); -} - -static int object_key_compare_keys(const void *key1, const void *key2) -{ - return strcmp(((const struct object_key *)key1)->key, - ((const struct object_key *)key2)->key); -} - -static int object_key_compare_serials(const void *key1, const void *key2) -{ - size_t a = ((const struct object_key *)key1)->serial; - size_t b = ((const struct object_key *)key2)->serial; - - return a < b ? -1 : a == b ? 0 : 1; -} - -static int do_dump(const json_t *json, size_t flags, int depth, - json_dump_callback_t dump, void *data) -{ - if(!json) - return -1; - - switch(json_typeof(json)) { - case JSON_NULL: - return dump("null", 4, data); - - case JSON_TRUE: - return dump("true", 4, data); - - case JSON_FALSE: - return dump("false", 5, data); - - case JSON_INTEGER: - { - char buffer[MAX_INTEGER_STR_LENGTH]; - int size; - - size = snprintf(buffer, MAX_INTEGER_STR_LENGTH, - "%" JSON_INTEGER_FORMAT, - json_integer_value(json)); - if(size < 0 || size >= MAX_INTEGER_STR_LENGTH) - return -1; - - return dump(buffer, size, data); - } - - case JSON_REAL: - { - char buffer[MAX_REAL_STR_LENGTH]; - int size; - double value = json_real_value(json); - - size = jsonp_dtostr(buffer, MAX_REAL_STR_LENGTH, value); - if(size < 0) - return -1; - - return dump(buffer, size, data); - } - - case JSON_STRING: - return dump_string(json_string_value(json), json_string_length(json), dump, data, flags); - - case JSON_ARRAY: - { - int i; - int n; - json_array_t *array; - - /* detect circular references */ - array = json_to_array(json); - if(array->visited) - goto array_error; - array->visited = 1; - - n = (int)json_array_size(json); - - if(dump("[", 1, data)) - goto array_error; - if(n == 0) { - array->visited = 0; - return dump("]", 1, data); - } - if(dump_indent(flags, depth + 1, 0, dump, data)) - goto array_error; - - for(i = 0; i < n; ++i) { - if(do_dump(json_array_get(json, i), flags, depth + 1, - dump, data)) - goto array_error; - - if(i < n - 1) - { - if(dump(",", 1, data) || - dump_indent(flags, depth + 1, 1, dump, data)) - goto array_error; - } - else - { - if(dump_indent(flags, depth, 0, dump, data)) - goto array_error; - } - } - - array->visited = 0; - return dump("]", 1, data); - - array_error: - array->visited = 0; - return -1; - } - - case JSON_OBJECT: - { - json_object_t *object; - void *iter; - const char *separator; - int separator_length; - - if(flags & JSON_COMPACT) { - separator = ":"; - separator_length = 1; - } - else { - separator = ": "; - separator_length = 2; - } - - /* detect circular references */ - object = json_to_object(json); - if(object->visited) - goto object_error; - object->visited = 1; - - iter = json_object_iter((json_t *)json); - - if(dump("{", 1, data)) - goto object_error; - if(!iter) { - object->visited = 0; - return dump("}", 1, data); - } - if(dump_indent(flags, depth + 1, 0, dump, data)) - goto object_error; - - if(flags & JSON_SORT_KEYS || flags & JSON_PRESERVE_ORDER) - { - struct object_key *keys; - size_t size, i; - int (*cmp_func)(const void *, const void *); - - size = json_object_size(json); - keys = jsonp_malloc(size * sizeof(struct object_key)); - if(!keys) - goto object_error; - - i = 0; - while(iter) - { - keys[i].serial = hashtable_iter_serial(iter); - keys[i].key = json_object_iter_key(iter); - iter = json_object_iter_next((json_t *)json, iter); - i++; - } - assert(i == size); - - if(flags & JSON_SORT_KEYS) - cmp_func = object_key_compare_keys; - else - cmp_func = object_key_compare_serials; - - qsort(keys, size, sizeof(struct object_key), cmp_func); - - for(i = 0; i < size; i++) - { - const char *key; - json_t *value; - - key = keys[i].key; - value = json_object_get(json, key); - assert(value); - - dump_string(key, strlen(key), dump, data, flags); - if(dump(separator, separator_length, data) || - do_dump(value, flags, depth + 1, dump, data)) - { - jsonp_free(keys); - goto object_error; - } - - if(i < size - 1) - { - if(dump(",", 1, data) || - dump_indent(flags, depth + 1, 1, dump, data)) - { - jsonp_free(keys); - goto object_error; - } - } - else - { - if(dump_indent(flags, depth, 0, dump, data)) - { - jsonp_free(keys); - goto object_error; - } - } - } - - jsonp_free(keys); - } - else - { - /* Don't sort keys */ - - while(iter) - { - void *next = json_object_iter_next((json_t *)json, iter); - const char *key = json_object_iter_key(iter); - - dump_string(key, strlen(key), dump, data, flags); - if(dump(separator, separator_length, data) || - do_dump(json_object_iter_value(iter), flags, depth + 1, - dump, data)) - goto object_error; - - if(next) - { - if(dump(",", 1, data) || - dump_indent(flags, depth + 1, 1, dump, data)) - goto object_error; - } - else - { - if(dump_indent(flags, depth, 0, dump, data)) - goto object_error; - } - - iter = next; - } - } - - object->visited = 0; - return dump("}", 1, data); - - object_error: - object->visited = 0; - return -1; - } - - default: - /* not reached */ - return -1; - } -} - -char *json_dumps(const json_t *json, size_t flags) -{ - strbuffer_t strbuff; - char *result; - - if(strbuffer_init(&strbuff)) - return NULL; - - if(json_dump_callback(json, dump_to_strbuffer, (void *)&strbuff, flags)) - result = NULL; - else - result = jsonp_strdup(strbuffer_value(&strbuff)); - - strbuffer_close(&strbuff); - return result; -} - -int json_dumpf(const json_t *json, FILE *output, size_t flags) -{ - return json_dump_callback(json, dump_to_file, (void *)output, flags); -} - -int json_dump_file(const json_t *json, const char *path, size_t flags) -{ - int result; - - FILE *output = fopen(path, "w"); - if(!output) - return -1; - - result = json_dumpf(json, output, flags); - - fclose(output); - return result; -} - -int json_dump_callback(const json_t *json, json_dump_callback_t callback, void *data, size_t flags) -{ - if(!(flags & JSON_ENCODE_ANY)) { - if(!json_is_array(json) && !json_is_object(json)) - return -1; - } - - return do_dump(json, flags, 0, callback, data); -} diff --git a/deps/jansson/src/error.c b/deps/jansson/src/error.c deleted file mode 100644 index 2ba8d82..0000000 --- a/deps/jansson/src/error.c +++ /dev/null @@ -1,63 +0,0 @@ -#include -#include "jansson_private.h" - -void jsonp_error_init(json_error_t *error, const char *source) -{ - if(error) - { - error->text[0] = '\0'; - error->line = -1; - error->column = -1; - error->position = 0; - if(source) - jsonp_error_set_source(error, source); - else - error->source[0] = '\0'; - } -} - -void jsonp_error_set_source(json_error_t *error, const char *source) -{ - size_t length; - - if(!error || !source) - return; - - length = strlen(source); - if(length < JSON_ERROR_SOURCE_LENGTH) - strcpy(error->source, source); - else { - size_t extra = length - JSON_ERROR_SOURCE_LENGTH + 4; - strcpy(error->source, "..."); - strcpy(error->source + 3, source + extra); - } -} - -void jsonp_error_set(json_error_t *error, int line, int column, - size_t position, const char *msg, ...) -{ - va_list ap; - - va_start(ap, msg); - jsonp_error_vset(error, line, column, position, msg, ap); - va_end(ap); -} - -void jsonp_error_vset(json_error_t *error, int line, int column, - size_t position, const char *msg, va_list ap) -{ - if(!error) - return; - - if(error->text[0] != '\0') { - /* error already set */ - return; - } - - error->line = line; - error->column = column; - error->position = (int)position; - - vsnprintf(error->text, JSON_ERROR_TEXT_LENGTH, msg, ap); - error->text[JSON_ERROR_TEXT_LENGTH - 1] = '\0'; -} diff --git a/deps/jansson/src/hashtable.c b/deps/jansson/src/hashtable.c deleted file mode 100644 index a254cfa..0000000 --- a/deps/jansson/src/hashtable.c +++ /dev/null @@ -1,367 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#include -#include -#include /* for JSON_INLINE */ -#include "jansson_private.h" /* for container_of() */ -#include "hashtable.h" - -typedef struct hashtable_list list_t; -typedef struct hashtable_pair pair_t; -typedef struct hashtable_bucket bucket_t; - -#define list_to_pair(list_) container_of(list_, pair_t, list) - -/* From http://www.cse.yorku.ca/~oz/hash.html */ -static size_t hash_str(const void *ptr) -{ - const char *str = (const char *)ptr; - - size_t hash = 5381; - size_t c; - - while((c = (size_t)*str)) - { - hash = ((hash << 5) + hash) + c; - str++; - } - - return hash; -} - -static JSON_INLINE void list_init(list_t *list) -{ - list->next = list; - list->prev = list; -} - -static JSON_INLINE void list_insert(list_t *list, list_t *node) -{ - node->next = list; - node->prev = list->prev; - list->prev->next = node; - list->prev = node; -} - -static JSON_INLINE void list_remove(list_t *list) -{ - list->prev->next = list->next; - list->next->prev = list->prev; -} - -static JSON_INLINE int bucket_is_empty(hashtable_t *hashtable, bucket_t *bucket) -{ - return bucket->first == &hashtable->list && bucket->first == bucket->last; -} - -static void insert_to_bucket(hashtable_t *hashtable, bucket_t *bucket, - list_t *list) -{ - if(bucket_is_empty(hashtable, bucket)) - { - list_insert(&hashtable->list, list); - bucket->first = bucket->last = list; - } - else - { - list_insert(bucket->first, list); - bucket->first = list; - } -} - -static const size_t primes[] = { - 5, 13, 23, 53, 97, 193, 389, 769, 1543, 3079, 6151, 12289, 24593, - 49157, 98317, 196613, 393241, 786433, 1572869, 3145739, 6291469, - 12582917, 25165843, 50331653, 100663319, 201326611, 402653189, - 805306457, 1610612741 -}; - -static JSON_INLINE size_t num_buckets(hashtable_t *hashtable) -{ - return primes[hashtable->num_buckets]; -} - - -static pair_t *hashtable_find_pair(hashtable_t *hashtable, bucket_t *bucket, - const char *key, size_t hash) -{ - list_t *list; - pair_t *pair; - - if(bucket_is_empty(hashtable, bucket)) - return NULL; - - list = bucket->first; - while(1) - { - pair = list_to_pair(list); - if(pair->hash == hash && strcmp(pair->key, key) == 0) - return pair; - - if(list == bucket->last) - break; - - list = list->next; - } - - return NULL; -} - -/* returns 0 on success, -1 if key was not found */ -static int hashtable_do_del(hashtable_t *hashtable, - const char *key, size_t hash) -{ - pair_t *pair; - bucket_t *bucket; - size_t index; - - index = hash % num_buckets(hashtable); - bucket = &hashtable->buckets[index]; - - pair = hashtable_find_pair(hashtable, bucket, key, hash); - if(!pair) - return -1; - - if(&pair->list == bucket->first && &pair->list == bucket->last) - bucket->first = bucket->last = &hashtable->list; - - else if(&pair->list == bucket->first) - bucket->first = pair->list.next; - - else if(&pair->list == bucket->last) - bucket->last = pair->list.prev; - - list_remove(&pair->list); - json_decref(pair->value); - - jsonp_free(pair); - hashtable->size--; - - return 0; -} - -static void hashtable_do_clear(hashtable_t *hashtable) -{ - list_t *list, *next; - pair_t *pair; - - for(list = hashtable->list.next; list != &hashtable->list; list = next) - { - next = list->next; - pair = list_to_pair(list); - json_decref(pair->value); - jsonp_free(pair); - } -} - -static int hashtable_do_rehash(hashtable_t *hashtable) -{ - list_t *list, *next; - pair_t *pair; - size_t i, index, new_size; - - jsonp_free(hashtable->buckets); - - hashtable->num_buckets++; - new_size = num_buckets(hashtable); - - hashtable->buckets = jsonp_malloc(new_size * sizeof(bucket_t)); - if(!hashtable->buckets) - return -1; - - for(i = 0; i < num_buckets(hashtable); i++) - { - hashtable->buckets[i].first = hashtable->buckets[i].last = - &hashtable->list; - } - - list = hashtable->list.next; - list_init(&hashtable->list); - - for(; list != &hashtable->list; list = next) { - next = list->next; - pair = list_to_pair(list); - index = pair->hash % new_size; - insert_to_bucket(hashtable, &hashtable->buckets[index], &pair->list); - } - - return 0; -} - - -int hashtable_init(hashtable_t *hashtable) -{ - size_t i; - - hashtable->size = 0; - hashtable->num_buckets = 0; /* index to primes[] */ - hashtable->buckets = jsonp_malloc(num_buckets(hashtable) * sizeof(bucket_t)); - if(!hashtable->buckets) - return -1; - - list_init(&hashtable->list); - - for(i = 0; i < num_buckets(hashtable); i++) - { - hashtable->buckets[i].first = hashtable->buckets[i].last = - &hashtable->list; - } - - return 0; -} - -void hashtable_close(hashtable_t *hashtable) -{ - hashtable_do_clear(hashtable); - jsonp_free(hashtable->buckets); -} - -int hashtable_set(hashtable_t *hashtable, - const char *key, size_t serial, - json_t *value) -{ - pair_t *pair; - bucket_t *bucket; - size_t hash, index; - - /* rehash if the load ratio exceeds 1 */ - if(hashtable->size >= num_buckets(hashtable)) - if(hashtable_do_rehash(hashtable)) - return -1; - - hash = hash_str(key); - index = hash % num_buckets(hashtable); - bucket = &hashtable->buckets[index]; - pair = hashtable_find_pair(hashtable, bucket, key, hash); - - if(pair) - { - json_decref(pair->value); - pair->value = value; - } - else - { - /* offsetof(...) returns the size of pair_t without the last, - flexible member. This way, the correct amount is - allocated. */ - - size_t len = strlen(key); - if(len >= (size_t)-1 - offsetof(pair_t, key)) { - /* Avoid an overflow if the key is very long */ - return -1; - } - - pair = jsonp_malloc(offsetof(pair_t, key) + len + 1); - if(!pair) - return -1; - - pair->hash = hash; - pair->serial = serial; - strcpy(pair->key, key); - pair->value = value; - list_init(&pair->list); - - insert_to_bucket(hashtable, bucket, &pair->list); - - hashtable->size++; - } - return 0; -} - -void *hashtable_get(hashtable_t *hashtable, const char *key) -{ - pair_t *pair; - size_t hash; - bucket_t *bucket; - - hash = hash_str(key); - bucket = &hashtable->buckets[hash % num_buckets(hashtable)]; - - pair = hashtable_find_pair(hashtable, bucket, key, hash); - if(!pair) - return NULL; - - return pair->value; -} - -int hashtable_del(hashtable_t *hashtable, const char *key) -{ - size_t hash = hash_str(key); - return hashtable_do_del(hashtable, key, hash); -} - -void hashtable_clear(hashtable_t *hashtable) -{ - size_t i; - - hashtable_do_clear(hashtable); - - for(i = 0; i < num_buckets(hashtable); i++) - { - hashtable->buckets[i].first = hashtable->buckets[i].last = - &hashtable->list; - } - - list_init(&hashtable->list); - hashtable->size = 0; -} - -void *hashtable_iter(hashtable_t *hashtable) -{ - return hashtable_iter_next(hashtable, &hashtable->list); -} - -void *hashtable_iter_at(hashtable_t *hashtable, const char *key) -{ - pair_t *pair; - size_t hash; - bucket_t *bucket; - - hash = hash_str(key); - bucket = &hashtable->buckets[hash % num_buckets(hashtable)]; - - pair = hashtable_find_pair(hashtable, bucket, key, hash); - if(!pair) - return NULL; - - return &pair->list; -} - -void *hashtable_iter_next(hashtable_t *hashtable, void *iter) -{ - list_t *list = (list_t *)iter; - if(list->next == &hashtable->list) - return NULL; - return list->next; -} - -void *hashtable_iter_key(void *iter) -{ - pair_t *pair = list_to_pair((list_t *)iter); - return pair->key; -} - -size_t hashtable_iter_serial(void *iter) -{ - pair_t *pair = list_to_pair((list_t *)iter); - return pair->serial; -} - -void *hashtable_iter_value(void *iter) -{ - pair_t *pair = list_to_pair((list_t *)iter); - return pair->value; -} - -void hashtable_iter_set(void *iter, json_t *value) -{ - pair_t *pair = list_to_pair((list_t *)iter); - - json_decref(pair->value); - pair->value = value; -} diff --git a/deps/jansson/src/hashtable.h b/deps/jansson/src/hashtable.h deleted file mode 100644 index 4a7ce6f..0000000 --- a/deps/jansson/src/hashtable.h +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#ifndef HASHTABLE_H -#define HASHTABLE_H - -struct hashtable_list { - struct hashtable_list *prev; - struct hashtable_list *next; -}; - -/* "pair" may be a bit confusing a name, but think of it as a - key-value pair. In this case, it just encodes some extra data, - too */ -struct hashtable_pair { - size_t hash; - struct hashtable_list list; - json_t *value; - size_t serial; - char key[1]; -}; - -struct hashtable_bucket { - struct hashtable_list *first; - struct hashtable_list *last; -}; - -typedef struct hashtable { - size_t size; - struct hashtable_bucket *buckets; - size_t num_buckets; /* index to primes[] */ - struct hashtable_list list; -} hashtable_t; - - -#define hashtable_key_to_iter(key_) \ - (&(container_of(key_, struct hashtable_pair, key)->list)) - -/** - * hashtable_init - Initialize a hashtable object - * - * @hashtable: The (statically allocated) hashtable object - * - * Initializes a statically allocated hashtable object. The object - * should be cleared with hashtable_close when it's no longer used. - * - * Returns 0 on success, -1 on error (out of memory). - */ -int hashtable_init(hashtable_t *hashtable); - -/** - * hashtable_close - Release all resources used by a hashtable object - * - * @hashtable: The hashtable - * - * Destroys a statically allocated hashtable object. - */ -void hashtable_close(hashtable_t *hashtable); - -/** - * hashtable_set - Add/modify value in hashtable - * - * @hashtable: The hashtable object - * @key: The key - * @serial: For addition order of keys - * @value: The value - * - * If a value with the given key already exists, its value is replaced - * with the new value. Value is "stealed" in the sense that hashtable - * doesn't increment its refcount but decreases the refcount when the - * value is no longer needed. - * - * Returns 0 on success, -1 on failure (out of memory). - */ -int hashtable_set(hashtable_t *hashtable, - const char *key, size_t serial, - json_t *value); - -/** - * hashtable_get - Get a value associated with a key - * - * @hashtable: The hashtable object - * @key: The key - * - * Returns value if it is found, or NULL otherwise. - */ -void *hashtable_get(hashtable_t *hashtable, const char *key); - -/** - * hashtable_del - Remove a value from the hashtable - * - * @hashtable: The hashtable object - * @key: The key - * - * Returns 0 on success, or -1 if the key was not found. - */ -int hashtable_del(hashtable_t *hashtable, const char *key); - -/** - * hashtable_clear - Clear hashtable - * - * @hashtable: The hashtable object - * - * Removes all items from the hashtable. - */ -void hashtable_clear(hashtable_t *hashtable); - -/** - * hashtable_iter - Iterate over hashtable - * - * @hashtable: The hashtable object - * - * Returns an opaque iterator to the first element in the hashtable. - * The iterator should be passed to hashtable_iter_* functions. - * The hashtable items are not iterated over in any particular order. - * - * There's no need to free the iterator in any way. The iterator is - * valid as long as the item that is referenced by the iterator is not - * deleted. Other values may be added or deleted. In particular, - * hashtable_iter_next() may be called on an iterator, and after that - * the key/value pair pointed by the old iterator may be deleted. - */ -void *hashtable_iter(hashtable_t *hashtable); - -/** - * hashtable_iter_at - Return an iterator at a specific key - * - * @hashtable: The hashtable object - * @key: The key that the iterator should point to - * - * Like hashtable_iter() but returns an iterator pointing to a - * specific key. - */ -void *hashtable_iter_at(hashtable_t *hashtable, const char *key); - -/** - * hashtable_iter_next - Advance an iterator - * - * @hashtable: The hashtable object - * @iter: The iterator - * - * Returns a new iterator pointing to the next element in the - * hashtable or NULL if the whole hastable has been iterated over. - */ -void *hashtable_iter_next(hashtable_t *hashtable, void *iter); - -/** - * hashtable_iter_key - Retrieve the key pointed by an iterator - * - * @iter: The iterator - */ -void *hashtable_iter_key(void *iter); - -/** - * hashtable_iter_serial - Retrieve the serial number pointed to by an iterator - * - * @iter: The iterator - */ -size_t hashtable_iter_serial(void *iter); - -/** - * hashtable_iter_value - Retrieve the value pointed by an iterator - * - * @iter: The iterator - */ -void *hashtable_iter_value(void *iter); - -/** - * hashtable_iter_set - Set the value pointed by an iterator - * - * @iter: The iterator - * @value: The value to set - */ -void hashtable_iter_set(void *iter, json_t *value); - -#endif diff --git a/deps/jansson/src/jansson.def b/deps/jansson/src/jansson.def deleted file mode 100644 index 3c7d6d1..0000000 --- a/deps/jansson/src/jansson.def +++ /dev/null @@ -1,68 +0,0 @@ -EXPORTS - json_delete - json_true - json_false - json_null - json_string - json_stringn - json_string_nocheck - json_stringn_nocheck - json_string_value - json_string_length - json_string_set - json_string_setn - json_string_set_nocheck - json_string_setn_nocheck - json_integer - json_integer_value - json_integer_set - json_real - json_real_value - json_real_set - json_number_value - json_array - json_array_size - json_array_get - json_array_set_new - json_array_append_new - json_array_insert_new - json_array_remove - json_array_clear - json_array_extend - json_object - json_object_size - json_object_get - json_object_set_new - json_object_set_new_nocheck - json_object_del - json_object_clear - json_object_update - json_object_update_existing - json_object_update_missing - json_object_iter - json_object_iter_at - json_object_iter_next - json_object_iter_key - json_object_iter_value - json_object_iter_set_new - json_object_key_to_iter - json_dumps - json_dumpf - json_dump_file - json_dump_callback - json_loads - json_loadb - json_loadf - json_load_file - json_load_callback - json_equal - json_copy - json_deep_copy - json_pack - json_pack_ex - json_vpack_ex - json_unpack - json_unpack_ex - json_vunpack_ex - json_set_alloc_funcs - diff --git a/deps/jansson/src/jansson.h b/deps/jansson/src/jansson.h deleted file mode 100644 index c497598..0000000 --- a/deps/jansson/src/jansson.h +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#ifndef JANSSON_H -#define JANSSON_H - -#include -#include /* for size_t */ -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* version */ - -#define JANSSON_MAJOR_VERSION 2 -#define JANSSON_MINOR_VERSION 5 -#define JANSSON_MICRO_VERSION 0 - -/* Micro version is omitted if it's 0 */ -#define JANSSON_VERSION "2.5" - -/* Version as a 3-byte hex number, e.g. 0x010201 == 1.2.1. Use this - for numeric comparisons, e.g. #if JANSSON_VERSION_HEX >= ... */ -#define JANSSON_VERSION_HEX ((JANSSON_MAJOR_VERSION << 16) | \ - (JANSSON_MINOR_VERSION << 8) | \ - (JANSSON_MICRO_VERSION << 0)) - - -/* types */ - -typedef enum { - JSON_OBJECT, - JSON_ARRAY, - JSON_STRING, - JSON_INTEGER, - JSON_REAL, - JSON_TRUE, - JSON_FALSE, - JSON_NULL -} json_type; - -typedef struct json_t { - json_type type; - size_t refcount; -} json_t; - -#ifndef JANSSON_USING_CMAKE /* disabled if using cmake */ -#if JSON_INTEGER_IS_LONG_LONG -#ifdef _WIN32 -#define JSON_INTEGER_FORMAT "I64d" -#else -#define JSON_INTEGER_FORMAT "lld" -#endif -typedef long long json_int_t; -#else -#define JSON_INTEGER_FORMAT "ld" -typedef long json_int_t; -#endif /* JSON_INTEGER_IS_LONG_LONG */ -#endif - -#define json_typeof(json) ((json)->type) -#define json_is_object(json) ((json) && json_typeof(json) == JSON_OBJECT) -#define json_is_array(json) ((json) && json_typeof(json) == JSON_ARRAY) -#define json_is_string(json) ((json) && json_typeof(json) == JSON_STRING) -#define json_is_integer(json) ((json) && json_typeof(json) == JSON_INTEGER) -#define json_is_real(json) ((json) && json_typeof(json) == JSON_REAL) -#define json_is_number(json) (json_is_integer(json) || json_is_real(json)) -#define json_is_true(json) ((json) && json_typeof(json) == JSON_TRUE) -#define json_is_false(json) ((json) && json_typeof(json) == JSON_FALSE) -#define json_boolean_value json_is_true -#define json_is_boolean(json) (json_is_true(json) || json_is_false(json)) -#define json_is_null(json) ((json) && json_typeof(json) == JSON_NULL) - -/* construction, destruction, reference counting */ - -json_t *json_object(void); -json_t *json_array(void); -json_t *json_string(const char *value); -json_t *json_stringn(const char *value, size_t len); -json_t *json_string_nocheck(const char *value); -json_t *json_stringn_nocheck(const char *value, size_t len); -json_t *json_integer(json_int_t value); -json_t *json_real(double value); -json_t *json_true(void); -json_t *json_false(void); -#define json_boolean(val) ((val) ? json_true() : json_false()) -json_t *json_null(void); - -static JSON_INLINE -json_t *json_incref(json_t *json) -{ - if(json && json->refcount != (size_t)-1) - ++json->refcount; - return json; -} - -/* do not call json_delete directly */ -void json_delete(json_t *json); - -static JSON_INLINE -void json_decref(json_t *json) -{ - if(json && json->refcount != (size_t)-1 && --json->refcount == 0) - json_delete(json); -} - - -/* error reporting */ - -#define JSON_ERROR_TEXT_LENGTH 160 -#define JSON_ERROR_SOURCE_LENGTH 80 - -typedef struct { - int line; - int column; - int position; - char source[JSON_ERROR_SOURCE_LENGTH]; - char text[JSON_ERROR_TEXT_LENGTH]; -} json_error_t; - - -/* getters, setters, manipulation */ - -size_t json_object_size(const json_t *object); -json_t *json_object_get(const json_t *object, const char *key); -int json_object_set_new(json_t *object, const char *key, json_t *value); -int json_object_set_new_nocheck(json_t *object, const char *key, json_t *value); -int json_object_del(json_t *object, const char *key); -int json_object_clear(json_t *object); -int json_object_update(json_t *object, json_t *other); -int json_object_update_existing(json_t *object, json_t *other); -int json_object_update_missing(json_t *object, json_t *other); -void *json_object_iter(json_t *object); -void *json_object_iter_at(json_t *object, const char *key); -void *json_object_key_to_iter(const char *key); -void *json_object_iter_next(json_t *object, void *iter); -const char *json_object_iter_key(void *iter); -json_t *json_object_iter_value(void *iter); -int json_object_iter_set_new(json_t *object, void *iter, json_t *value); - -#define json_object_foreach(object, key, value) \ - for(key = json_object_iter_key(json_object_iter(object)); \ - key && (value = json_object_iter_value(json_object_key_to_iter(key))); \ - key = json_object_iter_key(json_object_iter_next(object, json_object_key_to_iter(key)))) - -#define json_array_foreach(array, index, value) \ - for(index = 0; \ - index < json_array_size(array) && (value = json_array_get(array, index)); \ - index++) - -static JSON_INLINE -int json_object_set(json_t *object, const char *key, json_t *value) -{ - return json_object_set_new(object, key, json_incref(value)); -} - -static JSON_INLINE -int json_object_set_nocheck(json_t *object, const char *key, json_t *value) -{ - return json_object_set_new_nocheck(object, key, json_incref(value)); -} - -static JSON_INLINE -int json_object_iter_set(json_t *object, void *iter, json_t *value) -{ - return json_object_iter_set_new(object, iter, json_incref(value)); -} - -size_t json_array_size(const json_t *array); -json_t *json_array_get(const json_t *array, size_t index); -int json_array_set_new(json_t *array, size_t index, json_t *value); -int json_array_append_new(json_t *array, json_t *value); -int json_array_insert_new(json_t *array, size_t index, json_t *value); -int json_array_remove(json_t *array, size_t index); -int json_array_clear(json_t *array); -int json_array_extend(json_t *array, json_t *other); - -static JSON_INLINE -int json_array_set(json_t *array, size_t ind, json_t *value) -{ - return json_array_set_new(array, ind, json_incref(value)); -} - -static JSON_INLINE -int json_array_append(json_t *array, json_t *value) -{ - return json_array_append_new(array, json_incref(value)); -} - -static JSON_INLINE -int json_array_insert(json_t *array, size_t ind, json_t *value) -{ - return json_array_insert_new(array, ind, json_incref(value)); -} - -const char *json_string_value(const json_t *string); -size_t json_string_length(const json_t *string); -json_int_t json_integer_value(const json_t *integer); -double json_real_value(const json_t *real); -double json_number_value(const json_t *json); - -int json_string_set(json_t *string, const char *value); -int json_string_setn(json_t *string, const char *value, size_t len); -int json_string_set_nocheck(json_t *string, const char *value); -int json_string_setn_nocheck(json_t *string, const char *value, size_t len); -int json_integer_set(json_t *integer, json_int_t value); -int json_real_set(json_t *real, double value); - -/* pack, unpack */ - -json_t *json_pack(const char *fmt, ...); -json_t *json_pack_ex(json_error_t *error, size_t flags, const char *fmt, ...); -json_t *json_vpack_ex(json_error_t *error, size_t flags, const char *fmt, va_list ap); - -#define JSON_VALIDATE_ONLY 0x1 -#define JSON_STRICT 0x2 - -int json_unpack(json_t *root, const char *fmt, ...); -int json_unpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt, ...); -int json_vunpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt, va_list ap); - - -/* equality */ - -int json_equal(json_t *value1, json_t *value2); - - -/* copying */ - -json_t *json_copy(json_t *value); -json_t *json_deep_copy(const json_t *value); - - -/* decoding */ - -#define JSON_REJECT_DUPLICATES 0x1 -#define JSON_DISABLE_EOF_CHECK 0x2 -#define JSON_DECODE_ANY 0x4 -#define JSON_DECODE_INT_AS_REAL 0x8 -#define JSON_ALLOW_NUL 0x10 - -typedef size_t (*json_load_callback_t)(void *buffer, size_t buflen, void *data); - -json_t *json_loads(const char *input, size_t flags, json_error_t *error); -json_t *json_loadb(const char *buffer, size_t buflen, size_t flags, json_error_t *error); -json_t *json_loadf(FILE *input, size_t flags, json_error_t *error); -json_t *json_load_file(const char *path, size_t flags, json_error_t *error); -json_t *json_load_callback(json_load_callback_t callback, void *data, size_t flags, json_error_t *error); - - -/* encoding */ - -#define JSON_INDENT(n) (n & 0x1F) -#define JSON_COMPACT 0x20 -#define JSON_ENSURE_ASCII 0x40 -#define JSON_SORT_KEYS 0x80 -#define JSON_PRESERVE_ORDER 0x100 -#define JSON_ENCODE_ANY 0x200 -#define JSON_ESCAPE_SLASH 0x400 - -typedef int (*json_dump_callback_t)(const char *buffer, size_t size, void *data); - -char *json_dumps(const json_t *json, size_t flags); -int json_dumpf(const json_t *json, FILE *output, size_t flags); -int json_dump_file(const json_t *json, const char *path, size_t flags); -int json_dump_callback(const json_t *json, json_dump_callback_t callback, void *data, size_t flags); - -/* custom memory allocation */ - -typedef void *(*json_malloc_t)(size_t); -typedef void (*json_free_t)(void *); - -void json_set_alloc_funcs(json_malloc_t malloc_fn, json_free_t free_fn); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/deps/jansson/src/jansson_config.h.in b/deps/jansson/src/jansson_config.h.in deleted file mode 100644 index 785801f..0000000 --- a/deps/jansson/src/jansson_config.h.in +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2010-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - * - * - * This file specifies a part of the site-specific configuration for - * Jansson, namely those things that affect the public API in - * jansson.h. - * - * The configure script copies this file to jansson_config.h and - * replaces @var@ substitutions by values that fit your system. If you - * cannot run the configure script, you can do the value substitution - * by hand. - */ - -#ifndef JANSSON_CONFIG_H -#define JANSSON_CONFIG_H - -/* If your compiler supports the inline keyword in C, JSON_INLINE is - defined to `inline', otherwise empty. In C++, the inline is always - supported. */ -#ifdef __cplusplus -#define JSON_INLINE inline -#else -#define JSON_INLINE @json_inline@ -#endif - -/* If your compiler supports the `long long` type and the strtoll() - library function, JSON_INTEGER_IS_LONG_LONG is defined to 1, - otherwise to 0. */ -#define JSON_INTEGER_IS_LONG_LONG @json_have_long_long@ - -/* If locale.h and localeconv() are available, define to 1, - otherwise to 0. */ -#define JSON_HAVE_LOCALECONV @json_have_localeconv@ - -#endif diff --git a/deps/jansson/src/jansson_private.h b/deps/jansson/src/jansson_private.h deleted file mode 100644 index eb51d0d..0000000 --- a/deps/jansson/src/jansson_private.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#ifndef JANSSON_PRIVATE_H -#define JANSSON_PRIVATE_H - -#include -#include "jansson.h" -#include "hashtable.h" -#include "strbuffer.h" - -#define container_of(ptr_, type_, member_) \ - ((type_ *)((char *)ptr_ - offsetof(type_, member_))) - -/* On some platforms, max() may already be defined */ -#ifndef max -#define max(a, b) ((a) > (b) ? (a) : (b)) -#endif - -/* va_copy is a C99 feature. In C89 implementations, it's sometimes - available as __va_copy. If not, memcpy() should do the trick. */ -#ifndef va_copy -#ifdef __va_copy -#define va_copy __va_copy -#else -#define va_copy(a, b) memcpy(&(a), &(b), sizeof(va_list)) -#endif -#endif - -typedef struct { - json_t json; - hashtable_t hashtable; - size_t serial; - int visited; -} json_object_t; - -typedef struct { - json_t json; - size_t size; - size_t entries; - json_t **table; - int visited; -} json_array_t; - -typedef struct { - json_t json; - char *value; - size_t length; -} json_string_t; - -typedef struct { - json_t json; - double value; -} json_real_t; - -typedef struct { - json_t json; - json_int_t value; -} json_integer_t; - -#define json_to_object(json_) container_of(json_, json_object_t, json) -#define json_to_array(json_) container_of(json_, json_array_t, json) -#define json_to_string(json_) container_of(json_, json_string_t, json) -#define json_to_real(json_) container_of(json_, json_real_t, json) -#define json_to_integer(json_) container_of(json_, json_integer_t, json) - -/* Create a string by taking ownership of an existing buffer */ -json_t *jsonp_stringn_nocheck_own(const char *value, size_t len); - -/* Error message formatting */ -void jsonp_error_init(json_error_t *error, const char *source); -void jsonp_error_set_source(json_error_t *error, const char *source); -void jsonp_error_set(json_error_t *error, int line, int column, - size_t position, const char *msg, ...); -void jsonp_error_vset(json_error_t *error, int line, int column, - size_t position, const char *msg, va_list ap); - -/* Locale independent string<->double conversions */ -int jsonp_strtod(strbuffer_t *strbuffer, double *out); -int jsonp_dtostr(char *buffer, size_t size, double value); - -/* Wrappers for custom memory functions */ -void* jsonp_malloc(size_t size); -void jsonp_free(void *ptr); -char *jsonp_strndup(const char *str, size_t length); -char *jsonp_strdup(const char *str); -char *jsonp_strndup(const char *str, size_t len); - -/* Windows compatibility */ -#ifdef _WIN32 -#define snprintf _snprintf -#define vsnprintf _vsnprintf -#endif - -#endif diff --git a/deps/jansson/src/load.c b/deps/jansson/src/load.c deleted file mode 100644 index 5d0d1ef..0000000 --- a/deps/jansson/src/load.c +++ /dev/null @@ -1,1105 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include -#include -#include -#include -#include -#include - -#include "jansson.h" -#include "jansson_private.h" -#include "strbuffer.h" -#include "utf.h" - -#define STREAM_STATE_OK 0 -#define STREAM_STATE_EOF -1 -#define STREAM_STATE_ERROR -2 - -#define TOKEN_INVALID -1 -#define TOKEN_EOF 0 -#define TOKEN_STRING 256 -#define TOKEN_INTEGER 257 -#define TOKEN_REAL 258 -#define TOKEN_TRUE 259 -#define TOKEN_FALSE 260 -#define TOKEN_NULL 261 - -/* Locale independent versions of isxxx() functions */ -#define l_isupper(c) ('A' <= (c) && (c) <= 'Z') -#define l_islower(c) ('a' <= (c) && (c) <= 'z') -#define l_isalpha(c) (l_isupper(c) || l_islower(c)) -#define l_isdigit(c) ('0' <= (c) && (c) <= '9') -#define l_isxdigit(c) \ - (l_isdigit(c) || ('A' <= (c) && (c) <= 'F') || ('a' <= (c) && (c) <= 'f')) - -/* Read one byte from stream, convert to unsigned char, then int, and - return. return EOF on end of file. This corresponds to the - behaviour of fgetc(). */ -typedef int (*get_func)(void *data); - -typedef struct { - get_func get; - void *data; - char buffer[5]; - size_t buffer_pos; - int state; - int line; - int column, last_column; - size_t position; -} stream_t; - -typedef struct { - stream_t stream; - strbuffer_t saved_text; - int token; - union { - struct { - char *val; - size_t len; - } string; - json_int_t integer; - double real; - } value; -} lex_t; - -#define stream_to_lex(stream) container_of(stream, lex_t, stream) - - -/*** error reporting ***/ - -static void error_set(json_error_t *error, const lex_t *lex, - const char *msg, ...) -{ - va_list ap; - char msg_text[JSON_ERROR_TEXT_LENGTH]; - char msg_with_context[JSON_ERROR_TEXT_LENGTH]; - - int line = -1, col = -1; - size_t pos = 0; - const char *result = msg_text; - - if(!error) - return; - - va_start(ap, msg); - vsnprintf(msg_text, JSON_ERROR_TEXT_LENGTH, msg, ap); - msg_text[JSON_ERROR_TEXT_LENGTH - 1] = '\0'; - va_end(ap); - - if(lex) - { - const char *saved_text = strbuffer_value(&lex->saved_text); - - line = lex->stream.line; - col = lex->stream.column; - pos = lex->stream.position; - - if(saved_text && saved_text[0]) - { - if(lex->saved_text.length <= 20) { - snprintf(msg_with_context, JSON_ERROR_TEXT_LENGTH, - "%s near '%s'", msg_text, saved_text); - msg_with_context[JSON_ERROR_TEXT_LENGTH - 1] = '\0'; - result = msg_with_context; - } - } - else - { - if(lex->stream.state == STREAM_STATE_ERROR) { - /* No context for UTF-8 decoding errors */ - result = msg_text; - } - else { - snprintf(msg_with_context, JSON_ERROR_TEXT_LENGTH, - "%s near end of file", msg_text); - msg_with_context[JSON_ERROR_TEXT_LENGTH - 1] = '\0'; - result = msg_with_context; - } - } - } - - jsonp_error_set(error, line, col, pos, "%s", result); -} - - -/*** lexical analyzer ***/ - -static void -stream_init(stream_t *stream, get_func get, void *data) -{ - stream->get = get; - stream->data = data; - stream->buffer[0] = '\0'; - stream->buffer_pos = 0; - - stream->state = STREAM_STATE_OK; - stream->line = 1; - stream->column = 0; - stream->position = 0; -} - -static int stream_get(stream_t *stream, json_error_t *error) -{ - int c; - - if(stream->state != STREAM_STATE_OK) - return stream->state; - - if(!stream->buffer[stream->buffer_pos]) - { - c = stream->get(stream->data); - if(c == EOF) { - stream->state = STREAM_STATE_EOF; - return STREAM_STATE_EOF; - } - - stream->buffer[0] = c; - stream->buffer_pos = 0; - - if(0x80 <= c && c <= 0xFF) - { - /* multi-byte UTF-8 sequence */ - int i, count; - - count = (int)utf8_check_first(c); - if(!count) - goto out; - - assert(count >= 2); - - for(i = 1; i < count; i++) - stream->buffer[i] = stream->get(stream->data); - - if(!utf8_check_full(stream->buffer, count, NULL)) - goto out; - - stream->buffer[count] = '\0'; - } - else - stream->buffer[1] = '\0'; - } - - c = stream->buffer[stream->buffer_pos++]; - - stream->position++; - if(c == '\n') { - stream->line++; - stream->last_column = stream->column; - stream->column = 0; - } - else if(utf8_check_first(c)) { - /* track the Unicode character column, so increment only if - this is the first character of a UTF-8 sequence */ - stream->column++; - } - - return c; - -out: - stream->state = STREAM_STATE_ERROR; - error_set(error, stream_to_lex(stream), "unable to decode byte 0x%x", c); - return STREAM_STATE_ERROR; -} - -static void stream_unget(stream_t *stream, int c) -{ - if(c == STREAM_STATE_EOF || c == STREAM_STATE_ERROR) - return; - - stream->position--; - if(c == '\n') { - stream->line--; - stream->column = stream->last_column; - } - else if(utf8_check_first(c)) - stream->column--; - - assert(stream->buffer_pos > 0); - stream->buffer_pos--; - assert(stream->buffer[stream->buffer_pos] == c); -} - - -static int lex_get(lex_t *lex, json_error_t *error) -{ - return stream_get(&lex->stream, error); -} - -static void lex_save(lex_t *lex, int c) -{ - strbuffer_append_byte(&lex->saved_text, c); -} - -static int lex_get_save(lex_t *lex, json_error_t *error) -{ - int c = stream_get(&lex->stream, error); - if(c != STREAM_STATE_EOF && c != STREAM_STATE_ERROR) - lex_save(lex, c); - return c; -} - -static void lex_unget(lex_t *lex, int c) -{ - stream_unget(&lex->stream, c); -} - -static void lex_unget_unsave(lex_t *lex, int c) -{ - if(c != STREAM_STATE_EOF && c != STREAM_STATE_ERROR) { - /* Since we treat warnings as errors, when assertions are turned - * off the "d" variable would be set but never used. Which is - * treated as an error by GCC. - */ - #ifndef NDEBUG - char d; - #endif - stream_unget(&lex->stream, c); - #ifndef NDEBUG - d = - #endif - strbuffer_pop(&lex->saved_text); - assert(c == d); - } -} - -static void lex_save_cached(lex_t *lex) -{ - while(lex->stream.buffer[lex->stream.buffer_pos] != '\0') - { - lex_save(lex, lex->stream.buffer[lex->stream.buffer_pos]); - lex->stream.buffer_pos++; - lex->stream.position++; - } -} - -static void lex_free_string(lex_t *lex) -{ - jsonp_free(lex->value.string.val); - lex->value.string.val = NULL; - lex->value.string.len = 0; -} - -/* assumes that str points to 'u' plus at least 4 valid hex digits */ -static int32_t decode_unicode_escape(const char *str) -{ - int i; - int32_t value = 0; - - assert(str[0] == 'u'); - - for(i = 1; i <= 4; i++) { - char c = str[i]; - value <<= 4; - if(l_isdigit(c)) - value += c - '0'; - else if(l_islower(c)) - value += c - 'a' + 10; - else if(l_isupper(c)) - value += c - 'A' + 10; - else - return -1; - } - - return value; -} - -static void lex_scan_string(lex_t *lex, json_error_t *error) -{ - int c; - const char *p; - char *t; - int i; - - lex->value.string.val = NULL; - lex->token = TOKEN_INVALID; - - c = lex_get_save(lex, error); - - while(c != '"') { - if(c == STREAM_STATE_ERROR) - goto out; - - else if(c == STREAM_STATE_EOF) { - error_set(error, lex, "premature end of input"); - goto out; - } - - else if(0 <= c && c <= 0x1F) { - /* control character */ - lex_unget_unsave(lex, c); - if(c == '\n') - error_set(error, lex, "unexpected newline", c); - else - error_set(error, lex, "control character 0x%x", c); - goto out; - } - - else if(c == '\\') { - c = lex_get_save(lex, error); - if(c == 'u') { - c = lex_get_save(lex, error); - for(i = 0; i < 4; i++) { - if(!l_isxdigit(c)) { - error_set(error, lex, "invalid escape"); - goto out; - } - c = lex_get_save(lex, error); - } - } - else if(c == '"' || c == '\\' || c == '/' || c == 'b' || - c == 'f' || c == 'n' || c == 'r' || c == 't') - c = lex_get_save(lex, error); - else { - error_set(error, lex, "invalid escape"); - goto out; - } - } - else - c = lex_get_save(lex, error); - } - - /* the actual value is at most of the same length as the source - string, because: - - shortcut escapes (e.g. "\t") (length 2) are converted to 1 byte - - a single \uXXXX escape (length 6) is converted to at most 3 bytes - - two \uXXXX escapes (length 12) forming an UTF-16 surrogate pair - are converted to 4 bytes - */ - t = jsonp_malloc(lex->saved_text.length + 1); - if(!t) { - /* this is not very nice, since TOKEN_INVALID is returned */ - goto out; - } - lex->value.string.val = t; - - /* + 1 to skip the " */ - p = strbuffer_value(&lex->saved_text) + 1; - - while(*p != '"') { - if(*p == '\\') { - p++; - if(*p == 'u') { - size_t length; - int32_t value; - - value = decode_unicode_escape(p); - if(value < 0) { - error_set(error, lex, "invalid Unicode escape '%.6s'", p - 1); - goto out; - } - p += 5; - - if(0xD800 <= value && value <= 0xDBFF) { - /* surrogate pair */ - if(*p == '\\' && *(p + 1) == 'u') { - int32_t value2 = decode_unicode_escape(++p); - if(value2 < 0) { - error_set(error, lex, "invalid Unicode escape '%.6s'", p - 1); - goto out; - } - p += 5; - - if(0xDC00 <= value2 && value2 <= 0xDFFF) { - /* valid second surrogate */ - value = - ((value - 0xD800) << 10) + - (value2 - 0xDC00) + - 0x10000; - } - else { - /* invalid second surrogate */ - error_set(error, lex, - "invalid Unicode '\\u%04X\\u%04X'", - value, value2); - goto out; - } - } - else { - /* no second surrogate */ - error_set(error, lex, "invalid Unicode '\\u%04X'", - value); - goto out; - } - } - else if(0xDC00 <= value && value <= 0xDFFF) { - error_set(error, lex, "invalid Unicode '\\u%04X'", value); - goto out; - } - - if(utf8_encode(value, t, &length)) - assert(0); - t += length; - } - else { - switch(*p) { - case '"': case '\\': case '/': - *t = *p; break; - case 'b': *t = '\b'; break; - case 'f': *t = '\f'; break; - case 'n': *t = '\n'; break; - case 'r': *t = '\r'; break; - case 't': *t = '\t'; break; - default: assert(0); - } - t++; - p++; - } - } - else - *(t++) = *(p++); - } - *t = '\0'; - lex->value.string.len = t - lex->value.string.val; - lex->token = TOKEN_STRING; - return; - -out: - lex_free_string(lex); -} - -#ifndef JANSSON_USING_CMAKE /* disabled if using cmake */ -#if JSON_INTEGER_IS_LONG_LONG -#ifdef _MSC_VER /* Microsoft Visual Studio */ -#define json_strtoint _strtoi64 -#else -#define json_strtoint strtoll -#endif -#else -#define json_strtoint strtol -#endif -#endif - -static int lex_scan_number(lex_t *lex, int c, json_error_t *error) -{ - const char *saved_text; - char *end; - double value; - - lex->token = TOKEN_INVALID; - - if(c == '-') - c = lex_get_save(lex, error); - - if(c == '0') { - c = lex_get_save(lex, error); - if(l_isdigit(c)) { - lex_unget_unsave(lex, c); - goto out; - } - } - else if(l_isdigit(c)) { - c = lex_get_save(lex, error); - while(l_isdigit(c)) - c = lex_get_save(lex, error); - } - else { - lex_unget_unsave(lex, c); - goto out; - } - - if(c != '.' && c != 'E' && c != 'e') { - json_int_t value; - - lex_unget_unsave(lex, c); - - saved_text = strbuffer_value(&lex->saved_text); - - errno = 0; - value = json_strtoint(saved_text, &end, 10); - if(errno == ERANGE) { - if(value < 0) - error_set(error, lex, "too big negative integer"); - else - error_set(error, lex, "too big integer"); - goto out; - } - - assert(end == saved_text + lex->saved_text.length); - - lex->token = TOKEN_INTEGER; - lex->value.integer = value; - return 0; - } - - if(c == '.') { - c = lex_get(lex, error); - if(!l_isdigit(c)) { - lex_unget(lex, c); - goto out; - } - lex_save(lex, c); - - c = lex_get_save(lex, error); - while(l_isdigit(c)) - c = lex_get_save(lex, error); - } - - if(c == 'E' || c == 'e') { - c = lex_get_save(lex, error); - if(c == '+' || c == '-') - c = lex_get_save(lex, error); - - if(!l_isdigit(c)) { - lex_unget_unsave(lex, c); - goto out; - } - - c = lex_get_save(lex, error); - while(l_isdigit(c)) - c = lex_get_save(lex, error); - } - - lex_unget_unsave(lex, c); - - if(jsonp_strtod(&lex->saved_text, &value)) { - error_set(error, lex, "real number overflow"); - goto out; - } - - lex->token = TOKEN_REAL; - lex->value.real = value; - return 0; - -out: - return -1; -} - -static int lex_scan(lex_t *lex, json_error_t *error) -{ - int c; - - strbuffer_clear(&lex->saved_text); - - if(lex->token == TOKEN_STRING) - lex_free_string(lex); - - c = lex_get(lex, error); - while(c == ' ' || c == '\t' || c == '\n' || c == '\r') - c = lex_get(lex, error); - - if(c == STREAM_STATE_EOF) { - lex->token = TOKEN_EOF; - goto out; - } - - if(c == STREAM_STATE_ERROR) { - lex->token = TOKEN_INVALID; - goto out; - } - - lex_save(lex, c); - - if(c == '{' || c == '}' || c == '[' || c == ']' || c == ':' || c == ',') - lex->token = c; - - else if(c == '"') - lex_scan_string(lex, error); - - else if(l_isdigit(c) || c == '-') { - if(lex_scan_number(lex, c, error)) - goto out; - } - - else if(l_isalpha(c)) { - /* eat up the whole identifier for clearer error messages */ - const char *saved_text; - - c = lex_get_save(lex, error); - while(l_isalpha(c)) - c = lex_get_save(lex, error); - lex_unget_unsave(lex, c); - - saved_text = strbuffer_value(&lex->saved_text); - - if(strcmp(saved_text, "true") == 0) - lex->token = TOKEN_TRUE; - else if(strcmp(saved_text, "false") == 0) - lex->token = TOKEN_FALSE; - else if(strcmp(saved_text, "null") == 0) - lex->token = TOKEN_NULL; - else - lex->token = TOKEN_INVALID; - } - - else { - /* save the rest of the input UTF-8 sequence to get an error - message of valid UTF-8 */ - lex_save_cached(lex); - lex->token = TOKEN_INVALID; - } - -out: - return lex->token; -} - -static char *lex_steal_string(lex_t *lex, size_t *out_len) -{ - char *result = NULL; - if(lex->token == TOKEN_STRING) { - result = lex->value.string.val; - *out_len = lex->value.string.len; - lex->value.string.val = NULL; - lex->value.string.len = 0; - } - return result; -} - -static int lex_init(lex_t *lex, get_func get, void *data) -{ - stream_init(&lex->stream, get, data); - if(strbuffer_init(&lex->saved_text)) - return -1; - - lex->token = TOKEN_INVALID; - return 0; -} - -static void lex_close(lex_t *lex) -{ - if(lex->token == TOKEN_STRING) - lex_free_string(lex); - strbuffer_close(&lex->saved_text); -} - - -/*** parser ***/ - -static json_t *parse_value(lex_t *lex, size_t flags, json_error_t *error); - -static json_t *parse_object(lex_t *lex, size_t flags, json_error_t *error) -{ - json_t *object = json_object(); - if(!object) - return NULL; - - lex_scan(lex, error); - if(lex->token == '}') - return object; - - while(1) { - char *key; - size_t len; - json_t *value; - - if(lex->token != TOKEN_STRING) { - error_set(error, lex, "string or '}' expected"); - goto error; - } - - key = lex_steal_string(lex, &len); - if(!key) - return NULL; - if (memchr(key, '\0', len)) { - jsonp_free(key); - error_set(error, lex, "NUL byte in object key not supported"); - goto error; - } - - if(flags & JSON_REJECT_DUPLICATES) { - if(json_object_get(object, key)) { - jsonp_free(key); - error_set(error, lex, "duplicate object key"); - goto error; - } - } - - lex_scan(lex, error); - if(lex->token != ':') { - jsonp_free(key); - error_set(error, lex, "':' expected"); - goto error; - } - - lex_scan(lex, error); - value = parse_value(lex, flags, error); - if(!value) { - jsonp_free(key); - goto error; - } - - if(json_object_set_nocheck(object, key, value)) { - jsonp_free(key); - json_decref(value); - goto error; - } - - json_decref(value); - jsonp_free(key); - - lex_scan(lex, error); - if(lex->token != ',') - break; - - lex_scan(lex, error); - } - - if(lex->token != '}') { - error_set(error, lex, "'}' expected"); - goto error; - } - - return object; - -error: - json_decref(object); - return NULL; -} - -static json_t *parse_array(lex_t *lex, size_t flags, json_error_t *error) -{ - json_t *array = json_array(); - if(!array) - return NULL; - - lex_scan(lex, error); - if(lex->token == ']') - return array; - - while(lex->token) { - json_t *elem = parse_value(lex, flags, error); - if(!elem) - goto error; - - if(json_array_append(array, elem)) { - json_decref(elem); - goto error; - } - json_decref(elem); - - lex_scan(lex, error); - if(lex->token != ',') - break; - - lex_scan(lex, error); - } - - if(lex->token != ']') { - error_set(error, lex, "']' expected"); - goto error; - } - - return array; - -error: - json_decref(array); - return NULL; -} - -static json_t *parse_value(lex_t *lex, size_t flags, json_error_t *error) -{ - json_t *json; - double value; - - switch(lex->token) { - case TOKEN_STRING: { - const char *value = lex->value.string.val; - size_t len = lex->value.string.len; - - if(!(flags & JSON_ALLOW_NUL)) { - if(memchr(value, '\0', len)) { - error_set(error, lex, "\\u0000 is not allowed without JSON_ALLOW_NUL"); - return NULL; - } - } - - json = jsonp_stringn_nocheck_own(value, len); - if(json) { - lex->value.string.val = NULL; - lex->value.string.len = 0; - } - break; - } - - case TOKEN_INTEGER: { - if (flags & JSON_DECODE_INT_AS_REAL) { - if(jsonp_strtod(&lex->saved_text, &value)) { - error_set(error, lex, "real number overflow"); - return NULL; - } - json = json_real(value); - } else { - json = json_integer(lex->value.integer); - } - break; - } - - case TOKEN_REAL: { - json = json_real(lex->value.real); - break; - } - - case TOKEN_TRUE: - json = json_true(); - break; - - case TOKEN_FALSE: - json = json_false(); - break; - - case TOKEN_NULL: - json = json_null(); - break; - - case '{': - json = parse_object(lex, flags, error); - break; - - case '[': - json = parse_array(lex, flags, error); - break; - - case TOKEN_INVALID: - error_set(error, lex, "invalid token"); - return NULL; - - default: - error_set(error, lex, "unexpected token"); - return NULL; - } - - if(!json) - return NULL; - - return json; -} - -static json_t *parse_json(lex_t *lex, size_t flags, json_error_t *error) -{ - json_t *result; - - lex_scan(lex, error); - if(!(flags & JSON_DECODE_ANY)) { - if(lex->token != '[' && lex->token != '{') { - error_set(error, lex, "'[' or '{' expected"); - return NULL; - } - } - - result = parse_value(lex, flags, error); - if(!result) - return NULL; - - if(!(flags & JSON_DISABLE_EOF_CHECK)) { - lex_scan(lex, error); - if(lex->token != TOKEN_EOF) { - error_set(error, lex, "end of file expected"); - json_decref(result); - return NULL; - } - } - - if(error) { - /* Save the position even though there was no error */ - error->position = (int)lex->stream.position; - } - - return result; -} - -typedef struct -{ - const char *data; - int pos; -} string_data_t; - -static int string_get(void *data) -{ - char c; - string_data_t *stream = (string_data_t *)data; - c = stream->data[stream->pos]; - if(c == '\0') - return EOF; - else - { - stream->pos++; - return (unsigned char)c; - } -} - -json_t *json_loads(const char *string, size_t flags, json_error_t *error) -{ - lex_t lex; - json_t *result; - string_data_t stream_data; - - jsonp_error_init(error, ""); - - if (string == NULL) { - error_set(error, NULL, "wrong arguments"); - return NULL; - } - - stream_data.data = string; - stream_data.pos = 0; - - if(lex_init(&lex, string_get, (void *)&stream_data)) - return NULL; - - result = parse_json(&lex, flags, error); - - lex_close(&lex); - return result; -} - -typedef struct -{ - const char *data; - size_t len; - size_t pos; -} buffer_data_t; - -static int buffer_get(void *data) -{ - char c; - buffer_data_t *stream = data; - if(stream->pos >= stream->len) - return EOF; - - c = stream->data[stream->pos]; - stream->pos++; - return (unsigned char)c; -} - -json_t *json_loadb(const char *buffer, size_t buflen, size_t flags, json_error_t *error) -{ - lex_t lex; - json_t *result; - buffer_data_t stream_data; - - jsonp_error_init(error, ""); - - if (buffer == NULL) { - error_set(error, NULL, "wrong arguments"); - return NULL; - } - - stream_data.data = buffer; - stream_data.pos = 0; - stream_data.len = buflen; - - if(lex_init(&lex, buffer_get, (void *)&stream_data)) - return NULL; - - result = parse_json(&lex, flags, error); - - lex_close(&lex); - return result; -} - -json_t *json_loadf(FILE *input, size_t flags, json_error_t *error) -{ - lex_t lex; - const char *source; - json_t *result; - - if(input == stdin) - source = ""; - else - source = ""; - - jsonp_error_init(error, source); - - if (input == NULL) { - error_set(error, NULL, "wrong arguments"); - return NULL; - } - - if(lex_init(&lex, (get_func)fgetc, input)) - return NULL; - - result = parse_json(&lex, flags, error); - - lex_close(&lex); - return result; -} - -json_t *json_load_file(const char *path, size_t flags, json_error_t *error) -{ - json_t *result; - FILE *fp; - - jsonp_error_init(error, path); - - if (path == NULL) { - error_set(error, NULL, "wrong arguments"); - return NULL; - } - - fp = fopen(path, "rb"); - if(!fp) - { - error_set(error, NULL, "unable to open %s: %s", - path, strerror(errno)); - return NULL; - } - - result = json_loadf(fp, flags, error); - - fclose(fp); - return result; -} - -#define MAX_BUF_LEN 1024 - -typedef struct -{ - char data[MAX_BUF_LEN]; - size_t len; - size_t pos; - json_load_callback_t callback; - void *arg; -} callback_data_t; - -static int callback_get(void *data) -{ - char c; - callback_data_t *stream = data; - - if(stream->pos >= stream->len) { - stream->pos = 0; - stream->len = stream->callback(stream->data, MAX_BUF_LEN, stream->arg); - if(stream->len == 0 || stream->len == (size_t)-1) - return EOF; - } - - c = stream->data[stream->pos]; - stream->pos++; - return (unsigned char)c; -} - -json_t *json_load_callback(json_load_callback_t callback, void *arg, size_t flags, json_error_t *error) -{ - lex_t lex; - json_t *result; - - callback_data_t stream_data; - - memset(&stream_data, 0, sizeof(stream_data)); - stream_data.callback = callback; - stream_data.arg = arg; - - jsonp_error_init(error, ""); - - if (callback == NULL) { - error_set(error, NULL, "wrong arguments"); - return NULL; - } - - if(lex_init(&lex, (get_func)callback_get, &stream_data)) - return NULL; - - result = parse_json(&lex, flags, error); - - lex_close(&lex); - return result; -} diff --git a/deps/jansson/src/memory.c b/deps/jansson/src/memory.c deleted file mode 100644 index e6da96e..0000000 --- a/deps/jansson/src/memory.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * Copyright (c) 2011-2012 Basile Starynkevitch - * - * Jansson is free software; you can redistribute it and/or modify it - * under the terms of the MIT license. See LICENSE for details. - */ - -#include -#include - -#include "jansson.h" -#include "jansson_private.h" - -/* C89 allows these to be macros */ -#undef malloc -#undef free - -/* memory function pointers */ -static json_malloc_t do_malloc = malloc; -static json_free_t do_free = free; - -void *jsonp_malloc(size_t size) -{ - if(!size) - return NULL; - - return (*do_malloc)(size); -} - -void jsonp_free(void *ptr) -{ - if(!ptr) - return; - - (*do_free)(ptr); -} - -char *jsonp_strdup(const char *str) -{ - return jsonp_strndup(str, strlen(str)); -} - -char *jsonp_strndup(const char *str, size_t len) -{ - char *new_str; - - new_str = jsonp_malloc(len + 1); - if(!new_str) - return NULL; - - memcpy(new_str, str, len); - new_str[len] = '\0'; - return new_str; -} - -void json_set_alloc_funcs(json_malloc_t malloc_fn, json_free_t free_fn) -{ - do_malloc = malloc_fn; - do_free = free_fn; -} diff --git a/deps/jansson/src/pack_unpack.c b/deps/jansson/src/pack_unpack.c deleted file mode 100644 index b19097d..0000000 --- a/deps/jansson/src/pack_unpack.c +++ /dev/null @@ -1,788 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * Copyright (c) 2011-2012 Graeme Smecher - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#include -#include "jansson.h" -#include "jansson_private.h" -#include "utf.h" - -typedef struct { - int line; - int column; - size_t pos; - char token; -} token_t; - -typedef struct { - const char *start; - const char *fmt; - token_t prev_token; - token_t token; - token_t next_token; - json_error_t *error; - size_t flags; - int line; - int column; - size_t pos; -} scanner_t; - -#define token(scanner) ((scanner)->token.token) - -static const char * const type_names[] = { - "object", - "array", - "string", - "integer", - "real", - "true", - "false", - "null" -}; - -#define type_name(x) type_names[json_typeof(x)] - -static const char unpack_value_starters[] = "{[siIbfFOon"; - - -static void scanner_init(scanner_t *s, json_error_t *error, - size_t flags, const char *fmt) -{ - s->error = error; - s->flags = flags; - s->fmt = s->start = fmt; - memset(&s->prev_token, 0, sizeof(token_t)); - memset(&s->token, 0, sizeof(token_t)); - memset(&s->next_token, 0, sizeof(token_t)); - s->line = 1; - s->column = 0; - s->pos = 0; -} - -static void next_token(scanner_t *s) -{ - const char *t; - s->prev_token = s->token; - - if(s->next_token.line) { - s->token = s->next_token; - s->next_token.line = 0; - return; - } - - t = s->fmt; - s->column++; - s->pos++; - - /* skip space and ignored chars */ - while(*t == ' ' || *t == '\t' || *t == '\n' || *t == ',' || *t == ':') { - if(*t == '\n') { - s->line++; - s->column = 1; - } - else - s->column++; - - s->pos++; - t++; - } - - s->token.token = *t; - s->token.line = s->line; - s->token.column = s->column; - s->token.pos = s->pos; - - t++; - s->fmt = t; -} - -static void prev_token(scanner_t *s) -{ - s->next_token = s->token; - s->token = s->prev_token; -} - -static void set_error(scanner_t *s, const char *source, const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - - jsonp_error_vset(s->error, s->token.line, s->token.column, s->token.pos, - fmt, ap); - - jsonp_error_set_source(s->error, source); - - va_end(ap); -} - -static json_t *pack(scanner_t *s, va_list *ap); - - -/* ours will be set to 1 if jsonp_free() must be called for the result - afterwards */ -static char *read_string(scanner_t *s, va_list *ap, - const char *purpose, size_t *out_len, int *ours) -{ - char t; - strbuffer_t strbuff; - const char *str; - size_t length; - - next_token(s); - t = token(s); - prev_token(s); - - if(t != '#' && t != '%' && t != '+') { - /* Optimize the simple case */ - str = va_arg(*ap, const char *); - - if(!str) { - set_error(s, "", "NULL string argument"); - return NULL; - } - - length = strlen(str); - - if(!utf8_check_string(str, length)) { - set_error(s, "", "Invalid UTF-8 %s", purpose); - return NULL; - } - - *out_len = length; - *ours = 0; - return (char *)str; - } - - strbuffer_init(&strbuff); - - while(1) { - str = va_arg(*ap, const char *); - if(!str) { - set_error(s, "", "NULL string argument"); - strbuffer_close(&strbuff); - return NULL; - } - - next_token(s); - - if(token(s) == '#') { - length = va_arg(*ap, int); - } - else if(token(s) == '%') { - length = va_arg(*ap, size_t); - } - else { - prev_token(s); - length = strlen(str); - } - - if(strbuffer_append_bytes(&strbuff, str, length) == -1) { - set_error(s, "", "Out of memory"); - strbuffer_close(&strbuff); - return NULL; - } - - next_token(s); - if(token(s) != '+') { - prev_token(s); - break; - } - } - - if(!utf8_check_string(strbuff.value, strbuff.length)) { - set_error(s, "", "Invalid UTF-8 %s", purpose); - strbuffer_close(&strbuff); - return NULL; - } - - *out_len = strbuff.length; - *ours = 1; - return strbuffer_steal_value(&strbuff); -} - -static json_t *pack_object(scanner_t *s, va_list *ap) -{ - json_t *object = json_object(); - next_token(s); - - while(token(s) != '}') { - char *key; - size_t len; - int ours; - json_t *value; - - if(!token(s)) { - set_error(s, "", "Unexpected end of format string"); - goto error; - } - - if(token(s) != 's') { - set_error(s, "", "Expected format 's', got '%c'", token(s)); - goto error; - } - - key = read_string(s, ap, "object key", &len, &ours); - if(!key) - goto error; - - next_token(s); - - value = pack(s, ap); - if(!value) { - if(ours) - jsonp_free(key); - - goto error; - } - - if(json_object_set_new_nocheck(object, key, value)) { - if(ours) - jsonp_free(key); - - set_error(s, "", "Unable to add key \"%s\"", key); - goto error; - } - - if(ours) - jsonp_free(key); - - next_token(s); - } - - return object; - -error: - json_decref(object); - return NULL; -} - -static json_t *pack_array(scanner_t *s, va_list *ap) -{ - json_t *array = json_array(); - next_token(s); - - while(token(s) != ']') { - json_t *value; - - if(!token(s)) { - set_error(s, "", "Unexpected end of format string"); - goto error; - } - - value = pack(s, ap); - if(!value) - goto error; - - if(json_array_append_new(array, value)) { - set_error(s, "", "Unable to append to array"); - goto error; - } - - next_token(s); - } - return array; - -error: - json_decref(array); - return NULL; -} - -static json_t *pack(scanner_t *s, va_list *ap) -{ - switch(token(s)) { - case '{': - return pack_object(s, ap); - - case '[': - return pack_array(s, ap); - - case 's': /* string */ - { - char *str; - size_t len; - int ours; - - str = read_string(s, ap, "string", &len, &ours); - if(!str) - return NULL; - - if (ours) - return jsonp_stringn_nocheck_own(str, len); - else - return json_stringn_nocheck(str, len); - } - - case 'n': /* null */ - return json_null(); - - case 'b': /* boolean */ - return va_arg(*ap, int) ? json_true() : json_false(); - - case 'i': /* integer from int */ - return json_integer(va_arg(*ap, int)); - - case 'I': /* integer from json_int_t */ - return json_integer(va_arg(*ap, json_int_t)); - - case 'f': /* real */ - return json_real(va_arg(*ap, double)); - - case 'O': /* a json_t object; increments refcount */ - return json_incref(va_arg(*ap, json_t *)); - - case 'o': /* a json_t object; doesn't increment refcount */ - return va_arg(*ap, json_t *); - - default: - set_error(s, "", "Unexpected format character '%c'", - token(s)); - return NULL; - } -} - -static int unpack(scanner_t *s, json_t *root, va_list *ap); - -static int unpack_object(scanner_t *s, json_t *root, va_list *ap) -{ - int ret = -1; - int strict = 0; - - /* Use a set (emulated by a hashtable) to check that all object - keys are accessed. Checking that the correct number of keys - were accessed is not enough, as the same key can be unpacked - multiple times. - */ - hashtable_t key_set; - - if(hashtable_init(&key_set)) { - set_error(s, "", "Out of memory"); - return -1; - } - - if(root && !json_is_object(root)) { - set_error(s, "", "Expected object, got %s", - type_name(root)); - goto out; - } - next_token(s); - - while(token(s) != '}') { - const char *key; - json_t *value; - int opt = 0; - - if(strict != 0) { - set_error(s, "", "Expected '}' after '%c', got '%c'", - (strict == 1 ? '!' : '*'), token(s)); - goto out; - } - - if(!token(s)) { - set_error(s, "", "Unexpected end of format string"); - goto out; - } - - if(token(s) == '!' || token(s) == '*') { - strict = (token(s) == '!' ? 1 : -1); - next_token(s); - continue; - } - - if(token(s) != 's') { - set_error(s, "", "Expected format 's', got '%c'", token(s)); - goto out; - } - - key = va_arg(*ap, const char *); - if(!key) { - set_error(s, "", "NULL object key"); - goto out; - } - - next_token(s); - - if(token(s) == '?') { - opt = 1; - next_token(s); - } - - if(!root) { - /* skipping */ - value = NULL; - } - else { - value = json_object_get(root, key); - if(!value && !opt) { - set_error(s, "", "Object item not found: %s", key); - goto out; - } - } - - if(unpack(s, value, ap)) - goto out; - - hashtable_set(&key_set, key, 0, json_null()); - next_token(s); - } - - if(strict == 0 && (s->flags & JSON_STRICT)) - strict = 1; - - if(root && strict == 1 && key_set.size != json_object_size(root)) { - long diff = (long)json_object_size(root) - (long)key_set.size; - set_error(s, "", "%li object item(s) left unpacked", diff); - goto out; - } - - ret = 0; - -out: - hashtable_close(&key_set); - return ret; -} - -static int unpack_array(scanner_t *s, json_t *root, va_list *ap) -{ - size_t i = 0; - int strict = 0; - - if(root && !json_is_array(root)) { - set_error(s, "", "Expected array, got %s", type_name(root)); - return -1; - } - next_token(s); - - while(token(s) != ']') { - json_t *value; - - if(strict != 0) { - set_error(s, "", "Expected ']' after '%c', got '%c'", - (strict == 1 ? '!' : '*'), - token(s)); - return -1; - } - - if(!token(s)) { - set_error(s, "", "Unexpected end of format string"); - return -1; - } - - if(token(s) == '!' || token(s) == '*') { - strict = (token(s) == '!' ? 1 : -1); - next_token(s); - continue; - } - - if(!strchr(unpack_value_starters, token(s))) { - set_error(s, "", "Unexpected format character '%c'", - token(s)); - return -1; - } - - if(!root) { - /* skipping */ - value = NULL; - } - else { - value = json_array_get(root, i); - if(!value) { - set_error(s, "", "Array index %lu out of range", - (unsigned long)i); - return -1; - } - } - - if(unpack(s, value, ap)) - return -1; - - next_token(s); - i++; - } - - if(strict == 0 && (s->flags & JSON_STRICT)) - strict = 1; - - if(root && strict == 1 && i != json_array_size(root)) { - long diff = (long)json_array_size(root) - (long)i; - set_error(s, "", "%li array item(s) left unpacked", diff); - return -1; - } - - return 0; -} - -static int unpack(scanner_t *s, json_t *root, va_list *ap) -{ - switch(token(s)) - { - case '{': - return unpack_object(s, root, ap); - - case '[': - return unpack_array(s, root, ap); - - case 's': - if(root && !json_is_string(root)) { - set_error(s, "", "Expected string, got %s", - type_name(root)); - return -1; - } - - if(!(s->flags & JSON_VALIDATE_ONLY)) { - const char **str_target; - size_t *len_target = NULL; - - str_target = va_arg(*ap, const char **); - if(!str_target) { - set_error(s, "", "NULL string argument"); - return -1; - } - - next_token(s); - - if(token(s) == '%') { - len_target = va_arg(*ap, size_t *); - if(!len_target) { - set_error(s, "", "NULL string length argument"); - return -1; - } - } - else - prev_token(s); - - if(root) { - *str_target = json_string_value(root); - if(len_target) - *len_target = json_string_length(root); - } - } - return 0; - - case 'i': - if(root && !json_is_integer(root)) { - set_error(s, "", "Expected integer, got %s", - type_name(root)); - return -1; - } - - if(!(s->flags & JSON_VALIDATE_ONLY)) { - int *target = va_arg(*ap, int*); - if(root) - *target = (int)json_integer_value(root); - } - - return 0; - - case 'I': - if(root && !json_is_integer(root)) { - set_error(s, "", "Expected integer, got %s", - type_name(root)); - return -1; - } - - if(!(s->flags & JSON_VALIDATE_ONLY)) { - json_int_t *target = va_arg(*ap, json_int_t*); - if(root) - *target = json_integer_value(root); - } - - return 0; - - case 'b': - if(root && !json_is_boolean(root)) { - set_error(s, "", "Expected true or false, got %s", - type_name(root)); - return -1; - } - - if(!(s->flags & JSON_VALIDATE_ONLY)) { - int *target = va_arg(*ap, int*); - if(root) - *target = json_is_true(root); - } - - return 0; - - case 'f': - if(root && !json_is_real(root)) { - set_error(s, "", "Expected real, got %s", - type_name(root)); - return -1; - } - - if(!(s->flags & JSON_VALIDATE_ONLY)) { - double *target = va_arg(*ap, double*); - if(root) - *target = json_real_value(root); - } - - return 0; - - case 'F': - if(root && !json_is_number(root)) { - set_error(s, "", "Expected real or integer, got %s", - type_name(root)); - return -1; - } - - if(!(s->flags & JSON_VALIDATE_ONLY)) { - double *target = va_arg(*ap, double*); - if(root) - *target = json_number_value(root); - } - - return 0; - - case 'O': - if(root && !(s->flags & JSON_VALIDATE_ONLY)) - json_incref(root); - /* Fall through */ - - case 'o': - if(!(s->flags & JSON_VALIDATE_ONLY)) { - json_t **target = va_arg(*ap, json_t**); - if(root) - *target = root; - } - - return 0; - - case 'n': - /* Never assign, just validate */ - if(root && !json_is_null(root)) { - set_error(s, "", "Expected null, got %s", - type_name(root)); - return -1; - } - return 0; - - default: - set_error(s, "", "Unexpected format character '%c'", - token(s)); - return -1; - } -} - -json_t *json_vpack_ex(json_error_t *error, size_t flags, - const char *fmt, va_list ap) -{ - scanner_t s; - va_list ap_copy; - json_t *value; - - if(!fmt || !*fmt) { - jsonp_error_init(error, ""); - jsonp_error_set(error, -1, -1, 0, "NULL or empty format string"); - return NULL; - } - jsonp_error_init(error, NULL); - - scanner_init(&s, error, flags, fmt); - next_token(&s); - - va_copy(ap_copy, ap); - value = pack(&s, &ap_copy); - va_end(ap_copy); - - if(!value) - return NULL; - - next_token(&s); - if(token(&s)) { - json_decref(value); - set_error(&s, "", "Garbage after format string"); - return NULL; - } - - return value; -} - -json_t *json_pack_ex(json_error_t *error, size_t flags, const char *fmt, ...) -{ - json_t *value; - va_list ap; - - va_start(ap, fmt); - value = json_vpack_ex(error, flags, fmt, ap); - va_end(ap); - - return value; -} - -json_t *json_pack(const char *fmt, ...) -{ - json_t *value; - va_list ap; - - va_start(ap, fmt); - value = json_vpack_ex(NULL, 0, fmt, ap); - va_end(ap); - - return value; -} - -int json_vunpack_ex(json_t *root, json_error_t *error, size_t flags, - const char *fmt, va_list ap) -{ - scanner_t s; - va_list ap_copy; - - if(!root) { - jsonp_error_init(error, ""); - jsonp_error_set(error, -1, -1, 0, "NULL root value"); - return -1; - } - - if(!fmt || !*fmt) { - jsonp_error_init(error, ""); - jsonp_error_set(error, -1, -1, 0, "NULL or empty format string"); - return -1; - } - jsonp_error_init(error, NULL); - - scanner_init(&s, error, flags, fmt); - next_token(&s); - - va_copy(ap_copy, ap); - if(unpack(&s, root, &ap_copy)) { - va_end(ap_copy); - return -1; - } - va_end(ap_copy); - - next_token(&s); - if(token(&s)) { - set_error(&s, "", "Garbage after format string"); - return -1; - } - - return 0; -} - -int json_unpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt, ...) -{ - int ret; - va_list ap; - - va_start(ap, fmt); - ret = json_vunpack_ex(root, error, flags, fmt, ap); - va_end(ap); - - return ret; -} - -int json_unpack(json_t *root, const char *fmt, ...) -{ - int ret; - va_list ap; - - va_start(ap, fmt); - ret = json_vunpack_ex(root, NULL, 0, fmt, ap); - va_end(ap); - - return ret; -} diff --git a/deps/jansson/src/strbuffer.c b/deps/jansson/src/strbuffer.c deleted file mode 100644 index 2d6ff31..0000000 --- a/deps/jansson/src/strbuffer.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include -#include -#include "jansson_private.h" -#include "strbuffer.h" - -#define STRBUFFER_MIN_SIZE 16 -#define STRBUFFER_FACTOR 2 -#define STRBUFFER_SIZE_MAX ((size_t)-1) - -int strbuffer_init(strbuffer_t *strbuff) -{ - strbuff->size = STRBUFFER_MIN_SIZE; - strbuff->length = 0; - - strbuff->value = jsonp_malloc(strbuff->size); - if(!strbuff->value) - return -1; - - /* initialize to empty */ - strbuff->value[0] = '\0'; - return 0; -} - -void strbuffer_close(strbuffer_t *strbuff) -{ - if(strbuff->value) - jsonp_free(strbuff->value); - - strbuff->size = 0; - strbuff->length = 0; - strbuff->value = NULL; -} - -void strbuffer_clear(strbuffer_t *strbuff) -{ - strbuff->length = 0; - strbuff->value[0] = '\0'; -} - -const char *strbuffer_value(const strbuffer_t *strbuff) -{ - return strbuff->value; -} - -char *strbuffer_steal_value(strbuffer_t *strbuff) -{ - char *result = strbuff->value; - strbuff->value = NULL; - return result; -} - -int strbuffer_append(strbuffer_t *strbuff, const char *string) -{ - return strbuffer_append_bytes(strbuff, string, strlen(string)); -} - -int strbuffer_append_byte(strbuffer_t *strbuff, char byte) -{ - return strbuffer_append_bytes(strbuff, &byte, 1); -} - -int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size) -{ - if(size >= strbuff->size - strbuff->length) - { - size_t new_size; - char *new_value; - - /* avoid integer overflow */ - if (strbuff->size > STRBUFFER_SIZE_MAX / STRBUFFER_FACTOR - || size > STRBUFFER_SIZE_MAX - 1 - || strbuff->length > STRBUFFER_SIZE_MAX - 1 - size) - return -1; - - new_size = max(strbuff->size * STRBUFFER_FACTOR, - strbuff->length + size + 1); - - new_value = jsonp_malloc(new_size); - if(!new_value) - return -1; - - memcpy(new_value, strbuff->value, strbuff->length); - - jsonp_free(strbuff->value); - strbuff->value = new_value; - strbuff->size = new_size; - } - - memcpy(strbuff->value + strbuff->length, data, size); - strbuff->length += size; - strbuff->value[strbuff->length] = '\0'; - - return 0; -} - -char strbuffer_pop(strbuffer_t *strbuff) -{ - if(strbuff->length > 0) { - char c = strbuff->value[--strbuff->length]; - strbuff->value[strbuff->length] = '\0'; - return c; - } - else - return '\0'; -} diff --git a/deps/jansson/src/strbuffer.h b/deps/jansson/src/strbuffer.h deleted file mode 100644 index 06fd065..0000000 --- a/deps/jansson/src/strbuffer.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#ifndef STRBUFFER_H -#define STRBUFFER_H - -typedef struct { - char *value; - size_t length; /* bytes used */ - size_t size; /* bytes allocated */ -} strbuffer_t; - -int strbuffer_init(strbuffer_t *strbuff); -void strbuffer_close(strbuffer_t *strbuff); - -void strbuffer_clear(strbuffer_t *strbuff); - -const char *strbuffer_value(const strbuffer_t *strbuff); - -/* Steal the value and close the strbuffer */ -char *strbuffer_steal_value(strbuffer_t *strbuff); - -int strbuffer_append(strbuffer_t *strbuff, const char *string); -int strbuffer_append_byte(strbuffer_t *strbuff, char byte); -int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size); - -char strbuffer_pop(strbuffer_t *strbuff); - -#endif diff --git a/deps/jansson/src/strconv.c b/deps/jansson/src/strconv.c deleted file mode 100644 index 3e2cb7c..0000000 --- a/deps/jansson/src/strconv.c +++ /dev/null @@ -1,134 +0,0 @@ -#include -#include -#include -#include -#include "jansson_private.h" -#include "strbuffer.h" - -/* need config.h to get the correct snprintf */ -#ifdef HAVE_CONFIG_H -#include -#endif - -#if JSON_HAVE_LOCALECONV -#include - -/* - - This code assumes that the decimal separator is exactly one - character. - - - If setlocale() is called by another thread between the call to - localeconv() and the call to sprintf() or strtod(), the result may - be wrong. setlocale() is not thread-safe and should not be used - this way. Multi-threaded programs should use uselocale() instead. -*/ - -static void to_locale(strbuffer_t *strbuffer) -{ - const char *point; - char *pos; - - point = localeconv()->decimal_point; - if(*point == '.') { - /* No conversion needed */ - return; - } - - pos = strchr(strbuffer->value, '.'); - if(pos) - *pos = *point; -} - -static void from_locale(char *buffer) -{ - const char *point; - char *pos; - - point = localeconv()->decimal_point; - if(*point == '.') { - /* No conversion needed */ - return; - } - - pos = strchr(buffer, *point); - if(pos) - *pos = '.'; -} -#endif - -int jsonp_strtod(strbuffer_t *strbuffer, double *out) -{ - double value; - char *end; - -#if JSON_HAVE_LOCALECONV - to_locale(strbuffer); -#endif - - errno = 0; - value = strtod(strbuffer->value, &end); - assert(end == strbuffer->value + strbuffer->length); - - if(errno == ERANGE && value != 0) { - /* Overflow */ - return -1; - } - - *out = value; - return 0; -} - -int jsonp_dtostr(char *buffer, size_t size, double value) -{ - int ret; - char *start, *end; - size_t length; - - ret = snprintf(buffer, size, "%.17g", value); - if(ret < 0) - return -1; - - length = (size_t)ret; - if(length >= size) - return -1; - -#if JSON_HAVE_LOCALECONV - from_locale(buffer); -#endif - - /* Make sure there's a dot or 'e' in the output. Otherwise - a real is converted to an integer when decoding */ - if(strchr(buffer, '.') == NULL && - strchr(buffer, 'e') == NULL) - { - if(length + 3 >= size) { - /* No space to append ".0" */ - return -1; - } - buffer[length] = '.'; - buffer[length + 1] = '0'; - buffer[length + 2] = '\0'; - length += 2; - } - - /* Remove leading '+' from positive exponent. Also remove leading - zeros from exponents (added by some printf() implementations) */ - start = strchr(buffer, 'e'); - if(start) { - start++; - end = start + 1; - - if(*start == '-') - start++; - - while(*end == '0') - end++; - - if(end != start) { - memmove(start, end, length - (size_t)(end - buffer)); - length -= (size_t)(end - start); - } - } - - return (int)length; -} diff --git a/deps/jansson/src/utf.c b/deps/jansson/src/utf.c deleted file mode 100644 index cbeeb54..0000000 --- a/deps/jansson/src/utf.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#include -#include "utf.h" - -int utf8_encode(int32_t codepoint, char *buffer, size_t *size) -{ - if(codepoint < 0) - return -1; - else if(codepoint < 0x80) - { - buffer[0] = (char)codepoint; - *size = 1; - } - else if(codepoint < 0x800) - { - buffer[0] = 0xC0 + ((codepoint & 0x7C0) >> 6); - buffer[1] = 0x80 + ((codepoint & 0x03F)); - *size = 2; - } - else if(codepoint < 0x10000) - { - buffer[0] = 0xE0 + ((codepoint & 0xF000) >> 12); - buffer[1] = 0x80 + ((codepoint & 0x0FC0) >> 6); - buffer[2] = 0x80 + ((codepoint & 0x003F)); - *size = 3; - } - else if(codepoint <= 0x10FFFF) - { - buffer[0] = 0xF0 + ((codepoint & 0x1C0000) >> 18); - buffer[1] = 0x80 + ((codepoint & 0x03F000) >> 12); - buffer[2] = 0x80 + ((codepoint & 0x000FC0) >> 6); - buffer[3] = 0x80 + ((codepoint & 0x00003F)); - *size = 4; - } - else - return -1; - - return 0; -} - -size_t utf8_check_first(char byte) -{ - unsigned char u = (unsigned char)byte; - - if(u < 0x80) - return 1; - - if(0x80 <= u && u <= 0xBF) { - /* second, third or fourth byte of a multi-byte - sequence, i.e. a "continuation byte" */ - return 0; - } - else if(u == 0xC0 || u == 0xC1) { - /* overlong encoding of an ASCII byte */ - return 0; - } - else if(0xC2 <= u && u <= 0xDF) { - /* 2-byte sequence */ - return 2; - } - - else if(0xE0 <= u && u <= 0xEF) { - /* 3-byte sequence */ - return 3; - } - else if(0xF0 <= u && u <= 0xF4) { - /* 4-byte sequence */ - return 4; - } - else { /* u >= 0xF5 */ - /* Restricted (start of 4-, 5- or 6-byte sequence) or invalid - UTF-8 */ - return 0; - } -} - -size_t utf8_check_full(const char *buffer, size_t size, int32_t *codepoint) -{ - size_t i; - int32_t value = 0; - unsigned char u = (unsigned char)buffer[0]; - - if(size == 2) - { - value = u & 0x1F; - } - else if(size == 3) - { - value = u & 0xF; - } - else if(size == 4) - { - value = u & 0x7; - } - else - return 0; - - for(i = 1; i < size; i++) - { - u = (unsigned char)buffer[i]; - - if(u < 0x80 || u > 0xBF) { - /* not a continuation byte */ - return 0; - } - - value = (value << 6) + (u & 0x3F); - } - - if(value > 0x10FFFF) { - /* not in Unicode range */ - return 0; - } - - else if(0xD800 <= value && value <= 0xDFFF) { - /* invalid code point (UTF-16 surrogate halves) */ - return 0; - } - - else if((size == 2 && value < 0x80) || - (size == 3 && value < 0x800) || - (size == 4 && value < 0x10000)) { - /* overlong encoding */ - return 0; - } - - if(codepoint) - *codepoint = value; - - return 1; -} - -const char *utf8_iterate(const char *buffer, size_t bufsize, int32_t *codepoint) -{ - size_t count; - int32_t value; - - if(!bufsize) - return buffer; - - count = utf8_check_first(buffer[0]); - if(count <= 0) - return NULL; - - if(count == 1) - value = (unsigned char)buffer[0]; - else - { - if(count > bufsize || !utf8_check_full(buffer, count, &value)) - return NULL; - } - - if(codepoint) - *codepoint = value; - - return buffer + count; -} - -int utf8_check_string(const char *string, size_t length) -{ - size_t i; - - for(i = 0; i < length; i++) - { - size_t count = utf8_check_first(string[i]); - if(count == 0) - return 0; - else if(count > 1) - { - if(count > length - i) - return 0; - - if(!utf8_check_full(&string[i], count, NULL)) - return 0; - - i += count - 1; - } - } - - return 1; -} diff --git a/deps/jansson/src/utf.h b/deps/jansson/src/utf.h deleted file mode 100644 index 81f85ab..0000000 --- a/deps/jansson/src/utf.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#ifndef UTF_H -#define UTF_H - -#ifdef HAVE_CONFIG_H -#include - -#ifdef HAVE_INTTYPES_H -/* inttypes.h includes stdint.h in a standard environment, so there's -no need to include stdint.h separately. If inttypes.h doesn't define -int32_t, it's defined in config.h. */ -#include -#endif /* HAVE_INTTYPES_H */ - -#else /* !HAVE_CONFIG_H */ -#ifdef _WIN32 -typedef int int32_t; -#else /* !_WIN32 */ -/* Assume a standard environment */ -#include -#endif /* _WIN32 */ - -#endif /* HAVE_CONFIG_H */ - -int utf8_encode(int32_t codepoint, char *buffer, size_t *size); - -size_t utf8_check_first(char byte); -size_t utf8_check_full(const char *buffer, size_t size, int32_t *codepoint); -const char *utf8_iterate(const char *buffer, size_t size, int32_t *codepoint); - -int utf8_check_string(const char *string, size_t length); - -#endif diff --git a/deps/jansson/src/value.c b/deps/jansson/src/value.c deleted file mode 100644 index 336873b..0000000 --- a/deps/jansson/src/value.c +++ /dev/null @@ -1,1023 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include -#include -#include -#include - -#include "jansson.h" -#include "hashtable.h" -#include "jansson_private.h" -#include "utf.h" - -/* Work around nonstandard isnan() and isinf() implementations */ -#ifndef isnan -static JSON_INLINE int isnan(double x) { return x != x; } -#endif -#ifndef isinf -static JSON_INLINE int isinf(double x) { return !isnan(x) && isnan(x - x); } -#endif - -static JSON_INLINE void json_init(json_t *json, json_type type) -{ - json->type = type; - json->refcount = 1; -} - - -/*** object ***/ - -json_t *json_object(void) -{ - json_object_t *object = jsonp_malloc(sizeof(json_object_t)); - if(!object) - return NULL; - json_init(&object->json, JSON_OBJECT); - - if(hashtable_init(&object->hashtable)) - { - jsonp_free(object); - return NULL; - } - - object->serial = 0; - object->visited = 0; - - return &object->json; -} - -static void json_delete_object(json_object_t *object) -{ - hashtable_close(&object->hashtable); - jsonp_free(object); -} - -size_t json_object_size(const json_t *json) -{ - json_object_t *object; - - if(!json_is_object(json)) - return 0; - - object = json_to_object(json); - return object->hashtable.size; -} - -json_t *json_object_get(const json_t *json, const char *key) -{ - json_object_t *object; - - if(!key || !json_is_object(json)) - return NULL; - - object = json_to_object(json); - return hashtable_get(&object->hashtable, key); -} - -int json_object_set_new_nocheck(json_t *json, const char *key, json_t *value) -{ - json_object_t *object; - - if(!value) - return -1; - - if(!key || !json_is_object(json) || json == value) - { - json_decref(value); - return -1; - } - object = json_to_object(json); - - if(hashtable_set(&object->hashtable, key, object->serial++, value)) - { - json_decref(value); - return -1; - } - - return 0; -} - -int json_object_set_new(json_t *json, const char *key, json_t *value) -{ - if(!key || !utf8_check_string(key, strlen(key))) - { - json_decref(value); - return -1; - } - - return json_object_set_new_nocheck(json, key, value); -} - -int json_object_del(json_t *json, const char *key) -{ - json_object_t *object; - - if(!key || !json_is_object(json)) - return -1; - - object = json_to_object(json); - return hashtable_del(&object->hashtable, key); -} - -int json_object_clear(json_t *json) -{ - json_object_t *object; - - if(!json_is_object(json)) - return -1; - - object = json_to_object(json); - - hashtable_clear(&object->hashtable); - object->serial = 0; - - return 0; -} - -int json_object_update(json_t *object, json_t *other) -{ - const char *key; - json_t *value; - - if(!json_is_object(object) || !json_is_object(other)) - return -1; - - json_object_foreach(other, key, value) { - if(json_object_set_nocheck(object, key, value)) - return -1; - } - - return 0; -} - -int json_object_update_existing(json_t *object, json_t *other) -{ - const char *key; - json_t *value; - - if(!json_is_object(object) || !json_is_object(other)) - return -1; - - json_object_foreach(other, key, value) { - if(json_object_get(object, key)) - json_object_set_nocheck(object, key, value); - } - - return 0; -} - -int json_object_update_missing(json_t *object, json_t *other) -{ - const char *key; - json_t *value; - - if(!json_is_object(object) || !json_is_object(other)) - return -1; - - json_object_foreach(other, key, value) { - if(!json_object_get(object, key)) - json_object_set_nocheck(object, key, value); - } - - return 0; -} - -void *json_object_iter(json_t *json) -{ - json_object_t *object; - - if(!json_is_object(json)) - return NULL; - - object = json_to_object(json); - return hashtable_iter(&object->hashtable); -} - -void *json_object_iter_at(json_t *json, const char *key) -{ - json_object_t *object; - - if(!key || !json_is_object(json)) - return NULL; - - object = json_to_object(json); - return hashtable_iter_at(&object->hashtable, key); -} - -void *json_object_iter_next(json_t *json, void *iter) -{ - json_object_t *object; - - if(!json_is_object(json) || iter == NULL) - return NULL; - - object = json_to_object(json); - return hashtable_iter_next(&object->hashtable, iter); -} - -const char *json_object_iter_key(void *iter) -{ - if(!iter) - return NULL; - - return hashtable_iter_key(iter); -} - -json_t *json_object_iter_value(void *iter) -{ - if(!iter) - return NULL; - - return (json_t *)hashtable_iter_value(iter); -} - -int json_object_iter_set_new(json_t *json, void *iter, json_t *value) -{ - if(!json_is_object(json) || !iter || !value) - return -1; - - hashtable_iter_set(iter, value); - return 0; -} - -void *json_object_key_to_iter(const char *key) -{ - if(!key) - return NULL; - - return hashtable_key_to_iter(key); -} - -static int json_object_equal(json_t *object1, json_t *object2) -{ - const char *key; - json_t *value1, *value2; - - if(json_object_size(object1) != json_object_size(object2)) - return 0; - - json_object_foreach(object1, key, value1) { - value2 = json_object_get(object2, key); - - if(!json_equal(value1, value2)) - return 0; - } - - return 1; -} - -static json_t *json_object_copy(json_t *object) -{ - json_t *result; - - const char *key; - json_t *value; - - result = json_object(); - if(!result) - return NULL; - - json_object_foreach(object, key, value) - json_object_set_nocheck(result, key, value); - - return result; -} - -static json_t *json_object_deep_copy(const json_t *object) -{ - json_t *result; - void *iter; - - result = json_object(); - if(!result) - return NULL; - - /* Cannot use json_object_foreach because object has to be cast - non-const */ - iter = json_object_iter((json_t *)object); - while(iter) { - const char *key; - const json_t *value; - key = json_object_iter_key(iter); - value = json_object_iter_value(iter); - - json_object_set_new_nocheck(result, key, json_deep_copy(value)); - iter = json_object_iter_next((json_t *)object, iter); - } - - return result; -} - - -/*** array ***/ - -json_t *json_array(void) -{ - json_array_t *array = jsonp_malloc(sizeof(json_array_t)); - if(!array) - return NULL; - json_init(&array->json, JSON_ARRAY); - - array->entries = 0; - array->size = 8; - - array->table = jsonp_malloc(array->size * sizeof(json_t *)); - if(!array->table) { - jsonp_free(array); - return NULL; - } - - array->visited = 0; - - return &array->json; -} - -static void json_delete_array(json_array_t *array) -{ - size_t i; - - for(i = 0; i < array->entries; i++) - json_decref(array->table[i]); - - jsonp_free(array->table); - jsonp_free(array); -} - -size_t json_array_size(const json_t *json) -{ - if(!json_is_array(json)) - return 0; - - return json_to_array(json)->entries; -} - -json_t *json_array_get(const json_t *json, size_t index) -{ - json_array_t *array; - if(!json_is_array(json)) - return NULL; - array = json_to_array(json); - - if(index >= array->entries) - return NULL; - - return array->table[index]; -} - -int json_array_set_new(json_t *json, size_t index, json_t *value) -{ - json_array_t *array; - - if(!value) - return -1; - - if(!json_is_array(json) || json == value) - { - json_decref(value); - return -1; - } - array = json_to_array(json); - - if(index >= array->entries) - { - json_decref(value); - return -1; - } - - json_decref(array->table[index]); - array->table[index] = value; - - return 0; -} - -static void array_move(json_array_t *array, size_t dest, - size_t src, size_t count) -{ - memmove(&array->table[dest], &array->table[src], count * sizeof(json_t *)); -} - -static void array_copy(json_t **dest, size_t dpos, - json_t **src, size_t spos, - size_t count) -{ - memcpy(&dest[dpos], &src[spos], count * sizeof(json_t *)); -} - -static json_t **json_array_grow(json_array_t *array, - size_t amount, - int copy) -{ - size_t new_size; - json_t **old_table, **new_table; - - if(array->entries + amount <= array->size) - return array->table; - - old_table = array->table; - - new_size = max(array->size + amount, array->size * 2); - new_table = jsonp_malloc(new_size * sizeof(json_t *)); - if(!new_table) - return NULL; - - array->size = new_size; - array->table = new_table; - - if(copy) { - array_copy(array->table, 0, old_table, 0, array->entries); - jsonp_free(old_table); - return array->table; - } - - return old_table; -} - -int json_array_append_new(json_t *json, json_t *value) -{ - json_array_t *array; - - if(!value) - return -1; - - if(!json_is_array(json) || json == value) - { - json_decref(value); - return -1; - } - array = json_to_array(json); - - if(!json_array_grow(array, 1, 1)) { - json_decref(value); - return -1; - } - - array->table[array->entries] = value; - array->entries++; - - return 0; -} - -int json_array_insert_new(json_t *json, size_t index, json_t *value) -{ - json_array_t *array; - json_t **old_table; - - if(!value) - return -1; - - if(!json_is_array(json) || json == value) { - json_decref(value); - return -1; - } - array = json_to_array(json); - - if(index > array->entries) { - json_decref(value); - return -1; - } - - old_table = json_array_grow(array, 1, 0); - if(!old_table) { - json_decref(value); - return -1; - } - - if(old_table != array->table) { - array_copy(array->table, 0, old_table, 0, index); - array_copy(array->table, index + 1, old_table, index, - array->entries - index); - jsonp_free(old_table); - } - else - array_move(array, index + 1, index, array->entries - index); - - array->table[index] = value; - array->entries++; - - return 0; -} - -int json_array_remove(json_t *json, size_t index) -{ - json_array_t *array; - - if(!json_is_array(json)) - return -1; - array = json_to_array(json); - - if(index >= array->entries) - return -1; - - json_decref(array->table[index]); - - /* If we're removing the last element, nothing has to be moved */ - if(index < array->entries - 1) - array_move(array, index, index + 1, array->entries - index - 1); - - array->entries--; - - return 0; -} - -int json_array_clear(json_t *json) -{ - json_array_t *array; - size_t i; - - if(!json_is_array(json)) - return -1; - array = json_to_array(json); - - for(i = 0; i < array->entries; i++) - json_decref(array->table[i]); - - array->entries = 0; - return 0; -} - -int json_array_extend(json_t *json, json_t *other_json) -{ - json_array_t *array, *other; - size_t i; - - if(!json_is_array(json) || !json_is_array(other_json)) - return -1; - array = json_to_array(json); - other = json_to_array(other_json); - - if(!json_array_grow(array, other->entries, 1)) - return -1; - - for(i = 0; i < other->entries; i++) - json_incref(other->table[i]); - - array_copy(array->table, array->entries, other->table, 0, other->entries); - - array->entries += other->entries; - return 0; -} - -static int json_array_equal(json_t *array1, json_t *array2) -{ - size_t i, size; - - size = json_array_size(array1); - if(size != json_array_size(array2)) - return 0; - - for(i = 0; i < size; i++) - { - json_t *value1, *value2; - - value1 = json_array_get(array1, i); - value2 = json_array_get(array2, i); - - if(!json_equal(value1, value2)) - return 0; - } - - return 1; -} - -static json_t *json_array_copy(json_t *array) -{ - json_t *result; - size_t i; - - result = json_array(); - if(!result) - return NULL; - - for(i = 0; i < json_array_size(array); i++) - json_array_append(result, json_array_get(array, i)); - - return result; -} - -static json_t *json_array_deep_copy(const json_t *array) -{ - json_t *result; - size_t i; - - result = json_array(); - if(!result) - return NULL; - - for(i = 0; i < json_array_size(array); i++) - json_array_append_new(result, json_deep_copy(json_array_get(array, i))); - - return result; -} - -/*** string ***/ - -static json_t *string_create(const char *value, size_t len, int own) -{ - char *v; - json_string_t *string; - - if(!value) - return NULL; - - if(own) - v = (char *)value; - else { - v = jsonp_strndup(value, len); - if(!v) - return NULL; - } - - string = jsonp_malloc(sizeof(json_string_t)); - if(!string) { - if(!own) - jsonp_free(v); - return NULL; - } - json_init(&string->json, JSON_STRING); - string->value = v; - string->length = len; - - return &string->json; -} - -json_t *json_string_nocheck(const char *value) -{ - if(!value) - return NULL; - - return string_create(value, strlen(value), 0); -} - -json_t *json_stringn_nocheck(const char *value, size_t len) -{ - return string_create(value, len, 0); -} - -/* this is private; "steal" is not a public API concept */ -json_t *jsonp_stringn_nocheck_own(const char *value, size_t len) -{ - return string_create(value, len, 1); -} - -json_t *json_string(const char *value) -{ - if(!value) - return NULL; - - return json_stringn(value, strlen(value)); -} - -json_t *json_stringn(const char *value, size_t len) -{ - if(!value || !utf8_check_string(value, len)) - return NULL; - - return json_stringn_nocheck(value, len); -} - -const char *json_string_value(const json_t *json) -{ - if(!json_is_string(json)) - return NULL; - - return json_to_string(json)->value; -} - -size_t json_string_length(const json_t *json) -{ - if(!json_is_string(json)) - return 0; - - return json_to_string(json)->length; -} - -int json_string_set_nocheck(json_t *json, const char *value) -{ - if(!value) - return -1; - - return json_string_setn_nocheck(json, value, strlen(value)); -} - -int json_string_setn_nocheck(json_t *json, const char *value, size_t len) -{ - char *dup; - json_string_t *string; - - if(!json_is_string(json) || !value) - return -1; - - dup = jsonp_strndup(value, len); - if(!dup) - return -1; - - string = json_to_string(json); - jsonp_free(string->value); - string->value = dup; - string->length = len; - - return 0; -} - -int json_string_set(json_t *json, const char *value) -{ - if(!value) - return -1; - - return json_string_setn(json, value, strlen(value)); -} - -int json_string_setn(json_t *json, const char *value, size_t len) -{ - if(!value || !utf8_check_string(value, len)) - return -1; - - return json_string_setn_nocheck(json, value, len); -} - -static void json_delete_string(json_string_t *string) -{ - jsonp_free(string->value); - jsonp_free(string); -} - -static int json_string_equal(json_t *string1, json_t *string2) -{ - json_string_t *s1, *s2; - - if(!json_is_string(string1) || !json_is_string(string2)) - return 0; - - s1 = json_to_string(string1); - s2 = json_to_string(string2); - return s1->length == s2->length && !memcmp(s1->value, s2->value, s1->length); -} - -static json_t *json_string_copy(const json_t *string) -{ - json_string_t *s; - - if(!json_is_string(string)) - return NULL; - - s = json_to_string(string); - return json_stringn_nocheck(s->value, s->length); -} - - -/*** integer ***/ - -json_t *json_integer(json_int_t value) -{ - json_integer_t *integer = jsonp_malloc(sizeof(json_integer_t)); - if(!integer) - return NULL; - json_init(&integer->json, JSON_INTEGER); - - integer->value = value; - return &integer->json; -} - -json_int_t json_integer_value(const json_t *json) -{ - if(!json_is_integer(json)) - return 0; - - return json_to_integer(json)->value; -} - -int json_integer_set(json_t *json, json_int_t value) -{ - if(!json_is_integer(json)) - return -1; - - json_to_integer(json)->value = value; - - return 0; -} - -static void json_delete_integer(json_integer_t *integer) -{ - jsonp_free(integer); -} - -static int json_integer_equal(json_t *integer1, json_t *integer2) -{ - return json_integer_value(integer1) == json_integer_value(integer2); -} - -static json_t *json_integer_copy(const json_t *integer) -{ - return json_integer(json_integer_value(integer)); -} - - -/*** real ***/ - -json_t *json_real(double value) -{ - json_real_t *real; - - if(isnan(value) || isinf(value)) - return NULL; - - real = jsonp_malloc(sizeof(json_real_t)); - if(!real) - return NULL; - json_init(&real->json, JSON_REAL); - - real->value = value; - return &real->json; -} - -double json_real_value(const json_t *json) -{ - if(!json_is_real(json)) - return 0; - - return json_to_real(json)->value; -} - -int json_real_set(json_t *json, double value) -{ - if(!json_is_real(json) || isnan(value) || isinf(value)) - return -1; - - json_to_real(json)->value = value; - - return 0; -} - -static void json_delete_real(json_real_t *real) -{ - jsonp_free(real); -} - -static int json_real_equal(json_t *real1, json_t *real2) -{ - return json_real_value(real1) == json_real_value(real2); -} - -static json_t *json_real_copy(const json_t *real) -{ - return json_real(json_real_value(real)); -} - - -/*** number ***/ - -double json_number_value(const json_t *json) -{ - if(json_is_integer(json)) - return (double)json_integer_value(json); - else if(json_is_real(json)) - return json_real_value(json); - else - return 0.0; -} - - -/*** simple values ***/ - -json_t *json_true(void) -{ - static json_t the_true = {JSON_TRUE, (size_t)-1}; - return &the_true; -} - - -json_t *json_false(void) -{ - static json_t the_false = {JSON_FALSE, (size_t)-1}; - return &the_false; -} - - -json_t *json_null(void) -{ - static json_t the_null = {JSON_NULL, (size_t)-1}; - return &the_null; -} - - -/*** deletion ***/ - -void json_delete(json_t *json) -{ - if(json_is_object(json)) - json_delete_object(json_to_object(json)); - - else if(json_is_array(json)) - json_delete_array(json_to_array(json)); - - else if(json_is_string(json)) - json_delete_string(json_to_string(json)); - - else if(json_is_integer(json)) - json_delete_integer(json_to_integer(json)); - - else if(json_is_real(json)) - json_delete_real(json_to_real(json)); - - /* json_delete is not called for true, false or null */ -} - - -/*** equality ***/ - -int json_equal(json_t *json1, json_t *json2) -{ - if(!json1 || !json2) - return 0; - - if(json_typeof(json1) != json_typeof(json2)) - return 0; - - /* this covers true, false and null as they are singletons */ - if(json1 == json2) - return 1; - - if(json_is_object(json1)) - return json_object_equal(json1, json2); - - if(json_is_array(json1)) - return json_array_equal(json1, json2); - - if(json_is_string(json1)) - return json_string_equal(json1, json2); - - if(json_is_integer(json1)) - return json_integer_equal(json1, json2); - - if(json_is_real(json1)) - return json_real_equal(json1, json2); - - return 0; -} - - -/*** copying ***/ - -json_t *json_copy(json_t *json) -{ - if(!json) - return NULL; - - if(json_is_object(json)) - return json_object_copy(json); - - if(json_is_array(json)) - return json_array_copy(json); - - if(json_is_string(json)) - return json_string_copy(json); - - if(json_is_integer(json)) - return json_integer_copy(json); - - if(json_is_real(json)) - return json_real_copy(json); - - if(json_is_true(json) || json_is_false(json) || json_is_null(json)) - return json; - - return NULL; -} - -json_t *json_deep_copy(const json_t *json) -{ - if(!json) - return NULL; - - if(json_is_object(json)) - return json_object_deep_copy(json); - - if(json_is_array(json)) - return json_array_deep_copy(json); - - /* for the rest of the types, deep copying doesn't differ from - shallow copying */ - - if(json_is_string(json)) - return json_string_copy(json); - - if(json_is_integer(json)) - return json_integer_copy(json); - - if(json_is_real(json)) - return json_real_copy(json); - - if(json_is_true(json) || json_is_false(json) || json_is_null(json)) - return (json_t *)json; - - return NULL; -} diff --git a/deps/jansson/test/.gitignore b/deps/jansson/test/.gitignore deleted file mode 100644 index ae6c8f9..0000000 --- a/deps/jansson/test/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -logs -bin/json_process -suites/api/test_array -suites/api/test_copy -suites/api/test_cpp -suites/api/test_dump -suites/api/test_dump_callback -suites/api/test_equal -suites/api/test_load -suites/api/test_loadb -suites/api/test_memory_funcs -suites/api/test_number -suites/api/test_object -suites/api/test_pack -suites/api/test_simple -suites/api/test_unpack -suites/api/test_load_callback diff --git a/deps/jansson/test/Makefile.am b/deps/jansson/test/Makefile.am deleted file mode 100644 index 86d1614..0000000 --- a/deps/jansson/test/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -SUBDIRS = bin suites -EXTRA_DIST = scripts run-suites - -TESTS = run-suites -TESTS_ENVIRONMENT = \ - top_srcdir=$(top_srcdir) \ - top_builddir=$(top_builddir) - -clean-local: - rm -rf logs diff --git a/deps/jansson/test/bin/Makefile.am b/deps/jansson/test/bin/Makefile.am deleted file mode 100644 index 63b6dce..0000000 --- a/deps/jansson/test/bin/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -check_PROGRAMS = json_process - -AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src -LDFLAGS = -static # for speed and Valgrind -LDADD = $(top_builddir)/src/libjansson.la diff --git a/deps/jansson/test/bin/json_process.c b/deps/jansson/test/bin/json_process.c deleted file mode 100644 index 23afefe..0000000 --- a/deps/jansson/test/bin/json_process.c +++ /dev/null @@ -1,348 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include - -#ifdef HAVE_LOCALE_H -#include - #endif - -#if _WIN32 -#include /* for _setmode() */ -#include /* for _O_BINARY */ - -static const char dir_sep = '\\'; -#else -static const char dir_sep = '/'; -#endif - - -struct config { - int indent; - int compact; - int preserve_order; - int ensure_ascii; - int sort_keys; - int strip; - int use_env; -} conf; - -#define l_isspace(c) ((c) == ' ' || (c) == '\n' || (c) == '\r' || (c) == '\t') - -/* Return a pointer to the first non-whitespace character of str. - Modifies str so that all trailing whitespace characters are - replaced by '\0'. */ -static const char *strip(char *str) -{ - size_t length; - char *result = str; - while (*result && l_isspace(*result)) - result++; - - length = strlen(result); - if (length == 0) - return result; - - while (l_isspace(result[length - 1])) - result[--length] = '\0'; - - return result; -} - - -static char *loadfile(FILE *file) -{ - long fsize, ret; - char *buf; - - fseek(file, 0, SEEK_END); - fsize = ftell(file); - fseek(file, 0, SEEK_SET); - - buf = malloc(fsize+1); - ret = fread(buf, 1, fsize, file); - if (ret != fsize) - exit(1); - buf[fsize] = '\0'; - - return buf; -} - - -static void read_conf(FILE *conffile) -{ - char *buffer, *line, *val; - - buffer = loadfile(conffile); - for (line = strtok(buffer, "\r\n"); line; line = strtok(NULL, "\r\n")) { - if (!strncmp(line, "export ", 7)) - continue; - val = strchr(line, '='); - if (!val) { - printf("invalid configuration line\n"); - break; - } - *val++ = '\0'; - - if (!strcmp(line, "JSON_INDENT")) - conf.indent = atoi(val); - if (!strcmp(line, "JSON_COMPACT")) - conf.compact = atoi(val); - if (!strcmp(line, "JSON_ENSURE_ASCII")) - conf.ensure_ascii = atoi(val); - if (!strcmp(line, "JSON_PRESERVE_ORDER")) - conf.preserve_order = atoi(val); - if (!strcmp(line, "JSON_SORT_KEYS")) - conf.sort_keys = atoi(val); - if (!strcmp(line, "STRIP")) - conf.strip = atoi(val); - } - - free(buffer); -} - - -static int cmpfile(const char *str, const char *path, const char *fname) -{ - char filename[1024], *buffer; - int ret; - FILE *file; - - sprintf(filename, "%s%c%s", path, dir_sep, fname); - file = fopen(filename, "rb"); - if (!file) { - if (conf.strip) - strcat(filename, ".strip"); - else - strcat(filename, ".normal"); - file = fopen(filename, "rb"); - } - if (!file) { - printf("Error: test result file could not be opened.\n"); - exit(1); - } - - buffer = loadfile(file); - if (strcmp(buffer, str) != 0) - ret = 1; - else - ret = 0; - free(buffer); - fclose(file); - - return ret; -} - -int use_conf(char *test_path) -{ - int ret; - size_t flags = 0; - char filename[1024], errstr[1024]; - char *buffer; - FILE *infile, *conffile; - json_t *json; - json_error_t error; - - sprintf(filename, "%s%cinput", test_path, dir_sep); - if (!(infile = fopen(filename, "rb"))) { - fprintf(stderr, "Could not open \"%s\"\n", filename); - return 2; - } - - sprintf(filename, "%s%cenv", test_path, dir_sep); - conffile = fopen(filename, "rb"); - if (conffile) { - read_conf(conffile); - fclose(conffile); - } - - if (conf.indent < 0 || conf.indent > 255) { - fprintf(stderr, "invalid value for JSON_INDENT: %d\n", conf.indent); - return 2; - } - - if (conf.indent) - flags |= JSON_INDENT(conf.indent); - - if (conf.compact) - flags |= JSON_COMPACT; - - if (conf.ensure_ascii) - flags |= JSON_ENSURE_ASCII; - - if (conf.preserve_order) - flags |= JSON_PRESERVE_ORDER; - - if (conf.sort_keys) - flags |= JSON_SORT_KEYS; - - if (conf.strip) { - /* Load to memory, strip leading and trailing whitespace */ - buffer = loadfile(infile); - json = json_loads(strip(buffer), 0, &error); - free(buffer); - } - else - json = json_loadf(infile, 0, &error); - - fclose(infile); - - if (!json) { - sprintf(errstr, "%d %d %d\n%s\n", - error.line, error.column, error.position, - error.text); - - ret = cmpfile(errstr, test_path, "error"); - return ret; - } - - buffer = json_dumps(json, flags); - ret = cmpfile(buffer, test_path, "output"); - free(buffer); - json_decref(json); - - return ret; -} - -static int getenv_int(const char *name) -{ - char *value, *end; - long result; - - value = getenv(name); - if(!value) - return 0; - - result = strtol(value, &end, 10); - if(*end != '\0') - return 0; - - return (int)result; -} - -int use_env() -{ - int indent; - size_t flags = 0; - json_t *json; - json_error_t error; - - #ifdef _WIN32 - /* On Windows, set stdout and stderr to binary mode to avoid - outputting DOS line terminators */ - _setmode(_fileno(stdout), _O_BINARY); - _setmode(_fileno(stderr), _O_BINARY); - #endif - - indent = getenv_int("JSON_INDENT"); - if(indent < 0 || indent > 255) { - fprintf(stderr, "invalid value for JSON_INDENT: %d\n", indent); - return 2; - } - - if(indent > 0) - flags |= JSON_INDENT(indent); - - if(getenv_int("JSON_COMPACT") > 0) - flags |= JSON_COMPACT; - - if(getenv_int("JSON_ENSURE_ASCII")) - flags |= JSON_ENSURE_ASCII; - - if(getenv_int("JSON_PRESERVE_ORDER")) - flags |= JSON_PRESERVE_ORDER; - - if(getenv_int("JSON_SORT_KEYS")) - flags |= JSON_SORT_KEYS; - - if(getenv_int("STRIP")) { - /* Load to memory, strip leading and trailing whitespace */ - size_t size = 0, used = 0; - char *buffer = NULL; - - while(1) { - size_t count; - - size = (size == 0 ? 128 : size * 2); - buffer = realloc(buffer, size); - if(!buffer) { - fprintf(stderr, "Unable to allocate %d bytes\n", (int)size); - return 1; - } - - count = fread(buffer + used, 1, size - used, stdin); - if(count < size - used) { - buffer[used + count] = '\0'; - break; - } - used += count; - } - - json = json_loads(strip(buffer), 0, &error); - free(buffer); - } - else - json = json_loadf(stdin, 0, &error); - - if(!json) { - fprintf(stderr, "%d %d %d\n%s\n", - error.line, error.column, - error.position, error.text); - return 1; - } - - json_dumpf(json, stdout, flags); - json_decref(json); - - return 0; -} - -int main(int argc, char *argv[]) -{ - int i; - char *test_path = NULL; - - #ifdef HAVE_SETLOCALE - setlocale(LC_ALL, ""); - #endif - - if (argc < 2) { - goto usage; - } - - for (i = 1; i < argc; i++) { - if (!strcmp(argv[i], "--strip")) - conf.strip = 1; - else if (!strcmp(argv[i], "--env")) - conf.use_env = 1; - else - test_path = argv[i]; - } - - if (conf.use_env) - return use_env(); - else - { - if (!test_path) - goto usage; - - return use_conf(test_path); - } - -usage: - fprintf(stderr, "argc =%d\n", argc); - fprintf(stderr, "usage: %s [--strip] [--env] test_dir\n", argv[0]); - return 2; -} diff --git a/deps/jansson/test/run-suites b/deps/jansson/test/run-suites deleted file mode 100755 index 4cbaa8b..0000000 --- a/deps/jansson/test/run-suites +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh - -while [ -n "$1" ]; do - suite=$1 - if [ -x $top_srcdir/test/suites/$suite/run ]; then - SUITES="$SUITES $suite" - else - echo "No such suite: $suite" - exit 1 - fi - shift -done - -if [ -z "$SUITES" ]; then - suitedirs=$top_srcdir/test/suites/* - for suitedir in $suitedirs; do - if [ -d $suitedir ]; then - SUITES="$SUITES `basename $suitedir`" - fi - done -fi - -[ -z "$STOP" ] && STOP=0 - -suites_srcdir=$top_srcdir/test/suites -suites_builddir=suites -scriptdir=$top_srcdir/test/scripts -logdir=logs -bindir=bin -export suites_srcdir suites_builddir scriptdir logdir bindir - -passed=0 -failed=0 -for suite in $SUITES; do - echo "Suite: $suite" - if $suites_srcdir/$suite/run $suite; then - passed=$(($passed+1)) - else - failed=$(($failed+1)) - [ $STOP -eq 1 ] && break - fi -done - -if [ $failed -gt 0 ]; then - echo "$failed of $((passed+failed)) test suites failed" - exit 1 -else - echo "$passed test suites passed" - rm -rf $logdir -fi diff --git a/deps/jansson/test/scripts/run-tests.sh b/deps/jansson/test/scripts/run-tests.sh deleted file mode 100644 index 5ed3b9f..0000000 --- a/deps/jansson/test/scripts/run-tests.sh +++ /dev/null @@ -1,100 +0,0 @@ -# Copyright (c) 2009-2013 Petri Lehtinen -# -# Jansson is free software; you can redistribute it and/or modify -# it under the terms of the MIT license. See LICENSE for details. - -die() { - echo "$1" >&2 - exit 1 -} - -[ -n "$1" ] || die "Usage: $0 suite-name" -[ -n "$bindir" ] || die "Set bindir" -[ -n "$logdir" ] || die "Set logdir" -[ -n "$scriptdir" ] || die "Set scriptdir" -[ -n "$suites_srcdir" ] || die "Set suites_srcdir" -[ -n "$suites_builddir" ] || die "Set suites_builddir" - -json_process=$bindir/json_process - -suite_name=$1 -suite_srcdir=$suites_srcdir/$suite_name -suite_builddir=$suites_builddir/$suite_name -suite_log=$logdir/$suite_name - -[ -z "$VERBOSE" ] && VERBOSE=0 -[ -z "$STOP" ] && STOP=0 - -. $scriptdir/valgrind.sh - -rm -rf $suite_log -mkdir -p $suite_log - -for test_path in $suite_srcdir/*; do - test_name=$(basename $test_path) - test_builddir=$suite_builddir/$test_name - test_log=$suite_log/$test_name - - [ "$test_name" = "run" ] && continue - is_test || continue - - rm -rf $test_log - mkdir -p $test_log - if [ $VERBOSE -eq 1 ]; then - printf '%s... ' "$test_name" - fi - - run_test - case $? in - 0) - # Success - if [ $VERBOSE -eq 1 ]; then - printf 'ok\n' - else - printf '.' - fi - rm -rf $test_log - ;; - - 77) - # Skip - if [ $VERBOSE -eq 1 ]; then - printf 'skipped\n' - else - printf 'S' - fi - rm -rf $test_log - ;; - - *) - # Failure - if [ $VERBOSE -eq 1 ]; then - printf 'FAILED\n' - else - printf 'F' - fi - - [ $STOP -eq 1 ] && break - ;; - esac -done - -if [ $VERBOSE -eq 0 ]; then - printf '\n' -fi - -if [ -n "$(ls -A $suite_log)" ]; then - for test_log in $suite_log/*; do - test_name=$(basename $test_log) - test_path=$suite_srcdir/$test_name - echo "=================================================================" - echo "$suite_name/$test_name" - echo "=================================================================" - show_error - echo - done - echo "=================================================================" - exit 1 -else - rm -rf $suite_log -fi diff --git a/deps/jansson/test/scripts/valgrind.sh b/deps/jansson/test/scripts/valgrind.sh deleted file mode 100644 index 9b00438..0000000 --- a/deps/jansson/test/scripts/valgrind.sh +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (c) 2009-2013 Petri Lehtinen -# -# Jansson is free software; you can redistribute it and/or modify -# it under the terms of the MIT license. See LICENSE for details. - -[ -z "$VALGRIND" ] && VALGRIND=0 - -VALGRIND_CMDLINE="valgrind --leak-check=full --show-reachable=yes --track-origins=yes -q" - -if [ $VALGRIND -eq 1 ]; then - test_runner="$VALGRIND_CMDLINE" - json_process="$VALGRIND_CMDLINE $json_process" -else - test_runner="" -fi - -valgrind_check() { - if [ $VALGRIND -eq 1 ]; then - # Check for Valgrind error output. The valgrind option - # --error-exitcode is not enough because Valgrind doesn't - # think unfreed allocs are errors. - if grep -E -q '^==[0-9]+== ' $1; then - touch $test_log/valgrind_error - return 1 - fi - fi -} - -valgrind_show_error() { - if [ $VALGRIND -eq 1 -a -f $test_log/valgrind_error ]; then - echo "valgrind detected an error" - return 0 - fi - return 1 -} diff --git a/deps/jansson/test/suites/.gitattributes b/deps/jansson/test/suites/.gitattributes deleted file mode 100644 index 68d8861..0000000 --- a/deps/jansson/test/suites/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -api/ text=auto -* text eol=lf \ No newline at end of file diff --git a/deps/jansson/test/suites/Makefile.am b/deps/jansson/test/suites/Makefile.am deleted file mode 100644 index a53eb07..0000000 --- a/deps/jansson/test/suites/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -SUBDIRS = api -EXTRA_DIST = invalid invalid-unicode valid diff --git a/deps/jansson/test/suites/api/Makefile.am b/deps/jansson/test/suites/api/Makefile.am deleted file mode 100644 index 1dbdd2b..0000000 --- a/deps/jansson/test/suites/api/Makefile.am +++ /dev/null @@ -1,34 +0,0 @@ -EXTRA_DIST = run check-exports - -check_PROGRAMS = \ - test_array \ - test_copy \ - test_dump \ - test_dump_callback \ - test_equal \ - test_load \ - test_loadb \ - test_load_callback \ - test_memory_funcs \ - test_number \ - test_object \ - test_pack \ - test_simple \ - test_unpack - -test_array_SOURCES = test_array.c util.h -test_copy_SOURCES = test_copy.c util.h -test_dump_SOURCES = test_dump.c util.h -test_dump_callback_SOURCES = test_dump_callback.c util.h -test_load_SOURCES = test_load.c util.h -test_loadb_SOURCES = test_loadb.c util.h -test_memory_funcs_SOURCES = test_memory_funcs.c util.h -test_number_SOURCES = test_number.c util.h -test_object_SOURCES = test_object.c util.h -test_pack_SOURCES = test_pack.c util.h -test_simple_SOURCES = test_simple.c util.h -test_unpack_SOURCES = test_unpack.c util.h - -AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src -LDFLAGS = -static # for speed and Valgrind -LDADD = $(top_builddir)/src/libjansson.la diff --git a/deps/jansson/test/suites/api/check-exports b/deps/jansson/test/suites/api/check-exports deleted file mode 100755 index 9adca7d..0000000 --- a/deps/jansson/test/suites/api/check-exports +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -# -# This test checks that libjansson.so exports the correct symbols. -# - -SOFILE="../src/.libs/libjansson.so" - -# The list of symbols, which the shared object should export, is read -# from the def file, which is used in Windows builds -grep 'json_' $top_srcdir/src/jansson.def \ - | sed -e 's/ //g' \ - | sort \ - >$test_log/exports - -nm -D $SOFILE >/dev/null >$test_log/symbols 2>/dev/null \ - || exit 77 # Skip if "nm -D" doesn't seem to work - -grep ' [DT] ' $test_log/symbols | cut -d' ' -f3 | grep -v '^_' | sort >$test_log/output - -if ! cmp -s $test_log/exports $test_log/output; then - diff -u $test_log/exports $test_log/output >&2 - exit 1 -fi diff --git a/deps/jansson/test/suites/api/run b/deps/jansson/test/suites/api/run deleted file mode 100755 index 5f8e959..0000000 --- a/deps/jansson/test/suites/api/run +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2009-2013 Petri Lehtinen -# -# Jansson is free software; you can redistribute it and/or modify -# it under the terms of the MIT license. See LICENSE for details. - -is_test() { - case "$test_name" in - *.c|check-exports) - return 0 - ;; - *) - return 1 - ;; - esac -} - -run_test() { - if [ "$test_name" = "check-exports" ]; then - test_log=$test_log $test_path >$test_log/stdout 2>$test_log/stderr - else - $test_runner $suite_builddir/${test_name%.c} \ - >$test_log/stdout \ - 2>$test_log/stderr \ - || return 1 - valgrind_check $test_log/stderr || return 1 - fi -} - -show_error() { - valgrind_show_error && return - cat $test_log/stderr -} - -. $top_srcdir/test/scripts/run-tests.sh diff --git a/deps/jansson/test/suites/api/test_array.c b/deps/jansson/test/suites/api/test_array.c deleted file mode 100644 index 0a9447f..0000000 --- a/deps/jansson/test/suites/api/test_array.c +++ /dev/null @@ -1,432 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#include -#include "util.h" - -static void test_misc(void) -{ - json_t *array, *five, *seven, *value; - size_t i; - - array = json_array(); - five = json_integer(5); - seven = json_integer(7); - - if(!array) - fail("unable to create array"); - if(!five || !seven) - fail("unable to create integer"); - - if(json_array_size(array) != 0) - fail("empty array has nonzero size"); - - if(!json_array_append(array, NULL)) - fail("able to append NULL"); - - if(json_array_append(array, five)) - fail("unable to append"); - - if(json_array_size(array) != 1) - fail("wrong array size"); - - value = json_array_get(array, 0); - if(!value) - fail("unable to get item"); - if(value != five) - fail("got wrong value"); - - if(json_array_append(array, seven)) - fail("unable to append value"); - - if(json_array_size(array) != 2) - fail("wrong array size"); - - value = json_array_get(array, 1); - if(!value) - fail("unable to get item"); - if(value != seven) - fail("got wrong value"); - - if(json_array_set(array, 0, seven)) - fail("unable to set value"); - - if(!json_array_set(array, 0, NULL)) - fail("able to set NULL"); - - if(json_array_size(array) != 2) - fail("wrong array size"); - - value = json_array_get(array, 0); - if(!value) - fail("unable to get item"); - if(value != seven) - fail("got wrong value"); - - if(json_array_get(array, 2) != NULL) - fail("able to get value out of bounds"); - - if(!json_array_set(array, 2, seven)) - fail("able to set value out of bounds"); - - for(i = 2; i < 30; i++) { - if(json_array_append(array, seven)) - fail("unable to append value"); - - if(json_array_size(array) != i + 1) - fail("wrong array size"); - } - - for(i = 0; i < 30; i++) { - value = json_array_get(array, i); - if(!value) - fail("unable to get item"); - if(value != seven) - fail("got wrong value"); - } - - if(json_array_set_new(array, 15, json_integer(123))) - fail("unable to set new value"); - - value = json_array_get(array, 15); - if(!json_is_integer(value) || json_integer_value(value) != 123) - fail("json_array_set_new works incorrectly"); - - if(!json_array_set_new(array, 15, NULL)) - fail("able to set_new NULL value"); - - if(json_array_append_new(array, json_integer(321))) - fail("unable to append new value"); - - value = json_array_get(array, json_array_size(array) - 1); - if(!json_is_integer(value) || json_integer_value(value) != 321) - fail("json_array_append_new works incorrectly"); - - if(!json_array_append_new(array, NULL)) - fail("able to append_new NULL value"); - - json_decref(five); - json_decref(seven); - json_decref(array); -} - -static void test_insert(void) -{ - json_t *array, *five, *seven, *eleven, *value; - int i; - - array = json_array(); - five = json_integer(5); - seven = json_integer(7); - eleven = json_integer(11); - - if(!array) - fail("unable to create array"); - if(!five || !seven || !eleven) - fail("unable to create integer"); - - - if(!json_array_insert(array, 1, five)) - fail("able to insert value out of bounds"); - - - if(json_array_insert(array, 0, five)) - fail("unable to insert value in an empty array"); - - if(json_array_get(array, 0) != five) - fail("json_array_insert works incorrectly"); - - if(json_array_size(array) != 1) - fail("array size is invalid after insertion"); - - - if(json_array_insert(array, 1, seven)) - fail("unable to insert value at the end of an array"); - - if(json_array_get(array, 0) != five) - fail("json_array_insert works incorrectly"); - - if(json_array_get(array, 1) != seven) - fail("json_array_insert works incorrectly"); - - if(json_array_size(array) != 2) - fail("array size is invalid after insertion"); - - - if(json_array_insert(array, 1, eleven)) - fail("unable to insert value in the middle of an array"); - - if(json_array_get(array, 0) != five) - fail("json_array_insert works incorrectly"); - - if(json_array_get(array, 1) != eleven) - fail("json_array_insert works incorrectly"); - - if(json_array_get(array, 2) != seven) - fail("json_array_insert works incorrectly"); - - if(json_array_size(array) != 3) - fail("array size is invalid after insertion"); - - - if(json_array_insert_new(array, 2, json_integer(123))) - fail("unable to insert value in the middle of an array"); - - value = json_array_get(array, 2); - if(!json_is_integer(value) || json_integer_value(value) != 123) - fail("json_array_insert_new works incorrectly"); - - if(json_array_size(array) != 4) - fail("array size is invalid after insertion"); - - - for(i = 0; i < 20; i++) { - if(json_array_insert(array, 0, seven)) - fail("unable to insert value at the begining of an array"); - } - - for(i = 0; i < 20; i++) { - if(json_array_get(array, i) != seven) - fail("json_aray_insert works incorrectly"); - } - - if(json_array_size(array) != 24) - fail("array size is invalid after loop insertion"); - - json_decref(five); - json_decref(seven); - json_decref(eleven); - json_decref(array); -} - -static void test_remove(void) -{ - json_t *array, *five, *seven; - int i; - - array = json_array(); - five = json_integer(5); - seven = json_integer(7); - - if(!array) - fail("unable to create array"); - if(!five) - fail("unable to create integer"); - if(!seven) - fail("unable to create integer"); - - - if(!json_array_remove(array, 0)) - fail("able to remove an unexisting index"); - - - if(json_array_append(array, five)) - fail("unable to append"); - - if(!json_array_remove(array, 1)) - fail("able to remove an unexisting index"); - - if(json_array_remove(array, 0)) - fail("unable to remove"); - - if(json_array_size(array) != 0) - fail("array size is invalid after removing"); - - - if(json_array_append(array, five) || - json_array_append(array, seven) || - json_array_append(array, five) || - json_array_append(array, seven)) - fail("unable to append"); - - if(json_array_remove(array, 2)) - fail("unable to remove"); - - if(json_array_size(array) != 3) - fail("array size is invalid after removing"); - - if(json_array_get(array, 0) != five || - json_array_get(array, 1) != seven || - json_array_get(array, 2) != seven) - fail("remove works incorrectly"); - - json_decref(array); - - array = json_array(); - for(i = 0; i < 4; i++) { - json_array_append(array, five); - json_array_append(array, seven); - } - if(json_array_size(array) != 8) - fail("unable to append 8 items to array"); - - /* Remove an element from a "full" array. */ - json_array_remove(array, 5); - - json_decref(five); - json_decref(seven); - json_decref(array); -} - -static void test_clear(void) -{ - json_t *array, *five, *seven; - int i; - - array = json_array(); - five = json_integer(5); - seven = json_integer(7); - - if(!array) - fail("unable to create array"); - if(!five || !seven) - fail("unable to create integer"); - - for(i = 0; i < 10; i++) { - if(json_array_append(array, five)) - fail("unable to append"); - } - for(i = 0; i < 10; i++) { - if(json_array_append(array, seven)) - fail("unable to append"); - } - - if(json_array_size(array) != 20) - fail("array size is invalid after appending"); - - if(json_array_clear(array)) - fail("unable to clear"); - - if(json_array_size(array) != 0) - fail("array size is invalid after clearing"); - - json_decref(five); - json_decref(seven); - json_decref(array); -} - -static void test_extend(void) -{ - json_t *array1, *array2, *five, *seven; - int i; - - array1 = json_array(); - array2 = json_array(); - five = json_integer(5); - seven = json_integer(7); - - if(!array1 || !array2) - fail("unable to create array"); - if(!five || !seven) - fail("unable to create integer"); - - for(i = 0; i < 10; i++) { - if(json_array_append(array1, five)) - fail("unable to append"); - } - for(i = 0; i < 10; i++) { - if(json_array_append(array2, seven)) - fail("unable to append"); - } - - if(json_array_size(array1) != 10 || json_array_size(array2) != 10) - fail("array size is invalid after appending"); - - if(json_array_extend(array1, array2)) - fail("unable to extend"); - - for(i = 0; i < 10; i++) { - if(json_array_get(array1, i) != five) - fail("invalid array contents after extending"); - } - for(i = 10; i < 20; i++) { - if(json_array_get(array1, i) != seven) - fail("invalid array contents after extending"); - } - - json_decref(five); - json_decref(seven); - json_decref(array1); - json_decref(array2); -} - -static void test_circular() -{ - json_t *array1, *array2; - - /* the simple cases are checked */ - - array1 = json_array(); - if(!array1) - fail("unable to create array"); - - if(json_array_append(array1, array1) == 0) - fail("able to append self"); - - if(json_array_insert(array1, 0, array1) == 0) - fail("able to insert self"); - - if(json_array_append_new(array1, json_true())) - fail("failed to append true"); - - if(json_array_set(array1, 0, array1) == 0) - fail("able to set self"); - - json_decref(array1); - - - /* create circular references */ - - array1 = json_array(); - array2 = json_array(); - if(!array1 || !array2) - fail("unable to create array"); - - if(json_array_append(array1, array2) || - json_array_append(array2, array1)) - fail("unable to append"); - - /* circularity is detected when dumping */ - if(json_dumps(array1, 0) != NULL) - fail("able to dump circulars"); - - /* decref twice to deal with the circular references */ - json_decref(array1); - json_decref(array2); - json_decref(array1); -} - -static void test_array_foreach() -{ - size_t index; - json_t *array1, *array2, *value; - - array1 = json_pack("[sisisi]", "foo", 1, "bar", 2, "baz", 3); - array2 = json_array(); - - json_array_foreach(array1, index, value) { - json_array_append(array2, value); - } - - if(!json_equal(array1, array2)) - fail("json_array_foreach failed to iterate all elements"); - - json_decref(array1); - json_decref(array2); -} - - -static void run_tests() -{ - test_misc(); - test_insert(); - test_remove(); - test_clear(); - test_extend(); - test_circular(); - test_array_foreach(); -} diff --git a/deps/jansson/test/suites/api/test_copy.c b/deps/jansson/test/suites/api/test_copy.c deleted file mode 100644 index 580488d..0000000 --- a/deps/jansson/test/suites/api/test_copy.c +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#include -#include -#include "util.h" - -static void test_copy_simple(void) -{ - json_t *value, *copy; - - if(json_copy(NULL)) - fail("copying NULL doesn't return NULL"); - - /* true */ - value = json_true(); - copy = json_copy(value); - if(value != copy) - fail("copying true failed"); - json_decref(value); - json_decref(copy); - - /* false */ - value = json_false(); - copy = json_copy(value); - if(value != copy) - fail("copying false failed"); - json_decref(value); - json_decref(copy); - - /* null */ - value = json_null(); - copy = json_copy(value); - if(value != copy) - fail("copying null failed"); - json_decref(value); - json_decref(copy); - - /* string */ - value = json_string("foo"); - if(!value) - fail("unable to create a string"); - copy = json_copy(value); - if(!copy) - fail("unable to copy a string"); - if(copy == value) - fail("copying a string doesn't copy"); - if(!json_equal(copy, value)) - fail("copying a string produces an inequal copy"); - if(value->refcount != 1 || copy->refcount != 1) - fail("invalid refcounts"); - json_decref(value); - json_decref(copy); - - /* integer */ - value = json_integer(543); - if(!value) - fail("unable to create an integer"); - copy = json_copy(value); - if(!copy) - fail("unable to copy an integer"); - if(copy == value) - fail("copying an integer doesn't copy"); - if(!json_equal(copy, value)) - fail("copying an integer produces an inequal copy"); - if(value->refcount != 1 || copy->refcount != 1) - fail("invalid refcounts"); - json_decref(value); - json_decref(copy); - - /* real */ - value = json_real(123e9); - if(!value) - fail("unable to create a real"); - copy = json_copy(value); - if(!copy) - fail("unable to copy a real"); - if(copy == value) - fail("copying a real doesn't copy"); - if(!json_equal(copy, value)) - fail("copying a real produces an inequal copy"); - if(value->refcount != 1 || copy->refcount != 1) - fail("invalid refcounts"); - json_decref(value); - json_decref(copy); -} - -static void test_deep_copy_simple(void) -{ - json_t *value, *copy; - - if(json_deep_copy(NULL)) - fail("deep copying NULL doesn't return NULL"); - - /* true */ - value = json_true(); - copy = json_deep_copy(value); - if(value != copy) - fail("deep copying true failed"); - json_decref(value); - json_decref(copy); - - /* false */ - value = json_false(); - copy = json_deep_copy(value); - if(value != copy) - fail("deep copying false failed"); - json_decref(value); - json_decref(copy); - - /* null */ - value = json_null(); - copy = json_deep_copy(value); - if(value != copy) - fail("deep copying null failed"); - json_decref(value); - json_decref(copy); - - /* string */ - value = json_string("foo"); - if(!value) - fail("unable to create a string"); - copy = json_deep_copy(value); - if(!copy) - fail("unable to deep copy a string"); - if(copy == value) - fail("deep copying a string doesn't copy"); - if(!json_equal(copy, value)) - fail("deep copying a string produces an inequal copy"); - if(value->refcount != 1 || copy->refcount != 1) - fail("invalid refcounts"); - json_decref(value); - json_decref(copy); - - /* integer */ - value = json_integer(543); - if(!value) - fail("unable to create an integer"); - copy = json_deep_copy(value); - if(!copy) - fail("unable to deep copy an integer"); - if(copy == value) - fail("deep copying an integer doesn't copy"); - if(!json_equal(copy, value)) - fail("deep copying an integer produces an inequal copy"); - if(value->refcount != 1 || copy->refcount != 1) - fail("invalid refcounts"); - json_decref(value); - json_decref(copy); - - /* real */ - value = json_real(123e9); - if(!value) - fail("unable to create a real"); - copy = json_deep_copy(value); - if(!copy) - fail("unable to deep copy a real"); - if(copy == value) - fail("deep copying a real doesn't copy"); - if(!json_equal(copy, value)) - fail("deep copying a real produces an inequal copy"); - if(value->refcount != 1 || copy->refcount != 1) - fail("invalid refcounts"); - json_decref(value); - json_decref(copy); -} - -static void test_copy_array(void) -{ - const char *json_array_text = "[1, \"foo\", 3.141592, {\"foo\": \"bar\"}]"; - - json_t *array, *copy; - size_t i; - - array = json_loads(json_array_text, 0, NULL); - if(!array) - fail("unable to parse an array"); - - copy = json_copy(array); - if(!copy) - fail("unable to copy an array"); - if(copy == array) - fail("copying an array doesn't copy"); - if(!json_equal(copy, array)) - fail("copying an array produces an inequal copy"); - - for(i = 0; i < json_array_size(copy); i++) - { - if(json_array_get(array, i) != json_array_get(copy, i)) - fail("copying an array modifies its elements"); - } - - json_decref(array); - json_decref(copy); -} - -static void test_deep_copy_array(void) -{ - const char *json_array_text = "[1, \"foo\", 3.141592, {\"foo\": \"bar\"}]"; - - json_t *array, *copy; - size_t i; - - array = json_loads(json_array_text, 0, NULL); - if(!array) - fail("unable to parse an array"); - - copy = json_deep_copy(array); - if(!copy) - fail("unable to deep copy an array"); - if(copy == array) - fail("deep copying an array doesn't copy"); - if(!json_equal(copy, array)) - fail("deep copying an array produces an inequal copy"); - - for(i = 0; i < json_array_size(copy); i++) - { - if(json_array_get(array, i) == json_array_get(copy, i)) - fail("deep copying an array doesn't copy its elements"); - } - - json_decref(array); - json_decref(copy); -} - -static void test_copy_object(void) -{ - const char *json_object_text = - "{\"foo\": \"bar\", \"a\": 1, \"b\": 3.141592, \"c\": [1,2,3,4]}"; - - json_t *object, *copy; - void *iter; - - object = json_loads(json_object_text, 0, NULL); - if(!object) - fail("unable to parse an object"); - - copy = json_copy(object); - if(!copy) - fail("unable to copy an object"); - if(copy == object) - fail("copying an object doesn't copy"); - if(!json_equal(copy, object)) - fail("copying an object produces an inequal copy"); - - iter = json_object_iter(object); - while(iter) - { - const char *key; - json_t *value1, *value2; - - key = json_object_iter_key(iter); - value1 = json_object_iter_value(iter); - value2 = json_object_get(copy, key); - - if(value1 != value2) - fail("deep copying an object modifies its items"); - - iter = json_object_iter_next(object, iter); - } - - json_decref(object); - json_decref(copy); -} - -static void test_deep_copy_object(void) -{ - const char *json_object_text = - "{\"foo\": \"bar\", \"a\": 1, \"b\": 3.141592, \"c\": [1,2,3,4]}"; - - json_t *object, *copy; - void *iter; - - object = json_loads(json_object_text, 0, NULL); - if(!object) - fail("unable to parse an object"); - - copy = json_deep_copy(object); - if(!copy) - fail("unable to deep copy an object"); - if(copy == object) - fail("deep copying an object doesn't copy"); - if(!json_equal(copy, object)) - fail("deep copying an object produces an inequal copy"); - - iter = json_object_iter(object); - while(iter) - { - const char *key; - json_t *value1, *value2; - - key = json_object_iter_key(iter); - value1 = json_object_iter_value(iter); - value2 = json_object_get(copy, key); - - if(value1 == value2) - fail("deep copying an object doesn't copy its items"); - - iter = json_object_iter_next(object, iter); - } - - json_decref(object); - json_decref(copy); -} - -static void run_tests() -{ - test_copy_simple(); - test_deep_copy_simple(); - test_copy_array(); - test_deep_copy_array(); - test_copy_object(); - test_deep_copy_object(); -} diff --git a/deps/jansson/test/suites/api/test_dump.c b/deps/jansson/test/suites/api/test_dump.c deleted file mode 100644 index 89e73a7..0000000 --- a/deps/jansson/test/suites/api/test_dump.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#include -#include -#include "util.h" - -static int encode_null_callback(const char *buffer, size_t size, void *data) -{ - (void)buffer; - (void)size; - (void)data; - return 0; -} - -static void encode_null() -{ - if(json_dumps(NULL, JSON_ENCODE_ANY) != NULL) - fail("json_dumps didn't fail for NULL"); - - if(json_dumpf(NULL, stderr, JSON_ENCODE_ANY) != -1) - fail("json_dumpf didn't fail for NULL"); - - /* Don't test json_dump_file to avoid creating a file */ - - if(json_dump_callback(NULL, encode_null_callback, NULL, JSON_ENCODE_ANY) != -1) - fail("json_dump_callback didn't fail for NULL"); -} - - -static void encode_twice() -{ - /* Encode an empty object/array, add an item, encode again */ - - json_t *json; - char *result; - - json = json_object(); - result = json_dumps(json, 0); - if(!result || strcmp(result, "{}")) - fail("json_dumps failed"); - free(result); - - json_object_set_new(json, "foo", json_integer(5)); - result = json_dumps(json, 0); - if(!result || strcmp(result, "{\"foo\": 5}")) - fail("json_dumps failed"); - free(result); - - json_decref(json); - - json = json_array(); - result = json_dumps(json, 0); - if(!result || strcmp(result, "[]")) - fail("json_dumps failed"); - free(result); - - json_array_append_new(json, json_integer(5)); - result = json_dumps(json, 0); - if(!result || strcmp(result, "[5]")) - fail("json_dumps failed"); - free(result); - - json_decref(json); -} - -static void circular_references() -{ - /* Construct a JSON object/array with a circular reference: - - object: {"a": {"b": {"c": }}} - array: [[[]]] - - Encode it, remove the circular reference and encode again. - */ - - json_t *json; - char *result; - - json = json_object(); - json_object_set_new(json, "a", json_object()); - json_object_set_new(json_object_get(json, "a"), "b", json_object()); - json_object_set(json_object_get(json_object_get(json, "a"), "b"), "c", - json_object_get(json, "a")); - - if(json_dumps(json, 0)) - fail("json_dumps encoded a circular reference!"); - - json_object_del(json_object_get(json_object_get(json, "a"), "b"), "c"); - - result = json_dumps(json, 0); - if(!result || strcmp(result, "{\"a\": {\"b\": {}}}")) - fail("json_dumps failed!"); - free(result); - - json_decref(json); - - json = json_array(); - json_array_append_new(json, json_array()); - json_array_append_new(json_array_get(json, 0), json_array()); - json_array_append(json_array_get(json_array_get(json, 0), 0), - json_array_get(json, 0)); - - if(json_dumps(json, 0)) - fail("json_dumps encoded a circular reference!"); - - json_array_remove(json_array_get(json_array_get(json, 0), 0), 0); - - result = json_dumps(json, 0); - if(!result || strcmp(result, "[[[]]]")) - fail("json_dumps failed!"); - free(result); - - json_decref(json); -} - -static void encode_other_than_array_or_object() -{ - /* Encoding anything other than array or object should only - * succeed if the JSON_ENCODE_ANY flag is used */ - - json_t *json; - FILE *fp = NULL; - char *result; - - json = json_string("foo"); - if(json_dumps(json, 0) != NULL) - fail("json_dumps encoded a string!"); - if(json_dumpf(json, fp, 0) == 0) - fail("json_dumpf encoded a string!"); - - result = json_dumps(json, JSON_ENCODE_ANY); - if(!result || strcmp(result, "\"foo\"") != 0) - fail("json_dumps failed to encode a string with JSON_ENCODE_ANY"); - - free(result); - json_decref(json); - - json = json_integer(42); - if(json_dumps(json, 0) != NULL) - fail("json_dumps encoded an integer!"); - if(json_dumpf(json, fp, 0) == 0) - fail("json_dumpf encoded an integer!"); - - result = json_dumps(json, JSON_ENCODE_ANY); - if(!result || strcmp(result, "42") != 0) - fail("json_dumps failed to encode an integer with JSON_ENCODE_ANY"); - - free(result); - json_decref(json); - - -} - -static void escape_slashes() -{ - /* Test dump escaping slashes */ - - json_t *json; - char *result; - - json = json_object(); - json_object_set_new(json, "url", json_string("https://github.com/akheron/jansson")); - - result = json_dumps(json, 0); - if(!result || strcmp(result, "{\"url\": \"https://github.com/akheron/jansson\"}")) - fail("json_dumps failed to not escape slashes"); - - free(result); - - result = json_dumps(json, JSON_ESCAPE_SLASH); - if(!result || strcmp(result, "{\"url\": \"https:\\/\\/github.com\\/akheron\\/jansson\"}")) - fail("json_dumps failed to escape slashes"); - - free(result); - json_decref(json); -} - -static void encode_nul_byte() -{ - json_t *json; - char *result; - - json = json_stringn("nul byte \0 in string", 20); - result = json_dumps(json, JSON_ENCODE_ANY); - if(!result || memcmp(result, "\"nul byte \\u0000 in string\"", 27)) - fail("json_dumps failed to dump an embedded NUL byte"); - - free(result); - json_decref(json); -} - -static void run_tests() -{ - encode_null(); - encode_twice(); - circular_references(); - encode_other_than_array_or_object(); - escape_slashes(); - encode_nul_byte(); -} diff --git a/deps/jansson/test/suites/api/test_dump_callback.c b/deps/jansson/test/suites/api/test_dump_callback.c deleted file mode 100644 index 4536d56..0000000 --- a/deps/jansson/test/suites/api/test_dump_callback.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#include -#include -#include -#include "util.h" - -struct my_sink { - char *buf; - size_t off; - size_t cap; -}; - -static int my_writer(const char *buffer, size_t len, void *data) { - struct my_sink *s = data; - if (len > s->cap - s->off) { - return -1; - } - memcpy(s->buf + s->off, buffer, len); - s->off += len; - return 0; -} - -static void run_tests() -{ - struct my_sink s; - json_t *json; - const char str[] = "[\"A\", {\"B\": \"C\", \"e\": false}, 1, null, \"foo\"]"; - char *dumped_to_string; - - json = json_loads(str, 0, NULL); - if(!json) { - fail("json_loads failed"); - } - - dumped_to_string = json_dumps(json, 0); - if (!dumped_to_string) { - json_decref(json); - fail("json_dumps failed"); - } - - s.off = 0; - s.cap = strlen(dumped_to_string); - s.buf = malloc(s.cap); - if (!s.buf) { - json_decref(json); - free(dumped_to_string); - fail("malloc failed"); - } - - if (json_dump_callback(json, my_writer, &s, 0) == -1) { - json_decref(json); - free(dumped_to_string); - free(s.buf); - fail("json_dump_callback failed on an exact-length sink buffer"); - } - - if (strncmp(dumped_to_string, s.buf, s.off) != 0) { - json_decref(json); - free(dumped_to_string); - free(s.buf); - fail("json_dump_callback and json_dumps did not produce identical output"); - } - - s.off = 1; - if (json_dump_callback(json, my_writer, &s, 0) != -1) { - json_decref(json); - free(dumped_to_string); - free(s.buf); - fail("json_dump_callback succeeded on a short buffer when it should have failed"); - } - - json_decref(json); - free(dumped_to_string); - free(s.buf); -} diff --git a/deps/jansson/test/suites/api/test_equal.c b/deps/jansson/test/suites/api/test_equal.c deleted file mode 100644 index 354e5c9..0000000 --- a/deps/jansson/test/suites/api/test_equal.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#include -#include "util.h" - -static void test_equal_simple() -{ - json_t *value1, *value2; - - if(json_equal(NULL, NULL)) - fail("json_equal fails for two NULLs"); - - value1 = json_true(); - if(json_equal(value1, NULL) || json_equal(NULL, value1)) - fail("json_equal fails for NULL"); - - /* this covers true, false and null as they are singletons */ - if(!json_equal(value1, value1)) - fail("identical objects are not equal"); - json_decref(value1); - - /* integer */ - value1 = json_integer(1); - value2 = json_integer(1); - if(!value1 || !value2) - fail("unable to create integers"); - if(!json_equal(value1, value2)) - fail("json_equal fails for two equal integers"); - json_decref(value2); - - value2 = json_integer(2); - if(!value2) - fail("unable to create an integer"); - if(json_equal(value1, value2)) - fail("json_equal fails for two inequal integers"); - - json_decref(value1); - json_decref(value2); - - /* real */ - value1 = json_real(1.2); - value2 = json_real(1.2); - if(!value1 || !value2) - fail("unable to create reals"); - if(!json_equal(value1, value2)) - fail("json_equal fails for two equal reals"); - json_decref(value2); - - value2 = json_real(3.141592); - if(!value2) - fail("unable to create an real"); - if(json_equal(value1, value2)) - fail("json_equal fails for two inequal reals"); - - json_decref(value1); - json_decref(value2); - - /* string */ - value1 = json_string("foo"); - value2 = json_string("foo"); - if(!value1 || !value2) - fail("unable to create strings"); - if(!json_equal(value1, value2)) - fail("json_equal fails for two equal strings"); - json_decref(value2); - - value2 = json_string("bar"); - if(!value2) - fail("unable to create an string"); - if(json_equal(value1, value2)) - fail("json_equal fails for two inequal strings"); - - json_decref(value1); - json_decref(value2); -} - -static void test_equal_array() -{ - json_t *array1, *array2; - - array1 = json_array(); - array2 = json_array(); - if(!array1 || !array2) - fail("unable to create arrays"); - - if(!json_equal(array1, array2)) - fail("json_equal fails for two empty arrays"); - - json_array_append_new(array1, json_integer(1)); - json_array_append_new(array2, json_integer(1)); - json_array_append_new(array1, json_string("foo")); - json_array_append_new(array2, json_string("foo")); - json_array_append_new(array1, json_integer(2)); - json_array_append_new(array2, json_integer(2)); - if(!json_equal(array1, array2)) - fail("json_equal fails for two equal arrays"); - - json_array_remove(array2, 2); - if(json_equal(array1, array2)) - fail("json_equal fails for two inequal arrays"); - - json_array_append_new(array2, json_integer(3)); - if(json_equal(array1, array2)) - fail("json_equal fails for two inequal arrays"); - - json_decref(array1); - json_decref(array2); -} - -static void test_equal_object() -{ - json_t *object1, *object2; - - object1 = json_object(); - object2 = json_object(); - if(!object1 || !object2) - fail("unable to create objects"); - - if(!json_equal(object1, object2)) - fail("json_equal fails for two empty objects"); - - json_object_set_new(object1, "a", json_integer(1)); - json_object_set_new(object2, "a", json_integer(1)); - json_object_set_new(object1, "b", json_string("foo")); - json_object_set_new(object2, "b", json_string("foo")); - json_object_set_new(object1, "c", json_integer(2)); - json_object_set_new(object2, "c", json_integer(2)); - if(!json_equal(object1, object2)) - fail("json_equal fails for two equal objects"); - - json_object_del(object2, "c"); - if(json_equal(object1, object2)) - fail("json_equal fails for two inequal objects"); - - json_object_set_new(object2, "c", json_integer(3)); - if(json_equal(object1, object2)) - fail("json_equal fails for two inequal objects"); - - json_object_del(object2, "c"); - json_object_set_new(object2, "d", json_integer(2)); - if(json_equal(object1, object2)) - fail("json_equal fails for two inequal objects"); - - json_decref(object1); - json_decref(object2); -} - -static void test_equal_complex() -{ - json_t *value1, *value2; - - const char *complex_json = -"{" -" \"integer\": 1, " -" \"real\": 3.141592, " -" \"string\": \"foobar\", " -" \"true\": true, " -" \"object\": {" -" \"array-in-object\": [1,true,\"foo\",{}]," -" \"object-in-object\": {\"foo\": \"bar\"}" -" }," -" \"array\": [\"foo\", false, null, 1.234]" -"}"; - - value1 = json_loads(complex_json, 0, NULL); - value2 = json_loads(complex_json, 0, NULL); - if(!value1 || !value2) - fail("unable to parse JSON"); - if(!json_equal(value1, value2)) - fail("json_equal fails for two inequal strings"); - - json_decref(value1); - json_decref(value2); - - /* TODO: There's no negative test case here */ -} - -static void run_tests() -{ - test_equal_simple(); - test_equal_array(); - test_equal_object(); - test_equal_complex(); -} diff --git a/deps/jansson/test/suites/api/test_load.c b/deps/jansson/test/suites/api/test_load.c deleted file mode 100644 index eb52323..0000000 --- a/deps/jansson/test/suites/api/test_load.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#include -#include -#include "util.h" - -static void file_not_found() -{ - json_t *json; - json_error_t error; - char *pos; - - json = json_load_file("/path/to/nonexistent/file.json", 0, &error); - if(json) - fail("json_load_file returned non-NULL for a nonexistent file"); - if(error.line != -1) - fail("json_load_file returned an invalid line number"); - - /* The error message is locale specific, only check the beginning - of the error message. */ - - pos = strchr(error.text, ':'); - if(!pos) - fail("json_load_file returne an invalid error message"); - - *pos = '\0'; - - if(strcmp(error.text, "unable to open /path/to/nonexistent/file.json") != 0) - fail("json_load_file returned an invalid error message"); -} - -static void reject_duplicates() -{ - json_error_t error; - - if(json_loads("{\"foo\": 1, \"foo\": 2}", JSON_REJECT_DUPLICATES, &error)) - fail("json_loads did not detect a duplicate key"); - check_error("duplicate object key near '\"foo\"'", "", 1, 16, 16); -} - -static void disable_eof_check() -{ - json_error_t error; - json_t *json; - - const char *text = "{\"foo\": 1} garbage"; - - if(json_loads(text, 0, &error)) - fail("json_loads did not detect garbage after JSON text"); - check_error("end of file expected near 'garbage'", "", 1, 18, 18); - - json = json_loads(text, JSON_DISABLE_EOF_CHECK, &error); - if(!json) - fail("json_loads failed with JSON_DISABLE_EOF_CHECK"); - - json_decref(json); -} - -static void decode_any() -{ - json_t *json; - json_error_t error; - - json = json_loads("\"foo\"", JSON_DECODE_ANY, &error); - if (!json || !json_is_string(json)) - fail("json_load decoded any failed - string"); - json_decref(json); - - json = json_loads("42", JSON_DECODE_ANY, &error); - if (!json || !json_is_integer(json)) - fail("json_load decoded any failed - integer"); - json_decref(json); - - json = json_loads("true", JSON_DECODE_ANY, &error); - if (!json || !json_is_true(json)) - fail("json_load decoded any failed - boolean"); - json_decref(json); - - json = json_loads("null", JSON_DECODE_ANY, &error); - if (!json || !json_is_null(json)) - fail("json_load decoded any failed - null"); - json_decref(json); -} - -static void decode_int_as_real() -{ - json_t *json; - json_error_t error; - -#if JSON_INTEGER_IS_LONG_LONG - const char *imprecise; - json_int_t expected; -#endif - - json = json_loads("42", JSON_DECODE_INT_AS_REAL | JSON_DECODE_ANY, &error); - if (!json || !json_is_real(json) || json_real_value(json) != 42.0) - fail("json_load decode int as real failed - int"); - json_decref(json); - -#if JSON_INTEGER_IS_LONG_LONG - /* This number cannot be represented exactly by a double */ - imprecise = "9007199254740993"; - expected = 9007199254740992ll; - - json = json_loads(imprecise, JSON_DECODE_INT_AS_REAL | JSON_DECODE_ANY, - &error); - if (!json || !json_is_real(json) || expected != (json_int_t)json_real_value(json)) - fail("json_load decode int as real failed - expected imprecision"); - json_decref(json); -#endif -} - -static void allow_nul() -{ - const char *text = "\"nul byte \\u0000 in string\""; - const char *expected = "nul byte \0 in string"; - size_t len = 20; - json_t *json; - - json = json_loads(text, JSON_ALLOW_NUL | JSON_DECODE_ANY, NULL); - if(!json || !json_is_string(json)) - fail("unable to decode embedded NUL byte"); - - if(json_string_length(json) != len) - fail("decoder returned wrong string length"); - - if(memcmp(json_string_value(json), expected, len + 1)) - fail("decoder returned wrong string content"); - - json_decref(json); -} - -static void load_wrong_args() -{ - json_t *json; - json_error_t error; - - json = json_loads(NULL, 0, &error); - if (json) - fail("json_loads should return NULL if the first argument is NULL"); - - json = json_loadb(NULL, 0, 0, &error); - if (json) - fail("json_loadb should return NULL if the first argument is NULL"); - - json = json_loadf(NULL, 0, &error); - if (json) - fail("json_loadf should return NULL if the first argument is NULL"); - - json = json_load_file(NULL, 0, &error); - if (json) - fail("json_loadf should return NULL if the first argument is NULL"); -} - -static void position() -{ - json_t *json; - size_t flags = JSON_DISABLE_EOF_CHECK; - json_error_t error; - - json = json_loads("{\"foo\": \"bar\"}", 0, &error); - if(error.position != 14) - fail("json_loads returned a wrong position"); - json_decref(json); - - json = json_loads("{\"foo\": \"bar\"} baz quux", flags, &error); - if(error.position != 14) - fail("json_loads returned a wrong position"); - json_decref(json); -} - -static void run_tests() -{ - file_not_found(); - reject_duplicates(); - disable_eof_check(); - decode_any(); - decode_int_as_real(); - allow_nul(); - load_wrong_args(); - position(); -} diff --git a/deps/jansson/test/suites/api/test_load_callback.c b/deps/jansson/test/suites/api/test_load_callback.c deleted file mode 100644 index 9449528..0000000 --- a/deps/jansson/test/suites/api/test_load_callback.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2009-2011 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#include -#include -#include -#include "util.h" - -struct my_source { - const char *buf; - size_t off; - size_t cap; -}; - -static const char my_str[] = "[\"A\", {\"B\": \"C\", \"e\": false}, 1, null, \"foo\"]"; - -static size_t greedy_reader(void *buf, size_t buflen, void *arg) -{ - struct my_source *s = arg; - if (buflen > s->cap - s->off) - buflen = s->cap - s->off; - if (buflen > 0) { - memcpy(buf, s->buf + s->off, buflen); - s->off += buflen; - return buflen; - } else { - return 0; - } -} - -static void run_tests() -{ - struct my_source s; - json_t *json; - json_error_t error; - - s.off = 0; - s.cap = strlen(my_str); - s.buf = my_str; - - json = json_load_callback(greedy_reader, &s, 0, &error); - - if (!json) - fail("json_load_callback failed on a valid callback"); - json_decref(json); - - s.off = 0; - s.cap = strlen(my_str) - 1; - s.buf = my_str; - - json = json_load_callback(greedy_reader, &s, 0, &error); - if (json) { - json_decref(json); - fail("json_load_callback should have failed on an incomplete stream, but it didn't"); - } - if (strcmp(error.source, "") != 0) { - fail("json_load_callback returned an invalid error source"); - } - if (strcmp(error.text, "']' expected near end of file") != 0) { - fail("json_load_callback returned an invalid error message for an unclosed top-level array"); - } - - json = json_load_callback(NULL, NULL, 0, &error); - if (json) { - json_decref(json); - fail("json_load_callback should have failed on NULL load callback, but it didn't"); - } - if (strcmp(error.text, "wrong arguments") != 0) { - fail("json_load_callback returned an invalid error message for a NULL load callback"); - } -} diff --git a/deps/jansson/test/suites/api/test_loadb.c b/deps/jansson/test/suites/api/test_loadb.c deleted file mode 100644 index fa5e967..0000000 --- a/deps/jansson/test/suites/api/test_loadb.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#include -#include -#include "util.h" - -static void run_tests() -{ - json_t *json; - json_error_t error; - const char str[] = "[\"A\", {\"B\": \"C\"}, 1, 2, 3]garbage"; - size_t len = strlen(str) - strlen("garbage"); - - json = json_loadb(str, len, 0, &error); - if(!json) { - fail("json_loadb failed on a valid JSON buffer"); - } - json_decref(json); - - json = json_loadb(str, len - 1, 0, &error); - if (json) { - json_decref(json); - fail("json_loadb should have failed on an incomplete buffer, but it didn't"); - } - if(error.line != 1) { - fail("json_loadb returned an invalid line number on fail"); - } - if(strcmp(error.text, "']' expected near end of file") != 0) { - fail("json_loadb returned an invalid error message for an unclosed top-level array"); - } -} diff --git a/deps/jansson/test/suites/api/test_memory_funcs.c b/deps/jansson/test/suites/api/test_memory_funcs.c deleted file mode 100644 index 8737389..0000000 --- a/deps/jansson/test/suites/api/test_memory_funcs.c +++ /dev/null @@ -1,82 +0,0 @@ -#include -#include - -#include "util.h" - -static int malloc_called = 0; -static int free_called = 0; - -/* helper */ -static void create_and_free_complex_object() -{ - json_t *obj; - - obj = json_pack("{s:i,s:n,s:b,s:b,s:{s:s},s:[i,i,i]", - "foo", 42, - "bar", - "baz", 1, - "qux", 0, - "alice", "bar", "baz", - "bob", 9, 8, 7); - - json_decref(obj); -} - -static void *my_malloc(size_t size) -{ - malloc_called += 1; - return malloc(size); -} - -static void my_free(void *ptr) -{ - free_called += 1; - free(ptr); -} - -static void test_simple() -{ - json_set_alloc_funcs(my_malloc, my_free); - create_and_free_complex_object(); - - if(malloc_called != 20 || free_called != 20) - fail("Custom allocation failed"); -} - - -/* - Test the secure memory functions code given in the API reference - documentation, but by using plain memset instead of - guaranteed_memset(). -*/ - -static void *secure_malloc(size_t size) -{ - /* Store the memory area size in the beginning of the block */ - void *ptr = malloc(size + 8); - *((size_t *)ptr) = size; - return (char *)ptr + 8; -} - -static void secure_free(void *ptr) -{ - size_t size; - - ptr = (char *)ptr - 8; - size = *((size_t *)ptr); - - /*guaranteed_*/memset(ptr, 0, size + 8); - free(ptr); -} - -static void test_secure_funcs(void) -{ - json_set_alloc_funcs(secure_malloc, secure_free); - create_and_free_complex_object(); -} - -static void run_tests() -{ - test_simple(); - test_secure_funcs(); -} diff --git a/deps/jansson/test/suites/api/test_number.c b/deps/jansson/test/suites/api/test_number.c deleted file mode 100644 index b506a2b..0000000 --- a/deps/jansson/test/suites/api/test_number.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#include -#include -#include "util.h" - -static void run_tests() -{ - json_t *integer, *real; - json_int_t i; - double d; - - integer = json_integer(5); - real = json_real(100.1); - - if(!integer) - fail("unable to create integer"); - if(!real) - fail("unable to create real"); - - i = json_integer_value(integer); - if(i != 5) - fail("wrong integer value"); - - d = json_real_value(real); - if(d != 100.1) - fail("wrong real value"); - - d = json_number_value(integer); - if(d != 5.0) - fail("wrong number value"); - d = json_number_value(real); - if(d != 100.1) - fail("wrong number value"); - - json_decref(integer); - json_decref(real); - -#ifdef NAN - real = json_real(NAN); - if(real != NULL) - fail("could construct a real from NaN"); - - real = json_real(1.0); - if(json_real_set(real, NAN) != -1) - fail("could set a real to NaN"); - - if(json_real_value(real) != 1.0) - fail("real value changed unexpectedly"); - - json_decref(real); -#endif - -#ifdef INFINITY - real = json_real(INFINITY); - if(real != NULL) - fail("could construct a real from Inf"); - - real = json_real(1.0); - if(json_real_set(real, INFINITY) != -1) - fail("could set a real to Inf"); - - if(json_real_value(real) != 1.0) - fail("real value changed unexpectedly"); - - json_decref(real); -#endif -} diff --git a/deps/jansson/test/suites/api/test_object.c b/deps/jansson/test/suites/api/test_object.c deleted file mode 100644 index ba428e1..0000000 --- a/deps/jansson/test/suites/api/test_object.c +++ /dev/null @@ -1,511 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#include -#include -#include "util.h" - -static void test_clear() -{ - json_t *object, *ten; - - object = json_object(); - ten = json_integer(10); - - if(!object) - fail("unable to create object"); - if(!ten) - fail("unable to create integer"); - - if(json_object_set(object, "a", ten) || - json_object_set(object, "b", ten) || - json_object_set(object, "c", ten) || - json_object_set(object, "d", ten) || - json_object_set(object, "e", ten)) - fail("unable to set value"); - - if(json_object_size(object) != 5) - fail("invalid size"); - - json_object_clear(object); - - if(json_object_size(object) != 0) - fail("invalid size after clear"); - - json_decref(ten); - json_decref(object); -} - -static void test_update() -{ - json_t *object, *other, *nine, *ten; - - object = json_object(); - other = json_object(); - - nine = json_integer(9); - ten = json_integer(10); - - if(!object || !other) - fail("unable to create object"); - if(!nine || !ten) - fail("unable to create integer"); - - - /* update an empty object with an empty object */ - - if(json_object_update(object, other)) - fail("unable to update an emtpy object with an empty object"); - - if(json_object_size(object) != 0) - fail("invalid size after update"); - - if(json_object_size(other) != 0) - fail("invalid size for updater after update"); - - - /* update an empty object with a nonempty object */ - - if(json_object_set(other, "a", ten) || - json_object_set(other, "b", ten) || - json_object_set(other, "c", ten) || - json_object_set(other, "d", ten) || - json_object_set(other, "e", ten)) - fail("unable to set value"); - - if(json_object_update(object, other)) - fail("unable to update an empty object"); - - if(json_object_size(object) != 5) - fail("invalid size after update"); - - if(json_object_get(object, "a") != ten || - json_object_get(object, "b") != ten || - json_object_get(object, "c") != ten || - json_object_get(object, "d") != ten || - json_object_get(object, "e") != ten) - fail("update works incorrectly"); - - - /* perform the same update again */ - - if(json_object_update(object, other)) - fail("unable to update a non-empty object"); - - if(json_object_size(object) != 5) - fail("invalid size after update"); - - if(json_object_get(object, "a") != ten || - json_object_get(object, "b") != ten || - json_object_get(object, "c") != ten || - json_object_get(object, "d") != ten || - json_object_get(object, "e") != ten) - fail("update works incorrectly"); - - - /* update a nonempty object with a nonempty object with both old - and new keys */ - - if(json_object_clear(other)) - fail("clear failed"); - - if(json_object_set(other, "a", nine) || - json_object_set(other, "b", nine) || - json_object_set(other, "f", nine) || - json_object_set(other, "g", nine) || - json_object_set(other, "h", nine)) - fail("unable to set value"); - - if(json_object_update(object, other)) - fail("unable to update a nonempty object"); - - if(json_object_size(object) != 8) - fail("invalid size after update"); - - if(json_object_get(object, "a") != nine || - json_object_get(object, "b") != nine || - json_object_get(object, "f") != nine || - json_object_get(object, "g") != nine || - json_object_get(object, "h") != nine) - fail("update works incorrectly"); - - json_decref(nine); - json_decref(ten); - json_decref(other); - json_decref(object); -} - -static void test_conditional_updates() -{ - json_t *object, *other; - - object = json_pack("{sisi}", "foo", 1, "bar", 2); - other = json_pack("{sisi}", "foo", 3, "baz", 4); - - if(json_object_update_existing(object, other)) - fail("json_object_update_existing failed"); - - if(json_object_size(object) != 2) - fail("json_object_update_existing added new items"); - - if(json_integer_value(json_object_get(object, "foo")) != 3) - fail("json_object_update_existing failed to update existing key"); - - if(json_integer_value(json_object_get(object, "bar")) != 2) - fail("json_object_update_existing updated wrong key"); - - json_decref(object); - - object = json_pack("{sisi}", "foo", 1, "bar", 2); - - if(json_object_update_missing(object, other)) - fail("json_object_update_missing failed"); - - if(json_object_size(object) != 3) - fail("json_object_update_missing didn't add new items"); - - if(json_integer_value(json_object_get(object, "foo")) != 1) - fail("json_object_update_missing updated existing key"); - - if(json_integer_value(json_object_get(object, "bar")) != 2) - fail("json_object_update_missing updated wrong key"); - - if(json_integer_value(json_object_get(object, "baz")) != 4) - fail("json_object_update_missing didn't add new items"); - - json_decref(object); - json_decref(other); -} - -static void test_circular() -{ - json_t *object1, *object2; - - object1 = json_object(); - object2 = json_object(); - if(!object1 || !object2) - fail("unable to create object"); - - /* the simple case is checked */ - if(json_object_set(object1, "a", object1) == 0) - fail("able to set self"); - - /* create circular references */ - if(json_object_set(object1, "a", object2) || - json_object_set(object2, "a", object1)) - fail("unable to set value"); - - /* circularity is detected when dumping */ - if(json_dumps(object1, 0) != NULL) - fail("able to dump circulars"); - - /* decref twice to deal with the circular references */ - json_decref(object1); - json_decref(object2); - json_decref(object1); -} - -static void test_set_nocheck() -{ - json_t *object, *string; - - object = json_object(); - string = json_string("bar"); - - if(!object) - fail("unable to create object"); - if(!string) - fail("unable to create string"); - - if(json_object_set_nocheck(object, "foo", string)) - fail("json_object_set_nocheck failed"); - if(json_object_get(object, "foo") != string) - fail("json_object_get after json_object_set_nocheck failed"); - - /* invalid UTF-8 in key */ - if(json_object_set_nocheck(object, "a\xefz", string)) - fail("json_object_set_nocheck failed for invalid UTF-8"); - if(json_object_get(object, "a\xefz") != string) - fail("json_object_get after json_object_set_nocheck failed"); - - if(json_object_set_new_nocheck(object, "bax", json_integer(123))) - fail("json_object_set_new_nocheck failed"); - if(json_integer_value(json_object_get(object, "bax")) != 123) - fail("json_object_get after json_object_set_new_nocheck failed"); - - /* invalid UTF-8 in key */ - if(json_object_set_new_nocheck(object, "asdf\xfe", json_integer(321))) - fail("json_object_set_new_nocheck failed for invalid UTF-8"); - if(json_integer_value(json_object_get(object, "asdf\xfe")) != 321) - fail("json_object_get after json_object_set_new_nocheck failed"); - - json_decref(string); - json_decref(object); -} - -static void test_iterators() -{ - json_t *object, *foo, *bar, *baz; - void *iter; - - if(json_object_iter(NULL)) - fail("able to iterate over NULL"); - - if(json_object_iter_next(NULL, NULL)) - fail("able to increment an iterator on a NULL object"); - - object = json_object(); - foo = json_string("foo"); - bar = json_string("bar"); - baz = json_string("baz"); - if(!object || !foo || !bar || !bar) - fail("unable to create values"); - - if(json_object_iter_next(object, NULL)) - fail("able to increment a NULL iterator"); - - if(json_object_set(object, "a", foo) || - json_object_set(object, "b", bar) || - json_object_set(object, "c", baz)) - fail("unable to populate object"); - - iter = json_object_iter(object); - if(!iter) - fail("unable to get iterator"); - if(strcmp(json_object_iter_key(iter), "a")) - fail("iterating failed: wrong key"); - if(json_object_iter_value(iter) != foo) - fail("iterating failed: wrong value"); - - iter = json_object_iter_next(object, iter); - if(!iter) - fail("unable to increment iterator"); - if(strcmp(json_object_iter_key(iter), "b")) - fail("iterating failed: wrong key"); - if(json_object_iter_value(iter) != bar) - fail("iterating failed: wrong value"); - - iter = json_object_iter_next(object, iter); - if(!iter) - fail("unable to increment iterator"); - if(strcmp(json_object_iter_key(iter), "c")) - fail("iterating failed: wrong key"); - if(json_object_iter_value(iter) != baz) - fail("iterating failed: wrong value"); - - if(json_object_iter_next(object, iter) != NULL) - fail("able to iterate over the end"); - - if(json_object_iter_at(object, "foo")) - fail("json_object_iter_at() succeeds for non-existent key"); - - iter = json_object_iter_at(object, "b"); - if(!iter) - fail("json_object_iter_at() fails for an existing key"); - - if(strcmp(json_object_iter_key(iter), "b")) - fail("iterating failed: wrong key"); - if(json_object_iter_value(iter) != bar) - fail("iterating failed: wrong value"); - - iter = json_object_iter_next(object, iter); - if(!iter) - fail("unable to increment iterator"); - if(strcmp(json_object_iter_key(iter), "c")) - fail("iterating failed: wrong key"); - if(json_object_iter_value(iter) != baz) - fail("iterating failed: wrong value"); - - if(json_object_iter_set(object, iter, bar)) - fail("unable to set value at iterator"); - - if(strcmp(json_object_iter_key(iter), "c")) - fail("json_object_iter_key() fails after json_object_iter_set()"); - if(json_object_iter_value(iter) != bar) - fail("json_object_iter_value() fails after json_object_iter_set()"); - if(json_object_get(object, "c") != bar) - fail("json_object_get() fails after json_object_iter_set()"); - - json_decref(object); - json_decref(foo); - json_decref(bar); - json_decref(baz); -} - -static void test_misc() -{ - json_t *object, *string, *other_string, *value; - - object = json_object(); - string = json_string("test"); - other_string = json_string("other"); - - if(!object) - fail("unable to create object"); - if(!string || !other_string) - fail("unable to create string"); - - if(json_object_get(object, "a")) - fail("value for nonexisting key"); - - if(json_object_set(object, "a", string)) - fail("unable to set value"); - - if(!json_object_set(object, NULL, string)) - fail("able to set NULL key"); - - if(!json_object_set(object, "a", NULL)) - fail("able to set NULL value"); - - /* invalid UTF-8 in key */ - if(!json_object_set(object, "a\xefz", string)) - fail("able to set invalid unicode key"); - - value = json_object_get(object, "a"); - if(!value) - fail("no value for existing key"); - if(value != string) - fail("got different value than what was added"); - - /* "a", "lp" and "px" collide in a five-bucket hashtable */ - if(json_object_set(object, "b", string) || - json_object_set(object, "lp", string) || - json_object_set(object, "px", string)) - fail("unable to set value"); - - value = json_object_get(object, "a"); - if(!value) - fail("no value for existing key"); - if(value != string) - fail("got different value than what was added"); - - if(json_object_set(object, "a", other_string)) - fail("unable to replace an existing key"); - - value = json_object_get(object, "a"); - if(!value) - fail("no value for existing key"); - if(value != other_string) - fail("got different value than what was set"); - - if(!json_object_del(object, "nonexisting")) - fail("able to delete a nonexisting key"); - - if(json_object_del(object, "px")) - fail("unable to delete an existing key"); - - if(json_object_del(object, "a")) - fail("unable to delete an existing key"); - - if(json_object_del(object, "lp")) - fail("unable to delete an existing key"); - - - /* add many keys to initiate rehashing */ - - if(json_object_set(object, "a", string)) - fail("unable to set value"); - - if(json_object_set(object, "lp", string)) - fail("unable to set value"); - - if(json_object_set(object, "px", string)) - fail("unable to set value"); - - if(json_object_set(object, "c", string)) - fail("unable to set value"); - - if(json_object_set(object, "d", string)) - fail("unable to set value"); - - if(json_object_set(object, "e", string)) - fail("unable to set value"); - - - if(json_object_set_new(object, "foo", json_integer(123))) - fail("unable to set new value"); - - value = json_object_get(object, "foo"); - if(!json_is_integer(value) || json_integer_value(value) != 123) - fail("json_object_set_new works incorrectly"); - - if(!json_object_set_new(object, NULL, json_integer(432))) - fail("able to set_new NULL key"); - - if(!json_object_set_new(object, "foo", NULL)) - fail("able to set_new NULL value"); - - json_decref(string); - json_decref(other_string); - json_decref(object); -} - -static void test_preserve_order() -{ - json_t *object; - char *result; - - const char *expected = "{\"foobar\": 1, \"bazquux\": 6, \"lorem ipsum\": 3, \"sit amet\": 5, \"helicopter\": 7}"; - - object = json_object(); - - json_object_set_new(object, "foobar", json_integer(1)); - json_object_set_new(object, "bazquux", json_integer(2)); - json_object_set_new(object, "lorem ipsum", json_integer(3)); - json_object_set_new(object, "dolor", json_integer(4)); - json_object_set_new(object, "sit amet", json_integer(5)); - - /* changing a value should preserve the order */ - json_object_set_new(object, "bazquux", json_integer(6)); - - /* deletion shouldn't change the order of others */ - json_object_del(object, "dolor"); - - /* add a new item just to make sure */ - json_object_set_new(object, "helicopter", json_integer(7)); - - result = json_dumps(object, JSON_PRESERVE_ORDER); - - if(strcmp(expected, result) != 0) { - fprintf(stderr, "%s != %s", expected, result); - fail("JSON_PRESERVE_ORDER doesn't work"); - } - - free(result); - json_decref(object); -} - -static void test_object_foreach() -{ - const char *key; - json_t *object1, *object2, *value; - - object1 = json_pack("{sisisi}", "foo", 1, "bar", 2, "baz", 3); - object2 = json_object(); - - json_object_foreach(object1, key, value) - json_object_set(object2, key, value); - - if(!json_equal(object1, object2)) - fail("json_object_foreach failed to iterate all key-value pairs"); - - json_decref(object1); - json_decref(object2); -} - -static void run_tests() -{ - test_misc(); - test_clear(); - test_update(); - test_conditional_updates(); - test_circular(); - test_set_nocheck(); - test_iterators(); - test_preserve_order(); - test_object_foreach(); -} diff --git a/deps/jansson/test/suites/api/test_pack.c b/deps/jansson/test/suites/api/test_pack.c deleted file mode 100644 index 348d8b2..0000000 --- a/deps/jansson/test/suites/api/test_pack.c +++ /dev/null @@ -1,307 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * Copyright (c) 2010-2012 Graeme Smecher - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include -#include -#include "util.h" - -static void run_tests() -{ - json_t *value; - int i; - char buffer[4] = {'t', 'e', 's', 't'}; - json_error_t error; - - /* - * Simple, valid json_pack cases - */ - /* true */ - value = json_pack("b", 1); - if(!json_is_true(value)) - fail("json_pack boolean failed"); - if(value->refcount != (size_t)-1) - fail("json_pack boolean refcount failed"); - json_decref(value); - - /* false */ - value = json_pack("b", 0); - if(!json_is_false(value)) - fail("json_pack boolean failed"); - if(value->refcount != (size_t)-1) - fail("json_pack boolean refcount failed"); - json_decref(value); - - /* null */ - value = json_pack("n"); - if(!json_is_null(value)) - fail("json_pack null failed"); - if(value->refcount != (size_t)-1) - fail("json_pack null refcount failed"); - json_decref(value); - - /* integer */ - value = json_pack("i", 1); - if(!json_is_integer(value) || json_integer_value(value) != 1) - fail("json_pack integer failed"); - if(value->refcount != (size_t)1) - fail("json_pack integer refcount failed"); - json_decref(value); - - /* integer from json_int_t */ - value = json_pack("I", (json_int_t)555555); - if(!json_is_integer(value) || json_integer_value(value) != 555555) - fail("json_pack json_int_t failed"); - if(value->refcount != (size_t)1) - fail("json_pack integer refcount failed"); - json_decref(value); - - /* real */ - value = json_pack("f", 1.0); - if(!json_is_real(value) || json_real_value(value) != 1.0) - fail("json_pack real failed"); - if(value->refcount != (size_t)1) - fail("json_pack real refcount failed"); - json_decref(value); - - /* string */ - value = json_pack("s", "test"); - if(!json_is_string(value) || strcmp("test", json_string_value(value))) - fail("json_pack string failed"); - if(value->refcount != (size_t)1) - fail("json_pack string refcount failed"); - json_decref(value); - - /* string and length (int) */ - value = json_pack("s#", "test asdf", 4); - if(!json_is_string(value) || strcmp("test", json_string_value(value))) - fail("json_pack string and length failed"); - if(value->refcount != (size_t)1) - fail("json_pack string and length refcount failed"); - json_decref(value); - - /* string and length (size_t) */ - value = json_pack("s%", "test asdf", (size_t)4); - if(!json_is_string(value) || strcmp("test", json_string_value(value))) - fail("json_pack string and length failed"); - if(value->refcount != (size_t)1) - fail("json_pack string and length refcount failed"); - json_decref(value); - - /* string and length (int), non-NUL terminated string */ - value = json_pack("s#", buffer, 4); - if(!json_is_string(value) || strcmp("test", json_string_value(value))) - fail("json_pack string and length (int) failed"); - if(value->refcount != (size_t)1) - fail("json_pack string and length (int) refcount failed"); - json_decref(value); - - /* string and length (size_t), non-NUL terminated string */ - value = json_pack("s%", buffer, (size_t)4); - if(!json_is_string(value) || strcmp("test", json_string_value(value))) - fail("json_pack string and length (size_t) failed"); - if(value->refcount != (size_t)1) - fail("json_pack string and length (size_t) refcount failed"); - json_decref(value); - - /* string concatenation */ - value = json_pack("s++", "te", "st", "ing"); - if(!json_is_string(value) || strcmp("testing", json_string_value(value))) - fail("json_pack string concatenation failed"); - if(value->refcount != (size_t)1) - fail("json_pack string concatenation refcount failed"); - json_decref(value); - - /* string concatenation and length (int) */ - value = json_pack("s#+#+", "test", 1, "test", 2, "test"); - if(!json_is_string(value) || strcmp("ttetest", json_string_value(value))) - fail("json_pack string concatenation and length (int) failed"); - if(value->refcount != (size_t)1) - fail("json_pack string concatenation and length (int) refcount failed"); - json_decref(value); - - /* string concatenation and length (size_t) */ - value = json_pack("s%+%+", "test", (size_t)1, "test", (size_t)2, "test"); - if(!json_is_string(value) || strcmp("ttetest", json_string_value(value))) - fail("json_pack string concatenation and length (size_t) failed"); - if(value->refcount != (size_t)1) - fail("json_pack string concatenation and length (size_t) refcount failed"); - json_decref(value); - - /* empty object */ - value = json_pack("{}", 1.0); - if(!json_is_object(value) || json_object_size(value) != 0) - fail("json_pack empty object failed"); - if(value->refcount != (size_t)1) - fail("json_pack empty object refcount failed"); - json_decref(value); - - /* empty list */ - value = json_pack("[]", 1.0); - if(!json_is_array(value) || json_array_size(value) != 0) - fail("json_pack empty list failed"); - if(value->refcount != (size_t)1) - fail("json_pack empty list failed"); - json_decref(value); - - /* non-incref'd object */ - value = json_pack("o", json_integer(1)); - if(!json_is_integer(value) || json_integer_value(value) != 1) - fail("json_pack object failed"); - if(value->refcount != (size_t)1) - fail("json_pack integer refcount failed"); - json_decref(value); - - /* incref'd object */ - value = json_pack("O", json_integer(1)); - if(!json_is_integer(value) || json_integer_value(value) != 1) - fail("json_pack object failed"); - if(value->refcount != (size_t)2) - fail("json_pack integer refcount failed"); - json_decref(value); - json_decref(value); - - /* simple object */ - value = json_pack("{s:[]}", "foo"); - if(!json_is_object(value) || json_object_size(value) != 1) - fail("json_pack array failed"); - if(!json_is_array(json_object_get(value, "foo"))) - fail("json_pack array failed"); - if(json_object_get(value, "foo")->refcount != (size_t)1) - fail("json_pack object refcount failed"); - json_decref(value); - - /* object with complex key */ - value = json_pack("{s+#+: []}", "foo", "barbar", 3, "baz"); - if(!json_is_object(value) || json_object_size(value) != 1) - fail("json_pack array failed"); - if(!json_is_array(json_object_get(value, "foobarbaz"))) - fail("json_pack array failed"); - if(json_object_get(value, "foobarbaz")->refcount != (size_t)1) - fail("json_pack object refcount failed"); - json_decref(value); - - /* simple array */ - value = json_pack("[i,i,i]", 0, 1, 2); - if(!json_is_array(value) || json_array_size(value) != 3) - fail("json_pack object failed"); - for(i=0; i<3; i++) - { - if(!json_is_integer(json_array_get(value, i)) || - json_integer_value(json_array_get(value, i)) != i) - - fail("json_pack integer array failed"); - } - json_decref(value); - - /* Whitespace; regular string */ - value = json_pack(" s ", "test"); - if(!json_is_string(value) || strcmp("test", json_string_value(value))) - fail("json_pack string (with whitespace) failed"); - json_decref(value); - - /* Whitespace; empty array */ - value = json_pack("[ ]"); - if(!json_is_array(value) || json_array_size(value) != 0) - fail("json_pack empty array (with whitespace) failed"); - json_decref(value); - - /* Whitespace; array */ - value = json_pack("[ i , i, i ] ", 1, 2, 3); - if(!json_is_array(value) || json_array_size(value) != 3) - fail("json_pack array (with whitespace) failed"); - json_decref(value); - - /* - * Invalid cases - */ - - /* newline in format string */ - if(json_pack_ex(&error, 0, "{\n\n1")) - fail("json_pack failed to catch invalid format '1'"); - check_error("Expected format 's', got '1'", "", 3, 1, 4); - - /* mismatched open/close array/object */ - if(json_pack_ex(&error, 0, "[}")) - fail("json_pack failed to catch mismatched '}'"); - check_error("Unexpected format character '}'", "", 1, 2, 2); - - if(json_pack_ex(&error, 0, "{]")) - fail("json_pack failed to catch mismatched ']'"); - check_error("Expected format 's', got ']'", "", 1, 2, 2); - - /* missing close array */ - if(json_pack_ex(&error, 0, "[")) - fail("json_pack failed to catch missing ']'"); - check_error("Unexpected end of format string", "", 1, 2, 2); - - /* missing close object */ - if(json_pack_ex(&error, 0, "{")) - fail("json_pack failed to catch missing '}'"); - check_error("Unexpected end of format string", "", 1, 2, 2); - - /* garbage after format string */ - if(json_pack_ex(&error, 0, "[i]a", 42)) - fail("json_pack failed to catch garbage after format string"); - check_error("Garbage after format string", "", 1, 4, 4); - - if(json_pack_ex(&error, 0, "ia", 42)) - fail("json_pack failed to catch garbage after format string"); - check_error("Garbage after format string", "", 1, 2, 2); - - /* NULL string */ - if(json_pack_ex(&error, 0, "s", NULL)) - fail("json_pack failed to catch null argument string"); - check_error("NULL string argument", "", 1, 1, 1); - - /* + on its own */ - if(json_pack_ex(&error, 0, "+", NULL)) - fail("json_pack failed to a lone +"); - check_error("Unexpected format character '+'", "", 1, 1, 1); - - /* NULL format */ - if(json_pack_ex(&error, 0, NULL)) - fail("json_pack failed to catch NULL format string"); - check_error("NULL or empty format string", "", -1, -1, 0); - - /* NULL key */ - if(json_pack_ex(&error, 0, "{s:i}", NULL, 1)) - fail("json_pack failed to catch NULL key"); - check_error("NULL string argument", "", 1, 2, 2); - - /* More complicated checks for row/columns */ - if(json_pack_ex(&error, 0, "{ {}: s }", "foo")) - fail("json_pack failed to catch object as key"); - check_error("Expected format 's', got '{'", "", 1, 3, 3); - - /* Complex object */ - if(json_pack_ex(&error, 0, "{ s: {}, s:[ii{} }", "foo", "bar", 12, 13)) - fail("json_pack failed to catch missing ]"); - check_error("Unexpected format character '}'", "", 1, 19, 19); - - /* Complex array */ - if(json_pack_ex(&error, 0, "[[[[[ [[[[[ [[[[ }]]]] ]]]] ]]]]]")) - fail("json_pack failed to catch extra }"); - check_error("Unexpected format character '}'", "", 1, 21, 21); - - /* Invalid UTF-8 in object key */ - if(json_pack_ex(&error, 0, "{s:i}", "\xff\xff", 42)) - fail("json_pack failed to catch invalid UTF-8 in an object key"); - check_error("Invalid UTF-8 object key", "", 1, 2, 2); - - /* Invalid UTF-8 in a string */ - if(json_pack_ex(&error, 0, "{s:s}", "foo", "\xff\xff")) - fail("json_pack failed to catch invalid UTF-8 in a string"); - check_error("Invalid UTF-8 string", "", 1, 4, 4); -} diff --git a/deps/jansson/test/suites/api/test_simple.c b/deps/jansson/test/suites/api/test_simple.c deleted file mode 100644 index 7eed591..0000000 --- a/deps/jansson/test/suites/api/test_simple.c +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#include -#include -#include "util.h" - -/* Call the simple functions not covered by other tests of the public API */ -static void run_tests() -{ - json_t *value; - - value = json_boolean(1); - if(!json_is_true(value)) - fail("json_boolean(1) failed"); - json_decref(value); - - value = json_boolean(-123); - if(!json_is_true(value)) - fail("json_boolean(-123) failed"); - json_decref(value); - - value = json_boolean(0); - if(!json_is_false(value)) - fail("json_boolean(0) failed"); - if(json_boolean_value(value) != 0) - fail("json_boolean_value failed"); - json_decref(value); - - - value = json_integer(1); - if(json_typeof(value) != JSON_INTEGER) - fail("json_typeof failed"); - - if(json_is_object(value)) - fail("json_is_object failed"); - - if(json_is_array(value)) - fail("json_is_array failed"); - - if(json_is_string(value)) - fail("json_is_string failed"); - - if(!json_is_integer(value)) - fail("json_is_integer failed"); - - if(json_is_real(value)) - fail("json_is_real failed"); - - if(!json_is_number(value)) - fail("json_is_number failed"); - - if(json_is_true(value)) - fail("json_is_true failed"); - - if(json_is_false(value)) - fail("json_is_false failed"); - - if(json_is_boolean(value)) - fail("json_is_boolean failed"); - - if(json_is_null(value)) - fail("json_is_null failed"); - - json_decref(value); - - - value = json_string("foo"); - if(!value) - fail("json_string failed"); - if(strcmp(json_string_value(value), "foo")) - fail("invalid string value"); - if (json_string_length(value) != 3) - fail("invalid string length"); - - if(json_string_set(value, "barr")) - fail("json_string_set failed"); - if(strcmp(json_string_value(value), "barr")) - fail("invalid string value"); - if (json_string_length(value) != 4) - fail("invalid string length"); - - if(json_string_setn(value, "hi\0ho", 5)) - fail("json_string_set failed"); - if(memcmp(json_string_value(value), "hi\0ho\0", 6)) - fail("invalid string value"); - if (json_string_length(value) != 5) - fail("invalid string length"); - - json_decref(value); - - value = json_string(NULL); - if(value) - fail("json_string(NULL) failed"); - - /* invalid UTF-8 */ - value = json_string("a\xefz"); - if(value) - fail("json_string() failed"); - - value = json_string_nocheck("foo"); - if(!value) - fail("json_string_nocheck failed"); - if(strcmp(json_string_value(value), "foo")) - fail("invalid string value"); - if (json_string_length(value) != 3) - fail("invalid string length"); - - if(json_string_set_nocheck(value, "barr")) - fail("json_string_set_nocheck failed"); - if(strcmp(json_string_value(value), "barr")) - fail("invalid string value"); - if (json_string_length(value) != 4) - fail("invalid string length"); - - if(json_string_setn_nocheck(value, "hi\0ho", 5)) - fail("json_string_set failed"); - if(memcmp(json_string_value(value), "hi\0ho\0", 6)) - fail("invalid string value"); - if (json_string_length(value) != 5) - fail("invalid string length"); - - json_decref(value); - - /* invalid UTF-8 */ - value = json_string_nocheck("qu\xff"); - if(!value) - fail("json_string_nocheck failed"); - if(strcmp(json_string_value(value), "qu\xff")) - fail("invalid string value"); - if (json_string_length(value) != 3) - fail("invalid string length"); - - if(json_string_set_nocheck(value, "\xfd\xfe\xff")) - fail("json_string_set_nocheck failed"); - if(strcmp(json_string_value(value), "\xfd\xfe\xff")) - fail("invalid string value"); - if (json_string_length(value) != 3) - fail("invalid string length"); - - json_decref(value); - - - value = json_integer(123); - if(!value) - fail("json_integer failed"); - if(json_integer_value(value) != 123) - fail("invalid integer value"); - if(json_number_value(value) != 123.0) - fail("invalid number value"); - - if(json_integer_set(value, 321)) - fail("json_integer_set failed"); - if(json_integer_value(value) != 321) - fail("invalid integer value"); - if(json_number_value(value) != 321.0) - fail("invalid number value"); - - json_decref(value); - - value = json_real(123.123); - if(!value) - fail("json_real failed"); - if(json_real_value(value) != 123.123) - fail("invalid integer value"); - if(json_number_value(value) != 123.123) - fail("invalid number value"); - - if(json_real_set(value, 321.321)) - fail("json_real_set failed"); - if(json_real_value(value) != 321.321) - fail("invalid real value"); - if(json_number_value(value) != 321.321) - fail("invalid number value"); - - json_decref(value); - - value = json_true(); - if(!value) - fail("json_true failed"); - json_decref(value); - - value = json_false(); - if(!value) - fail("json_false failed"); - json_decref(value); - - value = json_null(); - if(!value) - fail("json_null failed"); - json_decref(value); - - /* Test reference counting on singletons (true, false, null) */ - value = json_true(); - if(value->refcount != (size_t)-1) - fail("refcounting true works incorrectly"); - json_decref(value); - if(value->refcount != (size_t)-1) - fail("refcounting true works incorrectly"); - json_incref(value); - if(value->refcount != (size_t)-1) - fail("refcounting true works incorrectly"); - - value = json_false(); - if(value->refcount != (size_t)-1) - fail("refcounting false works incorrectly"); - json_decref(value); - if(value->refcount != (size_t)-1) - fail("refcounting false works incorrectly"); - json_incref(value); - if(value->refcount != (size_t)-1) - fail("refcounting false works incorrectly"); - - value = json_null(); - if(value->refcount != (size_t)-1) - fail("refcounting null works incorrectly"); - json_decref(value); - if(value->refcount != (size_t)-1) - fail("refcounting null works incorrectly"); - json_incref(value); - if(value->refcount != (size_t)-1) - fail("refcounting null works incorrectly"); -} diff --git a/deps/jansson/test/suites/api/test_unpack.c b/deps/jansson/test/suites/api/test_unpack.c deleted file mode 100644 index 7f049dd..0000000 --- a/deps/jansson/test/suites/api/test_unpack.c +++ /dev/null @@ -1,381 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * Copyright (c) 2010-2012 Graeme Smecher - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#include -#include -#include -#include "util.h" - -static void run_tests() -{ - json_t *j, *j2; - int i1, i2, i3; - json_int_t I1; - int rv; - size_t z; - double f; - char *s; - - json_error_t error; - - /* - * Simple, valid json_pack cases - */ - - /* true */ - rv = json_unpack(json_true(), "b", &i1); - if(rv || !i1) - fail("json_unpack boolean failed"); - - /* false */ - rv = json_unpack(json_false(), "b", &i1); - if(rv || i1) - fail("json_unpack boolean failed"); - - /* null */ - if(json_unpack(json_null(), "n")) - fail("json_unpack null failed"); - - /* integer */ - j = json_integer(42); - rv = json_unpack(j, "i", &i1); - if(rv || i1 != 42) - fail("json_unpack integer failed"); - json_decref(j); - - /* json_int_t */ - j = json_integer(5555555); - rv = json_unpack(j, "I", &I1); - if(rv || I1 != 5555555) - fail("json_unpack json_int_t failed"); - json_decref(j); - - /* real */ - j = json_real(1.7); - rv = json_unpack(j, "f", &f); - if(rv || f != 1.7) - fail("json_unpack real failed"); - json_decref(j); - - /* number */ - j = json_integer(12345); - rv = json_unpack(j, "F", &f); - if(rv || f != 12345.0) - fail("json_unpack (real or) integer failed"); - json_decref(j); - - j = json_real(1.7); - rv = json_unpack(j, "F", &f); - if(rv || f != 1.7) - fail("json_unpack real (or integer) failed"); - json_decref(j); - - /* string */ - j = json_string("foo"); - rv = json_unpack(j, "s", &s); - if(rv || strcmp(s, "foo")) - fail("json_unpack string failed"); - json_decref(j); - - /* string with length (size_t) */ - j = json_string("foo"); - rv = json_unpack(j, "s%", &s, &z); - if(rv || strcmp(s, "foo") || z != 3) - fail("json_unpack string with length (size_t) failed"); - json_decref(j); - - /* empty object */ - j = json_object(); - if(json_unpack(j, "{}")) - fail("json_unpack empty object failed"); - json_decref(j); - - /* empty list */ - j = json_array(); - if(json_unpack(j, "[]")) - fail("json_unpack empty list failed"); - json_decref(j); - - /* non-incref'd object */ - j = json_object(); - rv = json_unpack(j, "o", &j2); - if(rv || j2 != j || j->refcount != 1) - fail("json_unpack object failed"); - json_decref(j); - - /* incref'd object */ - j = json_object(); - rv = json_unpack(j, "O", &j2); - if(rv || j2 != j || j->refcount != 2) - fail("json_unpack object failed"); - json_decref(j); - json_decref(j); - - /* simple object */ - j = json_pack("{s:i}", "foo", 42); - rv = json_unpack(j, "{s:i}", "foo", &i1); - if(rv || i1 != 42) - fail("json_unpack simple object failed"); - json_decref(j); - - /* simple array */ - j = json_pack("[iii]", 1, 2, 3); - rv = json_unpack(j, "[i,i,i]", &i1, &i2, &i3); - if(rv || i1 != 1 || i2 != 2 || i3 != 3) - fail("json_unpack simple array failed"); - json_decref(j); - - /* object with many items & strict checking */ - j = json_pack("{s:i, s:i, s:i}", "a", 1, "b", 2, "c", 3); - rv = json_unpack(j, "{s:i, s:i, s:i}", "a", &i1, "b", &i2, "c", &i3); - if(rv || i1 != 1 || i2 != 2 || i3 != 3) - fail("json_unpack object with many items failed"); - json_decref(j); - - /* - * Invalid cases - */ - - j = json_integer(42); - if(!json_unpack_ex(j, &error, 0, "z")) - fail("json_unpack succeeded with invalid format character"); - check_error("Unexpected format character 'z'", "", 1, 1, 1); - - if(!json_unpack_ex(NULL, &error, 0, "[i]")) - fail("json_unpack succeeded with NULL root"); - check_error("NULL root value", "", -1, -1, 0); - json_decref(j); - - /* mismatched open/close array/object */ - j = json_pack("[]"); - if(!json_unpack_ex(j, &error, 0, "[}")) - fail("json_unpack failed to catch mismatched ']'"); - check_error("Unexpected format character '}'", "", 1, 2, 2); - json_decref(j); - - j = json_pack("{}"); - if(!json_unpack_ex(j, &error, 0, "{]")) - fail("json_unpack failed to catch mismatched '}'"); - check_error("Expected format 's', got ']'", "", 1, 2, 2); - json_decref(j); - - /* missing close array */ - j = json_pack("[]"); - if(!json_unpack_ex(j, &error, 0, "[")) - fail("json_unpack failed to catch missing ']'"); - check_error("Unexpected end of format string", "", 1, 2, 2); - json_decref(j); - - /* missing close object */ - j = json_pack("{}"); - if(!json_unpack_ex(j, &error, 0, "{")) - fail("json_unpack failed to catch missing '}'"); - check_error("Unexpected end of format string", "", 1, 2, 2); - json_decref(j); - - /* garbage after format string */ - j = json_pack("[i]", 42); - if(!json_unpack_ex(j, &error, 0, "[i]a", &i1)) - fail("json_unpack failed to catch garbage after format string"); - check_error("Garbage after format string", "", 1, 4, 4); - json_decref(j); - - j = json_integer(12345); - if(!json_unpack_ex(j, &error, 0, "ia", &i1)) - fail("json_unpack failed to catch garbage after format string"); - check_error("Garbage after format string", "", 1, 2, 2); - json_decref(j); - - /* NULL format string */ - j = json_pack("[]"); - if(!json_unpack_ex(j, &error, 0, NULL)) - fail("json_unpack failed to catch null format string"); - check_error("NULL or empty format string", "", -1, -1, 0); - json_decref(j); - - /* NULL string pointer */ - j = json_string("foobie"); - if(!json_unpack_ex(j, &error, 0, "s", NULL)) - fail("json_unpack failed to catch null string pointer"); - check_error("NULL string argument", "", 1, 1, 1); - json_decref(j); - - /* invalid types */ - j = json_integer(42); - j2 = json_string("foo"); - if(!json_unpack_ex(j, &error, 0, "s")) - fail("json_unpack failed to catch invalid type"); - check_error("Expected string, got integer", "", 1, 1, 1); - - if(!json_unpack_ex(j, &error, 0, "n")) - fail("json_unpack failed to catch invalid type"); - check_error("Expected null, got integer", "", 1, 1, 1); - - if(!json_unpack_ex(j, &error, 0, "b")) - fail("json_unpack failed to catch invalid type"); - check_error("Expected true or false, got integer", "", 1, 1, 1); - - if(!json_unpack_ex(j2, &error, 0, "i")) - fail("json_unpack failed to catch invalid type"); - check_error("Expected integer, got string", "", 1, 1, 1); - - if(!json_unpack_ex(j2, &error, 0, "I")) - fail("json_unpack failed to catch invalid type"); - check_error("Expected integer, got string", "", 1, 1, 1); - - if(!json_unpack_ex(j, &error, 0, "f")) - fail("json_unpack failed to catch invalid type"); - check_error("Expected real, got integer", "", 1, 1, 1); - - if(!json_unpack_ex(j2, &error, 0, "F")) - fail("json_unpack failed to catch invalid type"); - check_error("Expected real or integer, got string", "", 1, 1, 1); - - if(!json_unpack_ex(j, &error, 0, "[i]")) - fail("json_unpack failed to catch invalid type"); - check_error("Expected array, got integer", "", 1, 1, 1); - - if(!json_unpack_ex(j, &error, 0, "{si}", "foo")) - fail("json_unpack failed to catch invalid type"); - check_error("Expected object, got integer", "", 1, 1, 1); - - json_decref(j); - json_decref(j2); - - /* Array index out of range */ - j = json_pack("[i]", 1); - if(!json_unpack_ex(j, &error, 0, "[ii]", &i1, &i2)) - fail("json_unpack failed to catch index out of array bounds"); - check_error("Array index 1 out of range", "", 1, 3, 3); - json_decref(j); - - /* NULL object key */ - j = json_pack("{si}", "foo", 42); - if(!json_unpack_ex(j, &error, 0, "{si}", NULL, &i1)) - fail("json_unpack failed to catch null string pointer"); - check_error("NULL object key", "", 1, 2, 2); - json_decref(j); - - /* Object key not found */ - j = json_pack("{si}", "foo", 42); - if(!json_unpack_ex(j, &error, 0, "{si}", "baz", &i1)) - fail("json_unpack failed to catch null string pointer"); - check_error("Object item not found: baz", "", 1, 3, 3); - json_decref(j); - - /* - * Strict validation - */ - - j = json_pack("[iii]", 1, 2, 3); - rv = json_unpack(j, "[iii!]", &i1, &i2, &i3); - if(rv || i1 != 1 || i2 != 2 || i3 != 3) - fail("json_unpack array with strict validation failed"); - json_decref(j); - - j = json_pack("[iii]", 1, 2, 3); - if(!json_unpack_ex(j, &error, 0, "[ii!]", &i1, &i2)) - fail("json_unpack array with strict validation failed"); - check_error("1 array item(s) left unpacked", "", 1, 5, 5); - json_decref(j); - - /* Like above, but with JSON_STRICT instead of '!' format */ - j = json_pack("[iii]", 1, 2, 3); - if(!json_unpack_ex(j, &error, JSON_STRICT, "[ii]", &i1, &i2)) - fail("json_unpack array with strict validation failed"); - check_error("1 array item(s) left unpacked", "", 1, 4, 4); - json_decref(j); - - j = json_pack("{s:s, s:i}", "foo", "bar", "baz", 42); - rv = json_unpack(j, "{sssi!}", "foo", &s, "baz", &i1); - if(rv || strcmp(s, "bar") != 0 || i1 != 42) - fail("json_unpack object with strict validation failed"); - json_decref(j); - - /* Unpack the same item twice */ - j = json_pack("{s:s, s:i}", "foo", "bar", "baz", 42); - if(!json_unpack_ex(j, &error, 0, "{s:s,s:s!}", "foo", &s, "foo", &s)) - fail("json_unpack object with strict validation failed"); - check_error("1 object item(s) left unpacked", "", 1, 10, 10); - json_decref(j); - - j = json_pack("[i,{s:i,s:n},[i,i]]", 1, "foo", 2, "bar", 3, 4); - if(json_unpack_ex(j, NULL, JSON_STRICT | JSON_VALIDATE_ONLY, - "[i{sisn}[ii]]", "foo", "bar")) - fail("json_unpack complex value with strict validation failed"); - json_decref(j); - - /* ! and * must be last */ - j = json_pack("[ii]", 1, 2); - if(!json_unpack_ex(j, &error, 0, "[i!i]", &i1, &i2)) - fail("json_unpack failed to catch ! in the middle of an array"); - check_error("Expected ']' after '!', got 'i'", "", 1, 4, 4); - - if(!json_unpack_ex(j, &error, 0, "[i*i]", &i1, &i2)) - fail("json_unpack failed to catch * in the middle of an array"); - check_error("Expected ']' after '*', got 'i'", "", 1, 4, 4); - json_decref(j); - - j = json_pack("{sssi}", "foo", "bar", "baz", 42); - if(!json_unpack_ex(j, &error, 0, "{ss!si}", "foo", &s, "baz", &i1)) - fail("json_unpack failed to catch ! in the middle of an object"); - check_error("Expected '}' after '!', got 's'", "", 1, 5, 5); - - if(!json_unpack_ex(j, &error, 0, "{ss*si}", "foo", &s, "baz", &i1)) - fail("json_unpack failed to catch ! in the middle of an object"); - check_error("Expected '}' after '*', got 's'", "", 1, 5, 5); - json_decref(j); - - /* Error in nested object */ - j = json_pack("{s{snsn}}", "foo", "bar", "baz"); - if(!json_unpack_ex(j, &error, 0, "{s{sn!}}", "foo", "bar")) - fail("json_unpack nested object with strict validation failed"); - check_error("1 object item(s) left unpacked", "", 1, 7, 7); - json_decref(j); - - /* Error in nested array */ - j = json_pack("[[ii]]", 1, 2); - if(!json_unpack_ex(j, &error, 0, "[[i!]]", &i1)) - fail("json_unpack nested array with strict validation failed"); - check_error("1 array item(s) left unpacked", "", 1, 5, 5); - json_decref(j); - - /* Optional values */ - j = json_object(); - i1 = 0; - if(json_unpack(j, "{s?i}", "foo", &i1)) - fail("json_unpack failed for optional key"); - if(i1 != 0) - fail("json_unpack unpacked an optional key"); - json_decref(j); - - i1 = 0; - j = json_pack("{si}", "foo", 42); - if(json_unpack(j, "{s?i}", "foo", &i1)) - fail("json_unpack failed for an optional value"); - if(i1 != 42) - fail("json_unpack failed to unpack an optional value"); - json_decref(j); - - j = json_object(); - i1 = i2 = i3 = 0; - if(json_unpack(j, "{s?[ii]s?{s{si}}}", - "foo", &i1, &i2, - "bar", "baz", "quux", &i3)) - fail("json_unpack failed for complex optional values"); - if(i1 != 0 || i2 != 0 || i3 != 0) - fail("json_unpack unexpectedly unpacked something"); - json_decref(j); - - j = json_pack("{s{si}}", "foo", "bar", 42); - if(json_unpack(j, "{s?{s?i}}", "foo", "bar", &i1)) - fail("json_unpack failed for complex optional values"); - if(i1 != 42) - fail("json_unpack failed to unpack"); - json_decref(j); -} diff --git a/deps/jansson/test/suites/api/util.h b/deps/jansson/test/suites/api/util.h deleted file mode 100644 index b86a546..0000000 --- a/deps/jansson/test/suites/api/util.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2009-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - */ - -#ifndef UTIL_H -#define UTIL_H - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#if HAVE_LOCALE_H -#include -#endif - -#include - -#define failhdr fprintf(stderr, "%s:%s:%d: ", __FILE__, __FUNCTION__, __LINE__) - -#define fail(msg) \ - do { \ - failhdr; \ - fprintf(stderr, "%s\n", msg); \ - exit(1); \ - } while(0) - -/* Assumes json_error_t error */ -#define check_error(text_, source_, line_, column_, position_) \ - do { \ - if(strcmp(error.text, text_) != 0) { \ - failhdr; \ - fprintf(stderr, "text: \"%s\" != \"%s\"\n", error.text, text_); \ - exit(1); \ - } \ - if(strcmp(error.source, source_) != 0) { \ - failhdr; \ - \ - fprintf(stderr, "source: \"%s\" != \"%s\"\n", error.source, source_); \ - exit(1); \ - } \ - if(error.line != line_) { \ - failhdr; \ - fprintf(stderr, "line: %d != %d\n", error.line, line_); \ - exit(1); \ - } \ - if(error.column != column_) { \ - failhdr; \ - fprintf(stderr, "column: %d != %d\n", error.column, column_); \ - exit(1); \ - } \ - if(error.position != position_) { \ - failhdr; \ - fprintf(stderr, "position: %d != %d\n", error.position, position_); \ - exit(1); \ - } \ - } while(0) - - -static void run_tests(); - -int main() { -#ifdef HAVE_SETLOCALE - setlocale(LC_ALL, ""); -#endif - run_tests(); - return 0; -} - -#endif diff --git a/deps/jansson/test/suites/encoding-flags/array/input b/deps/jansson/test/suites/encoding-flags/array/input deleted file mode 100644 index 44e2ace..0000000 --- a/deps/jansson/test/suites/encoding-flags/array/input +++ /dev/null @@ -1 +0,0 @@ -[1, 2] diff --git a/deps/jansson/test/suites/encoding-flags/array/output b/deps/jansson/test/suites/encoding-flags/array/output deleted file mode 100644 index fd8ef09..0000000 --- a/deps/jansson/test/suites/encoding-flags/array/output +++ /dev/null @@ -1 +0,0 @@ -[1, 2] \ No newline at end of file diff --git a/deps/jansson/test/suites/encoding-flags/compact-array/env b/deps/jansson/test/suites/encoding-flags/compact-array/env deleted file mode 100644 index 4474aaf..0000000 --- a/deps/jansson/test/suites/encoding-flags/compact-array/env +++ /dev/null @@ -1,2 +0,0 @@ -JSON_COMPACT=1 -export JSON_COMPACT diff --git a/deps/jansson/test/suites/encoding-flags/compact-array/input b/deps/jansson/test/suites/encoding-flags/compact-array/input deleted file mode 100644 index 44e2ace..0000000 --- a/deps/jansson/test/suites/encoding-flags/compact-array/input +++ /dev/null @@ -1 +0,0 @@ -[1, 2] diff --git a/deps/jansson/test/suites/encoding-flags/compact-array/output b/deps/jansson/test/suites/encoding-flags/compact-array/output deleted file mode 100644 index 3169929..0000000 --- a/deps/jansson/test/suites/encoding-flags/compact-array/output +++ /dev/null @@ -1 +0,0 @@ -[1,2] \ No newline at end of file diff --git a/deps/jansson/test/suites/encoding-flags/compact-object/env b/deps/jansson/test/suites/encoding-flags/compact-object/env deleted file mode 100644 index 4474aaf..0000000 --- a/deps/jansson/test/suites/encoding-flags/compact-object/env +++ /dev/null @@ -1,2 +0,0 @@ -JSON_COMPACT=1 -export JSON_COMPACT diff --git a/deps/jansson/test/suites/encoding-flags/compact-object/input b/deps/jansson/test/suites/encoding-flags/compact-object/input deleted file mode 100644 index 062e54f..0000000 --- a/deps/jansson/test/suites/encoding-flags/compact-object/input +++ /dev/null @@ -1 +0,0 @@ -{"a": 1, "b": 2} diff --git a/deps/jansson/test/suites/encoding-flags/compact-object/output b/deps/jansson/test/suites/encoding-flags/compact-object/output deleted file mode 100644 index 73a5d70..0000000 --- a/deps/jansson/test/suites/encoding-flags/compact-object/output +++ /dev/null @@ -1 +0,0 @@ -{"a":1,"b":2} \ No newline at end of file diff --git a/deps/jansson/test/suites/encoding-flags/ensure-ascii/env b/deps/jansson/test/suites/encoding-flags/ensure-ascii/env deleted file mode 100644 index 1b7b3e3..0000000 --- a/deps/jansson/test/suites/encoding-flags/ensure-ascii/env +++ /dev/null @@ -1,2 +0,0 @@ -JSON_ENSURE_ASCII=1 -export JSON_ENSURE_ASCII diff --git a/deps/jansson/test/suites/encoding-flags/ensure-ascii/input b/deps/jansson/test/suites/encoding-flags/ensure-ascii/input deleted file mode 100644 index 69469ce..0000000 --- a/deps/jansson/test/suites/encoding-flags/ensure-ascii/input +++ /dev/null @@ -1,8 +0,0 @@ -[ - "foo", - "Ć„ Ƥ ƶ", - "foo ƄƤ", - "ƄƤ foo", - "Ć„ foo Ƥ", - "clef g: š„ž" -] diff --git a/deps/jansson/test/suites/encoding-flags/ensure-ascii/output b/deps/jansson/test/suites/encoding-flags/ensure-ascii/output deleted file mode 100644 index 94fa79d..0000000 --- a/deps/jansson/test/suites/encoding-flags/ensure-ascii/output +++ /dev/null @@ -1 +0,0 @@ -["foo", "\u00E5 \u00E4 \u00F6", "foo \u00E5\u00E4", "\u00E5\u00E4 foo", "\u00E5 foo \u00E4", "clef g: \uD834\uDD1E"] \ No newline at end of file diff --git a/deps/jansson/test/suites/encoding-flags/indent-array/env b/deps/jansson/test/suites/encoding-flags/indent-array/env deleted file mode 100644 index d220f83..0000000 --- a/deps/jansson/test/suites/encoding-flags/indent-array/env +++ /dev/null @@ -1,2 +0,0 @@ -JSON_INDENT=4 -export JSON_INDENT diff --git a/deps/jansson/test/suites/encoding-flags/indent-array/input b/deps/jansson/test/suites/encoding-flags/indent-array/input deleted file mode 100644 index 44e2ace..0000000 --- a/deps/jansson/test/suites/encoding-flags/indent-array/input +++ /dev/null @@ -1 +0,0 @@ -[1, 2] diff --git a/deps/jansson/test/suites/encoding-flags/indent-array/output b/deps/jansson/test/suites/encoding-flags/indent-array/output deleted file mode 100644 index c57d705..0000000 --- a/deps/jansson/test/suites/encoding-flags/indent-array/output +++ /dev/null @@ -1,4 +0,0 @@ -[ - 1, - 2 -] \ No newline at end of file diff --git a/deps/jansson/test/suites/encoding-flags/indent-compact-array/env b/deps/jansson/test/suites/encoding-flags/indent-compact-array/env deleted file mode 100644 index 78fbfcc..0000000 --- a/deps/jansson/test/suites/encoding-flags/indent-compact-array/env +++ /dev/null @@ -1,3 +0,0 @@ -JSON_INDENT=4 -JSON_COMPACT=1 -export JSON_INDENT JSON_COMPACT diff --git a/deps/jansson/test/suites/encoding-flags/indent-compact-array/input b/deps/jansson/test/suites/encoding-flags/indent-compact-array/input deleted file mode 100644 index 44e2ace..0000000 --- a/deps/jansson/test/suites/encoding-flags/indent-compact-array/input +++ /dev/null @@ -1 +0,0 @@ -[1, 2] diff --git a/deps/jansson/test/suites/encoding-flags/indent-compact-array/output b/deps/jansson/test/suites/encoding-flags/indent-compact-array/output deleted file mode 100644 index c57d705..0000000 --- a/deps/jansson/test/suites/encoding-flags/indent-compact-array/output +++ /dev/null @@ -1,4 +0,0 @@ -[ - 1, - 2 -] \ No newline at end of file diff --git a/deps/jansson/test/suites/encoding-flags/indent-compact-object/env b/deps/jansson/test/suites/encoding-flags/indent-compact-object/env deleted file mode 100644 index 78fbfcc..0000000 --- a/deps/jansson/test/suites/encoding-flags/indent-compact-object/env +++ /dev/null @@ -1,3 +0,0 @@ -JSON_INDENT=4 -JSON_COMPACT=1 -export JSON_INDENT JSON_COMPACT diff --git a/deps/jansson/test/suites/encoding-flags/indent-compact-object/input b/deps/jansson/test/suites/encoding-flags/indent-compact-object/input deleted file mode 100644 index 062e54f..0000000 --- a/deps/jansson/test/suites/encoding-flags/indent-compact-object/input +++ /dev/null @@ -1 +0,0 @@ -{"a": 1, "b": 2} diff --git a/deps/jansson/test/suites/encoding-flags/indent-compact-object/output b/deps/jansson/test/suites/encoding-flags/indent-compact-object/output deleted file mode 100644 index 9cc4294..0000000 --- a/deps/jansson/test/suites/encoding-flags/indent-compact-object/output +++ /dev/null @@ -1,4 +0,0 @@ -{ - "a":1, - "b":2 -} \ No newline at end of file diff --git a/deps/jansson/test/suites/encoding-flags/indent-object/env b/deps/jansson/test/suites/encoding-flags/indent-object/env deleted file mode 100644 index d220f83..0000000 --- a/deps/jansson/test/suites/encoding-flags/indent-object/env +++ /dev/null @@ -1,2 +0,0 @@ -JSON_INDENT=4 -export JSON_INDENT diff --git a/deps/jansson/test/suites/encoding-flags/indent-object/input b/deps/jansson/test/suites/encoding-flags/indent-object/input deleted file mode 100644 index 062e54f..0000000 --- a/deps/jansson/test/suites/encoding-flags/indent-object/input +++ /dev/null @@ -1 +0,0 @@ -{"a": 1, "b": 2} diff --git a/deps/jansson/test/suites/encoding-flags/indent-object/output b/deps/jansson/test/suites/encoding-flags/indent-object/output deleted file mode 100644 index 0fbddba..0000000 --- a/deps/jansson/test/suites/encoding-flags/indent-object/output +++ /dev/null @@ -1,4 +0,0 @@ -{ - "a": 1, - "b": 2 -} \ No newline at end of file diff --git a/deps/jansson/test/suites/encoding-flags/object/input b/deps/jansson/test/suites/encoding-flags/object/input deleted file mode 100644 index 062e54f..0000000 --- a/deps/jansson/test/suites/encoding-flags/object/input +++ /dev/null @@ -1 +0,0 @@ -{"a": 1, "b": 2} diff --git a/deps/jansson/test/suites/encoding-flags/object/output b/deps/jansson/test/suites/encoding-flags/object/output deleted file mode 100644 index ecd219f..0000000 --- a/deps/jansson/test/suites/encoding-flags/object/output +++ /dev/null @@ -1 +0,0 @@ -{"a": 1, "b": 2} \ No newline at end of file diff --git a/deps/jansson/test/suites/encoding-flags/preserve-order/env b/deps/jansson/test/suites/encoding-flags/preserve-order/env deleted file mode 100644 index 4d9d206..0000000 --- a/deps/jansson/test/suites/encoding-flags/preserve-order/env +++ /dev/null @@ -1,2 +0,0 @@ -JSON_PRESERVE_ORDER=1 -export JSON_PRESERVE_ORDER diff --git a/deps/jansson/test/suites/encoding-flags/preserve-order/input b/deps/jansson/test/suites/encoding-flags/preserve-order/input deleted file mode 100644 index 27bcf18..0000000 --- a/deps/jansson/test/suites/encoding-flags/preserve-order/input +++ /dev/null @@ -1 +0,0 @@ -{"foo": 1, "bar": 2, "asdf": 3, "deadbeef": 4, "badc0ffee": 5, "qwerty": 6} diff --git a/deps/jansson/test/suites/encoding-flags/preserve-order/output b/deps/jansson/test/suites/encoding-flags/preserve-order/output deleted file mode 100644 index 7a443f6..0000000 --- a/deps/jansson/test/suites/encoding-flags/preserve-order/output +++ /dev/null @@ -1 +0,0 @@ -{"foo": 1, "bar": 2, "asdf": 3, "deadbeef": 4, "badc0ffee": 5, "qwerty": 6} \ No newline at end of file diff --git a/deps/jansson/test/suites/encoding-flags/run b/deps/jansson/test/suites/encoding-flags/run deleted file mode 100755 index 1920f7f..0000000 --- a/deps/jansson/test/suites/encoding-flags/run +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2009-2013 Petri Lehtinen -# -# Jansson is free software; you can redistribute it and/or modify -# it under the terms of the MIT license. See LICENSE for details. - -is_test() { - test -d $test_path -} - -run_test() { - ( - if [ -f $test_path/env ]; then - . $test_path/env - fi - $json_process --env <$test_path/input >$test_log/stdout 2>$test_log/stderr - ) - valgrind_check $test_log/stderr || return 1 - cmp -s $test_path/output $test_log/stdout -} - -show_error() { - valgrind_show_error && return - - echo "EXPECTED OUTPUT:" - nl -bn $test_path/output - echo "ACTUAL OUTPUT:" - nl -bn $test_log/stdout -} - -. $top_srcdir/test/scripts/run-tests.sh diff --git a/deps/jansson/test/suites/encoding-flags/sort-keys/env b/deps/jansson/test/suites/encoding-flags/sort-keys/env deleted file mode 100644 index 3ef24cb..0000000 --- a/deps/jansson/test/suites/encoding-flags/sort-keys/env +++ /dev/null @@ -1,2 +0,0 @@ -JSON_SORT_KEYS=1 -export JSON_SORT_KEYS diff --git a/deps/jansson/test/suites/encoding-flags/sort-keys/input b/deps/jansson/test/suites/encoding-flags/sort-keys/input deleted file mode 100644 index 66951d6..0000000 --- a/deps/jansson/test/suites/encoding-flags/sort-keys/input +++ /dev/null @@ -1 +0,0 @@ -{"foo": 1, "bar": 2, "baz": 3, "quux": 4} diff --git a/deps/jansson/test/suites/encoding-flags/sort-keys/output b/deps/jansson/test/suites/encoding-flags/sort-keys/output deleted file mode 100644 index 132d9df..0000000 --- a/deps/jansson/test/suites/encoding-flags/sort-keys/output +++ /dev/null @@ -1 +0,0 @@ -{"bar": 2, "baz": 3, "foo": 1, "quux": 4} \ No newline at end of file diff --git a/deps/jansson/test/suites/invalid-unicode/encoded-surrogate-half/error b/deps/jansson/test/suites/invalid-unicode/encoded-surrogate-half/error deleted file mode 100644 index 762d2c4..0000000 --- a/deps/jansson/test/suites/invalid-unicode/encoded-surrogate-half/error +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -unable to decode byte 0xed near '"' diff --git a/deps/jansson/test/suites/invalid-unicode/encoded-surrogate-half/input b/deps/jansson/test/suites/invalid-unicode/encoded-surrogate-half/input deleted file mode 100644 index 515dd93..0000000 --- a/deps/jansson/test/suites/invalid-unicode/encoded-surrogate-half/input +++ /dev/null @@ -1 +0,0 @@ -["ķ¢« <-- encoded surrogate half"] diff --git a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-after-backslash/error b/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-after-backslash/error deleted file mode 100644 index b16dc17..0000000 --- a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-after-backslash/error +++ /dev/null @@ -1,2 +0,0 @@ -1 3 3 -unable to decode byte 0xe5 near '"\' diff --git a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-after-backslash/input b/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-after-backslash/input deleted file mode 100644 index 57c8bee..0000000 --- a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-after-backslash/input +++ /dev/null @@ -1 +0,0 @@ -["\å"] diff --git a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-array/error b/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-array/error deleted file mode 100644 index be15386..0000000 --- a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-array/error +++ /dev/null @@ -1,2 +0,0 @@ -1 1 1 -unable to decode byte 0xe5 diff --git a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-array/input b/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-array/input deleted file mode 100644 index ebefcd6..0000000 --- a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-array/input +++ /dev/null @@ -1 +0,0 @@ -[å] diff --git a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-bigger-int/error b/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-bigger-int/error deleted file mode 100644 index 01b4476..0000000 --- a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-bigger-int/error +++ /dev/null @@ -1,2 +0,0 @@ -1 4 4 -unable to decode byte 0xe5 near '123' diff --git a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-bigger-int/input b/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-bigger-int/input deleted file mode 100644 index e512f9a..0000000 --- a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-bigger-int/input +++ /dev/null @@ -1 +0,0 @@ -[123å] diff --git a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-escape/error b/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-escape/error deleted file mode 100644 index c13583d..0000000 --- a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-escape/error +++ /dev/null @@ -1,2 +0,0 @@ -1 4 4 -unable to decode byte 0xe5 near '"\u' diff --git a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-escape/input b/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-escape/input deleted file mode 100644 index 2b271b8..0000000 --- a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-escape/input +++ /dev/null @@ -1 +0,0 @@ -["\uå"] diff --git a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-exponent/error b/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-exponent/error deleted file mode 100644 index c7b20b7..0000000 --- a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-exponent/error +++ /dev/null @@ -1,2 +0,0 @@ -1 4 4 -unable to decode byte 0xe5 near '1e1' diff --git a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-exponent/input b/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-exponent/input deleted file mode 100644 index d8e83c5..0000000 --- a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-exponent/input +++ /dev/null @@ -1 +0,0 @@ -[1e1å] diff --git a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-identifier/error b/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-identifier/error deleted file mode 100644 index 33dfc23..0000000 --- a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-identifier/error +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -unable to decode byte 0xe5 near 'a' diff --git a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-identifier/input b/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-identifier/input deleted file mode 100644 index ef03851..0000000 --- a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-identifier/input +++ /dev/null @@ -1 +0,0 @@ -[aå] diff --git a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-int/error b/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-int/error deleted file mode 100644 index 8f08970..0000000 --- a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-int/error +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -unable to decode byte 0xe5 near '0' diff --git a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-int/input b/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-int/input deleted file mode 100644 index 371226e..0000000 --- a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-int/input +++ /dev/null @@ -1 +0,0 @@ -[0å] diff --git a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-real-after-e/error b/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-real-after-e/error deleted file mode 100644 index b7660e3..0000000 --- a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-real-after-e/error +++ /dev/null @@ -1,2 +0,0 @@ -1 3 3 -unable to decode byte 0xe5 near '1e' diff --git a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-real-after-e/input b/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-real-after-e/input deleted file mode 100644 index 17fc29c..0000000 --- a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-real-after-e/input +++ /dev/null @@ -1 +0,0 @@ -[1eå] diff --git a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-string/error b/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-string/error deleted file mode 100644 index 0b7039a..0000000 --- a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-string/error +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -unable to decode byte 0xe5 near '"' diff --git a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-string/input b/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-string/input deleted file mode 100644 index 00b79c0..0000000 --- a/deps/jansson/test/suites/invalid-unicode/invalid-utf-8-in-string/input +++ /dev/null @@ -1 +0,0 @@ -["å <-- invalid UTF-8"] diff --git a/deps/jansson/test/suites/invalid-unicode/lone-invalid-utf-8/error b/deps/jansson/test/suites/invalid-unicode/lone-invalid-utf-8/error deleted file mode 100644 index 8e9a511..0000000 --- a/deps/jansson/test/suites/invalid-unicode/lone-invalid-utf-8/error +++ /dev/null @@ -1,2 +0,0 @@ -1 0 0 -unable to decode byte 0xe5 diff --git a/deps/jansson/test/suites/invalid-unicode/lone-invalid-utf-8/input b/deps/jansson/test/suites/invalid-unicode/lone-invalid-utf-8/input deleted file mode 100644 index eb80796..0000000 --- a/deps/jansson/test/suites/invalid-unicode/lone-invalid-utf-8/input +++ /dev/null @@ -1 +0,0 @@ -å diff --git a/deps/jansson/test/suites/invalid-unicode/lone-utf-8-continuation-byte/error b/deps/jansson/test/suites/invalid-unicode/lone-utf-8-continuation-byte/error deleted file mode 100644 index 86bbad3..0000000 --- a/deps/jansson/test/suites/invalid-unicode/lone-utf-8-continuation-byte/error +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -unable to decode byte 0x81 near '"' diff --git a/deps/jansson/test/suites/invalid-unicode/lone-utf-8-continuation-byte/input b/deps/jansson/test/suites/invalid-unicode/lone-utf-8-continuation-byte/input deleted file mode 100644 index 62a26b6..0000000 --- a/deps/jansson/test/suites/invalid-unicode/lone-utf-8-continuation-byte/input +++ /dev/null @@ -1 +0,0 @@ -[""] diff --git a/deps/jansson/test/suites/invalid-unicode/not-in-unicode-range/error b/deps/jansson/test/suites/invalid-unicode/not-in-unicode-range/error deleted file mode 100644 index d07ccb3..0000000 --- a/deps/jansson/test/suites/invalid-unicode/not-in-unicode-range/error +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -unable to decode byte 0xf4 near '"' diff --git a/deps/jansson/test/suites/invalid-unicode/not-in-unicode-range/input b/deps/jansson/test/suites/invalid-unicode/not-in-unicode-range/input deleted file mode 100644 index 1216186..0000000 --- a/deps/jansson/test/suites/invalid-unicode/not-in-unicode-range/input +++ /dev/null @@ -1 +0,0 @@ -["ōæææ"] diff --git a/deps/jansson/test/suites/invalid-unicode/overlong-3-byte-encoding/error b/deps/jansson/test/suites/invalid-unicode/overlong-3-byte-encoding/error deleted file mode 100644 index 8a05aba..0000000 --- a/deps/jansson/test/suites/invalid-unicode/overlong-3-byte-encoding/error +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -unable to decode byte 0xe0 near '"' diff --git a/deps/jansson/test/suites/invalid-unicode/overlong-3-byte-encoding/input b/deps/jansson/test/suites/invalid-unicode/overlong-3-byte-encoding/input deleted file mode 100644 index 0bf909f..0000000 --- a/deps/jansson/test/suites/invalid-unicode/overlong-3-byte-encoding/input +++ /dev/null @@ -1 +0,0 @@ -["ą€¢ <-- overlong encoding"] diff --git a/deps/jansson/test/suites/invalid-unicode/overlong-4-byte-encoding/error b/deps/jansson/test/suites/invalid-unicode/overlong-4-byte-encoding/error deleted file mode 100644 index 7e19c5f..0000000 --- a/deps/jansson/test/suites/invalid-unicode/overlong-4-byte-encoding/error +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -unable to decode byte 0xf0 near '"' diff --git a/deps/jansson/test/suites/invalid-unicode/overlong-4-byte-encoding/input b/deps/jansson/test/suites/invalid-unicode/overlong-4-byte-encoding/input deleted file mode 100644 index c6b6313..0000000 --- a/deps/jansson/test/suites/invalid-unicode/overlong-4-byte-encoding/input +++ /dev/null @@ -1 +0,0 @@ -["š€€¢ <-- overlong encoding"] diff --git a/deps/jansson/test/suites/invalid-unicode/overlong-ascii-encoding/error b/deps/jansson/test/suites/invalid-unicode/overlong-ascii-encoding/error deleted file mode 100644 index 1d382ed..0000000 --- a/deps/jansson/test/suites/invalid-unicode/overlong-ascii-encoding/error +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -unable to decode byte 0xc1 near '"' diff --git a/deps/jansson/test/suites/invalid-unicode/overlong-ascii-encoding/input b/deps/jansson/test/suites/invalid-unicode/overlong-ascii-encoding/input deleted file mode 100644 index ef6e10a..0000000 --- a/deps/jansson/test/suites/invalid-unicode/overlong-ascii-encoding/input +++ /dev/null @@ -1 +0,0 @@ -["Į"] diff --git a/deps/jansson/test/suites/invalid-unicode/restricted-utf-8/error b/deps/jansson/test/suites/invalid-unicode/restricted-utf-8/error deleted file mode 100644 index d018f5f..0000000 --- a/deps/jansson/test/suites/invalid-unicode/restricted-utf-8/error +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -unable to decode byte 0xfd near '"' diff --git a/deps/jansson/test/suites/invalid-unicode/restricted-utf-8/input b/deps/jansson/test/suites/invalid-unicode/restricted-utf-8/input deleted file mode 100644 index ba60170..0000000 --- a/deps/jansson/test/suites/invalid-unicode/restricted-utf-8/input +++ /dev/null @@ -1 +0,0 @@ -["ż"] diff --git a/deps/jansson/test/suites/invalid-unicode/run b/deps/jansson/test/suites/invalid-unicode/run deleted file mode 100755 index ac584f6..0000000 --- a/deps/jansson/test/suites/invalid-unicode/run +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2009-2013 Petri Lehtinen -# -# Jansson is free software; you can redistribute it and/or modify -# it under the terms of the MIT license. See LICENSE for details. - -is_test() { - test -d $test_path -} - -run_test() { - $json_process --env <$test_path/input >$test_log/stdout 2>$test_log/stderr - valgrind_check $test_log/stderr || return 1 - cmp -s $test_path/error $test_log/stderr -} - -show_error() { - valgrind_show_error && return - - echo "EXPECTED ERROR:" - nl -bn $test_path/error - echo "ACTUAL ERROR:" - nl -bn $test_log/stderr -} - -. $top_srcdir/test/scripts/run-tests.sh diff --git a/deps/jansson/test/suites/invalid-unicode/truncated-utf-8/error b/deps/jansson/test/suites/invalid-unicode/truncated-utf-8/error deleted file mode 100644 index 8a05aba..0000000 --- a/deps/jansson/test/suites/invalid-unicode/truncated-utf-8/error +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -unable to decode byte 0xe0 near '"' diff --git a/deps/jansson/test/suites/invalid-unicode/truncated-utf-8/input b/deps/jansson/test/suites/invalid-unicode/truncated-utf-8/input deleted file mode 100644 index bce9e18..0000000 --- a/deps/jansson/test/suites/invalid-unicode/truncated-utf-8/input +++ /dev/null @@ -1 +0,0 @@ -["ą’ <-- truncated UTF-8"] diff --git a/deps/jansson/test/suites/invalid/apostrophe/error b/deps/jansson/test/suites/invalid/apostrophe/error deleted file mode 100644 index 79bb2a0..0000000 --- a/deps/jansson/test/suites/invalid/apostrophe/error +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -invalid token near ''' diff --git a/deps/jansson/test/suites/invalid/apostrophe/input b/deps/jansson/test/suites/invalid/apostrophe/input deleted file mode 100644 index f2dd4d2..0000000 --- a/deps/jansson/test/suites/invalid/apostrophe/input +++ /dev/null @@ -1 +0,0 @@ -[' diff --git a/deps/jansson/test/suites/invalid/ascii-unicode-identifier/error b/deps/jansson/test/suites/invalid/ascii-unicode-identifier/error deleted file mode 100644 index a4d8142..0000000 --- a/deps/jansson/test/suites/invalid/ascii-unicode-identifier/error +++ /dev/null @@ -1,2 +0,0 @@ -1 1 1 -'[' or '{' expected near 'a' diff --git a/deps/jansson/test/suites/invalid/ascii-unicode-identifier/input b/deps/jansson/test/suites/invalid/ascii-unicode-identifier/input deleted file mode 100644 index c2c0208..0000000 --- a/deps/jansson/test/suites/invalid/ascii-unicode-identifier/input +++ /dev/null @@ -1 +0,0 @@ -aĆ„ diff --git a/deps/jansson/test/suites/invalid/brace-comma/error b/deps/jansson/test/suites/invalid/brace-comma/error deleted file mode 100644 index ce04621..0000000 --- a/deps/jansson/test/suites/invalid/brace-comma/error +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -string or '}' expected near ',' diff --git a/deps/jansson/test/suites/invalid/brace-comma/input b/deps/jansson/test/suites/invalid/brace-comma/input deleted file mode 100644 index 74a6628..0000000 --- a/deps/jansson/test/suites/invalid/brace-comma/input +++ /dev/null @@ -1 +0,0 @@ -{, diff --git a/deps/jansson/test/suites/invalid/bracket-comma/error b/deps/jansson/test/suites/invalid/bracket-comma/error deleted file mode 100644 index ce0a912..0000000 --- a/deps/jansson/test/suites/invalid/bracket-comma/error +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -unexpected token near ',' diff --git a/deps/jansson/test/suites/invalid/bracket-comma/input b/deps/jansson/test/suites/invalid/bracket-comma/input deleted file mode 100644 index 5b911f1..0000000 --- a/deps/jansson/test/suites/invalid/bracket-comma/input +++ /dev/null @@ -1 +0,0 @@ -[, diff --git a/deps/jansson/test/suites/invalid/bracket-one-comma/error.normal b/deps/jansson/test/suites/invalid/bracket-one-comma/error.normal deleted file mode 100644 index 0248b11..0000000 --- a/deps/jansson/test/suites/invalid/bracket-one-comma/error.normal +++ /dev/null @@ -1,2 +0,0 @@ -2 0 4 -']' expected near end of file diff --git a/deps/jansson/test/suites/invalid/bracket-one-comma/error.strip b/deps/jansson/test/suites/invalid/bracket-one-comma/error.strip deleted file mode 100644 index f89b38f..0000000 --- a/deps/jansson/test/suites/invalid/bracket-one-comma/error.strip +++ /dev/null @@ -1,2 +0,0 @@ -1 3 3 -']' expected near end of file diff --git a/deps/jansson/test/suites/invalid/bracket-one-comma/input b/deps/jansson/test/suites/invalid/bracket-one-comma/input deleted file mode 100644 index 874691b..0000000 --- a/deps/jansson/test/suites/invalid/bracket-one-comma/input +++ /dev/null @@ -1 +0,0 @@ -[1, diff --git a/deps/jansson/test/suites/invalid/empty/error b/deps/jansson/test/suites/invalid/empty/error deleted file mode 100644 index f45da6f..0000000 --- a/deps/jansson/test/suites/invalid/empty/error +++ /dev/null @@ -1,2 +0,0 @@ -1 0 0 -'[' or '{' expected near end of file diff --git a/deps/jansson/test/suites/invalid/empty/input b/deps/jansson/test/suites/invalid/empty/input deleted file mode 100644 index e69de29..0000000 diff --git a/deps/jansson/test/suites/invalid/extra-comma-in-array/error b/deps/jansson/test/suites/invalid/extra-comma-in-array/error deleted file mode 100644 index cae86c2..0000000 --- a/deps/jansson/test/suites/invalid/extra-comma-in-array/error +++ /dev/null @@ -1,2 +0,0 @@ -1 4 4 -unexpected token near ']' diff --git a/deps/jansson/test/suites/invalid/extra-comma-in-array/input b/deps/jansson/test/suites/invalid/extra-comma-in-array/input deleted file mode 100644 index e8b1a17..0000000 --- a/deps/jansson/test/suites/invalid/extra-comma-in-array/input +++ /dev/null @@ -1 +0,0 @@ -[1,] diff --git a/deps/jansson/test/suites/invalid/extra-comma-in-multiline-array/error b/deps/jansson/test/suites/invalid/extra-comma-in-multiline-array/error deleted file mode 100644 index 5baeea4..0000000 --- a/deps/jansson/test/suites/invalid/extra-comma-in-multiline-array/error +++ /dev/null @@ -1,2 +0,0 @@ -6 1 17 -unexpected token near ']' diff --git a/deps/jansson/test/suites/invalid/extra-comma-in-multiline-array/input b/deps/jansson/test/suites/invalid/extra-comma-in-multiline-array/input deleted file mode 100644 index bcb2a75..0000000 --- a/deps/jansson/test/suites/invalid/extra-comma-in-multiline-array/input +++ /dev/null @@ -1,6 +0,0 @@ -[1, -2, -3, -4, -5, -] diff --git a/deps/jansson/test/suites/invalid/garbage-after-newline/error b/deps/jansson/test/suites/invalid/garbage-after-newline/error deleted file mode 100644 index 5d2dec3..0000000 --- a/deps/jansson/test/suites/invalid/garbage-after-newline/error +++ /dev/null @@ -1,2 +0,0 @@ -2 3 11 -end of file expected near 'foo' diff --git a/deps/jansson/test/suites/invalid/garbage-after-newline/input b/deps/jansson/test/suites/invalid/garbage-after-newline/input deleted file mode 100644 index 3614ac7..0000000 --- a/deps/jansson/test/suites/invalid/garbage-after-newline/input +++ /dev/null @@ -1,2 +0,0 @@ -[1,2,3] -foo diff --git a/deps/jansson/test/suites/invalid/garbage-at-the-end/error b/deps/jansson/test/suites/invalid/garbage-at-the-end/error deleted file mode 100644 index cdd8175..0000000 --- a/deps/jansson/test/suites/invalid/garbage-at-the-end/error +++ /dev/null @@ -1,2 +0,0 @@ -1 10 10 -end of file expected near 'foo' diff --git a/deps/jansson/test/suites/invalid/garbage-at-the-end/input b/deps/jansson/test/suites/invalid/garbage-at-the-end/input deleted file mode 100644 index 55aee53..0000000 --- a/deps/jansson/test/suites/invalid/garbage-at-the-end/input +++ /dev/null @@ -1 +0,0 @@ -[1,2,3]foo diff --git a/deps/jansson/test/suites/invalid/integer-starting-with-zero/error b/deps/jansson/test/suites/invalid/integer-starting-with-zero/error deleted file mode 100644 index 64e0536..0000000 --- a/deps/jansson/test/suites/invalid/integer-starting-with-zero/error +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -invalid token near '0' diff --git a/deps/jansson/test/suites/invalid/integer-starting-with-zero/input b/deps/jansson/test/suites/invalid/integer-starting-with-zero/input deleted file mode 100644 index 12f67e2..0000000 --- a/deps/jansson/test/suites/invalid/integer-starting-with-zero/input +++ /dev/null @@ -1 +0,0 @@ -[012] diff --git a/deps/jansson/test/suites/invalid/invalid-escape/error b/deps/jansson/test/suites/invalid/invalid-escape/error deleted file mode 100644 index d9863f7..0000000 --- a/deps/jansson/test/suites/invalid/invalid-escape/error +++ /dev/null @@ -1,2 +0,0 @@ -1 4 4 -invalid escape near '"\a' diff --git a/deps/jansson/test/suites/invalid/invalid-escape/input b/deps/jansson/test/suites/invalid/invalid-escape/input deleted file mode 100644 index 64c7b70..0000000 --- a/deps/jansson/test/suites/invalid/invalid-escape/input +++ /dev/null @@ -1 +0,0 @@ -["\a <-- invalid escape"] diff --git a/deps/jansson/test/suites/invalid/invalid-identifier/error b/deps/jansson/test/suites/invalid/invalid-identifier/error deleted file mode 100644 index 496c6ab..0000000 --- a/deps/jansson/test/suites/invalid/invalid-identifier/error +++ /dev/null @@ -1,2 +0,0 @@ -1 5 5 -invalid token near 'troo' diff --git a/deps/jansson/test/suites/invalid/invalid-identifier/input b/deps/jansson/test/suites/invalid/invalid-identifier/input deleted file mode 100644 index 3d2860d..0000000 --- a/deps/jansson/test/suites/invalid/invalid-identifier/input +++ /dev/null @@ -1 +0,0 @@ -[troo diff --git a/deps/jansson/test/suites/invalid/invalid-negative-integer/error b/deps/jansson/test/suites/invalid/invalid-negative-integer/error deleted file mode 100644 index f2526c5..0000000 --- a/deps/jansson/test/suites/invalid/invalid-negative-integer/error +++ /dev/null @@ -1,2 +0,0 @@ -1 8 8 -']' expected near 'foo' diff --git a/deps/jansson/test/suites/invalid/invalid-negative-integer/input b/deps/jansson/test/suites/invalid/invalid-negative-integer/input deleted file mode 100644 index 6196980..0000000 --- a/deps/jansson/test/suites/invalid/invalid-negative-integer/input +++ /dev/null @@ -1 +0,0 @@ -[-123foo] diff --git a/deps/jansson/test/suites/invalid/invalid-negative-real/error b/deps/jansson/test/suites/invalid/invalid-negative-real/error deleted file mode 100644 index 933158a..0000000 --- a/deps/jansson/test/suites/invalid/invalid-negative-real/error +++ /dev/null @@ -1,2 +0,0 @@ -1 12 12 -']' expected near 'foo' diff --git a/deps/jansson/test/suites/invalid/invalid-negative-real/input b/deps/jansson/test/suites/invalid/invalid-negative-real/input deleted file mode 100644 index 3c763d3..0000000 --- a/deps/jansson/test/suites/invalid/invalid-negative-real/input +++ /dev/null @@ -1 +0,0 @@ -[-123.123foo] diff --git a/deps/jansson/test/suites/invalid/invalid-second-surrogate/error b/deps/jansson/test/suites/invalid/invalid-second-surrogate/error deleted file mode 100644 index e5a2359..0000000 --- a/deps/jansson/test/suites/invalid/invalid-second-surrogate/error +++ /dev/null @@ -1,2 +0,0 @@ -1 62 62 -invalid Unicode '\uD888\u3210' diff --git a/deps/jansson/test/suites/invalid/invalid-second-surrogate/input b/deps/jansson/test/suites/invalid/invalid-second-surrogate/input deleted file mode 100644 index b21453f..0000000 --- a/deps/jansson/test/suites/invalid/invalid-second-surrogate/input +++ /dev/null @@ -1 +0,0 @@ -["\uD888\u3210 (first surrogate and invalid second surrogate)"] diff --git a/deps/jansson/test/suites/invalid/lone-open-brace/error.normal b/deps/jansson/test/suites/invalid/lone-open-brace/error.normal deleted file mode 100644 index 00dc765..0000000 --- a/deps/jansson/test/suites/invalid/lone-open-brace/error.normal +++ /dev/null @@ -1,2 +0,0 @@ -2 0 2 -string or '}' expected near end of file diff --git a/deps/jansson/test/suites/invalid/lone-open-brace/error.strip b/deps/jansson/test/suites/invalid/lone-open-brace/error.strip deleted file mode 100644 index bb1c047..0000000 --- a/deps/jansson/test/suites/invalid/lone-open-brace/error.strip +++ /dev/null @@ -1,2 +0,0 @@ -1 1 1 -string or '}' expected near end of file diff --git a/deps/jansson/test/suites/invalid/lone-open-brace/input b/deps/jansson/test/suites/invalid/lone-open-brace/input deleted file mode 100644 index 98232c6..0000000 --- a/deps/jansson/test/suites/invalid/lone-open-brace/input +++ /dev/null @@ -1 +0,0 @@ -{ diff --git a/deps/jansson/test/suites/invalid/lone-open-bracket/error.normal b/deps/jansson/test/suites/invalid/lone-open-bracket/error.normal deleted file mode 100644 index f463928..0000000 --- a/deps/jansson/test/suites/invalid/lone-open-bracket/error.normal +++ /dev/null @@ -1,2 +0,0 @@ -2 0 2 -']' expected near end of file diff --git a/deps/jansson/test/suites/invalid/lone-open-bracket/error.strip b/deps/jansson/test/suites/invalid/lone-open-bracket/error.strip deleted file mode 100644 index 2bc07ea..0000000 --- a/deps/jansson/test/suites/invalid/lone-open-bracket/error.strip +++ /dev/null @@ -1,2 +0,0 @@ -1 1 1 -']' expected near end of file diff --git a/deps/jansson/test/suites/invalid/lone-open-bracket/input b/deps/jansson/test/suites/invalid/lone-open-bracket/input deleted file mode 100644 index 558ed37..0000000 --- a/deps/jansson/test/suites/invalid/lone-open-bracket/input +++ /dev/null @@ -1 +0,0 @@ -[ diff --git a/deps/jansson/test/suites/invalid/lone-second-surrogate/error b/deps/jansson/test/suites/invalid/lone-second-surrogate/error deleted file mode 100644 index bc5f34e..0000000 --- a/deps/jansson/test/suites/invalid/lone-second-surrogate/error +++ /dev/null @@ -1,2 +0,0 @@ -1 40 40 -invalid Unicode '\uDFAA' diff --git a/deps/jansson/test/suites/invalid/lone-second-surrogate/input b/deps/jansson/test/suites/invalid/lone-second-surrogate/input deleted file mode 100644 index 328e35c..0000000 --- a/deps/jansson/test/suites/invalid/lone-second-surrogate/input +++ /dev/null @@ -1 +0,0 @@ -["\uDFAA (second surrogate on it's own)"] diff --git a/deps/jansson/test/suites/invalid/minus-sign-without-number/error b/deps/jansson/test/suites/invalid/minus-sign-without-number/error deleted file mode 100644 index b3a78b9..0000000 --- a/deps/jansson/test/suites/invalid/minus-sign-without-number/error +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -invalid token near '-' diff --git a/deps/jansson/test/suites/invalid/minus-sign-without-number/input b/deps/jansson/test/suites/invalid/minus-sign-without-number/input deleted file mode 100644 index 0337883..0000000 --- a/deps/jansson/test/suites/invalid/minus-sign-without-number/input +++ /dev/null @@ -1 +0,0 @@ -[-foo] diff --git a/deps/jansson/test/suites/invalid/negative-integer-starting-with-zero/error b/deps/jansson/test/suites/invalid/negative-integer-starting-with-zero/error deleted file mode 100644 index 36adc34..0000000 --- a/deps/jansson/test/suites/invalid/negative-integer-starting-with-zero/error +++ /dev/null @@ -1,2 +0,0 @@ -1 3 3 -invalid token near '-0' diff --git a/deps/jansson/test/suites/invalid/negative-integer-starting-with-zero/input b/deps/jansson/test/suites/invalid/negative-integer-starting-with-zero/input deleted file mode 100644 index 6fbb7a2..0000000 --- a/deps/jansson/test/suites/invalid/negative-integer-starting-with-zero/input +++ /dev/null @@ -1 +0,0 @@ -[-012] diff --git a/deps/jansson/test/suites/invalid/null-byte-in-object-key/error b/deps/jansson/test/suites/invalid/null-byte-in-object-key/error deleted file mode 100644 index 3ec685b..0000000 --- a/deps/jansson/test/suites/invalid/null-byte-in-object-key/error +++ /dev/null @@ -1,2 +0,0 @@ -1 15 15 -NUL byte in object key not supported near '"foo\u0000bar"' diff --git a/deps/jansson/test/suites/invalid/null-byte-in-object-key/input b/deps/jansson/test/suites/invalid/null-byte-in-object-key/input deleted file mode 100644 index 593f0f6..0000000 --- a/deps/jansson/test/suites/invalid/null-byte-in-object-key/input +++ /dev/null @@ -1 +0,0 @@ -{"foo\u0000bar": 42} \ No newline at end of file diff --git a/deps/jansson/test/suites/invalid/null-byte-in-string/error b/deps/jansson/test/suites/invalid/null-byte-in-string/error deleted file mode 100644 index 45f9bd8..0000000 --- a/deps/jansson/test/suites/invalid/null-byte-in-string/error +++ /dev/null @@ -1,2 +0,0 @@ -1 12 12 -control character 0x0 near '"null byte ' diff --git a/deps/jansson/test/suites/invalid/null-byte-in-string/input b/deps/jansson/test/suites/invalid/null-byte-in-string/input deleted file mode 100644 index 268d1f1..0000000 Binary files a/deps/jansson/test/suites/invalid/null-byte-in-string/input and /dev/null differ diff --git a/deps/jansson/test/suites/invalid/null-byte-in-string/nostrip b/deps/jansson/test/suites/invalid/null-byte-in-string/nostrip deleted file mode 100644 index 80f4bf7..0000000 --- a/deps/jansson/test/suites/invalid/null-byte-in-string/nostrip +++ /dev/null @@ -1,2 +0,0 @@ -The embedded NULL byte breaks json_loads(), which is used instead of -json_loadf() in the stripped tests. diff --git a/deps/jansson/test/suites/invalid/null-byte-outside-string/error b/deps/jansson/test/suites/invalid/null-byte-outside-string/error deleted file mode 100644 index 44d4def..0000000 --- a/deps/jansson/test/suites/invalid/null-byte-outside-string/error +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -invalid token near end of file diff --git a/deps/jansson/test/suites/invalid/null-byte-outside-string/input b/deps/jansson/test/suites/invalid/null-byte-outside-string/input deleted file mode 100644 index aa550eb..0000000 Binary files a/deps/jansson/test/suites/invalid/null-byte-outside-string/input and /dev/null differ diff --git a/deps/jansson/test/suites/invalid/null-byte-outside-string/nostrip b/deps/jansson/test/suites/invalid/null-byte-outside-string/nostrip deleted file mode 100644 index 80f4bf7..0000000 --- a/deps/jansson/test/suites/invalid/null-byte-outside-string/nostrip +++ /dev/null @@ -1,2 +0,0 @@ -The embedded NULL byte breaks json_loads(), which is used instead of -json_loadf() in the stripped tests. diff --git a/deps/jansson/test/suites/invalid/null/error b/deps/jansson/test/suites/invalid/null/error deleted file mode 100644 index 1f5d464..0000000 --- a/deps/jansson/test/suites/invalid/null/error +++ /dev/null @@ -1,2 +0,0 @@ -1 4 4 -'[' or '{' expected near 'null' diff --git a/deps/jansson/test/suites/invalid/null/input b/deps/jansson/test/suites/invalid/null/input deleted file mode 100644 index 19765bd..0000000 --- a/deps/jansson/test/suites/invalid/null/input +++ /dev/null @@ -1 +0,0 @@ -null diff --git a/deps/jansson/test/suites/invalid/object-apostrophes/error b/deps/jansson/test/suites/invalid/object-apostrophes/error deleted file mode 100644 index 23fab01..0000000 --- a/deps/jansson/test/suites/invalid/object-apostrophes/error +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -string or '}' expected near ''' diff --git a/deps/jansson/test/suites/invalid/object-apostrophes/input b/deps/jansson/test/suites/invalid/object-apostrophes/input deleted file mode 100644 index 52b2905..0000000 --- a/deps/jansson/test/suites/invalid/object-apostrophes/input +++ /dev/null @@ -1 +0,0 @@ -{'a' diff --git a/deps/jansson/test/suites/invalid/object-garbage-at-end/error b/deps/jansson/test/suites/invalid/object-garbage-at-end/error deleted file mode 100644 index 06c4ec1..0000000 --- a/deps/jansson/test/suites/invalid/object-garbage-at-end/error +++ /dev/null @@ -1,2 +0,0 @@ -1 12 12 -'}' expected near '123' diff --git a/deps/jansson/test/suites/invalid/object-garbage-at-end/input b/deps/jansson/test/suites/invalid/object-garbage-at-end/input deleted file mode 100644 index 62c19d7..0000000 --- a/deps/jansson/test/suites/invalid/object-garbage-at-end/input +++ /dev/null @@ -1 +0,0 @@ -{"a":"a" 123} diff --git a/deps/jansson/test/suites/invalid/object-in-unterminated-array/error.normal b/deps/jansson/test/suites/invalid/object-in-unterminated-array/error.normal deleted file mode 100644 index 0248b11..0000000 --- a/deps/jansson/test/suites/invalid/object-in-unterminated-array/error.normal +++ /dev/null @@ -1,2 +0,0 @@ -2 0 4 -']' expected near end of file diff --git a/deps/jansson/test/suites/invalid/object-in-unterminated-array/error.strip b/deps/jansson/test/suites/invalid/object-in-unterminated-array/error.strip deleted file mode 100644 index f89b38f..0000000 --- a/deps/jansson/test/suites/invalid/object-in-unterminated-array/error.strip +++ /dev/null @@ -1,2 +0,0 @@ -1 3 3 -']' expected near end of file diff --git a/deps/jansson/test/suites/invalid/object-in-unterminated-array/input b/deps/jansson/test/suites/invalid/object-in-unterminated-array/input deleted file mode 100644 index ca9ec37..0000000 --- a/deps/jansson/test/suites/invalid/object-in-unterminated-array/input +++ /dev/null @@ -1 +0,0 @@ -[{} diff --git a/deps/jansson/test/suites/invalid/object-no-colon/error.normal b/deps/jansson/test/suites/invalid/object-no-colon/error.normal deleted file mode 100644 index 78d84f7..0000000 --- a/deps/jansson/test/suites/invalid/object-no-colon/error.normal +++ /dev/null @@ -1,2 +0,0 @@ -2 0 5 -':' expected near end of file diff --git a/deps/jansson/test/suites/invalid/object-no-colon/error.strip b/deps/jansson/test/suites/invalid/object-no-colon/error.strip deleted file mode 100644 index 528e266..0000000 --- a/deps/jansson/test/suites/invalid/object-no-colon/error.strip +++ /dev/null @@ -1,2 +0,0 @@ -1 4 4 -':' expected near end of file diff --git a/deps/jansson/test/suites/invalid/object-no-colon/input b/deps/jansson/test/suites/invalid/object-no-colon/input deleted file mode 100644 index 107e626..0000000 --- a/deps/jansson/test/suites/invalid/object-no-colon/input +++ /dev/null @@ -1 +0,0 @@ -{"a" diff --git a/deps/jansson/test/suites/invalid/object-no-value/error.normal b/deps/jansson/test/suites/invalid/object-no-value/error.normal deleted file mode 100644 index 47ad902..0000000 --- a/deps/jansson/test/suites/invalid/object-no-value/error.normal +++ /dev/null @@ -1,2 +0,0 @@ -2 0 6 -unexpected token near end of file diff --git a/deps/jansson/test/suites/invalid/object-no-value/error.strip b/deps/jansson/test/suites/invalid/object-no-value/error.strip deleted file mode 100644 index b36c5e2..0000000 --- a/deps/jansson/test/suites/invalid/object-no-value/error.strip +++ /dev/null @@ -1,2 +0,0 @@ -1 5 5 -unexpected token near end of file diff --git a/deps/jansson/test/suites/invalid/object-no-value/input b/deps/jansson/test/suites/invalid/object-no-value/input deleted file mode 100644 index f68f262..0000000 --- a/deps/jansson/test/suites/invalid/object-no-value/input +++ /dev/null @@ -1 +0,0 @@ -{"a": diff --git a/deps/jansson/test/suites/invalid/object-unterminated-value/error.normal b/deps/jansson/test/suites/invalid/object-unterminated-value/error.normal deleted file mode 100644 index 2ad76d4..0000000 --- a/deps/jansson/test/suites/invalid/object-unterminated-value/error.normal +++ /dev/null @@ -1,2 +0,0 @@ -1 7 7 -unexpected newline near '"a' diff --git a/deps/jansson/test/suites/invalid/object-unterminated-value/error.strip b/deps/jansson/test/suites/invalid/object-unterminated-value/error.strip deleted file mode 100644 index 385afb5..0000000 --- a/deps/jansson/test/suites/invalid/object-unterminated-value/error.strip +++ /dev/null @@ -1,2 +0,0 @@ -1 7 7 -premature end of input near '"a' diff --git a/deps/jansson/test/suites/invalid/object-unterminated-value/input b/deps/jansson/test/suites/invalid/object-unterminated-value/input deleted file mode 100644 index b854d7e..0000000 --- a/deps/jansson/test/suites/invalid/object-unterminated-value/input +++ /dev/null @@ -1 +0,0 @@ -{"a":"a diff --git a/deps/jansson/test/suites/invalid/real-garbage-after-e/error b/deps/jansson/test/suites/invalid/real-garbage-after-e/error deleted file mode 100644 index b40ffa9..0000000 --- a/deps/jansson/test/suites/invalid/real-garbage-after-e/error +++ /dev/null @@ -1,2 +0,0 @@ -1 3 3 -invalid token near '1e' diff --git a/deps/jansson/test/suites/invalid/real-garbage-after-e/input b/deps/jansson/test/suites/invalid/real-garbage-after-e/input deleted file mode 100644 index 6a945ac..0000000 --- a/deps/jansson/test/suites/invalid/real-garbage-after-e/input +++ /dev/null @@ -1 +0,0 @@ -[1ea] diff --git a/deps/jansson/test/suites/invalid/real-negative-overflow/error b/deps/jansson/test/suites/invalid/real-negative-overflow/error deleted file mode 100644 index d7f8e41..0000000 --- a/deps/jansson/test/suites/invalid/real-negative-overflow/error +++ /dev/null @@ -1,2 +0,0 @@ -1 15 15 -real number overflow near '-123123e100000' diff --git a/deps/jansson/test/suites/invalid/real-negative-overflow/input b/deps/jansson/test/suites/invalid/real-negative-overflow/input deleted file mode 100644 index b5bd21c..0000000 --- a/deps/jansson/test/suites/invalid/real-negative-overflow/input +++ /dev/null @@ -1 +0,0 @@ -[-123123e100000] diff --git a/deps/jansson/test/suites/invalid/real-positive-overflow/error b/deps/jansson/test/suites/invalid/real-positive-overflow/error deleted file mode 100644 index 55883c9..0000000 --- a/deps/jansson/test/suites/invalid/real-positive-overflow/error +++ /dev/null @@ -1,2 +0,0 @@ -1 14 14 -real number overflow near '123123e100000' diff --git a/deps/jansson/test/suites/invalid/real-positive-overflow/input b/deps/jansson/test/suites/invalid/real-positive-overflow/input deleted file mode 100644 index 524e53b..0000000 --- a/deps/jansson/test/suites/invalid/real-positive-overflow/input +++ /dev/null @@ -1 +0,0 @@ -[123123e100000] diff --git a/deps/jansson/test/suites/invalid/real-truncated-at-e/error b/deps/jansson/test/suites/invalid/real-truncated-at-e/error deleted file mode 100644 index b40ffa9..0000000 --- a/deps/jansson/test/suites/invalid/real-truncated-at-e/error +++ /dev/null @@ -1,2 +0,0 @@ -1 3 3 -invalid token near '1e' diff --git a/deps/jansson/test/suites/invalid/real-truncated-at-e/input b/deps/jansson/test/suites/invalid/real-truncated-at-e/input deleted file mode 100644 index 1d67b7b..0000000 --- a/deps/jansson/test/suites/invalid/real-truncated-at-e/input +++ /dev/null @@ -1 +0,0 @@ -[1e] diff --git a/deps/jansson/test/suites/invalid/real-truncated-at-point/error b/deps/jansson/test/suites/invalid/real-truncated-at-point/error deleted file mode 100644 index db972e8..0000000 --- a/deps/jansson/test/suites/invalid/real-truncated-at-point/error +++ /dev/null @@ -1,2 +0,0 @@ -1 3 3 -invalid token near '1.' diff --git a/deps/jansson/test/suites/invalid/real-truncated-at-point/input b/deps/jansson/test/suites/invalid/real-truncated-at-point/input deleted file mode 100644 index b652b3f..0000000 --- a/deps/jansson/test/suites/invalid/real-truncated-at-point/input +++ /dev/null @@ -1 +0,0 @@ -[1.] diff --git a/deps/jansson/test/suites/invalid/run b/deps/jansson/test/suites/invalid/run deleted file mode 100755 index a640ea0..0000000 --- a/deps/jansson/test/suites/invalid/run +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2009-2013 Petri Lehtinen -# -# Jansson is free software; you can redistribute it and/or modify -# it under the terms of the MIT license. See LICENSE for details. - -is_test() { - test -d $test_path -} - -do_run() { - variant=$1 - s=".$1" - - strip=0 - if [ "$variant" = "strip" ]; then - # This test should not be stripped - [ -f $test_path/nostrip ] && return - strip=1 - fi - - STRIP=$strip $json_process --env \ - <$test_path/input >$test_log/stdout$s 2>$test_log/stderr$s - valgrind_check $test_log/stderr$s || return 1 - - ref=error - [ -f $test_path/error$s ] && ref=error$s - - if ! cmp -s $test_path/$ref $test_log/stderr$s; then - echo $variant > $test_log/variant - return 1 - fi -} - -run_test() { - do_run normal && do_run strip -} - -show_error() { - valgrind_show_error && return - - read variant < $test_log/variant - s=".$variant" - - echo "VARIANT: $variant" - - echo "EXPECTED ERROR:" - ref=error - [ -f $test_path/error$s ] && ref=error$s - nl -bn $test_path/$ref - - echo "ACTUAL ERROR:" - nl -bn $test_log/stderr$s -} - -. $top_srcdir/test/scripts/run-tests.sh diff --git a/deps/jansson/test/suites/invalid/tab-character-in-string/error b/deps/jansson/test/suites/invalid/tab-character-in-string/error deleted file mode 100644 index 9e2f76e..0000000 --- a/deps/jansson/test/suites/invalid/tab-character-in-string/error +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -control character 0x9 near '"' diff --git a/deps/jansson/test/suites/invalid/tab-character-in-string/input b/deps/jansson/test/suites/invalid/tab-character-in-string/input deleted file mode 100644 index 3ebae09..0000000 --- a/deps/jansson/test/suites/invalid/tab-character-in-string/input +++ /dev/null @@ -1 +0,0 @@ -[" <-- tab character"] diff --git a/deps/jansson/test/suites/invalid/too-big-negative-integer/error b/deps/jansson/test/suites/invalid/too-big-negative-integer/error deleted file mode 100644 index a0640b9..0000000 --- a/deps/jansson/test/suites/invalid/too-big-negative-integer/error +++ /dev/null @@ -1,2 +0,0 @@ -1 32 32 -too big negative integer diff --git a/deps/jansson/test/suites/invalid/too-big-negative-integer/input b/deps/jansson/test/suites/invalid/too-big-negative-integer/input deleted file mode 100644 index d6c26f1..0000000 --- a/deps/jansson/test/suites/invalid/too-big-negative-integer/input +++ /dev/null @@ -1 +0,0 @@ -[-123123123123123123123123123123] diff --git a/deps/jansson/test/suites/invalid/too-big-positive-integer/error b/deps/jansson/test/suites/invalid/too-big-positive-integer/error deleted file mode 100644 index 3bdbefd..0000000 --- a/deps/jansson/test/suites/invalid/too-big-positive-integer/error +++ /dev/null @@ -1,2 +0,0 @@ -1 31 31 -too big integer diff --git a/deps/jansson/test/suites/invalid/too-big-positive-integer/input b/deps/jansson/test/suites/invalid/too-big-positive-integer/input deleted file mode 100644 index 27c8553..0000000 --- a/deps/jansson/test/suites/invalid/too-big-positive-integer/input +++ /dev/null @@ -1 +0,0 @@ -[123123123123123123123123123123] diff --git a/deps/jansson/test/suites/invalid/truncated-unicode-surrogate/error b/deps/jansson/test/suites/invalid/truncated-unicode-surrogate/error deleted file mode 100644 index 1b99f06..0000000 --- a/deps/jansson/test/suites/invalid/truncated-unicode-surrogate/error +++ /dev/null @@ -1,2 +0,0 @@ -1 46 46 -invalid Unicode '\uDADA' diff --git a/deps/jansson/test/suites/invalid/truncated-unicode-surrogate/input b/deps/jansson/test/suites/invalid/truncated-unicode-surrogate/input deleted file mode 100644 index 2b340f4..0000000 --- a/deps/jansson/test/suites/invalid/truncated-unicode-surrogate/input +++ /dev/null @@ -1 +0,0 @@ -["\uDADA (first surrogate without the second)"] diff --git a/deps/jansson/test/suites/invalid/unicode-identifier/error b/deps/jansson/test/suites/invalid/unicode-identifier/error deleted file mode 100644 index 178b0dd..0000000 --- a/deps/jansson/test/suites/invalid/unicode-identifier/error +++ /dev/null @@ -1,2 +0,0 @@ -1 1 2 -'[' or '{' expected near 'Ć„' diff --git a/deps/jansson/test/suites/invalid/unicode-identifier/input b/deps/jansson/test/suites/invalid/unicode-identifier/input deleted file mode 100644 index aad321c..0000000 --- a/deps/jansson/test/suites/invalid/unicode-identifier/input +++ /dev/null @@ -1 +0,0 @@ -Ć„ diff --git a/deps/jansson/test/suites/invalid/unterminated-array-and-object/error.normal b/deps/jansson/test/suites/invalid/unterminated-array-and-object/error.normal deleted file mode 100644 index 5b19804..0000000 --- a/deps/jansson/test/suites/invalid/unterminated-array-and-object/error.normal +++ /dev/null @@ -1,2 +0,0 @@ -2 0 3 -string or '}' expected near end of file diff --git a/deps/jansson/test/suites/invalid/unterminated-array-and-object/error.strip b/deps/jansson/test/suites/invalid/unterminated-array-and-object/error.strip deleted file mode 100644 index da2bb22..0000000 --- a/deps/jansson/test/suites/invalid/unterminated-array-and-object/error.strip +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -string or '}' expected near end of file diff --git a/deps/jansson/test/suites/invalid/unterminated-array-and-object/input b/deps/jansson/test/suites/invalid/unterminated-array-and-object/input deleted file mode 100644 index cd9dc64..0000000 --- a/deps/jansson/test/suites/invalid/unterminated-array-and-object/input +++ /dev/null @@ -1 +0,0 @@ -[{ diff --git a/deps/jansson/test/suites/invalid/unterminated-array/error.normal b/deps/jansson/test/suites/invalid/unterminated-array/error.normal deleted file mode 100644 index 8025ed1..0000000 --- a/deps/jansson/test/suites/invalid/unterminated-array/error.normal +++ /dev/null @@ -1,2 +0,0 @@ -2 0 5 -']' expected near end of file diff --git a/deps/jansson/test/suites/invalid/unterminated-array/error.strip b/deps/jansson/test/suites/invalid/unterminated-array/error.strip deleted file mode 100644 index 495d0f7..0000000 --- a/deps/jansson/test/suites/invalid/unterminated-array/error.strip +++ /dev/null @@ -1,2 +0,0 @@ -1 4 4 -']' expected near end of file diff --git a/deps/jansson/test/suites/invalid/unterminated-array/input b/deps/jansson/test/suites/invalid/unterminated-array/input deleted file mode 100644 index 727ee81..0000000 --- a/deps/jansson/test/suites/invalid/unterminated-array/input +++ /dev/null @@ -1 +0,0 @@ -["a" diff --git a/deps/jansson/test/suites/invalid/unterminated-empty-key/error.normal b/deps/jansson/test/suites/invalid/unterminated-empty-key/error.normal deleted file mode 100644 index 3d646ab..0000000 --- a/deps/jansson/test/suites/invalid/unterminated-empty-key/error.normal +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -unexpected newline near '"' diff --git a/deps/jansson/test/suites/invalid/unterminated-empty-key/error.strip b/deps/jansson/test/suites/invalid/unterminated-empty-key/error.strip deleted file mode 100644 index 94f1947..0000000 --- a/deps/jansson/test/suites/invalid/unterminated-empty-key/error.strip +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -premature end of input near '"' diff --git a/deps/jansson/test/suites/invalid/unterminated-empty-key/input b/deps/jansson/test/suites/invalid/unterminated-empty-key/input deleted file mode 100644 index 4117452..0000000 --- a/deps/jansson/test/suites/invalid/unterminated-empty-key/input +++ /dev/null @@ -1 +0,0 @@ -{" diff --git a/deps/jansson/test/suites/invalid/unterminated-key/error.normal b/deps/jansson/test/suites/invalid/unterminated-key/error.normal deleted file mode 100644 index 5f09b77..0000000 --- a/deps/jansson/test/suites/invalid/unterminated-key/error.normal +++ /dev/null @@ -1,2 +0,0 @@ -1 3 3 -unexpected newline near '"a' diff --git a/deps/jansson/test/suites/invalid/unterminated-key/error.strip b/deps/jansson/test/suites/invalid/unterminated-key/error.strip deleted file mode 100644 index 8b6bec4..0000000 --- a/deps/jansson/test/suites/invalid/unterminated-key/error.strip +++ /dev/null @@ -1,2 +0,0 @@ -1 3 3 -premature end of input near '"a' diff --git a/deps/jansson/test/suites/invalid/unterminated-key/input b/deps/jansson/test/suites/invalid/unterminated-key/input deleted file mode 100644 index 705948c..0000000 --- a/deps/jansson/test/suites/invalid/unterminated-key/input +++ /dev/null @@ -1 +0,0 @@ -{"a diff --git a/deps/jansson/test/suites/invalid/unterminated-object-and-array/error b/deps/jansson/test/suites/invalid/unterminated-object-and-array/error deleted file mode 100644 index ed97be7..0000000 --- a/deps/jansson/test/suites/invalid/unterminated-object-and-array/error +++ /dev/null @@ -1,2 +0,0 @@ -1 2 2 -string or '}' expected near '[' diff --git a/deps/jansson/test/suites/invalid/unterminated-object-and-array/input b/deps/jansson/test/suites/invalid/unterminated-object-and-array/input deleted file mode 100644 index da35a86..0000000 --- a/deps/jansson/test/suites/invalid/unterminated-object-and-array/input +++ /dev/null @@ -1 +0,0 @@ -{[ diff --git a/deps/jansson/test/suites/invalid/unterminated-string/error.normal b/deps/jansson/test/suites/invalid/unterminated-string/error.normal deleted file mode 100644 index 5f09b77..0000000 --- a/deps/jansson/test/suites/invalid/unterminated-string/error.normal +++ /dev/null @@ -1,2 +0,0 @@ -1 3 3 -unexpected newline near '"a' diff --git a/deps/jansson/test/suites/invalid/unterminated-string/error.strip b/deps/jansson/test/suites/invalid/unterminated-string/error.strip deleted file mode 100644 index 8b6bec4..0000000 --- a/deps/jansson/test/suites/invalid/unterminated-string/error.strip +++ /dev/null @@ -1,2 +0,0 @@ -1 3 3 -premature end of input near '"a' diff --git a/deps/jansson/test/suites/invalid/unterminated-string/input b/deps/jansson/test/suites/invalid/unterminated-string/input deleted file mode 100644 index 38ab6b0..0000000 --- a/deps/jansson/test/suites/invalid/unterminated-string/input +++ /dev/null @@ -1 +0,0 @@ -["a diff --git a/deps/jansson/test/suites/valid/complex-array/env b/deps/jansson/test/suites/valid/complex-array/env deleted file mode 100644 index bd89eff..0000000 --- a/deps/jansson/test/suites/valid/complex-array/env +++ /dev/null @@ -1 +0,0 @@ -JSON_SORT_KEYS=1 \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/complex-array/input b/deps/jansson/test/suites/valid/complex-array/input deleted file mode 100644 index 1b9bbb9..0000000 --- a/deps/jansson/test/suites/valid/complex-array/input +++ /dev/null @@ -1,5 +0,0 @@ -[1,2,3,4, -"a", "b", "c", -{"foo": "bar", "core": "dump"}, -true, false, true, true, null, false -] diff --git a/deps/jansson/test/suites/valid/complex-array/output b/deps/jansson/test/suites/valid/complex-array/output deleted file mode 100644 index 7aefe56..0000000 --- a/deps/jansson/test/suites/valid/complex-array/output +++ /dev/null @@ -1 +0,0 @@ -[1, 2, 3, 4, "a", "b", "c", {"core": "dump", "foo": "bar"}, true, false, true, true, null, false] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/empty-array/input b/deps/jansson/test/suites/valid/empty-array/input deleted file mode 100644 index fe51488..0000000 --- a/deps/jansson/test/suites/valid/empty-array/input +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/deps/jansson/test/suites/valid/empty-array/output b/deps/jansson/test/suites/valid/empty-array/output deleted file mode 100644 index 0637a08..0000000 --- a/deps/jansson/test/suites/valid/empty-array/output +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/empty-object-in-array/input b/deps/jansson/test/suites/valid/empty-object-in-array/input deleted file mode 100644 index 93d5140..0000000 --- a/deps/jansson/test/suites/valid/empty-object-in-array/input +++ /dev/null @@ -1 +0,0 @@ -[{}] diff --git a/deps/jansson/test/suites/valid/empty-object-in-array/output b/deps/jansson/test/suites/valid/empty-object-in-array/output deleted file mode 100644 index ee1aac4..0000000 --- a/deps/jansson/test/suites/valid/empty-object-in-array/output +++ /dev/null @@ -1 +0,0 @@ -[{}] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/empty-object/input b/deps/jansson/test/suites/valid/empty-object/input deleted file mode 100644 index 0967ef4..0000000 --- a/deps/jansson/test/suites/valid/empty-object/input +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/deps/jansson/test/suites/valid/empty-object/output b/deps/jansson/test/suites/valid/empty-object/output deleted file mode 100644 index 9e26dfe..0000000 --- a/deps/jansson/test/suites/valid/empty-object/output +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/empty-string/input b/deps/jansson/test/suites/valid/empty-string/input deleted file mode 100644 index 66a1e18..0000000 --- a/deps/jansson/test/suites/valid/empty-string/input +++ /dev/null @@ -1 +0,0 @@ -[""] diff --git a/deps/jansson/test/suites/valid/empty-string/output b/deps/jansson/test/suites/valid/empty-string/output deleted file mode 100644 index 93b6be2..0000000 --- a/deps/jansson/test/suites/valid/empty-string/output +++ /dev/null @@ -1 +0,0 @@ -[""] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/escaped-utf-control-char/input b/deps/jansson/test/suites/valid/escaped-utf-control-char/input deleted file mode 100644 index 9a98545..0000000 --- a/deps/jansson/test/suites/valid/escaped-utf-control-char/input +++ /dev/null @@ -1 +0,0 @@ -["\u0012 escaped control character"] diff --git a/deps/jansson/test/suites/valid/escaped-utf-control-char/output b/deps/jansson/test/suites/valid/escaped-utf-control-char/output deleted file mode 100644 index 07221b7..0000000 --- a/deps/jansson/test/suites/valid/escaped-utf-control-char/output +++ /dev/null @@ -1 +0,0 @@ -["\u0012 escaped control character"] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/false/input b/deps/jansson/test/suites/valid/false/input deleted file mode 100644 index 4343652..0000000 --- a/deps/jansson/test/suites/valid/false/input +++ /dev/null @@ -1 +0,0 @@ -[false] diff --git a/deps/jansson/test/suites/valid/false/output b/deps/jansson/test/suites/valid/false/output deleted file mode 100644 index 67b2f07..0000000 --- a/deps/jansson/test/suites/valid/false/output +++ /dev/null @@ -1 +0,0 @@ -[false] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/negative-int/input b/deps/jansson/test/suites/valid/negative-int/input deleted file mode 100644 index a96d5cd..0000000 --- a/deps/jansson/test/suites/valid/negative-int/input +++ /dev/null @@ -1 +0,0 @@ -[-123] diff --git a/deps/jansson/test/suites/valid/negative-int/output b/deps/jansson/test/suites/valid/negative-int/output deleted file mode 100644 index 8e30f8b..0000000 --- a/deps/jansson/test/suites/valid/negative-int/output +++ /dev/null @@ -1 +0,0 @@ -[-123] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/negative-one/input b/deps/jansson/test/suites/valid/negative-one/input deleted file mode 100644 index 2363a1a..0000000 --- a/deps/jansson/test/suites/valid/negative-one/input +++ /dev/null @@ -1 +0,0 @@ -[-1] diff --git a/deps/jansson/test/suites/valid/negative-one/output b/deps/jansson/test/suites/valid/negative-one/output deleted file mode 100644 index 99d21a2..0000000 --- a/deps/jansson/test/suites/valid/negative-one/output +++ /dev/null @@ -1 +0,0 @@ -[-1] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/negative-zero/input b/deps/jansson/test/suites/valid/negative-zero/input deleted file mode 100644 index 40fc49c..0000000 --- a/deps/jansson/test/suites/valid/negative-zero/input +++ /dev/null @@ -1 +0,0 @@ -[-0] diff --git a/deps/jansson/test/suites/valid/negative-zero/output b/deps/jansson/test/suites/valid/negative-zero/output deleted file mode 100644 index 6e7ea63..0000000 --- a/deps/jansson/test/suites/valid/negative-zero/output +++ /dev/null @@ -1 +0,0 @@ -[0] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/null/input b/deps/jansson/test/suites/valid/null/input deleted file mode 100644 index 62864b3..0000000 --- a/deps/jansson/test/suites/valid/null/input +++ /dev/null @@ -1 +0,0 @@ -[null] diff --git a/deps/jansson/test/suites/valid/null/output b/deps/jansson/test/suites/valid/null/output deleted file mode 100644 index 500db4a..0000000 --- a/deps/jansson/test/suites/valid/null/output +++ /dev/null @@ -1 +0,0 @@ -[null] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/one-byte-utf-8/input b/deps/jansson/test/suites/valid/one-byte-utf-8/input deleted file mode 100644 index 8bda468..0000000 --- a/deps/jansson/test/suites/valid/one-byte-utf-8/input +++ /dev/null @@ -1 +0,0 @@ -["\u002c one-byte UTF-8"] diff --git a/deps/jansson/test/suites/valid/one-byte-utf-8/output b/deps/jansson/test/suites/valid/one-byte-utf-8/output deleted file mode 100644 index c33d250..0000000 --- a/deps/jansson/test/suites/valid/one-byte-utf-8/output +++ /dev/null @@ -1 +0,0 @@ -[", one-byte UTF-8"] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/real-capital-e-negative-exponent/input b/deps/jansson/test/suites/valid/real-capital-e-negative-exponent/input deleted file mode 100644 index 1e9fa51..0000000 --- a/deps/jansson/test/suites/valid/real-capital-e-negative-exponent/input +++ /dev/null @@ -1 +0,0 @@ -[1E-2] diff --git a/deps/jansson/test/suites/valid/real-capital-e-negative-exponent/output b/deps/jansson/test/suites/valid/real-capital-e-negative-exponent/output deleted file mode 100644 index 75b9ef9..0000000 --- a/deps/jansson/test/suites/valid/real-capital-e-negative-exponent/output +++ /dev/null @@ -1 +0,0 @@ -[0.01] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/real-capital-e-positive-exponent/input b/deps/jansson/test/suites/valid/real-capital-e-positive-exponent/input deleted file mode 100644 index 6a6ab93..0000000 --- a/deps/jansson/test/suites/valid/real-capital-e-positive-exponent/input +++ /dev/null @@ -1 +0,0 @@ -[1E+2] diff --git a/deps/jansson/test/suites/valid/real-capital-e-positive-exponent/output b/deps/jansson/test/suites/valid/real-capital-e-positive-exponent/output deleted file mode 100644 index d8ff702..0000000 --- a/deps/jansson/test/suites/valid/real-capital-e-positive-exponent/output +++ /dev/null @@ -1 +0,0 @@ -[100.0] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/real-capital-e/input b/deps/jansson/test/suites/valid/real-capital-e/input deleted file mode 100644 index e703223..0000000 --- a/deps/jansson/test/suites/valid/real-capital-e/input +++ /dev/null @@ -1 +0,0 @@ -[1E22] diff --git a/deps/jansson/test/suites/valid/real-capital-e/output b/deps/jansson/test/suites/valid/real-capital-e/output deleted file mode 100644 index 9a739f2..0000000 --- a/deps/jansson/test/suites/valid/real-capital-e/output +++ /dev/null @@ -1 +0,0 @@ -[1e22] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/real-exponent/input b/deps/jansson/test/suites/valid/real-exponent/input deleted file mode 100644 index b2a69b9..0000000 --- a/deps/jansson/test/suites/valid/real-exponent/input +++ /dev/null @@ -1 +0,0 @@ -[123e45] diff --git a/deps/jansson/test/suites/valid/real-exponent/output b/deps/jansson/test/suites/valid/real-exponent/output deleted file mode 100644 index 5ffc719..0000000 --- a/deps/jansson/test/suites/valid/real-exponent/output +++ /dev/null @@ -1 +0,0 @@ -[1.2299999999999999e47] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/real-fraction-exponent/input b/deps/jansson/test/suites/valid/real-fraction-exponent/input deleted file mode 100644 index 0c1660d..0000000 --- a/deps/jansson/test/suites/valid/real-fraction-exponent/input +++ /dev/null @@ -1 +0,0 @@ -[123.456e78] diff --git a/deps/jansson/test/suites/valid/real-fraction-exponent/output b/deps/jansson/test/suites/valid/real-fraction-exponent/output deleted file mode 100644 index 66a3c81..0000000 --- a/deps/jansson/test/suites/valid/real-fraction-exponent/output +++ /dev/null @@ -1 +0,0 @@ -[1.23456e80] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/real-negative-exponent/input b/deps/jansson/test/suites/valid/real-negative-exponent/input deleted file mode 100644 index daa4af9..0000000 --- a/deps/jansson/test/suites/valid/real-negative-exponent/input +++ /dev/null @@ -1 +0,0 @@ -[1e-2] diff --git a/deps/jansson/test/suites/valid/real-negative-exponent/output b/deps/jansson/test/suites/valid/real-negative-exponent/output deleted file mode 100644 index 75b9ef9..0000000 --- a/deps/jansson/test/suites/valid/real-negative-exponent/output +++ /dev/null @@ -1 +0,0 @@ -[0.01] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/real-positive-exponent/input b/deps/jansson/test/suites/valid/real-positive-exponent/input deleted file mode 100644 index f378077..0000000 --- a/deps/jansson/test/suites/valid/real-positive-exponent/input +++ /dev/null @@ -1 +0,0 @@ -[1e+2] diff --git a/deps/jansson/test/suites/valid/real-positive-exponent/output b/deps/jansson/test/suites/valid/real-positive-exponent/output deleted file mode 100644 index d8ff702..0000000 --- a/deps/jansson/test/suites/valid/real-positive-exponent/output +++ /dev/null @@ -1 +0,0 @@ -[100.0] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/real-underflow/input b/deps/jansson/test/suites/valid/real-underflow/input deleted file mode 100644 index dc70996..0000000 --- a/deps/jansson/test/suites/valid/real-underflow/input +++ /dev/null @@ -1 +0,0 @@ -[123e-10000000] diff --git a/deps/jansson/test/suites/valid/real-underflow/output b/deps/jansson/test/suites/valid/real-underflow/output deleted file mode 100644 index 92df1df..0000000 --- a/deps/jansson/test/suites/valid/real-underflow/output +++ /dev/null @@ -1 +0,0 @@ -[0.0] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/run b/deps/jansson/test/suites/valid/run deleted file mode 100755 index c30d94a..0000000 --- a/deps/jansson/test/suites/valid/run +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2009-2013 Petri Lehtinen -# -# Jansson is free software; you can redistribute it and/or modify -# it under the terms of the MIT license. See LICENSE for details. - -JSON_SORT_KEYS=1 -export JSON_SORT_KEYS - -is_test() { - test -d $test_path -} - -do_run() { - variant=$1 - s=".$1" - - strip=0 - [ "$variant" = "strip" ] && strip=1 - - STRIP=$strip $json_process --env \ - <$test_path/input >$test_log/stdout$s 2>$test_log/stderr$s - valgrind_check $test_log/stderr$s || return 1 - - ref=output - [ -f $test_path/output$s ] && ref=output$s - - if ! cmp -s $test_path/$ref $test_log/stdout$s; then - echo $variant > $test_log/variant - return 1 - fi -} - -run_test() { - do_run normal && do_run strip -} - -show_error() { - valgrind_show_error && return - - read variant < $test_log/variant - s=".$variant" - - echo "VARIANT: $variant" - - echo "EXPECTED OUTPUT:" - ref=output - [ -f $test_path/output$s ] && ref=output$s - nl -bn $test_path/$ref - - echo "ACTUAL OUTPUT:" - nl -bn $test_log/stdout$s -} - -. $top_srcdir/test/scripts/run-tests.sh diff --git a/deps/jansson/test/suites/valid/short-string/input b/deps/jansson/test/suites/valid/short-string/input deleted file mode 100644 index 0c3426d..0000000 --- a/deps/jansson/test/suites/valid/short-string/input +++ /dev/null @@ -1 +0,0 @@ -["a"] diff --git a/deps/jansson/test/suites/valid/short-string/output b/deps/jansson/test/suites/valid/short-string/output deleted file mode 100644 index eac5f7b..0000000 --- a/deps/jansson/test/suites/valid/short-string/output +++ /dev/null @@ -1 +0,0 @@ -["a"] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/simple-ascii-string/input b/deps/jansson/test/suites/valid/simple-ascii-string/input deleted file mode 100644 index 929b215..0000000 --- a/deps/jansson/test/suites/valid/simple-ascii-string/input +++ /dev/null @@ -1 +0,0 @@ -["abcdefghijklmnopqrstuvwxyz1234567890 "] diff --git a/deps/jansson/test/suites/valid/simple-ascii-string/output b/deps/jansson/test/suites/valid/simple-ascii-string/output deleted file mode 100644 index 90358ab..0000000 --- a/deps/jansson/test/suites/valid/simple-ascii-string/output +++ /dev/null @@ -1 +0,0 @@ -["abcdefghijklmnopqrstuvwxyz1234567890 "] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/simple-int-0/input b/deps/jansson/test/suites/valid/simple-int-0/input deleted file mode 100644 index 111bb86..0000000 --- a/deps/jansson/test/suites/valid/simple-int-0/input +++ /dev/null @@ -1 +0,0 @@ -[0] diff --git a/deps/jansson/test/suites/valid/simple-int-0/output b/deps/jansson/test/suites/valid/simple-int-0/output deleted file mode 100644 index 6e7ea63..0000000 --- a/deps/jansson/test/suites/valid/simple-int-0/output +++ /dev/null @@ -1 +0,0 @@ -[0] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/simple-int-1/input b/deps/jansson/test/suites/valid/simple-int-1/input deleted file mode 100644 index 7660873..0000000 --- a/deps/jansson/test/suites/valid/simple-int-1/input +++ /dev/null @@ -1 +0,0 @@ -[1] diff --git a/deps/jansson/test/suites/valid/simple-int-1/output b/deps/jansson/test/suites/valid/simple-int-1/output deleted file mode 100644 index bace2a0..0000000 --- a/deps/jansson/test/suites/valid/simple-int-1/output +++ /dev/null @@ -1 +0,0 @@ -[1] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/simple-int-123/input b/deps/jansson/test/suites/valid/simple-int-123/input deleted file mode 100644 index 3214bfe..0000000 --- a/deps/jansson/test/suites/valid/simple-int-123/input +++ /dev/null @@ -1 +0,0 @@ -[123] diff --git a/deps/jansson/test/suites/valid/simple-int-123/output b/deps/jansson/test/suites/valid/simple-int-123/output deleted file mode 100644 index e47f69a..0000000 --- a/deps/jansson/test/suites/valid/simple-int-123/output +++ /dev/null @@ -1 +0,0 @@ -[123] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/simple-object/input b/deps/jansson/test/suites/valid/simple-object/input deleted file mode 100644 index a34fb49..0000000 --- a/deps/jansson/test/suites/valid/simple-object/input +++ /dev/null @@ -1 +0,0 @@ -{"a":[]} diff --git a/deps/jansson/test/suites/valid/simple-object/output b/deps/jansson/test/suites/valid/simple-object/output deleted file mode 100644 index 982abe8..0000000 --- a/deps/jansson/test/suites/valid/simple-object/output +++ /dev/null @@ -1 +0,0 @@ -{"a": []} \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/simple-real/input b/deps/jansson/test/suites/valid/simple-real/input deleted file mode 100644 index 0fed7df..0000000 --- a/deps/jansson/test/suites/valid/simple-real/input +++ /dev/null @@ -1 +0,0 @@ -[123.456789] diff --git a/deps/jansson/test/suites/valid/simple-real/output b/deps/jansson/test/suites/valid/simple-real/output deleted file mode 100644 index b02878e..0000000 --- a/deps/jansson/test/suites/valid/simple-real/output +++ /dev/null @@ -1 +0,0 @@ -[123.456789] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/string-escapes/input b/deps/jansson/test/suites/valid/string-escapes/input deleted file mode 100644 index d994564..0000000 --- a/deps/jansson/test/suites/valid/string-escapes/input +++ /dev/null @@ -1 +0,0 @@ -["\"\\\/\b\f\n\r\t"] diff --git a/deps/jansson/test/suites/valid/string-escapes/output b/deps/jansson/test/suites/valid/string-escapes/output deleted file mode 100644 index ca5c1c6..0000000 --- a/deps/jansson/test/suites/valid/string-escapes/output +++ /dev/null @@ -1 +0,0 @@ -["\"\\/\b\f\n\r\t"] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/three-byte-utf-8/input b/deps/jansson/test/suites/valid/three-byte-utf-8/input deleted file mode 100644 index ccc0bfa..0000000 --- a/deps/jansson/test/suites/valid/three-byte-utf-8/input +++ /dev/null @@ -1 +0,0 @@ -["\u0821 three-byte UTF-8"] diff --git a/deps/jansson/test/suites/valid/three-byte-utf-8/output b/deps/jansson/test/suites/valid/three-byte-utf-8/output deleted file mode 100644 index c44d124..0000000 --- a/deps/jansson/test/suites/valid/three-byte-utf-8/output +++ /dev/null @@ -1 +0,0 @@ -["ą ” three-byte UTF-8"] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/true/input b/deps/jansson/test/suites/valid/true/input deleted file mode 100644 index 29513c4..0000000 --- a/deps/jansson/test/suites/valid/true/input +++ /dev/null @@ -1 +0,0 @@ -[true] diff --git a/deps/jansson/test/suites/valid/true/output b/deps/jansson/test/suites/valid/true/output deleted file mode 100644 index de601e3..0000000 --- a/deps/jansson/test/suites/valid/true/output +++ /dev/null @@ -1 +0,0 @@ -[true] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/two-byte-utf-8/input b/deps/jansson/test/suites/valid/two-byte-utf-8/input deleted file mode 100644 index 05ae854..0000000 --- a/deps/jansson/test/suites/valid/two-byte-utf-8/input +++ /dev/null @@ -1 +0,0 @@ -["\u0123 two-byte UTF-8"] diff --git a/deps/jansson/test/suites/valid/two-byte-utf-8/output b/deps/jansson/test/suites/valid/two-byte-utf-8/output deleted file mode 100644 index 1f0988d..0000000 --- a/deps/jansson/test/suites/valid/two-byte-utf-8/output +++ /dev/null @@ -1 +0,0 @@ -["Ä£ two-byte UTF-8"] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/utf-8-string/input b/deps/jansson/test/suites/valid/utf-8-string/input deleted file mode 100644 index 20dc64a..0000000 --- a/deps/jansson/test/suites/valid/utf-8-string/input +++ /dev/null @@ -1 +0,0 @@ -["ā‚¬Ć¾Ä±Å“É™ĆŸĆ° some utf-8 ÄøŹ’Ć—Å‹ĀµĆ„Ƥƶš„ž"] diff --git a/deps/jansson/test/suites/valid/utf-8-string/output b/deps/jansson/test/suites/valid/utf-8-string/output deleted file mode 100644 index 5372865..0000000 --- a/deps/jansson/test/suites/valid/utf-8-string/output +++ /dev/null @@ -1 +0,0 @@ -["ā‚¬Ć¾Ä±Å“É™ĆŸĆ° some utf-8 ÄøŹ’Ć—Å‹ĀµĆ„Ƥƶš„ž"] \ No newline at end of file diff --git a/deps/jansson/test/suites/valid/utf-surrogate-four-byte-encoding/input b/deps/jansson/test/suites/valid/utf-surrogate-four-byte-encoding/input deleted file mode 100644 index c598b41..0000000 --- a/deps/jansson/test/suites/valid/utf-surrogate-four-byte-encoding/input +++ /dev/null @@ -1 +0,0 @@ -["\uD834\uDD1E surrogate, four-byte UTF-8"] diff --git a/deps/jansson/test/suites/valid/utf-surrogate-four-byte-encoding/output b/deps/jansson/test/suites/valid/utf-surrogate-four-byte-encoding/output deleted file mode 100644 index fa806d2..0000000 --- a/deps/jansson/test/suites/valid/utf-surrogate-four-byte-encoding/output +++ /dev/null @@ -1 +0,0 @@ -["š„ž surrogate, four-byte UTF-8"] \ No newline at end of file diff --git a/deps/jansson/win32/jansson_config.h b/deps/jansson/win32/jansson_config.h deleted file mode 100644 index ab1da5d..0000000 --- a/deps/jansson/win32/jansson_config.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2010-2013 Petri Lehtinen - * - * Jansson is free software; you can redistribute it and/or modify - * it under the terms of the MIT license. See LICENSE for details. - * - * - * This file specifies a part of the site-specific configuration for - * Jansson, namely those things that affect the public API in - * jansson.h. - * - * The configure script copies this file to jansson_config.h and - * replaces @var@ substitutions by values that fit your system. If you - * cannot run the configure script, you can do the value substitution - * by hand. - */ - -#ifndef JANSSON_CONFIG_H -#define JANSSON_CONFIG_H - -/* If your compiler supports the inline keyword in C, JSON_INLINE is - defined to `inline', otherwise empty. In C++, the inline is always - supported. */ -#ifdef __cplusplus -#define JSON_INLINE inline -#else -#define JSON_INLINE __inline -#endif - -/* If your compiler supports the `long long` type and the strtoll() - library function, JSON_INTEGER_IS_LONG_LONG is defined to 1, - otherwise to 0. */ -#define JSON_INTEGER_IS_LONG_LONG 1 - -/* If locale.h and localeconv() are available, define to 1, - otherwise to 0. */ -#define JSON_HAVE_LOCALECONV 1 - -#endif diff --git a/deps/jansson/win32/vs2010/jansson.sln b/deps/jansson/win32/vs2010/jansson.sln deleted file mode 100644 index f5640eb..0000000 --- a/deps/jansson/win32/vs2010/jansson.sln +++ /dev/null @@ -1,26 +0,0 @@ -ļ»æ -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jansson", "jansson.vcxproj", "{76226D20-1972-4789-A595-EDACC7A76DC3}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {76226D20-1972-4789-A595-EDACC7A76DC3}.Debug|Win32.ActiveCfg = Debug|Win32 - {76226D20-1972-4789-A595-EDACC7A76DC3}.Debug|Win32.Build.0 = Debug|Win32 - {76226D20-1972-4789-A595-EDACC7A76DC3}.Debug|x64.ActiveCfg = Debug|x64 - {76226D20-1972-4789-A595-EDACC7A76DC3}.Debug|x64.Build.0 = Debug|x64 - {76226D20-1972-4789-A595-EDACC7A76DC3}.Release|Win32.ActiveCfg = Release|Win32 - {76226D20-1972-4789-A595-EDACC7A76DC3}.Release|Win32.Build.0 = Release|Win32 - {76226D20-1972-4789-A595-EDACC7A76DC3}.Release|x64.ActiveCfg = Release|x64 - {76226D20-1972-4789-A595-EDACC7A76DC3}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/deps/jansson/win32/vs2010/jansson.vcxproj b/deps/jansson/win32/vs2010/jansson.vcxproj deleted file mode 100644 index 1fe675a..0000000 --- a/deps/jansson/win32/vs2010/jansson.vcxproj +++ /dev/null @@ -1,181 +0,0 @@ -ļ»æ - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - - - - - - - - - - - - - - - - - - - - - {76226D20-1972-4789-A595-EDACC7A76DC3} - Win32Proj - jansson_dll - jansson - - - - StaticLibrary - true - Unicode - v120 - - - StaticLibrary - true - Unicode - v120 - - - StaticLibrary - false - true - Unicode - v120 - - - StaticLibrary - false - true - Unicode - v120 - - - - - - - - - - - - - - - - - - - true - Output\$(Configuration)\ - Build\$(Configuration)\ - - - true - Output\$(Configuration)\ - Build\$(Configuration)\ - - - false - Output\$(Configuration)\ - Build\$(Configuration)\ - - - false - Output\$(Configuration)\ - Build\$(Configuration)\ - - - - NotUsing - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;JANSSON_DLL_EXPORTS;%(PreprocessorDefinitions) - .. - 4996 - - - Windows - true - ../../src/jansson.def - - - - - NotUsing - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;JANSSON_DLL_EXPORTS;%(PreprocessorDefinitions) - .. - 4996 - - - Windows - true - ../../src/jansson.def - - - - - Level3 - NotUsing - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;JANSSON_DLL_EXPORTS;%(PreprocessorDefinitions) - .. - 4996 - - - Windows - true - true - true - ../../src/jansson.def - - - - - Level3 - NotUsing - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;JANSSON_DLL_EXPORTS;%(PreprocessorDefinitions) - .. - 4996 - - - Windows - true - true - true - ../../src/jansson.def - - - - - - \ No newline at end of file diff --git a/deps/jansson/win32/vs2010/jansson.vcxproj.filters b/deps/jansson/win32/vs2010/jansson.vcxproj.filters deleted file mode 100644 index f8eee30..0000000 --- a/deps/jansson/win32/vs2010/jansson.vcxproj.filters +++ /dev/null @@ -1,69 +0,0 @@ -ļ»æ - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/deps/jansson/win32/vs2010/jansson.vcxproj.user b/deps/jansson/win32/vs2010/jansson.vcxproj.user deleted file mode 100644 index ace9a86..0000000 --- a/deps/jansson/win32/vs2010/jansson.vcxproj.user +++ /dev/null @@ -1,3 +0,0 @@ -ļ»æ - - \ No newline at end of file diff --git a/deps/lzma/CMakeLists.txt b/deps/lzma/CMakeLists.txt deleted file mode 100644 index e5e9d15..0000000 --- a/deps/lzma/CMakeLists.txt +++ /dev/null @@ -1,145 +0,0 @@ -cmake_minimum_required(VERSION 3.2) - -project(lzma) - -set(LIBLZMA_INCLUDE_DIRS - "${CMAKE_CURRENT_SOURCE_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}/liblzma/api" - CACHE PATH "lzma include path") - -set(LIBLZMA_CONFIG - "${CMAKE_CURRENT_SOURCE_DIR}/config.h" - CACHE PATH "lzma config.h path") - -include_directories( - ${LIBLZMA_INCLUDE_DIRS} - common - liblzma/api - liblzma/check - liblzma/common - liblzma/delta - liblzma/lz - liblzma/lzma - liblzma/rangecoder - liblzma/simple -) - -add_definitions( - -DHAVE_CONFIG_H - -DTUKLIB_SYMBOL_PREFIX=lzma_) - -if(WIN32) - if(MSVC) - add_compile_options("$<$:/MT>") - endif() - add_definitions( - -Dinline=_inline - -Drestrict=__restrict) -endif() - -set(liblzma_check_SOURCES - liblzma/check/check.c) - -list(APPEND liblzma_check_SOURCES - liblzma/check/crc32_table.c - liblzma/check/crc32_fast.c - liblzma/check/crc64_table.c - liblzma/check/crc64_fast.c - liblzma/check/sha256.c) - -set(liblzma_common_SOURCES - liblzma/common/common.c - liblzma/common/block_util.c - liblzma/common/easy_preset.c - liblzma/common/filter_common.c - liblzma/common/hardware_physmem.c - liblzma/common/index.c - liblzma/common/stream_flags_common.c - liblzma/common/vli_size.c - liblzma/common/alone_encoder.c - liblzma/common/block_buffer_encoder.c - liblzma/common/block_encoder.c - liblzma/common/block_header_encoder.c - liblzma/common/easy_buffer_encoder.c - liblzma/common/easy_encoder.c - liblzma/common/easy_encoder_memusage.c - liblzma/common/filter_buffer_encoder.c - liblzma/common/filter_encoder.c - liblzma/common/filter_flags_encoder.c - liblzma/common/index_encoder.c - liblzma/common/stream_buffer_encoder.c - liblzma/common/stream_encoder.c - liblzma/common/stream_flags_encoder.c - liblzma/common/vli_encoder.c - liblzma/common/alone_decoder.c - liblzma/common/auto_decoder.c - liblzma/common/block_buffer_decoder.c - liblzma/common/block_decoder.c - liblzma/common/block_header_decoder.c - liblzma/common/easy_decoder_memusage.c - liblzma/common/filter_buffer_decoder.c - liblzma/common/filter_decoder.c - liblzma/common/filter_flags_decoder.c - liblzma/common/index_decoder.c - liblzma/common/index_hash.c - liblzma/common/stream_buffer_decoder.c - liblzma/common/stream_decoder.c - liblzma/common/stream_flags_decoder.c - liblzma/common/vli_decoder.c) - -set(liblzma_delta_SOURCES - liblzma/delta/delta_common.c - liblzma/delta/delta_encoder.c - liblzma/delta/delta_decoder.c) - -set(liblzma_lzma_SOURCES - liblzma/lzma/lzma_encoder.c - liblzma/lzma/lzma_encoder_presets.c - liblzma/lzma/lzma_encoder_optimum_fast.c - liblzma/lzma/lzma_encoder_optimum_normal.c - liblzma/lzma/fastpos_table.c - liblzma/lzma/lzma_decoder.c - - liblzma/lzma/lzma2_encoder.c - liblzma/lzma/lzma2_decoder.c) - -set(liblzma_lz_SOURCES - liblzma/lz/lz_encoder.c - liblzma/lz/lz_encoder_mf.c - liblzma/lz/lz_decoder.c) - -set(liblzma_rangecoder_SOURCES - liblzma/rangecoder/price_table.c) - -set(liblzma_simple_SOURCES - liblzma/simple/simple_coder.c - liblzma/simple/simple_encoder.c - liblzma/simple/simple_decoder.c - - liblzma/simple/arm.c - liblzma/simple/armthumb.c - liblzma/simple/ia64.c - liblzma/simple/powerpc.c - liblzma/simple/sparc.c - liblzma/simple/x86.c) - -if (WIN32) - SET_SOURCE_FILES_PROPERTIES( - ${liblzma_check_SOURCES} - ${liblzma_common_SOURCES} - ${liblzma_delta_SOURCES} - ${liblzma_lz_SOURCES} - ${liblzma_lzma_SOURCES} - ${liblzma_rangecoder_SOURCES} - ${liblzma_simple_SOURCES} - PROPERTIES LANGUAGE C) -endif() - -add_library(lzma STATIC - ${liblzma_check_SOURCES} - ${liblzma_common_SOURCES} - ${liblzma_delta_SOURCES} - ${liblzma_lz_SOURCES} - ${liblzma_lzma_SOURCES} - ${liblzma_rangecoder_SOURCES} - ${liblzma_simple_SOURCES}) diff --git a/deps/lzma/common/common_w32res.rc b/deps/lzma/common/common_w32res.rc deleted file mode 100644 index fdb88d1..0000000 --- a/deps/lzma/common/common_w32res.rc +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - */ - -#include -#include "config.h" -#define LZMA_H_INTERNAL -#define LZMA_H_INTERNAL_RC -#include "lzma/version.h" - -#ifndef MY_BUILD -# define MY_BUILD 0 -#endif -#define MY_VERSION LZMA_VERSION_MAJOR,LZMA_VERSION_MINOR,LZMA_VERSION_PATCH,MY_BUILD - -#define MY_FILENAME MY_NAME MY_SUFFIX -#define MY_COMPANY "The Tukaani Project " -#define MY_PRODUCT PACKAGE_NAME " <" PACKAGE_URL ">" - -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -VS_VERSION_INFO VERSIONINFO - FILEVERSION MY_VERSION - PRODUCTVERSION MY_VERSION - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK - FILEFLAGS 0 - FILEOS VOS_NT_WINDOWS32 - FILETYPE MY_TYPE - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", MY_COMPANY - VALUE "FileDescription", MY_DESC - VALUE "FileVersion", LZMA_VERSION_STRING - VALUE "InternalName", MY_NAME - VALUE "OriginalFilename", MY_FILENAME - VALUE "ProductName", MY_PRODUCT - VALUE "ProductVersion", LZMA_VERSION_STRING - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END diff --git a/deps/lzma/common/mythread.h b/deps/lzma/common/mythread.h deleted file mode 100644 index 476c2fc..0000000 --- a/deps/lzma/common/mythread.h +++ /dev/null @@ -1,42 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file mythread.h -/// \brief Wrappers for threads -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "sysdefs.h" - - -#ifdef HAVE_PTHREAD -# include - -# define mythread_once(func) \ - do { \ - static pthread_once_t once_ = PTHREAD_ONCE_INIT; \ - pthread_once(&once_, &func); \ - } while (0) - -# define mythread_sigmask(how, set, oset) \ - pthread_sigmask(how, set, oset) - -#else - -# define mythread_once(func) \ - do { \ - static bool once_ = false; \ - if (!once_) { \ - func(); \ - once_ = true; \ - } \ - } while (0) - -# define mythread_sigmask(how, set, oset) \ - sigprocmask(how, set, oset) - -#endif diff --git a/deps/lzma/common/sysdefs.h b/deps/lzma/common/sysdefs.h deleted file mode 100644 index 6b823bd..0000000 --- a/deps/lzma/common/sysdefs.h +++ /dev/null @@ -1,199 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file sysdefs.h -/// \brief Common includes, definitions, system-specific things etc. -/// -/// This file is used also by the lzma command line tool, that's why this -/// file is separate from common.h. -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_SYSDEFS_H -#define LZMA_SYSDEFS_H - -////////////// -// Includes // -////////////// - -#ifdef HAVE_CONFIG_H -# include -#endif - -#if defined(_MSC_VER) && _MSC_VER >= 1400 -# define VC_EXTRALEAN -# include -# include -# undef VC_EXTRALEAN -#endif - -// Get standard-compliant stdio functions under MinGW and MinGW-w64. -#ifdef __MINGW32__ -# define __USE_MINGW_ANSI_STDIO 1 -#endif - -// size_t and NULL -#include - -#ifdef HAVE_INTTYPES_H -# include -#endif - -// C99 says that inttypes.h always includes stdint.h, but some systems -// don't do that, and require including stdint.h separately. -#ifdef HAVE_STDINT_H -# include -#endif - -// Some pre-C99 systems have SIZE_MAX in limits.h instead of stdint.h. The -// limits are also used to figure out some macros missing from pre-C99 systems. -#ifdef HAVE_LIMITS_H -# include -#endif - -// Be more compatible with systems that have non-conforming inttypes.h. -// We assume that int is 32-bit and that long is either 32-bit or 64-bit. -// Full Autoconf test could be more correct, but this should work well enough. -// Note that this duplicates some code from lzma.h, but this is better since -// we can work without inttypes.h thanks to Autoconf tests. -#ifndef UINT32_C -# if UINT_MAX != 4294967295U -# error UINT32_C is not defined and unsigned int is not 32-bit. -# endif -# define UINT32_C(n) n ## U -#endif -#ifndef UINT32_MAX -# define UINT32_MAX UINT32_C(4294967295) -#endif -#ifndef PRIu32 -# define PRIu32 "u" -#endif -#ifndef PRIx32 -# define PRIx32 "x" -#endif -#ifndef PRIX32 -# define PRIX32 "X" -#endif - -#if ULONG_MAX == 4294967295UL -# ifndef UINT64_C -# define UINT64_C(n) n ## ULL -# endif -# ifndef PRIu64 -# define PRIu64 "llu" -# endif -# ifndef PRIx64 -# define PRIx64 "llx" -# endif -# ifndef PRIX64 -# define PRIX64 "llX" -# endif -#else -# ifndef UINT64_C -# define UINT64_C(n) n ## UL -# endif -# ifndef PRIu64 -# define PRIu64 "lu" -# endif -# ifndef PRIx64 -# define PRIx64 "lx" -# endif -# ifndef PRIX64 -# define PRIX64 "lX" -# endif -#endif -#ifndef UINT64_MAX -# define UINT64_MAX UINT64_C(18446744073709551615) -#endif - -// Incorrect(?) SIZE_MAX: -// - Interix headers typedef size_t to unsigned long, -// but a few lines later define SIZE_MAX to INT32_MAX. -// - SCO OpenServer (x86) headers typedef size_t to unsigned int -// but define SIZE_MAX to INT32_MAX. -#if defined(__INTERIX) || defined(_SCO_DS) -# undef SIZE_MAX -#endif - -// The code currently assumes that size_t is either 32-bit or 64-bit. -#ifndef SIZE_MAX -# if SIZEOF_SIZE_T == 4 -# define SIZE_MAX UINT32_MAX -# elif SIZEOF_SIZE_T == 8 -# define SIZE_MAX UINT64_MAX -# else -# error size_t is not 32-bit or 64-bit -# endif -#endif -#if SIZE_MAX != UINT32_MAX && SIZE_MAX != UINT64_MAX -# error size_t is not 32-bit or 64-bit -#endif - -#include -#include - -// Pre-C99 systems lack stdbool.h. All the code in LZMA Utils must be written -// so that it works with fake bool type, for example: -// -// bool foo = (flags & 0x100) != 0; -// bool bar = !!(flags & 0x100); -// -// This works with the real C99 bool but breaks with fake bool: -// -// bool baz = (flags & 0x100); -// -#ifdef HAVE_STDBOOL_H -# include -#else -# if ! HAVE__BOOL -typedef unsigned char _Bool; -# endif -# define bool _Bool -# define false 0 -# define true 1 -# define __bool_true_false_are_defined 1 -#endif - -// string.h should be enough but let's include strings.h and memory.h too if -// they exists, since that shouldn't do any harm, but may improve portability. -#ifdef HAVE_STRING_H -# include -#endif - -#ifdef HAVE_STRINGS_H -# include -#endif - -#ifdef HAVE_MEMORY_H -# include -#endif - - -//////////// -// Macros // -//////////// - -#undef memzero -#define memzero(s, n) memset(s, 0, n) - -// NOTE: Avoid using MIN() and MAX(), because even conditionally defining -// those macros can cause some portability trouble, since on some systems -// the system headers insist defining their own versions. -#define my_min(x, y) ((x) < (y) ? (x) : (y)) -#define my_max(x, y) ((x) > (y) ? (x) : (y)) - -#ifndef ARRAY_SIZE -# define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) -#endif - -#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4 -# define lzma_attr_alloc_size(x) __attribute__((__alloc_size__(x))) -#else -# define lzma_attr_alloc_size(x) -#endif - -#endif diff --git a/deps/lzma/common/tuklib_common.h b/deps/lzma/common/tuklib_common.h deleted file mode 100644 index 31fbab5..0000000 --- a/deps/lzma/common/tuklib_common.h +++ /dev/null @@ -1,71 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file tuklib_common.h -/// \brief Common definitions for tuklib modules -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef TUKLIB_COMMON_H -#define TUKLIB_COMMON_H - -// The config file may be replaced by a package-specific file. -// It should include at least stddef.h, inttypes.h, and limits.h. -#include "tuklib_config.h" - -// TUKLIB_SYMBOL_PREFIX is prefixed to all symbols exported by -// the tuklib modules. If you use a tuklib module in a library, -// you should use TUKLIB_SYMBOL_PREFIX to make sure that there -// are no symbol conflicts in case someone links your library -// into application that also uses the same tuklib module. -#ifndef TUKLIB_SYMBOL_PREFIX -# define TUKLIB_SYMBOL_PREFIX -#endif - -#define TUKLIB_CAT_X(a, b) a ## b -#define TUKLIB_CAT(a, b) TUKLIB_CAT_X(a, b) - -#ifndef TUKLIB_SYMBOL -# define TUKLIB_SYMBOL(sym) TUKLIB_CAT(TUKLIB_SYMBOL_PREFIX, sym) -#endif - -#ifndef TUKLIB_DECLS_BEGIN -# ifdef __cplusplus -# define TUKLIB_DECLS_BEGIN extern "C" { -# else -# define TUKLIB_DECLS_BEGIN -# endif -#endif - -#ifndef TUKLIB_DECLS_END -# ifdef __cplusplus -# define TUKLIB_DECLS_END } -# else -# define TUKLIB_DECLS_END -# endif -#endif - -#if defined(__GNUC__) && defined(__GNUC_MINOR__) -# define TUKLIB_GNUC_REQ(major, minor) \ - ((__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)) \ - || __GNUC__ > (major)) -#else -# define TUKLIB_GNUC_REQ(major, minor) 0 -#endif - -#if TUKLIB_GNUC_REQ(2, 5) -# define tuklib_attr_noreturn __attribute__((__noreturn__)) -#else -# define tuklib_attr_noreturn -#endif - -#if (defined(_WIN32) && !defined(__CYGWIN__)) \ - || defined(__OS2__) || defined(__MSDOS__) -# define TUKLIB_DOSLIKE 1 -#endif - -#endif diff --git a/deps/lzma/common/tuklib_config.h b/deps/lzma/common/tuklib_config.h deleted file mode 100644 index 549cb24..0000000 --- a/deps/lzma/common/tuklib_config.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include "sysdefs.h" -#else -# include -# include -# include -#endif diff --git a/deps/lzma/common/tuklib_cpucores.c b/deps/lzma/common/tuklib_cpucores.c deleted file mode 100644 index 1da13df..0000000 --- a/deps/lzma/common/tuklib_cpucores.c +++ /dev/null @@ -1,62 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file tuklib_cpucores.c -/// \brief Get the number of CPU cores online -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "tuklib_cpucores.h" - -#if defined(TUKLIB_CPUCORES_SYSCTL) -# ifdef HAVE_SYS_PARAM_H -# include -# endif -# include - -#elif defined(TUKLIB_CPUCORES_SYSCONF) -# include - -// HP-UX -#elif defined(TUKLIB_CPUCORES_PSTAT_GETDYNAMIC) -# include -# include -#endif - - -extern uint32_t -tuklib_cpucores(void) -{ - uint32_t ret = 0; - -#if defined(TUKLIB_CPUCORES_SYSCTL) - int name[2] = { CTL_HW, HW_NCPU }; - int cpus; - size_t cpus_size = sizeof(cpus); - if (sysctl(name, 2, &cpus, &cpus_size, NULL, 0) != -1 - && cpus_size == sizeof(cpus) && cpus > 0) - ret = cpus; - -#elif defined(TUKLIB_CPUCORES_SYSCONF) -# ifdef _SC_NPROCESSORS_ONLN - // Most systems - const long cpus = sysconf(_SC_NPROCESSORS_ONLN); -# else - // IRIX - const long cpus = sysconf(_SC_NPROC_ONLN); -# endif - if (cpus > 0) - ret = cpus; - -#elif defined(TUKLIB_CPUCORES_PSTAT_GETDYNAMIC) - struct pst_dynamic pst; - if (pstat_getdynamic(&pst, sizeof(pst), 1, 0) != -1) - ret = pst.psd_proc_cnt; -#endif - - return ret; -} diff --git a/deps/lzma/common/tuklib_cpucores.h b/deps/lzma/common/tuklib_cpucores.h deleted file mode 100644 index be1ce1c..0000000 --- a/deps/lzma/common/tuklib_cpucores.h +++ /dev/null @@ -1,23 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file tuklib_cpucores.h -/// \brief Get the number of CPU cores online -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef TUKLIB_CPUCORES_H -#define TUKLIB_CPUCORES_H - -#include "tuklib_common.h" -TUKLIB_DECLS_BEGIN - -#define tuklib_cpucores TUKLIB_SYMBOL(tuklib_cpucores) -extern uint32_t tuklib_cpucores(void); - -TUKLIB_DECLS_END -#endif diff --git a/deps/lzma/common/tuklib_exit.c b/deps/lzma/common/tuklib_exit.c deleted file mode 100644 index c393be6..0000000 --- a/deps/lzma/common/tuklib_exit.c +++ /dev/null @@ -1,57 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file tuklib_exit.c -/// \brief Close stdout and stderr, and exit -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "tuklib_common.h" - -#include -#include - -#include "tuklib_gettext.h" -#include "tuklib_progname.h" -#include "tuklib_exit.h" - - -extern void -tuklib_exit(int status, int err_status, int show_error) -{ - if (status != err_status) { - // Close stdout. If something goes wrong, - // print an error message to stderr. - const int ferror_err = ferror(stdout); - const int fclose_err = fclose(stdout); - if (ferror_err || fclose_err) { - status = err_status; - - // If it was fclose() that failed, we have the reason - // in errno. If only ferror() indicated an error, - // we have no idea what the reason was. - if (show_error) - fprintf(stderr, "%s: %s: %s\n", progname, - _("Writing to standard " - "output failed"), - fclose_err ? strerror(errno) - : _("Unknown error")); - } - } - - if (status != err_status) { - // Close stderr. If something goes wrong, there's - // nothing where we could print an error message. - // Just set the exit status. - const int ferror_err = ferror(stderr); - const int fclose_err = fclose(stderr); - if (fclose_err || ferror_err) - status = err_status; - } - - exit(status); -} diff --git a/deps/lzma/common/tuklib_exit.h b/deps/lzma/common/tuklib_exit.h deleted file mode 100644 index b11776f..0000000 --- a/deps/lzma/common/tuklib_exit.h +++ /dev/null @@ -1,25 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file tuklib_exit.h -/// \brief Close stdout and stderr, and exit -/// \note Requires tuklib_progname and tuklib_gettext modules -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef TUKLIB_EXIT_H -#define TUKLIB_EXIT_H - -#include "tuklib_common.h" -TUKLIB_DECLS_BEGIN - -#define tuklib_exit TUKLIB_SYMBOL(tuklib_exit) -extern void tuklib_exit(int status, int err_status, int show_error) - tuklib_attr_noreturn; - -TUKLIB_DECLS_END -#endif diff --git a/deps/lzma/common/tuklib_gettext.h b/deps/lzma/common/tuklib_gettext.h deleted file mode 100644 index ff18904..0000000 --- a/deps/lzma/common/tuklib_gettext.h +++ /dev/null @@ -1,44 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file tuklib_gettext.h -/// \brief Wrapper for gettext and friends -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef TUKLIB_GETTEXT_H -#define TUKLIB_GETTEXT_H - -#include "tuklib_common.h" -#include - -#ifndef TUKLIB_GETTEXT -# ifdef ENABLE_NLS -# define TUKLIB_GETTEXT 1 -# else -# define TUKLIB_GETTEXT 0 -# endif -#endif - -#if TUKLIB_GETTEXT -# include -# define tuklib_gettext_init(package, localedir) \ - do { \ - setlocale(LC_ALL, ""); \ - bindtextdomain(package, localedir); \ - textdomain(package); \ - } while (0) -# define _(msgid) gettext(msgid) -#else -# define tuklib_gettext_init(package, localedir) \ - setlocale(LC_ALL, "") -# define _(msgid) (msgid) -# define ngettext(msgid1, msgid2, n) ((n) == 1 ? (msgid1) : (msgid2)) -#endif -#define N_(msgid) msgid - -#endif diff --git a/deps/lzma/common/tuklib_integer.h b/deps/lzma/common/tuklib_integer.h deleted file mode 100644 index e6daa77..0000000 --- a/deps/lzma/common/tuklib_integer.h +++ /dev/null @@ -1,523 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file tuklib_integer.h -/// \brief Various integer and bit operations -/// -/// This file provides macros or functions to do some basic integer and bit -/// operations. -/// -/// Endianness related integer operations (XX = 16, 32, or 64; Y = b or l): -/// - Byte swapping: bswapXX(num) -/// - Byte order conversions to/from native: convXXYe(num) -/// - Aligned reads: readXXYe(ptr) -/// - Aligned writes: writeXXYe(ptr, num) -/// - Unaligned reads (16/32-bit only): unaligned_readXXYe(ptr) -/// - Unaligned writes (16/32-bit only): unaligned_writeXXYe(ptr, num) -/// -/// Since they can macros, the arguments should have no side effects since -/// they may be evaluated more than once. -/// -/// \todo PowerPC and possibly some other architectures support -/// byte swapping load and store instructions. This file -/// doesn't take advantage of those instructions. -/// -/// Bit scan operations for non-zero 32-bit integers: -/// - Bit scan reverse (find highest non-zero bit): bsr32(num) -/// - Count leading zeros: clz32(num) -/// - Count trailing zeros: ctz32(num) -/// - Bit scan forward (simply an alias for ctz32()): bsf32(num) -/// -/// The above bit scan operations return 0-31. If num is zero, -/// the result is undefined. -// -// Authors: Lasse Collin -// Joachim Henke -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef TUKLIB_INTEGER_H -#define TUKLIB_INTEGER_H - -#include "tuklib_common.h" - - -//////////////////////////////////////// -// Operating system specific features // -//////////////////////////////////////// - -#if defined(HAVE_BYTESWAP_H) - // glibc, uClibc, dietlibc -# include -# ifdef HAVE_BSWAP_16 -# define bswap16(num) bswap_16(num) -# endif -# ifdef HAVE_BSWAP_32 -# define bswap32(num) bswap_32(num) -# endif -# ifdef HAVE_BSWAP_64 -# define bswap64(num) bswap_64(num) -# endif - -#elif defined(HAVE_SYS_ENDIAN_H) - // *BSDs and Darwin -# include - -#elif defined(HAVE_SYS_BYTEORDER_H) - // Solaris -# include -# ifdef BSWAP_16 -# define bswap16(num) BSWAP_16(num) -# endif -# ifdef BSWAP_32 -# define bswap32(num) BSWAP_32(num) -# endif -# ifdef BSWAP_64 -# define bswap64(num) BSWAP_64(num) -# endif -# ifdef BE_16 -# define conv16be(num) BE_16(num) -# endif -# ifdef BE_32 -# define conv32be(num) BE_32(num) -# endif -# ifdef BE_64 -# define conv64be(num) BE_64(num) -# endif -# ifdef LE_16 -# define conv16le(num) LE_16(num) -# endif -# ifdef LE_32 -# define conv32le(num) LE_32(num) -# endif -# ifdef LE_64 -# define conv64le(num) LE_64(num) -# endif -#endif - - -/////////////////// -// Byte swapping // -/////////////////// - -#ifndef bswap16 -# define bswap16(num) \ - (((uint16_t)(num) << 8) | ((uint16_t)(num) >> 8)) -#endif - -#ifndef bswap32 -# define bswap32(num) \ - ( (((uint32_t)(num) << 24) ) \ - | (((uint32_t)(num) << 8) & UINT32_C(0x00FF0000)) \ - | (((uint32_t)(num) >> 8) & UINT32_C(0x0000FF00)) \ - | (((uint32_t)(num) >> 24) ) ) -#endif - -#ifndef bswap64 -# define bswap64(num) \ - ( (((uint64_t)(num) << 56) ) \ - | (((uint64_t)(num) << 40) & UINT64_C(0x00FF000000000000)) \ - | (((uint64_t)(num) << 24) & UINT64_C(0x0000FF0000000000)) \ - | (((uint64_t)(num) << 8) & UINT64_C(0x000000FF00000000)) \ - | (((uint64_t)(num) >> 8) & UINT64_C(0x00000000FF000000)) \ - | (((uint64_t)(num) >> 24) & UINT64_C(0x0000000000FF0000)) \ - | (((uint64_t)(num) >> 40) & UINT64_C(0x000000000000FF00)) \ - | (((uint64_t)(num) >> 56) ) ) -#endif - -// Define conversion macros using the basic byte swapping macros. -#ifdef WORDS_BIGENDIAN -# ifndef conv16be -# define conv16be(num) ((uint16_t)(num)) -# endif -# ifndef conv32be -# define conv32be(num) ((uint32_t)(num)) -# endif -# ifndef conv64be -# define conv64be(num) ((uint64_t)(num)) -# endif -# ifndef conv16le -# define conv16le(num) bswap16(num) -# endif -# ifndef conv32le -# define conv32le(num) bswap32(num) -# endif -# ifndef conv64le -# define conv64le(num) bswap64(num) -# endif -#else -# ifndef conv16be -# define conv16be(num) bswap16(num) -# endif -# ifndef conv32be -# define conv32be(num) bswap32(num) -# endif -# ifndef conv64be -# define conv64be(num) bswap64(num) -# endif -# ifndef conv16le -# define conv16le(num) ((uint16_t)(num)) -# endif -# ifndef conv32le -# define conv32le(num) ((uint32_t)(num)) -# endif -# ifndef conv64le -# define conv64le(num) ((uint64_t)(num)) -# endif -#endif - - -////////////////////////////// -// Aligned reads and writes // -////////////////////////////// - -static inline uint16_t -read16be(const uint8_t *buf) -{ - uint16_t num = *(const uint16_t *)buf; - return conv16be(num); -} - - -static inline uint16_t -read16le(const uint8_t *buf) -{ - uint16_t num = *(const uint16_t *)buf; - return conv16le(num); -} - - -static inline uint32_t -read32be(const uint8_t *buf) -{ - uint32_t num = *(const uint32_t *)buf; - return conv32be(num); -} - - -static inline uint32_t -read32le(const uint8_t *buf) -{ - uint32_t num = *(const uint32_t *)buf; - return conv32le(num); -} - - -static inline uint64_t -read64be(const uint8_t *buf) -{ - uint64_t num = *(const uint64_t *)buf; - return conv64be(num); -} - - -static inline uint64_t -read64le(const uint8_t *buf) -{ - uint64_t num = *(const uint64_t *)buf; - return conv64le(num); -} - - -// NOTE: Possible byte swapping must be done in a macro to allow GCC -// to optimize byte swapping of constants when using glibc's or *BSD's -// byte swapping macros. The actual write is done in an inline function -// to make type checking of the buf pointer possible similarly to readXXYe() -// functions. - -#define write16be(buf, num) write16ne((buf), conv16be(num)) -#define write16le(buf, num) write16ne((buf), conv16le(num)) -#define write32be(buf, num) write32ne((buf), conv32be(num)) -#define write32le(buf, num) write32ne((buf), conv32le(num)) -#define write64be(buf, num) write64ne((buf), conv64be(num)) -#define write64le(buf, num) write64ne((buf), conv64le(num)) - - -static inline void -write16ne(uint8_t *buf, uint16_t num) -{ - *(uint16_t *)buf = num; - return; -} - - -static inline void -write32ne(uint8_t *buf, uint32_t num) -{ - *(uint32_t *)buf = num; - return; -} - - -static inline void -write64ne(uint8_t *buf, uint64_t num) -{ - *(uint64_t *)buf = num; - return; -} - - -//////////////////////////////// -// Unaligned reads and writes // -//////////////////////////////// - -// NOTE: TUKLIB_FAST_UNALIGNED_ACCESS indicates only support for 16-bit and -// 32-bit unaligned integer loads and stores. It's possible that 64-bit -// unaligned access doesn't work or is slower than byte-by-byte access. -// Since unaligned 64-bit is probably not needed as often as 16-bit or -// 32-bit, we simply don't support 64-bit unaligned access for now. -#ifdef TUKLIB_FAST_UNALIGNED_ACCESS -# define unaligned_read16be read16be -# define unaligned_read16le read16le -# define unaligned_read32be read32be -# define unaligned_read32le read32le -# define unaligned_write16be write16be -# define unaligned_write16le write16le -# define unaligned_write32be write32be -# define unaligned_write32le write32le - -#else - -static inline uint16_t -unaligned_read16be(const uint8_t *buf) -{ - uint16_t num = ((uint16_t)buf[0] << 8) | (uint16_t)buf[1]; - return num; -} - - -static inline uint16_t -unaligned_read16le(const uint8_t *buf) -{ - uint16_t num = ((uint16_t)buf[0]) | ((uint16_t)buf[1] << 8); - return num; -} - - -static inline uint32_t -unaligned_read32be(const uint8_t *buf) -{ - uint32_t num = (uint32_t)buf[0] << 24; - num |= (uint32_t)buf[1] << 16; - num |= (uint32_t)buf[2] << 8; - num |= (uint32_t)buf[3]; - return num; -} - - -static inline uint32_t -unaligned_read32le(const uint8_t *buf) -{ - uint32_t num = (uint32_t)buf[0]; - num |= (uint32_t)buf[1] << 8; - num |= (uint32_t)buf[2] << 16; - num |= (uint32_t)buf[3] << 24; - return num; -} - - -static inline void -unaligned_write16be(uint8_t *buf, uint16_t num) -{ - buf[0] = num >> 8; - buf[1] = num; - return; -} - - -static inline void -unaligned_write16le(uint8_t *buf, uint16_t num) -{ - buf[0] = num; - buf[1] = num >> 8; - return; -} - - -static inline void -unaligned_write32be(uint8_t *buf, uint32_t num) -{ - buf[0] = num >> 24; - buf[1] = num >> 16; - buf[2] = num >> 8; - buf[3] = num; - return; -} - - -static inline void -unaligned_write32le(uint8_t *buf, uint32_t num) -{ - buf[0] = num; - buf[1] = num >> 8; - buf[2] = num >> 16; - buf[3] = num >> 24; - return; -} - -#endif - - -static inline uint32_t -bsr32(uint32_t n) -{ - // Check for ICC first, since it tends to define __GNUC__ too. -#if defined(__INTEL_COMPILER) - return _bit_scan_reverse(n); - -#elif TUKLIB_GNUC_REQ(3, 4) && UINT_MAX == UINT32_MAX - // GCC >= 3.4 has __builtin_clz(), which gives good results on - // multiple architectures. On x86, __builtin_clz() ^ 31U becomes - // either plain BSR (so the XOR gets optimized away) or LZCNT and - // XOR (if -march indicates that SSE4a instructions are supported). - return __builtin_clz(n) ^ 31U; - -#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) - uint32_t i; - __asm__("bsrl %1, %0" : "=r" (i) : "rm" (n)); - return i; - -#elif defined(_MSC_VER) && _MSC_VER >= 1400 - // MSVC isn't supported by tuklib, but since this code exists, - // it doesn't hurt to have it here anyway. - uint32_t i; - _BitScanReverse((DWORD *)&i, n); - return i; - -#else - uint32_t i = 31; - - if ((n & UINT32_C(0xFFFF0000)) == 0) { - n <<= 16; - i = 15; - } - - if ((n & UINT32_C(0xFF000000)) == 0) { - n <<= 8; - i -= 8; - } - - if ((n & UINT32_C(0xF0000000)) == 0) { - n <<= 4; - i -= 4; - } - - if ((n & UINT32_C(0xC0000000)) == 0) { - n <<= 2; - i -= 2; - } - - if ((n & UINT32_C(0x80000000)) == 0) - --i; - - return i; -#endif -} - - -static inline uint32_t -clz32(uint32_t n) -{ -#if defined(__INTEL_COMPILER) - return _bit_scan_reverse(n) ^ 31U; - -#elif TUKLIB_GNUC_REQ(3, 4) && UINT_MAX == UINT32_MAX - return __builtin_clz(n); - -#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) - uint32_t i; - __asm__("bsrl %1, %0\n\t" - "xorl $31, %0" - : "=r" (i) : "rm" (n)); - return i; - -#elif defined(_MSC_VER) && _MSC_VER >= 1400 - uint32_t i; - _BitScanReverse((DWORD *)&i, n); - return i ^ 31U; - -#else - uint32_t i = 0; - - if ((n & UINT32_C(0xFFFF0000)) == 0) { - n <<= 16; - i = 16; - } - - if ((n & UINT32_C(0xFF000000)) == 0) { - n <<= 8; - i += 8; - } - - if ((n & UINT32_C(0xF0000000)) == 0) { - n <<= 4; - i += 4; - } - - if ((n & UINT32_C(0xC0000000)) == 0) { - n <<= 2; - i += 2; - } - - if ((n & UINT32_C(0x80000000)) == 0) - ++i; - - return i; -#endif -} - - -static inline uint32_t -ctz32(uint32_t n) -{ -#if defined(__INTEL_COMPILER) - return _bit_scan_forward(n); - -#elif TUKLIB_GNUC_REQ(3, 4) && UINT_MAX >= UINT32_MAX - return __builtin_ctz(n); - -#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) - uint32_t i; - __asm__("bsfl %1, %0" : "=r" (i) : "rm" (n)); - return i; - -#elif defined(_MSC_VER) && _MSC_VER >= 1400 - uint32_t i; - _BitScanForward((DWORD *)&i, n); - return i; - -#else - uint32_t i = 0; - - if ((n & UINT32_C(0x0000FFFF)) == 0) { - n >>= 16; - i = 16; - } - - if ((n & UINT32_C(0x000000FF)) == 0) { - n >>= 8; - i += 8; - } - - if ((n & UINT32_C(0x0000000F)) == 0) { - n >>= 4; - i += 4; - } - - if ((n & UINT32_C(0x00000003)) == 0) { - n >>= 2; - i += 2; - } - - if ((n & UINT32_C(0x00000001)) == 0) - ++i; - - return i; -#endif -} - -#define bsf32 ctz32 - -#endif diff --git a/deps/lzma/common/tuklib_mbstr.h b/deps/lzma/common/tuklib_mbstr.h deleted file mode 100644 index 9f35835..0000000 --- a/deps/lzma/common/tuklib_mbstr.h +++ /dev/null @@ -1,66 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file tuklib_mstr.h -/// \brief Utility functions for handling multibyte strings -/// -/// If not enough multibyte string support is available in the C library, -/// these functions keep working with the assumption that all strings -/// are in a single-byte character set without combining characters, e.g. -/// US-ASCII or ISO-8859-*. -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef TUKLIB_MBSTR_H -#define TUKLIB_MBSTR_H - -#include "tuklib_common.h" -TUKLIB_DECLS_BEGIN - -#define tuklib_mbstr_width TUKLIB_SYMBOL(tuklib_mbstr_width) -extern size_t tuklib_mbstr_width(const char *str, size_t *bytes); -///< -/// \brief Get the number of columns needed for the multibyte string -/// -/// This is somewhat similar to wcswidth() but works on multibyte strings. -/// -/// \param str String whose width is to be calculated. If the -/// current locale uses a multibyte character set -/// that has shift states, the string must begin -/// and end in the initial shift state. -/// \param bytes If this is not NULL, *bytes is set to the -/// value returned by strlen(str) (even if an -/// error occurs when calculating the width). -/// -/// \return On success, the number of columns needed to display the -/// string e.g. in a terminal emulator is returned. On error, -/// (size_t)-1 is returned. Possible errors include invalid, -/// partial, or non-printable multibyte character in str, or -/// that str doesn't end in the initial shift state. - -#define tuklib_mbstr_fw TUKLIB_SYMBOL(tuklib_mbstr_fw) -extern int tuklib_mbstr_fw(const char *str, int columns_min); -///< -/// \brief Get the field width for printf() e.g. to align table columns -/// -/// Printing simple tables to a terminal can be done using the field field -/// feature in the printf() format string, but it works only with single-byte -/// character sets. To do the same with multibyte strings, tuklib_mbstr_fw() -/// can be used to calculate appropriate field width. -/// -/// The behavior of this function is undefined, if -/// - str is NULL or not terminated with '\0'; -/// - columns_min <= 0; or -/// - the calculated field width exceeds INT_MAX. -/// -/// \return If tuklib_mbstr_width(str, NULL) fails, -1 is returned. -/// If str needs more columns than columns_min, zero is returned. -/// Otherwise a positive integer is returned, which can be -/// used as the field width, e.g. printf("%*s", fw, str). - -TUKLIB_DECLS_END -#endif diff --git a/deps/lzma/common/tuklib_mbstr_fw.c b/deps/lzma/common/tuklib_mbstr_fw.c deleted file mode 100644 index 978a3fe..0000000 --- a/deps/lzma/common/tuklib_mbstr_fw.c +++ /dev/null @@ -1,31 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file tuklib_mstr_fw.c -/// \brief Get the field width for printf() e.g. to align table columns -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "tuklib_mbstr.h" - - -extern int -tuklib_mbstr_fw(const char *str, int columns_min) -{ - size_t len; - const size_t width = tuklib_mbstr_width(str, &len); - if (width == (size_t)-1) - return -1; - - if (width > (size_t)columns_min) - return 0; - - if (width < (size_t)columns_min) - len += (size_t)columns_min - width; - - return len; -} diff --git a/deps/lzma/common/tuklib_mbstr_width.c b/deps/lzma/common/tuklib_mbstr_width.c deleted file mode 100644 index 3c38990..0000000 --- a/deps/lzma/common/tuklib_mbstr_width.c +++ /dev/null @@ -1,64 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file tuklib_mstr_width.c -/// \brief Calculate width of a multibyte string -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "tuklib_mbstr.h" - -#if defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH) -# include -#endif - - -extern size_t -tuklib_mbstr_width(const char *str, size_t *bytes) -{ - const size_t len = strlen(str); - if (bytes != NULL) - *bytes = len; - -#if !(defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH)) - // In single-byte mode, the width of the string is the same - // as its length. - return len; - -#else - mbstate_t state; - memset(&state, 0, sizeof(state)); - - size_t width = 0; - size_t i = 0; - - // Convert one multibyte character at a time to wchar_t - // and get its width using wcwidth(). - while (i < len) { - wchar_t wc; - const size_t ret = mbrtowc(&wc, str + i, len - i, &state); - if (ret < 1 || ret > len) - return (size_t)-1; - - i += ret; - - const int wc_width = wcwidth(wc); - if (wc_width < 0) - return (size_t)-1; - - width += wc_width; - } - - // Require that the string ends in the initial shift state. - // This way the caller can be combine the string with other - // strings without needing to worry about the shift states. - if (!mbsinit(&state)) - return (size_t)-1; - - return width; -#endif -} diff --git a/deps/lzma/common/tuklib_open_stdxxx.c b/deps/lzma/common/tuklib_open_stdxxx.c deleted file mode 100644 index 26702a6..0000000 --- a/deps/lzma/common/tuklib_open_stdxxx.c +++ /dev/null @@ -1,57 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file tuklib_open_stdxxx.c -/// \brief Make sure that file descriptors 0, 1, and 2 are open -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "tuklib_open_stdxxx.h" - -#ifndef TUKLIB_DOSLIKE -# include -# include -# include -# include -#endif - - -extern void -tuklib_open_stdxxx(int err_status) -{ -#ifdef TUKLIB_DOSLIKE - // Do nothing, just silence warnings. - (void)err_status; - -#else - for (int i = 0; i <= 2; ++i) { - // We use fcntl() to check if the file descriptor is open. - if (fcntl(i, F_GETFD) == -1 && errno == EBADF) { - // With stdin, we could use /dev/full so that - // writing to stdin would fail. However, /dev/full - // is Linux specific, and if the program tries to - // write to stdin, there's already a problem anyway. - const int fd = open("/dev/null", O_NOCTTY - | (i == 0 ? O_WRONLY : O_RDONLY)); - - if (fd != i) { - if (fd != -1) - (void)close(fd); - - // Something went wrong. Exit with the - // exit status we were given. Don't try - // to print an error message, since stderr - // may very well be non-existent. This - // error should be extremely rare. - exit(err_status); - } - } - } -#endif - - return; -} diff --git a/deps/lzma/common/tuklib_open_stdxxx.h b/deps/lzma/common/tuklib_open_stdxxx.h deleted file mode 100644 index b911616..0000000 --- a/deps/lzma/common/tuklib_open_stdxxx.h +++ /dev/null @@ -1,23 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file tuklib_open_stdxxx.h -/// \brief Make sure that file descriptors 0, 1, and 2 are open -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef TUKLIB_OPEN_STDXXX_H -#define TUKLIB_OPEN_STDXXX_H - -#include "tuklib_common.h" -TUKLIB_DECLS_BEGIN - -#define tuklib_open_stdxx TUKLIB_SYMBOL(tuklib_open_stdxxx) -extern void tuklib_open_stdxxx(int err_status); - -TUKLIB_DECLS_END -#endif diff --git a/deps/lzma/common/tuklib_physmem.c b/deps/lzma/common/tuklib_physmem.c deleted file mode 100644 index 623b6e7..0000000 --- a/deps/lzma/common/tuklib_physmem.c +++ /dev/null @@ -1,196 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file tuklib_physmem.c -/// \brief Get the amount of physical memory -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "tuklib_physmem.h" - -// We want to use Windows-specific code on Cygwin, which also has memory -// information available via sysconf(), but on Cygwin 1.5 and older it -// gives wrong results (from our point of view). -#if defined(_WIN32) || defined(__CYGWIN__) -# ifndef _WIN32_WINNT -# define _WIN32_WINNT 0x0500 -# endif -# include - -#elif defined(__OS2__) -# define INCL_DOSMISC -# include - -#elif defined(__DJGPP__) -# include - -#elif defined(__VMS) -# include -# include -# include - -// AIX -#elif defined(TUKLIB_PHYSMEM_AIX) -# include - -#elif defined(TUKLIB_PHYSMEM_SYSCONF) -# include - -#elif defined(TUKLIB_PHYSMEM_SYSCTL) -# ifdef HAVE_SYS_PARAM_H -# include -# endif -# include - -// Tru64 -#elif defined(TUKLIB_PHYSMEM_GETSYSINFO) -# include -# include - -// HP-UX -#elif defined(TUKLIB_PHYSMEM_PSTAT_GETSTATIC) -# include -# include - -// IRIX -#elif defined(TUKLIB_PHYSMEM_GETINVENT_R) -# include - -// This sysinfo() is Linux-specific. -#elif defined(TUKLIB_PHYSMEM_SYSINFO) -# include -#endif - - -extern uint64_t -tuklib_physmem(void) -{ - uint64_t ret = 0; - -#if defined(_WIN32) || defined(__CYGWIN__) - if ((GetVersion() & 0xFF) >= 5) { - // Windows 2000 and later have GlobalMemoryStatusEx() which - // supports reporting values greater than 4 GiB. To keep the - // code working also on older Windows versions, use - // GlobalMemoryStatusEx() conditionally. - HMODULE kernel32 = GetModuleHandle("kernel32.dll"); - if (kernel32 != NULL) { - BOOL (WINAPI *gmse)(LPMEMORYSTATUSEX) = GetProcAddress( - kernel32, "GlobalMemoryStatusEx"); - if (gmse != NULL) { - MEMORYSTATUSEX meminfo; - meminfo.dwLength = sizeof(meminfo); - if (gmse(&meminfo)) - ret = meminfo.ullTotalPhys; - } - } - } - - if (ret == 0) { - // GlobalMemoryStatus() is supported by Windows 95 and later, - // so it is fine to link against it unconditionally. Note that - // GlobalMemoryStatus() has no return value. - MEMORYSTATUS meminfo; - meminfo.dwLength = sizeof(meminfo); - GlobalMemoryStatus(&meminfo); - ret = meminfo.dwTotalPhys; - } - -#elif defined(__OS2__) - unsigned long mem; - if (DosQuerySysInfo(QSV_TOTPHYSMEM, QSV_TOTPHYSMEM, - &mem, sizeof(mem)) == 0) - ret = mem; - -#elif defined(__DJGPP__) - __dpmi_free_mem_info meminfo; - if (__dpmi_get_free_memory_information(&meminfo) == 0 - && meminfo.total_number_of_physical_pages - != (unsigned long)-1) - ret = (uint64_t)meminfo.total_number_of_physical_pages * 4096; - -#elif defined(__VMS) - int vms_mem; - int val = SYI$_MEMSIZE; - if (LIB$GETSYI(&val, &vms_mem, 0, 0, 0, 0) == SS$_NORMAL) - ret = (uint64_t)vms_mem * 8192; - -#elif defined(TUKLIB_PHYSMEM_AIX) - ret = _system_configuration.physmem; - -#elif defined(TUKLIB_PHYSMEM_SYSCONF) - const long pagesize = sysconf(_SC_PAGESIZE); - const long pages = sysconf(_SC_PHYS_PAGES); - if (pagesize != -1 && pages != -1) - // According to docs, pagesize * pages can overflow. - // Simple case is 32-bit box with 4 GiB or more RAM, - // which may report exactly 4 GiB of RAM, and "long" - // being 32-bit will overflow. Casting to uint64_t - // hopefully avoids overflows in the near future. - ret = (uint64_t)pagesize * (uint64_t)pages; - -#elif defined(TUKLIB_PHYSMEM_SYSCTL) - int name[2] = { - CTL_HW, -#ifdef HW_PHYSMEM64 - HW_PHYSMEM64 -#else - HW_PHYSMEM -#endif - }; - union { - uint32_t u32; - uint64_t u64; - } mem; - size_t mem_ptr_size = sizeof(mem.u64); - if (sysctl(name, 2, &mem.u64, &mem_ptr_size, NULL, 0) != -1) { - // IIRC, 64-bit "return value" is possible on some 64-bit - // BSD systems even with HW_PHYSMEM (instead of HW_PHYSMEM64), - // so support both. - if (mem_ptr_size == sizeof(mem.u64)) - ret = mem.u64; - else if (mem_ptr_size == sizeof(mem.u32)) - ret = mem.u32; - } - -#elif defined(TUKLIB_PHYSMEM_GETSYSINFO) - // Docs are unclear if "start" is needed, but it doesn't hurt - // much to have it. - int memkb; - int start = 0; - if (getsysinfo(GSI_PHYSMEM, (caddr_t)&memkb, sizeof(memkb), &start) - != -1) - ret = (uint64_t)memkb * 1024; - -#elif defined(TUKLIB_PHYSMEM_PSTAT_GETSTATIC) - struct pst_static pst; - if (pstat_getstatic(&pst, sizeof(pst), 1, 0) != -1) - ret = (uint64_t)pst.physical_memory * (uint64_t)pst.page_size; - -#elif defined(TUKLIB_PHYSMEM_GETINVENT_R) - inv_state_t *st = NULL; - if (setinvent_r(&st) != -1) { - inventory_t *i; - while ((i = getinvent_r(st)) != NULL) { - if (i->inv_class == INV_MEMORY - && i->inv_type == INV_MAIN_MB) { - ret = (uint64_t)i->inv_state << 20; - break; - } - } - - endinvent_r(st); - } - -#elif defined(TUKLIB_PHYSMEM_SYSINFO) - struct sysinfo si; - if (sysinfo(&si) == 0) - ret = (uint64_t)si.totalram * si.mem_unit; -#endif - - return ret; -} diff --git a/deps/lzma/common/tuklib_physmem.h b/deps/lzma/common/tuklib_physmem.h deleted file mode 100644 index 09e2a51..0000000 --- a/deps/lzma/common/tuklib_physmem.h +++ /dev/null @@ -1,28 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file tuklib_physmem.h -/// \brief Get the amount of physical memory -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef TUKLIB_PHYSMEM_H -#define TUKLIB_PHYSMEM_H - -#include "tuklib_common.h" -TUKLIB_DECLS_BEGIN - -#define tuklib_physmem TUKLIB_SYMBOL(tuklib_physmem) -extern uint64_t tuklib_physmem(void); -///< -/// \brief Get the amount of physical memory in bytes -/// -/// \return Amount of physical memory in bytes. On error, zero is -/// returned. - -TUKLIB_DECLS_END -#endif diff --git a/deps/lzma/common/tuklib_progname.c b/deps/lzma/common/tuklib_progname.c deleted file mode 100644 index 7cb7e20..0000000 --- a/deps/lzma/common/tuklib_progname.c +++ /dev/null @@ -1,50 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file tuklib_progname.c -/// \brief Program name to be displayed in messages -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "tuklib_progname.h" -#include - - -#if !HAVE_DECL_PROGRAM_INVOCATION_NAME -char *progname = NULL; -#endif - - -extern void -tuklib_progname_init(char **argv) -{ -#ifdef TUKLIB_DOSLIKE - // On these systems, argv[0] always has the full path and .exe - // suffix even if the user just types the plain program name. - // We modify argv[0] to make it nicer to read. - - // Strip the leading path. - char *p = argv[0] + strlen(argv[0]); - while (argv[0] < p && p[-1] != '/' && p[-1] != '\\') - --p; - - argv[0] = p; - - // Strip the .exe suffix. - p = strrchr(p, '.'); - if (p != NULL) - *p = '\0'; - - // Make it lowercase. - for (p = argv[0]; *p != '\0'; ++p) - if (*p >= 'A' && *p <= 'Z') - *p = *p - 'A' + 'a'; -#endif - - progname = argv[0]; - return; -} diff --git a/deps/lzma/common/tuklib_progname.h b/deps/lzma/common/tuklib_progname.h deleted file mode 100644 index 791b125..0000000 --- a/deps/lzma/common/tuklib_progname.h +++ /dev/null @@ -1,32 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file tuklib_progname.h -/// \brief Program name to be displayed in messages -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef TUKLIB_PROGNAME_H -#define TUKLIB_PROGNAME_H - -#include "tuklib_common.h" -#include - -TUKLIB_DECLS_BEGIN - -#if HAVE_DECL_PROGRAM_INVOCATION_NAME -# define progname program_invocation_name -#else -# define progname TUKLIB_SYMBOL(tuklib_progname) - extern char *progname; -#endif - -#define tuklib_progname_init TUKLIB_SYMBOL(tuklib_progname_init) -extern void tuklib_progname_init(char **argv); - -TUKLIB_DECLS_END -#endif diff --git a/deps/lzma/config.h b/deps/lzma/config.h deleted file mode 100644 index 59c1f30..0000000 --- a/deps/lzma/config.h +++ /dev/null @@ -1,415 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define if building universal (internal helper macro) */ -/* #undef AC_APPLE_UNIVERSAL_BUILD */ - -/* How many MiB of RAM to assume if the real amount cannot be determined. */ -#define ASSUME_RAM 128 - -/* Define to 1 if translation of program messages to the user's native -language is requested. */ -/* #undef ENABLE_NLS */ - -/* Define to 1 if bswap_16 is available. */ -/* #undef HAVE_BSWAP_16 */ - -/* Define to 1 if bswap_32 is available. */ -/* #undef HAVE_BSWAP_32 */ - -/* Define to 1 if bswap_64 is available. */ -/* #undef HAVE_BSWAP_64 */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_BYTESWAP_H */ - -/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the -CoreFoundation framework. */ -/* #undef HAVE_CFLOCALECOPYCURRENT */ - -/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in -the CoreFoundation framework. */ -/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */ - -/* Define to 1 if crc32 integrity check is enabled. */ -#define HAVE_CHECK_CRC32 1 - -/* Define to 1 if crc64 integrity check is enabled. */ -#define HAVE_CHECK_CRC64 1 - -/* Define to 1 if sha256 integrity check is enabled. */ -#define HAVE_CHECK_SHA256 1 - -/* Define if the GNU dcgettext() function is already present or preinstalled. -*/ -/* #undef HAVE_DCGETTEXT */ - -/* Define to 1 if you have the declaration of `program_invocation_name', and -to 0 if you don't. */ -#define HAVE_DECL_PROGRAM_INVOCATION_NAME 0 - -/* Define to 1 if arm decoder is enabled. */ -#define HAVE_DECODER_ARM 1 - -/* Define to 1 if armthumb decoder is enabled. */ -#define HAVE_DECODER_ARMTHUMB 1 - -/* Define to 1 if delta decoder is enabled. */ -#define HAVE_DECODER_DELTA 1 - -/* Define to 1 if ia64 decoder is enabled. */ -#define HAVE_DECODER_IA64 1 - -/* Define to 1 if lzma1 decoder is enabled. */ -#define HAVE_DECODER_LZMA1 1 - -/* Define to 1 if lzma2 decoder is enabled. */ -#define HAVE_DECODER_LZMA2 1 - -/* Define to 1 if powerpc decoder is enabled. */ -#define HAVE_DECODER_POWERPC 1 - -/* Define to 1 if sparc decoder is enabled. */ -#define HAVE_DECODER_SPARC 1 - -/* Define to 1 if x86 decoder is enabled. */ -#define HAVE_DECODER_X86 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_DLFCN_H */ - -/* Define to 1 if arm encoder is enabled. */ -#define HAVE_ENCODER_ARM 1 - -/* Define to 1 if armthumb encoder is enabled. */ -#define HAVE_ENCODER_ARMTHUMB 1 - -/* Define to 1 if delta encoder is enabled. */ -#define HAVE_ENCODER_DELTA 1 - -/* Define to 1 if ia64 encoder is enabled. */ -#define HAVE_ENCODER_IA64 1 - -/* Define to 1 if lzma1 encoder is enabled. */ -#define HAVE_ENCODER_LZMA1 1 - -/* Define to 1 if lzma2 encoder is enabled. */ -#define HAVE_ENCODER_LZMA2 1 - -/* Define to 1 if powerpc encoder is enabled. */ -#define HAVE_ENCODER_POWERPC 1 - -/* Define to 1 if sparc encoder is enabled. */ -#define HAVE_ENCODER_SPARC 1 - -/* Define to 1 if x86 encoder is enabled. */ -#define HAVE_ENCODER_X86 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the `futimens' function. */ -/* #undef HAVE_FUTIMENS */ - -/* Define to 1 if you have the `futimes' function. */ -/* #undef HAVE_FUTIMES */ - -/* Define to 1 if you have the `futimesat' function. */ -/* #undef HAVE_FUTIMESAT */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_GETOPT_H */ - -/* Define to 1 if you have the `getopt_long' function. */ -/* #undef HAVE_GETOPT_LONG */ - -/* Define if the GNU gettext() function is already present or preinstalled. */ -/* #undef HAVE_GETTEXT */ - -/* Define if you have the iconv() function and it works. */ -#define HAVE_ICONV 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define to 1 if mbrtowc and mbstate_t are properly declared. */ -#define HAVE_MBRTOWC 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 to enable bt2 match finder. */ -#define HAVE_MF_BT2 1 - -/* Define to 1 to enable bt3 match finder. */ -#define HAVE_MF_BT3 1 - -/* Define to 1 to enable bt4 match finder. */ -#define HAVE_MF_BT4 1 - -/* Define to 1 to enable hc3 match finder. */ -#define HAVE_MF_HC3 1 - -/* Define to 1 to enable hc4 match finder. */ -#define HAVE_MF_HC4 1 - -/* Define to 1 if getopt.h declares extern int optreset. */ -/* #undef HAVE_OPTRESET */ - -/* Define if you have POSIX threads libraries and header files. */ -/* #undef HAVE_PTHREAD */ - -/* Have PTHREAD_PRIO_INHERIT. */ -/* #undef HAVE_PTHREAD_PRIO_INHERIT */ - -/* Define to 1 if optimizing for size. */ -/* #undef HAVE_SMALL */ - -/* Define to 1 if stdbool.h conforms to C99. */ -#define HAVE_STDBOOL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_STRINGS_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if `st_atimensec' is a member of `struct stat'. */ -/* #undef HAVE_STRUCT_STAT_ST_ATIMENSEC */ - -/* Define to 1 if `st_atimespec.tv_nsec' is a member of `struct stat'. */ -/* #undef HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC */ - -/* Define to 1 if `st_atim.st__tim.tv_nsec' is a member of `struct stat'. */ -/* #undef HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC */ - -/* Define to 1 if `st_atim.tv_nsec' is a member of `struct stat'. */ -/* #undef HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC */ - -/* Define to 1 if `st_uatime' is a member of `struct stat'. */ -/* #undef HAVE_STRUCT_STAT_ST_UATIME */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_BYTEORDER_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_ENDIAN_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TIME_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if the system has the type `uintptr_t'. */ -#define HAVE_UINTPTR_T 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to 1 if you have the `utime' function. */ -#define HAVE_UTIME 1 - -/* Define to 1 if you have the `utimes' function. */ -/* #undef HAVE_UTIMES */ - -/* Define to 1 or 0, depending whether the compiler supports simple visibility -declarations. */ -#define HAVE_VISIBILITY 1 - -/* Define to 1 if you have the `wcwidth' function. */ -/* #undef HAVE_WCWIDTH */ - -/* Define to 1 if the system has the type `_Bool'. */ -#define HAVE__BOOL 1 - -/* Define to the sub-directory in which libtool stores uninstalled libraries. -*/ -#define LT_OBJDIR ".libs/" - -/* Name of package */ -#define PACKAGE "xz" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "lasse.collin@tukaani.org" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "XZ Utils" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "xz" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "http://tukaani.org/xz/" - -/* Define to necessary symbol if this constant uses a non-standard name on -your system. */ -/* #undef PTHREAD_CREATE_JOINABLE */ - -/* The size of `size_t', as computed by sizeof. */ -#define SIZEOF_SIZE_T 4 - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define to 1 if the number of available CPU cores can be detected with -pstat_getdynamic(). */ -/* #undef TUKLIB_CPUCORES_PSTAT_GETDYNAMIC */ - -/* Define to 1 if the number of available CPU cores can be detected with -sysconf(_SC_NPROCESSORS_ONLN) or sysconf(_SC_NPROC_ONLN). */ -/* #undef TUKLIB_CPUCORES_SYSCONF */ - -/* Define to 1 if the number of available CPU cores can be detected with -sysctl(). */ -/* #undef TUKLIB_CPUCORES_SYSCTL */ - -/* Define to 1 if the system supports fast unaligned access to 16-bit and -32-bit integers. */ -#define TUKLIB_FAST_UNALIGNED_ACCESS 1 - -/* Define to 1 if the amount of physical memory can be detected with -_system_configuration.physmem. */ -/* #undef TUKLIB_PHYSMEM_AIX */ - -/* Define to 1 if the amount of physical memory can be detected with -getinvent_r(). */ -/* #undef TUKLIB_PHYSMEM_GETINVENT_R */ - -/* Define to 1 if the amount of physical memory can be detected with -getsysinfo(). */ -/* #undef TUKLIB_PHYSMEM_GETSYSINFO */ - -/* Define to 1 if the amount of physical memory can be detected with -pstat_getstatic(). */ -/* #undef TUKLIB_PHYSMEM_PSTAT_GETSTATIC */ - -/* Define to 1 if the amount of physical memory can be detected with -sysconf(_SC_PAGESIZE) and sysconf(_SC_PHYS_PAGES). */ -/* #undef TUKLIB_PHYSMEM_SYSCONF */ - -/* Define to 1 if the amount of physical memory can be detected with sysctl(). -*/ -/* #undef TUKLIB_PHYSMEM_SYSCTL */ - -/* Define to 1 if the amount of physical memory can be detected with Linux -sysinfo(). */ -/* #undef TUKLIB_PHYSMEM_SYSINFO */ - -/* Enable extensions on AIX 3, Interix. */ -#ifndef _ALL_SOURCE -# define _ALL_SOURCE 1 -#endif -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -#endif -/* Enable threading extensions on Solaris. */ -#ifndef _POSIX_PTHREAD_SEMANTICS -# define _POSIX_PTHREAD_SEMANTICS 1 -#endif -/* Enable extensions on HP NonStop. */ -#ifndef _TANDEM_SOURCE -# define _TANDEM_SOURCE 1 -#endif -/* Enable general extensions on Solaris. */ -#ifndef __EXTENSIONS__ -# define __EXTENSIONS__ 1 -#endif - -#include "version.h" - -/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most -significant byte first (like Motorola and SPARC, unlike Intel). */ -#if defined AC_APPLE_UNIVERSAL_BUILD -# if defined __BIG_ENDIAN__ -# define WORDS_BIGENDIAN 1 -# endif -#else -# ifndef WORDS_BIGENDIAN -/* # undef WORDS_BIGENDIAN */ -# endif -#endif - -/* Enable large inode numbers on Mac OS X 10.5. */ -#ifndef _DARWIN_USE_64_BIT_INODE -# define _DARWIN_USE_64_BIT_INODE 1 -#endif - -/* Number of bits in a file offset, on hosts where this is settable. */ -#define _FILE_OFFSET_BITS 64 - -/* Define for large files, on AIX-style hosts. */ -/* #undef _LARGE_FILES */ - -/* Define to 1 if on MINIX. */ -/* #undef _MINIX */ - -/* Define to 2 if the system does not provide POSIX.1 features except with -this defined. */ -/* #undef _POSIX_1_SOURCE */ - -/* Define to 1 if you need to in order for `stat' and other things to work. */ -/* #undef _POSIX_SOURCE */ - -/* Define for Solaris 2.5.1 so the uint32_t typedef from , -, or is not used. If the typedef were allowed, the -#define below would cause a syntax error. */ -/* #undef _UINT32_T */ - -/* Define for Solaris 2.5.1 so the uint64_t typedef from , -, or is not used. If the typedef were allowed, the -#define below would cause a syntax error. */ -/* #undef _UINT64_T */ - -/* Define for Solaris 2.5.1 so the uint8_t typedef from , -, or is not used. If the typedef were allowed, the -#define below would cause a syntax error. */ -/* #undef _UINT8_T */ - -/* Define to rpl_ if the getopt replacement functions and variables should be -used. */ -/* #undef __GETOPT_PREFIX */ - -/* Define to the type of a signed integer type of width exactly 32 bits if -such a type exists and the standard includes do not define it. */ -/* #undef int32_t */ - -/* Define to the type of a signed integer type of width exactly 64 bits if -such a type exists and the standard includes do not define it. */ -/* #undef int64_t */ - -/* Define to the type of an unsigned integer type of width exactly 16 bits if -such a type exists and the standard includes do not define it. */ -/* #undef uint16_t */ - -/* Define to the type of an unsigned integer type of width exactly 32 bits if -such a type exists and the standard includes do not define it. */ -/* #undef uint32_t */ - -/* Define to the type of an unsigned integer type of width exactly 64 bits if -such a type exists and the standard includes do not define it. */ -/* #undef uint64_t */ - -/* Define to the type of an unsigned integer type of width exactly 8 bits if -such a type exists and the standard includes do not define it. */ -/* #undef uint8_t */ - -/* Define to the type of an unsigned integer type wide enough to hold a -pointer, if such a type exists, and if the system does not define it. */ -/* #undef uintptr_t */ \ No newline at end of file diff --git a/deps/lzma/liblzma/api/lzma.h b/deps/lzma/liblzma/api/lzma.h deleted file mode 100644 index 05e7841..0000000 --- a/deps/lzma/liblzma/api/lzma.h +++ /dev/null @@ -1,314 +0,0 @@ -/** - * \file api/lzma.h - * \brief The public API of liblzma data compression library - * - * liblzma is a public domain general-purpose data compression library with - * a zlib-like API. The native file format is .xz, but also the old .lzma - * format and raw (no headers) streams are supported. Multiple compression - * algorithms (filters) are supported. Currently LZMA2 is the primary filter. - * - * liblzma is part of XZ Utils . XZ Utils includes - * a gzip-like command line tool named xz and some other tools. XZ Utils - * is developed and maintained by Lasse Collin. - * - * Major parts of liblzma are based on Igor Pavlov's public domain LZMA SDK - * . - * - * The SHA-256 implementation is based on the public domain code found from - * 7-Zip , which has a modified version of the public - * domain SHA-256 code found from Crypto++ . - * The SHA-256 code in Crypto++ was written by Kevin Springle and Wei Dai. - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - */ - -#ifndef LZMA_H -#define LZMA_H - -/***************************** - * Required standard headers * - *****************************/ - -/* - * liblzma API headers need some standard types and macros. To allow - * including lzma.h without requiring the application to include other - * headers first, lzma.h includes the required standard headers unless - * they already seem to be included already or if LZMA_MANUAL_HEADERS - * has been defined. - * - * Here's what types and macros are needed and from which headers: - * - stddef.h: size_t, NULL - * - stdint.h: uint8_t, uint32_t, uint64_t, UINT32_C(n), uint64_C(n), - * UINT32_MAX, UINT64_MAX - * - * However, inttypes.h is a little more portable than stdint.h, although - * inttypes.h declares some unneeded things compared to plain stdint.h. - * - * The hacks below aren't perfect, specifically they assume that inttypes.h - * exists and that it typedefs at least uint8_t, uint32_t, and uint64_t, - * and that, in case of incomplete inttypes.h, unsigned int is 32-bit. - * If the application already takes care of setting up all the types and - * macros properly (for example by using gnulib's stdint.h or inttypes.h), - * we try to detect that the macros are already defined and don't include - * inttypes.h here again. However, you may define LZMA_MANUAL_HEADERS to - * force this file to never include any system headers. - * - * Some could argue that liblzma API should provide all the required types, - * for example lzma_uint64, LZMA_UINT64_C(n), and LZMA_UINT64_MAX. This was - * seen as an unnecessary mess, since most systems already provide all the - * necessary types and macros in the standard headers. - * - * Note that liblzma API still has lzma_bool, because using stdbool.h would - * break C89 and C++ programs on many systems. sizeof(bool) in C99 isn't - * necessarily the same as sizeof(bool) in C++. - */ - -#ifndef LZMA_MANUAL_HEADERS - /* - * I suppose this works portably also in C++. Note that in C++, - * we need to get size_t into the global namespace. - */ -# include - - /* - * Skip inttypes.h if we already have all the required macros. If we - * have the macros, we assume that we have the matching typedefs too. - */ -# if !defined(UINT32_C) || !defined(UINT64_C) \ - || !defined(UINT32_MAX) || !defined(UINT64_MAX) - /* - * MSVC has no C99 support, and thus it cannot be used to - * compile liblzma. The liblzma API has to still be usable - * from MSVC, so we need to define the required standard - * integer types here. - */ -# if defined(_WIN32) && defined(_MSC_VER) - typedef unsigned __int8 uint8_t; - typedef unsigned __int32 uint32_t; - typedef unsigned __int64 uint64_t; -# else - /* Use the standard inttypes.h. */ -# ifdef __cplusplus - /* - * C99 sections 7.18.2 and 7.18.4 specify - * that C++ implementations define the limit - * and constant macros only if specifically - * requested. Note that if you want the - * format macros (PRIu64 etc.) too, you need - * to define __STDC_FORMAT_MACROS before - * including lzma.h, since re-including - * inttypes.h with __STDC_FORMAT_MACROS - * defined doesn't necessarily work. - */ -# ifndef __STDC_LIMIT_MACROS -# define __STDC_LIMIT_MACROS 1 -# endif -# ifndef __STDC_CONSTANT_MACROS -# define __STDC_CONSTANT_MACROS 1 -# endif -# endif - -# include -# endif - - /* - * Some old systems have only the typedefs in inttypes.h, and - * lack all the macros. For those systems, we need a few more - * hacks. We assume that unsigned int is 32-bit and unsigned - * long is either 32-bit or 64-bit. If these hacks aren't - * enough, the application has to setup the types manually - * before including lzma.h. - */ -# ifndef UINT32_C -# if defined(_WIN32) && defined(_MSC_VER) -# define UINT32_C(n) n ## UI32 -# else -# define UINT32_C(n) n ## U -# endif -# endif - -# ifndef UINT64_C -# if defined(_WIN32) && defined(_MSC_VER) -# define UINT64_C(n) n ## UI64 -# else - /* Get ULONG_MAX. */ -# include -# if ULONG_MAX == 4294967295UL -# define UINT64_C(n) n ## ULL -# else -# define UINT64_C(n) n ## UL -# endif -# endif -# endif - -# ifndef UINT32_MAX -# define UINT32_MAX (UINT32_C(4294967295)) -# endif - -# ifndef UINT64_MAX -# define UINT64_MAX (UINT64_C(18446744073709551615)) -# endif -# endif -#endif /* ifdef LZMA_MANUAL_HEADERS */ - - -/****************** - * LZMA_API macro * - ******************/ - -/* - * Some systems require that the functions and function pointers are - * declared specially in the headers. LZMA_API_IMPORT is for importing - * symbols and LZMA_API_CALL is to specify the calling convention. - * - * By default it is assumed that the application will link dynamically - * against liblzma. #define LZMA_API_STATIC in your application if you - * want to link against static liblzma. If you don't care about portability - * to operating systems like Windows, or at least don't care about linking - * against static liblzma on them, don't worry about LZMA_API_STATIC. That - * is, most developers will never need to use LZMA_API_STATIC. - * - * The GCC variants are a special case on Windows (Cygwin and MinGW). - * We rely on GCC doing the right thing with its auto-import feature, - * and thus don't use __declspec(dllimport). This way developers don't - * need to worry about LZMA_API_STATIC. Also the calling convention is - * omitted on Cygwin but not on MinGW. - */ -#ifndef LZMA_API_IMPORT -# define LZMA_API_STATIC -# if !defined(LZMA_API_STATIC) && defined(_WIN32) && !defined(__GNUC__) -# define LZMA_API_IMPORT __declspec(dllimport) -# else -# define LZMA_API_IMPORT -# endif -#endif - -#ifndef LZMA_API_CALL -# if defined(_WIN32) && !defined(__CYGWIN__) -# define LZMA_API_CALL __cdecl -# else -# define LZMA_API_CALL -# endif -#endif - -#ifndef LZMA_API -# define LZMA_API(type) LZMA_API_IMPORT type LZMA_API_CALL -#endif - - -/*********** - * nothrow * - ***********/ - -/* - * None of the functions in liblzma may throw an exception. Even - * the functions that use callback functions won't throw exceptions, - * because liblzma would break if a callback function threw an exception. - */ -#ifndef lzma_nothrow -# if defined(__cplusplus) -# define lzma_nothrow throw() -# elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) -# define lzma_nothrow __attribute__((__nothrow__)) -# else -# define lzma_nothrow -# endif -#endif - - -/******************** - * GNU C extensions * - ********************/ - -/* - * GNU C extensions are used conditionally in the public API. It doesn't - * break anything if these are sometimes enabled and sometimes not, only - * affects warnings and optimizations. - */ -#if __GNUC__ >= 3 -# ifndef lzma_attribute -# define lzma_attribute(attr) __attribute__(attr) -# endif - - /* warn_unused_result was added in GCC 3.4. */ -# ifndef lzma_attr_warn_unused_result -# if __GNUC__ == 3 && __GNUC_MINOR__ < 4 -# define lzma_attr_warn_unused_result -# endif -# endif - -#else -# ifndef lzma_attribute -# define lzma_attribute(attr) -# endif -#endif - - -#ifndef lzma_attr_pure -# define lzma_attr_pure lzma_attribute((__pure__)) -#endif - -#ifndef lzma_attr_const -# define lzma_attr_const lzma_attribute((__const__)) -#endif - -#ifndef lzma_attr_warn_unused_result -# define lzma_attr_warn_unused_result \ - lzma_attribute((__warn_unused_result__)) -#endif - - -/************** - * Subheaders * - **************/ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Subheaders check that this is defined. It is to prevent including - * them directly from applications. - */ -#define LZMA_H_INTERNAL 1 - -/* Basic features */ -#include "lzma/version.h" -#include "lzma/base.h" -#include "lzma/vli.h" -#include "lzma/check.h" - -/* Filters */ -#include "lzma/filter.h" -#include "lzma/bcj.h" -#include "lzma/delta.h" -#include "lzma/lzma.h" - -/* Container formats */ -#include "lzma/container.h" - -/* Advanced features */ -#include "lzma/stream_flags.h" -#include "lzma/block.h" -#include "lzma/index.h" -#include "lzma/index_hash.h" - -/* Hardware information */ -#include "lzma/hardware.h" - -/* - * All subheaders included. Undefine LZMA_H_INTERNAL to prevent applications - * re-including the subheaders. - */ -#undef LZMA_H_INTERNAL - -#ifdef __cplusplus -} -#endif - -#endif /* ifndef LZMA_H */ diff --git a/deps/lzma/liblzma/api/lzma/base.h b/deps/lzma/liblzma/api/lzma/base.h deleted file mode 100644 index 43dde8d..0000000 --- a/deps/lzma/liblzma/api/lzma/base.h +++ /dev/null @@ -1,601 +0,0 @@ -/** - * \file lzma/base.h - * \brief Data types and functions used in many places in liblzma API - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Boolean - * - * This is here because C89 doesn't have stdbool.h. To set a value for - * variables having type lzma_bool, you can use - * - C99's `true' and `false' from stdbool.h; - * - C++'s internal `true' and `false'; or - * - integers one (true) and zero (false). - */ -typedef unsigned char lzma_bool; - - -/** - * \brief Type of reserved enumeration variable in structures - * - * To avoid breaking library ABI when new features are added, several - * structures contain extra variables that may be used in future. Since - * sizeof(enum) can be different than sizeof(int), and sizeof(enum) may - * even vary depending on the range of enumeration constants, we specify - * a separate type to be used for reserved enumeration variables. All - * enumeration constants in liblzma API will be non-negative and less - * than 128, which should guarantee that the ABI won't break even when - * new constants are added to existing enumerations. - */ -typedef enum { - LZMA_RESERVED_ENUM = 0 -} lzma_reserved_enum; - - -/** - * \brief Return values used by several functions in liblzma - * - * Check the descriptions of specific functions to find out which return - * values they can return. With some functions the return values may have - * more specific meanings than described here; those differences are - * described per-function basis. - */ -typedef enum { - LZMA_OK = 0, - /**< - * \brief Operation completed successfully - */ - - LZMA_STREAM_END = 1, - /**< - * \brief End of stream was reached - * - * In encoder, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, or - * LZMA_FINISH was finished. In decoder, this indicates - * that all the data was successfully decoded. - * - * In all cases, when LZMA_STREAM_END is returned, the last - * output bytes should be picked from strm->next_out. - */ - - LZMA_NO_CHECK = 2, - /**< - * \brief Input stream has no integrity check - * - * This return value can be returned only if the - * LZMA_TELL_NO_CHECK flag was used when initializing - * the decoder. LZMA_NO_CHECK is just a warning, and - * the decoding can be continued normally. - * - * It is possible to call lzma_get_check() immediately after - * lzma_code has returned LZMA_NO_CHECK. The result will - * naturally be LZMA_CHECK_NONE, but the possibility to call - * lzma_get_check() may be convenient in some applications. - */ - - LZMA_UNSUPPORTED_CHECK = 3, - /**< - * \brief Cannot calculate the integrity check - * - * The usage of this return value is different in encoders - * and decoders. - * - * Encoders can return this value only from the initialization - * function. If initialization fails with this value, the - * encoding cannot be done, because there's no way to produce - * output with the correct integrity check. - * - * Decoders can return this value only from lzma_code() and - * only if the LZMA_TELL_UNSUPPORTED_CHECK flag was used when - * initializing the decoder. The decoding can still be - * continued normally even if the check type is unsupported, - * but naturally the check will not be validated, and possible - * errors may go undetected. - * - * With decoder, it is possible to call lzma_get_check() - * immediately after lzma_code() has returned - * LZMA_UNSUPPORTED_CHECK. This way it is possible to find - * out what the unsupported Check ID was. - */ - - LZMA_GET_CHECK = 4, - /**< - * \brief Integrity check type is now available - * - * This value can be returned only by the lzma_code() function - * and only if the decoder was initialized with the - * LZMA_TELL_ANY_CHECK flag. LZMA_GET_CHECK tells the - * application that it may now call lzma_get_check() to find - * out the Check ID. This can be used, for example, to - * implement a decoder that accepts only files that have - * strong enough integrity check. - */ - - LZMA_MEM_ERROR = 5, - /**< - * \brief Cannot allocate memory - * - * Memory allocation failed, or the size of the allocation - * would be greater than SIZE_MAX. - * - * Due to internal implementation reasons, the coding cannot - * be continued even if more memory were made available after - * LZMA_MEM_ERROR. - */ - - LZMA_MEMLIMIT_ERROR = 6, - /** - * \brief Memory usage limit was reached - * - * Decoder would need more memory than allowed by the - * specified memory usage limit. To continue decoding, - * the memory usage limit has to be increased with - * lzma_memlimit_set(). - */ - - LZMA_FORMAT_ERROR = 7, - /**< - * \brief File format not recognized - * - * The decoder did not recognize the input as supported file - * format. This error can occur, for example, when trying to - * decode .lzma format file with lzma_stream_decoder, - * because lzma_stream_decoder accepts only the .xz format. - */ - - LZMA_OPTIONS_ERROR = 8, - /**< - * \brief Invalid or unsupported options - * - * Invalid or unsupported options, for example - * - unsupported filter(s) or filter options; or - * - reserved bits set in headers (decoder only). - * - * Rebuilding liblzma with more features enabled, or - * upgrading to a newer version of liblzma may help. - */ - - LZMA_DATA_ERROR = 9, - /**< - * \brief Data is corrupt - * - * The usage of this return value is different in encoders - * and decoders. In both encoder and decoder, the coding - * cannot continue after this error. - * - * Encoders return this if size limits of the target file - * format would be exceeded. These limits are huge, thus - * getting this error from an encoder is mostly theoretical. - * For example, the maximum compressed and uncompressed - * size of a .xz Stream is roughly 8 EiB (2^63 bytes). - * - * Decoders return this error if the input data is corrupt. - * This can mean, for example, invalid CRC32 in headers - * or invalid check of uncompressed data. - */ - - LZMA_BUF_ERROR = 10, - /**< - * \brief No progress is possible - * - * This error code is returned when the coder cannot consume - * any new input and produce any new output. The most common - * reason for this error is that the input stream being - * decoded is truncated or corrupt. - * - * This error is not fatal. Coding can be continued normally - * by providing more input and/or more output space, if - * possible. - * - * Typically the first call to lzma_code() that can do no - * progress returns LZMA_OK instead of LZMA_BUF_ERROR. Only - * the second consecutive call doing no progress will return - * LZMA_BUF_ERROR. This is intentional. - * - * With zlib, Z_BUF_ERROR may be returned even if the - * application is doing nothing wrong, so apps will need - * to handle Z_BUF_ERROR specially. The above hack - * guarantees that liblzma never returns LZMA_BUF_ERROR - * to properly written applications unless the input file - * is truncated or corrupt. This should simplify the - * applications a little. - */ - - LZMA_PROG_ERROR = 11, - /**< - * \brief Programming error - * - * This indicates that the arguments given to the function are - * invalid or the internal state of the decoder is corrupt. - * - Function arguments are invalid or the structures - * pointed by the argument pointers are invalid - * e.g. if strm->next_out has been set to NULL and - * strm->avail_out > 0 when calling lzma_code(). - * - lzma_* functions have been called in wrong order - * e.g. lzma_code() was called right after lzma_end(). - * - If errors occur randomly, the reason might be flaky - * hardware. - * - * If you think that your code is correct, this error code - * can be a sign of a bug in liblzma. See the documentation - * how to report bugs. - */ -} lzma_ret; - - -/** - * \brief The `action' argument for lzma_code() - * - * After the first use of LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, or LZMA_FINISH, - * the same `action' must is used until lzma_code() returns LZMA_STREAM_END. - * Also, the amount of input (that is, strm->avail_in) must not be modified - * by the application until lzma_code() returns LZMA_STREAM_END. Changing the - * `action' or modifying the amount of input will make lzma_code() return - * LZMA_PROG_ERROR. - */ -typedef enum { - LZMA_RUN = 0, - /**< - * \brief Continue coding - * - * Encoder: Encode as much input as possible. Some internal - * buffering will probably be done (depends on the filter - * chain in use), which causes latency: the input used won't - * usually be decodeable from the output of the same - * lzma_code() call. - * - * Decoder: Decode as much input as possible and produce as - * much output as possible. - */ - - LZMA_SYNC_FLUSH = 1, - /**< - * \brief Make all the input available at output - * - * Normally the encoder introduces some latency. - * LZMA_SYNC_FLUSH forces all the buffered data to be - * available at output without resetting the internal - * state of the encoder. This way it is possible to use - * compressed stream for example for communication over - * network. - * - * Only some filters support LZMA_SYNC_FLUSH. Trying to use - * LZMA_SYNC_FLUSH with filters that don't support it will - * make lzma_code() return LZMA_OPTIONS_ERROR. For example, - * LZMA1 doesn't support LZMA_SYNC_FLUSH but LZMA2 does. - * - * Using LZMA_SYNC_FLUSH very often can dramatically reduce - * the compression ratio. With some filters (for example, - * LZMA2), fine-tuning the compression options may help - * mitigate this problem significantly (for example, - * match finder with LZMA2). - * - * Decoders don't support LZMA_SYNC_FLUSH. - */ - - LZMA_FULL_FLUSH = 2, - /**< - * \brief Finish encoding of the current Block - * - * All the input data going to the current Block must have - * been given to the encoder (the last bytes can still be - * pending in* next_in). Call lzma_code() with LZMA_FULL_FLUSH - * until it returns LZMA_STREAM_END. Then continue normally - * with LZMA_RUN or finish the Stream with LZMA_FINISH. - * - * This action is currently supported only by Stream encoder - * and easy encoder (which uses Stream encoder). If there is - * no unfinished Block, no empty Block is created. - */ - - LZMA_FINISH = 3 - /**< - * \brief Finish the coding operation - * - * All the input data must have been given to the encoder - * (the last bytes can still be pending in next_in). - * Call lzma_code() with LZMA_FINISH until it returns - * LZMA_STREAM_END. Once LZMA_FINISH has been used, - * the amount of input must no longer be changed by - * the application. - * - * When decoding, using LZMA_FINISH is optional unless the - * LZMA_CONCATENATED flag was used when the decoder was - * initialized. When LZMA_CONCATENATED was not used, the only - * effect of LZMA_FINISH is that the amount of input must not - * be changed just like in the encoder. - */ -} lzma_action; - - -/** - * \brief Custom functions for memory handling - * - * A pointer to lzma_allocator may be passed via lzma_stream structure - * to liblzma, and some advanced functions take a pointer to lzma_allocator - * as a separate function argument. The library will use the functions - * specified in lzma_allocator for memory handling instead of the default - * malloc() and free(). C++ users should note that the custom memory - * handling functions must not throw exceptions. - * - * liblzma doesn't make an internal copy of lzma_allocator. Thus, it is - * OK to change these function pointers in the middle of the coding - * process, but obviously it must be done carefully to make sure that the - * replacement `free' can deallocate memory allocated by the earlier - * `alloc' function(s). - */ -typedef struct { - /** - * \brief Pointer to a custom memory allocation function - * - * If you don't want a custom allocator, but still want - * custom free(), set this to NULL and liblzma will use - * the standard malloc(). - * - * \param opaque lzma_allocator.opaque (see below) - * \param nmemb Number of elements like in calloc(). liblzma - * will always set nmemb to 1, so it is safe to - * ignore nmemb in a custom allocator if you like. - * The nmemb argument exists only for - * compatibility with zlib and libbzip2. - * \param size Size of an element in bytes. - * liblzma never sets this to zero. - * - * \return Pointer to the beginning of a memory block of - * `size' bytes, or NULL if allocation fails - * for some reason. When allocation fails, functions - * of liblzma return LZMA_MEM_ERROR. - * - * The allocator should not waste time zeroing the allocated buffers. - * This is not only about speed, but also memory usage, since the - * operating system kernel doesn't necessarily allocate the requested - * memory in physical memory until it is actually used. With small - * input files, liblzma may actually need only a fraction of the - * memory that it requested for allocation. - * - * \note LZMA_MEM_ERROR is also used when the size of the - * allocation would be greater than SIZE_MAX. Thus, - * don't assume that the custom allocator must have - * returned NULL if some function from liblzma - * returns LZMA_MEM_ERROR. - */ - void *(LZMA_API_CALL *alloc)(void *opaque, size_t nmemb, size_t size); - - /** - * \brief Pointer to a custom memory freeing function - * - * If you don't want a custom freeing function, but still - * want a custom allocator, set this to NULL and liblzma - * will use the standard free(). - * - * \param opaque lzma_allocator.opaque (see below) - * \param ptr Pointer returned by lzma_allocator.alloc(), - * or when it is set to NULL, a pointer returned - * by the standard malloc(). - */ - void (LZMA_API_CALL *free)(void *opaque, void *ptr); - - /** - * \brief Pointer passed to .alloc() and .free() - * - * opaque is passed as the first argument to lzma_allocator.alloc() - * and lzma_allocator.free(). This intended to ease implementing - * custom memory allocation functions for use with liblzma. - * - * If you don't need this, you should set this to NULL. - */ - void *opaque; - -} lzma_allocator; - - -/** - * \brief Internal data structure - * - * The contents of this structure is not visible outside the library. - */ -typedef struct lzma_internal_s lzma_internal; - - -/** - * \brief Passing data to and from liblzma - * - * The lzma_stream structure is used for - * - passing pointers to input and output buffers to liblzma; - * - defining custom memory hander functions; and - * - holding a pointer to coder-specific internal data structures. - * - * Typical usage: - * - * - After allocating lzma_stream (on stack or with malloc()), it must be - * initialized to LZMA_STREAM_INIT (see LZMA_STREAM_INIT for details). - * - * - Initialize a coder to the lzma_stream, for example by using - * lzma_easy_encoder() or lzma_auto_decoder(). Some notes: - * - In contrast to zlib, strm->next_in and strm->next_out are - * ignored by all initialization functions, thus it is safe - * to not initialize them yet. - * - The initialization functions always set strm->total_in and - * strm->total_out to zero. - * - If the initialization function fails, no memory is left allocated - * that would require freeing with lzma_end() even if some memory was - * associated with the lzma_stream structure when the initialization - * function was called. - * - * - Use lzma_code() to do the actual work. - * - * - Once the coding has been finished, the existing lzma_stream can be - * reused. It is OK to reuse lzma_stream with different initialization - * function without calling lzma_end() first. Old allocations are - * automatically freed. - * - * - Finally, use lzma_end() to free the allocated memory. lzma_end() never - * frees the lzma_stream structure itself. - * - * Application may modify the values of total_in and total_out as it wants. - * They are updated by liblzma to match the amount of data read and - * written, but aren't used for anything else. - */ -typedef struct { - const uint8_t *next_in; /**< Pointer to the next input byte. */ - size_t avail_in; /**< Number of available input bytes in next_in. */ - uint64_t total_in; /**< Total number of bytes read by liblzma. */ - - uint8_t *next_out; /**< Pointer to the next output position. */ - size_t avail_out; /**< Amount of free space in next_out. */ - uint64_t total_out; /**< Total number of bytes written by liblzma. */ - - /** - * \brief Custom memory allocation functions - * - * In most cases this is NULL which makes liblzma use - * the standard malloc() and free(). - */ - lzma_allocator *allocator; - - /** Internal state is not visible to applications. */ - lzma_internal *internal; - - /* - * Reserved space to allow possible future extensions without - * breaking the ABI. Excluding the initialization of this structure, - * you should not touch these, because the names of these variables - * may change. - */ - void *reserved_ptr1; - void *reserved_ptr2; - void *reserved_ptr3; - void *reserved_ptr4; - uint64_t reserved_int1; - uint64_t reserved_int2; - size_t reserved_int3; - size_t reserved_int4; - lzma_reserved_enum reserved_enum1; - lzma_reserved_enum reserved_enum2; - -} lzma_stream; - - -/** - * \brief Initialization for lzma_stream - * - * When you declare an instance of lzma_stream, you can immediately - * initialize it so that initialization functions know that no memory - * has been allocated yet: - * - * lzma_stream strm = LZMA_STREAM_INIT; - * - * If you need to initialize a dynamically allocated lzma_stream, you can use - * memset(strm_pointer, 0, sizeof(lzma_stream)). Strictly speaking, this - * violates the C standard since NULL may have different internal - * representation than zero, but it should be portable enough in practice. - * Anyway, for maximum portability, you can use something like this: - * - * lzma_stream tmp = LZMA_STREAM_INIT; - * *strm = tmp; - */ -#define LZMA_STREAM_INIT \ - { NULL, 0, 0, NULL, 0, 0, NULL, NULL, \ - NULL, NULL, NULL, NULL, 0, 0, 0, 0, \ - LZMA_RESERVED_ENUM, LZMA_RESERVED_ENUM } - - -/** - * \brief Encode or decode data - * - * Once the lzma_stream has been successfully initialized (e.g. with - * lzma_stream_encoder()), the actual encoding or decoding is done - * using this function. The application has to update strm->next_in, - * strm->avail_in, strm->next_out, and strm->avail_out to pass input - * to and get output from liblzma. - * - * See the description of the coder-specific initialization function to find - * out what `action' values are supported by the coder. - */ -extern LZMA_API(lzma_ret) lzma_code(lzma_stream *strm, lzma_action action) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Free memory allocated for the coder data structures - * - * \param strm Pointer to lzma_stream that is at least initialized - * with LZMA_STREAM_INIT. - * - * After lzma_end(strm), strm->internal is guaranteed to be NULL. No other - * members of the lzma_stream structure are touched. - * - * \note zlib indicates an error if application end()s unfinished - * stream structure. liblzma doesn't do this, and assumes that - * application knows what it is doing. - */ -extern LZMA_API(void) lzma_end(lzma_stream *strm) lzma_nothrow; - - -/** - * \brief Get the memory usage of decoder filter chain - * - * This function is currently supported only when *strm has been initialized - * with a function that takes a memlimit argument. With other functions, you - * should use e.g. lzma_raw_encoder_memusage() or lzma_raw_decoder_memusage() - * to estimate the memory requirements. - * - * This function is useful e.g. after LZMA_MEMLIMIT_ERROR to find out how big - * the memory usage limit should have been to decode the input. Note that - * this may give misleading information if decoding .xz Streams that have - * multiple Blocks, because each Block can have different memory requirements. - * - * \return How much memory is currently allocated for the filter - * decoders. If no filter chain is currently allocated, - * some non-zero value is still returned, which is less than - * or equal to what any filter chain would indicate as its - * memory requirement. - * - * If this function isn't supported by *strm or some other error - * occurs, zero is returned. - */ -extern LZMA_API(uint64_t) lzma_memusage(const lzma_stream *strm) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Get the current memory usage limit - * - * This function is supported only when *strm has been initialized with - * a function that takes a memlimit argument. - * - * \return On success, the current memory usage limit is returned - * (always non-zero). On error, zero is returned. - */ -extern LZMA_API(uint64_t) lzma_memlimit_get(const lzma_stream *strm) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Set the memory usage limit - * - * This function is supported only when *strm has been initialized with - * a function that takes a memlimit argument. - * - * \return - LZMA_OK: New memory usage limit successfully set. - * - LZMA_MEMLIMIT_ERROR: The new limit is too small. - * The limit was not changed. - * - LZMA_PROG_ERROR: Invalid arguments, e.g. *strm doesn't - * support memory usage limit or memlimit was zero. - */ -extern LZMA_API(lzma_ret) lzma_memlimit_set( - lzma_stream *strm, uint64_t memlimit) lzma_nothrow; diff --git a/deps/lzma/liblzma/api/lzma/bcj.h b/deps/lzma/liblzma/api/lzma/bcj.h deleted file mode 100644 index 8e37538..0000000 --- a/deps/lzma/liblzma/api/lzma/bcj.h +++ /dev/null @@ -1,90 +0,0 @@ -/** - * \file lzma/bcj.h - * \brief Branch/Call/Jump conversion filters - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/* Filter IDs for lzma_filter.id */ - -#define LZMA_FILTER_X86 LZMA_VLI_C(0x04) - /**< - * Filter for x86 binaries - */ - -#define LZMA_FILTER_POWERPC LZMA_VLI_C(0x05) - /**< - * Filter for Big endian PowerPC binaries - */ - -#define LZMA_FILTER_IA64 LZMA_VLI_C(0x06) - /**< - * Filter for IA-64 (Itanium) binaries. - */ - -#define LZMA_FILTER_ARM LZMA_VLI_C(0x07) - /**< - * Filter for ARM binaries. - */ - -#define LZMA_FILTER_ARMTHUMB LZMA_VLI_C(0x08) - /**< - * Filter for ARM-Thumb binaries. - */ - -#define LZMA_FILTER_SPARC LZMA_VLI_C(0x09) - /**< - * Filter for SPARC binaries. - */ - - -/** - * \brief Options for BCJ filters - * - * The BCJ filters never change the size of the data. Specifying options - * for them is optional: if pointer to options is NULL, default value is - * used. You probably never need to specify options to BCJ filters, so just - * set the options pointer to NULL and be happy. - * - * If options with non-default values have been specified when encoding, - * the same options must also be specified when decoding. - * - * \note At the moment, none of the BCJ filters support - * LZMA_SYNC_FLUSH. If LZMA_SYNC_FLUSH is specified, - * LZMA_OPTIONS_ERROR will be returned. If there is need, - * partial support for LZMA_SYNC_FLUSH can be added in future. - * Partial means that flushing would be possible only at - * offsets that are multiple of 2, 4, or 16 depending on - * the filter, except x86 which cannot be made to support - * LZMA_SYNC_FLUSH predictably. - */ -typedef struct { - /** - * \brief Start offset for conversions - * - * This setting is useful only when the same filter is used - * _separately_ for multiple sections of the same executable file, - * and the sections contain cross-section branch/call/jump - * instructions. In that case it is beneficial to set the start - * offset of the non-first sections so that the relative addresses - * of the cross-section branch/call/jump instructions will use the - * same absolute addresses as in the first section. - * - * When the pointer to options is NULL, the default value (zero) - * is used. - */ - uint32_t start_offset; - -} lzma_options_bcj; diff --git a/deps/lzma/liblzma/api/lzma/block.h b/deps/lzma/liblzma/api/lzma/block.h deleted file mode 100644 index e6710a7..0000000 --- a/deps/lzma/liblzma/api/lzma/block.h +++ /dev/null @@ -1,533 +0,0 @@ -/** - * \file lzma/block.h - * \brief .xz Block handling - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Options for the Block and Block Header encoders and decoders - * - * Different Block handling functions use different parts of this structure. - * Some read some members, other functions write, and some do both. Only the - * members listed for reading need to be initialized when the specified - * functions are called. The members marked for writing will be assigned - * new values at some point either by calling the given function or by - * later calls to lzma_code(). - */ -typedef struct { - /** - * \brief Block format version - * - * To prevent API and ABI breakages if new features are needed in - * the Block field, a version number is used to indicate which - * fields in this structure are in use. For now, version must always - * be zero. With non-zero version, most Block related functions will - * return LZMA_OPTIONS_ERROR. - * - * Read by: - * - All functions that take pointer to lzma_block as argument, - * including lzma_block_header_decode(). - * - * Written by: - * - lzma_block_header_decode() - */ - uint32_t version; - - /** - * \brief Size of the Block Header field - * - * This is always a multiple of four. - * - * Read by: - * - lzma_block_header_encode() - * - lzma_block_header_decode() - * - lzma_block_compressed_size() - * - lzma_block_unpadded_size() - * - lzma_block_total_size() - * - lzma_block_decoder() - * - lzma_block_buffer_decode() - * - * Written by: - * - lzma_block_header_size() - * - lzma_block_buffer_encode() - */ - uint32_t header_size; -# define LZMA_BLOCK_HEADER_SIZE_MIN 8 -# define LZMA_BLOCK_HEADER_SIZE_MAX 1024 - - /** - * \brief Type of integrity Check - * - * The Check ID is not stored into the Block Header, thus its value - * must be provided also when decoding. - * - * Read by: - * - lzma_block_header_encode() - * - lzma_block_header_decode() - * - lzma_block_compressed_size() - * - lzma_block_unpadded_size() - * - lzma_block_total_size() - * - lzma_block_encoder() - * - lzma_block_decoder() - * - lzma_block_buffer_encode() - * - lzma_block_buffer_decode() - */ - lzma_check check; - - /** - * \brief Size of the Compressed Data in bytes - * - * Encoding: If this is not LZMA_VLI_UNKNOWN, Block Header encoder - * will store this value to the Block Header. Block encoder doesn't - * care about this value, but will set it once the encoding has been - * finished. - * - * Decoding: If this is not LZMA_VLI_UNKNOWN, Block decoder will - * verify that the size of the Compressed Data field matches - * compressed_size. - * - * Usually you don't know this value when encoding in streamed mode, - * and thus cannot write this field into the Block Header. - * - * In non-streamed mode you can reserve space for this field before - * encoding the actual Block. After encoding the data, finish the - * Block by encoding the Block Header. Steps in detail: - * - * - Set compressed_size to some big enough value. If you don't know - * better, use LZMA_VLI_MAX, but remember that bigger values take - * more space in Block Header. - * - * - Call lzma_block_header_size() to see how much space you need to - * reserve for the Block Header. - * - * - Encode the Block using lzma_block_encoder() and lzma_code(). - * It sets compressed_size to the correct value. - * - * - Use lzma_block_header_encode() to encode the Block Header. - * Because space was reserved in the first step, you don't need - * to call lzma_block_header_size() anymore, because due to - * reserving, header_size has to be big enough. If it is "too big", - * lzma_block_header_encode() will add enough Header Padding to - * make Block Header to match the size specified by header_size. - * - * Read by: - * - lzma_block_header_size() - * - lzma_block_header_encode() - * - lzma_block_compressed_size() - * - lzma_block_unpadded_size() - * - lzma_block_total_size() - * - lzma_block_decoder() - * - lzma_block_buffer_decode() - * - * Written by: - * - lzma_block_header_decode() - * - lzma_block_compressed_size() - * - lzma_block_encoder() - * - lzma_block_decoder() - * - lzma_block_buffer_encode() - * - lzma_block_buffer_decode() - */ - lzma_vli compressed_size; - - /** - * \brief Uncompressed Size in bytes - * - * This is handled very similarly to compressed_size above. - * - * uncompressed_size is needed by fewer functions than - * compressed_size. This is because uncompressed_size isn't - * needed to validate that Block stays within proper limits. - * - * Read by: - * - lzma_block_header_size() - * - lzma_block_header_encode() - * - lzma_block_decoder() - * - lzma_block_buffer_decode() - * - * Written by: - * - lzma_block_header_decode() - * - lzma_block_encoder() - * - lzma_block_decoder() - * - lzma_block_buffer_encode() - * - lzma_block_buffer_decode() - */ - lzma_vli uncompressed_size; - - /** - * \brief Array of filters - * - * There can be 1-4 filters. The end of the array is marked with - * .id = LZMA_VLI_UNKNOWN. - * - * Read by: - * - lzma_block_header_size() - * - lzma_block_header_encode() - * - lzma_block_encoder() - * - lzma_block_decoder() - * - lzma_block_buffer_encode() - * - lzma_block_buffer_decode() - * - * Written by: - * - lzma_block_header_decode(): Note that this does NOT free() - * the old filter options structures. All unused filters[] will - * have .id == LZMA_VLI_UNKNOWN and .options == NULL. If - * decoding fails, all filters[] are guaranteed to be - * LZMA_VLI_UNKNOWN and NULL. - * - * \note Because of the array is terminated with - * .id = LZMA_VLI_UNKNOWN, the actual array must - * have LZMA_FILTERS_MAX + 1 members or the Block - * Header decoder will overflow the buffer. - */ - lzma_filter *filters; - - /** - * \brief Raw value stored in the Check field - * - * After successful coding, the first lzma_check_size(check) bytes - * of this array contain the raw value stored in the Check field. - * - * Note that CRC32 and CRC64 are stored in little endian byte order. - * Take it into account if you display the Check values to the user. - * - * Written by: - * - lzma_block_encoder() - * - lzma_block_decoder() - * - lzma_block_buffer_encode() - * - lzma_block_buffer_decode() - */ - uint8_t raw_check[LZMA_CHECK_SIZE_MAX]; - - /* - * Reserved space to allow possible future extensions without - * breaking the ABI. You should not touch these, because the names - * of these variables may change. These are and will never be used - * with the currently supported options, so it is safe to leave these - * uninitialized. - */ - void *reserved_ptr1; - void *reserved_ptr2; - void *reserved_ptr3; - uint32_t reserved_int1; - uint32_t reserved_int2; - lzma_vli reserved_int3; - lzma_vli reserved_int4; - lzma_vli reserved_int5; - lzma_vli reserved_int6; - lzma_vli reserved_int7; - lzma_vli reserved_int8; - lzma_reserved_enum reserved_enum1; - lzma_reserved_enum reserved_enum2; - lzma_reserved_enum reserved_enum3; - lzma_reserved_enum reserved_enum4; - lzma_bool reserved_bool1; - lzma_bool reserved_bool2; - lzma_bool reserved_bool3; - lzma_bool reserved_bool4; - lzma_bool reserved_bool5; - lzma_bool reserved_bool6; - lzma_bool reserved_bool7; - lzma_bool reserved_bool8; - -} lzma_block; - - -/** - * \brief Decode the Block Header Size field - * - * To decode Block Header using lzma_block_header_decode(), the size of the - * Block Header has to be known and stored into lzma_block.header_size. - * The size can be calculated from the first byte of a Block using this macro. - * Note that if the first byte is 0x00, it indicates beginning of Index; use - * this macro only when the byte is not 0x00. - * - * There is no encoding macro, because Block Header encoder is enough for that. - */ -#define lzma_block_header_size_decode(b) (((uint32_t)(b) + 1) * 4) - - -/** - * \brief Calculate Block Header Size - * - * Calculate the minimum size needed for the Block Header field using the - * settings specified in the lzma_block structure. Note that it is OK to - * increase the calculated header_size value as long as it is a multiple of - * four and doesn't exceed LZMA_BLOCK_HEADER_SIZE_MAX. Increasing header_size - * just means that lzma_block_header_encode() will add Header Padding. - * - * \return - LZMA_OK: Size calculated successfully and stored to - * block->header_size. - * - LZMA_OPTIONS_ERROR: Unsupported version, filters or - * filter options. - * - LZMA_PROG_ERROR: Invalid values like compressed_size == 0. - * - * \note This doesn't check that all the options are valid i.e. this - * may return LZMA_OK even if lzma_block_header_encode() or - * lzma_block_encoder() would fail. If you want to validate the - * filter chain, consider using lzma_memlimit_encoder() which as - * a side-effect validates the filter chain. - */ -extern LZMA_API(lzma_ret) lzma_block_header_size(lzma_block *block) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Encode Block Header - * - * The caller must have calculated the size of the Block Header already with - * lzma_block_header_size(). If a value larger than the one calculated by - * lzma_block_header_size() is used, the Block Header will be padded to the - * specified size. - * - * \param out Beginning of the output buffer. This must be - * at least block->header_size bytes. - * \param block Block options to be encoded. - * - * \return - LZMA_OK: Encoding was successful. block->header_size - * bytes were written to output buffer. - * - LZMA_OPTIONS_ERROR: Invalid or unsupported options. - * - LZMA_PROG_ERROR: Invalid arguments, for example - * block->header_size is invalid or block->filters is NULL. - */ -extern LZMA_API(lzma_ret) lzma_block_header_encode( - const lzma_block *block, uint8_t *out) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Decode Block Header - * - * block->version should be set to the highest value supported by the - * application; currently the only possible version is zero. This function - * will set version to the lowest value that still supports all the features - * required by the Block Header. - * - * The size of the Block Header must have already been decoded with - * lzma_block_header_size_decode() macro and stored to block->header_size. - * - * The integrity check type from Stream Header must have been stored - * to block->check. - * - * block->filters must have been allocated, but they don't need to be - * initialized (possible existing filter options are not freed). - * - * \param block Destination for Block options. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() (and also free() - * if an error occurs). - * \param in Beginning of the input buffer. This must be - * at least block->header_size bytes. - * - * \return - LZMA_OK: Decoding was successful. block->header_size - * bytes were read from the input buffer. - * - LZMA_OPTIONS_ERROR: The Block Header specifies some - * unsupported options such as unsupported filters. This can - * happen also if block->version was set to a too low value - * compared to what would be required to properly represent - * the information stored in the Block Header. - * - LZMA_DATA_ERROR: Block Header is corrupt, for example, - * the CRC32 doesn't match. - * - LZMA_PROG_ERROR: Invalid arguments, for example - * block->header_size is invalid or block->filters is NULL. - */ -extern LZMA_API(lzma_ret) lzma_block_header_decode(lzma_block *block, - lzma_allocator *allocator, const uint8_t *in) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Validate and set Compressed Size according to Unpadded Size - * - * Block Header stores Compressed Size, but Index has Unpadded Size. If the - * application has already parsed the Index and is now decoding Blocks, - * it can calculate Compressed Size from Unpadded Size. This function does - * exactly that with error checking: - * - * - Compressed Size calculated from Unpadded Size must be positive integer, - * that is, Unpadded Size must be big enough that after Block Header and - * Check fields there's still at least one byte for Compressed Size. - * - * - If Compressed Size was present in Block Header, the new value - * calculated from Unpadded Size is compared against the value - * from Block Header. - * - * \note This function must be called _after_ decoding the Block Header - * field so that it can properly validate Compressed Size if it - * was present in Block Header. - * - * \return - LZMA_OK: block->compressed_size was set successfully. - * - LZMA_DATA_ERROR: unpadded_size is too small compared to - * block->header_size and lzma_check_size(block->check). - * - LZMA_PROG_ERROR: Some values are invalid. For example, - * block->header_size must be a multiple of four and - * between 8 and 1024 inclusive. - */ -extern LZMA_API(lzma_ret) lzma_block_compressed_size( - lzma_block *block, lzma_vli unpadded_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Calculate Unpadded Size - * - * The Index field stores Unpadded Size and Uncompressed Size. The latter - * can be taken directly from the lzma_block structure after coding a Block, - * but Unpadded Size needs to be calculated from Block Header Size, - * Compressed Size, and size of the Check field. This is where this function - * is needed. - * - * \return Unpadded Size on success, or zero on error. - */ -extern LZMA_API(lzma_vli) lzma_block_unpadded_size(const lzma_block *block) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Calculate the total encoded size of a Block - * - * This is equivalent to lzma_block_unpadded_size() except that the returned - * value includes the size of the Block Padding field. - * - * \return On success, total encoded size of the Block. On error, - * zero is returned. - */ -extern LZMA_API(lzma_vli) lzma_block_total_size(const lzma_block *block) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Initialize .xz Block encoder - * - * Valid actions for lzma_code() are LZMA_RUN, LZMA_SYNC_FLUSH (only if the - * filter chain supports it), and LZMA_FINISH. - * - * \return - LZMA_OK: All good, continue with lzma_code(). - * - LZMA_MEM_ERROR - * - LZMA_OPTIONS_ERROR - * - LZMA_UNSUPPORTED_CHECK: block->check specifies a Check ID - * that is not supported by this buid of liblzma. Initializing - * the encoder failed. - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_block_encoder( - lzma_stream *strm, lzma_block *block) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Initialize .xz Block decoder - * - * Valid actions for lzma_code() are LZMA_RUN and LZMA_FINISH. Using - * LZMA_FINISH is not required. It is supported only for convenience. - * - * \return - LZMA_OK: All good, continue with lzma_code(). - * - LZMA_UNSUPPORTED_CHECK: Initialization was successful, but - * the given Check ID is not supported, thus Check will be - * ignored. - * - LZMA_PROG_ERROR - * - LZMA_MEM_ERROR - */ -extern LZMA_API(lzma_ret) lzma_block_decoder( - lzma_stream *strm, lzma_block *block) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Calculate maximum output size for single-call Block encoding - * - * This is equivalent to lzma_stream_buffer_bound() but for .xz Blocks. - * See the documentation of lzma_stream_buffer_bound(). - */ -extern LZMA_API(size_t) lzma_block_buffer_bound(size_t uncompressed_size) - lzma_nothrow; - - -/** - * \brief Single-call .xz Block encoder - * - * In contrast to the multi-call encoder initialized with - * lzma_block_encoder(), this function encodes also the Block Header. This - * is required to make it possible to write appropriate Block Header also - * in case the data isn't compressible, and different filter chain has to be - * used to encode the data in uncompressed form using uncompressed chunks - * of the LZMA2 filter. - * - * When the data isn't compressible, header_size, compressed_size, and - * uncompressed_size are set just like when the data was compressible, but - * it is possible that header_size is too small to hold the filter chain - * specified in block->filters, because that isn't necessarily the filter - * chain that was actually used to encode the data. lzma_block_unpadded_size() - * still works normally, because it doesn't read the filters array. - * - * \param block Block options: block->version, block->check, - * and block->filters must have been initialized. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * \param in Beginning of the input buffer - * \param in_size Size of the input buffer - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_BUF_ERROR: Not enough output buffer space. - * - LZMA_UNSUPPORTED_CHECK - * - LZMA_OPTIONS_ERROR - * - LZMA_MEM_ERROR - * - LZMA_DATA_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_block_buffer_encode( - lzma_block *block, lzma_allocator *allocator, - const uint8_t *in, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Single-call .xz Block decoder - * - * This is single-call equivalent of lzma_block_decoder(), and requires that - * the caller has already decoded Block Header and checked its memory usage. - * - * \param block Block options just like with lzma_block_decoder(). - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * \param in Beginning of the input buffer - * \param in_pos The next byte will be read from in[*in_pos]. - * *in_pos is updated only if decoding succeeds. - * \param in_size Size of the input buffer; the first byte that - * won't be read is in[in_size]. - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return - LZMA_OK: Decoding was successful. - * - LZMA_OPTIONS_ERROR - * - LZMA_DATA_ERROR - * - LZMA_MEM_ERROR - * - LZMA_BUF_ERROR: Output buffer was too small. - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_block_buffer_decode( - lzma_block *block, lzma_allocator *allocator, - const uint8_t *in, size_t *in_pos, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) - lzma_nothrow; diff --git a/deps/lzma/liblzma/api/lzma/check.h b/deps/lzma/liblzma/api/lzma/check.h deleted file mode 100644 index 6a243db..0000000 --- a/deps/lzma/liblzma/api/lzma/check.h +++ /dev/null @@ -1,150 +0,0 @@ -/** - * \file lzma/check.h - * \brief Integrity checks - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Type of the integrity check (Check ID) - * - * The .xz format supports multiple types of checks that are calculated - * from the uncompressed data. They vary in both speed and ability to - * detect errors. - */ -typedef enum { - LZMA_CHECK_NONE = 0, - /**< - * No Check is calculated. - * - * Size of the Check field: 0 bytes - */ - - LZMA_CHECK_CRC32 = 1, - /**< - * CRC32 using the polynomial from the IEEE 802.3 standard - * - * Size of the Check field: 4 bytes - */ - - LZMA_CHECK_CRC64 = 4, - /**< - * CRC64 using the polynomial from the ECMA-182 standard - * - * Size of the Check field: 8 bytes - */ - - LZMA_CHECK_SHA256 = 10 - /**< - * SHA-256 - * - * Size of the Check field: 32 bytes - */ -} lzma_check; - - -/** - * \brief Maximum valid Check ID - * - * The .xz file format specification specifies 16 Check IDs (0-15). Some - * of them are only reserved, that is, no actual Check algorithm has been - * assigned. When decoding, liblzma still accepts unknown Check IDs for - * future compatibility. If a valid but unsupported Check ID is detected, - * liblzma can indicate a warning; see the flags LZMA_TELL_NO_CHECK, - * LZMA_TELL_UNSUPPORTED_CHECK, and LZMA_TELL_ANY_CHECK in container.h. - */ -#define LZMA_CHECK_ID_MAX 15 - - -/** - * \brief Test if the given Check ID is supported - * - * Return true if the given Check ID is supported by this liblzma build. - * Otherwise false is returned. It is safe to call this with a value that - * is not in the range [0, 15]; in that case the return value is always false. - * - * You can assume that LZMA_CHECK_NONE and LZMA_CHECK_CRC32 are always - * supported (even if liblzma is built with limited features). - */ -extern LZMA_API(lzma_bool) lzma_check_is_supported(lzma_check check) - lzma_nothrow lzma_attr_const; - - -/** - * \brief Get the size of the Check field with the given Check ID - * - * Although not all Check IDs have a check algorithm associated, the size of - * every Check is already frozen. This function returns the size (in bytes) of - * the Check field with the specified Check ID. The values are: - * { 0, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64 } - * - * If the argument is not in the range [0, 15], UINT32_MAX is returned. - */ -extern LZMA_API(uint32_t) lzma_check_size(lzma_check check) - lzma_nothrow lzma_attr_const; - - -/** - * \brief Maximum size of a Check field - */ -#define LZMA_CHECK_SIZE_MAX 64 - - -/** - * \brief Calculate CRC32 - * - * Calculate CRC32 using the polynomial from the IEEE 802.3 standard. - * - * \param buf Pointer to the input buffer - * \param size Size of the input buffer - * \param crc Previously returned CRC value. This is used to - * calculate the CRC of a big buffer in smaller chunks. - * Set to zero when starting a new calculation. - * - * \return Updated CRC value, which can be passed to this function - * again to continue CRC calculation. - */ -extern LZMA_API(uint32_t) lzma_crc32( - const uint8_t *buf, size_t size, uint32_t crc) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Calculate CRC64 - * - * Calculate CRC64 using the polynomial from the ECMA-182 standard. - * - * This function is used similarly to lzma_crc32(). See its documentation. - */ -extern LZMA_API(uint64_t) lzma_crc64( - const uint8_t *buf, size_t size, uint64_t crc) - lzma_nothrow lzma_attr_pure; - - -/* - * SHA-256 functions are currently not exported to public API. - * Contact Lasse Collin if you think it should be. - */ - - -/** - * \brief Get the type of the integrity check - * - * This function can be called only immediately after lzma_code() has - * returned LZMA_NO_CHECK, LZMA_UNSUPPORTED_CHECK, or LZMA_GET_CHECK. - * Calling this function in any other situation has undefined behavior. - */ -extern LZMA_API(lzma_check) lzma_get_check(const lzma_stream *strm) - lzma_nothrow; diff --git a/deps/lzma/liblzma/api/lzma/container.h b/deps/lzma/liblzma/api/lzma/container.h deleted file mode 100644 index 7a9ffc6..0000000 --- a/deps/lzma/liblzma/api/lzma/container.h +++ /dev/null @@ -1,424 +0,0 @@ -/** - * \file lzma/container.h - * \brief File formats - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/************ - * Encoding * - ************/ - -/** - * \brief Default compression preset - * - * It's not straightforward to recommend a default preset, because in some - * cases keeping the resource usage relatively low is more important that - * getting the maximum compression ratio. - */ -#define LZMA_PRESET_DEFAULT UINT32_C(6) - - -/** - * \brief Mask for preset level - * - * This is useful only if you need to extract the level from the preset - * variable. That should be rare. - */ -#define LZMA_PRESET_LEVEL_MASK UINT32_C(0x1F) - - -/* - * Preset flags - * - * Currently only one flag is defined. - */ - -/** - * \brief Extreme compression preset - * - * This flag modifies the preset to make the encoding significantly slower - * while improving the compression ratio only marginally. This is useful - * when you don't mind wasting time to get as small result as possible. - * - * This flag doesn't affect the memory usage requirements of the decoder (at - * least not significantly). The memory usage of the encoder may be increased - * a little but only at the lowest preset levels (0-3). - */ -#define LZMA_PRESET_EXTREME (UINT32_C(1) << 31) - - -/** - * \brief Calculate approximate memory usage of easy encoder - * - * This function is a wrapper for lzma_raw_encoder_memusage(). - * - * \param preset Compression preset (level and possible flags) - * - * \return Number of bytes of memory required for the given - * preset when encoding. If an error occurs, for example - * due to unsupported preset, UINT64_MAX is returned. - */ -extern LZMA_API(uint64_t) lzma_easy_encoder_memusage(uint32_t preset) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Calculate approximate decoder memory usage of a preset - * - * This function is a wrapper for lzma_raw_decoder_memusage(). - * - * \param preset Compression preset (level and possible flags) - * - * \return Number of bytes of memory required to decompress a file - * that was compressed using the given preset. If an error - * occurs, for example due to unsupported preset, UINT64_MAX - * is returned. - */ -extern LZMA_API(uint64_t) lzma_easy_decoder_memusage(uint32_t preset) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Initialize .xz Stream encoder using a preset number - * - * This function is intended for those who just want to use the basic features - * if liblzma (that is, most developers out there). - * - * \param strm Pointer to lzma_stream that is at least initialized - * with LZMA_STREAM_INIT. - * \param preset Compression preset to use. A preset consist of level - * number and zero or more flags. Usually flags aren't - * used, so preset is simply a number [0, 9] which match - * the options -0 ... -9 of the xz command line tool. - * Additional flags can be be set using bitwise-or with - * the preset level number, e.g. 6 | LZMA_PRESET_EXTREME. - * \param check Integrity check type to use. See check.h for available - * checks. The xz command line tool defaults to - * LZMA_CHECK_CRC64, which is a good choice if you are - * unsure. LZMA_CHECK_CRC32 is good too as long as the - * uncompressed file is not many gigabytes. - * - * \return - LZMA_OK: Initialization succeeded. Use lzma_code() to - * encode your data. - * - LZMA_MEM_ERROR: Memory allocation failed. - * - LZMA_OPTIONS_ERROR: The given compression preset is not - * supported by this build of liblzma. - * - LZMA_UNSUPPORTED_CHECK: The given check type is not - * supported by this liblzma build. - * - LZMA_PROG_ERROR: One or more of the parameters have values - * that will never be valid. For example, strm == NULL. - * - * If initialization fails (return value is not LZMA_OK), all the memory - * allocated for *strm by liblzma is always freed. Thus, there is no need - * to call lzma_end() after failed initialization. - * - * If initialization succeeds, use lzma_code() to do the actual encoding. - * Valid values for `action' (the second argument of lzma_code()) are - * LZMA_RUN, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, and LZMA_FINISH. In future, - * there may be compression levels or flags that don't support LZMA_SYNC_FLUSH. - */ -extern LZMA_API(lzma_ret) lzma_easy_encoder( - lzma_stream *strm, uint32_t preset, lzma_check check) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Single-call .xz Stream encoding using a preset number - * - * The maximum required output buffer size can be calculated with - * lzma_stream_buffer_bound(). - * - * \param preset Compression preset to use. See the description - * in lzma_easy_encoder(). - * \param check Type of the integrity check to calculate from - * uncompressed data. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * \param in Beginning of the input buffer - * \param in_size Size of the input buffer - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_BUF_ERROR: Not enough output buffer space. - * - LZMA_UNSUPPORTED_CHECK - * - LZMA_OPTIONS_ERROR - * - LZMA_MEM_ERROR - * - LZMA_DATA_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_easy_buffer_encode( - uint32_t preset, lzma_check check, - lzma_allocator *allocator, const uint8_t *in, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow; - - -/** - * \brief Initialize .xz Stream encoder using a custom filter chain - * - * \param strm Pointer to properly prepared lzma_stream - * \param filters Array of filters. This must be terminated with - * filters[n].id = LZMA_VLI_UNKNOWN. See filter.h for - * more information. - * \param check Type of the integrity check to calculate from - * uncompressed data. - * - * \return - LZMA_OK: Initialization was successful. - * - LZMA_MEM_ERROR - * - LZMA_UNSUPPORTED_CHECK - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_stream_encoder(lzma_stream *strm, - const lzma_filter *filters, lzma_check check) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Initialize .lzma encoder (legacy file format) - * - * The .lzma format is sometimes called the LZMA_Alone format, which is the - * reason for the name of this function. The .lzma format supports only the - * LZMA1 filter. There is no support for integrity checks like CRC32. - * - * Use this function if and only if you need to create files readable by - * legacy LZMA tools such as LZMA Utils 4.32.x. Moving to the .xz format - * is strongly recommended. - * - * The valid action values for lzma_code() are LZMA_RUN and LZMA_FINISH. - * No kind of flushing is supported, because the file format doesn't make - * it possible. - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_alone_encoder( - lzma_stream *strm, const lzma_options_lzma *options) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Calculate output buffer size for single-call Stream encoder - * - * When trying to compress uncompressible data, the encoded size will be - * slightly bigger than the input data. This function calculates how much - * output buffer space is required to be sure that lzma_stream_buffer_encode() - * doesn't return LZMA_BUF_ERROR. - * - * The calculated value is not exact, but it is guaranteed to be big enough. - * The actual maximum output space required may be slightly smaller (up to - * about 100 bytes). This should not be a problem in practice. - * - * If the calculated maximum size doesn't fit into size_t or would make the - * Stream grow past LZMA_VLI_MAX (which should never happen in practice), - * zero is returned to indicate the error. - * - * \note The limit calculated by this function applies only to - * single-call encoding. Multi-call encoding may (and probably - * will) have larger maximum expansion when encoding - * uncompressible data. Currently there is no function to - * calculate the maximum expansion of multi-call encoding. - */ -extern LZMA_API(size_t) lzma_stream_buffer_bound(size_t uncompressed_size) - lzma_nothrow; - - -/** - * \brief Single-call .xz Stream encoder - * - * \param filters Array of filters. This must be terminated with - * filters[n].id = LZMA_VLI_UNKNOWN. See filter.h - * for more information. - * \param check Type of the integrity check to calculate from - * uncompressed data. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * \param in Beginning of the input buffer - * \param in_size Size of the input buffer - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_BUF_ERROR: Not enough output buffer space. - * - LZMA_UNSUPPORTED_CHECK - * - LZMA_OPTIONS_ERROR - * - LZMA_MEM_ERROR - * - LZMA_DATA_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_stream_buffer_encode( - lzma_filter *filters, lzma_check check, - lzma_allocator *allocator, const uint8_t *in, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/************ - * Decoding * - ************/ - -/** - * This flag makes lzma_code() return LZMA_NO_CHECK if the input stream - * being decoded has no integrity check. Note that when used with - * lzma_auto_decoder(), all .lzma files will trigger LZMA_NO_CHECK - * if LZMA_TELL_NO_CHECK is used. - */ -#define LZMA_TELL_NO_CHECK UINT32_C(0x01) - - -/** - * This flag makes lzma_code() return LZMA_UNSUPPORTED_CHECK if the input - * stream has an integrity check, but the type of the integrity check is not - * supported by this liblzma version or build. Such files can still be - * decoded, but the integrity check cannot be verified. - */ -#define LZMA_TELL_UNSUPPORTED_CHECK UINT32_C(0x02) - - -/** - * This flag makes lzma_code() return LZMA_GET_CHECK as soon as the type - * of the integrity check is known. The type can then be got with - * lzma_get_check(). - */ -#define LZMA_TELL_ANY_CHECK UINT32_C(0x04) - - -/** - * This flag enables decoding of concatenated files with file formats that - * allow concatenating compressed files as is. From the formats currently - * supported by liblzma, only the .xz format allows concatenated files. - * Concatenated files are not allowed with the legacy .lzma format. - * - * This flag also affects the usage of the `action' argument for lzma_code(). - * When LZMA_CONCATENATED is used, lzma_code() won't return LZMA_STREAM_END - * unless LZMA_FINISH is used as `action'. Thus, the application has to set - * LZMA_FINISH in the same way as it does when encoding. - * - * If LZMA_CONCATENATED is not used, the decoders still accept LZMA_FINISH - * as `action' for lzma_code(), but the usage of LZMA_FINISH isn't required. - */ -#define LZMA_CONCATENATED UINT32_C(0x08) - - -/** - * \brief Initialize .xz Stream decoder - * - * \param strm Pointer to properly prepared lzma_stream - * \param memlimit Memory usage limit as bytes. Use UINT64_MAX - * to effectively disable the limiter. - * \param flags Bitwise-or of zero or more of the decoder flags: - * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, - * LZMA_TELL_ANY_CHECK, LZMA_CONCATENATED - * - * \return - LZMA_OK: Initialization was successful. - * - LZMA_MEM_ERROR: Cannot allocate memory. - * - LZMA_OPTIONS_ERROR: Unsupported flags - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_stream_decoder( - lzma_stream *strm, uint64_t memlimit, uint32_t flags) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Decode .xz Streams and .lzma files with autodetection - * - * This decoder autodetects between the .xz and .lzma file formats, and - * calls lzma_stream_decoder() or lzma_alone_decoder() once the type - * of the input file has been detected. - * - * \param strm Pointer to properly prepared lzma_stream - * \param memlimit Memory usage limit as bytes. Use UINT64_MAX - * to effectively disable the limiter. - * \param flags Bitwise-or of flags, or zero for no flags. - * - * \return - LZMA_OK: Initialization was successful. - * - LZMA_MEM_ERROR: Cannot allocate memory. - * - LZMA_OPTIONS_ERROR: Unsupported flags - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_auto_decoder( - lzma_stream *strm, uint64_t memlimit, uint32_t flags) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Initialize .lzma decoder (legacy file format) - * - * Valid `action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH. - * There is no need to use LZMA_FINISH, but allowing it may simplify - * certain types of applications. - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_alone_decoder( - lzma_stream *strm, uint64_t memlimit) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Single-call .xz Stream decoder - * - * \param memlimit Pointer to how much memory the decoder is allowed - * to allocate. The value pointed by this pointer is - * modified if and only if LZMA_MEMLIMIT_ERROR is - * returned. - * \param flags Bitwise-or of zero or more of the decoder flags: - * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, - * LZMA_CONCATENATED. Note that LZMA_TELL_ANY_CHECK - * is not allowed and will return LZMA_PROG_ERROR. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * \param in Beginning of the input buffer - * \param in_pos The next byte will be read from in[*in_pos]. - * *in_pos is updated only if decoding succeeds. - * \param in_size Size of the input buffer; the first byte that - * won't be read is in[in_size]. - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if decoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return - LZMA_OK: Decoding was successful. - * - LZMA_FORMAT_ERROR - * - LZMA_OPTIONS_ERROR - * - LZMA_DATA_ERROR - * - LZMA_NO_CHECK: This can be returned only if using - * the LZMA_TELL_NO_CHECK flag. - * - LZMA_UNSUPPORTED_CHECK: This can be returned only if using - * the LZMA_TELL_UNSUPPORTED_CHECK flag. - * - LZMA_MEM_ERROR - * - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached. - * The minimum required memlimit value was stored to *memlimit. - * - LZMA_BUF_ERROR: Output buffer was too small. - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_stream_buffer_decode( - uint64_t *memlimit, uint32_t flags, lzma_allocator *allocator, - const uint8_t *in, size_t *in_pos, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) - lzma_nothrow lzma_attr_warn_unused_result; diff --git a/deps/lzma/liblzma/api/lzma/delta.h b/deps/lzma/liblzma/api/lzma/delta.h deleted file mode 100644 index 592fc4f..0000000 --- a/deps/lzma/liblzma/api/lzma/delta.h +++ /dev/null @@ -1,77 +0,0 @@ -/** - * \file lzma/delta.h - * \brief Delta filter - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Filter ID - * - * Filter ID of the Delta filter. This is used as lzma_filter.id. - */ -#define LZMA_FILTER_DELTA LZMA_VLI_C(0x03) - - -/** - * \brief Type of the delta calculation - * - * Currently only byte-wise delta is supported. Other possible types could - * be, for example, delta of 16/32/64-bit little/big endian integers, but - * these are not currently planned since byte-wise delta is almost as good. - */ -typedef enum { - LZMA_DELTA_TYPE_BYTE -} lzma_delta_type; - - -/** - * \brief Options for the Delta filter - * - * These options are needed by both encoder and decoder. - */ -typedef struct { - /** For now, this must always be LZMA_DELTA_TYPE_BYTE. */ - lzma_delta_type type; - - /** - * \brief Delta distance - * - * With the only currently supported type, LZMA_DELTA_TYPE_BYTE, - * the distance is as bytes. - * - * Examples: - * - 16-bit stereo audio: distance = 4 bytes - * - 24-bit RGB image data: distance = 3 bytes - */ - uint32_t dist; -# define LZMA_DELTA_DIST_MIN 1 -# define LZMA_DELTA_DIST_MAX 256 - - /* - * Reserved space to allow possible future extensions without - * breaking the ABI. You should not touch these, because the names - * of these variables may change. These are and will never be used - * when type is LZMA_DELTA_TYPE_BYTE, so it is safe to leave these - * uninitialized. - */ - uint32_t reserved_int1; - uint32_t reserved_int2; - uint32_t reserved_int3; - uint32_t reserved_int4; - void *reserved_ptr1; - void *reserved_ptr2; - -} lzma_options_delta; diff --git a/deps/lzma/liblzma/api/lzma/filter.h b/deps/lzma/liblzma/api/lzma/filter.h deleted file mode 100644 index e0bc163..0000000 --- a/deps/lzma/liblzma/api/lzma/filter.h +++ /dev/null @@ -1,424 +0,0 @@ -/** - * \file lzma/filter.h - * \brief Common filter related types and functions - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Maximum number of filters in a chain - * - * A filter chain can have 1-4 filters, of which three are allowed to change - * the size of the data. Usually only one or two filters are needed. - */ -#define LZMA_FILTERS_MAX 4 - - -/** - * \brief Filter options - * - * This structure is used to pass Filter ID and a pointer filter's - * options to liblzma. A few functions work with a single lzma_filter - * structure, while most functions expect a filter chain. - * - * A filter chain is indicated with an array of lzma_filter structures. - * The array is terminated with .id = LZMA_VLI_UNKNOWN. Thus, the filter - * array must have LZMA_FILTERS_MAX + 1 elements (that is, five) to - * be able to hold any arbitrary filter chain. This is important when - * using lzma_block_header_decode() from block.h, because too small - * array would make liblzma write past the end of the filters array. - */ -typedef struct { - /** - * \brief Filter ID - * - * Use constants whose name begin with `LZMA_FILTER_' to specify - * different filters. In an array of lzma_filter structures, use - * LZMA_VLI_UNKNOWN to indicate end of filters. - * - * \note This is not an enum, because on some systems enums - * cannot be 64-bit. - */ - lzma_vli id; - - /** - * \brief Pointer to filter-specific options structure - * - * If the filter doesn't need options, set this to NULL. If id is - * set to LZMA_VLI_UNKNOWN, options is ignored, and thus - * doesn't need be initialized. - */ - void *options; - -} lzma_filter; - - -/** - * \brief Test if the given Filter ID is supported for encoding - * - * Return true if the give Filter ID is supported for encoding by this - * liblzma build. Otherwise false is returned. - * - * There is no way to list which filters are available in this particular - * liblzma version and build. It would be useless, because the application - * couldn't know what kind of options the filter would need. - */ -extern LZMA_API(lzma_bool) lzma_filter_encoder_is_supported(lzma_vli id) - lzma_nothrow lzma_attr_const; - - -/** - * \brief Test if the given Filter ID is supported for decoding - * - * Return true if the give Filter ID is supported for decoding by this - * liblzma build. Otherwise false is returned. - */ -extern LZMA_API(lzma_bool) lzma_filter_decoder_is_supported(lzma_vli id) - lzma_nothrow lzma_attr_const; - - -/** - * \brief Copy the filters array - * - * Copy the Filter IDs and filter-specific options from src to dest. - * Up to LZMA_FILTERS_MAX filters are copied, plus the terminating - * .id == LZMA_VLI_UNKNOWN. Thus, dest should have at least - * LZMA_FILTERS_MAX + 1 elements space unless the caller knows that - * src is smaller than that. - * - * Unless the filter-specific options is NULL, the Filter ID has to be - * supported by liblzma, because liblzma needs to know the size of every - * filter-specific options structure. The filter-specific options are not - * validated. If options is NULL, any unsupported Filter IDs are copied - * without returning an error. - * - * Old filter-specific options in dest are not freed, so dest doesn't - * need to be initialized by the caller in any way. - * - * If an error occurs, memory possibly already allocated by this function - * is always freed. - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_OPTIONS_ERROR: Unsupported Filter ID and its options - * is not NULL. - * - LZMA_PROG_ERROR: src or dest is NULL. - */ -extern LZMA_API(lzma_ret) lzma_filters_copy(const lzma_filter *src, - lzma_filter *dest, lzma_allocator *allocator) lzma_nothrow; - - -/** - * \brief Calculate approximate memory requirements for raw encoder - * - * This function can be used to calculate the memory requirements for - * Block and Stream encoders too because Block and Stream encoders don't - * need significantly more memory than raw encoder. - * - * \param filters Array of filters terminated with - * .id == LZMA_VLI_UNKNOWN. - * - * \return Number of bytes of memory required for the given - * filter chain when encoding. If an error occurs, - * for example due to unsupported filter chain, - * UINT64_MAX is returned. - */ -extern LZMA_API(uint64_t) lzma_raw_encoder_memusage(const lzma_filter *filters) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Calculate approximate memory requirements for raw decoder - * - * This function can be used to calculate the memory requirements for - * Block and Stream decoders too because Block and Stream decoders don't - * need significantly more memory than raw decoder. - * - * \param filters Array of filters terminated with - * .id == LZMA_VLI_UNKNOWN. - * - * \return Number of bytes of memory required for the given - * filter chain when decoding. If an error occurs, - * for example due to unsupported filter chain, - * UINT64_MAX is returned. - */ -extern LZMA_API(uint64_t) lzma_raw_decoder_memusage(const lzma_filter *filters) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Initialize raw encoder - * - * This function may be useful when implementing custom file formats. - * - * \param strm Pointer to properly prepared lzma_stream - * \param filters Array of lzma_filter structures. The end of the - * array must be marked with .id = LZMA_VLI_UNKNOWN. - * - * The `action' with lzma_code() can be LZMA_RUN, LZMA_SYNC_FLUSH (if the - * filter chain supports it), or LZMA_FINISH. - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_raw_encoder( - lzma_stream *strm, const lzma_filter *filters) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Initialize raw decoder - * - * The initialization of raw decoder goes similarly to raw encoder. - * - * The `action' with lzma_code() can be LZMA_RUN or LZMA_FINISH. Using - * LZMA_FINISH is not required, it is supported just for convenience. - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_raw_decoder( - lzma_stream *strm, const lzma_filter *filters) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Update the filter chain in the encoder - * - * This function is for advanced users only. This function has two slightly - * different purposes: - * - * - After LZMA_FULL_FLUSH when using Stream encoder: Set a new filter - * chain, which will be used starting from the next Block. - * - * - After LZMA_SYNC_FLUSH using Raw, Block, or Stream encoder: Change - * the filter-specific options in the middle of encoding. The actual - * filters in the chain (Filter IDs) cannot be changed. In the future, - * it might become possible to change the filter options without - * using LZMA_SYNC_FLUSH. - * - * While rarely useful, this function may be called also when no data has - * been compressed yet. In that case, this function will behave as if - * LZMA_FULL_FLUSH (Stream encoder) or LZMA_SYNC_FLUSH (Raw or Block - * encoder) had been used right before calling this function. - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_MEMLIMIT_ERROR - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_filters_update( - lzma_stream *strm, const lzma_filter *filters) lzma_nothrow; - - -/** - * \brief Single-call raw encoder - * - * \param filters Array of lzma_filter structures. The end of the - * array must be marked with .id = LZMA_VLI_UNKNOWN. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * \param in Beginning of the input buffer - * \param in_size Size of the input buffer - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_BUF_ERROR: Not enough output buffer space. - * - LZMA_OPTIONS_ERROR - * - LZMA_MEM_ERROR - * - LZMA_DATA_ERROR - * - LZMA_PROG_ERROR - * - * \note There is no function to calculate how big output buffer - * would surely be big enough. (lzma_stream_buffer_bound() - * works only for lzma_stream_buffer_encode(); raw encoder - * won't necessarily meet that bound.) - */ -extern LZMA_API(lzma_ret) lzma_raw_buffer_encode( - const lzma_filter *filters, lzma_allocator *allocator, - const uint8_t *in, size_t in_size, uint8_t *out, - size_t *out_pos, size_t out_size) lzma_nothrow; - - -/** - * \brief Single-call raw decoder - * - * \param filters Array of lzma_filter structures. The end of the - * array must be marked with .id = LZMA_VLI_UNKNOWN. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * \param in Beginning of the input buffer - * \param in_pos The next byte will be read from in[*in_pos]. - * *in_pos is updated only if decoding succeeds. - * \param in_size Size of the input buffer; the first byte that - * won't be read is in[in_size]. - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - */ -extern LZMA_API(lzma_ret) lzma_raw_buffer_decode( - const lzma_filter *filters, lzma_allocator *allocator, - const uint8_t *in, size_t *in_pos, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow; - - -/** - * \brief Get the size of the Filter Properties field - * - * This function may be useful when implementing custom file formats - * using the raw encoder and decoder. - * - * \param size Pointer to uint32_t to hold the size of the properties - * \param filter Filter ID and options (the size of the properties may - * vary depending on the options) - * - * \return - LZMA_OK - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - * - * \note This function validates the Filter ID, but does not - * necessarily validate the options. Thus, it is possible - * that this returns LZMA_OK while the following call to - * lzma_properties_encode() returns LZMA_OPTIONS_ERROR. - */ -extern LZMA_API(lzma_ret) lzma_properties_size( - uint32_t *size, const lzma_filter *filter) lzma_nothrow; - - -/** - * \brief Encode the Filter Properties field - * - * \param filter Filter ID and options - * \param props Buffer to hold the encoded options. The size of - * buffer must have been already determined with - * lzma_properties_size(). - * - * \return - LZMA_OK - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - * - * \note Even this function won't validate more options than actually - * necessary. Thus, it is possible that encoding the properties - * succeeds but using the same options to initialize the encoder - * will fail. - * - * \note If lzma_properties_size() indicated that the size - * of the Filter Properties field is zero, calling - * lzma_properties_encode() is not required, but it - * won't do any harm either. - */ -extern LZMA_API(lzma_ret) lzma_properties_encode( - const lzma_filter *filter, uint8_t *props) lzma_nothrow; - - -/** - * \brief Decode the Filter Properties field - * - * \param filter filter->id must have been set to the correct - * Filter ID. filter->options doesn't need to be - * initialized (it's not freed by this function). The - * decoded options will be stored to filter->options. - * filter->options is set to NULL if there are no - * properties or if an error occurs. - * \param allocator Custom memory allocator used to allocate the - * options. Set to NULL to use the default malloc(), - * and in case of an error, also free(). - * \param props Input buffer containing the properties. - * \param props_size Size of the properties. This must be the exact - * size; giving too much or too little input will - * return LZMA_OPTIONS_ERROR. - * - * \return - LZMA_OK - * - LZMA_OPTIONS_ERROR - * - LZMA_MEM_ERROR - */ -extern LZMA_API(lzma_ret) lzma_properties_decode( - lzma_filter *filter, lzma_allocator *allocator, - const uint8_t *props, size_t props_size) lzma_nothrow; - - -/** - * \brief Calculate encoded size of a Filter Flags field - * - * Knowing the size of Filter Flags is useful to know when allocating - * memory to hold the encoded Filter Flags. - * - * \param size Pointer to integer to hold the calculated size - * \param filter Filter ID and associated options whose encoded - * size is to be calculated - * - * \return - LZMA_OK: *size set successfully. Note that this doesn't - * guarantee that filter->options is valid, thus - * lzma_filter_flags_encode() may still fail. - * - LZMA_OPTIONS_ERROR: Unknown Filter ID or unsupported options. - * - LZMA_PROG_ERROR: Invalid options - * - * \note If you need to calculate size of List of Filter Flags, - * you need to loop over every lzma_filter entry. - */ -extern LZMA_API(lzma_ret) lzma_filter_flags_size( - uint32_t *size, const lzma_filter *filter) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Encode Filter Flags into given buffer - * - * In contrast to some functions, this doesn't allocate the needed buffer. - * This is due to how this function is used internally by liblzma. - * - * \param filter Filter ID and options to be encoded - * \param out Beginning of the output buffer - * \param out_pos out[*out_pos] is the next write position. This - * is updated by the encoder. - * \param out_size out[out_size] is the first byte to not write. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_OPTIONS_ERROR: Invalid or unsupported options. - * - LZMA_PROG_ERROR: Invalid options or not enough output - * buffer space (you should have checked it with - * lzma_filter_flags_size()). - */ -extern LZMA_API(lzma_ret) lzma_filter_flags_encode(const lzma_filter *filter, - uint8_t *out, size_t *out_pos, size_t out_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Decode Filter Flags from given buffer - * - * The decoded result is stored into *filter. The old value of - * filter->options is not free()d. - * - * \return - LZMA_OK - * - LZMA_OPTIONS_ERROR - * - LZMA_MEM_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_filter_flags_decode( - lzma_filter *filter, lzma_allocator *allocator, - const uint8_t *in, size_t *in_pos, size_t in_size) - lzma_nothrow lzma_attr_warn_unused_result; diff --git a/deps/lzma/liblzma/api/lzma/hardware.h b/deps/lzma/liblzma/api/lzma/hardware.h deleted file mode 100644 index e7dd03c..0000000 --- a/deps/lzma/liblzma/api/lzma/hardware.h +++ /dev/null @@ -1,50 +0,0 @@ -/** - * \file lzma/hardware.h - * \brief Hardware information - * - * Since liblzma can consume a lot of system resources, it also provides - * ways to limit the resource usage. Applications linking against liblzma - * need to do the actual decisions how much resources to let liblzma to use. - * To ease making these decisions, liblzma provides functions to find out - * the relevant capabilities of the underlaying hardware. Currently there - * is only a function to find out the amount of RAM, but in the future there - * will be also a function to detect how many concurrent threads the system - * can run. - * - * \note On some operating systems, these function may temporarily - * load a shared library or open file descriptor(s) to find out - * the requested hardware information. Unless the application - * assumes that specific file descriptors are not touched by - * other threads, this should have no effect on thread safety. - * Possible operations involving file descriptors will restart - * the syscalls if they return EINTR. - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Get the total amount of physical memory (RAM) in bytes - * - * This function may be useful when determining a reasonable memory - * usage limit for decompressing or how much memory it is OK to use - * for compressing. - * - * \return On success, the total amount of physical memory in bytes - * is returned. If the amount of RAM cannot be determined, - * zero is returned. This can happen if an error occurs - * or if there is no code in liblzma to detect the amount - * of RAM on the specific operating system. - */ -extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow; diff --git a/deps/lzma/liblzma/api/lzma/index.h b/deps/lzma/liblzma/api/lzma/index.h deleted file mode 100644 index 16bacc2..0000000 --- a/deps/lzma/liblzma/api/lzma/index.h +++ /dev/null @@ -1,682 +0,0 @@ -/** - * \file lzma/index.h - * \brief Handling of .xz Index and related information - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Opaque data type to hold the Index(es) and other information - * - * lzma_index often holds just one .xz Index and possibly the Stream Flags - * of the same Stream and size of the Stream Padding field. However, - * multiple lzma_indexes can be concatenated with lzma_index_cat() and then - * there may be information about multiple Streams in the same lzma_index. - * - * Notes about thread safety: Only one thread may modify lzma_index at - * a time. All functions that take non-const pointer to lzma_index - * modify it. As long as no thread is modifying the lzma_index, getting - * information from the same lzma_index can be done from multiple threads - * at the same time with functions that take a const pointer to - * lzma_index or use lzma_index_iter. The same iterator must be used - * only by one thread at a time, of course, but there can be as many - * iterators for the same lzma_index as needed. - */ -typedef struct lzma_index_s lzma_index; - - -/** - * \brief Iterator to get information about Blocks and Streams - */ -typedef struct { - struct { - /** - * \brief Pointer to Stream Flags - * - * This is NULL if Stream Flags have not been set for - * this Stream with lzma_index_stream_flags(). - */ - const lzma_stream_flags *flags; - - const void *reserved_ptr1; - const void *reserved_ptr2; - const void *reserved_ptr3; - - /** - * \brief Stream number in the lzma_index - * - * The first Stream is 1. - */ - lzma_vli number; - - /** - * \brief Number of Blocks in the Stream - * - * If this is zero, the block structure below has - * undefined values. - */ - lzma_vli block_count; - - /** - * \brief Compressed start offset of this Stream - * - * The offset is relative to the beginning of the lzma_index - * (i.e. usually the beginning of the .xz file). - */ - lzma_vli compressed_offset; - - /** - * \brief Uncompressed start offset of this Stream - * - * The offset is relative to the beginning of the lzma_index - * (i.e. usually the beginning of the .xz file). - */ - lzma_vli uncompressed_offset; - - /** - * \brief Compressed size of this Stream - * - * This includes all headers except the possible - * Stream Padding after this Stream. - */ - lzma_vli compressed_size; - - /** - * \brief Uncompressed size of this Stream - */ - lzma_vli uncompressed_size; - - /** - * \brief Size of Stream Padding after this Stream - * - * If it hasn't been set with lzma_index_stream_padding(), - * this defaults to zero. Stream Padding is always - * a multiple of four bytes. - */ - lzma_vli padding; - - lzma_vli reserved_vli1; - lzma_vli reserved_vli2; - lzma_vli reserved_vli3; - lzma_vli reserved_vli4; - } stream; - - struct { - /** - * \brief Block number in the file - * - * The first Block is 1. - */ - lzma_vli number_in_file; - - /** - * \brief Compressed start offset of this Block - * - * This offset is relative to the beginning of the - * lzma_index (i.e. usually the beginning of the .xz file). - * Normally this is where you should seek in the .xz file - * to start decompressing this Block. - */ - lzma_vli compressed_file_offset; - - /** - * \brief Uncompressed start offset of this Block - * - * This offset is relative to the beginning of the lzma_index - * (i.e. usually the beginning of the .xz file). - * - * When doing random-access reading, it is possible that - * the target offset is not exactly at Block boundary. One - * will need to compare the target offset against - * uncompressed_file_offset or uncompressed_stream_offset, - * and possibly decode and throw away some amount of data - * before reaching the target offset. - */ - lzma_vli uncompressed_file_offset; - - /** - * \brief Block number in this Stream - * - * The first Block is 1. - */ - lzma_vli number_in_stream; - - /** - * \brief Compressed start offset of this Block - * - * This offset is relative to the beginning of the Stream - * containing this Block. - */ - lzma_vli compressed_stream_offset; - - /** - * \brief Uncompressed start offset of this Block - * - * This offset is relative to the beginning of the Stream - * containing this Block. - */ - lzma_vli uncompressed_stream_offset; - - /** - * \brief Uncompressed size of this Block - * - * You should pass this to the Block decoder if you will - * decode this Block. It will allow the Block decoder to - * validate the uncompressed size. - */ - lzma_vli uncompressed_size; - - /** - * \brief Unpadded size of this Block - * - * You should pass this to the Block decoder if you will - * decode this Block. It will allow the Block decoder to - * validate the unpadded size. - */ - lzma_vli unpadded_size; - - /** - * \brief Total compressed size - * - * This includes all headers and padding in this Block. - * This is useful if you need to know how many bytes - * the Block decoder will actually read. - */ - lzma_vli total_size; - - lzma_vli reserved_vli1; - lzma_vli reserved_vli2; - lzma_vli reserved_vli3; - lzma_vli reserved_vli4; - - const void *reserved_ptr1; - const void *reserved_ptr2; - const void *reserved_ptr3; - const void *reserved_ptr4; - } block; - - /* - * Internal data which is used to store the state of the iterator. - * The exact format may vary between liblzma versions, so don't - * touch these in any way. - */ - union { - const void *p; - size_t s; - lzma_vli v; - } internal[6]; -} lzma_index_iter; - - -/** - * \brief Operation mode for lzma_index_iter_next() - */ -typedef enum { - LZMA_INDEX_ITER_ANY = 0, - /**< - * \brief Get the next Block or Stream - * - * Go to the next Block if the current Stream has at least - * one Block left. Otherwise go to the next Stream even if - * it has no Blocks. If the Stream has no Blocks - * (lzma_index_iter.stream.block_count == 0), - * lzma_index_iter.block will have undefined values. - */ - - LZMA_INDEX_ITER_STREAM = 1, - /**< - * \brief Get the next Stream - * - * Go to the next Stream even if the current Stream has - * unread Blocks left. If the next Stream has at least one - * Block, the iterator will point to the first Block. - * If there are no Blocks, lzma_index_iter.block will have - * undefined values. - */ - - LZMA_INDEX_ITER_BLOCK = 2, - /**< - * \brief Get the next Block - * - * Go to the next Block if the current Stream has at least - * one Block left. If the current Stream has no Blocks left, - * the next Stream with at least one Block is located and - * the iterator will be made to point to the first Block of - * that Stream. - */ - - LZMA_INDEX_ITER_NONEMPTY_BLOCK = 3 - /**< - * \brief Get the next non-empty Block - * - * This is like LZMA_INDEX_ITER_BLOCK except that it will - * skip Blocks whose Uncompressed Size is zero. - */ - -} lzma_index_iter_mode; - - -/** - * \brief Calculate memory usage of lzma_index - * - * On disk, the size of the Index field depends on both the number of Records - * stored and how big values the Records store (due to variable-length integer - * encoding). When the Index is kept in lzma_index structure, the memory usage - * depends only on the number of Records/Blocks stored in the Index(es), and - * in case of concatenated lzma_indexes, the number of Streams. The size in - * RAM is almost always significantly bigger than in the encoded form on disk. - * - * This function calculates an approximate amount of memory needed hold - * the given number of Streams and Blocks in lzma_index structure. This - * value may vary between CPU architectures and also between liblzma versions - * if the internal implementation is modified. - */ -extern LZMA_API(uint64_t) lzma_index_memusage( - lzma_vli streams, lzma_vli blocks) lzma_nothrow; - - -/** - * \brief Calculate the memory usage of an existing lzma_index - * - * This is a shorthand for lzma_index_memusage(lzma_index_stream_count(i), - * lzma_index_block_count(i)). - */ -extern LZMA_API(uint64_t) lzma_index_memused(const lzma_index *i) - lzma_nothrow; - - -/** - * \brief Allocate and initialize a new lzma_index structure - * - * \return On success, a pointer to an empty initialized lzma_index is - * returned. If allocation fails, NULL is returned. - */ -extern LZMA_API(lzma_index *) lzma_index_init(lzma_allocator *allocator) - lzma_nothrow; - - -/** - * \brief Deallocate lzma_index - * - * If i is NULL, this does nothing. - */ -extern LZMA_API(void) lzma_index_end(lzma_index *i, lzma_allocator *allocator) - lzma_nothrow; - - -/** - * \brief Add a new Block to lzma_index - * - * \param i Pointer to a lzma_index structure - * \param allocator Pointer to lzma_allocator, or NULL to - * use malloc() - * \param unpadded_size Unpadded Size of a Block. This can be - * calculated with lzma_block_unpadded_size() - * after encoding or decoding the Block. - * \param uncompressed_size Uncompressed Size of a Block. This can be - * taken directly from lzma_block structure - * after encoding or decoding the Block. - * - * Appending a new Block does not invalidate iterators. For example, - * if an iterator was pointing to the end of the lzma_index, after - * lzma_index_append() it is possible to read the next Block with - * an existing iterator. - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_DATA_ERROR: Compressed or uncompressed size of the - * Stream or size of the Index field would grow too big. - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_append( - lzma_index *i, lzma_allocator *allocator, - lzma_vli unpadded_size, lzma_vli uncompressed_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Set the Stream Flags - * - * Set the Stream Flags of the last (and typically the only) Stream - * in lzma_index. This can be useful when reading information from the - * lzma_index, because to decode Blocks, knowing the integrity check type - * is needed. - * - * The given Stream Flags are copied into internal preallocated structure - * in the lzma_index, thus the caller doesn't need to keep the *stream_flags - * available after calling this function. - * - * \return - LZMA_OK - * - LZMA_OPTIONS_ERROR: Unsupported stream_flags->version. - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_stream_flags( - lzma_index *i, const lzma_stream_flags *stream_flags) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Get the types of integrity Checks - * - * If lzma_index_stream_flags() is used to set the Stream Flags for - * every Stream, lzma_index_checks() can be used to get a bitmask to - * indicate which Check types have been used. It can be useful e.g. if - * showing the Check types to the user. - * - * The bitmask is 1 << check_id, e.g. CRC32 is 1 << 1 and SHA-256 is 1 << 10. - */ -extern LZMA_API(uint32_t) lzma_index_checks(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Set the amount of Stream Padding - * - * Set the amount of Stream Padding of the last (and typically the only) - * Stream in the lzma_index. This is needed when planning to do random-access - * reading within multiple concatenated Streams. - * - * By default, the amount of Stream Padding is assumed to be zero bytes. - * - * \return - LZMA_OK - * - LZMA_DATA_ERROR: The file size would grow too big. - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_stream_padding( - lzma_index *i, lzma_vli stream_padding) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Get the number of Streams - */ -extern LZMA_API(lzma_vli) lzma_index_stream_count(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Get the number of Blocks - * - * This returns the total number of Blocks in lzma_index. To get number - * of Blocks in individual Streams, use lzma_index_iter. - */ -extern LZMA_API(lzma_vli) lzma_index_block_count(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Get the size of the Index field as bytes - * - * This is needed to verify the Backward Size field in the Stream Footer. - */ -extern LZMA_API(lzma_vli) lzma_index_size(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Get the total size of the Stream - * - * If multiple lzma_indexes have been combined, this works as if the Blocks - * were in a single Stream. This is useful if you are going to combine - * Blocks from multiple Streams into a single new Stream. - */ -extern LZMA_API(lzma_vli) lzma_index_stream_size(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Get the total size of the Blocks - * - * This doesn't include the Stream Header, Stream Footer, Stream Padding, - * or Index fields. - */ -extern LZMA_API(lzma_vli) lzma_index_total_size(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Get the total size of the file - * - * When no lzma_indexes have been combined with lzma_index_cat() and there is - * no Stream Padding, this function is identical to lzma_index_stream_size(). - * If multiple lzma_indexes have been combined, this includes also the headers - * of each separate Stream and the possible Stream Padding fields. - */ -extern LZMA_API(lzma_vli) lzma_index_file_size(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Get the uncompressed size of the file - */ -extern LZMA_API(lzma_vli) lzma_index_uncompressed_size(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Initialize an iterator - * - * \param iter Pointer to a lzma_index_iter structure - * \param i lzma_index to which the iterator will be associated - * - * This function associates the iterator with the given lzma_index, and calls - * lzma_index_iter_rewind() on the iterator. - * - * This function doesn't allocate any memory, thus there is no - * lzma_index_iter_end(). The iterator is valid as long as the - * associated lzma_index is valid, that is, until lzma_index_end() or - * using it as source in lzma_index_cat(). Specifically, lzma_index doesn't - * become invalid if new Blocks are added to it with lzma_index_append() or - * if it is used as the destination in lzma_index_cat(). - * - * It is safe to make copies of an initialized lzma_index_iter, for example, - * to easily restart reading at some particular position. - */ -extern LZMA_API(void) lzma_index_iter_init( - lzma_index_iter *iter, const lzma_index *i) lzma_nothrow; - - -/** - * \brief Rewind the iterator - * - * Rewind the iterator so that next call to lzma_index_iter_next() will - * return the first Block or Stream. - */ -extern LZMA_API(void) lzma_index_iter_rewind(lzma_index_iter *iter) - lzma_nothrow; - - -/** - * \brief Get the next Block or Stream - * - * \param iter Iterator initialized with lzma_index_iter_init() - * \param mode Specify what kind of information the caller wants - * to get. See lzma_index_iter_mode for details. - * - * \return If next Block or Stream matching the mode was found, *iter - * is updated and this function returns false. If no Block or - * Stream matching the mode is found, *iter is not modified - * and this function returns true. If mode is set to an unknown - * value, *iter is not modified and this function returns true. - */ -extern LZMA_API(lzma_bool) lzma_index_iter_next( - lzma_index_iter *iter, lzma_index_iter_mode mode) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Locate a Block - * - * If it is possible to seek in the .xz file, it is possible to parse - * the Index field(s) and use lzma_index_iter_locate() to do random-access - * reading with granularity of Block size. - * - * \param iter Iterator that was earlier initialized with - * lzma_index_iter_init(). - * \param target Uncompressed target offset which the caller would - * like to locate from the Stream - * - * If the target is smaller than the uncompressed size of the Stream (can be - * checked with lzma_index_uncompressed_size()): - * - Information about the Stream and Block containing the requested - * uncompressed offset is stored into *iter. - * - Internal state of the iterator is adjusted so that - * lzma_index_iter_next() can be used to read subsequent Blocks or Streams. - * - This function returns false. - * - * If target is greater than the uncompressed size of the Stream, *iter - * is not modified, and this function returns true. - */ -extern LZMA_API(lzma_bool) lzma_index_iter_locate( - lzma_index_iter *iter, lzma_vli target) lzma_nothrow; - - -/** - * \brief Concatenate lzma_indexes - * - * Concatenating lzma_indexes is useful when doing random-access reading in - * multi-Stream .xz file, or when combining multiple Streams into single - * Stream. - * - * \param dest lzma_index after which src is appended - * \param src lzma_index to be appended after dest. If this - * function succeeds, the memory allocated for src - * is freed or moved to be part of dest, and all - * iterators pointing to src will become invalid. - * \param allocator Custom memory allocator; can be NULL to use - * malloc() and free(). - * - * \return - LZMA_OK: lzma_indexes were concatenated successfully. - * src is now a dangling pointer. - * - LZMA_DATA_ERROR: *dest would grow too big. - * - LZMA_MEM_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_cat( - lzma_index *dest, lzma_index *src, lzma_allocator *allocator) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Duplicate lzma_index - * - * \return A copy of the lzma_index, or NULL if memory allocation failed. - */ -extern LZMA_API(lzma_index *) lzma_index_dup( - const lzma_index *i, lzma_allocator *allocator) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Initialize .xz Index encoder - * - * \param strm Pointer to properly prepared lzma_stream - * \param i Pointer to lzma_index which should be encoded. - * - * The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH. - * It is enough to use only one of them (you can choose freely; use LZMA_RUN - * to support liblzma versions older than 5.0.0). - * - * \return - LZMA_OK: Initialization succeeded, continue with lzma_code(). - * - LZMA_MEM_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_encoder( - lzma_stream *strm, const lzma_index *i) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Initialize .xz Index decoder - * - * \param strm Pointer to properly prepared lzma_stream - * \param i The decoded Index will be made available via - * this pointer. Initially this function will - * set *i to NULL (the old value is ignored). If - * decoding succeeds (lzma_code() returns - * LZMA_STREAM_END), *i will be set to point - * to a new lzma_index, which the application - * has to later free with lzma_index_end(). - * \param memlimit How much memory the resulting lzma_index is - * allowed to require. - * - * The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH. - * It is enough to use only one of them (you can choose freely; use LZMA_RUN - * to support liblzma versions older than 5.0.0). - * - * \return - LZMA_OK: Initialization succeeded, continue with lzma_code(). - * - LZMA_MEM_ERROR - * - LZMA_MEMLIMIT_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_decoder( - lzma_stream *strm, lzma_index **i, uint64_t memlimit) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Single-call .xz Index encoder - * - * \param i lzma_index to be encoded - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_BUF_ERROR: Output buffer is too small. Use - * lzma_index_size() to find out how much output - * space is needed. - * - LZMA_PROG_ERROR - * - * \note This function doesn't take allocator argument since all - * the internal data is allocated on stack. - */ -extern LZMA_API(lzma_ret) lzma_index_buffer_encode(const lzma_index *i, - uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow; - - -/** - * \brief Single-call .xz Index decoder - * - * \param i If decoding succeeds, *i will point to a new - * lzma_index, which the application has to - * later free with lzma_index_end(). If an error - * occurs, *i will be NULL. The old value of *i - * is always ignored and thus doesn't need to be - * initialized by the caller. - * \param memlimit Pointer to how much memory the resulting - * lzma_index is allowed to require. The value - * pointed by this pointer is modified if and only - * if LZMA_MEMLIMIT_ERROR is returned. - * \param allocator Pointer to lzma_allocator, or NULL to use malloc() - * \param in Beginning of the input buffer - * \param in_pos The next byte will be read from in[*in_pos]. - * *in_pos is updated only if decoding succeeds. - * \param in_size Size of the input buffer; the first byte that - * won't be read is in[in_size]. - * - * \return - LZMA_OK: Decoding was successful. - * - LZMA_MEM_ERROR - * - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached. - * The minimum required memlimit value was stored to *memlimit. - * - LZMA_DATA_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_buffer_decode(lzma_index **i, - uint64_t *memlimit, lzma_allocator *allocator, - const uint8_t *in, size_t *in_pos, size_t in_size) - lzma_nothrow; diff --git a/deps/lzma/liblzma/api/lzma/index_hash.h b/deps/lzma/liblzma/api/lzma/index_hash.h deleted file mode 100644 index fa2e048..0000000 --- a/deps/lzma/liblzma/api/lzma/index_hash.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - * \file lzma/index_hash.h - * \brief Validate Index by using a hash function - * - * Hashing makes it possible to use constant amount of memory to validate - * Index of arbitrary size. - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - -/** - * \brief Opaque data type to hold the Index hash - */ -typedef struct lzma_index_hash_s lzma_index_hash; - - -/** - * \brief Allocate and initialize a new lzma_index_hash structure - * - * If index_hash is NULL, a new lzma_index_hash structure is allocated, - * initialized, and a pointer to it returned. If allocation fails, NULL - * is returned. - * - * If index_hash is non-NULL, it is reinitialized and the same pointer - * returned. In this case, return value cannot be NULL or a different - * pointer than the index_hash that was given as an argument. - */ -extern LZMA_API(lzma_index_hash *) lzma_index_hash_init( - lzma_index_hash *index_hash, lzma_allocator *allocator) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Deallocate lzma_index_hash structure - */ -extern LZMA_API(void) lzma_index_hash_end( - lzma_index_hash *index_hash, lzma_allocator *allocator) - lzma_nothrow; - - -/** - * \brief Add a new Record to an Index hash - * - * \param index Pointer to a lzma_index_hash structure - * \param unpadded_size Unpadded Size of a Block - * \param uncompressed_size Uncompressed Size of a Block - * - * \return - LZMA_OK - * - LZMA_DATA_ERROR: Compressed or uncompressed size of the - * Stream or size of the Index field would grow too big. - * - LZMA_PROG_ERROR: Invalid arguments or this function is being - * used when lzma_index_hash_decode() has already been used. - */ -extern LZMA_API(lzma_ret) lzma_index_hash_append(lzma_index_hash *index_hash, - lzma_vli unpadded_size, lzma_vli uncompressed_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Decode and validate the Index field - * - * After telling the sizes of all Blocks with lzma_index_hash_append(), - * the actual Index field is decoded with this function. Specifically, - * once decoding of the Index field has been started, no more Records - * can be added using lzma_index_hash_append(). - * - * This function doesn't use lzma_stream structure to pass the input data. - * Instead, the input buffer is specified using three arguments. This is - * because it matches better the internal APIs of liblzma. - * - * \param index_hash Pointer to a lzma_index_hash structure - * \param in Pointer to the beginning of the input buffer - * \param in_pos in[*in_pos] is the next byte to process - * \param in_size in[in_size] is the first byte not to process - * - * \return - LZMA_OK: So far good, but more input is needed. - * - LZMA_STREAM_END: Index decoded successfully and it matches - * the Records given with lzma_index_hash_append(). - * - LZMA_DATA_ERROR: Index is corrupt or doesn't match the - * information given with lzma_index_hash_append(). - * - LZMA_BUF_ERROR: Cannot progress because *in_pos >= in_size. - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_hash_decode(lzma_index_hash *index_hash, - const uint8_t *in, size_t *in_pos, size_t in_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Get the size of the Index field as bytes - * - * This is needed to verify the Backward Size field in the Stream Footer. - */ -extern LZMA_API(lzma_vli) lzma_index_hash_size( - const lzma_index_hash *index_hash) - lzma_nothrow lzma_attr_pure; diff --git a/deps/lzma/liblzma/api/lzma/lzma.h b/deps/lzma/liblzma/api/lzma/lzma.h deleted file mode 100644 index 3f8e095..0000000 --- a/deps/lzma/liblzma/api/lzma/lzma.h +++ /dev/null @@ -1,420 +0,0 @@ -/** - * \file lzma/lzma.h - * \brief LZMA1 and LZMA2 filters - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief LZMA1 Filter ID - * - * LZMA1 is the very same thing as what was called just LZMA in LZMA Utils, - * 7-Zip, and LZMA SDK. It's called LZMA1 here to prevent developers from - * accidentally using LZMA when they actually want LZMA2. - * - * LZMA1 shouldn't be used for new applications unless you _really_ know - * what you are doing. LZMA2 is almost always a better choice. - */ -#define LZMA_FILTER_LZMA1 LZMA_VLI_C(0x4000000000000001) - -/** - * \brief LZMA2 Filter ID - * - * Usually you want this instead of LZMA1. Compared to LZMA1, LZMA2 adds - * support for LZMA_SYNC_FLUSH, uncompressed chunks (smaller expansion - * when trying to compress uncompressible data), possibility to change - * lc/lp/pb in the middle of encoding, and some other internal improvements. - */ -#define LZMA_FILTER_LZMA2 LZMA_VLI_C(0x21) - - -/** - * \brief Match finders - * - * Match finder has major effect on both speed and compression ratio. - * Usually hash chains are faster than binary trees. - * - * If you will use LZMA_SYNC_FLUSH often, the hash chains may be a better - * choice, because binary trees get much higher compression ratio penalty - * with LZMA_SYNC_FLUSH. - * - * The memory usage formulas are only rough estimates, which are closest to - * reality when dict_size is a power of two. The formulas are more complex - * in reality, and can also change a little between liblzma versions. Use - * lzma_raw_encoder_memusage() to get more accurate estimate of memory usage. - */ -typedef enum { - LZMA_MF_HC3 = 0x03, - /**< - * \brief Hash Chain with 2- and 3-byte hashing - * - * Minimum nice_len: 3 - * - * Memory usage: - * - dict_size <= 16 MiB: dict_size * 7.5 - * - dict_size > 16 MiB: dict_size * 5.5 + 64 MiB - */ - - LZMA_MF_HC4 = 0x04, - /**< - * \brief Hash Chain with 2-, 3-, and 4-byte hashing - * - * Minimum nice_len: 4 - * - * Memory usage: - * - dict_size <= 32 MiB: dict_size * 7.5 - * - dict_size > 32 MiB: dict_size * 6.5 - */ - - LZMA_MF_BT2 = 0x12, - /**< - * \brief Binary Tree with 2-byte hashing - * - * Minimum nice_len: 2 - * - * Memory usage: dict_size * 9.5 - */ - - LZMA_MF_BT3 = 0x13, - /**< - * \brief Binary Tree with 2- and 3-byte hashing - * - * Minimum nice_len: 3 - * - * Memory usage: - * - dict_size <= 16 MiB: dict_size * 11.5 - * - dict_size > 16 MiB: dict_size * 9.5 + 64 MiB - */ - - LZMA_MF_BT4 = 0x14 - /**< - * \brief Binary Tree with 2-, 3-, and 4-byte hashing - * - * Minimum nice_len: 4 - * - * Memory usage: - * - dict_size <= 32 MiB: dict_size * 11.5 - * - dict_size > 32 MiB: dict_size * 10.5 - */ -} lzma_match_finder; - - -/** - * \brief Test if given match finder is supported - * - * Return true if the given match finder is supported by this liblzma build. - * Otherwise false is returned. It is safe to call this with a value that - * isn't listed in lzma_match_finder enumeration; the return value will be - * false. - * - * There is no way to list which match finders are available in this - * particular liblzma version and build. It would be useless, because - * a new match finder, which the application developer wasn't aware, - * could require giving additional options to the encoder that the older - * match finders don't need. - */ -extern LZMA_API(lzma_bool) lzma_mf_is_supported(lzma_match_finder match_finder) - lzma_nothrow lzma_attr_const; - - -/** - * \brief Compression modes - * - * This selects the function used to analyze the data produced by the match - * finder. - */ -typedef enum { - LZMA_MODE_FAST = 1, - /**< - * \brief Fast compression - * - * Fast mode is usually at its best when combined with - * a hash chain match finder. - */ - - LZMA_MODE_NORMAL = 2 - /**< - * \brief Normal compression - * - * This is usually notably slower than fast mode. Use this - * together with binary tree match finders to expose the - * full potential of the LZMA1 or LZMA2 encoder. - */ -} lzma_mode; - - -/** - * \brief Test if given compression mode is supported - * - * Return true if the given compression mode is supported by this liblzma - * build. Otherwise false is returned. It is safe to call this with a value - * that isn't listed in lzma_mode enumeration; the return value will be false. - * - * There is no way to list which modes are available in this particular - * liblzma version and build. It would be useless, because a new compression - * mode, which the application developer wasn't aware, could require giving - * additional options to the encoder that the older modes don't need. - */ -extern LZMA_API(lzma_bool) lzma_mode_is_supported(lzma_mode mode) - lzma_nothrow lzma_attr_const; - - -/** - * \brief Options specific to the LZMA1 and LZMA2 filters - * - * Since LZMA1 and LZMA2 share most of the code, it's simplest to share - * the options structure too. For encoding, all but the reserved variables - * need to be initialized unless specifically mentioned otherwise. - * lzma_lzma_preset() can be used to get a good starting point. - * - * For raw decoding, both LZMA1 and LZMA2 need dict_size, preset_dict, and - * preset_dict_size (if preset_dict != NULL). LZMA1 needs also lc, lp, and pb. - */ -typedef struct { - /** - * \brief Dictionary size in bytes - * - * Dictionary size indicates how many bytes of the recently processed - * uncompressed data is kept in memory. One method to reduce size of - * the uncompressed data is to store distance-length pairs, which - * indicate what data to repeat from the dictionary buffer. Thus, - * the bigger the dictionary, the better the compression ratio - * usually is. - * - * Maximum size of the dictionary depends on multiple things: - * - Memory usage limit - * - Available address space (not a problem on 64-bit systems) - * - Selected match finder (encoder only) - * - * Currently the maximum dictionary size for encoding is 1.5 GiB - * (i.e. (UINT32_C(1) << 30) + (UINT32_C(1) << 29)) even on 64-bit - * systems for certain match finder implementation reasons. In the - * future, there may be match finders that support bigger - * dictionaries. - * - * Decoder already supports dictionaries up to 4 GiB - 1 B (i.e. - * UINT32_MAX), so increasing the maximum dictionary size of the - * encoder won't cause problems for old decoders. - * - * Because extremely small dictionaries sizes would have unneeded - * overhead in the decoder, the minimum dictionary size is 4096 bytes. - * - * \note When decoding, too big dictionary does no other harm - * than wasting memory. - */ - uint32_t dict_size; -# define LZMA_DICT_SIZE_MIN UINT32_C(4096) -# define LZMA_DICT_SIZE_DEFAULT (UINT32_C(1) << 23) - - /** - * \brief Pointer to an initial dictionary - * - * It is possible to initialize the LZ77 history window using - * a preset dictionary. It is useful when compressing many - * similar, relatively small chunks of data independently from - * each other. The preset dictionary should contain typical - * strings that occur in the files being compressed. The most - * probable strings should be near the end of the preset dictionary. - * - * This feature should be used only in special situations. For - * now, it works correctly only with raw encoding and decoding. - * Currently none of the container formats supported by - * liblzma allow preset dictionary when decoding, thus if - * you create a .xz or .lzma file with preset dictionary, it - * cannot be decoded with the regular decoder functions. In the - * future, the .xz format will likely get support for preset - * dictionary though. - */ - const uint8_t *preset_dict; - - /** - * \brief Size of the preset dictionary - * - * Specifies the size of the preset dictionary. If the size is - * bigger than dict_size, only the last dict_size bytes are - * processed. - * - * This variable is read only when preset_dict is not NULL. - * If preset_dict is not NULL but preset_dict_size is zero, - * no preset dictionary is used (identical to only setting - * preset_dict to NULL). - */ - uint32_t preset_dict_size; - - /** - * \brief Number of literal context bits - * - * How many of the highest bits of the previous uncompressed - * eight-bit byte (also known as `literal') are taken into - * account when predicting the bits of the next literal. - * - * E.g. in typical English text, an upper-case letter is - * often followed by a lower-case letter, and a lower-case - * letter is usually followed by another lower-case letter. - * In the US-ASCII character set, the highest three bits are 010 - * for upper-case letters and 011 for lower-case letters. - * When lc is at least 3, the literal coding can take advantage of - * this property in the uncompressed data. - * - * There is a limit that applies to literal context bits and literal - * position bits together: lc + lp <= 4. Without this limit the - * decoding could become very slow, which could have security related - * results in some cases like email servers doing virus scanning. - * This limit also simplifies the internal implementation in liblzma. - * - * There may be LZMA1 streams that have lc + lp > 4 (maximum possible - * lc would be 8). It is not possible to decode such streams with - * liblzma. - */ - uint32_t lc; -# define LZMA_LCLP_MIN 0 -# define LZMA_LCLP_MAX 4 -# define LZMA_LC_DEFAULT 3 - - /** - * \brief Number of literal position bits - * - * lp affects what kind of alignment in the uncompressed data is - * assumed when encoding literals. A literal is a single 8-bit byte. - * See pb below for more information about alignment. - */ - uint32_t lp; -# define LZMA_LP_DEFAULT 0 - - /** - * \brief Number of position bits - * - * pb affects what kind of alignment in the uncompressed data is - * assumed in general. The default means four-byte alignment - * (2^ pb =2^2=4), which is often a good choice when there's - * no better guess. - * - * When the aligment is known, setting pb accordingly may reduce - * the file size a little. E.g. with text files having one-byte - * alignment (US-ASCII, ISO-8859-*, UTF-8), setting pb=0 can - * improve compression slightly. For UTF-16 text, pb=1 is a good - * choice. If the alignment is an odd number like 3 bytes, pb=0 - * might be the best choice. - * - * Even though the assumed alignment can be adjusted with pb and - * lp, LZMA1 and LZMA2 still slightly favor 16-byte alignment. - * It might be worth taking into account when designing file formats - * that are likely to be often compressed with LZMA1 or LZMA2. - */ - uint32_t pb; -# define LZMA_PB_MIN 0 -# define LZMA_PB_MAX 4 -# define LZMA_PB_DEFAULT 2 - - /** Compression mode */ - lzma_mode mode; - - /** - * \brief Nice length of a match - * - * This determines how many bytes the encoder compares from the match - * candidates when looking for the best match. Once a match of at - * least nice_len bytes long is found, the encoder stops looking for - * better candidates and encodes the match. (Naturally, if the found - * match is actually longer than nice_len, the actual length is - * encoded; it's not truncated to nice_len.) - * - * Bigger values usually increase the compression ratio and - * compression time. For most files, 32 to 128 is a good value, - * which gives very good compression ratio at good speed. - * - * The exact minimum value depends on the match finder. The maximum - * is 273, which is the maximum length of a match that LZMA1 and - * LZMA2 can encode. - */ - uint32_t nice_len; - - /** Match finder ID */ - lzma_match_finder mf; - - /** - * \brief Maximum search depth in the match finder - * - * For every input byte, match finder searches through the hash chain - * or binary tree in a loop, each iteration going one step deeper in - * the chain or tree. The searching stops if - * - a match of at least nice_len bytes long is found; - * - all match candidates from the hash chain or binary tree have - * been checked; or - * - maximum search depth is reached. - * - * Maximum search depth is needed to prevent the match finder from - * wasting too much time in case there are lots of short match - * candidates. On the other hand, stopping the search before all - * candidates have been checked can reduce compression ratio. - * - * Setting depth to zero tells liblzma to use an automatic default - * value, that depends on the selected match finder and nice_len. - * The default is in the range [4, 200] or so (it may vary between - * liblzma versions). - * - * Using a bigger depth value than the default can increase - * compression ratio in some cases. There is no strict maximum value, - * but high values (thousands or millions) should be used with care: - * the encoder could remain fast enough with typical input, but - * malicious input could cause the match finder to slow down - * dramatically, possibly creating a denial of service attack. - */ - uint32_t depth; - - /* - * Reserved space to allow possible future extensions without - * breaking the ABI. You should not touch these, because the names - * of these variables may change. These are and will never be used - * with the currently supported options, so it is safe to leave these - * uninitialized. - */ - uint32_t reserved_int1; - uint32_t reserved_int2; - uint32_t reserved_int3; - uint32_t reserved_int4; - uint32_t reserved_int5; - uint32_t reserved_int6; - uint32_t reserved_int7; - uint32_t reserved_int8; - lzma_reserved_enum reserved_enum1; - lzma_reserved_enum reserved_enum2; - lzma_reserved_enum reserved_enum3; - lzma_reserved_enum reserved_enum4; - void *reserved_ptr1; - void *reserved_ptr2; - -} lzma_options_lzma; - - -/** - * \brief Set a compression preset to lzma_options_lzma structure - * - * 0 is the fastest and 9 is the slowest. These match the switches -0 .. -9 - * of the xz command line tool. In addition, it is possible to bitwise-or - * flags to the preset. Currently only LZMA_PRESET_EXTREME is supported. - * The flags are defined in container.h, because the flags are used also - * with lzma_easy_encoder(). - * - * The preset values are subject to changes between liblzma versions. - * - * This function is available only if LZMA1 or LZMA2 encoder has been enabled - * when building liblzma. - * - * \return On success, false is returned. If the preset is not - * supported, true is returned. - */ -extern LZMA_API(lzma_bool) lzma_lzma_preset( - lzma_options_lzma *options, uint32_t preset) lzma_nothrow; diff --git a/deps/lzma/liblzma/api/lzma/stream_flags.h b/deps/lzma/liblzma/api/lzma/stream_flags.h deleted file mode 100644 index bbdd408..0000000 --- a/deps/lzma/liblzma/api/lzma/stream_flags.h +++ /dev/null @@ -1,223 +0,0 @@ -/** - * \file lzma/stream_flags.h - * \brief .xz Stream Header and Stream Footer encoder and decoder - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Size of Stream Header and Stream Footer - * - * Stream Header and Stream Footer have the same size and they are not - * going to change even if a newer version of the .xz file format is - * developed in future. - */ -#define LZMA_STREAM_HEADER_SIZE 12 - - -/** - * \brief Options for encoding/decoding Stream Header and Stream Footer - */ -typedef struct { - /** - * \brief Stream Flags format version - * - * To prevent API and ABI breakages if new features are needed in - * Stream Header or Stream Footer, a version number is used to - * indicate which fields in this structure are in use. For now, - * version must always be zero. With non-zero version, the - * lzma_stream_header_encode() and lzma_stream_footer_encode() - * will return LZMA_OPTIONS_ERROR. - * - * lzma_stream_header_decode() and lzma_stream_footer_decode() - * will always set this to the lowest value that supports all the - * features indicated by the Stream Flags field. The application - * must check that the version number set by the decoding functions - * is supported by the application. Otherwise it is possible that - * the application will decode the Stream incorrectly. - */ - uint32_t version; - - /** - * \brief Backward Size - * - * Backward Size must be a multiple of four bytes. In this Stream - * format version, Backward Size is the size of the Index field. - * - * Backward Size isn't actually part of the Stream Flags field, but - * it is convenient to include in this structure anyway. Backward - * Size is present only in the Stream Footer. There is no need to - * initialize backward_size when encoding Stream Header. - * - * lzma_stream_header_decode() always sets backward_size to - * LZMA_VLI_UNKNOWN so that it is convenient to use - * lzma_stream_flags_compare() when both Stream Header and Stream - * Footer have been decoded. - */ - lzma_vli backward_size; -# define LZMA_BACKWARD_SIZE_MIN 4 -# define LZMA_BACKWARD_SIZE_MAX (LZMA_VLI_C(1) << 34) - - /** - * \brief Check ID - * - * This indicates the type of the integrity check calculated from - * uncompressed data. - */ - lzma_check check; - - /* - * Reserved space to allow possible future extensions without - * breaking the ABI. You should not touch these, because the - * names of these variables may change. - * - * (We will never be able to use all of these since Stream Flags - * is just two bytes plus Backward Size of four bytes. But it's - * nice to have the proper types when they are needed.) - */ - lzma_reserved_enum reserved_enum1; - lzma_reserved_enum reserved_enum2; - lzma_reserved_enum reserved_enum3; - lzma_reserved_enum reserved_enum4; - lzma_bool reserved_bool1; - lzma_bool reserved_bool2; - lzma_bool reserved_bool3; - lzma_bool reserved_bool4; - lzma_bool reserved_bool5; - lzma_bool reserved_bool6; - lzma_bool reserved_bool7; - lzma_bool reserved_bool8; - uint32_t reserved_int1; - uint32_t reserved_int2; - -} lzma_stream_flags; - - -/** - * \brief Encode Stream Header - * - * \param options Stream Header options to be encoded. - * options->backward_size is ignored and doesn't - * need to be initialized. - * \param out Beginning of the output buffer of - * LZMA_STREAM_HEADER_SIZE bytes. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_OPTIONS_ERROR: options->version is not supported by - * this liblzma version. - * - LZMA_PROG_ERROR: Invalid options. - */ -extern LZMA_API(lzma_ret) lzma_stream_header_encode( - const lzma_stream_flags *options, uint8_t *out) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Encode Stream Footer - * - * \param options Stream Footer options to be encoded. - * \param out Beginning of the output buffer of - * LZMA_STREAM_HEADER_SIZE bytes. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_OPTIONS_ERROR: options->version is not supported by - * this liblzma version. - * - LZMA_PROG_ERROR: Invalid options. - */ -extern LZMA_API(lzma_ret) lzma_stream_footer_encode( - const lzma_stream_flags *options, uint8_t *out) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Decode Stream Header - * - * \param options Target for the decoded Stream Header options. - * \param in Beginning of the input buffer of - * LZMA_STREAM_HEADER_SIZE bytes. - * - * options->backward_size is always set to LZMA_VLI_UNKNOWN. This is to - * help comparing Stream Flags from Stream Header and Stream Footer with - * lzma_stream_flags_compare(). - * - * \return - LZMA_OK: Decoding was successful. - * - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given - * buffer cannot be Stream Header. - * - LZMA_DATA_ERROR: CRC32 doesn't match, thus the header - * is corrupt. - * - LZMA_OPTIONS_ERROR: Unsupported options are present - * in the header. - * - * \note When decoding .xz files that contain multiple Streams, it may - * make sense to print "file format not recognized" only if - * decoding of the Stream Header of the _first_ Stream gives - * LZMA_FORMAT_ERROR. If non-first Stream Header gives - * LZMA_FORMAT_ERROR, the message used for LZMA_DATA_ERROR is - * probably more appropriate. - * - * For example, Stream decoder in liblzma uses LZMA_DATA_ERROR if - * LZMA_FORMAT_ERROR is returned by lzma_stream_header_decode() - * when decoding non-first Stream. - */ -extern LZMA_API(lzma_ret) lzma_stream_header_decode( - lzma_stream_flags *options, const uint8_t *in) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Decode Stream Footer - * - * \param options Target for the decoded Stream Header options. - * \param in Beginning of the input buffer of - * LZMA_STREAM_HEADER_SIZE bytes. - * - * \return - LZMA_OK: Decoding was successful. - * - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given - * buffer cannot be Stream Footer. - * - LZMA_DATA_ERROR: CRC32 doesn't match, thus the Stream Footer - * is corrupt. - * - LZMA_OPTIONS_ERROR: Unsupported options are present - * in Stream Footer. - * - * \note If Stream Header was already decoded successfully, but - * decoding Stream Footer returns LZMA_FORMAT_ERROR, the - * application should probably report some other error message - * than "file format not recognized", since the file more likely - * is corrupt (possibly truncated). Stream decoder in liblzma - * uses LZMA_DATA_ERROR in this situation. - */ -extern LZMA_API(lzma_ret) lzma_stream_footer_decode( - lzma_stream_flags *options, const uint8_t *in) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Compare two lzma_stream_flags structures - * - * backward_size values are compared only if both are not - * LZMA_VLI_UNKNOWN. - * - * \return - LZMA_OK: Both are equal. If either had backward_size set - * to LZMA_VLI_UNKNOWN, backward_size values were not - * compared or validated. - * - LZMA_DATA_ERROR: The structures differ. - * - LZMA_OPTIONS_ERROR: version in either structure is greater - * than the maximum supported version (currently zero). - * - LZMA_PROG_ERROR: Invalid value, e.g. invalid check or - * backward_size. - */ -extern LZMA_API(lzma_ret) lzma_stream_flags_compare( - const lzma_stream_flags *a, const lzma_stream_flags *b) - lzma_nothrow lzma_attr_pure; diff --git a/deps/lzma/liblzma/api/lzma/version.h b/deps/lzma/liblzma/api/lzma/version.h deleted file mode 100644 index beec18e..0000000 --- a/deps/lzma/liblzma/api/lzma/version.h +++ /dev/null @@ -1,121 +0,0 @@ -/** - * \file lzma/version.h - * \brief Version number - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/* - * Version number split into components - */ -#define LZMA_VERSION_MAJOR 5 -#define LZMA_VERSION_MINOR 0 -#define LZMA_VERSION_PATCH 7 -#define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE - -#ifndef LZMA_VERSION_COMMIT -# define LZMA_VERSION_COMMIT "" -#endif - - -/* - * Map symbolic stability levels to integers. - */ -#define LZMA_VERSION_STABILITY_ALPHA 0 -#define LZMA_VERSION_STABILITY_BETA 1 -#define LZMA_VERSION_STABILITY_STABLE 2 - - -/** - * \brief Compile-time version number - * - * The version number is of format xyyyzzzs where - * - x = major - * - yyy = minor - * - zzz = revision - * - s indicates stability: 0 = alpha, 1 = beta, 2 = stable - * - * The same xyyyzzz triplet is never reused with different stability levels. - * For example, if 5.1.0alpha has been released, there will never be 5.1.0beta - * or 5.1.0 stable. - * - * \note The version number of liblzma has nothing to with - * the version number of Igor Pavlov's LZMA SDK. - */ -#define LZMA_VERSION (LZMA_VERSION_MAJOR * UINT32_C(10000000) \ - + LZMA_VERSION_MINOR * UINT32_C(10000) \ - + LZMA_VERSION_PATCH * UINT32_C(10) \ - + LZMA_VERSION_STABILITY) - - -/* - * Macros to construct the compile-time version string - */ -#if LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_ALPHA -# define LZMA_VERSION_STABILITY_STRING "alpha" -#elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_BETA -# define LZMA_VERSION_STABILITY_STRING "beta" -#elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_STABLE -# define LZMA_VERSION_STABILITY_STRING "" -#else -# error Incorrect LZMA_VERSION_STABILITY -#endif - -#define LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit) \ - #major "." #minor "." #patch stability commit - -#define LZMA_VERSION_STRING_C(major, minor, patch, stability, commit) \ - LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit) - - -/** - * \brief Compile-time version as a string - * - * This can be for example "4.999.5alpha", "4.999.8beta", or "5.0.0" (stable - * versions don't have any "stable" suffix). In future, a snapshot built - * from source code repository may include an additional suffix, for example - * "4.999.8beta-21-g1d92". The commit ID won't be available in numeric form - * in LZMA_VERSION macro. - */ -#define LZMA_VERSION_STRING LZMA_VERSION_STRING_C( \ - LZMA_VERSION_MAJOR, LZMA_VERSION_MINOR, \ - LZMA_VERSION_PATCH, LZMA_VERSION_STABILITY_STRING, \ - LZMA_VERSION_COMMIT) - - -/* #ifndef is needed for use with windres (MinGW or Cygwin). */ -#ifndef LZMA_H_INTERNAL_RC - -/** - * \brief Run-time version number as an integer - * - * Return the value of LZMA_VERSION macro at the compile time of liblzma. - * This allows the application to compare if it was built against the same, - * older, or newer version of liblzma that is currently running. - */ -extern LZMA_API(uint32_t) lzma_version_number(void) - lzma_nothrow lzma_attr_const; - - -/** - * \brief Run-time version as a string - * - * This function may be useful if you want to display which version of - * liblzma your application is currently using. - */ -extern LZMA_API(const char *) lzma_version_string(void) - lzma_nothrow lzma_attr_const; - -#endif diff --git a/deps/lzma/liblzma/api/lzma/vli.h b/deps/lzma/liblzma/api/lzma/vli.h deleted file mode 100644 index 9ad13f2..0000000 --- a/deps/lzma/liblzma/api/lzma/vli.h +++ /dev/null @@ -1,166 +0,0 @@ -/** - * \file lzma/vli.h - * \brief Variable-length integer handling - * - * In the .xz format, most integers are encoded in a variable-length - * representation, which is sometimes called little endian base-128 encoding. - * This saves space when smaller values are more likely than bigger values. - * - * The encoding scheme encodes seven bits to every byte, using minimum - * number of bytes required to represent the given value. Encodings that use - * non-minimum number of bytes are invalid, thus every integer has exactly - * one encoded representation. The maximum number of bits in a VLI is 63, - * thus the vli argument must be less than or equal to UINT64_MAX / 2. You - * should use LZMA_VLI_MAX for clarity. - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Maximum supported value of a variable-length integer - */ -#define LZMA_VLI_MAX (UINT64_MAX / 2) - -/** - * \brief VLI value to denote that the value is unknown - */ -#define LZMA_VLI_UNKNOWN UINT64_MAX - -/** - * \brief Maximum supported encoded length of variable length integers - */ -#define LZMA_VLI_BYTES_MAX 9 - -/** - * \brief VLI constant suffix - */ -#define LZMA_VLI_C(n) UINT64_C(n) - - -/** - * \brief Variable-length integer type - * - * Valid VLI values are in the range [0, LZMA_VLI_MAX]. Unknown value is - * indicated with LZMA_VLI_UNKNOWN, which is the maximum value of the - * underlaying integer type. - * - * lzma_vli will be uint64_t for the foreseeable future. If a bigger size - * is needed in the future, it is guaranteed that 2 * LZMA_VLI_MAX will - * not overflow lzma_vli. This simplifies integer overflow detection. - */ -typedef uint64_t lzma_vli; - - -/** - * \brief Validate a variable-length integer - * - * This is useful to test that application has given acceptable values - * for example in the uncompressed_size and compressed_size variables. - * - * \return True if the integer is representable as VLI or if it - * indicates unknown value. - */ -#define lzma_vli_is_valid(vli) \ - ((vli) <= LZMA_VLI_MAX || (vli) == LZMA_VLI_UNKNOWN) - - -/** - * \brief Encode a variable-length integer - * - * This function has two modes: single-call and multi-call. Single-call mode - * encodes the whole integer at once; it is an error if the output buffer is - * too small. Multi-call mode saves the position in *vli_pos, and thus it is - * possible to continue encoding if the buffer becomes full before the whole - * integer has been encoded. - * - * \param vli Integer to be encoded - * \param vli_pos How many VLI-encoded bytes have already been written - * out. When starting to encode a new integer in - * multi-call mode, *vli_pos must be set to zero. - * To use single-call encoding, set vli_pos to NULL. - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return Slightly different return values are used in multi-call and - * single-call modes. - * - * Single-call (vli_pos == NULL): - * - LZMA_OK: Integer successfully encoded. - * - LZMA_PROG_ERROR: Arguments are not sane. This can be due - * to too little output space; single-call mode doesn't use - * LZMA_BUF_ERROR, since the application should have checked - * the encoded size with lzma_vli_size(). - * - * Multi-call (vli_pos != NULL): - * - LZMA_OK: So far all OK, but the integer is not - * completely written out yet. - * - LZMA_STREAM_END: Integer successfully encoded. - * - LZMA_BUF_ERROR: No output space was provided. - * - LZMA_PROG_ERROR: Arguments are not sane. - */ -extern LZMA_API(lzma_ret) lzma_vli_encode(lzma_vli vli, size_t *vli_pos, - uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow; - - -/** - * \brief Decode a variable-length integer - * - * Like lzma_vli_encode(), this function has single-call and multi-call modes. - * - * \param vli Pointer to decoded integer. The decoder will - * initialize it to zero when *vli_pos == 0, so - * application isn't required to initialize *vli. - * \param vli_pos How many bytes have already been decoded. When - * starting to decode a new integer in multi-call - * mode, *vli_pos must be initialized to zero. To - * use single-call decoding, set vli_pos to NULL. - * \param in Beginning of the input buffer - * \param in_pos The next byte will be read from in[*in_pos]. - * \param in_size Size of the input buffer; the first byte that - * won't be read is in[in_size]. - * - * \return Slightly different return values are used in multi-call and - * single-call modes. - * - * Single-call (vli_pos == NULL): - * - LZMA_OK: Integer successfully decoded. - * - LZMA_DATA_ERROR: Integer is corrupt. This includes hitting - * the end of the input buffer before the whole integer was - * decoded; providing no input at all will use LZMA_DATA_ERROR. - * - LZMA_PROG_ERROR: Arguments are not sane. - * - * Multi-call (vli_pos != NULL): - * - LZMA_OK: So far all OK, but the integer is not - * completely decoded yet. - * - LZMA_STREAM_END: Integer successfully decoded. - * - LZMA_DATA_ERROR: Integer is corrupt. - * - LZMA_BUF_ERROR: No input was provided. - * - LZMA_PROG_ERROR: Arguments are not sane. - */ -extern LZMA_API(lzma_ret) lzma_vli_decode(lzma_vli *vli, size_t *vli_pos, - const uint8_t *in, size_t *in_pos, size_t in_size) - lzma_nothrow; - - -/** - * \brief Get the number of bytes required to encode a VLI - * - * \return Number of bytes on success (1-9). If vli isn't valid, - * zero is returned. - */ -extern LZMA_API(uint32_t) lzma_vli_size(lzma_vli vli) - lzma_nothrow lzma_attr_pure; diff --git a/deps/lzma/liblzma/check/Makefile.inc b/deps/lzma/liblzma/check/Makefile.inc deleted file mode 100644 index e4067a9..0000000 --- a/deps/lzma/liblzma/check/Makefile.inc +++ /dev/null @@ -1,51 +0,0 @@ -## -## Author: Lasse Collin -## -## This file has been put into the public domain. -## You can do whatever you want with this file. -## - -EXTRA_DIST += \ - check/crc32_tablegen.c \ - check/crc64_tablegen.c - -liblzma_la_SOURCES += \ - check/check.c \ - check/check.h \ - check/crc_macros.h - -if COND_CHECK_CRC32 -if COND_SMALL -liblzma_la_SOURCES += check/crc32_small.c -else -liblzma_la_SOURCES += \ - check/crc32_table.c \ - check/crc32_table_le.h \ - check/crc32_table_be.h -if COND_ASM_X86 -liblzma_la_SOURCES += check/crc32_x86.S -else -liblzma_la_SOURCES += check/crc32_fast.c -endif -endif -endif - -if COND_CHECK_CRC64 -if COND_SMALL -liblzma_la_SOURCES += check/crc64_small.c -else -liblzma_la_SOURCES += \ - check/crc64_table.c \ - check/crc64_table_le.h \ - check/crc64_table_be.h -if COND_ASM_X86 -liblzma_la_SOURCES += check/crc64_x86.S -else -liblzma_la_SOURCES += check/crc64_fast.c -endif -endif -endif - -if COND_CHECK_SHA256 -liblzma_la_SOURCES += check/sha256.c -endif diff --git a/deps/lzma/liblzma/check/check.c b/deps/lzma/liblzma/check/check.c deleted file mode 100644 index 428ddae..0000000 --- a/deps/lzma/liblzma/check/check.c +++ /dev/null @@ -1,174 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file check.c -/// \brief Single API to access different integrity checks -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "check.h" - - -extern LZMA_API(lzma_bool) -lzma_check_is_supported(lzma_check type) -{ - if ((unsigned int)(type) > LZMA_CHECK_ID_MAX) - return false; - - static const lzma_bool available_checks[LZMA_CHECK_ID_MAX + 1] = { - true, // LZMA_CHECK_NONE - -#ifdef HAVE_CHECK_CRC32 - true, -#else - false, -#endif - - false, // Reserved - false, // Reserved - -#ifdef HAVE_CHECK_CRC64 - true, -#else - false, -#endif - - false, // Reserved - false, // Reserved - false, // Reserved - false, // Reserved - false, // Reserved - -#ifdef HAVE_CHECK_SHA256 - true, -#else - false, -#endif - - false, // Reserved - false, // Reserved - false, // Reserved - false, // Reserved - false, // Reserved - }; - - return available_checks[(unsigned int)(type)]; -} - - -extern LZMA_API(uint32_t) -lzma_check_size(lzma_check type) -{ - if ((unsigned int)(type) > LZMA_CHECK_ID_MAX) - return UINT32_MAX; - - // See file-format.txt section 2.1.1.2. - static const uint8_t check_sizes[LZMA_CHECK_ID_MAX + 1] = { - 0, - 4, 4, 4, - 8, 8, 8, - 16, 16, 16, - 32, 32, 32, - 64, 64, 64 - }; - - return check_sizes[(unsigned int)(type)]; -} - - -extern void -lzma_check_init(lzma_check_state *check, lzma_check type) -{ - switch (type) { - case LZMA_CHECK_NONE: - break; - -#ifdef HAVE_CHECK_CRC32 - case LZMA_CHECK_CRC32: - check->state.crc32 = 0; - break; -#endif - -#ifdef HAVE_CHECK_CRC64 - case LZMA_CHECK_CRC64: - check->state.crc64 = 0; - break; -#endif - -#ifdef HAVE_CHECK_SHA256 - case LZMA_CHECK_SHA256: - lzma_sha256_init(check); - break; -#endif - - default: - break; - } - - return; -} - - -extern void -lzma_check_update(lzma_check_state *check, lzma_check type, - const uint8_t *buf, size_t size) -{ - switch (type) { -#ifdef HAVE_CHECK_CRC32 - case LZMA_CHECK_CRC32: - check->state.crc32 = lzma_crc32(buf, size, check->state.crc32); - break; -#endif - -#ifdef HAVE_CHECK_CRC64 - case LZMA_CHECK_CRC64: - check->state.crc64 = lzma_crc64(buf, size, check->state.crc64); - break; -#endif - -#ifdef HAVE_CHECK_SHA256 - case LZMA_CHECK_SHA256: - lzma_sha256_update(buf, size, check); - break; -#endif - - default: - break; - } - - return; -} - - -extern void -lzma_check_finish(lzma_check_state *check, lzma_check type) -{ - switch (type) { -#ifdef HAVE_CHECK_CRC32 - case LZMA_CHECK_CRC32: - check->buffer.u32[0] = conv32le(check->state.crc32); - break; -#endif - -#ifdef HAVE_CHECK_CRC64 - case LZMA_CHECK_CRC64: - check->buffer.u64[0] = conv64le(check->state.crc64); - break; -#endif - -#ifdef HAVE_CHECK_SHA256 - case LZMA_CHECK_SHA256: - lzma_sha256_finish(check); - break; -#endif - - default: - break; - } - - return; -} diff --git a/deps/lzma/liblzma/check/check.h b/deps/lzma/liblzma/check/check.h deleted file mode 100644 index e100d2b..0000000 --- a/deps/lzma/liblzma/check/check.h +++ /dev/null @@ -1,95 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file check.h -/// \brief Internal API to different integrity check functions -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_CHECK_H -#define LZMA_CHECK_H - -#include "common.h" - - -// Index hashing needs the best possible hash function (preferably -// a cryptographic hash) for maximum reliability. -#if defined(HAVE_CHECK_SHA256) -# define LZMA_CHECK_BEST LZMA_CHECK_SHA256 -#elif defined(HAVE_CHECK_CRC64) -# define LZMA_CHECK_BEST LZMA_CHECK_CRC64 -#else -# define LZMA_CHECK_BEST LZMA_CHECK_CRC32 -#endif - - -/// \brief Structure to hold internal state of the check being calculated -/// -/// \note This is not in the public API because this structure may -/// change in future if new integrity check algorithms are added. -typedef struct { - /// Buffer to hold the final result and a temporary buffer for SHA256. - union { - uint8_t u8[64]; - uint32_t u32[16]; - uint64_t u64[8]; - } buffer; - - /// Check-specific data - union { - uint32_t crc32; - uint64_t crc64; - - struct { - /// Internal state - uint32_t state[8]; - - /// Size of the message excluding padding - uint64_t size; - } sha256; - } state; - -} lzma_check_state; - - -/// lzma_crc32_table[0] is needed by LZ encoder so we need to keep -/// the array two-dimensional. -#ifdef HAVE_SMALL -extern uint32_t lzma_crc32_table[1][256]; -extern void lzma_crc32_init(void); -#else -extern const uint32_t lzma_crc32_table[8][256]; -extern const uint64_t lzma_crc64_table[4][256]; -#endif - - -/// \brief Initialize *check depending on type -/// -/// \return LZMA_OK on success. LZMA_UNSUPPORTED_CHECK if the type is not -/// supported by the current version or build of liblzma. -/// LZMA_PROG_ERROR if type > LZMA_CHECK_ID_MAX. -extern void lzma_check_init(lzma_check_state *check, lzma_check type); - -/// Update the check state -extern void lzma_check_update(lzma_check_state *check, lzma_check type, - const uint8_t *buf, size_t size); - -/// Finish the check calculation and store the result to check->buffer.u8. -extern void lzma_check_finish(lzma_check_state *check, lzma_check type); - - -/// Prepare SHA-256 state for new input. -extern void lzma_sha256_init(lzma_check_state *check); - -/// Update the SHA-256 hash state -extern void lzma_sha256_update( - const uint8_t *buf, size_t size, lzma_check_state *check); - -/// Finish the SHA-256 calculation and store the result to check->buffer.u8. -extern void lzma_sha256_finish(lzma_check_state *check); - -#endif diff --git a/deps/lzma/liblzma/check/crc32_fast.c b/deps/lzma/liblzma/check/crc32_fast.c deleted file mode 100644 index 3de0263..0000000 --- a/deps/lzma/liblzma/check/crc32_fast.c +++ /dev/null @@ -1,82 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file crc32.c -/// \brief CRC32 calculation -/// -/// Calculate the CRC32 using the slice-by-eight algorithm. -/// It is explained in this document: -/// http://www.intel.com/technology/comms/perfnet/download/CRC_generators.pdf -/// The code in this file is not the same as in Intel's paper, but -/// the basic principle is identical. -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "check.h" -#include "crc_macros.h" - - -// If you make any changes, do some benchmarking! Seemingly unrelated -// changes can very easily ruin the performance (and very probably is -// very compiler dependent). -extern LZMA_API(uint32_t) -lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc) -{ - crc = ~crc; - -#ifdef WORDS_BIGENDIAN - crc = bswap32(crc); -#endif - - if (size > 8) { - // Fix the alignment, if needed. The if statement above - // ensures that this won't read past the end of buf[]. - while ((uintptr_t)(buf) & 7) { - crc = lzma_crc32_table[0][*buf++ ^ A(crc)] ^ S8(crc); - --size; - } - - // Calculate the position where to stop. - const uint8_t *const limit = buf + (size & ~(size_t)(7)); - - // Calculate how many bytes must be calculated separately - // before returning the result. - size &= (size_t)(7); - - // Calculate the CRC32 using the slice-by-eight algorithm. - while (buf < limit) { - crc ^= *(const uint32_t *)(buf); - buf += 4; - - crc = lzma_crc32_table[7][A(crc)] - ^ lzma_crc32_table[6][B(crc)] - ^ lzma_crc32_table[5][C(crc)] - ^ lzma_crc32_table[4][D(crc)]; - - const uint32_t tmp = *(const uint32_t *)(buf); - buf += 4; - - // At least with some compilers, it is critical for - // performance, that the crc variable is XORed - // between the two table-lookup pairs. - crc = lzma_crc32_table[3][A(tmp)] - ^ lzma_crc32_table[2][B(tmp)] - ^ crc - ^ lzma_crc32_table[1][C(tmp)] - ^ lzma_crc32_table[0][D(tmp)]; - } - } - - while (size-- != 0) - crc = lzma_crc32_table[0][*buf++ ^ A(crc)] ^ S8(crc); - -#ifdef WORDS_BIGENDIAN - crc = bswap32(crc); -#endif - - return ~crc; -} diff --git a/deps/lzma/liblzma/check/crc32_small.c b/deps/lzma/liblzma/check/crc32_small.c deleted file mode 100644 index 5f8a328..0000000 --- a/deps/lzma/liblzma/check/crc32_small.c +++ /dev/null @@ -1,61 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file crc32_small.c -/// \brief CRC32 calculation (size-optimized) -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "check.h" - - -uint32_t lzma_crc32_table[1][256]; - - -static void -crc32_init(void) -{ - static const uint32_t poly32 = UINT32_C(0xEDB88320); - - for (size_t b = 0; b < 256; ++b) { - uint32_t r = b; - for (size_t i = 0; i < 8; ++i) { - if (r & 1) - r = (r >> 1) ^ poly32; - else - r >>= 1; - } - - lzma_crc32_table[0][b] = r; - } - - return; -} - - -extern void -lzma_crc32_init(void) -{ - mythread_once(crc32_init); - return; -} - - -extern LZMA_API(uint32_t) -lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc) -{ - lzma_crc32_init(); - - crc = ~crc; - - while (size != 0) { - crc = lzma_crc32_table[0][*buf++ ^ (crc & 0xFF)] ^ (crc >> 8); - --size; - } - - return ~crc; -} diff --git a/deps/lzma/liblzma/check/crc32_table.c b/deps/lzma/liblzma/check/crc32_table.c deleted file mode 100644 index 368874e..0000000 --- a/deps/lzma/liblzma/check/crc32_table.c +++ /dev/null @@ -1,19 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file crc32_table.c -/// \brief Precalculated CRC32 table with correct endianness -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "common.h" - -#ifdef WORDS_BIGENDIAN -# include "crc32_table_be.h" -#else -# include "crc32_table_le.h" -#endif diff --git a/deps/lzma/liblzma/check/crc32_table_be.h b/deps/lzma/liblzma/check/crc32_table_be.h deleted file mode 100644 index c483cb6..0000000 --- a/deps/lzma/liblzma/check/crc32_table_be.h +++ /dev/null @@ -1,525 +0,0 @@ -/* This file has been automatically generated by crc32_tablegen.c. */ - -const uint32_t lzma_crc32_table[8][256] = { - { - 0x00000000, 0x96300777, 0x2C610EEE, 0xBA510999, - 0x19C46D07, 0x8FF46A70, 0x35A563E9, 0xA395649E, - 0x3288DB0E, 0xA4B8DC79, 0x1EE9D5E0, 0x88D9D297, - 0x2B4CB609, 0xBD7CB17E, 0x072DB8E7, 0x911DBF90, - 0x6410B71D, 0xF220B06A, 0x4871B9F3, 0xDE41BE84, - 0x7DD4DA1A, 0xEBE4DD6D, 0x51B5D4F4, 0xC785D383, - 0x56986C13, 0xC0A86B64, 0x7AF962FD, 0xECC9658A, - 0x4F5C0114, 0xD96C0663, 0x633D0FFA, 0xF50D088D, - 0xC8206E3B, 0x5E10694C, 0xE44160D5, 0x727167A2, - 0xD1E4033C, 0x47D4044B, 0xFD850DD2, 0x6BB50AA5, - 0xFAA8B535, 0x6C98B242, 0xD6C9BBDB, 0x40F9BCAC, - 0xE36CD832, 0x755CDF45, 0xCF0DD6DC, 0x593DD1AB, - 0xAC30D926, 0x3A00DE51, 0x8051D7C8, 0x1661D0BF, - 0xB5F4B421, 0x23C4B356, 0x9995BACF, 0x0FA5BDB8, - 0x9EB80228, 0x0888055F, 0xB2D90CC6, 0x24E90BB1, - 0x877C6F2F, 0x114C6858, 0xAB1D61C1, 0x3D2D66B6, - 0x9041DC76, 0x0671DB01, 0xBC20D298, 0x2A10D5EF, - 0x8985B171, 0x1FB5B606, 0xA5E4BF9F, 0x33D4B8E8, - 0xA2C90778, 0x34F9000F, 0x8EA80996, 0x18980EE1, - 0xBB0D6A7F, 0x2D3D6D08, 0x976C6491, 0x015C63E6, - 0xF4516B6B, 0x62616C1C, 0xD8306585, 0x4E0062F2, - 0xED95066C, 0x7BA5011B, 0xC1F40882, 0x57C40FF5, - 0xC6D9B065, 0x50E9B712, 0xEAB8BE8B, 0x7C88B9FC, - 0xDF1DDD62, 0x492DDA15, 0xF37CD38C, 0x654CD4FB, - 0x5861B24D, 0xCE51B53A, 0x7400BCA3, 0xE230BBD4, - 0x41A5DF4A, 0xD795D83D, 0x6DC4D1A4, 0xFBF4D6D3, - 0x6AE96943, 0xFCD96E34, 0x468867AD, 0xD0B860DA, - 0x732D0444, 0xE51D0333, 0x5F4C0AAA, 0xC97C0DDD, - 0x3C710550, 0xAA410227, 0x10100BBE, 0x86200CC9, - 0x25B56857, 0xB3856F20, 0x09D466B9, 0x9FE461CE, - 0x0EF9DE5E, 0x98C9D929, 0x2298D0B0, 0xB4A8D7C7, - 0x173DB359, 0x810DB42E, 0x3B5CBDB7, 0xAD6CBAC0, - 0x2083B8ED, 0xB6B3BF9A, 0x0CE2B603, 0x9AD2B174, - 0x3947D5EA, 0xAF77D29D, 0x1526DB04, 0x8316DC73, - 0x120B63E3, 0x843B6494, 0x3E6A6D0D, 0xA85A6A7A, - 0x0BCF0EE4, 0x9DFF0993, 0x27AE000A, 0xB19E077D, - 0x44930FF0, 0xD2A30887, 0x68F2011E, 0xFEC20669, - 0x5D5762F7, 0xCB676580, 0x71366C19, 0xE7066B6E, - 0x761BD4FE, 0xE02BD389, 0x5A7ADA10, 0xCC4ADD67, - 0x6FDFB9F9, 0xF9EFBE8E, 0x43BEB717, 0xD58EB060, - 0xE8A3D6D6, 0x7E93D1A1, 0xC4C2D838, 0x52F2DF4F, - 0xF167BBD1, 0x6757BCA6, 0xDD06B53F, 0x4B36B248, - 0xDA2B0DD8, 0x4C1B0AAF, 0xF64A0336, 0x607A0441, - 0xC3EF60DF, 0x55DF67A8, 0xEF8E6E31, 0x79BE6946, - 0x8CB361CB, 0x1A8366BC, 0xA0D26F25, 0x36E26852, - 0x95770CCC, 0x03470BBB, 0xB9160222, 0x2F260555, - 0xBE3BBAC5, 0x280BBDB2, 0x925AB42B, 0x046AB35C, - 0xA7FFD7C2, 0x31CFD0B5, 0x8B9ED92C, 0x1DAEDE5B, - 0xB0C2649B, 0x26F263EC, 0x9CA36A75, 0x0A936D02, - 0xA906099C, 0x3F360EEB, 0x85670772, 0x13570005, - 0x824ABF95, 0x147AB8E2, 0xAE2BB17B, 0x381BB60C, - 0x9B8ED292, 0x0DBED5E5, 0xB7EFDC7C, 0x21DFDB0B, - 0xD4D2D386, 0x42E2D4F1, 0xF8B3DD68, 0x6E83DA1F, - 0xCD16BE81, 0x5B26B9F6, 0xE177B06F, 0x7747B718, - 0xE65A0888, 0x706A0FFF, 0xCA3B0666, 0x5C0B0111, - 0xFF9E658F, 0x69AE62F8, 0xD3FF6B61, 0x45CF6C16, - 0x78E20AA0, 0xEED20DD7, 0x5483044E, 0xC2B30339, - 0x612667A7, 0xF71660D0, 0x4D476949, 0xDB776E3E, - 0x4A6AD1AE, 0xDC5AD6D9, 0x660BDF40, 0xF03BD837, - 0x53AEBCA9, 0xC59EBBDE, 0x7FCFB247, 0xE9FFB530, - 0x1CF2BDBD, 0x8AC2BACA, 0x3093B353, 0xA6A3B424, - 0x0536D0BA, 0x9306D7CD, 0x2957DE54, 0xBF67D923, - 0x2E7A66B3, 0xB84A61C4, 0x021B685D, 0x942B6F2A, - 0x37BE0BB4, 0xA18E0CC3, 0x1BDF055A, 0x8DEF022D - }, { - 0x00000000, 0x41311B19, 0x82623632, 0xC3532D2B, - 0x04C56C64, 0x45F4777D, 0x86A75A56, 0xC796414F, - 0x088AD9C8, 0x49BBC2D1, 0x8AE8EFFA, 0xCBD9F4E3, - 0x0C4FB5AC, 0x4D7EAEB5, 0x8E2D839E, 0xCF1C9887, - 0x5112C24A, 0x1023D953, 0xD370F478, 0x9241EF61, - 0x55D7AE2E, 0x14E6B537, 0xD7B5981C, 0x96848305, - 0x59981B82, 0x18A9009B, 0xDBFA2DB0, 0x9ACB36A9, - 0x5D5D77E6, 0x1C6C6CFF, 0xDF3F41D4, 0x9E0E5ACD, - 0xA2248495, 0xE3159F8C, 0x2046B2A7, 0x6177A9BE, - 0xA6E1E8F1, 0xE7D0F3E8, 0x2483DEC3, 0x65B2C5DA, - 0xAAAE5D5D, 0xEB9F4644, 0x28CC6B6F, 0x69FD7076, - 0xAE6B3139, 0xEF5A2A20, 0x2C09070B, 0x6D381C12, - 0xF33646DF, 0xB2075DC6, 0x715470ED, 0x30656BF4, - 0xF7F32ABB, 0xB6C231A2, 0x75911C89, 0x34A00790, - 0xFBBC9F17, 0xBA8D840E, 0x79DEA925, 0x38EFB23C, - 0xFF79F373, 0xBE48E86A, 0x7D1BC541, 0x3C2ADE58, - 0x054F79F0, 0x447E62E9, 0x872D4FC2, 0xC61C54DB, - 0x018A1594, 0x40BB0E8D, 0x83E823A6, 0xC2D938BF, - 0x0DC5A038, 0x4CF4BB21, 0x8FA7960A, 0xCE968D13, - 0x0900CC5C, 0x4831D745, 0x8B62FA6E, 0xCA53E177, - 0x545DBBBA, 0x156CA0A3, 0xD63F8D88, 0x970E9691, - 0x5098D7DE, 0x11A9CCC7, 0xD2FAE1EC, 0x93CBFAF5, - 0x5CD76272, 0x1DE6796B, 0xDEB55440, 0x9F844F59, - 0x58120E16, 0x1923150F, 0xDA703824, 0x9B41233D, - 0xA76BFD65, 0xE65AE67C, 0x2509CB57, 0x6438D04E, - 0xA3AE9101, 0xE29F8A18, 0x21CCA733, 0x60FDBC2A, - 0xAFE124AD, 0xEED03FB4, 0x2D83129F, 0x6CB20986, - 0xAB2448C9, 0xEA1553D0, 0x29467EFB, 0x687765E2, - 0xF6793F2F, 0xB7482436, 0x741B091D, 0x352A1204, - 0xF2BC534B, 0xB38D4852, 0x70DE6579, 0x31EF7E60, - 0xFEF3E6E7, 0xBFC2FDFE, 0x7C91D0D5, 0x3DA0CBCC, - 0xFA368A83, 0xBB07919A, 0x7854BCB1, 0x3965A7A8, - 0x4B98833B, 0x0AA99822, 0xC9FAB509, 0x88CBAE10, - 0x4F5DEF5F, 0x0E6CF446, 0xCD3FD96D, 0x8C0EC274, - 0x43125AF3, 0x022341EA, 0xC1706CC1, 0x804177D8, - 0x47D73697, 0x06E62D8E, 0xC5B500A5, 0x84841BBC, - 0x1A8A4171, 0x5BBB5A68, 0x98E87743, 0xD9D96C5A, - 0x1E4F2D15, 0x5F7E360C, 0x9C2D1B27, 0xDD1C003E, - 0x120098B9, 0x533183A0, 0x9062AE8B, 0xD153B592, - 0x16C5F4DD, 0x57F4EFC4, 0x94A7C2EF, 0xD596D9F6, - 0xE9BC07AE, 0xA88D1CB7, 0x6BDE319C, 0x2AEF2A85, - 0xED796BCA, 0xAC4870D3, 0x6F1B5DF8, 0x2E2A46E1, - 0xE136DE66, 0xA007C57F, 0x6354E854, 0x2265F34D, - 0xE5F3B202, 0xA4C2A91B, 0x67918430, 0x26A09F29, - 0xB8AEC5E4, 0xF99FDEFD, 0x3ACCF3D6, 0x7BFDE8CF, - 0xBC6BA980, 0xFD5AB299, 0x3E099FB2, 0x7F3884AB, - 0xB0241C2C, 0xF1150735, 0x32462A1E, 0x73773107, - 0xB4E17048, 0xF5D06B51, 0x3683467A, 0x77B25D63, - 0x4ED7FACB, 0x0FE6E1D2, 0xCCB5CCF9, 0x8D84D7E0, - 0x4A1296AF, 0x0B238DB6, 0xC870A09D, 0x8941BB84, - 0x465D2303, 0x076C381A, 0xC43F1531, 0x850E0E28, - 0x42984F67, 0x03A9547E, 0xC0FA7955, 0x81CB624C, - 0x1FC53881, 0x5EF42398, 0x9DA70EB3, 0xDC9615AA, - 0x1B0054E5, 0x5A314FFC, 0x996262D7, 0xD85379CE, - 0x174FE149, 0x567EFA50, 0x952DD77B, 0xD41CCC62, - 0x138A8D2D, 0x52BB9634, 0x91E8BB1F, 0xD0D9A006, - 0xECF37E5E, 0xADC26547, 0x6E91486C, 0x2FA05375, - 0xE836123A, 0xA9070923, 0x6A542408, 0x2B653F11, - 0xE479A796, 0xA548BC8F, 0x661B91A4, 0x272A8ABD, - 0xE0BCCBF2, 0xA18DD0EB, 0x62DEFDC0, 0x23EFE6D9, - 0xBDE1BC14, 0xFCD0A70D, 0x3F838A26, 0x7EB2913F, - 0xB924D070, 0xF815CB69, 0x3B46E642, 0x7A77FD5B, - 0xB56B65DC, 0xF45A7EC5, 0x370953EE, 0x763848F7, - 0xB1AE09B8, 0xF09F12A1, 0x33CC3F8A, 0x72FD2493 - }, { - 0x00000000, 0x376AC201, 0x6ED48403, 0x59BE4602, - 0xDCA80907, 0xEBC2CB06, 0xB27C8D04, 0x85164F05, - 0xB851130E, 0x8F3BD10F, 0xD685970D, 0xE1EF550C, - 0x64F91A09, 0x5393D808, 0x0A2D9E0A, 0x3D475C0B, - 0x70A3261C, 0x47C9E41D, 0x1E77A21F, 0x291D601E, - 0xAC0B2F1B, 0x9B61ED1A, 0xC2DFAB18, 0xF5B56919, - 0xC8F23512, 0xFF98F713, 0xA626B111, 0x914C7310, - 0x145A3C15, 0x2330FE14, 0x7A8EB816, 0x4DE47A17, - 0xE0464D38, 0xD72C8F39, 0x8E92C93B, 0xB9F80B3A, - 0x3CEE443F, 0x0B84863E, 0x523AC03C, 0x6550023D, - 0x58175E36, 0x6F7D9C37, 0x36C3DA35, 0x01A91834, - 0x84BF5731, 0xB3D59530, 0xEA6BD332, 0xDD011133, - 0x90E56B24, 0xA78FA925, 0xFE31EF27, 0xC95B2D26, - 0x4C4D6223, 0x7B27A022, 0x2299E620, 0x15F32421, - 0x28B4782A, 0x1FDEBA2B, 0x4660FC29, 0x710A3E28, - 0xF41C712D, 0xC376B32C, 0x9AC8F52E, 0xADA2372F, - 0xC08D9A70, 0xF7E75871, 0xAE591E73, 0x9933DC72, - 0x1C259377, 0x2B4F5176, 0x72F11774, 0x459BD575, - 0x78DC897E, 0x4FB64B7F, 0x16080D7D, 0x2162CF7C, - 0xA4748079, 0x931E4278, 0xCAA0047A, 0xFDCAC67B, - 0xB02EBC6C, 0x87447E6D, 0xDEFA386F, 0xE990FA6E, - 0x6C86B56B, 0x5BEC776A, 0x02523168, 0x3538F369, - 0x087FAF62, 0x3F156D63, 0x66AB2B61, 0x51C1E960, - 0xD4D7A665, 0xE3BD6464, 0xBA032266, 0x8D69E067, - 0x20CBD748, 0x17A11549, 0x4E1F534B, 0x7975914A, - 0xFC63DE4F, 0xCB091C4E, 0x92B75A4C, 0xA5DD984D, - 0x989AC446, 0xAFF00647, 0xF64E4045, 0xC1248244, - 0x4432CD41, 0x73580F40, 0x2AE64942, 0x1D8C8B43, - 0x5068F154, 0x67023355, 0x3EBC7557, 0x09D6B756, - 0x8CC0F853, 0xBBAA3A52, 0xE2147C50, 0xD57EBE51, - 0xE839E25A, 0xDF53205B, 0x86ED6659, 0xB187A458, - 0x3491EB5D, 0x03FB295C, 0x5A456F5E, 0x6D2FAD5F, - 0x801B35E1, 0xB771F7E0, 0xEECFB1E2, 0xD9A573E3, - 0x5CB33CE6, 0x6BD9FEE7, 0x3267B8E5, 0x050D7AE4, - 0x384A26EF, 0x0F20E4EE, 0x569EA2EC, 0x61F460ED, - 0xE4E22FE8, 0xD388EDE9, 0x8A36ABEB, 0xBD5C69EA, - 0xF0B813FD, 0xC7D2D1FC, 0x9E6C97FE, 0xA90655FF, - 0x2C101AFA, 0x1B7AD8FB, 0x42C49EF9, 0x75AE5CF8, - 0x48E900F3, 0x7F83C2F2, 0x263D84F0, 0x115746F1, - 0x944109F4, 0xA32BCBF5, 0xFA958DF7, 0xCDFF4FF6, - 0x605D78D9, 0x5737BAD8, 0x0E89FCDA, 0x39E33EDB, - 0xBCF571DE, 0x8B9FB3DF, 0xD221F5DD, 0xE54B37DC, - 0xD80C6BD7, 0xEF66A9D6, 0xB6D8EFD4, 0x81B22DD5, - 0x04A462D0, 0x33CEA0D1, 0x6A70E6D3, 0x5D1A24D2, - 0x10FE5EC5, 0x27949CC4, 0x7E2ADAC6, 0x494018C7, - 0xCC5657C2, 0xFB3C95C3, 0xA282D3C1, 0x95E811C0, - 0xA8AF4DCB, 0x9FC58FCA, 0xC67BC9C8, 0xF1110BC9, - 0x740744CC, 0x436D86CD, 0x1AD3C0CF, 0x2DB902CE, - 0x4096AF91, 0x77FC6D90, 0x2E422B92, 0x1928E993, - 0x9C3EA696, 0xAB546497, 0xF2EA2295, 0xC580E094, - 0xF8C7BC9F, 0xCFAD7E9E, 0x9613389C, 0xA179FA9D, - 0x246FB598, 0x13057799, 0x4ABB319B, 0x7DD1F39A, - 0x3035898D, 0x075F4B8C, 0x5EE10D8E, 0x698BCF8F, - 0xEC9D808A, 0xDBF7428B, 0x82490489, 0xB523C688, - 0x88649A83, 0xBF0E5882, 0xE6B01E80, 0xD1DADC81, - 0x54CC9384, 0x63A65185, 0x3A181787, 0x0D72D586, - 0xA0D0E2A9, 0x97BA20A8, 0xCE0466AA, 0xF96EA4AB, - 0x7C78EBAE, 0x4B1229AF, 0x12AC6FAD, 0x25C6ADAC, - 0x1881F1A7, 0x2FEB33A6, 0x765575A4, 0x413FB7A5, - 0xC429F8A0, 0xF3433AA1, 0xAAFD7CA3, 0x9D97BEA2, - 0xD073C4B5, 0xE71906B4, 0xBEA740B6, 0x89CD82B7, - 0x0CDBCDB2, 0x3BB10FB3, 0x620F49B1, 0x55658BB0, - 0x6822D7BB, 0x5F4815BA, 0x06F653B8, 0x319C91B9, - 0xB48ADEBC, 0x83E01CBD, 0xDA5E5ABF, 0xED3498BE - }, { - 0x00000000, 0x6567BCB8, 0x8BC809AA, 0xEEAFB512, - 0x5797628F, 0x32F0DE37, 0xDC5F6B25, 0xB938D79D, - 0xEF28B4C5, 0x8A4F087D, 0x64E0BD6F, 0x018701D7, - 0xB8BFD64A, 0xDDD86AF2, 0x3377DFE0, 0x56106358, - 0x9F571950, 0xFA30A5E8, 0x149F10FA, 0x71F8AC42, - 0xC8C07BDF, 0xADA7C767, 0x43087275, 0x266FCECD, - 0x707FAD95, 0x1518112D, 0xFBB7A43F, 0x9ED01887, - 0x27E8CF1A, 0x428F73A2, 0xAC20C6B0, 0xC9477A08, - 0x3EAF32A0, 0x5BC88E18, 0xB5673B0A, 0xD00087B2, - 0x6938502F, 0x0C5FEC97, 0xE2F05985, 0x8797E53D, - 0xD1878665, 0xB4E03ADD, 0x5A4F8FCF, 0x3F283377, - 0x8610E4EA, 0xE3775852, 0x0DD8ED40, 0x68BF51F8, - 0xA1F82BF0, 0xC49F9748, 0x2A30225A, 0x4F579EE2, - 0xF66F497F, 0x9308F5C7, 0x7DA740D5, 0x18C0FC6D, - 0x4ED09F35, 0x2BB7238D, 0xC518969F, 0xA07F2A27, - 0x1947FDBA, 0x7C204102, 0x928FF410, 0xF7E848A8, - 0x3D58149B, 0x583FA823, 0xB6901D31, 0xD3F7A189, - 0x6ACF7614, 0x0FA8CAAC, 0xE1077FBE, 0x8460C306, - 0xD270A05E, 0xB7171CE6, 0x59B8A9F4, 0x3CDF154C, - 0x85E7C2D1, 0xE0807E69, 0x0E2FCB7B, 0x6B4877C3, - 0xA20F0DCB, 0xC768B173, 0x29C70461, 0x4CA0B8D9, - 0xF5986F44, 0x90FFD3FC, 0x7E5066EE, 0x1B37DA56, - 0x4D27B90E, 0x284005B6, 0xC6EFB0A4, 0xA3880C1C, - 0x1AB0DB81, 0x7FD76739, 0x9178D22B, 0xF41F6E93, - 0x03F7263B, 0x66909A83, 0x883F2F91, 0xED589329, - 0x546044B4, 0x3107F80C, 0xDFA84D1E, 0xBACFF1A6, - 0xECDF92FE, 0x89B82E46, 0x67179B54, 0x027027EC, - 0xBB48F071, 0xDE2F4CC9, 0x3080F9DB, 0x55E74563, - 0x9CA03F6B, 0xF9C783D3, 0x176836C1, 0x720F8A79, - 0xCB375DE4, 0xAE50E15C, 0x40FF544E, 0x2598E8F6, - 0x73888BAE, 0x16EF3716, 0xF8408204, 0x9D273EBC, - 0x241FE921, 0x41785599, 0xAFD7E08B, 0xCAB05C33, - 0x3BB659ED, 0x5ED1E555, 0xB07E5047, 0xD519ECFF, - 0x6C213B62, 0x094687DA, 0xE7E932C8, 0x828E8E70, - 0xD49EED28, 0xB1F95190, 0x5F56E482, 0x3A31583A, - 0x83098FA7, 0xE66E331F, 0x08C1860D, 0x6DA63AB5, - 0xA4E140BD, 0xC186FC05, 0x2F294917, 0x4A4EF5AF, - 0xF3762232, 0x96119E8A, 0x78BE2B98, 0x1DD99720, - 0x4BC9F478, 0x2EAE48C0, 0xC001FDD2, 0xA566416A, - 0x1C5E96F7, 0x79392A4F, 0x97969F5D, 0xF2F123E5, - 0x05196B4D, 0x607ED7F5, 0x8ED162E7, 0xEBB6DE5F, - 0x528E09C2, 0x37E9B57A, 0xD9460068, 0xBC21BCD0, - 0xEA31DF88, 0x8F566330, 0x61F9D622, 0x049E6A9A, - 0xBDA6BD07, 0xD8C101BF, 0x366EB4AD, 0x53090815, - 0x9A4E721D, 0xFF29CEA5, 0x11867BB7, 0x74E1C70F, - 0xCDD91092, 0xA8BEAC2A, 0x46111938, 0x2376A580, - 0x7566C6D8, 0x10017A60, 0xFEAECF72, 0x9BC973CA, - 0x22F1A457, 0x479618EF, 0xA939ADFD, 0xCC5E1145, - 0x06EE4D76, 0x6389F1CE, 0x8D2644DC, 0xE841F864, - 0x51792FF9, 0x341E9341, 0xDAB12653, 0xBFD69AEB, - 0xE9C6F9B3, 0x8CA1450B, 0x620EF019, 0x07694CA1, - 0xBE519B3C, 0xDB362784, 0x35999296, 0x50FE2E2E, - 0x99B95426, 0xFCDEE89E, 0x12715D8C, 0x7716E134, - 0xCE2E36A9, 0xAB498A11, 0x45E63F03, 0x208183BB, - 0x7691E0E3, 0x13F65C5B, 0xFD59E949, 0x983E55F1, - 0x2106826C, 0x44613ED4, 0xAACE8BC6, 0xCFA9377E, - 0x38417FD6, 0x5D26C36E, 0xB389767C, 0xD6EECAC4, - 0x6FD61D59, 0x0AB1A1E1, 0xE41E14F3, 0x8179A84B, - 0xD769CB13, 0xB20E77AB, 0x5CA1C2B9, 0x39C67E01, - 0x80FEA99C, 0xE5991524, 0x0B36A036, 0x6E511C8E, - 0xA7166686, 0xC271DA3E, 0x2CDE6F2C, 0x49B9D394, - 0xF0810409, 0x95E6B8B1, 0x7B490DA3, 0x1E2EB11B, - 0x483ED243, 0x2D596EFB, 0xC3F6DBE9, 0xA6916751, - 0x1FA9B0CC, 0x7ACE0C74, 0x9461B966, 0xF10605DE - }, { - 0x00000000, 0xB029603D, 0x6053C07A, 0xD07AA047, - 0xC0A680F5, 0x708FE0C8, 0xA0F5408F, 0x10DC20B2, - 0xC14B7030, 0x7162100D, 0xA118B04A, 0x1131D077, - 0x01EDF0C5, 0xB1C490F8, 0x61BE30BF, 0xD1975082, - 0x8297E060, 0x32BE805D, 0xE2C4201A, 0x52ED4027, - 0x42316095, 0xF21800A8, 0x2262A0EF, 0x924BC0D2, - 0x43DC9050, 0xF3F5F06D, 0x238F502A, 0x93A63017, - 0x837A10A5, 0x33537098, 0xE329D0DF, 0x5300B0E2, - 0x042FC1C1, 0xB406A1FC, 0x647C01BB, 0xD4556186, - 0xC4894134, 0x74A02109, 0xA4DA814E, 0x14F3E173, - 0xC564B1F1, 0x754DD1CC, 0xA537718B, 0x151E11B6, - 0x05C23104, 0xB5EB5139, 0x6591F17E, 0xD5B89143, - 0x86B821A1, 0x3691419C, 0xE6EBE1DB, 0x56C281E6, - 0x461EA154, 0xF637C169, 0x264D612E, 0x96640113, - 0x47F35191, 0xF7DA31AC, 0x27A091EB, 0x9789F1D6, - 0x8755D164, 0x377CB159, 0xE706111E, 0x572F7123, - 0x4958F358, 0xF9719365, 0x290B3322, 0x9922531F, - 0x89FE73AD, 0x39D71390, 0xE9ADB3D7, 0x5984D3EA, - 0x88138368, 0x383AE355, 0xE8404312, 0x5869232F, - 0x48B5039D, 0xF89C63A0, 0x28E6C3E7, 0x98CFA3DA, - 0xCBCF1338, 0x7BE67305, 0xAB9CD342, 0x1BB5B37F, - 0x0B6993CD, 0xBB40F3F0, 0x6B3A53B7, 0xDB13338A, - 0x0A846308, 0xBAAD0335, 0x6AD7A372, 0xDAFEC34F, - 0xCA22E3FD, 0x7A0B83C0, 0xAA712387, 0x1A5843BA, - 0x4D773299, 0xFD5E52A4, 0x2D24F2E3, 0x9D0D92DE, - 0x8DD1B26C, 0x3DF8D251, 0xED827216, 0x5DAB122B, - 0x8C3C42A9, 0x3C152294, 0xEC6F82D3, 0x5C46E2EE, - 0x4C9AC25C, 0xFCB3A261, 0x2CC90226, 0x9CE0621B, - 0xCFE0D2F9, 0x7FC9B2C4, 0xAFB31283, 0x1F9A72BE, - 0x0F46520C, 0xBF6F3231, 0x6F159276, 0xDF3CF24B, - 0x0EABA2C9, 0xBE82C2F4, 0x6EF862B3, 0xDED1028E, - 0xCE0D223C, 0x7E244201, 0xAE5EE246, 0x1E77827B, - 0x92B0E6B1, 0x2299868C, 0xF2E326CB, 0x42CA46F6, - 0x52166644, 0xE23F0679, 0x3245A63E, 0x826CC603, - 0x53FB9681, 0xE3D2F6BC, 0x33A856FB, 0x838136C6, - 0x935D1674, 0x23747649, 0xF30ED60E, 0x4327B633, - 0x102706D1, 0xA00E66EC, 0x7074C6AB, 0xC05DA696, - 0xD0818624, 0x60A8E619, 0xB0D2465E, 0x00FB2663, - 0xD16C76E1, 0x614516DC, 0xB13FB69B, 0x0116D6A6, - 0x11CAF614, 0xA1E39629, 0x7199366E, 0xC1B05653, - 0x969F2770, 0x26B6474D, 0xF6CCE70A, 0x46E58737, - 0x5639A785, 0xE610C7B8, 0x366A67FF, 0x864307C2, - 0x57D45740, 0xE7FD377D, 0x3787973A, 0x87AEF707, - 0x9772D7B5, 0x275BB788, 0xF72117CF, 0x470877F2, - 0x1408C710, 0xA421A72D, 0x745B076A, 0xC4726757, - 0xD4AE47E5, 0x648727D8, 0xB4FD879F, 0x04D4E7A2, - 0xD543B720, 0x656AD71D, 0xB510775A, 0x05391767, - 0x15E537D5, 0xA5CC57E8, 0x75B6F7AF, 0xC59F9792, - 0xDBE815E9, 0x6BC175D4, 0xBBBBD593, 0x0B92B5AE, - 0x1B4E951C, 0xAB67F521, 0x7B1D5566, 0xCB34355B, - 0x1AA365D9, 0xAA8A05E4, 0x7AF0A5A3, 0xCAD9C59E, - 0xDA05E52C, 0x6A2C8511, 0xBA562556, 0x0A7F456B, - 0x597FF589, 0xE95695B4, 0x392C35F3, 0x890555CE, - 0x99D9757C, 0x29F01541, 0xF98AB506, 0x49A3D53B, - 0x983485B9, 0x281DE584, 0xF86745C3, 0x484E25FE, - 0x5892054C, 0xE8BB6571, 0x38C1C536, 0x88E8A50B, - 0xDFC7D428, 0x6FEEB415, 0xBF941452, 0x0FBD746F, - 0x1F6154DD, 0xAF4834E0, 0x7F3294A7, 0xCF1BF49A, - 0x1E8CA418, 0xAEA5C425, 0x7EDF6462, 0xCEF6045F, - 0xDE2A24ED, 0x6E0344D0, 0xBE79E497, 0x0E5084AA, - 0x5D503448, 0xED795475, 0x3D03F432, 0x8D2A940F, - 0x9DF6B4BD, 0x2DDFD480, 0xFDA574C7, 0x4D8C14FA, - 0x9C1B4478, 0x2C322445, 0xFC488402, 0x4C61E43F, - 0x5CBDC48D, 0xEC94A4B0, 0x3CEE04F7, 0x8CC764CA - }, { - 0x00000000, 0xA5D35CCB, 0x0BA1C84D, 0xAE729486, - 0x1642919B, 0xB391CD50, 0x1DE359D6, 0xB830051D, - 0x6D8253EC, 0xC8510F27, 0x66239BA1, 0xC3F0C76A, - 0x7BC0C277, 0xDE139EBC, 0x70610A3A, 0xD5B256F1, - 0x9B02D603, 0x3ED18AC8, 0x90A31E4E, 0x35704285, - 0x8D404798, 0x28931B53, 0x86E18FD5, 0x2332D31E, - 0xF68085EF, 0x5353D924, 0xFD214DA2, 0x58F21169, - 0xE0C21474, 0x451148BF, 0xEB63DC39, 0x4EB080F2, - 0x3605AC07, 0x93D6F0CC, 0x3DA4644A, 0x98773881, - 0x20473D9C, 0x85946157, 0x2BE6F5D1, 0x8E35A91A, - 0x5B87FFEB, 0xFE54A320, 0x502637A6, 0xF5F56B6D, - 0x4DC56E70, 0xE81632BB, 0x4664A63D, 0xE3B7FAF6, - 0xAD077A04, 0x08D426CF, 0xA6A6B249, 0x0375EE82, - 0xBB45EB9F, 0x1E96B754, 0xB0E423D2, 0x15377F19, - 0xC08529E8, 0x65567523, 0xCB24E1A5, 0x6EF7BD6E, - 0xD6C7B873, 0x7314E4B8, 0xDD66703E, 0x78B52CF5, - 0x6C0A580F, 0xC9D904C4, 0x67AB9042, 0xC278CC89, - 0x7A48C994, 0xDF9B955F, 0x71E901D9, 0xD43A5D12, - 0x01880BE3, 0xA45B5728, 0x0A29C3AE, 0xAFFA9F65, - 0x17CA9A78, 0xB219C6B3, 0x1C6B5235, 0xB9B80EFE, - 0xF7088E0C, 0x52DBD2C7, 0xFCA94641, 0x597A1A8A, - 0xE14A1F97, 0x4499435C, 0xEAEBD7DA, 0x4F388B11, - 0x9A8ADDE0, 0x3F59812B, 0x912B15AD, 0x34F84966, - 0x8CC84C7B, 0x291B10B0, 0x87698436, 0x22BAD8FD, - 0x5A0FF408, 0xFFDCA8C3, 0x51AE3C45, 0xF47D608E, - 0x4C4D6593, 0xE99E3958, 0x47ECADDE, 0xE23FF115, - 0x378DA7E4, 0x925EFB2F, 0x3C2C6FA9, 0x99FF3362, - 0x21CF367F, 0x841C6AB4, 0x2A6EFE32, 0x8FBDA2F9, - 0xC10D220B, 0x64DE7EC0, 0xCAACEA46, 0x6F7FB68D, - 0xD74FB390, 0x729CEF5B, 0xDCEE7BDD, 0x793D2716, - 0xAC8F71E7, 0x095C2D2C, 0xA72EB9AA, 0x02FDE561, - 0xBACDE07C, 0x1F1EBCB7, 0xB16C2831, 0x14BF74FA, - 0xD814B01E, 0x7DC7ECD5, 0xD3B57853, 0x76662498, - 0xCE562185, 0x6B857D4E, 0xC5F7E9C8, 0x6024B503, - 0xB596E3F2, 0x1045BF39, 0xBE372BBF, 0x1BE47774, - 0xA3D47269, 0x06072EA2, 0xA875BA24, 0x0DA6E6EF, - 0x4316661D, 0xE6C53AD6, 0x48B7AE50, 0xED64F29B, - 0x5554F786, 0xF087AB4D, 0x5EF53FCB, 0xFB266300, - 0x2E9435F1, 0x8B47693A, 0x2535FDBC, 0x80E6A177, - 0x38D6A46A, 0x9D05F8A1, 0x33776C27, 0x96A430EC, - 0xEE111C19, 0x4BC240D2, 0xE5B0D454, 0x4063889F, - 0xF8538D82, 0x5D80D149, 0xF3F245CF, 0x56211904, - 0x83934FF5, 0x2640133E, 0x883287B8, 0x2DE1DB73, - 0x95D1DE6E, 0x300282A5, 0x9E701623, 0x3BA34AE8, - 0x7513CA1A, 0xD0C096D1, 0x7EB20257, 0xDB615E9C, - 0x63515B81, 0xC682074A, 0x68F093CC, 0xCD23CF07, - 0x189199F6, 0xBD42C53D, 0x133051BB, 0xB6E30D70, - 0x0ED3086D, 0xAB0054A6, 0x0572C020, 0xA0A19CEB, - 0xB41EE811, 0x11CDB4DA, 0xBFBF205C, 0x1A6C7C97, - 0xA25C798A, 0x078F2541, 0xA9FDB1C7, 0x0C2EED0C, - 0xD99CBBFD, 0x7C4FE736, 0xD23D73B0, 0x77EE2F7B, - 0xCFDE2A66, 0x6A0D76AD, 0xC47FE22B, 0x61ACBEE0, - 0x2F1C3E12, 0x8ACF62D9, 0x24BDF65F, 0x816EAA94, - 0x395EAF89, 0x9C8DF342, 0x32FF67C4, 0x972C3B0F, - 0x429E6DFE, 0xE74D3135, 0x493FA5B3, 0xECECF978, - 0x54DCFC65, 0xF10FA0AE, 0x5F7D3428, 0xFAAE68E3, - 0x821B4416, 0x27C818DD, 0x89BA8C5B, 0x2C69D090, - 0x9459D58D, 0x318A8946, 0x9FF81DC0, 0x3A2B410B, - 0xEF9917FA, 0x4A4A4B31, 0xE438DFB7, 0x41EB837C, - 0xF9DB8661, 0x5C08DAAA, 0xF27A4E2C, 0x57A912E7, - 0x19199215, 0xBCCACEDE, 0x12B85A58, 0xB76B0693, - 0x0F5B038E, 0xAA885F45, 0x04FACBC3, 0xA1299708, - 0x749BC1F9, 0xD1489D32, 0x7F3A09B4, 0xDAE9557F, - 0x62D95062, 0xC70A0CA9, 0x6978982F, 0xCCABC4E4 - }, { - 0x00000000, 0xB40B77A6, 0x29119F97, 0x9D1AE831, - 0x13244FF4, 0xA72F3852, 0x3A35D063, 0x8E3EA7C5, - 0x674EEF33, 0xD3459895, 0x4E5F70A4, 0xFA540702, - 0x746AA0C7, 0xC061D761, 0x5D7B3F50, 0xE97048F6, - 0xCE9CDE67, 0x7A97A9C1, 0xE78D41F0, 0x53863656, - 0xDDB89193, 0x69B3E635, 0xF4A90E04, 0x40A279A2, - 0xA9D23154, 0x1DD946F2, 0x80C3AEC3, 0x34C8D965, - 0xBAF67EA0, 0x0EFD0906, 0x93E7E137, 0x27EC9691, - 0x9C39BDCF, 0x2832CA69, 0xB5282258, 0x012355FE, - 0x8F1DF23B, 0x3B16859D, 0xA60C6DAC, 0x12071A0A, - 0xFB7752FC, 0x4F7C255A, 0xD266CD6B, 0x666DBACD, - 0xE8531D08, 0x5C586AAE, 0xC142829F, 0x7549F539, - 0x52A563A8, 0xE6AE140E, 0x7BB4FC3F, 0xCFBF8B99, - 0x41812C5C, 0xF58A5BFA, 0x6890B3CB, 0xDC9BC46D, - 0x35EB8C9B, 0x81E0FB3D, 0x1CFA130C, 0xA8F164AA, - 0x26CFC36F, 0x92C4B4C9, 0x0FDE5CF8, 0xBBD52B5E, - 0x79750B44, 0xCD7E7CE2, 0x506494D3, 0xE46FE375, - 0x6A5144B0, 0xDE5A3316, 0x4340DB27, 0xF74BAC81, - 0x1E3BE477, 0xAA3093D1, 0x372A7BE0, 0x83210C46, - 0x0D1FAB83, 0xB914DC25, 0x240E3414, 0x900543B2, - 0xB7E9D523, 0x03E2A285, 0x9EF84AB4, 0x2AF33D12, - 0xA4CD9AD7, 0x10C6ED71, 0x8DDC0540, 0x39D772E6, - 0xD0A73A10, 0x64AC4DB6, 0xF9B6A587, 0x4DBDD221, - 0xC38375E4, 0x77880242, 0xEA92EA73, 0x5E999DD5, - 0xE54CB68B, 0x5147C12D, 0xCC5D291C, 0x78565EBA, - 0xF668F97F, 0x42638ED9, 0xDF7966E8, 0x6B72114E, - 0x820259B8, 0x36092E1E, 0xAB13C62F, 0x1F18B189, - 0x9126164C, 0x252D61EA, 0xB83789DB, 0x0C3CFE7D, - 0x2BD068EC, 0x9FDB1F4A, 0x02C1F77B, 0xB6CA80DD, - 0x38F42718, 0x8CFF50BE, 0x11E5B88F, 0xA5EECF29, - 0x4C9E87DF, 0xF895F079, 0x658F1848, 0xD1846FEE, - 0x5FBAC82B, 0xEBB1BF8D, 0x76AB57BC, 0xC2A0201A, - 0xF2EA1688, 0x46E1612E, 0xDBFB891F, 0x6FF0FEB9, - 0xE1CE597C, 0x55C52EDA, 0xC8DFC6EB, 0x7CD4B14D, - 0x95A4F9BB, 0x21AF8E1D, 0xBCB5662C, 0x08BE118A, - 0x8680B64F, 0x328BC1E9, 0xAF9129D8, 0x1B9A5E7E, - 0x3C76C8EF, 0x887DBF49, 0x15675778, 0xA16C20DE, - 0x2F52871B, 0x9B59F0BD, 0x0643188C, 0xB2486F2A, - 0x5B3827DC, 0xEF33507A, 0x7229B84B, 0xC622CFED, - 0x481C6828, 0xFC171F8E, 0x610DF7BF, 0xD5068019, - 0x6ED3AB47, 0xDAD8DCE1, 0x47C234D0, 0xF3C94376, - 0x7DF7E4B3, 0xC9FC9315, 0x54E67B24, 0xE0ED0C82, - 0x099D4474, 0xBD9633D2, 0x208CDBE3, 0x9487AC45, - 0x1AB90B80, 0xAEB27C26, 0x33A89417, 0x87A3E3B1, - 0xA04F7520, 0x14440286, 0x895EEAB7, 0x3D559D11, - 0xB36B3AD4, 0x07604D72, 0x9A7AA543, 0x2E71D2E5, - 0xC7019A13, 0x730AEDB5, 0xEE100584, 0x5A1B7222, - 0xD425D5E7, 0x602EA241, 0xFD344A70, 0x493F3DD6, - 0x8B9F1DCC, 0x3F946A6A, 0xA28E825B, 0x1685F5FD, - 0x98BB5238, 0x2CB0259E, 0xB1AACDAF, 0x05A1BA09, - 0xECD1F2FF, 0x58DA8559, 0xC5C06D68, 0x71CB1ACE, - 0xFFF5BD0B, 0x4BFECAAD, 0xD6E4229C, 0x62EF553A, - 0x4503C3AB, 0xF108B40D, 0x6C125C3C, 0xD8192B9A, - 0x56278C5F, 0xE22CFBF9, 0x7F3613C8, 0xCB3D646E, - 0x224D2C98, 0x96465B3E, 0x0B5CB30F, 0xBF57C4A9, - 0x3169636C, 0x856214CA, 0x1878FCFB, 0xAC738B5D, - 0x17A6A003, 0xA3ADD7A5, 0x3EB73F94, 0x8ABC4832, - 0x0482EFF7, 0xB0899851, 0x2D937060, 0x999807C6, - 0x70E84F30, 0xC4E33896, 0x59F9D0A7, 0xEDF2A701, - 0x63CC00C4, 0xD7C77762, 0x4ADD9F53, 0xFED6E8F5, - 0xD93A7E64, 0x6D3109C2, 0xF02BE1F3, 0x44209655, - 0xCA1E3190, 0x7E154636, 0xE30FAE07, 0x5704D9A1, - 0xBE749157, 0x0A7FE6F1, 0x97650EC0, 0x236E7966, - 0xAD50DEA3, 0x195BA905, 0x84414134, 0x304A3692 - }, { - 0x00000000, 0x9E00AACC, 0x7D072542, 0xE3078F8E, - 0xFA0E4A84, 0x640EE048, 0x87096FC6, 0x1909C50A, - 0xB51BE5D3, 0x2B1B4F1F, 0xC81CC091, 0x561C6A5D, - 0x4F15AF57, 0xD115059B, 0x32128A15, 0xAC1220D9, - 0x2B31BB7C, 0xB53111B0, 0x56369E3E, 0xC83634F2, - 0xD13FF1F8, 0x4F3F5B34, 0xAC38D4BA, 0x32387E76, - 0x9E2A5EAF, 0x002AF463, 0xE32D7BED, 0x7D2DD121, - 0x6424142B, 0xFA24BEE7, 0x19233169, 0x87239BA5, - 0x566276F9, 0xC862DC35, 0x2B6553BB, 0xB565F977, - 0xAC6C3C7D, 0x326C96B1, 0xD16B193F, 0x4F6BB3F3, - 0xE379932A, 0x7D7939E6, 0x9E7EB668, 0x007E1CA4, - 0x1977D9AE, 0x87777362, 0x6470FCEC, 0xFA705620, - 0x7D53CD85, 0xE3536749, 0x0054E8C7, 0x9E54420B, - 0x875D8701, 0x195D2DCD, 0xFA5AA243, 0x645A088F, - 0xC8482856, 0x5648829A, 0xB54F0D14, 0x2B4FA7D8, - 0x324662D2, 0xAC46C81E, 0x4F414790, 0xD141ED5C, - 0xEDC29D29, 0x73C237E5, 0x90C5B86B, 0x0EC512A7, - 0x17CCD7AD, 0x89CC7D61, 0x6ACBF2EF, 0xF4CB5823, - 0x58D978FA, 0xC6D9D236, 0x25DE5DB8, 0xBBDEF774, - 0xA2D7327E, 0x3CD798B2, 0xDFD0173C, 0x41D0BDF0, - 0xC6F32655, 0x58F38C99, 0xBBF40317, 0x25F4A9DB, - 0x3CFD6CD1, 0xA2FDC61D, 0x41FA4993, 0xDFFAE35F, - 0x73E8C386, 0xEDE8694A, 0x0EEFE6C4, 0x90EF4C08, - 0x89E68902, 0x17E623CE, 0xF4E1AC40, 0x6AE1068C, - 0xBBA0EBD0, 0x25A0411C, 0xC6A7CE92, 0x58A7645E, - 0x41AEA154, 0xDFAE0B98, 0x3CA98416, 0xA2A92EDA, - 0x0EBB0E03, 0x90BBA4CF, 0x73BC2B41, 0xEDBC818D, - 0xF4B54487, 0x6AB5EE4B, 0x89B261C5, 0x17B2CB09, - 0x909150AC, 0x0E91FA60, 0xED9675EE, 0x7396DF22, - 0x6A9F1A28, 0xF49FB0E4, 0x17983F6A, 0x899895A6, - 0x258AB57F, 0xBB8A1FB3, 0x588D903D, 0xC68D3AF1, - 0xDF84FFFB, 0x41845537, 0xA283DAB9, 0x3C837075, - 0xDA853B53, 0x4485919F, 0xA7821E11, 0x3982B4DD, - 0x208B71D7, 0xBE8BDB1B, 0x5D8C5495, 0xC38CFE59, - 0x6F9EDE80, 0xF19E744C, 0x1299FBC2, 0x8C99510E, - 0x95909404, 0x0B903EC8, 0xE897B146, 0x76971B8A, - 0xF1B4802F, 0x6FB42AE3, 0x8CB3A56D, 0x12B30FA1, - 0x0BBACAAB, 0x95BA6067, 0x76BDEFE9, 0xE8BD4525, - 0x44AF65FC, 0xDAAFCF30, 0x39A840BE, 0xA7A8EA72, - 0xBEA12F78, 0x20A185B4, 0xC3A60A3A, 0x5DA6A0F6, - 0x8CE74DAA, 0x12E7E766, 0xF1E068E8, 0x6FE0C224, - 0x76E9072E, 0xE8E9ADE2, 0x0BEE226C, 0x95EE88A0, - 0x39FCA879, 0xA7FC02B5, 0x44FB8D3B, 0xDAFB27F7, - 0xC3F2E2FD, 0x5DF24831, 0xBEF5C7BF, 0x20F56D73, - 0xA7D6F6D6, 0x39D65C1A, 0xDAD1D394, 0x44D17958, - 0x5DD8BC52, 0xC3D8169E, 0x20DF9910, 0xBEDF33DC, - 0x12CD1305, 0x8CCDB9C9, 0x6FCA3647, 0xF1CA9C8B, - 0xE8C35981, 0x76C3F34D, 0x95C47CC3, 0x0BC4D60F, - 0x3747A67A, 0xA9470CB6, 0x4A408338, 0xD44029F4, - 0xCD49ECFE, 0x53494632, 0xB04EC9BC, 0x2E4E6370, - 0x825C43A9, 0x1C5CE965, 0xFF5B66EB, 0x615BCC27, - 0x7852092D, 0xE652A3E1, 0x05552C6F, 0x9B5586A3, - 0x1C761D06, 0x8276B7CA, 0x61713844, 0xFF719288, - 0xE6785782, 0x7878FD4E, 0x9B7F72C0, 0x057FD80C, - 0xA96DF8D5, 0x376D5219, 0xD46ADD97, 0x4A6A775B, - 0x5363B251, 0xCD63189D, 0x2E649713, 0xB0643DDF, - 0x6125D083, 0xFF257A4F, 0x1C22F5C1, 0x82225F0D, - 0x9B2B9A07, 0x052B30CB, 0xE62CBF45, 0x782C1589, - 0xD43E3550, 0x4A3E9F9C, 0xA9391012, 0x3739BADE, - 0x2E307FD4, 0xB030D518, 0x53375A96, 0xCD37F05A, - 0x4A146BFF, 0xD414C133, 0x37134EBD, 0xA913E471, - 0xB01A217B, 0x2E1A8BB7, 0xCD1D0439, 0x531DAEF5, - 0xFF0F8E2C, 0x610F24E0, 0x8208AB6E, 0x1C0801A2, - 0x0501C4A8, 0x9B016E64, 0x7806E1EA, 0xE6064B26 - } -}; diff --git a/deps/lzma/liblzma/check/crc32_table_le.h b/deps/lzma/liblzma/check/crc32_table_le.h deleted file mode 100644 index 25f4fc4..0000000 --- a/deps/lzma/liblzma/check/crc32_table_le.h +++ /dev/null @@ -1,525 +0,0 @@ -/* This file has been automatically generated by crc32_tablegen.c. */ - -const uint32_t lzma_crc32_table[8][256] = { - { - 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, - 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, - 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, - 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, - 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, - 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, - 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, - 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, - 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, - 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, - 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, - 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, - 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, - 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, - 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, - 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, - 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, - 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, - 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, - 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, - 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, - 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, - 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, - 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, - 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, - 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, - 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, - 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, - 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, - 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, - 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, - 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, - 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, - 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, - 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, - 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, - 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, - 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, - 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, - 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, - 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, - 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, - 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, - 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, - 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, - 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, - 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, - 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, - 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, - 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, - 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, - 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, - 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, - 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, - 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, - 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, - 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, - 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, - 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, - 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, - 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, - 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, - 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, - 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D - }, { - 0x00000000, 0x191B3141, 0x32366282, 0x2B2D53C3, - 0x646CC504, 0x7D77F445, 0x565AA786, 0x4F4196C7, - 0xC8D98A08, 0xD1C2BB49, 0xFAEFE88A, 0xE3F4D9CB, - 0xACB54F0C, 0xB5AE7E4D, 0x9E832D8E, 0x87981CCF, - 0x4AC21251, 0x53D92310, 0x78F470D3, 0x61EF4192, - 0x2EAED755, 0x37B5E614, 0x1C98B5D7, 0x05838496, - 0x821B9859, 0x9B00A918, 0xB02DFADB, 0xA936CB9A, - 0xE6775D5D, 0xFF6C6C1C, 0xD4413FDF, 0xCD5A0E9E, - 0x958424A2, 0x8C9F15E3, 0xA7B24620, 0xBEA97761, - 0xF1E8E1A6, 0xE8F3D0E7, 0xC3DE8324, 0xDAC5B265, - 0x5D5DAEAA, 0x44469FEB, 0x6F6BCC28, 0x7670FD69, - 0x39316BAE, 0x202A5AEF, 0x0B07092C, 0x121C386D, - 0xDF4636F3, 0xC65D07B2, 0xED705471, 0xF46B6530, - 0xBB2AF3F7, 0xA231C2B6, 0x891C9175, 0x9007A034, - 0x179FBCFB, 0x0E848DBA, 0x25A9DE79, 0x3CB2EF38, - 0x73F379FF, 0x6AE848BE, 0x41C51B7D, 0x58DE2A3C, - 0xF0794F05, 0xE9627E44, 0xC24F2D87, 0xDB541CC6, - 0x94158A01, 0x8D0EBB40, 0xA623E883, 0xBF38D9C2, - 0x38A0C50D, 0x21BBF44C, 0x0A96A78F, 0x138D96CE, - 0x5CCC0009, 0x45D73148, 0x6EFA628B, 0x77E153CA, - 0xBABB5D54, 0xA3A06C15, 0x888D3FD6, 0x91960E97, - 0xDED79850, 0xC7CCA911, 0xECE1FAD2, 0xF5FACB93, - 0x7262D75C, 0x6B79E61D, 0x4054B5DE, 0x594F849F, - 0x160E1258, 0x0F152319, 0x243870DA, 0x3D23419B, - 0x65FD6BA7, 0x7CE65AE6, 0x57CB0925, 0x4ED03864, - 0x0191AEA3, 0x188A9FE2, 0x33A7CC21, 0x2ABCFD60, - 0xAD24E1AF, 0xB43FD0EE, 0x9F12832D, 0x8609B26C, - 0xC94824AB, 0xD05315EA, 0xFB7E4629, 0xE2657768, - 0x2F3F79F6, 0x362448B7, 0x1D091B74, 0x04122A35, - 0x4B53BCF2, 0x52488DB3, 0x7965DE70, 0x607EEF31, - 0xE7E6F3FE, 0xFEFDC2BF, 0xD5D0917C, 0xCCCBA03D, - 0x838A36FA, 0x9A9107BB, 0xB1BC5478, 0xA8A76539, - 0x3B83984B, 0x2298A90A, 0x09B5FAC9, 0x10AECB88, - 0x5FEF5D4F, 0x46F46C0E, 0x6DD93FCD, 0x74C20E8C, - 0xF35A1243, 0xEA412302, 0xC16C70C1, 0xD8774180, - 0x9736D747, 0x8E2DE606, 0xA500B5C5, 0xBC1B8484, - 0x71418A1A, 0x685ABB5B, 0x4377E898, 0x5A6CD9D9, - 0x152D4F1E, 0x0C367E5F, 0x271B2D9C, 0x3E001CDD, - 0xB9980012, 0xA0833153, 0x8BAE6290, 0x92B553D1, - 0xDDF4C516, 0xC4EFF457, 0xEFC2A794, 0xF6D996D5, - 0xAE07BCE9, 0xB71C8DA8, 0x9C31DE6B, 0x852AEF2A, - 0xCA6B79ED, 0xD37048AC, 0xF85D1B6F, 0xE1462A2E, - 0x66DE36E1, 0x7FC507A0, 0x54E85463, 0x4DF36522, - 0x02B2F3E5, 0x1BA9C2A4, 0x30849167, 0x299FA026, - 0xE4C5AEB8, 0xFDDE9FF9, 0xD6F3CC3A, 0xCFE8FD7B, - 0x80A96BBC, 0x99B25AFD, 0xB29F093E, 0xAB84387F, - 0x2C1C24B0, 0x350715F1, 0x1E2A4632, 0x07317773, - 0x4870E1B4, 0x516BD0F5, 0x7A468336, 0x635DB277, - 0xCBFAD74E, 0xD2E1E60F, 0xF9CCB5CC, 0xE0D7848D, - 0xAF96124A, 0xB68D230B, 0x9DA070C8, 0x84BB4189, - 0x03235D46, 0x1A386C07, 0x31153FC4, 0x280E0E85, - 0x674F9842, 0x7E54A903, 0x5579FAC0, 0x4C62CB81, - 0x8138C51F, 0x9823F45E, 0xB30EA79D, 0xAA1596DC, - 0xE554001B, 0xFC4F315A, 0xD7626299, 0xCE7953D8, - 0x49E14F17, 0x50FA7E56, 0x7BD72D95, 0x62CC1CD4, - 0x2D8D8A13, 0x3496BB52, 0x1FBBE891, 0x06A0D9D0, - 0x5E7EF3EC, 0x4765C2AD, 0x6C48916E, 0x7553A02F, - 0x3A1236E8, 0x230907A9, 0x0824546A, 0x113F652B, - 0x96A779E4, 0x8FBC48A5, 0xA4911B66, 0xBD8A2A27, - 0xF2CBBCE0, 0xEBD08DA1, 0xC0FDDE62, 0xD9E6EF23, - 0x14BCE1BD, 0x0DA7D0FC, 0x268A833F, 0x3F91B27E, - 0x70D024B9, 0x69CB15F8, 0x42E6463B, 0x5BFD777A, - 0xDC656BB5, 0xC57E5AF4, 0xEE530937, 0xF7483876, - 0xB809AEB1, 0xA1129FF0, 0x8A3FCC33, 0x9324FD72 - }, { - 0x00000000, 0x01C26A37, 0x0384D46E, 0x0246BE59, - 0x0709A8DC, 0x06CBC2EB, 0x048D7CB2, 0x054F1685, - 0x0E1351B8, 0x0FD13B8F, 0x0D9785D6, 0x0C55EFE1, - 0x091AF964, 0x08D89353, 0x0A9E2D0A, 0x0B5C473D, - 0x1C26A370, 0x1DE4C947, 0x1FA2771E, 0x1E601D29, - 0x1B2F0BAC, 0x1AED619B, 0x18ABDFC2, 0x1969B5F5, - 0x1235F2C8, 0x13F798FF, 0x11B126A6, 0x10734C91, - 0x153C5A14, 0x14FE3023, 0x16B88E7A, 0x177AE44D, - 0x384D46E0, 0x398F2CD7, 0x3BC9928E, 0x3A0BF8B9, - 0x3F44EE3C, 0x3E86840B, 0x3CC03A52, 0x3D025065, - 0x365E1758, 0x379C7D6F, 0x35DAC336, 0x3418A901, - 0x3157BF84, 0x3095D5B3, 0x32D36BEA, 0x331101DD, - 0x246BE590, 0x25A98FA7, 0x27EF31FE, 0x262D5BC9, - 0x23624D4C, 0x22A0277B, 0x20E69922, 0x2124F315, - 0x2A78B428, 0x2BBADE1F, 0x29FC6046, 0x283E0A71, - 0x2D711CF4, 0x2CB376C3, 0x2EF5C89A, 0x2F37A2AD, - 0x709A8DC0, 0x7158E7F7, 0x731E59AE, 0x72DC3399, - 0x7793251C, 0x76514F2B, 0x7417F172, 0x75D59B45, - 0x7E89DC78, 0x7F4BB64F, 0x7D0D0816, 0x7CCF6221, - 0x798074A4, 0x78421E93, 0x7A04A0CA, 0x7BC6CAFD, - 0x6CBC2EB0, 0x6D7E4487, 0x6F38FADE, 0x6EFA90E9, - 0x6BB5866C, 0x6A77EC5B, 0x68315202, 0x69F33835, - 0x62AF7F08, 0x636D153F, 0x612BAB66, 0x60E9C151, - 0x65A6D7D4, 0x6464BDE3, 0x662203BA, 0x67E0698D, - 0x48D7CB20, 0x4915A117, 0x4B531F4E, 0x4A917579, - 0x4FDE63FC, 0x4E1C09CB, 0x4C5AB792, 0x4D98DDA5, - 0x46C49A98, 0x4706F0AF, 0x45404EF6, 0x448224C1, - 0x41CD3244, 0x400F5873, 0x4249E62A, 0x438B8C1D, - 0x54F16850, 0x55330267, 0x5775BC3E, 0x56B7D609, - 0x53F8C08C, 0x523AAABB, 0x507C14E2, 0x51BE7ED5, - 0x5AE239E8, 0x5B2053DF, 0x5966ED86, 0x58A487B1, - 0x5DEB9134, 0x5C29FB03, 0x5E6F455A, 0x5FAD2F6D, - 0xE1351B80, 0xE0F771B7, 0xE2B1CFEE, 0xE373A5D9, - 0xE63CB35C, 0xE7FED96B, 0xE5B86732, 0xE47A0D05, - 0xEF264A38, 0xEEE4200F, 0xECA29E56, 0xED60F461, - 0xE82FE2E4, 0xE9ED88D3, 0xEBAB368A, 0xEA695CBD, - 0xFD13B8F0, 0xFCD1D2C7, 0xFE976C9E, 0xFF5506A9, - 0xFA1A102C, 0xFBD87A1B, 0xF99EC442, 0xF85CAE75, - 0xF300E948, 0xF2C2837F, 0xF0843D26, 0xF1465711, - 0xF4094194, 0xF5CB2BA3, 0xF78D95FA, 0xF64FFFCD, - 0xD9785D60, 0xD8BA3757, 0xDAFC890E, 0xDB3EE339, - 0xDE71F5BC, 0xDFB39F8B, 0xDDF521D2, 0xDC374BE5, - 0xD76B0CD8, 0xD6A966EF, 0xD4EFD8B6, 0xD52DB281, - 0xD062A404, 0xD1A0CE33, 0xD3E6706A, 0xD2241A5D, - 0xC55EFE10, 0xC49C9427, 0xC6DA2A7E, 0xC7184049, - 0xC25756CC, 0xC3953CFB, 0xC1D382A2, 0xC011E895, - 0xCB4DAFA8, 0xCA8FC59F, 0xC8C97BC6, 0xC90B11F1, - 0xCC440774, 0xCD866D43, 0xCFC0D31A, 0xCE02B92D, - 0x91AF9640, 0x906DFC77, 0x922B422E, 0x93E92819, - 0x96A63E9C, 0x976454AB, 0x9522EAF2, 0x94E080C5, - 0x9FBCC7F8, 0x9E7EADCF, 0x9C381396, 0x9DFA79A1, - 0x98B56F24, 0x99770513, 0x9B31BB4A, 0x9AF3D17D, - 0x8D893530, 0x8C4B5F07, 0x8E0DE15E, 0x8FCF8B69, - 0x8A809DEC, 0x8B42F7DB, 0x89044982, 0x88C623B5, - 0x839A6488, 0x82580EBF, 0x801EB0E6, 0x81DCDAD1, - 0x8493CC54, 0x8551A663, 0x8717183A, 0x86D5720D, - 0xA9E2D0A0, 0xA820BA97, 0xAA6604CE, 0xABA46EF9, - 0xAEEB787C, 0xAF29124B, 0xAD6FAC12, 0xACADC625, - 0xA7F18118, 0xA633EB2F, 0xA4755576, 0xA5B73F41, - 0xA0F829C4, 0xA13A43F3, 0xA37CFDAA, 0xA2BE979D, - 0xB5C473D0, 0xB40619E7, 0xB640A7BE, 0xB782CD89, - 0xB2CDDB0C, 0xB30FB13B, 0xB1490F62, 0xB08B6555, - 0xBBD72268, 0xBA15485F, 0xB853F606, 0xB9919C31, - 0xBCDE8AB4, 0xBD1CE083, 0xBF5A5EDA, 0xBE9834ED - }, { - 0x00000000, 0xB8BC6765, 0xAA09C88B, 0x12B5AFEE, - 0x8F629757, 0x37DEF032, 0x256B5FDC, 0x9DD738B9, - 0xC5B428EF, 0x7D084F8A, 0x6FBDE064, 0xD7018701, - 0x4AD6BFB8, 0xF26AD8DD, 0xE0DF7733, 0x58631056, - 0x5019579F, 0xE8A530FA, 0xFA109F14, 0x42ACF871, - 0xDF7BC0C8, 0x67C7A7AD, 0x75720843, 0xCDCE6F26, - 0x95AD7F70, 0x2D111815, 0x3FA4B7FB, 0x8718D09E, - 0x1ACFE827, 0xA2738F42, 0xB0C620AC, 0x087A47C9, - 0xA032AF3E, 0x188EC85B, 0x0A3B67B5, 0xB28700D0, - 0x2F503869, 0x97EC5F0C, 0x8559F0E2, 0x3DE59787, - 0x658687D1, 0xDD3AE0B4, 0xCF8F4F5A, 0x7733283F, - 0xEAE41086, 0x525877E3, 0x40EDD80D, 0xF851BF68, - 0xF02BF8A1, 0x48979FC4, 0x5A22302A, 0xE29E574F, - 0x7F496FF6, 0xC7F50893, 0xD540A77D, 0x6DFCC018, - 0x359FD04E, 0x8D23B72B, 0x9F9618C5, 0x272A7FA0, - 0xBAFD4719, 0x0241207C, 0x10F48F92, 0xA848E8F7, - 0x9B14583D, 0x23A83F58, 0x311D90B6, 0x89A1F7D3, - 0x1476CF6A, 0xACCAA80F, 0xBE7F07E1, 0x06C36084, - 0x5EA070D2, 0xE61C17B7, 0xF4A9B859, 0x4C15DF3C, - 0xD1C2E785, 0x697E80E0, 0x7BCB2F0E, 0xC377486B, - 0xCB0D0FA2, 0x73B168C7, 0x6104C729, 0xD9B8A04C, - 0x446F98F5, 0xFCD3FF90, 0xEE66507E, 0x56DA371B, - 0x0EB9274D, 0xB6054028, 0xA4B0EFC6, 0x1C0C88A3, - 0x81DBB01A, 0x3967D77F, 0x2BD27891, 0x936E1FF4, - 0x3B26F703, 0x839A9066, 0x912F3F88, 0x299358ED, - 0xB4446054, 0x0CF80731, 0x1E4DA8DF, 0xA6F1CFBA, - 0xFE92DFEC, 0x462EB889, 0x549B1767, 0xEC277002, - 0x71F048BB, 0xC94C2FDE, 0xDBF98030, 0x6345E755, - 0x6B3FA09C, 0xD383C7F9, 0xC1366817, 0x798A0F72, - 0xE45D37CB, 0x5CE150AE, 0x4E54FF40, 0xF6E89825, - 0xAE8B8873, 0x1637EF16, 0x048240F8, 0xBC3E279D, - 0x21E91F24, 0x99557841, 0x8BE0D7AF, 0x335CB0CA, - 0xED59B63B, 0x55E5D15E, 0x47507EB0, 0xFFEC19D5, - 0x623B216C, 0xDA874609, 0xC832E9E7, 0x708E8E82, - 0x28ED9ED4, 0x9051F9B1, 0x82E4565F, 0x3A58313A, - 0xA78F0983, 0x1F336EE6, 0x0D86C108, 0xB53AA66D, - 0xBD40E1A4, 0x05FC86C1, 0x1749292F, 0xAFF54E4A, - 0x322276F3, 0x8A9E1196, 0x982BBE78, 0x2097D91D, - 0x78F4C94B, 0xC048AE2E, 0xD2FD01C0, 0x6A4166A5, - 0xF7965E1C, 0x4F2A3979, 0x5D9F9697, 0xE523F1F2, - 0x4D6B1905, 0xF5D77E60, 0xE762D18E, 0x5FDEB6EB, - 0xC2098E52, 0x7AB5E937, 0x680046D9, 0xD0BC21BC, - 0x88DF31EA, 0x3063568F, 0x22D6F961, 0x9A6A9E04, - 0x07BDA6BD, 0xBF01C1D8, 0xADB46E36, 0x15080953, - 0x1D724E9A, 0xA5CE29FF, 0xB77B8611, 0x0FC7E174, - 0x9210D9CD, 0x2AACBEA8, 0x38191146, 0x80A57623, - 0xD8C66675, 0x607A0110, 0x72CFAEFE, 0xCA73C99B, - 0x57A4F122, 0xEF189647, 0xFDAD39A9, 0x45115ECC, - 0x764DEE06, 0xCEF18963, 0xDC44268D, 0x64F841E8, - 0xF92F7951, 0x41931E34, 0x5326B1DA, 0xEB9AD6BF, - 0xB3F9C6E9, 0x0B45A18C, 0x19F00E62, 0xA14C6907, - 0x3C9B51BE, 0x842736DB, 0x96929935, 0x2E2EFE50, - 0x2654B999, 0x9EE8DEFC, 0x8C5D7112, 0x34E11677, - 0xA9362ECE, 0x118A49AB, 0x033FE645, 0xBB838120, - 0xE3E09176, 0x5B5CF613, 0x49E959FD, 0xF1553E98, - 0x6C820621, 0xD43E6144, 0xC68BCEAA, 0x7E37A9CF, - 0xD67F4138, 0x6EC3265D, 0x7C7689B3, 0xC4CAEED6, - 0x591DD66F, 0xE1A1B10A, 0xF3141EE4, 0x4BA87981, - 0x13CB69D7, 0xAB770EB2, 0xB9C2A15C, 0x017EC639, - 0x9CA9FE80, 0x241599E5, 0x36A0360B, 0x8E1C516E, - 0x866616A7, 0x3EDA71C2, 0x2C6FDE2C, 0x94D3B949, - 0x090481F0, 0xB1B8E695, 0xA30D497B, 0x1BB12E1E, - 0x43D23E48, 0xFB6E592D, 0xE9DBF6C3, 0x516791A6, - 0xCCB0A91F, 0x740CCE7A, 0x66B96194, 0xDE0506F1 - }, { - 0x00000000, 0x3D6029B0, 0x7AC05360, 0x47A07AD0, - 0xF580A6C0, 0xC8E08F70, 0x8F40F5A0, 0xB220DC10, - 0x30704BC1, 0x0D106271, 0x4AB018A1, 0x77D03111, - 0xC5F0ED01, 0xF890C4B1, 0xBF30BE61, 0x825097D1, - 0x60E09782, 0x5D80BE32, 0x1A20C4E2, 0x2740ED52, - 0x95603142, 0xA80018F2, 0xEFA06222, 0xD2C04B92, - 0x5090DC43, 0x6DF0F5F3, 0x2A508F23, 0x1730A693, - 0xA5107A83, 0x98705333, 0xDFD029E3, 0xE2B00053, - 0xC1C12F04, 0xFCA106B4, 0xBB017C64, 0x866155D4, - 0x344189C4, 0x0921A074, 0x4E81DAA4, 0x73E1F314, - 0xF1B164C5, 0xCCD14D75, 0x8B7137A5, 0xB6111E15, - 0x0431C205, 0x3951EBB5, 0x7EF19165, 0x4391B8D5, - 0xA121B886, 0x9C419136, 0xDBE1EBE6, 0xE681C256, - 0x54A11E46, 0x69C137F6, 0x2E614D26, 0x13016496, - 0x9151F347, 0xAC31DAF7, 0xEB91A027, 0xD6F18997, - 0x64D15587, 0x59B17C37, 0x1E1106E7, 0x23712F57, - 0x58F35849, 0x659371F9, 0x22330B29, 0x1F532299, - 0xAD73FE89, 0x9013D739, 0xD7B3ADE9, 0xEAD38459, - 0x68831388, 0x55E33A38, 0x124340E8, 0x2F236958, - 0x9D03B548, 0xA0639CF8, 0xE7C3E628, 0xDAA3CF98, - 0x3813CFCB, 0x0573E67B, 0x42D39CAB, 0x7FB3B51B, - 0xCD93690B, 0xF0F340BB, 0xB7533A6B, 0x8A3313DB, - 0x0863840A, 0x3503ADBA, 0x72A3D76A, 0x4FC3FEDA, - 0xFDE322CA, 0xC0830B7A, 0x872371AA, 0xBA43581A, - 0x9932774D, 0xA4525EFD, 0xE3F2242D, 0xDE920D9D, - 0x6CB2D18D, 0x51D2F83D, 0x167282ED, 0x2B12AB5D, - 0xA9423C8C, 0x9422153C, 0xD3826FEC, 0xEEE2465C, - 0x5CC29A4C, 0x61A2B3FC, 0x2602C92C, 0x1B62E09C, - 0xF9D2E0CF, 0xC4B2C97F, 0x8312B3AF, 0xBE729A1F, - 0x0C52460F, 0x31326FBF, 0x7692156F, 0x4BF23CDF, - 0xC9A2AB0E, 0xF4C282BE, 0xB362F86E, 0x8E02D1DE, - 0x3C220DCE, 0x0142247E, 0x46E25EAE, 0x7B82771E, - 0xB1E6B092, 0x8C869922, 0xCB26E3F2, 0xF646CA42, - 0x44661652, 0x79063FE2, 0x3EA64532, 0x03C66C82, - 0x8196FB53, 0xBCF6D2E3, 0xFB56A833, 0xC6368183, - 0x74165D93, 0x49767423, 0x0ED60EF3, 0x33B62743, - 0xD1062710, 0xEC660EA0, 0xABC67470, 0x96A65DC0, - 0x248681D0, 0x19E6A860, 0x5E46D2B0, 0x6326FB00, - 0xE1766CD1, 0xDC164561, 0x9BB63FB1, 0xA6D61601, - 0x14F6CA11, 0x2996E3A1, 0x6E369971, 0x5356B0C1, - 0x70279F96, 0x4D47B626, 0x0AE7CCF6, 0x3787E546, - 0x85A73956, 0xB8C710E6, 0xFF676A36, 0xC2074386, - 0x4057D457, 0x7D37FDE7, 0x3A978737, 0x07F7AE87, - 0xB5D77297, 0x88B75B27, 0xCF1721F7, 0xF2770847, - 0x10C70814, 0x2DA721A4, 0x6A075B74, 0x576772C4, - 0xE547AED4, 0xD8278764, 0x9F87FDB4, 0xA2E7D404, - 0x20B743D5, 0x1DD76A65, 0x5A7710B5, 0x67173905, - 0xD537E515, 0xE857CCA5, 0xAFF7B675, 0x92979FC5, - 0xE915E8DB, 0xD475C16B, 0x93D5BBBB, 0xAEB5920B, - 0x1C954E1B, 0x21F567AB, 0x66551D7B, 0x5B3534CB, - 0xD965A31A, 0xE4058AAA, 0xA3A5F07A, 0x9EC5D9CA, - 0x2CE505DA, 0x11852C6A, 0x562556BA, 0x6B457F0A, - 0x89F57F59, 0xB49556E9, 0xF3352C39, 0xCE550589, - 0x7C75D999, 0x4115F029, 0x06B58AF9, 0x3BD5A349, - 0xB9853498, 0x84E51D28, 0xC34567F8, 0xFE254E48, - 0x4C059258, 0x7165BBE8, 0x36C5C138, 0x0BA5E888, - 0x28D4C7DF, 0x15B4EE6F, 0x521494BF, 0x6F74BD0F, - 0xDD54611F, 0xE03448AF, 0xA794327F, 0x9AF41BCF, - 0x18A48C1E, 0x25C4A5AE, 0x6264DF7E, 0x5F04F6CE, - 0xED242ADE, 0xD044036E, 0x97E479BE, 0xAA84500E, - 0x4834505D, 0x755479ED, 0x32F4033D, 0x0F942A8D, - 0xBDB4F69D, 0x80D4DF2D, 0xC774A5FD, 0xFA148C4D, - 0x78441B9C, 0x4524322C, 0x028448FC, 0x3FE4614C, - 0x8DC4BD5C, 0xB0A494EC, 0xF704EE3C, 0xCA64C78C - }, { - 0x00000000, 0xCB5CD3A5, 0x4DC8A10B, 0x869472AE, - 0x9B914216, 0x50CD91B3, 0xD659E31D, 0x1D0530B8, - 0xEC53826D, 0x270F51C8, 0xA19B2366, 0x6AC7F0C3, - 0x77C2C07B, 0xBC9E13DE, 0x3A0A6170, 0xF156B2D5, - 0x03D6029B, 0xC88AD13E, 0x4E1EA390, 0x85427035, - 0x9847408D, 0x531B9328, 0xD58FE186, 0x1ED33223, - 0xEF8580F6, 0x24D95353, 0xA24D21FD, 0x6911F258, - 0x7414C2E0, 0xBF481145, 0x39DC63EB, 0xF280B04E, - 0x07AC0536, 0xCCF0D693, 0x4A64A43D, 0x81387798, - 0x9C3D4720, 0x57619485, 0xD1F5E62B, 0x1AA9358E, - 0xEBFF875B, 0x20A354FE, 0xA6372650, 0x6D6BF5F5, - 0x706EC54D, 0xBB3216E8, 0x3DA66446, 0xF6FAB7E3, - 0x047A07AD, 0xCF26D408, 0x49B2A6A6, 0x82EE7503, - 0x9FEB45BB, 0x54B7961E, 0xD223E4B0, 0x197F3715, - 0xE82985C0, 0x23755665, 0xA5E124CB, 0x6EBDF76E, - 0x73B8C7D6, 0xB8E41473, 0x3E7066DD, 0xF52CB578, - 0x0F580A6C, 0xC404D9C9, 0x4290AB67, 0x89CC78C2, - 0x94C9487A, 0x5F959BDF, 0xD901E971, 0x125D3AD4, - 0xE30B8801, 0x28575BA4, 0xAEC3290A, 0x659FFAAF, - 0x789ACA17, 0xB3C619B2, 0x35526B1C, 0xFE0EB8B9, - 0x0C8E08F7, 0xC7D2DB52, 0x4146A9FC, 0x8A1A7A59, - 0x971F4AE1, 0x5C439944, 0xDAD7EBEA, 0x118B384F, - 0xE0DD8A9A, 0x2B81593F, 0xAD152B91, 0x6649F834, - 0x7B4CC88C, 0xB0101B29, 0x36846987, 0xFDD8BA22, - 0x08F40F5A, 0xC3A8DCFF, 0x453CAE51, 0x8E607DF4, - 0x93654D4C, 0x58399EE9, 0xDEADEC47, 0x15F13FE2, - 0xE4A78D37, 0x2FFB5E92, 0xA96F2C3C, 0x6233FF99, - 0x7F36CF21, 0xB46A1C84, 0x32FE6E2A, 0xF9A2BD8F, - 0x0B220DC1, 0xC07EDE64, 0x46EAACCA, 0x8DB67F6F, - 0x90B34FD7, 0x5BEF9C72, 0xDD7BEEDC, 0x16273D79, - 0xE7718FAC, 0x2C2D5C09, 0xAAB92EA7, 0x61E5FD02, - 0x7CE0CDBA, 0xB7BC1E1F, 0x31286CB1, 0xFA74BF14, - 0x1EB014D8, 0xD5ECC77D, 0x5378B5D3, 0x98246676, - 0x852156CE, 0x4E7D856B, 0xC8E9F7C5, 0x03B52460, - 0xF2E396B5, 0x39BF4510, 0xBF2B37BE, 0x7477E41B, - 0x6972D4A3, 0xA22E0706, 0x24BA75A8, 0xEFE6A60D, - 0x1D661643, 0xD63AC5E6, 0x50AEB748, 0x9BF264ED, - 0x86F75455, 0x4DAB87F0, 0xCB3FF55E, 0x006326FB, - 0xF135942E, 0x3A69478B, 0xBCFD3525, 0x77A1E680, - 0x6AA4D638, 0xA1F8059D, 0x276C7733, 0xEC30A496, - 0x191C11EE, 0xD240C24B, 0x54D4B0E5, 0x9F886340, - 0x828D53F8, 0x49D1805D, 0xCF45F2F3, 0x04192156, - 0xF54F9383, 0x3E134026, 0xB8873288, 0x73DBE12D, - 0x6EDED195, 0xA5820230, 0x2316709E, 0xE84AA33B, - 0x1ACA1375, 0xD196C0D0, 0x5702B27E, 0x9C5E61DB, - 0x815B5163, 0x4A0782C6, 0xCC93F068, 0x07CF23CD, - 0xF6999118, 0x3DC542BD, 0xBB513013, 0x700DE3B6, - 0x6D08D30E, 0xA65400AB, 0x20C07205, 0xEB9CA1A0, - 0x11E81EB4, 0xDAB4CD11, 0x5C20BFBF, 0x977C6C1A, - 0x8A795CA2, 0x41258F07, 0xC7B1FDA9, 0x0CED2E0C, - 0xFDBB9CD9, 0x36E74F7C, 0xB0733DD2, 0x7B2FEE77, - 0x662ADECF, 0xAD760D6A, 0x2BE27FC4, 0xE0BEAC61, - 0x123E1C2F, 0xD962CF8A, 0x5FF6BD24, 0x94AA6E81, - 0x89AF5E39, 0x42F38D9C, 0xC467FF32, 0x0F3B2C97, - 0xFE6D9E42, 0x35314DE7, 0xB3A53F49, 0x78F9ECEC, - 0x65FCDC54, 0xAEA00FF1, 0x28347D5F, 0xE368AEFA, - 0x16441B82, 0xDD18C827, 0x5B8CBA89, 0x90D0692C, - 0x8DD55994, 0x46898A31, 0xC01DF89F, 0x0B412B3A, - 0xFA1799EF, 0x314B4A4A, 0xB7DF38E4, 0x7C83EB41, - 0x6186DBF9, 0xAADA085C, 0x2C4E7AF2, 0xE712A957, - 0x15921919, 0xDECECABC, 0x585AB812, 0x93066BB7, - 0x8E035B0F, 0x455F88AA, 0xC3CBFA04, 0x089729A1, - 0xF9C19B74, 0x329D48D1, 0xB4093A7F, 0x7F55E9DA, - 0x6250D962, 0xA90C0AC7, 0x2F987869, 0xE4C4ABCC - }, { - 0x00000000, 0xA6770BB4, 0x979F1129, 0x31E81A9D, - 0xF44F2413, 0x52382FA7, 0x63D0353A, 0xC5A73E8E, - 0x33EF4E67, 0x959845D3, 0xA4705F4E, 0x020754FA, - 0xC7A06A74, 0x61D761C0, 0x503F7B5D, 0xF64870E9, - 0x67DE9CCE, 0xC1A9977A, 0xF0418DE7, 0x56368653, - 0x9391B8DD, 0x35E6B369, 0x040EA9F4, 0xA279A240, - 0x5431D2A9, 0xF246D91D, 0xC3AEC380, 0x65D9C834, - 0xA07EF6BA, 0x0609FD0E, 0x37E1E793, 0x9196EC27, - 0xCFBD399C, 0x69CA3228, 0x582228B5, 0xFE552301, - 0x3BF21D8F, 0x9D85163B, 0xAC6D0CA6, 0x0A1A0712, - 0xFC5277FB, 0x5A257C4F, 0x6BCD66D2, 0xCDBA6D66, - 0x081D53E8, 0xAE6A585C, 0x9F8242C1, 0x39F54975, - 0xA863A552, 0x0E14AEE6, 0x3FFCB47B, 0x998BBFCF, - 0x5C2C8141, 0xFA5B8AF5, 0xCBB39068, 0x6DC49BDC, - 0x9B8CEB35, 0x3DFBE081, 0x0C13FA1C, 0xAA64F1A8, - 0x6FC3CF26, 0xC9B4C492, 0xF85CDE0F, 0x5E2BD5BB, - 0x440B7579, 0xE27C7ECD, 0xD3946450, 0x75E36FE4, - 0xB044516A, 0x16335ADE, 0x27DB4043, 0x81AC4BF7, - 0x77E43B1E, 0xD19330AA, 0xE07B2A37, 0x460C2183, - 0x83AB1F0D, 0x25DC14B9, 0x14340E24, 0xB2430590, - 0x23D5E9B7, 0x85A2E203, 0xB44AF89E, 0x123DF32A, - 0xD79ACDA4, 0x71EDC610, 0x4005DC8D, 0xE672D739, - 0x103AA7D0, 0xB64DAC64, 0x87A5B6F9, 0x21D2BD4D, - 0xE47583C3, 0x42028877, 0x73EA92EA, 0xD59D995E, - 0x8BB64CE5, 0x2DC14751, 0x1C295DCC, 0xBA5E5678, - 0x7FF968F6, 0xD98E6342, 0xE86679DF, 0x4E11726B, - 0xB8590282, 0x1E2E0936, 0x2FC613AB, 0x89B1181F, - 0x4C162691, 0xEA612D25, 0xDB8937B8, 0x7DFE3C0C, - 0xEC68D02B, 0x4A1FDB9F, 0x7BF7C102, 0xDD80CAB6, - 0x1827F438, 0xBE50FF8C, 0x8FB8E511, 0x29CFEEA5, - 0xDF879E4C, 0x79F095F8, 0x48188F65, 0xEE6F84D1, - 0x2BC8BA5F, 0x8DBFB1EB, 0xBC57AB76, 0x1A20A0C2, - 0x8816EAF2, 0x2E61E146, 0x1F89FBDB, 0xB9FEF06F, - 0x7C59CEE1, 0xDA2EC555, 0xEBC6DFC8, 0x4DB1D47C, - 0xBBF9A495, 0x1D8EAF21, 0x2C66B5BC, 0x8A11BE08, - 0x4FB68086, 0xE9C18B32, 0xD82991AF, 0x7E5E9A1B, - 0xEFC8763C, 0x49BF7D88, 0x78576715, 0xDE206CA1, - 0x1B87522F, 0xBDF0599B, 0x8C184306, 0x2A6F48B2, - 0xDC27385B, 0x7A5033EF, 0x4BB82972, 0xEDCF22C6, - 0x28681C48, 0x8E1F17FC, 0xBFF70D61, 0x198006D5, - 0x47ABD36E, 0xE1DCD8DA, 0xD034C247, 0x7643C9F3, - 0xB3E4F77D, 0x1593FCC9, 0x247BE654, 0x820CEDE0, - 0x74449D09, 0xD23396BD, 0xE3DB8C20, 0x45AC8794, - 0x800BB91A, 0x267CB2AE, 0x1794A833, 0xB1E3A387, - 0x20754FA0, 0x86024414, 0xB7EA5E89, 0x119D553D, - 0xD43A6BB3, 0x724D6007, 0x43A57A9A, 0xE5D2712E, - 0x139A01C7, 0xB5ED0A73, 0x840510EE, 0x22721B5A, - 0xE7D525D4, 0x41A22E60, 0x704A34FD, 0xD63D3F49, - 0xCC1D9F8B, 0x6A6A943F, 0x5B828EA2, 0xFDF58516, - 0x3852BB98, 0x9E25B02C, 0xAFCDAAB1, 0x09BAA105, - 0xFFF2D1EC, 0x5985DA58, 0x686DC0C5, 0xCE1ACB71, - 0x0BBDF5FF, 0xADCAFE4B, 0x9C22E4D6, 0x3A55EF62, - 0xABC30345, 0x0DB408F1, 0x3C5C126C, 0x9A2B19D8, - 0x5F8C2756, 0xF9FB2CE2, 0xC813367F, 0x6E643DCB, - 0x982C4D22, 0x3E5B4696, 0x0FB35C0B, 0xA9C457BF, - 0x6C636931, 0xCA146285, 0xFBFC7818, 0x5D8B73AC, - 0x03A0A617, 0xA5D7ADA3, 0x943FB73E, 0x3248BC8A, - 0xF7EF8204, 0x519889B0, 0x6070932D, 0xC6079899, - 0x304FE870, 0x9638E3C4, 0xA7D0F959, 0x01A7F2ED, - 0xC400CC63, 0x6277C7D7, 0x539FDD4A, 0xF5E8D6FE, - 0x647E3AD9, 0xC209316D, 0xF3E12BF0, 0x55962044, - 0x90311ECA, 0x3646157E, 0x07AE0FE3, 0xA1D90457, - 0x579174BE, 0xF1E67F0A, 0xC00E6597, 0x66796E23, - 0xA3DE50AD, 0x05A95B19, 0x34414184, 0x92364A30 - }, { - 0x00000000, 0xCCAA009E, 0x4225077D, 0x8E8F07E3, - 0x844A0EFA, 0x48E00E64, 0xC66F0987, 0x0AC50919, - 0xD3E51BB5, 0x1F4F1B2B, 0x91C01CC8, 0x5D6A1C56, - 0x57AF154F, 0x9B0515D1, 0x158A1232, 0xD92012AC, - 0x7CBB312B, 0xB01131B5, 0x3E9E3656, 0xF23436C8, - 0xF8F13FD1, 0x345B3F4F, 0xBAD438AC, 0x767E3832, - 0xAF5E2A9E, 0x63F42A00, 0xED7B2DE3, 0x21D12D7D, - 0x2B142464, 0xE7BE24FA, 0x69312319, 0xA59B2387, - 0xF9766256, 0x35DC62C8, 0xBB53652B, 0x77F965B5, - 0x7D3C6CAC, 0xB1966C32, 0x3F196BD1, 0xF3B36B4F, - 0x2A9379E3, 0xE639797D, 0x68B67E9E, 0xA41C7E00, - 0xAED97719, 0x62737787, 0xECFC7064, 0x205670FA, - 0x85CD537D, 0x496753E3, 0xC7E85400, 0x0B42549E, - 0x01875D87, 0xCD2D5D19, 0x43A25AFA, 0x8F085A64, - 0x562848C8, 0x9A824856, 0x140D4FB5, 0xD8A74F2B, - 0xD2624632, 0x1EC846AC, 0x9047414F, 0x5CED41D1, - 0x299DC2ED, 0xE537C273, 0x6BB8C590, 0xA712C50E, - 0xADD7CC17, 0x617DCC89, 0xEFF2CB6A, 0x2358CBF4, - 0xFA78D958, 0x36D2D9C6, 0xB85DDE25, 0x74F7DEBB, - 0x7E32D7A2, 0xB298D73C, 0x3C17D0DF, 0xF0BDD041, - 0x5526F3C6, 0x998CF358, 0x1703F4BB, 0xDBA9F425, - 0xD16CFD3C, 0x1DC6FDA2, 0x9349FA41, 0x5FE3FADF, - 0x86C3E873, 0x4A69E8ED, 0xC4E6EF0E, 0x084CEF90, - 0x0289E689, 0xCE23E617, 0x40ACE1F4, 0x8C06E16A, - 0xD0EBA0BB, 0x1C41A025, 0x92CEA7C6, 0x5E64A758, - 0x54A1AE41, 0x980BAEDF, 0x1684A93C, 0xDA2EA9A2, - 0x030EBB0E, 0xCFA4BB90, 0x412BBC73, 0x8D81BCED, - 0x8744B5F4, 0x4BEEB56A, 0xC561B289, 0x09CBB217, - 0xAC509190, 0x60FA910E, 0xEE7596ED, 0x22DF9673, - 0x281A9F6A, 0xE4B09FF4, 0x6A3F9817, 0xA6959889, - 0x7FB58A25, 0xB31F8ABB, 0x3D908D58, 0xF13A8DC6, - 0xFBFF84DF, 0x37558441, 0xB9DA83A2, 0x7570833C, - 0x533B85DA, 0x9F918544, 0x111E82A7, 0xDDB48239, - 0xD7718B20, 0x1BDB8BBE, 0x95548C5D, 0x59FE8CC3, - 0x80DE9E6F, 0x4C749EF1, 0xC2FB9912, 0x0E51998C, - 0x04949095, 0xC83E900B, 0x46B197E8, 0x8A1B9776, - 0x2F80B4F1, 0xE32AB46F, 0x6DA5B38C, 0xA10FB312, - 0xABCABA0B, 0x6760BA95, 0xE9EFBD76, 0x2545BDE8, - 0xFC65AF44, 0x30CFAFDA, 0xBE40A839, 0x72EAA8A7, - 0x782FA1BE, 0xB485A120, 0x3A0AA6C3, 0xF6A0A65D, - 0xAA4DE78C, 0x66E7E712, 0xE868E0F1, 0x24C2E06F, - 0x2E07E976, 0xE2ADE9E8, 0x6C22EE0B, 0xA088EE95, - 0x79A8FC39, 0xB502FCA7, 0x3B8DFB44, 0xF727FBDA, - 0xFDE2F2C3, 0x3148F25D, 0xBFC7F5BE, 0x736DF520, - 0xD6F6D6A7, 0x1A5CD639, 0x94D3D1DA, 0x5879D144, - 0x52BCD85D, 0x9E16D8C3, 0x1099DF20, 0xDC33DFBE, - 0x0513CD12, 0xC9B9CD8C, 0x4736CA6F, 0x8B9CCAF1, - 0x8159C3E8, 0x4DF3C376, 0xC37CC495, 0x0FD6C40B, - 0x7AA64737, 0xB60C47A9, 0x3883404A, 0xF42940D4, - 0xFEEC49CD, 0x32464953, 0xBCC94EB0, 0x70634E2E, - 0xA9435C82, 0x65E95C1C, 0xEB665BFF, 0x27CC5B61, - 0x2D095278, 0xE1A352E6, 0x6F2C5505, 0xA386559B, - 0x061D761C, 0xCAB77682, 0x44387161, 0x889271FF, - 0x825778E6, 0x4EFD7878, 0xC0727F9B, 0x0CD87F05, - 0xD5F86DA9, 0x19526D37, 0x97DD6AD4, 0x5B776A4A, - 0x51B26353, 0x9D1863CD, 0x1397642E, 0xDF3D64B0, - 0x83D02561, 0x4F7A25FF, 0xC1F5221C, 0x0D5F2282, - 0x079A2B9B, 0xCB302B05, 0x45BF2CE6, 0x89152C78, - 0x50353ED4, 0x9C9F3E4A, 0x121039A9, 0xDEBA3937, - 0xD47F302E, 0x18D530B0, 0x965A3753, 0x5AF037CD, - 0xFF6B144A, 0x33C114D4, 0xBD4E1337, 0x71E413A9, - 0x7B211AB0, 0xB78B1A2E, 0x39041DCD, 0xF5AE1D53, - 0x2C8E0FFF, 0xE0240F61, 0x6EAB0882, 0xA201081C, - 0xA8C40105, 0x646E019B, 0xEAE10678, 0x264B06E6 - } -}; diff --git a/deps/lzma/liblzma/check/crc32_tablegen.c b/deps/lzma/liblzma/check/crc32_tablegen.c deleted file mode 100644 index 31a4d27..0000000 --- a/deps/lzma/liblzma/check/crc32_tablegen.c +++ /dev/null @@ -1,117 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file crc32_tablegen.c -/// \brief Generate crc32_table_le.h and crc32_table_be.h -/// -/// Compiling: gcc -std=c99 -o crc32_tablegen crc32_tablegen.c -/// Add -DWORDS_BIGENDIAN to generate big endian table. -/// Add -DLZ_HASH_TABLE to generate lz_encoder_hash_table.h (little endian). -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include -#include "../../common/tuklib_integer.h" - - -static uint32_t crc32_table[8][256]; - - -static void -init_crc32_table(void) -{ - static const uint32_t poly32 = UINT32_C(0xEDB88320); - - for (size_t s = 0; s < 8; ++s) { - for (size_t b = 0; b < 256; ++b) { - uint32_t r = s == 0 ? b : crc32_table[s - 1][b]; - - for (size_t i = 0; i < 8; ++i) { - if (r & 1) - r = (r >> 1) ^ poly32; - else - r >>= 1; - } - - crc32_table[s][b] = r; - } - } - -#ifdef WORDS_BIGENDIAN - for (size_t s = 0; s < 8; ++s) - for (size_t b = 0; b < 256; ++b) - crc32_table[s][b] = bswap32(crc32_table[s][b]); -#endif - - return; -} - - -static void -print_crc32_table(void) -{ - printf("/* This file has been automatically generated by " - "crc32_tablegen.c. */\n\n" - "const uint32_t lzma_crc32_table[8][256] = {\n\t{"); - - for (size_t s = 0; s < 8; ++s) { - for (size_t b = 0; b < 256; ++b) { - if ((b % 4) == 0) - printf("\n\t\t"); - - printf("0x%08" PRIX32, crc32_table[s][b]); - - if (b != 255) - printf(",%s", (b+1) % 4 == 0 ? "" : " "); - } - - if (s == 7) - printf("\n\t}\n};\n"); - else - printf("\n\t}, {"); - } - - return; -} - - -static void -print_lz_table(void) -{ - printf("/* This file has been automatically generated by " - "crc32_tablegen.c. */\n\n" - "const uint32_t lzma_lz_hash_table[256] = {"); - - for (size_t b = 0; b < 256; ++b) { - if ((b % 4) == 0) - printf("\n\t"); - - printf("0x%08" PRIX32, crc32_table[0][b]); - - if (b != 255) - printf(",%s", (b+1) % 4 == 0 ? "" : " "); - } - - printf("\n};\n"); - - return; -} - - -int -main(void) -{ - init_crc32_table(); - -#ifdef LZ_HASH_TABLE - print_lz_table(); -#else - print_crc32_table(); -#endif - - return 0; -} diff --git a/deps/lzma/liblzma/check/crc32_x86.S b/deps/lzma/liblzma/check/crc32_x86.S deleted file mode 100644 index 67f68a4..0000000 --- a/deps/lzma/liblzma/check/crc32_x86.S +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Speed-optimized CRC32 using slicing-by-eight algorithm - * - * This uses only i386 instructions, but it is optimized for i686 and later - * (including e.g. Pentium II/III/IV, Athlon XP, and Core 2). For i586 - * (e.g. Pentium), slicing-by-four would be better, and even the C version - * of slicing-by-eight built with gcc -march=i586 tends to be a little bit - * better than this. Very few probably run this code on i586 or older x86 - * so this shouldn't be a problem in practice. - * - * Authors: Igor Pavlov (original version) - * Lasse Collin (AT&T syntax, PIC support, better portability) - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * This code needs lzma_crc32_table, which can be created using the - * following C code: - -uint32_t lzma_crc32_table[8][256]; - -void -init_table(void) -{ - // IEEE-802.3 - static const uint32_t poly32 = UINT32_C(0xEDB88320); - - // Castagnoli - // static const uint32_t poly32 = UINT32_C(0x82F63B78); - - // Koopman - // static const uint32_t poly32 = UINT32_C(0xEB31D82E); - - for (size_t s = 0; s < 8; ++s) { - for (size_t b = 0; b < 256; ++b) { - uint32_t r = s == 0 ? b : lzma_crc32_table[s - 1][b]; - - for (size_t i = 0; i < 8; ++i) { - if (r & 1) - r = (r >> 1) ^ poly32; - else - r >>= 1; - } - - lzma_crc32_table[s][b] = r; - } - } -} - - * The prototype of the CRC32 function: - * extern uint32_t lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc); - */ - -/* - * On some systems, the functions need to be prefixed. The prefix is - * usually an underscore. - */ -#ifndef __USER_LABEL_PREFIX__ -# define __USER_LABEL_PREFIX__ -#endif -#define MAKE_SYM_CAT(prefix, sym) prefix ## sym -#define MAKE_SYM(prefix, sym) MAKE_SYM_CAT(prefix, sym) -#define LZMA_CRC32 MAKE_SYM(__USER_LABEL_PREFIX__, lzma_crc32) -#define LZMA_CRC32_TABLE MAKE_SYM(__USER_LABEL_PREFIX__, lzma_crc32_table) - -/* - * Solaris assembler doesn't have .p2align, and Darwin uses .align - * differently than GNU/Linux and Solaris. - */ -#if defined(__APPLE__) || defined(__MSDOS__) -# define ALIGN(pow2, abs) .align pow2 -#else -# define ALIGN(pow2, abs) .align abs -#endif - - .text - .globl LZMA_CRC32 - -#if !defined(__APPLE__) && !defined(_WIN32) && !defined(__CYGWIN__) \ - && !defined(__MSDOS__) - .type LZMA_CRC32, @function -#endif - - ALIGN(4, 16) -LZMA_CRC32: - /* - * Register usage: - * %eax crc - * %esi buf - * %edi size or buf + size - * %ebx lzma_crc32_table - * %ebp Table index - * %ecx Temporary - * %edx Temporary - */ - pushl %ebx - pushl %esi - pushl %edi - pushl %ebp - movl 0x14(%esp), %esi /* buf */ - movl 0x18(%esp), %edi /* size */ - movl 0x1C(%esp), %eax /* crc */ - - /* - * Store the address of lzma_crc32_table to %ebx. This is needed to - * get position-independent code (PIC). - * - * The PIC macro is defined by libtool, while __PIC__ is defined - * by GCC but only on some systems. Testing for both makes it simpler - * to test this code without libtool, and keeps the code working also - * when built with libtool but using something else than GCC. - * - * I understood that libtool may define PIC on Windows even though - * the code in Windows DLLs is not PIC in sense that it is in ELF - * binaries, so we need a separate check to always use the non-PIC - * code on Windows. - */ -#if (!defined(PIC) && !defined(__PIC__)) \ - || (defined(_WIN32) || defined(__CYGWIN__)) - /* Not PIC */ - movl $ LZMA_CRC32_TABLE, %ebx -#elif defined(__APPLE__) - /* Mach-O */ - call .L_get_pc -.L_pic: - leal .L_lzma_crc32_table$non_lazy_ptr-.L_pic(%ebx), %ebx - movl (%ebx), %ebx -#else - /* ELF */ - call .L_get_pc - addl $_GLOBAL_OFFSET_TABLE_, %ebx - movl LZMA_CRC32_TABLE@GOT(%ebx), %ebx -#endif - - /* Complement the initial value. */ - notl %eax - - ALIGN(4, 16) -.L_align: - /* - * Check if there is enough input to use slicing-by-eight. - * We need 16 bytes, because the loop pre-reads eight bytes. - */ - cmpl $16, %edi - jb .L_rest - - /* Check if we have reached alignment of eight bytes. */ - testl $7, %esi - jz .L_slice - - /* Calculate CRC of the next input byte. */ - movzbl (%esi), %ebp - incl %esi - movzbl %al, %ecx - xorl %ecx, %ebp - shrl $8, %eax - xorl (%ebx, %ebp, 4), %eax - decl %edi - jmp .L_align - - ALIGN(2, 4) -.L_slice: - /* - * If we get here, there's at least 16 bytes of aligned input - * available. Make %edi multiple of eight bytes. Store the possible - * remainder over the "size" variable in the argument stack. - */ - movl %edi, 0x18(%esp) - andl $-8, %edi - subl %edi, 0x18(%esp) - - /* - * Let %edi be buf + size - 8 while running the main loop. This way - * we can compare for equality to determine when exit the loop. - */ - addl %esi, %edi - subl $8, %edi - - /* Read in the first eight aligned bytes. */ - xorl (%esi), %eax - movl 4(%esi), %ecx - movzbl %cl, %ebp - -.L_loop: - movl 0x0C00(%ebx, %ebp, 4), %edx - movzbl %ch, %ebp - xorl 0x0800(%ebx, %ebp, 4), %edx - shrl $16, %ecx - xorl 8(%esi), %edx - movzbl %cl, %ebp - xorl 0x0400(%ebx, %ebp, 4), %edx - movzbl %ch, %ebp - xorl (%ebx, %ebp, 4), %edx - movzbl %al, %ebp - - /* - * Read the next four bytes, for which the CRC is calculated - * on the next interation of the loop. - */ - movl 12(%esi), %ecx - - xorl 0x1C00(%ebx, %ebp, 4), %edx - movzbl %ah, %ebp - shrl $16, %eax - xorl 0x1800(%ebx, %ebp, 4), %edx - movzbl %ah, %ebp - movzbl %al, %eax - movl 0x1400(%ebx, %eax, 4), %eax - addl $8, %esi - xorl %edx, %eax - xorl 0x1000(%ebx, %ebp, 4), %eax - - /* Check for end of aligned input. */ - cmpl %edi, %esi - movzbl %cl, %ebp - jne .L_loop - - /* - * Process the remaining eight bytes, which we have already - * copied to %ecx and %edx. - */ - movl 0x0C00(%ebx, %ebp, 4), %edx - movzbl %ch, %ebp - xorl 0x0800(%ebx, %ebp, 4), %edx - shrl $16, %ecx - movzbl %cl, %ebp - xorl 0x0400(%ebx, %ebp, 4), %edx - movzbl %ch, %ebp - xorl (%ebx, %ebp, 4), %edx - movzbl %al, %ebp - - xorl 0x1C00(%ebx, %ebp, 4), %edx - movzbl %ah, %ebp - shrl $16, %eax - xorl 0x1800(%ebx, %ebp, 4), %edx - movzbl %ah, %ebp - movzbl %al, %eax - movl 0x1400(%ebx, %eax, 4), %eax - addl $8, %esi - xorl %edx, %eax - xorl 0x1000(%ebx, %ebp, 4), %eax - - /* Copy the number of remaining bytes to %edi. */ - movl 0x18(%esp), %edi - -.L_rest: - /* Check for end of input. */ - testl %edi, %edi - jz .L_return - - /* Calculate CRC of the next input byte. */ - movzbl (%esi), %ebp - incl %esi - movzbl %al, %ecx - xorl %ecx, %ebp - shrl $8, %eax - xorl (%ebx, %ebp, 4), %eax - decl %edi - jmp .L_rest - -.L_return: - /* Complement the final value. */ - notl %eax - - popl %ebp - popl %edi - popl %esi - popl %ebx - ret - -#if defined(PIC) || defined(__PIC__) - ALIGN(4, 16) -.L_get_pc: - movl (%esp), %ebx - ret -#endif - -#if defined(__APPLE__) && (defined(PIC) || defined(__PIC__)) - /* Mach-O PIC */ - .section __IMPORT,__pointers,non_lazy_symbol_pointers -.L_lzma_crc32_table$non_lazy_ptr: - .indirect_symbol LZMA_CRC32_TABLE - .long 0 - -#elif defined(_WIN32) || defined(__CYGWIN__) -# ifdef DLL_EXPORT - /* This is equivalent of __declspec(dllexport). */ - .section .drectve - .ascii " -export:lzma_crc32" -# endif - -#elif !defined(__MSDOS__) - /* ELF */ - .size LZMA_CRC32, .-LZMA_CRC32 -#endif - -/* - * This is needed to support non-executable stack. It's ugly to - * use __linux__ here, but I don't know a way to detect when - * we are using GNU assembler. - */ -#if defined(__ELF__) && defined(__linux__) - .section .note.GNU-stack,"",@progbits -#endif diff --git a/deps/lzma/liblzma/check/crc64_fast.c b/deps/lzma/liblzma/check/crc64_fast.c deleted file mode 100644 index 52af29e..0000000 --- a/deps/lzma/liblzma/check/crc64_fast.c +++ /dev/null @@ -1,72 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file crc64.c -/// \brief CRC64 calculation -/// -/// Calculate the CRC64 using the slice-by-four algorithm. This is the same -/// idea that is used in crc32_fast.c, but for CRC64 we use only four tables -/// instead of eight to avoid increasing CPU cache usage. -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "check.h" -#include "crc_macros.h" - - -#ifdef WORDS_BIGENDIAN -# define A1(x) ((x) >> 56) -#else -# define A1 A -#endif - - -// See the comments in crc32_fast.c. They aren't duplicated here. -extern LZMA_API(uint64_t) -lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc) -{ - crc = ~crc; - -#ifdef WORDS_BIGENDIAN - crc = bswap64(crc); -#endif - - if (size > 4) { - while ((uintptr_t)(buf) & 3) { - crc = lzma_crc64_table[0][*buf++ ^ A1(crc)] ^ S8(crc); - --size; - } - - const uint8_t *const limit = buf + (size & ~(size_t)(3)); - size &= (size_t)(3); - - while (buf < limit) { -#ifdef WORDS_BIGENDIAN - const uint32_t tmp = (crc >> 32) - ^ *(const uint32_t *)(buf); -#else - const uint32_t tmp = crc ^ *(const uint32_t *)(buf); -#endif - buf += 4; - - crc = lzma_crc64_table[3][A(tmp)] - ^ lzma_crc64_table[2][B(tmp)] - ^ S32(crc) - ^ lzma_crc64_table[1][C(tmp)] - ^ lzma_crc64_table[0][D(tmp)]; - } - } - - while (size-- != 0) - crc = lzma_crc64_table[0][*buf++ ^ A1(crc)] ^ S8(crc); - -#ifdef WORDS_BIGENDIAN - crc = bswap64(crc); -#endif - - return ~crc; -} diff --git a/deps/lzma/liblzma/check/crc64_small.c b/deps/lzma/liblzma/check/crc64_small.c deleted file mode 100644 index 55d7231..0000000 --- a/deps/lzma/liblzma/check/crc64_small.c +++ /dev/null @@ -1,53 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file crc64_small.c -/// \brief CRC64 calculation (size-optimized) -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "check.h" - - -static uint64_t crc64_table[256]; - - -static void -crc64_init(void) -{ - static const uint64_t poly64 = UINT64_C(0xC96C5795D7870F42); - - for (size_t b = 0; b < 256; ++b) { - uint64_t r = b; - for (size_t i = 0; i < 8; ++i) { - if (r & 1) - r = (r >> 1) ^ poly64; - else - r >>= 1; - } - - crc64_table[b] = r; - } - - return; -} - - -extern LZMA_API(uint64_t) -lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc) -{ - mythread_once(crc64_init); - - crc = ~crc; - - while (size != 0) { - crc = crc64_table[*buf++ ^ (crc & 0xFF)] ^ (crc >> 8); - --size; - } - - return ~crc; -} diff --git a/deps/lzma/liblzma/check/crc64_table.c b/deps/lzma/liblzma/check/crc64_table.c deleted file mode 100644 index 1fbcd94..0000000 --- a/deps/lzma/liblzma/check/crc64_table.c +++ /dev/null @@ -1,19 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file crc64_table.c -/// \brief Precalculated CRC64 table with correct endianness -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "common.h" - -#ifdef WORDS_BIGENDIAN -# include "crc64_table_be.h" -#else -# include "crc64_table_le.h" -#endif diff --git a/deps/lzma/liblzma/check/crc64_table_be.h b/deps/lzma/liblzma/check/crc64_table_be.h deleted file mode 100644 index ea074f3..0000000 --- a/deps/lzma/liblzma/check/crc64_table_be.h +++ /dev/null @@ -1,521 +0,0 @@ -/* This file has been automatically generated by crc64_tablegen.c. */ - -const uint64_t lzma_crc64_table[4][256] = { - { - UINT64_C(0x0000000000000000), UINT64_C(0x6F5FA703BE4C2EB3), - UINT64_C(0x5BA040A8573684F4), UINT64_C(0x34FFE7ABE97AAA47), - UINT64_C(0x335E8FFF84C3D07B), UINT64_C(0x5C0128FC3A8FFEC8), - UINT64_C(0x68FECF57D3F5548F), UINT64_C(0x07A168546DB97A3C), - UINT64_C(0x66BC1EFF0987A1F7), UINT64_C(0x09E3B9FCB7CB8F44), - UINT64_C(0x3D1C5E575EB12503), UINT64_C(0x5243F954E0FD0BB0), - UINT64_C(0x55E291008D44718C), UINT64_C(0x3ABD360333085F3F), - UINT64_C(0x0E42D1A8DA72F578), UINT64_C(0x611D76AB643EDBCB), - UINT64_C(0x4966335138A19B7D), UINT64_C(0x2639945286EDB5CE), - UINT64_C(0x12C673F96F971F89), UINT64_C(0x7D99D4FAD1DB313A), - UINT64_C(0x7A38BCAEBC624B06), UINT64_C(0x15671BAD022E65B5), - UINT64_C(0x2198FC06EB54CFF2), UINT64_C(0x4EC75B055518E141), - UINT64_C(0x2FDA2DAE31263A8A), UINT64_C(0x40858AAD8F6A1439), - UINT64_C(0x747A6D066610BE7E), UINT64_C(0x1B25CA05D85C90CD), - UINT64_C(0x1C84A251B5E5EAF1), UINT64_C(0x73DB05520BA9C442), - UINT64_C(0x4724E2F9E2D36E05), UINT64_C(0x287B45FA5C9F40B6), - UINT64_C(0x92CC66A2704237FB), UINT64_C(0xFD93C1A1CE0E1948), - UINT64_C(0xC96C260A2774B30F), UINT64_C(0xA633810999389DBC), - UINT64_C(0xA192E95DF481E780), UINT64_C(0xCECD4E5E4ACDC933), - UINT64_C(0xFA32A9F5A3B76374), UINT64_C(0x956D0EF61DFB4DC7), - UINT64_C(0xF470785D79C5960C), UINT64_C(0x9B2FDF5EC789B8BF), - UINT64_C(0xAFD038F52EF312F8), UINT64_C(0xC08F9FF690BF3C4B), - UINT64_C(0xC72EF7A2FD064677), UINT64_C(0xA87150A1434A68C4), - UINT64_C(0x9C8EB70AAA30C283), UINT64_C(0xF3D11009147CEC30), - UINT64_C(0xDBAA55F348E3AC86), UINT64_C(0xB4F5F2F0F6AF8235), - UINT64_C(0x800A155B1FD52872), UINT64_C(0xEF55B258A19906C1), - UINT64_C(0xE8F4DA0CCC207CFD), UINT64_C(0x87AB7D0F726C524E), - UINT64_C(0xB3549AA49B16F809), UINT64_C(0xDC0B3DA7255AD6BA), - UINT64_C(0xBD164B0C41640D71), UINT64_C(0xD249EC0FFF2823C2), - UINT64_C(0xE6B60BA416528985), UINT64_C(0x89E9ACA7A81EA736), - UINT64_C(0x8E48C4F3C5A7DD0A), UINT64_C(0xE11763F07BEBF3B9), - UINT64_C(0xD5E8845B929159FE), UINT64_C(0xBAB723582CDD774D), - UINT64_C(0xA187C3EBCA2BB664), UINT64_C(0xCED864E8746798D7), - UINT64_C(0xFA2783439D1D3290), UINT64_C(0x9578244023511C23), - UINT64_C(0x92D94C144EE8661F), UINT64_C(0xFD86EB17F0A448AC), - UINT64_C(0xC9790CBC19DEE2EB), UINT64_C(0xA626ABBFA792CC58), - UINT64_C(0xC73BDD14C3AC1793), UINT64_C(0xA8647A177DE03920), - UINT64_C(0x9C9B9DBC949A9367), UINT64_C(0xF3C43ABF2AD6BDD4), - UINT64_C(0xF46552EB476FC7E8), UINT64_C(0x9B3AF5E8F923E95B), - UINT64_C(0xAFC512431059431C), UINT64_C(0xC09AB540AE156DAF), - UINT64_C(0xE8E1F0BAF28A2D19), UINT64_C(0x87BE57B94CC603AA), - UINT64_C(0xB341B012A5BCA9ED), UINT64_C(0xDC1E17111BF0875E), - UINT64_C(0xDBBF7F457649FD62), UINT64_C(0xB4E0D846C805D3D1), - UINT64_C(0x801F3FED217F7996), UINT64_C(0xEF4098EE9F335725), - UINT64_C(0x8E5DEE45FB0D8CEE), UINT64_C(0xE10249464541A25D), - UINT64_C(0xD5FDAEEDAC3B081A), UINT64_C(0xBAA209EE127726A9), - UINT64_C(0xBD0361BA7FCE5C95), UINT64_C(0xD25CC6B9C1827226), - UINT64_C(0xE6A3211228F8D861), UINT64_C(0x89FC861196B4F6D2), - UINT64_C(0x334BA549BA69819F), UINT64_C(0x5C14024A0425AF2C), - UINT64_C(0x68EBE5E1ED5F056B), UINT64_C(0x07B442E253132BD8), - UINT64_C(0x00152AB63EAA51E4), UINT64_C(0x6F4A8DB580E67F57), - UINT64_C(0x5BB56A1E699CD510), UINT64_C(0x34EACD1DD7D0FBA3), - UINT64_C(0x55F7BBB6B3EE2068), UINT64_C(0x3AA81CB50DA20EDB), - UINT64_C(0x0E57FB1EE4D8A49C), UINT64_C(0x61085C1D5A948A2F), - UINT64_C(0x66A93449372DF013), UINT64_C(0x09F6934A8961DEA0), - UINT64_C(0x3D0974E1601B74E7), UINT64_C(0x5256D3E2DE575A54), - UINT64_C(0x7A2D961882C81AE2), UINT64_C(0x1572311B3C843451), - UINT64_C(0x218DD6B0D5FE9E16), UINT64_C(0x4ED271B36BB2B0A5), - UINT64_C(0x497319E7060BCA99), UINT64_C(0x262CBEE4B847E42A), - UINT64_C(0x12D3594F513D4E6D), UINT64_C(0x7D8CFE4CEF7160DE), - UINT64_C(0x1C9188E78B4FBB15), UINT64_C(0x73CE2FE4350395A6), - UINT64_C(0x4731C84FDC793FE1), UINT64_C(0x286E6F4C62351152), - UINT64_C(0x2FCF07180F8C6B6E), UINT64_C(0x4090A01BB1C045DD), - UINT64_C(0x746F47B058BAEF9A), UINT64_C(0x1B30E0B3E6F6C129), - UINT64_C(0x420F87D795576CC9), UINT64_C(0x2D5020D42B1B427A), - UINT64_C(0x19AFC77FC261E83D), UINT64_C(0x76F0607C7C2DC68E), - UINT64_C(0x715108281194BCB2), UINT64_C(0x1E0EAF2BAFD89201), - UINT64_C(0x2AF1488046A23846), UINT64_C(0x45AEEF83F8EE16F5), - UINT64_C(0x24B399289CD0CD3E), UINT64_C(0x4BEC3E2B229CE38D), - UINT64_C(0x7F13D980CBE649CA), UINT64_C(0x104C7E8375AA6779), - UINT64_C(0x17ED16D718131D45), UINT64_C(0x78B2B1D4A65F33F6), - UINT64_C(0x4C4D567F4F2599B1), UINT64_C(0x2312F17CF169B702), - UINT64_C(0x0B69B486ADF6F7B4), UINT64_C(0x6436138513BAD907), - UINT64_C(0x50C9F42EFAC07340), UINT64_C(0x3F96532D448C5DF3), - UINT64_C(0x38373B79293527CF), UINT64_C(0x57689C7A9779097C), - UINT64_C(0x63977BD17E03A33B), UINT64_C(0x0CC8DCD2C04F8D88), - UINT64_C(0x6DD5AA79A4715643), UINT64_C(0x028A0D7A1A3D78F0), - UINT64_C(0x3675EAD1F347D2B7), UINT64_C(0x592A4DD24D0BFC04), - UINT64_C(0x5E8B258620B28638), UINT64_C(0x31D482859EFEA88B), - UINT64_C(0x052B652E778402CC), UINT64_C(0x6A74C22DC9C82C7F), - UINT64_C(0xD0C3E175E5155B32), UINT64_C(0xBF9C46765B597581), - UINT64_C(0x8B63A1DDB223DFC6), UINT64_C(0xE43C06DE0C6FF175), - UINT64_C(0xE39D6E8A61D68B49), UINT64_C(0x8CC2C989DF9AA5FA), - UINT64_C(0xB83D2E2236E00FBD), UINT64_C(0xD762892188AC210E), - UINT64_C(0xB67FFF8AEC92FAC5), UINT64_C(0xD920588952DED476), - UINT64_C(0xEDDFBF22BBA47E31), UINT64_C(0x8280182105E85082), - UINT64_C(0x8521707568512ABE), UINT64_C(0xEA7ED776D61D040D), - UINT64_C(0xDE8130DD3F67AE4A), UINT64_C(0xB1DE97DE812B80F9), - UINT64_C(0x99A5D224DDB4C04F), UINT64_C(0xF6FA752763F8EEFC), - UINT64_C(0xC205928C8A8244BB), UINT64_C(0xAD5A358F34CE6A08), - UINT64_C(0xAAFB5DDB59771034), UINT64_C(0xC5A4FAD8E73B3E87), - UINT64_C(0xF15B1D730E4194C0), UINT64_C(0x9E04BA70B00DBA73), - UINT64_C(0xFF19CCDBD43361B8), UINT64_C(0x90466BD86A7F4F0B), - UINT64_C(0xA4B98C738305E54C), UINT64_C(0xCBE62B703D49CBFF), - UINT64_C(0xCC47432450F0B1C3), UINT64_C(0xA318E427EEBC9F70), - UINT64_C(0x97E7038C07C63537), UINT64_C(0xF8B8A48FB98A1B84), - UINT64_C(0xE388443C5F7CDAAD), UINT64_C(0x8CD7E33FE130F41E), - UINT64_C(0xB8280494084A5E59), UINT64_C(0xD777A397B60670EA), - UINT64_C(0xD0D6CBC3DBBF0AD6), UINT64_C(0xBF896CC065F32465), - UINT64_C(0x8B768B6B8C898E22), UINT64_C(0xE4292C6832C5A091), - UINT64_C(0x85345AC356FB7B5A), UINT64_C(0xEA6BFDC0E8B755E9), - UINT64_C(0xDE941A6B01CDFFAE), UINT64_C(0xB1CBBD68BF81D11D), - UINT64_C(0xB66AD53CD238AB21), UINT64_C(0xD935723F6C748592), - UINT64_C(0xEDCA9594850E2FD5), UINT64_C(0x829532973B420166), - UINT64_C(0xAAEE776D67DD41D0), UINT64_C(0xC5B1D06ED9916F63), - UINT64_C(0xF14E37C530EBC524), UINT64_C(0x9E1190C68EA7EB97), - UINT64_C(0x99B0F892E31E91AB), UINT64_C(0xF6EF5F915D52BF18), - UINT64_C(0xC210B83AB428155F), UINT64_C(0xAD4F1F390A643BEC), - UINT64_C(0xCC5269926E5AE027), UINT64_C(0xA30DCE91D016CE94), - UINT64_C(0x97F2293A396C64D3), UINT64_C(0xF8AD8E3987204A60), - UINT64_C(0xFF0CE66DEA99305C), UINT64_C(0x9053416E54D51EEF), - UINT64_C(0xA4ACA6C5BDAFB4A8), UINT64_C(0xCBF301C603E39A1B), - UINT64_C(0x7144229E2F3EED56), UINT64_C(0x1E1B859D9172C3E5), - UINT64_C(0x2AE46236780869A2), UINT64_C(0x45BBC535C6444711), - UINT64_C(0x421AAD61ABFD3D2D), UINT64_C(0x2D450A6215B1139E), - UINT64_C(0x19BAEDC9FCCBB9D9), UINT64_C(0x76E54ACA4287976A), - UINT64_C(0x17F83C6126B94CA1), UINT64_C(0x78A79B6298F56212), - UINT64_C(0x4C587CC9718FC855), UINT64_C(0x2307DBCACFC3E6E6), - UINT64_C(0x24A6B39EA27A9CDA), UINT64_C(0x4BF9149D1C36B269), - UINT64_C(0x7F06F336F54C182E), UINT64_C(0x105954354B00369D), - UINT64_C(0x382211CF179F762B), UINT64_C(0x577DB6CCA9D35898), - UINT64_C(0x6382516740A9F2DF), UINT64_C(0x0CDDF664FEE5DC6C), - UINT64_C(0x0B7C9E30935CA650), UINT64_C(0x642339332D1088E3), - UINT64_C(0x50DCDE98C46A22A4), UINT64_C(0x3F83799B7A260C17), - UINT64_C(0x5E9E0F301E18D7DC), UINT64_C(0x31C1A833A054F96F), - UINT64_C(0x053E4F98492E5328), UINT64_C(0x6A61E89BF7627D9B), - UINT64_C(0x6DC080CF9ADB07A7), UINT64_C(0x029F27CC24972914), - UINT64_C(0x3660C067CDED8353), UINT64_C(0x593F676473A1ADE0) - }, { - UINT64_C(0x0000000000000000), UINT64_C(0x0DF1D05C9279E954), - UINT64_C(0x1AE2A1B924F3D2A9), UINT64_C(0x171371E5B68A3BFD), - UINT64_C(0xB1DA4DDC62497DC1), UINT64_C(0xBC2B9D80F0309495), - UINT64_C(0xAB38EC6546BAAF68), UINT64_C(0xA6C93C39D4C3463C), - UINT64_C(0xE7AB9517EE3D2210), UINT64_C(0xEA5A454B7C44CB44), - UINT64_C(0xFD4934AECACEF0B9), UINT64_C(0xF0B8E4F258B719ED), - UINT64_C(0x5671D8CB8C745FD1), UINT64_C(0x5B8008971E0DB685), - UINT64_C(0x4C937972A8878D78), UINT64_C(0x4162A92E3AFE642C), - UINT64_C(0xCE572B2FDC7B4420), UINT64_C(0xC3A6FB734E02AD74), - UINT64_C(0xD4B58A96F8889689), UINT64_C(0xD9445ACA6AF17FDD), - UINT64_C(0x7F8D66F3BE3239E1), UINT64_C(0x727CB6AF2C4BD0B5), - UINT64_C(0x656FC74A9AC1EB48), UINT64_C(0x689E171608B8021C), - UINT64_C(0x29FCBE3832466630), UINT64_C(0x240D6E64A03F8F64), - UINT64_C(0x331E1F8116B5B499), UINT64_C(0x3EEFCFDD84CC5DCD), - UINT64_C(0x9826F3E4500F1BF1), UINT64_C(0x95D723B8C276F2A5), - UINT64_C(0x82C4525D74FCC958), UINT64_C(0x8F358201E685200C), - UINT64_C(0x9CAF565EB8F78840), UINT64_C(0x915E86022A8E6114), - UINT64_C(0x864DF7E79C045AE9), UINT64_C(0x8BBC27BB0E7DB3BD), - UINT64_C(0x2D751B82DABEF581), UINT64_C(0x2084CBDE48C71CD5), - UINT64_C(0x3797BA3BFE4D2728), UINT64_C(0x3A666A676C34CE7C), - UINT64_C(0x7B04C34956CAAA50), UINT64_C(0x76F51315C4B34304), - UINT64_C(0x61E662F0723978F9), UINT64_C(0x6C17B2ACE04091AD), - UINT64_C(0xCADE8E953483D791), UINT64_C(0xC72F5EC9A6FA3EC5), - UINT64_C(0xD03C2F2C10700538), UINT64_C(0xDDCDFF708209EC6C), - UINT64_C(0x52F87D71648CCC60), UINT64_C(0x5F09AD2DF6F52534), - UINT64_C(0x481ADCC8407F1EC9), UINT64_C(0x45EB0C94D206F79D), - UINT64_C(0xE32230AD06C5B1A1), UINT64_C(0xEED3E0F194BC58F5), - UINT64_C(0xF9C0911422366308), UINT64_C(0xF4314148B04F8A5C), - UINT64_C(0xB553E8668AB1EE70), UINT64_C(0xB8A2383A18C80724), - UINT64_C(0xAFB149DFAE423CD9), UINT64_C(0xA24099833C3BD58D), - UINT64_C(0x0489A5BAE8F893B1), UINT64_C(0x097875E67A817AE5), - UINT64_C(0x1E6B0403CC0B4118), UINT64_C(0x139AD45F5E72A84C), - UINT64_C(0x385FADBC70EF1181), UINT64_C(0x35AE7DE0E296F8D5), - UINT64_C(0x22BD0C05541CC328), UINT64_C(0x2F4CDC59C6652A7C), - UINT64_C(0x8985E06012A66C40), UINT64_C(0x8474303C80DF8514), - UINT64_C(0x936741D93655BEE9), UINT64_C(0x9E969185A42C57BD), - UINT64_C(0xDFF438AB9ED23391), UINT64_C(0xD205E8F70CABDAC5), - UINT64_C(0xC5169912BA21E138), UINT64_C(0xC8E7494E2858086C), - UINT64_C(0x6E2E7577FC9B4E50), UINT64_C(0x63DFA52B6EE2A704), - UINT64_C(0x74CCD4CED8689CF9), UINT64_C(0x793D04924A1175AD), - UINT64_C(0xF6088693AC9455A1), UINT64_C(0xFBF956CF3EEDBCF5), - UINT64_C(0xECEA272A88678708), UINT64_C(0xE11BF7761A1E6E5C), - UINT64_C(0x47D2CB4FCEDD2860), UINT64_C(0x4A231B135CA4C134), - UINT64_C(0x5D306AF6EA2EFAC9), UINT64_C(0x50C1BAAA7857139D), - UINT64_C(0x11A3138442A977B1), UINT64_C(0x1C52C3D8D0D09EE5), - UINT64_C(0x0B41B23D665AA518), UINT64_C(0x06B06261F4234C4C), - UINT64_C(0xA0795E5820E00A70), UINT64_C(0xAD888E04B299E324), - UINT64_C(0xBA9BFFE10413D8D9), UINT64_C(0xB76A2FBD966A318D), - UINT64_C(0xA4F0FBE2C81899C1), UINT64_C(0xA9012BBE5A617095), - UINT64_C(0xBE125A5BECEB4B68), UINT64_C(0xB3E38A077E92A23C), - UINT64_C(0x152AB63EAA51E400), UINT64_C(0x18DB666238280D54), - UINT64_C(0x0FC817878EA236A9), UINT64_C(0x0239C7DB1CDBDFFD), - UINT64_C(0x435B6EF52625BBD1), UINT64_C(0x4EAABEA9B45C5285), - UINT64_C(0x59B9CF4C02D66978), UINT64_C(0x54481F1090AF802C), - UINT64_C(0xF2812329446CC610), UINT64_C(0xFF70F375D6152F44), - UINT64_C(0xE8638290609F14B9), UINT64_C(0xE59252CCF2E6FDED), - UINT64_C(0x6AA7D0CD1463DDE1), UINT64_C(0x67560091861A34B5), - UINT64_C(0x7045717430900F48), UINT64_C(0x7DB4A128A2E9E61C), - UINT64_C(0xDB7D9D11762AA020), UINT64_C(0xD68C4D4DE4534974), - UINT64_C(0xC19F3CA852D97289), UINT64_C(0xCC6EECF4C0A09BDD), - UINT64_C(0x8D0C45DAFA5EFFF1), UINT64_C(0x80FD9586682716A5), - UINT64_C(0x97EEE463DEAD2D58), UINT64_C(0x9A1F343F4CD4C40C), - UINT64_C(0x3CD6080698178230), UINT64_C(0x3127D85A0A6E6B64), - UINT64_C(0x2634A9BFBCE45099), UINT64_C(0x2BC579E32E9DB9CD), - UINT64_C(0xF5A054D6CA71FB90), UINT64_C(0xF851848A580812C4), - UINT64_C(0xEF42F56FEE822939), UINT64_C(0xE2B325337CFBC06D), - UINT64_C(0x447A190AA8388651), UINT64_C(0x498BC9563A416F05), - UINT64_C(0x5E98B8B38CCB54F8), UINT64_C(0x536968EF1EB2BDAC), - UINT64_C(0x120BC1C1244CD980), UINT64_C(0x1FFA119DB63530D4), - UINT64_C(0x08E9607800BF0B29), UINT64_C(0x0518B02492C6E27D), - UINT64_C(0xA3D18C1D4605A441), UINT64_C(0xAE205C41D47C4D15), - UINT64_C(0xB9332DA462F676E8), UINT64_C(0xB4C2FDF8F08F9FBC), - UINT64_C(0x3BF77FF9160ABFB0), UINT64_C(0x3606AFA5847356E4), - UINT64_C(0x2115DE4032F96D19), UINT64_C(0x2CE40E1CA080844D), - UINT64_C(0x8A2D32257443C271), UINT64_C(0x87DCE279E63A2B25), - UINT64_C(0x90CF939C50B010D8), UINT64_C(0x9D3E43C0C2C9F98C), - UINT64_C(0xDC5CEAEEF8379DA0), UINT64_C(0xD1AD3AB26A4E74F4), - UINT64_C(0xC6BE4B57DCC44F09), UINT64_C(0xCB4F9B0B4EBDA65D), - UINT64_C(0x6D86A7329A7EE061), UINT64_C(0x6077776E08070935), - UINT64_C(0x7764068BBE8D32C8), UINT64_C(0x7A95D6D72CF4DB9C), - UINT64_C(0x690F0288728673D0), UINT64_C(0x64FED2D4E0FF9A84), - UINT64_C(0x73EDA3315675A179), UINT64_C(0x7E1C736DC40C482D), - UINT64_C(0xD8D54F5410CF0E11), UINT64_C(0xD5249F0882B6E745), - UINT64_C(0xC237EEED343CDCB8), UINT64_C(0xCFC63EB1A64535EC), - UINT64_C(0x8EA4979F9CBB51C0), UINT64_C(0x835547C30EC2B894), - UINT64_C(0x94463626B8488369), UINT64_C(0x99B7E67A2A316A3D), - UINT64_C(0x3F7EDA43FEF22C01), UINT64_C(0x328F0A1F6C8BC555), - UINT64_C(0x259C7BFADA01FEA8), UINT64_C(0x286DABA6487817FC), - UINT64_C(0xA75829A7AEFD37F0), UINT64_C(0xAAA9F9FB3C84DEA4), - UINT64_C(0xBDBA881E8A0EE559), UINT64_C(0xB04B584218770C0D), - UINT64_C(0x1682647BCCB44A31), UINT64_C(0x1B73B4275ECDA365), - UINT64_C(0x0C60C5C2E8479898), UINT64_C(0x0191159E7A3E71CC), - UINT64_C(0x40F3BCB040C015E0), UINT64_C(0x4D026CECD2B9FCB4), - UINT64_C(0x5A111D096433C749), UINT64_C(0x57E0CD55F64A2E1D), - UINT64_C(0xF129F16C22896821), UINT64_C(0xFCD82130B0F08175), - UINT64_C(0xEBCB50D5067ABA88), UINT64_C(0xE63A8089940353DC), - UINT64_C(0xCDFFF96ABA9EEA11), UINT64_C(0xC00E293628E70345), - UINT64_C(0xD71D58D39E6D38B8), UINT64_C(0xDAEC888F0C14D1EC), - UINT64_C(0x7C25B4B6D8D797D0), UINT64_C(0x71D464EA4AAE7E84), - UINT64_C(0x66C7150FFC244579), UINT64_C(0x6B36C5536E5DAC2D), - UINT64_C(0x2A546C7D54A3C801), UINT64_C(0x27A5BC21C6DA2155), - UINT64_C(0x30B6CDC470501AA8), UINT64_C(0x3D471D98E229F3FC), - UINT64_C(0x9B8E21A136EAB5C0), UINT64_C(0x967FF1FDA4935C94), - UINT64_C(0x816C801812196769), UINT64_C(0x8C9D504480608E3D), - UINT64_C(0x03A8D24566E5AE31), UINT64_C(0x0E590219F49C4765), - UINT64_C(0x194A73FC42167C98), UINT64_C(0x14BBA3A0D06F95CC), - UINT64_C(0xB2729F9904ACD3F0), UINT64_C(0xBF834FC596D53AA4), - UINT64_C(0xA8903E20205F0159), UINT64_C(0xA561EE7CB226E80D), - UINT64_C(0xE403475288D88C21), UINT64_C(0xE9F2970E1AA16575), - UINT64_C(0xFEE1E6EBAC2B5E88), UINT64_C(0xF31036B73E52B7DC), - UINT64_C(0x55D90A8EEA91F1E0), UINT64_C(0x5828DAD278E818B4), - UINT64_C(0x4F3BAB37CE622349), UINT64_C(0x42CA7B6B5C1BCA1D), - UINT64_C(0x5150AF3402696251), UINT64_C(0x5CA17F6890108B05), - UINT64_C(0x4BB20E8D269AB0F8), UINT64_C(0x4643DED1B4E359AC), - UINT64_C(0xE08AE2E860201F90), UINT64_C(0xED7B32B4F259F6C4), - UINT64_C(0xFA68435144D3CD39), UINT64_C(0xF799930DD6AA246D), - UINT64_C(0xB6FB3A23EC544041), UINT64_C(0xBB0AEA7F7E2DA915), - UINT64_C(0xAC199B9AC8A792E8), UINT64_C(0xA1E84BC65ADE7BBC), - UINT64_C(0x072177FF8E1D3D80), UINT64_C(0x0AD0A7A31C64D4D4), - UINT64_C(0x1DC3D646AAEEEF29), UINT64_C(0x1032061A3897067D), - UINT64_C(0x9F07841BDE122671), UINT64_C(0x92F654474C6BCF25), - UINT64_C(0x85E525A2FAE1F4D8), UINT64_C(0x8814F5FE68981D8C), - UINT64_C(0x2EDDC9C7BC5B5BB0), UINT64_C(0x232C199B2E22B2E4), - UINT64_C(0x343F687E98A88919), UINT64_C(0x39CEB8220AD1604D), - UINT64_C(0x78AC110C302F0461), UINT64_C(0x755DC150A256ED35), - UINT64_C(0x624EB0B514DCD6C8), UINT64_C(0x6FBF60E986A53F9C), - UINT64_C(0xC9765CD0526679A0), UINT64_C(0xC4878C8CC01F90F4), - UINT64_C(0xD394FD697695AB09), UINT64_C(0xDE652D35E4EC425D) - }, { - UINT64_C(0x0000000000000000), UINT64_C(0xCB6D6A914AE10B3F), - UINT64_C(0x96DBD42295C2177E), UINT64_C(0x5DB6BEB3DF231C41), - UINT64_C(0x2CB7A9452A852FFC), UINT64_C(0xE7DAC3D4606424C3), - UINT64_C(0xBA6C7D67BF473882), UINT64_C(0x710117F6F5A633BD), - UINT64_C(0xDD705D247FA5876A), UINT64_C(0x161D37B535448C55), - UINT64_C(0x4BAB8906EA679014), UINT64_C(0x80C6E397A0869B2B), - UINT64_C(0xF1C7F4615520A896), UINT64_C(0x3AAA9EF01FC1A3A9), - UINT64_C(0x671C2043C0E2BFE8), UINT64_C(0xAC714AD28A03B4D7), - UINT64_C(0xBAE1BA48FE4A0FD5), UINT64_C(0x718CD0D9B4AB04EA), - UINT64_C(0x2C3A6E6A6B8818AB), UINT64_C(0xE75704FB21691394), - UINT64_C(0x9656130DD4CF2029), UINT64_C(0x5D3B799C9E2E2B16), - UINT64_C(0x008DC72F410D3757), UINT64_C(0xCBE0ADBE0BEC3C68), - UINT64_C(0x6791E76C81EF88BF), UINT64_C(0xACFC8DFDCB0E8380), - UINT64_C(0xF14A334E142D9FC1), UINT64_C(0x3A2759DF5ECC94FE), - UINT64_C(0x4B264E29AB6AA743), UINT64_C(0x804B24B8E18BAC7C), - UINT64_C(0xDDFD9A0B3EA8B03D), UINT64_C(0x1690F09A7449BB02), - UINT64_C(0xF1DD7B3ED73AC638), UINT64_C(0x3AB011AF9DDBCD07), - UINT64_C(0x6706AF1C42F8D146), UINT64_C(0xAC6BC58D0819DA79), - UINT64_C(0xDD6AD27BFDBFE9C4), UINT64_C(0x1607B8EAB75EE2FB), - UINT64_C(0x4BB10659687DFEBA), UINT64_C(0x80DC6CC8229CF585), - UINT64_C(0x2CAD261AA89F4152), UINT64_C(0xE7C04C8BE27E4A6D), - UINT64_C(0xBA76F2383D5D562C), UINT64_C(0x711B98A977BC5D13), - UINT64_C(0x001A8F5F821A6EAE), UINT64_C(0xCB77E5CEC8FB6591), - UINT64_C(0x96C15B7D17D879D0), UINT64_C(0x5DAC31EC5D3972EF), - UINT64_C(0x4B3CC1762970C9ED), UINT64_C(0x8051ABE76391C2D2), - UINT64_C(0xDDE71554BCB2DE93), UINT64_C(0x168A7FC5F653D5AC), - UINT64_C(0x678B683303F5E611), UINT64_C(0xACE602A24914ED2E), - UINT64_C(0xF150BC119637F16F), UINT64_C(0x3A3DD680DCD6FA50), - UINT64_C(0x964C9C5256D54E87), UINT64_C(0x5D21F6C31C3445B8), - UINT64_C(0x00974870C31759F9), UINT64_C(0xCBFA22E189F652C6), - UINT64_C(0xBAFB35177C50617B), UINT64_C(0x71965F8636B16A44), - UINT64_C(0x2C20E135E9927605), UINT64_C(0xE74D8BA4A3737D3A), - UINT64_C(0xE2BBF77CAE758C71), UINT64_C(0x29D69DEDE494874E), - UINT64_C(0x7460235E3BB79B0F), UINT64_C(0xBF0D49CF71569030), - UINT64_C(0xCE0C5E3984F0A38D), UINT64_C(0x056134A8CE11A8B2), - UINT64_C(0x58D78A1B1132B4F3), UINT64_C(0x93BAE08A5BD3BFCC), - UINT64_C(0x3FCBAA58D1D00B1B), UINT64_C(0xF4A6C0C99B310024), - UINT64_C(0xA9107E7A44121C65), UINT64_C(0x627D14EB0EF3175A), - UINT64_C(0x137C031DFB5524E7), UINT64_C(0xD811698CB1B42FD8), - UINT64_C(0x85A7D73F6E973399), UINT64_C(0x4ECABDAE247638A6), - UINT64_C(0x585A4D34503F83A4), UINT64_C(0x933727A51ADE889B), - UINT64_C(0xCE819916C5FD94DA), UINT64_C(0x05ECF3878F1C9FE5), - UINT64_C(0x74EDE4717ABAAC58), UINT64_C(0xBF808EE0305BA767), - UINT64_C(0xE2363053EF78BB26), UINT64_C(0x295B5AC2A599B019), - UINT64_C(0x852A10102F9A04CE), UINT64_C(0x4E477A81657B0FF1), - UINT64_C(0x13F1C432BA5813B0), UINT64_C(0xD89CAEA3F0B9188F), - UINT64_C(0xA99DB955051F2B32), UINT64_C(0x62F0D3C44FFE200D), - UINT64_C(0x3F466D7790DD3C4C), UINT64_C(0xF42B07E6DA3C3773), - UINT64_C(0x13668C42794F4A49), UINT64_C(0xD80BE6D333AE4176), - UINT64_C(0x85BD5860EC8D5D37), UINT64_C(0x4ED032F1A66C5608), - UINT64_C(0x3FD1250753CA65B5), UINT64_C(0xF4BC4F96192B6E8A), - UINT64_C(0xA90AF125C60872CB), UINT64_C(0x62679BB48CE979F4), - UINT64_C(0xCE16D16606EACD23), UINT64_C(0x057BBBF74C0BC61C), - UINT64_C(0x58CD05449328DA5D), UINT64_C(0x93A06FD5D9C9D162), - UINT64_C(0xE2A178232C6FE2DF), UINT64_C(0x29CC12B2668EE9E0), - UINT64_C(0x747AAC01B9ADF5A1), UINT64_C(0xBF17C690F34CFE9E), - UINT64_C(0xA987360A8705459C), UINT64_C(0x62EA5C9BCDE44EA3), - UINT64_C(0x3F5CE22812C752E2), UINT64_C(0xF43188B9582659DD), - UINT64_C(0x85309F4FAD806A60), UINT64_C(0x4E5DF5DEE761615F), - UINT64_C(0x13EB4B6D38427D1E), UINT64_C(0xD88621FC72A37621), - UINT64_C(0x74F76B2EF8A0C2F6), UINT64_C(0xBF9A01BFB241C9C9), - UINT64_C(0xE22CBF0C6D62D588), UINT64_C(0x2941D59D2783DEB7), - UINT64_C(0x5840C26BD225ED0A), UINT64_C(0x932DA8FA98C4E635), - UINT64_C(0xCE9B164947E7FA74), UINT64_C(0x05F67CD80D06F14B), - UINT64_C(0xC477EFF95CEB18E3), UINT64_C(0x0F1A8568160A13DC), - UINT64_C(0x52AC3BDBC9290F9D), UINT64_C(0x99C1514A83C804A2), - UINT64_C(0xE8C046BC766E371F), UINT64_C(0x23AD2C2D3C8F3C20), - UINT64_C(0x7E1B929EE3AC2061), UINT64_C(0xB576F80FA94D2B5E), - UINT64_C(0x1907B2DD234E9F89), UINT64_C(0xD26AD84C69AF94B6), - UINT64_C(0x8FDC66FFB68C88F7), UINT64_C(0x44B10C6EFC6D83C8), - UINT64_C(0x35B01B9809CBB075), UINT64_C(0xFEDD7109432ABB4A), - UINT64_C(0xA36BCFBA9C09A70B), UINT64_C(0x6806A52BD6E8AC34), - UINT64_C(0x7E9655B1A2A11736), UINT64_C(0xB5FB3F20E8401C09), - UINT64_C(0xE84D819337630048), UINT64_C(0x2320EB027D820B77), - UINT64_C(0x5221FCF4882438CA), UINT64_C(0x994C9665C2C533F5), - UINT64_C(0xC4FA28D61DE62FB4), UINT64_C(0x0F9742475707248B), - UINT64_C(0xA3E60895DD04905C), UINT64_C(0x688B620497E59B63), - UINT64_C(0x353DDCB748C68722), UINT64_C(0xFE50B62602278C1D), - UINT64_C(0x8F51A1D0F781BFA0), UINT64_C(0x443CCB41BD60B49F), - UINT64_C(0x198A75F26243A8DE), UINT64_C(0xD2E71F6328A2A3E1), - UINT64_C(0x35AA94C78BD1DEDB), UINT64_C(0xFEC7FE56C130D5E4), - UINT64_C(0xA37140E51E13C9A5), UINT64_C(0x681C2A7454F2C29A), - UINT64_C(0x191D3D82A154F127), UINT64_C(0xD2705713EBB5FA18), - UINT64_C(0x8FC6E9A03496E659), UINT64_C(0x44AB83317E77ED66), - UINT64_C(0xE8DAC9E3F47459B1), UINT64_C(0x23B7A372BE95528E), - UINT64_C(0x7E011DC161B64ECF), UINT64_C(0xB56C77502B5745F0), - UINT64_C(0xC46D60A6DEF1764D), UINT64_C(0x0F000A3794107D72), - UINT64_C(0x52B6B4844B336133), UINT64_C(0x99DBDE1501D26A0C), - UINT64_C(0x8F4B2E8F759BD10E), UINT64_C(0x4426441E3F7ADA31), - UINT64_C(0x1990FAADE059C670), UINT64_C(0xD2FD903CAAB8CD4F), - UINT64_C(0xA3FC87CA5F1EFEF2), UINT64_C(0x6891ED5B15FFF5CD), - UINT64_C(0x352753E8CADCE98C), UINT64_C(0xFE4A3979803DE2B3), - UINT64_C(0x523B73AB0A3E5664), UINT64_C(0x9956193A40DF5D5B), - UINT64_C(0xC4E0A7899FFC411A), UINT64_C(0x0F8DCD18D51D4A25), - UINT64_C(0x7E8CDAEE20BB7998), UINT64_C(0xB5E1B07F6A5A72A7), - UINT64_C(0xE8570ECCB5796EE6), UINT64_C(0x233A645DFF9865D9), - UINT64_C(0x26CC1885F29E9492), UINT64_C(0xEDA17214B87F9FAD), - UINT64_C(0xB017CCA7675C83EC), UINT64_C(0x7B7AA6362DBD88D3), - UINT64_C(0x0A7BB1C0D81BBB6E), UINT64_C(0xC116DB5192FAB051), - UINT64_C(0x9CA065E24DD9AC10), UINT64_C(0x57CD0F730738A72F), - UINT64_C(0xFBBC45A18D3B13F8), UINT64_C(0x30D12F30C7DA18C7), - UINT64_C(0x6D67918318F90486), UINT64_C(0xA60AFB1252180FB9), - UINT64_C(0xD70BECE4A7BE3C04), UINT64_C(0x1C668675ED5F373B), - UINT64_C(0x41D038C6327C2B7A), UINT64_C(0x8ABD5257789D2045), - UINT64_C(0x9C2DA2CD0CD49B47), UINT64_C(0x5740C85C46359078), - UINT64_C(0x0AF676EF99168C39), UINT64_C(0xC19B1C7ED3F78706), - UINT64_C(0xB09A0B882651B4BB), UINT64_C(0x7BF761196CB0BF84), - UINT64_C(0x2641DFAAB393A3C5), UINT64_C(0xED2CB53BF972A8FA), - UINT64_C(0x415DFFE973711C2D), UINT64_C(0x8A30957839901712), - UINT64_C(0xD7862BCBE6B30B53), UINT64_C(0x1CEB415AAC52006C), - UINT64_C(0x6DEA56AC59F433D1), UINT64_C(0xA6873C3D131538EE), - UINT64_C(0xFB31828ECC3624AF), UINT64_C(0x305CE81F86D72F90), - UINT64_C(0xD71163BB25A452AA), UINT64_C(0x1C7C092A6F455995), - UINT64_C(0x41CAB799B06645D4), UINT64_C(0x8AA7DD08FA874EEB), - UINT64_C(0xFBA6CAFE0F217D56), UINT64_C(0x30CBA06F45C07669), - UINT64_C(0x6D7D1EDC9AE36A28), UINT64_C(0xA610744DD0026117), - UINT64_C(0x0A613E9F5A01D5C0), UINT64_C(0xC10C540E10E0DEFF), - UINT64_C(0x9CBAEABDCFC3C2BE), UINT64_C(0x57D7802C8522C981), - UINT64_C(0x26D697DA7084FA3C), UINT64_C(0xEDBBFD4B3A65F103), - UINT64_C(0xB00D43F8E546ED42), UINT64_C(0x7B602969AFA7E67D), - UINT64_C(0x6DF0D9F3DBEE5D7F), UINT64_C(0xA69DB362910F5640), - UINT64_C(0xFB2B0DD14E2C4A01), UINT64_C(0x3046674004CD413E), - UINT64_C(0x414770B6F16B7283), UINT64_C(0x8A2A1A27BB8A79BC), - UINT64_C(0xD79CA49464A965FD), UINT64_C(0x1CF1CE052E486EC2), - UINT64_C(0xB08084D7A44BDA15), UINT64_C(0x7BEDEE46EEAAD12A), - UINT64_C(0x265B50F53189CD6B), UINT64_C(0xED363A647B68C654), - UINT64_C(0x9C372D928ECEF5E9), UINT64_C(0x575A4703C42FFED6), - UINT64_C(0x0AECF9B01B0CE297), UINT64_C(0xC181932151EDE9A8) - }, { - UINT64_C(0x0000000000000000), UINT64_C(0xDCA12C225E8AEE1D), - UINT64_C(0xB8435944BC14DD3B), UINT64_C(0x64E27566E29E3326), - UINT64_C(0x7087B2887829BA77), UINT64_C(0xAC269EAA26A3546A), - UINT64_C(0xC8C4EBCCC43D674C), UINT64_C(0x1465C7EE9AB78951), - UINT64_C(0xE00E6511F15274EF), UINT64_C(0x3CAF4933AFD89AF2), - UINT64_C(0x584D3C554D46A9D4), UINT64_C(0x84EC107713CC47C9), - UINT64_C(0x9089D799897BCE98), UINT64_C(0x4C28FBBBD7F12085), - UINT64_C(0x28CA8EDD356F13A3), UINT64_C(0xF46BA2FF6BE5FDBE), - UINT64_C(0x4503C48DC90A304C), UINT64_C(0x99A2E8AF9780DE51), - UINT64_C(0xFD409DC9751EED77), UINT64_C(0x21E1B1EB2B94036A), - UINT64_C(0x35847605B1238A3B), UINT64_C(0xE9255A27EFA96426), - UINT64_C(0x8DC72F410D375700), UINT64_C(0x5166036353BDB91D), - UINT64_C(0xA50DA19C385844A3), UINT64_C(0x79AC8DBE66D2AABE), - UINT64_C(0x1D4EF8D8844C9998), UINT64_C(0xC1EFD4FADAC67785), - UINT64_C(0xD58A13144071FED4), UINT64_C(0x092B3F361EFB10C9), - UINT64_C(0x6DC94A50FC6523EF), UINT64_C(0xB1686672A2EFCDF2), - UINT64_C(0x8A06881B93156098), UINT64_C(0x56A7A439CD9F8E85), - UINT64_C(0x3245D15F2F01BDA3), UINT64_C(0xEEE4FD7D718B53BE), - UINT64_C(0xFA813A93EB3CDAEF), UINT64_C(0x262016B1B5B634F2), - UINT64_C(0x42C263D7572807D4), UINT64_C(0x9E634FF509A2E9C9), - UINT64_C(0x6A08ED0A62471477), UINT64_C(0xB6A9C1283CCDFA6A), - UINT64_C(0xD24BB44EDE53C94C), UINT64_C(0x0EEA986C80D92751), - UINT64_C(0x1A8F5F821A6EAE00), UINT64_C(0xC62E73A044E4401D), - UINT64_C(0xA2CC06C6A67A733B), UINT64_C(0x7E6D2AE4F8F09D26), - UINT64_C(0xCF054C965A1F50D4), UINT64_C(0x13A460B40495BEC9), - UINT64_C(0x774615D2E60B8DEF), UINT64_C(0xABE739F0B88163F2), - UINT64_C(0xBF82FE1E2236EAA3), UINT64_C(0x6323D23C7CBC04BE), - UINT64_C(0x07C1A75A9E223798), UINT64_C(0xDB608B78C0A8D985), - UINT64_C(0x2F0B2987AB4D243B), UINT64_C(0xF3AA05A5F5C7CA26), - UINT64_C(0x974870C31759F900), UINT64_C(0x4BE95CE149D3171D), - UINT64_C(0x5F8C9B0FD3649E4C), UINT64_C(0x832DB72D8DEE7051), - UINT64_C(0xE7CFC24B6F704377), UINT64_C(0x3B6EEE6931FAAD6A), - UINT64_C(0x91131E980D8418A2), UINT64_C(0x4DB232BA530EF6BF), - UINT64_C(0x295047DCB190C599), UINT64_C(0xF5F16BFEEF1A2B84), - UINT64_C(0xE194AC1075ADA2D5), UINT64_C(0x3D3580322B274CC8), - UINT64_C(0x59D7F554C9B97FEE), UINT64_C(0x8576D976973391F3), - UINT64_C(0x711D7B89FCD66C4D), UINT64_C(0xADBC57ABA25C8250), - UINT64_C(0xC95E22CD40C2B176), UINT64_C(0x15FF0EEF1E485F6B), - UINT64_C(0x019AC90184FFD63A), UINT64_C(0xDD3BE523DA753827), - UINT64_C(0xB9D9904538EB0B01), UINT64_C(0x6578BC676661E51C), - UINT64_C(0xD410DA15C48E28EE), UINT64_C(0x08B1F6379A04C6F3), - UINT64_C(0x6C538351789AF5D5), UINT64_C(0xB0F2AF7326101BC8), - UINT64_C(0xA497689DBCA79299), UINT64_C(0x783644BFE22D7C84), - UINT64_C(0x1CD431D900B34FA2), UINT64_C(0xC0751DFB5E39A1BF), - UINT64_C(0x341EBF0435DC5C01), UINT64_C(0xE8BF93266B56B21C), - UINT64_C(0x8C5DE64089C8813A), UINT64_C(0x50FCCA62D7426F27), - UINT64_C(0x44990D8C4DF5E676), UINT64_C(0x983821AE137F086B), - UINT64_C(0xFCDA54C8F1E13B4D), UINT64_C(0x207B78EAAF6BD550), - UINT64_C(0x1B1596839E91783A), UINT64_C(0xC7B4BAA1C01B9627), - UINT64_C(0xA356CFC72285A501), UINT64_C(0x7FF7E3E57C0F4B1C), - UINT64_C(0x6B92240BE6B8C24D), UINT64_C(0xB7330829B8322C50), - UINT64_C(0xD3D17D4F5AAC1F76), UINT64_C(0x0F70516D0426F16B), - UINT64_C(0xFB1BF3926FC30CD5), UINT64_C(0x27BADFB03149E2C8), - UINT64_C(0x4358AAD6D3D7D1EE), UINT64_C(0x9FF986F48D5D3FF3), - UINT64_C(0x8B9C411A17EAB6A2), UINT64_C(0x573D6D38496058BF), - UINT64_C(0x33DF185EABFE6B99), UINT64_C(0xEF7E347CF5748584), - UINT64_C(0x5E16520E579B4876), UINT64_C(0x82B77E2C0911A66B), - UINT64_C(0xE6550B4AEB8F954D), UINT64_C(0x3AF42768B5057B50), - UINT64_C(0x2E91E0862FB2F201), UINT64_C(0xF230CCA471381C1C), - UINT64_C(0x96D2B9C293A62F3A), UINT64_C(0x4A7395E0CD2CC127), - UINT64_C(0xBE18371FA6C93C99), UINT64_C(0x62B91B3DF843D284), - UINT64_C(0x065B6E5B1ADDE1A2), UINT64_C(0xDAFA427944570FBF), - UINT64_C(0xCE9F8597DEE086EE), UINT64_C(0x123EA9B5806A68F3), - UINT64_C(0x76DCDCD362F45BD5), UINT64_C(0xAA7DF0F13C7EB5C8), - UINT64_C(0xA739329F30A7E9D6), UINT64_C(0x7B981EBD6E2D07CB), - UINT64_C(0x1F7A6BDB8CB334ED), UINT64_C(0xC3DB47F9D239DAF0), - UINT64_C(0xD7BE8017488E53A1), UINT64_C(0x0B1FAC351604BDBC), - UINT64_C(0x6FFDD953F49A8E9A), UINT64_C(0xB35CF571AA106087), - UINT64_C(0x4737578EC1F59D39), UINT64_C(0x9B967BAC9F7F7324), - UINT64_C(0xFF740ECA7DE14002), UINT64_C(0x23D522E8236BAE1F), - UINT64_C(0x37B0E506B9DC274E), UINT64_C(0xEB11C924E756C953), - UINT64_C(0x8FF3BC4205C8FA75), UINT64_C(0x535290605B421468), - UINT64_C(0xE23AF612F9ADD99A), UINT64_C(0x3E9BDA30A7273787), - UINT64_C(0x5A79AF5645B904A1), UINT64_C(0x86D883741B33EABC), - UINT64_C(0x92BD449A818463ED), UINT64_C(0x4E1C68B8DF0E8DF0), - UINT64_C(0x2AFE1DDE3D90BED6), UINT64_C(0xF65F31FC631A50CB), - UINT64_C(0x0234930308FFAD75), UINT64_C(0xDE95BF2156754368), - UINT64_C(0xBA77CA47B4EB704E), UINT64_C(0x66D6E665EA619E53), - UINT64_C(0x72B3218B70D61702), UINT64_C(0xAE120DA92E5CF91F), - UINT64_C(0xCAF078CFCCC2CA39), UINT64_C(0x165154ED92482424), - UINT64_C(0x2D3FBA84A3B2894E), UINT64_C(0xF19E96A6FD386753), - UINT64_C(0x957CE3C01FA65475), UINT64_C(0x49DDCFE2412CBA68), - UINT64_C(0x5DB8080CDB9B3339), UINT64_C(0x8119242E8511DD24), - UINT64_C(0xE5FB5148678FEE02), UINT64_C(0x395A7D6A3905001F), - UINT64_C(0xCD31DF9552E0FDA1), UINT64_C(0x1190F3B70C6A13BC), - UINT64_C(0x757286D1EEF4209A), UINT64_C(0xA9D3AAF3B07ECE87), - UINT64_C(0xBDB66D1D2AC947D6), UINT64_C(0x6117413F7443A9CB), - UINT64_C(0x05F5345996DD9AED), UINT64_C(0xD954187BC85774F0), - UINT64_C(0x683C7E096AB8B902), UINT64_C(0xB49D522B3432571F), - UINT64_C(0xD07F274DD6AC6439), UINT64_C(0x0CDE0B6F88268A24), - UINT64_C(0x18BBCC8112910375), UINT64_C(0xC41AE0A34C1BED68), - UINT64_C(0xA0F895C5AE85DE4E), UINT64_C(0x7C59B9E7F00F3053), - UINT64_C(0x88321B189BEACDED), UINT64_C(0x5493373AC56023F0), - UINT64_C(0x3071425C27FE10D6), UINT64_C(0xECD06E7E7974FECB), - UINT64_C(0xF8B5A990E3C3779A), UINT64_C(0x241485B2BD499987), - UINT64_C(0x40F6F0D45FD7AAA1), UINT64_C(0x9C57DCF6015D44BC), - UINT64_C(0x362A2C073D23F174), UINT64_C(0xEA8B002563A91F69), - UINT64_C(0x8E69754381372C4F), UINT64_C(0x52C85961DFBDC252), - UINT64_C(0x46AD9E8F450A4B03), UINT64_C(0x9A0CB2AD1B80A51E), - UINT64_C(0xFEEEC7CBF91E9638), UINT64_C(0x224FEBE9A7947825), - UINT64_C(0xD6244916CC71859B), UINT64_C(0x0A85653492FB6B86), - UINT64_C(0x6E671052706558A0), UINT64_C(0xB2C63C702EEFB6BD), - UINT64_C(0xA6A3FB9EB4583FEC), UINT64_C(0x7A02D7BCEAD2D1F1), - UINT64_C(0x1EE0A2DA084CE2D7), UINT64_C(0xC2418EF856C60CCA), - UINT64_C(0x7329E88AF429C138), UINT64_C(0xAF88C4A8AAA32F25), - UINT64_C(0xCB6AB1CE483D1C03), UINT64_C(0x17CB9DEC16B7F21E), - UINT64_C(0x03AE5A028C007B4F), UINT64_C(0xDF0F7620D28A9552), - UINT64_C(0xBBED03463014A674), UINT64_C(0x674C2F646E9E4869), - UINT64_C(0x93278D9B057BB5D7), UINT64_C(0x4F86A1B95BF15BCA), - UINT64_C(0x2B64D4DFB96F68EC), UINT64_C(0xF7C5F8FDE7E586F1), - UINT64_C(0xE3A03F137D520FA0), UINT64_C(0x3F01133123D8E1BD), - UINT64_C(0x5BE36657C146D29B), UINT64_C(0x87424A759FCC3C86), - UINT64_C(0xBC2CA41CAE3691EC), UINT64_C(0x608D883EF0BC7FF1), - UINT64_C(0x046FFD5812224CD7), UINT64_C(0xD8CED17A4CA8A2CA), - UINT64_C(0xCCAB1694D61F2B9B), UINT64_C(0x100A3AB68895C586), - UINT64_C(0x74E84FD06A0BF6A0), UINT64_C(0xA84963F2348118BD), - UINT64_C(0x5C22C10D5F64E503), UINT64_C(0x8083ED2F01EE0B1E), - UINT64_C(0xE4619849E3703838), UINT64_C(0x38C0B46BBDFAD625), - UINT64_C(0x2CA57385274D5F74), UINT64_C(0xF0045FA779C7B169), - UINT64_C(0x94E62AC19B59824F), UINT64_C(0x484706E3C5D36C52), - UINT64_C(0xF92F6091673CA1A0), UINT64_C(0x258E4CB339B64FBD), - UINT64_C(0x416C39D5DB287C9B), UINT64_C(0x9DCD15F785A29286), - UINT64_C(0x89A8D2191F151BD7), UINT64_C(0x5509FE3B419FF5CA), - UINT64_C(0x31EB8B5DA301C6EC), UINT64_C(0xED4AA77FFD8B28F1), - UINT64_C(0x19210580966ED54F), UINT64_C(0xC58029A2C8E43B52), - UINT64_C(0xA1625CC42A7A0874), UINT64_C(0x7DC370E674F0E669), - UINT64_C(0x69A6B708EE476F38), UINT64_C(0xB5079B2AB0CD8125), - UINT64_C(0xD1E5EE4C5253B203), UINT64_C(0x0D44C26E0CD95C1E) - } -}; diff --git a/deps/lzma/liblzma/check/crc64_table_le.h b/deps/lzma/liblzma/check/crc64_table_le.h deleted file mode 100644 index 1196b31..0000000 --- a/deps/lzma/liblzma/check/crc64_table_le.h +++ /dev/null @@ -1,521 +0,0 @@ -/* This file has been automatically generated by crc64_tablegen.c. */ - -const uint64_t lzma_crc64_table[4][256] = { - { - UINT64_C(0x0000000000000000), UINT64_C(0xB32E4CBE03A75F6F), - UINT64_C(0xF4843657A840A05B), UINT64_C(0x47AA7AE9ABE7FF34), - UINT64_C(0x7BD0C384FF8F5E33), UINT64_C(0xC8FE8F3AFC28015C), - UINT64_C(0x8F54F5D357CFFE68), UINT64_C(0x3C7AB96D5468A107), - UINT64_C(0xF7A18709FF1EBC66), UINT64_C(0x448FCBB7FCB9E309), - UINT64_C(0x0325B15E575E1C3D), UINT64_C(0xB00BFDE054F94352), - UINT64_C(0x8C71448D0091E255), UINT64_C(0x3F5F08330336BD3A), - UINT64_C(0x78F572DAA8D1420E), UINT64_C(0xCBDB3E64AB761D61), - UINT64_C(0x7D9BA13851336649), UINT64_C(0xCEB5ED8652943926), - UINT64_C(0x891F976FF973C612), UINT64_C(0x3A31DBD1FAD4997D), - UINT64_C(0x064B62BCAEBC387A), UINT64_C(0xB5652E02AD1B6715), - UINT64_C(0xF2CF54EB06FC9821), UINT64_C(0x41E11855055BC74E), - UINT64_C(0x8A3A2631AE2DDA2F), UINT64_C(0x39146A8FAD8A8540), - UINT64_C(0x7EBE1066066D7A74), UINT64_C(0xCD905CD805CA251B), - UINT64_C(0xF1EAE5B551A2841C), UINT64_C(0x42C4A90B5205DB73), - UINT64_C(0x056ED3E2F9E22447), UINT64_C(0xB6409F5CFA457B28), - UINT64_C(0xFB374270A266CC92), UINT64_C(0x48190ECEA1C193FD), - UINT64_C(0x0FB374270A266CC9), UINT64_C(0xBC9D3899098133A6), - UINT64_C(0x80E781F45DE992A1), UINT64_C(0x33C9CD4A5E4ECDCE), - UINT64_C(0x7463B7A3F5A932FA), UINT64_C(0xC74DFB1DF60E6D95), - UINT64_C(0x0C96C5795D7870F4), UINT64_C(0xBFB889C75EDF2F9B), - UINT64_C(0xF812F32EF538D0AF), UINT64_C(0x4B3CBF90F69F8FC0), - UINT64_C(0x774606FDA2F72EC7), UINT64_C(0xC4684A43A15071A8), - UINT64_C(0x83C230AA0AB78E9C), UINT64_C(0x30EC7C140910D1F3), - UINT64_C(0x86ACE348F355AADB), UINT64_C(0x3582AFF6F0F2F5B4), - UINT64_C(0x7228D51F5B150A80), UINT64_C(0xC10699A158B255EF), - UINT64_C(0xFD7C20CC0CDAF4E8), UINT64_C(0x4E526C720F7DAB87), - UINT64_C(0x09F8169BA49A54B3), UINT64_C(0xBAD65A25A73D0BDC), - UINT64_C(0x710D64410C4B16BD), UINT64_C(0xC22328FF0FEC49D2), - UINT64_C(0x85895216A40BB6E6), UINT64_C(0x36A71EA8A7ACE989), - UINT64_C(0x0ADDA7C5F3C4488E), UINT64_C(0xB9F3EB7BF06317E1), - UINT64_C(0xFE5991925B84E8D5), UINT64_C(0x4D77DD2C5823B7BA), - UINT64_C(0x64B62BCAEBC387A1), UINT64_C(0xD7986774E864D8CE), - UINT64_C(0x90321D9D438327FA), UINT64_C(0x231C512340247895), - UINT64_C(0x1F66E84E144CD992), UINT64_C(0xAC48A4F017EB86FD), - UINT64_C(0xEBE2DE19BC0C79C9), UINT64_C(0x58CC92A7BFAB26A6), - UINT64_C(0x9317ACC314DD3BC7), UINT64_C(0x2039E07D177A64A8), - UINT64_C(0x67939A94BC9D9B9C), UINT64_C(0xD4BDD62ABF3AC4F3), - UINT64_C(0xE8C76F47EB5265F4), UINT64_C(0x5BE923F9E8F53A9B), - UINT64_C(0x1C4359104312C5AF), UINT64_C(0xAF6D15AE40B59AC0), - UINT64_C(0x192D8AF2BAF0E1E8), UINT64_C(0xAA03C64CB957BE87), - UINT64_C(0xEDA9BCA512B041B3), UINT64_C(0x5E87F01B11171EDC), - UINT64_C(0x62FD4976457FBFDB), UINT64_C(0xD1D305C846D8E0B4), - UINT64_C(0x96797F21ED3F1F80), UINT64_C(0x2557339FEE9840EF), - UINT64_C(0xEE8C0DFB45EE5D8E), UINT64_C(0x5DA24145464902E1), - UINT64_C(0x1A083BACEDAEFDD5), UINT64_C(0xA9267712EE09A2BA), - UINT64_C(0x955CCE7FBA6103BD), UINT64_C(0x267282C1B9C65CD2), - UINT64_C(0x61D8F8281221A3E6), UINT64_C(0xD2F6B4961186FC89), - UINT64_C(0x9F8169BA49A54B33), UINT64_C(0x2CAF25044A02145C), - UINT64_C(0x6B055FEDE1E5EB68), UINT64_C(0xD82B1353E242B407), - UINT64_C(0xE451AA3EB62A1500), UINT64_C(0x577FE680B58D4A6F), - UINT64_C(0x10D59C691E6AB55B), UINT64_C(0xA3FBD0D71DCDEA34), - UINT64_C(0x6820EEB3B6BBF755), UINT64_C(0xDB0EA20DB51CA83A), - UINT64_C(0x9CA4D8E41EFB570E), UINT64_C(0x2F8A945A1D5C0861), - UINT64_C(0x13F02D374934A966), UINT64_C(0xA0DE61894A93F609), - UINT64_C(0xE7741B60E174093D), UINT64_C(0x545A57DEE2D35652), - UINT64_C(0xE21AC88218962D7A), UINT64_C(0x5134843C1B317215), - UINT64_C(0x169EFED5B0D68D21), UINT64_C(0xA5B0B26BB371D24E), - UINT64_C(0x99CA0B06E7197349), UINT64_C(0x2AE447B8E4BE2C26), - UINT64_C(0x6D4E3D514F59D312), UINT64_C(0xDE6071EF4CFE8C7D), - UINT64_C(0x15BB4F8BE788911C), UINT64_C(0xA6950335E42FCE73), - UINT64_C(0xE13F79DC4FC83147), UINT64_C(0x521135624C6F6E28), - UINT64_C(0x6E6B8C0F1807CF2F), UINT64_C(0xDD45C0B11BA09040), - UINT64_C(0x9AEFBA58B0476F74), UINT64_C(0x29C1F6E6B3E0301B), - UINT64_C(0xC96C5795D7870F42), UINT64_C(0x7A421B2BD420502D), - UINT64_C(0x3DE861C27FC7AF19), UINT64_C(0x8EC62D7C7C60F076), - UINT64_C(0xB2BC941128085171), UINT64_C(0x0192D8AF2BAF0E1E), - UINT64_C(0x4638A2468048F12A), UINT64_C(0xF516EEF883EFAE45), - UINT64_C(0x3ECDD09C2899B324), UINT64_C(0x8DE39C222B3EEC4B), - UINT64_C(0xCA49E6CB80D9137F), UINT64_C(0x7967AA75837E4C10), - UINT64_C(0x451D1318D716ED17), UINT64_C(0xF6335FA6D4B1B278), - UINT64_C(0xB199254F7F564D4C), UINT64_C(0x02B769F17CF11223), - UINT64_C(0xB4F7F6AD86B4690B), UINT64_C(0x07D9BA1385133664), - UINT64_C(0x4073C0FA2EF4C950), UINT64_C(0xF35D8C442D53963F), - UINT64_C(0xCF273529793B3738), UINT64_C(0x7C0979977A9C6857), - UINT64_C(0x3BA3037ED17B9763), UINT64_C(0x888D4FC0D2DCC80C), - UINT64_C(0x435671A479AAD56D), UINT64_C(0xF0783D1A7A0D8A02), - UINT64_C(0xB7D247F3D1EA7536), UINT64_C(0x04FC0B4DD24D2A59), - UINT64_C(0x3886B22086258B5E), UINT64_C(0x8BA8FE9E8582D431), - UINT64_C(0xCC0284772E652B05), UINT64_C(0x7F2CC8C92DC2746A), - UINT64_C(0x325B15E575E1C3D0), UINT64_C(0x8175595B76469CBF), - UINT64_C(0xC6DF23B2DDA1638B), UINT64_C(0x75F16F0CDE063CE4), - UINT64_C(0x498BD6618A6E9DE3), UINT64_C(0xFAA59ADF89C9C28C), - UINT64_C(0xBD0FE036222E3DB8), UINT64_C(0x0E21AC88218962D7), - UINT64_C(0xC5FA92EC8AFF7FB6), UINT64_C(0x76D4DE52895820D9), - UINT64_C(0x317EA4BB22BFDFED), UINT64_C(0x8250E80521188082), - UINT64_C(0xBE2A516875702185), UINT64_C(0x0D041DD676D77EEA), - UINT64_C(0x4AAE673FDD3081DE), UINT64_C(0xF9802B81DE97DEB1), - UINT64_C(0x4FC0B4DD24D2A599), UINT64_C(0xFCEEF8632775FAF6), - UINT64_C(0xBB44828A8C9205C2), UINT64_C(0x086ACE348F355AAD), - UINT64_C(0x34107759DB5DFBAA), UINT64_C(0x873E3BE7D8FAA4C5), - UINT64_C(0xC094410E731D5BF1), UINT64_C(0x73BA0DB070BA049E), - UINT64_C(0xB86133D4DBCC19FF), UINT64_C(0x0B4F7F6AD86B4690), - UINT64_C(0x4CE50583738CB9A4), UINT64_C(0xFFCB493D702BE6CB), - UINT64_C(0xC3B1F050244347CC), UINT64_C(0x709FBCEE27E418A3), - UINT64_C(0x3735C6078C03E797), UINT64_C(0x841B8AB98FA4B8F8), - UINT64_C(0xADDA7C5F3C4488E3), UINT64_C(0x1EF430E13FE3D78C), - UINT64_C(0x595E4A08940428B8), UINT64_C(0xEA7006B697A377D7), - UINT64_C(0xD60ABFDBC3CBD6D0), UINT64_C(0x6524F365C06C89BF), - UINT64_C(0x228E898C6B8B768B), UINT64_C(0x91A0C532682C29E4), - UINT64_C(0x5A7BFB56C35A3485), UINT64_C(0xE955B7E8C0FD6BEA), - UINT64_C(0xAEFFCD016B1A94DE), UINT64_C(0x1DD181BF68BDCBB1), - UINT64_C(0x21AB38D23CD56AB6), UINT64_C(0x9285746C3F7235D9), - UINT64_C(0xD52F0E859495CAED), UINT64_C(0x6601423B97329582), - UINT64_C(0xD041DD676D77EEAA), UINT64_C(0x636F91D96ED0B1C5), - UINT64_C(0x24C5EB30C5374EF1), UINT64_C(0x97EBA78EC690119E), - UINT64_C(0xAB911EE392F8B099), UINT64_C(0x18BF525D915FEFF6), - UINT64_C(0x5F1528B43AB810C2), UINT64_C(0xEC3B640A391F4FAD), - UINT64_C(0x27E05A6E926952CC), UINT64_C(0x94CE16D091CE0DA3), - UINT64_C(0xD3646C393A29F297), UINT64_C(0x604A2087398EADF8), - UINT64_C(0x5C3099EA6DE60CFF), UINT64_C(0xEF1ED5546E415390), - UINT64_C(0xA8B4AFBDC5A6ACA4), UINT64_C(0x1B9AE303C601F3CB), - UINT64_C(0x56ED3E2F9E224471), UINT64_C(0xE5C372919D851B1E), - UINT64_C(0xA26908783662E42A), UINT64_C(0x114744C635C5BB45), - UINT64_C(0x2D3DFDAB61AD1A42), UINT64_C(0x9E13B115620A452D), - UINT64_C(0xD9B9CBFCC9EDBA19), UINT64_C(0x6A978742CA4AE576), - UINT64_C(0xA14CB926613CF817), UINT64_C(0x1262F598629BA778), - UINT64_C(0x55C88F71C97C584C), UINT64_C(0xE6E6C3CFCADB0723), - UINT64_C(0xDA9C7AA29EB3A624), UINT64_C(0x69B2361C9D14F94B), - UINT64_C(0x2E184CF536F3067F), UINT64_C(0x9D36004B35545910), - UINT64_C(0x2B769F17CF112238), UINT64_C(0x9858D3A9CCB67D57), - UINT64_C(0xDFF2A94067518263), UINT64_C(0x6CDCE5FE64F6DD0C), - UINT64_C(0x50A65C93309E7C0B), UINT64_C(0xE388102D33392364), - UINT64_C(0xA4226AC498DEDC50), UINT64_C(0x170C267A9B79833F), - UINT64_C(0xDCD7181E300F9E5E), UINT64_C(0x6FF954A033A8C131), - UINT64_C(0x28532E49984F3E05), UINT64_C(0x9B7D62F79BE8616A), - UINT64_C(0xA707DB9ACF80C06D), UINT64_C(0x14299724CC279F02), - UINT64_C(0x5383EDCD67C06036), UINT64_C(0xE0ADA17364673F59) - }, { - UINT64_C(0x0000000000000000), UINT64_C(0x54E979925CD0F10D), - UINT64_C(0xA9D2F324B9A1E21A), UINT64_C(0xFD3B8AB6E5711317), - UINT64_C(0xC17D4962DC4DDAB1), UINT64_C(0x959430F0809D2BBC), - UINT64_C(0x68AFBA4665EC38AB), UINT64_C(0x3C46C3D4393CC9A6), - UINT64_C(0x10223DEE1795ABE7), UINT64_C(0x44CB447C4B455AEA), - UINT64_C(0xB9F0CECAAE3449FD), UINT64_C(0xED19B758F2E4B8F0), - UINT64_C(0xD15F748CCBD87156), UINT64_C(0x85B60D1E9708805B), - UINT64_C(0x788D87A87279934C), UINT64_C(0x2C64FE3A2EA96241), - UINT64_C(0x20447BDC2F2B57CE), UINT64_C(0x74AD024E73FBA6C3), - UINT64_C(0x899688F8968AB5D4), UINT64_C(0xDD7FF16ACA5A44D9), - UINT64_C(0xE13932BEF3668D7F), UINT64_C(0xB5D04B2CAFB67C72), - UINT64_C(0x48EBC19A4AC76F65), UINT64_C(0x1C02B80816179E68), - UINT64_C(0x3066463238BEFC29), UINT64_C(0x648F3FA0646E0D24), - UINT64_C(0x99B4B516811F1E33), UINT64_C(0xCD5DCC84DDCFEF3E), - UINT64_C(0xF11B0F50E4F32698), UINT64_C(0xA5F276C2B823D795), - UINT64_C(0x58C9FC745D52C482), UINT64_C(0x0C2085E60182358F), - UINT64_C(0x4088F7B85E56AF9C), UINT64_C(0x14618E2A02865E91), - UINT64_C(0xE95A049CE7F74D86), UINT64_C(0xBDB37D0EBB27BC8B), - UINT64_C(0x81F5BEDA821B752D), UINT64_C(0xD51CC748DECB8420), - UINT64_C(0x28274DFE3BBA9737), UINT64_C(0x7CCE346C676A663A), - UINT64_C(0x50AACA5649C3047B), UINT64_C(0x0443B3C41513F576), - UINT64_C(0xF9783972F062E661), UINT64_C(0xAD9140E0ACB2176C), - UINT64_C(0x91D78334958EDECA), UINT64_C(0xC53EFAA6C95E2FC7), - UINT64_C(0x380570102C2F3CD0), UINT64_C(0x6CEC098270FFCDDD), - UINT64_C(0x60CC8C64717DF852), UINT64_C(0x3425F5F62DAD095F), - UINT64_C(0xC91E7F40C8DC1A48), UINT64_C(0x9DF706D2940CEB45), - UINT64_C(0xA1B1C506AD3022E3), UINT64_C(0xF558BC94F1E0D3EE), - UINT64_C(0x086336221491C0F9), UINT64_C(0x5C8A4FB0484131F4), - UINT64_C(0x70EEB18A66E853B5), UINT64_C(0x2407C8183A38A2B8), - UINT64_C(0xD93C42AEDF49B1AF), UINT64_C(0x8DD53B3C839940A2), - UINT64_C(0xB193F8E8BAA58904), UINT64_C(0xE57A817AE6757809), - UINT64_C(0x18410BCC03046B1E), UINT64_C(0x4CA8725E5FD49A13), - UINT64_C(0x8111EF70BCAD5F38), UINT64_C(0xD5F896E2E07DAE35), - UINT64_C(0x28C31C54050CBD22), UINT64_C(0x7C2A65C659DC4C2F), - UINT64_C(0x406CA61260E08589), UINT64_C(0x1485DF803C307484), - UINT64_C(0xE9BE5536D9416793), UINT64_C(0xBD572CA48591969E), - UINT64_C(0x9133D29EAB38F4DF), UINT64_C(0xC5DAAB0CF7E805D2), - UINT64_C(0x38E121BA129916C5), UINT64_C(0x6C0858284E49E7C8), - UINT64_C(0x504E9BFC77752E6E), UINT64_C(0x04A7E26E2BA5DF63), - UINT64_C(0xF99C68D8CED4CC74), UINT64_C(0xAD75114A92043D79), - UINT64_C(0xA15594AC938608F6), UINT64_C(0xF5BCED3ECF56F9FB), - UINT64_C(0x088767882A27EAEC), UINT64_C(0x5C6E1E1A76F71BE1), - UINT64_C(0x6028DDCE4FCBD247), UINT64_C(0x34C1A45C131B234A), - UINT64_C(0xC9FA2EEAF66A305D), UINT64_C(0x9D135778AABAC150), - UINT64_C(0xB177A9428413A311), UINT64_C(0xE59ED0D0D8C3521C), - UINT64_C(0x18A55A663DB2410B), UINT64_C(0x4C4C23F46162B006), - UINT64_C(0x700AE020585E79A0), UINT64_C(0x24E399B2048E88AD), - UINT64_C(0xD9D81304E1FF9BBA), UINT64_C(0x8D316A96BD2F6AB7), - UINT64_C(0xC19918C8E2FBF0A4), UINT64_C(0x9570615ABE2B01A9), - UINT64_C(0x684BEBEC5B5A12BE), UINT64_C(0x3CA2927E078AE3B3), - UINT64_C(0x00E451AA3EB62A15), UINT64_C(0x540D28386266DB18), - UINT64_C(0xA936A28E8717C80F), UINT64_C(0xFDDFDB1CDBC73902), - UINT64_C(0xD1BB2526F56E5B43), UINT64_C(0x85525CB4A9BEAA4E), - UINT64_C(0x7869D6024CCFB959), UINT64_C(0x2C80AF90101F4854), - UINT64_C(0x10C66C44292381F2), UINT64_C(0x442F15D675F370FF), - UINT64_C(0xB9149F60908263E8), UINT64_C(0xEDFDE6F2CC5292E5), - UINT64_C(0xE1DD6314CDD0A76A), UINT64_C(0xB5341A8691005667), - UINT64_C(0x480F903074714570), UINT64_C(0x1CE6E9A228A1B47D), - UINT64_C(0x20A02A76119D7DDB), UINT64_C(0x744953E44D4D8CD6), - UINT64_C(0x8972D952A83C9FC1), UINT64_C(0xDD9BA0C0F4EC6ECC), - UINT64_C(0xF1FF5EFADA450C8D), UINT64_C(0xA51627688695FD80), - UINT64_C(0x582DADDE63E4EE97), UINT64_C(0x0CC4D44C3F341F9A), - UINT64_C(0x308217980608D63C), UINT64_C(0x646B6E0A5AD82731), - UINT64_C(0x9950E4BCBFA93426), UINT64_C(0xCDB99D2EE379C52B), - UINT64_C(0x90FB71CAD654A0F5), UINT64_C(0xC41208588A8451F8), - UINT64_C(0x392982EE6FF542EF), UINT64_C(0x6DC0FB7C3325B3E2), - UINT64_C(0x518638A80A197A44), UINT64_C(0x056F413A56C98B49), - UINT64_C(0xF854CB8CB3B8985E), UINT64_C(0xACBDB21EEF686953), - UINT64_C(0x80D94C24C1C10B12), UINT64_C(0xD43035B69D11FA1F), - UINT64_C(0x290BBF007860E908), UINT64_C(0x7DE2C69224B01805), - UINT64_C(0x41A405461D8CD1A3), UINT64_C(0x154D7CD4415C20AE), - UINT64_C(0xE876F662A42D33B9), UINT64_C(0xBC9F8FF0F8FDC2B4), - UINT64_C(0xB0BF0A16F97FF73B), UINT64_C(0xE4567384A5AF0636), - UINT64_C(0x196DF93240DE1521), UINT64_C(0x4D8480A01C0EE42C), - UINT64_C(0x71C2437425322D8A), UINT64_C(0x252B3AE679E2DC87), - UINT64_C(0xD810B0509C93CF90), UINT64_C(0x8CF9C9C2C0433E9D), - UINT64_C(0xA09D37F8EEEA5CDC), UINT64_C(0xF4744E6AB23AADD1), - UINT64_C(0x094FC4DC574BBEC6), UINT64_C(0x5DA6BD4E0B9B4FCB), - UINT64_C(0x61E07E9A32A7866D), UINT64_C(0x350907086E777760), - UINT64_C(0xC8328DBE8B066477), UINT64_C(0x9CDBF42CD7D6957A), - UINT64_C(0xD073867288020F69), UINT64_C(0x849AFFE0D4D2FE64), - UINT64_C(0x79A1755631A3ED73), UINT64_C(0x2D480CC46D731C7E), - UINT64_C(0x110ECF10544FD5D8), UINT64_C(0x45E7B682089F24D5), - UINT64_C(0xB8DC3C34EDEE37C2), UINT64_C(0xEC3545A6B13EC6CF), - UINT64_C(0xC051BB9C9F97A48E), UINT64_C(0x94B8C20EC3475583), - UINT64_C(0x698348B826364694), UINT64_C(0x3D6A312A7AE6B799), - UINT64_C(0x012CF2FE43DA7E3F), UINT64_C(0x55C58B6C1F0A8F32), - UINT64_C(0xA8FE01DAFA7B9C25), UINT64_C(0xFC177848A6AB6D28), - UINT64_C(0xF037FDAEA72958A7), UINT64_C(0xA4DE843CFBF9A9AA), - UINT64_C(0x59E50E8A1E88BABD), UINT64_C(0x0D0C771842584BB0), - UINT64_C(0x314AB4CC7B648216), UINT64_C(0x65A3CD5E27B4731B), - UINT64_C(0x989847E8C2C5600C), UINT64_C(0xCC713E7A9E159101), - UINT64_C(0xE015C040B0BCF340), UINT64_C(0xB4FCB9D2EC6C024D), - UINT64_C(0x49C73364091D115A), UINT64_C(0x1D2E4AF655CDE057), - UINT64_C(0x216889226CF129F1), UINT64_C(0x7581F0B03021D8FC), - UINT64_C(0x88BA7A06D550CBEB), UINT64_C(0xDC53039489803AE6), - UINT64_C(0x11EA9EBA6AF9FFCD), UINT64_C(0x4503E72836290EC0), - UINT64_C(0xB8386D9ED3581DD7), UINT64_C(0xECD1140C8F88ECDA), - UINT64_C(0xD097D7D8B6B4257C), UINT64_C(0x847EAE4AEA64D471), - UINT64_C(0x794524FC0F15C766), UINT64_C(0x2DAC5D6E53C5366B), - UINT64_C(0x01C8A3547D6C542A), UINT64_C(0x5521DAC621BCA527), - UINT64_C(0xA81A5070C4CDB630), UINT64_C(0xFCF329E2981D473D), - UINT64_C(0xC0B5EA36A1218E9B), UINT64_C(0x945C93A4FDF17F96), - UINT64_C(0x6967191218806C81), UINT64_C(0x3D8E608044509D8C), - UINT64_C(0x31AEE56645D2A803), UINT64_C(0x65479CF41902590E), - UINT64_C(0x987C1642FC734A19), UINT64_C(0xCC956FD0A0A3BB14), - UINT64_C(0xF0D3AC04999F72B2), UINT64_C(0xA43AD596C54F83BF), - UINT64_C(0x59015F20203E90A8), UINT64_C(0x0DE826B27CEE61A5), - UINT64_C(0x218CD888524703E4), UINT64_C(0x7565A11A0E97F2E9), - UINT64_C(0x885E2BACEBE6E1FE), UINT64_C(0xDCB7523EB73610F3), - UINT64_C(0xE0F191EA8E0AD955), UINT64_C(0xB418E878D2DA2858), - UINT64_C(0x492362CE37AB3B4F), UINT64_C(0x1DCA1B5C6B7BCA42), - UINT64_C(0x5162690234AF5051), UINT64_C(0x058B1090687FA15C), - UINT64_C(0xF8B09A268D0EB24B), UINT64_C(0xAC59E3B4D1DE4346), - UINT64_C(0x901F2060E8E28AE0), UINT64_C(0xC4F659F2B4327BED), - UINT64_C(0x39CDD344514368FA), UINT64_C(0x6D24AAD60D9399F7), - UINT64_C(0x414054EC233AFBB6), UINT64_C(0x15A92D7E7FEA0ABB), - UINT64_C(0xE892A7C89A9B19AC), UINT64_C(0xBC7BDE5AC64BE8A1), - UINT64_C(0x803D1D8EFF772107), UINT64_C(0xD4D4641CA3A7D00A), - UINT64_C(0x29EFEEAA46D6C31D), UINT64_C(0x7D0697381A063210), - UINT64_C(0x712612DE1B84079F), UINT64_C(0x25CF6B4C4754F692), - UINT64_C(0xD8F4E1FAA225E585), UINT64_C(0x8C1D9868FEF51488), - UINT64_C(0xB05B5BBCC7C9DD2E), UINT64_C(0xE4B2222E9B192C23), - UINT64_C(0x1989A8987E683F34), UINT64_C(0x4D60D10A22B8CE39), - UINT64_C(0x61042F300C11AC78), UINT64_C(0x35ED56A250C15D75), - UINT64_C(0xC8D6DC14B5B04E62), UINT64_C(0x9C3FA586E960BF6F), - UINT64_C(0xA0796652D05C76C9), UINT64_C(0xF4901FC08C8C87C4), - UINT64_C(0x09AB957669FD94D3), UINT64_C(0x5D42ECE4352D65DE) - }, { - UINT64_C(0x0000000000000000), UINT64_C(0x3F0BE14A916A6DCB), - UINT64_C(0x7E17C29522D4DB96), UINT64_C(0x411C23DFB3BEB65D), - UINT64_C(0xFC2F852A45A9B72C), UINT64_C(0xC3246460D4C3DAE7), - UINT64_C(0x823847BF677D6CBA), UINT64_C(0xBD33A6F5F6170171), - UINT64_C(0x6A87A57F245D70DD), UINT64_C(0x558C4435B5371D16), - UINT64_C(0x149067EA0689AB4B), UINT64_C(0x2B9B86A097E3C680), - UINT64_C(0x96A8205561F4C7F1), UINT64_C(0xA9A3C11FF09EAA3A), - UINT64_C(0xE8BFE2C043201C67), UINT64_C(0xD7B4038AD24A71AC), - UINT64_C(0xD50F4AFE48BAE1BA), UINT64_C(0xEA04ABB4D9D08C71), - UINT64_C(0xAB18886B6A6E3A2C), UINT64_C(0x94136921FB0457E7), - UINT64_C(0x2920CFD40D135696), UINT64_C(0x162B2E9E9C793B5D), - UINT64_C(0x57370D412FC78D00), UINT64_C(0x683CEC0BBEADE0CB), - UINT64_C(0xBF88EF816CE79167), UINT64_C(0x80830ECBFD8DFCAC), - UINT64_C(0xC19F2D144E334AF1), UINT64_C(0xFE94CC5EDF59273A), - UINT64_C(0x43A76AAB294E264B), UINT64_C(0x7CAC8BE1B8244B80), - UINT64_C(0x3DB0A83E0B9AFDDD), UINT64_C(0x02BB49749AF09016), - UINT64_C(0x38C63AD73E7BDDF1), UINT64_C(0x07CDDB9DAF11B03A), - UINT64_C(0x46D1F8421CAF0667), UINT64_C(0x79DA19088DC56BAC), - UINT64_C(0xC4E9BFFD7BD26ADD), UINT64_C(0xFBE25EB7EAB80716), - UINT64_C(0xBAFE7D685906B14B), UINT64_C(0x85F59C22C86CDC80), - UINT64_C(0x52419FA81A26AD2C), UINT64_C(0x6D4A7EE28B4CC0E7), - UINT64_C(0x2C565D3D38F276BA), UINT64_C(0x135DBC77A9981B71), - UINT64_C(0xAE6E1A825F8F1A00), UINT64_C(0x9165FBC8CEE577CB), - UINT64_C(0xD079D8177D5BC196), UINT64_C(0xEF72395DEC31AC5D), - UINT64_C(0xEDC9702976C13C4B), UINT64_C(0xD2C29163E7AB5180), - UINT64_C(0x93DEB2BC5415E7DD), UINT64_C(0xACD553F6C57F8A16), - UINT64_C(0x11E6F50333688B67), UINT64_C(0x2EED1449A202E6AC), - UINT64_C(0x6FF1379611BC50F1), UINT64_C(0x50FAD6DC80D63D3A), - UINT64_C(0x874ED556529C4C96), UINT64_C(0xB845341CC3F6215D), - UINT64_C(0xF95917C370489700), UINT64_C(0xC652F689E122FACB), - UINT64_C(0x7B61507C1735FBBA), UINT64_C(0x446AB136865F9671), - UINT64_C(0x057692E935E1202C), UINT64_C(0x3A7D73A3A48B4DE7), - UINT64_C(0x718C75AE7CF7BBE2), UINT64_C(0x4E8794E4ED9DD629), - UINT64_C(0x0F9BB73B5E236074), UINT64_C(0x30905671CF490DBF), - UINT64_C(0x8DA3F084395E0CCE), UINT64_C(0xB2A811CEA8346105), - UINT64_C(0xF3B432111B8AD758), UINT64_C(0xCCBFD35B8AE0BA93), - UINT64_C(0x1B0BD0D158AACB3F), UINT64_C(0x2400319BC9C0A6F4), - UINT64_C(0x651C12447A7E10A9), UINT64_C(0x5A17F30EEB147D62), - UINT64_C(0xE72455FB1D037C13), UINT64_C(0xD82FB4B18C6911D8), - UINT64_C(0x9933976E3FD7A785), UINT64_C(0xA6387624AEBDCA4E), - UINT64_C(0xA4833F50344D5A58), UINT64_C(0x9B88DE1AA5273793), - UINT64_C(0xDA94FDC5169981CE), UINT64_C(0xE59F1C8F87F3EC05), - UINT64_C(0x58ACBA7A71E4ED74), UINT64_C(0x67A75B30E08E80BF), - UINT64_C(0x26BB78EF533036E2), UINT64_C(0x19B099A5C25A5B29), - UINT64_C(0xCE049A2F10102A85), UINT64_C(0xF10F7B65817A474E), - UINT64_C(0xB01358BA32C4F113), UINT64_C(0x8F18B9F0A3AE9CD8), - UINT64_C(0x322B1F0555B99DA9), UINT64_C(0x0D20FE4FC4D3F062), - UINT64_C(0x4C3CDD90776D463F), UINT64_C(0x73373CDAE6072BF4), - UINT64_C(0x494A4F79428C6613), UINT64_C(0x7641AE33D3E60BD8), - UINT64_C(0x375D8DEC6058BD85), UINT64_C(0x08566CA6F132D04E), - UINT64_C(0xB565CA530725D13F), UINT64_C(0x8A6E2B19964FBCF4), - UINT64_C(0xCB7208C625F10AA9), UINT64_C(0xF479E98CB49B6762), - UINT64_C(0x23CDEA0666D116CE), UINT64_C(0x1CC60B4CF7BB7B05), - UINT64_C(0x5DDA28934405CD58), UINT64_C(0x62D1C9D9D56FA093), - UINT64_C(0xDFE26F2C2378A1E2), UINT64_C(0xE0E98E66B212CC29), - UINT64_C(0xA1F5ADB901AC7A74), UINT64_C(0x9EFE4CF390C617BF), - UINT64_C(0x9C4505870A3687A9), UINT64_C(0xA34EE4CD9B5CEA62), - UINT64_C(0xE252C71228E25C3F), UINT64_C(0xDD592658B98831F4), - UINT64_C(0x606A80AD4F9F3085), UINT64_C(0x5F6161E7DEF55D4E), - UINT64_C(0x1E7D42386D4BEB13), UINT64_C(0x2176A372FC2186D8), - UINT64_C(0xF6C2A0F82E6BF774), UINT64_C(0xC9C941B2BF019ABF), - UINT64_C(0x88D5626D0CBF2CE2), UINT64_C(0xB7DE83279DD54129), - UINT64_C(0x0AED25D26BC24058), UINT64_C(0x35E6C498FAA82D93), - UINT64_C(0x74FAE74749169BCE), UINT64_C(0x4BF1060DD87CF605), - UINT64_C(0xE318EB5CF9EF77C4), UINT64_C(0xDC130A1668851A0F), - UINT64_C(0x9D0F29C9DB3BAC52), UINT64_C(0xA204C8834A51C199), - UINT64_C(0x1F376E76BC46C0E8), UINT64_C(0x203C8F3C2D2CAD23), - UINT64_C(0x6120ACE39E921B7E), UINT64_C(0x5E2B4DA90FF876B5), - UINT64_C(0x899F4E23DDB20719), UINT64_C(0xB694AF694CD86AD2), - UINT64_C(0xF7888CB6FF66DC8F), UINT64_C(0xC8836DFC6E0CB144), - UINT64_C(0x75B0CB09981BB035), UINT64_C(0x4ABB2A430971DDFE), - UINT64_C(0x0BA7099CBACF6BA3), UINT64_C(0x34ACE8D62BA50668), - UINT64_C(0x3617A1A2B155967E), UINT64_C(0x091C40E8203FFBB5), - UINT64_C(0x4800633793814DE8), UINT64_C(0x770B827D02EB2023), - UINT64_C(0xCA382488F4FC2152), UINT64_C(0xF533C5C265964C99), - UINT64_C(0xB42FE61DD628FAC4), UINT64_C(0x8B2407574742970F), - UINT64_C(0x5C9004DD9508E6A3), UINT64_C(0x639BE59704628B68), - UINT64_C(0x2287C648B7DC3D35), UINT64_C(0x1D8C270226B650FE), - UINT64_C(0xA0BF81F7D0A1518F), UINT64_C(0x9FB460BD41CB3C44), - UINT64_C(0xDEA84362F2758A19), UINT64_C(0xE1A3A228631FE7D2), - UINT64_C(0xDBDED18BC794AA35), UINT64_C(0xE4D530C156FEC7FE), - UINT64_C(0xA5C9131EE54071A3), UINT64_C(0x9AC2F254742A1C68), - UINT64_C(0x27F154A1823D1D19), UINT64_C(0x18FAB5EB135770D2), - UINT64_C(0x59E69634A0E9C68F), UINT64_C(0x66ED777E3183AB44), - UINT64_C(0xB15974F4E3C9DAE8), UINT64_C(0x8E5295BE72A3B723), - UINT64_C(0xCF4EB661C11D017E), UINT64_C(0xF045572B50776CB5), - UINT64_C(0x4D76F1DEA6606DC4), UINT64_C(0x727D1094370A000F), - UINT64_C(0x3361334B84B4B652), UINT64_C(0x0C6AD20115DEDB99), - UINT64_C(0x0ED19B758F2E4B8F), UINT64_C(0x31DA7A3F1E442644), - UINT64_C(0x70C659E0ADFA9019), UINT64_C(0x4FCDB8AA3C90FDD2), - UINT64_C(0xF2FE1E5FCA87FCA3), UINT64_C(0xCDF5FF155BED9168), - UINT64_C(0x8CE9DCCAE8532735), UINT64_C(0xB3E23D8079394AFE), - UINT64_C(0x64563E0AAB733B52), UINT64_C(0x5B5DDF403A195699), - UINT64_C(0x1A41FC9F89A7E0C4), UINT64_C(0x254A1DD518CD8D0F), - UINT64_C(0x9879BB20EEDA8C7E), UINT64_C(0xA7725A6A7FB0E1B5), - UINT64_C(0xE66E79B5CC0E57E8), UINT64_C(0xD96598FF5D643A23), - UINT64_C(0x92949EF28518CC26), UINT64_C(0xAD9F7FB81472A1ED), - UINT64_C(0xEC835C67A7CC17B0), UINT64_C(0xD388BD2D36A67A7B), - UINT64_C(0x6EBB1BD8C0B17B0A), UINT64_C(0x51B0FA9251DB16C1), - UINT64_C(0x10ACD94DE265A09C), UINT64_C(0x2FA73807730FCD57), - UINT64_C(0xF8133B8DA145BCFB), UINT64_C(0xC718DAC7302FD130), - UINT64_C(0x8604F9188391676D), UINT64_C(0xB90F185212FB0AA6), - UINT64_C(0x043CBEA7E4EC0BD7), UINT64_C(0x3B375FED7586661C), - UINT64_C(0x7A2B7C32C638D041), UINT64_C(0x45209D785752BD8A), - UINT64_C(0x479BD40CCDA22D9C), UINT64_C(0x789035465CC84057), - UINT64_C(0x398C1699EF76F60A), UINT64_C(0x0687F7D37E1C9BC1), - UINT64_C(0xBBB45126880B9AB0), UINT64_C(0x84BFB06C1961F77B), - UINT64_C(0xC5A393B3AADF4126), UINT64_C(0xFAA872F93BB52CED), - UINT64_C(0x2D1C7173E9FF5D41), UINT64_C(0x121790397895308A), - UINT64_C(0x530BB3E6CB2B86D7), UINT64_C(0x6C0052AC5A41EB1C), - UINT64_C(0xD133F459AC56EA6D), UINT64_C(0xEE3815133D3C87A6), - UINT64_C(0xAF2436CC8E8231FB), UINT64_C(0x902FD7861FE85C30), - UINT64_C(0xAA52A425BB6311D7), UINT64_C(0x9559456F2A097C1C), - UINT64_C(0xD44566B099B7CA41), UINT64_C(0xEB4E87FA08DDA78A), - UINT64_C(0x567D210FFECAA6FB), UINT64_C(0x6976C0456FA0CB30), - UINT64_C(0x286AE39ADC1E7D6D), UINT64_C(0x176102D04D7410A6), - UINT64_C(0xC0D5015A9F3E610A), UINT64_C(0xFFDEE0100E540CC1), - UINT64_C(0xBEC2C3CFBDEABA9C), UINT64_C(0x81C922852C80D757), - UINT64_C(0x3CFA8470DA97D626), UINT64_C(0x03F1653A4BFDBBED), - UINT64_C(0x42ED46E5F8430DB0), UINT64_C(0x7DE6A7AF6929607B), - UINT64_C(0x7F5DEEDBF3D9F06D), UINT64_C(0x40560F9162B39DA6), - UINT64_C(0x014A2C4ED10D2BFB), UINT64_C(0x3E41CD0440674630), - UINT64_C(0x83726BF1B6704741), UINT64_C(0xBC798ABB271A2A8A), - UINT64_C(0xFD65A96494A49CD7), UINT64_C(0xC26E482E05CEF11C), - UINT64_C(0x15DA4BA4D78480B0), UINT64_C(0x2AD1AAEE46EEED7B), - UINT64_C(0x6BCD8931F5505B26), UINT64_C(0x54C6687B643A36ED), - UINT64_C(0xE9F5CE8E922D379C), UINT64_C(0xD6FE2FC403475A57), - UINT64_C(0x97E20C1BB0F9EC0A), UINT64_C(0xA8E9ED51219381C1) - }, { - UINT64_C(0x0000000000000000), UINT64_C(0x1DEE8A5E222CA1DC), - UINT64_C(0x3BDD14BC445943B8), UINT64_C(0x26339EE26675E264), - UINT64_C(0x77BA297888B28770), UINT64_C(0x6A54A326AA9E26AC), - UINT64_C(0x4C673DC4CCEBC4C8), UINT64_C(0x5189B79AEEC76514), - UINT64_C(0xEF7452F111650EE0), UINT64_C(0xF29AD8AF3349AF3C), - UINT64_C(0xD4A9464D553C4D58), UINT64_C(0xC947CC137710EC84), - UINT64_C(0x98CE7B8999D78990), UINT64_C(0x8520F1D7BBFB284C), - UINT64_C(0xA3136F35DD8ECA28), UINT64_C(0xBEFDE56BFFA26BF4), - UINT64_C(0x4C300AC98DC40345), UINT64_C(0x51DE8097AFE8A299), - UINT64_C(0x77ED1E75C99D40FD), UINT64_C(0x6A03942BEBB1E121), - UINT64_C(0x3B8A23B105768435), UINT64_C(0x2664A9EF275A25E9), - UINT64_C(0x0057370D412FC78D), UINT64_C(0x1DB9BD5363036651), - UINT64_C(0xA34458389CA10DA5), UINT64_C(0xBEAAD266BE8DAC79), - UINT64_C(0x98994C84D8F84E1D), UINT64_C(0x8577C6DAFAD4EFC1), - UINT64_C(0xD4FE714014138AD5), UINT64_C(0xC910FB1E363F2B09), - UINT64_C(0xEF2365FC504AC96D), UINT64_C(0xF2CDEFA2726668B1), - UINT64_C(0x986015931B88068A), UINT64_C(0x858E9FCD39A4A756), - UINT64_C(0xA3BD012F5FD14532), UINT64_C(0xBE538B717DFDE4EE), - UINT64_C(0xEFDA3CEB933A81FA), UINT64_C(0xF234B6B5B1162026), - UINT64_C(0xD4072857D763C242), UINT64_C(0xC9E9A209F54F639E), - UINT64_C(0x771447620AED086A), UINT64_C(0x6AFACD3C28C1A9B6), - UINT64_C(0x4CC953DE4EB44BD2), UINT64_C(0x5127D9806C98EA0E), - UINT64_C(0x00AE6E1A825F8F1A), UINT64_C(0x1D40E444A0732EC6), - UINT64_C(0x3B737AA6C606CCA2), UINT64_C(0x269DF0F8E42A6D7E), - UINT64_C(0xD4501F5A964C05CF), UINT64_C(0xC9BE9504B460A413), - UINT64_C(0xEF8D0BE6D2154677), UINT64_C(0xF26381B8F039E7AB), - UINT64_C(0xA3EA36221EFE82BF), UINT64_C(0xBE04BC7C3CD22363), - UINT64_C(0x9837229E5AA7C107), UINT64_C(0x85D9A8C0788B60DB), - UINT64_C(0x3B244DAB87290B2F), UINT64_C(0x26CAC7F5A505AAF3), - UINT64_C(0x00F95917C3704897), UINT64_C(0x1D17D349E15CE94B), - UINT64_C(0x4C9E64D30F9B8C5F), UINT64_C(0x5170EE8D2DB72D83), - UINT64_C(0x7743706F4BC2CFE7), UINT64_C(0x6AADFA3169EE6E3B), - UINT64_C(0xA218840D981E1391), UINT64_C(0xBFF60E53BA32B24D), - UINT64_C(0x99C590B1DC475029), UINT64_C(0x842B1AEFFE6BF1F5), - UINT64_C(0xD5A2AD7510AC94E1), UINT64_C(0xC84C272B3280353D), - UINT64_C(0xEE7FB9C954F5D759), UINT64_C(0xF391339776D97685), - UINT64_C(0x4D6CD6FC897B1D71), UINT64_C(0x50825CA2AB57BCAD), - UINT64_C(0x76B1C240CD225EC9), UINT64_C(0x6B5F481EEF0EFF15), - UINT64_C(0x3AD6FF8401C99A01), UINT64_C(0x273875DA23E53BDD), - UINT64_C(0x010BEB384590D9B9), UINT64_C(0x1CE5616667BC7865), - UINT64_C(0xEE288EC415DA10D4), UINT64_C(0xF3C6049A37F6B108), - UINT64_C(0xD5F59A785183536C), UINT64_C(0xC81B102673AFF2B0), - UINT64_C(0x9992A7BC9D6897A4), UINT64_C(0x847C2DE2BF443678), - UINT64_C(0xA24FB300D931D41C), UINT64_C(0xBFA1395EFB1D75C0), - UINT64_C(0x015CDC3504BF1E34), UINT64_C(0x1CB2566B2693BFE8), - UINT64_C(0x3A81C88940E65D8C), UINT64_C(0x276F42D762CAFC50), - UINT64_C(0x76E6F54D8C0D9944), UINT64_C(0x6B087F13AE213898), - UINT64_C(0x4D3BE1F1C854DAFC), UINT64_C(0x50D56BAFEA787B20), - UINT64_C(0x3A78919E8396151B), UINT64_C(0x27961BC0A1BAB4C7), - UINT64_C(0x01A58522C7CF56A3), UINT64_C(0x1C4B0F7CE5E3F77F), - UINT64_C(0x4DC2B8E60B24926B), UINT64_C(0x502C32B8290833B7), - UINT64_C(0x761FAC5A4F7DD1D3), UINT64_C(0x6BF126046D51700F), - UINT64_C(0xD50CC36F92F31BFB), UINT64_C(0xC8E24931B0DFBA27), - UINT64_C(0xEED1D7D3D6AA5843), UINT64_C(0xF33F5D8DF486F99F), - UINT64_C(0xA2B6EA171A419C8B), UINT64_C(0xBF586049386D3D57), - UINT64_C(0x996BFEAB5E18DF33), UINT64_C(0x848574F57C347EEF), - UINT64_C(0x76489B570E52165E), UINT64_C(0x6BA611092C7EB782), - UINT64_C(0x4D958FEB4A0B55E6), UINT64_C(0x507B05B56827F43A), - UINT64_C(0x01F2B22F86E0912E), UINT64_C(0x1C1C3871A4CC30F2), - UINT64_C(0x3A2FA693C2B9D296), UINT64_C(0x27C12CCDE095734A), - UINT64_C(0x993CC9A61F3718BE), UINT64_C(0x84D243F83D1BB962), - UINT64_C(0xA2E1DD1A5B6E5B06), UINT64_C(0xBF0F57447942FADA), - UINT64_C(0xEE86E0DE97859FCE), UINT64_C(0xF3686A80B5A93E12), - UINT64_C(0xD55BF462D3DCDC76), UINT64_C(0xC8B57E3CF1F07DAA), - UINT64_C(0xD6E9A7309F3239A7), UINT64_C(0xCB072D6EBD1E987B), - UINT64_C(0xED34B38CDB6B7A1F), UINT64_C(0xF0DA39D2F947DBC3), - UINT64_C(0xA1538E481780BED7), UINT64_C(0xBCBD041635AC1F0B), - UINT64_C(0x9A8E9AF453D9FD6F), UINT64_C(0x876010AA71F55CB3), - UINT64_C(0x399DF5C18E573747), UINT64_C(0x24737F9FAC7B969B), - UINT64_C(0x0240E17DCA0E74FF), UINT64_C(0x1FAE6B23E822D523), - UINT64_C(0x4E27DCB906E5B037), UINT64_C(0x53C956E724C911EB), - UINT64_C(0x75FAC80542BCF38F), UINT64_C(0x6814425B60905253), - UINT64_C(0x9AD9ADF912F63AE2), UINT64_C(0x873727A730DA9B3E), - UINT64_C(0xA104B94556AF795A), UINT64_C(0xBCEA331B7483D886), - UINT64_C(0xED6384819A44BD92), UINT64_C(0xF08D0EDFB8681C4E), - UINT64_C(0xD6BE903DDE1DFE2A), UINT64_C(0xCB501A63FC315FF6), - UINT64_C(0x75ADFF0803933402), UINT64_C(0x6843755621BF95DE), - UINT64_C(0x4E70EBB447CA77BA), UINT64_C(0x539E61EA65E6D666), - UINT64_C(0x0217D6708B21B372), UINT64_C(0x1FF95C2EA90D12AE), - UINT64_C(0x39CAC2CCCF78F0CA), UINT64_C(0x24244892ED545116), - UINT64_C(0x4E89B2A384BA3F2D), UINT64_C(0x536738FDA6969EF1), - UINT64_C(0x7554A61FC0E37C95), UINT64_C(0x68BA2C41E2CFDD49), - UINT64_C(0x39339BDB0C08B85D), UINT64_C(0x24DD11852E241981), - UINT64_C(0x02EE8F674851FBE5), UINT64_C(0x1F0005396A7D5A39), - UINT64_C(0xA1FDE05295DF31CD), UINT64_C(0xBC136A0CB7F39011), - UINT64_C(0x9A20F4EED1867275), UINT64_C(0x87CE7EB0F3AAD3A9), - UINT64_C(0xD647C92A1D6DB6BD), UINT64_C(0xCBA943743F411761), - UINT64_C(0xED9ADD965934F505), UINT64_C(0xF07457C87B1854D9), - UINT64_C(0x02B9B86A097E3C68), UINT64_C(0x1F5732342B529DB4), - UINT64_C(0x3964ACD64D277FD0), UINT64_C(0x248A26886F0BDE0C), - UINT64_C(0x7503911281CCBB18), UINT64_C(0x68ED1B4CA3E01AC4), - UINT64_C(0x4EDE85AEC595F8A0), UINT64_C(0x53300FF0E7B9597C), - UINT64_C(0xEDCDEA9B181B3288), UINT64_C(0xF02360C53A379354), - UINT64_C(0xD610FE275C427130), UINT64_C(0xCBFE74797E6ED0EC), - UINT64_C(0x9A77C3E390A9B5F8), UINT64_C(0x879949BDB2851424), - UINT64_C(0xA1AAD75FD4F0F640), UINT64_C(0xBC445D01F6DC579C), - UINT64_C(0x74F1233D072C2A36), UINT64_C(0x691FA96325008BEA), - UINT64_C(0x4F2C37814375698E), UINT64_C(0x52C2BDDF6159C852), - UINT64_C(0x034B0A458F9EAD46), UINT64_C(0x1EA5801BADB20C9A), - UINT64_C(0x38961EF9CBC7EEFE), UINT64_C(0x257894A7E9EB4F22), - UINT64_C(0x9B8571CC164924D6), UINT64_C(0x866BFB923465850A), - UINT64_C(0xA05865705210676E), UINT64_C(0xBDB6EF2E703CC6B2), - UINT64_C(0xEC3F58B49EFBA3A6), UINT64_C(0xF1D1D2EABCD7027A), - UINT64_C(0xD7E24C08DAA2E01E), UINT64_C(0xCA0CC656F88E41C2), - UINT64_C(0x38C129F48AE82973), UINT64_C(0x252FA3AAA8C488AF), - UINT64_C(0x031C3D48CEB16ACB), UINT64_C(0x1EF2B716EC9DCB17), - UINT64_C(0x4F7B008C025AAE03), UINT64_C(0x52958AD220760FDF), - UINT64_C(0x74A614304603EDBB), UINT64_C(0x69489E6E642F4C67), - UINT64_C(0xD7B57B059B8D2793), UINT64_C(0xCA5BF15BB9A1864F), - UINT64_C(0xEC686FB9DFD4642B), UINT64_C(0xF186E5E7FDF8C5F7), - UINT64_C(0xA00F527D133FA0E3), UINT64_C(0xBDE1D8233113013F), - UINT64_C(0x9BD246C15766E35B), UINT64_C(0x863CCC9F754A4287), - UINT64_C(0xEC9136AE1CA42CBC), UINT64_C(0xF17FBCF03E888D60), - UINT64_C(0xD74C221258FD6F04), UINT64_C(0xCAA2A84C7AD1CED8), - UINT64_C(0x9B2B1FD69416ABCC), UINT64_C(0x86C59588B63A0A10), - UINT64_C(0xA0F60B6AD04FE874), UINT64_C(0xBD188134F26349A8), - UINT64_C(0x03E5645F0DC1225C), UINT64_C(0x1E0BEE012FED8380), - UINT64_C(0x383870E3499861E4), UINT64_C(0x25D6FABD6BB4C038), - UINT64_C(0x745F4D278573A52C), UINT64_C(0x69B1C779A75F04F0), - UINT64_C(0x4F82599BC12AE694), UINT64_C(0x526CD3C5E3064748), - UINT64_C(0xA0A13C6791602FF9), UINT64_C(0xBD4FB639B34C8E25), - UINT64_C(0x9B7C28DBD5396C41), UINT64_C(0x8692A285F715CD9D), - UINT64_C(0xD71B151F19D2A889), UINT64_C(0xCAF59F413BFE0955), - UINT64_C(0xECC601A35D8BEB31), UINT64_C(0xF1288BFD7FA74AED), - UINT64_C(0x4FD56E9680052119), UINT64_C(0x523BE4C8A22980C5), - UINT64_C(0x74087A2AC45C62A1), UINT64_C(0x69E6F074E670C37D), - UINT64_C(0x386F47EE08B7A669), UINT64_C(0x2581CDB02A9B07B5), - UINT64_C(0x03B253524CEEE5D1), UINT64_C(0x1E5CD90C6EC2440D) - } -}; diff --git a/deps/lzma/liblzma/check/crc64_tablegen.c b/deps/lzma/liblzma/check/crc64_tablegen.c deleted file mode 100644 index fddaa7e..0000000 --- a/deps/lzma/liblzma/check/crc64_tablegen.c +++ /dev/null @@ -1,88 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file crc64_tablegen.c -/// \brief Generate crc64_table_le.h and crc64_table_be.h -/// -/// Compiling: gcc -std=c99 -o crc64_tablegen crc64_tablegen.c -/// Add -DWORDS_BIGENDIAN to generate big endian table. -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include -#include "../../common/tuklib_integer.h" - - -static uint64_t crc64_table[4][256]; - - -extern void -init_crc64_table(void) -{ - static const uint64_t poly64 = UINT64_C(0xC96C5795D7870F42); - - for (size_t s = 0; s < 4; ++s) { - for (size_t b = 0; b < 256; ++b) { - uint64_t r = s == 0 ? b : crc64_table[s - 1][b]; - - for (size_t i = 0; i < 8; ++i) { - if (r & 1) - r = (r >> 1) ^ poly64; - else - r >>= 1; - } - - crc64_table[s][b] = r; - } - } - -#ifdef WORDS_BIGENDIAN - for (size_t s = 0; s < 4; ++s) - for (size_t b = 0; b < 256; ++b) - crc64_table[s][b] = bswap64(crc64_table[s][b]); -#endif - - return; -} - - -static void -print_crc64_table(void) -{ - printf("/* This file has been automatically generated by " - "crc64_tablegen.c. */\n\n" - "const uint64_t lzma_crc64_table[4][256] = {\n\t{"); - - for (size_t s = 0; s < 4; ++s) { - for (size_t b = 0; b < 256; ++b) { - if ((b % 2) == 0) - printf("\n\t\t"); - - printf("UINT64_C(0x%016" PRIX64 ")", - crc64_table[s][b]); - - if (b != 255) - printf(",%s", (b+1) % 2 == 0 ? "" : " "); - } - - if (s == 3) - printf("\n\t}\n};\n"); - else - printf("\n\t}, {"); - } - - return; -} - - -int -main(void) -{ - init_crc64_table(); - print_crc64_table(); - return 0; -} diff --git a/deps/lzma/liblzma/check/crc64_x86.S b/deps/lzma/liblzma/check/crc64_x86.S deleted file mode 100644 index f5bb84b..0000000 --- a/deps/lzma/liblzma/check/crc64_x86.S +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Speed-optimized CRC64 using slicing-by-four algorithm - * - * This uses only i386 instructions, but it is optimized for i686 and later - * (including e.g. Pentium II/III/IV, Athlon XP, and Core 2). - * - * Authors: Igor Pavlov (original CRC32 assembly code) - * Lasse Collin (CRC64 adaptation of the modified CRC32 code) - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * This code needs lzma_crc64_table, which can be created using the - * following C code: - -uint64_t lzma_crc64_table[4][256]; - -void -init_table(void) -{ - // ECMA-182 - static const uint64_t poly64 = UINT64_C(0xC96C5795D7870F42); - - for (size_t s = 0; s < 4; ++s) { - for (size_t b = 0; b < 256; ++b) { - uint64_t r = s == 0 ? b : lzma_crc64_table[s - 1][b]; - - for (size_t i = 0; i < 8; ++i) { - if (r & 1) - r = (r >> 1) ^ poly64; - else - r >>= 1; - } - - lzma_crc64_table[s][b] = r; - } - } -} - - * The prototype of the CRC64 function: - * extern uint64_t lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc); - */ - -/* - * On some systems, the functions need to be prefixed. The prefix is - * usually an underscore. - */ -#ifndef __USER_LABEL_PREFIX__ -# define __USER_LABEL_PREFIX__ -#endif -#define MAKE_SYM_CAT(prefix, sym) prefix ## sym -#define MAKE_SYM(prefix, sym) MAKE_SYM_CAT(prefix, sym) -#define LZMA_CRC64 MAKE_SYM(__USER_LABEL_PREFIX__, lzma_crc64) -#define LZMA_CRC64_TABLE MAKE_SYM(__USER_LABEL_PREFIX__, lzma_crc64_table) - -/* - * Solaris assembler doesn't have .p2align, and Darwin uses .align - * differently than GNU/Linux and Solaris. - */ -#if defined(__APPLE__) || defined(__MSDOS__) -# define ALIGN(pow2, abs) .align pow2 -#else -# define ALIGN(pow2, abs) .align abs -#endif - - .text - .globl LZMA_CRC64 - -#if !defined(__APPLE__) && !defined(_WIN32) && !defined(__CYGWIN__) \ - && !defined(__MSDOS__) - .type LZMA_CRC64, @function -#endif - - ALIGN(4, 16) -LZMA_CRC64: - /* - * Register usage: - * %eax crc LSB - * %edx crc MSB - * %esi buf - * %edi size or buf + size - * %ebx lzma_crc64_table - * %ebp Table index - * %ecx Temporary - */ - pushl %ebx - pushl %esi - pushl %edi - pushl %ebp - movl 0x14(%esp), %esi /* buf */ - movl 0x18(%esp), %edi /* size */ - movl 0x1C(%esp), %eax /* crc LSB */ - movl 0x20(%esp), %edx /* crc MSB */ - - /* - * Store the address of lzma_crc64_table to %ebx. This is needed to - * get position-independent code (PIC). - * - * The PIC macro is defined by libtool, while __PIC__ is defined - * by GCC but only on some systems. Testing for both makes it simpler - * to test this code without libtool, and keeps the code working also - * when built with libtool but using something else than GCC. - * - * I understood that libtool may define PIC on Windows even though - * the code in Windows DLLs is not PIC in sense that it is in ELF - * binaries, so we need a separate check to always use the non-PIC - * code on Windows. - */ -#if (!defined(PIC) && !defined(__PIC__)) \ - || (defined(_WIN32) || defined(__CYGWIN__)) - /* Not PIC */ - movl $ LZMA_CRC64_TABLE, %ebx -#elif defined(__APPLE__) - /* Mach-O */ - call .L_get_pc -.L_pic: - leal .L_lzma_crc64_table$non_lazy_ptr-.L_pic(%ebx), %ebx - movl (%ebx), %ebx -#else - /* ELF */ - call .L_get_pc - addl $_GLOBAL_OFFSET_TABLE_, %ebx - movl LZMA_CRC64_TABLE@GOT(%ebx), %ebx -#endif - - /* Complement the initial value. */ - notl %eax - notl %edx - -.L_align: - /* - * Check if there is enough input to use slicing-by-four. - * We need eight bytes, because the loop pre-reads four bytes. - */ - cmpl $8, %edi - jb .L_rest - - /* Check if we have reached alignment of four bytes. */ - testl $3, %esi - jz .L_slice - - /* Calculate CRC of the next input byte. */ - movzbl (%esi), %ebp - incl %esi - movzbl %al, %ecx - xorl %ecx, %ebp - shrdl $8, %edx, %eax - xorl (%ebx, %ebp, 8), %eax - shrl $8, %edx - xorl 4(%ebx, %ebp, 8), %edx - decl %edi - jmp .L_align - -.L_slice: - /* - * If we get here, there's at least eight bytes of aligned input - * available. Make %edi multiple of four bytes. Store the possible - * remainder over the "size" variable in the argument stack. - */ - movl %edi, 0x18(%esp) - andl $-4, %edi - subl %edi, 0x18(%esp) - - /* - * Let %edi be buf + size - 4 while running the main loop. This way - * we can compare for equality to determine when exit the loop. - */ - addl %esi, %edi - subl $4, %edi - - /* Read in the first four aligned bytes. */ - movl (%esi), %ecx - -.L_loop: - xorl %eax, %ecx - movzbl %cl, %ebp - movl 0x1800(%ebx, %ebp, 8), %eax - xorl %edx, %eax - movl 0x1804(%ebx, %ebp, 8), %edx - movzbl %ch, %ebp - xorl 0x1000(%ebx, %ebp, 8), %eax - xorl 0x1004(%ebx, %ebp, 8), %edx - shrl $16, %ecx - movzbl %cl, %ebp - xorl 0x0800(%ebx, %ebp, 8), %eax - xorl 0x0804(%ebx, %ebp, 8), %edx - movzbl %ch, %ebp - addl $4, %esi - xorl (%ebx, %ebp, 8), %eax - xorl 4(%ebx, %ebp, 8), %edx - - /* Check for end of aligned input. */ - cmpl %edi, %esi - - /* - * Copy the next input byte to %ecx. It is slightly faster to - * read it here than at the top of the loop. - */ - movl (%esi), %ecx - jb .L_loop - - /* - * Process the remaining four bytes, which we have already - * copied to %ecx. - */ - xorl %eax, %ecx - movzbl %cl, %ebp - movl 0x1800(%ebx, %ebp, 8), %eax - xorl %edx, %eax - movl 0x1804(%ebx, %ebp, 8), %edx - movzbl %ch, %ebp - xorl 0x1000(%ebx, %ebp, 8), %eax - xorl 0x1004(%ebx, %ebp, 8), %edx - shrl $16, %ecx - movzbl %cl, %ebp - xorl 0x0800(%ebx, %ebp, 8), %eax - xorl 0x0804(%ebx, %ebp, 8), %edx - movzbl %ch, %ebp - addl $4, %esi - xorl (%ebx, %ebp, 8), %eax - xorl 4(%ebx, %ebp, 8), %edx - - /* Copy the number of remaining bytes to %edi. */ - movl 0x18(%esp), %edi - -.L_rest: - /* Check for end of input. */ - testl %edi, %edi - jz .L_return - - /* Calculate CRC of the next input byte. */ - movzbl (%esi), %ebp - incl %esi - movzbl %al, %ecx - xorl %ecx, %ebp - shrdl $8, %edx, %eax - xorl (%ebx, %ebp, 8), %eax - shrl $8, %edx - xorl 4(%ebx, %ebp, 8), %edx - decl %edi - jmp .L_rest - -.L_return: - /* Complement the final value. */ - notl %eax - notl %edx - - popl %ebp - popl %edi - popl %esi - popl %ebx - ret - -#if defined(PIC) || defined(__PIC__) - ALIGN(4, 16) -.L_get_pc: - movl (%esp), %ebx - ret -#endif - -#if defined(__APPLE__) && (defined(PIC) || defined(__PIC__)) - /* Mach-O PIC */ - .section __IMPORT,__pointers,non_lazy_symbol_pointers -.L_lzma_crc64_table$non_lazy_ptr: - .indirect_symbol LZMA_CRC64_TABLE - .long 0 - -#elif defined(_WIN32) || defined(__CYGWIN__) -# ifdef DLL_EXPORT - /* This is equivalent of __declspec(dllexport). */ - .section .drectve - .ascii " -export:lzma_crc64" -# endif - -#elif !defined(__MSDOS__) - /* ELF */ - .size LZMA_CRC64, .-LZMA_CRC64 -#endif - -/* - * This is needed to support non-executable stack. It's ugly to - * use __linux__ here, but I don't know a way to detect when - * we are using GNU assembler. - */ -#if defined(__ELF__) && defined(__linux__) - .section .note.GNU-stack,"",@progbits -#endif diff --git a/deps/lzma/liblzma/check/crc_macros.h b/deps/lzma/liblzma/check/crc_macros.h deleted file mode 100644 index a7c21b7..0000000 --- a/deps/lzma/liblzma/check/crc_macros.h +++ /dev/null @@ -1,30 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file crc_macros.h -/// \brief Some endian-dependent macros for CRC32 and CRC64 -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifdef WORDS_BIGENDIAN -# define A(x) ((x) >> 24) -# define B(x) (((x) >> 16) & 0xFF) -# define C(x) (((x) >> 8) & 0xFF) -# define D(x) ((x) & 0xFF) - -# define S8(x) ((x) << 8) -# define S32(x) ((x) << 32) - -#else -# define A(x) ((x) & 0xFF) -# define B(x) (((x) >> 8) & 0xFF) -# define C(x) (((x) >> 16) & 0xFF) -# define D(x) ((x) >> 24) - -# define S8(x) ((x) >> 8) -# define S32(x) ((x) >> 32) -#endif diff --git a/deps/lzma/liblzma/check/sha256.c b/deps/lzma/liblzma/check/sha256.c deleted file mode 100644 index f2cc0d7..0000000 --- a/deps/lzma/liblzma/check/sha256.c +++ /dev/null @@ -1,200 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file sha256.c -/// \brief SHA-256 -/// -/// \todo Crypto++ has x86 ASM optimizations. They use SSE so if they -/// are imported to liblzma, SSE instructions need to be used -/// conditionally to keep the code working on older boxes. -// -// This code is based on the code found from 7-Zip, which has a modified -// version of the SHA-256 found from Crypto++ . -// The code was modified a little to fit into liblzma. -// -// Authors: Kevin Springle -// Wei Dai -// Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -// Avoid bogus warnings in transform(). -#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 2) || __GNUC__ > 4 -# pragma GCC diagnostic ignored "-Wuninitialized" -#endif - -#include "check.h" - -// At least on x86, GCC is able to optimize this to a rotate instruction. -#define rotr_32(num, amount) ((num) >> (amount) | (num) << (32 - (amount))) - -#define blk0(i) (W[i] = data[i]) -#define blk2(i) (W[i & 15] += s1(W[(i - 2) & 15]) + W[(i - 7) & 15] \ - + s0(W[(i - 15) & 15])) - -#define Ch(x, y, z) (z ^ (x & (y ^ z))) -#define Maj(x, y, z) ((x & y) | (z & (x | y))) - -#define a(i) T[(0 - i) & 7] -#define b(i) T[(1 - i) & 7] -#define c(i) T[(2 - i) & 7] -#define d(i) T[(3 - i) & 7] -#define e(i) T[(4 - i) & 7] -#define f(i) T[(5 - i) & 7] -#define g(i) T[(6 - i) & 7] -#define h(i) T[(7 - i) & 7] - -#define R(i) \ - h(i) += S1(e(i)) + Ch(e(i), f(i), g(i)) + SHA256_K[i + j] \ - + (j ? blk2(i) : blk0(i)); \ - d(i) += h(i); \ - h(i) += S0(a(i)) + Maj(a(i), b(i), c(i)) - -#define S0(x) (rotr_32(x, 2) ^ rotr_32(x, 13) ^ rotr_32(x, 22)) -#define S1(x) (rotr_32(x, 6) ^ rotr_32(x, 11) ^ rotr_32(x, 25)) -#define s0(x) (rotr_32(x, 7) ^ rotr_32(x, 18) ^ (x >> 3)) -#define s1(x) (rotr_32(x, 17) ^ rotr_32(x, 19) ^ (x >> 10)) - - -static const uint32_t SHA256_K[64] = { - 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, - 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, - 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, - 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, - 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC, - 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, - 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, - 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967, - 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, - 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, - 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, - 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, - 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, - 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, - 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, - 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2, -}; - - -static void -transform(uint32_t state[8], const uint32_t data[16]) -{ - uint32_t W[16]; - uint32_t T[8]; - - // Copy state[] to working vars. - memcpy(T, state, sizeof(T)); - - // 64 operations, partially loop unrolled - for (unsigned int j = 0; j < 64; j += 16) { - R( 0); R( 1); R( 2); R( 3); - R( 4); R( 5); R( 6); R( 7); - R( 8); R( 9); R(10); R(11); - R(12); R(13); R(14); R(15); - } - - // Add the working vars back into state[]. - state[0] += a(0); - state[1] += b(0); - state[2] += c(0); - state[3] += d(0); - state[4] += e(0); - state[5] += f(0); - state[6] += g(0); - state[7] += h(0); -} - - -static void -process(lzma_check_state *check) -{ -#ifdef WORDS_BIGENDIAN - transform(check->state.sha256.state, check->buffer.u32); - -#else - uint32_t data[16]; - - for (size_t i = 0; i < 16; ++i) - data[i] = bswap32(check->buffer.u32[i]); - - transform(check->state.sha256.state, data); -#endif - - return; -} - - -extern void -lzma_sha256_init(lzma_check_state *check) -{ - static const uint32_t s[8] = { - 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, - 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19, - }; - - memcpy(check->state.sha256.state, s, sizeof(s)); - check->state.sha256.size = 0; - - return; -} - - -extern void -lzma_sha256_update(const uint8_t *buf, size_t size, lzma_check_state *check) -{ - // Copy the input data into a properly aligned temporary buffer. - // This way we can be called with arbitrarily sized buffers - // (no need to be multiple of 64 bytes), and the code works also - // on architectures that don't allow unaligned memory access. - while (size > 0) { - const size_t copy_start = check->state.sha256.size & 0x3F; - size_t copy_size = 64 - copy_start; - if (copy_size > size) - copy_size = size; - - memcpy(check->buffer.u8 + copy_start, buf, copy_size); - - buf += copy_size; - size -= copy_size; - check->state.sha256.size += copy_size; - - if ((check->state.sha256.size & 0x3F) == 0) - process(check); - } - - return; -} - - -extern void -lzma_sha256_finish(lzma_check_state *check) -{ - // Add padding as described in RFC 3174 (it describes SHA-1 but - // the same padding style is used for SHA-256 too). - size_t pos = check->state.sha256.size & 0x3F; - check->buffer.u8[pos++] = 0x80; - - while (pos != 64 - 8) { - if (pos == 64) { - process(check); - pos = 0; - } - - check->buffer.u8[pos++] = 0x00; - } - - // Convert the message size from bytes to bits. - check->state.sha256.size *= 8; - - check->buffer.u64[(64 - 8) / 8] = conv64be(check->state.sha256.size); - - process(check); - - for (size_t i = 0; i < 8; ++i) - check->buffer.u32[i] = conv32be(check->state.sha256.state[i]); - - return; -} diff --git a/deps/lzma/liblzma/common/alone_decoder.c b/deps/lzma/liblzma/common/alone_decoder.c deleted file mode 100644 index c25112e..0000000 --- a/deps/lzma/liblzma/common/alone_decoder.c +++ /dev/null @@ -1,238 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file alone_decoder.c -/// \brief Decoder for LZMA_Alone files -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "alone_decoder.h" -#include "lzma_decoder.h" -#include "lz_decoder.h" - - -struct lzma_coder_s { - lzma_next_coder next; - - enum { - SEQ_PROPERTIES, - SEQ_DICTIONARY_SIZE, - SEQ_UNCOMPRESSED_SIZE, - SEQ_CODER_INIT, - SEQ_CODE, - } sequence; - - /// If true, reject files that are unlikely to be .lzma files. - /// If false, more non-.lzma files get accepted and will give - /// LZMA_DATA_ERROR either immediately or after a few output bytes. - bool picky; - - /// Position in the header fields - size_t pos; - - /// Uncompressed size decoded from the header - lzma_vli uncompressed_size; - - /// Memory usage limit - uint64_t memlimit; - - /// Amount of memory actually needed (only an estimate) - uint64_t memusage; - - /// Options decoded from the header needed to initialize - /// the LZMA decoder - lzma_options_lzma options; -}; - - -static lzma_ret -alone_decode(lzma_coder *coder, - lzma_allocator *allocator lzma_attribute((__unused__)), - const uint8_t *restrict in, size_t *restrict in_pos, - size_t in_size, uint8_t *restrict out, - size_t *restrict out_pos, size_t out_size, - lzma_action action) -{ - while (*out_pos < out_size - && (coder->sequence == SEQ_CODE || *in_pos < in_size)) - switch (coder->sequence) { - case SEQ_PROPERTIES: - if (lzma_lzma_lclppb_decode(&coder->options, in[*in_pos])) - return LZMA_FORMAT_ERROR; - - coder->sequence = SEQ_DICTIONARY_SIZE; - ++*in_pos; - break; - - case SEQ_DICTIONARY_SIZE: - coder->options.dict_size - |= (size_t)(in[*in_pos]) << (coder->pos * 8); - - if (++coder->pos == 4) { - if (coder->picky && coder->options.dict_size - != UINT32_MAX) { - // A hack to ditch tons of false positives: - // We allow only dictionary sizes that are - // 2^n or 2^n + 2^(n-1). LZMA_Alone created - // only files with 2^n, but accepts any - // dictionary size. - uint32_t d = coder->options.dict_size - 1; - d |= d >> 2; - d |= d >> 3; - d |= d >> 4; - d |= d >> 8; - d |= d >> 16; - ++d; - - if (d != coder->options.dict_size) - return LZMA_FORMAT_ERROR; - } - - coder->pos = 0; - coder->sequence = SEQ_UNCOMPRESSED_SIZE; - } - - ++*in_pos; - break; - - case SEQ_UNCOMPRESSED_SIZE: - coder->uncompressed_size - |= (lzma_vli)(in[*in_pos]) << (coder->pos * 8); - ++*in_pos; - if (++coder->pos < 8) - break; - - // Another hack to ditch false positives: Assume that - // if the uncompressed size is known, it must be less - // than 256 GiB. - if (coder->picky - && coder->uncompressed_size != LZMA_VLI_UNKNOWN - && coder->uncompressed_size - >= (LZMA_VLI_C(1) << 38)) - return LZMA_FORMAT_ERROR; - - // Calculate the memory usage so that it is ready - // for SEQ_CODER_INIT. - coder->memusage = lzma_lzma_decoder_memusage(&coder->options) - + LZMA_MEMUSAGE_BASE; - - coder->pos = 0; - coder->sequence = SEQ_CODER_INIT; - - // Fall through - - case SEQ_CODER_INIT: { - if (coder->memusage > coder->memlimit) - return LZMA_MEMLIMIT_ERROR; - - lzma_filter_info filters[2] = { - { - .init = &lzma_lzma_decoder_init, - .options = &coder->options, - }, { - .init = NULL, - } - }; - - const lzma_ret ret = lzma_next_filter_init(&coder->next, - allocator, filters); - if (ret != LZMA_OK) - return ret; - - // Use a hack to set the uncompressed size. - lzma_lz_decoder_uncompressed(coder->next.coder, - coder->uncompressed_size); - - coder->sequence = SEQ_CODE; - break; - } - - case SEQ_CODE: { - return coder->next.code(coder->next.coder, - allocator, in, in_pos, in_size, - out, out_pos, out_size, action); - } - - default: - return LZMA_PROG_ERROR; - } - - return LZMA_OK; -} - - -static void -alone_decoder_end(lzma_coder *coder, lzma_allocator *allocator) -{ - lzma_next_end(&coder->next, allocator); - lzma_free(coder, allocator); - return; -} - - -static lzma_ret -alone_decoder_memconfig(lzma_coder *coder, uint64_t *memusage, - uint64_t *old_memlimit, uint64_t new_memlimit) -{ - *memusage = coder->memusage; - *old_memlimit = coder->memlimit; - - if (new_memlimit != 0) { - if (new_memlimit < coder->memusage) - return LZMA_MEMLIMIT_ERROR; - - coder->memlimit = new_memlimit; - } - - return LZMA_OK; -} - - -extern lzma_ret -lzma_alone_decoder_init(lzma_next_coder *next, lzma_allocator *allocator, - uint64_t memlimit, bool picky) -{ - lzma_next_coder_init(&lzma_alone_decoder_init, next, allocator); - - if (memlimit == 0) - return LZMA_PROG_ERROR; - - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) - return LZMA_MEM_ERROR; - - next->code = &alone_decode; - next->end = &alone_decoder_end; - next->memconfig = &alone_decoder_memconfig; - next->coder->next = LZMA_NEXT_CODER_INIT; - } - - next->coder->sequence = SEQ_PROPERTIES; - next->coder->picky = picky; - next->coder->pos = 0; - next->coder->options.dict_size = 0; - next->coder->options.preset_dict = NULL; - next->coder->options.preset_dict_size = 0; - next->coder->uncompressed_size = 0; - next->coder->memlimit = memlimit; - next->coder->memusage = LZMA_MEMUSAGE_BASE; - - return LZMA_OK; -} - - -extern LZMA_API(lzma_ret) -lzma_alone_decoder(lzma_stream *strm, uint64_t memlimit) -{ - lzma_next_strm_init(lzma_alone_decoder_init, strm, memlimit, false); - - strm->internal->supported_actions[LZMA_RUN] = true; - strm->internal->supported_actions[LZMA_FINISH] = true; - - return LZMA_OK; -} diff --git a/deps/lzma/liblzma/common/alone_decoder.h b/deps/lzma/liblzma/common/alone_decoder.h deleted file mode 100644 index f666fc3..0000000 --- a/deps/lzma/liblzma/common/alone_decoder.h +++ /dev/null @@ -1,23 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file alone_decoder.h -/// \brief Decoder for LZMA_Alone files -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_ALONE_DECODER_H -#define LZMA_ALONE_DECODER_H - -#include "common.h" - - -extern lzma_ret lzma_alone_decoder_init( - lzma_next_coder *next, lzma_allocator *allocator, - uint64_t memlimit, bool picky); - -#endif diff --git a/deps/lzma/liblzma/common/alone_encoder.c b/deps/lzma/liblzma/common/alone_encoder.c deleted file mode 100644 index eb1697e..0000000 --- a/deps/lzma/liblzma/common/alone_encoder.c +++ /dev/null @@ -1,157 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file alone_decoder.c -/// \brief Decoder for LZMA_Alone files -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "common.h" -#include "lzma_encoder.h" - - -#define ALONE_HEADER_SIZE (1 + 4 + 8) - - -struct lzma_coder_s { - lzma_next_coder next; - - enum { - SEQ_HEADER, - SEQ_CODE, - } sequence; - - size_t header_pos; - uint8_t header[ALONE_HEADER_SIZE]; -}; - - -static lzma_ret -alone_encode(lzma_coder *coder, - lzma_allocator *allocator lzma_attribute((__unused__)), - const uint8_t *restrict in, size_t *restrict in_pos, - size_t in_size, uint8_t *restrict out, - size_t *restrict out_pos, size_t out_size, - lzma_action action) -{ - while (*out_pos < out_size) - switch (coder->sequence) { - case SEQ_HEADER: - lzma_bufcpy(coder->header, &coder->header_pos, - ALONE_HEADER_SIZE, - out, out_pos, out_size); - if (coder->header_pos < ALONE_HEADER_SIZE) - return LZMA_OK; - - coder->sequence = SEQ_CODE; - break; - - case SEQ_CODE: - return coder->next.code(coder->next.coder, - allocator, in, in_pos, in_size, - out, out_pos, out_size, action); - - default: - assert(0); - return LZMA_PROG_ERROR; - } - - return LZMA_OK; -} - - -static void -alone_encoder_end(lzma_coder *coder, lzma_allocator *allocator) -{ - lzma_next_end(&coder->next, allocator); - lzma_free(coder, allocator); - return; -} - - -// At least for now, this is not used by any internal function. -static lzma_ret -alone_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_options_lzma *options) -{ - lzma_next_coder_init(&alone_encoder_init, next, allocator); - - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) - return LZMA_MEM_ERROR; - - next->code = &alone_encode; - next->end = &alone_encoder_end; - next->coder->next = LZMA_NEXT_CODER_INIT; - } - - // Basic initializations - next->coder->sequence = SEQ_HEADER; - next->coder->header_pos = 0; - - // Encode the header: - // - Properties (1 byte) - if (lzma_lzma_lclppb_encode(options, next->coder->header)) - return LZMA_OPTIONS_ERROR; - - // - Dictionary size (4 bytes) - if (options->dict_size < LZMA_DICT_SIZE_MIN) - return LZMA_OPTIONS_ERROR; - - // Round up to the next 2^n or 2^n + 2^(n - 1) depending on which - // one is the next unless it is UINT32_MAX. While the header would - // allow any 32-bit integer, we do this to keep the decoder of liblzma - // accepting the resulting files. - uint32_t d = options->dict_size - 1; - d |= d >> 2; - d |= d >> 3; - d |= d >> 4; - d |= d >> 8; - d |= d >> 16; - if (d != UINT32_MAX) - ++d; - - unaligned_write32le(next->coder->header + 1, d); - - // - Uncompressed size (always unknown and using EOPM) - memset(next->coder->header + 1 + 4, 0xFF, 8); - - // Initialize the LZMA encoder. - const lzma_filter_info filters[2] = { - { - .init = &lzma_lzma_encoder_init, - .options = (void *)(options), - }, { - .init = NULL, - } - }; - - return lzma_next_filter_init(&next->coder->next, allocator, filters); -} - - -/* -extern lzma_ret -lzma_alone_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_options_alone *options) -{ - lzma_next_coder_init(&alone_encoder_init, next, allocator, options); -} -*/ - - -extern LZMA_API(lzma_ret) -lzma_alone_encoder(lzma_stream *strm, const lzma_options_lzma *options) -{ - lzma_next_strm_init(alone_encoder_init, strm, options); - - strm->internal->supported_actions[LZMA_RUN] = true; - strm->internal->supported_actions[LZMA_FINISH] = true; - - return LZMA_OK; -} diff --git a/deps/lzma/liblzma/common/auto_decoder.c b/deps/lzma/liblzma/common/auto_decoder.c deleted file mode 100644 index 35c895f..0000000 --- a/deps/lzma/liblzma/common/auto_decoder.c +++ /dev/null @@ -1,186 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file auto_decoder.c -/// \brief Autodetect between .xz Stream and .lzma (LZMA_Alone) formats -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "stream_decoder.h" -#include "alone_decoder.h" - - -struct lzma_coder_s { - /// Stream decoder or LZMA_Alone decoder - lzma_next_coder next; - - uint64_t memlimit; - uint32_t flags; - - enum { - SEQ_INIT, - SEQ_CODE, - SEQ_FINISH, - } sequence; -}; - - -static lzma_ret -auto_decode(lzma_coder *coder, lzma_allocator *allocator, - const uint8_t *restrict in, size_t *restrict in_pos, - size_t in_size, uint8_t *restrict out, - size_t *restrict out_pos, size_t out_size, lzma_action action) -{ - switch (coder->sequence) { - case SEQ_INIT: - if (*in_pos >= in_size) - return LZMA_OK; - - // Update the sequence now, because we want to continue from - // SEQ_CODE even if we return some LZMA_*_CHECK. - coder->sequence = SEQ_CODE; - - // Detect the file format. For now this is simple, since if - // it doesn't start with 0xFD (the first magic byte of the - // new format), it has to be LZMA_Alone, or something that - // we don't support at all. - if (in[*in_pos] == 0xFD) { - return_if_error(lzma_stream_decoder_init( - &coder->next, allocator, - coder->memlimit, coder->flags)); - } else { - return_if_error(lzma_alone_decoder_init(&coder->next, - allocator, coder->memlimit, true)); - - // If the application wants to know about missing - // integrity check or about the check in general, we - // need to handle it here, because LZMA_Alone decoder - // doesn't accept any flags. - if (coder->flags & LZMA_TELL_NO_CHECK) - return LZMA_NO_CHECK; - - if (coder->flags & LZMA_TELL_ANY_CHECK) - return LZMA_GET_CHECK; - } - - // Fall through - - case SEQ_CODE: { - const lzma_ret ret = coder->next.code( - coder->next.coder, allocator, - in, in_pos, in_size, - out, out_pos, out_size, action); - if (ret != LZMA_STREAM_END - || (coder->flags & LZMA_CONCATENATED) == 0) - return ret; - - coder->sequence = SEQ_FINISH; - } - - // Fall through - - case SEQ_FINISH: - // When LZMA_DECODE_CONCATENATED was used and we were decoding - // LZMA_Alone file, we need to check check that there is no - // trailing garbage and wait for LZMA_FINISH. - if (*in_pos < in_size) - return LZMA_DATA_ERROR; - - return action == LZMA_FINISH ? LZMA_STREAM_END : LZMA_OK; - - default: - assert(0); - return LZMA_PROG_ERROR; - } -} - - -static void -auto_decoder_end(lzma_coder *coder, lzma_allocator *allocator) -{ - lzma_next_end(&coder->next, allocator); - lzma_free(coder, allocator); - return; -} - - -static lzma_check -auto_decoder_get_check(const lzma_coder *coder) -{ - // It is LZMA_Alone if get_check is NULL. - return coder->next.get_check == NULL ? LZMA_CHECK_NONE - : coder->next.get_check(coder->next.coder); -} - - -static lzma_ret -auto_decoder_memconfig(lzma_coder *coder, uint64_t *memusage, - uint64_t *old_memlimit, uint64_t new_memlimit) -{ - lzma_ret ret; - - if (coder->next.memconfig != NULL) { - ret = coder->next.memconfig(coder->next.coder, - memusage, old_memlimit, new_memlimit); - assert(*old_memlimit == coder->memlimit); - } else { - // No coder is configured yet. Use the base value as - // the current memory usage. - *memusage = LZMA_MEMUSAGE_BASE; - *old_memlimit = coder->memlimit; - ret = LZMA_OK; - } - - if (ret == LZMA_OK && new_memlimit != 0) - coder->memlimit = new_memlimit; - - return ret; -} - - -static lzma_ret -auto_decoder_init(lzma_next_coder *next, lzma_allocator *allocator, - uint64_t memlimit, uint32_t flags) -{ - lzma_next_coder_init(&auto_decoder_init, next, allocator); - - if (memlimit == 0) - return LZMA_PROG_ERROR; - - if (flags & ~LZMA_SUPPORTED_FLAGS) - return LZMA_OPTIONS_ERROR; - - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) - return LZMA_MEM_ERROR; - - next->code = &auto_decode; - next->end = &auto_decoder_end; - next->get_check = &auto_decoder_get_check; - next->memconfig = &auto_decoder_memconfig; - next->coder->next = LZMA_NEXT_CODER_INIT; - } - - next->coder->memlimit = memlimit; - next->coder->flags = flags; - next->coder->sequence = SEQ_INIT; - - return LZMA_OK; -} - - -extern LZMA_API(lzma_ret) -lzma_auto_decoder(lzma_stream *strm, uint64_t memlimit, uint32_t flags) -{ - lzma_next_strm_init(auto_decoder_init, strm, memlimit, flags); - - strm->internal->supported_actions[LZMA_RUN] = true; - strm->internal->supported_actions[LZMA_FINISH] = true; - - return LZMA_OK; -} diff --git a/deps/lzma/liblzma/common/block_buffer_decoder.c b/deps/lzma/liblzma/common/block_buffer_decoder.c deleted file mode 100644 index ff27a11..0000000 --- a/deps/lzma/liblzma/common/block_buffer_decoder.c +++ /dev/null @@ -1,80 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file block_buffer_decoder.c -/// \brief Single-call .xz Block decoder -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "block_decoder.h" - - -extern LZMA_API(lzma_ret) -lzma_block_buffer_decode(lzma_block *block, lzma_allocator *allocator, - const uint8_t *in, size_t *in_pos, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) -{ - if (in_pos == NULL || (in == NULL && *in_pos != in_size) - || *in_pos > in_size || out_pos == NULL - || (out == NULL && *out_pos != out_size) - || *out_pos > out_size) - return LZMA_PROG_ERROR; - - // Initialize the Block decoder. - lzma_next_coder block_decoder = LZMA_NEXT_CODER_INIT; - lzma_ret ret = lzma_block_decoder_init( - &block_decoder, allocator, block); - - if (ret == LZMA_OK) { - // Save the positions so that we can restore them in case - // an error occurs. - const size_t in_start = *in_pos; - const size_t out_start = *out_pos; - - // Do the actual decoding. - ret = block_decoder.code(block_decoder.coder, allocator, - in, in_pos, in_size, out, out_pos, out_size, - LZMA_FINISH); - - if (ret == LZMA_STREAM_END) { - ret = LZMA_OK; - } else { - if (ret == LZMA_OK) { - // Either the input was truncated or the - // output buffer was too small. - assert(*in_pos == in_size - || *out_pos == out_size); - - // If all the input was consumed, then the - // input is truncated, even if the output - // buffer is also full. This is because - // processing the last byte of the Block - // never produces output. - // - // NOTE: This assumption may break when new - // filters are added, if the end marker of - // the filter doesn't consume at least one - // complete byte. - if (*in_pos == in_size) - ret = LZMA_DATA_ERROR; - else - ret = LZMA_BUF_ERROR; - } - - // Restore the positions. - *in_pos = in_start; - *out_pos = out_start; - } - } - - // Free the decoder memory. This needs to be done even if - // initialization fails, because the internal API doesn't - // require the initialization function to free its memory on error. - lzma_next_end(&block_decoder, allocator); - - return ret; -} diff --git a/deps/lzma/liblzma/common/block_buffer_encoder.c b/deps/lzma/liblzma/common/block_buffer_encoder.c deleted file mode 100644 index 519c6a6..0000000 --- a/deps/lzma/liblzma/common/block_buffer_encoder.c +++ /dev/null @@ -1,305 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file block_buffer_encoder.c -/// \brief Single-call .xz Block encoder -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "block_encoder.h" -#include "filter_encoder.h" -#include "lzma2_encoder.h" -#include "check.h" - - -/// Estimate the maximum size of the Block Header and Check fields for -/// a Block that uses LZMA2 uncompressed chunks. We could use -/// lzma_block_header_size() but this is simpler. -/// -/// Block Header Size + Block Flags + Compressed Size -/// + Uncompressed Size + Filter Flags for LZMA2 + CRC32 + Check -/// and round up to the next multiple of four to take Header Padding -/// into account. -#define HEADERS_BOUND ((1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 3 + 4 \ - + LZMA_CHECK_SIZE_MAX + 3) & ~3) - - -static lzma_vli -lzma2_bound(lzma_vli uncompressed_size) -{ - // Prevent integer overflow in overhead calculation. - if (uncompressed_size > COMPRESSED_SIZE_MAX) - return 0; - - // Calculate the exact overhead of the LZMA2 headers: Round - // uncompressed_size up to the next multiple of LZMA2_CHUNK_MAX, - // multiply by the size of per-chunk header, and add one byte for - // the end marker. - const lzma_vli overhead = ((uncompressed_size + LZMA2_CHUNK_MAX - 1) - / LZMA2_CHUNK_MAX) - * LZMA2_HEADER_UNCOMPRESSED + 1; - - // Catch the possible integer overflow. - if (COMPRESSED_SIZE_MAX - overhead < uncompressed_size) - return 0; - - return uncompressed_size + overhead; -} - - -extern LZMA_API(size_t) -lzma_block_buffer_bound(size_t uncompressed_size) -{ - // For now, if the data doesn't compress, we always use uncompressed - // chunks of LZMA2. In future we may use Subblock filter too, but - // but for simplicity we probably will still use the same bound - // calculation even though Subblock filter would have slightly less - // overhead. - lzma_vli lzma2_size = lzma2_bound(uncompressed_size); - if (lzma2_size == 0) - return 0; - - // Take Block Padding into account. - lzma2_size = (lzma2_size + 3) & ~LZMA_VLI_C(3); - -#if SIZE_MAX < LZMA_VLI_MAX - // Catch the possible integer overflow on 32-bit systems. There's no - // overflow on 64-bit systems, because lzma2_bound() already takes - // into account the size of the headers in the Block. - if (SIZE_MAX - HEADERS_BOUND < lzma2_size) - return 0; -#endif - - return HEADERS_BOUND + lzma2_size; -} - - -static lzma_ret -block_encode_uncompressed(lzma_block *block, const uint8_t *in, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) -{ - // TODO: Figure out if the last filter is LZMA2 or Subblock and use - // that filter to encode the uncompressed chunks. - - // Use LZMA2 uncompressed chunks. We wouldn't need a dictionary at - // all, but LZMA2 always requires a dictionary, so use the minimum - // value to minimize memory usage of the decoder. - lzma_options_lzma lzma2 = { - .dict_size = LZMA_DICT_SIZE_MIN, - }; - - lzma_filter filters[2]; - filters[0].id = LZMA_FILTER_LZMA2; - filters[0].options = &lzma2; - filters[1].id = LZMA_VLI_UNKNOWN; - - // Set the above filter options to *block temporarily so that we can - // encode the Block Header. - lzma_filter *filters_orig = block->filters; - block->filters = filters; - - if (lzma_block_header_size(block) != LZMA_OK) { - block->filters = filters_orig; - return LZMA_PROG_ERROR; - } - - // Check that there's enough output space. The caller has already - // set block->compressed_size to what lzma2_bound() has returned, - // so we can reuse that value. We know that compressed_size is a - // known valid VLI and header_size is a small value so their sum - // will never overflow. - assert(block->compressed_size == lzma2_bound(in_size)); - if (out_size - *out_pos - < block->header_size + block->compressed_size) { - block->filters = filters_orig; - return LZMA_BUF_ERROR; - } - - if (lzma_block_header_encode(block, out + *out_pos) != LZMA_OK) { - block->filters = filters_orig; - return LZMA_PROG_ERROR; - } - - block->filters = filters_orig; - *out_pos += block->header_size; - - // Encode the data using LZMA2 uncompressed chunks. - size_t in_pos = 0; - uint8_t control = 0x01; // Dictionary reset - - while (in_pos < in_size) { - // Control byte: Indicate uncompressed chunk, of which - // the first resets the dictionary. - out[(*out_pos)++] = control; - control = 0x02; // No dictionary reset - - // Size of the uncompressed chunk - const size_t copy_size - = my_min(in_size - in_pos, LZMA2_CHUNK_MAX); - out[(*out_pos)++] = (copy_size - 1) >> 8; - out[(*out_pos)++] = (copy_size - 1) & 0xFF; - - // The actual data - assert(*out_pos + copy_size <= out_size); - memcpy(out + *out_pos, in + in_pos, copy_size); - - in_pos += copy_size; - *out_pos += copy_size; - } - - // End marker - out[(*out_pos)++] = 0x00; - assert(*out_pos <= out_size); - - return LZMA_OK; -} - - -static lzma_ret -block_encode_normal(lzma_block *block, lzma_allocator *allocator, - const uint8_t *in, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) -{ - // Find out the size of the Block Header. - block->compressed_size = lzma2_bound(in_size); - if (block->compressed_size == 0) - return LZMA_DATA_ERROR; - - block->uncompressed_size = in_size; - return_if_error(lzma_block_header_size(block)); - - // Reserve space for the Block Header and skip it for now. - if (out_size - *out_pos <= block->header_size) - return LZMA_BUF_ERROR; - - const size_t out_start = *out_pos; - *out_pos += block->header_size; - - // Limit out_size so that we stop encoding if the output would grow - // bigger than what uncompressed Block would be. - if (out_size - *out_pos > block->compressed_size) - out_size = *out_pos + block->compressed_size; - - // TODO: In many common cases this could be optimized to use - // significantly less memory. - lzma_next_coder raw_encoder = LZMA_NEXT_CODER_INIT; - lzma_ret ret = lzma_raw_encoder_init( - &raw_encoder, allocator, block->filters); - - if (ret == LZMA_OK) { - size_t in_pos = 0; - ret = raw_encoder.code(raw_encoder.coder, allocator, - in, &in_pos, in_size, out, out_pos, out_size, - LZMA_FINISH); - } - - // NOTE: This needs to be run even if lzma_raw_encoder_init() failed. - lzma_next_end(&raw_encoder, allocator); - - if (ret == LZMA_STREAM_END) { - // Compression was successful. Write the Block Header. - block->compressed_size - = *out_pos - (out_start + block->header_size); - ret = lzma_block_header_encode(block, out + out_start); - if (ret != LZMA_OK) - ret = LZMA_PROG_ERROR; - - } else if (ret == LZMA_OK) { - // Output buffer became full. - ret = LZMA_BUF_ERROR; - } - - // Reset *out_pos if something went wrong. - if (ret != LZMA_OK) - *out_pos = out_start; - - return ret; -} - - -extern LZMA_API(lzma_ret) -lzma_block_buffer_encode(lzma_block *block, lzma_allocator *allocator, - const uint8_t *in, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) -{ - // Validate the arguments. - if (block == NULL || (in == NULL && in_size != 0) || out == NULL - || out_pos == NULL || *out_pos > out_size) - return LZMA_PROG_ERROR; - - // The contents of the structure may depend on the version so - // check the version before validating the contents of *block. - if (block->version != 0) - return LZMA_OPTIONS_ERROR; - - if ((unsigned int)(block->check) > LZMA_CHECK_ID_MAX - || block->filters == NULL) - return LZMA_PROG_ERROR; - - if (!lzma_check_is_supported(block->check)) - return LZMA_UNSUPPORTED_CHECK; - - // Size of a Block has to be a multiple of four, so limit the size - // here already. This way we don't need to check it again when adding - // Block Padding. - out_size -= (out_size - *out_pos) & 3; - - // Get the size of the Check field. - const size_t check_size = lzma_check_size(block->check); - assert(check_size != UINT32_MAX); - - // Reserve space for the Check field. - if (out_size - *out_pos <= check_size) - return LZMA_BUF_ERROR; - - out_size -= check_size; - - // Do the actual compression. - const lzma_ret ret = block_encode_normal(block, allocator, - in, in_size, out, out_pos, out_size); - if (ret != LZMA_OK) { - // If the error was something else than output buffer - // becoming full, return the error now. - if (ret != LZMA_BUF_ERROR) - return ret; - - // The data was uncompressible (at least with the options - // given to us) or the output buffer was too small. Use the - // uncompressed chunks of LZMA2 to wrap the data into a valid - // Block. If we haven't been given enough output space, even - // this may fail. - return_if_error(block_encode_uncompressed(block, in, in_size, - out, out_pos, out_size)); - } - - assert(*out_pos <= out_size); - - // Block Padding. No buffer overflow here, because we already adjusted - // out_size so that (out_size - out_start) is a multiple of four. - // Thus, if the buffer is full, the loop body can never run. - for (size_t i = (size_t)(block->compressed_size); i & 3; ++i) { - assert(*out_pos < out_size); - out[(*out_pos)++] = 0x00; - } - - // If there's no Check field, we are done now. - if (check_size > 0) { - // Calculate the integrity check. We reserved space for - // the Check field earlier so we don't need to check for - // available output space here. - lzma_check_state check; - lzma_check_init(&check, block->check); - lzma_check_update(&check, block->check, in, in_size); - lzma_check_finish(&check, block->check); - - memcpy(block->raw_check, check.buffer.u8, check_size); - memcpy(out + *out_pos, check.buffer.u8, check_size); - *out_pos += check_size; - } - - return LZMA_OK; -} diff --git a/deps/lzma/liblzma/common/block_decoder.c b/deps/lzma/liblzma/common/block_decoder.c deleted file mode 100644 index a3ce6f4..0000000 --- a/deps/lzma/liblzma/common/block_decoder.c +++ /dev/null @@ -1,242 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file block_decoder.c -/// \brief Decodes .xz Blocks -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "block_decoder.h" -#include "filter_decoder.h" -#include "check.h" - - -struct lzma_coder_s { - enum { - SEQ_CODE, - SEQ_PADDING, - SEQ_CHECK, - } sequence; - - /// The filters in the chain; initialized with lzma_raw_decoder_init(). - lzma_next_coder next; - - /// Decoding options; we also write Compressed Size and Uncompressed - /// Size back to this structure when the decoding has been finished. - lzma_block *block; - - /// Compressed Size calculated while decoding - lzma_vli compressed_size; - - /// Uncompressed Size calculated while decoding - lzma_vli uncompressed_size; - - /// Maximum allowed Compressed Size; this takes into account the - /// size of the Block Header and Check fields when Compressed Size - /// is unknown. - lzma_vli compressed_limit; - - /// Position when reading the Check field - size_t check_pos; - - /// Check of the uncompressed data - lzma_check_state check; -}; - - -static inline bool -update_size(lzma_vli *size, lzma_vli add, lzma_vli limit) -{ - if (limit > LZMA_VLI_MAX) - limit = LZMA_VLI_MAX; - - if (limit < *size || limit - *size < add) - return true; - - *size += add; - - return false; -} - - -static inline bool -is_size_valid(lzma_vli size, lzma_vli reference) -{ - return reference == LZMA_VLI_UNKNOWN || reference == size; -} - - -static lzma_ret -block_decode(lzma_coder *coder, lzma_allocator *allocator, - const uint8_t *restrict in, size_t *restrict in_pos, - size_t in_size, uint8_t *restrict out, - size_t *restrict out_pos, size_t out_size, lzma_action action) -{ - switch (coder->sequence) { - case SEQ_CODE: { - const size_t in_start = *in_pos; - const size_t out_start = *out_pos; - - const lzma_ret ret = coder->next.code(coder->next.coder, - allocator, in, in_pos, in_size, - out, out_pos, out_size, action); - - const size_t in_used = *in_pos - in_start; - const size_t out_used = *out_pos - out_start; - - // NOTE: We compare to compressed_limit here, which prevents - // the total size of the Block growing past LZMA_VLI_MAX. - if (update_size(&coder->compressed_size, in_used, - coder->compressed_limit) - || update_size(&coder->uncompressed_size, - out_used, - coder->block->uncompressed_size)) - return LZMA_DATA_ERROR; - - lzma_check_update(&coder->check, coder->block->check, - out + out_start, out_used); - - if (ret != LZMA_STREAM_END) - return ret; - - // Compressed and Uncompressed Sizes are now at their final - // values. Verify that they match the values given to us. - if (!is_size_valid(coder->compressed_size, - coder->block->compressed_size) - || !is_size_valid(coder->uncompressed_size, - coder->block->uncompressed_size)) - return LZMA_DATA_ERROR; - - // Copy the values into coder->block. The caller - // may use this information to construct Index. - coder->block->compressed_size = coder->compressed_size; - coder->block->uncompressed_size = coder->uncompressed_size; - - coder->sequence = SEQ_PADDING; - } - - // Fall through - - case SEQ_PADDING: - // Compressed Data is padded to a multiple of four bytes. - while (coder->compressed_size & 3) { - if (*in_pos >= in_size) - return LZMA_OK; - - // We use compressed_size here just get the Padding - // right. The actual Compressed Size was stored to - // coder->block already, and won't be modified by - // us anymore. - ++coder->compressed_size; - - if (in[(*in_pos)++] != 0x00) - return LZMA_DATA_ERROR; - } - - if (coder->block->check == LZMA_CHECK_NONE) - return LZMA_STREAM_END; - - lzma_check_finish(&coder->check, coder->block->check); - coder->sequence = SEQ_CHECK; - - // Fall through - - case SEQ_CHECK: { - const size_t check_size = lzma_check_size(coder->block->check); - lzma_bufcpy(in, in_pos, in_size, coder->block->raw_check, - &coder->check_pos, check_size); - if (coder->check_pos < check_size) - return LZMA_OK; - - // Validate the Check only if we support it. - // coder->check.buffer may be uninitialized - // when the Check ID is not supported. - if (lzma_check_is_supported(coder->block->check) - && memcmp(coder->block->raw_check, - coder->check.buffer.u8, - check_size) != 0) - return LZMA_DATA_ERROR; - - return LZMA_STREAM_END; - } - } - - return LZMA_PROG_ERROR; -} - - -static void -block_decoder_end(lzma_coder *coder, lzma_allocator *allocator) -{ - lzma_next_end(&coder->next, allocator); - lzma_free(coder, allocator); - return; -} - - -extern lzma_ret -lzma_block_decoder_init(lzma_next_coder *next, lzma_allocator *allocator, - lzma_block *block) -{ - lzma_next_coder_init(&lzma_block_decoder_init, next, allocator); - - // Validate the options. lzma_block_unpadded_size() does that for us - // except for Uncompressed Size and filters. Filters are validated - // by the raw decoder. - if (lzma_block_unpadded_size(block) == 0 - || !lzma_vli_is_valid(block->uncompressed_size)) - return LZMA_PROG_ERROR; - - // Allocate and initialize *next->coder if needed. - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) - return LZMA_MEM_ERROR; - - next->code = &block_decode; - next->end = &block_decoder_end; - next->coder->next = LZMA_NEXT_CODER_INIT; - } - - // Basic initializations - next->coder->sequence = SEQ_CODE; - next->coder->block = block; - next->coder->compressed_size = 0; - next->coder->uncompressed_size = 0; - - // If Compressed Size is not known, we calculate the maximum allowed - // value so that encoded size of the Block (including Block Padding) - // is still a valid VLI and a multiple of four. - next->coder->compressed_limit - = block->compressed_size == LZMA_VLI_UNKNOWN - ? (LZMA_VLI_MAX & ~LZMA_VLI_C(3)) - - block->header_size - - lzma_check_size(block->check) - : block->compressed_size; - - // Initialize the check. It's caller's problem if the Check ID is not - // supported, and the Block decoder cannot verify the Check field. - // Caller can test lzma_check_is_supported(block->check). - next->coder->check_pos = 0; - lzma_check_init(&next->coder->check, block->check); - - // Initialize the filter chain. - return lzma_raw_decoder_init(&next->coder->next, allocator, - block->filters); -} - - -extern LZMA_API(lzma_ret) -lzma_block_decoder(lzma_stream *strm, lzma_block *block) -{ - lzma_next_strm_init(lzma_block_decoder_init, strm, block); - - strm->internal->supported_actions[LZMA_RUN] = true; - strm->internal->supported_actions[LZMA_FINISH] = true; - - return LZMA_OK; -} diff --git a/deps/lzma/liblzma/common/block_decoder.h b/deps/lzma/liblzma/common/block_decoder.h deleted file mode 100644 index 7da9df6..0000000 --- a/deps/lzma/liblzma/common/block_decoder.h +++ /dev/null @@ -1,22 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file block_decoder.h -/// \brief Decodes .xz Blocks -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_BLOCK_DECODER_H -#define LZMA_BLOCK_DECODER_H - -#include "common.h" - - -extern lzma_ret lzma_block_decoder_init(lzma_next_coder *next, - lzma_allocator *allocator, lzma_block *block); - -#endif diff --git a/deps/lzma/liblzma/common/block_encoder.c b/deps/lzma/liblzma/common/block_encoder.c deleted file mode 100644 index 1eeb502..0000000 --- a/deps/lzma/liblzma/common/block_encoder.c +++ /dev/null @@ -1,217 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file block_encoder.c -/// \brief Encodes .xz Blocks -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "block_encoder.h" -#include "filter_encoder.h" -#include "check.h" - - -struct lzma_coder_s { - /// The filters in the chain; initialized with lzma_raw_decoder_init(). - lzma_next_coder next; - - /// Encoding options; we also write Unpadded Size, Compressed Size, - /// and Uncompressed Size back to this structure when the encoding - /// has been finished. - lzma_block *block; - - enum { - SEQ_CODE, - SEQ_PADDING, - SEQ_CHECK, - } sequence; - - /// Compressed Size calculated while encoding - lzma_vli compressed_size; - - /// Uncompressed Size calculated while encoding - lzma_vli uncompressed_size; - - /// Position in the Check field - size_t pos; - - /// Check of the uncompressed data - lzma_check_state check; -}; - - -static lzma_ret -block_encode(lzma_coder *coder, lzma_allocator *allocator, - const uint8_t *restrict in, size_t *restrict in_pos, - size_t in_size, uint8_t *restrict out, - size_t *restrict out_pos, size_t out_size, lzma_action action) -{ - // Check that our amount of input stays in proper limits. - if (LZMA_VLI_MAX - coder->uncompressed_size < in_size - *in_pos) - return LZMA_DATA_ERROR; - - switch (coder->sequence) { - case SEQ_CODE: { - const size_t in_start = *in_pos; - const size_t out_start = *out_pos; - - const lzma_ret ret = coder->next.code(coder->next.coder, - allocator, in, in_pos, in_size, - out, out_pos, out_size, action); - - const size_t in_used = *in_pos - in_start; - const size_t out_used = *out_pos - out_start; - - if (COMPRESSED_SIZE_MAX - coder->compressed_size < out_used) - return LZMA_DATA_ERROR; - - coder->compressed_size += out_used; - - // No need to check for overflow because we have already - // checked it at the beginning of this function. - coder->uncompressed_size += in_used; - - lzma_check_update(&coder->check, coder->block->check, - in + in_start, in_used); - - if (ret != LZMA_STREAM_END || action == LZMA_SYNC_FLUSH) - return ret; - - assert(*in_pos == in_size); - assert(action == LZMA_FINISH); - - // Copy the values into coder->block. The caller - // may use this information to construct Index. - coder->block->compressed_size = coder->compressed_size; - coder->block->uncompressed_size = coder->uncompressed_size; - - coder->sequence = SEQ_PADDING; - } - - // Fall through - - case SEQ_PADDING: - // Pad Compressed Data to a multiple of four bytes. We can - // use coder->compressed_size for this since we don't need - // it for anything else anymore. - while (coder->compressed_size & 3) { - if (*out_pos >= out_size) - return LZMA_OK; - - out[*out_pos] = 0x00; - ++*out_pos; - ++coder->compressed_size; - } - - if (coder->block->check == LZMA_CHECK_NONE) - return LZMA_STREAM_END; - - lzma_check_finish(&coder->check, coder->block->check); - - coder->sequence = SEQ_CHECK; - - // Fall through - - case SEQ_CHECK: { - const size_t check_size = lzma_check_size(coder->block->check); - lzma_bufcpy(coder->check.buffer.u8, &coder->pos, check_size, - out, out_pos, out_size); - if (coder->pos < check_size) - return LZMA_OK; - - memcpy(coder->block->raw_check, coder->check.buffer.u8, - check_size); - return LZMA_STREAM_END; - } - } - - return LZMA_PROG_ERROR; -} - - -static void -block_encoder_end(lzma_coder *coder, lzma_allocator *allocator) -{ - lzma_next_end(&coder->next, allocator); - lzma_free(coder, allocator); - return; -} - - -static lzma_ret -block_encoder_update(lzma_coder *coder, lzma_allocator *allocator, - const lzma_filter *filters lzma_attribute((__unused__)), - const lzma_filter *reversed_filters) -{ - if (coder->sequence != SEQ_CODE) - return LZMA_PROG_ERROR; - - return lzma_next_filter_update( - &coder->next, allocator, reversed_filters); -} - - -extern lzma_ret -lzma_block_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, - lzma_block *block) -{ - lzma_next_coder_init(&lzma_block_encoder_init, next, allocator); - - if (block == NULL) - return LZMA_PROG_ERROR; - - // The contents of the structure may depend on the version so - // check the version first. - if (block->version != 0) - return LZMA_OPTIONS_ERROR; - - // If the Check ID is not supported, we cannot calculate the check and - // thus not create a proper Block. - if ((unsigned int)(block->check) > LZMA_CHECK_ID_MAX) - return LZMA_PROG_ERROR; - - if (!lzma_check_is_supported(block->check)) - return LZMA_UNSUPPORTED_CHECK; - - // Allocate and initialize *next->coder if needed. - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) - return LZMA_MEM_ERROR; - - next->code = &block_encode; - next->end = &block_encoder_end; - next->update = &block_encoder_update; - next->coder->next = LZMA_NEXT_CODER_INIT; - } - - // Basic initializations - next->coder->sequence = SEQ_CODE; - next->coder->block = block; - next->coder->compressed_size = 0; - next->coder->uncompressed_size = 0; - next->coder->pos = 0; - - // Initialize the check - lzma_check_init(&next->coder->check, block->check); - - // Initialize the requested filters. - return lzma_raw_encoder_init(&next->coder->next, allocator, - block->filters); -} - - -extern LZMA_API(lzma_ret) -lzma_block_encoder(lzma_stream *strm, lzma_block *block) -{ - lzma_next_strm_init(lzma_block_encoder_init, strm, block); - - strm->internal->supported_actions[LZMA_RUN] = true; - strm->internal->supported_actions[LZMA_FINISH] = true; - - return LZMA_OK; -} diff --git a/deps/lzma/liblzma/common/block_encoder.h b/deps/lzma/liblzma/common/block_encoder.h deleted file mode 100644 index b9eff0b..0000000 --- a/deps/lzma/liblzma/common/block_encoder.h +++ /dev/null @@ -1,47 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file block_encoder.h -/// \brief Encodes .xz Blocks -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_BLOCK_ENCODER_H -#define LZMA_BLOCK_ENCODER_H - -#include "common.h" - - -/// \brief Biggest Compressed Size value that the Block encoder supports -/// -/// The maximum size of a single Block is limited by the maximum size of -/// a Stream, which in theory is 2^63 - 3 bytes (i.e. LZMA_VLI_MAX - 3). -/// While the size is really big and no one should hit it in practice, we -/// take it into account in some places anyway to catch some errors e.g. if -/// application passes insanely big value to some function. -/// -/// We could take into account the headers etc. to determine the exact -/// maximum size of the Compressed Data field, but the complexity would give -/// us nothing useful. Instead, limit the size of Compressed Data so that -/// even with biggest possible Block Header and Check fields the total -/// encoded size of the Block stays as a valid VLI. This doesn't guarantee -/// that the size of the Stream doesn't grow too big, but that problem is -/// taken care outside the Block handling code. -/// -/// ~LZMA_VLI_C(3) is to guarantee that if we need padding at the end of -/// the Compressed Data field, it will still stay in the proper limit. -/// -/// This constant is in this file because it is needed in both -/// block_encoder.c and block_buffer_encoder.c. -#define COMPRESSED_SIZE_MAX ((LZMA_VLI_MAX - LZMA_BLOCK_HEADER_SIZE_MAX \ - - LZMA_CHECK_SIZE_MAX) & ~LZMA_VLI_C(3)) - - -extern lzma_ret lzma_block_encoder_init(lzma_next_coder *next, - lzma_allocator *allocator, lzma_block *block); - -#endif diff --git a/deps/lzma/liblzma/common/block_header_decoder.c b/deps/lzma/liblzma/common/block_header_decoder.c deleted file mode 100644 index 2c9573e..0000000 --- a/deps/lzma/liblzma/common/block_header_decoder.c +++ /dev/null @@ -1,116 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file block_header_decoder.c -/// \brief Decodes Block Header from .xz files -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "common.h" -#include "check.h" - - -static void -free_properties(lzma_block *block, lzma_allocator *allocator) -{ - // Free allocated filter options. The last array member is not - // touched after the initialization in the beginning of - // lzma_block_header_decode(), so we don't need to touch that here. - for (size_t i = 0; i < LZMA_FILTERS_MAX; ++i) { - lzma_free(block->filters[i].options, allocator); - block->filters[i].id = LZMA_VLI_UNKNOWN; - block->filters[i].options = NULL; - } - - return; -} - - -extern LZMA_API(lzma_ret) -lzma_block_header_decode(lzma_block *block, - lzma_allocator *allocator, const uint8_t *in) -{ - // NOTE: We consider the header to be corrupt not only when the - // CRC32 doesn't match, but also when variable-length integers - // are invalid or over 63 bits, or if the header is too small - // to contain the claimed information. - - // Initialize the filter options array. This way the caller can - // safely free() the options even if an error occurs in this function. - for (size_t i = 0; i <= LZMA_FILTERS_MAX; ++i) { - block->filters[i].id = LZMA_VLI_UNKNOWN; - block->filters[i].options = NULL; - } - - // Always zero for now. - block->version = 0; - - // Validate Block Header Size and Check type. The caller must have - // already set these, so it is a programming error if this test fails. - if (lzma_block_header_size_decode(in[0]) != block->header_size - || (unsigned int)(block->check) > LZMA_CHECK_ID_MAX) - return LZMA_PROG_ERROR; - - // Exclude the CRC32 field. - const size_t in_size = block->header_size - 4; - - // Verify CRC32 - if (lzma_crc32(in, in_size, 0) != unaligned_read32le(in + in_size)) - return LZMA_DATA_ERROR; - - // Check for unsupported flags. - if (in[1] & 0x3C) - return LZMA_OPTIONS_ERROR; - - // Start after the Block Header Size and Block Flags fields. - size_t in_pos = 2; - - // Compressed Size - if (in[1] & 0x40) { - return_if_error(lzma_vli_decode(&block->compressed_size, - NULL, in, &in_pos, in_size)); - - // Validate Compressed Size. This checks that it isn't zero - // and that the total size of the Block is a valid VLI. - if (lzma_block_unpadded_size(block) == 0) - return LZMA_DATA_ERROR; - } else { - block->compressed_size = LZMA_VLI_UNKNOWN; - } - - // Uncompressed Size - if (in[1] & 0x80) - return_if_error(lzma_vli_decode(&block->uncompressed_size, - NULL, in, &in_pos, in_size)); - else - block->uncompressed_size = LZMA_VLI_UNKNOWN; - - // Filter Flags - const size_t filter_count = (in[1] & 3) + 1; - for (size_t i = 0; i < filter_count; ++i) { - const lzma_ret ret = lzma_filter_flags_decode( - &block->filters[i], allocator, - in, &in_pos, in_size); - if (ret != LZMA_OK) { - free_properties(block, allocator); - return ret; - } - } - - // Padding - while (in_pos < in_size) { - if (in[in_pos++] != 0x00) { - free_properties(block, allocator); - - // Possibly some new field present so use - // LZMA_OPTIONS_ERROR instead of LZMA_DATA_ERROR. - return LZMA_OPTIONS_ERROR; - } - } - - return LZMA_OK; -} diff --git a/deps/lzma/liblzma/common/block_header_encoder.c b/deps/lzma/liblzma/common/block_header_encoder.c deleted file mode 100644 index 707dd0c..0000000 --- a/deps/lzma/liblzma/common/block_header_encoder.c +++ /dev/null @@ -1,132 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file block_header_encoder.c -/// \brief Encodes Block Header for .xz files -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "common.h" -#include "check.h" - - -extern LZMA_API(lzma_ret) -lzma_block_header_size(lzma_block *block) -{ - if (block->version != 0) - return LZMA_OPTIONS_ERROR; - - // Block Header Size + Block Flags + CRC32. - uint32_t size = 1 + 1 + 4; - - // Compressed Size - if (block->compressed_size != LZMA_VLI_UNKNOWN) { - const uint32_t add = lzma_vli_size(block->compressed_size); - if (add == 0 || block->compressed_size == 0) - return LZMA_PROG_ERROR; - - size += add; - } - - // Uncompressed Size - if (block->uncompressed_size != LZMA_VLI_UNKNOWN) { - const uint32_t add = lzma_vli_size(block->uncompressed_size); - if (add == 0) - return LZMA_PROG_ERROR; - - size += add; - } - - // List of Filter Flags - if (block->filters == NULL || block->filters[0].id == LZMA_VLI_UNKNOWN) - return LZMA_PROG_ERROR; - - for (size_t i = 0; block->filters[i].id != LZMA_VLI_UNKNOWN; ++i) { - // Don't allow too many filters. - if (i == LZMA_FILTERS_MAX) - return LZMA_PROG_ERROR; - - uint32_t add; - return_if_error(lzma_filter_flags_size(&add, - block->filters + i)); - - size += add; - } - - // Pad to a multiple of four bytes. - block->header_size = (size + 3) & ~UINT32_C(3); - - // NOTE: We don't verify that the encoded size of the Block stays - // within limits. This is because it is possible that we are called - // with exaggerated Compressed Size (e.g. LZMA_VLI_MAX) to reserve - // space for Block Header, and later called again with lower, - // real values. - - return LZMA_OK; -} - - -extern LZMA_API(lzma_ret) -lzma_block_header_encode(const lzma_block *block, uint8_t *out) -{ - // Validate everything but filters. - if (lzma_block_unpadded_size(block) == 0 - || !lzma_vli_is_valid(block->uncompressed_size)) - return LZMA_PROG_ERROR; - - // Indicate the size of the buffer _excluding_ the CRC32 field. - const size_t out_size = block->header_size - 4; - - // Store the Block Header Size. - out[0] = out_size / 4; - - // We write Block Flags in pieces. - out[1] = 0x00; - size_t out_pos = 2; - - // Compressed Size - if (block->compressed_size != LZMA_VLI_UNKNOWN) { - return_if_error(lzma_vli_encode(block->compressed_size, NULL, - out, &out_pos, out_size)); - - out[1] |= 0x40; - } - - // Uncompressed Size - if (block->uncompressed_size != LZMA_VLI_UNKNOWN) { - return_if_error(lzma_vli_encode(block->uncompressed_size, NULL, - out, &out_pos, out_size)); - - out[1] |= 0x80; - } - - // Filter Flags - if (block->filters == NULL || block->filters[0].id == LZMA_VLI_UNKNOWN) - return LZMA_PROG_ERROR; - - size_t filter_count = 0; - do { - // There can be a maximum of four filters. - if (filter_count == LZMA_FILTERS_MAX) - return LZMA_PROG_ERROR; - - return_if_error(lzma_filter_flags_encode( - block->filters + filter_count, - out, &out_pos, out_size)); - - } while (block->filters[++filter_count].id != LZMA_VLI_UNKNOWN); - - out[1] |= filter_count - 1; - - // Padding - memzero(out + out_pos, out_size - out_pos); - - // CRC32 - unaligned_write32le(out + out_size, lzma_crc32(out, out_size, 0)); - - return LZMA_OK; -} diff --git a/deps/lzma/liblzma/common/block_util.c b/deps/lzma/liblzma/common/block_util.c deleted file mode 100644 index 62c9345..0000000 --- a/deps/lzma/liblzma/common/block_util.c +++ /dev/null @@ -1,90 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file block_header.c -/// \brief Utility functions to handle lzma_block -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "common.h" -#include "index.h" - - -extern LZMA_API(lzma_ret) -lzma_block_compressed_size(lzma_block *block, lzma_vli unpadded_size) -{ - // Validate everything but Uncompressed Size and filters. - if (lzma_block_unpadded_size(block) == 0) - return LZMA_PROG_ERROR; - - const uint32_t container_size = block->header_size - + lzma_check_size(block->check); - - // Validate that Compressed Size will be greater than zero. - if (unpadded_size <= container_size) - return LZMA_DATA_ERROR; - - // Calculate what Compressed Size is supposed to be. - // If Compressed Size was present in Block Header, - // compare that the new value matches it. - const lzma_vli compressed_size = unpadded_size - container_size; - if (block->compressed_size != LZMA_VLI_UNKNOWN - && block->compressed_size != compressed_size) - return LZMA_DATA_ERROR; - - block->compressed_size = compressed_size; - - return LZMA_OK; -} - - -extern LZMA_API(lzma_vli) -lzma_block_unpadded_size(const lzma_block *block) -{ - // Validate the values that we are interested in i.e. all but - // Uncompressed Size and the filters. - // - // NOTE: This function is used for validation too, so it is - // essential that these checks are always done even if - // Compressed Size is unknown. - if (block == NULL || block->version != 0 - || block->header_size < LZMA_BLOCK_HEADER_SIZE_MIN - || block->header_size > LZMA_BLOCK_HEADER_SIZE_MAX - || (block->header_size & 3) - || !lzma_vli_is_valid(block->compressed_size) - || block->compressed_size == 0 - || (unsigned int)(block->check) > LZMA_CHECK_ID_MAX) - return 0; - - // If Compressed Size is unknown, return that we cannot know - // size of the Block either. - if (block->compressed_size == LZMA_VLI_UNKNOWN) - return LZMA_VLI_UNKNOWN; - - // Calculate Unpadded Size and validate it. - const lzma_vli unpadded_size = block->compressed_size - + block->header_size - + lzma_check_size(block->check); - - assert(unpadded_size >= UNPADDED_SIZE_MIN); - if (unpadded_size > UNPADDED_SIZE_MAX) - return 0; - - return unpadded_size; -} - - -extern LZMA_API(lzma_vli) -lzma_block_total_size(const lzma_block *block) -{ - lzma_vli unpadded_size = lzma_block_unpadded_size(block); - - if (unpadded_size != LZMA_VLI_UNKNOWN) - unpadded_size = vli_ceil4(unpadded_size); - - return unpadded_size; -} diff --git a/deps/lzma/liblzma/common/common.c b/deps/lzma/liblzma/common/common.c deleted file mode 100644 index b9e3860..0000000 --- a/deps/lzma/liblzma/common/common.c +++ /dev/null @@ -1,388 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file common.h -/// \brief Common functions needed in many places in liblzma -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "common.h" - - -///////////// -// Version // -///////////// - -extern LZMA_API(uint32_t) -lzma_version_number(void) -{ - return LZMA_VERSION; -} - - -extern LZMA_API(const char *) -lzma_version_string(void) -{ - return LZMA_VERSION_STRING; -} - - -/////////////////////// -// Memory allocation // -/////////////////////// - -extern void * lzma_attribute((__malloc__)) lzma_attr_alloc_size(1) -lzma_alloc(size_t size, lzma_allocator *allocator) -{ - // Some malloc() variants return NULL if called with size == 0. - if (size == 0) - size = 1; - - void *ptr; - - if (allocator != NULL && allocator->alloc != NULL) - ptr = allocator->alloc(allocator->opaque, 1, size); - else - ptr = malloc(size); - - return ptr; -} - - -extern void -lzma_free(void *ptr, lzma_allocator *allocator) -{ - if (allocator != NULL && allocator->free != NULL) - allocator->free(allocator->opaque, ptr); - else - free(ptr); - - return; -} - - -////////// -// Misc // -////////// - -extern size_t -lzma_bufcpy(const uint8_t *restrict in, size_t *restrict in_pos, - size_t in_size, uint8_t *restrict out, - size_t *restrict out_pos, size_t out_size) -{ - const size_t in_avail = in_size - *in_pos; - const size_t out_avail = out_size - *out_pos; - const size_t copy_size = my_min(in_avail, out_avail); - - memcpy(out + *out_pos, in + *in_pos, copy_size); - - *in_pos += copy_size; - *out_pos += copy_size; - - return copy_size; -} - - -extern lzma_ret -lzma_next_filter_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters) -{ - lzma_next_coder_init(filters[0].init, next, allocator); - next->id = filters[0].id; - return filters[0].init == NULL - ? LZMA_OK : filters[0].init(next, allocator, filters); -} - - -extern lzma_ret -lzma_next_filter_update(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter *reversed_filters) -{ - // Check that the application isn't trying to change the Filter ID. - // End of filters is indicated with LZMA_VLI_UNKNOWN in both - // reversed_filters[0].id and next->id. - if (reversed_filters[0].id != next->id) - return LZMA_PROG_ERROR; - - if (reversed_filters[0].id == LZMA_VLI_UNKNOWN) - return LZMA_OK; - - assert(next->update != NULL); - return next->update(next->coder, allocator, NULL, reversed_filters); -} - - -extern void -lzma_next_end(lzma_next_coder *next, lzma_allocator *allocator) -{ - if (next->init != (uintptr_t)(NULL)) { - // To avoid tiny end functions that simply call - // lzma_free(coder, allocator), we allow leaving next->end - // NULL and call lzma_free() here. - if (next->end != NULL) - next->end(next->coder, allocator); - else - lzma_free(next->coder, allocator); - - // Reset the variables so the we don't accidentally think - // that it is an already initialized coder. - *next = LZMA_NEXT_CODER_INIT; - } - - return; -} - - -////////////////////////////////////// -// External to internal API wrapper // -////////////////////////////////////// - -extern lzma_ret -lzma_strm_init(lzma_stream *strm) -{ - if (strm == NULL) - return LZMA_PROG_ERROR; - - if (strm->internal == NULL) { - strm->internal = lzma_alloc(sizeof(lzma_internal), - strm->allocator); - if (strm->internal == NULL) - return LZMA_MEM_ERROR; - - strm->internal->next = LZMA_NEXT_CODER_INIT; - } - - strm->internal->supported_actions[LZMA_RUN] = false; - strm->internal->supported_actions[LZMA_SYNC_FLUSH] = false; - strm->internal->supported_actions[LZMA_FULL_FLUSH] = false; - strm->internal->supported_actions[LZMA_FINISH] = false; - strm->internal->sequence = ISEQ_RUN; - strm->internal->allow_buf_error = false; - - strm->total_in = 0; - strm->total_out = 0; - - return LZMA_OK; -} - - -extern LZMA_API(lzma_ret) -lzma_code(lzma_stream *strm, lzma_action action) -{ - // Sanity checks - if ((strm->next_in == NULL && strm->avail_in != 0) - || (strm->next_out == NULL && strm->avail_out != 0) - || strm->internal == NULL - || strm->internal->next.code == NULL - || (unsigned int)(action) > LZMA_FINISH - || !strm->internal->supported_actions[action]) - return LZMA_PROG_ERROR; - - // Check if unsupported members have been set to non-zero or non-NULL, - // which would indicate that some new feature is wanted. - if (strm->reserved_ptr1 != NULL - || strm->reserved_ptr2 != NULL - || strm->reserved_ptr3 != NULL - || strm->reserved_ptr4 != NULL - || strm->reserved_int1 != 0 - || strm->reserved_int2 != 0 - || strm->reserved_int3 != 0 - || strm->reserved_int4 != 0 - || strm->reserved_enum1 != LZMA_RESERVED_ENUM - || strm->reserved_enum2 != LZMA_RESERVED_ENUM) - return LZMA_OPTIONS_ERROR; - - switch (strm->internal->sequence) { - case ISEQ_RUN: - switch (action) { - case LZMA_RUN: - break; - - case LZMA_SYNC_FLUSH: - strm->internal->sequence = ISEQ_SYNC_FLUSH; - break; - - case LZMA_FULL_FLUSH: - strm->internal->sequence = ISEQ_FULL_FLUSH; - break; - - case LZMA_FINISH: - strm->internal->sequence = ISEQ_FINISH; - break; - } - - break; - - case ISEQ_SYNC_FLUSH: - // The same action must be used until we return - // LZMA_STREAM_END, and the amount of input must not change. - if (action != LZMA_SYNC_FLUSH - || strm->internal->avail_in != strm->avail_in) - return LZMA_PROG_ERROR; - - break; - - case ISEQ_FULL_FLUSH: - if (action != LZMA_FULL_FLUSH - || strm->internal->avail_in != strm->avail_in) - return LZMA_PROG_ERROR; - - break; - - case ISEQ_FINISH: - if (action != LZMA_FINISH - || strm->internal->avail_in != strm->avail_in) - return LZMA_PROG_ERROR; - - break; - - case ISEQ_END: - return LZMA_STREAM_END; - - case ISEQ_ERROR: - default: - return LZMA_PROG_ERROR; - } - - size_t in_pos = 0; - size_t out_pos = 0; - lzma_ret ret = strm->internal->next.code( - strm->internal->next.coder, strm->allocator, - strm->next_in, &in_pos, strm->avail_in, - strm->next_out, &out_pos, strm->avail_out, action); - - strm->next_in += in_pos; - strm->avail_in -= in_pos; - strm->total_in += in_pos; - - strm->next_out += out_pos; - strm->avail_out -= out_pos; - strm->total_out += out_pos; - - strm->internal->avail_in = strm->avail_in; - - switch (ret) { - case LZMA_OK: - // Don't return LZMA_BUF_ERROR when it happens the first time. - // This is to avoid returning LZMA_BUF_ERROR when avail_out - // was zero but still there was no more data left to written - // to next_out. - if (out_pos == 0 && in_pos == 0) { - if (strm->internal->allow_buf_error) - ret = LZMA_BUF_ERROR; - else - strm->internal->allow_buf_error = true; - } else { - strm->internal->allow_buf_error = false; - } - break; - - case LZMA_STREAM_END: - if (strm->internal->sequence == ISEQ_SYNC_FLUSH - || strm->internal->sequence == ISEQ_FULL_FLUSH) - strm->internal->sequence = ISEQ_RUN; - else - strm->internal->sequence = ISEQ_END; - - // Fall through - - case LZMA_NO_CHECK: - case LZMA_UNSUPPORTED_CHECK: - case LZMA_GET_CHECK: - case LZMA_MEMLIMIT_ERROR: - // Something else than LZMA_OK, but not a fatal error, - // that is, coding may be continued (except if ISEQ_END). - strm->internal->allow_buf_error = false; - break; - - default: - // All the other errors are fatal; coding cannot be continued. - assert(ret != LZMA_BUF_ERROR); - strm->internal->sequence = ISEQ_ERROR; - break; - } - - return ret; -} - - -extern LZMA_API(void) -lzma_end(lzma_stream *strm) -{ - if (strm != NULL && strm->internal != NULL) { - lzma_next_end(&strm->internal->next, strm->allocator); - lzma_free(strm->internal, strm->allocator); - strm->internal = NULL; - } - - return; -} - - -extern LZMA_API(lzma_check) -lzma_get_check(const lzma_stream *strm) -{ - // Return LZMA_CHECK_NONE if we cannot know the check type. - // It's a bug in the application if this happens. - if (strm->internal->next.get_check == NULL) - return LZMA_CHECK_NONE; - - return strm->internal->next.get_check(strm->internal->next.coder); -} - - -extern LZMA_API(uint64_t) -lzma_memusage(const lzma_stream *strm) -{ - uint64_t memusage; - uint64_t old_memlimit; - - if (strm == NULL || strm->internal == NULL - || strm->internal->next.memconfig == NULL - || strm->internal->next.memconfig( - strm->internal->next.coder, - &memusage, &old_memlimit, 0) != LZMA_OK) - return 0; - - return memusage; -} - - -extern LZMA_API(uint64_t) -lzma_memlimit_get(const lzma_stream *strm) -{ - uint64_t old_memlimit; - uint64_t memusage; - - if (strm == NULL || strm->internal == NULL - || strm->internal->next.memconfig == NULL - || strm->internal->next.memconfig( - strm->internal->next.coder, - &memusage, &old_memlimit, 0) != LZMA_OK) - return 0; - - return old_memlimit; -} - - -extern LZMA_API(lzma_ret) -lzma_memlimit_set(lzma_stream *strm, uint64_t new_memlimit) -{ - // Dummy variables to simplify memconfig functions - uint64_t old_memlimit; - uint64_t memusage; - - if (strm == NULL || strm->internal == NULL - || strm->internal->next.memconfig == NULL) - return LZMA_PROG_ERROR; - - if (new_memlimit != 0 && new_memlimit < LZMA_MEMUSAGE_BASE) - return LZMA_MEMLIMIT_ERROR; - - return strm->internal->next.memconfig(strm->internal->next.coder, - &memusage, &old_memlimit, new_memlimit); -} diff --git a/deps/lzma/liblzma/common/common.h b/deps/lzma/liblzma/common/common.h deleted file mode 100644 index 45aba4f..0000000 --- a/deps/lzma/liblzma/common/common.h +++ /dev/null @@ -1,284 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file common.h -/// \brief Definitions common to the whole liblzma library -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_COMMON_H -#define LZMA_COMMON_H - -#include "sysdefs.h" -#include "mythread.h" -#include "tuklib_integer.h" - -#if defined(_WIN32) || defined(__CYGWIN__) -# ifdef DLL_EXPORT -# define LZMA_API_EXPORT __declspec(dllexport) -# else -# define LZMA_API_EXPORT -# endif -// Don't use ifdef or defined() below. -#elif HAVE_VISIBILITY -# define LZMA_API_EXPORT __attribute__((__visibility__("default"))) -#else -# define LZMA_API_EXPORT -#endif - -#define LZMA_API(type) LZMA_API_EXPORT type LZMA_API_CALL - -#include "lzma.h" - -// These allow helping the compiler in some often-executed branches, whose -// result is almost always the same. -#ifdef __GNUC__ -# define likely(expr) __builtin_expect(expr, true) -# define unlikely(expr) __builtin_expect(expr, false) -#else -# define likely(expr) (expr) -# define unlikely(expr) (expr) -#endif - - -/// Size of temporary buffers needed in some filters -#define LZMA_BUFFER_SIZE 4096 - - -/// Starting value for memory usage estimates. Instead of calculating size -/// of _every_ structure and taking into account malloc() overhead etc., we -/// add a base size to all memory usage estimates. It's not very accurate -/// but should be easily good enough. -#define LZMA_MEMUSAGE_BASE (UINT64_C(1) << 15) - -/// Start of internal Filter ID space. These IDs must never be used -/// in Streams. -#define LZMA_FILTER_RESERVED_START (LZMA_VLI_C(1) << 62) - - -/// Supported flags that can be passed to lzma_stream_decoder() -/// or lzma_auto_decoder(). -#define LZMA_SUPPORTED_FLAGS \ - ( LZMA_TELL_NO_CHECK \ - | LZMA_TELL_UNSUPPORTED_CHECK \ - | LZMA_TELL_ANY_CHECK \ - | LZMA_CONCATENATED ) - - -/// Type of encoder/decoder specific data; the actual structure is defined -/// differently in different coders. -typedef struct lzma_coder_s lzma_coder; - -typedef struct lzma_next_coder_s lzma_next_coder; - -typedef struct lzma_filter_info_s lzma_filter_info; - - -/// Type of a function used to initialize a filter encoder or decoder -typedef lzma_ret (*lzma_init_function)( - lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters); - -/// Type of a function to do some kind of coding work (filters, Stream, -/// Block encoders/decoders etc.). Some special coders use don't use both -/// input and output buffers, but for simplicity they still use this same -/// function prototype. -typedef lzma_ret (*lzma_code_function)( - lzma_coder *coder, lzma_allocator *allocator, - const uint8_t *restrict in, size_t *restrict in_pos, - size_t in_size, uint8_t *restrict out, - size_t *restrict out_pos, size_t out_size, - lzma_action action); - -/// Type of a function to free the memory allocated for the coder -typedef void (*lzma_end_function)( - lzma_coder *coder, lzma_allocator *allocator); - - -/// Raw coder validates and converts an array of lzma_filter structures to -/// an array of lzma_filter_info structures. This array is used with -/// lzma_next_filter_init to initialize the filter chain. -struct lzma_filter_info_s { - /// Filter ID. This is used only by the encoder - /// with lzma_filters_update(). - lzma_vli id; - - /// Pointer to function used to initialize the filter. - /// This is NULL to indicate end of array. - lzma_init_function init; - - /// Pointer to filter's options structure - void *options; -}; - - -/// Hold data and function pointers of the next filter in the chain. -struct lzma_next_coder_s { - /// Pointer to coder-specific data - lzma_coder *coder; - - /// Filter ID. This is LZMA_VLI_UNKNOWN when this structure doesn't - /// point to a filter coder. - lzma_vli id; - - /// "Pointer" to init function. This is never called here. - /// We need only to detect if we are initializing a coder - /// that was allocated earlier. See lzma_next_coder_init and - /// lzma_next_strm_init macros in this file. - uintptr_t init; - - /// Pointer to function to do the actual coding - lzma_code_function code; - - /// Pointer to function to free lzma_next_coder.coder. This can - /// be NULL; in that case, lzma_free is called to free - /// lzma_next_coder.coder. - lzma_end_function end; - - /// Pointer to function to return the type of the integrity check. - /// Most coders won't support this. - lzma_check (*get_check)(const lzma_coder *coder); - - /// Pointer to function to get and/or change the memory usage limit. - /// If new_memlimit == 0, the limit is not changed. - lzma_ret (*memconfig)(lzma_coder *coder, uint64_t *memusage, - uint64_t *old_memlimit, uint64_t new_memlimit); - - /// Update the filter-specific options or the whole filter chain - /// in the encoder. - lzma_ret (*update)(lzma_coder *coder, lzma_allocator *allocator, - const lzma_filter *filters, - const lzma_filter *reversed_filters); -}; - - -/// Macro to initialize lzma_next_coder structure -#define LZMA_NEXT_CODER_INIT \ - (lzma_next_coder){ \ - .coder = NULL, \ - .init = (uintptr_t)(NULL), \ - .id = LZMA_VLI_UNKNOWN, \ - .code = NULL, \ - .end = NULL, \ - .get_check = NULL, \ - .memconfig = NULL, \ - .update = NULL, \ - } - - -/// Internal data for lzma_strm_init, lzma_code, and lzma_end. A pointer to -/// this is stored in lzma_stream. -struct lzma_internal_s { - /// The actual coder that should do something useful - lzma_next_coder next; - - /// Track the state of the coder. This is used to validate arguments - /// so that the actual coders can rely on e.g. that LZMA_SYNC_FLUSH - /// is used on every call to lzma_code until next.code has returned - /// LZMA_STREAM_END. - enum { - ISEQ_RUN, - ISEQ_SYNC_FLUSH, - ISEQ_FULL_FLUSH, - ISEQ_FINISH, - ISEQ_END, - ISEQ_ERROR, - } sequence; - - /// A copy of lzma_stream avail_in. This is used to verify that the - /// amount of input doesn't change once e.g. LZMA_FINISH has been - /// used. - size_t avail_in; - - /// Indicates which lzma_action values are allowed by next.code. - bool supported_actions[4]; - - /// If true, lzma_code will return LZMA_BUF_ERROR if no progress was - /// made (no input consumed and no output produced by next.code). - bool allow_buf_error; -}; - - -/// Allocates memory -extern void *lzma_alloc(size_t size, lzma_allocator *allocator) - lzma_attribute((__malloc__)) lzma_attr_alloc_size(1); - -/// Frees memory -extern void lzma_free(void *ptr, lzma_allocator *allocator); - - -/// Allocates strm->internal if it is NULL, and initializes *strm and -/// strm->internal. This function is only called via lzma_next_strm_init macro. -extern lzma_ret lzma_strm_init(lzma_stream *strm); - -/// Initializes the next filter in the chain, if any. This takes care of -/// freeing the memory of previously initialized filter if it is different -/// than the filter being initialized now. This way the actual filter -/// initialization functions don't need to use lzma_next_coder_init macro. -extern lzma_ret lzma_next_filter_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters); - -/// Update the next filter in the chain, if any. This checks that -/// the application is not trying to change the Filter IDs. -extern lzma_ret lzma_next_filter_update( - lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter *reversed_filters); - -/// Frees the memory allocated for next->coder either using next->end or, -/// if next->end is NULL, using lzma_free. -extern void lzma_next_end(lzma_next_coder *next, lzma_allocator *allocator); - - -/// Copy as much data as possible from in[] to out[] and update *in_pos -/// and *out_pos accordingly. Returns the number of bytes copied. -extern size_t lzma_bufcpy(const uint8_t *restrict in, size_t *restrict in_pos, - size_t in_size, uint8_t *restrict out, - size_t *restrict out_pos, size_t out_size); - - -/// \brief Return if expression doesn't evaluate to LZMA_OK -/// -/// There are several situations where we want to return immediately -/// with the value of expr if it isn't LZMA_OK. This macro shortens -/// the code a little. -#define return_if_error(expr) \ -do { \ - const lzma_ret ret_ = (expr); \ - if (ret_ != LZMA_OK) \ - return ret_; \ -} while (0) - - -/// If next isn't already initialized, free the previous coder. Then mark -/// that next is _possibly_ initialized for the coder using this macro. -/// "Possibly" means that if e.g. allocation of next->coder fails, the -/// structure isn't actually initialized for this coder, but leaving -/// next->init to func is still OK. -#define lzma_next_coder_init(func, next, allocator) \ -do { \ - if ((uintptr_t)(func) != (next)->init) \ - lzma_next_end(next, allocator); \ - (next)->init = (uintptr_t)(func); \ -} while (0) - - -/// Initializes lzma_strm and calls func() to initialize strm->internal->next. -/// (The function being called will use lzma_next_coder_init()). If -/// initialization fails, memory that wasn't freed by func() is freed -/// along strm->internal. -#define lzma_next_strm_init(func, strm, ...) \ -do { \ - return_if_error(lzma_strm_init(strm)); \ - const lzma_ret ret_ = func(&(strm)->internal->next, \ - (strm)->allocator, __VA_ARGS__); \ - if (ret_ != LZMA_OK) { \ - lzma_end(strm); \ - return ret_; \ - } \ -} while (0) - -#endif diff --git a/deps/lzma/liblzma/common/easy_buffer_encoder.c b/deps/lzma/liblzma/common/easy_buffer_encoder.c deleted file mode 100644 index c4be34c..0000000 --- a/deps/lzma/liblzma/common/easy_buffer_encoder.c +++ /dev/null @@ -1,27 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file easy_buffer_encoder.c -/// \brief Easy single-call .xz Stream encoder -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "easy_preset.h" - - -extern LZMA_API(lzma_ret) -lzma_easy_buffer_encode(uint32_t preset, lzma_check check, - lzma_allocator *allocator, const uint8_t *in, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) -{ - lzma_options_easy opt_easy; - if (lzma_easy_preset(&opt_easy, preset)) - return LZMA_OPTIONS_ERROR; - - return lzma_stream_buffer_encode(opt_easy.filters, check, - allocator, in, in_size, out, out_pos, out_size); -} diff --git a/deps/lzma/liblzma/common/easy_decoder_memusage.c b/deps/lzma/liblzma/common/easy_decoder_memusage.c deleted file mode 100644 index 20bcd5b..0000000 --- a/deps/lzma/liblzma/common/easy_decoder_memusage.c +++ /dev/null @@ -1,24 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file easy_decoder_memusage.c -/// \brief Decoder memory usage calculation to match easy encoder presets -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "easy_preset.h" - - -extern LZMA_API(uint64_t) -lzma_easy_decoder_memusage(uint32_t preset) -{ - lzma_options_easy opt_easy; - if (lzma_easy_preset(&opt_easy, preset)) - return UINT32_MAX; - - return lzma_raw_decoder_memusage(opt_easy.filters); -} diff --git a/deps/lzma/liblzma/common/easy_encoder.c b/deps/lzma/liblzma/common/easy_encoder.c deleted file mode 100644 index d13ccd7..0000000 --- a/deps/lzma/liblzma/common/easy_encoder.c +++ /dev/null @@ -1,25 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file easy_encoder.c -/// \brief Easy .xz Stream encoder initialization -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "easy_preset.h" -#include "stream_encoder.h" - - -extern LZMA_API(lzma_ret) -lzma_easy_encoder(lzma_stream *strm, uint32_t preset, lzma_check check) -{ - lzma_options_easy opt_easy; - if (lzma_easy_preset(&opt_easy, preset)) - return LZMA_OPTIONS_ERROR; - - return lzma_stream_encoder(strm, opt_easy.filters, check); -} diff --git a/deps/lzma/liblzma/common/easy_encoder_memusage.c b/deps/lzma/liblzma/common/easy_encoder_memusage.c deleted file mode 100644 index e910575..0000000 --- a/deps/lzma/liblzma/common/easy_encoder_memusage.c +++ /dev/null @@ -1,24 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file easy_encoder_memusage.c -/// \brief Easy .xz Stream encoder memory usage calculation -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "easy_preset.h" - - -extern LZMA_API(uint64_t) -lzma_easy_encoder_memusage(uint32_t preset) -{ - lzma_options_easy opt_easy; - if (lzma_easy_preset(&opt_easy, preset)) - return UINT32_MAX; - - return lzma_raw_encoder_memusage(opt_easy.filters); -} diff --git a/deps/lzma/liblzma/common/easy_preset.c b/deps/lzma/liblzma/common/easy_preset.c deleted file mode 100644 index 2f98598..0000000 --- a/deps/lzma/liblzma/common/easy_preset.c +++ /dev/null @@ -1,27 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file easy_preset.c -/// \brief Preset handling for easy encoder and decoder -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "easy_preset.h" - - -extern bool -lzma_easy_preset(lzma_options_easy *opt_easy, uint32_t preset) -{ - if (lzma_lzma_preset(&opt_easy->opt_lzma, preset)) - return true; - - opt_easy->filters[0].id = LZMA_FILTER_LZMA2; - opt_easy->filters[0].options = &opt_easy->opt_lzma; - opt_easy->filters[1].id = LZMA_VLI_UNKNOWN; - - return false; -} diff --git a/deps/lzma/liblzma/common/easy_preset.h b/deps/lzma/liblzma/common/easy_preset.h deleted file mode 100644 index 382ade8..0000000 --- a/deps/lzma/liblzma/common/easy_preset.h +++ /dev/null @@ -1,32 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file easy_preset.h -/// \brief Preset handling for easy encoder and decoder -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "common.h" - - -typedef struct { - /// We need to keep the filters array available in case - /// LZMA_FULL_FLUSH is used. - lzma_filter filters[LZMA_FILTERS_MAX + 1]; - - /// Options for LZMA2 - lzma_options_lzma opt_lzma; - - // Options for more filters can be added later, so this struct - // is not ready to be put into the public API. - -} lzma_options_easy; - - -/// Set *easy to the settings given by the preset. Returns true on error, -/// false on success. -extern bool lzma_easy_preset(lzma_options_easy *easy, uint32_t preset); diff --git a/deps/lzma/liblzma/common/filter_buffer_decoder.c b/deps/lzma/liblzma/common/filter_buffer_decoder.c deleted file mode 100644 index 2d35ef8..0000000 --- a/deps/lzma/liblzma/common/filter_buffer_decoder.c +++ /dev/null @@ -1,87 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file filter_buffer_decoder.c -/// \brief Single-call raw decoding -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "filter_decoder.h" - - -extern LZMA_API(lzma_ret) -lzma_raw_buffer_decode(const lzma_filter *filters, lzma_allocator *allocator, - const uint8_t *in, size_t *in_pos, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) -{ - // Validate what isn't validated later in filter_common.c. - if (in == NULL || in_pos == NULL || *in_pos > in_size || out == NULL - || out_pos == NULL || *out_pos > out_size) - return LZMA_PROG_ERROR; - - // Initialize the decoer. - lzma_next_coder next = LZMA_NEXT_CODER_INIT; - return_if_error(lzma_raw_decoder_init(&next, allocator, filters)); - - // Store the positions so that we can restore them if something - // goes wrong. - const size_t in_start = *in_pos; - const size_t out_start = *out_pos; - - // Do the actual decoding and free decoder's memory. - lzma_ret ret = next.code(next.coder, allocator, in, in_pos, in_size, - out, out_pos, out_size, LZMA_FINISH); - - if (ret == LZMA_STREAM_END) { - ret = LZMA_OK; - } else { - if (ret == LZMA_OK) { - // Either the input was truncated or the - // output buffer was too small. - assert(*in_pos == in_size || *out_pos == out_size); - - if (*in_pos != in_size) { - // Since input wasn't consumed completely, - // the output buffer became full and is - // too small. - ret = LZMA_BUF_ERROR; - - } else if (*out_pos != out_size) { - // Since output didn't became full, the input - // has to be truncated. - ret = LZMA_DATA_ERROR; - - } else { - // All the input was consumed and output - // buffer is full. Now we don't immediately - // know the reason for the error. Try - // decoding one more byte. If it succeeds, - // then the output buffer was too small. If - // we cannot get a new output byte, the input - // is truncated. - uint8_t tmp[1]; - size_t tmp_pos = 0; - (void)next.code(next.coder, allocator, - in, in_pos, in_size, - tmp, &tmp_pos, 1, LZMA_FINISH); - - if (tmp_pos == 1) - ret = LZMA_BUF_ERROR; - else - ret = LZMA_DATA_ERROR; - } - } - - // Restore the positions. - *in_pos = in_start; - *out_pos = out_start; - } - - lzma_next_end(&next, allocator); - - return ret; -} diff --git a/deps/lzma/liblzma/common/filter_buffer_encoder.c b/deps/lzma/liblzma/common/filter_buffer_encoder.c deleted file mode 100644 index 646e1b3..0000000 --- a/deps/lzma/liblzma/common/filter_buffer_encoder.c +++ /dev/null @@ -1,54 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file filter_buffer_encoder.c -/// \brief Single-call raw encoding -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "filter_encoder.h" - - -extern LZMA_API(lzma_ret) -lzma_raw_buffer_encode(const lzma_filter *filters, lzma_allocator *allocator, - const uint8_t *in, size_t in_size, uint8_t *out, - size_t *out_pos, size_t out_size) -{ - // Validate what isn't validated later in filter_common.c. - if ((in == NULL && in_size != 0) || out == NULL - || out_pos == NULL || *out_pos > out_size) - return LZMA_PROG_ERROR; - - // Initialize the encoder - lzma_next_coder next = LZMA_NEXT_CODER_INIT; - return_if_error(lzma_raw_encoder_init(&next, allocator, filters)); - - // Store the output position so that we can restore it if - // something goes wrong. - const size_t out_start = *out_pos; - - // Do the actual encoding and free coder's memory. - size_t in_pos = 0; - lzma_ret ret = next.code(next.coder, allocator, in, &in_pos, in_size, - out, out_pos, out_size, LZMA_FINISH); - lzma_next_end(&next, allocator); - - if (ret == LZMA_STREAM_END) { - ret = LZMA_OK; - } else { - if (ret == LZMA_OK) { - // Output buffer was too small. - assert(*out_pos == out_size); - ret = LZMA_BUF_ERROR; - } - - // Restore the output position. - *out_pos = out_start; - } - - return ret; -} diff --git a/deps/lzma/liblzma/common/filter_common.c b/deps/lzma/liblzma/common/filter_common.c deleted file mode 100644 index 7c95b05..0000000 --- a/deps/lzma/liblzma/common/filter_common.c +++ /dev/null @@ -1,337 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file filter_common.c -/// \brief Filter-specific stuff common for both encoder and decoder -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "filter_common.h" - - -static const struct { - /// Filter ID - lzma_vli id; - - /// Size of the filter-specific options structure - size_t options_size; - - /// True if it is OK to use this filter as non-last filter in - /// the chain. - bool non_last_ok; - - /// True if it is OK to use this filter as the last filter in - /// the chain. - bool last_ok; - - /// True if the filter may change the size of the data (that is, the - /// amount of encoded output can be different than the amount of - /// uncompressed input). - bool changes_size; - -} features[] = { -#if defined (HAVE_ENCODER_LZMA1) || defined(HAVE_DECODER_LZMA1) - { - .id = LZMA_FILTER_LZMA1, - .options_size = sizeof(lzma_options_lzma), - .non_last_ok = false, - .last_ok = true, - .changes_size = true, - }, -#endif -#if defined(HAVE_ENCODER_LZMA2) || defined(HAVE_DECODER_LZMA2) - { - .id = LZMA_FILTER_LZMA2, - .options_size = sizeof(lzma_options_lzma), - .non_last_ok = false, - .last_ok = true, - .changes_size = true, - }, -#endif -#if defined(HAVE_ENCODER_X86) || defined(HAVE_DECODER_X86) - { - .id = LZMA_FILTER_X86, - .options_size = sizeof(lzma_options_bcj), - .non_last_ok = true, - .last_ok = false, - .changes_size = false, - }, -#endif -#if defined(HAVE_ENCODER_POWERPC) || defined(HAVE_DECODER_POWERPC) - { - .id = LZMA_FILTER_POWERPC, - .options_size = sizeof(lzma_options_bcj), - .non_last_ok = true, - .last_ok = false, - .changes_size = false, - }, -#endif -#if defined(HAVE_ENCODER_IA64) || defined(HAVE_DECODER_IA64) - { - .id = LZMA_FILTER_IA64, - .options_size = sizeof(lzma_options_bcj), - .non_last_ok = true, - .last_ok = false, - .changes_size = false, - }, -#endif -#if defined(HAVE_ENCODER_ARM) || defined(HAVE_DECODER_ARM) - { - .id = LZMA_FILTER_ARM, - .options_size = sizeof(lzma_options_bcj), - .non_last_ok = true, - .last_ok = false, - .changes_size = false, - }, -#endif -#if defined(HAVE_ENCODER_ARMTHUMB) || defined(HAVE_DECODER_ARMTHUMB) - { - .id = LZMA_FILTER_ARMTHUMB, - .options_size = sizeof(lzma_options_bcj), - .non_last_ok = true, - .last_ok = false, - .changes_size = false, - }, -#endif -#if defined(HAVE_ENCODER_SPARC) || defined(HAVE_DECODER_SPARC) - { - .id = LZMA_FILTER_SPARC, - .options_size = sizeof(lzma_options_bcj), - .non_last_ok = true, - .last_ok = false, - .changes_size = false, - }, -#endif -#if defined(HAVE_ENCODER_DELTA) || defined(HAVE_DECODER_DELTA) - { - .id = LZMA_FILTER_DELTA, - .options_size = sizeof(lzma_options_delta), - .non_last_ok = true, - .last_ok = false, - .changes_size = false, - }, -#endif - { - .id = LZMA_VLI_UNKNOWN - } -}; - - -extern LZMA_API(lzma_ret) -lzma_filters_copy(const lzma_filter *src, lzma_filter *dest, - lzma_allocator *allocator) -{ - if (src == NULL || dest == NULL) - return LZMA_PROG_ERROR; - - lzma_ret ret; - size_t i; - for (i = 0; src[i].id != LZMA_VLI_UNKNOWN; ++i) { - // There must be a maximum of four filters plus - // the array terminator. - if (i == LZMA_FILTERS_MAX) { - ret = LZMA_OPTIONS_ERROR; - goto error; - } - - dest[i].id = src[i].id; - - if (src[i].options == NULL) { - dest[i].options = NULL; - } else { - // See if the filter is supported only when the - // options is not NULL. This might be convenient - // sometimes if the app is actually copying only - // a partial filter chain with a place holder ID. - // - // When options is not NULL, the Filter ID must be - // supported by us, because otherwise we don't know - // how big the options are. - size_t j; - for (j = 0; src[i].id != features[j].id; ++j) { - if (features[j].id == LZMA_VLI_UNKNOWN) { - ret = LZMA_OPTIONS_ERROR; - goto error; - } - } - - // Allocate and copy the options. - dest[i].options = lzma_alloc(features[j].options_size, - allocator); - if (dest[i].options == NULL) { - ret = LZMA_MEM_ERROR; - goto error; - } - - memcpy(dest[i].options, src[i].options, - features[j].options_size); - } - } - - // Terminate the filter array. - assert(i <= LZMA_FILTERS_MAX + 1); - dest[i].id = LZMA_VLI_UNKNOWN; - dest[i].options = NULL; - - return LZMA_OK; - -error: - // Free the options which we have already allocated. - while (i-- > 0) { - lzma_free(dest[i].options, allocator); - dest[i].options = NULL; - } - - return ret; -} - - -static lzma_ret -validate_chain(const lzma_filter *filters, size_t *count) -{ - // There must be at least one filter. - if (filters == NULL || filters[0].id == LZMA_VLI_UNKNOWN) - return LZMA_PROG_ERROR; - - // Number of non-last filters that may change the size of the data - // significantly (that is, more than 1-2 % or so). - size_t changes_size_count = 0; - - // True if it is OK to add a new filter after the current filter. - bool non_last_ok = true; - - // True if the last filter in the given chain is actually usable as - // the last filter. Only filters that support embedding End of Payload - // Marker can be used as the last filter in the chain. - bool last_ok = false; - - size_t i = 0; - do { - size_t j; - for (j = 0; filters[i].id != features[j].id; ++j) - if (features[j].id == LZMA_VLI_UNKNOWN) - return LZMA_OPTIONS_ERROR; - - // If the previous filter in the chain cannot be a non-last - // filter, the chain is invalid. - if (!non_last_ok) - return LZMA_OPTIONS_ERROR; - - non_last_ok = features[j].non_last_ok; - last_ok = features[j].last_ok; - changes_size_count += features[j].changes_size; - - } while (filters[++i].id != LZMA_VLI_UNKNOWN); - - // There must be 1-4 filters. The last filter must be usable as - // the last filter in the chain. A maximum of three filters are - // allowed to change the size of the data. - if (i > LZMA_FILTERS_MAX || !last_ok || changes_size_count > 3) - return LZMA_OPTIONS_ERROR; - - *count = i; - return LZMA_OK; -} - - -extern lzma_ret -lzma_raw_coder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter *options, - lzma_filter_find coder_find, bool is_encoder) -{ - // Do some basic validation and get the number of filters. - size_t count; - return_if_error(validate_chain(options, &count)); - - // Set the filter functions and copy the options pointer. - lzma_filter_info filters[LZMA_FILTERS_MAX + 1]; - if (is_encoder) { - for (size_t i = 0; i < count; ++i) { - // The order of the filters is reversed in the - // encoder. It allows more efficient handling - // of the uncompressed data. - const size_t j = count - i - 1; - - const lzma_filter_coder *const fc - = coder_find(options[i].id); - if (fc == NULL || fc->init == NULL) - return LZMA_OPTIONS_ERROR; - - filters[j].id = options[i].id; - filters[j].init = fc->init; - filters[j].options = options[i].options; - } - } else { - for (size_t i = 0; i < count; ++i) { - const lzma_filter_coder *const fc - = coder_find(options[i].id); - if (fc == NULL || fc->init == NULL) - return LZMA_OPTIONS_ERROR; - - filters[i].id = options[i].id; - filters[i].init = fc->init; - filters[i].options = options[i].options; - } - } - - // Terminate the array. - filters[count].id = LZMA_VLI_UNKNOWN; - filters[count].init = NULL; - - // Initialize the filters. - const lzma_ret ret = lzma_next_filter_init(next, allocator, filters); - if (ret != LZMA_OK) - lzma_next_end(next, allocator); - - return ret; -} - - -extern uint64_t -lzma_raw_coder_memusage(lzma_filter_find coder_find, - const lzma_filter *filters) -{ - // The chain has to have at least one filter. - { - size_t tmp; - if (validate_chain(filters, &tmp) != LZMA_OK) - return UINT64_MAX; - } - - uint64_t total = 0; - size_t i = 0; - - do { - const lzma_filter_coder *const fc - = coder_find(filters[i].id); - if (fc == NULL) - return UINT64_MAX; // Unsupported Filter ID - - if (fc->memusage == NULL) { - // This filter doesn't have a function to calculate - // the memory usage and validate the options. Such - // filters need only little memory, so we use 1 KiB - // as a good estimate. They also accept all possible - // options, so there's no need to worry about lack - // of validation. - total += 1024; - } else { - // Call the filter-specific memory usage calculation - // function. - const uint64_t usage - = fc->memusage(filters[i].options); - if (usage == UINT64_MAX) - return UINT64_MAX; // Invalid options - - total += usage; - } - } while (filters[++i].id != LZMA_VLI_UNKNOWN); - - // Add some fixed amount of extra. It's to compensate memory usage - // of Stream, Block etc. coders, malloc() overhead, stack etc. - return total + LZMA_MEMUSAGE_BASE; -} diff --git a/deps/lzma/liblzma/common/filter_common.h b/deps/lzma/liblzma/common/filter_common.h deleted file mode 100644 index cd61fc0..0000000 --- a/deps/lzma/liblzma/common/filter_common.h +++ /dev/null @@ -1,48 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file filter_common.c -/// \brief Filter-specific stuff common for both encoder and decoder -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_FILTER_COMMON_H -#define LZMA_FILTER_COMMON_H - -#include "common.h" - - -/// Both lzma_filter_encoder and lzma_filter_decoder begin with these members. -typedef struct { - /// Filter ID - lzma_vli id; - - /// Initializes the filter encoder and calls lzma_next_filter_init() - /// for filters + 1. - lzma_init_function init; - - /// Calculates memory usage of the encoder. If the options are - /// invalid, UINT64_MAX is returned. - uint64_t (*memusage)(const void *options); - -} lzma_filter_coder; - - -typedef const lzma_filter_coder *(*lzma_filter_find)(lzma_vli id); - - -extern lzma_ret lzma_raw_coder_init( - lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter *filters, - lzma_filter_find coder_find, bool is_encoder); - - -extern uint64_t lzma_raw_coder_memusage(lzma_filter_find coder_find, - const lzma_filter *filters); - - -#endif diff --git a/deps/lzma/liblzma/common/filter_decoder.c b/deps/lzma/liblzma/common/filter_decoder.c deleted file mode 100644 index 1ebbe2a..0000000 --- a/deps/lzma/liblzma/common/filter_decoder.c +++ /dev/null @@ -1,183 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file filter_decoder.c -/// \brief Filter ID mapping to filter-specific functions -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "filter_decoder.h" -#include "filter_common.h" -#include "lzma_decoder.h" -#include "lzma2_decoder.h" -#include "simple_decoder.h" -#include "delta_decoder.h" - - -typedef struct { - /// Filter ID - lzma_vli id; - - /// Initializes the filter encoder and calls lzma_next_filter_init() - /// for filters + 1. - lzma_init_function init; - - /// Calculates memory usage of the encoder. If the options are - /// invalid, UINT64_MAX is returned. - uint64_t (*memusage)(const void *options); - - /// Decodes Filter Properties. - /// - /// \return - LZMA_OK: Properties decoded successfully. - /// - LZMA_OPTIONS_ERROR: Unsupported properties - /// - LZMA_MEM_ERROR: Memory allocation failed. - lzma_ret (*props_decode)(void **options, lzma_allocator *allocator, - const uint8_t *props, size_t props_size); - -} lzma_filter_decoder; - - -static const lzma_filter_decoder decoders[] = { -#ifdef HAVE_DECODER_LZMA1 - { - .id = LZMA_FILTER_LZMA1, - .init = &lzma_lzma_decoder_init, - .memusage = &lzma_lzma_decoder_memusage, - .props_decode = &lzma_lzma_props_decode, - }, -#endif -#ifdef HAVE_DECODER_LZMA2 - { - .id = LZMA_FILTER_LZMA2, - .init = &lzma_lzma2_decoder_init, - .memusage = &lzma_lzma2_decoder_memusage, - .props_decode = &lzma_lzma2_props_decode, - }, -#endif -#ifdef HAVE_DECODER_X86 - { - .id = LZMA_FILTER_X86, - .init = &lzma_simple_x86_decoder_init, - .memusage = NULL, - .props_decode = &lzma_simple_props_decode, - }, -#endif -#ifdef HAVE_DECODER_POWERPC - { - .id = LZMA_FILTER_POWERPC, - .init = &lzma_simple_powerpc_decoder_init, - .memusage = NULL, - .props_decode = &lzma_simple_props_decode, - }, -#endif -#ifdef HAVE_DECODER_IA64 - { - .id = LZMA_FILTER_IA64, - .init = &lzma_simple_ia64_decoder_init, - .memusage = NULL, - .props_decode = &lzma_simple_props_decode, - }, -#endif -#ifdef HAVE_DECODER_ARM - { - .id = LZMA_FILTER_ARM, - .init = &lzma_simple_arm_decoder_init, - .memusage = NULL, - .props_decode = &lzma_simple_props_decode, - }, -#endif -#ifdef HAVE_DECODER_ARMTHUMB - { - .id = LZMA_FILTER_ARMTHUMB, - .init = &lzma_simple_armthumb_decoder_init, - .memusage = NULL, - .props_decode = &lzma_simple_props_decode, - }, -#endif -#ifdef HAVE_DECODER_SPARC - { - .id = LZMA_FILTER_SPARC, - .init = &lzma_simple_sparc_decoder_init, - .memusage = NULL, - .props_decode = &lzma_simple_props_decode, - }, -#endif -#ifdef HAVE_DECODER_DELTA - { - .id = LZMA_FILTER_DELTA, - .init = &lzma_delta_decoder_init, - .memusage = &lzma_delta_coder_memusage, - .props_decode = &lzma_delta_props_decode, - }, -#endif -}; - - -static const lzma_filter_decoder * -decoder_find(lzma_vli id) -{ - for (size_t i = 0; i < ARRAY_SIZE(decoders); ++i) - if (decoders[i].id == id) - return decoders + i; - - return NULL; -} - - -extern LZMA_API(lzma_bool) -lzma_filter_decoder_is_supported(lzma_vli id) -{ - return decoder_find(id) != NULL; -} - - -extern lzma_ret -lzma_raw_decoder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter *options) -{ - return lzma_raw_coder_init(next, allocator, - options, (lzma_filter_find)(&decoder_find), false); -} - - -extern LZMA_API(lzma_ret) -lzma_raw_decoder(lzma_stream *strm, const lzma_filter *options) -{ - lzma_next_strm_init(lzma_raw_decoder_init, strm, options); - - strm->internal->supported_actions[LZMA_RUN] = true; - strm->internal->supported_actions[LZMA_FINISH] = true; - - return LZMA_OK; -} - - -extern LZMA_API(uint64_t) -lzma_raw_decoder_memusage(const lzma_filter *filters) -{ - return lzma_raw_coder_memusage( - (lzma_filter_find)(&decoder_find), filters); -} - - -extern LZMA_API(lzma_ret) -lzma_properties_decode(lzma_filter *filter, lzma_allocator *allocator, - const uint8_t *props, size_t props_size) -{ - // Make it always NULL so that the caller can always safely free() it. - filter->options = NULL; - - const lzma_filter_decoder *const fd = decoder_find(filter->id); - if (fd == NULL) - return LZMA_OPTIONS_ERROR; - - if (fd->props_decode == NULL) - return props_size == 0 ? LZMA_OK : LZMA_OPTIONS_ERROR; - - return fd->props_decode( - &filter->options, allocator, props, props_size); -} diff --git a/deps/lzma/liblzma/common/filter_decoder.h b/deps/lzma/liblzma/common/filter_decoder.h deleted file mode 100644 index d5c68bd..0000000 --- a/deps/lzma/liblzma/common/filter_decoder.h +++ /dev/null @@ -1,23 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file filter_decoder.c -/// \brief Filter ID mapping to filter-specific functions -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_FILTER_DECODER_H -#define LZMA_FILTER_DECODER_H - -#include "common.h" - - -extern lzma_ret lzma_raw_decoder_init( - lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter *options); - -#endif diff --git a/deps/lzma/liblzma/common/filter_encoder.c b/deps/lzma/liblzma/common/filter_encoder.c deleted file mode 100644 index 635d812..0000000 --- a/deps/lzma/liblzma/common/filter_encoder.c +++ /dev/null @@ -1,288 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file filter_decoder.c -/// \brief Filter ID mapping to filter-specific functions -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "filter_encoder.h" -#include "filter_common.h" -#include "lzma_encoder.h" -#include "lzma2_encoder.h" -#include "simple_encoder.h" -#include "delta_encoder.h" - - -typedef struct { - /// Filter ID - lzma_vli id; - - /// Initializes the filter encoder and calls lzma_next_filter_init() - /// for filters + 1. - lzma_init_function init; - - /// Calculates memory usage of the encoder. If the options are - /// invalid, UINT64_MAX is returned. - uint64_t (*memusage)(const void *options); - - /// Calculates the minimum sane size for Blocks (or other types of - /// chunks) to which the input data can be split to make - /// multithreaded encoding possible. If this is NULL, it is assumed - /// that the encoder is fast enough with single thread. - lzma_vli (*chunk_size)(const void *options); - - /// Tells the size of the Filter Properties field. If options are - /// invalid, UINT32_MAX is returned. If this is NULL, props_size_fixed - /// is used. - lzma_ret (*props_size_get)(uint32_t *size, const void *options); - uint32_t props_size_fixed; - - /// Encodes Filter Properties. - /// - /// \return - LZMA_OK: Properties encoded successfully. - /// - LZMA_OPTIONS_ERROR: Unsupported options - /// - LZMA_PROG_ERROR: Invalid options or not enough - /// output space - lzma_ret (*props_encode)(const void *options, uint8_t *out); - -} lzma_filter_encoder; - - -static const lzma_filter_encoder encoders[] = { -#ifdef HAVE_ENCODER_LZMA1 - { - .id = LZMA_FILTER_LZMA1, - .init = &lzma_lzma_encoder_init, - .memusage = &lzma_lzma_encoder_memusage, - .chunk_size = NULL, // FIXME - .props_size_get = NULL, - .props_size_fixed = 5, - .props_encode = &lzma_lzma_props_encode, - }, -#endif -#ifdef HAVE_ENCODER_LZMA2 - { - .id = LZMA_FILTER_LZMA2, - .init = &lzma_lzma2_encoder_init, - .memusage = &lzma_lzma2_encoder_memusage, - .chunk_size = NULL, // FIXME - .props_size_get = NULL, - .props_size_fixed = 1, - .props_encode = &lzma_lzma2_props_encode, - }, -#endif -#ifdef HAVE_ENCODER_X86 - { - .id = LZMA_FILTER_X86, - .init = &lzma_simple_x86_encoder_init, - .memusage = NULL, - .chunk_size = NULL, - .props_size_get = &lzma_simple_props_size, - .props_encode = &lzma_simple_props_encode, - }, -#endif -#ifdef HAVE_ENCODER_POWERPC - { - .id = LZMA_FILTER_POWERPC, - .init = &lzma_simple_powerpc_encoder_init, - .memusage = NULL, - .chunk_size = NULL, - .props_size_get = &lzma_simple_props_size, - .props_encode = &lzma_simple_props_encode, - }, -#endif -#ifdef HAVE_ENCODER_IA64 - { - .id = LZMA_FILTER_IA64, - .init = &lzma_simple_ia64_encoder_init, - .memusage = NULL, - .chunk_size = NULL, - .props_size_get = &lzma_simple_props_size, - .props_encode = &lzma_simple_props_encode, - }, -#endif -#ifdef HAVE_ENCODER_ARM - { - .id = LZMA_FILTER_ARM, - .init = &lzma_simple_arm_encoder_init, - .memusage = NULL, - .chunk_size = NULL, - .props_size_get = &lzma_simple_props_size, - .props_encode = &lzma_simple_props_encode, - }, -#endif -#ifdef HAVE_ENCODER_ARMTHUMB - { - .id = LZMA_FILTER_ARMTHUMB, - .init = &lzma_simple_armthumb_encoder_init, - .memusage = NULL, - .chunk_size = NULL, - .props_size_get = &lzma_simple_props_size, - .props_encode = &lzma_simple_props_encode, - }, -#endif -#ifdef HAVE_ENCODER_SPARC - { - .id = LZMA_FILTER_SPARC, - .init = &lzma_simple_sparc_encoder_init, - .memusage = NULL, - .chunk_size = NULL, - .props_size_get = &lzma_simple_props_size, - .props_encode = &lzma_simple_props_encode, - }, -#endif -#ifdef HAVE_ENCODER_DELTA - { - .id = LZMA_FILTER_DELTA, - .init = &lzma_delta_encoder_init, - .memusage = &lzma_delta_coder_memusage, - .chunk_size = NULL, - .props_size_get = NULL, - .props_size_fixed = 1, - .props_encode = &lzma_delta_props_encode, - }, -#endif -}; - - -static const lzma_filter_encoder * -encoder_find(lzma_vli id) -{ - for (size_t i = 0; i < ARRAY_SIZE(encoders); ++i) - if (encoders[i].id == id) - return encoders + i; - - return NULL; -} - - -extern LZMA_API(lzma_bool) -lzma_filter_encoder_is_supported(lzma_vli id) -{ - return encoder_find(id) != NULL; -} - - -extern LZMA_API(lzma_ret) -lzma_filters_update(lzma_stream *strm, const lzma_filter *filters) -{ - if (strm->internal->next.update == NULL) - return LZMA_PROG_ERROR; - - // Validate the filter chain. - if (lzma_raw_encoder_memusage(filters) == UINT64_MAX) - return LZMA_OPTIONS_ERROR; - - // The actual filter chain in the encoder is reversed. Some things - // still want the normal order chain, so we provide both. - size_t count = 1; - while (filters[count].id != LZMA_VLI_UNKNOWN) - ++count; - - lzma_filter reversed_filters[LZMA_FILTERS_MAX + 1]; - for (size_t i = 0; i < count; ++i) - reversed_filters[count - i - 1] = filters[i]; - - reversed_filters[count].id = LZMA_VLI_UNKNOWN; - - return strm->internal->next.update(strm->internal->next.coder, - strm->allocator, filters, reversed_filters); -} - - -extern lzma_ret -lzma_raw_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter *options) -{ - return lzma_raw_coder_init(next, allocator, - options, (lzma_filter_find)(&encoder_find), true); -} - - -extern LZMA_API(lzma_ret) -lzma_raw_encoder(lzma_stream *strm, const lzma_filter *options) -{ - lzma_next_strm_init(lzma_raw_coder_init, strm, options, - (lzma_filter_find)(&encoder_find), true); - - strm->internal->supported_actions[LZMA_RUN] = true; - strm->internal->supported_actions[LZMA_SYNC_FLUSH] = true; - strm->internal->supported_actions[LZMA_FINISH] = true; - - return LZMA_OK; -} - - -extern LZMA_API(uint64_t) -lzma_raw_encoder_memusage(const lzma_filter *filters) -{ - return lzma_raw_coder_memusage( - (lzma_filter_find)(&encoder_find), filters); -} - - -/* -extern LZMA_API(lzma_vli) -lzma_chunk_size(const lzma_filter *filters) -{ - lzma_vli max = 0; - - for (size_t i = 0; filters[i].id != LZMA_VLI_UNKNOWN; ++i) { - const lzma_filter_encoder *const fe - = encoder_find(filters[i].id); - if (fe->chunk_size != NULL) { - const lzma_vli size - = fe->chunk_size(filters[i].options); - if (size == LZMA_VLI_UNKNOWN) - return LZMA_VLI_UNKNOWN; - - if (size > max) - max = size; - } - } - - return max; -} -*/ - - -extern LZMA_API(lzma_ret) -lzma_properties_size(uint32_t *size, const lzma_filter *filter) -{ - const lzma_filter_encoder *const fe = encoder_find(filter->id); - if (fe == NULL) { - // Unknown filter - if the Filter ID is a proper VLI, - // return LZMA_OPTIONS_ERROR instead of LZMA_PROG_ERROR, - // because it's possible that we just don't have support - // compiled in for the requested filter. - return filter->id <= LZMA_VLI_MAX - ? LZMA_OPTIONS_ERROR : LZMA_PROG_ERROR; - } - - if (fe->props_size_get == NULL) { - // No props_size_get() function, use props_size_fixed. - *size = fe->props_size_fixed; - return LZMA_OK; - } - - return fe->props_size_get(size, filter->options); -} - - -extern LZMA_API(lzma_ret) -lzma_properties_encode(const lzma_filter *filter, uint8_t *props) -{ - const lzma_filter_encoder *const fe = encoder_find(filter->id); - if (fe == NULL) - return LZMA_PROG_ERROR; - - if (fe->props_encode == NULL) - return LZMA_OK; - - return fe->props_encode(filter->options, props); -} diff --git a/deps/lzma/liblzma/common/filter_encoder.h b/deps/lzma/liblzma/common/filter_encoder.h deleted file mode 100644 index 5bc137f..0000000 --- a/deps/lzma/liblzma/common/filter_encoder.h +++ /dev/null @@ -1,27 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file filter_encoder.c -/// \brief Filter ID mapping to filter-specific functions -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_FILTER_ENCODER_H -#define LZMA_FILTER_ENCODER_H - -#include "common.h" - - -// FIXME: Might become a part of the public API once finished. -// extern lzma_vli lzma_chunk_size(const lzma_filter *filters); - - -extern lzma_ret lzma_raw_encoder_init( - lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter *filters); - -#endif diff --git a/deps/lzma/liblzma/common/filter_flags_decoder.c b/deps/lzma/liblzma/common/filter_flags_decoder.c deleted file mode 100644 index caae10c..0000000 --- a/deps/lzma/liblzma/common/filter_flags_decoder.c +++ /dev/null @@ -1,46 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file filter_flags_decoder.c -/// \brief Decodes a Filter Flags field -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "filter_decoder.h" - - -extern LZMA_API(lzma_ret) -lzma_filter_flags_decode( - lzma_filter *filter, lzma_allocator *allocator, - const uint8_t *in, size_t *in_pos, size_t in_size) -{ - // Set the pointer to NULL so the caller can always safely free it. - filter->options = NULL; - - // Filter ID - return_if_error(lzma_vli_decode(&filter->id, NULL, - in, in_pos, in_size)); - - if (filter->id >= LZMA_FILTER_RESERVED_START) - return LZMA_DATA_ERROR; - - // Size of Properties - lzma_vli props_size; - return_if_error(lzma_vli_decode(&props_size, NULL, - in, in_pos, in_size)); - - // Filter Properties - if (in_size - *in_pos < props_size) - return LZMA_DATA_ERROR; - - const lzma_ret ret = lzma_properties_decode( - filter, allocator, in + *in_pos, props_size); - - *in_pos += props_size; - - return ret; -} diff --git a/deps/lzma/liblzma/common/filter_flags_encoder.c b/deps/lzma/liblzma/common/filter_flags_encoder.c deleted file mode 100644 index d110566..0000000 --- a/deps/lzma/liblzma/common/filter_flags_encoder.c +++ /dev/null @@ -1,56 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file filter_flags_encoder.c -/// \brief Decodes a Filter Flags field -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "filter_encoder.h" - - -extern LZMA_API(lzma_ret) -lzma_filter_flags_size(uint32_t *size, const lzma_filter *filter) -{ - if (filter->id >= LZMA_FILTER_RESERVED_START) - return LZMA_PROG_ERROR; - - return_if_error(lzma_properties_size(size, filter)); - - *size += lzma_vli_size(filter->id) + lzma_vli_size(*size); - - return LZMA_OK; -} - - -extern LZMA_API(lzma_ret) -lzma_filter_flags_encode(const lzma_filter *filter, - uint8_t *out, size_t *out_pos, size_t out_size) -{ - // Filter ID - if (filter->id >= LZMA_FILTER_RESERVED_START) - return LZMA_PROG_ERROR; - - return_if_error(lzma_vli_encode(filter->id, NULL, - out, out_pos, out_size)); - - // Size of Properties - uint32_t props_size; - return_if_error(lzma_properties_size(&props_size, filter)); - return_if_error(lzma_vli_encode(props_size, NULL, - out, out_pos, out_size)); - - // Filter Properties - if (out_size - *out_pos < props_size) - return LZMA_PROG_ERROR; - - return_if_error(lzma_properties_encode(filter, out + *out_pos)); - - *out_pos += props_size; - - return LZMA_OK; -} diff --git a/deps/lzma/liblzma/common/hardware_physmem.c b/deps/lzma/liblzma/common/hardware_physmem.c deleted file mode 100644 index 7405b65..0000000 --- a/deps/lzma/liblzma/common/hardware_physmem.c +++ /dev/null @@ -1,25 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file hardware_physmem.c -/// \brief Get the total amount of physical memory (RAM) -// -// Author: Jonathan Nieder -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "common.h" - -#include "tuklib_physmem.h" - - -extern LZMA_API(uint64_t) -lzma_physmem(void) -{ - // It is simpler to make lzma_physmem() a wrapper for - // tuklib_physmem() than to hack appropriate symbol visiblity - // support for the tuklib modules. - return tuklib_physmem(); -} diff --git a/deps/lzma/liblzma/common/index.c b/deps/lzma/liblzma/common/index.c deleted file mode 100644 index 9af4bc1..0000000 --- a/deps/lzma/liblzma/common/index.c +++ /dev/null @@ -1,1244 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file index.c -/// \brief Handling of .xz Indexes and some other Stream information -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "index.h" -#include "stream_flags_common.h" - - -/// \brief How many Records to allocate at once -/// -/// This should be big enough to avoid making lots of tiny allocations -/// but small enough to avoid too much unused memory at once. -#define INDEX_GROUP_SIZE 512 - - -/// \brief How many Records can be allocated at once at maximum -#define PREALLOC_MAX ((SIZE_MAX - sizeof(index_group)) / sizeof(index_record)) - - -/// \brief Base structure for index_stream and index_group structures -typedef struct index_tree_node_s index_tree_node; -struct index_tree_node_s { - /// Uncompressed start offset of this Stream (relative to the - /// beginning of the file) or Block (relative to the beginning - /// of the Stream) - lzma_vli uncompressed_base; - - /// Compressed start offset of this Stream or Block - lzma_vli compressed_base; - - index_tree_node *parent; - index_tree_node *left; - index_tree_node *right; -}; - - -/// \brief AVL tree to hold index_stream or index_group structures -typedef struct { - /// Root node - index_tree_node *root; - - /// Leftmost node. Since the tree will be filled sequentially, - /// this won't change after the first node has been added to - /// the tree. - index_tree_node *leftmost; - - /// The rightmost node in the tree. Since the tree is filled - /// sequentially, this is always the node where to add the new data. - index_tree_node *rightmost; - - /// Number of nodes in the tree - uint32_t count; - -} index_tree; - - -typedef struct { - lzma_vli uncompressed_sum; - lzma_vli unpadded_sum; -} index_record; - - -typedef struct { - /// Every Record group is part of index_stream.groups tree. - index_tree_node node; - - /// Number of Blocks in this Stream before this group. - lzma_vli number_base; - - /// Number of Records that can be put in records[]. - size_t allocated; - - /// Index of the last Record in use. - size_t last; - - /// The sizes in this array are stored as cumulative sums relative - /// to the beginning of the Stream. This makes it possible to - /// use binary search in lzma_index_locate(). - /// - /// Note that the cumulative summing is done specially for - /// unpadded_sum: The previous value is rounded up to the next - /// multiple of four before adding the Unpadded Size of the new - /// Block. The total encoded size of the Blocks in the Stream - /// is records[last].unpadded_sum in the last Record group of - /// the Stream. - /// - /// For example, if the Unpadded Sizes are 39, 57, and 81, the - /// stored values are 39, 97 (40 + 57), and 181 (100 + 181). - /// The total encoded size of these Blocks is 184. - /// - /// This is a flexible array, because it makes easy to optimize - /// memory usage in case someone concatenates many Streams that - /// have only one or few Blocks. - index_record records[]; - -} index_group; - - -typedef struct { - /// Every index_stream is a node in the tree of Sreams. - index_tree_node node; - - /// Number of this Stream (first one is 1) - uint32_t number; - - /// Total number of Blocks before this Stream - lzma_vli block_number_base; - - /// Record groups of this Stream are stored in a tree. - /// It's a T-tree with AVL-tree balancing. There are - /// INDEX_GROUP_SIZE Records per node by default. - /// This keeps the number of memory allocations reasonable - /// and finding a Record is fast. - index_tree groups; - - /// Number of Records in this Stream - lzma_vli record_count; - - /// Size of the List of Records field in this Stream. This is used - /// together with record_count to calculate the size of the Index - /// field and thus the total size of the Stream. - lzma_vli index_list_size; - - /// Stream Flags of this Stream. This is meaningful only if - /// the Stream Flags have been told us with lzma_index_stream_flags(). - /// Initially stream_flags.version is set to UINT32_MAX to indicate - /// that the Stream Flags are unknown. - lzma_stream_flags stream_flags; - - /// Amount of Stream Padding after this Stream. This defaults to - /// zero and can be set with lzma_index_stream_padding(). - lzma_vli stream_padding; - -} index_stream; - - -struct lzma_index_s { - /// AVL-tree containing the Stream(s). Often there is just one - /// Stream, but using a tree keeps lookups fast even when there - /// are many concatenated Streams. - index_tree streams; - - /// Uncompressed size of all the Blocks in the Stream(s) - lzma_vli uncompressed_size; - - /// Total size of all the Blocks in the Stream(s) - lzma_vli total_size; - - /// Total number of Records in all Streams in this lzma_index - lzma_vli record_count; - - /// Size of the List of Records field if all the Streams in this - /// lzma_index were packed into a single Stream (makes it simpler to - /// take many .xz files and combine them into a single Stream). - /// - /// This value together with record_count is needed to calculate - /// Backward Size that is stored into Stream Footer. - lzma_vli index_list_size; - - /// How many Records to allocate at once in lzma_index_append(). - /// This defaults to INDEX_GROUP_SIZE but can be overriden with - /// lzma_index_prealloc(). - size_t prealloc; - - /// Bitmask indicating what integrity check types have been used - /// as set by lzma_index_stream_flags(). The bit of the last Stream - /// is not included here, since it is possible to change it by - /// calling lzma_index_stream_flags() again. - uint32_t checks; -}; - - -static void -index_tree_init(index_tree *tree) -{ - tree->root = NULL; - tree->leftmost = NULL; - tree->rightmost = NULL; - tree->count = 0; - return; -} - - -/// Helper for index_tree_end() -static void -index_tree_node_end(index_tree_node *node, lzma_allocator *allocator, - void (*free_func)(void *node, lzma_allocator *allocator)) -{ - // The tree won't ever be very huge, so recursion should be fine. - // 20 levels in the tree is likely quite a lot already in practice. - if (node->left != NULL) - index_tree_node_end(node->left, allocator, free_func); - - if (node->right != NULL) - index_tree_node_end(node->right, allocator, free_func); - - if (free_func != NULL) - free_func(node, allocator); - - lzma_free(node, allocator); - return; -} - - -/// Free the meory allocated for a tree. If free_func is not NULL, -/// it is called on each node before freeing the node. This is used -/// to free the Record groups from each index_stream before freeing -/// the index_stream itself. -static void -index_tree_end(index_tree *tree, lzma_allocator *allocator, - void (*free_func)(void *node, lzma_allocator *allocator)) -{ - if (tree->root != NULL) - index_tree_node_end(tree->root, allocator, free_func); - - return; -} - - -/// Add a new node to the tree. node->uncompressed_base and -/// node->compressed_base must have been set by the caller already. -static void -index_tree_append(index_tree *tree, index_tree_node *node) -{ - node->parent = tree->rightmost; - node->left = NULL; - node->right = NULL; - - ++tree->count; - - // Handle the special case of adding the first node. - if (tree->root == NULL) { - tree->root = node; - tree->leftmost = node; - tree->rightmost = node; - return; - } - - // The tree is always filled sequentially. - assert(tree->rightmost->uncompressed_base <= node->uncompressed_base); - assert(tree->rightmost->compressed_base < node->compressed_base); - - // Add the new node after the rightmost node. It's the correct - // place due to the reason above. - tree->rightmost->right = node; - tree->rightmost = node; - - // Balance the AVL-tree if needed. We don't need to keep the balance - // factors in nodes, because we always fill the tree sequentially, - // and thus know the state of the tree just by looking at the node - // count. From the node count we can calculate how many steps to go - // up in the tree to find the rotation root. - uint32_t up = tree->count ^ (UINT32_C(1) << bsr32(tree->count)); - if (up != 0) { - // Locate the root node for the rotation. - up = ctz32(tree->count) + 2; - do { - node = node->parent; - } while (--up > 0); - - // Rotate left using node as the rotation root. - index_tree_node *pivot = node->right; - - if (node->parent == NULL) { - tree->root = pivot; - } else { - assert(node->parent->right == node); - node->parent->right = pivot; - } - - pivot->parent = node->parent; - - node->right = pivot->left; - if (node->right != NULL) - node->right->parent = node; - - pivot->left = node; - node->parent = pivot; - } - - return; -} - - -/// Get the next node in the tree. Return NULL if there are no more nodes. -static void * -index_tree_next(const index_tree_node *node) -{ - if (node->right != NULL) { - node = node->right; - while (node->left != NULL) - node = node->left; - - return (void *)(node); - } - - while (node->parent != NULL && node->parent->right == node) - node = node->parent; - - return (void *)(node->parent); -} - - -/// Locate a node that contains the given uncompressed offset. It is -/// caller's job to check that target is not bigger than the uncompressed -/// size of the tree (the last node would be returned in that case still). -static void * -index_tree_locate(const index_tree *tree, lzma_vli target) -{ - const index_tree_node *result = NULL; - const index_tree_node *node = tree->root; - - assert(tree->leftmost == NULL - || tree->leftmost->uncompressed_base == 0); - - // Consecutive nodes may have the same uncompressed_base. - // We must pick the rightmost one. - while (node != NULL) { - if (node->uncompressed_base > target) { - node = node->left; - } else { - result = node; - node = node->right; - } - } - - return (void *)(result); -} - - -/// Allocate and initialize a new Stream using the given base offsets. -static index_stream * -index_stream_init(lzma_vli compressed_base, lzma_vli uncompressed_base, - lzma_vli stream_number, lzma_vli block_number_base, - lzma_allocator *allocator) -{ - index_stream *s = lzma_alloc(sizeof(index_stream), allocator); - if (s == NULL) - return NULL; - - s->node.uncompressed_base = uncompressed_base; - s->node.compressed_base = compressed_base; - s->node.parent = NULL; - s->node.left = NULL; - s->node.right = NULL; - - s->number = stream_number; - s->block_number_base = block_number_base; - - index_tree_init(&s->groups); - - s->record_count = 0; - s->index_list_size = 0; - s->stream_flags.version = UINT32_MAX; - s->stream_padding = 0; - - return s; -} - - -/// Free the memory allocated for a Stream and its Record groups. -static void -index_stream_end(void *node, lzma_allocator *allocator) -{ - index_stream *s = node; - index_tree_end(&s->groups, allocator, NULL); - return; -} - - -static lzma_index * -index_init_plain(lzma_allocator *allocator) -{ - lzma_index *i = lzma_alloc(sizeof(lzma_index), allocator); - if (i != NULL) { - index_tree_init(&i->streams); - i->uncompressed_size = 0; - i->total_size = 0; - i->record_count = 0; - i->index_list_size = 0; - i->prealloc = INDEX_GROUP_SIZE; - i->checks = 0; - } - - return i; -} - - -extern LZMA_API(lzma_index *) -lzma_index_init(lzma_allocator *allocator) -{ - lzma_index *i = index_init_plain(allocator); - if (i == NULL) - return NULL; - - index_stream *s = index_stream_init(0, 0, 1, 0, allocator); - if (s == NULL) { - lzma_free(i, allocator); - return NULL; - } - - index_tree_append(&i->streams, &s->node); - - return i; -} - - -extern LZMA_API(void) -lzma_index_end(lzma_index *i, lzma_allocator *allocator) -{ - // NOTE: If you modify this function, check also the bottom - // of lzma_index_cat(). - if (i != NULL) { - index_tree_end(&i->streams, allocator, &index_stream_end); - lzma_free(i, allocator); - } - - return; -} - - -extern void -lzma_index_prealloc(lzma_index *i, lzma_vli records) -{ - if (records > PREALLOC_MAX) - records = PREALLOC_MAX; - - i->prealloc = (size_t)(records); - return; -} - - -extern LZMA_API(uint64_t) -lzma_index_memusage(lzma_vli streams, lzma_vli blocks) -{ - // This calculates an upper bound that is only a little bit - // bigger than the exact maximum memory usage with the given - // parameters. - - // Typical malloc() overhead is 2 * sizeof(void *) but we take - // a little bit extra just in case. Using LZMA_MEMUSAGE_BASE - // instead would give too inaccurate estimate. - const size_t alloc_overhead = 4 * sizeof(void *); - - // Amount of memory needed for each Stream base structures. - // We assume that every Stream has at least one Block and - // thus at least one group. - const size_t stream_base = sizeof(index_stream) - + sizeof(index_group) + 2 * alloc_overhead; - - // Amount of memory needed per group. - const size_t group_base = sizeof(index_group) - + INDEX_GROUP_SIZE * sizeof(index_record) - + alloc_overhead; - - // Number of groups. There may actually be more, but that overhead - // has been taken into account in stream_base already. - const lzma_vli groups - = (blocks + INDEX_GROUP_SIZE - 1) / INDEX_GROUP_SIZE; - - // Memory used by index_stream and index_group structures. - const uint64_t streams_mem = streams * stream_base; - const uint64_t groups_mem = groups * group_base; - - // Memory used by the base structure. - const uint64_t index_base = sizeof(lzma_index) + alloc_overhead; - - // Validate the arguments and catch integer overflows. - // Maximum number of Streams is "only" UINT32_MAX, because - // that limit is used by the tree containing the Streams. - const uint64_t limit = UINT64_MAX - index_base; - if (streams == 0 || streams > UINT32_MAX || blocks > LZMA_VLI_MAX - || streams > limit / stream_base - || groups > limit / group_base - || limit - streams_mem < groups_mem) - return UINT64_MAX; - - return index_base + streams_mem + groups_mem; -} - - -extern LZMA_API(uint64_t) -lzma_index_memused(const lzma_index *i) -{ - return lzma_index_memusage(i->streams.count, i->record_count); -} - - -extern LZMA_API(lzma_vli) -lzma_index_block_count(const lzma_index *i) -{ - return i->record_count; -} - - -extern LZMA_API(lzma_vli) -lzma_index_stream_count(const lzma_index *i) -{ - return i->streams.count; -} - - -extern LZMA_API(lzma_vli) -lzma_index_size(const lzma_index *i) -{ - return index_size(i->record_count, i->index_list_size); -} - - -extern LZMA_API(lzma_vli) -lzma_index_total_size(const lzma_index *i) -{ - return i->total_size; -} - - -extern LZMA_API(lzma_vli) -lzma_index_stream_size(const lzma_index *i) -{ - // Stream Header + Blocks + Index + Stream Footer - return LZMA_STREAM_HEADER_SIZE + i->total_size - + index_size(i->record_count, i->index_list_size) - + LZMA_STREAM_HEADER_SIZE; -} - - -static lzma_vli -index_file_size(lzma_vli compressed_base, lzma_vli unpadded_sum, - lzma_vli record_count, lzma_vli index_list_size, - lzma_vli stream_padding) -{ - // Earlier Streams and Stream Paddings + Stream Header - // + Blocks + Index + Stream Footer + Stream Padding - // - // This might go over LZMA_VLI_MAX due to too big unpadded_sum - // when this function is used in lzma_index_append(). - lzma_vli file_size = compressed_base + 2 * LZMA_STREAM_HEADER_SIZE - + stream_padding + vli_ceil4(unpadded_sum); - if (file_size > LZMA_VLI_MAX) - return LZMA_VLI_UNKNOWN; - - // The same applies here. - file_size += index_size(record_count, index_list_size); - if (file_size > LZMA_VLI_MAX) - return LZMA_VLI_UNKNOWN; - - return file_size; -} - - -extern LZMA_API(lzma_vli) -lzma_index_file_size(const lzma_index *i) -{ - const index_stream *s = (const index_stream *)(i->streams.rightmost); - const index_group *g = (const index_group *)(s->groups.rightmost); - return index_file_size(s->node.compressed_base, - g == NULL ? 0 : g->records[g->last].unpadded_sum, - s->record_count, s->index_list_size, - s->stream_padding); -} - - -extern LZMA_API(lzma_vli) -lzma_index_uncompressed_size(const lzma_index *i) -{ - return i->uncompressed_size; -} - - -extern LZMA_API(uint32_t) -lzma_index_checks(const lzma_index *i) -{ - uint32_t checks = i->checks; - - // Get the type of the Check of the last Stream too. - const index_stream *s = (const index_stream *)(i->streams.rightmost); - if (s->stream_flags.version != UINT32_MAX) - checks |= UINT32_C(1) << s->stream_flags.check; - - return checks; -} - - -extern uint32_t -lzma_index_padding_size(const lzma_index *i) -{ - return (LZMA_VLI_C(4) - index_size_unpadded( - i->record_count, i->index_list_size)) & 3; -} - - -extern LZMA_API(lzma_ret) -lzma_index_stream_flags(lzma_index *i, const lzma_stream_flags *stream_flags) -{ - if (i == NULL || stream_flags == NULL) - return LZMA_PROG_ERROR; - - // Validate the Stream Flags. - return_if_error(lzma_stream_flags_compare( - stream_flags, stream_flags)); - - index_stream *s = (index_stream *)(i->streams.rightmost); - s->stream_flags = *stream_flags; - - return LZMA_OK; -} - - -extern LZMA_API(lzma_ret) -lzma_index_stream_padding(lzma_index *i, lzma_vli stream_padding) -{ - if (i == NULL || stream_padding > LZMA_VLI_MAX - || (stream_padding & 3) != 0) - return LZMA_PROG_ERROR; - - index_stream *s = (index_stream *)(i->streams.rightmost); - - // Check that the new value won't make the file grow too big. - const lzma_vli old_stream_padding = s->stream_padding; - s->stream_padding = 0; - if (lzma_index_file_size(i) + stream_padding > LZMA_VLI_MAX) { - s->stream_padding = old_stream_padding; - return LZMA_DATA_ERROR; - } - - s->stream_padding = stream_padding; - return LZMA_OK; -} - - -extern LZMA_API(lzma_ret) -lzma_index_append(lzma_index *i, lzma_allocator *allocator, - lzma_vli unpadded_size, lzma_vli uncompressed_size) -{ - // Validate. - if (i == NULL || unpadded_size < UNPADDED_SIZE_MIN - || unpadded_size > UNPADDED_SIZE_MAX - || uncompressed_size > LZMA_VLI_MAX) - return LZMA_PROG_ERROR; - - index_stream *s = (index_stream *)(i->streams.rightmost); - index_group *g = (index_group *)(s->groups.rightmost); - - const lzma_vli compressed_base = g == NULL ? 0 - : vli_ceil4(g->records[g->last].unpadded_sum); - const lzma_vli uncompressed_base = g == NULL ? 0 - : g->records[g->last].uncompressed_sum; - const uint32_t index_list_size_add = lzma_vli_size(unpadded_size) - + lzma_vli_size(uncompressed_size); - - // Check that the file size will stay within limits. - if (index_file_size(s->node.compressed_base, - compressed_base + unpadded_size, s->record_count + 1, - s->index_list_size + index_list_size_add, - s->stream_padding) == LZMA_VLI_UNKNOWN) - return LZMA_DATA_ERROR; - - // The size of the Index field must not exceed the maximum value - // that can be stored in the Backward Size field. - if (index_size(i->record_count + 1, - i->index_list_size + index_list_size_add) - > LZMA_BACKWARD_SIZE_MAX) - return LZMA_DATA_ERROR; - - if (g != NULL && g->last + 1 < g->allocated) { - // There is space in the last group at least for one Record. - ++g->last; - } else { - // We need to allocate a new group. - g = lzma_alloc(sizeof(index_group) - + i->prealloc * sizeof(index_record), - allocator); - if (g == NULL) - return LZMA_MEM_ERROR; - - g->last = 0; - g->allocated = i->prealloc; - - // Reset prealloc so that if the application happens to - // add new Records, the allocation size will be sane. - i->prealloc = INDEX_GROUP_SIZE; - - // Set the start offsets of this group. - g->node.uncompressed_base = uncompressed_base; - g->node.compressed_base = compressed_base; - g->number_base = s->record_count + 1; - - // Add the new group to the Stream. - index_tree_append(&s->groups, &g->node); - } - - // Add the new Record to the group. - g->records[g->last].uncompressed_sum - = uncompressed_base + uncompressed_size; - g->records[g->last].unpadded_sum - = compressed_base + unpadded_size; - - // Update the totals. - ++s->record_count; - s->index_list_size += index_list_size_add; - - i->total_size += vli_ceil4(unpadded_size); - i->uncompressed_size += uncompressed_size; - ++i->record_count; - i->index_list_size += index_list_size_add; - - return LZMA_OK; -} - - -/// Structure to pass info to index_cat_helper() -typedef struct { - /// Uncompressed size of the destination - lzma_vli uncompressed_size; - - /// Compressed file size of the destination - lzma_vli file_size; - - /// Same as above but for Block numbers - lzma_vli block_number_add; - - /// Number of Streams that were in the destination index before we - /// started appending new Streams from the source index. This is - /// used to fix the Stream numbering. - uint32_t stream_number_add; - - /// Destination index' Stream tree - index_tree *streams; - -} index_cat_info; - - -/// Add the Stream nodes from the source index to dest using recursion. -/// Simplest iterative traversal of the source tree wouldn't work, because -/// we update the pointers in nodes when moving them to the destination tree. -static void -index_cat_helper(const index_cat_info *info, index_stream *this) -{ - index_stream *left = (index_stream *)(this->node.left); - index_stream *right = (index_stream *)(this->node.right); - - if (left != NULL) - index_cat_helper(info, left); - - this->node.uncompressed_base += info->uncompressed_size; - this->node.compressed_base += info->file_size; - this->number += info->stream_number_add; - this->block_number_base += info->block_number_add; - index_tree_append(info->streams, &this->node); - - if (right != NULL) - index_cat_helper(info, right); - - return; -} - - -extern LZMA_API(lzma_ret) -lzma_index_cat(lzma_index *restrict dest, lzma_index *restrict src, - lzma_allocator *allocator) -{ - const lzma_vli dest_file_size = lzma_index_file_size(dest); - - // Check that we don't exceed the file size limits. - if (dest_file_size + lzma_index_file_size(src) > LZMA_VLI_MAX - || dest->uncompressed_size + src->uncompressed_size - > LZMA_VLI_MAX) - return LZMA_DATA_ERROR; - - // Check that the encoded size of the combined lzma_indexes stays - // within limits. In theory, this should be done only if we know - // that the user plans to actually combine the Streams and thus - // construct a single Index (probably rare). However, exceeding - // this limit is quite theoretical, so we do this check always - // to simplify things elsewhere. - { - const lzma_vli dest_size = index_size_unpadded( - dest->record_count, dest->index_list_size); - const lzma_vli src_size = index_size_unpadded( - src->record_count, src->index_list_size); - if (vli_ceil4(dest_size + src_size) > LZMA_BACKWARD_SIZE_MAX) - return LZMA_DATA_ERROR; - } - - // Optimize the last group to minimize memory usage. Allocation has - // to be done before modifying dest or src. - { - index_stream *s = (index_stream *)(dest->streams.rightmost); - index_group *g = (index_group *)(s->groups.rightmost); - if (g != NULL && g->last + 1 < g->allocated) { - assert(g->node.left == NULL); - assert(g->node.right == NULL); - - index_group *newg = lzma_alloc(sizeof(index_group) - + (g->last + 1) - * sizeof(index_record), - allocator); - if (newg == NULL) - return LZMA_MEM_ERROR; - - newg->node = g->node; - newg->allocated = g->last + 1; - newg->last = g->last; - newg->number_base = g->number_base; - - memcpy(newg->records, g->records, newg->allocated - * sizeof(index_record)); - - if (g->node.parent != NULL) { - assert(g->node.parent->right == &g->node); - g->node.parent->right = &newg->node; - } - - if (s->groups.leftmost == &g->node) { - assert(s->groups.root == &g->node); - s->groups.leftmost = &newg->node; - s->groups.root = &newg->node; - } - - if (s->groups.rightmost == &g->node) - s->groups.rightmost = &newg->node; - - lzma_free(g, allocator); - } - } - - // Add all the Streams from src to dest. Update the base offsets - // of each Stream from src. - const index_cat_info info = { - .uncompressed_size = dest->uncompressed_size, - .file_size = dest_file_size, - .stream_number_add = dest->streams.count, - .block_number_add = dest->record_count, - .streams = &dest->streams, - }; - index_cat_helper(&info, (index_stream *)(src->streams.root)); - - // Update info about all the combined Streams. - dest->uncompressed_size += src->uncompressed_size; - dest->total_size += src->total_size; - dest->record_count += src->record_count; - dest->index_list_size += src->index_list_size; - dest->checks = lzma_index_checks(dest) | src->checks; - - // There's nothing else left in src than the base structure. - lzma_free(src, allocator); - - return LZMA_OK; -} - - -/// Duplicate an index_stream. -static index_stream * -index_dup_stream(const index_stream *src, lzma_allocator *allocator) -{ - // Catch a somewhat theoretical integer overflow. - if (src->record_count > PREALLOC_MAX) - return NULL; - - // Allocate and initialize a new Stream. - index_stream *dest = index_stream_init(src->node.compressed_base, - src->node.uncompressed_base, src->number, - src->block_number_base, allocator); - - // Return immediately if allocation failed or if there are - // no groups to duplicate. - if (dest == NULL || src->groups.leftmost == NULL) - return dest; - - // Copy the overall information. - dest->record_count = src->record_count; - dest->index_list_size = src->index_list_size; - dest->stream_flags = src->stream_flags; - dest->stream_padding = src->stream_padding; - - // Allocate memory for the Records. We put all the Records into - // a single group. It's simplest and also tends to make - // lzma_index_locate() a little bit faster with very big Indexes. - index_group *destg = lzma_alloc(sizeof(index_group) - + src->record_count * sizeof(index_record), - allocator); - if (destg == NULL) { - index_stream_end(dest, allocator); - return NULL; - } - - // Initialize destg. - destg->node.uncompressed_base = 0; - destg->node.compressed_base = 0; - destg->number_base = 1; - destg->allocated = src->record_count; - destg->last = src->record_count - 1; - - // Go through all the groups in src and copy the Records into destg. - const index_group *srcg = (const index_group *)(src->groups.leftmost); - size_t i = 0; - do { - memcpy(destg->records + i, srcg->records, - (srcg->last + 1) * sizeof(index_record)); - i += srcg->last + 1; - srcg = index_tree_next(&srcg->node); - } while (srcg != NULL); - - assert(i == destg->allocated); - - // Add the group to the new Stream. - index_tree_append(&dest->groups, &destg->node); - - return dest; -} - - -extern LZMA_API(lzma_index *) -lzma_index_dup(const lzma_index *src, lzma_allocator *allocator) -{ - // Allocate the base structure (no initial Stream). - lzma_index *dest = index_init_plain(allocator); - if (dest == NULL) - return NULL; - - // Copy the totals. - dest->uncompressed_size = src->uncompressed_size; - dest->total_size = src->total_size; - dest->record_count = src->record_count; - dest->index_list_size = src->index_list_size; - - // Copy the Streams and the groups in them. - const index_stream *srcstream - = (const index_stream *)(src->streams.leftmost); - do { - index_stream *deststream = index_dup_stream( - srcstream, allocator); - if (deststream == NULL) { - lzma_index_end(dest, allocator); - return NULL; - } - - index_tree_append(&dest->streams, &deststream->node); - - srcstream = index_tree_next(&srcstream->node); - } while (srcstream != NULL); - - return dest; -} - - -/// Indexing for lzma_index_iter.internal[] -enum { - ITER_INDEX, - ITER_STREAM, - ITER_GROUP, - ITER_RECORD, - ITER_METHOD, -}; - - -/// Values for lzma_index_iter.internal[ITER_METHOD].s -enum { - ITER_METHOD_NORMAL, - ITER_METHOD_NEXT, - ITER_METHOD_LEFTMOST, -}; - - -static void -iter_set_info(lzma_index_iter *iter) -{ - const lzma_index *i = iter->internal[ITER_INDEX].p; - const index_stream *stream = iter->internal[ITER_STREAM].p; - const index_group *group = iter->internal[ITER_GROUP].p; - const size_t record = iter->internal[ITER_RECORD].s; - - // lzma_index_iter.internal must not contain a pointer to the last - // group in the index, because that may be reallocated by - // lzma_index_cat(). - if (group == NULL) { - // There are no groups. - assert(stream->groups.root == NULL); - iter->internal[ITER_METHOD].s = ITER_METHOD_LEFTMOST; - - } else if (i->streams.rightmost != &stream->node - || stream->groups.rightmost != &group->node) { - // The group is not not the last group in the index. - iter->internal[ITER_METHOD].s = ITER_METHOD_NORMAL; - - } else if (stream->groups.leftmost != &group->node) { - // The group isn't the only group in the Stream, thus we - // know that it must have a parent group i.e. it's not - // the root node. - assert(stream->groups.root != &group->node); - assert(group->node.parent->right == &group->node); - iter->internal[ITER_METHOD].s = ITER_METHOD_NEXT; - iter->internal[ITER_GROUP].p = group->node.parent; - - } else { - // The Stream has only one group. - assert(stream->groups.root == &group->node); - assert(group->node.parent == NULL); - iter->internal[ITER_METHOD].s = ITER_METHOD_LEFTMOST; - iter->internal[ITER_GROUP].p = NULL; - } - - iter->stream.number = stream->number; - iter->stream.block_count = stream->record_count; - iter->stream.compressed_offset = stream->node.compressed_base; - iter->stream.uncompressed_offset = stream->node.uncompressed_base; - - // iter->stream.flags will be NULL if the Stream Flags haven't been - // set with lzma_index_stream_flags(). - iter->stream.flags = stream->stream_flags.version == UINT32_MAX - ? NULL : &stream->stream_flags; - iter->stream.padding = stream->stream_padding; - - if (stream->groups.rightmost == NULL) { - // Stream has no Blocks. - iter->stream.compressed_size = index_size(0, 0) - + 2 * LZMA_STREAM_HEADER_SIZE; - iter->stream.uncompressed_size = 0; - } else { - const index_group *g = (const index_group *)( - stream->groups.rightmost); - - // Stream Header + Stream Footer + Index + Blocks - iter->stream.compressed_size = 2 * LZMA_STREAM_HEADER_SIZE - + index_size(stream->record_count, - stream->index_list_size) - + vli_ceil4(g->records[g->last].unpadded_sum); - iter->stream.uncompressed_size - = g->records[g->last].uncompressed_sum; - } - - if (group != NULL) { - iter->block.number_in_stream = group->number_base + record; - iter->block.number_in_file = iter->block.number_in_stream - + stream->block_number_base; - - iter->block.compressed_stream_offset - = record == 0 ? group->node.compressed_base - : vli_ceil4(group->records[ - record - 1].unpadded_sum); - iter->block.uncompressed_stream_offset - = record == 0 ? group->node.uncompressed_base - : group->records[record - 1].uncompressed_sum; - - iter->block.uncompressed_size - = group->records[record].uncompressed_sum - - iter->block.uncompressed_stream_offset; - iter->block.unpadded_size - = group->records[record].unpadded_sum - - iter->block.compressed_stream_offset; - iter->block.total_size = vli_ceil4(iter->block.unpadded_size); - - iter->block.compressed_stream_offset - += LZMA_STREAM_HEADER_SIZE; - - iter->block.compressed_file_offset - = iter->block.compressed_stream_offset - + iter->stream.compressed_offset; - iter->block.uncompressed_file_offset - = iter->block.uncompressed_stream_offset - + iter->stream.uncompressed_offset; - } - - return; -} - - -extern LZMA_API(void) -lzma_index_iter_init(lzma_index_iter *iter, const lzma_index *i) -{ - iter->internal[ITER_INDEX].p = i; - lzma_index_iter_rewind(iter); - return; -} - - -extern LZMA_API(void) -lzma_index_iter_rewind(lzma_index_iter *iter) -{ - iter->internal[ITER_STREAM].p = NULL; - iter->internal[ITER_GROUP].p = NULL; - iter->internal[ITER_RECORD].s = 0; - iter->internal[ITER_METHOD].s = ITER_METHOD_NORMAL; - return; -} - - -extern LZMA_API(lzma_bool) -lzma_index_iter_next(lzma_index_iter *iter, lzma_index_iter_mode mode) -{ - // Catch unsupported mode values. - if ((unsigned int)(mode) > LZMA_INDEX_ITER_NONEMPTY_BLOCK) - return true; - - const lzma_index *i = iter->internal[ITER_INDEX].p; - const index_stream *stream = iter->internal[ITER_STREAM].p; - const index_group *group = NULL; - size_t record = iter->internal[ITER_RECORD].s; - - // If we are being asked for the next Stream, leave group to NULL - // so that the rest of the this function thinks that this Stream - // has no groups and will thus go to the next Stream. - if (mode != LZMA_INDEX_ITER_STREAM) { - // Get the pointer to the current group. See iter_set_inf() - // for explanation. - switch (iter->internal[ITER_METHOD].s) { - case ITER_METHOD_NORMAL: - group = iter->internal[ITER_GROUP].p; - break; - - case ITER_METHOD_NEXT: - group = index_tree_next(iter->internal[ITER_GROUP].p); - break; - - case ITER_METHOD_LEFTMOST: - group = (const index_group *)( - stream->groups.leftmost); - break; - } - } - -again: - if (stream == NULL) { - // We at the beginning of the lzma_index. - // Locate the first Stream. - stream = (const index_stream *)(i->streams.leftmost); - if (mode >= LZMA_INDEX_ITER_BLOCK) { - // Since we are being asked to return information - // about the first a Block, skip Streams that have - // no Blocks. - while (stream->groups.leftmost == NULL) { - stream = index_tree_next(&stream->node); - if (stream == NULL) - return true; - } - } - - // Start from the first Record in the Stream. - group = (const index_group *)(stream->groups.leftmost); - record = 0; - - } else if (group != NULL && record < group->last) { - // The next Record is in the same group. - ++record; - - } else { - // This group has no more Records or this Stream has - // no Blocks at all. - record = 0; - - // If group is not NULL, this Stream has at least one Block - // and thus at least one group. Find the next group. - if (group != NULL) - group = index_tree_next(&group->node); - - if (group == NULL) { - // This Stream has no more Records. Find the next - // Stream. If we are being asked to return information - // about a Block, we skip empty Streams. - do { - stream = index_tree_next(&stream->node); - if (stream == NULL) - return true; - } while (mode >= LZMA_INDEX_ITER_BLOCK - && stream->groups.leftmost == NULL); - - group = (const index_group *)( - stream->groups.leftmost); - } - } - - if (mode == LZMA_INDEX_ITER_NONEMPTY_BLOCK) { - // We need to look for the next Block again if this Block - // is empty. - if (record == 0) { - if (group->node.uncompressed_base - == group->records[0].uncompressed_sum) - goto again; - } else if (group->records[record - 1].uncompressed_sum - == group->records[record].uncompressed_sum) { - goto again; - } - } - - iter->internal[ITER_STREAM].p = stream; - iter->internal[ITER_GROUP].p = group; - iter->internal[ITER_RECORD].s = record; - - iter_set_info(iter); - - return false; -} - - -extern LZMA_API(lzma_bool) -lzma_index_iter_locate(lzma_index_iter *iter, lzma_vli target) -{ - const lzma_index *i = iter->internal[ITER_INDEX].p; - - // If the target is past the end of the file, return immediately. - if (i->uncompressed_size <= target) - return true; - - // Locate the Stream containing the target offset. - const index_stream *stream = index_tree_locate(&i->streams, target); - assert(stream != NULL); - target -= stream->node.uncompressed_base; - - // Locate the group containing the target offset. - const index_group *group = index_tree_locate(&stream->groups, target); - assert(group != NULL); - - // Use binary search to locate the exact Record. It is the first - // Record whose uncompressed_sum is greater than target. - // This is because we want the rightmost Record that fullfills the - // search criterion. It is possible that there are empty Blocks; - // we don't want to return them. - size_t left = 0; - size_t right = group->last; - - while (left < right) { - const size_t pos = left + (right - left) / 2; - if (group->records[pos].uncompressed_sum <= target) - left = pos + 1; - else - right = pos; - } - - iter->internal[ITER_STREAM].p = stream; - iter->internal[ITER_GROUP].p = group; - iter->internal[ITER_RECORD].s = left; - - iter_set_info(iter); - - return false; -} diff --git a/deps/lzma/liblzma/common/index.h b/deps/lzma/liblzma/common/index.h deleted file mode 100644 index 64e9724..0000000 --- a/deps/lzma/liblzma/common/index.h +++ /dev/null @@ -1,73 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file index.h -/// \brief Handling of Index -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_INDEX_H -#define LZMA_INDEX_H - -#include "common.h" - - -/// Minimum Unpadded Size -#define UNPADDED_SIZE_MIN LZMA_VLI_C(5) - -/// Maximum Unpadded Size -#define UNPADDED_SIZE_MAX (LZMA_VLI_MAX & ~LZMA_VLI_C(3)) - - -/// Get the size of the Index Padding field. This is needed by Index encoder -/// and decoder, but applications should have no use for this. -extern uint32_t lzma_index_padding_size(const lzma_index *i); - - -/// Set for how many Records to allocate memory the next time -/// lzma_index_append() needs to allocate space for a new Record. -/// This is used only by the Index decoder. -extern void lzma_index_prealloc(lzma_index *i, lzma_vli records); - - -/// Round the variable-length integer to the next multiple of four. -static inline lzma_vli -vli_ceil4(lzma_vli vli) -{ - assert(vli <= LZMA_VLI_MAX); - return (vli + 3) & ~LZMA_VLI_C(3); -} - - -/// Calculate the size of the Index field excluding Index Padding -static inline lzma_vli -index_size_unpadded(lzma_vli count, lzma_vli index_list_size) -{ - // Index Indicator + Number of Records + List of Records + CRC32 - return 1 + lzma_vli_size(count) + index_list_size + 4; -} - - -/// Calculate the size of the Index field including Index Padding -static inline lzma_vli -index_size(lzma_vli count, lzma_vli index_list_size) -{ - return vli_ceil4(index_size_unpadded(count, index_list_size)); -} - - -/// Calculate the total size of the Stream -static inline lzma_vli -index_stream_size(lzma_vli blocks_size, - lzma_vli count, lzma_vli index_list_size) -{ - return LZMA_STREAM_HEADER_SIZE + blocks_size - + index_size(count, index_list_size) - + LZMA_STREAM_HEADER_SIZE; -} - -#endif diff --git a/deps/lzma/liblzma/common/index_decoder.c b/deps/lzma/liblzma/common/index_decoder.c deleted file mode 100644 index 83c8a3a..0000000 --- a/deps/lzma/liblzma/common/index_decoder.c +++ /dev/null @@ -1,345 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file index_decoder.c -/// \brief Decodes the Index field -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "index.h" -#include "check.h" - - -struct lzma_coder_s { - enum { - SEQ_INDICATOR, - SEQ_COUNT, - SEQ_MEMUSAGE, - SEQ_UNPADDED, - SEQ_UNCOMPRESSED, - SEQ_PADDING_INIT, - SEQ_PADDING, - SEQ_CRC32, - } sequence; - - /// Memory usage limit - uint64_t memlimit; - - /// Target Index - lzma_index *index; - - /// Pointer give by the application, which is set after - /// successful decoding. - lzma_index **index_ptr; - - /// Number of Records left to decode. - lzma_vli count; - - /// The most recent Unpadded Size field - lzma_vli unpadded_size; - - /// The most recent Uncompressed Size field - lzma_vli uncompressed_size; - - /// Position in integers - size_t pos; - - /// CRC32 of the List of Records field - uint32_t crc32; -}; - - -static lzma_ret -index_decode(lzma_coder *coder, lzma_allocator *allocator, - const uint8_t *restrict in, size_t *restrict in_pos, - size_t in_size, - uint8_t *restrict out lzma_attribute((__unused__)), - size_t *restrict out_pos lzma_attribute((__unused__)), - size_t out_size lzma_attribute((__unused__)), - lzma_action action lzma_attribute((__unused__))) -{ - // Similar optimization as in index_encoder.c - const size_t in_start = *in_pos; - lzma_ret ret = LZMA_OK; - - while (*in_pos < in_size) - switch (coder->sequence) { - case SEQ_INDICATOR: - // Return LZMA_DATA_ERROR instead of e.g. LZMA_PROG_ERROR or - // LZMA_FORMAT_ERROR, because a typical usage case for Index - // decoder is when parsing the Stream backwards. If seeking - // backward from the Stream Footer gives us something that - // doesn't begin with Index Indicator, the file is considered - // corrupt, not "programming error" or "unrecognized file - // format". One could argue that the application should - // verify the Index Indicator before trying to decode the - // Index, but well, I suppose it is simpler this way. - if (in[(*in_pos)++] != 0x00) - return LZMA_DATA_ERROR; - - coder->sequence = SEQ_COUNT; - break; - - case SEQ_COUNT: - ret = lzma_vli_decode(&coder->count, &coder->pos, - in, in_pos, in_size); - if (ret != LZMA_STREAM_END) - goto out; - - coder->pos = 0; - coder->sequence = SEQ_MEMUSAGE; - - // Fall through - - case SEQ_MEMUSAGE: - if (lzma_index_memusage(1, coder->count) > coder->memlimit) { - ret = LZMA_MEMLIMIT_ERROR; - goto out; - } - - // Tell the Index handling code how many Records this - // Index has to allow it to allocate memory more efficiently. - lzma_index_prealloc(coder->index, coder->count); - - ret = LZMA_OK; - coder->sequence = coder->count == 0 - ? SEQ_PADDING_INIT : SEQ_UNPADDED; - break; - - case SEQ_UNPADDED: - case SEQ_UNCOMPRESSED: { - lzma_vli *size = coder->sequence == SEQ_UNPADDED - ? &coder->unpadded_size - : &coder->uncompressed_size; - - ret = lzma_vli_decode(size, &coder->pos, - in, in_pos, in_size); - if (ret != LZMA_STREAM_END) - goto out; - - ret = LZMA_OK; - coder->pos = 0; - - if (coder->sequence == SEQ_UNPADDED) { - // Validate that encoded Unpadded Size isn't too small - // or too big. - if (coder->unpadded_size < UNPADDED_SIZE_MIN - || coder->unpadded_size - > UNPADDED_SIZE_MAX) - return LZMA_DATA_ERROR; - - coder->sequence = SEQ_UNCOMPRESSED; - } else { - // Add the decoded Record to the Index. - return_if_error(lzma_index_append( - coder->index, allocator, - coder->unpadded_size, - coder->uncompressed_size)); - - // Check if this was the last Record. - coder->sequence = --coder->count == 0 - ? SEQ_PADDING_INIT - : SEQ_UNPADDED; - } - - break; - } - - case SEQ_PADDING_INIT: - coder->pos = lzma_index_padding_size(coder->index); - coder->sequence = SEQ_PADDING; - - // Fall through - - case SEQ_PADDING: - if (coder->pos > 0) { - --coder->pos; - if (in[(*in_pos)++] != 0x00) - return LZMA_DATA_ERROR; - - break; - } - - // Finish the CRC32 calculation. - coder->crc32 = lzma_crc32(in + in_start, - *in_pos - in_start, coder->crc32); - - coder->sequence = SEQ_CRC32; - - // Fall through - - case SEQ_CRC32: - do { - if (*in_pos == in_size) - return LZMA_OK; - - if (((coder->crc32 >> (coder->pos * 8)) & 0xFF) - != in[(*in_pos)++]) - return LZMA_DATA_ERROR; - - } while (++coder->pos < 4); - - // Decoding was successful, now we can let the application - // see the decoded Index. - *coder->index_ptr = coder->index; - - // Make index NULL so we don't free it unintentionally. - coder->index = NULL; - - return LZMA_STREAM_END; - - default: - assert(0); - return LZMA_PROG_ERROR; - } - -out: - // Update the CRC32, - coder->crc32 = lzma_crc32(in + in_start, - *in_pos - in_start, coder->crc32); - - return ret; -} - - -static void -index_decoder_end(lzma_coder *coder, lzma_allocator *allocator) -{ - lzma_index_end(coder->index, allocator); - lzma_free(coder, allocator); - return; -} - - -static lzma_ret -index_decoder_memconfig(lzma_coder *coder, uint64_t *memusage, - uint64_t *old_memlimit, uint64_t new_memlimit) -{ - *memusage = lzma_index_memusage(1, coder->count); - *old_memlimit = coder->memlimit; - - if (new_memlimit != 0) { - if (new_memlimit < *memusage) - return LZMA_MEMLIMIT_ERROR; - - coder->memlimit = new_memlimit; - } - - return LZMA_OK; -} - - -static lzma_ret -index_decoder_reset(lzma_coder *coder, lzma_allocator *allocator, - lzma_index **i, uint64_t memlimit) -{ - // Remember the pointer given by the application. We will set it - // to point to the decoded Index only if decoding is successful. - // Before that, keep it NULL so that applications can always safely - // pass it to lzma_index_end() no matter did decoding succeed or not. - coder->index_ptr = i; - *i = NULL; - - // We always allocate a new lzma_index. - coder->index = lzma_index_init(allocator); - if (coder->index == NULL) - return LZMA_MEM_ERROR; - - // Initialize the rest. - coder->sequence = SEQ_INDICATOR; - coder->memlimit = memlimit; - coder->count = 0; // Needs to be initialized due to _memconfig(). - coder->pos = 0; - coder->crc32 = 0; - - return LZMA_OK; -} - - -static lzma_ret -index_decoder_init(lzma_next_coder *next, lzma_allocator *allocator, - lzma_index **i, uint64_t memlimit) -{ - lzma_next_coder_init(&index_decoder_init, next, allocator); - - if (i == NULL || memlimit == 0) - return LZMA_PROG_ERROR; - - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) - return LZMA_MEM_ERROR; - - next->code = &index_decode; - next->end = &index_decoder_end; - next->memconfig = &index_decoder_memconfig; - next->coder->index = NULL; - } else { - lzma_index_end(next->coder->index, allocator); - } - - return index_decoder_reset(next->coder, allocator, i, memlimit); -} - - -extern LZMA_API(lzma_ret) -lzma_index_decoder(lzma_stream *strm, lzma_index **i, uint64_t memlimit) -{ - lzma_next_strm_init(index_decoder_init, strm, i, memlimit); - - strm->internal->supported_actions[LZMA_RUN] = true; - strm->internal->supported_actions[LZMA_FINISH] = true; - - return LZMA_OK; -} - - -extern LZMA_API(lzma_ret) -lzma_index_buffer_decode( - lzma_index **i, uint64_t *memlimit, lzma_allocator *allocator, - const uint8_t *in, size_t *in_pos, size_t in_size) -{ - // Sanity checks - if (i == NULL || memlimit == NULL - || in == NULL || in_pos == NULL || *in_pos > in_size) - return LZMA_PROG_ERROR; - - // Initialize the decoder. - lzma_coder coder; - return_if_error(index_decoder_reset(&coder, allocator, i, *memlimit)); - - // Store the input start position so that we can restore it in case - // of an error. - const size_t in_start = *in_pos; - - // Do the actual decoding. - lzma_ret ret = index_decode(&coder, allocator, in, in_pos, in_size, - NULL, NULL, 0, LZMA_RUN); - - if (ret == LZMA_STREAM_END) { - ret = LZMA_OK; - } else { - // Something went wrong, free the Index structure and restore - // the input position. - lzma_index_end(coder.index, allocator); - *in_pos = in_start; - - if (ret == LZMA_OK) { - // The input is truncated or otherwise corrupt. - // Use LZMA_DATA_ERROR instead of LZMA_BUF_ERROR - // like lzma_vli_decode() does in single-call mode. - ret = LZMA_DATA_ERROR; - - } else if (ret == LZMA_MEMLIMIT_ERROR) { - // Tell the caller how much memory would have - // been needed. - *memlimit = lzma_index_memusage(1, coder.count); - } - } - - return ret; -} diff --git a/deps/lzma/liblzma/common/index_encoder.c b/deps/lzma/liblzma/common/index_encoder.c deleted file mode 100644 index 45919f0..0000000 --- a/deps/lzma/liblzma/common/index_encoder.c +++ /dev/null @@ -1,254 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file index_encoder.c -/// \brief Encodes the Index field -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "index_encoder.h" -#include "index.h" -#include "check.h" - - -struct lzma_coder_s { - enum { - SEQ_INDICATOR, - SEQ_COUNT, - SEQ_UNPADDED, - SEQ_UNCOMPRESSED, - SEQ_NEXT, - SEQ_PADDING, - SEQ_CRC32, - } sequence; - - /// Index being encoded - const lzma_index *index; - - /// Iterator for the Index being encoded - lzma_index_iter iter; - - /// Position in integers - size_t pos; - - /// CRC32 of the List of Records field - uint32_t crc32; -}; - - -static lzma_ret -index_encode(lzma_coder *coder, - lzma_allocator *allocator lzma_attribute((__unused__)), - const uint8_t *restrict in lzma_attribute((__unused__)), - size_t *restrict in_pos lzma_attribute((__unused__)), - size_t in_size lzma_attribute((__unused__)), - uint8_t *restrict out, size_t *restrict out_pos, - size_t out_size, - lzma_action action lzma_attribute((__unused__))) -{ - // Position where to start calculating CRC32. The idea is that we - // need to call lzma_crc32() only once per call to index_encode(). - const size_t out_start = *out_pos; - - // Return value to use if we return at the end of this function. - // We use "goto out" to jump out of the while-switch construct - // instead of returning directly, because that way we don't need - // to copypaste the lzma_crc32() call to many places. - lzma_ret ret = LZMA_OK; - - while (*out_pos < out_size) - switch (coder->sequence) { - case SEQ_INDICATOR: - out[*out_pos] = 0x00; - ++*out_pos; - coder->sequence = SEQ_COUNT; - break; - - case SEQ_COUNT: { - const lzma_vli count = lzma_index_block_count(coder->index); - ret = lzma_vli_encode(count, &coder->pos, - out, out_pos, out_size); - if (ret != LZMA_STREAM_END) - goto out; - - ret = LZMA_OK; - coder->pos = 0; - coder->sequence = SEQ_NEXT; - break; - } - - case SEQ_NEXT: - if (lzma_index_iter_next( - &coder->iter, LZMA_INDEX_ITER_BLOCK)) { - // Get the size of the Index Padding field. - coder->pos = lzma_index_padding_size(coder->index); - assert(coder->pos <= 3); - coder->sequence = SEQ_PADDING; - break; - } - - coder->sequence = SEQ_UNPADDED; - - // Fall through - - case SEQ_UNPADDED: - case SEQ_UNCOMPRESSED: { - const lzma_vli size = coder->sequence == SEQ_UNPADDED - ? coder->iter.block.unpadded_size - : coder->iter.block.uncompressed_size; - - ret = lzma_vli_encode(size, &coder->pos, - out, out_pos, out_size); - if (ret != LZMA_STREAM_END) - goto out; - - ret = LZMA_OK; - coder->pos = 0; - - // Advance to SEQ_UNCOMPRESSED or SEQ_NEXT. - ++coder->sequence; - break; - } - - case SEQ_PADDING: - if (coder->pos > 0) { - --coder->pos; - out[(*out_pos)++] = 0x00; - break; - } - - // Finish the CRC32 calculation. - coder->crc32 = lzma_crc32(out + out_start, - *out_pos - out_start, coder->crc32); - - coder->sequence = SEQ_CRC32; - - // Fall through - - case SEQ_CRC32: - // We don't use the main loop, because we don't want - // coder->crc32 to be touched anymore. - do { - if (*out_pos == out_size) - return LZMA_OK; - - out[*out_pos] = (coder->crc32 >> (coder->pos * 8)) - & 0xFF; - ++*out_pos; - - } while (++coder->pos < 4); - - return LZMA_STREAM_END; - - default: - assert(0); - return LZMA_PROG_ERROR; - } - -out: - // Update the CRC32. - coder->crc32 = lzma_crc32(out + out_start, - *out_pos - out_start, coder->crc32); - - return ret; -} - - -static void -index_encoder_end(lzma_coder *coder, lzma_allocator *allocator) -{ - lzma_free(coder, allocator); - return; -} - - -static void -index_encoder_reset(lzma_coder *coder, const lzma_index *i) -{ - lzma_index_iter_init(&coder->iter, i); - - coder->sequence = SEQ_INDICATOR; - coder->index = i; - coder->pos = 0; - coder->crc32 = 0; - - return; -} - - -extern lzma_ret -lzma_index_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_index *i) -{ - lzma_next_coder_init(&lzma_index_encoder_init, next, allocator); - - if (i == NULL) - return LZMA_PROG_ERROR; - - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) - return LZMA_MEM_ERROR; - - next->code = &index_encode; - next->end = &index_encoder_end; - } - - index_encoder_reset(next->coder, i); - - return LZMA_OK; -} - - -extern LZMA_API(lzma_ret) -lzma_index_encoder(lzma_stream *strm, const lzma_index *i) -{ - lzma_next_strm_init(lzma_index_encoder_init, strm, i); - - strm->internal->supported_actions[LZMA_RUN] = true; - strm->internal->supported_actions[LZMA_FINISH] = true; - - return LZMA_OK; -} - - -extern LZMA_API(lzma_ret) -lzma_index_buffer_encode(const lzma_index *i, - uint8_t *out, size_t *out_pos, size_t out_size) -{ - // Validate the arguments. - if (i == NULL || out == NULL || out_pos == NULL || *out_pos > out_size) - return LZMA_PROG_ERROR; - - // Don't try to encode if there's not enough output space. - if (out_size - *out_pos < lzma_index_size(i)) - return LZMA_BUF_ERROR; - - // The Index encoder needs just one small data structure so we can - // allocate it on stack. - lzma_coder coder; - index_encoder_reset(&coder, i); - - // Do the actual encoding. This should never fail, but store - // the original *out_pos just in case. - const size_t out_start = *out_pos; - lzma_ret ret = index_encode(&coder, NULL, NULL, NULL, 0, - out, out_pos, out_size, LZMA_RUN); - - if (ret == LZMA_STREAM_END) { - ret = LZMA_OK; - } else { - // We should never get here, but just in case, restore the - // output position and set the error accordingly if something - // goes wrong and debugging isn't enabled. - assert(0); - *out_pos = out_start; - ret = LZMA_PROG_ERROR; - } - - return ret; -} diff --git a/deps/lzma/liblzma/common/index_encoder.h b/deps/lzma/liblzma/common/index_encoder.h deleted file mode 100644 index a13c94d..0000000 --- a/deps/lzma/liblzma/common/index_encoder.h +++ /dev/null @@ -1,23 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file index_encoder.h -/// \brief Encodes the Index field -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_INDEX_ENCODER_H -#define LZMA_INDEX_ENCODER_H - -#include "common.h" - - -extern lzma_ret lzma_index_encoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_index *i); - - -#endif diff --git a/deps/lzma/liblzma/common/index_hash.c b/deps/lzma/liblzma/common/index_hash.c deleted file mode 100644 index e3e9386..0000000 --- a/deps/lzma/liblzma/common/index_hash.c +++ /dev/null @@ -1,332 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file index_hash.c -/// \brief Validates Index by using a hash function -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "common.h" -#include "index.h" -#include "check.h" - - -typedef struct { - /// Sum of the Block sizes (including Block Padding) - lzma_vli blocks_size; - - /// Sum of the Uncompressed Size fields - lzma_vli uncompressed_size; - - /// Number of Records - lzma_vli count; - - /// Size of the List of Index Records as bytes - lzma_vli index_list_size; - - /// Check calculated from Unpadded Sizes and Uncompressed Sizes. - lzma_check_state check; - -} lzma_index_hash_info; - - -struct lzma_index_hash_s { - enum { - SEQ_BLOCK, - SEQ_COUNT, - SEQ_UNPADDED, - SEQ_UNCOMPRESSED, - SEQ_PADDING_INIT, - SEQ_PADDING, - SEQ_CRC32, - } sequence; - - /// Information collected while decoding the actual Blocks. - lzma_index_hash_info blocks; - - /// Information collected from the Index field. - lzma_index_hash_info records; - - /// Number of Records not fully decoded - lzma_vli remaining; - - /// Unpadded Size currently being read from an Index Record. - lzma_vli unpadded_size; - - /// Uncompressed Size currently being read from an Index Record. - lzma_vli uncompressed_size; - - /// Position in variable-length integers when decoding them from - /// the List of Records. - size_t pos; - - /// CRC32 of the Index - uint32_t crc32; -}; - - -extern LZMA_API(lzma_index_hash *) -lzma_index_hash_init(lzma_index_hash *index_hash, lzma_allocator *allocator) -{ - if (index_hash == NULL) { - index_hash = lzma_alloc(sizeof(lzma_index_hash), allocator); - if (index_hash == NULL) - return NULL; - } - - index_hash->sequence = SEQ_BLOCK; - index_hash->blocks.blocks_size = 0; - index_hash->blocks.uncompressed_size = 0; - index_hash->blocks.count = 0; - index_hash->blocks.index_list_size = 0; - index_hash->records.blocks_size = 0; - index_hash->records.uncompressed_size = 0; - index_hash->records.count = 0; - index_hash->records.index_list_size = 0; - index_hash->unpadded_size = 0; - index_hash->uncompressed_size = 0; - index_hash->pos = 0; - index_hash->crc32 = 0; - - // These cannot fail because LZMA_CHECK_BEST is known to be supported. - (void)lzma_check_init(&index_hash->blocks.check, LZMA_CHECK_BEST); - (void)lzma_check_init(&index_hash->records.check, LZMA_CHECK_BEST); - - return index_hash; -} - - -extern LZMA_API(void) -lzma_index_hash_end(lzma_index_hash *index_hash, lzma_allocator *allocator) -{ - lzma_free(index_hash, allocator); - return; -} - - -extern LZMA_API(lzma_vli) -lzma_index_hash_size(const lzma_index_hash *index_hash) -{ - // Get the size of the Index from ->blocks instead of ->records for - // cases where application wants to know the Index Size before - // decoding the Index. - return index_size(index_hash->blocks.count, - index_hash->blocks.index_list_size); -} - - -/// Updates the sizes and the hash without any validation. -static lzma_ret -hash_append(lzma_index_hash_info *info, lzma_vli unpadded_size, - lzma_vli uncompressed_size) -{ - info->blocks_size += vli_ceil4(unpadded_size); - info->uncompressed_size += uncompressed_size; - info->index_list_size += lzma_vli_size(unpadded_size) - + lzma_vli_size(uncompressed_size); - ++info->count; - - const lzma_vli sizes[2] = { unpadded_size, uncompressed_size }; - lzma_check_update(&info->check, LZMA_CHECK_BEST, - (const uint8_t *)(sizes), sizeof(sizes)); - - return LZMA_OK; -} - - -extern LZMA_API(lzma_ret) -lzma_index_hash_append(lzma_index_hash *index_hash, lzma_vli unpadded_size, - lzma_vli uncompressed_size) -{ - // Validate the arguments. - if (index_hash->sequence != SEQ_BLOCK - || unpadded_size < UNPADDED_SIZE_MIN - || unpadded_size > UNPADDED_SIZE_MAX - || uncompressed_size > LZMA_VLI_MAX) - return LZMA_PROG_ERROR; - - // Update the hash. - return_if_error(hash_append(&index_hash->blocks, - unpadded_size, uncompressed_size)); - - // Validate the properties of *info are still in allowed limits. - if (index_hash->blocks.blocks_size > LZMA_VLI_MAX - || index_hash->blocks.uncompressed_size > LZMA_VLI_MAX - || index_size(index_hash->blocks.count, - index_hash->blocks.index_list_size) - > LZMA_BACKWARD_SIZE_MAX - || index_stream_size(index_hash->blocks.blocks_size, - index_hash->blocks.count, - index_hash->blocks.index_list_size) - > LZMA_VLI_MAX) - return LZMA_DATA_ERROR; - - return LZMA_OK; -} - - -extern LZMA_API(lzma_ret) -lzma_index_hash_decode(lzma_index_hash *index_hash, const uint8_t *in, - size_t *in_pos, size_t in_size) -{ - // Catch zero input buffer here, because in contrast to Index encoder - // and decoder functions, applications call this function directly - // instead of via lzma_code(), which does the buffer checking. - if (*in_pos >= in_size) - return LZMA_BUF_ERROR; - - // NOTE: This function has many similarities to index_encode() and - // index_decode() functions found from index_encoder.c and - // index_decoder.c. See the comments especially in index_encoder.c. - const size_t in_start = *in_pos; - lzma_ret ret = LZMA_OK; - - while (*in_pos < in_size) - switch (index_hash->sequence) { - case SEQ_BLOCK: - // Check the Index Indicator is present. - if (in[(*in_pos)++] != 0x00) - return LZMA_DATA_ERROR; - - index_hash->sequence = SEQ_COUNT; - break; - - case SEQ_COUNT: { - ret = lzma_vli_decode(&index_hash->remaining, - &index_hash->pos, in, in_pos, in_size); - if (ret != LZMA_STREAM_END) - goto out; - - // The count must match the count of the Blocks decoded. - if (index_hash->remaining != index_hash->blocks.count) - return LZMA_DATA_ERROR; - - ret = LZMA_OK; - index_hash->pos = 0; - - // Handle the special case when there are no Blocks. - index_hash->sequence = index_hash->remaining == 0 - ? SEQ_PADDING_INIT : SEQ_UNPADDED; - break; - } - - case SEQ_UNPADDED: - case SEQ_UNCOMPRESSED: { - lzma_vli *size = index_hash->sequence == SEQ_UNPADDED - ? &index_hash->unpadded_size - : &index_hash->uncompressed_size; - - ret = lzma_vli_decode(size, &index_hash->pos, - in, in_pos, in_size); - if (ret != LZMA_STREAM_END) - goto out; - - ret = LZMA_OK; - index_hash->pos = 0; - - if (index_hash->sequence == SEQ_UNPADDED) { - if (index_hash->unpadded_size < UNPADDED_SIZE_MIN - || index_hash->unpadded_size - > UNPADDED_SIZE_MAX) - return LZMA_DATA_ERROR; - - index_hash->sequence = SEQ_UNCOMPRESSED; - } else { - // Update the hash. - return_if_error(hash_append(&index_hash->records, - index_hash->unpadded_size, - index_hash->uncompressed_size)); - - // Verify that we don't go over the known sizes. Note - // that this validation is simpler than the one used - // in lzma_index_hash_append(), because here we know - // that values in index_hash->blocks are already - // validated and we are fine as long as we don't - // exceed them in index_hash->records. - if (index_hash->blocks.blocks_size - < index_hash->records.blocks_size - || index_hash->blocks.uncompressed_size - < index_hash->records.uncompressed_size - || index_hash->blocks.index_list_size - < index_hash->records.index_list_size) - return LZMA_DATA_ERROR; - - // Check if this was the last Record. - index_hash->sequence = --index_hash->remaining == 0 - ? SEQ_PADDING_INIT : SEQ_UNPADDED; - } - - break; - } - - case SEQ_PADDING_INIT: - index_hash->pos = (LZMA_VLI_C(4) - index_size_unpadded( - index_hash->records.count, - index_hash->records.index_list_size)) & 3; - index_hash->sequence = SEQ_PADDING; - - // Fall through - - case SEQ_PADDING: - if (index_hash->pos > 0) { - --index_hash->pos; - if (in[(*in_pos)++] != 0x00) - return LZMA_DATA_ERROR; - - break; - } - - // Compare the sizes. - if (index_hash->blocks.blocks_size - != index_hash->records.blocks_size - || index_hash->blocks.uncompressed_size - != index_hash->records.uncompressed_size - || index_hash->blocks.index_list_size - != index_hash->records.index_list_size) - return LZMA_DATA_ERROR; - - // Finish the hashes and compare them. - lzma_check_finish(&index_hash->blocks.check, LZMA_CHECK_BEST); - lzma_check_finish(&index_hash->records.check, LZMA_CHECK_BEST); - if (memcmp(index_hash->blocks.check.buffer.u8, - index_hash->records.check.buffer.u8, - lzma_check_size(LZMA_CHECK_BEST)) != 0) - return LZMA_DATA_ERROR; - - // Finish the CRC32 calculation. - index_hash->crc32 = lzma_crc32(in + in_start, - *in_pos - in_start, index_hash->crc32); - - index_hash->sequence = SEQ_CRC32; - - // Fall through - - case SEQ_CRC32: - do { - if (*in_pos == in_size) - return LZMA_OK; - - if (((index_hash->crc32 >> (index_hash->pos * 8)) - & 0xFF) != in[(*in_pos)++]) - return LZMA_DATA_ERROR; - - } while (++index_hash->pos < 4); - - return LZMA_STREAM_END; - - default: - assert(0); - return LZMA_PROG_ERROR; - } - -out: - // Update the CRC32, - index_hash->crc32 = lzma_crc32(in + in_start, - *in_pos - in_start, index_hash->crc32); - - return ret; -} diff --git a/deps/lzma/liblzma/common/stream_buffer_decoder.c b/deps/lzma/liblzma/common/stream_buffer_decoder.c deleted file mode 100644 index ae75315..0000000 --- a/deps/lzma/liblzma/common/stream_buffer_decoder.c +++ /dev/null @@ -1,91 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file stream_buffer_decoder.c -/// \brief Single-call .xz Stream decoder -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "stream_decoder.h" - - -extern LZMA_API(lzma_ret) -lzma_stream_buffer_decode(uint64_t *memlimit, uint32_t flags, - lzma_allocator *allocator, - const uint8_t *in, size_t *in_pos, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) -{ - // Sanity checks - if (in_pos == NULL || (in == NULL && *in_pos != in_size) - || *in_pos > in_size || out_pos == NULL - || (out == NULL && *out_pos != out_size) - || *out_pos > out_size) - return LZMA_PROG_ERROR; - - // Catch flags that are not allowed in buffer-to-buffer decoding. - if (flags & LZMA_TELL_ANY_CHECK) - return LZMA_PROG_ERROR; - - // Initialize the Stream decoder. - // TODO: We need something to tell the decoder that it can use the - // output buffer as workspace, and thus save significant amount of RAM. - lzma_next_coder stream_decoder = LZMA_NEXT_CODER_INIT; - lzma_ret ret = lzma_stream_decoder_init( - &stream_decoder, allocator, *memlimit, flags); - - if (ret == LZMA_OK) { - // Save the positions so that we can restore them in case - // an error occurs. - const size_t in_start = *in_pos; - const size_t out_start = *out_pos; - - // Do the actual decoding. - ret = stream_decoder.code(stream_decoder.coder, allocator, - in, in_pos, in_size, out, out_pos, out_size, - LZMA_FINISH); - - if (ret == LZMA_STREAM_END) { - ret = LZMA_OK; - } else { - // Something went wrong, restore the positions. - *in_pos = in_start; - *out_pos = out_start; - - if (ret == LZMA_OK) { - // Either the input was truncated or the - // output buffer was too small. - assert(*in_pos == in_size - || *out_pos == out_size); - - // If all the input was consumed, then the - // input is truncated, even if the output - // buffer is also full. This is because - // processing the last byte of the Stream - // never produces output. - if (*in_pos == in_size) - ret = LZMA_DATA_ERROR; - else - ret = LZMA_BUF_ERROR; - - } else if (ret == LZMA_MEMLIMIT_ERROR) { - // Let the caller know how much memory would - // have been needed. - uint64_t memusage; - (void)stream_decoder.memconfig( - stream_decoder.coder, - memlimit, &memusage, 0); - } - } - } - - // Free the decoder memory. This needs to be done even if - // initialization fails, because the internal API doesn't - // require the initialization function to free its memory on error. - lzma_next_end(&stream_decoder, allocator); - - return ret; -} diff --git a/deps/lzma/liblzma/common/stream_buffer_encoder.c b/deps/lzma/liblzma/common/stream_buffer_encoder.c deleted file mode 100644 index 2450ee2..0000000 --- a/deps/lzma/liblzma/common/stream_buffer_encoder.c +++ /dev/null @@ -1,140 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file stream_buffer_encoder.c -/// \brief Single-call .xz Stream encoder -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "index.h" - - -/// Maximum size of Index that has exactly one Record. -/// Index Indicator + Number of Records + Record + CRC32 rounded up to -/// the next multiple of four. -#define INDEX_BOUND ((1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 4 + 3) & ~3) - -/// Stream Header, Stream Footer, and Index -#define HEADERS_BOUND (2 * LZMA_STREAM_HEADER_SIZE + INDEX_BOUND) - - -extern LZMA_API(size_t) -lzma_stream_buffer_bound(size_t uncompressed_size) -{ - // Get the maximum possible size of a Block. - const size_t block_bound = lzma_block_buffer_bound(uncompressed_size); - if (block_bound == 0) - return 0; - - // Catch the possible integer overflow and also prevent the size of - // the Stream exceeding LZMA_VLI_MAX (theoretically possible on - // 64-bit systems). - if (my_min(SIZE_MAX, LZMA_VLI_MAX) - block_bound < HEADERS_BOUND) - return 0; - - return block_bound + HEADERS_BOUND; -} - - -extern LZMA_API(lzma_ret) -lzma_stream_buffer_encode(lzma_filter *filters, lzma_check check, - lzma_allocator *allocator, const uint8_t *in, size_t in_size, - uint8_t *out, size_t *out_pos_ptr, size_t out_size) -{ - // Sanity checks - if (filters == NULL || (unsigned int)(check) > LZMA_CHECK_ID_MAX - || (in == NULL && in_size != 0) || out == NULL - || out_pos_ptr == NULL || *out_pos_ptr > out_size) - return LZMA_PROG_ERROR; - - if (!lzma_check_is_supported(check)) - return LZMA_UNSUPPORTED_CHECK; - - // Note for the paranoids: Index encoder prevents the Stream from - // getting too big and still being accepted with LZMA_OK, and Block - // encoder catches if the input is too big. So we don't need to - // separately check if the buffers are too big. - - // Use a local copy. We update *out_pos_ptr only if everything - // succeeds. - size_t out_pos = *out_pos_ptr; - - // Check that there's enough space for both Stream Header and - // Stream Footer. - if (out_size - out_pos <= 2 * LZMA_STREAM_HEADER_SIZE) - return LZMA_BUF_ERROR; - - // Reserve space for Stream Footer so we don't need to check for - // available space again before encoding Stream Footer. - out_size -= LZMA_STREAM_HEADER_SIZE; - - // Encode the Stream Header. - lzma_stream_flags stream_flags = { - .version = 0, - .check = check, - }; - - if (lzma_stream_header_encode(&stream_flags, out + out_pos) - != LZMA_OK) - return LZMA_PROG_ERROR; - - out_pos += LZMA_STREAM_HEADER_SIZE; - - // Encode a Block but only if there is at least one byte of input. - lzma_block block = { - .version = 0, - .check = check, - .filters = filters, - }; - - if (in_size > 0) - return_if_error(lzma_block_buffer_encode(&block, allocator, - in, in_size, out, &out_pos, out_size)); - - // Index - { - // Create an Index. It will have one Record if there was - // at least one byte of input to encode. Otherwise the - // Index will be empty. - lzma_index *i = lzma_index_init(allocator); - if (i == NULL) - return LZMA_MEM_ERROR; - - lzma_ret ret = LZMA_OK; - - if (in_size > 0) - ret = lzma_index_append(i, allocator, - lzma_block_unpadded_size(&block), - block.uncompressed_size); - - // If adding the Record was successful, encode the Index - // and get its size which will be stored into Stream Footer. - if (ret == LZMA_OK) { - ret = lzma_index_buffer_encode( - i, out, &out_pos, out_size); - - stream_flags.backward_size = lzma_index_size(i); - } - - lzma_index_end(i, allocator); - - if (ret != LZMA_OK) - return ret; - } - - // Stream Footer. We have already reserved space for this. - if (lzma_stream_footer_encode(&stream_flags, out + out_pos) - != LZMA_OK) - return LZMA_PROG_ERROR; - - out_pos += LZMA_STREAM_HEADER_SIZE; - - // Everything went fine, make the new output position available - // to the application. - *out_pos_ptr = out_pos; - return LZMA_OK; -} diff --git a/deps/lzma/liblzma/common/stream_decoder.c b/deps/lzma/liblzma/common/stream_decoder.c deleted file mode 100644 index 37ea71e..0000000 --- a/deps/lzma/liblzma/common/stream_decoder.c +++ /dev/null @@ -1,451 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file stream_decoder.c -/// \brief Decodes .xz Streams -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "stream_decoder.h" -#include "block_decoder.h" - - -struct lzma_coder_s { - enum { - SEQ_STREAM_HEADER, - SEQ_BLOCK_HEADER, - SEQ_BLOCK, - SEQ_INDEX, - SEQ_STREAM_FOOTER, - SEQ_STREAM_PADDING, - } sequence; - - /// Block or Metadata decoder. This takes little memory and the same - /// data structure can be used to decode every Block Header, so it's - /// a good idea to have a separate lzma_next_coder structure for it. - lzma_next_coder block_decoder; - - /// Block options decoded by the Block Header decoder and used by - /// the Block decoder. - lzma_block block_options; - - /// Stream Flags from Stream Header - lzma_stream_flags stream_flags; - - /// Index is hashed so that it can be compared to the sizes of Blocks - /// with O(1) memory usage. - lzma_index_hash *index_hash; - - /// Memory usage limit - uint64_t memlimit; - - /// Amount of memory actually needed (only an estimate) - uint64_t memusage; - - /// If true, LZMA_NO_CHECK is returned if the Stream has - /// no integrity check. - bool tell_no_check; - - /// If true, LZMA_UNSUPPORTED_CHECK is returned if the Stream has - /// an integrity check that isn't supported by this liblzma build. - bool tell_unsupported_check; - - /// If true, LZMA_GET_CHECK is returned after decoding Stream Header. - bool tell_any_check; - - /// If true, we will decode concatenated Streams that possibly have - /// Stream Padding between or after them. LZMA_STREAM_END is returned - /// once the application isn't giving us any new input, and we aren't - /// in the middle of a Stream, and possible Stream Padding is a - /// multiple of four bytes. - bool concatenated; - - /// When decoding concatenated Streams, this is true as long as we - /// are decoding the first Stream. This is needed to avoid misleading - /// LZMA_FORMAT_ERROR in case the later Streams don't have valid magic - /// bytes. - bool first_stream; - - /// Write position in buffer[] and position in Stream Padding - size_t pos; - - /// Buffer to hold Stream Header, Block Header, and Stream Footer. - /// Block Header has biggest maximum size. - uint8_t buffer[LZMA_BLOCK_HEADER_SIZE_MAX]; -}; - - -static lzma_ret -stream_decoder_reset(lzma_coder *coder, lzma_allocator *allocator) -{ - // Initialize the Index hash used to verify the Index. - coder->index_hash = lzma_index_hash_init(coder->index_hash, allocator); - if (coder->index_hash == NULL) - return LZMA_MEM_ERROR; - - // Reset the rest of the variables. - coder->sequence = SEQ_STREAM_HEADER; - coder->pos = 0; - - return LZMA_OK; -} - - -static lzma_ret -stream_decode(lzma_coder *coder, lzma_allocator *allocator, - const uint8_t *restrict in, size_t *restrict in_pos, - size_t in_size, uint8_t *restrict out, - size_t *restrict out_pos, size_t out_size, lzma_action action) -{ - // When decoding the actual Block, it may be able to produce more - // output even if we don't give it any new input. - while (true) - switch (coder->sequence) { - case SEQ_STREAM_HEADER: { - // Copy the Stream Header to the internal buffer. - lzma_bufcpy(in, in_pos, in_size, coder->buffer, &coder->pos, - LZMA_STREAM_HEADER_SIZE); - - // Return if we didn't get the whole Stream Header yet. - if (coder->pos < LZMA_STREAM_HEADER_SIZE) - return LZMA_OK; - - coder->pos = 0; - - // Decode the Stream Header. - const lzma_ret ret = lzma_stream_header_decode( - &coder->stream_flags, coder->buffer); - if (ret != LZMA_OK) - return ret == LZMA_FORMAT_ERROR && !coder->first_stream - ? LZMA_DATA_ERROR : ret; - - // If we are decoding concatenated Streams, and the later - // Streams have invalid Header Magic Bytes, we give - // LZMA_DATA_ERROR instead of LZMA_FORMAT_ERROR. - coder->first_stream = false; - - // Copy the type of the Check so that Block Header and Block - // decoders see it. - coder->block_options.check = coder->stream_flags.check; - - // Even if we return LZMA_*_CHECK below, we want - // to continue from Block Header decoding. - coder->sequence = SEQ_BLOCK_HEADER; - - // Detect if there's no integrity check or if it is - // unsupported if those were requested by the application. - if (coder->tell_no_check && coder->stream_flags.check - == LZMA_CHECK_NONE) - return LZMA_NO_CHECK; - - if (coder->tell_unsupported_check - && !lzma_check_is_supported( - coder->stream_flags.check)) - return LZMA_UNSUPPORTED_CHECK; - - if (coder->tell_any_check) - return LZMA_GET_CHECK; - } - - // Fall through - - case SEQ_BLOCK_HEADER: { - if (*in_pos >= in_size) - return LZMA_OK; - - if (coder->pos == 0) { - // Detect if it's Index. - if (in[*in_pos] == 0x00) { - coder->sequence = SEQ_INDEX; - break; - } - - // Calculate the size of the Block Header. Note that - // Block Header decoder wants to see this byte too - // so don't advance *in_pos. - coder->block_options.header_size - = lzma_block_header_size_decode( - in[*in_pos]); - } - - // Copy the Block Header to the internal buffer. - lzma_bufcpy(in, in_pos, in_size, coder->buffer, &coder->pos, - coder->block_options.header_size); - - // Return if we didn't get the whole Block Header yet. - if (coder->pos < coder->block_options.header_size) - return LZMA_OK; - - coder->pos = 0; - - // Version 0 is currently the only possible version. - coder->block_options.version = 0; - - // Set up a buffer to hold the filter chain. Block Header - // decoder will initialize all members of this array so - // we don't need to do it here. - lzma_filter filters[LZMA_FILTERS_MAX + 1]; - coder->block_options.filters = filters; - - // Decode the Block Header. - return_if_error(lzma_block_header_decode(&coder->block_options, - allocator, coder->buffer)); - - // Check the memory usage limit. - const uint64_t memusage = lzma_raw_decoder_memusage(filters); - lzma_ret ret; - - if (memusage == UINT64_MAX) { - // One or more unknown Filter IDs. - ret = LZMA_OPTIONS_ERROR; - } else { - // Now we can set coder->memusage since we know that - // the filter chain is valid. We don't want - // lzma_memusage() to return UINT64_MAX in case of - // invalid filter chain. - coder->memusage = memusage; - - if (memusage > coder->memlimit) { - // The chain would need too much memory. - ret = LZMA_MEMLIMIT_ERROR; - } else { - // Memory usage is OK. - // Initialize the Block decoder. - ret = lzma_block_decoder_init( - &coder->block_decoder, - allocator, - &coder->block_options); - } - } - - // Free the allocated filter options since they are needed - // only to initialize the Block decoder. - for (size_t i = 0; i < LZMA_FILTERS_MAX; ++i) - lzma_free(filters[i].options, allocator); - - coder->block_options.filters = NULL; - - // Check if memory usage calculation and Block enocoder - // initialization succeeded. - if (ret != LZMA_OK) - return ret; - - coder->sequence = SEQ_BLOCK; - } - - // Fall through - - case SEQ_BLOCK: { - const lzma_ret ret = coder->block_decoder.code( - coder->block_decoder.coder, allocator, - in, in_pos, in_size, out, out_pos, out_size, - action); - - if (ret != LZMA_STREAM_END) - return ret; - - // Block decoded successfully. Add the new size pair to - // the Index hash. - return_if_error(lzma_index_hash_append(coder->index_hash, - lzma_block_unpadded_size( - &coder->block_options), - coder->block_options.uncompressed_size)); - - coder->sequence = SEQ_BLOCK_HEADER; - break; - } - - case SEQ_INDEX: { - // If we don't have any input, don't call - // lzma_index_hash_decode() since it would return - // LZMA_BUF_ERROR, which we must not do here. - if (*in_pos >= in_size) - return LZMA_OK; - - // Decode the Index and compare it to the hash calculated - // from the sizes of the Blocks (if any). - const lzma_ret ret = lzma_index_hash_decode(coder->index_hash, - in, in_pos, in_size); - if (ret != LZMA_STREAM_END) - return ret; - - coder->sequence = SEQ_STREAM_FOOTER; - } - - // Fall through - - case SEQ_STREAM_FOOTER: { - // Copy the Stream Footer to the internal buffer. - lzma_bufcpy(in, in_pos, in_size, coder->buffer, &coder->pos, - LZMA_STREAM_HEADER_SIZE); - - // Return if we didn't get the whole Stream Footer yet. - if (coder->pos < LZMA_STREAM_HEADER_SIZE) - return LZMA_OK; - - coder->pos = 0; - - // Decode the Stream Footer. The decoder gives - // LZMA_FORMAT_ERROR if the magic bytes don't match, - // so convert that return code to LZMA_DATA_ERROR. - lzma_stream_flags footer_flags; - const lzma_ret ret = lzma_stream_footer_decode( - &footer_flags, coder->buffer); - if (ret != LZMA_OK) - return ret == LZMA_FORMAT_ERROR - ? LZMA_DATA_ERROR : ret; - - // Check that Index Size stored in the Stream Footer matches - // the real size of the Index field. - if (lzma_index_hash_size(coder->index_hash) - != footer_flags.backward_size) - return LZMA_DATA_ERROR; - - // Compare that the Stream Flags fields are identical in - // both Stream Header and Stream Footer. - return_if_error(lzma_stream_flags_compare( - &coder->stream_flags, &footer_flags)); - - if (!coder->concatenated) - return LZMA_STREAM_END; - - coder->sequence = SEQ_STREAM_PADDING; - } - - // Fall through - - case SEQ_STREAM_PADDING: - assert(coder->concatenated); - - // Skip over possible Stream Padding. - while (true) { - if (*in_pos >= in_size) { - // Unless LZMA_FINISH was used, we cannot - // know if there's more input coming later. - if (action != LZMA_FINISH) - return LZMA_OK; - - // Stream Padding must be a multiple of - // four bytes. - return coder->pos == 0 - ? LZMA_STREAM_END - : LZMA_DATA_ERROR; - } - - // If the byte is not zero, it probably indicates - // beginning of a new Stream (or the file is corrupt). - if (in[*in_pos] != 0x00) - break; - - ++*in_pos; - coder->pos = (coder->pos + 1) & 3; - } - - // Stream Padding must be a multiple of four bytes (empty - // Stream Padding is OK). - if (coder->pos != 0) { - ++*in_pos; - return LZMA_DATA_ERROR; - } - - // Prepare to decode the next Stream. - return_if_error(stream_decoder_reset(coder, allocator)); - break; - - default: - assert(0); - return LZMA_PROG_ERROR; - } - - // Never reached -} - - -static void -stream_decoder_end(lzma_coder *coder, lzma_allocator *allocator) -{ - lzma_next_end(&coder->block_decoder, allocator); - lzma_index_hash_end(coder->index_hash, allocator); - lzma_free(coder, allocator); - return; -} - - -static lzma_check -stream_decoder_get_check(const lzma_coder *coder) -{ - return coder->stream_flags.check; -} - - -static lzma_ret -stream_decoder_memconfig(lzma_coder *coder, uint64_t *memusage, - uint64_t *old_memlimit, uint64_t new_memlimit) -{ - *memusage = coder->memusage; - *old_memlimit = coder->memlimit; - - if (new_memlimit != 0) { - if (new_memlimit < coder->memusage) - return LZMA_MEMLIMIT_ERROR; - - coder->memlimit = new_memlimit; - } - - return LZMA_OK; -} - - -extern lzma_ret -lzma_stream_decoder_init(lzma_next_coder *next, lzma_allocator *allocator, - uint64_t memlimit, uint32_t flags) -{ - lzma_next_coder_init(&lzma_stream_decoder_init, next, allocator); - - if (memlimit == 0) - return LZMA_PROG_ERROR; - - if (flags & ~LZMA_SUPPORTED_FLAGS) - return LZMA_OPTIONS_ERROR; - - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) - return LZMA_MEM_ERROR; - - next->code = &stream_decode; - next->end = &stream_decoder_end; - next->get_check = &stream_decoder_get_check; - next->memconfig = &stream_decoder_memconfig; - - next->coder->block_decoder = LZMA_NEXT_CODER_INIT; - next->coder->index_hash = NULL; - } - - next->coder->memlimit = memlimit; - next->coder->memusage = LZMA_MEMUSAGE_BASE; - next->coder->tell_no_check = (flags & LZMA_TELL_NO_CHECK) != 0; - next->coder->tell_unsupported_check - = (flags & LZMA_TELL_UNSUPPORTED_CHECK) != 0; - next->coder->tell_any_check = (flags & LZMA_TELL_ANY_CHECK) != 0; - next->coder->concatenated = (flags & LZMA_CONCATENATED) != 0; - next->coder->first_stream = true; - - return stream_decoder_reset(next->coder, allocator); -} - - -extern LZMA_API(lzma_ret) -lzma_stream_decoder(lzma_stream *strm, uint64_t memlimit, uint32_t flags) -{ - lzma_next_strm_init(lzma_stream_decoder_init, strm, memlimit, flags); - - strm->internal->supported_actions[LZMA_RUN] = true; - strm->internal->supported_actions[LZMA_FINISH] = true; - - return LZMA_OK; -} diff --git a/deps/lzma/liblzma/common/stream_decoder.h b/deps/lzma/liblzma/common/stream_decoder.h deleted file mode 100644 index e54ac28..0000000 --- a/deps/lzma/liblzma/common/stream_decoder.h +++ /dev/null @@ -1,21 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file stream_decoder.h -/// \brief Decodes .xz Streams -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_STREAM_DECODER_H -#define LZMA_STREAM_DECODER_H - -#include "common.h" - -extern lzma_ret lzma_stream_decoder_init(lzma_next_coder *next, - lzma_allocator *allocator, uint64_t memlimit, uint32_t flags); - -#endif diff --git a/deps/lzma/liblzma/common/stream_encoder.c b/deps/lzma/liblzma/common/stream_encoder.c deleted file mode 100644 index 97a7a23..0000000 --- a/deps/lzma/liblzma/common/stream_encoder.c +++ /dev/null @@ -1,331 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file stream_encoder.c -/// \brief Encodes .xz Streams -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "stream_encoder.h" -#include "block_encoder.h" -#include "index_encoder.h" - - -struct lzma_coder_s { - enum { - SEQ_STREAM_HEADER, - SEQ_BLOCK_INIT, - SEQ_BLOCK_HEADER, - SEQ_BLOCK_ENCODE, - SEQ_INDEX_ENCODE, - SEQ_STREAM_FOOTER, - } sequence; - - /// True if Block encoder has been initialized by - /// lzma_stream_encoder_init() or stream_encoder_update() - /// and thus doesn't need to be initialized in stream_encode(). - bool block_encoder_is_initialized; - - /// Block - lzma_next_coder block_encoder; - - /// Options for the Block encoder - lzma_block block_options; - - /// The filter chain currently in use - lzma_filter filters[LZMA_FILTERS_MAX + 1]; - - /// Index encoder. This is separate from Block encoder, because this - /// doesn't take much memory, and when encoding multiple Streams - /// with the same encoding options we avoid reallocating memory. - lzma_next_coder index_encoder; - - /// Index to hold sizes of the Blocks - lzma_index *index; - - /// Read position in buffer[] - size_t buffer_pos; - - /// Total number of bytes in buffer[] - size_t buffer_size; - - /// Buffer to hold Stream Header, Block Header, and Stream Footer. - /// Block Header has biggest maximum size. - uint8_t buffer[LZMA_BLOCK_HEADER_SIZE_MAX]; -}; - - -static lzma_ret -block_encoder_init(lzma_coder *coder, lzma_allocator *allocator) -{ - // Prepare the Block options. Even though Block encoder doesn't need - // compressed_size, uncompressed_size, and header_size to be - // initialized, it is a good idea to do it here, because this way - // we catch if someone gave us Filter ID that cannot be used in - // Blocks/Streams. - coder->block_options.compressed_size = LZMA_VLI_UNKNOWN; - coder->block_options.uncompressed_size = LZMA_VLI_UNKNOWN; - - return_if_error(lzma_block_header_size(&coder->block_options)); - - // Initialize the actual Block encoder. - return lzma_block_encoder_init(&coder->block_encoder, allocator, - &coder->block_options); -} - - -static lzma_ret -stream_encode(lzma_coder *coder, lzma_allocator *allocator, - const uint8_t *restrict in, size_t *restrict in_pos, - size_t in_size, uint8_t *restrict out, - size_t *restrict out_pos, size_t out_size, lzma_action action) -{ - // Main loop - while (*out_pos < out_size) - switch (coder->sequence) { - case SEQ_STREAM_HEADER: - case SEQ_BLOCK_HEADER: - case SEQ_STREAM_FOOTER: - lzma_bufcpy(coder->buffer, &coder->buffer_pos, - coder->buffer_size, out, out_pos, out_size); - if (coder->buffer_pos < coder->buffer_size) - return LZMA_OK; - - if (coder->sequence == SEQ_STREAM_FOOTER) - return LZMA_STREAM_END; - - coder->buffer_pos = 0; - ++coder->sequence; - break; - - case SEQ_BLOCK_INIT: { - if (*in_pos == in_size) { - // If we are requested to flush or finish the current - // Block, return LZMA_STREAM_END immediately since - // there's nothing to do. - if (action != LZMA_FINISH) - return action == LZMA_RUN - ? LZMA_OK : LZMA_STREAM_END; - - // The application had used LZMA_FULL_FLUSH to finish - // the previous Block, but now wants to finish without - // encoding new data, or it is simply creating an - // empty Stream with no Blocks. - // - // Initialize the Index encoder, and continue to - // actually encoding the Index. - return_if_error(lzma_index_encoder_init( - &coder->index_encoder, allocator, - coder->index)); - coder->sequence = SEQ_INDEX_ENCODE; - break; - } - - // Initialize the Block encoder unless it was already - // initialized by lzma_stream_encoder_init() or - // stream_encoder_update(). - if (!coder->block_encoder_is_initialized) - return_if_error(block_encoder_init(coder, allocator)); - - // Make it false so that we don't skip the initialization - // with the next Block. - coder->block_encoder_is_initialized = false; - - // Encode the Block Header. This shouldn't fail since we have - // already initialized the Block encoder. - if (lzma_block_header_encode(&coder->block_options, - coder->buffer) != LZMA_OK) - return LZMA_PROG_ERROR; - - coder->buffer_size = coder->block_options.header_size; - coder->sequence = SEQ_BLOCK_HEADER; - break; - } - - case SEQ_BLOCK_ENCODE: { - static const lzma_action convert[4] = { - LZMA_RUN, - LZMA_SYNC_FLUSH, - LZMA_FINISH, - LZMA_FINISH, - }; - - const lzma_ret ret = coder->block_encoder.code( - coder->block_encoder.coder, allocator, - in, in_pos, in_size, - out, out_pos, out_size, convert[action]); - if (ret != LZMA_STREAM_END || action == LZMA_SYNC_FLUSH) - return ret; - - // Add a new Index Record. - const lzma_vli unpadded_size = lzma_block_unpadded_size( - &coder->block_options); - assert(unpadded_size != 0); - return_if_error(lzma_index_append(coder->index, allocator, - unpadded_size, - coder->block_options.uncompressed_size)); - - coder->sequence = SEQ_BLOCK_INIT; - break; - } - - case SEQ_INDEX_ENCODE: { - // Call the Index encoder. It doesn't take any input, so - // those pointers can be NULL. - const lzma_ret ret = coder->index_encoder.code( - coder->index_encoder.coder, allocator, - NULL, NULL, 0, - out, out_pos, out_size, LZMA_RUN); - if (ret != LZMA_STREAM_END) - return ret; - - // Encode the Stream Footer into coder->buffer. - const lzma_stream_flags stream_flags = { - .version = 0, - .backward_size = lzma_index_size(coder->index), - .check = coder->block_options.check, - }; - - if (lzma_stream_footer_encode(&stream_flags, coder->buffer) - != LZMA_OK) - return LZMA_PROG_ERROR; - - coder->buffer_size = LZMA_STREAM_HEADER_SIZE; - coder->sequence = SEQ_STREAM_FOOTER; - break; - } - - default: - assert(0); - return LZMA_PROG_ERROR; - } - - return LZMA_OK; -} - - -static void -stream_encoder_end(lzma_coder *coder, lzma_allocator *allocator) -{ - lzma_next_end(&coder->block_encoder, allocator); - lzma_next_end(&coder->index_encoder, allocator); - lzma_index_end(coder->index, allocator); - - for (size_t i = 0; coder->filters[i].id != LZMA_VLI_UNKNOWN; ++i) - lzma_free(coder->filters[i].options, allocator); - - lzma_free(coder, allocator); - return; -} - - -static lzma_ret -stream_encoder_update(lzma_coder *coder, lzma_allocator *allocator, - const lzma_filter *filters, - const lzma_filter *reversed_filters) -{ - if (coder->sequence <= SEQ_BLOCK_INIT) { - // There is no incomplete Block waiting to be finished, - // thus we can change the whole filter chain. Start by - // trying to initialize the Block encoder with the new - // chain. This way we detect if the chain is valid. - coder->block_encoder_is_initialized = false; - coder->block_options.filters = (lzma_filter *)(filters); - const lzma_ret ret = block_encoder_init(coder, allocator); - coder->block_options.filters = coder->filters; - if (ret != LZMA_OK) - return ret; - - coder->block_encoder_is_initialized = true; - - } else if (coder->sequence <= SEQ_BLOCK_ENCODE) { - // We are in the middle of a Block. Try to update only - // the filter-specific options. - return_if_error(coder->block_encoder.update( - coder->block_encoder.coder, allocator, - filters, reversed_filters)); - } else { - // Trying to update the filter chain when we are already - // encoding Index or Stream Footer. - return LZMA_PROG_ERROR; - } - - // Free the copy of the old chain and make a copy of the new chain. - for (size_t i = 0; coder->filters[i].id != LZMA_VLI_UNKNOWN; ++i) - lzma_free(coder->filters[i].options, allocator); - - return lzma_filters_copy(filters, coder->filters, allocator); -} - - -extern lzma_ret -lzma_stream_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter *filters, lzma_check check) -{ - lzma_next_coder_init(&lzma_stream_encoder_init, next, allocator); - - if (filters == NULL) - return LZMA_PROG_ERROR; - - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) - return LZMA_MEM_ERROR; - - next->code = &stream_encode; - next->end = &stream_encoder_end; - next->update = &stream_encoder_update; - - next->coder->filters[0].id = LZMA_VLI_UNKNOWN; - next->coder->block_encoder = LZMA_NEXT_CODER_INIT; - next->coder->index_encoder = LZMA_NEXT_CODER_INIT; - next->coder->index = NULL; - } - - // Basic initializations - next->coder->sequence = SEQ_STREAM_HEADER; - next->coder->block_options.version = 0; - next->coder->block_options.check = check; - - // Initialize the Index - lzma_index_end(next->coder->index, allocator); - next->coder->index = lzma_index_init(allocator); - if (next->coder->index == NULL) - return LZMA_MEM_ERROR; - - // Encode the Stream Header - lzma_stream_flags stream_flags = { - .version = 0, - .check = check, - }; - return_if_error(lzma_stream_header_encode( - &stream_flags, next->coder->buffer)); - - next->coder->buffer_pos = 0; - next->coder->buffer_size = LZMA_STREAM_HEADER_SIZE; - - // Initialize the Block encoder. This way we detect unsupported - // filter chains when initializing the Stream encoder instead of - // giving an error after Stream Header has already written out. - return stream_encoder_update( - next->coder, allocator, filters, NULL); -} - - -extern LZMA_API(lzma_ret) -lzma_stream_encoder(lzma_stream *strm, - const lzma_filter *filters, lzma_check check) -{ - lzma_next_strm_init(lzma_stream_encoder_init, strm, filters, check); - - strm->internal->supported_actions[LZMA_RUN] = true; - strm->internal->supported_actions[LZMA_SYNC_FLUSH] = true; - strm->internal->supported_actions[LZMA_FULL_FLUSH] = true; - strm->internal->supported_actions[LZMA_FINISH] = true; - - return LZMA_OK; -} diff --git a/deps/lzma/liblzma/common/stream_encoder.h b/deps/lzma/liblzma/common/stream_encoder.h deleted file mode 100644 index 46a7aed..0000000 --- a/deps/lzma/liblzma/common/stream_encoder.h +++ /dev/null @@ -1,23 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file stream_encoder.h -/// \brief Encodes .xz Streams -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_STREAM_ENCODER_H -#define LZMA_STREAM_ENCODER_H - -#include "common.h" - - -extern lzma_ret lzma_stream_encoder_init( - lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter *filters, lzma_check check); - -#endif diff --git a/deps/lzma/liblzma/common/stream_flags_common.c b/deps/lzma/liblzma/common/stream_flags_common.c deleted file mode 100644 index fbe8eb8..0000000 --- a/deps/lzma/liblzma/common/stream_flags_common.c +++ /dev/null @@ -1,47 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file stream_flags_common.c -/// \brief Common stuff for Stream flags coders -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "stream_flags_common.h" - - -const uint8_t lzma_header_magic[6] = { 0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00 }; -const uint8_t lzma_footer_magic[2] = { 0x59, 0x5A }; - - -extern LZMA_API(lzma_ret) -lzma_stream_flags_compare( - const lzma_stream_flags *a, const lzma_stream_flags *b) -{ - // We can compare only version 0 structures. - if (a->version != 0 || b->version != 0) - return LZMA_OPTIONS_ERROR; - - // Check type - if ((unsigned int)(a->check) > LZMA_CHECK_ID_MAX - || (unsigned int)(b->check) > LZMA_CHECK_ID_MAX) - return LZMA_PROG_ERROR; - - if (a->check != b->check) - return LZMA_DATA_ERROR; - - // Backward Sizes are compared only if they are known in both. - if (a->backward_size != LZMA_VLI_UNKNOWN - && b->backward_size != LZMA_VLI_UNKNOWN) { - if (!is_backward_size_valid(a) || !is_backward_size_valid(b)) - return LZMA_PROG_ERROR; - - if (a->backward_size != b->backward_size) - return LZMA_DATA_ERROR; - } - - return LZMA_OK; -} diff --git a/deps/lzma/liblzma/common/stream_flags_common.h b/deps/lzma/liblzma/common/stream_flags_common.h deleted file mode 100644 index 9f3122a..0000000 --- a/deps/lzma/liblzma/common/stream_flags_common.h +++ /dev/null @@ -1,33 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file stream_flags_common.h -/// \brief Common stuff for Stream flags coders -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_STREAM_FLAGS_COMMON_H -#define LZMA_STREAM_FLAGS_COMMON_H - -#include "common.h" - -/// Size of the Stream Flags field -#define LZMA_STREAM_FLAGS_SIZE 2 - -extern const uint8_t lzma_header_magic[6]; -extern const uint8_t lzma_footer_magic[2]; - - -static inline bool -is_backward_size_valid(const lzma_stream_flags *options) -{ - return options->backward_size >= LZMA_BACKWARD_SIZE_MIN - && options->backward_size <= LZMA_BACKWARD_SIZE_MAX - && (options->backward_size & 3) == 0; -} - -#endif diff --git a/deps/lzma/liblzma/common/stream_flags_decoder.c b/deps/lzma/liblzma/common/stream_flags_decoder.c deleted file mode 100644 index 1bc2f97..0000000 --- a/deps/lzma/liblzma/common/stream_flags_decoder.c +++ /dev/null @@ -1,82 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file stream_flags_decoder.c -/// \brief Decodes Stream Header and Stream Footer from .xz files -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "stream_flags_common.h" - - -static bool -stream_flags_decode(lzma_stream_flags *options, const uint8_t *in) -{ - // Reserved bits must be unset. - if (in[0] != 0x00 || (in[1] & 0xF0)) - return true; - - options->version = 0; - options->check = in[1] & 0x0F; - - return false; -} - - -extern LZMA_API(lzma_ret) -lzma_stream_header_decode(lzma_stream_flags *options, const uint8_t *in) -{ - // Magic - if (memcmp(in, lzma_header_magic, sizeof(lzma_header_magic)) != 0) - return LZMA_FORMAT_ERROR; - - // Verify the CRC32 so we can distinguish between corrupt - // and unsupported files. - const uint32_t crc = lzma_crc32(in + sizeof(lzma_header_magic), - LZMA_STREAM_FLAGS_SIZE, 0); - if (crc != unaligned_read32le(in + sizeof(lzma_header_magic) - + LZMA_STREAM_FLAGS_SIZE)) - return LZMA_DATA_ERROR; - - // Stream Flags - if (stream_flags_decode(options, in + sizeof(lzma_header_magic))) - return LZMA_OPTIONS_ERROR; - - // Set Backward Size to indicate unknown value. That way - // lzma_stream_flags_compare() can be used to compare Stream Header - // and Stream Footer while keeping it useful also for comparing - // two Stream Footers. - options->backward_size = LZMA_VLI_UNKNOWN; - - return LZMA_OK; -} - - -extern LZMA_API(lzma_ret) -lzma_stream_footer_decode(lzma_stream_flags *options, const uint8_t *in) -{ - // Magic - if (memcmp(in + sizeof(uint32_t) * 2 + LZMA_STREAM_FLAGS_SIZE, - lzma_footer_magic, sizeof(lzma_footer_magic)) != 0) - return LZMA_FORMAT_ERROR; - - // CRC32 - const uint32_t crc = lzma_crc32(in + sizeof(uint32_t), - sizeof(uint32_t) + LZMA_STREAM_FLAGS_SIZE, 0); - if (crc != unaligned_read32le(in)) - return LZMA_DATA_ERROR; - - // Stream Flags - if (stream_flags_decode(options, in + sizeof(uint32_t) * 2)) - return LZMA_OPTIONS_ERROR; - - // Backward Size - options->backward_size = unaligned_read32le(in + sizeof(uint32_t)); - options->backward_size = (options->backward_size + 1) * 4; - - return LZMA_OK; -} diff --git a/deps/lzma/liblzma/common/stream_flags_encoder.c b/deps/lzma/liblzma/common/stream_flags_encoder.c deleted file mode 100644 index 4e71715..0000000 --- a/deps/lzma/liblzma/common/stream_flags_encoder.c +++ /dev/null @@ -1,86 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file stream_flags_encoder.c -/// \brief Encodes Stream Header and Stream Footer for .xz files -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "stream_flags_common.h" - - -static bool -stream_flags_encode(const lzma_stream_flags *options, uint8_t *out) -{ - if ((unsigned int)(options->check) > LZMA_CHECK_ID_MAX) - return true; - - out[0] = 0x00; - out[1] = options->check; - - return false; -} - - -extern LZMA_API(lzma_ret) -lzma_stream_header_encode(const lzma_stream_flags *options, uint8_t *out) -{ - assert(sizeof(lzma_header_magic) + LZMA_STREAM_FLAGS_SIZE - + 4 == LZMA_STREAM_HEADER_SIZE); - - if (options->version != 0) - return LZMA_OPTIONS_ERROR; - - // Magic - memcpy(out, lzma_header_magic, sizeof(lzma_header_magic)); - - // Stream Flags - if (stream_flags_encode(options, out + sizeof(lzma_header_magic))) - return LZMA_PROG_ERROR; - - // CRC32 of the Stream Header - const uint32_t crc = lzma_crc32(out + sizeof(lzma_header_magic), - LZMA_STREAM_FLAGS_SIZE, 0); - - unaligned_write32le(out + sizeof(lzma_header_magic) - + LZMA_STREAM_FLAGS_SIZE, crc); - - return LZMA_OK; -} - - -extern LZMA_API(lzma_ret) -lzma_stream_footer_encode(const lzma_stream_flags *options, uint8_t *out) -{ - assert(2 * 4 + LZMA_STREAM_FLAGS_SIZE + sizeof(lzma_footer_magic) - == LZMA_STREAM_HEADER_SIZE); - - if (options->version != 0) - return LZMA_OPTIONS_ERROR; - - // Backward Size - if (!is_backward_size_valid(options)) - return LZMA_PROG_ERROR; - - unaligned_write32le(out + 4, options->backward_size / 4 - 1); - - // Stream Flags - if (stream_flags_encode(options, out + 2 * 4)) - return LZMA_PROG_ERROR; - - // CRC32 - const uint32_t crc = lzma_crc32( - out + 4, 4 + LZMA_STREAM_FLAGS_SIZE, 0); - - unaligned_write32le(out, crc); - - // Magic - memcpy(out + 2 * 4 + LZMA_STREAM_FLAGS_SIZE, - lzma_footer_magic, sizeof(lzma_footer_magic)); - - return LZMA_OK; -} diff --git a/deps/lzma/liblzma/common/vli_decoder.c b/deps/lzma/liblzma/common/vli_decoder.c deleted file mode 100644 index c181828..0000000 --- a/deps/lzma/liblzma/common/vli_decoder.c +++ /dev/null @@ -1,86 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file vli_decoder.c -/// \brief Decodes variable-length integers -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "common.h" - - -extern LZMA_API(lzma_ret) -lzma_vli_decode(lzma_vli *restrict vli, size_t *vli_pos, - const uint8_t *restrict in, size_t *restrict in_pos, - size_t in_size) -{ - // If we haven't been given vli_pos, work in single-call mode. - size_t vli_pos_internal = 0; - if (vli_pos == NULL) { - vli_pos = &vli_pos_internal; - *vli = 0; - - // If there's no input, use LZMA_DATA_ERROR. This way it is - // easy to decode VLIs from buffers that have known size, - // and get the correct error code in case the buffer is - // too short. - if (*in_pos >= in_size) - return LZMA_DATA_ERROR; - - } else { - // Initialize *vli when starting to decode a new integer. - if (*vli_pos == 0) - *vli = 0; - - // Validate the arguments. - if (*vli_pos >= LZMA_VLI_BYTES_MAX - || (*vli >> (*vli_pos * 7)) != 0) - return LZMA_PROG_ERROR;; - - if (*in_pos >= in_size) - return LZMA_BUF_ERROR; - } - - do { - // Read the next byte. Use a temporary variable so that we - // can update *in_pos immediately. - const uint8_t byte = in[*in_pos]; - ++*in_pos; - - // Add the newly read byte to *vli. - *vli += (lzma_vli)(byte & 0x7F) << (*vli_pos * 7); - ++*vli_pos; - - // Check if this is the last byte of a multibyte integer. - if ((byte & 0x80) == 0) { - // We don't allow using variable-length integers as - // padding i.e. the encoding must use the most the - // compact form. - if (byte == 0x00 && *vli_pos > 1) - return LZMA_DATA_ERROR; - - return vli_pos == &vli_pos_internal - ? LZMA_OK : LZMA_STREAM_END; - } - - // There is at least one more byte coming. If we have already - // read maximum number of bytes, the integer is considered - // corrupt. - // - // If we need bigger integers in future, old versions liblzma - // will confusingly indicate the file being corrupt istead of - // unsupported. I suppose it's still better this way, because - // in the foreseeable future (writing this in 2008) the only - // reason why files would appear having over 63-bit integers - // is that the files are simply corrupt. - if (*vli_pos == LZMA_VLI_BYTES_MAX) - return LZMA_DATA_ERROR; - - } while (*in_pos < in_size); - - return vli_pos == &vli_pos_internal ? LZMA_DATA_ERROR : LZMA_OK; -} diff --git a/deps/lzma/liblzma/common/vli_encoder.c b/deps/lzma/liblzma/common/vli_encoder.c deleted file mode 100644 index f864269..0000000 --- a/deps/lzma/liblzma/common/vli_encoder.c +++ /dev/null @@ -1,69 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file vli_encoder.c -/// \brief Encodes variable-length integers -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "common.h" - - -extern LZMA_API(lzma_ret) -lzma_vli_encode(lzma_vli vli, size_t *vli_pos, - uint8_t *restrict out, size_t *restrict out_pos, - size_t out_size) -{ - // If we haven't been given vli_pos, work in single-call mode. - size_t vli_pos_internal = 0; - if (vli_pos == NULL) { - vli_pos = &vli_pos_internal; - - // In single-call mode, we expect that the caller has - // reserved enough output space. - if (*out_pos >= out_size) - return LZMA_PROG_ERROR; - } else { - // This never happens when we are called by liblzma, but - // may happen if called directly from an application. - if (*out_pos >= out_size) - return LZMA_BUF_ERROR; - } - - // Validate the arguments. - if (*vli_pos >= LZMA_VLI_BYTES_MAX || vli > LZMA_VLI_MAX) - return LZMA_PROG_ERROR; - - // Shift vli so that the next bits to encode are the lowest. In - // single-call mode this never changes vli since *vli_pos is zero. - vli >>= *vli_pos * 7; - - // Write the non-last bytes in a loop. - while (vli >= 0x80) { - // We don't need *vli_pos during this function call anymore, - // but update it here so that it is ready if we need to - // return before the whole integer has been decoded. - ++*vli_pos; - assert(*vli_pos < LZMA_VLI_BYTES_MAX); - - // Write the next byte. - out[*out_pos] = (uint8_t)(vli) | 0x80; - vli >>= 7; - - if (++*out_pos == out_size) - return vli_pos == &vli_pos_internal - ? LZMA_PROG_ERROR : LZMA_OK; - } - - // Write the last byte. - out[*out_pos] = (uint8_t)(vli); - ++*out_pos; - ++*vli_pos; - - return vli_pos == &vli_pos_internal ? LZMA_OK : LZMA_STREAM_END; - -} diff --git a/deps/lzma/liblzma/common/vli_size.c b/deps/lzma/liblzma/common/vli_size.c deleted file mode 100644 index ec1b4fa..0000000 --- a/deps/lzma/liblzma/common/vli_size.c +++ /dev/null @@ -1,30 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file vli_size.c -/// \brief Calculates the encoded size of a variable-length integer -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "common.h" - - -extern LZMA_API(uint32_t) -lzma_vli_size(lzma_vli vli) -{ - if (vli > LZMA_VLI_MAX) - return 0; - - uint32_t i = 0; - do { - vli >>= 7; - ++i; - } while (vli != 0); - - assert(i <= LZMA_VLI_BYTES_MAX); - return i; -} diff --git a/deps/lzma/liblzma/delta/Makefile.inc b/deps/lzma/liblzma/delta/Makefile.inc deleted file mode 100644 index c7739b4..0000000 --- a/deps/lzma/liblzma/delta/Makefile.inc +++ /dev/null @@ -1,23 +0,0 @@ -## -## Author: Lasse Collin -## -## This file has been put into the public domain. -## You can do whatever you want with this file. -## - -liblzma_la_SOURCES += \ - delta/delta_common.c \ - delta/delta_common.h \ - delta/delta_private.h - -if COND_ENCODER_DELTA -liblzma_la_SOURCES += \ - delta/delta_encoder.c \ - delta/delta_encoder.h -endif - -if COND_DECODER_DELTA -liblzma_la_SOURCES += \ - delta/delta_decoder.c \ - delta/delta_decoder.h -endif diff --git a/deps/lzma/liblzma/delta/delta_common.c b/deps/lzma/liblzma/delta/delta_common.c deleted file mode 100644 index 930ad21..0000000 --- a/deps/lzma/liblzma/delta/delta_common.c +++ /dev/null @@ -1,70 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file delta_common.c -/// \brief Common stuff for Delta encoder and decoder -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "delta_common.h" -#include "delta_private.h" - - -static void -delta_coder_end(lzma_coder *coder, lzma_allocator *allocator) -{ - lzma_next_end(&coder->next, allocator); - lzma_free(coder, allocator); - return; -} - - -extern lzma_ret -lzma_delta_coder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters) -{ - // Allocate memory for the decoder if needed. - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) - return LZMA_MEM_ERROR; - - // End function is the same for encoder and decoder. - next->end = &delta_coder_end; - next->coder->next = LZMA_NEXT_CODER_INIT; - } - - // Validate the options. - if (lzma_delta_coder_memusage(filters[0].options) == UINT64_MAX) - return LZMA_OPTIONS_ERROR; - - // Set the delta distance. - const lzma_options_delta *opt = filters[0].options; - next->coder->distance = opt->dist; - - // Initialize the rest of the variables. - next->coder->pos = 0; - memzero(next->coder->history, LZMA_DELTA_DIST_MAX); - - // Initialize the next decoder in the chain, if any. - return lzma_next_filter_init(&next->coder->next, - allocator, filters + 1); -} - - -extern uint64_t -lzma_delta_coder_memusage(const void *options) -{ - const lzma_options_delta *opt = options; - - if (opt == NULL || opt->type != LZMA_DELTA_TYPE_BYTE - || opt->dist < LZMA_DELTA_DIST_MIN - || opt->dist > LZMA_DELTA_DIST_MAX) - return UINT64_MAX; - - return sizeof(lzma_coder); -} diff --git a/deps/lzma/liblzma/delta/delta_common.h b/deps/lzma/liblzma/delta/delta_common.h deleted file mode 100644 index 7e7e1ba..0000000 --- a/deps/lzma/liblzma/delta/delta_common.h +++ /dev/null @@ -1,20 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file delta_common.h -/// \brief Common stuff for Delta encoder and decoder -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_DELTA_COMMON_H -#define LZMA_DELTA_COMMON_H - -#include "common.h" - -extern uint64_t lzma_delta_coder_memusage(const void *options); - -#endif diff --git a/deps/lzma/liblzma/delta/delta_decoder.c b/deps/lzma/liblzma/delta/delta_decoder.c deleted file mode 100644 index 2cf60d5..0000000 --- a/deps/lzma/liblzma/delta/delta_decoder.c +++ /dev/null @@ -1,76 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file delta_decoder.c -/// \brief Delta filter decoder -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "delta_decoder.h" -#include "delta_private.h" - - -static void -decode_buffer(lzma_coder *coder, uint8_t *buffer, size_t size) -{ - const size_t distance = coder->distance; - - for (size_t i = 0; i < size; ++i) { - buffer[i] += coder->history[(distance + coder->pos) & 0xFF]; - coder->history[coder->pos-- & 0xFF] = buffer[i]; - } -} - - -static lzma_ret -delta_decode(lzma_coder *coder, lzma_allocator *allocator, - const uint8_t *restrict in, size_t *restrict in_pos, - size_t in_size, uint8_t *restrict out, - size_t *restrict out_pos, size_t out_size, lzma_action action) -{ - assert(coder->next.code != NULL); - - const size_t out_start = *out_pos; - - const lzma_ret ret = coder->next.code(coder->next.coder, allocator, - in, in_pos, in_size, out, out_pos, out_size, - action); - - decode_buffer(coder, out + out_start, *out_pos - out_start); - - return ret; -} - - -extern lzma_ret -lzma_delta_decoder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters) -{ - next->code = &delta_decode; - return lzma_delta_coder_init(next, allocator, filters); -} - - -extern lzma_ret -lzma_delta_props_decode(void **options, lzma_allocator *allocator, - const uint8_t *props, size_t props_size) -{ - if (props_size != 1) - return LZMA_OPTIONS_ERROR; - - lzma_options_delta *opt - = lzma_alloc(sizeof(lzma_options_delta), allocator); - if (opt == NULL) - return LZMA_MEM_ERROR; - - opt->type = LZMA_DELTA_TYPE_BYTE; - opt->dist = props[0] + 1; - - *options = opt; - - return LZMA_OK; -} diff --git a/deps/lzma/liblzma/delta/delta_decoder.h b/deps/lzma/liblzma/delta/delta_decoder.h deleted file mode 100644 index ae89acc..0000000 --- a/deps/lzma/liblzma/delta/delta_decoder.h +++ /dev/null @@ -1,25 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file delta_decoder.h -/// \brief Delta filter decoder -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_DELTA_DECODER_H -#define LZMA_DELTA_DECODER_H - -#include "delta_common.h" - -extern lzma_ret lzma_delta_decoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters); - -extern lzma_ret lzma_delta_props_decode( - void **options, lzma_allocator *allocator, - const uint8_t *props, size_t props_size); - -#endif diff --git a/deps/lzma/liblzma/delta/delta_encoder.c b/deps/lzma/liblzma/delta/delta_encoder.c deleted file mode 100644 index 15c7951..0000000 --- a/deps/lzma/liblzma/delta/delta_encoder.c +++ /dev/null @@ -1,121 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file delta_encoder.c -/// \brief Delta filter encoder -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "delta_encoder.h" -#include "delta_private.h" - - -/// Copies and encodes the data at the same time. This is used when Delta -/// is the first filter in the chain (and thus the last filter in the -/// encoder's filter stack). -static void -copy_and_encode(lzma_coder *coder, - const uint8_t *restrict in, uint8_t *restrict out, size_t size) -{ - const size_t distance = coder->distance; - - for (size_t i = 0; i < size; ++i) { - const uint8_t tmp = coder->history[ - (distance + coder->pos) & 0xFF]; - coder->history[coder->pos-- & 0xFF] = in[i]; - out[i] = in[i] - tmp; - } -} - - -/// Encodes the data in place. This is used when we are the last filter -/// in the chain (and thus non-last filter in the encoder's filter stack). -static void -encode_in_place(lzma_coder *coder, uint8_t *buffer, size_t size) -{ - const size_t distance = coder->distance; - - for (size_t i = 0; i < size; ++i) { - const uint8_t tmp = coder->history[ - (distance + coder->pos) & 0xFF]; - coder->history[coder->pos-- & 0xFF] = buffer[i]; - buffer[i] -= tmp; - } -} - - -static lzma_ret -delta_encode(lzma_coder *coder, lzma_allocator *allocator, - const uint8_t *restrict in, size_t *restrict in_pos, - size_t in_size, uint8_t *restrict out, - size_t *restrict out_pos, size_t out_size, lzma_action action) -{ - lzma_ret ret; - - if (coder->next.code == NULL) { - const size_t in_avail = in_size - *in_pos; - const size_t out_avail = out_size - *out_pos; - const size_t size = my_min(in_avail, out_avail); - - copy_and_encode(coder, in + *in_pos, out + *out_pos, size); - - *in_pos += size; - *out_pos += size; - - ret = action != LZMA_RUN && *in_pos == in_size - ? LZMA_STREAM_END : LZMA_OK; - - } else { - const size_t out_start = *out_pos; - - ret = coder->next.code(coder->next.coder, allocator, - in, in_pos, in_size, out, out_pos, out_size, - action); - - encode_in_place(coder, out + out_start, *out_pos - out_start); - } - - return ret; -} - - -static lzma_ret -delta_encoder_update(lzma_coder *coder, lzma_allocator *allocator, - const lzma_filter *filters_null lzma_attribute((__unused__)), - const lzma_filter *reversed_filters) -{ - // Delta doesn't and will never support changing the options in - // the middle of encoding. If the app tries to change them, we - // simply ignore them. - return lzma_next_filter_update( - &coder->next, allocator, reversed_filters + 1); -} - - -extern lzma_ret -lzma_delta_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters) -{ - next->code = &delta_encode; - next->update = &delta_encoder_update; - return lzma_delta_coder_init(next, allocator, filters); -} - - -extern lzma_ret -lzma_delta_props_encode(const void *options, uint8_t *out) -{ - // The caller must have already validated the options, so it's - // LZMA_PROG_ERROR if they are invalid. - if (lzma_delta_coder_memusage(options) == UINT64_MAX) - return LZMA_PROG_ERROR; - - const lzma_options_delta *opt = options; - out[0] = opt->dist - LZMA_DELTA_DIST_MIN; - - return LZMA_OK; -} diff --git a/deps/lzma/liblzma/delta/delta_encoder.h b/deps/lzma/liblzma/delta/delta_encoder.h deleted file mode 100644 index a447862..0000000 --- a/deps/lzma/liblzma/delta/delta_encoder.h +++ /dev/null @@ -1,23 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file delta_encoder.h -/// \brief Delta filter encoder -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_DELTA_ENCODER_H -#define LZMA_DELTA_ENCODER_H - -#include "delta_common.h" - -extern lzma_ret lzma_delta_encoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters); - -extern lzma_ret lzma_delta_props_encode(const void *options, uint8_t *out); - -#endif diff --git a/deps/lzma/liblzma/delta/delta_private.h b/deps/lzma/liblzma/delta/delta_private.h deleted file mode 100644 index 62b7fed..0000000 --- a/deps/lzma/liblzma/delta/delta_private.h +++ /dev/null @@ -1,37 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file delta_private.h -/// \brief Private common stuff for Delta encoder and decoder -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_DELTA_PRIVATE_H -#define LZMA_DELTA_PRIVATE_H - -#include "delta_common.h" - -struct lzma_coder_s { - /// Next coder in the chain - lzma_next_coder next; - - /// Delta distance - size_t distance; - - /// Position in history[] - uint8_t pos; - - /// Buffer to hold history of the original data - uint8_t history[LZMA_DELTA_DIST_MAX]; -}; - - -extern lzma_ret lzma_delta_coder_init( - lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters); - -#endif diff --git a/deps/lzma/liblzma/lz/Makefile.inc b/deps/lzma/liblzma/lz/Makefile.inc deleted file mode 100644 index 75742a8..0000000 --- a/deps/lzma/liblzma/lz/Makefile.inc +++ /dev/null @@ -1,22 +0,0 @@ -## -## Author: Lasse Collin -## -## This file has been put into the public domain. -## You can do whatever you want with this file. -## - -if COND_ENCODER_LZ -liblzma_la_SOURCES += \ - lz/lz_encoder.c \ - lz/lz_encoder.h \ - lz/lz_encoder_hash.h \ - lz/lz_encoder_hash_table.h \ - lz/lz_encoder_mf.c -endif - - -if COND_DECODER_LZ -liblzma_la_SOURCES += \ - lz/lz_decoder.c \ - lz/lz_decoder.h -endif diff --git a/deps/lzma/liblzma/lz/lz_decoder.c b/deps/lzma/liblzma/lz/lz_decoder.c deleted file mode 100644 index d74085c..0000000 --- a/deps/lzma/liblzma/lz/lz_decoder.c +++ /dev/null @@ -1,300 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file lz_decoder.c -/// \brief LZ out window -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -// liblzma supports multiple LZ77-based filters. The LZ part is shared -// between these filters. The LZ code takes care of dictionary handling -// and passing the data between filters in the chain. The filter-specific -// part decodes from the input buffer to the dictionary. - - -#include "lz_decoder.h" - - -struct lzma_coder_s { - /// Dictionary (history buffer) - lzma_dict dict; - - /// The actual LZ-based decoder e.g. LZMA - lzma_lz_decoder lz; - - /// Next filter in the chain, if any. Note that LZMA and LZMA2 are - /// only allowed as the last filter, but the long-range filter in - /// future can be in the middle of the chain. - lzma_next_coder next; - - /// True if the next filter in the chain has returned LZMA_STREAM_END. - bool next_finished; - - /// True if the LZ decoder (e.g. LZMA) has detected end of payload - /// marker. This may become true before next_finished becomes true. - bool this_finished; - - /// Temporary buffer needed when the LZ-based filter is not the last - /// filter in the chain. The output of the next filter is first - /// decoded into buffer[], which is then used as input for the actual - /// LZ-based decoder. - struct { - size_t pos; - size_t size; - uint8_t buffer[LZMA_BUFFER_SIZE]; - } temp; -}; - - -static void -lz_decoder_reset(lzma_coder *coder) -{ - coder->dict.pos = 0; - coder->dict.full = 0; - coder->dict.buf[coder->dict.size - 1] = '\0'; - coder->dict.need_reset = false; - return; -} - - -static lzma_ret -decode_buffer(lzma_coder *coder, - const uint8_t *restrict in, size_t *restrict in_pos, - size_t in_size, uint8_t *restrict out, - size_t *restrict out_pos, size_t out_size) -{ - while (true) { - // Wrap the dictionary if needed. - if (coder->dict.pos == coder->dict.size) - coder->dict.pos = 0; - - // Store the current dictionary position. It is needed to know - // where to start copying to the out[] buffer. - const size_t dict_start = coder->dict.pos; - - // Calculate how much we allow coder->lz.code() to decode. - // It must not decode past the end of the dictionary - // buffer, and we don't want it to decode more than is - // actually needed to fill the out[] buffer. - coder->dict.limit = coder->dict.pos - + my_min(out_size - *out_pos, - coder->dict.size - coder->dict.pos); - - // Call the coder->lz.code() to do the actual decoding. - const lzma_ret ret = coder->lz.code( - coder->lz.coder, &coder->dict, - in, in_pos, in_size); - - // Copy the decoded data from the dictionary to the out[] - // buffer. - const size_t copy_size = coder->dict.pos - dict_start; - assert(copy_size <= out_size - *out_pos); - memcpy(out + *out_pos, coder->dict.buf + dict_start, - copy_size); - *out_pos += copy_size; - - // Reset the dictionary if so requested by coder->lz.code(). - if (coder->dict.need_reset) { - lz_decoder_reset(coder); - - // Since we reset dictionary, we don't check if - // dictionary became full. - if (ret != LZMA_OK || *out_pos == out_size) - return ret; - } else { - // Return if everything got decoded or an error - // occurred, or if there's no more data to decode. - // - // Note that detecting if there's something to decode - // is done by looking if dictionary become full - // instead of looking if *in_pos == in_size. This - // is because it is possible that all the input was - // consumed already but some data is pending to be - // written to the dictionary. - if (ret != LZMA_OK || *out_pos == out_size - || coder->dict.pos < coder->dict.size) - return ret; - } - } -} - - -static lzma_ret -lz_decode(lzma_coder *coder, - lzma_allocator *allocator lzma_attribute((__unused__)), - const uint8_t *restrict in, size_t *restrict in_pos, - size_t in_size, uint8_t *restrict out, - size_t *restrict out_pos, size_t out_size, - lzma_action action) -{ - if (coder->next.code == NULL) - return decode_buffer(coder, in, in_pos, in_size, - out, out_pos, out_size); - - // We aren't the last coder in the chain, we need to decode - // our input to a temporary buffer. - while (*out_pos < out_size) { - // Fill the temporary buffer if it is empty. - if (!coder->next_finished - && coder->temp.pos == coder->temp.size) { - coder->temp.pos = 0; - coder->temp.size = 0; - - const lzma_ret ret = coder->next.code( - coder->next.coder, - allocator, in, in_pos, in_size, - coder->temp.buffer, &coder->temp.size, - LZMA_BUFFER_SIZE, action); - - if (ret == LZMA_STREAM_END) - coder->next_finished = true; - else if (ret != LZMA_OK || coder->temp.size == 0) - return ret; - } - - if (coder->this_finished) { - if (coder->temp.size != 0) - return LZMA_DATA_ERROR; - - if (coder->next_finished) - return LZMA_STREAM_END; - - return LZMA_OK; - } - - const lzma_ret ret = decode_buffer(coder, coder->temp.buffer, - &coder->temp.pos, coder->temp.size, - out, out_pos, out_size); - - if (ret == LZMA_STREAM_END) - coder->this_finished = true; - else if (ret != LZMA_OK) - return ret; - else if (coder->next_finished && *out_pos < out_size) - return LZMA_DATA_ERROR; - } - - return LZMA_OK; -} - - -static void -lz_decoder_end(lzma_coder *coder, lzma_allocator *allocator) -{ - lzma_next_end(&coder->next, allocator); - lzma_free(coder->dict.buf, allocator); - - if (coder->lz.end != NULL) - coder->lz.end(coder->lz.coder, allocator); - else - lzma_free(coder->lz.coder, allocator); - - lzma_free(coder, allocator); - return; -} - - -extern lzma_ret -lzma_lz_decoder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters, - lzma_ret (*lz_init)(lzma_lz_decoder *lz, - lzma_allocator *allocator, const void *options, - lzma_lz_options *lz_options)) -{ - // Allocate the base structure if it isn't already allocated. - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) - return LZMA_MEM_ERROR; - - next->code = &lz_decode; - next->end = &lz_decoder_end; - - next->coder->dict.buf = NULL; - next->coder->dict.size = 0; - next->coder->lz = LZMA_LZ_DECODER_INIT; - next->coder->next = LZMA_NEXT_CODER_INIT; - } - - // Allocate and initialize the LZ-based decoder. It will also give - // us the dictionary size. - lzma_lz_options lz_options; - return_if_error(lz_init(&next->coder->lz, allocator, - filters[0].options, &lz_options)); - - // If the dictionary size is very small, increase it to 4096 bytes. - // This is to prevent constant wrapping of the dictionary, which - // would slow things down. The downside is that since we don't check - // separately for the real dictionary size, we may happily accept - // corrupt files. - if (lz_options.dict_size < 4096) - lz_options.dict_size = 4096; - - // Make dictionary size a multipe of 16. Some LZ-based decoders like - // LZMA use the lowest bits lzma_dict.pos to know the alignment of the - // data. Aligned buffer is also good when memcpying from the - // dictionary to the output buffer, since applications are - // recommended to give aligned buffers to liblzma. - // - // Avoid integer overflow. - if (lz_options.dict_size > SIZE_MAX - 15) - return LZMA_MEM_ERROR; - - lz_options.dict_size = (lz_options.dict_size + 15) & ~((size_t)(15)); - - // Allocate and initialize the dictionary. - if (next->coder->dict.size != lz_options.dict_size) { - lzma_free(next->coder->dict.buf, allocator); - next->coder->dict.buf - = lzma_alloc(lz_options.dict_size, allocator); - if (next->coder->dict.buf == NULL) - return LZMA_MEM_ERROR; - - next->coder->dict.size = lz_options.dict_size; - } - - lz_decoder_reset(next->coder); - - // Use the preset dictionary if it was given to us. - if (lz_options.preset_dict != NULL - && lz_options.preset_dict_size > 0) { - // If the preset dictionary is bigger than the actual - // dictionary, copy only the tail. - const size_t copy_size = my_min(lz_options.preset_dict_size, - lz_options.dict_size); - const size_t offset = lz_options.preset_dict_size - copy_size; - memcpy(next->coder->dict.buf, lz_options.preset_dict + offset, - copy_size); - next->coder->dict.pos = copy_size; - next->coder->dict.full = copy_size; - } - - // Miscellaneous initializations - next->coder->next_finished = false; - next->coder->this_finished = false; - next->coder->temp.pos = 0; - next->coder->temp.size = 0; - - // Initialize the next filter in the chain, if any. - return lzma_next_filter_init(&next->coder->next, allocator, - filters + 1); -} - - -extern uint64_t -lzma_lz_decoder_memusage(size_t dictionary_size) -{ - return sizeof(lzma_coder) + (uint64_t)(dictionary_size); -} - - -extern void -lzma_lz_decoder_uncompressed(lzma_coder *coder, lzma_vli uncompressed_size) -{ - coder->lz.set_uncompressed(coder->lz.coder, uncompressed_size); -} diff --git a/deps/lzma/liblzma/lz/lz_decoder.h b/deps/lzma/liblzma/lz/lz_decoder.h deleted file mode 100644 index 7266e80..0000000 --- a/deps/lzma/liblzma/lz/lz_decoder.h +++ /dev/null @@ -1,234 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file lz_decoder.h -/// \brief LZ out window -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_LZ_DECODER_H -#define LZMA_LZ_DECODER_H - -#include "common.h" - - -typedef struct { - /// Pointer to the dictionary buffer. It can be an allocated buffer - /// internal to liblzma, or it can a be a buffer given by the - /// application when in single-call mode (not implemented yet). - uint8_t *buf; - - /// Write position in dictionary. The next byte will be written to - /// buf[pos]. - size_t pos; - - /// Indicates how full the dictionary is. This is used by - /// dict_is_distance_valid() to detect corrupt files that would - /// read beyond the beginning of the dictionary. - size_t full; - - /// Write limit - size_t limit; - - /// Size of the dictionary - size_t size; - - /// True when dictionary should be reset before decoding more data. - bool need_reset; - -} lzma_dict; - - -typedef struct { - size_t dict_size; - const uint8_t *preset_dict; - size_t preset_dict_size; -} lzma_lz_options; - - -typedef struct { - /// Data specific to the LZ-based decoder - lzma_coder *coder; - - /// Function to decode from in[] to *dict - lzma_ret (*code)(lzma_coder *restrict coder, - lzma_dict *restrict dict, const uint8_t *restrict in, - size_t *restrict in_pos, size_t in_size); - - void (*reset)(lzma_coder *coder, const void *options); - - /// Set the uncompressed size - void (*set_uncompressed)(lzma_coder *coder, - lzma_vli uncompressed_size); - - /// Free allocated resources - void (*end)(lzma_coder *coder, lzma_allocator *allocator); - -} lzma_lz_decoder; - - -#define LZMA_LZ_DECODER_INIT \ - (lzma_lz_decoder){ \ - .coder = NULL, \ - .code = NULL, \ - .reset = NULL, \ - .set_uncompressed = NULL, \ - .end = NULL, \ - } - - -extern lzma_ret lzma_lz_decoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters, - lzma_ret (*lz_init)(lzma_lz_decoder *lz, - lzma_allocator *allocator, const void *options, - lzma_lz_options *lz_options)); - -extern uint64_t lzma_lz_decoder_memusage(size_t dictionary_size); - -extern void lzma_lz_decoder_uncompressed( - lzma_coder *coder, lzma_vli uncompressed_size); - - -////////////////////// -// Inline functions // -////////////////////// - -/// Get a byte from the history buffer. -static inline uint8_t -dict_get(const lzma_dict *const dict, const uint32_t distance) -{ - return dict->buf[dict->pos - distance - 1 - + (distance < dict->pos ? 0 : dict->size)]; -} - - -/// Test if dictionary is empty. -static inline bool -dict_is_empty(const lzma_dict *const dict) -{ - return dict->full == 0; -} - - -/// Validate the match distance -static inline bool -dict_is_distance_valid(const lzma_dict *const dict, const size_t distance) -{ - return dict->full > distance; -} - - -/// Repeat *len bytes at distance. -static inline bool -dict_repeat(lzma_dict *dict, uint32_t distance, uint32_t *len) -{ - // Don't write past the end of the dictionary. - const size_t dict_avail = dict->limit - dict->pos; - uint32_t left = my_min(dict_avail, *len); - *len -= left; - - // Repeat a block of data from the history. Because memcpy() is faster - // than copying byte by byte in a loop, the copying process gets split - // into three cases. - if (distance < left) { - // Source and target areas overlap, thus we can't use - // memcpy() nor even memmove() safely. - do { - dict->buf[dict->pos] = dict_get(dict, distance); - ++dict->pos; - } while (--left > 0); - - } else if (distance < dict->pos) { - // The easiest and fastest case - memcpy(dict->buf + dict->pos, - dict->buf + dict->pos - distance - 1, - left); - dict->pos += left; - - } else { - // The bigger the dictionary, the more rare this - // case occurs. We need to "wrap" the dict, thus - // we might need two memcpy() to copy all the data. - assert(dict->full == dict->size); - const uint32_t copy_pos - = dict->pos - distance - 1 + dict->size; - uint32_t copy_size = dict->size - copy_pos; - - if (copy_size < left) { - memmove(dict->buf + dict->pos, dict->buf + copy_pos, - copy_size); - dict->pos += copy_size; - copy_size = left - copy_size; - memcpy(dict->buf + dict->pos, dict->buf, copy_size); - dict->pos += copy_size; - } else { - memmove(dict->buf + dict->pos, dict->buf + copy_pos, - left); - dict->pos += left; - } - } - - // Update how full the dictionary is. - if (dict->full < dict->pos) - dict->full = dict->pos; - - return unlikely(*len != 0); -} - - -/// Puts one byte into the dictionary. Returns true if the dictionary was -/// already full and the byte couldn't be added. -static inline bool -dict_put(lzma_dict *dict, uint8_t byte) -{ - if (unlikely(dict->pos == dict->limit)) - return true; - - dict->buf[dict->pos++] = byte; - - if (dict->pos > dict->full) - dict->full = dict->pos; - - return false; -} - - -/// Copies arbitrary amount of data into the dictionary. -static inline void -dict_write(lzma_dict *restrict dict, const uint8_t *restrict in, - size_t *restrict in_pos, size_t in_size, - size_t *restrict left) -{ - // NOTE: If we are being given more data than the size of the - // dictionary, it could be possible to optimize the LZ decoder - // so that not everything needs to go through the dictionary. - // This shouldn't be very common thing in practice though, and - // the slowdown of one extra memcpy() isn't bad compared to how - // much time it would have taken if the data were compressed. - - if (in_size - *in_pos > *left) - in_size = *in_pos + *left; - - *left -= lzma_bufcpy(in, in_pos, in_size, - dict->buf, &dict->pos, dict->limit); - - if (dict->pos > dict->full) - dict->full = dict->pos; - - return; -} - - -static inline void -dict_reset(lzma_dict *dict) -{ - dict->need_reset = true; - return; -} - -#endif diff --git a/deps/lzma/liblzma/lz/lz_encoder.c b/deps/lzma/liblzma/lz/lz_encoder.c deleted file mode 100644 index e240696..0000000 --- a/deps/lzma/liblzma/lz/lz_encoder.c +++ /dev/null @@ -1,583 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file lz_encoder.c -/// \brief LZ in window -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "lz_encoder.h" -#include "lz_encoder_hash.h" - -// See lz_encoder_hash.h. This is a bit hackish but avoids making -// endianness a conditional in makefiles. -#if defined(WORDS_BIGENDIAN) && !defined(HAVE_SMALL) -# include "lz_encoder_hash_table.h" -#endif - - -struct lzma_coder_s { - /// LZ-based encoder e.g. LZMA - lzma_lz_encoder lz; - - /// History buffer and match finder - lzma_mf mf; - - /// Next coder in the chain - lzma_next_coder next; -}; - - -/// \brief Moves the data in the input window to free space for new data -/// -/// mf->buffer is a sliding input window, which keeps mf->keep_size_before -/// bytes of input history available all the time. Now and then we need to -/// "slide" the buffer to make space for the new data to the end of the -/// buffer. At the same time, data older than keep_size_before is dropped. -/// -static void -move_window(lzma_mf *mf) -{ - // Align the move to a multiple of 16 bytes. Some LZ-based encoders - // like LZMA use the lowest bits of mf->read_pos to know the - // alignment of the uncompressed data. We also get better speed - // for memmove() with aligned buffers. - assert(mf->read_pos > mf->keep_size_before); - const uint32_t move_offset - = (mf->read_pos - mf->keep_size_before) & ~UINT32_C(15); - - assert(mf->write_pos > move_offset); - const size_t move_size = mf->write_pos - move_offset; - - assert(move_offset + move_size <= mf->size); - - memmove(mf->buffer, mf->buffer + move_offset, move_size); - - mf->offset += move_offset; - mf->read_pos -= move_offset; - mf->read_limit -= move_offset; - mf->write_pos -= move_offset; - - return; -} - - -/// \brief Tries to fill the input window (mf->buffer) -/// -/// If we are the last encoder in the chain, our input data is in in[]. -/// Otherwise we call the next filter in the chain to process in[] and -/// write its output to mf->buffer. -/// -/// This function must not be called once it has returned LZMA_STREAM_END. -/// -static lzma_ret -fill_window(lzma_coder *coder, lzma_allocator *allocator, const uint8_t *in, - size_t *in_pos, size_t in_size, lzma_action action) -{ - assert(coder->mf.read_pos <= coder->mf.write_pos); - - // Move the sliding window if needed. - if (coder->mf.read_pos >= coder->mf.size - coder->mf.keep_size_after) - move_window(&coder->mf); - - // Maybe this is ugly, but lzma_mf uses uint32_t for most things - // (which I find cleanest), but we need size_t here when filling - // the history window. - size_t write_pos = coder->mf.write_pos; - lzma_ret ret; - if (coder->next.code == NULL) { - // Not using a filter, simply memcpy() as much as possible. - lzma_bufcpy(in, in_pos, in_size, coder->mf.buffer, - &write_pos, coder->mf.size); - - ret = action != LZMA_RUN && *in_pos == in_size - ? LZMA_STREAM_END : LZMA_OK; - - } else { - ret = coder->next.code(coder->next.coder, allocator, - in, in_pos, in_size, - coder->mf.buffer, &write_pos, - coder->mf.size, action); - } - - coder->mf.write_pos = write_pos; - - // If end of stream has been reached or flushing completed, we allow - // the encoder to process all the input (that is, read_pos is allowed - // to reach write_pos). Otherwise we keep keep_size_after bytes - // available as prebuffer. - if (ret == LZMA_STREAM_END) { - assert(*in_pos == in_size); - ret = LZMA_OK; - coder->mf.action = action; - coder->mf.read_limit = coder->mf.write_pos; - - } else if (coder->mf.write_pos > coder->mf.keep_size_after) { - // This needs to be done conditionally, because if we got - // only little new input, there may be too little input - // to do any encoding yet. - coder->mf.read_limit = coder->mf.write_pos - - coder->mf.keep_size_after; - } - - // Restart the match finder after finished LZMA_SYNC_FLUSH. - if (coder->mf.pending > 0 - && coder->mf.read_pos < coder->mf.read_limit) { - // Match finder may update coder->pending and expects it to - // start from zero, so use a temporary variable. - const size_t pending = coder->mf.pending; - coder->mf.pending = 0; - - // Rewind read_pos so that the match finder can hash - // the pending bytes. - assert(coder->mf.read_pos >= pending); - coder->mf.read_pos -= pending; - - // Call the skip function directly instead of using - // mf_skip(), since we don't want to touch mf->read_ahead. - coder->mf.skip(&coder->mf, pending); - } - - return ret; -} - - -static lzma_ret -lz_encode(lzma_coder *coder, lzma_allocator *allocator, - const uint8_t *restrict in, size_t *restrict in_pos, - size_t in_size, - uint8_t *restrict out, size_t *restrict out_pos, - size_t out_size, lzma_action action) -{ - while (*out_pos < out_size - && (*in_pos < in_size || action != LZMA_RUN)) { - // Read more data to coder->mf.buffer if needed. - if (coder->mf.action == LZMA_RUN && coder->mf.read_pos - >= coder->mf.read_limit) - return_if_error(fill_window(coder, allocator, - in, in_pos, in_size, action)); - - // Encode - const lzma_ret ret = coder->lz.code(coder->lz.coder, - &coder->mf, out, out_pos, out_size); - if (ret != LZMA_OK) { - // Setting this to LZMA_RUN for cases when we are - // flushing. It doesn't matter when finishing or if - // an error occurred. - coder->mf.action = LZMA_RUN; - return ret; - } - } - - return LZMA_OK; -} - - -static bool -lz_encoder_prepare(lzma_mf *mf, lzma_allocator *allocator, - const lzma_lz_options *lz_options) -{ - // For now, the dictionary size is limited to 1.5 GiB. This may grow - // in the future if needed, but it needs a little more work than just - // changing this check. - if (lz_options->dict_size < LZMA_DICT_SIZE_MIN - || lz_options->dict_size - > (UINT32_C(1) << 30) + (UINT32_C(1) << 29) - || lz_options->nice_len > lz_options->match_len_max) - return true; - - mf->keep_size_before = lz_options->before_size + lz_options->dict_size; - - mf->keep_size_after = lz_options->after_size - + lz_options->match_len_max; - - // To avoid constant memmove()s, allocate some extra space. Since - // memmove()s become more expensive when the size of the buffer - // increases, we reserve more space when a large dictionary is - // used to make the memmove() calls rarer. - // - // This works with dictionaries up to about 3 GiB. If bigger - // dictionary is wanted, some extra work is needed: - // - Several variables in lzma_mf have to be changed from uint32_t - // to size_t. - // - Memory usage calculation needs something too, e.g. use uint64_t - // for mf->size. - uint32_t reserve = lz_options->dict_size / 2; - if (reserve > (UINT32_C(1) << 30)) - reserve /= 2; - - reserve += (lz_options->before_size + lz_options->match_len_max - + lz_options->after_size) / 2 + (UINT32_C(1) << 19); - - const uint32_t old_size = mf->size; - mf->size = mf->keep_size_before + reserve + mf->keep_size_after; - - // Deallocate the old history buffer if it exists but has different - // size than what is needed now. - if (mf->buffer != NULL && old_size != mf->size) { - lzma_free(mf->buffer, allocator); - mf->buffer = NULL; - } - - // Match finder options - mf->match_len_max = lz_options->match_len_max; - mf->nice_len = lz_options->nice_len; - - // cyclic_size has to stay smaller than 2 Gi. Note that this doesn't - // mean limiting dictionary size to less than 2 GiB. With a match - // finder that uses multibyte resolution (hashes start at e.g. every - // fourth byte), cyclic_size would stay below 2 Gi even when - // dictionary size is greater than 2 GiB. - // - // It would be possible to allow cyclic_size >= 2 Gi, but then we - // would need to be careful to use 64-bit types in various places - // (size_t could do since we would need bigger than 32-bit address - // space anyway). It would also require either zeroing a multigigabyte - // buffer at initialization (waste of time and RAM) or allow - // normalization in lz_encoder_mf.c to access uninitialized - // memory to keep the code simpler. The current way is simple and - // still allows pretty big dictionaries, so I don't expect these - // limits to change. - mf->cyclic_size = lz_options->dict_size + 1; - - // Validate the match finder ID and setup the function pointers. - switch (lz_options->match_finder) { -#ifdef HAVE_MF_HC3 - case LZMA_MF_HC3: - mf->find = &lzma_mf_hc3_find; - mf->skip = &lzma_mf_hc3_skip; - break; -#endif -#ifdef HAVE_MF_HC4 - case LZMA_MF_HC4: - mf->find = &lzma_mf_hc4_find; - mf->skip = &lzma_mf_hc4_skip; - break; -#endif -#ifdef HAVE_MF_BT2 - case LZMA_MF_BT2: - mf->find = &lzma_mf_bt2_find; - mf->skip = &lzma_mf_bt2_skip; - break; -#endif -#ifdef HAVE_MF_BT3 - case LZMA_MF_BT3: - mf->find = &lzma_mf_bt3_find; - mf->skip = &lzma_mf_bt3_skip; - break; -#endif -#ifdef HAVE_MF_BT4 - case LZMA_MF_BT4: - mf->find = &lzma_mf_bt4_find; - mf->skip = &lzma_mf_bt4_skip; - break; -#endif - - default: - return true; - } - - // Calculate the sizes of mf->hash and mf->son and check that - // nice_len is big enough for the selected match finder. - const uint32_t hash_bytes = lz_options->match_finder & 0x0F; - if (hash_bytes > mf->nice_len) - return true; - - const bool is_bt = (lz_options->match_finder & 0x10) != 0; - uint32_t hs; - - if (hash_bytes == 2) { - hs = 0xFFFF; - } else { - // Round dictionary size up to the next 2^n - 1 so it can - // be used as a hash mask. - hs = lz_options->dict_size - 1; - hs |= hs >> 1; - hs |= hs >> 2; - hs |= hs >> 4; - hs |= hs >> 8; - hs >>= 1; - hs |= 0xFFFF; - - if (hs > (UINT32_C(1) << 24)) { - if (hash_bytes == 3) - hs = (UINT32_C(1) << 24) - 1; - else - hs >>= 1; - } - } - - mf->hash_mask = hs; - - ++hs; - if (hash_bytes > 2) - hs += HASH_2_SIZE; - if (hash_bytes > 3) - hs += HASH_3_SIZE; -/* - No match finder uses this at the moment. - if (mf->hash_bytes > 4) - hs += HASH_4_SIZE; -*/ - - // If the above code calculating hs is modified, make sure that - // this assertion stays valid (UINT32_MAX / 5 is not strictly the - // exact limit). If it doesn't, you need to calculate that - // hash_size_sum + sons_count cannot overflow. - assert(hs < UINT32_MAX / 5); - - const uint32_t old_count = mf->hash_size_sum + mf->sons_count; - mf->hash_size_sum = hs; - mf->sons_count = mf->cyclic_size; - if (is_bt) - mf->sons_count *= 2; - - const uint32_t new_count = mf->hash_size_sum + mf->sons_count; - - // Deallocate the old hash array if it exists and has different size - // than what is needed now. - if (old_count != new_count) { - lzma_free(mf->hash, allocator); - mf->hash = NULL; - } - - // Maximum number of match finder cycles - mf->depth = lz_options->depth; - if (mf->depth == 0) { - if (is_bt) - mf->depth = 16 + mf->nice_len / 2; - else - mf->depth = 4 + mf->nice_len / 4; - } - - return false; -} - - -static bool -lz_encoder_init(lzma_mf *mf, lzma_allocator *allocator, - const lzma_lz_options *lz_options) -{ - // Allocate the history buffer. - if (mf->buffer == NULL) { - mf->buffer = lzma_alloc(mf->size, allocator); - if (mf->buffer == NULL) - return true; - } - - // Use cyclic_size as initial mf->offset. This allows - // avoiding a few branches in the match finders. The downside is - // that match finder needs to be normalized more often, which may - // hurt performance with huge dictionaries. - mf->offset = mf->cyclic_size; - mf->read_pos = 0; - mf->read_ahead = 0; - mf->read_limit = 0; - mf->write_pos = 0; - mf->pending = 0; - - // Allocate match finder's hash array. - const size_t alloc_count = mf->hash_size_sum + mf->sons_count; - -#if UINT32_MAX >= SIZE_MAX / 4 - // Check for integer overflow. (Huge dictionaries are not - // possible on 32-bit CPU.) - if (alloc_count > SIZE_MAX / sizeof(uint32_t)) - return true; -#endif - - if (mf->hash == NULL) { - mf->hash = lzma_alloc(alloc_count * sizeof(uint32_t), - allocator); - if (mf->hash == NULL) - return true; - } - - mf->son = mf->hash + mf->hash_size_sum; - mf->cyclic_pos = 0; - - // Initialize the hash table. Since EMPTY_HASH_VALUE is zero, we - // can use memset(). -/* - for (uint32_t i = 0; i < hash_size_sum; ++i) - mf->hash[i] = EMPTY_HASH_VALUE; -*/ - memzero(mf->hash, (size_t)(mf->hash_size_sum) * sizeof(uint32_t)); - - // We don't need to initialize mf->son, but not doing that will - // make Valgrind complain in normalization (see normalize() in - // lz_encoder_mf.c). - // - // Skipping this initialization is *very* good when big dictionary is - // used but only small amount of data gets actually compressed: most - // of the mf->hash won't get actually allocated by the kernel, so - // we avoid wasting RAM and improve initialization speed a lot. - //memzero(mf->son, (size_t)(mf->sons_count) * sizeof(uint32_t)); - - // Handle preset dictionary. - if (lz_options->preset_dict != NULL - && lz_options->preset_dict_size > 0) { - // If the preset dictionary is bigger than the actual - // dictionary, use only the tail. - mf->write_pos = my_min(lz_options->preset_dict_size, mf->size); - memcpy(mf->buffer, lz_options->preset_dict - + lz_options->preset_dict_size - mf->write_pos, - mf->write_pos); - mf->action = LZMA_SYNC_FLUSH; - mf->skip(mf, mf->write_pos); - } - - mf->action = LZMA_RUN; - - return false; -} - - -extern uint64_t -lzma_lz_encoder_memusage(const lzma_lz_options *lz_options) -{ - // Old buffers must not exist when calling lz_encoder_prepare(). - lzma_mf mf = { - .buffer = NULL, - .hash = NULL, - .hash_size_sum = 0, - .sons_count = 0, - }; - - // Setup the size information into mf. - if (lz_encoder_prepare(&mf, NULL, lz_options)) - return UINT64_MAX; - - // Calculate the memory usage. - return (uint64_t)(mf.hash_size_sum + mf.sons_count) - * sizeof(uint32_t) - + (uint64_t)(mf.size) + sizeof(lzma_coder); -} - - -static void -lz_encoder_end(lzma_coder *coder, lzma_allocator *allocator) -{ - lzma_next_end(&coder->next, allocator); - - lzma_free(coder->mf.hash, allocator); - lzma_free(coder->mf.buffer, allocator); - - if (coder->lz.end != NULL) - coder->lz.end(coder->lz.coder, allocator); - else - lzma_free(coder->lz.coder, allocator); - - lzma_free(coder, allocator); - return; -} - - -static lzma_ret -lz_encoder_update(lzma_coder *coder, lzma_allocator *allocator, - const lzma_filter *filters_null lzma_attribute((__unused__)), - const lzma_filter *reversed_filters) -{ - if (coder->lz.options_update == NULL) - return LZMA_PROG_ERROR; - - return_if_error(coder->lz.options_update( - coder->lz.coder, reversed_filters)); - - return lzma_next_filter_update( - &coder->next, allocator, reversed_filters + 1); -} - - -extern lzma_ret -lzma_lz_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters, - lzma_ret (*lz_init)(lzma_lz_encoder *lz, - lzma_allocator *allocator, const void *options, - lzma_lz_options *lz_options)) -{ -#ifdef HAVE_SMALL - // We need that the CRC32 table has been initialized. - lzma_crc32_init(); -#endif - - // Allocate and initialize the base data structure. - if (next->coder == NULL) { - next->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (next->coder == NULL) - return LZMA_MEM_ERROR; - - next->code = &lz_encode; - next->end = &lz_encoder_end; - next->update = &lz_encoder_update; - - next->coder->lz.coder = NULL; - next->coder->lz.code = NULL; - next->coder->lz.end = NULL; - - next->coder->mf.buffer = NULL; - next->coder->mf.hash = NULL; - next->coder->mf.hash_size_sum = 0; - next->coder->mf.sons_count = 0; - - next->coder->next = LZMA_NEXT_CODER_INIT; - } - - // Initialize the LZ-based encoder. - lzma_lz_options lz_options; - return_if_error(lz_init(&next->coder->lz, allocator, - filters[0].options, &lz_options)); - - // Setup the size information into next->coder->mf and deallocate - // old buffers if they have wrong size. - if (lz_encoder_prepare(&next->coder->mf, allocator, &lz_options)) - return LZMA_OPTIONS_ERROR; - - // Allocate new buffers if needed, and do the rest of - // the initialization. - if (lz_encoder_init(&next->coder->mf, allocator, &lz_options)) - return LZMA_MEM_ERROR; - - // Initialize the next filter in the chain, if any. - return lzma_next_filter_init(&next->coder->next, allocator, - filters + 1); -} - - -extern LZMA_API(lzma_bool) -lzma_mf_is_supported(lzma_match_finder mf) -{ - bool ret = false; - -#ifdef HAVE_MF_HC3 - if (mf == LZMA_MF_HC3) - ret = true; -#endif - -#ifdef HAVE_MF_HC4 - if (mf == LZMA_MF_HC4) - ret = true; -#endif - -#ifdef HAVE_MF_BT2 - if (mf == LZMA_MF_BT2) - ret = true; -#endif - -#ifdef HAVE_MF_BT3 - if (mf == LZMA_MF_BT3) - ret = true; -#endif - -#ifdef HAVE_MF_BT4 - if (mf == LZMA_MF_BT4) - ret = true; -#endif - - return ret; -} diff --git a/deps/lzma/liblzma/lz/lz_encoder.h b/deps/lzma/liblzma/lz/lz_encoder.h deleted file mode 100644 index 741c453..0000000 --- a/deps/lzma/liblzma/lz/lz_encoder.h +++ /dev/null @@ -1,328 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file lz_encoder.h -/// \brief LZ in window and match finder API -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_LZ_ENCODER_H -#define LZMA_LZ_ENCODER_H - -#include "common.h" - - -/// A table of these is used by the LZ-based encoder to hold -/// the length-distance pairs found by the match finder. -typedef struct { - uint32_t len; - uint32_t dist; -} lzma_match; - - -typedef struct lzma_mf_s lzma_mf; -struct lzma_mf_s { - /////////////// - // In Window // - /////////////// - - /// Pointer to buffer with data to be compressed - uint8_t *buffer; - - /// Total size of the allocated buffer (that is, including all - /// the extra space) - uint32_t size; - - /// Number of bytes that must be kept available in our input history. - /// That is, once keep_size_before bytes have been processed, - /// buffer[read_pos - keep_size_before] is the oldest byte that - /// must be available for reading. - uint32_t keep_size_before; - - /// Number of bytes that must be kept in buffer after read_pos. - /// That is, read_pos <= write_pos - keep_size_after as long as - /// action is LZMA_RUN; when action != LZMA_RUN, read_pos is allowed - /// to reach write_pos so that the last bytes get encoded too. - uint32_t keep_size_after; - - /// Match finders store locations of matches using 32-bit integers. - /// To avoid adjusting several megabytes of integers every time the - /// input window is moved with move_window, we only adjust the - /// offset of the buffer. Thus, buffer[value_in_hash_table - offset] - /// is the byte pointed by value_in_hash_table. - uint32_t offset; - - /// buffer[read_pos] is the next byte to run through the match - /// finder. This is incremented in the match finder once the byte - /// has been processed. - uint32_t read_pos; - - /// Number of bytes that have been ran through the match finder, but - /// which haven't been encoded by the LZ-based encoder yet. - uint32_t read_ahead; - - /// As long as read_pos is less than read_limit, there is enough - /// input available in buffer for at least one encoding loop. - /// - /// Because of the stateful API, read_limit may and will get greater - /// than read_pos quite often. This is taken into account when - /// calculating the value for keep_size_after. - uint32_t read_limit; - - /// buffer[write_pos] is the first byte that doesn't contain valid - /// uncompressed data; that is, the next input byte will be copied - /// to buffer[write_pos]. - uint32_t write_pos; - - /// Number of bytes not hashed before read_pos. This is needed to - /// restart the match finder after LZMA_SYNC_FLUSH. - uint32_t pending; - - ////////////////// - // Match Finder // - ////////////////// - - /// Find matches. Returns the number of distance-length pairs written - /// to the matches array. This is called only via lzma_mf_find(). - uint32_t (*find)(lzma_mf *mf, lzma_match *matches); - - /// Skips num bytes. This is like find() but doesn't make the - /// distance-length pairs available, thus being a little faster. - /// This is called only via mf_skip(). - void (*skip)(lzma_mf *mf, uint32_t num); - - uint32_t *hash; - uint32_t *son; - uint32_t cyclic_pos; - uint32_t cyclic_size; // Must be dictionary size + 1. - uint32_t hash_mask; - - /// Maximum number of loops in the match finder - uint32_t depth; - - /// Maximum length of a match that the match finder will try to find. - uint32_t nice_len; - - /// Maximum length of a match supported by the LZ-based encoder. - /// If the longest match found by the match finder is nice_len, - /// mf_find() tries to expand it up to match_len_max bytes. - uint32_t match_len_max; - - /// When running out of input, binary tree match finders need to know - /// if it is due to flushing or finishing. The action is used also - /// by the LZ-based encoders themselves. - lzma_action action; - - /// Number of elements in hash[] - uint32_t hash_size_sum; - - /// Number of elements in son[] - uint32_t sons_count; -}; - - -typedef struct { - /// Extra amount of data to keep available before the "actual" - /// dictionary. - size_t before_size; - - /// Size of the history buffer - size_t dict_size; - - /// Extra amount of data to keep available after the "actual" - /// dictionary. - size_t after_size; - - /// Maximum length of a match that the LZ-based encoder can accept. - /// This is used to extend matches of length nice_len to the - /// maximum possible length. - size_t match_len_max; - - /// Match finder will search matches up to this length. - /// This must be less than or equal to match_len_max. - size_t nice_len; - - /// Type of the match finder to use - lzma_match_finder match_finder; - - /// Maximum search depth - uint32_t depth; - - /// TODO: Comment - const uint8_t *preset_dict; - - uint32_t preset_dict_size; - -} lzma_lz_options; - - -// The total usable buffer space at any moment outside the match finder: -// before_size + dict_size + after_size + match_len_max -// -// In reality, there's some extra space allocated to prevent the number of -// memmove() calls reasonable. The bigger the dict_size is, the bigger -// this extra buffer will be since with bigger dictionaries memmove() would -// also take longer. -// -// A single encoder loop in the LZ-based encoder may call the match finder -// (mf_find() or mf_skip()) at most after_size times. In other words, -// a single encoder loop may increment lzma_mf.read_pos at most after_size -// times. Since matches are looked up to -// lzma_mf.buffer[lzma_mf.read_pos + match_len_max - 1], the total -// amount of extra buffer needed after dict_size becomes -// after_size + match_len_max. -// -// before_size has two uses. The first one is to keep literals available -// in cases when the LZ-based encoder has made some read ahead. -// TODO: Maybe this could be changed by making the LZ-based encoders to -// store the actual literals as they do with length-distance pairs. -// -// Algorithms such as LZMA2 first try to compress a chunk, and then check -// if the encoded result is smaller than the uncompressed one. If the chunk -// was uncompressible, it is better to store it in uncompressed form in -// the output stream. To do this, the whole uncompressed chunk has to be -// still available in the history buffer. before_size achieves that. - - -typedef struct { - /// Data specific to the LZ-based encoder - lzma_coder *coder; - - /// Function to encode from *dict to out[] - lzma_ret (*code)(lzma_coder *restrict coder, - lzma_mf *restrict mf, uint8_t *restrict out, - size_t *restrict out_pos, size_t out_size); - - /// Free allocated resources - void (*end)(lzma_coder *coder, lzma_allocator *allocator); - - /// Update the options in the middle of the encoding. - lzma_ret (*options_update)(lzma_coder *coder, - const lzma_filter *filter); - -} lzma_lz_encoder; - - -// Basic steps: -// 1. Input gets copied into the dictionary. -// 2. Data in dictionary gets run through the match finder byte by byte. -// 3. The literals and matches are encoded using e.g. LZMA. -// -// The bytes that have been ran through the match finder, but not encoded yet, -// are called `read ahead'. - - -/// Get pointer to the first byte not ran through the match finder -static inline const uint8_t * -mf_ptr(const lzma_mf *mf) -{ - return mf->buffer + mf->read_pos; -} - - -/// Get the number of bytes that haven't been ran through the match finder yet. -static inline uint32_t -mf_avail(const lzma_mf *mf) -{ - return mf->write_pos - mf->read_pos; -} - - -/// Get the number of bytes that haven't been encoded yet (some of these -/// bytes may have been ran through the match finder though). -static inline uint32_t -mf_unencoded(const lzma_mf *mf) -{ - return mf->write_pos - mf->read_pos + mf->read_ahead; -} - - -/// Calculate the absolute offset from the beginning of the most recent -/// dictionary reset. Only the lowest four bits are important, so there's no -/// problem that we don't know the 64-bit size of the data encoded so far. -/// -/// NOTE: When moving the input window, we need to do it so that the lowest -/// bits of dict->read_pos are not modified to keep this macro working -/// as intended. -static inline uint32_t -mf_position(const lzma_mf *mf) -{ - return mf->read_pos - mf->read_ahead; -} - - -/// Since everything else begins with mf_, use it also for lzma_mf_find(). -#define mf_find lzma_mf_find - - -/// Skip the given number of bytes. This is used when a good match was found. -/// For example, if mf_find() finds a match of 200 bytes long, the first byte -/// of that match was already consumed by mf_find(), and the rest 199 bytes -/// have to be skipped with mf_skip(mf, 199). -static inline void -mf_skip(lzma_mf *mf, uint32_t amount) -{ - if (amount != 0) { - mf->skip(mf, amount); - mf->read_ahead += amount; - } -} - - -/// Copies at most *left number of bytes from the history buffer -/// to out[]. This is needed by LZMA2 to encode uncompressed chunks. -static inline void -mf_read(lzma_mf *mf, uint8_t *out, size_t *out_pos, size_t out_size, - size_t *left) -{ - const size_t out_avail = out_size - *out_pos; - const size_t copy_size = my_min(out_avail, *left); - - assert(mf->read_ahead == 0); - assert(mf->read_pos >= *left); - - memcpy(out + *out_pos, mf->buffer + mf->read_pos - *left, - copy_size); - - *out_pos += copy_size; - *left -= copy_size; - return; -} - - -extern lzma_ret lzma_lz_encoder_init( - lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters, - lzma_ret (*lz_init)(lzma_lz_encoder *lz, - lzma_allocator *allocator, const void *options, - lzma_lz_options *lz_options)); - - -extern uint64_t lzma_lz_encoder_memusage(const lzma_lz_options *lz_options); - - -// These are only for LZ encoder's internal use. -extern uint32_t lzma_mf_find( - lzma_mf *mf, uint32_t *count, lzma_match *matches); - -extern uint32_t lzma_mf_hc3_find(lzma_mf *dict, lzma_match *matches); -extern void lzma_mf_hc3_skip(lzma_mf *dict, uint32_t amount); - -extern uint32_t lzma_mf_hc4_find(lzma_mf *dict, lzma_match *matches); -extern void lzma_mf_hc4_skip(lzma_mf *dict, uint32_t amount); - -extern uint32_t lzma_mf_bt2_find(lzma_mf *dict, lzma_match *matches); -extern void lzma_mf_bt2_skip(lzma_mf *dict, uint32_t amount); - -extern uint32_t lzma_mf_bt3_find(lzma_mf *dict, lzma_match *matches); -extern void lzma_mf_bt3_skip(lzma_mf *dict, uint32_t amount); - -extern uint32_t lzma_mf_bt4_find(lzma_mf *dict, lzma_match *matches); -extern void lzma_mf_bt4_skip(lzma_mf *dict, uint32_t amount); - -#endif diff --git a/deps/lzma/liblzma/lz/lz_encoder_hash.h b/deps/lzma/liblzma/lz/lz_encoder_hash.h deleted file mode 100644 index 342a333..0000000 --- a/deps/lzma/liblzma/lz/lz_encoder_hash.h +++ /dev/null @@ -1,108 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file lz_encoder_hash.h -/// \brief Hash macros for match finders -// -// Author: Igor Pavlov -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_LZ_ENCODER_HASH_H -#define LZMA_LZ_ENCODER_HASH_H - -#if defined(WORDS_BIGENDIAN) && !defined(HAVE_SMALL) - // This is to make liblzma produce the same output on big endian - // systems that it does on little endian systems. lz_encoder.c - // takes care of including the actual table. - extern const uint32_t lzma_lz_hash_table[256]; -# define hash_table lzma_lz_hash_table -#else -# include "check.h" -# define hash_table lzma_crc32_table[0] -#endif - -#define HASH_2_SIZE (UINT32_C(1) << 10) -#define HASH_3_SIZE (UINT32_C(1) << 16) -#define HASH_4_SIZE (UINT32_C(1) << 20) - -#define HASH_2_MASK (HASH_2_SIZE - 1) -#define HASH_3_MASK (HASH_3_SIZE - 1) -#define HASH_4_MASK (HASH_4_SIZE - 1) - -#define FIX_3_HASH_SIZE (HASH_2_SIZE) -#define FIX_4_HASH_SIZE (HASH_2_SIZE + HASH_3_SIZE) -#define FIX_5_HASH_SIZE (HASH_2_SIZE + HASH_3_SIZE + HASH_4_SIZE) - -// Endianness doesn't matter in hash_2_calc() (no effect on the output). -#ifdef TUKLIB_FAST_UNALIGNED_ACCESS -# define hash_2_calc() \ - const uint32_t hash_value = *(const uint16_t *)(cur) -#else -# define hash_2_calc() \ - const uint32_t hash_value \ - = (uint32_t)(cur[0]) | ((uint32_t)(cur[1]) << 8) -#endif - -#define hash_3_calc() \ - const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \ - const uint32_t hash_2_value = temp & HASH_2_MASK; \ - const uint32_t hash_value \ - = (temp ^ ((uint32_t)(cur[2]) << 8)) & mf->hash_mask - -#define hash_4_calc() \ - const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \ - const uint32_t hash_2_value = temp & HASH_2_MASK; \ - const uint32_t hash_3_value \ - = (temp ^ ((uint32_t)(cur[2]) << 8)) & HASH_3_MASK; \ - const uint32_t hash_value = (temp ^ ((uint32_t)(cur[2]) << 8) \ - ^ (hash_table[cur[3]] << 5)) & mf->hash_mask - - -// The following are not currently used. - -#define hash_5_calc() \ - const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \ - const uint32_t hash_2_value = temp & HASH_2_MASK; \ - const uint32_t hash_3_value \ - = (temp ^ ((uint32_t)(cur[2]) << 8)) & HASH_3_MASK; \ - uint32_t hash_4_value = (temp ^ ((uint32_t)(cur[2]) << 8) ^ \ - ^ hash_table[cur[3]] << 5); \ - const uint32_t hash_value \ - = (hash_4_value ^ (hash_table[cur[4]] << 3)) \ - & mf->hash_mask; \ - hash_4_value &= HASH_4_MASK - -/* -#define hash_zip_calc() \ - const uint32_t hash_value \ - = (((uint32_t)(cur[0]) | ((uint32_t)(cur[1]) << 8)) \ - ^ hash_table[cur[2]]) & 0xFFFF -*/ - -#define hash_zip_calc() \ - const uint32_t hash_value \ - = (((uint32_t)(cur[2]) | ((uint32_t)(cur[0]) << 8)) \ - ^ hash_table[cur[1]]) & 0xFFFF - -#define mt_hash_2_calc() \ - const uint32_t hash_2_value \ - = (hash_table[cur[0]] ^ cur[1]) & HASH_2_MASK - -#define mt_hash_3_calc() \ - const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \ - const uint32_t hash_2_value = temp & HASH_2_MASK; \ - const uint32_t hash_3_value \ - = (temp ^ ((uint32_t)(cur[2]) << 8)) & HASH_3_MASK - -#define mt_hash_4_calc() \ - const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \ - const uint32_t hash_2_value = temp & HASH_2_MASK; \ - const uint32_t hash_3_value \ - = (temp ^ ((uint32_t)(cur[2]) << 8)) & HASH_3_MASK; \ - const uint32_t hash_4_value = (temp ^ ((uint32_t)(cur[2]) << 8) ^ \ - (hash_table[cur[3]] << 5)) & HASH_4_MASK - -#endif diff --git a/deps/lzma/liblzma/lz/lz_encoder_hash_table.h b/deps/lzma/liblzma/lz/lz_encoder_hash_table.h deleted file mode 100644 index 8c51717..0000000 --- a/deps/lzma/liblzma/lz/lz_encoder_hash_table.h +++ /dev/null @@ -1,68 +0,0 @@ -/* This file has been automatically generated by crc32_tablegen.c. */ - -const uint32_t lzma_lz_hash_table[256] = { - 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, - 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, - 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, - 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, - 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, - 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, - 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, - 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, - 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, - 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, - 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, - 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, - 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, - 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, - 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, - 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, - 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, - 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, - 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, - 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, - 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, - 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, - 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, - 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, - 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, - 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, - 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, - 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, - 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, - 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, - 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, - 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, - 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, - 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, - 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, - 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, - 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, - 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, - 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, - 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, - 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, - 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, - 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, - 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, - 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, - 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, - 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, - 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, - 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, - 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, - 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, - 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, - 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, - 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, - 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, - 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, - 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, - 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, - 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, - 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, - 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, - 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, - 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, - 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D -}; diff --git a/deps/lzma/liblzma/lz/lz_encoder_mf.c b/deps/lzma/liblzma/lz/lz_encoder_mf.c deleted file mode 100644 index f82a1c1..0000000 --- a/deps/lzma/liblzma/lz/lz_encoder_mf.c +++ /dev/null @@ -1,753 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file lz_encoder_mf.c -/// \brief Match finders -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "lz_encoder.h" -#include "lz_encoder_hash.h" - - -/// \brief Find matches starting from the current byte -/// -/// \return The length of the longest match found -extern uint32_t -lzma_mf_find(lzma_mf *mf, uint32_t *count_ptr, lzma_match *matches) -{ - // Call the match finder. It returns the number of length-distance - // pairs found. - // FIXME: Minimum count is zero, what _exactly_ is the maximum? - const uint32_t count = mf->find(mf, matches); - - // Length of the longest match; assume that no matches were found - // and thus the maximum length is zero. - uint32_t len_best = 0; - - if (count > 0) { -#ifndef NDEBUG - // Validate the matches. - for (uint32_t i = 0; i < count; ++i) { - assert(matches[i].len <= mf->nice_len); - assert(matches[i].dist < mf->read_pos); - assert(memcmp(mf_ptr(mf) - 1, - mf_ptr(mf) - matches[i].dist - 2, - matches[i].len) == 0); - } -#endif - - // The last used element in the array contains - // the longest match. - len_best = matches[count - 1].len; - - // If a match of maximum search length was found, try to - // extend the match to maximum possible length. - if (len_best == mf->nice_len) { - // The limit for the match length is either the - // maximum match length supported by the LZ-based - // encoder or the number of bytes left in the - // dictionary, whichever is smaller. - uint32_t limit = mf_avail(mf) + 1; - if (limit > mf->match_len_max) - limit = mf->match_len_max; - - // Pointer to the byte we just ran through - // the match finder. - const uint8_t *p1 = mf_ptr(mf) - 1; - - // Pointer to the beginning of the match. We need -1 - // here because the match distances are zero based. - const uint8_t *p2 = p1 - matches[count - 1].dist - 1; - - while (len_best < limit - && p1[len_best] == p2[len_best]) - ++len_best; - } - } - - *count_ptr = count; - - // Finally update the read position to indicate that match finder was - // run for this dictionary offset. - ++mf->read_ahead; - - return len_best; -} - - -/// Hash value to indicate unused element in the hash. Since we start the -/// positions from dict_size + 1, zero is always too far to qualify -/// as usable match position. -#define EMPTY_HASH_VALUE 0 - - -/// Normalization must be done when lzma_mf.offset + lzma_mf.read_pos -/// reaches MUST_NORMALIZE_POS. -#define MUST_NORMALIZE_POS UINT32_MAX - - -/// \brief Normalizes hash values -/// -/// The hash arrays store positions of match candidates. The positions are -/// relative to an arbitrary offset that is not the same as the absolute -/// offset in the input stream. The relative position of the current byte -/// is lzma_mf.offset + lzma_mf.read_pos. The distances of the matches are -/// the differences of the current read position and the position found from -/// the hash. -/// -/// To prevent integer overflows of the offsets stored in the hash arrays, -/// we need to "normalize" the stored values now and then. During the -/// normalization, we drop values that indicate distance greater than the -/// dictionary size, thus making space for new values. -static void -normalize(lzma_mf *mf) -{ - assert(mf->read_pos + mf->offset == MUST_NORMALIZE_POS); - - // In future we may not want to touch the lowest bits, because there - // may be match finders that use larger resolution than one byte. - const uint32_t subvalue - = (MUST_NORMALIZE_POS - mf->cyclic_size); - // & (~(UINT32_C(1) << 10) - 1); - - const uint32_t count = mf->hash_size_sum + mf->sons_count; - uint32_t *hash = mf->hash; - - for (uint32_t i = 0; i < count; ++i) { - // If the distance is greater than the dictionary size, - // we can simply mark the hash element as empty. - // - // NOTE: Only the first mf->hash_size_sum elements are - // initialized for sure. There may be uninitialized elements - // in mf->son. Since we go through both mf->hash and - // mf->son here in normalization, Valgrind may complain - // that the "if" below depends on uninitialized value. In - // this case it is safe to ignore the warning. See also the - // comments in lz_encoder_init() in lz_encoder.c. - if (hash[i] <= subvalue) - hash[i] = EMPTY_HASH_VALUE; - else - hash[i] -= subvalue; - } - - // Update offset to match the new locations. - mf->offset -= subvalue; - - return; -} - - -/// Mark the current byte as processed from point of view of the match finder. -static void -move_pos(lzma_mf *mf) -{ - if (++mf->cyclic_pos == mf->cyclic_size) - mf->cyclic_pos = 0; - - ++mf->read_pos; - assert(mf->read_pos <= mf->write_pos); - - if (unlikely(mf->read_pos + mf->offset == UINT32_MAX)) - normalize(mf); -} - - -/// When flushing, we cannot run the match finder unless there is nice_len -/// bytes available in the dictionary. Instead, we skip running the match -/// finder (indicating that no match was found), and count how many bytes we -/// have ignored this way. -/// -/// When new data is given after the flushing was completed, the match finder -/// is restarted by rewinding mf->read_pos backwards by mf->pending. Then -/// the missed bytes are added to the hash using the match finder's skip -/// function (with small amount of input, it may start using mf->pending -/// again if flushing). -/// -/// Due to this rewinding, we don't touch cyclic_pos or test for -/// normalization. It will be done when the match finder's skip function -/// catches up after a flush. -static void -move_pending(lzma_mf *mf) -{ - ++mf->read_pos; - assert(mf->read_pos <= mf->write_pos); - ++mf->pending; -} - - -/// Calculate len_limit and determine if there is enough input to run -/// the actual match finder code. Sets up "cur" and "pos". This macro -/// is used by all find functions and binary tree skip functions. Hash -/// chain skip function doesn't need len_limit so a simpler code is used -/// in them. -#define header(is_bt, len_min, ret_op) \ - uint32_t len_limit = mf_avail(mf); \ - if (mf->nice_len <= len_limit) { \ - len_limit = mf->nice_len; \ - } else if (len_limit < (len_min) \ - || (is_bt && mf->action == LZMA_SYNC_FLUSH)) { \ - assert(mf->action != LZMA_RUN); \ - move_pending(mf); \ - ret_op; \ - } \ - const uint8_t *cur = mf_ptr(mf); \ - const uint32_t pos = mf->read_pos + mf->offset - - -/// Header for find functions. "return 0" indicates that zero matches -/// were found. -#define header_find(is_bt, len_min) \ - header(is_bt, len_min, return 0); \ - uint32_t matches_count = 0 - - -/// Header for a loop in a skip function. "continue" tells to skip the rest -/// of the code in the loop. -#define header_skip(is_bt, len_min) \ - header(is_bt, len_min, continue) - - -/// Calls hc_find_func() or bt_find_func() and calculates the total number -/// of matches found. Updates the dictionary position and returns the number -/// of matches found. -#define call_find(func, len_best) \ -do { \ - matches_count = func(len_limit, pos, cur, cur_match, mf->depth, \ - mf->son, mf->cyclic_pos, mf->cyclic_size, \ - matches + matches_count, len_best) \ - - matches; \ - move_pos(mf); \ - return matches_count; \ -} while (0) - - -//////////////// -// Hash Chain // -//////////////// - -#if defined(HAVE_MF_HC3) || defined(HAVE_MF_HC4) -/// -/// -/// \param len_limit Don't look for matches longer than len_limit. -/// \param pos lzma_mf.read_pos + lzma_mf.offset -/// \param cur Pointer to current byte (mf_ptr(mf)) -/// \param cur_match Start position of the current match candidate -/// \param depth Maximum length of the hash chain -/// \param son lzma_mf.son (contains the hash chain) -/// \param cyclic_pos -/// \param cyclic_size -/// \param matches Array to hold the matches. -/// \param len_best The length of the longest match found so far. -static lzma_match * -hc_find_func( - const uint32_t len_limit, - const uint32_t pos, - const uint8_t *const cur, - uint32_t cur_match, - uint32_t depth, - uint32_t *const son, - const uint32_t cyclic_pos, - const uint32_t cyclic_size, - lzma_match *matches, - uint32_t len_best) -{ - son[cyclic_pos] = cur_match; - - while (true) { - const uint32_t delta = pos - cur_match; - if (depth-- == 0 || delta >= cyclic_size) - return matches; - - const uint8_t *const pb = cur - delta; - cur_match = son[cyclic_pos - delta - + (delta > cyclic_pos ? cyclic_size : 0)]; - - if (pb[len_best] == cur[len_best] && pb[0] == cur[0]) { - uint32_t len = 0; - while (++len != len_limit) - if (pb[len] != cur[len]) - break; - - if (len_best < len) { - len_best = len; - matches->len = len; - matches->dist = delta - 1; - ++matches; - - if (len == len_limit) - return matches; - } - } - } -} - - -#define hc_find(len_best) \ - call_find(hc_find_func, len_best) - - -#define hc_skip() \ -do { \ - mf->son[mf->cyclic_pos] = cur_match; \ - move_pos(mf); \ -} while (0) - -#endif - - -#ifdef HAVE_MF_HC3 -extern uint32_t -lzma_mf_hc3_find(lzma_mf *mf, lzma_match *matches) -{ - header_find(false, 3); - - hash_3_calc(); - - const uint32_t delta2 = pos - mf->hash[hash_2_value]; - const uint32_t cur_match = mf->hash[FIX_3_HASH_SIZE + hash_value]; - - mf->hash[hash_2_value] = pos; - mf->hash[FIX_3_HASH_SIZE + hash_value] = pos; - - uint32_t len_best = 2; - - if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) { - for ( ; len_best != len_limit; ++len_best) - if (*(cur + len_best - delta2) != cur[len_best]) - break; - - matches[0].len = len_best; - matches[0].dist = delta2 - 1; - matches_count = 1; - - if (len_best == len_limit) { - hc_skip(); - return 1; // matches_count - } - } - - hc_find(len_best); -} - - -extern void -lzma_mf_hc3_skip(lzma_mf *mf, uint32_t amount) -{ - do { - if (mf_avail(mf) < 3) { - move_pending(mf); - continue; - } - - const uint8_t *cur = mf_ptr(mf); - const uint32_t pos = mf->read_pos + mf->offset; - - hash_3_calc(); - - const uint32_t cur_match - = mf->hash[FIX_3_HASH_SIZE + hash_value]; - - mf->hash[hash_2_value] = pos; - mf->hash[FIX_3_HASH_SIZE + hash_value] = pos; - - hc_skip(); - - } while (--amount != 0); -} -#endif - - -#ifdef HAVE_MF_HC4 -extern uint32_t -lzma_mf_hc4_find(lzma_mf *mf, lzma_match *matches) -{ - header_find(false, 4); - - hash_4_calc(); - - uint32_t delta2 = pos - mf->hash[hash_2_value]; - const uint32_t delta3 - = pos - mf->hash[FIX_3_HASH_SIZE + hash_3_value]; - const uint32_t cur_match = mf->hash[FIX_4_HASH_SIZE + hash_value]; - - mf->hash[hash_2_value ] = pos; - mf->hash[FIX_3_HASH_SIZE + hash_3_value] = pos; - mf->hash[FIX_4_HASH_SIZE + hash_value] = pos; - - uint32_t len_best = 1; - - if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) { - len_best = 2; - matches[0].len = 2; - matches[0].dist = delta2 - 1; - matches_count = 1; - } - - if (delta2 != delta3 && delta3 < mf->cyclic_size - && *(cur - delta3) == *cur) { - len_best = 3; - matches[matches_count++].dist = delta3 - 1; - delta2 = delta3; - } - - if (matches_count != 0) { - for ( ; len_best != len_limit; ++len_best) - if (*(cur + len_best - delta2) != cur[len_best]) - break; - - matches[matches_count - 1].len = len_best; - - if (len_best == len_limit) { - hc_skip(); - return matches_count; - } - } - - if (len_best < 3) - len_best = 3; - - hc_find(len_best); -} - - -extern void -lzma_mf_hc4_skip(lzma_mf *mf, uint32_t amount) -{ - do { - if (mf_avail(mf) < 4) { - move_pending(mf); - continue; - } - - const uint8_t *cur = mf_ptr(mf); - const uint32_t pos = mf->read_pos + mf->offset; - - hash_4_calc(); - - const uint32_t cur_match - = mf->hash[FIX_4_HASH_SIZE + hash_value]; - - mf->hash[hash_2_value] = pos; - mf->hash[FIX_3_HASH_SIZE + hash_3_value] = pos; - mf->hash[FIX_4_HASH_SIZE + hash_value] = pos; - - hc_skip(); - - } while (--amount != 0); -} -#endif - - -///////////////// -// Binary Tree // -///////////////// - -#if defined(HAVE_MF_BT2) || defined(HAVE_MF_BT3) || defined(HAVE_MF_BT4) -static lzma_match * -bt_find_func( - const uint32_t len_limit, - const uint32_t pos, - const uint8_t *const cur, - uint32_t cur_match, - uint32_t depth, - uint32_t *const son, - const uint32_t cyclic_pos, - const uint32_t cyclic_size, - lzma_match *matches, - uint32_t len_best) -{ - uint32_t *ptr0 = son + (cyclic_pos << 1) + 1; - uint32_t *ptr1 = son + (cyclic_pos << 1); - - uint32_t len0 = 0; - uint32_t len1 = 0; - - while (true) { - const uint32_t delta = pos - cur_match; - if (depth-- == 0 || delta >= cyclic_size) { - *ptr0 = EMPTY_HASH_VALUE; - *ptr1 = EMPTY_HASH_VALUE; - return matches; - } - - uint32_t *const pair = son + ((cyclic_pos - delta - + (delta > cyclic_pos ? cyclic_size : 0)) - << 1); - - const uint8_t *const pb = cur - delta; - uint32_t len = my_min(len0, len1); - - if (pb[len] == cur[len]) { - while (++len != len_limit) - if (pb[len] != cur[len]) - break; - - if (len_best < len) { - len_best = len; - matches->len = len; - matches->dist = delta - 1; - ++matches; - - if (len == len_limit) { - *ptr1 = pair[0]; - *ptr0 = pair[1]; - return matches; - } - } - } - - if (pb[len] < cur[len]) { - *ptr1 = cur_match; - ptr1 = pair + 1; - cur_match = *ptr1; - len1 = len; - } else { - *ptr0 = cur_match; - ptr0 = pair; - cur_match = *ptr0; - len0 = len; - } - } -} - - -static void -bt_skip_func( - const uint32_t len_limit, - const uint32_t pos, - const uint8_t *const cur, - uint32_t cur_match, - uint32_t depth, - uint32_t *const son, - const uint32_t cyclic_pos, - const uint32_t cyclic_size) -{ - uint32_t *ptr0 = son + (cyclic_pos << 1) + 1; - uint32_t *ptr1 = son + (cyclic_pos << 1); - - uint32_t len0 = 0; - uint32_t len1 = 0; - - while (true) { - const uint32_t delta = pos - cur_match; - if (depth-- == 0 || delta >= cyclic_size) { - *ptr0 = EMPTY_HASH_VALUE; - *ptr1 = EMPTY_HASH_VALUE; - return; - } - - uint32_t *pair = son + ((cyclic_pos - delta - + (delta > cyclic_pos ? cyclic_size : 0)) - << 1); - const uint8_t *pb = cur - delta; - uint32_t len = my_min(len0, len1); - - if (pb[len] == cur[len]) { - while (++len != len_limit) - if (pb[len] != cur[len]) - break; - - if (len == len_limit) { - *ptr1 = pair[0]; - *ptr0 = pair[1]; - return; - } - } - - if (pb[len] < cur[len]) { - *ptr1 = cur_match; - ptr1 = pair + 1; - cur_match = *ptr1; - len1 = len; - } else { - *ptr0 = cur_match; - ptr0 = pair; - cur_match = *ptr0; - len0 = len; - } - } -} - - -#define bt_find(len_best) \ - call_find(bt_find_func, len_best) - -#define bt_skip() \ -do { \ - bt_skip_func(len_limit, pos, cur, cur_match, mf->depth, \ - mf->son, mf->cyclic_pos, \ - mf->cyclic_size); \ - move_pos(mf); \ -} while (0) - -#endif - - -#ifdef HAVE_MF_BT2 -extern uint32_t -lzma_mf_bt2_find(lzma_mf *mf, lzma_match *matches) -{ - header_find(true, 2); - - hash_2_calc(); - - const uint32_t cur_match = mf->hash[hash_value]; - mf->hash[hash_value] = pos; - - bt_find(1); -} - - -extern void -lzma_mf_bt2_skip(lzma_mf *mf, uint32_t amount) -{ - do { - header_skip(true, 2); - - hash_2_calc(); - - const uint32_t cur_match = mf->hash[hash_value]; - mf->hash[hash_value] = pos; - - bt_skip(); - - } while (--amount != 0); -} -#endif - - -#ifdef HAVE_MF_BT3 -extern uint32_t -lzma_mf_bt3_find(lzma_mf *mf, lzma_match *matches) -{ - header_find(true, 3); - - hash_3_calc(); - - const uint32_t delta2 = pos - mf->hash[hash_2_value]; - const uint32_t cur_match = mf->hash[FIX_3_HASH_SIZE + hash_value]; - - mf->hash[hash_2_value] = pos; - mf->hash[FIX_3_HASH_SIZE + hash_value] = pos; - - uint32_t len_best = 2; - - if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) { - for ( ; len_best != len_limit; ++len_best) - if (*(cur + len_best - delta2) != cur[len_best]) - break; - - matches[0].len = len_best; - matches[0].dist = delta2 - 1; - matches_count = 1; - - if (len_best == len_limit) { - bt_skip(); - return 1; // matches_count - } - } - - bt_find(len_best); -} - - -extern void -lzma_mf_bt3_skip(lzma_mf *mf, uint32_t amount) -{ - do { - header_skip(true, 3); - - hash_3_calc(); - - const uint32_t cur_match - = mf->hash[FIX_3_HASH_SIZE + hash_value]; - - mf->hash[hash_2_value] = pos; - mf->hash[FIX_3_HASH_SIZE + hash_value] = pos; - - bt_skip(); - - } while (--amount != 0); -} -#endif - - -#ifdef HAVE_MF_BT4 -extern uint32_t -lzma_mf_bt4_find(lzma_mf *mf, lzma_match *matches) -{ - header_find(true, 4); - - hash_4_calc(); - - uint32_t delta2 = pos - mf->hash[hash_2_value]; - const uint32_t delta3 - = pos - mf->hash[FIX_3_HASH_SIZE + hash_3_value]; - const uint32_t cur_match = mf->hash[FIX_4_HASH_SIZE + hash_value]; - - mf->hash[hash_2_value] = pos; - mf->hash[FIX_3_HASH_SIZE + hash_3_value] = pos; - mf->hash[FIX_4_HASH_SIZE + hash_value] = pos; - - uint32_t len_best = 1; - - if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) { - len_best = 2; - matches[0].len = 2; - matches[0].dist = delta2 - 1; - matches_count = 1; - } - - if (delta2 != delta3 && delta3 < mf->cyclic_size - && *(cur - delta3) == *cur) { - len_best = 3; - matches[matches_count++].dist = delta3 - 1; - delta2 = delta3; - } - - if (matches_count != 0) { - for ( ; len_best != len_limit; ++len_best) - if (*(cur + len_best - delta2) != cur[len_best]) - break; - - matches[matches_count - 1].len = len_best; - - if (len_best == len_limit) { - bt_skip(); - return matches_count; - } - } - - if (len_best < 3) - len_best = 3; - - bt_find(len_best); -} - - -extern void -lzma_mf_bt4_skip(lzma_mf *mf, uint32_t amount) -{ - do { - header_skip(true, 4); - - hash_4_calc(); - - const uint32_t cur_match - = mf->hash[FIX_4_HASH_SIZE + hash_value]; - - mf->hash[hash_2_value] = pos; - mf->hash[FIX_3_HASH_SIZE + hash_3_value] = pos; - mf->hash[FIX_4_HASH_SIZE + hash_value] = pos; - - bt_skip(); - - } while (--amount != 0); -} -#endif diff --git a/deps/lzma/liblzma/lzma/fastpos.h b/deps/lzma/liblzma/lzma/fastpos.h deleted file mode 100644 index 4aea231..0000000 --- a/deps/lzma/liblzma/lzma/fastpos.h +++ /dev/null @@ -1,140 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file fastpos.h -/// \brief Kind of two-bit version of bit scan reverse -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_FASTPOS_H -#define LZMA_FASTPOS_H - -// LZMA encodes match distances (positions) by storing the highest two -// bits using a six-bit value [0, 63], and then the missing lower bits. -// Dictionary size is also stored using this encoding in the new .lzma -// file format header. -// -// fastpos.h provides a way to quickly find out the correct six-bit -// values. The following table gives some examples of this encoding: -// -// pos return -// 0 0 -// 1 1 -// 2 2 -// 3 3 -// 4 4 -// 5 4 -// 6 5 -// 7 5 -// 8 6 -// 11 6 -// 12 7 -// ... ... -// 15 7 -// 16 8 -// 17 8 -// ... ... -// 23 8 -// 24 9 -// 25 9 -// ... ... -// -// -// Provided functions or macros -// ---------------------------- -// -// get_pos_slot(pos) is the basic version. get_pos_slot_2(pos) -// assumes that pos >= FULL_DISTANCES, thus the result is at least -// FULL_DISTANCES_BITS * 2. Using get_pos_slot(pos) instead of -// get_pos_slot_2(pos) would give the same result, but get_pos_slot_2(pos) -// should be tiny bit faster due to the assumption being made. -// -// -// Size vs. speed -// -------------- -// -// With some CPUs that have fast BSR (bit scan reverse) instruction, the -// size optimized version is slightly faster than the bigger table based -// approach. Such CPUs include Intel Pentium Pro, Pentium II, Pentium III -// and Core 2 (possibly others). AMD K7 seems to have slower BSR, but that -// would still have speed roughly comparable to the table version. Older -// x86 CPUs like the original Pentium have very slow BSR; on those systems -// the table version is a lot faster. -// -// On some CPUs, the table version is a lot faster when using position -// dependent code, but with position independent code the size optimized -// version is slightly faster. This occurs at least on 32-bit SPARC (no -// ASM optimizations). -// -// I'm making the table version the default, because that has good speed -// on all systems I have tried. The size optimized version is sometimes -// slightly faster, but sometimes it is a lot slower. - -#ifdef HAVE_SMALL -# define get_pos_slot(pos) ((pos) <= 4 ? (pos) : get_pos_slot_2(pos)) - -static inline uint32_t -get_pos_slot_2(uint32_t pos) -{ - const uint32_t i = bsr32(pos); - return (i + i) + ((pos >> (i - 1)) & 1); -} - - -#else - -#define FASTPOS_BITS 13 - -extern const uint8_t lzma_fastpos[1 << FASTPOS_BITS]; - - -#define fastpos_shift(extra, n) \ - ((extra) + (n) * (FASTPOS_BITS - 1)) - -#define fastpos_limit(extra, n) \ - (UINT32_C(1) << (FASTPOS_BITS + fastpos_shift(extra, n))) - -#define fastpos_result(pos, extra, n) \ - lzma_fastpos[(pos) >> fastpos_shift(extra, n)] \ - + 2 * fastpos_shift(extra, n) - - -static inline uint32_t -get_pos_slot(uint32_t pos) -{ - // If it is small enough, we can pick the result directly from - // the precalculated table. - if (pos < fastpos_limit(0, 0)) - return lzma_fastpos[pos]; - - if (pos < fastpos_limit(0, 1)) - return fastpos_result(pos, 0, 1); - - return fastpos_result(pos, 0, 2); -} - - -#ifdef FULL_DISTANCES_BITS -static inline uint32_t -get_pos_slot_2(uint32_t pos) -{ - assert(pos >= FULL_DISTANCES); - - if (pos < fastpos_limit(FULL_DISTANCES_BITS - 1, 0)) - return fastpos_result(pos, FULL_DISTANCES_BITS - 1, 0); - - if (pos < fastpos_limit(FULL_DISTANCES_BITS - 1, 1)) - return fastpos_result(pos, FULL_DISTANCES_BITS - 1, 1); - - return fastpos_result(pos, FULL_DISTANCES_BITS - 1, 2); -} -#endif - -#endif - -#endif diff --git a/deps/lzma/liblzma/lzma/fastpos_table.c b/deps/lzma/liblzma/lzma/fastpos_table.c deleted file mode 100644 index 6a3ceac..0000000 --- a/deps/lzma/liblzma/lzma/fastpos_table.c +++ /dev/null @@ -1,519 +0,0 @@ -/* This file has been automatically generated by fastpos_tablegen.c. */ - -#include "common.h" -#include "fastpos.h" - -const uint8_t lzma_fastpos[1 << FASTPOS_BITS] = { - 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, - 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25 -}; diff --git a/deps/lzma/liblzma/lzma/fastpos_tablegen.c b/deps/lzma/liblzma/lzma/fastpos_tablegen.c deleted file mode 100644 index c97e6f4..0000000 --- a/deps/lzma/liblzma/lzma/fastpos_tablegen.c +++ /dev/null @@ -1,56 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file fastpos_tablegen.c -/// \brief Generates the lzma_fastpos[] lookup table -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include "fastpos.h" - - -int -main(void) -{ - uint8_t fastpos[1 << FASTPOS_BITS]; - - const uint8_t fast_slots = 2 * FASTPOS_BITS; - uint32_t c = 2; - - fastpos[0] = 0; - fastpos[1] = 1; - - for (uint8_t slot_fast = 2; slot_fast < fast_slots; ++slot_fast) { - const uint32_t k = 1 << ((slot_fast >> 1) - 1); - for (uint32_t j = 0; j < k; ++j, ++c) - fastpos[c] = slot_fast; - } - - printf("/* This file has been automatically generated " - "by fastpos_tablegen.c. */\n\n" - "#include \"common.h\"\n" - "#include \"fastpos.h\"\n\n" - "const uint8_t lzma_fastpos[1 << FASTPOS_BITS] = {"); - - for (size_t i = 0; i < (1 << FASTPOS_BITS); ++i) { - if (i % 16 == 0) - printf("\n\t"); - - printf("%3u", (unsigned int)(fastpos[i])); - - if (i != (1 << FASTPOS_BITS) - 1) - printf(","); - } - - printf("\n};\n"); - - return 0; -} diff --git a/deps/lzma/liblzma/lzma/lzma2_decoder.c b/deps/lzma/liblzma/lzma/lzma2_decoder.c deleted file mode 100644 index 3e42575..0000000 --- a/deps/lzma/liblzma/lzma/lzma2_decoder.c +++ /dev/null @@ -1,304 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file lzma2_decoder.c -/// \brief LZMA2 decoder -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "lzma2_decoder.h" -#include "lz_decoder.h" -#include "lzma_decoder.h" - - -struct lzma_coder_s { - enum sequence { - SEQ_CONTROL, - SEQ_UNCOMPRESSED_1, - SEQ_UNCOMPRESSED_2, - SEQ_COMPRESSED_0, - SEQ_COMPRESSED_1, - SEQ_PROPERTIES, - SEQ_LZMA, - SEQ_COPY, - } sequence; - - /// Sequence after the size fields have been decoded. - enum sequence next_sequence; - - /// LZMA decoder - lzma_lz_decoder lzma; - - /// Uncompressed size of LZMA chunk - size_t uncompressed_size; - - /// Compressed size of the chunk (naturally equals to uncompressed - /// size of uncompressed chunk) - size_t compressed_size; - - /// True if properties are needed. This is false before the - /// first LZMA chunk. - bool need_properties; - - /// True if dictionary reset is needed. This is false before the - /// first chunk (LZMA or uncompressed). - bool need_dictionary_reset; - - lzma_options_lzma options; -}; - - -static lzma_ret -lzma2_decode(lzma_coder *restrict coder, lzma_dict *restrict dict, - const uint8_t *restrict in, size_t *restrict in_pos, - size_t in_size) -{ - // With SEQ_LZMA it is possible that no new input is needed to do - // some progress. The rest of the sequences assume that there is - // at least one byte of input. - while (*in_pos < in_size || coder->sequence == SEQ_LZMA) - switch (coder->sequence) { - case SEQ_CONTROL: { - const uint32_t control = in[*in_pos]; - ++*in_pos; - - // End marker - if (control == 0x00) - return LZMA_STREAM_END; - - if (control >= 0xE0 || control == 1) { - // Dictionary reset implies that next LZMA chunk has - // to set new properties. - coder->need_properties = true; - coder->need_dictionary_reset = true; - } else if (coder->need_dictionary_reset) { - return LZMA_DATA_ERROR; - } - - if (control >= 0x80) { - // LZMA chunk. The highest five bits of the - // uncompressed size are taken from the control byte. - coder->uncompressed_size = (control & 0x1F) << 16; - coder->sequence = SEQ_UNCOMPRESSED_1; - - // See if there are new properties or if we need to - // reset the state. - if (control >= 0xC0) { - // When there are new properties, state reset - // is done at SEQ_PROPERTIES. - coder->need_properties = false; - coder->next_sequence = SEQ_PROPERTIES; - - } else if (coder->need_properties) { - return LZMA_DATA_ERROR; - - } else { - coder->next_sequence = SEQ_LZMA; - - // If only state reset is wanted with old - // properties, do the resetting here for - // simplicity. - if (control >= 0xA0) - coder->lzma.reset(coder->lzma.coder, - &coder->options); - } - } else { - // Invalid control values - if (control > 2) - return LZMA_DATA_ERROR; - - // It's uncompressed chunk - coder->sequence = SEQ_COMPRESSED_0; - coder->next_sequence = SEQ_COPY; - } - - if (coder->need_dictionary_reset) { - // Finish the dictionary reset and let the caller - // flush the dictionary to the actual output buffer. - coder->need_dictionary_reset = false; - dict_reset(dict); - return LZMA_OK; - } - - break; - } - - case SEQ_UNCOMPRESSED_1: - coder->uncompressed_size += (uint32_t)(in[(*in_pos)++]) << 8; - coder->sequence = SEQ_UNCOMPRESSED_2; - break; - - case SEQ_UNCOMPRESSED_2: - coder->uncompressed_size += in[(*in_pos)++] + 1; - coder->sequence = SEQ_COMPRESSED_0; - coder->lzma.set_uncompressed(coder->lzma.coder, - coder->uncompressed_size); - break; - - case SEQ_COMPRESSED_0: - coder->compressed_size = (uint32_t)(in[(*in_pos)++]) << 8; - coder->sequence = SEQ_COMPRESSED_1; - break; - - case SEQ_COMPRESSED_1: - coder->compressed_size += in[(*in_pos)++] + 1; - coder->sequence = coder->next_sequence; - break; - - case SEQ_PROPERTIES: - if (lzma_lzma_lclppb_decode(&coder->options, in[(*in_pos)++])) - return LZMA_DATA_ERROR; - - coder->lzma.reset(coder->lzma.coder, &coder->options); - - coder->sequence = SEQ_LZMA; - break; - - case SEQ_LZMA: { - // Store the start offset so that we can update - // coder->compressed_size later. - const size_t in_start = *in_pos; - - // Decode from in[] to *dict. - const lzma_ret ret = coder->lzma.code(coder->lzma.coder, - dict, in, in_pos, in_size); - - // Validate and update coder->compressed_size. - const size_t in_used = *in_pos - in_start; - if (in_used > coder->compressed_size) - return LZMA_DATA_ERROR; - - coder->compressed_size -= in_used; - - // Return if we didn't finish the chunk, or an error occurred. - if (ret != LZMA_STREAM_END) - return ret; - - // The LZMA decoder must have consumed the whole chunk now. - // We don't need to worry about uncompressed size since it - // is checked by the LZMA decoder. - if (coder->compressed_size != 0) - return LZMA_DATA_ERROR; - - coder->sequence = SEQ_CONTROL; - break; - } - - case SEQ_COPY: { - // Copy from input to the dictionary as is. - dict_write(dict, in, in_pos, in_size, &coder->compressed_size); - if (coder->compressed_size != 0) - return LZMA_OK; - - coder->sequence = SEQ_CONTROL; - break; - } - - default: - assert(0); - return LZMA_PROG_ERROR; - } - - return LZMA_OK; -} - - -static void -lzma2_decoder_end(lzma_coder *coder, lzma_allocator *allocator) -{ - assert(coder->lzma.end == NULL); - lzma_free(coder->lzma.coder, allocator); - - lzma_free(coder, allocator); - - return; -} - - -static lzma_ret -lzma2_decoder_init(lzma_lz_decoder *lz, lzma_allocator *allocator, - const void *opt, lzma_lz_options *lz_options) -{ - if (lz->coder == NULL) { - lz->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (lz->coder == NULL) - return LZMA_MEM_ERROR; - - lz->code = &lzma2_decode; - lz->end = &lzma2_decoder_end; - - lz->coder->lzma = LZMA_LZ_DECODER_INIT; - } - - const lzma_options_lzma *options = opt; - - lz->coder->sequence = SEQ_CONTROL; - lz->coder->need_properties = true; - lz->coder->need_dictionary_reset = options->preset_dict == NULL - || options->preset_dict_size == 0; - - return lzma_lzma_decoder_create(&lz->coder->lzma, - allocator, options, lz_options); -} - - -extern lzma_ret -lzma_lzma2_decoder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters) -{ - // LZMA2 can only be the last filter in the chain. This is enforced - // by the raw_decoder initialization. - assert(filters[1].init == NULL); - - return lzma_lz_decoder_init(next, allocator, filters, - &lzma2_decoder_init); -} - - -extern uint64_t -lzma_lzma2_decoder_memusage(const void *options) -{ - return sizeof(lzma_coder) - + lzma_lzma_decoder_memusage_nocheck(options); -} - - -extern lzma_ret -lzma_lzma2_props_decode(void **options, lzma_allocator *allocator, - const uint8_t *props, size_t props_size) -{ - if (props_size != 1) - return LZMA_OPTIONS_ERROR; - - // Check that reserved bits are unset. - if (props[0] & 0xC0) - return LZMA_OPTIONS_ERROR; - - // Decode the dictionary size. - if (props[0] > 40) - return LZMA_OPTIONS_ERROR; - - lzma_options_lzma *opt = lzma_alloc( - sizeof(lzma_options_lzma), allocator); - if (opt == NULL) - return LZMA_MEM_ERROR; - - if (props[0] == 40) { - opt->dict_size = UINT32_MAX; - } else { - opt->dict_size = 2 | (props[0] & 1); - opt->dict_size <<= props[0] / 2 + 11; - } - - opt->preset_dict = NULL; - opt->preset_dict_size = 0; - - *options = opt; - - return LZMA_OK; -} diff --git a/deps/lzma/liblzma/lzma/lzma2_decoder.h b/deps/lzma/liblzma/lzma/lzma2_decoder.h deleted file mode 100644 index fac4ac4..0000000 --- a/deps/lzma/liblzma/lzma/lzma2_decoder.h +++ /dev/null @@ -1,28 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file lzma2_decoder.h -/// \brief LZMA2 decoder -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_LZMA2_DECODER_H -#define LZMA_LZMA2_DECODER_H - -#include "common.h" - -extern lzma_ret lzma_lzma2_decoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters); - -extern uint64_t lzma_lzma2_decoder_memusage(const void *options); - -extern lzma_ret lzma_lzma2_props_decode( - void **options, lzma_allocator *allocator, - const uint8_t *props, size_t props_size); - -#endif diff --git a/deps/lzma/liblzma/lzma/lzma2_encoder.c b/deps/lzma/liblzma/lzma/lzma2_encoder.c deleted file mode 100644 index 992720c..0000000 --- a/deps/lzma/liblzma/lzma/lzma2_encoder.c +++ /dev/null @@ -1,393 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file lzma2_encoder.c -/// \brief LZMA2 encoder -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "lz_encoder.h" -#include "lzma_encoder.h" -#include "fastpos.h" -#include "lzma2_encoder.h" - - -struct lzma_coder_s { - enum { - SEQ_INIT, - SEQ_LZMA_ENCODE, - SEQ_LZMA_COPY, - SEQ_UNCOMPRESSED_HEADER, - SEQ_UNCOMPRESSED_COPY, - } sequence; - - /// LZMA encoder - lzma_coder *lzma; - - /// LZMA options currently in use. - lzma_options_lzma opt_cur; - - bool need_properties; - bool need_state_reset; - bool need_dictionary_reset; - - /// Uncompressed size of a chunk - size_t uncompressed_size; - - /// Compressed size of a chunk (excluding headers); this is also used - /// to indicate the end of buf[] in SEQ_LZMA_COPY. - size_t compressed_size; - - /// Read position in buf[] - size_t buf_pos; - - /// Buffer to hold the chunk header and LZMA compressed data - uint8_t buf[LZMA2_HEADER_MAX + LZMA2_CHUNK_MAX]; -}; - - -static void -lzma2_header_lzma(lzma_coder *coder) -{ - assert(coder->uncompressed_size > 0); - assert(coder->uncompressed_size <= LZMA2_UNCOMPRESSED_MAX); - assert(coder->compressed_size > 0); - assert(coder->compressed_size <= LZMA2_CHUNK_MAX); - - size_t pos; - - if (coder->need_properties) { - pos = 0; - - if (coder->need_dictionary_reset) - coder->buf[pos] = 0x80 + (3 << 5); - else - coder->buf[pos] = 0x80 + (2 << 5); - } else { - pos = 1; - - if (coder->need_state_reset) - coder->buf[pos] = 0x80 + (1 << 5); - else - coder->buf[pos] = 0x80; - } - - // Set the start position for copying. - coder->buf_pos = pos; - - // Uncompressed size - size_t size = coder->uncompressed_size - 1; - coder->buf[pos++] += size >> 16; - coder->buf[pos++] = (size >> 8) & 0xFF; - coder->buf[pos++] = size & 0xFF; - - // Compressed size - size = coder->compressed_size - 1; - coder->buf[pos++] = size >> 8; - coder->buf[pos++] = size & 0xFF; - - // Properties, if needed - if (coder->need_properties) - lzma_lzma_lclppb_encode(&coder->opt_cur, coder->buf + pos); - - coder->need_properties = false; - coder->need_state_reset = false; - coder->need_dictionary_reset = false; - - // The copying code uses coder->compressed_size to indicate the end - // of coder->buf[], so we need add the maximum size of the header here. - coder->compressed_size += LZMA2_HEADER_MAX; - - return; -} - - -static void -lzma2_header_uncompressed(lzma_coder *coder) -{ - assert(coder->uncompressed_size > 0); - assert(coder->uncompressed_size <= LZMA2_CHUNK_MAX); - - // If this is the first chunk, we need to include dictionary - // reset indicator. - if (coder->need_dictionary_reset) - coder->buf[0] = 1; - else - coder->buf[0] = 2; - - coder->need_dictionary_reset = false; - - // "Compressed" size - coder->buf[1] = (coder->uncompressed_size - 1) >> 8; - coder->buf[2] = (coder->uncompressed_size - 1) & 0xFF; - - // Set the start position for copying. - coder->buf_pos = 0; - return; -} - - -static lzma_ret -lzma2_encode(lzma_coder *restrict coder, lzma_mf *restrict mf, - uint8_t *restrict out, size_t *restrict out_pos, - size_t out_size) -{ - while (*out_pos < out_size) - switch (coder->sequence) { - case SEQ_INIT: - // If there's no input left and we are flushing or finishing, - // don't start a new chunk. - if (mf_unencoded(mf) == 0) { - // Write end of payload marker if finishing. - if (mf->action == LZMA_FINISH) - out[(*out_pos)++] = 0; - - return mf->action == LZMA_RUN - ? LZMA_OK : LZMA_STREAM_END; - } - - if (coder->need_state_reset) - return_if_error(lzma_lzma_encoder_reset( - coder->lzma, &coder->opt_cur)); - - coder->uncompressed_size = 0; - coder->compressed_size = 0; - coder->sequence = SEQ_LZMA_ENCODE; - - // Fall through - - case SEQ_LZMA_ENCODE: { - // Calculate how much more uncompressed data this chunk - // could accept. - const uint32_t left = LZMA2_UNCOMPRESSED_MAX - - coder->uncompressed_size; - uint32_t limit; - - if (left < mf->match_len_max) { - // Must flush immediately since the next LZMA symbol - // could make the uncompressed size of the chunk too - // big. - limit = 0; - } else { - // Calculate maximum read_limit that is OK from point - // of view of LZMA2 chunk size. - limit = mf->read_pos - mf->read_ahead - + left - mf->match_len_max; - } - - // Save the start position so that we can update - // coder->uncompressed_size. - const uint32_t read_start = mf->read_pos - mf->read_ahead; - - // Call the LZMA encoder until the chunk is finished. - const lzma_ret ret = lzma_lzma_encode(coder->lzma, mf, - coder->buf + LZMA2_HEADER_MAX, - &coder->compressed_size, - LZMA2_CHUNK_MAX, limit); - - coder->uncompressed_size += mf->read_pos - mf->read_ahead - - read_start; - - assert(coder->compressed_size <= LZMA2_CHUNK_MAX); - assert(coder->uncompressed_size <= LZMA2_UNCOMPRESSED_MAX); - - if (ret != LZMA_STREAM_END) - return LZMA_OK; - - // See if the chunk compressed. If it didn't, we encode it - // as uncompressed chunk. This saves a few bytes of space - // and makes decoding faster. - if (coder->compressed_size >= coder->uncompressed_size) { - coder->uncompressed_size += mf->read_ahead; - assert(coder->uncompressed_size - <= LZMA2_UNCOMPRESSED_MAX); - mf->read_ahead = 0; - lzma2_header_uncompressed(coder); - coder->need_state_reset = true; - coder->sequence = SEQ_UNCOMPRESSED_HEADER; - break; - } - - // The chunk did compress at least by one byte, so we store - // the chunk as LZMA. - lzma2_header_lzma(coder); - - coder->sequence = SEQ_LZMA_COPY; - } - - // Fall through - - case SEQ_LZMA_COPY: - // Copy the compressed chunk along its headers to the - // output buffer. - lzma_bufcpy(coder->buf, &coder->buf_pos, - coder->compressed_size, - out, out_pos, out_size); - if (coder->buf_pos != coder->compressed_size) - return LZMA_OK; - - coder->sequence = SEQ_INIT; - break; - - case SEQ_UNCOMPRESSED_HEADER: - // Copy the three-byte header to indicate uncompressed chunk. - lzma_bufcpy(coder->buf, &coder->buf_pos, - LZMA2_HEADER_UNCOMPRESSED, - out, out_pos, out_size); - if (coder->buf_pos != LZMA2_HEADER_UNCOMPRESSED) - return LZMA_OK; - - coder->sequence = SEQ_UNCOMPRESSED_COPY; - - // Fall through - - case SEQ_UNCOMPRESSED_COPY: - // Copy the uncompressed data as is from the dictionary - // to the output buffer. - mf_read(mf, out, out_pos, out_size, &coder->uncompressed_size); - if (coder->uncompressed_size != 0) - return LZMA_OK; - - coder->sequence = SEQ_INIT; - break; - } - - return LZMA_OK; -} - - -static void -lzma2_encoder_end(lzma_coder *coder, lzma_allocator *allocator) -{ - lzma_free(coder->lzma, allocator); - lzma_free(coder, allocator); - return; -} - - -static lzma_ret -lzma2_encoder_options_update(lzma_coder *coder, const lzma_filter *filter) -{ - // New options can be set only when there is no incomplete chunk. - // This is the case at the beginning of the raw stream and right - // after LZMA_SYNC_FLUSH. - if (filter->options == NULL || coder->sequence != SEQ_INIT) - return LZMA_PROG_ERROR; - - // Look if there are new options. At least for now, - // only lc/lp/pb can be changed. - const lzma_options_lzma *opt = filter->options; - if (coder->opt_cur.lc != opt->lc || coder->opt_cur.lp != opt->lp - || coder->opt_cur.pb != opt->pb) { - // Validate the options. - if (opt->lc > LZMA_LCLP_MAX || opt->lp > LZMA_LCLP_MAX - || opt->lc + opt->lp > LZMA_LCLP_MAX - || opt->pb > LZMA_PB_MAX) - return LZMA_OPTIONS_ERROR; - - // The new options will be used when the encoder starts - // a new LZMA2 chunk. - coder->opt_cur.lc = opt->lc; - coder->opt_cur.lp = opt->lp; - coder->opt_cur.pb = opt->pb; - coder->need_properties = true; - coder->need_state_reset = true; - } - - return LZMA_OK; -} - - -static lzma_ret -lzma2_encoder_init(lzma_lz_encoder *lz, lzma_allocator *allocator, - const void *options, lzma_lz_options *lz_options) -{ - if (options == NULL) - return LZMA_PROG_ERROR; - - if (lz->coder == NULL) { - lz->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (lz->coder == NULL) - return LZMA_MEM_ERROR; - - lz->code = &lzma2_encode; - lz->end = &lzma2_encoder_end; - lz->options_update = &lzma2_encoder_options_update; - - lz->coder->lzma = NULL; - } - - lz->coder->opt_cur = *(const lzma_options_lzma *)(options); - - lz->coder->sequence = SEQ_INIT; - lz->coder->need_properties = true; - lz->coder->need_state_reset = false; - lz->coder->need_dictionary_reset - = lz->coder->opt_cur.preset_dict == NULL - || lz->coder->opt_cur.preset_dict_size == 0; - - // Initialize LZMA encoder - return_if_error(lzma_lzma_encoder_create(&lz->coder->lzma, allocator, - &lz->coder->opt_cur, lz_options)); - - // Make sure that we will always have enough history available in - // case we need to use uncompressed chunks. They are used when the - // compressed size of a chunk is not smaller than the uncompressed - // size, so we need to have at least LZMA2_COMPRESSED_MAX bytes - // history available. - if (lz_options->before_size + lz_options->dict_size < LZMA2_CHUNK_MAX) - lz_options->before_size - = LZMA2_CHUNK_MAX - lz_options->dict_size; - - return LZMA_OK; -} - - -extern lzma_ret -lzma_lzma2_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters) -{ - return lzma_lz_encoder_init( - next, allocator, filters, &lzma2_encoder_init); -} - - -extern uint64_t -lzma_lzma2_encoder_memusage(const void *options) -{ - const uint64_t lzma_mem = lzma_lzma_encoder_memusage(options); - if (lzma_mem == UINT64_MAX) - return UINT64_MAX; - - return sizeof(lzma_coder) + lzma_mem; -} - - -extern lzma_ret -lzma_lzma2_props_encode(const void *options, uint8_t *out) -{ - const lzma_options_lzma *const opt = options; - uint32_t d = my_max(opt->dict_size, LZMA_DICT_SIZE_MIN); - - // Round up to the next 2^n - 1 or 2^n + 2^(n - 1) - 1 depending - // on which one is the next: - --d; - d |= d >> 2; - d |= d >> 3; - d |= d >> 4; - d |= d >> 8; - d |= d >> 16; - - // Get the highest two bits using the proper encoding: - if (d == UINT32_MAX) - out[0] = 40; - else - out[0] = get_pos_slot(d + 1) - 24; - - return LZMA_OK; -} diff --git a/deps/lzma/liblzma/lzma/lzma2_encoder.h b/deps/lzma/liblzma/lzma/lzma2_encoder.h deleted file mode 100644 index ca19ef4..0000000 --- a/deps/lzma/liblzma/lzma/lzma2_encoder.h +++ /dev/null @@ -1,41 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file lzma2_encoder.h -/// \brief LZMA2 encoder -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_LZMA2_ENCODER_H -#define LZMA_LZMA2_ENCODER_H - -#include "common.h" - - -/// Maximum number of bytes of actual data per chunk (no headers) -#define LZMA2_CHUNK_MAX (UINT32_C(1) << 16) - -/// Maximum uncompressed size of LZMA chunk (no headers) -#define LZMA2_UNCOMPRESSED_MAX (UINT32_C(1) << 21) - -/// Maximum size of LZMA2 headers -#define LZMA2_HEADER_MAX 6 - -/// Size of a header for uncompressed chunk -#define LZMA2_HEADER_UNCOMPRESSED 3 - - -extern lzma_ret lzma_lzma2_encoder_init( - lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters); - -extern uint64_t lzma_lzma2_encoder_memusage(const void *options); - -extern lzma_ret lzma_lzma2_props_encode(const void *options, uint8_t *out); - -#endif diff --git a/deps/lzma/liblzma/lzma/lzma_common.h b/deps/lzma/liblzma/lzma/lzma_common.h deleted file mode 100644 index e31e285..0000000 --- a/deps/lzma/liblzma/lzma/lzma_common.h +++ /dev/null @@ -1,223 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file lzma_common.h -/// \brief Private definitions common to LZMA encoder and decoder -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_LZMA_COMMON_H -#define LZMA_LZMA_COMMON_H - -#include "common.h" -#include "range_common.h" - - -/////////////////// -// Miscellaneous // -/////////////////// - -/// Maximum number of position states. A position state is the lowest pos bits -/// number of bits of the current uncompressed offset. In some places there -/// are different sets of probabilities for different pos states. -#define POS_STATES_MAX (1 << LZMA_PB_MAX) - - -/// Validates lc, lp, and pb. -static inline bool -is_lclppb_valid(const lzma_options_lzma *options) -{ - return options->lc <= LZMA_LCLP_MAX && options->lp <= LZMA_LCLP_MAX - && options->lc + options->lp <= LZMA_LCLP_MAX - && options->pb <= LZMA_PB_MAX; -} - - -/////////// -// State // -/////////// - -/// This enum is used to track which events have occurred most recently and -/// in which order. This information is used to predict the next event. -/// -/// Events: -/// - Literal: One 8-bit byte -/// - Match: Repeat a chunk of data at some distance -/// - Long repeat: Multi-byte match at a recently seen distance -/// - Short repeat: One-byte repeat at a recently seen distance -/// -/// The event names are in from STATE_oldest_older_previous. REP means -/// either short or long repeated match, and NONLIT means any non-literal. -typedef enum { - STATE_LIT_LIT, - STATE_MATCH_LIT_LIT, - STATE_REP_LIT_LIT, - STATE_SHORTREP_LIT_LIT, - STATE_MATCH_LIT, - STATE_REP_LIT, - STATE_SHORTREP_LIT, - STATE_LIT_MATCH, - STATE_LIT_LONGREP, - STATE_LIT_SHORTREP, - STATE_NONLIT_MATCH, - STATE_NONLIT_REP, -} lzma_lzma_state; - - -/// Total number of states -#define STATES 12 - -/// The lowest 7 states indicate that the previous state was a literal. -#define LIT_STATES 7 - - -/// Indicate that the latest state was a literal. -#define update_literal(state) \ - state = ((state) <= STATE_SHORTREP_LIT_LIT \ - ? STATE_LIT_LIT \ - : ((state) <= STATE_LIT_SHORTREP \ - ? (state) - 3 \ - : (state) - 6)) - -/// Indicate that the latest state was a match. -#define update_match(state) \ - state = ((state) < LIT_STATES ? STATE_LIT_MATCH : STATE_NONLIT_MATCH) - -/// Indicate that the latest state was a long repeated match. -#define update_long_rep(state) \ - state = ((state) < LIT_STATES ? STATE_LIT_LONGREP : STATE_NONLIT_REP) - -/// Indicate that the latest state was a short match. -#define update_short_rep(state) \ - state = ((state) < LIT_STATES ? STATE_LIT_SHORTREP : STATE_NONLIT_REP) - -/// Test if the previous state was a literal. -#define is_literal_state(state) \ - ((state) < LIT_STATES) - - -///////////// -// Literal // -///////////// - -/// Each literal coder is divided in three sections: -/// - 0x001-0x0FF: Without match byte -/// - 0x101-0x1FF: With match byte; match bit is 0 -/// - 0x201-0x2FF: With match byte; match bit is 1 -/// -/// Match byte is used when the previous LZMA symbol was something else than -/// a literal (that is, it was some kind of match). -#define LITERAL_CODER_SIZE 0x300 - -/// Maximum number of literal coders -#define LITERAL_CODERS_MAX (1 << LZMA_LCLP_MAX) - -/// Locate the literal coder for the next literal byte. The choice depends on -/// - the lowest literal_pos_bits bits of the position of the current -/// byte; and -/// - the highest literal_context_bits bits of the previous byte. -#define literal_subcoder(probs, lc, lp_mask, pos, prev_byte) \ - ((probs)[(((pos) & lp_mask) << lc) + ((prev_byte) >> (8 - lc))]) - - -static inline void -literal_init(probability (*probs)[LITERAL_CODER_SIZE], - uint32_t lc, uint32_t lp) -{ - assert(lc + lp <= LZMA_LCLP_MAX); - - const uint32_t coders = 1U << (lc + lp); - - for (uint32_t i = 0; i < coders; ++i) - for (uint32_t j = 0; j < LITERAL_CODER_SIZE; ++j) - bit_reset(probs[i][j]); - - return; -} - - -////////////////// -// Match length // -////////////////// - -// Minimum length of a match is two bytes. -#define MATCH_LEN_MIN 2 - -// Match length is encoded with 4, 5, or 10 bits. -// -// Length Bits -// 2-9 4 = Choice=0 + 3 bits -// 10-17 5 = Choice=1 + Choice2=0 + 3 bits -// 18-273 10 = Choice=1 + Choice2=1 + 8 bits -#define LEN_LOW_BITS 3 -#define LEN_LOW_SYMBOLS (1 << LEN_LOW_BITS) -#define LEN_MID_BITS 3 -#define LEN_MID_SYMBOLS (1 << LEN_MID_BITS) -#define LEN_HIGH_BITS 8 -#define LEN_HIGH_SYMBOLS (1 << LEN_HIGH_BITS) -#define LEN_SYMBOLS (LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS + LEN_HIGH_SYMBOLS) - -// Maximum length of a match is 273 which is a result of the encoding -// described above. -#define MATCH_LEN_MAX (MATCH_LEN_MIN + LEN_SYMBOLS - 1) - - -//////////////////// -// Match distance // -//////////////////// - -// Different set of probabilities is used for match distances that have very -// short match length: Lengths of 2, 3, and 4 bytes have a separate set of -// probabilities for each length. The matches with longer length use a shared -// set of probabilities. -#define LEN_TO_POS_STATES 4 - -// Macro to get the index of the appropriate probability array. -#define get_len_to_pos_state(len) \ - ((len) < LEN_TO_POS_STATES + MATCH_LEN_MIN \ - ? (len) - MATCH_LEN_MIN \ - : LEN_TO_POS_STATES - 1) - -// The highest two bits of a match distance (pos slot) are encoded using six -// bits. See fastpos.h for more explanation. -#define POS_SLOT_BITS 6 -#define POS_SLOTS (1 << POS_SLOT_BITS) - -// Match distances up to 127 are fully encoded using probabilities. Since -// the highest two bits (pos slot) are always encoded using six bits, the -// distances 0-3 don't need any additional bits to encode, since the pos -// slot itself is the same as the actual distance. START_POS_MODEL_INDEX -// indicates the first pos slot where at least one additional bit is needed. -#define START_POS_MODEL_INDEX 4 - -// Match distances greater than 127 are encoded in three pieces: -// - pos slot: the highest two bits -// - direct bits: 2-26 bits below the highest two bits -// - alignment bits: four lowest bits -// -// Direct bits don't use any probabilities. -// -// The pos slot value of 14 is for distances 128-191 (see the table in -// fastpos.h to understand why). -#define END_POS_MODEL_INDEX 14 - -// Pos slots that indicate a distance <= 127. -#define FULL_DISTANCES_BITS (END_POS_MODEL_INDEX / 2) -#define FULL_DISTANCES (1 << FULL_DISTANCES_BITS) - -// For match distances greater than 127, only the highest two bits and the -// lowest four bits (alignment) is encoded using probabilities. -#define ALIGN_BITS 4 -#define ALIGN_TABLE_SIZE (1 << ALIGN_BITS) -#define ALIGN_MASK (ALIGN_TABLE_SIZE - 1) - -// LZMA remembers the four most recent match distances. Reusing these distances -// tends to take less space than re-encoding the actual distance value. -#define REP_DISTANCES 4 - -#endif diff --git a/deps/lzma/liblzma/lzma/lzma_decoder.c b/deps/lzma/liblzma/lzma/lzma_decoder.c deleted file mode 100644 index 9979bb4..0000000 --- a/deps/lzma/liblzma/lzma/lzma_decoder.c +++ /dev/null @@ -1,1057 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file lzma_decoder.c -/// \brief LZMA decoder -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "lz_decoder.h" -#include "lzma_common.h" -#include "lzma_decoder.h" -#include "range_decoder.h" - - -#ifdef HAVE_SMALL - -// Macros for (somewhat) size-optimized code. -#define seq_4(seq) seq - -#define seq_6(seq) seq - -#define seq_8(seq) seq - -#define seq_len(seq) \ - seq ## _CHOICE, \ - seq ## _CHOICE2, \ - seq ## _BITTREE - -#define len_decode(target, ld, pos_state, seq) \ -do { \ -case seq ## _CHOICE: \ - rc_if_0(ld.choice, seq ## _CHOICE) { \ - rc_update_0(ld.choice); \ - probs = ld.low[pos_state];\ - limit = LEN_LOW_SYMBOLS; \ - target = MATCH_LEN_MIN; \ - } else { \ - rc_update_1(ld.choice); \ -case seq ## _CHOICE2: \ - rc_if_0(ld.choice2, seq ## _CHOICE2) { \ - rc_update_0(ld.choice2); \ - probs = ld.mid[pos_state]; \ - limit = LEN_MID_SYMBOLS; \ - target = MATCH_LEN_MIN + LEN_LOW_SYMBOLS; \ - } else { \ - rc_update_1(ld.choice2); \ - probs = ld.high; \ - limit = LEN_HIGH_SYMBOLS; \ - target = MATCH_LEN_MIN + LEN_LOW_SYMBOLS \ - + LEN_MID_SYMBOLS; \ - } \ - } \ - symbol = 1; \ -case seq ## _BITTREE: \ - do { \ - rc_bit(probs[symbol], , , seq ## _BITTREE); \ - } while (symbol < limit); \ - target += symbol - limit; \ -} while (0) - -#else // HAVE_SMALL - -// Unrolled versions -#define seq_4(seq) \ - seq ## 0, \ - seq ## 1, \ - seq ## 2, \ - seq ## 3 - -#define seq_6(seq) \ - seq ## 0, \ - seq ## 1, \ - seq ## 2, \ - seq ## 3, \ - seq ## 4, \ - seq ## 5 - -#define seq_8(seq) \ - seq ## 0, \ - seq ## 1, \ - seq ## 2, \ - seq ## 3, \ - seq ## 4, \ - seq ## 5, \ - seq ## 6, \ - seq ## 7 - -#define seq_len(seq) \ - seq ## _CHOICE, \ - seq ## _LOW0, \ - seq ## _LOW1, \ - seq ## _LOW2, \ - seq ## _CHOICE2, \ - seq ## _MID0, \ - seq ## _MID1, \ - seq ## _MID2, \ - seq ## _HIGH0, \ - seq ## _HIGH1, \ - seq ## _HIGH2, \ - seq ## _HIGH3, \ - seq ## _HIGH4, \ - seq ## _HIGH5, \ - seq ## _HIGH6, \ - seq ## _HIGH7 - -#define len_decode(target, ld, pos_state, seq) \ -do { \ - symbol = 1; \ -case seq ## _CHOICE: \ - rc_if_0(ld.choice, seq ## _CHOICE) { \ - rc_update_0(ld.choice); \ - rc_bit_case(ld.low[pos_state][symbol], , , seq ## _LOW0); \ - rc_bit_case(ld.low[pos_state][symbol], , , seq ## _LOW1); \ - rc_bit_case(ld.low[pos_state][symbol], , , seq ## _LOW2); \ - target = symbol - LEN_LOW_SYMBOLS + MATCH_LEN_MIN; \ - } else { \ - rc_update_1(ld.choice); \ -case seq ## _CHOICE2: \ - rc_if_0(ld.choice2, seq ## _CHOICE2) { \ - rc_update_0(ld.choice2); \ - rc_bit_case(ld.mid[pos_state][symbol], , , \ - seq ## _MID0); \ - rc_bit_case(ld.mid[pos_state][symbol], , , \ - seq ## _MID1); \ - rc_bit_case(ld.mid[pos_state][symbol], , , \ - seq ## _MID2); \ - target = symbol - LEN_MID_SYMBOLS \ - + MATCH_LEN_MIN + LEN_LOW_SYMBOLS; \ - } else { \ - rc_update_1(ld.choice2); \ - rc_bit_case(ld.high[symbol], , , seq ## _HIGH0); \ - rc_bit_case(ld.high[symbol], , , seq ## _HIGH1); \ - rc_bit_case(ld.high[symbol], , , seq ## _HIGH2); \ - rc_bit_case(ld.high[symbol], , , seq ## _HIGH3); \ - rc_bit_case(ld.high[symbol], , , seq ## _HIGH4); \ - rc_bit_case(ld.high[symbol], , , seq ## _HIGH5); \ - rc_bit_case(ld.high[symbol], , , seq ## _HIGH6); \ - rc_bit_case(ld.high[symbol], , , seq ## _HIGH7); \ - target = symbol - LEN_HIGH_SYMBOLS \ - + MATCH_LEN_MIN \ - + LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS; \ - } \ - } \ -} while (0) - -#endif // HAVE_SMALL - - -/// Length decoder probabilities; see comments in lzma_common.h. -typedef struct { - probability choice; - probability choice2; - probability low[POS_STATES_MAX][LEN_LOW_SYMBOLS]; - probability mid[POS_STATES_MAX][LEN_MID_SYMBOLS]; - probability high[LEN_HIGH_SYMBOLS]; -} lzma_length_decoder; - - -struct lzma_coder_s { - /////////////////// - // Probabilities // - /////////////////// - - /// Literals; see comments in lzma_common.h. - probability literal[LITERAL_CODERS_MAX][LITERAL_CODER_SIZE]; - - /// If 1, it's a match. Otherwise it's a single 8-bit literal. - probability is_match[STATES][POS_STATES_MAX]; - - /// If 1, it's a repeated match. The distance is one of rep0 .. rep3. - probability is_rep[STATES]; - - /// If 0, distance of a repeated match is rep0. - /// Otherwise check is_rep1. - probability is_rep0[STATES]; - - /// If 0, distance of a repeated match is rep1. - /// Otherwise check is_rep2. - probability is_rep1[STATES]; - - /// If 0, distance of a repeated match is rep2. Otherwise it is rep3. - probability is_rep2[STATES]; - - /// If 1, the repeated match has length of one byte. Otherwise - /// the length is decoded from rep_len_decoder. - probability is_rep0_long[STATES][POS_STATES_MAX]; - - /// Probability tree for the highest two bits of the match distance. - /// There is a separate probability tree for match lengths of - /// 2 (i.e. MATCH_LEN_MIN), 3, 4, and [5, 273]. - probability pos_slot[LEN_TO_POS_STATES][POS_SLOTS]; - - /// Probability trees for additional bits for match distance when the - /// distance is in the range [4, 127]. - probability pos_special[FULL_DISTANCES - END_POS_MODEL_INDEX]; - - /// Probability tree for the lowest four bits of a match distance - /// that is equal to or greater than 128. - probability pos_align[ALIGN_TABLE_SIZE]; - - /// Length of a normal match - lzma_length_decoder match_len_decoder; - - /// Length of a repeated match - lzma_length_decoder rep_len_decoder; - - /////////////////// - // Decoder state // - /////////////////// - - // Range coder - lzma_range_decoder rc; - - // Types of the most recently seen LZMA symbols - lzma_lzma_state state; - - uint32_t rep0; ///< Distance of the latest match - uint32_t rep1; ///< Distance of second latest match - uint32_t rep2; ///< Distance of third latest match - uint32_t rep3; ///< Distance of fourth latest match - - uint32_t pos_mask; // (1U << pb) - 1 - uint32_t literal_context_bits; - uint32_t literal_pos_mask; - - /// Uncompressed size as bytes, or LZMA_VLI_UNKNOWN if end of - /// payload marker is expected. - lzma_vli uncompressed_size; - - //////////////////////////////// - // State of incomplete symbol // - //////////////////////////////// - - /// Position where to continue the decoder loop - enum { - SEQ_NORMALIZE, - SEQ_IS_MATCH, - seq_8(SEQ_LITERAL), - seq_8(SEQ_LITERAL_MATCHED), - SEQ_LITERAL_WRITE, - SEQ_IS_REP, - seq_len(SEQ_MATCH_LEN), - seq_6(SEQ_POS_SLOT), - SEQ_POS_MODEL, - SEQ_DIRECT, - seq_4(SEQ_ALIGN), - SEQ_EOPM, - SEQ_IS_REP0, - SEQ_SHORTREP, - SEQ_IS_REP0_LONG, - SEQ_IS_REP1, - SEQ_IS_REP2, - seq_len(SEQ_REP_LEN), - SEQ_COPY, - } sequence; - - /// Base of the current probability tree - probability *probs; - - /// Symbol being decoded. This is also used as an index variable in - /// bittree decoders: probs[symbol] - uint32_t symbol; - - /// Used as a loop termination condition on bittree decoders and - /// direct bits decoder. - uint32_t limit; - - /// Matched literal decoder: 0x100 or 0 to help avoiding branches. - /// Bittree reverse decoders: Offset of the next bit: 1 << offset - uint32_t offset; - - /// If decoding a literal: match byte. - /// If decoding a match: length of the match. - uint32_t len; -}; - - -static lzma_ret -lzma_decode(lzma_coder *restrict coder, lzma_dict *restrict dictptr, - const uint8_t *restrict in, - size_t *restrict in_pos, size_t in_size) -{ - //////////////////// - // Initialization // - //////////////////// - - if (!rc_read_init(&coder->rc, in, in_pos, in_size)) - return LZMA_OK; - - /////////////// - // Variables // - /////////////// - - // Making local copies of often-used variables improves both - // speed and readability. - - lzma_dict dict = *dictptr; - - const size_t dict_start = dict.pos; - - // Range decoder - rc_to_local(coder->rc, *in_pos); - - // State - uint32_t state = coder->state; - uint32_t rep0 = coder->rep0; - uint32_t rep1 = coder->rep1; - uint32_t rep2 = coder->rep2; - uint32_t rep3 = coder->rep3; - - const uint32_t pos_mask = coder->pos_mask; - - // These variables are actually needed only if we last time ran - // out of input in the middle of the decoder loop. - probability *probs = coder->probs; - uint32_t symbol = coder->symbol; - uint32_t limit = coder->limit; - uint32_t offset = coder->offset; - uint32_t len = coder->len; - - const uint32_t literal_pos_mask = coder->literal_pos_mask; - const uint32_t literal_context_bits = coder->literal_context_bits; - - // Temporary variables - uint32_t pos_state = dict.pos & pos_mask; - - lzma_ret ret = LZMA_OK; - - // If uncompressed size is known, there must be no end of payload - // marker. - const bool no_eopm = coder->uncompressed_size - != LZMA_VLI_UNKNOWN; - if (no_eopm && coder->uncompressed_size < dict.limit - dict.pos) - dict.limit = dict.pos + (size_t)(coder->uncompressed_size); - - // The main decoder loop. The "switch" is used to restart the decoder at - // correct location. Once restarted, the "switch" is no longer used. - switch (coder->sequence) - while (true) { - // Calculate new pos_state. This is skipped on the first loop - // since we already calculated it when setting up the local - // variables. - pos_state = dict.pos & pos_mask; - - case SEQ_NORMALIZE: - case SEQ_IS_MATCH: - if (unlikely(no_eopm && dict.pos == dict.limit)) - break; - - rc_if_0(coder->is_match[state][pos_state], SEQ_IS_MATCH) { - rc_update_0(coder->is_match[state][pos_state]); - - // It's a literal i.e. a single 8-bit byte. - - probs = literal_subcoder(coder->literal, - literal_context_bits, literal_pos_mask, - dict.pos, dict_get(&dict, 0)); - symbol = 1; - - if (is_literal_state(state)) { - // Decode literal without match byte. -#ifdef HAVE_SMALL - case SEQ_LITERAL: - do { - rc_bit(probs[symbol], , , SEQ_LITERAL); - } while (symbol < (1 << 8)); -#else - rc_bit_case(probs[symbol], , , SEQ_LITERAL0); - rc_bit_case(probs[symbol], , , SEQ_LITERAL1); - rc_bit_case(probs[symbol], , , SEQ_LITERAL2); - rc_bit_case(probs[symbol], , , SEQ_LITERAL3); - rc_bit_case(probs[symbol], , , SEQ_LITERAL4); - rc_bit_case(probs[symbol], , , SEQ_LITERAL5); - rc_bit_case(probs[symbol], , , SEQ_LITERAL6); - rc_bit_case(probs[symbol], , , SEQ_LITERAL7); -#endif - } else { - // Decode literal with match byte. - // - // We store the byte we compare against - // ("match byte") to "len" to minimize the - // number of variables we need to store - // between decoder calls. - len = dict_get(&dict, rep0) << 1; - - // The usage of "offset" allows omitting some - // branches, which should give tiny speed - // improvement on some CPUs. "offset" gets - // set to zero if match_bit didn't match. - offset = 0x100; - -#ifdef HAVE_SMALL - case SEQ_LITERAL_MATCHED: - do { - const uint32_t match_bit - = len & offset; - const uint32_t subcoder_index - = offset + match_bit - + symbol; - - rc_bit(probs[subcoder_index], - offset &= ~match_bit, - offset &= match_bit, - SEQ_LITERAL_MATCHED); - - // It seems to be faster to do this - // here instead of putting it to the - // beginning of the loop and then - // putting the "case" in the middle - // of the loop. - len <<= 1; - - } while (symbol < (1 << 8)); -#else - // Unroll the loop. - uint32_t match_bit; - uint32_t subcoder_index; - -# define d(seq) \ - case seq: \ - match_bit = len & offset; \ - subcoder_index = offset + match_bit + symbol; \ - rc_bit(probs[subcoder_index], \ - offset &= ~match_bit, \ - offset &= match_bit, \ - seq) - - d(SEQ_LITERAL_MATCHED0); - len <<= 1; - d(SEQ_LITERAL_MATCHED1); - len <<= 1; - d(SEQ_LITERAL_MATCHED2); - len <<= 1; - d(SEQ_LITERAL_MATCHED3); - len <<= 1; - d(SEQ_LITERAL_MATCHED4); - len <<= 1; - d(SEQ_LITERAL_MATCHED5); - len <<= 1; - d(SEQ_LITERAL_MATCHED6); - len <<= 1; - d(SEQ_LITERAL_MATCHED7); -# undef d -#endif - } - - //update_literal(state); - // Use a lookup table to update to literal state, - // since compared to other state updates, this would - // need two branches. - static const lzma_lzma_state next_state[] = { - STATE_LIT_LIT, - STATE_LIT_LIT, - STATE_LIT_LIT, - STATE_LIT_LIT, - STATE_MATCH_LIT_LIT, - STATE_REP_LIT_LIT, - STATE_SHORTREP_LIT_LIT, - STATE_MATCH_LIT, - STATE_REP_LIT, - STATE_SHORTREP_LIT, - STATE_MATCH_LIT, - STATE_REP_LIT - }; - state = next_state[state]; - - case SEQ_LITERAL_WRITE: - if (unlikely(dict_put(&dict, symbol))) { - coder->sequence = SEQ_LITERAL_WRITE; - goto out; - } - - continue; - } - - // Instead of a new byte we are going to get a byte range - // (distance and length) which will be repeated from our - // output history. - - rc_update_1(coder->is_match[state][pos_state]); - - case SEQ_IS_REP: - rc_if_0(coder->is_rep[state], SEQ_IS_REP) { - // Not a repeated match - rc_update_0(coder->is_rep[state]); - update_match(state); - - // The latest three match distances are kept in - // memory in case there are repeated matches. - rep3 = rep2; - rep2 = rep1; - rep1 = rep0; - - // Decode the length of the match. - len_decode(len, coder->match_len_decoder, - pos_state, SEQ_MATCH_LEN); - - // Prepare to decode the highest two bits of the - // match distance. - probs = coder->pos_slot[get_len_to_pos_state(len)]; - symbol = 1; - -#ifdef HAVE_SMALL - case SEQ_POS_SLOT: - do { - rc_bit(probs[symbol], , , SEQ_POS_SLOT); - } while (symbol < POS_SLOTS); -#else - rc_bit_case(probs[symbol], , , SEQ_POS_SLOT0); - rc_bit_case(probs[symbol], , , SEQ_POS_SLOT1); - rc_bit_case(probs[symbol], , , SEQ_POS_SLOT2); - rc_bit_case(probs[symbol], , , SEQ_POS_SLOT3); - rc_bit_case(probs[symbol], , , SEQ_POS_SLOT4); - rc_bit_case(probs[symbol], , , SEQ_POS_SLOT5); -#endif - // Get rid of the highest bit that was needed for - // indexing of the probability array. - symbol -= POS_SLOTS; - assert(symbol <= 63); - - if (symbol < START_POS_MODEL_INDEX) { - // Match distances [0, 3] have only two bits. - rep0 = symbol; - } else { - // Decode the lowest [1, 29] bits of - // the match distance. - limit = (symbol >> 1) - 1; - assert(limit >= 1 && limit <= 30); - rep0 = 2 + (symbol & 1); - - if (symbol < END_POS_MODEL_INDEX) { - // Prepare to decode the low bits for - // a distance of [4, 127]. - assert(limit <= 5); - rep0 <<= limit; - assert(rep0 <= 96); - // -1 is fine, because we start - // decoding at probs[1], not probs[0]. - // NOTE: This violates the C standard, - // since we are doing pointer - // arithmetic past the beginning of - // the array. - assert((int32_t)(rep0 - symbol - 1) - >= -1); - assert((int32_t)(rep0 - symbol - 1) - <= 82); - probs = coder->pos_special + rep0 - - symbol - 1; - symbol = 1; - offset = 0; - case SEQ_POS_MODEL: -#ifdef HAVE_SMALL - do { - rc_bit(probs[symbol], , - rep0 += 1 << offset, - SEQ_POS_MODEL); - } while (++offset < limit); -#else - switch (limit) { - case 5: - assert(offset == 0); - rc_bit(probs[symbol], , - rep0 += 1, - SEQ_POS_MODEL); - ++offset; - --limit; - case 4: - rc_bit(probs[symbol], , - rep0 += 1 << offset, - SEQ_POS_MODEL); - ++offset; - --limit; - case 3: - rc_bit(probs[symbol], , - rep0 += 1 << offset, - SEQ_POS_MODEL); - ++offset; - --limit; - case 2: - rc_bit(probs[symbol], , - rep0 += 1 << offset, - SEQ_POS_MODEL); - ++offset; - --limit; - case 1: - // We need "symbol" only for - // indexing the probability - // array, thus we can use - // rc_bit_last() here to omit - // the unneeded updating of - // "symbol". - rc_bit_last(probs[symbol], , - rep0 += 1 << offset, - SEQ_POS_MODEL); - } -#endif - } else { - // The distance is >= 128. Decode the - // lower bits without probabilities - // except the lowest four bits. - assert(symbol >= 14); - assert(limit >= 6); - limit -= ALIGN_BITS; - assert(limit >= 2); - case SEQ_DIRECT: - // Not worth manual unrolling - do { - rc_direct(rep0, SEQ_DIRECT); - } while (--limit > 0); - - // Decode the lowest four bits using - // probabilities. - rep0 <<= ALIGN_BITS; - symbol = 1; -#ifdef HAVE_SMALL - offset = 0; - case SEQ_ALIGN: - do { - rc_bit(coder->pos_align[ - symbol], , - rep0 += 1 << offset, - SEQ_ALIGN); - } while (++offset < ALIGN_BITS); -#else - case SEQ_ALIGN0: - rc_bit(coder->pos_align[symbol], , - rep0 += 1, SEQ_ALIGN0); - case SEQ_ALIGN1: - rc_bit(coder->pos_align[symbol], , - rep0 += 2, SEQ_ALIGN1); - case SEQ_ALIGN2: - rc_bit(coder->pos_align[symbol], , - rep0 += 4, SEQ_ALIGN2); - case SEQ_ALIGN3: - // Like in SEQ_POS_MODEL, we don't - // need "symbol" for anything else - // than indexing the probability array. - rc_bit_last(coder->pos_align[symbol], , - rep0 += 8, SEQ_ALIGN3); -#endif - - if (rep0 == UINT32_MAX) { - // End of payload marker was - // found. It must not be - // present if uncompressed - // size is known. - if (coder->uncompressed_size - != LZMA_VLI_UNKNOWN) { - ret = LZMA_DATA_ERROR; - goto out; - } - - case SEQ_EOPM: - // LZMA1 stream with - // end-of-payload marker. - rc_normalize(SEQ_EOPM); - ret = LZMA_STREAM_END; - goto out; - } - } - } - - // Validate the distance we just decoded. - if (unlikely(!dict_is_distance_valid(&dict, rep0))) { - ret = LZMA_DATA_ERROR; - goto out; - } - - } else { - rc_update_1(coder->is_rep[state]); - - // Repeated match - // - // The match distance is a value that we have had - // earlier. The latest four match distances are - // available as rep0, rep1, rep2 and rep3. We will - // now decode which of them is the new distance. - // - // There cannot be a match if we haven't produced - // any output, so check that first. - if (unlikely(!dict_is_distance_valid(&dict, 0))) { - ret = LZMA_DATA_ERROR; - goto out; - } - - case SEQ_IS_REP0: - rc_if_0(coder->is_rep0[state], SEQ_IS_REP0) { - rc_update_0(coder->is_rep0[state]); - // The distance is rep0. - - case SEQ_IS_REP0_LONG: - rc_if_0(coder->is_rep0_long[state][pos_state], - SEQ_IS_REP0_LONG) { - rc_update_0(coder->is_rep0_long[ - state][pos_state]); - - update_short_rep(state); - - case SEQ_SHORTREP: - if (unlikely(dict_put(&dict, dict_get( - &dict, rep0)))) { - coder->sequence = SEQ_SHORTREP; - goto out; - } - - continue; - } - - // Repeating more than one byte at - // distance of rep0. - rc_update_1(coder->is_rep0_long[ - state][pos_state]); - - } else { - rc_update_1(coder->is_rep0[state]); - - case SEQ_IS_REP1: - // The distance is rep1, rep2 or rep3. Once - // we find out which one of these three, it - // is stored to rep0 and rep1, rep2 and rep3 - // are updated accordingly. - rc_if_0(coder->is_rep1[state], SEQ_IS_REP1) { - rc_update_0(coder->is_rep1[state]); - - const uint32_t distance = rep1; - rep1 = rep0; - rep0 = distance; - - } else { - rc_update_1(coder->is_rep1[state]); - case SEQ_IS_REP2: - rc_if_0(coder->is_rep2[state], - SEQ_IS_REP2) { - rc_update_0(coder->is_rep2[ - state]); - - const uint32_t distance = rep2; - rep2 = rep1; - rep1 = rep0; - rep0 = distance; - - } else { - rc_update_1(coder->is_rep2[ - state]); - - const uint32_t distance = rep3; - rep3 = rep2; - rep2 = rep1; - rep1 = rep0; - rep0 = distance; - } - } - } - - update_long_rep(state); - - // Decode the length of the repeated match. - len_decode(len, coder->rep_len_decoder, - pos_state, SEQ_REP_LEN); - } - - ///////////////////////////////// - // Repeat from history buffer. // - ///////////////////////////////// - - // The length is always between these limits. There is no way - // to trigger the algorithm to set len outside this range. - assert(len >= MATCH_LEN_MIN); - assert(len <= MATCH_LEN_MAX); - - case SEQ_COPY: - // Repeat len bytes from distance of rep0. - if (unlikely(dict_repeat(&dict, rep0, &len))) { - coder->sequence = SEQ_COPY; - goto out; - } - } - - rc_normalize(SEQ_NORMALIZE); - coder->sequence = SEQ_IS_MATCH; - -out: - // Save state - - // NOTE: Must not copy dict.limit. - dictptr->pos = dict.pos; - dictptr->full = dict.full; - - rc_from_local(coder->rc, *in_pos); - - coder->state = state; - coder->rep0 = rep0; - coder->rep1 = rep1; - coder->rep2 = rep2; - coder->rep3 = rep3; - - coder->probs = probs; - coder->symbol = symbol; - coder->limit = limit; - coder->offset = offset; - coder->len = len; - - // Update the remaining amount of uncompressed data if uncompressed - // size was known. - if (coder->uncompressed_size != LZMA_VLI_UNKNOWN) { - coder->uncompressed_size -= dict.pos - dict_start; - - // Since there cannot be end of payload marker if the - // uncompressed size was known, we check here if we - // finished decoding. - if (coder->uncompressed_size == 0 && ret == LZMA_OK - && coder->sequence != SEQ_NORMALIZE) - ret = coder->sequence == SEQ_IS_MATCH - ? LZMA_STREAM_END : LZMA_DATA_ERROR; - } - - // We can do an additional check in the range decoder to catch some - // corrupted files. - if (ret == LZMA_STREAM_END) { - if (!rc_is_finished(coder->rc)) - ret = LZMA_DATA_ERROR; - - // Reset the range decoder so that it is ready to reinitialize - // for a new LZMA2 chunk. - rc_reset(coder->rc); - } - - return ret; -} - - - -static void -lzma_decoder_uncompressed(lzma_coder *coder, lzma_vli uncompressed_size) -{ - coder->uncompressed_size = uncompressed_size; -} - -/* -extern void -lzma_lzma_decoder_uncompressed(void *coder_ptr, lzma_vli uncompressed_size) -{ - // This is hack. - (*(lzma_coder **)(coder))->uncompressed_size = uncompressed_size; -} -*/ - -static void -lzma_decoder_reset(lzma_coder *coder, const void *opt) -{ - const lzma_options_lzma *options = opt; - - // NOTE: We assume that lc/lp/pb are valid since they were - // successfully decoded with lzma_lzma_decode_properties(). - - // Calculate pos_mask. We don't need pos_bits as is for anything. - coder->pos_mask = (1U << options->pb) - 1; - - // Initialize the literal decoder. - literal_init(coder->literal, options->lc, options->lp); - - coder->literal_context_bits = options->lc; - coder->literal_pos_mask = (1U << options->lp) - 1; - - // State - coder->state = STATE_LIT_LIT; - coder->rep0 = 0; - coder->rep1 = 0; - coder->rep2 = 0; - coder->rep3 = 0; - coder->pos_mask = (1U << options->pb) - 1; - - // Range decoder - rc_reset(coder->rc); - - // Bit and bittree decoders - for (uint32_t i = 0; i < STATES; ++i) { - for (uint32_t j = 0; j <= coder->pos_mask; ++j) { - bit_reset(coder->is_match[i][j]); - bit_reset(coder->is_rep0_long[i][j]); - } - - bit_reset(coder->is_rep[i]); - bit_reset(coder->is_rep0[i]); - bit_reset(coder->is_rep1[i]); - bit_reset(coder->is_rep2[i]); - } - - for (uint32_t i = 0; i < LEN_TO_POS_STATES; ++i) - bittree_reset(coder->pos_slot[i], POS_SLOT_BITS); - - for (uint32_t i = 0; i < FULL_DISTANCES - END_POS_MODEL_INDEX; ++i) - bit_reset(coder->pos_special[i]); - - bittree_reset(coder->pos_align, ALIGN_BITS); - - // Len decoders (also bit/bittree) - const uint32_t num_pos_states = 1U << options->pb; - bit_reset(coder->match_len_decoder.choice); - bit_reset(coder->match_len_decoder.choice2); - bit_reset(coder->rep_len_decoder.choice); - bit_reset(coder->rep_len_decoder.choice2); - - for (uint32_t pos_state = 0; pos_state < num_pos_states; ++pos_state) { - bittree_reset(coder->match_len_decoder.low[pos_state], - LEN_LOW_BITS); - bittree_reset(coder->match_len_decoder.mid[pos_state], - LEN_MID_BITS); - - bittree_reset(coder->rep_len_decoder.low[pos_state], - LEN_LOW_BITS); - bittree_reset(coder->rep_len_decoder.mid[pos_state], - LEN_MID_BITS); - } - - bittree_reset(coder->match_len_decoder.high, LEN_HIGH_BITS); - bittree_reset(coder->rep_len_decoder.high, LEN_HIGH_BITS); - - coder->sequence = SEQ_IS_MATCH; - coder->probs = NULL; - coder->symbol = 0; - coder->limit = 0; - coder->offset = 0; - coder->len = 0; - - return; -} - - -extern lzma_ret -lzma_lzma_decoder_create(lzma_lz_decoder *lz, lzma_allocator *allocator, - const void *opt, lzma_lz_options *lz_options) -{ - if (lz->coder == NULL) { - lz->coder = lzma_alloc(sizeof(lzma_coder), allocator); - if (lz->coder == NULL) - return LZMA_MEM_ERROR; - - lz->code = &lzma_decode; - lz->reset = &lzma_decoder_reset; - lz->set_uncompressed = &lzma_decoder_uncompressed; - } - - // All dictionary sizes are OK here. LZ decoder will take care of - // the special cases. - const lzma_options_lzma *options = opt; - lz_options->dict_size = options->dict_size; - lz_options->preset_dict = options->preset_dict; - lz_options->preset_dict_size = options->preset_dict_size; - - return LZMA_OK; -} - - -/// Allocate and initialize LZMA decoder. This is used only via LZ -/// initialization (lzma_lzma_decoder_init() passes function pointer to -/// the LZ initialization). -static lzma_ret -lzma_decoder_init(lzma_lz_decoder *lz, lzma_allocator *allocator, - const void *options, lzma_lz_options *lz_options) -{ - if (!is_lclppb_valid(options)) - return LZMA_PROG_ERROR; - - return_if_error(lzma_lzma_decoder_create( - lz, allocator, options, lz_options)); - - lzma_decoder_reset(lz->coder, options); - lzma_decoder_uncompressed(lz->coder, LZMA_VLI_UNKNOWN); - - return LZMA_OK; -} - - -extern lzma_ret -lzma_lzma_decoder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters) -{ - // LZMA can only be the last filter in the chain. This is enforced - // by the raw_decoder initialization. - assert(filters[1].init == NULL); - - return lzma_lz_decoder_init(next, allocator, filters, - &lzma_decoder_init); -} - - -extern bool -lzma_lzma_lclppb_decode(lzma_options_lzma *options, uint8_t byte) -{ - if (byte > (4 * 5 + 4) * 9 + 8) - return true; - - // See the file format specification to understand this. - options->pb = byte / (9 * 5); - byte -= options->pb * 9 * 5; - options->lp = byte / 9; - options->lc = byte - options->lp * 9; - - return options->lc + options->lp > LZMA_LCLP_MAX; -} - - -extern uint64_t -lzma_lzma_decoder_memusage_nocheck(const void *options) -{ - const lzma_options_lzma *const opt = options; - return sizeof(lzma_coder) + lzma_lz_decoder_memusage(opt->dict_size); -} - - -extern uint64_t -lzma_lzma_decoder_memusage(const void *options) -{ - if (!is_lclppb_valid(options)) - return UINT64_MAX; - - return lzma_lzma_decoder_memusage_nocheck(options); -} - - -extern lzma_ret -lzma_lzma_props_decode(void **options, lzma_allocator *allocator, - const uint8_t *props, size_t props_size) -{ - if (props_size != 5) - return LZMA_OPTIONS_ERROR; - - lzma_options_lzma *opt - = lzma_alloc(sizeof(lzma_options_lzma), allocator); - if (opt == NULL) - return LZMA_MEM_ERROR; - - if (lzma_lzma_lclppb_decode(opt, props[0])) - goto error; - - // All dictionary sizes are accepted, including zero. LZ decoder - // will automatically use a dictionary at least a few KiB even if - // a smaller dictionary is requested. - opt->dict_size = unaligned_read32le(props + 1); - - opt->preset_dict = NULL; - opt->preset_dict_size = 0; - - *options = opt; - - return LZMA_OK; - -error: - lzma_free(opt, allocator); - return LZMA_OPTIONS_ERROR; -} diff --git a/deps/lzma/liblzma/lzma/lzma_decoder.h b/deps/lzma/liblzma/lzma/lzma_decoder.h deleted file mode 100644 index a463a76..0000000 --- a/deps/lzma/liblzma/lzma/lzma_decoder.h +++ /dev/null @@ -1,52 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file lzma_decoder.h -/// \brief LZMA decoder API -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_LZMA_DECODER_H -#define LZMA_LZMA_DECODER_H - -#include "common.h" - - -/// Allocates and initializes LZMA decoder -extern lzma_ret lzma_lzma_decoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters); - -extern uint64_t lzma_lzma_decoder_memusage(const void *options); - -extern lzma_ret lzma_lzma_props_decode( - void **options, lzma_allocator *allocator, - const uint8_t *props, size_t props_size); - - -/// \brief Decodes the LZMA Properties byte (lc/lp/pb) -/// -/// \return true if error occurred, false on success -/// -extern bool lzma_lzma_lclppb_decode( - lzma_options_lzma *options, uint8_t byte); - - -#ifdef LZMA_LZ_DECODER_H -/// Allocate and setup function pointers only. This is used by LZMA1 and -/// LZMA2 decoders. -extern lzma_ret lzma_lzma_decoder_create( - lzma_lz_decoder *lz, lzma_allocator *allocator, - const void *opt, lzma_lz_options *lz_options); - -/// Gets memory usage without validating lc/lp/pb. This is used by LZMA2 -/// decoder, because raw LZMA2 decoding doesn't need lc/lp/pb. -extern uint64_t lzma_lzma_decoder_memusage_nocheck(const void *options); - -#endif - -#endif diff --git a/deps/lzma/liblzma/lzma/lzma_encoder.c b/deps/lzma/liblzma/lzma/lzma_encoder.c deleted file mode 100644 index 0b9ee9e..0000000 --- a/deps/lzma/liblzma/lzma/lzma_encoder.c +++ /dev/null @@ -1,675 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file lzma_encoder.c -/// \brief LZMA encoder -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "lzma2_encoder.h" -#include "lzma_encoder_private.h" -#include "fastpos.h" - - -///////////// -// Literal // -///////////// - -static inline void -literal_matched(lzma_range_encoder *rc, probability *subcoder, - uint32_t match_byte, uint32_t symbol) -{ - uint32_t offset = 0x100; - symbol += UINT32_C(1) << 8; - - do { - match_byte <<= 1; - const uint32_t match_bit = match_byte & offset; - const uint32_t subcoder_index - = offset + match_bit + (symbol >> 8); - const uint32_t bit = (symbol >> 7) & 1; - rc_bit(rc, &subcoder[subcoder_index], bit); - - symbol <<= 1; - offset &= ~(match_byte ^ symbol); - - } while (symbol < (UINT32_C(1) << 16)); -} - - -static inline void -literal(lzma_coder *coder, lzma_mf *mf, uint32_t position) -{ - // Locate the literal byte to be encoded and the subcoder. - const uint8_t cur_byte = mf->buffer[ - mf->read_pos - mf->read_ahead]; - probability *subcoder = literal_subcoder(coder->literal, - coder->literal_context_bits, coder->literal_pos_mask, - position, mf->buffer[mf->read_pos - mf->read_ahead - 1]); - - if (is_literal_state(coder->state)) { - // Previous LZMA-symbol was a literal. Encode a normal - // literal without a match byte. - rc_bittree(&coder->rc, subcoder, 8, cur_byte); - } else { - // Previous LZMA-symbol was a match. Use the last byte of - // the match as a "match byte". That is, compare the bits - // of the current literal and the match byte. - const uint8_t match_byte = mf->buffer[ - mf->read_pos - coder->reps[0] - 1 - - mf->read_ahead]; - literal_matched(&coder->rc, subcoder, match_byte, cur_byte); - } - - update_literal(coder->state); -} - - -////////////////// -// Match length // -////////////////// - -static void -length_update_prices(lzma_length_encoder *lc, const uint32_t pos_state) -{ - const uint32_t table_size = lc->table_size; - lc->counters[pos_state] = table_size; - - const uint32_t a0 = rc_bit_0_price(lc->choice); - const uint32_t a1 = rc_bit_1_price(lc->choice); - const uint32_t b0 = a1 + rc_bit_0_price(lc->choice2); - const uint32_t b1 = a1 + rc_bit_1_price(lc->choice2); - uint32_t *const prices = lc->prices[pos_state]; - - uint32_t i; - for (i = 0; i < table_size && i < LEN_LOW_SYMBOLS; ++i) - prices[i] = a0 + rc_bittree_price(lc->low[pos_state], - LEN_LOW_BITS, i); - - for (; i < table_size && i < LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS; ++i) - prices[i] = b0 + rc_bittree_price(lc->mid[pos_state], - LEN_MID_BITS, i - LEN_LOW_SYMBOLS); - - for (; i < table_size; ++i) - prices[i] = b1 + rc_bittree_price(lc->high, LEN_HIGH_BITS, - i - LEN_LOW_SYMBOLS - LEN_MID_SYMBOLS); - - return; -} - - -static inline void -length(lzma_range_encoder *rc, lzma_length_encoder *lc, - const uint32_t pos_state, uint32_t len, const bool fast_mode) -{ - assert(len <= MATCH_LEN_MAX); - len -= MATCH_LEN_MIN; - - if (len < LEN_LOW_SYMBOLS) { - rc_bit(rc, &lc->choice, 0); - rc_bittree(rc, lc->low[pos_state], LEN_LOW_BITS, len); - } else { - rc_bit(rc, &lc->choice, 1); - len -= LEN_LOW_SYMBOLS; - - if (len < LEN_MID_SYMBOLS) { - rc_bit(rc, &lc->choice2, 0); - rc_bittree(rc, lc->mid[pos_state], LEN_MID_BITS, len); - } else { - rc_bit(rc, &lc->choice2, 1); - len -= LEN_MID_SYMBOLS; - rc_bittree(rc, lc->high, LEN_HIGH_BITS, len); - } - } - - // Only getoptimum uses the prices so don't update the table when - // in fast mode. - if (!fast_mode) - if (--lc->counters[pos_state] == 0) - length_update_prices(lc, pos_state); -} - - -/////////// -// Match // -/////////// - -static inline void -match(lzma_coder *coder, const uint32_t pos_state, - const uint32_t distance, const uint32_t len) -{ - update_match(coder->state); - - length(&coder->rc, &coder->match_len_encoder, pos_state, len, - coder->fast_mode); - - const uint32_t pos_slot = get_pos_slot(distance); - const uint32_t len_to_pos_state = get_len_to_pos_state(len); - rc_bittree(&coder->rc, coder->pos_slot[len_to_pos_state], - POS_SLOT_BITS, pos_slot); - - if (pos_slot >= START_POS_MODEL_INDEX) { - const uint32_t footer_bits = (pos_slot >> 1) - 1; - const uint32_t base = (2 | (pos_slot & 1)) << footer_bits; - const uint32_t pos_reduced = distance - base; - - if (pos_slot < END_POS_MODEL_INDEX) { - // Careful here: base - pos_slot - 1 can be -1, but - // rc_bittree_reverse starts at probs[1], not probs[0]. - rc_bittree_reverse(&coder->rc, - coder->pos_special + base - pos_slot - 1, - footer_bits, pos_reduced); - } else { - rc_direct(&coder->rc, pos_reduced >> ALIGN_BITS, - footer_bits - ALIGN_BITS); - rc_bittree_reverse( - &coder->rc, coder->pos_align, - ALIGN_BITS, pos_reduced & ALIGN_MASK); - ++coder->align_price_count; - } - } - - coder->reps[3] = coder->reps[2]; - coder->reps[2] = coder->reps[1]; - coder->reps[1] = coder->reps[0]; - coder->reps[0] = distance; - ++coder->match_price_count; -} - - -//////////////////// -// Repeated match // -//////////////////// - -static inline void -rep_match(lzma_coder *coder, const uint32_t pos_state, - const uint32_t rep, const uint32_t len) -{ - if (rep == 0) { - rc_bit(&coder->rc, &coder->is_rep0[coder->state], 0); - rc_bit(&coder->rc, - &coder->is_rep0_long[coder->state][pos_state], - len != 1); - } else { - const uint32_t distance = coder->reps[rep]; - rc_bit(&coder->rc, &coder->is_rep0[coder->state], 1); - - if (rep == 1) { - rc_bit(&coder->rc, &coder->is_rep1[coder->state], 0); - } else { - rc_bit(&coder->rc, &coder->is_rep1[coder->state], 1); - rc_bit(&coder->rc, &coder->is_rep2[coder->state], - rep - 2); - - if (rep == 3) - coder->reps[3] = coder->reps[2]; - - coder->reps[2] = coder->reps[1]; - } - - coder->reps[1] = coder->reps[0]; - coder->reps[0] = distance; - } - - if (len == 1) { - update_short_rep(coder->state); - } else { - length(&coder->rc, &coder->rep_len_encoder, pos_state, len, - coder->fast_mode); - update_long_rep(coder->state); - } -} - - -////////// -// Main // -////////// - -static void -encode_symbol(lzma_coder *coder, lzma_mf *mf, - uint32_t back, uint32_t len, uint32_t position) -{ - const uint32_t pos_state = position & coder->pos_mask; - - if (back == UINT32_MAX) { - // Literal i.e. eight-bit byte - assert(len == 1); - rc_bit(&coder->rc, - &coder->is_match[coder->state][pos_state], 0); - literal(coder, mf, position); - } else { - // Some type of match - rc_bit(&coder->rc, - &coder->is_match[coder->state][pos_state], 1); - - if (back < REP_DISTANCES) { - // It's a repeated match i.e. the same distance - // has been used earlier. - rc_bit(&coder->rc, &coder->is_rep[coder->state], 1); - rep_match(coder, pos_state, back, len); - } else { - // Normal match - rc_bit(&coder->rc, &coder->is_rep[coder->state], 0); - match(coder, pos_state, back - REP_DISTANCES, len); - } - } - - assert(mf->read_ahead >= len); - mf->read_ahead -= len; -} - - -static bool -encode_init(lzma_coder *coder, lzma_mf *mf) -{ - assert(mf_position(mf) == 0); - - if (mf->read_pos == mf->read_limit) { - if (mf->action == LZMA_RUN) - return false; // We cannot do anything. - - // We are finishing (we cannot get here when flushing). - assert(mf->write_pos == mf->read_pos); - assert(mf->action == LZMA_FINISH); - } else { - // Do the actual initialization. The first LZMA symbol must - // always be a literal. - mf_skip(mf, 1); - mf->read_ahead = 0; - rc_bit(&coder->rc, &coder->is_match[0][0], 0); - rc_bittree(&coder->rc, coder->literal[0], 8, mf->buffer[0]); - } - - // Initialization is done (except if empty file). - coder->is_initialized = true; - - return true; -} - - -static void -encode_eopm(lzma_coder *coder, uint32_t position) -{ - const uint32_t pos_state = position & coder->pos_mask; - rc_bit(&coder->rc, &coder->is_match[coder->state][pos_state], 1); - rc_bit(&coder->rc, &coder->is_rep[coder->state], 0); - match(coder, pos_state, UINT32_MAX, MATCH_LEN_MIN); -} - - -/// Number of bytes that a single encoding loop in lzma_lzma_encode() can -/// consume from the dictionary. This limit comes from lzma_lzma_optimum() -/// and may need to be updated if that function is significantly modified. -#define LOOP_INPUT_MAX (OPTS + 1) - - -extern lzma_ret -lzma_lzma_encode(lzma_coder *restrict coder, lzma_mf *restrict mf, - uint8_t *restrict out, size_t *restrict out_pos, - size_t out_size, uint32_t limit) -{ - // Initialize the stream if no data has been encoded yet. - if (!coder->is_initialized && !encode_init(coder, mf)) - return LZMA_OK; - - // Get the lowest bits of the uncompressed offset from the LZ layer. - uint32_t position = mf_position(mf); - - while (true) { - // Encode pending bits, if any. Calling this before encoding - // the next symbol is needed only with plain LZMA, since - // LZMA2 always provides big enough buffer to flush - // everything out from the range encoder. For the same reason, - // rc_encode() never returns true when this function is used - // as part of LZMA2 encoder. - if (rc_encode(&coder->rc, out, out_pos, out_size)) { - assert(limit == UINT32_MAX); - return LZMA_OK; - } - - // With LZMA2 we need to take care that compressed size of - // a chunk doesn't get too big. - // FIXME? Check if this could be improved. - if (limit != UINT32_MAX - && (mf->read_pos - mf->read_ahead >= limit - || *out_pos + rc_pending(&coder->rc) - >= LZMA2_CHUNK_MAX - - LOOP_INPUT_MAX)) - break; - - // Check that there is some input to process. - if (mf->read_pos >= mf->read_limit) { - if (mf->action == LZMA_RUN) - return LZMA_OK; - - if (mf->read_ahead == 0) - break; - } - - // Get optimal match (repeat position and length). - // Value ranges for pos: - // - [0, REP_DISTANCES): repeated match - // - [REP_DISTANCES, UINT32_MAX): - // match at (pos - REP_DISTANCES) - // - UINT32_MAX: not a match but a literal - // Value ranges for len: - // - [MATCH_LEN_MIN, MATCH_LEN_MAX] - uint32_t len; - uint32_t back; - - if (coder->fast_mode) - lzma_lzma_optimum_fast(coder, mf, &back, &len); - else - lzma_lzma_optimum_normal( - coder, mf, &back, &len, position); - - encode_symbol(coder, mf, back, len, position); - - position += len; - } - - if (!coder->is_flushed) { - coder->is_flushed = true; - - // We don't support encoding plain LZMA streams without EOPM, - // and LZMA2 doesn't use EOPM at LZMA level. - if (limit == UINT32_MAX) - encode_eopm(coder, position); - - // Flush the remaining bytes from the range encoder. - rc_flush(&coder->rc); - - // Copy the remaining bytes to the output buffer. If there - // isn't enough output space, we will copy out the remaining - // bytes on the next call to this function by using - // the rc_encode() call in the encoding loop above. - if (rc_encode(&coder->rc, out, out_pos, out_size)) { - assert(limit == UINT32_MAX); - return LZMA_OK; - } - } - - // Make it ready for the next LZMA2 chunk. - coder->is_flushed = false; - - return LZMA_STREAM_END; -} - - -static lzma_ret -lzma_encode(lzma_coder *restrict coder, lzma_mf *restrict mf, - uint8_t *restrict out, size_t *restrict out_pos, - size_t out_size) -{ - // Plain LZMA has no support for sync-flushing. - if (unlikely(mf->action == LZMA_SYNC_FLUSH)) - return LZMA_OPTIONS_ERROR; - - return lzma_lzma_encode(coder, mf, out, out_pos, out_size, UINT32_MAX); -} - - -//////////////////// -// Initialization // -//////////////////// - -static bool -is_options_valid(const lzma_options_lzma *options) -{ - // Validate some of the options. LZ encoder validates nice_len too - // but we need a valid value here earlier. - return is_lclppb_valid(options) - && options->nice_len >= MATCH_LEN_MIN - && options->nice_len <= MATCH_LEN_MAX - && (options->mode == LZMA_MODE_FAST - || options->mode == LZMA_MODE_NORMAL); -} - - -static void -set_lz_options(lzma_lz_options *lz_options, const lzma_options_lzma *options) -{ - // LZ encoder initialization does the validation for these so we - // don't need to validate here. - lz_options->before_size = OPTS; - lz_options->dict_size = options->dict_size; - lz_options->after_size = LOOP_INPUT_MAX; - lz_options->match_len_max = MATCH_LEN_MAX; - lz_options->nice_len = options->nice_len; - lz_options->match_finder = options->mf; - lz_options->depth = options->depth; - lz_options->preset_dict = options->preset_dict; - lz_options->preset_dict_size = options->preset_dict_size; - return; -} - - -static void -length_encoder_reset(lzma_length_encoder *lencoder, - const uint32_t num_pos_states, const bool fast_mode) -{ - bit_reset(lencoder->choice); - bit_reset(lencoder->choice2); - - for (size_t pos_state = 0; pos_state < num_pos_states; ++pos_state) { - bittree_reset(lencoder->low[pos_state], LEN_LOW_BITS); - bittree_reset(lencoder->mid[pos_state], LEN_MID_BITS); - } - - bittree_reset(lencoder->high, LEN_HIGH_BITS); - - if (!fast_mode) - for (size_t pos_state = 0; pos_state < num_pos_states; - ++pos_state) - length_update_prices(lencoder, pos_state); - - return; -} - - -extern lzma_ret -lzma_lzma_encoder_reset(lzma_coder *coder, const lzma_options_lzma *options) -{ - if (!is_options_valid(options)) - return LZMA_OPTIONS_ERROR; - - coder->pos_mask = (1U << options->pb) - 1; - coder->literal_context_bits = options->lc; - coder->literal_pos_mask = (1U << options->lp) - 1; - - // Range coder - rc_reset(&coder->rc); - - // State - coder->state = STATE_LIT_LIT; - for (size_t i = 0; i < REP_DISTANCES; ++i) - coder->reps[i] = 0; - - literal_init(coder->literal, options->lc, options->lp); - - // Bit encoders - for (size_t i = 0; i < STATES; ++i) { - for (size_t j = 0; j <= coder->pos_mask; ++j) { - bit_reset(coder->is_match[i][j]); - bit_reset(coder->is_rep0_long[i][j]); - } - - bit_reset(coder->is_rep[i]); - bit_reset(coder->is_rep0[i]); - bit_reset(coder->is_rep1[i]); - bit_reset(coder->is_rep2[i]); - } - - for (size_t i = 0; i < FULL_DISTANCES - END_POS_MODEL_INDEX; ++i) - bit_reset(coder->pos_special[i]); - - // Bit tree encoders - for (size_t i = 0; i < LEN_TO_POS_STATES; ++i) - bittree_reset(coder->pos_slot[i], POS_SLOT_BITS); - - bittree_reset(coder->pos_align, ALIGN_BITS); - - // Length encoders - length_encoder_reset(&coder->match_len_encoder, - 1U << options->pb, coder->fast_mode); - - length_encoder_reset(&coder->rep_len_encoder, - 1U << options->pb, coder->fast_mode); - - // Price counts are incremented every time appropriate probabilities - // are changed. price counts are set to zero when the price tables - // are updated, which is done when the appropriate price counts have - // big enough value, and lzma_mf.read_ahead == 0 which happens at - // least every OPTS (a few thousand) possible price count increments. - // - // By resetting price counts to UINT32_MAX / 2, we make sure that the - // price tables will be initialized before they will be used (since - // the value is definitely big enough), and that it is OK to increment - // price counts without risk of integer overflow (since UINT32_MAX / 2 - // is small enough). The current code doesn't increment price counts - // before initializing price tables, but it maybe done in future if - // we add support for saving the state between LZMA2 chunks. - coder->match_price_count = UINT32_MAX / 2; - coder->align_price_count = UINT32_MAX / 2; - - coder->opts_end_index = 0; - coder->opts_current_index = 0; - - return LZMA_OK; -} - - -extern lzma_ret -lzma_lzma_encoder_create(lzma_coder **coder_ptr, lzma_allocator *allocator, - const lzma_options_lzma *options, lzma_lz_options *lz_options) -{ - // Allocate lzma_coder if it wasn't already allocated. - if (*coder_ptr == NULL) { - *coder_ptr = lzma_alloc(sizeof(lzma_coder), allocator); - if (*coder_ptr == NULL) - return LZMA_MEM_ERROR; - } - - lzma_coder *coder = *coder_ptr; - - // Set compression mode. We haven't validates the options yet, - // but it's OK here, since nothing bad happens with invalid - // options in the code below, and they will get rejected by - // lzma_lzma_encoder_reset() call at the end of this function. - switch (options->mode) { - case LZMA_MODE_FAST: - coder->fast_mode = true; - break; - - case LZMA_MODE_NORMAL: { - coder->fast_mode = false; - - // Set dist_table_size. - // Round the dictionary size up to next 2^n. - uint32_t log_size = 0; - while ((UINT32_C(1) << log_size) < options->dict_size) - ++log_size; - - coder->dist_table_size = log_size * 2; - - // Length encoders' price table size - coder->match_len_encoder.table_size - = options->nice_len + 1 - MATCH_LEN_MIN; - coder->rep_len_encoder.table_size - = options->nice_len + 1 - MATCH_LEN_MIN; - break; - } - - default: - return LZMA_OPTIONS_ERROR; - } - - // We don't need to write the first byte as literal if there is - // a non-empty preset dictionary. encode_init() wouldn't even work - // if there is a non-empty preset dictionary, because encode_init() - // assumes that position is zero and previous byte is also zero. - coder->is_initialized = options->preset_dict != NULL - && options->preset_dict_size > 0; - coder->is_flushed = false; - - set_lz_options(lz_options, options); - - return lzma_lzma_encoder_reset(coder, options); -} - - -static lzma_ret -lzma_encoder_init(lzma_lz_encoder *lz, lzma_allocator *allocator, - const void *options, lzma_lz_options *lz_options) -{ - lz->code = &lzma_encode; - return lzma_lzma_encoder_create( - &lz->coder, allocator, options, lz_options); -} - - -extern lzma_ret -lzma_lzma_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters) -{ - return lzma_lz_encoder_init( - next, allocator, filters, &lzma_encoder_init); -} - - -extern uint64_t -lzma_lzma_encoder_memusage(const void *options) -{ - if (!is_options_valid(options)) - return UINT64_MAX; - - lzma_lz_options lz_options; - set_lz_options(&lz_options, options); - - const uint64_t lz_memusage = lzma_lz_encoder_memusage(&lz_options); - if (lz_memusage == UINT64_MAX) - return UINT64_MAX; - - return (uint64_t)(sizeof(lzma_coder)) + lz_memusage; -} - - -extern bool -lzma_lzma_lclppb_encode(const lzma_options_lzma *options, uint8_t *byte) -{ - if (!is_lclppb_valid(options)) - return true; - - *byte = (options->pb * 5 + options->lp) * 9 + options->lc; - assert(*byte <= (4 * 5 + 4) * 9 + 8); - - return false; -} - - -#ifdef HAVE_ENCODER_LZMA1 -extern lzma_ret -lzma_lzma_props_encode(const void *options, uint8_t *out) -{ - const lzma_options_lzma *const opt = options; - - if (lzma_lzma_lclppb_encode(opt, out)) - return LZMA_PROG_ERROR; - - unaligned_write32le(out + 1, opt->dict_size); - - return LZMA_OK; -} -#endif - - -extern LZMA_API(lzma_bool) -lzma_mode_is_supported(lzma_mode mode) -{ - return mode == LZMA_MODE_FAST || mode == LZMA_MODE_NORMAL; -} diff --git a/deps/lzma/liblzma/lzma/lzma_encoder.h b/deps/lzma/liblzma/lzma/lzma_encoder.h deleted file mode 100644 index 835e1f5..0000000 --- a/deps/lzma/liblzma/lzma/lzma_encoder.h +++ /dev/null @@ -1,54 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file lzma_encoder.h -/// \brief LZMA encoder API -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_LZMA_ENCODER_H -#define LZMA_LZMA_ENCODER_H - -#include "common.h" - - -extern lzma_ret lzma_lzma_encoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters); - - -extern uint64_t lzma_lzma_encoder_memusage(const void *options); - -extern lzma_ret lzma_lzma_props_encode(const void *options, uint8_t *out); - - -/// Encodes lc/lp/pb into one byte. Returns false on success and true on error. -extern bool lzma_lzma_lclppb_encode( - const lzma_options_lzma *options, uint8_t *byte); - - -#ifdef LZMA_LZ_ENCODER_H - -/// Initializes raw LZMA encoder; this is used by LZMA2. -extern lzma_ret lzma_lzma_encoder_create( - lzma_coder **coder_ptr, lzma_allocator *allocator, - const lzma_options_lzma *options, lzma_lz_options *lz_options); - - -/// Resets an already initialized LZMA encoder; this is used by LZMA2. -extern lzma_ret lzma_lzma_encoder_reset( - lzma_coder *coder, const lzma_options_lzma *options); - - -extern lzma_ret lzma_lzma_encode(lzma_coder *restrict coder, - lzma_mf *restrict mf, uint8_t *restrict out, - size_t *restrict out_pos, size_t out_size, - uint32_t read_limit); - -#endif - -#endif diff --git a/deps/lzma/liblzma/lzma/lzma_encoder_optimum_fast.c b/deps/lzma/liblzma/lzma/lzma_encoder_optimum_fast.c deleted file mode 100644 index f835f69..0000000 --- a/deps/lzma/liblzma/lzma/lzma_encoder_optimum_fast.c +++ /dev/null @@ -1,179 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file lzma_encoder_optimum_fast.c -// -// Author: Igor Pavlov -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "lzma_encoder_private.h" - - -#define change_pair(small_dist, big_dist) \ - (((big_dist) >> 7) > (small_dist)) - - -extern void -lzma_lzma_optimum_fast(lzma_coder *restrict coder, lzma_mf *restrict mf, - uint32_t *restrict back_res, uint32_t *restrict len_res) -{ - const uint32_t nice_len = mf->nice_len; - - uint32_t len_main; - uint32_t matches_count; - if (mf->read_ahead == 0) { - len_main = mf_find(mf, &matches_count, coder->matches); - } else { - assert(mf->read_ahead == 1); - len_main = coder->longest_match_length; - matches_count = coder->matches_count; - } - - const uint8_t *buf = mf_ptr(mf) - 1; - const uint32_t buf_avail = my_min(mf_avail(mf) + 1, MATCH_LEN_MAX); - - if (buf_avail < 2) { - // There's not enough input left to encode a match. - *back_res = UINT32_MAX; - *len_res = 1; - return; - } - - // Look for repeated matches; scan the previous four match distances - uint32_t rep_len = 0; - uint32_t rep_index = 0; - - for (uint32_t i = 0; i < REP_DISTANCES; ++i) { - // Pointer to the beginning of the match candidate - const uint8_t *const buf_back = buf - coder->reps[i] - 1; - - // If the first two bytes (2 == MATCH_LEN_MIN) do not match, - // this rep is not useful. - if (not_equal_16(buf, buf_back)) - continue; - - // The first two bytes matched. - // Calculate the length of the match. - uint32_t len; - for (len = 2; len < buf_avail - && buf[len] == buf_back[len]; ++len) ; - - // If we have found a repeated match that is at least - // nice_len long, return it immediately. - if (len >= nice_len) { - *back_res = i; - *len_res = len; - mf_skip(mf, len - 1); - return; - } - - if (len > rep_len) { - rep_index = i; - rep_len = len; - } - } - - // We didn't find a long enough repeated match. Encode it as a normal - // match if the match length is at least nice_len. - if (len_main >= nice_len) { - *back_res = coder->matches[matches_count - 1].dist - + REP_DISTANCES; - *len_res = len_main; - mf_skip(mf, len_main - 1); - return; - } - - uint32_t back_main = 0; - if (len_main >= 2) { - back_main = coder->matches[matches_count - 1].dist; - - while (matches_count > 1 && len_main == - coder->matches[matches_count - 2].len + 1) { - if (!change_pair(coder->matches[ - matches_count - 2].dist, - back_main)) - break; - - --matches_count; - len_main = coder->matches[matches_count - 1].len; - back_main = coder->matches[matches_count - 1].dist; - } - - if (len_main == 2 && back_main >= 0x80) - len_main = 1; - } - - if (rep_len >= 2) { - if (rep_len + 1 >= len_main - || (rep_len + 2 >= len_main - && back_main > (UINT32_C(1) << 9)) - || (rep_len + 3 >= len_main - && back_main > (UINT32_C(1) << 15))) { - *back_res = rep_index; - *len_res = rep_len; - mf_skip(mf, rep_len - 1); - return; - } - } - - if (len_main < 2 || buf_avail <= 2) { - *back_res = UINT32_MAX; - *len_res = 1; - return; - } - - // Get the matches for the next byte. If we find a better match, - // the current byte is encoded as a literal. - coder->longest_match_length = mf_find(mf, - &coder->matches_count, coder->matches); - - if (coder->longest_match_length >= 2) { - const uint32_t new_dist = coder->matches[ - coder->matches_count - 1].dist; - - if ((coder->longest_match_length >= len_main - && new_dist < back_main) - || (coder->longest_match_length == len_main + 1 - && !change_pair(back_main, new_dist)) - || (coder->longest_match_length > len_main + 1) - || (coder->longest_match_length + 1 >= len_main - && len_main >= 3 - && change_pair(new_dist, back_main))) { - *back_res = UINT32_MAX; - *len_res = 1; - return; - } - } - - // In contrast to LZMA SDK, dictionary could not have been moved - // between mf_find() calls, thus it is safe to just increment - // the old buf pointer instead of recalculating it with mf_ptr(). - ++buf; - - const uint32_t limit = len_main - 1; - - for (uint32_t i = 0; i < REP_DISTANCES; ++i) { - const uint8_t *const buf_back = buf - coder->reps[i] - 1; - - if (not_equal_16(buf, buf_back)) - continue; - - uint32_t len; - for (len = 2; len < limit - && buf[len] == buf_back[len]; ++len) ; - - if (len >= limit) { - *back_res = UINT32_MAX; - *len_res = 1; - return; - } - } - - *back_res = back_main + REP_DISTANCES; - *len_res = len_main; - mf_skip(mf, len_main - 2); - return; -} diff --git a/deps/lzma/liblzma/lzma/lzma_encoder_optimum_normal.c b/deps/lzma/liblzma/lzma/lzma_encoder_optimum_normal.c deleted file mode 100644 index 7e85649..0000000 --- a/deps/lzma/liblzma/lzma/lzma_encoder_optimum_normal.c +++ /dev/null @@ -1,868 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file lzma_encoder_optimum_normal.c -// -// Author: Igor Pavlov -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "lzma_encoder_private.h" -#include "fastpos.h" - - -//////////// -// Prices // -//////////// - -static uint32_t -get_literal_price(const lzma_coder *const coder, const uint32_t pos, - const uint32_t prev_byte, const bool match_mode, - uint32_t match_byte, uint32_t symbol) -{ - const probability *const subcoder = literal_subcoder(coder->literal, - coder->literal_context_bits, coder->literal_pos_mask, - pos, prev_byte); - - uint32_t price = 0; - - if (!match_mode) { - price = rc_bittree_price(subcoder, 8, symbol); - } else { - uint32_t offset = 0x100; - symbol += UINT32_C(1) << 8; - - do { - match_byte <<= 1; - - const uint32_t match_bit = match_byte & offset; - const uint32_t subcoder_index - = offset + match_bit + (symbol >> 8); - const uint32_t bit = (symbol >> 7) & 1; - price += rc_bit_price(subcoder[subcoder_index], bit); - - symbol <<= 1; - offset &= ~(match_byte ^ symbol); - - } while (symbol < (UINT32_C(1) << 16)); - } - - return price; -} - - -static inline uint32_t -get_len_price(const lzma_length_encoder *const lencoder, - const uint32_t len, const uint32_t pos_state) -{ - // NOTE: Unlike the other price tables, length prices are updated - // in lzma_encoder.c - return lencoder->prices[pos_state][len - MATCH_LEN_MIN]; -} - - -static inline uint32_t -get_short_rep_price(const lzma_coder *const coder, - const lzma_lzma_state state, const uint32_t pos_state) -{ - return rc_bit_0_price(coder->is_rep0[state]) - + rc_bit_0_price(coder->is_rep0_long[state][pos_state]); -} - - -static inline uint32_t -get_pure_rep_price(const lzma_coder *const coder, const uint32_t rep_index, - const lzma_lzma_state state, uint32_t pos_state) -{ - uint32_t price; - - if (rep_index == 0) { - price = rc_bit_0_price(coder->is_rep0[state]); - price += rc_bit_1_price(coder->is_rep0_long[state][pos_state]); - } else { - price = rc_bit_1_price(coder->is_rep0[state]); - - if (rep_index == 1) { - price += rc_bit_0_price(coder->is_rep1[state]); - } else { - price += rc_bit_1_price(coder->is_rep1[state]); - price += rc_bit_price(coder->is_rep2[state], - rep_index - 2); - } - } - - return price; -} - - -static inline uint32_t -get_rep_price(const lzma_coder *const coder, const uint32_t rep_index, - const uint32_t len, const lzma_lzma_state state, - const uint32_t pos_state) -{ - return get_len_price(&coder->rep_len_encoder, len, pos_state) - + get_pure_rep_price(coder, rep_index, state, pos_state); -} - - -static inline uint32_t -get_pos_len_price(const lzma_coder *const coder, const uint32_t pos, - const uint32_t len, const uint32_t pos_state) -{ - const uint32_t len_to_pos_state = get_len_to_pos_state(len); - uint32_t price; - - if (pos < FULL_DISTANCES) { - price = coder->distances_prices[len_to_pos_state][pos]; - } else { - const uint32_t pos_slot = get_pos_slot_2(pos); - price = coder->pos_slot_prices[len_to_pos_state][pos_slot] - + coder->align_prices[pos & ALIGN_MASK]; - } - - price += get_len_price(&coder->match_len_encoder, len, pos_state); - - return price; -} - - -static void -fill_distances_prices(lzma_coder *coder) -{ - for (uint32_t len_to_pos_state = 0; - len_to_pos_state < LEN_TO_POS_STATES; - ++len_to_pos_state) { - - uint32_t *const pos_slot_prices - = coder->pos_slot_prices[len_to_pos_state]; - - // Price to encode the pos_slot. - for (uint32_t pos_slot = 0; - pos_slot < coder->dist_table_size; ++pos_slot) - pos_slot_prices[pos_slot] = rc_bittree_price( - coder->pos_slot[len_to_pos_state], - POS_SLOT_BITS, pos_slot); - - // For matches with distance >= FULL_DISTANCES, add the price - // of the direct bits part of the match distance. (Align bits - // are handled by fill_align_prices()). - for (uint32_t pos_slot = END_POS_MODEL_INDEX; - pos_slot < coder->dist_table_size; ++pos_slot) - pos_slot_prices[pos_slot] += rc_direct_price( - ((pos_slot >> 1) - 1) - ALIGN_BITS); - - // Distances in the range [0, 3] are fully encoded with - // pos_slot, so they are used for coder->distances_prices - // as is. - for (uint32_t i = 0; i < START_POS_MODEL_INDEX; ++i) - coder->distances_prices[len_to_pos_state][i] - = pos_slot_prices[i]; - } - - // Distances in the range [4, 127] depend on pos_slot and pos_special. - // We do this in a loop separate from the above loop to avoid - // redundant calls to get_pos_slot(). - for (uint32_t i = START_POS_MODEL_INDEX; i < FULL_DISTANCES; ++i) { - const uint32_t pos_slot = get_pos_slot(i); - const uint32_t footer_bits = ((pos_slot >> 1) - 1); - const uint32_t base = (2 | (pos_slot & 1)) << footer_bits; - const uint32_t price = rc_bittree_reverse_price( - coder->pos_special + base - pos_slot - 1, - footer_bits, i - base); - - for (uint32_t len_to_pos_state = 0; - len_to_pos_state < LEN_TO_POS_STATES; - ++len_to_pos_state) - coder->distances_prices[len_to_pos_state][i] - = price + coder->pos_slot_prices[ - len_to_pos_state][pos_slot]; - } - - coder->match_price_count = 0; - return; -} - - -static void -fill_align_prices(lzma_coder *coder) -{ - for (uint32_t i = 0; i < ALIGN_TABLE_SIZE; ++i) - coder->align_prices[i] = rc_bittree_reverse_price( - coder->pos_align, ALIGN_BITS, i); - - coder->align_price_count = 0; - return; -} - - -///////////// -// Optimal // -///////////// - -static inline void -make_literal(lzma_optimal *optimal) -{ - optimal->back_prev = UINT32_MAX; - optimal->prev_1_is_literal = false; -} - - -static inline void -make_short_rep(lzma_optimal *optimal) -{ - optimal->back_prev = 0; - optimal->prev_1_is_literal = false; -} - - -#define is_short_rep(optimal) \ - ((optimal).back_prev == 0) - - -static void -backward(lzma_coder *restrict coder, uint32_t *restrict len_res, - uint32_t *restrict back_res, uint32_t cur) -{ - coder->opts_end_index = cur; - - uint32_t pos_mem = coder->opts[cur].pos_prev; - uint32_t back_mem = coder->opts[cur].back_prev; - - do { - if (coder->opts[cur].prev_1_is_literal) { - make_literal(&coder->opts[pos_mem]); - coder->opts[pos_mem].pos_prev = pos_mem - 1; - - if (coder->opts[cur].prev_2) { - coder->opts[pos_mem - 1].prev_1_is_literal - = false; - coder->opts[pos_mem - 1].pos_prev - = coder->opts[cur].pos_prev_2; - coder->opts[pos_mem - 1].back_prev - = coder->opts[cur].back_prev_2; - } - } - - const uint32_t pos_prev = pos_mem; - const uint32_t back_cur = back_mem; - - back_mem = coder->opts[pos_prev].back_prev; - pos_mem = coder->opts[pos_prev].pos_prev; - - coder->opts[pos_prev].back_prev = back_cur; - coder->opts[pos_prev].pos_prev = cur; - cur = pos_prev; - - } while (cur != 0); - - coder->opts_current_index = coder->opts[0].pos_prev; - *len_res = coder->opts[0].pos_prev; - *back_res = coder->opts[0].back_prev; - - return; -} - - -////////// -// Main // -////////// - -static inline uint32_t -helper1(lzma_coder *restrict coder, lzma_mf *restrict mf, - uint32_t *restrict back_res, uint32_t *restrict len_res, - uint32_t position) -{ - const uint32_t nice_len = mf->nice_len; - - uint32_t len_main; - uint32_t matches_count; - - if (mf->read_ahead == 0) { - len_main = mf_find(mf, &matches_count, coder->matches); - } else { - assert(mf->read_ahead == 1); - len_main = coder->longest_match_length; - matches_count = coder->matches_count; - } - - const uint32_t buf_avail = my_min(mf_avail(mf) + 1, MATCH_LEN_MAX); - if (buf_avail < 2) { - *back_res = UINT32_MAX; - *len_res = 1; - return UINT32_MAX; - } - - const uint8_t *const buf = mf_ptr(mf) - 1; - - uint32_t rep_lens[REP_DISTANCES]; - uint32_t rep_max_index = 0; - - for (uint32_t i = 0; i < REP_DISTANCES; ++i) { - const uint8_t *const buf_back = buf - coder->reps[i] - 1; - - if (not_equal_16(buf, buf_back)) { - rep_lens[i] = 0; - continue; - } - - uint32_t len_test; - for (len_test = 2; len_test < buf_avail - && buf[len_test] == buf_back[len_test]; - ++len_test) ; - - rep_lens[i] = len_test; - if (len_test > rep_lens[rep_max_index]) - rep_max_index = i; - } - - if (rep_lens[rep_max_index] >= nice_len) { - *back_res = rep_max_index; - *len_res = rep_lens[rep_max_index]; - mf_skip(mf, *len_res - 1); - return UINT32_MAX; - } - - - if (len_main >= nice_len) { - *back_res = coder->matches[matches_count - 1].dist - + REP_DISTANCES; - *len_res = len_main; - mf_skip(mf, len_main - 1); - return UINT32_MAX; - } - - const uint8_t current_byte = *buf; - const uint8_t match_byte = *(buf - coder->reps[0] - 1); - - if (len_main < 2 && current_byte != match_byte - && rep_lens[rep_max_index] < 2) { - *back_res = UINT32_MAX; - *len_res = 1; - return UINT32_MAX; - } - - coder->opts[0].state = coder->state; - - const uint32_t pos_state = position & coder->pos_mask; - - coder->opts[1].price = rc_bit_0_price( - coder->is_match[coder->state][pos_state]) - + get_literal_price(coder, position, buf[-1], - !is_literal_state(coder->state), - match_byte, current_byte); - - make_literal(&coder->opts[1]); - - const uint32_t match_price = rc_bit_1_price( - coder->is_match[coder->state][pos_state]); - const uint32_t rep_match_price = match_price - + rc_bit_1_price(coder->is_rep[coder->state]); - - if (match_byte == current_byte) { - const uint32_t short_rep_price = rep_match_price - + get_short_rep_price( - coder, coder->state, pos_state); - - if (short_rep_price < coder->opts[1].price) { - coder->opts[1].price = short_rep_price; - make_short_rep(&coder->opts[1]); - } - } - - const uint32_t len_end = my_max(len_main, rep_lens[rep_max_index]); - - if (len_end < 2) { - *back_res = coder->opts[1].back_prev; - *len_res = 1; - return UINT32_MAX; - } - - coder->opts[1].pos_prev = 0; - - for (uint32_t i = 0; i < REP_DISTANCES; ++i) - coder->opts[0].backs[i] = coder->reps[i]; - - uint32_t len = len_end; - do { - coder->opts[len].price = RC_INFINITY_PRICE; - } while (--len >= 2); - - - for (uint32_t i = 0; i < REP_DISTANCES; ++i) { - uint32_t rep_len = rep_lens[i]; - if (rep_len < 2) - continue; - - const uint32_t price = rep_match_price + get_pure_rep_price( - coder, i, coder->state, pos_state); - - do { - const uint32_t cur_and_len_price = price - + get_len_price( - &coder->rep_len_encoder, - rep_len, pos_state); - - if (cur_and_len_price < coder->opts[rep_len].price) { - coder->opts[rep_len].price = cur_and_len_price; - coder->opts[rep_len].pos_prev = 0; - coder->opts[rep_len].back_prev = i; - coder->opts[rep_len].prev_1_is_literal = false; - } - } while (--rep_len >= 2); - } - - - const uint32_t normal_match_price = match_price - + rc_bit_0_price(coder->is_rep[coder->state]); - - len = rep_lens[0] >= 2 ? rep_lens[0] + 1 : 2; - if (len <= len_main) { - uint32_t i = 0; - while (len > coder->matches[i].len) - ++i; - - for(; ; ++len) { - const uint32_t dist = coder->matches[i].dist; - const uint32_t cur_and_len_price = normal_match_price - + get_pos_len_price(coder, - dist, len, pos_state); - - if (cur_and_len_price < coder->opts[len].price) { - coder->opts[len].price = cur_and_len_price; - coder->opts[len].pos_prev = 0; - coder->opts[len].back_prev - = dist + REP_DISTANCES; - coder->opts[len].prev_1_is_literal = false; - } - - if (len == coder->matches[i].len) - if (++i == matches_count) - break; - } - } - - return len_end; -} - - -static inline uint32_t -helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf, - uint32_t len_end, uint32_t position, const uint32_t cur, - const uint32_t nice_len, const uint32_t buf_avail_full) -{ - uint32_t matches_count = coder->matches_count; - uint32_t new_len = coder->longest_match_length; - uint32_t pos_prev = coder->opts[cur].pos_prev; - lzma_lzma_state state; - - if (coder->opts[cur].prev_1_is_literal) { - --pos_prev; - - if (coder->opts[cur].prev_2) { - state = coder->opts[coder->opts[cur].pos_prev_2].state; - - if (coder->opts[cur].back_prev_2 < REP_DISTANCES) - update_long_rep(state); - else - update_match(state); - - } else { - state = coder->opts[pos_prev].state; - } - - update_literal(state); - - } else { - state = coder->opts[pos_prev].state; - } - - if (pos_prev == cur - 1) { - if (is_short_rep(coder->opts[cur])) - update_short_rep(state); - else - update_literal(state); - } else { - uint32_t pos; - if (coder->opts[cur].prev_1_is_literal - && coder->opts[cur].prev_2) { - pos_prev = coder->opts[cur].pos_prev_2; - pos = coder->opts[cur].back_prev_2; - update_long_rep(state); - } else { - pos = coder->opts[cur].back_prev; - if (pos < REP_DISTANCES) - update_long_rep(state); - else - update_match(state); - } - - if (pos < REP_DISTANCES) { - reps[0] = coder->opts[pos_prev].backs[pos]; - - uint32_t i; - for (i = 1; i <= pos; ++i) - reps[i] = coder->opts[pos_prev].backs[i - 1]; - - for (; i < REP_DISTANCES; ++i) - reps[i] = coder->opts[pos_prev].backs[i]; - - } else { - reps[0] = pos - REP_DISTANCES; - - for (uint32_t i = 1; i < REP_DISTANCES; ++i) - reps[i] = coder->opts[pos_prev].backs[i - 1]; - } - } - - coder->opts[cur].state = state; - - for (uint32_t i = 0; i < REP_DISTANCES; ++i) - coder->opts[cur].backs[i] = reps[i]; - - const uint32_t cur_price = coder->opts[cur].price; - - const uint8_t current_byte = *buf; - const uint8_t match_byte = *(buf - reps[0] - 1); - - const uint32_t pos_state = position & coder->pos_mask; - - const uint32_t cur_and_1_price = cur_price - + rc_bit_0_price(coder->is_match[state][pos_state]) - + get_literal_price(coder, position, buf[-1], - !is_literal_state(state), match_byte, current_byte); - - bool next_is_literal = false; - - if (cur_and_1_price < coder->opts[cur + 1].price) { - coder->opts[cur + 1].price = cur_and_1_price; - coder->opts[cur + 1].pos_prev = cur; - make_literal(&coder->opts[cur + 1]); - next_is_literal = true; - } - - const uint32_t match_price = cur_price - + rc_bit_1_price(coder->is_match[state][pos_state]); - const uint32_t rep_match_price = match_price - + rc_bit_1_price(coder->is_rep[state]); - - if (match_byte == current_byte - && !(coder->opts[cur + 1].pos_prev < cur - && coder->opts[cur + 1].back_prev == 0)) { - - const uint32_t short_rep_price = rep_match_price - + get_short_rep_price(coder, state, pos_state); - - if (short_rep_price <= coder->opts[cur + 1].price) { - coder->opts[cur + 1].price = short_rep_price; - coder->opts[cur + 1].pos_prev = cur; - make_short_rep(&coder->opts[cur + 1]); - next_is_literal = true; - } - } - - if (buf_avail_full < 2) - return len_end; - - const uint32_t buf_avail = my_min(buf_avail_full, nice_len); - - if (!next_is_literal && match_byte != current_byte) { // speed optimization - // try literal + rep0 - const uint8_t *const buf_back = buf - reps[0] - 1; - const uint32_t limit = my_min(buf_avail_full, nice_len + 1); - - uint32_t len_test = 1; - while (len_test < limit && buf[len_test] == buf_back[len_test]) - ++len_test; - - --len_test; - - if (len_test >= 2) { - lzma_lzma_state state_2 = state; - update_literal(state_2); - - const uint32_t pos_state_next = (position + 1) & coder->pos_mask; - const uint32_t next_rep_match_price = cur_and_1_price - + rc_bit_1_price(coder->is_match[state_2][pos_state_next]) - + rc_bit_1_price(coder->is_rep[state_2]); - - //for (; len_test >= 2; --len_test) { - const uint32_t offset = cur + 1 + len_test; - - while (len_end < offset) - coder->opts[++len_end].price = RC_INFINITY_PRICE; - - const uint32_t cur_and_len_price = next_rep_match_price - + get_rep_price(coder, 0, len_test, - state_2, pos_state_next); - - if (cur_and_len_price < coder->opts[offset].price) { - coder->opts[offset].price = cur_and_len_price; - coder->opts[offset].pos_prev = cur + 1; - coder->opts[offset].back_prev = 0; - coder->opts[offset].prev_1_is_literal = true; - coder->opts[offset].prev_2 = false; - } - //} - } - } - - - uint32_t start_len = 2; // speed optimization - - for (uint32_t rep_index = 0; rep_index < REP_DISTANCES; ++rep_index) { - const uint8_t *const buf_back = buf - reps[rep_index] - 1; - if (not_equal_16(buf, buf_back)) - continue; - - uint32_t len_test; - for (len_test = 2; len_test < buf_avail - && buf[len_test] == buf_back[len_test]; - ++len_test) ; - - while (len_end < cur + len_test) - coder->opts[++len_end].price = RC_INFINITY_PRICE; - - const uint32_t len_test_temp = len_test; - const uint32_t price = rep_match_price + get_pure_rep_price( - coder, rep_index, state, pos_state); - - do { - const uint32_t cur_and_len_price = price - + get_len_price(&coder->rep_len_encoder, - len_test, pos_state); - - if (cur_and_len_price < coder->opts[cur + len_test].price) { - coder->opts[cur + len_test].price = cur_and_len_price; - coder->opts[cur + len_test].pos_prev = cur; - coder->opts[cur + len_test].back_prev = rep_index; - coder->opts[cur + len_test].prev_1_is_literal = false; - } - } while (--len_test >= 2); - - len_test = len_test_temp; - - if (rep_index == 0) - start_len = len_test + 1; - - - uint32_t len_test_2 = len_test + 1; - const uint32_t limit = my_min(buf_avail_full, - len_test_2 + nice_len); - for (; len_test_2 < limit - && buf[len_test_2] == buf_back[len_test_2]; - ++len_test_2) ; - - len_test_2 -= len_test + 1; - - if (len_test_2 >= 2) { - lzma_lzma_state state_2 = state; - update_long_rep(state_2); - - uint32_t pos_state_next = (position + len_test) & coder->pos_mask; - - const uint32_t cur_and_len_literal_price = price - + get_len_price(&coder->rep_len_encoder, - len_test, pos_state) - + rc_bit_0_price(coder->is_match[state_2][pos_state_next]) - + get_literal_price(coder, position + len_test, - buf[len_test - 1], true, - buf_back[len_test], buf[len_test]); - - update_literal(state_2); - - pos_state_next = (position + len_test + 1) & coder->pos_mask; - - const uint32_t next_rep_match_price = cur_and_len_literal_price - + rc_bit_1_price(coder->is_match[state_2][pos_state_next]) - + rc_bit_1_price(coder->is_rep[state_2]); - - //for(; len_test_2 >= 2; len_test_2--) { - const uint32_t offset = cur + len_test + 1 + len_test_2; - - while (len_end < offset) - coder->opts[++len_end].price = RC_INFINITY_PRICE; - - const uint32_t cur_and_len_price = next_rep_match_price - + get_rep_price(coder, 0, len_test_2, - state_2, pos_state_next); - - if (cur_and_len_price < coder->opts[offset].price) { - coder->opts[offset].price = cur_and_len_price; - coder->opts[offset].pos_prev = cur + len_test + 1; - coder->opts[offset].back_prev = 0; - coder->opts[offset].prev_1_is_literal = true; - coder->opts[offset].prev_2 = true; - coder->opts[offset].pos_prev_2 = cur; - coder->opts[offset].back_prev_2 = rep_index; - } - //} - } - } - - - //for (uint32_t len_test = 2; len_test <= new_len; ++len_test) - if (new_len > buf_avail) { - new_len = buf_avail; - - matches_count = 0; - while (new_len > coder->matches[matches_count].len) - ++matches_count; - - coder->matches[matches_count++].len = new_len; - } - - - if (new_len >= start_len) { - const uint32_t normal_match_price = match_price - + rc_bit_0_price(coder->is_rep[state]); - - while (len_end < cur + new_len) - coder->opts[++len_end].price = RC_INFINITY_PRICE; - - uint32_t i = 0; - while (start_len > coder->matches[i].len) - ++i; - - for (uint32_t len_test = start_len; ; ++len_test) { - const uint32_t cur_back = coder->matches[i].dist; - uint32_t cur_and_len_price = normal_match_price - + get_pos_len_price(coder, - cur_back, len_test, pos_state); - - if (cur_and_len_price < coder->opts[cur + len_test].price) { - coder->opts[cur + len_test].price = cur_and_len_price; - coder->opts[cur + len_test].pos_prev = cur; - coder->opts[cur + len_test].back_prev - = cur_back + REP_DISTANCES; - coder->opts[cur + len_test].prev_1_is_literal = false; - } - - if (len_test == coder->matches[i].len) { - // Try Match + Literal + Rep0 - const uint8_t *const buf_back = buf - cur_back - 1; - uint32_t len_test_2 = len_test + 1; - const uint32_t limit = my_min(buf_avail_full, - len_test_2 + nice_len); - - for (; len_test_2 < limit && - buf[len_test_2] == buf_back[len_test_2]; - ++len_test_2) ; - - len_test_2 -= len_test + 1; - - if (len_test_2 >= 2) { - lzma_lzma_state state_2 = state; - update_match(state_2); - uint32_t pos_state_next - = (position + len_test) & coder->pos_mask; - - const uint32_t cur_and_len_literal_price = cur_and_len_price - + rc_bit_0_price( - coder->is_match[state_2][pos_state_next]) - + get_literal_price(coder, - position + len_test, - buf[len_test - 1], - true, - buf_back[len_test], - buf[len_test]); - - update_literal(state_2); - pos_state_next = (pos_state_next + 1) & coder->pos_mask; - - const uint32_t next_rep_match_price - = cur_and_len_literal_price - + rc_bit_1_price( - coder->is_match[state_2][pos_state_next]) - + rc_bit_1_price(coder->is_rep[state_2]); - - // for(; len_test_2 >= 2; --len_test_2) { - const uint32_t offset = cur + len_test + 1 + len_test_2; - - while (len_end < offset) - coder->opts[++len_end].price = RC_INFINITY_PRICE; - - cur_and_len_price = next_rep_match_price - + get_rep_price(coder, 0, len_test_2, - state_2, pos_state_next); - - if (cur_and_len_price < coder->opts[offset].price) { - coder->opts[offset].price = cur_and_len_price; - coder->opts[offset].pos_prev = cur + len_test + 1; - coder->opts[offset].back_prev = 0; - coder->opts[offset].prev_1_is_literal = true; - coder->opts[offset].prev_2 = true; - coder->opts[offset].pos_prev_2 = cur; - coder->opts[offset].back_prev_2 - = cur_back + REP_DISTANCES; - } - //} - } - - if (++i == matches_count) - break; - } - } - } - - return len_end; -} - - -extern void -lzma_lzma_optimum_normal(lzma_coder *restrict coder, lzma_mf *restrict mf, - uint32_t *restrict back_res, uint32_t *restrict len_res, - uint32_t position) -{ - // If we have symbols pending, return the next pending symbol. - if (coder->opts_end_index != coder->opts_current_index) { - assert(mf->read_ahead > 0); - *len_res = coder->opts[coder->opts_current_index].pos_prev - - coder->opts_current_index; - *back_res = coder->opts[coder->opts_current_index].back_prev; - coder->opts_current_index = coder->opts[ - coder->opts_current_index].pos_prev; - return; - } - - // Update the price tables. In LZMA SDK <= 4.60 (and possibly later) - // this was done in both initialization function and in the main loop. - // In liblzma they were moved into this single place. - if (mf->read_ahead == 0) { - if (coder->match_price_count >= (1 << 7)) - fill_distances_prices(coder); - - if (coder->align_price_count >= ALIGN_TABLE_SIZE) - fill_align_prices(coder); - } - - // TODO: This needs quite a bit of cleaning still. But splitting - // the original function into two pieces makes it at least a little - // more readable, since those two parts don't share many variables. - - uint32_t len_end = helper1(coder, mf, back_res, len_res, position); - if (len_end == UINT32_MAX) - return; - - uint32_t reps[REP_DISTANCES]; - memcpy(reps, coder->reps, sizeof(reps)); - - uint32_t cur; - for (cur = 1; cur < len_end; ++cur) { - assert(cur < OPTS); - - coder->longest_match_length = mf_find( - mf, &coder->matches_count, coder->matches); - - if (coder->longest_match_length >= mf->nice_len) - break; - - len_end = helper2(coder, reps, mf_ptr(mf) - 1, len_end, - position + cur, cur, mf->nice_len, - my_min(mf_avail(mf) + 1, OPTS - 1 - cur)); - } - - backward(coder, len_res, back_res, cur); - return; -} diff --git a/deps/lzma/liblzma/lzma/lzma_encoder_presets.c b/deps/lzma/liblzma/lzma/lzma_encoder_presets.c deleted file mode 100644 index 8484b77..0000000 --- a/deps/lzma/liblzma/lzma/lzma_encoder_presets.c +++ /dev/null @@ -1,63 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file lzma_encoder_presets.c -/// \brief Encoder presets -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "common.h" - - -extern LZMA_API(lzma_bool) -lzma_lzma_preset(lzma_options_lzma *options, uint32_t preset) -{ - const uint32_t level = preset & LZMA_PRESET_LEVEL_MASK; - const uint32_t flags = preset & ~LZMA_PRESET_LEVEL_MASK; - const uint32_t supported_flags = LZMA_PRESET_EXTREME; - - if (level > 9 || (flags & ~supported_flags)) - return true; - - options->preset_dict = NULL; - options->preset_dict_size = 0; - - options->lc = LZMA_LC_DEFAULT; - options->lp = LZMA_LP_DEFAULT; - options->pb = LZMA_PB_DEFAULT; - - static const uint8_t dict_pow2[] - = { 18, 20, 21, 22, 22, 23, 23, 24, 25, 26 }; - options->dict_size = UINT32_C(1) << dict_pow2[level]; - - if (level <= 3) { - options->mode = LZMA_MODE_FAST; - options->mf = level == 0 ? LZMA_MF_HC3 : LZMA_MF_HC4; - options->nice_len = level <= 1 ? 128 : 273; - static const uint8_t depths[] = { 4, 8, 24, 48 }; - options->depth = depths[level]; - } else { - options->mode = LZMA_MODE_NORMAL; - options->mf = LZMA_MF_BT4; - options->nice_len = level == 4 ? 16 : level == 5 ? 32 : 64; - options->depth = 0; - } - - if (flags & LZMA_PRESET_EXTREME) { - options->mode = LZMA_MODE_NORMAL; - options->mf = LZMA_MF_BT4; - if (level == 3 || level == 5) { - options->nice_len = 192; - options->depth = 0; - } else { - options->nice_len = 273; - options->depth = 512; - } - } - - return false; -} diff --git a/deps/lzma/liblzma/lzma/lzma_encoder_private.h b/deps/lzma/liblzma/lzma/lzma_encoder_private.h deleted file mode 100644 index 6847452..0000000 --- a/deps/lzma/liblzma/lzma/lzma_encoder_private.h +++ /dev/null @@ -1,148 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file lzma_encoder_private.h -/// \brief Private definitions for LZMA encoder -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_LZMA_ENCODER_PRIVATE_H -#define LZMA_LZMA_ENCODER_PRIVATE_H - -#include "lz_encoder.h" -#include "range_encoder.h" -#include "lzma_common.h" -#include "lzma_encoder.h" - - -// Macro to compare if the first two bytes in two buffers differ. This is -// needed in lzma_lzma_optimum_*() to test if the match is at least -// MATCH_LEN_MIN bytes. Unaligned access gives tiny gain so there's no -// reason to not use it when it is supported. -#ifdef TUKLIB_FAST_UNALIGNED_ACCESS -# define not_equal_16(a, b) \ - (*(const uint16_t *)(a) != *(const uint16_t *)(b)) -#else -# define not_equal_16(a, b) \ - ((a)[0] != (b)[0] || (a)[1] != (b)[1]) -#endif - - -// Optimal - Number of entries in the optimum array. -#define OPTS (1 << 12) - - -typedef struct { - probability choice; - probability choice2; - probability low[POS_STATES_MAX][LEN_LOW_SYMBOLS]; - probability mid[POS_STATES_MAX][LEN_MID_SYMBOLS]; - probability high[LEN_HIGH_SYMBOLS]; - - uint32_t prices[POS_STATES_MAX][LEN_SYMBOLS]; - uint32_t table_size; - uint32_t counters[POS_STATES_MAX]; - -} lzma_length_encoder; - - -typedef struct { - lzma_lzma_state state; - - bool prev_1_is_literal; - bool prev_2; - - uint32_t pos_prev_2; - uint32_t back_prev_2; - - uint32_t price; - uint32_t pos_prev; // pos_next; - uint32_t back_prev; - - uint32_t backs[REP_DISTANCES]; - -} lzma_optimal; - - -struct lzma_coder_s { - /// Range encoder - lzma_range_encoder rc; - - /// State - lzma_lzma_state state; - - /// The four most recent match distances - uint32_t reps[REP_DISTANCES]; - - /// Array of match candidates - lzma_match matches[MATCH_LEN_MAX + 1]; - - /// Number of match candidates in matches[] - uint32_t matches_count; - - /// Variable to hold the length of the longest match between calls - /// to lzma_lzma_optimum_*(). - uint32_t longest_match_length; - - /// True if using getoptimumfast - bool fast_mode; - - /// True if the encoder has been initialized by encoding the first - /// byte as a literal. - bool is_initialized; - - /// True if the range encoder has been flushed, but not all bytes - /// have been written to the output buffer yet. - bool is_flushed; - - uint32_t pos_mask; ///< (1 << pos_bits) - 1 - uint32_t literal_context_bits; - uint32_t literal_pos_mask; - - // These are the same as in lzma_decoder.c. See comments there. - probability literal[LITERAL_CODERS_MAX][LITERAL_CODER_SIZE]; - probability is_match[STATES][POS_STATES_MAX]; - probability is_rep[STATES]; - probability is_rep0[STATES]; - probability is_rep1[STATES]; - probability is_rep2[STATES]; - probability is_rep0_long[STATES][POS_STATES_MAX]; - probability pos_slot[LEN_TO_POS_STATES][POS_SLOTS]; - probability pos_special[FULL_DISTANCES - END_POS_MODEL_INDEX]; - probability pos_align[ALIGN_TABLE_SIZE]; - - // These are the same as in lzma_decoder.c except that the encoders - // include also price tables. - lzma_length_encoder match_len_encoder; - lzma_length_encoder rep_len_encoder; - - // Price tables - uint32_t pos_slot_prices[LEN_TO_POS_STATES][POS_SLOTS]; - uint32_t distances_prices[LEN_TO_POS_STATES][FULL_DISTANCES]; - uint32_t dist_table_size; - uint32_t match_price_count; - - uint32_t align_prices[ALIGN_TABLE_SIZE]; - uint32_t align_price_count; - - // Optimal - uint32_t opts_end_index; - uint32_t opts_current_index; - lzma_optimal opts[OPTS]; -}; - - -extern void lzma_lzma_optimum_fast( - lzma_coder *restrict coder, lzma_mf *restrict mf, - uint32_t *restrict back_res, uint32_t *restrict len_res); - -extern void lzma_lzma_optimum_normal(lzma_coder *restrict coder, - lzma_mf *restrict mf, uint32_t *restrict back_res, - uint32_t *restrict len_res, uint32_t position); - -#endif diff --git a/deps/lzma/liblzma/rangecoder/Makefile.inc b/deps/lzma/liblzma/rangecoder/Makefile.inc deleted file mode 100644 index d8a597a..0000000 --- a/deps/lzma/liblzma/rangecoder/Makefile.inc +++ /dev/null @@ -1,21 +0,0 @@ -## -## Author: Lasse Collin -## -## This file has been put into the public domain. -## You can do whatever you want with this file. -## - -EXTRA_DIST += rangecoder/price_tablegen.c - -liblzma_la_SOURCES += rangecoder/range_common.h - -if COND_ENCODER_LZMA1 -liblzma_la_SOURCES += \ - rangecoder/range_encoder.h \ - rangecoder/price.h \ - rangecoder/price_table.c -endif - -if COND_DECODER_LZMA1 -liblzma_la_SOURCES += rangecoder/range_decoder.h -endif diff --git a/deps/lzma/liblzma/rangecoder/price.h b/deps/lzma/liblzma/rangecoder/price.h deleted file mode 100644 index 8ae02ca..0000000 --- a/deps/lzma/liblzma/rangecoder/price.h +++ /dev/null @@ -1,92 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file price.h -/// \brief Probability price calculation -// -// Author: Igor Pavlov -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_PRICE_H -#define LZMA_PRICE_H - - -#define RC_MOVE_REDUCING_BITS 4 -#define RC_BIT_PRICE_SHIFT_BITS 4 -#define RC_PRICE_TABLE_SIZE (RC_BIT_MODEL_TOTAL >> RC_MOVE_REDUCING_BITS) - -#define RC_INFINITY_PRICE (UINT32_C(1) << 30) - - -/// Lookup table for the inline functions defined in this file. -extern const uint8_t lzma_rc_prices[RC_PRICE_TABLE_SIZE]; - - -static inline uint32_t -rc_bit_price(const probability prob, const uint32_t bit) -{ - return lzma_rc_prices[(prob ^ ((UINT32_C(0) - bit) - & (RC_BIT_MODEL_TOTAL - 1))) >> RC_MOVE_REDUCING_BITS]; -} - - -static inline uint32_t -rc_bit_0_price(const probability prob) -{ - return lzma_rc_prices[prob >> RC_MOVE_REDUCING_BITS]; -} - - -static inline uint32_t -rc_bit_1_price(const probability prob) -{ - return lzma_rc_prices[(prob ^ (RC_BIT_MODEL_TOTAL - 1)) - >> RC_MOVE_REDUCING_BITS]; -} - - -static inline uint32_t -rc_bittree_price(const probability *const probs, - const uint32_t bit_levels, uint32_t symbol) -{ - uint32_t price = 0; - symbol += UINT32_C(1) << bit_levels; - - do { - const uint32_t bit = symbol & 1; - symbol >>= 1; - price += rc_bit_price(probs[symbol], bit); - } while (symbol != 1); - - return price; -} - - -static inline uint32_t -rc_bittree_reverse_price(const probability *const probs, - uint32_t bit_levels, uint32_t symbol) -{ - uint32_t price = 0; - uint32_t model_index = 1; - - do { - const uint32_t bit = symbol & 1; - symbol >>= 1; - price += rc_bit_price(probs[model_index], bit); - model_index = (model_index << 1) + bit; - } while (--bit_levels != 0); - - return price; -} - - -static inline uint32_t -rc_direct_price(const uint32_t bits) -{ - return bits << RC_BIT_PRICE_SHIFT_BITS; -} - -#endif diff --git a/deps/lzma/liblzma/rangecoder/price_table.c b/deps/lzma/liblzma/rangecoder/price_table.c deleted file mode 100644 index ac64bf6..0000000 --- a/deps/lzma/liblzma/rangecoder/price_table.c +++ /dev/null @@ -1,22 +0,0 @@ -/* This file has been automatically generated by price_tablegen.c. */ - -#include "range_encoder.h" - -const uint8_t lzma_rc_prices[RC_PRICE_TABLE_SIZE] = { - 128, 103, 91, 84, 78, 73, 69, 66, - 63, 61, 58, 56, 54, 52, 51, 49, - 48, 46, 45, 44, 43, 42, 41, 40, - 39, 38, 37, 36, 35, 34, 34, 33, - 32, 31, 31, 30, 29, 29, 28, 28, - 27, 26, 26, 25, 25, 24, 24, 23, - 23, 22, 22, 22, 21, 21, 20, 20, - 19, 19, 19, 18, 18, 17, 17, 17, - 16, 16, 16, 15, 15, 15, 14, 14, - 14, 13, 13, 13, 12, 12, 12, 11, - 11, 11, 11, 10, 10, 10, 10, 9, - 9, 9, 9, 8, 8, 8, 8, 7, - 7, 7, 7, 6, 6, 6, 6, 5, - 5, 5, 5, 5, 4, 4, 4, 4, - 3, 3, 3, 3, 3, 2, 2, 2, - 2, 2, 2, 1, 1, 1, 1, 1 -}; diff --git a/deps/lzma/liblzma/rangecoder/price_tablegen.c b/deps/lzma/liblzma/rangecoder/price_tablegen.c deleted file mode 100644 index bf08ce3..0000000 --- a/deps/lzma/liblzma/rangecoder/price_tablegen.c +++ /dev/null @@ -1,87 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file price_tablegen.c -/// \brief Probability price table generator -/// -/// Compiling: gcc -std=c99 -o price_tablegen price_tablegen.c -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include "range_common.h" -#include "price.h" - - -static uint32_t rc_prices[RC_PRICE_TABLE_SIZE]; - - -static void -init_price_table(void) -{ - for (uint32_t i = (UINT32_C(1) << RC_MOVE_REDUCING_BITS) / 2; - i < RC_BIT_MODEL_TOTAL; - i += (UINT32_C(1) << RC_MOVE_REDUCING_BITS)) { - const uint32_t cycles_bits = RC_BIT_PRICE_SHIFT_BITS; - uint32_t w = i; - uint32_t bit_count = 0; - - for (uint32_t j = 0; j < cycles_bits; ++j) { - w *= w; - bit_count <<= 1; - - while (w >= (UINT32_C(1) << 16)) { - w >>= 1; - ++bit_count; - } - } - - rc_prices[i >> RC_MOVE_REDUCING_BITS] - = (RC_BIT_MODEL_TOTAL_BITS << cycles_bits) - - 15 - bit_count; - } - - return; -} - - -static void -print_price_table(void) -{ - printf("/* This file has been automatically generated by " - "price_tablegen.c. */\n\n" - "#include \"range_encoder.h\"\n\n" - "const uint8_t lzma_rc_prices[" - "RC_PRICE_TABLE_SIZE] = {"); - - const size_t array_size = sizeof(lzma_rc_prices) - / sizeof(lzma_rc_prices[0]); - for (size_t i = 0; i < array_size; ++i) { - if (i % 8 == 0) - printf("\n\t"); - - printf("%4" PRIu32, rc_prices[i]); - - if (i != array_size - 1) - printf(","); - } - - printf("\n};\n"); - - return; -} - - -int -main(void) -{ - init_price_table(); - print_price_table(); - return 0; -} diff --git a/deps/lzma/liblzma/rangecoder/range_common.h b/deps/lzma/liblzma/rangecoder/range_common.h deleted file mode 100644 index 0e64241..0000000 --- a/deps/lzma/liblzma/rangecoder/range_common.h +++ /dev/null @@ -1,73 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file range_common.h -/// \brief Common things for range encoder and decoder -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_RANGE_COMMON_H -#define LZMA_RANGE_COMMON_H - -#ifdef HAVE_CONFIG_H -# include "common.h" -#endif - - -/////////////// -// Constants // -/////////////// - -#define RC_SHIFT_BITS 8 -#define RC_TOP_BITS 24 -#define RC_TOP_VALUE (UINT32_C(1) << RC_TOP_BITS) -#define RC_BIT_MODEL_TOTAL_BITS 11 -#define RC_BIT_MODEL_TOTAL (UINT32_C(1) << RC_BIT_MODEL_TOTAL_BITS) -#define RC_MOVE_BITS 5 - - -//////////// -// Macros // -//////////// - -// Resets the probability so that both 0 and 1 have probability of 50 % -#define bit_reset(prob) \ - prob = RC_BIT_MODEL_TOTAL >> 1 - -// This does the same for a complete bit tree. -// (A tree represented as an array.) -#define bittree_reset(probs, bit_levels) \ - for (uint32_t bt_i = 0; bt_i < (1 << (bit_levels)); ++bt_i) \ - bit_reset((probs)[bt_i]) - - -////////////////////// -// Type definitions // -////////////////////// - -/// \brief Type of probabilities used with range coder -/// -/// This needs to be at least 12-bit integer, so uint16_t is a logical choice. -/// However, on some architecture and compiler combinations, a bigger type -/// may give better speed, because the probability variables are accessed -/// a lot. On the other hand, bigger probability type increases cache -/// footprint, since there are 2 to 14 thousand probability variables in -/// LZMA (assuming the limit of lc + lp <= 4; with lc + lp <= 12 there -/// would be about 1.5 million variables). -/// -/// With malicious files, the initialization speed of the LZMA decoder can -/// become important. In that case, smaller probability variables mean that -/// there is less bytes to write to RAM, which makes initialization faster. -/// With big probability type, the initialization can become so slow that it -/// can be a problem e.g. for email servers doing virus scanning. -/// -/// I will be sticking to uint16_t unless some specific architectures -/// are *much* faster (20-50 %) with uint32_t. -typedef uint16_t probability; - -#endif diff --git a/deps/lzma/liblzma/rangecoder/range_decoder.h b/deps/lzma/liblzma/rangecoder/range_decoder.h deleted file mode 100644 index fb96180..0000000 --- a/deps/lzma/liblzma/rangecoder/range_decoder.h +++ /dev/null @@ -1,179 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file range_decoder.h -/// \brief Range Decoder -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_RANGE_DECODER_H -#define LZMA_RANGE_DECODER_H - -#include "range_common.h" - - -typedef struct { - uint32_t range; - uint32_t code; - uint32_t init_bytes_left; -} lzma_range_decoder; - - -/// Reads the first five bytes to initialize the range decoder. -static inline bool -rc_read_init(lzma_range_decoder *rc, const uint8_t *restrict in, - size_t *restrict in_pos, size_t in_size) -{ - while (rc->init_bytes_left > 0) { - if (*in_pos == in_size) - return false; - - rc->code = (rc->code << 8) | in[*in_pos]; - ++*in_pos; - --rc->init_bytes_left; - } - - return true; -} - - -/// Makes local copies of range decoder and *in_pos variables. Doing this -/// improves speed significantly. The range decoder macros expect also -/// variables `in' and `in_size' to be defined. -#define rc_to_local(range_decoder, in_pos) \ - lzma_range_decoder rc = range_decoder; \ - size_t rc_in_pos = (in_pos); \ - uint32_t rc_bound - - -/// Stores the local copes back to the range decoder structure. -#define rc_from_local(range_decoder, in_pos) \ -do { \ - range_decoder = rc; \ - in_pos = rc_in_pos; \ -} while (0) - - -/// Resets the range decoder structure. -#define rc_reset(range_decoder) \ -do { \ - (range_decoder).range = UINT32_MAX; \ - (range_decoder).code = 0; \ - (range_decoder).init_bytes_left = 5; \ -} while (0) - - -/// When decoding has been properly finished, rc.code is always zero unless -/// the input stream is corrupt. So checking this can catch some corrupt -/// files especially if they don't have any other integrity check. -#define rc_is_finished(range_decoder) \ - ((range_decoder).code == 0) - - -/// Read the next input byte if needed. If more input is needed but there is -/// no more input available, "goto out" is used to jump out of the main -/// decoder loop. -#define rc_normalize(seq) \ -do { \ - if (rc.range < RC_TOP_VALUE) { \ - if (unlikely(rc_in_pos == in_size)) { \ - coder->sequence = seq; \ - goto out; \ - } \ - rc.range <<= RC_SHIFT_BITS; \ - rc.code = (rc.code << RC_SHIFT_BITS) | in[rc_in_pos++]; \ - } \ -} while (0) - - -/// Start decoding a bit. This must be used together with rc_update_0() -/// and rc_update_1(): -/// -/// rc_if_0(prob, seq) { -/// rc_update_0(prob); -/// // Do something -/// } else { -/// rc_update_1(prob); -/// // Do something else -/// } -/// -#define rc_if_0(prob, seq) \ - rc_normalize(seq); \ - rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * (prob); \ - if (rc.code < rc_bound) - - -/// Update the range decoder state and the used probability variable to -/// match a decoded bit of 0. -#define rc_update_0(prob) \ -do { \ - rc.range = rc_bound; \ - prob += (RC_BIT_MODEL_TOTAL - (prob)) >> RC_MOVE_BITS; \ -} while (0) - - -/// Update the range decoder state and the used probability variable to -/// match a decoded bit of 1. -#define rc_update_1(prob) \ -do { \ - rc.range -= rc_bound; \ - rc.code -= rc_bound; \ - prob -= (prob) >> RC_MOVE_BITS; \ -} while (0) - - -/// Decodes one bit and runs action0 or action1 depending on the decoded bit. -/// This macro is used as the last step in bittree reverse decoders since -/// those don't use "symbol" for anything else than indexing the probability -/// arrays. -#define rc_bit_last(prob, action0, action1, seq) \ -do { \ - rc_if_0(prob, seq) { \ - rc_update_0(prob); \ - action0; \ - } else { \ - rc_update_1(prob); \ - action1; \ - } \ -} while (0) - - -/// Decodes one bit, updates "symbol", and runs action0 or action1 depending -/// on the decoded bit. -#define rc_bit(prob, action0, action1, seq) \ - rc_bit_last(prob, \ - symbol <<= 1; action0, \ - symbol = (symbol << 1) + 1; action1, \ - seq); - - -/// Like rc_bit() but add "case seq:" as a prefix. This makes the unrolled -/// loops more readable because the code isn't littered with "case" -/// statements. On the other hand this also makes it less readable, since -/// spotting the places where the decoder loop may be restarted is less -/// obvious. -#define rc_bit_case(prob, action0, action1, seq) \ - case seq: rc_bit(prob, action0, action1, seq) - - -/// Decode a bit without using a probability. -#define rc_direct(dest, seq) \ -do { \ - rc_normalize(seq); \ - rc.range >>= 1; \ - rc.code -= rc.range; \ - rc_bound = UINT32_C(0) - (rc.code >> 31); \ - rc.code += rc.range & rc_bound; \ - dest = (dest << 1) + (rc_bound + 1); \ -} while (0) - - -// NOTE: No macros are provided for bittree decoding. It seems to be simpler -// to just write them open in the code. - -#endif diff --git a/deps/lzma/liblzma/rangecoder/range_encoder.h b/deps/lzma/liblzma/rangecoder/range_encoder.h deleted file mode 100644 index 1e1c369..0000000 --- a/deps/lzma/liblzma/rangecoder/range_encoder.h +++ /dev/null @@ -1,231 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file range_encoder.h -/// \brief Range Encoder -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_RANGE_ENCODER_H -#define LZMA_RANGE_ENCODER_H - -#include "range_common.h" -#include "price.h" - - -/// Maximum number of symbols that can be put pending into lzma_range_encoder -/// structure between calls to lzma_rc_encode(). For LZMA, 52+5 is enough -/// (match with big distance and length followed by range encoder flush). -#define RC_SYMBOLS_MAX 58 - - -typedef struct { - uint64_t low; - uint64_t cache_size; - uint32_t range; - uint8_t cache; - - /// Number of symbols in the tables - size_t count; - - /// rc_encode()'s position in the tables - size_t pos; - - /// Symbols to encode - enum { - RC_BIT_0, - RC_BIT_1, - RC_DIRECT_0, - RC_DIRECT_1, - RC_FLUSH, - } symbols[RC_SYMBOLS_MAX]; - - /// Probabilities associated with RC_BIT_0 or RC_BIT_1 - probability *probs[RC_SYMBOLS_MAX]; - -} lzma_range_encoder; - - -static inline void -rc_reset(lzma_range_encoder *rc) -{ - rc->low = 0; - rc->cache_size = 1; - rc->range = UINT32_MAX; - rc->cache = 0; - rc->count = 0; - rc->pos = 0; -} - - -static inline void -rc_bit(lzma_range_encoder *rc, probability *prob, uint32_t bit) -{ - rc->symbols[rc->count] = bit; - rc->probs[rc->count] = prob; - ++rc->count; -} - - -static inline void -rc_bittree(lzma_range_encoder *rc, probability *probs, - uint32_t bit_count, uint32_t symbol) -{ - uint32_t model_index = 1; - - do { - const uint32_t bit = (symbol >> --bit_count) & 1; - rc_bit(rc, &probs[model_index], bit); - model_index = (model_index << 1) + bit; - } while (bit_count != 0); -} - - -static inline void -rc_bittree_reverse(lzma_range_encoder *rc, probability *probs, - uint32_t bit_count, uint32_t symbol) -{ - uint32_t model_index = 1; - - do { - const uint32_t bit = symbol & 1; - symbol >>= 1; - rc_bit(rc, &probs[model_index], bit); - model_index = (model_index << 1) + bit; - } while (--bit_count != 0); -} - - -static inline void -rc_direct(lzma_range_encoder *rc, - uint32_t value, uint32_t bit_count) -{ - do { - rc->symbols[rc->count++] - = RC_DIRECT_0 + ((value >> --bit_count) & 1); - } while (bit_count != 0); -} - - -static inline void -rc_flush(lzma_range_encoder *rc) -{ - for (size_t i = 0; i < 5; ++i) - rc->symbols[rc->count++] = RC_FLUSH; -} - - -static inline bool -rc_shift_low(lzma_range_encoder *rc, - uint8_t *out, size_t *out_pos, size_t out_size) -{ - if ((uint32_t)(rc->low) < (uint32_t)(0xFF000000) - || (uint32_t)(rc->low >> 32) != 0) { - do { - if (*out_pos == out_size) - return true; - - out[*out_pos] = rc->cache + (uint8_t)(rc->low >> 32); - ++*out_pos; - rc->cache = 0xFF; - - } while (--rc->cache_size != 0); - - rc->cache = (rc->low >> 24) & 0xFF; - } - - ++rc->cache_size; - rc->low = (rc->low & 0x00FFFFFF) << RC_SHIFT_BITS; - - return false; -} - - -static inline bool -rc_encode(lzma_range_encoder *rc, - uint8_t *out, size_t *out_pos, size_t out_size) -{ - assert(rc->count <= RC_SYMBOLS_MAX); - - while (rc->pos < rc->count) { - // Normalize - if (rc->range < RC_TOP_VALUE) { - if (rc_shift_low(rc, out, out_pos, out_size)) - return true; - - rc->range <<= RC_SHIFT_BITS; - } - - // Encode a bit - switch (rc->symbols[rc->pos]) { - case RC_BIT_0: { - probability prob = *rc->probs[rc->pos]; - rc->range = (rc->range >> RC_BIT_MODEL_TOTAL_BITS) - * prob; - prob += (RC_BIT_MODEL_TOTAL - prob) >> RC_MOVE_BITS; - *rc->probs[rc->pos] = prob; - break; - } - - case RC_BIT_1: { - probability prob = *rc->probs[rc->pos]; - const uint32_t bound = prob * (rc->range - >> RC_BIT_MODEL_TOTAL_BITS); - rc->low += bound; - rc->range -= bound; - prob -= prob >> RC_MOVE_BITS; - *rc->probs[rc->pos] = prob; - break; - } - - case RC_DIRECT_0: - rc->range >>= 1; - break; - - case RC_DIRECT_1: - rc->range >>= 1; - rc->low += rc->range; - break; - - case RC_FLUSH: - // Prevent further normalizations. - rc->range = UINT32_MAX; - - // Flush the last five bytes (see rc_flush()). - do { - if (rc_shift_low(rc, out, out_pos, out_size)) - return true; - } while (++rc->pos < rc->count); - - // Reset the range encoder so we are ready to continue - // encoding if we weren't finishing the stream. - rc_reset(rc); - return false; - - default: - assert(0); - break; - } - - ++rc->pos; - } - - rc->count = 0; - rc->pos = 0; - - return false; -} - - -static inline uint64_t -rc_pending(const lzma_range_encoder *rc) -{ - return rc->cache_size + 5 - 1; -} - -#endif diff --git a/deps/lzma/liblzma/simple/Makefile.inc b/deps/lzma/liblzma/simple/Makefile.inc deleted file mode 100644 index 8a5e2d7..0000000 --- a/deps/lzma/liblzma/simple/Makefile.inc +++ /dev/null @@ -1,47 +0,0 @@ -## -## Author: Lasse Collin -## -## This file has been put into the public domain. -## You can do whatever you want with this file. -## - -liblzma_la_SOURCES += \ - simple/simple_coder.c \ - simple/simple_coder.h \ - simple/simple_private.h - -if COND_ENCODER_SIMPLE -liblzma_la_SOURCES += \ - simple/simple_encoder.c \ - simple/simple_encoder.h -endif - -if COND_DECODER_SIMPLE -liblzma_la_SOURCES += \ - simple/simple_decoder.c \ - simple/simple_decoder.h -endif - -if COND_FILTER_X86 -liblzma_la_SOURCES += simple/x86.c -endif - -if COND_FILTER_POWERPC -liblzma_la_SOURCES += simple/powerpc.c -endif - -if COND_FILTER_IA64 -liblzma_la_SOURCES += simple/ia64.c -endif - -if COND_FILTER_ARM -liblzma_la_SOURCES += simple/arm.c -endif - -if COND_FILTER_ARMTHUMB -liblzma_la_SOURCES += simple/armthumb.c -endif - -if COND_FILTER_SPARC -liblzma_la_SOURCES += simple/sparc.c -endif diff --git a/deps/lzma/liblzma/simple/arm.c b/deps/lzma/liblzma/simple/arm.c deleted file mode 100644 index a84702a..0000000 --- a/deps/lzma/liblzma/simple/arm.c +++ /dev/null @@ -1,69 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file arm.c -/// \brief Filter for ARM binaries -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "simple_private.h" - - -static size_t -arm_code(lzma_simple *simple lzma_attribute((__unused__)), - uint32_t now_pos, bool is_encoder, - uint8_t *buffer, size_t size) -{ - size_t i; - for (i = 0; i + 4 <= size; i += 4) { - if (buffer[i + 3] == 0xEB) { - uint32_t src = (buffer[i + 2] << 16) - | (buffer[i + 1] << 8) - | (buffer[i + 0]); - src <<= 2; - - uint32_t dest; - if (is_encoder) - dest = now_pos + (uint32_t)(i) + 8 + src; - else - dest = src - (now_pos + (uint32_t)(i) + 8); - - dest >>= 2; - buffer[i + 2] = (dest >> 16); - buffer[i + 1] = (dest >> 8); - buffer[i + 0] = dest; - } - } - - return i; -} - - -static lzma_ret -arm_coder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters, bool is_encoder) -{ - return lzma_simple_coder_init(next, allocator, filters, - &arm_code, 0, 4, 4, is_encoder); -} - - -extern lzma_ret -lzma_simple_arm_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters) -{ - return arm_coder_init(next, allocator, filters, true); -} - - -extern lzma_ret -lzma_simple_arm_decoder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters) -{ - return arm_coder_init(next, allocator, filters, false); -} diff --git a/deps/lzma/liblzma/simple/armthumb.c b/deps/lzma/liblzma/simple/armthumb.c deleted file mode 100644 index 4b49175..0000000 --- a/deps/lzma/liblzma/simple/armthumb.c +++ /dev/null @@ -1,74 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file armthumb.c -/// \brief Filter for ARM-Thumb binaries -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "simple_private.h" - - -static size_t -armthumb_code(lzma_simple *simple lzma_attribute((__unused__)), - uint32_t now_pos, bool is_encoder, - uint8_t *buffer, size_t size) -{ - size_t i; - for (i = 0; i + 4 <= size; i += 2) { - if ((buffer[i + 1] & 0xF8) == 0xF0 - && (buffer[i + 3] & 0xF8) == 0xF8) { - uint32_t src = ((buffer[i + 1] & 0x7) << 19) - | (buffer[i + 0] << 11) - | ((buffer[i + 3] & 0x7) << 8) - | (buffer[i + 2]); - - src <<= 1; - - uint32_t dest; - if (is_encoder) - dest = now_pos + (uint32_t)(i) + 4 + src; - else - dest = src - (now_pos + (uint32_t)(i) + 4); - - dest >>= 1; - buffer[i + 1] = 0xF0 | ((dest >> 19) & 0x7); - buffer[i + 0] = (dest >> 11); - buffer[i + 3] = 0xF8 | ((dest >> 8) & 0x7); - buffer[i + 2] = (dest); - i += 2; - } - } - - return i; -} - - -static lzma_ret -armthumb_coder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters, bool is_encoder) -{ - return lzma_simple_coder_init(next, allocator, filters, - &armthumb_code, 0, 4, 2, is_encoder); -} - - -extern lzma_ret -lzma_simple_armthumb_encoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters) -{ - return armthumb_coder_init(next, allocator, filters, true); -} - - -extern lzma_ret -lzma_simple_armthumb_decoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters) -{ - return armthumb_coder_init(next, allocator, filters, false); -} diff --git a/deps/lzma/liblzma/simple/ia64.c b/deps/lzma/liblzma/simple/ia64.c deleted file mode 100644 index ce3692b..0000000 --- a/deps/lzma/liblzma/simple/ia64.c +++ /dev/null @@ -1,110 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file ia64.c -/// \brief Filter for IA64 (Itanium) binaries -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "simple_private.h" - - -static size_t -ia64_code(lzma_simple *simple lzma_attribute((__unused__)), - uint32_t now_pos, bool is_encoder, - uint8_t *buffer, size_t size) -{ - static const uint32_t BRANCH_TABLE[32] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 4, 4, 6, 6, 0, 0, 7, 7, - 4, 4, 0, 0, 4, 4, 0, 0 - }; - - size_t i; - for (i = 0; i + 16 <= size; i += 16) { - const uint32_t instr_template = buffer[i] & 0x1F; - const uint32_t mask = BRANCH_TABLE[instr_template]; - uint32_t bit_pos = 5; - - for (size_t slot = 0; slot < 3; ++slot, bit_pos += 41) { - if (((mask >> slot) & 1) == 0) - continue; - - const size_t byte_pos = (bit_pos >> 3); - const uint32_t bit_res = bit_pos & 0x7; - uint64_t instruction = 0; - - for (size_t j = 0; j < 6; ++j) - instruction += (uint64_t)( - buffer[i + j + byte_pos]) - << (8 * j); - - uint64_t inst_norm = instruction >> bit_res; - - if (((inst_norm >> 37) & 0xF) == 0x5 - && ((inst_norm >> 9) & 0x7) == 0 - /* && (inst_norm & 0x3F)== 0 */ - ) { - uint32_t src = (uint32_t)( - (inst_norm >> 13) & 0xFFFFF); - src |= ((inst_norm >> 36) & 1) << 20; - - src <<= 4; - - uint32_t dest; - if (is_encoder) - dest = now_pos + (uint32_t)(i) + src; - else - dest = src - (now_pos + (uint32_t)(i)); - - dest >>= 4; - - inst_norm &= ~((uint64_t)(0x8FFFFF) << 13); - inst_norm |= (uint64_t)(dest & 0xFFFFF) << 13; - inst_norm |= (uint64_t)(dest & 0x100000) - << (36 - 20); - - instruction &= (1 << bit_res) - 1; - instruction |= (inst_norm << bit_res); - - for (size_t j = 0; j < 6; j++) - buffer[i + j + byte_pos] = (uint8_t)( - instruction - >> (8 * j)); - } - } - } - - return i; -} - - -static lzma_ret -ia64_coder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters, bool is_encoder) -{ - return lzma_simple_coder_init(next, allocator, filters, - &ia64_code, 0, 16, 16, is_encoder); -} - - -extern lzma_ret -lzma_simple_ia64_encoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters) -{ - return ia64_coder_init(next, allocator, filters, true); -} - - -extern lzma_ret -lzma_simple_ia64_decoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters) -{ - return ia64_coder_init(next, allocator, filters, false); -} diff --git a/deps/lzma/liblzma/simple/powerpc.c b/deps/lzma/liblzma/simple/powerpc.c deleted file mode 100644 index 6f83511..0000000 --- a/deps/lzma/liblzma/simple/powerpc.c +++ /dev/null @@ -1,73 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file powerpc.c -/// \brief Filter for PowerPC (big endian) binaries -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "simple_private.h" - - -static size_t -powerpc_code(lzma_simple *simple lzma_attribute((__unused__)), - uint32_t now_pos, bool is_encoder, - uint8_t *buffer, size_t size) -{ - size_t i; - for (i = 0; i + 4 <= size; i += 4) { - // PowerPC branch 6(48) 24(Offset) 1(Abs) 1(Link) - if ((buffer[i] >> 2) == 0x12 - && ((buffer[i + 3] & 3) == 1)) { - - const uint32_t src = ((buffer[i + 0] & 3) << 24) - | (buffer[i + 1] << 16) - | (buffer[i + 2] << 8) - | (buffer[i + 3] & (~3)); - - uint32_t dest; - if (is_encoder) - dest = now_pos + (uint32_t)(i) + src; - else - dest = src - (now_pos + (uint32_t)(i)); - - buffer[i + 0] = 0x48 | ((dest >> 24) & 0x03); - buffer[i + 1] = (dest >> 16); - buffer[i + 2] = (dest >> 8); - buffer[i + 3] &= 0x03; - buffer[i + 3] |= dest; - } - } - - return i; -} - - -static lzma_ret -powerpc_coder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters, bool is_encoder) -{ - return lzma_simple_coder_init(next, allocator, filters, - &powerpc_code, 0, 4, 4, is_encoder); -} - - -extern lzma_ret -lzma_simple_powerpc_encoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters) -{ - return powerpc_coder_init(next, allocator, filters, true); -} - - -extern lzma_ret -lzma_simple_powerpc_decoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters) -{ - return powerpc_coder_init(next, allocator, filters, false); -} diff --git a/deps/lzma/liblzma/simple/simple_coder.c b/deps/lzma/liblzma/simple/simple_coder.c deleted file mode 100644 index a02b039..0000000 --- a/deps/lzma/liblzma/simple/simple_coder.c +++ /dev/null @@ -1,277 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file simple_coder.c -/// \brief Wrapper for simple filters -/// -/// Simple filters don't change the size of the data i.e. number of bytes -/// in equals the number of bytes out. -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "simple_private.h" - - -/// Copied or encodes/decodes more data to out[]. -static lzma_ret -copy_or_code(lzma_coder *coder, lzma_allocator *allocator, - const uint8_t *restrict in, size_t *restrict in_pos, - size_t in_size, uint8_t *restrict out, - size_t *restrict out_pos, size_t out_size, lzma_action action) -{ - assert(!coder->end_was_reached); - - if (coder->next.code == NULL) { - lzma_bufcpy(in, in_pos, in_size, out, out_pos, out_size); - - // Check if end of stream was reached. - if (coder->is_encoder && action == LZMA_FINISH - && *in_pos == in_size) - coder->end_was_reached = true; - - } else { - // Call the next coder in the chain to provide us some data. - const lzma_ret ret = coder->next.code( - coder->next.coder, allocator, - in, in_pos, in_size, - out, out_pos, out_size, action); - - if (ret == LZMA_STREAM_END) { - assert(!coder->is_encoder - || action == LZMA_FINISH); - coder->end_was_reached = true; - - } else if (ret != LZMA_OK) { - return ret; - } - } - - return LZMA_OK; -} - - -static size_t -call_filter(lzma_coder *coder, uint8_t *buffer, size_t size) -{ - const size_t filtered = coder->filter(coder->simple, - coder->now_pos, coder->is_encoder, - buffer, size); - coder->now_pos += filtered; - return filtered; -} - - -static lzma_ret -simple_code(lzma_coder *coder, lzma_allocator *allocator, - const uint8_t *restrict in, size_t *restrict in_pos, - size_t in_size, uint8_t *restrict out, - size_t *restrict out_pos, size_t out_size, lzma_action action) -{ - // TODO: Add partial support for LZMA_SYNC_FLUSH. We can support it - // in cases when the filter is able to filter everything. With most - // simple filters it can be done at offset that is a multiple of 2, - // 4, or 16. With x86 filter, it needs good luck, and thus cannot - // be made to work predictably. - if (action == LZMA_SYNC_FLUSH) - return LZMA_OPTIONS_ERROR; - - // Flush already filtered data from coder->buffer[] to out[]. - if (coder->pos < coder->filtered) { - lzma_bufcpy(coder->buffer, &coder->pos, coder->filtered, - out, out_pos, out_size); - - // If we couldn't flush all the filtered data, return to - // application immediately. - if (coder->pos < coder->filtered) - return LZMA_OK; - - if (coder->end_was_reached) { - assert(coder->filtered == coder->size); - return LZMA_STREAM_END; - } - } - - // If we get here, there is no filtered data left in the buffer. - coder->filtered = 0; - - assert(!coder->end_was_reached); - - // If there is more output space left than there is unfiltered data - // in coder->buffer[], flush coder->buffer[] to out[], and copy/code - // more data to out[] hopefully filling it completely. Then filter - // the data in out[]. This step is where most of the data gets - // filtered if the buffer sizes used by the application are reasonable. - const size_t out_avail = out_size - *out_pos; - const size_t buf_avail = coder->size - coder->pos; - if (out_avail > buf_avail || buf_avail == 0) { - // Store the old position so that we know from which byte - // to start filtering. - const size_t out_start = *out_pos; - - // Flush data from coder->buffer[] to out[], but don't reset - // coder->pos and coder->size yet. This way the coder can be - // restarted if the next filter in the chain returns e.g. - // LZMA_MEM_ERROR. - memcpy(out + *out_pos, coder->buffer + coder->pos, buf_avail); - *out_pos += buf_avail; - - // Copy/Encode/Decode more data to out[]. - { - const lzma_ret ret = copy_or_code(coder, allocator, - in, in_pos, in_size, - out, out_pos, out_size, action); - assert(ret != LZMA_STREAM_END); - if (ret != LZMA_OK) - return ret; - } - - // Filter out[]. - const size_t size = *out_pos - out_start; - const size_t filtered = call_filter( - coder, out + out_start, size); - - const size_t unfiltered = size - filtered; - assert(unfiltered <= coder->allocated / 2); - - // Now we can update coder->pos and coder->size, because - // the next coder in the chain (if any) was successful. - coder->pos = 0; - coder->size = unfiltered; - - if (coder->end_was_reached) { - // The last byte has been copied to out[] already. - // They are left as is. - coder->size = 0; - - } else if (unfiltered > 0) { - // There is unfiltered data left in out[]. Copy it to - // coder->buffer[] and rewind *out_pos appropriately. - *out_pos -= unfiltered; - memcpy(coder->buffer, out + *out_pos, unfiltered); - } - } else if (coder->pos > 0) { - memmove(coder->buffer, coder->buffer + coder->pos, buf_avail); - coder->size -= coder->pos; - coder->pos = 0; - } - - assert(coder->pos == 0); - - // If coder->buffer[] isn't empty, try to fill it by copying/decoding - // more data. Then filter coder->buffer[] and copy the successfully - // filtered data to out[]. It is probable, that some filtered and - // unfiltered data will be left to coder->buffer[]. - if (coder->size > 0) { - { - const lzma_ret ret = copy_or_code(coder, allocator, - in, in_pos, in_size, - coder->buffer, &coder->size, - coder->allocated, action); - assert(ret != LZMA_STREAM_END); - if (ret != LZMA_OK) - return ret; - } - - coder->filtered = call_filter( - coder, coder->buffer, coder->size); - - // Everything is considered to be filtered if coder->buffer[] - // contains the last bytes of the data. - if (coder->end_was_reached) - coder->filtered = coder->size; - - // Flush as much as possible. - lzma_bufcpy(coder->buffer, &coder->pos, coder->filtered, - out, out_pos, out_size); - } - - // Check if we got everything done. - if (coder->end_was_reached && coder->pos == coder->size) - return LZMA_STREAM_END; - - return LZMA_OK; -} - - -static void -simple_coder_end(lzma_coder *coder, lzma_allocator *allocator) -{ - lzma_next_end(&coder->next, allocator); - lzma_free(coder->simple, allocator); - lzma_free(coder, allocator); - return; -} - - -static lzma_ret -simple_coder_update(lzma_coder *coder, lzma_allocator *allocator, - const lzma_filter *filters_null lzma_attribute((__unused__)), - const lzma_filter *reversed_filters) -{ - // No update support, just call the next filter in the chain. - return lzma_next_filter_update( - &coder->next, allocator, reversed_filters + 1); -} - - -extern lzma_ret -lzma_simple_coder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters, - size_t (*filter)(lzma_simple *simple, uint32_t now_pos, - bool is_encoder, uint8_t *buffer, size_t size), - size_t simple_size, size_t unfiltered_max, - uint32_t alignment, bool is_encoder) -{ - // Allocate memory for the lzma_coder structure if needed. - if (next->coder == NULL) { - // Here we allocate space also for the temporary buffer. We - // need twice the size of unfiltered_max, because then it - // is always possible to filter at least unfiltered_max bytes - // more data in coder->buffer[] if it can be filled completely. - next->coder = lzma_alloc(sizeof(lzma_coder) - + 2 * unfiltered_max, allocator); - if (next->coder == NULL) - return LZMA_MEM_ERROR; - - next->code = &simple_code; - next->end = &simple_coder_end; - next->update = &simple_coder_update; - - next->coder->next = LZMA_NEXT_CODER_INIT; - next->coder->filter = filter; - next->coder->allocated = 2 * unfiltered_max; - - // Allocate memory for filter-specific data structure. - if (simple_size > 0) { - next->coder->simple = lzma_alloc( - simple_size, allocator); - if (next->coder->simple == NULL) - return LZMA_MEM_ERROR; - } else { - next->coder->simple = NULL; - } - } - - if (filters[0].options != NULL) { - const lzma_options_bcj *simple = filters[0].options; - next->coder->now_pos = simple->start_offset; - if (next->coder->now_pos & (alignment - 1)) - return LZMA_OPTIONS_ERROR; - } else { - next->coder->now_pos = 0; - } - - // Reset variables. - next->coder->is_encoder = is_encoder; - next->coder->end_was_reached = false; - next->coder->pos = 0; - next->coder->filtered = 0; - next->coder->size = 0; - - return lzma_next_filter_init( - &next->coder->next, allocator, filters + 1); -} diff --git a/deps/lzma/liblzma/simple/simple_coder.h b/deps/lzma/liblzma/simple/simple_coder.h deleted file mode 100644 index 0952fad..0000000 --- a/deps/lzma/liblzma/simple/simple_coder.h +++ /dev/null @@ -1,60 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file simple_coder.h -/// \brief Wrapper for simple filters -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_SIMPLE_CODER_H -#define LZMA_SIMPLE_CODER_H - -#include "common.h" - - -extern lzma_ret lzma_simple_x86_encoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters); - -extern lzma_ret lzma_simple_x86_decoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters); - - -extern lzma_ret lzma_simple_powerpc_encoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters); - -extern lzma_ret lzma_simple_powerpc_decoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters); - - -extern lzma_ret lzma_simple_ia64_encoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters); - -extern lzma_ret lzma_simple_ia64_decoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters); - - -extern lzma_ret lzma_simple_arm_encoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters); - -extern lzma_ret lzma_simple_arm_decoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters); - - -extern lzma_ret lzma_simple_armthumb_encoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters); - -extern lzma_ret lzma_simple_armthumb_decoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters); - - -extern lzma_ret lzma_simple_sparc_encoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters); - -extern lzma_ret lzma_simple_sparc_decoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters); - -#endif diff --git a/deps/lzma/liblzma/simple/simple_decoder.c b/deps/lzma/liblzma/simple/simple_decoder.c deleted file mode 100644 index 0beccd3..0000000 --- a/deps/lzma/liblzma/simple/simple_decoder.c +++ /dev/null @@ -1,40 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file simple_decoder.c -/// \brief Properties decoder for simple filters -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "simple_decoder.h" - - -extern lzma_ret -lzma_simple_props_decode(void **options, lzma_allocator *allocator, - const uint8_t *props, size_t props_size) -{ - if (props_size == 0) - return LZMA_OK; - - if (props_size != 4) - return LZMA_OPTIONS_ERROR; - - lzma_options_bcj *opt = lzma_alloc( - sizeof(lzma_options_bcj), allocator); - if (opt == NULL) - return LZMA_MEM_ERROR; - - opt->start_offset = unaligned_read32le(props); - - // Don't leave an options structure allocated if start_offset is zero. - if (opt->start_offset == 0) - lzma_free(opt, allocator); - else - *options = opt; - - return LZMA_OK; -} diff --git a/deps/lzma/liblzma/simple/simple_decoder.h b/deps/lzma/liblzma/simple/simple_decoder.h deleted file mode 100644 index b8bf590..0000000 --- a/deps/lzma/liblzma/simple/simple_decoder.h +++ /dev/null @@ -1,22 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file simple_decoder.h -/// \brief Properties decoder for simple filters -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_SIMPLE_DECODER_H -#define LZMA_SIMPLE_DECODER_H - -#include "simple_coder.h" - -extern lzma_ret lzma_simple_props_decode( - void **options, lzma_allocator *allocator, - const uint8_t *props, size_t props_size); - -#endif diff --git a/deps/lzma/liblzma/simple/simple_encoder.c b/deps/lzma/liblzma/simple/simple_encoder.c deleted file mode 100644 index 8aa463b..0000000 --- a/deps/lzma/liblzma/simple/simple_encoder.c +++ /dev/null @@ -1,38 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file simple_encoder.c -/// \brief Properties encoder for simple filters -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "simple_encoder.h" - - -extern lzma_ret -lzma_simple_props_size(uint32_t *size, const void *options) -{ - const lzma_options_bcj *const opt = options; - *size = (opt == NULL || opt->start_offset == 0) ? 0 : 4; - return LZMA_OK; -} - - -extern lzma_ret -lzma_simple_props_encode(const void *options, uint8_t *out) -{ - const lzma_options_bcj *const opt = options; - - // The default start offset is zero, so we don't need to store any - // options unless the start offset is non-zero. - if (opt == NULL || opt->start_offset == 0) - return LZMA_OK; - - unaligned_write32le(out, opt->start_offset); - - return LZMA_OK; -} diff --git a/deps/lzma/liblzma/simple/simple_encoder.h b/deps/lzma/liblzma/simple/simple_encoder.h deleted file mode 100644 index 1cee482..0000000 --- a/deps/lzma/liblzma/simple/simple_encoder.h +++ /dev/null @@ -1,23 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file simple_encoder.c -/// \brief Properties encoder for simple filters -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_SIMPLE_ENCODER_H -#define LZMA_SIMPLE_ENCODER_H - -#include "simple_coder.h" - - -extern lzma_ret lzma_simple_props_size(uint32_t *size, const void *options); - -extern lzma_ret lzma_simple_props_encode(const void *options, uint8_t *out); - -#endif diff --git a/deps/lzma/liblzma/simple/simple_private.h b/deps/lzma/liblzma/simple/simple_private.h deleted file mode 100644 index fcf9f7c..0000000 --- a/deps/lzma/liblzma/simple/simple_private.h +++ /dev/null @@ -1,75 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file simple_private.h -/// \brief Private definitions for so called simple filters -// -// Author: Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef LZMA_SIMPLE_PRIVATE_H -#define LZMA_SIMPLE_PRIVATE_H - -#include "simple_coder.h" - - -typedef struct lzma_simple_s lzma_simple; - -struct lzma_coder_s { - /// Next filter in the chain - lzma_next_coder next; - - /// True if the next coder in the chain has returned LZMA_STREAM_END. - bool end_was_reached; - - /// True if filter() should encode the data; false to decode. - /// Currently all simple filters use the same function for encoding - /// and decoding, because the difference between encoders and decoders - /// is very small. - bool is_encoder; - - /// Pointer to filter-specific function, which does - /// the actual filtering. - size_t (*filter)(lzma_simple *simple, uint32_t now_pos, - bool is_encoder, uint8_t *buffer, size_t size); - - /// Pointer to filter-specific data, or NULL if filter doesn't need - /// any extra data. - lzma_simple *simple; - - /// The lowest 32 bits of the current position in the data. Most - /// filters need this to do conversions between absolute and relative - /// addresses. - uint32_t now_pos; - - /// Size of the memory allocated for the buffer. - size_t allocated; - - /// Flushing position in the temporary buffer. buffer[pos] is the - /// next byte to be copied to out[]. - size_t pos; - - /// buffer[filtered] is the first unfiltered byte. When pos is smaller - /// than filtered, there is unflushed filtered data in the buffer. - size_t filtered; - - /// Total number of bytes (both filtered and unfiltered) currently - /// in the temporary buffer. - size_t size; - - /// Temporary buffer - uint8_t buffer[]; -}; - - -extern lzma_ret lzma_simple_coder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters, - size_t (*filter)(lzma_simple *simple, uint32_t now_pos, - bool is_encoder, uint8_t *buffer, size_t size), - size_t simple_size, size_t unfiltered_max, - uint32_t alignment, bool is_encoder); - -#endif diff --git a/deps/lzma/liblzma/simple/sparc.c b/deps/lzma/liblzma/simple/sparc.c deleted file mode 100644 index 8270d6a..0000000 --- a/deps/lzma/liblzma/simple/sparc.c +++ /dev/null @@ -1,81 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file sparc.c -/// \brief Filter for SPARC binaries -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "simple_private.h" - - -static size_t -sparc_code(lzma_simple *simple lzma_attribute((__unused__)), - uint32_t now_pos, bool is_encoder, - uint8_t *buffer, size_t size) -{ - size_t i; - for (i = 0; i + 4 <= size; i += 4) { - - if ((buffer[i] == 0x40 && (buffer[i + 1] & 0xC0) == 0x00) - || (buffer[i] == 0x7F - && (buffer[i + 1] & 0xC0) == 0xC0)) { - - uint32_t src = ((uint32_t)buffer[i + 0] << 24) - | ((uint32_t)buffer[i + 1] << 16) - | ((uint32_t)buffer[i + 2] << 8) - | ((uint32_t)buffer[i + 3]); - - src <<= 2; - - uint32_t dest; - if (is_encoder) - dest = now_pos + (uint32_t)(i) + src; - else - dest = src - (now_pos + (uint32_t)(i)); - - dest >>= 2; - - dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) - | (dest & 0x3FFFFF) - | 0x40000000; - - buffer[i + 0] = (uint8_t)(dest >> 24); - buffer[i + 1] = (uint8_t)(dest >> 16); - buffer[i + 2] = (uint8_t)(dest >> 8); - buffer[i + 3] = (uint8_t)(dest); - } - } - - return i; -} - - -static lzma_ret -sparc_coder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters, bool is_encoder) -{ - return lzma_simple_coder_init(next, allocator, filters, - &sparc_code, 0, 4, 4, is_encoder); -} - - -extern lzma_ret -lzma_simple_sparc_encoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters) -{ - return sparc_coder_init(next, allocator, filters, true); -} - - -extern lzma_ret -lzma_simple_sparc_decoder_init(lzma_next_coder *next, - lzma_allocator *allocator, const lzma_filter_info *filters) -{ - return sparc_coder_init(next, allocator, filters, false); -} diff --git a/deps/lzma/liblzma/simple/x86.c b/deps/lzma/liblzma/simple/x86.c deleted file mode 100644 index 5d1509b..0000000 --- a/deps/lzma/liblzma/simple/x86.c +++ /dev/null @@ -1,154 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -/// \file x86.c -/// \brief Filter for x86 binaries (BCJ filter) -/// -// Authors: Igor Pavlov -// Lasse Collin -// -// This file has been put into the public domain. -// You can do whatever you want with this file. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "simple_private.h" - - -#define Test86MSByte(b) ((b) == 0 || (b) == 0xFF) - - -struct lzma_simple_s { - uint32_t prev_mask; - uint32_t prev_pos; -}; - - -static size_t -x86_code(lzma_simple *simple, uint32_t now_pos, bool is_encoder, - uint8_t *buffer, size_t size) -{ - static const bool MASK_TO_ALLOWED_STATUS[8] - = { true, true, true, false, true, false, false, false }; - - static const uint32_t MASK_TO_BIT_NUMBER[8] - = { 0, 1, 2, 2, 3, 3, 3, 3 }; - - uint32_t prev_mask = simple->prev_mask; - uint32_t prev_pos = simple->prev_pos; - - if (size < 5) - return 0; - - if (now_pos - prev_pos > 5) - prev_pos = now_pos - 5; - - const size_t limit = size - 5; - size_t buffer_pos = 0; - - while (buffer_pos <= limit) { - uint8_t b = buffer[buffer_pos]; - if (b != 0xE8 && b != 0xE9) { - ++buffer_pos; - continue; - } - - const uint32_t offset = now_pos + (uint32_t)(buffer_pos) - - prev_pos; - prev_pos = now_pos + (uint32_t)(buffer_pos); - - if (offset > 5) { - prev_mask = 0; - } else { - for (uint32_t i = 0; i < offset; ++i) { - prev_mask &= 0x77; - prev_mask <<= 1; - } - } - - b = buffer[buffer_pos + 4]; - - if (Test86MSByte(b) - && MASK_TO_ALLOWED_STATUS[(prev_mask >> 1) & 0x7] - && (prev_mask >> 1) < 0x10) { - - uint32_t src = ((uint32_t)(b) << 24) - | ((uint32_t)(buffer[buffer_pos + 3]) << 16) - | ((uint32_t)(buffer[buffer_pos + 2]) << 8) - | (buffer[buffer_pos + 1]); - - uint32_t dest; - while (true) { - if (is_encoder) - dest = src + (now_pos + (uint32_t)( - buffer_pos) + 5); - else - dest = src - (now_pos + (uint32_t)( - buffer_pos) + 5); - - if (prev_mask == 0) - break; - - const uint32_t i = MASK_TO_BIT_NUMBER[ - prev_mask >> 1]; - - b = (uint8_t)(dest >> (24 - i * 8)); - - if (!Test86MSByte(b)) - break; - - src = dest ^ ((1 << (32 - i * 8)) - 1); - } - - buffer[buffer_pos + 4] - = (uint8_t)(~(((dest >> 24) & 1) - 1)); - buffer[buffer_pos + 3] = (uint8_t)(dest >> 16); - buffer[buffer_pos + 2] = (uint8_t)(dest >> 8); - buffer[buffer_pos + 1] = (uint8_t)(dest); - buffer_pos += 5; - prev_mask = 0; - - } else { - ++buffer_pos; - prev_mask |= 1; - if (Test86MSByte(b)) - prev_mask |= 0x10; - } - } - - simple->prev_mask = prev_mask; - simple->prev_pos = prev_pos; - - return buffer_pos; -} - - -static lzma_ret -x86_coder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters, bool is_encoder) -{ - const lzma_ret ret = lzma_simple_coder_init(next, allocator, filters, - &x86_code, sizeof(lzma_simple), 5, 1, is_encoder); - - if (ret == LZMA_OK) { - next->coder->simple->prev_mask = 0; - next->coder->simple->prev_pos = (uint32_t)(-5); - } - - return ret; -} - - -extern lzma_ret -lzma_simple_x86_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters) -{ - return x86_coder_init(next, allocator, filters, true); -} - - -extern lzma_ret -lzma_simple_x86_decoder_init(lzma_next_coder *next, lzma_allocator *allocator, - const lzma_filter_info *filters) -{ - return x86_coder_init(next, allocator, filters, false); -} diff --git a/deps/lzma/version.h b/deps/lzma/version.h deleted file mode 100644 index 79627a5..0000000 --- a/deps/lzma/version.h +++ /dev/null @@ -1,8 +0,0 @@ -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "XZ Utils 5.0.7" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "5.0.7" - -/* Version number of package */ -#define VERSION "5.0.7" \ No newline at end of file diff --git a/deps/w32-pthreads/ANNOUNCE b/deps/w32-pthreads/ANNOUNCE deleted file mode 100644 index 950c86f..0000000 --- a/deps/w32-pthreads/ANNOUNCE +++ /dev/null @@ -1,483 +0,0 @@ -PTHREADS-WIN32 RELEASE 2.9.0 (2012-05-25) ------------------------------------------ -Web Site: http://sourceware.org/pthreads-win32/ -FTP Site: ftp://sourceware.org/pub/pthreads-win32 -Maintainer: Ross Johnson - - -We are pleased to announce the availability of a new release of -Pthreads-win32, an Open Source Software implementation of the -Threads component of the POSIX 1003.1 2001 Standard for Microsoft's -Win32 environment. Some functions from other sections of POSIX -1003.1 2001 are also supported including semaphores and scheduling -functions. - -Some common non-portable functions are also implemented for -additional compatibility, as are a few functions specific -to pthreads-win32 for easier integration with Win32 applications. - -Pthreads-win32 is free software, distributed under the GNU Lesser -General Public License (LGPL). - - -Acknowledgements ----------------- -This library is based originally on a Win32 pthreads -implementation contributed by John Bossom. - -The implementation of Condition Variables uses algorithms developed -by Alexander Terekhov and Louis Thomas. - -The implementation of POSIX mutexes has been improved by Thomas Pfaff -and later by Alexander Terekhov. - -The implementation of Spinlocks and Barriers was contributed -by Ross Johnson. - -The implementation of read/write locks was contributed by -Aurelio Medina and improved by Alexander Terekhov. - -Many others have contributed significant time and effort to solve crutial -problems in order to make the library workable, robust and reliable. - -Thanks to Xavier Leroy for granting permission to use and modify his -LinuxThreads manual pages. - -Thanks to The Open Group for making the Single Unix Specification -publicly available - many of the manual pages included in the package -were extracted from it. - -There is also a separate CONTRIBUTORS file. This file and others are -on the web site: - - http://sourceware.org/pthreads-win32 - -As much as possible, the ChangeLog file acknowledges contributions to the -code base in more detail. - - -Changes since the last release ------------------------------- -These are now documented in the NEWS file. -See the ChangeLog file also. - - -Known Bugs ----------- -These are now documented in the BUGS file. - - -Level of standards conformance ------------------------------- - -The following POSIX 1003.1 2001 options are defined and set to 200112L: - - _POSIX_THREADS - _POSIX_THREAD_SAFE_FUNCTIONS - _POSIX_THREAD_ATTR_STACKSIZE - _POSIX_THREAD_PRIORITY_SCHEDULING - _POSIX_SEMAPHORES - _POSIX_READER_WRITER_LOCKS - _POSIX_SPIN_LOCKS - _POSIX_BARRIERS - - -The following POSIX 1003.1 2001 options are defined and set to -1: - - _POSIX_THREAD_ATTR_STACKADDR - _POSIX_THREAD_PRIO_INHERIT - _POSIX_THREAD_PRIO_PROTECT - _POSIX_THREAD_PROCESS_SHARED - - -The following POSIX 1003.1 2001 limits are defined and set: - - _POSIX_THREAD_THREADS_MAX - _POSIX_SEM_VALUE_MAX - _POSIX_SEM_NSEMS_MAX - _POSIX_THREAD_KEYS_MAX - _POSIX_THREAD_DESTRUCTOR_ITERATIONS - PTHREAD_STACK_MIN - PTHREAD_THREADS_MAX - SEM_VALUE_MAX - SEM_NSEMS_MAX - PTHREAD_KEYS_MAX - PTHREAD_DESTRUCTOR_ITERATIONS - - -The following functions are implemented: - - --------------------------- - PThreads - --------------------------- - pthread_attr_init - pthread_attr_destroy - pthread_attr_getdetachstate - pthread_attr_getstackaddr - pthread_attr_getstacksize - pthread_attr_setdetachstate - pthread_attr_setstackaddr - pthread_attr_setstacksize - - pthread_create - pthread_detach - pthread_equal - pthread_exit - pthread_join - pthread_once - pthread_self - - pthread_cancel - pthread_cleanup_pop - pthread_cleanup_push - pthread_setcancelstate - pthread_setcanceltype - pthread_testcancel - - --------------------------- - Thread Specific Data - --------------------------- - pthread_key_create - pthread_key_delete - pthread_setspecific - pthread_getspecific - - --------------------------- - Mutexes - --------------------------- - pthread_mutexattr_init - pthread_mutexattr_destroy - pthread_mutexattr_getpshared - pthread_mutexattr_setpshared - pthread_mutexattr_gettype - pthread_mutexattr_settype (types: PTHREAD_MUTEX_DEFAULT - PTHREAD_MUTEX_NORMAL - PTHREAD_MUTEX_ERRORCHECK - PTHREAD_MUTEX_RECURSIVE ) - pthread_mutexattr_getrobust - pthread_mutexattr_setrobust (values: PTHREAD_MUTEX_STALLED - PTHREAD_MUTEX_ROBUST) - pthread_mutex_init - pthread_mutex_destroy - pthread_mutex_lock - pthread_mutex_trylock - pthread_mutex_timedlock - pthread_mutex_unlock - pthread_mutex_consistent - - --------------------------- - Condition Variables - --------------------------- - pthread_condattr_init - pthread_condattr_destroy - pthread_condattr_getpshared - pthread_condattr_setpshared - - pthread_cond_init - pthread_cond_destroy - pthread_cond_wait - pthread_cond_timedwait - pthread_cond_signal - pthread_cond_broadcast - - --------------------------- - Read/Write Locks - --------------------------- - pthread_rwlock_init - pthread_rwlock_destroy - pthread_rwlock_tryrdlock - pthread_rwlock_trywrlock - pthread_rwlock_rdlock - pthread_rwlock_timedrdlock - pthread_rwlock_rwlock - pthread_rwlock_timedwrlock - pthread_rwlock_unlock - pthread_rwlockattr_init - pthread_rwlockattr_destroy - pthread_rwlockattr_getpshared - pthread_rwlockattr_setpshared - - --------------------------- - Spin Locks - --------------------------- - pthread_spin_init - pthread_spin_destroy - pthread_spin_lock - pthread_spin_unlock - pthread_spin_trylock - - --------------------------- - Barriers - --------------------------- - pthread_barrier_init - pthread_barrier_destroy - pthread_barrier_wait - pthread_barrierattr_init - pthread_barrierattr_destroy - pthread_barrierattr_getpshared - pthread_barrierattr_setpshared - - --------------------------- - Semaphores - --------------------------- - sem_init - sem_destroy - sem_post - sem_wait - sem_trywait - sem_timedwait - sem_getvalue (# free if +ve, # of waiters if -ve) - sem_open (returns an error ENOSYS) - sem_close (returns an error ENOSYS) - sem_unlink (returns an error ENOSYS) - - --------------------------- - RealTime Scheduling - --------------------------- - pthread_attr_getschedparam - pthread_attr_setschedparam - pthread_attr_getinheritsched - pthread_attr_setinheritsched - pthread_attr_getschedpolicy (only supports SCHED_OTHER) - pthread_attr_setschedpolicy (only supports SCHED_OTHER) - pthread_getschedparam - pthread_setschedparam - pthread_getconcurrency - pthread_setconcurrency - pthread_attr_getscope - pthread_attr_setscope (only supports PTHREAD_SCOPE_SYSTEM) - sched_get_priority_max - sched_get_priority_min - sched_rr_get_interval (returns an error ENOTSUP) - sched_setscheduler (only supports SCHED_OTHER) - sched_getscheduler (only supports SCHED_OTHER) - sched_yield - - --------------------------- - Signals - --------------------------- - pthread_sigmask - pthread_kill (only supports zero sig value, - for thread validity checking) - - --------------------------- - Non-portable routines (see the README.NONPORTABLE file for usage) - --------------------------- - pthread_getw32threadhandle_np - pthread_timechange_handler_np - pthread_delay_np - pthread_getunique_np - pthread_mutexattr_getkind_np - pthread_mutexattr_setkind_np (types: PTHREAD_MUTEX_FAST_NP, - PTHREAD_MUTEX_ERRORCHECK_NP, - PTHREAD_MUTEX_RECURSIVE_NP, - PTHREAD_MUTEX_ADAPTIVE_NP, - PTHREAD_MUTEX_TIMED_NP) - pthread_num_processors_np - (The following four routines may be required when linking statically. - The process_* routines should not be needed for MSVC or GCC.) - pthread_win32_process_attach_np - pthread_win32_process_detach_np - (The following routines should only be needed to manage implicit - POSIX handles i.e. when Win native threads call POSIX thread routines - (other than pthread_create)) - pthread_win32_thread_attach_np - pthread_win32_thread_detach_np - - --------------------------- - Static Initializers - --------------------------- - PTHREAD_ONCE_INIT - PTHREAD_MUTEX_INITIALIZER - PTHREAD_RECURSIVE_MUTEX_INITIALIZER - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP - PTHREAD_ERRORCHECK_MUTEX_INITIALIZER - PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP - PTHREAD_COND_INITIALIZER - PTHREAD_RWLOCK_INITIALIZER - PTHREAD_SPINLOCK_INITIALIZER - - -The library includes two non-API functions for creating cancellation -points in applications and libraries: - - pthreadCancelableWait - pthreadCancelableTimedWait - - -The following functions are not implemented: - - --------------------------- - RealTime Scheduling - --------------------------- - pthread_mutex_getprioceiling - pthread_mutex_setprioceiling - pthread_mutex_attr_getprioceiling - pthread_mutex_attr_getprotocol - pthread_mutex_attr_setprioceiling - pthread_mutex_attr_setprotocol - - --------------------------- - Fork Handlers - --------------------------- - pthread_atfork - - --------------------------- - Stdio - --------------------------- - flockfile - ftrylockfile - funlockfile - getc_unlocked - getchar_unlocked - putc_unlocked - putchar_unlocked - - --------------------------- - Thread-Safe C Runtime Library - --------------------------- - readdir_r - getgrgid_r - getgrnam_r - getpwuid_r - getpwnam_r - - --------------------------- - Signals - --------------------------- - sigtimedwait - sigwait - sigwaitinfo - - --------------------------- - General - --------------------------- - sysconf - - --------------------------- - Thread-Safe C Runtime Library (macros) - --------------------------- - strtok_r - asctime_r - ctime_r - gmtime_r - localtime_r - rand_r - - -Availability ------------- - -The prebuilt DLL, export libs (for both MSVC and Mingw32), and the header -files (pthread.h, semaphore.h, sched.h) are available along with the -complete source code. - -The source code can be found at: - - ftp://sources.redhat.com/pub/pthreads-win32 - -and as individual source code files at - - ftp://sources.redhat.com/pub/pthreads-win32/source - -The pre-built DLL, export libraries and include files can be found at: - - ftp://sources.redhat.com/pub/pthreads-win32/dll-latest - - - -Mailing List ------------- - -There is a mailing list for discussing pthreads on Win32. To join, -send email to: - - pthreads-win32-subscribe@sourceware.cygnus.com - - -Application Development Environments ------------------------------------- - -See the README file for more information. - -MSVC: -MSVC using SEH works. Distribute pthreadVSE.dll with your application. -MSVC using C++ EH works. Distribute pthreadVCE.dll with your application. -MSVC using C setjmp/longjmp works. Distribute pthreadVC.dll with your application. - - -Mingw32: -See the FAQ, Questions 6 and 10. - -Mingw using C++ EH works. Distribute pthreadGCE.dll with your application. -Mingw using C setjmp/longjmp works. Distribute pthreadGC.dll with your application. - - -Cygwin: (http://sourceware.cygnus.com/cygwin/) -Developers using Cygwin do not need pthreads-win32 since it has POSIX threads -support. Refer to its documentation for details and extent. - - -UWIN: -UWIN is a complete Unix-like environment for Windows from AT&T. Pthreads-win32 -doesn't currently support UWIN (and vice versa), but that may change in the -future. - -Generally: -For convenience, the following pre-built files are available on the FTP site -(see Availability above): - - pthread.h - for POSIX threads - semaphore.h - for POSIX semaphores - sched.h - for POSIX scheduling - pthreadVCE.dll - built with MSVC++ compiler using C++ EH - pthreadVCE.lib - pthreadVC.dll - built with MSVC compiler using C setjmp/longjmp - pthreadVC.lib - pthreadVSE.dll - built with MSVC compiler using SEH - pthreadVSE.lib - pthreadGCE.dll - built with Mingw32 G++ 2.95.2-1 - pthreadGC.dll - built with Mingw32 GCC 2.95.2-1 using setjmp/longjmp - libpthreadGCE.a - derived from pthreadGCE.dll - libpthreadGC.a - derived from pthreadGC.dll - gcc.dll - needed if distributing applications that use - pthreadGCE.dll (but see the FAQ Q 10 for the latest - related information) - -These are the only files you need in order to build POSIX threads -applications for Win32 using either MSVC or Mingw32. - -See the FAQ file in the source tree for additional information. - - -Documentation -------------- - -For the authoritative reference, see the online POSIX -standard reference at: - - http://www.OpenGroup.org - -For POSIX Thread API programming, several reference books are -available: - - Programming with POSIX Threads - David R. Butenhof - Addison-Wesley (pub) - - Pthreads Programming - By Bradford Nichols, Dick Buttlar & Jacqueline Proulx Farrell - O'Reilly (pub) - -On the web: see the links at the bottom of the pthreads-win32 site: - - http://sources.redhat.com/pthreads-win32/ - - Currently, there is no documentation included in the package apart - from the copious comments in the source code. - - - -Enjoy! - -Ross Johnson diff --git a/deps/w32-pthreads/BUGS b/deps/w32-pthreads/BUGS deleted file mode 100644 index 285ba4e..0000000 --- a/deps/w32-pthreads/BUGS +++ /dev/null @@ -1,141 +0,0 @@ ----------- -Known bugs ----------- - -1. Not strictly a bug, more of a gotcha. - - Under MS VC++ (only tested with version 6.0), a term_func - set via the standard C++ set_terminate() function causes the - application to abort. - - Notes from the MSVC++ manual: - 1) A term_func() should call exit(), otherwise - abort() will be called on return to the caller. - A call to abort() raises SIGABRT and the default signal handler - for all signals terminates the calling program with - exit code 3. - 2) A term_func() must not throw an exception. Therefore - term_func() should not call pthread_exit(), which - works by throwing an exception (pthreadVCE or pthreadVSE) - or by calling longjmp (pthreadVC). - - Workaround: avoid using pthread_exit() in C++ applications. Exit - threads by dropping through the end of the thread routine. - -2. Cancellation problems in C++ builds - - Milan Gardian - - [Note: It's not clear if this problem isn't simply due to the context - switch in pthread_cancel() which occurs unless the QueueUserAPCEx - library and driver are installed and used. Just like setjmp/longjmp, - this is probably not going to work well in C++. In any case, unless for - some very unusual reason you really must use the C++ build then please - use the C build pthreadVC2.dll or pthreadGC2.dll, i.e. for C++ - applications.] - - This is suspected to be a compiler bug in VC6.0, and also seen in - VC7.0 and VS .NET 2003. The GNU C++ compiler does not have a problem - with this, and it has been reported that the Intel C++ 8.1 compiler - and Visual C++ 2005 Express Edition Beta2 pass tests\semaphore4.c - (which exposes the bug). - - Workaround [rpj - 2 Feb 2002] - ----------------------------- - [Please note: this workaround did not solve a similar problem in - snapshot-2004-11-03 or later, even though similar symptoms were seen. - tests\semaphore4.c fails in that snapshot for the VCE version of the - DLL.] - - The problem disappears when /Ob0 is used, i.e. /O2 /Ob0 works OK, - but if you want to use inlining optimisation you can be much more - specific about where it's switched off and on by using a pragma. - - So the inlining optimisation is interfering with the way that cleanup - handlers are run. It appears to relate to auto-inlining of class methods - since this is the only auto inlining that is performed at /O1 optimisation - (functions with the "inline" qualifier are also inlined, but the problem - doesn't appear to involve any such functions in the library or testsuite). - - In order to confirm the inlining culprit, the following use of pragmas - eliminate the problem but I don't know how to make it transparent, putting - it in, say, pthread.h where pthread_cleanup_push defined as a macro. - - #pragma inline_depth(0) - pthread_cleanup_push(handlerFunc, (void *) &arg); - - /* ... */ - - pthread_cleanup_pop(0); - #pragma inline_depth() - - Note the empty () pragma value after the pop macro. This resets depth to the - default. Or you can specify a non-zero depth here. - - The pragma is also needed (and now used) within the library itself wherever - cleanup handlers are used (condvar.c and rwlock.c). - - Use of these pragmas allows compiler optimisations /O1 and /O2 to be - used for either or both the library and applications. - - Experimenting further, I found that wrapping the actual cleanup handler - function with #pragma auto_inline(off|on) does NOT work. - - MSVC6.0 doesn't appear to support the C99 standard's _Pragma directive, - however, later versions may. This form is embeddable inside #define - macros, which would be ideal because it would mean that it could be added - to the push/pop macro definitions in pthread.h and hidden from the - application programmer. - - [/rpj] - - Original problem description - ---------------------------- - - The cancellation (actually, cleanup-after-cancel) tests fail when using VC - (professional) optimisation switches (/O1 or /O2) in pthreads library. I - have not investigated which concrete optimisation technique causes this - problem (/Og, /Oi, /Ot, /Oy, /Ob1, /Gs, /Gf, /Gy, etc.), but here is a - summary of builds and corresponding failures: - - * pthreads VSE (optimised tests): OK - * pthreads VCE (optimised tests): Failed "cleanup1" test (runtime) - - * pthreads VSE (DLL in CRT, optimised tests): OK - * pthreads VCE (DLL in CRT, optimised tests): Failed "cleanup1" test - (runtime) - - Please note that while in VSE version of the pthreads library the - optimisation does not really have any impact on the tests (they pass OK), in - VCE version addition of optimisation (/O2 in this case) causes the tests to - fail uniformly - either in "cleanup0" or "cleanup1" test cases. - - Please note that all the tests above use default pthreads DLL (no - optimisations, linked with either static or DLL CRT, based on test type). - Therefore the problem lies not within the pthreads DLL but within the - compiled client code (the application using pthreads -> involvement of - "pthread.h"). - - I think the message of this section is that usage of VCE version of pthreads - in applications relying on cancellation/cleanup AND using optimisations for - creation of production code is highly unreliable for the current version of - the pthreads library. - -3. The Borland Builder 5.5 version of the library produces memory read exceptions -in some tests. - -4. pthread_barrier_wait() can deadlock if the number of potential calling -threads for a particular barrier is greater than the barrier count parameter -given to pthread_barrier_init() for that barrier. - -This is due to the very lightweight implementation of pthread-win32 barriers. -To cope with more than "count" possible waiters, barriers must effectively -implement all the same safeguards as condition variables, making them much -"heavier" than at present. - -The workaround is to ensure that no more than "count" threads attempt to wait -at the barrier. - -5. Canceling a thread blocked on pthread_once appears not to work in the MSVC++ -version of the library "pthreadVCE.dll". The test case "once3.c" hangs. I have no -clues on this at present. All other versions pass this test ok - pthreadsVC.dll, -pthreadsVSE.dll, pthreadsGC.dll and pthreadsGCE.dll. diff --git a/deps/w32-pthreads/Bmakefile b/deps/w32-pthreads/Bmakefile deleted file mode 100644 index ea25dec..0000000 --- a/deps/w32-pthreads/Bmakefile +++ /dev/null @@ -1,268 +0,0 @@ -# This makefile is compatible with BCB make. Use "make -fBMakefile" to compile. -# -# The variables $DLLDEST and $LIBDEST hold the destination directories for the -# dll and the lib, respectively. Probably all that needs to change is $DEVROOT. -# -# Currently only the recommended pthreadBC.dll is built by this makefile. -# - - -DLL_VER = 2 - -DEVROOT = . - -DLLDEST = $(DEVROOT)\DLL -LIBDEST = $(DEVROOT)\DLL - -DLLS = pthreadBC$(DLL_VER).dll - -OPTIM = /O2 - -RC = brcc32 -RCFLAGS = -i. - -CFLAGS = /q /I. /D_WIN32_WINNT=0x400 /DHAVE_PTW32_CONFIG_H=1 /4 /tWD /tWM \ - /w-aus /w-asc /w-par - -#C cleanup code -BCFLAGS = $(PTW32_FLAGS) $(CFLAGS) - -# Agregate modules for inlinability -DLL_OBJS = \ - attr.obj \ - barrier.obj \ - cancel.obj \ - cleanup.obj \ - condvar.obj \ - create.obj \ - dll.obj \ - errno.obj \ - exit.obj \ - fork.obj \ - global.obj \ - misc.obj \ - mutex.obj \ - nonportable.obj \ - private.obj \ - rwlock.obj \ - sched.obj \ - semaphore.obj \ - signal.obj \ - spin.obj \ - sync.obj \ - tsd.obj - -INCL = config.h implement.h semaphore.h pthread.h need_errno.h - -ATTR_SRCS = \ - pthread_attr_init.c \ - pthread_attr_destroy.c \ - pthread_attr_getdetachstate.c \ - pthread_attr_setdetachstate.c \ - pthread_attr_getstackaddr.c \ - pthread_attr_setstackaddr.c \ - pthread_attr_getstacksize.c \ - pthread_attr_setstacksize.c \ - pthread_attr_getscope.c \ - pthread_attr_setscope.c - -BARRIER_SRCS = \ - pthread_barrier_init.c \ - pthread_barrier_destroy.c \ - pthread_barrier_wait.c \ - pthread_barrierattr_init.c \ - pthread_barrierattr_destroy.c \ - pthread_barrierattr_setpshared.c \ - pthread_barrierattr_getpshared.c - -CANCEL_SRCS = \ - pthread_setcancelstate.c \ - pthread_setcanceltype.c \ - pthread_testcancel.c \ - pthread_cancel.c - -CONDVAR_SRCS = \ - ptw32_cond_check_need_init.c \ - pthread_condattr_destroy.c \ - pthread_condattr_getpshared.c \ - pthread_condattr_init.c \ - pthread_condattr_setpshared.c \ - pthread_cond_destroy.c \ - pthread_cond_init.c \ - pthread_cond_signal.c \ - pthread_cond_wait.c - -EXIT_SRCS = \ - pthread_exit.c - -MISC_SRCS = \ - pthread_equal.c \ - pthread_getconcurrency.c \ - pthread_once.c \ - pthread_self.c \ - pthread_setconcurrency.c \ - ptw32_calloc.c \ - ptw32_MCS_lock.c \ - ptw32_new.c \ - w32_CancelableWait.c - -MUTEX_SRCS = \ - ptw32_mutex_check_need_init.c \ - pthread_mutex_init.c \ - pthread_mutex_destroy.c \ - pthread_mutexattr_init.c \ - pthread_mutexattr_destroy.c \ - pthread_mutexattr_getpshared.c \ - pthread_mutexattr_setpshared.c \ - pthread_mutexattr_settype.c \ - pthread_mutexattr_gettype.c \ - pthread_mutexattr_setrobust.c \ - pthread_mutexattr_getrobust.c \ - pthread_mutex_lock.c \ - pthread_mutex_timedlock.c \ - pthread_mutex_unlock.c \ - pthread_mutex_trylock.c \ - pthread_mutex_consistent.c - -NONPORTABLE_SRCS = \ - pthread_mutexattr_setkind_np.c \ - pthread_mutexattr_getkind_np.c \ - pthread_getw32threadhandle_np.c \ - pthread_delay_np.c \ - pthread_num_processors_np.c \ - pthread_win32_attach_detach_np.c \ - pthread_timechange_handler_np.c - -PRIVATE_SRCS = \ - ptw32_is_attr.c \ - ptw32_processInitialize.c \ - ptw32_processTerminate.c \ - ptw32_threadStart.c \ - ptw32_threadDestroy.c \ - ptw32_tkAssocCreate.c \ - ptw32_tkAssocDestroy.c \ - ptw32_callUserDestroyRoutines.c \ - ptw32_timespec.c \ - ptw32_relmillisecs.c \ - ptw32_throw.c \ - ptw32_getprocessors.c - -RWLOCK_SRCS = \ - ptw32_rwlock_check_need_init.c \ - ptw32_rwlock_cancelwrwait.c \ - pthread_rwlock_init.c \ - pthread_rwlock_destroy.c \ - pthread_rwlockattr_init.c \ - pthread_rwlockattr_destroy.c \ - pthread_rwlockattr_getpshared.c \ - pthread_rwlockattr_setpshared.c \ - pthread_rwlock_rdlock.c \ - pthread_rwlock_timedrdlock.c \ - pthread_rwlock_wrlock.c \ - pthread_rwlock_timedwrlock.c \ - pthread_rwlock_unlock.c \ - pthread_rwlock_tryrdlock.c \ - pthread_rwlock_trywrlock.c - -SCHED_SRCS = \ - pthread_attr_setschedpolicy.c \ - pthread_attr_getschedpolicy.c \ - pthread_attr_setschedparam.c \ - pthread_attr_getschedparam.c \ - pthread_attr_setinheritsched.c \ - pthread_attr_getinheritsched.c \ - pthread_setschedparam.c \ - pthread_getschedparam.c \ - sched_get_priority_max.c \ - sched_get_priority_min.c \ - sched_setscheduler.c \ - sched_getscheduler.c \ - sched_yield.c - -SEMAPHORE_SRCS = \ - sem_init.c \ - sem_destroy.c \ - sem_trywait.c \ - sem_timedwait.c \ - sem_wait.c \ - sem_post.c \ - sem_post_multiple.c \ - sem_getvalue.c \ - sem_open.c \ - sem_close.c \ - sem_unlink.c - -SPIN_SRCS = \ - ptw32_spinlock_check_need_init.c \ - pthread_spin_init.c \ - pthread_spin_destroy.c \ - pthread_spin_lock.c \ - pthread_spin_unlock.c \ - pthread_spin_trylock.c - -SYNC_SRCS = \ - pthread_detach.c \ - pthread_join.c - -TSD_SRCS = \ - pthread_key_create.c \ - pthread_key_delete.c \ - pthread_setspecific.c \ - pthread_getspecific.c - - -all: clean $(DLLS) - -realclean: clean - if exist pthread*.dll del pthread*.dll - if exist pthread*.lib del pthread*.lib - if exist *.stamp del *.stamp - -clean: - if exist *.obj del *.obj - if exist *.ilk del *.ilk - if exist *.ilc del *.ilc - if exist *.ild del *.ild - if exist *.ilf del *.ilf - if exist *.ils del *.ils - if exist *.tds del *.tds - if exist *.pdb del *.pdb - if exist *.exp del *.exp - if exist *.map del *.map - if exist *.o del *.o - if exist *.i del *.i - if exist *.res del *.res - - -install: $(DLLS) - copy pthread*.dll $(DLLDEST) - copy pthread*.lib $(LIBDEST) - -$(DLLS): $(DLL_OBJS) version.res - ilink32 /Tpd /Gi c0d32x.obj $(DLL_OBJS), \ - $@, ,\ - cw32mti.lib import32.lib, ,\ - version.res - -.c.obj: - $(CC) $(OPTIM) $(BCFLAGS) -c $< - -.rc.res: - $(RC) $(RCFLAGS) $< - -attr.obj: attr.c $(ATTR_SRCS) $(INCL) -barrier.obj: barrier.c $(BARRIER_SRCS) $(INCL) -cancel.obj: cancel.c $(CANCEL_SRCS) $(INCL) -condvar.obj: condvar.c $(CONDVAR_SRCS) $(INCL) -exit.obj: exit.c $(EXIT_SRCS) $(INCL) -misc.obj: misc.c $(MISC_SRCS) $(INCL) -mutex.obj: mutex.c $(MUTEX_SRCS) $(INCL) -nonportable.obj: nonportable.c $(NONPORTABLE_SRCS) $(INCL) -private.obj: private.c $(PRIVATE_SRCS) $(INCL) -rwlock.obj: rwlock.c $(RWLOCK_SRCS) $(INCL) -sched.obj: sched.c $(SCHED_SRCS) $(INCL) -semaphore.obj: semaphore.c $(SEMAPHORE_SRCS) $(INCL) -spin.obj: spin.c $(SPIN_SRCS) $(INCL) -sync.obj: sync.c $(SYNC_SRCS) $(INCL) -tsd.obj: tsd.c $(TSD_SRCS) $(INCL) -version.res: version.rc $(INCL) diff --git a/deps/w32-pthreads/CMakeLists.txt b/deps/w32-pthreads/CMakeLists.txt deleted file mode 100644 index 992ec69..0000000 --- a/deps/w32-pthreads/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -project(w32-pthreads) - -if(NOT WIN32) - return() -endif() - -set(w32-pthreads_SOURCES - pthread.c) - -set(w32-pthreads_HEADERS - implement.h - pthread.h - sched.h - semaphore.h) - -add_library(w32-pthreads SHARED - ${w32-pthreads_SOURCES} - ${w32-pthreads_HEADERS}) -target_compile_definitions(w32-pthreads - PRIVATE __CLEANUP_C PTW32_BUILD) -target_include_directories(w32-pthreads - PUBLIC - "$") -target_link_libraries(w32-pthreads) - -install_obs_core(w32-pthreads EXPORT w32-pthreads) diff --git a/deps/w32-pthreads/CONTRIBUTORS b/deps/w32-pthreads/CONTRIBUTORS deleted file mode 100644 index da31ff2..0000000 --- a/deps/w32-pthreads/CONTRIBUTORS +++ /dev/null @@ -1,140 +0,0 @@ -Contributors (in approximate order of appearance) - -[See also the ChangeLog file where individuals are -attributed in log entries. Likewise in the FAQ file.] - -Ben Elliston bje at cygnus dot com - Initiated the project; - setup the project infrastructure (CVS, web page, etc.); - early prototype routines. -Ross Johnson Ross dot Johnson at dot homemail dot com dot au - early prototype routines; - ongoing project coordination/maintenance; - implementation of spin locks and barriers; - various enhancements; - bug fixes; - documentation; - testsuite. -Robert Colquhoun rjc at trump dot net dot au - Early bug fixes. -John E. Bossom John dot Bossom at cognos dot com - Contributed substantial original working implementation; - bug fixes; - ongoing guidance and standards interpretation. -Anders Norlander anorland at hem2 dot passagen dot se - Early enhancements and runtime checking for supported - Win32 routines. -Tor Lillqvist tml at iki dot fi - General enhancements; - early bug fixes to condition variables. -Scott Lightner scott at curriculum dot com - Bug fix. -Kevin Ruland Kevin dot Ruland at anheuser-busch dot com - Various bug fixes. -Mike Russo miker at eai dot com - Bug fix. -Mark E. Armstrong avail at pacbell dot net - Bug fixes. -Lorin Hochstein lmh at xiphos dot ca - general bug fixes; bug fixes to condition variables. -Peter Slacik Peter dot Slacik at tatramed dot sk - Bug fixes. -Mumit Khan khan at xraylith dot wisc dot edu - Fixes to work with Mingw32. -Milan Gardian mg at tatramed dot sk - Bug fixes and reports/analyses of obscure problems. -Aurelio Medina aureliom at crt dot com - First implementation of read-write locks. -Graham Dumpleton Graham dot Dumpleton at ra dot pad dot otc dot telstra dot com dot au - Bug fix in condition variables. -Tristan Savatier tristan at mpegtv dot com - WinCE port. -Erik Hensema erik at hensema dot xs4all dot nl - Bug fixes. -Rich Peters rpeters at micro-magic dot com -Todd Owen towen at lucidcalm dot dropbear dot id dot au - Bug fixes to dll loading. -Jason Nye jnye at nbnet dot nb dot ca - Implementation of async cancelation. -Fred Forester fforest at eticomm dot net -Kevin D. Clark kclark at cabletron dot com -David Baggett dmb at itasoftware dot com - Bug fixes. -Paul Redondo paul at matchvision dot com -Scott McCaskill scott at 3dfx dot com - Bug fixes. -Jef Gearhart jgearhart at tpssys dot com - Bug fix. -Arthur Kantor akantor at bexusa dot com - Mutex enhancements. -Steven Reddie smr at essemer dot com dot au - Bug fix. -Alexander Terekhov TEREKHOV at de dot ibm dot com - Re-implemented and improved read-write locks; - (with Louis Thomas) re-implemented and improved - condition variables; - enhancements to semaphores; - enhancements to mutexes; - new mutex implementation in 'futex' style; - suggested a robust implementation of pthread_once - similar to that implemented by V.Kliathcko; - system clock change handling re CV timeouts; - bug fixes. -Thomas Pfaff tpfaff at gmx dot net - Changes to make C version usable with C++ applications; - re-implemented mutex routines to avoid Win32 mutexes - and TryEnterCriticalSection; - procedure to fix Mingw32 thread-safety issues. -Franco Bez franco dot bez at gmx dot de - procedure to fix Mingw32 thread-safety issues. -Louis Thomas lthomas at arbitrade dot com - (with Alexander Terekhov) re-implemented and improved - condition variables. -David Korn dgk at research dot att dot com - Ported to UWIN. -Phil Frisbie, Jr. phil at hawksoft dot com - Bug fix. -Ralf Brese Ralf dot Brese at pdb4 dot siemens dot de - Bug fix. -prionx at juno dot com prionx at juno dot com - Bug fixes. -Max Woodbury mtew at cds dot duke dot edu - POSIX versioning conditionals; - reduced namespace pollution; - idea to separate routines to reduce statically - linked image sizes. -Rob Fanner rfanner at stonethree dot com - Bug fix. -Michael Johnson michaelj at maine dot rr dot com - Bug fix. -Nicolas Barry boozai at yahoo dot com - Bug fixes. -Piet van Bruggen pietvb at newbridges dot nl - Bug fix. -Makoto Kato raven at oldskool dot jp - AMD64 port. -Panagiotis E. Hadjidoukas peh at hpclab dot ceid dot upatras dot gr - phadjido at cs dot uoi dot gr - Contributed the QueueUserAPCEx package which - makes preemptive async cancelation possible. -Will Bryant will dot bryant at ecosm dot com - Borland compiler patch and makefile. -Anuj Goyal anuj dot goyal at gmail dot com - Port to Digital Mars compiler. -Gottlob Frege gottlobfrege at gmail dot com - re-implemented pthread_once (version 2) - (pthread_once cancellation added by rpj). -Vladimir Kliatchko vladimir at kliatchko dot com - reimplemented pthread_once with the same form - as described by A.Terekhov (later version 2); - implementation of MCS (Mellor-Crummey/Scott) locks. -Ramiro Polla ramiro.polla at gmail dot com - static library auto init/cleanup on application - start/exit via RT hooks (MSC and GCC compilers only). -Daniel Richard G. skunk at iSKUNK dot org - Patches and cleanups for x86 and x64, particularly - across a range of MS build environments. -John Kamp john dot kamp at globalgraphics dot com - Patches to fix various problems on x64; brutal testing - particularly using high memory run environments. - diff --git a/deps/w32-pthreads/COPYING b/deps/w32-pthreads/COPYING deleted file mode 100644 index cac5794..0000000 --- a/deps/w32-pthreads/COPYING +++ /dev/null @@ -1,150 +0,0 @@ - pthreads-win32 - a POSIX threads library for Microsoft Windows - - -This file is Copyrighted ------------------------- - - This file is covered under the following Copyright: - - Copyright (C) 2001,2006 Ross P. Johnson - All rights reserved. - - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -Pthreads-win32 is covered by the GNU Lesser General Public License ------------------------------------------------------------------- - - Pthreads-win32 is open 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 version 2.1 of the - License. - - Pthreads-win32 is several binary link libraries, several modules, - associated interface definition files and scripts used to control - its compilation and installation. - - Pthreads-win32 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. - - A copy of the GNU Lesser General Public License is distributed with - pthreads-win32 under the filename: - - COPYING.LIB - - You should have received a copy of the version 2.1 GNU Lesser General - Public License with pthreads-win32; if not, write to: - - Free Software Foundation, Inc. - 51 Franklin Street - Fifth Floor - Boston, MA 02110-1301 - USA - - The contact addresses for pthreads-win32 is as follows: - - Web: http://sources.redhat.com/pthreads-win32 - Email: Ross Johnson - Please use: Firstname.Lastname@homemail.com.au - - - -Pthreads-win32 copyrights and exception files ---------------------------------------------- - - With the exception of the files listed below, Pthreads-win32 - is covered under the following GNU Lesser General Public License - Copyrights: - - Pthreads-win32 - POSIX Threads Library for Win32 - Copyright(C) 1998 John E. Bossom - Copyright(C) 1999,2006 Pthreads-win32 contributors - - The current list of contributors is contained - in the file CONTRIBUTORS included with the source - code distribution. The current list of CONTRIBUTORS - can also be seen at the following WWW location: - http://sources.redhat.com/pthreads-win32/contributors.html - - Contact Email: Ross Johnson - Please use: Firstname.Lastname@homemail.com.au - - These files are not covered under one of the Copyrights listed above: - - COPYING - COPYING.LIB - tests/rwlock7.c - - This file, COPYING, is distributed under the Copyright found at the - top of this file. It is important to note that you may distribute - verbatim copies of this file but you may not modify this file. - - The file COPYING.LIB, which contains a copy of the version 2.1 - GNU Lesser General Public License, is itself copyrighted by the - Free Software Foundation, Inc. Please note that the Free Software - Foundation, Inc. does NOT have a copyright over Pthreads-win32, - only the COPYING.LIB that is supplied with pthreads-win32. - - The file tests/rwlock7.c is derived from code written by - Dave Butenhof for his book 'Programming With POSIX(R) Threads'. - The original code was obtained by free download from his website - http://home.earthlink.net/~anneart/family/Threads/source.html - and did not contain a copyright or author notice. It is assumed to - be freely distributable. - - In all cases one may use and distribute these exception files freely. - And because one may freely distribute the LGPL covered files, the - entire pthreads-win32 source may be freely used and distributed. - - - -General Copyleft and License info ---------------------------------- - - For general information on Copylefts, see: - - http://www.gnu.org/copyleft/ - - For information on GNU Lesser General Public Licenses, see: - - http://www.gnu.org/copyleft/lesser.html - http://www.gnu.org/copyleft/lesser.txt - - -Why pthreads-win32 did not use the GNU General Public License -------------------------------------------------------------- - - The goal of the pthreads-win32 project has been to - provide a quality and complete implementation of the POSIX - threads API for Microsoft Windows within the limits imposed - by virtue of it being a stand-alone library and not - linked directly to other POSIX compliant libraries. For - example, some functions and features, such as those based - on POSIX signals, are missing. - - Pthreads-win32 is a library, available in several different - versions depending on supported compilers, and may be used - as a dynamically linked module or a statically linked set of - binary modules. It is not an application on it's own. - - It was fully intended that pthreads-win32 be usable with - commercial software not covered by either the GPL or the LGPL - licenses. Pthreads-win32 has many contributors to it's - code base, many of whom have done so because they have - used the library in commercial or proprietry software - projects. - - Releasing pthreads-win32 under the LGPL ensures that the - library can be used widely, while at the same time ensures - that bug fixes and improvements to the pthreads-win32 code - itself is returned to benefit all current and future users - of the library. - - Although pthreads-win32 makes it possible for applications - that use POSIX threads to be ported to Win32 platforms, the - broader goal of the project is to encourage the use of open - standards, and in particular, to make it just a little easier - for developers writing Win32 applications to consider - widening the potential market for their products. diff --git a/deps/w32-pthreads/COPYING.LIB b/deps/w32-pthreads/COPYING.LIB deleted file mode 100644 index db01cf0..0000000 --- a/deps/w32-pthreads/COPYING.LIB +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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.1 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/deps/w32-pthreads/ChangeLog b/deps/w32-pthreads/ChangeLog deleted file mode 100644 index 42abcc4..0000000 --- a/deps/w32-pthreads/ChangeLog +++ /dev/null @@ -1,5211 +0,0 @@ -2012-03-18 Ross Johnson - - * create.c (pthread_create): add __cdecl attribute to thread routine - arg - * implement.h (pthread_key_t): add __cdecl attribute to destructor - element - (ThreadParms): likewise for start element - * pthread.h (pthread_create): add __cdecl to prototype start arg - (pthread_once): likewise for init_routine arg - (pthread_key_create): likewise for destructor arg - (ptw32_cleanup_push): replace type of routine arg with previously - defined ptw32_cleanup_callback_t - * pthread_key_create.c: add __cdecl attribute to destructor arg - * pthread_once.c: add __cdecl attribute to init_routine arg - * ptw32_threadStart.c (start): add __cdecl to start variable type - - -2011-07-06 Ross Johnson - - * pthread_cond_wait.c (pragma inline_depth): this is almost redundant - now nevertheless fixed thei controlling MSC_VER from "< 800" to - "< 1400" (i.e. any prior to VC++ 8.0). - * pthread_once.ci (pragma inline_depth): Likewise. - * pthread_rwlock_timedwrlock.ci (pragma inline_depth): Likewise. - * pthread_rwlock_wrlock.ci (pragma inline_depth): Likewise. - * sem_timedwait.ci (pragma inline_depth): Likewise. - * sem_wait.ci (pragma inline_depth): Likewise. - -2011-07-05 Ross Johnson - - * pthread_win32_attach_detach_np.c: Use strncat_s if available - to removei a compile warning; MingW supports this routine but we - continue to use strncat anyway there because it is secure if - given the correct parameters; fix strncat param 3 to avoid - buffer overrun exploitation potential. - -2011-07-03 Ross Johnson - - * pthread_spin_unlock.c (EPERM): Return success if unlocking a lock - that is not locked, because single CPU machines wrap a - PTHREAD_MUTEX_NORMAL mutex, which returns success in this case. - * pthread_win32_attach_detach_np.c (QUSEREX.DLL): Load from an - absolute path only which must be the Windows System folder. - -2011-07-03 Daniel Richard G. - - * Makefile (_WIN32_WINNT): Removed; duplicate definition in - implement.h; more cleanup and enhancements. - -2011-07-02 Daniel Richard G. - - * Makefile: Cleanups and implovements. - * ptw32_MCS_locks.c: Casting fixes. - * implement.h: Interlocked call and argument casting macro fixes - to support older and newer build environments. - -2011-07-01 Ross Johnson - - * *.[ch] (PTW32_INTERLOCKED_*): Redo 23 and 64 bit versions of these - macros and re-apply in code to undo the incorrect changes from - 2011-06-29; remove some size_t casts which should not be required - and may be problematic.a - There are now two sets of macros: - PTW32_INTERLOCKED_*_LONG which work only on 32 bit integer variables; - PTW32_INTERLOCKED_*_SIZE which work on size_t integer variables, i.e. - LONG for 32 bit systems and LONGLONG for 64 bit systems. - * implement.h (MCS locks): nextFlag and waitFlag are now HANDLE type. - * ptw32_MCS_locks.c: Likewise. - * pthread.h (#include ): Removed. - * ptw32_throw.c (#include ): Added. - * ptw32_threadStart.c (#include ): Added. - * implement.h (#include ): Added. - -2011-06-30 Ross Johnson - - * pthread_once.c: Tighten 'if' statement casting; fix interlocked - pointer cast for 64 bit compatibility (missed yesterday); remove - the superfluous static cleanup routine and call the release routine - directly if popped. - * create.c (stackSize): Now type size_t. - * pthread.h (struct ptw32_thread_t_): Rearrange to fix element alignments. - -2011-06-29 Daniel Richard G. - - * ptw32_relmillisecs.c (ftime): - _ftime64_s() is only available in MSVC 2005 or later; - _ftime64() is available in MinGW or MSVC 2002 or later; - _ftime() is always available. - * pthread.h (long long): Not defined in older MSVC 6. - * implement.h (long long): Likewise. - * pthread_getunique_np.c (long long): Likewise. - -2011-06-29 Ross Johnson - - * *.[ch] (PTW32_INTERLOCKED_*): These macros should now work for - both 32 and 64 bit builds. The MingW versions are all inlined asm - while the MSVC versions expand to their Interlocked* or Interlocked*64 - counterparts appropriately. The argument type have also been changed - to cast to the appropriate value or pointer size for the architecture. - -2011-05-29 Ross Johnson - - * *.[ch] (#ifdef): Extended cleanup to whole project. - -2011-05-29 Daniel Richard G. - - * Makefile (CC): Define CC to allow use of other compatible - compilers such as the Intel compilter icl. - * implement.h (#if): Fix forms like #if HAVE_SOMETHING. - * pthread.h: Likewise. - * sched.h: Likewise; PTW32_LEVEL_* becomes PTW32_SCHED_LEVEL_*. - * semaphore.h: Likewise. - -2011-05-11 Ross Johnson - - * ptw32_callUserDestroyRoutines.c (terminate): Altered includes - to match ptw32_threadStart.c. - * GNUmakefile (GCE-inlined-debug, DOPT): Fixed. - -2011-04-31 Ross Johnson - - * (robust mutexes): Added this API. The API is not - mandatory for implementations that don't support PROCESS_SHARED - mutexes, nevertheless it was considered useful both functionally - and for source-level compatibility. - -2011-03-26 Ross Johnson - - * pthread_getunique_np.c: New non-POSIX interface for compatibility - with some other implementations; returns a 64 bit sequence number - that is unique to each thread in the process. - * pthread.h (pthread_getunique_np): Added. - * global.c: Add global sequence counter for above. - * implement.h: Likewise. - -2011-03-25 Ross Johnson - - * (cancelLock): Convert to an MCS lock and rename to stateLock. - * (threadLock): Likewise. - * (keyLock): Likewise. - * pthread_mutex*.c: First working robust mutexes. - -2011-03-11 Ross Johnson - - * implement.h (PTW32_INTERLOCKED_*CREMENT macros): increment/decrement - using ++/-- instead of add/subtract 1. - * ptw32_MCS_lock.c: Make casts consistent. - -2011-03-09 Ross Johnson - - * implement.h (ptw32_thread_t_): Add process unique sequence number. - * global.c: Replace global Critical Section objects with MCS - queue locks. - * implement.h: Likewise. - * pthread_cond_destroy.c: Likewise. - * pthread_cond_init.c: Likewise. - * pthread_detach.c: Likewise. - * pthread_join.c: Likewise. - * pthread_kill.c: Likewise. - * pthread_mutex_destroy.c: Likewise. - * pthread_rwlock_destroy.c: Likewise. - * pthread_spin_destroy.c: Likewise. - * pthread_timechange_handler_np.c: Likewise. - * ptw32_cond_check_need_init.c: Likewise. - * ptw32_mutex_check_need_init.c: Likewise. - * ptw32_processInitialize.c: Likewise. - * ptw32_processTerminate.c: Likewise. - * ptw32_reuse.c: Likewise. - * ptw32_rwlock_check_need_init.c: Likewise. - * ptw32_spinlock_check_need_init.c: Likewise. - -2011-03-06 Ross Johnson - - * several (MINGW64): Cast and call fixups for 64 bit compatibility; - clean build via x86_64-w64-mingw32 cross toolchain on Linux i686 - targeting x86_64 win64. - * ptw32_threadStart.c (ptw32_threadStart): Routine no longer attempts - to pass [unexpected C++] exceptions out of scope but ends the thread - normally setting EINTR as the exit status. - * ptw32_throw.c: Fix C++ exception throwing warnings; ignore - informational warning. - * implement.h: Likewise with the corresponding header definition. - -2011-03-04 Ross Johnson - - * implement.h (PTW32_INTERLOCKED_*): Mingw32 does not provide - the __sync_* intrinsics so implemented them here as macro - assembler routines. MSVS Interlocked* are emmitted as intrinsics - wherever possible, so we want mingw to match it; Extended to - include all interlocked routines used by the library; implemented - x86_64 versions also. - * ptw32_InterlockedCompareExchange.c: No code remaining here. - * ptw32_MCS_lock.c: Converted interlocked calls to use new macros. - * pthread_barrier_wait.c: Likewise. - * pthread_once.c: Likewise. - * ptw32_MCS_lock.c (ptw32_mcs_node_substitute): Name changed to - ptw32_mcs_node_transfer. - -2011-02-28 Ross Johnson - - * ptw32_relmillisecs.c: If possible, use _ftime64_s or _ftime64 - before resorting to _ftime. - -2011-02-27 Ross Johnson - - * sched_setscheduler.c: Ensure the handle is closed after use. - * sched_getscheduler.c: Likewise. - * pthread.h: Remove POSIX compatibility macros; don't define - timespec if already defined. - * context.h: Changes for 64 bit. - * pthread_cancel.c: Likewise. - * pthread_exit.c: Likewise. - * pthread_spin_destroy.c: Likewise. - * pthread_timechange_handler_np.c: Likewise. - * ptw32_MCS_lock.c: Likewise; some of these changes may - not be compatible with pre Windows 2000 systems; reverse the order of - the includes. - * ptw32_threadStart.c: Likewise. - * ptw32_throw.c: Likewise. - -2011-02-13 Ross Johnson - - * pthread_self: Add comment re returning 'nil' value to - indicate failure only to win32 threads that call us. - * pthread_attr_setstackaddr: Fix comments; note this - function and it's compliment are now removed from SUSv4. - -2011-02-12 Ross Johnson - - README.NONPORTABLE: Record a description of an obvious - method for nulling/comparing/hashing pthread_t using a - union; plus and investigation of a change of type for - pthread_t (to a union) to neutralise any padding bits and - bytes if they occur in pthread_t (the current pthread_t struct - does not contain padding AFAIK, but porting the library to a - future architecture may introduce them). Padding affects - byte-by-byte copies and compare operations. - -2010-11-16 Ross Johnson - - * ChangeLog: Add this entry ;-) - Restore entries from 2007 through 2009 that went missing - at the last update. - -2010-06-19 Ross Johnson - - * ptw32_MCS_lock.c (ptw32_mcs_node_substitute): Fix variable - names to avoid using C++ keyword ("new"). - * implement.h (ptw32_mcs_node_substitute): Likewise. - * pthread_barrier_wait.c: Fix signed/unsigned comparison warning. - -2010-06-18 Ramiro Polla - - * autostatic.c: New file; call pthread_win32_process_*() - libary init/cleanup routines automatically on application start - when statically linked. - * pthread.c (autostatic.c): Included. - * pthread.h (declspec): Remove import/export defines if compiler - is MINGW. - * sched.h (declspec): Likewise. - * semaphore.h (declspec): Likewise. - * need_errno.h (declspec): Likewise. - * Makefile (autostatic.obj): Add for small static builds. - * GNUmakefile (autostatic.o): Likewise. - * NEWS (Version 2.9.0): Add changes. - * README.NONPORTABLE (pthread_win32_process_*): Update - description. - -2010-06-15 Ramiro Polla - - * Makefile: Remove linkage with the winsock library by default. - * GNUmakefile: Likewise. - * pthread_getspecific.c: Likewise by removing calls to WSA - functions. - * config.h (RETAIN_WSALASTERROR): Can be defined if necessary. - -2010-01-26 Ross Johnson - - * ptw32_MCS_lock.c (ptw32_mcs_node_substitute): New routine - to allow relocating the lock owners thread-local node to somewhere - else, e.g. to global space so that another thread can release the - lock. Used in pthread_barrier_wait. - (ptw32_mcs_lock_try_acquire): New routine. - * pthread_barrier_init: Only one semaphore is used now. - * pthread_barrier_wait: Added an MCS guard lock with the last thread - to leave the barrier releasing the lock. This removes a deadlock bug - observed when there are greater than barrier-count threads - attempting to cross. - * pthread_barrier_destroy: Added an MCS guard lock. - -2009-03-03 Stephan O'Farrill - - * pthread_attr_getschedpolicy.c: Add "const" to function parameter - in accordance with SUSv3 (POSIX). - * pthread_attr_getinheritsched.c: Likewise. - * pthread_mutexattr_gettype.c: Likewise. - -2008-06-06 Robert Kindred - - * ptw32_throw.c (ptw32_throw): Remove possible reference to NULL - pointer. (At the same time made the switch block conditionally - included only if exitCode is needed - RPJ.) - * pthread_testcancel.c (pthread_testcancel): Remove duplicate and - misplaced pthread_mutex_unlock(). - -2008-02-21 Sebastian Gottschalk - - * pthread_attr_getdetachstate.c (pthread_attr_getdetachstate): - Remove potential and superfluous null pointer assignment. - -2007-11-22 Ivan Pizhenko - - * pthread.h (gmtime_r): gmtime returns 0 if tm represents a time - prior to 1/1/1970. Notice this to prevent raising an exception. - * pthread.h (localtime_r): Likewise for localtime. - -2007-07-14 Marcel Ruff - - * errno.c (_errno): Fix test for pthread_self() success. - * need_errno.h: Remove unintentional line wrap from #if line. - -2007-07-14 Mike Romanchuk - - * pthread.h (timespec): Fix tv_sec type. - -2007-01-07 Sinan Kaya - - * need_errno.h: Fix declaration of _errno - the local version of - _errno() is used, e.g. by WinCE. - -2007-01-06 Ross Johnson - - * ptw32_semwait.c: Add check for invalid sem_t after acquiring the - sem_t state guard mutex and before affecting changes to sema state. - -2007-01-06 Marcel Ruff - - * error.c: Fix reference to pthread handle exitStatus member for - builds that use NEED_ERRNO (i.e. WINCE). - * context.h: Add support for ARM processor (WinCE). - * mutex.c (process.h): Exclude for WINCE. - * create.c: Likewise. - * exit.c: Likewise. - * implement.h: Likewise. - * pthread_detach.c (signal.h): Exclude for WINCE. - * pthread_join.c: Likewise. - * pthread_kill.c: Likewise. - * pthread_rwlock_init.c (errno.h): Remove - included by pthread.h. - * pthread_rwlock_destroy.c: Likewise. - * pthread_rwlock_rdlock.c: Likewise. - * pthread_rwlock_timedrdlock.c: Likewise. - * pthread_rwlock_timedwrlock.c: Likewise. - * pthread_rwlock_tryrdlock.c: Likewise. - * pthread_rwlock_trywrlock.c: likewise. - * pthread_rwlock_unlock.c: Likewise. - * pthread_rwlock_wrlock.c: Likewise. - * pthread_rwlockattr_destroy.c: Likewise. - * pthread_rwlockattr_getpshared.c: Likewise. - * pthread_rwlockattr_init.c: Likewise. - * pthread_rwlockattr_setpshared.c: Likewise. - -2007-01-06 Romano Paolo Tenca - - * pthread_cond_destroy.c: Replace sem_wait() with non-cancelable - ptw32_semwait() since pthread_cond_destroy() is not a cancelation - point. - * implement.h (ptw32_spinlock_check_need_init): Add prototype. - * ptw32_MCS_lock.c: Reverse order of includes. - -2007-01-06 Eric Berge - - * pthread_cond_destroy.c: Add LeaveCriticalSection before returning - after errors. - -2007-01-04 Ross Johnson - - * ptw32_InterlockedCompareExchange.c: Conditionally skip for - Win64 as not required. - * pthread_win32_attach_detach_np.c (pthread_win32_process_attach_np): - Test for InterlockedCompareExchange is not required for Win64. - * context.h: New file. Included by pthread_cancel.h and any tests - that need it (e.g. context1.c). - * pthread_cancel.c: Architecture-dependent context macros moved - to context.h. - -2007-01-04 Kip Streithorst - - * implement.h (PTW32_INTERLOCKED_COMPARE_EXCHANGE): Add Win64 - support. - -2006-12-20 Ross Johnson - - * sem_destroy.c: Fix the race involving invalidation of the sema; - fix incorrect return of EBUSY resulting from the mutex trylock - on the private mutex guard. - * sem_wait.c: Add check for invalid sem_t after acquiring the - sem_t state guard mutex and before affecting changes to sema state. - * sem_trywait.c: Likewise. - * sem_timedwait.c: Likewise. - * sem_getvalue.c: Likewise. - * sem_post.c: Similar. - * sem_post_multiple.c: Likewise. - * sem_init.c: Set max Win32 semaphore count to SEM_VALUE_MAX (was - _POSIX_SEM_VALUE_MAX, which is a lower value - the minimum). - - * pthread_win32_attach_detach_np.c (pthread_win32_process_attach_np): - Load COREDLL.DLL under WINCE to check existence of - InterlockedCompareExchange() routine. This used to be done to test - for TryEnterCriticalSection() but was removed when this was no - longer needed. - -2006-01-25 Prashant Thakre - - * pthread_cancel.c: Added _M_IA64 register context support. - -2005-05-13 Ross Johnson - - * pthread_kill.c (pthread_kill): Remove check for Win32 thread - priority (to confirm HANDLE validity). Useless since thread HANDLEs - a not recycle-unique. - -2005-05-30 Vladimir Kliatchko - - * pthread_once.c: Re-implement using an MCS queue-based lock. The form - of pthread_once is as proposed by Alexander Terekhov (see entry of - 2005-03-13). The MCS lock implementation does not require a unique - 'name' to identify the lock between threads. Attempts to get the Event - or Semaphore based versions of pthread_once to a satisfactory level - of robustness have thus far failed. The last problem (avoiding races - involving non recycle-unique Win32 HANDLEs) was giving everyone - grey hair trying to solve it. - - * ptw32_MCS_lock.c: New MCS queue-based lock implementation. These - locks are efficient: they have very low overhead in the uncontended case; - are efficient in contention and minimise cache-coherence updates in - managing the user level FIFO queue; do not require an ABI change in the - library. - -2005-05-27 Alexander Gottwald - - * pthread.h: Some things, like HANDLE, were only defined if - PTW32_LEVEL was >= 3. They should always be defined. - -2005-05-25 Vladimir Kliatchko - - * pthread_once.c: Eliminate all priority operations and other - complexity by replacing the event with a semaphore. The advantage - of the change is the ability to release just one waiter if the - init_routine thread is cancelled yet still release all waiters when - done. Simplify once_control state checks to improve efficiency - further. - -2005-05-24 Mikael Magnusson - - * GNUmakefile: Patched to allow cross-compile with mingw32 on Linux. - It uses macros instead of referencing dlltool, gcc and g++ directly; - added a call to ranlib. For example the GC static library can be - built with: - make CC=i586-mingw32msvc-gcc RC=i586-mingw32msvc-windres \ - RANLIB=i586-mingw32msvc-ranlib clean GC-static - -2005-05-13 Ross Johnson - - * pthread_win32_attach_detach_np.c (pthread_win32_thread_detach_np): - Move on-exit-only stuff from ptw32_threadDestroy() to here. - * ptw32_threadDestroy.c: It's purpose is now only to reclaim thread - resources for detached threads, or via pthread_join() or - pthread_detach() on joinable threads. - * ptw32_threadStart.c: Calling user destruct routines has moved to - pthread_win32_thread_detach_np(); call pthread_win32_thread_detach_np() - directly if statically linking, otherwise do so via dllMain; store - thread return value in thread struct for all cases, including - cancellation and exception exits; thread abnormal exits go via - pthread_win32_thread_detach_np. - * pthread_join.c (pthread_join): Don't try to get return code from - Win32 thread - always get it from he thread struct. - * pthread_detach.c (pthread_detach): reduce extent of the thread - existence check since we now don't care if the Win32 thread HANDLE has - been closed; reclaim thread resources if the thread has exited already. - * ptw32_throw.c (ptw32_throw): For Win32 threads that are not implicit, - only Call thread cleanup if statically linking, otherwise leave it to - dllMain. - * sem_post.c (_POSIX_SEM_VALUE_MAX): Change to SEM_VALUE_MAX. - * sem_post_multiple.c: Likewise. - * sem_init.c: Likewise. - -2005-05-10 Ross Johnson - - * pthread_join.c (pthread_join): Add missing check for thread ID - reference count in thread existence test; reduce extent of the - existence test since we don't care if the Win32 thread HANDLE has - been closed. - -2005-05-09 Ross Johnson - - * ptw32_callUserDestroyRoutines.c: Run destructor process (i.e. - loop over all keys calling destructors) up to - PTHREAD_DESTRUCTOR_ITERATIONS times if TSD value isn't NULL yet; - modify assoc management. - * pthread_key_delete.c: Modify assoc management. - * ptw32_tkAssocDestroy.c: Fix error in assoc removal from chains. - * pthread.h - (_POSIX_THREAD_DESTRUCTOR_ITERATIONS): Define to value specified by - POSIX. - (_POSIX_THREAD_KEYS_MAX): Define to value specified by POSIX. - (PTHREAD_KEYS_MAX): Redefine [upward] to minimum required by POSIX. - (SEM_NSEMS_MAX): Define to implementation value. - (SEM_VALUE_MAX): Define to implementation value. - (_POSIX_SEM_NSEMS_MAX): Redefine to value specified by POSIX. - (_POSIX_SEM_VALUE_MAX): Redefine to value specified by POSIX. - -2005-05-06 Ross Johnson - - * signal.c (sigwait): Add a cancellation point to this otherwise - no-op. - * sem_init.c (sem_init): Check for and return ERANGE error. - * sem_post.c (sem_post): Likewise. - * sem_post_multiple.c (sem_post_multiple): Likewise. - * manual (directory): Added; see ChangeLog inside. - -2005-05-02 Ross Johnson - - * implement.h (struct pthread_key_t_): Change threadsLock to keyLock - so as not to be confused with the per thread lock 'threadlock'; - change all references to it. - * implement.h (struct ThreadKeyAssoc): Remove lock; add prevKey - and prevThread pointers; re-implemented all routines that use this - struct. The effect of this is to save one handle per association, - which could potentially equal the number of keys multiplied by the - number of threads, accumulating over time - and to free the - association memory as soon as it is no longer referenced by either - the key or the thread. Previously, the handle and memory were - released only after BOTH key and thread no longer referenced the - association. That is, often no association resources were released - until the process itself exited. In addition, at least one race - condition has been removed - where two threads could attempt to - release the association resources simultaneously - one via - ptw32_callUserDestroyRoutines and the other via - pthread_key_delete. - - thanks to Richard Hughes at Aculab for discovering the problem. - * pthread_key_create.c: See above. - * pthread_key_delete.c: See above. - * pthread_setspecific.c: See above. - * ptw32_callUserDestroyRoutines.c: See above. - * ptw32_tkAssocCreate.c: See above. - * ptw32_tkAssocDestroy.c: See above. - -2005-04-27 Ross Johnson - - * sem_wait.c (ptw32_sem_wait_cleanup): after cancellation re-attempt - to acquire the semaphore to avoid a race with a late sem_post. - * sem_timedwait.c: Modify comments. - -2005-04-25 Ross Johnson - - * ptw32_relmillisecs.c: New module; converts future abstime to - milliseconds relative to 'now'. - * pthread_mutex_timedlock.c: Use new ptw32_relmillisecs routine in - place of internal code; remove the NEED_SEM code - this routine is now - implemented for builds that define NEED_SEM (WinCE etc) - * sem_timedwait.c: Likewise; after timeout or cancellation, - re-attempt to acquire the semaphore in case one has been posted since - the timeout/cancel occurred. Thanks to Stefan Mueller. - * Makefile: Add ptw32_relmillisecs.c module; remove - ptw32_{in,de}crease_semaphore.c modules. - * GNUmakefile: Likewise. - * Bmakefile: Likewise. - - * sem_init.c: Re-write the NEED_SEM code to be consistent with the - non-NEED_SEM code, but retaining use of an event in place of the w32 sema - for w32 systems that don't include semaphores (WinCE); - the NEED_SEM versions of semaphores has been broken for a long time but is - now fixed and supports all of the same routines as the non-NEED_SEM case. - * sem_destroy.c: Likewise. - * sem_wait.c: Likewise. - * sem_post.c: Likewise. - * sem_post_multple.c: Likewise. - * implement.h: Likewise. - * sem_timedwait.c: Likewise; this routine is now - implemented for builds that define NEED_SEM (WinCE etc). - * sem_trywait.c: Likewise. - * sem_getvalue.c: Likewise. - - * pthread_once.c: Yet more changes, reverting closer to Gottlob Frege's - first design, but retaining cancellation, priority boosting, and adding - preservation of W32 error codes to make pthread_once transparent to - GetLastError. - -2005-04-11 Ross Johnson - - * pthread_once.c (pthread_once): Added priority boosting to - solve starvation problem after once_routine cancellation. - See notes in file. - -2005-04-06 Kevin Lussier - - * Makefile: Added debug targets for all versions of the library. - -2005-04-01 Ross Johnson - - * GNUmakefile: Add target to build libpthreadGC1.a as a static link - library. - * Makefile: Likewise for pthreadGC1.lib. - -2005-04-01 Kevin Lussier - - * sem_timedwait.c (sem_timedwait): Increase size of temp variables to - avoid int overflows for large timeout values. - * implement.h (int64_t): Include or define. - -2005-03-31 Dimitar Panayotov ^M - - * pthread.h: Fix conditional defines for static linking. - * sched.h: Liekwise. - * semaphore.h: Likewise. - * dll.c (PTW32_STATIC_LIB): Module is conditionally included - in the build. - -2005-03-16 Ross Johnson ^M - - * pthread_setcancelstate.c: Undo the last change. - -2005-03-16 Ross Johnson ^M - - * pthread_setcancelstate.c: Don't check for an async cancel event - if the library is using alertable async cancel.. - -2005-03-14 Ross Johnson - - * pthread_once.c (pthread_once): Downgrade interlocked operations to simple - memory operations where these are protected by the critical section; edit - comments. - -2005-03-13 Ross Johnson - - * pthread_once.c (pthread_once): Completely redesigned; a change was - required to the ABI (pthread_once_t_), and resulting in a version - compatibility index increment. - - NOTES: - The design (based on pseudo code contributed by Gottlob Frege) avoids - creating a kernel object if there is no contention. See URL for details:- - http://sources.redhat.com/ml/pthreads-win32/2005/msg00029.html - This uses late initialisation similar to the technique already used for - pthreads-win32 mutexes and semaphores (from Alexander Terekhov). - - The subsequent cancelation cleanup additions (by rpj) could not be implemented - without sacrificing some of the efficiency in Gottlob's design. In particular, - although each once_control uses it's own event to block on, a global CS is - required to manage it - since the event must be either re-usable or - re-creatable under cancelation. This is not needed in the non-cancelable - design because it is able to mark the event as closed (forever). - - When uncontested, a CS operation is equivalent to an Interlocked operation - in speed. So, in the final design with cancelability, an uncontested - once_control operation involves a minimum of five interlocked operations - (including the LeaveCS operation). - - ALTERNATIVES: - An alternative design from Alexander Terekhov proposed using a named mutex, - as sketched below:- - - if (!once_control) { // May be in TLS - named_mutex::guard guard(&once_control2); - if (!once_control2) { - - once_control2 = true; - } - once_control = true; - } - - A more detailed description of this can be found here:- - http://groups.yahoo.com/group/boost/message/15442 - - [Although the definition of a suitable PTHREAD_ONCE_INIT precludes use of the - TLS located flag, this is not critical.] - - There are three primary concerns though:- - 1) The [named] mutex is 'created' even in the uncontended case. - 2) A system wide unique name must be generated. - 3) Win32 mutexes are VERY slow even in the uncontended case. An uncontested - Win32 mutex lock operation can be 50 (or more) times slower than an - uncontested EnterCS operation. - - Ultimately, the named mutex trick is making use of the global locks maintained - by the kernel. - - * pthread.h (pthread_once_t_): One flag and an event HANDLE added. - (PTHREAD_ONCE_INIT): Additional values included. - -2005-03-08 Ross Johnson - - * pthread_once.c (pthread_once): Redesigned to elliminate potential - starvation problem. - - reported by Gottlob Frege - - * ptw32_threadDestroy.c (ptw32_threadDestroy): Implicit threads were - not closing their Win32 thread duplicate handle. - - reported by Dmitrii Semii - -2005-01-25 Ralf Kubis - - * Attempted acquisition of recursive mutex was causing waiting - threads to not be woken when the mutex is released. - - * GNUmakefile (GCE): Generate correct version resource comments. - -2005-01-01 Konstantin Voronkov - - * pthread_mutex_lock.c (pthread_mutex_lock): The new atomic exchange - mutex algorithm is known to allow a thread to steal the lock off - FIFO waiting threads. The next waiting FIFO thread gets a spurious - wake-up and must attempt to re-acquire the lock. The woken thread - was setting itself as the mutex's owner before the re-acquisition. - -2004-11-22 Ross Johnson - - * pthread_cond_wait.c (ptw32_cond_wait_cleanup): Undo change - from 2004-11-02. - * Makefile (DLL_VER): Added for DLL naming suffix - see README. - * GNUmakefile (DLL_VER): Likewise. - * Wmakefile (DLL_VER): Likewise. - * Bmakefile (DLL_VER): Likewise. - * pthread.dsw (version.rc): Added to MSVS workspace. - -2004-11-20 Boudewijn Dekker - - * pthread_getspecific.c (pthread_getspecific): Check for - invalid (NULL) key argument. - -2004-11-19 Ross Johnson - - * config.h (PTW32_THREAD_ID_REUSE_INCREMENT): Added to allow - building the library for either unique thread IDs like Solaris - or non-unique thread IDs like Linux; allows application developers - to override the library's default insensitivity to some apps - that may not be strictly POSIX compliant. - * version.rc: New resource module to encode version information - within the DLL. - * pthread.h: Added PTW32_VERSION* defines and grouped sections - required by resource compiler together; bulk of file is skipped - if RC_INVOKED. Defined some error numbers and other names for - Borland compiler. - -2004-11-02 Ross Johnson - - * pthread_cond_wait.c (ptw32_cond_wait_cleanup): Lock CV mutex at - start of cleanup handler rather than at the end. - * implement.h (PTW32_THREAD_REUSE_EMPTY): Renamed from *_BOTTOM. - (ptw32_threadReuseBottom): New global variable. - * global.c (ptw32_threadReuseBottom): Declare new variable. - * ptw32_reuse.c (ptw32_reuse): Change reuse LIFO stack to LILO queue - to more evenly distribute use of reusable thread IDs; use renamed - PTW32_THREAD_REUSE_EMPTY. - * ptw32_processTerminate.c (ptw2_processTerminate): Use renamed - PTW32_THREAD_REUSE_EMPTY. - -2004-10-31 Ross Johnson - - * implement.h (PThreadState): Add new state value - 'PThreadStateCancelPending'. - * pthread_testcancel.c (pthread_testcancel): Use new thread - 'PThreadStateCancelPending' state as short cut to avoid entering - kernel space via WaitForSingleObject() call. This was obviated - by user space sema acquisition in sem_wait() and sem_timedwait(), - which are also cancelation points. A call to pthread_testcancel() - was required, which introduced a kernel call, effectively nullifying - any gains made by the user space sem acquisition checks. - * pthread_cancel.c (pthread_cancel): Set new thread - 'PThreadStateCancelPending' state. - -2004-10-29 Ross Johnson - - * implement.h (pthread_t): Renamed to ptw32_thread_t; struct contains - all thread state. - * pthread.h (ptw32_handle_t): New general purpose struct to serve - as a handle for various reusable object IDs - currently only used - by pthread_t; contains a pointer to ptw32_thread_t (thread state) - and a general purpose uint for use as a reuse counter or flags etc. - (pthread_t): typedef'ed to ptw32_handle_t; the uint is the reuse - counter that allows the library to maintain unique POSIX thread IDs. - When the pthread struct reuse stack was introduced, threads would - often acquire an identical ID to a previously destroyed thread. The - same was true for the pre-reuse stack library, by virtue of pthread_t - being the address of the thread struct. The new pthread_t retains - the reuse stack but provides virtually unique thread IDs. - * sem_wait.c (ptw32_sem_wait_cleanup): New routine used for - cancelation cleanup. - * sem_timedwait.c (ptw32_sem_timedwait_cleanup): Likewise. - -2004-10-22 Ross Johnson - - * sem_init.c (sem_init): Introduce a 'lock' element in order to - replace the interlocked operations with conventional serialisation. - This is needed in order to be able to atomically modify the sema - value and perform Win32 sema release operations. Win32 semaphores are - used instead of events in order to support efficient multiple posting. - If the whole modify/release isn't atomic, a race between - sem_timedwait() and sem_post() could result in a release when there is - no waiting semaphore, which would cause too many threads to proceed. - * sem_wait.c (sem_wait): Use new 'lock'element. - * sem_timedwait.c (sem_timedwait): Likewise. - * sem_trywait.c (sem_trywait): Likewise. - * sem_post.c (sem_post): Likewise. - * sem_post_multiple.c (sem_post_multiple): Likewise. - * sem_getvalue.c (sem_getvalue): Likewise. - * ptw32_semwait.c (ptw32_semwait): Likewise. - * sem_destroy.c (sem_destroy): Likewise; also tightened the conditions - for semaphore destruction; in particular, a semaphore will not be - destroyed if it has waiters. - * sem_timedwait.c (sem_timedwait): Added cancel cleanup handler to - restore sema value when cancelled. - * sem_wait.c (sem_wait): Likewise. - -2004-10-21 Ross Johnson - - * pthread_mutex_unlock.c (pthread_mutex_unlock): Must use PulseEvent() - rather than SetEvent() to reset the event if there are no waiters. - -2004-10-19 Ross Johnson - - * sem_init.c (sem_init): New semaphore model based on the same idea - as mutexes, i.e. user space interlocked check to avoid - unnecessarily entering kernel space. Wraps the Win32 semaphore and - keeps it's own counter. Although the motivation to do this has existed - for a long time, credit goes to Alexander Terekhov for providing - the logic. I have deviated slightly from AT's logic to add the waiters - count, which has made the code more complicated by adding cancelation - cleanup. This also appears to have broken the VCE (C++ EH) version of - the library (the same problem as previously reported - see BUGS #2), - only apparently not fixable using the usual workaround, nor by turning - all optimisation off. The GCE version works fine, so it is presumed to - be a bug in MSVC++ 6.0. The cancelation exception is thrown and caught - correctly, but the cleanup class destructor is never called. The failing - test is tests\semaphore4.c. - * sem_wait.c (sem_wait): Implemented user space check model. - * sem_post.c (sem_post): Likewise. - * sem_trywait.c (sem_trywait): Likewise. - * sem_timedwait.c (sem_timedwait): Likewise. - * sem_post_multiple.c (sem_post_multiple): Likewise. - * sem_getvalue.c (sem_getvalue): Likewise. - * ptw32_semwait.c (ptw32_semwait): Likewise. - * implement.h (sem_t_): Add counter element. - -2004-10-15 Ross Johnson - - * implement.h (pthread_mutex_t_): Use an event in place of - the POSIX semaphore. - * pthread_mutex_init.c: Create the event; remove semaphore init. - * pthread_mutex_destroy.c: Delete the event. - * pthread_mutex_lock.c: Replace the semaphore wait with the event wait. - * pthread_mutex_trylock.c: Likewise. - * pthread_mutex_timedlock.c: Likewise. - * pthread_mutex_unlock.c: Set the event. - -2004-10-14 Ross Johnson - - * pthread_mutex_lock.c (pthread_mutex_lock): New algorithm using - Terekhov's xchg based variation of Drepper's cmpxchg model. - Theoretically, xchg uses fewer clock cycles than cmpxchg (using IA-32 - as a reference), however, in my opinion bus locking dominates the - equation on smp systems, so the model with the least number of bus - lock operations in the execution path should win, which is Terekhov's - variant. On IA-32 uni-processor systems, it's faster to use the - CMPXCHG instruction without locking the bus than to use the XCHG - instruction, which always locks the bus. This makes the two variants - equal for the non-contended lock (fast lane) execution path on up - IA-32. Testing shows that the xchg variant is faster on up IA-32 as - well if the test forces higher lock contention frequency, even though - kernel calls should be dominating the times (on up IA-32, both - variants used CMPXCHG instructions and neither locked the bus). - * pthread_mutex_timedlock.c pthread_mutex_timedlock(): Similarly. - * pthread_mutex_trylock.c (pthread_mutex_trylock): Similarly. - * pthread_mutex_unlock.c (pthread_mutex_unlock): Similarly. - * ptw32_InterlockedCompareExchange.c (ptw32_InterlockExchange): New - function. - (PTW32_INTERLOCKED_EXCHANGE): Sets up macro to use inlined - ptw32_InterlockedExchange. - * implement.h (PTW32_INTERLOCKED_EXCHANGE): Set default to - InterlockedExchange(). - * Makefile: Building using /Ob2 so that asm sections within inline - functions are inlined. - -2004-10-08 Ross Johnson - - * pthread_mutex_destroy.c (pthread_mutex_destroy): Critical Section - element is no longer required. - * pthread_mutex_init.c (pthread_mutex_init): Likewise. - * pthread_mutex_lock.c (pthread_mutex_lock): New algorithm following - Drepper's paper at http://people.redhat.com/drepper/futex.pdf, but - using the existing semaphore in place of the futex described in the - paper. Idea suggested by Alexander Terekhov - see: - http://sources.redhat.com/ml/pthreads-win32/2003/msg00108.html - * pthread_mutex_timedlock.c pthread_mutex_timedlock(): Similarly. - * pthread_mutex_trylock.c (pthread_mutex_trylock): Similarly. - * pthread_mutex_unlock.c (pthread_mutex_unlock): Similarly. - * pthread_barrier_wait.c (pthread_barrier_wait): Use inlined version - of InterlockedCompareExchange() if possible - determined at - build-time. - * pthread_spin_destroy.c pthread_spin_destroy(): Likewise. - * pthread_spin_lock.c pthread_spin_lock():Likewise. - * pthread_spin_trylock.c (pthread_spin_trylock):Likewise. - * pthread_spin_unlock.c (pthread_spin_unlock):Likewise. - * ptw32_InterlockedCompareExchange.c: Sets up macro for inlined use. - * implement.h (pthread_mutex_t_): Remove Critical Section element. - (PTW32_INTERLOCKED_COMPARE_EXCHANGE): Set to default non-inlined - version of InterlockedCompareExchange(). - * private.c: Include ptw32_InterlockedCompareExchange.c first for - inlining. - * GNUmakefile: Add commandline option to use inlined - InterlockedCompareExchange(). - * Makefile: Likewise. - -2004-09-27 Ross Johnson - - * pthread_mutex_lock.c (pthread_mutex_lock): Separate - PTHREAD_MUTEX_NORMAL logic since we do not need to keep or check some - state required by other mutex types; do not check mutex pointer arg - for validity - leave this to the system since we are only checking - for NULL pointers. This should improve speed of NORMAL mutexes and - marginally improve speed of other type. - * pthread_mutex_trylock.c (pthread_mutex_trylock): Likewise. - * pthread_mutex_unlock.c (pthread_mutex_unlock): Likewise; also avoid - entering the critical section for the no-waiters case, with approx. - 30% reduction in lock/unlock overhead for this case. - * pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise; also - no longer keeps mutex if post-timeout second attempt succeeds - this - will assist applications that wish to impose strict lock deadlines, - rather than simply to escape from frozen locks. - -2004-09-09 Tristan Savatier - * pthread.h (struct pthread_once_t_): Qualify the 'done' element - as 'volatile'. - * pthread_once.c: Concerned about possible race condition, - specifically on MPU systems re concurrent access to multibyte types. - [Maintainer's note: the race condition is harmless on SPU systems - and only a problem on MPU systems if concurrent access results in an - exception (presumably generated by a hardware interrupt). There are - other instances of similar harmless race conditions that have not - been identified as issues.] - -2004-09-09 Ross Johnson - - * pthread.h: Declare additional types as volatile. - -2004-08-27 Ross Johnson - - * pthread_barrier_wait.c (pthread_barrier_wait): Remove excessive code - by substituting the internal non-cancelable version of sem_wait - (ptw32_semwait). - -2004-08-25 Ross Johnson - - * pthread_join.c (pthread_join): Rewrite and re-order the conditional - tests in an attempt to improve efficiency and remove a race - condition. - -2004-08-23 Ross Johnson - - * create.c (pthread_create): Don't create a thread if the thread - id pointer location (first arg) is inaccessible. A memory - protection fault will result if the thread id arg isn't an accessible - location. This is consistent with GNU/Linux but different to - Solaris or MKS (and possibly others), which accept NULL as meaning - 'don't return the created thread's ID'. Applications that run - using pthreads-win32 will run on all other POSIX threads - implementations, at least w.r.t. this feature. - - It was decided not to copy the Solaris et al behaviour because, - although it would have simplified some application porting (but only - from Solaris to Windows), the feature is not technically necessary, - and the alternative segfault behaviour helps avoid buggy application - code. - -2004-07-01 Anuj Goyal - - * builddmc.bat: New; Windows bat file to build the library. - * config.h (__DMC__): Support for Digital Mars compiler. - * create.c (__DMC__): Likewise. - * pthread_exit.c (__DMC__): Likewise. - * pthread_join.c (__DMC__): Likewise. - * ptw32_threadDestroy.c (__DMC__): Likewise. - * ptw32_threadStart.c (__DMC__): Likewise. - * ptw32_throw.c (__DMC__): Likewise. - -2004-06-29 Anuj Goyal - - * pthread.h (__DMC__): Initial support for Digital Mars compiler. - -2004-06-29 Will Bryant - - * README.Borland: New; description of Borland changes. - * Bmakefile: New makefile for the Borland make utility. - * ptw32_InterlockedCompareExchange.c: - Add Borland compatible asm code. - -2004-06-26 Jason Bard - - * pthread.h (HAVE_STRUCT_TIMESPEC): If undefined, define it - to avoid timespec struct redefined errors elsewhere in an - application. - -2004-06-21 Ross Johnson - - * pthread.h (PTHREAD_RECURSIVE_MUTEX_INITIALIZER): Mutex - initialiser added for compatibility with Linux threads and - others; currently not included in SUSV3. - * pthread.h (PTHREAD_ERRORCHECK_MUTEX_INITIALIZER): Likewise. - * pthread.h (PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP): Likewise. - * pthread.h (PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP): Likewise. - - * ptw32_mutex_check_need_init.c (ptw32_mutex_check_need_init): - Add new initialisers. - - * pthread_mutex_lock.c (pthread_mutex_lock): Check for new - initialisers. - * pthread_mutex_trylock.c (pthread_mutex_trylock): Likewise. - * pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise. - * pthread_mutex_unlock.c (pthread_mutex_unlock): Likewise. - * pthread_mutex_destroy.c (pthread_mutex_destroy): Likewise. - -2004-05-20 Ross Johnson - - * README.NONPORTABLE: Document pthread_win32_test_features_np(). - * FAQ: Update various answers. - -2004-05-19 Ross Johnson - - * Makefile: Don't define _WIN32_WINNT on compiler command line. - * GNUmakefile: Likewise. - -2004-05-16 Ross Johnson - - * pthread_cancel.c (pthread_cancel): Adapted to use auto-detected - QueueUserAPCEx features at run-time. - (ptw32_RegisterCancelation): Drop in replacement for QueueUserAPCEx() - if it can't be used. Provides older style non-preemptive async - cancelation. - * pthread_win32_attach_detach_np.c (pthread_win32_attach_np): - Auto-detect quserex.dll and the availability of alertdrv.sys; - initialise and close on process attach/detach. - * global.c (ptw32_register_cancelation): Pointer to either - QueueUserAPCEx() or ptw32_RegisterCancelation() depending on - availability. QueueUserAPCEx makes pre-emptive async cancelation - possible. - * implement.h: Add definitions and prototypes related to QueueUserAPC. - -2004-05-16 Panagiotis E. Hadjidoukas - - * QueueUserAPCEx (separate contributed package): Provides preemptive - APC feature. - * pthread_cancel.c (pthread_cancel): Initial integration of - QueueUserAPCEx into pthreads-win32 to provide true pre-emptive - async cancelation of threads, including blocked threads. - -2004-05-06 Makoto Kato - - * pthread.h (DWORD_PTR): Define typedef for older MSVC. - * pthread_cancel.c (AMD64): Add architecture specific Context register. - * ptw32_getprocessors.c: Use correct types (DWORD_PTR) for mask - variables. - -2004-04-06 P. van Bruggen - - * ptw32_threadDestroy.c: Destroy threadLock mutex to - close a memory leak. - -2004-02-13 Gustav Hallberg - - * pthread_equal.c: Remove redundant equality logic. - -2003-12-10 Philippe Di Cristo - - * sem_timedwait.c (sem_timedwait): Fix timeout calculations. - -2003-10-20 Alexander Terekhov - - * pthread_mutex_timedlock.c (ptw32_semwait): Move to individual module. - * ptw32_semwait.c: New module. - * pthread_cond_wait.c (ptw32_cond_wait_cleanup): Replace cancelable - sem_wait() call with non-cancelable ptw32_semwait() call. - * pthread.c (private.c): Re-order for inlining. GNU C warned that - function ptw32_semwait() was defined 'inline' after it was called. - * pthread_cond_signal.c (ptw32_cond_unblock): Likewise. - * pthread_delay_np.c: Disable Watcom warning with comment. - * *.c (process.h): Remove include from .c files. This is conditionally - included by the common project include files. - -2003-10-20 James Ewing - - * ptw32_getprocessors.c: Some Win32 environments don't have - GetProcessAffinityMask(), so always return CPU count = 1 for them. - * config.h (NEED_PROCESSOR_AFFINITY_MASK): Define for WinCE. - -2003-10-15 Ross Johnson - - * Re-indented all .c files using default GNU style to remove assorted - editor ugliness (used GNU indent utility in default style). - -2003-10-15 Alex Blanco - - * sem_init.c (sem_init): Would call CreateSemaphore even if the sema - struct calloc failed; was not freeing calloced memory if either - CreateSemaphore or CreateEvent failed. - -2003-10-14 Ross Johnson - - * pthread.h: Add Watcom compiler compatibility. Esssentially just add - the cdecl attribute to all exposed function prototypes so that Watcom - generates function call code compatible with non-Watcom built libraries. - By default, Watcom uses registers to pass function args if possible rather - than pushing to stack. - * semaphore.h: Likewise. - * sched.h: Likewise. - * pthread_cond_wait.c (ptw32_cond_wait_cleanup): Define with cdecl attribute - for Watcom compatibility. This routine is called via pthread_cleanup_push so - it had to match function arg definition. - * Wmakefile: New makefile for Watcom builds. - -2003-09-14 Ross Johnson - - * pthread_setschedparam.c (pthread_setschedparam): Attempt to map - all priority levels between max and min (as returned by - sched_get_priority_min/max) to reasonable Win32 priority levels - i.e. - levels between THREAD_PRIORITY_LOWEST/IDLE to THREAD_PRIORITY_LOWEST and - between THREAD_PRIORITY_HIGHEST/TIME_CRITICAL to THREAD_PRIORITY_HIGHEST - while others remain unchanged; record specified thread priority level - for return by pthread_getschedparam. - - Note that, previously, specified levels not matching Win32 priority levels - would silently leave the current thread priority unaltered. - - * pthread_getschedparam.c (pthread_getschedparam): Return the priority - level specified by the latest pthread_setschedparam or pthread_create rather - than the actual running thread priority as returned by GetThreadPriority - as - required by POSIX. I.e. temporary or adjusted actual priority levels are not - returned by this routine. - - * pthread_create.c (pthread_create): For priority levels specified via - pthread attributes, attempt to map all priority levels between max and - min (as returned by sched_get_priority_min/max) to reasonable Win32 - priority levels; record priority level given via attributes, or - inherited from parent thread, for later return by pthread_getschedparam. - - * ptw32_new.c (ptw32_new): Initialise pthread_t_ sched_priority element. - - * pthread_self.c (pthread_self): Set newly created implicit POSIX thread - sched_priority to Win32 thread's current actual priority. Temporarily - altered priorities can't be avoided in this case. - - * implement.h (struct pthread_t_): Add new sched_priority element. - -2003-09-12 Ross Johnson - - * sched_get_priority_min.c (sched_get_priority_min): On error should return -1 - with errno set. - * sched_get_priority_max.c (sched_get_priority_max): Likewise. - -2003-09-03 Ross Johnson - - * w32_cancelableWait.c (ptw32_cancelable_wait): Allow cancelation - of implicit POSIX threads as well. - -2003-09-02 Ross Johnson - - * pthread_win32_attach_detach_np.c (pthread_win32_thread_detach_np): - Add comment. - - * pthread_exit.c (pthread_exit): Fix to recycle the POSIX thread handle in - addition to calling user TSD destructors. Move the implicit POSIX thread exit - handling to ptw32_throw to centralise the logic. - - * ptw32_throw.c (ptw32_throw): Implicit POSIX threads have no point - to jump or throw to, so cleanup and exit the thread here in this case. For - processes using the C runtime, the exit code will be set to the POSIX - reason for the throw (i.e. PTHREAD_CANCEL or the value given to pthread_exit). - Note that pthread_exit() already had similar logic, which has been moved to - here. - - * ptw32_threadDestroy.c (ptw32_threadDestroy): Don't close the Win32 handle - of implicit POSIX threads - expect this to be done by Win32? - -2003-09-01 Ross Johnson - - * pthread_self.c (pthread_self): The newly aquired pthread_t must be - assigned to the reuse stack, not freed, if the routine fails somehow. - -2003-08-13 Ross Johnson - - * pthread_getschedparam.c (pthread_getschedparam): An invalid thread ID - parameter was returning an incorrect error value; now uses a more exhaustive - check for validity. - - * pthread_setschedparam.c (pthread_setschedparam): Likewise. - - * pthread_join.c (pthread_join): Now uses a more exhaustive - check for validity. - - * pthread_detach.c (pthread_detach): Likewise. - - * pthread_cancel.c (pthread_cancel): Likewise. - - * ptw32_threadDestroy.c (ptw32_threadDestroy): pthread_t structs are - never freed - push them onto a stack for reuse. - - * ptw32_new.c (ptw32_new): Check for reusable pthread_t before dynamically - allocating new memory for the struct. - - * pthread_kill.c (pthread_kill): New file; new routine; takes only a zero - signal arg so that applications can check the thread arg for validity; checks - that the underlying Win32 thread HANDLE is valid. - - * pthread.h (pthread_kill): Add prototype. - - * ptw32_reuse.c (ptw32_threadReusePop): New file; new routine; pop a - pthread_t off the reuse stack. pthread_t_ structs that have been destroyed, i.e. - have exited detached or have been joined, are cleaned up and put onto a reuse - stack. Consequently, thread IDs are no longer freed once calloced. The library - will attempt to get a struct off this stack before asking the system to alloc - new memory when creating threads. The stack is guarded by a global mutex. - (ptw32_threadReusePush): New routine; push a pthread_t onto the reuse stack. - - * implement.h (ptw32_threadReusePush): Add new prototype. - (ptw32_threadReusePop): Likewise. - (pthread_t): Add new element. - - * ptw32_processTerminate.c (ptw32_processTerminate): Delete the thread - reuse lock; free all thread ID structs on the thread reuse stack. - - * ptw32_processInitialize.c (ptw32_processInitialize): Initialise the - thread reuse lock. - -2003-07-19 Ross Johnson - - * GNUmakefile: modified to work under MsysDTK environment. - * pthread_spin_lock.c (pthread_spin_lock): Check for NULL arg. - * pthread_spin_unlock.c (pthread_spin_unlock): Likewise. - * pthread_spin_trylock.c (pthread_spin_trylock): Likewise; - fix incorrect pointer value if lock is dynamically initialised by - this function. - * sem_init.c (sem_init): Initialise sem_t value to quell compiler warning. - * sem_destroy.c (sem_destroy): Likewise. - * ptw32_threadStart.c (non-MSVC code sections): Include rather - than old-style ; fix all std:: namespace entities such as - std::terminate_handler instances and associated methods. - * ptw32_callUserDestroyRoutines.c (non-MSVC code sections): Likewise. - -2003-06-24 Piet van Bruggen - - * pthread_spin_destroy.c (pthread_spin_destroy): Was not freeing the - spinlock struct. - -2003-06-22 Nicolas Barry - - * pthread_mutex_destroy.c (pthread_mutex_destroy): When called - with a recursive mutex that was locked by the current thread, the - function was failing with a success return code. - -2003-05-15 Steven Reddie - - * pthread_win32_attach_detach_np.c (pthread_win32_process_detach_np): - NULLify ptw32_selfThreadKey after the thread is destroyed, otherwise - destructors calling pthreads routines might resurrect it again, creating - memory leaks. Call the underlying Win32 Tls routine directly rather than - pthread_setspecific(). - (pthread_win32_thread_detach_np): Likewise. - -2003-05-14 Viv - - * pthread.dsp: Change /MT compile flag to /MD. - -2003-03-04 Alexander Terekhov - - * pthread_mutex_timedlock.c (pthread_mutex_timedlock): Fix failure to - set ownership of mutex on second grab after abstime timeout. - - bug reported by Robert Strycek - -2002-12-17 Thomas Pfaff - - * pthread_mutex_lock.c (ptw32_semwait): New static routine to provide - a non-cancelable sem_wait() function. This is consistent with the - way that pthread_mutex_timedlock.c does it. - (pthread_mutex_lock): Use ptw32_semwait() instead of sem_wait(). - -2002-12-11 Thomas Pfaff - - * pthread_mutex_trylock.c: Should return EBUSY rather than EDEADLK. - * pthread_mutex_destroy.c: Remove redundant ownership test (the - trylock call does this for us); do not destroy a recursively locked - mutex. - -2002-09-20 Michael Johnson - - * pthread_cond_destroy.c (pthread_cond_destroy): - When two different threads exist, and one is attempting to - destroy a condition variable while the other is attempting to - initialize a condition variable that was created with - PTHREAD_COND_INITIALIZER, a deadlock can occur. Shrink - the ptw32_cond_list_lock critical section to fix it. - -2002-07-31 Ross Johnson - - * ptw32_threadStart.c (ptw32_threadStart): Thread cancelLock - destruction moved to ptw32_threadDestroy(). - - * ptw32_threadDestroy.c (ptw32_threadDestroy): Destroy - the thread's cancelLock. Moved here from ptw32_threadStart.c - to cleanup implicit threads as well. - -2002-07-30 Alexander Terekhov - - * pthread_cond_wait.c (ptw32_cond_wait_cleanup): - Remove code designed to avoid/prevent spurious wakeup - problems. It is believed that the sem_timedwait() call - is consuming a CV signal that it shouldn't and this is - breaking the avoidance logic. - -2002-07-30 Ross Johnson - - * sem_timedwait.c (sem_timedwait): Tighten checks for - unreasonable abstime values - that would result in - unexpected timeout values. - - * w32_CancelableWait.c (ptw32_cancelable_wait): - Tighten up return value checking and add comments. - - -2002-06-08 Ross Johnson - - * sem_getvalue.c (sem_getvalue): Now returns a value for the - NEED_SEM version (i.e. earlier versions of WinCE). - - -2002-06-04 Rob Fanner - - * sem_getvalue.c (sem_getvalue): The Johnson M. Hart - approach didn't work - we are forced to take an - intrusive approach. We try to decrement the sema - and then immediately release it again to get the - value. There is a small probability that this may - block other threads, but only momentarily. - -2002-06-03 Ross Johnson - - * sem_init.c (sem_init): Initialise Win32 semaphores - to _POSIX_SEM_VALUE_MAX (which this implementation - defines in pthread.h) so that sem_getvalue() can use - the trick described in the comments in sem_getvalue(). - * pthread.h (_POSIX_SEM_VALUE_MAX): Defined. - (_POSIX_SEM_NSEMS_MAX): Defined - not used but may be - useful for source code portability. - -2002-06-03 Rob Fanner - - * sem_getvalue.c (sem_getvalue): Did not work on NT. - Use approach suggested by Johnson M. Hart in his book - "Win32 System Programming". - -2002-02-28 Ross Johnson - - * errno.c: Compiler directive was incorrectly including code. - * pthread.h: Conditionally added some #defines from config.h - needed when not building the library. e.g. NEED_ERRNO, NEED_SEM. - (PTW32_DLLPORT): Now only defined if _DLL defined. - (_errno): Compiler directive was incorrectly including prototype. - * sched.h: Conditionally added some #defines from config.h - needed when not building the library. - * semaphore.h: Replace an instance of NEED_SEM that should - have been NEED_ERRNO. This change currently has nil effect. - - * GNUmakefile: Correct some recent changes. - - * Makefile: Add rule to generate pre-processor output. - -2002-02-23 Ross Johnson - - * pthread_rwlock_timedrdlock.c: New - untested. - * pthread_rwlock_timedwrlock.c: New - untested. - - * Testsuite passed (except known MSVC++ problems) - - * pthread_cond_destroy.c: Expand the time change - critical section to solve deadlock problem. - - * pthread.c: Add all remaining C modules. - * pthread.h: Use dllexport/dllimport attributes on functions - to avoid using pthread.def. - * sched.h: Likewise. - * semaphore.h: Likewise. - * GNUmakefile: Add new targets for single translation - unit build to maximise inlining potential; generate - pthread.def automatically. - * Makefile: Likewise, but no longer uses pthread.def. - -2002-02-20 Ross Johnson - - * pthread_cond_destroy.c (pthread_cond_destroy): - Enter the time change critical section earlier. - -2002-02-17 Ross Johnson - - * nonportable.c (pthread_delay_np): Make a true - cancelation point. Deferred cancels will interrupt the - wait. - -2002-02-07 Ross Johnson - - Reduced name space pollution. - ----------------------------- - When the appropriate symbols are defined, the headers - will restrict the definitions of new names. In particular, - it must be possible to NOT include the - header and related definitions with some combination - of symbol definitions. Secondly, it should be possible - that additional definitions should be limited to POSIX - compliant symbols by the definition of appropriate symbols. - - * pthread.h: POSIX conditionals. - * sched.h: POSIX conditionals. - * semaphore.h: POSIX conditionals. - - * semaphore.c: Included . - (sem_init): Changed magic 0x7FFFFFFFL to INT_MAX. - (sem_getvalue): Trial version. - - Reduce executable size. - ----------------------- - When linking with the static library, only those - routines actually called, either directly or indirectly - should be included. - - [Gcc has the -ffunction-segments option to do this but MSVC - doesn't have this feature as far as I can determine. Other - compilers are undetermined as well. - rpj] - - * semaphore.c: All routines are now in separate compilation units; - This file is used to congregate the separate modules for - potential inline optimisation and backward build compatibility. - * sem_close.c: Separated routine from semaphore.c. - * ptw32_decrease_semaphore.c: Likewise. - * sem_destroy.c: Likewise. - * sem_getvalue.c: Likewise. - * ptw32_increase_semaphore.c: Likewise. - * sem_init.c: Likewise. - * sem_open.c: Likewise. - * sem_post.c: Likewise. - * sem_post_multiple.c: Likewise. - * sem_timedwait.c: Likewise. - * sem_trywait.c: Likewise. - * sem_unlink.c: Likewise. - * sem_wait.c: Likewise. - -2002-02-04 Ross Johnson - - The following extends the idea above to the rest of pthreads-win32 - rpj - - * attr.c: All routines are now in separate compilation units; - This file is used to congregate the separate modules for - potential inline optimisation and backward build compatibility. - * pthread_attr_destroy.c: Separated routine from attr.c. - * pthread_attr_getdetachstate.c: Likewise. - * pthread_attr_getscope.c: Likewise. - * pthread_attr_getstackaddr.c: Likewise. - * pthread_attr_getstacksize.c: Likewise. - * pthread_attr_init.c: Likewise. - * pthread_attr_is_attr.c: Likewise. - * pthread_attr_setdetachstate.c: Likewise. - * pthread_attr_setscope.c: Likewise. - * pthread_attr_setstackaddr.c: Likewise. - * pthread_attr_setstacksize.c: Likewise. - - * pthread.c: Agregation of agregate modules for super-inlineability. - -2002-02-02 Ross Johnson - - * cancel.c: Rearranged some code and introduced checks - to disable cancelation at the start of a thread's cancelation - run to prevent double cancelation. The main problem - arises if a thread is canceling and then receives a subsequent - async cancel request. - * private.c: Likewise. - * condvar.c: Place pragmas around cleanup_push/pop to turn - off inline optimisation (/Obn where n>0 - MSVC only). Various - optimisation switches in MSVC turn this on, which interferes with - the way that cleanup handlers are run in C++ EH and SEH - code. Application code compiled with inline optimisation must - also wrap cleanup_push/pop blocks with the pragmas, e.g. - #pragma inline_depth(0) - pthread_cleanup_push(...) - ... - pthread_cleanup_pop(...) - #pragma inline_depth(8) - * rwlock.c: Likewise. - * mutex.c: Remove attempts to inline some functions. - * signal.c: Modify misleading comment. - -2002-02-01 Ross Johnson - - * semaphore.c (sem_trywait): Fix missing errno return - for systems that define NEED_SEM (e.g. early WinCE). - * mutex.c (pthread_mutex_timedlock): Return ENOTSUP - for systems that define NEED_SEM since they don't - have sem_trywait(). - -2002-01-27 Ross Johnson - - * mutex.c (pthread_mutex_timedlock): New function suggested by - Alexander Terekhov. The logic required to implement this - properly came from Alexander, with some collaboration - with Thomas Pfaff. - (pthread_mutex_unlock): Wrap the waiters check and sema - post in a critical section to prevent a race with - pthread_mutex_timedlock. - (ptw32_timed_semwait): New function; - returns a special result if the absolute timeout parameter - represents a time already passed when called; used by - pthread_mutex_timedwait(). Have deliberately not reused - the name "ptw32_sem_timedwait" because they are not the same - routine. - * condvar.c (ptw32_cond_timedwait): Use the new sem_timedwait() - instead of ptw32_sem_timedwait(), which now has a different - function. See previous. - * implement.h: Remove prototype for ptw32_sem_timedwait. - See next. - (pthread_mutex_t_): Add critical section element for access - to lock_idx during mutex post-timeout processing. - * semaphore.h (sem_timedwait): See next. - * semaphore.c (sem_timedwait): See next. - * private.c (ptw32_sem_timedwait): Move to semaphore.c - and rename as sem_timedwait(). - -2002-01-18 Ross Johnson - - * sync.c (pthread_join): Was getting the exit code from the - calling thread rather than the joined thread if - defined(__MINGW32__) && !defined(__MSVCRT__). - -2002-01-15 Ross Johnson - - * pthread.h: Unless the build explicitly defines __CLEANUP_SEH, - __CLEANUP_CXX, or __CLEANUP_C, then the build defaults to - __CLEANUP_C style cleanup. This style uses setjmp/longjmp - in the cancelation and thread exit implementations and therefore - won't do stack unwinding if linked to applications that have it - (e.g. C++ apps). This is currently consistent with most/all - commercial Unix POSIX threads implementations. - - * spin.c (pthread_spin_init): Edit renamed function call. - * nonportable.c (pthread_num_processors_np): New. - (pthread_getprocessors_np): Renamed to ptw32_getprocessors - and moved to private.c. - * private.c (pthread_getprocessors): Moved here from - nonportable.c. - * pthread.def (pthread_getprocessors_np): Removed - from export list. - - * rwlock.c (pthread_rwlockattr_init): New. - (pthread_rwlockattr_destroy): New. - (pthread_rwlockattr_getpshared): New. - (pthread_rwlockattr_setpshared): New. - -2002-01-14 Ross Johnson - - * attr.c (pthread_attr_setscope): Fix struct pointer - indirection error introduced 2002-01-04. - (pthread_attr_getscope): Likewise. - -2002-01-12 Ross Johnson - - * pthread.dsp (SOURCE): Add missing source files. - -2002-01-08 Ross Johnson - - * mutex.c (pthread_mutex_trylock): use - ptw32_interlocked_compare_exchange function pointer - rather than ptw32_InterlockedCompareExchange() directly - to retain portability to non-iX86 processors, - e.g. WinCE etc. The pointer will point to the native - OS version of InterlockedCompareExchange() if the - OS supports it (see ChangeLog entry of 2001-10-17). - -2002-01-07 Thomas Pfaff , Alexander Terekhov - - * mutex.c (pthread_mutex_init): Remove critical - section calls. - (pthread_mutex_destroy): Likewise. - (pthread_mutex_unlock): Likewise. - (pthread_mutex_trylock): Likewise; uses - ptw32_InterlockedCompareExchange() to avoid need for - critical section; library is no longer i386 compatible; - recursive mutexes now increment the lock count rather - than return EBUSY; errorcheck mutexes return EDEADLCK - rather than EBUSY. This behaviour is consistent with the - Solaris pthreads implementation. - * implement.h (pthread_mutex_t_): Remove critical - section element - no longer needed. - - -2002-01-04 Ross Johnson - - * attr.c (pthread_attr_setscope): Add more error - checking and actually store the scope value even - though it's not really necessary. - (pthread_attr_getscope): Return stored value. - * implement.h (pthread_attr_t_): Add new scope element. - * ANNOUNCE: Fix out of date comment next to - pthread_attr_setscope in conformance section. - -2001-12-21 Alexander Terekhov - - * mutex.c (pthread_mutex_lock): Decrementing lock_idx was - not thread-safe. - (pthread_mutex_trylock): Likewise. - -2001-10-26 prionx@juno.com - - * semaphore.c (sem_init): Fix typo and missing bracket - in conditionally compiled code. Only older versions of - WinCE require this code, hence it doesn't normally get - tested; somehow when sem_t reverted to an opaque struct - the calloc NULL check was left in the conditionally included - section. - (sem_destroy): Likewise, the calloced sem_t wasn't being freed. - -2001-10-25 Ross Johnson - - * GNUmakefile (libwsock32): Add to linker flags for - WSAGetLastError() and WSASetLastError(). - * Makefile (wsock32.lib): Likewise. - * create.c: Minor mostly inert changes. - * implement.h (PTW32_MAX): Move into here and renamed - from sched.h. - (PTW32_MIN): Likewise. - * GNUmakefile (TEST_ICE): Define if testing internal - implementation of InterlockedCompareExchange. - * Makefile (TEST_ICE): Likewise. - * private.c (TEST_ICE): Likewise. - -2001-10-24 Ross Johnson - - * attr.c (pthread_attr_setstacksize): Quell warning - from LCC by conditionally compiling the stacksize - validity check. LCC correctly warns that the condition - (stacksize < PTHREAD_STACK_MIN) is suspicious - because STACK_MIN is 0 and stacksize is of type - size_t (or unsigned int). - -2001-10-17 Ross Johnson - - * barrier.c: Move _LONG and _LPLONG defines into - implement.h; rename to PTW32_INTERLOCKED_LONG and - PTW32_INTERLOCKED_LPLONG respectively. - * spin.c: Likewise; ptw32_interlocked_compare_exchange used - in place of InterlockedCompareExchange directly. - * global.c (ptw32_interlocked_compare_exchange): Add - prototype for this new routine pointer to be used when - InterlockedCompareExchange isn't supported by Windows. - * nonportable.c (pthread_win32_process_attach_np): Check for - support of InterlockedCompareExchange in kernel32 and assign its - address to ptw32_interlocked_compare_exchange if it exists, or - our own ix86 specific implementation ptw32_InterlockedCompareExchange. - *private.c (ptw32_InterlockedCompareExchange): An - implementation of InterlockedCompareExchange() which is - specific to ix86; written directly in assembler for either - MSVC or GNU C; needed because Windows 95 doesn't support - InterlockedCompareExchange(). - - * sched.c (sched_get_priority_min): Extend to return - THREAD_PRIORITY_IDLE. - (sched_get_priority_max): Extend to return - THREAD_PRIORITY_CRITICAL. - -2001-10-15 Ross Johnson - - * spin.c (pthread_spin_lock): PTHREAD_SPINLOCK_INITIALIZER - was causing a program fault. - (pthread_spin_init): Could have alloced memory - without freeing under some error conditions. - - * mutex.c (pthread_mutex_init): Move memory - allocation of mutex struct after checking for - PROCESS_SHARED. - -2001-10-12 Ross Johnson - - * spin.c (pthread_spin_unlock): Was not returning - EPERM if the spinlock was not locked, for multi CPU - machines. - -2001-10-08 Ross Johnson - - * spin.c (pthread_spin_trylock): Was not returning - EBUSY for multi CPU machines. - -2001-08-24 Ross Johnson - - * condvar.c (pthread_cond_destroy): Remove cv element - that is no longer used. - * implement.h: Likewise. - -2001-08-23 Alexander Terekhov - - * condvar.c (pthread_cond_destroy): fix bug with - respect to deadlock in the case of concurrent - _destroy/_unblock; a condition variable can be destroyed - immediately after all the threads that are blocked on - it are awakened. - -2001-08-23 Phil Frisbie, Jr. - - * tsd.c (pthread_getspecific): Preserve the last - winsock error [from WSAGetLastError()]. - -2001-07-18 Scott McCaskill - - * mutex.c (pthread_mutexattr_init): Return ENOMEM - immediately and don't dereference the NULL pointer - if calloc fails. - (pthread_mutexattr_getpshared): Don't dereference - a pointer that is possibly NULL. - * barrier.c (pthread_barrierattr_init): Likewise - (pthread_barrierattr_getpshared): Don't dereference - a pointer that is possibly NULL. - * condvar.c (pthread_condattr_getpshared): Don't dereference - a pointer that is possibly NULL. - -2001-07-15 Ross Johnson - - * rwlock.c (pthread_rwlock_wrlock): Is allowed to be - a cancelation point; re-enable deferred cancelability - around the CV call. - -2001-07-10 Ross Johnson - - * barrier.c: Still more revamping. The exclusive access - mutex isn't really needed so it has been removed and replaced - by an InterlockedDecrement(). nSerial has been removed. - iStep is now dual-purpose. The process shared attribute - is now stored in the barrier struct. - * implement.h (pthread_barrier_t_): Lost some/gained one - elements. - * private.c (ptw32_threadStart): Removed some comments. - -2001-07-10 Ross Johnson - - * barrier.c: Revamped to fix the race condition. Two alternating - semaphores are used instead of the PulseEvent. Also improved - overall throughput by returning PTHREAD_BARRIER_SERIAL_THREAD - to the first waking thread. - * implement.h (pthread_barrier_t_): Revamped. - -2001-07-09 Ross Johnson - - * barrier.c: Fix several bugs in all routines. Now passes - tests/barrier5.c which is fairly rigorous. There is still - a non-optimal work-around for a race condition between - the barrier breeched event signal and event wait. Basically - the last (signalling) thread to hit the barrier yields - to allow any other threads, which may have lost the race, - to complete. - -2001-07-07 Ross Johnson - - * barrier.c: Changed synchronisation mechanism to a - Win32 manual reset Event and use PulseEvent to signal - waiting threads. If the implementation continued to use - a semaphore it would require a second semaphore and - some management to use them alternately as barriers. A - single semaphore allows threads to cascade from one barrier - through the next, leaving some threads blocked at the first. - * implement.h (pthread_barrier_t_): As per above. - * general: Made a number of other routines inlinable. - -2001-07-07 Ross Johnson - - * spin.c: Revamped and working; included static initialiser. - Now beta level. - * barrier.c: Likewise. - * condvar.c: Macro constant change; inline auto init routine. - * mutex.c: Likewise. - * rwlock.c: Likewise. - * private.c: Add support for spinlock initialiser. - * global.c: Likewise. - * implement.h: Likewise. - * pthread.h (PTHREAD_SPINLOCK_INITIALIZER): Fix typo. - -2001-07-05 Ross Johnson - - * barrier.c: Remove static initialisation - irrelevent - for this object. - * pthread.h (PTHREAD_BARRIER_INITIALIZER): Removed. - * rwlock.c (pthread_rwlock_wrlock): This routine is - not a cancelation point - disable deferred - cancelation around call to pthread_cond_wait(). - -2001-07-05 Ross Johnson - - * spin.c: New module implementing spin locks. - * barrier.c: New module implementing barriers. - * pthread.h (_POSIX_SPIN_LOCKS): defined. - (_POSIX_BARRIERS): Defined. - (pthread_spin_*): Defined. - (pthread_barrier*): Defined. - (PTHREAD_BARRIER_SERIAL_THREAD): Defined. - * implement.h (pthread_spinlock_t_): Defined. - (pthread_barrier_t_): Defined. - (pthread_barrierattr_t_): Defined. - - * mutex.c (pthread_mutex_lock): Return with the error - if an auto-initialiser initialisation fails. - - * nonportable.c (pthread_getprocessors_np): New; gets the - number of available processors for the current process. - -2001-07-03 Ross Johnson - - * pthread.h (_POSIX_READER_WRITER_LOCKS): Define it - if not already defined. - -2001-07-01 Alexander Terekhov - - * condvar.c: Fixed lost signal bug reported by Timur Aydin - (taydin@snet.net). - [RPJ (me) didn't translate the original algorithm - correctly.] - * semaphore.c: Added sem_post_multiple; this is a useful - routine, but it doesn't appear to be standard. For now it's - not an exported function. - -2001-06-25 Ross Johnson - - * create.c (pthread_create): Add priority inheritance - attributes. - * mutex.c (pthread_mutex_lock): Remove some overhead for - PTHREAD_MUTEX_NORMAL mutex types. Specifically, avoid - calling pthread_self() and pthread_equal() to check/set - the mutex owner. Introduce a new pseudo owner for this - type. Test results suggest increases in speed of up to - 90% for non-blocking locks. - This is the default type of mutex used internally by other - synchronising objects, ie. condition variables and - read-write locks. The test rwlock7.c shows about a - 30-35% speed increase over snapshot 2001-06-06. The - price of this is that the application developer - must ensure correct behaviour, or explicitly set the - mutex to a safer type such as PTHREAD_MUTEX_ERRORCHECK. - For example, PTHREAD_MUTEX_NORMAL (or PTHREAD_MUTEX_DEFAULT) - type mutexes will not return an error if a thread which is not - the owner calls pthread_mutex_unlock. The call will succeed - in unlocking the mutex if it is currently locked, but a - subsequent unlock by the true owner will then fail with EPERM. - This is however consistent with some other implementations. - (pthread_mutex_unlock): Likewise. - (pthread_mutex_trylock): Likewise. - (pthread_mutex_destroy): Likewise. - * attr.c (pthread_attr_init): PTHREAD_EXPLICIT_SCHED is the - default inheritance attribute; THREAD_PRIORITY_NORMAL is - the default priority for new threads. - * sched.c (pthread_attr_setschedpolicy): Added routine. - (pthread_attr_getschedpolicy): Added routine. - (pthread_attr_setinheritsched): Added routine. - (pthread_attr_getinheritsched): Added routine. - * pthread.h (sched_rr_set_interval): Added as a macro; - returns -1 with errno set to ENOSYS. - -2001-06-23 Ross Johnson - - *sched.c (pthread_attr_setschedparam): Add priority range - check. - (sched_setscheduler): New function; checks for a valid - pid and policy; checks for permission to set information - in the target process; expects pid to be a Win32 process ID, - not a process handle; the only scheduler policy allowed is - SCHED_OTHER. - (sched_getscheduler): Likewise, but checks for permission - to query. - * pthread.h (SCHED_*): Moved to sched.h as defined in the - POSIX standard. - * sched.h (SCHED_*): Moved from pthread.h. - (pid_t): Defined if necessary. - (sched_setscheduler): Defined. - (sched_getscheduler): Defined. - * pthread.def (sched_setscheduler): Exported. - (sched_getscheduler): Likewise. - -2001-06-23 Ralf Brese - - * create.c (pthread_create): Set thread priority from - thread attributes. - -2001-06-18 Ross Johnson - - * Made organisational-only changes to UWIN additions. - * dll.c (dllMain): Moved UWIN process attach code - to pthread_win32_process_attach_np(); moved - instance of pthread_count to global.c. - * global.c (pthread_count): Moved from dll.c. - * nonportable.c (pthread_win32_process_attach_np): - Moved _UWIN code to here from dll.c. - * implement.h (pthread_count): Define extern int. - * create.c (pthread_count): Remove extern int. - * private.c (pthread_count): Likewise. - * exit.c (pthread_count): Likewise. - -2001-06-18 David Korn - - * dll.c: Added changes necessary to work with UWIN. - * create.c: Likewise. - * pthread.h: Likewise. - * misc.c: Likewise. - * exit.c: Likewise. - * private.c: Likewise. - * implement.h: Likewise. - There is some room at the start of struct pthread_t_ - to implement the signal semantics in UWIN's posix.dll - although this is not yet complete. - * Nmakefile: Compatible with UWIN's Nmake utility. - * Nmakefile.tests: Likewise - for running the tests. - -2001-06-08 Ross Johnson - - * semaphore.h (sem_t): Fixed for compile and test. - * implement.h (sem_t_): Likewise. - * semaphore.c: Likewise. - * private.c (ptw32_sem_timedwait): Updated to use new - opaque sem_t. - -2001-06-06 Ross Johnson - - * semaphore.h (sem_t): Is now an opaque pointer; - moved actual definition to implement.h. - * implement.h (sem_t_): Move here from semaphore.h; - was the definition of sem_t. - * semaphore.c: Wherever necessary, changed use of sem - from that of a pointer to a pointer-pointer; added - extra checks for a valid sem_t; NULL sem_t when - it is destroyed; added extra checks when creating - and destroying sem_t elements in the NEED_SEM - code branches; changed from using a pthread_mutex_t - ((*sem)->mutex) to CRITICAL_SECTION ((*sem)->sem_lock_cs) - in NEED_SEM branches for access serialisation. - -2001-06-06 Ross Johnson - - * mutex.c (pthread_mutexattr_init): Remove - ptw32_mutex_default_kind. - -2001-06-05 Ross Johnson - - * nonportable.c (pthread_mutex_setdefaultkind_np): - Remove - should not have been included in the first place. - (pthread_mutex_getdefaultkind_np): Likewise. - * global.c (ptw32_mutex_default_kind): Likewise. - * mutex.c (pthread_mutex_init): Remove use of - ptw32_mutex_default_kind. - * pthread.h (pthread_mutex_setdefaultkind_np): Likewise. - (pthread_mutex_getdefaultkind_np): Likewise. - * pthread.def (pthread_mutexattr_setkind_np): Added. - (pthread_mutexattr_getkind_np): Likewise. - - * README: Many changes that should have gone in before - the last snapshot. - * README.NONPORTABLE: New - referred to by ANNOUNCE - but never created; documents the non-portable routines - included in the library - moved from README with new - routines added. - * ANNOUNCE (pthread_mutexattr_setkind_np): Added to - compliance list. - (pthread_mutexattr_getkind_np): Likewise. - -2001-06-04 Ross Johnson - - * condvar.c: Add original description of the algorithm as - developed by Terekhov and Thomas, plus reference to - README.CV. - -2001-06-03 Alexander Terekhov , Louis Thomas - - * condvar.c (pthread_cond_init): Completely revamped. - (pthread_cond_destroy): Likewise. - (ptw32_cond_wait_cleanup): Likewise. - (ptw32_cond_timedwait): Likewise. - (ptw32_cond_unblock): New general signaling routine. - (pthread_cond_signal): Now calls ptw32_cond_unblock. - (pthread_cond_broadcast): Likewise. - * implement.h (pthread_cond_t_): Revamped. - * README.CV: New; explanation of the above changes. - -2001-05-30 Ross Johnson - - * pthread.h (rand_r): Fake using _seed argument to quell - compiler warning (compiler should optimise this away later). - - * GNUmakefile (OPT): Leave symbolic information out of the library - and increase optimisation level - for smaller faster prebuilt - dlls. - -2001-05-29 Milan Gardian - - * Makefile: fix typo. - * pthreads.h: Fix problems with stdcall/cdecl conventions, in particular - remove the need for PT_STDCALL everywhere; remove warning supression. - * (errno): Fix the longstanding "inconsistent dll linkage" problem - with errno; now also works with /MD debugging libs - - warnings emerged when compiling pthreads library with /MD (or /MDd) - compiler switch, instead of /MT (or /MTd) (i.e. when compiling pthreads - using Multithreaded DLL CRT instead of Multithreaded statically linked - CRT). - * create.c (pthread_create): Likewise; fix typo. - * private.c (ptw32_threadStart): Eliminate use of terminate() which doesn't - throw exceptions. - * Remove unnecessary #includes from a number of modules - - [I had to #include malloc.h in implement.h for gcc - rpj]. - -2001-05-29 Thomas Pfaff - - * pthread.h (PTHREAD_MUTEX_DEFAULT): New; equivalent to - PTHREAD_MUTEX_DEFAULT_NP. - * (PTHREAD_MUTEX_NORMAL): Similarly. - * (PTHREAD_MUTEX_ERRORCHECK): Similarly. - * (PTHREAD_MUTEX_RECURSIVE): Similarly. - * (pthread_mutex_setdefaultkind_np): New; Linux compatibility stub - for pthread_mutexattr_settype. - * (pthread_mutexattr_getkind_np): New; Linux compatibility stub - for pthread_mutexattr_gettype. - * mutex.c (pthread_mutexattr_settype): New; allow - the following types of mutex: - PTHREAD_MUTEX_DEFAULT_NP - PTHREAD_MUTEX_NORMAL_NP - PTHREAD_MUTEX_ERRORCHECK_NP - PTHREAD_MUTEX_RECURSIVE_NP - * Note that PTHREAD_MUTEX_DEFAULT is equivalent to - PTHREAD_MUTEX_NORMAL - ie. mutexes should no longer - be recursive by default, and a thread will deadlock if it - tries to relock a mutex it already owns. This is inline with - other pthreads implementations. - * (pthread_mutex_lock): Process the lock request - according to the mutex type. - * (pthread_mutex_init): Eliminate use of Win32 mutexes as the - basis of POSIX mutexes - instead, a combination of one critical section - and one semaphore are used in conjunction with Win32 Interlocked* routines. - * (pthread_mutex_destroy): Likewise. - * (pthread_mutex_lock): Likewise. - * (pthread_mutex_trylock): Likewise. - * (pthread_mutex_unlock): Likewise. - * Use longjmp/setjmp to implement cancelation when building the library - using a C compiler which doesn't support exceptions, e.g. gcc -x c (note - that gcc -x c++ uses exceptions). - * Also fixed some of the same typos and eliminated PT_STDCALL as - Milan Gardian's patches above. - -2001-02-07 Alexander Terekhov - - * rwlock.c: Revamped. - * implement.h (pthread_rwlock_t_): Redefined. - This implementation does not have reader/writer starvation problem. - Rwlock attempts to behave more like a normal mutex with - races and scheduling policy determining who is more important; - It also supports recursive locking, - has less synchronization overhead (no broadcasts at all, - readers are not blocked on any condition variable) and seem to - be faster than the current implementation [W98 appears to be - approximately 15 percent faster at least - on top of speed increase - from Thomas Pfaff's changes to mutex.c - rpj]. - -2000-12-29 Ross Johnson - - * Makefile: Back-out "for" loops which don't work. - - * GNUmakefile: Remove the fake.a target; add the "realclean" - target; don't remove built libs under the "clean" target. - - * config.h: Add a guard against multiple inclusion. - - * semaphore.h: Add some defines from config.h to make - semaphore.h independent of config.h when building apps. - - * pthread.h (_errno): Back-out previous fix until we know how to - fix it properly. - - * implement.h (lockCount): Add missing element to pthread_mutex_t_. - - * sync.c (pthread_join): Spelling fix in comment. - - * private.c (ptw32_threadStart): Reset original termination - function (C++). - (ptw32_threadStart): Cleanup detached threads early in case - the library is statically linked. - (ptw32_callUserDestroyRoutines): Remove [SEH] __try block from - destructor call so that unhandled exceptions will be passed through - to the system; call terminate() from [C++] try block for the same - reason. - - * tsd.c (pthread_getspecific): Add comment. - - * mutex.c (pthread_mutex_init): Initialise new elements in - pthread_mutex_t. - (pthread_mutex_unlock): Invert "pthread_equal()" test. - -2000-12-28 Ross Johnson - - * semaphore.c (mode_t): Use ifndef HAVE_MODE_T to include definition. - - * config.h.in (HAVE_MODE_T): Added. - (_UWIN): Start adding defines for the UWIN package. - - * private.c (ptw32_threadStart): Unhandled exceptions are - now passed through to the system to deal with. This is consistent - with normal Windows behaviour. C++ applications may use - set_terminate() to override the default behaviour which is - to call ptw32_terminate(). Ptw32_terminate() cleans up some - POSIX thread stuff before calling the system default function - which calls abort(). The users termination function should conform - to standard C++ semantics which is to not return. It should - exit the thread (call pthread_exit()) or exit the application. - * private.c (ptw32_terminate): Added as the default set_terminate() - function. It calls the system default function after cleaning up - some POSIX thread stuff. - - * implement.h (ptw32_try_enter_critical_section): Move - declaration. - * global.c (ptw32_try_enter_critical_section): Moved - from dll.c. - * dll.c: Move process and thread attach/detach code into - functions in nonportable.c. - * nonportable.c (pthread_win32_process_attach_np): Process - attach code from dll.c is now available to static linked - applications. - * nonportable.c (pthread_win32_process_detach_np): Likewise. - * nonportable.c (pthread_win32_thread_attach_np): Likewise. - * nonportable.c (pthread_win32_thread_detach_np): Likewise. - - * pthread.h: Add new non-portable prototypes for static - linked applications. - - * GNUmakefile (OPT): Increase optimisation flag and remove - debug info flag. - - * pthread.def: Add new non-portable exports for static - linked applications. - -2000-12-11 Ross Johnson - - * FAQ: Update Answer 6 re getting a fully working - Mingw32 built library. - -2000-10-10 Steven Reddie - - * misc.c (pthread_self): Restore Win32 "last error" - cleared by TlsGetValue() call in - pthread_getspecific() - -2000-09-20 Arthur Kantor - - * mutex.c (pthread_mutex_lock): Record the owner - of the mutex. This requires also keeping count of - recursive locks ourselves rather than leaving it - to Win32 since we need to know when to NULL the - thread owner when the mutex is unlocked. - (pthread_mutex_trylock): Likewise. - (pthread_mutex_unlock): Check that the calling - thread owns the mutex, decrement the recursive - lock count, and NULL the owner if zero. Return - EPERM if the mutex is owned by another thread. - * implement.h (pthread_mutex_t_): Add ownerThread - and lockCount members. - -2000-09-13 Jef Gearhart - - * mutex.c (pthread_mutex_init): Call - TryEnterCriticalSection through the pointer - rather than directly so that the dll can load - on Windows versions that can't resolve the - function, eg. Windows 95 - -2000-09-09 Ross Johnson - - * pthread.h (ctime_r): Fix arg. - -2000-09-08 Ross Johnson - - * GNUmakefile(_WIN32_WINNT=0x400): Define in CFLAGS; - doesn't seem to be needed though. - - * cancel.c (pthread_cancel): Must get "self" through - calling pthread_self() which will ensure a POSIX thread - struct is built for non-POSIX threads; return an error - if this fails - - Ollie Leahy - (pthread_setcancelstate): Likewise. - (pthread_setcanceltype): Likewise. - * misc.c (ptw32_cancelable_wait): Likewise. - - * private.c (ptw32_tkAssocCreate): Remove unused #if 0 - wrapped code. - - * pthread.h (ptw32_get_exception_services_code): - Needed to be forward declared unconditionally. - -2000-09-06 Ross Johnson - - * cancel.c (pthread_cancel): If called from the main - thread "self" would be NULL; get "self" via pthread_self() - instead of directly from TLS so that an implicit - pthread object is created. - - * misc.c (pthread_equal): Strengthen test for NULLs. - -2000-09-02 Ross Johnson - - * condvar.c (ptw32_cond_wait_cleanup): Ensure that all - waking threads check if they are the last, and notify - the broadcaster if so - even if an error occurs in the - waiter. - - * semaphore.c (_decrease_semaphore): Should be - a call to ptw32_decrease_semaphore. - (_increase_semaphore): Should be a call to - ptw32_increase_semaphore. - - * misc.c (ptw32_cancelable_wait): Renamed from - CancelableWait. - * rwlock.c (_rwlock_check*): Renamed to - ptw32_rwlock_check*. - * mutex.c (_mutex_check*): Renamed to ptw32_mutex_check*. - * condvar.c (cond_timed*): Renamed to ptw32_cond_timed*. - (_cond_check*): Renamed to ptw32_cond_check*. - (cond_wait_cleanup*): Rename to ptw32_cond_wait_cleanup*. - (ptw32_cond_timedwait): Add comments. - -2000-08-22 Ross Johnson - - * private.c (ptw32_throw): Fix exception test; - move exceptionInformation declaration. - - * tsd.c (pthread_key_create): newkey wrongly declared. - - * pthread.h: Fix comment block. - -2000-08-18 Ross Johnson - - * mutex.c (pthread_mutex_destroy): Check that the mutex isn't - held; invalidate the mutex as early as possible to avoid - contention; not perfect - FIXME! - - * rwlock.c (pthread_rwlock_init): Remove redundant assignment - to "rw". - (pthread_rwlock_destroy): Invalidate the rwlock before - freeing up any of it's resources - to avoid contention. - - * private.c (ptw32_tkAssocCreate): Change assoc->lock - to use a dynamically initialised mutex - only consumes - a W32 mutex or critical section when first used, - not before. - - * mutex.c (pthread_mutex_init): Remove redundant assignment - to "mx". - (pthread_mutexattr_destroy): Set attribute to NULL - before freeing it's memory - to avoid contention. - - * implement.h (PTW32_EPS_CANCEL/PTW32_EPS_EXIT): - Must be defined for all compilers - used as generic - exception selectors by ptw32_throw(). - - * Several: Fix typos from scripted edit session - yesterday. - - * nonportable.c (pthread_mutexattr_setforcecs_np): - Moved this function from mutex.c. - (pthread_getw32threadhandle_np): New function to - return the win32 thread handle that the POSIX - thread is using. - * mutex.c (pthread_mutexattr_setforcecs_np): - Moved to new file "nonportable.c". - - * pthread.h (PTW32_BUILD): Only redefine __except - and catch compiler keywords if we aren't building - the library (ie. PTW32_BUILD is not defined) - - this is safer than defining and then undefining - if not building the library. - * implement.h: Remove __except and catch undefines. - * Makefile (CFLAGS): Define PTW32_BUILD. - * GNUmakefile (CFLAGS): Define PTW32_BUILD. - - * All appropriate: Change Pthread_exception* to - ptw32_exception* to be consistent with internal - identifier naming. - - * private.c (ptw32_throw): New function to provide - a generic exception throw for all internal - exceptions and EH schemes. - (ptw32_threadStart): pthread_exit() value is now - returned via the thread structure exitStatus - element. - * exit.c (pthread_exit): pthread_exit() value is now - returned via the thread structure exitStatus - element. - * cancel.c (ptw32_cancel_self): Now uses ptw32_throw. - (pthread_setcancelstate): Ditto. - (pthread_setcanceltype): Ditto. - (pthread_testcancel): Ditto. - (pthread_cancel): Ditto. - * misc.c (CancelableWait): Ditto. - * exit.c (pthread_exit): Ditto. - * All applicable: Change PTW32_ prefix to - PTW32_ prefix to remove leading underscores - from private library identifiers. - -2000-08-17 Ross Johnson - - * All applicable: Change _pthread_ prefix to - ptw32_ prefix to remove leading underscores - from private library identifiers (single - and double leading underscores are reserved in the - ANSI C standard for compiler implementations). - - * tsd.c (pthread_create_key): Initialise temporary - key before returning it's address to avoid race - conditions. - -2000-08-13 Ross Johnson - - * errno.c: Add _MD precompile condition; thus far - had no effect when using /MD compile option but I - thnk it should be there. - - * exit.c: Add __cplusplus to various #if lines; - was compiling SEH code even when VC++ had - C++ compile options. - - * private.c: ditto. - - * create.c (pthread_create): Add PT_STDCALL macro to - function pointer arg in _beginthread(). - - * pthread.h: PT_STDCALL really does need to be defined - in both this and impliment.h; don't set it to __cdecl - - this macro is only used to extend function pointer - casting for functions that will be passed as parameters. - (~PThreadCleanup): add cast and group expression. - (_errno): Add _MD compile conditional. - (PtW32NoCatchWarn): Change pragma message. - - * implement.h: Move and change PT_STDCALL define. - - * need_errno.h: Add _MD to compilation conditional. - - * GNUmakefile: Substantial rewrite for new naming - convention; set for nil optimisation (turn it up - when we have a working library build; add target - "fake.a" to build a libpthreadw32.a from the VC++ - built DLL pthreadVCE.dll. - - * pthread.def (LIBRARY): Don't specify in the .def - file - it is specified on the linker command line - since we now use the same .def file for variously - named .dlls. - - * Makefile: Substantial rewrite for new naming - convention; default nmake target only issues a - help message; run nmake with specific target - corresponding to the EH scheme being used. - - * README: Update information; add naming convention - explanation. - - * ANNOUNCE: Update information. - -2000-08-12 Ross Johnson - - * pthread.h: Add compile-time message when using - MSC_VER compiler and C++ EH to warn application - programmers to use PtW32Catch instead of catch(...) - if they want cancelation and pthread_exit to work. - - * implement.h: Remove #include ; we - use our own local semaphore.h. - -2000-08-10 Ross Johnson - - * cleanup.c (pthread_pop_cleanup): Remove _pthread - prefix from __except and catch keywords; implement.h - now simply undefines ptw32__except and - ptw32_catch if defined; VC++ was not textually - substituting ptw32_catch etc back to catch as - it was redefined; the reason for using the prefixed - version was to make it clear that it was not using - the pthread.h redefined catch keyword. - - * private.c (ptw32_threadStart): Ditto. - (ptw32_callUserDestroyRoutines): Ditto. - - * implement.h (ptw32__except): Remove #define. - (ptw32_catch): Remove #define. - - * GNUmakefile (pthread.a): New target to build - libpthread32.a from pthread.dll using dlltool. - - * buildlib.bat: Duplicate cl commands with args to - build C++ EH version of pthread.dll; use of .bat - files is redundant now that nmake compatible - Makefile is included; used as a kludge only now. - - * Makefile: Localise some macros and fix up the clean: - target to extend it and work properly. - - * CONTRIBUTORS: Add contributors. - - * ANNOUNCE: Updated. - - * README: Updated. - -2000-08-06 Ross Johnson - - * pthread.h: Remove #warning - VC++ doesn't accept it. - -2000-08-05 Ross Johnson - - * pthread.h (PtW32CatchAll): Add macro. When compiling - applications using VC++ with C++ EH rather than SEH - 'PtW32CatchAll' must be used in place of any 'catch( ... )' - if the application wants pthread cancelation or - pthread_exit() to work. - -2000-08-03 Ross Johnson - - * pthread.h: Add a base class ptw32_exception for - library internal exceptions and change the "catch" - re-define macro to use it. - -2000-08-02 Ross Johnson - - * GNUmakefile (CFLAGS): Add -mthreads. - Add new targets to generate cpp and asm output. - - * sync.c (pthread_join): Remove dead code. - -2000-07-25 Tristan Savatier - - * sched.c (sched_get_priority_max): Handle different WinCE and - Win32 priority values together. - (sched_get_priority_min): Ditto. - -2000-07-25 Ross Johnson - - * create.c (pthread_create): Force new threads to wait until - pthread_create has the new thread's handle; we also retain - a local copy of the handle for internal use until - pthread_create returns. - - * private.c (ptw32_threadStart): Initialise ei[]. - (ptw32_threadStart): When beginthread is used to start the - thread, force waiting until the creator thread had the - thread handle. - - * cancel.c (ptw32_cancel_thread): Include context switch - code for defined(_X86_) environments in addition to _M_IX86. - - * rwlock.c (pthread_rwlock_destroy): Assignment changed - to avoid compiler warning. - - * private.c (ptw32_get_exception_services_code): Cast - NULL return value to avoid compiler warning. - - * cleanup.c (pthread_pop_cleanup): Initialise "cleanup" variable - to avoid compiler warnings. - - * misc.c (ptw32_new): Change "new" variable to "t" to avoid - confusion with the C++ keyword of the same name. - - * condvar.c (cond_wait_cleanup): Initialise lastWaiter variable. - (cond_timedwait): Remove unused local variables. to avoid - compiler warnings. - - * dll.c (dllMain): Remove 2000-07-21 change - problem - appears to be in pthread_create(). - -2000-07-22 Ross Johnson - - * tsd.c (pthread_key_create): If a destructor was given - and the pthread_mutex_init failed, then would try to - reference a NULL pointer (*key); eliminate this section of - code by using a dynamically initialised mutex - (PTHREAD_MUTEX_INITIALIZER). - - * tsd.c (pthread_setspecific): Return an error if - unable to set the value; simplify cryptic conditional. - - * tsd.c (pthread_key_delete): Locking threadsLock relied - on mutex_lock returning an error if the key has no destructor. - ThreadsLock is only initialised if the key has a destructor. - Making this mutex a static could reduce the number of mutexes - used by an application since it is actually created only at - first use and it's often destroyed soon after. - -2000-07-22 Ross Johnson - - * FAQ: Added Q5 and Q6. - -2000-07-21 David Baggett - - * dll.c: Include resource leakage work-around. This is a - partial FIXME which doesn't stop all leakage. The real - problem needs to be found and fixed. - -2000-07-21 Ross Johnson - - * create.c (pthread_create): Set threadH to 0 (zero) - everywhere. Some assignments were using NULL. Maybe - it should be NULL everywhere - need to check. (I know - they are nearly always the same thing - but not by - definition.) - - * misc.c (pthread_self): Try to catch NULL thread handles - at the point where they might be generated, even though - they should always be valid at this point. - - * tsd.c (pthread_setspecific): return an error value if - pthread_self() returns NULL. - - * sync.c (pthread_join): return an error value if - pthread_self() returns NULL. - - * signal.c (pthread_sigmask): return an error value if - pthread_self() returns NULL. - -2000-03-02 Ross Johnson - - * attr.c (pthread_attr_init): Set default stacksize to zero (0) - rather than PTHREAD_STACK_MIN even though these are now the same. - - * pthread.h (PTHREAD_STACK_MIN): Lowered to 0. - -2000-01-28 Ross Johnson - - * mutex.c (pthread_mutex_init): Free mutex if it has been alloced; - if critical sections can be used instead of Win32 mutexes, test - that the critical section works and return an error if not. - -2000-01-07 Ross Johnson - - * cleanup.c (pthread_pop_cleanup): Include SEH code only if MSC is not - compiling as C++. - (pthread_push_cleanup): Include SEH code only if MSC is not - compiling as C++. - - * pthread.h: Include SEH code only if MSC is not - compiling as C++. - - * implement.h: Include SEH code only if MSC is not - compiling as C++. - - * cancel.c (ptw32_cancel_thread): Add _M_IX86 check. - (pthread_testcancel): Include SEH code only if MSC is not - compiling as C++. - (ptw32_cancel_self): Include SEH code only if MSC is not - compiling as C++. - -2000-01-06 Erik Hensema - - * Makefile: Remove inconsistencies in 'cl' args - -2000-01-04 Ross Johnson - - * private.c (ptw32_get_exception_services_code): New; returns - value of EXCEPTION_PTW32_SERVICES. - (ptw32_processInitialize): Remove initialisation of - ptw32_exception_services which is no longer needed. - - * pthread.h (ptw32_exception_services): Remove extern. - (ptw32_get_exception_services_code): Add function prototype; - use this to return EXCEPTION_PTW32_SERVICES value instead of - using the ptw32_exception_services variable which I had - trouble exporting through pthread.def. - - * global.c (ptw32_exception_services): Remove declaration. - -1999-11-22 Ross Johnson - - * implement.h: Forward declare ptw32_new(); - - * misc.c (ptw32_new): New; alloc and initialise a new pthread_t. - (pthread_self): New thread struct is generated by new routine - ptw32_new(). - - * create.c (pthread_create): New thread struct is generated - by new routine ptw32_new(). - -1999-11-21 Ross Johnson - - * global.c (ptw32_exception_services): Declare new variable. - - * private.c (ptw32_threadStart): Destroy thread's - cancelLock mutex; make 'catch' and '__except' usageimmune to - redfinitions in pthread.h. - (ptw32_processInitialize): Init new constant ptw32_exception_services. - - * create.c (pthread_create): Initialise thread's cancelLock - mutex. - - * cleanup.c (pthread_pop_cleanup): Make 'catch' and '__except' - usage immune to redfinition s in pthread.h. - - * private.c: Ditto. - - * pthread.h (catch): Redefine 'catch' so that C++ applications - won't catch our internal exceptions. - (__except): ditto for __except. - - * implement.h (ptw32_catch): Define internal version - of 'catch' because 'catch' is redefined by pthread.h. - (__except): ditto for __except. - (struct pthread_t_): Add cancelLock mutex for async cancel - safety. - -1999-11-21 Jason Nye , Erik Hensema - - * cancel.c (ptw32_cancel_self): New; part of the async - cancellation implementation. - (ptw32_cancel_thread): Ditto; this function is X86 - processor specific. - (pthread_setcancelstate): Add check for pending async - cancel request and cancel the calling thread if - required; add async-cancel safety lock. - (pthread_setcanceltype): Ditto. - -1999-11-13 Erik Hensema - - * configure.in (AC_OUTPUT): Put generated output into GNUmakefile - rather than Makefile. Makefile will become the MSC nmake compatible - version - -1999-11-13 John Bossom (John.Bossom@cognos.com> - - * misc.c (pthread_self): Add a note about GetCurrentThread - returning a pseudo-handle - -1999-11-10 Todd Owen - - * dll.c (dllMain): Free kernel32 ASAP. - If TryEnterCriticalSection is not being used, then free - the kernel32.dll handle now, rather than leaving it until - DLL_PROCESS_DETACH. - - Note: this is not a pedantic exercise in freeing unused - resources! It is a work-around for a bug in Windows 95 - (see microsoft knowledge base article, Q187684) which - does Bad Things when FreeLibrary is called within - the DLL_PROCESS_DETACH code, in certain situations. - Since w95 just happens to be a platform which does not - provide TryEnterCriticalSection, the bug will be - effortlessly avoided. - -1999-11-10 Ross Johnson - - * sync.c (pthread_join): Make it a deferred cancelation point. - - * misc.c (pthread_self): Explicitly initialise implicitly - created thread state to default values. - -1999-11-05 Tristan Savatier - - * pthread.h (winsock.h): Include unconditionally. - (ETIMEDOUT): Change fallback value to that defined by winsock.h. - - * general: Patched for portability to WinCE. The details are - described in the file WinCE-PORT. Follow the instructions - in README.WinCE to make the appropriate changes in config.h. - -1999-10-30 Erik Hensema - - * create.c (pthread_create): Explicitly initialise thread state to - default values. - - * cancel.c (pthread_setcancelstate): Check for NULL 'oldstate' - for compatibility with Solaris pthreads; - (pthread_setcanceltype): ditto: - -1999-10-23 Erik Hensema - - * pthread.h (ctime_r): Fix incorrect argument "_tm" - -1999-10-21 Aurelio Medina - - * pthread.h (_POSIX_THREADS): Only define it if it isn't - already defined. Projects may need to define this on - the CC command line under Win32 as it doesn't have unistd.h - -1999-10-17 Ross Johnson - - * rwlock.c (pthread_rwlock_destroy): Add cast to remove compile - warning. - - * condvar.c (pthread_cond_broadcast): Only release semaphores - if there are waiting threads. - -1999-10-15 Lorin Hochstein , Peter Slacik - - * condvar.c (cond_wait_cleanup): New static cleanup handler for - cond_timedwait; - (cond_timedwait): pthread_cleanup_push args changed; - canceling a thread while it's in pthread_cond_wait - will now decrement the waiters count and cleanup if it's the - last waiter. - -1999-10-15 Graham Dumpleton - - * condvar.c (cond_wait_cleanup): the last waiter will now reset the CV's - wasBroadcast flag - -Thu Sep 16 1999 Ross Johnson - - * rwlock.c (pthread_rwlock_destroy): Add serialisation. - (_rwlock_check_need_init): Check for detroyed rwlock. - * rwlock.c: Check return codes from _rwlock_check_need_init(); - modify comments; serialise access to rwlock objects during - operations; rename rw_mutex to rw_lock. - * implement.h: Rename rw_mutex to rw_lock. - * mutex.c (pthread_mutex_destroy): Add serialisation. - (_mutex_check_need_init): Check for detroyed mutex. - * condvar.c (pthread_cond_destroy): Add serialisation. - (_cond_check_need_init): Check for detroyed condvar. - * mutex.c: Modify comments. - * condvar.c: Modify comments. - -1999-08-10 Aurelio Medina - - * implement.h (pthread_rwlock_t_): Add. - * pthread.h (pthread_rwlock_t): Add. - (PTHREAD_RWLOCK_INITIALIZER): Add. - Add rwlock function prototypes. - * rwlock.c: New module. - * pthread.def: Add new rwlock functions. - * private.c (ptw32_processInitialize): initialise - ptw32_rwlock_test_init_lock critical section. - * global.c (ptw32_rwlock_test_init_lock): Add. - - * mutex.c (pthread_mutex_destroy): Don't free mutex memory - if mutex is PTHREAD_MUTEX_INITIALIZER and has not been - initialised yet. - -1999-08-08 Milan Gardian - - * mutex.c (pthread_mutex_destroy): Free mutex memory. - -1999-08-22 Ross Johnson - - * exit.c (pthread_exit): Fix reference to potentially - uninitialised pointer. - -1999-08-21 Ross Johnson - - * private.c (ptw32_threadStart): Apply fix of 1999-08-19 - this time to C++ and non-trapped C versions. Ommitted to - do this the first time through. - -1999-08-19 Ross Johnson - - * private.c (ptw32_threadStart): Return exit status from - the application thread startup routine. - - Milan Gardian - -1999-08-18 John Bossom - - * exit.c (pthread_exit): Put status into pthread_t->exitStatus - * private.c (ptw32_threadStart): Set pthread->exitStatus - on exit of try{} block. - * sync.c (pthread_join): use pthread_exitStatus value if the - thread exit doesn't return a value (for Mingw32 CRTDLL - which uses endthread instead of _endthreadex). - -Tue Aug 17 20:17:58 CDT 1999 Mumit Khan - - * create.c (pthread_create): Add CRTDLL suppport. - * exit.c (pthread_exit): Likewise. - * private.c (ptw32_threadStart): Likewise. - (ptw32_threadDestroy): Likewise. - * sync.c (pthread_join): Likewise. - * tests/join1.c (main): Warn about partial support for CRTDLL. - -Tue Aug 17 20:00:08 1999 Mumit Khan - - * Makefile.in (LD): Delete entry point. - * acconfig.h (STDCALL): Delete unused macro. - * configure.in: Remove test for STDCALL. - * config.h.in: Regenerate. - * errno.c (_errno): Fix self type. - * pthread.h (PT_STDCALL): Move from here to - * implement.h (PT_STDCALL): here. - (ptw32_threadStart): Fix prototype. - * private.c (ptw32_threadStart): Likewise. - -1999-08-14 Ross Johnson - - * exit.c (pthread_exit): Don't call pthread_self() but - get thread handle directly from TSD for efficiency. - -1999-08-12 Ross Johnson - - * private.c (ptw32_threadStart): ei[] only declared if _MSC_VER. - - * exit.c (pthread_exit): Check for implicitly created threads - to avoid raising an unhandled exception. - -1999-07-12 Peter Slacik - - * condvar.c (pthread_cond_destroy): Add critical section. - (cond_timedwait): Add critical section; check for timeout - waiting on semaphore. - (pthread_cond_broadcast): Add critical section. - -1999-07-09 Lorin Hochstein , John Bossom - - The problem was that cleanup handlers were not executed when - pthread_exit() was called. - - * implement.h (pthread_t_): Add exceptionInformation element for - C++ per-thread exception information. - (general): Define and rename exceptions. - -1999-07-09 Ross Johnson - - * misc.c (CancelableWait): PTW32_EPS_CANCEL (SEH) and - ptw32_exception_cancel (C++) used to identify the exception. - - * cancel.c (pthread_testcancel): PTW32_EPS_CANCEL (SEH) and - ptw32_exception_cancel (C++) used to identify the exception. - - * exit.c (pthread_exit): throw/raise an exception to return to - ptw32_threadStart() to exit the thread. PTW32_EPS_EXIT (SEH) - and ptw32_exception_exit (C++) used to identify the exception. - - * private.c (ptw32_threadStart): Add pthread_exit exception trap; - clean up and exit the thread directly rather than via pthread_exit(). - -Sun May 30 00:25:02 1999 Ross Johnson - - * semaphore.h (mode_t): Conditionally typedef it. - -Fri May 28 13:33:05 1999 Mark E. Armstrong - - * condvar.c (pthread_cond_broadcast): Fix possible memory fault - -Thu May 27 13:08:46 1999 Peter Slacik - - * condvar.c (pthread_cond_broadcast): Fix logic bug - -Thu May 27 13:08:46 1999 Bossom, John - - * condvar.c (pthread_cond_broadcast): optimise sem_post loop - -Fri May 14 12:13:18 1999 Mike Russo - - * attr.c (pthread_attr_setdetachstate): Fix logic bug - -Sat May 8 09:42:30 1999 Ross Johnson - - * pthread.def (sem_open): Add. - (sem_close): Add. - (sem_unlink): Add. - (sem_getvalue): Add. - - * FAQ (Question 3): Add. - -Thu Apr 8 01:16:23 1999 Ross Johnson - - * semaphore.c (sem_open): New function; returns an error (ENOSYS). - (sem_close): ditto. - (sem_unlink): ditto. - (sem_getvalue): ditto. - - * semaphore.h (_POSIX_SEMAPHORES): define. - -Wed Apr 7 14:09:52 1999 Ross Johnson - - * errno.c (_REENTRANT || _MT): Invert condition. - - * pthread.h (_errno): Conditionally include prototype. - -Wed Apr 7 09:37:00 1999 Ross Johnson - - * *.c (comments): Remove individual attributions - these are - documented sufficiently elsewhere. - - * implement.h (pthread.h): Remove extraneous include. - -Sun Apr 4 11:05:57 1999 Ross Johnson - - * sched.c (sched.h): Include. - - * sched.h: New file for POSIX 1b scheduling. - - * pthread.h: Move opaque structures to implement.h; move sched_* - prototypes out and into sched.h. - - * implement.h: Add opaque structures from pthread.h. - - * sched.c (sched_yield): New function. - - * condvar.c (ptw32_sem_*): Rename to sem_*; except for - ptw32_sem_timedwait which is an private function. - -Sat Apr 3 23:28:00 1999 Ross Johnson - - * Makefile.in (OBJS): Add errno.o. - -Fri Apr 2 11:08:50 1999 Ross Johnson - - * implement.h (ptw32_sem_*): Remove prototypes now defined in - semaphore.h. - - * pthread.h (sempahore.h): Include. - - * semaphore.h: New file for POSIX 1b semaphores. - - * semaphore.c (ptw32_sem_timedwait): Moved to private.c. - - * pthread.h (ptw32_sem_t): Change to sem_t. - - * private.c (ptw32_sem_timedwait): Moved from semaphore.c; - set errno on error. - - * pthread.h (pthread_t_): Add per-thread errno element. - -Fri Apr 2 11:08:50 1999 John Bossom - - * semaphore.c (ptw32_sem_*): Change to sem_*; these functions - will be exported from the library; set errno on error. - - * errno.c (_errno): New file. New function. - -Fri Mar 26 14:11:45 1999 Tor Lillqvist - - * semaphore.c (ptw32_sem_timedwait): Check for negative - milliseconds. - -Wed Mar 24 11:32:07 1999 John Bossom - - * misc.c (CancelableWait): Initialise exceptionInformation[2]. - (pthread_self): Get a real Win32 thread handle for implicit threads. - - * cancel.c (pthread_testcancel): Initialise exceptionInformation[2]. - - * implement.h (SE_INFORMATION): Fix values. - - * private.c (ptw32_threadDestroy): Close the thread handle. - -Fri Mar 19 12:57:27 1999 Ross Johnson - - * cancel.c (comments): Update and cleanup. - -Fri Mar 19 09:12:59 1999 Ross Johnson - - * private.c (ptw32_threadStart): status returns PTHREAD_CANCELED. - - * pthread.h (PTHREAD_CANCELED): defined. - -Tue Mar 16 1999 Ross Johnson - - * all: Add GNU LGPL and Copyright and Warranty. - -Mon Mar 15 00:20:13 1999 Ross Johnson - - * condvar.c (pthread_cond_init): fix possible uninitialised use - of cv. - -Sun Mar 14 21:01:59 1999 Ross Johnson - - * condvar.c (pthread_cond_destroy): don't do full cleanup if - static initialised cv has never been used. - (cond_timedwait): check result of auto-initialisation. - -Thu Mar 11 09:01:48 1999 Ross Johnson - - * pthread.h (pthread_mutex_t): revert to (pthread_mutex_t *); - define a value to serve as PTHREAD_MUTEX_INITIALIZER. - (pthread_mutex_t_): remove staticinit and valid elements. - (pthread_cond_t): revert to (pthread_cond_t_ *); - define a value to serve as PTHREAD_COND_INITIALIZER. - (pthread_cond_t_): remove staticinit and valid elements. - - * mutex.c (pthread_mutex_t args): adjust indirection of references. - (all functions): check for PTHREAD_MUTEX_INITIALIZER value; - check for NULL (invalid). - - * condvar.c (pthread_cond_t args): adjust indirection of references. - (all functions): check for PTHREAD_COND_INITIALIZER value; - check for NULL (invalid). - -Wed Mar 10 17:18:12 1999 Ross Johnson - - * misc.c (CancelableWait): Undo changes from Mar 8 and 7. - -Mon Mar 8 11:18:59 1999 Ross Johnson - - * misc.c (CancelableWait): Ensure cancelEvent handle is the lowest - indexed element in the handles array. Enhance test for abandoned - objects. - - * pthread.h (PTHREAD_MUTEX_INITIALIZER): Trailing elements not - initialised are set to zero by the compiler. This avoids the - problem of initialising the opaque critical section element in it. - (PTHREAD_COND_INITIALIZER): Ditto. - - * semaphore.c (ptw32_sem_timedwait): Check sem == NULL earlier. - -Sun Mar 7 12:31:14 1999 Ross Johnson - - * condvar.c (pthread_cond_init): set semaphore initial value - to 0, not 1. cond_timedwait was returning signaled immediately. - - * misc.c (CancelableWait): Place the cancel event handle first - in the handle table for WaitForMultipleObjects. This ensures that - the cancel event is recognised and acted apon if both objects - happen to be signaled together. - - * private.c (ptw32_cond_test_init_lock): Initialise and destroy. - - * implement.h (ptw32_cond_test_init_lock): Add extern. - - * global.c (ptw32_cond_test_init_lock): Add declaration. - - * condvar.c (pthread_cond_destroy): check for valid initialised CV; - flag destroyed CVs as invalid. - (pthread_cond_init): pthread_cond_t is no longer just a pointer. - This is because PTHREAD_COND_INITIALIZER needs state info to reside - in pthread_cond_t so that it can initialise on first use. Will work on - making pthread_cond_t (and other objects like it) opaque again, if - possible, later. - (cond_timedwait): add check for statically initialisation of - CV; initialise on first use. - (pthread_cond_signal): check for valid CV. - (pthread_cond_broadcast): check for valid CV. - (_cond_check_need_init): Add. - - * pthread.h (PTHREAD_COND_INITIALIZER): Fix. - (pthread_cond_t): no longer a pointer to pthread_cond_t_. - (pthread_cond_t_): add 'staticinit' and 'valid' elements. - -Sat Mar 6 1999 Ross Johnson - - * implement.h: Undate comments. - -Sun Feb 21 1999 Ross Johnson - - * pthread.h (PTHREAD_MUTEX_INITIALIZER): missing braces around - cs element initialiser. - -1999-02-21 Ben Elliston - - * pthread.h (pthread_exit): The return type of this function is - void, not int. - - * exit.c (pthread_exit): Do not return 0. - -Sat Feb 20 16:03:30 1999 Ross Johnson - - * dll.c (DLLMain): Expand TryEnterCriticalSection support test. - - * mutex.c (pthread_mutex_trylock): The check for - ptw32_try_enter_critical_section == NULL should have been - removed long ago. - -Fri Feb 19 16:03:30 1999 Ross Johnson - - * sync.c (pthread_join): Fix pthread_equal() test. - - * mutex.c (pthread_mutex_trylock): Check mutex != NULL before - using it. - -Thu Feb 18 16:17:30 1999 Ross Johnson - - * misc.c (pthread_equal): Fix inverted result. - - * Makefile.in: Use libpthread32.a as the name of the DLL export - library instead of pthread.lib. - - * condvar.c (pthread_cond_init): cv could have been used unitialised; - initialise. - - * create.c (pthread_create): parms could have been used unitialised; - initialise. - - * pthread.h (struct pthread_once_t_): Remove redefinition. - -Sat Feb 13 03:03:30 1999 Ross Johnson - - * pthread.h (struct pthread_once_t_): Replaced. - - * misc.c (pthread_once): Replace with John Bossom's version; - has lighter weight serialisation; fixes problem of not holding - competing threads until after the init_routine completes. - -Thu Feb 11 13:34:14 1999 Ross Johnson - - * misc.c (CancelableWait): Change C++ exception throw. - - * sync.c (pthread_join): Change FIXME comment - issue resolved. - -Wed Feb 10 12:49:11 1999 Ross Johnson - - * configure: Various temporary changes. - - Kevin Ruland - - * README: Update. - - * pthread.def (pthread_attr_getstackaddr): uncomment - (pthread_attr_setstackaddr): uncomment - -Fri Feb 5 13:42:30 1999 Ross Johnson - - * semaphore.c: Comment format changes. - -Thu Feb 4 10:07:28 1999 Ross Johnson - - * global.c: Remove ptw32_exception instantiation. - - * cancel.c (pthread_testcancel): Change C++ exception throw. - - * implement.h: Remove extern declaration. - -Wed Feb 3 13:04:44 1999 Ross Johnson - - * cleanup.c: Rename ptw32_*_cleanup() to pthread_*_cleanup(). - - * pthread.def: Ditto. - - * pthread.h: Ditto. - - * pthread.def (pthread_cleanup_push): Remove from export list; - the function is defined as a macro under all compilers. - (pthread_cleanup_pop): Ditto. - - * pthread.h: Remove #if defined(). - -Wed Feb 3 10:13:48 1999 Ross Johnson - - * sync.c (pthread_join): Check for NULL value_ptr arg; - check for detached threads. - -Tue Feb 2 18:07:43 1999 Ross Johnson - - * implement.h: Add #include . - Change sem_t to ptw32_sem_t. - -Tue Feb 2 18:07:43 1999 Kevin Ruland - - * signal.c (pthread_sigmask): Add and modify casts. - Reverse LHS/RHS bitwise assignments. - - * pthread.h: Remove #include . - (PTW32_ATTR_VALID): Add cast. - (struct pthread_t_): Add sigmask element. - - * dll.c: Add "extern C" for DLLMain. - (DllMain): Add cast. - - * create.c (pthread_create): Set sigmask in thread. - - * condvar.c: Remove #include. Change sem_* to ptw32_sem_*. - - * attr.c: Changed #include. - - * Makefile.in: Additional targets and changes to build the library - as a DLL. - -Fri Jan 29 11:56:28 1999 Ross Johnson - - * Makefile.in (OBJS): Add semaphore.o to list. - - * semaphore.c (ptw32_sem_timedwait): Move from private.c. - Rename sem_* to ptw32_sem_*. - - * pthread.h (pthread_cond_t): Change type of sem_t. - _POSIX_SEMAPHORES no longer defined. - - * semaphore.h: Contents moved to implement.h. - Removed from source tree. - - * implement.h: Add semaphore function prototypes and rename all - functions to prepend 'ptw32_'. They are - now private to the pthreads-win32 implementation. - - * private.c: Change #warning. - Move ptw32_sem_timedwait() to semaphore.c. - - * cleanup.c: Change #warning. - - * misc.c: Remove #include - - * pthread.def: Cleanup CVS merge conflicts. - - * global.c: Ditto. - - * ChangeLog: Ditto. - - * cleanup.c: Ditto. - -Sun Jan 24 01:34:52 1999 Ross Johnson - - * semaphore.c (sem_wait): Remove second arg to - pthreadCancelableWait() call. - -Sat Jan 23 17:36:40 1999 Ross Johnson - - * pthread.def: Add new functions to export list. - - * pthread.h (PTHREAD_MUTEX_AUTO_CS_NP): New. - (PTHREAD_MUTEX_FORCE_CS_NP): New. - - * README: Updated. - -Fri Jan 22 14:31:59 1999 Ross Johnson - - * Makefile.in (CFLAGS): Remove -fhandle-exceptions. Not needed - with egcs. Add -g for debugging. - - * create.c (pthread_create): Replace __stdcall with PT_STDCALL - macro. This is a hack and must be fixed. - - * misc.c (CancelableWait): Remove redundant statement. - - * mutex.c (pthread_mutexattr_init): Cast calloc return value. - - * misc.c (CancelableWait): Add cast. - (pthread_self): Add cast. - - * exit.c (pthread_exit): Add cast. - - * condvar.c (pthread_condattr_init): Cast calloc return value. - - * cleanup.c: Reorganise conditional compilation. - - * attr.c (pthread_attr_init): Remove unused 'result'. - Cast malloc return value. - - * private.c (ptw32_callUserDestroyRoutines): Redo conditional - compilation. - - * misc.c (CancelableWait): C++ version uses 'throw'. - - * cancel.c (pthread_testcancel): Ditto. - - * implement.h (class ptw32_exception): Define for C++. - - * pthread.h: Fix C, C++, and Win32 SEH condition compilation - mayhem around pthread_cleanup_* defines. C++ version now uses John - Bossom's cleanup handlers. - (pthread_attr_t): Make 'valid' unsigned. - Define '_timeb' as 'timeb' for Ming32. - Define PT_STDCALL as nothing for Mingw32. May be temporary. - - * cancel.c (pthread_testcancel): Cast return value. - -Wed Jan 20 09:31:28 1999 Ross Johnson - - * pthread.h (pthread_mutexattr_t): Changed to a pointer. - - * mutex.c (pthread_mutex_init): Conditionally create Win32 mutex - - from John Bossom's implementation. - (pthread_mutex_destroy): Conditionally close Win32 mutex - - from John Bossom's implementation. - (pthread_mutexattr_init): Replaced by John Bossom's version. - (pthread_mutexattr_destroy): Ditto. - (pthread_mutexattr_getpshared): New function from John Bossom's - implementation. - (pthread_mutexattr_setpshared): New function from John Bossom's - implementation. - -Tue Jan 19 18:27:42 1999 Ross Johnson - - * pthread.h (pthreadCancelableTimedWait): New prototype. - (pthreadCancelableWait): Remove second argument. - - * misc.c (CancelableWait): New static function is - pthreadCancelableWait() renamed. - (pthreadCancelableWait): Now just calls CancelableWait() with - INFINITE timeout. - (pthreadCancelableTimedWait): Just calls CancelableWait() - with passed in timeout. - -Tue Jan 19 18:27:42 1999 Scott Lightner - - * private.c (ptw32_sem_timedwait): 'abstime' arg really is - absolute time. Calculate relative time to wait from current - time before passing timeout to new routine - pthreadCancelableTimedWait(). - -Tue Jan 19 10:27:39 1999 Ross Johnson - - * pthread.h (pthread_mutexattr_setforcecs_np): New prototype. - - * mutex.c (pthread_mutexattr_init): Init 'pshared' and 'forcecs' - attributes to 0. - (pthread_mutexattr_setforcecs_np): New function (not portable). - - * pthread.h (pthread_mutex_t): - Add 'mutex' element. Set to NULL in PTHREAD_MUTEX_INITIALIZER. - The pthread_mutex_*() routines will try to optimise performance - by choosing either mutexes or critical sections as the basis - for pthread mutexes for each indevidual mutex. - (pthread_mutexattr_t_): Add 'forcecs' element. - Some applications may choose to force use of critical sections - if they know that:- - the mutex is PROCESS_PRIVATE and, - either the OS supports TryEnterCriticalSection() or - pthread_mutex_trylock() will never be called on the mutex. - This attribute will be setable via a non-portable routine. - - Note: We don't yet support PROCESS_SHARED mutexes, so the - implementation as it stands will default to Win32 mutexes only if - the OS doesn't support TryEnterCriticalSection. On Win9x, and early - versions of NT 'forcecs' will need to be set in order to get - critical section based mutexes. - -Sun Jan 17 12:01:26 1999 Ross Johnson - - * pthread.h (PTHREAD_MUTEX_INITIALIZER): Init new 'staticinit' - value to '1' and existing 'valid' value to '1'. - - * global.c (ptw32_mutex_test_init_lock): Add. - - * implement.h (ptw32_mutex_test_init_lock.): Add extern. - - * private.c (ptw32_processInitialize): Init critical section for - global lock used by _mutex_check_need_init(). - (ptw32_processTerminate): Ditto (:s/Init/Destroy/). - - * dll.c (dllMain): Move call to FreeLibrary() so that it is only - called once when the process detaches. - - * mutex.c (_mutex_check_need_init): New static function to test - and init PTHREAD_MUTEX_INITIALIZER mutexes. Provides serialised - access to the internal state of the uninitialised static mutex. - Called from pthread_mutex_trylock() and pthread_mutex_lock() which - do a quick unguarded test to check if _mutex_check_need_init() - needs to be called. This is safe as the test is conservative - and is repeated inside the guarded section of - _mutex_check_need_init(). Thus in all calls except the first - calls to lock static mutexes, the additional overhead to lock any - mutex is a single memory fetch and test for zero. - - * pthread.h (pthread_mutex_t_): Add 'staticinit' member. Mutexes - initialised by PTHREAD_MUTEX_INITIALIZER aren't really initialised - until the first attempt to lock it. Using the 'valid' - flag (which flags the mutex as destroyed or not) to record this - information would be messy. It is possible for a statically - initialised mutex such as this to be destroyed before ever being - used. - - * mutex.c (pthread_mutex_trylock): Call _mutex_check_need_init() - to test/init PTHREAD_MUTEX_INITIALIZER mutexes. - (pthread_mutex_lock): Ditto. - (pthread_mutex_unlock): Add check to ensure we don't try to unlock - an unitialised static mutex. - (pthread_mutex_destroy): Add check to ensure we don't try to delete - a critical section that we never created. Allows us to destroy - a static mutex that has never been locked (and hence initialised). - (pthread_mutex_init): Set 'staticinit' flag to 0 for the new mutex. - -Sun Jan 17 12:01:26 1999 Ross Johnson - - * private.c (ptw32_sem_timedwait): Move from semaphore.c. - - * semaphore.c : Remove redundant #includes. - (ptw32_sem_timedwait): Move to private.c. - (sem_wait): Add missing abstime arg to pthreadCancelableWait() call. - -Fri Jan 15 23:38:05 1999 Ross Johnson - - * condvar.c (cond_timedwait): Remove comment. - -Fri Jan 15 15:41:28 1999 Ross Johnson - - * pthread.h: Add new 'abstime' arg to pthreadCancelableWait() - prototype. - - * condvar.c (cond_timedwait): New generalised function called by - both pthread_cond_wait() and pthread_cond_timedwait(). This is - essentially pthread_cond_wait() renamed and modified to add the - 'abstime' arg and call the new ptw32_sem_timedwait() instead of - sem_wait(). - (pthread_cond_wait): Now just calls the internal static - function cond_timedwait() with an INFINITE wait. - (pthread_cond_timedwait): Now implemented. Calls the internal - static function cond_timedwait(). - - * implement.h (ptw32_sem_timedwait): New internal function - prototype. - - * misc.c (pthreadCancelableWait): Added new 'abstime' argument - to allow shorter than INFINITE wait. - - * semaphore.c (ptw32_sem_timedwait): New function for internal - use. This is essentially sem_wait() modified to add the - 'abstime' arg and call the modified (see above) - pthreadCancelableWait(). - -Thu Jan 14 14:27:13 1999 Ross Johnson - - * cleanup.c: Correct _cplusplus to __cplusplus wherever used. - - * Makefile.in: Add CC=g++ and add -fhandle-exceptions to CFLAGS. - The derived Makefile will compile all units of the package as C++ - so that those which include try/catch exception handling should work - properly. The package should compile ok if CC=gcc, however, exception - handling will not be included and thus thread cancellation, for - example, will not work. - - * cleanup.c (ptw32_pop_cleanup): Add #warning to compile this - file as C++ if using a cygwin32 environment. Perhaps the whole package - should be compiled using g++ under cygwin. - - * private.c (ptw32_threadStart): Change #error directive - into #warning and bracket for __CYGWIN__ and derivative compilers. - -Wed Jan 13 09:34:52 1999 Ross Johnson - - * build.bat: Delete old binaries before compiling/linking. - -Tue Jan 12 09:58:38 1999 Tor Lillqvist - - * dll.c: The Microsoft compiler pragmas probably are more - appropriately protected by _MSC_VER than by _WIN32. - - * pthread.h: Define ETIMEDOUT. This should be returned by - pthread_cond_timedwait which is not implemented yet as of - snapshot-1999-01-04-1305. It was implemented in the older version. - The Microsoft compiler pragmas probably are more appropriately - protected by _MSC_VER than by _WIN32. - - * pthread.def: pthread_mutex_destroy was missing from the def file - - * condvar.c (pthread_cond_broadcast): Ensure we only wait on threads - if there were any waiting on the condition. - I think pthread_cond_broadcast should do the WaitForSingleObject - only if cv->waiters > 0? Otherwise it seems to hang, at least in the - testg thread program from glib. - -Tue Jan 12 09:58:38 1999 Ross Johnson - - * condvar.c (pthread_cond_timedwait): Fix function description - comments. - - * semaphore.c (sem_post): Correct typo in comment. - -Mon Jan 11 20:33:19 1999 Ross Johnson - - * pthread.h: Re-arrange conditional compile of pthread_cleanup-* - macros. - - * cleanup.c (ptw32_push_cleanup): Provide conditional - compile of cleanup->prev. - -1999-01-11 Tor Lillqvist - - * condvar.c (pthread_cond_init): Invert logic when testing the - return value from calloc(). - -Sat Jan 9 14:32:08 1999 Ross Johnson - - * implement.h: Compile-time switch for CYGWIN derived environments - to use CreateThread instead of _beginthreadex. Ditto for ExitThread. - Patch provided by Anders Norlander . - -Tue Jan 5 16:33:04 1999 Ross Johnson - - * cleanup.c (ptw32_pop_cleanup): Add C++ version of __try/__except - block. Move trailing "}" out of #ifdef _WIN32 block left there by - (rpj's) mistake. - - * private.c: Remove #include which is included by pthread.h. - -1998-12-11 Ben Elliston - - * README: Update info about subscribing to the mailing list. - -Mon Jan 4 11:23:40 1999 Ross Johnson - - * all: No code changes, just cleanup. - - remove #if 0 /* Pre Bossom */ enclosed code. - - Remove some redundant #includes. - * pthread.h: Update implemented/unimplemented routines list. - * Tag the bossom merge branch getting ready to merge back to main - trunk. - -Tue Dec 29 13:11:16 1998 Ross Johnson - - * implement.h: Move the following struct definitions to pthread.h: - pthread_t_, pthread_attr_t_, pthread_mutex_t_, pthread_mutex_t_, - pthread_mutexattr_t_, pthread_key_t_, pthread_cond_t_, - pthread_condattr_t_, pthread_once_t_. - - * pthread.h: Add "_" prefix to pthread_push_cleanup and - pthread_pop_cleanup internal routines, and associated struct and - typedefs. - - * buildlib.bat: Add compile command for semaphore.c - - * pthread.def: Comment out pthread_atfork routine name. - Now unimplemented. - - * tsd.c (pthread_setspecific): Rename tkAssocCreate to - ptw32_tkAssocCreate. - (pthread_key_delete): Rename tkAssocDestroy to - ptw32_tkAssocDestroy. - - * sync.c (pthread_join): Rename threadDestroy to ptw32_threadDestroy - - * sched.c (is_attr): attr is now **attr (was *attr), so add extra - NULL pointer test. - (pthread_attr_setschedparam): Increase redirection for attr which is - now a **. - (pthread_attr_getschedparam): Ditto. - (pthread_setschedparam): Change thread validation and rename "thread" - Win32 thread Handle element name to match John Bossom's version. - (pthread_getschedparam): Ditto. - - * private.c (ptw32_threadDestroy): Rename call to - callUserDestroyRoutines() as ptw32_callUserDestroyRoutines() - - * misc.c: Add #include "implement.h". - - * dll.c: Remove defined(KLUDGE) wrapped code. - - * fork.c: Remove redefinition of ENOMEM. - Remove pthread_atfork() and fork() with #if 0/#endif. - - * create.c (pthread_create): Rename threadStart and threadDestroy calls - to ptw32_threadStart and ptw32_threadDestroy. - - * implement.h: Rename "detachedstate" to "detachstate". - - * attr.c: Rename "detachedstate" to "detachstate". - -Mon Dec 28 09:54:39 1998 John Bossom - - * semaphore.c: Initial version. - * semaphore.h: Initial version. - -Mon Dec 28 09:54:39 1998 Ross Johnson - - * pthread.h (pthread_attr_t_): Change to *pthread_attr_t. - -Mon Dec 28 09:54:39 1998 John Bossom, Ben Elliston - - * attr.c (pthread_attr_setstacksize): Merge with John's version. - (pthread_attr_getstacksize): Merge with John's version. - (pthread_attr_setstackaddr): Merge with John's version. - (pthread_attr_getstackaddr): Merge with John's version. - (pthread_attr_init): Merge with John's version. - (pthread_attr_destroy): Merge with John's version. - (pthread_attr_getdetachstate): Merge with John's version. - (pthread_attr_setdetachstate): Merge with John's version. - (is_attr): attr is now **attr (was *attr), so add extra NULL pointer - test. - -Mon Dec 28 09:54:39 1998 Ross Johnson - - * implement.h (pthread_attr_t_): Add and rename elements in JEB's - version to correspond to original, so that it can be used with - original attr routines. - - * pthread.h: Add #endif at end which was truncated in merging. - -Sun Dec 20 14:51:58 1998 Ross Johnson - - * misc.c (pthreadCancelableWait): New function by John Bossom. Non-standard - but provides a hook that can be used to implement cancellation points in - applications that use this library. - - * pthread.h (pthread_cleanup_pop): C++ (non-WIN32) version uses - try/catch to emulate John Bossom's WIN32 __try/__finally behaviour. - In the WIN32 version __finally block, add a test for AbnormalTermination otherwise - cleanup is only run if the cleanup_pop execute arg is non-zero. Cancellation - should cause the cleanup to run irrespective of the execute arg. - - * condvar.c (pthread_condattr_init): Replaced by John Bossom's version. - (pthread_condattr_destroy): Replaced by John Bossom's version. - (pthread_condattr_getpshared): Replaced by John Bossom's version. - (pthread_condattr_setpshared): Replaced by John Bossom's version. - (pthread_cond_init): Replaced by John Bossom's version. - Fix comment (refered to mutex rather than condition variable). - (pthread_cond_destroy): Replaced by John Bossom's version. - (pthread_cond_wait): Replaced by John Bossom's version. - (pthread_cond_timedwait): Replaced by John Bossom's version. - (pthread_cond_signal): Replaced by John Bossom's version. - (pthread_cond_broadcast): Replaced by John Bossom's version. - -Thu Dec 17 19:10:46 1998 Ross Johnson - - * tsd.c (pthread_key_create): Replaced by John Bossom's version. - (pthread_key_delete): Replaced by John Bossom's version. - (pthread_setspecific): Replaced by John Bossom's version. - (pthread_getspecific): Replaced by John Bossom's version. - -Mon Dec 7 09:44:40 1998 John Bossom - - * cancel.c (pthread_setcancelstate): Replaced. - (pthread_setcanceltype): Replaced. - (pthread_testcancel): Replaced. - (pthread_cancel): Replaced. - - * exit.c (pthread_exit): Replaced. - - * misc.c (pthread_self): Replaced. - (pthread_equal): Replaced. - - * sync.c (pthread_detach): Replaced. - (pthread_join): Replaced. - - * create.c (pthread_create): Replaced. - - * private.c (ptw32_processInitialize): New. - (ptw32_processTerminate): New. - (ptw32_threadStart): New. - (ptw32_threadDestroy): New. - (ptw32_cleanupStack): New. - (ptw32_tkAssocCreate): New. - (ptw32_tkAssocDestroy): New. - (ptw32_callUserDestroyRoutines): New. - - * implement.h: Added non-API structures and declarations. - - * dll.c (PthreadsEntryPoint): Cast return value of GetProcAddress - to resolve compile warning from MSVC. - - * dll.c (DLLmain): Replaced. - * dll.c (PthreadsEntryPoint): - Re-applied Anders Norlander's patch:- - Initialize ptw32_try_enter_critical_section at startup - and release kernel32 handle when DLL is being unloaded. - -Sun Dec 6 21:54:35 1998 Ross Johnson - - * buildlib.bat: Fix args to CL when building the .DLL - - * cleanup.c (ptw32_destructor_run_all): Fix TSD key management. - This is a tidy-up before TSD and Thread management is completely - replaced by John Bossom's code. - - * tsd.c (pthread_key_create): Fix TSD key management. - - * global.c (ptw32_key_virgin_next): Initialise. - - * build.bat: New DOS script to compile and link a pthreads app - using Microsoft's CL compiler linker. - * buildlib.bat: New DOS script to compile all the object files - and create pthread.lib and pthread.dll using Microsoft's CL - compiler linker. - -1998-12-05 Anders Norlander - - * implement.h (ptw32_try_enter_critical_section): New extern - * dll.c (ptw32_try_enter_critical_section): New pointer to - TryEnterCriticalSection if it exists; otherwise NULL. - * dll.c (PthreadsEntryPoint): - Initialize ptw32_try_enter_critical_section at startup - and release kernel32 handle when DLL is being unloaded. - * mutex.c (pthread_mutex_trylock): Replaced check for NT with - a check if ptw32_try_enter_critical_section is valid - pointer to a function. Call ptw32_try_enter_critical_section - instead of TryEnterCriticalSection to avoid errors on Win95. - -Thu Dec 3 13:32:00 1998 Ross Johnson - - * README: Correct cygwin32 compatibility statement. - -Sun Nov 15 21:24:06 1998 Ross Johnson - - * cleanup.c (ptw32_destructor_run_all): Declare missing void * arg. - Fixup CVS merge conflicts. - -1998-10-30 Ben Elliston - - * condvar.c (cond_wait): Fix semantic error. Test for equality - instead of making an assignment. - -Fri Oct 30 15:15:50 1998 Ross Johnson - - * cleanup.c (ptw32_handler_push): Fixed bug appending new - handler to list reported by Peter Slacik - . - (new_thread): Rename poorly named local variable to - "new_handler". - -Sat Oct 24 18:34:59 1998 Ross Johnson - - * global.c: Add TSD key management array and index declarations. - - * implement.h: Ditto for externs. - -Fri Oct 23 00:08:09 1998 Ross Johnson - - * implement.h (PTW32_TSD_KEY_REUSE): Add enum. - - * private.c (ptw32_delete_thread): Add call to - ptw32_destructor_run_all() to clean up the threads keys. - - * cleanup.c (ptw32_destructor_run_all): Check for no more dirty - keys to run destructors on. Assume that the destructor call always - succeeds and set the key value to NULL. - -Thu Oct 22 21:44:44 1998 Ross Johnson - - * tsd.c (pthread_setspecific): Add key management code. - (pthread_key_create): Ditto. - (pthread_key_delete): Ditto. - - * implement.h (struct ptw32_tsd_key): Add status member. - - * tsd.c: Add description of pthread_key_delete() from the - standard as a comment. - -Fri Oct 16 17:38:47 1998 Ross Johnson - - * cleanup.c (ptw32_destructor_run_all): Fix and improve - stepping through the key table. - -Thu Oct 15 14:05:01 1998 Ross Johnson - - * private.c (ptw32_new_thread): Remove init of destructorstack. - No longer an element of pthread_t. - - * tsd.c (pthread_setspecific): Fix type declaration and cast. - (pthread_getspecific): Ditto. - (pthread_getspecific): Change error return value to NULL if key - is not in use. - -Thu Oct 15 11:53:21 1998 Ross Johnson - - * global.c (ptw32_tsd_key_table): Fix declaration. - - * implement.h(ptw32_TSD_keys_TlsIndex): Add missing extern. - (ptw32_tsd_mutex): Ditto. - - * create.c (ptw32_start_call): Fix "keys" array declaration. - Add comment. - - * tsd.c (pthread_setspecific): Fix type declaration and cast. - (pthread_getspecific): Ditto. - - * cleanup.c (ptw32_destructor_run_all): Declare missing loop - counter. - -Wed Oct 14 21:09:24 1998 Ross Johnson - - * private.c (ptw32_new_thread): Increment ptw32_threads_count. - (ptw32_delete_thread): Decrement ptw32_threads_count. - Remove some comments. - - * exit.c (ptw32_exit): : Fix two pthread_mutex_lock() calls that - should have been pthread_mutex_unlock() calls. - (ptw32_vacuum): Remove call to ptw32_destructor_pop_all(). - - * create.c (pthread_create): Fix two pthread_mutex_lock() calls that - should have been pthread_mutex_unlock() calls. - - * global.c (ptw32_tsd_mutex): Add mutex for TSD operations. - - * tsd.c (pthread_key_create): Add critical section. - (pthread_setspecific): Ditto. - (pthread_getspecific): Ditto. - (pthread_key_delete): Ditto. - - * sync.c (pthread_join): Fix two pthread_mutex_lock() calls that - should have been pthread_mutex_unlock() calls. - -Mon Oct 12 00:00:44 1998 Ross Johnson - - * implement.h (ptw32_tsd_key_table): New. - - * create.c (ptw32_start_call): Initialise per-thread TSD keys - to NULL. - - * misc.c (pthread_once): Correct typo in comment. - - * implement.h (ptw32_destructor_push): Remove. - (ptw32_destructor_pop): Remove. - (ptw32_destructor_run_all): Rename from ptw32_destructor_pop_all. - (PTW32_TSD_KEY_DELETED): Add enum. - (PTW32_TSD_KEY_INUSE): Add enum. - - * cleanup.c (ptw32_destructor_push): Remove. - (ptw32_destructor_pop): Remove. - (ptw32_destructor_run_all): Totally revamped TSD. - - * dll.c (ptw32_TSD_keys_TlsIndex): Initialise. - - * tsd.c (pthread_setspecific): Totally revamped TSD. - (pthread_getspecific): Ditto. - (pthread_create): Ditto. - (pthread_delete): Ditto. - -Sun Oct 11 22:44:55 1998 Ross Johnson - - * global.c (ptw32_tsd_key_table): Add new global. - - * implement.h (ptw32_tsd_key_t and struct ptw32_tsd_key): - Add. - (struct _pthread): Remove destructorstack. - - * cleanup.c (ptw32_destructor_run_all): Rename from - ptw32_destructor_pop_all. The key destructor stack was made - global rather than per-thread. No longer removes destructor nodes - from the stack. Comments updated. - -1998-10-06 Ben Elliston - - * condvar.c (cond_wait): Use POSIX, not Win32 mutex calls. - (pthread_cond_broadcast): Likewise. - (pthread_cond_signal): Likewise. - -1998-10-05 Ben Elliston - - * pthread.def: Update. Some functions aren't available yet, others - are macros in . - - * tests/join.c: Remove; useless. - -Mon Oct 5 14:25:08 1998 Ross Johnson - - * pthread.def: New file for building the DLL. - -1998-10-05 Ben Elliston - - * misc.c (pthread_equal): Correct inverted logic bug. - (pthread_once): Use the POSIX mutex primitives, not Win32. Remove - irrelevant FIXME comment. - - * global.c (PTHREAD_MUTEX_INITIALIZER): Move to pthread.h. - - * pthread.h (PTHREAD_MUTEX_INITIALIZER): Define. - (pthread_mutex_t): Reimplement as a struct containing a valid - flag. If the flag is ever down upon entry to a mutex operation, - we call pthread_mutex_create() to initialise the object. This - fixes the problem of how to handle statically initialised objects - that can't call InitializeCriticalSection() due to their context. - (PTHREAD_ONCE_INIT): Define. - - * mutex.c (pthread_mutex_init): Set valid flag. - (pthread_mutex_destroy): Clear valid flag. - (pthread_mutex_lock): Check and handle the valid flag. - (pthread_mutex_unlock): Likewise. - (pthread_mutex_trylock): Likewise. - - * tests/mutex3.c: New file; test for the static initialisation - macro. Passes. - - * tests/create1.c: New file; test pthread_create(). Passes. - - * tests/equal.c: Poor test; remove. - - * tests/equal1.c New file; test pthread_equal(). Passes. - - * tests/once1.c: New file; test for pthread_once(). Passes. - - * tests/self.c: Remove; rename to self1.c. - - * tests/self1.c: This is the old self.c. - - * tests/self2.c: New file. Test pthread_self() with a single - thread. Passes. - - * tests/self3.c: New file. Test pthread_self() with a couple of - threads to ensure their thread IDs differ. Passes. - -1998-10-04 Ben Elliston - - * tests/mutex2.c: Test pthread_mutex_trylock(). Passes. - - * tests/mutex1.c: New basic test for mutex functions (it passes). - (main): Eliminate warning. - - * configure.in: Test for __stdcall, not _stdcall. Typo. - - * configure: Regenerate. - - * attr.c (pthread_attr_setstackaddr): Remove FIXME comment. Win32 - does know about ENOSYS after all. - (pthread_attr_setstackaddr): Likewise. - -1998-10-03 Ben Elliston - - * configure.in: Test for the `_stdcall' keyword. Define `STDCALL' - to `_stdcall' if we have it, null otherwise. - - * configure: Regenerate. - - * acconfig.h (STDCALL): New define. - - * config.h.in: Regenerate. - - * create.c (ptw32_start_call): Add STDCALL prefix. - - * mutex.c (pthread_mutex_init): Correct function signature. - - * attr.c (pthread_attr_init): Only zero out the `sigmask' member - if we have the sigset_t type. - - * pthread.h: No need to include . It doesn't even exist - on Win32! Again, an artifact of cross-compilation. - (pthread_sigmask): Only provide if we have the sigset_t type. - - * process.h: Remove. This was a stand-in before we started doing - native compilation under Win32. - - * pthread.h (pthread_mutex_init): Make `attr' argument const. - -1998-10-02 Ben Elliston - - * COPYING: Remove. - - * COPYING.LIB: Add. This library is under the LGPL. - -1998-09-13 Ben Elliston - - * configure.in: Test for required system features. - - * configure: Generate. - - * acconfig.h: New file. - - * config.h.in: Generate. - - * Makefile.in: Renamed from Makefile. - - * COPYING: Import from a recent GNU package. - - * config.guess: Likewise. - - * config.sub: Likewise. - - * install-sh: Likewise. - - * config.h: Remove. - - * Makefile: Likewise. - -1998-09-12 Ben Elliston - - * windows.h: No longer needed; remove. - - * windows.c: Likewise. - -Sat Sep 12 20:09:24 1998 Ross Johnson - - * windows.h: Remove error number definitions. These are in - - * tsd.c: Add comment explaining rationale for not building - POSIX TSD on top of Win32 TLS. - -1998-09-12 Ben Elliston - - * {most}.c: Include to get POSIX error values. - - * signal.c (pthread_sigmask): Only provide if HAVE_SIGSET_T is - defined. - - * config.h: #undef features, don't #define them. This will be - generated by autoconf very soon. - -1998-08-11 Ben Elliston - - * Makefile (LIB): Define. - (clean): Define target. - (all): Build a library not just the object files. - - * pthread.h: Provide a definition for struct timespec if we don't - already have one. - - * windows.c (TlsGetValue): Bug fix. - -Thu Aug 6 15:19:22 1998 Ross Johnson - - * misc.c (pthread_once): Fix arg 1 of EnterCriticalSection() - and LeaveCriticalSection() calls to pass address-of lock. - - * fork.c (pthread_atfork): Typecast (void (*)(void *)) funcptr - in each ptw32_handler_push() call. - - * exit.c (ptw32_exit): Fix attr arg in - pthread_attr_getdetachstate() call. - - * private.c (ptw32_new_thread): Typecast (HANDLE) NULL. - (ptw32_delete_thread): Ditto. - - * implement.h: (PTW32_MAX_THREADS): Add define. This keeps - changing in an attempt to make thread administration data types - opaque and cleanup DLL startup. - - * dll.c (PthreadsEntryPoint): - (ptw32_virgins): Remove malloc() and free() calls. - (ptw32_reuse): Ditto. - (ptw32_win32handle_map): Ditto. - (ptw32_threads_mutex_table): Ditto. - - * global.c (_POSIX_THREAD_THREADS_MAX): Initialise with - PTW32_MAX_THREADS. - (ptw32_virgins): Ditto. - (ptw32_reuse): Ditto. - (ptw32_win32handle_map): Ditto. - (ptw32_threads_mutex_table): Ditto. - - * create.c (pthread_create): Typecast (HANDLE) NULL. - Typecast (unsigned (*)(void *)) start_routine. - - * condvar.c (pthread_cond_init): Add address-of operator & to - arg 1 of pthread_mutex_init() call. - (pthread_cond_destroy): Add address-of operator & to - arg 1 of pthread_mutex_destroy() call. - - * cleanup.c (ptw32_destructor_pop_all): Add (int) cast to - pthread_getspecific() arg. - (ptw32_destructor_pop): Add (void *) cast to "if" conditional. - (ptw32_destructor_push): Add (void *) cast to - ptw32_handler_push() "key" arg. - (malloc.h): Add include. - - * implement.h (ptw32_destructor_pop): Add prototype. - - * tsd.c (implement.h): Add include. - - * sync.c (pthread_join): Remove target_thread_mutex and it's - initialisation. Rename getdetachedstate to getdetachstate. - Remove unused variable "exitcode". - (pthread_detach): Remove target_thread_mutex and it's - initialisation. Rename getdetachedstate to getdetachstate. - Rename setdetachedstate to setdetachstate. - - * signal.c (pthread_sigmask): Rename SIG_SET to SIG_SETMASK. - Cast "set" to (long *) in assignment to passify compiler warning. - Add address-of operator & to thread->attr.sigmask in memcpy() call - and assignment. - (pthread_sigmask): Add address-of operator & to thread->attr.sigmask - in memcpy() call and assignment. - - * windows.h (THREAD_PRIORITY_ERROR_RETURN): Add. - (THREAD_PRIORITY_LOWEST): Add. - (THREAD_PRIORITY_HIGHEST): Add. - - * sched.c (is_attr): Add function. - (implement.h): Add include. - (pthread_setschedparam): Rename all instances of "sched_policy" - to "sched_priority". - (pthread_getschedparam): Ditto. - -Tue Aug 4 16:57:58 1998 Ross Johnson - - * private.c (ptw32_delete_thread): Fix typo. Add missing ';'. - - * global.c (ptw32_virgins): Change types from pointer to - array pointer. - (ptw32_reuse): Ditto. - (ptw32_win32handle_map): Ditto. - (ptw32_threads_mutex_table): Ditto. - - * implement.h(ptw32_virgins): Change types from pointer to - array pointer. - (ptw32_reuse): Ditto. - (ptw32_win32handle_map): Ditto. - (ptw32_threads_mutex_table): Ditto. - - * private.c (ptw32_delete_thread): Fix "entry" should be "thread". - - * misc.c (pthread_self): Add extern for ptw32_threadID_TlsIndex. - - * global.c: Add comment. - - * misc.c (pthread_once): Fix member -> dereferences. - Change ptw32_once_flag to once_control->flag in "if" test. - -Tue Aug 4 00:09:30 1998 Ross Johnson - - * implement.h(ptw32_virgins): Add extern. - (ptw32_virgin_next): Ditto. - (ptw32_reuse): Ditto. - (ptw32_reuse_top): Ditto. - (ptw32_win32handle_map): Ditto. - (ptw32_threads_mutex_table): Ditto. - - * global.c (ptw32_virgins): Changed from array to pointer. - Storage allocation for the array moved into dll.c. - (ptw32_reuse): Ditto. - (ptw32_win32handle_map): Ditto. - (ptw32_threads_mutex_table): Ditto. - - * dll.c (PthreadsEntryPoint): Set up thread admin storage when - DLL is loaded. - - * fork.c (pthread_atfork): Fix function pointer arg to all - ptw32_handler_push() calls. Change "arg" arg to NULL in child push. - - * exit.c: Add windows.h and process.h includes. - (ptw32_exit): Add local detachstate declaration. - (ptw32_exit): Fix incorrect name for pthread_attr_getdetachstate(). - - * pthread.h (_POSIX_THREAD_ATTR_STACKSIZE): Move from global.c - (_POSIX_THREAD_ATTR_STACKADDR): Ditto. - - * create.c (pthread_create): Fix #if should be #ifdef. - (ptw32_start_call): Remove usused variables. - - * process.h: Create. - - * windows.h: Move _beginthreadex and _endthreadex into - process.h - -Mon Aug 3 21:19:57 1998 Ross Johnson - - * condvar.c (pthread_cond_init): Add NULL attr to - pthread_mutex_init() call - default attributes will be used. - (cond_wait): Fix typo. - (cond_wait): Fix typo - cv was ev. - (pthread_cond_broadcast): Fix two identical typos. - - * cleanup.c (ptw32_destructor_pop_all): Remove _ prefix from - PTHREAD_DESTRUCTOR_ITERATIONS. - - * pthread.h: Move _POSIX_* values into posix.h - - * pthread.h: Fix typo in pthread_mutex_init() prototype. - - * attr.c (pthread_attr_init): Fix error in priority member init. - - * windows.h (THREAD_PRIORITY_NORMAL): Add. - - * pthread.h (sched_param): Add missing ';' to struct definition. - - * attr.c (pthread_attr_init): Remove obsolete pthread_attr_t - member initialisation - cancelstate, canceltype, cancel_pending. - (is_attr): Make arg "attr" a const. - - * implement.h (PTW32_HANDLER_POP_LIFO): Remove definition. - (PTW32_HANDLER_POP_FIFO): Ditto. - (PTW32_VALID): Add missing newline escape (\). - (ptw32_handler_node): Make element "next" a pointer. - -1998-08-02 Ben Elliston - - * windows.h: Remove duplicate TlsSetValue() prototype. Add - TlsGetValue() prototype. - (FALSE): Define. - (TRUE): Likewise. - Add forgotten errno values. Guard against multiple #includes. - - * windows.c: New file. Implement stubs for Win32 functions. - - * Makefile (SRCS): Remove. Not explicitly needed. - (CFLAGS): Add -Wall for all warnings with GCC. - -Sun Aug 2 19:03:42 1998 Ross Johnson - - * config.h: Create. This is a temporary stand-in for autoconf yet - to be done. - (HAVE_SIGNAL_H): Add. - - * pthread.h: Minor rearrangement for temporary config.h. - -Fri Jul 31 14:00:29 1998 Ross Johnson - - * cleanup.c (ptw32_destructor_pop): Implement. Removes - destructors associated with a key without executing them. - (ptw32_destructor_pop_all): Add FIXME comment. - - * tsd.c (pthread_key_delete): Add call to ptw32_destructor_pop(). - -Fri Jul 31 00:05:45 1998 Ross Johnson - - * tsd.c (pthread_key_create): Update to properly associate - the destructor routine with the key. - (pthread_key_delete): Add FIXME comment. - - * exit.c (ptw32_vacuum): Add call to - ptw32_destructor_pop_all(). - - * implement.h (ptw32_handler_pop_all): Add prototype. - (ptw32_destructor_pop_all): Ditto. - - * cleanup.c (ptw32_destructor_push): Implement. This is just a - call to ptw32_handler_push(). - (ptw32_destructor_pop_all): Implement. This is significantly - different to ptw32_handler_pop_all(). - - * Makefile (SRCS): Create. Preliminary. - - * windows.h: Create. Contains Win32 definitions for compile - testing. This is just a standin for the real one. - - * pthread.h (SIG_UNBLOCK): Fix typo. Was SIG_BLOCK. - (windows.h): Add include. Required for CRITICAL_SECTION. - (pthread_cond_t): Move enum declaration outside of struct - definition. - (unistd.h): Add include - may be temporary. - - * condvar.c (windows.h): Add include. - - * implement.h (PTW32_THIS): Remove - no longer required. - (PTW32_STACK): Use pthread_self() instead of PTW32_THIS. - -Thu Jul 30 23:12:45 1998 Ross Johnson - - * implement.h: Remove ptw32_find_entry() prototype. - - * private.c: Extend comments. - Remove ptw32_find_entry() - no longer needed. - - * create.c (ptw32_start_call): Add call to TlsSetValue() to - store the thread ID. - - * dll.c (PthreadsEntryPoint): Implement. This is called - whenever a process loads the DLL. Used to initialise thread - local storage. - - * implement.h: Add ptw32_threadID_TlsIndex. - Add ()s around PTW32_VALID expression. - - * misc.c (pthread_self): Re-implement using Win32 TLS to store - the threads own ID. - -Wed Jul 29 11:39:03 1998 Ross Johnson - - * private.c: Corrections in comments. - (ptw32_new_thread): Alter "if" flow to be more natural. - - * cleanup.c (ptw32_handler_push): Same as below. - - * create.c (pthread_create): Same as below. - - * private.c (ptw32_new_thread): Rename "new" to "new_thread". - Since when has a C programmer been required to know C++? - -Tue Jul 28 14:04:29 1998 Ross Johnson - - * implement.h: Add PTW32_VALID macro. - - * sync.c (pthread_join): Modify to use the new thread - type and ptw32_delete_thread(). Rename "target" to "thread". - Remove extra local variable "target". - (pthread_detach): Ditto. - - * signal.c (pthread_sigmask): Move init of "us" out of inner block. - Fix instance of "this" should have been "us". Rename "us" to "thread". - - * sched.c (pthread_setschedparam): Modify to use the new thread - type. - (pthread_getschedparam): Ditto. - - * private.c (ptw32_find_thread): Fix return type and arg. - - * implement.h: Remove PTW32_YES and PTW32_NO. - (ptw32_new_thread): Add prototype. - (ptw32_find_thread): Ditto. - (ptw32_delete_thread): Ditto. - (ptw32_new_thread_entry): Remove prototype. - (ptw32_find_thread_entry): Ditto. - (ptw32_delete_thread_entry): Ditto. - ( PTW32_NEW, PTW32_INUSE, PTW32_EXITED, PTW32_REUSE): - Add. - - - * create.c (pthread_create): Minor rename "us" to "new" (I need - these cues but it doesn't stop me coming out with some major bugs - at times). - Load start_routine and arg into the thread so the wrapper can - call it. - - * exit.c (pthread_exit): Fix pthread_this should be pthread_self. - - * cancel.c (pthread_setcancelstate): Change - ptw32_threads_thread_t * to pthread_t and init with - pthread_this(). - (pthread_setcanceltype): Ditto. - - * exit.c (ptw32_exit): Add new pthread_t arg. - Rename ptw32_delete_thread_entry to ptw32_delete_thread. - Rename "us" to "thread". - (pthread_exit): Call ptw32_exit with added thread arg. - - * create.c (ptw32_start_call): Insert missing ")". - Add "us" arg to ptw32_exit() call. - (pthread_create): Modify to use new thread allocation scheme. - - * private.c: Added detailed explanation of the new thread - allocation scheme. - (ptw32_new_thread): Totally rewritten to use - new thread allocation scheme. - (ptw32_delete_thread): Ditto. - (ptw32_find_thread): Obsolete. - -Mon Jul 27 17:46:37 1998 Ross Johnson - - * create.c (pthread_create): Start of rewrite. Not completed yet. - - * private.c (ptw32_new_thread_entry): Start of rewrite. Not - complete. - - * implement.h (ptw32_threads_thread): Rename, remove thread - member, add win32handle and ptstatus members. - (ptw32_t): Add. - - * pthread.h: pthread_t is no longer mapped directly to a Win32 - HANDLE type. This is so we can let the Win32 thread terminate and - reuse the HANDLE while pthreads holds it's own thread ID until - the last waiting join exits. - -Mon Jul 27 00:20:37 1998 Ross Johnson - - * private.c (ptw32_delete_thread_entry): Destroy the thread - entry attribute object before deleting the thread entry itself. - - * attr.c (pthread_attr_init): Initialise cancel_pending = FALSE. - (pthread_attr_setdetachstate): Rename "detached" to "detachedstate". - (pthread_attr_getdetachstate): Ditto. - - * exit.c (ptw32_exit): Fix incorrect check for detachedstate. - - * implement.h (ptw32_call_t): Remove env member. - -Sun Jul 26 13:06:12 1998 Ross Johnson - - * implement.h (ptw32_new_thread_entry): Fix prototype. - (ptw32_find_thread_entry): Ditto. - (ptw32_delete_thread_entry): Ditto. - (ptw32_exit): Add prototype. - - * exit.c (ptw32_exit): New function. Called from pthread_exit() - and ptw32_start_call() to exit the thread. It allows an extra - argument which is the return code passed to _endthreadex(). - (ptw32_exit): Move thread entry delete call from ptw32_vacuum() - into here. Add more explanation of thread entry deletion. - (ptw32_exit): Clarify comment. - - * create.c (ptw32_start_call): Change pthread_exit() call to - ptw32_exit() call. - - * exit.c (ptw32_vacuum): Add thread entry deletion code - moved from ptw32_start_call(). See next item. - (pthread_exit): Remove longjmp(). Add mutex lock around thread table - manipulation code. This routine now calls _enthreadex(). - - * create.c (ptw32_start_call): Remove setjmp() call and move - cleanup code out. Call pthread_exit(NULL) to terminate the thread. - -1998-07-26 Ben Elliston - - * tsd.c (pthread_getspecific): Update comments. - - * mutex.c (pthread_mutexattr_setpshared): Not supported; remove. - (pthread_mutexattr_getpshared): Likewise. - - * pthread.h (pthread_mutexattr_setpshared): Remove prototype. - (pthread_mutexattr_getpshared): Likewise. - -Sun Jul 26 00:09:59 1998 Ross Johnson - - * sync.c: Rename all instances of ptw32_count_mutex to - ptw32_table_mutex. - - * implement.h: Rename ptw32_count_mutex to - ptw32_table_mutex. - - * global.c: Rename ptw32_count_mutex to - ptw32_table_mutex. - - * create.c (pthread_create): Add critical sections. - (ptw32_start_call): Rename ptw32_count_mutex to - ptw32_table_mutex. - - * cancel.c (pthread_setcancelstate): Fix indirection bug and rename - "this" to "us". - - * signal.c (pthread_sigmask): Rename "this" to "us" and fix some - minor syntax errors. Declare "us" and initialise it. - - * sync.c (pthread_detach): Rename "this" to "target". - - * pthread.h: Converting PTHREAD_* defines to alias the (const int) - values in global.c. - - * global.c: Started converting PTHREAD_* defines to (const int) as - a part of making the eventual pthreads DLL binary compatible - through version changes. - - * condvar.c (cond_wait): Add cancelation point. This applies the - point to both pthread_cond_wait() and pthread_cond_timedwait(). - - * exit.c (pthread_exit): Rename "this" to "us". - - * implement.h: Add comment. - - * sync.c (pthread_join): I've satisfied myself that pthread_detach() - does set the detached attribute in the thread entry attributes - to PTHREAD_CREATE_DETACHED. "if" conditions were changed to test - that attribute instead of a separate flag. - - * create.c (pthread_create): Rename "this" to "us". - (pthread_create): cancelstate and canceltype are not attributes - so the copy to thread entry attribute storage was removed. - Only the thread itself can change it's cancelstate or canceltype, - ie. the thread must exist already. - - * private.c (ptw32_delete_thread_entry): Mutex locks removed. - Mutexes must be applied at the caller level. - (ptw32_new_thread_entry): Ditto. - (ptw32_new_thread_entry): Init cancelstate, canceltype, and - cancel_pending to default values. - (ptw32_new_thread_entry): Rename "this" to "new". - (ptw32_find_thread_entry): Rename "this" to "entry". - (ptw32_delete_thread_entry): Rename "thread_entry" to "entry". - - * create.c (ptw32_start_call): Mutexes changed to - ptw32_count_mutex. All access to the threads table entries is - under the one mutex. Otherwise chaos reigns. - -Sat Jul 25 23:16:51 1998 Ross Johnson - - * implement.h (ptw32_threads_thread): Move cancelstate and - canceltype members out of pthread_attr_t into here. - - * fork.c (fork): Add comment. - -1998-07-25 Ben Elliston - - * fork.c (fork): Autoconfiscate. - -Sat Jul 25 00:00:13 1998 Ross Johnson - - * create.c (ptw32_start_call): Set thread priority. Ensure our - thread entry is removed from the thread table but only if - pthread_detach() was called and there are no waiting joins. - (pthread_create): Set detach flag in thread entry if the - thread is created PTHREAD_CREATE_DETACHED. - - * pthread.h (pthread_attr_t): Rename member "detachedstate". - - * attr.c (pthread_attr_init): Rename attr members. - - * exit.c (pthread_exit): Fix indirection mistake. - - * implement.h (PTW32_THREADS_TABLE_INDEX): Add. - - * exit.c (ptw32_vacuum): Fix incorrect args to - ptw32_handler_pop_all() calls. - Make thread entry removal conditional. - - * sync.c (pthread_join): Add multiple join and async detach handling. - - * implement.h (PTW32_THREADS_TABLE_INDEX): Add. - - * global.c (ptw32_threads_mutex_table): Add. - - * implement.h (ptw32_once_flag): Remove. - (ptw32_once_lock): Ditto. - (ptw32_threads_mutex_table): Add. - - * global.c (ptw32_once_flag): Remove. - (ptw32_once_lock): Ditto. - - * sync.c (pthread_join): Fix tests involving new return value - from ptw32_find_thread_entry(). - (pthread_detach): Ditto. - - * private.c (ptw32_find_thread_entry): Failure return code - changed from -1 to NULL. - -Fri Jul 24 23:09:33 1998 Ross Johnson - - * create.c (pthread_create): Change . to -> in sigmask memcpy() args. - - * pthread.h: (pthread_cancel): Add function prototype. - (pthread_testcancel): Ditto. - -1998-07-24 Ben Elliston - - * pthread.h (pthread_condattr_t): Rename dummy structure member. - (pthread_mutexattr_t): Likewise. - -Fri Jul 24 21:13:55 1998 Ross Johnson - - * cancel.c (pthread_cancel): Implement. - (pthread_testcancel): Implement. - - * exit.c (pthread_exit): Add comment explaining the longjmp(). - - * implement.h (ptw32_threads_thread_t): New member cancelthread. - (PTW32_YES): Define. - (PTW32_NO): Define. - (RND_SIZEOF): Remove. - - * create.c (pthread_create): Rename cancelability to cancelstate. - - * pthread.h (pthread_attr_t): Rename cancelability to cancelstate. - (PTHREAD_CANCELED): Define. - -1998-07-24 Ben Elliston - - * pthread.h (SIG_BLOCK): Define if not already defined. - (SIG_UNBLOCK): Likewise. - (SIG_SETMASK): Likewise. - (pthread_attr_t): Add signal mask member. - (pthread_sigmask): Add function prototype. - - * signal.c (pthread_sigmask): Implement. - - * create.c: #include to get a prototype for memcpy(). - (pthread_create): New threads inherit their creator's signal - mask. Copy the signal mask to the new thread structure if we know - about signals. - -Fri Jul 24 16:33:17 1998 Ross Johnson - - * fork.c (pthread_atfork): Add all the necessary push calls. - Local implementation semantics: - If we get an ENOMEM at any time then ALL handlers - (including those from previous pthread_atfork() calls) will be - popped off each of the three atfork stacks before we return. - (fork): Add all the necessary pop calls. Add the thread cancellation - and join calls to the child fork. - Add #includes. - - * implement.h: (ptw32_handler_push): Fix return type and stack arg - type in prototype. - (ptw32_handler_pop): Fix stack arg type in prototype. - (ptw32_handler_pop_all): Fix stack arg type in prototype. - - * cleanup.c (ptw32_handler_push): Change return type to int and - return ENOMEM if malloc() fails. - - * sync.c (pthread_detach): Use equality test, not assignment. - - * create.c (ptw32_start_call): Add call to Win32 CloseHandle() - if thread is detached. - -1998-07-24 Ben Elliston - - * sync.c (pthread_detach): Close the Win32 thread handle to - emulate detached (or daemon) threads. - -Fri Jul 24 03:00:25 1998 Ross Johnson - - * sync.c (pthread_join): Save valueptr arg in joinvalueptr for - pthread_exit() to use. - - * private.c (ptw32_new_thread_entry): Initialise joinvalueptr to - NULL. - - * create.c (ptw32_start_call): Rewrite to facilitate joins. - pthread_exit() will do a longjmp() back to here. Does appropriate - cleanup and exit/return from the thread. - (pthread_create): _beginthreadex() now passes a pointer to our - thread table entry instead of just the call member of that entry. - - * implement.h (ptw32_threads_thread): New member - void ** joinvalueptr. - (ptw32_call_t): New member jmpbuf env. - - * exit.c (pthread_exit): Major rewrite to handle joins and handing - value pointer to joining thread. Uses longjmp() back to - ptw32_start_call(). - - * create.c (pthread_create): Ensure values of new attribute members - are copied to the thread attribute object. - - * attr.c (pthread_attr_destroy): Fix merge conflicts. - (pthread_attr_getdetachstate): Fix merge conflicts. - (pthread_attr_setdetachstate): Fix merge conflicts. - - * pthread.h: Fix merge conflicts. - - * sync.c (pthread_join): Fix merge conflicts. - -Fri Jul 24 00:21:21 1998 Ross Johnson - - * sync.c (pthread_join): Add check for valid and joinable - thread. - (pthread_detach): Implement. After checking for a valid and joinable - thread, it's still a no-op. - - * private.c (ptw32_find_thread_entry): Bug prevented returning - an error value in some cases. - - * attr.c (pthread_attr_setdetachedstate): Implement. - (pthread_attr_getdetachedstate): Implement. - - * implement.h: Move more hidden definitions into here from - pthread.h. - -1998-07-24 Ben Elliston - - * pthread.h (PTHREAD_CREATE_JOINABLE): Define. - (PTHREAD_CREATE_DETACHED): Likewise. - (pthread_attr_t): Add new structure member `detached'. - (pthread_attr_getdetachstate): Add function prototype. - (pthread_attr_setdetachstate): Likewise. - - * sync.c (pthread_join): Return if the target thread is detached. - - * attr.c (pthread_attr_init): Initialise cancelability and - canceltype structure members. - (pthread_attr_getdetachstate): Implement. - (pthread_attr_setdetachstate): Likewise. - - * implement.h (PTW32_CANCEL_DEFAULTS): Remove. Bit fields - proved to be too cumbersome. Set the defaults in attr.c using the - public PTHREAD_CANCEL_* constants. - - * cancel.c: New file. - - * pthread.h (sched_param): Define this type. - (pthread_attr_getschedparam): Add function prototype. - (pthread_attr_setschedparam): Likewise. - (pthread_setcancelstate): Likewise. - (pthread_setcanceltype): Likewise. - (sched_get_priority_min): Likewise. - (sched_get_priority_max): Likewise. - (pthread_mutexattr_setprotocol): Remove; not supported. - (pthread_mutexattr_getprotocol): Likewise. - (pthread_mutexattr_setprioceiling): Likewise. - (pthread_mutexattr_getprioceiling): Likewise. - (pthread_attr_t): Add canceltype member. Update comments. - (SCHED_OTHER): Define this scheduling policy constant. - (SCHED_FIFO): Likewise. - (SCHED_RR): Likewise. - (SCHED_MIN): Define the lowest possible value for this constant. - (SCHED_MAX): Likewise, the maximum possible value. - (PTHREAD_CANCEL_ASYNCHRONOUS): Redefine. - (PTHREAD_CANCEL_DEFERRED): Likewise. - - * sched.c: New file. - (pthread_setschedparam): Implement. - (pthread_getschedparam): Implement. - (sched_get_priority_max): Validate policy argument. - (sched_get_priority_min): Likewise. - - * mutex.c (pthread_mutexattr_setprotocol): Remove; not supported. - (pthread_mutexattr_getprotocol): Likewise. - (pthread_mutexattr_setprioceiling): Likewise. - (pthread_mutexattr_getprioceiling): Likewise. - -Fri Jul 24 00:21:21 1998 Ross Johnson - - * create.c (pthread_create): Arg to ptw32_new_thread_entry() - changed. See next entry. Move mutex locks out. Changes made yesterday - and today allow us to start the new thread running rather than - temporarily suspended. - - * private.c (ptw32_new_thread_entry): ptw32_thread_table - was changed back to a table of thread structures rather than pointers. - As such we're trading storage for increaded speed. This routine - was modified to work with the new table. Mutex lock put in around - global data accesses. - (ptw32_find_thread_entry): Ditto - (ptw32_delete_thread_entry): Ditto - -Thu Jul 23 23:25:30 1998 Ross Johnson - - * global.c: New. Global data objects declared here. These moved from - pthread.h. - - * pthread.h: Move implementation hidden definitions into - implement.h. - - * implement.h: Move implementation hidden definitions from - pthread.h. Add constants to index into the different handler stacks. - - * cleanup.c (ptw32_handler_push): Simplify args. Restructure. - (ptw32_handler_pop): Simplify args. Restructure. - (ptw32_handler_pop_all): Simplify args. Restructure. - -Wed Jul 22 00:16:22 1998 Ross Johnson - - * attr.c, implement.h, pthread.h, ChangeLog: Resolve CVS merge - conflicts. - - * private.c (ptw32_find_thread_entry): Changes to return type - to support leaner ptw32_threads_table[] which now only stores - ptw32_thread_thread_t *. - (ptw32_new_thread_entry): Internal changes. - (ptw32_delete_thread_entry): Internal changes to avoid contention. - Calling routines changed accordingly. - - * pthread.h: Modified cleanup macros to use new generic push and pop. - Added destructor and atfork stacks to ptw32_threads_thread_t. - - * cleanup.c (ptw32_handler_push, ptw32_handler_pop, - ptw32_handler_pop_all): Renamed cleanup push and pop routines - and made generic to handle destructors and atfork handlers as - well. - - * create.c (ptw32_start_call): New function is a wrapper for - all new threads. It allows us to do some cleanup when the thread - returns, ie. that is otherwise only done if the thread is cancelled. - - * exit.c (ptw32_vacuum): New function contains code from - pthread_exit() that we need in the new ptw32_start_call() - as well. - - * implement.h: Various additions and minor changes. - - * pthread.h: Various additions and minor changes. - Change cleanup handler macros to use generic handler push and pop - functions. - - * attr.c: Minor mods to all functions. - (is_attr): Implemented missing function. - - * create.c (pthread_create): More clean up. - - * private.c (ptw32_find_thread_entry): Implement. - (ptw32_delete_thread_entry): Implement. - (ptw32_new_thread_entry): Implement. - These functions manipulate the implementations internal thread - table and are part of general code cleanup and modularisation. - They replace ptw32_getthreadindex() which was removed. - - * exit.c (pthread_exit): Changed to use the new code above. - - * pthread.h: Add cancelability constants. Update comments. - -1998-07-22 Ben Elliston - - * attr.c (pthread_setstacksize): Update test of attr argument. - (pthread_getstacksize): Likewise. - (pthread_setstackaddr): Likewise. - (pthread_getstackaddr): Likewise. - (pthread_attr_init): No need to allocate any storage. - (pthread_attr_destroy): No need to free any storage. - - * mutex.c (is_attr): Not likely to be needed; remove. - (remove_attr): Likewise. - (insert_attr): Likewise. - - * implement.h (ptw32_mutexattr_t): Moved to a public definition - in pthread.h. There was little gain in hiding these details. - (ptw32_condattr_t): Likewise. - (ptw32_attr_t): Likewise. - - * pthread.h (pthread_atfork): Add function prototype. - (pthread_attr_t): Moved here from implement.h. - - * fork.c (pthread_atfork): Preliminary implementation. - (ptw32_fork): Likewise. - -Wed Jul 22 00:16:22 1998 Ross Johnson - - * cleanup.c (ptw32_cleanup_push): Implement. - (ptw32_cleanup_pop): Implement. - (ptw32_do_cancellation): Implement. - These are private to the implementation. The real cleanup functions - are macros. See below. - - * pthread.h (pthread_cleanup_push): Implement as a macro. - (pthread_cleanup_pop): Implement as a macro. - Because these are macros which start and end a block, the POSIX scoping - requirement is observed. See the comment in the file. - - * exit.c (pthread_exit): Refine the code. - - * create.c (pthread_create): Code cleanup. - - * implement.h (RND_SIZEOF): Add RND_SIZEOF(T) to round sizeof(T) - up to multiple of DWORD. - Add function prototypes. - - * private.c (ptw32_getthreadindex): "*thread" should have been - "thread". Detect empty slot fail condition. - -1998-07-20 Ben Elliston - - * misc.c (pthread_once): Implement. Don't use a per-application - flag and mutex--make `pthread_once_t' contain these elements in - their structure. The earlier version had incorrect semantics. - - * pthread.h (ptw32_once_flag): Add new variable. Remove. - (ptw32_once_lock): Add new mutex lock to ensure integrity of - access to ptw32_once_flag. Remove. - (pthread_once): Add function prototype. - (pthread_once_t): Define this type. - -Mon Jul 20 02:31:05 1998 Ross Johnson - - * private.c (ptw32_getthreadindex): Implement. - - * pthread.h: Add application static data dependent on - _PTHREADS_BUILD_DLL define. This is needed to avoid allocating - non-sharable static data within the pthread DLL. - - * implement.h: Add ptw32_cleanup_stack_t, ptw32_cleanup_node_t - and PTW32_HASH_INDEX. - - * exit.c (pthread_exit): Begin work on cleanup and de-allocate - thread-private storage. - - * create.c (pthread_create): Add thread to thread table. - Keep a thread-private copy of the attributes with default values - filled in when necessary. Same for the cleanup stack. Make - pthread_create C run-time library friendly by using _beginthreadex() - instead of CreateThread(). Fix error returns. - -Sun Jul 19 16:26:23 1998 Ross Johnson - - * implement.h: Rename pthreads_thread_count to ptw32_threads_count. - Create ptw32_threads_thread_t struct to keep thread specific data. - - * create.c: Rename pthreads_thread_count to ptw32_threads_count. - (pthread_create): Handle errors from CreateThread(). - -1998-07-19 Ben Elliston - - * condvar.c (pthread_cond_wait): Generalise. Moved from here .. - (cond_wait): To here. - (pthread_cond_timedwait): Implement; use generalised cond_wait(). - - * pthread.h (pthread_key_t): Define this type. - (pthread_key_create): Add function prototype. - (pthread_setspecific): Likewise. - (pthread_getspecific): Likwise. - (pthread_key_delete): Likewise. - - * tsd.c (pthread_key_create): Implement. - (pthread_setspecific): Likewise. - (pthread_getspecific): Likewise. - (pthread_key_delete): Likewise. - - * mutex.c (pthread_mutex_trylock): Return ENOSYS if this function - is called on a Win32 platform which is not Windows NT. - -1998-07-18 Ben Elliston - - * condvar.c (pthread_condattr_init): Do not attempt to malloc any - storage; none is needed now that condattr_t is an empty struct. - (pthread_condattr_destory): Likewise; do not free storage. - (pthread_condattr_setpshared): No longer supported; return ENOSYS. - (pthread_condattr_getpshared): Likewise. - (pthread_cond_init): Implement with help from Douglas Schmidt. - Remember to initialise the cv's internal mutex. - (pthread_cond_wait): Likewise. - (pthread_cond_signal): Likewise. - (pthread_cond_broadcast): Likewise. - (pthread_cond_timedwait): Preliminary implementation, but I need - to see some API documentation for `WaitForMultipleObject'. - (pthread_destory): Implement. - - * pthread.h (pthread_cond_init): Add function protoype. - (pthread_cond_broadcast): Likewise. - (pthread_cond_signal): Likewise. - (pthread_cond_timedwait): Likewise. - (pthread_cond_wait): Likewise. - (pthread_cond_destroy): Likewise. - (pthread_cond_t): Define this type. Fix for u_int. Do not assume - that the mutex contained withing the pthread_cond_t structure will - be a critical section. Use our new POSIX type! - - * implement.h (ptw32_condattr_t): Remove shared attribute. - -1998-07-17 Ben Elliston - - * pthread.h (PTHREADS_PROCESS_PRIVATE): Remove. - (PTHREAD_PROCESS_SHARED): Likewise. No support for mutexes shared - across processes for now. - (pthread_mutex_t): Use a Win32 CRITICAL_SECTION type for better - performance. - - * implement.h (ptw32_mutexattr_t): Remove shared attribute. - - * mutex.c (pthread_mutexattr_setpshared): This optional function - is no longer supported, since we want to implement POSIX mutex - variables using the much more efficient Win32 critical section - primitives. Critical section objects in Win32 cannot be shared - between processes. - (pthread_mutexattr_getpshared): Likewise. - (pthread_mutexattr_init): No need to malloc any storage; the - attributes structure is now empty. - (pthread_mutexattr_destroy): This is now a nop. - (pthread_mutex_init): Use InitializeCriticalSection(). - (pthread_mutex_destroy): Use DeleteCriticalSection(). - (pthread_mutex_lock): Use EnterCriticalSection(). - (pthread_mutex_trylock): Use TryEnterCriticalSection(). This is - not supported by Windows 9x, but trylock is a hack anyway, IMHO. - (pthread_mutex_unlock): Use LeaveCriticalSection(). - -1998-07-14 Ben Elliston - - * attr.c (pthread_attr_setstacksize): Implement. - (pthread_attr_getstacksize): Likewise. - (pthread_attr_setstackaddr): Likewise. - (pthread_attr_getstackaddr): Likewise. - (pthread_attr_init): Likewise. - (pthread_attr_destroy): Likewise. - - * condvar.c (pthread_condattr_init): Add `_cond' to function name. - - * mutex.c (pthread_mutex_lock): Add `_mutex' to function name. - (pthread_mutex_trylock): Likewise. - (pthread_mutex_unlock): Likewise. - - * pthread.h (pthread_condattr_setpshared): Fix typo. - (pthread_attr_init): Add function prototype. - (pthread_attr_destroy): Likewise. - (pthread_attr_setstacksize): Likewise. - (pthread_attr_getstacksize): Likewise. - (pthread_attr_setstackaddr): Likewise. - (pthread_attr_getstackaddr): Likewise. - -Mon Jul 13 01:09:55 1998 Ross Johnson - - * implement.h: Wrap in #ifndef _IMPLEMENT_H - - * create.c (pthread_create): Map stacksize attr to Win32. - - * mutex.c: Include implement.h - -1998-07-13 Ben Elliston - - * condvar.c (pthread_condattr_init): Implement. - (pthread_condattr_destroy): Likewise. - (pthread_condattr_setpshared): Likewise. - (pthread_condattr_getpshared): Likewise. - - * implement.h (PTHREAD_THREADS_MAX): Remove trailing semicolon. - (PTHREAD_STACK_MIN): Specify; needs confirming. - (ptw32_attr_t): Define this type. - (ptw32_condattr_t): Likewise. - - * pthread.h (pthread_mutex_t): Define this type. - (pthread_condattr_t): Likewise. - (pthread_mutex_destroy): Add function prototype. - (pthread_lock): Likewise. - (pthread_trylock): Likewise. - (pthread_unlock): Likewise. - (pthread_condattr_init): Likewise. - (pthread_condattr_destroy): Likewise. - (pthread_condattr_setpshared): Likewise. - (pthread_condattr_getpshared): Likewise. - - * mutex.c (pthread_mutex_init): Implement. - (pthread_mutex_destroy): Likewise. - (pthread_lock): Likewise. - (pthread_trylock): Likewise. - (pthread_unlock): Likewise. - -1998-07-12 Ben Elliston - - * implement.h (ptw32_mutexattr_t): Define this implementation - internal type. Application programmers only see a mutex attribute - object as a void pointer. - - * pthread.h (pthread_mutexattr_t): Define this type. - (pthread_mutexattr_init): Add function prototype. - (pthread_mutexattr_destroy): Likewise. - (pthread_mutexattr_setpshared): Likewise. - (pthread_mutexattr_getpshared): Likewise. - (pthread_mutexattr_setprotocol): Likewise. - (pthread_mutexattr_getprotocol): Likewise. - (pthread_mutexattr_setprioceiling): Likewise. - (pthread_mutexattr_getprioceiling): Likewise. - (PTHREAD_PROCESS_PRIVATE): Define. - (PTHREAD_PROCESS_SHARED): Define. - - * mutex.c (pthread_mutexattr_init): Implement. - (pthread_mutexattr_destroy): Implement. - (pthread_mutexattr_setprotocol): Implement. - (pthread_mutexattr_getprotocol): Likewise. - (pthread_mutexattr_setprioceiling): Likewise. - (pthread_mutexattr_getprioceiling): Likewise. - (pthread_mutexattr_setpshared): Likewise. - (pthread_mutexattr_getpshared): Likewise. - (insert_attr): New function; very preliminary implementation! - (is_attr): Likewise. - (remove_attr): Likewise. - -Sat Jul 11 14:48:54 1998 Ross Johnson - - * implement.h: Preliminary implementation specific defines. - - * create.c (pthread_create): Preliminary implementation. - -1998-07-11 Ben Elliston - - * sync.c (pthread_join): Implement. - - * misc.c (pthread_equal): Likewise. - - * pthread.h (pthread_join): Add function prototype. - (pthread_equal): Likewise. - -1998-07-10 Ben Elliston - - * misc.c (pthread_self): Implement. - - * exit.c (pthread_exit): Implement. - - * pthread.h (pthread_exit): Add function prototype. - (pthread_self): Likewise. - (pthread_t): Define this type. - -1998-07-09 Ben Elliston - - * create.c (pthread_create): A dummy stub right now. - - * pthread.h (pthread_create): Add function prototype. diff --git a/deps/w32-pthreads/FAQ b/deps/w32-pthreads/FAQ deleted file mode 100644 index cb1786c..0000000 --- a/deps/w32-pthreads/FAQ +++ /dev/null @@ -1,451 +0,0 @@ - ========================================= - PTHREADS-WIN32 Frequently Asked Questions - ========================================= - -INDEX ------ - -Q 1 What is it? - -Q 2 Which of the several dll versions do I use? - or, - What are all these pthread*.dll and pthread*.lib files? - -Q 3 What is the library naming convention? - -Q 4 Cleanup code default style or: it used to work when I built - the library myself, but now it doesn't - why? - -Q 5 Why is the default library version now less exception-friendly? - -Q 6 Should I use Cygwin or Mingw32 as a development environment? - -Q 7 Now that pthreads-win32 builds under Mingw32, why do I get - memory access violations (segfaults)? - -Q 8 How do I use pthread.dll for Win32 (Visual C++ 5.0) - -Q 9 Cancelation doesn't work for me, why? - -Q 10 How do I generate pthreadGCE.dll and libpthreadw32.a for use - with Mingw32? - -Q 11 Why isn't pthread_t defined as a scalar (e.g. pointer or int) - like it is for other POSIX threads implementations? - -============================================================================= - -Q 1 What is it? ---- - -Pthreads-win32 is an Open Source Software implementation of the -Threads component of the POSIX 1003.1c 1995 Standard for Microsoft's -Win32 environment. Some functions from POSIX 1003.1b are also -supported including semaphores. Other related functions include -the set of read-write lock functions. The library also supports -some of the functionality of the Open Group's Single Unix -specification, version 2, namely mutex types. - -See the file "ANNOUNCE" for more information including standards -conformance details and list of supported routines. - - ------------------------------------------------------------------------------- - -Q 2 Which of the several dll versions do I use? ---- or, - What are all these pthread*.dll and pthread*.lib files? - -Simply, you only use one of them, but you need to choose carefully. - -The most important choice you need to make is whether to use a -version that uses exceptions internally, or not (there are versions -of the library that use exceptions as part of the thread -cancelation and cleanup implementation, and one that uses -setjmp/longjmp instead). - -There is some contension amongst POSIX threads experts as -to how POSIX threads cancelation and exit should work -with languages that include exceptions and handlers, e.g. -C++ and even C (Microsoft's Structured Exceptions). - -The issue is: should cancelation of a thread in, say, -a C++ application cause object destructors and C++ exception -handlers to be invoked as the stack unwinds during thread -exit, or not? - -There seems to be more opinion in favour of using the -standard C version of the library (no EH) with C++ applications -since this appears to be the assumption commercial pthreads -implementations make. Therefore, if you use an EH version -of pthreads-win32 then you may be under the illusion that -your application will be portable, when in fact it is likely to -behave very differently linked with other pthreads libraries. - -Now you may be asking: why have you kept the EH versions of -the library? - -There are a couple of reasons: -- there is division amongst the experts and so the code may - be needed in the future. (Yes, it's in the repository and we - can get it out anytime in the future, but ...) -- pthreads-win32 is one of the few implementations, and possibly - the only freely available one, that has EH versions. It may be - useful to people who want to play with or study application - behaviour under these conditions. - - ------------------------------------------------------------------------------- - -Q 3 What is the library naming convention? ---- - -Because the library is being built using various exception -handling schemes and compilers - and because the library -may not work reliably if these are mixed in an application, -each different version of the library has it's own name. - -Note 1: the incompatibility is really between EH implementations -of the different compilers. It should be possible to use the -standard C version from either compiler with C++ applications -built with a different compiler. If you use an EH version of -the library, then you must use the same compiler for the -application. This is another complication and dependency that -can be avoided by using only the standard C library version. - -Note 2: if you use a standard C pthread*.dll with a C++ -application, then any functions that you define that are -intended to be called via pthread_cleanup_push() must be -__cdecl. - -Note 3: the intention is to also name either the VC or GC -version (it should be arbitrary) as pthread.dll, including -pthread.lib and libpthread.a as appropriate. - -In general: - pthread[VG]{SE,CE,C}.dll - pthread[VG]{SE,CE,C}.lib - -where: - [VG] indicates the compiler - V - MS VC - G - GNU C - - {SE,CE,C} indicates the exception handling scheme - SE - Structured EH - CE - C++ EH - C - no exceptions - uses setjmp/longjmp - -For example: - pthreadVSE.dll (MSVC/SEH) - pthreadGCE.dll (GNUC/C++ EH) - pthreadGC.dll (GNUC/not dependent on exceptions) - -The GNU library archive file names have changed to: - - libpthreadGCE.a - libpthreadGC.a - - ------------------------------------------------------------------------------- - -Q 4 Cleanup code default style or: it used to work when I built ---- the library myself, but now it doesn't - why? - -Up to and including snapshot 2001-07-12, if not defined, the cleanup -style was determined automatically from the compiler used, and one -of the following was defined accordingly: - - __CLEANUP_SEH MSVC only - __CLEANUP_CXX C++, including MSVC++, GNU G++ - __CLEANUP_C C, including GNU GCC, not MSVC - -These defines determine the style of cleanup (see pthread.h) and, -most importantly, the way that cancelation and thread exit (via -pthread_exit) is performed (see the routine ptw32_throw() in private.c). - -In short, the exceptions versions of the library throw an exception -when a thread is canceled or exits (via pthread_exit()), which is -caught by a handler in the thread startup routine, so that the -the correct stack unwinding occurs regardless of where the thread -is when it's canceled or exits via pthread_exit(). - -After snapshot 2001-07-12, unless your build explicitly defines (e.g. -via a compiler option) __CLEANUP_SEH, __CLEANUP_CXX, or __CLEANUP_C, then -the build now ALWAYS defaults to __CLEANUP_C style cleanup. This style -uses setjmp/longjmp in the cancelation and pthread_exit implementations, -and therefore won't do stack unwinding even when linked to applications -that have it (e.g. C++ apps). This is for consistency with most/all -commercial Unix POSIX threads implementations. - -Although it was not clearly documented before, it is still necessary to -build your application using the same __CLEANUP_* define as was -used for the version of the library that you link with, so that the -correct parts of pthread.h are included. That is, the possible -defines require the following library versions: - - __CLEANUP_SEH pthreadVSE.dll - __CLEANUP_CXX pthreadVCE.dll or pthreadGCE.dll - __CLEANUP_C pthreadVC.dll or pthreadGC.dll - -THE POINT OF ALL THIS IS: if you have not been defining one of these -explicitly, then the defaults have been set according to the compiler -and language you are using, as described at the top of this -section. - -THIS NOW CHANGES, as has been explained above. For example: - -If you were building your application with MSVC++ i.e. using C++ -exceptions (rather than SEH) and not explicitly defining one of -__CLEANUP_*, then __CLEANUP_C++ was defined for you in pthread.h. -You should have been linking with pthreadVCE.dll, which does -stack unwinding. - -If you now build your application as you had before, pthread.h will now -set __CLEANUP_C as the default style, and you will need to link -with pthreadVC.dll. Stack unwinding will now NOT occur when a -thread is canceled, nor when the thread calls pthread_exit(). - -Your application will now most likely behave differently to previous -versions, and in non-obvious ways. Most likely is that local -objects may not be destroyed or cleaned up after a thread -is canceled. - -If you want the same behaviour as before, then you must now define -__CLEANUP_C++ explicitly using a compiler option and link with -pthreadVCE.dll as you did before. - - ------------------------------------------------------------------------------- - -Q 5 Why is the default library version now less exception-friendly? ---- - -Because most commercial Unix POSIX threads implementations don't allow you to -choose to have stack unwinding. (Compaq's TRU64 Unix is possibly an exception.) - -Therefore, providing it in pthread-win32 as a default could be dangerous -and non-portable. We still provide the choice but you must now consciously -make it. - -WHY NOT REMOVE THE EXCEPTIONS VERSIONS OF THE LIBRARY ALTOGETHER? -There are a few reasons: -- because there are well respected POSIX threads people who believe - that POSIX threads implementations should be exceptions-aware and - do the expected thing in that context. (There are equally respected - people who believe it should not be easily accessible, if it's there - at all.) -- because pthreads-win32 is one of the few implementations that has - the choice, perhaps the only freely available one, and so offers - a laboratory to people who may want to explore the effects; -- although the code will always be around somewhere for anyone who - wants it, once it's removed from the current version it will not be - nearly as visible to people who may have a use for it. - - ------------------------------------------------------------------------------- - -Q 6 Should I use Cygwin or Mingw32 as a development environment? ---- - -Important: see Q7 also. - -Use Mingw32 with the MSVCRT library to build applications that use -the pthreads DLL. - -Cygwin's own internal support for POSIX threads is growing. -Consult that project's documentation for more information. - ------------------------------------------------------------------------------- - -Q 7 Now that pthreads-win32 builds under Mingw32, why do I get ---- memory access violations (segfaults)? - -The latest Mingw32 package has thread-safe exception handling (see Q10). -Also, see Q6 above. - ------------------------------------------------------------------------------- - -Q 8 How do I use pthread.dll for Win32 (Visual C++ 5.0) ---- - -> -> I'm a "rookie" when it comes to your pthread implementation. I'm currently -> desperately trying to install the prebuilt .dll file into my MSVC compiler. -> Could you please provide me with explicit instructions on how to do this (or -> direct me to a resource(s) where I can acquire such information)? -> -> Thank you, -> - -You should have a .dll, .lib, .def, and three .h files. It is recommended -that you use pthreadVC.dll, rather than pthreadVCE.dll or pthreadVSE.dll -(see Q2 above). - -The .dll can go in any directory listed in your PATH environment -variable, so putting it into C:\WINDOWS should work. - -The .lib file can go in any directory listed in your LIB environment -variable. - -The .h files can go in any directory listed in your INCLUDE -environment variable. - -Or you might prefer to put the .lib and .h files into a new directory -and add its path to LIB and INCLUDE. You can probably do this easiest -by editing the file:- - -C:\Program Files\DevStudio\vc\bin\vcvars32.bat - -The .def file isn't used by anything in the pre-compiled version but -is included for information. - -Cheers. -Ross - ------------------------------------------------------------------------------- - -Q 9 Cancelation doesn't work for me, why? ---- - -> I'm investigating a problem regarding thread cancelation. The thread I want -> to cancel has PTHREAD_CANCEL_ASYNCHRONOUS, however, this piece of code -> blocks on the join(): -> -> if ((retv = Pthread_cancel( recvThread )) == 0) -> { -> retv = Pthread_join( recvThread, 0 ); -> } -> -> Pthread_* are just macro's; they call pthread_*. -> -> The thread recvThread seems to block on a select() call. It doesn't get -> cancelled. -> -> Two questions: -> -> 1) is this normal behaviour? -> -> 2) if not, how does the cancel mechanism work? I'm not very familliar to -> win32 programming, so I don't really understand how the *Event() family of -> calls work. - -The answer to your first question is, normal POSIX behaviour would -be to asynchronously cancel the thread. However, even that doesn't -guarantee cancelation as the standard only says it should be -cancelled as soon as possible. - -Snapshot 99-11-02 or earlier only partially supports asynchronous cancellation. -Snapshots since then simulate async cancelation by poking the address of -a cancelation routine into the PC of the threads context. This requires -the thread to be resumed in some way for the cancelation to actually -proceed. This is not true async cancelation, but it is as close as we've -been able to get to it. - -If the thread you're trying to cancel is blocked (for instance, it could be -waiting for data from the network), it will only get cancelled when it unblocks -(when the data arrives). For true pre-emptive cancelation in these cases, -pthreads-win32 from snapshot 2004-05-16 can automatically recognise and use the -QueueUserAPCEx package by Panagiotis E. Hadjidoukas. This package is available -from the pthreads-win32 ftp site and is included in the pthreads-win32 -self-unpacking zip from 2004-05-16 onwards. - -Using deferred cancelation would normally be the way to go, however, -even though the POSIX threads standard lists a number of C library -functions that are defined as deferred cancelation points, there is -no hookup between those which are provided by Windows and the -pthreads-win32 library. - -Incidently, it's worth noting for code portability that the older POSIX -threads standards cancelation point lists didn't include "select" because -(as I read in Butenhof) it wasn't part of POSIX. However, it does appear in -the SUSV3. - -Effectively, the only mandatory cancelation points that pthreads-win32 -recognises are those the library implements itself, ie. - - pthread_testcancel - pthread_cond_wait - pthread_cond_timedwait - pthread_join - sem_wait - sem_timedwait - pthread_delay_np - -The following routines from the non-mandatory list in SUSV3 are -cancelation points in pthreads-win32: - - pthread_rwlock_wrlock - pthread_rwlock_timedwrlock - -The following routines from the non-mandatory list in SUSV3 are not -cancelation points in pthreads-win32: - - pthread_rwlock_rdlock - pthread_rwlock_timedrdlock - -Pthreads-win32 also provides two functions that allow you to create -cancelation points within your application, but only for cases where -a thread is going to block on a Win32 handle. These are: - - pthreadCancelableWait(HANDLE waitHandle) /* Infinite wait */ - - pthreadCancelableTimedWait(HANDLE waitHandle, DWORD timeout) - ------------------------------------------------------------------------------- - - -Q 10 How do I create thread-safe applications using ----- pthreadGCE.dll, libpthreadw32.a and Mingw32? - -This should not be a problem with recent versions of MinGW32. - -For early versions, see Thomas Pfaff's email at: -http://sources.redhat.com/ml/pthreads-win32/2002/msg00000.html ------------------------------------------------------------------------------- - -Q 11 Why isn't pthread_t defined as a scalar (e.g. pointer or int) - like it is for other POSIX threads implementations? ----- - -Originally pthread_t was defined as a pointer (to the opaque pthread_t_ -struct) and later it was changed to a struct containing the original -pointer plus a sequence counter. This is allowed under both the original -POSIX Threads Standard and the current Single Unix Specification. - -When pthread_t is a simple pointer to a struct some very difficult to -debug problems arise from the process of freeing and later allocing -thread structs because new pthread_t handles can acquire the identity of -previously detached threads. The change to a struct was made, along with -some changes to their internal managment, in order to guarantee (for -practical applications) that the pthread_t handle will be unique over the -life of the running process. - -Where application code attempts to compare one pthread_t against another -directly, a compiler error will be emitted because structs can't be -compared at that level. This should signal a potentially serious problem -in the code design, which would go undetected if pthread_t was a scalar. - -The POSIX Threading API provides a function named pthread_equal() to -compare pthread_t thread handles. - -Other pthreads implementations, such as Sun's, use an int as the handle -but do guarantee uniqueness within the process scope. Win32 scalar typed -thread handles also guarantee uniqueness in system scope. It wasn't clear -how well the internal management of these handles would scale as the -number of threads and the fragmentation of the sequence numbering -increased for applications where thousands or millions of threads are -created and detached over time. The current management of threads within -pthreads-win32 using structs for pthread_t, and reusing without ever -freeing them, reduces the management time overheads to a constant, which -could be important given that pthreads-win32 threads are built on top of -Win32 threads and will therefore include that management overhead on top -of their own. The cost is that the memory resources used for thread -handles will remain at the peak level until the process exits. - -While it may be inconvenient for developers to be forced away from making -assumptions about the internals of pthread_t, the advantage for the -future development of pthread-win32, as well as those applications that -use it and other pthread implementations, is that the library is free to -change pthread_t internals and management as better methods arise. - diff --git a/deps/w32-pthreads/GNUmakefile b/deps/w32-pthreads/GNUmakefile deleted file mode 100644 index 9b92462..0000000 --- a/deps/w32-pthreads/GNUmakefile +++ /dev/null @@ -1,593 +0,0 @@ -# -# -------------------------------------------------------------------------- -# -# Pthreads-win32 - POSIX Threads Library for Win32 -# Copyright(C) 1998 John E. Bossom -# Copyright(C) 1999,2005 Pthreads-win32 contributors -# -# Contact Email: rpj@callisto.canberra.edu.au -# -# 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., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -# - -DLL_VER = 2 -DLL_VERD= $(DLL_VER)d - -DEVROOT = C:\PTHREADS - -DLLDEST = $(DEVROOT)\DLL -LIBDEST = $(DEVROOT)\DLL - -# If Running MsysDTK -RM = rm -f -MV = mv -f -CP = cp -f - -# If not. -#RM = erase -#MV = rename -#CP = copy - -# For cross compiling use e.g. -# make CROSS=x86_64-w64-mingw32- clean GC-inlined -CROSS = - -AR = $(CROSS)ar -DLLTOOL = $(CROSS)dlltool -CC = $(CROSS)gcc -CXX = $(CROSS)g++ -RANLIB = $(CROSS)ranlib -RC = $(CROSS)windres - -OPT = $(CLEANUP) -O3 # -finline-functions -findirect-inlining -XOPT = - -RCFLAGS = --include-dir=. -# Uncomment this if config.h defines RETAIN_WSALASTERROR -#LFLAGS = -lws2_32 - -# ---------------------------------------------------------------------- -# The library can be built with some alternative behaviour to -# facilitate development of applications on Win32 that will be ported -# to other POSIX systems. Nothing definable here will make the library -# non-compliant, but applications that make assumptions that POSIX -# does not garrantee may fail or misbehave under 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. -# Pthreads-win32 provides pseudo-unique IDs when the default increment -# (1) is used, but pthread_t is not a scalar type like Solaris's. -# -# Usage: -# Set to any value in the range: 0 <= value <= 2^wordsize -# -# Examples: -# Set to 0 to emulate non recycle-unique behaviour like Linux or *BSD. -# Set to 1 for recycle-unique thread IDs (this is the default). -# Set to some other +ve value to emulate smaller word size types -# (i.e. will wrap sooner). -# -#PTW32_FLAGS = "-DPTW32_THREAD_ID_REUSE_INCREMENT=0" -# -# ---------------------------------------------------------------------- - -GC_CFLAGS = $(PTW32_FLAGS) -GCE_CFLAGS = $(PTW32_FLAGS) -mthreads - -## Mingw -MAKE ?= make -CFLAGS = $(OPT) $(XOPT) -I. -DHAVE_PTW32_CONFIG_H -Wall - -DLL_INLINED_OBJS = \ - pthread.o \ - version.o - -# Agregate modules for inlinability -DLL_OBJS = \ - attr.o \ - barrier.o \ - cancel.o \ - cleanup.o \ - condvar.o \ - create.o \ - dll.o \ - errno.o \ - exit.o \ - fork.o \ - global.o \ - misc.o \ - mutex.o \ - nonportable.o \ - private.o \ - rwlock.o \ - sched.o \ - semaphore.o \ - signal.o \ - spin.o \ - sync.o \ - tsd.o \ - version.o - -# Separate modules for minimum size statically linked images -SMALL_STATIC_OBJS = \ - pthread_attr_init.o \ - pthread_attr_destroy.o \ - pthread_attr_getdetachstate.o \ - pthread_attr_setdetachstate.o \ - pthread_attr_getstackaddr.o \ - pthread_attr_setstackaddr.o \ - pthread_attr_getstacksize.o \ - pthread_attr_setstacksize.o \ - pthread_attr_getscope.o \ - pthread_attr_setscope.o \ - pthread_attr_setschedpolicy.o \ - pthread_attr_getschedpolicy.o \ - pthread_attr_setschedparam.o \ - pthread_attr_getschedparam.o \ - pthread_attr_setinheritsched.o \ - pthread_attr_getinheritsched.o \ - pthread_barrier_init.o \ - pthread_barrier_destroy.o \ - pthread_barrier_wait.o \ - pthread_barrierattr_init.o \ - pthread_barrierattr_destroy.o \ - pthread_barrierattr_setpshared.o \ - pthread_barrierattr_getpshared.o \ - pthread_setcancelstate.o \ - pthread_setcanceltype.o \ - pthread_testcancel.o \ - pthread_cancel.o \ - cleanup.o \ - pthread_condattr_destroy.o \ - pthread_condattr_getpshared.o \ - pthread_condattr_init.o \ - pthread_condattr_setpshared.o \ - pthread_cond_destroy.o \ - pthread_cond_init.o \ - pthread_cond_signal.o \ - pthread_cond_wait.o \ - create.o \ - dll.o \ - autostatic.o \ - errno.o \ - pthread_exit.o \ - fork.o \ - global.o \ - pthread_mutex_init.o \ - pthread_mutex_destroy.o \ - pthread_mutexattr_init.o \ - pthread_mutexattr_destroy.o \ - pthread_mutexattr_getpshared.o \ - pthread_mutexattr_setpshared.o \ - pthread_mutexattr_settype.o \ - pthread_mutexattr_gettype.o \ - pthread_mutexattr_setrobust.o \ - pthread_mutexattr_getrobust.o \ - pthread_mutex_lock.o \ - pthread_mutex_timedlock.o \ - pthread_mutex_unlock.o \ - pthread_mutex_trylock.o \ - pthread_mutex_consistent.o \ - pthread_mutexattr_setkind_np.o \ - pthread_mutexattr_getkind_np.o \ - pthread_getw32threadhandle_np.o \ - pthread_getunique_np.o \ - pthread_delay_np.o \ - pthread_num_processors_np.o \ - pthread_win32_attach_detach_np.o \ - pthread_equal.o \ - pthread_getconcurrency.o \ - pthread_once.o \ - pthread_self.o \ - pthread_setconcurrency.o \ - pthread_rwlock_init.o \ - pthread_rwlock_destroy.o \ - pthread_rwlockattr_init.o \ - pthread_rwlockattr_destroy.o \ - pthread_rwlockattr_getpshared.o \ - pthread_rwlockattr_setpshared.o \ - pthread_rwlock_rdlock.o \ - pthread_rwlock_wrlock.o \ - pthread_rwlock_unlock.o \ - pthread_rwlock_tryrdlock.o \ - pthread_rwlock_trywrlock.o \ - pthread_setschedparam.o \ - pthread_getschedparam.o \ - pthread_timechange_handler_np.o \ - ptw32_is_attr.o \ - ptw32_cond_check_need_init.o \ - ptw32_MCS_lock.o \ - ptw32_mutex_check_need_init.o \ - ptw32_processInitialize.o \ - ptw32_processTerminate.o \ - ptw32_threadStart.o \ - ptw32_threadDestroy.o \ - ptw32_tkAssocCreate.o \ - ptw32_tkAssocDestroy.o \ - ptw32_callUserDestroyRoutines.o \ - ptw32_timespec.o \ - ptw32_throw.o \ - ptw32_getprocessors.o \ - ptw32_calloc.o \ - ptw32_new.o \ - ptw32_reuse.o \ - ptw32_semwait.o \ - ptw32_relmillisecs.o \ - ptw32_rwlock_check_need_init.o \ - sched_get_priority_max.o \ - sched_get_priority_min.o \ - sched_setscheduler.o \ - sched_getscheduler.o \ - sched_yield.o \ - sem_init.o \ - sem_destroy.o \ - sem_trywait.o \ - sem_timedwait.o \ - sem_wait.o \ - sem_post.o \ - sem_post_multiple.o \ - sem_getvalue.o \ - sem_open.o \ - sem_close.o \ - sem_unlink.o \ - signal.o \ - pthread_kill.o \ - ptw32_spinlock_check_need_init.o \ - pthread_spin_init.o \ - pthread_spin_destroy.o \ - pthread_spin_lock.o \ - pthread_spin_unlock.o \ - pthread_spin_trylock.o \ - pthread_detach.o \ - pthread_join.o \ - pthread_key_create.o \ - pthread_key_delete.o \ - pthread_setspecific.o \ - pthread_getspecific.o \ - w32_CancelableWait.o \ - version.o - -INCL = \ - config.h \ - implement.h \ - semaphore.h \ - pthread.h \ - need_errno.h - -ATTR_SRCS = \ - pthread_attr_init.c \ - pthread_attr_destroy.c \ - pthread_attr_getdetachstate.c \ - pthread_attr_setdetachstate.c \ - pthread_attr_getstackaddr.c \ - pthread_attr_setstackaddr.c \ - pthread_attr_getstacksize.c \ - pthread_attr_setstacksize.c \ - pthread_attr_getscope.c \ - pthread_attr_setscope.c - -BARRIER_SRCS = \ - pthread_barrier_init.c \ - pthread_barrier_destroy.c \ - pthread_barrier_wait.c \ - pthread_barrierattr_init.c \ - pthread_barrierattr_destroy.c \ - pthread_barrierattr_setpshared.c \ - pthread_barrierattr_getpshared.c - -CANCEL_SRCS = \ - pthread_setcancelstate.c \ - pthread_setcanceltype.c \ - pthread_testcancel.c \ - pthread_cancel.c - -CONDVAR_SRCS = \ - ptw32_cond_check_need_init.c \ - pthread_condattr_destroy.c \ - pthread_condattr_getpshared.c \ - pthread_condattr_init.c \ - pthread_condattr_setpshared.c \ - pthread_cond_destroy.c \ - pthread_cond_init.c \ - pthread_cond_signal.c \ - pthread_cond_wait.c - -EXIT_SRCS = \ - pthread_exit.c - -MISC_SRCS = \ - pthread_equal.c \ - pthread_getconcurrency.c \ - pthread_kill.c \ - pthread_once.c \ - pthread_self.c \ - pthread_setconcurrency.c \ - ptw32_calloc.c \ - ptw32_MCS_lock.c \ - ptw32_new.c \ - ptw32_reuse.c \ - w32_CancelableWait.c - -MUTEX_SRCS = \ - ptw32_mutex_check_need_init.c \ - pthread_mutex_init.c \ - pthread_mutex_destroy.c \ - pthread_mutexattr_init.c \ - pthread_mutexattr_destroy.c \ - pthread_mutexattr_getpshared.c \ - pthread_mutexattr_setpshared.c \ - pthread_mutexattr_settype.c \ - pthread_mutexattr_gettype.c \ - pthread_mutexattr_setrobust.c \ - pthread_mutexattr_getrobust.c \ - pthread_mutex_lock.c \ - pthread_mutex_timedlock.c \ - pthread_mutex_unlock.c \ - pthread_mutex_trylock.c \ - pthread_mutex_consistent.c - -NONPORTABLE_SRCS = \ - pthread_mutexattr_setkind_np.c \ - pthread_mutexattr_getkind_np.c \ - pthread_getw32threadhandle_np.c \ - pthread_getunique_np.c \ - pthread_delay_np.c \ - pthread_num_processors_np.c \ - pthread_win32_attach_detach_np.c \ - pthread_timechange_handler_np.c - -PRIVATE_SRCS = \ - ptw32_is_attr.c \ - ptw32_processInitialize.c \ - ptw32_processTerminate.c \ - ptw32_threadStart.c \ - ptw32_threadDestroy.c \ - ptw32_tkAssocCreate.c \ - ptw32_tkAssocDestroy.c \ - ptw32_callUserDestroyRoutines.c \ - ptw32_semwait.c \ - ptw32_relmillisecs.c \ - ptw32_timespec.c \ - ptw32_throw.c \ - ptw32_getprocessors.c - -RWLOCK_SRCS = \ - ptw32_rwlock_check_need_init.c \ - ptw32_rwlock_cancelwrwait.c \ - pthread_rwlock_init.c \ - pthread_rwlock_destroy.c \ - pthread_rwlockattr_init.c \ - pthread_rwlockattr_destroy.c \ - pthread_rwlockattr_getpshared.c \ - pthread_rwlockattr_setpshared.c \ - pthread_rwlock_rdlock.c \ - pthread_rwlock_timedrdlock.c \ - pthread_rwlock_wrlock.c \ - pthread_rwlock_timedwrlock.c \ - pthread_rwlock_unlock.c \ - pthread_rwlock_tryrdlock.c \ - pthread_rwlock_trywrlock.c - -SCHED_SRCS = \ - pthread_attr_setschedpolicy.c \ - pthread_attr_getschedpolicy.c \ - pthread_attr_setschedparam.c \ - pthread_attr_getschedparam.c \ - pthread_attr_setinheritsched.c \ - pthread_attr_getinheritsched.c \ - pthread_setschedparam.c \ - pthread_getschedparam.c \ - sched_get_priority_max.c \ - sched_get_priority_min.c \ - sched_setscheduler.c \ - sched_getscheduler.c \ - sched_yield.c - -SEMAPHORE_SRCS = \ - sem_init.c \ - sem_destroy.c \ - sem_trywait.c \ - sem_timedwait.c \ - sem_wait.c \ - sem_post.c \ - sem_post_multiple.c \ - sem_getvalue.c \ - sem_open.c \ - sem_close.c \ - sem_unlink.c - -SPIN_SRCS = \ - ptw32_spinlock_check_need_init.c \ - pthread_spin_init.c \ - pthread_spin_destroy.c \ - pthread_spin_lock.c \ - pthread_spin_unlock.c \ - pthread_spin_trylock.c - -SYNC_SRCS = \ - pthread_detach.c \ - pthread_join.c - -TSD_SRCS = \ - pthread_key_create.c \ - pthread_key_delete.c \ - pthread_setspecific.c \ - pthread_getspecific.c - - -GCE_DLL = pthreadGCE$(DLL_VER).dll -GCED_DLL= pthreadGCE$(DLL_VERD).dll -GCE_LIB = libpthreadGCE$(DLL_VER).a -GCED_LIB= libpthreadGCE$(DLL_VERD).a -GCE_INLINED_STAMP = pthreadGCE$(DLL_VER).stamp -GCED_INLINED_STAMP = pthreadGCE$(DLL_VERD).stamp -GCE_STATIC_STAMP = libpthreadGCE$(DLL_VER).stamp -GCED_STATIC_STAMP = libpthreadGCE$(DLL_VERD).stamp - -GC_DLL = pthreadGC$(DLL_VER).dll -GCD_DLL = pthreadGC$(DLL_VERD).dll -GC_LIB = libpthreadGC$(DLL_VER).a -GCD_LIB = libpthreadGC$(DLL_VERD).a -GC_INLINED_STAMP = pthreadGC$(DLL_VER).stamp -GCD_INLINED_STAMP = pthreadGC$(DLL_VERD).stamp -GC_STATIC_STAMP = libpthreadGC$(DLL_VER).stamp -GCD_STATIC_STAMP = libpthreadGC$(DLL_VERD).stamp - -PTHREAD_DEF = pthread.def - -help: - @ echo "Run one of the following command lines:" - @ echo "make clean GC (to build the GNU C dll with C cleanup code)" - @ echo "make clean GCE (to build the GNU C dll with C++ exception handling)" - @ echo "make clean GC-inlined (to build the GNU C inlined dll with C cleanup code)" - @ echo "make clean GCE-inlined (to build the GNU C inlined dll with C++ exception handling)" - @ echo "make clean GC-static (to build the GNU C inlined static lib with C cleanup code)" - @ echo "make clean GC-debug (to build the GNU C debug dll with C cleanup code)" - @ echo "make clean GCE-debug (to build the GNU C debug dll with C++ exception handling)" - @ echo "make clean GC-inlined-debug (to build the GNU C inlined debug dll with C cleanup code)" - @ echo "make clean GCE-inlined-debug (to build the GNU C inlined debug dll with C++ exception handling)" - @ echo "make clean GC-static-debug (to build the GNU C inlined static debug lib with C cleanup code)" - -all: - @ $(MAKE) clean GCE - @ $(MAKE) clean GC - -GC: - $(MAKE) CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_OBJS)" $(GC_DLL) - -GC-debug: - $(MAKE) CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCD_DLL) - -GCE: - $(MAKE) CC=$(CXX) CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_OBJS)" $(GCE_DLL) - -GCE-debug: - $(MAKE) CC=$(CXX) CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_CXX -g -O0" $(GCED_DLL) - -GC-inlined: - $(MAKE) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" $(GC_INLINED_STAMP) - -GC-inlined-debug: - $(MAKE) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCD_INLINED_STAMP) - -GCE-inlined: - $(MAKE) CC=$(CXX) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" $(GCE_INLINED_STAMP) - -GCE-inlined-debug: - $(MAKE) CC=$(CXX) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_CXX -g -O0" $(GCED_INLINED_STAMP) - -GC-static: - $(MAKE) XOPT="-DPTW32_BUILD_INLINED -DPTW32_STATIC_LIB" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" $(GC_STATIC_STAMP) - -GC-static-debug: - $(MAKE) XOPT="-DPTW32_BUILD_INLINED -DPTW32_STATIC_LIB" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCD_STATIC_STAMP) - -tests: - @ cd tests - @ $(MAKE) auto - -%.pre: %.c - $(CC) -E -o $@ $(CFLAGS) $^ - -%.s: %.c - $(CC) -c $(CFLAGS) -DPTW32_BUILD_INLINED -Wa,-ahl $^ > $@ - -%.o: %.rc - $(RC) $(RCFLAGS) $(CLEANUP) -o $@ -i $< - -.SUFFIXES: .dll .rc .c .o - -.c.o:; $(CC) -c -o $@ $(CFLAGS) $(XC_FLAGS) $< - - -$(GC_DLL) $(GCD_DLL): $(DLL_OBJS) - $(CC) $(OPT) -shared -o $(GC_DLL) $(DLL_OBJS) $(LFLAGS) - $(DLLTOOL) -z pthread.def $(DLL_OBJS) - $(DLLTOOL) -k --dllname $@ --output-lib $(GC_LIB) --def $(PTHREAD_DEF) - -$(GCE_DLL): $(DLL_OBJS) - $(CC) $(OPT) -mthreads -shared -o $(GCE_DLL) $(DLL_OBJS) $(LFLAGS) - $(DLLTOOL) -z pthread.def $(DLL_OBJS) - $(DLLTOOL) -k --dllname $@ --output-lib $(GCE_LIB) --def $(PTHREAD_DEF) - -$(GC_INLINED_STAMP) $(GCD_INLINED_STAMP): $(DLL_INLINED_OBJS) - $(CC) $(OPT) $(XOPT) -shared -o $(GC_DLL) $(DLL_INLINED_OBJS) $(LFLAGS) - $(DLLTOOL) -z pthread.def $(DLL_INLINED_OBJS) - $(DLLTOOL) -k --dllname $(GC_DLL) --output-lib $(GC_LIB) --def $(PTHREAD_DEF) - echo touched > $(GC_INLINED_STAMP) - -$(GCE_INLINED_STAMP) $(GCED_INLINED_STAMP): $(DLL_INLINED_OBJS) - $(CC) $(OPT) $(XOPT) -mthreads -shared -o $(GCE_DLL) $(DLL_INLINED_OBJS) $(LFLAGS) - $(DLLTOOL) -z pthread.def $(DLL_INLINED_OBJS) - $(DLLTOOL) -k --dllname $(GCE_DLL) --output-lib $(GCE_LIB) --def $(PTHREAD_DEF) - echo touched > $(GCE_INLINED_STAMP) - -$(GC_STATIC_STAMP) $(GCD_STATIC_STAMP): $(DLL_INLINED_OBJS) - $(RM) $(GC_LIB) - $(AR) -rv $(GC_LIB) $(DLL_INLINED_OBJS) - $(RANLIB) $(GC_LIB) - echo touched > $(GC_STATIC_STAMP) - -clean: - -$(RM) *~ - -$(RM) *.i - -$(RM) *.s - -$(RM) *.o - -$(RM) *.obj - -$(RM) *.exe - -$(RM) $(PTHREAD_DEF) - -realclean: clean - -$(RM) $(GC_LIB) - -$(RM) $(GCE_LIB) - -$(RM) $(GC_DLL) - -$(RM) $(GCE_DLL) - -$(RM) $(GC_INLINED_STAMP) - -$(RM) $(GCE_INLINED_STAMP) - -$(RM) $(GC_STATIC_STAMP) - -$(RM) $(GCD_LIB) - -$(RM) $(GCED_LIB) - -$(RM) $(GCD_DLL) - -$(RM) $(GCED_DLL) - -$(RM) $(GCD_INLINED_STAMP) - -$(RM) $(GCED_INLINED_STAMP) - -$(RM) $(GCD_STATIC_STAMP) - -attr.o: attr.c $(ATTR_SRCS) $(INCL) -barrier.o: barrier.c $(BARRIER_SRCS) $(INCL) -cancel.o: cancel.c $(CANCEL_SRCS) $(INCL) -condvar.o: condvar.c $(CONDVAR_SRCS) $(INCL) -exit.o: exit.c $(EXIT_SRCS) $(INCL) -misc.o: misc.c $(MISC_SRCS) $(INCL) -mutex.o: mutex.c $(MUTEX_SRCS) $(INCL) -nonportable.o: nonportable.c $(NONPORTABLE_SRCS) $(INCL) -private.o: private.c $(PRIVATE_SRCS) $(INCL) -rwlock.o: rwlock.c $(RWLOCK_SRCS) $(INCL) -sched.o: sched.c $(SCHED_SRCS) $(INCL) -semaphore.o: semaphore.c $(SEMAPHORE_SRCS) $(INCL) -spin.o: spin.c $(SPIN_SRCS) $(INCL) -sync.o: sync.c $(SYNC_SRCS) $(INCL) -tsd.o: tsd.c $(TSD_SRCS) $(INCL) -version.o: version.rc $(INCL) diff --git a/deps/w32-pthreads/MAINTAINERS b/deps/w32-pthreads/MAINTAINERS deleted file mode 100644 index d253c1f..0000000 --- a/deps/w32-pthreads/MAINTAINERS +++ /dev/null @@ -1,4 +0,0 @@ -CVS Repository maintainers - -Ross Johnson rpj@ise.canberra.edu.au -Ben Elliston bje@cygnus.com diff --git a/deps/w32-pthreads/Makefile b/deps/w32-pthreads/Makefile deleted file mode 100644 index 472969c..0000000 --- a/deps/w32-pthreads/Makefile +++ /dev/null @@ -1,514 +0,0 @@ -# This makefile is compatible with MS nmake and can be used as a -# replacement for buildlib.bat. I've changed the target from an ordinary dll -# (/LD) to a debugging dll (/LDd). -# -# The variables $DLLDEST and $LIBDEST hold the destination directories for the -# dll and the lib, respectively. Probably all that needs to change is $DEVROOT. - - -# DLL_VER: -# See pthread.h and README - This number is computed as 'current - age' -DLL_VER = 2 -DLL_VERD= $(DLL_VER)d - -DEVROOT = C:\pthreads - -DLLDEST = $(DEVROOT)\dll -LIBDEST = $(DEVROOT)\lib -HDRDEST = $(DEVROOT)\include - -DLLS = pthreadVCE$(DLL_VER).dll pthreadVSE$(DLL_VER).dll pthreadVC$(DLL_VER).dll \ - pthreadVCE$(DLL_VERD).dll pthreadVSE$(DLL_VERD).dll pthreadVC$(DLL_VERD).dll -INLINED_STAMPS = pthreadVCE$(DLL_VER).stamp pthreadVSE$(DLL_VER).stamp pthreadVC$(DLL_VER).stamp \ - pthreadVCE$(DLL_VERD).stamp pthreadVSE$(DLL_VERD).stamp pthreadVC$(DLL_VERD).stamp -STATIC_STAMPS = pthreadVCE$(DLL_VER).static pthreadVSE$(DLL_VER).static pthreadVC$(DLL_VER).static \ - pthreadVCE$(DLL_VERD).static pthreadVSE$(DLL_VERD).static pthreadVC$(DLL_VERD).static - -CC = cl -CPPFLAGS = /I. /DHAVE_PTW32_CONFIG_H -XCFLAGS = /W3 /MD /nologo -CFLAGS = /O2 /Ob2 $(XCFLAGS) -CFLAGSD = /Z7 $(XCFLAGS) - -# Uncomment this if config.h defines RETAIN_WSALASTERROR -#XLIBS = wsock32.lib - -# Default cleanup style -CLEANUP = __CLEANUP_C - -# C++ Exceptions -VCEFLAGS = /EHsc /TP $(CPPFLAGS) $(CFLAGS) -VCEFLAGSD = /EHsc /TP $(CPPFLAGS) $(CFLAGSD) -#Structured Exceptions -VSEFLAGS = $(CPPFLAGS) $(CFLAGS) -VSEFLAGSD = $(CPPFLAGS) $(CFLAGSD) -#C cleanup code -VCFLAGS = $(CPPFLAGS) $(CFLAGS) -VCFLAGSD = $(CPPFLAGS) $(CFLAGSD) - -DLL_INLINED_OBJS = \ - pthread.obj \ - version.res - -# Aggregate modules for inlinability -DLL_OBJS = \ - attr.obj \ - barrier.obj \ - cancel.obj \ - cleanup.obj \ - condvar.obj \ - create.obj \ - dll.obj \ - autostatic.obj \ - errno.obj \ - exit.obj \ - fork.obj \ - global.obj \ - misc.obj \ - mutex.obj \ - nonportable.obj \ - private.obj \ - rwlock.obj \ - sched.obj \ - semaphore.obj \ - signal.obj \ - spin.obj \ - sync.obj \ - tsd.obj \ - version.res - -# Separate modules for minimising the size of statically linked images -SMALL_STATIC_OBJS = \ - pthread_attr_init.obj \ - pthread_attr_destroy.obj \ - pthread_attr_getdetachstate.obj \ - pthread_attr_setdetachstate.obj \ - pthread_attr_getstackaddr.obj \ - pthread_attr_setstackaddr.obj \ - pthread_attr_getstacksize.obj \ - pthread_attr_setstacksize.obj \ - pthread_attr_getscope.obj \ - pthread_attr_setscope.obj \ - pthread_attr_setschedpolicy.obj \ - pthread_attr_getschedpolicy.obj \ - pthread_attr_setschedparam.obj \ - pthread_attr_getschedparam.obj \ - pthread_attr_setinheritsched.obj \ - pthread_attr_getinheritsched.obj \ - pthread_barrier_init.obj \ - pthread_barrier_destroy.obj \ - pthread_barrier_wait.obj \ - pthread_barrierattr_init.obj \ - pthread_barrierattr_destroy.obj \ - pthread_barrierattr_setpshared.obj \ - pthread_barrierattr_getpshared.obj \ - pthread_setcancelstate.obj \ - pthread_setcanceltype.obj \ - pthread_testcancel.obj \ - pthread_cancel.obj \ - cleanup.obj \ - pthread_condattr_destroy.obj \ - pthread_condattr_getpshared.obj \ - pthread_condattr_init.obj \ - pthread_condattr_setpshared.obj \ - pthread_cond_destroy.obj \ - pthread_cond_init.obj \ - pthread_cond_signal.obj \ - pthread_cond_wait.obj \ - create.obj \ - dll.obj \ - autostatic.obj \ - errno.obj \ - pthread_exit.obj \ - fork.obj \ - global.obj \ - pthread_mutex_init.obj \ - pthread_mutex_destroy.obj \ - pthread_mutexattr_init.obj \ - pthread_mutexattr_destroy.obj \ - pthread_mutexattr_getpshared.obj \ - pthread_mutexattr_setpshared.obj \ - pthread_mutexattr_settype.obj \ - pthread_mutexattr_gettype.obj \ - pthread_mutexattr_setrobust.obj \ - pthread_mutexattr_getrobust.obj \ - pthread_mutex_lock.obj \ - pthread_mutex_timedlock.obj \ - pthread_mutex_unlock.obj \ - pthread_mutex_trylock.obj \ - pthread_mutex_consistent.obj \ - pthread_mutexattr_setkind_np.obj \ - pthread_mutexattr_getkind_np.obj \ - pthread_getw32threadhandle_np.obj \ - pthread_getunique_np.obj \ - pthread_delay_np.obj \ - pthread_num_processors_np.obj \ - pthread_win32_attach_detach_np.obj \ - pthread_equal.obj \ - pthread_getconcurrency.obj \ - pthread_once.obj \ - pthread_self.obj \ - pthread_setconcurrency.obj \ - pthread_rwlock_init.obj \ - pthread_rwlock_destroy.obj \ - pthread_rwlockattr_init.obj \ - pthread_rwlockattr_destroy.obj \ - pthread_rwlockattr_getpshared.obj \ - pthread_rwlockattr_setpshared.obj \ - pthread_rwlock_rdlock.obj \ - pthread_rwlock_wrlock.obj \ - pthread_rwlock_unlock.obj \ - pthread_rwlock_tryrdlock.obj \ - pthread_rwlock_trywrlock.obj \ - pthread_setschedparam.obj \ - pthread_getschedparam.obj \ - pthread_timechange_handler_np.obj \ - ptw32_is_attr.obj \ - ptw32_processInitialize.obj \ - ptw32_processTerminate.obj \ - ptw32_threadStart.obj \ - ptw32_threadDestroy.obj \ - ptw32_tkAssocCreate.obj \ - ptw32_tkAssocDestroy.obj \ - ptw32_callUserDestroyRoutines.obj \ - ptw32_timespec.obj \ - ptw32_throw.obj \ - ptw32_getprocessors.obj \ - ptw32_calloc.obj \ - ptw32_new.obj \ - ptw32_reuse.obj \ - ptw32_rwlock_check_need_init.obj \ - ptw32_cond_check_need_init.obj \ - ptw32_mutex_check_need_init.obj \ - ptw32_semwait.obj \ - ptw32_relmillisecs.obj \ - ptw32_MCS_lock.obj \ - sched_get_priority_max.obj \ - sched_get_priority_min.obj \ - sched_setscheduler.obj \ - sched_getscheduler.obj \ - sched_yield.obj \ - sem_init.obj \ - sem_destroy.obj \ - sem_trywait.obj \ - sem_timedwait.obj \ - sem_wait.obj \ - sem_post.obj \ - sem_post_multiple.obj \ - sem_getvalue.obj \ - sem_open.obj \ - sem_close.obj \ - sem_unlink.obj \ - signal.obj \ - pthread_kill.obj \ - ptw32_spinlock_check_need_init.obj \ - pthread_spin_init.obj \ - pthread_spin_destroy.obj \ - pthread_spin_lock.obj \ - pthread_spin_unlock.obj \ - pthread_spin_trylock.obj \ - pthread_detach.obj \ - pthread_join.obj \ - pthread_key_create.obj \ - pthread_key_delete.obj \ - pthread_setspecific.obj \ - pthread_getspecific.obj \ - w32_CancelableWait.obj \ - version.res - -INCL = config.h implement.h semaphore.h pthread.h need_errno.h - -ATTR_SRCS = \ - pthread_attr_init.c \ - pthread_attr_destroy.c \ - pthread_attr_getdetachstate.c \ - pthread_attr_setdetachstate.c \ - pthread_attr_getstackaddr.c \ - pthread_attr_setstackaddr.c \ - pthread_attr_getstacksize.c \ - pthread_attr_setstacksize.c \ - pthread_attr_getscope.c \ - pthread_attr_setscope.c - -BARRIER_SRCS = \ - pthread_barrier_init.c \ - pthread_barrier_destroy.c \ - pthread_barrier_wait.c \ - pthread_barrierattr_init.c \ - pthread_barrierattr_destroy.c \ - pthread_barrierattr_setpshared.c \ - pthread_barrierattr_getpshared.c - -CANCEL_SRCS = \ - pthread_setcancelstate.c \ - pthread_setcanceltype.c \ - pthread_testcancel.c \ - pthread_cancel.c - -CONDVAR_SRCS = \ - ptw32_cond_check_need_init.c \ - pthread_condattr_destroy.c \ - pthread_condattr_getpshared.c \ - pthread_condattr_init.c \ - pthread_condattr_setpshared.c \ - pthread_cond_destroy.c \ - pthread_cond_init.c \ - pthread_cond_signal.c \ - pthread_cond_wait.c - -EXIT_SRCS = \ - pthread_exit.c - -MISC_SRCS = \ - pthread_equal.c \ - pthread_getconcurrency.c \ - pthread_kill.c \ - pthread_once.c \ - pthread_self.c \ - pthread_setconcurrency.c \ - ptw32_calloc.c \ - ptw32_MCS_lock.c \ - ptw32_new.c \ - ptw32_reuse.c \ - ptw32_relmillisecs.c \ - w32_CancelableWait.c - -MUTEX_SRCS = \ - ptw32_mutex_check_need_init.c \ - pthread_mutex_init.c \ - pthread_mutex_destroy.c \ - pthread_mutexattr_init.c \ - pthread_mutexattr_destroy.c \ - pthread_mutexattr_getpshared.c \ - pthread_mutexattr_setpshared.c \ - pthread_mutexattr_settype.c \ - pthread_mutexattr_gettype.c \ - pthread_mutexattr_setrobust.c \ - pthread_mutexattr_getrobust.c \ - pthread_mutex_lock.c \ - pthread_mutex_timedlock.c \ - pthread_mutex_unlock.c \ - pthread_mutex_trylock.c \ - pthread_mutex_consistent.c - -NONPORTABLE_SRCS = \ - pthread_mutexattr_setkind_np.c \ - pthread_mutexattr_getkind_np.c \ - pthread_getw32threadhandle_np.c \ - pthread_getunique_np.c \ - pthread_delay_np.c \ - pthread_num_processors_np.c \ - pthread_win32_attach_detach_np.c \ - pthread_timechange_handler_np.c - -PRIVATE_SRCS = \ - ptw32_is_attr.c \ - ptw32_processInitialize.c \ - ptw32_processTerminate.c \ - ptw32_threadStart.c \ - ptw32_threadDestroy.c \ - ptw32_tkAssocCreate.c \ - ptw32_tkAssocDestroy.c \ - ptw32_callUserDestroyRoutines.c \ - ptw32_semwait.c \ - ptw32_timespec.c \ - ptw32_throw.c \ - ptw32_getprocessors.c - -RWLOCK_SRCS = \ - ptw32_rwlock_check_need_init.c \ - ptw32_rwlock_cancelwrwait.c \ - pthread_rwlock_init.c \ - pthread_rwlock_destroy.c \ - pthread_rwlockattr_init.c \ - pthread_rwlockattr_destroy.c \ - pthread_rwlockattr_getpshared.c \ - pthread_rwlockattr_setpshared.c \ - pthread_rwlock_rdlock.c \ - pthread_rwlock_timedrdlock.c \ - pthread_rwlock_wrlock.c \ - pthread_rwlock_timedwrlock.c \ - pthread_rwlock_unlock.c \ - pthread_rwlock_tryrdlock.c \ - pthread_rwlock_trywrlock.c - -SCHED_SRCS = \ - pthread_attr_setschedpolicy.c \ - pthread_attr_getschedpolicy.c \ - pthread_attr_setschedparam.c \ - pthread_attr_getschedparam.c \ - pthread_attr_setinheritsched.c \ - pthread_attr_getinheritsched.c \ - pthread_setschedparam.c \ - pthread_getschedparam.c \ - sched_get_priority_max.c \ - sched_get_priority_min.c \ - sched_setscheduler.c \ - sched_getscheduler.c \ - sched_yield.c - -SEMAPHORE_SRCS = \ - sem_init.c \ - sem_destroy.c \ - sem_trywait.c \ - sem_timedwait.c \ - sem_wait.c \ - sem_post.c \ - sem_post_multiple.c \ - sem_getvalue.c \ - sem_open.c \ - sem_close.c \ - sem_unlink.c - -SPIN_SRCS = \ - ptw32_spinlock_check_need_init.c \ - pthread_spin_init.c \ - pthread_spin_destroy.c \ - pthread_spin_lock.c \ - pthread_spin_unlock.c \ - pthread_spin_trylock.c - -SYNC_SRCS = \ - pthread_detach.c \ - pthread_join.c - -TSD_SRCS = \ - pthread_key_create.c \ - pthread_key_delete.c \ - pthread_setspecific.c \ - pthread_getspecific.c - - -help: - @ echo Run one of the following command lines: - @ echo nmake clean VCE (to build the MSVC dll with C++ exception handling) - @ echo nmake clean VSE (to build the MSVC dll with structured exception handling) - @ echo nmake clean VC (to build the MSVC dll with C cleanup code) - @ echo nmake clean VCE-inlined (to build the MSVC inlined dll with C++ exception handling) - @ echo nmake clean VSE-inlined (to build the MSVC inlined dll with structured exception handling) - @ echo nmake clean VC-inlined (to build the MSVC inlined dll with C cleanup code) - @ echo nmake clean VC-static (to build the MSVC static lib with C cleanup code) - @ echo nmake clean VCE-debug (to build the debug MSVC dll with C++ exception handling) - @ echo nmake clean VSE-debug (to build the debug MSVC dll with structured exception handling) - @ echo nmake clean VC-debug (to build the debug MSVC dll with C cleanup code) - @ echo nmake clean VCE-inlined-debug (to build the debug MSVC inlined dll with C++ exception handling) - @ echo nmake clean VSE-inlined-debug (to build the debug MSVC inlined dll with structured exception handling) - @ echo nmake clean VC-inlined-debug (to build the debug MSVC inlined dll with C cleanup code) - @ echo nmake clean VC-static-debug (to build the debug MSVC static lib with C cleanup code) - -all: - @ $(MAKE) /E clean VCE-inlined - @ $(MAKE) /E clean VSE-inlined - @ $(MAKE) /E clean VC-inlined - @ $(MAKE) /E clean VCE-inlined-debug - @ $(MAKE) /E clean VSE-inlined-debug - @ $(MAKE) /E clean VC-inlined-debug - -VCE: - @ $(MAKE) /E /nologo EHFLAGS="$(VCEFLAGS)" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VER).dll - -VCE-debug: - @ $(MAKE) /E /nologo EHFLAGS="$(VCEFLAGSD)" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VERD).dll - -VSE: - @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGS)" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VER).dll - -VSE-debug: - @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGSD)" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VERD).dll - -VC: - @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGS)" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).dll - -VC-debug: - @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGSD)" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).dll - -# -# The so-called inlined DLL is just a single translation unit with -# inlining optimisation turned on. -# -VCE-inlined: - @ $(MAKE) /E /nologo EHFLAGS="$(VCEFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VER).stamp - -VCE-inlined-debug: - @ $(MAKE) /E /nologo EHFLAGS="$(VCEFLAGSD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_CXX pthreadVCE$(DLL_VERD).stamp - -VSE-inlined: - @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VER).stamp - -VSE-inlined-debug: - @ $(MAKE) /E /nologo EHFLAGS="$(VSEFLAGSD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_SEH pthreadVSE$(DLL_VERD).stamp - -VC-inlined: - @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).stamp - -VC-inlined-debug: - @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGSD) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).stamp - -VC-static: - @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGS) /DPTW32_BUILD_INLINED /DPTW32_STATIC_LIB" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).static - -VC-static-debug: - @ $(MAKE) /E /nologo EHFLAGS="$(VCFLAGSD) /DPTW32_BUILD_INLINED /DPTW32_STATIC_LIB" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VERD).static - -realclean: clean - if exist pthread*.dll del pthread*.dll - if exist pthread*.lib del pthread*.lib - if exist *.manifest del *.manifest - if exist *.stamp del *.stamp - -clean: - if exist *.obj del *.obj - if exist *.def del *.def - if exist *.ilk del *.ilk - if exist *.pdb del *.pdb - if exist *.exp del *.exp - if exist *.map del *.map - if exist *.o del *.o - if exist *.i del *.i - if exist *.res del *.res - - -install: - copy pthread*.dll $(DLLDEST) - copy pthread*.lib $(LIBDEST) - copy pthread.h $(HDRDEST) - copy sched.h $(HDRDEST) - copy semaphore.h $(HDRDEST) - -$(DLLS): $(DLL_OBJS) - $(CC) /LDd /Zi /nologo $(DLL_OBJS) /link /implib:$*.lib $(XLIBS) /out:$@ - -$(INLINED_STAMPS): $(DLL_INLINED_OBJS) - $(CC) /LDd /Zi /nologo $(DLL_INLINED_OBJS) /link /implib:$*.lib $(XLIBS) /out:$*.dll - -$(STATIC_STAMPS): $(DLL_INLINED_OBJS) - if exist $*.lib del $*.lib - lib $(DLL_INLINED_OBJS) /out:$*.lib - -.c.obj: - $(CC) $(EHFLAGS) /D$(CLEANUP) -c $< - -# TARGET_CPU is an environment variable set by Visual Studio Command Prompt -# as provided by the SDK -.rc.res: - rc /dPTW32_ARCH$(TARGET_CPU) /dPTW32_RC_MSC /d$(CLEANUP) $< - -.c.i: - $(CC) /P /O2 /Ob1 $(VCFLAGS) $< - -attr.obj: attr.c $(ATTR_SRCS) $(INCL) -barrier.obj: barrier.c $(BARRIER_SRCS) $(INCL) -cancel.obj: cancel.c $(CANCEL_SRCS) $(INCL) -condvar.obj: condvar.c $(CONDVAR_SRCS) $(INCL) -exit.obj: exit.c $(EXIT_SRCS) $(INCL) -misc.obj: misc.c $(MISC_SRCS) $(INCL) -mutex.obj: mutex.c $(MUTEX_SRCS) $(INCL) -nonportable.obj: nonportable.c $(NONPORTABLE_SRCS) $(INCL) -private.obj: private.c $(PRIVATE_SRCS) $(INCL) -rwlock.obj: rwlock.c $(RWLOCK_SRCS) $(INCL) -sched.obj: sched.c $(SCHED_SRCS) $(INCL) -semaphore.obj: semaphore.c $(SEMAPHORE_SRCS) $(INCL) -spin.obj: spin.c $(SPIN_SRCS) $(INCL) -sync.obj: sync.c $(SYNC_SRCS) $(INCL) -tsd.obj: tsd.c $(TSD_SRCS) $(INCL) -version.res: version.rc $(INCL) diff --git a/deps/w32-pthreads/NEWS b/deps/w32-pthreads/NEWS deleted file mode 100644 index d1b7896..0000000 --- a/deps/w32-pthreads/NEWS +++ /dev/null @@ -1,1241 +0,0 @@ -RELEASE 2.9.0 -------------- -(2012-05-25) - -General -------- -New bug fixes in this release since 2.8.0 have NOT been applied to the -1.x.x series. - -Some changes post 2011-02-26 in CVS may not be compatible with pre -Windows 2000 systems. - -Use of other than the "C" version of the library is now discouraged. -That is, the "C++" version fails some tests and does not provide any -additional functionality. - -Testing and verification ------------------------- -This version has been tested on SMP architecture (Intel x64 Hex Core) -by completing the included test suite, stress and bench tests. - -New Features ------------- -DLL properties now properly includes the target architecture, i.e. -right-click on the file pthreadVC2.dll in explorer and choose the Detail -tab will show the compiler and architecture in the description field, e.g. -"MS C x64" or "MS C x86". -- Ross Johnson - -(MSC and GNU builds) The statically linked library now automatically -initialises and cleans up on program start/exit, i.e. statically linked -applications need not call the routines pthread_win32_process_attach_np() -and pthread_win32_process_detach_np() explicitly. The per-thread routine -pthread_win32_thread_detach_np() is also called at program exit to cleanup -POSIX resources acquired by the primary Windows native thread, if I (RJ) -understand the process correctly. Other Windows native threads that call -POSIX API routines may need to call the thread detach routine on thread -exit if the application depends on reclaimed POSIX resources or running -POSIX TSD (TLS) destructors. -See README.NONPORTABLE for descriptions of these routines. -- Ramiro Polla - -Robust mutexes are implemented within the PROCESS_PRIVATE scope. NOTE that -pthread_mutex_* functions may return different error codes for robust -mutexes than they otherwise do in normal usage, e.g. pthread_mutex_unlock -is required to check ownership for all mutex types when the mutex is -robust, whereas this does not occur for the "normal" non-robust mutex type. -- Ross Johnson - -pthread_getunique_np is implemented for source level compatibility -with some other implementations. This routine returns a 64 bit -sequence number that is uniquely associated with a thread. It can be -used by applications to order or hash POSIX thread handles. -- Ross Johnson - -Bug fixes ---------- -Many more changes for 64 bit systems. -- Kai Tietz - -Various modifications and fixes to build and test for WinCE. -- Marcel Ruff, Sinan Kaya - -Fix pthread_cond_destroy() - should not be a cancellation point. Other -minor build problems fixed. -- Romano Paolo Tenca - -Remove potential deadlock condition from pthread_cond_destroy(). -- Eric Berge - -Various modifications to build and test for Win64. -- Kip Streithorst - -Various fixes to the QueueUserAPCEx async cancellation helper DLL -(this is a separate download) and pthreads code cleanups. -- Sebastian Gottschalk - -Removed potential NULL pointer reference. -- Robert Kindred - -Removed the requirement that applications restrict the number of threads -calling pthread_barrier_wait to just the barrier count. Also reduced the -contention between barrier_wait and barrier_destroy. This change will have -slowed barriers down slightly but halves the number of semaphores consumed -per barrier to one. -- Ross Johnson - -Fixed a handle leak in sched_[gs]etscheduler. -- Mark Pizzolato - -Removed all of the POSIX re-entrant function compatibility macros from pthread.h. -Some were simply not semanticly correct. -- Igor Lubashev - -Threads no longer attempt to pass uncaught exceptions out of thread scope (C++ -and SEH builds only). Uncaught exceptions now cause the thread to exit with -the return code PTHREAD_CANCELED. -- Ross Johnson - -Lots of casting fixes particularly for x64, Interlocked fixes and reworking -for x64. -- Daniel Richard G., John Kamp - -Other changes -------------- -Dependence on the winsock library is now discretionary via -#define RETAIN_WSALASTERROR in config.h. It is undefined by default unless -WINCE is defined (because RJ is unsure of the dependency there). -- Ramiro Polla - -Several static POSIX mutexes used for internal management were replaced by -MCS queue-based locks to reduce resource consumption, in particular use of Win32 -objects. -- Ross Johnson - -For security, the QuserEx.dll if used must now be installed in the Windows System -folder. -- Ross Johnson - -New tests ---------- -robust[1-5].c - Robust mutexes -sequence1.c - per-thread unique sequence numbers - -Modified tests and benchtests ------------------------------ -All mutex*.c tests wherever appropriate have been modified to also test -robust mutexes under the same conditions. -Added robust mutex benchtests to benchtest*.c wherever appropriate. - - -RELEASE 2.8.0 -------------- -(2006-12-22) - -General -------- -New bug fixes in this release since 2.7.0 have not been applied to the -version 1.x.x series. It is probably time to drop version 1. - -Testing and verification ------------------------- -This release has not yet been tested on SMP architechtures. All tests pass -on a uni-processor system. - -Bug fixes ---------- -Sem_destroy could return EBUSY even though no threads were waiting on the -semaphore. Other races around invalidating semaphore structs (internally) -have been removed as well. - -New tests ---------- -semaphore5.c - tests the bug fix referred to above. - - -RELEASE 2.7.0 -------------- -(2005-06-04) - -General -------- -All new features in this release have been back-ported in release 1.11.0, -including the incorporation of MCS locks in pthread_once, however, versions -1 and 2 remain incompatible even though they are now identical in -performance and functionality. - -Testing and verification ------------------------- -This release has been tested (passed the test suite) on both uni-processor -and multi-processor systems. -- Tim Theisen - -Bug fixes ---------- -Pthread_once has been re-implemented to remove priority boosting and other -complexity to improve robustness. Races for Win32 handles that are not -recycle-unique have been removed. The general form of pthread_once is now -the same as that suggested earlier by Alexander Terekhov, but instead of the -'named mutex', a queue-based lock has been implemented which has the required -properties of dynamic self initialisation and destruction. This lock is also -efficient. The ABI is unaffected in as much as the size of pthread_once_t has -not changed and PTHREAD_ONCE_INIT has not changed, however, applications that -peek inside pthread_once_t, which is supposed to be opaque, will break. -- Vladimir Kliatchko - -New features ------------- -* Support for Mingw cross development tools added to GNUmakefile. -Mingw cross tools allow building the libraries on Linux. -- Mikael Magnusson - - -RELEASE 2.6.0 -------------- -(2005-05-19) - -General -------- -All of the bug fixes and new features in this release have been -back-ported in release 1.10.0. - -Testing and verification ------------------------- -This release has been tested (passed the test suite) on both uni-processor -and multi-processor systems. Thanks to Tim Theisen at TomoTherapy for -exhaustively running the MP tests and for providing crutial observations -and data when faults are detected. - -Bugs fixed ----------- - -* pthread_detach() now reclaims remaining thread resources if called after -the target thread has terminated. Previously, this routine did nothing in -this case. - -New tests ---------- - -* detach1.c - tests that pthread_detach properly invalidates the target -thread, which indicates that the thread resources have been reclaimed. - - -RELEASE 2.5.0 -------------- -(2005-05-09) - -General -------- - -The package now includes a reference documentation set consisting of -HTML formatted Unix-style manual pages that have been edited for -consistency with Pthreads-w32. The set can also be read online at: -http://sources.redhat.com/pthreads-win32/manual/index.html - -Thanks again to Tim Theisen for running the test suite pre-release -on an MP system. - -All of the bug fixes and new features in this release have been -back-ported in release 1.9.0. - -Bugs fixed ----------- - -* Thread Specific Data (TSD) key management has been ammended to -eliminate a source of (what was effectively) resource leakage (a HANDLE -plus memory for each key destruct routine/thread association). This was -not a true leak because these resources were eventually reclaimed when -pthread_key_delete was run AND each thread referencing the key had exited. -The problem was that these two conditions are often not met until very -late, and often not until the process is about to exit. - -The ammended implementation avoids the need for the problematic HANDLE -and reclaims the memory as soon as either the key is deleted OR the -thread exits, whichever is first. - -Thanks to Richard Hughes at Aculab for identifying and locating the leak. - -* TSD key destructors are now processed up to PTHREAD_DESTRUCTOR_ITERATIONS -times instead of just once. PTHREAD_DESTRUCTOR_ITERATIONS has been -defined in pthread.h for some time but not used. - -* Fix a semaphore accounting race between sem_post/sem_post_multiple -and sem_wait cancellation. This is the same issue as with -sem_timedwait that was fixed in the last release. - -* sem_init, sem_post, and sem_post_multiple now check that the -semaphore count never exceeds _POSIX_SEM_VALUE_MAX. - -* Although sigwait() is nothing more than a no-op, it should at least -be a cancellation point to be consistent with the standard. - -New tests ---------- - -* stress1.c - attempts to expose problems in condition variable -and semaphore timed wait logic. This test was inspired by Stephan -Mueller's sample test code used to identify the sem_timedwait bug -from the last release. It's not a part of the regular test suite -because it can take awhile to run. To run it: -nmake clean VC-stress - -* tsd2.c - tests that key destructors are re-run if the tsd key value is -not NULL after the destructor routine has run. Also tests that -pthread_setspecific() and pthread_getspecific() are callable from -destructors. - - -RELEASE 2.4.0 -------------- -(2005-04-26) - -General -------- - -There is now no plan to release a version 3.0.0 to fix problems in -pthread_once(). Other possible implementations of pthread_once -will still be investigated for a possible future release in an attempt -to reduce the current implementation's complexity. - -All of the bug fixes and new features in this release have been -back-ported for release 1.8.0. - -Bugs fixed ----------- - -* Fixed pthread_once race (failures on an MP system). Thanks to -Tim Theisen for running exhaustive pre-release testing on his MP system -using a range of compilers: - VC++ 6 - VC++ 7.1 - Intel C++ version 8.0 -All tests passed. -Some minor speed improvements were also done. - -* Fix integer overrun error in pthread_mutex_timedlock() - missed when -sem_timedwait() was fixed in release 2.2.0. This routine no longer returns -ENOTSUP when NEED_SEM is defined - it is supported (NEED_SEM is only -required for WinCE versions prior to 3.0). - -* Fix timeout bug in sem_timedwait(). -- Thanks to Stephan Mueller for reporting, providing diagnostic output -and test code. - -* Fix several problems in the NEED_SEM conditionally included code. -NEED_SEM included code is provided for systems that don't implement W32 -semaphores, such as WinCE prior to version 3.0. An alternate implementation -of POSIX semaphores is built using W32 events for these systems when -NEED_SEM is defined. This code has been completely rewritten in this -release to reuse most of the default POSIX semaphore code, and particularly, -to implement all of the sem_* routines supported by pthreads-win32. Tim -Theisen also run the test suite over the NEED_SEM code on his MP system. All -tests passed. - -* The library now builds without errors for the Borland Builder 5.5 compiler. - -New features ------------- - -* pthread_mutex_timedlock() and all sem_* routines provided by -pthreads-win32 are now implemented for WinCE versions prior to 3.0. Those -versions did not implement W32 semaphores. Define NEED_SEM in config.h when -building the library for these systems. - -Known issues in this release ----------------------------- - -* pthread_once is too complicated - but it works as far as testing can -determine.. - -* The Borland version of the dll fails some of the tests with a memory read -exception. The cause is not yet known but a compiler bug has not been ruled -out. - - -RELEASE 2.3.0 -------------- -(2005-04-12) - -General -------- - -Release 1.7.0 is a backport of features and bug fixes new in -this release. See earlier notes under Release 2.0.0/General. - -Bugs fixed ----------- - -* Fixed pthread_once potential for post once_routine cancellation -hanging due to starvation. See comments in pthread_once.c. -Momentary priority boosting is used to ensure that, after a -once_routine is cancelled, the thread that will run the -once_routine is not starved by higher priority waiting threads at -critical times. Priority boosting occurs only AFTER a once_routine -cancellation, and is applied only to that once_control. The -once_routine is run at the thread's normal base priority. - -New tests ---------- - -* once4.c: Aggressively tests pthread_once() under realtime -conditions using threads with varying priorities. Windows' -random priority boosting does not occur for threads with realtime -priority levels. - - -RELEASE 2.2.0 -------------- -(2005-04-04) - -General -------- - -* Added makefile targets to build static link versions of the library. -Both MinGW and MSVC. Please note that this does not imply any change -to the LGPL licensing, which still imposes psecific conditions on -distributing software that has been statically linked with this library. - -* There is a known bug in pthread_once(). Cancellation of the init_routine -exposes a potential starvation (i.e. deadlock) problem if a waiting thread -has a higher priority than the initting thread. This problem will be fixed -in version 3.0.0 of the library. - -Bugs fixed ----------- - -* Fix integer overrun error in sem_timedwait(). -Kevin Lussier - -* Fix preprocessor directives for static linking. -Dimitar Panayotov - - -RELEASE 2.1.0 -------------- -(2005-03-16) - -Bugs fixed ----------- - -* Reverse change to pthread_setcancelstate() in 2.0.0. - - -RELEASE 2.0.0 -------------- -(2005-03-16) - -General -------- - -This release represents an ABI change and the DLL version naming has -incremented from 1 to 2, e.g. pthreadVC2.dll. - -Version 1.4.0 back-ports the new functionality included in this -release. Please distribute DLLs built from that version with updates -to applications built on pthreads-win32 version 1.x.x. - -The package naming has changed, replacing the snapshot date with -the version number + descriptive information. E.g. this -release is "pthreads-w32-2-0-0-release". - -Bugs fixed ----------- - -* pthread_setcancelstate() no longer checks for a pending -async cancel event if the library is using alertable async -cancel. See the README file (Prerequisites section) for info -on adding alertable async cancelation. - -New features ------------- - -* pthread_once() now supports init_routine cancellability. - -New tests ---------- - -* Agressively test pthread_once() init_routine cancellability. - - -SNAPSHOT 2005-03-08 -------------------- -Version 1.3.0 - -Bug reports (fixed) -------------------- - -* Implicitly created threads leave Win32 handles behind after exiting. -- Dmitrii Semii - -* pthread_once() starvation problem. -- Gottlob Frege - -New tests ---------- - -* More intense testing of pthread_once(). - - -SNAPSHOT 2005-01-25 -------------------- -Version 1.2.0 - -Bug fixes ---------- - -* Attempted acquisition of a recursive mutex could cause waiting threads -to not be woken when the mutex was released. -- Ralf Kubis - -* Various package omissions have been fixed. - - -SNAPSHOT 2005-01-03 -------------------- -Version 1.1.0 - -Bug fixes ---------- - -* Unlocking recursive or errorcheck mutexes would sometimes -unexpectedly return an EPERM error (bug introduced in -snapshot-2004-11-03). -- Konstantin Voronkov - - -SNAPSHOT 2004-11-22 -------------------- -Version 1.0.0 - -This snapshot primarily fixes the condvar bug introduced in -snapshot-2004-11-03. DLL versioning has also been included to allow -applications to runtime check the Microsoft compatible DLL version -information, and to extend the DLL naming system for ABI and major -(non-backward compatible) API changes. See the README file for details. - -Bug fixes ---------- - -* Condition variables no longer deadlock (bug introduced in -snapshot-2004-11-03). -- Alexander Kotliarov and Nicolas at saintmac - -* DLL naming extended to avoid 'DLL hell' in the future, and to -accommodate the ABI change introduced in snapshot-2004-11-03. Snapshot -2004-11-03 will be removed from FTP sites. - -New features ------------- - -* A Microsoft-style version resource has been added to the DLL for -applications that wish to check DLL compatibility at runtime. - -* Pthreads-win32 DLL naming has been extended to allow incompatible DLL -versions to co-exist in the same filesystem. See the README file for details, -but briefly: while the version information inside the DLL will change with -each release from now on, the DLL version names will only change if the new -DLL is not backward compatible with older applications. - -The versioning scheme has been borrowed from GNU Libtool, and the DLL -naming scheme is from Cygwin. Provided the Libtool-style numbering rules are -honoured, the Cygwin DLL naming scheme automatcally ensures that DLL name -changes are minimal and that applications will not load an incompatible -pthreads-win32 DLL. - -Those who use the pre-built DLLs will find that the DLL/LIB names have a new -suffix (1) in this snapshot. E.g. pthreadVC1.dll etc. - -* The POSIX thread ID reuse uniqueness feature introduced in the last snapshot -has been kept as default, but the behaviour can now be controlled when the DLL -is built to effectively switch it off. This makes the library much more -sensitive to applications that assume that POSIX thread IDs are unique, i.e. -are not strictly compliant with POSIX. See the PTW32_THREAD_ID_REUSE_INCREMENT -macro comments in config.h for details. - -Other changes -------------- -Certain POSIX macros have changed. - -These changes are intended to conform to the Single Unix Specification version 3, -which states that, if set to 0 (zero) or not defined, then applications may use -sysconf() to determine their values at runtime. Pthreads-win32 does not -implement sysconf(). - -The following macros are no longer undefined, but defined and set to -1 -(not implemented): - - _POSIX_THREAD_ATTR_STACKADDR - _POSIX_THREAD_PRIO_INHERIT - _POSIX_THREAD_PRIO_PROTECT - _POSIX_THREAD_PROCESS_SHARED - -The following macros are defined and set to 200112L (implemented): - - _POSIX_THREADS - _POSIX_THREAD_SAFE_FUNCTIONS - _POSIX_THREAD_ATTR_STACKSIZE - _POSIX_THREAD_PRIORITY_SCHEDULING - _POSIX_SEMAPHORES - _POSIX_READER_WRITER_LOCKS - _POSIX_SPIN_LOCKS - _POSIX_BARRIERS - -The following macros are defined and set to appropriate values: - - _POSIX_THREAD_THREADS_MAX - _POSIX_SEM_VALUE_MAX - _POSIX_SEM_NSEMS_MAX - PTHREAD_DESTRUCTOR_ITERATIONS - PTHREAD_KEYS_MAX - PTHREAD_STACK_MIN - PTHREAD_THREADS_MAX - - -SNAPSHOT 2004-11-03 -------------------- - -DLLs produced from this snapshot cannot be used with older applications without -recompiling the application, due to a change to pthread_t to provide unique POSIX -thread IDs. - -Although this snapshot passes the extended test suite, many of the changes are -fairly major, and some applications may show different behaviour than previously, -so adopt with care. Hopefully, any changed behaviour will be due to the library -being better at it's job, not worse. - -Bug fixes ---------- - -* pthread_create() no longer accepts NULL as the thread reference arg. -A segfault (memory access fault) will result, and no thread will be -created. - -* pthread_barrier_wait() no longer acts as a cancelation point. - -* Fix potential race condition in pthread_once() -- Tristan Savatier - -* Changes to pthread_cond_destroy() exposed some coding weaknesses in several -test suite mini-apps because pthread_cond_destroy() now returns EBUSY if the CV -is still in use. - -New features ------------- - -* Added for compatibility: -PTHREAD_RECURSIVE_MUTEX_INITIALIZER, -PTHREAD_ERRORCHECK_MUTEX_INITIALIZER, -PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, -PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP - -* Initial support for Digital Mars compiler -- Anuj Goyal - -* Faster Mutexes. These have been been rewritten following a model provided by -Alexander Terekhov that reduces kernel space checks, and eliminates some additional -critical sections used to manage a race between timedlock expiration and unlock. -Please be aware that the new mutexes do not enforce strict absolute FIFO scheduling -of mutexes, however any out-of-order lock acquisition should be very rare. - -* Faster semaphores. Following a similar model to mutexes above, these have been -rewritten to use preliminary users space checks. - -* sem_getvalue() now returns the number of waiters. - -* The POSIX thread ID now has much stronger uniqueness characteristics. The library -garrantees not to reuse the same thread ID for at least 2^(wordsize) thread -destruction/creation cycles. - -New tests ---------- - -* semaphore4.c: Tests cancelation of the new sem_wait(). - -* semaphore4t.c: Likewise for sem_timedwait(). - -* rwlock8.c: Tests and times the slow execution paths of r/w locks, and the CVs, -mutexes, and semaphores that they're built on. - - -SNAPSHOT 2004-05-16 -------------------- - -Attempt to add Watcom to the list of compilers that can build the library. -This failed in the end due to it's non-thread-aware errno. The library -builds but the test suite fails. See README.Watcom for more details. - -Bug fixes ---------- -* Bug and memory leak in sem_init() -- Alex Blanco - -* ptw32_getprocessors() now returns CPU count of 1 for WinCE. -- James Ewing - -* pthread_cond_wait() could be canceled at a point where it should not -be cancelable. Fixed. -- Alexander Terekhov - -* sem_timedwait() had an incorrect timeout calculation. -- Philippe Di Cristo - -* Fix a memory leak left behind after threads are destroyed. -- P. van Bruggen - -New features ------------- -* Ported to AMD64. -- Makoto Kato - -* True pre-emptive asynchronous cancelation of threads. This is optional -and requires that Panagiotis E. Hadjidoukas's QueueUserAPCEx package be -installed. This package is included in the pthreads-win32 self-unpacking -Zip archive starting from this snapshot. See the README.txt file inside -the package for installation details. - -Note: If you don't use async cancelation in your application, or don't need -to cancel threads that are blocked on system resources such as network I/O, -then the default non-preemptive async cancelation is probably good enough. -However, pthreads-win32 auto-detects the availability of these components -at run-time, so you don't need to rebuild the library from source if you -change your mind later. - -All of the advice available in books and elsewhere on the undesirability -of using async cancelation in any application still stands, but this -feature is a welcome addition with respect to the library's conformance to -the POSIX standard. - -SNAPSHOT 2003-09-18 -------------------- - -Cleanup of thread priority management. In particular, setting of thread -priority now attempts to map invalid Win32 values within the range returned -by sched_get_priority_min/max() to useful values. See README.NONPORTABLE -under "Thread priority". - -Bug fixes ---------- -* pthread_getschedparam() now returns the priority given by the most recent -call to pthread_setschedparam() or established by pthread_create(), as -required by the standard. Previously, pthread_getschedparam() incorrectly -returned the running thread priority at the time of the call, which may have -been adjusted or temporarily promoted/demoted. - -* sched_get_priority_min() and sched_get_priority_max() now return -1 on error -and set errno. Previously, they incorrectly returned the error value directly. - - -SNAPSHOT 2003-09-04 -------------------- - -Bug fixes ---------- -* ptw32_cancelableWait() now allows cancelation of waiting implicit POSIX -threads. - -New test --------- -* cancel8.c tests cancelation of Win32 threads waiting at a POSIX cancelation -point. - - -SNAPSHOT 2003-09-03 -------------------- - -Bug fixes ---------- -* pthread_self() would free the newly created implicit POSIX thread handle if -DuplicateHandle failed instead of recycle it (very unlikely). - -* pthread_exit() was neither freeing nor recycling the POSIX thread struct -for implicit POSIX threads. - -New feature - Cancelation of/by Win32 (non-POSIX) threads ---------------------------------------------------------- -Since John Bossom's original implementation, the library has allowed non-POSIX -initialised threads (Win32 threads) to call pthreads-win32 routines and -therefore interact with POSIX threads. This is done by creating an on-the-fly -POSIX thread ID for the Win32 thread that, once created, allows fully -reciprical interaction. This did not extend to thread cancelation (async or -deferred). Now it does. - -Any thread can be canceled by any other thread (Win32 or POSIX) if the former -thread's POSIX pthread_t value is known. It's TSD destructors and POSIX -cleanup handlers will be run before the thread exits with an exit code of -PTHREAD_CANCELED (retrieved with GetExitCodeThread()). - -This allows a Win32 thread to, for example, call POSIX CV routines in the same way -that POSIX threads would/should, with pthread_cond_wait() cancelability and -cleanup handlers (pthread_cond_wait() is a POSIX cancelation point). - -By adding cancelation, Win32 threads should now be able to call all POSIX -threads routines that make sense including semaphores, mutexes, condition -variables, read/write locks, barriers, spinlocks, tsd, cleanup push/pop, -cancelation, pthread_exit, scheduling, etc. - -Note that these on-the-fly 'implicit' POSIX thread IDs are initialised as detached -(not joinable) with deferred cancelation type. The POSIX thread ID will be created -automatically by any POSIX routines that need a POSIX handle (unless the routine -needs a pthread_t as a parameter of course). A Win32 thread can discover it's own -POSIX thread ID by calling pthread_self(), which will create the handle if -necessary and return the pthread_t value. - -New tests ---------- -Test the above new feature. - - -SNAPSHOT 2003-08-19 -------------------- - -This snapshot fixes some accidental corruption to new test case sources. -There are no changes to the library source code. - - -SNAPSHOT 2003-08-15 -------------------- - -Bug fixes ---------- - -* pthread.dsp now uses correct compile flags (/MD). -- Viv - -* pthread_win32_process_detach_np() fixed memory leak. -- Steven Reddie - -* pthread_mutex_destroy() fixed incorrect return code. -- Nicolas Barry - -* pthread_spin_destroy() fixed memory leak. -- Piet van Bruggen - -* Various changes to tighten arg checking, and to work with later versions of -MinGW32 and MsysDTK. - -* pthread_getschedparam() etc, fixed dangerous thread validity checking. -- Nicolas Barry - -* POSIX thread handles are now reused and their memory is not freed on thread exit. -This allows for stronger thread validity checking. - -New standard routine --------------------- - -* pthread_kill() added to provide thread validity checking to applications. -It does not accept any non zero values for the signal arg. - -New test cases --------------- - -* New test cases to confirm validity checking, pthread_kill(), and thread reuse. - - -SNAPSHOT 2003-05-10 -------------------- - -Bug fixes ---------- - -* pthread_mutex_trylock() now returns correct error values. -pthread_mutex_destroy() will no longer destroy a recursively locked mutex. -pthread_mutex_lock() is no longer inadvertantly behaving as a cancelation point. -- Thomas Pfaff - -* pthread_mutex_timedlock() no longer occasionally sets incorrect mutex -ownership, causing deadlocks in some applications. -- Robert Strycek and Alexander Terekhov - - -SNAPSHOT 2002-11-04 -------------------- - -Bug fixes ---------- - -* sem_getvalue() now returns the correct value under Win NT and WinCE. -- Rob Fanner - -* sem_timedwait() now uses tighter checks for unreasonable -abstime values - that would result in unexpected timeout values. - -* ptw32_cond_wait_cleanup() no longer mysteriously consumes -CV signals but may produce more spurious wakeups. It is believed -that the sem_timedwait() call is consuming a CV signal that it -shouldn't. -- Alexander Terekhov - -* Fixed a memory leak in ptw32_threadDestroy() for implicit threads. - -* Fixed potential for deadlock in pthread_cond_destroy(). -A deadlock could occur for statically declared CVs (PTHREAD_COND_INITIALIZER), -when one thread is attempting to destroy the condition variable while another -is attempting to dynamically initialize it. -- Michael Johnson - - -SNAPSHOT 2002-03-02 -------------------- - -Cleanup code default style. (IMPORTANT) ----------------------------------------------------------------------- -Previously, if not defined, the cleanup style was determined automatically -from the compiler/language, and one of the following was defined accordingly: - - __CLEANUP_SEH MSVC only - __CLEANUP_CXX C++, including MSVC++, GNU G++ - __CLEANUP_C C, including GNU GCC, not MSVC - -These defines determine the style of cleanup (see pthread.h) and, -most importantly, the way that cancelation and thread exit (via -pthread_exit) is performed (see the routine ptw32_throw() in private.c). - -In short, the exceptions versions of the library throw an exception -when a thread is canceled or exits (via pthread_exit()), which is -caught by a handler in the thread startup routine, so that the -the correct stack unwinding occurs regardless of where the thread -is when it's canceled or exits via pthread_exit(). - -In this and future snapshots, unless the build explicitly defines (e.g. -via a compiler option) __CLEANUP_SEH, __CLEANUP_CXX, or __CLEANUP_C, then -the build NOW always defaults to __CLEANUP_C style cleanup. This style -uses setjmp/longjmp in the cancelation and pthread_exit implementations, -and therefore won't do stack unwinding even when linked to applications -that have it (e.g. C++ apps). This is for consistency with most -current commercial Unix POSIX threads implementations. Compaq's TRU64 -may be an exception (no pun intended) and possible future trend. - -Although it was not clearly documented before, it is still necessary to -build your application using the same __CLEANUP_* define as was -used for the version of the library that you link with, so that the -correct parts of pthread.h are included. That is, the possible -defines require the following library versions: - - __CLEANUP_SEH pthreadVSE.dll - __CLEANUP_CXX pthreadVCE.dll or pthreadGCE.dll - __CLEANUP_C pthreadVC.dll or pthreadGC.dll - -E.g. regardless of whether your app is C or C++, if you link with -pthreadVC.lib or libpthreadGC.a, then you must define __CLEANUP_C. - - -THE POINT OF ALL THIS IS: if you have not been defining one of these -explicitly, then the defaults as described at the top of this -section were being used. - -THIS NOW CHANGES, as has been explained above, but to try to make this -clearer here's an example: - -If you were building your application with MSVC++ i.e. using C++ -exceptions and not explicitly defining one of __CLEANUP_*, then -__CLEANUP_C++ was automatically defined for you in pthread.h. -You should have been linking with pthreadVCE.dll, which does -stack unwinding. - -If you now build your application as you had before, pthread.h will now -automatically set __CLEANUP_C as the default style, and you will need to -link with pthreadVC.dll. Stack unwinding will now NOT occur when a thread -is canceled, or the thread calls pthread_exit(). - -Your application will now most likely behave differently to previous -versions, and in non-obvious ways. Most likely is that locally -instantiated objects may not be destroyed or cleaned up after a thread -is canceled. - -If you want the same behaviour as before, then you must now define -__CLEANUP_C++ explicitly using a compiler option and link with -pthreadVCE.dll as you did before. - - -WHY ARE WE MAKING THE DEFAULT STYLE LESS EXCEPTION-FRIENDLY? -Because no commercial Unix POSIX threads implementation allows you to -choose to have stack unwinding. Therefore, providing it in pthread-win32 -as a default is dangerous. We still provide the choice but unless -you consciously choose to do otherwise, your pthreads applications will -now run or crash in similar ways irrespective of the threads platform -you use. Or at least this is the hope. - - -WHY NOT REMOVE THE EXCEPTIONS VERSIONS OF THE LIBRARY ALTOGETHER? -There are a few reasons: -- because there are well respected POSIX threads people who believe - that POSIX threads implementations should be exceptions aware and - do the expected thing in that context. (There are equally respected - people who believe it should not be easily accessible, if it's there - at all, for unconditional conformity to other implementations.) -- because pthreads-win32 is one of the few implementations that has - the choice, perhaps the only freely available one, and so offers - a laboratory to people who may want to explore the effects; -- although the code will always be around somewhere for anyone who - wants it, once it's removed from the current version it will not be - nearly as visible to people who may have a use for it. - - -Source module splitting ------------------------ -In order to enable smaller image sizes to be generated -for applications that link statically with the library, -most routines have been separated out into individual -source code files. - -This is being done in such a way as to be backward compatible. -The old source files are reused to congregate the individual -routine files into larger translation units (via a bunch of -# includes) so that the compiler can still optimise wherever -possible, e.g. through inlining, which can only be done -within the same translation unit. - -It is also possible to build the entire library by compiling -the single file named "pthread.c", which just #includes all -the secondary congregation source files. The compiler -may be able to use this to do more inlining of routines. - -Although the GNU compiler is able to produce libraries with -the necessary separation (the -ffunction-segments switch), -AFAIK, the MSVC and other compilers don't have this feature. - -Finally, since I use makefiles and command-line compilation, -I don't know what havoc this reorganisation may wreak amongst -IDE project file users. You should be able to continue -using your existing project files without modification. - - -New non-portable functions --------------------------- -pthread_num_processors_np(): - Returns the number of processors in the system that are - available to the process, as determined from the processor - affinity mask. - -pthread_timechange_handler_np(): - To improve tolerance against operator or time service initiated - system clock changes. - - This routine can be called by an application when it - receives a WM_TIMECHANGE message from the system. At present - it broadcasts all condition variables so that waiting threads - can wake up and re-evaluate their conditions and restart - their timed waits if required. - - Suggested by Alexander Terekhov - - -Platform dependence -------------------- -As Win95 doesn't provide one, the library now contains -it's own InterlockedCompareExchange() routine, which is used -whenever Windows doesn't provide it. InterlockedCompareExchange() -is used to implement spinlocks and barriers, and also in mutexes. -This routine relies on the CMPXCHG machine instruction which -is not available on i386 CPUs. This library (from snapshot -20010712 onwards) is therefore no longer supported on i386 -processor platforms. - - -New standard routines ---------------------- -For source code portability only - rwlocks cannot be process shared yet. - - pthread_rwlockattr_init() - pthread_rwlockattr_destroy() - pthread_rwlockattr_setpshared() - pthread_rwlockattr_getpshared() - -As defined in the new POSIX standard, and the Single Unix Spec version 3: - - sem_timedwait() - pthread_mutex_timedlock() - Alexander Terekhov and Thomas Pfaff - pthread_rwlock_timedrdlock() - adapted from pthread_rwlock_rdlock() - pthread_rwlock_timedwrlock() - adapted from pthread_rwlock_wrlock() - - -pthread.h no longer includes windows.h --------------------------------------- -[Not yet for G++] - -This was done to prevent conflicts. - -HANDLE, DWORD, and NULL are temporarily defined within pthread.h if -they are not already. - - -pthread.h, sched.h and semaphore.h now use dllexport/dllimport --------------------------------------------------------------- -Not only to avoid the need for the pthread.def file, but to -improve performance. Apparently, declaring functions with dllimport -generates a direct call to the function and avoids the overhead -of a stub function call. - -Bug fixes ---------- -* Fixed potential NULL pointer dereferences in pthread_mutexattr_init, -pthread_mutexattr_getpshared, pthread_barrierattr_init, -pthread_barrierattr_getpshared, and pthread_condattr_getpshared. -- Scott McCaskill - -* Removed potential race condition in pthread_mutex_trylock and -pthread_mutex_lock; -- Alexander Terekhov - -* The behaviour of pthread_mutex_trylock in relation to -recursive mutexes was inconsistent with commercial implementations. -Trylock would return EBUSY if the lock was owned already by the -calling thread regardless of mutex type. Trylock now increments the -recursion count and returns 0 for RECURSIVE mutexes, and will -return EDEADLK rather than EBUSY for ERRORCHECK mutexes. This is -consistent with Solaris. -- Thomas Pfaff - -* Found a fix for the library and workaround for applications for -the known bug #2, i.e. where __CLEANUP_CXX or __CLEANUP_SEH is defined. -See the "Known Bugs in this snapshot" section below. - -This could be made transparent to applications by replacing the macros that -define the current C++ and SEH versions of pthread_cleanup_push/pop -with the C version, but AFAIK cleanup handlers would not then run in the -correct sequence with destructors and exception cleanup handlers when -an exception occurs. - -* Cancelation once started in a thread cannot now be inadvertantly -double canceled. That is, once a thread begins it's cancelation run, -cancelation is disabled and a subsequent cancel request will -return an error (ESRCH). - -* errno: An incorrect compiler directive caused a local version -of errno to be used instead of the Win32 errno. Both instances are -thread-safe but applications checking errno after a pthreads-win32 -call would be wrong. Fixing this also fixed a bad compiler -option in the testsuite (/MT should have been /MD) which is -needed to link with the correct library MSVCRT.LIB. - - -SNAPSHOT 2001-07-12 -------------------- - -To be added - - -SNAPSHOT 2001-07-03 -------------------- - -To be added - - -SNAPSHOT 2000-08-13 -------------------- - -New: -- Renamed DLL and LIB files: - pthreadVSE.dll (MS VC++/Structured EH) - pthreadVSE.lib - pthreadVCE.dll (MS VC++/C++ EH) - pthreadVCE.lib - pthreadGCE.dll (GNU G++/C++ EH) - libpthreadw32.a - - Both your application and the pthread dll should use the - same exception handling scheme. - -Bugs fixed: -- MSVC++ C++ exception handling. - -Some new tests have been added. - - -SNAPSHOT 2000-08-10 -------------------- - -New: -- asynchronous cancelation on X86 (Jason Nye) -- Makefile compatible with MS nmake to replace - buildlib.bat -- GNUmakefile for Mingw32 -- tests/Makefile for MS nmake replaces runall.bat -- tests/GNUmakefile for Mingw32 - -Bugs fixed: -- kernel32 load/free problem -- attempt to hide internel exceptions from application - exception handlers (__try/__except and try/catch blocks) -- Win32 thread handle leakage bug - (David Baggett/Paul Redondo/Eyal Lebedinsky) - -Some new tests have been added. - - -SNAPSHOT 1999-11-02 -------------------- - -Bugs fixed: -- ctime_r macro had an incorrect argument (Erik Hensema), -- threads were not being created - PTHREAD_CANCEL_DEFERRED. This should have - had little effect as deferred is the only - supported type. (Ross Johnson). - -Some compatibility improvements added, eg. -- pthread_setcancelstate accepts NULL pointer - for the previous value argument. Ditto for - pthread_setcanceltype. This is compatible - with Solaris but should not affect - standard applications (Erik Hensema) - -Some new tests have been added. - - -SNAPSHOT 1999-10-17 -------------------- - -Bug fix - Cancelation of threads waiting on condition variables -now works properly (Lorin Hochstein and Peter Slacik) - - -SNAPSHOT 1999-08-12 -------------------- - -Fixed exception stack cleanup if calling pthread_exit() -- (Lorin Hochstein and John Bossom). - -Fixed bugs in condition variables - (Peter Slacik): - - additional contention checks - - properly adjust number of waiting threads after timed - condvar timeout. - - -SNAPSHOT 1999-05-30 -------------------- - -Some minor bugs have been fixed. See the ChangeLog file for details. - -Some more POSIX 1b functions are now included but ony return an -error (ENOSYS) if called. They are: - - sem_open - sem_close - sem_unlink - sem_getvalue - - -SNAPSHOT 1999-04-07 -------------------- - -Some POSIX 1b functions which were internally supported are now -available as exported functions: - - sem_init - sem_destroy - sem_wait - sem_trywait - sem_post - sched_yield - sched_get_priority_min - sched_get_priority_max - -Some minor bugs have been fixed. See the ChangeLog file for details. - - -SNAPSHOT 1999-03-16 -------------------- - -Initial release. - diff --git a/deps/w32-pthreads/Nmakefile b/deps/w32-pthreads/Nmakefile deleted file mode 100644 index d9e5bf1..0000000 --- a/deps/w32-pthreads/Nmakefile +++ /dev/null @@ -1,24 +0,0 @@ -/* - * nmake file for uwin pthread library - */ - -VERSION = - -CCFLAGS = -V -g $(CC.DLL) -HAVE_PTW32_CONFIG_H == 1 -_MT == 1 -_timeb == timeb -_ftime == ftime -_errno == _ast_errno - -$(INCLUDEDIR) :INSTALLDIR: pthread.h sched.h - -pthread $(VERSION) :LIBRARY: attr.c barrier.c cancel.c cleanup.c condvar.c \ - create.c dll.c exit.c fork.c global.c misc.c mutex.c private.c \ - rwlock.c sched.c semaphore.c spin.c sync.c tsd.c nonportable.c - -:: ANNOUNCE CONTRIBUTORS COPYING.LIB ChangeLog FAQ GNUmakefile MAINTAINERS \ - Makefile Makefile.in Makefile.vc NEWS PROGRESS README README.WinCE \ - TODO WinCE-PORT install-sh errno.c tests tests.mk acconfig.h \ - config.guess config.h.in config.sub configure configure.in signal.c \ - README.CV README.NONPORTABLE pthread.dsp pthread.dsw - diff --git a/deps/w32-pthreads/Nmakefile.tests b/deps/w32-pthreads/Nmakefile.tests deleted file mode 100644 index 203560b..0000000 --- a/deps/w32-pthreads/Nmakefile.tests +++ /dev/null @@ -1,260 +0,0 @@ -/* for running tests */ -CCFLAGS = -g -_MT == 1 -_timeb == timeb -_ftime == ftime - -.SOURCE: tests -/* -:PACKAGE: pthread -*/ - -set keepgoing - -":test:" : .MAKE .OPERATOR - local I - $(<:D:B:S=.pass) : .IMPLICIT $(>:D:B:S=.pass) - for I $(<) $(>) - $(I:D:B:S=.pass) : .VIRTUAL .FORCE $(I) - $(>) - end -sizes:: sizes.c -loadfree:: loadfree.c -mutex1:: mutex1.c -mutex1e:: mutex1e.c -mutex1n:: mutex1n.c -mutex1r:: mutex1r.c -mutex2:: mutex2.c -mutex2r:: mutex2r.c -mutex2e:: mutex2e.c -exit1:: exit1.c -condvar1:: condvar1.c -condvar1_1:: condvar1_1.c -condvar1_2:: condvar1_2.c -self1:: self1.c -condvar2:: condvar2.c -condvar2_1:: condvar2_1.c -condvar3_1:: condvar3_1.c -condvar3_2:: condvar3_2.c -condvar3_3:: condvar3_3.c -create1.:: create1.c -create2.:: create2.c -cancel1:: cancel1.c -cancel2:: cancel2.c -mutex3:: mutex3.c -mutex3r:: mutex3r.c -mutex3e:: mutex3e.c -mutex4:: mutex4.c -mutex5:: mutex5.c -mutex6:: mutex6.c -mutex6e:: mutex6e.c -mutex6n:: mutex6n.c -mutex6r:: mutex6r.c -mutex7:: mutex7.c -mutex6s:: mutex6s.c -mutex6rs:: mutex6rs.c -mutex6es:: mutex6es.c -mutex7e:: mutex7e.c -mutex7n:: mutex7n.c -mutex7r:: mutex7r.c -mutex8:: mutex8.c -mutex8e:: mutex8e.c -mutex8n:: mutex8n.c -mutex8r:: mutex8r.c -equal1:: equal1.c -exit2:: exit2.c -exit3:: exit3.c -exit4:: exit4.c -exit5:: exit5.c -join0:: join0.c -join1:: join1.c -join2:: join2.c -join3:: join3.c -kill1:: kill1.c -count1:: count1.c -once1:: once1.c -tsd1:: tsd1.c -self2:: self2.c -eyal1:: eyal1.c -condvar3:: condvar3.c -condvar4:: condvar4.c -condvar5:: condvar5.c -condvar6:: condvar6.c -condvar7:: condvar7.c -condvar8:: condvar8.c -condvar9:: condvar9.c -errno1:: errno1.c -reuse1.:: reuse1.c -reuse2.:: reuse2.c -rwlock1:: rwlock1.c -rwlock2:: rwlock2.c -rwlock3:: rwlock3.c -rwlock4:: rwlock4.c -rwlock5:: rwlock5.c -rwlock6:: rwlock6.c -rwlock7:: rwlock7.c -rwlock8:: rwlock8.c -rwlock2_t:: rwlock2_t.c -rwlock3_t:: rwlock3_t.c -rwlock4_t:: rwlock4_t.c -rwlock5_t:: rwlock5_t.c -rwlock6_t:: rwlock6_t.c -rwlock6_t2:: rwlock6_t2.c -semaphore1:: semaphore1.c -semaphore2:: semaphore2.c -semaphore3:: semaphore3.c -context1:: context1.c -cancel3:: cancel3.c -cancel4:: cancel4.c -cancel5:: cancel5.c -cancel6a:: cancel6a.c -cancel6d:: cancel6d.c -cancel7:: cancel7.c -cleanup0:: cleanup0.c -cleanup1:: cleanup1.c -cleanup2:: cleanup2.c -cleanup3:: cleanup3.c -priority1:: priority1.c -priority2:: priority2.c -inherit1:: inherit1.c -spin1:: spin1.c -spin2:: spin2.c -spin3:: spin3.c -spin4:: spin4.c -barrier1:: barrier1.c -barrier2:: barrier2.c -barrier3:: barrier3.c -barrier4:: barrier4.c -barrier5:: barrier5.c -exception1:: exception1.c -exception2:: exception2.c -exception3:: exception3.c -benchtest1:: benchtest1.c -benchtest2:: benchtest2.c -benchtest3:: benchtest3.c -benchtest4:: benchtest4.c -benchtest5:: benchtest5.c -valid1:: valid1.c -valid2:: valid2.c -cancel9:: cancel9.c - -sizes: :test: sizes -loadfree: :test: -mutex5 :test: loadfree -mutex1 :test: loadfree -mutex1n :test: loadfree -mutex1r :test: loadfree -mutex1e :test: loadfree -semaphore1 :test: loadfree -semaphore2 :test: loadfree -semaphore3 :test: loadfree -mutex2 :test: loadfree -mutex2r :test: loadfree -mutex2e :test: loadfree -exit1 :test: loadfree -condvar1 :test: loadfree -kill1 :test: loadfree -condvar1_1 :test: condvar1 -condvar1_2 :test: join2 -self1 :test: loadfree -condvar2 :test: condvar1 -condvar2_1 :test: condvar2 -create1 :test: mutex2 -create2 :test: create1 -reuse1 :test: create2 -reuse2 :test: reuse1 -cancel1 :test: create1 -cancel2 :test: cancel1 -mutex3 :test: create1 -mutex3r :test: create1 -mutex3e :test: create1 -mutex4 :test: mutex3 -mutex6 :test: mutex4 -mutex6n :test: mutex4 -mutex6e :test: mutex4 -mutex6r :test: mutex4 -mutex6s :test: mutex6 -mutex6rs :test: mutex6r -mutex6es :test: mutex6e -mutex7 :test: mutex6 -mutex7n :test: mutex6n -mutex7e :test: mutex6e -mutex7r :test: mutex6r -mutex8 :test: mutex7 -mutex8n :test: mutex7n -mutex8e :test: mutex7e -mutex8r :test: mutex7r -equal1 :test: create1 -exit2 :test: create1 -exit3 :test: create1 -exit4 :test: kill1 -exit5 :test: exit4 -join0 :test: create1 -join1 :test: create1 -join2 :test: create1 -join3 :test: join2 -count1 :test: join1 -once1 :test: create1 -tsd1 :test: join1 -self2 :test: create1 -eyal1 :test: tsd1 -condvar3 :test: create1 -condvar3_1 :test: condvar3 -condvar3_2 :test: condvar3_1 -condvar3_3 :test: condvar3_2 -condvar4 :test: create1 -condvar5 :test: condvar4 -condvar6 :test: condvar5 -condvar7 :test: condvar6 cleanup1 -condvar8 :test: condvar7 -condvar9 :test: condvar8 -errno1 :test: mutex3 -rwlock1 :test: condvar6 -rwlock2 :test: rwlock1 -rwlock3 :test: rwlock2 -rwlock4 :test: rwlock3 -rwlock5 :test: rwlock4 -rwlock6 :test: rwlock5 -rwlock7 :test: rwlock6 -rwlock8 :test: rwlock7 -rwlock2_t :test: rwlock2 -rwlock3_t :test: rwlock2_t -rwlock4_t :test: rwlock3_t -rwlock5_t :test: rwlock4_t -rwlock6_t :test: rwlock5_t -rwlock6_t2 :test: rwlock6_t -context1 :test: cancel2 -cancel3 :test: context1 -cancel4 :test: cancel3 -cancel5 :test: cancel3 -cancel6a :test: cancel3 -cancel6d :test: cancel3 -cancel7 :test: kill1 -cleanup0 :test: cancel5 -cleanup1 :test: cleanup0 -cleanup2 :test: cleanup1 -cleanup3 :test: cleanup2 -priority1 :test: join1 -priority2 :test: priority1 -inherit1 :test: join1 -spin1 :test: -spin2 :test: spin1.c -spin3 :test: spin2.c -spin4 :test: spin3.c -barrier1 :test: -barrier2 :test: barrier1.c -barrier3 :test: barrier2.c -barrier4 :test: barrier3.c -barrier5 :test: barrier4.c -benchtest1 :test: mutex3 -benchtest2 :test: benchtest1 -benchtest3 :test: benchtest2 -benchtest4 :test: benchtest3 -benchtest5 :test: benchtest4 -exception1 :test: cancel4 -exception2 :test: exception1 -exception3 :test: exception2 -exit4 :test: exit3 -valid1 :test: join1 -valid2 :test: valid1 -cancel9 :test: cancel8 diff --git a/deps/w32-pthreads/PROGRESS b/deps/w32-pthreads/PROGRESS deleted file mode 100644 index 9abf0bc..0000000 --- a/deps/w32-pthreads/PROGRESS +++ /dev/null @@ -1,4 +0,0 @@ -Please see the ANNOUNCE file "Level of Standards Conformance" -or the web page: - -http://sources.redhat.com/pthreads-win32/conformance.html diff --git a/deps/w32-pthreads/README b/deps/w32-pthreads/README deleted file mode 100644 index 545360b..0000000 --- a/deps/w32-pthreads/README +++ /dev/null @@ -1,601 +0,0 @@ -PTHREADS-WIN32 -============== - -Pthreads-win32 is free software, distributed under the GNU Lesser -General Public License (LGPL). See the file 'COPYING.LIB' for terms -and conditions. Also see the file 'COPYING' for information -specific to pthreads-win32, copyrights and the LGPL. - - -What is it? ------------ - -Pthreads-win32 is an Open Source Software implementation of the -Threads component of the POSIX 1003.1c 1995 Standard (or later) -for Microsoft's Win32 environment. Some functions from POSIX -1003.1b are also supported including semaphores. Other related -functions include the set of read-write lock functions. The -library also supports some of the functionality of the Open -Group's Single Unix specification, version 2, namely mutex types, -plus some common and pthreads-win32 specific non-portable -routines (see README.NONPORTABLE). - -See the file "ANNOUNCE" for more information including standards -conformance details and the list of supported and unsupported -routines. - - -Prerequisites -------------- -MSVC or GNU C (MinGW32 MSys development kit) - To build from source. - -QueueUserAPCEx by Panagiotis E. Hadjidoukas - To support any thread cancelation in C++ library builds or - to support cancelation of blocked threads in any build. - This library is not required otherwise. - - For true async cancelation of threads (including blocked threads). - This is a DLL and Windows driver that provides pre-emptive APC - by forcing threads into an alertable state when the APC is queued. - Both the DLL and driver are provided with the pthreads-win32.exe - self-unpacking ZIP, and on the pthreads-win32 FTP site (in source - and pre-built forms). Currently this is a separate LGPL package to - pthreads-win32. See the README in the QueueUserAPCEx folder for - installation instructions. - - Pthreads-win32 will automatically detect if the QueueUserAPCEx DLL - QuserEx.DLL is available and whether the driver AlertDrv.sys is - loaded. If it is not available, pthreads-win32 will simulate async - cancelation, which means that it can async cancel only threads that - are runnable. The simulated async cancellation cannot cancel blocked - threads. - - [FOR SECURITY] To be found Quserex.dll MUST be installed in the - Windows System Folder. This is not an unreasonable constraint given a - driver must also be installed and loaded at system startup. - - -Library naming --------------- - -Because the library is being built using various exception -handling schemes and compilers - and because the library -may not work reliably if these are mixed in an application, -each different version of the library has it's own name. - -Note 1: the incompatibility is really between EH implementations -of the different compilers. It should be possible to use the -standard C version from either compiler with C++ applications -built with a different compiler. If you use an EH version of -the library, then you must use the same compiler for the -application. This is another complication and dependency that -can be avoided by using only the standard C library version. - -Note 2: if you use a standard C pthread*.dll with a C++ -application, then any functions that you define that are -intended to be called via pthread_cleanup_push() must be -__cdecl. - -Note 3: the intention was to also name either the VC or GC -version (it should be arbitrary) as pthread.dll, including -pthread.lib and libpthread.a as appropriate. This is no longer -likely to happen. - -Note 4: the compatibility number was added so that applications -can differentiate between binary incompatible versions of the -libs and dlls. - -In general: - pthread[VG]{SE,CE,C}[c].dll - pthread[VG]{SE,CE,C}[c].lib - -where: - [VG] indicates the compiler - V - MS VC, or - G - GNU C - - {SE,CE,C} indicates the exception handling scheme - SE - Structured EH, or - CE - C++ EH, or - C - no exceptions - uses setjmp/longjmp - - c - DLL compatibility number indicating ABI and API - compatibility with applications built against - a snapshot with the same compatibility number. - See 'Version numbering' below. - -The name may also be suffixed by a 'd' to indicate a debugging version -of the library. E.g. pthreadVC2d.lib. Debugging versions contain -additional information for debugging (symbols etc) and are often not -optimised in any way (compiled with optimisation turned off). - -Examples: - pthreadVSE.dll (MSVC/SEH) - pthreadGCE.dll (GNUC/C++ EH) - pthreadGC.dll (GNUC/not dependent on exceptions) - pthreadVC1.dll (MSVC/not dependent on exceptions - not binary - compatible with pthreadVC.dll) - pthreadVC2.dll (MSVC/not dependent on exceptions - not binary - compatible with pthreadVC1.dll or pthreadVC.dll) - -The GNU library archive file names have correspondingly changed to: - - libpthreadGCEc.a - libpthreadGCc.a - - -Versioning numbering --------------------- - -Version numbering is separate from the snapshot dating system, and -is the canonical version identification system embedded within the -DLL using the Microsoft version resource system. The versioning -system chosen follows the GNU Libtool system. See -http://www.gnu.org/software/libtool/manual.html section 6.2. - -See the resource file 'version.rc'. - -Microsoft version numbers use 4 integers: - - 0.0.0.0 - -Pthreads-win32 uses the first 3 following the Libtool convention. -The fourth is commonly used for the build number, but will be reserved -for future use. - - current.revision.age.0 - -The numbers are changed as follows: - -1. If the library source code has changed at all since the last update, - then increment revision (`c:r:a' becomes `c:r+1:a'). -2. If any interfaces have been added, removed, or changed since the last - update, increment current, and set revision to 0. -3. If any interfaces have been added since the last public release, then - increment age. -4. If any interfaces have been removed or changed since the last public - release, then set age to 0. - - -DLL compatibility numbering is an attempt to ensure that applications -always load a compatible pthreads-win32 DLL by using a DLL naming system -that is consistent with the version numbering system. It also allows -older and newer DLLs to coexist in the same filesystem so that older -applications can continue to be used. For pre .NET Windows systems, -this inevitably requires incompatible versions of the same DLLs to have -different names. - -Pthreads-win32 has adopted the Cygwin convention of appending a single -integer number to the DLL name. The number used is based on the library -version number and is computed as 'current' - 'age'. - -(See http://home.att.net/~perlspinr/libversioning.html for a nicely -detailed explanation.) - -Using this method, DLL name/s will only change when the DLL's -backwards compatibility changes. Note that the addition of new -'interfaces' will not of itself change the DLL's compatibility for older -applications. - - -Which of the several dll versions to use? ------------------------------------------ -or, ---- -What are all these pthread*.dll and pthread*.lib files? -------------------------------------------------------- - -Simple, use either pthreadGCv.* if you use GCC, or pthreadVCv.* if you -use MSVC - where 'v' is the DLL versioning (compatibility) number. - -Otherwise, you need to choose carefully and know WHY. - -The most important choice you need to make is whether to use a -version that uses exceptions internally, or not. There are versions -of the library that use exceptions as part of the thread -cancelation and exit implementation. The default version uses -setjmp/longjmp. - -There is some contension amongst POSIX threads experts as -to how POSIX threads cancelation and exit should work -with languages that use exceptions, e.g. C++ and even C -(Microsoft's Structured Exceptions). - -The issue is: should cancelation of a thread in, say, -a C++ application cause object destructors and C++ exception -handlers to be invoked as the stack unwinds during thread -exit, or not? - -There seems to be more opinion in favour of using the -standard C version of the library (no EH) with C++ applications -for the reason that this appears to be the assumption commercial -pthreads implementations make. Therefore, if you use an EH version -of pthreads-win32 then you may be under the illusion that -your application will be portable, when in fact it is likely to -behave differently when linked with other pthreads libraries. - -Now you may be asking: then why have you kept the EH versions of -the library? - -There are a couple of reasons: -- there is division amongst the experts and so the code may - be needed in the future. Yes, it's in the repository and we - can get it out anytime in the future, but it would be difficult - to find. -- pthreads-win32 is one of the few implementations, and possibly - the only freely available one, that has EH versions. It may be - useful to people who want to play with or study application - behaviour under these conditions. - -Notes: - -[If you use either pthreadVCE or pthreadGCE] - -1. [See also the discussion in the FAQ file - Q2, Q4, and Q5] - -If your application contains catch(...) blocks in your POSIX -threads then you will need to replace the "catch(...)" with the macro -"PtW32Catch", eg. - - #ifdef PtW32Catch - PtW32Catch { - ... - } - #else - catch(...) { - ... - } - #endif - -Otherwise neither pthreads cancelation nor pthread_exit() will work -reliably when using versions of the library that use C++ exceptions -for cancelation and thread exit. - -This is due to what is believed to be a C++ compliance error in VC++ -whereby you may not have multiple handlers for the same exception in -the same try/catch block. GNU G++ doesn't have this restriction. - - -Other name changes ------------------- - -All snapshots prior to and including snapshot 2000-08-13 -used "_pthread_" as the prefix to library internal -functions, and "_PTHREAD_" to many library internal -macros. These have now been changed to "ptw32_" and "PTW32_" -respectively so as to not conflict with the ANSI standard's -reservation of identifiers beginning with "_" and "__" for -use by compiler implementations only. - -If you have written any applications and you are linking -statically with the pthreads-win32 library then you may have -included a call to _pthread_processInitialize. You will -now have to change that to ptw32_processInitialize. - - -Cleanup code default style --------------------------- - -Previously, if not defined, the cleanup style was determined automatically -from the compiler used, and one of the following was defined accordingly: - - __CLEANUP_SEH MSVC only - __CLEANUP_CXX C++, including MSVC++, GNU G++ - __CLEANUP_C C, including GNU GCC, not MSVC - -These defines determine the style of cleanup (see pthread.h) and, -most importantly, the way that cancelation and thread exit (via -pthread_exit) is performed (see the routine ptw32_throw()). - -In short, the exceptions versions of the library throw an exception -when a thread is canceled, or exits via pthread_exit(). This exception is -caught by a handler in the thread startup routine, so that the -the correct stack unwinding occurs regardless of where the thread -is when it's canceled or exits via pthread_exit(). - -In this snapshot, unless the build explicitly defines (e.g. via a -compiler option) __CLEANUP_SEH, __CLEANUP_CXX, or __CLEANUP_C, then -the build NOW always defaults to __CLEANUP_C style cleanup. This style -uses setjmp/longjmp in the cancelation and pthread_exit implementations, -and therefore won't do stack unwinding even when linked to applications -that have it (e.g. C++ apps). This is for consistency with most/all -commercial Unix POSIX threads implementations. - -Although it was not clearly documented before, it is still necessary to -build your application using the same __CLEANUP_* define as was -used for the version of the library that you link with, so that the -correct parts of pthread.h are included. That is, the possible -defines require the following library versions: - - __CLEANUP_SEH pthreadVSE.dll - __CLEANUP_CXX pthreadVCE.dll or pthreadGCE.dll - __CLEANUP_C pthreadVC.dll or pthreadGC.dll - -It is recommended that you let pthread.h use it's default __CLEANUP_C -for both library and application builds. That is, don't define any of -the above, and then link with pthreadVC.lib (MSVC or MSVC++) and -libpthreadGC.a (MinGW GCC or G++). The reason is explained below, but -another reason is that the prebuilt pthreadVCE.dll is currently broken. -Versions built with MSVC++ later than version 6 may not be broken, but I -can't verify this yet. - -WHY ARE WE MAKING THE DEFAULT STYLE LESS EXCEPTION-FRIENDLY? -Because no commercial Unix POSIX threads implementation allows you to -choose to have stack unwinding. Therefore, providing it in pthread-win32 -as a default is dangerous. We still provide the choice but unless -you consciously choose to do otherwise, your pthreads applications will -now run or crash in similar ways irrespective of the pthreads platform -you use. Or at least this is the hope. - - -Building under VC++ using C++ EH, Structured EH, or just C ----------------------------------------------------------- - -From the source directory run nmake without any arguments to list -help information. E.g. - -$ nmake - -Microsoft (R) Program Maintenance Utility Version 6.00.8168.0 -Copyright (C) Microsoft Corp 1988-1998. All rights reserved. - -Run one of the following command lines: -nmake clean VCE (to build the MSVC dll with C++ exception handling) -nmake clean VSE (to build the MSVC dll with structured exception handling) -nmake clean VC (to build the MSVC dll with C cleanup code) -nmake clean VCE-inlined (to build the MSVC inlined dll with C++ exception handling) -nmake clean VSE-inlined (to build the MSVC inlined dll with structured exception handling) -nmake clean VC-inlined (to build the MSVC inlined dll with C cleanup code) -nmake clean VC-static (to build the MSVC static lib with C cleanup code) -nmake clean VCE-debug (to build the debug MSVC dll with C++ exception handling) -nmake clean VSE-debug (to build the debug MSVC dll with structured exception handling) -nmake clean VC-debug (to build the debug MSVC dll with C cleanup code) -nmake clean VCE-inlined-debug (to build the debug MSVC inlined dll with C++ exception handling) -nmake clean VSE-inlined-debug (to build the debug MSVC inlined dll with structured exception handling) -nmake clean VC-inlined-debug (to build the debug MSVC inlined dll with C cleanup code) -nmake clean VC-static-debug (to build the debug MSVC static lib with C cleanup code) - - -The pre-built dlls are normally built using the *-inlined targets. - -You can run the testsuite by changing to the "tests" directory and -running nmake. E.g.: - -$ cd tests -$ nmake - -Microsoft (R) Program Maintenance Utility Version 6.00.8168.0 -Copyright (C) Microsoft Corp 1988-1998. All rights reserved. - -Run one of the following command lines: -nmake clean VC (to test using VC dll with VC (no EH) applications) -nmake clean VCX (to test using VC dll with VC++ (EH) applications) -nmake clean VCE (to test using the VCE dll with VC++ EH applications) -nmake clean VSE (to test using VSE dll with VC (SEH) applications) -nmake clean VC-bench (to benchtest using VC dll with C bench app) -nmake clean VCX-bench (to benchtest using VC dll with C++ bench app) -nmake clean VCE-bench (to benchtest using VCE dll with C++ bench app) -nmake clean VSE-bench (to benchtest using VSE dll with SEH bench app) -nmake clean VC-static (to test using VC static lib with VC (no EH) applications) - - -Building under Mingw32 ----------------------- - -The dll can be built easily with recent versions of Mingw32. -(The distributed versions are built using Mingw32 and MsysDTK -from www.mingw32.org.) - -From the source directory, run make for help information. E.g.: - -$ make -Run one of the following command lines: -make clean GC (to build the GNU C dll with C cleanup code) -make clean GCE (to build the GNU C dll with C++ exception handling) -make clean GC-inlined (to build the GNU C inlined dll with C cleanup code) -make clean GCE-inlined (to build the GNU C inlined dll with C++ exception handling) -make clean GC-static (to build the GNU C inlined static lib with C cleanup code) -make clean GC-debug (to build the GNU C debug dll with C cleanup code) -make clean GCE-debug (to build the GNU C debug dll with C++ exception handling) -make clean GC-inlined-debug (to build the GNU C inlined debug dll with C cleanup code) -make clean GCE-inlined-debug (to build the GNU C inlined debug dll with C++ exception handling) -make clean GC-static-debug (to build the GNU C inlined static debug lib with C cleanup code) - - -The pre-built dlls are normally built using the *-inlined targets. - -You can run the testsuite by changing to the "tests" directory and -running make for help information. E.g.: - -$ cd tests -$ make -Run one of the following command lines: -make clean GC (to test using GC dll with C (no EH) applications) -make clean GCX (to test using GC dll with C++ (EH) applications) -make clean GCE (to test using GCE dll with C++ (EH) applications) -make clean GC-bench (to benchtest using GNU C dll with C cleanup code) -make clean GCE-bench (to benchtest using GNU C dll with C++ exception handling) -make clean GC-static (to test using GC static lib with C (no EH) applications) - - -Building under Linux using the Mingw32 cross development tools --------------------------------------------------------------- - -You can build the library without leaving Linux by using the Mingw32 cross -development toolchain. See http://www.libsdl.org/extras/win32/cross/ for -tools and info. The GNUmakefile contains some support for this, for example: - -make CROSS=i386-mingw32msvc- clean GC-inlined - -will build pthreadGCn.dll and libpthreadGCn.a (n=version#), provided your -cross-tools/bin directory is in your PATH (or use the cross-make.sh script -at the URL above). - - -Building the library as a statically linkable library ------------------------------------------------------ - -General: PTW32_STATIC_LIB must be defined for both the library build and the -application build. The makefiles supplied and used by the following 'make' -command lines will define this for you. - -MSVC (creates pthreadVCn.lib as a static link lib): - -nmake clean VC-static - - -MinGW32 (creates libpthreadGCn.a as a static link lib): - -make clean GC-static - - -Define PTW32_STATIC_LIB when building your application. Also, your -application must call a two non-portable routines to initialise the -some state on startup and cleanup before exit. One other routine needs -to be called to cleanup after any Win32 threads have called POSIX API -routines. See README.NONPORTABLE or the html reference manual pages for -details on these routines: - -BOOL pthread_win32_process_attach_np (void); -BOOL pthread_win32_process_detach_np (void); -BOOL pthread_win32_thread_attach_np (void); // Currently a no-op -BOOL pthread_win32_thread_detach_np (void); - - -The tests makefiles have the same targets but only check that the -static library is statically linkable. They don't run the full -testsuite. To run the full testsuite, build the dlls and run the -dll test targets. - - -Building the library under Cygwin ---------------------------------- - -Cygwin is implementing it's own POSIX threads routines and these -will be the ones to use if you develop using Cygwin. - - -Ready to run binaries ---------------------- - -For convenience, the following ready-to-run files can be downloaded -from the FTP site (see under "Availability" below): - - pthread.h - semaphore.h - sched.h - pthreadVC.dll - built with MSVC compiler using C setjmp/longjmp - pthreadVC.lib - pthreadVCE.dll - built with MSVC++ compiler using C++ EH - pthreadVCE.lib - pthreadVSE.dll - built with MSVC compiler using SEH - pthreadVSE.lib - pthreadGC.dll - built with Mingw32 GCC - libpthreadGC.a - derived from pthreadGC.dll - pthreadGCE.dll - built with Mingw32 G++ - libpthreadGCE.a - derived from pthreadGCE.dll - -As of August 2003 pthreads-win32 pthreadG* versions are built and tested -using the MinGW + MsysDTK environment current as of that date or later. -The following file MAY be needed for older MinGW environments. - - gcc.dll - needed to build and run applications that use - pthreadGCE.dll. - - -Building applications with GNU compilers ----------------------------------------- - -If you're using pthreadGC.dll: - -With the three header files, pthreadGC.dll and libpthreadGC.a in the -same directory as your application myapp.c, you could compile, link -and run myapp.c under Mingw32 as follows: - - gcc -o myapp.exe myapp.c -I. -L. -lpthreadGC - myapp - -Or put pthreadGC.dll in an appropriate directory in your PATH, -put libpthreadGC.a in your system lib directory, and -put the three header files in your system include directory, -then use: - - gcc -o myapp.exe myapp.c -lpthreadGC - myapp - - -If you're using pthreadGCE.dll: - -With the three header files, pthreadGCE.dll, gcc.dll and libpthreadGCE.a -in the same directory as your application myapp.c, you could compile, -link and run myapp.c under Mingw32 as follows: - - gcc -x c++ -o myapp.exe myapp.c -I. -L. -lpthreadGCE - myapp - -Or put pthreadGCE.dll and gcc.dll in an appropriate directory in -your PATH, put libpthreadGCE.a in your system lib directory, and -put the three header files in your system include directory, -then use: - - gcc -x c++ -o myapp.exe myapp.c -lpthreadGCE - myapp - - -Availability ------------- - -The complete source code in either unbundled, self-extracting -Zip file, or tar/gzipped format can be found at: - - ftp://sources.redhat.com/pub/pthreads-win32 - -The pre-built DLL, export libraries and matching pthread.h can -be found at: - - ftp://sources.redhat.com/pub/pthreads-win32/dll-latest - -Home page: - - http://sources.redhat.com/pthreads-win32/ - - -Mailing list ------------- - -There is a mailing list for discussing pthreads on Win32. -To join, send email to: - - pthreads-win32-subscribe@sources.redhat.com - -Unsubscribe by sending mail to: - - pthreads-win32-unsubscribe@sources.redhat.com - - -Acknowledgements ----------------- - -See the ANNOUNCE file for acknowledgements. -See the 'CONTRIBUTORS' file for the list of contributors. - -As much as possible, the ChangeLog file attributes -contributions and patches that have been incorporated -in the library to the individuals responsible. - -Finally, thanks to all those who work on and contribute to the -POSIX and Single Unix Specification standards. The maturity of an -industry can be measured by it's open standards. - ----- -Ross Johnson - - - - - - - - - diff --git a/deps/w32-pthreads/README.Borland b/deps/w32-pthreads/README.Borland deleted file mode 100644 index a130d2b..0000000 --- a/deps/w32-pthreads/README.Borland +++ /dev/null @@ -1,57 +0,0 @@ -In ptw32_InterlockedCompareExchange.c, I've added a section for -Borland's compiler; it's identical to that for the MS compiler except -that it uses /* ... */ comments instead of ; comments. - -[RPJ: need to define HAVE_TASM32 in config.h to use the above.] - - -The other file is a makefile suitable for use with Borland's compiler -(run "make -fBmakefile" in the directory). It builds a single version -of the library, pthreadBC.dll and the corresponding pthreadBC.lib -import library, which is comparable to the pthreadVC version; I can't -personally see any demand for the versions that include structured or -C++ exception cancellation handling so I haven't attempted to build -those versions of the library. (I imagine a static version might be -of use to some, but we can't legally use that on my commercial -projects so I can't try that out, unfortunately.) - -[RPJ: Added tests\Bmakefile as well.] - -Borland C++ doesn't define the ENOSYS constant used by pthreads-win32; -rather than make more extensive patches to the pthreads-win32 source I -have a mostly-arbitrary constant for it in the makefile. However this -doesn't make it visible to the application using the library, so if -anyone actually wants to use this constant in their apps (why?) -someone might like to make a seperate NEED_BCC_something define to add -this stuff. - -The makefile also #defines EDEADLK as EDEADLOCK, _timeb as timeb, and -_ftime as ftime, to deal with the minor differences between the two -RTLs' naming conventions, and sets the compiler flags as required to -get a normal compile of the library. - -[RPJ: Moved errno values and _timeb etc to pthread.h, so apps will also -use them.] - -(While I'm on the subject, the reason Borland users should recompile -the library, rather than using the impdef/implib technique suggested -previously on the mailing list, is that a) the errno constants are -different, so the results returned by the pthread_* functions can be -meaningless, and b) the errno variable/pseudo-variable itself is -different in the MS & BCC runtimes, so you can't access the -pthreadVC's errno from a Borland C++-compiled host application -correctly - I imagine there are other potential problems from the RTL -mismatch too.) - -[RPJ: Make sure you use the same RTL in both dll and application builds. -The dll and tests Bmakefiles use cw32mti.lib. Having some trouble with -memory read exceptions running the test suite using BCC55.] - -Best regards, -Will - --- -Will Bryant -Systems Architect, eCOSM Limited -Cell +64 21 655 443, office +64 3 365 4176 -http://www.ecosm.com/ diff --git a/deps/w32-pthreads/README.CV b/deps/w32-pthreads/README.CV deleted file mode 100644 index 698728b..0000000 --- a/deps/w32-pthreads/README.CV +++ /dev/null @@ -1,3036 +0,0 @@ -README.CV -- Condition Variables --------------------------------- - -The original implementation of condition variables in -pthreads-win32 was based on a discussion paper: - -"Strategies for Implementing POSIX Condition Variables -on Win32": http://www.cs.wustl.edu/~schmidt/win32-cv-1.html - -The changes suggested below were made on Feb 6 2001. This -file is included in the package for the benefit of anyone -interested in understanding the pthreads-win32 implementation -of condition variables and the (sometimes subtle) issues that -it attempts to resolve. - -Thanks go to the individuals whose names appear throughout -the following text. - -Ross Johnson - --------------------------------------------------------------------- - -fyi.. (more detailed problem description/demos + possible fix/patch) - -regards, -alexander. - - -Alexander Terekhov -31.01.2001 17:43 - -To: ace-bugs@cs.wustl.edu -cc: -From: Alexander Terekhov/Germany/IBM@IBMDE -Subject: Implementation of POSIX CVs: spur.wakeups/lost - signals/deadlocks/unfairness - - - - ACE VERSION: - - 5.1.12 (pthread-win32 snapshot 2000-12-29) - - HOST MACHINE and OPERATING SYSTEM: - - IBM IntelliStation Z Pro, 2 x XEON 1GHz, Win2K - - TARGET MACHINE and OPERATING SYSTEM, if different from HOST: - COMPILER NAME AND VERSION (AND PATCHLEVEL): - - Microsoft Visual C++ 6.0 - - AREA/CLASS/EXAMPLE AFFECTED: - - Implementation of POSIX condition variables - OS.cpp/.h - - DOES THE PROBLEM AFFECT: - - EXECUTION? YES! - - SYNOPSIS: - - a) spurious wakeups (minor problem) - b) lost signals - c) broadcast deadlock - d) unfairness (minor problem) - - DESCRIPTION: - - Please see attached copy of discussion thread - from comp.programming.threads for more details on - some reported problems. (i've also posted a "fyi" - message to ace-users a week or two ago but - unfortunately did not get any response so far). - - It seems that current implementation suffers from - two essential problems: - - 1) cond.waiters_count does not accurately reflect - number of waiters blocked on semaphore - w/o - proper synchronisation that could result (in the - time window when counter is not accurate) - in spurious wakeups organised by subsequent - _signals and _broadcasts. - - 2) Always having (with no e.g. copy_and_clear/..) - the same queue in use (semaphore+counter) - neither signal nor broadcast provide 'atomic' - behaviour with respect to other threads/subsequent - calls to signal/broadcast/wait. - - Each problem and combination of both could produce - various nasty things: - - a) spurious wakeups (minor problem) - - it is possible that waiter(s) which was already - unblocked even so is still counted as blocked - waiter. signal and broadcast will release - semaphore which will produce a spurious wakeup - for a 'real' waiter coming later. - - b) lost signals - - signalling thread ends up consuming its own - signal. please see demo/discussion below. - - c) broadcast deadlock - - last_waiter processing code does not correctly - handle the case with multiple threads - waiting for the end of broadcast. - please see demo/discussion below. - - d) unfairness (minor problem) - - without SignalObjectAndWait some waiter(s) - may end up consuming broadcasted signals - multiple times (spurious wakeups) because waiter - thread(s) can be preempted before they call - semaphore wait (but after count++ and mtx.unlock). - - REPEAT BY: - - See below... run problem demos programs (tennis.cpp and - tennisb.cpp) number of times concurrently (on multiprocessor) - and in multiple sessions or just add a couple of "Sleep"s - as described in the attached copy of discussion thread - from comp.programming.threads - - SAMPLE FIX/WORKAROUND: - - See attached patch to pthread-win32.. well, I can not - claim that it is completely bug free but at least my - test and tests provided by pthreads-win32 seem to work. - Perhaps that will help. - - regards, - alexander. - - ->> Forum: comp.programming.threads ->> Thread: pthread_cond_* implementation questions -. -. -. -David Schwartz wrote: - -> terekhov@my-deja.com wrote: -> ->> BTW, could you please also share your view on other perceived ->> "problems" such as nested broadcast deadlock, spurious wakeups ->> and (the latest one) lost signals?? -> ->I'm not sure what you mean. The standard allows an implementation ->to do almost whatever it likes. In fact, you could implement ->pthread_cond_wait by releasing the mutex, sleeping a random ->amount of time, and then reacquiring the mutex. Of course, ->this would be a pretty poor implementation, but any code that ->didn't work under that implementation wouldn't be strictly ->compliant. - -The implementation you suggested is indeed correct -one (yes, now I see it :). However it requires from -signal/broadcast nothing more than to "{ return 0; }" -That is not the case for pthread-win32 and ACE -implementations. I do think that these implementations -(basically the same implementation) have some serious -problems with wait/signal/broadcast calls. I am looking -for help to clarify whether these problems are real -or not. I think that I can demonstrate what I mean -using one or two small sample programs. -. -. -. -========== -tennis.cpp -========== - -#include "ace/Synch.h" -#include "ace/Thread.h" - -enum GAME_STATE { - - START_GAME, - PLAYER_A, // Player A playes the ball - PLAYER_B, // Player B playes the ball - GAME_OVER, - ONE_PLAYER_GONE, - BOTH_PLAYERS_GONE - -}; - -enum GAME_STATE eGameState; -ACE_Mutex* pmtxGameStateLock; -ACE_Condition< ACE_Mutex >* pcndGameStateChange; - -void* - playerA( - void* pParm - ) -{ - - // For access to game state variable - pmtxGameStateLock->acquire(); - - // Play loop - while ( eGameState < GAME_OVER ) { - - // Play the ball - cout << endl << "PLAYER-A" << endl; - - // Now its PLAYER-B's turn - eGameState = PLAYER_B; - - // Signal to PLAYER-B that now it is his turn - pcndGameStateChange->signal(); - - // Wait until PLAYER-B finishes playing the ball - do { - - pcndGameStateChange->wait(); - - if ( PLAYER_B == eGameState ) - cout << endl << "----PLAYER-A: SPURIOUS WAKEUP!!!" << endl; - - } while ( PLAYER_B == eGameState ); - - } - - // PLAYER-A gone - eGameState = (GAME_STATE)(eGameState+1); - cout << endl << "PLAYER-A GONE" << endl; - - // No more access to state variable needed - pmtxGameStateLock->release(); - - // Signal PLAYER-A gone event - pcndGameStateChange->broadcast(); - - return 0; - -} - -void* - playerB( - void* pParm - ) -{ - - // For access to game state variable - pmtxGameStateLock->acquire(); - - // Play loop - while ( eGameState < GAME_OVER ) { - - // Play the ball - cout << endl << "PLAYER-B" << endl; - - // Now its PLAYER-A's turn - eGameState = PLAYER_A; - - // Signal to PLAYER-A that now it is his turn - pcndGameStateChange->signal(); - - // Wait until PLAYER-A finishes playing the ball - do { - - pcndGameStateChange->wait(); - - if ( PLAYER_A == eGameState ) - cout << endl << "----PLAYER-B: SPURIOUS WAKEUP!!!" << endl; - - } while ( PLAYER_A == eGameState ); - - } - - // PLAYER-B gone - eGameState = (GAME_STATE)(eGameState+1); - cout << endl << "PLAYER-B GONE" << endl; - - // No more access to state variable needed - pmtxGameStateLock->release(); - - // Signal PLAYER-B gone event - pcndGameStateChange->broadcast(); - - return 0; - -} - - -int -main (int, ACE_TCHAR *[]) -{ - - pmtxGameStateLock = new ACE_Mutex(); - pcndGameStateChange = new ACE_Condition< ACE_Mutex >( *pmtxGameStateLock -); - - // Set initial state - eGameState = START_GAME; - - // Create players - ACE_Thread::spawn( playerA ); - ACE_Thread::spawn( playerB ); - - // Give them 5 sec. to play - Sleep( 5000 );//sleep( 5 ); - - // Set game over state - pmtxGameStateLock->acquire(); - eGameState = GAME_OVER; - - // Let them know - pcndGameStateChange->broadcast(); - - // Wait for players to stop - do { - - pcndGameStateChange->wait(); - - } while ( eGameState < BOTH_PLAYERS_GONE ); - - // Cleanup - cout << endl << "GAME OVER" << endl; - pmtxGameStateLock->release(); - delete pcndGameStateChange; - delete pmtxGameStateLock; - - return 0; - -} - -=========== -tennisb.cpp -=========== -#include "ace/Synch.h" -#include "ace/Thread.h" - -enum GAME_STATE { - - START_GAME, - PLAYER_A, // Player A playes the ball - PLAYER_B, // Player B playes the ball - GAME_OVER, - ONE_PLAYER_GONE, - BOTH_PLAYERS_GONE - -}; - -enum GAME_STATE eGameState; -ACE_Mutex* pmtxGameStateLock; -ACE_Condition< ACE_Mutex >* pcndGameStateChange; - -void* - playerA( - void* pParm - ) -{ - - // For access to game state variable - pmtxGameStateLock->acquire(); - - // Play loop - while ( eGameState < GAME_OVER ) { - - // Play the ball - cout << endl << "PLAYER-A" << endl; - - // Now its PLAYER-B's turn - eGameState = PLAYER_B; - - // Signal to PLAYER-B that now it is his turn - pcndGameStateChange->broadcast(); - - // Wait until PLAYER-B finishes playing the ball - do { - - pcndGameStateChange->wait(); - - if ( PLAYER_B == eGameState ) - cout << endl << "----PLAYER-A: SPURIOUS WAKEUP!!!" << endl; - - } while ( PLAYER_B == eGameState ); - - } - - // PLAYER-A gone - eGameState = (GAME_STATE)(eGameState+1); - cout << endl << "PLAYER-A GONE" << endl; - - // No more access to state variable needed - pmtxGameStateLock->release(); - - // Signal PLAYER-A gone event - pcndGameStateChange->broadcast(); - - return 0; - -} - -void* - playerB( - void* pParm - ) -{ - - // For access to game state variable - pmtxGameStateLock->acquire(); - - // Play loop - while ( eGameState < GAME_OVER ) { - - // Play the ball - cout << endl << "PLAYER-B" << endl; - - // Now its PLAYER-A's turn - eGameState = PLAYER_A; - - // Signal to PLAYER-A that now it is his turn - pcndGameStateChange->broadcast(); - - // Wait until PLAYER-A finishes playing the ball - do { - - pcndGameStateChange->wait(); - - if ( PLAYER_A == eGameState ) - cout << endl << "----PLAYER-B: SPURIOUS WAKEUP!!!" << endl; - - } while ( PLAYER_A == eGameState ); - - } - - // PLAYER-B gone - eGameState = (GAME_STATE)(eGameState+1); - cout << endl << "PLAYER-B GONE" << endl; - - // No more access to state variable needed - pmtxGameStateLock->release(); - - // Signal PLAYER-B gone event - pcndGameStateChange->broadcast(); - - return 0; - -} - - -int -main (int, ACE_TCHAR *[]) -{ - - pmtxGameStateLock = new ACE_Mutex(); - pcndGameStateChange = new ACE_Condition< ACE_Mutex >( *pmtxGameStateLock -); - - // Set initial state - eGameState = START_GAME; - - // Create players - ACE_Thread::spawn( playerA ); - ACE_Thread::spawn( playerB ); - - // Give them 5 sec. to play - Sleep( 5000 );//sleep( 5 ); - - // Make some noise - pmtxGameStateLock->acquire(); - cout << endl << "---Noise ON..." << endl; - pmtxGameStateLock->release(); - for ( int i = 0; i < 100000; i++ ) - pcndGameStateChange->broadcast(); - cout << endl << "---Noise OFF" << endl; - - // Set game over state - pmtxGameStateLock->acquire(); - eGameState = GAME_OVER; - cout << endl << "---Stopping the game..." << endl; - - // Let them know - pcndGameStateChange->broadcast(); - - // Wait for players to stop - do { - - pcndGameStateChange->wait(); - - } while ( eGameState < BOTH_PLAYERS_GONE ); - - // Cleanup - cout << endl << "GAME OVER" << endl; - pmtxGameStateLock->release(); - delete pcndGameStateChange; - delete pmtxGameStateLock; - - return 0; - -} -. -. -. -David Schwartz wrote: ->> > It's compliant ->> ->> That is really good. -> ->> Tomorrow (I have to go urgently now) I will try to ->> demonstrate the lost-signal "problem" of current ->> pthread-win32 and ACE-(variant w/o SingleObjectAndWait) ->> implementations: players start suddenly drop their balls :-) ->> (with no change in source code). -> ->Signals aren't lost, they're going to the main thread, ->which isn't coded correctly to handle them. Try this: -> -> // Wait for players to stop -> do { -> -> pthread_cond_wait( &cndGameStateChange,&mtxGameStateLock ); ->printf("Main thread stole a signal\n"); -> -> } while ( eGameState < BOTH_PLAYERS_GONE ); -> ->I bet everytime you thing a signal is lost, you'll see that printf. ->The signal isn't lost, it was stolen by another thread. - -well, you can probably loose your bet.. it was indeed stolen -by "another" thread but not the one you seem to think of. - -I think that what actually happens is the following: - -H:\SA\UXX\pt\PTHREADS\TESTS>tennis3.exe - -PLAYER-A - -PLAYER-B - -----PLAYER-B: SPURIOUS WAKEUP!!! - -PLAYER-A GONE - -PLAYER-B GONE - -GAME OVER - -H:\SA\UXX\pt\PTHREADS\TESTS> - -here you can see that PLAYER-B after playing his first -ball (which came via signal from PLAYER-A) just dropped -it down. What happened is that his signal to player A -was consumed as spurious wakeup by himself (player B). - -The implementation has a problem: - -================ -waiting threads: -================ - -{ /** Critical Section - - inc cond.waiters_count - -} - - /* - /* Atomic only if using Win32 SignalObjectAndWait - /* - cond.mtx.release - - /*** ^^-- A THREAD WHICH DID SIGNAL MAY ACQUIRE THE MUTEX, - /*** GO INTO WAIT ON THE SAME CONDITION AND OVERTAKE - /*** ORIGINAL WAITER(S) CONSUMING ITS OWN SIGNAL! - - cond.sem.wait - -Player-A after playing game's initial ball went into -wait (called _wait) but was pre-empted before reaching -wait semaphore. He was counted as waiter but was not -actually waiting/blocked yet. - -=============== -signal threads: -=============== - -{ /** Critical Section - - waiters_count = cond.waiters_count - -} - - if ( waiters_count != 0 ) - - sem.post 1 - - endif - -Player-B after he received signal/ball from Player A -called _signal. The _signal did see that there was -one waiter blocked on the condition (Player-A) and -released the semaphore.. (but it did not unblock -Player-A because he was not actually blocked). -Player-B thread continued its execution, called _wait, -was counted as second waiter BUT was allowed to slip -through opened semaphore gate (which was opened for -Player-B) and received his own signal. Player B remained -blocked followed by Player A. Deadlock happened which -lasted until main thread came in and said game over. - -It seems to me that the implementation fails to -correctly implement the following statement -from specification: - -http://www.opengroup.org/ -onlinepubs/007908799/xsh/pthread_cond_wait.html - -"These functions atomically release mutex and cause -the calling thread to block on the condition variable -cond; atomically here means "atomically with respect -to access by another thread to the mutex and then the -condition variable". That is, if another thread is -able to acquire the mutex after the about-to-block -thread has released it, then a subsequent call to -pthread_cond_signal() or pthread_cond_broadcast() -in that thread behaves as if it were issued after -the about-to-block thread has blocked." - -Question: Am I right? - -(I produced the program output above by simply -adding ?Sleep( 1 )?: - -================ -waiting threads: -================ - -{ /** Critical Section - - inc cond.waiters_count - -} - - /* - /* Atomic only if using Win32 SignalObjectAndWait - /* - cond.mtx.release - -Sleep( 1 ); // Win32 - - /*** ^^-- A THREAD WHICH DID SIGNAL MAY ACQUIRE THE MUTEX, - /*** GO INTO WAIT ON THE SAME CONDITION AND OVERTAKE - /*** ORIGINAL WAITER(S) CONSUMING ITS OWN SIGNAL! - - cond.sem.wait - -to the source code of pthread-win32 implementation: - -http://sources.redhat.com/cgi-bin/cvsweb.cgi/pthreads/ -condvar.c?rev=1.36&content-type=text/ -x-cvsweb-markup&cvsroot=pthreads-win32 - - - /* - * We keep the lock held just long enough to increment the count of - * waiters by one (above). - * Note that we can't keep it held across the - * call to sem_wait since that will deadlock other calls - * to pthread_cond_signal - */ - cleanup_args.mutexPtr = mutex; - cleanup_args.cv = cv; - cleanup_args.resultPtr = &result; - - pthread_cleanup_push (ptw32_cond_wait_cleanup, (void *) -&cleanup_args); - - if ((result = pthread_mutex_unlock (mutex)) == 0) - {((result -Sleep( 1 ); // @AT - - /* - * Wait to be awakened by - * pthread_cond_signal, or - * pthread_cond_broadcast, or - * a timeout - * - * Note: - * ptw32_sem_timedwait is a cancelation point, - * hence providing the - * mechanism for making pthread_cond_wait a cancelation - * point. We use the cleanup mechanism to ensure we - * re-lock the mutex and decrement the waiters count - * if we are canceled. - */ - if (ptw32_sem_timedwait (&(cv->sema), abstime) == -1) { - result = errno; - } - } - - pthread_cleanup_pop (1); /* Always cleanup */ - - -BTW, on my system (2 CPUs) I can manage to get -signals lost even without any source code modification -if I run the tennis program many times in different -shell sessions. -. -. -. -David Schwartz wrote: ->terekhov@my-deja.com wrote: -> ->> well, it might be that the program is in fact buggy. ->> but you did not show me any bug. -> ->You're right. I was close but not dead on. I was correct, however, ->that the code is buggy because it uses 'pthread_cond_signal' even ->though not any thread waiting on the condition variable can do the ->job. I was wrong in which thread could be waiting on the cv but ->unable to do the job. - -Okay, lets change 'pthread_cond_signal' to 'pthread_cond_broadcast' -but also add some noise from main() right before declaring the game -to be over (I need it in order to demonstrate another problem of -pthread-win32/ACE implementations - broadcast deadlock)... -. -. -. -It is my understanding of POSIX conditions, -that on correct implementation added noise -in form of unnecessary broadcasts from main, -should not break the tennis program. The -only 'side effect' of added noise on correct -implementation would be 'spurious wakeups' of -players (in fact they are not spurious, -players just see them as spurious) unblocked, -not by another player but by main before -another player had a chance to acquire the -mutex and change the game state variable: -. -. -. - -PLAYER-B - -PLAYER-A - ----Noise ON... - -PLAYER-B - -PLAYER-A - -. -. -. - -PLAYER-B - -PLAYER-A - -----PLAYER-A: SPURIOUS WAKEUP!!! - -PLAYER-B - -PLAYER-A - ----Noise OFF - -PLAYER-B - ----Stopping the game... - -PLAYER-A GONE - -PLAYER-B GONE - -GAME OVER - -H:\SA\UXX\pt\PTHREADS\TESTS> - -On pthread-win32/ACE implementations the -program could stall: - -. -. -. - -PLAYER-A - -PLAYER-B - -PLAYER-A - -PLAYER-B - -PLAYER-A - -PLAYER-B - -PLAYER-A - -PLAYER-B - ----Noise ON... - -PLAYER-A - ----Noise OFF -^C -H:\SA\UXX\pt\PTHREADS\TESTS> - - -The implementation has problems: - -================ -waiting threads: -================ - -{ /** Critical Section - - inc cond.waiters_count - -} - - /* - /* Atomic only if using Win32 SignalObjectAndWait - /* - cond.mtx.release - cond.sem.wait - - /*** ^^-- WAITER CAN BE PREEMPTED AFTER BEING UNBLOCKED... - -{ /** Critical Section - - dec cond.waiters_count - - /*** ^^- ...AND BEFORE DECREMENTING THE COUNT (1) - - last_waiter = ( cond.was_broadcast && - cond.waiters_count == 0 ) - - if ( last_waiter ) - - cond.was_broadcast = FALSE - - endif - -} - - if ( last_waiter ) - - /* - /* Atomic only if using Win32 SignalObjectAndWait - /* - cond.auto_reset_event_or_sem.post /* Event for Win32 - cond.mtx.acquire - - /*** ^^-- ...AND BEFORE CALL TO mtx.acquire (2) - - /*** ^^-- NESTED BROADCASTS RESULT IN A DEADLOCK - - - else - - cond.mtx.acquire - - /*** ^^-- ...AND BEFORE CALL TO mtx.acquire (3) - - endif - - -================== -broadcast threads: -================== - -{ /** Critical Section - - waiters_count = cond.waiters_count - - if ( waiters_count != 0 ) - - cond.was_broadcast = TRUE - - endif - -} - -if ( waiters_count != 0 ) - - cond.sem.post waiters_count - - /*** ^^^^^--- SPURIOUS WAKEUPS DUE TO (1) - - cond.auto_reset_event_or_sem.wait /* Event for Win32 - - /*** ^^^^^--- DEADLOCK FOR FURTHER BROADCASTS IF THEY - HAPPEN TO GO INTO WAIT WHILE PREVIOUS - BROADCAST IS STILL IN PROGRESS/WAITING - -endif - -a) cond.waiters_count does not accurately reflect -number of waiters blocked on semaphore - that could -result (in the time window when counter is not accurate) -in spurios wakeups organised by subsequent _signals -and _broadcasts. From standard compliance point of view -that is OK but that could be a real problem from -performance/efficiency point of view. - -b) If subsequent broadcast happen to go into wait on -cond.auto_reset_event_or_sem before previous -broadcast was unblocked from cond.auto_reset_event_or_sem -by its last waiter, one of two blocked threads will -remain blocked because last_waiter processing code -fails to unblock both threads. - -In the situation with tennisb.c the Player-B was put -in a deadlock by noise (broadcast) coming from main -thread. And since Player-B holds the game state -mutex when it calls broadcast, the whole program -stalled: Player-A was deadlocked on mutex and -main thread after finishing with producing the noise -was deadlocked on mutex too (needed to declare the -game over) - -(I produced the program output above by simply -adding ?Sleep( 1 )?: - -================== -broadcast threads: -================== - -{ /** Critical Section - - waiters_count = cond.waiters_count - - if ( waiters_count != 0 ) - - cond.was_broadcast = TRUE - - endif - -} - -if ( waiters_count != 0 ) - -Sleep( 1 ); //Win32 - - cond.sem.post waiters_count - - /*** ^^^^^--- SPURIOUS WAKEUPS DUE TO (1) - - cond.auto_reset_event_or_sem.wait /* Event for Win32 - - /*** ^^^^^--- DEADLOCK FOR FURTHER BROADCASTS IF THEY - HAPPEN TO GO INTO WAIT WHILE PREVIOUS - BROADCAST IS STILL IN PROGRESS/WAITING - -endif - -to the source code of pthread-win32 implementation: - -http://sources.redhat.com/cgi-bin/cvsweb.cgi/pthreads/ -condvar.c?rev=1.36&content-type=text/ -x-cvsweb-markup&cvsroot=pthreads-win32 - - if (wereWaiters) - {(wereWaiters)sroot=pthreads-win32eb.cgi/pthreads/Yem...m - /* - * Wake up all waiters - */ - -Sleep( 1 ); //@AT - -#ifdef NEED_SEM - - result = (ptw32_increase_semaphore( &cv->sema, cv->waiters ) - ? 0 - : EINVAL); - -#else /* NEED_SEM */ - - result = (ReleaseSemaphore( cv->sema, cv->waiters, NULL ) - ? 0 - : EINVAL); - -#endif /* NEED_SEM */ - - } - - (void) pthread_mutex_unlock(&(cv->waitersLock)); - - if (wereWaiters && result == 0) - {(wereWaiters - /* - * Wait for all the awakened threads to acquire their part of - * the counting semaphore - */ - - if (WaitForSingleObject (cv->waitersDone, INFINITE) - == WAIT_OBJECT_0) - { - result = 0; - } - else - { - result = EINVAL; - } - - } - - return (result); - -} - -BTW, on my system (2 CPUs) I can manage to get -the program stalled even without any source code -modification if I run the tennisb program many -times in different shell sessions. - -=================== -pthread-win32 patch -=================== -struct pthread_cond_t_ { - long nWaitersBlocked; /* Number of threads blocked -*/ - long nWaitersUnblocked; /* Number of threads unblocked -*/ - long nWaitersToUnblock; /* Number of threads to unblock -*/ - sem_t semBlockQueue; /* Queue up threads waiting for the -*/ - /* condition to become signalled -*/ - sem_t semBlockLock; /* Semaphore that guards access to -*/ - /* | waiters blocked count/block queue -*/ - /* +-> Mandatory Sync.LEVEL-1 -*/ - pthread_mutex_t mtxUnblockLock; /* Mutex that guards access to -*/ - /* | waiters (to)unblock(ed) counts -*/ - /* +-> Optional* Sync.LEVEL-2 -*/ -}; /* Opt*) for _timedwait and -cancellation*/ - -int -pthread_cond_init (pthread_cond_t * cond, const pthread_condattr_t * attr) - int result = EAGAIN; - pthread_cond_t cv = NULL; - - if (cond == NULL) - {(cond - return EINVAL; - } - - if ((attr != NULL && *attr != NULL) && - ((*attr)->pshared == PTHREAD_PROCESS_SHARED)) - { - /* - * Creating condition variable that can be shared between - * processes. - */ - result = ENOSYS; - - goto FAIL0; - } - - cv = (pthread_cond_t) calloc (1, sizeof (*cv)); - - if (cv == NULL) - {(cv - result = ENOMEM; - goto FAIL0; - } - - cv->nWaitersBlocked = 0; - cv->nWaitersUnblocked = 0; - cv->nWaitersToUnblock = 0; - - if (sem_init (&(cv->semBlockLock), 0, 1) != 0) - {(sem_init - goto FAIL0; - } - - if (sem_init (&(cv->semBlockQueue), 0, 0) != 0) - {(sem_init - goto FAIL1; - } - - if (pthread_mutex_init (&(cv->mtxUnblockLock), 0) != 0) - {(pthread_mutex_init - goto FAIL2; - } - - - result = 0; - - goto DONE; - - /* - * ------------- - * Failed... - * ------------- - */ -FAIL2: - (void) sem_destroy (&(cv->semBlockQueue)); - -FAIL1: - (void) sem_destroy (&(cv->semBlockLock)); - -FAIL0: -DONE: - *cond = cv; - - return (result); - -} /* pthread_cond_init */ - -int -pthread_cond_destroy (pthread_cond_t * cond) -{ - int result = 0; - pthread_cond_t cv; - - /* - * Assuming any race condition here is harmless. - */ - if (cond == NULL - || *cond == NULL) - { - return EINVAL; - } - - if (*cond != (pthread_cond_t) PTW32_OBJECT_AUTO_INIT) - {(*cond - cv = *cond; - - /* - * Synchronize access to waiters blocked count (LEVEL-1) - */ - if (sem_wait(&(cv->semBlockLock)) != 0) - {(sem_wait(&(cv->semBlockLock)) - return errno; - } - - /* - * Synchronize access to waiters (to)unblock(ed) counts (LEVEL-2) - */ - if ((result = pthread_mutex_lock(&(cv->mtxUnblockLock))) != 0) - {((result - (void) sem_post(&(cv->semBlockLock)); - return result; - } - - /* - * Check whether cv is still busy (still has waiters blocked) - */ - if (cv->nWaitersBlocked - cv->nWaitersUnblocked > 0) - {(cv->nWaitersBlocked - (void) sem_post(&(cv->semBlockLock)); - (void) pthread_mutex_unlock(&(cv->mtxUnblockLock)); - return EBUSY; - } - - /* - * Now it is safe to destroy - */ - (void) sem_destroy (&(cv->semBlockLock)); - (void) sem_destroy (&(cv->semBlockQueue)); - (void) pthread_mutex_unlock (&(cv->mtxUnblockLock)); - (void) pthread_mutex_destroy (&(cv->mtxUnblockLock)); - - free(cv); - *cond = NULL; - } - else - { - /* - * See notes in ptw32_cond_check_need_init() above also. - */ - EnterCriticalSection(&ptw32_cond_test_init_lock); - - /* - * Check again. - */ - if (*cond == (pthread_cond_t) PTW32_OBJECT_AUTO_INIT) - {(*cond - /* - * This is all we need to do to destroy a statically - * initialised cond that has not yet been used (initialised). - * If we get to here, another thread - * waiting to initialise this cond will get an EINVAL. - */ - *cond = NULL; - } - else - { - /* - * The cv has been initialised while we were waiting - * so assume it's in use. - */ - result = EBUSY; - } - - LeaveCriticalSection(&ptw32_cond_test_init_lock); - } - - return (result); -} - -/* - * Arguments for cond_wait_cleanup, since we can only pass a - * single void * to it. - */ -typedef struct { - pthread_mutex_t * mutexPtr; - pthread_cond_t cv; - int * resultPtr; -} ptw32_cond_wait_cleanup_args_t; - -static void -ptw32_cond_wait_cleanup(void * args) -{ - ptw32_cond_wait_cleanup_args_t * cleanup_args = -(ptw32_cond_wait_cleanup_args_t *) args; - pthread_cond_t cv = cleanup_args->cv; - int * resultPtr = cleanup_args->resultPtr; - int eLastSignal; /* enum: 1=yes 0=no -1=cancelled/timedout w/o signal(s) -*/ - int result; - - /* - * Whether we got here as a result of signal/broadcast or because of - * timeout on wait or thread cancellation we indicate that we are no - * longer waiting. The waiter is responsible for adjusting waiters - * (to)unblock(ed) counts (protected by unblock lock). - * Unblock lock/Sync.LEVEL-2 supports _timedwait and cancellation. - */ - if ((result = pthread_mutex_lock(&(cv->mtxUnblockLock))) != 0) - {((result - *resultPtr = result; - return; - } - - cv->nWaitersUnblocked++; - - eLastSignal = (cv->nWaitersToUnblock == 0) ? - -1 : (--cv->nWaitersToUnblock == 0); - - /* - * No more LEVEL-2 access to waiters (to)unblock(ed) counts needed - */ - if ((result = pthread_mutex_unlock(&(cv->mtxUnblockLock))) != 0) - {((result - *resultPtr = result; - return; - } - - /* - * If last signal... - */ - if (eLastSignal == 1) - {(eLastSignal - /* - * ...it means that we have end of 'atomic' signal/broadcast - */ - if (sem_post(&(cv->semBlockLock)) != 0) - {(sem_post(&(cv->semBlockLock)) - *resultPtr = errno; - return; - } - } - /* - * If not last signal and not timed out/cancelled wait w/o signal... - */ - else if (eLastSignal == 0) - { - /* - * ...it means that next waiter can go through semaphore - */ - if (sem_post(&(cv->semBlockQueue)) != 0) - {(sem_post(&(cv->semBlockQueue)) - *resultPtr = errno; - return; - } - } - - /* - * XSH: Upon successful return, the mutex has been locked and is owned - * by the calling thread - */ - if ((result = pthread_mutex_lock(cleanup_args->mutexPtr)) != 0) - {((result - *resultPtr = result; - } - -} /* ptw32_cond_wait_cleanup */ - -static int -ptw32_cond_timedwait (pthread_cond_t * cond, - pthread_mutex_t * mutex, - const struct timespec *abstime) -{ - int result = 0; - pthread_cond_t cv; - ptw32_cond_wait_cleanup_args_t cleanup_args; - - if (cond == NULL || *cond == NULL) - {(cond - return EINVAL; - } - - /* - * We do a quick check to see if we need to do more work - * to initialise a static condition variable. We check - * again inside the guarded section of ptw32_cond_check_need_init() - * to avoid race conditions. - */ - if (*cond == (pthread_cond_t) PTW32_OBJECT_AUTO_INIT) - {(*cond - result = ptw32_cond_check_need_init(cond); - } - - if (result != 0 && result != EBUSY) - {(result - return result; - } - - cv = *cond; - - /* - * Synchronize access to waiters blocked count (LEVEL-1) - */ - if (sem_wait(&(cv->semBlockLock)) != 0) - {(sem_wait(&(cv->semBlockLock)) - return errno; - } - - cv->nWaitersBlocked++; - - /* - * Thats it. Counted means waiting, no more access needed - */ - if (sem_post(&(cv->semBlockLock)) != 0) - {(sem_post(&(cv->semBlockLock)) - return errno; - } - - /* - * Setup this waiter cleanup handler - */ - cleanup_args.mutexPtr = mutex; - cleanup_args.cv = cv; - cleanup_args.resultPtr = &result; - - pthread_cleanup_push (ptw32_cond_wait_cleanup, (void *) &cleanup_args); - - /* - * Now we can release 'mutex' and... - */ - if ((result = pthread_mutex_unlock (mutex)) == 0) - {((result - - /* - * ...wait to be awakened by - * pthread_cond_signal, or - * pthread_cond_broadcast, or - * timeout, or - * thread cancellation - * - * Note: - * - * ptw32_sem_timedwait is a cancellation point, - * hence providing the mechanism for making - * pthread_cond_wait a cancellation point. - * We use the cleanup mechanism to ensure we - * re-lock the mutex and adjust (to)unblock(ed) waiters - * counts if we are cancelled, timed out or signalled. - */ - if (ptw32_sem_timedwait (&(cv->semBlockQueue), abstime) != 0) - {(ptw32_sem_timedwait - result = errno; - } - } - - /* - * Always cleanup - */ - pthread_cleanup_pop (1); - - - /* - * "result" can be modified by the cleanup handler. - */ - return (result); - -} /* ptw32_cond_timedwait */ - - -static int -ptw32_cond_unblock (pthread_cond_t * cond, - int unblockAll) -{ - int result; - pthread_cond_t cv; - - if (cond == NULL || *cond == NULL) - {(cond - return EINVAL; - } - - cv = *cond; - - /* - * No-op if the CV is static and hasn't been initialised yet. - * Assuming that any race condition is harmless. - */ - if (cv == (pthread_cond_t) PTW32_OBJECT_AUTO_INIT) - {(cv - return 0; - } - - /* - * Synchronize access to waiters blocked count (LEVEL-1) - */ - if (sem_wait(&(cv->semBlockLock)) != 0) - {(sem_wait(&(cv->semBlockLock)) - return errno; - } - - /* - * Synchronize access to waiters (to)unblock(ed) counts (LEVEL-2) - * This sync.level supports _timedwait and cancellation - */ - if ((result = pthread_mutex_lock(&(cv->mtxUnblockLock))) != 0) - {((result - return result; - } - - /* - * Adjust waiters blocked and unblocked counts (collect garbage) - */ - if (cv->nWaitersUnblocked != 0) - {(cv->nWaitersUnblocked - cv->nWaitersBlocked -= cv->nWaitersUnblocked; - cv->nWaitersUnblocked = 0; - } - - /* - * If (after adjustment) there are still some waiters blocked counted... - */ - if ( cv->nWaitersBlocked > 0) - {( - /* - * We will unblock first waiter and leave semBlockLock/LEVEL-1 locked - * LEVEL-1 access is left disabled until last signal/unblock -completes - */ - cv->nWaitersToUnblock = (unblockAll) ? cv->nWaitersBlocked : 1; - - /* - * No more LEVEL-2 access to waiters (to)unblock(ed) counts needed - * This sync.level supports _timedwait and cancellation - */ - if ((result = pthread_mutex_unlock(&(cv->mtxUnblockLock))) != 0) - {((result - return result; - } - - - /* - * Now, with LEVEL-2 lock released let first waiter go through -semaphore - */ - if (sem_post(&(cv->semBlockQueue)) != 0) - {(sem_post(&(cv->semBlockQueue)) - return errno; - } - } - /* - * No waiter blocked - no more LEVEL-1 access to blocked count needed... - */ - else if (sem_post(&(cv->semBlockLock)) != 0) - { - return errno; - } - /* - * ...and no more LEVEL-2 access to waiters (to)unblock(ed) counts needed -too - * This sync.level supports _timedwait and cancellation - */ - else - { - result = pthread_mutex_unlock(&(cv->mtxUnblockLock)); - } - - return(result); - -} /* ptw32_cond_unblock */ - -int -pthread_cond_wait (pthread_cond_t * cond, - pthread_mutex_t * mutex) -{ - /* The NULL abstime arg means INFINITE waiting. */ - return(ptw32_cond_timedwait(cond, mutex, NULL)); -} /* pthread_cond_wait */ - - -int -pthread_cond_timedwait (pthread_cond_t * cond, - pthread_mutex_t * mutex, - const struct timespec *abstime) -{ - if (abstime == NULL) - {(abstime - return EINVAL; - } - - return(ptw32_cond_timedwait(cond, mutex, abstime)); -} /* pthread_cond_timedwait */ - - -int -pthread_cond_signal (pthread_cond_t * cond) -{ - /* The '0'(FALSE) unblockAll arg means unblock ONE waiter. */ - return(ptw32_cond_unblock(cond, 0)); -} /* pthread_cond_signal */ - -int -pthread_cond_broadcast (pthread_cond_t * cond) -{ - /* The '1'(TRUE) unblockAll arg means unblock ALL waiters. */ - return(ptw32_cond_unblock(cond, 1)); -} /* pthread_cond_broadcast */ - - - - -TEREKHOV@de.ibm.com on 17.01.2001 01:00:57 - -Please respond to TEREKHOV@de.ibm.com - -To: pthreads-win32@sourceware.cygnus.com -cc: schmidt@uci.edu -Subject: win32 conditions: sem+counter+event = broadcast_deadlock + - spur.wakeup/unfairness/incorrectness ?? - - - - - - - -Hi, - -Problem 1: broadcast_deadlock - -It seems that current implementation does not provide "atomic" -broadcasts. That may lead to "nested" broadcasts... and it seems -that nested case is not handled correctly -> producing a broadcast -DEADLOCK as a result. - -Scenario: - -N (>1) waiting threads W1..N are blocked (in _wait) on condition's -semaphore. - -Thread B1 calls pthread_cond_broadcast, which results in "releasing" N -W threads via incrementing semaphore counter by N (stored in -cv->waiters) BUT cv->waiters counter does not change!! The caller -thread B1 remains blocked on cv->waitersDone event (auto-reset!!) BUT -condition is not protected from starting another broadcast (when called -on another thread) while still waiting for the "old" broadcast to -complete on thread B1. - -M (>=0, waiters counter. - -L (N-M) "late" waiter W threads are a) still blocked/not returned from -their semaphore wait call or b) were preempted after sem_wait but before -lock( &cv->waitersLock ) or c) are blocked on cv->waitersLock. - -cv->waiters is still > 0 (= L). - -Another thread B2 (or some W thread from M group) calls -pthread_cond_broadcast and gains access to counter... neither a) nor b) -prevent thread B2 in pthread_cond_broadcast from gaining access to -counter and starting another broadcast ( for c) - it depends on -cv->waitersLock scheduling rules: FIFO=OK, PRTY=PROBLEM,... ) - -That call to pthread_cond_broadcast (on thread B2) will result in -incrementing semaphore by cv->waiters (=L) which is INCORRECT (all -W1..N were in fact already released by thread B1) and waiting on -_auto-reset_ event cv->waitersDone which is DEADLY WRONG (produces a -deadlock)... - -All late W1..L threads now have a chance to complete their _wait call. -Last W_L thread sets an auto-reselt event cv->waitersDone which will -release either B1 or B2 leaving one of B threads in a deadlock. - -Problem 2: spur.wakeup/unfairness/incorrectness - -It seems that: - -a) because of the same problem with counter which does not reflect the -actual number of NOT RELEASED waiters, the signal call may increment -a semaphore counter w/o having a waiter blocked on it. That will result -in (best case) spurious wake ups - performance degradation due to -unnecessary context switches and predicate re-checks and (in worth case) -unfairness/incorrectness problem - see b) - -b) neither signal nor broadcast prevent other threads - "new waiters" -(and in the case of signal, the caller thread as well) from going into -_wait and overtaking "old" waiters (already released but still not returned -from sem_wait on condition's semaphore). Win semaphore just [API DOC]: -"Maintains a count between zero and some maximum value, limiting the number -of threads that are simultaneously accessing a shared resource." Calling -ReleaseSemaphore does not imply (at least not documented) that on return -from ReleaseSemaphore all waiters will in fact become released (returned -from their Wait... call) and/or that new waiters calling Wait... afterwards -will become less importance. It is NOT documented to be an atomic release -of -waiters... And even if it would be there is still a problem with a thread -being preempted after Wait on semaphore and before Wait on cv->waitersLock -and scheduling rules for cv->waitersLock itself -(??WaitForMultipleObjects??) -That may result in unfairness/incorrectness problem as described -for SetEvent impl. in "Strategies for Implementing POSIX Condition -Variables -on Win32": http://www.cs.wustl.edu/~schmidt/win32-cv-1.html - -Unfairness -- The semantics of the POSIX pthread_cond_broadcast function is -to wake up all threads currently blocked in wait calls on the condition -variable. The awakened threads then compete for the external_mutex. To -ensure -fairness, all of these threads should be released from their -pthread_cond_wait calls and allowed to recheck their condition expressions -before other threads can successfully complete a wait on the condition -variable. - -Unfortunately, the SetEvent implementation above does not guarantee that -all -threads sleeping on the condition variable when cond_broadcast is called -will -acquire the external_mutex and check their condition expressions. Although -the Pthreads specification does not mandate this degree of fairness, the -lack of fairness can cause starvation. - -To illustrate the unfairness problem, imagine there are 2 threads, C1 and -C2, -that are blocked in pthread_cond_wait on condition variable not_empty_ that -is guarding a thread-safe message queue. Another thread, P1 then places two -messages onto the queue and calls pthread_cond_broadcast. If C1 returns -from -pthread_cond_wait, dequeues and processes the message, and immediately -waits -again then it and only it may end up acquiring both messages. Thus, C2 will -never get a chance to dequeue a message and run. - -The following illustrates the sequence of events: - -1. Thread C1 attempts to dequeue and waits on CV non_empty_ -2. Thread C2 attempts to dequeue and waits on CV non_empty_ -3. Thread P1 enqueues 2 messages and broadcasts to CV not_empty_ -4. Thread P1 exits -5. Thread C1 wakes up from CV not_empty_, dequeues a message and runs -6. Thread C1 waits again on CV not_empty_, immediately dequeues the 2nd - message and runs -7. Thread C1 exits -8. Thread C2 is the only thread left and blocks forever since - not_empty_ will never be signaled - -Depending on the algorithm being implemented, this lack of fairness may -yield -concurrent programs that have subtle bugs. Of course, application -developers -should not rely on the fairness semantics of pthread_cond_broadcast. -However, -there are many cases where fair implementations of condition variables can -simplify application code. - -Incorrectness -- A variation on the unfairness problem described above -occurs -when a third consumer thread, C3, is allowed to slip through even though it -was not waiting on condition variable not_empty_ when a broadcast occurred. - -To illustrate this, we will use the same scenario as above: 2 threads, C1 -and -C2, are blocked dequeuing messages from the message queue. Another thread, -P1 -then places two messages onto the queue and calls pthread_cond_broadcast. -C1 -returns from pthread_cond_wait, dequeues and processes the message. At this -time, C3 acquires the external_mutex, calls pthread_cond_wait and waits on -the events in WaitForMultipleObjects. Since C2 has not had a chance to run -yet, the BROADCAST event is still signaled. C3 then returns from -WaitForMultipleObjects, and dequeues and processes the message in the -queue. -Thus, C2 will never get a chance to dequeue a message and run. - -The following illustrates the sequence of events: - -1. Thread C1 attempts to dequeue and waits on CV non_empty_ -2. Thread C2 attempts to dequeue and waits on CV non_empty_ -3. Thread P1 enqueues 2 messages and broadcasts to CV not_empty_ -4. Thread P1 exits -5. Thread C1 wakes up from CV not_empty_, dequeues a message and runs -6. Thread C1 exits -7. Thread C3 waits on CV not_empty_, immediately dequeues the 2nd - message and runs -8. Thread C3 exits -9. Thread C2 is the only thread left and blocks forever since - not_empty_ will never be signaled - -In the above case, a thread that was not waiting on the condition variable -when a broadcast occurred was allowed to proceed. This leads to incorrect -semantics for a condition variable. - - -COMMENTS??? - -regards, -alexander. - ------------------------------------------------------------------------------ - -Subject: RE: FYI/comp.programming.threads/Re: pthread_cond_* - implementation questions -Date: Wed, 21 Feb 2001 11:54:47 +0100 -From: TEREKHOV@de.ibm.com -To: lthomas@arbitrade.com -CC: rpj@ise.canberra.edu.au, Thomas Pfaff , - Nanbor Wang - -Hi Louis, - -generation number 8.. - -had some time to revisit timeouts/spurious wakeup problem.. -found some bugs (in 7.b/c/d) and something to improve -(7a - using IPC semaphores but it should speedup Win32 -version as well). - -regards, -alexander. - ----------- Algorithm 8a / IMPL_SEM,UNBLOCK_STRATEGY == UNBLOCK_ALL ------ -given: -semBlockLock - bin.semaphore -semBlockQueue - semaphore -mtxExternal - mutex or CS -mtxUnblockLock - mutex or CS -nWaitersGone - int -nWaitersBlocked - int -nWaitersToUnblock - int - -wait( timeout ) { - - [auto: register int result ] // error checking omitted - [auto: register int nSignalsWasLeft ] - [auto: register int nWaitersWasGone ] - - sem_wait( semBlockLock ); - nWaitersBlocked++; - sem_post( semBlockLock ); - - unlock( mtxExternal ); - bTimedOut = sem_wait( semBlockQueue,timeout ); - - lock( mtxUnblockLock ); - if ( 0 != (nSignalsWasLeft = nWaitersToUnblock) ) { - if ( bTimeout ) { // timeout (or canceled) - if ( 0 != nWaitersBlocked ) { - nWaitersBlocked--; - } - else { - nWaitersGone++; // count spurious wakeups - } - } - if ( 0 == --nWaitersToUnblock ) { - if ( 0 != nWaitersBlocked ) { - sem_post( semBlockLock ); // open the gate - nSignalsWasLeft = 0; // do not open the gate below -again - } - else if ( 0 != (nWaitersWasGone = nWaitersGone) ) { - nWaitersGone = 0; - } - } - } - else if ( INT_MAX/2 == ++nWaitersGone ) { // timeout/canceled or spurious -semaphore :-) - sem_wait( semBlockLock ); - nWaitersBlocked -= nWaitersGone; // something is going on here - -test of timeouts? :-) - sem_post( semBlockLock ); - nWaitersGone = 0; - } - unlock( mtxUnblockLock ); - - if ( 1 == nSignalsWasLeft ) { - if ( 0 != nWaitersWasGone ) { - // sem_adjust( -nWaitersWasGone ); - while ( nWaitersWasGone-- ) { - sem_wait( semBlockLock ); // better now than spurious -later - } - } - sem_post( semBlockLock ); // open the gate - } - - lock( mtxExternal ); - - return ( bTimedOut ) ? ETIMEOUT : 0; -} - -signal(bAll) { - - [auto: register int result ] - [auto: register int nSignalsToIssue] - - lock( mtxUnblockLock ); - - if ( 0 != nWaitersToUnblock ) { // the gate is closed!!! - if ( 0 == nWaitersBlocked ) { // NO-OP - return unlock( mtxUnblockLock ); - } - if (bAll) { - nWaitersToUnblock += nSignalsToIssue=nWaitersBlocked; - nWaitersBlocked = 0; - } - else { - nSignalsToIssue = 1; - nWaitersToUnblock++; - nWaitersBlocked--; - } - } - else if ( nWaitersBlocked > nWaitersGone ) { // HARMLESS RACE CONDITION! - sem_wait( semBlockLock ); // close the gate - if ( 0 != nWaitersGone ) { - nWaitersBlocked -= nWaitersGone; - nWaitersGone = 0; - } - if (bAll) { - nSignalsToIssue = nWaitersToUnblock = nWaitersBlocked; - nWaitersBlocked = 0; - } - else { - nSignalsToIssue = nWaitersToUnblock = 1; - nWaitersBlocked--; - } - } - else { // NO-OP - return unlock( mtxUnblockLock ); - } - - unlock( mtxUnblockLock ); - sem_post( semBlockQueue,nSignalsToIssue ); - return result; -} - ----------- Algorithm 8b / IMPL_SEM,UNBLOCK_STRATEGY == UNBLOCK_ONEBYONE ------- -given: -semBlockLock - bin.semaphore -semBlockQueue - bin.semaphore -mtxExternal - mutex or CS -mtxUnblockLock - mutex or CS -nWaitersGone - int -nWaitersBlocked - int -nWaitersToUnblock - int - -wait( timeout ) { - - [auto: register int result ] // error checking omitted - [auto: register int nWaitersWasGone ] - [auto: register int nSignalsWasLeft ] - - sem_wait( semBlockLock ); - nWaitersBlocked++; - sem_post( semBlockLock ); - - unlock( mtxExternal ); - bTimedOut = sem_wait( semBlockQueue,timeout ); - - lock( mtxUnblockLock ); - if ( 0 != (nSignalsWasLeft = nWaitersToUnblock) ) { - if ( bTimeout ) { // timeout (or canceled) - if ( 0 != nWaitersBlocked ) { - nWaitersBlocked--; - nSignalsWasLeft = 0; // do not unblock next waiter -below (already unblocked) - } - else { - nWaitersGone = 1; // spurious wakeup pending!! - } - } - if ( 0 == --nWaitersToUnblock && - if ( 0 != nWaitersBlocked ) { - sem_post( semBlockLock ); // open the gate - nSignalsWasLeft = 0; // do not open the gate below -again - } - else if ( 0 != (nWaitersWasGone = nWaitersGone) ) { - nWaitersGone = 0; - } - } - } - else if ( INT_MAX/2 == ++nWaitersGone ) { // timeout/canceled or spurious -semaphore :-) - sem_wait( semBlockLock ); - nWaitersBlocked -= nWaitersGone; // something is going on here - -test of timeouts? :-) - sem_post( semBlockLock ); - nWaitersGone = 0; - } - unlock( mtxUnblockLock ); - - if ( 1 == nSignalsWasLeft ) { - if ( 0 != nWaitersWasGone ) { - // sem_adjust( -1 ); - sem_wait( semBlockQueue ); // better now than spurious -later - } - sem_post( semBlockLock ); // open the gate - } - else if ( 0 != nSignalsWasLeft ) { - sem_post( semBlockQueue ); // unblock next waiter - } - - lock( mtxExternal ); - - return ( bTimedOut ) ? ETIMEOUT : 0; -} - -signal(bAll) { - - [auto: register int result ] - - lock( mtxUnblockLock ); - - if ( 0 != nWaitersToUnblock ) { // the gate is closed!!! - if ( 0 == nWaitersBlocked ) { // NO-OP - return unlock( mtxUnblockLock ); - } - if (bAll) { - nWaitersToUnblock += nWaitersBlocked; - nWaitersBlocked = 0; - } - else { - nWaitersToUnblock++; - nWaitersBlocked--; - } - unlock( mtxUnblockLock ); - } - else if ( nWaitersBlocked > nWaitersGone ) { // HARMLESS RACE CONDITION! - sem_wait( semBlockLock ); // close the gate - if ( 0 != nWaitersGone ) { - nWaitersBlocked -= nWaitersGone; - nWaitersGone = 0; - } - if (bAll) { - nWaitersToUnblock = nWaitersBlocked; - nWaitersBlocked = 0; - } - else { - nWaitersToUnblock = 1; - nWaitersBlocked--; - } - unlock( mtxUnblockLock ); - sem_post( semBlockQueue ); - } - else { // NO-OP - unlock( mtxUnblockLock ); - } - - return result; -} - ----------- Algorithm 8c / IMPL_EVENT,UNBLOCK_STRATEGY == UNBLOCK_ONEBYONE ---------- -given: -hevBlockLock - auto-reset event -hevBlockQueue - auto-reset event -mtxExternal - mutex or CS -mtxUnblockLock - mutex or CS -nWaitersGone - int -nWaitersBlocked - int -nWaitersToUnblock - int - -wait( timeout ) { - - [auto: register int result ] // error checking omitted - [auto: register int nSignalsWasLeft ] - [auto: register int nWaitersWasGone ] - - wait( hevBlockLock,INFINITE ); - nWaitersBlocked++; - set_event( hevBlockLock ); - - unlock( mtxExternal ); - bTimedOut = wait( hevBlockQueue,timeout ); - - lock( mtxUnblockLock ); - if ( 0 != (SignalsWasLeft = nWaitersToUnblock) ) { - if ( bTimeout ) { // timeout (or canceled) - if ( 0 != nWaitersBlocked ) { - nWaitersBlocked--; - nSignalsWasLeft = 0; // do not unblock next waiter -below (already unblocked) - } - else { - nWaitersGone = 1; // spurious wakeup pending!! - } - } - if ( 0 == --nWaitersToUnblock ) - if ( 0 != nWaitersBlocked ) { - set_event( hevBlockLock ); // open the gate - nSignalsWasLeft = 0; // do not open the gate below -again - } - else if ( 0 != (nWaitersWasGone = nWaitersGone) ) { - nWaitersGone = 0; - } - } - } - else if ( INT_MAX/2 == ++nWaitersGone ) { // timeout/canceled or spurious -event :-) - wait( hevBlockLock,INFINITE ); - nWaitersBlocked -= nWaitersGone; // something is going on here - -test of timeouts? :-) - set_event( hevBlockLock ); - nWaitersGone = 0; - } - unlock( mtxUnblockLock ); - - if ( 1 == nSignalsWasLeft ) { - if ( 0 != nWaitersWasGone ) { - reset_event( hevBlockQueue ); // better now than spurious -later - } - set_event( hevBlockLock ); // open the gate - } - else if ( 0 != nSignalsWasLeft ) { - set_event( hevBlockQueue ); // unblock next waiter - } - - lock( mtxExternal ); - - return ( bTimedOut ) ? ETIMEOUT : 0; -} - -signal(bAll) { - - [auto: register int result ] - - lock( mtxUnblockLock ); - - if ( 0 != nWaitersToUnblock ) { // the gate is closed!!! - if ( 0 == nWaitersBlocked ) { // NO-OP - return unlock( mtxUnblockLock ); - } - if (bAll) { - nWaitersToUnblock += nWaitersBlocked; - nWaitersBlocked = 0; - } - else { - nWaitersToUnblock++; - nWaitersBlocked--; - } - unlock( mtxUnblockLock ); - } - else if ( nWaitersBlocked > nWaitersGone ) { // HARMLESS RACE CONDITION! - wait( hevBlockLock,INFINITE ); // close the gate - if ( 0 != nWaitersGone ) { - nWaitersBlocked -= nWaitersGone; - nWaitersGone = 0; - } - if (bAll) { - nWaitersToUnblock = nWaitersBlocked; - nWaitersBlocked = 0; - } - else { - nWaitersToUnblock = 1; - nWaitersBlocked--; - } - unlock( mtxUnblockLock ); - set_event( hevBlockQueue ); - } - else { // NO-OP - unlock( mtxUnblockLock ); - } - - return result; -} - ----------- Algorithm 8d / IMPL_EVENT,UNBLOCK_STRATEGY == UNBLOCK_ALL ------ -given: -hevBlockLock - auto-reset event -hevBlockQueueS - auto-reset event // for signals -hevBlockQueueB - manual-reset even // for broadcasts -mtxExternal - mutex or CS -mtxUnblockLock - mutex or CS -eBroadcast - int // 0: no broadcast, 1: broadcast, 2: -broadcast after signal(s) -nWaitersGone - int -nWaitersBlocked - int -nWaitersToUnblock - int - -wait( timeout ) { - - [auto: register int result ] // error checking omitted - [auto: register int eWasBroadcast ] - [auto: register int nSignalsWasLeft ] - [auto: register int nWaitersWasGone ] - - wait( hevBlockLock,INFINITE ); - nWaitersBlocked++; - set_event( hevBlockLock ); - - unlock( mtxExternal ); - bTimedOut = waitformultiple( hevBlockQueueS,hevBlockQueueB,timeout,ONE ); - - lock( mtxUnblockLock ); - if ( 0 != (SignalsWasLeft = nWaitersToUnblock) ) { - if ( bTimeout ) { // timeout (or canceled) - if ( 0 != nWaitersBlocked ) { - nWaitersBlocked--; - nSignalsWasLeft = 0; // do not unblock next waiter -below (already unblocked) - } - else if ( 1 != eBroadcast ) { - nWaitersGone = 1; - } - } - if ( 0 == --nWaitersToUnblock ) { - if ( 0 != nWaitersBlocked ) { - set_event( hevBlockLock ); // open the gate - nSignalsWasLeft = 0; // do not open the gate below -again - } - else { - if ( 0 != (eWasBroadcast = eBroadcast) ) { - eBroadcast = 0; - } - if ( 0 != (nWaitersWasGone = nWaitersGone ) { - nWaitersGone = 0; - } - } - } - else if ( 0 != eBroadcast ) { - nSignalsWasLeft = 0; // do not unblock next waiter -below (already unblocked) - } - } - else if ( INT_MAX/2 == ++nWaitersGone ) { // timeout/canceled or spurious -event :-) - wait( hevBlockLock,INFINITE ); - nWaitersBlocked -= nWaitersGone; // something is going on here - -test of timeouts? :-) - set_event( hevBlockLock ); - nWaitersGone = 0; - } - unlock( mtxUnblockLock ); - - if ( 1 == nSignalsWasLeft ) { - if ( 0 != eWasBroadcast ) { - reset_event( hevBlockQueueB ); - } - if ( 0 != nWaitersWasGone ) { - reset_event( hevBlockQueueS ); // better now than spurious -later - } - set_event( hevBlockLock ); // open the gate - } - else if ( 0 != nSignalsWasLeft ) { - set_event( hevBlockQueueS ); // unblock next waiter - } - - lock( mtxExternal ); - - return ( bTimedOut ) ? ETIMEOUT : 0; -} - -signal(bAll) { - - [auto: register int result ] - [auto: register HANDLE hevBlockQueue ] - - lock( mtxUnblockLock ); - - if ( 0 != nWaitersToUnblock ) { // the gate is closed!!! - if ( 0 == nWaitersBlocked ) { // NO-OP - return unlock( mtxUnblockLock ); - } - if (bAll) { - nWaitersToUnblock += nWaitersBlocked; - nWaitersBlocked = 0; - eBroadcast = 2; - hevBlockQueue = hevBlockQueueB; - } - else { - nWaitersToUnblock++; - nWaitersBlocked--; - return unlock( mtxUnblockLock ); - } - } - else if ( nWaitersBlocked > nWaitersGone ) { // HARMLESS RACE CONDITION! - wait( hevBlockLock,INFINITE ); // close the gate - if ( 0 != nWaitersGone ) { - nWaitersBlocked -= nWaitersGone; - nWaitersGone = 0; - } - if (bAll) { - nWaitersToUnblock = nWaitersBlocked; - nWaitersBlocked = 0; - eBroadcast = 1; - hevBlockQueue = hevBlockQueueB; - } - else { - nWaitersToUnblock = 1; - nWaitersBlocked--; - hevBlockQueue = hevBlockQueueS; - } - } - else { // NO-OP - return unlock( mtxUnblockLock ); - } - - unlock( mtxUnblockLock ); - set_event( hevBlockQueue ); - return result; -} ----------------------- Forwarded by Alexander Terekhov/Germany/IBM on -02/21/2001 09:13 AM --------------------------- - -Alexander Terekhov -02/20/2001 04:33 PM - -To: Louis Thomas -cc: - -From: Alexander Terekhov/Germany/IBM@IBMDE -Subject: RE: FYI/comp.programming.threads/Re: pthread_cond_* implementatio - n questions -Importance: Normal - ->Sorry, gotta take a break and work on something else for a while. ->Real work ->calls, unfortunately. I'll get back to you in two or three days. - -ok. no problem. here is some more stuff for pauses you might have -in between :) - ----------- Algorithm 7d / IMPL_EVENT,UNBLOCK_STRATEGY == UNBLOCK_ALL ------ -given: -hevBlockLock - auto-reset event -hevBlockQueueS - auto-reset event // for signals -hevBlockQueueB - manual-reset even // for broadcasts -mtxExternal - mutex or CS -mtxUnblockLock - mutex or CS -bBroadcast - int -nWaitersGone - int -nWaitersBlocked - int -nWaitersToUnblock - int - -wait( timeout ) { - - [auto: register int result ] // error checking omitted - [auto: register int bWasBroadcast ] - [auto: register int nSignalsWasLeft ] - - wait( hevBlockLock,INFINITE ); - nWaitersBlocked++; - set_event( hevBlockLock ); - - unlock( mtxExternal ); - bTimedOut = waitformultiple( hevBlockQueueS,hevBlockQueueB,timeout,ONE ); - - lock( mtxUnblockLock ); - if ( 0 != (SignalsWasLeft = nWaitersToUnblock) ) { - if ( bTimeout ) { // timeout (or canceled) - if ( 0 != nWaitersBlocked ) { - nWaitersBlocked--; - nSignalsWasLeft = 0; // do not unblock next waiter -below (already unblocked) - } - else if ( !bBroadcast ) { - wait( hevBlockQueueS,INFINITE ); // better now than spurious -later - } - } - if ( 0 == --nWaitersToUnblock ) { - if ( 0 != nWaitersBlocked ) { - if ( bBroadcast ) { - reset_event( hevBlockQueueB ); - bBroadcast = false; - } - set_event( hevBlockLock ); // open the gate - nSignalsWasLeft = 0; // do not open the gate below -again - } - else if ( false != (bWasBroadcast = bBroadcast) ) { - bBroadcast = false; - } - } - else { - bWasBroadcast = bBroadcast; - } - } - else if ( INT_MAX/2 == ++nWaitersGone ) { // timeout/canceled or spurious -event :-) - wait( hevBlockLock,INFINITE ); - nWaitersBlocked -= nWaitersGone; // something is going on here - -test of timeouts? :-) - set_event( hevBlockLock ); - nWaitersGone = 0; - } - unlock( mtxUnblockLock ); - - if ( 1 == nSignalsWasLeft ) { - if ( bWasBroadcast ) { - reset_event( hevBlockQueueB ); - } - set_event( hevBlockLock ); // open the gate - } - else if ( 0 != nSignalsWasLeft && !bWasBroadcast ) { - set_event( hevBlockQueueS ); // unblock next waiter - } - - lock( mtxExternal ); - - return ( bTimedOut ) ? ETIMEOUT : 0; -} - -signal(bAll) { - - [auto: register int result ] - [auto: register HANDLE hevBlockQueue ] - - lock( mtxUnblockLock ); - - if ( 0 != nWaitersToUnblock ) { // the gate is closed!!! - if ( 0 == nWaitersBlocked ) { // NO-OP - return unlock( mtxUnblockLock ); - } - if (bAll) { - nWaitersToUnblock += nWaitersBlocked; - nWaitersBlocked = 0; - bBroadcast = true; - hevBlockQueue = hevBlockQueueB; - } - else { - nWaitersToUnblock++; - nWaitersBlocked--; - return unlock( mtxUnblockLock ); - } - } - else if ( nWaitersBlocked > nWaitersGone ) { // HARMLESS RACE CONDITION! - wait( hevBlockLock,INFINITE ); // close the gate - if ( 0 != nWaitersGone ) { - nWaitersBlocked -= nWaitersGone; - nWaitersGone = 0; - } - if (bAll) { - nWaitersToUnblock = nWaitersBlocked; - nWaitersBlocked = 0; - bBroadcast = true; - hevBlockQueue = hevBlockQueueB; - } - else { - nWaitersToUnblock = 1; - nWaitersBlocked--; - hevBlockQueue = hevBlockQueueS; - } - } - else { // NO-OP - return unlock( mtxUnblockLock ); - } - - unlock( mtxUnblockLock ); - set_event( hevBlockQueue ); - return result; -} - - ----------------------------------------------------------------------------- - -Subject: RE: FYI/comp.programming.threads/Re: pthread_cond_* implementatio - n questions -Date: Mon, 26 Feb 2001 22:20:12 -0600 -From: Louis Thomas -To: "'TEREKHOV@de.ibm.com'" -CC: rpj@ise.canberra.edu.au, Thomas Pfaff , - Nanbor Wang - - -Sorry all. Busy week. - -> this insures the fairness -> which POSIX does not (e.g. two subsequent broadcasts - the gate does -insure -> that first wave waiters will start the race for the mutex before waiters -> from the second wave - Linux pthreads process/unblock both waves -> concurrently...) - -I'm not sure how we are any more fair about this than Linux. We certainly -don't guarantee that the threads released by the first broadcast will get -the external mutex before the threads of the second wave. In fact, it is -possible that those threads will never get the external mutex if there is -enough contention for it. - -> e.g. i was thinking about implementation with a pool of -> N semaphores/counters [...] - -I considered that too. The problem is as you mentioned in a). You really -need to assign threads to semaphores once you know how you want to wake them -up, not when they first begin waiting which is the only time you can assign -them. - -> well, i am not quite sure that i've fully understood your scenario, - -Hmm. Well, it think it's an important example, so I'll try again. First, we -have thread A which we KNOW is waiting on a condition. As soon as it becomes -unblocked for any reason, we will know because it will set a flag. Since the -flag is not set, we are 100% confident that thread A is waiting on the -condition. We have another thread, thread B, which has acquired the mutex -and is about to wait on the condition. Thus it is pretty clear that at any -point, either just A is waiting, or A and B are waiting. Now thread C comes -along. C is about to do a broadcast on the condition. A broadcast is -guaranteed to unblock all threads currently waiting on a condition, right? -Again, we said that either just A is waiting, or A and B are both waiting. -So, when C does its broadcast, depending upon whether B has started waiting -or not, thread C will unblock A or unblock A and B. Either way, C must -unblock A, right? - -Now, you said anything that happens is correct so long as a) "a signal is -not lost between unlocking the mutex and waiting on the condition" and b) "a -thread must not steal a signal it sent", correct? Requirement b) is easy to -satisfy: in this scenario, thread C will never wait on the condition, so it -won't steal any signals. Requirement a) is not hard either. The only way we -could fail to meet requirement a) in this scenario is if thread B was -started waiting but didn't wake up because a signal was lost. This will not -happen. - -Now, here is what happens. Assume thread C beats thread B. Thread C looks to -see how many threads are waiting on the condition. Thread C sees just one -thread, thread A, waiting. It does a broadcast waking up just one thread -because just one thread is waiting. Next, before A can become unblocked, -thread B begins waiting. Now there are two threads waiting, but only one -will be unblocked. Suppose B wins. B will become unblocked. A will not -become unblocked, because C only unblocked one thread (sema_post cond, 1). -So at the end, B finishes and A remains blocked. - -We have met both of your requirements, so by your rules, this is an -acceptable outcome. However, I think that the spec says this is an -unacceptable outcome! We know for certain that A was waiting and that C did -a broadcast, but A did not become unblocked! Yet, the spec says that a -broadcast wakes up all waiting threads. This did not happen. Do you agree -that this shows your rules are not strict enough? - -> and what about N2? :) this one does allow almost everything. - -Don't get me started about rule #2. I'll NEVER advocate an algorithm that -uses rule 2 as an excuse to suck! - -> but it is done (decrement)under mutex protection - this is not a subject -> of a race condition. - -You are correct. My mistake. - -> i would remove "_bTimedOut=false".. after all, it was a real timeout.. - -I disagree. A thread that can't successfully retract its waiter status can't -really have timed out. If a thread can't return without executing extra code -to deal with the fact that someone tried to unblock it, I think it is a poor -idea to pretend we -didn't realize someone was trying to signal us. After all, a signal is more -important than a time out. - -> when nSignaled != 0, it is possible to update nWaiters (--) and do not -> touch nGone - -I realize this, but I was thinking that writing it the other ways saves -another if statement. - -> adjust only if nGone != 0 and save one cache memory write - probably much -slower than 'if' - -Hmm. You are probably right. - -> well, in a strange (e.g. timeout test) program you may (theoretically) -> have an overflow of nWaiters/nGone counters (with waiters repeatedly -timing -> out and no signals at all). - -Also true. Not only that, but you also have the possibility that one could -overflow the number of waiters as well! However, considering the limit you -have chosen for nWaitersGone, I suppose it is unlikely that anyone would be -able to get INT_MAX/2 threads waiting on a single condition. :) - -Analysis of 8a: - -It looks correct to me. - -What are IPC semaphores? - -In the line where you state, "else if ( nWaitersBlocked > nWaitersGone ) { -// HARMLESS RACE CONDITION!" there is no race condition for nWaitersGone -because nWaitersGone is never modified without holding mtxUnblockLock. You -are correct that there is a harmless race on nWaitersBlocked, which can -increase and make the condition become true just after we check it. If this -happens, we interpret it as the wait starting after the signal. - -I like your optimization of this. You could improve Alg. 6 as follows: ----------- Algorithm 6b ---------- -signal(bAll) { - _nSig=0 - lock counters - // this is safe because nWaiting can only be decremented by a thread that - // owns counters and nGone can only be changed by a thread that owns -counters. - if (nWaiting>nGone) { - if (0==nSignaled) { - sema_wait gate // close gate if not already closed - } - if (nGone>0) { - nWaiting-=nGone - nGone=0 - } - _nSig=bAll?nWaiting:1 - nSignaled+=_nSig - nWaiting-=_nSig - } - unlock counters - if (0!=_nSig) { - sema_post queue, _nSig - } -} ----------- ---------- ---------- -I guess this wouldn't apply to Alg 8a because nWaitersGone changes meanings -depending upon whether the gate is open or closed. - -In the loop "while ( nWaitersWasGone-- ) {" you do a sema_wait on -semBlockLock. Perhaps waiting on semBlockQueue would be a better idea. - -What have you gained by making the last thread to be signaled do the waits -for all the timed out threads, besides added complexity? It took me a long -time to figure out what your objective was with this, to realize you were -using nWaitersGone to mean two different things, and to verify that you -hadn't introduced any bug by doing this. Even now I'm not 100% sure. - -What has all this playing about with nWaitersGone really gained us besides a -lot of complexity (it is much harder to verify that this solution is -correct), execution overhead (we now have a lot more if statements to -evaluate), and space overhead (more space for the extra code, and another -integer in our data)? We did manage to save a lock/unlock pair in an -uncommon case (when a time out occurs) at the above mentioned expenses in -the common cases. - -As for 8b, c, and d, they look ok though I haven't studied them thoroughly. -What would you use them for? - - Later, - -Louis! :) - ------------------------------------------------------------------------------ - -Subject: RE: FYI/comp.programming.threads/Re: pthread_cond_* implementatio - n questions -Date: Tue, 27 Feb 2001 15:51:28 +0100 -From: TEREKHOV@de.ibm.com -To: Louis Thomas -CC: rpj@ise.canberra.edu.au, Thomas Pfaff , - Nanbor Wang - -Hi Louis, - ->> that first wave waiters will start the race for the mutex before waiters ->> from the second wave - Linux pthreads process/unblock both waves ->> concurrently...) -> ->I'm not sure how we are any more fair about this than Linux. We certainly ->don't guarantee that the threads released by the first broadcast will get ->the external mutex before the threads of the second wave. In fact, it is ->possible that those threads will never get the external mutex if there is ->enough contention for it. - -correct. but gate is nevertheless more fair than Linux because of the -barrier it establishes between two races (1st and 2nd wave waiters) for -the mutex which under 'normal' circumstances (e.g. all threads of equal -priorities,..) will 'probably' result in fair behaviour with respect to -mutex ownership. - ->> well, i am not quite sure that i've fully understood your scenario, -> ->Hmm. Well, it think it's an important example, so I'll try again. ... - -ok. now i seem to understand this example. well, now it seems to me -that the only meaningful rule is just: - -a) "a signal is not lost between unlocking the mutex and waiting on the -condition" - -and that the rule - -b) "a thread must not steal a signal it sent" - -is not needed at all because a thread which violates b) also violates a). - -i'll try to explain.. - -i think that the most important thing is how POSIX defines waiter's -visibility: - -"if another thread is able to acquire the mutex after the about-to-block -thread -has released it, then a subsequent call to pthread_cond_signal() or -pthread_cond_broadcast() in that thread behaves as if it were issued after -the about-to-block thread has blocked. " - -my understanding is the following: - -1) there is no guarantees whatsoever with respect to whether -signal/broadcast -will actually unblock any 'waiter' if it is done w/o acquiring the mutex -first -(note that a thread may release it before signal/broadcast - it does not -matter). - -2) it is guaranteed that waiters become 'visible' - eligible for unblock as -soon -as signalling thread acquires the mutex (but not before!!) - -so.. - ->So, when C does its broadcast, depending upon whether B has started -waiting ->or not, thread C will unblock A or unblock A and B. Either way, C must ->unblock A, right? - -right. but only if C did acquire the mutex prior to broadcast (it may -release it before broadcast as well). - -implementation will violate waiters visibility rule (signal will become -lost) -if C will not unblock A. - ->Now, here is what happens. Assume thread C beats thread B. Thread C looks -to ->see how many threads are waiting on the condition. Thread C sees just one ->thread, thread A, waiting. It does a broadcast waking up just one thread ->because just one thread is waiting. Next, before A can become unblocked, ->thread B begins waiting. Now there are two threads waiting, but only one ->will be unblocked. Suppose B wins. B will become unblocked. A will not ->become unblocked, because C only unblocked one thread (sema_post cond, 1). ->So at the end, B finishes and A remains blocked. - -thread C did acquire the mutex ("Thread C sees just one thread, thread A, -waiting"). beginning from that moment it is guaranteed that subsequent -broadcast will unblock A. Otherwise we will have a lost signal with respect -to A. I do think that it does not matter whether the signal was physically -(completely) lost or was just stolen by another thread (B) - in both cases -it was simply lost with respect to A. - ->..Do you agree that this shows your rules are not strict enough? - -probably the opposite.. :-) i think that it shows that the only meaningful -rule is - -a) "a signal is not lost between unlocking the mutex and waiting on the -condition" - -with clarification of waiters visibility as defined by POSIX above. - ->> i would remove "_bTimedOut=false".. after all, it was a real timeout.. -> ->I disagree. A thread that can't successfully retract its waiter status -can't ->really have timed out. If a thread can't return without executing extra -code ->to deal with the fact that someone tried to unblock it, I think it is a -poor ->idea to pretend we ->didn't realize someone was trying to signal us. After all, a signal is -more ->important than a time out. - -a) POSIX does allow timed out thread to consume a signal (cancelled is -not). -b) ETIMEDOUT status just says that: "The time specified by abstime to -pthread_cond_timedwait() has passed." -c) it seem to me that hiding timeouts would violate "The -pthread_cond_timedwait() -function is the same as pthread_cond_wait() except that an error is -returned if -the absolute time specified by abstime passes (that is, system time equals -or -exceeds abstime) before the condition cond is signaled or broadcasted" -because -the abs. time did really pass before cond was signaled (waiter was -released via semaphore). however, if it really matters, i could imaging -that we -can save an abs. time of signal/broadcast and compare it with timeout after -unblock to find out whether it was a 'real' timeout or not. absent this -check -i do think that hiding timeouts would result in technical violation of -specification.. but i think that this check is not important and we can -simply -trust timeout error code provided by wait since we are not trying to make -'hard' realtime implementation. - ->What are IPC semaphores? - - -int semctl(int, int, int, ...); -int semget(key_t, int, int); -int semop(int, struct sembuf *, size_t); - -they support adjustment of semaphore counter (semvalue) -in one single call - imaging Win32 ReleaseSemaphore( hsem,-N ) - ->In the line where you state, "else if ( nWaitersBlocked > nWaitersGone ) { ->// HARMLESS RACE CONDITION!" there is no race condition for nWaitersGone ->because nWaitersGone is never modified without holding mtxUnblockLock. You ->are correct that there is a harmless race on nWaitersBlocked, which can ->increase and make the condition become true just after we check it. If -this ->happens, we interpret it as the wait starting after the signal. - -well, the reason why i've asked on comp.programming.threads whether this -race -condition is harmless or not is that in order to be harmless it should not -violate the waiters visibility rule (see above). Fortunately, we increment -the counter under protection of external mutex.. so that any (signalling) -thread which will acquire the mutex next, should see the updated counter -(in signal) according to POSIX memory visibility rules and mutexes -(memory barriers). But i am not so sure how it actually works on -Win32/INTEL -which does not explicitly define any memory visibility rules :( - ->I like your optimization of this. You could improve Alg. 6 as follows: ->---------- Algorithm 6b ---------- ->signal(bAll) { -> _nSig=0 -> lock counters -> // this is safe because nWaiting can only be decremented by a thread -that -> // owns counters and nGone can only be changed by a thread that owns ->counters. -> if (nWaiting>nGone) { -> if (0==nSignaled) { -> sema_wait gate // close gate if not already closed -> } -> if (nGone>0) { -> nWaiting-=nGone -> nGone=0 -> } -> _nSig=bAll?nWaiting:1 -> nSignaled+=_nSig -> nWaiting-=_nSig -> } -> unlock counters -> if (0!=_nSig) { -> sema_post queue, _nSig -> } ->} ->---------- ---------- ---------- ->I guess this wouldn't apply to Alg 8a because nWaitersGone changes -meanings ->depending upon whether the gate is open or closed. - -agree. - ->In the loop "while ( nWaitersWasGone-- ) {" you do a sema_wait on ->semBlockLock. Perhaps waiting on semBlockQueue would be a better idea. - -you are correct. my mistake. - ->What have you gained by making the last thread to be signaled do the waits ->for all the timed out threads, besides added complexity? It took me a long ->time to figure out what your objective was with this, to realize you were ->using nWaitersGone to mean two different things, and to verify that you ->hadn't introduced any bug by doing this. Even now I'm not 100% sure. -> ->What has all this playing about with nWaitersGone really gained us besides -a ->lot of complexity (it is much harder to verify that this solution is ->correct), execution overhead (we now have a lot more if statements to ->evaluate), and space overhead (more space for the extra code, and another ->integer in our data)? We did manage to save a lock/unlock pair in an ->uncommon case (when a time out occurs) at the above mentioned expenses in ->the common cases. - -well, please consider the following: - -1) with multiple waiters unblocked (but some timed out) the trick with -counter -seem to ensure potentially higher level of concurrency by not delaying -most of unblocked waiters for semaphore cleanup - only the last one -will be delayed but all others would already contend/acquire/release -the external mutex - the critical section protected by mtxUnblockLock is -made smaller (increment + couple of IFs is faster than system/kernel call) -which i think is good in general. however, you are right, this is done -at expense of 'normal' waiters.. - -2) some semaphore APIs (e.g. POSIX IPC sems) do allow to adjust the -semaphore counter in one call => less system/kernel calls.. imagine: - -if ( 1 == nSignalsWasLeft ) { - if ( 0 != nWaitersWasGone ) { - ReleaseSemaphore( semBlockQueue,-nWaitersWasGone ); // better now -than spurious later - } - sem_post( semBlockLock ); // open the gate - } - -3) even on win32 a single thread doing multiple cleanup calls (to wait) -will probably result in faster execution (because of processor caching) -than multiple threads each doing a single call to wait. - ->As for 8b, c, and d, they look ok though I haven't studied them -thoroughly. ->What would you use them for? - -8b) for semaphores which do not allow to unblock multiple waiters -in a single call to post/release (e.g. POSIX realtime semaphores - -) - -8c/8d) for WinCE prior to 3.0 (WinCE 3.0 does have semaphores) - -ok. so, which one is the 'final' algorithm(s) which we should use in -pthreads-win32?? - -regards, -alexander. - ----------------------------------------------------------------------------- - -Louis Thomas on 02/27/2001 05:20:12 AM - -Please respond to Louis Thomas - -To: Alexander Terekhov/Germany/IBM@IBMDE -cc: rpj@ise.canberra.edu.au, Thomas Pfaff , Nanbor Wang - -Subject: RE: FYI/comp.programming.threads/Re: pthread_cond_* implementatio - n questions - -Sorry all. Busy week. - -> this insures the fairness -> which POSIX does not (e.g. two subsequent broadcasts - the gate does -insure -> that first wave waiters will start the race for the mutex before waiters -> from the second wave - Linux pthreads process/unblock both waves -> concurrently...) - -I'm not sure how we are any more fair about this than Linux. We certainly -don't guarantee that the threads released by the first broadcast will get -the external mutex before the threads of the second wave. In fact, it is -possible that those threads will never get the external mutex if there is -enough contention for it. - -> e.g. i was thinking about implementation with a pool of -> N semaphores/counters [...] - -I considered that too. The problem is as you mentioned in a). You really -need to assign threads to semaphores once you know how you want to wake -them -up, not when they first begin waiting which is the only time you can assign -them. - -> well, i am not quite sure that i've fully understood your scenario, - -Hmm. Well, it think it's an important example, so I'll try again. First, we -have thread A which we KNOW is waiting on a condition. As soon as it -becomes -unblocked for any reason, we will know because it will set a flag. Since -the -flag is not set, we are 100% confident that thread A is waiting on the -condition. We have another thread, thread B, which has acquired the mutex -and is about to wait on the condition. Thus it is pretty clear that at any -point, either just A is waiting, or A and B are waiting. Now thread C comes -along. C is about to do a broadcast on the condition. A broadcast is -guaranteed to unblock all threads currently waiting on a condition, right? -Again, we said that either just A is waiting, or A and B are both waiting. -So, when C does its broadcast, depending upon whether B has started waiting -or not, thread C will unblock A or unblock A and B. Either way, C must -unblock A, right? - -Now, you said anything that happens is correct so long as a) "a signal is -not lost between unlocking the mutex and waiting on the condition" and b) -"a -thread must not steal a signal it sent", correct? Requirement b) is easy to -satisfy: in this scenario, thread C will never wait on the condition, so it -won't steal any signals. Requirement a) is not hard either. The only way -we -could fail to meet requirement a) in this scenario is if thread B was -started waiting but didn't wake up because a signal was lost. This will not -happen. - -Now, here is what happens. Assume thread C beats thread B. Thread C looks -to -see how many threads are waiting on the condition. Thread C sees just one -thread, thread A, waiting. It does a broadcast waking up just one thread -because just one thread is waiting. Next, before A can become unblocked, -thread B begins waiting. Now there are two threads waiting, but only one -will be unblocked. Suppose B wins. B will become unblocked. A will not -become unblocked, because C only unblocked one thread (sema_post cond, 1). -So at the end, B finishes and A remains blocked. - -We have met both of your requirements, so by your rules, this is an -acceptable outcome. However, I think that the spec says this is an -unacceptable outcome! We know for certain that A was waiting and that C did -a broadcast, but A did not become unblocked! Yet, the spec says that a -broadcast wakes up all waiting threads. This did not happen. Do you agree -that this shows your rules are not strict enough? - -> and what about N2? :) this one does allow almost everything. - -Don't get me started about rule #2. I'll NEVER advocate an algorithm that -uses rule 2 as an excuse to suck! - -> but it is done (decrement)under mutex protection - this is not a subject -> of a race condition. - -You are correct. My mistake. - -> i would remove "_bTimedOut=false".. after all, it was a real timeout.. - -I disagree. A thread that can't successfully retract its waiter status -can't -really have timed out. If a thread can't return without executing extra -code -to deal with the fact that someone tried to unblock it, I think it is a -poor -idea to pretend we -didn't realize someone was trying to signal us. After all, a signal is more -important than a time out. - -> when nSignaled != 0, it is possible to update nWaiters (--) and do not -> touch nGone - -I realize this, but I was thinking that writing it the other ways saves -another if statement. - -> adjust only if nGone != 0 and save one cache memory write - probably much -slower than 'if' - -Hmm. You are probably right. - -> well, in a strange (e.g. timeout test) program you may (theoretically) -> have an overflow of nWaiters/nGone counters (with waiters repeatedly -timing -> out and no signals at all). - -Also true. Not only that, but you also have the possibility that one could -overflow the number of waiters as well! However, considering the limit you -have chosen for nWaitersGone, I suppose it is unlikely that anyone would be -able to get INT_MAX/2 threads waiting on a single condition. :) - -Analysis of 8a: - -It looks correct to me. - -What are IPC semaphores? - -In the line where you state, "else if ( nWaitersBlocked > nWaitersGone ) { -// HARMLESS RACE CONDITION!" there is no race condition for nWaitersGone -because nWaitersGone is never modified without holding mtxUnblockLock. You -are correct that there is a harmless race on nWaitersBlocked, which can -increase and make the condition become true just after we check it. If this -happens, we interpret it as the wait starting after the signal. - -I like your optimization of this. You could improve Alg. 6 as follows: ----------- Algorithm 6b ---------- -signal(bAll) { - _nSig=0 - lock counters - // this is safe because nWaiting can only be decremented by a thread that - // owns counters and nGone can only be changed by a thread that owns -counters. - if (nWaiting>nGone) { - if (0==nSignaled) { - sema_wait gate // close gate if not already closed - } - if (nGone>0) { - nWaiting-=nGone - nGone=0 - } - _nSig=bAll?nWaiting:1 - nSignaled+=_nSig - nWaiting-=_nSig - } - unlock counters - if (0!=_nSig) { - sema_post queue, _nSig - } -} ----------- ---------- ---------- -I guess this wouldn't apply to Alg 8a because nWaitersGone changes meanings -depending upon whether the gate is open or closed. - -In the loop "while ( nWaitersWasGone-- ) {" you do a sema_wait on -semBlockLock. Perhaps waiting on semBlockQueue would be a better idea. - -What have you gained by making the last thread to be signaled do the waits -for all the timed out threads, besides added complexity? It took me a long -time to figure out what your objective was with this, to realize you were -using nWaitersGone to mean two different things, and to verify that you -hadn't introduced any bug by doing this. Even now I'm not 100% sure. - -What has all this playing about with nWaitersGone really gained us besides -a -lot of complexity (it is much harder to verify that this solution is -correct), execution overhead (we now have a lot more if statements to -evaluate), and space overhead (more space for the extra code, and another -integer in our data)? We did manage to save a lock/unlock pair in an -uncommon case (when a time out occurs) at the above mentioned expenses in -the common cases. - -As for 8b, c, and d, they look ok though I haven't studied them thoroughly. -What would you use them for? - - Later, - -Louis! :) - diff --git a/deps/w32-pthreads/README.NONPORTABLE b/deps/w32-pthreads/README.NONPORTABLE deleted file mode 100644 index 9bdc445..0000000 --- a/deps/w32-pthreads/README.NONPORTABLE +++ /dev/null @@ -1,783 +0,0 @@ -This file documents non-portable functions and other issues. - -Non-portable functions included in pthreads-win32 -------------------------------------------------- - -BOOL -pthread_win32_test_features_np(int mask) - - This routine allows an application to check which - run-time auto-detected features are available within - the library. - - The possible features are: - - PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE - Return TRUE if the native version of - InterlockedCompareExchange() is being used. - This feature is not meaningful in recent - library versions as MSVC builds only support - system implemented ICE. Note that all Mingw - builds use inlined asm versions of all the - Interlocked routines. - PTW32_ALERTABLE_ASYNC_CANCEL - Return TRUE is the QueueUserAPCEx package - QUSEREX.DLL is available and the AlertDrv.sys - driver is loaded into Windows, providing - alertable (pre-emptive) asyncronous threads - cancelation. If this feature returns FALSE - then the default async cancel scheme is in - use, which cannot cancel blocked threads. - - Features may be Or'ed into the mask parameter, in which case - the routine returns TRUE if any of the Or'ed features would - return TRUE. At this stage it doesn't make sense to Or features - but it may some day. - - -void * -pthread_timechange_handler_np(void *) - - To improve tolerance against operator or time service - initiated system clock changes. - - This routine can be called by an application when it - receives a WM_TIMECHANGE message from the system. At - present it broadcasts all condition variables so that - waiting threads can wake up and re-evaluate their - conditions and restart their timed waits if required. - - It has the same return type and argument type as a - thread routine so that it may be called directly - through pthread_create(), i.e. as a separate thread. - - Parameters - - Although a parameter must be supplied, it is ignored. - The value NULL can be used. - - Return values - - It can return an error EAGAIN to indicate that not - all condition variables were broadcast for some reason. - Otherwise, 0 is returned. - - If run as a thread, the return value is returned - through pthread_join(). - - The return value should be cast to an integer. - - -HANDLE -pthread_getw32threadhandle_np(pthread_t thread); - - Returns the win32 thread handle that the POSIX - thread "thread" is running as. - - Applications can use the win32 handle to set - win32 specific attributes of the thread. - -DWORD -pthread_getw32threadid_np (pthread_t thread) - - Returns the Windows native thread ID that the POSIX - thread "thread" is running as. - - Only valid when the library is built where - ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) - and otherwise returns 0. - - -int -pthread_mutexattr_setkind_np(pthread_mutexattr_t * attr, int kind) - -int -pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr, int *kind) - - These two routines are included for Linux compatibility - and are direct equivalents to the standard routines - pthread_mutexattr_settype - pthread_mutexattr_gettype - - pthread_mutexattr_setkind_np accepts the following - mutex kinds: - PTHREAD_MUTEX_FAST_NP - PTHREAD_MUTEX_ERRORCHECK_NP - PTHREAD_MUTEX_RECURSIVE_NP - - These are really just equivalent to (respectively): - PTHREAD_MUTEX_NORMAL - PTHREAD_MUTEX_ERRORCHECK - PTHREAD_MUTEX_RECURSIVE - -int -pthread_delay_np (const struct timespec *interval); - - This routine causes a thread to delay execution for a specific period of time. - This period ends at the current time plus the specified interval. The routine - will not return before the end of the period is reached, but may return an - arbitrary amount of time after the period has gone by. This can be due to - system load, thread priorities, and system timer granularity. - - Specifying an interval of zero (0) seconds and zero (0) nanoseconds is - allowed and can be used to force the thread to give up the processor or to - deliver a pending cancelation request. - - This routine is a cancelation point. - - The timespec structure contains the following two fields: - - tv_sec is an integer number of seconds. - tv_nsec is an integer number of nanoseconds. - - Return Values - - If an error condition occurs, this routine returns an integer value - indicating the type of error. Possible return values are as follows: - - 0 Successful completion. - [EINVAL] The value specified by interval is invalid. - -int -pthread_num_processors_np (void) - - This routine (found on HPUX systems) returns the number of processors - in the system. This implementation actually returns the number of - processors available to the process, which can be a lower number - than the system's number, depending on the process's affinity mask. - -BOOL -pthread_win32_process_attach_np (void); - -BOOL -pthread_win32_process_detach_np (void); - -BOOL -pthread_win32_thread_attach_np (void); - -BOOL -pthread_win32_thread_detach_np (void); - - These functions contain the code normally run via dllMain - when the library is used as a dll but which need to be - called explicitly by an application when the library - is statically linked. As of version 2.9.0 of the library, static - builds using either MSC or GCC will call pthread_win32_process_* - automatically at application startup and exit respectively. - - Otherwise, you will need to call pthread_win32_process_attach_np() - before you can call any pthread routines when statically linking. - You should call pthread_win32_process_detach_np() before - exiting your application to clean up. - - pthread_win32_thread_attach_np() is currently a no-op, but - pthread_win32_thread_detach_np() is needed to clean up - the implicit pthread handle that is allocated to a Win32 thread if - it calls any pthreads routines. Call this routine when the - Win32 thread exits. - - Threads created through pthread_create() do not need to call - pthread_win32_thread_detach_np(). - - These functions invariably return TRUE except for - pthread_win32_process_attach_np() which will return FALSE - if pthreads-win32 initialisation fails. - -int -pthreadCancelableWait (HANDLE waitHandle); - -int -pthreadCancelableTimedWait (HANDLE waitHandle, DWORD timeout); - - These two functions provide hooks into the pthread_cancel - mechanism that will allow you to wait on a Windows handle - and make it a cancellation point. Both functions block - until either the given w32 handle is signaled, or - pthread_cancel has been called. It is implemented using - WaitForMultipleObjects on 'waitHandle' and a manually - reset w32 event used to implement pthread_cancel. - - -Non-portable issues -------------------- - -Thread priority - - POSIX defines a single contiguous range of numbers that determine a - thread's priority. Win32 defines priority classes and priority - levels relative to these classes. Classes are simply priority base - levels that the defined priority levels are relative to such that, - changing a process's priority class will change the priority of all - of it's threads, while the threads retain the same relativity to each - other. - - A Win32 system defines a single contiguous monotonic range of values - that define system priority levels, just like POSIX. However, Win32 - restricts individual threads to a subset of this range on a - per-process basis. - - The following table shows the base priority levels for combinations - of priority class and priority value in Win32. - - Process Priority Class Thread Priority Level - ----------------------------------------------------------------- - 1 IDLE_PRIORITY_CLASS THREAD_PRIORITY_IDLE - 1 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_IDLE - 1 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_IDLE - 1 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_IDLE - 1 HIGH_PRIORITY_CLASS THREAD_PRIORITY_IDLE - 2 IDLE_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - 3 IDLE_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - 4 IDLE_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - 4 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - 5 IDLE_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - 5 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - 5 Background NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - 6 IDLE_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - 6 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - 6 Background NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - 7 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - 7 Background NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - 7 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - 8 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - 8 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - 8 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - 8 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - 9 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - 9 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - 9 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - 10 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - 10 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - 11 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - 11 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - 11 HIGH_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - 12 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - 12 HIGH_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - 13 HIGH_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - 14 HIGH_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - 15 HIGH_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - 15 HIGH_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - 15 IDLE_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - 15 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - 15 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - 15 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - 16 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_IDLE - 17 REALTIME_PRIORITY_CLASS -7 - 18 REALTIME_PRIORITY_CLASS -6 - 19 REALTIME_PRIORITY_CLASS -5 - 20 REALTIME_PRIORITY_CLASS -4 - 21 REALTIME_PRIORITY_CLASS -3 - 22 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - 23 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - 24 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - 25 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - 26 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - 27 REALTIME_PRIORITY_CLASS 3 - 28 REALTIME_PRIORITY_CLASS 4 - 29 REALTIME_PRIORITY_CLASS 5 - 30 REALTIME_PRIORITY_CLASS 6 - 31 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - - Windows NT: Values -7, -6, -5, -4, -3, 3, 4, 5, and 6 are not supported. - - - As you can see, the real priority levels available to any individual - Win32 thread are non-contiguous. - - An application using pthreads-win32 should not make assumptions about - the numbers used to represent thread priority levels, except that they - are monotonic between the values returned by sched_get_priority_min() - and sched_get_priority_max(). E.g. Windows 95, 98, NT, 2000, XP make - available a non-contiguous range of numbers between -15 and 15, while - at least one version of WinCE (3.0) defines the minimum priority - (THREAD_PRIORITY_LOWEST) as 5, and the maximum priority - (THREAD_PRIORITY_HIGHEST) as 1. - - Internally, pthreads-win32 maps any priority levels between - THREAD_PRIORITY_IDLE and THREAD_PRIORITY_LOWEST to THREAD_PRIORITY_LOWEST, - or between THREAD_PRIORITY_TIME_CRITICAL and THREAD_PRIORITY_HIGHEST to - THREAD_PRIORITY_HIGHEST. Currently, this also applies to - REALTIME_PRIORITY_CLASSi even if levels -7, -6, -5, -4, -3, 3, 4, 5, and 6 - are supported. - - If it wishes, a Win32 application using pthreads-win32 can use the Win32 - defined priority macros THREAD_PRIORITY_IDLE through - THREAD_PRIORITY_TIME_CRITICAL. - - -The opacity of the pthread_t datatype -------------------------------------- -and possible solutions for portable null/compare/hash, etc ----------------------------------------------------------- - -Because pthread_t is an opague datatype an implementation is permitted to define -pthread_t in any way it wishes. That includes defining some bits, if it is -scalar, or members, if it is an aggregate, to store information that may be -extra to the unique identifying value of the ID. As a result, pthread_t values -may not be directly comparable. - -If you want your code to be portable you must adhere to the following contraints: - -1) Don't assume it is a scalar data type, e.g. an integer or pointer value. There -are several other implementations where pthread_t is also a struct. See our FAQ -Question 11 for our reasons for defining pthread_t as a struct. - -2) You must not compare them using relational or equality operators. You must use -the API function pthread_equal() to test for equality. - -3) Never attempt to reference individual members. - - -The problem - -Certain applications would like to be able to access only the 'pure' pthread_t -id values, primarily to use as keys into data structures to manage threads or -thread-related data, but this is not possible in a maximally portable and -standards compliant way for current POSIX threads implementations. - -For implementations that define pthread_t as a scalar, programmers often employ -direct relational and equality operators on pthread_t. This code will break when -ported to an implementation that defines pthread_t as an aggregate type. - -For implementations that define pthread_t as an aggregate, e.g. a struct, -programmers can use memcmp etc., but then face the prospect that the struct may -include alignment padding bytes or bits as well as extra implementation-specific -members that are not part of the unique identifying value. - -[While this is not currently the case for pthreads-win32, opacity also -means that an implementation is free to change the definition, which should -generally only require that applications be recompiled and relinked, not -rewritten.] - - -Doesn't the compiler take care of padding? - -The C89 and later standards only effectively guarrantee element-by-element -equivalence following an assignment or pass by value of a struct or union, -therefore undefined areas of any two otherwise equivalent pthread_t instances -can still compare differently, e.g. attempting to compare two such pthread_t -variables byte-by-byte, e.g. memcmp(&t1, &t2, sizeof(pthread_t) may give an -incorrect result. In practice I'm reasonably confident that compilers routinely -also copy the padding bytes, mainly because assignment of unions would be far -too complicated otherwise. But it just isn't guarranteed by the standard. - -Illustration: - -We have two thread IDs t1 and t2 - -pthread_t t1, t2; - -In an application we create the threads and intend to store the thread IDs in an -ordered data structure (linked list, tree, etc) so we need to be able to compare -them in order to insert them initially and also to traverse. - -Suppose pthread_t contains undefined padding bits and our compiler copies our -pthread_t [struct] element-by-element, then for the assignment: - -pthread_t temp = t1; - -temp and t1 will be equivalent and correct but a byte-for-byte comparison such as -memcmp(&temp, &t1, sizeof(pthread_t)) == 0 may not return true as we expect because -the undefined bits may not have the same values in the two variable instances. - -Similarly if passing by value under the same conditions. - -If, on the other hand, the undefined bits are at least constant through every -assignment and pass-by-value then the byte-for-byte comparison -memcmp(&temp, &t1, sizeof(pthread_t)) == 0 will always return the expected result. -How can we force the behaviour we need? - - -Solutions - -Adding new functions to the standard API or as non-portable extentions is -the only reliable and portable way to provide the necessary operations. -Remember also that POSIX is not tied to the C language. The most common -functions that have been suggested are: - -pthread_null() -pthread_compare() -pthread_hash() - -A single more general purpose function could also be defined as a -basis for at least the last two of the above functions. - -First we need to list the freedoms and constraints with restpect -to pthread_t so that we can be sure our solution is compatible with the -standard. - -What is known or may be deduced from the standard: -1) pthread_t must be able to be passed by value, so it must be a single object. -2) from (1) it must be copyable so cannot embed thread-state information, locks -or other volatile objects required to manage the thread it associates with. -3) pthread_t may carry additional information, e.g. for debugging or to manage -itself. -4) there is an implicit requirement that the size of pthread_t is determinable -at compile-time and size-invariant, because it must be able to copy the object -(i.e. through assignment and pass-by-value). Such copies must be genuine -duplicates, not merely a copy of a pointer to a common instance such as -would be the case if pthread_t were defined as an array. - - -Suppose we define the following function: - -/* This function shall return it's argument */ -pthread_t* pthread_normalize(pthread_t* thread); - -For scalar or aggregate pthread_t types this function would simply zero any bits -within the pthread_t that don't uniquely identify the thread, including padding, -such that client code can return consistent results from operations done on the -result. If the additional bits are a pointer to an associate structure then -this function would ensure that the memory used to store that associate -structure does not leak. After normalization the following compare would be -valid and repeatable: - -memcmp(pthread_normalize(&t1),pthread_normalize(&t2),sizeof(pthread_t)) - -Note 1: such comparisons are intended merely to order and sort pthread_t values -and allow them to index various data structures. They are not intended to reveal -anything about the relationships between threads, like startup order. - -Note 2: the normalized pthread_t is also a valid pthread_t that uniquely -identifies the same thread. - -Advantages: -1) In most existing implementations this function would reduce to a no-op that -emits no additional instructions, i.e after in-lining or optimisation, or if -defined as a macro: -#define pthread_normalise(tptr) (tptr) - -2) This single function allows an application to portably derive -application-level versions of any of the other required functions. - -3) It is a generic function that could enable unanticipated uses. - -Disadvantages: -1) Less efficient than dedicated compare or hash functions for implementations -that include significant extra non-id elements in pthread_t. - -2) Still need to be concerned about padding if copying normalized pthread_t. -See the later section on defining pthread_t to neutralise padding issues. - -Generally a pthread_t may need to be normalized every time it is used, -which could have a significant impact. However, this is a design decision -for the implementor in a competitive environment. An implementation is free -to define a pthread_t in a way that minimises or eliminates padding or -renders this function a no-op. - -Hazards: -1) Pass-by-reference directly modifies 'thread' so the application must -synchronise access or ensure that the pointer refers to a copy. The alternative -of pass-by-value/return-by-value was considered but then this requires two copy -operations, disadvantaging implementations where this function is not a no-op -in terms of speed of execution. This function is intended to be used in high -frequency situations and needs to be efficient, or at least not unnecessarily -inefficient. The alternative also sits awkwardly with functions like memcmp. - -2) [Non-compliant] code that uses relational and equality operators on -arithmetic or pointer style pthread_t types would need to be rewritten, but it -should be rewritten anyway. - - -C implementation of null/compare/hash functions using pthread_normalize(): - -/* In pthread.h */ -pthread_t* pthread_normalize(pthread_t* thread); - -/* In user code */ -/* User-level bitclear function - clear bits in loc corresponding to mask */ -void* bitclear (void* loc, void* mask, size_t count); - -typedef unsigned int hash_t; - -/* User-level hash function */ -hash_t hash(void* ptr, size_t count); - -/* - * User-level pthr_null function - modifies the origin thread handle. - * The concept of a null pthread_t is highly implementation dependent - * and this design may be far from the mark. For example, in an - * implementation "null" may mean setting a special value inside one - * element of pthread_t to mean "INVALID". However, if that value was zero and - * formed part of the id component then we may get away with this design. - */ -pthread_t* pthr_null(pthread_t* tp) -{ - /* - * This should have the same effect as memset(tp, 0, sizeof(pthread_t)) - * We're just showing that we can do it. - */ - void* p = (void*) pthread_normalize(tp); - return (pthread_t*) bitclear(p, p, sizeof(pthread_t)); -} - -/* - * Safe user-level pthr_compare function - modifies temporary thread handle copies - */ -int pthr_compare_safe(pthread_t thread1, pthread_t thread2) -{ - return memcmp(pthread_normalize(&thread1), pthread_normalize(&thread2), sizeof(pthread_t)); -} - -/* - * Fast user-level pthr_compare function - modifies origin thread handles - */ -int pthr_compare_fast(pthread_t* thread1, pthread_t* thread2) -{ - return memcmp(pthread_normalize(&thread1), pthread_normalize(&thread2), sizeof(pthread_t)); -} - -/* - * Safe user-level pthr_hash function - modifies temporary thread handle copy - */ -hash_t pthr_hash_safe(pthread_t thread) -{ - return hash((void *) pthread_normalize(&thread), sizeof(pthread_t)); -} - -/* - * Fast user-level pthr_hash function - modifies origin thread handle - */ -hash_t pthr_hash_fast(pthread_t thread) -{ - return hash((void *) pthread_normalize(&thread), sizeof(pthread_t)); -} - -/* User-level bitclear function - modifies the origin array */ -void* bitclear(void* loc, void* mask, size_t count) -{ - int i; - for (i=0; i < count; i++) { - (unsigned char) *loc++ &= ~((unsigned char) *mask++); - } -} - -/* Donald Knuth hash */ -hash_t hash(void* str, size_t count) -{ - hash_t hash = (hash_t) count; - unsigned int i = 0; - - for(i = 0; i < len; str++, i++) - { - hash = ((hash << 5) ^ (hash >> 27)) ^ (*str); - } - return hash; -} - -/* Example of advantage point (3) - split a thread handle into its id and non-id values */ -pthread_t id = thread, non-id = thread; -bitclear((void*) &non-id, (void*) pthread_normalize(&id), sizeof(pthread_t)); - - -A pthread_t type change proposal to neutralise the effects of padding - -Even if pthread_nornalize() is available, padding is still a problem because -the standard only garrantees element-by-element equivalence through -copy operations (assignment and pass-by-value). So padding bit values can -still change randomly after calls to pthread_normalize(). - -[I suspect that most compilers take the easy path and always byte-copy anyway, -partly because it becomes too complex to do (e.g. unions that contain sub-aggregates) -but also because programmers can easily design their aggregates to minimise and -often eliminate padding]. - -How can we eliminate the problem of padding bytes in structs? Could -defining pthread_t as a union rather than a struct provide a solution? - -In fact, the Linux pthread.h defines most of it's pthread_*_t objects (but not -pthread_t itself) as unions, possibly for this and/or other reasons. We'll -borrow some element naming from there but the ideas themselves are well known -- the __align element used to force alignment of the union comes from K&R's -storage allocator example. - -/* Essentially our current pthread_t renamed */ -typedef struct { - struct thread_state_t * __p; - long __x; /* sequence counter */ -} thread_id_t; - -Ensuring that the last element in the above struct is a long ensures that the -overall struct size is a multiple of sizeof(long), so there should be no trailing -padding in this struct or the union we define below. -(Later we'll see that we can handle internal but not trailing padding.) - -/* New pthread_t */ -typedef union { - char __size[sizeof(thread_id_t)]; /* array as the first element */ - thread_id_t __tid; - long __align; /* Ensure that the union starts on long boundary */ -} pthread_t; - -This guarrantees that, during an assignment or pass-by-value, the compiler copies -every byte in our thread_id_t because the compiler guarrantees that the __size -array, which we have ensured is the equal-largest element in the union, retains -equivalence. - -This means that pthread_t values stored, assigned and passed by value will at least -carry the value of any undefined padding bytes along and therefore ensure that -those values remain consistent. Our comparisons will return consistent results and -our hashes of [zero initialised] pthread_t values will also return consistent -results. - -We have also removed the need for a pthread_null() function; we can initialise -at declaration time or easily create our own const pthread_t to use in assignments -later: - -const pthread_t null_tid = {0}; /* braces are required */ - -pthread_t t; -... -t = null_tid; - - -Note that we don't have to explicitly make use of the __size array at all. It's -there just to force the compiler behaviour we want. - - -Partial solutions without a pthread_normalize function - - -An application-level pthread_null and pthread_compare proposal -(and pthread_hash proposal by extention) - -In order to deal with the problem of scalar/aggregate pthread_t type disparity in -portable code I suggest using an old-fashioned union, e.g.: - -Contraints: -- there is no padding, or padding values are preserved through assignment and - pass-by-value (see above); -- there are no extra non-id values in the pthread_t. - - -Example 1: A null initialiser for pthread_t variables... - -typedef union { - unsigned char b[sizeof(pthread_t)]; - pthread_t t; -} init_t; - -const init_t initial = {0}; - -pthread_t tid = initial.t; /* init tid to all zeroes */ - - -Example 2: A comparison function for pthread_t values - -typedef union { - unsigned char b[sizeof(pthread_t)]; - pthread_t t; -} pthcmp_t; - -int pthcmp(pthread_t left, pthread_t right) -{ - /* - * Compare two pthread handles in a way that imposes a repeatable but arbitrary - * ordering on them. - * I.e. given the same set of pthread_t handles the ordering should be the same - * each time but the order has no particular meaning other than that. E.g. - * the ordering does not imply the thread start sequence, or any other - * relationship between threads. - * - * Return values are: - * 1 : left is greater than right - * 0 : left is equal to right - * -1 : left is less than right - */ - int i; - pthcmp_t L, R; - L.t = left; - R.t = right; - for (i = 0; i < sizeof(pthread_t); i++) - { - if (L.b[i] > R.b[i]) - return 1; - else if (L.b[i] < R.b[i]) - return -1; - } - return 0; -} - -It has been pointed out that the C99 standard allows for the possibility that -integer types also may include padding bits, which could invalidate the above -method. This addition to C99 was specifically included after it was pointed -out that there was one, presumably not particularly well known, architecture -that included a padding bit in it's 32 bit integer type. See section 6.2.6.2 -of both the standard and the rationale, specifically the paragraph starting at -line 16 on page 43 of the rationale. - - -An aside - -Certain compilers, e.g. gcc and one of the IBM compilers, include a feature -extention: provided the union contains a member of the same type as the -object then the object may be cast to the union itself. - -We could use this feature to speed up the pthrcmp() function from example 2 -above by casting rather than assigning the pthread_t arguments to the union, e.g.: - -int pthcmp(pthread_t left, pthread_t right) -{ - /* - * Compare two pthread handles in a way that imposes a repeatable but arbitrary - * ordering on them. - * I.e. given the same set of pthread_t handles the ordering should be the same - * each time but the order has no particular meaning other than that. E.g. - * the ordering does not imply the thread start sequence, or any other - * relationship between threads. - * - * Return values are: - * 1 : left is greater than right - * 0 : left is equal to right - * -1 : left is less than right - */ - int i; - for (i = 0; i < sizeof(pthread_t); i++) - { - if (((pthcmp_t)left).b[i] > ((pthcmp_t)right).b[i]) - return 1; - else if (((pthcmp_t)left).b[i] < ((pthcmp_t)right).b[i]) - return -1; - } - return 0; -} - - -Result thus far - -We can't remove undefined bits if they are there in pthread_t already, but we have -attempted to render them inert for comparison and hashing functions by making them -consistent through assignment, copy and pass-by-value. - -Note: Hashing pthread_t values requires that all pthread_t variables be initialised -to the same value (usually all zeros) before being assigned a proper thread ID, i.e. -to ensure that any padding bits are zero, or at least the same value for all -pthread_t. Since all pthread_t values are generated by the library in the first -instance this need not be an application-level operation. - - -Conclusion - -I've attempted to resolve the multiple issues of type opacity and the possible -presence of undefined bits and bytes in pthread_t values, which prevent -applications from comparing or hashing pthread handles. - -Two complimentary partial solutions have been proposed, one an application-level -scheme to handle both scalar and aggregate pthread_t types equally, plus a -definition of pthread_t itself that neutralises padding bits and bytes by -coercing semantics out of the compiler to eliminate variations in the values of -padding bits. - -I have not provided any solution to the problem of handling extra values embedded -in pthread_t, e.g. debugging or trap information that an implementation is entitled -to include. Therefore none of this replaces the portability and flexibility of API -functions but what functions are needed? The threads standard is unlikely to -include that can be implemented by a combination of existing features and more -generic functions (several references in the threads rationale suggest this. -Therefore I propose that the following function could replace the several functions -that have been suggested in conversations: - -pthread_t * pthread_normalize(pthread_t * handle); - -For most existing pthreads implementations this function, or macro, would reduce to -a no-op with zero call overhead. diff --git a/deps/w32-pthreads/README.Watcom b/deps/w32-pthreads/README.Watcom deleted file mode 100644 index 2974928..0000000 --- a/deps/w32-pthreads/README.Watcom +++ /dev/null @@ -1,62 +0,0 @@ -Watcom compiler notes -===================== - -Status ------- -Not yet usable. Although the library builds under Watcom it -substantially fails the test suite. - -There is a working Wmakefile for wmake for the library build. - -invoke as any of: -wmake -f Wmakefile clean WC -wmake -f Wmakefile clean WC-inlined -wmake -f Wmakefile clean WCE -wmake -f Wmakefile clean WCE-inlined - -These build pthreadWC.dll and pthreadWCE.dll. - -There is a working Wmakefile for wmake for the test suite. - -invoke as any of: -wmake -f Wmakefile clean WC -wmake -f Wmakefile clean WCX -wmake -f Wmakefile clean WCE -wmake -f Wmakefile clean WC-bench -wmake -f Wmakefile clean WCX-bench -wmake -f Wmakefile clean WCE-bench - - -Current known problems ----------------------- - -Library build: -The Watcom compiler uses a different default call convention to MS C or GNU C and so -applications are not compatible with pthreadVC.dll etc using pre 2003-10-14 versions -of pthread.h, sched.h, or semaphore.h. The cdecl attribute can be used on exposed -function prototypes to force compatibility with MS C built DLLs. - -However, there appear to be other incompatibilities. Errno.h, for example, defines -different values for the standard C and POSIX errors to those defined by the MS C -errno.h. It may be that references to Watcom's threads compatible 'errno' do set -and return translated numbers consistently, but I have not verified this. - -Watcom defines errno as a dereferenced pointer returned by the function -_get_errno_ptr(). This is similar to both the MS and GNU C environments for -multithreaded use. However, the Watcom version appears to have a number of problems: - -- different threads return the same pointer value. Compare with the MS and GNU C -versions which correctly return different values (since each thread must maintain -a thread specific errno value). - -- an errno value set within the DLL appears as zero in the application even though -both share the same thread. - -Therefore applications built using the Watcom compiler may need to use -a Watcom built version of the library (pthreadWC.dll). If this is the case, then -the cdecl function attribute should not be required. - -Application builds: -The test suite fails with the Watcom compiler. - -Test semaphore1.c fails for pthreadWC.dll because errno returns 0 instead of EAGAIN. diff --git a/deps/w32-pthreads/README.WinCE b/deps/w32-pthreads/README.WinCE deleted file mode 100644 index a2cd8c2..0000000 --- a/deps/w32-pthreads/README.WinCE +++ /dev/null @@ -1,6 +0,0 @@ -WinCE port ----------- -(See the file WinCE-PORT for a detailed explanation.) - -Make sure you define "WINCE" amongst your compiler flags (eg. -DWINCE). -The config.h file will define all the necessary defines for you. diff --git a/deps/w32-pthreads/TODO b/deps/w32-pthreads/TODO deleted file mode 100644 index fa9efc4..0000000 --- a/deps/w32-pthreads/TODO +++ /dev/null @@ -1,7 +0,0 @@ - Things that aren't done yet - --------------------------- - -1. Implement PTHREAD_PROCESS_SHARED for semaphores, mutexes, - condition variables, read/write locks, barriers. - - diff --git a/deps/w32-pthreads/WinCE-PORT b/deps/w32-pthreads/WinCE-PORT deleted file mode 100644 index 7bcfdea..0000000 --- a/deps/w32-pthreads/WinCE-PORT +++ /dev/null @@ -1,222 +0,0 @@ -NOTE: The comments in this file relate to the original WinCE port -done by Tristan Savatier. The semaphore routines have been -completely rewritten since (2005-04-25), having been progressively -broken more and more by changes to the library. All of the semaphore -routines implemented for W9x/WNT/2000 and up should now also work for -WinCE. Also, pthread_mutex_timedlock should now work. - -Additional WinCE updates have been applied since this as well. Check the -ChangeLog file and search for WINCE for example. (2007-01-07) - -[RPJ] - ----- - -Some interesting news: - -I have been able to port pthread-win32 to Windows-CE, -which uses a subset of the WIN32 API. - -Since we intend to keep using pthread-win32 for our -Commercial WinCE developments, I would be very interested -if WinCE support could be added to the main source tree -of pthread-win32. Also, I would like to be credited -for this port :-) - -Now, here is the story... - -The port was performed and tested on a Casio "Cassiopeia" -PalmSize PC, which runs a MIP processor. The OS in the -Casio is WinCE version 2.11, but I used VC++ 6.0 with -the WinCE SDK for version 2.01. - -I used pthread-win32 to port a heavily multithreaded -commercial application (real-time MPEG video player) -from Linux to WinCE. I consider the changes that -I have done to be quite well tested. - -Overall the modifications that we had to do are minor. - -The WinCE port were based on pthread-win32-snap-1999-05-30, -but I am certain that they can be integrated very easiely -to more recent versions of the source. - -I have attached the modified source code: -pthread-win32-snap-1999-05-30-WinCE. - -All the changes do not affect the code compiled on non-WinCE -environment, provided that the macros used for WinCE compilation -are not used, of course! - -Overall description of the WinCE port: -------------------------------------- - -Most of the changes had to be made in areas where -pthread-win32 was relying on some standard-C librairies -(e.g. _ftime, calloc, errno), which are not available -on WinCE. We have changed the code to use native Win32 -API instead (or in some cases we made wrappers). - -The Win32 Semaphores are not available, -so we had to re-implement Semaphores using mutexes -and events. - -Limitations / known problems of the WinCE port: ----------------------------------------------- - -Not all the semaphore routines have been ported -(semaphores are defined by Posix but are not part -pf pthread). I have just done enough to make -pthread routines (that rely internally on semaphores) -work, like signal conditions. - -I noticed that the Win32 threads work slightly -differently on WinCE. This may have some impact -on some tricky parts of pthread-win32, but I have -not really investigated. For example, on WinCE, -the process is killed if the main thread falls off -the bottom (or calls pthread_exit), regardless -of the existence of any other detached thread. -Microsoft manual indicates that this behavior is -deffirent from that of Windows Threads for other -Win32 platforms. - - -Detailed descriptions of the changes and rationals: - ------------------------------------- -- use a new macro NEED_ERRNO. - -If defined, the code in errno.c that defines a reentrant errno -is compiled, regardless of _MT and _REENTRANT. - -Rational: On WinCE, there is no support for , or -any other standard C library, i.e. even if _MT or _REENTRANT -is defined, errno is not provided by any library. NEED_ERRNO -must be set to compile for WinCE. - ------------------------------------- -- In implement.h, change #include to #include "semaphore.h". - -Rational: semaphore.h is provided in pthread-win32 and should not -be searched in the systems standard include. would not compile. -This change does not seem to create problems on "classic" win32 -(e.g. win95). - ------------------------------------- -- use a new macro NEED_CALLOC. - -If defined, some code in misc.c will provide a replacement -for calloc, which is not available on Win32. - - ------------------------------------- -- use a new macro NEED_CREATETHREAD. - -If defined, implement.h defines the macro _beginthreadex -and _endthreadex. - -Rational: On WinCE, the wrappers _beginthreadex and _endthreadex -do not exist. The native Win32 routines must be used. - ------------------------------------- -- in misc.c: - -#ifdef NEED_DUPLICATEHANDLE - /* DuplicateHandle does not exist on WinCE */ - self->threadH = GetCurrentThread(); -#else - if( !DuplicateHandle( - GetCurrentProcess(), - GetCurrentThread(), - GetCurrentProcess(), - &self->threadH, - 0, - FALSE, - DUPLICATE_SAME_ACCESS ) ) - { - free( self ); - return (NULL); - } -#endif - -Rational: On WinCE, DuplicateHandle does not exist. I could not understand -why DuplicateHandle must be used. It seems to me that getting the current -thread handle with GetCurrentThread() is sufficient, and it seems to work -perfectly fine, so maybe DuplicateHandle was just plain useless to begin with ? - ------------------------------------- -- In private.c, added some code at the beginning of ptw32_processInitialize -to detect the case of multiple calls to ptw32_processInitialize. - -Rational: In order to debug pthread-win32, it is easier to compile -it as a regular library (it is not possible to debug DLL's on winCE). -In that case, the application must call ptw32_rocessInitialize() -explicitely, to initialize pthread-win32. It is safer in this circumstance -to handle the case where ptw32_processInitialize() is called on -an already initialized library: - -int -ptw32_processInitialize (void) -{ - if (ptw32_processInitialized) { - /* - * ignore if already initialized. this is useful for - * programs that uses a non-dll pthread - * library. such programs must call ptw32_processInitialize() explicitely, - * since this initialization routine is automatically called only when - * the dll is loaded. - */ - return TRUE; - } - ptw32_processInitialized = TRUE; - [...] -} - ------------------------------------- -- in private.c, if macro NEED_FTIME is defined, add routines to -convert timespec_to_filetime and filetime_to_timespec, and modified -code that was using _ftime() to use Win32 API instead. - -Rational: _ftime is not available on WinCE. It is necessary to use -the native Win32 time API instead. - -Note: the routine timespec_to_filetime is provided as a convenience and a mean -to test that filetime_to_timespec works, but it is not used by the library. - ------------------------------------- -- in semaphore.c, if macro NEED_SEM is defined, add code for the routines -_increase_semaphore and _decrease_semaphore, and modify significantly -the implementation of the semaphores so that it does not use CreateSemaphore. - -Rational: CreateSemaphore is not available on WinCE. I had to re-implement -semaphores using mutexes and Events. - -Note: Only the semaphore routines that are used by pthread are implemented -(i.e. signal conditions rely on a subset of the semaphores routines, and -this subset works). Some other semaphore routines (e.g. sem_trywait) are -not yet supported on my WinCE port (and since I don't need them, I am not -planning to do anything about them). - ------------------------------------- -- in tsd.c, changed the code that defines TLS_OUT_OF_INDEXES - -/* TLS_OUT_OF_INDEXES not defined on WinCE */ -#ifndef TLS_OUT_OF_INDEXES -#define TLS_OUT_OF_INDEXES 0xffffffff -#endif - -Rational: TLS_OUT_OF_INDEXES is not defined in any standard include file -on WinCE. - ------------------------------------- -- added file need_errno.h - -Rational: On WinCE, there is no errno.h file. need_errno.h is just a -copy of windows version of errno.h, with minor modifications due to the fact -that some of the error codes are defined by the WinCE socket library. -In pthread.h, if NEED_ERRNO is defined, the file need_errno.h is -included (instead of ). - - --- eof diff --git a/deps/w32-pthreads/attr.c b/deps/w32-pthreads/attr.c deleted file mode 100644 index fa1a1dd..0000000 --- a/deps/w32-pthreads/attr.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * attr.c - * - * Description: - * This translation unit agregates operations on thread attribute objects. - * It is used for inline optimisation. - * - * The included modules are used separately when static executable sizes - * must be minimised. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -#include "pthread_attr_init.c" -#include "pthread_attr_destroy.c" -#include "pthread_attr_getdetachstate.c" -#include "pthread_attr_setdetachstate.c" -#include "pthread_attr_getstackaddr.c" -#include "pthread_attr_setstackaddr.c" -#include "pthread_attr_getstacksize.c" -#include "pthread_attr_setstacksize.c" -#include "pthread_attr_getscope.c" -#include "pthread_attr_setscope.c" diff --git a/deps/w32-pthreads/autostatic.c b/deps/w32-pthreads/autostatic.c deleted file mode 100644 index e8bc3a8..0000000 --- a/deps/w32-pthreads/autostatic.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * autostatic.c - * - * Description: - * This translation unit implements static auto-init and auto-exit logic. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#if defined(PTW32_STATIC_LIB) - -#if defined(__MINGW64__) || defined(__MINGW32__) || defined(_MSC_VER) - -#include "pthread.h" -#include "implement.h" - -static void on_process_init(void) -{ - pthread_win32_process_attach_np (); -} - -static void on_process_exit(void) -{ - pthread_win32_thread_detach_np (); - pthread_win32_process_detach_np (); -} - -#if defined(__MINGW64__) || defined(__MINGW32__) -# define attribute_section(a) __attribute__((section(a))) -#elif defined(_MSC_VER) -# define attribute_section(a) __pragma(section(a,long,read)); __declspec(allocate(a)) -#endif - -attribute_section(".ctors") void *gcc_ctor = on_process_init; -attribute_section(".dtors") void *gcc_dtor = on_process_exit; - -attribute_section(".CRT$XCU") void *msc_ctor = on_process_init; -attribute_section(".CRT$XPU") void *msc_dtor = on_process_exit; - -#endif /* defined(__MINGW64__) || defined(__MINGW32__) || defined(_MSC_VER) */ - -#endif /* PTW32_STATIC_LIB */ diff --git a/deps/w32-pthreads/barrier.c b/deps/w32-pthreads/barrier.c deleted file mode 100644 index c34fd7f..0000000 --- a/deps/w32-pthreads/barrier.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * barrier.c - * - * Description: - * This translation unit implements barrier primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -#include "pthread_barrier_init.c" -#include "pthread_barrier_destroy.c" -#include "pthread_barrier_wait.c" -#include "pthread_barrierattr_init.c" -#include "pthread_barrierattr_destroy.c" -#include "pthread_barrierattr_getpshared.c" -#include "pthread_barrierattr_setpshared.c" diff --git a/deps/w32-pthreads/builddmc.bat b/deps/w32-pthreads/builddmc.bat deleted file mode 100644 index bf813d8..0000000 --- a/deps/w32-pthreads/builddmc.bat +++ /dev/null @@ -1,9 +0,0 @@ -; Build the pthreads library with the Digital Mars Compiler -; -set DMCDIR=c:\dm - -; RELEASE -%DMCDIR%\bin\dmc -D_WIN32_WINNT -D_MT -DHAVE_PTW32_CONFIG_H -I.;c:\dm\include -o+all -WD pthread.c user32.lib+kernel32.lib+wsock32.lib -L/impl -L/NODEBUG -L/SU:WINDOWS - -; DEBUG -%DMCDIR%\bin\dmc -g -D_WIN32_WINNT -D_MT -DHAVE_PTW32_CONFIG_H -I.;c:\dm\include -o+all -WD pthread.c user32.lib+kernel32.lib+wsock32.lib -L/impl -L/SU:WINDOWS diff --git a/deps/w32-pthreads/cancel.c b/deps/w32-pthreads/cancel.c deleted file mode 100644 index 3a554a0..0000000 --- a/deps/w32-pthreads/cancel.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * cancel.c - * - * Description: - * POSIX thread functions related to thread cancellation. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -#include "pthread_setcancelstate.c" -#include "pthread_setcanceltype.c" -#include "pthread_testcancel.c" -#include "pthread_cancel.c" diff --git a/deps/w32-pthreads/cleanup.c b/deps/w32-pthreads/cleanup.c deleted file mode 100644 index fc69ca8..0000000 --- a/deps/w32-pthreads/cleanup.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * cleanup.c - * - * Description: - * This translation unit implements routines associated - * with cleaning up threads. - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -/* - * The functions ptw32_pop_cleanup and ptw32_push_cleanup - * are implemented here for applications written in C with no - * SEH or C++ destructor support. - */ - -ptw32_cleanup_t * -ptw32_pop_cleanup (int execute) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function pops the most recently pushed cleanup - * handler. If execute is nonzero, then the cleanup handler - * is executed if non-null. - * - * PARAMETERS - * execute - * if nonzero, execute the cleanup handler - * - * - * DESCRIPTION - * This function pops the most recently pushed cleanup - * handler. If execute is nonzero, then the cleanup handler - * is executed if non-null. - * NOTE: specify 'execute' as nonzero to avoid duplication - * of common cleanup code. - * - * RESULTS - * N/A - * - * ------------------------------------------------------ - */ -{ - ptw32_cleanup_t *cleanup; - - cleanup = (ptw32_cleanup_t *) pthread_getspecific (ptw32_cleanupKey); - - if (cleanup != NULL) - { - if (execute && (cleanup->routine != NULL)) - { - - (*cleanup->routine) (cleanup->arg); - - } - - pthread_setspecific (ptw32_cleanupKey, (void *) cleanup->prev); - - } - - return (cleanup); - -} /* ptw32_pop_cleanup */ - - -void -ptw32_push_cleanup (ptw32_cleanup_t * cleanup, - ptw32_cleanup_callback_t routine, void *arg) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function pushes a new cleanup handler onto the thread's stack - * of cleanup handlers. Each cleanup handler pushed onto the stack is - * popped and invoked with the argument 'arg' when - * a) the thread exits by calling 'pthread_exit', - * b) when the thread acts on a cancellation request, - * c) or when the thread calls pthread_cleanup_pop with a nonzero - * 'execute' argument - * - * PARAMETERS - * cleanup - * a pointer to an instance of pthread_cleanup_t, - * - * routine - * pointer to a cleanup handler, - * - * arg - * parameter to be passed to the cleanup handler - * - * - * DESCRIPTION - * This function pushes a new cleanup handler onto the thread's stack - * of cleanup handlers. Each cleanup handler pushed onto the stack is - * popped and invoked with the argument 'arg' when - * a) the thread exits by calling 'pthread_exit', - * b) when the thread acts on a cancellation request, - * c) or when the thrad calls pthread_cleanup_pop with a nonzero - * 'execute' argument - * NOTE: pthread_push_cleanup, ptw32_pop_cleanup must be paired - * in the same lexical scope. - * - * RESULTS - * pthread_cleanup_t * - * pointer to the previous cleanup - * - * ------------------------------------------------------ - */ -{ - cleanup->routine = routine; - cleanup->arg = arg; - - cleanup->prev = (ptw32_cleanup_t *) pthread_getspecific (ptw32_cleanupKey); - - pthread_setspecific (ptw32_cleanupKey, (void *) cleanup); - -} /* ptw32_push_cleanup */ diff --git a/deps/w32-pthreads/condvar.c b/deps/w32-pthreads/condvar.c deleted file mode 100644 index 556596d..0000000 --- a/deps/w32-pthreads/condvar.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * condvar.c - * - * Description: - * This translation unit implements condition variables and their primitives. - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - */ - -#include "pthread.h" -#include "implement.h" - -#include "ptw32_cond_check_need_init.c" -#include "pthread_condattr_init.c" -#include "pthread_condattr_destroy.c" -#include "pthread_condattr_getpshared.c" -#include "pthread_condattr_setpshared.c" -#include "pthread_cond_init.c" -#include "pthread_cond_destroy.c" -#include "pthread_cond_wait.c" -#include "pthread_cond_signal.c" diff --git a/deps/w32-pthreads/config.h b/deps/w32-pthreads/config.h deleted file mode 100644 index e231724..0000000 --- a/deps/w32-pthreads/config.h +++ /dev/null @@ -1,153 +0,0 @@ -/* config.h */ - -#ifndef PTW32_CONFIG_H -#define PTW32_CONFIG_H - -/********************************************************************* - * Defaults: see target specific redefinitions below. - *********************************************************************/ - -/* We're building the pthreads-win32 library */ -#define PTW32_BUILD - -/* Do we know about the C type sigset_t? */ -#undef HAVE_SIGSET_T - -/* Define if you have the header file. */ -#undef HAVE_SIGNAL_H - -/* Define if you have the Borland TASM32 or compatible assembler. */ -#undef HAVE_TASM32 - -/* Define if you don't have Win32 DuplicateHandle. (eg. WinCE) */ -#undef NEED_DUPLICATEHANDLE - -/* Define if you don't have Win32 _beginthreadex. (eg. WinCE) */ -#undef NEED_CREATETHREAD - -/* Define if you don't have Win32 errno. (eg. WinCE) */ -#undef NEED_ERRNO - -/* Define if you don't have Win32 calloc. (eg. WinCE) */ -#undef NEED_CALLOC - -/* Define if you don't have Win32 ftime. (eg. WinCE) */ -#undef NEED_FTIME - -/* Define if you don't have Win32 semaphores. (eg. WinCE 2.1 or earlier) */ -#undef NEED_SEM - -/* Define if you need to convert string parameters to unicode. (eg. WinCE) */ -#undef NEED_UNICODE_CONSTS - -/* Define if your C (not C++) compiler supports "inline" functions. */ -#undef HAVE_C_INLINE - -/* Do we know about type mode_t? */ -#undef HAVE_MODE_T - -/* - * Define if GCC has atomic builtins, i.e. __sync_* intrinsics - * __sync_lock_* is implemented in mingw32 gcc 4.5.2 at least - * so this define does not turn those on or off. If you get an - * error from __sync_lock* then consider upgrading your gcc. - */ -#undef HAVE_GCC_ATOMIC_BUILTINS - -/* Define if you have the timespec struct */ -#undef HAVE_STRUCT_TIMESPEC - -/* Define if you don't have the GetProcessAffinityMask() */ -#undef NEED_PROCESS_AFFINITY_MASK - -/* Define if your version of Windows TLSGetValue() clears WSALastError - * and calling SetLastError() isn't enough restore it. You'll also need to - * link against wsock32.lib (or libwsock32.a for MinGW). - */ -#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 -# -# ---------------------------------------------------------------------- - */ -#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. - *********************************************************************/ -#if defined(WINCE) -#define NEED_DUPLICATEHANDLE -#define NEED_CREATETHREAD -#define NEED_ERRNO -#define NEED_CALLOC -#define NEED_FTIME -/* #define NEED_SEM */ -#define NEED_UNICODE_CONSTS -#define NEED_PROCESS_AFFINITY_MASK -/* This may not be needed */ -#define RETAIN_WSALASTERROR -#endif - -#if defined(_UWIN) -#define HAVE_MODE_T -#define HAVE_STRUCT_TIMESPEC -#endif - -#if defined(__GNUC__) -#define HAVE_C_INLINE -#endif - -#if defined(__MINGW64__) -#define HAVE_MODE_T -#define HAVE_STRUCT_TIMESPEC -#elif defined(__MINGW32__) -#define HAVE_MODE_T -#endif - -#if defined(__BORLANDC__) -#endif - -#if defined(__WATCOMC__) -#endif - -#if defined(__DMC__) -#define HAVE_SIGNAL_H -#define HAVE_C_INLINE -#endif - - - -#endif diff --git a/deps/w32-pthreads/context.h b/deps/w32-pthreads/context.h deleted file mode 100644 index f55dd73..0000000 --- a/deps/w32-pthreads/context.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * context.h - * - * Description: - * POSIX thread macros related to thread cancellation. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef PTW32_CONTEXT_H -#define PTW32_CONTEXT_H - -#undef PTW32_PROGCTR - -#if defined(_M_IX86) || (defined(_X86_) && !defined(__amd64__)) -#define PTW32_PROGCTR(Context) ((Context).Eip) -#endif - -#if defined (_M_IA64) || defined(_IA64) -#define PTW32_PROGCTR(Context) ((Context).StIIP) -#endif - -#if defined(_MIPS_) || defined(MIPS) -#define PTW32_PROGCTR(Context) ((Context).Fir) -#endif - -#if defined(_ALPHA_) -#define PTW32_PROGCTR(Context) ((Context).Fir) -#endif - -#if defined(_PPC_) -#define PTW32_PROGCTR(Context) ((Context).Iar) -#endif - -#if defined(_AMD64_) || defined(__amd64__) -#define PTW32_PROGCTR(Context) ((Context).Rip) -#endif - -#if defined(_ARM_) || defined(ARM) -#define PTW32_PROGCTR(Context) ((Context).Pc) -#endif - -#if !defined(PTW32_PROGCTR) -#error Module contains CPU-specific code; modify and recompile. -#endif - -#endif diff --git a/deps/w32-pthreads/create.c b/deps/w32-pthreads/create.c deleted file mode 100644 index 1927296..0000000 --- a/deps/w32-pthreads/create.c +++ /dev/null @@ -1,308 +0,0 @@ -/* - * create.c - * - * Description: - * This translation unit implements routines associated with spawning a new - * thread. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" -#if ! defined(_UWIN) && ! defined(WINCE) -#include -#endif - -int -pthread_create (pthread_t * tid, - const pthread_attr_t * attr, - void *(PTW32_CDECL *start) (void *), void *arg) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function creates a thread running the start function, - * passing it the parameter value, 'arg'. The 'attr' - * argument specifies optional creation attributes. - * The identity of the new thread is returned - * via 'tid', which should not be NULL. - * - * PARAMETERS - * tid - * pointer to an instance of pthread_t - * - * attr - * optional pointer to an instance of pthread_attr_t - * - * start - * pointer to the starting routine for the new thread - * - * arg - * optional parameter passed to 'start' - * - * - * DESCRIPTION - * This function creates a thread running the start function, - * passing it the parameter value, 'arg'. The 'attr' - * argument specifies optional creation attributes. - * The identity of the new thread is returned - * via 'tid', which should not be the NULL pointer. - * - * RESULTS - * 0 successfully created thread, - * EINVAL attr invalid, - * EAGAIN insufficient resources. - * - * ------------------------------------------------------ - */ -{ - pthread_t thread; - ptw32_thread_t * tp; - register pthread_attr_t a; - HANDLE threadH = 0; - int result = EAGAIN; - int run = PTW32_TRUE; - ThreadParms *parms = NULL; - unsigned int stackSize; - int priority; - pthread_t self; - - /* - * Before doing anything, check that tid can be stored through - * without invoking a memory protection error (segfault). - * Make sure that the assignment below can't be optimised out by the compiler. - * This is assured by conditionally assigning *tid again at the end. - */ - tid->x = 0; - - if (attr != NULL) - { - a = *attr; - } - else - { - a = NULL; - } - - if ((thread = ptw32_new ()).p == NULL) - { - goto FAIL0; - } - - tp = (ptw32_thread_t *) thread.p; - - priority = tp->sched_priority; - - if ((parms = (ThreadParms *) malloc (sizeof (*parms))) == NULL) - { - goto FAIL0; - } - - parms->tid = thread; - parms->start = start; - parms->arg = arg; - -#if defined(HAVE_SIGSET_T) - - /* - * Threads inherit their initial sigmask from their creator thread. - */ - self = pthread_self(); - tp->sigmask = ((ptw32_thread_t *)self.p)->sigmask; - -#endif /* HAVE_SIGSET_T */ - - - if (a != NULL) - { - stackSize = (unsigned int)a->stacksize; - tp->detachState = a->detachstate; - priority = a->param.sched_priority; - -#if (THREAD_PRIORITY_LOWEST > THREAD_PRIORITY_NORMAL) - /* WinCE */ -#else - /* Everything else */ - - /* - * Thread priority must be set to a valid system level - * without altering the value set by pthread_attr_setschedparam(). - */ - - /* - * PTHREAD_EXPLICIT_SCHED is the default because Win32 threads - * don't inherit their creator's priority. They are started with - * THREAD_PRIORITY_NORMAL (win32 value). The result of not supplying - * an 'attr' arg to pthread_create() is equivalent to defaulting to - * PTHREAD_EXPLICIT_SCHED and priority THREAD_PRIORITY_NORMAL. - */ - if (PTHREAD_INHERIT_SCHED == a->inheritsched) - { - /* - * If the thread that called pthread_create() is a Win32 thread - * then the inherited priority could be the result of a temporary - * system adjustment. This is not the case for POSIX threads. - */ -#if ! defined(HAVE_SIGSET_T) - self = pthread_self (); -#endif - priority = ((ptw32_thread_t *) self.p)->sched_priority; - } - -#endif - - } - else - { - /* - * Default stackSize - */ - stackSize = PTHREAD_STACK_MIN; - } - - tp->state = run ? PThreadStateInitial : PThreadStateSuspended; - - tp->keys = NULL; - - /* - * Threads must be started in suspended mode and resumed if necessary - * after _beginthreadex returns us the handle. Otherwise we set up a - * race condition between the creating and the created threads. - * Note that we also retain a local copy of the handle for use - * by us in case thread.p->threadH gets NULLed later but before we've - * finished with it here. - */ - -#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) - - tp->threadH = - threadH = - (HANDLE) _beginthreadex ((void *) NULL, /* No security info */ - stackSize, /* default stack size */ - ptw32_threadStart, - parms, - (unsigned) - CREATE_SUSPENDED, - (unsigned *) &(tp->thread)); - - if (threadH != 0) - { - if (a != NULL) - { - (void) ptw32_setthreadpriority (thread, SCHED_OTHER, priority); - } - - if (run) - { - ResumeThread (threadH); - } - } - -#else - - { - ptw32_mcs_local_node_t stateLock; - - /* - * This lock will force pthread_threadStart() to wait until we have - * the thread handle and have set the priority. - */ - ptw32_mcs_lock_acquire(&tp->stateLock, &stateLock); - - tp->threadH = - threadH = - (HANDLE) _beginthread (ptw32_threadStart, stackSize, /* default stack size */ - parms); - - /* - * Make the return code match _beginthreadex's. - */ - if (threadH == (HANDLE) - 1L) - { - tp->threadH = threadH = 0; - } - else - { - if (!run) - { - /* - * beginthread does not allow for create flags, so we do it now. - * Note that beginthread itself creates the thread in SUSPENDED - * mode, and then calls ResumeThread to start it. - */ - SuspendThread (threadH); - } - - if (a != NULL) - { - (void) ptw32_setthreadpriority (thread, SCHED_OTHER, priority); - } - } - - ptw32_mcs_lock_release (&stateLock); - } -#endif - - result = (threadH != 0) ? 0 : EAGAIN; - - /* - * Fall Through Intentionally - */ - - /* - * ------------ - * Failure Code - * ------------ - */ - -FAIL0: - if (result != 0) - { - - ptw32_threadDestroy (thread); - tp = NULL; - - if (parms != NULL) - { - free (parms); - } - } - else - { - *tid = thread; - } - -#if defined(_UWIN) - if (result == 0) - pthread_count++; -#endif - return (result); - -} /* pthread_create */ diff --git a/deps/w32-pthreads/dll.c b/deps/w32-pthreads/dll.c deleted file mode 100644 index 8350cdd..0000000 --- a/deps/w32-pthreads/dll.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * dll.c - * - * Description: - * This translation unit implements DLL initialisation. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#if !defined(PTW32_STATIC_LIB) - -#include "pthread.h" -#include "implement.h" - -#if defined(_MSC_VER) -/* - * lpvReserved yields an unreferenced formal parameter; - * ignore it - */ -#pragma warning( disable : 4100 ) -#endif - -#if defined(__cplusplus) -/* - * Dear c++: Please don't mangle this name. -thanks - */ -extern "C" -#endif /* __cplusplus */ - BOOL WINAPI -DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved) -{ - BOOL result = PTW32_TRUE; - - switch (fdwReason) - { - - case DLL_PROCESS_ATTACH: - result = pthread_win32_process_attach_np (); - break; - - case DLL_THREAD_ATTACH: - /* - * A thread is being created - */ - result = pthread_win32_thread_attach_np (); - break; - - case DLL_THREAD_DETACH: - /* - * A thread is exiting cleanly - */ - result = pthread_win32_thread_detach_np (); - break; - - case DLL_PROCESS_DETACH: - (void) pthread_win32_thread_detach_np (); - result = pthread_win32_process_detach_np (); - break; - } - - return (result); - -} /* DllMain */ - -#endif /* PTW32_STATIC_LIB */ diff --git a/deps/w32-pthreads/errno.c b/deps/w32-pthreads/errno.c deleted file mode 100644 index 1f5bfff..0000000 --- a/deps/w32-pthreads/errno.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * errno.c - * - * Description: - * This translation unit implements routines associated with spawning a new - * thread. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#if defined(NEED_ERRNO) - -#include "pthread.h" -#include "implement.h" - -static int reallyBad = ENOMEM; - -/* - * Re-entrant errno. - * - * Each thread has it's own errno variable in pthread_t. - * - * The benefit of using the pthread_t structure - * instead of another TSD key is TSD keys are limited - * on Win32 to 64 per process. Secondly, to implement - * it properly without using pthread_t you'd need - * to dynamically allocate an int on starting the thread - * and store it manually into TLS and then ensure that you free - * it on thread termination. We get all that for free - * by simply storing the errno on the pthread_t structure. - * - * MSVC and Mingw32 already have their own thread-safe errno. - * - * #if defined( _REENTRANT ) || defined( _MT ) - * #define errno *_errno() - * - * int *_errno( void ); - * #else - * extern int errno; - * #endif - * - */ - -int * -_errno (void) -{ - pthread_t self; - int *result; - - if ((self = pthread_self ()).p == NULL) - { - /* - * Yikes! unable to allocate a thread! - * Throw an exception? return an error? - */ - result = &reallyBad; - } - else - { - result = (int *)(&self.p->exitStatus); - } - - return (result); - -} /* _errno */ - -#endif /* (NEED_ERRNO) */ diff --git a/deps/w32-pthreads/exit.c b/deps/w32-pthreads/exit.c deleted file mode 100644 index 7645d7a..0000000 --- a/deps/w32-pthreads/exit.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * exit.c - * - * Description: - * This translation unit implements routines associated with exiting from - * a thread. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" -#if ! defined(_UWIN) && ! defined(WINCE) -# include -#endif - -#include "pthread_exit.c" diff --git a/deps/w32-pthreads/fork.c b/deps/w32-pthreads/fork.c deleted file mode 100644 index 32acba6..0000000 --- a/deps/w32-pthreads/fork.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * fork.c - * - * Description: - * Implementation of fork() for POSIX threads. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - - -#include "pthread.h" -#include "implement.h" diff --git a/deps/w32-pthreads/global.c b/deps/w32-pthreads/global.c deleted file mode 100644 index 0bdf325..0000000 --- a/deps/w32-pthreads/global.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * global.c - * - * Description: - * This translation unit instantiates data associated with the implementation - * as a whole. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int ptw32_processInitialized = PTW32_FALSE; -ptw32_thread_t * ptw32_threadReuseTop = PTW32_THREAD_REUSE_EMPTY; -ptw32_thread_t * ptw32_threadReuseBottom = PTW32_THREAD_REUSE_EMPTY; -pthread_key_t ptw32_selfThreadKey = NULL; -pthread_key_t ptw32_cleanupKey = NULL; -pthread_cond_t ptw32_cond_list_head = NULL; -pthread_cond_t ptw32_cond_list_tail = NULL; - -int ptw32_concurrency = 0; - -/* What features have been auto-detected */ -int ptw32_features = 0; - -/* - * Global [process wide] thread sequence Number - */ -unsigned __int64 ptw32_threadSeqNumber = 0; - -/* - * Function pointer to QueueUserAPCEx if it exists, otherwise - * it will be set at runtime to a substitute routine which cannot unblock - * blocked threads. - */ -DWORD (*ptw32_register_cancelation) (PAPCFUNC, HANDLE, DWORD) = NULL; - -/* - * Global lock for managing pthread_t struct reuse. - */ -ptw32_mcs_lock_t ptw32_thread_reuse_lock = 0; - -/* - * Global lock for testing internal state of statically declared mutexes. - */ -ptw32_mcs_lock_t ptw32_mutex_test_init_lock = 0; - -/* - * Global lock for testing internal state of PTHREAD_COND_INITIALIZER - * created condition variables. - */ -ptw32_mcs_lock_t ptw32_cond_test_init_lock = 0; - -/* - * Global lock for testing internal state of PTHREAD_RWLOCK_INITIALIZER - * created read/write locks. - */ -ptw32_mcs_lock_t ptw32_rwlock_test_init_lock = 0; - -/* - * Global lock for testing internal state of PTHREAD_SPINLOCK_INITIALIZER - * created spin locks. - */ -ptw32_mcs_lock_t ptw32_spinlock_test_init_lock = 0; - -/* - * Global lock for condition variable linked list. The list exists - * to wake up CVs when a WM_TIMECHANGE message arrives. See - * w32_TimeChangeHandler.c. - */ -ptw32_mcs_lock_t ptw32_cond_list_lock = 0; - -#if defined(_UWIN) -/* - * Keep a count of the number of threads. - */ -int pthread_count = 0; -#endif diff --git a/deps/w32-pthreads/implement.h b/deps/w32-pthreads/implement.h deleted file mode 100644 index db7888b..0000000 --- a/deps/w32-pthreads/implement.h +++ /dev/null @@ -1,943 +0,0 @@ -/* - * implement.h - * - * Definitions that don't need to be public. - * - * Keeps all the internals out of pthread.h - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: Ross.Johnson@homemail.com.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#if !defined(_IMPLEMENT_H) -#define _IMPLEMENT_H - -#if !defined(_WIN32_WINNT) -#define _WIN32_WINNT 0x0400 -#endif - -#include - -/* - * In case windows.h doesn't define it (e.g. WinCE perhaps) - */ -#if defined(WINCE) -typedef VOID (APIENTRY *PAPCFUNC)(DWORD dwParam); -#endif - -/* - * note: ETIMEDOUT is correctly defined in winsock.h - */ -#include - -/* - * In case ETIMEDOUT hasn't been defined above somehow. - */ -#if !defined(ETIMEDOUT) -# define ETIMEDOUT 10060 /* This is the value in winsock.h. */ -#endif - -#if !defined(malloc) -#include -#endif - -#if defined(__CLEANUP_C) -# include -#endif - -#if !defined(INT_MAX) -#include -#endif - -/* use local include files during development */ -#include "semaphore.h" -#include "sched.h" - -#if defined(HAVE_C_INLINE) || defined(__cplusplus) -#define INLINE inline -#else -#define INLINE -#endif - -#if defined(_MSC_VER) && _MSC_VER < 1300 -/* - * MSVC 6 does not use the "volatile" qualifier - */ -#define PTW32_INTERLOCKED_VOLATILE -#else -#define PTW32_INTERLOCKED_VOLATILE volatile -#endif -#define PTW32_INTERLOCKED_LONG long -#define PTW32_INTERLOCKED_SIZE size_t -#define PTW32_INTERLOCKED_PVOID PVOID -#define PTW32_INTERLOCKED_LONGPTR PTW32_INTERLOCKED_VOLATILE long* -#define PTW32_INTERLOCKED_SIZEPTR PTW32_INTERLOCKED_VOLATILE size_t* -#define PTW32_INTERLOCKED_PVOID_PTR PTW32_INTERLOCKED_VOLATILE PVOID* - -#if defined(__MINGW64__) || defined(__MINGW32__) -# include -#elif defined(__BORLANDC__) -# define int64_t ULONGLONG -#else -# define int64_t _int64 -# if defined(_MSC_VER) && _MSC_VER < 1300 - typedef long intptr_t; -# endif -#endif - -typedef enum -{ - /* - * This enumeration represents the state of the thread; - * The thread is still "alive" if the numeric value of the - * state is greater or equal "PThreadStateRunning". - */ - PThreadStateInitial = 0, /* Thread not running */ - PThreadStateRunning, /* Thread alive & kicking */ - PThreadStateSuspended, /* Thread alive but suspended */ - PThreadStateCancelPending, /* Thread alive but */ - /* has cancelation pending. */ - PThreadStateCanceling, /* Thread alive but is */ - /* in the process of terminating */ - /* due to a cancellation request */ - PThreadStateExiting, /* Thread alive but exiting */ - /* due to an exception */ - PThreadStateLast, /* All handlers have been run and now */ - /* final cleanup can be done. */ - PThreadStateReuse /* In reuse pool. */ -} -PThreadState; - -typedef struct ptw32_mcs_node_t_ ptw32_mcs_local_node_t; -typedef struct ptw32_mcs_node_t_* ptw32_mcs_lock_t; -typedef struct ptw32_robust_node_t_ ptw32_robust_node_t; -typedef struct ptw32_thread_t_ ptw32_thread_t; - - -struct ptw32_thread_t_ -{ - unsigned __int64 seqNumber; /* Process-unique thread sequence number */ - HANDLE threadH; /* Win32 thread handle - POSIX thread is invalid if threadH == 0 */ - pthread_t ptHandle; /* This thread's permanent pthread_t handle */ - ptw32_thread_t * prevReuse; /* Links threads on reuse stack */ - volatile PThreadState state; - ptw32_mcs_lock_t threadLock; /* Used for serialised access to public thread state */ - ptw32_mcs_lock_t stateLock; /* Used for async-cancel safety */ - HANDLE cancelEvent; - void *exitStatus; - void *parms; - void *keys; - void *nextAssoc; -#if defined(__CLEANUP_C) - jmp_buf start_mark; /* Jump buffer follows void* so should be aligned */ -#endif /* __CLEANUP_C */ -#if defined(HAVE_SIGSET_T) - sigset_t sigmask; -#endif /* HAVE_SIGSET_T */ - ptw32_mcs_lock_t - robustMxListLock; /* robustMxList lock */ - ptw32_robust_node_t* - robustMxList; /* List of currenty held robust mutexes */ - int ptErrno; - int detachState; - int sched_priority; /* As set, not as currently is */ - int cancelState; - int cancelType; - int implicit:1; - DWORD thread; /* Win32 thread ID */ -#if defined(_UWIN) - DWORD dummy[5]; -#endif - size_t align; /* Force alignment if this struct is packed */ -}; - - -/* - * Special value to mark attribute objects as valid. - */ -#define PTW32_ATTR_VALID ((unsigned long) 0xC4C0FFEE) - -struct pthread_attr_t_ -{ - unsigned long valid; - void *stackaddr; - size_t stacksize; - int detachstate; - struct sched_param param; - int inheritsched; - int contentionscope; -#if defined(HAVE_SIGSET_T) - sigset_t sigmask; -#endif /* HAVE_SIGSET_T */ -}; - - -/* - * ==================== - * ==================== - * Semaphores, Mutexes and Condition Variables - * ==================== - * ==================== - */ - -struct sem_t_ -{ - int value; - pthread_mutex_t lock; - HANDLE sem; -#if defined(NEED_SEM) - int leftToUnblock; -#endif -}; - -#define PTW32_OBJECT_AUTO_INIT ((void *)(size_t) -1) -#define PTW32_OBJECT_INVALID NULL - -struct pthread_mutex_t_ -{ - LONG lock_idx; /* Provides exclusive access to mutex state - via the Interlocked* mechanism. - 0: unlocked/free. - 1: locked - no other waiters. - -1: locked - with possible other waiters. - */ - int recursive_count; /* Number of unlocks a thread needs to perform - before the lock is released (recursive - mutexes only). */ - int kind; /* Mutex type. */ - pthread_t ownerThread; - HANDLE event; /* Mutex release notification to waiting - threads. */ - ptw32_robust_node_t* - robustNode; /* Extra state for robust mutexes */ -}; - -enum ptw32_robust_state_t_ -{ - PTW32_ROBUST_CONSISTENT, - PTW32_ROBUST_INCONSISTENT, - PTW32_ROBUST_NOTRECOVERABLE -}; - -typedef enum ptw32_robust_state_t_ ptw32_robust_state_t; - -/* - * Node used to manage per-thread lists of currently-held robust mutexes. - */ -struct ptw32_robust_node_t_ -{ - pthread_mutex_t mx; - ptw32_robust_state_t stateInconsistent; - ptw32_robust_node_t* prev; - ptw32_robust_node_t* next; -}; - -struct pthread_mutexattr_t_ -{ - int pshared; - int kind; - int robustness; -}; - -/* - * Possible values, other than PTW32_OBJECT_INVALID, - * for the "interlock" element in a spinlock. - * - * In this implementation, when a spinlock is initialised, - * the number of cpus available to the process is checked. - * If there is only one cpu then "interlock" is set equal to - * PTW32_SPIN_USE_MUTEX and u.mutex is an initialised mutex. - * If the number of cpus is greater than 1 then "interlock" - * is set equal to PTW32_SPIN_UNLOCKED and the number is - * stored in u.cpus. This arrangement allows the spinlock - * routines to attempt an InterlockedCompareExchange on "interlock" - * immediately and, if that fails, to try the inferior mutex. - * - * "u.cpus" isn't used for anything yet, but could be used at - * some point to optimise spinlock behaviour. - */ -#define PTW32_SPIN_INVALID (0) -#define PTW32_SPIN_UNLOCKED (1) -#define PTW32_SPIN_LOCKED (2) -#define PTW32_SPIN_USE_MUTEX (3) - -struct pthread_spinlock_t_ -{ - long interlock; /* Locking element for multi-cpus. */ - union - { - int cpus; /* No. of cpus if multi cpus, or */ - pthread_mutex_t mutex; /* mutex if single cpu. */ - } u; -}; - -/* - * MCS lock queue node - see ptw32_MCS_lock.c - */ -struct ptw32_mcs_node_t_ -{ - struct ptw32_mcs_node_t_ **lock; /* ptr to tail of queue */ - struct ptw32_mcs_node_t_ *next; /* ptr to successor in queue */ - HANDLE readyFlag; /* set after lock is released by - predecessor */ - HANDLE nextFlag; /* set after 'next' ptr is set by - successor */ -}; - - -struct pthread_barrier_t_ -{ - unsigned int nCurrentBarrierHeight; - unsigned int nInitialBarrierHeight; - int pshared; - sem_t semBarrierBreeched; - ptw32_mcs_lock_t lock; - ptw32_mcs_local_node_t proxynode; -}; - -struct pthread_barrierattr_t_ -{ - int pshared; -}; - -struct pthread_key_t_ -{ - DWORD key; - void (PTW32_CDECL *destructor) (void *); - ptw32_mcs_lock_t keyLock; - void *threads; -}; - - -typedef struct ThreadParms ThreadParms; - -struct ThreadParms -{ - pthread_t tid; - void *(PTW32_CDECL *start) (void *); - void *arg; -}; - - -struct pthread_cond_t_ -{ - long nWaitersBlocked; /* Number of threads blocked */ - long nWaitersGone; /* Number of threads timed out */ - long nWaitersToUnblock; /* Number of threads to unblock */ - sem_t semBlockQueue; /* Queue up threads waiting for the */ - /* condition to become signalled */ - sem_t semBlockLock; /* Semaphore that guards access to */ - /* | waiters blocked count/block queue */ - /* +-> Mandatory Sync.LEVEL-1 */ - pthread_mutex_t mtxUnblockLock; /* Mutex that guards access to */ - /* | waiters (to)unblock(ed) counts */ - /* +-> Optional* Sync.LEVEL-2 */ - pthread_cond_t next; /* Doubly linked list */ - pthread_cond_t prev; -}; - - -struct pthread_condattr_t_ -{ - int pshared; -}; - -#define PTW32_RWLOCK_MAGIC 0xfacade2 - -struct pthread_rwlock_t_ -{ - pthread_mutex_t mtxExclusiveAccess; - pthread_mutex_t mtxSharedAccessCompleted; - pthread_cond_t cndSharedAccessCompleted; - int nSharedAccessCount; - int nExclusiveAccessCount; - int nCompletedSharedAccessCount; - int nMagic; -}; - -struct pthread_rwlockattr_t_ -{ - int pshared; -}; - -typedef struct ThreadKeyAssoc ThreadKeyAssoc; - -struct ThreadKeyAssoc -{ - /* - * Purpose: - * This structure creates an association between a thread and a key. - * It is used to implement the implicit invocation of a user defined - * destroy routine for thread specific data registered by a user upon - * exiting a thread. - * - * Graphically, the arrangement is as follows, where: - * - * K - Key with destructor - * (head of chain is key->threads) - * T - Thread that has called pthread_setspecific(Kn) - * (head of chain is thread->keys) - * A - Association. Each association is a node at the - * intersection of two doubly-linked lists. - * - * T1 T2 T3 - * | | | - * | | | - * K1 -----+-----A-----A-----> - * | | | - * | | | - * K2 -----A-----A-----+-----> - * | | | - * | | | - * K3 -----A-----+-----A-----> - * | | | - * | | | - * V V V - * - * Access to the association is guarded by two locks: the key's - * general lock (guarding the row) and the thread's general - * lock (guarding the column). This avoids the need for a - * dedicated lock for each association, which not only consumes - * more handles but requires that the lock resources persist - * until both the key is deleted and the thread has called the - * destructor. The two-lock arrangement allows those resources - * to be freed as soon as either thread or key is concluded. - * - * To avoid deadlock, whenever both locks are required both the - * key and thread locks are acquired consistently in the order - * "key lock then thread lock". An exception to this exists - * when a thread calls the destructors, however, this is done - * carefully (but inelegantly) to avoid deadlock. - * - * An association is created when a thread first calls - * pthread_setspecific() on a key that has a specified - * destructor. - * - * An association is destroyed either immediately after the - * thread calls the key destructor function on thread exit, or - * when the key is deleted. - * - * Attributes: - * thread - * reference to the thread that owns the - * association. This is actually the pointer to the - * thread struct itself. Since the association is - * destroyed before the thread exits, this can never - * point to a different logical thread to the one that - * created the assoc, i.e. after thread struct reuse. - * - * key - * reference to the key that owns the association. - * - * nextKey - * The pthread_t->keys attribute is the head of a - * chain of associations that runs through the nextKey - * link. This chain provides the 1 to many relationship - * between a pthread_t and all pthread_key_t on which - * it called pthread_setspecific. - * - * prevKey - * Similarly. - * - * nextThread - * The pthread_key_t->threads attribute is the head of - * a chain of associations that runs through the - * nextThreads link. This chain provides the 1 to many - * relationship between a pthread_key_t and all the - * PThreads that have called pthread_setspecific for - * this pthread_key_t. - * - * prevThread - * Similarly. - * - * Notes: - * 1) As soon as either the key or the thread is no longer - * referencing the association, it can be destroyed. The - * association will be removed from both chains. - * - * 2) Under WIN32, an association is only created by - * pthread_setspecific if the user provided a - * destroyRoutine when they created the key. - * - * - */ - ptw32_thread_t * thread; - pthread_key_t key; - ThreadKeyAssoc *nextKey; - ThreadKeyAssoc *nextThread; - ThreadKeyAssoc *prevKey; - ThreadKeyAssoc *prevThread; -}; - - -#if defined(__CLEANUP_SEH) -/* - * -------------------------------------------------------------- - * MAKE_SOFTWARE_EXCEPTION - * This macro constructs a software exception code following - * the same format as the standard Win32 error codes as defined - * in WINERROR.H - * Values are 32 bit values laid out as follows: - * - * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 - * +---+-+-+-----------------------+-------------------------------+ - * |Sev|C|R| Facility | Code | - * +---+-+-+-----------------------+-------------------------------+ - * - * Severity Values: - */ -#define SE_SUCCESS 0x00 -#define SE_INFORMATION 0x01 -#define SE_WARNING 0x02 -#define SE_ERROR 0x03 - -#define MAKE_SOFTWARE_EXCEPTION( _severity, _facility, _exception ) \ -( (DWORD) ( ( (_severity) << 30 ) | /* Severity code */ \ - ( 1 << 29 ) | /* MS=0, User=1 */ \ - ( 0 << 28 ) | /* Reserved */ \ - ( (_facility) << 16 ) | /* Facility Code */ \ - ( (_exception) << 0 ) /* Exception Code */ \ - ) ) - -/* - * We choose one specific Facility/Error code combination to - * identify our software exceptions vs. WIN32 exceptions. - * We store our actual component and error code within - * the optional information array. - */ -#define EXCEPTION_PTW32_SERVICES \ - MAKE_SOFTWARE_EXCEPTION( SE_ERROR, \ - PTW32_SERVICES_FACILITY, \ - PTW32_SERVICES_ERROR ) - -#define PTW32_SERVICES_FACILITY 0xBAD -#define PTW32_SERVICES_ERROR 0xDEED - -#endif /* __CLEANUP_SEH */ - -/* - * Services available through EXCEPTION_PTW32_SERVICES - * and also used [as parameters to ptw32_throw()] as - * generic exception selectors. - */ - -#define PTW32_EPS_EXIT (1) -#define PTW32_EPS_CANCEL (2) - - -/* Useful macros */ -#define PTW32_MAX(a,b) ((a)<(b)?(b):(a)) -#define PTW32_MIN(a,b) ((a)>(b)?(b):(a)) - - -/* Declared in pthread_cancel.c */ -extern DWORD (*ptw32_register_cancelation) (PAPCFUNC, HANDLE, DWORD); - -/* Thread Reuse stack bottom marker. Must not be NULL or any valid pointer to memory. */ -#define PTW32_THREAD_REUSE_EMPTY ((ptw32_thread_t *)(size_t) 1) - -extern int ptw32_processInitialized; -extern ptw32_thread_t * ptw32_threadReuseTop; -extern ptw32_thread_t * ptw32_threadReuseBottom; -extern pthread_key_t ptw32_selfThreadKey; -extern pthread_key_t ptw32_cleanupKey; -extern pthread_cond_t ptw32_cond_list_head; -extern pthread_cond_t ptw32_cond_list_tail; - -extern int ptw32_mutex_default_kind; - -extern unsigned __int64 ptw32_threadSeqNumber; - -extern int ptw32_concurrency; - -extern int ptw32_features; - -extern ptw32_mcs_lock_t ptw32_thread_reuse_lock; -extern ptw32_mcs_lock_t ptw32_mutex_test_init_lock; -extern ptw32_mcs_lock_t ptw32_cond_list_lock; -extern ptw32_mcs_lock_t ptw32_cond_test_init_lock; -extern ptw32_mcs_lock_t ptw32_rwlock_test_init_lock; -extern ptw32_mcs_lock_t ptw32_spinlock_test_init_lock; - -#if defined(_UWIN) -extern int pthread_count; -#endif - -#if defined(__cplusplus) -extern "C" -{ -#endif /* __cplusplus */ - -/* - * ===================== - * ===================== - * Forward Declarations - * ===================== - * ===================== - */ - - int ptw32_is_attr (const pthread_attr_t * attr); - - int ptw32_cond_check_need_init (pthread_cond_t * cond); - int ptw32_mutex_check_need_init (pthread_mutex_t * mutex); - int ptw32_rwlock_check_need_init (pthread_rwlock_t * rwlock); - - int ptw32_robust_mutex_inherit(pthread_mutex_t * mutex); - void ptw32_robust_mutex_add(pthread_mutex_t* mutex, pthread_t self); - void ptw32_robust_mutex_remove(pthread_mutex_t* mutex, ptw32_thread_t* otp); - - DWORD - ptw32_RegisterCancelation (PAPCFUNC callback, - HANDLE threadH, DWORD callback_arg); - - int ptw32_processInitialize (void); - - void ptw32_processTerminate (void); - - void ptw32_threadDestroy (pthread_t tid); - - void ptw32_pop_cleanup_all (int execute); - - pthread_t ptw32_new (void); - - pthread_t ptw32_threadReusePop (void); - - void ptw32_threadReusePush (pthread_t thread); - - int ptw32_getprocessors (int *count); - - int ptw32_setthreadpriority (pthread_t thread, int policy, int priority); - - void ptw32_rwlock_cancelwrwait (void *arg); - -#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || (defined(__MSVCRT__) && ! defined(__DMC__)) - unsigned __stdcall -#else - void -#endif - ptw32_threadStart (void *vthreadParms); - - void ptw32_callUserDestroyRoutines (pthread_t thread); - - int ptw32_tkAssocCreate (ptw32_thread_t * thread, pthread_key_t key); - - void ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc); - - int ptw32_semwait (sem_t * sem); - - DWORD ptw32_relmillisecs (const struct timespec * abstime); - - void ptw32_mcs_lock_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node); - - int ptw32_mcs_lock_try_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node); - - void ptw32_mcs_lock_release (ptw32_mcs_local_node_t * node); - - void ptw32_mcs_node_transfer (ptw32_mcs_local_node_t * new_node, ptw32_mcs_local_node_t * old_node); - -#if defined(NEED_FTIME) - void ptw32_timespec_to_filetime (const struct timespec *ts, FILETIME * ft); - void ptw32_filetime_to_timespec (const FILETIME * ft, struct timespec *ts); -#endif - -/* Declared in misc.c */ -#if defined(NEED_CALLOC) -#define calloc(n, s) ptw32_calloc(n, s) - void *ptw32_calloc (size_t n, size_t s); -#endif - -/* Declared in private.c */ -#if defined(_MSC_VER) -/* - * Ignore the warning: - * "C++ exception specification ignored except to indicate that - * the function is not __declspec(nothrow)." - */ -#pragma warning(disable:4290) -#endif - void ptw32_throw (DWORD exception) -#if defined(__CLEANUP_CXX) - throw(ptw32_exception_cancel,ptw32_exception_exit) -#endif -; - -#if defined(__cplusplus) -} -#endif /* __cplusplus */ - - -#if defined(_UWIN_) -# if defined(_MT) -# if defined(__cplusplus) -extern "C" -{ -# endif - _CRTIMP unsigned long __cdecl _beginthread (void (__cdecl *) (void *), - unsigned, void *); - _CRTIMP void __cdecl _endthread (void); - _CRTIMP unsigned long __cdecl _beginthreadex (void *, unsigned, - unsigned (__stdcall *) (void *), - void *, unsigned, unsigned *); - _CRTIMP void __cdecl _endthreadex (unsigned); -# if defined(__cplusplus) -} -# endif -# endif -#else -# include -# endif - - -/* - * Use intrinsic versions wherever possible. VC will do this - * automatically where possible and GCC define these if available: - * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 - * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 - * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 - * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 - * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 - * - * The full set of Interlocked intrinsics in GCC are (check versions): - * type __sync_fetch_and_add (type *ptr, type value, ...) - * type __sync_fetch_and_sub (type *ptr, type value, ...) - * type __sync_fetch_and_or (type *ptr, type value, ...) - * type __sync_fetch_and_and (type *ptr, type value, ...) - * type __sync_fetch_and_xor (type *ptr, type value, ...) - * type __sync_fetch_and_nand (type *ptr, type value, ...) - * type __sync_add_and_fetch (type *ptr, type value, ...) - * type __sync_sub_and_fetch (type *ptr, type value, ...) - * type __sync_or_and_fetch (type *ptr, type value, ...) - * type __sync_and_and_fetch (type *ptr, type value, ...) - * type __sync_xor_and_fetch (type *ptr, type value, ...) - * type __sync_nand_and_fetch (type *ptr, type value, ...) - * bool __sync_bool_compare_and_swap (type *ptr, type oldval type newval, ...) - * type __sync_val_compare_and_swap (type *ptr, type oldval type newval, ...) - * __sync_synchronize (...) // Full memory barrier - * type __sync_lock_test_and_set (type *ptr, type value, ...) // Acquire barrier - * void __sync_lock_release (type *ptr, ...) // Release barrier - * - * These are all overloaded and take 1,2,4,8 byte scalar or pointer types. - * - * The above aren't available in Mingw32 as of gcc 4.5.2 so define our own. - */ -#if defined(__GNUC__) -# if defined(_WIN64) -# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_64(location, value, comparand) \ - ({ \ - __typeof (value) _result; \ - __asm__ __volatile__ \ - ( \ - "lock\n\t" \ - "cmpxchgq %2,(%1)" \ - :"=a" (_result) \ - :"r" (location), "r" (value), "a" (comparand) \ - :"memory", "cc"); \ - _result; \ - }) -# define PTW32_INTERLOCKED_EXCHANGE_64(location, value) \ - ({ \ - __typeof (value) _result; \ - __asm__ __volatile__ \ - ( \ - "xchgq %0,(%1)" \ - :"=r" (_result) \ - :"r" (location), "0" (value) \ - :"memory", "cc"); \ - _result; \ - }) -# define PTW32_INTERLOCKED_EXCHANGE_ADD_64(location, value) \ - ({ \ - __typeof (value) _result; \ - __asm__ __volatile__ \ - ( \ - "lock\n\t" \ - "xaddq %0,(%1)" \ - :"=r" (_result) \ - :"r" (location), "0" (value) \ - :"memory", "cc"); \ - _result; \ - }) -# define PTW32_INTERLOCKED_INCREMENT_64(location) \ - ({ \ - PTW32_INTERLOCKED_LONG _temp = 1; \ - __asm__ __volatile__ \ - ( \ - "lock\n\t" \ - "xaddq %0,(%1)" \ - :"+r" (_temp) \ - :"r" (location) \ - :"memory", "cc"); \ - ++_temp; \ - }) -# define PTW32_INTERLOCKED_DECREMENT_64(location) \ - ({ \ - PTW32_INTERLOCKED_LONG _temp = -1; \ - __asm__ __volatile__ \ - ( \ - "lock\n\t" \ - "xaddq %2,(%1)" \ - :"+r" (_temp) \ - :"r" (location) \ - :"memory", "cc"); \ - --_temp; \ - }) -#endif -# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG(location, value, comparand) \ - ({ \ - __typeof (value) _result; \ - __asm__ __volatile__ \ - ( \ - "lock\n\t" \ - "cmpxchgl %2,(%1)" \ - :"=a" (_result) \ - :"r" (location), "r" (value), "a" (comparand) \ - :"memory", "cc"); \ - _result; \ - }) -# define PTW32_INTERLOCKED_EXCHANGE_LONG(location, value) \ - ({ \ - __typeof (value) _result; \ - __asm__ __volatile__ \ - ( \ - "xchgl %0,(%1)" \ - :"=r" (_result) \ - :"r" (location), "0" (value) \ - :"memory", "cc"); \ - _result; \ - }) -# define PTW32_INTERLOCKED_EXCHANGE_ADD_LONG(location, value) \ - ({ \ - __typeof (value) _result; \ - __asm__ __volatile__ \ - ( \ - "lock\n\t" \ - "xaddl %0,(%1)" \ - :"=r" (_result) \ - :"r" (location), "0" (value) \ - :"memory", "cc"); \ - _result; \ - }) -# define PTW32_INTERLOCKED_INCREMENT_LONG(location) \ - ({ \ - PTW32_INTERLOCKED_LONG _temp = 1; \ - __asm__ __volatile__ \ - ( \ - "lock\n\t" \ - "xaddl %0,(%1)" \ - :"+r" (_temp) \ - :"r" (location) \ - :"memory", "cc"); \ - ++_temp; \ - }) -# define PTW32_INTERLOCKED_DECREMENT_LONG(location) \ - ({ \ - PTW32_INTERLOCKED_LONG _temp = -1; \ - __asm__ __volatile__ \ - ( \ - "lock\n\t" \ - "xaddl %0,(%1)" \ - :"+r" (_temp) \ - :"r" (location) \ - :"memory", "cc"); \ - --_temp; \ - }) -# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR(location, value, comparand) \ - PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE((PTW32_INTERLOCKED_SIZEPTR)location, \ - (PTW32_INTERLOCKED_SIZE)value, \ - (PTW32_INTERLOCKED_SIZE)comparand) -# define PTW32_INTERLOCKED_EXCHANGE_PTR(location, value) \ - PTW32_INTERLOCKED_EXCHANGE_SIZE((PTW32_INTERLOCKED_SIZEPTR)location, \ - (PTW32_INTERLOCKED_SIZE)value) -#else -# if defined(_WIN64) -# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_64 InterlockedCompareExchange64 -# define PTW32_INTERLOCKED_EXCHANGE_64 InterlockedExchange64 -# define PTW32_INTERLOCKED_EXCHANGE_ADD_64 InterlockedExchangeAdd64 -# define PTW32_INTERLOCKED_INCREMENT_64 InterlockedIncrement64 -# define PTW32_INTERLOCKED_DECREMENT_64 InterlockedDecrement64 -# endif -# if defined(_MSC_VER) && _MSC_VER < 1300 && !defined(_WIN64) /* MSVC 6 */ -# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG(location, value, comparand) \ - ((LONG)InterlockedCompareExchange((PVOID *)(location), (PVOID)(value), (PVOID)(comparand))) -# else -# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG InterlockedCompareExchange -# endif -# define PTW32_INTERLOCKED_EXCHANGE_LONG InterlockedExchange -# define PTW32_INTERLOCKED_EXCHANGE_ADD_LONG InterlockedExchangeAdd -# define PTW32_INTERLOCKED_INCREMENT_LONG InterlockedIncrement -# define PTW32_INTERLOCKED_DECREMENT_LONG InterlockedDecrement -# if defined(_MSC_VER) && _MSC_VER < 1300 && !defined(_WIN64) /* MSVC 6 */ -# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR InterlockedCompareExchange -# define PTW32_INTERLOCKED_EXCHANGE_PTR(location, value) \ - ((PVOID)InterlockedExchange((LPLONG)(location), (LONG)(value))) -# else -# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR InterlockedCompareExchangePointer -# define PTW32_INTERLOCKED_EXCHANGE_PTR InterlockedExchangePointer -# endif -#endif -#if defined(_WIN64) -# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE PTW32_INTERLOCKED_COMPARE_EXCHANGE_64 -# define PTW32_INTERLOCKED_EXCHANGE_SIZE PTW32_INTERLOCKED_EXCHANGE_64 -# define PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE PTW32_INTERLOCKED_EXCHANGE_ADD_64 -# define PTW32_INTERLOCKED_INCREMENT_SIZE PTW32_INTERLOCKED_INCREMENT_64 -# define PTW32_INTERLOCKED_DECREMENT_SIZE PTW32_INTERLOCKED_DECREMENT_64 -#else -# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG -# define PTW32_INTERLOCKED_EXCHANGE_SIZE PTW32_INTERLOCKED_EXCHANGE_LONG -# define PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE PTW32_INTERLOCKED_EXCHANGE_ADD_LONG -# define PTW32_INTERLOCKED_INCREMENT_SIZE PTW32_INTERLOCKED_INCREMENT_LONG -# define PTW32_INTERLOCKED_DECREMENT_SIZE PTW32_INTERLOCKED_DECREMENT_LONG -#endif - -#if defined(NEED_CREATETHREAD) - -/* - * Macro uses args so we can cast start_proc to LPTHREAD_START_ROUTINE - * in order to avoid warnings because of return type - */ - -#define _beginthreadex(security, \ - stack_size, \ - start_proc, \ - arg, \ - flags, \ - pid) \ - CreateThread(security, \ - stack_size, \ - (LPTHREAD_START_ROUTINE) start_proc, \ - arg, \ - flags, \ - pid) - -#define _endthreadex ExitThread - -#endif /* NEED_CREATETHREAD */ - - -#endif /* _IMPLEMENT_H */ diff --git a/deps/w32-pthreads/libpthreadGC2.a b/deps/w32-pthreads/libpthreadGC2.a deleted file mode 100644 index 43ff77e..0000000 Binary files a/deps/w32-pthreads/libpthreadGC2.a and /dev/null differ diff --git a/deps/w32-pthreads/libpthreadGC2.stamp b/deps/w32-pthreads/libpthreadGC2.stamp deleted file mode 100644 index 16225d0..0000000 --- a/deps/w32-pthreads/libpthreadGC2.stamp +++ /dev/null @@ -1 +0,0 @@ -touched diff --git a/deps/w32-pthreads/manual/ChangeLog b/deps/w32-pthreads/manual/ChangeLog deleted file mode 100644 index 071b847..0000000 --- a/deps/w32-pthreads/manual/ChangeLog +++ /dev/null @@ -1,74 +0,0 @@ -2011-03-26 Ross Johnson - - * pthread_nutex_init.html (robust mutexes): Added - descriptions for newly implemented interface. - * pthread_mutexattr_init.html (robust mutexes): Likewise. - * pthread_getsequence_np.html: New. - * index.html: Updated. - -2008-06-30 Ross Johnson - - * pthread_setschedparam.html: Fix "see also" links. - -2005-05-06 Ross Johnson - - * PortabilityIssues.html: Was nonPortableIssues.html. - * index.html: Updated; add table of contents at top. - * *.html: Add Pthreads-win32 header info; add link back to the - index page 'index.html'. - -2005-05-06 Ross Johnson - - * index.html: New. - * nonPortableIssues.html: New. - * pthread_attr_init.html: New. - * pthread_attr_setstackaddr.html: New. - * pthread_attr_setstacksize.html: New. - * pthread_barrierattr_init.html: New. - * pthread_barrierattr_setpshared.html: New. - * pthread_barrier_init.html: New. - * pthread_barrier_wait.html: New. - * pthreadCancelableWait.html: New. - * pthread_cancel.html: New. - * pthread_cleanup_push.html: New. - * pthread_condattr_init.html: New. - * pthread_condattr_setpshared.html: New. - * pthread_cond_init.html: New. - * pthread_create.html: New. - * pthread_delay_np.html: New. - * pthread_detach.html: New. - * pthread_equal.html: New. - * pthread_exit.html: New. - * pthread_getw32threadhandle_np.html: New. - * pthread_join.html: New. - * pthread_key_create.html: New. - * pthread_kill.html: New. - * pthread_mutexattr_init.html: New. - * pthread_mutexattr_setpshared.html: New. - * pthread_mutex_init.html: New. - * pthread_num_processors_np.html: New. - * pthread_once.html: New. - * pthread_rwlockattr_init.html: New. - * pthread_rwlockattr_setpshared.html: New. - * pthread_rwlock_init.html: New. - * pthread_rwlock_rdlock.html: New. - * pthread_rwlock_timedrdlock.html: New. - * pthread_rwlock_timedwrlock.html: New. - * pthread_rwlock_unlock.html: New. - * pthread_rwlock_wrlock.html: New. - * pthread_self.html: New. - * pthread_setcancelstate.html: New. - * pthread_setcanceltype.html: New. - * pthread_setconcurrency.html: New. - * pthread_setschedparam.html: New. - * pthread_spin_init.html: New. - * pthread_spin_lock.html: New. - * pthread_spin_unlock.html: New. - * pthread_timechange_handler_np.html: New. - * pthread_win32_attach_detach_np.html: New. - * pthread_win32_test_features_np.html: New. - * sched_get_priority_max.html: New. - * sched_getscheduler.html: New. - * sched_setscheduler.html: New. - * sched_yield.html: New. - * sem_init.html: New. diff --git a/deps/w32-pthreads/manual/PortabilityIssues.html b/deps/w32-pthreads/manual/PortabilityIssues.html deleted file mode 100644 index 376a5f0..0000000 --- a/deps/w32-pthreads/manual/PortabilityIssues.html +++ /dev/null @@ -1,718 +0,0 @@ - - - - - PORTABILITYISSUES manual page - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

Portability issues

-

Synopsis

-

Thread priority

-

Description

-

Thread priority

-

POSIX defines a single contiguous range -of numbers that determine a thread's priority. Win32 defines priority -classes - and priority levels relative to these classes. Classes are -simply priority base levels that the defined priority levels are -relative to such that, changing a process's priority class will -change the priority of all of it's threads, while the threads retain -the same relativity to each other.

-

A Win32 system defines a single -contiguous monotonic range of values that define system priority -levels, just like POSIX. However, Win32 restricts individual threads -to a subset of this range on a per-process basis.

-

The following table shows the base -priority levels for combinations of priority class and priority value -in Win32.

-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-


-

-
-

Process Priority Class

-
-

Thread Priority Level

-
-

1

-
-

IDLE_PRIORITY_CLASS

-
-

THREAD_PRIORITY_IDLE

-
-

1

-
-

BELOW_NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_IDLE

-
-

1

-
-

NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_IDLE

-
-

1

-
-

ABOVE_NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_IDLE

-
-

1

-
-

HIGH_PRIORITY_CLASS

-
-

THREAD_PRIORITY_IDLE

-
-

2

-
-

IDLE_PRIORITY_CLASS

-
-

THREAD_PRIORITY_LOWEST

-
-

3

-
-

IDLE_PRIORITY_CLASS

-
-

THREAD_PRIORITY_BELOW_NORMAL

-
-

4

-
-

IDLE_PRIORITY_CLASS

-
-

THREAD_PRIORITY_NORMAL

-
-

4

-
-

BELOW_NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_LOWEST

-
-

5

-
-

IDLE_PRIORITY_CLASS

-
-

THREAD_PRIORITY_ABOVE_NORMAL

-
-

5

-
-

BELOW_NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_BELOW_NORMAL

-
-

5

-
-

Background NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_LOWEST

-
-

6

-
-

IDLE_PRIORITY_CLASS

-
-

THREAD_PRIORITY_HIGHEST

-
-

6

-
-

BELOW_NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_NORMAL

-
-

6

-
-

Background NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_BELOW_NORMAL

-
-

7

-
-

BELOW_NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_ABOVE_NORMAL

-
-

7

-
-

Background NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_NORMAL

-
-

7

-
-

Foreground NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_LOWEST

-
-

8

-
-

BELOW_NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_HIGHEST

-
-

8

-
-

NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_ABOVE_NORMAL

-
-

8

-
-

Foreground NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_BELOW_NORMAL

-
-

8

-
-

ABOVE_NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_LOWEST

-
-

9

-
-

NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_HIGHEST

-
-

9

-
-

Foreground NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_NORMAL

-
-

9

-
-

ABOVE_NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_BELOW_NORMAL

-
-

10

-
-

Foreground NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_ABOVE_NORMAL

-
-

10

-
-

ABOVE_NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_NORMAL

-
-

11

-
-

Foreground NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_HIGHEST

-
-

11

-
-

ABOVE_NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_ABOVE_NORMAL

-
-

11

-
-

HIGH_PRIORITY_CLASS

-
-

THREAD_PRIORITY_LOWEST

-
-

12

-
-

ABOVE_NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_HIGHEST

-
-

12

-
-

HIGH_PRIORITY_CLASS

-
-

THREAD_PRIORITY_BELOW_NORMAL

-
-

13

-
-

HIGH_PRIORITY_CLASS

-
-

THREAD_PRIORITY_NORMAL

-
-

14

-
-

HIGH_PRIORITY_CLASS

-
-

THREAD_PRIORITY_ABOVE_NORMAL

-
-

15

-
-

HIGH_PRIORITY_CLASS

-
-

THREAD_PRIORITY_HIGHEST

-
-

15

-
-

HIGH_PRIORITY_CLASS

-
-

THREAD_PRIORITY_TIME_CRITICAL

-
-

15

-
-

IDLE_PRIORITY_CLASS

-
-

THREAD_PRIORITY_TIME_CRITICAL

-
-

15

-
-

BELOW_NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_TIME_CRITICAL

-
-

15

-
-

NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_TIME_CRITICAL

-
-

15

-
-

ABOVE_NORMAL_PRIORITY_CLASS

-
-

THREAD_PRIORITY_TIME_CRITICAL

-
-

16

-
-

REALTIME_PRIORITY_CLASS

-
-

THREAD_PRIORITY_IDLE

-
-

17

-
-

REALTIME_PRIORITY_CLASS

-
-

-7

-
-

18

-
-

REALTIME_PRIORITY_CLASS

-
-

-6

-
-

19

-
-

REALTIME_PRIORITY_CLASS

-
-

-5

-
-

20

-
-

REALTIME_PRIORITY_CLASS

-
-

-4

-
-

21

-
-

REALTIME_PRIORITY_CLASS

-
-

-3

-
-

22

-
-

REALTIME_PRIORITY_CLASS

-
-

THREAD_PRIORITY_LOWEST

-
-

23

-
-

REALTIME_PRIORITY_CLASS

-
-

THREAD_PRIORITY_BELOW_NORMAL

-
-

24

-
-

REALTIME_PRIORITY_CLASS

-
-

THREAD_PRIORITY_NORMAL

-
-

25

-
-

REALTIME_PRIORITY_CLASS

-
-

THREAD_PRIORITY_ABOVE_NORMAL

-
-

26

-
-

REALTIME_PRIORITY_CLASS

-
-

THREAD_PRIORITY_HIGHEST

-
-

27

-
-

REALTIME_PRIORITY_CLASS

-
-

3

-
-

28

-
-

REALTIME_PRIORITY_CLASS

-
-

4

-
-

29

-
-

REALTIME_PRIORITY_CLASS

-
-

5

-
-

30

-
-

REALTIME_PRIORITY_CLASS

-
-

6

-
-

31

-
-

REALTIME_PRIORITY_CLASS

-
-

THREAD_PRIORITY_TIME_CRITICAL

-
-
-
-

Windows NT: Values -7, -6, -5, -4, -3, 3, -4, 5, and 6 are not supported.

-

As you can see, the real priority levels -available to any individual Win32 thread are non-contiguous.

-

An application using Pthreads-w32 should -not make assumptions about the numbers used to represent thread -priority levels, except that they are monotonic between the values -returned by sched_get_priority_min() and sched_get_priority_max(). -E.g. Windows 95, 98, NT, 2000, XP make available a non-contiguous -range of numbers between -15 and 15, while at least one version of -WinCE (3.0) defines the minimum priority (THREAD_PRIORITY_LOWEST) as -5, and the maximum priority (THREAD_PRIORITY_HIGHEST) as 1.

-

Internally, pthreads-win32 maps any -priority levels between THREAD_PRIORITY_IDLE and -THREAD_PRIORITY_LOWEST to THREAD_PRIORITY_LOWEST, or between -THREAD_PRIORITY_TIME_CRITICAL and THREAD_PRIORITY_HIGHEST to -THREAD_PRIORITY_HIGHEST. Currently, this also applies to -REALTIME_PRIORITY_CLASS even if levels -7, -6, -5, -4, -3, 3, 4, 5, -and 6 are supported.

-

If it wishes, a Win32 application using -pthreads-w32 can use the Win32 defined priority macros -THREAD_PRIORITY_IDLE through THREAD_PRIORITY_TIME_CRITICAL.

-

Author

-

Ross Johnson for use with Pthreads-w32.

-

See also

-



-

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/index.html b/deps/w32-pthreads/manual/index.html deleted file mode 100644 index f7b5bc9..0000000 --- a/deps/w32-pthreads/manual/index.html +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - -Pthreads-w32

-

Table of Contents

-

POSIX -threads API reference
Miscellaneous -POSIX thread safe routines provided by Pthreads-w32
Non-portable -Pthreads-w32 routines
Other

-

POSIX threads API -reference

-

pthread_attr_destroy

-

pthread_attr_getdetachstate

-

pthread_attr_getinheritsched

-

pthread_attr_getschedparam

-

pthread_attr_getschedpolicy

-

pthread_attr_getscope

-

pthread_attr_getstackaddr

-

pthread_attr_getstacksize

-

pthread_attr_init

-

pthread_attr_setdetachstate

-

pthread_attr_setinheritsched

-

pthread_attr_setschedparam

-

pthread_attr_setschedpolicy

-

pthread_attr_setscope

-

pthread_attr_setstackaddr

-

pthread_attr_setstacksize

-

pthread_barrierattr_destroy

-

pthread_barrierattr_getpshared

-

pthread_barrierattr_init

-

pthread_barrierattr_setpshared

-

pthread_barrier_destroy

-

pthread_barrier_init

-

pthread_barrier_wait

-

pthread_cancel

-

pthread_cleanup_pop

-

pthread_cleanup_push

-

pthread_condattr_destroy

-

pthread_condattr_getpshared

-

pthread_condattr_init

-

pthread_condattr_setpshared

-

pthread_cond_broadcast

-

pthread_cond_destroy

-

pthread_cond_init

-

pthread_cond_signal

-

pthread_cond_timedwait

-

pthread_cond_wait

-

pthread_create

-

pthread_detach

-

pthread_equal

-

pthread_exit

-

pthread_getconcurrency

-

pthread_getschedparam

-

pthread_getunique_np

-

pthread_getspecific

-

pthread_join

-

pthread_key_create

-

pthread_key_delete

-

pthread_kill

-

pthread_mutexattr_destroy

-

pthread_mutexattr_getkind_np

-

pthread_mutexattr_getpshared

-

pthread_mutexattr_getrobust

-

pthread_mutexattr_gettype

-

pthread_mutexattr_init

-

pthread_mutexattr_setkind_np

-

pthread_mutexattr_setpshared

-

pthread_mutexattr_setrobust

-

pthread_mutexattr_settype

-

pthread_mutex_consistent

-

pthread_mutex_destroy

-

pthread_mutex_init

-

pthread_mutex_lock

-

pthread_mutex_timedlock

-

pthread_mutex_trylock

-

pthread_mutex_unlock

-

pthread_once

-

pthread_rwlockattr_destroy

-

pthread_rwlockattr_getpshared

-

pthread_rwlockattr_init

-

pthread_rwlockattr_setpshared

-

pthread_rwlock_destroy

-

pthread_rwlock_init

-

pthread_rwlock_rdlock

-

pthread_rwlock_timedrdlock

-

pthread_rwlock_timedwrlock

-

pthread_rwlock_tryrdlock

-

pthread_rwlock_trywrlock

-

pthread_rwlock_unlock

-

pthread_rwlock_wrlock

-

pthread_self

-

pthread_setcancelstate

-

pthread_setcanceltype

-

pthread_setconcurrency

-

pthread_setschedparam

-

pthread_setspecific

-

pthread_sigmask

-

pthread_spin_destroy

-

pthread_spin_init

-

pthread_spin_lock

-

pthread_spin_trylock

-

pthread_spin_unlock

-

pthread_testcancel

-

sched_get_priority_max

-

sched_get_priority_min

-

sched_getscheduler

-

sched_setscheduler

-

sched_yield

-

sem_close

-

sem_destroy

-

sem_getvalue

-

sem_init

-

sem_open

-

sem_post

-

sem_post_multiple

-

sem_timedwait

-

sem_trywait

-

sem_unlink

-

sem_wait

-

sigwait

-

Non-portable -Pthreads-w32 routines

-

pthreadCancelableTimedWait

-

pthreadCancelableWait

-

pthread_delay_np

-

pthread_getw32threadhandle_np

-

pthread_num_processors_np

-

pthread_win32_test_features_np

-

pthread_timechange_handler_np

-

pthread_win32_process_attach_np

-

pthread_win32_process_detach_np

-

pthread_win32_thread_attach_np

-

pthread_win32_thread_detach_np

-

Other

-

Portability -issues

- - \ No newline at end of file diff --git a/deps/w32-pthreads/manual/pthreadCancelableWait.html b/deps/w32-pthreads/manual/pthreadCancelableWait.html deleted file mode 100644 index 9d7c1a4..0000000 --- a/deps/w32-pthreads/manual/pthreadCancelableWait.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - - PTHREADCANCELLABLEWAIT manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthreadCancelableTimedWait, -pthreadCancelableWait ā€“ provide cancellation hooks for user Win32 -routines

-

Synopsis

-

#include <pthread.h> -

-

int pthreadCancelableTimedWait (HANDLE waitHandle, -DWORD timeout);

-

int pthreadCancelableWait (HANDLE waitHandle);

-

Description

-

These two functions provide hooks into the pthread_cancel() -mechanism that will allow you to wait on a Windows handle and make it -a cancellation point. Both functions block until either the given -Win32 HANDLE is signalled, or pthread_cancel() -has been called. They are implemented using WaitForMultipleObjects -on waitHandle and the manually reset Win32 event handle that -is the target of pthread_cancel(). -These routines may be called from Win32 native threads but -pthread_cancel() will -require that thread's POSIX thread ID that the thread must retrieve -using pthread_self().

-

pthreadCancelableTimedWait is the timed version that will -return with the code ETIMEDOUT if the interval timeout -milliseconds elapses before waitHandle is signalled.

-

Cancellation

-

These routines allow routines that block on Win32 HANDLEs to be -cancellable via pthread_cancel().

-

Return Value

-



-

-

Errors

-

The pthreadCancelableTimedWait function returns the -following error code on error: -

-
-
-
ETIMEDOUT -
-
-

-The interval timeout milliseconds elapsed before waitHandle -was signalled.

-

Author

-

Ross Johnson for use with Pthreads-w32.

-

See also

-

pthread_cancel(), -pthread_self()

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_attr_init.html b/deps/w32-pthreads/manual/pthread_attr_init.html deleted file mode 100644 index fa5ab58..0000000 --- a/deps/w32-pthreads/manual/pthread_attr_init.html +++ /dev/null @@ -1,280 +0,0 @@ - - - - - PTHREAD_ATTR_INIT(3) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_attr_init, pthread_attr_destroy, -pthread_attr_setdetachstate, pthread_attr_getdetachstate, -pthread_attr_setschedparam, pthread_attr_getschedparam, -pthread_attr_setschedpolicy, pthread_attr_getschedpolicy, -pthread_attr_setinheritsched, pthread_attr_getinheritsched, -pthread_attr_setscope, pthread_attr_getscope - thread creation -attributes -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_attr_init(pthread_attr_t *attr); -

-

int pthread_attr_destroy(pthread_attr_t *attr); -

-

int pthread_attr_setdetachstate(pthread_attr_t *attr, -int detachstate); -

-

int pthread_attr_getdetachstate(const pthread_attr_t *attr, -int *detachstate); -

-

int pthread_attr_setschedpolicy(pthread_attr_t *attr, -int policy); -

-

int pthread_attr_getschedpolicy(const pthread_attr_t *attr, -int *policy); -

-

int pthread_attr_setschedparam(pthread_attr_t *attr, -const struct sched_param *param); -

-

int pthread_attr_getschedparam(const pthread_attr_t *attr, -struct sched_param *param); -

-

int pthread_attr_setinheritsched(pthread_attr_t *attr, -int inherit); -

-

int pthread_attr_getinheritsched(const pthread_attr_t *attr, -int *inherit); -

-

int pthread_attr_setscope(pthread_attr_t *attr, -int scope); -

-

int pthread_attr_getscope(const pthread_attr_t *attr, -int *scope); -

-

Description

-

Setting attributes for threads is achieved by filling a thread -attribute object attr of type pthread_attr_t, then -passing it as second argument to pthread_create(3) -. Passing NULL is equivalent to passing a thread attribute -object with all attributes set to their default values. -

-

pthread_attr_init initializes the thread attribute object -attr and fills it with default values for the attributes. (The -default values are listed below for each attribute.) -

-

Each attribute attrname (see below for a list of all -attributes) can be individually set using the function -pthread_attr_setattrname and retrieved using the -function pthread_attr_getattrname. -

-

pthread_attr_destroy destroys a thread attribute object, -which must not then be reused until it is reinitialized. -

-

Attribute objects are consulted only when creating a new thread. -The same attribute object can be used for creating several threads. -Modifying an attribute object after a call to pthread_create -does not change the attributes of the thread previously created. -

-

The following thread attributes are supported: -

-

detachstate

-

Control whether the thread is created in the joinable state (value -PTHREAD_CREATE_JOINABLE) or in the detached state ( -PTHREAD_CREATE_DETACHED). -

-

Default value: PTHREAD_CREATE_JOINABLE. -

-

In the joinable state, another thread can synchronize on the -thread termination and recover its termination code using -pthread_join(3) . When a -joinable thread terminates, some of the thread resources are kept -allocated, and released only when another thread performs -pthread_join(3) on that -thread. -

-

In the detached state, the thread's resources are released -immediately when it terminates. pthread_join(3) -cannot be used to synchronize on the thread termination. -

-

A thread created in the joinable state can later be put in the -detached thread using pthread_detach(3) -. -

-

schedpolicy

-

Select the scheduling policy for the thread: one of SCHED_OTHER -(regular, non-real-time scheduling), SCHED_RR (real-time, -round-robin) or SCHED_FIFO (real-time, first-in first-out). -

-

Pthreads-w32 only supports SCHED_OTHER - attempting -to set one of the other policies will return an error ENOTSUP.

-

Default value: SCHED_OTHER. -

-

Pthreads-w32 only supports SCHED_OTHER - attempting -to set one of the other policies will return an error ENOTSUP.

-

The scheduling policy of a thread can be changed after creation -with pthread_setschedparam(3) -. -

-

schedparam

-

Contain the scheduling parameters (essentially, the scheduling -priority) for the thread.

-

Pthreads-w32 supports the priority levels defined by the -Windows system it is running on. Under Windows, thread priorities are -relative to the process priority class, which must be set via the -Windows W32 API.

-

Default value: priority is 0 (Win32 level THREAD_PRIORITY_NORMAL). -

-

The scheduling priority of a thread can be changed after creation -with pthread_setschedparam(3) -. -

-

inheritsched

-

Indicate whether the scheduling policy and scheduling parameters -for the newly created thread are determined by the values of the -schedpolicy and schedparam attributes (value -PTHREAD_EXPLICIT_SCHED) or are inherited from the parent -thread (value PTHREAD_INHERIT_SCHED). -

-

Default value: PTHREAD_EXPLICIT_SCHED. -

-

scope

-

Define the scheduling contention scope for the created thread. The -only value supported in the Pthreads-w32 implementation is -PTHREAD_SCOPE_SYSTEM, meaning that the threads contend for CPU -time with all processes running on the machine. The other value -specified by the standard, PTHREAD_SCOPE_PROCESS, means that -scheduling contention occurs only between the threads of the running -process.

-

Pthreads-w32 only supports PTHREAD_SCOPE_SYSTEM.

-

Default value: PTHREAD_SCOPE_SYSTEM. -

-

Return Value

-

All functions return 0 on success and a non-zero error code on -error. On success, the pthread_attr_getattrname -functions also store the current value of the attribute attrname -in the location pointed to by their second argument. -

-

Errors

-

The pthread_attr_setdetachstate function returns the -following error codes on error: -

-
-
-
EINVAL -
- the specified detachstate is not one of - PTHREAD_CREATE_JOINABLE or PTHREAD_CREATE_DETACHED. -
-
-

-The pthread_attr_setschedparam function returns the following -error codes on error: -

-
-
-
EINVAL -
- the priority specified in param is outside the range of - allowed priorities for the scheduling policy currently in attr - (1 to 99 for SCHED_FIFO and SCHED_RR; 0 for - SCHED_OTHER). -
-
-

-The pthread_attr_setschedpolicy function returns the following -error codes on error: -

-
-
-
EINVAL -
- the specified policy is not one of SCHED_OTHER, - SCHED_FIFO, or SCHED_RR. -
- ENOTSUP -
- policy is not SCHED_OTHER, the only value supported - by Pthreads-w32.
-
-

-The pthread_attr_setinheritsched function returns the -following error codes on error: -

-
-
-
EINVAL -
- the specified inherit is not one of PTHREAD_INHERIT_SCHED - or PTHREAD_EXPLICIT_SCHED. -
-
-

-The pthread_attr_setscope function returns the following error -codes on error: -

-
-
-
EINVAL -
- the specified scope is not one of PTHREAD_SCOPE_SYSTEM - or PTHREAD_SCOPE_PROCESS. -
- ENOTSUP -
- the specified scope is PTHREAD_SCOPE_PROCESS (not - supported by Pthreads-w32). -
-
-

-Author

-

Xavier Leroy <Xavier.Leroy@inria.fr> -

-

Modified by Ross Johnson for use with Pthreads-w32.

-

See Also

-

pthread_create(3) , -pthread_join(3) , -pthread_detach(3) , -pthread_setschedparam(3) -. -

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_attr_setstackaddr.html b/deps/w32-pthreads/manual/pthread_attr_setstackaddr.html deleted file mode 100644 index 868832c..0000000 --- a/deps/w32-pthreads/manual/pthread_attr_setstackaddr.html +++ /dev/null @@ -1,158 +0,0 @@ - - - - - "PTHREAD_ATTR_GETSTACKADDR"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_attr_getstackaddr, pthread_attr_setstackaddr - get and set -the stackaddr attribute -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_attr_getstackaddr(const pthread_attr_t *restrict -attr, void **restrict stackaddr);
int -pthread_attr_setstackaddr(pthread_attr_t *
attr, void -*stackaddr); -

-

Description

-

The pthread_attr_getstackaddr and pthread_attr_setstackaddr -functions, respectively, shall get and set the thread creation -stackaddr attribute in the attr object. -

-

The stackaddr attribute specifies the location of storage -to be used for the created threadā€™s stack. The size of the storage -shall be at least {PTHREAD_STACK_MIN}. -

-

Pthreads-w32 defines _POSIX_THREAD_ATTR_STACKADDR in -pthread.h as -1 to indicate that these routines are implemented but -cannot used to set or get the stack address. These routines always -return the error ENOSYS when called.

-

Return Value

-

Upon successful completion, pthread_attr_getstackaddr and -pthread_attr_setstackaddr shall return a value of 0; -otherwise, an error number shall be returned to indicate the error. -

-

The pthread_attr_getstackaddr function stores the stackaddr -attribute value in stackaddr if successful. -

-

Errors

-

The pthread_attr_setstackaddr function always returns the -following error code: -

-
-
-
ENOSYS
- The function is not supported. -
-
-

-The pthread_attr_getstackaddr function always returns the -following error code: -

-
-
-
ENOSYS
- The function is not supported. -
-
-

-These functions shall not return an error code of [EINTR]. -

-

The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

The specification of the stackaddr attribute presents -several ambiguities that make portable use of these interfaces -impossible. The description of the single address parameter as a -"stack" does not specify a particular relationship between -the address and the "stack" implied by that address. For -example, the address may be taken as the low memory address of a -buffer intended for use as a stack, or it may be taken as the address -to be used as the initial stack pointer register value for the new -thread. These two are not the same except for a machine on which the -stack grows "up" from low memory to high, and on which a -"push" operation first stores the value in memory and then -increments the stack pointer register. Further, on a machine where -the stack grows "down" from high memory to low, -interpretation of the address as the "low memory" address -requires a determination of the intended size of the stack. -IEEE Std 1003.1-2001 has introduced the new interfaces -pthread_attr_setstack(3) -and pthread_attr_getstack(3) -to resolve these ambiguities. -

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

pthread_attr_destroy(3) -, pthread_attr_getdetachstate(3) -, pthread_attr_getstack(3) -, pthread_attr_getstacksize(3) -, pthread_attr_setstack(3) -, pthread_create(3) , the -Base Definitions volume of IEEE Std 1003.1-2001, -<limits.h>, <pthread.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_attr_setstacksize.html b/deps/w32-pthreads/manual/pthread_attr_setstacksize.html deleted file mode 100644 index ae9d031..0000000 --- a/deps/w32-pthreads/manual/pthread_attr_setstacksize.html +++ /dev/null @@ -1,127 +0,0 @@ - - - - - "PTHREAD_ATTR_GETSTACKSIZE"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_attr_getstacksize, pthread_attr_setstacksize - get and set -the stacksize attribute -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_attr_getstacksize(const pthread_attr_t *restrict -attr, size_t *restrict stacksize);
int -pthread_attr_setstacksize(pthread_attr_t *
attr, size_t -stacksize); -

-

Description

-

The pthread_attr_getstacksize and pthread_attr_setstacksize -functions, respectively, shall get and set the thread creation -stacksize attribute in the attr object. -

-

The stacksize attribute shall define the minimum stack size -(in bytes) allocated for the created threads stack. -

-

Pthreads-w32 defines _POSIX_THREAD_ATTR_STACKSIZE in -pthread.h to indicate that these routines are implemented and may be -used to set or get the stack size.

-

Default value: 0 (in Pthreads-w32 a value of 0 means the stack -will grow as required)

-

Return Value

-

Upon successful completion, pthread_attr_getstacksize and -pthread_attr_setstacksize shall return a value of 0; -otherwise, an error number shall be returned to indicate the error. -

-

The pthread_attr_getstacksize function stores the stacksize -attribute value in stacksize if successful. -

-

Errors

-

The pthread_attr_setstacksize function shall fail if: -

-
-
EINVAL -
- The value of stacksize is less than {PTHREAD_STACK_MIN} or - exceeds a system-imposed limit. -
-

-These functions shall not return an error code of [EINTR]. -

-

The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

None. -

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

pthread_attr_destroy(3) -, pthread_attr_getstackaddr(3) -, pthread_attr_getdetachstate(3) -, pthread_create(3) , -the Base Definitions volume of IEEE Std 1003.1-2001, -<limits.h>, <pthread.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_barrier_init.html b/deps/w32-pthreads/manual/pthread_barrier_init.html deleted file mode 100644 index f581358..0000000 --- a/deps/w32-pthreads/manual/pthread_barrier_init.html +++ /dev/null @@ -1,197 +0,0 @@ - - - - - "PTHREAD_BARRIER_DESTROY"(P) manual page - - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_barrier_destroy, pthread_barrier_init - destroy and -initialize a barrier object (ADVANCED REALTIME THREADS) -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_barrier_destroy(pthread_barrier_t *barrier); -
int pthread_barrier_init(pthread_barrier_t *restrict
barrier, -const pthread_barrierattr_t *restrict attr, unsigned -count); -

-

Description

-

The pthread_barrier_destroy function shall destroy the -barrier referenced by barrier and release any resources used -by the barrier. The effect of subsequent use of the barrier is -undefined until the barrier is reinitialized by another call to -pthread_barrier_init . An implementation may use this function -to set barrier to an invalid value. An error code is returned if pthread_barrier_destroy is called when any thread is -blocked on the barrier, or if this function is called with an -uninitialized barrier. -

-

The pthread_barrier_init function shall allocate any -resources required to use the barrier referenced by barrier -and shall initialize the barrier with attributes referenced by attr. -If attr is NULL, the default barrier attributes shall be used; -the effect is the same as passing the address of a default barrier -attributes object. The results are undefined if pthread_barrier_init -is called when any thread is blocked on the barrier (that is, has not -returned from the pthread_barrier_wait(3) -call). The results are undefined if a barrier is used without first -being initialized. The results are undefined if pthread_barrier_init -is called specifying an already initialized barrier. -

-

The count argument specifies the number of threads that -must call pthread_barrier_wait(3) -before any of them successfully return from the call. The value -specified by count must be greater than zero. -

-

If the pthread_barrier_init function fails, the barrier -shall not be initialized and the contents of barrier are -undefined. -

-

Only the object referenced by barrier may be used for -performing synchronization. The result of referring to copies of that -object in calls to pthread_barrier_destroy or -pthread_barrier_wait(3) -is undefined.

-

Return Value

-

Upon successful completion, these functions shall return zero; -otherwise, an error number shall be returned to indicate the error. -

-

Errors

-

The pthread_barrier_destroy function may fail if: -

-
-
EBUSY -
- The implementation has detected an attempt to destroy a barrier - while it is in use (for example, while being used in a - pthread_barrier_wait(3) - call) by another thread. -
- EINVAL -
- The value specified by barrier is invalid. -
-

-The pthread_barrier_init function shall fail if: -

-
-
EAGAIN -
- The system lacks the necessary resources to initialize another - barrier. -
- EINVAL -
- The value specified by count is equal to zero. -
- ENOMEM -
- Insufficient memory exists to initialize the barrier. -
-

-The pthread_barrier_init function may fail if: -

-
-
EBUSY -
- The implementation has detected an attempt to reinitialize a barrier - while it is in use (for example, while being used in a - pthread_barrier_wait(3) - call) by another thread. -
- EINVAL -
- The value specified by attr is invalid. -
-

-These functions shall not return an error code of [EINTR]. -

-

The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

The pthread_barrier_destroy and pthread_barrier_init -functions are part of the Barriers option and need not be provided on -all implementations. -

-

Pthreads-w32 defines _POSIX_BARRIERS to indicate -that these routines are implemented and may be used.

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

Known Bugs

-
-
In - pthreads-win32, - the behaviour of threads which enter pthread_barrier_wait(3) - while the barrier is being destroyed is undefined. -
-

-See Also

-

pthread_barrier_wait(3) -, the Base Definitions volume of IEEE Std 1003.1-2001, -<pthread.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - \ No newline at end of file diff --git a/deps/w32-pthreads/manual/pthread_barrier_wait.html b/deps/w32-pthreads/manual/pthread_barrier_wait.html deleted file mode 100644 index f407aa5..0000000 --- a/deps/w32-pthreads/manual/pthread_barrier_wait.html +++ /dev/null @@ -1,161 +0,0 @@ - - - - - "PTHREAD_BARRIER_WAIT"(P) manual page - - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_barrier_wait - synchronize at a barrier (ADVANCED -REALTIME THREADS) -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_barrier_wait(pthread_barrier_t *barrier); - -

-

Description

-

The pthread_barrier_wait function shall synchronize -participating threads at the barrier referenced by barrier. -The calling thread shall block until the required number of threads -have called pthread_barrier_wait specifying the barrier. -

-

When the required number of threads have called -pthread_barrier_wait specifying the barrier, the constant -PTHREAD_BARRIER_SERIAL_THREAD shall be returned to one -unspecified thread and zero shall be returned to each of the -remaining threads. At this point, the barrier shall be reset to the -state it had as a result of the most recent pthread_barrier_init(3) -function that referenced it. -

-

The constant PTHREAD_BARRIER_SERIAL_THREAD is defined in -<pthread.h> and its value shall be distinct from any -other value returned by pthread_barrier_wait . -

-

The results are undefined if this function is called with an -uninitialized barrier. -

-

If a signal is delivered to a thread blocked on a barrier, upon -return from the signal handler the thread shall resume waiting at the -barrier if the barrier wait has not completed (that is, if the -required number of threads have not arrived at the barrier during the -execution of the signal handler); otherwise, the thread shall -continue as normal from the completed barrier wait. Until the thread -in the signal handler returns from it, it is unspecified whether -other threads may proceed past the barrier once they have all reached -it. -

-

A thread that has blocked on a barrier shall not prevent any -unblocked thread that is eligible to use the same processing -resources from eventually making forward progress in its execution. -Eligibility for processing resources shall be determined by the -scheduling policy. -

-

Return Value

-

Upon successful completion, the pthread_barrier_wait -function shall return PTHREAD_BARRIER_SERIAL_THREAD for a -single (arbitrary) thread synchronized at the barrier and zero for -each of the other threads. Otherwise, an error number shall be -returned to indicate the error. -

-

Errors

-

The pthread_barrier_wait function may fail if: -

-
-
EINVAL -
- The value specified by barrier does not refer to an - initialized barrier object. -
-

-This function shall not return an error code of [EINTR]. -

-

The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

Applications using this function may be subject to priority -inversion, as discussed in the Base Definitions volume of -IEEE Std 1003.1-2001, Section 3.285, Priority Inversion. -

-

The pthread_barrier_wait function is part of the Barriers -option and need not be provided on all implementations. -

-

Pthreads-w32 defines _POSIX_BARRIERS to indicate -that this routine is implemented and may be used.

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

Known Bugs

-
- None.
-

-See Also

-

pthread_barrier_destroy(3), -pthread_barrier_init(3), -the Base Definitions volume of IEEE Std 1003.1-2001, -<pthread.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - \ No newline at end of file diff --git a/deps/w32-pthreads/manual/pthread_barrierattr_init.html b/deps/w32-pthreads/manual/pthread_barrierattr_init.html deleted file mode 100644 index a7c8027..0000000 --- a/deps/w32-pthreads/manual/pthread_barrierattr_init.html +++ /dev/null @@ -1,142 +0,0 @@ - - - - - "PTHREAD_BARRIERATTR_DESTROY"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_barrierattr_destroy, pthread_barrierattr_init - destroy -and initialize the barrier attributes object (ADVANCED REALTIME -THREADS) -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_barrierattr_destroy(pthread_barrierattr_t *attr); -
int pthread_barrierattr_init(pthread_barrierattr_t *
attr); - -

-

Description

-

The pthread_barrierattr_destroy function shall destroy a -barrier attributes object. A destroyed attr attributes object -can be reinitialized using pthread_barrierattr_init ; the -results of otherwise referencing the object after it has been -destroyed are undefined. An implementation may cause -pthread_barrierattr_destroy to set the object referenced by -attr to an invalid value. -

-

The pthread_barrierattr_init function shall initialize a -barrier attributes object attr with the default value for all -of the attributes defined by the implementation. -

-

Results are undefined if pthread_barrierattr_init is called -specifying an already initialized attr attributes object. -

-

After a barrier attributes object has been used to initialize one -or more barriers, any function affecting the attributes object -(including destruction) shall not affect any previously initialized -barrier. -

-

Return Value

-

If successful, the pthread_barrierattr_destroy and -pthread_barrierattr_init functions shall return zero; -otherwise, an error number shall be returned to indicate the error. -

-

Errors

-

The pthread_barrierattr_destroy function may fail if: -

-
-
EINVAL -
- The value specified by attr is invalid. -
-

-The pthread_barrierattr_init function shall fail if: -

-
-
ENOMEM -
- Insufficient memory exists to initialize the barrier attributes - object. -
-

-These functions shall not return an error code of [EINTR]. -

-

The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

The pthread_barrierattr_destroy and -pthread_barrierattr_init functions are part of the Barriers -option and need not be provided on all implementations. -

-

Pthreads-w32 defines _POSIX_BARRIERS to indicate -that these routines are implemented and may be used.

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

pthread_barrierattr_getpshared(3) -, pthread_barrierattr_setpshared(3) -, the Base Definitions volume of IEEE Std 1003.1-2001, -<pthread.h>. -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_barrierattr_setpshared.html b/deps/w32-pthreads/manual/pthread_barrierattr_setpshared.html deleted file mode 100644 index 2c62d3d..0000000 --- a/deps/w32-pthreads/manual/pthread_barrierattr_setpshared.html +++ /dev/null @@ -1,159 +0,0 @@ - - - - - "PTHREAD_BARRIERATTR_GETPSHARED"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_barrierattr_getpshared, pthread_barrierattr_setpshared - -get and set the process-shared attribute of the barrier attributes -object (ADVANCED REALTIME THREADS) -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_barrierattr_getpshared(const pthread_barrierattr_t -* restrict attr, int *restrict pshared); -
int pthread_barrierattr_setpshared(pthread_barrierattr_t *
attr, -int pshared); -

-

Description

-

The pthread_barrierattr_getpshared function shall obtain -the value of the process-shared attribute from the attributes -object referenced by attr. The pthread_barrierattr_setpshared -function shall set the process-shared attribute in an -initialized attributes object referenced by attr. -

-

The process-shared attribute is set to -PTHREAD_PROCESS_SHARED to permit a barrier to be operated upon by any -thread that has access to the memory where the barrier is allocated. -If the process-shared attribute is PTHREAD_PROCESS_PRIVATE, -the barrier shall only be operated upon by threads created within the -same process as the thread that initialized the barrier; if threads -of different processes attempt to operate on such a barrier, the -behavior is undefined. The default value of the attribute shall be -PTHREAD_PROCESS_PRIVATE. Both constants PTHREAD_PROCESS_SHARED and -PTHREAD_PROCESS_PRIVATE are defined in <pthread.h>. -

-

Pthreads-w32 defines _POSIX_THREAD_PROCESS_SHARED in -pthread.h as -1 to indicate that these routines are implemented but -that the process shared attribute is not supported.

-

Additional attributes, their default values, and the names of the -associated functions to get and set those attribute values are -implementation-defined. -

-

Return Value

-

If successful, the pthread_barrierattr_getpshared function -shall return zero and store the value of the process-shared -attribute of attr into the object referenced by the pshared -parameter. Otherwise, an error number shall be returned to indicate -the error. -

-

If successful, the pthread_barrierattr_setpshared function -shall return zero; otherwise, an error number shall be returned to -indicate the error. -

-

Errors

-

These functions may fail if: -

-
-
EINVAL -
- The value specified by attr is invalid. -
- The pthread_barrierattr_setpshared function may fail if: -
- EINVAL -
- The new value specified for the process-shared attribute is - not one of the legal values PTHREAD_PROCESS_SHARED or - PTHREAD_PROCESS_PRIVATE. -
- ENOSYS -
- The value specified by attr was PTHREAD_PROCESS_SHARED - (Pthreads-w32).
-

-These functions shall not return an error code of [EINTR]. -

-

The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

The pthread_barrierattr_getpshared and -pthread_barrierattr_setpshared functions are part of the -Barriers option and need not be provided on all implementations. -

-

Pthreads-w32 defines _POSIX_BARRIERS and -_POSIX_THREAD_PROCESS_SHARED in pthread.h as -1 to indicate -that these routines are implemented and may be used, but do not -support the process shared option.

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

pthread_barrier_destroy(3) -, pthread_barrierattr_destroy(3) -, pthread_barrierattr_init(3) -, the Base Definitions volume of IEEE Std 1003.1-2001, -<pthread.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_cancel.html b/deps/w32-pthreads/manual/pthread_cancel.html deleted file mode 100644 index d9acd77..0000000 --- a/deps/w32-pthreads/manual/pthread_cancel.html +++ /dev/null @@ -1,205 +0,0 @@ - - - - - PTHREAD_CANCEL(3) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_cancel, pthread_setcancelstate, pthread_setcanceltype, -pthread_testcancel - thread cancellation -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_cancel(pthread_t thread); -

-

int pthread_setcancelstate(int state, int -*oldstate); -

-

int pthread_setcanceltype(int type, int -*oldtype); -

-

void pthread_testcancel(void); -

-

Description

-

Cancellation is the mechanism by which a thread can terminate the -execution of another thread. More precisely, a thread can send a -cancellation request to another thread. Depending on its settings, -the target thread can then either ignore the request, honor it -immediately, or defer it until it reaches a cancellation point. -

-

When a thread eventually honors a cancellation request, it -performs as if pthread_exit(PTHREAD_CANCELED) has been called -at that point: all cleanup handlers are executed in reverse order, -destructor functions for thread-specific data are called, and finally -the thread stops executing with the return value PTHREAD_CANCELED. -See pthread_exit(3) for more -information. -

-

pthread_cancel sends a cancellation request to the thread -denoted by the thread argument. -

-

pthread_setcancelstate changes the cancellation state for -the calling thread -- that is, whether cancellation requests are -ignored or not. The state argument is the new cancellation -state: either PTHREAD_CANCEL_ENABLE to enable cancellation, or -PTHREAD_CANCEL_DISABLE to disable cancellation (cancellation -requests are ignored). If oldstate is not NULL, the -previous cancellation state is stored in the location pointed to by -oldstate, and can thus be restored later by another call to -pthread_setcancelstate. -

-

pthread_setcanceltype changes the type of responses to -cancellation requests for the calling thread: asynchronous -(immediate) or deferred. The type argument is the new -cancellation type: either PTHREAD_CANCEL_ASYNCHRONOUS to -cancel the calling thread as soon as the cancellation request is -received, or PTHREAD_CANCEL_DEFERRED to keep the cancellation -request pending until the next cancellation point. If oldtype -is not NULL, the previous cancellation state is stored in the -location pointed to by oldtype, and can thus be restored later -by another call to pthread_setcanceltype. -

-

Pthreads-w32 provides two levels of support for -PTHREAD_CANCEL_ASYNCHRONOUS: full and partial. Full support -requires an additional DLL and driver be installed on the Windows -system (see the See Also section below) that allows blocked threads -to be cancelled immediately. Partial support means that the target -thread will not cancel until it resumes execution naturally. Partial -support is provided if either the DLL or the driver are not -automatically detected by the pthreads-w32 library at run-time.

-

Threads are always created by pthread_create(3) -with cancellation enabled and deferred. That is, the initial -cancellation state is PTHREAD_CANCEL_ENABLE and the initial -type is PTHREAD_CANCEL_DEFERRED. -

-

Cancellation points are those points in the program execution -where a test for pending cancellation requests is performed and -cancellation is executed if positive. The following POSIX threads -functions are cancellation points: -

-

pthread_join(3) -
pthread_cond_wait(3) -
pthread_cond_timedwait(3) -
pthread_testcancel(3)
sem_wait(3) -
sem_timedwait(3)
sigwait(3)

-

Pthreads-w32 provides two functions to enable additional -cancellation points to be created in user functions that block on -Win32 HANDLEs:

-

pthreadCancelableWait() -
pthreadCancelableTimedWait()

-

All other POSIX threads functions are guaranteed not to be -cancellation points. That is, they never perform cancellation in -deferred cancellation mode. -

-

pthread_testcancel does nothing except testing for pending -cancellation and executing it. Its purpose is to introduce explicit -checks for cancellation in long sequences of code that do not call -cancellation point functions otherwise. -

-

Return Value

-

pthread_cancel, pthread_setcancelstate and -pthread_setcanceltype return 0 on success and a non-zero error -code on error. -

-

Errors

-

pthread_cancel returns the following error code on error: -

-
-
-
ESRCH -
- no thread could be found corresponding to that specified by the - thread ID. -
-
-

-pthread_setcancelstate returns the following error code on -error: -

-
-
-
EINVAL -
- the state argument is not -
-
-
-PTHREAD_CANCEL_ENABLE nor PTHREAD_CANCEL_DISABLE -
-

pthread_setcanceltype returns the following error code on -error: -

-
-
-
EINVAL -
- the type argument is not -
-
-
-PTHREAD_CANCEL_DEFERRED nor PTHREAD_CANCEL_ASYNCHRONOUS -
-

Author

-

Xavier Leroy <Xavier.Leroy@inria.fr> -

-

Modified by Ross Johnson for use with Pthreads-w32.

-

See Also

-

pthread_exit(3) , -pthread_cleanup_push(3) -, pthread_cleanup_pop(3) -, Pthreads-w32 package README file 'Prerequisites' section. -

-

Bugs

-

POSIX specifies that a number of system calls (basically, all -system calls that may block, such as read(2) -, write(2) , wait(2) -, etc.) and library functions that may call these system calls (e.g. -fprintf(3) ) are cancellation -points. Pthreads-win32 is not integrated enough with the C -library to implement this, and thus none of the C library functions -is a cancellation point. -

-

A workaround for these calls is to temporarily switch to -asynchronous cancellation (assuming full asynchronous cancellation -support is installed). So, checking for cancellation during a read -system call, for instance, can be achieved as follows: -

-


-
-
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldCancelType);
-read(fd, buffer, length);
-pthread_setcanceltype(oldCancelType, NULL);
-
-
Table of Contents
- - - diff --git a/deps/w32-pthreads/manual/pthread_cleanup_push.html b/deps/w32-pthreads/manual/pthread_cleanup_push.html deleted file mode 100644 index 0fc071e..0000000 --- a/deps/w32-pthreads/manual/pthread_cleanup_push.html +++ /dev/null @@ -1,140 +0,0 @@ - - - - - PTHREAD_CLEANUP(3) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_cleanup_push, pthread_cleanup_pop - install and remove -cleanup handlers -

-

Synopsis

-

#include <pthread.h> -

-

void pthread_cleanup_push(void (*routine) (void -*), void *arg); -

-

void pthread_cleanup_pop(int execute); -

-

Description

-

Cleanup handlers are functions that get called when a thread -terminates, either by calling pthread_exit(3) -or because of cancellation. Cleanup handlers are installed and -removed following a stack-like discipline. -

-

The purpose of cleanup handlers is to free the resources that a -thread may hold at the time it terminates. In particular, if a thread -exits or is cancelled while it owns a locked mutex, the mutex will -remain locked forever and prevent other threads from executing -normally. The best way to avoid this is, just before locking the -mutex, to install a cleanup handler whose effect is to unlock the -mutex. Cleanup handlers can be used similarly to free blocks -allocated with malloc(3) or close -file descriptors on thread termination. -

-

pthread_cleanup_push installs the routine function -with argument arg as a cleanup handler. From this point on to -the matching pthread_cleanup_pop, the function routine -will be called with arguments arg when the thread terminates, -either through pthread_exit(3) -or by cancellation. If several cleanup handlers are active at that -point, they are called in LIFO order: the most recently installed -handler is called first. -

-

pthread_cleanup_pop removes the most recently installed -cleanup handler. If the execute argument is not 0, it also -executes the handler, by calling the routine function with -arguments arg. If the execute argument is 0, the -handler is only removed but not executed. -

-

Matching pairs of pthread_cleanup_push and -pthread_cleanup_pop must occur in the same function, at the -same level of block nesting. Actually, pthread_cleanup_push -and pthread_cleanup_pop are macros, and the expansion of -pthread_cleanup_push introduces an open brace { with -the matching closing brace } being introduced by the expansion -of the matching pthread_cleanup_pop. -

-

Return Value

-
None. -
-

Errors

-
None. -
-

Author

-
Xavier Leroy -<Xavier.Leroy@inria.fr> -
-
Modified by -Ross Johnson for use with Pthreads-w32.
-

See Also

-
pthread_exit(3) -, pthread_cancel(3) , -pthread_setcanceltype(3) . -
-

Example

-
Here is how -to lock a mutex mut in such a way that it will be unlocked if -the thread is canceled while mut is locked: -
-
pthread_cleanup_push(pthread_mutex_unlock, (void *) &mut);
-pthread_mutex_lock(&mut);
-/* do some work */
-pthread_mutex_unlock(&mut);
-pthread_cleanup_pop(0);
-Equivalently, the last two lines can be replaced by -
-
pthread_cleanup_pop(1);
-Notice that the code above is safe only in deferred cancellation mode -(see pthread_setcanceltype(3) -). In asynchronous cancellation mode, a cancellation can occur -between pthread_cleanup_push and pthread_mutex_lock, or -between pthread_mutex_unlock and pthread_cleanup_pop, -resulting in both cases in the thread trying to unlock a mutex not -locked by the current thread. This is the main reason why -asynchronous cancellation is difficult to use. -
-
If the code -above must also work in asynchronous cancellation mode, then it must -switch to deferred mode for locking and unlocking the mutex: -
-
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);
-pthread_cleanup_push(pthread_mutex_unlock, (void *) &mut);
-pthread_mutex_lock(&mut);
-/* do some work */
-pthread_cleanup_pop(1);
-pthread_setcanceltype(oldtype, NULL);
-
-
-Table of Contents
- - - diff --git a/deps/w32-pthreads/manual/pthread_cond_init.html b/deps/w32-pthreads/manual/pthread_cond_init.html deleted file mode 100644 index 937e490..0000000 --- a/deps/w32-pthreads/manual/pthread_cond_init.html +++ /dev/null @@ -1,313 +0,0 @@ - - - - - PTHREAD_COND(3) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_cond_init, pthread_cond_destroy, pthread_cond_signal, -pthread_cond_broadcast, pthread_cond_wait, pthread_cond_timedwait - -operations on conditions -

-

Synopsis

-

#include <pthread.h> -

-

pthread_cond_t cond = PTHREAD_COND_INITIALIZER; -

-

int pthread_cond_init(pthread_cond_t *cond, -pthread_condattr_t *cond_attr); -

-

int pthread_cond_signal(pthread_cond_t *cond); -

-

int pthread_cond_broadcast(pthread_cond_t *cond); -

-

int pthread_cond_wait(pthread_cond_t *cond, -pthread_mutex_t *mutex); -

-

int pthread_cond_timedwait(pthread_cond_t *cond, -pthread_mutex_t *mutex, const struct timespec -*abstime); -

-

int pthread_cond_destroy(pthread_cond_t *cond); -

-

Description

-

A condition (short for ā€˜ā€˜condition variableā€™ā€™) is a -synchronization device that allows threads to suspend execution and -relinquish the processors until some predicate on shared data is -satisfied. The basic operations on conditions are: signal the -condition (when the predicate becomes true), and wait for the -condition, suspending the thread execution until another thread -signals the condition. -

-

A condition variable must always be associated with a mutex, to -avoid the race condition where a thread prepares to wait on a -condition variable and another thread signals the condition just -before the first thread actually waits on it. -

-

pthread_cond_init initializes the condition variable cond, -using the condition attributes specified in cond_attr, or -default attributes if cond_attr is NULL. -

-

Variables of type pthread_cond_t can also be initialized -statically, using the constant PTHREAD_COND_INITIALIZER. In -the Pthreads-w32 implementation, an application should still -call pthread_cond_destroy at some point to ensure that any -resources consumed by the condition variable are released.

-

pthread_cond_signal restarts one of the threads that are -waiting on the condition variable cond. If no threads are -waiting on cond, nothing happens. If several threads are -waiting on cond, exactly one is restarted, but it is not -specified which. -

-

pthread_cond_broadcast restarts all the threads that are -waiting on the condition variable cond. Nothing happens if no -threads are waiting on cond. -

-

pthread_cond_wait atomically unlocks the mutex (as -per pthread_unlock_mutex) and waits for the condition variable -cond to be signalled. The thread execution is suspended and -does not consume any CPU time until the condition variable is -signalled. The mutex must be locked by the calling thread on -entrance to pthread_cond_wait. Before returning to the calling -thread, pthread_cond_wait re-acquires mutex (as per -pthread_lock_mutex). -

-

Unlocking the mutex and suspending on the condition variable is -done atomically. Thus, if all threads always acquire the mutex before -signalling the condition, this guarantees that the condition cannot -be signalled (and thus ignored) between the time a thread locks the -mutex and the time it waits on the condition variable. -

-

pthread_cond_timedwait atomically unlocks mutex and -waits on cond, as pthread_cond_wait does, but it also -bounds the duration of the wait. If cond has not been -signalled within the amount of time specified by abstime, the -mutex mutex is re-acquired and pthread_cond_timedwait -returns the error ETIMEDOUT. The abstime parameter -specifies an absolute time, with the same origin as time(2) -and gettimeofday(2). -

-

pthread_cond_destroy destroys a condition variable, freeing -the resources it might hold. No threads must be waiting on the -condition variable on entrance to pthread_cond_destroy.

-

Cancellation

-

pthread_cond_wait and pthread_cond_timedwait are -cancellation points. If a thread is cancelled while suspended in one -of these functions, the thread immediately resumes execution, then -locks again the mutex argument to pthread_cond_wait and -pthread_cond_timedwait, and finally executes the cancellation. -Consequently, cleanup handlers are assured that mutex is -locked when they are called. -

-

Async-signal Safety

-

The condition functions are not async-signal safe, and should not -be called from a signal handler. In particular, calling -pthread_cond_signal or pthread_cond_broadcast from a -signal handler may deadlock the calling thread. -

-

Return Value

-

All condition variable functions return 0 on success and a -non-zero error code on error. -

-

Errors

-

pthread_cond_init, pthread_cond_signal, -pthread_cond_broadcast, and pthread_cond_wait never -return an error code. -

-

The pthread_cond_init function returns the following error -codes on error: -

-
-
-
EINVAL -
- The cond argument is invalid. -
- ENOMEM -
-
-
-There was not enough memory to allocate the condition variable. -
-

The pthread_cond_signal function returns the following -error codes on error: -

-
-
-
EINVAL -
- The cond argument is invalid. -
-
-

-The pthread_cond_broadcast function returns the following -error codes on error: -

-
-
-
EINVAL -
- The cond argument is invalid. -
-
-

-The pthread_cond_wait function returns the following error -codes on error: -

-
-
-
EINVAL -
- The cond argument is invalid. -
- ENOMEM -
-
-
-There was not enough memory to allocate the statically initialised -condition variable. Statically initialised condition variables are -dynamically allocated by the first thread to wait on them.
-

The pthread_cond_timedwait function returns the following -error codes on error: -

-
-
-
EINVAL -
-
-

-The cond argument is invalid. -

-
-
-
ETIMEDOUT -
- The condition variable was not signalled before the timeout - specified by abstime -
- ENOMEM -
-
-
-There was not enough memory to allocate the statically initialised -condition variable. Statically initialised condition variables are -dynamically allocated by the first thread to wait on them. -
-

The pthread_cond_destroy function returns the following -error code on error: -

-
-
-
EINVAL -
-
-

-The cond argument is invalid. -

-
-
-
EBUSY -
- Some threads are currently waiting on cond. -
-
-

-Author

-

Xavier Leroy <Xavier.Leroy@inria.fr> -

-

Modified by Ross Johnson for use with Pthreads-w32.

-

See Also

-

pthread_condattr_init(3) -, pthread_mutex_lock(3) -, pthread_mutex_unlock(3) -, pthread_cancel(3). -

-

Example

-

Consider two shared variables x and y, protected by -the mutex mut, and a condition variable cond that is to -be signaled whenever x becomes greater than y. -

-
int x,y;
-pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
-pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
-Waiting until x is greater than y is performed as -follows: -
-
pthread_mutex_lock(&mut);
-while (x <= y) {
-        pthread_cond_wait(&cond, &mut);
-}
-/* operate on x and y */
-pthread_mutex_unlock(&mut);
-Modifications on x and y that may cause x to -become greater than y should signal the condition if needed: -
-
pthread_mutex_lock(&mut);
-/* modify x and y */
-if (x > y) pthread_cond_broadcast(&cond);
-pthread_mutex_unlock(&mut);
-If it can be proved that at most one waiting thread needs to be waken -up (for instance, if there are only two threads communicating through -x and y), pthread_cond_signal can be used as a -slightly more efficient alternative to pthread_cond_broadcast. -If in doubt, use pthread_cond_broadcast. -
-
To wait for x to -become greater than y with a timeout of 5 seconds, do: -
-
struct timeval now;
-struct timespec timeout;
-int retcode;
-pthread_mutex_lock(&mut);
-gettimeofday(&now);
-timeout.tv_sec = now.tv_sec + 5;
-timeout.tv_nsec = now.tv_usec * 1000;
-retcode = 0;
-while (x <= y && retcode != ETIMEDOUT) {
-        retcode = pthread_cond_timedwait(&cond, &mut, &timeout);
-}
-if (retcode == ETIMEDOUT) {
-        /* timeout occurred */
-} else {
-        /* operate on x and y */
-}
-pthread_mutex_unlock(&mut);
-
-
-Table of Contents
- - - diff --git a/deps/w32-pthreads/manual/pthread_condattr_init.html b/deps/w32-pthreads/manual/pthread_condattr_init.html deleted file mode 100644 index 8b8b2f2..0000000 --- a/deps/w32-pthreads/manual/pthread_condattr_init.html +++ /dev/null @@ -1,98 +0,0 @@ - - - - - PTHREAD_CONDATTR(3) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_condattr_init, pthread_condattr_destroy - condition -creation -

-

attributes -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_condattr_init(pthread_condattr_t *attr); -

-

int pthread_condattr_destroy(pthread_condattr_t *attr); -

-

Description

-

Condition attributes can be specified at condition creation time, -by passing a condition attribute object as second argument to -pthread_cond_init(3) . -Passing NULL is equivalent to passing a condition attribute -object with all attributes set to their default values. -

-

pthread_condattr_init initializes the condition attribute -object attr and fills it with default values for the -attributes. pthread_condattr_destroy destroys a condition -attribute object, which must not be reused until it is reinitialized.

-

Pthreads-w32 defines _POSIX_THREAD_PROCESS_SHARED in -pthread.h as -1 to indicate that the attribute routines are -implemented but that the process shared attribute is not supported.

-

Return Value

-

All condition variable functions return 0 on success and a -non-zero error code on error.

-

Errors

-

The pthread_condattr_init function returns the following -error code on error: -

-
-
-
ENOMEM -
- The was insufficient memory to create the attribute. - -
-
-

-The pthread_condattr_destroy function returns the following -error code on error: -

-
-
-
EINVAL -
- The attr argument is not valid. - -
-
-

-Author

-

Xavier Leroy <Xavier.Leroy@inria.fr> -

-

Modified by Ross Johnson for use with Pthreads-w32.

-

See Also

-

pthread_cond_init(3) . -

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_condattr_setpshared.html b/deps/w32-pthreads/manual/pthread_condattr_setpshared.html deleted file mode 100644 index eda357e..0000000 --- a/deps/w32-pthreads/manual/pthread_condattr_setpshared.html +++ /dev/null @@ -1,153 +0,0 @@ - - - - - "PTHREAD_CONDATTR_GETPSHARED"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_condattr_getpshared, pthread_condattr_setpshared - get and -set the process-shared condition variable attributes -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_condattr_getpshared(const pthread_condattr_t -*restrict attr, int *restrict pshared); -
int pthread_condattr_setpshared(pthread_condattr_t *
attr, -int pshared); -

-

Description

-

The pthread_condattr_getpshared function shall obtain the -value of the process-shared attribute from the attributes -object referenced by attr. The pthread_condattr_setpshared -function shall set the process-shared attribute in an -initialized attributes object referenced by attr. -

-

The process-shared attribute is set to -PTHREAD_PROCESS_SHARED to permit a condition variable to be -operated upon by any thread that has access to the memory where the -condition variable is allocated, even if the condition variable is -allocated in memory that is shared by multiple processes. If the -process-shared attribute is PTHREAD_PROCESS_PRIVATE, -the condition variable shall only be operated upon by threads created -within the same process as the thread that initialized the condition -variable; if threads of differing processes attempt to operate on -such a condition variable, the behavior is undefined. The default -value of the attribute is PTHREAD_PROCESS_PRIVATE. -

-

Pthreads-w32 defines _POSIX_THREAD_PROCESS_SHARED in -pthread.h as -1 to indicate that these routines are implemented but -that the process shared attribute is not supported.

-

Return Value

-

If successful, the pthread_condattr_setpshared function -shall return zero; otherwise, an error number shall be returned to -indicate the error. -

-

If successful, the pthread_condattr_getpshared function -shall return zero and store the value of the process-shared -attribute of attr into the object referenced by the pshared -parameter. Otherwise, an error number shall be returned to indicate -the error. -

-

Errors

-

The pthread_condattr_getpshared and -pthread_condattr_setpshared functions may fail if: -

-
-
EINVAL -
- The value specified by attr is invalid. -
-

-The pthread_condattr_setpshared function may fail if: -

-
-
EINVAL -
- The new value specified for the attribute is outside the range of - legal values for that attribute. -
- ENOSYS -
- The value specified by attr was PTHREAD_PROCESS_SHARED - (Pthreads-w32).
-

-These functions shall not return an error code of [EINTR]. -

-

The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

Pthreads-w32 defines _POSIX_THREAD_PROCESS_SHARED in -pthread.h as -1 to indicate that these routines are implemented and -may be used, but do not support the process shared option.

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

pthread_create(3) , -pthread_cond_destroy(3) , -pthread_condattr_destroy(3) -, pthread_mutex_destroy(3) -, the Base Definitions volume of IEEE Std 1003.1-2001, -<pthread.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_create.html b/deps/w32-pthreads/manual/pthread_create.html deleted file mode 100644 index d1ebbc3..0000000 --- a/deps/w32-pthreads/manual/pthread_create.html +++ /dev/null @@ -1,94 +0,0 @@ - - - - - PTHREAD_CREATE(3) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_create - create a new thread -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_create(pthread_t * thread, -pthread_attr_t * attr, void * (*start_routine)(void -*), void * arg); -

-

Description

-

pthread_create creates a new thread of control that -executes concurrently with the calling thread. The new thread applies -the function start_routine passing it arg as first -argument. The new thread terminates either explicitly, by calling -pthread_exit(3) , or -implicitly, by returning from the start_routine function. The -latter case is equivalent to calling pthread_exit(3) -with the result returned by start_routine as exit code. -

-

The initial signal state of the new thread is inherited from it's -creating thread and there are no pending signals. Pthreads-w32 -does not yet implement signals.

-

The attr argument specifies thread attributes to be applied -to the new thread. See pthread_attr_init(3) -for a complete list of thread attributes. The attr argument -can also be NULL, in which case default attributes are used: -the created thread is joinable (not detached) and has default (non -real-time) scheduling policy. -

-

Return Value

-

On success, the identifier of the newly created thread is stored -in the location pointed by the thread argument, and a 0 is -returned. On error, a non-zero error code is returned. -

-

Errors

-
-
EAGAIN -
-
-
- Not enough system resources to create a process for the new - thread, or
more than PTHREAD_THREADS_MAX threads are - already active. -
-
-
-

-Author

-

Xavier Leroy <Xavier.Leroy@inria.fr> -

-

Modified by Ross Johnson for use with Pthreads-w32.

-

See Also

-

pthread_exit(3) , -pthread_join(3) , -pthread_detach(3) , -pthread_attr_init(3) . -

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_delay_np.html b/deps/w32-pthreads/manual/pthread_delay_np.html deleted file mode 100644 index ce533e2..0000000 --- a/deps/w32-pthreads/manual/pthread_delay_np.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - - PTHREAD_DELAY_NP manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_delay_np ā€“ suspend the -thread for a specified period

-

Synopsis

-

#include <pthread.h> -

-

int pthread_delay_np (const struct timespec *interval);

-

Description

-

pthread_delay_np causes a thread to delay execution for a -specific period of time. This period ends at the current time plus -the specified interval. The routine will not return before the end of -the period is reached, but may return an arbitrary amount of time -after the period has gone by. This can be due to system load, thread -priorities, and system timer granularity.

-

Specifying an interval of zero (0) seconds and zero (0) -nanoseconds is allowed and can be used to force the thread to give up -the processor or to deliver a pending cancellation request.

-

Cancellation

-

pthread_delay_np is a cancellation point.

-

Return Value

-

If an error condition occurs, pthread_delay_np returns an -integer value indicating the type of error.

-

Errors

-

The pthread_delay_np function returns the following error -code on error: -

-
-
-
EINVAL -
-
-

-The value specified by interval is invalid.

-

Author

-

Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_detach.html b/deps/w32-pthreads/manual/pthread_detach.html deleted file mode 100644 index 252adb8..0000000 --- a/deps/w32-pthreads/manual/pthread_detach.html +++ /dev/null @@ -1,90 +0,0 @@ - - - - - PTHREAD_DETACH(3) manual page - - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_detach - put a running thread in the detached state -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_detach(pthread_t th); -

-

Description

-

pthread_detach puts the thread th in the detached -state. This guarantees that the resources consumed by th will -be freed immediately when th terminates. However, this -prevents other threads from synchronizing on the termination of th -using pthread_join. If, when pthread_detach is called, -th has already terminated, all of th's remaining -resources will be freed.

-

A thread can be created initially in the detached state, using the -detachstate attribute to pthread_create(3) -. In contrast, pthread_detach applies to threads created in -the joinable state, and which need to be put in the detached state -later. -

-

After pthread_detach completes, subsequent attempts to -perform pthread_join on th will fail. If another thread -is already joining the thread th at the time pthread_detach -is called, th will be detached and pthread_join will -eventually return when th terminates but may not return with -th's correct return code. -

-

Return Value

-

On success, 0 is returned. On error, a non-zero error code is -returned. -

-

Errors

-
-
ESRCH -
- No thread could be found corresponding to that specified by th -
- EINVAL -
- the thread th is already in the detached state -
-

-Author

-

Xavier Leroy <Xavier.Leroy@inria.fr> -

-

Modified by Ross Johnson for use with Pthreads-w32.

-

See Also

-

pthread_create(3) , -pthread_join(3) , -pthread_attr_setdetachstate(3) -

-
-

Table of Contents

- - - \ No newline at end of file diff --git a/deps/w32-pthreads/manual/pthread_equal.html b/deps/w32-pthreads/manual/pthread_equal.html deleted file mode 100644 index 6f61063..0000000 --- a/deps/w32-pthreads/manual/pthread_equal.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - - -PTHREAD_EQUAL(3) manual page - - -Table of Contents

- -

-

Name

-pthread_equal - compare two thread identifiers -

-

Synopsis

-#include <pthread.h> - -

int pthread_equal(pthread_t thread1, pthread_t thread2); -

-

Description

-pthread_equal -determines if two thread identifiers refer to the same thread. -

-

Return Value

-A -non-zero value is returned if thread1 and thread2 refer to the same thread. -Otherwise, 0 is returned. -

-

Author

-Xavier Leroy <Xavier.Leroy@inria.fr> -

-

See Also

-pthread_self(3) -. -

- -


-Table of Contents

-

- - diff --git a/deps/w32-pthreads/manual/pthread_exit.html b/deps/w32-pthreads/manual/pthread_exit.html deleted file mode 100644 index e97318f..0000000 --- a/deps/w32-pthreads/manual/pthread_exit.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - - -PTHREAD_EXIT(3) manual page - - -Table of Contents

- -

-

Name

-pthread_exit - terminate the calling thread -

-

Synopsis

-#include <pthread.h> - -

void pthread_exit(void *retval); -

-

Description

-pthread_exit terminates the -execution of the calling thread. All cleanup handlers that have been set -for the calling thread with pthread_cleanup_push(3) - are executed in reverse -order (the most recently pushed handler is executed first). Finalization -functions for thread-specific data are then called for all keys that have -non- NULL values associated with them in the calling thread (see pthread_key_create(3) -). -Finally, execution of the calling thread is stopped. -

The retval argument -is the return value of the thread. It can be consulted from another thread -using pthread_join(3) -. -

-

Return Value

-The pthread_exit function never returns. - -

-

Author

-Xavier Leroy <Xavier.Leroy@inria.fr> -

-

See Also

-pthread_create(3) -, pthread_join(3) -. -

- -


-Table of Contents

-

- - diff --git a/deps/w32-pthreads/manual/pthread_getunique_np.html b/deps/w32-pthreads/manual/pthread_getunique_np.html deleted file mode 100644 index 182ce73..0000000 --- a/deps/w32-pthreads/manual/pthread_getunique_np.html +++ /dev/null @@ -1,76 +0,0 @@ - - - - - PTHREAD_GETW32THREADHANDLE_NP manual page - - - - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - -Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_getunique_np ā€“ get the -unique sequence number associated with a thread

-

Synopsis

-

#include <pthread.h> -

-

unsigned long long pthread_getunique_np(pthread_t thread);

-

Description

-

Returns the unique 64 bit -sequence number assigned to thread.

-

In Pthreads-win32:

-
    -
  • the value returned is not reused after the thread terminates - so it is unique for the life of the process

    -
  • Windows native threads may obtain their own POSIX thread - sequence number by first retrieving their pthread_t handle - via pthread_self to use as the thread argument.

    -
-

This function was added for source code compatibility with some -other POSIX threads implementations.

-

Cancellation

-

None.

-

Return Value

-

pthread_getunique_np returns the unique sequence number for -thread.

-

Errors

-

None.

-

Author

-

Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - \ No newline at end of file diff --git a/deps/w32-pthreads/manual/pthread_getw32threadhandle_np.html b/deps/w32-pthreads/manual/pthread_getw32threadhandle_np.html deleted file mode 100644 index 7e8de64..0000000 --- a/deps/w32-pthreads/manual/pthread_getw32threadhandle_np.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - - PTHREAD_GETW32THREADHANDLE_NP manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_getw32threadhandle_np ā€“ get -the Win32 thread handle associated with a thread

-

Synopsis

-

#include <pthread.h> -

-

HANDLE pthread_getw32threadhandle_np(pthread_t thread);

-

Description

-

Returns the Win32 native thread HANDLE that the POSIX -thread thread is running as.

-

Applications can use the Win32 handle to set Win32 specific -attributes of the thread.

-

Cancellation

-

None.

-

Return Value

-

pthread_getw32threadhandle_np returns the Win32 native -thread HANDLE for the specified POSIX thread thread.

-

Errors

-

None.

-

Author

-

Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_join.html b/deps/w32-pthreads/manual/pthread_join.html deleted file mode 100644 index 3e3f3b9..0000000 --- a/deps/w32-pthreads/manual/pthread_join.html +++ /dev/null @@ -1,118 +0,0 @@ - - - - - PTHREAD_JOIN(3) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_join - wait for termination of another thread -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_join(pthread_t th, void -**thread_return); -

-

Description

-

pthread_join suspends the execution of the calling thread -until the thread identified by th terminates, either by -calling pthread_exit(3) or by -being cancelled. -

-

If thread_return is not NULL, the return value of th -is stored in the location pointed to by thread_return. The -return value of th is either the argument it gave to -pthread_exit(3) , or -PTHREAD_CANCELED if th was cancelled. -

-

The joined thread th must be in the joinable state: it must -not have been detached using pthread_detach(3) -or the PTHREAD_CREATE_DETACHED attribute to pthread_create(3) -. -

-

When a joinable thread terminates, its memory resources (thread -descriptor and stack) are not deallocated until another thread -performs pthread_join on it. Therefore, pthread_join -must be called once for each joinable thread created to avoid memory -leaks. -

-

At most one thread can wait for the termination of a given thread. -Calling pthread_join on a thread th on which another -thread is already waiting for termination returns an error. -

-

Cancellation

-

pthread_join is a cancellation point. If a thread is -cancelled while suspended in pthread_join, the thread -execution resumes immediately and the cancellation is executed -without waiting for the th thread to terminate. If -cancellation occurs during pthread_join, the th thread -remains not joined. -

-

Return Value

-

On success, the return value of th is stored in the -location pointed to by thread_return, and 0 is returned. On -error, a non-zero error code is returned. -

-

Errors

-
-
ESRCH -
- No thread could be found corresponding to that specified by th. -
- EINVAL -
- The th thread has been detached. -
- EINVAL -
- Another thread is already waiting on termination of th. -
- EDEADLK -
- The th argument refers to the calling thread. -
-

-Author

-

Xavier Leroy <Xavier.Leroy@inria.fr> -

-

See Also

-

pthread_exit(3) , -pthread_detach(3) , -pthread_create(3) , -pthread_attr_setdetachstate(3) -, pthread_cleanup_push(3) -, pthread_key_create(3) -. -

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_key_create.html b/deps/w32-pthreads/manual/pthread_key_create.html deleted file mode 100644 index 5ecca69..0000000 --- a/deps/w32-pthreads/manual/pthread_key_create.html +++ /dev/null @@ -1,211 +0,0 @@ - - - - - PTHREAD_SPECIFIC(3) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_key_create, pthread_key_delete, pthread_setspecific, -pthread_getspecific - management of thread-specific data -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_key_create(pthread_key_t *key, void -(*destr_function) (void *)); -

-

int pthread_key_delete(pthread_key_t key); -

-

int pthread_setspecific(pthread_key_t key, const -void *pointer); -

-

void * pthread_getspecific(pthread_key_t key); -

-

Description

-

Programs often need global or static variables that have different -values in different threads. Since threads share one memory space, -this cannot be achieved with regular variables. Thread-specific data -is the POSIX threads answer to this need. -

-

Each thread possesses a private memory block, the thread-specific -data area, or TSD area for short. This area is indexed by TSD keys. -The TSD area associates values of type void * to TSD keys. TSD -keys are common to all threads, but the value associated with a given -TSD key can be different in each thread. -

-

For concreteness, the TSD areas can be viewed as arrays of void -* pointers, TSD keys as integer indices into these arrays, and -the value of a TSD key as the value of the corresponding array -element in the calling thread. -

-

When a thread is created, its TSD area initially associates NULL -with all keys. -

-

pthread_key_create allocates a new TSD key. The key is -stored in the location pointed to by key. There is a limit of -PTHREAD_KEYS_MAX on the number of keys allocated at a given -time. The value initially associated with the returned key is NULL -in all currently executing threads. -

-

The destr_function argument, if not NULL, specifies -a destructor function associated with the key. When a thread -terminates via pthread_exit or by cancellation, destr_function -is called with arguments the value associated with the key in that -thread. The destr_function is not called if that value is NULL -or the key has been deleted. The order in which destructor -functions are called at thread termination time is unspecified. -

-

Before the destructor function is called, the NULL value is -associated with the key in the current thread. A destructor function -might, however, re-associate non- NULL values to that key or -some other key. To deal with this, if after all the destructors have -been called for all non- NULL values, there are still some -non- NULL values with associated destructors, then the process -is repeated.

-

pthread_key_delete deallocates a TSD key. It does not check -whether non- NULL values are associated with that key in the -currently executing threads, nor call the destructor function -associated with the key. -

-

pthread_setspecific changes the value associated with key -in the calling thread, storing the given pointer instead. -

-

pthread_getspecific returns the value currently associated -with key in the calling thread. -

-

The routines pthread_setspecific, pthread_getspecific, -and pthread_key_delete can be called from destr_function -targeting any valid key including the key on which destr_function -is currently operating. If pthread_getspecific is called on -the key whose thread specific data is being destroyed, the value NULL -is returned, unless pthread_setspecific was called previously -on that key from within destr_function to set the value to -non-NULL. For some implementations the effect of calling -pthread_setspecific from within destr_function can be -either memory leakage or infinite loops if destr_function has -already been called at least PTHREAD_DESTRUCTOR_ITERATIONS -times.

-

Pthreads-w32 stops running key -destr_function routines after PTHREAD_DESTRUCTOR_ITERATIONS -iterations, even if some non- NULL values with associated -descriptors remain. If memory is allocated and associated with a key -from within destr_function, that memory may not be reclaimed -because that key's destr_function, may not run again.

-

Return Value

-

pthread_key_create, pthread_key_delete, and -pthread_setspecific return 0 on success and a non-zero error -code on failure. If successful, pthread_key_create stores the -newly allocated key in the location pointed to by its key -argument. -

-

pthread_getspecific returns the value associated with key -on success, and NULL on error. -

-

Errors

-

pthread_key_create returns the following error code on -error: -

-
-
-
EAGAIN -
-
-
-PTHREAD_KEYS_MAX keys are already allocated -
-
-
-
ENOMEM -
-
-
-Insufficient memory to allocate the key. -
-

pthread_key_delete and pthread_setspecific return -the following error code on error: -

-
-
-
EINVAL -
- key is not a valid, allocated TSD key -
-
-

-pthread_getspecific returns NULL if key is not a -valid, allocated TSD key. -

-

Author

-

Xavier Leroy <Xavier.Leroy@inria.fr> -

-

Modified by Ross Johnson for use with Pthreads-w32.

-

See Also

-

pthread_create(3) , -pthread_exit(3) , -pthread_testcancel(3) . -

-

Example

-

The following code fragment allocates a thread-specific array of -100 characters, with automatic reclamation at thread exit: -

-


-
-
/* Key for the thread-specific buffer */
-static pthread_key_t buffer_key;
-/* Once-only initialisation of the key */
-static pthread_once_t buffer_key_once = PTHREAD_ONCE_INIT;
-/* Allocate the thread-specific buffer */
-void buffer_alloc(void)
-{
-  pthread_once(&buffer_key_once, buffer_key_alloc);
-  pthread_setspecific(buffer_key, malloc(100));
-}
-/* Return the thread-specific buffer */
-char * get_buffer(void)
-{
-  return (char *) pthread_getspecific(buffer_key);
-}
-/* Allocate the key */
-static void buffer_key_alloc()
-{
-  pthread_key_create(&buffer_key, buffer_destroy);
-}
-/* Free the thread-specific buffer */
-static void buffer_destroy(void * buf)
-{
-  free(buf);
-}
-
-
-Table of Contents
- - - \ No newline at end of file diff --git a/deps/w32-pthreads/manual/pthread_kill.html b/deps/w32-pthreads/manual/pthread_kill.html deleted file mode 100644 index 33d61b2..0000000 --- a/deps/w32-pthreads/manual/pthread_kill.html +++ /dev/null @@ -1,152 +0,0 @@ - - - - - PTHREAD_SIGNAL(3) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_sigmask, pthread_kill, sigwait - handling of signals in -threads -

-

Synopsis

-

#include <pthread.h>
#include <signal.h> -

-

int pthread_sigmask(int how, const sigset_t -*newmask, sigset_t *oldmask); -

-

int pthread_kill(pthread_t thread, int signo); -

-

int sigwait(const sigset_t *set, int *sig);

-

Description

-

pthread_sigmask changes the signal mask for the calling -thread as described by the how and newmask arguments. -If oldmask is not NULL, the previous signal mask is -stored in the location pointed to by oldmask. Pthreads-w32 -implements this function but no other function uses the signal mask -yet.

-

The meaning of the how and newmask arguments is the -same as for sigprocmask(2). -If how is SIG_SETMASK, the signal mask is set to -newmask. If how is SIG_BLOCK, the signals -specified to newmask are added to the current signal mask. If -how is SIG_UNBLOCK, the signals specified to newmask -are removed from the current signal mask. -

-

Recall that signal masks are set on a per-thread basis, but signal -actions and signal handlers, as set with sigaction(2), are -shared between all threads. -

-

pthread_kill send signal number signo to the thread -thread. Pthreads-w32 only supports signal number 0, -which does not send any signal but causes pthread_kill to -return an error if thread is not valid.

-

sigwait suspends the calling thread until one of the -signals in set is delivered to the calling thread. It then -stores the number of the signal received in the location pointed to -by sig and returns. The signals in set must be blocked -and not ignored on entrance to sigwait. If the delivered -signal has a signal handler function attached, that function is not -called. Pthreads-w32 implements this function as a -cancellation point only - it does not wait for any signals and does -not change the location pointed to by sig.

-

Cancellation

-

sigwait is a cancellation point. -

-

Return Value

-

On success, 0 is returned. On failure, a non-zero error code is -returned. -

-

Errors

-

The pthread_sigmask function returns the following error -codes on error: -

-
-
-
EINVAL -
- how is not one of SIG_SETMASK, SIG_BLOCK, or - SIG_UNBLOCK -
-
-

-The pthread_kill function returns the following error codes on -error: -

-
-
-
EINVAL -
- signo is not a valid signal number or is unsupported.
- ESRCH -
- the thread thread does not exist (e.g. it has already - terminated) -
-
-

-The sigwait function never returns an error. -

-

Author

-

Xavier Leroy <Xavier.Leroy@inria.fr> -

-

Modified by Ross Johnson for use with Pthreads-w32.

-

See Also

-

-

-

Notes

-

In any implementation, for sigwait to work reliably, the -signals being waited for must be blocked in all threads, not only in -the calling thread, since otherwise the POSIX semantics for signal -delivery do not guarantee that itā€™s the thread doing the sigwait -that will receive the signal. The best way to achieve this is to -block those signals before any threads are created, and never unblock -them in the program other than by calling sigwait. This works -because all threads inherit their initial sigmask from their creating -thread.

-

Bugs

-

Pthreads-w32 does not implement signals yet and so these -routines have almost no use except to prevent the compiler or linker -from complaining. pthread_kill is useful in determining if the -thread is a valid thread, but since many threads implementations -reuse thread IDs, the valid thread may no longer be the thread you -think it is, and so this method of determining thread validity is not -portable, and very risky. Pthreads-w32 from version 1.0.0 -onwards implements pseudo-unique thread IDs, so applications that use -this technique (but really shouldn't) have some protection.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_mutex_init.html b/deps/w32-pthreads/manual/pthread_mutex_init.html deleted file mode 100644 index cdb333e..0000000 --- a/deps/w32-pthreads/manual/pthread_mutex_init.html +++ /dev/null @@ -1,356 +0,0 @@ - - - - - PTHREAD_MUTEX(3) manual page - - - - - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - -Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_mutex_init, pthread_mutex_lock, pthread_mutex_trylock, -pthread_mutex_timedlock, pthread_mutex_unlock, -pthread_mutex_consistent, pthread_mutex_destroy - operations on -mutexes -

-

Synopsis

-

#include <pthread.h> -

-

#include <time.h>

-

pthread_mutex_t fastmutex = -PTHREAD_MUTEX_INITIALIZER; -

-

pthread_mutex_t recmutex = -PTHREAD_RECURSIVE_MUTEX_INITIALIZER; -

-

pthread_mutex_t errchkmutex = -PTHREAD_ERRORCHECK_MUTEX_INITIALIZER; -

-

pthread_mutex_t recmutex = -PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; -

-

pthread_mutex_t errchkmutex = -PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; -

-

int pthread_mutex_init(pthread_mutex_t *mutex, -const pthread_mutexattr_t *mutexattr); -

-

int pthread_mutex_lock(pthread_mutex_t *mutex); -

-

int pthread_mutex_trylock(pthread_mutex_t *mutex); -

-

int pthread_mutex_timedlock(pthread_mutex_t *mutex, -const struct timespec *abs_timeout); -

-

int pthread_mutex_unlock(pthread_mutex_t *mutex); -

-

int pthread_mutex_consistent(pthread_mutex_t *mutex); -

-

int pthread_mutex_destroy(pthread_mutex_t *mutex); -

-

Description

-

A mutex is a MUTual EXclusion device, and is useful for protecting -shared data structures from concurrent modifications, and -implementing critical sections and monitors. -

-

A mutex has two possible states: unlocked (not owned by any -thread), and locked (owned by one thread). A mutex can never be owned -by two different threads simultaneously. A thread attempting to lock -a mutex that is already locked by another thread is suspended until -the owning thread unlocks the mutex first. -

-

pthread_mutex_init initializes the mutex object pointed to -by mutex according to the mutex attributes specified in -mutexattr. If mutexattr is NULL, default -attributes are used instead. -

-

The type of a mutex determines whether it can be locked again by a -thread that already owns it. The default type is ā€œnormalā€. See -pthread_mutexattr_init(3) -for more information on mutex attributes. -

-

Variables of type pthread_mutex_t can also be initialized -statically, using the constants PTHREAD_MUTEX_INITIALIZER (for -normal ā€œfastā€ mutexes), PTHREAD_RECURSIVE_MUTEX_INITIALIZER -(for recursive mutexes), and PTHREAD_ERRORCHECK_MUTEX_INITIALIZER -(for error checking mutexes). In -the Pthreads-w32 implementation, -an application should still call pthread_mutex_destroy -at some point to ensure that any -resources consumed by the mutex are released.

-

Any mutex type can be -initialized as a robust mutex. -See pthread_mutexattr_init(3) -for more information as well as the -section Robust Mutexes -below.

-

pthread_mutex_lock locks the given mutex. If the mutex is -currently unlocked, it becomes locked and owned by the calling -thread, and pthread_mutex_lock returns immediately. If the -mutex is already locked by another thread, pthread_mutex_lock -suspends the calling thread until the mutex is unlocked.

-

If the mutex is already locked by the calling thread, the behavior -of pthread_mutex_lock depends on the type of the mutex. If the -mutex is of the ā€œnormalā€ type, the calling thread is suspended -until the mutex is unlocked, thus effectively causing the calling -thread to deadlock. If the mutex is of the ā€˜ā€˜error checkingā€™ā€™ -type, pthread_mutex_lock returns immediately with the error -code EDEADLK. If the mutex is of the ā€˜ā€˜recursiveā€™ā€™ -type, pthread_mutex_lock succeeds and returns immediately, -recording the number of times the calling thread has locked the -mutex. An equal number of pthread_mutex_unlock operations must -be performed before the mutex returns to the unlocked state. -

-

pthread_mutex_trylock behaves identically to -pthread_mutex_lock, except that it does not block the calling -thread if the mutex is already locked by another thread (or by the -calling thread in the case of a ā€œnormalā€ or ā€œerrorcheckā€ -mutex). Instead, pthread_mutex_trylock returns immediately -with the error code EBUSY. -

-

pthread_mutex_timedlock behaves identically to -pthread_mutex_lock, except that if it cannot acquire the lock -before the abs_timeout time, the call returns with the error -code ETIMEDOUT. If the mutex can be locked immediately it is, -and the abs_timeout parameter is ignored.

-

pthread_mutex_consistent may only be called for -PTHREAD_MUTEX_ROBUST mutexes. It simply marks the mutex as -consistent. See Robust Mutexes below.

-

pthread_mutex_unlock unlocks the given mutex. The mutex is -assumed to be locked and owned by the calling thread on entrance to -pthread_mutex_unlock. If the mutex is of the ā€œnormalā€ -type, pthread_mutex_unlock always returns it to the unlocked -state. If it is of the ā€˜ā€˜recursiveā€™ā€™ type, it decrements the -locking count of the mutex (number of pthread_mutex_lock -operations performed on it by the calling thread), and only when this -count reaches zero is the mutex actually unlocked. In Pthreads-win32, -non-robust normal or default mutex types do not check the owner of -the mutex. For all types of robust mutexes the owner is checked and -an error code is returned if the calling thread does not own the -mutex.

-

On ā€˜ā€˜error checkingā€™ā€™ mutexes, pthread_mutex_unlock -actually checks at run-time that the mutex is locked on entrance, and -that it was locked by the same thread that is now calling -pthread_mutex_unlock. If these conditions are not met, an -error code is returned and the mutex remains unchanged. ā€˜ā€˜Normalā€™ā€™ -[non-robust] mutexes perform no such checks, thus allowing a locked -mutex to be unlocked by a thread other than its owner. This is -non-portable behavior and is not meant to be used as a feature.

-

pthread_mutex_destroy destroys a mutex object, freeing the -resources it might hold. The mutex must be unlocked on entrance.

-

Robust Mutexes

-

If the mutex is PTHREAD_MUTEX_ROBUST and the owning thread -terminates without unlocking the mutex the implementation will wake -one waiting thread, if any. The next thread to acquire the mutex will -receive the error code EOWNERDEAD, -in which case that thread should if possible ensure that the state -protected by the mutex is consistent and then call -pthread_mutex_consistent before -unlocking. The mutex may then be used normally from then on.

-

If the thread cannot recover the -state then it must call pthread_mutex_unlock -without calling pthread_mutex_consistent. -This will mark the mutex as unusable and wake all currently waiting -threads with the return code ENOTRECOVERABLE. -The error indicates that the mutex is no longer usable and any -threads that receive this error code from any lock operation have not -acquired the mutex. The mutex can be made consistent by calling -pthread_mutex_destroy to -uninitialize the mutex, and calling pthread_mutex_int -to reinitialize the mutex. However, -the state that was protected by the mutex remains inconsistent and -some form of application recovery is required.

-

If a thread that receives the -EOWNERDEAD error code -itself terminates without unlocking the mutex then this behaviour -repeats for the next acquiring thread.

-

Applications must ensure that -they check the return values from all calls targeting robust mutexes.

-

Robust mutexes are slower because they -require some additional overhead, however they are not very much -slower than the non-robust recursive type.

-

Cancellation

-

None of the mutex functions is a cancellation point, not even -pthread_mutex_lock, in spite of the fact that it can suspend a -thread for arbitrary durations. This way, the status of mutexes at -cancellation points is predictable, allowing cancellation handlers to -unlock precisely those mutexes that need to be unlocked before the -thread stops executing. Consequently, threads using deferred -cancellation should never hold a mutex for extended periods of time. -

-

Async-signal Safety

-

The mutex functions are not async-signal safe. What this means is -that they should not be called from a signal handler. In particular, -calling pthread_mutex_lock or pthread_mutex_unlock from -a signal handler may deadlock the calling thread. -

-

Return Value

-

pthread_mutex_init always returns 0. The other mutex -functions return 0 on success and a non-zero error code on error. -

-

Errors

-

The pthread_mutex_lock function returns the following error -code on error: -

-
-
-
EINVAL
- the mutex has not been properly initialized. -
- EDEADLK
- the mutex is already locked by the calling thread (ā€˜ā€˜error - checkingā€™ā€™ mutexes only). -
- EOWNERDEAD
- the robust mutex is now locked by the calling thread after the - previous owner terminated without unlocking it.
- ENOTRECOVERABLE
- the robust mutex is not locked and is no longer usable after the - previous owner unlocked it without calling - pthread_mutex_consistent.
-
- The pthread_mutex_trylock function returns the following - error codes on error: -
-
- EBUSY -
- the mutex could not be acquired because it was currently locked. -
- EINVAL -
- the mutex has not been properly initialized. -
- EOWNERDEAD
- the robust mutex is now locked by the calling thread after the - previous owner terminated without unlocking it.
- ENOTRECOVERABLE
- the robust mutex is not locked and is no longer usable after the - previous owner unlocked it without calling - pthread_mutex_consistent.
-
-

-The pthread_mutex_timedlock function returns the following -error codes on error: -

-
-
-
ETIMEDOUT -
- the mutex could not be acquired before the abs_timeout time - arrived. -
- EINVAL -
- the mutex has not been properly initialized. -
- EOWNERDEAD
- the robust mutex is now locked by the calling thread after the - previous owner terminated without unlocking it.
- ENOTRECOVERABLE
- the robust mutex is not locked and is no longer usable after the - previous owner unlocked it without calling - pthread_mutex_consistent.
-
-

-The pthread_mutex_unlock function returns the following error -code on error: -

-
-
-
EINVAL -
- the mutex has not been properly initialized. -
- EPERM -
- the calling thread does not own the mutex (ā€˜ā€˜error checkingā€™ā€™ - mutexes only). -
-
-

-The pthread_mutex_destroy function returns the following error -code on error: -

-
-
-
EBUSY -
- the mutex is currently locked. -
-
-

-Author

-

Xavier Leroy <Xavier.Leroy@inria.fr> -

-

Modified by Ross Johnson for use with Pthreads-w32.

-

See Also

-

pthread_mutexattr_init(3) -, pthread_mutexattr_settype(3) -, pthread_cancel(3) . -

-

Example

-

A shared global variable x can be protected by a mutex as -follows: -

-
int x;
-pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
-All accesses and modifications to x should be bracketed by -calls to pthread_mutex_lock and pthread_mutex_unlock as -follows: -
-
pthread_mutex_lock(&mut);
-/* operate on x */
-pthread_mutex_unlock(&mut);
-
-
Table -of Contents
- - - \ No newline at end of file diff --git a/deps/w32-pthreads/manual/pthread_mutexattr_init.html b/deps/w32-pthreads/manual/pthread_mutexattr_init.html deleted file mode 100644 index 760521f..0000000 --- a/deps/w32-pthreads/manual/pthread_mutexattr_init.html +++ /dev/null @@ -1,207 +0,0 @@ - - - - - PTHREAD_MUTEXATTR(3) manual page - - - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - -Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_mutexattr_init, pthread_mutexattr_destroy, -pthread_mutexattr_settype, pthread_mutexattr_gettype - mutex creation -attributes -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_mutexattr_init(pthread_mutexattr_t *attr); -

-

int pthread_mutexattr_destroy(pthread_mutexattr_t *attr); -

-

int pthread_mutexattr_settype(pthread_mutexattr_t *attr, -int type); -

-

int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, -int *type); -

-

int pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, -int type); -

-

int pthread_mutexattr_getkind_np(const pthread_mutexattr_t -*attr, int *type); -

-

int pthread_mutexattr_setrobust(pthread_mutexattr_t *attr, -int robust); -

-

int pthread_mutexattr_getrobust(pthread_mutexattr_t *attr, -int *robust); -

-

Description

-

Mutex attributes can be specified at mutex creation time, by -passing a mutex attribute object as second argument to -pthread_mutex_init(3) . -Passing NULL is equivalent to passing a mutex attribute object -with all attributes set to their default values. -

-

pthread_mutexattr_init initializes the mutex attribute -object attr and fills it with default values for the -attributes. -

-

pthread_mutexattr_destroy destroys a mutex attribute -object, which must not be reused until it is reinitialized.

-

pthread_mutexattr_settype sets the mutex type attribute in -attr to the value specified by type. -

-

pthread_mutexattr_gettype retrieves the current value of -the mutex kind attribute in attr and stores it in the location -pointed to by type. -

-

Pthreads-w32 also recognises the following equivalent -functions that are used in Linux:

-

pthread_mutexattr_setkind_np is an alias for -pthread_mutexattr_settype. -

-

pthread_mutexattr_getkind_np is -an alias for pthread_mutexattr_gettype. -

-

The following mutex types are supported:

-

PTHREAD_MUTEX_NORMAL - for -ā€˜ā€˜fastā€™ā€™ mutexes.

-

PTHREAD_MUTEX_RECURSIVE - for -ā€˜ā€˜recursiveā€™ā€™ mutexes.

-

PTHREAD_MUTEX_ERRORCHECK - for -ā€˜ā€˜error checkingā€™ā€™ mutexes.

-

The mutex type determines what happens if a thread attempts to -lock a mutex it already owns with pthread_mutex_lock(3) -. If the mutex is of the ā€œnormalā€ or ā€œfastā€ type, -pthread_mutex_lock(3) -simply suspends the calling thread forever. If the mutex is of the -ā€˜ā€˜error checkingā€™ā€™ type, pthread_mutex_lock(3) -returns immediately with the error code EDEADLK. If the mutex -is of the ā€˜ā€˜recursiveā€™ā€™ type, the call to -pthread_mutex_lock(3) -returns immediately with a success return code. The number of times -the thread owning the mutex has locked it is recorded in the mutex. -The owning thread must call pthread_mutex_unlock(3) -the same number of times before the mutex returns to the unlocked -state. -

-

The default mutex type is PTHREAD_MUTEX_NORMAL

-

Pthreads-w32 also recognises the following equivalent types -that are used by Linux:

-

PTHREAD_MUTEX_FAST_NP -ā€“ equivalent to PTHREAD_MUTEX_NORMAL

-

PTHREAD_MUTEX_RECURSIVE_NP

-

PTHREAD_MUTEX_ERRORCHECK_NP

-

pthread_mutexattr_setrobust -sets the robustness attribute to the value given by robust.

-

pthread_mutexattr_getrobust -returns the current robustness value to the location given by -*robust.

-

The possible values for robust -are:

-

PTHREAD_MUTEX_STALLED -- when the owner of the mutex terminates without unlocking the mutex, -all subsequent calls to pthread_mutex_*lock() are blocked from -progress in an unspecified manner.

-

PTHREAD_MUTEX_ROBUST -- when the owner of the mutex terminates without unlocking the mutex, -the mutex is unlocked. The next owner of this mutex acquires the -mutex with an error return of EOWNERDEAD.

-

Return Value

-

On success all functions return -0, otherwise they return an error code as follows:

-

pthread_mutexattr_init

-

ENOMEM -- insufficient memory for attr.

-

pthread_mutexattr_destroy

-

EINVAL -- attr -is invalid.

-

pthread_mutexattr_gettype

-

EINVAL -- attr -is invalid.

-

pthread_mutexattr_settype

-
-
-
-
EINVAL - attr - is invalid or type - is none of:
-
-
- PTHREAD_MUTEX_NORMAL
PTHREAD_MUTEX_FAST_NP
PTHREAD_MUTEX_RECURSIVE
PTHREAD_MUTEX_RECURSIVE_NP
PTHREAD_MUTEX_ERRORCHECK
PTHREAD_MUTEX_ERRORCHECK_NP
-
-
-
-
-
-
-

-pthread_mutexattr_getrobust

-

EINVAL -ā€“ attr -or robust -is invalid.

-

pthread_mutexattr_setrobust

-

EINVAL -ā€“ attr -or robust -is invalid.

-

Author

-

Xavier Leroy <Xavier.Leroy@inria.fr> -

-

Modified by Ross Johnson for use with Pthreads-w32.

-

See Also

-

pthread_mutex_init(3) -, pthread_mutex_lock(3) -, pthread_mutex_unlock(3) -. -

-

Notes

-

For speed, Pthreads-w32 never checks the thread ownership -of non-robust mutexes of type PTHREAD_MUTEX_NORMAL (or -PTHREAD_MUTEX_FAST_NP) when performing operations on the -mutex. It is therefore possible for one thread to lock such a mutex -and another to unlock it.

-

When developing code, it is a common -precaution to substitute the error checking type, then drop in the -normal type for release if the extra performance is required.

-
-

Table of Contents

- - - \ No newline at end of file diff --git a/deps/w32-pthreads/manual/pthread_mutexattr_setpshared.html b/deps/w32-pthreads/manual/pthread_mutexattr_setpshared.html deleted file mode 100644 index 25bf9f6..0000000 --- a/deps/w32-pthreads/manual/pthread_mutexattr_setpshared.html +++ /dev/null @@ -1,151 +0,0 @@ - - - - - "PTHREAD_MUTEXATTR_GETPSHARED"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_mutexattr_getpshared, pthread_mutexattr_setpshared - get -and set the process-shared attribute -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_mutexattr_getpshared(const pthread_mutexattr_t * -restrict attr, int *restrict pshared); -
int pthread_mutexattr_setpshared(pthread_mutexattr_t *
attr, -int pshared); -

-

Description

-

The pthread_mutexattr_getpshared function shall obtain the -value of the process-shared attribute from the attributes -object referenced by attr. The pthread_mutexattr_setpshared -function shall set the process-shared attribute in an -initialized attributes object referenced by attr. -

-

The process-shared attribute is set to -PTHREAD_PROCESS_SHARED to permit a mutex to be operated upon -by any thread that has access to the memory where the mutex is -allocated, even if the mutex is allocated in memory that is shared by -multiple processes. If the process-shared attribute is -PTHREAD_PROCESS_PRIVATE, the mutex shall only be operated upon -by threads created within the same process as the thread that -initialized the mutex; if threads of differing processes attempt to -operate on such a mutex, the behavior is undefined. The default value -of the attribute shall be PTHREAD_PROCESS_PRIVATE. -

-

Pthreads-w32 defines _POSIX_THREAD_PROCESS_SHARED in -pthread.h as -1 to indicate that these routines are implemented but -the process shared option is not supported.

-

Return Value

-

Upon successful completion, pthread_mutexattr_setpshared -shall return zero; otherwise, an error number shall be returned to -indicate the error. -

-

Upon successful completion, pthread_mutexattr_getpshared -shall return zero and store the value of the process-shared -attribute of attr into the object referenced by the pshared -parameter. Otherwise, an error number shall be returned to indicate -the error. -

-

Errors

-

The pthread_mutexattr_getpshared and -pthread_mutexattr_setpshared functions may fail if: -

-
-
EINVAL -
- The value specified by attr is invalid. -
-

-The pthread_mutexattr_setpshared function may fail if: -

-
-
EINVAL -
- The new value specified for the attribute is outside the range of - legal values for that attribute. -
- ENOTSUP -
- The new value specified for the attribute is PTHREAD_PROCESS_SHARED. -
-

-These functions shall not return an error code of [EINTR]. -

-

The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

None. -

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

pthread_cond_destroy(3) -, pthread_create(3) , -pthread_mutex_destroy(3) -, pthread_mutexattr_destroy(3) -, the Base Definitions volume of IEEE Std 1003.1-2001, -<pthread.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_num_processors_np.html b/deps/w32-pthreads/manual/pthread_num_processors_np.html deleted file mode 100644 index 0509410..0000000 --- a/deps/w32-pthreads/manual/pthread_num_processors_np.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - - PTHREAD_NUM_PROCESSORS_NP manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_num_processors_np ā€“ get the -number of processors (CPUs) in use by the process

-

Synopsis

-

#include <pthread.h> -

-

int pthread_num_processors_np(void);

-

Description

-

pthread_num_processors_np returns the number of processors -in the system. This implementation actually returns the number of -processors available to the process, which can be a lower number than -the system's number, depending on the process's affinity mask.

-

Cancellation

-

None.

-

Return Value

-

pthread_num_processors_np returns the number of processors -currently available to the process.

-

Errors

-

None.

-

Author

-

Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_once.html b/deps/w32-pthreads/manual/pthread_once.html deleted file mode 100644 index 856fb86..0000000 --- a/deps/w32-pthreads/manual/pthread_once.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - - PTHREAD_ONCE(3) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_once - once-only initialization -

-

Synopsis

-

#include <pthread.h> -

-

pthread_once_t once_control = PTHREAD_ONCE_INIT; -

-

int pthread_once(pthread_once_t *once_control, -void (*init_routine) (void)); -

-

Description

-

The purpose of pthread_once is to ensure that a piece of -initialization code is executed at most once. The once_control -argument points to a static or extern variable statically initialized -to PTHREAD_ONCE_INIT. -

-

The first time pthread_once is called with a given -once_control argument, it calls init_routine with no -argument and changes the value of the once_control variable to -record that initialization has been performed. Subsequent calls to -pthread_once with the same once_control argument do -nothing. -

-

Cancellation

-

While pthread_once is not a cancellation point, -init_routine can be. The effect on once_control of a -cancellation inside the init_routine is to leave it as if -pthread_once had not been called by the cancelled thread.

-

Return Value

-

pthread_once -returns 0 on success, or an error code on failure.

-

Errors

-

The pthread_once function returns the following error code -on error: -

-
-
-
EINVAL -
-
-

-The once_control or init_routine parameter is NULL.

-

Author

-

Xavier Leroy <Xavier.Leroy@inria.fr> -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - \ No newline at end of file diff --git a/deps/w32-pthreads/manual/pthread_rwlock_init.html b/deps/w32-pthreads/manual/pthread_rwlock_init.html deleted file mode 100644 index 530df93..0000000 --- a/deps/w32-pthreads/manual/pthread_rwlock_init.html +++ /dev/null @@ -1,193 +0,0 @@ - - - - - "PTHREAD_RWLOCK_DESTROY"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_rwlock_destroy, pthread_rwlock_init - destroy and -initialize a read-write lock object -

-

Synopsis

-

#include <pthread.h> -

-

pthread_wrlock_t rwlock = -PTHREAD_RWLOCK_INITIALIZER;

-

int pthread_rwlock_destroy(pthread_rwlock_t *rwlock); -
int pthread_rwlock_init(pthread_rwlock_t *restrict
rwlock, -const pthread_rwlockattr_t *restrict attr); -

-

Description

-

The pthread_rwlock_destroy function shall destroy the -read-write lock object referenced by rwlock and release any -resources used by the lock. The effect of subsequent use of the lock -is undefined until the lock is reinitialized by another call to -pthread_rwlock_init. An implementation may cause -pthread_rwlock_destroy to set the object referenced by rwlock -to an invalid value. Results are undefined if pthread_rwlock_destroy -is called when any thread holds rwlock. Attempting to destroy -an uninitialized read-write lock results in undefined behavior. -

-

The pthread_rwlock_init function shall allocate any -resources required to use the read-write lock referenced by rwlock -and initializes the lock to an unlocked state with attributes -referenced by attr. If attr is NULL, the default -read-write lock attributes shall be used; the effect is the same as -passing the address of a default read-write lock attributes object. -Once initialized, the lock can be used any number of times without -being reinitialized. Results are undefined if pthread_rwlock_init -is called specifying an already initialized read-write lock. Results -are undefined if a read-write lock is used without first being -initialized. -

-

If the pthread_rwlock_init function fails, rwlock -shall not be initialized and the contents of rwlock are -undefined. -

-

Pthreads-w32 supports statically initialized rwlock -objects using PTHREAD_RWLOCK_INITIALIZER. -An application should still call pthread_rwlock_destroy at -some point to ensure that any resources consumed by the read/write -lock are released.

-

Only the object referenced by rwlock may be used for -performing synchronization. The result of referring to copies of that -object in calls to pthread_rwlock_destroy , -pthread_rwlock_rdlock , pthread_rwlock_timedrdlock , -pthread_rwlock_timedwrlock , pthread_rwlock_tryrdlock , -pthread_rwlock_trywrlock , pthread_rwlock_unlock , or -pthread_rwlock_wrlock is undefined. -

-

Pthreads-w32 defines _POSIX_READER_WRITER_LOCKS in -pthread.h as 200112L to indicate that the reader/writer routines are -implemented and may be used.

-

Return Value

-

If successful, the pthread_rwlock_destroy and -pthread_rwlock_init functions shall return zero; otherwise, an -error number shall be returned to indicate the error. -

-

The [EBUSY] and [EINVAL] error checks, if implemented, act as if -they were performed immediately at the beginning of processing for -the function and caused an error return prior to modifying the state -of the read-write lock specified by rwlock. -

-

Errors

-

The pthread_rwlock_destroy function may fail if: -

-
-
EBUSY -
- The implementation has detected an attempt to destroy the object - referenced by rwlock while it is locked. -
- EINVAL -
- The value specified by rwlock is invalid. -
-

-The pthread_rwlock_init function shall fail if: -

-
-
EAGAIN -
- The system lacked the necessary resources (other than memory) to - initialize another read-write lock. -
- ENOMEM -
- Insufficient memory exists to initialize the read-write lock. -
-

-
-

-The pthread_rwlock_init function may fail if: -

-
-
EINVAL -
- The value specified by attr is invalid. -
-

-These functions shall not return an error code of [EINTR]. -

-

The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

Applications using these and related read-write lock functions may -be subject to priority inversion, as discussed in the Base -Definitions volume of IEEE Std 1003.1-2001, Section 3.285, -Priority Inversion. -

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

pthread_rwlock_rdlock(3) -, pthread_rwlock_timedrdlock(3) -, pthread_rwlock_timedwrlock(3) -, pthread_rwlock_tryrdlock(3) -, pthread_rwlock_trywrlock(3) -, pthread_rwlock_unlock(3) -, pthread_rwlock_wrlock(3) -, the Base Definitions volume of IEEE Std 1003.1-2001, -<pthread.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_rwlock_rdlock.html b/deps/w32-pthreads/manual/pthread_rwlock_rdlock.html deleted file mode 100644 index 3b63f25..0000000 --- a/deps/w32-pthreads/manual/pthread_rwlock_rdlock.html +++ /dev/null @@ -1,168 +0,0 @@ - - - - - "PTHREAD_RWLOCK_RDLOCK"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_rwlock_rdlock, pthread_rwlock_tryrdlock - lock a -read-write lock object for reading -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock); -
int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock); - -

-

Description

-

The pthread_rwlock_rdlock function shall apply a read lock -to the read-write lock referenced by rwlock. The calling -thread acquires the read lock if a writer does not hold the lock and -there are no writers blocked on the lock. -

-

Pthreads-win32 does not prefer either writers or readers in -acquiring the lock ā€“ all threads enter a single prioritised FIFO -queue. While this may not be optimally efficient for some -applications, it does ensure that one type does not starve the other.

-

A thread may hold multiple concurrent read locks on rwlock -(that is, successfully call the pthread_rwlock_rdlock function -n times). If so, the application shall ensure that the thread -performs matching unlocks (that is, it calls the -pthread_rwlock_unlock(3) -function n times). -

-

The pthread_rwlock_tryrdlock function shall apply a read -lock as in the pthread_rwlock_rdlock function, with the -exception that the function shall fail if the equivalent -pthread_rwlock_rdlock call would have blocked the calling -thread. In no case shall the pthread_rwlock_tryrdlock function -ever block; it always either acquires the lock or fails and returns -immediately. -

-

Results are undefined if any of these functions are called with an -uninitialized read-write lock. -

-

Pthreads-w32 does not detect deadlock if the thread already -owns the lock for writing.

-

Pthreads-w32 defines _POSIX_READER_WRITER_LOCKS in -pthread.h as 200112L to indicate that the reader/writer routines are -implemented and may be used.

-

Return Value

-

If successful, the pthread_rwlock_rdlock function shall -return zero; otherwise, an error number shall be returned to indicate -the error. -

-

The pthread_rwlock_tryrdlock function shall return zero if -the lock for reading on the read-write lock object referenced by -rwlock is acquired. Otherwise, an error number shall be -returned to indicate the error. -

-

Errors

-

The pthread_rwlock_tryrdlock function shall fail if: -

-
-
EBUSY -
- The read-write lock could not be acquired for reading because a - writer holds the lock or a writer with the appropriate priority was - blocked on it. -
-

-The pthread_rwlock_rdlock and pthread_rwlock_tryrdlock -functions may fail if: -

-
-
EINVAL -
- The value specified by rwlock does not refer to an - initialized read-write lock object. -
- EAGAIN -
- The read lock could not be acquired because the maximum number of - read locks for rwlock has been exceeded. -
-

-These functions shall not return an error code of [EINTR]. -

-

The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

Applications using these functions may be subject to priority -inversion, as discussed in the Base Definitions volume of -IEEE Std 1003.1-2001, Section 3.285, Priority Inversion. -

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

pthread_rwlock_destroy(3) -, pthread_rwlock_timedrdlock(3) -, pthread_rwlock_timedwrlock(3) -, pthread_rwlock_trywrlock(3) -, pthread_rwlock_unlock(3) -, pthread_rwlock_wrlock(3) -, the Base Definitions volume of IEEE Std 1003.1-2001, -<pthread.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_rwlock_timedrdlock.html b/deps/w32-pthreads/manual/pthread_rwlock_timedrdlock.html deleted file mode 100644 index 1b9ca63..0000000 --- a/deps/w32-pthreads/manual/pthread_rwlock_timedrdlock.html +++ /dev/null @@ -1,156 +0,0 @@ - - - - - "PTHREAD_RWLOCK_TIMEDRDLOCK"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_rwlock_timedrdlock - lock a read-write lock for reading -

-

Synopsis

-

#include <pthread.h>
#include <time.h> -

-

int pthread_rwlock_timedrdlock(pthread_rwlock_t *restrict -rwlock, const struct timespec *restrict abs_timeout); - -

-

Description

-

The pthread_rwlock_timedrdlock function shall apply a read -lock to the read-write lock referenced by rwlock as in the -pthread_rwlock_rdlock(3) -function. However, if the lock cannot be acquired without waiting for -other threads to unlock the lock, this wait shall be terminated when -the specified timeout expires. The timeout shall expire when the -absolute time specified by abs_timeout passes, as measured by -the clock on which timeouts are based (that is, when the value of -that clock equals or exceeds abs_timeout), or if the absolute -time specified by abs_timeout has already been passed at the -time of the call. -

-

The timespec data type is defined in the <time.h> -header. Under no circumstances shall the function fail with a timeout -if the lock can be acquired immediately. The validity of the -abs_timeout parameter need not be checked if the lock can be -immediately acquired. -

-

The calling thread may deadlock if at the time the call is made it -holds a write lock on rwlock. The results are undefined if -this function is called with an uninitialized read-write lock. -

-

Pthreads-w32 defines _POSIX_READER_WRITER_LOCKS in -pthread.h as 200112L to indicate that the reader/writer routines are -implemented and may be used.

-

Return Value

-

The pthread_rwlock_timedrdlock function shall return zero -if the lock for reading on the read-write lock object referenced by -rwlock is acquired. Otherwise, an error number shall be -returned to indicate the error. -

-

Errors

-

The pthread_rwlock_timedrdlock function shall fail if: -

-
-
ETIMEDOUT -
- The lock could not be acquired before the specified timeout expired. -
-

-The pthread_rwlock_timedrdlock function may fail if: -

-
-
EAGAIN -
- The read lock could not be acquired because the maximum number of - read locks for lock would be exceeded. -
- EINVAL -
- The value specified by rwlock does not refer to an - initialized read-write lock object, or the abs_timeout - nanosecond value is less than zero or greater than or equal to 1000 - million. -
-

-This function shall not return an error code of [EINTR]. -

-

The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

Applications using this function may be subject to priority -inversion, as discussed in the Base Definitions volume of -IEEE Std 1003.1-2001, Section 3.285, Priority Inversion. -

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

pthread_rwlock_destroy(3) -, pthread_rwlock_rdlock(3) -, pthread_rwlock_timedwrlock(3) -, pthread_rwlock_tryrdlock(3) -, pthread_rwlock_trywrlock(3) -, pthread_rwlock_unlock(3) -, pthread_rwlock_wrlock(3) -, the Base Definitions volume of IEEE Std 1003.1-2001, -<pthread.h>, <time.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_rwlock_timedwrlock.html b/deps/w32-pthreads/manual/pthread_rwlock_timedwrlock.html deleted file mode 100644 index 0213bab..0000000 --- a/deps/w32-pthreads/manual/pthread_rwlock_timedwrlock.html +++ /dev/null @@ -1,150 +0,0 @@ - - - - - "PTHREAD_RWLOCK_TIMEDWRLOCK"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_rwlock_timedwrlock - lock a read-write lock for writing -

-

Synopsis

-

#include <pthread.h>
#include <time.h> -

-

int pthread_rwlock_timedwrlock(pthread_rwlock_t *restrict -rwlock, const struct timespec *restrict abs_timeout); - -

-

Description

-

The pthread_rwlock_timedwrlock function shall apply a write -lock to the read-write lock referenced by rwlock as in the -pthread_rwlock_wrlock(3) -function. However, if the lock cannot be acquired without waiting for -other threads to unlock the lock, this wait shall be terminated when -the specified timeout expires. The timeout shall expire when the -absolute time specified by abs_timeout passes, as measured by -the clock on which timeouts are based (that is, when the value of -that clock equals or exceeds abs_timeout), or if the absolute -time specified by abs_timeout has already been passed at the -time of the call. -

-

The timespec data type is defined in the <time.h> -header. Under no circumstances shall the function fail with a timeout -if the lock can be acquired immediately. The validity of the -abs_timeout parameter need not be checked if the lock can be -immediately acquired. -

-

The calling thread may deadlock if at the time the call is made it -holds the read-write lock. The results are undefined if this function -is called with an uninitialized read-write lock. -

-

Pthreads-w32 defines _POSIX_READER_WRITER_LOCKS in -pthread.h as 200112L to indicate that the reader/writer routines are -implemented and may be used.

-

Return Value

-

The pthread_rwlock_timedwrlock function shall return zero -if the lock for writing on the read-write lock object referenced by -rwlock is acquired. Otherwise, an error number shall be -returned to indicate the error. -

-

Errors

-

The pthread_rwlock_timedwrlock function shall fail if: -

-
-
ETIMEDOUT -
- The lock could not be acquired before the specified timeout expired. -
-

-The pthread_rwlock_timedwrlock function may fail if: -

-
-
EINVAL -
- The value specified by rwlock does not refer to an initialized - read-write lock object, or the abs_timeout nanosecond value - is less than zero or greater than or equal to 1000 million. -
-

-This function shall not return an error code of [EINTR]. -

-

The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

Applications using this function may be subject to priority -inversion, as discussed in the Base Definitions volume of -IEEE Std 1003.1-2001, Section 3.285, Priority Inversion. -

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

pthread_rwlock_destroy(3) -, pthread_rwlock_rdlock(3) -, pthread_rwlock_timedrdlock(3) -, pthread_rwlock_tryrdlock(3) -, pthread_rwlock_trywrlock(3) -, pthread_rwlock_unlock(3) -, pthread_rwlock_wrlock(3) -, the Base Definitions volume of IEEE Std 1003.1-2001, -<pthread.h>, <time.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_rwlock_unlock.html b/deps/w32-pthreads/manual/pthread_rwlock_unlock.html deleted file mode 100644 index 09725cc..0000000 --- a/deps/w32-pthreads/manual/pthread_rwlock_unlock.html +++ /dev/null @@ -1,141 +0,0 @@ - - - - - "PTHREAD_RWLOCK_UNLOCK"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_rwlock_unlock - unlock a read-write lock object -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_rwlock_unlock(pthread_rwlock_t *rwlock); - -

-

Description

-

The pthread_rwlock_unlock function shall release a lock -held on the read-write lock object referenced by rwlock. -Results are undefined if the read-write lock rwlock is not -held by the calling thread. -

-

If this function is called to release a read lock from the -read-write lock object and there are other read locks currently held -on this read-write lock object, the read-write lock object remains in -the read locked state. If this function releases the last read lock -for this read-write lock object, the read-write lock object shall be -put in the unlocked state with no owners. -

-

If this function is called to release a write lock for this -read-write lock object, the read-write lock object shall be put in -the unlocked state. -

-

Pthreads-win32 does not prefer either writers or readers in -acquiring the lock ā€“ all threads enter a single prioritised FIFO -queue. While this may not be optimally efficient for some -applications, it does ensure that one type does not starve the other.

-

Results are undefined if any of these functions are called with an -uninitialized read-write lock. -

-

Pthreads-w32 defines _POSIX_READER_WRITER_LOCKS in -pthread.h as 200112L to indicate that the reader/writer routines are -implemented and may be used.

-

Return Value

-

If successful, the pthread_rwlock_unlock function shall -return zero; otherwise, an error number shall be returned to indicate -the error. -

-

Errors

-

The pthread_rwlock_unlock function may fail if: -

-
-
EINVAL -
- The value specified by rwlock does not refer to an - initialized read-write lock object. -
-

-
-

-The pthread_rwlock_unlock function shall not return an error -code of [EINTR]. -

-

The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

None. -

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

pthread_rwlock_destroy(3) -, pthread_rwlock_rdlock(3) -, pthread_rwlock_timedrdlock(3) -, pthread_rwlock_timedwrlock(3) -, pthread_rwlock_tryrdlock(3) -, pthread_rwlock_trywrlock(3) -, pthread_rwlock_wrlock(3) -, the Base Definitions volume of IEEE Std 1003.1-2001, -<pthread.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_rwlock_wrlock.html b/deps/w32-pthreads/manual/pthread_rwlock_wrlock.html deleted file mode 100644 index 02b3a19..0000000 --- a/deps/w32-pthreads/manual/pthread_rwlock_wrlock.html +++ /dev/null @@ -1,153 +0,0 @@ - - - - - "PTHREAD_RWLOCK_TRYWRLOCK"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_rwlock_trywrlock, pthread_rwlock_wrlock - lock a -read-write lock object for writing -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock); -
int pthread_rwlock_wrlock(pthread_rwlock_t *
rwlock); - -

-

Description

-

The pthread_rwlock_trywrlock function shall apply a write -lock like the pthread_rwlock_wrlock function, with the -exception that the function shall fail if any thread currently holds -rwlock (for reading or writing). -

-

The pthread_rwlock_wrlock function shall apply a write lock -to the read-write lock referenced by rwlock. The calling -thread acquires the write lock if no other thread (reader or writer) -holds the read-write lock rwlock. Otherwise, the thread shall -block until it can acquire the lock. The calling thread may deadlock -if at the time the call is made it holds the read-write lock (whether -a read or write lock). -

-

Pthreads-win32 does not prefer either writers or readers in -acquiring the lock ā€“ all threads enter a single prioritised FIFO -queue. While this may not be optimally efficient for some -applications, it does ensure that one type does not starve the other.

-

Results are undefined if any of these functions are called with an -uninitialized read-write lock. -

-

Pthreads-w32 defines _POSIX_READER_WRITER_LOCKS in -pthread.h as 200112L to indicate that the reader/writer routines are -implemented and may be used.

-

Return Value

-

The pthread_rwlock_trywrlock function shall return zero if -the lock for writing on the read-write lock object referenced by -rwlock is acquired. Otherwise, an error number shall be -returned to indicate the error. -

-

If successful, the pthread_rwlock_wrlock function shall -return zero; otherwise, an error number shall be returned to indicate -the error. -

-

Errors

-

The pthread_rwlock_trywrlock function shall fail if: -

-
-
EBUSY -
- The read-write lock could not be acquired for writing because it was - already locked for reading or writing. -
-

-The pthread_rwlock_trywrlock and pthread_rwlock_wrlock -functions may fail if: -

-
-
EINVAL -
- The value specified by rwlock does not refer to an - initialized read-write lock object. -
-

-These functions shall not return an error code of [EINTR]. -

-

The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

Applications using these functions may be subject to priority -inversion, as discussed in the Base Definitions volume of -IEEE Std 1003.1-2001, Section 3.285, Priority Inversion. -

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

pthread_rwlock_destroy(3) -, pthread_rwlock_rdlock(3) -, pthread_rwlock_timedrdlock(3) -, pthread_rwlock_timedwrlock(3) -, pthread_rwlock_tryrdlock(3) -, pthread_rwlock_unlock(3) -, the Base Definitions volume of IEEE Std 1003.1-2001, -<pthread.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_rwlockattr_init.html b/deps/w32-pthreads/manual/pthread_rwlockattr_init.html deleted file mode 100644 index 67da876..0000000 --- a/deps/w32-pthreads/manual/pthread_rwlockattr_init.html +++ /dev/null @@ -1,141 +0,0 @@ - - - - - "PTHREAD_RWLOCKATTR_DESTROY"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_rwlockattr_destroy, pthread_rwlockattr_init - destroy and -initialize the read-write lock attributes object -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr); -
int pthread_rwlockattr_init(pthread_rwlockattr_t *
attr); - -

-

Description

-

The pthread_rwlockattr_destroy function shall destroy a -read-write lock attributes object. A destroyed attr attributes -object can be reinitialized using pthread_rwlockattr_init ; -the results of otherwise referencing the object after it has been -destroyed are undefined. An implementation may cause -pthread_rwlockattr_destroy to set the object referenced by -attr to an invalid value. -

-

The pthread_rwlockattr_init function shall initialize a -read-write lock attributes object attr with the default value -for all of the attributes defined by the implementation. -

-

Results are undefined if pthread_rwlockattr_init is called -specifying an already initialized attr attributes object. -

-

After a read-write lock attributes object has been used to -initialize one or more read-write locks, any function affecting the -attributes object (including destruction) shall not affect any -previously initialized read-write locks. -

-

Pthreads-w32 defines _POSIX_READER_WRITER_LOCKS in -pthread.h as 200112L to indicate that the reader/writer routines are -implemented and may be used.

-

Return Value

-

If successful, the pthread_rwlockattr_destroy and -pthread_rwlockattr_init functions shall return zero; -otherwise, an error number shall be returned to indicate the error. -

-

Errors

-

The pthread_rwlockattr_destroy function may fail if: -

-
-
EINVAL -
- The value specified by attr is invalid. -
-

-The pthread_rwlockattr_init function shall fail if: -

-
-
ENOMEM -
- Insufficient memory exists to initialize the read-write lock - attributes object. -
-

-These functions shall not return an error code of [EINTR]. -

-

The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

None. -

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

pthread_rwlock_destroy(3) -, pthread_rwlockattr_getpshared(3) -, pthread_rwlockattr_setpshared(3) -, the Base Definitions volume of IEEE Std 1003.1-2001, -<pthread.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_rwlockattr_setpshared.html b/deps/w32-pthreads/manual/pthread_rwlockattr_setpshared.html deleted file mode 100644 index 9db6f4c..0000000 --- a/deps/w32-pthreads/manual/pthread_rwlockattr_setpshared.html +++ /dev/null @@ -1,160 +0,0 @@ - - - - - "PTHREAD_RWLOCKATTR_GETPSHARED"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_rwlockattr_getpshared, pthread_rwlockattr_setpshared - get -and set the process-shared attribute of the read-write lock -attributes object -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t * -restrict attr, int *restrict pshared); -
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *
attr, -int pshared); -

-

Description

-

The pthread_rwlockattr_getpshared function shall obtain the -value of the process-shared attribute from the initialized -attributes object referenced by attr. The -pthread_rwlockattr_setpshared function shall set the -process-shared attribute in an initialized attributes object -referenced by attr. -

-

The process-shared attribute shall be set to -PTHREAD_PROCESS_SHARED to permit a read-write lock to be -operated upon by any thread that has access to the memory where the -read-write lock is allocated, even if the read-write lock is -allocated in memory that is shared by multiple processes. If the -process-shared attribute is PTHREAD_PROCESS_PRIVATE, -the read-write lock shall only be operated upon by threads created -within the same process as the thread that initialized the read-write -lock; if threads of differing processes attempt to operate on such a -read-write lock, the behavior is undefined. The default value of the -process-shared attribute shall be PTHREAD_PROCESS_PRIVATE. -

-

Pthreads-w32 defines _POSIX_THREAD_PROCESS_SHARED in -pthread.h as -1 to indicate that these routines are implemented but -they do not support the process shared option.

-

Additional attributes, their default values, and the names of the -associated functions to get and set those attribute values are -implementation-defined. -

-

Pthreads-w32 defines _POSIX_READER_WRITER_LOCKS in -pthread.h as 200112L to indicate that the reader/writer routines are -implemented and may be used.

-

Return Value

-

Upon successful completion, the pthread_rwlockattr_getpshared -function shall return zero and store the value of the process-shared -attribute of attr into the object referenced by the pshared -parameter. Otherwise, an error number shall be returned to indicate -the error. -

-

If successful, the pthread_rwlockattr_setpshared function -shall return zero; otherwise, an error number shall be returned to -indicate the error. -

-

Errors

-

The pthread_rwlockattr_getpshared and -pthread_rwlockattr_setpshared functions may fail if: -

-
-
EINVAL -
- The value specified by attr is invalid. -
-

-The pthread_rwlockattr_setpshared function may fail if: -

-
-
EINVAL -
- The new value specified for the attribute is outside the range of - legal values for that attribute. -
- ENOTSUP -
- The new value specified for the attribute is PTHREAD_PROCESS_SHARED. -
-

-These functions shall not return an error code of [EINTR]. -

-

The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

None. -

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

pthread_rwlock_destroy(3) -, pthread_rwlockattr_destroy(3) -, pthread_rwlockattr_init(3) -, the Base Definitions volume of IEEE Std 1003.1-2001, -<pthread.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_self.html b/deps/w32-pthreads/manual/pthread_self.html deleted file mode 100644 index 82e16ea..0000000 --- a/deps/w32-pthreads/manual/pthread_self.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - PTHREAD_SELF(3) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_self - return identifier of current thread -

-

Synopsis

-

#include <pthread.h> -

-

pthread_t pthread_self(void); -

-

Description

-

pthread_self return the thread identifier for the calling -thread. -

-

Pthreads-w32 also provides support for Win32 native -threads to interact with POSIX threads through the pthreads API. -Whereas all threads created via a call to pthread_create have a POSIX -thread ID and thread state, the library ensures that any Win32 native -threads that interact through the Pthreads API also generate a POSIX -thread ID and thread state when and if necessary. This provides full -reciprocity between Win32 and POSIX -threads. Win32 native threads that generate a POSIX thread ID and -state are treated by the library as having been created with the -PTHREAD_CREATE_DETACHED attribute.

-

Any Win32 native thread may call pthread_self directly to -return it's POSIX thread identifier. The ID and state will be -generated if it does not already exist. Win32 native threads do not -need to call pthread_self before calling Pthreads-w32 routines -unless that routine requires a pthread_t parameter.

-

Author

-

Xavier Leroy <Xavier.Leroy@inria.fr> -

-

Modified by Ross Johnson for use with Pthreads-w32.

-

See Also

-

pthread_equal(3) , -pthread_join(3) , -pthread_detach(3) , -pthread_setschedparam(3) -, pthread_getschedparam(3) -. -

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_setcancelstate.html b/deps/w32-pthreads/manual/pthread_setcancelstate.html deleted file mode 100644 index 3ce65c4..0000000 --- a/deps/w32-pthreads/manual/pthread_setcancelstate.html +++ /dev/null @@ -1,207 +0,0 @@ - - - - - PTHREAD_CANCEL(3) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_cancel, pthread_setcancelstate, pthread_setcanceltype, -pthread_testcancel - thread cancellation -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_cancel(pthread_t thread); -

-

int pthread_setcancelstate(int state, int -*oldstate); -

-

int pthread_setcanceltype(int type, int -*oldtype); -

-

void pthread_testcancel(void); -

-

Description

-

Cancellation is the mechanism by which a thread can terminate the -execution of another thread. More precisely, a thread can send a -cancellation request to another thread. Depending on its settings, -the target thread can then either ignore the request, honor it -immediately, or defer it until it reaches a cancellation point. -

-

When a thread eventually honors a cancellation request, it -performs as if pthread_exit(PTHREAD_CANCELED) has been called -at that point: all cleanup handlers are executed in reverse order, -destructor functions for thread-specific data are called, and finally -the thread stops executing with the return value PTHREAD_CANCELED. -See pthread_exit(3) for more -information. -

-

pthread_cancel sends a cancellation request to the thread -denoted by the thread argument. -

-

pthread_setcancelstate changes the cancellation state for -the calling thread -- that is, whether cancellation requests are -ignored or not. The state argument is the new cancellation -state: either PTHREAD_CANCEL_ENABLE to enable cancellation, or -PTHREAD_CANCEL_DISABLE to disable cancellation (cancellation -requests are ignored). If oldstate is not NULL, the -previous cancellation state is stored in the location pointed to by -oldstate, and can thus be restored later by another call to -pthread_setcancelstate. -

-

pthread_setcanceltype changes the type of responses to -cancellation requests for the calling thread: asynchronous -(immediate) or deferred. The type argument is the new -cancellation type: either PTHREAD_CANCEL_ASYNCHRONOUS to -cancel the calling thread as soon as the cancellation request is -received, or PTHREAD_CANCEL_DEFERRED to keep the cancellation -request pending until the next cancellation point. If oldtype -is not NULL, the previous cancellation state is stored in the -location pointed to by oldtype, and can thus be restored later -by another call to pthread_setcanceltype. -

-

Pthreads-w32 provides two levels of support for -PTHREAD_CANCEL_ASYNCHRONOUS: full and partial. Full support -requires an additional DLL and driver be installed on the Windows -system (see the See Also section below) that allows blocked threads -to be cancelled immediately. Partial support means that the target -thread will not cancel until it resumes execution naturally. Partial -support is provided if either the DLL or the driver are not -automatically detected by the pthreads-w32 library at run-time.

-

Threads are always created by pthread_create(3) -with cancellation enabled and deferred. That is, the initial -cancellation state is PTHREAD_CANCEL_ENABLE and the initial -type is PTHREAD_CANCEL_DEFERRED. -

-

Cancellation points are those points in the program execution -where a test for pending cancellation requests is performed and -cancellation is executed if positive. The following POSIX threads -functions are cancellation points: -

-

pthread_join(3) -
pthread_cond_wait(3) -
pthread_cond_timedwait(3) -
pthread_testcancel(3) -
sem_wait(3)
sem_timedwait(3) -
sigwait(3) (not supported under -Pthreads-w32)

-

Pthreads-w32 provides two functions to enable additional -cancellation points to be created in user functions that block on -Win32 HANDLEs:

-

pthreadCancelableWait() -
pthreadCancelableTimedWait()

-

All other POSIX threads functions are guaranteed not to be -cancellation points. That is, they never perform cancellation in -deferred cancellation mode. -

-

pthread_testcancel does nothing except testing for pending -cancellation and executing it. Its purpose is to introduce explicit -checks for cancellation in long sequences of code that do not call -cancellation point functions otherwise. -

-

Return Value

-

pthread_cancel, pthread_setcancelstate and -pthread_setcanceltype return 0 on success and a non-zero error -code on error. -

-

Errors

-

pthread_cancel returns the following error code on error: -

-
-
-
ESRCH -
- no thread could be found corresponding to that specified by the - thread ID. -
-
-

-pthread_setcancelstate returns the following error code on -error: -

-
-
-
EINVAL -
- the state argument is not -
-
-
-PTHREAD_CANCEL_ENABLE nor PTHREAD_CANCEL_DISABLE -
-

pthread_setcanceltype returns the following error code on -error: -

-
-
-
EINVAL -
- the type argument is not -
-
-
-PTHREAD_CANCEL_DEFERRED nor PTHREAD_CANCEL_ASYNCHRONOUS -
-

Author

-

Xavier Leroy <Xavier.Leroy@inria.fr> -

-

Modified by Ross Johnson for use with Pthreads-w32.

-

See Also

-

pthread_exit(3) , -pthread_cleanup_push(3) -, pthread_cleanup_pop(3) -, Pthreads-w32 package README file 'Prerequisites' section. -

-

Bugs

-

POSIX specifies that a number of system calls (basically, all -system calls that may block, such as read(2) -, write(2) , wait(2) -, etc.) and library functions that may call these system calls (e.g. -fprintf(3) ) are cancellation -points. Pthreads-win32 is not integrated enough with the C -library to implement this, and thus none of the C library functions -is a cancellation point. -

-

A workaround for these calls is to temporarily switch to -asynchronous cancellation (assuming full asynchronous cancellation -support is installed). So, checking for cancellation during a read -system call, for instance, can be achieved as follows: -

-


-
-
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldCancelType);
-read(fd, buffer, length);
-pthread_setcanceltype(oldCancelType, NULL);
-
-
Table of Contents
- - - diff --git a/deps/w32-pthreads/manual/pthread_setcanceltype.html b/deps/w32-pthreads/manual/pthread_setcanceltype.html deleted file mode 100644 index 935ed82..0000000 --- a/deps/w32-pthreads/manual/pthread_setcanceltype.html +++ /dev/null @@ -1,207 +0,0 @@ - - - - - PTHREAD_CANCEL(3) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_cancel, pthread_setcancelstate, pthread_setcanceltype, -pthread_testcancel - thread cancellation -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_cancel(pthread_t thread); -

-

int pthread_setcancelstate(int state, int -*oldstate); -

-

int pthread_setcanceltype(int type, int -*oldtype); -

-

void pthread_testcancel(void); -

-

Description

-

Cancellation is the mechanism by which a thread can terminate the -execution of another thread. More precisely, a thread can send a -cancellation request to another thread. Depending on its settings, -the target thread can then either ignore the request, honor it -immediately, or defer it until it reaches a cancellation point. -

-

When a thread eventually honors a cancellation request, it -performs as if pthread_exit(PTHREAD_CANCELED) has been called -at that point: all cleanup handlers are executed in reverse order, -destructor functions for thread-specific data are called, and finally -the thread stops executing with the return value PTHREAD_CANCELED. -See pthread_exit(3) for more -information. -

-

pthread_cancel sends a cancellation request to the thread -denoted by the thread argument. -

-

pthread_setcancelstate changes the cancellation state for -the calling thread -- that is, whether cancellation requests are -ignored or not. The state argument is the new cancellation -state: either PTHREAD_CANCEL_ENABLE to enable cancellation, or -PTHREAD_CANCEL_DISABLE to disable cancellation (cancellation -requests are ignored). If oldstate is not NULL, the -previous cancellation state is stored in the location pointed to by -oldstate, and can thus be restored later by another call to -pthread_setcancelstate. -

-

pthread_setcanceltype changes the type of responses to -cancellation requests for the calling thread: asynchronous -(immediate) or deferred. The type argument is the new -cancellation type: either PTHREAD_CANCEL_ASYNCHRONOUS to -cancel the calling thread as soon as the cancellation request is -received, or PTHREAD_CANCEL_DEFERRED to keep the cancellation -request pending until the next cancellation point. If oldtype -is not NULL, the previous cancellation state is stored in the -location pointed to by oldtype, and can thus be restored later -by another call to pthread_setcanceltype. -

-

Pthreads-w32 provides two levels of support for -PTHREAD_CANCEL_ASYNCHRONOUS: full and partial. Full support -requires an additional DLL and driver be installed on the Windows -system (see the See Also section below) that allows blocked threads -to be cancelled immediately. Partial support means that the target -thread will not cancel until it resumes execution naturally. Partial -support is provided if either the DLL or the driver are not -automatically detected by the pthreads-w32 library at run-time.

-

Threads are always created by pthread_create(3) -with cancellation enabled and deferred. That is, the initial -cancellation state is PTHREAD_CANCEL_ENABLE and the initial -type is PTHREAD_CANCEL_DEFERRED. -

-

Cancellation points are those points in the program execution -where a test for pending cancellation requests is performed and -cancellation is executed if positive. The following POSIX threads -functions are cancellation points: -

-

pthread_join(3) -
pthread_cond_wait(3) -
pthread_cond_timedwait(3) -
pthread_testcancel(3) -
sem_wait(3)
sem_timedwait(3) -
sigwait(3) (not supported under -Pthreads-w32)

-

Pthreads-w32 provides two functions to enable additional -cancellation points to be created in user functions that block on -Win32 HANDLEs:

-

pthreadCancelableWait() -
pthreadCancelableTimedWait()

-

All other POSIX threads functions are guaranteed not to be -cancellation points. That is, they never perform cancellation in -deferred cancellation mode. -

-

pthread_testcancel does nothing except testing for pending -cancellation and executing it. Its purpose is to introduce explicit -checks for cancellation in long sequences of code that do not call -cancellation point functions otherwise. -

-

Return Value

-

pthread_cancel, pthread_setcancelstate and -pthread_setcanceltype return 0 on success and a non-zero error -code on error. -

-

Errors

-

pthread_cancel returns the following error code on error: -

-
-
-
ESRCH -
- no thread could be found corresponding to that specified by the - thread ID. -
-
-

-pthread_setcancelstate returns the following error code on -error: -

-
-
-
EINVAL -
- the state argument is not -
-
-
-PTHREAD_CANCEL_ENABLE nor PTHREAD_CANCEL_DISABLE -
-

pthread_setcanceltype returns the following error code on -error: -

-
-
-
EINVAL -
- the type argument is not -
-
-
-PTHREAD_CANCEL_DEFERRED nor PTHREAD_CANCEL_ASYNCHRONOUS -
-

Author

-

Xavier Leroy <Xavier.Leroy@inria.fr> -

-

Modified by Ross Johnson for use with Pthreads-w32.

-

See Also

-

pthread_exit(3) , -pthread_cleanup_push(3) -, pthread_cleanup_pop(3) -, Pthreads-w32 package README file 'Prerequisites' section. -

-

Bugs

-

POSIX specifies that a number of system calls (basically, all -system calls that may block, such as read(2) -, write(2) , wait(2) -, etc.) and library functions that may call these system calls (e.g. -fprintf(3) ) are cancellation -points. Pthreads-win32 is not integrated enough with the C -library to implement this, and thus none of the C library functions -is a cancellation point. -

-

A workaround for these calls is to temporarily switch to -asynchronous cancellation (assuming full asynchronous cancellation -support is installed). So, checking for cancellation during a read -system call, for instance, can be achieved as follows: -

-


-
-
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldCancelType);
-read(fd, buffer, length);
-pthread_setcanceltype(oldCancelType, NULL);
-
-
Table of Contents
- - - diff --git a/deps/w32-pthreads/manual/pthread_setconcurrency.html b/deps/w32-pthreads/manual/pthread_setconcurrency.html deleted file mode 100644 index cdd4f58..0000000 --- a/deps/w32-pthreads/manual/pthread_setconcurrency.html +++ /dev/null @@ -1,155 +0,0 @@ - - - - - "PTHREAD_GETCONCURRENCY"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_getconcurrency, pthread_setconcurrency - get and set the -level of concurrency -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_getconcurrency(void);
int -pthread_setconcurrency(int new_level); -

-

Description

-

Unbound threads in a process may or may not be required to be -simultaneously active. By default, the threads implementation ensures -that a sufficient number of threads are active so that the process -can continue to make progress. While this conserves system resources, -it may not produce the most effective level of concurrency. -

-

The pthread_setconcurrency function allows an application -to inform the threads implementation of its desired concurrency -level, new_level. The actual level of concurrency provided by -the implementation as a result of this function call is unspecified. -

-

If new_level is zero, it causes the implementation to -maintain the concurrency level at its discretion as if -pthread_setconcurrency had never been called. -

-

The pthread_getconcurrency function shall return the value -set by a previous call to the pthread_setconcurrency function. -If the pthread_setconcurrency function was not previously -called, this function shall return zero to indicate that the -implementation is maintaining the concurrency level. -

-

A call to pthread_setconcurrency shall inform the -implementation of its desired concurrency level. The implementation -shall use this as a hint, not a requirement. -

-

If an implementation does not support multiplexing of user threads -on top of several kernel-scheduled entities, the -pthread_setconcurrency and pthread_getconcurrency -functions are provided for source code compatibility but they shall -have no effect when called. To maintain the function semantics, the -new_level parameter is saved when pthread_setconcurrency -is called so that a subsequent call to pthread_getconcurrency -shall return the same value. -

-

Pthreads-w32 provides these routines for source code -compatibility only, as described in the previous paragraph.

-

Return Value

-

If successful, the pthread_setconcurrency function shall -return zero; otherwise, an error number shall be returned to indicate -the error. -

-

The pthread_getconcurrency function shall always return the -concurrency level set by a previous call to pthread_setconcurrency -. If the pthread_setconcurrency function has never been -called, pthread_getconcurrency shall return zero. -

-

Errors

-

The pthread_setconcurrency function shall fail if: -

-
-
EINVAL -
- The value specified by new_level is negative. -
- EAGAIN -
- The value specific by new_level would cause a system resource - to be exceeded. -
-

-These functions shall not return an error code of [EINTR]. -

-

The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

Use of these functions changes the state of the underlying -concurrency upon which the application depends. Library developers -are advised to not use the pthread_getconcurrency and -pthread_setconcurrency functions since their use may conflict -with an applications use of these functions. -

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

The Base Definitions volume of IEEE Std 1003.1-2001, -<pthread.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_setschedparam.html b/deps/w32-pthreads/manual/pthread_setschedparam.html deleted file mode 100644 index 8dbb9c4..0000000 --- a/deps/w32-pthreads/manual/pthread_setschedparam.html +++ /dev/null @@ -1,114 +0,0 @@ - - - - - PTHREAD_SETSCHEDPARAM(3) manual page - - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_setschedparam, pthread_getschedparam - control thread -scheduling -

-

parameters -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_setschedparam(pthread_t target_thread, -int policy, const struct sched_param *param); -

-

int pthread_getschedparam(pthread_t target_thread, -int *policy, struct sched_param *param); -

-

Description

-

pthread_setschedparam sets the scheduling parameters for -the thread target_thread as indicated by policy and -param. policy can be either SCHED_OTHER -(regular, non-real-time scheduling), SCHED_RR (real-time, -round-robin) or SCHED_FIFO (real-time, first-in first-out). -param specifies the scheduling priority for the two real-time -policies.

-

Pthreads-w32 only supports SCHED_OTHER and does not support -the real-time scheduling policies SCHED_RR and SCHED_FIFO. -

-

pthread_getschedparam retrieves the scheduling policy and -scheduling parameters for the thread target_thread and stores -them in the locations pointed to by policy and param, -respectively. -

-

Return Value

-

pthread_setschedparam and pthread_getschedparam -return 0 on success and a non-zero error code on error. -

-

Errors

-

On error, pthread_setschedparam returns the following error -codes: -

-
-
-
ENOTSUP -
- policy is not SCHED_OTHER.
- EINVAL -
- One of the arguments is invalid, or the priority value specified by - param is not valid for the specified policy.
- ESRCH -
- The target_thread is invalid or has already terminated -
-
-

-On error, pthread_getschedparam returns the following error -codes: -

-
-
-
ESRCH -
- the target_thread is invalid or has already terminated -
-
-

-Author

-

Xavier Leroy <Xavier.Leroy@inria.fr> -

-

Modified by Ross Johnson for use with Pthreads-w32.

-

See Also

-

sched_setscheduler(2) -, sched_getscheduler(2) -, sched_getparam(2) , -pthread_attr_setschedpolicy(3) -, pthread_attr_setschedparam(3) -. -

-
-

Table of Contents

- - - \ No newline at end of file diff --git a/deps/w32-pthreads/manual/pthread_spin_init.html b/deps/w32-pthreads/manual/pthread_spin_init.html deleted file mode 100644 index 35e657b..0000000 --- a/deps/w32-pthreads/manual/pthread_spin_init.html +++ /dev/null @@ -1,176 +0,0 @@ - - - - - "PTHREAD_SPIN_DESTROY"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_spin_destroy, pthread_spin_init - destroy or initialize a -spin lock object (ADVANCED REALTIME THREADS) -

-

Synopsis

-

#include <pthread.h> -

-

pthread_spinlock_t lock = -PTHREAD_SPINLOCK_INITIALIZER;

-

int pthread_spin_destroy(pthread_spinlock_t *lock); -
int pthread_spin_init(pthread_spinlock_t *
lock, int -pshared); -

-

Description

-

The pthread_spin_destroy function shall destroy the spin -lock referenced by lock and release any resources used by the -lock. The effect of subsequent use of the lock is undefined until the -lock is reinitialized by another call to pthread_spin_init . -The results are undefined if pthread_spin_destroy is called -when a thread holds the lock, or if this function is called with an -uninitialized thread spin lock. -

-

The pthread_spin_init function shall allocate any resources -required to use the spin lock referenced by lock and -initialize the lock to an unlocked state. -

-

Pthreads-w32 supports single and multiple processor systems -as well as process CPU affinity masking by checking the mask when the -spin lock is initialized. If the process is using only a single -processor at the time pthread_spin_init is called then the -spin lock is initialized as a PTHREAD_MUTEX_NORMAL mutex object. A -thread that calls pthread_spin_lock(3) -will block rather than spin in this case. If the process CPU affinity -mask is altered after the spin lock has been initialised, the spin -lock is not modified, and may no longer be optimal for the number of -CPUs available.

-

Pthreads-w32 defines _POSIX_THREAD_PROCESS_SHARED in -pthread.h as -1 to indicate that these routines do not support the -PTHREAD_PROCESS_SHARED attribute. pthread_spin_init -will return the error ENOTSUP if the value of pshared -is not PTHREAD_PROCESS_PRIVATE.

-

The results are undefined if pthread_spin_init is called -specifying an already initialized spin lock. The results are -undefined if a spin lock is used without first being initialized. -

-

If the pthread_spin_init function fails, the lock is not -initialized and the contents of lock are undefined. -

-

Only the object referenced by lock may be used for -performing synchronization. -

-

The result of referring to copies of that object in calls to -pthread_spin_destroy , pthread_spin_lock(3) -, pthread_spin_trylock(3), -or pthread_spin_unlock(3) -is undefined. -

-

Pthreads-w32 supports statically initialized spin locks -using PTHREAD_SPINLOCK_INITIALIZER. An application should -still call pthread_spin_destroy at some point to ensure that -any resources consumed by the spin lock are released.

-

Return Value

-

Upon successful completion, these functions shall return zero; -otherwise, an error number shall be returned to indicate the error. -

-

Errors

-

These functions may fail if: -

-
-
EBUSY -
- The implementation has detected an attempt to initialize or destroy - a spin lock while it is in use (for example, while being used in a - pthread_spin_lock(3) - call) by another thread. -
- EINVAL -
- The value specified by lock is invalid. -
-

-The pthread_spin_init function shall fail if: -

-
-
ENOTSUP -
- The value of pshared is not PTHREAD_PROCESS_PRIVATE.
- ENOMEM -
- Insufficient memory exists to initialize the lock. -
-

-These functions shall not return an error code of [EINTR]. -

-

The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

The pthread_spin_destroy and pthread_spin_init -functions are part of the Spin Locks option and need not be provided -on all implementations. -

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

pthread_spin_lock(3) , -pthread_spin_unlock(3) -, the Base Definitions volume of IEEE Std 1003.1-2001, -<pthread.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_spin_lock.html b/deps/w32-pthreads/manual/pthread_spin_lock.html deleted file mode 100644 index dd180ae..0000000 --- a/deps/w32-pthreads/manual/pthread_spin_lock.html +++ /dev/null @@ -1,141 +0,0 @@ - - - - - "PTHREAD_SPIN_LOCK"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_spin_lock, pthread_spin_trylock - lock a spin lock object -(ADVANCED REALTIME THREADS) -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_spin_lock(pthread_spinlock_t *lock); -
int pthread_spin_trylock(pthread_spinlock_t *
lock); - -

-

Description

-

The pthread_spin_lock function shall lock the spin lock -referenced by lock. The calling thread shall acquire the lock -if it is not held by another thread. Otherwise, the thread shall spin -(that is, shall not return from the pthread_spin_lock call) -until the lock becomes available. The results are undefined if the -calling thread holds the lock at the time the call is made.

-

Pthreads-w32 supports single and multiple processor systems -as well as process CPU affinity masking by checking the mask when the -spin lock is initialized. If the process is using only a single -processor at the time pthread_spin_init(3) -is called then the spin lock is initialized as a PTHREAD_MUTEX_NORMAL -mutex object. A thread that calls pthread_spin_lock will block -rather than spin in this case. If the process CPU affinity mask is -altered after the spin lock has been initialised, the spin lock is -not modified, and may no longer be optimal for the number of CPUs -available.

-

The pthread_spin_trylock function shall lock the spin lock -referenced by lock if it is not held by any thread. Otherwise, -the function shall fail. -

-

The results are undefined if any of these functions is called with -an uninitialized spin lock. -

-

Return Value

-

Upon successful completion, these functions shall return zero; -otherwise, an error number shall be returned to indicate the error. -

-

Errors

-

These functions may fail if: -

-
-
EINVAL -
- The value specified by lock does not refer to an initialized - spin lock object. -
-

-The pthread_spin_trylock function shall fail if: -

-
-
EBUSY -
- A thread currently holds the lock. -
-

-These functions shall not return an error code of [EINTR]. -

-

The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

Applications using this function may be subject to priority -inversion, as discussed in the Base Definitions volume of -IEEE Std 1003.1-2001, Section 3.285, Priority Inversion. -

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

pthread_spin_destroy(3) -, pthread_spin_unlock(3) -, the Base Definitions volume of IEEE Std 1003.1-2001, -<pthread.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_spin_unlock.html b/deps/w32-pthreads/manual/pthread_spin_unlock.html deleted file mode 100644 index 2215700..0000000 --- a/deps/w32-pthreads/manual/pthread_spin_unlock.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - "PTHREAD_SPIN_UNLOCK"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_spin_unlock - unlock a spin lock object (ADVANCED -REALTIME THREADS) -

-

Synopsis

-

#include <pthread.h> -

-

int pthread_spin_unlock(pthread_spinlock_t *lock); - -

-

Description

-

The pthread_spin_unlock function shall release the spin -lock referenced by lock which was locked via the -pthread_spin_lock(3) or -pthread_spin_trylock(3) -functions. If there are threads spinning on the lock when -pthread_spin_unlock is called, the lock becomes available and -an unspecified spinning thread shall acquire the lock. -

-

Pthreads-w32 does not check ownership of the lock and it is -therefore possible for a thread other than the locker to unlock the -spin lock. This is not a feature that should be exploited.

-

The results are undefined if this function is called with an -uninitialized thread spin lock. -

-

Return Value

-

Upon successful completion, the pthread_spin_unlock -function shall return zero; otherwise, an error number shall be -returned to indicate the error. -

-

Errors

-

The pthread_spin_unlock function may fail if: -

-
-
EINVAL -
- An invalid argument was specified. -
-
-
-

-This function shall not return an error code of [EINTR]. -

-

The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

Pthreads-w32 does not check ownership of the lock and it is -therefore possible for a thread other than the locker to unlock the -spin lock. This is not a feature that should be exploited.

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

pthread_spin_destroy(3) -, pthread_spin_lock(3) -, the Base Definitions volume of IEEE Std 1003.1-2001, -<pthread.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_timechange_handler_np.html b/deps/w32-pthreads/manual/pthread_timechange_handler_np.html deleted file mode 100644 index 54226da..0000000 --- a/deps/w32-pthreads/manual/pthread_timechange_handler_np.html +++ /dev/null @@ -1,76 +0,0 @@ - - - - - PTHREAD_TIMECHANGE_HANDLER_NP manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_timechange_handler_np ā€“ -alert timed waiting condition variables to system time changes.

-

Synopsis

-

#include <pthread.h> -

-

void * pthread_timechange_handler_np(void * dummy);

-

Description

-

To improve tolerance against operator or time service initiated -system clock changes.

-

pthread_timechange_handler_np can be called by an -application when it receives a WM_TIMECHANGE message from the system. -At present it broadcasts all condition variables so that waiting -threads can wake up and re-evaluate their conditions and restart -their timed waits if required.

-

pthread_timechange_handler_np has the same return type and -argument type as a thread routine so that it may be called directly -through pthread_create(), i.e. as a separate thread. If run as a -thread, the return code must be retrieved through pthread_join().

-

Although the dummy parameter is required it is not used and -any value including NULL can be given.

-

Cancellation

-

None.

-

Return Value

-

pthread_timechange_handler_np returns 0 on success, or an -error code.

-

Errors

-

The pthread_timechange_handler_np function returns the -following error code on error: -

-
-
-
EAGAIN -
-
-

-To indicate that not all condition variables were signalled for some -reason.

-

Author

-

Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_win32_attach_detach_np.html b/deps/w32-pthreads/manual/pthread_win32_attach_detach_np.html deleted file mode 100644 index f8cfc36..0000000 --- a/deps/w32-pthreads/manual/pthread_win32_attach_detach_np.html +++ /dev/null @@ -1,74 +0,0 @@ - - - - - PTHREAD_WIN32_ATTACH_DETACH_NP manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_win32_process_attach_np, -pthread_win32_process_detach_np, pthread_win32_thread_attach_np, -pthread_win32_thread_detach_np ā€“ exposed versions of the -pthreads-w32 DLL dllMain() switch functionality for use when -statically linking the library.

-

Synopsis

-

#include <pthread.h> -

-

BOOL pthread_win32_process_attach_np (void);

-

BOOL pthread_win32_process_detach_np (void);

-

BOOL pthread_win32_thread_attach_np (void);

-

BOOL pthread_win32_thread_detach_np (void);

-

Description

-

These functions contain the code normally run via dllMain -when the library is used as a dll but which need to be called -explicitly by an application when the library is statically linked. As of version 2.9.0, the static library built using either MSC or GCC includes RT hooks which will call the pthread_win32_process_*_np routines automatically on start/exit of the application.

-

You will need to call pthread_win32_process_attach_np -before you can call any pthread routines when statically linking. You -should call pthread_win32_process_detach_np before exiting -your application to clean up.

-

pthread_win32_thread_attach_np is currently a no-op, but -pthread_win32_thread_detach_np is needed to clean up the -implicit pthread handle that is allocated to a Win32 thread if it -calls certain pthreads routines. Call this routine when the Win32 -thread exits.

-

These functions invariably return TRUE except for -pthread_win32_process_attach_np which will return FALSE if -pthreads-w32 initialisation fails.

-

Cancellation

-

None.

-

Return Value

-

These routines return TRUE (non-zero) on success, or FALSE (0) if -they fail.

-

Errors

-

None.

-

Author

-

Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/pthread_win32_test_features_np.html b/deps/w32-pthreads/manual/pthread_win32_test_features_np.html deleted file mode 100644 index 1d8e112..0000000 --- a/deps/w32-pthreads/manual/pthread_win32_test_features_np.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - - PTHREAD_WIN32_TEST_FEATURES_NP manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

pthread_win32_test_features_np ā€“ -find out what features were detected at process attach time.

-

Synopsis

-

#include <pthread.h> -

-

BOOL pthread_win32_test_features_np(int mask);

-

Description

-

pthread_win32_test_features_np allows an application to -check which run-time auto-detected features are available within the -library.

-

The possible features are:

-

PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE

-

Return TRUE if the Win32 version of -InterlockedCompareExchange() is being used. On IA32 systems the -library can use optimised and inlinable assembler versions of -InterlockedExchange() and InterlockedCompareExchange().

-

PTW32_ALERTABLE_ASYNC_CANCEL

-

Return TRUE if the QueueUserAPCEx package -QUSEREX.DLL and the AlertDrv.sys driver was detected. This package -provides alertable (pre-emptive) asynchronous threads cancellation. -If this feature returns FALSE then the default async cancel scheme is -in use, which cannot cancel blocked threads.

-

Cancellation

-

None.

-

Return Value

-

pthread_win32_test_features_np returns TRUE (non-zero) if -the specified feature is present, and FALSE (0) otherwise.

-

Errors

-

None.

-

Author

-

Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - \ No newline at end of file diff --git a/deps/w32-pthreads/manual/sched_get_priority_max.html b/deps/w32-pthreads/manual/sched_get_priority_max.html deleted file mode 100644 index 5486902..0000000 --- a/deps/w32-pthreads/manual/sched_get_priority_max.html +++ /dev/null @@ -1,115 +0,0 @@ - - - - - "SCHED_GET_PRIORITY_MAX"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

sched_get_priority_max, sched_get_priority_min - get priority -limits (REALTIME) -

-

Synopsis

-

#include <sched.h> -

-

int sched_get_priority_max(int policy);
int -sched_get_priority_min(int
policy); -

-

Description

-

The sched_get_priority_max and sched_get_priority_min -functions shall return the appropriate maximum or minimum, -respectively, for the scheduling policy specified by policy. -

-

The value of policy shall be one of the scheduling policy -values defined in <sched.h>. -

-

Return Value

-

If successful, the sched_get_priority_max and -sched_get_priority_min functions shall return the appropriate -maximum or minimum values, respectively. If unsuccessful, they shall -return a value of -1 and set errno to indicate the error. -

-

Errors

-

The sched_get_priority_max and sched_get_priority_min -functions shall fail if: -

-
-
EINVAL -
- The value of the policy parameter does not represent a - defined scheduling policy. -
-

-The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

None. -

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

sched_getscheduler(3) -, sched_setscheduler(3) -, the Base Definitions volume of IEEE Std 1003.1-2001, -<sched.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - \ No newline at end of file diff --git a/deps/w32-pthreads/manual/sched_getscheduler.html b/deps/w32-pthreads/manual/sched_getscheduler.html deleted file mode 100644 index 0089e24..0000000 --- a/deps/w32-pthreads/manual/sched_getscheduler.html +++ /dev/null @@ -1,127 +0,0 @@ - - - - - "SCHED_GETSCHEDULER"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

sched_getscheduler - get scheduling policy (REALTIME) -

-

Synopsis

-

#include <sched.h> -

-

int sched_getscheduler(pid_t pid); -

-

Description

-

The sched_getscheduler function shall return the scheduling -policy of the process specified by pid. If the value of pid -is negative, the behavior of the sched_getscheduler function -is unspecified. -

-

The values that can be returned by sched_getscheduler are -defined in the <sched.h> header. -

-

Pthreads-w32 only supports the SCHED_OTHER policy, -which is the only value that can be returned. However, checks on pid -and permissions are performed first so that the other useful side -effects of this routine are retained.

-

If a process specified by pid exists, and if the calling -process has permission, the scheduling policy shall be returned for -the process whose process ID is equal to pid. -

-

If pid is zero, the scheduling policy shall be returned for -the calling process. -

-

Return Value

-

Upon successful completion, the sched_getscheduler function -shall return the scheduling policy of the specified process. If -unsuccessful, the function shall return -1 and set errno to -indicate the error. -

-

Errors

-

The sched_getscheduler function shall fail if: -

-
-
EPERM -
- The requesting process does not have permission to determine the - scheduling policy of the specified process. -
- ESRCH -
- No process can be found corresponding to that specified by pid. -
-

-The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

None. -

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

sched_setscheduler(3) -, the Base Definitions volume of IEEE Std 1003.1-2001, -<sched.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/sched_setscheduler.html b/deps/w32-pthreads/manual/sched_setscheduler.html deleted file mode 100644 index c6e62ae..0000000 --- a/deps/w32-pthreads/manual/sched_setscheduler.html +++ /dev/null @@ -1,181 +0,0 @@ - - - - - "SCHED_SETSCHEDULER"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

sched_setscheduler - set scheduling policy and parameters -(REALTIME) -

-

Synopsis

-

#include <sched.h> -

-

int sched_setscheduler(pid_t pid, int policy, -const struct sched_param *param); -

-

Description

-

The sched_setscheduler function shall set the scheduling -policy and scheduling parameters of the process specified by pid -to policy and the parameters specified in the sched_param -structure pointed to by param, respectively. The value of the -sched_priority member in the sched_param structure -shall be any integer within the inclusive priority range for the -scheduling policy specified by policy. If the value of pid -is negative, the behavior of the sched_setscheduler function -is unspecified. -

-

The possible values for the policy parameter are defined in -the <sched.h> header. -

-

Pthreads-w32 only supports the SCHED_OTHER policy. -Any other value for policy will return failure with errno set -to ENOSYS. However, checks on pid and permissions are -performed first so that the other useful side effects of this routine -are retained.

-

If a process specified by pid exists, and if the calling -process has permission, the scheduling policy and scheduling -parameters shall be set for the process whose process ID is equal to -pid. -

-

If pid is zero, the scheduling policy and scheduling -parameters shall be set for the calling process. -

-

Implementations may require that the requesting process have -permission to set its own scheduling parameters or those of another -process. Additionally, implementation-defined restrictions may apply -as to the appropriate privileges required to set a processā€™ own -scheduling policy, or another processā€™ scheduling policy, to a -particular value. -

-

The sched_setscheduler function shall be considered -successful if it succeeds in setting the scheduling policy and -scheduling parameters of the process specified by pid to the -values specified by policy and the structure pointed to by -param, respectively. -

-

The effect of this function on individual threads is dependent on -the scheduling contention scope of the threads: -

-
-
* -
- For threads with system scheduling contention scope, these functions - shall have no effect on their scheduling. -
- * -
- For threads with process scheduling contention scope, the threadsā€™ - scheduling policy and associated parameters shall not be affected. - However, the scheduling of these threads with respect to threads in - other processes may be dependent on the scheduling parameters of - their process, which are governed using these functions. -
-

-This function is not atomic with respect to other threads in the -process. Threads may continue to execute while this function call is -in the process of changing the scheduling policy and associated -scheduling parameters for the underlying kernel-scheduled entities -used by the process contention scope threads. -

-

Return Value

-

Upon successful completion, the function shall return the former -scheduling policy of the specified process. If the sched_setscheduler -function fails to complete successfully, the policy and scheduling -parameters shall remain unchanged, and the function shall return a -value of -1 and set errno to indicate the error. -

-

Errors

-

The sched_setscheduler function shall fail if: -

-
-
EINVAL -
- The value of the policy parameter is invalid, or one or more - of the parameters contained in param is outside the valid - range for the specified scheduling policy. -
- EPERM -
- The requesting process does not have permission to set either or - both of the scheduling parameters or the scheduling policy of the - specified process. -
- ESRCH -
- No process can be found corresponding to that specified by pid. -
-

-The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

None. -

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

sched_getscheduler(3) -, the Base Definitions volume of IEEE Std 1003.1-2001, -<sched.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-

Modified by Ross Johnson for use with Pthreads-w32.

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/sched_yield.html b/deps/w32-pthreads/manual/sched_yield.html deleted file mode 100644 index fa5ed04..0000000 --- a/deps/w32-pthreads/manual/sched_yield.html +++ /dev/null @@ -1,98 +0,0 @@ - - - - - "SCHED_YIELD"(P) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

sched_yield - yield the processor -

-

Synopsis

-

#include <sched.h> -

-

int sched_yield(void); -

-

Description

-

The sched_yield function shall force the running thread to -relinquish the processor until it again becomes the head of its -thread list. It takes no arguments. -

-

Return Value

-

The sched_yield function shall return 0 if it completes -successfully; otherwise, it shall return a value of -1 and set errno -to indicate the error. -

-

Errors

-

No errors are defined. -

-

The following sections are informative. -

-

Examples

-

None. -

-

Application Usage

-

None. -

-

Rationale

-

None. -

-

Future Directions

-

None. -

-

See Also

-

The Base Definitions volume of IEEE Std 1003.1-2001, -<sched.h> -

-

Copyright

-

Portions of this text are reprinted and reproduced in electronic -form from IEEE Std 1003.1, 2003 Edition, Standard for Information -Technology -- Portable Operating System Interface (POSIX), The Open -Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the -Institute of Electrical and Electronics Engineers, Inc and The Open -Group. In the event of any discrepancy between this version and the -original IEEE and The Open Group Standard, the original IEEE and The -Open Group Standard is the referee document. The original Standard -can be obtained online at http://www.opengroup.org/unix/online.html -. -

-
-

Table of Contents

- - - diff --git a/deps/w32-pthreads/manual/sem_init.html b/deps/w32-pthreads/manual/sem_init.html deleted file mode 100644 index 80e0580..0000000 --- a/deps/w32-pthreads/manual/sem_init.html +++ /dev/null @@ -1,200 +0,0 @@ - - - - - SEMAPHORES(3) manual page - - - - - - - -

POSIX Threads for Windows ā€“ REFERENCE - Pthreads-w32

-

Reference Index

-

Table of Contents

-

Name

-

sem_init, sem_wait, sem_trywait, sem_post, sem_getvalue, -sem_destroy - operations on semaphores -

-

Synopsis

-

#include <semaphore.h> -

-

int sem_init(sem_t *sem, int pshared, -unsigned int value); -

-

int sem_wait(sem_t * sem); -

-

int sem_timedwait(sem_t * sem, const struct -timespec *abstime); -

-

int sem_trywait(sem_t * sem); -

-

int sem_post(sem_t * sem); -

-

int sem_post_multiple(sem_t * sem, int -number); -

-

int sem_getvalue(sem_t * sem, int * sval); -

-

int sem_destroy(sem_t * sem); -

-

Description

-

Semaphores are counters for resources shared between threads. The -basic operations on semaphores are: increment the counter atomically, -and wait until the counter is non-null and decrement it atomically. -

-

sem_init initializes the semaphore object pointed to by -sem. The count associated with the semaphore is set initially -to value. The pshared argument indicates whether the -semaphore is local to the current process ( pshared is zero) -or is to be shared between several processes ( pshared is not -zero).

-

Pthreads-w32 currently does not support process-shared -semaphores, thus sem_init always returns with error EPERM -if pshared is not zero. -

-

sem_wait atomically decrements sem's count if it is -greater than 0 and returns immediately or it suspends the calling -thread until it can resume following a call to sem_post or -sem_post_multiple.

-

sem_timedwait atomically decrements sem's count if -it is greater than 0 and returns immediately, or it suspends the -calling thread. If abstime time arrives before the thread can -resume following a call to sem_post or sem_post_multiple, -then sem_timedwait returns with a return code of -1 after -having set errno to ETIMEDOUT. If the call can return -without suspending then abstime is not checked.

-

sem_trywait atomically decrements sem's count if it -is greater than 0 and returns immediately, or it returns immediately -with a return code of -1 after having set errno to EAGAIN. -sem_trywait never blocks.

-

sem_post either releases one thread if there are any -waiting on sem, or it atomically increments sem's -count.

-

sem_post_multiple either releases multiple threads if there -are any waiting on sem and/or it atomically increases sem's -count. If there are currently n waiters, where n the -largest number less than or equal to number, then n -waiters are released and sem's count is incremented by number -minus n.

-

sem_getvalue stores in the location pointed to by sval -the current count of the semaphore sem. In the Pthreads-w32 -implementation: if the value returned in sval is greater than -or equal to 0 it was the sem's count at some point during the -call to sem_getvalue. If the value returned in sval is -less than 0 then it's absolute value represents the number of threads -waiting on sem at some point during the call to sem_getvalue. -POSIX does not require an implementation of sem_getvalue -to return a value in sval that is less than 0, but if it does -then it's absolute value must represent the number of waiters.

-

sem_destroy destroys a semaphore object, freeing the -resources it might hold. No threads should be waiting on the -semaphore at the time sem_destroy is called.

-

Cancellation

-

sem_wait and sem_timedwait are cancellation points. -

-

Async-signal Safety

-

These routines are not async-cancel safe.

-

Return Value

-

All semaphore functions return 0 on success, or -1 on error in -which case they write an error code in errno. -

-

Errors

-

The sem_init function sets errno to the following -codes on error: -

-
-
-
EINVAL -
- value exceeds the maximal counter value SEM_VALUE_MAX -
- ENOSYS -
-
-
-pshared is not zero -
-

The sem_timedwait function sets errno to the -following error code on error: -

-
-
-
ETIMEDOUT -
-
-
-if abstime arrives before the waiting thread can resume -following a call to sem_post or sem_post_multiple. -
-

The sem_trywait function sets errno to the following -error code on error: -

-
-
-
EAGAIN -
-
-
-if the semaphore count is currently 0 -
-

The sem_post and sem_post_multiple functions set -errno to the following error code on error: -

-
-
-
ERANGE -
- if after incrementing, the semaphore count would exceed - SEM_VALUE_MAX (the semaphore count is left unchanged in this - case) -
-
-

-The sem_destroy function sets errno to the following -error code on error: -

-
-
-
EBUSY -
- if some threads are currently blocked waiting on the semaphore. -
-
-

-Author

-

Xavier Leroy <Xavier.Leroy@inria.fr> -

-

Modified by Ross Johnson for use with Pthreads-w32.

-

See Also

-

pthread_mutex_init(3) -, pthread_cond_init(3) , -pthread_cancel(3) . -

-
-

Table of Contents

- - - \ No newline at end of file diff --git a/deps/w32-pthreads/misc.c b/deps/w32-pthreads/misc.c deleted file mode 100644 index cf0e4ec..0000000 --- a/deps/w32-pthreads/misc.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * misc.c - * - * Description: - * This translation unit implements miscellaneous thread functions. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -#include "pthread_kill.c" -#include "pthread_once.c" -#include "pthread_self.c" -#include "pthread_equal.c" -#include "pthread_setconcurrency.c" -#include "pthread_getconcurrency.c" -#include "ptw32_new.c" -#include "ptw32_calloc.c" -#include "ptw32_reuse.c" -#include "w32_CancelableWait.c" diff --git a/deps/w32-pthreads/mutex.c b/deps/w32-pthreads/mutex.c deleted file mode 100644 index 78bc6d2..0000000 --- a/deps/w32-pthreads/mutex.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * mutex.c - * - * Description: - * This translation unit implements mutual exclusion (mutex) primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#if ! defined(_UWIN) && ! defined(WINCE) -# include -#endif -#if !defined(NEED_FTIME) -#include -#endif -#include "pthread.h" -#include "implement.h" - - -#include "ptw32_mutex_check_need_init.c" -#include "pthread_mutex_init.c" -#include "pthread_mutex_destroy.c" -#include "pthread_mutexattr_init.c" -#include "pthread_mutexattr_destroy.c" -#include "pthread_mutexattr_getpshared.c" -#include "pthread_mutexattr_setpshared.c" -#include "pthread_mutexattr_settype.c" -#include "pthread_mutexattr_gettype.c" -#include "pthread_mutexattr_setrobust.c" -#include "pthread_mutexattr_getrobust.c" -#include "pthread_mutex_lock.c" -#include "pthread_mutex_timedlock.c" -#include "pthread_mutex_unlock.c" -#include "pthread_mutex_trylock.c" -#include "pthread_mutex_consistent.c" diff --git a/deps/w32-pthreads/nonportable.c b/deps/w32-pthreads/nonportable.c deleted file mode 100644 index b9ff9bf..0000000 --- a/deps/w32-pthreads/nonportable.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * nonportable.c - * - * Description: - * This translation unit implements non-portable thread functions. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -#include "pthread_mutexattr_setkind_np.c" -#include "pthread_mutexattr_getkind_np.c" -#include "pthread_getw32threadhandle_np.c" -#include "pthread_getunique_np.c" -#include "pthread_delay_np.c" -#include "pthread_num_processors_np.c" -#include "pthread_win32_attach_detach_np.c" -#include "pthread_timechange_handler_np.c" diff --git a/deps/w32-pthreads/private.c b/deps/w32-pthreads/private.c deleted file mode 100644 index 52d73b7..0000000 --- a/deps/w32-pthreads/private.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * private.c - * - * Description: - * This translation unit implements routines which are private to - * the implementation and may be used throughout it. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -#include "ptw32_MCS_lock.c" -#include "ptw32_is_attr.c" -#include "ptw32_processInitialize.c" -#include "ptw32_processTerminate.c" -#include "ptw32_threadStart.c" -#include "ptw32_threadDestroy.c" -#include "ptw32_tkAssocCreate.c" -#include "ptw32_tkAssocDestroy.c" -#include "ptw32_callUserDestroyRoutines.c" -#include "ptw32_semwait.c" -#include "ptw32_timespec.c" -#include "ptw32_relmillisecs.c" -#include "ptw32_throw.c" -#include "ptw32_getprocessors.c" diff --git a/deps/w32-pthreads/pthread.c b/deps/w32-pthreads/pthread.c deleted file mode 100644 index a061c8c..0000000 --- a/deps/w32-pthreads/pthread.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * pthread.c - * - * Description: - * This translation unit agregates pthreads-win32 translation units. - * It is used for inline optimisation of the library, - * maximising for speed at the expense of size. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -/* The following are ordered for inlining */ - -#include "private.c" -#include "attr.c" -#include "barrier.c" -#include "cancel.c" -#include "cleanup.c" -#include "condvar.c" -#include "create.c" -#include "dll.c" -#include "autostatic.c" -#include "errno.c" -#include "exit.c" -#include "fork.c" -#include "global.c" -#include "misc.c" -#include "mutex.c" -#include "nonportable.c" -#include "rwlock.c" -#include "sched.c" -#include "semaphore.c" -#include "signal.c" -#include "spin.c" -#include "sync.c" -#include "tsd.c" diff --git a/deps/w32-pthreads/pthread.dsp b/deps/w32-pthreads/pthread.dsp deleted file mode 100644 index 112bff7..0000000 --- a/deps/w32-pthreads/pthread.dsp +++ /dev/null @@ -1,142 +0,0 @@ -# Microsoft Developer Studio Project File - Name="pthread" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=pthread - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "pthread.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "pthread.mak" CFG="pthread - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "pthread - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "pthread - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "pthread - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "." -# PROP Intermediate_Dir "." -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PTW32_BUILD" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "__CLEANUP_C" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PTW32_BUILD" /YX /FD /c -# SUBTRACT CPP /u -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x809 /d "NDEBUG" -# ADD RSC /l 0x409 /i "." /d "NDEBUG" /d "PTW32_RC_MSC" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib ws2_32.lib /nologo /dll /pdb:none /machine:I386 /out:".\pthreadVC2.dll" - -!ELSEIF "$(CFG)" == "pthread - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "." -# PROP Intermediate_Dir "." -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PTW32_BUILD" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /D "__CLEANUP_C" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PTW32_BUILD" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x809 /d "_DEBUG" -# ADD RSC /l 0x409 /i "." /d "_DEBUG" /d "PTW32_RC_MSC" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib ws2_32.lib /nologo /dll /map /debug /machine:I386 /out:".\pthreadVC2.dll" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "pthread - Win32 Release" -# Name "pthread - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\pthread.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\implement.h -# End Source File -# Begin Source File - -SOURCE=.\pthread.h -# End Source File -# Begin Source File - -SOURCE=.\sched.h -# End Source File -# Begin Source File - -SOURCE=.\semaphore.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# Begin Source File - -SOURCE=.\version.rc - -!IF "$(CFG)" == "pthread - Win32 Release" - -# ADD BASE RSC /l 0xc09 -# ADD RSC /l 0x409 /i "." /d "PTW32_RC_MSC" - -!ELSEIF "$(CFG)" == "pthread - Win32 Debug" - -# ADD BASE RSC /l 0xc09 -# ADD RSC /l 0x409 /i "." /d "PTW32_RC_MSC" - -!ENDIF - -# End Source File -# End Group -# End Target -# End Project diff --git a/deps/w32-pthreads/pthread.dsw b/deps/w32-pthreads/pthread.dsw deleted file mode 100644 index 815a678..0000000 --- a/deps/w32-pthreads/pthread.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "pthread"=.\pthread.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/deps/w32-pthreads/pthread.h b/deps/w32-pthreads/pthread.h deleted file mode 100644 index d4fc589..0000000 --- a/deps/w32-pthreads/pthread.h +++ /dev/null @@ -1,1372 +0,0 @@ -/* This is an implementation of the threads API of POSIX 1003.1-2001. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#if !defined( PTHREAD_H ) -#define PTHREAD_H - -/* - * See the README file for an explanation of the pthreads-win32 version - * numbering scheme and how the DLL is named etc. - */ -#define PTW32_VERSION 2,9,1,0 -#define PTW32_VERSION_STRING "2, 9, 1, 0\0" - -/* There are three implementations of cancel cleanup. - * Note that pthread.h is included in both application - * compilation units and also internally for the library. - * The code here and within the library aims to work - * for all reasonable combinations of environments. - * - * The three implementations are: - * - * WIN32 SEH - * C - * C++ - * - * Please note that exiting a push/pop block via - * "return", "exit", "break", or "continue" will - * lead to different behaviour amongst applications - * depending upon whether the library was built - * using SEH, C++, or C. For example, a library built - * with SEH will call the cleanup routine, while both - * C++ and C built versions will not. - */ - -/* - * Define defaults for cleanup code. - * Note: Unless the build explicitly defines one of the following, then - * we default to standard C style cleanup. This style uses setjmp/longjmp - * in the cancelation and thread exit implementations and therefore won't - * do stack unwinding if linked to applications that have it (e.g. - * C++ apps). This is currently consistent with most/all commercial Unix - * POSIX threads implementations. - */ -#if !defined( __CLEANUP_SEH ) && !defined( __CLEANUP_CXX ) && !defined( __CLEANUP_C ) -# define __CLEANUP_C -#endif - -#if defined( __CLEANUP_SEH ) && ( !defined( _MSC_VER ) && !defined(PTW32_RC_MSC)) -#error ERROR [__FILE__, line __LINE__]: SEH is not supported for this compiler. -#endif - -/* - * Stop here if we are being included by the resource compiler. - */ -#if !defined(RC_INVOKED) - -#undef PTW32_LEVEL - -#if defined(_POSIX_SOURCE) -#define PTW32_LEVEL 0 -/* Early POSIX */ -#endif - -#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 -#undef PTW32_LEVEL -#define PTW32_LEVEL 1 -/* Include 1b, 1c and 1d */ -#endif - -#if defined(INCLUDE_NP) -#undef PTW32_LEVEL -#define PTW32_LEVEL 2 -/* Include Non-Portable extensions */ -#endif - -#define PTW32_LEVEL_MAX 3 - -#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_LEVEL) -#define PTW32_LEVEL PTW32_LEVEL_MAX -/* Include everything */ -#endif - -#if defined(_UWIN) -# define HAVE_STRUCT_TIMESPEC 1 -# define HAVE_SIGNAL_H 1 -# undef HAVE_PTW32_CONFIG_H -# pragma comment(lib, "pthread") -#endif - -/* - * ------------------------------------------------------------- - * - * - * Module: pthread.h - * - * Purpose: - * Provides an implementation of PThreads based upon the - * standard: - * - * POSIX 1003.1-2001 - * and - * The Single Unix Specification version 3 - * - * (these two are equivalent) - * - * in order to enhance code portability between Windows, - * various commercial Unix implementations, and Linux. - * - * See the ANNOUNCE file for a full list of conforming - * routines and defined constants, and a list of missing - * routines and constants not defined in this implementation. - * - * Authors: - * There have been many contributors to this library. - * The initial implementation was contributed by - * John Bossom, and several others have provided major - * sections or revisions of parts of the implementation. - * Often significant effort has been contributed to - * find and fix important bugs and other problems to - * improve the reliability of the library, which sometimes - * is not reflected in the amount of code which changed as - * result. - * As much as possible, the contributors are acknowledged - * in the ChangeLog file in the source code distribution - * where their changes are noted in detail. - * - * Contributors are listed in the CONTRIBUTORS file. - * - * As usual, all bouquets go to the contributors, and all - * brickbats go to the project maintainer. - * - * Maintainer: - * The code base for this project is coordinated and - * eventually pre-tested, packaged, and made available by - * - * Ross Johnson - * - * QA Testers: - * Ultimately, the library is tested in the real world by - * a host of competent and demanding scientists and - * engineers who report bugs and/or provide solutions - * which are then fixed or incorporated into subsequent - * versions of the library. Each time a bug is fixed, a - * test case is written to prove the fix and ensure - * that later changes to the code don't reintroduce the - * same error. The number of test cases is slowly growing - * and therefore so is the code reliability. - * - * Compliance: - * See the file ANNOUNCE for the list of implemented - * and not-implemented routines and defined options. - * Of course, these are all defined is this file as well. - * - * Web site: - * The source code and other information about this library - * are available from - * - * http://sources.redhat.com/pthreads-win32/ - * - * ------------------------------------------------------------- - */ - -/* Try to avoid including windows.h */ -#if (defined(__MINGW64__) || defined(__MINGW32__)) && defined(__cplusplus) -#define PTW32_INCLUDE_WINDOWS_H -#endif - -#if defined(PTW32_INCLUDE_WINDOWS_H) -#include -#endif - -#if defined(_MSC_VER) && _MSC_VER < 1300 || defined(__DMC__) -/* - * VC++6.0 or early compiler's header has no DWORD_PTR type. - */ -typedef unsigned long DWORD_PTR; -typedef unsigned long ULONG_PTR; -#endif - -#if defined(_MSC_VER) && _MSC_VER >= 1900 -#define HAVE_STRUCT_TIMESPEC -#endif -/* - * ----------------- - * autoconf switches - * ----------------- - */ - -#if defined(HAVE_PTW32_CONFIG_H) -#include "config.h" -#endif /* HAVE_PTW32_CONFIG_H */ - -#if !defined(NEED_FTIME) -#include -#else /* NEED_FTIME */ -/* use native WIN32 time API */ -#endif /* NEED_FTIME */ - -#if defined(HAVE_SIGNAL_H) -#include -#endif /* HAVE_SIGNAL_H */ - -#include - -/* - * Boolean values to make us independent of system includes. - */ -enum { - PTW32_FALSE = 0, - PTW32_TRUE = (! PTW32_FALSE) -}; - -/* - * This is a duplicate of what is in the autoconf config.h, - * which is only used when building the pthread-win32 libraries. - */ - -#if !defined(PTW32_CONFIG_H) -# if defined(WINCE) -# define NEED_ERRNO -# define NEED_SEM -# endif -# if defined(__MINGW64__) -# define HAVE_STRUCT_TIMESPEC -# define HAVE_MODE_T -# elif defined(_UWIN) || defined(__MINGW32__) -# define HAVE_MODE_T -# endif -#endif - -/* - * - */ - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX -#if defined(NEED_ERRNO) -#include "need_errno.h" -#else -#include -#endif -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ - -/* - * Several systems don't define some error numbers. - */ -#if !defined(ENOTSUP) -# define ENOTSUP 48 /* This is the value in Solaris. */ -#endif - -#if !defined(ETIMEDOUT) -# define ETIMEDOUT 10060 /* Same as WSAETIMEDOUT */ -#endif - -#if !defined(ENOSYS) -# define ENOSYS 140 /* Semi-arbitrary value */ -#endif - -#if !defined(EDEADLK) -# if defined(EDEADLOCK) -# define EDEADLK EDEADLOCK -# else -# define EDEADLK 36 /* This is the value in MSVC. */ -# endif -#endif - -/* POSIX 2008 - related to robust mutexes */ -#if !defined(EOWNERDEAD) -# define EOWNERDEAD 43 -#endif -#if !defined(ENOTRECOVERABLE) -# define ENOTRECOVERABLE 44 -#endif - -#include "sched.h" - -/* - * To avoid including windows.h we define only those things that we - * actually need from it. - */ -#if !defined(PTW32_INCLUDE_WINDOWS_H) -#if !defined(HANDLE) -# define PTW32__HANDLE_DEF -# define HANDLE void * -#endif -#if !defined(DWORD) -# define PTW32__DWORD_DEF -# define DWORD unsigned long -#endif -#endif - -#if !defined(HAVE_STRUCT_TIMESPEC) -#define HAVE_STRUCT_TIMESPEC -#if !defined(_TIMESPEC_DEFINED) -#define _TIMESPEC_DEFINED -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -#endif /* _TIMESPEC_DEFINED */ -#endif /* HAVE_STRUCT_TIMESPEC */ - -#if !defined(SIG_BLOCK) -#define SIG_BLOCK 0 -#endif /* SIG_BLOCK */ - -#if !defined(SIG_UNBLOCK) -#define SIG_UNBLOCK 1 -#endif /* SIG_UNBLOCK */ - -#if !defined(SIG_SETMASK) -#define SIG_SETMASK 2 -#endif /* SIG_SETMASK */ - -#if defined(__cplusplus) -extern "C" -{ -#endif /* __cplusplus */ - -/* - * ------------------------------------------------------------- - * - * POSIX 1003.1-2001 Options - * ========================= - * - * Options are normally set in , which is not provided - * with pthreads-win32. - * - * For conformance with the Single Unix Specification (version 3), all of the - * options below are defined, and have a value of either -1 (not supported) - * or 200112L (supported). - * - * These options can neither be left undefined nor have a value of 0, because - * either indicates that sysconf(), which is not implemented, may be used at - * runtime to check the status of the option. - * - * _POSIX_THREADS (== 200112L) - * If == 200112L, you can use threads - * - * _POSIX_THREAD_ATTR_STACKSIZE (== 200112L) - * If == 200112L, you can control the size of a thread's - * stack - * pthread_attr_getstacksize - * pthread_attr_setstacksize - * - * _POSIX_THREAD_ATTR_STACKADDR (== -1) - * If == 200112L, you can allocate and control a thread's - * stack. If not supported, the following functions - * will return ENOSYS, indicating they are not - * supported: - * pthread_attr_getstackaddr - * pthread_attr_setstackaddr - * - * _POSIX_THREAD_PRIORITY_SCHEDULING (== -1) - * If == 200112L, you can use realtime scheduling. - * This option indicates that the behaviour of some - * implemented functions conforms to the additional TPS - * requirements in the standard. E.g. rwlocks favour - * writers over readers when threads have equal priority. - * - * _POSIX_THREAD_PRIO_INHERIT (== -1) - * If == 200112L, you can create priority inheritance - * mutexes. - * pthread_mutexattr_getprotocol + - * pthread_mutexattr_setprotocol + - * - * _POSIX_THREAD_PRIO_PROTECT (== -1) - * If == 200112L, you can create priority ceiling mutexes - * Indicates the availability of: - * pthread_mutex_getprioceiling - * pthread_mutex_setprioceiling - * pthread_mutexattr_getprioceiling - * pthread_mutexattr_getprotocol + - * pthread_mutexattr_setprioceiling - * pthread_mutexattr_setprotocol + - * - * _POSIX_THREAD_PROCESS_SHARED (== -1) - * If set, you can create mutexes and condition - * variables that can be shared with another - * process.If set, indicates the availability - * of: - * pthread_mutexattr_getpshared - * pthread_mutexattr_setpshared - * pthread_condattr_getpshared - * pthread_condattr_setpshared - * - * _POSIX_THREAD_SAFE_FUNCTIONS (== 200112L) - * If == 200112L you can use the special *_r library - * functions that provide thread-safe behaviour - * - * _POSIX_READER_WRITER_LOCKS (== 200112L) - * If == 200112L, you can use read/write locks - * - * _POSIX_SPIN_LOCKS (== 200112L) - * If == 200112L, you can use spin locks - * - * _POSIX_BARRIERS (== 200112L) - * If == 200112L, you can use barriers - * - * + These functions provide both 'inherit' and/or - * 'protect' protocol, based upon these macro - * settings. - * - * ------------------------------------------------------------- - */ - -/* - * POSIX Options - */ -#undef _POSIX_THREADS -#define _POSIX_THREADS 200809L - -#undef _POSIX_READER_WRITER_LOCKS -#define _POSIX_READER_WRITER_LOCKS 200809L - -#undef _POSIX_SPIN_LOCKS -#define _POSIX_SPIN_LOCKS 200809L - -#undef _POSIX_BARRIERS -#define _POSIX_BARRIERS 200809L - -#undef _POSIX_THREAD_SAFE_FUNCTIONS -#define _POSIX_THREAD_SAFE_FUNCTIONS 200809L - -#undef _POSIX_THREAD_ATTR_STACKSIZE -#define _POSIX_THREAD_ATTR_STACKSIZE 200809L - -/* - * The following options are not supported - */ -#undef _POSIX_THREAD_ATTR_STACKADDR -#define _POSIX_THREAD_ATTR_STACKADDR -1 - -#undef _POSIX_THREAD_PRIO_INHERIT -#define _POSIX_THREAD_PRIO_INHERIT -1 - -#undef _POSIX_THREAD_PRIO_PROTECT -#define _POSIX_THREAD_PRIO_PROTECT -1 - -/* TPS is not fully supported. */ -#undef _POSIX_THREAD_PRIORITY_SCHEDULING -#define _POSIX_THREAD_PRIORITY_SCHEDULING -1 - -#undef _POSIX_THREAD_PROCESS_SHARED -#define _POSIX_THREAD_PROCESS_SHARED -1 - - -/* - * POSIX 1003.1-2001 Limits - * =========================== - * - * These limits are normally set in , which is not provided with - * pthreads-win32. - * - * PTHREAD_DESTRUCTOR_ITERATIONS - * Maximum number of attempts to destroy - * a thread's thread-specific data on - * termination (must be at least 4) - * - * PTHREAD_KEYS_MAX - * Maximum number of thread-specific data keys - * available per process (must be at least 128) - * - * PTHREAD_STACK_MIN - * Minimum supported stack size for a thread - * - * PTHREAD_THREADS_MAX - * Maximum number of threads supported per - * process (must be at least 64). - * - * SEM_NSEMS_MAX - * The maximum number of semaphores a process can have. - * (must be at least 256) - * - * SEM_VALUE_MAX - * The maximum value a semaphore can have. - * (must be at least 32767) - * - */ -#undef _POSIX_THREAD_DESTRUCTOR_ITERATIONS -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 - -#undef PTHREAD_DESTRUCTOR_ITERATIONS -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS - -#undef _POSIX_THREAD_KEYS_MAX -#define _POSIX_THREAD_KEYS_MAX 128 - -#undef PTHREAD_KEYS_MAX -#define PTHREAD_KEYS_MAX _POSIX_THREAD_KEYS_MAX - -#undef PTHREAD_STACK_MIN -#define PTHREAD_STACK_MIN 0 - -#undef _POSIX_THREAD_THREADS_MAX -#define _POSIX_THREAD_THREADS_MAX 64 - - /* Arbitrary value */ -#undef PTHREAD_THREADS_MAX -#define PTHREAD_THREADS_MAX 2019 - -#undef _POSIX_SEM_NSEMS_MAX -#define _POSIX_SEM_NSEMS_MAX 256 - - /* Arbitrary value */ -#undef SEM_NSEMS_MAX -#define SEM_NSEMS_MAX 1024 - -#undef _POSIX_SEM_VALUE_MAX -#define _POSIX_SEM_VALUE_MAX 32767 - -#undef SEM_VALUE_MAX -#define SEM_VALUE_MAX INT_MAX - - -#if defined(__GNUC__) && !defined(__declspec) -# error Please upgrade your GNU compiler to one that supports __declspec. -#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. - */ -#if !defined(PTW32_STATIC_LIB) -# if defined(PTW32_BUILD) -# define PTW32_DLLPORT __declspec (dllexport) -# else -# define PTW32_DLLPORT -# endif -#else -# define PTW32_DLLPORT -#endif - -/* - * The Open Watcom C/C++ compiler uses a non-standard calling convention - * that passes function args in registers unless __cdecl is explicitly specified - * in exposed function prototypes. - * - * We force all calls to cdecl 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 application, then you can probably define this as a null string. - * Remember that pthread.h (this file) is used for both the DLL and application builds. - */ -#define PTW32_CDECL __cdecl - -#if defined(_UWIN) && PTW32_LEVEL >= PTW32_LEVEL_MAX -# include -#else -/* - * Generic handle type - intended to extend uniqueness beyond - * that available with a simple pointer. It should scale for either - * IA-32 or IA-64. - */ -typedef struct { - void * p; /* Pointer to actual object */ - unsigned int x; /* Extra information - reuse count etc */ -} ptw32_handle_t; - -typedef ptw32_handle_t pthread_t; -typedef struct pthread_attr_t_ * pthread_attr_t; -typedef struct pthread_once_t_ pthread_once_t; -typedef struct pthread_key_t_ * pthread_key_t; -typedef struct pthread_mutex_t_ * pthread_mutex_t; -typedef struct pthread_mutexattr_t_ * pthread_mutexattr_t; -typedef struct pthread_cond_t_ * pthread_cond_t; -typedef struct pthread_condattr_t_ * pthread_condattr_t; -#endif -typedef struct pthread_rwlock_t_ * pthread_rwlock_t; -typedef struct pthread_rwlockattr_t_ * pthread_rwlockattr_t; -typedef struct pthread_spinlock_t_ * pthread_spinlock_t; -typedef struct pthread_barrier_t_ * pthread_barrier_t; -typedef struct pthread_barrierattr_t_ * pthread_barrierattr_t; - -/* - * ==================== - * ==================== - * POSIX Threads - * ==================== - * ==================== - */ - -enum { -/* - * pthread_attr_{get,set}detachstate - */ - PTHREAD_CREATE_JOINABLE = 0, /* Default */ - PTHREAD_CREATE_DETACHED = 1, - -/* - * pthread_attr_{get,set}inheritsched - */ - PTHREAD_INHERIT_SCHED = 0, - PTHREAD_EXPLICIT_SCHED = 1, /* Default */ - -/* - * pthread_{get,set}scope - */ - PTHREAD_SCOPE_PROCESS = 0, - PTHREAD_SCOPE_SYSTEM = 1, /* Default */ - -/* - * pthread_setcancelstate paramters - */ - PTHREAD_CANCEL_ENABLE = 0, /* Default */ - PTHREAD_CANCEL_DISABLE = 1, - -/* - * pthread_setcanceltype parameters - */ - PTHREAD_CANCEL_ASYNCHRONOUS = 0, - PTHREAD_CANCEL_DEFERRED = 1, /* Default */ - -/* - * pthread_mutexattr_{get,set}pshared - * pthread_condattr_{get,set}pshared - */ - PTHREAD_PROCESS_PRIVATE = 0, - PTHREAD_PROCESS_SHARED = 1, - -/* - * pthread_mutexattr_{get,set}robust - */ - PTHREAD_MUTEX_STALLED = 0, /* Default */ - PTHREAD_MUTEX_ROBUST = 1, - -/* - * pthread_barrier_wait - */ - PTHREAD_BARRIER_SERIAL_THREAD = -1 -}; - -/* - * ==================== - * ==================== - * Cancelation - * ==================== - * ==================== - */ -#define PTHREAD_CANCELED ((void *)(size_t) -1) - - -/* - * ==================== - * ==================== - * Once Key - * ==================== - * ==================== - */ -#define PTHREAD_ONCE_INIT { PTW32_FALSE, 0, 0, 0} - -struct pthread_once_t_ -{ - int done; /* indicates if user function has been executed */ - void * lock; - int reserved1; - int reserved2; -}; - - -/* - * ==================== - * ==================== - * Object initialisers - * ==================== - * ==================== - */ -#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t)(size_t) -1) -#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER ((pthread_mutex_t)(size_t) -2) -#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER ((pthread_mutex_t)(size_t) -3) - -/* - * Compatibility with LinuxThreads - */ -#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP PTHREAD_RECURSIVE_MUTEX_INITIALIZER -#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP PTHREAD_ERRORCHECK_MUTEX_INITIALIZER - -#define PTHREAD_COND_INITIALIZER ((pthread_cond_t)(size_t) -1) - -#define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t)(size_t) -1) - -#define PTHREAD_SPINLOCK_INITIALIZER ((pthread_spinlock_t)(size_t) -1) - - -/* - * Mutex types. - */ -enum -{ - /* Compatibility with LinuxThreads */ - PTHREAD_MUTEX_FAST_NP, - PTHREAD_MUTEX_RECURSIVE_NP, - PTHREAD_MUTEX_ERRORCHECK_NP, - PTHREAD_MUTEX_TIMED_NP = PTHREAD_MUTEX_FAST_NP, - PTHREAD_MUTEX_ADAPTIVE_NP = PTHREAD_MUTEX_FAST_NP, - /* For compatibility with POSIX */ - PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_FAST_NP, - PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, - PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, - PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL -}; - - -typedef struct ptw32_cleanup_t ptw32_cleanup_t; - -#if defined(_MSC_VER) -/* Disable MSVC 'anachronism used' warning */ -#pragma warning( disable : 4229 ) -#endif - -typedef void (* PTW32_CDECL ptw32_cleanup_callback_t)(void *); - -#if defined(_MSC_VER) -#pragma warning( default : 4229 ) -#endif - -struct ptw32_cleanup_t -{ - ptw32_cleanup_callback_t routine; - void *arg; - struct ptw32_cleanup_t *prev; -}; - -#if defined(__CLEANUP_SEH) - /* - * WIN32 SEH version of cancel cleanup. - */ - -#define pthread_cleanup_push( _rout, _arg ) \ - { \ - ptw32_cleanup_t _cleanup; \ - \ - _cleanup.routine = (ptw32_cleanup_callback_t)(_rout); \ - _cleanup.arg = (_arg); \ - __try \ - { \ - -#define pthread_cleanup_pop( _execute ) \ - } \ - __finally \ - { \ - if( _execute || AbnormalTermination()) \ - { \ - (*(_cleanup.routine))( _cleanup.arg ); \ - } \ - } \ - } - -#else /* __CLEANUP_SEH */ - -#if defined(__CLEANUP_C) - - /* - * C implementation of PThreads cancel cleanup - */ - -#define pthread_cleanup_push( _rout, _arg ) \ - { \ - ptw32_cleanup_t _cleanup; \ - \ - ptw32_push_cleanup( &_cleanup, (ptw32_cleanup_callback_t) (_rout), (_arg) ); \ - -#define pthread_cleanup_pop( _execute ) \ - (void) ptw32_pop_cleanup( _execute ); \ - } - -#else /* __CLEANUP_C */ - -#if defined(__CLEANUP_CXX) - - /* - * C++ version of cancel cleanup. - * - John E. Bossom. - */ - - class PThreadCleanup { - /* - * PThreadCleanup - * - * Purpose - * This class is a C++ helper class that is - * used to implement pthread_cleanup_push/ - * pthread_cleanup_pop. - * The destructor of this class automatically - * pops the pushed cleanup routine regardless - * of how the code exits the scope - * (i.e. such as by an exception) - */ - ptw32_cleanup_callback_t cleanUpRout; - void * obj; - int executeIt; - - public: - PThreadCleanup() : - cleanUpRout( 0 ), - obj( 0 ), - executeIt( 0 ) - /* - * No cleanup performed - */ - { - } - - PThreadCleanup( - ptw32_cleanup_callback_t routine, - void * arg ) : - cleanUpRout( routine ), - obj( arg ), - executeIt( 1 ) - /* - * Registers a cleanup routine for 'arg' - */ - { - } - - ~PThreadCleanup() - { - if ( executeIt && ((void *) cleanUpRout != (void *) 0) ) - { - (void) (*cleanUpRout)( obj ); - } - } - - void execute( int exec ) - { - executeIt = exec; - } - }; - - /* - * C++ implementation of PThreads cancel cleanup; - * This implementation takes advantage of a helper - * class who's destructor automatically calls the - * cleanup routine if we exit our scope weirdly - */ -#define pthread_cleanup_push( _rout, _arg ) \ - { \ - PThreadCleanup cleanup((ptw32_cleanup_callback_t)(_rout), \ - (void *) (_arg) ); - -#define pthread_cleanup_pop( _execute ) \ - cleanup.execute( _execute ); \ - } - -#else - -#error ERROR [__FILE__, line __LINE__]: Cleanup type undefined. - -#endif /* __CLEANUP_CXX */ - -#endif /* __CLEANUP_C */ - -#endif /* __CLEANUP_SEH */ - -/* - * =============== - * =============== - * Methods - * =============== - * =============== - */ - -/* - * PThread Attribute Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_attr_init (pthread_attr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_destroy (pthread_attr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getdetachstate (const pthread_attr_t * attr, - int *detachstate); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstackaddr (const pthread_attr_t * attr, - void **stackaddr); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstacksize (const pthread_attr_t * attr, - size_t * stacksize); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setdetachstate (pthread_attr_t * attr, - int detachstate); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstackaddr (pthread_attr_t * attr, - void *stackaddr); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstacksize (pthread_attr_t * attr, - size_t stacksize); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedparam (const pthread_attr_t *attr, - struct sched_param *param); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedparam (pthread_attr_t *attr, - const struct sched_param *param); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedpolicy (pthread_attr_t *, - int); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedpolicy (const pthread_attr_t *, - int *); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setinheritsched(pthread_attr_t * attr, - int inheritsched); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getinheritsched(const pthread_attr_t * attr, - int * inheritsched); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setscope (pthread_attr_t *, - int); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getscope (const pthread_attr_t *, - int *); - -/* - * PThread Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_create (pthread_t * tid, - const pthread_attr_t * attr, - void *(PTW32_CDECL *start) (void *), - void *arg); - -PTW32_DLLPORT int PTW32_CDECL pthread_detach (pthread_t tid); - -PTW32_DLLPORT int PTW32_CDECL pthread_equal (pthread_t t1, - pthread_t t2); - -PTW32_DLLPORT void PTW32_CDECL pthread_exit (void *value_ptr); - -PTW32_DLLPORT int PTW32_CDECL pthread_join (pthread_t thread, - void **value_ptr); - -PTW32_DLLPORT pthread_t PTW32_CDECL pthread_self (void); - -PTW32_DLLPORT int PTW32_CDECL pthread_cancel (pthread_t thread); - -PTW32_DLLPORT int PTW32_CDECL pthread_setcancelstate (int state, - int *oldstate); - -PTW32_DLLPORT int PTW32_CDECL pthread_setcanceltype (int type, - int *oldtype); - -PTW32_DLLPORT void PTW32_CDECL pthread_testcancel (void); - -PTW32_DLLPORT int PTW32_CDECL pthread_once (pthread_once_t * once_control, - void (PTW32_CDECL *init_routine) (void)); - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX -PTW32_DLLPORT ptw32_cleanup_t * PTW32_CDECL ptw32_pop_cleanup (int execute); - -PTW32_DLLPORT void PTW32_CDECL ptw32_push_cleanup (ptw32_cleanup_t * cleanup, - ptw32_cleanup_callback_t routine, - void *arg); -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ - -/* - * Thread Specific Data Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_key_create (pthread_key_t * key, - void (PTW32_CDECL *destructor) (void *)); - -PTW32_DLLPORT int PTW32_CDECL pthread_key_delete (pthread_key_t key); - -PTW32_DLLPORT int PTW32_CDECL pthread_setspecific (pthread_key_t key, - const void *value); - -PTW32_DLLPORT void * PTW32_CDECL pthread_getspecific (pthread_key_t key); - - -/* - * Mutex Attribute Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_init (pthread_mutexattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_destroy (pthread_mutexattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getpshared (const pthread_mutexattr_t - * attr, - int *pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setpshared (pthread_mutexattr_t * attr, - int pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_settype (pthread_mutexattr_t * attr, int kind); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_gettype (const pthread_mutexattr_t * attr, int *kind); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setrobust( - pthread_mutexattr_t *attr, - int robust); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getrobust( - const pthread_mutexattr_t * attr, - int * robust); - -/* - * Barrier Attribute Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_init (pthread_barrierattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_destroy (pthread_barrierattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_getpshared (const pthread_barrierattr_t - * attr, - int *pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_setpshared (pthread_barrierattr_t * attr, - int pshared); - -/* - * Mutex Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_init (pthread_mutex_t * mutex, - const pthread_mutexattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_destroy (pthread_mutex_t * mutex); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_lock (pthread_mutex_t * mutex); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_timedlock(pthread_mutex_t * mutex, - const struct timespec *abstime); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_trylock (pthread_mutex_t * mutex); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_unlock (pthread_mutex_t * mutex); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_consistent (pthread_mutex_t * mutex); - -/* - * Spinlock Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_spin_init (pthread_spinlock_t * lock, int pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_spin_destroy (pthread_spinlock_t * lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_spin_lock (pthread_spinlock_t * lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_spin_trylock (pthread_spinlock_t * lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_spin_unlock (pthread_spinlock_t * lock); - -/* - * Barrier Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_barrier_init (pthread_barrier_t * barrier, - const pthread_barrierattr_t * attr, - unsigned int count); - -PTW32_DLLPORT int PTW32_CDECL pthread_barrier_destroy (pthread_barrier_t * barrier); - -PTW32_DLLPORT int PTW32_CDECL pthread_barrier_wait (pthread_barrier_t * barrier); - -/* - * Condition Variable Attribute Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_init (pthread_condattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_destroy (pthread_condattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_getpshared (const pthread_condattr_t * attr, - int *pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_setpshared (pthread_condattr_t * attr, - int pshared); - -/* - * Condition Variable Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_cond_init (pthread_cond_t * cond, - const pthread_condattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_cond_destroy (pthread_cond_t * cond); - -PTW32_DLLPORT int PTW32_CDECL pthread_cond_wait (pthread_cond_t * cond, - pthread_mutex_t * mutex); - -PTW32_DLLPORT int PTW32_CDECL pthread_cond_timedwait (pthread_cond_t * cond, - pthread_mutex_t * mutex, - const struct timespec *abstime); - -PTW32_DLLPORT int PTW32_CDECL pthread_cond_signal (pthread_cond_t * cond); - -PTW32_DLLPORT int PTW32_CDECL pthread_cond_broadcast (pthread_cond_t * cond); - -/* - * Scheduling - */ -PTW32_DLLPORT int PTW32_CDECL pthread_setschedparam (pthread_t thread, - int policy, - const struct sched_param *param); - -PTW32_DLLPORT int PTW32_CDECL pthread_getschedparam (pthread_t thread, - int *policy, - struct sched_param *param); - -PTW32_DLLPORT int PTW32_CDECL pthread_setconcurrency (int); - -PTW32_DLLPORT int PTW32_CDECL pthread_getconcurrency (void); - -/* - * Read-Write Lock Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_init(pthread_rwlock_t *lock, - const pthread_rwlockattr_t *attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_destroy(pthread_rwlock_t *lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_tryrdlock(pthread_rwlock_t *); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_trywrlock(pthread_rwlock_t *); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_rdlock(pthread_rwlock_t *lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_timedrdlock(pthread_rwlock_t *lock, - const struct timespec *abstime); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_wrlock(pthread_rwlock_t *lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_timedwrlock(pthread_rwlock_t *lock, - const struct timespec *abstime); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_unlock(pthread_rwlock_t *lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_init (pthread_rwlockattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_destroy (pthread_rwlockattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * attr, - int *pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr, - int pshared); - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 - -/* - * Signal Functions. Should be defined in but MSVC and MinGW32 - * already have signal.h that don't define these. - */ -PTW32_DLLPORT int PTW32_CDECL pthread_kill(pthread_t thread, int sig); - -/* - * Non-portable functions - */ - -/* - * Compatibility with Linux. - */ -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setkind_np(pthread_mutexattr_t * attr, - int kind); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr, - int *kind); - -/* - * Possibly supported by other POSIX threads implementations - */ -PTW32_DLLPORT int PTW32_CDECL pthread_delay_np (struct timespec * interval); -PTW32_DLLPORT int PTW32_CDECL pthread_num_processors_np(void); -PTW32_DLLPORT unsigned __int64 PTW32_CDECL pthread_getunique_np(pthread_t thread); - -/* - * Useful if an application wants to statically link - * the lib rather than load the DLL at run-time. - */ -PTW32_DLLPORT int PTW32_CDECL pthread_win32_process_attach_np(void); -PTW32_DLLPORT int PTW32_CDECL pthread_win32_process_detach_np(void); -PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_attach_np(void); -PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_detach_np(void); - -/* - * Features that are auto-detected at load/run time. - */ -PTW32_DLLPORT int PTW32_CDECL pthread_win32_test_features_np(int); -enum ptw32_features { - PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE = 0x0001, /* System provides it. */ - PTW32_ALERTABLE_ASYNC_CANCEL = 0x0002 /* Can cancel blocked threads. */ -}; - -/* - * Register a system time change with the library. - * Causes the library to perform various functions - * in response to the change. Should be called whenever - * the application's top level window receives a - * WM_TIMECHANGE message. It can be passed directly to - * pthread_create() as a new thread if desired. - */ -PTW32_DLLPORT void * PTW32_CDECL pthread_timechange_handler_np(void *); - -#endif /*PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 */ - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX - -/* - * Returns the Win32 HANDLE for the POSIX thread. - */ -PTW32_DLLPORT HANDLE PTW32_CDECL pthread_getw32threadhandle_np(pthread_t thread); -/* - * Returns the win32 thread ID for POSIX thread. - */ -PTW32_DLLPORT DWORD PTW32_CDECL pthread_getw32threadid_np (pthread_t thread); - - -/* - * Protected Methods - * - * This function blocks until the given WIN32 handle - * is signaled or pthread_cancel had been called. - * This function allows the caller to hook into the - * PThreads cancel mechanism. It is implemented using - * - * WaitForMultipleObjects - * - * on 'waitHandle' and a manually reset WIN32 Event - * used to implement pthread_cancel. The 'timeout' - * argument to TimedWait is simply passed to - * WaitForMultipleObjects. - */ -PTW32_DLLPORT int PTW32_CDECL pthreadCancelableWait (HANDLE waitHandle); -PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle, - DWORD timeout); - -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ - -/* - * Thread-Safe C Runtime Library Mappings. - */ -#if !defined(_UWIN) -# if defined(NEED_ERRNO) - PTW32_DLLPORT int * PTW32_CDECL _errno( void ); -# else -# if !defined(errno) -# if (defined(_MT) || defined(_DLL)) - __declspec(dllimport) extern int * __cdecl _errno(void); -# define errno (*_errno()) -# endif -# endif -# endif -#endif - -/* - * Some compiler environments don't define some things. - */ -#if defined(__BORLANDC__) -# define _ftime ftime -# define _timeb timeb -#endif - -#if defined(__cplusplus) - -/* - * Internal exceptions - */ -class ptw32_exception {}; -class ptw32_exception_cancel : public ptw32_exception {}; -class ptw32_exception_exit : public ptw32_exception {}; - -#endif - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX - -/* FIXME: This is only required if the library was built using SEH */ -/* - * Get internal SEH tag - */ -PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void); - -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ - -#if !defined(PTW32_BUILD) - -#if defined(__CLEANUP_SEH) - -/* - * Redefine the SEH __except keyword to ensure that applications - * propagate our internal exceptions up to the library's internal handlers. - */ -#define __except( E ) \ - __except( ( GetExceptionCode() == ptw32_get_exception_services_code() ) \ - ? EXCEPTION_CONTINUE_SEARCH : ( E ) ) - -#endif /* __CLEANUP_SEH */ - -#if defined(__CLEANUP_CXX) - -/* - * Redefine the C++ catch keyword to ensure that applications - * propagate our internal exceptions up to the library's internal handlers. - */ -#if defined(_MSC_VER) - /* - * WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll' - * if you want Pthread-Win32 cancelation and pthread_exit to work. - */ - -#if !defined(PtW32NoCatchWarn) - -#pragma message("Specify \"/DPtW32NoCatchWarn\" compiler flag to skip this message.") -#pragma message("------------------------------------------------------------------") -#pragma message("When compiling applications with MSVC++ and C++ exception handling:") -#pragma message(" Replace any 'catch( ... )' in routines called from POSIX threads") -#pragma message(" with 'PtW32CatchAll' or 'CATCHALL' if you want POSIX thread") -#pragma message(" cancelation and pthread_exit to work. For example:") -#pragma message("") -#pragma message(" #if defined(PtW32CatchAll)") -#pragma message(" PtW32CatchAll") -#pragma message(" #else") -#pragma message(" catch(...)") -#pragma message(" #endif") -#pragma message(" {") -#pragma message(" /* Catchall block processing */") -#pragma message(" }") -#pragma message("------------------------------------------------------------------") - -#endif - -#define PtW32CatchAll \ - catch( ptw32_exception & ) { throw; } \ - catch( ... ) - -#else /* _MSC_VER */ - -#define catch( E ) \ - catch( ptw32_exception & ) { throw; } \ - catch( E ) - -#endif /* _MSC_VER */ - -#endif /* __CLEANUP_CXX */ - -#endif /* ! PTW32_BUILD */ - -#if defined(__cplusplus) -} /* End of extern "C" */ -#endif /* __cplusplus */ - -#if defined(PTW32__HANDLE_DEF) -# undef HANDLE -#endif -#if defined(PTW32__DWORD_DEF) -# undef DWORD -#endif - -#undef PTW32_LEVEL -#undef PTW32_LEVEL_MAX - -#endif /* ! RC_INVOKED */ - -#endif /* PTHREAD_H */ diff --git a/deps/w32-pthreads/pthread.lastbuildstate b/deps/w32-pthreads/pthread.lastbuildstate deleted file mode 100644 index 71ee68a..0000000 --- a/deps/w32-pthreads/pthread.lastbuildstate +++ /dev/null @@ -1,2 +0,0 @@ -#v4.0:v100:false -Release-Static|x64|D:\OBS2\liboms-util\w32-pthreads\| diff --git a/deps/w32-pthreads/pthread.sln b/deps/w32-pthreads/pthread.sln deleted file mode 100644 index fbf5991..0000000 --- a/deps/w32-pthreads/pthread.sln +++ /dev/null @@ -1,38 +0,0 @@ -ļ»æ -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pthread", "pthread.vcxproj", "{969D9298-8CEF-14A3-8EEF-E3C596896C8D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Debug-Static|Win32 = Debug-Static|Win32 - Debug-Static|x64 = Debug-Static|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - Release-Static|Win32 = Release-Static|Win32 - Release-Static|x64 = Release-Static|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {969D9298-8CEF-14A3-8EEF-E3C596896C8D}.Debug|Win32.ActiveCfg = Debug|Win32 - {969D9298-8CEF-14A3-8EEF-E3C596896C8D}.Debug|Win32.Build.0 = Debug|Win32 - {969D9298-8CEF-14A3-8EEF-E3C596896C8D}.Debug|x64.ActiveCfg = Debug|x64 - {969D9298-8CEF-14A3-8EEF-E3C596896C8D}.Debug|x64.Build.0 = Debug|x64 - {969D9298-8CEF-14A3-8EEF-E3C596896C8D}.Debug-Static|Win32.ActiveCfg = Debug-Static|Win32 - {969D9298-8CEF-14A3-8EEF-E3C596896C8D}.Debug-Static|Win32.Build.0 = Debug-Static|Win32 - {969D9298-8CEF-14A3-8EEF-E3C596896C8D}.Debug-Static|x64.ActiveCfg = Debug-Static|x64 - {969D9298-8CEF-14A3-8EEF-E3C596896C8D}.Debug-Static|x64.Build.0 = Debug-Static|x64 - {969D9298-8CEF-14A3-8EEF-E3C596896C8D}.Release|Win32.ActiveCfg = Release|Win32 - {969D9298-8CEF-14A3-8EEF-E3C596896C8D}.Release|Win32.Build.0 = Release|Win32 - {969D9298-8CEF-14A3-8EEF-E3C596896C8D}.Release|x64.ActiveCfg = Release|x64 - {969D9298-8CEF-14A3-8EEF-E3C596896C8D}.Release|x64.Build.0 = Release|x64 - {969D9298-8CEF-14A3-8EEF-E3C596896C8D}.Release-Static|Win32.ActiveCfg = Release-Static|Win32 - {969D9298-8CEF-14A3-8EEF-E3C596896C8D}.Release-Static|Win32.Build.0 = Release-Static|Win32 - {969D9298-8CEF-14A3-8EEF-E3C596896C8D}.Release-Static|x64.ActiveCfg = Release-Static|x64 - {969D9298-8CEF-14A3-8EEF-E3C596896C8D}.Release-Static|x64.Build.0 = Release-Static|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/deps/w32-pthreads/pthread.vcxproj b/deps/w32-pthreads/pthread.vcxproj deleted file mode 100644 index 8a17fed..0000000 --- a/deps/w32-pthreads/pthread.vcxproj +++ /dev/null @@ -1,514 +0,0 @@ -ļ»æ - - - - Debug-Static - Win32 - - - Debug-Static - x64 - - - Debug - Win32 - - - Debug - x64 - - - Release-Static - Win32 - - - Release-Static - x64 - - - Release - Win32 - - - Release - x64 - - - - - - - - - DynamicLibrary - false - MultiByte - - - DynamicLibrary - false - MultiByte - - - DynamicLibrary - false - MultiByte - - - StaticLibrary - false - MultiByte - - - DynamicLibrary - false - MultiByte - - - DynamicLibrary - false - MultiByte - - - DynamicLibrary - false - MultiByte - - - StaticLibrary - false - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - .\.\ - .\.\ - false - - - .\.\ - .\.\ - false - - - .\.\ - .\.\ - false - - - .\.\ - .\.\ - false - - - .\.\ - .\.\ - true - - - .\.\ - .\.\ - true - - - .\.\ - .\.\ - true - - - .\.\ - .\.\ - true - - - - MultiThreadedDLL - OnlyExplicitInline - true - true - MaxSpeed - true - Level3 - .;%(AdditionalIncludeDirectories) - false - __CLEANUP_C;WIN32;NDEBUG;_WINDOWS;_USRDLL;PTW32_BUILD;%(PreprocessorDefinitions) - .\.\ - .\.\pthread.pch - .\.\ - .\.\ - - - true - NDEBUG;%(PreprocessorDefinitions) - .\.\pthread.tlb - true - Win32 - - - 0x0409 - .;%(AdditionalIncludeDirectories) - NDEBUG;PTW32_RC_MSC;%(PreprocessorDefinitions) - - - true - .\.\pthread.bsc - - - true - true - Console - .\pthreadVC2.dll - .\.\pthreadVC2.lib - ws2_32.lib;%(AdditionalDependencies) - - - - - MultiThreadedDLL - OnlyExplicitInline - true - true - MaxSpeed - true - Level3 - .;%(AdditionalIncludeDirectories) - false - __CLEANUP_C;WIN32;NDEBUG;_WINDOWS;_USRDLL;PTW32_BUILD;%(PreprocessorDefinitions) - .\.\ - .\.\pthread.pch - .\.\ - .\.\ - - - true - NDEBUG;%(PreprocessorDefinitions) - .\.\pthread.tlb - true - Win32 - - - 0x0409 - .;%(AdditionalIncludeDirectories) - NDEBUG;PTW32_RC_MSC;%(PreprocessorDefinitions) - - - true - .\.\pthread.bsc - - - true - true - Console - .\pthreadVC2.dll - .\.\pthreadVC2.lib - ws2_32.lib;%(AdditionalDependencies) - - - - - MultiThreadedDLL - OnlyExplicitInline - true - true - MaxSpeed - true - Level3 - .;%(AdditionalIncludeDirectories) - false - __CLEANUP_C;WIN32;NDEBUG;_WINDOWS;_USRDLL;PTW32_BUILD;%(PreprocessorDefinitions) - .\.\ - .\.\pthread.pch - .\.\ - .\.\ - - - true - NDEBUG;%(PreprocessorDefinitions) - .\.\pthread.tlb - true - - - 0x0409 - .;%(AdditionalIncludeDirectories) - NDEBUG;PTW32_RC_MSC;%(PreprocessorDefinitions) - - - true - .\.\pthread.bsc - - - true - true - Console - .\pthreadVC2.dll - .\.\pthreadVC2.lib - ws2_32.lib;%(AdditionalDependencies) - - - - - MultiThreadedDLL - OnlyExplicitInline - true - true - MaxSpeed - true - Level3 - .;%(AdditionalIncludeDirectories) - false - __CLEANUP_C;WIN32;NDEBUG;_WINDOWS;_USRDLL;PTW32_BUILD;%(PreprocessorDefinitions) - .\.\ - .\.\pthread.pch - .\.\ - .\.\ - - - true - NDEBUG;%(PreprocessorDefinitions) - .\.\pthread.tlb - true - - - 0x0409 - .;%(AdditionalIncludeDirectories) - NDEBUG;PTW32_RC_MSC;%(PreprocessorDefinitions) - - - true - .\.\pthread.bsc - - - true - true - Console - .\pthreadVC2.dll - .\.\pthreadVC2.lib - ws2_32.lib;%(AdditionalDependencies) - - - .\pthreadVC2.lib - - - - - MultiThreadedDebugDLL - Default - false - Disabled - true - Level3 - true - EditAndContinue - .;%(AdditionalIncludeDirectories) - __CLEANUP_C;WIN32;_DEBUG;_WINDOWS;_USRDLL;PTW32_BUILD;%(PreprocessorDefinitions) - .\.\ - .\.\pthread.pch - .\.\ - .\.\ - EnableFastChecks - - - true - _DEBUG;%(PreprocessorDefinitions) - .\.\pthread.tlb - true - Win32 - - - 0x0409 - .;%(AdditionalIncludeDirectories) - _DEBUG;PTW32_RC_MSC;%(PreprocessorDefinitions) - - - true - .\.\pthread.bsc - - - true - true - true - Console - .\pthreadVC2.dll - .\.\pthreadVC2.lib - ws2_32.lib;%(AdditionalDependencies) - - - - - MultiThreadedDebugDLL - Default - false - Disabled - true - Level3 - true - EditAndContinue - .;%(AdditionalIncludeDirectories) - __CLEANUP_C;WIN32;_DEBUG;_WINDOWS;_USRDLL;PTW32_BUILD;%(PreprocessorDefinitions) - .\.\ - .\.\pthread.pch - .\.\ - .\.\ - EnableFastChecks - - - true - _DEBUG;%(PreprocessorDefinitions) - .\.\pthread.tlb - true - Win32 - - - 0x0409 - .;%(AdditionalIncludeDirectories) - _DEBUG;PTW32_RC_MSC;%(PreprocessorDefinitions) - - - true - .\.\pthread.bsc - - - true - true - true - Console - .\pthreadVC2.dll - .\.\pthreadVC2.lib - ws2_32.lib;%(AdditionalDependencies) - - - - - MultiThreadedDebugDLL - Default - false - Disabled - true - Level3 - ProgramDatabase - .;%(AdditionalIncludeDirectories) - __CLEANUP_C;WIN32;_DEBUG;_WINDOWS;_USRDLL;PTW32_BUILD;%(PreprocessorDefinitions) - .\.\ - .\.\pthread.pch - .\.\ - .\.\ - EnableFastChecks - - - true - _DEBUG;%(PreprocessorDefinitions) - .\.\pthread.tlb - true - - - 0x0409 - .;%(AdditionalIncludeDirectories) - _DEBUG;PTW32_RC_MSC;%(PreprocessorDefinitions) - - - true - .\.\pthread.bsc - - - true - true - true - Console - .\pthreadVC2.dll - .\.\pthreadVC2.lib - ws2_32.lib;%(AdditionalDependencies) - - - - - MultiThreadedDebugDLL - Default - false - Disabled - true - Level3 - ProgramDatabase - .;%(AdditionalIncludeDirectories) - __CLEANUP_C;WIN32;_DEBUG;_WINDOWS;_USRDLL;PTW32_BUILD;%(PreprocessorDefinitions) - .\.\ - .\.\pthread.pch - .\.\ - .\.\ - EnableFastChecks - - - true - _DEBUG;%(PreprocessorDefinitions) - .\.\pthread.tlb - true - - - 0x0409 - .;%(AdditionalIncludeDirectories) - _DEBUG;PTW32_RC_MSC;%(PreprocessorDefinitions) - - - true - .\.\pthread.bsc - - - true - true - true - Console - .\pthreadVC2.dll - .\.\pthreadVC2.lib - ws2_32.lib;%(AdditionalDependencies) - - - .\pthreadVC2.lib - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/deps/w32-pthreads/pthread.vcxproj.filters b/deps/w32-pthreads/pthread.vcxproj.filters deleted file mode 100644 index fc5c64a..0000000 --- a/deps/w32-pthreads/pthread.vcxproj.filters +++ /dev/null @@ -1,36 +0,0 @@ -ļ»æ - - - - {ed014216-ffe7-4e4f-b783-9812a5e778d7} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - {a9cc5beb-e838-4849-9cbd-ee1de4bda860} - h;hpp;hxx;hm;inl - - - {636c1d95-8104-45b5-aa12-6e8e3c5ebcee} - ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/deps/w32-pthreads/pthread_attr_destroy.c b/deps/w32-pthreads/pthread_attr_destroy.c deleted file mode 100644 index 1489e4c..0000000 --- a/deps/w32-pthreads/pthread_attr_destroy.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * pthread_attr_destroy.c - * - * Description: - * This translation unit implements operations on thread attribute objects. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_attr_destroy (pthread_attr_t * attr) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * Destroys a thread attributes object. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_attr_t - * - * - * DESCRIPTION - * Destroys a thread attributes object. - * - * NOTES: - * 1) Does not affect threads created with 'attr'. - * - * RESULTS - * 0 successfully destroyed attr, - * EINVAL 'attr' is invalid. - * - * ------------------------------------------------------ - */ -{ - if (ptw32_is_attr (attr) != 0) - { - return EINVAL; - } - - /* - * Set the attribute object to a specific invalid value. - */ - (*attr)->valid = 0; - free (*attr); - *attr = NULL; - - return 0; -} diff --git a/deps/w32-pthreads/pthread_attr_getdetachstate.c b/deps/w32-pthreads/pthread_attr_getdetachstate.c deleted file mode 100644 index e5050ab..0000000 --- a/deps/w32-pthreads/pthread_attr_getdetachstate.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * pthread_attr_getdetachstate.c - * - * Description: - * This translation unit implements operations on thread attribute objects. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_attr_getdetachstate (const pthread_attr_t * attr, int *detachstate) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function determines whether threads created with - * 'attr' will run detached. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_attr_t - * - * detachstate - * pointer to an integer into which is returned one - * of: - * - * PTHREAD_CREATE_JOINABLE - * Thread ID is valid, must be joined - * - * PTHREAD_CREATE_DETACHED - * Thread ID is invalid, cannot be joined, - * canceled, or modified - * - * - * DESCRIPTION - * This function determines whether threads created with - * 'attr' will run detached. - * - * NOTES: - * 1) You cannot join or cancel detached threads. - * - * RESULTS - * 0 successfully retrieved detach state, - * EINVAL 'attr' is invalid - * - * ------------------------------------------------------ - */ -{ - if (ptw32_is_attr (attr) != 0 || detachstate == NULL) - { - return EINVAL; - } - - *detachstate = (*attr)->detachstate; - return 0; -} diff --git a/deps/w32-pthreads/pthread_attr_getinheritsched.c b/deps/w32-pthreads/pthread_attr_getinheritsched.c deleted file mode 100644 index a7d59f6..0000000 --- a/deps/w32-pthreads/pthread_attr_getinheritsched.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * pthread_attr_getinheritsched.c - * - * Description: - * POSIX thread functions that deal with thread scheduling. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" -#include "sched.h" - -int -pthread_attr_getinheritsched (const pthread_attr_t * attr, int *inheritsched) -{ - if (ptw32_is_attr (attr) != 0 || inheritsched == NULL) - { - return EINVAL; - } - - *inheritsched = (*attr)->inheritsched; - return 0; -} diff --git a/deps/w32-pthreads/pthread_attr_getschedparam.c b/deps/w32-pthreads/pthread_attr_getschedparam.c deleted file mode 100644 index 0cecde3..0000000 --- a/deps/w32-pthreads/pthread_attr_getschedparam.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * pthread_attr_getschedparam.c - * - * Description: - * POSIX thread functions that deal with thread scheduling. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" -#include "sched.h" - -int -pthread_attr_getschedparam (const pthread_attr_t * attr, - struct sched_param *param) -{ - if (ptw32_is_attr (attr) != 0 || param == NULL) - { - return EINVAL; - } - - memcpy (param, &(*attr)->param, sizeof (*param)); - return 0; -} diff --git a/deps/w32-pthreads/pthread_attr_getschedpolicy.c b/deps/w32-pthreads/pthread_attr_getschedpolicy.c deleted file mode 100644 index 73c9081..0000000 --- a/deps/w32-pthreads/pthread_attr_getschedpolicy.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * pthread_attr_getschedpolicy.c - * - * Description: - * POSIX thread functions that deal with thread scheduling. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" -#include "sched.h" - -int -pthread_attr_getschedpolicy (const pthread_attr_t * attr, int *policy) -{ - if (ptw32_is_attr (attr) != 0 || policy == NULL) - { - return EINVAL; - } - - /* - * Validate the policy arg. - * Check that a policy constant wasn't passed rather than &policy. - */ - if (policy <= (int *) SCHED_MAX) - { - return EINVAL; - } - - *policy = SCHED_OTHER; - - return 0; -} diff --git a/deps/w32-pthreads/pthread_attr_getscope.c b/deps/w32-pthreads/pthread_attr_getscope.c deleted file mode 100644 index ac644e4..0000000 --- a/deps/w32-pthreads/pthread_attr_getscope.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * pthread_attr_getscope.c - * - * Description: - * This translation unit implements operations on thread attribute objects. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -/* ignore warning "unreferenced formal parameter" */ -#if defined(_MSC_VER) -#pragma warning( disable : 4100 ) -#endif - -int -pthread_attr_getscope (const pthread_attr_t * attr, int *contentionscope) -{ -#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) - *contentionscope = (*attr)->contentionscope; - return 0; -#else - return ENOSYS; -#endif -} diff --git a/deps/w32-pthreads/pthread_attr_getstackaddr.c b/deps/w32-pthreads/pthread_attr_getstackaddr.c deleted file mode 100644 index 15a3f00..0000000 --- a/deps/w32-pthreads/pthread_attr_getstackaddr.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * pthread_attr_getstackaddr.c - * - * Description: - * This translation unit implements operations on thread attribute objects. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -/* ignore warning "unreferenced formal parameter" */ -#if defined(_MSC_VER) -#pragma warning( disable : 4100 ) -#endif - -int -pthread_attr_getstackaddr (const pthread_attr_t * attr, void **stackaddr) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function determines the address of the stack - * on which threads created with 'attr' will run. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_attr_t - * - * stackaddr - * pointer into which is returned the stack address. - * - * - * DESCRIPTION - * This function determines the address of the stack - * on which threads created with 'attr' will run. - * - * NOTES: - * 1) Function supported only if this macro is - * defined: - * - * _POSIX_THREAD_ATTR_STACKADDR - * - * 2) Create only one thread for each stack - * address.. - * - * RESULTS - * 0 successfully retreived stack address, - * EINVAL 'attr' is invalid - * ENOSYS function not supported - * - * ------------------------------------------------------ - */ -{ -#if defined( _POSIX_THREAD_ATTR_STACKADDR ) - - if (ptw32_is_attr (attr) != 0) - { - return EINVAL; - } - - *stackaddr = (*attr)->stackaddr; - return 0; - -#else - - return ENOSYS; - -#endif /* _POSIX_THREAD_ATTR_STACKADDR */ -} diff --git a/deps/w32-pthreads/pthread_attr_getstacksize.c b/deps/w32-pthreads/pthread_attr_getstacksize.c deleted file mode 100644 index 948a12f..0000000 --- a/deps/w32-pthreads/pthread_attr_getstacksize.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * pthread_attr_getstacksize.c - * - * Description: - * This translation unit implements operations on thread attribute objects. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -/* ignore warning "unreferenced formal parameter" */ -#if defined(_MSC_VER) -#pragma warning( disable : 4100 ) -#endif - -int -pthread_attr_getstacksize (const pthread_attr_t * attr, size_t * stacksize) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function determines the size of the stack on - * which threads created with 'attr' will run. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_attr_t - * - * stacksize - * pointer to size_t into which is returned the - * stack size, in bytes. - * - * - * DESCRIPTION - * This function determines the size of the stack on - * which threads created with 'attr' will run. - * - * NOTES: - * 1) Function supported only if this macro is - * defined: - * - * _POSIX_THREAD_ATTR_STACKSIZE - * - * 2) Use on newly created attributes object to - * find the default stack size. - * - * RESULTS - * 0 successfully retrieved stack size, - * EINVAL 'attr' is invalid - * ENOSYS function not supported - * - * ------------------------------------------------------ - */ -{ -#if defined(_POSIX_THREAD_ATTR_STACKSIZE) - - if (ptw32_is_attr (attr) != 0) - { - return EINVAL; - } - - /* Everything is okay. */ - *stacksize = (*attr)->stacksize; - return 0; - -#else - - return ENOSYS; - -#endif /* _POSIX_THREAD_ATTR_STACKSIZE */ - -} diff --git a/deps/w32-pthreads/pthread_attr_init.c b/deps/w32-pthreads/pthread_attr_init.c deleted file mode 100644 index 4eff84f..0000000 --- a/deps/w32-pthreads/pthread_attr_init.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * pthread_attr_init.c - * - * Description: - * This translation unit implements operations on thread attribute objects. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_attr_init (pthread_attr_t * attr) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * Initializes a thread attributes object with default - * attributes. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_attr_t - * - * - * DESCRIPTION - * Initializes a thread attributes object with default - * attributes. - * - * NOTES: - * 1) Used to define thread attributes - * - * RESULTS - * 0 successfully initialized attr, - * ENOMEM insufficient memory for attr. - * - * ------------------------------------------------------ - */ -{ - pthread_attr_t attr_result; - - if (attr == NULL) - { - /* This is disallowed. */ - return EINVAL; - } - - attr_result = (pthread_attr_t) malloc (sizeof (*attr_result)); - - if (attr_result == NULL) - { - return ENOMEM; - } - -#if defined(_POSIX_THREAD_ATTR_STACKSIZE) - /* - * Default to zero size. Unless changed explicitly this - * will allow Win32 to set the size to that of the - * main thread. - */ - attr_result->stacksize = 0; -#endif - -#if defined(_POSIX_THREAD_ATTR_STACKADDR) - /* FIXME: Set this to something sensible when we support it. */ - attr_result->stackaddr = NULL; -#endif - - attr_result->detachstate = PTHREAD_CREATE_JOINABLE; - -#if defined(HAVE_SIGSET_T) - memset (&(attr_result->sigmask), 0, sizeof (sigset_t)); -#endif /* HAVE_SIGSET_T */ - - /* - * Win32 sets new threads to THREAD_PRIORITY_NORMAL and - * not to that of the parent thread. We choose to default to - * this arrangement. - */ - attr_result->param.sched_priority = THREAD_PRIORITY_NORMAL; - attr_result->inheritsched = PTHREAD_EXPLICIT_SCHED; - attr_result->contentionscope = PTHREAD_SCOPE_SYSTEM; - - attr_result->valid = PTW32_ATTR_VALID; - - *attr = attr_result; - - return 0; -} diff --git a/deps/w32-pthreads/pthread_attr_setdetachstate.c b/deps/w32-pthreads/pthread_attr_setdetachstate.c deleted file mode 100644 index c20926a..0000000 --- a/deps/w32-pthreads/pthread_attr_setdetachstate.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * pthread_attr_setdetachstate.c - * - * Description: - * This translation unit implements operations on thread attribute objects. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_attr_setdetachstate (pthread_attr_t * attr, int detachstate) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function specifies whether threads created with - * 'attr' will run detached. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_attr_t - * - * detachstate - * an integer containing one of: - * - * PTHREAD_CREATE_JOINABLE - * Thread ID is valid, must be joined - * - * PTHREAD_CREATE_DETACHED - * Thread ID is invalid, cannot be joined, - * canceled, or modified - * - * - * DESCRIPTION - * This function specifies whether threads created with - * 'attr' will run detached. - * - * NOTES: - * 1) You cannot join or cancel detached threads. - * - * RESULTS - * 0 successfully set detach state, - * EINVAL 'attr' or 'detachstate' is invalid - * - * ------------------------------------------------------ - */ -{ - if (ptw32_is_attr (attr) != 0) - { - return EINVAL; - } - - if (detachstate != PTHREAD_CREATE_JOINABLE && - detachstate != PTHREAD_CREATE_DETACHED) - { - return EINVAL; - } - - (*attr)->detachstate = detachstate; - return 0; -} diff --git a/deps/w32-pthreads/pthread_attr_setinheritsched.c b/deps/w32-pthreads/pthread_attr_setinheritsched.c deleted file mode 100644 index 2f921fc..0000000 --- a/deps/w32-pthreads/pthread_attr_setinheritsched.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * pthread_attr_setinheritsched.c - * - * Description: - * POSIX thread functions that deal with thread scheduling. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" -#include "sched.h" - -int -pthread_attr_setinheritsched (pthread_attr_t * attr, int inheritsched) -{ - if (ptw32_is_attr (attr) != 0) - { - return EINVAL; - } - - if (PTHREAD_INHERIT_SCHED != inheritsched - && PTHREAD_EXPLICIT_SCHED != inheritsched) - { - return EINVAL; - } - - (*attr)->inheritsched = inheritsched; - return 0; -} diff --git a/deps/w32-pthreads/pthread_attr_setschedparam.c b/deps/w32-pthreads/pthread_attr_setschedparam.c deleted file mode 100644 index 969fe7c..0000000 --- a/deps/w32-pthreads/pthread_attr_setschedparam.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * pthread_attr_setschedparam.c - * - * Description: - * POSIX thread functions that deal with thread scheduling. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" -#include "sched.h" - -int -pthread_attr_setschedparam (pthread_attr_t * attr, - const struct sched_param *param) -{ - int priority; - - if (ptw32_is_attr (attr) != 0 || param == NULL) - { - return EINVAL; - } - - priority = param->sched_priority; - - /* Validate priority level. */ - if (priority < sched_get_priority_min (SCHED_OTHER) || - priority > sched_get_priority_max (SCHED_OTHER)) - { - return EINVAL; - } - - memcpy (&(*attr)->param, param, sizeof (*param)); - return 0; -} diff --git a/deps/w32-pthreads/pthread_attr_setschedpolicy.c b/deps/w32-pthreads/pthread_attr_setschedpolicy.c deleted file mode 100644 index d8873ae..0000000 --- a/deps/w32-pthreads/pthread_attr_setschedpolicy.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * pthread_attr_setschedpolicy.c - * - * Description: - * POSIX thread functions that deal with thread scheduling. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" -#include "sched.h" - -int -pthread_attr_setschedpolicy (pthread_attr_t * attr, int policy) -{ - if (ptw32_is_attr (attr) != 0) - { - return EINVAL; - } - - if (policy != SCHED_OTHER) - { - return ENOTSUP; - } - - return 0; -} diff --git a/deps/w32-pthreads/pthread_attr_setscope.c b/deps/w32-pthreads/pthread_attr_setscope.c deleted file mode 100644 index 2cdffe8..0000000 --- a/deps/w32-pthreads/pthread_attr_setscope.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * pthread_attr_setscope.c - * - * Description: - * This translation unit implements operations on thread attribute objects. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -/* ignore warning "unreferenced formal parameter" */ -#if defined(_MSC_VER) -#pragma warning( disable : 4100 ) -#endif - -int -pthread_attr_setscope (pthread_attr_t * attr, int contentionscope) -{ -#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) - switch (contentionscope) - { - case PTHREAD_SCOPE_SYSTEM: - (*attr)->contentionscope = contentionscope; - return 0; - case PTHREAD_SCOPE_PROCESS: - return ENOTSUP; - default: - return EINVAL; - } -#else - return ENOSYS; -#endif -} diff --git a/deps/w32-pthreads/pthread_attr_setstackaddr.c b/deps/w32-pthreads/pthread_attr_setstackaddr.c deleted file mode 100644 index 5eb2b61..0000000 --- a/deps/w32-pthreads/pthread_attr_setstackaddr.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * pthread_attr_setstackaddr.c - * - * Description: - * This translation unit implements operations on thread attribute objects. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_attr_setstackaddr (pthread_attr_t * attr, void *stackaddr) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * Threads created with 'attr' will run on the stack - * starting at 'stackaddr'. - * Stack must be at least PTHREAD_STACK_MIN bytes. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_attr_t - * - * stackaddr - * the address of the stack to use - * - * - * DESCRIPTION - * Threads created with 'attr' will run on the stack - * starting at 'stackaddr'. - * Stack must be at least PTHREAD_STACK_MIN bytes. - * - * NOTES: - * 1) Function supported only if this macro is - * defined: - * - * _POSIX_THREAD_ATTR_STACKADDR - * - * 2) Create only one thread for each stack - * address.. - * - * 3) Ensure that stackaddr is aligned. - * - * RESULTS - * 0 successfully set stack address, - * EINVAL 'attr' is invalid - * ENOSYS function not supported - * - * ------------------------------------------------------ - */ -{ -#if defined( _POSIX_THREAD_ATTR_STACKADDR ) - - if (ptw32_is_attr (attr) != 0) - { - return EINVAL; - } - - (*attr)->stackaddr = stackaddr; - return 0; - -#else - - return ENOSYS; - -#endif /* _POSIX_THREAD_ATTR_STACKADDR */ -} diff --git a/deps/w32-pthreads/pthread_attr_setstacksize.c b/deps/w32-pthreads/pthread_attr_setstacksize.c deleted file mode 100644 index cd8f702..0000000 --- a/deps/w32-pthreads/pthread_attr_setstacksize.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * pthread_attr_setstacksize.c - * - * Description: - * This translation unit implements operations on thread attribute objects. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_attr_setstacksize (pthread_attr_t * attr, size_t stacksize) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function specifies the size of the stack on - * which threads created with 'attr' will run. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_attr_t - * - * stacksize - * stack size, in bytes. - * - * - * DESCRIPTION - * This function specifies the size of the stack on - * which threads created with 'attr' will run. - * - * NOTES: - * 1) Function supported only if this macro is - * defined: - * - * _POSIX_THREAD_ATTR_STACKSIZE - * - * 2) Find the default first (using - * pthread_attr_getstacksize), then increase - * by multiplying. - * - * 3) Only use if thread needs more than the - * default. - * - * RESULTS - * 0 successfully set stack size, - * EINVAL 'attr' is invalid or stacksize too - * small or too big. - * ENOSYS function not supported - * - * ------------------------------------------------------ - */ -{ -#if defined(_POSIX_THREAD_ATTR_STACKSIZE) - -#if PTHREAD_STACK_MIN > 0 - - /* Verify that the stack size is within range. */ - if (stacksize < PTHREAD_STACK_MIN) - { - return EINVAL; - } - -#endif - - if (ptw32_is_attr (attr) != 0) - { - return EINVAL; - } - - /* Everything is okay. */ - (*attr)->stacksize = stacksize; - return 0; - -#else - - return ENOSYS; - -#endif /* _POSIX_THREAD_ATTR_STACKSIZE */ - -} diff --git a/deps/w32-pthreads/pthread_barrier_destroy.c b/deps/w32-pthreads/pthread_barrier_destroy.c deleted file mode 100644 index 48e2423..0000000 --- a/deps/w32-pthreads/pthread_barrier_destroy.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * pthread_barrier_destroy.c - * - * Description: - * This translation unit implements barrier primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -int -pthread_barrier_destroy (pthread_barrier_t * barrier) -{ - int result = 0; - pthread_barrier_t b; - ptw32_mcs_local_node_t node; - - if (barrier == NULL || *barrier == (pthread_barrier_t) PTW32_OBJECT_INVALID) - { - return EINVAL; - } - - if (0 != ptw32_mcs_lock_try_acquire(&(*barrier)->lock, &node)) - { - return EBUSY; - } - - b = *barrier; - - if (b->nCurrentBarrierHeight < b->nInitialBarrierHeight) - { - result = EBUSY; - } - else - { - if (0 == (result = sem_destroy (&(b->semBarrierBreeched)))) - { - *barrier = (pthread_barrier_t) PTW32_OBJECT_INVALID; - /* - * Release the lock before freeing b. - * - * FIXME: There may be successors which, when we release the lock, - * will be linked into b->lock, which will be corrupted at some - * point with undefined results for the application. To fix this - * will require changing pthread_barrier_t from a pointer to - * pthread_barrier_t_ to an instance. This is a change to the ABI - * and will require a major version number increment. - */ - ptw32_mcs_lock_release(&node); - (void) free (b); - return 0; - } - else - { - /* - * This should not ever be reached. - * Restore the barrier to working condition before returning. - */ - (void) sem_init (&(b->semBarrierBreeched), b->pshared, 0); - } - - if (result != 0) - { - /* - * The barrier still exists and is valid - * in the event of any error above. - */ - result = EBUSY; - } - } - - ptw32_mcs_lock_release(&node); - return (result); -} diff --git a/deps/w32-pthreads/pthread_barrier_init.c b/deps/w32-pthreads/pthread_barrier_init.c deleted file mode 100644 index 8bb9894..0000000 --- a/deps/w32-pthreads/pthread_barrier_init.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * pthread_barrier_init.c - * - * Description: - * This translation unit implements barrier primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_barrier_init (pthread_barrier_t * barrier, - const pthread_barrierattr_t * attr, unsigned int count) -{ - pthread_barrier_t b; - - if (barrier == NULL || count == 0) - { - return EINVAL; - } - - if (NULL != (b = (pthread_barrier_t) calloc (1, sizeof (*b)))) - { - b->pshared = (attr != NULL && *attr != NULL - ? (*attr)->pshared : PTHREAD_PROCESS_PRIVATE); - - b->nCurrentBarrierHeight = b->nInitialBarrierHeight = count; - b->lock = 0; - - if (0 == sem_init (&(b->semBarrierBreeched), b->pshared, 0)) - { - *barrier = b; - return 0; - } - (void) free (b); - } - - return ENOMEM; -} diff --git a/deps/w32-pthreads/pthread_barrier_wait.c b/deps/w32-pthreads/pthread_barrier_wait.c deleted file mode 100644 index 9fe987e..0000000 --- a/deps/w32-pthreads/pthread_barrier_wait.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * pthread_barrier_wait.c - * - * Description: - * This translation unit implements barrier primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_barrier_wait (pthread_barrier_t * barrier) -{ - int result; - pthread_barrier_t b; - - ptw32_mcs_local_node_t node; - - if (barrier == NULL || *barrier == (pthread_barrier_t) PTW32_OBJECT_INVALID) - { - return EINVAL; - } - - ptw32_mcs_lock_acquire(&(*barrier)->lock, &node); - - b = *barrier; - if (--b->nCurrentBarrierHeight == 0) - { - /* - * We are the last thread to arrive at the barrier before it releases us. - * Move our MCS local node to the global scope barrier handle so that the - * last thread out (not necessarily us) can release the lock. - */ - ptw32_mcs_node_transfer(&b->proxynode, &node); - - /* - * Any threads that have not quite entered sem_wait below when the - * multiple_post has completed will nevertheless continue through - * the semaphore (barrier). - */ - result = (b->nInitialBarrierHeight > 1 - ? sem_post_multiple (&(b->semBarrierBreeched), - b->nInitialBarrierHeight - 1) : 0); - } - else - { - ptw32_mcs_lock_release(&node); - /* - * Use the non-cancelable version of sem_wait(). - * - * It is possible that all nInitialBarrierHeight-1 threads are - * at this point when the last thread enters the barrier, resets - * nCurrentBarrierHeight = nInitialBarrierHeight and leaves. - * If pthread_barrier_destroy is called at that moment then the - * barrier will be destroyed along with the semas. - */ - result = ptw32_semwait (&(b->semBarrierBreeched)); - } - - if ((PTW32_INTERLOCKED_LONG)PTW32_INTERLOCKED_INCREMENT_LONG((PTW32_INTERLOCKED_LONGPTR)&b->nCurrentBarrierHeight) - == (PTW32_INTERLOCKED_LONG)b->nInitialBarrierHeight) - { - /* - * We are the last thread to cross this barrier - */ - ptw32_mcs_lock_release(&b->proxynode); - if (0 == result) - { - result = PTHREAD_BARRIER_SERIAL_THREAD; - } - } - - return (result); -} diff --git a/deps/w32-pthreads/pthread_barrierattr_destroy.c b/deps/w32-pthreads/pthread_barrierattr_destroy.c deleted file mode 100644 index 59853db..0000000 --- a/deps/w32-pthreads/pthread_barrierattr_destroy.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * pthread_barrier_attr_destroy.c - * - * Description: - * This translation unit implements barrier primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_barrierattr_destroy (pthread_barrierattr_t * attr) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * Destroys a barrier attributes object. The object can - * no longer be used. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_barrierattr_t - * - * - * DESCRIPTION - * Destroys a barrier attributes object. The object can - * no longer be used. - * - * NOTES: - * 1) Does not affect barrieres created using 'attr' - * - * RESULTS - * 0 successfully released attr, - * EINVAL 'attr' is invalid. - * - * ------------------------------------------------------ - */ -{ - int result = 0; - - if (attr == NULL || *attr == NULL) - { - result = EINVAL; - } - else - { - pthread_barrierattr_t ba = *attr; - - *attr = NULL; - free (ba); - } - - return (result); -} /* pthread_barrierattr_destroy */ diff --git a/deps/w32-pthreads/pthread_barrierattr_getpshared.c b/deps/w32-pthreads/pthread_barrierattr_getpshared.c deleted file mode 100644 index e2529da..0000000 --- a/deps/w32-pthreads/pthread_barrierattr_getpshared.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * pthread_barrier_attr_getpshared.c - * - * Description: - * This translation unit implements barrier primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_barrierattr_getpshared (const pthread_barrierattr_t * attr, - int *pshared) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * Determine whether barriers created with 'attr' can be - * shared between processes. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_barrierattr_t - * - * pshared - * will be set to one of: - * - * PTHREAD_PROCESS_SHARED - * May be shared if in shared memory - * - * PTHREAD_PROCESS_PRIVATE - * Cannot be shared. - * - * - * DESCRIPTION - * Mutexes creatd with 'attr' can be shared between - * processes if pthread_barrier_t variable is allocated - * in memory shared by these processes. - * NOTES: - * 1) pshared barriers MUST be allocated in shared - * memory. - * 2) The following macro is defined if shared barriers - * are supported: - * _POSIX_THREAD_PROCESS_SHARED - * - * RESULTS - * 0 successfully retrieved attribute, - * EINVAL 'attr' is invalid, - * - * ------------------------------------------------------ - */ -{ - int result; - - if ((attr != NULL && *attr != NULL) && (pshared != NULL)) - { - *pshared = (*attr)->pshared; - result = 0; - } - else - { - result = EINVAL; - } - - return (result); -} /* pthread_barrierattr_getpshared */ diff --git a/deps/w32-pthreads/pthread_barrierattr_init.c b/deps/w32-pthreads/pthread_barrierattr_init.c deleted file mode 100644 index 7e7b13e..0000000 --- a/deps/w32-pthreads/pthread_barrierattr_init.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * pthread_barrier_attr_init.c - * - * Description: - * This translation unit implements barrier primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_barrierattr_init (pthread_barrierattr_t * attr) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * Initializes a barrier attributes object with default - * attributes. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_barrierattr_t - * - * - * DESCRIPTION - * Initializes a barrier attributes object with default - * attributes. - * - * NOTES: - * 1) Used to define barrier types - * - * RESULTS - * 0 successfully initialized attr, - * ENOMEM insufficient memory for attr. - * - * ------------------------------------------------------ - */ -{ - pthread_barrierattr_t ba; - int result = 0; - - ba = (pthread_barrierattr_t) calloc (1, sizeof (*ba)); - - if (ba == NULL) - { - result = ENOMEM; - } - else - { - ba->pshared = PTHREAD_PROCESS_PRIVATE; - } - - *attr = ba; - - return (result); -} /* pthread_barrierattr_init */ diff --git a/deps/w32-pthreads/pthread_barrierattr_setpshared.c b/deps/w32-pthreads/pthread_barrierattr_setpshared.c deleted file mode 100644 index 2612c07..0000000 --- a/deps/w32-pthreads/pthread_barrierattr_setpshared.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * pthread_barrier_attr_setpshared.c - * - * Description: - * This translation unit implements barrier primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_barrierattr_setpshared (pthread_barrierattr_t * attr, int pshared) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * Barriers created with 'attr' can be shared between - * processes if pthread_barrier_t variable is allocated - * in memory shared by these processes. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_barrierattr_t - * - * pshared - * must be one of: - * - * PTHREAD_PROCESS_SHARED - * May be shared if in shared memory - * - * PTHREAD_PROCESS_PRIVATE - * Cannot be shared. - * - * DESCRIPTION - * Mutexes creatd with 'attr' can be shared between - * processes if pthread_barrier_t variable is allocated - * in memory shared by these processes. - * - * NOTES: - * 1) pshared barriers MUST be allocated in shared - * memory. - * - * 2) The following macro is defined if shared barriers - * are supported: - * _POSIX_THREAD_PROCESS_SHARED - * - * RESULTS - * 0 successfully set attribute, - * EINVAL 'attr' or pshared is invalid, - * ENOSYS PTHREAD_PROCESS_SHARED not supported, - * - * ------------------------------------------------------ - */ -{ - int result; - - if ((attr != NULL && *attr != NULL) && - ((pshared == PTHREAD_PROCESS_SHARED) || - (pshared == PTHREAD_PROCESS_PRIVATE))) - { - if (pshared == PTHREAD_PROCESS_SHARED) - { - -#if !defined( _POSIX_THREAD_PROCESS_SHARED ) - - result = ENOSYS; - pshared = PTHREAD_PROCESS_PRIVATE; - -#else - - result = 0; - -#endif /* _POSIX_THREAD_PROCESS_SHARED */ - - } - else - { - result = 0; - } - - (*attr)->pshared = pshared; - } - else - { - result = EINVAL; - } - - return (result); - -} /* pthread_barrierattr_setpshared */ diff --git a/deps/w32-pthreads/pthread_cancel.c b/deps/w32-pthreads/pthread_cancel.c deleted file mode 100644 index 4af0c6e..0000000 --- a/deps/w32-pthreads/pthread_cancel.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * pthread_cancel.c - * - * Description: - * POSIX thread functions related to thread cancellation. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" -#include "context.h" - -static void -ptw32_cancel_self (void) -{ - ptw32_throw (PTW32_EPS_CANCEL); - - /* Never reached */ -} - -static void CALLBACK -ptw32_cancel_callback (ULONG_PTR unused) -{ - ptw32_throw (PTW32_EPS_CANCEL); - - /* Never reached */ -} - -/* - * ptw32_RegisterCancelation() - - * Must have args of same type as QueueUserAPCEx because this function - * is a substitute for QueueUserAPCEx if it's not available. - */ -DWORD -ptw32_RegisterCancelation (PAPCFUNC unused1, HANDLE threadH, DWORD unused2) -{ - CONTEXT context; - - context.ContextFlags = CONTEXT_CONTROL; - GetThreadContext (threadH, &context); - PTW32_PROGCTR (context) = (DWORD_PTR) ptw32_cancel_self; - SetThreadContext (threadH, &context); - return 0; -} - -int -pthread_cancel (pthread_t thread) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function requests cancellation of 'thread'. - * - * PARAMETERS - * thread - * reference to an instance of pthread_t - * - * - * DESCRIPTION - * This function requests cancellation of 'thread'. - * NOTE: cancellation is asynchronous; use pthread_join to - * wait for termination of 'thread' if necessary. - * - * RESULTS - * 0 successfully requested cancellation, - * ESRCH no thread found corresponding to 'thread', - * ENOMEM implicit self thread create failed. - * ------------------------------------------------------ - */ -{ - int result; - int cancel_self; - pthread_t self; - ptw32_thread_t * tp; - ptw32_mcs_local_node_t stateLock; - - result = pthread_kill (thread, 0); - - if (0 != result) - { - return result; - } - - if ((self = pthread_self ()).p == NULL) - { - return ENOMEM; - }; - - /* - * For self cancellation we need to ensure that a thread can't - * deadlock itself trying to cancel itself asynchronously - * (pthread_cancel is required to be an async-cancel - * safe function). - */ - cancel_self = pthread_equal (thread, self); - - tp = (ptw32_thread_t *) thread.p; - - /* - * Lock for async-cancel safety. - */ - ptw32_mcs_lock_acquire (&tp->stateLock, &stateLock); - - if (tp->cancelType == PTHREAD_CANCEL_ASYNCHRONOUS - && tp->cancelState == PTHREAD_CANCEL_ENABLE - && tp->state < PThreadStateCanceling) - { - if (cancel_self) - { - tp->state = PThreadStateCanceling; - tp->cancelState = PTHREAD_CANCEL_DISABLE; - - ptw32_mcs_lock_release (&stateLock); - ptw32_throw (PTW32_EPS_CANCEL); - - /* Never reached */ - } - else - { - HANDLE threadH = tp->threadH; - - SuspendThread (threadH); - - if (WaitForSingleObject (threadH, 0) == WAIT_TIMEOUT) - { - tp->state = PThreadStateCanceling; - tp->cancelState = PTHREAD_CANCEL_DISABLE; - /* - * If alertdrv and QueueUserAPCEx is available then the following - * will result in a call to QueueUserAPCEx with the args given, otherwise - * this will result in a call to ptw32_RegisterCancelation and only - * the threadH arg will be used. - */ - ptw32_register_cancelation ((PAPCFUNC)ptw32_cancel_callback, threadH, 0); - ptw32_mcs_lock_release (&stateLock); - ResumeThread (threadH); - } - } - } - else - { - /* - * Set for deferred cancellation. - */ - if (tp->state < PThreadStateCancelPending) - { - tp->state = PThreadStateCancelPending; - if (!SetEvent (tp->cancelEvent)) - { - result = ESRCH; - } - } - else if (tp->state >= PThreadStateCanceling) - { - result = ESRCH; - } - - ptw32_mcs_lock_release (&stateLock); - } - - return (result); -} diff --git a/deps/w32-pthreads/pthread_cond_destroy.c b/deps/w32-pthreads/pthread_cond_destroy.c deleted file mode 100644 index d960172..0000000 --- a/deps/w32-pthreads/pthread_cond_destroy.c +++ /dev/null @@ -1,253 +0,0 @@ -/* - * pthread_cond_destroy.c - * - * Description: - * This translation unit implements condition variables and their primitives. - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -int -pthread_cond_destroy (pthread_cond_t * cond) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function destroys a condition variable - * - * - * PARAMETERS - * cond - * pointer to an instance of pthread_cond_t - * - * - * DESCRIPTION - * This function destroys a condition variable. - * - * NOTES: - * 1) A condition variable can be destroyed - * immediately after all the threads that - * are blocked on it are awakened. e.g. - * - * struct list { - * pthread_mutex_t lm; - * ... - * } - * - * struct elt { - * key k; - * int busy; - * pthread_cond_t notbusy; - * ... - * } - * - * - * struct elt * - * list_find(struct list *lp, key k) - * { - * struct elt *ep; - * - * pthread_mutex_lock(&lp->lm); - * while ((ep = find_elt(l,k) != NULL) && ep->busy) - * pthread_cond_wait(&ep->notbusy, &lp->lm); - * if (ep != NULL) - * ep->busy = 1; - * pthread_mutex_unlock(&lp->lm); - * return(ep); - * } - * - * delete_elt(struct list *lp, struct elt *ep) - * { - * pthread_mutex_lock(&lp->lm); - * assert(ep->busy); - * ... remove ep from list ... - * ep->busy = 0; - * (A) pthread_cond_broadcast(&ep->notbusy); - * pthread_mutex_unlock(&lp->lm); - * (B) pthread_cond_destroy(&rp->notbusy); - * free(ep); - * } - * - * In this example, the condition variable - * and its list element may be freed (line B) - * immediately after all threads waiting for - * it are awakened (line A), since the mutex - * and the code ensure that no other thread - * can touch the element to be deleted. - * - * RESULTS - * 0 successfully released condition variable, - * EINVAL 'cond' is invalid, - * EBUSY 'cond' is in use, - * - * ------------------------------------------------------ - */ -{ - pthread_cond_t cv; - int result = 0, result1 = 0, result2 = 0; - - /* - * Assuming any race condition here is harmless. - */ - if (cond == NULL || *cond == NULL) - { - return EINVAL; - } - - if (*cond != PTHREAD_COND_INITIALIZER) - { - ptw32_mcs_local_node_t node; - ptw32_mcs_lock_acquire(&ptw32_cond_list_lock, &node); - - cv = *cond; - - /* - * Close the gate; this will synchronize this thread with - * all already signaled waiters to let them retract their - * waiter status - SEE NOTE 1 ABOVE!!! - */ - if (ptw32_semwait (&(cv->semBlockLock)) != 0) /* Non-cancelable */ - { - result = errno; - } - else - { - /* - * !TRY! lock mtxUnblockLock; try will detect busy condition - * and will not cause a deadlock with respect to concurrent - * signal/broadcast. - */ - if ((result = pthread_mutex_trylock (&(cv->mtxUnblockLock))) != 0) - { - (void) sem_post (&(cv->semBlockLock)); - } - } - - if (result != 0) - { - ptw32_mcs_lock_release(&node); - return result; - } - - /* - * Check whether cv is still busy (still has waiters) - */ - if (cv->nWaitersBlocked > cv->nWaitersGone) - { - if (sem_post (&(cv->semBlockLock)) != 0) - { - result = errno; - } - result1 = pthread_mutex_unlock (&(cv->mtxUnblockLock)); - result2 = EBUSY; - } - else - { - /* - * Now it is safe to destroy - */ - *cond = NULL; - - if (sem_destroy (&(cv->semBlockLock)) != 0) - { - result = errno; - } - if (sem_destroy (&(cv->semBlockQueue)) != 0) - { - result1 = errno; - } - if ((result2 = pthread_mutex_unlock (&(cv->mtxUnblockLock))) == 0) - { - result2 = pthread_mutex_destroy (&(cv->mtxUnblockLock)); - } - - /* Unlink the CV from the list */ - - if (ptw32_cond_list_head == cv) - { - ptw32_cond_list_head = cv->next; - } - else - { - cv->prev->next = cv->next; - } - - if (ptw32_cond_list_tail == cv) - { - ptw32_cond_list_tail = cv->prev; - } - else - { - cv->next->prev = cv->prev; - } - - (void) free (cv); - } - - ptw32_mcs_lock_release(&node); - } - else - { - ptw32_mcs_local_node_t node; - /* - * See notes in ptw32_cond_check_need_init() above also. - */ - ptw32_mcs_lock_acquire(&ptw32_cond_test_init_lock, &node); - - /* - * Check again. - */ - if (*cond == PTHREAD_COND_INITIALIZER) - { - /* - * This is all we need to do to destroy a statically - * initialised cond that has not yet been used (initialised). - * If we get to here, another thread waiting to initialise - * this cond will get an EINVAL. That's OK. - */ - *cond = NULL; - } - else - { - /* - * The cv has been initialised while we were waiting - * so assume it's in use. - */ - result = EBUSY; - } - - ptw32_mcs_lock_release(&node); - } - - return ((result != 0) ? result : ((result1 != 0) ? result1 : result2)); -} diff --git a/deps/w32-pthreads/pthread_cond_init.c b/deps/w32-pthreads/pthread_cond_init.c deleted file mode 100644 index c2d2526..0000000 --- a/deps/w32-pthreads/pthread_cond_init.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * pthread_cond_init.c - * - * Description: - * This translation unit implements condition variables and their primitives. - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_cond_init (pthread_cond_t * cond, const pthread_condattr_t * attr) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function initializes a condition variable. - * - * PARAMETERS - * cond - * pointer to an instance of pthread_cond_t - * - * attr - * specifies optional creation attributes. - * - * - * DESCRIPTION - * This function initializes a condition variable. - * - * RESULTS - * 0 successfully created condition variable, - * EINVAL 'attr' is invalid, - * EAGAIN insufficient resources (other than - * memory, - * ENOMEM insufficient memory, - * EBUSY 'cond' is already initialized, - * - * ------------------------------------------------------ - */ -{ - int result; - pthread_cond_t cv = NULL; - - if (cond == NULL) - { - return EINVAL; - } - - if ((attr != NULL && *attr != NULL) && - ((*attr)->pshared == PTHREAD_PROCESS_SHARED)) - { - /* - * Creating condition variable that can be shared between - * processes. - */ - result = ENOSYS; - goto DONE; - } - - cv = (pthread_cond_t) calloc (1, sizeof (*cv)); - - if (cv == NULL) - { - result = ENOMEM; - goto DONE; - } - - cv->nWaitersBlocked = 0; - cv->nWaitersToUnblock = 0; - cv->nWaitersGone = 0; - - if (sem_init (&(cv->semBlockLock), 0, 1) != 0) - { - result = errno; - goto FAIL0; - } - - if (sem_init (&(cv->semBlockQueue), 0, 0) != 0) - { - result = errno; - goto FAIL1; - } - - if ((result = pthread_mutex_init (&(cv->mtxUnblockLock), 0)) != 0) - { - goto FAIL2; - } - - result = 0; - - goto DONE; - - /* - * ------------- - * Failed... - * ------------- - */ -FAIL2: - (void) sem_destroy (&(cv->semBlockQueue)); - -FAIL1: - (void) sem_destroy (&(cv->semBlockLock)); - -FAIL0: - (void) free (cv); - cv = NULL; - -DONE: - if (0 == result) - { - ptw32_mcs_local_node_t node; - - ptw32_mcs_lock_acquire(&ptw32_cond_list_lock, &node); - - cv->next = NULL; - cv->prev = ptw32_cond_list_tail; - - if (ptw32_cond_list_tail != NULL) - { - ptw32_cond_list_tail->next = cv; - } - - ptw32_cond_list_tail = cv; - - if (ptw32_cond_list_head == NULL) - { - ptw32_cond_list_head = cv; - } - - ptw32_mcs_lock_release(&node); - } - - *cond = cv; - - return result; - -} /* pthread_cond_init */ diff --git a/deps/w32-pthreads/pthread_cond_signal.c b/deps/w32-pthreads/pthread_cond_signal.c deleted file mode 100644 index f3d384a..0000000 --- a/deps/w32-pthreads/pthread_cond_signal.c +++ /dev/null @@ -1,231 +0,0 @@ -/* - * pthread_cond_signal.c - * - * Description: - * This translation unit implements condition variables and their primitives. - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * ------------------------------------------------------------- - * Algorithm: - * See the comments at the top of pthread_cond_wait.c. - */ - -#include "pthread.h" -#include "implement.h" - -static INLINE int -ptw32_cond_unblock (pthread_cond_t * cond, int unblockAll) - /* - * Notes. - * - * Does not use the external mutex for synchronisation, - * therefore semBlockLock is needed. - * mtxUnblockLock is for LEVEL-2 synch. LEVEL-2 is the - * state where the external mutex is not necessarily locked by - * any thread, ie. between cond_wait unlocking and re-acquiring - * the lock after having been signaled or a timeout or - * cancellation. - * - * Uses the following CV elements: - * nWaitersBlocked - * nWaitersToUnblock - * nWaitersGone - * mtxUnblockLock - * semBlockLock - * semBlockQueue - */ -{ - int result; - pthread_cond_t cv; - int nSignalsToIssue; - - if (cond == NULL || *cond == NULL) - { - return EINVAL; - } - - cv = *cond; - - /* - * No-op if the CV is static and hasn't been initialised yet. - * Assuming that any race condition is harmless. - */ - if (cv == PTHREAD_COND_INITIALIZER) - { - return 0; - } - - if ((result = pthread_mutex_lock (&(cv->mtxUnblockLock))) != 0) - { - return result; - } - - if (0 != cv->nWaitersToUnblock) - { - if (0 == cv->nWaitersBlocked) - { - return pthread_mutex_unlock (&(cv->mtxUnblockLock)); - } - if (unblockAll) - { - cv->nWaitersToUnblock += (nSignalsToIssue = cv->nWaitersBlocked); - cv->nWaitersBlocked = 0; - } - else - { - nSignalsToIssue = 1; - cv->nWaitersToUnblock++; - cv->nWaitersBlocked--; - } - } - else if (cv->nWaitersBlocked > cv->nWaitersGone) - { - /* Use the non-cancellable version of sem_wait() */ - if (ptw32_semwait (&(cv->semBlockLock)) != 0) - { - result = errno; - (void) pthread_mutex_unlock (&(cv->mtxUnblockLock)); - return result; - } - if (0 != cv->nWaitersGone) - { - cv->nWaitersBlocked -= cv->nWaitersGone; - cv->nWaitersGone = 0; - } - if (unblockAll) - { - nSignalsToIssue = cv->nWaitersToUnblock = cv->nWaitersBlocked; - cv->nWaitersBlocked = 0; - } - else - { - nSignalsToIssue = cv->nWaitersToUnblock = 1; - cv->nWaitersBlocked--; - } - } - else - { - return pthread_mutex_unlock (&(cv->mtxUnblockLock)); - } - - if ((result = pthread_mutex_unlock (&(cv->mtxUnblockLock))) == 0) - { - if (sem_post_multiple (&(cv->semBlockQueue), nSignalsToIssue) != 0) - { - result = errno; - } - } - - return result; - -} /* ptw32_cond_unblock */ - -int -pthread_cond_signal (pthread_cond_t * cond) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function signals a condition variable, waking - * one waiting thread. - * If SCHED_FIFO or SCHED_RR policy threads are waiting - * the highest priority waiter is awakened; otherwise, - * an unspecified waiter is awakened. - * - * PARAMETERS - * cond - * pointer to an instance of pthread_cond_t - * - * - * DESCRIPTION - * This function signals a condition variable, waking - * one waiting thread. - * If SCHED_FIFO or SCHED_RR policy threads are waiting - * the highest priority waiter is awakened; otherwise, - * an unspecified waiter is awakened. - * - * NOTES: - * - * 1) Use when any waiter can respond and only one need - * respond (all waiters being equal). - * - * RESULTS - * 0 successfully signaled condition, - * EINVAL 'cond' is invalid, - * - * ------------------------------------------------------ - */ -{ - /* - * The '0'(FALSE) unblockAll arg means unblock ONE waiter. - */ - return (ptw32_cond_unblock (cond, 0)); - -} /* pthread_cond_signal */ - -int -pthread_cond_broadcast (pthread_cond_t * cond) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function broadcasts the condition variable, - * waking all current waiters. - * - * PARAMETERS - * cond - * pointer to an instance of pthread_cond_t - * - * - * DESCRIPTION - * This function signals a condition variable, waking - * all waiting threads. - * - * NOTES: - * - * 1) Use when more than one waiter may respond to - * predicate change or if any waiting thread may - * not be able to respond - * - * RESULTS - * 0 successfully signalled condition to all - * waiting threads, - * EINVAL 'cond' is invalid - * ENOSPC a required resource has been exhausted, - * - * ------------------------------------------------------ - */ -{ - /* - * The TRUE unblockAll arg means unblock ALL waiters. - */ - return (ptw32_cond_unblock (cond, PTW32_TRUE)); - -} /* pthread_cond_broadcast */ diff --git a/deps/w32-pthreads/pthread_cond_wait.c b/deps/w32-pthreads/pthread_cond_wait.c deleted file mode 100644 index 8248407..0000000 --- a/deps/w32-pthreads/pthread_cond_wait.c +++ /dev/null @@ -1,567 +0,0 @@ -/* - * pthread_cond_wait.c - * - * Description: - * This translation unit implements condition variables and their primitives. - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * ------------------------------------------------------------- - * Algorithm: - * The algorithm used in this implementation is that developed by - * Alexander Terekhov in colaboration with Louis Thomas. The bulk - * of the discussion is recorded in the file README.CV, which contains - * several generations of both colaborators original algorithms. The final - * algorithm used here is the one referred to as - * - * Algorithm 8a / IMPL_SEM,UNBLOCK_STRATEGY == UNBLOCK_ALL - * - * presented below in pseudo-code as it appeared: - * - * - * given: - * semBlockLock - bin.semaphore - * semBlockQueue - semaphore - * mtxExternal - mutex or CS - * mtxUnblockLock - mutex or CS - * nWaitersGone - int - * nWaitersBlocked - int - * nWaitersToUnblock - int - * - * wait( timeout ) { - * - * [auto: register int result ] // error checking omitted - * [auto: register int nSignalsWasLeft ] - * [auto: register int nWaitersWasGone ] - * - * sem_wait( semBlockLock ); - * nWaitersBlocked++; - * sem_post( semBlockLock ); - * - * unlock( mtxExternal ); - * bTimedOut = sem_wait( semBlockQueue,timeout ); - * - * lock( mtxUnblockLock ); - * if ( 0 != (nSignalsWasLeft = nWaitersToUnblock) ) { - * if ( bTimeout ) { // timeout (or canceled) - * if ( 0 != nWaitersBlocked ) { - * nWaitersBlocked--; - * } - * else { - * nWaitersGone++; // count spurious wakeups. - * } - * } - * if ( 0 == --nWaitersToUnblock ) { - * if ( 0 != nWaitersBlocked ) { - * sem_post( semBlockLock ); // open the gate. - * nSignalsWasLeft = 0; // do not open the gate - * // below again. - * } - * else if ( 0 != (nWaitersWasGone = nWaitersGone) ) { - * nWaitersGone = 0; - * } - * } - * } - * else if ( INT_MAX/2 == ++nWaitersGone ) { // timeout/canceled or - * // spurious semaphore :-) - * sem_wait( semBlockLock ); - * nWaitersBlocked -= nWaitersGone; // something is going on here - * // - test of timeouts? :-) - * sem_post( semBlockLock ); - * nWaitersGone = 0; - * } - * unlock( mtxUnblockLock ); - * - * if ( 1 == nSignalsWasLeft ) { - * if ( 0 != nWaitersWasGone ) { - * // sem_adjust( semBlockQueue,-nWaitersWasGone ); - * while ( nWaitersWasGone-- ) { - * sem_wait( semBlockQueue ); // better now than spurious later - * } - * } sem_post( semBlockLock ); // open the gate - * } - * - * lock( mtxExternal ); - * - * return ( bTimedOut ) ? ETIMEOUT : 0; - * } - * - * signal(bAll) { - * - * [auto: register int result ] - * [auto: register int nSignalsToIssue] - * - * lock( mtxUnblockLock ); - * - * if ( 0 != nWaitersToUnblock ) { // the gate is closed!!! - * if ( 0 == nWaitersBlocked ) { // NO-OP - * return unlock( mtxUnblockLock ); - * } - * if (bAll) { - * nWaitersToUnblock += nSignalsToIssue=nWaitersBlocked; - * nWaitersBlocked = 0; - * } - * else { - * nSignalsToIssue = 1; - * nWaitersToUnblock++; - * nWaitersBlocked--; - * } - * } - * else if ( nWaitersBlocked > nWaitersGone ) { // HARMLESS RACE CONDITION! - * sem_wait( semBlockLock ); // close the gate - * if ( 0 != nWaitersGone ) { - * nWaitersBlocked -= nWaitersGone; - * nWaitersGone = 0; - * } - * if (bAll) { - * nSignalsToIssue = nWaitersToUnblock = nWaitersBlocked; - * nWaitersBlocked = 0; - * } - * else { - * nSignalsToIssue = nWaitersToUnblock = 1; - * nWaitersBlocked--; - * } - * } - * else { // NO-OP - * return unlock( mtxUnblockLock ); - * } - * - * unlock( mtxUnblockLock ); - * sem_post( semBlockQueue,nSignalsToIssue ); - * return result; - * } - * ------------------------------------------------------------- - * - * Algorithm 9 / IMPL_SEM,UNBLOCK_STRATEGY == UNBLOCK_ALL - * - * presented below in pseudo-code; basically 8a... - * ...BUT W/O "spurious wakes" prevention: - * - * - * given: - * semBlockLock - bin.semaphore - * semBlockQueue - semaphore - * mtxExternal - mutex or CS - * mtxUnblockLock - mutex or CS - * nWaitersGone - int - * nWaitersBlocked - int - * nWaitersToUnblock - int - * - * wait( timeout ) { - * - * [auto: register int result ] // error checking omitted - * [auto: register int nSignalsWasLeft ] - * - * sem_wait( semBlockLock ); - * ++nWaitersBlocked; - * sem_post( semBlockLock ); - * - * unlock( mtxExternal ); - * bTimedOut = sem_wait( semBlockQueue,timeout ); - * - * lock( mtxUnblockLock ); - * if ( 0 != (nSignalsWasLeft = nWaitersToUnblock) ) { - * --nWaitersToUnblock; - * } - * else if ( INT_MAX/2 == ++nWaitersGone ) { // timeout/canceled or - * // spurious semaphore :-) - * sem_wait( semBlockLock ); - * nWaitersBlocked -= nWaitersGone; // something is going on here - * // - test of timeouts? :-) - * sem_post( semBlockLock ); - * nWaitersGone = 0; - * } - * unlock( mtxUnblockLock ); - * - * if ( 1 == nSignalsWasLeft ) { - * sem_post( semBlockLock ); // open the gate - * } - * - * lock( mtxExternal ); - * - * return ( bTimedOut ) ? ETIMEOUT : 0; - * } - * - * signal(bAll) { - * - * [auto: register int result ] - * [auto: register int nSignalsToIssue] - * - * lock( mtxUnblockLock ); - * - * if ( 0 != nWaitersToUnblock ) { // the gate is closed!!! - * if ( 0 == nWaitersBlocked ) { // NO-OP - * return unlock( mtxUnblockLock ); - * } - * if (bAll) { - * nWaitersToUnblock += nSignalsToIssue=nWaitersBlocked; - * nWaitersBlocked = 0; - * } - * else { - * nSignalsToIssue = 1; - * ++nWaitersToUnblock; - * --nWaitersBlocked; - * } - * } - * else if ( nWaitersBlocked > nWaitersGone ) { // HARMLESS RACE CONDITION! - * sem_wait( semBlockLock ); // close the gate - * if ( 0 != nWaitersGone ) { - * nWaitersBlocked -= nWaitersGone; - * nWaitersGone = 0; - * } - * if (bAll) { - * nSignalsToIssue = nWaitersToUnblock = nWaitersBlocked; - * nWaitersBlocked = 0; - * } - * else { - * nSignalsToIssue = nWaitersToUnblock = 1; - * --nWaitersBlocked; - * } - * } - * else { // NO-OP - * return unlock( mtxUnblockLock ); - * } - * - * unlock( mtxUnblockLock ); - * sem_post( semBlockQueue,nSignalsToIssue ); - * return result; - * } - * ------------------------------------------------------------- - * - */ - -#include "pthread.h" -#include "implement.h" - -/* - * Arguments for cond_wait_cleanup, since we can only pass a - * single void * to it. - */ -typedef struct -{ - pthread_mutex_t *mutexPtr; - pthread_cond_t cv; - int *resultPtr; -} ptw32_cond_wait_cleanup_args_t; - -static void PTW32_CDECL -ptw32_cond_wait_cleanup (void *args) -{ - ptw32_cond_wait_cleanup_args_t *cleanup_args = - (ptw32_cond_wait_cleanup_args_t *) args; - pthread_cond_t cv = cleanup_args->cv; - int *resultPtr = cleanup_args->resultPtr; - int nSignalsWasLeft; - int result; - - /* - * Whether we got here as a result of signal/broadcast or because of - * timeout on wait or thread cancellation we indicate that we are no - * longer waiting. The waiter is responsible for adjusting waiters - * (to)unblock(ed) counts (protected by unblock lock). - */ - if ((result = pthread_mutex_lock (&(cv->mtxUnblockLock))) != 0) - { - *resultPtr = result; - return; - } - - if (0 != (nSignalsWasLeft = cv->nWaitersToUnblock)) - { - --(cv->nWaitersToUnblock); - } - else if (INT_MAX / 2 == ++(cv->nWaitersGone)) - { - /* Use the non-cancellable version of sem_wait() */ - if (ptw32_semwait (&(cv->semBlockLock)) != 0) - { - *resultPtr = errno; - /* - * This is a fatal error for this CV, - * so we deliberately don't unlock - * cv->mtxUnblockLock before returning. - */ - return; - } - cv->nWaitersBlocked -= cv->nWaitersGone; - if (sem_post (&(cv->semBlockLock)) != 0) - { - *resultPtr = errno; - /* - * This is a fatal error for this CV, - * so we deliberately don't unlock - * cv->mtxUnblockLock before returning. - */ - return; - } - cv->nWaitersGone = 0; - } - - if ((result = pthread_mutex_unlock (&(cv->mtxUnblockLock))) != 0) - { - *resultPtr = result; - return; - } - - if (1 == nSignalsWasLeft) - { - if (sem_post (&(cv->semBlockLock)) != 0) - { - *resultPtr = errno; - return; - } - } - - /* - * XSH: Upon successful return, the mutex has been locked and is owned - * by the calling thread. - */ - if ((result = pthread_mutex_lock (cleanup_args->mutexPtr)) != 0) - { - *resultPtr = result; - } -} /* ptw32_cond_wait_cleanup */ - -static INLINE int -ptw32_cond_timedwait (pthread_cond_t * cond, - pthread_mutex_t * mutex, const struct timespec *abstime) -{ - int result = 0; - pthread_cond_t cv; - ptw32_cond_wait_cleanup_args_t cleanup_args; - - if (cond == NULL || *cond == NULL) - { - return EINVAL; - } - - /* - * We do a quick check to see if we need to do more work - * to initialise a static condition variable. We check - * again inside the guarded section of ptw32_cond_check_need_init() - * to avoid race conditions. - */ - if (*cond == PTHREAD_COND_INITIALIZER) - { - result = ptw32_cond_check_need_init (cond); - } - - if (result != 0 && result != EBUSY) - { - return result; - } - - cv = *cond; - - /* Thread can be cancelled in sem_wait() but this is OK */ - if (sem_wait (&(cv->semBlockLock)) != 0) - { - return errno; - } - - ++(cv->nWaitersBlocked); - - if (sem_post (&(cv->semBlockLock)) != 0) - { - return errno; - } - - /* - * Setup this waiter cleanup handler - */ - cleanup_args.mutexPtr = mutex; - cleanup_args.cv = cv; - cleanup_args.resultPtr = &result; - -#if defined(_MSC_VER) && _MSC_VER < 1400 -#pragma inline_depth(0) -#endif - pthread_cleanup_push (ptw32_cond_wait_cleanup, (void *) &cleanup_args); - - /* - * Now we can release 'mutex' and... - */ - if ((result = pthread_mutex_unlock (mutex)) == 0) - { - - /* - * ...wait to be awakened by - * pthread_cond_signal, or - * pthread_cond_broadcast, or - * timeout, or - * thread cancellation - * - * Note: - * - * sem_timedwait is a cancellation point, - * hence providing the mechanism for making - * pthread_cond_wait a cancellation point. - * We use the cleanup mechanism to ensure we - * re-lock the mutex and adjust (to)unblock(ed) waiters - * counts if we are cancelled, timed out or signalled. - */ - if (sem_timedwait (&(cv->semBlockQueue), abstime) != 0) - { - result = errno; - } - } - - /* - * Always cleanup - */ - pthread_cleanup_pop (1); -#if defined(_MSC_VER) && _MSC_VER < 1400 -#pragma inline_depth() -#endif - - /* - * "result" can be modified by the cleanup handler. - */ - return result; - -} /* ptw32_cond_timedwait */ - - -int -pthread_cond_wait (pthread_cond_t * cond, pthread_mutex_t * mutex) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function waits on a condition variable until - * awakened by a signal or broadcast. - * - * Caller MUST be holding the mutex lock; the - * lock is released and the caller is blocked waiting - * on 'cond'. When 'cond' is signaled, the mutex - * is re-acquired before returning to the caller. - * - * PARAMETERS - * cond - * pointer to an instance of pthread_cond_t - * - * mutex - * pointer to an instance of pthread_mutex_t - * - * - * DESCRIPTION - * This function waits on a condition variable until - * awakened by a signal or broadcast. - * - * NOTES: - * - * 1) The function must be called with 'mutex' LOCKED - * by the calling thread, or undefined behaviour - * will result. - * - * 2) This routine atomically releases 'mutex' and causes - * the calling thread to block on the condition variable. - * The blocked thread may be awakened by - * pthread_cond_signal or - * pthread_cond_broadcast. - * - * Upon successful completion, the 'mutex' has been locked and - * is owned by the calling thread. - * - * - * RESULTS - * 0 caught condition; mutex released, - * EINVAL 'cond' or 'mutex' is invalid, - * EINVAL different mutexes for concurrent waits, - * EINVAL mutex is not held by the calling thread, - * - * ------------------------------------------------------ - */ -{ - /* - * The NULL abstime arg means INFINITE waiting. - */ - return (ptw32_cond_timedwait (cond, mutex, NULL)); - -} /* pthread_cond_wait */ - - -int -pthread_cond_timedwait (pthread_cond_t * cond, - pthread_mutex_t * mutex, - const struct timespec *abstime) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function waits on a condition variable either until - * awakened by a signal or broadcast; or until the time - * specified by abstime passes. - * - * PARAMETERS - * cond - * pointer to an instance of pthread_cond_t - * - * mutex - * pointer to an instance of pthread_mutex_t - * - * abstime - * pointer to an instance of (const struct timespec) - * - * - * DESCRIPTION - * This function waits on a condition variable either until - * awakened by a signal or broadcast; or until the time - * specified by abstime passes. - * - * NOTES: - * 1) The function must be called with 'mutex' LOCKED - * by the calling thread, or undefined behaviour - * will result. - * - * 2) This routine atomically releases 'mutex' and causes - * the calling thread to block on the condition variable. - * The blocked thread may be awakened by - * pthread_cond_signal or - * pthread_cond_broadcast. - * - * - * RESULTS - * 0 caught condition; mutex released, - * EINVAL 'cond', 'mutex', or abstime is invalid, - * EINVAL different mutexes for concurrent waits, - * EINVAL mutex is not held by the calling thread, - * ETIMEDOUT abstime ellapsed before cond was signaled. - * - * ------------------------------------------------------ - */ -{ - if (abstime == NULL) - { - return EINVAL; - } - - return (ptw32_cond_timedwait (cond, mutex, abstime)); - -} /* pthread_cond_timedwait */ diff --git a/deps/w32-pthreads/pthread_condattr_destroy.c b/deps/w32-pthreads/pthread_condattr_destroy.c deleted file mode 100644 index d401cee..0000000 --- a/deps/w32-pthreads/pthread_condattr_destroy.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * condvar_attr_destroy.c - * - * Description: - * This translation unit implements condition variables and their primitives. - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_condattr_destroy (pthread_condattr_t * attr) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * Destroys a condition variable attributes object. - * The object can no longer be used. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_condattr_t - * - * - * DESCRIPTION - * Destroys a condition variable attributes object. - * The object can no longer be used. - * - * NOTES: - * 1) Does not affect condition variables created - * using 'attr' - * - * RESULTS - * 0 successfully released attr, - * EINVAL 'attr' is invalid. - * - * ------------------------------------------------------ - */ -{ - int result = 0; - - if (attr == NULL || *attr == NULL) - { - result = EINVAL; - } - else - { - (void) free (*attr); - - *attr = NULL; - result = 0; - } - - return result; - -} /* pthread_condattr_destroy */ diff --git a/deps/w32-pthreads/pthread_condattr_getpshared.c b/deps/w32-pthreads/pthread_condattr_getpshared.c deleted file mode 100644 index 7b508e3..0000000 --- a/deps/w32-pthreads/pthread_condattr_getpshared.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * pthread_condattr_getpshared.c - * - * Description: - * This translation unit implements condition variables and their primitives. - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_condattr_getpshared (const pthread_condattr_t * attr, int *pshared) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * Determine whether condition variables created with 'attr' - * can be shared between processes. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_condattr_t - * - * pshared - * will be set to one of: - * - * PTHREAD_PROCESS_SHARED - * May be shared if in shared memory - * - * PTHREAD_PROCESS_PRIVATE - * Cannot be shared. - * - * - * DESCRIPTION - * Condition Variables created with 'attr' can be shared - * between processes if pthread_cond_t variable is allocated - * in memory shared by these processes. - * NOTES: - * 1) pshared condition variables MUST be allocated in - * shared memory. - * - * 2) The following macro is defined if shared mutexes - * are supported: - * _POSIX_THREAD_PROCESS_SHARED - * - * RESULTS - * 0 successfully retrieved attribute, - * EINVAL 'attr' or 'pshared' is invalid, - * - * ------------------------------------------------------ - */ -{ - int result; - - if ((attr != NULL && *attr != NULL) && (pshared != NULL)) - { - *pshared = (*attr)->pshared; - result = 0; - } - else - { - result = EINVAL; - } - - return result; - -} /* pthread_condattr_getpshared */ diff --git a/deps/w32-pthreads/pthread_condattr_init.c b/deps/w32-pthreads/pthread_condattr_init.c deleted file mode 100644 index fd59642..0000000 --- a/deps/w32-pthreads/pthread_condattr_init.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * pthread_condattr_init.c - * - * Description: - * This translation unit implements condition variables and their primitives. - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_condattr_init (pthread_condattr_t * attr) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * Initializes a condition variable attributes object - * with default attributes. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_condattr_t - * - * - * DESCRIPTION - * Initializes a condition variable attributes object - * with default attributes. - * - * NOTES: - * 1) Use to define condition variable types - * 2) It is up to the application to ensure - * that it doesn't re-init an attribute - * without destroying it first. Otherwise - * a memory leak is created. - * - * RESULTS - * 0 successfully initialized attr, - * ENOMEM insufficient memory for attr. - * - * ------------------------------------------------------ - */ -{ - pthread_condattr_t attr_result; - int result = 0; - - attr_result = (pthread_condattr_t) calloc (1, sizeof (*attr_result)); - - if (attr_result == NULL) - { - result = ENOMEM; - } - - *attr = attr_result; - - return result; - -} /* pthread_condattr_init */ diff --git a/deps/w32-pthreads/pthread_condattr_setpshared.c b/deps/w32-pthreads/pthread_condattr_setpshared.c deleted file mode 100644 index f624207..0000000 --- a/deps/w32-pthreads/pthread_condattr_setpshared.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * pthread_condattr_setpshared.c - * - * Description: - * This translation unit implements condition variables and their primitives. - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_condattr_setpshared (pthread_condattr_t * attr, int pshared) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * Mutexes created with 'attr' can be shared between - * processes if pthread_mutex_t variable is allocated - * in memory shared by these processes. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_mutexattr_t - * - * pshared - * must be one of: - * - * PTHREAD_PROCESS_SHARED - * May be shared if in shared memory - * - * PTHREAD_PROCESS_PRIVATE - * Cannot be shared. - * - * DESCRIPTION - * Mutexes creatd with 'attr' can be shared between - * processes if pthread_mutex_t variable is allocated - * in memory shared by these processes. - * - * NOTES: - * 1) pshared mutexes MUST be allocated in shared - * memory. - * - * 2) The following macro is defined if shared mutexes - * are supported: - * _POSIX_THREAD_PROCESS_SHARED - * - * RESULTS - * 0 successfully set attribute, - * EINVAL 'attr' or pshared is invalid, - * ENOSYS PTHREAD_PROCESS_SHARED not supported, - * - * ------------------------------------------------------ - */ -{ - int result; - - if ((attr != NULL && *attr != NULL) - && ((pshared == PTHREAD_PROCESS_SHARED) - || (pshared == PTHREAD_PROCESS_PRIVATE))) - { - if (pshared == PTHREAD_PROCESS_SHARED) - { - -#if !defined( _POSIX_THREAD_PROCESS_SHARED ) - result = ENOSYS; - pshared = PTHREAD_PROCESS_PRIVATE; -#else - result = 0; - -#endif /* _POSIX_THREAD_PROCESS_SHARED */ - - } - else - { - result = 0; - } - - (*attr)->pshared = pshared; - } - else - { - result = EINVAL; - } - - return result; - -} /* pthread_condattr_setpshared */ diff --git a/deps/w32-pthreads/pthread_delay_np.c b/deps/w32-pthreads/pthread_delay_np.c deleted file mode 100644 index 8d681e9..0000000 --- a/deps/w32-pthreads/pthread_delay_np.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * pthreads_delay_np.c - * - * Description: - * This translation unit implements non-portable thread functions. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -/* - * pthread_delay_np - * - * DESCRIPTION - * - * This routine causes a thread to delay execution for a specific period of time. - * This period ends at the current time plus the specified interval. The routine - * will not return before the end of the period is reached, but may return an - * arbitrary amount of time after the period has gone by. This can be due to - * system load, thread priorities, and system timer granularity. - * - * Specifying an interval of zero (0) seconds and zero (0) nanoseconds is - * allowed and can be used to force the thread to give up the processor or to - * deliver a pending cancelation request. - * - * The timespec structure contains the following two fields: - * - * tv_sec is an integer number of seconds. - * tv_nsec is an integer number of nanoseconds. - * - * Return Values - * - * If an error condition occurs, this routine returns an integer value indicating - * the type of error. Possible return values are as follows: - * - * 0 - * Successful completion. - * [EINVAL] - * The value specified by interval is invalid. - * - * Example - * - * The following code segment would wait for 5 and 1/2 seconds - * - * struct timespec tsWait; - * int intRC; - * - * tsWait.tv_sec = 5; - * tsWait.tv_nsec = 500000000L; - * intRC = pthread_delay_np(&tsWait); - */ -int -pthread_delay_np (struct timespec *interval) -{ - DWORD wait_time; - DWORD secs_in_millisecs; - DWORD millisecs; - DWORD status; - pthread_t self; - ptw32_thread_t * sp; - - if (interval == NULL) - { - return EINVAL; - } - - if (interval->tv_sec == 0L && interval->tv_nsec == 0L) - { - pthread_testcancel (); - Sleep (0); - pthread_testcancel (); - return (0); - } - - /* convert secs to millisecs */ - secs_in_millisecs = (DWORD)interval->tv_sec * 1000L; - - /* convert nanosecs to millisecs (rounding up) */ - millisecs = (interval->tv_nsec + 999999L) / 1000000L; - -#if defined(__WATCOMC__) -#pragma disable_message (124) -#endif - - /* - * Most compilers will issue a warning 'comparison always 0' - * because the variable type is unsigned, but we need to keep this - * for some reason I can't recall now. - */ - if (0 > (wait_time = secs_in_millisecs + millisecs)) - { - return EINVAL; - } - -#if defined(__WATCOMC__) -#pragma enable_message (124) -#endif - - if (NULL == (self = pthread_self ()).p) - { - return ENOMEM; - } - - sp = (ptw32_thread_t *) self.p; - - if (sp->cancelState == PTHREAD_CANCEL_ENABLE) - { - /* - * Async cancelation won't catch us until wait_time is up. - * Deferred cancelation will cancel us immediately. - */ - if (WAIT_OBJECT_0 == - (status = WaitForSingleObject (sp->cancelEvent, wait_time))) - { - ptw32_mcs_local_node_t stateLock; - /* - * Canceling! - */ - ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); - if (sp->state < PThreadStateCanceling) - { - sp->state = PThreadStateCanceling; - sp->cancelState = PTHREAD_CANCEL_DISABLE; - ptw32_mcs_lock_release (&stateLock); - - ptw32_throw (PTW32_EPS_CANCEL); - } - - ptw32_mcs_lock_release (&stateLock); - return ESRCH; - } - else if (status != WAIT_TIMEOUT) - { - return EINVAL; - } - } - else - { - Sleep (wait_time); - } - - return (0); -} diff --git a/deps/w32-pthreads/pthread_detach.c b/deps/w32-pthreads/pthread_detach.c deleted file mode 100644 index 10f79d8..0000000 --- a/deps/w32-pthreads/pthread_detach.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * pthread_detach.c - * - * Description: - * This translation unit implements functions related to thread - * synchronisation. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -/* - * Not needed yet, but defining it should indicate clashes with build target - * environment that should be fixed. - */ -#if !defined(WINCE) -# include -#endif - - -int -pthread_detach (pthread_t thread) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function detaches the given thread. - * - * PARAMETERS - * thread - * an instance of a pthread_t - * - * - * DESCRIPTION - * This function detaches the given thread. You may use it to - * detach the main thread or to detach a joinable thread. - * NOTE: detached threads cannot be joined; - * storage is freed immediately on termination. - * - * RESULTS - * 0 successfully detached the thread, - * EINVAL thread is not a joinable thread, - * ENOSPC a required resource has been exhausted, - * ESRCH no thread could be found for 'thread', - * - * ------------------------------------------------------ - */ -{ - int result; - BOOL destroyIt = PTW32_FALSE; - ptw32_thread_t * tp = (ptw32_thread_t *) thread.p; - ptw32_mcs_local_node_t node; - - ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node); - - if (NULL == tp - || thread.x != tp->ptHandle.x) - { - result = ESRCH; - } - else if (PTHREAD_CREATE_DETACHED == tp->detachState) - { - result = EINVAL; - } - else - { - ptw32_mcs_local_node_t stateLock; - /* - * Joinable ptw32_thread_t structs are not scavenged until - * a join or detach is done. The thread may have exited already, - * but all of the state and locks etc are still there. - */ - result = 0; - - ptw32_mcs_lock_acquire (&tp->stateLock, &stateLock); - if (tp->state != PThreadStateLast) - { - tp->detachState = PTHREAD_CREATE_DETACHED; - } - else if (tp->detachState != PTHREAD_CREATE_DETACHED) - { - /* - * Thread is joinable and has exited or is exiting. - */ - destroyIt = PTW32_TRUE; - } - ptw32_mcs_lock_release (&stateLock); - } - - ptw32_mcs_lock_release(&node); - - if (result == 0) - { - /* Thread is joinable */ - - if (destroyIt) - { - /* The thread has exited or is exiting but has not been joined or - * detached. Need to wait in case it's still exiting. - */ - (void) WaitForSingleObject(tp->threadH, INFINITE); - ptw32_threadDestroy (thread); - } - } - - return (result); - -} /* pthread_detach */ diff --git a/deps/w32-pthreads/pthread_equal.c b/deps/w32-pthreads/pthread_equal.c deleted file mode 100644 index aae0085..0000000 --- a/deps/w32-pthreads/pthread_equal.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * pthread_equal.c - * - * Description: - * This translation unit implements miscellaneous thread functions. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_equal (pthread_t t1, pthread_t t2) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function returns nonzero if t1 and t2 are equal, else - * returns zero - * - * PARAMETERS - * t1, - * t2 - * thread IDs - * - * - * DESCRIPTION - * This function returns nonzero if t1 and t2 are equal, else - * returns zero. - * - * RESULTS - * non-zero if t1 and t2 refer to the same thread, - * 0 t1 and t2 do not refer to the same thread - * - * ------------------------------------------------------ - */ -{ - int result; - - /* - * We also accept NULL == NULL - treating NULL as a thread - * for this special case, because there is no error that we can return. - */ - result = ( t1.p == t2.p && t1.x == t2.x ); - - return (result); - -} /* pthread_equal */ diff --git a/deps/w32-pthreads/pthread_exit.c b/deps/w32-pthreads/pthread_exit.c deleted file mode 100644 index 30ae5f4..0000000 --- a/deps/w32-pthreads/pthread_exit.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * pthread_exit.c - * - * Description: - * This translation unit implements routines associated with exiting from - * a thread. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" -#if !defined(_UWIN) -/*# include */ -#endif - -void -pthread_exit (void *value_ptr) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function terminates the calling thread, returning - * the value 'value_ptr' to any joining thread. - * - * PARAMETERS - * value_ptr - * a generic data value (i.e. not the address of a value) - * - * - * DESCRIPTION - * This function terminates the calling thread, returning - * the value 'value_ptr' to any joining thread. - * NOTE: thread should be joinable. - * - * RESULTS - * N/A - * - * ------------------------------------------------------ - */ -{ - ptw32_thread_t * sp; - - /* - * Don't use pthread_self() to avoid creating an implicit POSIX thread handle - * unnecessarily. - */ - sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); - -#if defined(_UWIN) - if (--pthread_count <= 0) - exit ((int) value_ptr); -#endif - - if (NULL == sp) - { - /* - * A POSIX thread handle was never created. I.e. this is a - * Win32 thread that has never called a pthreads-win32 routine that - * required a POSIX handle. - * - * Implicit POSIX handles are cleaned up in ptw32_throw() now. - */ - -#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) - _endthreadex ((unsigned) (size_t) value_ptr); -#else - _endthread (); -#endif - - /* Never reached */ - } - - sp->exitStatus = value_ptr; - - ptw32_throw (PTW32_EPS_EXIT); - - /* Never reached. */ - -} diff --git a/deps/w32-pthreads/pthread_getconcurrency.c b/deps/w32-pthreads/pthread_getconcurrency.c deleted file mode 100644 index 5c9856c..0000000 --- a/deps/w32-pthreads/pthread_getconcurrency.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * pthread_getconcurrency.c - * - * Description: - * This translation unit implements miscellaneous thread functions. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_getconcurrency (void) -{ - return ptw32_concurrency; -} diff --git a/deps/w32-pthreads/pthread_getschedparam.c b/deps/w32-pthreads/pthread_getschedparam.c deleted file mode 100644 index bef6efe..0000000 --- a/deps/w32-pthreads/pthread_getschedparam.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * sched_getschedparam.c - * - * Description: - * POSIX thread functions that deal with thread scheduling. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" -#include "sched.h" - -int -pthread_getschedparam (pthread_t thread, int *policy, - struct sched_param *param) -{ - int result; - - /* Validate the thread id. */ - result = pthread_kill (thread, 0); - if (0 != result) - { - return result; - } - - /* - * Validate the policy and param args. - * Check that a policy constant wasn't passed rather than &policy. - */ - if (policy <= (int *) SCHED_MAX || param == NULL) - { - return EINVAL; - } - - /* Fill out the policy. */ - *policy = SCHED_OTHER; - - /* - * This function must return the priority value set by - * the most recent pthread_setschedparam() or pthread_create() - * for the target thread. It must not return the actual thread - * priority as altered by any system priority adjustments etc. - */ - param->sched_priority = ((ptw32_thread_t *)thread.p)->sched_priority; - - return 0; -} diff --git a/deps/w32-pthreads/pthread_getspecific.c b/deps/w32-pthreads/pthread_getspecific.c deleted file mode 100644 index f3e8af7..0000000 --- a/deps/w32-pthreads/pthread_getspecific.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * pthread_getspecific.c - * - * Description: - * POSIX thread functions which implement thread-specific data (TSD). - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -void * -pthread_getspecific (pthread_key_t key) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function returns the current value of key in the - * calling thread. If no value has been set for 'key' in - * the thread, NULL is returned. - * - * PARAMETERS - * key - * an instance of pthread_key_t - * - * - * DESCRIPTION - * This function returns the current value of key in the - * calling thread. If no value has been set for 'key' in - * the thread, NULL is returned. - * - * RESULTS - * key value or NULL on failure - * - * ------------------------------------------------------ - */ -{ - void * ptr; - - if (key == NULL) - { - ptr = NULL; - } - else - { - int lasterror = GetLastError (); -#if defined(RETAIN_WSALASTERROR) - int lastWSAerror = WSAGetLastError (); -#endif - ptr = TlsGetValue (key->key); - - SetLastError (lasterror); -#if defined(RETAIN_WSALASTERROR) - WSASetLastError (lastWSAerror); -#endif - } - - return ptr; -} diff --git a/deps/w32-pthreads/pthread_getunique_np.c b/deps/w32-pthreads/pthread_getunique_np.c deleted file mode 100644 index 9ab1c5b..0000000 --- a/deps/w32-pthreads/pthread_getunique_np.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * pthread_getunique_np.c - * - * Description: - * This translation unit implements non-portable thread functions. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -/* - * - */ -unsigned __int64 -pthread_getunique_np (pthread_t thread) -{ - return ((ptw32_thread_t*)thread.p)->seqNumber; -} diff --git a/deps/w32-pthreads/pthread_getw32threadhandle_np.c b/deps/w32-pthreads/pthread_getw32threadhandle_np.c deleted file mode 100644 index 23ed746..0000000 --- a/deps/w32-pthreads/pthread_getw32threadhandle_np.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * pthread_getw32threadhandle_np.c - * - * Description: - * This translation unit implements non-portable thread functions. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -/* - * pthread_getw32threadhandle_np() - * - * Returns the win32 thread handle that the POSIX - * thread "thread" is running as. - * - * Applications can use the win32 handle to set - * win32 specific attributes of the thread. - */ -HANDLE -pthread_getw32threadhandle_np (pthread_t thread) -{ - return ((ptw32_thread_t *)thread.p)->threadH; -} - -/* - * pthread_getw32threadid_np() - * - * Returns the win32 thread id that the POSIX - * thread "thread" is running as. - */ -DWORD -pthread_getw32threadid_np (pthread_t thread) -{ - return ((ptw32_thread_t *)thread.p)->thread; -} diff --git a/deps/w32-pthreads/pthread_join.c b/deps/w32-pthreads/pthread_join.c deleted file mode 100644 index 86318b7..0000000 --- a/deps/w32-pthreads/pthread_join.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - * pthread_join.c - * - * Description: - * This translation unit implements functions related to thread - * synchronisation. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -/* - * Not needed yet, but defining it should indicate clashes with build target - * environment that should be fixed. - */ -#if !defined(WINCE) -# include -#endif - - -int -pthread_join (pthread_t thread, void **value_ptr) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function waits for 'thread' to terminate and - * returns the thread's exit value if 'value_ptr' is not - * NULL. This also detaches the thread on successful - * completion. - * - * PARAMETERS - * thread - * an instance of pthread_t - * - * value_ptr - * pointer to an instance of pointer to void - * - * - * DESCRIPTION - * This function waits for 'thread' to terminate and - * returns the thread's exit value if 'value_ptr' is not - * NULL. This also detaches the thread on successful - * completion. - * NOTE: detached threads cannot be joined or canceled - * - * RESULTS - * 0 'thread' has completed - * EINVAL thread is not a joinable thread, - * ESRCH no thread could be found with ID 'thread', - * ENOENT thread couldn't find it's own valid handle, - * EDEADLK attempt to join thread with self - * - * ------------------------------------------------------ - */ -{ - int result; - pthread_t self; - ptw32_thread_t * tp = (ptw32_thread_t *) thread.p; - ptw32_mcs_local_node_t node; - - ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node); - - if (NULL == tp - || thread.x != tp->ptHandle.x) - { - result = ESRCH; - } - else if (PTHREAD_CREATE_DETACHED == tp->detachState) - { - result = EINVAL; - } - else - { - result = 0; - } - - ptw32_mcs_lock_release(&node); - - if (result == 0) - { - /* - * The target thread is joinable and can't be reused before we join it. - */ - self = pthread_self(); - - if (NULL == self.p) - { - result = ENOENT; - } - else if (pthread_equal (self, thread)) - { - result = EDEADLK; - } - else - { - /* - * Pthread_join is a cancelation point. - * If we are canceled then our target thread must not be - * detached (destroyed). This is guarranteed because - * pthreadCancelableWait will not return if we - * are canceled. - */ - result = pthreadCancelableWait (tp->threadH); - - if (0 == result) - { - if (value_ptr != NULL) - { - *value_ptr = tp->exitStatus; - } - - /* - * The result of making multiple simultaneous calls to - * pthread_join() or pthread_detach() specifying the same - * target is undefined. - */ - result = pthread_detach (thread); - } - else - { - result = ESRCH; - } - } - } - - return (result); - -} /* pthread_join */ diff --git a/deps/w32-pthreads/pthread_key_create.c b/deps/w32-pthreads/pthread_key_create.c deleted file mode 100644 index ff69c90..0000000 --- a/deps/w32-pthreads/pthread_key_create.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * pthread_key_create.c - * - * Description: - * POSIX thread functions which implement thread-specific data (TSD). - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -/* TLS_OUT_OF_INDEXES not defined on WinCE */ -#if !defined(TLS_OUT_OF_INDEXES) -#define TLS_OUT_OF_INDEXES 0xffffffff -#endif - -int -pthread_key_create (pthread_key_t * key, void (PTW32_CDECL *destructor) (void *)) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function creates a thread-specific data key visible - * to all threads. All existing and new threads have a value - * NULL for key until set using pthread_setspecific. When any - * thread with a non-NULL value for key terminates, 'destructor' - * is called with key's current value for that thread. - * - * PARAMETERS - * key - * pointer to an instance of pthread_key_t - * - * - * DESCRIPTION - * This function creates a thread-specific data key visible - * to all threads. All existing and new threads have a value - * NULL for key until set using pthread_setspecific. When any - * thread with a non-NULL value for key terminates, 'destructor' - * is called with key's current value for that thread. - * - * RESULTS - * 0 successfully created semaphore, - * EAGAIN insufficient resources or PTHREAD_KEYS_MAX - * exceeded, - * ENOMEM insufficient memory to create the key, - * - * ------------------------------------------------------ - */ -{ - int result = 0; - pthread_key_t newkey; - - if ((newkey = (pthread_key_t) calloc (1, sizeof (*newkey))) == NULL) - { - result = ENOMEM; - } - else if ((newkey->key = TlsAlloc ()) == TLS_OUT_OF_INDEXES) - { - result = EAGAIN; - - free (newkey); - newkey = NULL; - } - else if (destructor != NULL) - { - /* - * Have to manage associations between thread and key; - * Therefore, need a lock that allows competing threads - * to gain exclusive access to the key->threads list. - * - * The mutex will only be created when it is first locked. - */ - newkey->keyLock = 0; - newkey->destructor = destructor; - } - - *key = newkey; - - return (result); -} diff --git a/deps/w32-pthreads/pthread_key_delete.c b/deps/w32-pthreads/pthread_key_delete.c deleted file mode 100644 index 165276e..0000000 --- a/deps/w32-pthreads/pthread_key_delete.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * pthread_key_delete.c - * - * Description: - * POSIX thread functions which implement thread-specific data (TSD). - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_key_delete (pthread_key_t key) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function deletes a thread-specific data key. This - * does not change the value of the thread specific data key - * for any thread and does not run the key's destructor - * in any thread so it should be used with caution. - * - * PARAMETERS - * key - * pointer to an instance of pthread_key_t - * - * - * DESCRIPTION - * This function deletes a thread-specific data key. This - * does not change the value of the thread specific data key - * for any thread and does not run the key's destructor - * in any thread so it should be used with caution. - * - * RESULTS - * 0 successfully deleted the key, - * EINVAL key is invalid, - * - * ------------------------------------------------------ - */ -{ - ptw32_mcs_local_node_t keyLock; - int result = 0; - - if (key != NULL) - { - if (key->threads != NULL && key->destructor != NULL) - { - ThreadKeyAssoc *assoc; - ptw32_mcs_lock_acquire (&(key->keyLock), &keyLock); - /* - * Run through all Thread<-->Key associations - * for this key. - * - * While we hold at least one of the locks guarding - * the assoc, we know that the assoc pointed to by - * key->threads is valid. - */ - while ((assoc = (ThreadKeyAssoc *) key->threads) != NULL) - { - ptw32_mcs_local_node_t threadLock; - ptw32_thread_t * thread = assoc->thread; - - if (assoc == NULL) - { - /* Finished */ - break; - } - - ptw32_mcs_lock_acquire (&(thread->threadLock), &threadLock); - /* - * Since we are starting at the head of the key's threads - * chain, this will also point key->threads at the next assoc. - * While we hold key->keyLock, no other thread can insert - * a new assoc via pthread_setspecific. - */ - ptw32_tkAssocDestroy (assoc); - ptw32_mcs_lock_release (&threadLock); - ptw32_mcs_lock_release (&keyLock); - } - } - - TlsFree (key->key); - if (key->destructor != NULL) - { - /* A thread could be holding the keyLock */ - ptw32_mcs_lock_acquire (&(key->keyLock), &keyLock); - ptw32_mcs_lock_release (&keyLock); - } - -#if defined( _DEBUG ) - memset ((char *) key, 0, sizeof (*key)); -#endif - free (key); - } - - return (result); -} diff --git a/deps/w32-pthreads/pthread_kill.c b/deps/w32-pthreads/pthread_kill.c deleted file mode 100644 index 1c3af53..0000000 --- a/deps/w32-pthreads/pthread_kill.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * pthread_kill.c - * - * Description: - * This translation unit implements the pthread_kill routine. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -/* - * Not needed yet, but defining it should indicate clashes with build target - * environment that should be fixed. - */ -#if !defined(WINCE) -# include -#endif - -int -pthread_kill (pthread_t thread, int sig) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function requests that a signal be delivered to the - * specified thread. If sig is zero, error checking is - * performed but no signal is actually sent such that this - * function can be used to check for a valid thread ID. - * - * PARAMETERS - * thread reference to an instances of pthread_t - * sig signal. Currently only a value of 0 is supported. - * - * - * DESCRIPTION - * This function requests that a signal be delivered to the - * specified thread. If sig is zero, error checking is - * performed but no signal is actually sent such that this - * function can be used to check for a valid thread ID. - * - * RESULTS - * ESRCH the thread is not a valid thread ID, - * EINVAL the value of the signal is invalid - * or unsupported. - * 0 the signal was successfully sent. - * - * ------------------------------------------------------ - */ -{ - int result = 0; - ptw32_thread_t * tp; - ptw32_mcs_local_node_t node; - - ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node); - - tp = (ptw32_thread_t *) thread.p; - - if (NULL == tp - || thread.x != tp->ptHandle.x - || NULL == tp->threadH) - { - result = ESRCH; - } - - ptw32_mcs_lock_release(&node); - - if (0 == result && 0 != sig) - { - /* - * Currently does not support any signals. - */ - result = EINVAL; - } - - return result; - -} /* pthread_kill */ diff --git a/deps/w32-pthreads/pthread_mutex_consistent.c b/deps/w32-pthreads/pthread_mutex_consistent.c deleted file mode 100644 index e0bd3a3..0000000 --- a/deps/w32-pthreads/pthread_mutex_consistent.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - * pthread_mutex_consistent.c - * - * Description: - * This translation unit implements mutual exclusion (mutex) primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ -#if !defined(_UWIN) -/*# include */ -#endif -#include "pthread.h" -#include "implement.h" - -INLINE -int -ptw32_robust_mutex_inherit(pthread_mutex_t * mutex) -{ - int result; - pthread_mutex_t mx = *mutex; - ptw32_robust_node_t* robust = mx->robustNode; - - switch ((LONG)PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR)&robust->stateInconsistent, - (PTW32_INTERLOCKED_LONG)PTW32_ROBUST_INCONSISTENT, - (PTW32_INTERLOCKED_LONG)-1 /* The terminating thread sets this */)) - { - case -1L: - result = EOWNERDEAD; - break; - case (LONG)PTW32_ROBUST_NOTRECOVERABLE: - result = ENOTRECOVERABLE; - break; - default: - result = 0; - break; - } - - return result; -} - -/* - * The next two internal support functions depend on only being - * called by the thread that owns the robust mutex. This enables - * us to avoid additional locks. - * Any mutex currently in the thread's robust mutex list is held - * by the thread, again eliminating the need for locks. - * The forward/backward links allow the thread to unlock mutexes - * in any order, not necessarily the reverse locking order. - * This is all possible because it is an error if a thread that - * does not own the [robust] mutex attempts to unlock it. - */ - -INLINE -void -ptw32_robust_mutex_add(pthread_mutex_t* mutex, pthread_t self) -{ - ptw32_robust_node_t** list; - pthread_mutex_t mx = *mutex; - ptw32_thread_t* tp = (ptw32_thread_t*)self.p; - ptw32_robust_node_t* robust = mx->robustNode; - - list = &tp->robustMxList; - mx->ownerThread = self; - if (NULL == *list) - { - robust->prev = NULL; - robust->next = NULL; - *list = robust; - } - else - { - robust->prev = NULL; - robust->next = *list; - (*list)->prev = robust; - *list = robust; - } -} - -INLINE -void -ptw32_robust_mutex_remove(pthread_mutex_t* mutex, ptw32_thread_t* otp) -{ - ptw32_robust_node_t** list; - pthread_mutex_t mx = *mutex; - ptw32_robust_node_t* robust = mx->robustNode; - - list = &(((ptw32_thread_t*)mx->ownerThread.p)->robustMxList); - mx->ownerThread.p = otp; - if (robust->next != NULL) - { - robust->next->prev = robust->prev; - } - if (robust->prev != NULL) - { - robust->prev->next = robust->next; - } - if (*list == robust) - { - *list = robust->next; - } -} - - -int -pthread_mutex_consistent (pthread_mutex_t* mutex) -{ - pthread_mutex_t mx = *mutex; - int result = 0; - - /* - * Let the system deal with invalid pointers. - */ - if (mx == NULL) - { - return EINVAL; - } - - if (mx->kind >= 0 - || (PTW32_INTERLOCKED_LONG)PTW32_ROBUST_INCONSISTENT != PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR)&mx->robustNode->stateInconsistent, - (PTW32_INTERLOCKED_LONG)PTW32_ROBUST_CONSISTENT, - (PTW32_INTERLOCKED_LONG)PTW32_ROBUST_INCONSISTENT)) - { - result = EINVAL; - } - - return (result); -} - diff --git a/deps/w32-pthreads/pthread_mutex_destroy.c b/deps/w32-pthreads/pthread_mutex_destroy.c deleted file mode 100644 index 93588ed..0000000 --- a/deps/w32-pthreads/pthread_mutex_destroy.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * pthread_mutex_destroy.c - * - * Description: - * This translation unit implements mutual exclusion (mutex) primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_mutex_destroy (pthread_mutex_t * mutex) -{ - int result = 0; - pthread_mutex_t mx; - - /* - * Let the system deal with invalid pointers. - */ - - /* - * Check to see if we have something to delete. - */ - if (*mutex < PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) - { - mx = *mutex; - - result = pthread_mutex_trylock (&mx); - - /* - * If trylock succeeded and the mutex is not recursively locked it - * can be destroyed. - */ - if (0 == result || ENOTRECOVERABLE == result) - { - if (mx->kind != PTHREAD_MUTEX_RECURSIVE || 1 == mx->recursive_count) - { - /* - * FIXME!!! - * The mutex isn't held by another thread but we could still - * be too late invalidating the mutex below since another thread - * may already have entered mutex_lock and the check for a valid - * *mutex != NULL. - */ - *mutex = NULL; - - result = (0 == result)?pthread_mutex_unlock(&mx):0; - - if (0 == result) - { - if (mx->robustNode != NULL) - { - free(mx->robustNode); - } - if (!CloseHandle (mx->event)) - { - *mutex = mx; - result = EINVAL; - } - else - { - free (mx); - } - } - else - { - /* - * Restore the mutex before we return the error. - */ - *mutex = mx; - } - } - else /* mx->recursive_count > 1 */ - { - /* - * The mutex must be recursive and already locked by us (this thread). - */ - mx->recursive_count--; /* Undo effect of pthread_mutex_trylock() above */ - result = EBUSY; - } - } - } - else - { - ptw32_mcs_local_node_t node; - - /* - * See notes in ptw32_mutex_check_need_init() above also. - */ - - ptw32_mcs_lock_acquire(&ptw32_mutex_test_init_lock, &node); - - /* - * Check again. - */ - if (*mutex >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) - { - /* - * This is all we need to do to destroy a statically - * initialised mutex that has not yet been used (initialised). - * If we get to here, another thread - * waiting to initialise this mutex will get an EINVAL. - */ - *mutex = NULL; - } - else - { - /* - * The mutex has been initialised while we were waiting - * so assume it's in use. - */ - result = EBUSY; - } - ptw32_mcs_lock_release(&node); - } - - return (result); -} diff --git a/deps/w32-pthreads/pthread_mutex_init.c b/deps/w32-pthreads/pthread_mutex_init.c deleted file mode 100644 index 52ea956..0000000 --- a/deps/w32-pthreads/pthread_mutex_init.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * pthread_mutex_init.c - * - * Description: - * This translation unit implements mutual exclusion (mutex) primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_mutex_init (pthread_mutex_t * mutex, const pthread_mutexattr_t * attr) -{ - int result = 0; - pthread_mutex_t mx; - - if (mutex == NULL) - { - return EINVAL; - } - - if (attr != NULL && *attr != NULL) - { - if ((*attr)->pshared == PTHREAD_PROCESS_SHARED) - { - /* - * Creating mutex that can be shared between - * processes. - */ -#if _POSIX_THREAD_PROCESS_SHARED >= 0 - - /* - * Not implemented yet. - */ - -#error ERROR [__FILE__, line __LINE__]: Process shared mutexes are not supported yet. - -#else - - return ENOSYS; - -#endif /* _POSIX_THREAD_PROCESS_SHARED */ - } - } - - mx = (pthread_mutex_t) calloc (1, sizeof (*mx)); - - if (mx == NULL) - { - result = ENOMEM; - } - else - { - mx->lock_idx = 0; - mx->recursive_count = 0; - mx->robustNode = NULL; - if (attr == NULL || *attr == NULL) - { - mx->kind = PTHREAD_MUTEX_DEFAULT; - } - else - { - mx->kind = (*attr)->kind; - if ((*attr)->robustness == PTHREAD_MUTEX_ROBUST) - { - /* - * Use the negative range to represent robust types. - * Replaces a memory fetch with a register negate and incr - * in pthread_mutex_lock etc. - * - * Map 0,1,..,n to -1,-2,..,(-n)-1 - */ - mx->kind = -mx->kind - 1; - - mx->robustNode = (ptw32_robust_node_t*) malloc(sizeof(ptw32_robust_node_t)); - mx->robustNode->stateInconsistent = PTW32_ROBUST_CONSISTENT; - mx->robustNode->mx = mx; - mx->robustNode->next = NULL; - mx->robustNode->prev = NULL; - } - } - - mx->ownerThread.p = NULL; - - mx->event = CreateEvent (NULL, PTW32_FALSE, /* manual reset = No */ - PTW32_FALSE, /* initial state = not signaled */ - NULL); /* event name */ - - if (0 == mx->event) - { - result = ENOSPC; - free (mx); - mx = NULL; - } - } - - *mutex = mx; - - return (result); -} diff --git a/deps/w32-pthreads/pthread_mutex_lock.c b/deps/w32-pthreads/pthread_mutex_lock.c deleted file mode 100644 index a222172..0000000 --- a/deps/w32-pthreads/pthread_mutex_lock.c +++ /dev/null @@ -1,269 +0,0 @@ -/* - * pthread_mutex_lock.c - * - * Description: - * This translation unit implements mutual exclusion (mutex) primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#if !defined(_UWIN) -/*# include */ -#endif -#include "pthread.h" -#include "implement.h" - -int -pthread_mutex_lock (pthread_mutex_t * mutex) -{ - int kind; - pthread_mutex_t mx; - int result = 0; - - /* - * Let the system deal with invalid pointers. - */ - if (*mutex == NULL) - { - return EINVAL; - } - - /* - * We do a quick check to see if we need to do more work - * to initialise a static mutex. We check - * again inside the guarded section of ptw32_mutex_check_need_init() - * to avoid race conditions. - */ - if (*mutex >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) - { - if ((result = ptw32_mutex_check_need_init (mutex)) != 0) - { - return (result); - } - } - - mx = *mutex; - kind = mx->kind; - - if (kind >= 0) - { - /* Non-robust */ - if (PTHREAD_MUTEX_NORMAL == kind) - { - if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1) != 0) - { - while ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) -1) != 0) - { - if (WAIT_OBJECT_0 != WaitForSingleObject (mx->event, INFINITE)) - { - result = EINVAL; - break; - } - } - } - } - else - { - pthread_t self = pthread_self(); - - if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1, - (PTW32_INTERLOCKED_LONG) 0) == 0) - { - mx->recursive_count = 1; - mx->ownerThread = self; - } - else - { - if (pthread_equal (mx->ownerThread, self)) - { - if (kind == PTHREAD_MUTEX_RECURSIVE) - { - mx->recursive_count++; - } - else - { - result = EDEADLK; - } - } - else - { - while ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) -1) != 0) - { - if (WAIT_OBJECT_0 != WaitForSingleObject (mx->event, INFINITE)) - { - result = EINVAL; - break; - } - } - - if (0 == result) - { - mx->recursive_count = 1; - mx->ownerThread = self; - } - } - } - } - } - else - { - /* - * Robust types - * All types record the current owner thread. - * The mutex is added to a per thread list when ownership is acquired. - */ - ptw32_robust_state_t* statePtr = &mx->robustNode->stateInconsistent; - - if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( - (PTW32_INTERLOCKED_LONGPTR)statePtr, - (PTW32_INTERLOCKED_LONG)0)) - { - result = ENOTRECOVERABLE; - } - else - { - pthread_t self = pthread_self(); - - kind = -kind - 1; /* Convert to non-robust range */ - - if (PTHREAD_MUTEX_NORMAL == kind) - { - if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1) != 0) - { - while (0 == (result = ptw32_robust_mutex_inherit(mutex)) - && (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) -1) != 0) - { - if (WAIT_OBJECT_0 != WaitForSingleObject (mx->event, INFINITE)) - { - result = EINVAL; - break; - } - if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == - PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( - (PTW32_INTERLOCKED_LONGPTR)statePtr, - (PTW32_INTERLOCKED_LONG)0)) - { - /* Unblock the next thread */ - SetEvent(mx->event); - result = ENOTRECOVERABLE; - break; - } - } - } - if (0 == result || EOWNERDEAD == result) - { - /* - * Add mutex to the per-thread robust mutex currently-held list. - * If the thread terminates, all mutexes in this list will be unlocked. - */ - ptw32_robust_mutex_add(mutex, self); - } - } - else - { - if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1, - (PTW32_INTERLOCKED_LONG) 0) == 0) - { - mx->recursive_count = 1; - /* - * Add mutex to the per-thread robust mutex currently-held list. - * If the thread terminates, all mutexes in this list will be unlocked. - */ - ptw32_robust_mutex_add(mutex, self); - } - else - { - if (pthread_equal (mx->ownerThread, self)) - { - if (PTHREAD_MUTEX_RECURSIVE == kind) - { - mx->recursive_count++; - } - else - { - result = EDEADLK; - } - } - else - { - while (0 == (result = ptw32_robust_mutex_inherit(mutex)) - && (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) -1) != 0) - { - if (WAIT_OBJECT_0 != WaitForSingleObject (mx->event, INFINITE)) - { - result = EINVAL; - break; - } - if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == - PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( - (PTW32_INTERLOCKED_LONGPTR)statePtr, - (PTW32_INTERLOCKED_LONG)0)) - { - /* Unblock the next thread */ - SetEvent(mx->event); - result = ENOTRECOVERABLE; - break; - } - } - - if (0 == result || EOWNERDEAD == result) - { - mx->recursive_count = 1; - /* - * Add mutex to the per-thread robust mutex currently-held list. - * If the thread terminates, all mutexes in this list will be unlocked. - */ - ptw32_robust_mutex_add(mutex, self); - } - } - } - } - } - } - - return (result); -} - diff --git a/deps/w32-pthreads/pthread_mutex_timedlock.c b/deps/w32-pthreads/pthread_mutex_timedlock.c deleted file mode 100644 index 398ced8..0000000 --- a/deps/w32-pthreads/pthread_mutex_timedlock.c +++ /dev/null @@ -1,324 +0,0 @@ -/* - * pthread_mutex_timedlock.c - * - * Description: - * This translation unit implements mutual exclusion (mutex) primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -static INLINE int -ptw32_timed_eventwait (HANDLE event, const struct timespec *abstime) - /* - * ------------------------------------------------------ - * DESCRIPTION - * This function waits on an event until signaled or until - * abstime passes. - * If abstime has passed when this routine is called then - * it returns a result to indicate this. - * - * If 'abstime' is a NULL pointer then this function will - * block until it can successfully decrease the value or - * until interrupted by a signal. - * - * This routine is not a cancelation point. - * - * RESULTS - * 0 successfully signaled, - * ETIMEDOUT abstime passed - * EINVAL 'event' is not a valid event, - * - * ------------------------------------------------------ - */ -{ - - DWORD milliseconds; - DWORD status; - - if (event == NULL) - { - return EINVAL; - } - else - { - if (abstime == NULL) - { - milliseconds = INFINITE; - } - else - { - /* - * Calculate timeout as milliseconds from current system time. - */ - milliseconds = ptw32_relmillisecs (abstime); - } - - status = WaitForSingleObject (event, milliseconds); - - if (status == WAIT_OBJECT_0) - { - return 0; - } - else if (status == WAIT_TIMEOUT) - { - return ETIMEDOUT; - } - else - { - return EINVAL; - } - } - - return 0; - -} /* ptw32_timed_semwait */ - - -int -pthread_mutex_timedlock (pthread_mutex_t * mutex, - const struct timespec *abstime) -{ - pthread_mutex_t mx; - int kind; - int result = 0; - - /* - * Let the system deal with invalid pointers. - */ - - /* - * We do a quick check to see if we need to do more work - * to initialise a static mutex. We check - * again inside the guarded section of ptw32_mutex_check_need_init() - * to avoid race conditions. - */ - if (*mutex >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) - { - if ((result = ptw32_mutex_check_need_init (mutex)) != 0) - { - return (result); - } - } - - mx = *mutex; - kind = mx->kind; - - if (kind >= 0) - { - if (mx->kind == PTHREAD_MUTEX_NORMAL) - { - if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1) != 0) - { - while ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) -1) != 0) - { - if (0 != (result = ptw32_timed_eventwait (mx->event, abstime))) - { - return result; - } - } - } - } - else - { - pthread_t self = pthread_self(); - - if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1, - (PTW32_INTERLOCKED_LONG) 0) == 0) - { - mx->recursive_count = 1; - mx->ownerThread = self; - } - else - { - if (pthread_equal (mx->ownerThread, self)) - { - if (mx->kind == PTHREAD_MUTEX_RECURSIVE) - { - mx->recursive_count++; - } - else - { - return EDEADLK; - } - } - else - { - while ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) -1) != 0) - { - if (0 != (result = ptw32_timed_eventwait (mx->event, abstime))) - { - return result; - } - } - - mx->recursive_count = 1; - mx->ownerThread = self; - } - } - } - } - else - { - /* - * Robust types - * All types record the current owner thread. - * The mutex is added to a per thread list when ownership is acquired. - */ - ptw32_robust_state_t* statePtr = &mx->robustNode->stateInconsistent; - - if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( - (PTW32_INTERLOCKED_LONGPTR)statePtr, - (PTW32_INTERLOCKED_LONG)0)) - { - result = ENOTRECOVERABLE; - } - else - { - pthread_t self = pthread_self(); - - kind = -kind - 1; /* Convert to non-robust range */ - - if (PTHREAD_MUTEX_NORMAL == kind) - { - if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1) != 0) - { - while (0 == (result = ptw32_robust_mutex_inherit(mutex)) - && (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) -1) != 0) - { - if (0 != (result = ptw32_timed_eventwait (mx->event, abstime))) - { - return result; - } - if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == - PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( - (PTW32_INTERLOCKED_LONGPTR)statePtr, - (PTW32_INTERLOCKED_LONG)0)) - { - /* Unblock the next thread */ - SetEvent(mx->event); - result = ENOTRECOVERABLE; - break; - } - } - - if (0 == result || EOWNERDEAD == result) - { - /* - * Add mutex to the per-thread robust mutex currently-held list. - * If the thread terminates, all mutexes in this list will be unlocked. - */ - ptw32_robust_mutex_add(mutex, self); - } - } - } - else - { - pthread_t self = pthread_self(); - - if (0 == (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1, - (PTW32_INTERLOCKED_LONG) 0)) - { - mx->recursive_count = 1; - /* - * Add mutex to the per-thread robust mutex currently-held list. - * If the thread terminates, all mutexes in this list will be unlocked. - */ - ptw32_robust_mutex_add(mutex, self); - } - else - { - if (pthread_equal (mx->ownerThread, self)) - { - if (PTHREAD_MUTEX_RECURSIVE == kind) - { - mx->recursive_count++; - } - else - { - return EDEADLK; - } - } - else - { - while (0 == (result = ptw32_robust_mutex_inherit(mutex)) - && (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) -1) != 0) - { - if (0 != (result = ptw32_timed_eventwait (mx->event, abstime))) - { - return result; - } - } - - if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == - PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( - (PTW32_INTERLOCKED_LONGPTR)statePtr, - (PTW32_INTERLOCKED_LONG)0)) - { - /* Unblock the next thread */ - SetEvent(mx->event); - result = ENOTRECOVERABLE; - } - else if (0 == result || EOWNERDEAD == result) - { - mx->recursive_count = 1; - /* - * Add mutex to the per-thread robust mutex currently-held list. - * If the thread terminates, all mutexes in this list will be unlocked. - */ - ptw32_robust_mutex_add(mutex, self); - } - } - } - } - } - } - - return result; -} diff --git a/deps/w32-pthreads/pthread_mutex_trylock.c b/deps/w32-pthreads/pthread_mutex_trylock.c deleted file mode 100644 index 7dd9c3f..0000000 --- a/deps/w32-pthreads/pthread_mutex_trylock.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - * pthread_mutex_trylock.c - * - * Description: - * This translation unit implements mutual exclusion (mutex) primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_mutex_trylock (pthread_mutex_t * mutex) -{ - pthread_mutex_t mx; - int kind; - int result = 0; - - /* - * Let the system deal with invalid pointers. - */ - - /* - * We do a quick check to see if we need to do more work - * to initialise a static mutex. We check - * again inside the guarded section of ptw32_mutex_check_need_init() - * to avoid race conditions. - */ - if (*mutex >= PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) - { - if ((result = ptw32_mutex_check_need_init (mutex)) != 0) - { - return (result); - } - } - - mx = *mutex; - kind = mx->kind; - - if (kind >= 0) - { - /* Non-robust */ - if (0 == (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1, - (PTW32_INTERLOCKED_LONG) 0)) - { - if (kind != PTHREAD_MUTEX_NORMAL) - { - mx->recursive_count = 1; - mx->ownerThread = pthread_self (); - } - } - else - { - if (kind == PTHREAD_MUTEX_RECURSIVE && - pthread_equal (mx->ownerThread, pthread_self ())) - { - mx->recursive_count++; - } - else - { - result = EBUSY; - } - } - } - else - { - /* - * Robust types - * All types record the current owner thread. - * The mutex is added to a per thread list when ownership is acquired. - */ - pthread_t self; - ptw32_robust_state_t* statePtr = &mx->robustNode->stateInconsistent; - - if ((PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE == - PTW32_INTERLOCKED_EXCHANGE_ADD_LONG( - (PTW32_INTERLOCKED_LONGPTR)statePtr, - (PTW32_INTERLOCKED_LONG)0)) - { - return ENOTRECOVERABLE; - } - - self = pthread_self(); - kind = -kind - 1; /* Convert to non-robust range */ - - if (0 == (PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ( - (PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1, - (PTW32_INTERLOCKED_LONG) 0)) - { - if (kind != PTHREAD_MUTEX_NORMAL) - { - mx->recursive_count = 1; - } - ptw32_robust_mutex_add(mutex, self); - } - else - { - if (PTHREAD_MUTEX_RECURSIVE == kind && - pthread_equal (mx->ownerThread, pthread_self ())) - { - mx->recursive_count++; - } - else - { - if (EOWNERDEAD == (result = ptw32_robust_mutex_inherit(mutex))) - { - mx->recursive_count = 1; - ptw32_robust_mutex_add(mutex, self); - } - else - { - if (0 == result) - { - result = EBUSY; - } - } - } - } - } - - return (result); -} diff --git a/deps/w32-pthreads/pthread_mutex_unlock.c b/deps/w32-pthreads/pthread_mutex_unlock.c deleted file mode 100644 index 66b375a..0000000 --- a/deps/w32-pthreads/pthread_mutex_unlock.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * pthread_mutex_unlock.c - * - * Description: - * This translation unit implements mutual exclusion (mutex) primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_mutex_unlock (pthread_mutex_t * mutex) -{ - int result = 0; - int kind; - pthread_mutex_t mx; - - /* - * Let the system deal with invalid pointers. - */ - - mx = *mutex; - - /* - * If the thread calling us holds the mutex then there is no - * race condition. If another thread holds the - * lock then we shouldn't be in here. - */ - if (mx < PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) - { - kind = mx->kind; - - if (kind >= 0) - { - if (kind == PTHREAD_MUTEX_NORMAL) - { - LONG idx; - - idx = (LONG) PTW32_INTERLOCKED_EXCHANGE_LONG ((PTW32_INTERLOCKED_LONGPTR)&mx->lock_idx, - (PTW32_INTERLOCKED_LONG)0); - if (idx != 0) - { - if (idx < 0) - { - /* - * Someone may be waiting on that mutex. - */ - if (SetEvent (mx->event) == 0) - { - result = EINVAL; - } - } - } - } - else - { - if (pthread_equal (mx->ownerThread, pthread_self())) - { - if (kind != PTHREAD_MUTEX_RECURSIVE - || 0 == --mx->recursive_count) - { - mx->ownerThread.p = NULL; - - if ((LONG) PTW32_INTERLOCKED_EXCHANGE_LONG ((PTW32_INTERLOCKED_LONGPTR)&mx->lock_idx, - (PTW32_INTERLOCKED_LONG)0) < 0L) - { - /* Someone may be waiting on that mutex */ - if (SetEvent (mx->event) == 0) - { - result = EINVAL; - } - } - } - } - else - { - result = EPERM; - } - } - } - else - { - /* Robust types */ - pthread_t self = pthread_self(); - kind = -kind - 1; /* Convert to non-robust range */ - - /* - * The thread must own the lock regardless of type if the mutex - * is robust. - */ - if (pthread_equal (mx->ownerThread, self)) - { - PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG((PTW32_INTERLOCKED_LONGPTR) &mx->robustNode->stateInconsistent, - (PTW32_INTERLOCKED_LONG)PTW32_ROBUST_NOTRECOVERABLE, - (PTW32_INTERLOCKED_LONG)PTW32_ROBUST_INCONSISTENT); - if (PTHREAD_MUTEX_NORMAL == kind) - { - ptw32_robust_mutex_remove(mutex, NULL); - - if ((LONG) PTW32_INTERLOCKED_EXCHANGE_LONG((PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 0) < 0) - { - /* - * Someone may be waiting on that mutex. - */ - if (SetEvent (mx->event) == 0) - { - result = EINVAL; - } - } - } - else - { - if (kind != PTHREAD_MUTEX_RECURSIVE - || 0 == --mx->recursive_count) - { - ptw32_robust_mutex_remove(mutex, NULL); - - if ((LONG) PTW32_INTERLOCKED_EXCHANGE_LONG((PTW32_INTERLOCKED_LONGPTR) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 0) < 0) - { - /* - * Someone may be waiting on that mutex. - */ - if (SetEvent (mx->event) == 0) - { - result = EINVAL; - } - } - } - } - } - else - { - result = EPERM; - } - } - } - else if (mx != PTHREAD_MUTEX_INITIALIZER) - { - result = EINVAL; - } - - return (result); -} diff --git a/deps/w32-pthreads/pthread_mutexattr_destroy.c b/deps/w32-pthreads/pthread_mutexattr_destroy.c deleted file mode 100644 index 0cdec0f..0000000 --- a/deps/w32-pthreads/pthread_mutexattr_destroy.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * pthread_mutexattr_destroy.c - * - * Description: - * This translation unit implements mutual exclusion (mutex) primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_mutexattr_destroy (pthread_mutexattr_t * attr) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * Destroys a mutex attributes object. The object can - * no longer be used. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_mutexattr_t - * - * - * DESCRIPTION - * Destroys a mutex attributes object. The object can - * no longer be used. - * - * NOTES: - * 1) Does not affect mutexes created using 'attr' - * - * RESULTS - * 0 successfully released attr, - * EINVAL 'attr' is invalid. - * - * ------------------------------------------------------ - */ -{ - int result = 0; - - if (attr == NULL || *attr == NULL) - { - result = EINVAL; - } - else - { - pthread_mutexattr_t ma = *attr; - - *attr = NULL; - free (ma); - } - - return (result); -} /* pthread_mutexattr_destroy */ diff --git a/deps/w32-pthreads/pthread_mutexattr_getkind_np.c b/deps/w32-pthreads/pthread_mutexattr_getkind_np.c deleted file mode 100644 index 753b36f..0000000 --- a/deps/w32-pthreads/pthread_mutexattr_getkind_np.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * pthread_mutexattr_getkind_np.c - * - * Description: - * This translation unit implements non-portable thread functions. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -int -pthread_mutexattr_getkind_np (pthread_mutexattr_t * attr, int *kind) -{ - return pthread_mutexattr_gettype (attr, kind); -} diff --git a/deps/w32-pthreads/pthread_mutexattr_getpshared.c b/deps/w32-pthreads/pthread_mutexattr_getpshared.c deleted file mode 100644 index 4752110..0000000 --- a/deps/w32-pthreads/pthread_mutexattr_getpshared.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * pthread_mutexattr_getpshared.c - * - * Description: - * This translation unit implements mutual exclusion (mutex) primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_mutexattr_getpshared (const pthread_mutexattr_t * attr, int *pshared) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * Determine whether mutexes created with 'attr' can be - * shared between processes. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_mutexattr_t - * - * pshared - * will be set to one of: - * - * PTHREAD_PROCESS_SHARED - * May be shared if in shared memory - * - * PTHREAD_PROCESS_PRIVATE - * Cannot be shared. - * - * - * DESCRIPTION - * Mutexes creatd with 'attr' can be shared between - * processes if pthread_mutex_t variable is allocated - * in memory shared by these processes. - * NOTES: - * 1) pshared mutexes MUST be allocated in shared - * memory. - * 2) The following macro is defined if shared mutexes - * are supported: - * _POSIX_THREAD_PROCESS_SHARED - * - * RESULTS - * 0 successfully retrieved attribute, - * EINVAL 'attr' is invalid, - * - * ------------------------------------------------------ - */ -{ - int result; - - if ((attr != NULL && *attr != NULL) && (pshared != NULL)) - { - *pshared = (*attr)->pshared; - result = 0; - } - else - { - result = EINVAL; - } - - return (result); - -} /* pthread_mutexattr_getpshared */ diff --git a/deps/w32-pthreads/pthread_mutexattr_getrobust.c b/deps/w32-pthreads/pthread_mutexattr_getrobust.c deleted file mode 100644 index a4b7550..0000000 --- a/deps/w32-pthreads/pthread_mutexattr_getrobust.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * pthread_mutexattr_getrobust.c - * - * Description: - * This translation unit implements mutual exclusion (mutex) primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_mutexattr_getrobust (const pthread_mutexattr_t * attr, int * robust) - /* - * ------------------------------------------------------ - * - * DOCPUBLIC - * The pthread_mutexattr_setrobust() and - * pthread_mutexattr_getrobust() functions respectively set and - * get the mutex robust attribute. This attribute is set in the - * robust parameter to these functions. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_mutexattr_t - * - * robust - * must be one of: - * - * PTHREAD_MUTEX_STALLED - * - * PTHREAD_MUTEX_ROBUST - * - * DESCRIPTION - * The pthread_mutexattr_setrobust() and - * pthread_mutexattr_getrobust() functions respectively set and - * get the mutex robust attribute. This attribute is set in the - * robust parameter to these functions. The default value of the - * robust attribute is PTHREAD_MUTEX_STALLED. - * - * The robustness of mutex is contained in the robustness attribute - * of the mutex attributes. Valid mutex robustness values are: - * - * PTHREAD_MUTEX_STALLED - * No special actions are taken if the owner of the mutex is - * terminated while holding the mutex lock. This can lead to - * deadlocks if no other thread can unlock the mutex. - * This is the default value. - * - * PTHREAD_MUTEX_ROBUST - * If the process containing the owning thread of a robust mutex - * terminates while holding the mutex lock, the next thread that - * acquires the mutex shall be notified about the termination by - * the return value [EOWNERDEAD] from the locking function. If the - * owning thread of a robust mutex terminates while holding the mutex - * lock, the next thread that acquires the mutex may be notified - * about the termination by the return value [EOWNERDEAD]. The - * notified thread can then attempt to mark the state protected by - * the mutex as consistent again by a call to - * pthread_mutex_consistent(). After a subsequent successful call to - * pthread_mutex_unlock(), the mutex lock shall be released and can - * be used normally by other threads. If the mutex is unlocked without - * a call to pthread_mutex_consistent(), it shall be in a permanently - * unusable state and all attempts to lock the mutex shall fail with - * the error [ENOTRECOVERABLE]. The only permissible operation on such - * a mutex is pthread_mutex_destroy(). - * - * RESULTS - * 0 successfully set attribute, - * EINVAL 'attr' or 'robust' is invalid, - * - * ------------------------------------------------------ - */ -{ - int result = EINVAL; - - if ((attr != NULL && *attr != NULL && robust != NULL)) - { - *robust = (*attr)->robustness; - result = 0; - } - - return (result); -} /* pthread_mutexattr_getrobust */ diff --git a/deps/w32-pthreads/pthread_mutexattr_gettype.c b/deps/w32-pthreads/pthread_mutexattr_gettype.c deleted file mode 100644 index 817ab69..0000000 --- a/deps/w32-pthreads/pthread_mutexattr_gettype.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * pthread_mutexattr_gettype.c - * - * Description: - * This translation unit implements mutual exclusion (mutex) primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_mutexattr_gettype (const pthread_mutexattr_t * attr, int *kind) -{ - int result = 0; - - if (attr != NULL && *attr != NULL && kind != NULL) - { - *kind = (*attr)->kind; - } - else - { - result = EINVAL; - } - - return (result); -} diff --git a/deps/w32-pthreads/pthread_mutexattr_init.c b/deps/w32-pthreads/pthread_mutexattr_init.c deleted file mode 100644 index f6960f4..0000000 --- a/deps/w32-pthreads/pthread_mutexattr_init.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * pthread_mutexattr_init.c - * - * Description: - * This translation unit implements mutual exclusion (mutex) primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_mutexattr_init (pthread_mutexattr_t * attr) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * Initializes a mutex attributes object with default - * attributes. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_mutexattr_t - * - * - * DESCRIPTION - * Initializes a mutex attributes object with default - * attributes. - * - * NOTES: - * 1) Used to define mutex types - * - * RESULTS - * 0 successfully initialized attr, - * ENOMEM insufficient memory for attr. - * - * ------------------------------------------------------ - */ -{ - int result = 0; - pthread_mutexattr_t ma; - - ma = (pthread_mutexattr_t) calloc (1, sizeof (*ma)); - - if (ma == NULL) - { - result = ENOMEM; - } - else - { - ma->pshared = PTHREAD_PROCESS_PRIVATE; - ma->kind = PTHREAD_MUTEX_DEFAULT; - } - - *attr = ma; - - return (result); -} /* pthread_mutexattr_init */ diff --git a/deps/w32-pthreads/pthread_mutexattr_setkind_np.c b/deps/w32-pthreads/pthread_mutexattr_setkind_np.c deleted file mode 100644 index 06bb92d..0000000 --- a/deps/w32-pthreads/pthread_mutexattr_setkind_np.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * pthread_mutexattr_setkind_np.c - * - * Description: - * This translation unit implements non-portable thread functions. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -int -pthread_mutexattr_setkind_np (pthread_mutexattr_t * attr, int kind) -{ - return pthread_mutexattr_settype (attr, kind); -} diff --git a/deps/w32-pthreads/pthread_mutexattr_setpshared.c b/deps/w32-pthreads/pthread_mutexattr_setpshared.c deleted file mode 100644 index 09e750b..0000000 --- a/deps/w32-pthreads/pthread_mutexattr_setpshared.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * pthread_mutexattr_setpshared.c - * - * Description: - * This translation unit implements mutual exclusion (mutex) primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_mutexattr_setpshared (pthread_mutexattr_t * attr, int pshared) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * Mutexes created with 'attr' can be shared between - * processes if pthread_mutex_t variable is allocated - * in memory shared by these processes. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_mutexattr_t - * - * pshared - * must be one of: - * - * PTHREAD_PROCESS_SHARED - * May be shared if in shared memory - * - * PTHREAD_PROCESS_PRIVATE - * Cannot be shared. - * - * DESCRIPTION - * Mutexes creatd with 'attr' can be shared between - * processes if pthread_mutex_t variable is allocated - * in memory shared by these processes. - * - * NOTES: - * 1) pshared mutexes MUST be allocated in shared - * memory. - * - * 2) The following macro is defined if shared mutexes - * are supported: - * _POSIX_THREAD_PROCESS_SHARED - * - * RESULTS - * 0 successfully set attribute, - * EINVAL 'attr' or pshared is invalid, - * ENOSYS PTHREAD_PROCESS_SHARED not supported, - * - * ------------------------------------------------------ - */ -{ - int result; - - if ((attr != NULL && *attr != NULL) && - ((pshared == PTHREAD_PROCESS_SHARED) || - (pshared == PTHREAD_PROCESS_PRIVATE))) - { - if (pshared == PTHREAD_PROCESS_SHARED) - { - -#if !defined( _POSIX_THREAD_PROCESS_SHARED ) - - result = ENOSYS; - pshared = PTHREAD_PROCESS_PRIVATE; - -#else - - result = 0; - -#endif /* _POSIX_THREAD_PROCESS_SHARED */ - - } - else - { - result = 0; - } - - (*attr)->pshared = pshared; - } - else - { - result = EINVAL; - } - - return (result); - -} /* pthread_mutexattr_setpshared */ diff --git a/deps/w32-pthreads/pthread_mutexattr_setrobust.c b/deps/w32-pthreads/pthread_mutexattr_setrobust.c deleted file mode 100644 index f55a333..0000000 --- a/deps/w32-pthreads/pthread_mutexattr_setrobust.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * pthread_mutexattr_setrobust.c - * - * Description: - * This translation unit implements mutual exclusion (mutex) primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_mutexattr_setrobust (pthread_mutexattr_t * attr, int robust) - /* - * ------------------------------------------------------ - * - * DOCPUBLIC - * The pthread_mutexattr_setrobust() and - * pthread_mutexattr_getrobust() functions respectively set and - * get the mutex robust attribute. This attribute is set in the - * robust parameter to these functions. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_mutexattr_t - * - * robust - * must be one of: - * - * PTHREAD_MUTEX_STALLED - * - * PTHREAD_MUTEX_ROBUST - * - * DESCRIPTION - * The pthread_mutexattr_setrobust() and - * pthread_mutexattr_getrobust() functions respectively set and - * get the mutex robust attribute. This attribute is set in the - * robust parameter to these functions. The default value of the - * robust attribute is PTHREAD_MUTEX_STALLED. - * - * The robustness of mutex is contained in the robustness attribute - * of the mutex attributes. Valid mutex robustness values are: - * - * PTHREAD_MUTEX_STALLED - * No special actions are taken if the owner of the mutex is - * terminated while holding the mutex lock. This can lead to - * deadlocks if no other thread can unlock the mutex. - * This is the default value. - * - * PTHREAD_MUTEX_ROBUST - * If the process containing the owning thread of a robust mutex - * terminates while holding the mutex lock, the next thread that - * acquires the mutex shall be notified about the termination by - * the return value [EOWNERDEAD] from the locking function. If the - * owning thread of a robust mutex terminates while holding the mutex - * lock, the next thread that acquires the mutex may be notified - * about the termination by the return value [EOWNERDEAD]. The - * notified thread can then attempt to mark the state protected by - * the mutex as consistent again by a call to - * pthread_mutex_consistent(). After a subsequent successful call to - * pthread_mutex_unlock(), the mutex lock shall be released and can - * be used normally by other threads. If the mutex is unlocked without - * a call to pthread_mutex_consistent(), it shall be in a permanently - * unusable state and all attempts to lock the mutex shall fail with - * the error [ENOTRECOVERABLE]. The only permissible operation on such - * a mutex is pthread_mutex_destroy(). - * - * RESULTS - * 0 successfully set attribute, - * EINVAL 'attr' or 'robust' is invalid, - * - * ------------------------------------------------------ - */ -{ - int result = EINVAL; - - if ((attr != NULL && *attr != NULL)) - { - switch (robust) - { - case PTHREAD_MUTEX_STALLED: - case PTHREAD_MUTEX_ROBUST: - (*attr)->robustness = robust; - result = 0; - break; - } - } - - return (result); -} /* pthread_mutexattr_setrobust */ diff --git a/deps/w32-pthreads/pthread_mutexattr_settype.c b/deps/w32-pthreads/pthread_mutexattr_settype.c deleted file mode 100644 index e6b95ae..0000000 --- a/deps/w32-pthreads/pthread_mutexattr_settype.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * pthread_mutexattr_settype.c - * - * Description: - * This translation unit implements mutual exclusion (mutex) primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_mutexattr_settype (pthread_mutexattr_t * attr, int kind) - /* - * ------------------------------------------------------ - * - * DOCPUBLIC - * The pthread_mutexattr_settype() and - * pthread_mutexattr_gettype() functions respectively set and - * get the mutex type attribute. This attribute is set in the - * type parameter to these functions. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_mutexattr_t - * - * type - * must be one of: - * - * PTHREAD_MUTEX_DEFAULT - * - * PTHREAD_MUTEX_NORMAL - * - * PTHREAD_MUTEX_ERRORCHECK - * - * PTHREAD_MUTEX_RECURSIVE - * - * DESCRIPTION - * The pthread_mutexattr_settype() and - * pthread_mutexattr_gettype() functions respectively set and - * get the mutex type attribute. This attribute is set in the - * type parameter to these functions. The default value of the - * type attribute is PTHREAD_MUTEX_DEFAULT. - * - * The type of mutex is contained in the type attribute of the - * mutex attributes. Valid mutex types include: - * - * PTHREAD_MUTEX_NORMAL - * This type of mutex does not detect deadlock. A - * thread attempting to relock this mutex without - * first unlocking it will deadlock. Attempting to - * unlock a mutex locked by a different thread - * results in undefined behavior. Attempting to - * unlock an unlocked mutex results in undefined - * behavior. - * - * PTHREAD_MUTEX_ERRORCHECK - * This type of mutex provides error checking. A - * thread attempting to relock this mutex without - * first unlocking it will return with an error. A - * thread attempting to unlock a mutex which another - * thread has locked will return with an error. A - * thread attempting to unlock an unlocked mutex will - * return with an error. - * - * PTHREAD_MUTEX_DEFAULT - * Same as PTHREAD_MUTEX_NORMAL. - * - * PTHREAD_MUTEX_RECURSIVE - * A thread attempting to relock this mutex without - * first unlocking it will succeed in locking the - * mutex. The relocking deadlock which can occur with - * mutexes of type PTHREAD_MUTEX_NORMAL cannot occur - * with this type of mutex. Multiple locks of this - * mutex require the same number of unlocks to - * release the mutex before another thread can - * acquire the mutex. A thread attempting to unlock a - * mutex which another thread has locked will return - * with an error. A thread attempting to unlock an - * unlocked mutex will return with an error. This - * type of mutex is only supported for mutexes whose - * process shared attribute is - * PTHREAD_PROCESS_PRIVATE. - * - * RESULTS - * 0 successfully set attribute, - * EINVAL 'attr' or 'type' is invalid, - * - * ------------------------------------------------------ - */ -{ - int result = 0; - - if ((attr != NULL && *attr != NULL)) - { - switch (kind) - { - case PTHREAD_MUTEX_FAST_NP: - case PTHREAD_MUTEX_RECURSIVE_NP: - case PTHREAD_MUTEX_ERRORCHECK_NP: - (*attr)->kind = kind; - break; - default: - result = EINVAL; - break; - } - } - else - { - result = EINVAL; - } - - return (result); -} /* pthread_mutexattr_settype */ diff --git a/deps/w32-pthreads/pthread_num_processors_np.c b/deps/w32-pthreads/pthread_num_processors_np.c deleted file mode 100644 index 081dff6..0000000 --- a/deps/w32-pthreads/pthread_num_processors_np.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * pthread_num_processors_np.c - * - * Description: - * This translation unit implements non-portable thread functions. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -/* - * pthread_num_processors_np() - * - * Get the number of CPUs available to the process. - */ -int -pthread_num_processors_np (void) -{ - int count; - - if (ptw32_getprocessors (&count) != 0) - { - count = 1; - } - - return (count); -} diff --git a/deps/w32-pthreads/pthread_once.c b/deps/w32-pthreads/pthread_once.c deleted file mode 100644 index 5c9e900..0000000 --- a/deps/w32-pthreads/pthread_once.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * pthread_once.c - * - * Description: - * This translation unit implements miscellaneous thread functions. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -int -pthread_once (pthread_once_t * once_control, void (PTW32_CDECL *init_routine) (void)) -{ - if (once_control == NULL || init_routine == NULL) - { - return EINVAL; - } - - if ((PTW32_INTERLOCKED_LONG)PTW32_FALSE == - (PTW32_INTERLOCKED_LONG)PTW32_INTERLOCKED_EXCHANGE_ADD_LONG((PTW32_INTERLOCKED_LONGPTR)&once_control->done, - (PTW32_INTERLOCKED_LONG)0)) /* MBR fence */ - { - ptw32_mcs_local_node_t node; - - ptw32_mcs_lock_acquire((ptw32_mcs_lock_t *)&once_control->lock, &node); - - if (!once_control->done) - { - -#if defined(_MSC_VER) && _MSC_VER < 1400 -#pragma inline_depth(0) -#endif - - pthread_cleanup_push(ptw32_mcs_lock_release, &node); - (*init_routine)(); - pthread_cleanup_pop(0); - -#if defined(_MSC_VER) && _MSC_VER < 1400 -#pragma inline_depth() -#endif - - once_control->done = PTW32_TRUE; - } - - ptw32_mcs_lock_release(&node); - } - - return 0; - -} /* pthread_once */ diff --git a/deps/w32-pthreads/pthread_rwlock_destroy.c b/deps/w32-pthreads/pthread_rwlock_destroy.c deleted file mode 100644 index fe79e1e..0000000 --- a/deps/w32-pthreads/pthread_rwlock_destroy.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * pthread_rwlock_destroy.c - * - * Description: - * This translation unit implements read/write lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -#include "pthread.h" -#include "implement.h" - -int -pthread_rwlock_destroy (pthread_rwlock_t * rwlock) -{ - pthread_rwlock_t rwl; - int result = 0, result1 = 0, result2 = 0; - - if (rwlock == NULL || *rwlock == NULL) - { - return EINVAL; - } - - if (*rwlock != PTHREAD_RWLOCK_INITIALIZER) - { - rwl = *rwlock; - - if (rwl->nMagic != PTW32_RWLOCK_MAGIC) - { - return EINVAL; - } - - if ((result = pthread_mutex_lock (&(rwl->mtxExclusiveAccess))) != 0) - { - return result; - } - - if ((result = - pthread_mutex_lock (&(rwl->mtxSharedAccessCompleted))) != 0) - { - (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)); - return result; - } - - /* - * Check whether any threads own/wait for the lock (wait for ex.access); - * report "BUSY" if so. - */ - if (rwl->nExclusiveAccessCount > 0 - || rwl->nSharedAccessCount > rwl->nCompletedSharedAccessCount) - { - result = pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted)); - result1 = pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)); - result2 = EBUSY; - } - else - { - rwl->nMagic = 0; - - if ((result = - pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted))) != 0) - { - pthread_mutex_unlock (&rwl->mtxExclusiveAccess); - return result; - } - - if ((result = - pthread_mutex_unlock (&(rwl->mtxExclusiveAccess))) != 0) - { - return result; - } - - *rwlock = NULL; /* Invalidate rwlock before anything else */ - result = pthread_cond_destroy (&(rwl->cndSharedAccessCompleted)); - result1 = pthread_mutex_destroy (&(rwl->mtxSharedAccessCompleted)); - result2 = pthread_mutex_destroy (&(rwl->mtxExclusiveAccess)); - (void) free (rwl); - } - } - else - { - ptw32_mcs_local_node_t node; - /* - * See notes in ptw32_rwlock_check_need_init() above also. - */ - ptw32_mcs_lock_acquire(&ptw32_rwlock_test_init_lock, &node); - - /* - * Check again. - */ - if (*rwlock == PTHREAD_RWLOCK_INITIALIZER) - { - /* - * This is all we need to do to destroy a statically - * initialised rwlock that has not yet been used (initialised). - * If we get to here, another thread - * waiting to initialise this rwlock will get an EINVAL. - */ - *rwlock = NULL; - } - else - { - /* - * The rwlock has been initialised while we were waiting - * so assume it's in use. - */ - result = EBUSY; - } - - ptw32_mcs_lock_release(&node); - } - - return ((result != 0) ? result : ((result1 != 0) ? result1 : result2)); -} diff --git a/deps/w32-pthreads/pthread_rwlock_init.c b/deps/w32-pthreads/pthread_rwlock_init.c deleted file mode 100644 index cbba633..0000000 --- a/deps/w32-pthreads/pthread_rwlock_init.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * pthread_rwlock_init.c - * - * Description: - * This translation unit implements read/write lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -#include "pthread.h" -#include "implement.h" - -int -pthread_rwlock_init (pthread_rwlock_t * rwlock, - const pthread_rwlockattr_t * attr) -{ - int result; - pthread_rwlock_t rwl = 0; - - if (rwlock == NULL) - { - return EINVAL; - } - - if (attr != NULL && *attr != NULL) - { - result = EINVAL; /* Not supported */ - goto DONE; - } - - rwl = (pthread_rwlock_t) calloc (1, sizeof (*rwl)); - - if (rwl == NULL) - { - result = ENOMEM; - goto DONE; - } - - rwl->nSharedAccessCount = 0; - rwl->nExclusiveAccessCount = 0; - rwl->nCompletedSharedAccessCount = 0; - - result = pthread_mutex_init (&rwl->mtxExclusiveAccess, NULL); - if (result != 0) - { - goto FAIL0; - } - - result = pthread_mutex_init (&rwl->mtxSharedAccessCompleted, NULL); - if (result != 0) - { - goto FAIL1; - } - - result = pthread_cond_init (&rwl->cndSharedAccessCompleted, NULL); - if (result != 0) - { - goto FAIL2; - } - - rwl->nMagic = PTW32_RWLOCK_MAGIC; - - result = 0; - goto DONE; - -FAIL2: - (void) pthread_mutex_destroy (&(rwl->mtxSharedAccessCompleted)); - -FAIL1: - (void) pthread_mutex_destroy (&(rwl->mtxExclusiveAccess)); - -FAIL0: - (void) free (rwl); - rwl = NULL; - -DONE: - *rwlock = rwl; - - return result; -} diff --git a/deps/w32-pthreads/pthread_rwlock_rdlock.c b/deps/w32-pthreads/pthread_rwlock_rdlock.c deleted file mode 100644 index fb91b70..0000000 --- a/deps/w32-pthreads/pthread_rwlock_rdlock.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - * pthread_rwlock_rdlock.c - * - * Description: - * This translation unit implements read/write lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -#include "pthread.h" -#include "implement.h" - -int -pthread_rwlock_rdlock (pthread_rwlock_t * rwlock) -{ - int result; - pthread_rwlock_t rwl; - - if (rwlock == NULL || *rwlock == NULL) - { - return EINVAL; - } - - /* - * We do a quick check to see if we need to do more work - * to initialise a static rwlock. We check - * again inside the guarded section of ptw32_rwlock_check_need_init() - * to avoid race conditions. - */ - if (*rwlock == PTHREAD_RWLOCK_INITIALIZER) - { - result = ptw32_rwlock_check_need_init (rwlock); - - if (result != 0 && result != EBUSY) - { - return result; - } - } - - rwl = *rwlock; - - if (rwl->nMagic != PTW32_RWLOCK_MAGIC) - { - return EINVAL; - } - - if ((result = pthread_mutex_lock (&(rwl->mtxExclusiveAccess))) != 0) - { - return result; - } - - if (++rwl->nSharedAccessCount == INT_MAX) - { - if ((result = - pthread_mutex_lock (&(rwl->mtxSharedAccessCompleted))) != 0) - { - (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)); - return result; - } - - rwl->nSharedAccessCount -= rwl->nCompletedSharedAccessCount; - rwl->nCompletedSharedAccessCount = 0; - - if ((result = - pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted))) != 0) - { - (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)); - return result; - } - } - - return (pthread_mutex_unlock (&(rwl->mtxExclusiveAccess))); -} diff --git a/deps/w32-pthreads/pthread_rwlock_timedrdlock.c b/deps/w32-pthreads/pthread_rwlock_timedrdlock.c deleted file mode 100644 index d73dd10..0000000 --- a/deps/w32-pthreads/pthread_rwlock_timedrdlock.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * pthread_rwlock_timedrdlock.c - * - * Description: - * This translation unit implements read/write lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -#include "pthread.h" -#include "implement.h" - -int -pthread_rwlock_timedrdlock (pthread_rwlock_t * rwlock, - const struct timespec *abstime) -{ - int result; - pthread_rwlock_t rwl; - - if (rwlock == NULL || *rwlock == NULL) - { - return EINVAL; - } - - /* - * We do a quick check to see if we need to do more work - * to initialise a static rwlock. We check - * again inside the guarded section of ptw32_rwlock_check_need_init() - * to avoid race conditions. - */ - if (*rwlock == PTHREAD_RWLOCK_INITIALIZER) - { - result = ptw32_rwlock_check_need_init (rwlock); - - if (result != 0 && result != EBUSY) - { - return result; - } - } - - rwl = *rwlock; - - if (rwl->nMagic != PTW32_RWLOCK_MAGIC) - { - return EINVAL; - } - - if ((result = - pthread_mutex_timedlock (&(rwl->mtxExclusiveAccess), abstime)) != 0) - { - return result; - } - - if (++rwl->nSharedAccessCount == INT_MAX) - { - if ((result = - pthread_mutex_timedlock (&(rwl->mtxSharedAccessCompleted), - abstime)) != 0) - { - if (result == ETIMEDOUT) - { - ++rwl->nCompletedSharedAccessCount; - } - (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)); - return result; - } - - rwl->nSharedAccessCount -= rwl->nCompletedSharedAccessCount; - rwl->nCompletedSharedAccessCount = 0; - - if ((result = - pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted))) != 0) - { - (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)); - return result; - } - } - - return (pthread_mutex_unlock (&(rwl->mtxExclusiveAccess))); -} diff --git a/deps/w32-pthreads/pthread_rwlock_timedwrlock.c b/deps/w32-pthreads/pthread_rwlock_timedwrlock.c deleted file mode 100644 index 8e8e14e..0000000 --- a/deps/w32-pthreads/pthread_rwlock_timedwrlock.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * pthread_rwlock_timedwrlock.c - * - * Description: - * This translation unit implements read/write lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -#include "pthread.h" -#include "implement.h" - -int -pthread_rwlock_timedwrlock (pthread_rwlock_t * rwlock, - const struct timespec *abstime) -{ - int result; - pthread_rwlock_t rwl; - - if (rwlock == NULL || *rwlock == NULL) - { - return EINVAL; - } - - /* - * We do a quick check to see if we need to do more work - * to initialise a static rwlock. We check - * again inside the guarded section of ptw32_rwlock_check_need_init() - * to avoid race conditions. - */ - if (*rwlock == PTHREAD_RWLOCK_INITIALIZER) - { - result = ptw32_rwlock_check_need_init (rwlock); - - if (result != 0 && result != EBUSY) - { - return result; - } - } - - rwl = *rwlock; - - if (rwl->nMagic != PTW32_RWLOCK_MAGIC) - { - return EINVAL; - } - - if ((result = - pthread_mutex_timedlock (&(rwl->mtxExclusiveAccess), abstime)) != 0) - { - return result; - } - - if ((result = - pthread_mutex_timedlock (&(rwl->mtxSharedAccessCompleted), - abstime)) != 0) - { - (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)); - return result; - } - - if (rwl->nExclusiveAccessCount == 0) - { - if (rwl->nCompletedSharedAccessCount > 0) - { - rwl->nSharedAccessCount -= rwl->nCompletedSharedAccessCount; - rwl->nCompletedSharedAccessCount = 0; - } - - if (rwl->nSharedAccessCount > 0) - { - rwl->nCompletedSharedAccessCount = -rwl->nSharedAccessCount; - - /* - * This routine may be a cancelation point - * according to POSIX 1003.1j section 18.1.2. - */ -#if defined(_MSC_VER) && _MSC_VER < 1400 -#pragma inline_depth(0) -#endif - pthread_cleanup_push (ptw32_rwlock_cancelwrwait, (void *) rwl); - - do - { - result = - pthread_cond_timedwait (&(rwl->cndSharedAccessCompleted), - &(rwl->mtxSharedAccessCompleted), - abstime); - } - while (result == 0 && rwl->nCompletedSharedAccessCount < 0); - - pthread_cleanup_pop ((result != 0) ? 1 : 0); -#if defined(_MSC_VER) && _MSC_VER < 1400 -#pragma inline_depth() -#endif - - if (result == 0) - { - rwl->nSharedAccessCount = 0; - } - } - } - - if (result == 0) - { - rwl->nExclusiveAccessCount++; - } - - return result; -} diff --git a/deps/w32-pthreads/pthread_rwlock_tryrdlock.c b/deps/w32-pthreads/pthread_rwlock_tryrdlock.c deleted file mode 100644 index 10e1460..0000000 --- a/deps/w32-pthreads/pthread_rwlock_tryrdlock.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - * pthread_rwlock_tryrdlock.c - * - * Description: - * This translation unit implements read/write lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -#include "pthread.h" -#include "implement.h" - -int -pthread_rwlock_tryrdlock (pthread_rwlock_t * rwlock) -{ - int result; - pthread_rwlock_t rwl; - - if (rwlock == NULL || *rwlock == NULL) - { - return EINVAL; - } - - /* - * We do a quick check to see if we need to do more work - * to initialise a static rwlock. We check - * again inside the guarded section of ptw32_rwlock_check_need_init() - * to avoid race conditions. - */ - if (*rwlock == PTHREAD_RWLOCK_INITIALIZER) - { - result = ptw32_rwlock_check_need_init (rwlock); - - if (result != 0 && result != EBUSY) - { - return result; - } - } - - rwl = *rwlock; - - if (rwl->nMagic != PTW32_RWLOCK_MAGIC) - { - return EINVAL; - } - - if ((result = pthread_mutex_trylock (&(rwl->mtxExclusiveAccess))) != 0) - { - return result; - } - - if (++rwl->nSharedAccessCount == INT_MAX) - { - if ((result = - pthread_mutex_lock (&(rwl->mtxSharedAccessCompleted))) != 0) - { - (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)); - return result; - } - - rwl->nSharedAccessCount -= rwl->nCompletedSharedAccessCount; - rwl->nCompletedSharedAccessCount = 0; - - if ((result = - pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted))) != 0) - { - (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)); - return result; - } - } - - return (pthread_mutex_unlock (&rwl->mtxExclusiveAccess)); -} diff --git a/deps/w32-pthreads/pthread_rwlock_trywrlock.c b/deps/w32-pthreads/pthread_rwlock_trywrlock.c deleted file mode 100644 index 249ecf7..0000000 --- a/deps/w32-pthreads/pthread_rwlock_trywrlock.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * pthread_rwlock_trywrlock.c - * - * Description: - * This translation unit implements read/write lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -#include "pthread.h" -#include "implement.h" - -int -pthread_rwlock_trywrlock (pthread_rwlock_t * rwlock) -{ - int result, result1; - pthread_rwlock_t rwl; - - if (rwlock == NULL || *rwlock == NULL) - { - return EINVAL; - } - - /* - * We do a quick check to see if we need to do more work - * to initialise a static rwlock. We check - * again inside the guarded section of ptw32_rwlock_check_need_init() - * to avoid race conditions. - */ - if (*rwlock == PTHREAD_RWLOCK_INITIALIZER) - { - result = ptw32_rwlock_check_need_init (rwlock); - - if (result != 0 && result != EBUSY) - { - return result; - } - } - - rwl = *rwlock; - - if (rwl->nMagic != PTW32_RWLOCK_MAGIC) - { - return EINVAL; - } - - if ((result = pthread_mutex_trylock (&(rwl->mtxExclusiveAccess))) != 0) - { - return result; - } - - if ((result = - pthread_mutex_trylock (&(rwl->mtxSharedAccessCompleted))) != 0) - { - result1 = pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)); - return ((result1 != 0) ? result1 : result); - } - - if (rwl->nExclusiveAccessCount == 0) - { - if (rwl->nCompletedSharedAccessCount > 0) - { - rwl->nSharedAccessCount -= rwl->nCompletedSharedAccessCount; - rwl->nCompletedSharedAccessCount = 0; - } - - if (rwl->nSharedAccessCount > 0) - { - if ((result = - pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted))) != 0) - { - (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)); - return result; - } - - if ((result = - pthread_mutex_unlock (&(rwl->mtxExclusiveAccess))) == 0) - { - result = EBUSY; - } - } - else - { - rwl->nExclusiveAccessCount = 1; - } - } - else - { - result = EBUSY; - } - - return result; -} diff --git a/deps/w32-pthreads/pthread_rwlock_unlock.c b/deps/w32-pthreads/pthread_rwlock_unlock.c deleted file mode 100644 index a2f69d1..0000000 --- a/deps/w32-pthreads/pthread_rwlock_unlock.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * pthread_rwlock_unlock.c - * - * Description: - * This translation unit implements read/write lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -#include "pthread.h" -#include "implement.h" - -int -pthread_rwlock_unlock (pthread_rwlock_t * rwlock) -{ - int result, result1; - pthread_rwlock_t rwl; - - if (rwlock == NULL || *rwlock == NULL) - { - return (EINVAL); - } - - if (*rwlock == PTHREAD_RWLOCK_INITIALIZER) - { - /* - * Assume any race condition here is harmless. - */ - return 0; - } - - rwl = *rwlock; - - if (rwl->nMagic != PTW32_RWLOCK_MAGIC) - { - return EINVAL; - } - - if (rwl->nExclusiveAccessCount == 0) - { - if ((result = - pthread_mutex_lock (&(rwl->mtxSharedAccessCompleted))) != 0) - { - return result; - } - - if (++rwl->nCompletedSharedAccessCount == 0) - { - result = pthread_cond_signal (&(rwl->cndSharedAccessCompleted)); - } - - result1 = pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted)); - } - else - { - rwl->nExclusiveAccessCount--; - - result = pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted)); - result1 = pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)); - - } - - return ((result != 0) ? result : result1); -} diff --git a/deps/w32-pthreads/pthread_rwlock_wrlock.c b/deps/w32-pthreads/pthread_rwlock_wrlock.c deleted file mode 100644 index 30ce75d..0000000 --- a/deps/w32-pthreads/pthread_rwlock_wrlock.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * pthread_rwlock_wrlock.c - * - * Description: - * This translation unit implements read/write lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -#include "pthread.h" -#include "implement.h" - -int -pthread_rwlock_wrlock (pthread_rwlock_t * rwlock) -{ - int result; - pthread_rwlock_t rwl; - - if (rwlock == NULL || *rwlock == NULL) - { - return EINVAL; - } - - /* - * We do a quick check to see if we need to do more work - * to initialise a static rwlock. We check - * again inside the guarded section of ptw32_rwlock_check_need_init() - * to avoid race conditions. - */ - if (*rwlock == PTHREAD_RWLOCK_INITIALIZER) - { - result = ptw32_rwlock_check_need_init (rwlock); - - if (result != 0 && result != EBUSY) - { - return result; - } - } - - rwl = *rwlock; - - if (rwl->nMagic != PTW32_RWLOCK_MAGIC) - { - return EINVAL; - } - - if ((result = pthread_mutex_lock (&(rwl->mtxExclusiveAccess))) != 0) - { - return result; - } - - if ((result = pthread_mutex_lock (&(rwl->mtxSharedAccessCompleted))) != 0) - { - (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)); - return result; - } - - if (rwl->nExclusiveAccessCount == 0) - { - if (rwl->nCompletedSharedAccessCount > 0) - { - rwl->nSharedAccessCount -= rwl->nCompletedSharedAccessCount; - rwl->nCompletedSharedAccessCount = 0; - } - - if (rwl->nSharedAccessCount > 0) - { - rwl->nCompletedSharedAccessCount = -rwl->nSharedAccessCount; - - /* - * This routine may be a cancelation point - * according to POSIX 1003.1j section 18.1.2. - */ -#if defined(_MSC_VER) && _MSC_VER < 1400 -#pragma inline_depth(0) -#endif - pthread_cleanup_push (ptw32_rwlock_cancelwrwait, (void *) rwl); - - do - { - result = pthread_cond_wait (&(rwl->cndSharedAccessCompleted), - &(rwl->mtxSharedAccessCompleted)); - } - while (result == 0 && rwl->nCompletedSharedAccessCount < 0); - - pthread_cleanup_pop ((result != 0) ? 1 : 0); -#if defined(_MSC_VER) && _MSC_VER < 1400 -#pragma inline_depth() -#endif - - if (result == 0) - { - rwl->nSharedAccessCount = 0; - } - } - } - - if (result == 0) - { - rwl->nExclusiveAccessCount++; - } - - return result; -} diff --git a/deps/w32-pthreads/pthread_rwlockattr_destroy.c b/deps/w32-pthreads/pthread_rwlockattr_destroy.c deleted file mode 100644 index c2c7d99..0000000 --- a/deps/w32-pthreads/pthread_rwlockattr_destroy.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * pthread_rwlockattr_destroy.c - * - * Description: - * This translation unit implements read/write lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -#include "pthread.h" -#include "implement.h" - -int -pthread_rwlockattr_destroy (pthread_rwlockattr_t * attr) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * Destroys a rwlock attributes object. The object can - * no longer be used. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_rwlockattr_t - * - * - * DESCRIPTION - * Destroys a rwlock attributes object. The object can - * no longer be used. - * - * NOTES: - * 1) Does not affect rwlockss created using 'attr' - * - * RESULTS - * 0 successfully released attr, - * EINVAL 'attr' is invalid. - * - * ------------------------------------------------------ - */ -{ - int result = 0; - - if (attr == NULL || *attr == NULL) - { - result = EINVAL; - } - else - { - pthread_rwlockattr_t rwa = *attr; - - *attr = NULL; - free (rwa); - } - - return (result); -} /* pthread_rwlockattr_destroy */ diff --git a/deps/w32-pthreads/pthread_rwlockattr_getpshared.c b/deps/w32-pthreads/pthread_rwlockattr_getpshared.c deleted file mode 100644 index 0474e08..0000000 --- a/deps/w32-pthreads/pthread_rwlockattr_getpshared.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * pthread_rwlockattr_getpshared.c - * - * Description: - * This translation unit implements read/write lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -#include "pthread.h" -#include "implement.h" - -int -pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * attr, - int *pshared) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * Determine whether rwlocks created with 'attr' can be - * shared between processes. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_rwlockattr_t - * - * pshared - * will be set to one of: - * - * PTHREAD_PROCESS_SHARED - * May be shared if in shared memory - * - * PTHREAD_PROCESS_PRIVATE - * Cannot be shared. - * - * - * DESCRIPTION - * Rwlocks creatd with 'attr' can be shared between - * processes if pthread_rwlock_t variable is allocated - * in memory shared by these processes. - * NOTES: - * 1) pshared rwlocks MUST be allocated in shared - * memory. - * 2) The following macro is defined if shared rwlocks - * are supported: - * _POSIX_THREAD_PROCESS_SHARED - * - * RESULTS - * 0 successfully retrieved attribute, - * EINVAL 'attr' is invalid, - * - * ------------------------------------------------------ - */ -{ - int result; - - if ((attr != NULL && *attr != NULL) && (pshared != NULL)) - { - *pshared = (*attr)->pshared; - result = 0; - } - else - { - result = EINVAL; - } - - return (result); - -} /* pthread_rwlockattr_getpshared */ diff --git a/deps/w32-pthreads/pthread_rwlockattr_init.c b/deps/w32-pthreads/pthread_rwlockattr_init.c deleted file mode 100644 index a028421..0000000 --- a/deps/w32-pthreads/pthread_rwlockattr_init.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * pthread_rwlockattr_init.c - * - * Description: - * This translation unit implements read/write lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -#include "pthread.h" -#include "implement.h" - -int -pthread_rwlockattr_init (pthread_rwlockattr_t * attr) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * Initializes a rwlock attributes object with default - * attributes. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_rwlockattr_t - * - * - * DESCRIPTION - * Initializes a rwlock attributes object with default - * attributes. - * - * RESULTS - * 0 successfully initialized attr, - * ENOMEM insufficient memory for attr. - * - * ------------------------------------------------------ - */ -{ - int result = 0; - pthread_rwlockattr_t rwa; - - rwa = (pthread_rwlockattr_t) calloc (1, sizeof (*rwa)); - - if (rwa == NULL) - { - result = ENOMEM; - } - else - { - rwa->pshared = PTHREAD_PROCESS_PRIVATE; - } - - *attr = rwa; - - return (result); -} /* pthread_rwlockattr_init */ diff --git a/deps/w32-pthreads/pthread_rwlockattr_setpshared.c b/deps/w32-pthreads/pthread_rwlockattr_setpshared.c deleted file mode 100644 index 7b4c2cb..0000000 --- a/deps/w32-pthreads/pthread_rwlockattr_setpshared.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - * pthread_rwlockattr_setpshared.c - * - * Description: - * This translation unit implements read/write lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include - -#include "pthread.h" -#include "implement.h" - -int -pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr, int pshared) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * Rwlocks created with 'attr' can be shared between - * processes if pthread_rwlock_t variable is allocated - * in memory shared by these processes. - * - * PARAMETERS - * attr - * pointer to an instance of pthread_rwlockattr_t - * - * pshared - * must be one of: - * - * PTHREAD_PROCESS_SHARED - * May be shared if in shared memory - * - * PTHREAD_PROCESS_PRIVATE - * Cannot be shared. - * - * DESCRIPTION - * Rwlocks creatd with 'attr' can be shared between - * processes if pthread_rwlock_t variable is allocated - * in memory shared by these processes. - * - * NOTES: - * 1) pshared rwlocks MUST be allocated in shared - * memory. - * - * 2) The following macro is defined if shared rwlocks - * are supported: - * _POSIX_THREAD_PROCESS_SHARED - * - * RESULTS - * 0 successfully set attribute, - * EINVAL 'attr' or pshared is invalid, - * ENOSYS PTHREAD_PROCESS_SHARED not supported, - * - * ------------------------------------------------------ - */ -{ - int result; - - if ((attr != NULL && *attr != NULL) && - ((pshared == PTHREAD_PROCESS_SHARED) || - (pshared == PTHREAD_PROCESS_PRIVATE))) - { - if (pshared == PTHREAD_PROCESS_SHARED) - { - -#if !defined( _POSIX_THREAD_PROCESS_SHARED ) - - result = ENOSYS; - pshared = PTHREAD_PROCESS_PRIVATE; - -#else - - result = 0; - -#endif /* _POSIX_THREAD_PROCESS_SHARED */ - - } - else - { - result = 0; - } - - (*attr)->pshared = pshared; - } - else - { - result = EINVAL; - } - - return (result); - -} /* pthread_rwlockattr_setpshared */ diff --git a/deps/w32-pthreads/pthread_self.c b/deps/w32-pthreads/pthread_self.c deleted file mode 100644 index f13926f..0000000 --- a/deps/w32-pthreads/pthread_self.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * pthread_self.c - * - * Description: - * This translation unit implements miscellaneous thread functions. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -pthread_t -pthread_self (void) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function returns a reference to the current running - * thread. - * - * PARAMETERS - * N/A - * - * - * DESCRIPTION - * This function returns a reference to the current running - * thread. - * - * RESULTS - * pthread_t reference to the current thread - * - * ------------------------------------------------------ - */ -{ - pthread_t self; - pthread_t nil = {NULL, 0}; - ptw32_thread_t * sp; - -#if defined(_UWIN) - if (!ptw32_selfThreadKey) - return nil; -#endif - - sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); - - if (sp != NULL) - { - self = sp->ptHandle; - } - else - { - /* - * Need to create an implicit 'self' for the currently - * executing thread. - */ - self = ptw32_new (); - sp = (ptw32_thread_t *) self.p; - - if (sp != NULL) - { - /* - * This is a non-POSIX thread which has chosen to call - * a POSIX threads function for some reason. We assume that - * it isn't joinable, but we do assume that it's - * (deferred) cancelable. - */ - sp->implicit = 1; - sp->detachState = PTHREAD_CREATE_DETACHED; - sp->thread = GetCurrentThreadId (); - -#if defined(NEED_DUPLICATEHANDLE) - /* - * DuplicateHandle does not exist on WinCE. - * - * NOTE: - * GetCurrentThread only returns a pseudo-handle - * which is only valid in the current thread context. - * Therefore, you should not pass the handle to - * other threads for whatever purpose. - */ - sp->threadH = GetCurrentThread (); -#else - if (!DuplicateHandle (GetCurrentProcess (), - GetCurrentThread (), - GetCurrentProcess (), - &sp->threadH, - 0, FALSE, DUPLICATE_SAME_ACCESS)) - { - /* - * Should not do this, but we have no alternative if - * we can't get a Win32 thread handle. - * Thread structs are never freed. - */ - ptw32_threadReusePush (self); - /* - * As this is a win32 thread calling us and we have failed, - * return a value that makes sense to win32. - */ - return nil; - } -#endif - - /* - * No need to explicitly serialise access to sched_priority - * because the new handle is not yet public. - */ - sp->sched_priority = GetThreadPriority (sp->threadH); - pthread_setspecific (ptw32_selfThreadKey, (void *) sp); - } - } - - return (self); - -} /* pthread_self */ diff --git a/deps/w32-pthreads/pthread_setcancelstate.c b/deps/w32-pthreads/pthread_setcancelstate.c deleted file mode 100644 index 126801f..0000000 --- a/deps/w32-pthreads/pthread_setcancelstate.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * pthread_setcancelstate.c - * - * Description: - * POSIX thread functions related to thread cancellation. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_setcancelstate (int state, int *oldstate) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function atomically sets the calling thread's - * cancelability state to 'state' and returns the previous - * cancelability state at the location referenced by - * 'oldstate' - * - * PARAMETERS - * state, - * oldstate - * PTHREAD_CANCEL_ENABLE - * cancellation is enabled, - * - * PTHREAD_CANCEL_DISABLE - * cancellation is disabled - * - * - * DESCRIPTION - * This function atomically sets the calling thread's - * cancelability state to 'state' and returns the previous - * cancelability state at the location referenced by - * 'oldstate'. - * - * NOTES: - * 1) Use to disable cancellation around 'atomic' code that - * includes cancellation points - * - * COMPATIBILITY ADDITIONS - * If 'oldstate' is NULL then the previous state is not returned - * but the function still succeeds. (Solaris) - * - * RESULTS - * 0 successfully set cancelability type, - * EINVAL 'state' is invalid - * - * ------------------------------------------------------ - */ -{ - ptw32_mcs_local_node_t stateLock; - int result = 0; - pthread_t self = pthread_self (); - ptw32_thread_t * sp = (ptw32_thread_t *) self.p; - - if (sp == NULL - || (state != PTHREAD_CANCEL_ENABLE && state != PTHREAD_CANCEL_DISABLE)) - { - return EINVAL; - } - - /* - * Lock for async-cancel safety. - */ - ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); - - if (oldstate != NULL) - { - *oldstate = sp->cancelState; - } - - sp->cancelState = state; - - /* - * Check if there is a pending asynchronous cancel - */ - if (state == PTHREAD_CANCEL_ENABLE - && sp->cancelType == PTHREAD_CANCEL_ASYNCHRONOUS - && WaitForSingleObject (sp->cancelEvent, 0) == WAIT_OBJECT_0) - { - sp->state = PThreadStateCanceling; - sp->cancelState = PTHREAD_CANCEL_DISABLE; - ResetEvent (sp->cancelEvent); - ptw32_mcs_lock_release (&stateLock); - ptw32_throw (PTW32_EPS_CANCEL); - - /* Never reached */ - } - - ptw32_mcs_lock_release (&stateLock); - - return (result); - -} /* pthread_setcancelstate */ diff --git a/deps/w32-pthreads/pthread_setcanceltype.c b/deps/w32-pthreads/pthread_setcanceltype.c deleted file mode 100644 index 00522ae..0000000 --- a/deps/w32-pthreads/pthread_setcanceltype.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * pthread_setcanceltype.c - * - * Description: - * POSIX thread functions related to thread cancellation. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_setcanceltype (int type, int *oldtype) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function atomically sets the calling thread's - * cancelability type to 'type' and returns the previous - * cancelability type at the location referenced by - * 'oldtype' - * - * PARAMETERS - * type, - * oldtype - * PTHREAD_CANCEL_DEFERRED - * only deferred cancelation is allowed, - * - * PTHREAD_CANCEL_ASYNCHRONOUS - * Asynchronous cancellation is allowed - * - * - * DESCRIPTION - * This function atomically sets the calling thread's - * cancelability type to 'type' and returns the previous - * cancelability type at the location referenced by - * 'oldtype' - * - * NOTES: - * 1) Use with caution; most code is not safe for use - * with asynchronous cancelability. - * - * COMPATIBILITY ADDITIONS - * If 'oldtype' is NULL then the previous type is not returned - * but the function still succeeds. (Solaris) - * - * RESULTS - * 0 successfully set cancelability type, - * EINVAL 'type' is invalid - * - * ------------------------------------------------------ - */ -{ - ptw32_mcs_local_node_t stateLock; - int result = 0; - pthread_t self = pthread_self (); - ptw32_thread_t * sp = (ptw32_thread_t *) self.p; - - if (sp == NULL - || (type != PTHREAD_CANCEL_DEFERRED - && type != PTHREAD_CANCEL_ASYNCHRONOUS)) - { - return EINVAL; - } - - /* - * Lock for async-cancel safety. - */ - ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); - - if (oldtype != NULL) - { - *oldtype = sp->cancelType; - } - - sp->cancelType = type; - - /* - * Check if there is a pending asynchronous cancel - */ - if (sp->cancelState == PTHREAD_CANCEL_ENABLE - && type == PTHREAD_CANCEL_ASYNCHRONOUS - && WaitForSingleObject (sp->cancelEvent, 0) == WAIT_OBJECT_0) - { - sp->state = PThreadStateCanceling; - sp->cancelState = PTHREAD_CANCEL_DISABLE; - ResetEvent (sp->cancelEvent); - ptw32_mcs_lock_release (&stateLock); - ptw32_throw (PTW32_EPS_CANCEL); - - /* Never reached */ - } - - ptw32_mcs_lock_release (&stateLock); - - return (result); - -} /* pthread_setcanceltype */ diff --git a/deps/w32-pthreads/pthread_setconcurrency.c b/deps/w32-pthreads/pthread_setconcurrency.c deleted file mode 100644 index 7fd2a3b..0000000 --- a/deps/w32-pthreads/pthread_setconcurrency.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * pthread_setconcurrency.c - * - * Description: - * This translation unit implements miscellaneous thread functions. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_setconcurrency (int level) -{ - if (level < 0) - { - return EINVAL; - } - else - { - ptw32_concurrency = level; - return 0; - } -} diff --git a/deps/w32-pthreads/pthread_setschedparam.c b/deps/w32-pthreads/pthread_setschedparam.c deleted file mode 100644 index 63025fd..0000000 --- a/deps/w32-pthreads/pthread_setschedparam.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - * sched_setschedparam.c - * - * Description: - * POSIX thread functions that deal with thread scheduling. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" -#include "sched.h" - -int -pthread_setschedparam (pthread_t thread, int policy, - const struct sched_param *param) -{ - int result; - - /* Validate the thread id. */ - result = pthread_kill (thread, 0); - if (0 != result) - { - return result; - } - - /* Validate the scheduling policy. */ - if (policy < SCHED_MIN || policy > SCHED_MAX) - { - return EINVAL; - } - - /* Ensure the policy is SCHED_OTHER. */ - if (policy != SCHED_OTHER) - { - return ENOTSUP; - } - - return (ptw32_setthreadpriority (thread, policy, param->sched_priority)); -} - - -int -ptw32_setthreadpriority (pthread_t thread, int policy, int priority) -{ - int prio; - ptw32_mcs_local_node_t threadLock; - int result = 0; - ptw32_thread_t * tp = (ptw32_thread_t *) thread.p; - - prio = priority; - - /* Validate priority level. */ - if (prio < sched_get_priority_min (policy) || - prio > sched_get_priority_max (policy)) - { - return EINVAL; - } - -#if (THREAD_PRIORITY_LOWEST > THREAD_PRIORITY_NORMAL) -/* WinCE */ -#else -/* Everything else */ - - if (THREAD_PRIORITY_IDLE < prio && THREAD_PRIORITY_LOWEST > prio) - { - prio = THREAD_PRIORITY_LOWEST; - } - else if (THREAD_PRIORITY_TIME_CRITICAL > prio - && THREAD_PRIORITY_HIGHEST < prio) - { - prio = THREAD_PRIORITY_HIGHEST; - } - -#endif - - ptw32_mcs_lock_acquire (&tp->threadLock, &threadLock); - - /* If this fails, the current priority is unchanged. */ - if (0 == SetThreadPriority (tp->threadH, prio)) - { - result = EINVAL; - } - else - { - /* - * Must record the thread's sched_priority as given, - * not as finally adjusted. - */ - tp->sched_priority = priority; - } - - ptw32_mcs_lock_release (&threadLock); - - return result; -} diff --git a/deps/w32-pthreads/pthread_setspecific.c b/deps/w32-pthreads/pthread_setspecific.c deleted file mode 100644 index 5f66cae..0000000 --- a/deps/w32-pthreads/pthread_setspecific.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * pthread_setspecific.c - * - * Description: - * POSIX thread functions which implement thread-specific data (TSD). - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_setspecific (pthread_key_t key, const void *value) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function sets the value of the thread specific - * key in the calling thread. - * - * PARAMETERS - * key - * an instance of pthread_key_t - * value - * the value to set key to - * - * - * DESCRIPTION - * This function sets the value of the thread specific - * key in the calling thread. - * - * RESULTS - * 0 successfully set value - * EAGAIN could not set value - * ENOENT SERIOUS!! - * - * ------------------------------------------------------ - */ -{ - pthread_t self; - int result = 0; - - if (key != ptw32_selfThreadKey) - { - /* - * Using pthread_self will implicitly create - * an instance of pthread_t for the current - * thread if one wasn't explicitly created - */ - self = pthread_self (); - if (self.p == NULL) - { - return ENOENT; - } - } - else - { - /* - * Resolve catch-22 of registering thread with selfThread - * key - */ - ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); - - if (sp == NULL) - { - if (value == NULL) - { - return ENOENT; - } - self = *((pthread_t *) value); - } - else - { - self = sp->ptHandle; - } - } - - result = 0; - - if (key != NULL) - { - if (self.p != NULL && key->destructor != NULL && value != NULL) - { - ptw32_mcs_local_node_t keyLock; - ptw32_mcs_local_node_t threadLock; - ptw32_thread_t * sp = (ptw32_thread_t *) self.p; - /* - * Only require associations if we have to - * call user destroy routine. - * Don't need to locate an existing association - * when setting data to NULL for WIN32 since the - * data is stored with the operating system; not - * on the association; setting assoc to NULL short - * circuits the search. - */ - ThreadKeyAssoc *assoc; - - ptw32_mcs_lock_acquire(&(key->keyLock), &keyLock); - ptw32_mcs_lock_acquire(&(sp->threadLock), &threadLock); - - assoc = (ThreadKeyAssoc *) sp->keys; - /* - * Locate existing association - */ - while (assoc != NULL) - { - if (assoc->key == key) - { - /* - * Association already exists - */ - break; - } - assoc = assoc->nextKey; - } - - /* - * create an association if not found - */ - if (assoc == NULL) - { - result = ptw32_tkAssocCreate (sp, key); - } - - ptw32_mcs_lock_release(&threadLock); - ptw32_mcs_lock_release(&keyLock); - } - - if (result == 0) - { - if (!TlsSetValue (key->key, (LPVOID) value)) - { - result = EAGAIN; - } - } - } - - return (result); -} /* pthread_setspecific */ diff --git a/deps/w32-pthreads/pthread_spin_destroy.c b/deps/w32-pthreads/pthread_spin_destroy.c deleted file mode 100644 index 39451d5..0000000 --- a/deps/w32-pthreads/pthread_spin_destroy.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * pthread_spin_destroy.c - * - * Description: - * This translation unit implements spin lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_spin_destroy (pthread_spinlock_t * lock) -{ - register pthread_spinlock_t s; - int result = 0; - - if (lock == NULL || *lock == NULL) - { - return EINVAL; - } - - if ((s = *lock) != PTHREAD_SPINLOCK_INITIALIZER) - { - if (s->interlock == PTW32_SPIN_USE_MUTEX) - { - result = pthread_mutex_destroy (&(s->u.mutex)); - } - else if ((PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED != - PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((PTW32_INTERLOCKED_LONGPTR) &s->interlock, - (PTW32_INTERLOCKED_LONG) PTW32_SPIN_INVALID, - (PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED)) - { - result = EINVAL; - } - - if (0 == result) - { - /* - * We are relying on the application to ensure that all other threads - * have finished with the spinlock before destroying it. - */ - *lock = NULL; - (void) free (s); - } - } - else - { - /* - * See notes in ptw32_spinlock_check_need_init() above also. - */ - ptw32_mcs_local_node_t node; - - ptw32_mcs_lock_acquire(&ptw32_spinlock_test_init_lock, &node); - - /* - * Check again. - */ - if (*lock == PTHREAD_SPINLOCK_INITIALIZER) - { - /* - * This is all we need to do to destroy a statically - * initialised spinlock that has not yet been used (initialised). - * If we get to here, another thread - * waiting to initialise this mutex will get an EINVAL. - */ - *lock = NULL; - } - else - { - /* - * The spinlock has been initialised while we were waiting - * so assume it's in use. - */ - result = EBUSY; - } - - ptw32_mcs_lock_release(&node); - } - - return (result); -} diff --git a/deps/w32-pthreads/pthread_spin_init.c b/deps/w32-pthreads/pthread_spin_init.c deleted file mode 100644 index 268372b..0000000 --- a/deps/w32-pthreads/pthread_spin_init.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - * pthread_spin_init.c - * - * Description: - * This translation unit implements spin lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_spin_init (pthread_spinlock_t * lock, int pshared) -{ - pthread_spinlock_t s; - int cpus = 0; - int result = 0; - - if (lock == NULL) - { - return EINVAL; - } - - if (0 != ptw32_getprocessors (&cpus)) - { - cpus = 1; - } - - if (cpus > 1) - { - if (pshared == PTHREAD_PROCESS_SHARED) - { - /* - * Creating spinlock that can be shared between - * processes. - */ -#if _POSIX_THREAD_PROCESS_SHARED >= 0 - - /* - * Not implemented yet. - */ - -#error ERROR [__FILE__, line __LINE__]: Process shared spin locks are not supported yet. - -#else - - return ENOSYS; - -#endif /* _POSIX_THREAD_PROCESS_SHARED */ - - } - } - - s = (pthread_spinlock_t) calloc (1, sizeof (*s)); - - if (s == NULL) - { - return ENOMEM; - } - - if (cpus > 1) - { - s->u.cpus = cpus; - s->interlock = PTW32_SPIN_UNLOCKED; - } - else - { - pthread_mutexattr_t ma; - result = pthread_mutexattr_init (&ma); - - if (0 == result) - { - ma->pshared = pshared; - result = pthread_mutex_init (&(s->u.mutex), &ma); - if (0 == result) - { - s->interlock = PTW32_SPIN_USE_MUTEX; - } - } - (void) pthread_mutexattr_destroy (&ma); - } - - if (0 == result) - { - *lock = s; - } - else - { - (void) free (s); - *lock = NULL; - } - - return (result); -} diff --git a/deps/w32-pthreads/pthread_spin_lock.c b/deps/w32-pthreads/pthread_spin_lock.c deleted file mode 100644 index 67d6e0c..0000000 --- a/deps/w32-pthreads/pthread_spin_lock.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * pthread_spin_lock.c - * - * Description: - * This translation unit implements spin lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_spin_lock (pthread_spinlock_t * lock) -{ - register pthread_spinlock_t s; - - if (NULL == lock || NULL == *lock) - { - return (EINVAL); - } - - if (*lock == PTHREAD_SPINLOCK_INITIALIZER) - { - int result; - - if ((result = ptw32_spinlock_check_need_init (lock)) != 0) - { - return (result); - } - } - - s = *lock; - - while ((PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED == - PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((PTW32_INTERLOCKED_LONGPTR) &s->interlock, - (PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED, - (PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED)) - { - } - - if (s->interlock == PTW32_SPIN_LOCKED) - { - return 0; - } - else if (s->interlock == PTW32_SPIN_USE_MUTEX) - { - return pthread_mutex_lock (&(s->u.mutex)); - } - - return EINVAL; -} diff --git a/deps/w32-pthreads/pthread_spin_trylock.c b/deps/w32-pthreads/pthread_spin_trylock.c deleted file mode 100644 index a300773..0000000 --- a/deps/w32-pthreads/pthread_spin_trylock.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * pthread_spin_trylock.c - * - * Description: - * This translation unit implements spin lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_spin_trylock (pthread_spinlock_t * lock) -{ - register pthread_spinlock_t s; - - if (NULL == lock || NULL == *lock) - { - return (EINVAL); - } - - if (*lock == PTHREAD_SPINLOCK_INITIALIZER) - { - int result; - - if ((result = ptw32_spinlock_check_need_init (lock)) != 0) - { - return (result); - } - } - - s = *lock; - - switch ((long) - PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((PTW32_INTERLOCKED_LONGPTR) &s->interlock, - (PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED, - (PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED)) - { - case PTW32_SPIN_UNLOCKED: - return 0; - case PTW32_SPIN_LOCKED: - return EBUSY; - case PTW32_SPIN_USE_MUTEX: - return pthread_mutex_trylock (&(s->u.mutex)); - } - - return EINVAL; -} diff --git a/deps/w32-pthreads/pthread_spin_unlock.c b/deps/w32-pthreads/pthread_spin_unlock.c deleted file mode 100644 index cfb2428..0000000 --- a/deps/w32-pthreads/pthread_spin_unlock.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * pthread_spin_unlock.c - * - * Description: - * This translation unit implements spin lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -pthread_spin_unlock (pthread_spinlock_t * lock) -{ - register pthread_spinlock_t s; - - if (NULL == lock || NULL == *lock) - { - return (EINVAL); - } - - s = *lock; - - if (s == PTHREAD_SPINLOCK_INITIALIZER) - { - return EPERM; - } - - switch ((long) - PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((PTW32_INTERLOCKED_LONGPTR) &s->interlock, - (PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED, - (PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED)) - { - case PTW32_SPIN_LOCKED: - case PTW32_SPIN_UNLOCKED: - return 0; - case PTW32_SPIN_USE_MUTEX: - return pthread_mutex_unlock (&(s->u.mutex)); - } - - return EINVAL; -} diff --git a/deps/w32-pthreads/pthread_testcancel.c b/deps/w32-pthreads/pthread_testcancel.c deleted file mode 100644 index 1cccc33..0000000 --- a/deps/w32-pthreads/pthread_testcancel.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * pthread_testcancel.c - * - * Description: - * POSIX thread functions related to thread cancellation. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -void -pthread_testcancel (void) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function creates a deferred cancellation point - * in the calling thread. The call has no effect if the - * current cancelability state is - * PTHREAD_CANCEL_DISABLE - * - * PARAMETERS - * N/A - * - * - * DESCRIPTION - * This function creates a deferred cancellation point - * in the calling thread. The call has no effect if the - * current cancelability state is - * PTHREAD_CANCEL_DISABLE - * - * NOTES: - * 1) Cancellation is asynchronous. Use pthread_join - * to wait for termination of thread if necessary - * - * RESULTS - * N/A - * - * ------------------------------------------------------ - */ -{ - ptw32_mcs_local_node_t stateLock; - pthread_t self = pthread_self (); - ptw32_thread_t * sp = (ptw32_thread_t *) self.p; - - if (sp == NULL) - { - return; - } - - /* - * Pthread_cancel() will have set sp->state to PThreadStateCancelPending - * and set an event, so no need to enter kernel space if - * sp->state != PThreadStateCancelPending - that only slows us down. - */ - if (sp->state != PThreadStateCancelPending) - { - return; - } - - ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); - - if (sp->cancelState != PTHREAD_CANCEL_DISABLE) - { - ResetEvent(sp->cancelEvent); - sp->state = PThreadStateCanceling; - sp->cancelState = PTHREAD_CANCEL_DISABLE; - ptw32_mcs_lock_release (&stateLock); - ptw32_throw (PTW32_EPS_CANCEL); - /* Never returns here */ - } - - ptw32_mcs_lock_release (&stateLock); -} /* pthread_testcancel */ diff --git a/deps/w32-pthreads/pthread_timechange_handler_np.c b/deps/w32-pthreads/pthread_timechange_handler_np.c deleted file mode 100644 index 0145df2..0000000 --- a/deps/w32-pthreads/pthread_timechange_handler_np.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * pthread_timechange_handler_np.c - * - * Description: - * This translation unit implements miscellaneous thread functions. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -/* - * Notes on handling system time adjustments (especially negative ones). - * --------------------------------------------------------------------- - * - * This solution was suggested by Alexander Terekhov, but any errors - * in the implementation are mine - [Ross Johnson] - * - * 1) The problem: threads doing a timedwait on a CV may expect to timeout - * at a specific absolute time according to a system timer. If the - * system clock is adjusted backwards then those threads sleep longer than - * expected. Also, pthreads-win32 converts absolute times to intervals in - * order to make use of the underlying Win32, and so waiting threads may - * awake before their proper abstimes. - * - * 2) We aren't able to distinquish between threads on timed or untimed waits, - * so we wake them all at the time of the adjustment so that they can - * re-evaluate their conditions and re-compute their timeouts. - * - * 3) We rely on correctly written applications for this to work. Specifically, - * they must be able to deal properly with spurious wakeups. That is, - * they must re-test their condition upon wakeup and wait again if - * the condition is not satisfied. - */ - -void * -pthread_timechange_handler_np (void *arg) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * Broadcasts all CVs to force re-evaluation and - * new timeouts if required. - * - * PARAMETERS - * NONE - * - * - * DESCRIPTION - * Broadcasts all CVs to force re-evaluation and - * new timeouts if required. - * - * This routine may be passed directly to pthread_create() - * as a new thread in order to run asynchronously. - * - * - * RESULTS - * 0 successfully broadcast all CVs - * EAGAIN Not all CVs were broadcast - * - * ------------------------------------------------------ - */ -{ - int result = 0; - pthread_cond_t cv; - ptw32_mcs_local_node_t node; - - ptw32_mcs_lock_acquire(&ptw32_cond_list_lock, &node); - - cv = ptw32_cond_list_head; - - while (cv != NULL && 0 == result) - { - result = pthread_cond_broadcast (&cv); - cv = cv->next; - } - - ptw32_mcs_lock_release(&node); - - return (void *) (size_t) (result != 0 ? EAGAIN : 0); -} diff --git a/deps/w32-pthreads/pthread_win32_attach_detach_np.c b/deps/w32-pthreads/pthread_win32_attach_detach_np.c deleted file mode 100644 index d17cabc..0000000 --- a/deps/w32-pthreads/pthread_win32_attach_detach_np.c +++ /dev/null @@ -1,258 +0,0 @@ -/* - * pthread_win32_attach_detach_np.c - * - * Description: - * This translation unit implements non-portable thread functions. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -#include - -/* - * Handle to quserex.dll - */ -static HINSTANCE ptw32_h_quserex; - -BOOL -pthread_win32_process_attach_np () -{ - TCHAR QuserExDLLPathBuf[1024]; - BOOL result = TRUE; - - result = ptw32_processInitialize (); - -#if defined(_UWIN) - pthread_count++; -#endif - -#if defined(__GNUC__) - ptw32_features = 0; -#else - /* - * This is obsolete now. - */ - ptw32_features = PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE; -#endif - - /* - * Load QUSEREX.DLL and try to get address of QueueUserAPCEx. - * Because QUSEREX.DLL requires a driver to be installed we will - * assume the DLL is in the system directory. - * - * This should take care of any security issues. - */ -#if defined(__GNUC__) || _MSC_VER < 1400 - if(GetSystemDirectory(QuserExDLLPathBuf, sizeof(QuserExDLLPathBuf))) - { - (void) strncat(QuserExDLLPathBuf, - "\\QUSEREX.DLL", - sizeof(QuserExDLLPathBuf) - strlen(QuserExDLLPathBuf) - 1); - ptw32_h_quserex = LoadLibrary(QuserExDLLPathBuf); - } -#else - /* strncat is secure - this is just to avoid a warning */ - if(GetSystemDirectory(QuserExDLLPathBuf, sizeof(QuserExDLLPathBuf) / sizeof(TCHAR)) && - 0 == _tcsncat_s(QuserExDLLPathBuf, sizeof(QuserExDLLPathBuf) / sizeof(TCHAR), TEXT("\\QUSEREX.DLL"), 12)) - { - ptw32_h_quserex = LoadLibrary(QuserExDLLPathBuf); - } -#endif - - if (ptw32_h_quserex != NULL) - { - ptw32_register_cancelation = (DWORD (*)(PAPCFUNC, HANDLE, DWORD)) -#if defined(NEED_UNICODE_CONSTS) - GetProcAddress (ptw32_h_quserex, - (const TCHAR *) TEXT ("QueueUserAPCEx")); -#else - GetProcAddress (ptw32_h_quserex, (LPCSTR) "QueueUserAPCEx"); -#endif - } - - if (NULL == ptw32_register_cancelation) - { - ptw32_register_cancelation = ptw32_RegisterCancelation; - - if (ptw32_h_quserex != NULL) - { - (void) FreeLibrary (ptw32_h_quserex); - } - ptw32_h_quserex = 0; - } - else - { - /* Initialise QueueUserAPCEx */ - BOOL (*queue_user_apc_ex_init) (VOID); - - queue_user_apc_ex_init = (BOOL (*)(VOID)) -#if defined(NEED_UNICODE_CONSTS) - GetProcAddress (ptw32_h_quserex, - (const TCHAR *) TEXT ("QueueUserAPCEx_Init")); -#else - GetProcAddress (ptw32_h_quserex, (LPCSTR) "QueueUserAPCEx_Init"); -#endif - - if (queue_user_apc_ex_init == NULL || !queue_user_apc_ex_init ()) - { - ptw32_register_cancelation = ptw32_RegisterCancelation; - - (void) FreeLibrary (ptw32_h_quserex); - ptw32_h_quserex = 0; - } - } - - if (ptw32_h_quserex) - { - ptw32_features |= PTW32_ALERTABLE_ASYNC_CANCEL; - } - - return result; -} - - -BOOL -pthread_win32_process_detach_np () -{ - if (ptw32_processInitialized) - { - ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); - - if (sp != NULL) - { - /* - * Detached threads have their resources automatically - * cleaned up upon exit (others must be 'joined'). - */ - if (sp->detachState == PTHREAD_CREATE_DETACHED) - { - ptw32_threadDestroy (sp->ptHandle); - TlsSetValue (ptw32_selfThreadKey->key, NULL); - } - } - - /* - * The DLL is being unmapped from the process's address space - */ - ptw32_processTerminate (); - - if (ptw32_h_quserex) - { - /* Close QueueUserAPCEx */ - BOOL (*queue_user_apc_ex_fini) (VOID); - - queue_user_apc_ex_fini = (BOOL (*)(VOID)) -#if defined(NEED_UNICODE_CONSTS) - GetProcAddress (ptw32_h_quserex, - (const TCHAR *) TEXT ("QueueUserAPCEx_Fini")); -#else - GetProcAddress (ptw32_h_quserex, (LPCSTR) "QueueUserAPCEx_Fini"); -#endif - - if (queue_user_apc_ex_fini != NULL) - { - (void) queue_user_apc_ex_fini (); - } - (void) FreeLibrary (ptw32_h_quserex); - } - } - - return TRUE; -} - -BOOL -pthread_win32_thread_attach_np () -{ - return TRUE; -} - -BOOL -pthread_win32_thread_detach_np () -{ - if (ptw32_processInitialized) - { - /* - * Don't use pthread_self() - to avoid creating an implicit POSIX thread handle - * unnecessarily. - */ - ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); - - if (sp != NULL) // otherwise Win32 thread with no implicit POSIX handle. - { - ptw32_mcs_local_node_t stateLock; - ptw32_callUserDestroyRoutines (sp->ptHandle); - - ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); - sp->state = PThreadStateLast; - /* - * If the thread is joinable at this point then it MUST be joined - * or detached explicitly by the application. - */ - ptw32_mcs_lock_release (&stateLock); - - /* - * Robust Mutexes - */ - while (sp->robustMxList != NULL) - { - pthread_mutex_t mx = sp->robustMxList->mx; - ptw32_robust_mutex_remove(&mx, sp); - (void) PTW32_INTERLOCKED_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR)&mx->robustNode->stateInconsistent, - (PTW32_INTERLOCKED_LONG)-1); - /* - * If there are no waiters then the next thread to block will - * sleep, wakeup immediately and then go back to sleep. - * See pthread_mutex_lock.c. - */ - SetEvent(mx->event); - } - - - if (sp->detachState == PTHREAD_CREATE_DETACHED) - { - ptw32_threadDestroy (sp->ptHandle); - - TlsSetValue (ptw32_selfThreadKey->key, NULL); - } - } - } - - return TRUE; -} - -BOOL -pthread_win32_test_features_np (int feature_mask) -{ - return ((ptw32_features & feature_mask) == feature_mask); -} diff --git a/deps/w32-pthreads/ptw32_MCS_lock.c b/deps/w32-pthreads/ptw32_MCS_lock.c deleted file mode 100644 index 5eec5ce..0000000 --- a/deps/w32-pthreads/ptw32_MCS_lock.c +++ /dev/null @@ -1,278 +0,0 @@ -/* - * ptw32_MCS_lock.c - * - * Description: - * This translation unit implements queue-based locks. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -/* - * About MCS locks: - * - * MCS locks are queue-based locks, where the queue nodes are local to the - * thread. The 'lock' is nothing more than a global pointer that points to - * the last node in the queue, or is NULL if the queue is empty. - * - * Originally designed for use as spin locks requiring no kernel resources - * for synchronisation or blocking, the implementation below has adapted - * the MCS spin lock for use as a general mutex that will suspend threads - * when there is lock contention. - * - * Because the queue nodes are thread-local, most of the memory read/write - * operations required to add or remove nodes from the queue do not trigger - * cache-coherence updates. - * - * Like 'named' mutexes, MCS locks consume system resources transiently - - * they are able to acquire and free resources automatically - but MCS - * locks do not require any unique 'name' to identify the lock to all - * threads using it. - * - * Usage of MCS locks: - * - * - you need a global ptw32_mcs_lock_t instance initialised to 0 or NULL. - * - you need a local thread-scope ptw32_mcs_local_node_t instance, which - * may serve several different locks but you need at least one node for - * every lock held concurrently by a thread. - * - * E.g.: - * - * ptw32_mcs_lock_t lock1 = 0; - * ptw32_mcs_lock_t lock2 = 0; - * - * void *mythread(void *arg) - * { - * ptw32_mcs_local_node_t node; - * - * ptw32_mcs_acquire (&lock1, &node); - * ptw32_mcs_lock_release (&node); - * - * ptw32_mcs_lock_acquire (&lock2, &node); - * ptw32_mcs_lock_release (&node); - * { - * ptw32_mcs_local_node_t nodex; - * - * ptw32_mcs_lock_acquire (&lock1, &node); - * ptw32_mcs_lock_acquire (&lock2, &nodex); - * - * ptw32_mcs_lock_release (&nodex); - * ptw32_mcs_lock_release (&node); - * } - * return (void *)0; - * } - */ - -#include "pthread.h" -#include "sched.h" -#include "implement.h" - -/* - * ptw32_mcs_flag_set -- notify another thread about an event. - * - * Set event if an event handle has been stored in the flag, and - * set flag to -1 otherwise. Note that -1 cannot be a valid handle value. - */ -INLINE void -ptw32_mcs_flag_set (HANDLE * flag) -{ - HANDLE e = (HANDLE)(PTW32_INTERLOCKED_SIZE)PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( - (PTW32_INTERLOCKED_SIZEPTR)flag, - (PTW32_INTERLOCKED_SIZE)-1, - (PTW32_INTERLOCKED_SIZE)0); - if ((HANDLE)0 != e) - { - /* another thread has already stored an event handle in the flag */ - SetEvent(e); - } -} - -/* - * ptw32_mcs_flag_set -- wait for notification from another. - * - * Store an event handle in the flag and wait on it if the flag has not been - * set, and proceed without creating an event otherwise. - */ -INLINE void -ptw32_mcs_flag_wait (HANDLE * flag) -{ - if ((PTW32_INTERLOCKED_LONG)0 == - PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE((PTW32_INTERLOCKED_SIZEPTR)flag, - (PTW32_INTERLOCKED_SIZE)0)) /* MBR fence */ - { - /* the flag is not set. create event. */ - - HANDLE e = CreateEvent(NULL, PTW32_FALSE, PTW32_FALSE, NULL); - - if ((PTW32_INTERLOCKED_SIZE)0 == PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( - (PTW32_INTERLOCKED_SIZEPTR)flag, - (PTW32_INTERLOCKED_SIZE)e, - (PTW32_INTERLOCKED_SIZE)0)) - { - /* stored handle in the flag. wait on it now. */ - WaitForSingleObject(e, INFINITE); - } - - CloseHandle(e); - } -} - -/* - * ptw32_mcs_lock_acquire -- acquire an MCS lock. - * - * See: - * J. M. Mellor-Crummey and M. L. Scott. - * Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors. - * ACM Transactions on Computer Systems, 9(1):21-65, Feb. 1991. - */ -#if defined(PTW32_BUILD_INLINED) -INLINE -#endif /* PTW32_BUILD_INLINED */ -void -ptw32_mcs_lock_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node) -{ - ptw32_mcs_local_node_t *pred; - - node->lock = lock; - node->nextFlag = 0; - node->readyFlag = 0; - node->next = 0; /* initially, no successor */ - - /* queue for the lock */ - pred = (ptw32_mcs_local_node_t *)PTW32_INTERLOCKED_EXCHANGE_PTR((PTW32_INTERLOCKED_PVOID_PTR)lock, - (PTW32_INTERLOCKED_PVOID)node); - - if (0 != pred) - { - /* the lock was not free. link behind predecessor. */ - pred->next = node; - ptw32_mcs_flag_set(&pred->nextFlag); - ptw32_mcs_flag_wait(&node->readyFlag); - } -} - -/* - * ptw32_mcs_lock_release -- release an MCS lock. - * - * See: - * J. M. Mellor-Crummey and M. L. Scott. - * Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors. - * ACM Transactions on Computer Systems, 9(1):21-65, Feb. 1991. - */ -#if defined(PTW32_BUILD_INLINED) -INLINE -#endif /* PTW32_BUILD_INLINED */ -void -ptw32_mcs_lock_release (ptw32_mcs_local_node_t * node) -{ - ptw32_mcs_lock_t *lock = node->lock; - ptw32_mcs_local_node_t *next = - (ptw32_mcs_local_node_t *) - PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE((PTW32_INTERLOCKED_SIZEPTR)&node->next, (PTW32_INTERLOCKED_SIZE)0); /* MBR fence */ - - if (0 == next) - { - /* no known successor */ - - if (node == (ptw32_mcs_local_node_t *) - PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR((PTW32_INTERLOCKED_PVOID_PTR)lock, - (PTW32_INTERLOCKED_PVOID)0, - (PTW32_INTERLOCKED_PVOID)node)) - { - /* no successor, lock is free now */ - return; - } - - /* A successor has started enqueueing behind us so wait for them to link to us */ - ptw32_mcs_flag_wait(&node->nextFlag); - next = (ptw32_mcs_local_node_t *) - PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE((PTW32_INTERLOCKED_SIZEPTR)&node->next, (PTW32_INTERLOCKED_SIZE)0); /* MBR fence */ - } - - /* pass the lock */ - ptw32_mcs_flag_set(&next->readyFlag); -} - -/* - * ptw32_mcs_lock_try_acquire - */ -#if defined(PTW32_BUILD_INLINED) -INLINE -#endif /* PTW32_BUILD_INLINED */ -int -ptw32_mcs_lock_try_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node) -{ - node->lock = lock; - node->nextFlag = 0; - node->readyFlag = 0; - node->next = 0; /* initially, no successor */ - - return ((PTW32_INTERLOCKED_PVOID)PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR((PTW32_INTERLOCKED_PVOID_PTR)lock, - (PTW32_INTERLOCKED_PVOID)node, - (PTW32_INTERLOCKED_PVOID)0) - == (PTW32_INTERLOCKED_PVOID)0) ? 0 : EBUSY; -} - -/* - * ptw32_mcs_node_transfer -- move an MCS lock local node, usually from thread - * space to, for example, global space so that another thread can release - * the lock on behalf of the current lock owner. - * - * Example: used in pthread_barrier_wait where we want the last thread out of - * the barrier to release the lock owned by the last thread to enter the barrier - * (the one that releases all threads but not necessarily the last to leave). - * - * Should only be called by the thread that has the lock. - */ -#if defined(PTW32_BUILD_INLINED) -INLINE -#endif /* PTW32_BUILD_INLINED */ -void -ptw32_mcs_node_transfer (ptw32_mcs_local_node_t * new_node, ptw32_mcs_local_node_t * old_node) -{ - new_node->lock = old_node->lock; - new_node->nextFlag = 0; /* Not needed - used only in initial Acquire */ - new_node->readyFlag = 0; /* Not needed - we were waiting on this */ - new_node->next = 0; - - if ((ptw32_mcs_local_node_t *)PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR((PTW32_INTERLOCKED_PVOID_PTR)new_node->lock, - (PTW32_INTERLOCKED_PVOID)new_node, - (PTW32_INTERLOCKED_PVOID)old_node) - != old_node) - { - /* - * A successor has queued after us, so wait for them to link to us - */ - while (old_node->next == 0) - { - sched_yield(); - } - new_node->next = old_node->next; - } -} diff --git a/deps/w32-pthreads/ptw32_OLL_lock.c b/deps/w32-pthreads/ptw32_OLL_lock.c deleted file mode 100644 index b92b8fa..0000000 --- a/deps/w32-pthreads/ptw32_OLL_lock.c +++ /dev/null @@ -1,734 +0,0 @@ -/* - * ptw32_OLL_lock.c - * - * Description: - * This translation unit implements extended reader/writer queue-based locks. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -/* - * About the OLL lock (Scalable Reader-Writer Lock): - * - * OLL locks are queue-based locks similar to the MCS queue lock, where the queue - * nodes are local to the thread but where reader threads can enter the critical - * section immediately without going through a central guard lock if there are - * already readers holding the lock. - * - * Covered by United States Patent Application 20100241774 (Oracle) - */ - -#include "pthread.h" -#include "sched.h" -#include "implement.h" - -/* - * C-SNZI support - */ -typedef union ptw32_oll_counter_t_ ptw32_oll_counter_t; -typedef struct ptw32_oll_snziRoot_t_ ptw32_oll_snziRoot_t; -typedef struct ptw32_oll_snziNode_t_ ptw32_oll_snziNode_t; -typedef union ptw32_oll_snziNodeOrRoot_t_ ptw32_oll_snziNodeOrRoot_t; -typedef struct ptw32_oll_queryResult_t_ ptw32_oll_queryResult_t; -typedef struct ptw32_oll_ticket_t_ ptw32_oll_ticket_t; -typedef struct ptw32_oll_csnzi_t_ ptw32_oll_csnzi_t; - -enum -{ - ptw32_archWidth = sizeof(size_t)*8, - ptw32_oll_countWidth = ptw32_archWidth-2 -}; - -#define PTW32_OLL_MAXREADERS (((size_t)2<<(ptw32_oll_countWidth-1))-1) - -union ptw32_oll_counter_t_ -{ - size_t word : ptw32_archWidth; - struct - { - /* - * This needs to be a single word - * - * ------------------------------------ - * | STATE | ROOT | COUNT (readers) | - * ------------------------------------ - * 63 / 31 62 / 30 61 / 29 .. 0 - */ - size_t count : ptw32_oll_countWidth; - size_t root : 1; /* ROOT or NODE */ - size_t state : 1; /* OPEN or CLOSED (root only) */ - } internal; -}; - -struct ptw32_oll_snziRoot_t_ -{ - /* - * "counter" must be at same offset in both - * ptw32_oll_snziNode_t and ptw32_oll_snziRoot_t - */ - ptw32_oll_counter_t counter; -}; - -enum -{ - ptw32_oll_snziRoot_open = 0, - ptw32_oll_snziRoot_closed = 1 -}; - -enum -{ - ptw32_oll_snzi_root = 0, - ptw32_oll_snzi_node = 1 -}; - -/* - * Some common SNZI root whole-word states that can be used to set or compare - * root words with a single operation. - */ -ptw32_oll_snziRoot_t ptw32_oll_snziRoot_openAndZero = {.counter.internal.count = 0, - .counter.internal.root = ptw32_oll_snzi_root, - .counter.internal.state = ptw32_oll_snziRoot_open}; -ptw32_oll_snziRoot_t ptw32_oll_snziRoot_closedAndZero = {.counter.internal.count = 0, - .counter.internal.root = ptw32_oll_snzi_root, - .counter.internal.state = ptw32_oll_snziRoot_closed}; - -struct ptw32_oll_queryResult_t_ -{ - BOOL nonZero; - BOOL open; -}; - -union ptw32_oll_snziNodeOrRoot_t_ -{ - ptw32_oll_snziRoot_t* rootPtr; - ptw32_oll_snziNode_t* nodePtr; -}; - -struct ptw32_oll_snziNode_t_ -{ - /* "counter" must be at same offset in both - * ptw32_oll_snziNode_t and ptw32_oll_snziRoot_t - */ - ptw32_oll_counter_t counter; - ptw32_oll_snziNodeOrRoot_t parentPtr; -}; - -struct ptw32_oll_ticket_t_ -{ - ptw32_oll_snziNodeOrRoot_t snziNodeOrRoot; -}; - -ptw32_oll_ticket_t ptw32_oll_ticket_null = {NULL}; - -struct ptw32_oll_csnzi_t_ -{ - ptw32_oll_snziRoot_t proxyRoot; - ptw32_oll_snziNode_t leafs[]; -}; - -/* - * FOLL lock support - */ - -typedef struct ptw32_foll_node_t_ ptw32_foll_node_t; -typedef struct ptw32_foll_local_t_ ptw32_foll_local_t; -typedef struct ptw32_foll_rwlock_t_ ptw32_foll_rwlock_t; - -enum -{ - ptw32_srwl_reader, - ptw32_srwl_writer -}; - -enum -{ - ptw32_srwl_free, - ptw32_srwl_in_use -}; - -struct ptw32_foll_node_t_ -{ - ptw32_foll_node_t* qNextPtr; - ptw32_oll_csnzi_t* csnziPtr; - ptw32_foll_node_t* nextPtr; - int kind; - int allocState; - BOOL spin; -}; - -struct ptw32_foll_local_t_ -{ - ptw32_foll_node_t* rNodePtr; // Default read node. Immutable - ptw32_foll_node_t* wNodePtr; // Write node. Immutable. - ptw32_foll_node_t* departFromPtr; // List node we last arrived at. - ptw32_oll_ticket_t ticket; // C-SNZI ticket -}; - -struct ptw32_foll_rwlock_t_ -{ - ptw32_foll_node_t* tailPtr; - ptw32_foll_node_t* rNodesPtr; // Head of reader node -}; - -/* - * ShouldArriveAtTree() returns true if: - * the compare_exchange in Arrive() fails too often under read access; or - * ?? - * Note that this is measured across all access to - * this lock, not just this attempt, so that highly - * read-contended locks will use C-SNZI. Lightly - * read-contended locks can reduce memory usage and some - * processing by using the root directly. - */ -BOOL -ptw32_oll_ShouldArriveAtTree() -{ - return PTW32_FALSE; -} - -size_t -ptw32_oll_GetLeafForThread() -{ - return 0; -} - -/* - * Only readers call ptw32_oll_Arrive() - * - * Checks whether the C-SNZI state is OPEN, and if so, - * increments the surplus of the C-SNZI by either directly - * arriving at the root node, or calling TreeArrive on one - * of the leaf nodes. Returns a ticket pointing to the node - * that was arrived at. If the state is CLOSED, makes no - * change and returns a ticket that contains no pointer. - */ -ptw32_oll_ticket_t -ptw32_oll_Arrive(ptw32_oll_csnzi_t* csnzi) -{ - for (;;) - { - ptw32_oll_ticket_t ticket; - ptw32_oll_snziRoot_t oldProxy = csnzi->proxyRoot; - if (oldProxy.counter.internal.state != ptw32_oll_snziRoot_open) - { - ticket.snziNodeOrRoot.rootPtr = (ptw32_oll_snziRoot_t*)NULL; - return ticket; - } - if (!ptw32_oll_ShouldArriveAtTree()) - { - ptw32_oll_snziRoot_t newProxy = oldProxy; - newProxy.counter.internal.count++; - if (PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( - (PTW32_INTERLOCKED_SIZEPTR)&csnzi->proxyRoot.counter, - (PTW32_INTERLOCKED_SIZE)newProxy.counter.word, - (PTW32_INTERLOCKED_SIZE)oldProxy.counter.word) - == (PTW32_INTERLOCKED_SIZE)oldProxy.counter.word) - { - /* Exchange successful */ - ticket.snziNodeOrRoot.rootPtr = &csnzi->proxyRoot; - return ticket; - } - } - else - { - ptw32_oll_snziNode_t* leafPtr = &csnzi->leafs[ptw32_oll_GetLeafForThread()]; - ticket.snziNodeOrRoot.nodePtr = (ptw32_oll_TreeArrive(leafPtr) ? leafPtr : (ptw32_oll_snziNode_t*)NULL); - return ticket; - } - } -} - -/* - * Decrements the C-SNZI surplus. Returns false iff the - * resulting state is CLOSED and the surplus is zero. - * Ticket must have been returned by an arrival. Must have - * received this ticket from Arrive more times than Depart - * has been called with the ticket. (Thus, the surplus - * must be greater than zero.) - */ -BOOL -ptw32_oll_Depart(ptw32_oll_ticket_t ticket) -{ - return ptw32_oll_TreeDepart(ticket.snziNodeOrRoot); -} - -/* - * Increments the C-SNZI surplus and returns true if the - * C-SNZI is open or has a surplus. Calls TreeArrive - * recursively on the nodeā€™s parent if needed. - * Otherwise, returns false without making any changes. - */ -BOOL -ptw32_oll_TreeArrive(ptw32_oll_snziNodeOrRoot_t snziNodeOrRoot) -{ - if (snziNodeOrRoot.nodePtr->counter.internal.root != ptw32_oll_snzi_root) - { - /* Non-root node */ - ptw32_oll_counter_t newCounter, oldCounter; - BOOL arrivedAtParent = PTW32_FALSE; - do - { - oldCounter = snziNodeOrRoot.nodePtr->counter; - if (0 == oldCounter.internal.count && !arrivedAtParent) - { - if (ptw32_oll_TreeArrive(snziNodeOrRoot.nodePtr->parentPtr)) - arrivedAtParent = PTW32_TRUE; - else - return PTW32_FALSE; - } - newCounter = oldCounter; - newCounter.internal.count++; - } while (PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( - (PTW32_INTERLOCKED_SIZEPTR)&snziNodeOrRoot.nodePtr->counter, - (PTW32_INTERLOCKED_SIZE)newCounter.word, - (PTW32_INTERLOCKED_SIZE)oldCounter.word) - != (PTW32_INTERLOCKED_SIZE)oldCounter.word); - if (newCounter.internal.count != 0 && arrivedAtParent) - ptw32_oll_TreeDepart(snziNodeOrRoot.nodePtr->parentPtr); - return PTW32_TRUE; - } - else - { - /* Root node */ - ptw32_oll_snziRoot_t newRoot, oldRoot; - do - { - oldRoot = *(ptw32_oll_snziRoot_t*)snziNodeOrRoot.rootPtr; - if (oldRoot.counter.word == ptw32_oll_snziRoot_closedAndZero.counter.word) - return PTW32_FALSE; - newRoot = oldRoot; - newRoot.counter.internal.count++; - } while (PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( - (PTW32_INTERLOCKED_SIZEPTR)&snziNodeOrRoot.rootPtr->counter, - (PTW32_INTERLOCKED_SIZE)newRoot.counter.word, - (PTW32_INTERLOCKED_SIZE)oldRoot.counter.word) - != (PTW32_INTERLOCKED_SIZE)oldRoot.counter.word); - return PTW32_TRUE; - } -} - -/* - * Decrements the C-SNZI surplus, calling TreeDepart - * recursively on the nodeā€™s parent if needed. Returns - * false iff the resulting state of the C-SNZI is CLOSED - * and the surplus is zero. Otherwise, returns true. - */ -BOOL -ptw32_oll_TreeDepart(ptw32_oll_snziNodeOrRoot_t snziNodeOrRoot) -{ - if (snziNodeOrRoot.nodePtr->counter.internal.root != ptw32_oll_snzi_root) - { - /* Non-root node */ - ptw32_oll_counter_t newCounter, oldCounter; - do - { - newCounter = oldCounter = snziNodeOrRoot.nodePtr->counter; - newCounter.internal.count--; - } while (PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( - (PTW32_INTERLOCKED_SIZEPTR)&snziNodeOrRoot.nodePtr->counter, - (PTW32_INTERLOCKED_SIZE)newCounter.word, - (PTW32_INTERLOCKED_SIZE)oldCounter.word) - != (PTW32_INTERLOCKED_SIZE)oldCounter.word); - return (0 == newCounter.internal.count) - ? ptw32_oll_TreeDepart(snziNodeOrRoot.nodePtr->parentPtr) - : PTW32_TRUE; - } - else - { - /* Root node */ - ptw32_oll_snziRoot_t newRoot, oldRoot; - do - { - newRoot = oldRoot = *(ptw32_oll_snziRoot_t*)snziNodeOrRoot.rootPtr; - newRoot.counter.internal.count--; - } while (PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( - (PTW32_INTERLOCKED_SIZEPTR)&snziNodeOrRoot.rootPtr->counter, - (PTW32_INTERLOCKED_SIZE)newRoot.counter.word, - (PTW32_INTERLOCKED_SIZE)oldRoot.counter.word) - != (PTW32_INTERLOCKED_SIZE)oldRoot.counter.word); - return (newRoot.counter.word != ptw32_oll_snziRoot_closedAndZero.counter.word); - } -} - -/* - * Opens a C-SNZI object. Requires C-SNZI state to be - * CLOSED and the surplus to be zero. - */ -void -ptw32_oll_Open(ptw32_oll_csnzi_t* csnziPtr) -{ - csnziPtr->proxyRoot = ptw32_oll_snziRoot_openAndZero; -} - -/* - * Opens a C-SNZI object while atomically performing count - * arrivals. Requires C-SNZI state to be CLOSED and - * the surplus to be zero. - */ -void -ptw32_oll_OpenWithArrivals(ptw32_oll_csnzi_t* csnziPtr, size_t count, BOOL close) -{ - csnziPtr->proxyRoot.counter.internal.count = count; - csnziPtr->proxyRoot.counter.internal.state = (close ? ptw32_oll_snziRoot_closed : ptw32_oll_snziRoot_open); -} - -/* - * Closes a C-SNZI object. Returns true iff the C-SNZI - * state changed from OPEN to CLOSED and the surplus is - * zero. - */ -BOOL -ptw32_oll_Close(ptw32_oll_csnzi_t* csnziPtr) -{ - ptw32_oll_snziRoot_t newProxy, oldProxy; - do - { - oldProxy = csnziPtr->proxyRoot; - if (oldProxy.counter.internal.state != ptw32_oll_snziRoot_open) - { - return PTW32_FALSE; - } - newProxy = oldProxy; - newProxy.counter.internal.state = ptw32_oll_snziRoot_closed; - } while (PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( - (PTW32_INTERLOCKED_SIZEPTR)&csnziPtr->proxyRoot.counter, - (PTW32_INTERLOCKED_SIZE)newProxy.counter.word, - (PTW32_INTERLOCKED_SIZE)oldProxy.counter.word) - != (PTW32_INTERLOCKED_SIZE)oldProxy.counter.word); - return (newProxy.counter.word == ptw32_oll_snziRoot_closedAndZero.counter.word); -} - -/* - * Closes a C-SNZI if its surplus is zero. Otherwise, does - * nothing. Returns true iff C-SNZI state changed from - * OPEN to CLOSED. - */ -BOOL -ptw32_oll_CloseIfEmpty(ptw32_oll_csnzi_t* csnziPtr) -{ - ptw32_oll_snziRoot_t newProxy, oldProxy; - do - { - oldProxy = csnziPtr->proxyRoot; - if (oldProxy.counter.word != ptw32_oll_snziRoot_openAndZero.counter.word) - { - return PTW32_FALSE; - } - newProxy = ptw32_oll_snziRoot_closedAndZero; - } while (PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE( - (PTW32_INTERLOCKED_SIZEPTR)&csnziPtr->proxyRoot.counter, - (PTW32_INTERLOCKED_SIZE)newProxy.counter.word, - (PTW32_INTERLOCKED_SIZE)oldProxy.counter.word) - != (PTW32_INTERLOCKED_SIZE)oldProxy.counter.word); - return PTW32_TRUE; -} - -/* - * Returns whether the C-SNZI has a nonzero surplus and - * whether the C-SNZI is open. - * "nonZero" doesn't appear to be used anywhere in the algorithms. - */ -ptw32_oll_queryResult_t -ptw32_oll_Query(ptw32_oll_csnzi_t* csnziPtr) -{ - ptw32_oll_queryResult_t query; - ptw32_oll_snziRoot_t proxy = csnziPtr->proxyRoot; - - query.nonZero = (proxy.counter.internal.count > 0); - query.open = (proxy.counter.internal.state == ptw32_oll_snziRoot_open); - return query; -} - -/* - * Returns whether the Arrive operation that returned - * the ticket succeeded. - */ -BOOL -ptw32_oll_Arrived(ptw32_oll_ticket_t t) -{ - return (t.snziNodeOrRoot.nodePtr != NULL); -} - -/* - * Constructs and returns a ticket that can be used to - * depart from the root node. - */ -ptw32_oll_ticket_t -ptw32_oll_DirectTicket(ptw32_oll_csnzi_t* csnziPtr) -{ - ptw32_oll_ticket_t ticket; - ticket.snziNodeOrRoot.rootPtr = &csnziPtr->proxyRoot; - return ticket; -} - -/* Scalable RW Locks */ - -typedef struct ptw32_srwl_rwlock_t_ ptw32_srwl_rwlock_t; -typedef struct ptw32_srwl_node_t_ ptw32_srwl_node_t; -typedef struct ptw32_srwl_local_t_ ptw32_srwl_local_t; - -enum -{ - ptw32_srwl_reader = 0, - ptw32_srwl_writer = 1 -}; - -enum -{ - ptw32_srwl_free = 0, - ptw32_srwl_in_use = 1 -}; - -struct ptw32_srwl_rwlock_t_ -{ - ptw32_srwl_node_t* tailPtr; - ptw32_srwl_node_t* readerNodePtr; -}; - -struct ptw32_srwl_node_t_ -{ - ptw32_srwl_node_t* qNextPtr; - ptw32_oll_csnzi_t* csnziPtr; - ptw32_srwl_node_t* nextReaderPtr; - int kind; /* ptw32_srwl_reader, ptw32_srwl_writer */ - int allocState; /* ptw32_srwl_free, ptw32_srwl_in_use */ - BOOL spin; -}; - -/* - * When a ptw32_srwl_local_t is instantiated the "kind" of each of - * rNode and wNode must be set as appropriate. This is the only - * time "kind" is set. - */ -struct ptw32_srwl_local_t_ -{ - ptw32_srwl_node_t* rNodePtr; - ptw32_srwl_node_t* wNodePtr; - ptw32_srwl_node_t* departFromPtr; - ptw32_oll_ticket_t ticket; -}; - -/* Allocates a new reader node. */ -ptw32_srwl_node_t* -ptw32_srwl_AllocReaderNode(ptw32_srwl_local_t* local) -{ - ptw32_srwl_node_t* currNodePtr = local->rNodePtr; - for (;;) - { - if (currNodePtr->allocState == ptw32_srwl_free) - { - if (PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG( - (PTW32_INTERLOCKED_LONGPTR)&currNodePtr->allocState, - (PTW32_INTERLOCKED_LONG)ptw32_srwl_in_use, - (PTW32_INTERLOCKED_LONG)ptw32_srwl_free) - == (PTW32_INTERLOCKED_LONG)ptw32_srwl_in_use) - { - return currNodePtr; - } - } - currNodePtr = currNodePtr->next; - } -} - -/* - * Frees a reader node. Requires that its allocState - * is ptw32_srwl_in_use. - */ -void -ptw32_srwl_FreeReaderNode(ptw32_srwl_node_t* nodePtr) -{ - nodePtr->allocState := ptw32_srwl_free; -} - -void -ptw32_srwl_WriterLock(ptw32_srwl_rwlock_t* lockPtr, ptw32_srwl_local_t* localPtr) -{ - oldTailPtr = (ptw32_srwl_rwlock_t*)PTW32_INTERLOCKED_EXCHANGE_PTR( - (PTW32_INTERLOCKED_PVOID_PTR)&lockPtr->tailPtr, - (PTW32_INTERLOCKED_PVOID)localPtr->wNodePtr); - if (oldTailPtr != NULL) - { - localPtr->wNodePtr->spin := PTW32_TRUE; - oldTailPtr->qNextPtr = localPtr->wNodePtr; - if (oldTailPtr->kind == ptw32_srwl_writer) - { - while (localPtr->wNodePtr->spin); - } - else - { - /* Wait until node is properly recycled */ - while (ptw32_oll_Query(oldTailPtr->csnzi).open); - /* - * Close C-SNZI of previous reader node. - * If there are no readers to signal us, spin on - * previous node and free it before entering - * critical section. - */ - if (ptw32_oll_Close(oldTailPtr->csnzi)) - { - while (oldTailPtr->spin); - ptw32_srwl_FreeReaderNode(oldTailPtr); - } - else - { - while (localPtr->wNodePtr->spin); - } - } - } -} - -void -ptw32_srwl_WriterUnlock(ptw32_srwl_rwlock_t* lockPtr, ptw32_srwl_local_t* localPtr) -{ - if (localPtr->wNodePtr->qNextPtr == NULL) - { - if (PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR( - (PTW32_INTERLOCKED_PVOIDPTR)&lockPtr->tailPtr, - (PTW32_INTERLOCKED_PVOID)NULL, - (PTW32_INTERLOCKED_PVOID)localPtr->wNodePtr) - == (PTW32_INTERLOCKED_PVOID)NULL) - { - return; - } - else - { - while (localPtr->wNodePtr->qNextPtr == NULL); - } - } - /* Clean up */ - localPtr->wNodePtr->qNextPtr->spin = PTW32_FALSE; - localPtr->wNodePtr->qNextPtr = NULL; -} - -void -ptw32_srwl_ReaderLock(ptw32_srwl_rwlock_t* lockPtr, ptw32_srwl_local_t* localPtr) -{ - ptw32_srwl_node_t* rNodePtr = NULL; - for (;;) - { - ptw32_srwl_node_t* tailPtr = lockPtr->tailPtr; - /* If no nodes are in the queue */ - if (tailPtr == NULL) - { - if (rNodePtr == NULL) - { - rNodePtr = ptw32_srwl_AllocReaderNode(localPtr); - } - rNodePtr->spin = PTW32_FALSE; - if (PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR( - (PTW32_INTERLOCKED_PVOIDPTR)&lockPtr->tailPtr, - (PTW32_INTERLOCKED_PVOID)rNodePtr, - (PTW32_INTERLOCKED_PVOID)NULL) - == (PTW32_INTERLOCKED_PVOID)rNodePtr) - { - ptw32_oll_Open(rNodePtr->csnzi); - localPtr->ticket = ptw32_oll_Arrive(rNodePtr->csnzi); - if (ptw32_oll_Arrived(localPtr->ticket)) - { - localPtr->departFromPtr = rNodePtr; - return; - } - /* Avoid reusing inserted node */ - rNodePtr = NULL; - } - } - /* Otherwise, there is a node in the queue */ - else - { - /* Is last node a writer node? */ - if (tailPtr->kind == ptw32_srwl_writer) - { - if (rNodePtr == NULL) - { - rNodePtr = ptw32_srwl_AllocReaderNode(localPtr); - } - rNodePtr->spin = PTW32_TRUE; - if (PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR( - (PTW32_INTERLOCKED_PVOIDPTR)&lockPtr->tailPtr, - (PTW32_INTERLOCKED_PVOID)rNodePtr, - (PTW32_INTERLOCKED_PVOID)tailPtr) - == (PTW32_INTERLOCKED_PVOID)rNodePtr) - { - tailPtr->qNextPtr = rNodePtr; - localPtr->ticket = ptw32_oll_Arrive(rNodePtr->csnzi); - if (ptw32_oll_Arrived(localPtr->ticket)) - { - localPtr->departFromPtr = rNodePtr; - while (rNodePtr->spin); - return; - } - /* Avoid reusing inserted node */ - rNodePtr = NULL; - } - } - /* - * Otherwise, last node is a reader node. - * (tailPtr->kind == ptw32_srwl_reader) - */ - else - { - localPtr->ticket = ptw32_oll_Arrive(tailPtr->csnzi); - if (ptw32_oll_Arrived(localPtr->ticket)) - { - if (rNodePtr != NULL) - { - ptw32_srwl_FreeReaderNode(rNodePtr); - } - localPtr->departFromPtr = tailPtr; - while (tailPtr->spin); - return; - } - } - } - } -} - -void -ptw32_srwl_ReaderUnlock(ptw32_srwl_rwlock_t* lockPtr, ptw32_srwl_local_t* localPtr) -{ - if (ptw32_oll_Depart(localPtr->departFromPtr->csnzi, localPtr->ticket)) - { - return; - } - /* Clean up */ - localPtr->departFromPtr->qNextPtr->spin = PTW32_FALSE; - localPtr->departFromPtr->qNextPtr = NULL; - ptw32_srwl_FreeReaderNode(localPtr->departFromPtr); -} - - -#include - -int main() -{ - printf("%lx\n", PTW32_OLL_MAXREADERS); - return 0; -} - diff --git a/deps/w32-pthreads/ptw32_callUserDestroyRoutines.c b/deps/w32-pthreads/ptw32_callUserDestroyRoutines.c deleted file mode 100644 index ab15f2c..0000000 --- a/deps/w32-pthreads/ptw32_callUserDestroyRoutines.c +++ /dev/null @@ -1,232 +0,0 @@ -/* - * ptw32_callUserDestroyRoutines.c - * - * Description: - * This translation unit implements routines which are private to - * the implementation and may be used throughout it. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -#if defined(__CLEANUP_CXX) -# if defined(_MSC_VER) -# include -# elif defined(__WATCOMC__) -# include -# include -# else -# if defined(__GNUC__) && __GNUC__ < 3 -# include -# else -# include - using - std::terminate; -# endif -# endif -#endif - -void -ptw32_callUserDestroyRoutines (pthread_t thread) - /* - * ------------------------------------------------------------------- - * DOCPRIVATE - * - * This the routine runs through all thread keys and calls - * the destroy routines on the user's data for the current thread. - * It simulates the behaviour of POSIX Threads. - * - * PARAMETERS - * thread - * an instance of pthread_t - * - * RETURNS - * N/A - * ------------------------------------------------------------------- - */ -{ - ThreadKeyAssoc * assoc; - - if (thread.p != NULL) - { - ptw32_mcs_local_node_t threadLock; - ptw32_mcs_local_node_t keyLock; - int assocsRemaining; - int iterations = 0; - ptw32_thread_t * sp = (ptw32_thread_t *) thread.p; - - /* - * Run through all Thread<-->Key associations - * for the current thread. - * - * Do this process at most PTHREAD_DESTRUCTOR_ITERATIONS times. - */ - do - { - assocsRemaining = 0; - iterations++; - - ptw32_mcs_lock_acquire(&(sp->threadLock), &threadLock); - /* - * The pointer to the next assoc is stored in the thread struct so that - * the assoc destructor in pthread_key_delete can adjust it - * if it deletes this assoc. This can happen if we fail to acquire - * both locks below, and are forced to release all of our locks, - * leaving open the opportunity for pthread_key_delete to get in - * before us. - */ - sp->nextAssoc = sp->keys; - ptw32_mcs_lock_release(&threadLock); - - for (;;) - { - void * value; - pthread_key_t k; - void (*destructor) (void *); - - /* - * First we need to serialise with pthread_key_delete by locking - * both assoc guards, but in the reverse order to our convention, - * so we must be careful to avoid deadlock. - */ - ptw32_mcs_lock_acquire(&(sp->threadLock), &threadLock); - - if ((assoc = (ThreadKeyAssoc *)sp->nextAssoc) == NULL) - { - /* Finished */ - ptw32_mcs_lock_release(&threadLock); - break; - } - else - { - /* - * assoc->key must be valid because assoc can't change or be - * removed from our chain while we hold at least one lock. If - * the assoc was on our key chain then the key has not been - * deleted yet. - * - * Now try to acquire the second lock without deadlocking. - * If we fail, we need to relinquish the first lock and the - * processor and then try to acquire them all again. - */ - if (ptw32_mcs_lock_try_acquire(&(assoc->key->keyLock), &keyLock) == EBUSY) - { - ptw32_mcs_lock_release(&threadLock); - Sleep(0); - /* - * Go around again. - * If pthread_key_delete has removed this assoc in the meantime, - * sp->nextAssoc will point to a new assoc. - */ - continue; - } - } - - /* We now hold both locks */ - - sp->nextAssoc = assoc->nextKey; - - /* - * Key still active; pthread_key_delete - * will block on these same mutexes before - * it can release actual key; therefore, - * key is valid and we can call the destroy - * routine; - */ - k = assoc->key; - destructor = k->destructor; - value = TlsGetValue(k->key); - TlsSetValue (k->key, NULL); - - // Every assoc->key exists and has a destructor - if (value != NULL && iterations <= PTHREAD_DESTRUCTOR_ITERATIONS) - { - /* - * Unlock both locks before the destructor runs. - * POSIX says pthread_key_delete can be run from destructors, - * and that probably includes with this key as target. - * pthread_setspecific can also be run from destructors and - * also needs to be able to access the assocs. - */ - ptw32_mcs_lock_release(&threadLock); - ptw32_mcs_lock_release(&keyLock); - - assocsRemaining++; - -#if defined(__cplusplus) - - try - { - /* - * Run the caller's cleanup routine. - */ - destructor (value); - } - catch (...) - { - /* - * A system unexpected exception has occurred - * running the user's destructor. - * We get control back within this block in case - * the application has set up it's own terminate - * handler. Since we are leaving the thread we - * should not get any internal pthreads - * exceptions. - */ - terminate (); - } - -#else /* __cplusplus */ - - /* - * Run the caller's cleanup routine. - */ - destructor (value); - -#endif /* __cplusplus */ - - } - else - { - /* - * Remove association from both the key and thread chains - * and reclaim it's memory resources. - */ - ptw32_tkAssocDestroy (assoc); - ptw32_mcs_lock_release(&threadLock); - ptw32_mcs_lock_release(&keyLock); - } - } - } - while (assocsRemaining); - } -} /* ptw32_callUserDestroyRoutines */ diff --git a/deps/w32-pthreads/ptw32_calloc.c b/deps/w32-pthreads/ptw32_calloc.c deleted file mode 100644 index 7fad76b..0000000 --- a/deps/w32-pthreads/ptw32_calloc.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * ptw32_calloc.c - * - * Description: - * This translation unit implements miscellaneous thread functions. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -#if defined(NEED_CALLOC) -void * -ptw32_calloc (size_t n, size_t s) -{ - unsigned int m = n * s; - void *p; - - p = malloc (m); - if (p == NULL) - return NULL; - - memset (p, 0, m); - - return p; -} -#endif diff --git a/deps/w32-pthreads/ptw32_cond_check_need_init.c b/deps/w32-pthreads/ptw32_cond_check_need_init.c deleted file mode 100644 index 20b045b..0000000 --- a/deps/w32-pthreads/ptw32_cond_check_need_init.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * ptw32_cond_check_need_init.c - * - * Description: - * This translation unit implements condition variables and their primitives. - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -INLINE int -ptw32_cond_check_need_init (pthread_cond_t * cond) -{ - int result = 0; - ptw32_mcs_local_node_t node; - - /* - * The following guarded test is specifically for statically - * initialised condition variables (via PTHREAD_OBJECT_INITIALIZER). - */ - ptw32_mcs_lock_acquire(&ptw32_cond_test_init_lock, &node); - - /* - * We got here possibly under race - * conditions. Check again inside the critical section. - * If a static cv has been destroyed, the application can - * re-initialise it only by calling pthread_cond_init() - * explicitly. - */ - if (*cond == PTHREAD_COND_INITIALIZER) - { - result = pthread_cond_init (cond, NULL); - } - else if (*cond == NULL) - { - /* - * The cv has been destroyed while we were waiting to - * initialise it, so the operation that caused the - * auto-initialisation should fail. - */ - result = EINVAL; - } - - ptw32_mcs_lock_release(&node); - - return result; -} diff --git a/deps/w32-pthreads/ptw32_getprocessors.c b/deps/w32-pthreads/ptw32_getprocessors.c deleted file mode 100644 index 9207491..0000000 --- a/deps/w32-pthreads/ptw32_getprocessors.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * ptw32_getprocessors.c - * - * Description: - * This translation unit implements routines which are private to - * the implementation and may be used throughout it. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -/* - * ptw32_getprocessors() - * - * Get the number of CPUs available to the process. - * - * If the available number of CPUs is 1 then pthread_spin_lock() - * will block rather than spin if the lock is already owned. - * - * pthread_spin_init() calls this routine when initialising - * a spinlock. If the number of available processors changes - * (after a call to SetProcessAffinityMask()) then only - * newly initialised spinlocks will notice. - */ -int -ptw32_getprocessors (int *count) -{ - DWORD_PTR vProcessCPUs; - DWORD_PTR vSystemCPUs; - int result = 0; - -#if defined(NEED_PROCESS_AFFINITY_MASK) - - *count = 1; - -#else - - if (GetProcessAffinityMask (GetCurrentProcess (), - &vProcessCPUs, &vSystemCPUs)) - { - DWORD_PTR bit; - int CPUs = 0; - - for (bit = 1; bit != 0; bit <<= 1) - { - if (vProcessCPUs & bit) - { - CPUs++; - } - } - *count = CPUs; - } - else - { - result = EAGAIN; - } - -#endif - - return (result); -} diff --git a/deps/w32-pthreads/ptw32_is_attr.c b/deps/w32-pthreads/ptw32_is_attr.c deleted file mode 100644 index 1b633e1..0000000 --- a/deps/w32-pthreads/ptw32_is_attr.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * ptw32_is_attr.c - * - * Description: - * This translation unit implements operations on thread attribute objects. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -int -ptw32_is_attr (const pthread_attr_t * attr) -{ - /* Return 0 if the attr object is valid, non-zero otherwise. */ - - return (attr == NULL || - *attr == NULL || (*attr)->valid != PTW32_ATTR_VALID); -} diff --git a/deps/w32-pthreads/ptw32_mutex_check_need_init.c b/deps/w32-pthreads/ptw32_mutex_check_need_init.c deleted file mode 100644 index 9574233..0000000 --- a/deps/w32-pthreads/ptw32_mutex_check_need_init.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * ptw32_mutex_check_need_init.c - * - * Description: - * This translation unit implements mutual exclusion (mutex) primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -static struct pthread_mutexattr_t_ ptw32_recursive_mutexattr_s = - {PTHREAD_PROCESS_PRIVATE, PTHREAD_MUTEX_RECURSIVE}; -static struct pthread_mutexattr_t_ ptw32_errorcheck_mutexattr_s = - {PTHREAD_PROCESS_PRIVATE, PTHREAD_MUTEX_ERRORCHECK}; -static pthread_mutexattr_t ptw32_recursive_mutexattr = &ptw32_recursive_mutexattr_s; -static pthread_mutexattr_t ptw32_errorcheck_mutexattr = &ptw32_errorcheck_mutexattr_s; - - -INLINE int -ptw32_mutex_check_need_init (pthread_mutex_t * mutex) -{ - register int result = 0; - register pthread_mutex_t mtx; - ptw32_mcs_local_node_t node; - - ptw32_mcs_lock_acquire(&ptw32_mutex_test_init_lock, &node); - - /* - * We got here possibly under race - * conditions. Check again inside the critical section - * and only initialise if the mutex is valid (not been destroyed). - * If a static mutex has been destroyed, the application can - * re-initialise it only by calling pthread_mutex_init() - * explicitly. - */ - mtx = *mutex; - - if (mtx == PTHREAD_MUTEX_INITIALIZER) - { - result = pthread_mutex_init (mutex, NULL); - } - else if (mtx == PTHREAD_RECURSIVE_MUTEX_INITIALIZER) - { - result = pthread_mutex_init (mutex, &ptw32_recursive_mutexattr); - } - else if (mtx == PTHREAD_ERRORCHECK_MUTEX_INITIALIZER) - { - result = pthread_mutex_init (mutex, &ptw32_errorcheck_mutexattr); - } - else if (mtx == NULL) - { - /* - * The mutex has been destroyed while we were waiting to - * initialise it, so the operation that caused the - * auto-initialisation should fail. - */ - result = EINVAL; - } - - ptw32_mcs_lock_release(&node); - - return (result); -} diff --git a/deps/w32-pthreads/ptw32_new.c b/deps/w32-pthreads/ptw32_new.c deleted file mode 100644 index b0ba268..0000000 --- a/deps/w32-pthreads/ptw32_new.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * ptw32_new.c - * - * Description: - * This translation unit implements miscellaneous thread functions. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -pthread_t -ptw32_new (void) -{ - pthread_t t; - pthread_t nil = {NULL, 0}; - ptw32_thread_t * tp; - - /* - * If there's a reusable pthread_t then use it. - */ - t = ptw32_threadReusePop (); - - if (NULL != t.p) - { - tp = (ptw32_thread_t *) t.p; - } - else - { - /* No reuse threads available */ - tp = (ptw32_thread_t *) calloc (1, sizeof(ptw32_thread_t)); - - if (tp == NULL) - { - return nil; - } - - /* ptHandle.p needs to point to it's parent ptw32_thread_t. */ - t.p = tp->ptHandle.p = tp; - t.x = tp->ptHandle.x = 0; - } - - /* Set default state. */ - tp->seqNumber = ++ptw32_threadSeqNumber; - tp->sched_priority = THREAD_PRIORITY_NORMAL; - tp->detachState = PTHREAD_CREATE_JOINABLE; - tp->cancelState = PTHREAD_CANCEL_ENABLE; - tp->cancelType = PTHREAD_CANCEL_DEFERRED; - tp->stateLock = 0; - tp->threadLock = 0; - tp->robustMxListLock = 0; - tp->robustMxList = NULL; - tp->cancelEvent = CreateEvent (0, (int) PTW32_TRUE, /* manualReset */ - (int) PTW32_FALSE, /* setSignaled */ - NULL); - - if (tp->cancelEvent == NULL) - { - ptw32_threadReusePush (tp->ptHandle); - return nil; - } - - return t; - -} diff --git a/deps/w32-pthreads/ptw32_processInitialize.c b/deps/w32-pthreads/ptw32_processInitialize.c deleted file mode 100644 index 4a63df8..0000000 --- a/deps/w32-pthreads/ptw32_processInitialize.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * ptw32_processInitialize.c - * - * Description: - * This translation unit implements routines which are private to - * the implementation and may be used throughout it. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -ptw32_processInitialize (void) - /* - * ------------------------------------------------------ - * DOCPRIVATE - * This function performs process wide initialization for - * the pthread library. - * - * PARAMETERS - * N/A - * - * DESCRIPTION - * This function performs process wide initialization for - * the pthread library. - * If successful, this routine sets the global variable - * ptw32_processInitialized to TRUE. - * - * RESULTS - * TRUE if successful, - * FALSE otherwise - * - * ------------------------------------------------------ - */ -{ - if (ptw32_processInitialized) - { - /* - * Ignore if already initialized. this is useful for - * programs that uses a non-dll pthread - * library. Such programs must call ptw32_processInitialize() explicitly, - * since this initialization routine is automatically called only when - * the dll is loaded. - */ - return PTW32_TRUE; - } - - ptw32_processInitialized = PTW32_TRUE; - - /* - * Initialize Keys - */ - if ((pthread_key_create (&ptw32_selfThreadKey, NULL) != 0) || - (pthread_key_create (&ptw32_cleanupKey, NULL) != 0)) - { - - ptw32_processTerminate (); - } - - return (ptw32_processInitialized); - -} /* processInitialize */ diff --git a/deps/w32-pthreads/ptw32_processTerminate.c b/deps/w32-pthreads/ptw32_processTerminate.c deleted file mode 100644 index 8b017a7..0000000 --- a/deps/w32-pthreads/ptw32_processTerminate.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * ptw32_processTerminate.c - * - * Description: - * This translation unit implements routines which are private to - * the implementation and may be used throughout it. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -void -ptw32_processTerminate (void) - /* - * ------------------------------------------------------ - * DOCPRIVATE - * This function performs process wide termination for - * the pthread library. - * - * PARAMETERS - * N/A - * - * DESCRIPTION - * This function performs process wide termination for - * the pthread library. - * This routine sets the global variable - * ptw32_processInitialized to FALSE - * - * RESULTS - * N/A - * - * ------------------------------------------------------ - */ -{ - if (ptw32_processInitialized) - { - ptw32_thread_t * tp, * tpNext; - ptw32_mcs_local_node_t node; - - if (ptw32_selfThreadKey != NULL) - { - /* - * Release ptw32_selfThreadKey - */ - pthread_key_delete (ptw32_selfThreadKey); - - ptw32_selfThreadKey = NULL; - } - - if (ptw32_cleanupKey != NULL) - { - /* - * Release ptw32_cleanupKey - */ - pthread_key_delete (ptw32_cleanupKey); - - ptw32_cleanupKey = NULL; - } - - ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node); - - tp = ptw32_threadReuseTop; - while (tp != PTW32_THREAD_REUSE_EMPTY) - { - tpNext = tp->prevReuse; - free (tp); - tp = tpNext; - } - - ptw32_mcs_lock_release(&node); - - ptw32_processInitialized = PTW32_FALSE; - } - -} /* processTerminate */ diff --git a/deps/w32-pthreads/ptw32_relmillisecs.c b/deps/w32-pthreads/ptw32_relmillisecs.c deleted file mode 100644 index 5459206..0000000 --- a/deps/w32-pthreads/ptw32_relmillisecs.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * ptw32_relmillisecs.c - * - * Description: - * This translation unit implements miscellaneous thread functions. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" -#if !defined(NEED_FTIME) -#include -#endif - - -#if defined(PTW32_BUILD_INLINED) -INLINE -#endif /* PTW32_BUILD_INLINED */ -DWORD -ptw32_relmillisecs (const struct timespec * abstime) -{ - const int64_t NANOSEC_PER_MILLISEC = 1000000; - const int64_t MILLISEC_PER_SEC = 1000; - DWORD milliseconds; - int64_t tmpAbsMilliseconds; - int64_t tmpCurrMilliseconds; -#if defined(NEED_FTIME) - struct timespec currSysTime; - FILETIME ft; - SYSTEMTIME st; -#else /* ! NEED_FTIME */ -#if ( defined(_MSC_VER) && _MSC_VER >= 1300 ) || \ - ( (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 ) - struct __timeb64 currSysTime; -#else - struct _timeb currSysTime; -#endif -#endif /* NEED_FTIME */ - - - /* - * Calculate timeout as milliseconds from current system time. - */ - - /* - * subtract current system time from abstime in a way that checks - * that abstime is never in the past, or is never equivalent to the - * defined INFINITE value (0xFFFFFFFF). - * - * Assume all integers are unsigned, i.e. cannot test if less than 0. - */ - tmpAbsMilliseconds = (int64_t)abstime->tv_sec * MILLISEC_PER_SEC; - tmpAbsMilliseconds += ((int64_t)abstime->tv_nsec + (NANOSEC_PER_MILLISEC/2)) / NANOSEC_PER_MILLISEC; - - /* get current system time */ - -#if defined(NEED_FTIME) - - GetSystemTime(&st); - SystemTimeToFileTime(&st, &ft); - /* - * GetSystemTimeAsFileTime(&ft); would be faster, - * but it does not exist on WinCE - */ - - ptw32_filetime_to_timespec(&ft, &currSysTime); - - tmpCurrMilliseconds = (int64_t)currSysTime.tv_sec * MILLISEC_PER_SEC; - tmpCurrMilliseconds += ((int64_t)currSysTime.tv_nsec + (NANOSEC_PER_MILLISEC/2)) - / NANOSEC_PER_MILLISEC; - -#else /* ! NEED_FTIME */ - -#if defined(_MSC_VER) && _MSC_VER >= 1400 - _ftime64_s(&currSysTime); -#elif ( defined(_MSC_VER) && _MSC_VER >= 1300 ) || \ - ( (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 ) - _ftime64(&currSysTime); -#else - _ftime(&currSysTime); -#endif - - tmpCurrMilliseconds = (int64_t) currSysTime.time * MILLISEC_PER_SEC; - tmpCurrMilliseconds += (int64_t) currSysTime.millitm; - -#endif /* NEED_FTIME */ - - if (tmpAbsMilliseconds > tmpCurrMilliseconds) - { - milliseconds = (DWORD) (tmpAbsMilliseconds - tmpCurrMilliseconds); - if (milliseconds == INFINITE) - { - /* Timeouts must be finite */ - milliseconds--; - } - } - else - { - /* The abstime given is in the past */ - milliseconds = 0; - } - - return milliseconds; -} diff --git a/deps/w32-pthreads/ptw32_reuse.c b/deps/w32-pthreads/ptw32_reuse.c deleted file mode 100644 index f252528..0000000 --- a/deps/w32-pthreads/ptw32_reuse.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * ptw32_threadReuse.c - * - * Description: - * This translation unit implements miscellaneous thread functions. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -/* - * How it works: - * A pthread_t is a struct (2x32 bit scalar types on IA-32, 2x64 bit on IA-64) - * which is normally passed/returned by value to/from pthreads routines. - * Applications are therefore storing a copy of the struct as it is at that - * time. - * - * The original pthread_t struct plus all copies of it contain the address of - * the thread state struct ptw32_thread_t_ (p), plus a reuse counter (x). Each - * ptw32_thread_t contains the original copy of it's pthread_t. - * Once malloced, a ptw32_thread_t_ struct is not freed until the process exits. - * - * The thread reuse stack is a simple LILO stack managed through a singly - * linked list element in the ptw32_thread_t. - * - * Each time a thread is destroyed, the ptw32_thread_t address is pushed onto the - * reuse stack after it's ptHandle's reuse counter has been incremented. - * - * The following can now be said from this: - * - two pthread_t's are identical if their ptw32_thread_t reference pointers - * are equal and their reuse counters are equal. That is, - * - * equal = (a.p == b.p && a.x == b.x) - * - * - a pthread_t copy refers to a destroyed thread if the reuse counter in - * the copy is not equal to the reuse counter in the original. - * - * threadDestroyed = (copy.x != ((ptw32_thread_t *)copy.p)->ptHandle.x) - * - */ - -/* - * Pop a clean pthread_t struct off the reuse stack. - */ -pthread_t -ptw32_threadReusePop (void) -{ - pthread_t t = {NULL, 0}; - ptw32_mcs_local_node_t node; - - ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node); - - if (PTW32_THREAD_REUSE_EMPTY != ptw32_threadReuseTop) - { - ptw32_thread_t * tp; - - tp = ptw32_threadReuseTop; - - ptw32_threadReuseTop = tp->prevReuse; - - if (PTW32_THREAD_REUSE_EMPTY == ptw32_threadReuseTop) - { - ptw32_threadReuseBottom = PTW32_THREAD_REUSE_EMPTY; - } - - tp->prevReuse = NULL; - - t = tp->ptHandle; - } - - ptw32_mcs_lock_release(&node); - - return t; - -} - -/* - * Push a clean pthread_t struct onto the reuse stack. - * Must be re-initialised when reused. - * All object elements (mutexes, events etc) must have been either - * detroyed before this, or never initialised. - */ -void -ptw32_threadReusePush (pthread_t thread) -{ - ptw32_thread_t * tp = (ptw32_thread_t *) thread.p; - pthread_t t; - ptw32_mcs_local_node_t node; - - ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node); - - t = tp->ptHandle; - memset(tp, 0, sizeof(ptw32_thread_t)); - - /* Must restore the original POSIX handle that we just wiped. */ - tp->ptHandle = t; - - /* Bump the reuse counter now */ -#if defined(PTW32_THREAD_ID_REUSE_INCREMENT) - tp->ptHandle.x += PTW32_THREAD_ID_REUSE_INCREMENT; -#else - tp->ptHandle.x++; -#endif - - tp->state = PThreadStateReuse; - - tp->prevReuse = PTW32_THREAD_REUSE_EMPTY; - - if (PTW32_THREAD_REUSE_EMPTY != ptw32_threadReuseBottom) - { - ptw32_threadReuseBottom->prevReuse = tp; - } - else - { - ptw32_threadReuseTop = tp; - } - - ptw32_threadReuseBottom = tp; - - ptw32_mcs_lock_release(&node); -} diff --git a/deps/w32-pthreads/ptw32_rwlock_cancelwrwait.c b/deps/w32-pthreads/ptw32_rwlock_cancelwrwait.c deleted file mode 100644 index 4124d98..0000000 --- a/deps/w32-pthreads/ptw32_rwlock_cancelwrwait.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ptw32_rwlock_cancelwrwait.c - * - * Description: - * This translation unit implements read/write lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -void -ptw32_rwlock_cancelwrwait (void *arg) -{ - pthread_rwlock_t rwl = (pthread_rwlock_t) arg; - - rwl->nSharedAccessCount = -rwl->nCompletedSharedAccessCount; - rwl->nCompletedSharedAccessCount = 0; - - (void) pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted)); - (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)); -} diff --git a/deps/w32-pthreads/ptw32_rwlock_check_need_init.c b/deps/w32-pthreads/ptw32_rwlock_check_need_init.c deleted file mode 100644 index 7a7ef9c..0000000 --- a/deps/w32-pthreads/ptw32_rwlock_check_need_init.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * pthread_rwlock_check_need_init.c - * - * Description: - * This translation unit implements read/write lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -INLINE int -ptw32_rwlock_check_need_init (pthread_rwlock_t * rwlock) -{ - int result = 0; - ptw32_mcs_local_node_t node; - - /* - * The following guarded test is specifically for statically - * initialised rwlocks (via PTHREAD_RWLOCK_INITIALIZER). - */ - ptw32_mcs_lock_acquire(&ptw32_rwlock_test_init_lock, &node); - - /* - * We got here possibly under race - * conditions. Check again inside the critical section - * and only initialise if the rwlock is valid (not been destroyed). - * If a static rwlock has been destroyed, the application can - * re-initialise it only by calling pthread_rwlock_init() - * explicitly. - */ - if (*rwlock == PTHREAD_RWLOCK_INITIALIZER) - { - result = pthread_rwlock_init (rwlock, NULL); - } - else if (*rwlock == NULL) - { - /* - * The rwlock has been destroyed while we were waiting to - * initialise it, so the operation that caused the - * auto-initialisation should fail. - */ - result = EINVAL; - } - - ptw32_mcs_lock_release(&node); - - return result; -} diff --git a/deps/w32-pthreads/ptw32_semwait.c b/deps/w32-pthreads/ptw32_semwait.c deleted file mode 100644 index bc96487..0000000 --- a/deps/w32-pthreads/ptw32_semwait.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * ptw32_semwait.c - * - * Description: - * This translation unit implements mutual exclusion (mutex) primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#if !defined(_UWIN) -/*# include */ -#endif -#include "pthread.h" -#include "implement.h" - - -int -ptw32_semwait (sem_t * sem) - /* - * ------------------------------------------------------ - * DESCRIPTION - * This function waits on a POSIX semaphore. If the - * semaphore value is greater than zero, it decreases - * its value by one. If the semaphore value is zero, then - * the calling thread (or process) is blocked until it can - * successfully decrease the value. - * - * Unlike sem_wait(), this routine is non-cancelable. - * - * RESULTS - * 0 successfully decreased semaphore, - * -1 failed, error in errno. - * ERRNO - * EINVAL 'sem' is not a valid semaphore, - * ENOSYS semaphores are not supported, - * EINTR the function was interrupted by a signal, - * EDEADLK a deadlock condition was detected. - * - * ------------------------------------------------------ - */ -{ - int result = 0; - sem_t s = *sem; - - if (s == NULL) - { - result = EINVAL; - } - else - { - if ((result = pthread_mutex_lock (&s->lock)) == 0) - { - int v; - - /* See sem_destroy.c - */ - if (*sem == NULL) - { - (void) pthread_mutex_unlock (&s->lock); - errno = EINVAL; - return -1; - } - - v = --s->value; - (void) pthread_mutex_unlock (&s->lock); - - if (v < 0) - { - /* Must wait */ - if (WaitForSingleObject (s->sem, INFINITE) == WAIT_OBJECT_0) - { -#if defined(NEED_SEM) - if (pthread_mutex_lock (&s->lock) == 0) - { - if (*sem == NULL) - { - (void) pthread_mutex_unlock (&s->lock); - errno = EINVAL; - return -1; - } - - if (s->leftToUnblock > 0) - { - --s->leftToUnblock; - SetEvent(s->sem); - } - (void) pthread_mutex_unlock (&s->lock); - } -#endif - return 0; - } - } - else - { - return 0; - } - } - } - - if (result != 0) - { - errno = result; - return -1; - } - - return 0; - -} /* ptw32_semwait */ diff --git a/deps/w32-pthreads/ptw32_spinlock_check_need_init.c b/deps/w32-pthreads/ptw32_spinlock_check_need_init.c deleted file mode 100644 index 1fa63d9..0000000 --- a/deps/w32-pthreads/ptw32_spinlock_check_need_init.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * ptw32_spinlock_check_need_init.c - * - * Description: - * This translation unit implements spin lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -INLINE int -ptw32_spinlock_check_need_init (pthread_spinlock_t * lock) -{ - int result = 0; - ptw32_mcs_local_node_t node; - - /* - * The following guarded test is specifically for statically - * initialised spinlocks (via PTHREAD_SPINLOCK_INITIALIZER). - */ - ptw32_mcs_lock_acquire(&ptw32_spinlock_test_init_lock, &node); - - /* - * We got here possibly under race - * conditions. Check again inside the critical section - * and only initialise if the spinlock is valid (not been destroyed). - * If a static spinlock has been destroyed, the application can - * re-initialise it only by calling pthread_spin_init() - * explicitly. - */ - if (*lock == PTHREAD_SPINLOCK_INITIALIZER) - { - result = pthread_spin_init (lock, PTHREAD_PROCESS_PRIVATE); - } - else if (*lock == NULL) - { - /* - * The spinlock has been destroyed while we were waiting to - * initialise it, so the operation that caused the - * auto-initialisation should fail. - */ - result = EINVAL; - } - - ptw32_mcs_lock_release(&node); - - return (result); -} diff --git a/deps/w32-pthreads/ptw32_threadDestroy.c b/deps/w32-pthreads/ptw32_threadDestroy.c deleted file mode 100644 index 38b7417..0000000 --- a/deps/w32-pthreads/ptw32_threadDestroy.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * ptw32_threadDestroy.c - * - * Description: - * This translation unit implements routines which are private to - * the implementation and may be used throughout it. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -void -ptw32_threadDestroy (pthread_t thread) -{ - ptw32_thread_t * tp = (ptw32_thread_t *) thread.p; - ptw32_thread_t threadCopy; - - if (tp != NULL) - { - /* - * Copy thread state so that the thread can be atomically NULLed. - */ - memcpy (&threadCopy, tp, sizeof (threadCopy)); - - /* - * Thread ID structs are never freed. They're NULLed and reused. - * This also sets the thread to PThreadStateInitial (invalid). - */ - ptw32_threadReusePush (thread); - - /* Now work on the copy. */ - if (threadCopy.cancelEvent != NULL) - { - CloseHandle (threadCopy.cancelEvent); - } - -#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) - /* - * See documentation for endthread vs endthreadex. - */ - if (threadCopy.threadH != 0) - { - CloseHandle (threadCopy.threadH); - } -#endif - - } -} /* ptw32_threadDestroy */ - diff --git a/deps/w32-pthreads/ptw32_threadStart.c b/deps/w32-pthreads/ptw32_threadStart.c deleted file mode 100644 index e7d3925..0000000 --- a/deps/w32-pthreads/ptw32_threadStart.c +++ /dev/null @@ -1,357 +0,0 @@ -/* - * ptw32_threadStart.c - * - * Description: - * This translation unit implements routines which are private to - * the implementation and may be used throughout it. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" -#include - -#if defined(__CLEANUP_C) -# include -#endif - -#if defined(__CLEANUP_SEH) - -static DWORD -ExceptionFilter (EXCEPTION_POINTERS * ep, DWORD * ei) -{ - switch (ep->ExceptionRecord->ExceptionCode) - { - case EXCEPTION_PTW32_SERVICES: - { - DWORD param; - DWORD numParams = ep->ExceptionRecord->NumberParameters; - - numParams = (numParams > 3) ? 3 : numParams; - - for (param = 0; param < numParams; param++) - { - ei[param] = ep->ExceptionRecord->ExceptionInformation[param]; - } - - return EXCEPTION_EXECUTE_HANDLER; - break; - } - default: - { - /* - * A system unexpected exception has occurred running the user's - * routine. We need to cleanup before letting the exception - * out of thread scope. - */ - pthread_t self = pthread_self (); - - ptw32_callUserDestroyRoutines (self); - - return EXCEPTION_CONTINUE_SEARCH; - break; - } - } -} - -#elif defined(__CLEANUP_CXX) - -#if defined(_MSC_VER) -# include -#elif defined(__WATCOMC__) -# include -# include -typedef terminate_handler - terminate_function; -#else -# if defined(__GNUC__) && __GNUC__ < 3 -# include -# else -# include -using - std::terminate_handler; -using - std::terminate; -using - std::set_terminate; -# endif -typedef terminate_handler - terminate_function; -#endif - -static terminate_function - ptw32_oldTerminate; - -void -ptw32_terminate () -{ - set_terminate (ptw32_oldTerminate); - (void) pthread_win32_thread_detach_np (); - terminate (); -} - -#endif - -#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || (defined (__MSVCRT__) && ! defined (__DMC__)) -unsigned - __stdcall -#else -void -#endif -ptw32_threadStart (void *vthreadParms) -{ - ThreadParms * threadParms = (ThreadParms *) vthreadParms; - pthread_t self; - ptw32_thread_t * sp; - void * (PTW32_CDECL *start) (void *); - void * arg; - -#if defined(__CLEANUP_SEH) - DWORD - ei[] = { 0, 0, 0 }; -#endif - -#if defined(__CLEANUP_C) - int setjmp_rc; -#endif - - ptw32_mcs_local_node_t stateLock; - void * status = (void *) 0; - - self = threadParms->tid; - sp = (ptw32_thread_t *) self.p; - start = threadParms->start; - arg = threadParms->arg; - - free (threadParms); - -#if (defined(__MINGW64__) || defined(__MINGW32__)) && ! defined (__MSVCRT__) - /* - * beginthread does not return the thread id and is running - * before it returns us the thread handle, and so we do it here. - */ - sp->thread = GetCurrentThreadId (); - /* - * Here we're using stateLock as a general-purpose lock - * to make the new thread wait until the creating thread - * has the new handle. - */ - ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); - pthread_setspecific (ptw32_selfThreadKey, sp); -#else - pthread_setspecific (ptw32_selfThreadKey, sp); - ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); -#endif - - sp->state = PThreadStateRunning; - ptw32_mcs_lock_release (&stateLock); - -#if defined(__CLEANUP_SEH) - - __try - { - /* - * Run the caller's routine; - */ - status = sp->exitStatus = (*start) (arg); - sp->state = PThreadStateExiting; - -#if defined(_UWIN) - if (--pthread_count <= 0) - exit (0); -#endif - - } - __except (ExceptionFilter (GetExceptionInformation (), ei)) - { - switch (ei[0]) - { - case PTW32_EPS_CANCEL: - status = sp->exitStatus = PTHREAD_CANCELED; -#if defined(_UWIN) - if (--pthread_count <= 0) - exit (0); -#endif - break; - case PTW32_EPS_EXIT: - status = sp->exitStatus; - break; - default: - status = sp->exitStatus = PTHREAD_CANCELED; - break; - } - } - -#else /* __CLEANUP_SEH */ - -#if defined(__CLEANUP_C) - - setjmp_rc = setjmp (sp->start_mark); - - if (0 == setjmp_rc) - { - - /* - * Run the caller's routine; - */ - status = sp->exitStatus = (*start) (arg); - sp->state = PThreadStateExiting; - } - else - { - switch (setjmp_rc) - { - case PTW32_EPS_CANCEL: - status = sp->exitStatus = PTHREAD_CANCELED; - break; - case PTW32_EPS_EXIT: - status = sp->exitStatus; - break; - default: - status = sp->exitStatus = PTHREAD_CANCELED; - break; - } - } - -#else /* __CLEANUP_C */ - -#if defined(__CLEANUP_CXX) - - ptw32_oldTerminate = set_terminate (&ptw32_terminate); - - try - { - /* - * Run the caller's routine in a nested try block so that we - * can run the user's terminate function, which may call - * pthread_exit() or be canceled. - */ - try - { - status = sp->exitStatus = (*start) (arg); - sp->state = PThreadStateExiting; - } - catch (ptw32_exception &) - { - /* - * Pass these through to the outer block. - */ - throw; - } - catch (...) - { - /* - * We want to run the user's terminate function if supplied. - * That function may call pthread_exit() or be canceled, which will - * be handled by the outer try block. - * - * ptw32_terminate() will be called if there is no user - * supplied function. - */ - terminate_function - term_func = set_terminate (0); - set_terminate (term_func); - - if (term_func != 0) - { - term_func (); - } - throw; - } - } - catch (ptw32_exception_cancel &) - { - /* - * Thread was canceled. - */ - status = sp->exitStatus = PTHREAD_CANCELED; - } - catch (ptw32_exception_exit &) - { - /* - * Thread was exited via pthread_exit(). - */ - status = sp->exitStatus; - } - catch (...) - { - /* - * A system unexpected exception has occurred running the user's - * terminate routine. We get control back within this block - * and exit with a substitute status. If the thread was not - * cancelled then this indicates the unhandled exception. - */ - status = sp->exitStatus = PTHREAD_CANCELED; - } - - (void) set_terminate (ptw32_oldTerminate); - -#else - -#error ERROR [__FILE__, line __LINE__]: Cleanup type undefined. - -#endif /* __CLEANUP_CXX */ -#endif /* __CLEANUP_C */ -#endif /* __CLEANUP_SEH */ - -#if defined(PTW32_STATIC_LIB) - /* - * We need to cleanup the pthread now if we have - * been statically linked, in which case the cleanup - * in dllMain won't get done. Joinable threads will - * only be partially cleaned up and must be fully cleaned - * up by pthread_join() or pthread_detach(). - * - * Note: if this library has been statically linked, - * implicitly created pthreads (those created - * for Win32 threads which have called pthreads routines) - * must be cleaned up explicitly by the application - * (by calling pthread_win32_thread_detach_np()). - * For the dll, dllMain will do the cleanup automatically. - */ - (void) pthread_win32_thread_detach_np (); -#endif - -#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) - _endthreadex ((unsigned)(size_t) status); -#else - _endthread (); -#endif - - /* - * Never reached. - */ - -#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) - return (unsigned)(size_t) status; -#endif - -} /* ptw32_threadStart */ diff --git a/deps/w32-pthreads/ptw32_throw.c b/deps/w32-pthreads/ptw32_throw.c deleted file mode 100644 index ff1895a..0000000 --- a/deps/w32-pthreads/ptw32_throw.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * ptw32_throw.c - * - * Description: - * This translation unit implements routines which are private to - * the implementation and may be used throughout it. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - -#if defined(__CLEANUP_C) -# include -#endif - -/* - * ptw32_throw - * - * All canceled and explicitly exited POSIX threads go through - * here. This routine knows how to exit both POSIX initiated threads and - * 'implicit' POSIX threads for each of the possible language modes (C, - * C++, and SEH). - */ -#if defined(_MSC_VER) -/* - * Ignore the warning: - * "C++ exception specification ignored except to indicate that - * the function is not __declspec(nothrow)." - */ -#pragma warning(disable:4290) -#endif -void -ptw32_throw (DWORD exception) -#if defined(__CLEANUP_CXX) - throw(ptw32_exception_cancel,ptw32_exception_exit) -#endif -{ - /* - * Don't use pthread_self() to avoid creating an implicit POSIX thread handle - * unnecessarily. - */ - ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); - -#if defined(__CLEANUP_SEH) - DWORD exceptionInformation[3]; -#endif - - sp->state = PThreadStateExiting; - - if (exception != PTW32_EPS_CANCEL && exception != PTW32_EPS_EXIT) - { - /* Should never enter here */ - exit (1); - } - - if (NULL == sp || sp->implicit) - { - /* - * We're inside a non-POSIX initialised Win32 thread - * so there is no point to jump or throw back to. Just do an - * explicit thread exit here after cleaning up POSIX - * residue (i.e. cleanup handlers, POSIX thread handle etc). - */ -#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) - unsigned exitCode = 0; - - switch (exception) - { - case PTW32_EPS_CANCEL: - exitCode = (unsigned)(size_t) PTHREAD_CANCELED; - break; - case PTW32_EPS_EXIT: - if (NULL != sp) - { - exitCode = (unsigned)(size_t) sp->exitStatus; - } - break; - } -#endif - -#if defined(PTW32_STATIC_LIB) - - pthread_win32_thread_detach_np (); - -#endif - -#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__) - _endthreadex (exitCode); -#else - _endthread (); -#endif - - } - -#if defined(__CLEANUP_SEH) - - - exceptionInformation[0] = (DWORD) (exception); - exceptionInformation[1] = (DWORD) (0); - exceptionInformation[2] = (DWORD) (0); - - RaiseException (EXCEPTION_PTW32_SERVICES, 0, 3, exceptionInformation); - -#else /* __CLEANUP_SEH */ - -#if defined(__CLEANUP_C) - - ptw32_pop_cleanup_all (1); - longjmp (sp->start_mark, exception); - -#else /* __CLEANUP_C */ - -#if defined(__CLEANUP_CXX) - - switch (exception) - { - case PTW32_EPS_CANCEL: - throw ptw32_exception_cancel (); - break; - case PTW32_EPS_EXIT: - throw ptw32_exception_exit (); - break; - } - -#else - -#error ERROR [__FILE__, line __LINE__]: Cleanup type undefined. - -#endif /* __CLEANUP_CXX */ - -#endif /* __CLEANUP_C */ - -#endif /* __CLEANUP_SEH */ - - /* Never reached */ -} - - -void -ptw32_pop_cleanup_all (int execute) -{ - while (NULL != ptw32_pop_cleanup (execute)) - { - } -} - - -DWORD -ptw32_get_exception_services_code (void) -{ -#if defined(__CLEANUP_SEH) - - return EXCEPTION_PTW32_SERVICES; - -#else - - return (DWORD)0; - -#endif -} diff --git a/deps/w32-pthreads/ptw32_timespec.c b/deps/w32-pthreads/ptw32_timespec.c deleted file mode 100644 index 1ce8f46..0000000 --- a/deps/w32-pthreads/ptw32_timespec.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * ptw32_timespec.c - * - * Description: - * This translation unit implements routines which are private to - * the implementation and may be used throughout it. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -#if defined(NEED_FTIME) - -/* - * time between jan 1, 1601 and jan 1, 1970 in units of 100 nanoseconds - */ -#define PTW32_TIMESPEC_TO_FILETIME_OFFSET \ - ( ((int64_t) 27111902 << 32) + (int64_t) 3577643008 ) - -INLINE void -ptw32_timespec_to_filetime (const struct timespec *ts, FILETIME * ft) - /* - * ------------------------------------------------------------------- - * converts struct timespec - * where the time is expressed in seconds and nanoseconds from Jan 1, 1970. - * into FILETIME (as set by GetSystemTimeAsFileTime), where the time is - * expressed in 100 nanoseconds from Jan 1, 1601, - * ------------------------------------------------------------------- - */ -{ - *(int64_t *) ft = ts->tv_sec * 10000000 - + (ts->tv_nsec + 50) / 100 + PTW32_TIMESPEC_TO_FILETIME_OFFSET; -} - -INLINE void -ptw32_filetime_to_timespec (const FILETIME * ft, struct timespec *ts) - /* - * ------------------------------------------------------------------- - * converts FILETIME (as set by GetSystemTimeAsFileTime), where the time is - * expressed in 100 nanoseconds from Jan 1, 1601, - * into struct timespec - * where the time is expressed in seconds and nanoseconds from Jan 1, 1970. - * ------------------------------------------------------------------- - */ -{ - ts->tv_sec = - (int) ((*(int64_t *) ft - PTW32_TIMESPEC_TO_FILETIME_OFFSET) / 10000000); - ts->tv_nsec = - (int) ((*(int64_t *) ft - PTW32_TIMESPEC_TO_FILETIME_OFFSET - - ((int64_t) ts->tv_sec * (int64_t) 10000000)) * 100); -} - -#endif /* NEED_FTIME */ diff --git a/deps/w32-pthreads/ptw32_tkAssocCreate.c b/deps/w32-pthreads/ptw32_tkAssocCreate.c deleted file mode 100644 index 7f0fab2..0000000 --- a/deps/w32-pthreads/ptw32_tkAssocCreate.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * ptw32_tkAssocCreate.c - * - * Description: - * This translation unit implements routines which are private to - * the implementation and may be used throughout it. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -int -ptw32_tkAssocCreate (ptw32_thread_t * sp, pthread_key_t key) - /* - * ------------------------------------------------------------------- - * This routine creates an association that - * is unique for the given (thread,key) combination.The association - * is referenced by both the thread and the key. - * This association allows us to determine what keys the - * current thread references and what threads a given key - * references. - * See the detailed description - * at the beginning of this file for further details. - * - * Notes: - * 1) New associations are pushed to the beginning of the - * chain so that the internal ptw32_selfThreadKey association - * is always last, thus allowing selfThreadExit to - * be implicitly called last by pthread_exit. - * 2) - * - * Parameters: - * thread - * current running thread. - * key - * key on which to create an association. - * Returns: - * 0 - if successful, - * ENOMEM - not enough memory to create assoc or other object - * EINVAL - an internal error occurred - * ENOSYS - an internal error occurred - * ------------------------------------------------------------------- - */ -{ - ThreadKeyAssoc *assoc; - - /* - * Have to create an association and add it - * to both the key and the thread. - * - * Both key->keyLock and thread->threadLock are locked before - * entry to this routine. - */ - assoc = (ThreadKeyAssoc *) calloc (1, sizeof (*assoc)); - - if (assoc == NULL) - { - return ENOMEM; - } - - assoc->thread = sp; - assoc->key = key; - - /* - * Register assoc with key - */ - assoc->prevThread = NULL; - assoc->nextThread = (ThreadKeyAssoc *) key->threads; - if (assoc->nextThread != NULL) - { - assoc->nextThread->prevThread = assoc; - } - key->threads = (void *) assoc; - - /* - * Register assoc with thread - */ - assoc->prevKey = NULL; - assoc->nextKey = (ThreadKeyAssoc *) sp->keys; - if (assoc->nextKey != NULL) - { - assoc->nextKey->prevKey = assoc; - } - sp->keys = (void *) assoc; - - return (0); - -} /* ptw32_tkAssocCreate */ diff --git a/deps/w32-pthreads/ptw32_tkAssocDestroy.c b/deps/w32-pthreads/ptw32_tkAssocDestroy.c deleted file mode 100644 index d43974f..0000000 --- a/deps/w32-pthreads/ptw32_tkAssocDestroy.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * ptw32_tkAssocDestroy.c - * - * Description: - * This translation unit implements routines which are private to - * the implementation and may be used throughout it. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -void -ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc) - /* - * ------------------------------------------------------------------- - * This routine releases all resources for the given ThreadKeyAssoc - * once it is no longer being referenced - * ie) either the key or thread has stopped referencing it. - * - * Parameters: - * assoc - * an instance of ThreadKeyAssoc. - * Returns: - * N/A - * ------------------------------------------------------------------- - */ -{ - - /* - * Both key->keyLock and thread->threadLock are locked before - * entry to this routine. - */ - if (assoc != NULL) - { - ThreadKeyAssoc * prev, * next; - - /* Remove assoc from thread's keys chain */ - prev = assoc->prevKey; - next = assoc->nextKey; - if (prev != NULL) - { - prev->nextKey = next; - } - if (next != NULL) - { - next->prevKey = prev; - } - - if (assoc->thread->keys == assoc) - { - /* We're at the head of the thread's keys chain */ - assoc->thread->keys = next; - } - if (assoc->thread->nextAssoc == assoc) - { - /* - * Thread is exiting and we're deleting the assoc to be processed next. - * Hand thread the assoc after this one. - */ - assoc->thread->nextAssoc = next; - } - - /* Remove assoc from key's threads chain */ - prev = assoc->prevThread; - next = assoc->nextThread; - if (prev != NULL) - { - prev->nextThread = next; - } - if (next != NULL) - { - next->prevThread = prev; - } - - if (assoc->key->threads == assoc) - { - /* We're at the head of the key's threads chain */ - assoc->key->threads = next; - } - - free (assoc); - } - -} /* ptw32_tkAssocDestroy */ diff --git a/deps/w32-pthreads/rwlock.c b/deps/w32-pthreads/rwlock.c deleted file mode 100644 index 089cf36..0000000 --- a/deps/w32-pthreads/rwlock.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * rwlock.c - * - * Description: - * This translation unit implements read/write lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "ptw32_rwlock_check_need_init.c" -#include "ptw32_rwlock_cancelwrwait.c" -#include "pthread_rwlock_init.c" -#include "pthread_rwlock_destroy.c" -#include "pthread_rwlockattr_init.c" -#include "pthread_rwlockattr_destroy.c" -#include "pthread_rwlockattr_getpshared.c" -#include "pthread_rwlockattr_setpshared.c" -#include "pthread_rwlock_rdlock.c" -#include "pthread_rwlock_timedrdlock.c" -#include "pthread_rwlock_wrlock.c" -#include "pthread_rwlock_timedwrlock.c" -#include "pthread_rwlock_unlock.c" -#include "pthread_rwlock_tryrdlock.c" -#include "pthread_rwlock_trywrlock.c" diff --git a/deps/w32-pthreads/sched.c b/deps/w32-pthreads/sched.c deleted file mode 100644 index 34dcbc0..0000000 --- a/deps/w32-pthreads/sched.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * sched.c - * - * Description: - * POSIX thread functions that deal with thread scheduling. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" -#include "sched.h" - -#include "pthread_attr_setschedpolicy.c" -#include "pthread_attr_getschedpolicy.c" -#include "pthread_attr_setschedparam.c" -#include "pthread_attr_getschedparam.c" -#include "pthread_attr_setinheritsched.c" -#include "pthread_attr_getinheritsched.c" -#include "pthread_setschedparam.c" -#include "pthread_getschedparam.c" -#include "sched_get_priority_max.c" -#include "sched_get_priority_min.c" -#include "sched_setscheduler.c" -#include "sched_getscheduler.c" -#include "sched_yield.c" diff --git a/deps/w32-pthreads/sched.h b/deps/w32-pthreads/sched.h deleted file mode 100644 index 806ee52..0000000 --- a/deps/w32-pthreads/sched.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Module: sched.h - * - * Purpose: - * Provides an implementation of POSIX realtime extensions - * as defined in - * - * POSIX 1003.1b-1993 (POSIX.1b) - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ -#if !defined(_SCHED_H) -#define _SCHED_H - -#undef PTW32_SCHED_LEVEL - -#if defined(_POSIX_SOURCE) -#define PTW32_SCHED_LEVEL 0 -/* Early POSIX */ -#endif - -#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 -#undef PTW32_SCHED_LEVEL -#define PTW32_SCHED_LEVEL 1 -/* Include 1b, 1c and 1d */ -#endif - -#if defined(INCLUDE_NP) -#undef PTW32_SCHED_LEVEL -#define PTW32_SCHED_LEVEL 2 -/* Include Non-Portable extensions */ -#endif - -#define PTW32_SCHED_LEVEL_MAX 3 - -#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_SCHED_LEVEL) -#define PTW32_SCHED_LEVEL PTW32_SCHED_LEVEL_MAX -/* Include everything */ -#endif - - -#if defined(__GNUC__) && !defined(__declspec) -# error Please upgrade your GNU compiler to one that supports __declspec. -#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. - */ -#if !defined(PTW32_STATIC_LIB) -# if defined(PTW32_BUILD) -# define PTW32_DLLPORT __declspec (dllexport) -# else -# define PTW32_DLLPORT -# endif -#else -# define PTW32_DLLPORT -#endif - -/* - * This is a duplicate of what is in the autoconf config.h, - * which is only used when building the pthread-win32 libraries. - */ - -#if !defined(PTW32_CONFIG_H) -# if defined(WINCE) -# define NEED_ERRNO -# define NEED_SEM -# endif -# if defined(__MINGW64__) -# define HAVE_STRUCT_TIMESPEC -# define HAVE_MODE_T -# elif defined(_UWIN) || defined(__MINGW32__) -# define HAVE_MODE_T -# endif -#endif - -/* - * - */ - -#if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX -#if defined(NEED_ERRNO) -#include "need_errno.h" -#else -#include -#endif -#endif /* PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX */ - -#if (defined(__MINGW64__) || defined(__MINGW32__)) || defined(_UWIN) -# if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX -/* For pid_t */ -# include -/* Required by Unix 98 */ -# include -# else - typedef int pid_t; -# endif -#else - typedef int pid_t; -#endif - -/* Thread scheduling policies */ - -enum { - SCHED_OTHER = 0, - SCHED_FIFO, - SCHED_RR, - SCHED_MIN = SCHED_OTHER, - SCHED_MAX = SCHED_RR -}; - -struct sched_param { - int sched_priority; -}; - -#if defined(__cplusplus) -extern "C" -{ -#endif /* __cplusplus */ - -PTW32_DLLPORT int __cdecl sched_yield (void); - -PTW32_DLLPORT int __cdecl sched_get_priority_min (int policy); - -PTW32_DLLPORT int __cdecl sched_get_priority_max (int policy); - -PTW32_DLLPORT int __cdecl sched_setscheduler (pid_t pid, int policy); - -PTW32_DLLPORT int __cdecl sched_getscheduler (pid_t pid); - -/* - * Note that this macro returns ENOTSUP rather than - * ENOSYS as might be expected. However, returning ENOSYS - * should mean that sched_get_priority_{min,max} are - * not implemented as well as sched_rr_get_interval. - * This is not the case, since we just don't support - * round-robin scheduling. Therefore I have chosen to - * return the same value as sched_setscheduler when - * SCHED_RR is passed to it. - */ -#define sched_rr_get_interval(_pid, _interval) \ - ( errno = ENOTSUP, (int) -1 ) - - -#if defined(__cplusplus) -} /* End of extern "C" */ -#endif /* __cplusplus */ - -#undef PTW32_SCHED_LEVEL -#undef PTW32_SCHED_LEVEL_MAX - -#endif /* !_SCHED_H */ - diff --git a/deps/w32-pthreads/sched_get_priority_max.c b/deps/w32-pthreads/sched_get_priority_max.c deleted file mode 100644 index bd9de08..0000000 --- a/deps/w32-pthreads/sched_get_priority_max.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * sched_get_priority_max.c - * - * Description: - * POSIX thread functions that deal with thread scheduling. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" -#include "sched.h" - -/* - * On Windows98, THREAD_PRIORITY_LOWEST is (-2) and - * THREAD_PRIORITY_HIGHEST is 2, and everything works just fine. - * - * On WinCE 3.0, it so happen that THREAD_PRIORITY_LOWEST is 5 - * and THREAD_PRIORITY_HIGHEST is 1 (yes, I know, it is funny: - * highest priority use smaller numbers) and the following happens: - * - * sched_get_priority_min() returns 5 - * sched_get_priority_max() returns 1 - * - * The following table shows the base priority levels for combinations - * of priority class and priority value in Win32. - * - * Process Priority Class Thread Priority Level - * ----------------------------------------------------------------- - * 1 IDLE_PRIORITY_CLASS THREAD_PRIORITY_IDLE - * 1 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_IDLE - * 1 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_IDLE - * 1 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_IDLE - * 1 HIGH_PRIORITY_CLASS THREAD_PRIORITY_IDLE - * 2 IDLE_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - * 3 IDLE_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - * 4 IDLE_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - * 4 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - * 5 IDLE_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - * 5 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - * 5 Background NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - * 6 IDLE_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - * 6 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - * 6 Background NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - * 7 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - * 7 Background NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - * 7 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - * 8 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - * 8 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - * 8 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - * 8 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - * 9 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - * 9 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - * 9 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - * 10 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - * 10 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - * 11 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - * 11 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - * 11 HIGH_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - * 12 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - * 12 HIGH_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - * 13 HIGH_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - * 14 HIGH_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - * 15 HIGH_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - * 15 HIGH_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - * 15 IDLE_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - * 15 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - * 15 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - * 15 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - * 16 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_IDLE - * 17 REALTIME_PRIORITY_CLASS -7 - * 18 REALTIME_PRIORITY_CLASS -6 - * 19 REALTIME_PRIORITY_CLASS -5 - * 20 REALTIME_PRIORITY_CLASS -4 - * 21 REALTIME_PRIORITY_CLASS -3 - * 22 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - * 23 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - * 24 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - * 25 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - * 26 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - * 27 REALTIME_PRIORITY_CLASS 3 - * 28 REALTIME_PRIORITY_CLASS 4 - * 29 REALTIME_PRIORITY_CLASS 5 - * 30 REALTIME_PRIORITY_CLASS 6 - * 31 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - * - * Windows NT: Values -7, -6, -5, -4, -3, 3, 4, 5, and 6 are not supported. - */ - - -int -sched_get_priority_max (int policy) -{ - if (policy < SCHED_MIN || policy > SCHED_MAX) - { - errno = EINVAL; - return -1; - } - -#if (THREAD_PRIORITY_LOWEST > THREAD_PRIORITY_NORMAL) - /* WinCE? */ - return PTW32_MAX (THREAD_PRIORITY_IDLE, THREAD_PRIORITY_TIME_CRITICAL); -#else - /* This is independent of scheduling policy in Win32. */ - return PTW32_MAX (THREAD_PRIORITY_IDLE, THREAD_PRIORITY_TIME_CRITICAL); -#endif -} diff --git a/deps/w32-pthreads/sched_get_priority_min.c b/deps/w32-pthreads/sched_get_priority_min.c deleted file mode 100644 index 7e50f1e..0000000 --- a/deps/w32-pthreads/sched_get_priority_min.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * sched_get_priority_min.c - * - * Description: - * POSIX thread functions that deal with thread scheduling. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" -#include "sched.h" - -/* - * On Windows98, THREAD_PRIORITY_LOWEST is (-2) and - * THREAD_PRIORITY_HIGHEST is 2, and everything works just fine. - * - * On WinCE 3.0, it so happen that THREAD_PRIORITY_LOWEST is 5 - * and THREAD_PRIORITY_HIGHEST is 1 (yes, I know, it is funny: - * highest priority use smaller numbers) and the following happens: - * - * sched_get_priority_min() returns 5 - * sched_get_priority_max() returns 1 - * - * The following table shows the base priority levels for combinations - * of priority class and priority value in Win32. - * - * Process Priority Class Thread Priority Level - * ----------------------------------------------------------------- - * 1 IDLE_PRIORITY_CLASS THREAD_PRIORITY_IDLE - * 1 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_IDLE - * 1 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_IDLE - * 1 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_IDLE - * 1 HIGH_PRIORITY_CLASS THREAD_PRIORITY_IDLE - * 2 IDLE_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - * 3 IDLE_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - * 4 IDLE_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - * 4 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - * 5 IDLE_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - * 5 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - * 5 Background NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - * 6 IDLE_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - * 6 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - * 6 Background NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - * 7 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - * 7 Background NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - * 7 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - * 8 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - * 8 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - * 8 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - * 8 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - * 9 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - * 9 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - * 9 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - * 10 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - * 10 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - * 11 Foreground NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - * 11 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - * 11 HIGH_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - * 12 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - * 12 HIGH_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - * 13 HIGH_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - * 14 HIGH_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - * 15 HIGH_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - * 15 HIGH_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - * 15 IDLE_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - * 15 BELOW_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - * 15 NORMAL_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - * 15 ABOVE_NORMAL_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - * 16 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_IDLE - * 17 REALTIME_PRIORITY_CLASS -7 - * 18 REALTIME_PRIORITY_CLASS -6 - * 19 REALTIME_PRIORITY_CLASS -5 - * 20 REALTIME_PRIORITY_CLASS -4 - * 21 REALTIME_PRIORITY_CLASS -3 - * 22 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_LOWEST - * 23 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_BELOW_NORMAL - * 24 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_NORMAL - * 25 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_ABOVE_NORMAL - * 26 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_HIGHEST - * 27 REALTIME_PRIORITY_CLASS 3 - * 28 REALTIME_PRIORITY_CLASS 4 - * 29 REALTIME_PRIORITY_CLASS 5 - * 30 REALTIME_PRIORITY_CLASS 6 - * 31 REALTIME_PRIORITY_CLASS THREAD_PRIORITY_TIME_CRITICAL - * - * Windows NT: Values -7, -6, -5, -4, -3, 3, 4, 5, and 6 are not supported. - * - */ - - -int -sched_get_priority_min (int policy) -{ - if (policy < SCHED_MIN || policy > SCHED_MAX) - { - errno = EINVAL; - return -1; - } - -#if (THREAD_PRIORITY_LOWEST > THREAD_PRIORITY_NORMAL) - /* WinCE? */ - return PTW32_MIN (THREAD_PRIORITY_IDLE, THREAD_PRIORITY_TIME_CRITICAL); -#else - /* This is independent of scheduling policy in Win32. */ - return PTW32_MIN (THREAD_PRIORITY_IDLE, THREAD_PRIORITY_TIME_CRITICAL); -#endif -} diff --git a/deps/w32-pthreads/sched_getscheduler.c b/deps/w32-pthreads/sched_getscheduler.c deleted file mode 100644 index f849936..0000000 --- a/deps/w32-pthreads/sched_getscheduler.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * sched_getscheduler.c - * - * Description: - * POSIX thread functions that deal with thread scheduling. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" -#include "sched.h" - -int -sched_getscheduler (pid_t pid) -{ - /* - * Win32 only has one policy which we call SCHED_OTHER. - * However, we try to provide other valid side-effects - * such as EPERM and ESRCH errors. - */ - if (0 != pid) - { - int selfPid = (int) GetCurrentProcessId (); - - if (pid != selfPid) - { - HANDLE h = - OpenProcess (PROCESS_QUERY_INFORMATION, PTW32_FALSE, (DWORD) pid); - - if (NULL == h) - { - errno = - (GetLastError () == - (0xFF & ERROR_ACCESS_DENIED)) ? EPERM : ESRCH; - return -1; - } - else - CloseHandle(h); - } - } - - return SCHED_OTHER; -} diff --git a/deps/w32-pthreads/sched_setscheduler.c b/deps/w32-pthreads/sched_setscheduler.c deleted file mode 100644 index c292888..0000000 --- a/deps/w32-pthreads/sched_setscheduler.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * sched_setscheduler.c - * - * Description: - * POSIX thread functions that deal with thread scheduling. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" -#include "sched.h" - -int -sched_setscheduler (pid_t pid, int policy) -{ - /* - * Win32 only has one policy which we call SCHED_OTHER. - * However, we try to provide other valid side-effects - * such as EPERM and ESRCH errors. Choosing to check - * for a valid policy last allows us to get the most value out - * of this function. - */ - if (0 != pid) - { - int selfPid = (int) GetCurrentProcessId (); - - if (pid != selfPid) - { - HANDLE h = - OpenProcess (PROCESS_SET_INFORMATION, PTW32_FALSE, (DWORD) pid); - - if (NULL == h) - { - errno = - (GetLastError () == - (0xFF & ERROR_ACCESS_DENIED)) ? EPERM : ESRCH; - return -1; - } - else - CloseHandle(h); - } - } - - if (SCHED_OTHER != policy) - { - errno = ENOSYS; - return -1; - } - - /* - * Don't set anything because there is nothing to set. - * Just return the current (the only possible) value. - */ - return SCHED_OTHER; -} diff --git a/deps/w32-pthreads/sched_yield.c b/deps/w32-pthreads/sched_yield.c deleted file mode 100644 index 9744071..0000000 --- a/deps/w32-pthreads/sched_yield.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * sched_yield.c - * - * Description: - * POSIX thread functions that deal with thread scheduling. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" -#include "sched.h" - -int -sched_yield (void) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function indicates that the calling thread is - * willing to give up some time slices to other threads. - * - * PARAMETERS - * N/A - * - * - * DESCRIPTION - * This function indicates that the calling thread is - * willing to give up some time slices to other threads. - * NOTE: Since this is part of POSIX 1003.1b - * (realtime extensions), it is defined as returning - * -1 if an error occurs and sets errno to the actual - * error. - * - * RESULTS - * 0 successfully created semaphore, - * ENOSYS sched_yield not supported, - * - * ------------------------------------------------------ - */ -{ - Sleep (0); - - return 0; -} diff --git a/deps/w32-pthreads/sem_close.c b/deps/w32-pthreads/sem_close.c deleted file mode 100644 index 6e434a1..0000000 --- a/deps/w32-pthreads/sem_close.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * ------------------------------------------------------------- - * - * Module: sem_close.c - * - * Purpose: - * Semaphores aren't actually part of the PThreads standard. - * They are defined by the POSIX Standard: - * - * POSIX 1003.1b-1993 (POSIX.1b) - * - * ------------------------------------------------------------- - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "semaphore.h" -#include "implement.h" - -/* ignore warning "unreferenced formal parameter" */ -#if defined(_MSC_VER) -#pragma warning( disable : 4100 ) -#endif - -int -sem_close (sem_t * sem) -{ - errno = ENOSYS; - return -1; -} /* sem_close */ diff --git a/deps/w32-pthreads/sem_destroy.c b/deps/w32-pthreads/sem_destroy.c deleted file mode 100644 index 880a412..0000000 --- a/deps/w32-pthreads/sem_destroy.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * ------------------------------------------------------------- - * - * Module: sem_destroy.c - * - * Purpose: - * Semaphores aren't actually part of the PThreads standard. - * They are defined by the POSIX Standard: - * - * POSIX 1003.1b-1993 (POSIX.1b) - * - * ------------------------------------------------------------- - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "semaphore.h" -#include "implement.h" - - -int -sem_destroy (sem_t * sem) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function destroys an unnamed semaphore. - * - * PARAMETERS - * sem - * pointer to an instance of sem_t - * - * DESCRIPTION - * This function destroys an unnamed semaphore. - * - * RESULTS - * 0 successfully destroyed semaphore, - * -1 failed, error in errno - * ERRNO - * EINVAL 'sem' is not a valid semaphore, - * ENOSYS semaphores are not supported, - * EBUSY threads (or processes) are currently - * blocked on 'sem' - * - * ------------------------------------------------------ - */ -{ - int result = 0; - sem_t s = NULL; - - if (sem == NULL || *sem == NULL) - { - result = EINVAL; - } - else - { - s = *sem; - - if ((result = pthread_mutex_lock (&s->lock)) == 0) - { - if (s->value < 0) - { - (void) pthread_mutex_unlock (&s->lock); - result = EBUSY; - } - else - { - /* There are no threads currently blocked on this semaphore. */ - - if (!CloseHandle (s->sem)) - { - (void) pthread_mutex_unlock (&s->lock); - result = EINVAL; - } - else - { - /* - * Invalidate the semaphore handle when we have the lock. - * Other sema operations should test this after acquiring the lock - * to check that the sema is still valid, i.e. before performing any - * operations. This may only be necessary before the sema op routine - * returns so that the routine can return EINVAL - e.g. if setting - * s->value to SEM_VALUE_MAX below does force a fall-through. - */ - *sem = NULL; - - /* Prevent anyone else actually waiting on or posting this sema. - */ - s->value = SEM_VALUE_MAX; - - (void) pthread_mutex_unlock (&s->lock); - - do - { - /* Give other threads a chance to run and exit any sema op - * routines. Due to the SEM_VALUE_MAX value, if sem_post or - * sem_wait were blocked by us they should fall through. - */ - Sleep(0); - } - while (pthread_mutex_destroy (&s->lock) == EBUSY); - } - } - } - } - - if (result != 0) - { - errno = result; - return -1; - } - - free (s); - - return 0; - -} /* sem_destroy */ diff --git a/deps/w32-pthreads/sem_getvalue.c b/deps/w32-pthreads/sem_getvalue.c deleted file mode 100644 index 13525c6..0000000 --- a/deps/w32-pthreads/sem_getvalue.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * ------------------------------------------------------------- - * - * Module: sem_getvalue.c - * - * Purpose: - * Semaphores aren't actually part of PThreads. - * They are defined by the POSIX Standard: - * - * POSIX 1003.1-2001 - * - * ------------------------------------------------------------- - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "semaphore.h" -#include "implement.h" - - -int -sem_getvalue (sem_t * sem, int *sval) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function stores the current count value of the - * semaphore. - * RESULTS - * - * Return value - * - * 0 sval has been set. - * -1 failed, error in errno - * - * in global errno - * - * EINVAL 'sem' is not a valid semaphore, - * ENOSYS this function is not supported, - * - * - * PARAMETERS - * - * sem pointer to an instance of sem_t - * - * sval pointer to int. - * - * DESCRIPTION - * This function stores the current count value of the semaphore - * pointed to by sem in the int pointed to by sval. - */ -{ - if (sem == NULL || *sem == NULL || sval == NULL) - { - errno = EINVAL; - return -1; - } - else - { - long value; - register sem_t s = *sem; - int result = 0; - - if ((result = pthread_mutex_lock(&s->lock)) == 0) - { - /* See sem_destroy.c - */ - if (*sem == NULL) - { - (void) pthread_mutex_unlock (&s->lock); - errno = EINVAL; - return -1; - } - - value = s->value; - (void) pthread_mutex_unlock(&s->lock); - *sval = value; - } - - return result; - } - -} /* sem_getvalue */ diff --git a/deps/w32-pthreads/sem_init.c b/deps/w32-pthreads/sem_init.c deleted file mode 100644 index b8c31fe..0000000 --- a/deps/w32-pthreads/sem_init.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - * ------------------------------------------------------------- - * - * Module: sem_init.c - * - * Purpose: - * Semaphores aren't actually part of PThreads. - * They are defined by the POSIX Standard: - * - * POSIX 1003.1-2001 - * - * ------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "semaphore.h" -#include "implement.h" - -int -sem_init (sem_t * sem, int pshared, unsigned int value) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function initializes a semaphore. The - * initial value of the semaphore is 'value' - * - * PARAMETERS - * sem - * pointer to an instance of sem_t - * - * pshared - * if zero, this semaphore may only be shared between - * threads in the same process. - * if nonzero, the semaphore can be shared between - * processes - * - * value - * initial value of the semaphore counter - * - * DESCRIPTION - * This function initializes a semaphore. The - * initial value of the semaphore is set to 'value'. - * - * RESULTS - * 0 successfully created semaphore, - * -1 failed, error in errno - * ERRNO - * EINVAL 'sem' is not a valid semaphore, or - * 'value' >= SEM_VALUE_MAX - * ENOMEM out of memory, - * ENOSPC a required resource has been exhausted, - * ENOSYS semaphores are not supported, - * EPERM the process lacks appropriate privilege - * - * ------------------------------------------------------ - */ -{ - int result = 0; - sem_t s = NULL; - - if (pshared != 0) - { - /* - * Creating a semaphore that can be shared between - * processes - */ - result = EPERM; - } - else if (value > (unsigned int)SEM_VALUE_MAX) - { - result = EINVAL; - } - else - { - s = (sem_t) calloc (1, sizeof (*s)); - - if (NULL == s) - { - result = ENOMEM; - } - else - { - - s->value = value; - if (pthread_mutex_init(&s->lock, NULL) == 0) - { - -#if defined(NEED_SEM) - - s->sem = CreateEvent (NULL, - PTW32_FALSE, /* auto (not manual) reset */ - PTW32_FALSE, /* initial state is unset */ - NULL); - - if (0 == s->sem) - { - free (s); - (void) pthread_mutex_destroy(&s->lock); - result = ENOSPC; - } - else - { - s->leftToUnblock = 0; - } - -#else /* NEED_SEM */ - - if ((s->sem = CreateSemaphore (NULL, /* Always NULL */ - (long) 0, /* Force threads to wait */ - (long) SEM_VALUE_MAX, /* Maximum value */ - NULL)) == 0) /* Name */ - { - (void) pthread_mutex_destroy(&s->lock); - result = ENOSPC; - } - -#endif /* NEED_SEM */ - - } - else - { - result = ENOSPC; - } - - if (result != 0) - { - free(s); - } - } - } - - if (result != 0) - { - errno = result; - return -1; - } - - *sem = s; - - return 0; - -} /* sem_init */ diff --git a/deps/w32-pthreads/sem_open.c b/deps/w32-pthreads/sem_open.c deleted file mode 100644 index a0d7a34..0000000 --- a/deps/w32-pthreads/sem_open.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * ------------------------------------------------------------- - * - * Module: sem_open.c - * - * Purpose: - * Semaphores aren't actually part of the PThreads standard. - * They are defined by the POSIX Standard: - * - * POSIX 1003.1b-1993 (POSIX.1b) - * - * ------------------------------------------------------------- - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "semaphore.h" -#include "implement.h" - -/* ignore warning "unreferenced formal parameter" */ -#if defined(_MSC_VER) -#pragma warning( disable : 4100 ) -#endif - -int -sem_open (const char *name, int oflag, mode_t mode, unsigned int value) -{ - errno = ENOSYS; - return -1; -} /* sem_open */ diff --git a/deps/w32-pthreads/sem_post.c b/deps/w32-pthreads/sem_post.c deleted file mode 100644 index d8a3e3d..0000000 --- a/deps/w32-pthreads/sem_post.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - * ------------------------------------------------------------- - * - * Module: sem_post.c - * - * Purpose: - * Semaphores aren't actually part of the PThreads standard. - * They are defined by the POSIX Standard: - * - * POSIX 1003.1b-1993 (POSIX.1b) - * - * ------------------------------------------------------------- - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "semaphore.h" -#include "implement.h" - - -int -sem_post (sem_t * sem) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function posts a wakeup to a semaphore. - * - * PARAMETERS - * sem - * pointer to an instance of sem_t - * - * DESCRIPTION - * This function posts a wakeup to a semaphore. If there - * are waiting threads (or processes), one is awakened; - * otherwise, the semaphore value is incremented by one. - * - * RESULTS - * 0 successfully posted semaphore, - * -1 failed, error in errno - * ERRNO - * EINVAL 'sem' is not a valid semaphore, - * ENOSYS semaphores are not supported, - * ERANGE semaphore count is too big - * - * ------------------------------------------------------ - */ -{ - int result = 0; - sem_t s = *sem; - - if (s == NULL) - { - result = EINVAL; - } - else if ((result = pthread_mutex_lock (&s->lock)) == 0) - { - /* See sem_destroy.c - */ - if (*sem == NULL) - { - (void) pthread_mutex_unlock (&s->lock); - result = EINVAL; - return -1; - } - - if (s->value < SEM_VALUE_MAX) - { -#if defined(NEED_SEM) - if (++s->value <= 0 - && !SetEvent(s->sem)) - { - s->value--; - result = EINVAL; - } -#else - if (++s->value <= 0 - && !ReleaseSemaphore (s->sem, 1, NULL)) - { - s->value--; - result = EINVAL; - } -#endif /* NEED_SEM */ - } - else - { - result = ERANGE; - } - - (void) pthread_mutex_unlock (&s->lock); - } - - if (result != 0) - { - errno = result; - return -1; - } - - return 0; - -} /* sem_post */ diff --git a/deps/w32-pthreads/sem_post_multiple.c b/deps/w32-pthreads/sem_post_multiple.c deleted file mode 100644 index c0a3f68..0000000 --- a/deps/w32-pthreads/sem_post_multiple.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * ------------------------------------------------------------- - * - * Module: sem_post_multiple.c - * - * Purpose: - * Semaphores aren't actually part of the PThreads standard. - * They are defined by the POSIX Standard: - * - * POSIX 1003.1b-1993 (POSIX.1b) - * - * ------------------------------------------------------------- - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "semaphore.h" -#include "implement.h" - - -int -sem_post_multiple (sem_t * sem, int count) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function posts multiple wakeups to a semaphore. - * - * PARAMETERS - * sem - * pointer to an instance of sem_t - * - * count - * counter, must be greater than zero. - * - * DESCRIPTION - * This function posts multiple wakeups to a semaphore. If there - * are waiting threads (or processes), n <= count are awakened; - * the semaphore value is incremented by count - n. - * - * RESULTS - * 0 successfully posted semaphore, - * -1 failed, error in errno - * ERRNO - * EINVAL 'sem' is not a valid semaphore - * or count is less than or equal to zero. - * ERANGE semaphore count is too big - * - * ------------------------------------------------------ - */ -{ - int result = 0; - long waiters; - sem_t s = *sem; - - if (s == NULL || count <= 0) - { - result = EINVAL; - } - else if ((result = pthread_mutex_lock (&s->lock)) == 0) - { - /* See sem_destroy.c - */ - if (*sem == NULL) - { - (void) pthread_mutex_unlock (&s->lock); - result = EINVAL; - return -1; - } - - if (s->value <= (SEM_VALUE_MAX - count)) - { - waiters = -s->value; - s->value += count; - if (waiters > 0) - { -#if defined(NEED_SEM) - if (SetEvent(s->sem)) - { - waiters--; - s->leftToUnblock += count - 1; - if (s->leftToUnblock > waiters) - { - s->leftToUnblock = waiters; - } - } -#else - if (ReleaseSemaphore (s->sem, (waiters<=count)?waiters:count, 0)) - { - /* No action */ - } -#endif - else - { - s->value -= count; - result = EINVAL; - } - } - } - else - { - result = ERANGE; - } - (void) pthread_mutex_unlock (&s->lock); - } - - if (result != 0) - { - errno = result; - return -1; - } - - return 0; - -} /* sem_post_multiple */ diff --git a/deps/w32-pthreads/sem_timedwait.c b/deps/w32-pthreads/sem_timedwait.c deleted file mode 100644 index 831a050..0000000 --- a/deps/w32-pthreads/sem_timedwait.c +++ /dev/null @@ -1,238 +0,0 @@ -/* - * ------------------------------------------------------------- - * - * Module: sem_timedwait.c - * - * Purpose: - * Semaphores aren't actually part of the PThreads standard. - * They are defined by the POSIX Standard: - * - * POSIX 1003.1b-1993 (POSIX.1b) - * - * ------------------------------------------------------------- - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "semaphore.h" -#include "implement.h" - - -typedef struct { - sem_t sem; - int * resultPtr; -} sem_timedwait_cleanup_args_t; - - -static void PTW32_CDECL -ptw32_sem_timedwait_cleanup (void * args) -{ - sem_timedwait_cleanup_args_t * a = (sem_timedwait_cleanup_args_t *)args; - sem_t s = a->sem; - - if (pthread_mutex_lock (&s->lock) == 0) - { - /* - * We either timed out or were cancelled. - * If someone has posted between then and now we try to take the semaphore. - * Otherwise the semaphore count may be wrong after we - * return. In the case of a cancellation, it is as if we - * were cancelled just before we return (after taking the semaphore) - * which is ok. - */ - if (WaitForSingleObject(s->sem, 0) == WAIT_OBJECT_0) - { - /* We got the semaphore on the second attempt */ - *(a->resultPtr) = 0; - } - else - { - /* Indicate we're no longer waiting */ - s->value++; -#if defined(NEED_SEM) - if (s->value > 0) - { - s->leftToUnblock = 0; - } -#else - /* - * Don't release the W32 sema, it doesn't need adjustment - * because it doesn't record the number of waiters. - */ -#endif - } - (void) pthread_mutex_unlock (&s->lock); - } -} - - -int -sem_timedwait (sem_t * sem, const struct timespec *abstime) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function waits on a semaphore possibly until - * 'abstime' time. - * - * PARAMETERS - * sem - * pointer to an instance of sem_t - * - * abstime - * pointer to an instance of struct timespec - * - * DESCRIPTION - * This function waits on a semaphore. If the - * semaphore value is greater than zero, it decreases - * its value by one. If the semaphore value is zero, then - * the calling thread (or process) is blocked until it can - * successfully decrease the value or until interrupted by - * a signal. - * - * If 'abstime' is a NULL pointer then this function will - * block until it can successfully decrease the value or - * until interrupted by a signal. - * - * RESULTS - * 0 successfully decreased semaphore, - * -1 failed, error in errno - * ERRNO - * EINVAL 'sem' is not a valid semaphore, - * ENOSYS semaphores are not supported, - * EINTR the function was interrupted by a signal, - * EDEADLK a deadlock condition was detected. - * ETIMEDOUT abstime elapsed before success. - * - * ------------------------------------------------------ - */ -{ - int result = 0; - sem_t s = *sem; - - pthread_testcancel(); - - if (sem == NULL) - { - result = EINVAL; - } - else - { - DWORD milliseconds; - - if (abstime == NULL) - { - milliseconds = INFINITE; - } - else - { - /* - * Calculate timeout as milliseconds from current system time. - */ - milliseconds = ptw32_relmillisecs (abstime); - } - - if ((result = pthread_mutex_lock (&s->lock)) == 0) - { - int v; - - /* See sem_destroy.c - */ - if (*sem == NULL) - { - (void) pthread_mutex_unlock (&s->lock); - errno = EINVAL; - return -1; - } - - v = --s->value; - (void) pthread_mutex_unlock (&s->lock); - - if (v < 0) - { -#if defined(NEED_SEM) - int timedout; -#endif - sem_timedwait_cleanup_args_t cleanup_args; - - cleanup_args.sem = s; - cleanup_args.resultPtr = &result; - -#if defined(_MSC_VER) && _MSC_VER < 1400 -#pragma inline_depth(0) -#endif - /* Must wait */ - pthread_cleanup_push(ptw32_sem_timedwait_cleanup, (void *) &cleanup_args); -#if defined(NEED_SEM) - timedout = -#endif - result = pthreadCancelableTimedWait (s->sem, milliseconds); - pthread_cleanup_pop(result); -#if defined(_MSC_VER) && _MSC_VER < 1400 -#pragma inline_depth() -#endif - -#if defined(NEED_SEM) - - if (!timedout && pthread_mutex_lock (&s->lock) == 0) - { - if (*sem == NULL) - { - (void) pthread_mutex_unlock (&s->lock); - errno = EINVAL; - return -1; - } - - if (s->leftToUnblock > 0) - { - --s->leftToUnblock; - SetEvent(s->sem); - } - (void) pthread_mutex_unlock (&s->lock); - } - -#endif /* NEED_SEM */ - - } - } - - } - - if (result != 0) - { - - errno = result; - return -1; - - } - - return 0; - -} /* sem_timedwait */ diff --git a/deps/w32-pthreads/sem_trywait.c b/deps/w32-pthreads/sem_trywait.c deleted file mode 100644 index cf5f5bb..0000000 --- a/deps/w32-pthreads/sem_trywait.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * ------------------------------------------------------------- - * - * Module: sem_trywait.c - * - * Purpose: - * Semaphores aren't actually part of the PThreads standard. - * They are defined by the POSIX Standard: - * - * POSIX 1003.1b-1993 (POSIX.1b) - * - * ------------------------------------------------------------- - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "semaphore.h" -#include "implement.h" - - -int -sem_trywait (sem_t * sem) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function tries to wait on a semaphore. - * - * PARAMETERS - * sem - * pointer to an instance of sem_t - * - * DESCRIPTION - * This function tries to wait on a semaphore. If the - * semaphore value is greater than zero, it decreases - * its value by one. If the semaphore value is zero, then - * this function returns immediately with the error EAGAIN - * - * RESULTS - * 0 successfully decreased semaphore, - * -1 failed, error in errno - * ERRNO - * EAGAIN the semaphore was already locked, - * EINVAL 'sem' is not a valid semaphore, - * ENOTSUP sem_trywait is not supported, - * EINTR the function was interrupted by a signal, - * EDEADLK a deadlock condition was detected. - * - * ------------------------------------------------------ - */ -{ - int result = 0; - sem_t s = *sem; - - if (s == NULL) - { - result = EINVAL; - } - else if ((result = pthread_mutex_lock (&s->lock)) == 0) - { - /* See sem_destroy.c - */ - if (*sem == NULL) - { - (void) pthread_mutex_unlock (&s->lock); - errno = EINVAL; - return -1; - } - - if (s->value > 0) - { - s->value--; - } - else - { - result = EAGAIN; - } - - (void) pthread_mutex_unlock (&s->lock); - } - - if (result != 0) - { - errno = result; - return -1; - } - - return 0; - -} /* sem_trywait */ diff --git a/deps/w32-pthreads/sem_unlink.c b/deps/w32-pthreads/sem_unlink.c deleted file mode 100644 index a232caf..0000000 --- a/deps/w32-pthreads/sem_unlink.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * ------------------------------------------------------------- - * - * Module: sem_unlink.c - * - * Purpose: - * Semaphores aren't actually part of the PThreads standard. - * They are defined by the POSIX Standard: - * - * POSIX 1003.1b-1993 (POSIX.1b) - * - * ------------------------------------------------------------- - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "semaphore.h" -#include "implement.h" - -/* ignore warning "unreferenced formal parameter" */ -#if defined(_MSC_VER) -#pragma warning( disable : 4100 ) -#endif - -int -sem_unlink (const char *name) -{ - errno = ENOSYS; - return -1; -} /* sem_unlink */ diff --git a/deps/w32-pthreads/sem_wait.c b/deps/w32-pthreads/sem_wait.c deleted file mode 100644 index 26184fa..0000000 --- a/deps/w32-pthreads/sem_wait.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - * ------------------------------------------------------------- - * - * Module: sem_wait.c - * - * Purpose: - * Semaphores aren't actually part of the PThreads standard. - * They are defined by the POSIX Standard: - * - * POSIX 1003.1b-1993 (POSIX.1b) - * - * ------------------------------------------------------------- - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "semaphore.h" -#include "implement.h" - - -static void PTW32_CDECL -ptw32_sem_wait_cleanup(void * sem) -{ - sem_t s = (sem_t) sem; - - if (pthread_mutex_lock (&s->lock) == 0) - { - /* - * If sema is destroyed do nothing, otherwise:- - * If the sema is posted between us being cancelled and us locking - * the sema again above then we need to consume that post but cancel - * anyway. If we don't get the semaphore we indicate that we're no - * longer waiting. - */ - if (*((sem_t *)sem) != NULL && !(WaitForSingleObject(s->sem, 0) == WAIT_OBJECT_0)) - { - ++s->value; -#if defined(NEED_SEM) - if (s->value > 0) - { - s->leftToUnblock = 0; - } -#else - /* - * Don't release the W32 sema, it doesn't need adjustment - * because it doesn't record the number of waiters. - */ -#endif /* NEED_SEM */ - } - (void) pthread_mutex_unlock (&s->lock); - } -} - -int -sem_wait (sem_t * sem) - /* - * ------------------------------------------------------ - * DOCPUBLIC - * This function waits on a semaphore. - * - * PARAMETERS - * sem - * pointer to an instance of sem_t - * - * DESCRIPTION - * This function waits on a semaphore. If the - * semaphore value is greater than zero, it decreases - * its value by one. If the semaphore value is zero, then - * the calling thread (or process) is blocked until it can - * successfully decrease the value or until interrupted by - * a signal. - * - * RESULTS - * 0 successfully decreased semaphore, - * -1 failed, error in errno - * ERRNO - * EINVAL 'sem' is not a valid semaphore, - * ENOSYS semaphores are not supported, - * EINTR the function was interrupted by a signal, - * EDEADLK a deadlock condition was detected. - * - * ------------------------------------------------------ - */ -{ - int result = 0; - sem_t s = *sem; - - pthread_testcancel(); - - if (s == NULL) - { - result = EINVAL; - } - else - { - if ((result = pthread_mutex_lock (&s->lock)) == 0) - { - int v; - - /* See sem_destroy.c - */ - if (*sem == NULL) - { - (void) pthread_mutex_unlock (&s->lock); - errno = EINVAL; - return -1; - } - - v = --s->value; - (void) pthread_mutex_unlock (&s->lock); - - if (v < 0) - { -#if defined(_MSC_VER) && _MSC_VER < 1400 -#pragma inline_depth(0) -#endif - /* Must wait */ - pthread_cleanup_push(ptw32_sem_wait_cleanup, (void *) s); - result = pthreadCancelableWait (s->sem); - /* Cleanup if we're canceled or on any other error */ - pthread_cleanup_pop(result); -#if defined(_MSC_VER) && _MSC_VER < 1400 -#pragma inline_depth() -#endif - } -#if defined(NEED_SEM) - - if (!result && pthread_mutex_lock (&s->lock) == 0) - { - if (*sem == NULL) - { - (void) pthread_mutex_unlock (&s->lock); - errno = EINVAL; - return -1; - } - - if (s->leftToUnblock > 0) - { - --s->leftToUnblock; - SetEvent(s->sem); - } - (void) pthread_mutex_unlock (&s->lock); - } - -#endif /* NEED_SEM */ - - } - - } - - if (result != 0) - { - errno = result; - return -1; - } - - return 0; - -} /* sem_wait */ diff --git a/deps/w32-pthreads/semaphore.c b/deps/w32-pthreads/semaphore.c deleted file mode 100644 index dfcab9e..0000000 --- a/deps/w32-pthreads/semaphore.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * ------------------------------------------------------------- - * - * Module: semaphore.c - * - * Purpose: - * Concatenated version of separate modules to allow - * inlining optimisation, which it is assumed can only - * be effective within a single module. - * - * Semaphores aren't actually part of the PThreads standard. - * They are defined by the POSIX Standard: - * - * POSIX 1003.1b-1993 (POSIX.1b) - * - * ------------------------------------------------------------- - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#if !defined(NEED_FTIME) -# include -#endif - -#include - -#include "pthread.h" -#include "semaphore.h" -#include "implement.h" - - -#include "sem_init.c" -#include "sem_destroy.c" -#include "sem_trywait.c" -#include "sem_wait.c" -#include "sem_timedwait.c" -#include "sem_post.c" -#include "sem_post_multiple.c" -#include "sem_getvalue.c" -#include "sem_open.c" -#include "sem_close.c" -#include "sem_unlink.c" diff --git a/deps/w32-pthreads/semaphore.h b/deps/w32-pthreads/semaphore.h deleted file mode 100644 index 52890ed..0000000 --- a/deps/w32-pthreads/semaphore.h +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Module: semaphore.h - * - * Purpose: - * Semaphores aren't actually part of the PThreads standard. - * They are defined by the POSIX Standard: - * - * POSIX 1003.1b-1993 (POSIX.1b) - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ -#if !defined( SEMAPHORE_H ) -#define SEMAPHORE_H - -#undef PTW32_SEMAPHORE_LEVEL - -#if defined(_POSIX_SOURCE) -#define PTW32_SEMAPHORE_LEVEL 0 -/* Early POSIX */ -#endif - -#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 -#undef PTW32_SEMAPHORE_LEVEL -#define PTW32_SEMAPHORE_LEVEL 1 -/* Include 1b, 1c and 1d */ -#endif - -#if defined(INCLUDE_NP) -#undef PTW32_SEMAPHORE_LEVEL -#define PTW32_SEMAPHORE_LEVEL 2 -/* Include Non-Portable extensions */ -#endif - -#define PTW32_SEMAPHORE_LEVEL_MAX 3 - -#if !defined(PTW32_SEMAPHORE_LEVEL) -#define PTW32_SEMAPHORE_LEVEL PTW32_SEMAPHORE_LEVEL_MAX -/* Include everything */ -#endif - -#if defined(__GNUC__) && ! defined (__declspec) -# error Please upgrade your GNU compiler to one that supports __declspec. -#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. - */ -#if !defined(PTW32_STATIC_LIB) -# if defined(PTW32_BUILD) -# define PTW32_DLLPORT __declspec (dllexport) -# else -# define PTW32_DLLPORT -# endif -#else -# define PTW32_DLLPORT -#endif - -/* - * This is a duplicate of what is in the autoconf config.h, - * which is only used when building the pthread-win32 libraries. - */ - -#if !defined(PTW32_CONFIG_H) -# if defined(WINCE) -# define NEED_ERRNO -# define NEED_SEM -# endif -# if defined(__MINGW64__) -# define HAVE_STRUCT_TIMESPEC -# define HAVE_MODE_T -# elif defined(_UWIN) || defined(__MINGW32__) -# define HAVE_MODE_T -# endif -#endif - -/* - * - */ - -#if PTW32_SEMAPHORE_LEVEL >= PTW32_SEMAPHORE_LEVEL_MAX -#if defined(NEED_ERRNO) -#include "need_errno.h" -#else -#include -#endif -#endif /* PTW32_SEMAPHORE_LEVEL >= PTW32_SEMAPHORE_LEVEL_MAX */ - -#define _POSIX_SEMAPHORES - -#if defined(__cplusplus) -extern "C" -{ -#endif /* __cplusplus */ - -#if !defined(HAVE_MODE_T) -typedef unsigned int mode_t; -#endif - - -typedef struct sem_t_ * sem_t; - -PTW32_DLLPORT int __cdecl sem_init (sem_t * sem, - int pshared, - unsigned int value); - -PTW32_DLLPORT int __cdecl sem_destroy (sem_t * sem); - -PTW32_DLLPORT int __cdecl sem_trywait (sem_t * sem); - -PTW32_DLLPORT int __cdecl sem_wait (sem_t * sem); - -PTW32_DLLPORT int __cdecl sem_timedwait (sem_t * sem, - const struct timespec * abstime); - -PTW32_DLLPORT int __cdecl sem_post (sem_t * sem); - -PTW32_DLLPORT int __cdecl sem_post_multiple (sem_t * sem, - int count); - -PTW32_DLLPORT int __cdecl sem_open (const char * name, - int oflag, - mode_t mode, - unsigned int value); - -PTW32_DLLPORT int __cdecl sem_close (sem_t * sem); - -PTW32_DLLPORT int __cdecl sem_unlink (const char * name); - -PTW32_DLLPORT int __cdecl sem_getvalue (sem_t * sem, - int * sval); - -#if defined(__cplusplus) -} /* End of extern "C" */ -#endif /* __cplusplus */ - -#undef PTW32_SEMAPHORE_LEVEL -#undef PTW32_SEMAPHORE_LEVEL_MAX - -#endif /* !SEMAPHORE_H */ diff --git a/deps/w32-pthreads/signal.c b/deps/w32-pthreads/signal.c deleted file mode 100644 index 32a1e44..0000000 --- a/deps/w32-pthreads/signal.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * signal.c - * - * Description: - * Thread-aware signal functions. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -/* - * Possible future strategy for implementing pthread_kill() - * ======================================================== - * - * Win32 does not implement signals. - * Signals are simply software interrupts. - * pthread_kill() asks the system to deliver a specified - * signal (interrupt) to a specified thread in the same - * process. - * Signals are always asynchronous (no deferred signals). - * Pthread-win32 has an async cancelation mechanism. - * A similar system can be written to deliver signals - * within the same process (on ix86 processors at least). - * - * Each thread maintains information about which - * signals it will respond to. Handler routines - * are set on a per-process basis - not per-thread. - * When signalled, a thread will check it's sigmask - * and, if the signal is not being ignored, call the - * handler routine associated with the signal. The - * thread must then (except for some signals) return to - * the point where it was interrupted. - * - * Ideally the system itself would check the target thread's - * mask before possibly needlessly bothering the thread - * itself. This could be done by pthread_kill(), that is, - * in the signaling thread since it has access to - * all pthread_t structures. It could also retrieve - * the handler routine address to minimise the target - * threads response overhead. This may also simplify - * serialisation of the access to the per-thread signal - * structures. - * - * pthread_kill() eventually calls a routine similar to - * ptw32_cancel_thread() which manipulates the target - * threads processor context to cause the thread to - * run the handler launcher routine. pthread_kill() must - * save the target threads current context so that the - * handler launcher routine can restore the context after - * the signal handler has returned. Some handlers will not - * return, eg. the default SIGKILL handler may simply - * call pthread_exit(). - * - * The current context is saved in the target threads - * pthread_t structure. - */ - -#include "pthread.h" -#include "implement.h" - -#if defined(HAVE_SIGSET_T) - -static void -ptw32_signal_thread () -{ -} - -static void -ptw32_signal_callhandler () -{ -} - -int -pthread_sigmask (int how, sigset_t const *set, sigset_t * oset) -{ - pthread_t thread = pthread_self (); - - if (thread.p == NULL) - { - return ENOENT; - } - - /* Validate the `how' argument. */ - if (set != NULL) - { - switch (how) - { - case SIG_BLOCK: - break; - case SIG_UNBLOCK: - break; - case SIG_SETMASK: - break; - default: - /* Invalid `how' argument. */ - return EINVAL; - } - } - - /* Copy the old mask before modifying it. */ - if (oset != NULL) - { - memcpy (oset, &(thread.p->sigmask), sizeof (sigset_t)); - } - - if (set != NULL) - { - unsigned int i; - - /* FIXME: this code assumes that sigmask is an even multiple of - the size of a long integer. */ - - unsigned long *src = (unsigned long const *) set; - unsigned long *dest = (unsigned long *) &(thread.p->sigmask); - - switch (how) - { - case SIG_BLOCK: - for (i = 0; i < (sizeof (sigset_t) / sizeof (unsigned long)); i++) - { - /* OR the bit field longword-wise. */ - *dest++ |= *src++; - } - break; - case SIG_UNBLOCK: - for (i = 0; i < (sizeof (sigset_t) / sizeof (unsigned long)); i++) - { - /* XOR the bitfield longword-wise. */ - *dest++ ^= *src++; - } - case SIG_SETMASK: - /* Replace the whole sigmask. */ - memcpy (&(thread.p->sigmask), set, sizeof (sigset_t)); - break; - } - } - - return 0; -} - -int -sigwait (const sigset_t * set, int *sig) -{ - /* This routine is a cancellation point */ - pthread_test_cancel(); -} - -int -sigaction (int signum, const struct sigaction *act, struct sigaction *oldact) -{ -} - -#endif /* HAVE_SIGSET_T */ diff --git a/deps/w32-pthreads/spin.c b/deps/w32-pthreads/spin.c deleted file mode 100644 index bf44e59..0000000 --- a/deps/w32-pthreads/spin.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * spin.c - * - * Description: - * This translation unit implements spin lock primitives. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -#include "ptw32_spinlock_check_need_init.c" -#include "pthread_spin_init.c" -#include "pthread_spin_destroy.c" -#include "pthread_spin_lock.c" -#include "pthread_spin_unlock.c" -#include "pthread_spin_trylock.c" diff --git a/deps/w32-pthreads/sync.c b/deps/w32-pthreads/sync.c deleted file mode 100644 index c0f8fca..0000000 --- a/deps/w32-pthreads/sync.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * sync.c - * - * Description: - * This translation unit implements functions related to thread - * synchronisation. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -#include "pthread_detach.c" -#include "pthread_join.c" diff --git a/deps/w32-pthreads/tests/Bmakefile b/deps/w32-pthreads/tests/Bmakefile deleted file mode 100644 index 277ad5f..0000000 --- a/deps/w32-pthreads/tests/Bmakefile +++ /dev/null @@ -1,358 +0,0 @@ -# Makefile for the pthreads test suite. -# If all of the .pass files can be created, the test suite has passed. -# -# -------------------------------------------------------------------------- -# -# Pthreads-win32 - POSIX Threads Library for Win32 -# Copyright(C) 1998 John E. Bossom -# Copyright(C) 1999,2005 Pthreads-win32 contributors -# -# Contact Email: rpj@callisto.canberra.edu.au -# -# 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., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -# - -DLL_VER = 2 - -CP = copy -RM = erase -CAT = type -MKDIR = mkdir -TOUCH = echo Passed > -ECHO = @echo - -# The next path is relative to $BUILD_DIR -QAPC = # ..\QueueUserAPCEx\User\quserex.dll - -CPHDR = pthread.h semaphore.h sched.h - -OPTIM = -O2 - -XXLIBS = cw32mti.lib ws2_32.lib - -# C++ Exceptions -BCEFLAGS = -P -DPtW32NoCatchWarn -D__CLEANUP_CXX -BCELIB = pthreadBCE$(DLL_VER).lib -BCEDLL = pthreadBCE$(DLL_VER).dll -# C cleanup code -BCFLAGS = -D__CLEANUP_C -BCLIB = pthreadBC$(DLL_VER).lib -BCDLL = pthreadBC$(DLL_VER).dll -# C++ Exceptions in application - using VC version of pthreads dll -BCXFLAGS = -D__CLEANUP_C - -# Defaults -CPLIB = $(BCLIB) -CPDLL = $(BCDLL) - -CFLAGS= -q $(OPTIM) /D_WIN32_WINNT=0x400 -w -tWC -tWM -4 -w-aus -w-asc -w-par -LFLAGS= -INCLUDES=-I. -BUILD_DIR=.. - -COPYFILES = $(CPHDR) $(CPLIB) $(CPDLL) $(QAPC) - -EHFLAGS = - -# If a test case returns a non-zero exit code to the shell, make will -# stop. - -PASSES= loadfree.pass \ - errno1.pass \ - self1.pass mutex5.pass \ - mutex1.pass mutex1n.pass mutex1e.pass mutex1r.pass \ - semaphore1.pass semaphore2.pass semaphore3.pass \ - mutex2.pass mutex3.pass \ - mutex2r.pass mutex2e.pass mutex3r.pass mutex3e.pass \ - condvar1.pass condvar1_1.pass condvar1_2.pass condvar2.pass condvar2_1.pass \ - exit1.pass create1.pass create2.pass reuse1.pass reuse2.pass equal1.pass \ - sequence1.pass kill1.pass valid1.pass valid2.pass \ - exit2.pass exit3.pass exit4.pass exit5.pass \ - join0.pass join1.pass detach1.pass join2.pass join3.pass \ - mutex4.pass mutex6.pass mutex6n.pass mutex6e.pass mutex6r.pass \ - mutex6s.pass mutex6es.pass mutex6rs.pass \ - mutex7.pass mutex7n.pass mutex7e.pass mutex7r.pass \ - mutex8.pass mutex8n.pass mutex8e.pass mutex8r.pass \ - robust1.pass robust2.pass robust3.pass robust4.pass robust5.pass \ - count1.pass \ - once1.pass once2.pass once3.pass once4.pass \ - self2.pass \ - cancel1.pass cancel2.pass \ - semaphore4.pass semaphore4t.pass semaphore5.pass \ - barrier1.pass barrier2.pass barrier3.pass barrier4.pass barrier5.pass barrier6.pass \ - tsd1.pass tsd2.pass delay1.pass delay2.pass eyal1.pass \ - condvar3.pass condvar3_1.pass condvar3_2.pass condvar3_3.pass \ - condvar4.pass condvar5.pass condvar6.pass \ - condvar7.pass condvar8.pass condvar9.pass \ - rwlock1.pass rwlock2.pass rwlock3.pass rwlock4.pass \ - rwlock5.pass rwlock6.pass rwlock7.pass rwlock8.pass \ - rwlock2_t.pass rwlock3_t.pass rwlock4_t.pass rwlock5_t.pass rwlock6_t.pass rwlock6_t2.pass \ - context1.pass \ - cancel3.pass cancel4.pass cancel5.pass cancel6a.pass cancel6d.pass \ - cancel7.pass cancel8.pass \ - cleanup0.pass cleanup1.pass cleanup2.pass cleanup3.pass \ - priority1.pass priority2.pass inherit1.pass \ - spin1.pass spin2.pass spin3.pass spin4.pass \ - exception1.pass exception2.pass exception3.pass \ - cancel9.pass stress1.pass - -BENCHRESULTS = \ - benchtest1.bench benchtest2.bench benchtest3.bench benchtest4.bench benchtest5.bench - -help: - @ $(ECHO) Run one of the following command lines: - @ $(ECHO) make clean BC (to test using BC dll with VC (no EH) applications) - @ $(ECHO) make clean BCX (to test using BC dll with VC++ (EH) applications) - @ $(ECHO) make clean BCE (to test using the BCE dll with VC++ EH applications) - @ $(ECHO) make clean BC-bench (to benchtest using BC dll with C bench app) - @ $(ECHO) make clean BCX-bench (to benchtest using BC dll with C++ bench app) - @ $(ECHO) make clean BCE-bench (to benchtest using BCE dll with C++ bench app) - -all: - @ make clean BC - @ make clean BCX - @ make clean BCE - @ make clean BC-bench - -# This allows an individual test application to be made using the default lib. -# e.g. make clean test cancel3.exe -test: $(CPLIB) $(CPDLL) $(CPHDR) $(QAPC) - -tests: $(CPLIB) $(CPDLL) $(CPHDR) $(QAPC) sizes.pass $(PASSES) - @ $(ECHO) ALL TESTS PASSED! Congratulations! - -benchtests: $(CPLIB) $(CPDLL) $(CPHDR) $(BENCHRESULTS) - @ $(ECHO) ALL BENCH TESTS DONE. - -sizes.pass: sizes.exe - @ $(ECHO) ... Running $(TEST) test: $*.exe - @ .\$*.exe > SIZES.$(TEST) - @ $(CAT) SIZES.$(TEST) - @ $(ECHO) ...... Passed - @ $(TOUCH) $*.pass - -BCE: - @ make -f Bmakefile TEST="$@" CPLIB="$(BCELIB)" CPDLL="$(BCEDLL)" EHFLAGS="$(BCEFLAGS)" tests - -BC: - @ make -f Bmakefile TEST="$@" CPLIB="$(BCLIB)" CPDLL="$(BCDLL)" EHFLAGS="$(BCFLAGS)" tests - -BCX: - @ make -f Bmakefile TEST="$@" CPLIB="$(BCLIB)" CPDLL="$(BCDLL)" EHFLAGS="$(BCXFLAGS)" tests - -BCE-bench: - @ make -f Bmakefile TEST="$@" CPLIB="$(BCELIB)" CPDLL="$(BCEDLL)" EHFLAGS="$(BCEFLAGS)" XXLIBS="benchlib.o" benchtests - -BC-bench: - @ make -f Bmakefile TEST="$@" CPLIB="$(BCLIB)" CPDLL="$(BCDLL)" EHFLAGS="$(BCFLAGS)" XXLIBS="benchlib.o" benchtests - -BCX-bench: - @ make -f Bmakefile TEST="$@" CPLIB="$(BCLIB)" CPDLL="$(BCDLL)" EHFLAGS="$(BCXFLAGS)" XXLIBS="benchlib.o" benchtests - -.exe.pass: - @ $(ECHO) ... Running $(TEST) test: $< - @ .\$< - @ $(ECHO) ...... Passed - @ $(TOUCH) $@ - -.exe.bench: - @ $(ECHO) ... Running $(TEST) benchtest: $< - @ .\$< - @ $(ECHO) ...... Done - @ $(TOUCH) $@ - -.c.exe: - @ $(ECHO) $(CC) $(EHFLAGS) $(CFLAGS) $(INCLUDES) $< -e$@ $(LFLAGS) $(CPLIB) $(XXLIBS) - @ $(CC) $(EHFLAGS) $(CFLAGS) $(INCLUDES) $< -e$@ $(LFLAGS) $(CPLIB) $(XXLIBS) - -.c.o: - @ $(ECHO) $(CC) $(EHFLAGS) -c $(CFLAGS) $(INCLUDES) $< -o$@ - @ $(CC) $(EHFLAGS) $(CFLAGS) -c $(INCLUDES) $< -o$@ - - -.c.i: - @ $(CC) /P $(EHFLAGS) $(CFLAGS) $(INCLUDES) $< - -$(COPYFILES): - @ $(ECHO) Copying $(BUILD_DIR)\$@ - @ $(CP) $(BUILD_DIR)\$@ . - -pthread.dll: $(CPDLL) - @ $(CP) $(CPDLL) pthread.dll - @ $(CP) $(CPLIB) pthread.lib - -clean: - - $(RM) *.dll - - $(RM) *.lib - - $(RM) pthread.h - - $(RM) semaphore.h - - $(RM) sched.h - - $(RM) *.e - - $(RM) *.i - - $(RM) *.obj - - $(RM) *.tds - - $(RM) *.pdb - - $(RM) *.o - - $(RM) *.asm - - $(RM) *.exe - - $(RM) *.pass - - $(RM) *.bench - - $(RM) *.log - -benchtest1.bench: -benchtest2.bench: -benchtest3.bench: -benchtest4.bench: -benchtest5.bench: -barrier1.pass: semaphore4.pass -barrier2.pass: barrier1.pass -barrier3.pass: barrier2.pass -barrier4.pass: barrier3.pass -barrier5.pass: barrier4.pass -barrier6.pass: barrier5.pass -cancel1.pass: create1.pass -cancel2.pass: cancel1.pass -cancel3.pass: context1.pass -cancel4.pass: cancel3.pass -cancel5.pass: cancel3.pass -cancel6a.pass: cancel3.pass -cancel6d.pass: cancel3.pass -cancel7.pass: kill1.pass -cancel8.pass: cancel7.pass -cancel9.pass: cancel8.pass -cleanup0.pass: cancel5.pass -cleanup1.pass: cleanup0.pass -cleanup2.pass: cleanup1.pass -cleanup3.pass: cleanup2.pass -condvar1.pass: -condvar1_1.pass: condvar1.pass -condvar1_2.pass: join2.pass -condvar2.pass: condvar1.pass -condvar2_1.pass: condvar2.pass join2.pass -condvar3.pass: create1.pass condvar2.pass -condvar3_1.pass: condvar3.pass join2.pass -condvar3_2.pass: condvar3_1.pass -condvar3_3.pass: condvar3_2.pass -condvar4.pass: create1.pass -condvar5.pass: condvar4.pass -condvar6.pass: condvar5.pass -condvar7.pass: condvar6.pass cleanup1.pass -condvar8.pass: condvar7.pass -condvar9.pass: condvar8.pass -context1.pass: cancel1.pass -count1.pass: join1.pass -create1.pass: mutex2.pass -create2.pass: create1.pass -delay1.pass: -delay2.pass: delay1.pass -detach1.pass: join0.pass -equal1.pass: create1.pass -errno1.pass: mutex3.pass -exception1.pass: cancel4.pass -exception2.pass: exception1.pass -exception3.pass: exception2.pass -exit1.pass: -exit2.pass: create1.pass -exit3.pass: create1.pass -exit4.pass: -exit5.pass: kill1.pass -eyal1.pass: tsd1.pass -inherit1.pass: join1.pass priority1.pass -join0.pass: create1.pass -join1.pass: create1.pass -join2.pass: create1.pass -join3.pass: join2.pass -kill1.pass: -loadfree.pass: pthread.dll -mutex1.pass: self1.pass -mutex1n.pass: mutex1.pass -mutex1e.pass: mutex1.pass -mutex1r.pass: mutex1.pass -mutex2.pass: mutex1.pass -mutex2r.pass: mutex2.pass -mutex2e.pass: mutex2.pass -mutex3.pass: create1.pass -mutex3r.pass: mutex3.pass -mutex3e.pass: mutex3.pass -mutex4.pass: mutex3.pass -mutex5.pass: -mutex6.pass: mutex4.pass -mutex6n.pass: mutex4.pass -mutex6e.pass: mutex4.pass -mutex6r.pass: mutex4.pass -mutex6s.pass: mutex6.pass -mutex6rs.pass: mutex6r.pass -mutex6es.pass: mutex6e.pass -mutex7.pass: mutex6.pass -mutex7n.pass: mutex6n.pass -mutex7e.pass: mutex6e.pass -mutex7r.pass: mutex6r.pass -mutex8.pass: mutex7.pass -mutex8n.pass: mutex7n.pass -mutex8e.pass: mutex7e.pass -mutex8r.pass: mutex7r.pass -once1.pass: create1.pass -once2.pass: once1.pass -once3.pass: once2.pass -once4.pass: once3.pass -priority1.pass: join1.pass -priority2.pass: priority1.pass barrier3.pass -reuse1.pass: create2.pass -reuse2.pass: reuse1.pass -robust1.pass: mutex8r.pass -robust2.pass: mutex8r.pass -robust3.pass: robust2.pass -robust4.pass: robust3.pass -robust5.pass: robust4.pass -rwlock1.pass: condvar6.pass -rwlock2.pass: rwlock1.pass -rwlock3.pass: rwlock2.pass join2.pass -rwlock4.pass: rwlock3.pass -rwlock5.pass: rwlock4.pass -rwlock6.pass: rwlock5.pass -rwlock7.pass: rwlock6.pass -rwlock8.pass: rwlock7.pass -rwlock2_t.pass: rwlock2.pass -rwlock3_t.pass: rwlock2_t.pass -rwlock4_t.pass: rwlock3_t.pass -rwlock5_t.pass: rwlock4_t.pass -rwlock6_t.pass: rwlock5_t.pass -rwlock6_t2.pass: rwlock6_t.pass -self1.pass: -self2.pass: create1.pass -semaphore1.pass: -semaphore2.pass: -semaphore3.pass: semaphore2.pass -semaphore4.pass: semaphore3.pass cancel1.pass -semaphore4t.pass: semaphore4.pass -semaphore5.pass: semaphore4.pass -sequence1.pass: reuse2.pass -sizes.pass: -spin1.pass: -spin2.pass: spin1.pass -spin3.pass: spin2.pass -spin4.pass: spin3.pass -stress1.pass: -tsd1.pass: barrier5.pass join1.pass -tsd2.pass: tsd1.pass -valid1.pass: join1.pass -valid2.pass: valid1.pass diff --git a/deps/w32-pthreads/tests/ChangeLog b/deps/w32-pthreads/tests/ChangeLog deleted file mode 100644 index dfb4f45..0000000 --- a/deps/w32-pthreads/tests/ChangeLog +++ /dev/null @@ -1,1000 +0,0 @@ -2011-07-03 Ross Johnson - - * create3.c: Removed; testing a condition that is not in the library's - scope and was more trouble than it was worth. - * cancel2.c: Ensure this test only runs for Structured or C++ EH. - * exit2.c: Shorten Sleep() time. - * exit3.c: Likewise. - * cancel1.c: Likewise. - * cancel3.c: Likewise. - * exception3.c: Likewise; make terminate routine consistent for all - build environments. - -2011-07-02 Ross Johnson - - * spin3.c: Unlock the unlocked spinlock now returns success. - * rwlock3.c: Join the thread to ensure it's completed. - * rwlock4.c: Likewise. - * rwlock5.c: Likewise. - * Makefile: Adjust prerequisites. - * GNUmakefile: Likewise. - * Bmakefile: Likewise. - * Wmakefile: Likewise. - -2011-07-02 Daniel Richard G. - - * *.[ch]: Cleanups around timeb struct, mainly centralising - macro definitions in test.h. - * Makefile: Fix annoying nmake warning. - -2011-06-30 Ross Johnson - - * sequence1.c: Fix loop overrun. - -2011-05-11 Ross Johnson - - * GNUmakefile (GCE-debug): New target; expects pthreadGCE2d.dll. - -2011-05-05 Ross Johnson - - * openmp1.c: Add missing test; used to comfirm that this - library works with libgomp; if this test produces a segfault - then try upgrading your version of libgomp/gcc; gcc version - 4.5.2 passes this test. - -2011-03-26 Ross Johnson - - * sequence1.c: New test for new pthread_getsequence_np(). - -2011-03-24 Ross Johnson - - * mutex*.c: Include tests for robust mutexes wherever - appropriate. - * benchtest*.c: Include comparisons for robust mutexes. - * robust1.c: New test for robust mutex handling. - * robust2.c: Likewise. - * robust3.c: Likewise. - * robust4.c: Likewise. - * robust5.c: Likewise. - * GNUmakefile: Include new tests. - * Makefile: Likewise. - * Bmakefile: Likewise (not tested). - * Wmakefile: Likewise (not tested). - -2011-03-06 Ross Johnson - - * several (MINGW64): Cast and call fixups for 64 bit compatibility; - clean build via x86_64-w64-mingw32 cross toolchain on Linux - i686 targeting x86_64 win64. - -2011-03-04 Ross Johnson - - * condvar3_2.c: abstime.tv_sec operation warning fixed. - * several: Use correct casting on pthread_join result arg - and associated declaration and usage; assumed that 64 bit - gcc gave some warnings for it. - -2011-02-28 Ross Johnson - - * test.h: Define FTIME to be _ftime64_s or _ftime64 or _ftime - in that order of preference where supported. - * several: Replace calls to _ftime with the FTIME macro. - -2010-06-19 Ross Johnson - - * Makefile (STATICRESULTS): Add all tests into suite for static - library. - * GNUmakefile (STATICTESTS): Likewise, except for openmp1.c which - has a DLL dependency. - -2010-02-04 Ross Johnson - - * openmp1.c: New; for libgomp compatibility (OpenMP). - * barrier5.c: Rewrite after changes to barriers. - * barrier6.c: New. - * benchtest6.c: New; timing barriers. - * GNUMakefile: Update for new tests. - * Makefile: Ditto. - * BMakefile: Ditto. - * once3.c: Improve cancelation testing. - * stress1.c: Fix comment. - -2007-01-04 Ross Johnson - - * context1.c: Include context.h from library sources and remove - x86 dependence in main(). - -2005-06-12 Ross Johnson - - * stress1.c (millisecondsFromNow): Remove limit 0 <= millisecs < 1000; - now works for -INT_MAX <= millisecs <= INT_MAX; not needed for - stress1.c but should be general anyway. - -2005-05-18 Ross Johnson - - * reuse2.c (main): Must use a read with memory barrier semantics - when polling 'done' to force the cache into coherence on MP systems. - -2005-05-15 Ross Johnson - - * detach1.c: New test. - * join1.c: Reduce sleep times. - * join0.c: Remove MSVCRT conditional compile - join should always - return the thread exit code. - * join1.c: Likewise. - * join2.c: Likewise. - * join3.c: Likewise. - -2005-04-18 Ross Johnson - - * condvar3.c: Remove locks from around signalling calls - should not - be required for normal operation and only serve to mask deficiencies; - ensure that CV destruction is not premature after removing guards. - * condvar3_1.c: Likewise. - * condvar3_2.c: Likewise. - * condvar3_3.c: Likewise. - * condvar4.c: Likewise. - * condvar5.c: Likewise. - * condvar6.c: Likewise. - * condvar7.c: Likewise. - * condvar8.c: Likewise. - * condvar9.c: Likewise. - -2005-04-11 Ross Johnson - - * once4.c: New test; tries to test priority adjustments - in pthread_once(); set priority class to realtime so that - any failures can be seen. - -2005-04-06 Ross Johnson - - * cleanup0.c: Fix unguarded global variable accesses. - * cleanup1.c: Likewise. - * cleanup2.c: Likewise. - * cleanup3.c: Likewise. - * once2.c: Likewise. - * once3.c: Likewise. - -2005-04-01 Ross Johnson - - * GNUmakefile: Add target to test linking static link library. - * Makefile: Likewise. - * self1.c: Run process attach/detach routines when static linked. - -2005-03-16 Ross Johnson - - * mutex5.c: Prevent optimiser from removing asserts. - -2005-03-12 Ross Johnson - - * once3.c: New test. - -2005-03-08 Ross Johnson - - * once2.c: New test. - -2004-11-19 Ross Johnson - - * Bmakefile: New makefile for Borland. - * Makefile (DLL_VER): Added. - * GNUmakefile (DLL_VER): Added. - * Wmakefile (DLL_VER): Added. - -2004-10-29 Ross Johnson - - * semaphore4.c: New test. - * semaphore4t.c: New test. - * Debug.dsp (et al): Created MSVC Workspace project to aid debugging. - * All: Many tests have been modified to work with the new pthread - ID type; some other corrections were made after some library - functions were semantically strengthened. For example, - pthread_cond_destroy() no longer destroys a busy CV, which - required minor redesigns of some tests, including some where - the mutex associated with the CV was not locked during - signaling and broadcasting. - -2004-10-23 Ross Johnson - - * condvar3.c: Fixed mutex operations that were incorrectly - placed in relation to their condition variable operations. - The error became evident after sem_destroy() was rewritten - and conditions for destroing the semaphore were tightened. - As a result, pthread_cond_destroy() was not able to - destroy the cv queueing sempahore. - * condvar3_1.c: Likewise. - * condvar3_2.c: Likewise. - * condvar4.c: Likewise. - * condvar5.c: Likewise. - * condvar6.c: Likewise. - * condvar7.c: Likewise. - * condvar8.c: Likewise. - * condvar9.c: Likewise. - -2004-10-19 Ross Johnson - - * semaphore3.c: New test. - -2004-10-14 Ross Johnson - - * rwlock7.c (main): Tidy up statistics reporting; randomise - update accesses. - * rwlock8.c: New test. - -2004-09-08 Alexandre Girao - - * cancel7.c (main): Win98 wants a valid (non-NULL) location - for the last arg of _beginthreadex(). - * cancel8.c (main): Likewise. - * exit4.c (main): Likewise. - * exit5.c (main): Likewise. - -2004-08-26 Ross Johnson - - * create3.c: New test. - -2004-06-21 Ross Johnson - - * mutex2r.c: New test. - * mutex2e.c: New test. - * mutex3r.c: New test. - * mutex3e.c: New test. - * mutex6s.c: New test. - * mutex6rs.c: New test. - * mutex6es.c: New test. - -2004-05-21 Ross Johnson - - * join3.c: New test. - -2004-05-16 Ross Johnson - - * condvar2.c (WIN32_WINNT): Define to avoid redefinition warning - from inclusion of implement.h. - * convar2_1.c: Likewise. - * condvar3_1.c: Likewise. - * condvar3_2.c: Likewise. - * context1.c: Likewise. - * sizes.c: Likewise. - * Makefile: Don't define _WIN32_WINNT on compiler command line. - * GNUmakefile: Likewise. - * priority1.c (main): Add column to output for actual win32 - priority. - -2004-05-16 Ross Johnson - - * cancel9.c: New test. - * cancel3.c: Remove inappropriate conditional compilation; - GNU C version of test suite no longer quietly skips this test. - * cancel5.c: Likewise. - * GNUmakefile: Can now build individual test app using default - C version of library using 'make clean testname.c'. - * Makefile: Likewise for VC using 'nmake clean test testname.c'. - -2003-10-14 Ross Johnson - - * Wmakefile: New makefile for Watcom testing. - -2003-09-18 Ross Johnson - - * benchtest.h: Move old mutex code into benchlib.c. - * benchlib.c: New statically linked module to ensure that - bench apps don't inline the code and therefore have an unfair - advantage over the pthreads lib routines. Made little or no - difference. - * benchtest1.c: Minor change to avoid compiler warnings. - * benchtest5.c: Likewise. - * benchtest2.c: Fix misinformation in output report. - * README.BENCH: Add comments on results. - -2003-09-14 Ross Johnson - - * priority1.c: Reworked to comply with modified priority - management and provide additional output. - * priority2.c: Likewise. - * inherit1.c: Likewise. - -2003-09-03 Ross Johnson - - * exit4.c: New test. - * exit5.c: New test. - * cancel7.c: New test. - * cancel8.c: New test. - -2003-08-13 Ross Johnson - - * reuse1.c: New test. - * reuse1.c: New test. - * valid1.c: New test. - * valid2.c: New test. - * kill1.c: New test. - * create2.c: Now included in test regime. - -2003-07-19 Ross Johnson - - * eyal1.c (waste_time): Make threads do more work to ensure that - all threads get to do some work. - * semaphore1.c: Make it clear that certain errors are expected. - * exception2.c (non_MSVC code sections): Change to include - C++ standard include file, i.e. change to . - * exception3.c (non_MSVC code sections): Likewise; qualify std:: - namespace entities where necessary. - * GNUmakefile: modified to work in the MsysDTK (newer MinGW) - environment; define CC as gcc or g++ as appropriate because - using gcc -x c++ doesn't link with required c++ libs by default, - but g++ does. - -2002-12-11 Ross Johnson - - * mutex7e.c: Assert EBUSY return instead of EDEADLK. - -2002-06-03 Ross Johnson - - * semaphore2.c: New test. - -2002-03-02 Ross Johnson - - * Makefile (CFLAGS): Changed /MT to /MD to link with - the correct library MSVCRT.LIB. Otherwise errno doesn't - work. - -2002-02-28 Ross Johnson - - * exception3.c: Correct recent change. - - * semaphore1.c: New test. - - * Makefile: Add rule to generate pre-processor output. - -2002-02-28 Ross Johnson - - * exception3.c (terminateFunction): For MSVC++, call - exit() rather than pthread_exit(). Add comments to explain - why. - * Notes from the MSVC++ manual: - * 1) A term_func() should call exit(), otherwise - * abort() will be called on return to the caller. - * abort() raises SIGABRT. The default signal handler - * for all signals terminates the calling program with - * exit code 3. - * 2) A term_func() must not throw an exception. Therefore - * term_func() should not call pthread_exit() if an - * an exception-using version of pthreads-win32 library - * is being used (i.e. either pthreadVCE or pthreadVSE). - - -2002-02-23 Ross Johnson - - * rwlock2_t.c: New test. - * rwlock3_t.c: New test. - * rwlock4_t.c: New test. - * rwlock5_t.c: New test. - * rwlock6_t.c: New test. - * rwlock6_t2.c: New test. - * rwlock6.c (main): Swap thread and result variables - to correspond to actual thread functions. - * rwlock1.c: Change test description comment to correspond - to the actual test. - - * condvar1_2.c: Loop over the test many times in the hope - of detecting any intermittent deadlocks. This is to - test a fixed problem in pthread_cond_destroy.c. - - * spin4.c: Remove unused variable. - -2002-02-17 Ross Johnson - - * condvar1_1.c: New test. - * condvar1_2.c: New test. - -2002-02-07 Ross Johnson - - * delay1.c: New test. - * delay2.c: New test. - * exit4.c: New test. - -2002-02-02 Ross Johnson - - * mutex8: New test. - * mutex8n: New test. - * mutex8e: New test. - * mutex8r: New test. - * cancel6a: New test. - * cancel6d: New test. - * cleanup0.c: Add pragmas for inline optimisation control. - * cleanup1.c: Add pragmas for inline optimisation control. - * cleanup2.c: Add pragmas for inline optimisation control. - * cleanup3.c: Add pragmas for inline optimisation control. - * condvar7.c: Add pragmas for inline optimisation control. - * condvar8.c: Add pragmas for inline optimisation control. - * condvar9.c: Add pragmas for inline optimisation control. - -2002-01-30 Ross Johnson - - * cleanup1.c (): Must be declared __cdecl when compiled - as C++ AND testing the standard C library version. - -2002-01-16 Ross Johnson - - * spin4.c (main): Fix renamed function call. - -2002-01-14 Ross Johnson - - * exception3.c (main): Shorten wait time. - -2002-01-09 Ross Johnson - - * mutex7.c: New test. - * mutex7n.c: New test. - * mutex7e.c: New test. - * mutex7r.c: New test. - * mutex6.c: Modified to avoid leaving the locked mutex - around on exit. - -2001-10-25 Ross Johnson - - * condvar2.c: Remove reference to cv->nWaitersUnblocked. - * condvar2_1.c: Likewise; lower NUMTHREADS from 60 to 30. - * condvar3_1.c: Likewise. - * condvar3_2.c: Likewise. - * count1.c: lower NUMTHREADS from 60 to 30. - * inherit1.c: Determine valid priority values and then - assert values returned by POSIX routines are the same. - * priority1.c: Likewise. - * priority2.c: Likewise. - -2001-07-12 Ross Johnson - - * barrier5.c: Assert that precisely one thread receives - PTHREAD_BARRIER_SERIAL_THREAD at each barrier. - -2001-07-09 Ross Johnson - - * barrier3.c: Fixed. - * barrier4.c: Fixed. - * barrier5.c: New; proves that all threads in the group - reaching the barrier wait and then resume together. Repeats the test - using groups of 1 to 16 threads. Each group of threads must negotiate - a large number of barriers (10000). - * spin4.c: Fixed. - * test.h (error_string): Modified the success (0) value. - -2001-07-07 Ross Johnson - - * spin3.c: Changed test and fixed. - * spin4.c: Fixed. - * barrier3.c: Fixed. - * barrier4.c: Fixed. - -2001-07-05 Ross Johnson - - * spin1.c: New; testing spinlocks. - * spin2.c: New; testing spinlocks. - * spin3.c: New; testing spinlocks. - * spin4.c: New; testing spinlocks. - * barrier1.c: New; testing barriers. - * barrier2.c: New; testing barriers. - * barrier3.c: New; testing barriers. - * barrier4.c: New; testing barriers. - * GNUmakefile: Add new tests. - * Makefile: Add new tests. - -2001-07-01 Ross Johnson - - * benchtest3.c: New; timing mutexes. - * benchtest4.c: New; time mutexes. - * condvar3_1.c: Fixed bug - Alexander Terekhov - * condvar3_3.c: New test. - -2001-06-25 Ross Johnson - - * priority1.c: New test. - * priority2.c: New test. - * inherit1.c: New test. - * benchtest1.c: New; timing mutexes. - * benchtest2.c: New; timing mutexes. - * mutex4.c: Modified to test all mutex types. - -2001-06-8 Ross Johnson - - * mutex5.c: Insert inert change to quell compiler warnings. - * condvar3_2.c: Remove unused variable. - -2001-06-3 Ross Johnson - - * condvar2_1.c: New test. - * condvar3_1.c: New test. - * condvar3_2.c: New test. - -2001-05-30 Ross Johnson - - * mutex1n.c: New test. - * mutex1e.c: New test. - * mutex1r.c: New test. - * mutex4.c: Now locks and unlocks a mutex. - * mutex5.c: New test. - * mutex6.c: New test. - * mutex6n.c: New test. - * mutex6e.c: New test. - * mutex6r.c: New test. - * Makefile: Added new tests; reorganised. - * GNUmakefile: Likewise. - * rwlock6.c: Fix to properly prove read-while-write locking - and single writer locking. - -2001-05-29 Ross Johnson - - * Makefile: Reorganisation. - * GNUmakefile: Likewise. - - Thomas Pfaff - - * exception1.c: Add stdio.h include to define fprintf and stderr - in non-exception C version of main(). - * exception2.c: Likewise. - * exception3.c: Likewise. - - * Makefile (rwlock7): Add new test. - * GNUmakefile (rwlock7): Add new test. - * rwlock7.c: New test. - * rwlock6.c: Changed to test that writer has priority. - - * eyal1.c (main): Unlock each mutex_start lock before destroying - it. - -2000-12-29 Ross Johnson - - * GNUmakefile: Add mutex4 test; ensure libpthreadw32.a is - removed for "clean" target. - * Makefile: Add mutex4 test. - - * exception3.c: Remove SEH code; automatically pass the test - under SEH (which is an N/A environment). - - * mutex4.c: New test. - - * eyal1.c (do_work_unit): Add a dummy "if" to force the - optimiser to retain code; reduce thread work loads. - - * condvar8.c (main): Add an additional "assert" for debugging; - increase pthread_cond_signal timeout. - -2000-12-28 Ross Johnson - - * eyal1.c: Increase thread work loads. - * exception2.c: New test. - * exception3.c: New test. - * Makefile: Add new tests exception2.c and exception3.c. - * GNUmakefile: Likewise. - -2000-12-11 Ross Johnson - - * cleanup3.c: Remove unused variable. - * cleanup2.c: Likewise. - * exception1.c: Throw an exception rather than use - a deliberate zero divide so that catch(...) will - handle it under Mingw32. Mingw32 now builds the - library correctly to pass all tests - see Thomas - Pfaff's detailed instructions re needed changes - to Mingw32 in the Pthreads-Win32 FAQ. - -2000-09-08 Ross Johnson - - * cancel5.c: New; tests calling pthread_cancel() - from the main thread without first creating a - POSIX thread struct for the non-POSIX main thread - - this forces pthread_cancel() to create one via - pthread_self(). - * Makefile (cancel5): Add new test. - * GNUmakefile (cancel5): Likewise. - -2000-08-17 Ross Johnson - - * create2.c: New; Test that pthread_t contains - the W32 HANDLE before it calls the thread routine - proper. - -2000-08-13 Ross Johnson - - * condvar3.c: Minor change to eliminate compiler - warning. - - * condvar4.c: ditto. - - * condvar5.c: ditto. - - * condvar6.c: ditto. - - * condvar7.c: ditto. - - * condvar8.c: ditto. - - * condvar9.c: ditto. - - * exit1.c: Function needed return statement. - - * cleanup1.c: Remove unnecessary printf arg. - - * cleanup2.c: Fix cast. - - * rwlock6.c: Fix casts. - - * exception1.c (PtW32CatchAll): Had the wrong name; - fix casts. - - * cancel3.c: Remove unused waitLock variable. - - * GNUmakefile: Change library/dll naming; add new tests; - general minor changes. - - * Makefile: Change library/dll naming; add targets for - testing each of the two VC++ EH scheme versions; - default target now issues help message; compile warnings - now interpreted as errors to stop the make; add new - tests; restructure to remove prerequisites needed - otherwise. - - * README: Updated. - - -2000-08-10 Ross Johnson - - * eyal1.c (main): Change implicit cast to explicit - cast when passing "print_server" function pointer; - G++ no longer allows implicit func parameter casts. - - * cleanup1.c: Remove unused "waitLock". - (main): Fix implicit parameter cast. - - * cancel2.c (main): Fix implicit parameter cast. - - * cancel4.c (main): Fix implicit parameter cast. - - * cancel3.c (main): Fix implicit parameter cast. - - * GNUmakefile: Renamed from Makefile; Add missing - cancel1 and cancel2 test targets. - - * Makefile: Converted for use with MS nmake. - -2000-08-06 Ross Johnson - - * ccl.bat: Add /nologo to remove extraneous output. - - * exception1.c (exceptionedThread): Init 'dummy'; - put expression into if condition to prevent optimising away; - remove unused variable. - - * cancel4.c (mythread): Cast return value to avoid warnings. - - * cancel2.c (mythread): Missing #endif. - - * condvar9.c (mythread): Cast return value to avoid warnings. - - * condvar8.c (mythread): Cast return value to avoid warnings. - - * condvar7.c (mythread): Cast return value to avoid warnings. - - * cleanup3.c (mythread): Cast return value to avoid warnings. - - * cleanup2.c (mythread): Cast return value to avoid warnings. - - * cleanup1.c (mythread): Cast return value to avoid warnings. - - * condvar5.c (mythread): Cast return value to avoid warnings. - - * condvar3.c (mythread): Cast return value to avoid warnings. - - * condvar6.c (mythread): Cast return value to avoid warnings. - - * condvar4.c (mythread): Cast return value to avoid warnings. - -2000-08-05 Ross Johnson - - * cancel2.c: Use PtW32CatchAll macro if defined. - - * exception1.c: Use PtW32CatchAll macro if defined. - -2000-08-02 Ross Johnson - - * tsd1.c: Fix typecasts of &result [g++ is now very fussy]. - - * test.h (assert): Return 0's explicitly to allay - g++ errors. - - * join2.c: Add explicit typecasts. - - * join1.c: Add explicit typecasts. - - * join0.c: Add explicit typecasts. - - * eyal1.c: Add explicit typecasts. - - * count1.c (main): Add type cast to remove g++ parse warning - [gcc-2.95.2 seems to have tightened up on this]. - - * Makefile (GLANG): Use c++ explicitly. - Remove MSVC sections (was commented out). - Add target to generate cpp output. - -2000-07-25 Ross Johnson - - * runtest.bat: modified to work under W98. - - * runall.bat: Add new tests; modified to work under W98. - It was ok under NT. - - * Makefile: Add new tests. - - * exception1.c: New; Test passing exceptions back to the - application and retaining library internal exceptions. - - * join0.c: New; Test a single join. - -2000-01-06 Ross Johnson - - * cleanup1.c: New; Test cleanup handler executes (when thread is - canceled). - - * cleanup2.c: New; Test cleanup handler executes (when thread is - not canceled). - - * cleanup3.c: New; Test cleanup handler does not execute - (when thread is not canceled). - -2000-01-04 Ross Johnson - - * cancel4.c: New; Test cancelation does not occur in deferred - cancelation threads with no cancelation points. - - * cancel3.c: New; Test asynchronous cancelation. - - * context1.c: New; Test context switching method for async - cancelation. - -1999-11-23 Ross Johnson - - * test.h: Add header includes; include local header versions rather - than system versions; rearrange the assert macro defines. - -1999-11-07 Ross Johnson - - * loadfree.c: New. Test loading and freeing the library (DLL). - -1999-10-30 Ross Johnson - - * cancel1.c: New. Test pthread_setcancelstate and - pthread_setcanceltype functions. - * eyal1.c (waste_time): Change calculation to avoid FP exception - on Aplhas - - Rich Peters - -Oct 14 1999 Ross Johnson - - * condvar7.c: New. Test broadcast after waiting thread is canceled. - * condvar8.c: New. Test multiple broadcasts. - * condvar9.c: New. Test multiple broadcasts with thread - cancelation. - -Sep 16 1999 Ross Johnson - - * rwlock6.c: New test. - -Sep 15 1999 Ross Johnson - - * rwlock1.c: New test. - * rwlock2.c: New test. - * rwlock3.c: New test. - * rwlock4.c: New test. - * rwlock5.c: New test. - -Aug 22 1999 Ross Johnson - - * runall.bat (join2): Add test. - -Aug 19 1999 Ross Johnson - - * join2.c: New test. - -Wed Aug 12 1999 Ross Johnson - - * Makefile (LIBS): Add -L. - -Mon May 31 10:25:01 1999 Ross Johnson - - * Makefile (GLANG): Add GCC language option. - -Sat May 29 23:29:04 1999 Ross Johnson - - * runall.bat (condvar5): Add new test. - - * runall.bat (condvar6): Add new test. - - * Makefile (condvar5) : Add new test. - - * Makefile (condvar6) : Add new test. - - * condvar5.c: New test for pthread_cond_broadcast(). - - * condvar6.c: New test for pthread_cond_broadcast(). - -Sun Apr 4 12:04:28 1999 Ross Johnson - - * tsd1.c (mythread): Change Sleep(0) to sched_yield(). - (sched.h): Include. - - * condvar3.c (mythread): Remove redundant Sleep(). - - * runtest.bat: Re-organised to make more informative. - -Fri Mar 19 1999 Ross Johnson - - * *.bat: redirect unwanted output to nul: - - * runall.bat: new. - - * cancel1.c: new. Not part of suite yet. - -Mon Mar 15 00:17:55 1999 Ross Johnson - - * mutex1.c: only test mutex init and destroy; add assertions. - - * count1.c: raise number of spawned threads to 60 (appears to - be the limit under Win98). - -Sun Mar 14 21:31:02 1999 Ross Johnson - - * test.h (assert): add assertion trace option. - Use: - "#define ASSERT_TRACE 1" to turn it on, - "#define ASSERT_TRACE 0" to turn it off (default). - - * condvar3.c (main): add more assertions. - - * condvar4.c (main): add more assertions. - - * condvar1.c (main): add more assertions. - -Fri Mar 12 08:34:15 1999 Ross Johnson - - * condvar4.c (cvthing): switch the order of the INITIALIZERs. - - * eyal1.c (main): Fix trylock loop; was not waiting for thread to lock - the "started" mutex. - -Wed Mar 10 10:41:52 1999 Ross Johnson - - * tryentercs.c: Apply typo patch from bje. - - * tryentercs2.c: Ditto. - -Sun Mar 7 10:41:52 1999 Ross Johnson - - * Makefile (condvar3, condvar4): Add tests. - - * condvar4.c (General): Reduce to simple test case; prerequisite - is condvar3.c; add description. - - * condvar3.c (General): Reduce to simple test case; prerequisite - is condvar2.c; add description. - - * condvar2.c (General): Reduce to simple test case; prerequisite - is condvar1.c; add description. - - * condvar1.c (General): Reduce to simple test case; add - description. - - * Template.c (Comments): Add generic test detail. - -1999-02-23 Ross Johnson - - * Template.c: Revamp. - - * condvar1.c: Add. - - * condvar2.c: Add. - - * Makefile: Add condvar1 condvar2 tests. - - * exit1.c, exit2.c, exit3.c: Cosmetic changes. - -1999-02-23 Ross Johnson - - * Makefile: Some refinement. - - * *.c: More exhaustive checking through assertions; clean up; - add some more tests. - - * Makefile: Now actually runs the tests. - - * tests.h: Define our own assert macro. The Mingw32 - version pops up a dialog but we want to run non-interactively. - - * equal1.c: use assert a little more directly so that it - prints the actual call statement. - - * exit1.c: Modify to return 0 on success, 1 on failure. - -1999-02-22 Ross Johnson - - * self2.c: Bring up to date. - - * self3.c: Ditto. - -1999-02-21 Ben Elliston - - * README: Update. - - * Makefile: New file. Run all tests automatically. Primitive tests - are run first; more complex tests are run last. - - * count1.c: New test. Validate the thread count. - - * exit2.c: Perform a simpler test. - - * exit3.c: New test. Replaces exit2.c, since exit2.c needs to - perform simpler checking first. - - * create1.c: Update to use the new testsuite exiting convention. - - * equal1.c: Likewise. - - * mutex1.c: Likewise. - - * mutex2.c: Likewise. - - * once1.c: Likewise. - - * self2.c: Likewise. - - * self3.c: Likewise. - - * tsd1.c: Likewise. - -1999-02-20 Ross Johnson - - * mutex2.c: Test static mutex initialisation. - - * test.h: New. Declares a table mapping error numbers to - error names. - -1999-01-17 Ross Johnson - - * runtest: New script to build and run a test in the tests directory. - -Wed Dec 30 11:22:44 1998 Ross Johnson - - * tsd1.c: Re-written. See comments at start of file. - * Template.c: New. Contains skeleton code and comment template - intended to fully document the test. - -Fri Oct 16 17:59:49 1998 Ross Johnson - - * tsd1.c (destroy_key): Add function. Change diagnostics. - -Thu Oct 15 17:42:37 1998 Ross Johnson - - * tsd1.c (mythread): Fix some casts and add some message - output. Fix inverted conditional. - -Mon Oct 12 02:12:29 1998 Ross Johnson - - * tsd1.c: New. Test TSD using 1 key and 2 threads. - -1998-09-13 Ben Elliston - - * eyal1.c: New file; contributed by Eyal Lebedinsky - . - -1998-09-12 Ben Elliston - - * exit2.c (func): Return a value. - (main): Call the right thread entry function. - -1998-07-22 Ben Elliston - - * exit2.c (main): Fix size of pthread_t array. - -1998-07-10 Ben Elliston - - * exit2.c: New file; test pthread_exit() harder. - - * exit1.c: New file; test pthread_exit(). diff --git a/deps/w32-pthreads/tests/Debug.dsp b/deps/w32-pthreads/tests/Debug.dsp deleted file mode 100644 index 191b978..0000000 --- a/deps/w32-pthreads/tests/Debug.dsp +++ /dev/null @@ -1,93 +0,0 @@ -# Microsoft Developer Studio Project File - Name="Debug" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=Debug - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "Debug.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "Debug.mak" CFG="Debug - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "Debug - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "Debug - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "Debug - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0xc09 /d "NDEBUG" -# ADD RSC /l 0xc09 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "Debug - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /WX /Gm /ZI /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "CLEANUP_C" /FR /YX /FD /GZ /c -# ADD BASE RSC /l 0xc09 /d "_DEBUG" -# ADD RSC /l 0xc09 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pthreadVC2d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:".." - -!ENDIF - -# Begin Target - -# Name "Debug - Win32 Release" -# Name "Debug - Win32 Debug" -# Begin Source File - -SOURCE=.\Debug.txt -# End Source File -# Begin Source File - -SOURCE=.\semaphore1.c -# End Source File -# End Target -# End Project diff --git a/deps/w32-pthreads/tests/Debug.dsw b/deps/w32-pthreads/tests/Debug.dsw deleted file mode 100644 index 5fd6af3..0000000 --- a/deps/w32-pthreads/tests/Debug.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "Debug"=.\Debug.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/deps/w32-pthreads/tests/Debug.plg b/deps/w32-pthreads/tests/Debug.plg deleted file mode 100644 index 22ce672..0000000 --- a/deps/w32-pthreads/tests/Debug.plg +++ /dev/null @@ -1,32 +0,0 @@ - - -
-

Build Log

-

---------------------Configuration: Debug - Win32 Debug-------------------- -

-

Command Lines

-Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP9.tmp" with contents -[ -/nologo /MDd /W3 /WX /Gm /ZI /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "CLEANUP_C" /FR"Debug/" /Fp"Debug/Debug.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c -"E:\PTHREADS\pthreads.2\tests\semaphore1.c" -] -Creating command line "cl.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP9.tmp" -Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSPA.tmp" with contents -[ -kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pthreadVC2d.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/Debug.pdb" /debug /machine:I386 /out:"Debug/Debug.exe" /pdbtype:sept /libpath:".." -.\Debug\semaphore1.obj -] -Creating command line "link.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSPA.tmp" -

Output Window

-Compiling... -semaphore1.c -Linking... - - - -

Results

-Debug.exe - 0 error(s), 0 warning(s) -
- - diff --git a/deps/w32-pthreads/tests/Debug.txt b/deps/w32-pthreads/tests/Debug.txt deleted file mode 100644 index 5323874..0000000 --- a/deps/w32-pthreads/tests/Debug.txt +++ /dev/null @@ -1,6 +0,0 @@ -This project is used to debug individual test case programs. - -To build and debug a test case: -- add the .c file to this project; -- remove any .c files from other test cases from this project. -- build and debug as usual. \ No newline at end of file diff --git a/deps/w32-pthreads/tests/GNUmakefile b/deps/w32-pthreads/tests/GNUmakefile deleted file mode 100644 index f6bfd31..0000000 --- a/deps/w32-pthreads/tests/GNUmakefile +++ /dev/null @@ -1,447 +0,0 @@ -# Makefile for the pthreads test suite. -# If all of the .pass files can be created, the test suite has passed. -# -# -------------------------------------------------------------------------- -# -# Pthreads-win32 - POSIX Threads Library for Win32 -# Copyright(C) 1998 John E. Bossom -# Copyright(C) 1999,2005 Pthreads-win32 contributors -# -# Contact Email: rpj@callisto.canberra.edu.au -# -# 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., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -# - -DLL_VER = 2 - -CP = cp -f -MV = mv -f -RM = rm -f -CAT = cat -MKDIR = mkdir -TOUCH = echo Passed > -ECHO = @echo -MAKE = make -k - -# For cross compiling use e.g. -# # make CROSS=i386-mingw32msvc- clean GC -CROSS = - -# For cross testing use e.g. -# # make RUN=wine CROSS=i386-mingw32msvc- clean GC -RUN = - -AR = $(CROSS)ar -DLLTOOL = $(CROSS)dlltool -CC = $(CROSS)gcc -CXX = $(CROSS)g++ -RANLIB = $(CROSS)ranlib - -# -# Mingw32 -# -XXCFLAGS = -XXLIBS = -lws2_32 -lgomp -OPT = -O3 -DOPT = -g -O0 -#CFLAGS = -O3 -UNDEBUG -Wall $(XXCFLAGS) -CFLAGS = ${OPT} -UNDEBUG -Wall $(XXCFLAGS) -BUILD_DIR = .. -INCLUDES = -I. - -.INTERMEDIATE: %.exe %.pass -.SECONDARY: %.exe %.pass -.PRECIOUS: %.exe %.pass - -TEST = GC - -# Default lib version -GCX = $(TEST)$(DLL_VER) - -# Files we need to run the tests -# - paths are relative to pthreads build dir. -HDR = pthread.h semaphore.h sched.h -LIB = libpthread$(GCX).a -DLL = pthread$(GCX).dll -# The next path is relative to $BUILD_DIR -QAPC = # ../QueueUserAPCEx/User/quserex.dll - -COPYFILES = $(HDR) $(LIB) $(DLL) $(QAPC) - -# If a test case returns a non-zero exit code to the shell, make will -# stop. - -TESTS = \ - sizes loadfree \ - self1 mutex5 mutex1 mutex1e mutex1n mutex1r \ - semaphore1 semaphore2 semaphore3 \ - condvar1 condvar1_1 condvar1_2 condvar2 condvar2_1 exit1 \ - create1 create2 create3 reuse1 reuse2 equal1 \ - sequence1 kill1 valid1 valid2 \ - exit2 exit3 exit4 exit5 \ - join0 join1 detach1 join2 join3 \ - mutex2 mutex2r mutex2e mutex3 mutex3r mutex3e \ - mutex4 mutex6 mutex6n mutex6e mutex6r \ - mutex6s mutex6es mutex6rs \ - mutex7 mutex7n mutex7e mutex7r mutex8 mutex8n mutex8e mutex8r \ - robust1 robust2 robust3 robust4 robust5 \ - count1 \ - once1 once2 once3 once4 self2 \ - cancel1 cancel2 \ - semaphore4 semaphore4t semaphore5 \ - barrier1 barrier2 barrier3 barrier4 barrier5 barrier6 \ - tsd1 tsd2 openmp1 delay1 delay2 eyal1 \ - condvar3 condvar3_1 condvar3_2 condvar3_3 \ - condvar4 condvar5 condvar6 condvar7 condvar8 condvar9 \ - errno1 \ - rwlock1 rwlock2 rwlock3 rwlock4 rwlock5 rwlock6 rwlock7 rwlock8 \ - rwlock2_t rwlock3_t rwlock4_t rwlock5_t rwlock6_t rwlock6_t2 \ - context1 cancel3 cancel4 cancel5 cancel6a cancel6d \ - cancel7 cancel8 \ - cleanup0 cleanup1 cleanup2 cleanup3 \ - priority1 priority2 inherit1 \ - spin1 spin2 spin3 spin4 \ - exception1 exception2 exception3 \ - cancel9 stress1 - -STRESSTESTS = \ - stress1 - -BENCHTESTS = \ - benchtest1 benchtest2 benchtest3 benchtest4 benchtest5 - -STATICTESTS = \ - sizes \ - self1 mutex5 mutex1 mutex1e mutex1n mutex1r \ - semaphore1 semaphore2 semaphore3 \ - condvar1 condvar1_1 condvar1_2 condvar2 condvar2_1 exit1 \ - create1 create2 create3 reuse1 reuse2 equal1 \ - sequence1 kill1 valid1 valid2 \ - exit2 exit3 exit4 exit5 \ - join0 join1 detach1 join2 join3 \ - mutex2 mutex2r mutex2e mutex3 mutex3r mutex3e \ - mutex4 mutex6 mutex6n mutex6e mutex6r \ - mutex6s mutex6es mutex6rs \ - mutex7 mutex7n mutex7e mutex7r mutex8 mutex8n mutex8e mutex8r \ - robust1 robust2 robust3 robust4 robust5 \ - count1 \ - once1 once2 once3 once4 self2 \ - cancel1 cancel2 \ - semaphore4 semaphore4t semaphore5 \ - barrier1 barrier2 barrier3 barrier4 barrier5 barrier6 \ - tsd1 tsd2 delay1 delay2 eyal1 \ - condvar3 condvar3_1 condvar3_2 condvar3_3 \ - condvar4 condvar5 condvar6 condvar7 condvar8 condvar9 \ - errno1 \ - rwlock1 rwlock2 rwlock3 rwlock4 rwlock5 rwlock6 rwlock7 rwlock8 \ - rwlock2_t rwlock3_t rwlock4_t rwlock5_t rwlock6_t rwlock6_t2 \ - context1 cancel3 cancel4 cancel5 cancel6a cancel6d \ - cancel7 cancel8 \ - cleanup0 cleanup1 cleanup2 cleanup3 \ - priority1 priority2 inherit1 \ - spin1 spin2 spin3 spin4 \ - exception1 exception2 exception3 \ - cancel9 stress1 - -ALLTESTS = $(TESTS) $(BENCHTESTS) - -ASM = $(ALLTESTS:%=%.s) -PASSES = $(TESTS:%=%.pass) -BENCHRESULTS = $(BENCHTESTS:%=%.bench) -STRESSRESULTS = $(STRESSTESTS:%=%.pass) -STATICRESULTS = $(STATICTESTS:%=%.pass) - -help: - @ $(ECHO) "Run one of the following command lines:" - @ $(ECHO) "make clean GC (to test using GC dll with C (no EH) applications)" - @ $(ECHO) "make clean GCX (to test using GC dll with C++ (EH) applications)" - @ $(ECHO) "make clean GCE (to test using GCE dll with C++ (EH) applications)" - @ $(ECHO) "make clean GC-bench (to benchtest using GNU C dll with C cleanup code)" - @ $(ECHO) "make clean GCE-bench (to benchtest using GNU C dll with C++ exception handling)" - @ $(ECHO) "make clean GC-stress (to stresstest using GNU C dll with C cleanup code)" - @ $(ECHO) "make clean GCE-stress (to stresstest using GNU C dll with C++ exception handling)" - @ $(ECHO) "make clean GC-static (to test using GC static lib with C (no EH) applications)" - @ $(ECHO) "make clean GC-debug (to test using GC dll with C (no EH) applications)" - -all: - @ $(MAKE) clean GC - @ $(MAKE) clean GCX - @ $(MAKE) clean GCE - -GC: - $(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-fopenmp -D__CLEANUP_C" all-pass - -GC-asm: - $(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-fopenmp -D__CLEANUP_C" all-asm - -GCE: - $(MAKE) TEST=GCE CC=$(CXX) XXCFLAGS="-fopenmp -mthreads -D__CLEANUP_CXX" all-pass - -GCX: - $(MAKE) TEST=GC CC=$(CXX) XXCFLAGS="-fopenmp -mthreads -D__CLEANUP_C" all-pass - -GC-bench: - $(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-D__CLEANUP_C" XXLIBS="benchlib.o" all-bench - -GCE-bench: - $(MAKE) TEST=GCE CC=$(CXX) XXCFLAGS="-mthreads -D__CLEANUP_CXX" XXLIBS="benchlib." all-bench - -GC-debug: - $(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-fopenmp -D__CLEANUP_C" OPT="${DOPT}" DLL_VER="$(DLL_VER)d" all-pass - -GCE-debug: - $(MAKE) TEST=GCE CC=$(CXX) XXCFLAGS="-fopenmp -D__CLEANUP_CXX" OPT="${DOPT}" DLL_VER="$(DLL_VER)d" all-pass - -GC-bench-debug: - $(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-D__CLEANUP_C" XXLIBS="benchlib.o" OPT="${OPT}" DLL_VER="$(DLL_VER)d" all-bench - -GC-static: - $(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-D__CLEANUP_C -DPTW32_STATIC_LIB" XXLIBS="-lws2_32" DLL="" all-static - -GC-stress: - $(ECHO) Stress tests can take a long time since they are trying to - $(ECHO) expose weaknesses that may be intermittant or statistically rare. - $(ECHO) A pass does not prove correctness, but may give greater confidence. - $(MAKE) TEST=GC CC=$(CC) XXCFLAGS="-D__CLEANUP_C" XXLIBS="" all-stress - -GCE-stress: - $(MAKE) TEST=GCE CC=$(CXX) XXCFLAGS="-mthreads -D__CLEANUP_CXX" XXLIBS="" all-stress - -all-asm: $(ASM) - @ $(ECHO) ALL TESTS PASSED! Congratulations! - -all-pass: $(PASSES) - @ $(ECHO) ALL TESTS PASSED! Congratulations! - -all-bench: $(BENCHRESULTS) - @ $(ECHO) BENCH TESTS COMPLETED. - -all-stress: $(STRESSRESULTS) - @ $(ECHO) STRESS TESTS COMPLETED. - -all-static: $(STATICRESULTS) - @ $(ECHO) ALL STATIC TESTS PASSED! Congratulations! - -benchtest1.bench: -benchtest2.bench: -benchtest3.bench: -benchtest4.bench: -benchtest5.bench: - -barrier1.pass: semaphore4.pass -barrier2.pass: barrier1.pass -barrier3.pass: barrier2.pass -barrier4.pass: barrier3.pass -barrier5.pass: barrier4.pass -barrier6.pass: barrier5.pass -cancel1.pass: create1.pass -cancel2.pass: cancel1.pass -cancel3.pass: context1.pass -cancel4.pass: cancel3.pass -cancel5.pass: cancel3.pass -cancel6a.pass: cancel3.pass -cancel6d.pass: cancel3.pass -cancel7.pass: kill1.pass -cancel8.pass: cancel7.pass -cancel9.pass: cancel8.pass -cleanup0.pass: cancel5.pass -cleanup1.pass: cleanup0.pass -cleanup2.pass: cleanup1.pass -cleanup3.pass: cleanup2.pass -condvar1.pass: -condvar1_1.pass: condvar1.pass -condvar1_2.pass: join2.pass -condvar2.pass: condvar1.pass -condvar2_1.pass: condvar2.pass join2.pass -condvar3.pass: create1.pass condvar2.pass -condvar3_1.pass: condvar3.pass join2.pass -condvar3_2.pass: condvar3_1.pass -condvar3_3.pass: condvar3_2.pass -condvar4.pass: create1.pass -condvar5.pass: condvar4.pass -condvar6.pass: condvar5.pass -condvar7.pass: condvar6.pass cleanup1.pass -condvar8.pass: condvar7.pass -condvar9.pass: condvar8.pass -context1.pass: cancel1.pass -count1.pass: join1.pass -create1.pass: mutex2.pass -create2.pass: create1.pass -create3.pass: create2.pass -delay1.pass: -delay2.pass: delay1.pass -detach1.pass: join0.pass -equal1.pass: create1.pass -errno1.pass: mutex3.pass -exception1.pass: cancel4.pass -exception2.pass: exception1.pass -exception3.pass: exception2.pass -exit1.pass: -exit2.pass: create1.pass -exit3.pass: create1.pass -exit4.pass: -exit5.pass: exit4.pass kill1.pass -eyal1.pass: tsd1.pass -inherit1.pass: join1.pass priority1.pass -join0.pass: create1.pass -join1.pass: create1.pass -join2.pass: create1.pass -join3.pass: join2.pass -kill1.pass: -loadfree.pass: pthread.dll -mutex1.pass: self1.pass -mutex1n.pass: mutex1.pass -mutex1e.pass: mutex1.pass -mutex1r.pass: mutex1.pass -mutex2.pass: mutex1.pass -mutex2r.pass: mutex2.pass -mutex2e.pass: mutex2.pass -mutex3.pass: create1.pass -mutex3r.pass: mutex3.pass -mutex3e.pass: mutex3.pass -mutex4.pass: mutex3.pass -mutex5.pass: -mutex6.pass: mutex4.pass -mutex6n.pass: mutex4.pass -mutex6e.pass: mutex4.pass -mutex6r.pass: mutex4.pass -mutex6s.pass: mutex6.pass -mutex6rs.pass: mutex6r.pass -mutex6es.pass: mutex6e.pass -mutex7.pass: mutex6.pass -mutex7n.pass: mutex6n.pass -mutex7e.pass: mutex6e.pass -mutex7r.pass: mutex6r.pass -mutex8.pass: mutex7.pass -mutex8n.pass: mutex7n.pass -mutex8e.pass: mutex7e.pass -mutex8r.pass: mutex7r.pass -once1.pass: create1.pass -once2.pass: once1.pass -once3.pass: once2.pass -once4.pass: once3.pass -openmp1.pass: tsd2.pass -priority1.pass: join1.pass -priority2.pass: priority1.pass barrier3.pass -reuse1.pass: create3.pass -reuse2.pass: reuse1.pass -robust1.pass: mutex8r.pass -robust2.pass: mutex8r.pass -robust3.pass: robust2.pass -robust4.pass: robust3.pass -robust5.pass: robust4.pass -rwlock1.pass: condvar6.pass -rwlock2.pass: rwlock1.pass -rwlock3.pass: rwlock2.pass join2.pass -rwlock4.pass: rwlock3.pass -rwlock5.pass: rwlock4.pass -rwlock6.pass: rwlock5.pass -rwlock7.pass: rwlock6.pass -rwlock8.pass: rwlock7.pass -rwlock2_t.pass: rwlock2.pass -rwlock3_t.pass: rwlock2_t.pass -rwlock4_t.pass: rwlock3_t.pass -rwlock5_t.pass: rwlock4_t.pass -rwlock6_t.pass: rwlock5_t.pass -rwlock6_t2.pass: rwlock6_t.pass -self1.pass: -self2.pass: create1.pass -semaphore1.pass: -semaphore2.pass: -semaphore3.pass: semaphore2.pass -semaphore4.pass: semaphore3.pass cancel1.pass -semaphore4t.pass: semaphore4.pass -semaphore5.pass: semaphore4.pass -sequence1.pass: reuse2.pass -sizes.pass: -spin1.pass: -spin2.pass: spin1.pass -spin3.pass: spin2.pass -spin4.pass: spin3.pass -stress1.pass: -tsd1.pass: barrier5.pass join1.pass -tsd2.pass: tsd1.pass -valid1.pass: join1.pass -valid2.pass: valid1.pass - -sizes.pass: sizes.exe - @ $(ECHO) Running $* - @ $(RUN) ./$< > SIZES.$(TEST) - @ $(CAT) SIZES.$(TEST) - @ $(ECHO) Passed - @ $(TOUCH) $@ - -%.pass: %.exe - @ $(ECHO) Running $* - @ $(RUN) ./$* - @ $(ECHO) Passed - @ $(TOUCH) $@ - -%.bench: $(LIB) $(DLL) $(HDR) $(QAPC) $(XXLIBS) %.exe - @ $(ECHO) Running $* - @ $(RUN) ./$* - @ $(ECHO) Done - @ $(TOUCH) $@ - -%.exe: %.c $(LIB) $(DLL) $(HDR) $(QAPC) - @ $(ECHO) Compiling $@ - @ $(ECHO) $(CC) $(CFLAGS) -o $@ $< $(INCLUDES) -L. -lpthread$(GCX) -lsupc++ $(XXLIBS) - @ $(CC) $(CFLAGS) -o $@ $< $(INCLUDES) -L. -lpthread$(GCX) -lsupc++ $(XXLIBS) - -%.pre: %.c $(HDR) - @ $(CC) -E $(CFLAGS) -o $@ $< $(INCLUDES) - -%.s: %.c $(HDR) - @ $(ECHO) Compiling $@ - @ $(CC) -S $(CFLAGS) -o $@ $< $(INCLUDES) - -$(COPYFILES): - @ $(ECHO) Copying $(BUILD_DIR)/$@ - @ $(CP) $(BUILD_DIR)/$@ . - -benchlib.o: benchlib.c - @ $(ECHO) Compiling $@ - @ $(ECHO) $(CC) -c $(CFLAGS) $< $(INCLUDES) - @ $(CC) -c $(CFLAGS) $< $(INCLUDES) - -pthread.dll: $(DLL) - @ $(CP) $(DLL) $@ - -clean: - - $(RM) *.dll - - $(RM) *.lib - - $(RM) pthread.h - - $(RM) semaphore.h - - $(RM) sched.h - - $(RM) *.a - - $(RM) *.e - - $(RM) *.i - - $(RM) *.o - - $(RM) *.s - - $(RM) *.so - - $(RM) *.obj - - $(RM) *.pdb - - $(RM) *.exe - - $(RM) *.pass - - $(RM) *.bench - - $(RM) *.static - - $(RM) *.log diff --git a/deps/w32-pthreads/tests/Makefile b/deps/w32-pthreads/tests/Makefile deleted file mode 100644 index 55991f1..0000000 --- a/deps/w32-pthreads/tests/Makefile +++ /dev/null @@ -1,450 +0,0 @@ -# Makefile for the pthreads test suite. -# If all of the .pass files can be created, the test suite has passed. -# -# -------------------------------------------------------------------------- -# -# Pthreads-win32 - POSIX Threads Library for Win32 -# Copyright(C) 1998 John E. Bossom -# Copyright(C) 1999,2005 Pthreads-win32 contributors -# -# Contact Email: rpj@callisto.canberra.edu.au -# -# 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., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -# - -DLL_VER = 2 - -CP = copy -RM = erase -CAT = type -MKDIR = mkdir -TOUCH = echo Passed > -ECHO = echo - -# The next path is relative to $BUILD_DIR -QAPC = # ..\QueueUserAPCEx\User\quserex.dll - -CPHDR = pthread.h semaphore.h sched.h - -OPTIM = /O2 /Ob0 - -XXLIBS = ws2_32.lib - -# C++ Exceptions -VCEFLAGS = /EHsc /TP /DPtW32NoCatchWarn /D__CLEANUP_CXX -VCELIB = pthreadVCE$(DLL_VER).lib -VCEDLL = pthreadVCE$(DLL_VER).dll -# Structured Exceptions -VSEFLAGS = /D__CLEANUP_SEH -VSELIB = pthreadVSE$(DLL_VER).lib -VSEDLL = pthreadVSE$(DLL_VER).dll -# C cleanup code -VCFLAGS = /D__CLEANUP_C -VCLIB = pthreadVC$(DLL_VER).lib -VCDLL = pthreadVC$(DLL_VER).dll -# C++ Exceptions in application - using VC version of pthreads dll -VCXFLAGS = /EHsc /TP /D__CLEANUP_C - -# Defaults -CPLIB = $(VCLIB) -CPDLL = $(VCDLL) - -CFLAGS= $(OPTIM) /W3 /MD /nologo /Z7 -LFLAGS= /INCREMENTAL:NO -INCLUDES=-I. -BUILD_DIR=.. - -COPYFILES = $(CPHDR) $(CPLIB) $(CPDLL) $(QAPC) - -TEST = -EHFLAGS = - -# If a test case returns a non-zero exit code to the shell, make will -# stop. - -PASSES = sizes.pass $(REGULAR_PASSES) - -REGULAR_PASSES = loadfree.pass \ - self1.pass mutex5.pass \ - mutex1.pass mutex1n.pass mutex1e.pass mutex1r.pass \ - semaphore1.pass semaphore2.pass semaphore3.pass \ - mutex2.pass mutex3.pass \ - mutex2r.pass mutex2e.pass mutex3r.pass mutex3e.pass \ - condvar1.pass condvar1_1.pass condvar1_2.pass condvar2.pass condvar2_1.pass \ - exit1.pass create1.pass create2.pass create3.pass reuse1.pass reuse2.pass equal1.pass \ - sequence1.pass kill1.pass valid1.pass valid2.pass \ - exit2.pass exit3.pass exit4.pass exit5.pass \ - join0.pass join1.pass detach1.pass join2.pass join3.pass \ - mutex4.pass mutex6.pass mutex6n.pass mutex6e.pass mutex6r.pass \ - mutex6s.pass mutex6es.pass mutex6rs.pass \ - mutex7.pass mutex7n.pass mutex7e.pass mutex7r.pass \ - mutex8.pass mutex8n.pass mutex8e.pass mutex8r.pass \ - robust1.pass robust2.pass robust3.pass robust4.pass robust5.pass \ - count1.pass \ - once1.pass once2.pass once3.pass once4.pass \ - self2.pass \ - cancel1.pass cancel2.pass \ - semaphore4.pass semaphore4t.pass semaphore5.pass \ - barrier1.pass barrier2.pass barrier3.pass barrier4.pass barrier5.pass barrier6.pass \ - tsd1.pass tsd2.pass delay1.pass delay2.pass eyal1.pass \ - condvar3.pass condvar3_1.pass condvar3_2.pass condvar3_3.pass \ - condvar4.pass condvar5.pass condvar6.pass \ - condvar7.pass condvar8.pass condvar9.pass \ - errno1.pass \ - rwlock1.pass rwlock2.pass rwlock3.pass rwlock4.pass \ - rwlock5.pass rwlock6.pass rwlock7.pass rwlock8.pass \ - rwlock2_t.pass rwlock3_t.pass rwlock4_t.pass rwlock5_t.pass rwlock6_t.pass rwlock6_t2.pass \ - context1.pass \ - cancel3.pass cancel4.pass cancel5.pass cancel6a.pass cancel6d.pass \ - cancel7.pass cancel8.pass \ - cleanup0.pass cleanup1.pass cleanup2.pass cleanup3.pass \ - priority1.pass priority2.pass inherit1.pass \ - spin1.pass spin2.pass spin3.pass spin4.pass \ - exception1.pass exception2.pass exception3.pass \ - cancel9.pass stress1.pass - -BENCHRESULTS = \ - benchtest1.bench benchtest2.bench benchtest3.bench benchtest4.bench benchtest5.bench - -STRESSRESULTS = \ - stress1.stress - -STATICRESULTS = \ - sizes.pass \ - self1.pass mutex5.pass \ - mutex1.pass mutex1n.pass mutex1e.pass mutex1r.pass \ - semaphore1.pass semaphore2.pass semaphore3.pass \ - mutex2.pass mutex3.pass \ - mutex2r.pass mutex2e.pass mutex3r.pass mutex3e.pass \ - condvar1.pass condvar1_1.pass condvar1_2.pass condvar2.pass condvar2_1.pass \ - exit1.pass create1.pass create2.pass create3.pass reuse1.pass reuse2.pass equal1.pass \ - sequence1.pass kill1.pass valid1.pass valid2.pass \ - exit2.pass exit3.pass exit4.pass exit5.pass \ - join0.pass join1.pass detach1.pass join2.pass join3.pass \ - mutex4.pass mutex6.pass mutex6n.pass mutex6e.pass mutex6r.pass \ - mutex6s.pass mutex6es.pass mutex6rs.pass \ - mutex7.pass mutex7n.pass mutex7e.pass mutex7r.pass \ - mutex8.pass mutex8n.pass mutex8e.pass mutex8r.pass \ - robust1.pass robust2.pass robust3.pass robust4.pass robust5.pass \ - count1.pass \ - once1.pass once2.pass once3.pass once4.pass \ - self2.pass \ - cancel1.pass cancel2.pass \ - semaphore4.pass semaphore4t.pass semaphore5.pass \ - barrier1.pass barrier2.pass barrier3.pass barrier4.pass barrier5.pass barrier6.pass \ - tsd1.pass tsd2.pass delay1.pass delay2.pass eyal1.pass \ - condvar3.pass condvar3_1.pass condvar3_2.pass condvar3_3.pass \ - condvar4.pass condvar5.pass condvar6.pass \ - condvar7.pass condvar8.pass condvar9.pass \ - errno1.pass \ - rwlock1.pass rwlock2.pass rwlock3.pass rwlock4.pass \ - rwlock5.pass rwlock6.pass rwlock7.pass rwlock8.pass \ - rwlock2_t.pass rwlock3_t.pass rwlock4_t.pass rwlock5_t.pass rwlock6_t.pass rwlock6_t2.pass \ - context1.pass \ - cancel3.pass cancel4.pass cancel5.pass cancel6a.pass cancel6d.pass \ - cancel7.pass cancel8.pass \ - cleanup0.pass cleanup1.pass cleanup2.pass cleanup3.pass \ - priority1.pass priority2.pass inherit1.pass \ - spin1.pass spin2.pass spin3.pass spin4.pass \ - exception1.pass exception2.pass exception3.pass \ - cancel9.pass stress1.pass - -help: - @ $(ECHO) Run one of the following command lines: - @ $(ECHO) nmake clean VC (to test using VC dll with VC (no EH) apps) - @ $(ECHO) nmake clean VC-bench (to benchtest using VC dll with C bench apps) - @ $(ECHO) nmake clean VC-stress (to stresstest using VC dll with C stress apps) - @ $(ECHO) nmake clean VC-static (to test using VC static lib with VC (no EH) apps) - @ $(ECHO) nmake clean VCX (to test using VC dll with VC++ (EH) applications) - @ $(ECHO) nmake clean VCX-bench (to benchtest using VC dll with C++ bench apps) - @ $(ECHO) nmake clean VCX-stress (to stresstest using VC dll with C++ stress apps) - @ $(ECHO) nmake clean VCE (to test using the VCE dll with VC++ EH applications) - @ $(ECHO) nmake clean VCE-bench (to benchtest using VCE dll with C++ bench apps) - @ $(ECHO) nmake clean VCE-stress (to stresstest using VCE dll with C++ stress apps) - @ $(ECHO) nmake clean VSE (to test using VSE dll with VC (SEH) apps) - @ $(ECHO) nmake clean VSE-bench (to benchtest using VSE dll with SEH bench apps) - @ $(ECHO) nmake clean VSE-stress (to stresstest using VSE dll with SEH stress apps) - -all: - @ $(MAKE) /E clean VC - @ $(MAKE) /E clean VCX - @ $(MAKE) /E clean VCE - @ $(MAKE) /E clean VSE - @ $(MAKE) /E clean VC-bench - @ $(MAKE) /E clean VC-stress - -# This allows an individual test application to be made using the default lib. -# e.g. nmake clean test cancel3.exe -test: $(CPLIB) $(CPDLL) $(CPHDR) $(QAPC) - -tests: $(CPLIB) $(CPDLL) $(CPHDR) $(QAPC) $(PASSES) - @ $(ECHO) ALL TESTS PASSED! Congratulations! - -benchtests: $(CPLIB) $(CPDLL) $(CPHDR) $(XXLIBS) $(BENCHRESULTS) - @ $(ECHO) ALL BENCH TESTS DONE. - -stresstests: $(CPLIB) $(CPDLL) $(CPHDR) $(STRESSRESULTS) - @ $(ECHO) ALL STRESS TESTS DONE. - -statictests: $(CPLIB) $(CPDLL) $(CPHDR) $(STATICRESULTS) - @ $(ECHO) ALL STATIC TESTS DONE. - -sizes.pass: sizes.exe - @ $(ECHO) ... Running $(TEST)$(DLL_VER) test: $*.exe - @ .\$*.exe > SIZES.$(TEST) - @ $(CAT) SIZES.$(TEST) - @ $(ECHO) ...... Passed - @ $(TOUCH) $*.pass - -$(REGULAR_PASSES): $*.exe - @ $(ECHO) ... Running $(TEST) test: $*.exe - @ .\$*.exe - @ $(ECHO) ...... Passed - @ $(TOUCH) $*.pass - -$(BENCHRESULTS): $*.exe - @ $(ECHO) ... Running $(TEST) benchtest: $*.exe - @ .\$*.exe - @ $(ECHO) ...... Done - @ $(TOUCH) $*.bench - -$(STRESSRESULTS): $*.exe - @ $(ECHO) ... Running $(TEST) stresstest: $*.exe - @ .\$*.exe - @ $(ECHO) ...... Done - @ $(TOUCH) $*.pass - -VC: - @ $(MAKE) /E TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCFLAGS)" tests - -VCE: - @ $(MAKE) /E TEST="$@" CPLIB="$(VCELIB)" CPDLL="$(VCEDLL)" EHFLAGS="$(VCEFLAGS)" tests - -VSE: - @ $(MAKE) /E TEST="$@" CPLIB="$(VSELIB)" CPDLL="$(VSEDLL)" EHFLAGS="$(VSEFLAGS)" tests - -VCX: - @ $(MAKE) /E TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCXFLAGS)" tests - -VC-bench: - @ $(MAKE) /E TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCFLAGS)" XXLIBS="benchlib.o" benchtests - -VCE-bench: - @ $(MAKE) /E TEST="$@" CPLIB="$(VCELIB)" CPDLL="$(VCEDLL)" EHFLAGS="$(VCEFLAGS)" XXLIBS="benchlib.o" benchtests - -VSE-bench: - @ $(MAKE) /E TEST="$@" CPLIB="$(VSELIB)" CPDLL="$(VSEDLL)" EHFLAGS="$(VSEFLAGS)" XXLIBS="benchlib.o" benchtests - -VCX-bench: - @ $(MAKE) /E TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCXFLAGS)" XXLIBS="benchlib.o" benchtests - -VC-stress: - @ $(MAKE) /E TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCFLAGS)" stresstests - -VCE-stress: - @ $(MAKE) /E TEST="$@" CPLIB="$(VCELIB)" CPDLL="$(VCEDLL)" EHFLAGS="$(VCEFLAGS)" stresstests - -VSE-stress: - @ $(MAKE) /E TEST="$@" CPLIB="$(VSELIB)" CPDLL="$(VSEDLL)" EHFLAGS="$(VSEFLAGS)" stresstests - -VCX-stress: - @ $(MAKE) /E TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCXFLAGS)" stresstests - -VC-static: - @ $(MAKE) /E TEST="$@" CPLIB="$(VCLIB)" CPDLL="" EHFLAGS="$(VCFLAGS) /DPTW32_STATIC_LIB" statictests - -.c.exe: - @ $(ECHO) $(CC) $(EHFLAGS) $(CFLAGS) $(INCLUDES) $< /Fe$@ /link $(LFLAGS) $(CPLIB) $(XXLIBS) - @ $(CC) $(EHFLAGS) $(CFLAGS) $(INCLUDES) $< /Fe$@ /link $(LFLAGS) $(CPLIB) $(XXLIBS) - -.c.o: - @ $(ECHO) $(CC) $(EHFLAGS) /c $(CFLAGS) $(INCLUDES) $< /Fo$@ - @ $(CC) $(EHFLAGS) $(CFLAGS) /c $(INCLUDES) $< /Fo$@ - -.c.i: - @ $(CC) /P $(EHFLAGS) $(CFLAGS) $(INCLUDES) $< - -$(COPYFILES): - @ $(ECHO) Copying $(BUILD_DIR)\$@ - @ $(CP) $(BUILD_DIR)\$@ . - -pthread.dll: $(CPDLL) - @ $(CP) $(CPDLL) pthread.dll - @ $(CP) $(CPLIB) pthread.lib - -clean: - - $(RM) *.dll - - $(RM) *.lib - - $(RM) pthread.h - - $(RM) semaphore.h - - $(RM) sched.h - - $(RM) *.e - - $(RM) *.i - - $(RM) *.obj - - $(RM) *.pdb - - $(RM) *.o - - $(RM) *.asm - - $(RM) *.exe - - $(RM) *.pass - - $(RM) *.bench - - $(RM) *.log - -benchtest1.bench: -benchtest2.bench: -benchtest3.bench: -benchtest4.bench: -benchtest5.bench: - -barrier1.pass: semaphore4.pass -barrier2.pass: barrier1.pass -barrier3.pass: barrier2.pass -barrier4.pass: barrier3.pass -barrier5.pass: barrier4.pass -barrier6.pass: barrier5.pass -cancel1.pass: create1.pass -cancel2.pass: cancel1.pass -cancel3.pass: context1.pass -cancel4.pass: cancel3.pass -cancel5.pass: cancel3.pass -cancel6a.pass: cancel3.pass -cancel6d.pass: cancel3.pass -cancel7.pass: kill1.pass -cancel8.pass: cancel7.pass -cancel9.pass: cancel8.pass -cleanup0.pass: cancel5.pass -cleanup1.pass: cleanup0.pass -cleanup2.pass: cleanup1.pass -cleanup3.pass: cleanup2.pass -condvar1.pass: -condvar1_1.pass: condvar1.pass -condvar1_2.pass: join2.pass -condvar2.pass: condvar1.pass -condvar2_1.pass: condvar2.pass join2.pass -condvar3.pass: create1.pass condvar2.pass -condvar3_1.pass: condvar3.pass join2.pass -condvar3_2.pass: condvar3_1.pass -condvar3_3.pass: condvar3_2.pass -condvar4.pass: create1.pass -condvar5.pass: condvar4.pass -condvar6.pass: condvar5.pass -condvar7.pass: condvar6.pass cleanup1.pass -condvar8.pass: condvar7.pass -condvar9.pass: condvar8.pass -context1.pass: cancel1.pass -count1.pass: join1.pass -create1.pass: mutex2.pass -create2.pass: create1.pass -create3.pass: create2.pass -delay1.pass: -delay2.pass: delay1.pass -detach1.pass: join0.pass -equal1.pass: create1.pass -errno1.pass: mutex3.pass -exception1.pass: cancel4.pass -exception2.pass: exception1.pass -exception3.pass: exception2.pass -exit1.pass: -exit2.pass: create1.pass -exit3.pass: create1.pass -exit4.pass: -exit5.pass: kill1.pass -eyal1.pass: tsd1.pass -inherit1.pass: join1.pass priority1.pass -join0.pass: create1.pass -join1.pass: create1.pass -join2.pass: create1.pass -join3.pass: join2.pass -kill1.pass: -loadfree.pass: pthread.dll -mutex1.pass: self1.pass -mutex1n.pass: mutex1.pass -mutex1e.pass: mutex1.pass -mutex1r.pass: mutex1.pass -mutex2.pass: mutex1.pass -mutex2r.pass: mutex2.pass -mutex2e.pass: mutex2.pass -mutex3.pass: create1.pass -mutex3r.pass: mutex3.pass -mutex3e.pass: mutex3.pass -mutex4.pass: mutex3.pass -mutex5.pass: -mutex6.pass: mutex4.pass -mutex6n.pass: mutex4.pass -mutex6e.pass: mutex4.pass -mutex6r.pass: mutex4.pass -mutex6s.pass: mutex6.pass -mutex6rs.pass: mutex6r.pass -mutex6es.pass: mutex6e.pass -mutex7.pass: mutex6.pass -mutex7n.pass: mutex6n.pass -mutex7e.pass: mutex6e.pass -mutex7r.pass: mutex6r.pass -mutex8.pass: mutex7.pass -mutex8n.pass: mutex7n.pass -mutex8e.pass: mutex7e.pass -mutex8r.pass: mutex7r.pass -once1.pass: create1.pass -once2.pass: once1.pass -once3.pass: once2.pass -once4.pass: once3.pass -priority1.pass: join1.pass -priority2.pass: priority1.pass barrier3.pass -reuse1.pass: create3.pass -reuse2.pass: reuse1.pass -robust1.pass: mutex8r.pass -robust2.pass: mutex8r.pass -robust3.pass: robust2.pass -robust4.pass: robust3.pass -robust5.pass: robust4.pass -rwlock1.pass: condvar6.pass -rwlock2.pass: rwlock1.pass -rwlock3.pass: rwlock2.pass join2.pass -rwlock4.pass: rwlock3.pass -rwlock5.pass: rwlock4.pass -rwlock6.pass: rwlock5.pass -rwlock7.pass: rwlock6.pass -rwlock8.pass: rwlock7.pass -rwlock2_t.pass: rwlock2.pass -rwlock3_t.pass: rwlock2_t.pass -rwlock4_t.pass: rwlock3_t.pass -rwlock5_t.pass: rwlock4_t.pass -rwlock6_t.pass: rwlock5_t.pass -rwlock6_t2.pass: rwlock6_t.pass -self1.pass: -self2.pass: create1.pass -semaphore1.pass: -semaphore2.pass: -semaphore3.pass: semaphore2.pass -semaphore4.pass: semaphore3.pass cancel1.pass -semaphore4t.pass: semaphore4.pass -semaphore5.pass: semaphore4.pass -sequence1.pass: reuse2.pass -sizes.pass: -spin1.pass: -spin2.pass: spin1.pass -spin3.pass: spin2.pass -spin4.pass: spin3.pass -stress1.pass: condvar9.pass barrier5.pass -tsd1.pass: barrier5.pass join1.pass -tsd2.pass: tsd1.pass -valid1.pass: join1.pass -valid2.pass: valid1.pass diff --git a/deps/w32-pthreads/tests/README b/deps/w32-pthreads/tests/README deleted file mode 100644 index a1b5646..0000000 --- a/deps/w32-pthreads/tests/README +++ /dev/null @@ -1,44 +0,0 @@ -Running test cases in this directory ------------------------------------- - -These make scripts expect to be able to copy the dll, library -and header files from this directory's parent directory, -which should be the pthreads-win32 source directory. - -MS VC nmake -------------- - -Run the target corresponding to the DLL version being tested: - -nmake clean VC - -or: - -nmake clean VS - - -GNU GCC make ------------- - -Run "make clean" and then "make". See the "Known bugs" section -in ..\README. - - -Writing Test Cases ------------------- - -Tests written in this test suite should behave in the following manner: - - * If a test fails, leave main() with a result of 1. - - * If a test succeeds, leave main() with a result of 0. - - * No diagnostic output should appear when the test is succeeding. - Diagnostic output may be emitted if something in the test - fails, to help determine the cause of the test failure. - -Notes: ------- - -Many test cases use knowledge of implementation internals which are supposed -to be opaque to portable applications. diff --git a/deps/w32-pthreads/tests/README.BENCHTESTS b/deps/w32-pthreads/tests/README.BENCHTESTS deleted file mode 100644 index 448570c..0000000 --- a/deps/w32-pthreads/tests/README.BENCHTESTS +++ /dev/null @@ -1,74 +0,0 @@ - ------------- -Benchmarking ------------- -There is a set a benchmarking programs in the -"tests" directory. These should be runnable using the -following command-lines corresponding to each of the possible -library builds: - -MSVC: -nmake clean VC-bench -nmake clean VCE-bench -nmake clean VSE-bench - -Mingw32: -make clean GC-bench -make clean GCE-bench - -UWIN: -The benchtests are run as part of the testsuite. - - -Mutex benchtests ----------------- - -benchtest1 - Lock plus unlock on an unlocked mutex. -benchtest2 - Lock plus unlock on a locked mutex. -benchtest3 - Trylock on a locked mutex. -benchtest4 - Trylock plus unlock on an unlocked mutex. - - -Each test times up to three alternate synchronisation -implementations as a reference, and then times each of -the four mutex types provided by the library. Each is -described below: - -Simple Critical Section -- uses a simple Win32 critical section. There is no -additional overhead for this case as there is in the -remaining cases. - -POSIX mutex implemented using a Critical Section -- The old implementation which uses runtime adaptation -depending on the Windows variant being run on. When -the pthreads DLL was run on WinNT or higher then -POSIX mutexes would use Win32 Critical Sections. - -POSIX mutex implemented using a Win32 Mutex -- The old implementation which uses runtime adaptation -depending on the Windows variant being run on. When -the pthreads DLL was run on Win9x then POSIX mutexes -would use Win32 Mutexes (because TryEnterCriticalSection -is not implemented on Win9x). - -PTHREAD_MUTEX_DEFAULT -PTHREAD_MUTEX_NORMAL -PTHREAD_MUTEX_ERRORCHECK -PTHREAD_MUTEX_RECURSIVE -- The current implementation supports these mutex types. -The underlying basis of POSIX mutexes is now the same -irrespective of the Windows variant, and should therefore -have consistent performance. - - -Semaphore benchtests --------------------- - -benchtest5 - Timing for various uncontended cases. - - -In all benchtests, the operation is repeated a large -number of times and an average is calculated. Loop -overhead is measured and subtracted from all test times. - diff --git a/deps/w32-pthreads/tests/SIZES.GC b/deps/w32-pthreads/tests/SIZES.GC deleted file mode 100644 index 4a575cb..0000000 --- a/deps/w32-pthreads/tests/SIZES.GC +++ /dev/null @@ -1,21 +0,0 @@ -Sizes of pthreads-win32 structs -------------------------------- - pthread_t 8 - ptw32_thread_t 160 - pthread_attr_t_ 28 - sem_t_ 12 - pthread_mutex_t_ 28 - pthread_mutexattr_t_ 12 - pthread_spinlock_t_ 8 - pthread_barrier_t_ 36 - pthread_barrierattr_t_ 4 - pthread_key_t_ 16 - pthread_cond_t_ 32 - pthread_condattr_t_ 4 - pthread_rwlock_t_ 28 - pthread_rwlockattr_t_ 4 - pthread_once_t_ 16 - ptw32_cleanup_t 12 - ptw32_mcs_node_t_ 16 - sched_param 4 -------------------------------- diff --git a/deps/w32-pthreads/tests/SIZES.GCE b/deps/w32-pthreads/tests/SIZES.GCE deleted file mode 100644 index 048b3ab..0000000 --- a/deps/w32-pthreads/tests/SIZES.GCE +++ /dev/null @@ -1,21 +0,0 @@ -Sizes of pthreads-win32 structs -------------------------------- - pthread_t 8 - ptw32_thread_t 96 - pthread_attr_t_ 28 - sem_t_ 12 - pthread_mutex_t_ 28 - pthread_mutexattr_t_ 12 - pthread_spinlock_t_ 8 - pthread_barrier_t_ 36 - pthread_barrierattr_t_ 4 - pthread_key_t_ 16 - pthread_cond_t_ 32 - pthread_condattr_t_ 4 - pthread_rwlock_t_ 28 - pthread_rwlockattr_t_ 4 - pthread_once_t_ 16 - ptw32_cleanup_t 12 - ptw32_mcs_node_t_ 16 - sched_param 4 -------------------------------- diff --git a/deps/w32-pthreads/tests/SIZES.VC b/deps/w32-pthreads/tests/SIZES.VC deleted file mode 100644 index a73236d..0000000 --- a/deps/w32-pthreads/tests/SIZES.VC +++ /dev/null @@ -1,21 +0,0 @@ -Sizes of pthreads-win32 structs -------------------------------- - pthread_t 16 - ptw32_thread_t 432 - pthread_attr_t_ 40 - sem_t_ 24 - pthread_mutex_t_ 48 - pthread_mutexattr_t_ 12 - pthread_spinlock_t_ 16 - pthread_barrier_t_ 64 - pthread_barrierattr_t_ 4 - pthread_key_t_ 32 - pthread_cond_t_ 56 - pthread_condattr_t_ 4 - pthread_rwlock_t_ 40 - pthread_rwlockattr_t_ 4 - pthread_once_t_ 24 - ptw32_cleanup_t 24 - ptw32_mcs_node_t_ 32 - sched_param 4 -------------------------------- diff --git a/deps/w32-pthreads/tests/SIZES.VCE b/deps/w32-pthreads/tests/SIZES.VCE deleted file mode 100644 index 048b3ab..0000000 --- a/deps/w32-pthreads/tests/SIZES.VCE +++ /dev/null @@ -1,21 +0,0 @@ -Sizes of pthreads-win32 structs -------------------------------- - pthread_t 8 - ptw32_thread_t 96 - pthread_attr_t_ 28 - sem_t_ 12 - pthread_mutex_t_ 28 - pthread_mutexattr_t_ 12 - pthread_spinlock_t_ 8 - pthread_barrier_t_ 36 - pthread_barrierattr_t_ 4 - pthread_key_t_ 16 - pthread_cond_t_ 32 - pthread_condattr_t_ 4 - pthread_rwlock_t_ 28 - pthread_rwlockattr_t_ 4 - pthread_once_t_ 16 - ptw32_cleanup_t 12 - ptw32_mcs_node_t_ 16 - sched_param 4 -------------------------------- diff --git a/deps/w32-pthreads/tests/SIZES.VSE b/deps/w32-pthreads/tests/SIZES.VSE deleted file mode 100644 index 048b3ab..0000000 --- a/deps/w32-pthreads/tests/SIZES.VSE +++ /dev/null @@ -1,21 +0,0 @@ -Sizes of pthreads-win32 structs -------------------------------- - pthread_t 8 - ptw32_thread_t 96 - pthread_attr_t_ 28 - sem_t_ 12 - pthread_mutex_t_ 28 - pthread_mutexattr_t_ 12 - pthread_spinlock_t_ 8 - pthread_barrier_t_ 36 - pthread_barrierattr_t_ 4 - pthread_key_t_ 16 - pthread_cond_t_ 32 - pthread_condattr_t_ 4 - pthread_rwlock_t_ 28 - pthread_rwlockattr_t_ 4 - pthread_once_t_ 16 - ptw32_cleanup_t 12 - ptw32_mcs_node_t_ 16 - sched_param 4 -------------------------------- diff --git a/deps/w32-pthreads/tests/Wmakefile b/deps/w32-pthreads/tests/Wmakefile deleted file mode 100644 index f732e94..0000000 --- a/deps/w32-pthreads/tests/Wmakefile +++ /dev/null @@ -1,355 +0,0 @@ -# Watcom makefile for the pthreads test suite. -# If all of the .pass files can be created, the test suite has passed. -# -# -------------------------------------------------------------------------- -# -# Pthreads-win32 - POSIX Threads Library for Win32 -# Copyright(C) 1998 John E. Bossom -# Copyright(C) 1999,2005 Pthreads-win32 contributors -# -# Contact Email: rpj@callisto.canberra.edu.au -# -# 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., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -# - - -DLL_VER = 2 - -.EXTENSIONS: - -.EXTENSIONS: .pass .exe .obj .i .c - -CP = copy -RM = erase -CAT = type -MKDIR = mkdir -TOUCH = echo Passed > -ECHO = @echo - -CPHDR = pthread.h semaphore.h sched.h - -OPTIM = -od - -XXLIBS = - -# C++ Exceptions -WCEFLAGS = -xs -dPtW32NoCatchWarn -d__CLEANUP_CXX -WCELIB = pthreadWCE$(DLL_VER).lib -WCEDLL = pthreadWCE$(DLL_VER).dll -# C cleanup code -WCFLAGS = -d__CLEANUP_C -WCLIB = pthreadWC$(DLL_VER).lib -WCDLL = pthreadWC$(DLL_VER).dll -# C++ Exceptions in application - using WC version of pthreads dll -WCXFLAGS = -xs -d__CLEANUP_C - -CFLAGS= -w4 -e25 -d_WIN32_WINNT=0x400 -d_REENTRANT -zq -bm $(OPTIM) -5r -bt=nt -mf -d2 - -LFLAGS= -INCLUDES= -i=. -BUILD_DIR=.. - -# The next path is relative to $BUILD_DIR -QAPC = # ..\QueueUserAPCEx\User\quserex.dll - -COPYFILES = $(CPHDR) $(CPLIB) $(CPDLL) $(QAPC) - -TEST = -EHFLAGS = - -# If a test case returns a non-zero exit code to the shell, make will -# stop. - -PASSES = sizes.pass loadfree.pass & - self1.pass mutex5.pass & - mutex1.pass mutex1n.pass mutex1e.pass mutex1r.pass & - semaphore1.pass semaphore2.pass semaphore3.pass & - mutex2.pass mutex3.pass & - mutex2r.pass mutex2e.pass mutex3r.pass mutex3e.pass & - condvar1.pass condvar1_1.pass condvar1_2.pass condvar2.pass condvar2_1.pass & - exit1.pass create1.pass create2.pass reuse1.pass reuse2.pass equal1.pass & - sequence1.pass kill1.pass valid1.pass valid2.pass & - exit2.pass exit3.pass exit4 exit5 & - join0.pass join1.pass detach1.pass join2.pass join3.pass & - mutex4.pass mutex6.pass mutex6n.pass mutex6e.pass mutex6r.pass & - mutex6s.pass mutex6es.pass mutex6rs.pass & - mutex7.pass mutex7n.pass mutex7e.pass mutex7r.pass & - mutex8.pass mutex8n.pass mutex8e.pass mutex8r.pass & - robust1.pass robust2.pass robust3.pass robust4.pass robust5.pass & - count1.pass & - once1.pass once2.pass once3.pass once4.pass tsd1.pass & - self2.pass & - cancel1.pass cancel2.pass & - semaphore4.pass semaphore4t.pass semaphore5.pass & - delay1.pass delay2.pass eyal1.pass & - condvar3.pass condvar3_1.pass condvar3_2.pass condvar3_3.pass & - condvar4.pass condvar5.pass condvar6.pass & - condvar7.pass condvar8.pass condvar9.pass & - errno1.pass & - rwlock1.pass rwlock2.pass rwlock3.pass rwlock4.pass rwlock5.pass & - rwlock6.pass rwlock7.pass rwlock8.pass & - rwlock2_t.pass rwlock3_t.pass rwlock4_t.pass rwlock5_t.pass rwlock6_t.pass rwlock6_t2.pass & - context1.pass & - cancel3.pass cancel4.pass cancel5.pass cancel6a.pass cancel6d.pass & - cancel7 cancel8 & - cleanup0.pass cleanup1.pass cleanup2.pass cleanup3.pass & - priority1.pass priority2.pass inherit1.pass & - spin1.pass spin2.pass spin3.pass spin4.pass & - barrier1.pass barrier2.pass barrier3.pass barrier4.pass barrier5.pass & - exception1.pass exception2.pass exception3.pass & - cancel9.pass stress1.pass - -BENCHRESULTS = & - benchtest1.bench benchtest2.bench benchtest3.bench benchtest4.bench benchtest5.bench - -help: .SYMBOLIC - @ $(ECHO) Run one of the following command lines: - @ $(ECHO) wmake /f Wmakefile clean WC (to test using WC dll with wcc386 (no EH) applications) - @ $(ECHO) wmake /f Wmakefile clean WCX (to test using WC dll with wpp386 (EH) applications) - @ $(ECHO) wmake /f Wmakefile clean WCE (to test using the WCE dll with wpp386 EH applications) - @ $(ECHO) wmake /f Wmakefile clean WC-bench (to benchtest using WC dll with C bench app) - @ $(ECHO) wmake /f Wmakefile clean WCX-bench (to benchtest using WC dll with C++ bench app) - @ $(ECHO) wmake /f Wmakefile clean WCE-bench (to benchtest using WCE dll with C++ bench app) - -all: .SYMBOLIC - @ wmake /f Wmakefile clean WC - @ wmake /f Wmakefile clean WCX - @ wmake /f Wmakefile clean WCE - @ wmake /f Wmakefile clean WSE - @ wmake /f Wmakefile clean WC-bench - -tests: $(CPLIB) $(CPDLL) $(CPHDR) $(PASSES) .SYMBOLIC - @ $(ECHO) ALL TESTS PASSED! Congratulations! - -benchtests: $(CPLIB) $(CPDLL) $(CPHDR) $(XXLIBS) $(BENCHRESULTS) .SYMBOLIC - @ $(ECHO) ALL BENCH TESTS DONE. - -$(BENCHRESULTS): ($[*).exe - @ $(ECHO) ... Running $(TEST) benchtest: ($[*).exe - @ .\($[*).exe - @ $(ECHO) ...... Done - @ $(TOUCH) ($[*).bench - -WCE: .SYMBOLIC - @ wmake /f Wmakefile CC=wpp386 TEST="$@" CPLIB="$(WCELIB)" CPDLL="$(WCEDLL)" EHFLAGS="$(WCEFLAGS)" tests - -WC: .SYMBOLIC - @ wmake /f Wmakefile CC=wcc386 TEST="$@" CPLIB="$(WCLIB)" CPDLL="$(WCDLL)" EHFLAGS="$(WCFLAGS)" tests - -WCX: .SYMBOLIC - @ wmake /f Wmakefile CC=wpp386 TEST="$@" CPLIB="$(WCLIB)" CPDLL="$(WCDLL)" EHFLAGS="$(WCXFLAGS)" tests - -WCE-bench: .SYMBOLIC - @ wmake /f Wmakefile CC=wpp386 TEST="$@" CPLIB="$(WCELIB)" CPDLL="$(WCEDLL)" EHFLAGS="$(WCEFLAGS)" XXLIBS="benchlib.o" benchtests - -WC-bench: .SYMBOLIC - @ wmake /f Wmakefile CC=wcc386 TEST="$@" CPLIB="$(WCLIB)" CPDLL="$(WCDLL)" EHFLAGS="$(WCFLAGS)" XXLIBS="benchlib.o" benchtests - -WCX-bench: .SYMBOLIC - @ wmake /f Wmakefile CC=wpp386 TEST="$@" CPLIB="$(WCLIB)" CPDLL="$(WCDLL)" EHFLAGS="$(WCXFLAGS)" XXLIBS="benchlib.o" benchtests - -sizes.pass: sizes.exe - @ $(ECHO) ... Running $(TEST) test: $^* - @ $[@ > SIZES.$(TEST) - @ $(CAT) SIZES.$(TEST) - @ $(ECHO) ...... Passed - @ $(TOUCH) $^@ - -.exe.pass: - @ $(ECHO) ... Running $(TEST) test: $^* - @ $[@ - @ $(ECHO) ...... Passed - @ $(TOUCH) $^@ - -.obj.exe: - @ $(ECHO) wlink NAME $^@ FILE $[@ LIBRARY $(CPLIB) OPTION quiet - @ wlink NAME $^@ FILE $[@ LIBRARY $(CPLIB) OPTION quiet - -.c.obj: - @ $(ECHO) $(CC) $^* $(EHFLAGS) $(CFLAGS) $(INCLUDES) - @ $(CC) $^* $(EHFLAGS) $(CFLAGS) $(INCLUDES) - -.c.i: - @ $(CC) /P $(EHFLAGS) $(CFLAGS) $(INCLUDES) $< - -$(COPYFILES): .SYMBOLIC - @ $(ECHO) Copying $(BUILD_DIR)\$@ - @ $(CP) $(BUILD_DIR)\$@ . - -pthread.dll: - @ $(CP) $(CPDLL) $*.dll - @ $(CP) $(CPLIB) $*.lib - -clean: .SYMBOLIC - @ if exist *.dll $(RM) *.dll - @ if exist *.lib $(RM) *.lib - @ if exist *.err $(RM) *.err - @ if exist pthread.h $(RM) pthread.h - @ if exist semaphore.h $(RM) semaphore.h - @ if exist sched.h $(RM) sched.h - @ if exist *.e $(RM) *.e - @ if exist *.i $(RM) *.i - @ if exist *.obj $(RM) *.obj - @ if exist *.pdb $(RM) *.pdb - @ if exist *.o $(RM) *.o - @ if exist *.asm $(RM) *.asm - @ if exist *.exe $(RM) *.exe - @ if exist *.pass $(RM) *.pass - @ if exist *.bench $(RM) *.bench - @ if exist *.log $(RM) *.log - @ $(ECHO) Clean completed. - -benchtest1.bench: -benchtest2.bench: -benchtest3.bench: -benchtest4.bench: -benchtest5.bench: -barrier1.pass: -barrier2.pass: barrier1.pass -barrier3.pass: barrier2.pass -barrier4.pass: barrier3.pass -barrier5.pass: barrier4.pass -cancel1.pass: create1.pass -cancel2.pass: cancel1.pass -cancel3.pass: context1.pass -cancel4.pass: cancel3.pass -cancel5.pass: cancel3.pass -cancel6a.pass: cancel3.pass -cancel6d.pass: cancel3.pass -cancel7.pass: kill1.pass -cancel8.pass: cancel7.pass -cleanup0.pass: cancel5.pass -cleanup1.pass: cleanup0.pass -cleanup2.pass: cleanup1.pass -cleanup3.pass: cleanup2.pass -condvar1.pass: -condvar1_1.pass: condvar1.pass -condvar1_2.pass: join2.pass -condvar2.pass: condvar1.pass -condvar2_1.pass: condvar2.pass join2.pass -condvar3.pass: create1.pass condvar2.pass -condvar3_1.pass: condvar3.pass join2.pass -condvar3_2.pass: condvar3_1.pass -condvar3_3.pass: condvar3_2.pass -condvar4.pass: create1.pass -condvar5.pass: condvar4.pass -condvar6.pass: condvar5.pass -condvar7.pass: condvar6.pass cleanup1.pass -condvar8.pass: condvar7.pass -condvar9.pass: condvar8.pass -context1.pass: cancel1.pass -count1.pass: join1.pass -create1.pass: mutex2.pass -create2.pass: create1.pass -delay1.pass: -delay2.pass: delay1.pass -detach1.pass: join0.pass -equal1.pass: create1.pass -errno1.pass: mutex3.pass -exception1.pass: cancel4.pass -exception2.pass: exception1.pass -exception3.pass: exception2.pass -exit1.pass: -exit2.pass: create1.pass -exit3.pass: create1.pass -exit4.pass: -exit5.pass: kill1.pass -eyal1.pass: tsd1.pass -inherit1.pass: join1.pass priority1.pass -join0.pass: create1.pass -join1.pass: create1.pass -join2.pass: create1.pass -join3.pass: join2.pass -kill1.pass: -loadfree.pass: pthread.dll -mutex1.pass: self1.pass -mutex1n.pass: mutex1.pass -mutex1e.pass: mutex1.pass -mutex1r.pass: mutex1.pass -mutex2.pass: mutex1.pass -mutex2r.pass: mutex2.pass -mutex2e.pass: mutex2.pass -mutex3.pass: create1.pass -mutex3r.pass: mutex3.pass -mutex3e.pass: mutex3.pass -mutex4.pass: mutex3.pass -mutex5.pass: -mutex6.pass: mutex4.pass -mutex6n.pass: mutex4.pass -mutex6e.pass: mutex4.pass -mutex6r.pass: mutex4.pass -mutex6s.pass: mutex6.pass -mutex6rs.pass: mutex6r.pass -mutex6es.pass: mutex6e.pass -mutex7.pass: mutex6.pass -mutex7n.pass: mutex6n.pass -mutex7e.pass: mutex6e.pass -mutex7r.pass: mutex6r.pass -mutex8.pass: mutex7.pass -mutex8n.pass: mutex7n.pass -mutex8e.pass: mutex7e.pass -mutex8r.pass: mutex7r.pass -once1.pass: create1.pass -once2.pass: once1.pass -once3.pass: once2.pass -once4.pass: once3.pass -priority1.pass: join1.pass -priority2.pass: priority1.pass barrier3.pass -reuse1.pass: create2.pass -reuse2.pass: reuse1.pass -robust1.pass: mutex8r.pass -robust2.pass: mutex8r.pass -robust3.pass: robust2.pass -robust4.pass: robust3.pass -robust5.pass: robust4.pass -rwlock1.pass: condvar6.pass -rwlock2.pass: rwlock1.pass -rwlock3.pass: rwlock2.pass join2.pass -rwlock4.pass: rwlock3.pass -rwlock5.pass: rwlock4.pass -rwlock6.pass: rwlock5.pass -rwlock7.pass: rwlock6.pass -rwlock2_t.pass: rwlock2.pass -rwlock3_t.pass: rwlock2_t.pass -rwlock4_t.pass: rwlock3_t.pass -rwlock5_t.pass: rwlock4_t.pass -rwlock6_t.pass: rwlock5_t.pass -rwlock6_t2.pass: rwlock6_t.pass -self1.pass: -self2.pass: create1.pass -semaphore1.pass: -semaphore2.pass: -semaphore3.pass: semaphore2.pass -semaphore4.pass: semaphore3.pass cancel1.pass -semaphore4t.pass: semaphore4.pass -semaphore5.pass: semaphore4.pass -sequence1.pass: reuse2.pass -sizes.pass: -spin1.pass: -spin2.pass: spin1.pass -spin3.pass: spin2.pass -spin4.pass: spin3.pass -stress1.pass: -tsd1.pass: join1.pass -valid1.pass: join1.pass -valid2.pass: valid1.pass -cancel9.pass: cancel8.pass diff --git a/deps/w32-pthreads/tests/barrier1.c b/deps/w32-pthreads/tests/barrier1.c deleted file mode 100644 index bdcb6b9..0000000 --- a/deps/w32-pthreads/tests/barrier1.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * barrier1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Create a barrier object and then destroy it. - * - */ - -#include "test.h" - -pthread_barrier_t barrier = NULL; - -int -main() -{ - assert(barrier == NULL); - - assert(pthread_barrier_init(&barrier, NULL, 1) == 0); - - assert(barrier != NULL); - - assert(pthread_barrier_destroy(&barrier) == 0); - - assert(barrier == NULL); - - return 0; -} diff --git a/deps/w32-pthreads/tests/barrier2.c b/deps/w32-pthreads/tests/barrier2.c deleted file mode 100644 index e489469..0000000 --- a/deps/w32-pthreads/tests/barrier2.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * barrier2.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Declare a single barrier object, wait on it, - * and then destroy it. - * - */ - -#include "test.h" - -pthread_barrier_t barrier = NULL; - -int -main() -{ - assert(pthread_barrier_init(&barrier, NULL, 1) == 0); - - assert(pthread_barrier_wait(&barrier) == PTHREAD_BARRIER_SERIAL_THREAD); - - assert(pthread_barrier_destroy(&barrier) == 0); - - return 0; -} diff --git a/deps/w32-pthreads/tests/barrier3.c b/deps/w32-pthreads/tests/barrier3.c deleted file mode 100644 index a458e4c..0000000 --- a/deps/w32-pthreads/tests/barrier3.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * barrier3.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Declare a single barrier object with barrier attribute, wait on it, - * and then destroy it. - * - */ - -#include "test.h" - -pthread_barrier_t barrier = NULL; -static void* result = (void*)1; - -void * func(void * arg) -{ - return (void *) (size_t)pthread_barrier_wait(&barrier); -} - -int -main() -{ - pthread_t t; - pthread_barrierattr_t ba; - - assert(pthread_barrierattr_init(&ba) == 0); - assert(pthread_barrierattr_setpshared(&ba, PTHREAD_PROCESS_PRIVATE) == 0); - assert(pthread_barrier_init(&barrier, &ba, 1) == 0); - - assert(pthread_create(&t, NULL, func, NULL) == 0); - - assert(pthread_join(t, &result) == 0); - - assert((int)(size_t)result == PTHREAD_BARRIER_SERIAL_THREAD); - - assert(pthread_barrier_destroy(&barrier) == 0); - assert(pthread_barrierattr_destroy(&ba) == 0); - - return 0; -} diff --git a/deps/w32-pthreads/tests/barrier4.c b/deps/w32-pthreads/tests/barrier4.c deleted file mode 100644 index 633fe10..0000000 --- a/deps/w32-pthreads/tests/barrier4.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * barrier4.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Declare a single barrier object, multiple wait on it, - * and then destroy it. - * - */ - -#include "test.h" - -enum { - NUMTHREADS = 16 -}; - -pthread_barrier_t barrier = NULL; -pthread_mutex_t mx = PTHREAD_MUTEX_INITIALIZER; -static int serialThreadCount = 0; -static int otherThreadCount = 0; - -void * -func(void * arg) -{ - int result = pthread_barrier_wait(&barrier); - - assert(pthread_mutex_lock(&mx) == 0); - - if (result == PTHREAD_BARRIER_SERIAL_THREAD) - { - serialThreadCount++; - } - else if (0 == result) - { - otherThreadCount++; - } - else - { - printf("Barrier wait failed: error = %s\n", error_string[result]); - fflush(stdout); - return NULL; - } - assert(pthread_mutex_unlock(&mx) == 0); - - return NULL; -} - -int -main() -{ - int i, j; - pthread_t t[NUMTHREADS + 1]; - - for (j = 1; j <= NUMTHREADS; j++) - { - printf("Barrier height = %d\n", j); - - serialThreadCount = 0; - - assert(pthread_barrier_init(&barrier, NULL, j) == 0); - - for (i = 1; i <= j; i++) - { - assert(pthread_create(&t[i], NULL, func, NULL) == 0); - } - - for (i = 1; i <= j; i++) - { - assert(pthread_join(t[i], NULL) == 0); - } - - assert(serialThreadCount == 1); - - assert(pthread_barrier_destroy(&barrier) == 0); - } - - assert(pthread_mutex_destroy(&mx) == 0); - - return 0; -} diff --git a/deps/w32-pthreads/tests/barrier5.c b/deps/w32-pthreads/tests/barrier5.c deleted file mode 100644 index b359349..0000000 --- a/deps/w32-pthreads/tests/barrier5.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * barrier5.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Set up a series of barriers at different heights and test various numbers - * of threads accessing, especially cases where there are more threads than the - * barrier height (count), i.e. test contention when the barrier is released. - */ - -#include "test.h" - -enum { - NUMTHREADS = 15, - HEIGHT = 10, - BARRIERMULTIPLE = 1000 -}; - -pthread_barrier_t barrier = NULL; -pthread_mutex_t mx = PTHREAD_MUTEX_INITIALIZER; -LONG totalThreadCrossings; - -void * -func(void * crossings) -{ - int result; - int serialThreads = 0; - - while ((LONG)(size_t)crossings >= (LONG)InterlockedIncrement((LPLONG)&totalThreadCrossings)) - { - result = pthread_barrier_wait(&barrier); - - if (result == PTHREAD_BARRIER_SERIAL_THREAD) - { - serialThreads++; - } - else if (result != 0) - { - printf("Barrier failed: result = %s\n", error_string[result]); - fflush(stdout); - return NULL; - } - } - - return (void*)(size_t)serialThreads; -} - -int -main() -{ - int i, j; - void* result; - int serialThreadsTotal; - LONG Crossings; - pthread_t t[NUMTHREADS + 1]; - - for (j = 1; j <= NUMTHREADS; j++) - { - int height = j -#include - -#ifdef __GNUC__ -#include -#endif - -#include "benchtest.h" - -int old_mutex_use = OLD_WIN32CS; - -BOOL (WINAPI *ptw32_try_enter_critical_section)(LPCRITICAL_SECTION) = NULL; -HINSTANCE ptw32_h_kernel32; - -void -dummy_call(int * a) -{ -} - -void -interlocked_inc_with_conditionals(int * a) -{ - if (a != NULL) - if (InterlockedIncrement((long *) a) == -1) - { - *a = 0; - } -} - -void -interlocked_dec_with_conditionals(int * a) -{ - if (a != NULL) - if (InterlockedDecrement((long *) a) == -1) - { - *a = 0; - } -} - -int -old_mutex_init(old_mutex_t *mutex, const old_mutexattr_t *attr) -{ - int result = 0; - old_mutex_t mx; - - if (mutex == NULL) - { - return EINVAL; - } - - mx = (old_mutex_t) calloc(1, sizeof(*mx)); - - if (mx == NULL) - { - result = ENOMEM; - goto FAIL0; - } - - mx->mutex = 0; - - if (attr != NULL - && *attr != NULL - && (*attr)->pshared == PTHREAD_PROCESS_SHARED - ) - { - result = ENOSYS; - } - else - { - CRITICAL_SECTION cs; - - /* - * Load KERNEL32 and try to get address of TryEnterCriticalSection - */ - ptw32_h_kernel32 = LoadLibrary(TEXT("KERNEL32.DLL")); - ptw32_try_enter_critical_section = (BOOL (WINAPI *)(LPCRITICAL_SECTION)) - -#if defined(NEED_UNICODE_CONSTS) - GetProcAddress(ptw32_h_kernel32, - (const TCHAR *)TEXT("TryEnterCriticalSection")); -#else - GetProcAddress(ptw32_h_kernel32, - (LPCSTR) "TryEnterCriticalSection"); -#endif - - if (ptw32_try_enter_critical_section != NULL) - { - InitializeCriticalSection(&cs); - if ((*ptw32_try_enter_critical_section)(&cs)) - { - LeaveCriticalSection(&cs); - } - else - { - /* - * Not really supported (Win98?). - */ - ptw32_try_enter_critical_section = NULL; - } - DeleteCriticalSection(&cs); - } - - if (ptw32_try_enter_critical_section == NULL) - { - (void) FreeLibrary(ptw32_h_kernel32); - ptw32_h_kernel32 = 0; - } - - if (old_mutex_use == OLD_WIN32CS) - { - InitializeCriticalSection(&mx->cs); - } - else if (old_mutex_use == OLD_WIN32MUTEX) - { - mx->mutex = CreateMutex (NULL, - FALSE, - NULL); - - if (mx->mutex == 0) - { - result = EAGAIN; - } - } - else - { - result = EINVAL; - } - } - - if (result != 0 && mx != NULL) - { - free(mx); - mx = NULL; - } - -FAIL0: - *mutex = mx; - - return(result); -} - - -int -old_mutex_lock(old_mutex_t *mutex) -{ - int result = 0; - old_mutex_t mx; - - if (mutex == NULL || *mutex == NULL) - { - return EINVAL; - } - - if (*mutex == (old_mutex_t) PTW32_OBJECT_AUTO_INIT) - { - /* - * Don't use initialisers when benchtesting. - */ - result = EINVAL; - } - - mx = *mutex; - - if (result == 0) - { - if (mx->mutex == 0) - { - EnterCriticalSection(&mx->cs); - } - else - { - result = (WaitForSingleObject(mx->mutex, INFINITE) - == WAIT_OBJECT_0) - ? 0 - : EINVAL; - } - } - - return(result); -} - -int -old_mutex_unlock(old_mutex_t *mutex) -{ - int result = 0; - old_mutex_t mx; - - if (mutex == NULL || *mutex == NULL) - { - return EINVAL; - } - - mx = *mutex; - - if (mx != (old_mutex_t) PTW32_OBJECT_AUTO_INIT) - { - if (mx->mutex == 0) - { - LeaveCriticalSection(&mx->cs); - } - else - { - result = (ReleaseMutex (mx->mutex) ? 0 : EINVAL); - } - } - else - { - result = EINVAL; - } - - return(result); -} - - -int -old_mutex_trylock(old_mutex_t *mutex) -{ - int result = 0; - old_mutex_t mx; - - if (mutex == NULL || *mutex == NULL) - { - return EINVAL; - } - - if (*mutex == (old_mutex_t) PTW32_OBJECT_AUTO_INIT) - { - /* - * Don't use initialisers when benchtesting. - */ - result = EINVAL; - } - - mx = *mutex; - - if (result == 0) - { - if (mx->mutex == 0) - { - if (ptw32_try_enter_critical_section == NULL) - { - result = 0; - } - else if ((*ptw32_try_enter_critical_section)(&mx->cs) != TRUE) - { - result = EBUSY; - } - } - else - { - DWORD status; - - status = WaitForSingleObject (mx->mutex, 0); - - if (status != WAIT_OBJECT_0) - { - result = ((status == WAIT_TIMEOUT) - ? EBUSY - : EINVAL); - } - } - } - - return(result); -} - - -int -old_mutex_destroy(old_mutex_t *mutex) -{ - int result = 0; - old_mutex_t mx; - - if (mutex == NULL - || *mutex == NULL) - { - return EINVAL; - } - - if (*mutex != (old_mutex_t) PTW32_OBJECT_AUTO_INIT) - { - mx = *mutex; - - if ((result = old_mutex_trylock(&mx)) == 0) - { - *mutex = NULL; - - (void) old_mutex_unlock(&mx); - - if (mx->mutex == 0) - { - DeleteCriticalSection(&mx->cs); - } - else - { - result = (CloseHandle (mx->mutex) ? 0 : EINVAL); - } - - if (result == 0) - { - mx->mutex = 0; - free(mx); - } - else - { - *mutex = mx; - } - } - } - else - { - result = EINVAL; - } - - if (ptw32_try_enter_critical_section != NULL) - { - (void) FreeLibrary(ptw32_h_kernel32); - ptw32_h_kernel32 = 0; - } - - return(result); -} - -/****************************************************************************************/ diff --git a/deps/w32-pthreads/tests/benchtest.h b/deps/w32-pthreads/tests/benchtest.h deleted file mode 100644 index 429af5c..0000000 --- a/deps/w32-pthreads/tests/benchtest.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - */ - -#include "../config.h" - -enum { - OLD_WIN32CS, - OLD_WIN32MUTEX -}; - -extern int old_mutex_use; - -struct old_mutex_t_ { - HANDLE mutex; - CRITICAL_SECTION cs; -}; - -typedef struct old_mutex_t_ * old_mutex_t; - -struct old_mutexattr_t_ { - int pshared; -}; - -typedef struct old_mutexattr_t_ * old_mutexattr_t; - -extern BOOL (WINAPI *ptw32_try_enter_critical_section)(LPCRITICAL_SECTION); -extern HINSTANCE ptw32_h_kernel32; - -#define PTW32_OBJECT_AUTO_INIT ((void *) -1) - -void dummy_call(int * a); -void interlocked_inc_with_conditionals(int *a); -void interlocked_dec_with_conditionals(int *a); -int old_mutex_init(old_mutex_t *mutex, const old_mutexattr_t *attr); -int old_mutex_lock(old_mutex_t *mutex); -int old_mutex_unlock(old_mutex_t *mutex); -int old_mutex_trylock(old_mutex_t *mutex); -int old_mutex_destroy(old_mutex_t *mutex); -/****************************************************************************************/ diff --git a/deps/w32-pthreads/tests/benchtest1.c b/deps/w32-pthreads/tests/benchtest1.c deleted file mode 100644 index 92be49c..0000000 --- a/deps/w32-pthreads/tests/benchtest1.c +++ /dev/null @@ -1,266 +0,0 @@ -/* - * benchtest1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Measure time taken to complete an elementary operation. - * - * - Mutex - * Single thread iteration over lock/unlock for each mutex type. - */ - -#include "test.h" -#include - -#ifdef __GNUC__ -#include -#endif - -#include "benchtest.h" - -#define PTW32_MUTEX_TYPES -#define ITERATIONS 10000000L - -pthread_mutex_t mx; -pthread_mutexattr_t ma; -PTW32_STRUCT_TIMEB currSysTimeStart; -PTW32_STRUCT_TIMEB currSysTimeStop; -long durationMilliSecs; -long overHeadMilliSecs = 0; -int two = 2; -int one = 1; -int zero = 0; -int iter; - -#define GetDurationMilliSecs(_TStart, _TStop) ((long)((_TStop.time*1000+_TStop.millitm) \ - - (_TStart.time*1000+_TStart.millitm))) - -/* - * Dummy use of j, otherwise the loop may be removed by the optimiser - * when doing the overhead timing with an empty loop. - */ -#define TESTSTART \ - { int i, j = 0, k = 0; PTW32_FTIME(&currSysTimeStart); for (i = 0; i < ITERATIONS; i++) { j++; - -#define TESTSTOP \ - }; PTW32_FTIME(&currSysTimeStop); if (j + k == i) j++; } - - -void -runTest (char * testNameString, int mType) -{ -#ifdef PTW32_MUTEX_TYPES - assert(pthread_mutexattr_settype(&ma, mType) == 0); -#endif - assert(pthread_mutex_init(&mx, &ma) == 0); - - TESTSTART - assert((pthread_mutex_lock(&mx),1) == one); - assert((pthread_mutex_unlock(&mx),2) == two); - TESTSTOP - - assert(pthread_mutex_destroy(&mx) == 0); - - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - - printf( "%-45s %15ld %15.3f\n", - testNameString, - durationMilliSecs, - (float) durationMilliSecs * 1E3 / ITERATIONS); -} - - -int -main (int argc, char *argv[]) -{ - int i = 0; - CRITICAL_SECTION cs; - old_mutex_t ox; - pthread_mutexattr_init(&ma); - - printf( "=============================================================================\n"); - printf( "\nLock plus unlock on an unlocked mutex.\n%ld iterations\n\n", - ITERATIONS); - printf( "%-45s %15s %15s\n", - "Test", - "Total(msec)", - "average(usec)"); - printf( "-----------------------------------------------------------------------------\n"); - - /* - * Time the loop overhead so we can subtract it from the actual test times. - */ - TESTSTART - assert(1 == one); - assert(2 == two); - TESTSTOP - - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - overHeadMilliSecs = durationMilliSecs; - - - TESTSTART - assert((dummy_call(&i), 1) == one); - assert((dummy_call(&i), 2) == two); - TESTSTOP - - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - - printf( "%-45s %15ld %15.3f\n", - "Dummy call x 2", - durationMilliSecs, - (float) (durationMilliSecs * 1E3 / ITERATIONS)); - - - TESTSTART - assert((interlocked_inc_with_conditionals(&i), 1) == one); - assert((interlocked_dec_with_conditionals(&i), 2) == two); - TESTSTOP - - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - - printf( "%-45s %15ld %15.3f\n", - "Dummy call -> Interlocked with cond x 2", - durationMilliSecs, - (float) durationMilliSecs * 1E3 / ITERATIONS); - - - TESTSTART - assert((InterlockedIncrement((LPLONG)&i), 1) == (LONG)one); - assert((InterlockedDecrement((LPLONG)&i), 2) == (LONG)two); - TESTSTOP - - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - - printf( "%-45s %15ld %15.3f\n", - "InterlockedOp x 2", - durationMilliSecs, - (float) durationMilliSecs * 1E3 / ITERATIONS); - - - InitializeCriticalSection(&cs); - - TESTSTART - assert((EnterCriticalSection(&cs), 1) == one); - assert((LeaveCriticalSection(&cs), 2) == two); - TESTSTOP - - DeleteCriticalSection(&cs); - - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - - printf( "%-45s %15ld %15.3f\n", - "Simple Critical Section", - durationMilliSecs, - (float) durationMilliSecs * 1E3 / ITERATIONS); - - - old_mutex_use = OLD_WIN32CS; - assert(old_mutex_init(&ox, NULL) == 0); - - TESTSTART - assert(old_mutex_lock(&ox) == zero); - assert(old_mutex_unlock(&ox) == zero); - TESTSTOP - - assert(old_mutex_destroy(&ox) == 0); - - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - - printf( "%-45s %15ld %15.3f\n", - "Old PT Mutex using a Critical Section (WNT)", - durationMilliSecs, - (float) durationMilliSecs * 1E3 / ITERATIONS); - - - old_mutex_use = OLD_WIN32MUTEX; - assert(old_mutex_init(&ox, NULL) == 0); - - TESTSTART - assert(old_mutex_lock(&ox) == zero); - assert(old_mutex_unlock(&ox) == zero); - TESTSTOP - - assert(old_mutex_destroy(&ox) == 0); - - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - - printf( "%-45s %15ld %15.3f\n", - "Old PT Mutex using a Win32 Mutex (W9x)", - durationMilliSecs, - (float) durationMilliSecs * 1E3 / ITERATIONS); - - printf( ".............................................................................\n"); - - /* - * Now we can start the actual tests - */ -#ifdef PTW32_MUTEX_TYPES - runTest("PTHREAD_MUTEX_DEFAULT", PTHREAD_MUTEX_DEFAULT); - - runTest("PTHREAD_MUTEX_NORMAL", PTHREAD_MUTEX_NORMAL); - - runTest("PTHREAD_MUTEX_ERRORCHECK", PTHREAD_MUTEX_ERRORCHECK); - - runTest("PTHREAD_MUTEX_RECURSIVE", PTHREAD_MUTEX_RECURSIVE); -#else - runTest("Non-blocking lock", 0); -#endif - - printf( ".............................................................................\n"); - - pthread_mutexattr_setrobust(&ma, PTHREAD_MUTEX_ROBUST); - -#ifdef PTW32_MUTEX_TYPES - runTest("PTHREAD_MUTEX_DEFAULT (Robust)", PTHREAD_MUTEX_DEFAULT); - - runTest("PTHREAD_MUTEX_NORMAL (Robust)", PTHREAD_MUTEX_NORMAL); - - runTest("PTHREAD_MUTEX_ERRORCHECK (Robust)", PTHREAD_MUTEX_ERRORCHECK); - - runTest("PTHREAD_MUTEX_RECURSIVE (Robust)", PTHREAD_MUTEX_RECURSIVE); -#else - runTest("Non-blocking lock", 0); -#endif - - printf( "=============================================================================\n"); - - /* - * End of tests. - */ - - pthread_mutexattr_destroy(&ma); - - one = i; /* Dummy assignment to avoid 'variable unused' warning */ - return 0; -} diff --git a/deps/w32-pthreads/tests/benchtest2.c b/deps/w32-pthreads/tests/benchtest2.c deleted file mode 100644 index 488d9c1..0000000 --- a/deps/w32-pthreads/tests/benchtest2.c +++ /dev/null @@ -1,327 +0,0 @@ -/* - * benchtest1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Measure time taken to complete an elementary operation. - * - * - Mutex - * Two threads iterate over lock/unlock for each mutex type. - * The two threads are forced into lock-step using two mutexes, - * forcing the threads to block on each lock operation. The - * time measured is therefore the worst case senario. - */ - -#include "test.h" -#include - -#ifdef __GNUC__ -#include -#endif - -#include "benchtest.h" - -#define PTW32_MUTEX_TYPES -#define ITERATIONS 100000L - -pthread_mutex_t gate1, gate2; -old_mutex_t ox1, ox2; -CRITICAL_SECTION cs1, cs2; -pthread_mutexattr_t ma; -long durationMilliSecs; -long overHeadMilliSecs = 0; -PTW32_STRUCT_TIMEB currSysTimeStart; -PTW32_STRUCT_TIMEB currSysTimeStop; -pthread_t worker; -int running = 0; - -#define GetDurationMilliSecs(_TStart, _TStop) ((long)((_TStop.time*1000+_TStop.millitm) \ - - (_TStart.time*1000+_TStart.millitm))) - -/* - * Dummy use of j, otherwise the loop may be removed by the optimiser - * when doing the overhead timing with an empty loop. - */ -#define TESTSTART \ - { int i, j = 0, k = 0; PTW32_FTIME(&currSysTimeStart); for (i = 0; i < ITERATIONS; i++) { j++; - -#define TESTSTOP \ - }; PTW32_FTIME(&currSysTimeStop); if (j + k == i) j++; } - - -void * -overheadThread(void * arg) -{ - do - { - sched_yield(); - } - while (running); - - return NULL; -} - - -void * -oldThread(void * arg) -{ - do - { - (void) old_mutex_lock(&ox1); - (void) old_mutex_lock(&ox2); - (void) old_mutex_unlock(&ox1); - sched_yield(); - (void) old_mutex_unlock(&ox2); - } - while (running); - - return NULL; -} - -void * -workerThread(void * arg) -{ - do - { - (void) pthread_mutex_lock(&gate1); - (void) pthread_mutex_lock(&gate2); - (void) pthread_mutex_unlock(&gate1); - sched_yield(); - (void) pthread_mutex_unlock(&gate2); - } - while (running); - - return NULL; -} - -void * -CSThread(void * arg) -{ - do - { - EnterCriticalSection(&cs1); - EnterCriticalSection(&cs2); - LeaveCriticalSection(&cs1); - sched_yield(); - LeaveCriticalSection(&cs2); - } - while (running); - - return NULL; -} - -void -runTest (char * testNameString, int mType) -{ -#ifdef PTW32_MUTEX_TYPES - assert(pthread_mutexattr_settype(&ma, mType) == 0); -#endif - assert(pthread_mutex_init(&gate1, &ma) == 0); - assert(pthread_mutex_init(&gate2, &ma) == 0); - assert(pthread_mutex_lock(&gate1) == 0); - assert(pthread_mutex_lock(&gate2) == 0); - running = 1; - assert(pthread_create(&worker, NULL, workerThread, NULL) == 0); - TESTSTART - (void) pthread_mutex_unlock(&gate1); - sched_yield(); - (void) pthread_mutex_unlock(&gate2); - (void) pthread_mutex_lock(&gate1); - (void) pthread_mutex_lock(&gate2); - TESTSTOP - running = 0; - assert(pthread_mutex_unlock(&gate2) == 0); - assert(pthread_mutex_unlock(&gate1) == 0); - assert(pthread_join(worker, NULL) == 0); - assert(pthread_mutex_destroy(&gate2) == 0); - assert(pthread_mutex_destroy(&gate1) == 0); - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - printf( "%-45s %15ld %15.3f\n", - testNameString, - durationMilliSecs, - (float) durationMilliSecs * 1E3 / ITERATIONS / 4 /* Four locks/unlocks per iteration */); -} - - -int -main (int argc, char *argv[]) -{ - assert(pthread_mutexattr_init(&ma) == 0); - - printf( "=============================================================================\n"); - printf( "\nLock plus unlock on a locked mutex.\n"); - printf("%ld iterations, four locks/unlocks per iteration.\n\n", ITERATIONS); - - printf( "%-45s %15s %15s\n", - "Test", - "Total(msec)", - "average(usec)"); - printf( "-----------------------------------------------------------------------------\n"); - - /* - * Time the loop overhead so we can subtract it from the actual test times. - */ - - running = 1; - assert(pthread_create(&worker, NULL, overheadThread, NULL) == 0); - TESTSTART - sched_yield(); - sched_yield(); - TESTSTOP - running = 0; - assert(pthread_join(worker, NULL) == 0); - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - overHeadMilliSecs = durationMilliSecs; - - - InitializeCriticalSection(&cs1); - InitializeCriticalSection(&cs2); - EnterCriticalSection(&cs1); - EnterCriticalSection(&cs2); - running = 1; - assert(pthread_create(&worker, NULL, CSThread, NULL) == 0); - TESTSTART - LeaveCriticalSection(&cs1); - sched_yield(); - LeaveCriticalSection(&cs2); - EnterCriticalSection(&cs1); - EnterCriticalSection(&cs2); - TESTSTOP - running = 0; - LeaveCriticalSection(&cs2); - LeaveCriticalSection(&cs1); - assert(pthread_join(worker, NULL) == 0); - DeleteCriticalSection(&cs2); - DeleteCriticalSection(&cs1); - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - printf( "%-45s %15ld %15.3f\n", - "Simple Critical Section", - durationMilliSecs, - (float) durationMilliSecs * 1E3 / ITERATIONS / 4 ); - - - old_mutex_use = OLD_WIN32CS; - assert(old_mutex_init(&ox1, NULL) == 0); - assert(old_mutex_init(&ox2, NULL) == 0); - assert(old_mutex_lock(&ox1) == 0); - assert(old_mutex_lock(&ox2) == 0); - running = 1; - assert(pthread_create(&worker, NULL, oldThread, NULL) == 0); - TESTSTART - (void) old_mutex_unlock(&ox1); - sched_yield(); - (void) old_mutex_unlock(&ox2); - (void) old_mutex_lock(&ox1); - (void) old_mutex_lock(&ox2); - TESTSTOP - running = 0; - assert(old_mutex_unlock(&ox1) == 0); - assert(old_mutex_unlock(&ox2) == 0); - assert(pthread_join(worker, NULL) == 0); - assert(old_mutex_destroy(&ox2) == 0); - assert(old_mutex_destroy(&ox1) == 0); - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - printf( "%-45s %15ld %15.3f\n", - "Old PT Mutex using a Critical Section (WNT)", - durationMilliSecs, - (float) durationMilliSecs * 1E3 / ITERATIONS / 4); - - - old_mutex_use = OLD_WIN32MUTEX; - assert(old_mutex_init(&ox1, NULL) == 0); - assert(old_mutex_init(&ox2, NULL) == 0); - assert(old_mutex_lock(&ox1) == 0); - assert(old_mutex_lock(&ox2) == 0); - running = 1; - assert(pthread_create(&worker, NULL, oldThread, NULL) == 0); - TESTSTART - (void) old_mutex_unlock(&ox1); - sched_yield(); - (void) old_mutex_unlock(&ox2); - (void) old_mutex_lock(&ox1); - (void) old_mutex_lock(&ox2); - TESTSTOP - running = 0; - assert(old_mutex_unlock(&ox1) == 0); - assert(old_mutex_unlock(&ox2) == 0); - assert(pthread_join(worker, NULL) == 0); - assert(old_mutex_destroy(&ox2) == 0); - assert(old_mutex_destroy(&ox1) == 0); - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - printf( "%-45s %15ld %15.3f\n", - "Old PT Mutex using a Win32 Mutex (W9x)", - durationMilliSecs, - (float) durationMilliSecs * 1E3 / ITERATIONS / 4); - - printf( ".............................................................................\n"); - - /* - * Now we can start the actual tests - */ -#ifdef PTW32_MUTEX_TYPES - runTest("PTHREAD_MUTEX_DEFAULT", PTHREAD_MUTEX_DEFAULT); - - runTest("PTHREAD_MUTEX_NORMAL", PTHREAD_MUTEX_NORMAL); - - runTest("PTHREAD_MUTEX_ERRORCHECK", PTHREAD_MUTEX_ERRORCHECK); - - runTest("PTHREAD_MUTEX_RECURSIVE", PTHREAD_MUTEX_RECURSIVE); -#else - runTest("Non-blocking lock", 0); -#endif - - printf( ".............................................................................\n"); - - pthread_mutexattr_setrobust(&ma, PTHREAD_MUTEX_ROBUST); - -#ifdef PTW32_MUTEX_TYPES - runTest("PTHREAD_MUTEX_DEFAULT (Robust)", PTHREAD_MUTEX_DEFAULT); - - runTest("PTHREAD_MUTEX_NORMAL (Robust)", PTHREAD_MUTEX_NORMAL); - - runTest("PTHREAD_MUTEX_ERRORCHECK (Robust)", PTHREAD_MUTEX_ERRORCHECK); - - runTest("PTHREAD_MUTEX_RECURSIVE (Robust)", PTHREAD_MUTEX_RECURSIVE); -#else - runTest("Non-blocking lock", 0); -#endif - - printf( "=============================================================================\n"); - /* - * End of tests. - */ - - pthread_mutexattr_destroy(&ma); - - return 0; -} diff --git a/deps/w32-pthreads/tests/benchtest3.c b/deps/w32-pthreads/tests/benchtest3.c deleted file mode 100644 index e63aa6e..0000000 --- a/deps/w32-pthreads/tests/benchtest3.c +++ /dev/null @@ -1,217 +0,0 @@ -/* - * benchtest3.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Measure time taken to complete an elementary operation. - * - * - Mutex - * Single thread iteration over a trylock on a locked mutex for each mutex type. - */ - -#include "test.h" -#include - -#ifdef __GNUC__ -#include -#endif - -#include "benchtest.h" - -#define PTW32_MUTEX_TYPES -#define ITERATIONS 10000000L - -pthread_mutex_t mx; -old_mutex_t ox; -pthread_mutexattr_t ma; -PTW32_STRUCT_TIMEB currSysTimeStart; -PTW32_STRUCT_TIMEB currSysTimeStop; -long durationMilliSecs; -long overHeadMilliSecs = 0; - -#define GetDurationMilliSecs(_TStart, _TStop) ((long)((_TStop.time*1000+_TStop.millitm) \ - - (_TStart.time*1000+_TStart.millitm))) - -/* - * Dummy use of j, otherwise the loop may be removed by the optimiser - * when doing the overhead timing with an empty loop. - */ -#define TESTSTART \ - { int i, j = 0, k = 0; PTW32_FTIME(&currSysTimeStart); for (i = 0; i < ITERATIONS; i++) { j++; - -#define TESTSTOP \ - }; PTW32_FTIME(&currSysTimeStop); if (j + k == i) j++; } - - -void * -trylockThread (void * arg) -{ - TESTSTART - (void) pthread_mutex_trylock(&mx); - TESTSTOP - - return NULL; -} - - -void * -oldTrylockThread (void * arg) -{ - TESTSTART - (void) old_mutex_trylock(&ox); - TESTSTOP - - return NULL; -} - - -void -runTest (char * testNameString, int mType) -{ - pthread_t t; - -#ifdef PTW32_MUTEX_TYPES - (void) pthread_mutexattr_settype(&ma, mType); -#endif - assert(pthread_mutex_init(&mx, &ma) == 0); - assert(pthread_mutex_lock(&mx) == 0); - assert(pthread_create(&t, NULL, trylockThread, 0) == 0); - assert(pthread_join(t, NULL) == 0); - assert(pthread_mutex_unlock(&mx) == 0); - assert(pthread_mutex_destroy(&mx) == 0); - - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - - printf( "%-45s %15ld %15.3f\n", - testNameString, - durationMilliSecs, - (float) durationMilliSecs * 1E3 / ITERATIONS); -} - - -int -main (int argc, char *argv[]) -{ - pthread_t t; - - assert(pthread_mutexattr_init(&ma) == 0); - - printf( "=============================================================================\n"); - printf( "\nTrylock on a locked mutex.\n"); - printf( "%ld iterations.\n\n", ITERATIONS); - printf( "%-45s %15s %15s\n", - "Test", - "Total(msec)", - "average(usec)"); - printf( "-----------------------------------------------------------------------------\n"); - - /* - * Time the loop overhead so we can subtract it from the actual test times. - */ - - TESTSTART - TESTSTOP - - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - overHeadMilliSecs = durationMilliSecs; - - - old_mutex_use = OLD_WIN32CS; - assert(old_mutex_init(&ox, NULL) == 0); - assert(old_mutex_lock(&ox) == 0); - assert(pthread_create(&t, NULL, oldTrylockThread, 0) == 0); - assert(pthread_join(t, NULL) == 0); - assert(old_mutex_unlock(&ox) == 0); - assert(old_mutex_destroy(&ox) == 0); - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - printf( "%-45s %15ld %15.3f\n", - "Old PT Mutex using a Critical Section (WNT)", - durationMilliSecs, - (float) durationMilliSecs * 1E3 / ITERATIONS); - - old_mutex_use = OLD_WIN32MUTEX; - assert(old_mutex_init(&ox, NULL) == 0); - assert(old_mutex_lock(&ox) == 0); - assert(pthread_create(&t, NULL, oldTrylockThread, 0) == 0); - assert(pthread_join(t, NULL) == 0); - assert(old_mutex_unlock(&ox) == 0); - assert(old_mutex_destroy(&ox) == 0); - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - printf( "%-45s %15ld %15.3f\n", - "Old PT Mutex using a Win32 Mutex (W9x)", - durationMilliSecs, - (float) durationMilliSecs * 1E3 / ITERATIONS); - - printf( ".............................................................................\n"); - - /* - * Now we can start the actual tests - */ -#ifdef PTW32_MUTEX_TYPES - runTest("PTHREAD_MUTEX_DEFAULT", PTHREAD_MUTEX_DEFAULT); - - runTest("PTHREAD_MUTEX_NORMAL", PTHREAD_MUTEX_NORMAL); - - runTest("PTHREAD_MUTEX_ERRORCHECK", PTHREAD_MUTEX_ERRORCHECK); - - runTest("PTHREAD_MUTEX_RECURSIVE", PTHREAD_MUTEX_RECURSIVE); -#else - runTest("Non-blocking lock", 0); -#endif - - printf( ".............................................................................\n"); - - pthread_mutexattr_setrobust(&ma, PTHREAD_MUTEX_ROBUST); - -#ifdef PTW32_MUTEX_TYPES - runTest("PTHREAD_MUTEX_DEFAULT (Robust)", PTHREAD_MUTEX_DEFAULT); - - runTest("PTHREAD_MUTEX_NORMAL (Robust)", PTHREAD_MUTEX_NORMAL); - - runTest("PTHREAD_MUTEX_ERRORCHECK (Robust)", PTHREAD_MUTEX_ERRORCHECK); - - runTest("PTHREAD_MUTEX_RECURSIVE (Robust)", PTHREAD_MUTEX_RECURSIVE); -#else - runTest("Non-blocking lock", 0); -#endif - - printf( "=============================================================================\n"); - - /* - * End of tests. - */ - - pthread_mutexattr_destroy(&ma); - - return 0; -} diff --git a/deps/w32-pthreads/tests/benchtest4.c b/deps/w32-pthreads/tests/benchtest4.c deleted file mode 100644 index 073ed9e..0000000 --- a/deps/w32-pthreads/tests/benchtest4.c +++ /dev/null @@ -1,198 +0,0 @@ -/* - * benchtest4.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Measure time taken to complete an elementary operation. - * - * - Mutex - * Single thread iteration over trylock/unlock for each mutex type. - */ - -#include "test.h" -#include - -#ifdef __GNUC__ -#include -#endif - -#include "benchtest.h" - -#define PTW32_MUTEX_TYPES -#define ITERATIONS 10000000L - -pthread_mutex_t mx; -old_mutex_t ox; -pthread_mutexattr_t ma; -PTW32_STRUCT_TIMEB currSysTimeStart; -PTW32_STRUCT_TIMEB currSysTimeStop; -long durationMilliSecs; -long overHeadMilliSecs = 0; - -#define GetDurationMilliSecs(_TStart, _TStop) ((long)((_TStop.time*1000+_TStop.millitm) \ - - (_TStart.time*1000+_TStart.millitm))) - -/* - * Dummy use of j, otherwise the loop may be removed by the optimiser - * when doing the overhead timing with an empty loop. - */ -#define TESTSTART \ - { int i, j = 0, k = 0; PTW32_FTIME(&currSysTimeStart); for (i = 0; i < ITERATIONS; i++) { j++; - -#define TESTSTOP \ - }; PTW32_FTIME(&currSysTimeStop); if (j + k == i) j++; } - - -void -oldRunTest (char * testNameString, int mType) -{ -} - - -void -runTest (char * testNameString, int mType) -{ -#ifdef PTW32_MUTEX_TYPES - pthread_mutexattr_settype(&ma, mType); -#endif - pthread_mutex_init(&mx, &ma); - - TESTSTART - (void) pthread_mutex_trylock(&mx); - (void) pthread_mutex_unlock(&mx); - TESTSTOP - - pthread_mutex_destroy(&mx); - - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - - printf( "%-45s %15ld %15.3f\n", - testNameString, - durationMilliSecs, - (float) durationMilliSecs * 1E3 / ITERATIONS); -} - - -int -main (int argc, char *argv[]) -{ - pthread_mutexattr_init(&ma); - - printf( "=============================================================================\n"); - printf( "Trylock plus unlock on an unlocked mutex.\n"); - printf( "%ld iterations.\n\n", ITERATIONS); - printf( "%-45s %15s %15s\n", - "Test", - "Total(msec)", - "average(usec)"); - printf( "-----------------------------------------------------------------------------\n"); - - /* - * Time the loop overhead so we can subtract it from the actual test times. - */ - - TESTSTART - TESTSTOP - - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - overHeadMilliSecs = durationMilliSecs; - - old_mutex_use = OLD_WIN32CS; - assert(old_mutex_init(&ox, NULL) == 0); - TESTSTART - (void) old_mutex_trylock(&ox); - (void) old_mutex_unlock(&ox); - TESTSTOP - assert(old_mutex_destroy(&ox) == 0); - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - printf( "%-45s %15ld %15.3f\n", - "Old PT Mutex using a Critical Section (WNT)", - durationMilliSecs, - (float) durationMilliSecs * 1E3 / ITERATIONS); - - old_mutex_use = OLD_WIN32MUTEX; - assert(old_mutex_init(&ox, NULL) == 0); - TESTSTART - (void) old_mutex_trylock(&ox); - (void) old_mutex_unlock(&ox); - TESTSTOP - assert(old_mutex_destroy(&ox) == 0); - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - printf( "%-45s %15ld %15.3f\n", - "Old PT Mutex using a Win32 Mutex (W9x)", - durationMilliSecs, - (float) durationMilliSecs * 1E3 / ITERATIONS); - - printf( ".............................................................................\n"); - - /* - * Now we can start the actual tests - */ -#ifdef PTW32_MUTEX_TYPES - runTest("PTHREAD_MUTEX_DEFAULT", PTHREAD_MUTEX_DEFAULT); - - runTest("PTHREAD_MUTEX_NORMAL", PTHREAD_MUTEX_NORMAL); - - runTest("PTHREAD_MUTEX_ERRORCHECK", PTHREAD_MUTEX_ERRORCHECK); - - runTest("PTHREAD_MUTEX_RECURSIVE", PTHREAD_MUTEX_RECURSIVE); -#else - runTest("Non-blocking lock", 0); -#endif - - printf( ".............................................................................\n"); - - pthread_mutexattr_setrobust(&ma, PTHREAD_MUTEX_ROBUST); - -#ifdef PTW32_MUTEX_TYPES - runTest("PTHREAD_MUTEX_DEFAULT (Robust)", PTHREAD_MUTEX_DEFAULT); - - runTest("PTHREAD_MUTEX_NORMAL (Robust)", PTHREAD_MUTEX_NORMAL); - - runTest("PTHREAD_MUTEX_ERRORCHECK (Robust)", PTHREAD_MUTEX_ERRORCHECK); - - runTest("PTHREAD_MUTEX_RECURSIVE (Robust)", PTHREAD_MUTEX_RECURSIVE); -#else - runTest("Non-blocking lock", 0); -#endif - - printf( "=============================================================================\n"); - - /* - * End of tests. - */ - - pthread_mutexattr_destroy(&ma); - - return 0; -} diff --git a/deps/w32-pthreads/tests/benchtest5.c b/deps/w32-pthreads/tests/benchtest5.c deleted file mode 100644 index 368074b..0000000 --- a/deps/w32-pthreads/tests/benchtest5.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * benchtest5.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Measure time taken to complete an elementary operation. - * - * - Semaphore - * Single thread iteration over post/wait for a semaphore. - */ - -#include "test.h" -#include - -#ifdef __GNUC__ -#include -#endif - -#include "benchtest.h" - -#define ITERATIONS 1000000L - -sem_t sema; -HANDLE w32sema; - -PTW32_STRUCT_TIMEB currSysTimeStart; -PTW32_STRUCT_TIMEB currSysTimeStop; -long durationMilliSecs; -long overHeadMilliSecs = 0; -int one = 1; -int zero = 0; - -#define GetDurationMilliSecs(_TStart, _TStop) ((long)((_TStop.time*1000+_TStop.millitm) \ - - (_TStart.time*1000+_TStart.millitm))) - -/* - * Dummy use of j, otherwise the loop may be removed by the optimiser - * when doing the overhead timing with an empty loop. - */ -#define TESTSTART \ - { int i, j = 0, k = 0; PTW32_FTIME(&currSysTimeStart); for (i = 0; i < ITERATIONS; i++) { j++; - -#define TESTSTOP \ - }; PTW32_FTIME(&currSysTimeStop); if (j + k == i) j++; } - - -void -reportTest (char * testNameString) -{ - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - - printf( "%-45s %15ld %15.3f\n", - testNameString, - durationMilliSecs, - (float) durationMilliSecs * 1E3 / ITERATIONS); -} - - -int -main (int argc, char *argv[]) -{ - printf( "=============================================================================\n"); - printf( "\nOperations on a semaphore.\n%ld iterations\n\n", - ITERATIONS); - printf( "%-45s %15s %15s\n", - "Test", - "Total(msec)", - "average(usec)"); - printf( "-----------------------------------------------------------------------------\n"); - - /* - * Time the loop overhead so we can subtract it from the actual test times. - */ - - TESTSTART - assert(1 == one); - TESTSTOP - - durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs; - overHeadMilliSecs = durationMilliSecs; - - - /* - * Now we can start the actual tests - */ - assert((w32sema = CreateSemaphore(NULL, (long) 0, (long) ITERATIONS, NULL)) != 0); - TESTSTART - assert((ReleaseSemaphore(w32sema, 1, NULL),1) == one); - TESTSTOP - assert(CloseHandle(w32sema) != 0); - - reportTest("W32 Post with no waiters"); - - - assert((w32sema = CreateSemaphore(NULL, (long) ITERATIONS, (long) ITERATIONS, NULL)) != 0); - TESTSTART - assert((WaitForSingleObject(w32sema, INFINITE),1) == one); - TESTSTOP - assert(CloseHandle(w32sema) != 0); - - reportTest("W32 Wait without blocking"); - - - assert(sem_init(&sema, 0, 0) == 0); - TESTSTART - assert((sem_post(&sema),1) == one); - TESTSTOP - assert(sem_destroy(&sema) == 0); - - reportTest("POSIX Post with no waiters"); - - - assert(sem_init(&sema, 0, ITERATIONS) == 0); - TESTSTART - assert((sem_wait(&sema),1) == one); - TESTSTOP - assert(sem_destroy(&sema) == 0); - - reportTest("POSIX Wait without blocking"); - - - printf( "=============================================================================\n"); - - /* - * End of tests. - */ - - return 0; -} diff --git a/deps/w32-pthreads/tests/cancel1.c b/deps/w32-pthreads/tests/cancel1.c deleted file mode 100644 index b9d0d94..0000000 --- a/deps/w32-pthreads/tests/cancel1.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * File: cancel1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Test setting cancel state and cancel type. - * - - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - pthread_setcancelstate function - * - pthread_setcanceltype function - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - pthread_create, pthread_self work. - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 2 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -void * -mythread(void * arg) -{ - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - /* ... */ - { - int oldstate; - int oldtype; - - assert(pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate) == 0); - assert(oldstate == PTHREAD_CANCEL_ENABLE); /* Check default */ - assert(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) == 0); - assert(pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL) == 0); - assert(pthread_setcancelstate(oldstate, &oldstate) == 0); - assert(oldstate == PTHREAD_CANCEL_DISABLE); /* Check setting */ - - assert(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype) == 0); - assert(oldtype == PTHREAD_CANCEL_DEFERRED); /* Check default */ - assert(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) == 0); - assert(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0); - assert(pthread_setcanceltype(oldtype, &oldtype) == 0); - assert(oldtype == PTHREAD_CANCEL_ASYNCHRONOUS); /* Check setting */ - } - - return 0; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - assert((t[0] = pthread_self()).p != NULL); - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - - /* - * Give threads time to run. - */ - Sleep(NUMTHREADS * 100); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - failed = !threadbag[i].started; - - if (failed) - { - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. Set "failed" and only print ouput on failure. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - /* ... */ - } - - assert(!failed); - - /* - * Success. - */ - return 0; -} diff --git a/deps/w32-pthreads/tests/cancel2.c b/deps/w32-pthreads/tests/cancel2.c deleted file mode 100644 index 95bd1e3..0000000 --- a/deps/w32-pthreads/tests/cancel2.c +++ /dev/null @@ -1,258 +0,0 @@ -/* - * File: cancel2.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Test SEH or C++ cancel exception handling within - * application exception blocks. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel, pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -/* - * Don't know how to identify if we are using SEH so it's only C++ for now - */ -#if defined(__cplusplus) - -#include "test.h" - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 4 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -static pthread_mutex_t waitLock = PTHREAD_MUTEX_INITIALIZER; - -void * -mythread(void * arg) -{ - int result = 0; - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - /* Set to known state and type */ - - assert(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) == 0); - - switch (bag->threadnum % 2) - { - case 0: - assert(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0); - result = 0; - break; - case 1: - assert(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) == 0); - result = 1; - break; - } - -#if !defined(__cplusplus) - __try -#else - try -#endif - { - /* Wait for go from main */ - assert(pthread_mutex_lock(&waitLock) == 0); - assert(pthread_mutex_unlock(&waitLock) == 0); - sched_yield(); - - for (;;) - { - pthread_testcancel(); - } - } -#if !defined(__cplusplus) - __except(EXCEPTION_EXECUTE_HANDLER) -#else -#if defined(PtW32CatchAll) - PtW32CatchAll -#else - catch(...) -#endif -#endif - { - /* - * Should not get into here. - */ - result += 100; - } - - /* - * Should not get to here either. - */ - result += 1000; - - return (void *) (size_t)result; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - assert((t[0] = pthread_self()).p != NULL); - assert(pthread_mutex_lock(&waitLock) == 0); - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep(500); - - assert(pthread_mutex_unlock(&waitLock) == 0); - - Sleep(500); - - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_cancel(t[i]) == 0); - } - - /* - * Give threads time to run. - */ - Sleep(NUMTHREADS * 100); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - if (!threadbag[i].started) - { - failed |= !threadbag[i].started; - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. Set "failed" and only print output on failure. - */ - failed = 0; - for (i = 1; i <= NUMTHREADS; i++) - { - int fail = 0; - void* result = (void*)0; - - assert(pthread_join(t[i], &result) == 0); - fail = ((int)(size_t)result != (int) PTHREAD_CANCELED); - if (fail) - { - fprintf(stderr, "Thread %d: started %d: location %d: cancel type %s\n", - i, - threadbag[i].started, - (int)(size_t)result, - (((int)(size_t)result % 2) == 0) ? "ASYNCHRONOUS" : "DEFERRED"); - } - failed |= fail; - } - - assert(!failed); - - /* - * Success. - */ - return 0; -} - -#else /* defined(__cplusplus) */ - -#include - -int -main() -{ - fprintf(stderr, "Test N/A for this compiler environment.\n"); - return 0; -} - -#endif /* defined(__cplusplus) */ - diff --git a/deps/w32-pthreads/tests/cancel3.c b/deps/w32-pthreads/tests/cancel3.c deleted file mode 100644 index 5e89a32..0000000 --- a/deps/w32-pthreads/tests/cancel3.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * File: cancel3.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Test asynchronous cancelation (alertable or non-alertable). - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - Async cancel if thread is not blocked (i.e. voluntarily resumes if blocked). - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel, pthread_join. - * - quserex.dll and alertdrv.sys are not available. - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum -{ - NUMTHREADS = 4 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ -{ - int threadnum; - int started; - /* Add more per-thread state variables here */ - int count; -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -void * -mythread (void *arg) -{ - void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1); - bag_t *bag = (bag_t *) arg; - - assert (bag == &threadbag[bag->threadnum]); - assert (bag->started == 0); - bag->started = 1; - - /* Set to known state and type */ - - assert (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) == 0); - - assert (pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0); - - /* - * We wait up to 10 seconds, waking every 0.1 seconds, - * for a cancelation to be applied to us. - */ - for (bag->count = 0; bag->count < 100; bag->count++) - Sleep (100); - - return result; -} - -int -main () -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - assert ((t[0] = pthread_self ()).p != NULL); - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert (pthread_create (&t[i], NULL, mythread, (void *) &threadbag[i]) - == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep (NUMTHREADS * 100); - - for (i = 1; i <= NUMTHREADS; i++) - { - assert (pthread_cancel (t[i]) == 0); - } - - /* - * Give threads time to complete. - */ - Sleep (NUMTHREADS * 100); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - if (!threadbag[i].started) - { - failed |= !threadbag[i].started; - fprintf (stderr, "Thread %d: started %d\n", i, - threadbag[i].started); - } - } - - assert (!failed); - - /* - * Check any results here. Set "failed" and only print output on failure. - */ - failed = 0; - for (i = 1; i <= NUMTHREADS; i++) - { - int fail = 0; - void* result = (void*)0; - - /* - * The thread does not contain any cancelation points, so - * a return value of PTHREAD_CANCELED confirms that async - * cancelation succeeded. - */ - assert (pthread_join (t[i], &result) == 0); - - fail = (result != PTHREAD_CANCELED); - - if (fail) - { - fprintf (stderr, "Thread %d: started %d: count %d\n", - i, threadbag[i].started, threadbag[i].count); - } - failed = (failed || fail); - } - - assert (!failed); - - /* - * Success. - */ - return 0; -} diff --git a/deps/w32-pthreads/tests/cancel4.c b/deps/w32-pthreads/tests/cancel4.c deleted file mode 100644 index 972e2b8..0000000 --- a/deps/w32-pthreads/tests/cancel4.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - * File: cancel4.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Test cancelation does not occur in deferred - * cancelation threads with no cancelation points. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - pthread_create - * pthread_self - * pthread_cancel - * pthread_join - * pthread_setcancelstate - * pthread_setcanceltype - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 4 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ - int count; -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -void * -mythread(void * arg) -{ - void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1); - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - /* Set to known state and type */ - - assert(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) == 0); - - assert(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) == 0); - - /* - * We wait up to 2 seconds, waking every 0.1 seconds, - * for a cancelation to be applied to us. - */ - for (bag->count = 0; bag->count < 20; bag->count++) - Sleep(100); - - return result; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - assert((t[0] = pthread_self()).p != NULL); - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep(500); - - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_cancel(t[i]) == 0); - } - - /* - * Give threads time to run. - */ - Sleep(NUMTHREADS * 100); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - if (!threadbag[i].started) - { - failed |= !threadbag[i].started; - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. Set "failed" and only print output on failure. - */ - failed = 0; - for (i = 1; i <= NUMTHREADS; i++) - { - int fail = 0; - void* result = (void*)0; - - /* - * The thread does not contain any cancelation points, so - * a return value of PTHREAD_CANCELED indicates that async - * cancelation occurred. - */ - assert(pthread_join(t[i], &result) == 0); - - fail = (result == PTHREAD_CANCELED); - - if (fail) - { - fprintf(stderr, "Thread %d: started %d: count %d\n", - i, - threadbag[i].started, - threadbag[i].count); - } - failed = (failed || fail); - } - - assert(!failed); - - /* - * Success. - */ - return 0; -} diff --git a/deps/w32-pthreads/tests/cancel5.c b/deps/w32-pthreads/tests/cancel5.c deleted file mode 100644 index 03c9da6..0000000 --- a/deps/w32-pthreads/tests/cancel5.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - * File: cancel5.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Test calling pthread_cancel from the main thread - * without calling pthread_self() in main. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel, pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum -{ - NUMTHREADS = 4 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ -{ - int threadnum; - int started; - /* Add more per-thread state variables here */ - int count; -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -void * -mythread (void *arg) -{ - void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1); - bag_t *bag = (bag_t *) arg; - - assert (bag == &threadbag[bag->threadnum]); - assert (bag->started == 0); - bag->started = 1; - - /* Set to known state and type */ - - assert (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) == 0); - - assert (pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0); - - /* - * We wait up to 10 seconds, waking every 0.1 seconds, - * for a cancelation to be applied to us. - */ - for (bag->count = 0; bag->count < 100; bag->count++) - Sleep (100); - - return result; -} - -int -main () -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert (pthread_create (&t[i], NULL, mythread, (void *) &threadbag[i]) - == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep (500); - - for (i = 1; i <= NUMTHREADS; i++) - { - assert (pthread_cancel (t[i]) == 0); - } - - /* - * Give threads time to run. - */ - Sleep (NUMTHREADS * 100); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - if (!threadbag[i].started) - { - failed |= !threadbag[i].started; - fprintf (stderr, "Thread %d: started %d\n", i, - threadbag[i].started); - } - } - - assert (!failed); - - /* - * Check any results here. Set "failed" and only print output on failure. - */ - failed = 0; - for (i = 1; i <= NUMTHREADS; i++) - { - int fail = 0; - void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1); - - /* - * The thread does not contain any cancelation points, so - * a return value of PTHREAD_CANCELED confirms that async - * cancelation succeeded. - */ - assert (pthread_join (t[i], &result) == 0); - - fail = (result != PTHREAD_CANCELED); - - if (fail) - { - fprintf (stderr, "Thread %d: started %d: count %d\n", - i, threadbag[i].started, threadbag[i].count); - } - failed = (failed || fail); - } - - assert (!failed); - - /* - * Success. - */ - return 0; -} diff --git a/deps/w32-pthreads/tests/cancel6a.c b/deps/w32-pthreads/tests/cancel6a.c deleted file mode 100644 index ba22391..0000000 --- a/deps/w32-pthreads/tests/cancel6a.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * File: cancel6a.c - * - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright (C) 1998 Ben Elliston and Ross Johnson - * Copyright (C) 1999,2000,2001 Ross Johnson - * - * Contact Email: rpj@ise.canberra.edu.au - * - * 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.1 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; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Test double cancelation - asynchronous. - * Second attempt should fail (ESRCH). - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel, pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 4 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ - int count; -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -void * -mythread(void * arg) -{ - void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1); - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - /* Set to known state and type */ - - assert(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) == 0); - - assert(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0); - - /* - * We wait up to 10 seconds, waking every 0.1 seconds, - * for a cancelation to be applied to us. - */ - for (bag->count = 0; bag->count < 100; bag->count++) - Sleep(100); - - return result; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - assert((t[0] = pthread_self()).p != NULL); - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep(500); - - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_cancel(t[i]) == 0); - assert(pthread_cancel(t[i]) == ESRCH); - } - - /* - * Give threads time to run. - */ - Sleep(NUMTHREADS * 100); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - if (!threadbag[i].started) - { - failed |= !threadbag[i].started; - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. Set "failed" and only print output on failure. - */ - failed = 0; - for (i = 1; i <= NUMTHREADS; i++) - { - int fail = 0; - void* result = (void*)0; - - /* - * The thread does not contain any cancelation points, so - * a return value of PTHREAD_CANCELED confirms that async - * cancelation succeeded. - */ - assert(pthread_join(t[i], &result) == 0); - - fail = (result != PTHREAD_CANCELED); - - if (fail) - { - fprintf(stderr, "Thread %d: started %d: count %d\n", - i, - threadbag[i].started, - threadbag[i].count); - } - failed = (failed || fail); - } - - assert(!failed); - - /* - * Success. - */ - return 0; -} diff --git a/deps/w32-pthreads/tests/cancel6d.c b/deps/w32-pthreads/tests/cancel6d.c deleted file mode 100644 index 9c18d8b..0000000 --- a/deps/w32-pthreads/tests/cancel6d.c +++ /dev/null @@ -1,193 +0,0 @@ -/* - * File: cancel6d.c - * - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright (C) 1998 Ben Elliston and Ross Johnson - * Copyright (C) 1999,2000,2001 Ross Johnson - * - * Contact Email: rpj@ise.canberra.edu.au - * - * 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.1 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; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Test double cancelation - deferred. - * Second attempt should succeed (unless the canceled thread has started - * cancelation already - not tested here). - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel, pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 4 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ - int count; -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -void * -mythread(void * arg) -{ - void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1); - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - /* Set to known state and type */ - - assert(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) == 0); - - assert(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) == 0); - - /* - * We wait up to 10 seconds, waking every 0.1 seconds, - * for a cancelation to be applied to us. - */ - for (bag->count = 0; bag->count < 100; bag->count++) - { - Sleep(100); - pthread_testcancel(); - } - - return result; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - assert((t[0] = pthread_self()).p != NULL); - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *)(size_t) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep(500); - - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_cancel(t[i]) == 0); - if (pthread_cancel(t[i]) != 0) - { - printf("Second cancelation failed but this is expected sometimes.\n"); - } - } - - /* - * Give threads time to run. - */ - Sleep(NUMTHREADS * 100); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - if (!threadbag[i].started) - { - failed |= !threadbag[i].started; - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. Set "failed" and only print output on failure. - */ - failed = 0; - for (i = 1; i <= NUMTHREADS; i++) - { - int fail = 0; - void* result = (void*)0; - - assert(pthread_join(t[i], &result) == 0); - - fail = (result != PTHREAD_CANCELED); - - if (fail) - { - fprintf(stderr, "Thread %d: started %d: count %d\n", - i, - threadbag[i].started, - threadbag[i].count); - } - failed = (failed || fail); - } - - assert(!failed); - - /* - * Success. - */ - return 0; -} diff --git a/deps/w32-pthreads/tests/cancel7.c b/deps/w32-pthreads/tests/cancel7.c deleted file mode 100644 index 0132b38..0000000 --- a/deps/w32-pthreads/tests/cancel7.c +++ /dev/null @@ -1,218 +0,0 @@ -/* - * File: cancel7.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Test canceling a Win32 thread having created an - * implicit POSIX handle for it. - * - * Test Method (Validation or Falsification): - * - Validate return value and that POSIX handle is created and destroyed. - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" -#ifndef _UWIN -#include -#endif - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 4 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ - int count; - pthread_t self; -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -#if ! defined (__MINGW32__) || defined (__MSVCRT__) -unsigned __stdcall -#else -void -#endif -Win32thread(void * arg) -{ - int i; - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - assert((bag->self = pthread_self()).p != NULL); - assert(pthread_kill(bag->self, 0) == 0); - - for (i = 0; i < 100; i++) - { - Sleep(100); - pthread_testcancel(); - } - -#if ! defined (__MINGW32__) || defined (__MSVCRT__) - return 0; -#endif -} - -int -main() -{ - int failed = 0; - int i; - HANDLE h[NUMTHREADS + 1]; - unsigned thrAddr; /* Dummy variable to pass a valid location to _beginthreadex (Win98). */ - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; -#if ! defined (__MINGW32__) || defined (__MSVCRT__) - h[i] = (HANDLE) _beginthreadex(NULL, 0, Win32thread, (void *) &threadbag[i], 0, &thrAddr); -#else - h[i] = (HANDLE) _beginthread(Win32thread, 0, (void *) &threadbag[i]); -#endif - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep(500); - - /* - * Cancel all threads. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_kill(threadbag[i].self, 0) == 0); - assert(pthread_cancel(threadbag[i].self) == 0); - } - - /* - * Give threads time to run. - */ - Sleep(NUMTHREADS * 100); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - if (!threadbag[i].started) - { - failed |= !threadbag[i].started; - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. Set "failed" and only print output on failure. - */ - failed = 0; - for (i = 1; i <= NUMTHREADS; i++) - { - int fail = 0; - int result = 0; - -#if ! defined (__MINGW32__) || defined (__MSVCRT__) - assert(GetExitCodeThread(h[i], (LPDWORD) &result) == TRUE); -#else - /* - * Can't get a result code. - */ - result = (int)(size_t)PTHREAD_CANCELED; -#endif - - assert(threadbag[i].self.p != NULL); - assert(pthread_kill(threadbag[i].self, 0) == ESRCH); - - fail = (result != (int)(size_t)PTHREAD_CANCELED); - - if (fail) - { - fprintf(stderr, "Thread %d: started %d: count %d\n", - i, - threadbag[i].started, - threadbag[i].count); - } - failed = (failed || fail); - } - - assert(!failed); - - /* - * Success. - */ - return 0; -} - diff --git a/deps/w32-pthreads/tests/cancel8.c b/deps/w32-pthreads/tests/cancel8.c deleted file mode 100644 index d7799fb..0000000 --- a/deps/w32-pthreads/tests/cancel8.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - * File: cancel8.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Test cancelling a blocked Win32 thread having created an - * implicit POSIX handle for it. - * - * Test Method (Validation or Falsification): - * - Validate return value and that POSIX handle is created and destroyed. - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" -#ifndef _UWIN -#include -#endif - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 4 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ - int count; - pthread_t self; -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -pthread_cond_t CV = PTHREAD_COND_INITIALIZER; -pthread_mutex_t CVLock = PTHREAD_MUTEX_INITIALIZER; - -#if ! defined (__MINGW32__) || defined (__MSVCRT__) -unsigned __stdcall -#else -void -#endif -Win32thread(void * arg) -{ - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - assert((bag->self = pthread_self()).p != NULL); - assert(pthread_kill(bag->self, 0) == 0); - - assert(pthread_mutex_lock(&CVLock) == 0); - pthread_cleanup_push(pthread_mutex_unlock, &CVLock); - pthread_cond_wait(&CV, &CVLock); - pthread_cleanup_pop(1); - -#if ! defined (__MINGW32__) || defined (__MSVCRT__) - return 0; -#endif -} - -int -main() -{ - int failed = 0; - int i; - HANDLE h[NUMTHREADS + 1]; - unsigned thrAddr; /* Dummy variable to pass a valid location to _beginthreadex (Win98). */ - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; -#if ! defined (__MINGW32__) || defined (__MSVCRT__) - h[i] = (HANDLE) _beginthreadex(NULL, 0, Win32thread, (void *) &threadbag[i], 0, &thrAddr); -#else - h[i] = (HANDLE) _beginthread(Win32thread, 0, (void *) &threadbag[i]); -#endif - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep(500); - - /* - * Cancel all threads. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_kill(threadbag[i].self, 0) == 0); - assert(pthread_cancel(threadbag[i].self) == 0); - } - - /* - * Give threads time to run. - */ - Sleep(NUMTHREADS * 100); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - if (!threadbag[i].started) - { - failed |= !threadbag[i].started; - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. Set "failed" and only print output on failure. - */ - failed = 0; - for (i = 1; i <= NUMTHREADS; i++) - { - int fail = 0; - int result = 0; - -#if ! defined (__MINGW32__) || defined (__MSVCRT__) - assert(GetExitCodeThread(h[i], (LPDWORD) &result) == TRUE); -#else - /* - * Can't get a result code. - */ - result = (int)(size_t)PTHREAD_CANCELED; -#endif - - assert(threadbag[i].self.p != NULL); - assert(pthread_kill(threadbag[i].self, 0) == ESRCH); - - fail = (result != (int)(size_t)PTHREAD_CANCELED); - - if (fail) - { - fprintf(stderr, "Thread %d: started %d: count %d\n", - i, - threadbag[i].started, - threadbag[i].count); - } - failed = (failed || fail); - } - - assert(!failed); - - /* - * Success. - */ - return 0; -} - diff --git a/deps/w32-pthreads/tests/cancel9.c b/deps/w32-pthreads/tests/cancel9.c deleted file mode 100644 index ab28aec..0000000 --- a/deps/w32-pthreads/tests/cancel9.c +++ /dev/null @@ -1,202 +0,0 @@ -/* - * File: cancel9.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Test true asynchronous cancelation with Alert driver. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - Cancel threads, including those blocked on system recources - * such as network I/O. - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel, pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" -#include - - -void * -test_udp (void *arg) -{ - struct sockaddr_in serverAddress; - struct sockaddr_in clientAddress; - SOCKET UDPSocket; - int addr_len; - int nbyte, bytes; - char buffer[4096]; - WORD wsaVersion = MAKEWORD (2, 2); - WSADATA wsaData; - - pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL); - pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL); - - if (WSAStartup (wsaVersion, &wsaData) != 0) - { - return NULL; - } - - UDPSocket = socket (AF_INET, SOCK_DGRAM, 0); - if ((int)UDPSocket == -1) - { - printf ("Server: socket ERROR \n"); - exit (-1); - } - - serverAddress.sin_family = AF_INET; - serverAddress.sin_addr.s_addr = INADDR_ANY; - serverAddress.sin_port = htons (9003); - - if (bind - (UDPSocket, (struct sockaddr *) &serverAddress, - sizeof (struct sockaddr_in))) - { - printf ("Server: ERROR can't bind UDPSocket"); - exit (-1); - } - - addr_len = sizeof (struct sockaddr); - - nbyte = 512; - - bytes = - recvfrom (UDPSocket, (char *) buffer, nbyte, 0, - (struct sockaddr *) &clientAddress, &addr_len); - - closesocket (UDPSocket); - WSACleanup (); - - return NULL; -} - - -void * -test_sleep (void *arg) -{ - pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL); - pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL); - - Sleep (1000); - return NULL; - -} - -void * -test_wait (void *arg) -{ - HANDLE hEvent; - DWORD dwEvent; - - pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL); - pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL); - - hEvent = CreateEvent (NULL, FALSE, FALSE, NULL); - - dwEvent = WaitForSingleObject (hEvent, 1000); /* WAIT_IO_COMPLETION */ - - return NULL; -} - - -int -main () -{ - pthread_t t; - void *result; - - if (pthread_win32_test_features_np (PTW32_ALERTABLE_ASYNC_CANCEL)) - { - printf ("Cancel sleeping thread.\n"); - assert (pthread_create (&t, NULL, test_sleep, NULL) == 0); - /* Sleep for a while; then cancel */ - Sleep (100); - assert (pthread_cancel (t) == 0); - assert (pthread_join (t, &result) == 0); - assert (result == PTHREAD_CANCELED && "test_sleep" != NULL); - - printf ("Cancel waiting thread.\n"); - assert (pthread_create (&t, NULL, test_wait, NULL) == 0); - /* Sleep for a while; then cancel. */ - Sleep (100); - assert (pthread_cancel (t) == 0); - assert (pthread_join (t, &result) == 0); - assert (result == PTHREAD_CANCELED && "test_wait"); - - printf ("Cancel blocked thread (blocked on network I/O).\n"); - assert (pthread_create (&t, NULL, test_udp, NULL) == 0); - /* Sleep for a while; then cancel. */ - Sleep (100); - assert (pthread_cancel (t) == 0); - assert (pthread_join (t, &result) == 0); - assert (result == PTHREAD_CANCELED && "test_udp" != NULL); - } - else - { - printf ("Alertable async cancel not available.\n"); - } - - /* - * Success. - */ - return 0; -} diff --git a/deps/w32-pthreads/tests/cleanup0.c b/deps/w32-pthreads/tests/cleanup0.c deleted file mode 100644 index 8303064..0000000 --- a/deps/w32-pthreads/tests/cleanup0.c +++ /dev/null @@ -1,229 +0,0 @@ -/* - * File: cleanup1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Test cleanup handler executes (when thread is not canceled). - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel, pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#if defined(_MSC_VER) || defined(__cplusplus) - -#include "test.h" - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 10 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ - int count; -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -typedef struct { - int i; - CRITICAL_SECTION cs; -} sharedInt_t; - -static sharedInt_t pop_count = {0, {0}}; - -static void -increment_pop_count(void * arg) -{ - sharedInt_t * sI = (sharedInt_t *) arg; - - EnterCriticalSection(&sI->cs); - sI->i++; - LeaveCriticalSection(&sI->cs); -} - -void * -mythread(void * arg) -{ - int result = 0; - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - /* Set to known state and type */ - - assert(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) == 0); - - assert(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0); - -#ifdef _MSC_VER -#pragma inline_depth(0) -#endif - pthread_cleanup_push(increment_pop_count, (void *) &pop_count); - - Sleep(100); - - pthread_cleanup_pop(1); -#ifdef _MSC_VER -#pragma inline_depth() -#endif - - return (void *) (size_t)result; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - InitializeCriticalSection(&pop_count.cs); - - assert((t[0] = pthread_self()).p != NULL); - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep(500); - - /* - * Give threads time to run. - */ - Sleep(NUMTHREADS * 100); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - if (!threadbag[i].started) - { - failed |= !threadbag[i].started; - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. Set "failed" and only print output on failure. - */ - failed = 0; - for (i = 1; i <= NUMTHREADS; i++) - { - int fail = 0; - void* result = (void*)0; - - assert(pthread_join(t[i], &result) == 0); - - fail = ((int)(size_t)result == (int) PTHREAD_CANCELED); - - if (fail) - { - fprintf(stderr, "Thread %d: started %d: result %d\n", - i, - threadbag[i].started, - (int)(size_t)result); - fflush(stderr); - } - failed = (failed || fail); - } - - assert(!failed); - - assert(pop_count.i == NUMTHREADS); - - DeleteCriticalSection(&pop_count.cs); - - /* - * Success. - */ - return 0; -} - -#else /* defined(_MSC_VER) || defined(__cplusplus) */ - -int -main() -{ - return 0; -} - -#endif /* defined(_MSC_VER) || defined(__cplusplus) */ diff --git a/deps/w32-pthreads/tests/cleanup1.c b/deps/w32-pthreads/tests/cleanup1.c deleted file mode 100644 index 4ddd5d0..0000000 --- a/deps/w32-pthreads/tests/cleanup1.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * File: cleanup1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Test cleanup handler executes (when thread is canceled). - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel, pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#if defined(_MSC_VER) || defined(__cplusplus) - -#include "test.h" - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 10 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ - int count; -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -typedef struct { - int i; - CRITICAL_SECTION cs; -} sharedInt_t; - -static sharedInt_t pop_count = {0, {0}}; - -static void -#ifdef __CLEANUP_C -__cdecl -#endif -increment_pop_count(void * arg) -{ - sharedInt_t * sI = (sharedInt_t *) arg; - - EnterCriticalSection(&sI->cs); - sI->i++; - LeaveCriticalSection(&sI->cs); -} - -void * -mythread(void * arg) -{ - int result = 0; - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - /* Set to known state and type */ - - assert(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) == 0); - - assert(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0); - -#ifdef _MSC_VER -#pragma inline_depth(0) -#endif - pthread_cleanup_push(increment_pop_count, (void *) &pop_count); - /* - * We don't have true async cancelation - it relies on the thread - * at least re-entering the run state at some point. - * We wait up to 10 seconds, waking every 0.1 seconds, - * for a cancelation to be applied to us. - */ - for (bag->count = 0; bag->count < 100; bag->count++) - Sleep(100); - - pthread_cleanup_pop(0); -#ifdef _MSC_VER -#pragma inline_depth() -#endif - - return (void *) (size_t)result; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - InitializeCriticalSection(&pop_count.cs); - - assert((t[0] = pthread_self()).p != NULL); - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep(500); - - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_cancel(t[i]) == 0); - } - - /* - * Give threads time to run. - */ - Sleep(NUMTHREADS * 100); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - if (!threadbag[i].started) - { - failed |= !threadbag[i].started; - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. Set "failed" and only print output on failure. - */ - failed = 0; - for (i = 1; i <= NUMTHREADS; i++) - { - int fail = 0; - void* result = (void*)0; - - assert(pthread_join(t[i], &result) == 0); - - fail = ((int)(size_t)result != (int) PTHREAD_CANCELED); - - if (fail) - { - fprintf(stderr, "Thread %d: started %d: result %d\n", - i, - threadbag[i].started, - (int)(size_t)result); - } - failed = (failed || fail); - } - - assert(!failed); - - assert(pop_count.i == NUMTHREADS); - - DeleteCriticalSection(&pop_count.cs); - - /* - * Success. - */ - return 0; -} - -#else /* defined(_MSC_VER) || defined(__cplusplus) */ - -int -main() -{ - return 0; -} - -#endif /* defined(_MSC_VER) || defined(__cplusplus) */ diff --git a/deps/w32-pthreads/tests/cleanup2.c b/deps/w32-pthreads/tests/cleanup2.c deleted file mode 100644 index b167490..0000000 --- a/deps/w32-pthreads/tests/cleanup2.c +++ /dev/null @@ -1,217 +0,0 @@ -/* - * File: cleanup2.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Test cleanup handler executes (when thread is not canceled). - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel, pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#if defined(_MSC_VER) || defined(__cplusplus) - -#include "test.h" - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 10 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ - int count; -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -typedef struct { - int i; - CRITICAL_SECTION cs; -} sharedInt_t; - -static sharedInt_t pop_count = {0, {0}}; - -static void -increment_pop_count(void * arg) -{ - sharedInt_t * sI = (sharedInt_t *) arg; - - EnterCriticalSection(&sI->cs); - sI->i++; - LeaveCriticalSection(&sI->cs); -} - -void * -mythread(void * arg) -{ - int result = 0; - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - -#ifdef _MSC_VER -#pragma inline_depth(0) -#endif - pthread_cleanup_push(increment_pop_count, (void *) &pop_count); - - sched_yield(); - - pthread_cleanup_pop(1); -#ifdef _MSC_VER -#pragma inline_depth() -#endif - - return (void *) (size_t)result; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - InitializeCriticalSection(&pop_count.cs); - - assert((t[0] = pthread_self()).p != NULL); - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep(1000); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - if (!threadbag[i].started) - { - failed |= !threadbag[i].started; - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. Set "failed" and only print output on failure. - */ - failed = 0; - for (i = 1; i <= NUMTHREADS; i++) - { - int fail = 0; - void* result = (void*)0; - - assert(pthread_join(t[i], &result) == 0); - - fail = ((int)(size_t)result != 0); - - if (fail) - { - fprintf(stderr, "Thread %d: started %d: result: %d\n", - i, - threadbag[i].started, - (int)(size_t)result); - } - failed = (failed || fail); - } - - assert(!failed); - - assert(pop_count.i == NUMTHREADS); - - DeleteCriticalSection(&pop_count.cs); - - /* - * Success. - */ - return 0; -} - -#else /* defined(_MSC_VER) || defined(__cplusplus) */ - -int -main() -{ - return 0; -} - -#endif /* defined(_MSC_VER) || defined(__cplusplus) */ diff --git a/deps/w32-pthreads/tests/cleanup3.c b/deps/w32-pthreads/tests/cleanup3.c deleted file mode 100644 index 37f5168..0000000 --- a/deps/w32-pthreads/tests/cleanup3.c +++ /dev/null @@ -1,222 +0,0 @@ -/* - * File: cleanup3.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Test cleanup handler does not execute (when thread is - * not canceled). - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel, pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#if defined(_MSC_VER) || defined(__cplusplus) - -#include "test.h" - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 10 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ - int count; -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -typedef struct { - int i; - CRITICAL_SECTION cs; -} sharedInt_t; - -static sharedInt_t pop_count = {0, {0}}; - -static void -increment_pop_count(void * arg) -{ - sharedInt_t * sI = (sharedInt_t *) arg; - - EnterCriticalSection(&sI->cs); - sI->i++; - LeaveCriticalSection(&sI->cs); -} - -void * -mythread(void * arg) -{ - int result = 0; - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - -#ifdef _MSC_VER -#pragma inline_depth(0) -#endif - pthread_cleanup_push(increment_pop_count, (void *) &pop_count); - - sched_yield(); - - EnterCriticalSection(&pop_count.cs); - pop_count.i--; - LeaveCriticalSection(&pop_count.cs); - - pthread_cleanup_pop(0); -#ifdef _MSC_VER -#pragma inline_depth() -#endif - - return (void *) (size_t)result; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - InitializeCriticalSection(&pop_count.cs); - - assert((t[0] = pthread_self()).p != NULL); - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep(1000); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - if (!threadbag[i].started) - { - failed |= !threadbag[i].started; - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. Set "failed" and only print output on failure. - */ - failed = 0; - for (i = 1; i <= NUMTHREADS; i++) - { - int fail = 0; - void* result = (void*)0; - - assert(pthread_join(t[i], &result) == 0); - - fail = ((int)(size_t)result != 0); - - if (fail) - { - fprintf(stderr, "Thread %d: started %d: result: %d\n", - i, - threadbag[i].started, - (int)(size_t)result); - } - failed = (failed || fail); - } - - assert(!failed); - - assert(pop_count.i == -(NUMTHREADS)); - - DeleteCriticalSection(&pop_count.cs); - - /* - * Success. - */ - return 0; -} - -#else /* defined(_MSC_VER) || defined(__cplusplus) */ - -int -main() -{ - return 0; -} - -#endif /* defined(_MSC_VER) || defined(__cplusplus) */ diff --git a/deps/w32-pthreads/tests/condvar1.c b/deps/w32-pthreads/tests/condvar1.c deleted file mode 100644 index da0c7af..0000000 --- a/deps/w32-pthreads/tests/condvar1.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * File: condvar1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test initialisation and destruction of a CV. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Creates and then imediately destroys a CV. Does not - * test the CV. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - pthread_cond_init returns 0, and - * - pthread_cond_destroy returns 0. - * - Process returns zero exit status. - * - * Fail Criteria: - * - pthread_cond_init returns non-zero, or - * - pthread_cond_destroy returns non-zero. - * - Process returns non-zero exit status. - */ - -#include "test.h" - -static pthread_cond_t cv = NULL; - -int -main() -{ - assert(cv == NULL); - - assert(pthread_cond_init(&cv, NULL) == 0); - - assert(cv != NULL); - - assert(pthread_cond_destroy(&cv) == 0); - - assert(cv == NULL); - - return 0; -} diff --git a/deps/w32-pthreads/tests/condvar1_1.c b/deps/w32-pthreads/tests/condvar1_1.c deleted file mode 100644 index 12bf85f..0000000 --- a/deps/w32-pthreads/tests/condvar1_1.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * File: condvar1_1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test CV linked list management. - * - * Test Method (Validation or Falsification): - * - Validation: - * Initiate and destroy several CVs in random order. - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Creates and then imediately destroys a CV. Does not - * test the CV. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - All initialised CVs destroyed without segfault. - * - Successfully broadcasts all remaining CVs after - * each CV is removed. - * - * Fail Criteria: - */ - -#include -#include "test.h" - -enum { - NUM_CV = 100 -}; - -static pthread_cond_t cv[NUM_CV]; - -int -main() -{ - int i, j; - - for (i = 0; i < NUM_CV; i++) - { - /* Traverse the list before every init of a CV. */ - assert(pthread_timechange_handler_np(NULL) == (void *) 0); - assert(pthread_cond_init(&cv[i], NULL) == 0); - } - - j = NUM_CV; - (void) srand((unsigned)time(NULL)); - - do - { - i = (NUM_CV - 1) * rand() / RAND_MAX; - if (cv[i] != NULL) - { - j--; - assert(pthread_cond_destroy(&cv[i]) == 0); - /* Traverse the list every time we remove a CV. */ - assert(pthread_timechange_handler_np(NULL) == (void *) 0); - } - } - while (j > 0); - - return 0; -} diff --git a/deps/w32-pthreads/tests/condvar1_2.c b/deps/w32-pthreads/tests/condvar1_2.c deleted file mode 100644 index 8a591a0..0000000 --- a/deps/w32-pthreads/tests/condvar1_2.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * File: condvar1_2.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test CV linked list management and serialisation. - * - * Test Method (Validation or Falsification): - * - Validation: - * Initiate and destroy several CVs in random order. - * Asynchronously traverse the CV list and broadcast. - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Creates and then imediately destroys a CV. Does not - * test the CV. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - All initialised CVs destroyed without segfault. - * - Successfully broadcasts all remaining CVs after - * each CV is removed. - * - * Fail Criteria: - */ - -#include -#include "test.h" - -enum { - NUM_CV = 5, - NUM_LOOPS = 5 -}; - -static pthread_cond_t cv[NUM_CV]; - -int -main() -{ - int i, j, k; - void* result = (void*)-1; - pthread_t t; - - for (k = 0; k < NUM_LOOPS; k++) - { - for (i = 0; i < NUM_CV; i++) - { - assert(pthread_cond_init(&cv[i], NULL) == 0); - } - - j = NUM_CV; - (void) srand((unsigned)time(NULL)); - - /* Traverse the list asynchronously. */ - assert(pthread_create(&t, NULL, pthread_timechange_handler_np, NULL) == 0); - - do - { - i = (NUM_CV - 1) * rand() / RAND_MAX; - if (cv[i] != NULL) - { - j--; - assert(pthread_cond_destroy(&cv[i]) == 0); - } - } - while (j > 0); - - assert(pthread_join(t, &result) == 0); - assert ((int)(size_t)result == 0); - } - - return 0; -} diff --git a/deps/w32-pthreads/tests/condvar2.c b/deps/w32-pthreads/tests/condvar2.c deleted file mode 100644 index 159f777..0000000 --- a/deps/w32-pthreads/tests/condvar2.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * File: condvar2.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test timed wait on a CV. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Because the CV is never signaled, we expect the wait to time out. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - pthread_cond_timedwait returns ETIMEDOUT. - * - Process returns zero exit status. - * - * Fail Criteria: - * - pthread_cond_timedwait does not return ETIMEDOUT. - * - Process returns non-zero exit status. - */ - -#define _WIN32_WINNT 0x400 - -#include "test.h" -#include - -pthread_cond_t cv; -pthread_mutex_t mutex; - -#include "../implement.h" - -int -main() -{ - struct timespec abstime = { 0, 0 }; - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - assert(pthread_cond_init(&cv, NULL) == 0); - - assert(pthread_mutex_init(&mutex, NULL) == 0); - - assert(pthread_mutex_lock(&mutex) == 0); - - /* get current system time */ - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 1; - - assert(pthread_cond_timedwait(&cv, &mutex, &abstime) == ETIMEDOUT); - - assert(pthread_mutex_unlock(&mutex) == 0); - - { - int result = pthread_cond_destroy(&cv); - if (result != 0) - { - fprintf(stderr, "Result = %s\n", error_string[result]); - fprintf(stderr, "\tWaitersBlocked = %ld\n", cv->nWaitersBlocked); - fprintf(stderr, "\tWaitersGone = %ld\n", cv->nWaitersGone); - fprintf(stderr, "\tWaitersToUnblock = %ld\n", cv->nWaitersToUnblock); - fflush(stderr); - } - assert(result == 0); - } - - return 0; -} diff --git a/deps/w32-pthreads/tests/condvar2_1.c b/deps/w32-pthreads/tests/condvar2_1.c deleted file mode 100644 index 6b3fdd6..0000000 --- a/deps/w32-pthreads/tests/condvar2_1.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * File: condvar2_1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test timeout of multiple waits on a CV with no signal/broadcast. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Because the CV is never signaled, we expect the waits to time out. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - pthread_cond_timedwait returns ETIMEDOUT. - * - Process returns zero exit status. - * - * Fail Criteria: - * - pthread_cond_timedwait does not return ETIMEDOUT. - * - Process returns non-zero exit status. - */ - -#define _WIN32_WINNT 0x400 - -#include "test.h" -#include - -static pthread_cond_t cv; -static pthread_mutex_t mutex; -static struct timespec abstime = { 0, 0 }; - -enum { - NUMTHREADS = 30 -}; - -void * -mythread(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - - assert(pthread_cond_timedwait(&cv, &mutex, &abstime) == ETIMEDOUT); - - assert(pthread_mutex_unlock(&mutex) == 0); - - return arg; -} - -#include "../implement.h" - -int -main() -{ - int i; - pthread_t t[NUMTHREADS + 1]; - void* result = (void*)0; - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - assert(pthread_cond_init(&cv, NULL) == 0); - - assert(pthread_mutex_init(&mutex, NULL) == 0); - - /* get current system time */ - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 5; - - assert(pthread_mutex_lock(&mutex) == 0); - - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_create(&t[i], NULL, mythread, (void *)(size_t)i) == 0); - } - - assert(pthread_mutex_unlock(&mutex) == 0); - - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_join(t[i], &result) == 0); - assert((int)(size_t)result == i); - } - - { - int result = pthread_cond_destroy(&cv); - if (result != 0) - { - fprintf(stderr, "Result = %s\n", error_string[result]); - fprintf(stderr, "\tWaitersBlocked = %ld\n", cv->nWaitersBlocked); - fprintf(stderr, "\tWaitersGone = %ld\n", cv->nWaitersGone); - fprintf(stderr, "\tWaitersToUnblock = %ld\n", cv->nWaitersToUnblock); - fflush(stderr); - } - assert(result == 0); - } - - return 0; -} diff --git a/deps/w32-pthreads/tests/condvar3.c b/deps/w32-pthreads/tests/condvar3.c deleted file mode 100644 index fea8d21..0000000 --- a/deps/w32-pthreads/tests/condvar3.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * File: condvar3.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test basic function of a CV - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - The primary thread takes the lock before creating any threads. - * The secondary thread blocks on the lock allowing the primary - * thread to enter the cv wait state which releases the lock. - * The secondary thread then takes the lock and signals the waiting - * primary thread. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - pthread_cond_timedwait returns 0. - * - Process returns zero exit status. - * - * Fail Criteria: - * - pthread_cond_timedwait returns ETIMEDOUT. - * - Process returns non-zero exit status. - */ - -#include "test.h" -#include - -static pthread_cond_t cv; -static pthread_mutex_t mutex; -static int shared = 0; - -enum { - NUMTHREADS = 2 /* Including the primary thread. */ -}; - -void * -mythread(void * arg) -{ - int result = 0; - - assert(pthread_mutex_lock(&mutex) == 0); - shared++; - assert(pthread_mutex_unlock(&mutex) == 0); - - if ((result = pthread_cond_signal(&cv)) != 0) - { - printf("Error = %s\n", error_string[result]); - } - assert(result == 0); - - - return (void *) 0; -} - -int -main() -{ - pthread_t t[NUMTHREADS]; - struct timespec abstime = { 0, 0 }; - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - assert((t[0] = pthread_self()).p != NULL); - - assert(pthread_cond_init(&cv, NULL) == 0); - - assert(pthread_mutex_init(&mutex, NULL) == 0); - - assert(pthread_mutex_lock(&mutex) == 0); - - /* get current system time */ - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - assert(pthread_create(&t[1], NULL, mythread, (void *) 1) == 0); - - abstime.tv_sec += 5; - - while (! (shared > 0)) - assert(pthread_cond_timedwait(&cv, &mutex, &abstime) == 0); - - assert(shared > 0); - - assert(pthread_mutex_unlock(&mutex) == 0); - - assert(pthread_join(t[1], NULL) == 0); - - assert(pthread_cond_destroy(&cv) == 0); - - return 0; -} diff --git a/deps/w32-pthreads/tests/condvar3_1.c b/deps/w32-pthreads/tests/condvar3_1.c deleted file mode 100644 index f4cf9cc..0000000 --- a/deps/w32-pthreads/tests/condvar3_1.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * File: condvar3_1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test timeout of multiple waits on a CV with some signaled. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Because some CVs are never signaled, we expect their waits to time out. - * Some are signaled, the rest time out. Pthread_cond_destroy() will fail - * unless all are accounted for, either signaled or timedout. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - pthread_cond_timedwait returns ETIMEDOUT. - * - Process returns zero exit status. - * - * Fail Criteria: - * - pthread_cond_timedwait does not return ETIMEDOUT. - * - Process returns non-zero exit status. - */ - -#define _WIN32_WINNT 0x400 - -#include "test.h" -#include - -static pthread_cond_t cv; -static pthread_cond_t cv1; -static pthread_mutex_t mutex; -static pthread_mutex_t mutex1; -static struct timespec abstime = { 0, 0 }; -static int timedout = 0; -static int signaled = 0; -static int awoken = 0; -static int waiting = 0; - -enum { - NUMTHREADS = 30 -}; - -void * -mythread(void * arg) -{ - int result; - - assert(pthread_mutex_lock(&mutex1) == 0); - ++waiting; - assert(pthread_mutex_unlock(&mutex1) == 0); - assert(pthread_cond_signal(&cv1) == 0); - - assert(pthread_mutex_lock(&mutex) == 0); - result = pthread_cond_timedwait(&cv, &mutex, &abstime); - if (result == ETIMEDOUT) - { - timedout++; - } - else - { - awoken++; - } - assert(pthread_mutex_unlock(&mutex) == 0); - - return arg; -} - -#include "../implement.h" - -int -main() -{ - int i; - pthread_t t[NUMTHREADS + 1]; - void* result = (void*)0; - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - assert(pthread_cond_init(&cv, NULL) == 0); - assert(pthread_cond_init(&cv1, NULL) == 0); - - assert(pthread_mutex_init(&mutex, NULL) == 0); - assert(pthread_mutex_init(&mutex1, NULL) == 0); - - /* get current system time */ - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 5; - - assert(pthread_mutex_lock(&mutex1) == 0); - - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_create(&t[i], NULL, mythread, (void *)(size_t)i) == 0); - } - - do { - assert(pthread_cond_wait(&cv1,&mutex1) == 0); - } while ( NUMTHREADS > waiting ); - - assert(pthread_mutex_unlock(&mutex1) == 0); - - for (i = NUMTHREADS/3; i <= 2*NUMTHREADS/3; i++) - { -// assert(pthread_mutex_lock(&mutex) == 0); - assert(pthread_cond_signal(&cv) == 0); -// assert(pthread_mutex_unlock(&mutex) == 0); - - signaled++; - } - - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_join(t[i], &result) == 0); - assert((int)(size_t)result == i); - } - - fprintf(stderr, "awk = %d\n", awoken); - fprintf(stderr, "sig = %d\n", signaled); - fprintf(stderr, "tot = %d\n", timedout); - - assert(signaled == awoken); - assert(timedout == NUMTHREADS - signaled); - - assert(pthread_cond_destroy(&cv1) == 0); - - { - int result = pthread_cond_destroy(&cv); - if (result != 0) - { - fprintf(stderr, "Result = %s\n", error_string[result]); - fprintf(stderr, "\tWaitersBlocked = %ld\n", cv->nWaitersBlocked); - fprintf(stderr, "\tWaitersGone = %ld\n", cv->nWaitersGone); - fprintf(stderr, "\tWaitersToUnblock = %ld\n", cv->nWaitersToUnblock); - fflush(stderr); - } - assert(result == 0); - } - - assert(pthread_mutex_destroy(&mutex1) == 0); - assert(pthread_mutex_destroy(&mutex) == 0); - - return 0; -} diff --git a/deps/w32-pthreads/tests/condvar3_2.c b/deps/w32-pthreads/tests/condvar3_2.c deleted file mode 100644 index 4a90959..0000000 --- a/deps/w32-pthreads/tests/condvar3_2.c +++ /dev/null @@ -1,193 +0,0 @@ -/* - * File: condvar3_2.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test timeout of multiple waits on a CV with remainder broadcast awoken. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Because some CVs are never signaled, we expect their waits to time out. - * Some time out, the rest are broadcast signaled. Pthread_cond_destroy() will fail - * unless all are accounted for, either signaled or timedout. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - pthread_cond_timedwait returns ETIMEDOUT. - * - Process returns zero exit status. - * - * Fail Criteria: - * - pthread_cond_timedwait does not return ETIMEDOUT. - * - Process returns non-zero exit status. - */ - -#define _WIN32_WINNT 0x400 - -#include "test.h" -#include - -static pthread_cond_t cv; -static pthread_mutex_t mutex; -static struct timespec abstime = { 0, 0 }; -static struct timespec abstime2 = { 0, 0 }; -static int timedout = 0; -static int awoken = 0; - -enum { - NUMTHREADS = 30 -}; - -void * -mythread(void * arg) -{ - int result; - - assert(pthread_mutex_lock(&mutex) == 0); - - abstime2.tv_sec = abstime.tv_sec; - - if ((int) (size_t)arg % 3 == 0) - { - abstime2.tv_sec += 2; - } - - result = pthread_cond_timedwait(&cv, &mutex, &abstime2); - assert(pthread_mutex_unlock(&mutex) == 0); - if (result == ETIMEDOUT) - { - InterlockedIncrement((LPLONG)&timedout); - } - else - { - InterlockedIncrement((LPLONG)&awoken); - } - - - return arg; -} - -#include "../implement.h" - -int -main() -{ - int i; - pthread_t t[NUMTHREADS + 1]; - void* result = (void*)0; - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - assert(pthread_cond_init(&cv, NULL) == 0); - - assert(pthread_mutex_init(&mutex, NULL) == 0); - - /* get current system time */ - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = abstime2.tv_sec = (long)currSysTime.time + 5; - abstime.tv_nsec = abstime2.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - assert(pthread_mutex_lock(&mutex) == 0); - - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_create(&t[i], NULL, mythread, (void *)(size_t)i) == 0); - } - - assert(pthread_mutex_unlock(&mutex) == 0); - - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_join(t[i], &result) == 0); - assert((int)(size_t)result == i); - /* - * Approximately 2/3rds of the threads are expected to time out. - * Signal the remainder after some threads have woken up and exited - * and while some are still waking up after timeout. - * Also tests that redundant broadcasts don't return errors. - */ - -// assert(pthread_mutex_lock(&mutex) == 0); - - if (InterlockedExchangeAdd((LPLONG)&awoken, 0L) > NUMTHREADS/3) - { - assert(pthread_cond_broadcast(&cv) == 0); - } - -// assert(pthread_mutex_unlock(&mutex) == 0); - - } - - assert(awoken == NUMTHREADS - timedout); - - { - int result = pthread_cond_destroy(&cv); - if (result != 0) - { - fprintf(stderr, "Result = %s\n", error_string[result]); - fprintf(stderr, "\tWaitersBlocked = %ld\n", cv->nWaitersBlocked); - fprintf(stderr, "\tWaitersGone = %ld\n", cv->nWaitersGone); - fprintf(stderr, "\tWaitersToUnblock = %ld\n", cv->nWaitersToUnblock); - fflush(stderr); - } - assert(result == 0); - } - - assert(pthread_mutex_destroy(&mutex) == 0); - - return 0; -} diff --git a/deps/w32-pthreads/tests/condvar3_3.c b/deps/w32-pthreads/tests/condvar3_3.c deleted file mode 100644 index bc479a5..0000000 --- a/deps/w32-pthreads/tests/condvar3_3.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * File: condvar3_3.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test timeouts and lost signals on a CV. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - pthread_cond_timedwait returns ETIMEDOUT. - * - Process returns zero exit status. - * - * Fail Criteria: - * - pthread_cond_timedwait does not return ETIMEDOUT. - * - Process returns non-zero exit status. - */ - -/* Timur Aydin (taydin@snet.net) */ - -#include "test.h" - -#include - -pthread_cond_t cnd; -pthread_mutex_t mtx; - -int main() -{ - int rc; - - struct timespec abstime = { 0, 0 }; - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - assert(pthread_cond_init(&cnd, 0) == 0); - assert(pthread_mutex_init(&mtx, 0) == 0); - - /* get current system time */ - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - abstime.tv_sec += 1; - - /* Here pthread_cond_timedwait should time out after one second. */ - - assert(pthread_mutex_lock(&mtx) == 0); - - assert((rc = pthread_cond_timedwait(&cnd, &mtx, &abstime)) == ETIMEDOUT); - - assert(pthread_mutex_unlock(&mtx) == 0); - - /* Here, the condition variable is signaled, but there are no - threads waiting on it. The signal should be lost and - the next pthread_cond_timedwait should time out too. */ - -// assert(pthread_mutex_lock(&mtx) == 0); - - assert((rc = pthread_cond_signal(&cnd)) == 0); - -// assert(pthread_mutex_unlock(&mtx) == 0); - - assert(pthread_mutex_lock(&mtx) == 0); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - abstime.tv_sec += 1; - - assert((rc = pthread_cond_timedwait(&cnd, &mtx, &abstime)) == ETIMEDOUT); - - assert(pthread_mutex_unlock(&mtx) == 0); - - return 0; -} diff --git a/deps/w32-pthreads/tests/condvar4.c b/deps/w32-pthreads/tests/condvar4.c deleted file mode 100644 index 15a47e0..0000000 --- a/deps/w32-pthreads/tests/condvar4.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - * File: condvar4.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test PTHREAD_COND_INITIALIZER. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Test basic CV function but starting with a static initialised - * CV. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - pthread_cond_timedwait returns 0. - * - Process returns zero exit status. - * - * Fail Criteria: - * - pthread_cond_timedwait returns ETIMEDOUT. - * - Process returns non-zero exit status. - */ - -#include "test.h" -#include - -typedef struct cvthing_t_ cvthing_t; - -struct cvthing_t_ { - pthread_cond_t notbusy; - pthread_mutex_t lock; - int shared; -}; - -static cvthing_t cvthing = { - PTHREAD_COND_INITIALIZER, - PTHREAD_MUTEX_INITIALIZER, - 0 -}; - -enum { - NUMTHREADS = 2 -}; - -void * -mythread(void * arg) -{ - assert(pthread_mutex_lock(&cvthing.lock) == 0); - cvthing.shared++; - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - assert(pthread_cond_signal(&cvthing.notbusy) == 0); - - return (void *) 0; -} - -int -main() -{ - pthread_t t[NUMTHREADS]; - struct timespec abstime = { 0, 0 }; - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - cvthing.shared = 0; - - assert((t[0] = pthread_self()).p != NULL); - - assert(cvthing.notbusy == PTHREAD_COND_INITIALIZER); - - assert(cvthing.lock == PTHREAD_MUTEX_INITIALIZER); - - assert(pthread_mutex_lock(&cvthing.lock) == 0); - - assert(cvthing.lock != PTHREAD_MUTEX_INITIALIZER); - - /* get current system time */ - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 5; - - assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == ETIMEDOUT); - - assert(cvthing.notbusy != PTHREAD_COND_INITIALIZER); - - assert(pthread_create(&t[1], NULL, mythread, (void *) 1) == 0); - - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 5; - - while (! (cvthing.shared > 0)) - assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == 0); - - assert(cvthing.shared > 0); - - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - assert(pthread_join(t[1], NULL) == 0); - - assert(pthread_mutex_destroy(&cvthing.lock) == 0); - - assert(cvthing.lock == NULL); - - assert(pthread_cond_destroy(&cvthing.notbusy) == 0); - - assert(cvthing.notbusy == NULL); - - return 0; -} diff --git a/deps/w32-pthreads/tests/condvar5.c b/deps/w32-pthreads/tests/condvar5.c deleted file mode 100644 index e8d00e3..0000000 --- a/deps/w32-pthreads/tests/condvar5.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * File: condvar5.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test pthread_cond_broadcast. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Test broadcast with one waiting CV. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - pthread_cond_timedwait returns 0. - * - Process returns zero exit status. - * - * Fail Criteria: - * - pthread_cond_timedwait returns ETIMEDOUT. - * - Process returns non-zero exit status. - */ - -#include "test.h" -#include - -typedef struct cvthing_t_ cvthing_t; - -struct cvthing_t_ { - pthread_cond_t notbusy; - pthread_mutex_t lock; - int shared; -}; - -static cvthing_t cvthing = { - PTHREAD_COND_INITIALIZER, - PTHREAD_MUTEX_INITIALIZER, - 0 -}; - -enum { - NUMTHREADS = 2 -}; - -void * -mythread(void * arg) -{ - assert(pthread_mutex_lock(&cvthing.lock) == 0); - cvthing.shared++; - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - assert(pthread_cond_broadcast(&cvthing.notbusy) == 0); - - return (void *) 0; -} - -int -main() -{ - pthread_t t[NUMTHREADS]; - struct timespec abstime = { 0, 0 }; - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - cvthing.shared = 0; - - assert((t[0] = pthread_self()).p != NULL); - - assert(cvthing.notbusy == PTHREAD_COND_INITIALIZER); - - assert(cvthing.lock == PTHREAD_MUTEX_INITIALIZER); - - assert(pthread_mutex_lock(&cvthing.lock) == 0); - - assert(cvthing.lock != PTHREAD_MUTEX_INITIALIZER); - - /* get current system time */ - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 5; - - assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == ETIMEDOUT); - - assert(cvthing.notbusy != PTHREAD_COND_INITIALIZER); - - assert(pthread_create(&t[1], NULL, mythread, (void *) 1) == 0); - - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 5; - - while (! (cvthing.shared > 0)) - assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == 0); - - assert(cvthing.shared > 0); - - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - assert(pthread_join(t[1], NULL) == 0); - - assert(pthread_mutex_destroy(&cvthing.lock) == 0); - - assert(cvthing.lock == NULL); - - assert(pthread_cond_destroy(&cvthing.notbusy) == 0); - - assert(cvthing.notbusy == NULL); - - return 0; -} diff --git a/deps/w32-pthreads/tests/condvar6.c b/deps/w32-pthreads/tests/condvar6.c deleted file mode 100644 index fc0047b..0000000 --- a/deps/w32-pthreads/tests/condvar6.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * File: condvar6.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test pthread_cond_broadcast. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Test broadcast with NUMTHREADS (=5) waiting CVs. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" -#include - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 5 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -typedef struct cvthing_t_ cvthing_t; - -struct cvthing_t_ { - pthread_cond_t notbusy; - pthread_mutex_t lock; - int shared; -}; - -static cvthing_t cvthing = { - PTHREAD_COND_INITIALIZER, - PTHREAD_MUTEX_INITIALIZER, - 0 -}; - -static pthread_mutex_t start_flag = PTHREAD_MUTEX_INITIALIZER; - -static struct timespec abstime = { 0, 0 }; - -static int awoken; - -void * -mythread(void * arg) -{ - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - /* Wait for the start gun */ - assert(pthread_mutex_lock(&start_flag) == 0); - assert(pthread_mutex_unlock(&start_flag) == 0); - - assert(pthread_mutex_lock(&cvthing.lock) == 0); - - while (! (cvthing.shared > 0)) - assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == 0); - - assert(cvthing.shared > 0); - - awoken++; - - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - return (void *) 0; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - cvthing.shared = 0; - - assert((t[0] = pthread_self()).p != NULL); - - assert(cvthing.notbusy == PTHREAD_COND_INITIALIZER); - - assert(cvthing.lock == PTHREAD_MUTEX_INITIALIZER); - - assert(pthread_mutex_lock(&start_flag) == 0); - - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 5; - - assert((t[0] = pthread_self()).p != NULL); - - awoken = 0; - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - - assert(pthread_mutex_unlock(&start_flag) == 0); - - /* - * Give threads time to start. - */ - Sleep(1000); - - assert(pthread_mutex_lock(&cvthing.lock) == 0); - cvthing.shared++; - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - assert(pthread_cond_broadcast(&cvthing.notbusy) == 0); - - /* - * Give threads time to complete. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_join(t[i], NULL) == 0); - } - - /* - * Cleanup the CV. - */ - - assert(pthread_mutex_destroy(&cvthing.lock) == 0); - - assert(cvthing.lock == NULL); - - assert(pthread_cond_destroy(&cvthing.notbusy) == 0); - - assert(cvthing.notbusy == NULL); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - failed = !threadbag[i].started; - - if (failed) - { - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. - */ - - assert(awoken == NUMTHREADS); - - /* - * Success. - */ - return 0; -} - - diff --git a/deps/w32-pthreads/tests/condvar7.c b/deps/w32-pthreads/tests/condvar7.c deleted file mode 100644 index d42d1d0..0000000 --- a/deps/w32-pthreads/tests/condvar7.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - * File: condvar7.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test pthread_cond_broadcast with thread cancelation. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Test broadcast with NUMTHREADS (=5) waiting CVs, one is canceled while waiting. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" -#include - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 5 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -typedef struct cvthing_t_ cvthing_t; - -struct cvthing_t_ { - pthread_cond_t notbusy; - pthread_mutex_t lock; - int shared; -}; - -static cvthing_t cvthing = { - PTHREAD_COND_INITIALIZER, - PTHREAD_MUTEX_INITIALIZER, - 0 -}; - -static pthread_mutex_t start_flag = PTHREAD_MUTEX_INITIALIZER; - -static struct timespec abstime = { 0, 0 }; - -static int awoken; - -void * -mythread(void * arg) -{ - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - /* Wait for the start gun */ - assert(pthread_mutex_lock(&start_flag) == 0); - assert(pthread_mutex_unlock(&start_flag) == 0); - - assert(pthread_mutex_lock(&cvthing.lock) == 0); - -#ifdef _MSC_VER -#pragma inline_depth(0) -#endif - pthread_cleanup_push(pthread_mutex_unlock, (void *) &cvthing.lock); - - while (! (cvthing.shared > 0)) - assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == 0); - - pthread_cleanup_pop(0); -#ifdef _MSC_VER -#pragma inline_depth() -#endif - - assert(cvthing.shared > 0); - - awoken++; - - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - return (void *) 0; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - cvthing.shared = 0; - - assert((t[0] = pthread_self()).p != NULL); - - assert(cvthing.notbusy == PTHREAD_COND_INITIALIZER); - - assert(cvthing.lock == PTHREAD_MUTEX_INITIALIZER); - - assert(pthread_mutex_lock(&start_flag) == 0); - - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (time_t)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 10; - - assert((t[0] = pthread_self()).p != NULL); - - awoken = 0; - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - - assert(pthread_mutex_unlock(&start_flag) == 0); - - /* - * Give threads time to start. - */ - Sleep(1000); - - /* - * Cancel one of the threads. - */ - assert(pthread_cancel(t[1]) == 0); - assert(pthread_join(t[1], NULL) == 0); - - assert(pthread_mutex_lock(&cvthing.lock) == 0); - cvthing.shared++; - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - /* - * Signal all remaining waiting threads. - */ - assert(pthread_cond_broadcast(&cvthing.notbusy) == 0); - - /* - * Wait for all threads to complete. - */ - for (i = 2; i <= NUMTHREADS; i++) - assert(pthread_join(t[i], NULL) == 0); - - /* - * Cleanup the CV. - */ - - assert(pthread_mutex_destroy(&cvthing.lock) == 0); - - assert(cvthing.lock == NULL); - - assert(pthread_cond_destroy(&cvthing.notbusy) == 0); - - assert(cvthing.notbusy == NULL); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - failed = !threadbag[i].started; - - if (failed) - { - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. - */ - - assert(awoken == (NUMTHREADS - 1)); - - /* - * Success. - */ - return 0; -} diff --git a/deps/w32-pthreads/tests/condvar8.c b/deps/w32-pthreads/tests/condvar8.c deleted file mode 100644 index 3155c2d..0000000 --- a/deps/w32-pthreads/tests/condvar8.c +++ /dev/null @@ -1,258 +0,0 @@ -/* - * File: condvar8.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test multiple pthread_cond_broadcasts. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Make NUMTHREADS threads wait on CV, broadcast signal them, and then repeat. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" -#include - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 5 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -typedef struct cvthing_t_ cvthing_t; - -struct cvthing_t_ { - pthread_cond_t notbusy; - pthread_mutex_t lock; - int shared; -}; - -static cvthing_t cvthing = { - PTHREAD_COND_INITIALIZER, - PTHREAD_MUTEX_INITIALIZER, - 0 -}; - -static pthread_mutex_t start_flag = PTHREAD_MUTEX_INITIALIZER; - -static struct timespec abstime = { 0, 0 }; - -static int awoken; - -static void * -mythread(void * arg) -{ - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - /* Wait for the start gun */ - assert(pthread_mutex_lock(&start_flag) == 0); - assert(pthread_mutex_unlock(&start_flag) == 0); - - assert(pthread_mutex_lock(&cvthing.lock) == 0); - -#ifdef _MSC_VER -#pragma inline_depth(0) -#endif - pthread_cleanup_push(pthread_mutex_unlock, (void *) &cvthing.lock); - - while (! (cvthing.shared > 0)) - assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == 0); - - pthread_cleanup_pop(0); -#ifdef _MSC_VER -#pragma inline_depth() -#endif - - assert(cvthing.shared > 0); - - awoken++; - - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - return (void *) 0; -} - -int -main() -{ - int failed = 0; - int i; - int first, last; - pthread_t t[NUMTHREADS + 1]; - - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - assert((t[0] = pthread_self()).p != NULL); - - assert(cvthing.notbusy == PTHREAD_COND_INITIALIZER); - - assert(cvthing.lock == PTHREAD_MUTEX_INITIALIZER); - - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 10; - - assert((t[0] = pthread_self()).p != NULL); - - awoken = 0; - - for (first = 1, last = NUMTHREADS / 2; - first < NUMTHREADS; - first = last + 1, last = NUMTHREADS) - { - assert(pthread_mutex_lock(&start_flag) == 0); - - for (i = first; i <= last; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - cvthing.shared = 0; - - assert(pthread_mutex_unlock(&start_flag) == 0); - - /* - * Give threads time to start. - */ - Sleep(100); - - assert(pthread_mutex_lock(&cvthing.lock) == 0); - cvthing.shared++; - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - assert(pthread_cond_broadcast(&cvthing.notbusy) == 0); - - /* - * Give threads time to complete. - */ - for (i = first; i <= last; i++) - { - assert(pthread_join(t[i], NULL) == 0); - } - - assert(awoken == (i - 1)); - } - - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - failed = !threadbag[i].started; - - if (failed) - { - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - /* - * Cleanup the CV. - */ - - assert(pthread_mutex_destroy(&cvthing.lock) == 0); - - assert(cvthing.lock == NULL); - - assert(pthread_cond_destroy(&cvthing.notbusy) == 0); - - assert(cvthing.notbusy == NULL); - - assert(!failed); - - /* - * Check any results here. - */ - - assert(awoken == NUMTHREADS); - - /* - * Success. - */ - return 0; -} diff --git a/deps/w32-pthreads/tests/condvar9.c b/deps/w32-pthreads/tests/condvar9.c deleted file mode 100644 index 97286e6..0000000 --- a/deps/w32-pthreads/tests/condvar9.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - * File: condvar9.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test multiple pthread_cond_broadcasts with thread cancelation. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Make NUMTHREADS threads wait on CV, cancel one, broadcast signal them, - * and then repeat. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" -#include - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 9 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - int finished; - /* Add more per-thread state variables here */ -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -typedef struct cvthing_t_ cvthing_t; - -struct cvthing_t_ { - pthread_cond_t notbusy; - pthread_mutex_t lock; - int shared; -}; - -static cvthing_t cvthing = { - PTHREAD_COND_INITIALIZER, - PTHREAD_MUTEX_INITIALIZER, - 0 -}; - -static pthread_mutex_t start_flag = PTHREAD_MUTEX_INITIALIZER; - -static struct timespec abstime = { 0, 0 }; - -static int awoken; - -static void * -mythread(void * arg) -{ - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - /* Wait for the start gun */ - assert(pthread_mutex_lock(&start_flag) == 0); - assert(pthread_mutex_unlock(&start_flag) == 0); - - assert(pthread_mutex_lock(&cvthing.lock) == 0); - - /* - * pthread_cond_timedwait is a cancelation point and we're - * going to cancel some threads deliberately. - */ -#ifdef _MSC_VER -#pragma inline_depth(0) -#endif - pthread_cleanup_push(pthread_mutex_unlock, (void *) &cvthing.lock); - - while (! (cvthing.shared > 0)) - assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == 0); - - pthread_cleanup_pop(0); -#ifdef _MSC_VER -#pragma inline_depth() -#endif - - assert(cvthing.shared > 0); - - awoken++; - bag->finished = 1; - - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - return (void *) 0; -} - -int -main() -{ - int failed = 0; - int i; - int first, last; - int canceledThreads = 0; - pthread_t t[NUMTHREADS + 1]; - - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - assert((t[0] = pthread_self()).p != NULL); - - assert(cvthing.notbusy == PTHREAD_COND_INITIALIZER); - - assert(cvthing.lock == PTHREAD_MUTEX_INITIALIZER); - - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 5; - - assert((t[0] = pthread_self()).p != NULL); - - awoken = 0; - - for (first = 1, last = NUMTHREADS / 2; - first < NUMTHREADS; - first = last + 1, last = NUMTHREADS) - { - int ct; - - assert(pthread_mutex_lock(&start_flag) == 0); - - for (i = first; i <= last; i++) - { - threadbag[i].started = threadbag[i].finished = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - cvthing.shared = 0; - - assert(pthread_mutex_unlock(&start_flag) == 0); - - /* - * Give threads time to start. - */ - Sleep(1000); - - ct = (first + last) / 2; - assert(pthread_cancel(t[ct]) == 0); - canceledThreads++; - assert(pthread_join(t[ct], NULL) == 0); - - assert(pthread_mutex_lock(&cvthing.lock) == 0); - cvthing.shared++; - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - assert(pthread_cond_broadcast(&cvthing.notbusy) == 0); - - /* - * Standard check that all threads started - and wait for them to finish. - */ - for (i = first; i <= last; i++) - { - failed = !threadbag[i].started; - - if (failed) - { - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - else - { - assert(pthread_join(t[i], NULL) == 0 || threadbag[i].finished == 0); -// fprintf(stderr, "Thread %d: finished %d\n", i, threadbag[i].finished); - } - } - } - - /* - * Cleanup the CV. - */ - - assert(pthread_mutex_destroy(&cvthing.lock) == 0); - - assert(cvthing.lock == NULL); - - assert_e(pthread_cond_destroy(&cvthing.notbusy), ==, 0); - - assert(cvthing.notbusy == NULL); - - assert(!failed); - - /* - * Check any results here. - */ - - assert(awoken == NUMTHREADS - canceledThreads); - - /* - * Success. - */ - return 0; -} diff --git a/deps/w32-pthreads/tests/context1.c b/deps/w32-pthreads/tests/context1.c deleted file mode 100644 index 6f4daa9..0000000 --- a/deps/w32-pthreads/tests/context1.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * File: context1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Test context switching method. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - pthread_create - * pthread_exit - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#define _WIN32_WINNT 0x400 - -#include "test.h" -#include "../implement.h" -#include "../context.h" - -static int washere = 0; - -static void * func(void * arg) -{ - washere = 1; - - Sleep(1000); - - return 0; -} - -static void -anotherEnding () -{ - /* - * Switched context - */ - washere++; - - pthread_exit(0); -} - -int -main() -{ - pthread_t t; - HANDLE hThread; - - assert(pthread_create(&t, NULL, func, NULL) == 0); - - hThread = ((ptw32_thread_t *)t.p)->threadH; - - Sleep(500); - - SuspendThread(hThread); - - if (WaitForSingleObject(hThread, 0) == WAIT_TIMEOUT) - { - /* - * Ok, thread did not exit before we got to it. - */ - CONTEXT context; - - context.ContextFlags = CONTEXT_CONTROL; - - GetThreadContext(hThread, &context); - PTW32_PROGCTR (context) = (DWORD_PTR) anotherEnding; - SetThreadContext(hThread, &context); - ResumeThread(hThread); - } - else - { - printf("Exited early\n"); - fflush(stdout); - } - - Sleep(1000); - - assert(washere == 2); - - return 0; -} - diff --git a/deps/w32-pthreads/tests/count1.c b/deps/w32-pthreads/tests/count1.c deleted file mode 100644 index 16ecef1..0000000 --- a/deps/w32-pthreads/tests/count1.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * count1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Description: - * Test some basic assertions about the number of threads at runtime. - */ - -#include "test.h" - -#define NUMTHREADS (30) - -static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; -static pthread_t threads[NUMTHREADS]; -static unsigned numThreads = 0; - -void * -myfunc(void *arg) -{ - pthread_mutex_lock(&lock); - numThreads++; - pthread_mutex_unlock(&lock); - - Sleep(1000); - return 0; -} -int -main() -{ - int i; - int maxThreads = sizeof(threads) / sizeof(pthread_t); - - /* - * Spawn NUMTHREADS threads. Each thread should increment the - * numThreads variable, sleep for one second. - */ - for (i = 0; i < maxThreads; i++) - { - assert(pthread_create(&threads[i], NULL, myfunc, 0) == 0); - } - - /* - * Wait for all the threads to exit. - */ - for (i = 0; i < maxThreads; i++) - { - assert(pthread_join(threads[i], NULL) == 0); - } - - /* - * Check the number of threads created. - */ - assert((int) numThreads == maxThreads); - - /* - * Success. - */ - return 0; -} diff --git a/deps/w32-pthreads/tests/create1.c b/deps/w32-pthreads/tests/create1.c deleted file mode 100644 index bf7a1cb..0000000 --- a/deps/w32-pthreads/tests/create1.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * create1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Description: - * Create a thread and check that it ran. - * - * Depends on API functions: None. - */ - -#include "test.h" - -static int washere = 0; - -void * func(void * arg) -{ - washere = 1; - return 0; -} - -int -main() -{ - pthread_t t; - - assert(pthread_create(&t, NULL, func, NULL) == 0); - - /* A dirty hack, but we cannot rely on pthread_join in this - primitive test. */ - Sleep(2000); - - assert(washere == 1); - - return 0; -} diff --git a/deps/w32-pthreads/tests/create2.c b/deps/w32-pthreads/tests/create2.c deleted file mode 100644 index f3fd3c0..0000000 --- a/deps/w32-pthreads/tests/create2.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * File: create2.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test that threads have a Win32 handle when started. - * - * Test Method (Validation or Falsification): - * - Statistical, not absolute (depends on sample size). - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -enum { - NUMTHREADS = 10000 -}; - -static int washere = 0; - -void * func(void * arg) -{ - washere = 1; - return (void *) 0; -} - -int -main() -{ - pthread_t t; - pthread_attr_t attr; - void * result = NULL; - int i; - - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); - - for (i = 0; i < NUMTHREADS; i++) - { - washere = 0; - assert(pthread_create(&t, &attr, func, NULL) == 0); - assert(pthread_join(t, &result) == 0); - assert((int)(size_t)result == 0); - assert(washere == 1); - } - - return 0; -} diff --git a/deps/w32-pthreads/tests/create3.c b/deps/w32-pthreads/tests/create3.c deleted file mode 100644 index c8a4323..0000000 --- a/deps/w32-pthreads/tests/create3.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * File: create3.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test passing arg to thread function. - * - * Test Method (Validation or Falsification): - * - Statistical, not absolute (depends on sample size). - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -enum { - NUMTHREADS = 10000 -}; - -static int washere = 0; - -void * func(void * arg) -{ - washere = (int)(size_t)arg; - return (void *) 0; -} - -int -main() -{ - pthread_t t; - pthread_attr_t attr; - void * result = NULL; - int i; - - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); - - for (i = 0; i < NUMTHREADS; i++) - { - washere = 0; - assert(pthread_create(&t, &attr, func, (void *)(size_t)1) == 0); - assert(pthread_join(t, &result) == 0); - assert((int)(size_t)result == 0); - assert(washere == 1); - } - - return 0; -} diff --git a/deps/w32-pthreads/tests/delay1.c b/deps/w32-pthreads/tests/delay1.c deleted file mode 100644 index e8a7d5f..0000000 --- a/deps/w32-pthreads/tests/delay1.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * delay1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Depends on API functions: - * pthread_delay_np - */ - -#include "test.h" - -int -main(int argc, char * argv[]) -{ - struct timespec interval = {1L, 500000000L}; - - assert(pthread_delay_np(&interval) == 0); - - return 0; -} - diff --git a/deps/w32-pthreads/tests/delay2.c b/deps/w32-pthreads/tests/delay2.c deleted file mode 100644 index bc933f4..0000000 --- a/deps/w32-pthreads/tests/delay2.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * delay1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Depends on API functions: - * pthread_delay_np - */ - -#include "test.h" - -pthread_mutex_t mx = PTHREAD_MUTEX_INITIALIZER; - -void * -func(void * arg) -{ - struct timespec interval = {5, 500000000L}; - - assert(pthread_mutex_lock(&mx) == 0); - -#ifdef _MSC_VER -#pragma inline_depth(0) -#endif - pthread_cleanup_push(pthread_mutex_unlock, &mx); - assert(pthread_delay_np(&interval) == 0); - pthread_cleanup_pop(1); -#ifdef _MSC_VER -#pragma inline_depth() -#endif - - return (void *)(size_t)1; -} - -int -main(int argc, char * argv[]) -{ - pthread_t t; - void* result = (void*)0; - - assert(pthread_mutex_lock(&mx) == 0); - - assert(pthread_create(&t, NULL, func, NULL) == 0); - assert(pthread_cancel(t) == 0); - - assert(pthread_mutex_unlock(&mx) == 0); - - assert(pthread_join(t, &result) == 0); - assert(result == (void*)PTHREAD_CANCELED); - - return 0; -} - diff --git a/deps/w32-pthreads/tests/detach1.c b/deps/w32-pthreads/tests/detach1.c deleted file mode 100644 index 3f219fd..0000000 --- a/deps/w32-pthreads/tests/detach1.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Test for pthread_detach(). - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Depends on API functions: pthread_create(), pthread_detach(), pthread_exit(). - */ - -#include "test.h" - - -enum { - NUMTHREADS = 100 -}; - -void * -func(void * arg) -{ - int i = (int)(size_t)arg; - - Sleep(i * 10); - - pthread_exit(arg); - - /* Never reached. */ - exit(1); -} - -int -main(int argc, char * argv[]) -{ - pthread_t id[NUMTHREADS]; - int i; - - /* Create a few threads and then exit. */ - for (i = 0; i < NUMTHREADS; i++) - { - assert(pthread_create(&id[i], NULL, func, (void *)(size_t)i) == 0); - } - - /* Some threads will finish before they are detached, some after. */ - Sleep(NUMTHREADS/2 * 10 + 50); - - for (i = 0; i < NUMTHREADS; i++) - { - assert(pthread_detach(id[i]) == 0); - } - - Sleep(NUMTHREADS * 10 + 100); - - /* - * Check that all threads are now invalid. - * This relies on unique thread IDs - e.g. works with - * pthreads-w32 or Solaris, but may not work for Linux, BSD etc. - */ - for (i = 0; i < NUMTHREADS; i++) - { - assert(pthread_kill(id[i], 0) == ESRCH); - } - - /* Success. */ - return 0; -} diff --git a/deps/w32-pthreads/tests/equal1.c b/deps/w32-pthreads/tests/equal1.c deleted file mode 100644 index 3f5cad7..0000000 --- a/deps/w32-pthreads/tests/equal1.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Test for pthread_equal. - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Depends on functions: pthread_create(). - */ - -#include "test.h" - -void * func(void * arg) -{ - Sleep(2000); - return 0; -} - -int -main() -{ - pthread_t t1, t2; - - assert(pthread_create(&t1, NULL, func, (void *) 1) == 0); - - assert(pthread_create(&t2, NULL, func, (void *) 2) == 0); - - assert(pthread_equal(t1, t2) == 0); - - assert(pthread_equal(t1,t1) != 0); - - /* This is a hack. We don't want to rely on pthread_join - yet if we can help it. */ - Sleep(4000); - - /* Success. */ - return 0; -} diff --git a/deps/w32-pthreads/tests/errno1.c b/deps/w32-pthreads/tests/errno1.c deleted file mode 100644 index 53558bd..0000000 --- a/deps/w32-pthreads/tests/errno1.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * File: errno1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Test thread-safety of errno - * - - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 3 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -pthread_mutex_t stop_here = PTHREAD_MUTEX_INITIALIZER; - -void * -mythread(void * arg) -{ - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - errno = bag->threadnum; - - Sleep(1000); - - pthread_mutex_lock(&stop_here); - - assert(errno == bag->threadnum); - - pthread_mutex_unlock(&stop_here); - - Sleep(1000); - - return 0; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - pthread_mutex_lock(&stop_here); - errno = 0; - - assert((t[0] = pthread_self()).p != NULL); - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep(2000); - pthread_mutex_unlock(&stop_here); - - /* - * Give threads time to run. - */ - Sleep(NUMTHREADS * 1000); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - failed = !threadbag[i].started; - - if (failed) - { - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. Set "failed" and only print ouput on failure. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - /* ... */ - } - - assert(!failed); - - /* - * Success. - */ - return 0; -} diff --git a/deps/w32-pthreads/tests/exception1.c b/deps/w32-pthreads/tests/exception1.c deleted file mode 100644 index c0b0812..0000000 --- a/deps/w32-pthreads/tests/exception1.c +++ /dev/null @@ -1,263 +0,0 @@ -/* - * File: exception1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Test passing of exceptions back to the application. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel, pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#if defined(_MSC_VER) || defined(__cplusplus) - -#include "test.h" - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 4 -}; - -void * -exceptionedThread(void * arg) -{ - int dummy = 0; - void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1); - /* Set to async cancelable */ - - assert(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) == 0); - - assert(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0); - - Sleep(100); - -#if defined(_MSC_VER) && !defined(__cplusplus) - __try - { - int zero = (int) (size_t)arg; /* Passed in from arg to avoid compiler error */ - int one = 1; - /* - * The deliberate exception condition (zero divide) is - * in an "if" to avoid being optimised out. - */ - if (dummy == one/zero) - Sleep(0); - } - __except (EXCEPTION_EXECUTE_HANDLER) - { - /* Should get into here. */ - result = (void*)((int)(size_t)PTHREAD_CANCELED + 2); - } -#elif defined(__cplusplus) - try - { - /* - * I had a zero divide exception here but it - * wasn't being caught by the catch(...) - * below under Mingw32. That could be a problem. - */ - throw dummy; - } -#if defined(PtW32CatchAll) - PtW32CatchAll -#else - catch (...) -#endif - { - /* Should get into here. */ - result = (void*)((int)(size_t)PTHREAD_CANCELED + 2); - } -#endif - - return (void *) (size_t)result; -} - -void * -canceledThread(void * arg) -{ - void* result = (void*)((int)(size_t)PTHREAD_CANCELED + 1); - int count; - - /* Set to async cancelable */ - - assert(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) == 0); - - assert(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0); - -#if defined(_MSC_VER) && !defined(__cplusplus) - __try - { - /* - * We wait up to 10 seconds, waking every 0.1 seconds, - * for a cancelation to be applied to us. - */ - for (count = 0; count < 100; count++) - Sleep(100); - } - __except (EXCEPTION_EXECUTE_HANDLER) - { - /* Should NOT get into here. */ - result = (void*)((int)(size_t)PTHREAD_CANCELED + 2); - } -#elif defined(__cplusplus) - try - { - /* - * We wait up to 10 seconds, waking every 0.1 seconds, - * for a cancelation to be applied to us. - */ - for (count = 0; count < 100; count++) - Sleep(100); - } -#if defined(PtW32CatchAll) - PtW32CatchAll -#else - catch (...) -#endif - { - /* Should NOT get into here. */ - result = (void*)((int)(size_t)PTHREAD_CANCELED + 2); - } -#endif - - return (void *) (size_t)result; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t mt; - pthread_t et[NUMTHREADS]; - pthread_t ct[NUMTHREADS]; - - assert((mt = pthread_self()).p != NULL); - - for (i = 0; i < NUMTHREADS; i++) - { - assert(pthread_create(&et[i], NULL, exceptionedThread, (void *) 0) == 0); - assert(pthread_create(&ct[i], NULL, canceledThread, NULL) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep(1000); - - for (i = 0; i < NUMTHREADS; i++) - { - assert(pthread_cancel(ct[i]) == 0); - } - - /* - * Give threads time to run. - */ - Sleep(NUMTHREADS * 1000); - - /* - * Check any results here. Set "failed" and only print output on failure. - */ - failed = 0; - for (i = 0; i < NUMTHREADS; i++) - { - int fail = 0; - void* result = (void*)0; - - /* Canceled thread */ - assert(pthread_join(ct[i], &result) == 0); - assert(!(fail = (result != PTHREAD_CANCELED))); - - failed = (failed || fail); - - /* Exceptioned thread */ - assert(pthread_join(et[i], &result) == 0); - assert(!(fail = (result != (void*)((int)(size_t)PTHREAD_CANCELED + 2)))); - - failed = (failed || fail); - } - - assert(!failed); - - /* - * Success. - */ - return 0; -} - -#else /* defined(_MSC_VER) || defined(__cplusplus) */ - -#include - -int -main() -{ - fprintf(stderr, "Test N/A for this compiler environment.\n"); - return 0; -} - -#endif /* defined(_MSC_VER) || defined(__cplusplus) */ diff --git a/deps/w32-pthreads/tests/exception2.c b/deps/w32-pthreads/tests/exception2.c deleted file mode 100644 index 16eda12..0000000 --- a/deps/w32-pthreads/tests/exception2.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - * File: exception2.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Test passing of exceptions out of thread scope. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - - -#if defined(_MSC_VER) || defined(__cplusplus) - -#if defined(_MSC_VER) && defined(__cplusplus) -#include -#elif defined(__cplusplus) -#include -#endif - -#ifdef __GNUC__ -#include -#endif - -#include "test.h" - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 1 -}; - - -void * -exceptionedThread(void * arg) -{ - int dummy = 0x1; - -#if defined(_MSC_VER) && !defined(__cplusplus) - - RaiseException(dummy, 0, 0, NULL); - -#elif defined(__cplusplus) - - throw dummy; - -#endif - - return (void *) 100; -} - -int -main(int argc, char* argv[]) -{ - int i; - pthread_t mt; - pthread_t et[NUMTHREADS]; - - if (argc <= 1) - { - int result; - - printf("You should see an \"abnormal termination\" message\n"); - fflush(stdout); - result = system("exception2.exe die"); - exit(0); - } - - assert((mt = pthread_self()).p != NULL); - - for (i = 0; i < NUMTHREADS; i++) - { - assert(pthread_create(&et[i], NULL, exceptionedThread, NULL) == 0); - } - - Sleep(1000); - - /* - * Success. - */ - return 0; -} - -#else /* defined(_MSC_VER) || defined(__cplusplus) */ - -#include - -int -main() -{ - fprintf(stderr, "Test N/A for this compiler environment.\n"); - return 0; -} - -#endif /* defined(_MSC_VER) || defined(__cplusplus) */ diff --git a/deps/w32-pthreads/tests/exception3.c b/deps/w32-pthreads/tests/exception3.c deleted file mode 100644 index cb98393..0000000 --- a/deps/w32-pthreads/tests/exception3.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * File: exception3.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Test running of user supplied terminate() function. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -#if defined(__cplusplus) - -#if defined(_MSC_VER) -# include -#else -# if defined(__GNUC__) && __GNUC__ < 3 -# include -# else -# include - using std::set_terminate; -# endif -#endif - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 1 -}; - -int caught = 0; -pthread_mutex_t caughtLock; - -void -terminateFunction () -{ - assert(pthread_mutex_lock(&caughtLock) == 0); - caught++; -#if 0 - { - FILE * fp = fopen("pthread.log", "a"); - fprintf(fp, "Caught = %d\n", caught); - fclose(fp); - } -#endif - assert(pthread_mutex_unlock(&caughtLock) == 0); - - /* - * Notes from the MSVC++ manual: - * 1) A term_func() should call exit(), otherwise - * abort() will be called on return to the caller. - * abort() raises SIGABRT. The default signal handler - * for all signals terminates the calling program with - * exit code 3. - * 2) A term_func() must not throw an exception. Dev: Therefore - * term_func() should not call pthread_exit() if an - * exception-using version of pthreads-win32 library - * is being used (i.e. either pthreadVCE or pthreadVSE). - */ - exit(0); -} - -void * -exceptionedThread(void * arg) -{ - int dummy = 0x1; - - (void) set_terminate(&terminateFunction); - - throw dummy; - - return (void *) 0; -} - -int -main() -{ - int i; - pthread_t mt; - pthread_t et[NUMTHREADS]; - pthread_mutexattr_t ma; - - assert((mt = pthread_self()).p != NULL); - - printf("See the notes inside of exception3.c re term_funcs.\n"); - - assert(pthread_mutexattr_init(&ma) == 0); - assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_ERRORCHECK) == 0); - assert(pthread_mutex_init(&caughtLock, &ma) == 0); - assert(pthread_mutexattr_destroy(&ma) == 0); - - for (i = 0; i < NUMTHREADS; i++) - { - assert(pthread_create(&et[i], NULL, exceptionedThread, NULL) == 0); - } - - Sleep(NUMTHREADS * 100); - - assert(caught == NUMTHREADS); - - /* - * Success. - */ - return 0; -} - -#else /* defined(__cplusplus) */ - -#include - -int -main() -{ - fprintf(stderr, "Test N/A for this compiler environment.\n"); - return 0; -} - -#endif /* defined(__cplusplus) */ diff --git a/deps/w32-pthreads/tests/exit1.c b/deps/w32-pthreads/tests/exit1.c deleted file mode 100644 index 8625e10..0000000 --- a/deps/w32-pthreads/tests/exit1.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Test for pthread_exit(). - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Depends on API functions: None. - */ - -#include "test.h" - -int -main(int argc, char * argv[]) -{ - /* A simple test first. */ - pthread_exit((void *) 0); - - /* Not reached */ - assert(0); - return 0; -} diff --git a/deps/w32-pthreads/tests/exit2.c b/deps/w32-pthreads/tests/exit2.c deleted file mode 100644 index 21a193c..0000000 --- a/deps/w32-pthreads/tests/exit2.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Test for pthread_exit(). - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Depends on API functions: - * pthread_create() - * pthread_exit() - */ - -#include "test.h" - -void * -func(void * arg) -{ - pthread_exit(arg); - - /* Never reached. */ - assert(0); - - return NULL; -} - -int -main(int argc, char * argv[]) -{ - pthread_t t; - - assert(pthread_create(&t, NULL, func, (void *) NULL) == 0); - - Sleep(100); - - return 0; -} diff --git a/deps/w32-pthreads/tests/exit3.c b/deps/w32-pthreads/tests/exit3.c deleted file mode 100644 index f7e3103..0000000 --- a/deps/w32-pthreads/tests/exit3.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Test for pthread_exit(). - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Depends on API functions: pthread_create(). - */ - -#include "test.h" - -void * -func(void * arg) -{ - pthread_exit(arg); - - /* Never reached. */ - assert(0); - - return NULL; -} - -int -main(int argc, char * argv[]) -{ - pthread_t id[4]; - int i; - - /* Create a few threads and then exit. */ - for (i = 0; i < 4; i++) - { - assert(pthread_create(&id[i], NULL, func, (void *)(size_t)i) == 0); - } - - Sleep(400); - - /* Success. */ - return 0; -} diff --git a/deps/w32-pthreads/tests/exit4.c b/deps/w32-pthreads/tests/exit4.c deleted file mode 100644 index d23c6f9..0000000 --- a/deps/w32-pthreads/tests/exit4.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - * File: exit4.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Test calling pthread_exit from a Win32 thread - * without having created an implicit POSIX handle for it. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" -#ifndef _UWIN -#include -#endif - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 4 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ - int count; -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -#if ! defined (__MINGW32__) || defined (__MSVCRT__) -unsigned __stdcall -#else -void -#endif -Win32thread(void * arg) -{ - int result = 1; - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - /* - * Doesn't return and doesn't create an implicit POSIX handle. - */ - pthread_exit((void *)(size_t)result); - - return 0; -} - -int -main() -{ - int failed = 0; - int i; - HANDLE h[NUMTHREADS + 1]; - unsigned thrAddr; /* Dummy variable to pass a valid location to _beginthreadex (Win98). */ - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; -#if ! defined (__MINGW32__) || defined (__MSVCRT__) - h[i] = (HANDLE) _beginthreadex(NULL, 0, Win32thread, (void *) &threadbag[i], 0, &thrAddr); -#else - h[i] = (HANDLE) _beginthread(Win32thread, 0, (void *) &threadbag[i]); -#endif - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep(500); - - /* - * Give threads time to run. - */ - Sleep(NUMTHREADS * 100); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - if (!threadbag[i].started) - { - failed |= !threadbag[i].started; - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. Set "failed" and only print output on failure. - */ - failed = 0; - for (i = 1; i <= NUMTHREADS; i++) - { - int fail = 0; - int result = 0; - -#if ! defined (__MINGW32__) || defined (__MSVCRT__) - assert(GetExitCodeThread(h[i], (LPDWORD) &result) == TRUE); -#else - /* - * Can't get a result code. - */ - result = 1; -#endif - - fail = (result != 1); - - if (fail) - { - fprintf(stderr, "Thread %d: started %d: count %d\n", - i, - threadbag[i].started, - threadbag[i].count); - } - failed = (failed || fail); - } - - assert(!failed); - - /* - * Success. - */ - return 0; -} - diff --git a/deps/w32-pthreads/tests/exit5.c b/deps/w32-pthreads/tests/exit5.c deleted file mode 100644 index 6cb3f27..0000000 --- a/deps/w32-pthreads/tests/exit5.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - * File: exit5.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Test calling pthread_exit from a Win32 thread - * having created an implicit POSIX handle for it. - * - * Test Method (Validation or Falsification): - * - Validate return value and that POSIX handle is created and destroyed. - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" -#ifndef _UWIN -#include -#endif - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 4 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ - int count; - pthread_t self; -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -#if ! defined (__MINGW32__) || defined (__MSVCRT__) -unsigned __stdcall -#else -void -#endif -Win32thread(void * arg) -{ - int result = 1; - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - assert((bag->self = pthread_self()).p != NULL); - assert(pthread_kill(bag->self, 0) == 0); - - /* - * Doesn't return. - */ - pthread_exit((void *)(size_t)result); - - return 0; -} - -int -main() -{ - int failed = 0; - int i; - HANDLE h[NUMTHREADS + 1]; - unsigned thrAddr; /* Dummy variable to pass a valid location to _beginthreadex (Win98). */ - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; -#if ! defined (__MINGW32__) || defined (__MSVCRT__) - h[i] = (HANDLE) _beginthreadex(NULL, 0, Win32thread, (void *) &threadbag[i], 0, &thrAddr); -#else - h[i] = (HANDLE) _beginthread(Win32thread, 0, (void *) &threadbag[i]); -#endif - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep(500); - - /* - * Give threads time to run. - */ - Sleep(NUMTHREADS * 100); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - if (!threadbag[i].started) - { - failed |= !threadbag[i].started; - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. Set "failed" and only print output on failure. - */ - failed = 0; - for (i = 1; i <= NUMTHREADS; i++) - { - int fail = 0; - int result = 0; - -#if ! defined (__MINGW32__) || defined (__MSVCRT__) - assert(GetExitCodeThread(h[i], (LPDWORD) &result) == TRUE); -#else - /* - * Can't get a result code. - */ - result = 1; -#endif - - assert(threadbag[i].self.p != NULL && pthread_kill(threadbag[i].self, 0) == ESRCH); - - fail = (result != 1); - - if (fail) - { - fprintf(stderr, "Thread %d: started %d: count %d\n", - i, - threadbag[i].started, - threadbag[i].count); - } - failed = (failed || fail); - } - - assert(!failed); - - /* - * Success. - */ - return 0; -} - diff --git a/deps/w32-pthreads/tests/eyal1.c b/deps/w32-pthreads/tests/eyal1.c deleted file mode 100644 index b2f5881..0000000 --- a/deps/w32-pthreads/tests/eyal1.c +++ /dev/null @@ -1,367 +0,0 @@ -/* Simple POSIX threads program. - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Author: Eyal Lebedinsky eyal@eyal.emu.id.au - * Written: Sep 1998. - * Version Date: 12 Sep 1998 - * - * Do we need to lock stdout or is it thread safe? - * - * Used: - * pthread_t - * pthread_attr_t - * pthread_create() - * pthread_join() - * pthread_mutex_t - * PTHREAD_MUTEX_INITIALIZER - * pthread_mutex_init() [not used now] - * pthread_mutex_destroy() - * pthread_mutex_lock() - * pthread_mutex_trylock() - * pthread_mutex_unlock() - * - * What this program does is establish a work queue (implemented using - * four mutexes for each thread). It then schedules work (by storing - * a number in 'todo') and releases the threads. When the work is done - * the threads will block. The program then repeats the same thing once - * more (just to test the logic) and when the work is done it destroyes - * the threads. - * - * The 'work' we do is simply burning CPU cycles in a loop. - * The 'todo' work queue is trivial - each threads pops one element - * off it by incrementing it, the poped number is the 'work' to do. - * When 'todo' reaches the limit (nwork) the queue is considered - * empty. - * - * The number displayed at the end is the amount of work each thread - * did, so we can see if the load was properly distributed. - * - * The program was written to test a threading setup (not seen here) - * rather than to demonstrate correct usage of the pthread facilities. - * - * Note how each thread is given access to a thread control structure - * (TC) which is used for communicating to/from the main program (e.g. - * the threads knows its 'id' and also filles in the 'work' done). -*/ - -#include "test.h" - -#include -#include - -struct thread_control { - int id; - pthread_t thread; /* thread id */ - pthread_mutex_t mutex_start; - pthread_mutex_t mutex_started; - pthread_mutex_t mutex_end; - pthread_mutex_t mutex_ended; - long work; /* work done */ - int stat; /* pthread_init status */ -}; - -typedef struct thread_control TC; - -static TC *tcs = NULL; -static int nthreads = 10; -static int nwork = 100; -static int quiet = 0; - -static int todo = -1; - -static pthread_mutex_t mutex_todo = PTHREAD_MUTEX_INITIALIZER; -static pthread_mutex_t mutex_stdout = PTHREAD_MUTEX_INITIALIZER; - - -static void -die (int ret) -{ - if (NULL != tcs) - { - free (tcs); - tcs = NULL; - } - - if (ret) - exit (ret); -} - - -static double -waste_time (int n) -{ - int i; - double f, g, h, s; - - s = 0.0; - - /* - * Useless work. - */ - for (i = n*100; i > 0; --i) - { - f = rand (); - g = rand (); - h = rand (); - s += 2.0 * f * g / (h != 0.0 ? (h * h) : 1.0); - } - return s; -} - -static int -do_work_unit (int who, int n) -{ - int i; - static int nchars = 0; - double f = 0.0; - - if (quiet) - i = 0; - else { - /* - * get lock on stdout - */ - assert(pthread_mutex_lock (&mutex_stdout) == 0); - - /* - * do our job - */ - i = printf ("%c", "0123456789abcdefghijklmnopqrstuvwxyz"[who]); - - if (!(++nchars % 50)) - printf ("\n"); - - fflush (stdout); - - /* - * release lock on stdout - */ - assert(pthread_mutex_unlock (&mutex_stdout) == 0); - } - - n = rand () % 10000; /* ignore incoming 'n' */ - f = waste_time (n); - - /* This prevents the statement above from being optimised out */ - if (f > 0.0) - return(n); - - return (n); -} - -static int -print_server (void *ptr) -{ - int mywork; - int n; - TC *tc = (TC *)ptr; - - assert(pthread_mutex_lock (&tc->mutex_started) == 0); - - for (;;) - { - assert(pthread_mutex_lock (&tc->mutex_start) == 0); - assert(pthread_mutex_unlock (&tc->mutex_start) == 0); - assert(pthread_mutex_lock (&tc->mutex_ended) == 0); - assert(pthread_mutex_unlock (&tc->mutex_started) == 0); - - for (;;) - { - - /* - * get lock on todo list - */ - assert(pthread_mutex_lock (&mutex_todo) == 0); - - mywork = todo; - if (todo >= 0) - { - ++todo; - if (todo >= nwork) - todo = -1; - } - assert(pthread_mutex_unlock (&mutex_todo) == 0); - - if (mywork < 0) - break; - - assert((n = do_work_unit (tc->id, mywork)) >= 0); - tc->work += n; - } - - assert(pthread_mutex_lock (&tc->mutex_end) == 0); - assert(pthread_mutex_unlock (&tc->mutex_end) == 0); - assert(pthread_mutex_lock (&tc->mutex_started) == 0); - assert(pthread_mutex_unlock (&tc->mutex_ended) == 0); - - if (-2 == mywork) - break; - } - - assert(pthread_mutex_unlock (&tc->mutex_started) == 0); - - return (0); -} - -static void -dosync (void) -{ - int i; - - for (i = 0; i < nthreads; ++i) - { - assert(pthread_mutex_lock (&tcs[i].mutex_end) == 0); - assert(pthread_mutex_unlock (&tcs[i].mutex_start) == 0); - assert(pthread_mutex_lock (&tcs[i].mutex_started) == 0); - assert(pthread_mutex_unlock (&tcs[i].mutex_started) == 0); - } - - /* - * Now threads do their work - */ - for (i = 0; i < nthreads; ++i) - { - assert(pthread_mutex_lock (&tcs[i].mutex_start) == 0); - assert(pthread_mutex_unlock (&tcs[i].mutex_end) == 0); - assert(pthread_mutex_lock (&tcs[i].mutex_ended) == 0); - assert(pthread_mutex_unlock (&tcs[i].mutex_ended) == 0); - } -} - -static void -dowork (void) -{ - todo = 0; - dosync(); - - todo = 0; - dosync(); -} - -int -main (int argc, char *argv[]) -{ - int i; - - assert(NULL != (tcs = (TC *) calloc (nthreads, sizeof (*tcs)))); - - /* - * Launch threads - */ - for (i = 0; i < nthreads; ++i) - { - tcs[i].id = i; - - assert(pthread_mutex_init (&tcs[i].mutex_start, NULL) == 0); - assert(pthread_mutex_init (&tcs[i].mutex_started, NULL) == 0); - assert(pthread_mutex_init (&tcs[i].mutex_end, NULL) == 0); - assert(pthread_mutex_init (&tcs[i].mutex_ended, NULL) == 0); - - tcs[i].work = 0; - - assert(pthread_mutex_lock (&tcs[i].mutex_start) == 0); - assert((tcs[i].stat = - pthread_create (&tcs[i].thread, - NULL, - (void *(*)(void *))print_server, - (void *) &tcs[i]) - ) == 0); - - /* - * Wait for thread initialisation - */ - { - int trylock = 0; - - while (trylock == 0) - { - trylock = pthread_mutex_trylock(&tcs[i].mutex_started); - assert(trylock == 0 || trylock == EBUSY); - - if (trylock == 0) - { - assert(pthread_mutex_unlock (&tcs[i].mutex_started) == 0); - } - } - } - } - - dowork (); - - /* - * Terminate threads - */ - todo = -2; /* please terminate */ - dosync(); - - for (i = 0; i < nthreads; ++i) - { - if (0 == tcs[i].stat) - assert(pthread_join (tcs[i].thread, NULL) == 0); - } - - /* - * destroy locks - */ - assert(pthread_mutex_destroy (&mutex_stdout) == 0); - assert(pthread_mutex_destroy (&mutex_todo) == 0); - - /* - * Cleanup - */ - printf ("\n"); - - /* - * Show results - */ - for (i = 0; i < nthreads; ++i) - { - printf ("%2d ", i); - if (0 == tcs[i].stat) - printf ("%10ld\n", tcs[i].work); - else - printf ("failed %d\n", tcs[i].stat); - - assert(pthread_mutex_unlock(&tcs[i].mutex_start) == 0); - - assert(pthread_mutex_destroy (&tcs[i].mutex_start) == 0); - assert(pthread_mutex_destroy (&tcs[i].mutex_started) == 0); - assert(pthread_mutex_destroy (&tcs[i].mutex_end) == 0); - assert(pthread_mutex_destroy (&tcs[i].mutex_ended) == 0); - } - - die (0); - - return (0); -} diff --git a/deps/w32-pthreads/tests/inherit1.c b/deps/w32-pthreads/tests/inherit1.c deleted file mode 100644 index b7464eb..0000000 --- a/deps/w32-pthreads/tests/inherit1.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * File: inherit1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test thread priority inheritance. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -enum { - PTW32TEST_THREAD_INIT_PRIO = 0, - PTW32TEST_MAXPRIORITIES = 512 -}; - -int minPrio; -int maxPrio; -int validPriorities[PTW32TEST_MAXPRIORITIES]; - - -void * func(void * arg) -{ - int policy; - struct sched_param param; - - assert(pthread_getschedparam(pthread_self(), &policy, ¶m) == 0); - return (void *) (size_t)param.sched_priority; -} - - -void * -getValidPriorities(void * arg) -{ - int prioSet; - pthread_t thread = pthread_self(); - HANDLE threadH = pthread_getw32threadhandle_np(thread); - struct sched_param param; - - for (prioSet = minPrio; - prioSet <= maxPrio; - prioSet++) - { - /* - * If prioSet is invalid then the threads priority is unchanged - * from the previous value. Make the previous value a known - * one so that we can check later. - */ - param.sched_priority = prioSet; - assert(pthread_setschedparam(thread, SCHED_OTHER, ¶m) == 0); - validPriorities[prioSet+(PTW32TEST_MAXPRIORITIES/2)] = GetThreadPriority(threadH); - } - - return (void *) 0; -} - - -int -main() -{ - pthread_t t; - pthread_t mainThread = pthread_self(); - pthread_attr_t attr; - void * result = NULL; - struct sched_param param; - struct sched_param mainParam; - int prio; - int policy; - int inheritsched = -1; - pthread_t threadID = pthread_self(); - HANDLE threadH = pthread_getw32threadhandle_np(threadID); - - assert((maxPrio = sched_get_priority_max(SCHED_OTHER)) != -1); - assert((minPrio = sched_get_priority_min(SCHED_OTHER)) != -1); - - assert(pthread_create(&t, NULL, getValidPriorities, NULL) == 0); - assert(pthread_join(t, &result) == 0); - - assert(pthread_attr_init(&attr) == 0); - assert(pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED) == 0); - assert(pthread_attr_getinheritsched(&attr, &inheritsched) == 0); - assert(inheritsched == PTHREAD_INHERIT_SCHED); - - for (prio = minPrio; prio <= maxPrio; prio++) - { - mainParam.sched_priority = prio; - - /* Set the thread's priority to a known initial value. */ - SetThreadPriority(threadH, PTW32TEST_THREAD_INIT_PRIO); - - /* Change the main thread priority */ - assert(pthread_setschedparam(mainThread, SCHED_OTHER, &mainParam) == 0); - assert(pthread_getschedparam(mainThread, &policy, &mainParam) == 0); - assert(policy == SCHED_OTHER); - /* Priority returned below should be the level set by pthread_setschedparam(). */ - assert(mainParam.sched_priority == prio); - assert(GetThreadPriority(threadH) == - validPriorities[prio+(PTW32TEST_MAXPRIORITIES/2)]); - - for (param.sched_priority = prio; - param.sched_priority <= maxPrio; - param.sched_priority++) - { - /* The new thread create should ignore this new priority */ - assert(pthread_attr_setschedparam(&attr, ¶m) == 0); - assert(pthread_create(&t, &attr, func, NULL) == 0); - pthread_join(t, &result); - assert((int)(size_t) result == mainParam.sched_priority); - } - } - - return 0; -} diff --git a/deps/w32-pthreads/tests/join0.c b/deps/w32-pthreads/tests/join0.c deleted file mode 100644 index 044e56f..0000000 --- a/deps/w32-pthreads/tests/join0.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Test for pthread_join(). - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Depends on API functions: pthread_create(), pthread_exit(). - */ - -#include "test.h" - -void * -func(void * arg) -{ - Sleep(2000); - - pthread_exit(arg); - - /* Never reached. */ - exit(1); -} - -int -main(int argc, char * argv[]) -{ - pthread_t id; - void* result = (void*)0; - - /* Create a single thread and wait for it to exit. */ - assert(pthread_create(&id, NULL, func, (void *) 123) == 0); - - assert(pthread_join(id, &result) == 0); - - assert((int)(size_t)result == 123); - - /* Success. */ - return 0; -} diff --git a/deps/w32-pthreads/tests/join1.c b/deps/w32-pthreads/tests/join1.c deleted file mode 100644 index 68ad159..0000000 --- a/deps/w32-pthreads/tests/join1.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Test for pthread_join(). - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Depends on API functions: pthread_create(), pthread_join(), pthread_exit(). - */ - -#include "test.h" - -void * -func(void * arg) -{ - int i = (int)(size_t)arg; - - Sleep(i * 100); - - pthread_exit(arg); - - /* Never reached. */ - exit(1); -} - -int -main(int argc, char * argv[]) -{ - pthread_t id[4]; - int i; - void* result = (void*)-1; - - /* Create a few threads and then exit. */ - for (i = 0; i < 4; i++) - { - assert(pthread_create(&id[i], NULL, func, (void *)(size_t)i) == 0); - } - - /* Some threads will finish before they are joined, some after. */ - Sleep(2 * 100 + 50); - - for (i = 0; i < 4; i++) - { - assert(pthread_join(id[i], &result) == 0); - assert((int)(size_t)result == i); - } - - /* Success. */ - return 0; -} diff --git a/deps/w32-pthreads/tests/join2.c b/deps/w32-pthreads/tests/join2.c deleted file mode 100644 index 05fe37e..0000000 --- a/deps/w32-pthreads/tests/join2.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Test for pthread_join() returning return value from threads. - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Depends on API functions: pthread_create(). - */ - -#include "test.h" - -void * -func(void * arg) -{ - Sleep(1000); - return arg; -} - -int -main(int argc, char * argv[]) -{ - pthread_t id[4]; - int i; - void* result = (void*)-1; - - /* Create a few threads and then exit. */ - for (i = 0; i < 4; i++) - { - assert(pthread_create(&id[i], NULL, func, (void *)(size_t)i) == 0); - } - - for (i = 0; i < 4; i++) - { - assert(pthread_join(id[i], &result) == 0); - assert((int)(size_t)result == i); - } - - /* Success. */ - return 0; -} diff --git a/deps/w32-pthreads/tests/join3.c b/deps/w32-pthreads/tests/join3.c deleted file mode 100644 index 6e5426f..0000000 --- a/deps/w32-pthreads/tests/join3.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Test for pthread_join() returning return value from threads. - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Depends on API functions: pthread_create(). - */ - -#include "test.h" - -void * -func(void * arg) -{ - sched_yield(); - return arg; -} - -int -main(int argc, char * argv[]) -{ - pthread_t id[4]; - int i; - void* result = (void*)-1; - - /* Create a few threads and then exit. */ - for (i = 0; i < 4; i++) - { - assert(pthread_create(&id[i], NULL, func, (void *)(size_t)i) == 0); - } - - /* - * Let threads exit before we join them. - * We should still retrieve the exit code for the threads. - */ - Sleep(1000); - - for (i = 0; i < 4; i++) - { - assert(pthread_join(id[i], &result) == 0); - assert((int)(size_t)result == i); - } - - /* Success. */ - return 0; -} diff --git a/deps/w32-pthreads/tests/kill1.c b/deps/w32-pthreads/tests/kill1.c deleted file mode 100644 index ce34361..0000000 --- a/deps/w32-pthreads/tests/kill1.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * File: kill1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - pthread_kill() does not support non zero signals.. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - - -int -main() -{ - assert(pthread_kill(pthread_self(), 1) == EINVAL); - - return 0; -} diff --git a/deps/w32-pthreads/tests/loadfree.c b/deps/w32-pthreads/tests/loadfree.c deleted file mode 100644 index e278a02..0000000 --- a/deps/w32-pthreads/tests/loadfree.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * From: Todd Owen - * To: pthreads-win32@sourceware.cygnus.com - * Subject: invalid page fault when using LoadLibrary/FreeLibrary - * - * hi, - * for me, pthread.dll consistently causes an "invalid page fault in - * kernel32.dll" when I load it "explicitly"...to be precise, loading (with - * LoadLibrary) isn't a problem, it gives the error when I call FreeLibrary. - * I guess that the dll's cleanup must be causing the error. - * - * Implicit linkage of the dll has never given me this problem. Here's a - * program (console application) that gives me the error. - * - * I compile with: mingw32 (gcc-2.95 release), with the MSVCRT add-on (not - * that the compiler should make much difference in this case). - * PTHREAD.DLL: is the precompiled 1999-11-02 one (I tried an older one as - * well, with the same result). - * - * Fascinatingly, if you have your own dll (mycode.dll) which implicitly - * loads pthread.dll, and then do LoadLibrary/FreeLibrary on _this_ dll, the - * same thing happens. - * - */ - -#include "test.h" - -int main() { - HINSTANCE hinst; - - assert((hinst = LoadLibrary("pthread")) != (HINSTANCE) 0); - - Sleep(100); - - FreeLibrary(hinst); - return 0; -} - diff --git a/deps/w32-pthreads/tests/mutex1.c b/deps/w32-pthreads/tests/mutex1.c deleted file mode 100644 index a2c1e69..0000000 --- a/deps/w32-pthreads/tests/mutex1.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * mutex1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Create a simple mutex object, lock it, and then unlock it again. - * This is the simplest test of the pthread mutex family that we can do. - * - * Depends on API functions: - * pthread_mutex_init() - * pthread_mutex_lock() - * pthread_mutex_unlock() - * pthread_mutex_destroy() - */ - -#include "test.h" - -pthread_mutex_t mutex = NULL; - -int -main() -{ - assert(mutex == NULL); - - assert(pthread_mutex_init(&mutex, NULL) == 0); - - assert(mutex != NULL); - - assert(pthread_mutex_lock(&mutex) == 0); - - assert(pthread_mutex_unlock(&mutex) == 0); - - assert(pthread_mutex_destroy(&mutex) == 0); - - assert(mutex == NULL); - - return 0; -} diff --git a/deps/w32-pthreads/tests/mutex1e.c b/deps/w32-pthreads/tests/mutex1e.c deleted file mode 100644 index 11d2a06..0000000 --- a/deps/w32-pthreads/tests/mutex1e.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * mutex1e.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * As for mutex1.c but with type set to PTHREAD_MUTEX_ERRORCHECK. - * - * Create a simple mutex object, lock it, unlock it, then destroy it. - * This is the simplest test of the pthread mutex family that we can do. - * - * Depends on API functions: - * pthread_mutexattr_settype() - * pthread_mutex_init() - * pthread_mutex_destroy() - */ - -#include "test.h" - -pthread_mutex_t mutex = NULL; -pthread_mutexattr_t mxAttr; - -int -main() -{ - assert(pthread_mutexattr_init(&mxAttr) == 0); - - BEGIN_MUTEX_STALLED_ROBUST(mxAttr) - - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_ERRORCHECK) == 0); - - assert(mutex == NULL); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(mutex != NULL); - - assert(pthread_mutex_lock(&mutex) == 0); - - assert(pthread_mutex_unlock(&mutex) == 0); - - assert(pthread_mutex_destroy(&mutex) == 0); - - assert(mutex == NULL); - - END_MUTEX_STALLED_ROBUST(mxAttr) - - return 0; -} diff --git a/deps/w32-pthreads/tests/mutex1n.c b/deps/w32-pthreads/tests/mutex1n.c deleted file mode 100644 index a898744..0000000 --- a/deps/w32-pthreads/tests/mutex1n.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * mutex1n.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * As for mutex1.c but with type set to PTHREAD_MUTEX_NORMAL. - * - * Create a simple mutex object, lock it, unlock it, then destroy it. - * This is the simplest test of the pthread mutex family that we can do. - * - * Depends on API functions: - * pthread_mutexattr_settype() - * pthread_mutex_init() - * pthread_mutex_destroy() - */ - -#include "test.h" - -pthread_mutex_t mutex = NULL; -pthread_mutexattr_t mxAttr; - -int -main() -{ - assert(pthread_mutexattr_init(&mxAttr) == 0); - - BEGIN_MUTEX_STALLED_ROBUST(mxAttr) - - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_NORMAL) == 0); - - assert(mutex == NULL); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(mutex != NULL); - - assert(pthread_mutex_lock(&mutex) == 0); - - assert(pthread_mutex_unlock(&mutex) == 0); - - assert(pthread_mutex_destroy(&mutex) == 0); - - assert(mutex == NULL); - - END_MUTEX_STALLED_ROBUST(mxAttr) - - return 0; -} diff --git a/deps/w32-pthreads/tests/mutex1r.c b/deps/w32-pthreads/tests/mutex1r.c deleted file mode 100644 index 8087ab3..0000000 --- a/deps/w32-pthreads/tests/mutex1r.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * mutex1r.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * As for mutex1.c but with type set to PTHREAD_MUTEX_RECURSIVE. - * - * Create a simple mutex object, lock it, unlock it, then destroy it. - * This is the simplest test of the pthread mutex family that we can do. - * - * Depends on API functions: - * pthread_mutexattr_settype() - * pthread_mutex_init() - * pthread_mutex_destroy() - */ - -#include "test.h" - -pthread_mutex_t mutex = NULL; -pthread_mutexattr_t mxAttr; - -int -main() -{ - assert(pthread_mutexattr_init(&mxAttr) == 0); - - BEGIN_MUTEX_STALLED_ROBUST(mxAttr) - - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_RECURSIVE) == 0); - - assert(mutex == NULL); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(mutex != NULL); - - assert(pthread_mutex_lock(&mutex) == 0); - - assert(pthread_mutex_unlock(&mutex) == 0); - - assert(pthread_mutex_destroy(&mutex) == 0); - - assert(mutex == NULL); - - END_MUTEX_STALLED_ROBUST(mxAttr) - - return 0; -} diff --git a/deps/w32-pthreads/tests/mutex2.c b/deps/w32-pthreads/tests/mutex2.c deleted file mode 100644 index 0782100..0000000 --- a/deps/w32-pthreads/tests/mutex2.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * mutex2.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Declare a static mutex object, lock it, - * and then unlock it again. - * - * Depends on API functions: - * pthread_mutex_lock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - -int -main() -{ - assert(mutex == PTHREAD_MUTEX_INITIALIZER); - - assert(pthread_mutex_lock(&mutex) == 0); - - assert(mutex != PTHREAD_MUTEX_INITIALIZER); - - assert(mutex != NULL); - - assert(pthread_mutex_unlock(&mutex) == 0); - - assert(pthread_mutex_destroy(&mutex) == 0); - - assert(mutex == NULL); - - return 0; -} diff --git a/deps/w32-pthreads/tests/mutex2e.c b/deps/w32-pthreads/tests/mutex2e.c deleted file mode 100644 index a12f31c..0000000 --- a/deps/w32-pthreads/tests/mutex2e.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * mutex2e.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Declare a static mutex object, lock it, - * and then unlock it again. - * - * Depends on API functions: - * pthread_mutex_lock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -pthread_mutex_t mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER; - -int -main() -{ - assert(mutex == PTHREAD_ERRORCHECK_MUTEX_INITIALIZER); - - assert(pthread_mutex_lock(&mutex) == 0); - - assert(mutex != PTHREAD_ERRORCHECK_MUTEX_INITIALIZER); - - assert(mutex != NULL); - - assert(pthread_mutex_unlock(&mutex) == 0); - - assert(pthread_mutex_destroy(&mutex) == 0); - - assert(mutex == NULL); - - return 0; -} diff --git a/deps/w32-pthreads/tests/mutex2r.c b/deps/w32-pthreads/tests/mutex2r.c deleted file mode 100644 index a84152a..0000000 --- a/deps/w32-pthreads/tests/mutex2r.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * mutex2r.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Declare a static mutex object, lock it, - * and then unlock it again. - * - * Depends on API functions: - * pthread_mutex_lock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -pthread_mutex_t mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER; - -int -main() -{ - assert(mutex == PTHREAD_RECURSIVE_MUTEX_INITIALIZER); - - assert(pthread_mutex_lock(&mutex) == 0); - - assert(mutex != PTHREAD_RECURSIVE_MUTEX_INITIALIZER); - - assert(mutex != NULL); - - assert(pthread_mutex_unlock(&mutex) == 0); - - assert(pthread_mutex_destroy(&mutex) == 0); - - assert(mutex == NULL); - - return 0; -} diff --git a/deps/w32-pthreads/tests/mutex3.c b/deps/w32-pthreads/tests/mutex3.c deleted file mode 100644 index e6014b2..0000000 --- a/deps/w32-pthreads/tests/mutex3.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * mutex3.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Declare a static mutex object, lock it, trylock it, - * and then unlock it again. - * - * Depends on API functions: - * pthread_mutex_lock() - * pthread_mutex_trylock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; - -static int washere = 0; - -void * func(void * arg) -{ - assert(pthread_mutex_trylock(&mutex1) == EBUSY); - - washere = 1; - - return 0; -} - -int -main() -{ - pthread_t t; - - assert(pthread_mutex_lock(&mutex1) == 0); - - assert(pthread_create(&t, NULL, func, NULL) == 0); - assert(pthread_join(t, NULL) == 0); - - assert(pthread_mutex_unlock(&mutex1) == 0); - - assert(washere == 1); - - return 0; -} diff --git a/deps/w32-pthreads/tests/mutex3e.c b/deps/w32-pthreads/tests/mutex3e.c deleted file mode 100644 index 3eeaaa6..0000000 --- a/deps/w32-pthreads/tests/mutex3e.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * mutex3e.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Declare a static mutex object, lock it, trylock it, - * and then unlock it again. - * - * Depends on API functions: - * pthread_mutex_lock() - * pthread_mutex_trylock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -pthread_mutex_t mutex1 = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER; - -static int washere = 0; - -void * func(void * arg) -{ - assert(pthread_mutex_trylock(&mutex1) == EBUSY); - - washere = 1; - - return 0; -} - -int -main() -{ - pthread_t t; - - assert(pthread_mutex_lock(&mutex1) == 0); - - assert(pthread_create(&t, NULL, func, NULL) == 0); - assert(pthread_join(t, NULL) == 0); - - assert(pthread_mutex_unlock(&mutex1) == 0); - - assert(washere == 1); - - return 0; -} diff --git a/deps/w32-pthreads/tests/mutex3r.c b/deps/w32-pthreads/tests/mutex3r.c deleted file mode 100644 index 2364d71..0000000 --- a/deps/w32-pthreads/tests/mutex3r.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * mutex3r.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Declare a static mutex object, lock it, trylock it, - * and then unlock it again. - * - * Depends on API functions: - * pthread_mutex_lock() - * pthread_mutex_trylock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -pthread_mutex_t mutex1 = PTHREAD_RECURSIVE_MUTEX_INITIALIZER; - -static int washere = 0; - -void * func(void * arg) -{ - assert(pthread_mutex_trylock(&mutex1) == EBUSY); - - washere = 1; - - return 0; -} - -int -main() -{ - pthread_t t; - - assert(pthread_mutex_lock(&mutex1) == 0); - - assert(pthread_create(&t, NULL, func, NULL) == 0); - assert(pthread_join(t, NULL) == 0); - - assert(pthread_mutex_unlock(&mutex1) == 0); - - assert(washere == 1); - - return 0; -} diff --git a/deps/w32-pthreads/tests/mutex4.c b/deps/w32-pthreads/tests/mutex4.c deleted file mode 100644 index c324645..0000000 --- a/deps/w32-pthreads/tests/mutex4.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * mutex4.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Thread A locks mutex - thread B tries to unlock. - * - * Depends on API functions: - * pthread_mutex_lock() - * pthread_mutex_trylock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int wasHere = 0; - -static pthread_mutex_t mutex1; - -void * unlocker(void * arg) -{ - int expectedResult = (int)(size_t)arg; - - wasHere++; - assert(pthread_mutex_unlock(&mutex1) == expectedResult); - wasHere++; - return NULL; -} - -int -main() -{ - pthread_t t; - pthread_mutexattr_t ma; - - assert(pthread_mutexattr_init(&ma) == 0); - - BEGIN_MUTEX_STALLED_ROBUST(ma) - - wasHere = 0; - assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_DEFAULT) == 0); - assert(pthread_mutex_init(&mutex1, &ma) == 0); - assert(pthread_mutex_lock(&mutex1) == 0); - assert(pthread_create(&t, NULL, unlocker, (void *)(size_t)(IS_ROBUST?EPERM:0)) == 0); - assert(pthread_join(t, NULL) == 0); - assert(pthread_mutex_unlock(&mutex1) == 0); - assert(wasHere == 2); - - wasHere = 0; - assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_NORMAL) == 0); - assert(pthread_mutex_init(&mutex1, &ma) == 0); - assert(pthread_mutex_lock(&mutex1) == 0); - assert(pthread_create(&t, NULL, unlocker, (void *)(size_t)(IS_ROBUST?EPERM:0)) == 0); - assert(pthread_join(t, NULL) == 0); - assert(pthread_mutex_unlock(&mutex1) == 0); - assert(wasHere == 2); - - wasHere = 0; - assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_ERRORCHECK) == 0); - assert(pthread_mutex_init(&mutex1, &ma) == 0); - assert(pthread_mutex_lock(&mutex1) == 0); - assert(pthread_create(&t, NULL, unlocker, (void *)(size_t) EPERM) == 0); - assert(pthread_join(t, NULL) == 0); - assert(pthread_mutex_unlock(&mutex1) == 0); - assert(wasHere == 2); - - wasHere = 0; - assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_RECURSIVE) == 0); - assert(pthread_mutex_init(&mutex1, &ma) == 0); - assert(pthread_mutex_lock(&mutex1) == 0); - assert(pthread_create(&t, NULL, unlocker, (void *)(size_t) EPERM) == 0); - assert(pthread_join(t, NULL) == 0); - assert(pthread_mutex_unlock(&mutex1) == 0); - assert(wasHere == 2); - - END_MUTEX_STALLED_ROBUST(ma) - - return 0; -} diff --git a/deps/w32-pthreads/tests/mutex5.c b/deps/w32-pthreads/tests/mutex5.c deleted file mode 100644 index 741c6ac..0000000 --- a/deps/w32-pthreads/tests/mutex5.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * mutex5.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Confirm the equality/inequality of the various mutex types, - * and the default not-set value. - */ - -#include "test.h" - -static pthread_mutexattr_t mxAttr; - -/* Prevent optimiser from removing dead or obvious asserts. */ -int _optimiseFoil; -#define FOIL(x) (_optimiseFoil = x) - -int -main() -{ - int mxType = -1; - - assert(FOIL(PTHREAD_MUTEX_DEFAULT) == PTHREAD_MUTEX_NORMAL); - assert(FOIL(PTHREAD_MUTEX_DEFAULT) != PTHREAD_MUTEX_ERRORCHECK); - assert(FOIL(PTHREAD_MUTEX_DEFAULT) != PTHREAD_MUTEX_RECURSIVE); - assert(FOIL(PTHREAD_MUTEX_RECURSIVE) != PTHREAD_MUTEX_ERRORCHECK); - - assert(FOIL(PTHREAD_MUTEX_NORMAL) == PTHREAD_MUTEX_FAST_NP); - assert(FOIL(PTHREAD_MUTEX_RECURSIVE) == PTHREAD_MUTEX_RECURSIVE_NP); - assert(FOIL(PTHREAD_MUTEX_ERRORCHECK) == PTHREAD_MUTEX_ERRORCHECK_NP); - - assert(pthread_mutexattr_init(&mxAttr) == 0); - assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0); - assert(mxType == PTHREAD_MUTEX_NORMAL); - - return 0; -} diff --git a/deps/w32-pthreads/tests/mutex6.c b/deps/w32-pthreads/tests/mutex6.c deleted file mode 100644 index e181c22..0000000 --- a/deps/w32-pthreads/tests/mutex6.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * mutex6.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test the default (type not set) mutex type. - * Should be the same as PTHREAD_MUTEX_NORMAL. - * Thread locks mutex twice (recursive lock). - * Locking thread should deadlock on second attempt. - * - * Depends on API functions: - * pthread_mutex_lock() - * pthread_mutex_trylock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int lockCount = 0; - -static pthread_mutex_t mutex; - -void * locker(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - - /* Should wait here (deadlocked) */ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - - return 0; -} - -int -main() -{ - pthread_t t; - - assert(pthread_mutex_init(&mutex, NULL) == 0); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - Sleep(1000); - - assert(lockCount == 1); - - /* - * Should succeed even though we don't own the lock - * because FAST mutexes don't check ownership. - */ - assert(pthread_mutex_unlock(&mutex) == 0); - - Sleep (1000); - - assert(lockCount == 2); - - exit(0); - - /* Never reached */ - return 0; -} diff --git a/deps/w32-pthreads/tests/mutex6e.c b/deps/w32-pthreads/tests/mutex6e.c deleted file mode 100644 index aca99b6..0000000 --- a/deps/w32-pthreads/tests/mutex6e.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * mutex6e.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Tests PTHREAD_MUTEX_ERRORCHECK mutex type. - * Thread locks mutex twice (recursive lock). - * This should fail with an EDEADLK error. - * The second unlock attempt should fail with an EPERM error. - * - * Depends on API functions: - * pthread_create() - * pthread_join() - * pthread_mutexattr_init() - * pthread_mutexattr_destroy() - * pthread_mutexattr_settype() - * pthread_mutexattr_gettype() - * pthread_mutex_init() - * pthread_mutex_destroy() - * pthread_mutex_lock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int lockCount; - -static pthread_mutex_t mutex; -static pthread_mutexattr_t mxAttr; - -void * locker(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_lock(&mutex) == EDEADLK); - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - assert(pthread_mutex_unlock(&mutex) == EPERM); - - return (void *) 555; -} - -int -main() -{ - pthread_t t; - void* result = (void*)0; - int mxType = -1; - - assert(pthread_mutexattr_init(&mxAttr) == 0); - - BEGIN_MUTEX_STALLED_ROBUST(mxAttr) - - lockCount = 0; - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_ERRORCHECK) == 0); - assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0); - assert(mxType == PTHREAD_MUTEX_ERRORCHECK); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - assert(pthread_join(t, &result) == 0); - assert((int)(size_t)result == 555); - - assert(lockCount == 2); - - assert(pthread_mutex_destroy(&mutex) == 0); - - END_MUTEX_STALLED_ROBUST(mxAttr) - - assert(pthread_mutexattr_destroy(&mxAttr) == 0); - - exit(0); - - /* Never reached */ - return 0; -} - diff --git a/deps/w32-pthreads/tests/mutex6es.c b/deps/w32-pthreads/tests/mutex6es.c deleted file mode 100644 index a2d7d14..0000000 --- a/deps/w32-pthreads/tests/mutex6es.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * mutex6es.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Tests PTHREAD_MUTEX_ERRORCHECK static mutex type. - * Thread locks mutex twice (recursive lock). - * This should fail with an EDEADLK error. - * The second unlock attempt should fail with an EPERM error. - * - * Depends on API functions: - * pthread_create() - * pthread_join() - * pthread_mutexattr_init() - * pthread_mutexattr_destroy() - * pthread_mutexattr_settype() - * pthread_mutexattr_gettype() - * pthread_mutex_init() - * pthread_mutex_destroy() - * pthread_mutex_lock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int lockCount = 0; - -static pthread_mutex_t mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER; - -void * locker(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_lock(&mutex) == EDEADLK); - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - assert(pthread_mutex_unlock(&mutex) == EPERM); - - return (void *) 555; -} - -int -main() -{ - pthread_t t; - void* result = (void*)0; - - assert(mutex == PTHREAD_ERRORCHECK_MUTEX_INITIALIZER); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - assert(pthread_join(t, &result) == 0); - assert((int)(size_t)result == 555); - - assert(lockCount == 2); - - assert(pthread_mutex_destroy(&mutex) == 0); - - exit(0); - - /* Never reached */ - return 0; -} - diff --git a/deps/w32-pthreads/tests/mutex6n.c b/deps/w32-pthreads/tests/mutex6n.c deleted file mode 100644 index 2b3d6db..0000000 --- a/deps/w32-pthreads/tests/mutex6n.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * mutex6n.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Tests PTHREAD_MUTEX_NORMAL mutex type. - * Thread locks mutex twice (recursive lock). - * The thread should deadlock. - * - * Depends on API functions: - * pthread_create() - * pthread_mutexattr_init() - * pthread_mutexattr_settype() - * pthread_mutexattr_gettype() - * pthread_mutex_init() - * pthread_mutex_lock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int lockCount; - -static pthread_mutex_t mutex; -static pthread_mutexattr_t mxAttr; - -void * locker(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - - /* Should wait here (deadlocked) */ - assert(pthread_mutex_lock(&mutex) == 0); - - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - - return (void *) 555; -} - -int -main() -{ - pthread_t t; - int mxType = -1; - - assert(pthread_mutexattr_init(&mxAttr) == 0); - - BEGIN_MUTEX_STALLED_ROBUST(mxAttr) - - lockCount = 0; - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_NORMAL) == 0); - assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0); - assert(mxType == PTHREAD_MUTEX_NORMAL); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - Sleep(100); - - assert(lockCount == 1); - - assert(pthread_mutex_unlock(&mutex) == IS_ROBUST?EPERM:0); - - Sleep (100); - - assert(lockCount == IS_ROBUST?1:2); - - END_MUTEX_STALLED_ROBUST(mxAttr) - - exit(0); - - /* Never reached */ - return 0; -} - diff --git a/deps/w32-pthreads/tests/mutex6r.c b/deps/w32-pthreads/tests/mutex6r.c deleted file mode 100644 index c761cbc..0000000 --- a/deps/w32-pthreads/tests/mutex6r.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * mutex6r.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Tests PTHREAD_MUTEX_RECURSIVE mutex type. - * Thread locks mutex twice (recursive lock). - * Both locks and unlocks should succeed. - * - * Depends on API functions: - * pthread_create() - * pthread_join() - * pthread_mutexattr_init() - * pthread_mutexattr_destroy() - * pthread_mutexattr_settype() - * pthread_mutexattr_gettype() - * pthread_mutex_init() - * pthread_mutex_destroy() - * pthread_mutex_lock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int lockCount; - -static pthread_mutex_t mutex; -static pthread_mutexattr_t mxAttr; - -void * locker(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - assert(pthread_mutex_unlock(&mutex) == 0); - - return (void *) 555; -} - -int -main() -{ - pthread_t t; - void* result = (void*)0; - int mxType = -1; - - assert(pthread_mutexattr_init(&mxAttr) == 0); - - BEGIN_MUTEX_STALLED_ROBUST(mxAttr) - - lockCount = 0; - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_RECURSIVE) == 0); - assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0); - assert(mxType == PTHREAD_MUTEX_RECURSIVE); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - assert(pthread_join(t, &result) == 0); - assert((int)(size_t)result == 555); - - assert(lockCount == 2); - - assert(pthread_mutex_destroy(&mutex) == 0); - - END_MUTEX_STALLED_ROBUST(mxAttr) - - assert(pthread_mutexattr_destroy(&mxAttr) == 0); - - exit(0); - - /* Never reached */ - return 0; -} diff --git a/deps/w32-pthreads/tests/mutex6rs.c b/deps/w32-pthreads/tests/mutex6rs.c deleted file mode 100644 index 754ad4e..0000000 --- a/deps/w32-pthreads/tests/mutex6rs.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * mutex6rs.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Tests PTHREAD_MUTEX_RECURSIVE static mutex type. - * Thread locks mutex twice (recursive lock). - * Both locks and unlocks should succeed. - * - * Depends on API functions: - * pthread_create() - * pthread_join() - * pthread_mutexattr_init() - * pthread_mutexattr_destroy() - * pthread_mutexattr_settype() - * pthread_mutexattr_gettype() - * pthread_mutex_init() - * pthread_mutex_destroy() - * pthread_mutex_lock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int lockCount = 0; - -static pthread_mutex_t mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER; - -void * locker(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - assert(pthread_mutex_unlock(&mutex) == 0); - - return (void *) 555; -} - -int -main() -{ - pthread_t t; - void* result = (void*)0; - - assert(mutex == PTHREAD_RECURSIVE_MUTEX_INITIALIZER); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - assert(pthread_join(t, &result) == 0); - assert((int)(size_t)result == 555); - - assert(lockCount == 2); - - assert(pthread_mutex_destroy(&mutex) == 0); - - exit(0); - - /* Never reached */ - return 0; -} diff --git a/deps/w32-pthreads/tests/mutex6s.c b/deps/w32-pthreads/tests/mutex6s.c deleted file mode 100644 index 4f16a7b..0000000 --- a/deps/w32-pthreads/tests/mutex6s.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * mutex6s.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test the default (type not set) static mutex type. - * Should be the same as PTHREAD_MUTEX_NORMAL. - * Thread locks mutex twice (recursive lock). - * Locking thread should deadlock on second attempt. - * - * Depends on API functions: - * pthread_mutex_lock() - * pthread_mutex_trylock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int lockCount = 0; - -static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - -void * locker(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - - /* Should wait here (deadlocked) */ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - - return 0; -} - -int -main() -{ - pthread_t t; - - assert(mutex == PTHREAD_MUTEX_INITIALIZER); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - Sleep(1000); - - assert(lockCount == 1); - - /* - * Should succeed even though we don't own the lock - * because FAST mutexes don't check ownership. - */ - assert(pthread_mutex_unlock(&mutex) == 0); - - Sleep (1000); - - assert(lockCount == 2); - - exit(0); - - /* Never reached */ - return 0; -} diff --git a/deps/w32-pthreads/tests/mutex7.c b/deps/w32-pthreads/tests/mutex7.c deleted file mode 100644 index 0fd4b90..0000000 --- a/deps/w32-pthreads/tests/mutex7.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * mutex7.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test the default (type not set) mutex type. - * Should be the same as PTHREAD_MUTEX_NORMAL. - * Thread locks then trylocks mutex (attempted recursive lock). - * The thread should lock first time and EBUSY second time. - * - * Depends on API functions: - * pthread_mutex_lock() - * pthread_mutex_trylock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int lockCount = 0; - -static pthread_mutex_t mutex; - -void * locker(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_trylock(&mutex) == EBUSY); - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - assert(pthread_mutex_unlock(&mutex) == 0); - - return 0; -} - -int -main() -{ - pthread_t t; - - assert(pthread_mutex_init(&mutex, NULL) == 0); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - Sleep(1000); - - assert(lockCount == 2); - - exit(0); - - /* Never reached */ - return 0; -} diff --git a/deps/w32-pthreads/tests/mutex7e.c b/deps/w32-pthreads/tests/mutex7e.c deleted file mode 100644 index d27c4ca..0000000 --- a/deps/w32-pthreads/tests/mutex7e.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * mutex7e.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Tests PTHREAD_MUTEX_ERRORCHECK mutex type. - * Thread locks and then trylocks mutex (attempted recursive lock). - * Trylock should fail with an EBUSY error. - * The second unlock attempt should fail with an EPERM error. - * - * Depends on API functions: - * pthread_create() - * pthread_join() - * pthread_mutexattr_init() - * pthread_mutexattr_destroy() - * pthread_mutexattr_settype() - * pthread_mutexattr_gettype() - * pthread_mutex_init() - * pthread_mutex_destroy() - * pthread_mutex_lock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int lockCount; - -static pthread_mutex_t mutex; -static pthread_mutexattr_t mxAttr; - -void * locker(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_trylock(&mutex) == EBUSY); - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - - return (void *) 555; -} - -int -main() -{ - pthread_t t; - void* result = (void*)0; - int mxType = -1; - - assert(pthread_mutexattr_init(&mxAttr) == 0); - - BEGIN_MUTEX_STALLED_ROBUST(mxAttr) - - lockCount = 0; - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_ERRORCHECK) == 0); - assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0); - assert(mxType == PTHREAD_MUTEX_ERRORCHECK); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - assert(pthread_join(t, &result) == 0); - assert((int)(size_t)result == 555); - - assert(lockCount == 2); - - assert(pthread_mutex_destroy(&mutex) == 0); - - END_MUTEX_STALLED_ROBUST(mxAttr) - - assert(pthread_mutexattr_destroy(&mxAttr) == 0); - - exit(0); - - /* Never reached */ - return 0; -} - diff --git a/deps/w32-pthreads/tests/mutex7n.c b/deps/w32-pthreads/tests/mutex7n.c deleted file mode 100644 index 979e58d..0000000 --- a/deps/w32-pthreads/tests/mutex7n.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * mutex7n.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Tests PTHREAD_MUTEX_NORMAL mutex type. - * Thread locks then trylocks mutex (attempted recursive lock). - * The thread should lock first time and EBUSY second time. - * - * Depends on API functions: - * pthread_create() - * pthread_mutexattr_init() - * pthread_mutexattr_settype() - * pthread_mutexattr_gettype() - * pthread_mutex_init() - * pthread_mutex_lock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int lockCount; - -static pthread_mutex_t mutex; -static pthread_mutexattr_t mxAttr; - -void * locker(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_trylock(&mutex) == EBUSY); - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - - return (void *) 555; -} - -int -main() -{ - pthread_t t; - int mxType = -1; - - assert(pthread_mutexattr_init(&mxAttr) == 0); - - BEGIN_MUTEX_STALLED_ROBUST(mxAttr) - - lockCount = 0; - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_NORMAL) == 0); - assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0); - assert(mxType == PTHREAD_MUTEX_NORMAL); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - Sleep(100); - - assert(lockCount == 2); - - END_MUTEX_STALLED_ROBUST(mxAttr) - - assert(pthread_mutexattr_destroy(&mxAttr) == 0); - - exit(0); - - /* Never reached */ - return 0; -} - diff --git a/deps/w32-pthreads/tests/mutex7r.c b/deps/w32-pthreads/tests/mutex7r.c deleted file mode 100644 index f3adc52..0000000 --- a/deps/w32-pthreads/tests/mutex7r.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * mutex7r.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Tests PTHREAD_MUTEX_RECURSIVE mutex type. - * Thread locks mutex then trylocks mutex (recursive lock twice). - * Both locks and unlocks should succeed. - * - * Depends on API functions: - * pthread_create() - * pthread_join() - * pthread_mutexattr_init() - * pthread_mutexattr_destroy() - * pthread_mutexattr_settype() - * pthread_mutexattr_gettype() - * pthread_mutex_init() - * pthread_mutex_destroy() - * pthread_mutex_lock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int lockCount; - -static pthread_mutex_t mutex; -static pthread_mutexattr_t mxAttr; - -void * locker(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_trylock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - assert(pthread_mutex_unlock(&mutex) == 0); - - return (void *) 555; -} - -int -main() -{ - pthread_t t; - void* result = (void*)0; - int mxType = -1; - - assert(pthread_mutexattr_init(&mxAttr) == 0); - - BEGIN_MUTEX_STALLED_ROBUST(mxAttr) - - lockCount = 0; - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_RECURSIVE) == 0); - assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0); - assert(mxType == PTHREAD_MUTEX_RECURSIVE); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - assert(pthread_join(t, &result) == 0); - assert((int)(size_t)result == 555); - - assert(lockCount == 2); - - assert(pthread_mutex_destroy(&mutex) == 0); - - END_MUTEX_STALLED_ROBUST(mxAttr) - - assert(pthread_mutexattr_destroy(&mxAttr) == 0); - - exit(0); - - /* Never reached */ - return 0; -} diff --git a/deps/w32-pthreads/tests/mutex8.c b/deps/w32-pthreads/tests/mutex8.c deleted file mode 100644 index 8e25aaa..0000000 --- a/deps/w32-pthreads/tests/mutex8.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * mutex8.c - * - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright (C) 1998 Ben Elliston and Ross Johnson - * Copyright (C) 1999,2000,2001 Ross Johnson - * - * Contact Email: rpj@ise.canberra.edu.au - * - * 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.1 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; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test the default (type not set) mutex type exercising timedlock. - * Thread locks mutex, another thread timedlocks the mutex. - * Timed thread should timeout. - * - * Depends on API functions: - * pthread_mutex_lock() - * pthread_mutex_timedlock() - * pthread_mutex_unlock() - */ - -#include "test.h" -#include - -static int lockCount = 0; - -static pthread_mutex_t mutex; - -void * locker(void * arg) -{ - struct timespec abstime = { 0, 0 }; - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 1; - - assert(pthread_mutex_timedlock(&mutex, &abstime) == ETIMEDOUT); - - lockCount++; - - return 0; -} - -int -main() -{ - pthread_t t; - - assert(pthread_mutex_init(&mutex, NULL) == 0); - - assert(pthread_mutex_lock(&mutex) == 0); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - Sleep(2000); - - assert(lockCount == 1); - - assert(pthread_mutex_unlock(&mutex) == 0); - - return 0; -} diff --git a/deps/w32-pthreads/tests/mutex8e.c b/deps/w32-pthreads/tests/mutex8e.c deleted file mode 100644 index 936bd1b..0000000 --- a/deps/w32-pthreads/tests/mutex8e.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * mutex8e.c - * - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright (C) 1998 Ben Elliston and Ross Johnson - * Copyright (C) 1999,2000,2001 Ross Johnson - * - * Contact Email: rpj@ise.canberra.edu.au - * - * 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.1 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; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Tests PTHREAD_MUTEX_ERRORCHECK mutex type exercising timedlock. - * Thread locks mutex, another thread timedlocks the mutex. - * Timed thread should timeout. - * - * Depends on API functions: - * pthread_create() - * pthread_mutexattr_init() - * pthread_mutexattr_destroy() - * pthread_mutexattr_settype() - * pthread_mutexattr_gettype() - * pthread_mutex_init() - * pthread_mutex_destroy() - * pthread_mutex_lock() - * pthread_mutex_timedlock() - * pthread_mutex_unlock() - */ - -#include "test.h" -#include - -static int lockCount; - -static pthread_mutex_t mutex; -static pthread_mutexattr_t mxAttr; - -void * locker(void * arg) -{ - struct timespec abstime = { 0, 0 }; - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 1; - - assert(pthread_mutex_timedlock(&mutex, &abstime) == ETIMEDOUT); - - lockCount++; - - return 0; -} - -int -main() -{ - pthread_t t; - int mxType = -1; - - assert(pthread_mutexattr_init(&mxAttr) == 0); - - BEGIN_MUTEX_STALLED_ROBUST(mxAttr) - - lockCount = 0; - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_ERRORCHECK) == 0); - assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0); - assert(mxType == PTHREAD_MUTEX_ERRORCHECK); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(pthread_mutex_lock(&mutex) == 0); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - Sleep(2000); - - assert(lockCount == 1); - - assert(pthread_mutex_unlock(&mutex) == 0); - - END_MUTEX_STALLED_ROBUST(mxAttr) - - return 0; -} - diff --git a/deps/w32-pthreads/tests/mutex8n.c b/deps/w32-pthreads/tests/mutex8n.c deleted file mode 100644 index 42a3330..0000000 --- a/deps/w32-pthreads/tests/mutex8n.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * mutex8n.c - * - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright (C) 1998 Ben Elliston and Ross Johnson - * Copyright (C) 1999,2000,2001 Ross Johnson - * - * Contact Email: rpj@ise.canberra.edu.au - * - * 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.1 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; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Tests PTHREAD_MUTEX_NORMAL mutex type exercising timedlock. - * Thread locks mutex, another thread timedlocks the mutex. - * Timed thread should timeout. - * - * Depends on API functions: - * pthread_create() - * pthread_mutexattr_init() - * pthread_mutexattr_destroy() - * pthread_mutexattr_settype() - * pthread_mutexattr_gettype() - * pthread_mutex_init() - * pthread_mutex_destroy() - * pthread_mutex_lock() - * pthread_mutex_timedlock() - * pthread_mutex_unlock() - */ - -#include "test.h" -#include - -static int lockCount; - -static pthread_mutex_t mutex; -static pthread_mutexattr_t mxAttr; - -void * locker(void * arg) -{ - struct timespec abstime = { 0, 0 }; - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 1; - - assert(pthread_mutex_timedlock(&mutex, &abstime) == ETIMEDOUT); - - lockCount++; - - return 0; -} - -int -main() -{ - pthread_t t; - int mxType = -1; - - assert(pthread_mutexattr_init(&mxAttr) == 0); - - BEGIN_MUTEX_STALLED_ROBUST(mxAttr) - - lockCount = 0; - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_NORMAL) == 0); - assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0); - assert(mxType == PTHREAD_MUTEX_NORMAL); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(pthread_mutex_lock(&mutex) == 0); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - Sleep(2000); - - assert(lockCount == 1); - - assert(pthread_mutex_unlock(&mutex) == 0); - - END_MUTEX_STALLED_ROBUST(mxAttr) - - return 0; -} - diff --git a/deps/w32-pthreads/tests/mutex8r.c b/deps/w32-pthreads/tests/mutex8r.c deleted file mode 100644 index 3443edb..0000000 --- a/deps/w32-pthreads/tests/mutex8r.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * mutex8r.c - * - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright (C) 1998 Ben Elliston and Ross Johnson - * Copyright (C) 1999,2000,2001 Ross Johnson - * - * Contact Email: rpj@ise.canberra.edu.au - * - * 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.1 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; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Tests PTHREAD_MUTEX_RECURSIVE mutex type exercising timedlock. - * Thread locks mutex, another thread timedlocks the mutex. - * Timed thread should timeout. - * - * Depends on API functions: - * pthread_create() - * pthread_mutexattr_init() - * pthread_mutexattr_destroy() - * pthread_mutexattr_settype() - * pthread_mutexattr_gettype() - * pthread_mutex_init() - * pthread_mutex_destroy() - * pthread_mutex_lock() - * pthread_mutex_timedlock() - * pthread_mutex_unlock() - */ - -#include "test.h" -#include - -static int lockCount; - -static pthread_mutex_t mutex; -static pthread_mutexattr_t mxAttr; - -void * locker(void * arg) -{ - struct timespec abstime = { 0, 0 }; - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 1; - - assert(pthread_mutex_timedlock(&mutex, &abstime) == ETIMEDOUT); - - lockCount++; - - return 0; -} - -int -main() -{ - pthread_t t; - int mxType = -1; - - assert(pthread_mutexattr_init(&mxAttr) == 0); - - BEGIN_MUTEX_STALLED_ROBUST(mxAttr) - - lockCount = 0; - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_RECURSIVE) == 0); - assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0); - assert(mxType == PTHREAD_MUTEX_RECURSIVE); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(pthread_mutex_lock(&mutex) == 0); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - Sleep(2000); - - assert(lockCount == 1); - - assert(pthread_mutex_unlock(&mutex) == 0); - - END_MUTEX_STALLED_ROBUST(mxAttr) - - return 0; -} - diff --git a/deps/w32-pthreads/tests/once1.c b/deps/w32-pthreads/tests/once1.c deleted file mode 100644 index ac41367..0000000 --- a/deps/w32-pthreads/tests/once1.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * once1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Create a static pthread_once and test that it calls myfunc once. - * - * Depends on API functions: - * pthread_once() - * pthread_create() - */ - -#include "test.h" - -pthread_once_t once = PTHREAD_ONCE_INIT; - -static int washere = 0; - -void -myfunc(void) -{ - washere++; -} - -void * -mythread(void * arg) -{ - assert(pthread_once(&once, myfunc) == 0); - - return 0; -} - -int -main() -{ - pthread_t t1, t2; - - assert(pthread_create(&t1, NULL, mythread, NULL) == 0); - - assert(pthread_create(&t2, NULL, mythread, NULL) == 0); - - Sleep(2000); - - assert(washere == 1); - - return 0; -} diff --git a/deps/w32-pthreads/tests/once2.c b/deps/w32-pthreads/tests/once2.c deleted file mode 100644 index 2cce93e..0000000 --- a/deps/w32-pthreads/tests/once2.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * once2.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Create several static pthread_once objects and channel several threads - * through each. - * - * Depends on API functions: - * pthread_once() - * pthread_create() - */ - -#include "test.h" - -#define NUM_THREADS 100 /* Targeting each once control */ -#define NUM_ONCE 10 - -pthread_once_t o = PTHREAD_ONCE_INIT; -pthread_once_t once[NUM_ONCE]; - -typedef struct { - int i; - CRITICAL_SECTION cs; -} sharedInt_t; - -static sharedInt_t numOnce = {0, {0}}; -static sharedInt_t numThreads = {0, {0}}; - -void -myfunc(void) -{ - EnterCriticalSection(&numOnce.cs); - numOnce.i++; - LeaveCriticalSection(&numOnce.cs); - /* Simulate slow once routine so that following threads pile up behind it */ - Sleep(100); -} - -void * -mythread(void * arg) -{ - assert(pthread_once(&once[(int)(size_t)arg], myfunc) == 0); - EnterCriticalSection(&numThreads.cs); - numThreads.i++; - LeaveCriticalSection(&numThreads.cs); - return (void*)(size_t)0; -} - -int -main() -{ - pthread_t t[NUM_THREADS][NUM_ONCE]; - int i, j; - - InitializeCriticalSection(&numThreads.cs); - InitializeCriticalSection(&numOnce.cs); - - for (j = 0; j < NUM_ONCE; j++) - { - once[j] = o; - - for (i = 0; i < NUM_THREADS; i++) - { - /* GCC build: create was failing with EAGAIN after 790 threads */ - while (0 != pthread_create(&t[i][j], NULL, mythread, (void *)(size_t)j)) - sched_yield(); - } - } - - for (j = 0; j < NUM_ONCE; j++) - for (i = 0; i < NUM_THREADS; i++) - if (pthread_join(t[i][j], NULL) != 0) - printf("Join failed for [thread,once] = [%d,%d]\n", i, j); - - assert(numOnce.i == NUM_ONCE); - assert(numThreads.i == NUM_THREADS * NUM_ONCE); - - DeleteCriticalSection(&numOnce.cs); - DeleteCriticalSection(&numThreads.cs); - - return 0; -} diff --git a/deps/w32-pthreads/tests/once3.c b/deps/w32-pthreads/tests/once3.c deleted file mode 100644 index e34c17e..0000000 --- a/deps/w32-pthreads/tests/once3.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * once3.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Create several pthread_once objects and channel several threads - * through each. Make the init_routine cancelable and cancel them with - * waiters waiting. - * - * Depends on API functions: - * pthread_once() - * pthread_create() - * pthread_testcancel() - * pthread_cancel() - * pthread_once() - */ - -/* #define ASSERT_TRACE */ - -#include "test.h" - -#define NUM_THREADS 100 /* Targeting each once control */ -#define NUM_ONCE 10 - -static pthread_once_t o = PTHREAD_ONCE_INIT; -static pthread_once_t once[NUM_ONCE]; - -typedef struct { - int i; - CRITICAL_SECTION cs; -} sharedInt_t; - -static sharedInt_t numOnce = {0, {0}}; -static sharedInt_t numThreads = {0, {0}}; - -void -myfunc(void) -{ - EnterCriticalSection(&numOnce.cs); - numOnce.i++; - assert(numOnce.i > 0); - LeaveCriticalSection(&numOnce.cs); - /* Simulate slow once routine so that following threads pile up behind it */ - Sleep(10); - /* test for cancelation late so we're sure to have waiters. */ - pthread_testcancel(); -} - -void * -mythread(void * arg) -{ - /* - * Cancel every thread. These threads are deferred cancelable only, so - * only the thread performing the once routine (my_func) will see it (there are - * no other cancelation points here). The result will be that every thread - * eventually cancels only when it becomes the new 'once' thread. - */ - assert(pthread_cancel(pthread_self()) == 0); - assert(pthread_once(&once[(int)(size_t)arg], myfunc) == 0); - EnterCriticalSection(&numThreads.cs); - numThreads.i++; - LeaveCriticalSection(&numThreads.cs); - return (void*)(size_t)0; -} - -int -main() -{ - pthread_t t[NUM_THREADS][NUM_ONCE]; - int i, j; - - InitializeCriticalSection(&numThreads.cs); - InitializeCriticalSection(&numOnce.cs); - - for (j = 0; j < NUM_ONCE; j++) - { - once[j] = o; - - for (i = 0; i < NUM_THREADS; i++) - { - /* GCC build: create was failing with EAGAIN after 790 threads */ - while (0 != pthread_create(&t[i][j], NULL, mythread, (void *)(size_t)j)) - sched_yield(); - } - } - - for (j = 0; j < NUM_ONCE; j++) - for (i = 0; i < NUM_THREADS; i++) - if (pthread_join(t[i][j], NULL) != 0) - printf("Join failed for [thread,once] = [%d,%d]\n", i, j); - - /* - * All threads will cancel, none will return normally from - * pthread_once and so numThreads should never be incremented. However, - * numOnce should be incremented by every thread (NUM_THREADS*NUM_ONCE). - */ - assert(numOnce.i == NUM_ONCE * NUM_THREADS); - assert(numThreads.i == 0); - - DeleteCriticalSection(&numOnce.cs); - DeleteCriticalSection(&numThreads.cs); - - return 0; -} diff --git a/deps/w32-pthreads/tests/once4.c b/deps/w32-pthreads/tests/once4.c deleted file mode 100644 index 722f729..0000000 --- a/deps/w32-pthreads/tests/once4.c +++ /dev/null @@ -1,193 +0,0 @@ -/* - * once4.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Create several pthread_once objects and channel several threads - * through each. Make the init_routine cancelable and cancel them - * waiters waiting. Vary the priorities. - * - * Depends on API functions: - * pthread_once() - * pthread_create() - * pthread_testcancel() - * pthread_cancel() - * pthread_once() - */ - -#include "test.h" - -#define NUM_THREADS 100 /* Targeting each once control */ -#define NUM_ONCE 10 - -pthread_once_t o = PTHREAD_ONCE_INIT; -pthread_once_t once[NUM_ONCE]; - -typedef struct { - int i; - CRITICAL_SECTION cs; -} sharedInt_t; - -static sharedInt_t numOnce = {0, {0}}; -static sharedInt_t numThreads = {0, {0}}; - -typedef struct { - int threadnum; - int oncenum; - int myPrio; - HANDLE w32Thread; -} bag_t; - -static bag_t threadbag[NUM_THREADS][NUM_ONCE]; - -CRITICAL_SECTION print_lock; - -void -mycleanupfunc(void * arg) -{ - bag_t * bag = (bag_t *) arg; - EnterCriticalSection(&print_lock); - /* once thrd prio error */ - printf("%4d %4d %4d %4d\n", - bag->oncenum, - bag->threadnum, - bag->myPrio, - bag->myPrio - GetThreadPriority(bag->w32Thread)); - LeaveCriticalSection(&print_lock); -} - -void -myinitfunc(void) -{ - EnterCriticalSection(&numOnce.cs); - numOnce.i++; - LeaveCriticalSection(&numOnce.cs); - /* Simulate slow once routine so that following threads pile up behind it */ - Sleep(10); - /* test for cancelation late so we're sure to have waiters. */ - pthread_testcancel(); -} - -void * -mythread(void * arg) -{ - bag_t * bag = (bag_t *) arg; - struct sched_param param; - - /* - * Cancel every thread. These threads are deferred cancelable only, so - * only the thread performing the init_routine will see it (there are - * no other cancelation points here). The result will be that every thread - * eventually cancels only when it becomes the new initter. - */ - pthread_t self = pthread_self(); - bag->w32Thread = pthread_getw32threadhandle_np(self); - /* - * Set priority between -2 and 2 inclusive. - */ - bag->myPrio = (bag->threadnum % 5) - 2; - param.sched_priority = bag->myPrio; - pthread_setschedparam(self, SCHED_OTHER, ¶m); - - /* Trigger a cancellation at the next cancellation point in this thread */ - pthread_cancel(self); -#if 0 - pthread_cleanup_push(mycleanupfunc, arg); - assert(pthread_once(&once[bag->oncenum], myinitfunc) == 0); - pthread_cleanup_pop(1); -#else - assert(pthread_once(&once[bag->oncenum], myinitfunc) == 0); -#endif - EnterCriticalSection(&numThreads.cs); - numThreads.i++; - LeaveCriticalSection(&numThreads.cs); - return 0; -} - -int -main() -{ - pthread_t t[NUM_THREADS][NUM_ONCE]; - int i, j; - - InitializeCriticalSection(&print_lock); - InitializeCriticalSection(&numThreads.cs); - InitializeCriticalSection(&numOnce.cs); - -#if 0 - /* once thrd prio change */ - printf("once thrd prio error\n"); -#endif - - /* - * Set the priority class to realtime - otherwise normal - * Windows random priority boosting will obscure any problems. - */ - SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS); - /* Set main thread to lower prio than threads */ - SetThreadPriority(GetCurrentThread(), -2); - - for (j = 0; j < NUM_ONCE; j++) - { - once[j] = o; - - for (i = 0; i < NUM_THREADS; i++) - { - bag_t * bag = &threadbag[i][j]; - bag->threadnum = i; - bag->oncenum = j; - /* GCC build: create was failing with EAGAIN after 790 threads */ - while (0 != pthread_create(&t[i][j], NULL, mythread, (void *)bag)) - sched_yield(); - } - } - - for (j = 0; j < NUM_ONCE; j++) - for (i = 0; i < NUM_THREADS; i++) - if (pthread_join(t[i][j], NULL) != 0) - printf("Join failed for [thread,once] = [%d,%d]\n", i, j); - - /* - * All threads will cancel, none will return normally from - * pthread_once and so numThreads should never be incremented. However, - * numOnce should be incremented by every thread (NUM_THREADS*NUM_ONCE). - */ - assert(numOnce.i == NUM_ONCE * NUM_THREADS); - assert(numThreads.i == 0); - - DeleteCriticalSection(&numOnce.cs); - DeleteCriticalSection(&numThreads.cs); - DeleteCriticalSection(&print_lock); - - return 0; -} diff --git a/deps/w32-pthreads/tests/openmp1.c b/deps/w32-pthreads/tests/openmp1.c deleted file mode 100644 index ee36e75..0000000 --- a/deps/w32-pthreads/tests/openmp1.c +++ /dev/null @@ -1,140 +0,0 @@ -#include -#include -#ifdef _OPENMP -# include -#endif -#include - -enum { - Size = 10000 -}; - -const int ShouldSum = (Size-1)*Size/2; - -short Verbose = 1; - -short ThreadOK[3] = {0,0,0}; // Main, Thread1, Thread2 - -// Thread -void *_thread(void* Id) { - int i; - int x[Size]; - -#ifdef _OPENMP -# pragma omp parallel for -#endif - for ( i = 0; i < Size; i++ ) { -#ifdef _OPENMP - if (Verbose && i%1000==0) { - int tid = omp_get_thread_num(); -# pragma omp critical - printf("thread %d : tid %d handles %d\n",(int)Id,tid,i); - } -#endif - - x[i] = i; - } - - int Sum=0; - for ( i = 0; i < Size; i++ ) { - Sum += x[i]; - } - if (Verbose) { -#ifdef _OPENMP -# pragma omp critical -#endif - printf("Id %d : %s : %d(should be %d)\n",(int)Id, __FUNCTION__, Sum,ShouldSum); - } - if (Sum == ShouldSum) ThreadOK[(int)Id] = 1; - return NULL; -} - -// MainThread -void MainThread() { - int i; - -#ifdef _OPENMP -# pragma omp parallel for -#endif - for ( i = 0; i < 4; i++ ) { -#ifdef _OPENMP - int tid = omp_get_thread_num(); -# pragma omp critical - printf("Main : tid %d\n",tid); - _thread((void *)tid); -#endif - } - return; -} - -// Comment in/out for checking the effect of multiple threads. -#define SPAWN_THREADS - -// main -int main(int argc, char *argv[]) { - - if (argc>1) Verbose = 1; - -#ifdef _OPENMP - omp_set_nested(-1); - printf("%s%s%s\n", "Nested parallel blocks are ", omp_get_nested()?" ":"NOT ", "supported."); -#endif - - MainThread(); - -#ifdef SPAWN_THREADS - { - pthread_t a_thr; - pthread_t b_thr; - int status; - - printf("%s:%d - %s - a_thr:%p - b_thr:%p\n", - __FILE__,__LINE__,__FUNCTION__,a_thr.p,b_thr.p); - - status = pthread_create(&a_thr, NULL, _thread, (void*) 1 ); - if ( status != 0 ) { - printf("Failed to create thread 1\n"); - return (-1); - } - - status = pthread_create(&b_thr, NULL, _thread, (void*) 2 ); - if ( status != 0 ) { - printf("Failed to create thread 2\n"); - return (-1); - } - - status = pthread_join(a_thr, NULL); - if ( status != 0 ) { - printf("Failed to join thread 1\n"); - return (-1); - } - printf("Joined thread1\n"); - - status = pthread_join(b_thr, NULL); - if ( status != 0 ) { - printf("Failed to join thread 2\n"); - return (-1); - } - printf("Joined thread2\n"); - } -#endif // SPAWN_THREADS - - short OK = 0; - // Check that we have OpenMP before declaring things OK formally. -#ifdef _OPENMP - OK = 1; - { - short i; - for (i=0;i<3;i++) OK &= ThreadOK[i]; - } - if (OK) printf("OMP : All looks good\n"); - else printf("OMP : Error\n"); -#else - printf("OpenMP seems not enabled ...\n"); -#endif - - return OK?0:1; -} - -//g++ -fopenmp omp_test.c -o omp_test -lpthread - diff --git a/deps/w32-pthreads/tests/priority1.c b/deps/w32-pthreads/tests/priority1.c deleted file mode 100644 index 1bbf8a6..0000000 --- a/deps/w32-pthreads/tests/priority1.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * File: priority1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test thread priority explicit setting using thread attribute. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -enum { - PTW32TEST_THREAD_INIT_PRIO = 0, - PTW32TEST_MAXPRIORITIES = 512 -}; - -int minPrio; -int maxPrio; -int validPriorities[PTW32TEST_MAXPRIORITIES]; - -void * -func(void * arg) -{ - int policy; - struct sched_param param; - pthread_t threadID = pthread_self(); - - assert(pthread_getschedparam(threadID, &policy, ¶m) == 0); - assert(policy == SCHED_OTHER); - return (void *) (size_t)(param.sched_priority); -} - -void * -getValidPriorities(void * arg) -{ - int prioSet; - pthread_t threadID = pthread_self(); - HANDLE threadH = pthread_getw32threadhandle_np(threadID); - - printf("Using GetThreadPriority\n"); - printf("%10s %10s\n", "Set value", "Get value"); - - for (prioSet = minPrio; - prioSet <= maxPrio; - prioSet++) - { - /* - * If prioSet is invalid then the threads priority is unchanged - * from the previous value. Make the previous value a known - * one so that we can check later. - */ - if (prioSet < 0) - SetThreadPriority(threadH, THREAD_PRIORITY_LOWEST); - else - SetThreadPriority(threadH, THREAD_PRIORITY_HIGHEST); - SetThreadPriority(threadH, prioSet); - validPriorities[prioSet+(PTW32TEST_MAXPRIORITIES/2)] = GetThreadPriority(threadH); - printf("%10d %10d\n", prioSet, validPriorities[prioSet+(PTW32TEST_MAXPRIORITIES/2)]); - } - - return (void *) 0; -} - - -int -main() -{ - pthread_t t; - pthread_attr_t attr; - void * result = NULL; - struct sched_param param; - - assert((maxPrio = sched_get_priority_max(SCHED_OTHER)) != -1); - assert((minPrio = sched_get_priority_min(SCHED_OTHER)) != -1); - - assert(pthread_create(&t, NULL, getValidPriorities, NULL) == 0); - assert(pthread_join(t, &result) == 0); - - assert(pthread_attr_init(&attr) == 0); - assert(pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED) == 0); - - /* Set the thread's priority to a known initial value. */ - SetThreadPriority(pthread_getw32threadhandle_np(pthread_self()), - PTW32TEST_THREAD_INIT_PRIO); - - printf("Using pthread_getschedparam\n"); - printf("%10s %10s %10s\n", "Set value", "Get value", "Win priority"); - - for (param.sched_priority = minPrio; - param.sched_priority <= maxPrio; - param.sched_priority++) - { - int prio; - - assert(pthread_attr_setschedparam(&attr, ¶m) == 0); - assert(pthread_create(&t, &attr, func, (void *) &attr) == 0); - - assert((prio = GetThreadPriority(pthread_getw32threadhandle_np(t))) - == validPriorities[param.sched_priority+(PTW32TEST_MAXPRIORITIES/2)]); - - assert(pthread_join(t, &result) == 0); - - assert(param.sched_priority == (int)(size_t) result); - printf("%10d %10d %10d\n", param.sched_priority, (int)(size_t) result, prio); - } - - return 0; -} diff --git a/deps/w32-pthreads/tests/priority2.c b/deps/w32-pthreads/tests/priority2.c deleted file mode 100644 index d190202..0000000 --- a/deps/w32-pthreads/tests/priority2.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - * File: priority2.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test thread priority setting after creation. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -enum { - PTW32TEST_THREAD_INIT_PRIO = 0, - PTW32TEST_MAXPRIORITIES = 512 -}; - -int minPrio; -int maxPrio; -int validPriorities[PTW32TEST_MAXPRIORITIES]; -pthread_barrier_t startBarrier, endBarrier; - -void * func(void * arg) -{ - int policy; - int result; - struct sched_param param; - - result = pthread_barrier_wait(&startBarrier); - assert(result == 0 || result == PTHREAD_BARRIER_SERIAL_THREAD); - assert(pthread_getschedparam(pthread_self(), &policy, ¶m) == 0); - assert(policy == SCHED_OTHER); - result = pthread_barrier_wait(&endBarrier); - assert(result == 0 || result == PTHREAD_BARRIER_SERIAL_THREAD); - return (void *) (size_t)param.sched_priority; -} - - -void * -getValidPriorities(void * arg) -{ - int prioSet; - pthread_t thread = pthread_self(); - HANDLE threadH = pthread_getw32threadhandle_np(thread); - struct sched_param param; - - for (prioSet = minPrio; - prioSet <= maxPrio; - prioSet++) - { - /* - * If prioSet is invalid then the threads priority is unchanged - * from the previous value. Make the previous value a known - * one so that we can check later. - */ - param.sched_priority = prioSet; - assert(pthread_setschedparam(thread, SCHED_OTHER, ¶m) == 0); - validPriorities[prioSet+(PTW32TEST_MAXPRIORITIES/2)] = GetThreadPriority(threadH); - } - - return (void *) 0; -} - - -int -main() -{ - pthread_t t; - void * result = NULL; - int result2; - struct sched_param param; - - assert((maxPrio = sched_get_priority_max(SCHED_OTHER)) != -1); - assert((minPrio = sched_get_priority_min(SCHED_OTHER)) != -1); - - assert(pthread_create(&t, NULL, getValidPriorities, NULL) == 0); - assert(pthread_join(t, &result) == 0); - - assert(pthread_barrier_init(&startBarrier, NULL, 2) == 0); - assert(pthread_barrier_init(&endBarrier, NULL, 2) == 0); - - /* Set the thread's priority to a known initial value. - * If the new priority is invalid then the threads priority - * is unchanged from the previous value. - */ - SetThreadPriority(pthread_getw32threadhandle_np(pthread_self()), - PTW32TEST_THREAD_INIT_PRIO); - - for (param.sched_priority = minPrio; - param.sched_priority <= maxPrio; - param.sched_priority++) - { - assert(pthread_create(&t, NULL, func, NULL) == 0); - assert(pthread_setschedparam(t, SCHED_OTHER, ¶m) == 0); - result2 = pthread_barrier_wait(&startBarrier); - assert(result2 == 0 || result2 == PTHREAD_BARRIER_SERIAL_THREAD); - result2 = pthread_barrier_wait(&endBarrier); - assert(result2 == 0 || result2 == PTHREAD_BARRIER_SERIAL_THREAD); - assert(GetThreadPriority(pthread_getw32threadhandle_np(t)) == - validPriorities[param.sched_priority+(PTW32TEST_MAXPRIORITIES/2)]); - pthread_join(t, &result); - assert(param.sched_priority == (int)(size_t)result); - } - - return 0; -} diff --git a/deps/w32-pthreads/tests/reuse1.c b/deps/w32-pthreads/tests/reuse1.c deleted file mode 100644 index a467e77..0000000 --- a/deps/w32-pthreads/tests/reuse1.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * File: reuse1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Confirm that thread reuse works for joined threads. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -enum { - NUMTHREADS = 100 -}; - -static int washere = 0; - -void * func(void * arg) -{ - washere = 1; - return arg; -} - -int -main() -{ - pthread_t t, - last_t; - pthread_attr_t attr; - void * result = NULL; - int i; - - assert(pthread_attr_init(&attr) == 0);; - assert(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE) == 0); - - washere = 0; - assert(pthread_create(&t, &attr, func, NULL) == 0); - assert(pthread_join(t, &result) == 0);; - assert((int)(size_t)result == 0); - assert(washere == 1); - last_t = t; - - for (i = 1; i < NUMTHREADS; i++) - { - washere = 0; - assert(pthread_create(&t, &attr, func, (void *)(size_t)i) == 0); - pthread_join(t, &result); - assert((int)(size_t) result == i); - assert(washere == 1); - /* thread IDs should be unique */ - assert(!pthread_equal(t, last_t)); - /* thread struct pointers should be the same */ - assert(t.p == last_t.p); - /* thread handle reuse counter should be different by one */ - assert(t.x == last_t.x+1); - last_t = t; - } - - return 0; -} diff --git a/deps/w32-pthreads/tests/reuse2.c b/deps/w32-pthreads/tests/reuse2.c deleted file mode 100644 index 208e81d..0000000 --- a/deps/w32-pthreads/tests/reuse2.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * File: reuse2.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test that thread reuse works for detached threads. - * - Analyse thread struct reuse. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - This test is implementation specific - * because it uses knowledge of internals that should be - * opaque to an application. - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -/* - */ - -enum { - NUMTHREADS = 10000 -}; - - -static long done = 0; - -void * func(void * arg) -{ - sched_yield(); - - InterlockedIncrement(&done); - - return (void *) 0; -} - -int -main() -{ - pthread_t t[NUMTHREADS]; - pthread_attr_t attr; - int i; - unsigned int notUnique = 0, - totalHandles = 0, - reuseMax = 0, - reuseMin = NUMTHREADS; - - assert(pthread_attr_init(&attr) == 0); - assert(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) == 0); - - for (i = 0; i < NUMTHREADS; i++) - { - while(pthread_create(&t[i], &attr, func, NULL) != 0) - Sleep(1); - } - - while (NUMTHREADS > InterlockedExchangeAdd((LPLONG)&done, 0L)) - Sleep(100); - - Sleep(100); - - /* - * Analyse reuse by computing min and max number of times pthread_create() - * returned the same pthread_t value. - */ - for (i = 0; i < NUMTHREADS; i++) - { - if (t[i].p != NULL) - { - unsigned int j, thisMax; - - thisMax = t[i].x; - - for (j = i+1; j < NUMTHREADS; j++) - if (t[i].p == t[j].p) - { - if (t[i].x == t[j].x) - notUnique++; - if (thisMax < t[j].x) - thisMax = t[j].x; - t[j].p = NULL; - } - - if (reuseMin > thisMax) - reuseMin = thisMax; - - if (reuseMax < thisMax) - reuseMax = thisMax; - } - } - - for (i = 0; i < NUMTHREADS; i++) - if (t[i].p != NULL) - totalHandles++; - - /* - * pthread_t reuse counts start at 0, so we need to add 1 - * to the max and min values derived above. - */ - printf("For %d total threads:\n", NUMTHREADS); - printf("Non-unique IDs = %d\n", notUnique); - printf("Reuse maximum = %d\n", reuseMax + 1); - printf("Reuse minimum = %d\n", reuseMin + 1); - printf("Total handles = %d\n", totalHandles); - - return 0; -} diff --git a/deps/w32-pthreads/tests/robust1.c b/deps/w32-pthreads/tests/robust1.c deleted file mode 100644 index 04f0655..0000000 --- a/deps/w32-pthreads/tests/robust1.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * robust1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * For all robust mutex types. - * Thread A locks mutex - * Thread A terminates with no threads waiting on robust mutex - * Thread B acquires (inherits) mutex and unlocks - * Main attempts to lock mutex with unrecovered state. - * - * Depends on API functions: - * pthread_create() - * pthread_join() - * pthread_mutex_init() - * pthread_mutex_lock() - * pthread_mutex_unlock() - * pthread_mutex_destroy() - * pthread_mutexattr_init() - * pthread_mutexattr_setrobust() - * pthread_mutexattr_settype() - * pthread_mutexattr_destroy() - */ - -#include "test.h" - -static int lockCount; - -static pthread_mutex_t mutex; - -void * owner(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - - return 0; -} - -void * inheritor(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == EOWNERDEAD); - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - - return 0; -} - -int -main() -{ - pthread_t to, ti; - pthread_mutexattr_t ma; - - assert(pthread_mutexattr_init(&ma) == 0); - assert(pthread_mutexattr_setrobust(&ma, PTHREAD_MUTEX_ROBUST) == 0); - - /* Default (NORMAL) type */ - lockCount = 0; - assert(pthread_mutex_init(&mutex, &ma) == 0); - assert(pthread_create(&to, NULL, owner, NULL) == 0); - assert(pthread_join(to, NULL) == 0); - assert(pthread_create(&ti, NULL, inheritor, NULL) == 0); - assert(pthread_join(ti, NULL) == 0); - assert(lockCount == 2); - assert(pthread_mutex_lock(&mutex) == ENOTRECOVERABLE); - assert(pthread_mutex_unlock(&mutex) == EPERM); - assert(pthread_mutex_destroy(&mutex) == 0); - - /* NORMAL type */ - lockCount = 0; - assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_NORMAL) == 0); - assert(pthread_mutex_init(&mutex, &ma) == 0); - assert(pthread_create(&to, NULL, owner, NULL) == 0); - assert(pthread_join(to, NULL) == 0); - assert(pthread_create(&ti, NULL, inheritor, NULL) == 0); - assert(pthread_join(ti, NULL) == 0); - assert(lockCount == 2); - assert(pthread_mutex_lock(&mutex) == ENOTRECOVERABLE); - assert(pthread_mutex_unlock(&mutex) == EPERM); - assert(pthread_mutex_destroy(&mutex) == 0); - - /* ERRORCHECK type */ - lockCount = 0; - assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_ERRORCHECK) == 0); - assert(pthread_mutex_init(&mutex, &ma) == 0); - assert(pthread_create(&to, NULL, owner, NULL) == 0); - assert(pthread_join(to, NULL) == 0); - assert(pthread_create(&ti, NULL, inheritor, NULL) == 0); - assert(pthread_join(ti, NULL) == 0); - assert(lockCount == 2); - assert(pthread_mutex_lock(&mutex) == ENOTRECOVERABLE); - assert(pthread_mutex_unlock(&mutex) == EPERM); - assert(pthread_mutex_destroy(&mutex) == 0); - - /* RECURSIVE type */ - lockCount = 0; - assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_RECURSIVE) == 0); - assert(pthread_mutex_init(&mutex, &ma) == 0); - assert(pthread_create(&to, NULL, owner, NULL) == 0); - assert(pthread_join(to, NULL) == 0); - assert(pthread_create(&ti, NULL, inheritor, NULL) == 0); - assert(pthread_join(ti, NULL) == 0); - assert(lockCount == 2); - assert(pthread_mutex_lock(&mutex) == ENOTRECOVERABLE); - assert(pthread_mutex_unlock(&mutex) == EPERM); - assert(pthread_mutex_destroy(&mutex) == 0); - - assert(pthread_mutexattr_destroy(&ma) == 0); - - return 0; -} diff --git a/deps/w32-pthreads/tests/robust2.c b/deps/w32-pthreads/tests/robust2.c deleted file mode 100644 index c269842..0000000 --- a/deps/w32-pthreads/tests/robust2.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * robust2.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * For all robust mutex types. - * Thread A locks mutex - * Thread B blocks on mutex - * Thread A terminates with threads waiting on robust mutex - * Thread B awakes and inherits mutex and unlocks - * Main attempts to lock mutex with unrecovered state. - * - * Depends on API functions: - * pthread_create() - * pthread_join() - * pthread_mutex_init() - * pthread_mutex_lock() - * pthread_mutex_unlock() - * pthread_mutex_destroy() - * pthread_mutexattr_init() - * pthread_mutexattr_setrobust() - * pthread_mutexattr_settype() - * pthread_mutexattr_destroy() - */ - -#include "test.h" - -static int lockCount; - -static pthread_mutex_t mutex; - -void * owner(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - Sleep(200); - - return 0; -} - -void * inheritor(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == EOWNERDEAD); - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - - return 0; -} - -int -main() -{ - pthread_t to, ti; - pthread_mutexattr_t ma; - - assert(pthread_mutexattr_init(&ma) == 0); - assert(pthread_mutexattr_setrobust(&ma, PTHREAD_MUTEX_ROBUST) == 0); - - /* Default (NORMAL) type */ - lockCount = 0; - assert(pthread_mutex_init(&mutex, &ma) == 0); - assert(pthread_create(&to, NULL, owner, NULL) == 0); - Sleep(100); - assert(pthread_create(&ti, NULL, inheritor, NULL) == 0); - assert(pthread_join(to, NULL) == 0); - assert(pthread_join(ti, NULL) == 0); - assert(lockCount == 2); - assert(pthread_mutex_lock(&mutex) == ENOTRECOVERABLE); - assert(pthread_mutex_destroy(&mutex) == 0); - - /* NORMAL type */ - lockCount = 0; - assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_NORMAL) == 0); - assert(pthread_mutex_init(&mutex, &ma) == 0); - assert(pthread_create(&to, NULL, owner, NULL) == 0); - Sleep(100); - assert(pthread_create(&ti, NULL, inheritor, NULL) == 0); - assert(pthread_join(to, NULL) == 0); - assert(pthread_join(ti, NULL) == 0); - assert(lockCount == 2); - assert(pthread_mutex_lock(&mutex) == ENOTRECOVERABLE); - assert(pthread_mutex_destroy(&mutex) == 0); - - /* ERRORCHECK type */ - lockCount = 0; - assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_ERRORCHECK) == 0); - assert(pthread_mutex_init(&mutex, &ma) == 0); - assert(pthread_create(&to, NULL, owner, NULL) == 0); - Sleep(100); - assert(pthread_create(&ti, NULL, inheritor, NULL) == 0); - assert(pthread_join(to, NULL) == 0); - assert(pthread_join(ti, NULL) == 0); - assert(lockCount == 2); - assert(pthread_mutex_lock(&mutex) == ENOTRECOVERABLE); - assert(pthread_mutex_destroy(&mutex) == 0); - - /* RECURSIVE type */ - lockCount = 0; - assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_RECURSIVE) == 0); - assert(pthread_mutex_init(&mutex, &ma) == 0); - assert(pthread_create(&to, NULL, owner, NULL) == 0); - Sleep(100); - assert(pthread_create(&ti, NULL, inheritor, NULL) == 0); - assert(pthread_join(to, NULL) == 0); - assert(pthread_join(ti, NULL) == 0); - assert(lockCount == 2); - assert(pthread_mutex_lock(&mutex) == ENOTRECOVERABLE); - assert(pthread_mutex_destroy(&mutex) == 0); - - assert(pthread_mutexattr_destroy(&ma) == 0); - - return 0; -} diff --git a/deps/w32-pthreads/tests/robust3.c b/deps/w32-pthreads/tests/robust3.c deleted file mode 100644 index bff868b..0000000 --- a/deps/w32-pthreads/tests/robust3.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * robust3.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * For all robust mutex types. - * Thread A locks mutex - * Thread B blocks on mutex - * Thread A terminates with threads waiting on robust mutex - * Thread B awakes and inherits mutex, sets consistent and unlocks - * Main acquires mutex with recovered state. - * - * Depends on API functions: - * pthread_create() - * pthread_join() - * pthread_mutex_init() - * pthread_mutex_lock() - * pthread_mutex_unlock() - * pthread_mutex_consistent() - * pthread_mutex_destroy() - * pthread_mutexattr_init() - * pthread_mutexattr_setrobust() - * pthread_mutexattr_settype() - * pthread_mutexattr_destroy() - */ - -#include "test.h" - -static int lockCount; - -static pthread_mutex_t mutex; - -void * owner(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - Sleep(200); - - return 0; -} - -void * inheritor(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == EOWNERDEAD); - lockCount++; - assert(pthread_mutex_consistent(&mutex) == 0); - assert(pthread_mutex_unlock(&mutex) == 0); - - return 0; -} - -int -main() -{ - pthread_t to, ti; - pthread_mutexattr_t ma; - - assert(pthread_mutexattr_init(&ma) == 0); - assert(pthread_mutexattr_setrobust(&ma, PTHREAD_MUTEX_ROBUST) == 0); - - /* Default (NORMAL) type */ - lockCount = 0; - assert(pthread_mutex_init(&mutex, &ma) == 0); - assert(pthread_create(&to, NULL, owner, NULL) == 0); - Sleep(100); - assert(pthread_create(&ti, NULL, inheritor, NULL) == 0); - assert(pthread_join(to, NULL) == 0); - assert(pthread_join(ti, NULL) == 0); - assert(lockCount == 2); - assert(pthread_mutex_lock(&mutex) == 0); - assert(pthread_mutex_unlock(&mutex) == 0); - assert(pthread_mutex_destroy(&mutex) == 0); - - /* NORMAL type */ - lockCount = 0; - assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_NORMAL) == 0); - assert(pthread_mutex_init(&mutex, &ma) == 0); - assert(pthread_create(&to, NULL, owner, NULL) == 0); - Sleep(100); - assert(pthread_create(&ti, NULL, inheritor, NULL) == 0); - assert(pthread_join(to, NULL) == 0); - assert(pthread_join(ti, NULL) == 0); - assert(lockCount == 2); - assert(pthread_mutex_lock(&mutex) == 0); - assert(pthread_mutex_unlock(&mutex) == 0); - assert(pthread_mutex_destroy(&mutex) == 0); - - /* ERRORCHECK type */ - lockCount = 0; - assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_ERRORCHECK) == 0); - assert(pthread_mutex_init(&mutex, &ma) == 0); - assert(pthread_create(&to, NULL, owner, NULL) == 0); - Sleep(100); - assert(pthread_create(&ti, NULL, inheritor, NULL) == 0); - assert(pthread_join(to, NULL) == 0); - assert(pthread_join(ti, NULL) == 0); - assert(lockCount == 2); - assert(pthread_mutex_lock(&mutex) == 0); - assert(pthread_mutex_unlock(&mutex) == 0); - assert(pthread_mutex_destroy(&mutex) == 0); - - /* RECURSIVE type */ - lockCount = 0; - assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_RECURSIVE) == 0); - assert(pthread_mutex_init(&mutex, &ma) == 0); - assert(pthread_create(&to, NULL, owner, NULL) == 0); - Sleep(100); - assert(pthread_create(&ti, NULL, inheritor, NULL) == 0); - assert(pthread_join(to, NULL) == 0); - assert(pthread_join(ti, NULL) == 0); - assert(lockCount == 2); - assert(pthread_mutex_lock(&mutex) == 0); - assert(pthread_mutex_unlock(&mutex) == 0); - assert(pthread_mutex_destroy(&mutex) == 0); - - assert(pthread_mutexattr_destroy(&ma) == 0); - - return 0; -} diff --git a/deps/w32-pthreads/tests/robust4.c b/deps/w32-pthreads/tests/robust4.c deleted file mode 100644 index d284330..0000000 --- a/deps/w32-pthreads/tests/robust4.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - * robust4.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Thread A locks multiple robust mutexes - * Thread B blocks on same mutexes in different orderings - * Thread A terminates with thread waiting on mutexes - * Thread B awakes and inherits each mutex in turn, sets consistent and unlocks - * Main acquires mutexes with recovered state. - * - * Depends on API functions: - * pthread_create() - * pthread_join() - * pthread_mutex_init() - * pthread_mutex_lock() - * pthread_mutex_unlock() - * pthread_mutex_destroy() - * pthread_mutexattr_init() - * pthread_mutexattr_setrobust() - * pthread_mutexattr_settype() - * pthread_mutexattr_destroy() - */ - -#include "test.h" - -static int lockCount; - -static pthread_mutex_t mutex[3]; - -void * owner(void * arg) -{ - assert(pthread_mutex_lock(&mutex[0]) == 0); - lockCount++; - assert(pthread_mutex_lock(&mutex[1]) == 0); - lockCount++; - assert(pthread_mutex_lock(&mutex[2]) == 0); - lockCount++; - Sleep(200); - - return 0; -} - -void * inheritor(void * arg) -{ - int* o = (int*)arg; - - assert(pthread_mutex_lock(&mutex[o[0]]) == EOWNERDEAD); - lockCount++; - assert(pthread_mutex_lock(&mutex[o[1]]) == EOWNERDEAD); - lockCount++; - assert(pthread_mutex_lock(&mutex[o[2]]) == EOWNERDEAD); - lockCount++; - assert(pthread_mutex_consistent(&mutex[o[2]]) == 0); - assert(pthread_mutex_consistent(&mutex[o[1]]) == 0); - assert(pthread_mutex_consistent(&mutex[o[0]]) == 0); - assert(pthread_mutex_unlock(&mutex[o[2]]) == 0); - assert(pthread_mutex_unlock(&mutex[o[1]]) == 0); - assert(pthread_mutex_unlock(&mutex[o[0]]) == 0); - - return 0; -} - -int -main() -{ - pthread_t to, ti; - pthread_mutexattr_t ma; - int order[3]; - - assert(pthread_mutexattr_init(&ma) == 0); - assert(pthread_mutexattr_setrobust(&ma, PTHREAD_MUTEX_ROBUST) == 0); - - order[0]=0; - order[1]=1; - order[2]=2; - lockCount = 0; - assert(pthread_mutex_init(&mutex[0], &ma) == 0); - assert(pthread_mutex_init(&mutex[1], &ma) == 0); - assert(pthread_mutex_init(&mutex[2], &ma) == 0); - assert(pthread_create(&to, NULL, owner, NULL) == 0); - Sleep(100); - assert(pthread_create(&ti, NULL, inheritor, (void *)order) == 0); - assert(pthread_join(to, NULL) == 0); - assert(pthread_join(ti, NULL) == 0); - assert(lockCount == 6); - assert(pthread_mutex_lock(&mutex[0]) == 0); - assert(pthread_mutex_unlock(&mutex[0]) == 0); - assert(pthread_mutex_destroy(&mutex[0]) == 0); - assert(pthread_mutex_lock(&mutex[1]) == 0); - assert(pthread_mutex_unlock(&mutex[1]) == 0); - assert(pthread_mutex_destroy(&mutex[1]) == 0); - assert(pthread_mutex_lock(&mutex[2]) == 0); - assert(pthread_mutex_unlock(&mutex[2]) == 0); - assert(pthread_mutex_destroy(&mutex[2]) == 0); - - order[0]=1; - order[1]=0; - order[2]=2; - lockCount = 0; - assert(pthread_mutex_init(&mutex[0], &ma) == 0); - assert(pthread_mutex_init(&mutex[1], &ma) == 0); - assert(pthread_mutex_init(&mutex[2], &ma) == 0); - assert(pthread_create(&to, NULL, owner, NULL) == 0); - Sleep(100); - assert(pthread_create(&ti, NULL, inheritor, (void *)order) == 0); - assert(pthread_join(to, NULL) == 0); - assert(pthread_join(ti, NULL) == 0); - assert(lockCount == 6); - assert(pthread_mutex_lock(&mutex[0]) == 0); - assert(pthread_mutex_unlock(&mutex[0]) == 0); - assert(pthread_mutex_destroy(&mutex[0]) == 0); - assert(pthread_mutex_lock(&mutex[1]) == 0); - assert(pthread_mutex_unlock(&mutex[1]) == 0); - assert(pthread_mutex_destroy(&mutex[1]) == 0); - assert(pthread_mutex_lock(&mutex[2]) == 0); - assert(pthread_mutex_unlock(&mutex[2]) == 0); - assert(pthread_mutex_destroy(&mutex[2]) == 0); - - order[0]=0; - order[1]=2; - order[2]=1; - lockCount = 0; - assert(pthread_mutex_init(&mutex[0], &ma) == 0); - assert(pthread_mutex_init(&mutex[1], &ma) == 0); - assert(pthread_mutex_init(&mutex[2], &ma) == 0); - assert(pthread_create(&to, NULL, owner, NULL) == 0); - Sleep(100); - assert(pthread_create(&ti, NULL, inheritor, (void *)order) == 0); - assert(pthread_join(to, NULL) == 0); - assert(pthread_join(ti, NULL) == 0); - assert(lockCount == 6); - assert(pthread_mutex_lock(&mutex[0]) == 0); - assert(pthread_mutex_unlock(&mutex[0]) == 0); - assert(pthread_mutex_destroy(&mutex[0]) == 0); - assert(pthread_mutex_lock(&mutex[1]) == 0); - assert(pthread_mutex_unlock(&mutex[1]) == 0); - assert(pthread_mutex_destroy(&mutex[1]) == 0); - assert(pthread_mutex_lock(&mutex[2]) == 0); - assert(pthread_mutex_unlock(&mutex[2]) == 0); - assert(pthread_mutex_destroy(&mutex[2]) == 0); - - order[0]=2; - order[1]=1; - order[2]=0; - lockCount = 0; - assert(pthread_mutex_init(&mutex[0], &ma) == 0); - assert(pthread_mutex_init(&mutex[1], &ma) == 0); - assert(pthread_mutex_init(&mutex[2], &ma) == 0); - assert(pthread_create(&to, NULL, owner, NULL) == 0); - Sleep(100); - assert(pthread_create(&ti, NULL, inheritor, (void *)order) == 0); - assert(pthread_join(to, NULL) == 0); - assert(pthread_join(ti, NULL) == 0); - assert(lockCount == 6); - assert(pthread_mutex_lock(&mutex[0]) == 0); - assert(pthread_mutex_unlock(&mutex[0]) == 0); - assert(pthread_mutex_destroy(&mutex[0]) == 0); - assert(pthread_mutex_lock(&mutex[1]) == 0); - assert(pthread_mutex_unlock(&mutex[1]) == 0); - assert(pthread_mutex_destroy(&mutex[1]) == 0); - assert(pthread_mutex_lock(&mutex[2]) == 0); - assert(pthread_mutex_unlock(&mutex[2]) == 0); - assert(pthread_mutex_destroy(&mutex[2]) == 0); - - assert(pthread_mutexattr_destroy(&ma) == 0); - - return 0; -} diff --git a/deps/w32-pthreads/tests/robust5.c b/deps/w32-pthreads/tests/robust5.c deleted file mode 100644 index de8ae36..0000000 --- a/deps/w32-pthreads/tests/robust5.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - * robust5.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Thread A locks multiple robust mutexes - * Thread B blocks on same mutexes - * Thread A terminates with thread waiting on mutexes - * Thread B awakes and inherits each mutex in turn - * Thread B terminates leaving orphaned mutexes - * Main inherits mutexes, sets consistent and unlocks. - * - * Depends on API functions: - * pthread_create() - * pthread_join() - * pthread_mutex_init() - * pthread_mutex_lock() - * pthread_mutex_unlock() - * pthread_mutex_destroy() - * pthread_mutexattr_init() - * pthread_mutexattr_setrobust() - * pthread_mutexattr_settype() - * pthread_mutexattr_destroy() - */ - -#include "test.h" - -static int lockCount; - -static pthread_mutex_t mutex[3]; - -void * owner(void * arg) -{ - assert(pthread_mutex_lock(&mutex[0]) == 0); - lockCount++; - assert(pthread_mutex_lock(&mutex[1]) == 0); - lockCount++; - assert(pthread_mutex_lock(&mutex[2]) == 0); - lockCount++; - - return 0; -} - -void * inheritor(void * arg) -{ - assert(pthread_mutex_lock(&mutex[0]) == EOWNERDEAD); - lockCount++; - assert(pthread_mutex_lock(&mutex[1]) == EOWNERDEAD); - lockCount++; - assert(pthread_mutex_lock(&mutex[2]) == EOWNERDEAD); - lockCount++; - - return 0; -} - -int -main() -{ - pthread_t to, ti; - pthread_mutexattr_t ma; - - assert(pthread_mutexattr_init(&ma) == 0); - assert(pthread_mutexattr_setrobust(&ma, PTHREAD_MUTEX_ROBUST) == 0); - - lockCount = 0; - assert(pthread_mutex_init(&mutex[0], &ma) == 0); - assert(pthread_mutex_init(&mutex[1], &ma) == 0); - assert(pthread_mutex_init(&mutex[2], &ma) == 0); - assert(pthread_create(&to, NULL, owner, NULL) == 0); - assert(pthread_join(to, NULL) == 0); - assert(pthread_create(&ti, NULL, inheritor, NULL) == 0); - assert(pthread_join(ti, NULL) == 0); - assert(lockCount == 6); - assert(pthread_mutex_lock(&mutex[0]) == EOWNERDEAD); - assert(pthread_mutex_consistent(&mutex[0]) == 0); - assert(pthread_mutex_unlock(&mutex[0]) == 0); - assert(pthread_mutex_destroy(&mutex[0]) == 0); - assert(pthread_mutex_lock(&mutex[1]) == EOWNERDEAD); - assert(pthread_mutex_consistent(&mutex[1]) == 0); - assert(pthread_mutex_unlock(&mutex[1]) == 0); - assert(pthread_mutex_destroy(&mutex[1]) == 0); - assert(pthread_mutex_lock(&mutex[2]) == EOWNERDEAD); - assert(pthread_mutex_consistent(&mutex[2]) == 0); - assert(pthread_mutex_unlock(&mutex[2]) == 0); - assert(pthread_mutex_destroy(&mutex[2]) == 0); - - assert(pthread_mutexattr_destroy(&ma) == 0); - - return 0; -} diff --git a/deps/w32-pthreads/tests/rwlock1.c b/deps/w32-pthreads/tests/rwlock1.c deleted file mode 100644 index 3063763..0000000 --- a/deps/w32-pthreads/tests/rwlock1.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * rwlock1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Create a simple rwlock object and then destroy it. - * - * Depends on API functions: - * pthread_rwlock_init() - * pthread_rwlock_destroy() - */ - -#include "test.h" - -pthread_rwlock_t rwlock = NULL; - -int -main() -{ - assert(rwlock == NULL); - - assert(pthread_rwlock_init(&rwlock, NULL) == 0); - - assert(rwlock != NULL); - - assert(pthread_rwlock_destroy(&rwlock) == 0); - - assert(rwlock == NULL); - - return 0; -} diff --git a/deps/w32-pthreads/tests/rwlock2.c b/deps/w32-pthreads/tests/rwlock2.c deleted file mode 100644 index b99f05a..0000000 --- a/deps/w32-pthreads/tests/rwlock2.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * rwlock2.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Declare a static rwlock object, lock it, - * and then unlock it again. - * - * Depends on API functions: - * pthread_rwlock_rdlock() - * pthread_rwlock_unlock() - */ - -#include "test.h" - -pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER; - -int -main() -{ - assert(rwlock == PTHREAD_RWLOCK_INITIALIZER); - - assert(pthread_rwlock_rdlock(&rwlock) == 0); - - assert(rwlock != PTHREAD_RWLOCK_INITIALIZER); - - assert(rwlock != NULL); - - assert(pthread_rwlock_unlock(&rwlock) == 0); - - assert(pthread_rwlock_destroy(&rwlock) == 0); - - assert(rwlock == NULL); - - return 0; -} diff --git a/deps/w32-pthreads/tests/rwlock2_t.c b/deps/w32-pthreads/tests/rwlock2_t.c deleted file mode 100644 index 0f41d7f..0000000 --- a/deps/w32-pthreads/tests/rwlock2_t.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * rwlock2_t.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Declare a static rwlock object, timed-lock it, - * and then unlock it again. - * - * Depends on API functions: - * pthread_rwlock_timedrdlock() - * pthread_rwlock_unlock() - */ - -#include "test.h" -#include - -pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER; - -int -main() -{ - struct timespec abstime = { 0, 0 }; - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 1; - - assert(rwlock == PTHREAD_RWLOCK_INITIALIZER); - - assert(pthread_rwlock_timedrdlock(&rwlock, &abstime) == 0); - - assert(rwlock != PTHREAD_RWLOCK_INITIALIZER); - - assert(rwlock != NULL); - - assert(pthread_rwlock_unlock(&rwlock) == 0); - - assert(pthread_rwlock_destroy(&rwlock) == 0); - - assert(rwlock == NULL); - - return 0; -} diff --git a/deps/w32-pthreads/tests/rwlock3.c b/deps/w32-pthreads/tests/rwlock3.c deleted file mode 100644 index e27f7ed..0000000 --- a/deps/w32-pthreads/tests/rwlock3.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * rwlock3.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Declare a static rwlock object, wrlock it, trywrlock it, - * and then unlock it again. - * - * Depends on API functions: - * pthread_create() - * pthread_join() - * pthread_rwlock_wrlock() - * pthread_rwlock_trywrlock() - * pthread_rwlock_unlock() - */ - -#include "test.h" - -pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER; - -static int washere = 0; - -void * func(void * arg) -{ - assert(pthread_rwlock_trywrlock(&rwlock1) == EBUSY); - - washere = 1; - - return 0; -} - -int -main() -{ - pthread_t t; - - assert(pthread_rwlock_wrlock(&rwlock1) == 0); - - assert(pthread_create(&t, NULL, func, NULL) == 0); - - assert(pthread_join(t, NULL) == 0); - - assert(pthread_rwlock_unlock(&rwlock1) == 0); - - assert(washere == 1); - - return 0; -} diff --git a/deps/w32-pthreads/tests/rwlock3_t.c b/deps/w32-pthreads/tests/rwlock3_t.c deleted file mode 100644 index 7cbc987..0000000 --- a/deps/w32-pthreads/tests/rwlock3_t.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * rwlock3_t.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Declare a static rwlock object, timed-wrlock it, trywrlock it, - * and then unlock it again. - * - * Depends on API functions: - * pthread_rwlock_timedwrlock() - * pthread_rwlock_trywrlock() - * pthread_rwlock_unlock() - */ - -#include "test.h" -#include - -pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER; - -static int washere = 0; - -void * func(void * arg) -{ - assert(pthread_rwlock_trywrlock(&rwlock1) == EBUSY); - - washere = 1; - - return 0; -} - -int -main() -{ - pthread_t t; - struct timespec abstime = { 0, 0 }; - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 1; - - assert(pthread_rwlock_timedwrlock(&rwlock1, &abstime) == 0); - - assert(pthread_create(&t, NULL, func, NULL) == 0); - - Sleep(2000); - - assert(pthread_rwlock_unlock(&rwlock1) == 0); - - assert(washere == 1); - - return 0; -} diff --git a/deps/w32-pthreads/tests/rwlock4.c b/deps/w32-pthreads/tests/rwlock4.c deleted file mode 100644 index 863784f..0000000 --- a/deps/w32-pthreads/tests/rwlock4.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * rwlock4.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Declare a static rwlock object, rdlock it, trywrlock it, - * and then unlock it again. - * - * Depends on API functions: - * pthread_create() - * pthread_join() - * pthread_rwlock_rdlock() - * pthread_rwlock_trywrlock() - * pthread_rwlock_unlock() - */ - -#include "test.h" - -pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER; - -static int washere = 0; - -void * func(void * arg) -{ - assert(pthread_rwlock_trywrlock(&rwlock1) == EBUSY); - - washere = 1; - - return 0; -} - -int -main() -{ - pthread_t t; - - assert(pthread_rwlock_rdlock(&rwlock1) == 0); - - assert(pthread_create(&t, NULL, func, NULL) == 0); - - assert(pthread_join(t, NULL) == 0); - - assert(pthread_rwlock_unlock(&rwlock1) == 0); - - assert(washere == 1); - - return 0; -} diff --git a/deps/w32-pthreads/tests/rwlock4_t.c b/deps/w32-pthreads/tests/rwlock4_t.c deleted file mode 100644 index 41ce795..0000000 --- a/deps/w32-pthreads/tests/rwlock4_t.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * rwlock4_t.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Declare a static rwlock object, timed-rdlock it, trywrlock it, - * and then unlock it again. - * - * Depends on API functions: - * pthread_rwlock_timedrdlock() - * pthread_rwlock_trywrlock() - * pthread_rwlock_unlock() - */ - -#include "test.h" -#include - -pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER; - -static int washere = 0; - -void * func(void * arg) -{ - assert(pthread_rwlock_trywrlock(&rwlock1) == EBUSY); - - washere = 1; - - return 0; -} - -int -main() -{ - pthread_t t; - struct timespec abstime = { 0, 0 }; - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 1; - - assert(pthread_rwlock_timedrdlock(&rwlock1, &abstime) == 0); - - assert(pthread_create(&t, NULL, func, NULL) == 0); - - Sleep(2000); - - assert(pthread_rwlock_unlock(&rwlock1) == 0); - - assert(washere == 1); - - return 0; -} diff --git a/deps/w32-pthreads/tests/rwlock5.c b/deps/w32-pthreads/tests/rwlock5.c deleted file mode 100644 index d87b19c..0000000 --- a/deps/w32-pthreads/tests/rwlock5.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * rwlock5.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Declare a static rwlock object, rdlock it, tryrdlock it, - * and then unlock it again. - * - * Depends on API functions: - * pthread_create() - * pthread_join() - * pthread_rwlock_rdlock() - * pthread_rwlock_tryrdlock() - * pthread_rwlock_unlock() - */ - -#include "test.h" - -pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER; - -static int washere = 0; - -void * func(void * arg) -{ - assert(pthread_rwlock_tryrdlock(&rwlock1) == 0); - - assert(pthread_rwlock_unlock(&rwlock1) == 0); - - washere = 1; - - return 0; -} - -int -main() -{ - pthread_t t; - - assert(pthread_rwlock_rdlock(&rwlock1) == 0); - - assert(pthread_create(&t, NULL, func, NULL) == 0); - - assert(pthread_join(t, NULL) == 0); - - assert(pthread_rwlock_unlock(&rwlock1) == 0); - - assert(washere == 1); - - return 0; -} diff --git a/deps/w32-pthreads/tests/rwlock5_t.c b/deps/w32-pthreads/tests/rwlock5_t.c deleted file mode 100644 index 6280ce2..0000000 --- a/deps/w32-pthreads/tests/rwlock5_t.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * rwlock5_t.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Declare a static rwlock object, timed-rdlock it, tryrdlock it, - * and then unlock it again. - * - * Depends on API functions: - * pthread_rwlock_timedrdlock() - * pthread_rwlock_tryrdlock() - * pthread_rwlock_unlock() - */ - -#include "test.h" -#include - -pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER; - -static int washere = 0; - -void * func(void * arg) -{ - assert(pthread_rwlock_tryrdlock(&rwlock1) == 0); - - assert(pthread_rwlock_unlock(&rwlock1) == 0); - - washere = 1; - - return 0; -} - -int -main() -{ - pthread_t t; - struct timespec abstime = { 0, 0 }; - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 1; - - assert(pthread_rwlock_timedrdlock(&rwlock1, &abstime) == 0); - - assert(pthread_create(&t, NULL, func, NULL) == 0); - - Sleep(2000); - - assert(pthread_rwlock_unlock(&rwlock1) == 0); - - assert(washere == 1); - - return 0; -} diff --git a/deps/w32-pthreads/tests/rwlock6.c b/deps/w32-pthreads/tests/rwlock6.c deleted file mode 100644 index 3241c8f..0000000 --- a/deps/w32-pthreads/tests/rwlock6.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * rwlock6.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Check writer and reader locking - * - * Depends on API functions: - * pthread_rwlock_rdlock() - * pthread_rwlock_wrlock() - * pthread_rwlock_unlock() - */ - -#include "test.h" - -static pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER; - -static int bankAccount = 0; - -void * wrfunc(void * arg) -{ - int ba; - - assert(pthread_rwlock_wrlock(&rwlock1) == 0); - Sleep(200); - bankAccount += 10; - ba = bankAccount; - assert(pthread_rwlock_unlock(&rwlock1) == 0); - - return ((void *)(size_t)ba); -} - -void * rdfunc(void * arg) -{ - int ba; - - assert(pthread_rwlock_rdlock(&rwlock1) == 0); - ba = bankAccount; - assert(pthread_rwlock_unlock(&rwlock1) == 0); - - return ((void *)(size_t)ba); -} - -int -main() -{ - pthread_t wrt1; - pthread_t wrt2; - pthread_t rdt; - void* wr1Result = (void*)0; - void* wr2Result = (void*)0; - void* rdResult = (void*)0; - - bankAccount = 0; - - assert(pthread_create(&wrt1, NULL, wrfunc, NULL) == 0); - Sleep(50); - assert(pthread_create(&rdt, NULL, rdfunc, NULL) == 0); - Sleep(50); - assert(pthread_create(&wrt2, NULL, wrfunc, NULL) == 0); - - assert(pthread_join(wrt1, &wr1Result) == 0); - assert(pthread_join(rdt, &rdResult) == 0); - assert(pthread_join(wrt2, &wr2Result) == 0); - - assert((int)(size_t)wr1Result == 10); - assert((int)(size_t)rdResult == 10); - assert((int)(size_t)wr2Result == 20); - - return 0; -} diff --git a/deps/w32-pthreads/tests/rwlock6_t.c b/deps/w32-pthreads/tests/rwlock6_t.c deleted file mode 100644 index 8e664e7..0000000 --- a/deps/w32-pthreads/tests/rwlock6_t.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * rwlock6_t.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Check writer and reader locking with reader timeouts - * - * Depends on API functions: - * pthread_rwlock_timedrdlock() - * pthread_rwlock_wrlock() - * pthread_rwlock_unlock() - */ - -#include "test.h" -#include - -static pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER; - -static int bankAccount = 0; - -void * wrfunc(void * arg) -{ - assert(pthread_rwlock_wrlock(&rwlock1) == 0); - Sleep(2000); - bankAccount += 10; - assert(pthread_rwlock_unlock(&rwlock1) == 0); - - return ((void *)(size_t)bankAccount); -} - -void * rdfunc(void * arg) -{ - int ba = -1; - struct timespec abstime = { 0, 0 }; - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - - if ((int) (size_t)arg == 1) - { - abstime.tv_sec += 1; - assert(pthread_rwlock_timedrdlock(&rwlock1, &abstime) == ETIMEDOUT); - ba = 0; - } - else if ((int) (size_t)arg == 2) - { - abstime.tv_sec += 3; - assert(pthread_rwlock_timedrdlock(&rwlock1, &abstime) == 0); - ba = bankAccount; - assert(pthread_rwlock_unlock(&rwlock1) == 0); - } - - return ((void *)(size_t)ba); -} - -int -main() -{ - pthread_t wrt1; - pthread_t wrt2; - pthread_t rdt1; - pthread_t rdt2; - void* wr1Result = (void*)0; - void* wr2Result = (void*)0; - void* rd1Result = (void*)0; - void* rd2Result = (void*)0; - - bankAccount = 0; - - assert(pthread_create(&wrt1, NULL, wrfunc, NULL) == 0); - Sleep(500); - assert(pthread_create(&rdt1, NULL, rdfunc, (void *)(size_t)1) == 0); - Sleep(500); - assert(pthread_create(&wrt2, NULL, wrfunc, NULL) == 0); - Sleep(500); - assert(pthread_create(&rdt2, NULL, rdfunc, (void *)(size_t)2) == 0); - - assert(pthread_join(wrt1, &wr1Result) == 0); - assert(pthread_join(rdt1, &rd1Result) == 0); - assert(pthread_join(wrt2, &wr2Result) == 0); - assert(pthread_join(rdt2, &rd2Result) == 0); - - assert((int)(size_t)wr1Result == 10); - assert((int)(size_t)rd1Result == 0); - assert((int)(size_t)wr2Result == 20); - assert((int)(size_t)rd2Result == 20); - - return 0; -} - - diff --git a/deps/w32-pthreads/tests/rwlock6_t2.c b/deps/w32-pthreads/tests/rwlock6_t2.c deleted file mode 100644 index 2e6d7ce..0000000 --- a/deps/w32-pthreads/tests/rwlock6_t2.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * rwlock6_t2.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Check writer and reader timeouts. - * - * Depends on API functions: - * pthread_rwlock_timedrdlock() - * pthread_rwlock_timedwrlock() - * pthread_rwlock_unlock() - */ - -#include "test.h" -#include - -static pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER; - -static int bankAccount = 0; -struct timespec abstime = { 0, 0 }; - -void * wrfunc(void * arg) -{ - int result; - - result = pthread_rwlock_timedwrlock(&rwlock1, &abstime); - if ((int) (size_t)arg == 1) - { - assert(result == 0); - Sleep(2000); - bankAccount += 10; - assert(pthread_rwlock_unlock(&rwlock1) == 0); - return ((void *)(size_t)bankAccount); - } - else if ((int) (size_t)arg == 2) - { - assert(result == ETIMEDOUT); - return ((void *) 100); - } - - return ((void *)(size_t)-1); -} - -void * rdfunc(void * arg) -{ - int ba = 0; - - assert(pthread_rwlock_timedrdlock(&rwlock1, &abstime) == ETIMEDOUT); - - return ((void *)(size_t)ba); -} - -int -main() -{ - pthread_t wrt1; - pthread_t wrt2; - pthread_t rdt; - void* wr1Result = (void*)0; - void* wr2Result = (void*)0; - void* rdResult = (void*)0; - PTW32_STRUCT_TIMEB currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - PTW32_FTIME(&currSysTime); - - abstime.tv_sec = (long)currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 1; - - bankAccount = 0; - - assert(pthread_create(&wrt1, NULL, wrfunc, (void *)(size_t)1) == 0); - Sleep(100); - assert(pthread_create(&rdt, NULL, rdfunc, NULL) == 0); - Sleep(100); - assert(pthread_create(&wrt2, NULL, wrfunc, (void *)(size_t)2) == 0); - - assert(pthread_join(wrt1, &wr1Result) == 0); - assert(pthread_join(rdt, &rdResult) == 0); - assert(pthread_join(wrt2, &wr2Result) == 0); - - assert((int)(size_t)wr1Result == 10); - assert((int)(size_t)rdResult == 0); - assert((int)(size_t)wr2Result == 100); - - return 0; -} diff --git a/deps/w32-pthreads/tests/rwlock7.c b/deps/w32-pthreads/tests/rwlock7.c deleted file mode 100644 index 69d1a73..0000000 --- a/deps/w32-pthreads/tests/rwlock7.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - * rwlock7.c - * - * Hammer on a bunch of rwlocks to test robustness and fairness. - * Printed stats should be roughly even for each thread. - */ - -#include "test.h" -#include - -#ifdef __GNUC__ -#include -#endif - -#define THREADS 5 -#define DATASIZE 7 -#define ITERATIONS 1000000 - -/* - * Keep statistics for each thread. - */ -typedef struct thread_tag { - int thread_num; - pthread_t thread_id; - int updates; - int reads; - int changed; - int seed; -} thread_t; - -/* - * Read-write lock and shared data - */ -typedef struct data_tag { - pthread_rwlock_t lock; - int data; - int updates; -} data_t; - -static thread_t threads[THREADS]; -static data_t data[DATASIZE]; - -/* - * Thread start routine that uses read-write locks - */ -void *thread_routine (void *arg) -{ - thread_t *self = (thread_t*)arg; - int iteration; - int element = 0; - int seed = self->seed; - int interval = 1 + rand_r (&seed) % 71; - - self->changed = 0; - - for (iteration = 0; iteration < ITERATIONS; iteration++) - { - if (iteration % (ITERATIONS / 10) == 0) - { - putchar('.'); - fflush(stdout); - } - /* - * Each "self->interval" iterations, perform an - * update operation (write lock instead of read - * lock). - */ - if ((iteration % interval) == 0) - { - assert(pthread_rwlock_wrlock (&data[element].lock) == 0); - data[element].data = self->thread_num; - data[element].updates++; - self->updates++; - interval = 1 + rand_r (&seed) % 71; - assert(pthread_rwlock_unlock (&data[element].lock) == 0); - } else { - /* - * Look at the current data element to see whether - * the current thread last updated it. Count the - * times, to report later. - */ - assert(pthread_rwlock_rdlock (&data[element].lock) == 0); - - self->reads++; - - if (data[element].data != self->thread_num) - { - self->changed++; - interval = 1 + self->changed % 71; - } - - assert(pthread_rwlock_unlock (&data[element].lock) == 0); - } - - element = (element + 1) % DATASIZE; - - } - - return NULL; -} - -int -main (int argc, char *argv[]) -{ - int count; - int data_count; - int thread_updates = 0; - int data_updates = 0; - int seed = 1; - - PTW32_STRUCT_TIMEB currSysTime1; - PTW32_STRUCT_TIMEB currSysTime2; - - /* - * Initialize the shared data. - */ - for (data_count = 0; data_count < DATASIZE; data_count++) - { - data[data_count].data = 0; - data[data_count].updates = 0; - - assert(pthread_rwlock_init (&data[data_count].lock, NULL) == 0); - } - - PTW32_FTIME(&currSysTime1); - - /* - * Create THREADS threads to access shared data. - */ - for (count = 0; count < THREADS; count++) - { - threads[count].thread_num = count; - threads[count].updates = 0; - threads[count].reads = 0; - threads[count].seed = 1 + rand_r (&seed) % 71; - - assert(pthread_create (&threads[count].thread_id, - NULL, thread_routine, (void*)(size_t)&threads[count]) == 0); - } - - /* - * Wait for all threads to complete, and collect - * statistics. - */ - for (count = 0; count < THREADS; count++) - { - assert(pthread_join (threads[count].thread_id, NULL) == 0); - } - - putchar('\n'); - fflush(stdout); - - for (count = 0; count < THREADS; count++) - { - if (threads[count].changed > 0) - { - printf ("Thread %d found changed elements %d times\n", - count, threads[count].changed); - } - } - - putchar('\n'); - fflush(stdout); - - for (count = 0; count < THREADS; count++) - { - thread_updates += threads[count].updates; - printf ("%02d: seed %d, updates %d, reads %d\n", - count, threads[count].seed, - threads[count].updates, threads[count].reads); - } - - putchar('\n'); - fflush(stdout); - - /* - * Collect statistics for the data. - */ - for (data_count = 0; data_count < DATASIZE; data_count++) - { - data_updates += data[data_count].updates; - printf ("data %02d: value %d, %d updates\n", - data_count, data[data_count].data, data[data_count].updates); - assert(pthread_rwlock_destroy (&data[data_count].lock) == 0); - } - - printf ("%d thread updates, %d data updates\n", - thread_updates, data_updates); - - PTW32_FTIME(&currSysTime2); - - printf( "\nstart: %ld/%d, stop: %ld/%d, duration:%ld\n", - (long)currSysTime1.time,currSysTime1.millitm, - (long)currSysTime2.time,currSysTime2.millitm, - ((long)((currSysTime2.time*1000+currSysTime2.millitm) - - (currSysTime1.time*1000+currSysTime1.millitm)))); - - return 0; -} diff --git a/deps/w32-pthreads/tests/rwlock8.c b/deps/w32-pthreads/tests/rwlock8.c deleted file mode 100644 index 99c357a..0000000 --- a/deps/w32-pthreads/tests/rwlock8.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - * rwlock8.c - * - * Hammer on a bunch of rwlocks to test robustness and fairness. - * Printed stats should be roughly even for each thread. - * - * Yield during each access to exercise lock contention code paths - * more than rwlock7.c does (particularly on uni-processor systems). - */ - -#include "test.h" -#include - -#ifdef __GNUC__ -#include -#endif - -#define THREADS 5 -#define DATASIZE 7 -#define ITERATIONS 100000 - -/* - * Keep statistics for each thread. - */ -typedef struct thread_tag { - int thread_num; - pthread_t thread_id; - int updates; - int reads; - int changed; - int seed; -} thread_t; - -/* - * Read-write lock and shared data - */ -typedef struct data_tag { - pthread_rwlock_t lock; - int data; - int updates; -} data_t; - -static thread_t threads[THREADS]; -static data_t data[DATASIZE]; - -/* - * Thread start routine that uses read-write locks - */ -void *thread_routine (void *arg) -{ - thread_t *self = (thread_t*)arg; - int iteration; - int element = 0; - int seed = self->seed; - int interval = 1 + rand_r (&seed) % 71; - - self->changed = 0; - - for (iteration = 0; iteration < ITERATIONS; iteration++) - { - if (iteration % (ITERATIONS / 10) == 0) - { - putchar('.'); - fflush(stdout); - } - /* - * Each "self->interval" iterations, perform an - * update operation (write lock instead of read - * lock). - */ - if ((iteration % interval) == 0) - { - assert(pthread_rwlock_wrlock (&data[element].lock) == 0); - data[element].data = self->thread_num; - data[element].updates++; - self->updates++; - interval = 1 + rand_r (&seed) % 71; - sched_yield(); - assert(pthread_rwlock_unlock (&data[element].lock) == 0); - } else { - /* - * Look at the current data element to see whether - * the current thread last updated it. Count the - * times, to report later. - */ - assert(pthread_rwlock_rdlock (&data[element].lock) == 0); - - self->reads++; - - if (data[element].data != self->thread_num) - { - self->changed++; - interval = 1 + self->changed % 71; - } - - sched_yield(); - - assert(pthread_rwlock_unlock (&data[element].lock) == 0); - } - - element = (element + 1) % DATASIZE; - - } - - return NULL; -} - -int -main (int argc, char *argv[]) -{ - int count; - int data_count; - int thread_updates = 0; - int data_updates = 0; - int seed = 1; - - PTW32_STRUCT_TIMEB currSysTime1; - PTW32_STRUCT_TIMEB currSysTime2; - - /* - * Initialize the shared data. - */ - for (data_count = 0; data_count < DATASIZE; data_count++) - { - data[data_count].data = 0; - data[data_count].updates = 0; - - assert(pthread_rwlock_init (&data[data_count].lock, NULL) == 0); - } - - PTW32_FTIME(&currSysTime1); - - /* - * Create THREADS threads to access shared data. - */ - for (count = 0; count < THREADS; count++) - { - threads[count].thread_num = count; - threads[count].updates = 0; - threads[count].reads = 0; - threads[count].seed = 1 + rand_r (&seed) % 71; - - assert(pthread_create (&threads[count].thread_id, - NULL, thread_routine, (void*)(size_t)&threads[count]) == 0); - } - - /* - * Wait for all threads to complete, and collect - * statistics. - */ - for (count = 0; count < THREADS; count++) - { - assert(pthread_join (threads[count].thread_id, NULL) == 0); - } - - putchar('\n'); - fflush(stdout); - - for (count = 0; count < THREADS; count++) - { - if (threads[count].changed > 0) - { - printf ("Thread %d found changed elements %d times\n", - count, threads[count].changed); - } - } - - putchar('\n'); - fflush(stdout); - - for (count = 0; count < THREADS; count++) - { - thread_updates += threads[count].updates; - printf ("%02d: seed %d, updates %d, reads %d\n", - count, threads[count].seed, - threads[count].updates, threads[count].reads); - } - - putchar('\n'); - fflush(stdout); - - /* - * Collect statistics for the data. - */ - for (data_count = 0; data_count < DATASIZE; data_count++) - { - data_updates += data[data_count].updates; - printf ("data %02d: value %d, %d updates\n", - data_count, data[data_count].data, data[data_count].updates); - assert(pthread_rwlock_destroy (&data[data_count].lock) == 0); - } - - printf ("%d thread updates, %d data updates\n", - thread_updates, data_updates); - - PTW32_FTIME(&currSysTime2); - - printf( "\nstart: %ld/%d, stop: %ld/%d, duration:%ld\n", - (long)currSysTime1.time,currSysTime1.millitm, - (long)currSysTime2.time,currSysTime2.millitm, - ((long)((currSysTime2.time*1000+currSysTime2.millitm) - - (currSysTime1.time*1000+currSysTime1.millitm)))); - - return 0; -} diff --git a/deps/w32-pthreads/tests/self1.c b/deps/w32-pthreads/tests/self1.c deleted file mode 100644 index 7bc4a80..0000000 --- a/deps/w32-pthreads/tests/self1.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * self1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test for pthread_self(). - * - * Depends on API functions: - * pthread_self() - * - * Implicitly depends on: - * pthread_getspecific() - * pthread_setspecific() - */ - -#include "test.h" - -int -main(int argc, char * argv[]) -{ - /* - * This should always succeed unless the system has no - * resources (memory) left. - */ - pthread_t self; - -#if defined(PTW32_STATIC_LIB) && !(defined(_MSC_VER) || defined(__MINGW32__)) - pthread_win32_process_attach_np(); -#endif - - self = pthread_self(); - - assert(self.p != NULL); - -#if defined(PTW32_STATIC_LIB) && !(defined(_MSC_VER) || defined(__MINGW32__)) - pthread_win32_process_detach_np(); -#endif - return 0; -} diff --git a/deps/w32-pthreads/tests/self2.c b/deps/w32-pthreads/tests/self2.c deleted file mode 100644 index e92ede4..0000000 --- a/deps/w32-pthreads/tests/self2.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * self2.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test for pthread_self(). - * - * Depends on API functions: - * pthread_create() - * pthread_self() - * - * Implicitly depends on: - * pthread_getspecific() - * pthread_setspecific() - */ - -#include "test.h" -#include - -static pthread_t me; - -void * -entry(void * arg) -{ - me = pthread_self(); - - return arg; -} - -int -main() -{ - pthread_t t; - - assert(pthread_create(&t, NULL, entry, NULL) == 0); - - Sleep(100); - - assert(pthread_equal(t, me) != 0); - - /* Success. */ - return 0; -} diff --git a/deps/w32-pthreads/tests/semaphore1.c b/deps/w32-pthreads/tests/semaphore1.c deleted file mode 100644 index a6c02e6..0000000 --- a/deps/w32-pthreads/tests/semaphore1.c +++ /dev/null @@ -1,150 +0,0 @@ -/* - * File: semaphore1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Verify trywait() returns -1 and sets EAGAIN. - * - - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -void * -thr(void * arg) -{ - sem_t s; - int result; - - assert(sem_init(&s, PTHREAD_PROCESS_PRIVATE, 0) == 0); - - assert((result = sem_trywait(&s)) == -1); - - if ( result == -1 ) - { - int err = errno; - if (err != EAGAIN) - { - printf("thread: sem_trywait 1: expecting error %s: got %s\n", - error_string[EAGAIN], error_string[err]); fflush(stdout); - } - assert(err == EAGAIN); - } - else - { - printf("thread: ok 1\n"); - } - - assert((result = sem_post(&s)) == 0); - - assert((result = sem_trywait(&s)) == 0); - - assert(sem_post(&s) == 0); - - return NULL; -} - - -int -main() -{ - pthread_t t; - sem_t s; - void* result1 = (void*)-1; - int result2; - - assert(pthread_create(&t, NULL, thr, NULL) == 0); - assert(pthread_join(t, &result1) == 0); - assert((int)(size_t)result1 == 0); - - assert(sem_init(&s, PTHREAD_PROCESS_PRIVATE, 0) == 0); - - assert((result2 = sem_trywait(&s)) == -1); - - if (result2 == -1) - { - int err = errno; - if (err != EAGAIN) - { - printf("main: sem_trywait 1: expecting error %s: got %s\n", - error_string[EAGAIN], error_string[err]); fflush(stdout); - } - assert(err == EAGAIN); - } - else - { - printf("main: ok 1\n"); - } - - assert((result2 = sem_post(&s)) == 0); - - assert((result2 = sem_trywait(&s)) == 0); - - assert(sem_post(&s) == 0); - - return 0; -} - diff --git a/deps/w32-pthreads/tests/semaphore2.c b/deps/w32-pthreads/tests/semaphore2.c deleted file mode 100644 index 5a4e236..0000000 --- a/deps/w32-pthreads/tests/semaphore2.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * File: semaphore2.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Verify sem_getvalue returns the correct value. - * - - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -#define MAX_COUNT 100 - -int -main() -{ - sem_t s; - int value = 0; - int i; - - assert(sem_init(&s, PTHREAD_PROCESS_PRIVATE, MAX_COUNT) == 0); - assert(sem_getvalue(&s, &value) == 0); - assert(value == MAX_COUNT); -// printf("Value = %ld\n", value); - - for (i = MAX_COUNT - 1; i >= 0; i--) - { - assert(sem_wait(&s) == 0); - assert(sem_getvalue(&s, &value) == 0); -// printf("Value = %ld\n", value); - assert(value == i); - } - - for (i = 1; i <= MAX_COUNT; i++) - { - assert(sem_post(&s) == 0); - assert(sem_getvalue(&s, &value) == 0); -// printf("Value = %ld\n", value); - assert(value == i); - } - - return 0; -} - diff --git a/deps/w32-pthreads/tests/semaphore3.c b/deps/w32-pthreads/tests/semaphore3.c deleted file mode 100644 index 0ee8e5d..0000000 --- a/deps/w32-pthreads/tests/semaphore3.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * File: semaphore3.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Verify sem_getvalue returns the correct number of waiters. - * - - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -#define MAX_COUNT 100 - -sem_t s; - -void * -thr (void * arg) -{ - assert(sem_wait(&s) == 0); - assert(pthread_detach(pthread_self()) == 0); - return NULL; -} - -int -main() -{ - int value = 0; - int i; - pthread_t t[MAX_COUNT+1]; - - assert(sem_init(&s, PTHREAD_PROCESS_PRIVATE, 0) == 0); - assert(sem_getvalue(&s, &value) == 0); -// printf("Value = %d\n", value); fflush(stdout); - assert(value == 0); - - for (i = 1; i <= MAX_COUNT; i++) - { - assert(pthread_create(&t[i], NULL, thr, NULL) == 0); - do { - sched_yield(); - assert(sem_getvalue(&s, &value) == 0); - } while (value != -i); -// printf("Value = %d\n", value); fflush(stdout); - assert(-value == i); - } - - for (i = MAX_COUNT - 1; i >= 0; i--) - { - assert(sem_post(&s) == 0); - assert(sem_getvalue(&s, &value) == 0); -// printf("Value = %d\n", value); fflush(stdout); - assert(-value == i); - } - - return 0; -} - diff --git a/deps/w32-pthreads/tests/semaphore4.c b/deps/w32-pthreads/tests/semaphore4.c deleted file mode 100644 index b1356e4..0000000 --- a/deps/w32-pthreads/tests/semaphore4.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * File: semaphore4.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Verify sem_getvalue returns the correct number of waiters - * after threads are cancelled. - * - - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -#define MAX_COUNT 100 - -sem_t s; - -void * -thr (void * arg) -{ - assert(sem_wait(&s) == 0); - return NULL; -} - -int -main() -{ - int value = 0; - int i; - pthread_t t[MAX_COUNT+1]; - - assert(sem_init(&s, PTHREAD_PROCESS_PRIVATE, 0) == 0); - assert(sem_getvalue(&s, &value) == 0); - assert(value == 0); - - for (i = 1; i <= MAX_COUNT; i++) - { - assert(pthread_create(&t[i], NULL, thr, NULL) == 0); - do { - sched_yield(); - assert(sem_getvalue(&s, &value) == 0); - } while (value != -i); - assert(-value == i); - } - - assert(sem_getvalue(&s, &value) == 0); - assert(-value == MAX_COUNT); - assert(pthread_cancel(t[50]) == 0); - { - void* result; - assert(pthread_join(t[50], &result) == 0); - } - assert(sem_getvalue(&s, &value) == 0); - assert(-value == (MAX_COUNT - 1)); - - for (i = MAX_COUNT - 2; i >= 0; i--) - { - assert(sem_post(&s) == 0); - assert(sem_getvalue(&s, &value) == 0); - assert(-value == i); - } - - for (i = 1; i <= MAX_COUNT; i++) - if (i != 50) - assert(pthread_join(t[i], NULL) == 0); - - return 0; -} - diff --git a/deps/w32-pthreads/tests/semaphore4t.c b/deps/w32-pthreads/tests/semaphore4t.c deleted file mode 100644 index 5a8d7a9..0000000 --- a/deps/w32-pthreads/tests/semaphore4t.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * File: semaphore4t.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Verify sem_getvalue returns the correct number of waiters - * after threads are cancelled. - * - - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - sem_timedwait cancellation. - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -#define MAX_COUNT 100 - -sem_t s; - -void * -thr (void * arg) -{ - assert(sem_timedwait(&s, NULL) == 0); - return NULL; -} - -int -main() -{ - int value = 0; - int i; - pthread_t t[MAX_COUNT+1]; - - assert(sem_init(&s, PTHREAD_PROCESS_PRIVATE, 0) == 0); - assert(sem_getvalue(&s, &value) == 0); - assert(value == 0); - - for (i = 1; i <= MAX_COUNT; i++) - { - assert(pthread_create(&t[i], NULL, thr, NULL) == 0); - do { - sched_yield(); - assert(sem_getvalue(&s, &value) == 0); - } while (value != -i); - assert(-value == i); - } - - assert(sem_getvalue(&s, &value) == 0); - assert(-value == MAX_COUNT); - assert(pthread_cancel(t[50]) == 0); - assert(pthread_join(t[50], NULL) == 0); - assert(sem_getvalue(&s, &value) == 0); - assert(-value == MAX_COUNT - 1); - - for (i = MAX_COUNT - 2; i >= 0; i--) - { - assert(sem_post(&s) == 0); - assert(sem_getvalue(&s, &value) == 0); - assert(-value == i); - } - - for (i = 1; i <= MAX_COUNT; i++) - if (i != 50) - assert(pthread_join(t[i], NULL) == 0); - - return 0; -} - diff --git a/deps/w32-pthreads/tests/semaphore5.c b/deps/w32-pthreads/tests/semaphore5.c deleted file mode 100644 index 67fd339..0000000 --- a/deps/w32-pthreads/tests/semaphore5.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * File: semaphore5.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: Verify sem_destroy EBUSY race avoidance - * - - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -// #define ASSERT_TRACE - -#include "test.h" - -void * -thr(void * arg) -{ - assert(sem_post((sem_t *)arg) == 0); - - return 0; -} - - -int -main() -{ - pthread_t t; - sem_t s; - - assert(sem_init(&s, PTHREAD_PROCESS_PRIVATE, 0) == 0); - assert(pthread_create(&t, NULL, thr, (void *)&s) == 0); - - assert(sem_wait(&s) == 0); - assert(sem_destroy(&s) == 0); - - assert(pthread_join(t, NULL) == 0); - - return 0; -} - diff --git a/deps/w32-pthreads/tests/sequence1.c b/deps/w32-pthreads/tests/sequence1.c deleted file mode 100644 index fa1cdc5..0000000 --- a/deps/w32-pthreads/tests/sequence1.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * File: sequence1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - that unique thread sequence numbers are generated. - * - Analyse thread struct reuse. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - This test is implementation specific - * because it uses knowledge of internals that should be - * opaque to an application. - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - analysis output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - unique sequence numbers are generated for every new thread. - * - * Fail Criteria: - * - - */ - -#include "test.h" - -/* - */ - -enum { - NUMTHREADS = 10000 -}; - - -static long done = 0; -/* - * seqmap should have 1 in every element except [0] - * Thread sequence numbers start at 1 and we will also - * include this main thread so we need NUMTHREADS+2 - * elements. - */ -static UINT64 seqmap[NUMTHREADS+2]; - -void * func(void * arg) -{ - sched_yield(); - seqmap[(int)pthread_getunique_np(pthread_self())] = 1; - InterlockedIncrement(&done); - - return (void *) 0; -} - -int -main() -{ - pthread_t t[NUMTHREADS]; - pthread_attr_t attr; - int i; - - assert(pthread_attr_init(&attr) == 0); - assert(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) == 0); - - for (i = 0; i < NUMTHREADS+2; i++) - { - seqmap[i] = 0; - } - - for (i = 0; i < NUMTHREADS; i++) - { - if (NUMTHREADS/2 == i) - { - /* Include this main thread, which will be an implicit pthread_t */ - seqmap[(int)pthread_getunique_np(pthread_self())] = 1; - } - assert(pthread_create(&t[i], &attr, func, NULL) == 0); - } - - while (NUMTHREADS > InterlockedExchangeAdd((LPLONG)&done, 0L)) - Sleep(100); - - Sleep(100); - - assert(seqmap[0] == 0); - for (i = 1; i < NUMTHREADS+2; i++) - { - assert(seqmap[i] == 1); - } - - return 0; -} diff --git a/deps/w32-pthreads/tests/sizes.c b/deps/w32-pthreads/tests/sizes.c deleted file mode 100644 index 554d0e8..0000000 --- a/deps/w32-pthreads/tests/sizes.c +++ /dev/null @@ -1,32 +0,0 @@ -#define _WIN32_WINNT 0x400 - -#include "test.h" -#include "../implement.h" - -int -main() -{ - printf("Sizes of pthreads-win32 structs\n"); - printf("-------------------------------\n"); - printf("%30s %4d\n", "pthread_t", (int)sizeof(pthread_t)); - printf("%30s %4d\n", "ptw32_thread_t", (int)sizeof(ptw32_thread_t)); - printf("%30s %4d\n", "pthread_attr_t_", (int)sizeof(struct pthread_attr_t_)); - printf("%30s %4d\n", "sem_t_", (int)sizeof(struct sem_t_)); - printf("%30s %4d\n", "pthread_mutex_t_", (int)sizeof(struct pthread_mutex_t_)); - printf("%30s %4d\n", "pthread_mutexattr_t_", (int)sizeof(struct pthread_mutexattr_t_)); - printf("%30s %4d\n", "pthread_spinlock_t_", (int)sizeof(struct pthread_spinlock_t_)); - printf("%30s %4d\n", "pthread_barrier_t_", (int)sizeof(struct pthread_barrier_t_)); - printf("%30s %4d\n", "pthread_barrierattr_t_", (int)sizeof(struct pthread_barrierattr_t_)); - printf("%30s %4d\n", "pthread_key_t_", (int)sizeof(struct pthread_key_t_)); - printf("%30s %4d\n", "pthread_cond_t_", (int)sizeof(struct pthread_cond_t_)); - printf("%30s %4d\n", "pthread_condattr_t_", (int)sizeof(struct pthread_condattr_t_)); - printf("%30s %4d\n", "pthread_rwlock_t_", (int)sizeof(struct pthread_rwlock_t_)); - printf("%30s %4d\n", "pthread_rwlockattr_t_", (int)sizeof(struct pthread_rwlockattr_t_)); - printf("%30s %4d\n", "pthread_once_t_", (int)sizeof(struct pthread_once_t_)); - printf("%30s %4d\n", "ptw32_cleanup_t", (int)sizeof(struct ptw32_cleanup_t)); - printf("%30s %4d\n", "ptw32_mcs_node_t_", (int)sizeof(struct ptw32_mcs_node_t_)); - printf("%30s %4d\n", "sched_param", (int)sizeof(struct sched_param)); - printf("-------------------------------\n"); - - return 0; -} diff --git a/deps/w32-pthreads/tests/spin1.c b/deps/w32-pthreads/tests/spin1.c deleted file mode 100644 index 6ba5dac..0000000 --- a/deps/w32-pthreads/tests/spin1.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * spin1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Create a simple spinlock object, lock it, and then unlock it again. - * This is the simplest test of the pthread mutex family that we can do. - * - */ - -#include "test.h" - -pthread_spinlock_t lock; - -int -main() -{ - assert(pthread_spin_init(&lock, PTHREAD_PROCESS_PRIVATE) == 0); - - assert(pthread_spin_lock(&lock) == 0); - - assert(pthread_spin_unlock(&lock) == 0); - - assert(pthread_spin_destroy(&lock) == 0); - - assert(pthread_spin_lock(&lock) == EINVAL); - - return 0; -} diff --git a/deps/w32-pthreads/tests/spin2.c b/deps/w32-pthreads/tests/spin2.c deleted file mode 100644 index d08ac98..0000000 --- a/deps/w32-pthreads/tests/spin2.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * spin2.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Declare a spinlock object, lock it, trylock it, - * and then unlock it again. - * - */ - -#include "test.h" - -pthread_spinlock_t lock = NULL; - -static int washere = 0; - -void * func(void * arg) -{ - assert(pthread_spin_trylock(&lock) == EBUSY); - - washere = 1; - - return 0; -} - -int -main() -{ - pthread_t t; - - assert(pthread_spin_init(&lock, PTHREAD_PROCESS_PRIVATE) == 0); - - assert(pthread_spin_lock(&lock) == 0); - - assert(pthread_create(&t, NULL, func, NULL) == 0); - assert(pthread_join(t, NULL) == 0); - - assert(pthread_spin_unlock(&lock) == 0); - - assert(pthread_spin_destroy(&lock) == 0); - - assert(washere == 1); - - return 0; -} diff --git a/deps/w32-pthreads/tests/spin3.c b/deps/w32-pthreads/tests/spin3.c deleted file mode 100644 index ebf69ca..0000000 --- a/deps/w32-pthreads/tests/spin3.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * spin3.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Thread A locks spin - thread B tries to unlock. - * This should succeed, but it's undefined behaviour. - * - */ - -#include "test.h" - -static int wasHere = 0; - -static pthread_spinlock_t spin; - -void * unlocker(void * arg) -{ - int expectedResult = (int)(size_t)arg; - - wasHere++; - assert(pthread_spin_unlock(&spin) == expectedResult); - wasHere++; - return NULL; -} - -int -main() -{ - pthread_t t; - - wasHere = 0; - assert(pthread_spin_init(&spin, PTHREAD_PROCESS_PRIVATE) == 0); - assert(pthread_spin_lock(&spin) == 0); - assert(pthread_create(&t, NULL, unlocker, (void*)0) == 0); - assert(pthread_join(t, NULL) == 0); - /* - * Our spinlocks don't record the owner thread so any thread can unlock the spinlock, - * but nor is it an error for any thread to unlock a spinlock that is not locked. - */ - assert(pthread_spin_unlock(&spin) == 0); - assert(pthread_spin_destroy(&spin) == 0); - assert(wasHere == 2); - - return 0; -} diff --git a/deps/w32-pthreads/tests/spin4.c b/deps/w32-pthreads/tests/spin4.c deleted file mode 100644 index 277efd7..0000000 --- a/deps/w32-pthreads/tests/spin4.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * spin4.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Declare a static spinlock object, lock it, spin on it, - * and then unlock it again. - */ - -#include "test.h" -#include - -pthread_spinlock_t lock = PTHREAD_SPINLOCK_INITIALIZER; -PTW32_STRUCT_TIMEB currSysTimeStart; -PTW32_STRUCT_TIMEB currSysTimeStop; - -#define GetDurationMilliSecs(_TStart, _TStop) ((_TStop.time*1000+_TStop.millitm) \ - - (_TStart.time*1000+_TStart.millitm)) - -static int washere = 0; - -void * func(void * arg) -{ - PTW32_FTIME(&currSysTimeStart); - washere = 1; - assert(pthread_spin_lock(&lock) == 0); - assert(pthread_spin_unlock(&lock) == 0); - PTW32_FTIME(&currSysTimeStop); - - return (void *)(size_t)GetDurationMilliSecs(currSysTimeStart, currSysTimeStop); -} - -int -main() -{ - void* result = (void*)0; - pthread_t t; - int CPUs; - PTW32_STRUCT_TIMEB sysTime; - - if ((CPUs = pthread_num_processors_np()) == 1) - { - printf("Test not run - it requires multiple CPUs.\n"); - exit(0); - } - - assert(pthread_spin_lock(&lock) == 0); - - assert(pthread_create(&t, NULL, func, NULL) == 0); - - while (washere == 0) - { - sched_yield(); - } - - do - { - sched_yield(); - PTW32_FTIME(&sysTime); - } - while (GetDurationMilliSecs(currSysTimeStart, sysTime) <= 1000); - - assert(pthread_spin_unlock(&lock) == 0); - - assert(pthread_join(t, &result) == 0); - assert((int)(size_t)result > 1000); - - assert(pthread_spin_destroy(&lock) == 0); - - assert(washere == 1); - - return 0; -} diff --git a/deps/w32-pthreads/tests/stress1.c b/deps/w32-pthreads/tests/stress1.c deleted file mode 100644 index 04bdc16..0000000 --- a/deps/w32-pthreads/tests/stress1.c +++ /dev/null @@ -1,278 +0,0 @@ -/* - * stress1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Stress test condition variables, mutexes, semaphores. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - Correct accounting of semaphore and condition variable waiters. - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * Attempting to expose race conditions in cond vars, semaphores etc. - * - Master attempts to signal slave close to when timeout is due. - * - Master and slave do battle continuously until main tells them to stop. - * - Afterwards, the CV must be successfully destroyed (will return an - * error if there are waiters (including any internal semaphore waiters, - * which, if there are, cannot be real waiters). - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - CV is successfully destroyed. - * - * Fail Criteria: - * - CV destroy fails. - */ - -#include "test.h" -#include -#include - - -const unsigned int ITERATIONS = 1000; - -static pthread_t master, slave; -typedef struct { - int value; - pthread_cond_t cv; - pthread_mutex_t mx; -} mysig_t; - -static int allExit; -static mysig_t control = {0, PTHREAD_COND_INITIALIZER, PTHREAD_MUTEX_INITIALIZER}; -static pthread_barrier_t startBarrier, readyBarrier, holdBarrier; -static int timeoutCount = 0; -static int signalsTakenCount = 0; -static int signalsSent = 0; -static int bias = 0; -static int timeout = 10; // Must be > 0 - -enum { - CTL_STOP = -1 -}; - -/* - * Returns abstime 'milliseconds' from 'now'. - * - * Works for: -INT_MAX <= millisecs <= INT_MAX - */ -struct timespec * -millisecondsFromNow (struct timespec * time, int millisecs) -{ - PTW32_STRUCT_TIMEB currSysTime; - int64_t nanosecs, secs; - const int64_t NANOSEC_PER_MILLISEC = 1000000; - const int64_t NANOSEC_PER_SEC = 1000000000; - - /* get current system time and add millisecs */ - PTW32_FTIME(&currSysTime); - - secs = (int64_t)(currSysTime.time) + (millisecs / 1000); - nanosecs = ((int64_t) (millisecs%1000 + currSysTime.millitm)) * NANOSEC_PER_MILLISEC; - if (nanosecs >= NANOSEC_PER_SEC) - { - secs++; - nanosecs -= NANOSEC_PER_SEC; - } - else if (nanosecs < 0) - { - secs--; - nanosecs += NANOSEC_PER_SEC; - } - - time->tv_nsec = (long)nanosecs; - time->tv_sec = (long)secs; - - return time; -} - -void * -masterThread (void * arg) -{ - int dither = (int)(size_t)arg; - - timeout = (int)(size_t)arg; - - pthread_barrier_wait(&startBarrier); - - do - { - int sleepTime; - - assert(pthread_mutex_lock(&control.mx) == 0); - control.value = timeout; - assert(pthread_mutex_unlock(&control.mx) == 0); - - /* - * We are attempting to send the signal close to when the slave - * is due to timeout. We feel around by adding some [non-random] dither. - * - * dither is in the range 2*timeout peak-to-peak - * sleep time is the average of timeout plus dither. - * e.g. - * if timeout = 10 then dither = 20 and - * sleep millisecs is: 5 <= ms <= 15 - * - * The bias value attempts to apply some negative feedback to keep - * the ratio of timeouts to signals taken close to 1:1. - * bias changes more slowly than dither so as to average more. - * - * Finally, if abs(bias) exceeds timeout then timeout is incremented. - */ - if (signalsSent % timeout == 0) - { - if (timeoutCount > signalsTakenCount) - { - bias++; - } - else if (timeoutCount < signalsTakenCount) - { - bias--; - } - if (bias < -timeout || bias > timeout) - { - timeout++; - } - } - dither = (dither + 1 ) % (timeout * 2); - sleepTime = (timeout - bias + dither) / 2; - Sleep(sleepTime); - assert(pthread_cond_signal(&control.cv) == 0); - signalsSent++; - - pthread_barrier_wait(&holdBarrier); - pthread_barrier_wait(&readyBarrier); - } - while (!allExit); - - return NULL; -} - -void * -slaveThread (void * arg) -{ - struct timespec time; - - pthread_barrier_wait(&startBarrier); - - do - { - assert(pthread_mutex_lock(&control.mx) == 0); - if (pthread_cond_timedwait(&control.cv, - &control.mx, - millisecondsFromNow(&time, control.value)) == ETIMEDOUT) - { - timeoutCount++; - } - else - { - signalsTakenCount++; - } - assert(pthread_mutex_unlock(&control.mx) == 0); - - pthread_barrier_wait(&holdBarrier); - pthread_barrier_wait(&readyBarrier); - } - while (!allExit); - - return NULL; -} - -int -main () -{ - unsigned int i; - - assert(pthread_barrier_init(&startBarrier, NULL, 3) == 0); - assert(pthread_barrier_init(&readyBarrier, NULL, 3) == 0); - assert(pthread_barrier_init(&holdBarrier, NULL, 3) == 0); - - assert(pthread_create(&master, NULL, masterThread, (void *)(size_t)timeout) == 0); - assert(pthread_create(&slave, NULL, slaveThread, NULL) == 0); - - allExit = FALSE; - - pthread_barrier_wait(&startBarrier); - - for (i = 1; !allExit; i++) - { - pthread_barrier_wait(&holdBarrier); - if (i >= ITERATIONS) - { - allExit = TRUE; - } - pthread_barrier_wait(&readyBarrier); - } - - assert(pthread_join(slave, NULL) == 0); - assert(pthread_join(master, NULL) == 0); - - printf("Signals sent = %d\nWait timeouts = %d\nSignals taken = %d\nBias = %d\nTimeout = %d\n", - signalsSent, - timeoutCount, - signalsTakenCount, - (int) bias, - timeout); - - /* Cleanup */ - assert(pthread_barrier_destroy(&holdBarrier) == 0); - assert(pthread_barrier_destroy(&readyBarrier) == 0); - assert(pthread_barrier_destroy(&startBarrier) == 0); - assert(pthread_cond_destroy(&control.cv) == 0); - assert(pthread_mutex_destroy(&control.mx) == 0); - - /* Success. */ - return 0; -} diff --git a/deps/w32-pthreads/tests/test.h b/deps/w32-pthreads/tests/test.h deleted file mode 100644 index 1756a64..0000000 --- a/deps/w32-pthreads/tests/test.h +++ /dev/null @@ -1,182 +0,0 @@ -/* - * test.h - * - * Useful definitions and declarations for tests. - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - */ - -#ifndef _PTHREAD_TEST_H_ -#define _PTHREAD_TEST_H_ - -#include "pthread.h" -#include "sched.h" -#include "semaphore.h" - -#include -#include - -#define PTW32_THREAD_NULL_ID {NULL,0} - -/* - * Some non-thread POSIX API substitutes - */ -#define rand_r( _seed ) \ - ( _seed == _seed? rand() : rand() ) - -#if defined(__MINGW32__) -#include -#elif defined(__BORLANDC__) -#define int64_t ULONGLONG -#else -#define int64_t _int64 -#endif - -#if defined(_MSC_VER) && _MSC_VER >= 1400 -# define PTW32_FTIME(x) _ftime64_s(x) -# define PTW32_STRUCT_TIMEB struct __timeb64 -#elif ( defined(_MSC_VER) && _MSC_VER >= 1300 ) || \ - ( defined(__MINGW32__) && __MSVCRT_VERSION__ >= 0x0601 ) -# define PTW32_FTIME(x) _ftime64(x) -# define PTW32_STRUCT_TIMEB struct __timeb64 -#else -# define PTW32_FTIME(x) _ftime(x) -# define PTW32_STRUCT_TIMEB struct _timeb -#endif - - -const char * error_string[] = { - "ZERO_or_EOK", - "EPERM", - "ENOFILE_or_ENOENT", - "ESRCH", - "EINTR", - "EIO", - "ENXIO", - "E2BIG", - "ENOEXEC", - "EBADF", - "ECHILD", - "EAGAIN", - "ENOMEM", - "EACCES", - "EFAULT", - "UNKNOWN_15", - "EBUSY", - "EEXIST", - "EXDEV", - "ENODEV", - "ENOTDIR", - "EISDIR", - "EINVAL", - "ENFILE", - "EMFILE", - "ENOTTY", - "UNKNOWN_26", - "EFBIG", - "ENOSPC", - "ESPIPE", - "EROFS", - "EMLINK", - "EPIPE", - "EDOM", - "ERANGE", - "UNKNOWN_35", - "EDEADLOCK_or_EDEADLK", - "UNKNOWN_37", - "ENAMETOOLONG", - "ENOLCK", - "ENOSYS", - "ENOTEMPTY", - "EILSEQ", - "EOWNERDEAD", - "ENOTRECOVERABLE" -}; - -/* - * The Mingw32 assert macro calls the CRTDLL _assert function - * which pops up a dialog. We want to run in batch mode so - * we define our own assert macro. - */ -#ifdef assert -# undef assert -#endif - -#ifndef ASSERT_TRACE -# define ASSERT_TRACE 0 -#else -# undef ASSERT_TRACE -# define ASSERT_TRACE 1 -#endif - -# define assert(e) \ - ((e) ? ((ASSERT_TRACE) ? fprintf(stderr, \ - "Assertion succeeded: (%s), file %s, line %d\n", \ - #e, __FILE__, (int) __LINE__), \ - fflush(stderr) : \ - 0) : \ - (fprintf(stderr, "Assertion failed: (%s), file %s, line %d\n", \ - #e, __FILE__, (int) __LINE__), exit(1), 0)) - -int assertE; -# define assert_e(e, o, r) \ - (((assertE = e) o (r)) ? ((ASSERT_TRACE) ? fprintf(stderr, \ - "Assertion succeeded: (%s), file %s, line %d\n", \ - #e, __FILE__, (int) __LINE__), \ - fflush(stderr) : \ - 0) : \ - (fprintf(stderr, "Assertion failed: (%s %s %s), file %s, line %d, error %s\n", \ - #e,#o,#r, __FILE__, (int) __LINE__, error_string[assertE]), exit(1), 0)) - -#endif - -# define BEGIN_MUTEX_STALLED_ROBUST(mxAttr) \ - for(;;) \ - { \ - static int _i=0; \ - static int _robust; \ - pthread_mutexattr_getrobust(&(mxAttr), &_robust); - -# define END_MUTEX_STALLED_ROBUST(mxAttr) \ - printf("Pass %s\n", _robust==PTHREAD_MUTEX_ROBUST?"Robust":"Non-robust"); \ - if (++_i > 1) \ - break; \ - else \ - { \ - pthread_mutexattr_t *pma, *pmaEnd; \ - for(pma = &(mxAttr), pmaEnd = pma + sizeof(mxAttr)/sizeof(pthread_mutexattr_t); \ - pma < pmaEnd; \ - pthread_mutexattr_setrobust(pma++, PTHREAD_MUTEX_ROBUST)); \ - } \ - } - -# define IS_ROBUST (_robust==PTHREAD_MUTEX_ROBUST) diff --git a/deps/w32-pthreads/tests/tryentercs.c b/deps/w32-pthreads/tests/tryentercs.c deleted file mode 100644 index 2f606ec..0000000 --- a/deps/w32-pthreads/tests/tryentercs.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * tryentercs.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * See if we have the TryEnterCriticalSection function. - * Does not use any part of pthreads. - */ - -#include -#include -#include - -/* - * Function pointer to TryEnterCriticalSection if it exists - * - otherwise NULL - */ -BOOL (WINAPI *_try_enter_critical_section)(LPCRITICAL_SECTION) = -NULL; - -/* - * Handle to kernel32.dll - */ -static HINSTANCE _h_kernel32; - - -int -main() -{ - CRITICAL_SECTION cs; - - SetLastError(0); - - printf("Last Error [main enter] %ld\n", (long) GetLastError()); - - /* - * Load KERNEL32 and try to get address of TryEnterCriticalSection - */ - _h_kernel32 = LoadLibrary(TEXT("KERNEL32.DLL")); - _try_enter_critical_section = - (BOOL (PT_STDCALL *)(LPCRITICAL_SECTION)) - GetProcAddress(_h_kernel32, - (LPCSTR) "TryEnterCriticalSection"); - - if (_try_enter_critical_section != NULL) - { - InitializeCriticalSection(&cs); - - SetLastError(0); - - if ((*_try_enter_critical_section)(&cs) != 0) - { - LeaveCriticalSection(&cs); - } - else - { - printf("Last Error [try enter] %ld\n", (long) GetLastError()); - - _try_enter_critical_section = NULL; - } - DeleteCriticalSection(&cs); - } - - (void) FreeLibrary(_h_kernel32); - - printf("This system %s TryEnterCriticalSection.\n", - (_try_enter_critical_section == NULL) ? "DOES NOT SUPPORT" : "SUPPORTS"); - printf("POSIX Mutexes will be based on Win32 %s.\n", - (_try_enter_critical_section == NULL) ? "Mutexes" : "Critical Sections"); - - return(0); -} - diff --git a/deps/w32-pthreads/tests/tryentercs2.c b/deps/w32-pthreads/tests/tryentercs2.c deleted file mode 100644 index eeba906..0000000 --- a/deps/w32-pthreads/tests/tryentercs2.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * tryentercs.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * See if we have the TryEnterCriticalSection function. - * Does not use any part of pthreads. - */ - -#include -#include -#include - -/* - * Function pointer to TryEnterCriticalSection if it exists - * - otherwise NULL - */ -BOOL (WINAPI *_try_enter_critical_section)(LPCRITICAL_SECTION) = NULL; - -/* - * Handle to kernel32.dll - */ -static HINSTANCE _h_kernel32; - - -int -main() -{ - LPCRITICAL_SECTION lpcs = NULL; - - SetLastError(0); - - printf("Last Error [main enter] %ld\n", (long) GetLastError()); - - /* - * Load KERNEL32 and try to get address of TryEnterCriticalSection - */ - _h_kernel32 = LoadLibrary(TEXT("KERNEL32.DLL")); - _try_enter_critical_section = - (BOOL (PT_STDCALL *)(LPCRITICAL_SECTION)) - GetProcAddress(_h_kernel32, - (LPCSTR) "TryEnterCriticalSection"); - - if (_try_enter_critical_section != NULL) - { - SetLastError(0); - - (*_try_enter_critical_section)(lpcs); - - printf("Last Error [try enter] %ld\n", (long) GetLastError()); - } - - (void) FreeLibrary(_h_kernel32); - - printf("This system %s TryEnterCriticalSection.\n", - (_try_enter_critical_section == NULL) ? "DOES NOT SUPPORT" : "SUPPORTS"); - printf("POSIX Mutexes will be based on Win32 %s.\n", - (_try_enter_critical_section == NULL) ? "Mutexes" : "Critical Sections"); - - return(0); -} - diff --git a/deps/w32-pthreads/tests/tsd1.c b/deps/w32-pthreads/tests/tsd1.c deleted file mode 100644 index d2e9c9f..0000000 --- a/deps/w32-pthreads/tests/tsd1.c +++ /dev/null @@ -1,209 +0,0 @@ -/* - * tsd1.c - * - * Test Thread Specific Data (TSD) key creation and destruction. - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * - * -------------------------------------------------------------------------- - * - * Description: - * - - * - * Test Method (validation or falsification): - * - validation - * - * Requirements Tested: - * - keys are created for each existing thread including the main thread - * - keys are created for newly created threads - * - keys are thread specific - * - destroy routine is called on each thread exit including the main thread - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Environment: - * - - * - * Input: - * - none - * - * Output: - * - text to stdout - * - * Assumptions: - * - already validated: pthread_create() - * pthread_once() - * - main thread also has a POSIX thread identity - * - * Pass Criteria: - * - stdout matches file reference/tsd1.out - * - * Fail Criteria: - * - fails to match file reference/tsd1.out - * - output identifies failed component - */ - -#include -#include "test.h" - -enum { - NUM_THREADS = 100 -}; - -static pthread_key_t key = NULL; -static int accesscount[NUM_THREADS]; -static int thread_set[NUM_THREADS]; -static int thread_destroyed[NUM_THREADS]; -static pthread_barrier_t startBarrier; - -static void -destroy_key(void * arg) -{ - int * j = (int *) arg; - - (*j)++; - - assert(*j == 2); - - thread_destroyed[j - accesscount] = 1; -} - -static void -setkey(void * arg) -{ - int * j = (int *) arg; - - thread_set[j - accesscount] = 1; - - assert(*j == 0); - - assert(pthread_getspecific(key) == NULL); - - assert(pthread_setspecific(key, arg) == 0); - assert(pthread_setspecific(key, arg) == 0); - assert(pthread_setspecific(key, arg) == 0); - - assert(pthread_getspecific(key) == arg); - - (*j)++; - - assert(*j == 1); -} - -static void * -mythread(void * arg) -{ - (void) pthread_barrier_wait(&startBarrier); - - setkey(arg); - - return 0; - - /* Exiting the thread will call the key destructor. */ -} - -int -main() -{ - int i; - int fail = 0; - pthread_t thread[NUM_THREADS]; - - assert(pthread_barrier_init(&startBarrier, NULL, NUM_THREADS/2) == 0); - - for (i = 1; i < NUM_THREADS/2; i++) - { - accesscount[i] = thread_set[i] = thread_destroyed[i] = 0; - assert(pthread_create(&thread[i], NULL, mythread, (void *)&accesscount[i]) == 0); - } - - /* - * Here we test that existing threads will get a key created - * for them. - */ - assert(pthread_key_create(&key, destroy_key) == 0); - - (void) pthread_barrier_wait(&startBarrier); - - /* - * Test main thread key. - */ - accesscount[0] = 0; - setkey((void *) &accesscount[0]); - - /* - * Here we test that new threads will get a key created - * for them. - */ - for (i = NUM_THREADS/2; i < NUM_THREADS; i++) - { - accesscount[i] = thread_set[i] = thread_destroyed[i] = 0; - assert(pthread_create(&thread[i], NULL, mythread, (void *)&accesscount[i]) == 0); - } - - /* - * Wait for all threads to complete. - */ - for (i = 1; i < NUM_THREADS; i++) - { - assert(pthread_join(thread[i], NULL) == 0); - } - - assert(pthread_key_delete(key) == 0); - - assert(pthread_barrier_destroy(&startBarrier) == 0); - - for (i = 1; i < NUM_THREADS; i++) - { - /* - * The counter is incremented once when the key is set to - * a value, and again when the key is destroyed. If the key - * doesn't get set for some reason then it will still be - * NULL and the destroy function will not be called, and - * hence accesscount will not equal 2. - */ - if (accesscount[i] != 2) - { - fail++; - fprintf(stderr, "Thread %d key, set = %d, destroyed = %d\n", - i, thread_set[i], thread_destroyed[i]); - } - } - - fflush(stderr); - - return (fail); -} diff --git a/deps/w32-pthreads/tests/tsd2.c b/deps/w32-pthreads/tests/tsd2.c deleted file mode 100644 index 97082ed..0000000 --- a/deps/w32-pthreads/tests/tsd2.c +++ /dev/null @@ -1,213 +0,0 @@ -/* - * tsd2.c - * - * Test Thread Specific Data (TSD) key creation and destruction. - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * - * -------------------------------------------------------------------------- - * - * Description: - * - - * - * Test Method (validation or falsification): - * - validation - * - * Requirements Tested: - * - keys are created for each existing thread including the main thread - * - keys are created for newly created threads - * - keys are thread specific - * - destroy routine is called on each thread exit including the main thread - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Environment: - * - - * - * Input: - * - none - * - * Output: - * - text to stdout - * - * Assumptions: - * - already validated: pthread_create() - * pthread_once() - * - main thread also has a POSIX thread identity - * - * Pass Criteria: - * - stdout matches file reference/tsd1.out - * - * Fail Criteria: - * - fails to match file reference/tsd1.out - * - output identifies failed component - */ - -#include -#include "test.h" - -enum { - NUM_THREADS = 100 -}; - -static pthread_key_t key = NULL; -static int accesscount[NUM_THREADS]; -static int thread_set[NUM_THREADS]; -static int thread_destroyed[NUM_THREADS]; -static pthread_barrier_t startBarrier; - -static void -destroy_key(void * arg) -{ - int * j = (int *) arg; - - (*j)++; - - /* Set TSD key from the destructor to test destructor iteration */ - if (*j == 2) - assert(pthread_setspecific(key, arg) == 0); - else - assert(*j == 3); - - thread_destroyed[j - accesscount] = 1; -} - -static void -setkey(void * arg) -{ - int * j = (int *) arg; - - thread_set[j - accesscount] = 1; - - assert(*j == 0); - - assert(pthread_getspecific(key) == NULL); - - assert(pthread_setspecific(key, arg) == 0); - assert(pthread_setspecific(key, arg) == 0); - assert(pthread_setspecific(key, arg) == 0); - - assert(pthread_getspecific(key) == arg); - - (*j)++; - - assert(*j == 1); -} - -static void * -mythread(void * arg) -{ - (void) pthread_barrier_wait(&startBarrier); - - setkey(arg); - - return 0; - - /* Exiting the thread will call the key destructor. */ -} - -int -main() -{ - int i; - int fail = 0; - pthread_t thread[NUM_THREADS]; - - assert(pthread_barrier_init(&startBarrier, NULL, NUM_THREADS/2) == 0); - - for (i = 1; i < NUM_THREADS/2; i++) - { - accesscount[i] = thread_set[i] = thread_destroyed[i] = 0; - assert(pthread_create(&thread[i], NULL, mythread, (void *)&accesscount[i]) == 0); - } - - /* - * Here we test that existing threads will get a key created - * for them. - */ - assert(pthread_key_create(&key, destroy_key) == 0); - - (void) pthread_barrier_wait(&startBarrier); - - /* - * Test main thread key. - */ - accesscount[0] = 0; - setkey((void *) &accesscount[0]); - - /* - * Here we test that new threads will get a key created - * for them. - */ - for (i = NUM_THREADS/2; i < NUM_THREADS; i++) - { - accesscount[i] = thread_set[i] = thread_destroyed[i] = 0; - assert(pthread_create(&thread[i], NULL, mythread, (void *)&accesscount[i]) == 0); - } - - /* - * Wait for all threads to complete. - */ - for (i = 1; i < NUM_THREADS; i++) - { - assert(pthread_join(thread[i], NULL) == 0); - } - - assert(pthread_key_delete(key) == 0); - - assert(pthread_barrier_destroy(&startBarrier) == 0); - - for (i = 1; i < NUM_THREADS; i++) - { - /* - * The counter is incremented once when the key is set to - * a value, and again when the key is destroyed. If the key - * doesn't get set for some reason then it will still be - * NULL and the destroy function will not be called, and - * hence accesscount will not equal 2. - */ - if (accesscount[i] != 3) - { - fail++; - fprintf(stderr, "Thread %d key, set = %d, destroyed = %d\n", - i, thread_set[i], thread_destroyed[i]); - } - } - - fflush(stderr); - - return (fail); -} diff --git a/deps/w32-pthreads/tests/valid1.c b/deps/w32-pthreads/tests/valid1.c deleted file mode 100644 index 2db6095..0000000 --- a/deps/w32-pthreads/tests/valid1.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * File: valid1.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Test that thread validation works. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -enum { - NUMTHREADS = 1 -}; - -static int washere = 0; - -void * func(void * arg) -{ - washere = 1; - return (void *) 0; -} - -int -main() -{ - pthread_t t; - void * result = NULL; - - washere = 0; - assert(pthread_create(&t, NULL, func, NULL) == 0); - assert(pthread_join(t, &result) == 0); - assert((int)(size_t)result == 0); - assert(washere == 1); - sched_yield(); - assert(pthread_kill(t, 0) == ESRCH); - - return 0; -} diff --git a/deps/w32-pthreads/tests/valid2.c b/deps/w32-pthreads/tests/valid2.c deleted file mode 100644 index 4d14857..0000000 --- a/deps/w32-pthreads/tests/valid2.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * File: valid2.c - * - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * - * -------------------------------------------------------------------------- - * - * Test Synopsis: - * - Confirm that thread validation fails for garbage thread ID. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -int -main() -{ - pthread_t NullThread = PTW32_THREAD_NULL_ID; - - assert(pthread_kill(NullThread, 0) == ESRCH); - - return 0; -} diff --git a/deps/w32-pthreads/tsd.c b/deps/w32-pthreads/tsd.c deleted file mode 100644 index 9b4715b..0000000 --- a/deps/w32-pthreads/tsd.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * tsd.c - * - * Description: - * POSIX thread functions which implement thread-specific data (TSD). - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -#include "pthread_key_create.c" -#include "pthread_key_delete.c" -#include "pthread_setspecific.c" -#include "pthread_getspecific.c" diff --git a/deps/w32-pthreads/version.rc b/deps/w32-pthreads/version.rc deleted file mode 100644 index cac5304..0000000 --- a/deps/w32-pthreads/version.rc +++ /dev/null @@ -1,394 +0,0 @@ -/* This is an implementation of the threads API of POSIX 1003.1-2001. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include -#include "pthread.h" - -/* - * Note: the correct __CLEANUP_* macro must be defined corresponding to - * the definition used for the object file builds. This is done in the - * relevent makefiles for the command line builds, but users should ensure - * that their resource compiler knows what it is too. - * If using the default (no __CLEANUP_* defined), pthread.h will define it - * as __CLEANUP_C. - */ - -#if defined(__MINGW64__) -# define PTW32_ARCH "x64 (mingw64)" -#elif defined (__MINGW32__) -# define PTW32_ARCH "x86 (mingw32)" -#endif -#if defined(PTW32_ARCHx64) -# define PTW32_ARCH "x64" -#elif defined(PTW32_ARCHx86) -# define PTW32_ARCH "x86" -#endif - -#if defined(PTW32_RC_MSC) -# if defined(__CLEANUP_C) -# define PTW32_VERSIONINFO_NAME "pthreadVC2.DLL\0" -# define PTW32_VERSIONINFO_DESCRIPTION "MS C " PTW32_ARCH "\0" -# elif defined(__CLEANUP_CXX) -# define PTW32_VERSIONINFO_NAME "pthreadVCE2.DLL\0" -# define PTW32_VERSIONINFO_DESCRIPTION "MS C++ " PTW32_ARCH "\0" -# elif defined(__CLEANUP_SEH) -# define PTW32_VERSIONINFO_NAME "pthreadVSE2.DLL\0" -# define PTW32_VERSIONINFO_DESCRIPTION "MS C SEH " PTW32_ARCH "\0" -# else -# error Resource compiler doesn't know which cleanup style you're using - see version.rc -# endif -#elif defined(__GNUC__) -# if defined(__CLEANUP_C) -# define PTW32_VERSIONINFO_NAME "pthreadGC2.DLL\0" -# define PTW32_VERSIONINFO_DESCRIPTION "GNU C " PTW32_ARCH "\0" -# elif defined(__CLEANUP_CXX) -# define PTW32_VERSIONINFO_NAME "pthreadGCE2.DLL\0" -# define PTW32_VERSIONINFO_DESCRIPTION "GNU C++ " PTW32_ARCH "\0" -# else -# error Resource compiler doesn't know which cleanup style you're using - see version.rc -# endif -#elif defined(__BORLANDC__) -# if defined(__CLEANUP_C) -# define PTW32_VERSIONINFO_NAME "pthreadBC2.DLL\0" -# define PTW32_VERSIONINFO_DESCRIPTION "BORLAND C " PTW32_ARCH "\0" -# elif defined(__CLEANUP_CXX) -# define PTW32_VERSIONINFO_NAME "pthreadBCE2.DLL\0" -# define PTW32_VERSIONINFO_DESCRIPTION "BORLAND C++ " PTW32_ARCH "\0" -# else -# error Resource compiler doesn't know which cleanup style you're using - see version.rc -# endif -#elif defined(__WATCOMC__) -# if defined(__CLEANUP_C) -# define PTW32_VERSIONINFO_NAME "pthreadWC2.DLL\0" -# define PTW32_VERSIONINFO_DESCRIPTION "WATCOM C " PTW32_ARCH "\0" -# elif defined(__CLEANUP_CXX) -# define PTW32_VERSIONINFO_NAME "pthreadWCE2.DLL\0" -# define PTW32_VERSIONINFO_DESCRIPTION "WATCOM C++ " PTW32_ARCH "\0" -# else -# error Resource compiler doesn't know which cleanup style you're using - see version.rc -# endif -#else -# error Resource compiler doesn't know which compiler you're using - see version.rc -#endif - - -VS_VERSION_INFO VERSIONINFO - FILEVERSION PTW32_VERSION - PRODUCTVERSION PTW32_VERSION - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK - FILEFLAGS 0 - FILEOS VOS__WINDOWS32 - FILETYPE VFT_DLL -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "ProductName", "POSIX Threads for Windows LPGL\0" - VALUE "ProductVersion", PTW32_VERSION_STRING - VALUE "FileVersion", PTW32_VERSION_STRING - VALUE "FileDescription", PTW32_VERSIONINFO_DESCRIPTION - VALUE "InternalName", PTW32_VERSIONINFO_NAME - VALUE "OriginalFilename", PTW32_VERSIONINFO_NAME - VALUE "CompanyName", "Open Source Software community LGPL\0" - VALUE "LegalCopyright", "Copyright (C) Project contributors 2012\0" - VALUE "Comments", "http://sourceware.org/pthreads-win32/\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -/* -VERSIONINFO Resource - -The VERSIONINFO resource-definition statement creates a version-information -resource. The resource contains such information about the file as its -version number, its intended operating system, and its original filename. -The resource is intended to be used with the Version Information functions. - -versionID VERSIONINFO fixed-info { block-statement...} - -versionID - Version-information resource identifier. This value must be 1. - -fixed-info - Version information, such as the file version and the intended operating - system. This parameter consists of the following statements. - - - Statement Description - -------------------------------------------------------------------------- - FILEVERSION - version Binary version number for the file. The version - consists of two 32-bit integers, defined by four - 16-bit integers. For example, "FILEVERSION 3,10,0,61" - is translated into two doublewords: 0x0003000a and - 0x0000003d, in that order. Therefore, if version is - defined by the DWORD values dw1 and dw2, they need - to appear in the FILEVERSION statement as follows: - HIWORD(dw1), LOWORD(dw1), HIWORD(dw2), LOWORD(dw2). - PRODUCTVERSION - version Binary version number for the product with which the - file is distributed. The version parameter is two - 32-bit integers, defined by four 16-bit integers. - For more information about version, see the - FILEVERSION description. - FILEFLAGSMASK - fileflagsmask Bits in the FILEFLAGS statement are valid. If a bit - is set, the corresponding bit in FILEFLAGS is valid. - FILEFLAGSfileflags Attributes of the file. The fileflags parameter must - be the combination of all the file flags that are - valid at compile time. For 16-bit Windows, this - value is 0x3f. - FILEOSfileos Operating system for which this file was designed. - The fileos parameter can be one of the operating - system values given in the Remarks section. - FILETYPEfiletype General type of file. The filetype parameter can be - one of the file type values listed in the Remarks - section. - FILESUBTYPE - subtype Function of the file. The subtype parameter is zero - unless the type parameter in the FILETYPE statement - is VFT_DRV, VFT_FONT, or VFT_VXD. For a list of file - subtype values, see the Remarks section. - -block-statement - Specifies one or more version-information blocks. A block can contain - string information or variable information. For more information, see - StringFileInfo Block or VarFileInfo Block. - -Remarks - -To use the constants specified with the VERSIONINFO statement, you must -include the Winver.h or Windows.h header file in the resource-definition file. - -The following list describes the parameters used in the VERSIONINFO statement: - -fileflags - A combination of the following values. - - Value Description - - VS_FF_DEBUG File contains debugging information or is compiled - with debugging features enabled. - VS_FF_PATCHED File has been modified and is not identical to the - original shipping file of the same version number. - VS_FF_PRERELEASE File is a development version, not a commercially - released product. - VS_FF_PRIVATEBUILD File was not built using standard release procedures. - If this value is given, the StringFileInfo block must - contain a PrivateBuild string. - VS_FF_SPECIALBUILD File was built by the original company using standard - release procedures but is a variation of the standard - file of the same version number. If this value is - given, the StringFileInfo block must contain a - SpecialBuild string. - -fileos - One of the following values. - - Value Description - - VOS_UNKNOWN The operating system for which the file was designed - is unknown. - VOS_DOS File was designed for MS-DOS. - VOS_NT File was designed for Windows Server 2003 family, - Windows XP, Windows 2000, or Windows NT. - VOS__WINDOWS16 File was designed for 16-bit Windows. - VOS__WINDOWS32 File was designed for 32-bit Windows. - VOS_DOS_WINDOWS16 File was designed for 16-bit Windows running with - MS-DOS. - VOS_DOS_WINDOWS32 File was designed for 32-bit Windows running with - MS-DOS. - VOS_NT_WINDOWS32 File was designed for Windows Server 2003 family, - Windows XP, Windows 2000, or Windows NT. - - The values 0x00002L, 0x00003L, 0x20000L and 0x30000L are reserved. - -filetype - One of the following values. - - Value Description - - VFT_UNKNOWN File type is unknown. - VFT_APP File contains an application. - VFT_DLL File contains a dynamic-link library (DLL). - VFT_DRV File contains a device driver. If filetype is - VFT_DRV, subtype contains a more specific - description of the driver. - VFT_FONT File contains a font. If filetype is VFT_FONT, - subtype contains a more specific description of the - font. - VFT_VXD File contains a virtual device. - VFT_STATIC_LIB File contains a static-link library. - - All other values are reserved for use by Microsoft. - -subtype - Additional information about the file type. - - If filetype specifies VFT_DRV, this parameter can be one of the - following values. - - Value Description - - VFT2_UNKNOWN Driver type is unknown. - VFT2_DRV_COMM File contains a communications driver. - VFT2_DRV_PRINTER File contains a printer driver. - VFT2_DRV_KEYBOARD File contains a keyboard driver. - VFT2_DRV_LANGUAGE File contains a language driver. - VFT2_DRV_DISPLAY File contains a display driver. - VFT2_DRV_MOUSE File contains a mouse driver. - VFT2_DRV_NETWORK File contains a network driver. - VFT2_DRV_SYSTEM File contains a system driver. - VFT2_DRV_INSTALLABLE File contains an installable driver. - VFT2_DRV_SOUND File contains a sound driver. - VFT2_DRV_VERSIONED_PRINTER File contains a versioned printer driver. - - If filetype specifies VFT_FONT, this parameter can be one of the - following values. - - Value Description - - VFT2_UNKNOWN Font type is unknown. - VFT2_FONT_RASTER File contains a raster font. - VFT2_FONT_VECTOR File contains a vector font. - VFT2_FONT_TRUETYPE File contains a TrueType font. - - If filetype specifies VFT_VXD, this parameter must be the virtual-device - identifier included in the virtual-device control block. - - All subtype values not listed here are reserved for use by Microsoft. - -langID - One of the following language codes. - - Code Language Code Language - - 0x0401 Arabic 0x0415 Polish - 0x0402 Bulgarian 0x0416 Portuguese (Brazil) - 0x0403 Catalan 0x0417 Rhaeto-Romanic - 0x0404 Traditional Chinese 0x0418 Romanian - 0x0405 Czech 0x0419 Russian - 0x0406 Danish 0x041A Croato-Serbian (Latin) - 0x0407 German 0x041B Slovak - 0x0408 Greek 0x041C Albanian - 0x0409 U.S. English 0x041D Swedish - 0x040A Castilian Spanish 0x041E Thai - 0x040B Finnish 0x041F Turkish - 0x040C French 0x0420 Urdu - 0x040D Hebrew 0x0421 Bahasa - 0x040E Hungarian 0x0804 Simplified Chinese - 0x040F Icelandic 0x0807 Swiss German - 0x0410 Italian 0x0809 U.K. English - 0x0411 Japanese 0x080A Mexican Spanish - 0x0412 Korean 0x080C Belgian French - 0x0413 Dutch 0x0C0C Canadian French - 0x0414 Norwegian ā€“ Bokmal 0x100C Swiss French - 0x0810 Swiss Italian 0x0816 Portuguese (Portugal) - 0x0813 Belgian Dutch 0x081A Serbo-Croatian (Cyrillic) - 0x0814 Norwegian ā€“ Nynorsk - -charsetID - One of the following character-set identifiers. - - Identifier Character Set - - 0 7-bit ASCII - 932 Japan (Shift %Gā€“%@ JIS X-0208) - 949 Korea (Shift %Gā€“%@ KSC 5601) - 950 Taiwan (Big5) - 1200 Unicode - 1250 Latin-2 (Eastern European) - 1251 Cyrillic - 1252 Multilingual - 1253 Greek - 1254 Turkish - 1255 Hebrew - 1256 Arabic - -string-name - One of the following predefined names. - - Name Description - - Comments Additional information that should be displayed for - diagnostic purposes. - CompanyName Company that produced the file%Gā€”%@for example, - "Microsoft Corporation" or "Standard Microsystems - Corporation, Inc." This string is required. - FileDescription File description to be presented to users. This - string may be displayed in a list box when the user - is choosing files to install%Gā€”%@for example, - "Keyboard Driver for AT-Style Keyboards". This - string is required. - FileVersion Version number of the file%Gā€”%@for example, - "3.10" or "5.00.RC2". This string is required. - InternalName Internal name of the file, if one exists ā€” for - example, a module name if the file is a dynamic-link - library. If the file has no internal name, this - string should be the original filename, without - extension. This string is required. - LegalCopyright Copyright notices that apply to the file. This - should include the full text of all notices, legal - symbols, copyright dates, and so on ā€” for example, - "Copyright (C) Microsoft Corporation 1990ā€“1999". - This string is optional. - LegalTrademarks Trademarks and registered trademarks that apply to - the file. This should include the full text of all - notices, legal symbols, trademark numbers, and so on. - This string is optional. - OriginalFilename Original name of the file, not including a path. - This information enables an application to determine - whether a file has been renamed by a user. The - format of the name depends on the file system for - which the file was created. This string is required. - PrivateBuild Information about a private version of the file ā€” for - example, "Built by TESTER1 on \TESTBED". This string - should be present only if VS_FF_PRIVATEBUILD is - specified in the fileflags parameter of the root - block. - ProductName Name of the product with which the file is - distributed. This string is required. - ProductVersion Version of the product with which the file is - distributed ā€” for example, "3.10" or "5.00.RC2". - This string is required. - SpecialBuild Text that indicates how this version of the file - differs from the standard version ā€” for example, - "Private build for TESTER1 solving mouse problems - on M250 and M250E computers". This string should be - present only if VS_FF_SPECIALBUILD is specified in - the fileflags parameter of the root block. - */ diff --git a/deps/w32-pthreads/w32-pthreadsConfig.cmake.in b/deps/w32-pthreads/w32-pthreadsConfig.cmake.in deleted file mode 100644 index 2fe4aec..0000000 --- a/deps/w32-pthreads/w32-pthreadsConfig.cmake.in +++ /dev/null @@ -1,15 +0,0 @@ -# - Config file for the w32-pthreads package -# It defines the following variables -# THREADS_INCLUDE_DIRS -# THREADS_LIBRARIES - -set(W32_PTHREADS_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@") - -# Cleanup possible relative paths -get_filename_component(W32_PTHREADS_INCLUDE_DIRS "${THREADS_INCLUDE_DIRS}" ABSOLUTE) - -if(NOT TARGET w32-pthreads) - include("${CMAKE_CURRENT_LIST_DIR}/w32-pthreadsTarget.cmake") -endif() - -set(W32_PTHREADS_LIBRARIES w32-pthreads) diff --git a/deps/w32-pthreads/w32-pthreadsConfigVersion.cmake.in b/deps/w32-pthreads/w32-pthreadsConfigVersion.cmake.in deleted file mode 100644 index e69de29..0000000 diff --git a/deps/w32-pthreads/w32_CancelableWait.c b/deps/w32-pthreads/w32_CancelableWait.c deleted file mode 100644 index eb4c611..0000000 --- a/deps/w32-pthreads/w32_CancelableWait.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - * w32_CancelableWait.c - * - * Description: - * This translation unit implements miscellaneous thread functions. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "pthread.h" -#include "implement.h" - - -static INLINE int -ptw32_cancelable_wait (HANDLE waitHandle, DWORD timeout) - /* - * ------------------------------------------------------------------- - * This provides an extra hook into the pthread_cancel - * mechanism that will allow you to wait on a Windows handle and make it a - * cancellation point. This function blocks until the given WIN32 handle is - * signaled or pthread_cancel has been called. It is implemented using - * WaitForMultipleObjects on 'waitHandle' and a manually reset WIN32 - * event used to implement pthread_cancel. - * - * Given this hook it would be possible to implement more of the cancellation - * points. - * ------------------------------------------------------------------- - */ -{ - int result; - pthread_t self; - ptw32_thread_t * sp; - HANDLE handles[2]; - DWORD nHandles = 1; - DWORD status; - - handles[0] = waitHandle; - - self = pthread_self(); - sp = (ptw32_thread_t *) self.p; - - if (sp != NULL) - { - /* - * Get cancelEvent handle - */ - if (sp->cancelState == PTHREAD_CANCEL_ENABLE) - { - - if ((handles[1] = sp->cancelEvent) != NULL) - { - nHandles++; - } - } - } - else - { - handles[1] = NULL; - } - - status = WaitForMultipleObjects (nHandles, handles, PTW32_FALSE, timeout); - - switch (status - WAIT_OBJECT_0) - { - case 0: - /* - * Got the handle. - * In the event that both handles are signalled, the smallest index - * value (us) is returned. As it has been arranged, this ensures that - * we don't drop a signal that we should act on (i.e. semaphore, - * mutex, or condition variable etc). - */ - result = 0; - break; - - case 1: - /* - * Got cancel request. - * In the event that both handles are signaled, the cancel will - * be ignored (see case 0 comment). - */ - ResetEvent (handles[1]); - - if (sp != NULL) - { - ptw32_mcs_local_node_t stateLock; - /* - * Should handle POSIX and implicit POSIX threads.. - * Make sure we haven't been async-canceled in the meantime. - */ - ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); - if (sp->state < PThreadStateCanceling) - { - sp->state = PThreadStateCanceling; - sp->cancelState = PTHREAD_CANCEL_DISABLE; - ptw32_mcs_lock_release (&stateLock); - ptw32_throw (PTW32_EPS_CANCEL); - - /* Never reached */ - } - ptw32_mcs_lock_release (&stateLock); - } - - /* Should never get to here. */ - result = EINVAL; - break; - - default: - if (status == WAIT_TIMEOUT) - { - result = ETIMEDOUT; - } - else - { - result = EINVAL; - } - break; - } - - return (result); - -} /* CancelableWait */ - -int -pthreadCancelableWait (HANDLE waitHandle) -{ - return (ptw32_cancelable_wait (waitHandle, INFINITE)); -} - -int -pthreadCancelableTimedWait (HANDLE waitHandle, DWORD timeout) -{ - return (ptw32_cancelable_wait (waitHandle, timeout)); -}