Overview
Comment: | Split threading.h into threading.m and threading.h |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
1da2e596afb580ea9a13cc3541bcac5c |
User & Date: | js on 2014-07-18 10:47:36 |
Other Links: | manifest | tags |
Context
2014-07-18
| ||
11:00 | PLATFORMS.md: Add bare metal ARM Cortex-M4 check-in: 7d763c59aa user: js tags: trunk | |
10:47 | Split threading.h into threading.m and threading.h check-in: 1da2e596af user: js tags: trunk | |
10:08 | OFApplication: Only use argv if argc > 0 check-in: c1dbf3b212 user: js tags: trunk | |
Changes
Modified ObjFW.xcodeproj/project.pbxproj from [c6a5f00302] to [87fb892c02].
︙ | ︙ | |||
140 141 142 143 144 145 146 147 148 149 150 151 152 153 | 4B2B3E82140D430500EC2F7C /* OFMutableArray_adjacent.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B2B3E78140D430500EC2F7C /* OFMutableArray_adjacent.m */; }; 4B2B3E83140D430500EC2F7C /* OFMutableDictionary_hashtable.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B2B3E79140D430500EC2F7C /* OFMutableDictionary_hashtable.h */; settings = {ATTRIBUTES = (); }; }; 4B2B3E84140D430500EC2F7C /* OFMutableDictionary_hashtable.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B2B3E7A140D430500EC2F7C /* OFMutableDictionary_hashtable.m */; }; 4B325EDD1605F3A0007836CA /* OFRunLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B325ED91605F3A0007836CA /* OFRunLoop.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B325EDE1605F3A0007836CA /* OFRunLoop.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B325EDA1605F3A0007836CA /* OFRunLoop.m */; }; 4B325EDF1605F3A0007836CA /* OFTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B325EDB1605F3A0007836CA /* OFTimer.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B325EE01605F3A0007836CA /* OFTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B325EDC1605F3A0007836CA /* OFTimer.m */; }; 4B39844213D3A24600E6F825 /* OFSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B39844013D3A24600E6F825 /* OFSet.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B39844313D3A24600E6F825 /* OFSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B39844113D3A24600E6F825 /* OFSet.m */; }; 4B39844713D3AFB400E6F825 /* OFMutableSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B39844513D3AFB400E6F825 /* OFMutableSet.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B39844813D3AFB400E6F825 /* OFMutableSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B39844613D3AFB400E6F825 /* OFMutableSet.m */; }; 4B3B0798166978780044E634 /* OFMapTable.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B3B0796166978780044E634 /* OFMapTable.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3B0799166978780044E634 /* OFMapTable.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B3B0797166978780044E634 /* OFMapTable.m */; }; 4B3D238B1337FC0D00DD29B8 /* OFApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B175C1E116D130B003C99CB /* OFApplication.m */; }; | > | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | 4B2B3E82140D430500EC2F7C /* OFMutableArray_adjacent.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B2B3E78140D430500EC2F7C /* OFMutableArray_adjacent.m */; }; 4B2B3E83140D430500EC2F7C /* OFMutableDictionary_hashtable.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B2B3E79140D430500EC2F7C /* OFMutableDictionary_hashtable.h */; settings = {ATTRIBUTES = (); }; }; 4B2B3E84140D430500EC2F7C /* OFMutableDictionary_hashtable.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B2B3E7A140D430500EC2F7C /* OFMutableDictionary_hashtable.m */; }; 4B325EDD1605F3A0007836CA /* OFRunLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B325ED91605F3A0007836CA /* OFRunLoop.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B325EDE1605F3A0007836CA /* OFRunLoop.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B325EDA1605F3A0007836CA /* OFRunLoop.m */; }; 4B325EDF1605F3A0007836CA /* OFTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B325EDB1605F3A0007836CA /* OFTimer.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B325EE01605F3A0007836CA /* OFTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B325EDC1605F3A0007836CA /* OFTimer.m */; }; 4B3379CF1979326A0088E97E /* threading.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B3379CE1979326A0088E97E /* threading.m */; }; 4B39844213D3A24600E6F825 /* OFSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B39844013D3A24600E6F825 /* OFSet.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B39844313D3A24600E6F825 /* OFSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B39844113D3A24600E6F825 /* OFSet.m */; }; 4B39844713D3AFB400E6F825 /* OFMutableSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B39844513D3AFB400E6F825 /* OFMutableSet.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B39844813D3AFB400E6F825 /* OFMutableSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B39844613D3AFB400E6F825 /* OFMutableSet.m */; }; 4B3B0798166978780044E634 /* OFMapTable.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B3B0796166978780044E634 /* OFMapTable.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B3B0799166978780044E634 /* OFMapTable.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B3B0797166978780044E634 /* OFMapTable.m */; }; 4B3D238B1337FC0D00DD29B8 /* OFApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B175C1E116D130B003C99CB /* OFApplication.m */; }; |
︙ | ︙ | |||
616 617 618 619 620 621 622 623 624 625 626 627 628 629 | 4B2B3E78140D430500EC2F7C /* OFMutableArray_adjacent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFMutableArray_adjacent.m; path = src/OFMutableArray_adjacent.m; sourceTree = "<group>"; }; 4B2B3E79140D430500EC2F7C /* OFMutableDictionary_hashtable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFMutableDictionary_hashtable.h; path = src/OFMutableDictionary_hashtable.h; sourceTree = "<group>"; }; 4B2B3E7A140D430500EC2F7C /* OFMutableDictionary_hashtable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFMutableDictionary_hashtable.m; path = src/OFMutableDictionary_hashtable.m; sourceTree = "<group>"; }; 4B325ED91605F3A0007836CA /* OFRunLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFRunLoop.h; path = src/OFRunLoop.h; sourceTree = "<group>"; }; 4B325EDA1605F3A0007836CA /* OFRunLoop.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFRunLoop.m; path = src/OFRunLoop.m; sourceTree = "<group>"; }; 4B325EDB1605F3A0007836CA /* OFTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFTimer.h; path = src/OFTimer.h; sourceTree = "<group>"; }; 4B325EDC1605F3A0007836CA /* OFTimer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFTimer.m; path = src/OFTimer.m; sourceTree = "<group>"; }; 4B39844013D3A24600E6F825 /* OFSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFSet.h; path = src/OFSet.h; sourceTree = "<group>"; }; 4B39844113D3A24600E6F825 /* OFSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFSet.m; path = src/OFSet.m; sourceTree = "<group>"; }; 4B39844513D3AFB400E6F825 /* OFMutableSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFMutableSet.h; path = src/OFMutableSet.h; sourceTree = "<group>"; }; 4B39844613D3AFB400E6F825 /* OFMutableSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFMutableSet.m; path = src/OFMutableSet.m; sourceTree = "<group>"; }; 4B3B0796166978780044E634 /* OFMapTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFMapTable.h; path = src/OFMapTable.h; sourceTree = "<group>"; }; 4B3B0797166978780044E634 /* OFMapTable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFMapTable.m; path = src/OFMapTable.m; sourceTree = "<group>"; }; 4B3D236D1337FB5800DD29B8 /* base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = base64.h; path = src/base64.h; sourceTree = "<group>"; }; | > | 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 | 4B2B3E78140D430500EC2F7C /* OFMutableArray_adjacent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFMutableArray_adjacent.m; path = src/OFMutableArray_adjacent.m; sourceTree = "<group>"; }; 4B2B3E79140D430500EC2F7C /* OFMutableDictionary_hashtable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFMutableDictionary_hashtable.h; path = src/OFMutableDictionary_hashtable.h; sourceTree = "<group>"; }; 4B2B3E7A140D430500EC2F7C /* OFMutableDictionary_hashtable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFMutableDictionary_hashtable.m; path = src/OFMutableDictionary_hashtable.m; sourceTree = "<group>"; }; 4B325ED91605F3A0007836CA /* OFRunLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFRunLoop.h; path = src/OFRunLoop.h; sourceTree = "<group>"; }; 4B325EDA1605F3A0007836CA /* OFRunLoop.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFRunLoop.m; path = src/OFRunLoop.m; sourceTree = "<group>"; }; 4B325EDB1605F3A0007836CA /* OFTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFTimer.h; path = src/OFTimer.h; sourceTree = "<group>"; }; 4B325EDC1605F3A0007836CA /* OFTimer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFTimer.m; path = src/OFTimer.m; sourceTree = "<group>"; }; 4B3379CE1979326A0088E97E /* threading.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = threading.m; path = src/threading.m; sourceTree = "<group>"; }; 4B39844013D3A24600E6F825 /* OFSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFSet.h; path = src/OFSet.h; sourceTree = "<group>"; }; 4B39844113D3A24600E6F825 /* OFSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFSet.m; path = src/OFSet.m; sourceTree = "<group>"; }; 4B39844513D3AFB400E6F825 /* OFMutableSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFMutableSet.h; path = src/OFMutableSet.h; sourceTree = "<group>"; }; 4B39844613D3AFB400E6F825 /* OFMutableSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFMutableSet.m; path = src/OFMutableSet.m; sourceTree = "<group>"; }; 4B3B0796166978780044E634 /* OFMapTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFMapTable.h; path = src/OFMapTable.h; sourceTree = "<group>"; }; 4B3B0797166978780044E634 /* OFMapTable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFMapTable.m; path = src/OFMapTable.m; sourceTree = "<group>"; }; 4B3D236D1337FB5800DD29B8 /* base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = base64.h; path = src/base64.h; sourceTree = "<group>"; }; |
︙ | ︙ | |||
1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 | 4BA355B914879BDD00442EF4 /* of_strptime.m */, 4B7769EB1895C07D00D12284 /* resolver.h */, 4B7769EC1895C07D00D12284 /* resolver.m */, 4B7DD58718943D4A00990FD6 /* socket.h */, 4B40EC1A189FE2650031E19E /* socket.m */, 4B7DD58118942FE200990FD6 /* socket_helpers.h */, 4B67998B1099E7C50041064A /* threading.h */, 4B67998C1099E7C50041064A /* unicode.h */, 4BFBDD1610A0724800051AFB /* unicode.m */, 4B6AF97210A8D42E0003FB0A /* windows_1252.m */, ); name = ObjFW; sourceTree = "<group>"; }; | > | 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 | 4BA355B914879BDD00442EF4 /* of_strptime.m */, 4B7769EB1895C07D00D12284 /* resolver.h */, 4B7769EC1895C07D00D12284 /* resolver.m */, 4B7DD58718943D4A00990FD6 /* socket.h */, 4B40EC1A189FE2650031E19E /* socket.m */, 4B7DD58118942FE200990FD6 /* socket_helpers.h */, 4B67998B1099E7C50041064A /* threading.h */, 4B3379CE1979326A0088E97E /* threading.m */, 4B67998C1099E7C50041064A /* unicode.h */, 4BFBDD1610A0724800051AFB /* unicode.m */, 4B6AF97210A8D42E0003FB0A /* windows_1252.m */, ); name = ObjFW; sourceTree = "<group>"; }; |
︙ | ︙ | |||
2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 | 4BB52CC717B8EA7F00B7EBF5 /* codepage_437.m in Sources */, 4B3D23B41337FC0D00DD29B8 /* iso_8859_15.m in Sources */, 4B3D23B51337FC0D00DD29B8 /* foundation-compat.m in Sources */, 4B3D23EE1337FFD000DD29B8 /* of_asprintf.m in Sources */, 4BA355BA14879BDD00442EF4 /* of_strptime.m in Sources */, 4B7769EE1895C07D00D12284 /* resolver.m in Sources */, 4B40EC1B189FE2650031E19E /* socket.m in Sources */, 4B3D23B91337FC0D00DD29B8 /* unicode.m in Sources */, 4B3D23BA1337FC0D00DD29B8 /* windows_1252.m in Sources */, 4B90B79F133AD87D00BD33CB /* OFAcceptFailedException.m in Sources */, 4B90B7A1133AD87D00BD33CB /* OFAddressTranslationFailedException.m in Sources */, 4B17FF80133A2D17003E6DCD /* OFAllocFailedException.m in Sources */, 4B90B78E133AD46700BD33CB /* OFAlreadyConnectedException.m in Sources */, 4B90B7A3133AD87D00BD33CB /* OFBindFailedException.m in Sources */, | > | 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 | 4BB52CC717B8EA7F00B7EBF5 /* codepage_437.m in Sources */, 4B3D23B41337FC0D00DD29B8 /* iso_8859_15.m in Sources */, 4B3D23B51337FC0D00DD29B8 /* foundation-compat.m in Sources */, 4B3D23EE1337FFD000DD29B8 /* of_asprintf.m in Sources */, 4BA355BA14879BDD00442EF4 /* of_strptime.m in Sources */, 4B7769EE1895C07D00D12284 /* resolver.m in Sources */, 4B40EC1B189FE2650031E19E /* socket.m in Sources */, 4B3379CF1979326A0088E97E /* threading.m in Sources */, 4B3D23B91337FC0D00DD29B8 /* unicode.m in Sources */, 4B3D23BA1337FC0D00DD29B8 /* windows_1252.m in Sources */, 4B90B79F133AD87D00BD33CB /* OFAcceptFailedException.m in Sources */, 4B90B7A1133AD87D00BD33CB /* OFAddressTranslationFailedException.m in Sources */, 4B17FF80133A2D17003E6DCD /* OFAllocFailedException.m in Sources */, 4B90B78E133AD46700BD33CB /* OFAlreadyConnectedException.m in Sources */, 4B90B7A3133AD87D00BD33CB /* OFBindFailedException.m in Sources */, |
︙ | ︙ |
Modified configure.ac from [946d2ef267] to [7a71a1c5d4].
︙ | ︙ | |||
559 560 561 562 563 564 565 | AC_MSG_ERROR(No supported threads found!) ]) ;; esac AC_DEFINE(OF_HAVE_THREADS, 1, [Whether we have threads]) AC_SUBST(USE_SRCS_THREADS, '${SRCS_THREADS}') | < | 559 560 561 562 563 564 565 566 567 568 569 570 571 572 | AC_MSG_ERROR(No supported threads found!) ]) ;; esac AC_DEFINE(OF_HAVE_THREADS, 1, [Whether we have threads]) AC_SUBST(USE_SRCS_THREADS, '${SRCS_THREADS}') AC_ARG_ENABLE(compiler-tls, AS_HELP_STRING([--disable-compiler-tls], [disable compiler thread local storage])) AS_IF([test x"$enable_compiler_tls" != x"no"], [ AC_CHECK_HEADERS(threads.h, [ AC_DEFINE(OF_HAVE_THREADS_H, 1, |
︙ | ︙ |
Modified extra.mk.in from [41d3c65d8c] to [fca629a66d].
︙ | ︙ | |||
43 44 45 46 47 48 49 | RUNTIME_RUNTIME_A = @RUNTIME_RUNTIME_A@ RUNTIME_RUNTIME_LIB_A = @RUNTIME_RUNTIME_LIB_A@ RUNTIME_LIB_A = @RUNTIME_LIB_A@ RUN_TESTS = @RUN_TESTS@ TESTPLUGIN = @TESTPLUGIN@ TESTS_LIBS = @TESTS_LIBS@ TEST_LAUNCHER = @TEST_LAUNCHER@ | < | 43 44 45 46 47 48 49 50 51 52 53 | RUNTIME_RUNTIME_A = @RUNTIME_RUNTIME_A@ RUNTIME_RUNTIME_LIB_A = @RUNTIME_RUNTIME_LIB_A@ RUNTIME_LIB_A = @RUNTIME_LIB_A@ RUN_TESTS = @RUN_TESTS@ TESTPLUGIN = @TESTPLUGIN@ TESTS_LIBS = @TESTS_LIBS@ TEST_LAUNCHER = @TEST_LAUNCHER@ USE_SRCS_FILES = @USE_SRCS_FILES@ USE_SRCS_PLUGINS = @USE_SRCS_PLUGINS@ USE_SRCS_SOCKETS = @USE_SRCS_SOCKETS@ USE_SRCS_THREADS = @USE_SRCS_THREADS@ |
Modified src/Makefile from [cb3f5cbc4f] to [eff0314f0c].
︙ | ︙ | |||
92 93 94 95 96 97 98 | OFTCPSocket.m \ OFUDPSocket.m \ resolver.m \ socket.m SRCS_THREADS = OFCondition.m \ OFMutex.m \ OFRecursiveMutex.m \ | | > < | < | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | OFTCPSocket.m \ OFUDPSocket.m \ resolver.m \ socket.m SRCS_THREADS = OFCondition.m \ OFMutex.m \ OFRecursiveMutex.m \ OFThreadPool.m \ threading.m INCLUDES := ${SRCS:.m=.h} \ OFCollection.h \ OFHash.h \ OFJSONRepresentation.h \ OFLocking.h \ OFMessagePackRepresentation.h \ OFSerialization.h \ OFTLSSocket.h \ ObjFW.h \ asprintf.h \ autorelease.h \ ${ATOMIC_H} \ block.h \ instance.h \ macros.h \ objfw-defs.h SRCS += OFArray_adjacent.m \ OFArray_adjacentSubarray.m \ OFCountedSet_hashtable.m \ OFDictionary_hashtable.m \ OFMutableArray_adjacent.m \ OFMutableDictionary_hashtable.m \ |
︙ | ︙ |
Modified src/threading.h from [90da9579d7] to [25e6067bdf].
︙ | ︙ | |||
82 83 84 85 86 87 88 | # define of_thread_is_current(t) (t == GetCurrentThread()) # define of_thread_current GetCurrentThread #else # error of_thread_is_current not implemented! # error of_thread_current not implemented! #endif | < | < < < < < < < < < < < < < < < | < < < | < | | < < < < < < < < | < | < < < < < | | < < < < < < < < < < < | < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < | < | < < < < < < < < < < | < | < < < < < < < < | < | | | < < < < < < < < < < | < | < < < < < < < > < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | # define of_thread_is_current(t) (t == GetCurrentThread()) # define of_thread_current GetCurrentThread #else # error of_thread_is_current not implemented! # error of_thread_current not implemented! #endif extern bool of_thread_new(of_thread_t *thread, id (*function)(id), id data); extern bool of_thread_join(of_thread_t thread); extern bool of_thread_detach(of_thread_t thread); extern void noreturn of_thread_exit(void); extern void of_once(of_once_t *control, void (*func)(void)); extern bool of_mutex_new(of_mutex_t *mutex); extern bool of_mutex_lock(of_mutex_t *mutex); extern bool of_mutex_trylock(of_mutex_t *mutex); extern bool of_mutex_unlock(of_mutex_t *mutex); extern bool of_mutex_free(of_mutex_t *mutex); extern bool of_rmutex_new(of_rmutex_t *rmutex); extern bool of_rmutex_lock(of_rmutex_t *rmutex); extern bool of_rmutex_trylock(of_rmutex_t *rmutex); extern bool of_rmutex_unlock(of_rmutex_t *rmutex); extern bool of_rmutex_free(of_rmutex_t *rmutex); extern bool of_condition_new(of_condition_t *condition); extern bool of_condition_signal(of_condition_t *condition); extern bool of_condition_broadcast(of_condition_t *condition); extern bool of_condition_wait(of_condition_t *condition, of_mutex_t *mutex); extern bool of_condition_timed_wait(of_condition_t *condition, of_mutex_t *mutex, of_time_interval_t timeout); extern bool of_condition_free(of_condition_t *condition); /* TLS keys and spinlocks are inlined for performance. */ static OF_INLINE bool of_tlskey_new(of_tlskey_t *key) { #if defined(OF_HAVE_PTHREADS) return !pthread_key_create(key, NULL); #elif defined(_WIN32) |
︙ | ︙ | |||
483 484 485 486 487 488 489 | return true; #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) return !pthread_spin_destroy(spinlock); #else return of_mutex_free(spinlock); #endif } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 232 233 234 235 236 237 238 | return true; #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) return !pthread_spin_destroy(spinlock); #else return of_mutex_free(spinlock); #endif } |
Added src/threading.m version [fb1fdd6d5c].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | /* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 * Jonathan Schleifer <js@webkeks.org> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "threading.h" bool of_thread_new(of_thread_t *thread, id (*function)(id), id data) { #if defined(OF_HAVE_PTHREADS) return (pthread_create(thread, NULL, (void*(*)(void*))function, (__bridge void*)data) == 0); #elif defined(_WIN32) *thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)function, (__bridge void*)data, 0, NULL); return (thread != NULL); #else # error of_thread_new not implemented! #endif } bool of_thread_join(of_thread_t thread) { #if defined(OF_HAVE_PTHREADS) void *ret; if (pthread_join(thread, &ret) != 0) return false; # ifdef PTHREAD_CANCELED return (ret != PTHREAD_CANCELED); # else return true; # endif #elif defined(_WIN32) if (WaitForSingleObject(thread, INFINITE)) return false; CloseHandle(thread); return true; #else # error of_thread_join not implemented! #endif } bool of_thread_detach(of_thread_t thread) { #if defined(OF_HAVE_PTHREADS) return !pthread_detach(thread); #elif defined(_WIN32) /* FIXME */ return true; #else # error of_thread_detach not implemented! #endif } void noreturn of_thread_exit(void) { #if defined(OF_HAVE_PTHREADS) pthread_exit(NULL); #elif defined(_WIN32) ExitThread(0); #else # error of_thread_exit not implemented! #endif OF_UNREACHABLE } void of_once(of_once_t *control, void (*func)(void)) { #if defined(OF_HAVE_PTHREADS) pthread_once(control, func); #elif defined(_WIN32) switch (InterlockedCompareExchange(control, 1, 0)) { case 0: func(); InterlockedIncrement(control); break; case 1: while (*control == 1) Sleep(0); break; } #else # error of_once not implemented! #endif } bool of_mutex_new(of_mutex_t *mutex) { #if defined(OF_HAVE_PTHREADS) return !pthread_mutex_init(mutex, NULL); #elif defined(_WIN32) InitializeCriticalSection(mutex); return true; #else # error of_mutex_new not implemented! #endif } bool of_mutex_lock(of_mutex_t *mutex) { #if defined(OF_HAVE_PTHREADS) return !pthread_mutex_lock(mutex); #elif defined(_WIN32) EnterCriticalSection(mutex); return true; #else # error of_mutex_lock not implemented! #endif } bool of_mutex_trylock(of_mutex_t *mutex) { #if defined(OF_HAVE_PTHREADS) return !pthread_mutex_trylock(mutex); #elif defined(_WIN32) return TryEnterCriticalSection(mutex); #else # error of_mutex_trylock not implemented! #endif } bool of_mutex_unlock(of_mutex_t *mutex) { #if defined(OF_HAVE_PTHREADS) return (pthread_mutex_unlock(mutex) == 0); #elif defined(_WIN32) LeaveCriticalSection(mutex); return true; #else # error of_mutex_unlock not implemented! #endif } bool of_mutex_free(of_mutex_t *mutex) { #if defined(OF_HAVE_PTHREADS) return !pthread_mutex_destroy(mutex); #elif defined(_WIN32) DeleteCriticalSection(mutex); return true; #else # error of_mutex_free not implemented! #endif } bool of_rmutex_new(of_rmutex_t *rmutex) { #ifdef OF_HAVE_RECURSIVE_PTHREAD_MUTEXES pthread_mutexattr_t attr; if (pthread_mutexattr_init(&attr) != 0) return false; if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0) return false; if (pthread_mutex_init(rmutex, &attr) != 0) return false; if (pthread_mutexattr_destroy(&attr) != 0) return false; return true; #else if (!of_mutex_new(&rmutex->mutex)) return false; if (!of_tlskey_new(&rmutex->count)) return false; return true; #endif } bool of_rmutex_lock(of_rmutex_t *rmutex) { #ifdef OF_HAVE_RECURSIVE_PTHREAD_MUTEXES return of_mutex_lock(rmutex); #else uintptr_t count = (uintptr_t)of_tlskey_get(rmutex->count); if (count > 0) { if (!of_tlskey_set(rmutex->count, (void*)(count + 1))) return false; return true; } if (!of_mutex_lock(&rmutex->mutex)) return false; if (!of_tlskey_set(rmutex->count, (void*)1)) { of_mutex_unlock(&rmutex->mutex); return false; } return true; #endif } bool of_rmutex_trylock(of_rmutex_t *rmutex) { #ifdef OF_HAVE_RECURSIVE_PTHREAD_MUTEXES return of_mutex_trylock(rmutex); #else uintptr_t count = (uintptr_t)of_tlskey_get(rmutex->count); if (count > 0) { if (!of_tlskey_set(rmutex->count, (void*)(count + 1))) return false; return true; } if (!of_mutex_trylock(&rmutex->mutex)) return false; if (!of_tlskey_set(rmutex->count, (void*)1)) { of_mutex_unlock(&rmutex->mutex); return false; } return true; #endif } bool of_rmutex_unlock(of_rmutex_t *rmutex) { #ifdef OF_HAVE_RECURSIVE_PTHREAD_MUTEXES return of_mutex_unlock(rmutex); #else uintptr_t count = (uintptr_t)of_tlskey_get(rmutex->count); if (count > 1) { if (!of_tlskey_set(rmutex->count, (void*)(count - 1))) return false; return true; } if (!of_tlskey_set(rmutex->count, (void*)0)) return false; if (!of_mutex_unlock(&rmutex->mutex)) return false; return true; #endif } bool of_rmutex_free(of_rmutex_t *rmutex) { #ifdef OF_HAVE_RECURSIVE_PTHREAD_MUTEXES return of_mutex_free(rmutex); #else if (!of_mutex_free(&rmutex->mutex)) return false; if (!of_tlskey_free(rmutex->count)) return false; return true; #endif } bool of_condition_new(of_condition_t *condition) { #if defined(OF_HAVE_PTHREADS) return (pthread_cond_init(condition, NULL) == 0); #elif defined(_WIN32) condition->count = 0; if ((condition->event = CreateEvent(NULL, FALSE, 0, NULL)) == NULL) return false; return true; #else # error of_condition_new not implemented! #endif } bool of_condition_signal(of_condition_t *condition) { #if defined(OF_HAVE_PTHREADS) return !pthread_cond_signal(condition); #elif defined(_WIN32) return SetEvent(condition->event); #else # error of_condition_signal not implemented! #endif } bool of_condition_broadcast(of_condition_t *condition) { #if defined(OF_HAVE_PTHREADS) return !pthread_cond_broadcast(condition); #elif defined(_WIN32) int i; for (i = 0; i < condition->count; i++) if (!SetEvent(condition->event)) return false; return true; #else # error of_condition_broadcast not implemented! #endif } bool of_condition_wait(of_condition_t *condition, of_mutex_t *mutex) { #if defined(OF_HAVE_PTHREADS) return !pthread_cond_wait(condition, mutex); #elif defined(_WIN32) if (!of_mutex_unlock(mutex)) return false; of_atomic_int_inc(&condition->count); if (WaitForSingleObject(condition->event, INFINITE) != WAIT_OBJECT_0) { of_mutex_lock(mutex); return false; } of_atomic_int_dec(&condition->count); if (!of_mutex_lock(mutex)) return false; return true; #else # error of_condition_wait not implemented! #endif } bool of_condition_timed_wait(of_condition_t *condition, of_mutex_t *mutex, of_time_interval_t timeout) { #if defined(OF_HAVE_PTHREADS) struct timespec ts; ts.tv_sec = (time_t)timeout; ts.tv_nsec = lrint((timeout - ts.tv_sec) * 1000000000); return !pthread_cond_timedwait(condition, mutex, &ts); #elif defined(_WIN32) if (!of_mutex_unlock(mutex)) return false; of_atomic_int_inc(&condition->count); if (WaitForSingleObject(condition->event, timeout * 1000) != WAIT_OBJECT_0) { of_mutex_lock(mutex); return false; } of_atomic_int_dec(&condition->count); if (!of_mutex_lock(mutex)) return false; return true; #else # error of_condition_timed_wait not implemented! #endif } bool of_condition_free(of_condition_t *condition) { #if defined(OF_HAVE_PTHREADS) return !pthread_cond_destroy(condition); #elif defined(_WIN32) if (condition->count) return false; return CloseHandle(condition->event); #else # error of_condition_free not implemented! #endif } |