New upstream version 18.0.1+dfsg1
This commit is contained in:
parent
6efda2859e
commit
f2cf6cce50
1337 changed files with 41178 additions and 84670 deletions
358
deps/w32-pthreads/tests/Bmakefile
vendored
358
deps/w32-pthreads/tests/Bmakefile
vendored
|
|
@ -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
|
||||
1000
deps/w32-pthreads/tests/ChangeLog
vendored
1000
deps/w32-pthreads/tests/ChangeLog
vendored
File diff suppressed because it is too large
Load diff
93
deps/w32-pthreads/tests/Debug.dsp
vendored
93
deps/w32-pthreads/tests/Debug.dsp
vendored
|
|
@ -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
|
||||
29
deps/w32-pthreads/tests/Debug.dsw
vendored
29
deps/w32-pthreads/tests/Debug.dsw
vendored
|
|
@ -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>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
32
deps/w32-pthreads/tests/Debug.plg
vendored
32
deps/w32-pthreads/tests/Debug.plg
vendored
|
|
@ -1,32 +0,0 @@
|
|||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: Debug - Win32 Debug--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
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"
|
||||
<h3>Output Window</h3>
|
||||
Compiling...
|
||||
semaphore1.c
|
||||
Linking...
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
Debug.exe - 0 error(s), 0 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
6
deps/w32-pthreads/tests/Debug.txt
vendored
6
deps/w32-pthreads/tests/Debug.txt
vendored
|
|
@ -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.
|
||||
447
deps/w32-pthreads/tests/GNUmakefile
vendored
447
deps/w32-pthreads/tests/GNUmakefile
vendored
|
|
@ -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
|
||||
450
deps/w32-pthreads/tests/Makefile
vendored
450
deps/w32-pthreads/tests/Makefile
vendored
|
|
@ -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
|
||||
44
deps/w32-pthreads/tests/README
vendored
44
deps/w32-pthreads/tests/README
vendored
|
|
@ -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.
|
||||
74
deps/w32-pthreads/tests/README.BENCHTESTS
vendored
74
deps/w32-pthreads/tests/README.BENCHTESTS
vendored
|
|
@ -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.
|
||||
|
||||
21
deps/w32-pthreads/tests/SIZES.GC
vendored
21
deps/w32-pthreads/tests/SIZES.GC
vendored
|
|
@ -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
|
||||
-------------------------------
|
||||
21
deps/w32-pthreads/tests/SIZES.GCE
vendored
21
deps/w32-pthreads/tests/SIZES.GCE
vendored
|
|
@ -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
|
||||
-------------------------------
|
||||
21
deps/w32-pthreads/tests/SIZES.VC
vendored
21
deps/w32-pthreads/tests/SIZES.VC
vendored
|
|
@ -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
|
||||
-------------------------------
|
||||
21
deps/w32-pthreads/tests/SIZES.VCE
vendored
21
deps/w32-pthreads/tests/SIZES.VCE
vendored
|
|
@ -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
|
||||
-------------------------------
|
||||
21
deps/w32-pthreads/tests/SIZES.VSE
vendored
21
deps/w32-pthreads/tests/SIZES.VSE
vendored
|
|
@ -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
|
||||
-------------------------------
|
||||
355
deps/w32-pthreads/tests/Wmakefile
vendored
355
deps/w32-pthreads/tests/Wmakefile
vendored
|
|
@ -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
|
||||
58
deps/w32-pthreads/tests/barrier1.c
vendored
58
deps/w32-pthreads/tests/barrier1.c
vendored
|
|
@ -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;
|
||||
}
|
||||
55
deps/w32-pthreads/tests/barrier2.c
vendored
55
deps/w32-pthreads/tests/barrier2.c
vendored
|
|
@ -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;
|
||||
}
|
||||
71
deps/w32-pthreads/tests/barrier3.c
vendored
71
deps/w32-pthreads/tests/barrier3.c
vendored
|
|
@ -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;
|
||||
}
|
||||
110
deps/w32-pthreads/tests/barrier4.c
vendored
110
deps/w32-pthreads/tests/barrier4.c
vendored
|
|
@ -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;
|
||||
}
|
||||
118
deps/w32-pthreads/tests/barrier5.c
vendored
118
deps/w32-pthreads/tests/barrier5.c
vendored
|
|
@ -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<HEIGHT?j:HEIGHT;
|
||||
|
||||
totalThreadCrossings = 0;
|
||||
Crossings = height * BARRIERMULTIPLE;
|
||||
|
||||
printf("Threads=%d, Barrier height=%d\n", j, height);
|
||||
|
||||
assert(pthread_barrier_init(&barrier, NULL, height) == 0);
|
||||
|
||||
for (i = 1; i <= j; i++)
|
||||
{
|
||||
assert(pthread_create(&t[i], NULL, func, (void *)(size_t)Crossings) == 0);
|
||||
}
|
||||
|
||||
serialThreadsTotal = 0;
|
||||
for (i = 1; i <= j; i++)
|
||||
{
|
||||
assert(pthread_join(t[i], &result) == 0);
|
||||
serialThreadsTotal += (int)(size_t)result;
|
||||
}
|
||||
|
||||
assert(serialThreadsTotal == BARRIERMULTIPLE);
|
||||
|
||||
assert(pthread_barrier_destroy(&barrier) == 0);
|
||||
}
|
||||
|
||||
assert(pthread_mutex_destroy(&mx) == 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
117
deps/w32-pthreads/tests/barrier6.c
vendored
117
deps/w32-pthreads/tests/barrier6.c
vendored
|
|
@ -1,117 +0,0 @@
|
|||
/*
|
||||
* barrier6.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
|
||||
*
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Destroy the barrier after initial count threads are released then let
|
||||
* additional threads attempt to wait on it.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "test.h"
|
||||
|
||||
enum {
|
||||
NUMTHREADS = 31
|
||||
};
|
||||
|
||||
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++;
|
||||
}
|
||||
assert(pthread_mutex_unlock(&mx) == 0);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
int i, j, k;
|
||||
pthread_t t[NUMTHREADS + 1];
|
||||
|
||||
for (j = 1; j <= NUMTHREADS; j++)
|
||||
{
|
||||
int howHigh = j/2 + 1;
|
||||
|
||||
printf("Barrier height = %d, Total threads %d\n", howHigh, j);
|
||||
|
||||
serialThreadCount = 0;
|
||||
otherThreadCount = 0;
|
||||
|
||||
assert(pthread_barrier_init(&barrier, NULL, howHigh) == 0);
|
||||
|
||||
for (i = 1; i <= j; i++)
|
||||
{
|
||||
assert(pthread_create(&t[i], NULL, func, NULL) == 0);
|
||||
|
||||
if (i == howHigh)
|
||||
{
|
||||
for (k = 1; k <= howHigh; k++)
|
||||
{
|
||||
assert(pthread_join(t[k], NULL) == 0);
|
||||
}
|
||||
assert(pthread_barrier_destroy(&barrier) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = howHigh+1; i <= j; i++)
|
||||
{
|
||||
assert(pthread_join(t[i], NULL) == 0);
|
||||
}
|
||||
|
||||
assert(serialThreadCount == 1);
|
||||
assert(otherThreadCount == (howHigh - 1));
|
||||
|
||||
assert(pthread_barrier_destroy(&barrier) == EINVAL);
|
||||
}
|
||||
|
||||
assert(pthread_mutex_destroy(&mx) == 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
363
deps/w32-pthreads/tests/benchlib.c
vendored
363
deps/w32-pthreads/tests/benchlib.c
vendored
|
|
@ -1,363 +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"
|
||||
|
||||
#include "pthread.h"
|
||||
#include "sched.h"
|
||||
#include "semaphore.h"
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <stdlib.h>
|
||||
#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);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
70
deps/w32-pthreads/tests/benchtest.h
vendored
70
deps/w32-pthreads/tests/benchtest.h
vendored
|
|
@ -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);
|
||||
/****************************************************************************************/
|
||||
266
deps/w32-pthreads/tests/benchtest1.c
vendored
266
deps/w32-pthreads/tests/benchtest1.c
vendored
|
|
@ -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 <sys/timeb.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <stdlib.h>
|
||||
#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;
|
||||
}
|
||||
327
deps/w32-pthreads/tests/benchtest2.c
vendored
327
deps/w32-pthreads/tests/benchtest2.c
vendored
|
|
@ -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 <sys/timeb.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <stdlib.h>
|
||||
#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;
|
||||
}
|
||||
217
deps/w32-pthreads/tests/benchtest3.c
vendored
217
deps/w32-pthreads/tests/benchtest3.c
vendored
|
|
@ -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 <sys/timeb.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <stdlib.h>
|
||||
#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;
|
||||
}
|
||||
198
deps/w32-pthreads/tests/benchtest4.c
vendored
198
deps/w32-pthreads/tests/benchtest4.c
vendored
|
|
@ -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 <sys/timeb.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <stdlib.h>
|
||||
#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;
|
||||
}
|
||||
159
deps/w32-pthreads/tests/benchtest5.c
vendored
159
deps/w32-pthreads/tests/benchtest5.c
vendored
|
|
@ -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 <sys/timeb.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <stdlib.h>
|
||||
#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;
|
||||
}
|
||||
179
deps/w32-pthreads/tests/cancel1.c
vendored
179
deps/w32-pthreads/tests/cancel1.c
vendored
|
|
@ -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;
|
||||
}
|
||||
258
deps/w32-pthreads/tests/cancel2.c
vendored
258
deps/w32-pthreads/tests/cancel2.c
vendored
|
|
@ -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 <stdio.h>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
fprintf(stderr, "Test N/A for this compiler environment.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* defined(__cplusplus) */
|
||||
|
||||
201
deps/w32-pthreads/tests/cancel3.c
vendored
201
deps/w32-pthreads/tests/cancel3.c
vendored
|
|
@ -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;
|
||||
}
|
||||
203
deps/w32-pthreads/tests/cancel4.c
vendored
203
deps/w32-pthreads/tests/cancel4.c
vendored
|
|
@ -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;
|
||||
}
|
||||
199
deps/w32-pthreads/tests/cancel5.c
vendored
199
deps/w32-pthreads/tests/cancel5.c
vendored
|
|
@ -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;
|
||||
}
|
||||
191
deps/w32-pthreads/tests/cancel6a.c
vendored
191
deps/w32-pthreads/tests/cancel6a.c
vendored
|
|
@ -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;
|
||||
}
|
||||
193
deps/w32-pthreads/tests/cancel6d.c
vendored
193
deps/w32-pthreads/tests/cancel6d.c
vendored
|
|
@ -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;
|
||||
}
|
||||
218
deps/w32-pthreads/tests/cancel7.c
vendored
218
deps/w32-pthreads/tests/cancel7.c
vendored
|
|
@ -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 <process.h>
|
||||
#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;
|
||||
}
|
||||
|
||||
219
deps/w32-pthreads/tests/cancel8.c
vendored
219
deps/w32-pthreads/tests/cancel8.c
vendored
|
|
@ -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 <process.h>
|
||||
#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;
|
||||
}
|
||||
|
||||
202
deps/w32-pthreads/tests/cancel9.c
vendored
202
deps/w32-pthreads/tests/cancel9.c
vendored
|
|
@ -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 <windows.h>
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
229
deps/w32-pthreads/tests/cleanup0.c
vendored
229
deps/w32-pthreads/tests/cleanup0.c
vendored
|
|
@ -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) */
|
||||
242
deps/w32-pthreads/tests/cleanup1.c
vendored
242
deps/w32-pthreads/tests/cleanup1.c
vendored
|
|
@ -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) */
|
||||
217
deps/w32-pthreads/tests/cleanup2.c
vendored
217
deps/w32-pthreads/tests/cleanup2.c
vendored
|
|
@ -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) */
|
||||
222
deps/w32-pthreads/tests/cleanup3.c
vendored
222
deps/w32-pthreads/tests/cleanup3.c
vendored
|
|
@ -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) */
|
||||
97
deps/w32-pthreads/tests/condvar1.c
vendored
97
deps/w32-pthreads/tests/condvar1.c
vendored
|
|
@ -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;
|
||||
}
|
||||
115
deps/w32-pthreads/tests/condvar1_1.c
vendored
115
deps/w32-pthreads/tests/condvar1_1.c
vendored
|
|
@ -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 <stdlib.h>
|
||||
#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;
|
||||
}
|
||||
124
deps/w32-pthreads/tests/condvar1_2.c
vendored
124
deps/w32-pthreads/tests/condvar1_2.c
vendored
|
|
@ -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 <stdlib.h>
|
||||
#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;
|
||||
}
|
||||
125
deps/w32-pthreads/tests/condvar2.c
vendored
125
deps/w32-pthreads/tests/condvar2.c
vendored
|
|
@ -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 <sys/timeb.h>
|
||||
|
||||
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;
|
||||
}
|
||||
153
deps/w32-pthreads/tests/condvar2_1.c
vendored
153
deps/w32-pthreads/tests/condvar2_1.c
vendored
|
|
@ -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 <sys/timeb.h>
|
||||
|
||||
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;
|
||||
}
|
||||
148
deps/w32-pthreads/tests/condvar3.c
vendored
148
deps/w32-pthreads/tests/condvar3.c
vendored
|
|
@ -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 <sys/timeb.h>
|
||||
|
||||
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;
|
||||
}
|
||||
201
deps/w32-pthreads/tests/condvar3_1.c
vendored
201
deps/w32-pthreads/tests/condvar3_1.c
vendored
|
|
@ -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 <sys/timeb.h>
|
||||
|
||||
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;
|
||||
}
|
||||
193
deps/w32-pthreads/tests/condvar3_2.c
vendored
193
deps/w32-pthreads/tests/condvar3_2.c
vendored
|
|
@ -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 <sys/timeb.h>
|
||||
|
||||
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;
|
||||
}
|
||||
132
deps/w32-pthreads/tests/condvar3_3.c
vendored
132
deps/w32-pthreads/tests/condvar3_3.c
vendored
|
|
@ -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 <sys/timeb.h>
|
||||
|
||||
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;
|
||||
}
|
||||
169
deps/w32-pthreads/tests/condvar4.c
vendored
169
deps/w32-pthreads/tests/condvar4.c
vendored
|
|
@ -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 <sys/timeb.h>
|
||||
|
||||
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;
|
||||
}
|
||||
168
deps/w32-pthreads/tests/condvar5.c
vendored
168
deps/w32-pthreads/tests/condvar5.c
vendored
|
|
@ -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 <sys/timeb.h>
|
||||
|
||||
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;
|
||||
}
|
||||
242
deps/w32-pthreads/tests/condvar6.c
vendored
242
deps/w32-pthreads/tests/condvar6.c
vendored
|
|
@ -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 <sys/timeb.h>
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
||||
257
deps/w32-pthreads/tests/condvar7.c
vendored
257
deps/w32-pthreads/tests/condvar7.c
vendored
|
|
@ -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 <sys/timeb.h>
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
258
deps/w32-pthreads/tests/condvar8.c
vendored
258
deps/w32-pthreads/tests/condvar8.c
vendored
|
|
@ -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 <sys/timeb.h>
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
267
deps/w32-pthreads/tests/condvar9.c
vendored
267
deps/w32-pthreads/tests/condvar9.c
vendored
|
|
@ -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 <sys/timeb.h>
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
142
deps/w32-pthreads/tests/context1.c
vendored
142
deps/w32-pthreads/tests/context1.c
vendored
|
|
@ -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;
|
||||
}
|
||||
|
||||
90
deps/w32-pthreads/tests/count1.c
vendored
90
deps/w32-pthreads/tests/count1.c
vendored
|
|
@ -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;
|
||||
}
|
||||
66
deps/w32-pthreads/tests/create1.c
vendored
66
deps/w32-pthreads/tests/create1.c
vendored
|
|
@ -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;
|
||||
}
|
||||
109
deps/w32-pthreads/tests/create2.c
vendored
109
deps/w32-pthreads/tests/create2.c
vendored
|
|
@ -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;
|
||||
}
|
||||
109
deps/w32-pthreads/tests/create3.c
vendored
109
deps/w32-pthreads/tests/create3.c
vendored
|
|
@ -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;
|
||||
}
|
||||
51
deps/w32-pthreads/tests/delay1.c
vendored
51
deps/w32-pthreads/tests/delay1.c
vendored
|
|
@ -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;
|
||||
}
|
||||
|
||||
82
deps/w32-pthreads/tests/delay2.c
vendored
82
deps/w32-pthreads/tests/delay2.c
vendored
|
|
@ -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;
|
||||
}
|
||||
|
||||
93
deps/w32-pthreads/tests/detach1.c
vendored
93
deps/w32-pthreads/tests/detach1.c
vendored
|
|
@ -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;
|
||||
}
|
||||
66
deps/w32-pthreads/tests/equal1.c
vendored
66
deps/w32-pthreads/tests/equal1.c
vendored
|
|
@ -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;
|
||||
}
|
||||
177
deps/w32-pthreads/tests/errno1.c
vendored
177
deps/w32-pthreads/tests/errno1.c
vendored
|
|
@ -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;
|
||||
}
|
||||
263
deps/w32-pthreads/tests/exception1.c
vendored
263
deps/w32-pthreads/tests/exception1.c
vendored
|
|
@ -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 <stdio.h>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
fprintf(stderr, "Test N/A for this compiler environment.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* defined(_MSC_VER) || defined(__cplusplus) */
|
||||
158
deps/w32-pthreads/tests/exception2.c
vendored
158
deps/w32-pthreads/tests/exception2.c
vendored
|
|
@ -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 <eh.h>
|
||||
#elif defined(__cplusplus)
|
||||
#include <exception>
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <stdlib.h>
|
||||
#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 <stdio.h>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
fprintf(stderr, "Test N/A for this compiler environment.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* defined(_MSC_VER) || defined(__cplusplus) */
|
||||
183
deps/w32-pthreads/tests/exception3.c
vendored
183
deps/w32-pthreads/tests/exception3.c
vendored
|
|
@ -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 <eh.h>
|
||||
#else
|
||||
# if defined(__GNUC__) && __GNUC__ < 3
|
||||
# include <new.h>
|
||||
# else
|
||||
# include <new>
|
||||
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 <stdio.h>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
fprintf(stderr, "Test N/A for this compiler environment.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* defined(__cplusplus) */
|
||||
50
deps/w32-pthreads/tests/exit1.c
vendored
50
deps/w32-pthreads/tests/exit1.c
vendored
|
|
@ -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;
|
||||
}
|
||||
64
deps/w32-pthreads/tests/exit2.c
vendored
64
deps/w32-pthreads/tests/exit2.c
vendored
|
|
@ -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;
|
||||
}
|
||||
68
deps/w32-pthreads/tests/exit3.c
vendored
68
deps/w32-pthreads/tests/exit3.c
vendored
|
|
@ -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;
|
||||
}
|
||||
199
deps/w32-pthreads/tests/exit4.c
vendored
199
deps/w32-pthreads/tests/exit4.c
vendored
|
|
@ -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 <process.h>
|
||||
#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;
|
||||
}
|
||||
|
||||
205
deps/w32-pthreads/tests/exit5.c
vendored
205
deps/w32-pthreads/tests/exit5.c
vendored
|
|
@ -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 <process.h>
|
||||
#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;
|
||||
}
|
||||
|
||||
367
deps/w32-pthreads/tests/eyal1.c
vendored
367
deps/w32-pthreads/tests/eyal1.c
vendored
|
|
@ -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 <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
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);
|
||||
}
|
||||
177
deps/w32-pthreads/tests/inherit1.c
vendored
177
deps/w32-pthreads/tests/inherit1.c
vendored
|
|
@ -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;
|
||||
}
|
||||
67
deps/w32-pthreads/tests/join0.c
vendored
67
deps/w32-pthreads/tests/join0.c
vendored
|
|
@ -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;
|
||||
}
|
||||
78
deps/w32-pthreads/tests/join1.c
vendored
78
deps/w32-pthreads/tests/join1.c
vendored
|
|
@ -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;
|
||||
}
|
||||
69
deps/w32-pthreads/tests/join2.c
vendored
69
deps/w32-pthreads/tests/join2.c
vendored
|
|
@ -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;
|
||||
}
|
||||
75
deps/w32-pthreads/tests/join3.c
vendored
75
deps/w32-pthreads/tests/join3.c
vendored
|
|
@ -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;
|
||||
}
|
||||
83
deps/w32-pthreads/tests/kill1.c
vendored
83
deps/w32-pthreads/tests/kill1.c
vendored
|
|
@ -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;
|
||||
}
|
||||
70
deps/w32-pthreads/tests/loadfree.c
vendored
70
deps/w32-pthreads/tests/loadfree.c
vendored
|
|
@ -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 <towen@lucidcalm.dropbear.id.au>
|
||||
* 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;
|
||||
}
|
||||
|
||||
68
deps/w32-pthreads/tests/mutex1.c
vendored
68
deps/w32-pthreads/tests/mutex1.c
vendored
|
|
@ -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;
|
||||
}
|
||||
78
deps/w32-pthreads/tests/mutex1e.c
vendored
78
deps/w32-pthreads/tests/mutex1e.c
vendored
|
|
@ -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;
|
||||
}
|
||||
78
deps/w32-pthreads/tests/mutex1n.c
vendored
78
deps/w32-pthreads/tests/mutex1n.c
vendored
|
|
@ -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;
|
||||
}
|
||||
78
deps/w32-pthreads/tests/mutex1r.c
vendored
78
deps/w32-pthreads/tests/mutex1r.c
vendored
|
|
@ -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;
|
||||
}
|
||||
66
deps/w32-pthreads/tests/mutex2.c
vendored
66
deps/w32-pthreads/tests/mutex2.c
vendored
|
|
@ -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;
|
||||
}
|
||||
66
deps/w32-pthreads/tests/mutex2e.c
vendored
66
deps/w32-pthreads/tests/mutex2e.c
vendored
|
|
@ -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;
|
||||
}
|
||||
66
deps/w32-pthreads/tests/mutex2r.c
vendored
66
deps/w32-pthreads/tests/mutex2r.c
vendored
|
|
@ -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;
|
||||
}
|
||||
75
deps/w32-pthreads/tests/mutex3.c
vendored
75
deps/w32-pthreads/tests/mutex3.c
vendored
|
|
@ -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;
|
||||
}
|
||||
75
deps/w32-pthreads/tests/mutex3e.c
vendored
75
deps/w32-pthreads/tests/mutex3e.c
vendored
|
|
@ -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;
|
||||
}
|
||||
75
deps/w32-pthreads/tests/mutex3r.c
vendored
75
deps/w32-pthreads/tests/mutex3r.c
vendored
|
|
@ -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;
|
||||
}
|
||||
109
deps/w32-pthreads/tests/mutex4.c
vendored
109
deps/w32-pthreads/tests/mutex4.c
vendored
|
|
@ -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;
|
||||
}
|
||||
67
deps/w32-pthreads/tests/mutex5.c
vendored
67
deps/w32-pthreads/tests/mutex5.c
vendored
|
|
@ -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;
|
||||
}
|
||||
93
deps/w32-pthreads/tests/mutex6.c
vendored
93
deps/w32-pthreads/tests/mutex6.c
vendored
|
|
@ -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;
|
||||
}
|
||||
109
deps/w32-pthreads/tests/mutex6e.c
vendored
109
deps/w32-pthreads/tests/mutex6e.c
vendored
|
|
@ -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;
|
||||
}
|
||||
|
||||
94
deps/w32-pthreads/tests/mutex6es.c
vendored
94
deps/w32-pthreads/tests/mutex6es.c
vendored
|
|
@ -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;
|
||||
}
|
||||
|
||||
107
deps/w32-pthreads/tests/mutex6n.c
vendored
107
deps/w32-pthreads/tests/mutex6n.c
vendored
|
|
@ -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;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue