diff --git a/mps/code/amcssth.c b/mps/code/amcssth.c index 684cd94edb5..79eff570b0b 100644 --- a/mps/code/amcssth.c +++ b/mps/code/amcssth.c @@ -12,11 +12,11 @@ #include "fmtdy.h" #include "fmtdytst.h" #include "testlib.h" +#include "testthr.h" #include "mpslib.h" #include "mpscamc.h" #include "mpsavm.h" -#include /* pthread_create, pthread_join */ #include /* fflush, printf, putchar */ @@ -219,7 +219,7 @@ static void *test(mps_class_t pool_class, size_t roots_count) mps_ap_t ap, busy_ap; mps_addr_t busy_init; mps_pool_t pool; - pthread_t kids[10]; + testthr_t kids[10]; closure_s cl; die(mps_pool_create(&pool, arena, pool_class, format, chain), @@ -228,11 +228,8 @@ static void *test(mps_class_t pool_class, size_t roots_count) cl.pool = pool; cl.roots_count = roots_count; - for (i = 0; i < sizeof(kids)/sizeof(kids[0]); ++i) { - int err = pthread_create(&kids[i], NULL, kid_thread, &cl); - if (err != 0) - error("pthread_create returned %d", err); - } + for (i = 0; i < sizeof(kids)/sizeof(kids[0]); ++i) + testthr_create(&kids[i], kid_thread, &cl); die(mps_ap_create(&ap, pool, mps_rank_exact()), "BufferCreate"); die(mps_ap_create(&busy_ap, pool, mps_rank_exact()), "BufferCreate 2"); @@ -312,11 +309,8 @@ static void *test(mps_class_t pool_class, size_t roots_count) mps_ap_destroy(busy_ap); mps_ap_destroy(ap); - for (i = 0; i < sizeof(kids)/sizeof(kids[0]); ++i) { - int err = pthread_join(kids[i], NULL); - if (err != 0) - error("pthread_join returned %d", err); - } + for (i = 0; i < sizeof(kids)/sizeof(kids[0]); ++i) + testthr_join(&kids[i], NULL); mps_pool_destroy(pool); diff --git a/mps/code/awlutth.c b/mps/code/awlutth.c index dda34a31c63..2bfaddc3813 100644 --- a/mps/code/awlutth.c +++ b/mps/code/awlutth.c @@ -13,11 +13,11 @@ #include "mpsavm.h" #include "fmtdy.h" #include "testlib.h" +#include "testthr.h" #include "mpslib.h" #include "mps.h" #include "mpstd.h" -#include /* pthread_create, pthread_join */ #include /* printf, puts */ #include /* strlen */ @@ -311,7 +311,7 @@ static void *setup_thr(void *v) int main(int argc, char *argv[]) { mps_arena_t arena; - pthread_t pthread1; + testthr_t thread1; testlib_init(argc, argv); @@ -321,9 +321,9 @@ int main(int argc, char *argv[]) die(mps_arena_create(&arena, mps_arena_class_vm(), testArenaSIZE), "arena_create\n"); - pthread_create(&pthread1, NULL, setup_thr, (void *)arena); + testthr_create(&thread1, setup_thr, arena); setup_thr(arena); - pthread_join(pthread1, NULL); + testthr_join(&thread1, NULL); mps_arena_destroy(arena); printf("%s: Conclusion: Failed to find any defects.\n", argv[0]); diff --git a/mps/code/comm.gmk b/mps/code/comm.gmk index 04e4a742f18..27668756b14 100644 --- a/mps/code/comm.gmk +++ b/mps/code/comm.gmk @@ -158,7 +158,7 @@ SNC = poolsnc.c POOLN = pooln.c MV2 = poolmv2.c MVFF = poolmvff.c -TESTLIB = testlib.c +TESTLIB = testlib.c testthr.c FMTDY = fmtdy.c fmtno.c FMTDYTST = fmtdy.c fmtno.c fmtdytst.c FMTHETST = fmthe.c fmtdy.c fmtno.c fmtdytst.c @@ -252,6 +252,7 @@ TEST_TARGETS=\ gcbench \ locbwcss \ lockcov \ + lockut \ locusss \ locv \ messtest \ @@ -442,6 +443,9 @@ $(PFM)/$(VARIETY)/locbwcss: $(PFM)/$(VARIETY)/locbwcss.o \ $(PFM)/$(VARIETY)/lockcov: $(PFM)/$(VARIETY)/lockcov.o \ $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a +$(PFM)/$(VARIETY)/lockut: $(PFM)/$(VARIETY)/lockut.o \ + $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a + $(PFM)/$(VARIETY)/locusss: $(PFM)/$(VARIETY)/locusss.o \ $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a diff --git a/mps/code/commpost.nmk b/mps/code/commpost.nmk index fca846803d7..643f0d4a9bb 100644 --- a/mps/code/commpost.nmk +++ b/mps/code/commpost.nmk @@ -1,7 +1,7 @@ # commpost.nmk: SECOND COMMON FRAGMENT FOR PLATFORMS USING NMAKE -*- makefile -*- # # $Id$ -# Copyright (c) 2001-2013 Ravenbrook Limited. See end of file for license. +# Copyright (c) 2001-2014 Ravenbrook Limited. See end of file for license. # # DESCRIPTION # @@ -146,6 +146,10 @@ $(PFM)\$(VARIETY)\awluthe.exe: $(PFM)\$(VARIETY)\awluthe.obj \ $(FMTTESTOBJ) \ $(PFM)\$(VARIETY)\mps.lib $(TESTLIBOBJ) +$(PFM)\$(VARIETY)\awlutth.exe: $(PFM)\$(VARIETY)\awlutth.obj \ + $(FMTTESTOBJ) \ + $(PFM)\$(VARIETY)\mps.lib $(TESTLIBOBJ) + $(PFM)\$(VARIETY)\btcv.exe: $(PFM)\$(VARIETY)\btcv.obj \ $(PFM)\$(VARIETY)\mps.lib $(TESTLIBOBJ) @@ -155,6 +159,9 @@ $(PFM)\$(VARIETY)\bttest.exe: $(PFM)\$(VARIETY)\bttest.obj \ $(PFM)\$(VARIETY)\cvmicv.exe: $(PFM)\$(VARIETY)\cvmicv.obj \ $(PFM)\$(VARIETY)\mps.lib $(FMTTESTOBJ) $(TESTLIBOBJ) +$(PFM)\$(VARIETY)\djbench.exe: $(PFM)\$(VARIETY)\djbench.obj \ + $(PFM)\$(VARIETY)\mps.lib $(TESTLIBOBJ) + $(PFM)\$(VARIETY)\exposet0.exe: $(PFM)\$(VARIETY)\exposet0.obj \ $(PFM)\$(VARIETY)\mps.lib $(FMTTESTOBJ) $(TESTLIBOBJ) @@ -173,13 +180,16 @@ $(PFM)\$(VARIETY)\finaltest.exe: $(PFM)\$(VARIETY)\finaltest.obj \ $(PFM)\$(VARIETY)\fotest.exe: $(PFM)\$(VARIETY)\fotest.obj \ $(PFM)\$(VARIETY)\mps.lib $(TESTLIBOBJ) +$(PFM)\$(VARIETY)\gcbench.exe: $(PFM)\$(VARIETY)\gcbench.obj \ + $(PFM)\$(VARIETY)\mps.lib $(TESTLIBOBJ) + $(PFM)\$(VARIETY)\locbwcss.exe: $(PFM)\$(VARIETY)\locbwcss.obj \ $(PFM)\$(VARIETY)\mps.lib $(TESTLIBOBJ) $(PFM)\$(VARIETY)\lockcov.exe: $(PFM)\$(VARIETY)\lockcov.obj \ $(PFM)\$(VARIETY)\mps.lib $(TESTLIBOBJ) -$(PFM)\$(VARIETY)\lockutw3.exe: $(PFM)\$(VARIETY)\lockutw3.obj \ +$(PFM)\$(VARIETY)\lockut.exe: $(PFM)\$(VARIETY)\lockut.obj \ $(PFM)\$(VARIETY)\mps.lib $(TESTLIBOBJ) $(PFM)\$(VARIETY)\locusss.exe: $(PFM)\$(VARIETY)\locusss.obj \ @@ -306,7 +316,7 @@ $(PFM)\$(VARIETY)\sqlite3.obj: # C. COPYRIGHT AND LICENSE # -# Copyright (C) 2001-2013 Ravenbrook Limited . +# Copyright (C) 2001-2014 Ravenbrook Limited . # All rights reserved. This is an open source license. Contact # Ravenbrook for commercial licensing options. # diff --git a/mps/code/commpre.nmk b/mps/code/commpre.nmk index 75cead3ef26..dea19b0814c 100644 --- a/mps/code/commpre.nmk +++ b/mps/code/commpre.nmk @@ -58,23 +58,27 @@ TEST_TARGETS=\ airtest.exe \ amcss.exe \ amcsshe.exe \ + amcssth.exe \ amsss.exe \ amssshe.exe \ apss.exe \ arenacv.exe \ awlut.exe \ awluthe.exe \ + awlutth.exe \ btcv.exe \ bttest.exe \ + djbench.exe \ exposet0.exe \ expt825.exe \ fbmtest.exe \ finalcv.exe \ finaltest.exe \ fotest.exe \ + gcbench.exe \ locbwcss.exe \ lockcov.exe \ - lockutw3.exe \ + lockut.exe \ locusss.exe \ locv.exe \ messtest.exe \ @@ -176,7 +180,7 @@ SNC = DW = FMTTEST = FMTSCHEME = -TESTLIB = +TESTLIB = # CHECK PARAMETERS diff --git a/mps/code/djbench.c b/mps/code/djbench.c index b27e44e16a4..9aa4b0115f8 100644 --- a/mps/code/djbench.c +++ b/mps/code/djbench.c @@ -13,12 +13,9 @@ #include "mps.c" -#include -#include -#include -#include #include "getopt.h" #include "testlib.h" +#include "testthr.h" #define DJMUST(expr) \ @@ -135,24 +132,14 @@ typedef void *(*dj_t)(void *); static void weave(dj_t dj) { - pthread_t *threads = alloca(sizeof(threads[0]) * nthreads); + testthr_t *threads = alloca(sizeof(threads[0]) * nthreads); unsigned t; - for (t = 0; t < nthreads; ++t) { - int err = pthread_create(&threads[t], NULL, dj, NULL); - if (err != 0) { - fprintf(stderr, "Unable to create thread: %d\n", err); - exit(EXIT_FAILURE); - } - } + for (t = 0; t < nthreads; ++t) + testthr_create(&threads[t], dj, NULL); - for (t = 0; t < nthreads; ++t) { - int err = pthread_join(threads[t], NULL); - if (err != 0) { - fprintf(stderr, "Unable to join thread: %d\n", err); - exit(EXIT_FAILURE); - } - } + for (t = 0; t < nthreads; ++t) + testthr_join(&threads[t], NULL); } diff --git a/mps/code/gcbench.c b/mps/code/gcbench.c index 61b6e925e94..a850ab155be 100644 --- a/mps/code/gcbench.c +++ b/mps/code/gcbench.c @@ -7,15 +7,9 @@ */ #include "mps.c" - -#include -#include -#include -#include -#include #include "getopt.h" #include "testlib.h" - +#include "testthr.h" #include "fmtdy.h" #include "fmtdytst.h" @@ -56,7 +50,7 @@ typedef struct gcthread_s *gcthread_t; typedef void *(*gcthread_fn_t)(gcthread_t thread); struct gcthread_s { - pthread_t pthread; + testthr_t thread; mps_thr_t mps_thread; mps_root_t reg_root; mps_ap_t ap; @@ -189,23 +183,12 @@ static void weave(gcthread_fn_t fn) for (t = 0; t < nthreads; ++t) { gcthread_t thread = &threads[t]; - int err; thread->fn = fn; - err = pthread_create(&thread->pthread, NULL, start, thread); - if (err != 0) { - fprintf(stderr, "Unable to create thread: %d\n", err); - exit(EXIT_FAILURE); - } + testthr_create(&thread->thread, start, thread); } - for (t = 0; t < nthreads; ++t) { - gcthread_t thread = &threads[t]; - int err = pthread_join(thread->pthread, NULL); - if (err != 0) { - fprintf(stderr, "Unable to join thread: %d\n", err); - exit(EXIT_FAILURE); - } - } + for (t = 0; t < nthreads; ++t) + testthr_join(&threads[t].thread, NULL); } static void weave1(gcthread_fn_t fn) diff --git a/mps/code/lockutw3.c b/mps/code/lockut.c similarity index 87% rename from mps/code/lockutw3.c rename to mps/code/lockut.c index 43f486799df..ec22369bc13 100644 --- a/mps/code/lockutw3.c +++ b/mps/code/lockut.c @@ -1,21 +1,15 @@ -/* lockutw3.c: LOCK UTILIZATION TEST +/* lockut.c: LOCK UTILIZATION TEST * * $Id$ * Copyright (c) 2001-2014 Ravenbrook Limited. See end of file for license. */ -#include /* malloc */ - #include "mpm.h" #include "testlib.h" -#include "mpslib.h" +#include "testthr.h" -#include "mpswin.h" - - -#ifndef MPS_OS_W3 -#error "Relies on Win32 threads" -#endif +#include /* printf */ +#include /* malloc */ #define nTHREADS 4 @@ -24,7 +18,7 @@ static Lock lock; unsigned long shared, tmp; -void incR(unsigned long i) +static void incR(unsigned long i) { LockClaimRecursive(lock); if (i < 100) { @@ -40,7 +34,7 @@ void incR(unsigned long i) } -void inc(unsigned long i) +static void inc(unsigned long i) { incR( (i+1) >>1); i >>= 1; @@ -59,18 +53,17 @@ void inc(unsigned long i) #define COUNT 100000l -DWORD WINAPI thread0(void *p) +static void *thread0(void *p) { - (void)p; + testlib_unused(p); inc(COUNT); - return 0; + return NULL; } int main(int argc, char *argv[]) { - DWORD id; - HANDLE t[10]; + testthr_t t[10]; unsigned i; testlib_init(argc, argv); @@ -84,12 +77,10 @@ int main(int argc, char *argv[]) shared = 0; for(i = 0; i < nTHREADS; i++) - t[i] = CreateThread(NULL, 0, thread0, NULL, 0, &id); + testthr_create(&t[i], thread0, NULL); - for(i = 0; i < nTHREADS; i++) { - cdie(WaitForSingleObject(t[i], INFINITE) == WAIT_OBJECT_0, - "WaitForSingleObject"); - } + for(i = 0; i < nTHREADS; i++) + testthr_join(&t[i], NULL); Insist(shared == nTHREADS*COUNT); diff --git a/mps/code/mps.xcodeproj/project.pbxproj b/mps/code/mps.xcodeproj/project.pbxproj index ae3abb2cbc5..88f110bab01 100644 --- a/mps/code/mps.xcodeproj/project.pbxproj +++ b/mps/code/mps.xcodeproj/project.pbxproj @@ -50,6 +50,7 @@ 22B2BC3F18B643B700C33E63 /* PBXTargetDependency */, 2231BB6D18CA986B002D6322 /* PBXTargetDependency */, 31D60034156D3D5A00337B26 /* PBXTargetDependency */, + 2286E4C918F4389E004111E2 /* PBXTargetDependency */, 2231BB6F18CA986D002D6322 /* PBXTargetDependency */, 3114A5A0156E915A001E0AA3 /* PBXTargetDependency */, 3114A6A7156E9739001E0AA3 /* PBXTargetDependency */, @@ -88,6 +89,10 @@ 224CC793175E1821002FF81B /* libmps.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 31EEABFB156AAF9D00714D05 /* libmps.a */; }; 224CC79F175E321C002FF81B /* mv2test.c in Sources */ = {isa = PBXBuildFile; fileRef = 3114A686156E9674001E0AA3 /* mv2test.c */; }; 224CC7A0175E322C002FF81B /* fotest.c in Sources */ = {isa = PBXBuildFile; fileRef = 224CC79E175E3202002FF81B /* fotest.c */; }; + 22561A9818F4265D00372C66 /* testthrix.c in Sources */ = {isa = PBXBuildFile; fileRef = 22561A9718F4263300372C66 /* testthrix.c */; }; + 22561A9918F4266600372C66 /* testthrix.c in Sources */ = {isa = PBXBuildFile; fileRef = 22561A9718F4263300372C66 /* testthrix.c */; }; + 22561A9A18F426BB00372C66 /* testthrix.c in Sources */ = {isa = PBXBuildFile; fileRef = 22561A9718F4263300372C66 /* testthrix.c */; }; + 22561A9B18F426F300372C66 /* testthrix.c in Sources */ = {isa = PBXBuildFile; fileRef = 22561A9718F4263300372C66 /* testthrix.c */; }; 2291A5B1175CAB2F001D4920 /* fmtdy.c in Sources */ = {isa = PBXBuildFile; fileRef = 3124CAC6156BE48D00753214 /* fmtdy.c */; }; 2291A5B2175CAB2F001D4920 /* fmtdytst.c in Sources */ = {isa = PBXBuildFile; fileRef = 3124CAC7156BE48D00753214 /* fmtdytst.c */; }; 2291A5B3175CAB2F001D4920 /* fmthe.c in Sources */ = {isa = PBXBuildFile; fileRef = 3124CAE4156BE6D500753214 /* fmthe.c */; }; @@ -113,6 +118,10 @@ 22C2ACA718BE400A006B3677 /* testlib.c in Sources */ = {isa = PBXBuildFile; fileRef = 31EEAC9E156AB73400714D05 /* testlib.c */; }; 22C2ACA918BE400A006B3677 /* libmps.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 31EEABFB156AAF9D00714D05 /* libmps.a */; }; 22C2ACB018BE4049006B3677 /* nailboardtest.c in Sources */ = {isa = PBXBuildFile; fileRef = 22C2ACA018BE3FEC006B3677 /* nailboardtest.c */; }; + 22F846B518F437B900982BA7 /* testlib.c in Sources */ = {isa = PBXBuildFile; fileRef = 31EEAC9E156AB73400714D05 /* testlib.c */; }; + 22F846B718F437B900982BA7 /* libmps.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 31EEABFB156AAF9D00714D05 /* libmps.a */; }; + 22F846BE18F437D700982BA7 /* lockut.c in Sources */ = {isa = PBXBuildFile; fileRef = 22F846AF18F4379C00982BA7 /* lockut.c */; }; + 22F846BF18F437E000982BA7 /* testthrix.c in Sources */ = {isa = PBXBuildFile; fileRef = 22561A9718F4263300372C66 /* testthrix.c */; }; 22FA176916E8D6FC0098B23F /* fmtdy.c in Sources */ = {isa = PBXBuildFile; fileRef = 3124CAC6156BE48D00753214 /* fmtdy.c */; }; 22FA176A16E8D6FC0098B23F /* fmtdytst.c in Sources */ = {isa = PBXBuildFile; fileRef = 3124CAC7156BE48D00753214 /* fmtdytst.c */; }; 22FA176B16E8D6FC0098B23F /* fmthe.c in Sources */ = {isa = PBXBuildFile; fileRef = 3124CAE4156BE6D500753214 /* fmthe.c */; }; @@ -327,6 +336,13 @@ remoteGlobalIDString = 2D604B9B16514B1A003AAF46; remoteInfo = mpseventtxt; }; + 2286E4C818F4389E004111E2 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 31EEABDA156AAE9E00714D05 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 22F846B018F437B900982BA7; + remoteInfo = lockut; + }; 2291A5AE175CAB2F001D4920 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 31EEABDA156AAE9E00714D05 /* Project object */; @@ -418,6 +434,13 @@ remoteGlobalIDString = 3104AFF1156D37A0000A585A; remoteInfo = all; }; + 22F846B218F437B900982BA7 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 31EEABDA156AAE9E00714D05 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 31EEABFA156AAF9D00714D05; + remoteInfo = mps; + }; 22FA176616E8D6FC0098B23F /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 31EEABDA156AAE9E00714D05 /* Project object */; @@ -955,6 +978,15 @@ ); runOnlyForDeploymentPostprocessing = 1; }; + 22F846B818F437B900982BA7 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; 22FA177016E8D6FC0098B23F /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -1297,6 +1329,8 @@ 2231BB6918CA983C002D6322 /* locusss.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = locusss.c; sourceTree = ""; }; 224CC799175E1821002FF81B /* fotest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = fotest; sourceTree = BUILT_PRODUCTS_DIR; }; 224CC79E175E3202002FF81B /* fotest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fotest.c; sourceTree = ""; }; + 22561A9618F4263300372C66 /* testthr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = testthr.h; sourceTree = ""; }; + 22561A9718F4263300372C66 /* testthrix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testthrix.c; sourceTree = ""; }; 2291A5A8175CAA51001D4920 /* poolmv2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = poolmv2.h; sourceTree = ""; }; 2291A5A9175CAA9B001D4920 /* awlutth.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = awlutth.c; sourceTree = ""; }; 2291A5AA175CAA9B001D4920 /* exposet0.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = exposet0.c; sourceTree = ""; }; @@ -1317,6 +1351,8 @@ 22C2ACAF18BE400A006B3677 /* nailboardtest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = nailboardtest; sourceTree = BUILT_PRODUCTS_DIR; }; 22E30E821886FF1400D98EA9 /* nailboard.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = nailboard.c; sourceTree = ""; }; 22E30E831886FF1400D98EA9 /* nailboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nailboard.h; sourceTree = ""; }; + 22F846AF18F4379C00982BA7 /* lockut.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lockut.c; sourceTree = ""; }; + 22F846BD18F437B900982BA7 /* lockut */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = lockut; sourceTree = BUILT_PRODUCTS_DIR; }; 22FA177516E8D6FC0098B23F /* amcssth */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = amcssth; sourceTree = BUILT_PRODUCTS_DIR; }; 22FA177616E8D7A80098B23F /* amcssth.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = amcssth.c; sourceTree = ""; }; 22FACED1188807FF000FDBC1 /* airtest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = airtest.c; sourceTree = ""; }; @@ -1326,8 +1362,6 @@ 22FACED5188807FF000FDBC1 /* fmtno.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fmtno.h; sourceTree = ""; }; 22FACED6188807FF000FDBC1 /* fmtscheme.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fmtscheme.c; sourceTree = ""; }; 22FACED7188807FF000FDBC1 /* fmtscheme.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fmtscheme.h; sourceTree = ""; }; - 22FACED8188807FF000FDBC1 /* locbwcss.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = locbwcss.c; sourceTree = ""; }; - 22FACED9188807FF000FDBC1 /* locusss.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = locusss.c; sourceTree = ""; }; 22FACEDA1888088A000FDBC1 /* ss.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ss.c; sourceTree = ""; }; 22FACEDB188808D5000FDBC1 /* mpscmfs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mpscmfs.h; sourceTree = ""; }; 22FACEDC18880933000FDBC1 /* poolmfs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = poolmfs.h; sourceTree = ""; }; @@ -1665,6 +1699,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 22F846B618F437B900982BA7 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 22F846B718F437B900982BA7 /* libmps.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 22FA176E16E8D6FC0098B23F /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -2080,6 +2122,7 @@ 3124CAB3156BE1B700753214 /* Tests */ = { isa = PBXGroup; children = ( + 22F846AF18F4379C00982BA7 /* lockut.c */, 3114A63D156E94EA001E0AA3 /* abqtest.c */, 22FACED1188807FF000FDBC1 /* airtest.c */, 3124CAF5156BE81100753214 /* amcss.c */, @@ -2127,6 +2170,8 @@ 3114A628156E949A001E0AA3 /* teletest.c */, 31EEAC9E156AB73400714D05 /* testlib.c */, 2291A5F0175CB7A4001D4920 /* testlib.h */, + 22561A9618F4263300372C66 /* testthr.h */, + 22561A9718F4263300372C66 /* testthrix.c */, 3114A6BA156E9768001E0AA3 /* walkt0.c */, 31D6005E156D3F4A00337B26 /* zcoll.c */, 31D6007B156D3FCC00337B26 /* zmess.c */, @@ -2220,6 +2265,7 @@ 2231BB6718CA97DC002D6322 /* locusss */, 22FACEED18880983000FDBC1 /* airtest */, 22C2ACAF18BE400A006B3677 /* nailboardtest */, + 22F846BD18F437B900982BA7 /* lockut */, ); name = Products; sourceTree = ""; @@ -2548,6 +2594,24 @@ productReference = 22C2ACAF18BE400A006B3677 /* nailboardtest */; productType = "com.apple.product-type.tool"; }; + 22F846B018F437B900982BA7 /* lockut */ = { + isa = PBXNativeTarget; + buildConfigurationList = 22F846B918F437B900982BA7 /* Build configuration list for PBXNativeTarget "lockut" */; + buildPhases = ( + 22F846B318F437B900982BA7 /* Sources */, + 22F846B618F437B900982BA7 /* Frameworks */, + 22F846B818F437B900982BA7 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + 22F846B118F437B900982BA7 /* PBXTargetDependency */, + ); + name = lockut; + productName = lockcov; + productReference = 22F846BD18F437B900982BA7 /* lockut */; + productType = "com.apple.product-type.tool"; + }; 22FA176416E8D6FC0098B23F /* amcssth */ = { isa = PBXNativeTarget; buildConfigurationList = 22FA177116E8D6FC0098B23F /* Build configuration list for PBXNativeTarget "amcssth" */; @@ -3274,6 +3338,7 @@ 2231BB4C18CA97D8002D6322 /* locbwcss */, 31D60026156D3D3E00337B26 /* lockcov */, 2231BB5A18CA97DC002D6322 /* locusss */, + 22F846B018F437B900982BA7 /* lockut */, 3114A58F156E913C001E0AA3 /* locv */, 3114A694156E971B001E0AA3 /* messtest */, 31EEAC64156AB52600714D05 /* mpmss */, @@ -3353,6 +3418,7 @@ 2291A5B3175CAB2F001D4920 /* fmthe.c in Sources */, 2291A5B4175CAB2F001D4920 /* fmtno.c in Sources */, 2291A5B5175CAB2F001D4920 /* testlib.c in Sources */, + 22561A9918F4266600372C66 /* testthrix.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3398,6 +3464,16 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 22F846B318F437B900982BA7 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 22F846BE18F437D700982BA7 /* lockut.c in Sources */, + 22F846B518F437B900982BA7 /* testlib.c in Sources */, + 22F846BF18F437E000982BA7 /* testthrix.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 22FA176716E8D6FC0098B23F /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -3408,6 +3484,7 @@ 22FA176B16E8D6FC0098B23F /* fmthe.c in Sources */, 22FA176C16E8D6FC0098B23F /* fmtno.c in Sources */, 22FA176D16E8D6FC0098B23F /* testlib.c in Sources */, + 22561A9818F4265D00372C66 /* testthrix.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3684,6 +3761,7 @@ 318DA8D31892B27E0089718C /* testlib.c in Sources */, 6313D47318A4028E00EB03EF /* djbench.c in Sources */, 318DA8D21892B13B0089718C /* getoptl.c in Sources */, + 22561A9A18F426BB00372C66 /* testthrix.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3791,6 +3869,7 @@ 6313D47518A40C6300EB03EF /* fmtdytst.c in Sources */, 6313D47618A40C7B00EB03EF /* fmtdy.c in Sources */, 6313D46A18A400B200EB03EF /* getoptl.c in Sources */, + 22561A9B18F426F300372C66 /* testthrix.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3832,6 +3911,11 @@ target = 2D604B9B16514B1A003AAF46 /* mpseventtxt */; targetProxy = 2275798816C5422900B662B0 /* PBXContainerItemProxy */; }; + 2286E4C918F4389E004111E2 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 22F846B018F437B900982BA7 /* lockut */; + targetProxy = 2286E4C818F4389E004111E2 /* PBXContainerItemProxy */; + }; 2291A5AD175CAB2F001D4920 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 31EEABFA156AAF9D00714D05 /* mps */; @@ -3897,6 +3981,11 @@ target = 3104AFF1156D37A0000A585A /* all */; targetProxy = 22CDE92D16E9EB9300366D0A /* PBXContainerItemProxy */; }; + 22F846B118F437B900982BA7 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 31EEABFA156AAF9D00714D05 /* mps */; + targetProxy = 22F846B218F437B900982BA7 /* PBXContainerItemProxy */; + }; 22FA176516E8D6FC0098B23F /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 31EEABFA156AAF9D00714D05 /* mps */; @@ -4400,6 +4489,27 @@ }; name = Release; }; + 22F846BA18F437B900982BA7 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = lockut; + }; + name = Debug; + }; + 22F846BB18F437B900982BA7 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = lockut; + }; + name = Release; + }; + 22F846BC18F437B900982BA7 /* RASH */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = lockut; + }; + name = RASH; + }; 22FA177216E8D6FC0098B23F /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -5537,6 +5647,16 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 22F846B918F437B900982BA7 /* Build configuration list for PBXNativeTarget "lockut" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 22F846BA18F437B900982BA7 /* Debug */, + 22F846BB18F437B900982BA7 /* Release */, + 22F846BC18F437B900982BA7 /* RASH */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 22FA177116E8D6FC0098B23F /* Build configuration list for PBXNativeTarget "amcssth" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/mps/code/testthr.h b/mps/code/testthr.h new file mode 100644 index 00000000000..341f4f407b5 --- /dev/null +++ b/mps/code/testthr.h @@ -0,0 +1,123 @@ +/* testthr.h: MULTI-THREADED TEST INTERFACE + * + * $Id: //info.ravenbrook.com/project/mps/master/code/testlib.h#30 $ + * Copyright (c) 2014 Ravenbrook Limited. See end of file for license. + * + * .purpose: Simple interface to threads that makes it possible to + * write test cases that are portable between Windows (using the + * implementation in testthrw3.c) and Unix (using the implementation + * in testthrix.c). + */ + +#ifndef testthr_h +#define testthr_h + +#include "mpstd.h" + + +/* testthr_routine_t -- type of thread routines + * + * Use the pthread type here and convert back and forth in the Windows + * implementation. + */ +typedef void *(*testthr_routine_t)(void *); + + +/* testthr_t -- type of thread identifiers + * + * It is necessary to define it here (even though it requires some + * #ifdefs) so that clients can allocate storage for them. + */ + +#if defined(MPS_OS_W3) + +#include "mpswin.h" + +/* On Windows, a thread is identified by a HANDLE. + * + * But use a structure so that the thread has somewhere to store its + * result for use by testthr_join. + */ +typedef struct testthr_t { + HANDLE handle; + testthr_routine_t start; + void *arg; /* argument to pass to start */ + void *result; /* result returned from start */ +} testthr_t; + +#elif defined(MPS_OS_FR) || defined(MPS_OS_LI) || defined(MPS_OS_XC) + +#include + +/* In pthreads, a thread is identified by a pthread_t, which is + * allowed "to be defined as a structure" [IEEE Std 1003.1, sys/types.h] + * + */ +typedef pthread_t testthr_t; + +#else +#error "Unknown platform: can't determine a type for testthr_t." +#endif + + +/* testthr_create -- create a thread + * + * Store the identifier of the newly created thread in *thread_o, and + * call start, passing arg as the single parameter. + */ + +void testthr_create(testthr_t *thread_o, testthr_routine_t start, void *arg); + + +/* testthr_join -- wait for a thread to complete + * + * Suspend execution of the calling thread until the target thread + * terminates (if necessary), and if result_o is non-NULL, update + * *result_o with the return value of the thread's start. + */ + +void testthr_join(testthr_t *thread, void **result_o); + +#endif /* testthr_h */ + + +/* C. COPYRIGHT AND LICENSE + * + * Copyright (C) 2014 Ravenbrook Limited . + * All rights reserved. This is an open source license. Contact + * Ravenbrook for commercial licensing options. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Redistributions in any form must be accompanied by information on how + * to obtain complete source code for this software and any accompanying + * software that uses this software. The source code must either be + * included in the distribution or be available for no more than the cost + * of distribution plus a nominal fee, and must be freely redistributable + * under reasonable conditions. For an executable file, complete source + * code means the source code for all modules it contains. It does not + * include source code for modules or files that typically accompany the + * major components of the operating system on which the executable file + * runs. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff --git a/mps/code/testthrix.c b/mps/code/testthrix.c new file mode 100644 index 00000000000..f4c544e0b8a --- /dev/null +++ b/mps/code/testthrix.c @@ -0,0 +1,66 @@ +/* testthrix.c: MULTI-THREADED TEST IMPLEMENTATION (POSIX THREADS) + * + * $Id: //info.ravenbrook.com/project/mps/master/code/testlib.h#30 $ + * Copyright (c) 2014 Ravenbrook Limited. See end of file for license. + */ + +#include "testlib.h" +#include "testthr.h" + +#include /* strerror */ + +void testthr_create(testthr_t *thread_o, testthr_routine_t start, void *arg) +{ + int res = pthread_create(thread_o, NULL, start, arg); + if (res != 0) + error("pthread_create failed with result %d (%s)", res, strerror(res)); +} + +void testthr_join(testthr_t *thread, void **result_o) +{ + int res = pthread_join(*thread, result_o); + if (res != 0) + error("pthread_join failed with result %d (%s)", res, strerror(res)); +} + + +/* C. COPYRIGHT AND LICENSE + * + * Copyright (C) 2014 Ravenbrook Limited . + * All rights reserved. This is an open source license. Contact + * Ravenbrook for commercial licensing options. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Redistributions in any form must be accompanied by information on how + * to obtain complete source code for this software and any accompanying + * software that uses this software. The source code must either be + * included in the distribution or be available for no more than the cost + * of distribution plus a nominal fee, and must be freely redistributable + * under reasonable conditions. For an executable file, complete source + * code means the source code for all modules it contains. It does not + * include source code for modules or files that typically accompany the + * major components of the operating system on which the executable file + * runs. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff --git a/mps/code/testthrw3.c b/mps/code/testthrw3.c new file mode 100644 index 00000000000..cd5cf54ae79 --- /dev/null +++ b/mps/code/testthrw3.c @@ -0,0 +1,80 @@ +/* testthrw3.c: MULTI-THREADED TEST IMPLEMENTATION (WINDOWS) + * + * $Id: //info.ravenbrook.com/project/mps/master/code/testlib.h#30 $ + * Copyright (c) 2014 Ravenbrook Limited. See end of file for license. + */ + +#include "testlib.h" +#include "testthr.h" + +static DWORD WINAPI testthr_start(LPVOID arg) +{ + testthr_t *thread = arg; + thread->result = (*thread->start)(thread->arg); + return 0; +} + +void testthr_create(testthr_t *thread_o, testthr_routine_t start, void *arg) +{ + HANDLE res; + thread_o->start = start; + thread_o->arg = arg; + res = CreateThread(NULL, 0, testthr_start, thread_o, 0, NULL); + if (res == NULL) + error("CreateThread failed with error %lu", + (unsigned long)GetLastError()); + else + thread_o->handle = res; +} + +void testthr_join(testthr_t *thread, void **result_o) +{ + DWORD res = WaitForSingleObject(thread->handle, INFINITE); + if (res != WAIT_OBJECT_0) + error("WaitForSingleObject failed with result %lu (error %lu)", + (unsigned long)res, (unsigned long)GetLastError()); + if (result_o) + *result_o = thread->result; +} + + +/* C. COPYRIGHT AND LICENSE + * + * Copyright (C) 2014 Ravenbrook Limited . + * All rights reserved. This is an open source license. Contact + * Ravenbrook for commercial licensing options. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Redistributions in any form must be accompanied by information on how + * to obtain complete source code for this software and any accompanying + * software that uses this software. The source code must either be + * included in the distribution or be available for no more than the cost + * of distribution plus a nominal fee, and must be freely redistributable + * under reasonable conditions. For an executable file, complete source + * code means the source code for all modules it contains. It does not + * include source code for modules or files that typically accompany the + * major components of the operating system on which the executable file + * runs. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR + * PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ diff --git a/mps/tool/testrun.bat b/mps/tool/testrun.bat index 186f0f564bb..25994211d15 100755 --- a/mps/tool/testrun.bat +++ b/mps/tool/testrun.bat @@ -39,7 +39,7 @@ set ALL_TEST_CASES=^ fotest.exe ^ locbwcss.exe ^ lockcov.exe ^ - lockutw3.exe ^ + lockut.exe ^ locusss.exe ^ locv.exe ^ messtest.exe ^ diff --git a/mps/tool/testrun.sh b/mps/tool/testrun.sh index 4d0b1040942..175443bf820 100755 --- a/mps/tool/testrun.sh +++ b/mps/tool/testrun.sh @@ -36,6 +36,7 @@ ALL_TEST_CASES=" fotest locbwcss lockcov + lockut locusss locv messtest