Merge lp:~johill-lanl/epics-base/epicsThreadOnce-atomics-based into lp:~epics-core/epics-base/3.15
- epicsThreadOnce-atomics-based
- Merge into 3.15
Status: | Superseded |
---|---|
Proposed branch: | lp:~johill-lanl/epics-base/epicsThreadOnce-atomics-based |
Merge into: | lp:~epics-core/epics-base/3.15 |
Diff against target: |
3899 lines (+3245/-276) (has conflicts) 38 files modified
configure/CONFIG.gnuCommon (+2/-0) configure/CONFIG_COMMON (+18/-4) configure/RULES_BUILD (+5/-1) configure/os/CONFIG.solarisCommon.solarisCommon (+2/-0) configure/os/CONFIG.win32-x86.win32-x86 (+3/-1) src/libCom/Makefile (+283/-0) src/libCom/misc/compilerDependencies.h (+0/-104) src/libCom/misc/ipAddrToAsciiAsynchronous.cpp (+1/-1) src/libCom/osi/compiler/borland/compilerSpecific.h (+55/-0) src/libCom/osi/compiler/clang/compilerSpecific.h (+59/-0) src/libCom/osi/compiler/clang/epicsAtomicCD.h (+27/-0) src/libCom/osi/compiler/default/compilerSpecific.h (+45/-0) src/libCom/osi/compiler/default/epicsAtomicCD.h (+25/-0) src/libCom/osi/compiler/gcc/compilerSpecific.h (+62/-0) src/libCom/osi/compiler/gcc/epicsAtomicCD.h (+172/-0) src/libCom/osi/compiler/msvc/compilerSpecific.h (+57/-0) src/libCom/osi/compiler/msvc/epicsAtomicCD.h (+124/-0) src/libCom/osi/compiler/solStudio/epicsAtomicCD.h (+27/-0) src/libCom/osi/compilerDependencies.h (+47/-0) src/libCom/osi/epicsAtomic.h (+237/-0) src/libCom/osi/epicsAtomicDefault.h (+235/-0) src/libCom/osi/epicsThread.h (+1/-1) src/libCom/osi/epicsThreadOnce.cpp (+129/-0) src/libCom/osi/os/RTEMS/osdThread.c (+0/-32) src/libCom/osi/os/WIN32/epicsAtomicMS.h (+222/-0) src/libCom/osi/os/WIN32/epicsAtomicOSD.cpp (+22/-0) src/libCom/osi/os/WIN32/epicsAtomicOSD.h (+49/-0) src/libCom/osi/os/WIN32/osdThread.c (+0/-35) src/libCom/osi/os/posix/epicsAtomicOSD.cpp (+108/-0) src/libCom/osi/os/posix/epicsAtomicOSD.h (+32/-0) src/libCom/osi/os/posix/osdThread.c (+0/-44) src/libCom/osi/os/solaris/epicsAtomicOSD.h (+166/-0) src/libCom/osi/os/vxWorks/epicsAtomicOSD.cpp (+22/-0) src/libCom/osi/os/vxWorks/epicsAtomicOSD.h (+255/-0) src/libCom/osi/os/vxWorks/osdThread.c (+0/-53) src/libCom/test/Makefile (+9/-0) src/libCom/test/epicsAtomicPerform.cpp (+506/-0) src/libCom/test/epicsAtomicTest.cpp (+238/-0) Text conflict in src/libCom/Makefile |
To merge this branch: | bzr merge lp:~johill-lanl/epics-base/epicsThreadOnce-atomics-based |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
EPICS Core Developers | Pending | ||
Review via email: mp+73605@code.launchpad.net |
This proposal has been superseded by a proposal from 2011-08-31.
Commit message
Description of the change
o added new epicsAtomics based, and OS independent, implementation of epicsThreadOnce in epicsThreadOnce.cpp
o changed type of epicsThreadOnceId from epicsThreadId to void *
o fixed once flag isnt initialized with EPICSTHREAD_
o removed OS dependent implementations of epicsThreadOnce from {posix, RTEMS, vxWorks, win32}
Unmerged revisions
- 12261. By Jeff Hill
-
fixed spelling in comment
- 12260. By Jeff Hill
-
o moved epicsThreadOnce impl details to anonymous namespace
o fixed recursion sanity test is too agressive
o added some comments - 12259. By Jeff Hill
-
o added new epicsAtomics based, and OS independent, implementation of epicsThreadOnce in epicsThreadOnce.cpp
o changed type of epicsThreadOnceId from epicsThreadId to void *
o fixed once flag isnt initialized with EPICSTHREAD_ONCE_INIT in ipAddrToAsciiAs ynchronous. cpp
o removed OS dependent implementations of epicsThreadOnce from {posix, RTEMS, vxWorks, win32} - 12258. By Jeff Hill <email address hidden>
-
fixed names on redefinition protection macros for vxWorks
- 12257. By Jeff Hill
-
fixed epics atomic read memory barrier name - old versions of vxWorks
- 12256. By Jeff Hill
-
fixed word missing from vxWorks specific read and write memory barrier functions
- 12255. By Jeff Hill <email address hidden>
-
fixed vxWorks name for epicsAtomicTest
- 12254. By Jeff Hill <email address hidden>
-
fixed wrong return type old vxWorks epicsAtomicUnlock
- 12253. By Jeff Hill
-
fixed test count
- 12252. By Jeff Hill
-
fixed vxWorks jumbled ifdef
Preview Diff
1 | === modified file 'configure/CONFIG.gnuCommon' | |||
2 | --- configure/CONFIG.gnuCommon 2009-11-25 17:15:47 +0000 | |||
3 | +++ configure/CONFIG.gnuCommon 2011-08-31 22:29:24 +0000 | |||
4 | @@ -12,6 +12,8 @@ | |||
5 | 12 | 12 | ||
6 | 13 | GNU = YES | 13 | GNU = YES |
7 | 14 | 14 | ||
8 | 15 | CMPLR_CLASS = gcc | ||
9 | 16 | |||
10 | 15 | GNU_BIN = $(GNU_DIR)/bin | 17 | GNU_BIN = $(GNU_DIR)/bin |
11 | 16 | GNU_LIB = $(GNU_DIR)/lib | 18 | GNU_LIB = $(GNU_DIR)/lib |
12 | 17 | 19 | ||
13 | 18 | 20 | ||
14 | === modified file 'configure/CONFIG_COMMON' | |||
15 | --- configure/CONFIG_COMMON 2011-08-17 21:36:38 +0000 | |||
16 | +++ configure/CONFIG_COMMON 2011-08-31 22:29:24 +0000 | |||
17 | @@ -133,11 +133,14 @@ | |||
18 | 133 | GENERIC_SRC_DIRS = .. $(SRC_DIRS) | 133 | GENERIC_SRC_DIRS = .. $(SRC_DIRS) |
19 | 134 | OS_SRC_DIRS += . $(foreach dir, .. $(SRC_DIRS), \ | 134 | OS_SRC_DIRS += . $(foreach dir, .. $(SRC_DIRS), \ |
20 | 135 | $(addprefix $(dir)/, os/$(OS_CLASS) $(POSIX_$(POSIX)) os/default )) | 135 | $(addprefix $(dir)/, os/$(OS_CLASS) $(POSIX_$(POSIX)) os/default )) |
22 | 136 | ALL_SRC_DIRS = $(OS_SRC_DIRS) $(GENERIC_SRC_DIRS) | 136 | CMPLR_SRC_DIRS += . $(foreach dir, .. $(SRC_DIRS), \ |
23 | 137 | $(addprefix $(dir)/, compiler/$(CMPLR_CLASS) compiler/default )) | ||
24 | 138 | ALL_SRC_DIRS = $(CMPLR_SRC_DIRS) $(OS_SRC_DIRS) $(GENERIC_SRC_DIRS) | ||
25 | 137 | 139 | ||
26 | 138 | #-------------------------------------------------- | 140 | #-------------------------------------------------- |
27 | 139 | # compile line include directories | 141 | # compile line include directories |
28 | 140 | INSTALL_INCLUDES += \ | 142 | INSTALL_INCLUDES += \ |
29 | 143 | -I$(INSTALL_INCLUDE)/compiler/$(CMPLR_CLASS) \ | ||
30 | 141 | -I$(INSTALL_INCLUDE)/os/$(OS_CLASS) \ | 144 | -I$(INSTALL_INCLUDE)/os/$(OS_CLASS) \ |
31 | 142 | -I$(INSTALL_INCLUDE) | 145 | -I$(INSTALL_INCLUDE) |
32 | 143 | SRC_INCLUDES = -I$(COMMON_DIR) $(addprefix -I, $(wildcard $(ALL_SRC_DIRS))) | 146 | SRC_INCLUDES = -I$(COMMON_DIR) $(addprefix -I, $(wildcard $(ALL_SRC_DIRS))) |
33 | @@ -379,25 +382,36 @@ | |||
34 | 379 | # | 382 | # |
35 | 380 | # auto determine the directory paths that things are installed to | 383 | # auto determine the directory paths that things are installed to |
36 | 381 | # RULES: | 384 | # RULES: |
38 | 382 | # 1) found in any one of several os specific area | 385 | # 0) found in any one of several compiler specific paths |
39 | 386 | # => install to $(INSTALL_INCLUDE)/compiler/$(CMPLR_CLASS) | ||
40 | 387 | # 1) not found in (0) and found in any one of several OS specific paths | ||
41 | 383 | # => install to $(INSTALL_INCLUDE)/os/$(OS_CLASS) | 388 | # => install to $(INSTALL_INCLUDE)/os/$(OS_CLASS) |
43 | 384 | # 2) not foundin (1) and found in generic area | 389 | # 2) not found in (1) and found in generic paths |
44 | 385 | # => install to $(INSTALL_INCLUDE) | 390 | # => install to $(INSTALL_INCLUDE) |
45 | 386 | # 3) not found in (1) or (2) then may be (not yet) computer generated | 391 | # 3) not found in (1) or (2) then may be (not yet) computer generated |
46 | 387 | # => install into $(INSTALL_INCLUDE)/os/$(OS_CLASS) and let | 392 | # => install into $(INSTALL_INCLUDE)/os/$(OS_CLASS) and let |
47 | 388 | # build rules work on vpath | 393 | # build rules work on vpath |
48 | 389 | # | 394 | # |
49 | 390 | # These rules guarantee that the users include from | 395 | # These rules guarantee that the users include from |
51 | 391 | # no more than two directories | 396 | # no more than three directories |
52 | 392 | # | 397 | # |
53 | 393 | INSTALL_INC += $(foreach inc, $(INC), \ | 398 | INSTALL_INC += $(foreach inc, $(INC), \ |
54 | 394 | $(firstword \ | 399 | $(firstword \ |
55 | 400 | $(CMPLR_INSTALL_INC) \ | ||
56 | 395 | $(OS_INSTALL_INC) \ | 401 | $(OS_INSTALL_INC) \ |
57 | 396 | $(GENERIC_INSTALL_INC) \ | 402 | $(GENERIC_INSTALL_INC) \ |
58 | 397 | $(GENERATED_INSTALL_INC) ) ) | 403 | $(GENERATED_INSTALL_INC) ) ) |
59 | 398 | INSTALL_INC += $(addprefix $(INSTALL_INCLUDE)/os/$(OS_CLASS)/, $(INC_$(OS_CLASS)) ) | 404 | INSTALL_INC += $(addprefix $(INSTALL_INCLUDE)/os/$(OS_CLASS)/, $(INC_$(OS_CLASS)) ) |
60 | 399 | 405 | ||
61 | 400 | # | 406 | # |
62 | 407 | # Rule 0 | ||
63 | 408 | # | ||
64 | 409 | CMPLR_INSTALL_INC = $(addprefix $(INSTALL_INCLUDE)/compiler/$(CMPLR_CLASS)/, $(INSTALL_INC_jjj) ) | ||
65 | 410 | INSTALL_INC_jjj = $(foreach dir, $(CMPLR_SRC_DIRS), $(INSTALL_INC_iii) ) | ||
66 | 411 | INSTALL_INC_iii = $(subst $(dir)/, , $(INSTALL_INC_hhh) ) | ||
67 | 412 | INSTALL_INC_hhh = $(wildcard $(addsuffix /$(inc), $(dir)) ) | ||
68 | 413 | |||
69 | 414 | # | ||
70 | 401 | # Rule 1 | 415 | # Rule 1 |
71 | 402 | # | 416 | # |
72 | 403 | OS_INSTALL_INC = $(addprefix $(INSTALL_INCLUDE)/os/$(OS_CLASS)/, $(INSTALL_INC_ggg) ) | 417 | OS_INSTALL_INC = $(addprefix $(INSTALL_INCLUDE)/os/$(OS_CLASS)/, $(INSTALL_INC_ggg) ) |
73 | 404 | 418 | ||
74 | === modified file 'configure/RULES_BUILD' | |||
75 | --- configure/RULES_BUILD 2010-12-20 15:48:12 +0000 | |||
76 | +++ configure/RULES_BUILD 2011-08-31 22:29:24 +0000 | |||
77 | @@ -408,7 +408,11 @@ | |||
78 | 408 | @$(INSTALL) -d -m $(INSTALL_PERMISSIONS) $< $(@D) | 408 | @$(INSTALL) -d -m $(INSTALL_PERMISSIONS) $< $(@D) |
79 | 409 | 409 | ||
80 | 410 | $(INSTALL_INCLUDE)/os/$(OS_CLASS)/% : % | 410 | $(INSTALL_INCLUDE)/os/$(OS_CLASS)/% : % |
82 | 411 | $(ECHO) "Installing os dependent include file $@" | 411 | $(ECHO) "Installing OS dependent include file $@" |
83 | 412 | @$(INSTALL) -d -m $(INSTALL_PERMISSIONS) $< $(@D) | ||
84 | 413 | |||
85 | 414 | $(INSTALL_INCLUDE)/compiler/$(CMPLR_CLASS)/% : % | ||
86 | 415 | $(ECHO) "Installing compiler dependent include file $@" | ||
87 | 412 | @$(INSTALL) -d -m $(INSTALL_PERMISSIONS) $< $(@D) | 416 | @$(INSTALL) -d -m $(INSTALL_PERMISSIONS) $< $(@D) |
88 | 413 | 417 | ||
89 | 414 | $(INSTALL_DOC)/%: % | 418 | $(INSTALL_DOC)/%: % |
90 | 415 | 419 | ||
91 | === modified file 'configure/os/CONFIG.solarisCommon.solarisCommon' | |||
92 | --- configure/os/CONFIG.solarisCommon.solarisCommon 2010-10-05 19:27:37 +0000 | |||
93 | +++ configure/os/CONFIG.solarisCommon.solarisCommon 2011-08-31 22:29:24 +0000 | |||
94 | @@ -7,6 +7,8 @@ | |||
95 | 7 | # Sites may override these definitions in CONFIG_SITE.solaris-sparc.solaris-sparc | 7 | # Sites may override these definitions in CONFIG_SITE.solaris-sparc.solaris-sparc |
96 | 8 | #------------------------------------------------------- | 8 | #------------------------------------------------------- |
97 | 9 | 9 | ||
98 | 10 | CMPLR_CLASS = solStudio | ||
99 | 11 | |||
100 | 10 | SPARCWORKS = /opt/SUNWspro | 12 | SPARCWORKS = /opt/SUNWspro |
101 | 11 | GNU = NO | 13 | GNU = NO |
102 | 12 | 14 | ||
103 | 13 | 15 | ||
104 | === modified file 'configure/os/CONFIG.win32-x86.win32-x86' | |||
105 | --- configure/os/CONFIG.win32-x86.win32-x86 2011-08-17 21:36:38 +0000 | |||
106 | +++ configure/os/CONFIG.win32-x86.win32-x86 2011-08-31 22:29:24 +0000 | |||
107 | @@ -11,6 +11,8 @@ | |||
108 | 11 | 11 | ||
109 | 12 | VALID_BUILDS = Host Ioc | 12 | VALID_BUILDS = Host Ioc |
110 | 13 | 13 | ||
111 | 14 | CMPLR_CLASS = msvc | ||
112 | 15 | |||
113 | 14 | # convert UNIX path to native path | 16 | # convert UNIX path to native path |
114 | 15 | PATH_FILTER = $(subst /,\\,$(1)) | 17 | PATH_FILTER = $(subst /,\\,$(1)) |
115 | 16 | 18 | ||
116 | @@ -122,7 +124,7 @@ | |||
117 | 122 | # /D_CRTDBG_MAP_ALLOC | 124 | # /D_CRTDBG_MAP_ALLOC |
118 | 123 | # /RTCsu catch bugs occurring only in optimized code | 125 | # /RTCsu catch bugs occurring only in optimized code |
119 | 124 | # /DEPICS_FREELIST_DEBUG good for detecting mem mrg bugs | 126 | # /DEPICS_FREELIST_DEBUG good for detecting mem mrg bugs |
121 | 125 | OPT_CXXFLAGS_NO = /RTCsu /Zi | 127 | OPT_CXXFLAGS_NO = /RTCsu /Zi |
122 | 126 | 128 | ||
123 | 127 | # specify object file name and location | 129 | # specify object file name and location |
124 | 128 | OBJ_CXXFLAG = /Fo | 130 | OBJ_CXXFLAG = /Fo |
125 | 129 | 131 | ||
126 | === modified file 'src/libCom/Makefile' | |||
127 | --- src/libCom/Makefile 2011-08-23 22:28:20 +0000 | |||
128 | +++ src/libCom/Makefile 2011-08-31 22:29:24 +0000 | |||
129 | @@ -9,6 +9,7 @@ | |||
130 | 9 | TOP = ../.. | 9 | TOP = ../.. |
131 | 10 | include $(TOP)/configure/CONFIG | 10 | include $(TOP)/configure/CONFIG |
132 | 11 | 11 | ||
133 | 12 | <<<<<<< TREE | ||
134 | 12 | SRC = $(TOP)/src | 13 | SRC = $(TOP)/src |
135 | 13 | LIBCOM = $(SRC)/libCom | 14 | LIBCOM = $(SRC)/libCom |
136 | 14 | 15 | ||
137 | @@ -38,6 +39,288 @@ | |||
138 | 38 | include $(LIBCOM)/yacc/Makefile | 39 | include $(LIBCOM)/yacc/Makefile |
139 | 39 | 40 | ||
140 | 40 | # Library to build: | 41 | # Library to build: |
141 | 42 | ======= | ||
142 | 43 | LIBCOM = $(TOP)/src/libCom | ||
143 | 44 | |||
144 | 45 | # Command-line input support | ||
145 | 46 | epicsReadline_CFLAGS += -DEPICS_COMMANDLINE_LIBRARY=EPICS_COMMANDLINE_LIBRARY_$(COMMANDLINE_LIBRARY) | ||
146 | 47 | epicsReadline_INCLUDES += $(INCLUDES_$(COMMANDLINE_LIBRARY)) | ||
147 | 48 | |||
148 | 49 | #POSIX thread priority scheduling flag | ||
149 | 50 | THREAD_CPPFLAGS_NO += -DDONT_USE_POSIX_THREAD_PRIORITY_SCHEDULING | ||
150 | 51 | osdThread_CPPFLAGS += $(THREAD_CPPFLAGS_$(USE_POSIX_THREAD_PRIORITY_SCHEDULING)) | ||
151 | 52 | |||
152 | 53 | #epicsVersion is created by this Makefile | ||
153 | 54 | INC += epicsVersion.h | ||
154 | 55 | |||
155 | 56 | SRC_DIRS += $(LIBCOM)/bucketLib | ||
156 | 57 | INC += bucketLib.h | ||
157 | 58 | SRCS += bucketLib.c | ||
158 | 59 | |||
159 | 60 | SRC_DIRS += $(LIBCOM)/ring | ||
160 | 61 | #following needed for locating epicsRingPointer.h and epicsRingBytes.h | ||
161 | 62 | INC += epicsRingPointer.h | ||
162 | 63 | INC += epicsRingBytes.h | ||
163 | 64 | SRCS += epicsRingPointer.cpp | ||
164 | 65 | SRCS += epicsRingBytes.c | ||
165 | 66 | |||
166 | 67 | SRC_DIRS += $(LIBCOM)/calc | ||
167 | 68 | INC += postfix.h | ||
168 | 69 | SRCS += postfix.c | ||
169 | 70 | SRCS += calcPerform.c | ||
170 | 71 | |||
171 | 72 | SRC_DIRS += $(LIBCOM)/cvtFast | ||
172 | 73 | INC += cvtFast.h | ||
173 | 74 | SRCS += cvtFast.c | ||
174 | 75 | |||
175 | 76 | # From cppStd | ||
176 | 77 | SRC_DIRS += $(LIBCOM)/cppStd | ||
177 | 78 | INC += epicsAlgorithm.h | ||
178 | 79 | INC += epicsExcept.h | ||
179 | 80 | INC += epicsMemory.h | ||
180 | 81 | |||
181 | 82 | # From cxxTemplates | ||
182 | 83 | SRC_DIRS += $(LIBCOM)/cxxTemplates | ||
183 | 84 | INC += resourceLib.h | ||
184 | 85 | INC += tsDLList.h | ||
185 | 86 | INC += tsSLList.h | ||
186 | 87 | INC += tsMinMax.h | ||
187 | 88 | INC += tsBTree.h | ||
188 | 89 | INC += tsFreeList.h | ||
189 | 90 | INC += epicsSingleton.h | ||
190 | 91 | INC += epicsGuard.h | ||
191 | 92 | INC += epicsOnce.h | ||
192 | 93 | SRCS += resourceLib.cpp | ||
193 | 94 | SRCS += epicsOnce.cpp | ||
194 | 95 | SRCS += epicsSingletonMutex.cpp | ||
195 | 96 | |||
196 | 97 | SRC_DIRS += $(LIBCOM)/dbmf | ||
197 | 98 | INC += dbmf.h | ||
198 | 99 | SRCS += dbmf.c | ||
199 | 100 | |||
200 | 101 | SRC_DIRS += $(LIBCOM)/ellLib | ||
201 | 102 | INC += ellLib.h | ||
202 | 103 | SRCS += ellLib.c | ||
203 | 104 | |||
204 | 105 | SRC_DIRS += $(LIBCOM)/env | ||
205 | 106 | INC += envDefs.h | ||
206 | 107 | SRCS += envSubr.c | ||
207 | 108 | SRCS += envData.c | ||
208 | 109 | |||
209 | 110 | SRC_DIRS += $(LIBCOM)/error | ||
210 | 111 | INC += epicsPrint.h | ||
211 | 112 | INC += errMdef.h | ||
212 | 113 | INC += errSymTbl.h | ||
213 | 114 | INC += errlog.h | ||
214 | 115 | INC += error.h | ||
215 | 116 | SRCS += errlog.c | ||
216 | 117 | SRCS += errSymLib.c | ||
217 | 118 | SRCS += errSymTbl.c | ||
218 | 119 | |||
219 | 120 | SRC_DIRS += $(LIBCOM)/fdmgr | ||
220 | 121 | INC += fdManager.h | ||
221 | 122 | INC += fdmgr.h | ||
222 | 123 | SRCS += fdmgr.cpp | ||
223 | 124 | SRCS += fdManager.cpp | ||
224 | 125 | |||
225 | 126 | SRC_DIRS += $(LIBCOM)/freeList | ||
226 | 127 | INC += freeList.h | ||
227 | 128 | SRCS += freeListLib.c | ||
228 | 129 | HTMLS += freeList/freeList.html | ||
229 | 130 | |||
230 | 131 | SRC_DIRS += $(LIBCOM)/gpHash | ||
231 | 132 | INC += gpHash.h | ||
232 | 133 | SRCS += gpHashLib.c | ||
233 | 134 | HTMLS += gpHash/gpHash.html | ||
234 | 135 | |||
235 | 136 | SRC_DIRS += $(LIBCOM)/iocsh | ||
236 | 137 | INC += iocsh.h | ||
237 | 138 | INC += registry.h | ||
238 | 139 | INC += libComRegister.h | ||
239 | 140 | SRCS += iocsh.cpp | ||
240 | 141 | SRCS += registry.c | ||
241 | 142 | SRCS += libComRegister.c | ||
242 | 143 | |||
243 | 144 | SRC_DIRS += $(LIBCOM)/logClient | ||
244 | 145 | INC += iocLog.h | ||
245 | 146 | INC += logClient.h | ||
246 | 147 | SRCS += iocLog.c | ||
247 | 148 | SRCS += logClient.c | ||
248 | 149 | |||
249 | 150 | SRC_DIRS += $(LIBCOM)/macLib | ||
250 | 151 | INC += macLib.h | ||
251 | 152 | SRCS += macCore.c | ||
252 | 153 | SRCS += macEnv.c | ||
253 | 154 | SRCS += macUtil.c | ||
254 | 155 | |||
255 | 156 | SRC_DIRS += $(LIBCOM)/misc | ||
256 | 157 | INC += adjustment.h | ||
257 | 158 | INC += cantProceed.h | ||
258 | 159 | INC += dbDefs.h | ||
259 | 160 | INC += epicsConvert.h | ||
260 | 161 | INC += epicsExit.h | ||
261 | 162 | INC += epicsStdlib.h | ||
262 | 163 | INC += epicsString.h | ||
263 | 164 | INC += epicsTypes.h | ||
264 | 165 | INC += shareLib.h | ||
265 | 166 | INC += epicsExport.h | ||
266 | 167 | INC += unixFileName.h | ||
267 | 168 | INC += locationException.h | ||
268 | 169 | INC += ipAddrToAsciiAsynchronous.h | ||
269 | 170 | INC += epicsUnitTest.h | ||
270 | 171 | INC += testMain.h | ||
271 | 172 | SRCS += aToIPAddr.c | ||
272 | 173 | SRCS += adjustment.c | ||
273 | 174 | SRCS += cantProceed.c | ||
274 | 175 | SRCS += epicsConvert.c | ||
275 | 176 | SRCS += epicsExit.c | ||
276 | 177 | SRCS += epicsStdlib.c | ||
277 | 178 | SRCS += epicsString.c | ||
278 | 179 | SRCS += truncateFile.c | ||
279 | 180 | SRCS += ipAddrToAsciiAsynchronous.cpp | ||
280 | 181 | SRCS += epicsUnitTest.c | ||
281 | 182 | |||
282 | 183 | # From osi | ||
283 | 184 | SRC_DIRS += $(LIBCOM)/osi | ||
284 | 185 | INC += osiFileName.h | ||
285 | 186 | INC += osiSock.h | ||
286 | 187 | INC += osdSock.h | ||
287 | 188 | INC += epicsInterrupt.h | ||
288 | 189 | INC += osdInterrupt.h | ||
289 | 190 | |||
290 | 191 | INC += epicsMutex.h | ||
291 | 192 | INC += osdMutex.h | ||
292 | 193 | INC += epicsEvent.h | ||
293 | 194 | INC += osdEvent.h | ||
294 | 195 | INC += epicsMath.h | ||
295 | 196 | INC += osdMessageQueue.h | ||
296 | 197 | INC += osdStrtod.h | ||
297 | 198 | |||
298 | 199 | INC += epicsAssert.h | ||
299 | 200 | INC += epicsFindSymbol.h | ||
300 | 201 | INC += osiPoolStatus.h | ||
301 | 202 | INC += osdPoolStatus.h | ||
302 | 203 | INC += osdThread.h | ||
303 | 204 | |||
304 | 205 | INC += epicsThread.h | ||
305 | 206 | INC += epicsTime.h | ||
306 | 207 | INC += epicsGeneralTime.h | ||
307 | 208 | INC += osdTime.h | ||
308 | 209 | INC += generalTimeSup.h | ||
309 | 210 | INC += osiClockTime.h | ||
310 | 211 | INC += epicsSignal.h | ||
311 | 212 | INC += osiProcess.h | ||
312 | 213 | INC += osiUnistd.h | ||
313 | 214 | INC += osiWireFormat.h | ||
314 | 215 | INC += osdWireFormat.h | ||
315 | 216 | INC += osdWireConfig.h | ||
316 | 217 | INC += epicsAtomic.h | ||
317 | 218 | INC += epicsAtomicCD.h | ||
318 | 219 | INC += epicsAtomicOSD.h | ||
319 | 220 | INC += epicsAtomicDefault.h | ||
320 | 221 | INC += epicsEndian.h | ||
321 | 222 | INC += epicsReadline.h | ||
322 | 223 | INC += epicsMessageQueue.h | ||
323 | 224 | INC += epicsStdio.h | ||
324 | 225 | INC += epicsStdioRedirect.h | ||
325 | 226 | INC += epicsGetopt.h | ||
326 | 227 | |||
327 | 228 | INC += devLib.h | ||
328 | 229 | INC += devLibVME.h | ||
329 | 230 | INC += devLibVMEImpl.h | ||
330 | 231 | INC += osdVME.h | ||
331 | 232 | INC += compilerDependencies.h | ||
332 | 233 | INC += compilerSpecific.h | ||
333 | 234 | |||
334 | 235 | SRCS += epicsThread.cpp | ||
335 | 236 | SRCS += epicsMutex.cpp | ||
336 | 237 | SRCS += epicsEvent.cpp | ||
337 | 238 | SRCS += epicsTime.cpp | ||
338 | 239 | SRCS += epicsMessageQueue.cpp | ||
339 | 240 | SRCS += epicsMath.cpp | ||
340 | 241 | SRCS += epicsAtomicOSD.cpp | ||
341 | 242 | |||
342 | 243 | SRCS += epicsGeneralTime.c | ||
343 | 244 | SRCS += osiClockTime.c | ||
344 | 245 | |||
345 | 246 | SRCS += osdSock.c | ||
346 | 247 | SRCS += osdSockAddrReuse.cpp | ||
347 | 248 | SRCS += osiSock.c | ||
348 | 249 | SRCS += systemCallIntMech.cpp | ||
349 | 250 | SRCS += epicsSocketConvertErrnoToString.cpp | ||
350 | 251 | SRCS += osdAssert.c | ||
351 | 252 | SRCS += osdFindSymbol.c | ||
352 | 253 | SRCS += osdInterrupt.c | ||
353 | 254 | SRCS += osdPoolStatus.c | ||
354 | 255 | SRCS += osdSignal.cpp | ||
355 | 256 | SRCS += osdEnv.c | ||
356 | 257 | SRCS += epicsReadline.c | ||
357 | 258 | SRCS += epicsTempFile.cpp | ||
358 | 259 | SRCS += epicsThreadOnce.cpp | ||
359 | 260 | SRCS += epicsStdio.c | ||
360 | 261 | SRCS += osdStdio.c | ||
361 | 262 | |||
362 | 263 | osdEnv_CFLAGS_WIN32= -U__STDC__ | ||
363 | 264 | |||
364 | 265 | SRCS += osdThread.c | ||
365 | 266 | SRCS += osdMutex.c | ||
366 | 267 | SRCS += osdEvent.c | ||
367 | 268 | SRCS += osdTime.cpp | ||
368 | 269 | SRCS += osdProcess.c | ||
369 | 270 | SRCS += osdNetIntf.c | ||
370 | 271 | SRCS += osdMessageQueue.c | ||
371 | 272 | |||
372 | 273 | SRCS += devLibVME.c | ||
373 | 274 | SRCS += devLibVMEOSD.c | ||
374 | 275 | |||
375 | 276 | SRC_DIRS += $(LIBCOM)/taskwd | ||
376 | 277 | INC += taskwd.h | ||
377 | 278 | SRCS += taskwd.c | ||
378 | 279 | |||
379 | 280 | SRC_DIRS += $(LIBCOM)/timer | ||
380 | 281 | INC += epicsTimer.h | ||
381 | 282 | SRCS += epicsTimer.cpp | ||
382 | 283 | SRCS += timer.cpp | ||
383 | 284 | SRCS += timerQueue.cpp | ||
384 | 285 | SRCS += timerQueueActive.cpp | ||
385 | 286 | SRCS += timerQueueActiveMgr.cpp | ||
386 | 287 | SRCS += timerQueuePassive.cpp | ||
387 | 288 | |||
388 | 289 | #tsDefs contains R3.13 compatibility tsStamp code | ||
389 | 290 | SRC_DIRS += $(LIBCOM)/tsDefs | ||
390 | 291 | INC += tsDefs.h | ||
391 | 292 | SRCS += tsDefs.c | ||
392 | 293 | |||
393 | 294 | # Time providers, in osi | ||
394 | 295 | SRCS_vxWorks += osiNTPTime.c | ||
395 | 296 | SRCS_RTEMS += osiNTPTime.c | ||
396 | 297 | |||
397 | 298 | # These files are in osi/os/vxWorks | ||
398 | 299 | # Special reboot hook | ||
399 | 300 | SRCS_vxWorks += atReboot.cpp | ||
400 | 301 | # For old vxWorks applications | ||
401 | 302 | INC_vxWorks += camacLib.h | ||
402 | 303 | INC_vxWorks += epicsDynLink.h | ||
403 | 304 | INC_vxWorks += module_types.h | ||
404 | 305 | INC_vxWorks += task_params.h | ||
405 | 306 | SRCS_vxWorks += epicsDynLink.c | ||
406 | 307 | SRCS_vxWorks += veclist.c | ||
407 | 308 | SRCS_vxWorks += logMsgToErrlog.cpp | ||
408 | 309 | |||
409 | 310 | #This forces the vxWorks compatibility stuff to be loaded | ||
410 | 311 | OBJS_vxWorks = vxComLibrary | ||
411 | 312 | |||
412 | 313 | # These files are in osi/os/WIN32 | ||
413 | 314 | INC_WIN32 += epicsAtomicMS.h | ||
414 | 315 | SRCS_WIN32 += epicsGetopt.c | ||
415 | 316 | SRCS_WIN32 += setThreadName.cpp | ||
416 | 317 | #SRCS_WIN32 += dllmain.cpp | ||
417 | 318 | SRCS_WIN32 += forceBadAllocException.cpp | ||
418 | 319 | |||
419 | 320 | # Library to build: | ||
420 | 321 | # lib$(LIBRARY).a or ..dll/..exp/..lib | ||
421 | 322 | # | ||
422 | 323 | >>>>>>> MERGE-SOURCE | ||
423 | 41 | LIBRARY=Com | 324 | LIBRARY=Com |
424 | 42 | 325 | ||
425 | 43 | Com_SYS_LIBS_WIN32 = ws2_32 advapi32 user32 | 326 | Com_SYS_LIBS_WIN32 = ws2_32 advapi32 user32 |
426 | 44 | 327 | ||
427 | === removed file 'src/libCom/misc/compilerDependencies.h' | |||
428 | --- src/libCom/misc/compilerDependencies.h 2011-06-20 18:52:32 +0000 | |||
429 | +++ src/libCom/misc/compilerDependencies.h 1970-01-01 00:00:00 +0000 | |||
430 | @@ -1,104 +0,0 @@ | |||
431 | 1 | |||
432 | 2 | /*************************************************************************\ | ||
433 | 3 | * Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne | ||
434 | 4 | * National Laboratory. | ||
435 | 5 | * Copyright (c) 2002 The Regents of the University of California, as | ||
436 | 6 | * Operator of Los Alamos National Laboratory. | ||
437 | 7 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
438 | 8 | * in file LICENSE that is included with this distribution. | ||
439 | 9 | \*************************************************************************/ | ||
440 | 10 | |||
441 | 11 | /* | ||
442 | 12 | * Author: | ||
443 | 13 | * Jeffrey O. Hill | ||
444 | 14 | * johill@lanl.gov | ||
445 | 15 | */ | ||
446 | 16 | |||
447 | 17 | #ifndef compilerDependencies_h | ||
448 | 18 | #define compilerDependencies_h | ||
449 | 19 | |||
450 | 20 | /* | ||
451 | 21 | * This is an attempt to move all tests identifying what features a | ||
452 | 22 | * compiler supports into one file. | ||
453 | 23 | * | ||
454 | 24 | * Since this is a compiler, and not os dependent, issue then ifdefs | ||
455 | 25 | * are used. The ifdefs allow us to make the default assumption that | ||
456 | 26 | * standards incompliance issues will be fixed by future compiler | ||
457 | 27 | * releases. | ||
458 | 28 | */ | ||
459 | 29 | |||
460 | 30 | #ifdef __cplusplus | ||
461 | 31 | |||
462 | 32 | /* | ||
463 | 33 | * CXX_PLACEMENT_DELETE - defined if compiler supports placement delete | ||
464 | 34 | * CXX_THROW_SPECIFICATION - defined if compiler supports throw specification | ||
465 | 35 | */ | ||
466 | 36 | |||
467 | 37 | #if defined ( _MSC_VER ) | ||
468 | 38 | # if _MSC_VER >= 1200 /* visual studio 6.0 or later */ | ||
469 | 39 | # define CXX_PLACEMENT_DELETE | ||
470 | 40 | # endif | ||
471 | 41 | # if _MSC_VER > 1300 /* some release after visual studio 7 we hope */ | ||
472 | 42 | # define CXX_THROW_SPECIFICATION | ||
473 | 43 | # endif | ||
474 | 44 | #elif defined ( __HP_aCC ) | ||
475 | 45 | # if _HP_aCC > 33300 | ||
476 | 46 | # define CXX_PLACEMENT_DELETE | ||
477 | 47 | # endif | ||
478 | 48 | # define CXX_THROW_SPECIFICATION | ||
479 | 49 | #elif defined ( __BORLANDC__ ) | ||
480 | 50 | # if __BORLANDC__ >= 0x600 | ||
481 | 51 | # define CXX_PLACEMENT_DELETE | ||
482 | 52 | # endif | ||
483 | 53 | # define CXX_THROW_SPECIFICATION | ||
484 | 54 | #elif defined ( __GNUC__ ) | ||
485 | 55 | # if __GNUC__ > 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >= 95 ) | ||
486 | 56 | # define CXX_THROW_SPECIFICATION | ||
487 | 57 | # endif | ||
488 | 58 | # if __GNUC__ > 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >= 96 ) | ||
489 | 59 | # define CXX_PLACEMENT_DELETE | ||
490 | 60 | # endif | ||
491 | 61 | #else | ||
492 | 62 | # define CXX_PLACEMENT_DELETE | ||
493 | 63 | # define CXX_THROW_SPECIFICATION | ||
494 | 64 | #endif | ||
495 | 65 | |||
496 | 66 | /* | ||
497 | 67 | * usage: void func () epicsThrows (( std::bad_alloc, std::logic_error )) | ||
498 | 68 | */ | ||
499 | 69 | #if defined ( CXX_THROW_SPECIFICATION ) | ||
500 | 70 | # define epicsThrows(X) throw X | ||
501 | 71 | #else | ||
502 | 72 | # define epicsThrows(X) | ||
503 | 73 | #endif | ||
504 | 74 | |||
505 | 75 | /* | ||
506 | 76 | * usage: epicsPlacementDeleteOperator (( void *, myMemoryManager & )) | ||
507 | 77 | */ | ||
508 | 78 | #if defined ( CXX_PLACEMENT_DELETE ) | ||
509 | 79 | # define epicsPlacementDeleteOperator(X) void operator delete X; | ||
510 | 80 | #else | ||
511 | 81 | # define epicsPlacementDeleteOperator(X) | ||
512 | 82 | #endif | ||
513 | 83 | |||
514 | 84 | #endif /* __cplusplus */ | ||
515 | 85 | |||
516 | 86 | /* | ||
517 | 87 | * Enable format-string checking if possible | ||
518 | 88 | */ | ||
519 | 89 | #ifdef __GNUC__ | ||
520 | 90 | # define EPICS_PRINTF_STYLE(f,a) __attribute__((format(__printf__,f,a))) | ||
521 | 91 | #else | ||
522 | 92 | # define EPICS_PRINTF_STYLE(f,a) | ||
523 | 93 | #endif | ||
524 | 94 | |||
525 | 95 | /* | ||
526 | 96 | * Deprecation marker | ||
527 | 97 | */ | ||
528 | 98 | #if defined( __GNUC__ ) && (__GNUC__ > 2) | ||
529 | 99 | # define EPICS_DEPRECATED __attribute__((deprecated)) | ||
530 | 100 | #else | ||
531 | 101 | # define EPICS_DEPRECATED | ||
532 | 102 | #endif | ||
533 | 103 | |||
534 | 104 | #endif /* ifndef compilerDependencies_h */ | ||
535 | 105 | 0 | ||
536 | === modified file 'src/libCom/misc/ipAddrToAsciiAsynchronous.cpp' | |||
537 | --- src/libCom/misc/ipAddrToAsciiAsynchronous.cpp 2008-10-21 20:26:48 +0000 | |||
538 | +++ src/libCom/misc/ipAddrToAsciiAsynchronous.cpp 2011-08-31 22:29:24 +0000 | |||
539 | @@ -127,7 +127,7 @@ | |||
540 | 127 | ipAddrToAsciiEnginePrivate * ipAddrToAsciiEnginePrivate :: pEngine = 0; | 127 | ipAddrToAsciiEnginePrivate * ipAddrToAsciiEnginePrivate :: pEngine = 0; |
541 | 128 | unsigned ipAddrToAsciiEnginePrivate :: numberOfReferences = 0u; | 128 | unsigned ipAddrToAsciiEnginePrivate :: numberOfReferences = 0u; |
542 | 129 | bool ipAddrToAsciiEnginePrivate :: shutdownRequest = false; | 129 | bool ipAddrToAsciiEnginePrivate :: shutdownRequest = false; |
544 | 130 | static epicsThreadOnceId ipAddrToAsciiEngineGlobalMutexOnceFlag = 0; | 130 | static epicsThreadOnceId ipAddrToAsciiEngineGlobalMutexOnceFlag = EPICS_THREAD_ONCE_INIT; |
545 | 131 | 131 | ||
546 | 132 | // the users are not required to supply a show routine | 132 | // the users are not required to supply a show routine |
547 | 133 | // for there transaction callback class | 133 | // for there transaction callback class |
548 | 134 | 134 | ||
549 | === added directory 'src/libCom/osi/compiler' | |||
550 | === added directory 'src/libCom/osi/compiler/borland' | |||
551 | === added file 'src/libCom/osi/compiler/borland/compilerSpecific.h' | |||
552 | --- src/libCom/osi/compiler/borland/compilerSpecific.h 1970-01-01 00:00:00 +0000 | |||
553 | +++ src/libCom/osi/compiler/borland/compilerSpecific.h 2011-08-31 22:29:24 +0000 | |||
554 | @@ -0,0 +1,55 @@ | |||
555 | 1 | |||
556 | 2 | /*************************************************************************\ | ||
557 | 3 | * Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne | ||
558 | 4 | * National Laboratory. | ||
559 | 5 | * Copyright (c) 2002 The Regents of the University of California, as | ||
560 | 6 | * Operator of Los Alamos National Laboratory. | ||
561 | 7 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
562 | 8 | * in file LICENSE that is included with this distribution. | ||
563 | 9 | \*************************************************************************/ | ||
564 | 10 | |||
565 | 11 | /* | ||
566 | 12 | * Author: | ||
567 | 13 | * Jeffrey O. Hill | ||
568 | 14 | * johill@lanl.gov | ||
569 | 15 | */ | ||
570 | 16 | |||
571 | 17 | #ifndef compilerSpecific_h | ||
572 | 18 | #define compilerSpecific_h | ||
573 | 19 | |||
574 | 20 | #ifndef __BORLANDC__ | ||
575 | 21 | # error compiler/borland/compilerSpecific.h is only for use with the Borland compiler | ||
576 | 22 | #endif | ||
577 | 23 | |||
578 | 24 | #ifdef __cplusplus | ||
579 | 25 | |||
580 | 26 | /* | ||
581 | 27 | * in general we dont like ifdefs but they do allow us to check the | ||
582 | 28 | * compiler version and make the optimistic assumption that | ||
583 | 29 | * standards incompliance issues will be fixed by future compiler | ||
584 | 30 | * releases | ||
585 | 31 | */ | ||
586 | 32 | |||
587 | 33 | /* | ||
588 | 34 | * CXX_PLACEMENT_DELETE - defined if compiler supports placement delete | ||
589 | 35 | * CXX_THROW_SPECIFICATION - defined if compiler supports throw specification | ||
590 | 36 | */ | ||
591 | 37 | #if __BORLANDC__ >= 0x600 | ||
592 | 38 | # define CXX_PLACEMENT_DELETE | ||
593 | 39 | #endif | ||
594 | 40 | |||
595 | 41 | #define CXX_THROW_SPECIFICATION | ||
596 | 42 | |||
597 | 43 | #endif /* __cplusplus */ | ||
598 | 44 | |||
599 | 45 | /* | ||
600 | 46 | * Enable format-string checking if possible | ||
601 | 47 | */ | ||
602 | 48 | #define EPICS_PRINTF_STYLE(f,a) | ||
603 | 49 | |||
604 | 50 | /* | ||
605 | 51 | * Deprecation marker | ||
606 | 52 | */ | ||
607 | 53 | #define EPICS_DEPRECATED | ||
608 | 54 | |||
609 | 55 | #endif /* ifndef compilerSpecific_h */ | ||
610 | 0 | 56 | ||
611 | === added directory 'src/libCom/osi/compiler/clang' | |||
612 | === added file 'src/libCom/osi/compiler/clang/compilerSpecific.h' | |||
613 | --- src/libCom/osi/compiler/clang/compilerSpecific.h 1970-01-01 00:00:00 +0000 | |||
614 | +++ src/libCom/osi/compiler/clang/compilerSpecific.h 2011-08-31 22:29:24 +0000 | |||
615 | @@ -0,0 +1,59 @@ | |||
616 | 1 | |||
617 | 2 | /*************************************************************************\ | ||
618 | 3 | * Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne | ||
619 | 4 | * National Laboratory. | ||
620 | 5 | * Copyright (c) 2002 The Regents of the University of California, as | ||
621 | 6 | * Operator of Los Alamos National Laboratory. | ||
622 | 7 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
623 | 8 | * in file LICENSE that is included with this distribution. | ||
624 | 9 | \*************************************************************************/ | ||
625 | 10 | |||
626 | 11 | /* | ||
627 | 12 | * Author: | ||
628 | 13 | * Jeffrey O. Hill | ||
629 | 14 | * johill@lanl.gov | ||
630 | 15 | */ | ||
631 | 16 | |||
632 | 17 | #ifndef compilerSpecific_h | ||
633 | 18 | #define compilerSpecific_h | ||
634 | 19 | |||
635 | 20 | #ifndef __clang__ | ||
636 | 21 | # error compiler/clang/compilerSpecific.h is only for use with the clang compiler | ||
637 | 22 | #endif | ||
638 | 23 | |||
639 | 24 | /* | ||
640 | 25 | * WARNING: the current state of this file is only based on reading clang manuals | ||
641 | 26 | * and has not actually been tested with the compiler | ||
642 | 27 | */ | ||
643 | 28 | #pragma warning compiler/clang/compilerSpecific.h is based on reading the manual, but hasnt been tested with the clang compiler | ||
644 | 29 | |||
645 | 30 | #ifdef __cplusplus | ||
646 | 31 | |||
647 | 32 | /* | ||
648 | 33 | * CXX_PLACEMENT_DELETE - defined if compiler supports placement delete | ||
649 | 34 | * CXX_THROW_SPECIFICATION - defined if compiler supports throw specification | ||
650 | 35 | */ | ||
651 | 36 | #define CXX_PLACEMENT_DELETE | ||
652 | 37 | #define CXX_THROW_SPECIFICATION | ||
653 | 38 | |||
654 | 39 | #endif /* __cplusplus */ | ||
655 | 40 | |||
656 | 41 | /* | ||
657 | 42 | * Enable format-string checking if possible | ||
658 | 43 | */ | ||
659 | 44 | #if __has_attribute(format) | ||
660 | 45 | # define EPICS_PRINTF_STYLE(f,a) __attribute__((format(__printf__,f,a))) | ||
661 | 46 | #else | ||
662 | 47 | # define EPICS_PRINTF_STYLE | ||
663 | 48 | #endif | ||
664 | 49 | |||
665 | 50 | /* | ||
666 | 51 | * Deprecation marker if possible | ||
667 | 52 | */ | ||
668 | 53 | #if __has_attribute(deprecated) | ||
669 | 54 | # define EPICS_DEPRECATED __attribute__((deprecated)) | ||
670 | 55 | #else | ||
671 | 56 | # define EPICS_DEPRECATED | ||
672 | 57 | #endif | ||
673 | 58 | |||
674 | 59 | #endif /* ifndef compilerSpecific_h */ | ||
675 | 0 | 60 | ||
676 | === added file 'src/libCom/osi/compiler/clang/epicsAtomicCD.h' | |||
677 | --- src/libCom/osi/compiler/clang/epicsAtomicCD.h 1970-01-01 00:00:00 +0000 | |||
678 | +++ src/libCom/osi/compiler/clang/epicsAtomicCD.h 2011-08-31 22:29:24 +0000 | |||
679 | @@ -0,0 +1,27 @@ | |||
680 | 1 | |||
681 | 2 | /*************************************************************************\ | ||
682 | 3 | * Copyright (c) 2011 LANS LLC, as Operator of | ||
683 | 4 | * Los Alamos National Laboratory. | ||
684 | 5 | * Copyright (c) 2011 UChicago Argonne LLC, as Operator of Argonne | ||
685 | 6 | * National Laboratory. | ||
686 | 7 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
687 | 8 | * in file LICENSE that is included with this distribution. | ||
688 | 9 | \*************************************************************************/ | ||
689 | 10 | |||
690 | 11 | /* | ||
691 | 12 | * Author Jeffrey O. Hill | ||
692 | 13 | * johill@lanl.gov | ||
693 | 14 | */ | ||
694 | 15 | |||
695 | 16 | #ifndef epicsAtomicCD_h | ||
696 | 17 | #define epicsAtomicCD_h | ||
697 | 18 | |||
698 | 19 | #if defined ( __cplusplus ) | ||
699 | 20 | # define EPICS_ATOMIC_INLINE inline | ||
700 | 21 | #else | ||
701 | 22 | # define EPICS_ATOMIC_INLINE __inline__ | ||
702 | 23 | #endif | ||
703 | 24 | |||
704 | 25 | #include "epicsAtomicOSD.h" | ||
705 | 26 | |||
706 | 27 | #endif /* epicsAtomicCD_h */ | ||
707 | 0 | 28 | ||
708 | === added directory 'src/libCom/osi/compiler/default' | |||
709 | === added file 'src/libCom/osi/compiler/default/compilerSpecific.h' | |||
710 | --- src/libCom/osi/compiler/default/compilerSpecific.h 1970-01-01 00:00:00 +0000 | |||
711 | +++ src/libCom/osi/compiler/default/compilerSpecific.h 2011-08-31 22:29:24 +0000 | |||
712 | @@ -0,0 +1,45 @@ | |||
713 | 1 | |||
714 | 2 | /*************************************************************************\ | ||
715 | 3 | * Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne | ||
716 | 4 | * National Laboratory. | ||
717 | 5 | * Copyright (c) 2002 The Regents of the University of California, as | ||
718 | 6 | * Operator of Los Alamos National Laboratory. | ||
719 | 7 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
720 | 8 | * in file LICENSE that is included with this distribution. | ||
721 | 9 | \*************************************************************************/ | ||
722 | 10 | |||
723 | 11 | /* | ||
724 | 12 | * Author: | ||
725 | 13 | * Jeffrey O. Hill | ||
726 | 14 | * johill@lanl.gov | ||
727 | 15 | */ | ||
728 | 16 | |||
729 | 17 | #ifndef compilerSpecific_h | ||
730 | 18 | #define compilerSpecific_h | ||
731 | 19 | |||
732 | 20 | #ifdef __cplusplus | ||
733 | 21 | |||
734 | 22 | /* | ||
735 | 23 | * CXX_PLACEMENT_DELETE - defined if compiler supports placement delete | ||
736 | 24 | * CXX_THROW_SPECIFICATION - defined if compiler supports throw specification | ||
737 | 25 | * | ||
738 | 26 | * (our default guess is that the compiler implements the C++ 97 standard) | ||
739 | 27 | */ | ||
740 | 28 | #define CXX_THROW_SPECIFICATION | ||
741 | 29 | #define CXX_PLACEMENT_DELETE | ||
742 | 30 | |||
743 | 31 | #endif /* __cplusplus */ | ||
744 | 32 | |||
745 | 33 | /* | ||
746 | 34 | * Enable format-string checking if possible | ||
747 | 35 | * (our default guess is that the compiler doesnt implement non-standard extensions) | ||
748 | 36 | */ | ||
749 | 37 | #define EPICS_PRINTF_STYLE(f,a) | ||
750 | 38 | |||
751 | 39 | /* | ||
752 | 40 | * Deprecation marker | ||
753 | 41 | * (our default guess is that the compiler doesnt implement non-standard extensions) | ||
754 | 42 | */ | ||
755 | 43 | #define EPICS_DEPRECATED | ||
756 | 44 | |||
757 | 45 | #endif /* ifndef compilerSpecific_h */ | ||
758 | 0 | 46 | ||
759 | === added file 'src/libCom/osi/compiler/default/epicsAtomicCD.h' | |||
760 | --- src/libCom/osi/compiler/default/epicsAtomicCD.h 1970-01-01 00:00:00 +0000 | |||
761 | +++ src/libCom/osi/compiler/default/epicsAtomicCD.h 2011-08-31 22:29:24 +0000 | |||
762 | @@ -0,0 +1,25 @@ | |||
763 | 1 | |||
764 | 2 | /*************************************************************************\ | ||
765 | 3 | * Copyright (c) 2011 LANS LLC, as Operator of | ||
766 | 4 | * Los Alamos National Laboratory. | ||
767 | 5 | * Copyright (c) 2011 UChicago Argonne LLC, as Operator of Argonne | ||
768 | 6 | * National Laboratory. | ||
769 | 7 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
770 | 8 | * in file LICENSE that is included with this distribution. | ||
771 | 9 | \*************************************************************************/ | ||
772 | 10 | |||
773 | 11 | /* | ||
774 | 12 | * Author Jeffrey O. Hill | ||
775 | 13 | * johill@lanl.gov | ||
776 | 14 | */ | ||
777 | 15 | |||
778 | 16 | #ifndef epicsAtomicCD_h | ||
779 | 17 | #define epicsAtomicCD_h | ||
780 | 18 | |||
781 | 19 | #if __STDC_VERSION__ >= 199901L || defined ( __cplusplus ) | ||
782 | 20 | # define EPICS_ATOMIC_INLINE inline | ||
783 | 21 | #endif | ||
784 | 22 | |||
785 | 23 | #include "epicsAtomicOSD.h" | ||
786 | 24 | |||
787 | 25 | #endif /* epicsAtomicCD_h */ | ||
788 | 0 | 26 | ||
789 | === added directory 'src/libCom/osi/compiler/gcc' | |||
790 | === added file 'src/libCom/osi/compiler/gcc/compilerSpecific.h' | |||
791 | --- src/libCom/osi/compiler/gcc/compilerSpecific.h 1970-01-01 00:00:00 +0000 | |||
792 | +++ src/libCom/osi/compiler/gcc/compilerSpecific.h 2011-08-31 22:29:24 +0000 | |||
793 | @@ -0,0 +1,62 @@ | |||
794 | 1 | |||
795 | 2 | /*************************************************************************\ | ||
796 | 3 | * Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne | ||
797 | 4 | * National Laboratory. | ||
798 | 5 | * Copyright (c) 2002 The Regents of the University of California, as | ||
799 | 6 | * Operator of Los Alamos National Laboratory. | ||
800 | 7 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
801 | 8 | * in file LICENSE that is included with this distribution. | ||
802 | 9 | \*************************************************************************/ | ||
803 | 10 | |||
804 | 11 | /* | ||
805 | 12 | * Author: | ||
806 | 13 | * Jeffrey O. Hill | ||
807 | 14 | * johill@lanl.gov | ||
808 | 15 | */ | ||
809 | 16 | |||
810 | 17 | #ifndef compilerSpecific_h | ||
811 | 18 | #define compilerSpecific_h | ||
812 | 19 | |||
813 | 20 | #ifndef __GNUC__ | ||
814 | 21 | # error compiler/gcc/compilerSpecific.h is only for use with the gnu compiler | ||
815 | 22 | #endif | ||
816 | 23 | |||
817 | 24 | #ifdef __cplusplus | ||
818 | 25 | |||
819 | 26 | /* | ||
820 | 27 | * in general we dont like ifdefs but they do allow us to check the | ||
821 | 28 | * compiler version and make the optimistic assumption that | ||
822 | 29 | * standards incompliance issues will be fixed by future compiler | ||
823 | 30 | * releases | ||
824 | 31 | */ | ||
825 | 32 | |||
826 | 33 | /* | ||
827 | 34 | * CXX_PLACEMENT_DELETE - defined if compiler supports placement delete | ||
828 | 35 | * CXX_THROW_SPECIFICATION - defined if compiler supports throw specification | ||
829 | 36 | */ | ||
830 | 37 | |||
831 | 38 | #if __GNUC__ > 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >= 95 ) | ||
832 | 39 | # define CXX_THROW_SPECIFICATION | ||
833 | 40 | #endif | ||
834 | 41 | |||
835 | 42 | #if __GNUC__ > 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >= 96 ) | ||
836 | 43 | # define CXX_PLACEMENT_DELETE | ||
837 | 44 | #endif | ||
838 | 45 | |||
839 | 46 | #endif /* __cplusplus */ | ||
840 | 47 | |||
841 | 48 | /* | ||
842 | 49 | * Enable format-string checking if possible | ||
843 | 50 | */ | ||
844 | 51 | #define EPICS_PRINTF_STYLE(f,a) __attribute__((format(__printf__,f,a))) | ||
845 | 52 | |||
846 | 53 | /* | ||
847 | 54 | * Deprecation marker if possible | ||
848 | 55 | */ | ||
849 | 56 | #if (__GNUC__ > 2) | ||
850 | 57 | # define EPICS_DEPRECATED __attribute__((deprecated)) | ||
851 | 58 | #else | ||
852 | 59 | # define EPICS_DEPRECATED | ||
853 | 60 | #endif | ||
854 | 61 | |||
855 | 62 | #endif /* ifndef compilerSpecific_h */ | ||
856 | 0 | 63 | ||
857 | === added file 'src/libCom/osi/compiler/gcc/epicsAtomicCD.h' | |||
858 | --- src/libCom/osi/compiler/gcc/epicsAtomicCD.h 1970-01-01 00:00:00 +0000 | |||
859 | +++ src/libCom/osi/compiler/gcc/epicsAtomicCD.h 2011-08-31 22:29:24 +0000 | |||
860 | @@ -0,0 +1,172 @@ | |||
861 | 1 | |||
862 | 2 | /*************************************************************************\ | ||
863 | 3 | * Copyright (c) 2011 LANS LLC, as Operator of | ||
864 | 4 | * Los Alamos National Laboratory. | ||
865 | 5 | * Copyright (c) 2011 UChicago Argonne LLC, as Operator of Argonne | ||
866 | 6 | * National Laboratory. | ||
867 | 7 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
868 | 8 | * in file LICENSE that is included with this distribution. | ||
869 | 9 | \*************************************************************************/ | ||
870 | 10 | |||
871 | 11 | /* | ||
872 | 12 | * Author Jeffrey O. Hill | ||
873 | 13 | * johill@lanl.gov | ||
874 | 14 | */ | ||
875 | 15 | |||
876 | 16 | #ifndef epicsAtomicCD_h | ||
877 | 17 | #define epicsAtomicCD_h | ||
878 | 18 | |||
879 | 19 | #ifndef __GNUC__ | ||
880 | 20 | # error this header is only for use with the gnu compiler | ||
881 | 21 | #endif | ||
882 | 22 | |||
883 | 23 | #define EPICS_ATOMIC_INLINE __inline__ | ||
884 | 24 | |||
885 | 25 | #define GCC_ATOMIC_CONCAT( A, B ) GCC_ATOMIC_CONCATR(A,B) | ||
886 | 26 | #define GCC_ATOMIC_CONCATR( A, B ) ( A ## B ) | ||
887 | 27 | |||
888 | 28 | #define GCC_ATOMIC_INTRINSICS_AVAIL_INT_T \ | ||
889 | 29 | GCC_ATOMIC_CONCAT ( \ | ||
890 | 30 | __GCC_HAVE_SYNC_COMPARE_AND_SWAP_, \ | ||
891 | 31 | __SIZEOF_INT__ ) | ||
892 | 32 | |||
893 | 33 | #define GCC_ATOMIC_INTRINSICS_AVAIL_SIZE_T \ | ||
894 | 34 | GCC_ATOMIC_CONCAT ( \ | ||
895 | 35 | __GCC_HAVE_SYNC_COMPARE_AND_SWAP_, \ | ||
896 | 36 | __SIZEOF_SIZE_T__ ) | ||
897 | 37 | |||
898 | 38 | #define GCC_ATOMIC_INTRINSICS_MIN_X86 \ | ||
899 | 39 | ( defined ( __i486 ) || defined ( __pentium ) || \ | ||
900 | 40 | defined ( __pentiumpro ) || defined ( __MMX__ ) ) | ||
901 | 41 | |||
902 | 42 | #define GCC_ATOMIC_INTRINSICS_GCC4_OR_BETTER \ | ||
903 | 43 | ( ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 401 ) | ||
904 | 44 | |||
905 | 45 | #define GCC_ATOMIC_INTRINSICS_AVAIL_EARLIER \ | ||
906 | 46 | ( GCC_ATOMIC_INTRINSICS_MIN_X86 && \ | ||
907 | 47 | GCC_ATOMIC_INTRINSICS_GCC4_OR_BETTER ) | ||
908 | 48 | |||
909 | 49 | #ifdef __cplusplus | ||
910 | 50 | extern "C" { | ||
911 | 51 | #endif | ||
912 | 52 | |||
913 | 53 | /* | ||
914 | 54 | * We are optimistic that __sync_synchronize is implemented | ||
915 | 55 | * in all version four gcc invarient of target. The gnu doc | ||
916 | 56 | * seems to say that when not supported by architecture a call | ||
917 | 57 | * to an external function is generated but in practice | ||
918 | 58 | * this isnt the case for some of the atomic intrinsics, and | ||
919 | 59 | * so there is an undefined symbol. So far we have not seen | ||
920 | 60 | * that with __sync_synchronize, but we can only guess based | ||
921 | 61 | * on experimental evidence. | ||
922 | 62 | * | ||
923 | 63 | * For example we know that when generating object code for | ||
924 | 64 | * 386 most of the atomic instrinsics are not present and | ||
925 | 65 | * we see undefined symbols with mingw, but we dont have | ||
926 | 66 | * troubles with __sync_synchronize. | ||
927 | 67 | */ | ||
928 | 68 | #if GCC_ATOMIC_INTRINSICS_GCC4_OR_BETTER | ||
929 | 69 | |||
930 | 70 | #ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER | ||
931 | 71 | #define EPICS_ATOMIC_READ_MEMORY_BARRIER | ||
932 | 72 | EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier () | ||
933 | 73 | { | ||
934 | 74 | __sync_synchronize (); | ||
935 | 75 | } | ||
936 | 76 | #endif | ||
937 | 77 | |||
938 | 78 | #ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER | ||
939 | 79 | #define EPICS_ATOMIC_WRITE_MEMORY_BARRIER | ||
940 | 80 | EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier () | ||
941 | 81 | { | ||
942 | 82 | __sync_synchronize (); | ||
943 | 83 | } | ||
944 | 84 | #endif | ||
945 | 85 | |||
946 | 86 | #endif /* if GCC_ATOMIC_INTRINSICS_GCC4_OR_BETTER */ | ||
947 | 87 | |||
948 | 88 | #if GCC_ATOMIC_INTRINSICS_AVAIL_INT_T \ | ||
949 | 89 | || GCC_ATOMIC_INTRINSICS_AVAIL_EARLIER | ||
950 | 90 | |||
951 | 91 | #define EPICS_ATOMIC_INCR_INTT | ||
952 | 92 | EPICS_ATOMIC_INLINE int epicsAtomicIncrIntT ( int * pTarget ) | ||
953 | 93 | { | ||
954 | 94 | return __sync_add_and_fetch ( pTarget, 1 ); | ||
955 | 95 | } | ||
956 | 96 | |||
957 | 97 | #define EPICS_ATOMIC_DECR_INTT | ||
958 | 98 | EPICS_ATOMIC_INLINE int epicsAtomicDecrIntT ( int * pTarget ) | ||
959 | 99 | { | ||
960 | 100 | return __sync_sub_and_fetch ( pTarget, 1 ); | ||
961 | 101 | } | ||
962 | 102 | |||
963 | 103 | #define EPICS_ATOMIC_ADD_INTT | ||
964 | 104 | EPICS_ATOMIC_INLINE int epicsAtomicAddIntT ( int * pTarget, int delta ) | ||
965 | 105 | { | ||
966 | 106 | return __sync_add_and_fetch ( pTarget, delta ); | ||
967 | 107 | } | ||
968 | 108 | |||
969 | 109 | #define EPICS_ATOMIC_CAS_INTT | ||
970 | 110 | EPICS_ATOMIC_INLINE int epicsAtomicCmpAndSwapIntT ( int * pTarget, | ||
971 | 111 | int oldVal, int newVal ) | ||
972 | 112 | { | ||
973 | 113 | return __sync_val_compare_and_swap ( pTarget, oldVal, newVal); | ||
974 | 114 | } | ||
975 | 115 | |||
976 | 116 | #endif /* if GCC_ATOMIC_INTRINSICS_AVAIL_INT_T */ | ||
977 | 117 | |||
978 | 118 | #if GCC_ATOMIC_INTRINSICS_AVAIL_SIZE_T \ | ||
979 | 119 | || GCC_ATOMIC_INTRINSICS_AVAIL_EARLIER | ||
980 | 120 | |||
981 | 121 | #define EPICS_ATOMIC_INCR_SIZET | ||
982 | 122 | EPICS_ATOMIC_INLINE size_t epicsAtomicIncrSizeT ( size_t * pTarget ) | ||
983 | 123 | { | ||
984 | 124 | return __sync_add_and_fetch ( pTarget, 1u ); | ||
985 | 125 | } | ||
986 | 126 | |||
987 | 127 | #define EPICS_ATOMIC_DECR_SIZET | ||
988 | 128 | EPICS_ATOMIC_INLINE size_t epicsAtomicDecrSizeT ( size_t * pTarget ) | ||
989 | 129 | { | ||
990 | 130 | return __sync_sub_and_fetch ( pTarget, 1u ); | ||
991 | 131 | } | ||
992 | 132 | |||
993 | 133 | #define EPICS_ATOMIC_ADD_SIZET | ||
994 | 134 | EPICS_ATOMIC_INLINE size_t epicsAtomicAddSizeT ( size_t * pTarget, size_t delta ) | ||
995 | 135 | { | ||
996 | 136 | return __sync_add_and_fetch ( pTarget, delta ); | ||
997 | 137 | } | ||
998 | 138 | |||
999 | 139 | #define EPICS_ATOMIC_SUB_SIZET | ||
1000 | 140 | EPICS_ATOMIC_INLINE size_t epicsAtomicSubSizeT ( size_t * pTarget, size_t delta ) | ||
1001 | 141 | { | ||
1002 | 142 | return __sync_sub_and_fetch ( pTarget, delta ); | ||
1003 | 143 | } | ||
1004 | 144 | |||
1005 | 145 | #define EPICS_ATOMIC_CAS_SIZET | ||
1006 | 146 | EPICS_ATOMIC_INLINE size_t epicsAtomicCmpAndSwapSizeT ( size_t * pTarget, | ||
1007 | 147 | size_t oldVal, size_t newVal ) | ||
1008 | 148 | { | ||
1009 | 149 | return __sync_val_compare_and_swap ( pTarget, oldVal, newVal); | ||
1010 | 150 | } | ||
1011 | 151 | |||
1012 | 152 | #define EPICS_ATOMIC_CAS_PTRT | ||
1013 | 153 | EPICS_ATOMIC_INLINE EpicsAtomicPtrT epicsAtomicCmpAndSwapPtrT ( | ||
1014 | 154 | EpicsAtomicPtrT * pTarget, | ||
1015 | 155 | EpicsAtomicPtrT oldVal, EpicsAtomicPtrT newVal ) | ||
1016 | 156 | { | ||
1017 | 157 | return __sync_val_compare_and_swap ( pTarget, oldVal, newVal); | ||
1018 | 158 | } | ||
1019 | 159 | |||
1020 | 160 | #endif /* if GCC_ATOMIC_INTRINSICS_AVAIL_SIZE_T */ | ||
1021 | 161 | |||
1022 | 162 | #ifdef __cplusplus | ||
1023 | 163 | } /* end of extern "C" */ | ||
1024 | 164 | #endif | ||
1025 | 165 | |||
1026 | 166 | /* | ||
1027 | 167 | * if currently unavailable as gcc intrinsics we | ||
1028 | 168 | * will try for an os specific inline solution | ||
1029 | 169 | */ | ||
1030 | 170 | #include "epicsAtomicOSD.h" | ||
1031 | 171 | |||
1032 | 172 | #endif /* epicsAtomicCD_h */ | ||
1033 | 0 | 173 | ||
1034 | === added directory 'src/libCom/osi/compiler/msvc' | |||
1035 | === added file 'src/libCom/osi/compiler/msvc/compilerSpecific.h' | |||
1036 | --- src/libCom/osi/compiler/msvc/compilerSpecific.h 1970-01-01 00:00:00 +0000 | |||
1037 | +++ src/libCom/osi/compiler/msvc/compilerSpecific.h 2011-08-31 22:29:24 +0000 | |||
1038 | @@ -0,0 +1,57 @@ | |||
1039 | 1 | |||
1040 | 2 | /*************************************************************************\ | ||
1041 | 3 | * Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne | ||
1042 | 4 | * National Laboratory. | ||
1043 | 5 | * Copyright (c) 2002 The Regents of the University of California, as | ||
1044 | 6 | * Operator of Los Alamos National Laboratory. | ||
1045 | 7 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
1046 | 8 | * in file LICENSE that is included with this distribution. | ||
1047 | 9 | \*************************************************************************/ | ||
1048 | 10 | |||
1049 | 11 | /* | ||
1050 | 12 | * Author: | ||
1051 | 13 | * Jeffrey O. Hill | ||
1052 | 14 | * johill@lanl.gov | ||
1053 | 15 | */ | ||
1054 | 16 | |||
1055 | 17 | #ifndef compilerSpecific_h | ||
1056 | 18 | #define compilerSpecific_h | ||
1057 | 19 | |||
1058 | 20 | #ifndef _MSC_VER | ||
1059 | 21 | # error compiler/msvc/compilerSpecific.h is only for use with the Microsoft compiler | ||
1060 | 22 | #endif | ||
1061 | 23 | |||
1062 | 24 | #ifdef __cplusplus | ||
1063 | 25 | |||
1064 | 26 | /* | ||
1065 | 27 | * in general we dont like ifdefs but they do allow us to check the | ||
1066 | 28 | * compiler version and make the optimistic assumption that | ||
1067 | 29 | * standards incompliance issues will be fixed by future compiler | ||
1068 | 30 | * releases | ||
1069 | 31 | */ | ||
1070 | 32 | |||
1071 | 33 | /* | ||
1072 | 34 | * CXX_PLACEMENT_DELETE - defined if compiler supports placement delete | ||
1073 | 35 | * CXX_THROW_SPECIFICATION - defined if compiler supports throw specification | ||
1074 | 36 | */ | ||
1075 | 37 | #if _MSC_VER >= 1200 /* visual studio 6.0 or later */ | ||
1076 | 38 | # define CXX_PLACEMENT_DELETE | ||
1077 | 39 | #endif | ||
1078 | 40 | |||
1079 | 41 | #if _MSC_VER > 1300 /* some release after visual studio 7 we hope */ | ||
1080 | 42 | # define CXX_THROW_SPECIFICATION | ||
1081 | 43 | #endif | ||
1082 | 44 | |||
1083 | 45 | #endif /* __cplusplus */ | ||
1084 | 46 | |||
1085 | 47 | /* | ||
1086 | 48 | * Enable format-string checking if possible | ||
1087 | 49 | */ | ||
1088 | 50 | #define EPICS_PRINTF_STYLE(f,a) | ||
1089 | 51 | |||
1090 | 52 | /* | ||
1091 | 53 | * Deprecation marker | ||
1092 | 54 | */ | ||
1093 | 55 | #define EPICS_DEPRECATED | ||
1094 | 56 | |||
1095 | 57 | #endif /* ifndef compilerSpecific_h */ | ||
1096 | 0 | 58 | ||
1097 | === added file 'src/libCom/osi/compiler/msvc/epicsAtomicCD.h' | |||
1098 | --- src/libCom/osi/compiler/msvc/epicsAtomicCD.h 1970-01-01 00:00:00 +0000 | |||
1099 | +++ src/libCom/osi/compiler/msvc/epicsAtomicCD.h 2011-08-31 22:29:24 +0000 | |||
1100 | @@ -0,0 +1,124 @@ | |||
1101 | 1 | |||
1102 | 2 | /*************************************************************************\ | ||
1103 | 3 | * Copyright (c) 2011 LANS LLC, as Operator of | ||
1104 | 4 | * Los Alamos National Laboratory. | ||
1105 | 5 | * Copyright (c) 2011 UChicago Argonne LLC, as Operator of Argonne | ||
1106 | 6 | * National Laboratory. | ||
1107 | 7 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
1108 | 8 | * in file LICENSE that is included with this distribution. | ||
1109 | 9 | \*************************************************************************/ | ||
1110 | 10 | |||
1111 | 11 | /* | ||
1112 | 12 | * Author Jeffrey O. Hill | ||
1113 | 13 | * johill@lanl.gov | ||
1114 | 14 | */ | ||
1115 | 15 | |||
1116 | 16 | #ifndef epicsAtomicCD_h | ||
1117 | 17 | #define epicsAtomicCD_h | ||
1118 | 18 | |||
1119 | 19 | #include "epicsAssert.h" | ||
1120 | 20 | |||
1121 | 21 | #ifndef _MSC_VER | ||
1122 | 22 | # error this header file is only for use with with the Microsoft Compiler | ||
1123 | 23 | #endif | ||
1124 | 24 | |||
1125 | 25 | #ifdef _MSC_EXTENSIONS | ||
1126 | 26 | |||
1127 | 27 | #include <intrin.h> | ||
1128 | 28 | |||
1129 | 29 | #if _MSC_VER >= 1200 | ||
1130 | 30 | # define EPICS_ATOMIC_INLINE __forceinline | ||
1131 | 31 | #else | ||
1132 | 32 | # define EPICS_ATOMIC_INLINE __inline | ||
1133 | 33 | #endif | ||
1134 | 34 | |||
1135 | 35 | #if defined ( _M_IX86 ) | ||
1136 | 36 | # pragma warning( push ) | ||
1137 | 37 | # pragma warning( disable : 4793 ) | ||
1138 | 38 | EPICS_ATOMIC_INLINE void epicsAtomicMemoryBarrier () | ||
1139 | 39 | { | ||
1140 | 40 | long fence; | ||
1141 | 41 | __asm { xchg fence, eax } | ||
1142 | 42 | } | ||
1143 | 43 | # pragma warning( pop ) | ||
1144 | 44 | #elif defined ( _M_X64 ) | ||
1145 | 45 | # define MS_ATOMIC_64 | ||
1146 | 46 | # pragma intrinsic ( __faststorefence ) | ||
1147 | 47 | EPICS_ATOMIC_INLINE void epicsAtomicMemoryBarrier () | ||
1148 | 48 | { | ||
1149 | 49 | __faststorefence (); | ||
1150 | 50 | } | ||
1151 | 51 | #elif defined ( _M_IA64 ) | ||
1152 | 52 | # define MS_ATOMIC_64 | ||
1153 | 53 | # pragma intrinsic ( __mf ) | ||
1154 | 54 | EPICS_ATOMIC_INLINE void epicsAtomicMemoryBarrier () | ||
1155 | 55 | { | ||
1156 | 56 | __mf (); | ||
1157 | 57 | } | ||
1158 | 58 | #else | ||
1159 | 59 | # error unexpected target architecture, msvc version of epicsAtomicCD.h | ||
1160 | 60 | #endif | ||
1161 | 61 | |||
1162 | 62 | /* | ||
1163 | 63 | * The windows doc appears to recommend defining InterlockedExchange | ||
1164 | 64 | * to be _InterlockedExchange to cause it to be an intrinsic, but that | ||
1165 | 65 | * creates issues when later, in a windows os specific header, we include | ||
1166 | 66 | * windows.h. Therefore, we except some code duplication between the msvc | ||
1167 | 67 | * csAtomic.h and win32 osdAtomic.h to avoid problems, and to keep the | ||
1168 | 68 | * os specific windows.h header file out of the msvc cdAtomic.h | ||
1169 | 69 | */ | ||
1170 | 70 | #define MS_LONG long | ||
1171 | 71 | #define MS_InterlockedExchange _InterlockedExchange | ||
1172 | 72 | #define MS_InterlockedCompareExchange _InterlockedCompareExchange | ||
1173 | 73 | #define MS_InterlockedIncrement _InterlockedIncrement | ||
1174 | 74 | #define MS_InterlockedDecrement _InterlockedDecrement | ||
1175 | 75 | #define MS_InterlockedExchange _InterlockedExchange | ||
1176 | 76 | #define MS_InterlockedExchangeAdd _InterlockedExchangeAdd | ||
1177 | 77 | #if defined ( MS_ATOMIC_64 ) | ||
1178 | 78 | # define MS_LONGLONG long long | ||
1179 | 79 | # define MS_InterlockedIncrement64 _InterlockedIncrement64 | ||
1180 | 80 | # define MS_InterlockedDecrement64 _InterlockedDecrement64 | ||
1181 | 81 | # define MS_InterlockedExchange64 _InterlockedExchange64 | ||
1182 | 82 | # define MS_InterlockedExchangeAdd64 _InterlockedExchangeAdd64 | ||
1183 | 83 | # define MS_InterlockedCompareExchange64 _InterlockedCompareExchange64 | ||
1184 | 84 | #endif | ||
1185 | 85 | |||
1186 | 86 | #ifdef __cplusplus | ||
1187 | 87 | extern "C" { | ||
1188 | 88 | #endif /* __cplusplus */ | ||
1189 | 89 | |||
1190 | 90 | #define EPICS_ATOMIC_READ_MEMORY_BARRIER | ||
1191 | 91 | EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier () | ||
1192 | 92 | { | ||
1193 | 93 | epicsAtomicMemoryBarrier (); | ||
1194 | 94 | } | ||
1195 | 95 | |||
1196 | 96 | #define EPICS_ATOMIC_WRITE_MEMORY_BARRIER | ||
1197 | 97 | EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier () | ||
1198 | 98 | { | ||
1199 | 99 | epicsAtomicMemoryBarrier (); | ||
1200 | 100 | } | ||
1201 | 101 | |||
1202 | 102 | #ifdef __cplusplus | ||
1203 | 103 | } /* end of extern "C" */ | ||
1204 | 104 | #endif /* __cplusplus */ | ||
1205 | 105 | |||
1206 | 106 | #include "epicsAtomicMS.h" | ||
1207 | 107 | #include "epicsAtomicDefault.h" | ||
1208 | 108 | |||
1209 | 109 | #else /* ifdef _MSC_EXTENSIONS */ | ||
1210 | 110 | |||
1211 | 111 | #if defined ( __cplusplus ) | ||
1212 | 112 | # define EPICS_ATOMIC_INLINE inline | ||
1213 | 113 | #endif | ||
1214 | 114 | |||
1215 | 115 | /* | ||
1216 | 116 | * if unavailable as an intrinsic we will try | ||
1217 | 117 | * for os specific solution | ||
1218 | 118 | */ | ||
1219 | 119 | #include "epicsAtomicOSD.h" | ||
1220 | 120 | |||
1221 | 121 | #endif /* ifdef _MSC_EXTENSIONS */ | ||
1222 | 122 | |||
1223 | 123 | #endif /* epicsAtomicCD_h */ | ||
1224 | 124 | |||
1225 | 0 | 125 | ||
1226 | === added directory 'src/libCom/osi/compiler/solStudio' | |||
1227 | === added file 'src/libCom/osi/compiler/solStudio/epicsAtomicCD.h' | |||
1228 | --- src/libCom/osi/compiler/solStudio/epicsAtomicCD.h 1970-01-01 00:00:00 +0000 | |||
1229 | +++ src/libCom/osi/compiler/solStudio/epicsAtomicCD.h 2011-08-31 22:29:24 +0000 | |||
1230 | @@ -0,0 +1,27 @@ | |||
1231 | 1 | |||
1232 | 2 | /*************************************************************************\ | ||
1233 | 3 | * Copyright (c) 2011 LANS LLC, as Operator of | ||
1234 | 4 | * Los Alamos National Laboratory. | ||
1235 | 5 | * Copyright (c) 2011 UChicago Argonne LLC, as Operator of Argonne | ||
1236 | 6 | * National Laboratory. | ||
1237 | 7 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
1238 | 8 | * in file LICENSE that is included with this distribution. | ||
1239 | 9 | \*************************************************************************/ | ||
1240 | 10 | |||
1241 | 11 | /* | ||
1242 | 12 | * Author Jeffrey O. Hill | ||
1243 | 13 | * johill@lanl.gov | ||
1244 | 14 | */ | ||
1245 | 15 | |||
1246 | 16 | #ifndef epicsAtomicCD_h | ||
1247 | 17 | #define epicsAtomicCD_h | ||
1248 | 18 | |||
1249 | 19 | #if defined ( __cplusplus ) | ||
1250 | 20 | # define EPICS_ATOMIC_INLINE inline | ||
1251 | 21 | #else | ||
1252 | 22 | # define EPICS_ATOMIC_INLINE __inline | ||
1253 | 23 | #endif | ||
1254 | 24 | |||
1255 | 25 | #include "epicsAtomicOSD.h" | ||
1256 | 26 | |||
1257 | 27 | #endif /* epicsAtomicCD_h */ | ||
1258 | 0 | 28 | ||
1259 | === added file 'src/libCom/osi/compilerDependencies.h' | |||
1260 | --- src/libCom/osi/compilerDependencies.h 1970-01-01 00:00:00 +0000 | |||
1261 | +++ src/libCom/osi/compilerDependencies.h 2011-08-31 22:29:24 +0000 | |||
1262 | @@ -0,0 +1,47 @@ | |||
1263 | 1 | |||
1264 | 2 | /*************************************************************************\ | ||
1265 | 3 | * Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne | ||
1266 | 4 | * National Laboratory. | ||
1267 | 5 | * Copyright (c) 2002 The Regents of the University of California, as | ||
1268 | 6 | * Operator of Los Alamos National Laboratory. | ||
1269 | 7 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
1270 | 8 | * in file LICENSE that is included with this distribution. | ||
1271 | 9 | \*************************************************************************/ | ||
1272 | 10 | |||
1273 | 11 | /* | ||
1274 | 12 | * Author: | ||
1275 | 13 | * Jeffrey O. Hill | ||
1276 | 14 | * johill@lanl.gov | ||
1277 | 15 | */ | ||
1278 | 16 | |||
1279 | 17 | #ifndef compilerDependencies_h | ||
1280 | 18 | #define compilerDependencies_h | ||
1281 | 19 | |||
1282 | 20 | #include "compilerSpecific.h" | ||
1283 | 21 | |||
1284 | 22 | #ifdef __cplusplus | ||
1285 | 23 | |||
1286 | 24 | /* | ||
1287 | 25 | * usage: void func () epicsThrows (( std::bad_alloc, std::logic_error )) | ||
1288 | 26 | * | ||
1289 | 27 | * Note: now a widely accepted concensus (ref Meyers and C++ faq) is that | ||
1290 | 28 | * one should avoid using throw specifications in C++ code | ||
1291 | 29 | */ | ||
1292 | 30 | #if defined ( CXX_THROW_SPECIFICATION ) | ||
1293 | 31 | # define epicsThrows(X) throw X | ||
1294 | 32 | #else | ||
1295 | 33 | # define epicsThrows(X) | ||
1296 | 34 | #endif | ||
1297 | 35 | |||
1298 | 36 | /* | ||
1299 | 37 | * usage: epicsPlacementDeleteOperator (( void *, myMemoryManager & )) | ||
1300 | 38 | */ | ||
1301 | 39 | #if defined ( CXX_PLACEMENT_DELETE ) | ||
1302 | 40 | # define epicsPlacementDeleteOperator(X) void operator delete X; | ||
1303 | 41 | #else | ||
1304 | 42 | # define epicsPlacementDeleteOperator(X) | ||
1305 | 43 | #endif | ||
1306 | 44 | |||
1307 | 45 | #endif /* __cplusplus */ | ||
1308 | 46 | |||
1309 | 47 | #endif /* ifndef compilerDependencies_h */ | ||
1310 | 0 | 48 | ||
1311 | === added file 'src/libCom/osi/epicsAtomic.h' | |||
1312 | --- src/libCom/osi/epicsAtomic.h 1970-01-01 00:00:00 +0000 | |||
1313 | +++ src/libCom/osi/epicsAtomic.h 2011-08-31 22:29:24 +0000 | |||
1314 | @@ -0,0 +1,237 @@ | |||
1315 | 1 | |||
1316 | 2 | /*************************************************************************\ | ||
1317 | 3 | * Copyright (c) 2011 LANS LLC, as Operator of | ||
1318 | 4 | * Los Alamos National Laboratory. | ||
1319 | 5 | * Copyright (c) 2011 UChicago Argonne LLC, as Operator of Argonne | ||
1320 | 6 | * National Laboratory. | ||
1321 | 7 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
1322 | 8 | * in file LICENSE that is included with this distribution. | ||
1323 | 9 | \*************************************************************************/ | ||
1324 | 10 | |||
1325 | 11 | /* | ||
1326 | 12 | * Author Jeffrey O. Hill | ||
1327 | 13 | * johill@lanl.gov | ||
1328 | 14 | */ | ||
1329 | 15 | |||
1330 | 16 | #ifndef epicsAtomic_h | ||
1331 | 17 | #define epicsAtomic_h | ||
1332 | 18 | |||
1333 | 19 | #include <stdlib.h> /* define size_t */ | ||
1334 | 20 | |||
1335 | 21 | #include "shareLib.h" | ||
1336 | 22 | |||
1337 | 23 | #ifdef __cplusplus | ||
1338 | 24 | extern "C" { | ||
1339 | 25 | #endif | ||
1340 | 26 | |||
1341 | 27 | typedef void * EpicsAtomicPtrT; | ||
1342 | 28 | |||
1343 | 29 | /* load target into cache */ | ||
1344 | 30 | epicsShareFunc void epicsAtomicReadMemoryBarrier (); | ||
1345 | 31 | |||
1346 | 32 | /* push cache version of target into target */ | ||
1347 | 33 | epicsShareFunc void epicsAtomicWriteMemoryBarrier (); | ||
1348 | 34 | |||
1349 | 35 | /* | ||
1350 | 36 | * lock out other smp processors from accessing the target, | ||
1351 | 37 | * load target into cache, add one to target, flush cache | ||
1352 | 38 | * to target, allow other smp processors to access the target, | ||
1353 | 39 | * return new value of target as modified by this operation | ||
1354 | 40 | */ | ||
1355 | 41 | epicsShareFunc size_t epicsAtomicIncrSizeT ( size_t * pTarget ); | ||
1356 | 42 | epicsShareFunc int epicsAtomicIncrIntT ( int * pTarget ); | ||
1357 | 43 | |||
1358 | 44 | /* | ||
1359 | 45 | * lock out other smp processors from accessing the target, | ||
1360 | 46 | * load target into cache, subtract one from target, flush cache | ||
1361 | 47 | * to target, allow out other smp processors to access the target, | ||
1362 | 48 | * return new value of target as modified by this operation | ||
1363 | 49 | */ | ||
1364 | 50 | epicsShareFunc size_t epicsAtomicDecrSizeT ( size_t * pTarget ); | ||
1365 | 51 | epicsShareFunc int epicsAtomicDecrIntT ( int * pTarget ); | ||
1366 | 52 | |||
1367 | 53 | /* | ||
1368 | 54 | * lock out other smp processors from accessing the target, | ||
1369 | 55 | * load target into cache, add/sub delta to/from target, flush cache | ||
1370 | 56 | * to target, allow other smp processors to access the target, | ||
1371 | 57 | * return new value of target as modified by this operation | ||
1372 | 58 | */ | ||
1373 | 59 | epicsShareFunc size_t epicsAtomicAddSizeT ( size_t * pTarget, size_t delta ); | ||
1374 | 60 | epicsShareFunc size_t epicsAtomicSubSizeT ( size_t * pTarget, size_t delta ); | ||
1375 | 61 | epicsShareFunc int epicsAtomicAddIntT ( int * pTarget, int delta ); | ||
1376 | 62 | |||
1377 | 63 | /* | ||
1378 | 64 | * set cache version of target, flush cache to target | ||
1379 | 65 | */ | ||
1380 | 66 | epicsShareFunc void epicsAtomicSetSizeT ( size_t * pTarget, size_t newValue ); | ||
1381 | 67 | epicsShareFunc void epicsAtomicSetIntT ( int * pTarget, int newValue ); | ||
1382 | 68 | epicsShareFunc void epicsAtomicSetPtrT ( EpicsAtomicPtrT * pTarget, EpicsAtomicPtrT newValue ); | ||
1383 | 69 | |||
1384 | 70 | /* | ||
1385 | 71 | * fetch target into cache, return new value of target | ||
1386 | 72 | */ | ||
1387 | 73 | epicsShareFunc size_t epicsAtomicGetSizeT ( const size_t * pTarget ); | ||
1388 | 74 | epicsShareFunc int epicsAtomicGetIntT ( const int * pTarget ); | ||
1389 | 75 | epicsShareFunc EpicsAtomicPtrT epicsAtomicGetPtrT ( const EpicsAtomicPtrT * pTarget ); | ||
1390 | 76 | |||
1391 | 77 | /* | ||
1392 | 78 | * lock out other smp processors from accessing the target, | ||
1393 | 79 | * load target into cache, if target is equal to oldVal set target | ||
1394 | 80 | * to newVal, flush cache to target, allow other smp processors | ||
1395 | 81 | * to access the target, return the original value stored in the | ||
1396 | 82 | * target | ||
1397 | 83 | */ | ||
1398 | 84 | epicsShareFunc size_t epicsAtomicCmpAndSwapSizeT ( size_t * pTarget, | ||
1399 | 85 | size_t oldVal, size_t newVal ); | ||
1400 | 86 | epicsShareFunc int epicsAtomicCmpAndSwapIntT ( int * pTarget, | ||
1401 | 87 | int oldVal, int newVal ); | ||
1402 | 88 | epicsShareFunc EpicsAtomicPtrT epicsAtomicCmpAndSwapPtrT ( | ||
1403 | 89 | EpicsAtomicPtrT * pTarget, | ||
1404 | 90 | EpicsAtomicPtrT oldVal, | ||
1405 | 91 | EpicsAtomicPtrT newVal ); | ||
1406 | 92 | |||
1407 | 93 | #ifdef __cplusplus | ||
1408 | 94 | } /* end of extern "C" */ | ||
1409 | 95 | #endif | ||
1410 | 96 | |||
1411 | 97 | /* | ||
1412 | 98 | * options for inline compiler instrinsic or os specific | ||
1413 | 99 | * implementations of the above function prototypes | ||
1414 | 100 | * | ||
1415 | 101 | * its importnat for certaiin compiler to define the | ||
1416 | 102 | * inline functions before they get used in the c++ | ||
1417 | 103 | * code below | ||
1418 | 104 | */ | ||
1419 | 105 | #include "epicsAtomicCD.h" | ||
1420 | 106 | |||
1421 | 107 | #ifdef __cplusplus | ||
1422 | 108 | |||
1423 | 109 | namespace epics { | ||
1424 | 110 | namespace atomic { | ||
1425 | 111 | |||
1426 | 112 | /* | ||
1427 | 113 | * overloaded c++ interface | ||
1428 | 114 | */ | ||
1429 | 115 | epicsShareFunc size_t increment ( size_t & v ); | ||
1430 | 116 | epicsShareFunc int increment ( int & v ); | ||
1431 | 117 | epicsShareFunc size_t decrement ( size_t & v ); | ||
1432 | 118 | epicsShareFunc int decrement ( int & v ); | ||
1433 | 119 | epicsShareFunc size_t add ( size_t & v, size_t delta ); | ||
1434 | 120 | epicsShareFunc int add ( int & v, int delta ); | ||
1435 | 121 | epicsShareFunc size_t subtract ( size_t & v, size_t delta ); | ||
1436 | 122 | epicsShareFunc int subtract ( int & v, int delta ); | ||
1437 | 123 | epicsShareFunc void set ( size_t & v , size_t newValue ); | ||
1438 | 124 | epicsShareFunc void set ( int & v, int newValue ); | ||
1439 | 125 | epicsShareFunc void set ( EpicsAtomicPtrT & v, | ||
1440 | 126 | EpicsAtomicPtrT newValue ); | ||
1441 | 127 | epicsShareFunc size_t get ( const size_t & v ); | ||
1442 | 128 | epicsShareFunc int get ( const int & v ); | ||
1443 | 129 | epicsShareFunc EpicsAtomicPtrT get ( const EpicsAtomicPtrT & v ); | ||
1444 | 130 | epicsShareFunc size_t compareAndSwap ( size_t & v, size_t oldVal, | ||
1445 | 131 | size_t newVal ); | ||
1446 | 132 | epicsShareFunc int compareAndSwap ( int & v, int oldVal, int newVal ); | ||
1447 | 133 | epicsShareFunc EpicsAtomicPtrT compareAndSwap ( EpicsAtomicPtrT & v, | ||
1448 | 134 | EpicsAtomicPtrT oldVal, | ||
1449 | 135 | EpicsAtomicPtrT newVal ); | ||
1450 | 136 | |||
1451 | 137 | /************* incr ***************/ | ||
1452 | 138 | inline size_t increment ( size_t & v ) | ||
1453 | 139 | { | ||
1454 | 140 | return epicsAtomicIncrSizeT ( & v ); | ||
1455 | 141 | } | ||
1456 | 142 | |||
1457 | 143 | inline int increment ( int & v ) | ||
1458 | 144 | { | ||
1459 | 145 | return epicsAtomicIncrIntT ( & v ); | ||
1460 | 146 | } | ||
1461 | 147 | |||
1462 | 148 | /************* decr ***************/ | ||
1463 | 149 | inline size_t decrement ( size_t & v ) | ||
1464 | 150 | { | ||
1465 | 151 | return epicsAtomicDecrSizeT ( & v ); | ||
1466 | 152 | } | ||
1467 | 153 | |||
1468 | 154 | inline int decrement ( int & v ) | ||
1469 | 155 | { | ||
1470 | 156 | return epicsAtomicDecrIntT ( & v ); | ||
1471 | 157 | } | ||
1472 | 158 | |||
1473 | 159 | /************* add ***************/ | ||
1474 | 160 | inline size_t add ( size_t & v, size_t delta ) | ||
1475 | 161 | { | ||
1476 | 162 | return epicsAtomicAddSizeT ( & v, delta ); | ||
1477 | 163 | } | ||
1478 | 164 | |||
1479 | 165 | inline int add ( int & v, int delta ) | ||
1480 | 166 | { | ||
1481 | 167 | return epicsAtomicAddIntT ( & v, delta ); | ||
1482 | 168 | } | ||
1483 | 169 | |||
1484 | 170 | /************* sub ***************/ | ||
1485 | 171 | inline size_t subtract ( size_t & v, size_t delta ) | ||
1486 | 172 | { | ||
1487 | 173 | return epicsAtomicSubSizeT ( & v, delta ); | ||
1488 | 174 | } | ||
1489 | 175 | |||
1490 | 176 | inline int subtract ( int & v, int delta ) | ||
1491 | 177 | { | ||
1492 | 178 | return epicsAtomicAddIntT ( & v, -delta ); | ||
1493 | 179 | } | ||
1494 | 180 | |||
1495 | 181 | /************* set ***************/ | ||
1496 | 182 | inline void set ( size_t & v , size_t newValue ) | ||
1497 | 183 | { | ||
1498 | 184 | epicsAtomicSetSizeT ( & v, newValue ); | ||
1499 | 185 | } | ||
1500 | 186 | |||
1501 | 187 | inline void set ( int & v, int newValue ) | ||
1502 | 188 | { | ||
1503 | 189 | epicsAtomicSetIntT ( & v, newValue ); | ||
1504 | 190 | } | ||
1505 | 191 | |||
1506 | 192 | inline void set ( EpicsAtomicPtrT & v, EpicsAtomicPtrT newValue ) | ||
1507 | 193 | { | ||
1508 | 194 | epicsAtomicSetPtrT ( & v, newValue ); | ||
1509 | 195 | } | ||
1510 | 196 | |||
1511 | 197 | /************* get ***************/ | ||
1512 | 198 | inline size_t get ( const size_t & v ) | ||
1513 | 199 | { | ||
1514 | 200 | return epicsAtomicGetSizeT ( & v ); | ||
1515 | 201 | } | ||
1516 | 202 | |||
1517 | 203 | inline int get ( const int & v ) | ||
1518 | 204 | { | ||
1519 | 205 | return epicsAtomicGetIntT ( & v ); | ||
1520 | 206 | } | ||
1521 | 207 | |||
1522 | 208 | inline EpicsAtomicPtrT get ( const EpicsAtomicPtrT & v ) | ||
1523 | 209 | { | ||
1524 | 210 | return epicsAtomicGetPtrT ( & v ); | ||
1525 | 211 | } | ||
1526 | 212 | |||
1527 | 213 | /************* cas ***************/ | ||
1528 | 214 | inline size_t compareAndSwap ( size_t & v, | ||
1529 | 215 | size_t oldVal, size_t newVal ) | ||
1530 | 216 | { | ||
1531 | 217 | return epicsAtomicCmpAndSwapSizeT ( & v, oldVal, newVal ); | ||
1532 | 218 | } | ||
1533 | 219 | |||
1534 | 220 | inline int compareAndSwap ( int & v, int oldVal, int newVal ) | ||
1535 | 221 | { | ||
1536 | 222 | return epicsAtomicCmpAndSwapIntT ( & v, oldVal, newVal ); | ||
1537 | 223 | } | ||
1538 | 224 | |||
1539 | 225 | inline EpicsAtomicPtrT compareAndSwap ( EpicsAtomicPtrT & v, | ||
1540 | 226 | EpicsAtomicPtrT oldVal, | ||
1541 | 227 | EpicsAtomicPtrT newVal ) | ||
1542 | 228 | { | ||
1543 | 229 | return epicsAtomicCmpAndSwapPtrT ( & v, oldVal, newVal ); | ||
1544 | 230 | } | ||
1545 | 231 | |||
1546 | 232 | } /* end of namespace atomic */ | ||
1547 | 233 | } /* end of namespace epics */ | ||
1548 | 234 | |||
1549 | 235 | #endif /* ifdef __cplusplus */ | ||
1550 | 236 | |||
1551 | 237 | #endif /* epicsAtomic_h */ | ||
1552 | 0 | 238 | ||
1553 | === added file 'src/libCom/osi/epicsAtomicDefault.h' | |||
1554 | --- src/libCom/osi/epicsAtomicDefault.h 1970-01-01 00:00:00 +0000 | |||
1555 | +++ src/libCom/osi/epicsAtomicDefault.h 2011-08-31 22:29:24 +0000 | |||
1556 | @@ -0,0 +1,235 @@ | |||
1557 | 1 | |||
1558 | 2 | /*************************************************************************\ | ||
1559 | 3 | * Copyright (c) 2011 LANS LLC, as Operator of | ||
1560 | 4 | * Los Alamos National Laboratory. | ||
1561 | 5 | * Copyright (c) 2011 UChicago Argonne LLC, as Operator of Argonne | ||
1562 | 6 | * National Laboratory. | ||
1563 | 7 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
1564 | 8 | * in file LICENSE that is included with this distribution. | ||
1565 | 9 | \*************************************************************************/ | ||
1566 | 10 | |||
1567 | 11 | /* | ||
1568 | 12 | * Author Jeffrey O. Hill | ||
1569 | 13 | * johill@lanl.gov | ||
1570 | 14 | */ | ||
1571 | 15 | |||
1572 | 16 | #ifndef epicsAtomicDefault_h | ||
1573 | 17 | #define epicsAtomicDefault_h | ||
1574 | 18 | |||
1575 | 19 | /* | ||
1576 | 20 | * EPICS_ATOMIC_INLINE might be defined, but empty for an out-of-line | ||
1577 | 21 | * instantiation | ||
1578 | 22 | */ | ||
1579 | 23 | #ifdef EPICS_ATOMIC_INLINE | ||
1580 | 24 | |||
1581 | 25 | #ifdef __cpluplus | ||
1582 | 26 | extern "C" { | ||
1583 | 27 | #endif | ||
1584 | 28 | |||
1585 | 29 | /* | ||
1586 | 30 | * struct EpicsAtomicLockKey; | ||
1587 | 31 | * epicsShareFunc void epicsAtomicReadMemoryBarrier (); | ||
1588 | 32 | * epicsShareFunc void epicsAtomicWriteMemoryBarrier (); | ||
1589 | 33 | * epicsShareFunc void epicsAtomicLock ( struct EpicsAtomicLockKey * ); | ||
1590 | 34 | * epicsShareFunc void epicsAtomicUnock ( struct EpicsAtomicLockKey * ); | ||
1591 | 35 | */ | ||
1592 | 36 | |||
1593 | 37 | /* | ||
1594 | 38 | * incr | ||
1595 | 39 | */ | ||
1596 | 40 | #ifndef EPICS_ATOMIC_INCR_INTT | ||
1597 | 41 | EPICS_ATOMIC_INLINE int epicsAtomicIncrIntT ( int * pTarget ) | ||
1598 | 42 | { | ||
1599 | 43 | EpicsAtomicLockKey key; | ||
1600 | 44 | epicsAtomicLock ( & key ); | ||
1601 | 45 | const int result = ++(*pTarget); | ||
1602 | 46 | epicsAtomicUnlock ( & key ); | ||
1603 | 47 | return result; | ||
1604 | 48 | } | ||
1605 | 49 | #endif | ||
1606 | 50 | |||
1607 | 51 | #ifndef EPICS_ATOMIC_INCR_SIZET | ||
1608 | 52 | EPICS_ATOMIC_INLINE size_t epicsAtomicIncrSizeT ( size_t * pTarget ) | ||
1609 | 53 | { | ||
1610 | 54 | EpicsAtomicLockKey key; | ||
1611 | 55 | epicsAtomicLock ( & key ); | ||
1612 | 56 | const size_t result = ++(*pTarget); | ||
1613 | 57 | epicsAtomicUnlock ( & key ); | ||
1614 | 58 | return result; | ||
1615 | 59 | } | ||
1616 | 60 | #endif | ||
1617 | 61 | |||
1618 | 62 | /* | ||
1619 | 63 | * decr | ||
1620 | 64 | */ | ||
1621 | 65 | #ifndef EPICS_ATOMIC_DECR_INTT | ||
1622 | 66 | EPICS_ATOMIC_INLINE int epicsAtomicDecrIntT ( int * pTarget ) | ||
1623 | 67 | { | ||
1624 | 68 | EpicsAtomicLockKey key; | ||
1625 | 69 | epicsAtomicLock ( & key ); | ||
1626 | 70 | const int result = --(*pTarget); | ||
1627 | 71 | epicsAtomicUnlock ( & key ); | ||
1628 | 72 | return result; | ||
1629 | 73 | } | ||
1630 | 74 | #endif | ||
1631 | 75 | |||
1632 | 76 | #ifndef EPICS_ATOMIC_DECR_SIZET | ||
1633 | 77 | EPICS_ATOMIC_INLINE size_t epicsAtomicDecrSizeT ( size_t * pTarget ) | ||
1634 | 78 | { | ||
1635 | 79 | EpicsAtomicLockKey key; | ||
1636 | 80 | epicsAtomicLock ( & key ); | ||
1637 | 81 | const size_t result = --(*pTarget); | ||
1638 | 82 | epicsAtomicUnlock ( & key ); | ||
1639 | 83 | return result; | ||
1640 | 84 | } | ||
1641 | 85 | #endif | ||
1642 | 86 | |||
1643 | 87 | /* | ||
1644 | 88 | * add/sub | ||
1645 | 89 | */ | ||
1646 | 90 | #ifndef EPICS_ATOMIC_ADD_INTT | ||
1647 | 91 | EPICS_ATOMIC_INLINE int epicsAtomicAddIntT ( int * pTarget, int delta ) | ||
1648 | 92 | { | ||
1649 | 93 | EpicsAtomicLockKey key; | ||
1650 | 94 | epicsAtomicLock ( & key ); | ||
1651 | 95 | const int result = *pTarget += delta; | ||
1652 | 96 | epicsAtomicUnlock ( & key ); | ||
1653 | 97 | return result; | ||
1654 | 98 | } | ||
1655 | 99 | #endif | ||
1656 | 100 | |||
1657 | 101 | #ifndef EPICS_ATOMIC_ADD_SIZET | ||
1658 | 102 | EPICS_ATOMIC_INLINE size_t epicsAtomicAddSizeT ( size_t * pTarget, size_t delta ) | ||
1659 | 103 | { | ||
1660 | 104 | EpicsAtomicLockKey key; | ||
1661 | 105 | epicsAtomicLock ( & key ); | ||
1662 | 106 | const size_t result = *pTarget += delta; | ||
1663 | 107 | epicsAtomicUnlock ( & key ); | ||
1664 | 108 | return result; | ||
1665 | 109 | } | ||
1666 | 110 | #endif | ||
1667 | 111 | |||
1668 | 112 | #ifndef EPICS_ATOMIC_SUB_SIZET | ||
1669 | 113 | EPICS_ATOMIC_INLINE size_t epicsAtomicSubSizeT ( size_t * pTarget, size_t delta ) | ||
1670 | 114 | { | ||
1671 | 115 | EpicsAtomicLockKey key; | ||
1672 | 116 | epicsAtomicLock ( & key ); | ||
1673 | 117 | const size_t result = *pTarget -= delta; | ||
1674 | 118 | epicsAtomicUnlock ( & key ); | ||
1675 | 119 | return result; | ||
1676 | 120 | } | ||
1677 | 121 | #endif | ||
1678 | 122 | |||
1679 | 123 | /* | ||
1680 | 124 | * set | ||
1681 | 125 | */ | ||
1682 | 126 | #ifndef EPICS_ATOMIC_SET_INTT | ||
1683 | 127 | EPICS_ATOMIC_INLINE void epicsAtomicSetIntT ( int * pTarget, int newVal ) | ||
1684 | 128 | { | ||
1685 | 129 | *pTarget = newVal; | ||
1686 | 130 | epicsAtomicWriteMemoryBarrier (); | ||
1687 | 131 | } | ||
1688 | 132 | #endif | ||
1689 | 133 | |||
1690 | 134 | #ifndef EPICS_ATOMIC_SET_SIZET | ||
1691 | 135 | EPICS_ATOMIC_INLINE void epicsAtomicSetSizeT ( size_t * pTarget, size_t newVal ) | ||
1692 | 136 | { | ||
1693 | 137 | *pTarget = newVal; | ||
1694 | 138 | epicsAtomicWriteMemoryBarrier (); | ||
1695 | 139 | } | ||
1696 | 140 | #endif | ||
1697 | 141 | |||
1698 | 142 | #ifndef EPICS_ATOMIC_SET_PTRT | ||
1699 | 143 | EPICS_ATOMIC_INLINE void epicsAtomicSetPtrT ( EpicsAtomicPtrT * pTarget, | ||
1700 | 144 | EpicsAtomicPtrT newVal ) | ||
1701 | 145 | { | ||
1702 | 146 | *pTarget = newVal; | ||
1703 | 147 | epicsAtomicWriteMemoryBarrier (); | ||
1704 | 148 | } | ||
1705 | 149 | #endif | ||
1706 | 150 | |||
1707 | 151 | /* | ||
1708 | 152 | * get | ||
1709 | 153 | */ | ||
1710 | 154 | #ifndef EPICS_ATOMIC_GET_INTT | ||
1711 | 155 | EPICS_ATOMIC_INLINE int epicsAtomicGetIntT ( const int * pTarget ) | ||
1712 | 156 | { | ||
1713 | 157 | epicsAtomicReadMemoryBarrier (); | ||
1714 | 158 | return *pTarget; | ||
1715 | 159 | } | ||
1716 | 160 | #endif | ||
1717 | 161 | |||
1718 | 162 | #ifndef EPICS_ATOMIC_GET_SIZET | ||
1719 | 163 | EPICS_ATOMIC_INLINE size_t epicsAtomicGetSizeT ( const size_t * pTarget ) | ||
1720 | 164 | { | ||
1721 | 165 | epicsAtomicReadMemoryBarrier (); | ||
1722 | 166 | return *pTarget; | ||
1723 | 167 | } | ||
1724 | 168 | #endif | ||
1725 | 169 | |||
1726 | 170 | #ifndef EPICS_ATOMIC_GET_PTRT | ||
1727 | 171 | EPICS_ATOMIC_INLINE EpicsAtomicPtrT | ||
1728 | 172 | epicsAtomicGetPtrT ( const EpicsAtomicPtrT * pTarget ) | ||
1729 | 173 | { | ||
1730 | 174 | epicsAtomicReadMemoryBarrier (); | ||
1731 | 175 | return *pTarget; | ||
1732 | 176 | } | ||
1733 | 177 | #endif | ||
1734 | 178 | |||
1735 | 179 | /* | ||
1736 | 180 | * cmp and swap | ||
1737 | 181 | */ | ||
1738 | 182 | #ifndef EPICS_ATOMIC_CAS_INTT | ||
1739 | 183 | EPICS_ATOMIC_INLINE int epicsAtomicCmpAndSwapIntT ( int * pTarget, int oldval, int newval ) | ||
1740 | 184 | { | ||
1741 | 185 | EpicsAtomicLockKey key; | ||
1742 | 186 | epicsAtomicLock ( & key ); | ||
1743 | 187 | const int cur = *pTarget; | ||
1744 | 188 | if ( cur == oldval ) { | ||
1745 | 189 | *pTarget = newval; | ||
1746 | 190 | } | ||
1747 | 191 | epicsAtomicUnlock ( & key ); | ||
1748 | 192 | return cur; | ||
1749 | 193 | } | ||
1750 | 194 | #endif | ||
1751 | 195 | |||
1752 | 196 | #ifndef EPICS_ATOMIC_CAS_SIZET | ||
1753 | 197 | EPICS_ATOMIC_INLINE size_t epicsAtomicCmpAndSwapSizeT ( size_t * pTarget, | ||
1754 | 198 | size_t oldval, size_t newval ) | ||
1755 | 199 | { | ||
1756 | 200 | EpicsAtomicLockKey key; | ||
1757 | 201 | epicsAtomicLock ( & key ); | ||
1758 | 202 | const size_t cur = *pTarget; | ||
1759 | 203 | if ( cur == oldval ) { | ||
1760 | 204 | *pTarget = newval; | ||
1761 | 205 | } | ||
1762 | 206 | epicsAtomicUnlock ( & key ); | ||
1763 | 207 | return cur; | ||
1764 | 208 | } | ||
1765 | 209 | #endif | ||
1766 | 210 | |||
1767 | 211 | #ifndef EPICS_ATOMIC_CAS_PTRT | ||
1768 | 212 | EPICS_ATOMIC_INLINE EpicsAtomicPtrT epicsAtomicCmpAndSwapPtrT ( | ||
1769 | 213 | EpicsAtomicPtrT * pTarget, | ||
1770 | 214 | EpicsAtomicPtrT oldval, EpicsAtomicPtrT newval ) | ||
1771 | 215 | { | ||
1772 | 216 | EpicsAtomicLockKey key; | ||
1773 | 217 | epicsAtomicLock ( & key ); | ||
1774 | 218 | const EpicsAtomicPtrT cur = *pTarget; | ||
1775 | 219 | if ( cur == oldval ) { | ||
1776 | 220 | *pTarget = newval; | ||
1777 | 221 | } | ||
1778 | 222 | epicsAtomicUnlock ( & key ); | ||
1779 | 223 | return cur; | ||
1780 | 224 | } | ||
1781 | 225 | #endif | ||
1782 | 226 | |||
1783 | 227 | #ifdef __cpluplus | ||
1784 | 228 | } /* end of extern "C" */ | ||
1785 | 229 | #endif | ||
1786 | 230 | |||
1787 | 231 | #endif /* EPICS_ATOMIC_INLINE */ | ||
1788 | 232 | |||
1789 | 233 | #endif /* epicsAtomicDefault_h */ | ||
1790 | 234 | |||
1791 | 235 | |||
1792 | 0 | 236 | ||
1793 | === modified file 'src/libCom/osi/epicsThread.h' | |||
1794 | --- src/libCom/osi/epicsThread.h 2010-04-26 20:38:11 +0000 | |||
1795 | +++ src/libCom/osi/epicsThread.h 2011-08-31 22:29:24 +0000 | |||
1796 | @@ -51,7 +51,7 @@ | |||
1797 | 51 | /* (epicsThreadId)0 is guaranteed to be an invalid thread id */ | 51 | /* (epicsThreadId)0 is guaranteed to be an invalid thread id */ |
1798 | 52 | typedef struct epicsThreadOSD *epicsThreadId; | 52 | typedef struct epicsThreadOSD *epicsThreadId; |
1799 | 53 | 53 | ||
1801 | 54 | typedef epicsThreadId epicsThreadOnceId; | 54 | typedef void * epicsThreadOnceId; |
1802 | 55 | #define EPICS_THREAD_ONCE_INIT 0 | 55 | #define EPICS_THREAD_ONCE_INIT 0 |
1803 | 56 | 56 | ||
1804 | 57 | epicsShareFunc void epicsShareAPI epicsThreadOnce( | 57 | epicsShareFunc void epicsShareAPI epicsThreadOnce( |
1805 | 58 | 58 | ||
1806 | === added file 'src/libCom/osi/epicsThreadOnce.cpp' | |||
1807 | --- src/libCom/osi/epicsThreadOnce.cpp 1970-01-01 00:00:00 +0000 | |||
1808 | +++ src/libCom/osi/epicsThreadOnce.cpp 2011-08-31 22:29:24 +0000 | |||
1809 | @@ -0,0 +1,129 @@ | |||
1810 | 1 | |||
1811 | 2 | /*************************************************************************\ | ||
1812 | 3 | * Copyright (c) 2011 LANS LLC, as Operator of | ||
1813 | 4 | * Los Alamos National Laboratory. | ||
1814 | 5 | * Copyright (c) 2011 UChicago Argonne LLC, as Operator of Argonne | ||
1815 | 6 | * National Laboratory. | ||
1816 | 7 | * Copyright (c) 2002 The Regents of the University of California, as | ||
1817 | 8 | * Operator of Los Alamos National Laboratory. | ||
1818 | 9 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
1819 | 10 | * in file LICENSE that is included with this distribution. | ||
1820 | 11 | \*************************************************************************/ | ||
1821 | 12 | |||
1822 | 13 | /* | ||
1823 | 14 | * Author Jeffrey O. Hill johill@lanl.gov | ||
1824 | 15 | * Original Authors (before converting to operating system independent code): | ||
1825 | 16 | * Jeff Hill, Andrew Johnson, Marty Kraimer, Eric Norum | ||
1826 | 17 | */ | ||
1827 | 18 | |||
1828 | 19 | #include <cstdlib> | ||
1829 | 20 | |||
1830 | 21 | #define epicsExportSharedSymbols | ||
1831 | 22 | #include "errlog.h" | ||
1832 | 23 | #include "cantProceed.h" | ||
1833 | 24 | #include "epicsThread.h" | ||
1834 | 25 | #include "epicsAtomic.h" | ||
1835 | 26 | #include "epicsAssert.h" | ||
1836 | 27 | |||
1837 | 28 | namespace { | ||
1838 | 29 | |||
1839 | 30 | struct ThreadID { | ||
1840 | 31 | public: | ||
1841 | 32 | ThreadID (); | ||
1842 | 33 | ThreadID ( epicsThreadId id ); | ||
1843 | 34 | bool operator == ( const ThreadID & ) const; | ||
1844 | 35 | private: | ||
1845 | 36 | epicsThreadId m_threadId; | ||
1846 | 37 | ThreadID ( const ThreadID & ); // disabled | ||
1847 | 38 | ThreadID & operator = ( const ThreadID & ); // disabled | ||
1848 | 39 | }; | ||
1849 | 40 | |||
1850 | 41 | inline ThreadID :: ThreadID ( epicsThreadId id ) : | ||
1851 | 42 | m_threadId ( id ) | ||
1852 | 43 | { | ||
1853 | 44 | } | ||
1854 | 45 | |||
1855 | 46 | inline ThreadID :: ThreadID () : m_threadId ( 0 ) | ||
1856 | 47 | { | ||
1857 | 48 | } | ||
1858 | 49 | |||
1859 | 50 | inline bool ThreadID :: operator == ( const ThreadID & ctrl ) const | ||
1860 | 51 | { | ||
1861 | 52 | return ctrl.m_threadId == m_threadId; | ||
1862 | 53 | } | ||
1863 | 54 | |||
1864 | 55 | static ThreadID done; | ||
1865 | 56 | |||
1866 | 57 | } // end of namespace annonymous | ||
1867 | 58 | |||
1868 | 59 | using namespace epics; | ||
1869 | 60 | using namespace atomic; | ||
1870 | 61 | |||
1871 | 62 | /* | ||
1872 | 63 | * epicsThreadOnceOnly () | ||
1873 | 64 | */ | ||
1874 | 65 | static void epicsShareAPI epicsThreadOnceOnly ( epicsThreadOnceId * pId, | ||
1875 | 66 | void ( * pFunc )( void * ), | ||
1876 | 67 | void * pArg ) | ||
1877 | 68 | { | ||
1878 | 69 | static const epicsThreadOnceId idStartup = EPICS_THREAD_ONCE_INIT; | ||
1879 | 70 | ThreadID self ( epicsThreadGetIdSelf () ); | ||
1880 | 71 | epicsThreadOnceId pCurrent = compareAndSwap ( *pId, idStartup, & self ); | ||
1881 | 72 | if ( pCurrent != & done ) { | ||
1882 | 73 | if ( pCurrent == idStartup ) { | ||
1883 | 74 | ( *pFunc ) ( pArg ); | ||
1884 | 75 | set ( *pId, & done ); | ||
1885 | 76 | } | ||
1886 | 77 | else { | ||
1887 | 78 | { | ||
1888 | 79 | ThreadID & initID = | ||
1889 | 80 | * reinterpret_cast < ThreadID * > ( pCurrent ); | ||
1890 | 81 | if ( initID == self ) { | ||
1891 | 82 | cantProceed( "epicsThreadOnce() once was called " | ||
1892 | 83 | "recursively from the user's once fuction\n" ); | ||
1893 | 84 | } | ||
1894 | 85 | } | ||
1895 | 86 | static const std :: size_t spinDownInit = 1000u; | ||
1896 | 87 | static const std :: size_t spinCount = 10u; | ||
1897 | 88 | STATIC_ASSERT ( spinDownInit > spinCount ); | ||
1898 | 89 | static const std :: size_t spinThresh = spinDownInit - spinCount; | ||
1899 | 90 | std :: size_t spinDown = spinDownInit; | ||
1900 | 91 | do { | ||
1901 | 92 | if ( spinDown <= spinThresh ) { | ||
1902 | 93 | epicsThreadSleep ( epicsThreadSleepQuantum () ); | ||
1903 | 94 | } | ||
1904 | 95 | if ( spinDown > 0u ) { | ||
1905 | 96 | spinDown--; | ||
1906 | 97 | } | ||
1907 | 98 | else { | ||
1908 | 99 | errlogPrintf ( "epicsThreadOnce: waiting for another " | ||
1909 | 100 | "thread to finish calling the once function\n" ); | ||
1910 | 101 | spinDown = spinThresh; | ||
1911 | 102 | } | ||
1912 | 103 | pCurrent = get ( *pId ); | ||
1913 | 104 | } while ( pCurrent != & done ); | ||
1914 | 105 | } | ||
1915 | 106 | } | ||
1916 | 107 | } | ||
1917 | 108 | |||
1918 | 109 | // | ||
1919 | 110 | // we implement this as a separate function so that it is easy to see | ||
1920 | 111 | // that the performance impact of the primary (most commonly used) path | ||
1921 | 112 | // and that options for inlining this function are available (based on | ||
1922 | 113 | // source code organization) | ||
1923 | 114 | // | ||
1924 | 115 | // performance might be slightly better if this were implemented as an inline | ||
1925 | 116 | // function, but that would pull epicsAtomic.h into epicsThread.h, and on | ||
1926 | 117 | // windows this includes (the lean and mean version of) windows.h, so perhaps | ||
1927 | 118 | // its best to make this an out-of-line function as that type of instantiation | ||
1928 | 119 | // will probably have only a small negative impact on performance | ||
1929 | 120 | // | ||
1930 | 121 | extern "C" void epicsShareAPI epicsThreadOnce ( epicsThreadOnceId * pId, | ||
1931 | 122 | void ( * pFunc )( void * ), | ||
1932 | 123 | void * pArg ) | ||
1933 | 124 | { | ||
1934 | 125 | const epicsThreadOnceId pCurrent = get ( *pId ); | ||
1935 | 126 | if ( pCurrent != & done ) { | ||
1936 | 127 | epicsThreadOnceOnly ( pId, pFunc, pArg ); | ||
1937 | 128 | } | ||
1938 | 129 | } | ||
1939 | 0 | 130 | ||
1940 | === modified file 'src/libCom/osi/os/RTEMS/osdThread.c' | |||
1941 | --- src/libCom/osi/os/RTEMS/osdThread.c 2010-10-05 19:27:37 +0000 | |||
1942 | +++ src/libCom/osi/os/RTEMS/osdThread.c 2011-08-31 22:29:24 +0000 | |||
1943 | @@ -60,7 +60,6 @@ | |||
1944 | 60 | * Support for `once-only' execution | 60 | * Support for `once-only' execution |
1945 | 61 | */ | 61 | */ |
1946 | 62 | static int initialized = 0; | 62 | static int initialized = 0; |
1947 | 63 | static epicsMutexId onceMutex; | ||
1948 | 64 | 63 | ||
1949 | 65 | /* | 64 | /* |
1950 | 66 | * Just map osi 0 to 99 into RTEMS 199 to 100 | 65 | * Just map osi 0 to 99 into RTEMS 199 to 100 |
1951 | @@ -231,7 +230,6 @@ | |||
1952 | 231 | rtems_task_priority old; | 230 | rtems_task_priority old; |
1953 | 232 | 231 | ||
1954 | 233 | rtems_task_set_priority (RTEMS_SELF, epicsThreadGetOssPriorityValue(99), &old); | 232 | rtems_task_set_priority (RTEMS_SELF, epicsThreadGetOssPriorityValue(99), &old); |
1955 | 234 | onceMutex = epicsMutexMustCreate(); | ||
1956 | 235 | taskVarMutex = epicsMutexMustCreate (); | 233 | taskVarMutex = epicsMutexMustCreate (); |
1957 | 236 | rtems_task_ident (RTEMS_SELF, 0, &tid); | 234 | rtems_task_ident (RTEMS_SELF, 0, &tid); |
1958 | 237 | setThreadInfo (tid, "_main_", NULL, NULL); | 235 | setThreadInfo (tid, "_main_", NULL, NULL); |
1959 | @@ -471,36 +469,6 @@ | |||
1960 | 471 | } | 469 | } |
1961 | 472 | 470 | ||
1962 | 473 | /* | 471 | /* |
1963 | 474 | * Ensure func() is run only once. | ||
1964 | 475 | */ | ||
1965 | 476 | void epicsThreadOnce(epicsThreadOnceId *id, void(*func)(void *), void *arg) | ||
1966 | 477 | { | ||
1967 | 478 | #define EPICS_THREAD_ONCE_DONE (epicsThreadId) 1 | ||
1968 | 479 | |||
1969 | 480 | if (!initialized) epicsThreadInit(); | ||
1970 | 481 | epicsMutexMustLock(onceMutex); | ||
1971 | 482 | if (*id != EPICS_THREAD_ONCE_DONE) { | ||
1972 | 483 | if (*id == EPICS_THREAD_ONCE_INIT) { /* first call */ | ||
1973 | 484 | *id = epicsThreadGetIdSelf(); /* mark active */ | ||
1974 | 485 | epicsMutexUnlock(onceMutex); | ||
1975 | 486 | func(arg); | ||
1976 | 487 | epicsMutexMustLock(onceMutex); | ||
1977 | 488 | *id = EPICS_THREAD_ONCE_DONE; /* mark done */ | ||
1978 | 489 | } else if (*id == epicsThreadGetIdSelf()) { | ||
1979 | 490 | epicsMutexUnlock(onceMutex); | ||
1980 | 491 | cantProceed("Recursive epicsThreadOnce() initialization\n"); | ||
1981 | 492 | } else | ||
1982 | 493 | while (*id != EPICS_THREAD_ONCE_DONE) { | ||
1983 | 494 | /* Another thread is in the above func(arg) call. */ | ||
1984 | 495 | epicsMutexUnlock(onceMutex); | ||
1985 | 496 | epicsThreadSleep(epicsThreadSleepQuantum()); | ||
1986 | 497 | epicsMutexMustLock(onceMutex); | ||
1987 | 498 | } | ||
1988 | 499 | } | ||
1989 | 500 | epicsMutexUnlock(onceMutex); | ||
1990 | 501 | } | ||
1991 | 502 | |||
1992 | 503 | /* | ||
1993 | 504 | * Thread private storage implementation based on the vxWorks | 472 | * Thread private storage implementation based on the vxWorks |
1994 | 505 | * implementation by Andrew Johnson APS/ASD. | 473 | * implementation by Andrew Johnson APS/ASD. |
1995 | 506 | */ | 474 | */ |
1996 | 507 | 475 | ||
1997 | === added file 'src/libCom/osi/os/WIN32/epicsAtomicMS.h' | |||
1998 | --- src/libCom/osi/os/WIN32/epicsAtomicMS.h 1970-01-01 00:00:00 +0000 | |||
1999 | +++ src/libCom/osi/os/WIN32/epicsAtomicMS.h 2011-08-31 22:29:24 +0000 | |||
2000 | @@ -0,0 +1,222 @@ | |||
2001 | 1 | |||
2002 | 2 | /*************************************************************************\ | ||
2003 | 3 | * Copyright (c) 2011 LANS LLC, as Operator of | ||
2004 | 4 | * Los Alamos National Laboratory. | ||
2005 | 5 | * Copyright (c) 2011 UChicago Argonne LLC, as Operator of Argonne | ||
2006 | 6 | * National Laboratory. | ||
2007 | 7 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
2008 | 8 | * in file LICENSE that is included with this distribution. | ||
2009 | 9 | \*************************************************************************/ | ||
2010 | 10 | |||
2011 | 11 | /* | ||
2012 | 12 | * Author Jeffrey O. Hill | ||
2013 | 13 | * johill@lanl.gov | ||
2014 | 14 | */ | ||
2015 | 15 | |||
2016 | 16 | #ifndef epicsAtomicMS_h | ||
2017 | 17 | #define epicsAtomicMS_h | ||
2018 | 18 | |||
2019 | 19 | #include "epicsAssert.h" | ||
2020 | 20 | |||
2021 | 21 | #ifdef __cplusplus | ||
2022 | 22 | extern "C" { | ||
2023 | 23 | #endif /* __cplusplus */ | ||
2024 | 24 | |||
2025 | 25 | #ifndef EPICS_ATOMIC_INCR_INTT | ||
2026 | 26 | #define EPICS_ATOMIC_INCR_INTT | ||
2027 | 27 | EPICS_ATOMIC_INLINE int epicsAtomicIncrIntT ( int * pTarget ) | ||
2028 | 28 | { | ||
2029 | 29 | STATIC_ASSERT ( sizeof ( MS_LONG ) == sizeof ( int ) ); | ||
2030 | 30 | MS_LONG * const pTarg = ( MS_LONG * ) pTarget; | ||
2031 | 31 | return MS_InterlockedIncrement ( pTarg ); | ||
2032 | 32 | } | ||
2033 | 33 | #endif | ||
2034 | 34 | |||
2035 | 35 | #ifndef EPICS_ATOMIC_DECR_INTT | ||
2036 | 36 | #define EPICS_ATOMIC_DECR_INTT | ||
2037 | 37 | EPICS_ATOMIC_INLINE int epicsAtomicDecrIntT ( int * pTarget ) | ||
2038 | 38 | { | ||
2039 | 39 | STATIC_ASSERT ( sizeof ( MS_LONG ) == sizeof ( int ) ); | ||
2040 | 40 | MS_LONG * const pTarg = ( MS_LONG * ) ( pTarget ); | ||
2041 | 41 | return MS_InterlockedDecrement ( pTarg ); | ||
2042 | 42 | } | ||
2043 | 43 | #endif | ||
2044 | 44 | |||
2045 | 45 | #ifndef EPICS_ATOMIC_ADD_INTT | ||
2046 | 46 | #define EPICS_ATOMIC_ADD_INTT | ||
2047 | 47 | EPICS_ATOMIC_INLINE int epicsAtomicAddIntT ( int * pTarget, int delta ) | ||
2048 | 48 | { | ||
2049 | 49 | STATIC_ASSERT ( sizeof ( MS_LONG ) == sizeof ( int ) ); | ||
2050 | 50 | MS_LONG * const pTarg = ( MS_LONG * ) ( pTarget ); | ||
2051 | 51 | /* we dont use InterlockedAdd because only latest windows is supported */ | ||
2052 | 52 | return delta + ( int ) MS_InterlockedExchangeAdd ( pTarg, | ||
2053 | 53 | ( MS_LONG ) delta ); | ||
2054 | 54 | } | ||
2055 | 55 | #endif | ||
2056 | 56 | |||
2057 | 57 | #ifndef EPICS_ATOMIC_CAS_INTT | ||
2058 | 58 | #define EPICS_ATOMIC_CAS_INTT | ||
2059 | 59 | EPICS_ATOMIC_INLINE int epicsAtomicCmpAndSwapIntT ( int * pTarget, | ||
2060 | 60 | int oldVal, int newVal ) | ||
2061 | 61 | { | ||
2062 | 62 | STATIC_ASSERT ( sizeof ( MS_LONG ) == sizeof ( int ) ); | ||
2063 | 63 | MS_LONG * const pTarg = ( MS_LONG * ) ( pTarget ); | ||
2064 | 64 | return (int) MS_InterlockedCompareExchange ( pTarg, | ||
2065 | 65 | (MS_LONG) newVal, (MS_LONG) oldVal ); | ||
2066 | 66 | } | ||
2067 | 67 | #endif | ||
2068 | 68 | |||
2069 | 69 | #if ! defined ( MS_ATOMIC_64 ) | ||
2070 | 70 | |||
2071 | 71 | /* | ||
2072 | 72 | * necessary for next three functions | ||
2073 | 73 | * | ||
2074 | 74 | * looking at the MS documentation it appears that they will | ||
2075 | 75 | * keep type long the same size as an int on 64 bit builds | ||
2076 | 76 | */ | ||
2077 | 77 | STATIC_ASSERT ( sizeof ( MS_LONG ) == sizeof ( size_t ) ); | ||
2078 | 78 | |||
2079 | 79 | #ifndef EPICS_ATOMIC_INCR_SIZET | ||
2080 | 80 | #define EPICS_ATOMIC_INCR_SIZET | ||
2081 | 81 | EPICS_ATOMIC_INLINE size_t epicsAtomicIncrSizeT ( size_t * pTarget ) | ||
2082 | 82 | { | ||
2083 | 83 | MS_LONG * const pTarg = ( MS_LONG * ) pTarget; | ||
2084 | 84 | return MS_InterlockedIncrement ( pTarg ); | ||
2085 | 85 | } | ||
2086 | 86 | #endif | ||
2087 | 87 | |||
2088 | 88 | #ifndef EPICS_ATOMIC_DECR_SIZET | ||
2089 | 89 | #define EPICS_ATOMIC_DECR_SIZET | ||
2090 | 90 | EPICS_ATOMIC_INLINE size_t epicsAtomicDecrSizeT ( size_t * pTarget ) | ||
2091 | 91 | { | ||
2092 | 92 | MS_LONG * const pTarg = ( MS_LONG * ) ( pTarget ); | ||
2093 | 93 | return MS_InterlockedDecrement ( pTarg ); | ||
2094 | 94 | } | ||
2095 | 95 | #endif | ||
2096 | 96 | |||
2097 | 97 | #ifndef EPICS_ATOMIC_ADD_SIZET | ||
2098 | 98 | #define EPICS_ATOMIC_ADD_SIZET | ||
2099 | 99 | EPICS_ATOMIC_INLINE size_t epicsAtomicAddSizeT ( size_t * pTarget, | ||
2100 | 100 | size_t delta ) | ||
2101 | 101 | { | ||
2102 | 102 | MS_LONG * const pTarg = ( MS_LONG * ) ( pTarget ); | ||
2103 | 103 | /* we dont use InterlockedAdd because only latest windows is supported */ | ||
2104 | 104 | return delta + ( size_t ) MS_InterlockedExchangeAdd ( pTarg, | ||
2105 | 105 | ( MS_LONG ) delta ); | ||
2106 | 106 | } | ||
2107 | 107 | #endif | ||
2108 | 108 | |||
2109 | 109 | #ifndef EPICS_ATOMIC_SUB_SIZET | ||
2110 | 110 | #define EPICS_ATOMIC_SUB_SIZET | ||
2111 | 111 | EPICS_ATOMIC_INLINE size_t epicsAtomicSubSizeT ( size_t * pTarget, size_t delta ) | ||
2112 | 112 | { | ||
2113 | 113 | MS_LONG * const pTarg = ( MS_LONG * ) ( pTarget ); | ||
2114 | 114 | MS_LONG ldelta = (MS_LONG) delta; | ||
2115 | 115 | /* we dont use InterlockedAdd because only latest windows is supported */ | ||
2116 | 116 | return ( ( size_t ) MS_InterlockedExchangeAdd ( pTarg, -ldelta ) ) - delta; | ||
2117 | 117 | } | ||
2118 | 118 | #endif | ||
2119 | 119 | |||
2120 | 120 | #ifndef EPICS_ATOMIC_CAS_SIZET | ||
2121 | 121 | #define EPICS_ATOMIC_CAS_SIZET | ||
2122 | 122 | EPICS_ATOMIC_INLINE size_t epicsAtomicCmpAndSwapSizeT ( | ||
2123 | 123 | size_t * pTarget, | ||
2124 | 124 | size_t oldVal, size_t newVal ) | ||
2125 | 125 | { | ||
2126 | 126 | MS_LONG * const pTarg = ( MS_LONG * ) ( pTarget ); | ||
2127 | 127 | return (size_t) MS_InterlockedCompareExchange ( pTarg, | ||
2128 | 128 | (MS_LONG) newVal, (MS_LONG) oldVal ); | ||
2129 | 129 | } | ||
2130 | 130 | #endif | ||
2131 | 131 | |||
2132 | 132 | #ifndef EPICS_ATOMIC_CAS_PTRT | ||
2133 | 133 | #define EPICS_ATOMIC_CAS_PTRT | ||
2134 | 134 | EPICS_ATOMIC_INLINE EpicsAtomicPtrT epicsAtomicCmpAndSwapPtrT ( | ||
2135 | 135 | EpicsAtomicPtrT * pTarget, | ||
2136 | 136 | EpicsAtomicPtrT oldVal, EpicsAtomicPtrT newVal ) | ||
2137 | 137 | { | ||
2138 | 138 | MS_LONG * const pTarg = ( MS_LONG * ) ( pTarget ); | ||
2139 | 139 | return (EpicsAtomicPtrT) MS_InterlockedCompareExchange ( pTarg, | ||
2140 | 140 | (MS_LONG) newVal, (MS_LONG) oldVal ); | ||
2141 | 141 | } | ||
2142 | 142 | #endif | ||
2143 | 143 | |||
2144 | 144 | #else /* ! MS_ATOMIC_64 */ | ||
2145 | 145 | |||
2146 | 146 | /* | ||
2147 | 147 | * necessary for next three functions | ||
2148 | 148 | */ | ||
2149 | 149 | STATIC_ASSERT ( sizeof ( MS_LONGLONG ) == sizeof ( size_t ) ); | ||
2150 | 150 | |||
2151 | 151 | #ifndef EPICS_ATOMIC_INCR_SIZET | ||
2152 | 152 | #define EPICS_ATOMIC_INCR_SIZET | ||
2153 | 153 | EPICS_ATOMIC_INLINE size_t epicsAtomicIncrSizeT ( size_t * pTarget ) | ||
2154 | 154 | { | ||
2155 | 155 | MS_LONGLONG * const pTarg = ( MS_LONGLONG * ) pTarget; | ||
2156 | 156 | return ( size_t ) MS_InterlockedIncrement64 ( pTarg ); | ||
2157 | 157 | } | ||
2158 | 158 | #endif | ||
2159 | 159 | |||
2160 | 160 | #ifndef EPICS_ATOMIC_DECR_SIZET | ||
2161 | 161 | #define EPICS_ATOMIC_DECR_SIZET | ||
2162 | 162 | EPICS_ATOMIC_INLINE size_t epicsAtomicDecrSizeT ( size_t * pTarget ) | ||
2163 | 163 | { | ||
2164 | 164 | MS_LONGLONG * const pTarg = ( MS_LONGLONG * ) ( pTarget ); | ||
2165 | 165 | return ( size_t ) MS_InterlockedDecrement64 ( pTarg ); | ||
2166 | 166 | } | ||
2167 | 167 | #endif | ||
2168 | 168 | |||
2169 | 169 | #ifndef EPICS_ATOMIC_ADD_SIZET | ||
2170 | 170 | #define EPICS_ATOMIC_ADD_SIZET | ||
2171 | 171 | EPICS_ATOMIC_INLINE size_t epicsAtomicAddSizeT ( size_t * pTarget, size_t delta ) | ||
2172 | 172 | { | ||
2173 | 173 | MS_LONGLONG * const pTarg = ( MS_LONGLONG * ) ( pTarget ); | ||
2174 | 174 | /* we dont use InterlockedAdd64 because only latest windows is supported */ | ||
2175 | 175 | return delta + ( size_t ) MS_InterlockedExchangeAdd64 ( pTarg, | ||
2176 | 176 | ( MS_LONGLONG ) delta ); | ||
2177 | 177 | } | ||
2178 | 178 | #endif | ||
2179 | 179 | |||
2180 | 180 | #ifndef EPICS_ATOMIC_SUB_SIZET | ||
2181 | 181 | #define EPICS_ATOMIC_SUB_SIZET | ||
2182 | 182 | EPICS_ATOMIC_INLINE size_t epicsAtomicSubSizeT ( size_t * pTarget, size_t delta ) | ||
2183 | 183 | { | ||
2184 | 184 | MS_LONGLONG * const pTarg = ( MS_LONGLONG * ) ( pTarget ); | ||
2185 | 185 | MS_LONGLONG ldelta = (MS_LONGLONG) delta; | ||
2186 | 186 | /* we dont use InterlockedAdd64 because only latest windows is supported */ | ||
2187 | 187 | return (( size_t ) MS_InterlockedExchangeAdd64 ( pTarg, -ldelta )) - delta; | ||
2188 | 188 | } | ||
2189 | 189 | #endif | ||
2190 | 190 | |||
2191 | 191 | #ifndef EPICS_ATOMIC_CAS_SIZET | ||
2192 | 192 | #define EPICS_ATOMIC_CAS_SIZET | ||
2193 | 193 | EPICS_ATOMIC_INLINE size_t epicsAtomicCmpAndSwapSizeT ( size_t * pTarget, | ||
2194 | 194 | size_t oldVal, size_t newVal ) | ||
2195 | 195 | { | ||
2196 | 196 | MS_LONGLONG * const pTarg = ( MS_LONGLONG * ) ( pTarget ); | ||
2197 | 197 | return (size_t) MS_InterlockedCompareExchange64 ( pTarg, | ||
2198 | 198 | (MS_LONGLONG) newVal, | ||
2199 | 199 | (MS_LONGLONG) oldVal ); | ||
2200 | 200 | } | ||
2201 | 201 | #endif | ||
2202 | 202 | |||
2203 | 203 | #ifndef EPICS_ATOMIC_CAS_PTRT | ||
2204 | 204 | #define EPICS_ATOMIC_CAS_PTRT | ||
2205 | 205 | EPICS_ATOMIC_INLINE EpicsAtomicPtrT epicsAtomicCmpAndSwapPtrT ( | ||
2206 | 206 | EpicsAtomicPtrT * pTarget, | ||
2207 | 207 | EpicsAtomicPtrT oldVal, EpicsAtomicPtrT newVal ) | ||
2208 | 208 | { | ||
2209 | 209 | MS_LONGLONG * const pTarg = ( MS_LONGLONG * ) ( pTarget ); | ||
2210 | 210 | return (EpicsAtomicPtrT) MS_InterlockedCompareExchange64 ( pTarg, | ||
2211 | 211 | (MS_LONGLONG) newVal, (MS_LONGLONG) oldVal ); | ||
2212 | 212 | } | ||
2213 | 213 | #endif | ||
2214 | 214 | |||
2215 | 215 | #endif /* ! MS_ATOMIC_64 */ | ||
2216 | 216 | |||
2217 | 217 | #ifdef __cplusplus | ||
2218 | 218 | } /* end of extern "C" */ | ||
2219 | 219 | #endif /* __cplusplus */ | ||
2220 | 220 | |||
2221 | 221 | #endif /* ifdef epicsAtomicMS_h */ | ||
2222 | 222 | |||
2223 | 0 | 223 | ||
2224 | === added file 'src/libCom/osi/os/WIN32/epicsAtomicOSD.cpp' | |||
2225 | --- src/libCom/osi/os/WIN32/epicsAtomicOSD.cpp 1970-01-01 00:00:00 +0000 | |||
2226 | +++ src/libCom/osi/os/WIN32/epicsAtomicOSD.cpp 2011-08-31 22:29:24 +0000 | |||
2227 | @@ -0,0 +1,22 @@ | |||
2228 | 1 | |||
2229 | 2 | /*************************************************************************\ | ||
2230 | 3 | * Copyright (c) 2011 LANS LLC, as Operator of | ||
2231 | 4 | * Los Alamos National Laboratory. | ||
2232 | 5 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
2233 | 6 | * in file LICENSE that is included with this distribution. | ||
2234 | 7 | \*************************************************************************/ | ||
2235 | 8 | |||
2236 | 9 | /* | ||
2237 | 10 | * Author Jeffrey O. Hill | ||
2238 | 11 | * johill@lanl.gov | ||
2239 | 12 | */ | ||
2240 | 13 | |||
2241 | 14 | #define epicsExportSharedSymbols | ||
2242 | 15 | #include "epicsAtomic.h" | ||
2243 | 16 | |||
2244 | 17 | // if the compiler is unable to inline then instantiate out-of-line | ||
2245 | 18 | #ifndef EPICS_ATOMIC_INLINE | ||
2246 | 19 | #define EPICS_ATOMIC_INLINE | ||
2247 | 20 | #include "epicsAtomic.h" | ||
2248 | 21 | #endif | ||
2249 | 22 | |||
2250 | 0 | 23 | ||
2251 | === added file 'src/libCom/osi/os/WIN32/epicsAtomicOSD.h' | |||
2252 | --- src/libCom/osi/os/WIN32/epicsAtomicOSD.h 1970-01-01 00:00:00 +0000 | |||
2253 | +++ src/libCom/osi/os/WIN32/epicsAtomicOSD.h 2011-08-31 22:29:24 +0000 | |||
2254 | @@ -0,0 +1,49 @@ | |||
2255 | 1 | |||
2256 | 2 | /*************************************************************************\ | ||
2257 | 3 | * Copyright (c) 2011 LANS LLC, as Operator of | ||
2258 | 4 | * Los Alamos National Laboratory. | ||
2259 | 5 | * Copyright (c) 2011 UChicago Argonne LLC, as Operator of Argonne | ||
2260 | 6 | * National Laboratory. | ||
2261 | 7 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
2262 | 8 | * in file LICENSE that is included with this distribution. | ||
2263 | 9 | \*************************************************************************/ | ||
2264 | 10 | |||
2265 | 11 | /* | ||
2266 | 12 | * Author Jeffrey O. Hill | ||
2267 | 13 | * johill@lanl.gov | ||
2268 | 14 | */ | ||
2269 | 15 | |||
2270 | 16 | #ifndef epicsAtomicOSD_h | ||
2271 | 17 | #define epicsAtomicOSD_h | ||
2272 | 18 | |||
2273 | 19 | #define VC_EXTRALEAN | ||
2274 | 20 | #define STRICT | ||
2275 | 21 | #include "windows.h" | ||
2276 | 22 | |||
2277 | 23 | #if defined ( _WIN64 ) | ||
2278 | 24 | # define MS_ATOMIC_64 | ||
2279 | 25 | #endif | ||
2280 | 26 | |||
2281 | 27 | #define MS_LONG LONG | ||
2282 | 28 | #define MS_InterlockedExchange InterlockedExchange | ||
2283 | 29 | #define MS_InterlockedCompareExchange InterlockedCompareExchange | ||
2284 | 30 | #define MS_InterlockedIncrement InterlockedIncrement | ||
2285 | 31 | #define MS_InterlockedDecrement InterlockedDecrement | ||
2286 | 32 | #define MS_InterlockedExchange InterlockedExchange | ||
2287 | 33 | #define MS_InterlockedExchangeAdd InterlockedExchangeAdd | ||
2288 | 34 | #if defined ( MS_ATOMIC_64 ) | ||
2289 | 35 | # define MS_LONGLONG LONGLONG | ||
2290 | 36 | # define MS_InterlockedIncrement64 InterlockedIncrement64 | ||
2291 | 37 | # define MS_InterlockedDecrement64 InterlockedDecrement64 | ||
2292 | 38 | # define MS_InterlockedExchange64 InterlockedExchange64 | ||
2293 | 39 | # define MS_InterlockedExchangeAdd64 InterlockedExchangeAdd64 | ||
2294 | 40 | # define MS_InterlockedCompareExchange InterlockedCompareExchange64 | ||
2295 | 41 | #endif | ||
2296 | 42 | |||
2297 | 43 | #ifdef EPICS_ATOMIC_INLINE | ||
2298 | 44 | # include "epicsAtomicMS.h" | ||
2299 | 45 | # include "epicsAtomicDefault.h" | ||
2300 | 46 | #endif | ||
2301 | 47 | |||
2302 | 48 | #endif /* epicsAtomicOSD_h */ | ||
2303 | 49 | |||
2304 | 0 | 50 | ||
2305 | === modified file 'src/libCom/osi/os/WIN32/osdThread.c' | |||
2306 | --- src/libCom/osi/os/WIN32/osdThread.c 2011-02-11 22:33:58 +0000 | |||
2307 | +++ src/libCom/osi/os/WIN32/osdThread.c 2011-08-31 22:29:24 +0000 | |||
2308 | @@ -1008,41 +1008,6 @@ | |||
2309 | 1008 | } | 1008 | } |
2310 | 1009 | 1009 | ||
2311 | 1010 | /* | 1010 | /* |
2312 | 1011 | * epicsThreadOnce () | ||
2313 | 1012 | */ | ||
2314 | 1013 | epicsShareFunc void epicsShareAPI epicsThreadOnce ( | ||
2315 | 1014 | epicsThreadOnceId *id, void (*func)(void *), void *arg ) | ||
2316 | 1015 | { | ||
2317 | 1016 | static struct epicsThreadOSD threadOnceComplete; | ||
2318 | 1017 | #define EPICS_THREAD_ONCE_DONE & threadOnceComplete | ||
2319 | 1018 | win32ThreadGlobal * pGbl = fetchWin32ThreadGlobal (); | ||
2320 | 1019 | |||
2321 | 1020 | assert ( pGbl ); | ||
2322 | 1021 | |||
2323 | 1022 | EnterCriticalSection ( & pGbl->mutex ); | ||
2324 | 1023 | |||
2325 | 1024 | if ( *id != EPICS_THREAD_ONCE_DONE ) { | ||
2326 | 1025 | if ( *id == EPICS_THREAD_ONCE_INIT ) { /* first call */ | ||
2327 | 1026 | *id = epicsThreadGetIdSelf(); /* mark active */ | ||
2328 | 1027 | LeaveCriticalSection ( & pGbl->mutex ); | ||
2329 | 1028 | func ( arg ); | ||
2330 | 1029 | EnterCriticalSection ( & pGbl->mutex ); | ||
2331 | 1030 | *id = EPICS_THREAD_ONCE_DONE; /* mark done */ | ||
2332 | 1031 | } else if ( *id == epicsThreadGetIdSelf() ) { | ||
2333 | 1032 | LeaveCriticalSection ( & pGbl->mutex ); | ||
2334 | 1033 | cantProceed( "Recursive epicsThreadOnce() initialization\n" ); | ||
2335 | 1034 | } else | ||
2336 | 1035 | while ( *id != EPICS_THREAD_ONCE_DONE ) { | ||
2337 | 1036 | /* Another thread is in the above func(arg) call. */ | ||
2338 | 1037 | LeaveCriticalSection ( & pGbl->mutex ); | ||
2339 | 1038 | epicsThreadSleep ( epicsThreadSleepQuantum() ); | ||
2340 | 1039 | EnterCriticalSection ( & pGbl->mutex ); | ||
2341 | 1040 | } | ||
2342 | 1041 | } | ||
2343 | 1042 | LeaveCriticalSection ( & pGbl->mutex ); | ||
2344 | 1043 | } | ||
2345 | 1044 | |||
2346 | 1045 | /* | ||
2347 | 1046 | * epicsThreadPrivateCreate () | 1011 | * epicsThreadPrivateCreate () |
2348 | 1047 | */ | 1012 | */ |
2349 | 1048 | epicsShareFunc epicsThreadPrivateId epicsShareAPI epicsThreadPrivateCreate () | 1013 | epicsShareFunc epicsThreadPrivateId epicsShareAPI epicsThreadPrivateCreate () |
2350 | 1049 | 1014 | ||
2351 | === added file 'src/libCom/osi/os/posix/epicsAtomicOSD.cpp' | |||
2352 | --- src/libCom/osi/os/posix/epicsAtomicOSD.cpp 1970-01-01 00:00:00 +0000 | |||
2353 | +++ src/libCom/osi/os/posix/epicsAtomicOSD.cpp 2011-08-31 22:29:24 +0000 | |||
2354 | @@ -0,0 +1,108 @@ | |||
2355 | 1 | |||
2356 | 2 | /*************************************************************************\ | ||
2357 | 3 | * Copyright (c) 2011 LANS LLC, as Operator of | ||
2358 | 4 | * Los Alamos National Laboratory. | ||
2359 | 5 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
2360 | 6 | * in file LICENSE that is included with this distribution. | ||
2361 | 7 | \*************************************************************************/ | ||
2362 | 8 | |||
2363 | 9 | /* | ||
2364 | 10 | * Author Jeffrey O. Hill | ||
2365 | 11 | * johill@lanl.gov | ||
2366 | 12 | */ | ||
2367 | 13 | |||
2368 | 14 | #define epicsExportSharedSymbols | ||
2369 | 15 | #include "epicsAtomic.h" | ||
2370 | 16 | |||
2371 | 17 | // if the compiler is unable to inline then instantiate out-of-line | ||
2372 | 18 | #ifndef EPICS_ATOMIC_INLINE | ||
2373 | 19 | #define EPICS_ATOMIC_INLINE | ||
2374 | 20 | #include "epicsAtomic.h" | ||
2375 | 21 | #endif | ||
2376 | 22 | |||
2377 | 23 | /* Authors: Jeffrey O. Hill */ | ||
2378 | 24 | #include <errno.h> | ||
2379 | 25 | #include <unistd.h> | ||
2380 | 26 | #include <pthread.h> | ||
2381 | 27 | |||
2382 | 28 | #define epicsExportSharedSymbols | ||
2383 | 29 | #include "epicsAssert.h" | ||
2384 | 30 | |||
2385 | 31 | // if the compiler is unable to inline then instantiate out-of-line | ||
2386 | 32 | #ifndef EPICS_ATOMIC_INLINE | ||
2387 | 33 | #define EPICS_ATOMIC_INLINE | ||
2388 | 34 | #include "epicsAtomic.h" | ||
2389 | 35 | #endif | ||
2390 | 36 | |||
2391 | 37 | #ifndef EPICS_ATOMIC_LOCK | ||
2392 | 38 | |||
2393 | 39 | /* | ||
2394 | 40 | * Slow, but probably correct on all systems. | ||
2395 | 41 | * Useful only if something more efficent isnt | ||
2396 | 42 | * provided based on knowledge of the compiler | ||
2397 | 43 | * or OS | ||
2398 | 44 | * | ||
2399 | 45 | * A statically initialized pthread mutex doesnt | ||
2400 | 46 | * need to be destroyed | ||
2401 | 47 | * | ||
2402 | 48 | * !!!!! | ||
2403 | 49 | * !!!!! WARNING | ||
2404 | 50 | * !!!!! | ||
2405 | 51 | * !!!!! Do not use this implementation on systems where | ||
2406 | 52 | * !!!!! code runs at interrupt context. If so, then | ||
2407 | 53 | * !!!!! an implementation must be provided that is based | ||
2408 | 54 | * !!!!! on a compiler intrinsic or an interrpt lock and or | ||
2409 | 55 | * !!!!! a spin lock primitive | ||
2410 | 56 | * !!!!! | ||
2411 | 57 | */ | ||
2412 | 58 | static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; | ||
2413 | 59 | |||
2414 | 60 | void epicsAtomicLock ( EpicsAtomicLockKey * ) | ||
2415 | 61 | { | ||
2416 | 62 | unsigned countDown = 1000u; | ||
2417 | 63 | int status; | ||
2418 | 64 | while ( true ) { | ||
2419 | 65 | status = pthread_mutex_lock ( & mutex ); | ||
2420 | 66 | if ( status == 0 ) return; | ||
2421 | 67 | assert ( status == EINTR ); | ||
2422 | 68 | static const useconds_t retryDelayUSec = 100000; | ||
2423 | 69 | usleep ( retryDelayUSec ); | ||
2424 | 70 | countDown--; | ||
2425 | 71 | assert ( countDown ); | ||
2426 | 72 | } | ||
2427 | 73 | } | ||
2428 | 74 | |||
2429 | 75 | void epicsAtomicUnlock ( EpicsAtomicLockKey * ) | ||
2430 | 76 | { | ||
2431 | 77 | const int status = pthread_mutex_unlock ( & mutex ); | ||
2432 | 78 | assert ( status == 0 ); | ||
2433 | 79 | } | ||
2434 | 80 | |||
2435 | 81 | #endif // ifndef EPICS_ATOMIC_LOCK | ||
2436 | 82 | |||
2437 | 83 | #ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER | ||
2438 | 84 | // Slow, but probably correct on all systems. | ||
2439 | 85 | // Useful only if something more efficent isnt | ||
2440 | 86 | // provided based on knowledge of the compiler | ||
2441 | 87 | // or OS | ||
2442 | 88 | void epicsAtomicReadMemoryBarrier () | ||
2443 | 89 | { | ||
2444 | 90 | EpicsAtomicLockKey key; | ||
2445 | 91 | epicsAtomicLock ( & key ); | ||
2446 | 92 | epicsAtomicUnlock ( & key ); | ||
2447 | 93 | } | ||
2448 | 94 | #endif | ||
2449 | 95 | |||
2450 | 96 | #ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER | ||
2451 | 97 | // Slow, but probably correct on all systems. | ||
2452 | 98 | // Useful only if something more efficent isnt | ||
2453 | 99 | // provided based on knowledge of the compiler | ||
2454 | 100 | // or OS | ||
2455 | 101 | void epicsAtomicWriteMemoryBarrier () | ||
2456 | 102 | { | ||
2457 | 103 | EpicsAtomicLockKey key; | ||
2458 | 104 | epicsAtomicLock ( & key ); | ||
2459 | 105 | epicsAtomicUnlock ( & key ); | ||
2460 | 106 | } | ||
2461 | 107 | #endif | ||
2462 | 108 | |||
2463 | 0 | 109 | ||
2464 | === added file 'src/libCom/osi/os/posix/epicsAtomicOSD.h' | |||
2465 | --- src/libCom/osi/os/posix/epicsAtomicOSD.h 1970-01-01 00:00:00 +0000 | |||
2466 | +++ src/libCom/osi/os/posix/epicsAtomicOSD.h 2011-08-31 22:29:24 +0000 | |||
2467 | @@ -0,0 +1,32 @@ | |||
2468 | 1 | |||
2469 | 2 | /*************************************************************************\ | ||
2470 | 3 | * Copyright (c) 2011 LANS LLC, as Operator of | ||
2471 | 4 | * Los Alamos National Laboratory. | ||
2472 | 5 | * Copyright (c) 2011 UChicago Argonne LLC, as Operator of Argonne | ||
2473 | 6 | * National Laboratory. | ||
2474 | 7 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
2475 | 8 | * in file LICENSE that is included with this distribution. | ||
2476 | 9 | \*************************************************************************/ | ||
2477 | 10 | |||
2478 | 11 | /* | ||
2479 | 12 | * Author Jeffrey O. Hill | ||
2480 | 13 | * johill@lanl.gov | ||
2481 | 14 | */ | ||
2482 | 15 | |||
2483 | 16 | #ifndef epicsAtomicOSD_h | ||
2484 | 17 | #define epicsAtomicOSD_h | ||
2485 | 18 | |||
2486 | 19 | struct EpicsAtomicLockKey {}; | ||
2487 | 20 | epicsShareFunc void epicsAtomicReadMemoryBarrier (); | ||
2488 | 21 | epicsShareFunc void epicsAtomicWriteMemoryBarrier (); | ||
2489 | 22 | epicsShareFunc void epicsAtomicLock ( struct EpicsAtomicLockKey * ); | ||
2490 | 23 | epicsShareFunc void epicsAtomicUnlock ( struct EpicsAtomicLockKey * ); | ||
2491 | 24 | |||
2492 | 25 | #ifdef EPICS_ATOMIC_INLINE | ||
2493 | 26 | |||
2494 | 27 | #include "epicsAtomicDefault.h" | ||
2495 | 28 | |||
2496 | 29 | #endif /* ifdef EPICS_ATOMIC_INLINE */ | ||
2497 | 30 | |||
2498 | 31 | #endif /* epicsAtomicOSD_h */ | ||
2499 | 32 | |||
2500 | 0 | 33 | ||
2501 | === modified file 'src/libCom/osi/os/posix/osdThread.c' | |||
2502 | --- src/libCom/osi/os/posix/osdThread.c 2010-05-14 22:26:54 +0000 | |||
2503 | +++ src/libCom/osi/os/posix/osdThread.c 2011-08-31 22:29:24 +0000 | |||
2504 | @@ -76,7 +76,6 @@ | |||
2505 | 76 | } epicsThreadOSD; | 76 | } epicsThreadOSD; |
2506 | 77 | 77 | ||
2507 | 78 | static pthread_key_t getpthreadInfo; | 78 | static pthread_key_t getpthreadInfo; |
2508 | 79 | static pthread_mutex_t onceLock; | ||
2509 | 80 | static pthread_mutex_t listLock; | 79 | static pthread_mutex_t listLock; |
2510 | 81 | static ELLLIST pthreadList = ELLLIST_INIT; | 80 | static ELLLIST pthreadList = ELLLIST_INIT; |
2511 | 82 | static commonAttr *pcommonAttr = 0; | 81 | static commonAttr *pcommonAttr = 0; |
2512 | @@ -207,8 +206,6 @@ | |||
2513 | 207 | int status; | 206 | int status; |
2514 | 208 | 207 | ||
2515 | 209 | pthread_key_create(&getpthreadInfo,0); | 208 | pthread_key_create(&getpthreadInfo,0); |
2516 | 210 | status = pthread_mutex_init(&onceLock,0); | ||
2517 | 211 | checkStatusQuit(status,"pthread_mutex_init","epicsThreadInit"); | ||
2518 | 212 | status = pthread_mutex_init(&listLock,0); | 209 | status = pthread_mutex_init(&listLock,0); |
2519 | 213 | checkStatusQuit(status,"pthread_mutex_init","epicsThreadInit"); | 210 | checkStatusQuit(status,"pthread_mutex_init","epicsThreadInit"); |
2520 | 214 | pcommonAttr = calloc(1,sizeof(commonAttr)); | 211 | pcommonAttr = calloc(1,sizeof(commonAttr)); |
2521 | @@ -321,47 +318,6 @@ | |||
2522 | 321 | #endif /*_POSIX_THREAD_ATTR_STACKSIZE*/ | 318 | #endif /*_POSIX_THREAD_ATTR_STACKSIZE*/ |
2523 | 322 | } | 319 | } |
2524 | 323 | 320 | ||
2525 | 324 | 321 | ||
2526 | 325 | epicsShareFunc void epicsShareAPI epicsThreadOnce(epicsThreadOnceId *id, void (*func)(void *), void *arg) | ||
2527 | 326 | { | ||
2528 | 327 | static struct epicsThreadOSD threadOnceComplete; | ||
2529 | 328 | #define EPICS_THREAD_ONCE_DONE &threadOnceComplete | ||
2530 | 329 | int status; | ||
2531 | 330 | |||
2532 | 331 | epicsThreadInit(); | ||
2533 | 332 | status = mutexLock(&onceLock); | ||
2534 | 333 | if(status) { | ||
2535 | 334 | fprintf(stderr,"epicsThreadOnce: pthread_mutex_lock returned %s.\n", | ||
2536 | 335 | strerror(status)); | ||
2537 | 336 | exit(-1); | ||
2538 | 337 | } | ||
2539 | 338 | |||
2540 | 339 | if (*id != EPICS_THREAD_ONCE_DONE) { | ||
2541 | 340 | if (*id == EPICS_THREAD_ONCE_INIT) { /* first call */ | ||
2542 | 341 | *id = epicsThreadGetIdSelf(); /* mark active */ | ||
2543 | 342 | status = pthread_mutex_unlock(&onceLock); | ||
2544 | 343 | checkStatusQuit(status,"pthread_mutex_unlock", "epicsThreadOnce"); | ||
2545 | 344 | func(arg); | ||
2546 | 345 | status = mutexLock(&onceLock); | ||
2547 | 346 | checkStatusQuit(status,"pthread_mutex_lock", "epicsThreadOnce"); | ||
2548 | 347 | *id = EPICS_THREAD_ONCE_DONE; /* mark done */ | ||
2549 | 348 | } else if (*id == epicsThreadGetIdSelf()) { | ||
2550 | 349 | status = pthread_mutex_unlock(&onceLock); | ||
2551 | 350 | checkStatusQuit(status,"pthread_mutex_unlock", "epicsThreadOnce"); | ||
2552 | 351 | cantProceed("Recursive epicsThreadOnce() initialization\n"); | ||
2553 | 352 | } else | ||
2554 | 353 | while (*id != EPICS_THREAD_ONCE_DONE) { | ||
2555 | 354 | /* Another thread is in the above func(arg) call. */ | ||
2556 | 355 | status = pthread_mutex_unlock(&onceLock); | ||
2557 | 356 | checkStatusQuit(status,"pthread_mutex_unlock", "epicsThreadOnce"); | ||
2558 | 357 | epicsThreadSleep(epicsThreadSleepQuantum()); | ||
2559 | 358 | status = mutexLock(&onceLock); | ||
2560 | 359 | checkStatusQuit(status,"pthread_mutex_lock", "epicsThreadOnce"); | ||
2561 | 360 | } | ||
2562 | 361 | } | ||
2563 | 362 | status = pthread_mutex_unlock(&onceLock); | ||
2564 | 363 | checkStatusQuit(status,"pthread_mutex_unlock","epicsThreadOnce"); | ||
2565 | 364 | } | ||
2566 | 365 | |||
2567 | 366 | epicsShareFunc epicsThreadId epicsShareAPI epicsThreadCreate(const char *name, | 322 | epicsShareFunc epicsThreadId epicsShareAPI epicsThreadCreate(const char *name, |
2568 | 367 | unsigned int priority, unsigned int stackSize, | 323 | unsigned int priority, unsigned int stackSize, |
2569 | 368 | EPICSTHREADFUNC funptr,void *parm) | 324 | EPICSTHREADFUNC funptr,void *parm) |
2570 | 369 | 325 | ||
2571 | === added file 'src/libCom/osi/os/solaris/epicsAtomicOSD.h' | |||
2572 | --- src/libCom/osi/os/solaris/epicsAtomicOSD.h 1970-01-01 00:00:00 +0000 | |||
2573 | +++ src/libCom/osi/os/solaris/epicsAtomicOSD.h 2011-08-31 22:29:24 +0000 | |||
2574 | @@ -0,0 +1,166 @@ | |||
2575 | 1 | |||
2576 | 2 | /*************************************************************************\ | ||
2577 | 3 | * Copyright (c) 2011 LANS LLC, as Operator of | ||
2578 | 4 | * Los Alamos National Laboratory. | ||
2579 | 5 | * Copyright (c) 2011 UChicago Argonne LLC, as Operator of Argonne | ||
2580 | 6 | * National Laboratory. | ||
2581 | 7 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
2582 | 8 | * in file LICENSE that is included with this distribution. | ||
2583 | 9 | \*************************************************************************/ | ||
2584 | 10 | |||
2585 | 11 | /* | ||
2586 | 12 | * Author Jeffrey O. Hill | ||
2587 | 13 | * johill@lanl.gov | ||
2588 | 14 | */ | ||
2589 | 15 | |||
2590 | 16 | #ifndef epicsAtomicOSD_h | ||
2591 | 17 | #define epicsAtomicOSD_h | ||
2592 | 18 | |||
2593 | 19 | #if defined ( EPICS_ATOMIC_INLINE ) | ||
2594 | 20 | |||
2595 | 21 | /* | ||
2596 | 22 | * atomic.h exists only in Solaris 10 or higher | ||
2597 | 23 | */ | ||
2598 | 24 | #if defined ( __SunOS_5_10 ) | ||
2599 | 25 | |||
2600 | 26 | #include <atomic.h> | ||
2601 | 27 | |||
2602 | 28 | #ifdef __cplusplus | ||
2603 | 29 | extern "C" { | ||
2604 | 30 | #endif /* __cplusplus */ | ||
2605 | 31 | |||
2606 | 32 | #ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER | ||
2607 | 33 | #define EPICS_ATOMIC_READ_MEMORY_BARRIER | ||
2608 | 34 | EPICS_ATOMIC_INLINE int epicsAtomicReadMemoryBarrier () | ||
2609 | 35 | { | ||
2610 | 36 | membar_consumer (); | ||
2611 | 37 | } | ||
2612 | 38 | #endif | ||
2613 | 39 | |||
2614 | 40 | #ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER | ||
2615 | 41 | #define EPICS_ATOMIC_WRITE_MEMORY_BARRIER | ||
2616 | 42 | EPICS_ATOMIC_INLINE int epicsAtomicWriteMemoryBarrier () | ||
2617 | 43 | { | ||
2618 | 44 | membar_producer (); | ||
2619 | 45 | } | ||
2620 | 46 | #endif | ||
2621 | 47 | |||
2622 | 48 | #ifndef EPICS_ATOMIC_CAS_INTT | ||
2623 | 49 | #define EPICS_ATOMIC_CAS_INTT | ||
2624 | 50 | EPICS_ATOMIC_INLINE int epicsAtomicCmpAndSwapIntT ( int * pTarget, | ||
2625 | 51 | int oldVal, int newVal ) | ||
2626 | 52 | { | ||
2627 | 53 | STATIC_ASSERT ( sizeof ( int ) == sizeof ( unsigned ) ); | ||
2628 | 54 | return ( int ) atomic_cas_uint ( pTarget, ( unsigned ) oldVal, | ||
2629 | 55 | ( unsigned ) newVal ); | ||
2630 | 56 | } | ||
2631 | 57 | #endif | ||
2632 | 58 | |||
2633 | 59 | #ifndef EPICS_ATOMIC_CAS_SIZET | ||
2634 | 60 | #define EPICS_ATOMIC_CAS_SIZET | ||
2635 | 61 | EPICS_ATOMIC_INLINE EpicsAtomicPtrT epicsAtomicCmpAndSwapSizeT ( | ||
2636 | 62 | size_t * pTarget, | ||
2637 | 63 | size_t oldVal, size_t newVal ) | ||
2638 | 64 | { | ||
2639 | 65 | STATIC_ASSERT ( sizeof ( void * ) == sizeof ( size_t ) ); | ||
2640 | 66 | void ** ppPtr = (void **) pTarget; | ||
2641 | 67 | return ( size_t ) atomic_cas_ptr ( ppPtr, ( void * )oldVal, ( void * )newVal ); | ||
2642 | 68 | } | ||
2643 | 69 | #endif | ||
2644 | 70 | |||
2645 | 71 | #ifndef EPICS_ATOMIC_CAS_PTRT | ||
2646 | 72 | #define EPICS_ATOMIC_CAS_PTRT | ||
2647 | 73 | EPICS_ATOMIC_INLINE EpicsAtomicPtrT epicsAtomicCmpAndSwapPtrT ( | ||
2648 | 74 | EpicsAtomicPtrT * pTarget, | ||
2649 | 75 | EpicsAtomicPtrT oldVal, | ||
2650 | 76 | EpicsAtomicPtrT newVal ) | ||
2651 | 77 | { | ||
2652 | 78 | return atomic_cas_ptr ( pTarget, oldVal, newVal ); | ||
2653 | 79 | } | ||
2654 | 80 | #endif | ||
2655 | 81 | |||
2656 | 82 | #ifndef EPICS_ATOMIC_INCR_INTT | ||
2657 | 83 | #define EPICS_ATOMIC_INCR_INTT | ||
2658 | 84 | EPICS_ATOMIC_INLINE int epicsAtomicIncrIntT ( int * pTarget ) | ||
2659 | 85 | { | ||
2660 | 86 | STATIC_ASSERT ( sizeof ( unsigned ) == sizeof ( int ) ); | ||
2661 | 87 | unsigned * const pTarg = ( unsigned * ) ( pTarget ); | ||
2662 | 88 | return ( int ) atomic_inc_uint_nv ( pTarg ); | ||
2663 | 89 | } | ||
2664 | 90 | #endif | ||
2665 | 91 | |||
2666 | 92 | #ifndef EPICS_ATOMIC_INCR_SIZET | ||
2667 | 93 | #define EPICS_ATOMIC_INCR_SIZET | ||
2668 | 94 | EPICS_ATOMIC_INLINE size_t epicsAtomicIncrSizeT ( size_t * pTarget ) | ||
2669 | 95 | { | ||
2670 | 96 | STATIC_ASSERT ( sizeof ( void * ) == sizeof ( size_t ) ); | ||
2671 | 97 | void ** const ppTarg = ( void ** ) ( pTarget ); | ||
2672 | 98 | return ( size_t ) atomic_inc_ptr_nv ( ppTarg ); | ||
2673 | 99 | } | ||
2674 | 100 | #endif | ||
2675 | 101 | |||
2676 | 102 | #ifndef EPICS_ATOMIC_DECR_INTT | ||
2677 | 103 | #define EPICS_ATOMIC_DECR_INTT | ||
2678 | 104 | EPICS_ATOMIC_INLINE int epicsAtomicDecrIntT ( int * pTarget ) | ||
2679 | 105 | { | ||
2680 | 106 | STATIC_ASSERT ( sizeof ( unsigned ) == sizeof ( int ) ); | ||
2681 | 107 | unsigned * const pTarg = ( unsigned * ) ( pTarget ); | ||
2682 | 108 | return ( int ) atomic_dec_uint_nv ( pTarg ); | ||
2683 | 109 | } | ||
2684 | 110 | #endif | ||
2685 | 111 | |||
2686 | 112 | #ifndef EPICS_ATOMIC_DECR_SIZET | ||
2687 | 113 | #define EPICS_ATOMIC_DECR_SIZET | ||
2688 | 114 | EPICS_ATOMIC_INLINE size_t epicsAtomicDecrSizeT ( size_t * pTarget ) | ||
2689 | 115 | { | ||
2690 | 116 | STATIC_ASSERT ( sizeof ( void * ) == sizeof ( size_t ) ); | ||
2691 | 117 | void ** const pTarg = ( void ** ) ( pTarget ); | ||
2692 | 118 | return ( size_t ) atomic_dec_ptr_nv ( pTarg ); | ||
2693 | 119 | } | ||
2694 | 120 | #endif | ||
2695 | 121 | |||
2696 | 122 | #ifndef EPICS_ATOMIC_ADD_INTT | ||
2697 | 123 | #define EPICS_ATOMIC_ADD_INTT | ||
2698 | 124 | EPICS_ATOMIC_INLINE int epicsAtomicAddIntT ( int * pTarget, int delta ) | ||
2699 | 125 | { | ||
2700 | 126 | STATIC_ASSERT ( sizeof ( unsigned ) == sizeof ( int ) ); | ||
2701 | 127 | unsigned * const pTarg = ( unsigned * ) ( pTarget ); | ||
2702 | 128 | return ( int ) atomic_add_int_nv ( pTarg, delta ); | ||
2703 | 129 | } | ||
2704 | 130 | #endif | ||
2705 | 131 | |||
2706 | 132 | #ifndef EPICS_ATOMIC_ADD_SIZET | ||
2707 | 133 | #define EPICS_ATOMIC_ADD_SIZET | ||
2708 | 134 | EPICS_ATOMIC_INLINE size_t epicsAtomicAddSizeT ( size_t * pTarget, | ||
2709 | 135 | size_t delta ) | ||
2710 | 136 | { | ||
2711 | 137 | STATIC_ASSERT ( sizeof ( void * ) == sizeof ( size_t ) ); | ||
2712 | 138 | void ** const pTarg = ( void ** ) ( pTarget ); | ||
2713 | 139 | return ( size_t ) atomic_add_ptr_nv ( pTarg, ( ssize_t ) delta ); | ||
2714 | 140 | } | ||
2715 | 141 | #endif | ||
2716 | 142 | |||
2717 | 143 | #ifndef EPICS_ATOMIC_SUB_SIZET | ||
2718 | 144 | #define EPICS_ATOMIC_SUB_SIZET | ||
2719 | 145 | EPICS_ATOMIC_INLINE size_t epicsAtomicSubSizeT ( size_t * pTarget, | ||
2720 | 146 | size_t delta ) | ||
2721 | 147 | { | ||
2722 | 148 | STATIC_ASSERT ( sizeof ( void * ) == sizeof ( size_t ) ); | ||
2723 | 149 | void ** const pTarg = ( void ** ) ( pTarget ); | ||
2724 | 150 | ssize_t = sdelta = ( ssize_t ) delta; | ||
2725 | 151 | return ( size_t ) atomic_add_ptr_nv ( pTarg, -sdelta ); | ||
2726 | 152 | } | ||
2727 | 153 | #endif | ||
2728 | 154 | |||
2729 | 155 | #ifdef __cplusplus | ||
2730 | 156 | } /* end of extern "C" */ | ||
2731 | 157 | #endif /* __cplusplus */ | ||
2732 | 158 | |||
2733 | 159 | #endif /* ifdef __SunOS_5_10 */ | ||
2734 | 160 | |||
2735 | 161 | #include "epicsAtomicDefault.h" | ||
2736 | 162 | |||
2737 | 163 | #endif /* if defined ( EPICS_ATOMIC_INLINE ) */ | ||
2738 | 164 | |||
2739 | 165 | #endif /* epicsAtomicOSD_h */ | ||
2740 | 166 | |||
2741 | 0 | 167 | ||
2742 | === added file 'src/libCom/osi/os/vxWorks/epicsAtomicOSD.cpp' | |||
2743 | --- src/libCom/osi/os/vxWorks/epicsAtomicOSD.cpp 1970-01-01 00:00:00 +0000 | |||
2744 | +++ src/libCom/osi/os/vxWorks/epicsAtomicOSD.cpp 2011-08-31 22:29:24 +0000 | |||
2745 | @@ -0,0 +1,22 @@ | |||
2746 | 1 | |||
2747 | 2 | /*************************************************************************\ | ||
2748 | 3 | * Copyright (c) 2011 LANS LLC, as Operator of | ||
2749 | 4 | * Los Alamos National Laboratory. | ||
2750 | 5 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
2751 | 6 | * in file LICENSE that is included with this distribution. | ||
2752 | 7 | \*************************************************************************/ | ||
2753 | 8 | |||
2754 | 9 | /* | ||
2755 | 10 | * Author Jeffrey O. Hill | ||
2756 | 11 | * johill@lanl.gov | ||
2757 | 12 | */ | ||
2758 | 13 | |||
2759 | 14 | #define epicsExportSharedSymbols | ||
2760 | 15 | #include "epicsAtomic.h" | ||
2761 | 16 | |||
2762 | 17 | // if the compiler is unable to inline then instantiate out-of-line | ||
2763 | 18 | #ifndef EPICS_ATOMIC_INLINE | ||
2764 | 19 | #define EPICS_ATOMIC_INLINE | ||
2765 | 20 | #include "epicsAtomic.h" | ||
2766 | 21 | #endif | ||
2767 | 22 | |||
2768 | 0 | 23 | ||
2769 | === added file 'src/libCom/osi/os/vxWorks/epicsAtomicOSD.h' | |||
2770 | --- src/libCom/osi/os/vxWorks/epicsAtomicOSD.h 1970-01-01 00:00:00 +0000 | |||
2771 | +++ src/libCom/osi/os/vxWorks/epicsAtomicOSD.h 2011-08-31 22:29:24 +0000 | |||
2772 | @@ -0,0 +1,255 @@ | |||
2773 | 1 | /*************************************************************************\ | ||
2774 | 2 | * Copyright (c) 2011 LANS LLC, as Operator of | ||
2775 | 3 | * Los Alamos National Laboratory. | ||
2776 | 4 | * Copyright (c) 2011 UChicago Argonne, LLC, as Operator of | ||
2777 | 5 | * Argonne National Laboratory. | ||
2778 | 6 | * EPICS BASE is distributed subject to a Software License Agreement found | ||
2779 | 7 | * in file LICENSE that is included with this distribution. | ||
2780 | 8 | \*************************************************************************/ | ||
2781 | 9 | |||
2782 | 10 | /* | ||
2783 | 11 | * Author Jeffrey O. Hill | ||
2784 | 12 | * johill@lanl.gov | ||
2785 | 13 | */ | ||
2786 | 14 | |||
2787 | 15 | #ifndef epicsAtomicOSD_h | ||
2788 | 16 | #define epicsAtomicOSD_h | ||
2789 | 17 | |||
2790 | 18 | #if defined ( EPICS_ATOMIC_INLINE ) | ||
2791 | 19 | |||
2792 | 20 | #include "vxWorks.h" /* obtain the version of vxWorks */ | ||
2793 | 21 | #include "epicsAssert.h" | ||
2794 | 22 | |||
2795 | 23 | /* | ||
2796 | 24 | * With vxWorks 6.6 and later we need to use vxAtomicLib | ||
2797 | 25 | * to implement this functionality correctly on SMP systems | ||
2798 | 26 | */ | ||
2799 | 27 | #if _WRS_VXWORKS_MAJOR * 100 + _WRS_VXWORKS_MINOR >= 606 | ||
2800 | 28 | |||
2801 | 29 | #include <limits.h> | ||
2802 | 30 | #include <vxAtomicLib.h> | ||
2803 | 31 | |||
2804 | 32 | #ifdef __cplusplus | ||
2805 | 33 | extern "C" { | ||
2806 | 34 | #endif /* __cplusplus */ | ||
2807 | 35 | |||
2808 | 36 | #ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER | ||
2809 | 37 | #define EPICS_ATOMIC_READ_MEMORY_BARRIER | ||
2810 | 38 | EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier () | ||
2811 | 39 | { | ||
2812 | 40 | VX_MEM_BARRIER_R (); | ||
2813 | 41 | } | ||
2814 | 42 | #endif | ||
2815 | 43 | |||
2816 | 44 | #ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER | ||
2817 | 45 | #define EPICS_ATOMIC_WRITE_MEMORY_BARRIER | ||
2818 | 46 | EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier () | ||
2819 | 47 | { | ||
2820 | 48 | VX_MEM_BARRIER_W (); | ||
2821 | 49 | } | ||
2822 | 50 | #endif | ||
2823 | 51 | |||
2824 | 52 | /* | ||
2825 | 53 | * we make the probably correct guess that if ULONG_MAX | ||
2826 | 54 | * is the same as UINT_MAX then sizeof ( atomic_t ) | ||
2827 | 55 | * will be the same as sizeof ( size_t ) | ||
2828 | 56 | * | ||
2829 | 57 | * if ULONG_MAX != UINT_MAX then its 64 bit vxWorks and | ||
2830 | 58 | * WRS doesnt not supply at this time the atomic interface | ||
2831 | 59 | * for 8 byte integers that is needed - so that architecture | ||
2832 | 60 | * receives the lock synchronized version | ||
2833 | 61 | */ | ||
2834 | 62 | #if ULONG_MAX == UINT_MAX | ||
2835 | 63 | |||
2836 | 64 | STATIC_ASSERT ( sizeof ( atomic_t ) == sizeof ( size_t ) ); | ||
2837 | 65 | STATIC_ASSERT ( sizeof ( atomic_t ) == sizeof ( EpicsAtomicPtrT ) ); | ||
2838 | 66 | |||
2839 | 67 | |||
2840 | 68 | #ifndef EPICS_ATOMIC_INCR_SIZET | ||
2841 | 69 | #define EPICS_ATOMIC_INCR_SIZET | ||
2842 | 70 | EPICS_ATOMIC_INLINE size_t epicsAtomicIncrSizeT ( size_t * pTarget ) | ||
2843 | 71 | { | ||
2844 | 72 | atomic_t * const pTarg = ( atomic_t * ) ( pTarget ); | ||
2845 | 73 | const atomic_t oldVal = vxAtomicInc ( pTarg ); | ||
2846 | 74 | return 1 + ( size_t ) ( oldVal ); | ||
2847 | 75 | } | ||
2848 | 76 | #endif | ||
2849 | 77 | |||
2850 | 78 | #ifndef EPICS_ATOMIC_DECR_SIZET | ||
2851 | 79 | #define EPICS_ATOMIC_DECR_SIZET | ||
2852 | 80 | EPICS_ATOMIC_INLINE size_t epicsAtomicDecrSizeT ( size_t * pTarget ) | ||
2853 | 81 | { | ||
2854 | 82 | atomic_t * const pTarg = ( atomic_t * ) ( pTarget ); | ||
2855 | 83 | const atomic_t oldVal = vxAtomicDec ( pTarg ); | ||
2856 | 84 | return ( ( size_t ) oldVal ) - 1u; | ||
2857 | 85 | } | ||
2858 | 86 | #endif | ||
2859 | 87 | |||
2860 | 88 | #ifndef EPICS_ATOMIC_ADD_SIZET | ||
2861 | 89 | #define EPICS_ATOMIC_ADD_SIZET | ||
2862 | 90 | EPICS_ATOMIC_INLINE size_t epicsAtomicAddSizeT ( size_t * pTarget, size_t delta ) | ||
2863 | 91 | { | ||
2864 | 92 | /* | ||
2865 | 93 | * vxAtomicLib doc indicates that vxAtomicAdd is | ||
2866 | 94 | * implemented using signed arithmetic, but it | ||
2867 | 95 | * does not change the end result because twos | ||
2868 | 96 | * complement addition is used in either case | ||
2869 | 97 | */ | ||
2870 | 98 | atomic_t * const pTarg = ( atomic_t * ) ( pTarget ); | ||
2871 | 99 | const atomic_t oldVal = vxAtomicAdd ( pTarg, (atomic_t) delta ); | ||
2872 | 100 | return delta + ( size_t ) oldVal; | ||
2873 | 101 | } | ||
2874 | 102 | #endif | ||
2875 | 103 | |||
2876 | 104 | #ifndef EPICS_ATOMIC_SUB_SIZET | ||
2877 | 105 | #define EPICS_ATOMIC_SUB_SIZET | ||
2878 | 106 | EPICS_ATOMIC_INLINE size_t epicsAtomicSubSizeT ( size_t * pTarget, size_t delta ) | ||
2879 | 107 | { | ||
2880 | 108 | /* | ||
2881 | 109 | * vxAtomicLib doc indicates that vxAtomicSub is | ||
2882 | 110 | * implemented using signed arithmetic, but it | ||
2883 | 111 | * does not change the end result because twos | ||
2884 | 112 | * complement subtraction is used in either case | ||
2885 | 113 | */ | ||
2886 | 114 | atomic_t * const pTarg = ( atomic_t * ) ( pTarget ); | ||
2887 | 115 | const atomic_t oldVal = vxAtomicSub ( pTarg, (atomic_t) delta ); | ||
2888 | 116 | return ( ( size_t ) oldVal ) - delta; | ||
2889 | 117 | } | ||
2890 | 118 | #endif | ||
2891 | 119 | |||
2892 | 120 | #ifndef EPICS_ATOMIC_CAS_SIZET | ||
2893 | 121 | #define EPICS_ATOMIC_CAS_SIZET | ||
2894 | 122 | EPICS_ATOMIC_INLINE size_t epicsAtomicCmpAndSwapSizeT ( size_t * pTarget, | ||
2895 | 123 | size_t oldVal, size_t newVal ) | ||
2896 | 124 | { | ||
2897 | 125 | atomic_t * const pTarg = ( atomic_t * ) ( pTarget ); | ||
2898 | 126 | return ( size_t ) vxCas ( pTarg, (atomic_t) oldVal, (atomic_t) newVal ); | ||
2899 | 127 | } | ||
2900 | 128 | #endif | ||
2901 | 129 | |||
2902 | 130 | #ifndef EPICS_ATOMIC_CAS_PTRT | ||
2903 | 131 | #define EPICS_ATOMIC_CAS_PTRT | ||
2904 | 132 | EPICS_ATOMIC_INLINE EpicsAtomicPtrT epicsAtomicCmpAndSwapPtrT ( EpicsAtomicPtrT * pTarget, | ||
2905 | 133 | EpicsAtomicPtrT oldVal, EpicsAtomicPtrT newVal ) | ||
2906 | 134 | { | ||
2907 | 135 | atomic_t * const pTarg = ( atomic_t * ) ( pTarget ); | ||
2908 | 136 | return (EpicsAtomicPtrT) vxCas ( pTarg, (atomic_t) oldVal, (atomic_t) newVal ); | ||
2909 | 137 | } | ||
2910 | 138 | #endif | ||
2911 | 139 | |||
2912 | 140 | #else /* ULONG_MAX == UINT_MAX */ | ||
2913 | 141 | |||
2914 | 142 | /* | ||
2915 | 143 | * if its 64 bit SMP vxWorks and the compiler doesnt | ||
2916 | 144 | * have an intrinsic then maybe there isnt any way to | ||
2917 | 145 | * implement these without using a global lock because | ||
2918 | 146 | * size_t is maybe bigger than atomic_t | ||
2919 | 147 | * | ||
2920 | 148 | * I dont yet have access to vxWorks manuals for | ||
2921 | 149 | * 64 bit systems so this is still undecided, but is | ||
2922 | 150 | * defaulting now to a global lock | ||
2923 | 151 | */ | ||
2924 | 152 | |||
2925 | 153 | #endif /* ULONG_MAX == UINT_MAX */ | ||
2926 | 154 | |||
2927 | 155 | STATIC_ASSERT ( sizeof ( atomic_t ) == sizeof ( int ) ); | ||
2928 | 156 | |||
2929 | 157 | #ifndef EPICS_ATOMIC_INCR_INTT | ||
2930 | 158 | #define EPICS_ATOMIC_INCR_INTT | ||
2931 | 159 | EPICS_ATOMIC_INLINE int epicsAtomicIncrIntT ( int * pTarget ) | ||
2932 | 160 | { | ||
2933 | 161 | atomic_t * const pTarg = ( atomic_t * ) ( pTarget ); | ||
2934 | 162 | const atomic_t oldVal = vxAtomicInc ( pTarg ); | ||
2935 | 163 | return 1 + ( int ) oldVal; | ||
2936 | 164 | } | ||
2937 | 165 | #endif | ||
2938 | 166 | |||
2939 | 167 | #ifndef EPICS_ATOMIC_DECR_INTT | ||
2940 | 168 | #define EPICS_ATOMIC_DECR_INTT | ||
2941 | 169 | EPICS_ATOMIC_INLINE int epicsAtomicDecrIntT ( int * pTarget ) | ||
2942 | 170 | { | ||
2943 | 171 | atomic_t * const pTarg = ( atomic_t * ) ( pTarget ); | ||
2944 | 172 | const atomic_t oldVal = vxAtomicDec ( pTarg ); | ||
2945 | 173 | return ( ( int ) oldVal ) - 1; | ||
2946 | 174 | } | ||
2947 | 175 | #endif | ||
2948 | 176 | |||
2949 | 177 | #ifndef EPICS_ATOMIC_ADD_INTT | ||
2950 | 178 | #define EPICS_ATOMIC_ADD_INTT | ||
2951 | 179 | EPICS_ATOMIC_INLINE int epicsAtomicAddIntT ( int * pTarget, int delta ) | ||
2952 | 180 | { | ||
2953 | 181 | atomic_t * const pTarg = ( atomic_t * ) ( pTarget ); | ||
2954 | 182 | const atomic_t oldVal = vxAtomicAdd ( pTarg, (atomic_t) delta ); | ||
2955 | 183 | return delta + ( int ) oldVal; | ||
2956 | 184 | } | ||
2957 | 185 | #endif | ||
2958 | 186 | |||
2959 | 187 | #ifndef EPICS_ATOMIC_CAS_INTT | ||
2960 | 188 | #define EPICS_ATOMIC_CAS_INTT | ||
2961 | 189 | EPICS_ATOMIC_INLINE int epicsAtomicCmpAndSwapIntT ( int * pTarget, | ||
2962 | 190 | int oldVal, int newVal ) | ||
2963 | 191 | { | ||
2964 | 192 | atomic_t * const pTarg = ( atomic_t * ) ( pTarget ); | ||
2965 | 193 | return ( int ) vxCas ( pTarg, (atomic_t) oldVal, (atomic_t) newVal ); | ||
2966 | 194 | } | ||
2967 | 195 | #endif | ||
2968 | 196 | |||
2969 | 197 | #ifdef __cplusplus | ||
2970 | 198 | } /* end of extern "C" */ | ||
2971 | 199 | #endif /* __cplusplus */ | ||
2972 | 200 | |||
2973 | 201 | #else /* _WRS_VXWORKS_MAJOR * 100 + _WRS_VXWORKS_MINOR >= 606 */ | ||
2974 | 202 | |||
2975 | 203 | #include "vxLib.h" | ||
2976 | 204 | #include "intLib.h" | ||
2977 | 205 | |||
2978 | 206 | #ifdef __cplusplus | ||
2979 | 207 | extern "C" { | ||
2980 | 208 | #endif /* __cplusplus */ | ||
2981 | 209 | |||
2982 | 210 | #ifndef EPICS_ATOMIC_LOCK | ||
2983 | 211 | #define EPICS_ATOMIC_LOCK | ||
2984 | 212 | |||
2985 | 213 | typedef struct EpicsAtomicLockKey { int m_key; } EpicsAtomicLockKey; | ||
2986 | 214 | |||
2987 | 215 | EPICS_ATOMIC_INLINE void epicsAtomicLock ( EpicsAtomicLockKey * pKey ) | ||
2988 | 216 | { | ||
2989 | 217 | pKey->m_key = intLock (); | ||
2990 | 218 | } | ||
2991 | 219 | |||
2992 | 220 | EPICS_ATOMIC_INLINE void epicsAtomicUnlock ( EpicsAtomicLockKey * pKey ) | ||
2993 | 221 | { | ||
2994 | 222 | intUnlock ( pKey->m_key ); | ||
2995 | 223 | } | ||
2996 | 224 | #endif | ||
2997 | 225 | |||
2998 | 226 | #ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER | ||
2999 | 227 | #define EPICS_ATOMIC_READ_MEMORY_BARRIER | ||
3000 | 228 | /* | ||
3001 | 229 | * no need for memory barrior since prior to vxWorks 6.6 it is a single cpu system | ||
3002 | 230 | * (we are not protecting against multiple access to memory mapped IO) | ||
3003 | 231 | */ | ||
3004 | 232 | EPICS_ATOMIC_INLINE void epicsAtomicReadMemoryBarrier () {} | ||
3005 | 233 | #endif | ||
3006 | 234 | |||
3007 | 235 | #ifndef EPICS_ATOMIC_WRITE_MEMORY_BARRIER | ||
3008 | 236 | #define EPICS_ATOMIC_WRITE_MEMORY_BARRIER | ||
3009 | 237 | /* | ||
3010 | 238 | * no need for memory barrior since prior to vxWorks 6.6 it is a single cpu system | ||
3011 | 239 | * (we are not protecting against multiple access to memory mapped IO) | ||
3012 | 240 | */ | ||
3013 | 241 | EPICS_ATOMIC_INLINE void epicsAtomicWriteMemoryBarrier () {} | ||
3014 | 242 | #endif | ||
3015 | 243 | |||
3016 | 244 | #ifdef __cplusplus | ||
3017 | 245 | } /* end of extern "C" */ | ||
3018 | 246 | #endif /* __cplusplus */ | ||
3019 | 247 | |||
3020 | 248 | #endif /* _WRS_VXWORKS_MAJOR * 100 + _WRS_VXWORKS_MINOR >= 606 */ | ||
3021 | 249 | |||
3022 | 250 | #include "epicsAtomicDefault.h" | ||
3023 | 251 | |||
3024 | 252 | #endif /* if defined ( EPICS_ATOMIC_INLINE ) */ | ||
3025 | 253 | |||
3026 | 254 | #endif /* epicsAtomicOSD_h */ | ||
3027 | 255 | |||
3028 | 0 | 256 | ||
3029 | === modified file 'src/libCom/osi/os/vxWorks/osdThread.c' | |||
3030 | --- src/libCom/osi/os/vxWorks/osdThread.c 2010-08-11 15:45:17 +0000 | |||
3031 | +++ src/libCom/osi/os/vxWorks/osdThread.c 2011-08-31 22:29:24 +0000 | |||
3032 | @@ -53,7 +53,6 @@ | |||
3033 | 53 | static void **papTSD = 0; | 53 | static void **papTSD = 0; |
3034 | 54 | static int nepicsThreadPrivate = 0; | 54 | static int nepicsThreadPrivate = 0; |
3035 | 55 | 55 | ||
3036 | 56 | static SEM_ID epicsThreadOnceMutex = 0; | ||
3037 | 57 | 56 | ||
3038 | 58 | 57 | ||
3039 | 59 | /* Just map osi 0 to 99 into vx 100 to 199 */ | 58 | /* Just map osi 0 to 99 into vx 100 to 199 */ |
3040 | 60 | /* remember that for vxWorks lower number means higher priority */ | 59 | /* remember that for vxWorks lower number means higher priority */ |
3041 | @@ -83,19 +82,6 @@ | |||
3042 | 83 | } | 82 | } |
3043 | 84 | } | 83 | } |
3044 | 85 | 84 | ||
3045 | 86 | static void epicsThreadInit(void) | ||
3046 | 87 | { | ||
3047 | 88 | static int lock = 0; | ||
3048 | 89 | |||
3049 | 90 | while(!vxTas(&lock)) taskDelay(1); | ||
3050 | 91 | if(epicsThreadOnceMutex==0) { | ||
3051 | 92 | epicsThreadOnceMutex = semMCreate( | ||
3052 | 93 | SEM_DELETE_SAFE|SEM_INVERSION_SAFE|SEM_Q_PRIORITY); | ||
3053 | 94 | assert(epicsThreadOnceMutex); | ||
3054 | 95 | } | ||
3055 | 96 | lock = 0; | ||
3056 | 97 | } | ||
3057 | 98 | |||
3058 | 99 | unsigned int epicsThreadGetStackSize (epicsThreadStackSizeClass stackSizeClass) | 85 | unsigned int epicsThreadGetStackSize (epicsThreadStackSizeClass stackSizeClass) |
3059 | 100 | { | 86 | { |
3060 | 101 | 87 | ||
3061 | @@ -112,43 +98,6 @@ | |||
3062 | 112 | return stackSizeTable[stackSizeClass]; | 98 | return stackSizeTable[stackSizeClass]; |
3063 | 113 | } | 99 | } |
3064 | 114 | 100 | ||
3065 | 115 | struct epicsThreadOSD {}; | ||
3066 | 116 | /* Strictly speaking this should be a WIND_TCB, but we only need it to | ||
3067 | 117 | * be able to create an epicsThreadId that is guaranteed never to be | ||
3068 | 118 | * the same as any current TID, and since TIDs are pointers this works. | ||
3069 | 119 | */ | ||
3070 | 120 | |||
3071 | 121 | void epicsThreadOnce(epicsThreadOnceId *id, void (*func)(void *), void *arg) | ||
3072 | 122 | { | ||
3073 | 123 | static struct epicsThreadOSD threadOnceComplete; | ||
3074 | 124 | #define EPICS_THREAD_ONCE_DONE &threadOnceComplete | ||
3075 | 125 | int result; | ||
3076 | 126 | |||
3077 | 127 | epicsThreadInit(); | ||
3078 | 128 | result = semTake(epicsThreadOnceMutex, WAIT_FOREVER); | ||
3079 | 129 | assert(result == OK); | ||
3080 | 130 | if (*id != EPICS_THREAD_ONCE_DONE) { | ||
3081 | 131 | if (*id == EPICS_THREAD_ONCE_INIT) { /* first call */ | ||
3082 | 132 | *id = epicsThreadGetIdSelf(); /* mark active */ | ||
3083 | 133 | semGive(epicsThreadOnceMutex); | ||
3084 | 134 | func(arg); | ||
3085 | 135 | result = semTake(epicsThreadOnceMutex, WAIT_FOREVER); | ||
3086 | 136 | assert(result == OK); | ||
3087 | 137 | *id = EPICS_THREAD_ONCE_DONE; /* mark done */ | ||
3088 | 138 | } else if (*id == epicsThreadGetIdSelf()) { | ||
3089 | 139 | semGive(epicsThreadOnceMutex); | ||
3090 | 140 | cantProceed("Recursive epicsThreadOnce() initialization\n"); | ||
3091 | 141 | } else | ||
3092 | 142 | while (*id != EPICS_THREAD_ONCE_DONE) { | ||
3093 | 143 | /* Another thread is in the above func(arg) call. */ | ||
3094 | 144 | semGive(epicsThreadOnceMutex); | ||
3095 | 145 | epicsThreadSleep(epicsThreadSleepQuantum()); | ||
3096 | 146 | result = semTake(epicsThreadOnceMutex, WAIT_FOREVER); | ||
3097 | 147 | assert(result == OK); | ||
3098 | 148 | } | ||
3099 | 149 | } | ||
3100 | 150 | semGive(epicsThreadOnceMutex); | ||
3101 | 151 | } | ||
3102 | 152 | 101 | ||
3103 | 153 | 102 | ||
3104 | 154 | static void createFunction(EPICSTHREADFUNC func, void *parm) | 103 | static void createFunction(EPICSTHREADFUNC func, void *parm) |
3105 | 155 | { | 104 | { |
3106 | @@ -173,7 +122,6 @@ | |||
3107 | 173 | EPICSTHREADFUNC funptr,void *parm) | 122 | EPICSTHREADFUNC funptr,void *parm) |
3108 | 174 | { | 123 | { |
3109 | 175 | int tid; | 124 | int tid; |
3110 | 176 | if(epicsThreadOnceMutex==0) epicsThreadInit(); | ||
3111 | 177 | if(stackSize<100) { | 125 | if(stackSize<100) { |
3112 | 178 | errlogPrintf("epicsThreadCreate %s illegal stackSize %d\n",name,stackSize); | 126 | errlogPrintf("epicsThreadCreate %s illegal stackSize %d\n",name,stackSize); |
3113 | 179 | return(0); | 127 | return(0); |
3114 | @@ -343,7 +291,6 @@ | |||
3115 | 343 | static int lock = 0; | 291 | static int lock = 0; |
3116 | 344 | epicsThreadPrivateId id; | 292 | epicsThreadPrivateId id; |
3117 | 345 | 293 | ||
3118 | 346 | epicsThreadInit(); | ||
3119 | 347 | /*lock is necessary because ++nepicsThreadPrivate may not be indivisible*/ | 294 | /*lock is necessary because ++nepicsThreadPrivate may not be indivisible*/ |
3120 | 348 | while(!vxTas(&lock)) taskDelay(1); | 295 | while(!vxTas(&lock)) taskDelay(1); |
3121 | 349 | id = (epicsThreadPrivateId)++nepicsThreadPrivate; | 296 | id = (epicsThreadPrivateId)++nepicsThreadPrivate; |
3122 | 350 | 297 | ||
3123 | === modified file 'src/libCom/test/Makefile' | |||
3124 | --- src/libCom/test/Makefile 2011-08-30 23:09:11 +0000 | |||
3125 | +++ src/libCom/test/Makefile 2011-08-31 22:29:24 +0000 | |||
3126 | @@ -108,6 +108,11 @@ | |||
3127 | 108 | testHarness_SRCS += epicsMutexTest.cpp | 108 | testHarness_SRCS += epicsMutexTest.cpp |
3128 | 109 | TESTS += epicsMutexTest | 109 | TESTS += epicsMutexTest |
3129 | 110 | 110 | ||
3130 | 111 | TESTPROD_HOST += epicsAtomicTest | ||
3131 | 112 | epicsAtomicTest_SRCS += epicsAtomicTest.c | ||
3132 | 113 | testHarness_SRCS += epicsAtomicTest.c | ||
3133 | 114 | TESTS += epicsAtomicTest | ||
3134 | 115 | |||
3135 | 111 | TESTPROD_HOST += epicsExceptionTest | 116 | TESTPROD_HOST += epicsExceptionTest |
3136 | 112 | epicsExceptionTest_SRCS += epicsExceptionTest.cpp | 117 | epicsExceptionTest_SRCS += epicsExceptionTest.cpp |
3137 | 113 | testHarness_SRCS += epicsExceptionTest.cpp | 118 | testHarness_SRCS += epicsExceptionTest.cpp |
3138 | @@ -178,6 +183,10 @@ | |||
3139 | 178 | fdmgrTest_LIBS += ca | 183 | fdmgrTest_LIBS += ca |
3140 | 179 | # FIXME: program never exits. | 184 | # FIXME: program never exits. |
3141 | 180 | 185 | ||
3142 | 186 | TESTPROD_HOST += epicsAtomicPerform | ||
3143 | 187 | epicsAtomicPerform_SRCS += epicsAtomicPerform.cpp | ||
3144 | 188 | testHarness_SRCS += epicsAtomicPerform.cpp | ||
3145 | 189 | |||
3146 | 181 | TESTPROD_HOST += cvtFastPerform | 190 | TESTPROD_HOST += cvtFastPerform |
3147 | 182 | cvtFastPerform_SRCS += cvtFastPerform.cpp | 191 | cvtFastPerform_SRCS += cvtFastPerform.cpp |
3148 | 183 | testHarness_SRCS += cvtFastPerform.cpp | 192 | testHarness_SRCS += cvtFastPerform.cpp |
3149 | 184 | 193 | ||
3150 | === added file 'src/libCom/test/epicsAtomicPerform.cpp' | |||
3151 | --- src/libCom/test/epicsAtomicPerform.cpp 1970-01-01 00:00:00 +0000 | |||
3152 | +++ src/libCom/test/epicsAtomicPerform.cpp 2011-08-31 22:29:24 +0000 | |||
3153 | @@ -0,0 +1,506 @@ | |||
3154 | 1 | |||
3155 | 2 | #include <cstdlib> | ||
3156 | 3 | #include <cstdio> | ||
3157 | 4 | #include <cassert> | ||
3158 | 5 | #include <typeinfo> | ||
3159 | 6 | |||
3160 | 7 | #include "epicsInterrupt.h" | ||
3161 | 8 | #include "epicsAtomic.h" | ||
3162 | 9 | #include "epicsTime.h" | ||
3163 | 10 | #include "epicsUnitTest.h" | ||
3164 | 11 | #include "testMain.h" | ||
3165 | 12 | |||
3166 | 13 | using std :: size_t; | ||
3167 | 14 | using namespace epics; | ||
3168 | 15 | using namespace atomic; | ||
3169 | 16 | |||
3170 | 17 | class RefCtr { | ||
3171 | 18 | public: | ||
3172 | 19 | RefCtr (); | ||
3173 | 20 | ~RefCtr (); | ||
3174 | 21 | void reference (); | ||
3175 | 22 | void unreference (); | ||
3176 | 23 | private: | ||
3177 | 24 | size_t m_cnt; | ||
3178 | 25 | }; | ||
3179 | 26 | |||
3180 | 27 | class Ownership { | ||
3181 | 28 | public: | ||
3182 | 29 | Ownership (); | ||
3183 | 30 | Ownership ( RefCtr & refCtr ); | ||
3184 | 31 | Ownership ( const Ownership & ); | ||
3185 | 32 | ~Ownership (); | ||
3186 | 33 | Ownership & operator = ( const Ownership & ); | ||
3187 | 34 | private: | ||
3188 | 35 | RefCtr * _pRefCtr; | ||
3189 | 36 | static RefCtr m_noOwnership; | ||
3190 | 37 | }; | ||
3191 | 38 | |||
3192 | 39 | inline RefCtr :: RefCtr () | ||
3193 | 40 | { | ||
3194 | 41 | epicsAtomicSetSizeT ( & m_cnt, 0 ); | ||
3195 | 42 | } | ||
3196 | 43 | |||
3197 | 44 | inline RefCtr :: ~RefCtr () | ||
3198 | 45 | { | ||
3199 | 46 | unsigned cnt = epicsAtomicGetSizeT ( & m_cnt ); | ||
3200 | 47 | assert ( cnt == 0u ); | ||
3201 | 48 | } | ||
3202 | 49 | |||
3203 | 50 | inline void RefCtr :: reference () | ||
3204 | 51 | { | ||
3205 | 52 | epicsAtomicIncrSizeT ( & m_cnt ); | ||
3206 | 53 | } | ||
3207 | 54 | |||
3208 | 55 | inline void RefCtr :: unreference () | ||
3209 | 56 | { | ||
3210 | 57 | epicsAtomicDecrSizeT ( & m_cnt ); | ||
3211 | 58 | } | ||
3212 | 59 | |||
3213 | 60 | RefCtr Ownership :: m_noOwnership; | ||
3214 | 61 | |||
3215 | 62 | inline Ownership :: Ownership () : | ||
3216 | 63 | _pRefCtr ( & m_noOwnership ) | ||
3217 | 64 | { | ||
3218 | 65 | m_noOwnership.reference (); | ||
3219 | 66 | } | ||
3220 | 67 | |||
3221 | 68 | inline Ownership :: Ownership ( RefCtr & refCtr ) : | ||
3222 | 69 | _pRefCtr ( & refCtr ) | ||
3223 | 70 | { | ||
3224 | 71 | refCtr.reference (); | ||
3225 | 72 | } | ||
3226 | 73 | |||
3227 | 74 | inline Ownership :: Ownership ( const Ownership & ownership ) : | ||
3228 | 75 | _pRefCtr ( ownership._pRefCtr ) | ||
3229 | 76 | { | ||
3230 | 77 | _pRefCtr->reference (); | ||
3231 | 78 | } | ||
3232 | 79 | |||
3233 | 80 | inline Ownership :: ~Ownership () | ||
3234 | 81 | { | ||
3235 | 82 | _pRefCtr->unreference (); | ||
3236 | 83 | } | ||
3237 | 84 | |||
3238 | 85 | inline Ownership & Ownership :: | ||
3239 | 86 | operator = ( const Ownership & ownership ) | ||
3240 | 87 | { | ||
3241 | 88 | RefCtr * const pOldRefCtr = _pRefCtr; | ||
3242 | 89 | _pRefCtr = ownership._pRefCtr; | ||
3243 | 90 | _pRefCtr->reference (); | ||
3244 | 91 | pOldRefCtr->unreference (); | ||
3245 | 92 | return *this; | ||
3246 | 93 | } | ||
3247 | 94 | |||
3248 | 95 | inline Ownership retOwnership ( const Ownership & ownership ) | ||
3249 | 96 | { | ||
3250 | 97 | return Ownership ( ownership ); | ||
3251 | 98 | } | ||
3252 | 99 | |||
3253 | 100 | inline Ownership recurRetOwner10 ( const Ownership & ownershipIn ) | ||
3254 | 101 | { | ||
3255 | 102 | Ownership ownership = | ||
3256 | 103 | retOwnership ( | ||
3257 | 104 | retOwnership ( | ||
3258 | 105 | retOwnership ( | ||
3259 | 106 | retOwnership ( | ||
3260 | 107 | retOwnership ( ownershipIn ) ) ) ) ); | ||
3261 | 108 | return retOwnership ( | ||
3262 | 109 | retOwnership ( | ||
3263 | 110 | retOwnership ( | ||
3264 | 111 | retOwnership ( | ||
3265 | 112 | retOwnership ( ownership ) ) ) ) ); | ||
3266 | 113 | } | ||
3267 | 114 | |||
3268 | 115 | inline Ownership recurRetOwner100 ( const Ownership & ownershipIn ) | ||
3269 | 116 | { | ||
3270 | 117 | Ownership ownership = | ||
3271 | 118 | recurRetOwner10 ( | ||
3272 | 119 | recurRetOwner10 ( | ||
3273 | 120 | recurRetOwner10 ( | ||
3274 | 121 | recurRetOwner10 ( | ||
3275 | 122 | recurRetOwner10 ( ownershipIn ) ) ) ) ); | ||
3276 | 123 | return recurRetOwner10 ( | ||
3277 | 124 | recurRetOwner10 ( | ||
3278 | 125 | recurRetOwner10 ( | ||
3279 | 126 | recurRetOwner10 ( | ||
3280 | 127 | recurRetOwner10 ( ownership ) ) ) ) ); | ||
3281 | 128 | } | ||
3282 | 129 | |||
3283 | 130 | inline Ownership recurRetOwner1000 ( const Ownership & ownershipIn ) | ||
3284 | 131 | { | ||
3285 | 132 | Ownership ownership = | ||
3286 | 133 | recurRetOwner100 ( | ||
3287 | 134 | recurRetOwner100 ( | ||
3288 | 135 | recurRetOwner100 ( | ||
3289 | 136 | recurRetOwner100 ( | ||
3290 | 137 | recurRetOwner100 ( ownershipIn ) ) ) ) ); | ||
3291 | 138 | return recurRetOwner100 ( | ||
3292 | 139 | recurRetOwner100 ( | ||
3293 | 140 | recurRetOwner100 ( | ||
3294 | 141 | recurRetOwner100 ( | ||
3295 | 142 | recurRetOwner100 ( ownership ) ) ) ) ); | ||
3296 | 143 | } | ||
3297 | 144 | |||
3298 | 145 | inline void passRefOwnership ( const Ownership & ownershipIn, Ownership & ownershipOut ) | ||
3299 | 146 | { | ||
3300 | 147 | ownershipOut = ownershipIn; | ||
3301 | 148 | } | ||
3302 | 149 | |||
3303 | 150 | inline void passRefOwnership10 ( const Ownership & ownershipIn, Ownership & ownershipOut ) | ||
3304 | 151 | { | ||
3305 | 152 | Ownership ownershipTmp0; | ||
3306 | 153 | passRefOwnership ( ownershipIn, ownershipTmp0 ); | ||
3307 | 154 | Ownership ownershipTmp1; | ||
3308 | 155 | passRefOwnership ( ownershipTmp0, ownershipTmp1 ); | ||
3309 | 156 | Ownership ownershipTmp2; | ||
3310 | 157 | passRefOwnership ( ownershipTmp1, ownershipTmp2 ); | ||
3311 | 158 | Ownership ownershipTmp3; | ||
3312 | 159 | passRefOwnership ( ownershipTmp2, ownershipTmp3 ); | ||
3313 | 160 | Ownership ownershipTmp4; | ||
3314 | 161 | passRefOwnership ( ownershipTmp3, ownershipTmp4 ); | ||
3315 | 162 | Ownership ownershipTmp5; | ||
3316 | 163 | passRefOwnership ( ownershipTmp4, ownershipTmp5 ); | ||
3317 | 164 | Ownership ownershipTmp6; | ||
3318 | 165 | passRefOwnership ( ownershipTmp5, ownershipTmp6 ); | ||
3319 | 166 | Ownership ownershipTmp7; | ||
3320 | 167 | passRefOwnership ( ownershipTmp6, ownershipTmp7 ); | ||
3321 | 168 | Ownership ownershipTmp8; | ||
3322 | 169 | passRefOwnership ( ownershipTmp7, ownershipTmp8 ); | ||
3323 | 170 | passRefOwnership ( ownershipTmp8, ownershipOut ); | ||
3324 | 171 | } | ||
3325 | 172 | |||
3326 | 173 | inline void passRefOwnership100 ( const Ownership & ownershipIn, Ownership & ownershipOut ) | ||
3327 | 174 | { | ||
3328 | 175 | Ownership ownershipTmp0; | ||
3329 | 176 | passRefOwnership10 ( ownershipIn, ownershipTmp0 ); | ||
3330 | 177 | Ownership ownershipTmp1; | ||
3331 | 178 | passRefOwnership10 ( ownershipTmp0, ownershipTmp1 ); | ||
3332 | 179 | Ownership ownershipTmp2; | ||
3333 | 180 | passRefOwnership10 ( ownershipTmp1, ownershipTmp2 ); | ||
3334 | 181 | Ownership ownershipTmp3; | ||
3335 | 182 | passRefOwnership10 ( ownershipTmp2, ownershipTmp3 ); | ||
3336 | 183 | Ownership ownershipTmp4; | ||
3337 | 184 | passRefOwnership10 ( ownershipTmp3, ownershipTmp4 ); | ||
3338 | 185 | Ownership ownershipTmp5; | ||
3339 | 186 | passRefOwnership10 ( ownershipTmp4, ownershipTmp5 ); | ||
3340 | 187 | Ownership ownershipTmp6; | ||
3341 | 188 | passRefOwnership10 ( ownershipTmp5, ownershipTmp6 ); | ||
3342 | 189 | Ownership ownershipTmp7; | ||
3343 | 190 | passRefOwnership10 ( ownershipTmp6, ownershipTmp7 ); | ||
3344 | 191 | Ownership ownershipTmp8; | ||
3345 | 192 | passRefOwnership10 ( ownershipTmp7, ownershipTmp8 ); | ||
3346 | 193 | passRefOwnership10 ( ownershipTmp8, ownershipOut ); | ||
3347 | 194 | } | ||
3348 | 195 | |||
3349 | 196 | inline void passRefOwnership1000 ( const Ownership & ownershipIn, Ownership & ownershipOut ) | ||
3350 | 197 | { | ||
3351 | 198 | Ownership ownershipTmp0; | ||
3352 | 199 | passRefOwnership100 ( ownershipIn, ownershipTmp0 ); | ||
3353 | 200 | Ownership ownershipTmp1; | ||
3354 | 201 | passRefOwnership100 ( ownershipTmp0, ownershipTmp1 ); | ||
3355 | 202 | Ownership ownershipTmp2; | ||
3356 | 203 | passRefOwnership100 ( ownershipTmp1, ownershipTmp2 ); | ||
3357 | 204 | Ownership ownershipTmp3; | ||
3358 | 205 | passRefOwnership100 ( ownershipTmp2, ownershipTmp3 ); | ||
3359 | 206 | Ownership ownershipTmp4; | ||
3360 | 207 | passRefOwnership100 ( ownershipTmp3, ownershipTmp4 ); | ||
3361 | 208 | Ownership ownershipTmp5; | ||
3362 | 209 | passRefOwnership100 ( ownershipTmp4, ownershipTmp5 ); | ||
3363 | 210 | Ownership ownershipTmp6; | ||
3364 | 211 | passRefOwnership100 ( ownershipTmp5, ownershipTmp6 ); | ||
3365 | 212 | Ownership ownershipTmp7; | ||
3366 | 213 | passRefOwnership100 ( ownershipTmp6, ownershipTmp7 ); | ||
3367 | 214 | Ownership ownershipTmp8; | ||
3368 | 215 | passRefOwnership100 ( ownershipTmp7, ownershipTmp8 ); | ||
3369 | 216 | passRefOwnership100 ( ownershipTmp8, ownershipOut ); | ||
3370 | 217 | } | ||
3371 | 218 | |||
3372 | 219 | time_t extTime = 0; | ||
3373 | 220 | |||
3374 | 221 | template < class T > | ||
3375 | 222 | class OrdinaryIncr { | ||
3376 | 223 | public: | ||
3377 | 224 | OrdinaryIncr () : m_target ( 0 ) {} | ||
3378 | 225 | void run (); | ||
3379 | 226 | void diagnostic ( double delay ); | ||
3380 | 227 | private: | ||
3381 | 228 | T m_target; | ||
3382 | 229 | }; | ||
3383 | 230 | |||
3384 | 231 | // tests the time it takes to perform a call to an external | ||
3385 | 232 | // function and also increment an integer word. The | ||
3386 | 233 | // epicsInterruptIsInterruptContext function is an | ||
3387 | 234 | // out-of-line function implemented in a sharable library | ||
3388 | 235 | // so hopefully it wont be optimized away. | ||
3389 | 236 | template < class T > | ||
3390 | 237 | inline void OrdinaryIncr < T > :: run () | ||
3391 | 238 | { | ||
3392 | 239 | m_target += epicsInterruptIsInterruptContext (); | ||
3393 | 240 | m_target += epicsInterruptIsInterruptContext (); | ||
3394 | 241 | m_target += epicsInterruptIsInterruptContext (); | ||
3395 | 242 | m_target += epicsInterruptIsInterruptContext (); | ||
3396 | 243 | m_target += epicsInterruptIsInterruptContext (); | ||
3397 | 244 | m_target += epicsInterruptIsInterruptContext (); | ||
3398 | 245 | m_target += epicsInterruptIsInterruptContext (); | ||
3399 | 246 | m_target += epicsInterruptIsInterruptContext (); | ||
3400 | 247 | m_target += epicsInterruptIsInterruptContext (); | ||
3401 | 248 | m_target += epicsInterruptIsInterruptContext (); | ||
3402 | 249 | } | ||
3403 | 250 | |||
3404 | 251 | template < class T > | ||
3405 | 252 | void OrdinaryIncr < T > :: diagnostic ( double delay ) | ||
3406 | 253 | { | ||
3407 | 254 | delay /= 10.0; | ||
3408 | 255 | delay *= 1e6; | ||
3409 | 256 | const char * const pName = typeid ( T ) . name (); | ||
3410 | 257 | testDiag ( "raw incr of \"%s\" and a NOOP function call takes %f microseconds", | ||
3411 | 258 | pName, delay ); | ||
3412 | 259 | } | ||
3413 | 260 | |||
3414 | 261 | template < class T > | ||
3415 | 262 | class AtomicIncr { | ||
3416 | 263 | public: | ||
3417 | 264 | AtomicIncr () : m_target ( 0 ) {} | ||
3418 | 265 | void run (); | ||
3419 | 266 | void diagnostic ( double delay ); | ||
3420 | 267 | private: | ||
3421 | 268 | T m_target; | ||
3422 | 269 | }; | ||
3423 | 270 | |||
3424 | 271 | template < class T > | ||
3425 | 272 | inline void AtomicIncr < T > :: run () | ||
3426 | 273 | { | ||
3427 | 274 | increment ( m_target ); | ||
3428 | 275 | increment ( m_target ); | ||
3429 | 276 | increment ( m_target ); | ||
3430 | 277 | increment ( m_target ); | ||
3431 | 278 | increment ( m_target ); | ||
3432 | 279 | increment ( m_target ); | ||
3433 | 280 | increment ( m_target ); | ||
3434 | 281 | increment ( m_target ); | ||
3435 | 282 | increment ( m_target ); | ||
3436 | 283 | increment ( m_target ); | ||
3437 | 284 | } | ||
3438 | 285 | |||
3439 | 286 | template < class T > | ||
3440 | 287 | void AtomicIncr < T > :: diagnostic ( double delay ) | ||
3441 | 288 | { | ||
3442 | 289 | delay /= 10.0; | ||
3443 | 290 | delay *= 1e6; | ||
3444 | 291 | const char * const pName = typeid ( T ) . name (); | ||
3445 | 292 | testDiag ( "epicsAtomicIncr \"%s\" takes %f microseconds", | ||
3446 | 293 | pName, delay ); | ||
3447 | 294 | } | ||
3448 | 295 | |||
3449 | 296 | template < class T > T trueValue (); | ||
3450 | 297 | template < class T > T falseValue (); | ||
3451 | 298 | |||
3452 | 299 | // int | ||
3453 | 300 | template <> | ||
3454 | 301 | inline int trueValue < int > () { return 1; } | ||
3455 | 302 | |||
3456 | 303 | template <> | ||
3457 | 304 | inline int falseValue < int > () { return 0; } | ||
3458 | 305 | |||
3459 | 306 | // size_t | ||
3460 | 307 | template <> | ||
3461 | 308 | inline size_t trueValue < size_t > () { return 1u; } | ||
3462 | 309 | |||
3463 | 310 | template <> | ||
3464 | 311 | inline size_t falseValue < size_t > () { return 0u; } | ||
3465 | 312 | |||
3466 | 313 | // EpicsAtomicPtrT | ||
3467 | 314 | template <> | ||
3468 | 315 | inline EpicsAtomicPtrT trueValue < EpicsAtomicPtrT > () | ||
3469 | 316 | { static char c; return & c; } | ||
3470 | 317 | |||
3471 | 318 | template <> | ||
3472 | 319 | inline EpicsAtomicPtrT falseValue < EpicsAtomicPtrT > () | ||
3473 | 320 | { return 0u; } | ||
3474 | 321 | |||
3475 | 322 | template < class T > | ||
3476 | 323 | class AtomicCmpAndSwap { | ||
3477 | 324 | public: | ||
3478 | 325 | AtomicCmpAndSwap () : m_target ( 0 ) {} | ||
3479 | 326 | void run (); | ||
3480 | 327 | void diagnostic ( double delay ); | ||
3481 | 328 | private: | ||
3482 | 329 | T m_target; | ||
3483 | 330 | }; | ||
3484 | 331 | |||
3485 | 332 | template < class T > | ||
3486 | 333 | inline void AtomicCmpAndSwap < T > :: run () | ||
3487 | 334 | { | ||
3488 | 335 | compareAndSwap ( m_target, falseValue < T > (), trueValue < T > () ); | ||
3489 | 336 | compareAndSwap ( m_target, falseValue < T > (), trueValue < T > () ); | ||
3490 | 337 | compareAndSwap ( m_target, falseValue < T > (), trueValue < T > () ); | ||
3491 | 338 | compareAndSwap ( m_target, falseValue < T > (), trueValue < T > () ); | ||
3492 | 339 | compareAndSwap ( m_target, falseValue < T > (), trueValue < T > () ); | ||
3493 | 340 | compareAndSwap ( m_target, falseValue < T > (), trueValue < T > () ); | ||
3494 | 341 | compareAndSwap ( m_target, falseValue < T > (), trueValue < T > () ); | ||
3495 | 342 | compareAndSwap ( m_target, falseValue < T > (), trueValue < T > () ); | ||
3496 | 343 | compareAndSwap ( m_target, falseValue < T > (), trueValue < T > () ); | ||
3497 | 344 | compareAndSwap ( m_target, falseValue < T > (), trueValue < T > () ); | ||
3498 | 345 | } | ||
3499 | 346 | |||
3500 | 347 | template < class T > | ||
3501 | 348 | void AtomicCmpAndSwap < T > :: diagnostic ( double delay ) | ||
3502 | 349 | { | ||
3503 | 350 | delay /= 10.0; | ||
3504 | 351 | delay *= 1e6; | ||
3505 | 352 | const char * const pName = typeid ( T ) . name (); | ||
3506 | 353 | testDiag ( "epicsAtomicCmpAndSwap of \"%s\" takes %f microseconds", | ||
3507 | 354 | pName, delay ); | ||
3508 | 355 | } | ||
3509 | 356 | |||
3510 | 357 | template < class T > | ||
3511 | 358 | class AtomicSet { | ||
3512 | 359 | public: | ||
3513 | 360 | AtomicSet () : m_target ( 0 ) {} | ||
3514 | 361 | void run (); | ||
3515 | 362 | void diagnostic ( double delay ); | ||
3516 | 363 | private: | ||
3517 | 364 | T m_target; | ||
3518 | 365 | }; | ||
3519 | 366 | |||
3520 | 367 | template < class T > | ||
3521 | 368 | inline void AtomicSet < T > :: run () | ||
3522 | 369 | { | ||
3523 | 370 | set ( m_target, 0 ); | ||
3524 | 371 | set ( m_target, 0 ); | ||
3525 | 372 | set ( m_target, 0 ); | ||
3526 | 373 | set ( m_target, 0 ); | ||
3527 | 374 | set ( m_target, 0 ); | ||
3528 | 375 | set ( m_target, 0 ); | ||
3529 | 376 | set ( m_target, 0 ); | ||
3530 | 377 | set ( m_target, 0 ); | ||
3531 | 378 | set ( m_target, 0 ); | ||
3532 | 379 | set ( m_target, 0 ); | ||
3533 | 380 | } | ||
3534 | 381 | |||
3535 | 382 | template < class T > | ||
3536 | 383 | void AtomicSet < T > :: diagnostic ( double delay ) | ||
3537 | 384 | { | ||
3538 | 385 | delay /= 10.0; | ||
3539 | 386 | delay *= 1e6; | ||
3540 | 387 | const char * const pName = typeid ( T ) . name (); | ||
3541 | 388 | testDiag ( "epicsAtomicSet of \"%s\" takes %f microseconds", | ||
3542 | 389 | pName, delay ); | ||
3543 | 390 | } | ||
3544 | 391 | |||
3545 | 392 | static const unsigned N = 10000; | ||
3546 | 393 | |||
3547 | 394 | void recursiveOwnershipRetPerformance () | ||
3548 | 395 | { | ||
3549 | 396 | RefCtr refCtr; | ||
3550 | 397 | epicsTime begin = epicsTime::getCurrent (); | ||
3551 | 398 | for ( size_t i = 0; i < N; i++ ) { | ||
3552 | 399 | Ownership ownership ( refCtr ); | ||
3553 | 400 | recurRetOwner1000 ( ownership ); | ||
3554 | 401 | } | ||
3555 | 402 | double delay = epicsTime::getCurrent () - begin; | ||
3556 | 403 | delay /= N * 1000u; // convert to delay per call | ||
3557 | 404 | delay *= 1e6; // convert to micro seconds | ||
3558 | 405 | testDiag ( "retOwnership() takes %f microseconds", delay ); | ||
3559 | 406 | } | ||
3560 | 407 | |||
3561 | 408 | void ownershipPassRefPerformance () | ||
3562 | 409 | { | ||
3563 | 410 | RefCtr refCtr; | ||
3564 | 411 | epicsTime begin = epicsTime::getCurrent (); | ||
3565 | 412 | for ( size_t i = 0; i < N; i++ ) { | ||
3566 | 413 | Ownership ownershipSrc ( refCtr ); | ||
3567 | 414 | Ownership ownershipDest; | ||
3568 | 415 | passRefOwnership1000 ( ownershipSrc, ownershipDest ); | ||
3569 | 416 | } | ||
3570 | 417 | double delay = epicsTime::getCurrent () - begin; | ||
3571 | 418 | delay /= N * 1000u; // convert to delay per call | ||
3572 | 419 | delay *= 1e6; // convert to micro seconds | ||
3573 | 420 | testDiag ( "passRefOwnership() takes %f microseconds", delay ); | ||
3574 | 421 | } | ||
3575 | 422 | |||
3576 | 423 | template < class T > | ||
3577 | 424 | class Ten | ||
3578 | 425 | { | ||
3579 | 426 | public: | ||
3580 | 427 | void run (); | ||
3581 | 428 | void diagnostic ( double delay ); | ||
3582 | 429 | typedef Ten < Ten < T > > Hundred; | ||
3583 | 430 | typedef Ten < Hundred > Thousand; | ||
3584 | 431 | private: | ||
3585 | 432 | T m_target; | ||
3586 | 433 | }; | ||
3587 | 434 | |||
3588 | 435 | template < class T > | ||
3589 | 436 | inline void Ten < T > :: run () | ||
3590 | 437 | { | ||
3591 | 438 | m_target.run (); | ||
3592 | 439 | m_target.run (); | ||
3593 | 440 | m_target.run (); | ||
3594 | 441 | m_target.run (); | ||
3595 | 442 | m_target.run (); | ||
3596 | 443 | m_target.run (); | ||
3597 | 444 | m_target.run (); | ||
3598 | 445 | m_target.run (); | ||
3599 | 446 | m_target.run (); | ||
3600 | 447 | m_target.run (); | ||
3601 | 448 | } | ||
3602 | 449 | |||
3603 | 450 | template < class T > | ||
3604 | 451 | void Ten < T > :: diagnostic ( double delay ) | ||
3605 | 452 | { | ||
3606 | 453 | m_target.diagnostic ( delay / 10.0 ); | ||
3607 | 454 | } | ||
3608 | 455 | |||
3609 | 456 | template < class T > | ||
3610 | 457 | void measurePerformance () | ||
3611 | 458 | { | ||
3612 | 459 | epicsTime begin = epicsTime::getCurrent (); | ||
3613 | 460 | T target; | ||
3614 | 461 | for ( size_t i = 0; i < N; i++ ) { | ||
3615 | 462 | target.run (); | ||
3616 | 463 | target.run (); | ||
3617 | 464 | target.run (); | ||
3618 | 465 | target.run (); | ||
3619 | 466 | target.run (); | ||
3620 | 467 | target.run (); | ||
3621 | 468 | target.run (); | ||
3622 | 469 | target.run (); | ||
3623 | 470 | target.run (); | ||
3624 | 471 | target.run (); | ||
3625 | 472 | } | ||
3626 | 473 | double delay = epicsTime::getCurrent () - begin; | ||
3627 | 474 | delay /= ( N * 10u ); // convert to delay per call | ||
3628 | 475 | target.diagnostic ( delay ); | ||
3629 | 476 | } | ||
3630 | 477 | |||
3631 | 478 | template < class T > | ||
3632 | 479 | void measure () | ||
3633 | 480 | { | ||
3634 | 481 | measurePerformance < typename Ten < T > :: Hundred > (); | ||
3635 | 482 | } | ||
3636 | 483 | |||
3637 | 484 | MAIN ( epicsAtomicPerform ) | ||
3638 | 485 | { | ||
3639 | 486 | testPlan ( 0 ); | ||
3640 | 487 | // | ||
3641 | 488 | // The tests running here are measuring fast | ||
3642 | 489 | // functions so they tend to be impacted | ||
3643 | 490 | // by where the cache lines are wrt to the | ||
3644 | 491 | // virtual pages perhap | ||
3645 | 492 | // | ||
3646 | 493 | measure < AtomicSet < int > > (); | ||
3647 | 494 | measure < AtomicSet < size_t > > (); | ||
3648 | 495 | measure < AtomicSet < void * > > (); | ||
3649 | 496 | measure < OrdinaryIncr < int > > (); | ||
3650 | 497 | measure < OrdinaryIncr < size_t > > (); | ||
3651 | 498 | measure < AtomicIncr < int > > (); | ||
3652 | 499 | measure < AtomicIncr < size_t > > (); | ||
3653 | 500 | measure < AtomicCmpAndSwap < int > > (); | ||
3654 | 501 | measure < AtomicCmpAndSwap < size_t > > (); | ||
3655 | 502 | measure < AtomicCmpAndSwap < void * > > (); | ||
3656 | 503 | recursiveOwnershipRetPerformance (); | ||
3657 | 504 | ownershipPassRefPerformance (); | ||
3658 | 505 | return testDone(); | ||
3659 | 506 | } | ||
3660 | 0 | 507 | ||
3661 | === added file 'src/libCom/test/epicsAtomicTest.cpp' | |||
3662 | --- src/libCom/test/epicsAtomicTest.cpp 1970-01-01 00:00:00 +0000 | |||
3663 | +++ src/libCom/test/epicsAtomicTest.cpp 2011-08-31 22:29:24 +0000 | |||
3664 | @@ -0,0 +1,238 @@ | |||
3665 | 1 | |||
3666 | 2 | #include <stdlib.h> | ||
3667 | 3 | #include <assert.h> | ||
3668 | 4 | |||
3669 | 5 | #include "epicsAtomic.h" | ||
3670 | 6 | #include "epicsTime.h" | ||
3671 | 7 | #include "epicsThread.h" | ||
3672 | 8 | #include "epicsUnitTest.h" | ||
3673 | 9 | #include "testMain.h" | ||
3674 | 10 | |||
3675 | 11 | using namespace epics; | ||
3676 | 12 | using namespace atomic; | ||
3677 | 13 | |||
3678 | 14 | template < class T > | ||
3679 | 15 | struct TestDataIncrDecr { | ||
3680 | 16 | T m_testValue; | ||
3681 | 17 | size_t m_testIterations; | ||
3682 | 18 | }; | ||
3683 | 19 | |||
3684 | 20 | template < class T > | ||
3685 | 21 | struct TestDataAddSub { | ||
3686 | 22 | T m_testValue; | ||
3687 | 23 | size_t m_testIterations; | ||
3688 | 24 | static const T delta = 17; | ||
3689 | 25 | }; | ||
3690 | 26 | |||
3691 | 27 | template < class T > | ||
3692 | 28 | static void incr ( void *arg ) | ||
3693 | 29 | { | ||
3694 | 30 | TestDataIncrDecr < T > * const pTestData = | ||
3695 | 31 | reinterpret_cast < TestDataIncrDecr < T > * > ( arg ); | ||
3696 | 32 | increment ( pTestData->m_testValue ); | ||
3697 | 33 | increment ( pTestData->m_testIterations ); | ||
3698 | 34 | } | ||
3699 | 35 | |||
3700 | 36 | template < class T > | ||
3701 | 37 | static void decr ( void *arg ) | ||
3702 | 38 | { | ||
3703 | 39 | TestDataIncrDecr < T > * const pTestData = | ||
3704 | 40 | reinterpret_cast < TestDataIncrDecr < T > * > ( arg ); | ||
3705 | 41 | decrement ( pTestData->m_testValue ); | ||
3706 | 42 | increment ( pTestData->m_testIterations ); | ||
3707 | 43 | } | ||
3708 | 44 | |||
3709 | 45 | |||
3710 | 46 | template < class T > | ||
3711 | 47 | static void add ( void *arg ) | ||
3712 | 48 | { | ||
3713 | 49 | TestDataAddSub < T > * const pTestData = | ||
3714 | 50 | reinterpret_cast < TestDataAddSub < T > * > ( arg ); | ||
3715 | 51 | add ( pTestData->m_testValue, TestDataAddSub < T > :: delta ); | ||
3716 | 52 | increment ( pTestData->m_testIterations ); | ||
3717 | 53 | } | ||
3718 | 54 | |||
3719 | 55 | template < class T > | ||
3720 | 56 | static void sub ( void *arg ) | ||
3721 | 57 | { | ||
3722 | 58 | TestDataAddSub < T > * const pTestData = | ||
3723 | 59 | reinterpret_cast < TestDataAddSub < T > * > ( arg ); | ||
3724 | 60 | subtract ( pTestData->m_testValue, TestDataAddSub < T > :: delta ); | ||
3725 | 61 | increment ( pTestData->m_testIterations ); | ||
3726 | 62 | } | ||
3727 | 63 | |||
3728 | 64 | template < class T > | ||
3729 | 65 | struct TestDataCAS { | ||
3730 | 66 | T m_testValue; | ||
3731 | 67 | size_t m_testIterationsSet; | ||
3732 | 68 | size_t m_testIterationsNotSet; | ||
3733 | 69 | }; | ||
3734 | 70 | |||
3735 | 71 | int isModulo ( size_t N, size_t n ) | ||
3736 | 72 | { | ||
3737 | 73 | return ( n % N ) == 0u; | ||
3738 | 74 | } | ||
3739 | 75 | |||
3740 | 76 | template < class T > | ||
3741 | 77 | static T trueValue (); | ||
3742 | 78 | template < class T > | ||
3743 | 79 | static T falseValue (); | ||
3744 | 80 | |||
3745 | 81 | // int | ||
3746 | 82 | template <> | ||
3747 | 83 | inline int trueValue < int > () { return 1; } | ||
3748 | 84 | |||
3749 | 85 | template <> | ||
3750 | 86 | inline int falseValue < int > () { return 0; } | ||
3751 | 87 | |||
3752 | 88 | // size_t | ||
3753 | 89 | template <> | ||
3754 | 90 | inline size_t trueValue < size_t > () { return 1u; } | ||
3755 | 91 | |||
3756 | 92 | template <> | ||
3757 | 93 | inline size_t falseValue < size_t > () { return 0u; } | ||
3758 | 94 | |||
3759 | 95 | // EpicsAtomicPtrT | ||
3760 | 96 | template <> | ||
3761 | 97 | inline EpicsAtomicPtrT trueValue < EpicsAtomicPtrT > () | ||
3762 | 98 | { static char c; return & c; } | ||
3763 | 99 | |||
3764 | 100 | template <> | ||
3765 | 101 | inline EpicsAtomicPtrT falseValue < EpicsAtomicPtrT > () | ||
3766 | 102 | { return 0u; } | ||
3767 | 103 | |||
3768 | 104 | template < class T > | ||
3769 | 105 | static void cas ( void *arg ) | ||
3770 | 106 | { | ||
3771 | 107 | TestDataCAS < T > * const pTestData = | ||
3772 | 108 | reinterpret_cast < TestDataCAS < T > * > ( arg ); | ||
3773 | 109 | /* | ||
3774 | 110 | * intentionally waste cpu and maximize | ||
3775 | 111 | * contention for the shared data | ||
3776 | 112 | */ | ||
3777 | 113 | increment ( pTestData->m_testIterationsNotSet ); | ||
3778 | 114 | while ( ! compareAndSwap ( pTestData->m_testValue, | ||
3779 | 115 | falseValue < T > (), | ||
3780 | 116 | trueValue < T > () ) ) { | ||
3781 | 117 | } | ||
3782 | 118 | decrement ( pTestData->m_testIterationsNotSet ); | ||
3783 | 119 | set ( pTestData->m_testValue, falseValue < T > () ); | ||
3784 | 120 | increment ( pTestData->m_testIterationsSet ); | ||
3785 | 121 | } | ||
3786 | 122 | |||
3787 | 123 | template < class T > | ||
3788 | 124 | void testIncrDecr () | ||
3789 | 125 | { | ||
3790 | 126 | static const size_t N = 100; | ||
3791 | 127 | static const T NT = static_cast < T > ( N ); | ||
3792 | 128 | |||
3793 | 129 | const unsigned int stackSize = | ||
3794 | 130 | epicsThreadGetStackSize ( epicsThreadStackSmall ); | ||
3795 | 131 | |||
3796 | 132 | TestDataIncrDecr < T > testData = { 0, N }; | ||
3797 | 133 | set ( testData.m_testValue, NT ); | ||
3798 | 134 | testOk ( get ( testData.m_testValue ) == NT, | ||
3799 | 135 | "set/get %u", testData.m_testValue ); | ||
3800 | 136 | set ( testData.m_testIterations, 0u ); | ||
3801 | 137 | testOk ( get ( testData.m_testIterations ) == 0u, | ||
3802 | 138 | "set/get %u", testData.m_testIterations ); | ||
3803 | 139 | for ( size_t i = 0u; i < N; i++ ) { | ||
3804 | 140 | epicsThreadCreate ( "incr", | ||
3805 | 141 | 50, stackSize, incr < T >, & testData ); | ||
3806 | 142 | epicsThreadCreate ( "decr", | ||
3807 | 143 | 50, stackSize, decr < T >, & testData ); | ||
3808 | 144 | } | ||
3809 | 145 | while ( testData.m_testIterations < 2 * N ) { | ||
3810 | 146 | epicsThreadSleep ( 0.01 ); | ||
3811 | 147 | } | ||
3812 | 148 | testOk ( get ( testData.m_testIterations ) == 2 * N, | ||
3813 | 149 | "incr/decr iterations %u", | ||
3814 | 150 | testData.m_testIterations ); | ||
3815 | 151 | testOk ( get ( testData.m_testValue ) == NT, | ||
3816 | 152 | "incr/decr final value %u", | ||
3817 | 153 | testData.m_testValue ); | ||
3818 | 154 | } | ||
3819 | 155 | |||
3820 | 156 | template < class T > | ||
3821 | 157 | void testAddSub () | ||
3822 | 158 | { | ||
3823 | 159 | static const size_t N = 100; | ||
3824 | 160 | static const T NDT = TestDataAddSub < T > :: delta * | ||
3825 | 161 | static_cast < T > ( N ); | ||
3826 | 162 | |||
3827 | 163 | const unsigned int stackSize = | ||
3828 | 164 | epicsThreadGetStackSize ( epicsThreadStackSmall ); | ||
3829 | 165 | |||
3830 | 166 | TestDataIncrDecr < T > testData = { 0, N }; | ||
3831 | 167 | set ( testData.m_testValue, NDT ); | ||
3832 | 168 | testOk ( get ( testData.m_testValue ) == NDT, | ||
3833 | 169 | "set/get %u", testData.m_testValue ); | ||
3834 | 170 | set ( testData.m_testIterations, 0u ); | ||
3835 | 171 | testOk ( get ( testData.m_testIterations ) == 0u, | ||
3836 | 172 | "set/get %u", testData.m_testIterations ); | ||
3837 | 173 | for ( size_t i = 0u; i < N; i++ ) { | ||
3838 | 174 | epicsThreadCreate ( "add", | ||
3839 | 175 | 50, stackSize, add < T >, & testData ); | ||
3840 | 176 | epicsThreadCreate ( "sub", | ||
3841 | 177 | 50, stackSize, sub < T >, & testData ); | ||
3842 | 178 | } | ||
3843 | 179 | while ( testData.m_testIterations < 2 * N ) { | ||
3844 | 180 | epicsThreadSleep ( 0.01 ); | ||
3845 | 181 | } | ||
3846 | 182 | testOk ( get ( testData.m_testIterations ) == 2 * N, | ||
3847 | 183 | "add/sub iterations %u", | ||
3848 | 184 | testData.m_testIterations ); | ||
3849 | 185 | testOk ( get ( testData.m_testValue ) == NDT, | ||
3850 | 186 | "add/sub final value %u", | ||
3851 | 187 | testData.m_testValue ); | ||
3852 | 188 | } | ||
3853 | 189 | |||
3854 | 190 | template < class T > | ||
3855 | 191 | void testCAS () | ||
3856 | 192 | { | ||
3857 | 193 | static const size_t N = 10; | ||
3858 | 194 | |||
3859 | 195 | const unsigned int stackSize = | ||
3860 | 196 | epicsThreadGetStackSize ( epicsThreadStackSmall ); | ||
3861 | 197 | |||
3862 | 198 | TestDataCAS < T > testData = { 0, N, N }; | ||
3863 | 199 | set ( testData.m_testIterationsSet, 0 ); | ||
3864 | 200 | testOk ( get ( testData.m_testIterationsSet ) == 0u, | ||
3865 | 201 | "set/get %u", testData.m_testIterationsSet ); | ||
3866 | 202 | set ( testData.m_testIterationsNotSet, 0 ); | ||
3867 | 203 | testOk ( get ( testData.m_testIterationsNotSet ) == 0u, | ||
3868 | 204 | "set/get %u", testData.m_testIterationsNotSet ); | ||
3869 | 205 | set ( testData.m_testValue, trueValue < T > () ); | ||
3870 | 206 | testOk ( get ( testData.m_testValue ) == trueValue < T > (), | ||
3871 | 207 | "set/get a true value" ); | ||
3872 | 208 | for ( size_t i = 0u; i < N; i++ ) { | ||
3873 | 209 | epicsThreadCreate ( "tns", | ||
3874 | 210 | 50, stackSize, cas < T >, & testData ); | ||
3875 | 211 | } | ||
3876 | 212 | set ( testData.m_testValue, falseValue < T > () ); | ||
3877 | 213 | while ( testData.m_testIterationsSet < N ) { | ||
3878 | 214 | epicsThreadSleep ( 0.01 ); | ||
3879 | 215 | } | ||
3880 | 216 | testOk ( get ( testData.m_testIterationsSet ) == N, | ||
3881 | 217 | "test and set iterations %u", | ||
3882 | 218 | testData.m_testIterationsSet ); | ||
3883 | 219 | testOk ( get ( testData.m_testIterationsNotSet ) == 0u, | ||
3884 | 220 | "test and set not-set tracking = %u", | ||
3885 | 221 | testData.m_testIterationsNotSet ); | ||
3886 | 222 | } | ||
3887 | 223 | |||
3888 | 224 | MAIN ( epicsAtomicTest ) | ||
3889 | 225 | { | ||
3890 | 226 | |||
3891 | 227 | testPlan ( 31 ); | ||
3892 | 228 | |||
3893 | 229 | testIncrDecr < int > (); | ||
3894 | 230 | testIncrDecr < size_t > (); | ||
3895 | 231 | testAddSub < int > (); | ||
3896 | 232 | testAddSub < size_t > (); | ||
3897 | 233 | testCAS < int > (); | ||
3898 | 234 | testCAS < size_t > (); | ||
3899 | 235 | testCAS < EpicsAtomicPtrT > (); | ||
3900 | 236 | |||
3901 | 237 | return testDone (); | ||
3902 | 238 | } |