Loading include/config-win.h +3 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,9 @@ /* We have to do this define before including windows.h to get the AWE API functions */ #define _WIN32_WINNT 0x0500 #else /* Get NT 4.0 functions */ #define _WIN32_WINNT 0x0400 #endif #if defined(_MSC_VER) && _MSC_VER >= 1400 Loading include/my_pthread.h +5 −4 Original line number Diff line number Diff line Loading @@ -116,6 +116,7 @@ struct timespec { void win_pthread_init(void); int win_pthread_setspecific(void *A,void *B,uint length); int win_pthread_mutex_trylock(pthread_mutex_t *mutex); int pthread_create(pthread_t *,pthread_attr_t *,pthread_handler,void *); int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr); int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex); Loading Loading @@ -176,7 +177,7 @@ extern int pthread_mutex_destroy (pthread_mutex_t *); #else #define pthread_mutex_init(A,B) (InitializeCriticalSection(A),0) #define pthread_mutex_lock(A) (EnterCriticalSection(A),0) #define pthread_mutex_trylock(A) (WaitForSingleObject((A), 0) == WAIT_TIMEOUT) #define pthread_mutex_trylock(A) win_pthread_mutex_trylock((A)) #define pthread_mutex_unlock(A) LeaveCriticalSection(A) #define pthread_mutex_destroy(A) DeleteCriticalSection(A) #define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B)) Loading Loading @@ -574,7 +575,7 @@ typedef struct st_safe_mutex_info_t int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr, const char *file, uint line); int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line); int safe_mutex_lock(safe_mutex_t *mp, my_bool try_lock, const char *file, uint line); int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line); int safe_mutex_destroy(safe_mutex_t *mp,const char *file, uint line); int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp,const char *file, Loading @@ -597,12 +598,12 @@ void safe_mutex_end(FILE *file); #undef pthread_cond_timedwait #undef pthread_mutex_trylock #define pthread_mutex_init(A,B) safe_mutex_init((A),(B),__FILE__,__LINE__) #define pthread_mutex_lock(A) safe_mutex_lock((A),__FILE__,__LINE__) #define pthread_mutex_lock(A) safe_mutex_lock((A), FALSE, __FILE__, __LINE__) #define pthread_mutex_unlock(A) safe_mutex_unlock((A),__FILE__,__LINE__) #define pthread_mutex_destroy(A) safe_mutex_destroy((A),__FILE__,__LINE__) #define pthread_cond_wait(A,B) safe_cond_wait((A),(B),__FILE__,__LINE__) #define pthread_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__) #define pthread_mutex_trylock(A) pthread_mutex_lock(A) #define pthread_mutex_trylock(A) safe_mutex_lock((A), TRUE, __FILE__, __LINE__) #define pthread_mutex_t safe_mutex_t #define safe_mutex_assert_owner(mp) \ DBUG_ASSERT((mp)->count > 0 && \ Loading mysql-test/r/sp.result +176 −0 Original line number Diff line number Diff line Loading @@ -6389,4 +6389,180 @@ DROP TABLE t1; DROP PROCEDURE p1; DROP PROCEDURE p2; # # Bug#31035. # # # - Prepare. # DROP TABLE IF EXISTS t1; DROP FUNCTION IF EXISTS f1; DROP FUNCTION IF EXISTS f2; DROP FUNCTION IF EXISTS f3; DROP FUNCTION IF EXISTS f4; # # - Create required objects. # CREATE TABLE t1(c1 INT); INSERT INTO t1 VALUES (1), (2), (3); CREATE FUNCTION f1() RETURNS INT NOT DETERMINISTIC RETURN 1; CREATE FUNCTION f2(p INT) RETURNS INT NOT DETERMINISTIC RETURN 1; CREATE FUNCTION f3() RETURNS INT DETERMINISTIC RETURN 1; CREATE FUNCTION f4(p INT) RETURNS INT DETERMINISTIC RETURN 1; # # - Check. # SELECT f1() AS a FROM t1 GROUP BY a; a 1 SELECT f2(@a) AS a FROM t1 GROUP BY a; a 1 SELECT f3() AS a FROM t1 GROUP BY a; a 1 SELECT f4(0) AS a FROM t1 GROUP BY a; a 1 SELECT f4(@a) AS a FROM t1 GROUP BY a; a 1 # # - Cleanup. # DROP TABLE t1; DROP FUNCTION f1; DROP FUNCTION f2; DROP FUNCTION f3; DROP FUNCTION f4; # # Bug#31191. # # # - Prepare. # DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t2; DROP FUNCTION IF EXISTS f1; # # - Create required objects. # CREATE TABLE t1 ( id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, barcode INT(8) UNSIGNED ZEROFILL nOT NULL, PRIMARY KEY (id), UNIQUE KEY barcode (barcode) ); INSERT INTO t1 (id, barcode) VALUES (1, 12345678); INSERT INTO t1 (id, barcode) VALUES (2, 12345679); CREATE TABLE test.t2 ( id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, barcode BIGINT(11) UNSIGNED ZEROFILL NOT NULL, PRIMARY KEY (id) ); INSERT INTO test.t2 (id, barcode) VALUES (1, 12345106708); INSERT INTO test.t2 (id, barcode) VALUES (2, 12345106709); CREATE FUNCTION f1(p INT(8)) RETURNS BIGINT(11) UNSIGNED READS SQL DATA RETURN FLOOR(p/1000)*1000000 + 100000 + FLOOR((p MOD 1000)/10)*100 + (p MOD 10); # # - Check. # SELECT DISTINCT t1.barcode, f1(t1.barcode) FROM t1 INNER JOIN t2 ON f1(t1.barcode) = t2.barcode WHERE t1.barcode=12345678; barcode f1(t1.barcode) 12345678 12345106708 # # - Cleanup. # DROP TABLE t1; DROP TABLE t2; DROP FUNCTION f1; # # Bug#31226. # # # - Prepare. # DROP TABLE IF EXISTS t1; DROP FUNCTION IF EXISTS f1; # # - Create required objects. # CREATE TABLE t1(id INT); INSERT INTO t1 VALUES (1), (2), (3); CREATE FUNCTION f1() RETURNS DATETIME NOT DETERMINISTIC NO SQL RETURN NOW(); # # - Check. # SELECT f1() FROM t1 GROUP BY 1; f1() <timestamp> # # - Cleanup. # DROP TABLE t1; DROP FUNCTION f1; End of 5.0 tests mysql-test/t/sp.test +290 −0 Original line number Diff line number Diff line Loading @@ -7387,4 +7387,294 @@ DROP TABLE t1; DROP PROCEDURE p1; DROP PROCEDURE p2; ########################################################################### # # Bug#31035: select from function, group by result crasher. # ########################################################################### --echo --echo # --echo # Bug#31035. --echo # --echo --echo # --echo # - Prepare. --echo # --echo --disable_warnings DROP TABLE IF EXISTS t1; DROP FUNCTION IF EXISTS f1; DROP FUNCTION IF EXISTS f2; DROP FUNCTION IF EXISTS f3; DROP FUNCTION IF EXISTS f4; --enable_warnings --echo --echo # --echo # - Create required objects. --echo # --echo CREATE TABLE t1(c1 INT); --echo INSERT INTO t1 VALUES (1), (2), (3); --echo CREATE FUNCTION f1() RETURNS INT NOT DETERMINISTIC RETURN 1; --echo CREATE FUNCTION f2(p INT) RETURNS INT NOT DETERMINISTIC RETURN 1; --echo CREATE FUNCTION f3() RETURNS INT DETERMINISTIC RETURN 1; --echo CREATE FUNCTION f4(p INT) RETURNS INT DETERMINISTIC RETURN 1; --echo --echo # --echo # - Check. --echo # --echo # Not deterministic function, no arguments. SELECT f1() AS a FROM t1 GROUP BY a; --echo # Not deterministic function, non-constant argument. SELECT f2(@a) AS a FROM t1 GROUP BY a; --echo # Deterministic function, no arguments. SELECT f3() AS a FROM t1 GROUP BY a; --echo # Deterministic function, constant argument. SELECT f4(0) AS a FROM t1 GROUP BY a; --echo # Deterministic function, non-constant argument. SELECT f4(@a) AS a FROM t1 GROUP BY a; --echo --echo # --echo # - Cleanup. --echo # --echo DROP TABLE t1; DROP FUNCTION f1; DROP FUNCTION f2; DROP FUNCTION f3; DROP FUNCTION f4; --echo ########################################################################### # # Bug#31191: JOIN in combination with stored function crashes the server. # ########################################################################### --echo # --echo # Bug#31191. --echo # --echo --echo # --echo # - Prepare. --echo # --echo --disable_warnings DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t2; DROP FUNCTION IF EXISTS f1; --enable_warnings --echo --echo # --echo # - Create required objects. --echo # --echo CREATE TABLE t1 ( id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, barcode INT(8) UNSIGNED ZEROFILL nOT NULL, PRIMARY KEY (id), UNIQUE KEY barcode (barcode) ); --echo INSERT INTO t1 (id, barcode) VALUES (1, 12345678); INSERT INTO t1 (id, barcode) VALUES (2, 12345679); --echo CREATE TABLE test.t2 ( id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, barcode BIGINT(11) UNSIGNED ZEROFILL NOT NULL, PRIMARY KEY (id) ); --echo INSERT INTO test.t2 (id, barcode) VALUES (1, 12345106708); INSERT INTO test.t2 (id, barcode) VALUES (2, 12345106709); --echo CREATE FUNCTION f1(p INT(8)) RETURNS BIGINT(11) UNSIGNED READS SQL DATA RETURN FLOOR(p/1000)*1000000 + 100000 + FLOOR((p MOD 1000)/10)*100 + (p MOD 10); --echo --echo # --echo # - Check. --echo # --echo SELECT DISTINCT t1.barcode, f1(t1.barcode) FROM t1 INNER JOIN t2 ON f1(t1.barcode) = t2.barcode WHERE t1.barcode=12345678; --echo --echo # --echo # - Cleanup. --echo # --echo DROP TABLE t1; DROP TABLE t2; DROP FUNCTION f1; --echo ########################################################################### # # Bug#31226: Group by function crashes mysql. # ########################################################################### --echo # --echo # Bug#31226. --echo # --echo --echo # --echo # - Prepare. --echo # --echo --disable_warnings DROP TABLE IF EXISTS t1; DROP FUNCTION IF EXISTS f1; --enable_warnings --echo --echo # --echo # - Create required objects. --echo # --echo CREATE TABLE t1(id INT); --echo INSERT INTO t1 VALUES (1), (2), (3); --echo CREATE FUNCTION f1() RETURNS DATETIME NOT DETERMINISTIC NO SQL RETURN NOW(); --echo --echo # --echo # - Check. --echo # --echo --replace_column 1 <timestamp> SELECT f1() FROM t1 GROUP BY 1; --echo --echo # --echo # - Cleanup. --echo # --echo DROP TABLE t1; DROP FUNCTION f1; --echo ########################################################################### --echo End of 5.0 tests mysys/my_winthread.c +23 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,29 @@ void win_pthread_init(void) pthread_mutex_init(&THR_LOCK_thread,MY_MUTEX_INIT_FAST); } /** Adapter to @c pthread_mutex_trylock() @retval 0 Mutex was acquired @retval EBUSY Mutex was already locked by a thread */ int win_pthread_mutex_trylock(pthread_mutex_t *mutex) { if (TryEnterCriticalSection(mutex)) { /* Don't allow recursive lock */ if (mutex->RecursionCount > 1){ LeaveCriticalSection(mutex); return EBUSY; } return 0; } return EBUSY; } /* ** We have tried to use '_beginthreadex' instead of '_beginthread' here ** but in this case the program leaks about 512 characters for each Loading Loading
include/config-win.h +3 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,9 @@ /* We have to do this define before including windows.h to get the AWE API functions */ #define _WIN32_WINNT 0x0500 #else /* Get NT 4.0 functions */ #define _WIN32_WINNT 0x0400 #endif #if defined(_MSC_VER) && _MSC_VER >= 1400 Loading
include/my_pthread.h +5 −4 Original line number Diff line number Diff line Loading @@ -116,6 +116,7 @@ struct timespec { void win_pthread_init(void); int win_pthread_setspecific(void *A,void *B,uint length); int win_pthread_mutex_trylock(pthread_mutex_t *mutex); int pthread_create(pthread_t *,pthread_attr_t *,pthread_handler,void *); int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr); int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex); Loading Loading @@ -176,7 +177,7 @@ extern int pthread_mutex_destroy (pthread_mutex_t *); #else #define pthread_mutex_init(A,B) (InitializeCriticalSection(A),0) #define pthread_mutex_lock(A) (EnterCriticalSection(A),0) #define pthread_mutex_trylock(A) (WaitForSingleObject((A), 0) == WAIT_TIMEOUT) #define pthread_mutex_trylock(A) win_pthread_mutex_trylock((A)) #define pthread_mutex_unlock(A) LeaveCriticalSection(A) #define pthread_mutex_destroy(A) DeleteCriticalSection(A) #define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B)) Loading Loading @@ -574,7 +575,7 @@ typedef struct st_safe_mutex_info_t int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr, const char *file, uint line); int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line); int safe_mutex_lock(safe_mutex_t *mp, my_bool try_lock, const char *file, uint line); int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line); int safe_mutex_destroy(safe_mutex_t *mp,const char *file, uint line); int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp,const char *file, Loading @@ -597,12 +598,12 @@ void safe_mutex_end(FILE *file); #undef pthread_cond_timedwait #undef pthread_mutex_trylock #define pthread_mutex_init(A,B) safe_mutex_init((A),(B),__FILE__,__LINE__) #define pthread_mutex_lock(A) safe_mutex_lock((A),__FILE__,__LINE__) #define pthread_mutex_lock(A) safe_mutex_lock((A), FALSE, __FILE__, __LINE__) #define pthread_mutex_unlock(A) safe_mutex_unlock((A),__FILE__,__LINE__) #define pthread_mutex_destroy(A) safe_mutex_destroy((A),__FILE__,__LINE__) #define pthread_cond_wait(A,B) safe_cond_wait((A),(B),__FILE__,__LINE__) #define pthread_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__) #define pthread_mutex_trylock(A) pthread_mutex_lock(A) #define pthread_mutex_trylock(A) safe_mutex_lock((A), TRUE, __FILE__, __LINE__) #define pthread_mutex_t safe_mutex_t #define safe_mutex_assert_owner(mp) \ DBUG_ASSERT((mp)->count > 0 && \ Loading
mysql-test/r/sp.result +176 −0 Original line number Diff line number Diff line Loading @@ -6389,4 +6389,180 @@ DROP TABLE t1; DROP PROCEDURE p1; DROP PROCEDURE p2; # # Bug#31035. # # # - Prepare. # DROP TABLE IF EXISTS t1; DROP FUNCTION IF EXISTS f1; DROP FUNCTION IF EXISTS f2; DROP FUNCTION IF EXISTS f3; DROP FUNCTION IF EXISTS f4; # # - Create required objects. # CREATE TABLE t1(c1 INT); INSERT INTO t1 VALUES (1), (2), (3); CREATE FUNCTION f1() RETURNS INT NOT DETERMINISTIC RETURN 1; CREATE FUNCTION f2(p INT) RETURNS INT NOT DETERMINISTIC RETURN 1; CREATE FUNCTION f3() RETURNS INT DETERMINISTIC RETURN 1; CREATE FUNCTION f4(p INT) RETURNS INT DETERMINISTIC RETURN 1; # # - Check. # SELECT f1() AS a FROM t1 GROUP BY a; a 1 SELECT f2(@a) AS a FROM t1 GROUP BY a; a 1 SELECT f3() AS a FROM t1 GROUP BY a; a 1 SELECT f4(0) AS a FROM t1 GROUP BY a; a 1 SELECT f4(@a) AS a FROM t1 GROUP BY a; a 1 # # - Cleanup. # DROP TABLE t1; DROP FUNCTION f1; DROP FUNCTION f2; DROP FUNCTION f3; DROP FUNCTION f4; # # Bug#31191. # # # - Prepare. # DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t2; DROP FUNCTION IF EXISTS f1; # # - Create required objects. # CREATE TABLE t1 ( id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, barcode INT(8) UNSIGNED ZEROFILL nOT NULL, PRIMARY KEY (id), UNIQUE KEY barcode (barcode) ); INSERT INTO t1 (id, barcode) VALUES (1, 12345678); INSERT INTO t1 (id, barcode) VALUES (2, 12345679); CREATE TABLE test.t2 ( id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, barcode BIGINT(11) UNSIGNED ZEROFILL NOT NULL, PRIMARY KEY (id) ); INSERT INTO test.t2 (id, barcode) VALUES (1, 12345106708); INSERT INTO test.t2 (id, barcode) VALUES (2, 12345106709); CREATE FUNCTION f1(p INT(8)) RETURNS BIGINT(11) UNSIGNED READS SQL DATA RETURN FLOOR(p/1000)*1000000 + 100000 + FLOOR((p MOD 1000)/10)*100 + (p MOD 10); # # - Check. # SELECT DISTINCT t1.barcode, f1(t1.barcode) FROM t1 INNER JOIN t2 ON f1(t1.barcode) = t2.barcode WHERE t1.barcode=12345678; barcode f1(t1.barcode) 12345678 12345106708 # # - Cleanup. # DROP TABLE t1; DROP TABLE t2; DROP FUNCTION f1; # # Bug#31226. # # # - Prepare. # DROP TABLE IF EXISTS t1; DROP FUNCTION IF EXISTS f1; # # - Create required objects. # CREATE TABLE t1(id INT); INSERT INTO t1 VALUES (1), (2), (3); CREATE FUNCTION f1() RETURNS DATETIME NOT DETERMINISTIC NO SQL RETURN NOW(); # # - Check. # SELECT f1() FROM t1 GROUP BY 1; f1() <timestamp> # # - Cleanup. # DROP TABLE t1; DROP FUNCTION f1; End of 5.0 tests
mysql-test/t/sp.test +290 −0 Original line number Diff line number Diff line Loading @@ -7387,4 +7387,294 @@ DROP TABLE t1; DROP PROCEDURE p1; DROP PROCEDURE p2; ########################################################################### # # Bug#31035: select from function, group by result crasher. # ########################################################################### --echo --echo # --echo # Bug#31035. --echo # --echo --echo # --echo # - Prepare. --echo # --echo --disable_warnings DROP TABLE IF EXISTS t1; DROP FUNCTION IF EXISTS f1; DROP FUNCTION IF EXISTS f2; DROP FUNCTION IF EXISTS f3; DROP FUNCTION IF EXISTS f4; --enable_warnings --echo --echo # --echo # - Create required objects. --echo # --echo CREATE TABLE t1(c1 INT); --echo INSERT INTO t1 VALUES (1), (2), (3); --echo CREATE FUNCTION f1() RETURNS INT NOT DETERMINISTIC RETURN 1; --echo CREATE FUNCTION f2(p INT) RETURNS INT NOT DETERMINISTIC RETURN 1; --echo CREATE FUNCTION f3() RETURNS INT DETERMINISTIC RETURN 1; --echo CREATE FUNCTION f4(p INT) RETURNS INT DETERMINISTIC RETURN 1; --echo --echo # --echo # - Check. --echo # --echo # Not deterministic function, no arguments. SELECT f1() AS a FROM t1 GROUP BY a; --echo # Not deterministic function, non-constant argument. SELECT f2(@a) AS a FROM t1 GROUP BY a; --echo # Deterministic function, no arguments. SELECT f3() AS a FROM t1 GROUP BY a; --echo # Deterministic function, constant argument. SELECT f4(0) AS a FROM t1 GROUP BY a; --echo # Deterministic function, non-constant argument. SELECT f4(@a) AS a FROM t1 GROUP BY a; --echo --echo # --echo # - Cleanup. --echo # --echo DROP TABLE t1; DROP FUNCTION f1; DROP FUNCTION f2; DROP FUNCTION f3; DROP FUNCTION f4; --echo ########################################################################### # # Bug#31191: JOIN in combination with stored function crashes the server. # ########################################################################### --echo # --echo # Bug#31191. --echo # --echo --echo # --echo # - Prepare. --echo # --echo --disable_warnings DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t2; DROP FUNCTION IF EXISTS f1; --enable_warnings --echo --echo # --echo # - Create required objects. --echo # --echo CREATE TABLE t1 ( id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, barcode INT(8) UNSIGNED ZEROFILL nOT NULL, PRIMARY KEY (id), UNIQUE KEY barcode (barcode) ); --echo INSERT INTO t1 (id, barcode) VALUES (1, 12345678); INSERT INTO t1 (id, barcode) VALUES (2, 12345679); --echo CREATE TABLE test.t2 ( id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, barcode BIGINT(11) UNSIGNED ZEROFILL NOT NULL, PRIMARY KEY (id) ); --echo INSERT INTO test.t2 (id, barcode) VALUES (1, 12345106708); INSERT INTO test.t2 (id, barcode) VALUES (2, 12345106709); --echo CREATE FUNCTION f1(p INT(8)) RETURNS BIGINT(11) UNSIGNED READS SQL DATA RETURN FLOOR(p/1000)*1000000 + 100000 + FLOOR((p MOD 1000)/10)*100 + (p MOD 10); --echo --echo # --echo # - Check. --echo # --echo SELECT DISTINCT t1.barcode, f1(t1.barcode) FROM t1 INNER JOIN t2 ON f1(t1.barcode) = t2.barcode WHERE t1.barcode=12345678; --echo --echo # --echo # - Cleanup. --echo # --echo DROP TABLE t1; DROP TABLE t2; DROP FUNCTION f1; --echo ########################################################################### # # Bug#31226: Group by function crashes mysql. # ########################################################################### --echo # --echo # Bug#31226. --echo # --echo --echo # --echo # - Prepare. --echo # --echo --disable_warnings DROP TABLE IF EXISTS t1; DROP FUNCTION IF EXISTS f1; --enable_warnings --echo --echo # --echo # - Create required objects. --echo # --echo CREATE TABLE t1(id INT); --echo INSERT INTO t1 VALUES (1), (2), (3); --echo CREATE FUNCTION f1() RETURNS DATETIME NOT DETERMINISTIC NO SQL RETURN NOW(); --echo --echo # --echo # - Check. --echo # --echo --replace_column 1 <timestamp> SELECT f1() FROM t1 GROUP BY 1; --echo --echo # --echo # - Cleanup. --echo # --echo DROP TABLE t1; DROP FUNCTION f1; --echo ########################################################################### --echo End of 5.0 tests
mysys/my_winthread.c +23 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,29 @@ void win_pthread_init(void) pthread_mutex_init(&THR_LOCK_thread,MY_MUTEX_INIT_FAST); } /** Adapter to @c pthread_mutex_trylock() @retval 0 Mutex was acquired @retval EBUSY Mutex was already locked by a thread */ int win_pthread_mutex_trylock(pthread_mutex_t *mutex) { if (TryEnterCriticalSection(mutex)) { /* Don't allow recursive lock */ if (mutex->RecursionCount > 1){ LeaveCriticalSection(mutex); return EBUSY; } return 0; } return EBUSY; } /* ** We have tried to use '_beginthreadex' instead of '_beginthread' here ** but in this case the program leaks about 512 characters for each Loading