00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00047 #ifndef WINSTL_INCL_WINSTL_SYNCH_H_ATOMIC_FUNCTIONS
00048 #define WINSTL_INCL_WINSTL_SYNCH_H_ATOMIC_FUNCTIONS
00049
00050 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00051 # define WINSTL_VER_WINSTL_SYNCH_H_ATOMIC_FUNCTIONS_MAJOR 4
00052 # define WINSTL_VER_WINSTL_SYNCH_H_ATOMIC_FUNCTIONS_MINOR 4
00053 # define WINSTL_VER_WINSTL_SYNCH_H_ATOMIC_FUNCTIONS_REVISION 1
00054 # define WINSTL_VER_WINSTL_SYNCH_H_ATOMIC_FUNCTIONS_EDIT 203
00055 #endif
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 #ifndef WINSTL_INCL_WINSTL_H_WINSTL
00072 # include <winstl/winstl.h>
00073 #endif
00074 #ifndef WINSTL_INCL_WINSTL_SYNCH_H_ATOMIC_TYPES
00075 # include <winstl/synch/atomic_types.h>
00076 #endif
00077 #ifdef __cplusplus
00078 # ifndef WINSTL_INCL_WINSTL_SYNCH_HPP_SPIN_MUTEX
00079 # include <winstl/synch/spin_mutex.hpp>
00080 # endif
00081 #endif
00082
00083
00084
00085
00086
00087 #if !defined(WINSTL_ARCH_IS_X86) && \
00088 !defined(WINSTL_ARCH_IS_IA64) && \
00089 !defined(WINSTL_ARCH_IS_X64)
00090 # error Not valid for processors other than Intel
00091 #endif
00092
00093 #ifdef STLSOFT_ATOMIC_CALLCONV
00094 # undef STLSOFT_ATOMIC_CALLCONV
00095 #endif
00096 #ifdef WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL
00097 # undef WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL
00098 #endif
00099 #ifdef WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL
00100 # undef WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL
00101 #endif
00102
00103 #ifndef STLSOFT_NO_FASTCALL
00104 # if defined(STLSOFT_COMPILER_IS_BORLAND) || \
00105 defined(STLSOFT_COMPILER_IS_DMC) || \
00106 defined(STLSOFT_COMPILER_IS_WATCOM)
00107 # define STLSOFT_NO_FASTCALL
00108 # endif
00109 #endif
00110
00111 #if defined(WINSTL_ARCH_IS_X86)
00112
00113 # if defined(STLSOFT_CF_FASTCALL_SUPPORTED) && \
00114 !defined(STLSOFT_NO_FASTCALL)
00115 # define WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL
00116 # define WINSTL_ATOMIC_FNS_CALLCONV __fastcall
00117 # elif defined(STLSOFT_CF_STDCALL_SUPPORTED)
00118 # define WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL
00119 # define WINSTL_ATOMIC_FNS_CALLCONV __stdcall
00120 # else
00121 # error Need to define calling convention
00122 # endif
00123
00124 #elif defined(WINSTL_ARCH_IS_IA64) || \
00125 defined(WINSTL_ARCH_IS_X64)
00126
00127 # define WINSTL_ATOMIC_FNS_CALLCONV_IS_CDECL
00128 # define WINSTL_ATOMIC_FNS_CALLCONV __cdecl
00129
00130 #else
00131 # error Only defined for the Intel x86 and IA64 architectures
00132 #endif
00133
00134
00135
00136
00137
00138 #ifndef _WINSTL_NO_NAMESPACE
00139 # if defined(_STLSOFT_NO_NAMESPACE) || \
00140 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00141
00142 namespace winstl
00143 {
00144 # else
00145
00146
00147 namespace stlsoft
00148 {
00149
00150 namespace winstl_project
00151 {
00152
00153 # endif
00154 #endif
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166 #ifdef WINSTL_ATOMIC_FNS_DECL_
00167 # undef WINSTL_ATOMIC_FNS_DECL_
00168 #endif
00169
00170 #ifdef WINSTL_ATOMIC_FNS_IMPL_
00171 # undef WINSTL_ATOMIC_FNS_IMPL_
00172 #endif
00173
00174 #if defined(WINSTL_ATOMIC_FNS_DECLARATION_ONLY)
00175
00176 # define WINSTL_ATOMIC_FNS_DECL_(type) type WINSTL_ATOMIC_FNS_CALLCONV
00177 #elif defined(WINSTL_ATOMIC_FNS_DEFINITION)
00178
00179 # ifdef STSLSOFT_INLINE_ASM_SUPPORTED
00180 # define WINSTL_ATOMIC_FNS_IMPL_(type) __declspec(naked) type WINSTL_ATOMIC_FNS_CALLCONV
00181 # else
00182 # define WINSTL_ATOMIC_FNS_IMPL_(type) type WINSTL_ATOMIC_FNS_CALLCONV
00183 # endif
00184 #else
00185 # if defined(STLSOFT_COMPILER_IS_MWERKS) && \
00186 (__MWERKS__ & 0xFF00) < 0x3000
00187 # error CodeWarrior 7 and earlier does not generate correct code when inline naked functions are used
00188 # endif
00189
00190 #if !defined(__cplusplus) && \
00191 defined(STSLSOFT_INLINE_ASM_SUPPORTED)
00192
00193 # undef STSLSOFT_INLINE_ASM_SUPPORTED
00194 #endif
00195
00196 # ifdef STSLSOFT_INLINE_ASM_SUPPORTED
00197
00198 # ifdef STSLSOFT_ASM_IN_INLINE_SUPPORTED
00199 # define WINSTL_ATOMIC_FNS_DECL_(type) inline type WINSTL_ATOMIC_FNS_CALLCONV
00200 # define WINSTL_ATOMIC_FNS_IMPL_(type) inline __declspec(naked) type WINSTL_ATOMIC_FNS_CALLCONV
00201 # else
00202 # define WINSTL_ATOMIC_FNS_DECL_(type) type WINSTL_ATOMIC_FNS_CALLCONV
00203 # define WINSTL_ATOMIC_FNS_IMPL_(type) static __declspec(naked) type WINSTL_ATOMIC_FNS_CALLCONV
00204 # endif
00205 # else
00206
00207 # if defined(__cplusplus)
00208 # define WINSTL_ATOMIC_FNS_DECL_(type) inline type WINSTL_ATOMIC_FNS_CALLCONV
00209 # define WINSTL_ATOMIC_FNS_IMPL_(type) inline type WINSTL_ATOMIC_FNS_CALLCONV
00210 # else
00211 # define WINSTL_ATOMIC_FNS_DECL_(type) STLSOFT_INLINE type WINSTL_ATOMIC_FNS_CALLCONV
00212 # define WINSTL_ATOMIC_FNS_IMPL_(type) STLSOFT_INLINE type WINSTL_ATOMIC_FNS_CALLCONV
00213 # endif
00214 # endif
00215 #endif
00216
00217
00218
00219
00220
00221 #ifndef WINSTL_ATOMIC_FNS_DEFINITION
00222
00223
00224 WINSTL_ATOMIC_FNS_DECL_(atomic_int_t) atomic_preincrement_up(atomic_int_t volatile* pl);
00225 WINSTL_ATOMIC_FNS_DECL_(atomic_int_t) atomic_predecrement_up(atomic_int_t volatile* pl);
00226 WINSTL_ATOMIC_FNS_DECL_(atomic_int_t) atomic_postincrement_up(atomic_int_t volatile* pl);
00227 WINSTL_ATOMIC_FNS_DECL_(atomic_int_t) atomic_postdecrement_up(atomic_int_t volatile* pl);
00228 WINSTL_ATOMIC_FNS_DECL_(void) atomic_increment_up(atomic_int_t volatile* pl);
00229 WINSTL_ATOMIC_FNS_DECL_(void) atomic_decrement_up(atomic_int_t volatile* pl);
00230
00231 WINSTL_ATOMIC_FNS_DECL_(atomic_int_t) atomic_write_up(atomic_int_t volatile* pl, atomic_int_t n);
00232 WINSTL_ATOMIC_FNS_DECL_(atomic_int_t) atomic_read_up(atomic_int_t volatile const* pl);
00233
00234 WINSTL_ATOMIC_FNS_DECL_(atomic_int_t) atomic_postadd_up(atomic_int_t volatile* pl, atomic_int_t n);
00235 STLSOFT_INLINE atomic_int_t atomic_preadd_up(atomic_int_t volatile* pl, atomic_int_t n);
00236
00237
00238
00239
00240 WINSTL_ATOMIC_FNS_DECL_(atomic_int_t) atomic_preincrement_smp(atomic_int_t volatile* pl);
00241 WINSTL_ATOMIC_FNS_DECL_(atomic_int_t) atomic_predecrement_smp(atomic_int_t volatile* pl);
00242 WINSTL_ATOMIC_FNS_DECL_(atomic_int_t) atomic_postincrement_smp(atomic_int_t volatile* pl);
00243 WINSTL_ATOMIC_FNS_DECL_(atomic_int_t) atomic_postdecrement_smp(atomic_int_t volatile* pl);
00244 STLSOFT_INLINE void atomic_increment_smp(atomic_int_t volatile* pl);
00245 STLSOFT_INLINE void atomic_decrement_smp(atomic_int_t volatile* pl);
00246
00247 WINSTL_ATOMIC_FNS_DECL_(atomic_int_t) atomic_write_smp(atomic_int_t volatile* pl, atomic_int_t n);
00248 WINSTL_ATOMIC_FNS_DECL_(atomic_int_t) atomic_read_smp(atomic_int_t volatile const* pl);
00249
00250 WINSTL_ATOMIC_FNS_DECL_(atomic_int_t) atomic_postadd_smp(atomic_int_t volatile* pl, atomic_int_t n);
00251 STLSOFT_INLINE atomic_int_t atomic_preadd_smp(atomic_int_t volatile* pl, atomic_int_t n);
00252
00253
00254
00255
00256 WINSTL_ATOMIC_FNS_DECL_(atomic_int_t) atomic_preincrement(atomic_int_t volatile* pl);
00257 WINSTL_ATOMIC_FNS_DECL_(atomic_int_t) atomic_predecrement(atomic_int_t volatile* pl);
00258 WINSTL_ATOMIC_FNS_DECL_(atomic_int_t) atomic_postincrement(atomic_int_t volatile* pl);
00259 WINSTL_ATOMIC_FNS_DECL_(atomic_int_t) atomic_postdecrement(atomic_int_t volatile* pl);
00260 WINSTL_ATOMIC_FNS_DECL_(void) atomic_increment(atomic_int_t volatile* pl);
00261 WINSTL_ATOMIC_FNS_DECL_(void) atomic_decrement(atomic_int_t volatile* pl);
00262
00263 WINSTL_ATOMIC_FNS_DECL_(atomic_int_t) atomic_write(atomic_int_t volatile* pl, atomic_int_t n);
00264 WINSTL_ATOMIC_FNS_DECL_(atomic_int_t) atomic_read(atomic_int_t volatile const* pl);
00265
00266 WINSTL_ATOMIC_FNS_DECL_(atomic_int_t) atomic_postadd(atomic_int_t volatile* pl, atomic_int_t n);
00267 STLSOFT_INLINE atomic_int_t atomic_preadd(atomic_int_t volatile* pl, atomic_int_t n);
00268
00269
00270 #endif
00271
00272
00273
00274
00275
00276 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00277
00278 # if !defined(WINSTL_ATOMIC_FNS_DECLARATION_ONLY)
00279
00280 # ifdef STSLSOFT_INLINE_ASM_SUPPORTED
00281
00282
00283 #ifdef STLSOFT_COMPILER_IS_BORLAND
00284 # pragma warn -8002
00285 # pragma warn -8070
00286 #endif
00287
00288
00289
00294 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_preincrement_up(atomic_int_t volatile* )
00295 {
00296 _asm
00297 {
00298
00299
00300
00301 mov eax, 1
00302
00303 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00304
00305 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00306
00307
00308 mov ecx, dword ptr [esp + 4]
00309 #else
00310 # error Need to define calling convention
00311 #endif
00312
00313 xadd dword ptr [ecx], eax
00314
00315
00316
00317
00318 inc eax
00319
00320 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00321 ret
00322 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00323 ret 4
00324 #endif
00325 }
00326 }
00327
00332 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_predecrement_up(atomic_int_t volatile* )
00333 {
00334 _asm
00335 {
00336
00337
00338
00339 mov eax, -1
00340
00341 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00342
00343 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00344
00345
00346 mov ecx, dword ptr [esp + 4]
00347 #else
00348 # error Need to define calling convention
00349 #endif
00350
00351 xadd dword ptr [ecx], eax
00352
00353
00354
00355
00356 dec eax
00357
00358 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00359 ret
00360 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00361 ret 4
00362 #endif
00363 }
00364 }
00365
00370 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_postincrement_up(atomic_int_t volatile* )
00371 {
00372 _asm
00373 {
00374
00375
00376
00377 mov eax, 1
00378
00379 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00380
00381 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00382
00383
00384 mov ecx, dword ptr [esp + 4]
00385 #else
00386 # error Need to define calling convention
00387 #endif
00388
00389 xadd dword ptr [ecx], eax
00390
00391
00392
00393
00394
00395 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00396 ret
00397 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00398 ret 4
00399 #endif
00400 }
00401 }
00402
00407 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_postdecrement_up(atomic_int_t volatile* )
00408 {
00409 _asm
00410 {
00411
00412
00413
00414 mov eax, -1
00415
00416 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00417
00418 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00419
00420
00421 mov ecx, dword ptr [esp + 4]
00422 #else
00423 # error Need to define calling convention
00424 #endif
00425
00426 xadd dword ptr [ecx], eax
00427
00428
00429
00430
00431
00432 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00433 ret
00434 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00435 ret 4
00436 #endif
00437 }
00438 }
00439
00444 WINSTL_ATOMIC_FNS_IMPL_(void) atomic_increment_up(atomic_int_t volatile* )
00445 {
00446 _asm
00447 {
00448 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00449
00450 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00451
00452
00453 mov ecx, dword ptr [esp + 4]
00454 #else
00455 # error Need to define calling convention
00456 #endif
00457
00458 add dword ptr [ecx], 1
00459
00460 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00461 ret
00462 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00463 ret 4
00464 #endif
00465 }
00466 }
00467
00472 WINSTL_ATOMIC_FNS_IMPL_(void) atomic_decrement_up(atomic_int_t volatile* )
00473 {
00474 _asm
00475 {
00476 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00477
00478 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00479
00480
00481 mov ecx, dword ptr [esp + 4]
00482 #else
00483 # error Need to define calling convention
00484 #endif
00485
00486 sub dword ptr [ecx], 1
00487
00488 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00489 ret
00490 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00491 ret 4
00492 #endif
00493 }
00494 }
00495
00500 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_read_up(atomic_int_t volatile const* )
00501 {
00502 _asm
00503 {
00504 mov eax, 0
00505 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00506
00507
00508 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00509
00510 mov ecx, dword ptr [esp + 4]
00511 #else
00512 # error Need to define calling convention
00513 #endif
00514
00515
00516
00517
00518 xadd dword ptr [ecx], eax
00519
00520
00521
00522
00523
00524 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00525 ret
00526 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00527 ret 4
00528 #endif
00529 }
00530 }
00531
00536 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_write_up(atomic_int_t volatile* , atomic_int_t )
00537 {
00538 _asm
00539 {
00540 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00541
00542
00543
00544 xchg dword ptr [ecx], edx
00545
00546
00547 mov eax, edx
00548
00549 ret
00550 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00551
00552 mov ecx, dword ptr [esp + 4]
00553 mov eax, dword ptr [esp + 8]
00554
00555 xchg dword ptr [ecx], eax
00556
00557 ret 8
00558 #else
00559 # error Need to define calling convention
00560 #endif
00561 }
00562 }
00563
00564
00569 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_postadd_up(atomic_int_t volatile* , atomic_int_t )
00570 {
00571
00572 __asm
00573 {
00574 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00575
00576
00577
00578
00579
00580 xadd dword ptr [ecx], edx
00581
00582
00583 mov eax, edx
00584
00585 ret
00586 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00587
00588
00589
00590
00591
00592 mov ecx, dword ptr [esp + 4]
00593 mov eax, dword ptr [esp + 8]
00594
00595 xadd dword ptr [ecx], eax
00596
00597
00598
00599 ret 8
00600 #else
00601 # error Need to define calling convention
00602 #endif
00603 }
00604 }
00605
00606
00607
00612 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_preincrement_smp(atomic_int_t volatile* )
00613 {
00614 _asm
00615 {
00616
00617
00618
00619 mov eax, 1
00620
00621 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00622
00623 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00624
00625
00626 mov ecx, dword ptr [esp + 4]
00627 #else
00628 # error Need to define calling convention
00629 #endif
00630
00631 lock xadd dword ptr [ecx], eax
00632
00633
00634
00635
00636 inc eax
00637
00638 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00639 ret
00640 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00641 ret 4
00642 #endif
00643 }
00644 }
00645
00650 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_predecrement_smp(atomic_int_t volatile* )
00651 {
00652 _asm
00653 {
00654
00655
00656
00657 mov eax, -1
00658
00659 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00660
00661 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00662
00663
00664 mov ecx, dword ptr [esp + 4]
00665 #else
00666 # error Need to define calling convention
00667 #endif
00668
00669 lock xadd dword ptr [ecx], eax
00670
00671
00672
00673
00674 dec eax
00675
00676 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00677 ret
00678 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00679 ret 4
00680 #endif
00681 }
00682 }
00683
00688 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_postincrement_smp(atomic_int_t volatile* )
00689 {
00690 _asm
00691 {
00692
00693
00694
00695 mov eax, 1
00696
00697 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00698
00699 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00700
00701
00702 mov ecx, dword ptr [esp + 4]
00703 #else
00704 # error Need to define calling convention
00705 #endif
00706
00707 lock xadd dword ptr [ecx], eax
00708
00709
00710
00711
00712
00713 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00714 ret
00715 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00716 ret 4
00717 #endif
00718 }
00719 }
00720
00725 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_postdecrement_smp(atomic_int_t volatile* )
00726 {
00727 _asm
00728 {
00729
00730
00731
00732 mov eax, -1
00733
00734 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00735
00736 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00737
00738
00739 mov ecx, dword ptr [esp + 4]
00740 #else
00741 # error Need to define calling convention
00742 #endif
00743
00744 lock xadd dword ptr [ecx], eax
00745
00746
00747
00748
00749
00750 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00751 ret
00752 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00753 ret 4
00754 #endif
00755 }
00756 }
00757
00762 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_read_smp(atomic_int_t volatile const* )
00763 {
00764 _asm
00765 {
00766 mov eax, 0
00767 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00768
00769
00770 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00771
00772 mov ecx, dword ptr [esp + 4]
00773 #else
00774 # error Need to define calling convention
00775 #endif
00776
00777
00778
00779
00780 lock xadd dword ptr [ecx], eax
00781
00782
00783
00784
00785
00786 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00787 ret
00788 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00789 ret 4
00790 #endif
00791 }
00792 }
00793
00798 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_write_smp(atomic_int_t volatile* , atomic_int_t )
00799 {
00800 _asm
00801 {
00802 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00803
00804
00805
00806 xchg dword ptr [ecx], edx
00807
00808
00809 mov eax, edx
00810
00811 ret
00812 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00813
00814 mov ecx, dword ptr [esp + 4]
00815 mov eax, dword ptr [esp + 8]
00816
00817 xchg dword ptr [ecx], eax
00818
00819 ret 8
00820 #else
00821 # error Need to define calling convention
00822 #endif
00823 }
00824 }
00825
00826
00831 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_postadd_smp(atomic_int_t volatile* , atomic_int_t )
00832 {
00833
00834 __asm
00835 {
00836 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00837
00838
00839
00840
00841
00842 lock xadd dword ptr [ecx], edx
00843
00844
00845 mov eax, edx
00846
00847 ret
00848 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00849
00850
00851
00852
00853
00854 mov ecx, dword ptr [esp + 4]
00855 mov eax, dword ptr [esp + 8]
00856
00857 lock xadd dword ptr [ecx], eax
00858
00859
00860
00861 ret 8
00862 #else
00863 # error Need to define calling convention
00864 #endif
00865 }
00866 }
00867
00868
00869
00870 namespace
00871 {
00872 inline ws_bool_t is_host_up()
00873 {
00874
00875 static atomic_int_t s_spin;
00876 static ws_bool_t s_init;
00877 static ws_bool_t s_up;
00878
00879
00880 if(!s_init)
00881 {
00882 spin_mutex smx(&s_spin);
00883
00884 smx.lock();
00885 if(!s_init)
00886 {
00887 SYSTEM_INFO sys_info;
00888
00889 ::GetSystemInfo(&sys_info);
00890
00891 s_init = true;
00892
00893 s_up = 1 == sys_info.dwNumberOfProcessors;
00894 }
00895 smx.unlock();
00896 }
00897
00898 return s_up;
00899 }
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913 static ws_bool_t s_up = is_host_up();
00914 }
00915
00920 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_preincrement(atomic_int_t volatile* )
00921 {
00922 if(s_up)
00923 {
00924 _asm
00925 {
00926
00927
00928
00929 mov eax, 1
00930
00931 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00932
00933 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00934
00935
00936 mov ecx, dword ptr [esp + 4]
00937 #else
00938 # error Need to define calling convention
00939 #endif
00940
00941 xadd dword ptr [ecx], eax
00942
00943
00944
00945
00946 inc eax
00947
00948 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00949 ret
00950 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00951 ret 4
00952 #endif
00953 }
00954 }
00955 else
00956 {
00957 _asm
00958 {
00959
00960
00961
00962 mov eax, 1
00963
00964 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00965
00966 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00967
00968
00969 mov ecx, dword ptr [esp + 4]
00970 #else
00971 # error Need to define calling convention
00972 #endif
00973
00974 lock xadd dword ptr [ecx], eax
00975
00976
00977
00978
00979 inc eax
00980
00981 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
00982 ret
00983 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
00984 ret 4
00985 #endif
00986 }
00987 }
00988 }
00989
00994 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_predecrement(atomic_int_t volatile* )
00995 {
00996 if(s_up)
00997 {
00998 _asm
00999 {
01000
01001
01002
01003 mov eax, -1
01004
01005 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01006
01007 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01008
01009
01010 mov ecx, dword ptr [esp + 4]
01011 #else
01012 # error Need to define calling convention
01013 #endif
01014
01015 xadd dword ptr [ecx], eax
01016
01017
01018
01019
01020 dec eax
01021
01022 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01023 ret
01024 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01025 ret 4
01026 #endif
01027 }
01028 }
01029 else
01030 {
01031 _asm
01032 {
01033
01034
01035
01036 mov eax, -1
01037
01038 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01039
01040 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01041
01042
01043 mov ecx, dword ptr [esp + 4]
01044 #else
01045 # error Need to define calling convention
01046 #endif
01047
01048 lock xadd dword ptr [ecx], eax
01049
01050
01051
01052
01053 dec eax
01054
01055 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01056 ret
01057 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01058 ret 4
01059 #endif
01060 }
01061 }
01062 }
01063
01068 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_postincrement(atomic_int_t volatile* )
01069 {
01070 if(s_up)
01071 {
01072 _asm
01073 {
01074
01075
01076
01077 mov eax, 1
01078
01079 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01080
01081 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01082
01083
01084 mov ecx, dword ptr [esp + 4]
01085 #else
01086 # error Need to define calling convention
01087 #endif
01088
01089 xadd dword ptr [ecx], eax
01090
01091
01092
01093
01094
01095 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01096 ret
01097 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01098 ret 4
01099 #endif
01100 }
01101 }
01102 else
01103 {
01104 _asm
01105 {
01106
01107
01108
01109 mov eax, 1
01110
01111 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01112
01113 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01114
01115
01116 mov ecx, dword ptr [esp + 4]
01117 #else
01118 # error Need to define calling convention
01119 #endif
01120
01121 lock xadd dword ptr [ecx], eax
01122
01123
01124
01125
01126
01127 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01128 ret
01129 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01130 ret 4
01131 #endif
01132 }
01133 }
01134 }
01135
01140 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_postdecrement(atomic_int_t volatile* )
01141 {
01142 if(s_up)
01143 {
01144 _asm
01145 {
01146
01147
01148
01149 mov eax, -1
01150
01151 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01152
01153 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01154
01155
01156 mov ecx, dword ptr [esp + 4]
01157 #else
01158 # error Need to define calling convention
01159 #endif
01160
01161 xadd dword ptr [ecx], eax
01162
01163
01164
01165
01166
01167 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01168 ret
01169 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01170 ret 4
01171 #endif
01172 }
01173 }
01174 else
01175 {
01176 _asm
01177 {
01178
01179
01180
01181 mov eax, -1
01182
01183 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01184
01185 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01186
01187
01188 mov ecx, dword ptr [esp + 4]
01189 #else
01190 # error Need to define calling convention
01191 #endif
01192
01193 lock xadd dword ptr [ecx], eax
01194
01195
01196
01197
01198
01199 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01200 ret
01201 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01202 ret 4
01203 #endif
01204 }
01205 }
01206 }
01207
01212 WINSTL_ATOMIC_FNS_IMPL_(void) atomic_increment(atomic_int_t volatile* )
01213 {
01214 if(s_up)
01215 {
01216 _asm
01217 {
01218 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01219
01220 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01221
01222
01223 mov ecx, dword ptr [esp + 4]
01224 #else
01225 # error Need to define calling convention
01226 #endif
01227
01228 add dword ptr [ecx], 1
01229
01230 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01231 ret
01232 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01233 ret 4
01234 #endif
01235 }
01236 }
01237 else
01238 {
01239 _asm
01240 {
01241 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01242
01243 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01244
01245
01246 mov ecx, dword ptr [esp + 4]
01247 #else
01248 # error Need to define calling convention
01249 #endif
01250
01251
01252
01253
01254
01255 #if defined(STLSOFT_COMPILER_IS_VECTORC)
01256 mov eax, 1
01257 lock xadd dword ptr [ecx], eax
01258 #else
01259 lock add dword ptr [ecx], 1
01260 #endif
01261
01262
01263 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01264 ret
01265 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01266 ret 4
01267 #endif
01268 }
01269 }
01270 }
01271
01276 WINSTL_ATOMIC_FNS_IMPL_(void) atomic_decrement(atomic_int_t volatile* )
01277 {
01278 if(s_up)
01279 {
01280 _asm
01281 {
01282 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01283
01284 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01285
01286
01287 mov ecx, dword ptr [esp + 4]
01288 #else
01289 # error Need to define calling convention
01290 #endif
01291
01292 add dword ptr [ecx], -1
01293
01294 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01295 ret
01296 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01297 ret 4
01298 #endif
01299 }
01300 }
01301 else
01302 {
01303 _asm
01304 {
01305 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01306
01307 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01308
01309
01310 mov ecx, dword ptr [esp + 4]
01311 #else
01312 # error Need to define calling convention
01313 #endif
01314
01315 #if defined(STLSOFT_COMPILER_IS_VECTORC)
01316 mov eax, -1
01317 lock xadd dword ptr [ecx], eax
01318 #else
01319
01320 lock sub dword ptr [ecx], 1
01321 #endif
01322
01323 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01324 ret
01325 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01326 ret 4
01327 #endif
01328 }
01329 }
01330 }
01331
01336 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_read(atomic_int_t volatile const* )
01337 {
01338 if(s_up)
01339 {
01340 _asm
01341 {
01342 mov eax, 0
01343 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01344
01345
01346 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01347
01348 mov ecx, dword ptr [esp + 4]
01349 #else
01350 # error Need to define calling convention
01351 #endif
01352
01353
01354
01355
01356 xadd dword ptr [ecx], eax
01357
01358
01359
01360
01361
01362 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01363 ret
01364 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01365 ret 4
01366 #endif
01367 }
01368 }
01369 else
01370 {
01371 _asm
01372 {
01373 mov eax, 0
01374 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01375
01376
01377 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01378
01379 mov ecx, dword ptr [esp + 4]
01380 #else
01381 # error Need to define calling convention
01382 #endif
01383
01384
01385
01386
01387 lock xadd dword ptr [ecx], eax
01388
01389
01390
01391
01392
01393 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01394 ret
01395 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01396 ret 4
01397 #endif
01398 }
01399 }
01400 }
01401
01406 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_write(atomic_int_t volatile* , atomic_int_t )
01407 {
01408 _asm
01409 {
01410 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01411
01412
01413
01414 lock xchg dword ptr [ecx], edx
01415
01416
01417 mov eax, edx
01418
01419 ret
01420 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01421
01422 mov ecx, dword ptr [esp + 4]
01423 mov eax, dword ptr [esp + 8]
01424
01425 xchg dword ptr [ecx], eax
01426
01427 ret 8
01428 #else
01429 # error Need to define calling convention
01430 #endif
01431 }
01432 }
01433
01434
01439 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_postadd(atomic_int_t volatile* , atomic_int_t )
01440 {
01441
01442 if(s_up)
01443 {
01444 __asm
01445 {
01446 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01447
01448
01449
01450
01451
01452 xadd dword ptr [ecx], edx
01453
01454
01455 mov eax, edx
01456
01457 ret
01458 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01459
01460
01461
01462
01463
01464 mov ecx, dword ptr [esp + 4]
01465 mov eax, dword ptr [esp + 8]
01466
01467 xadd dword ptr [ecx], eax
01468
01469
01470
01471 ret 8
01472 #else
01473 # error Need to define calling convention
01474 #endif
01475 }
01476 }
01477 else
01478 {
01479 __asm
01480 {
01481 #if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL)
01482
01483
01484
01485
01486
01487 lock xadd dword ptr [ecx], edx
01488
01489
01490 mov eax, edx
01491
01492 ret
01493 #elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL)
01494
01495
01496
01497
01498
01499 mov ecx, dword ptr [esp + 4]
01500 mov eax, dword ptr [esp + 8]
01501
01502 lock xadd dword ptr [ecx], eax
01503
01504
01505
01506 ret 8
01507 #else
01508 # error Need to define calling convention
01509 #endif
01510 }
01511 }
01512 }
01513
01514 #ifdef STLSOFT_COMPILER_IS_BORLAND
01515 # pragma warn .8070
01516 # pragma warn .8002
01517 #endif
01518
01519 # else
01520
01521
01522
01523
01524
01525
01526
01527
01528
01533 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_preincrement(atomic_int_t volatile* pl)
01534 {
01535 #if defined(WINSTL_OS_IS_WIN32)
01536 return STLSOFT_NS_GLOBAL(InterlockedIncrement)((LPLONG)pl);
01537 #elif defined(WINSTL_OS_IS_WIN64)
01538 return STLSOFT_NS_GLOBAL(InterlockedDecrement64)((LONGLONG*)pl);
01539 #else
01540 # error Not valid for processors other than Intel
01541 #endif
01542 }
01543
01548 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_predecrement(atomic_int_t volatile* pl)
01549 {
01550 #if defined(WINSTL_OS_IS_WIN32)
01551 return STLSOFT_NS_GLOBAL(InterlockedDecrement)((LPLONG)pl);
01552 #elif defined(WINSTL_OS_IS_WIN64)
01553 return STLSOFT_NS_GLOBAL(InterlockedDecrement64)((LONGLONG*)pl);
01554 #else
01555 # error Not valid for processors other than Intel
01556 #endif
01557 }
01558
01563 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_postincrement(atomic_int_t volatile* pl)
01564 {
01565 atomic_int_t pre = *pl;
01566
01567 #if defined(WINSTL_OS_IS_WIN32)
01568 STLSOFT_NS_GLOBAL(InterlockedIncrement)((LPLONG)pl);
01569 #elif defined(WINSTL_OS_IS_WIN64)
01570 STLSOFT_NS_GLOBAL(InterlockedIncrement64)((LONGLONG*)pl);
01571 #else
01572 # error Not valid for processors other than Intel
01573 #endif
01574
01575 return pre;
01576 }
01577
01582 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_postdecrement(atomic_int_t volatile* pl)
01583 {
01584 atomic_int_t pre = *pl;
01585
01586 #if defined(WINSTL_OS_IS_WIN32)
01587 STLSOFT_NS_GLOBAL(InterlockedDecrement)((LPLONG)pl);
01588 #elif defined(WINSTL_OS_IS_WIN64)
01589 STLSOFT_NS_GLOBAL(InterlockedDecrement64)((LONGLONG*)pl);
01590 #else
01591 # error Not valid for processors other than Intel
01592 #endif
01593
01594 return pre;
01595 }
01596
01601 WINSTL_ATOMIC_FNS_IMPL_(void) atomic_increment(atomic_int_t volatile* pl)
01602 {
01603 #if defined(WINSTL_OS_IS_WIN32)
01604 STLSOFT_NS_GLOBAL(InterlockedIncrement)((LPLONG)pl);
01605 #elif defined(WINSTL_OS_IS_WIN64)
01606 STLSOFT_NS_GLOBAL(InterlockedIncrement64)((LONGLONG*)pl);
01607 #else
01608 # error Not valid for processors other than Intel
01609 #endif
01610 }
01611
01616 WINSTL_ATOMIC_FNS_IMPL_(void) atomic_decrement(atomic_int_t volatile* pl)
01617 {
01618 #if defined(WINSTL_OS_IS_WIN32)
01619 STLSOFT_NS_GLOBAL(InterlockedDecrement)((LPLONG)pl);
01620 #elif defined(WINSTL_OS_IS_WIN64)
01621 STLSOFT_NS_GLOBAL(InterlockedDecrement64)((LONGLONG*)pl);
01622 #else
01623 # error Not valid for processors other than Intel
01624 #endif
01625 }
01626
01631 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_write(atomic_int_t volatile* pl, atomic_int_t n)
01632 {
01633 #if defined(WINSTL_OS_IS_WIN32)
01634 return STLSOFT_NS_GLOBAL(InterlockedExchange)((LPLONG)pl, n);
01635 #elif defined(WINSTL_OS_IS_WIN64)
01636 return STLSOFT_NS_GLOBAL(InterlockedExchange64)((LONGLONG*)pl, n);
01637 #else
01638 # error Not valid for processors other than Intel
01639 #endif
01640 }
01641
01646 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_read(atomic_int_t volatile const* pl)
01647 {
01648 return *pl;
01649 }
01650
01655 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_postadd(atomic_int_t volatile* pl, atomic_int_t n)
01656 {
01657 #if defined(WINSTL_OS_IS_WIN32)
01658 return (atomic_int_t)STLSOFT_NS_GLOBAL(InterlockedExchangeAdd)((LPLONG)pl, n);
01659 #elif defined(WINSTL_OS_IS_WIN64)
01660 return (atomic_int_t)STLSOFT_NS_GLOBAL(InterlockedExchangeAdd64)((LONGLONG*)pl, n);
01661 #else
01662 # error Not valid for processors other than Intel
01663 #endif
01664 }
01665
01666
01667
01668
01673 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_preincrement_up(atomic_int_t volatile* pl)
01674 {
01675 return atomic_preincrement(pl);
01676 }
01677
01682 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_predecrement_up(atomic_int_t volatile* pl)
01683 {
01684 return atomic_predecrement(pl);
01685 }
01686
01691 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_postincrement_up(atomic_int_t volatile* pl)
01692 {
01693 return atomic_postincrement(pl);
01694 }
01695
01700 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_postdecrement_up(atomic_int_t volatile* pl)
01701 {
01702 return atomic_postdecrement(pl);
01703 }
01704
01709 WINSTL_ATOMIC_FNS_IMPL_(void) atomic_increment_up(atomic_int_t volatile* pl)
01710 {
01711 atomic_increment(pl);
01712 }
01713
01718 WINSTL_ATOMIC_FNS_IMPL_(void) atomic_decrement_up(atomic_int_t volatile* pl)
01719 {
01720 atomic_decrement(pl);
01721 }
01722
01727 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_write_up(atomic_int_t volatile* pl, atomic_int_t n)
01728 {
01729 return atomic_write(pl, n);
01730 }
01731
01736 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_read_up(atomic_int_t volatile const* pl)
01737 {
01738 return *pl;
01739 }
01740
01745 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_postadd_up(atomic_int_t volatile* pl, atomic_int_t n)
01746 {
01747 #if defined(WINSTL_OS_IS_WIN32)
01748 return (atomic_int_t)STLSOFT_NS_GLOBAL(InterlockedExchangeAdd)((LPLONG)pl, n);
01749 #elif defined(WINSTL_OS_IS_WIN64)
01750 return (atomic_int_t)STLSOFT_NS_GLOBAL(InterlockedExchangeAdd64)((LONGLONG*)pl, n);
01751 #else
01752 # error Not valid for processors other than Intel
01753 #endif
01754 }
01755
01756
01757
01762 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_preincrement_smp(atomic_int_t volatile* pl)
01763 {
01764 return atomic_preincrement(pl);
01765 }
01766
01771 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_predecrement_smp(atomic_int_t volatile* pl)
01772 {
01773 return atomic_predecrement(pl);
01774 }
01775
01780 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_postincrement_smp(atomic_int_t volatile* pl)
01781 {
01782 return atomic_postincrement(pl);
01783 }
01784
01789 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_postdecrement_smp(atomic_int_t volatile* pl)
01790 {
01791 return atomic_postdecrement(pl);
01792 }
01793
01798 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_write_smp(atomic_int_t volatile* pl, atomic_int_t n)
01799 {
01800 return atomic_write(pl, n);
01801 }
01802
01807 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_read_smp(atomic_int_t volatile const* pl)
01808 {
01809 return *pl;
01810 }
01811
01816 WINSTL_ATOMIC_FNS_IMPL_(atomic_int_t) atomic_postadd_smp(atomic_int_t volatile* pl, atomic_int_t n)
01817 {
01818 #if defined(WINSTL_OS_IS_WIN32)
01819 return (atomic_int_t)STLSOFT_NS_GLOBAL(InterlockedExchangeAdd)((LPLONG)pl, n);
01820 #elif defined(WINSTL_OS_IS_WIN64)
01821 return (atomic_int_t)STLSOFT_NS_GLOBAL(InterlockedExchangeAdd64)((LONGLONG*)pl, n);
01822 #else
01823 # error Not valid for processors other than Intel
01824 #endif
01825 }
01826
01827 # endif
01828
01829 # endif
01830
01831
01832
01833
01834
01839 STLSOFT_INLINE atomic_int_t atomic_preadd_up(atomic_int_t volatile* pl, atomic_int_t n)
01840 {
01841 return n + atomic_postadd_up(pl, n);
01842 }
01843
01848 STLSOFT_INLINE void atomic_increment_smp(atomic_int_t volatile* pl)
01849 {
01850 atomic_postincrement_smp(pl);
01851 }
01852
01857 STLSOFT_INLINE void atomic_decrement_smp(atomic_int_t volatile* pl)
01858 {
01859 atomic_postdecrement_smp(pl);
01860 }
01861
01866 STLSOFT_INLINE atomic_int_t atomic_preadd_smp(atomic_int_t volatile* pl, atomic_int_t n)
01867 {
01868 return n + atomic_postadd_smp(pl, n);
01869 }
01870
01875 STLSOFT_INLINE atomic_int_t atomic_preadd(atomic_int_t volatile* pl, atomic_int_t n)
01876 {
01877 return n + atomic_postadd(pl, n);
01878 }
01879
01880 #endif
01881
01882
01883
01884
01885
01886 #ifdef STLSOFT_UNITTEST
01887 # include "./unittest/atomic_functions_unittest_.h"
01888 #endif
01889
01890
01891
01892 #ifndef _WINSTL_NO_NAMESPACE
01893 # if defined(_STLSOFT_NO_NAMESPACE) || \
01894 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
01895 }
01896 # else
01897 }
01898 }
01899 # endif
01900 #endif
01901
01902
01903
01904 #endif
01905
01906