noderb 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/noderb_extension/libuv/AUTHORS +11 -1
- data/ext/noderb_extension/libuv/LICENSE +0 -8
- data/ext/noderb_extension/libuv/Makefile +5 -5
- data/ext/noderb_extension/libuv/README +11 -6
- data/ext/noderb_extension/libuv/common.gypi +158 -7
- data/ext/noderb_extension/libuv/config-unix.mk +34 -26
- data/ext/noderb_extension/libuv/gyp_uv +22 -4
- data/ext/noderb_extension/libuv/include/{eio.h → uv-private/eio.h} +2 -2
- data/ext/noderb_extension/libuv/include/{uv-unix.h → uv-private/uv-unix.h} +40 -0
- data/ext/noderb_extension/libuv/include/{uv-win.h → uv-private/uv-win.h} +96 -14
- data/ext/noderb_extension/libuv/include/uv.h +508 -83
- data/ext/noderb_extension/libuv/src/unix/cares.c +185 -0
- data/ext/noderb_extension/libuv/src/unix/core.c +828 -0
- data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config_darwin.h +4 -0
- data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config_linux.h +5 -15
- data/ext/noderb_extension/libuv/src/{eio → unix/eio}/eio.c +23 -2
- data/ext/noderb_extension/libuv/src/unix/error.c +102 -0
- data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config_linux.h +26 -15
- data/ext/noderb_extension/libuv/src/unix/fs.c +562 -0
- data/ext/noderb_extension/libuv/src/unix/internal.h +75 -0
- data/ext/noderb_extension/libuv/src/unix/pipe.c +282 -0
- data/ext/noderb_extension/libuv/src/unix/process.c +287 -0
- data/ext/noderb_extension/libuv/src/unix/stream.c +727 -0
- data/ext/noderb_extension/libuv/src/unix/tcp.c +226 -0
- data/ext/noderb_extension/libuv/src/unix/udp.c +524 -0
- data/ext/noderb_extension/libuv/src/{uv-eio.c → unix/uv-eio.c} +48 -27
- data/ext/noderb_extension/libuv/src/{uv-eio.h → unix/uv-eio.h} +1 -1
- data/ext/noderb_extension/libuv/src/uv-common.c +24 -14
- data/ext/noderb_extension/libuv/src/uv-common.h +12 -7
- data/ext/noderb_extension/libuv/src/win/async.c +14 -16
- data/ext/noderb_extension/libuv/src/win/cares.c +64 -79
- data/ext/noderb_extension/libuv/src/win/core.c +105 -53
- data/ext/noderb_extension/libuv/src/win/error.c +23 -13
- data/ext/noderb_extension/libuv/src/win/fs.c +807 -0
- data/ext/noderb_extension/libuv/src/win/getaddrinfo.c +61 -41
- data/ext/noderb_extension/libuv/src/win/handle.c +56 -30
- data/ext/noderb_extension/libuv/src/win/internal.h +134 -95
- data/ext/noderb_extension/libuv/src/win/loop-watcher.c +21 -18
- data/ext/noderb_extension/libuv/src/win/pipe.c +313 -158
- data/ext/noderb_extension/libuv/src/win/process.c +117 -131
- data/ext/noderb_extension/libuv/src/win/req.c +55 -31
- data/ext/noderb_extension/libuv/src/win/stdio.c +5 -5
- data/ext/noderb_extension/libuv/src/win/stream.c +19 -14
- data/ext/noderb_extension/libuv/src/win/tcp.c +278 -336
- data/ext/noderb_extension/libuv/src/win/threadpool.c +73 -0
- data/ext/noderb_extension/libuv/src/win/timer.c +44 -37
- data/ext/noderb_extension/libuv/src/win/udp.c +592 -0
- data/ext/noderb_extension/libuv/src/win/util.c +20 -6
- data/ext/noderb_extension/libuv/src/win/winapi.c +23 -6
- data/ext/noderb_extension/libuv/src/win/winapi.h +4206 -0
- data/ext/noderb_extension/libuv/src/win/winsock.c +270 -0
- data/ext/noderb_extension/libuv/src/win/winsock.h +134 -0
- data/ext/noderb_extension/libuv/test/benchmark-ares.c +10 -6
- data/ext/noderb_extension/libuv/test/benchmark-getaddrinfo.c +10 -7
- data/ext/noderb_extension/libuv/test/benchmark-list.h +21 -0
- data/ext/noderb_extension/libuv/test/benchmark-ping-pongs.c +11 -7
- data/ext/noderb_extension/libuv/test/benchmark-pound.c +147 -58
- data/ext/noderb_extension/libuv/test/benchmark-pump.c +29 -23
- data/ext/noderb_extension/libuv/test/benchmark-spawn.c +13 -10
- data/ext/noderb_extension/libuv/test/benchmark-udp-packet-storm.c +250 -0
- data/ext/noderb_extension/libuv/test/dns-server.c +11 -6
- data/ext/noderb_extension/libuv/test/echo-server.c +30 -22
- data/ext/noderb_extension/libuv/test/test-async.c +3 -3
- data/ext/noderb_extension/libuv/test/test-callback-stack.c +6 -6
- data/ext/noderb_extension/libuv/test/test-connection-fail.c +6 -5
- data/ext/noderb_extension/libuv/test/test-delayed-accept.c +13 -13
- data/ext/noderb_extension/libuv/test/test-fs.c +715 -0
- data/ext/noderb_extension/libuv/test/test-getaddrinfo.c +11 -8
- data/ext/noderb_extension/libuv/test/test-gethostbyname.c +8 -9
- data/ext/noderb_extension/libuv/test/test-getsockname.c +142 -16
- data/ext/noderb_extension/libuv/test/test-idle.c +4 -3
- data/ext/noderb_extension/libuv/test/test-list.h +29 -2
- data/ext/noderb_extension/libuv/test/test-loop-handles.c +9 -8
- data/ext/noderb_extension/libuv/test/test-ping-pong.c +9 -9
- data/ext/noderb_extension/libuv/test/test-pipe-bind-error.c +18 -14
- data/ext/noderb_extension/libuv/test/test-ref.c +17 -16
- data/ext/noderb_extension/libuv/test/test-shutdown-eof.c +5 -5
- data/ext/noderb_extension/libuv/test/test-spawn.c +17 -17
- data/ext/noderb_extension/libuv/test/test-tcp-bind-error.c +24 -18
- data/ext/noderb_extension/libuv/test/test-tcp-bind6-error.c +19 -14
- data/ext/noderb_extension/libuv/test/test-tcp-writealot.c +6 -5
- data/ext/noderb_extension/libuv/test/test-threadpool.c +59 -0
- data/ext/noderb_extension/libuv/test/test-timer-again.c +15 -12
- data/ext/noderb_extension/libuv/test/test-timer.c +8 -8
- data/ext/noderb_extension/libuv/test/test-udp-dgram-too-big.c +88 -0
- data/ext/noderb_extension/libuv/test/test-udp-ipv6.c +158 -0
- data/ext/noderb_extension/libuv/test/test-udp-send-and-recv.c +210 -0
- data/ext/noderb_extension/libuv/{all.gyp → uv.gyp} +75 -77
- data/ext/noderb_extension/libuv/vcbuild.bat +93 -0
- data/ext/noderb_extension/noderb.c +13 -0
- data/ext/noderb_extension/noderb_common.h +2 -1
- data/ext/noderb_extension/noderb_defer.c +54 -0
- data/ext/noderb_extension/noderb_defer.h +15 -0
- data/ext/noderb_extension/noderb_dns.c +1 -1
- data/ext/noderb_extension/noderb_fs.c +277 -0
- data/ext/noderb_extension/noderb_fs.h +27 -0
- data/ext/noderb_extension/noderb_process.c +5 -5
- data/ext/noderb_extension/noderb_tcp.c +10 -6
- data/ext/noderb_extension/noderb_timers.c +1 -1
- data/ext/noderb_extension/noderb_tools.c +42 -8
- data/ext/noderb_extension/noderb_tools.h +3 -1
- data/lib/noderb/defer.rb +25 -0
- data/lib/noderb/file.rb +119 -0
- data/lib/noderb/fs.rb +72 -0
- data/lib/noderb/version.rb +1 -1
- data/lib/noderb.rb +8 -0
- metadata +102 -266
- data/ext/noderb_extension/libuv/BSDmakefile +0 -2
- data/ext/noderb_extension/libuv/create-msvs-files.bat +0 -21
- data/ext/noderb_extension/libuv/deps/pthread-win32/ANNOUNCE +0 -482
- data/ext/noderb_extension/libuv/deps/pthread-win32/BUGS +0 -141
- data/ext/noderb_extension/libuv/deps/pthread-win32/Bmakefile +0 -268
- data/ext/noderb_extension/libuv/deps/pthread-win32/CONTRIBUTORS +0 -140
- data/ext/noderb_extension/libuv/deps/pthread-win32/COPYING +0 -150
- data/ext/noderb_extension/libuv/deps/pthread-win32/COPYING.LIB +0 -504
- data/ext/noderb_extension/libuv/deps/pthread-win32/ChangeLog +0 -5194
- data/ext/noderb_extension/libuv/deps/pthread-win32/FAQ +0 -451
- data/ext/noderb_extension/libuv/deps/pthread-win32/GNUmakefile +0 -593
- data/ext/noderb_extension/libuv/deps/pthread-win32/MAINTAINERS +0 -4
- data/ext/noderb_extension/libuv/deps/pthread-win32/Makefile +0 -516
- data/ext/noderb_extension/libuv/deps/pthread-win32/NEWS +0 -1245
- data/ext/noderb_extension/libuv/deps/pthread-win32/Nmakefile +0 -24
- data/ext/noderb_extension/libuv/deps/pthread-win32/Nmakefile.tests +0 -260
- data/ext/noderb_extension/libuv/deps/pthread-win32/PROGRESS +0 -4
- data/ext/noderb_extension/libuv/deps/pthread-win32/README +0 -601
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.Borland +0 -57
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.CV +0 -3036
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.NONPORTABLE +0 -783
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.Watcom +0 -62
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.WinCE +0 -6
- data/ext/noderb_extension/libuv/deps/pthread-win32/TODO +0 -7
- data/ext/noderb_extension/libuv/deps/pthread-win32/WinCE-PORT +0 -222
- data/ext/noderb_extension/libuv/deps/pthread-win32/attr.c +0 -53
- data/ext/noderb_extension/libuv/deps/pthread-win32/autostatic.c +0 -69
- data/ext/noderb_extension/libuv/deps/pthread-win32/barrier.c +0 -47
- data/ext/noderb_extension/libuv/deps/pthread-win32/build/all.gyp +0 -207
- data/ext/noderb_extension/libuv/deps/pthread-win32/builddmc.bat +0 -9
- data/ext/noderb_extension/libuv/deps/pthread-win32/cancel.c +0 -44
- data/ext/noderb_extension/libuv/deps/pthread-win32/cleanup.c +0 -148
- data/ext/noderb_extension/libuv/deps/pthread-win32/condvar.c +0 -50
- data/ext/noderb_extension/libuv/deps/pthread-win32/config.h +0 -153
- data/ext/noderb_extension/libuv/deps/pthread-win32/context.h +0 -74
- data/ext/noderb_extension/libuv/deps/pthread-win32/create.c +0 -308
- data/ext/noderb_extension/libuv/deps/pthread-win32/dll.c +0 -92
- data/ext/noderb_extension/libuv/deps/pthread-win32/errno.c +0 -94
- data/ext/noderb_extension/libuv/deps/pthread-win32/exit.c +0 -44
- data/ext/noderb_extension/libuv/deps/pthread-win32/fork.c +0 -39
- data/ext/noderb_extension/libuv/deps/pthread-win32/global.c +0 -107
- data/ext/noderb_extension/libuv/deps/pthread-win32/implement.h +0 -944
- data/ext/noderb_extension/libuv/deps/pthread-win32/misc.c +0 -50
- data/ext/noderb_extension/libuv/deps/pthread-win32/mutex.c +0 -62
- data/ext/noderb_extension/libuv/deps/pthread-win32/need_errno.h +0 -145
- data/ext/noderb_extension/libuv/deps/pthread-win32/nonportable.c +0 -47
- data/ext/noderb_extension/libuv/deps/pthread-win32/private.c +0 -54
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.c +0 -66
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.dsp +0 -142
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.dsw +0 -29
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.h +0 -1368
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_destroy.c +0 -79
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getdetachstate.c +0 -86
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getinheritsched.c +0 -51
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getschedparam.c +0 -52
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getschedpolicy.c +0 -61
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getscope.c +0 -54
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getstackaddr.c +0 -97
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getstacksize.c +0 -100
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_init.c +0 -117
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setdetachstate.c +0 -91
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setinheritsched.c +0 -57
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setschedparam.c +0 -63
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setschedpolicy.c +0 -55
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setscope.c +0 -62
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setstackaddr.c +0 -97
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setstacksize.c +0 -110
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrier_destroy.c +0 -103
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrier_init.c +0 -69
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrier_wait.c +0 -104
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_destroy.c +0 -83
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_getpshared.c +0 -95
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_init.c +0 -85
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_setpshared.c +0 -119
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cancel.c +0 -189
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_destroy.c +0 -253
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_init.c +0 -167
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_signal.c +0 -231
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_wait.c +0 -567
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_destroy.c +0 -86
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_getpshared.c +0 -97
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_init.c +0 -87
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_setpshared.c +0 -117
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_delay_np.c +0 -172
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_detach.c +0 -136
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_equal.c +0 -76
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_exit.c +0 -106
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getconcurrency.c +0 -45
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getschedparam.c +0 -75
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getspecific.c +0 -87
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getunique_np.c +0 -47
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getw32threadhandle_np.c +0 -65
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_join.c +0 -157
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_key_create.c +0 -108
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_key_delete.c +0 -125
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_kill.c +0 -105
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_consistent.c +0 -187
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_destroy.c +0 -148
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_init.c +0 -130
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_lock.c +0 -269
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_timedlock.c +0 -324
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_trylock.c +0 -154
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_unlock.c +0 -175
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_destroy.c +0 -83
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_getkind_np.c +0 -44
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_getpshared.c +0 -95
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_getrobust.c +0 -113
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_gettype.c +0 -56
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_init.c +0 -86
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_setkind_np.c +0 -44
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_setpshared.c +0 -119
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_setrobust.c +0 -119
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_settype.c +0 -143
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_num_processors_np.c +0 -56
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_once.c +0 -79
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_destroy.c +0 -143
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_init.c +0 -109
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_rdlock.c +0 -102
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_timedrdlock.c +0 -109
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_timedwrlock.c +0 -139
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_tryrdlock.c +0 -102
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_trywrlock.c +0 -122
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_unlock.c +0 -93
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_wrlock.c +0 -133
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_destroy.c +0 -84
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_getpshared.c +0 -97
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_init.c +0 -83
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_setpshared.c +0 -120
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_self.c +0 -141
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setcancelstate.c +0 -125
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setcanceltype.c +0 -126
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setconcurrency.c +0 -53
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setschedparam.c +0 -123
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setspecific.c +0 -167
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_destroy.c +0 -111
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_init.c +0 -123
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_lock.c +0 -80
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_trylock.c +0 -77
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_unlock.c +0 -71
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_testcancel.c +0 -103
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_timechange_handler_np.c +0 -108
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_win32_attach_detach_np.c +0 -258
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_MCS_lock.c +0 -278
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_callUserDestroyRoutines.c +0 -232
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_calloc.c +0 -56
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_cond_check_need_init.c +0 -78
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_getprocessors.c +0 -91
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_is_attr.c +0 -47
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_mutex_check_need_init.c +0 -92
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_new.c +0 -94
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_processInitialize.c +0 -92
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_processTerminate.c +0 -105
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_relmillisecs.c +0 -132
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_reuse.c +0 -151
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_rwlock_cancelwrwait.c +0 -50
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_rwlock_check_need_init.c +0 -77
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_semwait.c +0 -135
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_spinlock_check_need_init.c +0 -78
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_threadDestroy.c +0 -79
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_threadStart.c +0 -357
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_throw.c +0 -189
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_timespec.c +0 -83
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_tkAssocCreate.c +0 -118
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_tkAssocDestroy.c +0 -114
- data/ext/noderb_extension/libuv/deps/pthread-win32/rwlock.c +0 -51
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched.c +0 -53
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched.h +0 -183
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_get_priority_max.c +0 -134
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_get_priority_min.c +0 -135
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_getscheduler.c +0 -71
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_setscheduler.c +0 -83
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_yield.c +0 -71
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_close.c +0 -58
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_destroy.c +0 -144
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_getvalue.c +0 -110
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_init.c +0 -169
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_open.c +0 -58
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_post.c +0 -128
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_post_multiple.c +0 -142
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_timedwait.c +0 -238
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_trywait.c +0 -117
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_unlink.c +0 -58
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_wait.c +0 -187
- data/ext/noderb_extension/libuv/deps/pthread-win32/semaphore.c +0 -69
- data/ext/noderb_extension/libuv/deps/pthread-win32/semaphore.h +0 -169
- data/ext/noderb_extension/libuv/deps/pthread-win32/signal.c +0 -179
- data/ext/noderb_extension/libuv/deps/pthread-win32/spin.c +0 -46
- data/ext/noderb_extension/libuv/deps/pthread-win32/sync.c +0 -43
- data/ext/noderb_extension/libuv/deps/pthread-win32/tsd.c +0 -44
- data/ext/noderb_extension/libuv/deps/pthread-win32/version.rc +0 -388
- data/ext/noderb_extension/libuv/deps/pthread-win32/w32_CancelableWait.c +0 -161
- data/ext/noderb_extension/libuv/doc/iocp-links.html +0 -574
- data/ext/noderb_extension/libuv/src/uv-unix.c +0 -2421
- data/ext/noderb_extension/libuv/src/win/ntdll.h +0 -130
- /data/ext/noderb_extension/libuv/include/{ev.h → uv-private/ev.h} +0 -0
- /data/ext/noderb_extension/libuv/include/{ngx-queue.h → uv-private/ngx-queue.h} +0 -0
- /data/ext/noderb_extension/libuv/include/{tree.h → uv-private/tree.h} +0 -0
- /data/ext/noderb_extension/libuv/src/{uv-cygwin.c → unix/cygwin.c} +0 -0
- /data/ext/noderb_extension/libuv/src/{uv-darwin.c → unix/darwin.c} +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/Changes +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/LICENSE +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/Makefile.am +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/aclocal.m4 +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/autogen.sh +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config.h.in +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config_cygwin.h +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config_freebsd.h +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config_sunos.h +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/configure.ac +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/demo.c +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/ecb.h +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/eio.3 +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/eio.pod +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/libeio.m4 +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/xthread.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/Changes +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/LICENSE +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/Makefile.am +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/Makefile.in +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/README +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/aclocal.m4 +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/autogen.sh +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config.guess +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config.h.in +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config.sub +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config_cygwin.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config_darwin.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config_freebsd.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config_sunos.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/configure +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/configure.ac +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/depcomp +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev++.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev.3 +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev.pod +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_epoll.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_kqueue.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_poll.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_port.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_select.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_vars.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_win32.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_wrap.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/event.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/event.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/install-sh +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/libev.m4 +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ltmain.sh +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/missing +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/mkinstalldirs +0 -0
- /data/ext/noderb_extension/libuv/src/{uv-freebsd.c → unix/freebsd.c} +0 -0
- /data/ext/noderb_extension/libuv/src/{uv-linux.c → unix/linux.c} +0 -0
- /data/ext/noderb_extension/libuv/src/{uv-sunos.c → unix/sunos.c} +0 -0
@@ -1,944 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* implement.h
|
3
|
-
*
|
4
|
-
* Definitions that don't need to be public.
|
5
|
-
*
|
6
|
-
* Keeps all the internals out of pthread.h
|
7
|
-
*
|
8
|
-
* --------------------------------------------------------------------------
|
9
|
-
*
|
10
|
-
* Pthreads-win32 - POSIX Threads Library for Win32
|
11
|
-
* Copyright(C) 1998 John E. Bossom
|
12
|
-
* Copyright(C) 1999,2005 Pthreads-win32 contributors
|
13
|
-
*
|
14
|
-
* Contact Email: Ross.Johnson@homemail.com.au
|
15
|
-
*
|
16
|
-
* The current list of contributors is contained
|
17
|
-
* in the file CONTRIBUTORS included with the source
|
18
|
-
* code distribution. The list can also be seen at the
|
19
|
-
* following World Wide Web location:
|
20
|
-
* http://sources.redhat.com/pthreads-win32/contributors.html
|
21
|
-
*
|
22
|
-
* This library is free software; you can redistribute it and/or
|
23
|
-
* modify it under the terms of the GNU Lesser General Public
|
24
|
-
* License as published by the Free Software Foundation; either
|
25
|
-
* version 2 of the License, or (at your option) any later version.
|
26
|
-
*
|
27
|
-
* This library is distributed in the hope that it will be useful,
|
28
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
29
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
30
|
-
* Lesser General Public License for more details.
|
31
|
-
*
|
32
|
-
* You should have received a copy of the GNU Lesser General Public
|
33
|
-
* License along with this library in the file COPYING.LIB;
|
34
|
-
* if not, write to the Free Software Foundation, Inc.,
|
35
|
-
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
36
|
-
*/
|
37
|
-
|
38
|
-
#if !defined(_IMPLEMENT_H)
|
39
|
-
#define _IMPLEMENT_H
|
40
|
-
|
41
|
-
#if !defined(_WIN32_WINNT)
|
42
|
-
#define _WIN32_WINNT 0x0400
|
43
|
-
#endif
|
44
|
-
|
45
|
-
#include <windows.h>
|
46
|
-
|
47
|
-
/*
|
48
|
-
* In case windows.h doesn't define it (e.g. WinCE perhaps)
|
49
|
-
*/
|
50
|
-
#if defined(WINCE)
|
51
|
-
typedef VOID (APIENTRY *PAPCFUNC)(DWORD dwParam);
|
52
|
-
#endif
|
53
|
-
|
54
|
-
/*
|
55
|
-
* note: ETIMEDOUT is correctly defined in winsock.h
|
56
|
-
*/
|
57
|
-
#include <winsock.h>
|
58
|
-
|
59
|
-
/*
|
60
|
-
* In case ETIMEDOUT hasn't been defined above somehow.
|
61
|
-
*/
|
62
|
-
#if !defined(ETIMEDOUT)
|
63
|
-
# define ETIMEDOUT 10060 /* This is the value in winsock.h. */
|
64
|
-
#endif
|
65
|
-
|
66
|
-
#if !defined(malloc)
|
67
|
-
#include <malloc.h>
|
68
|
-
#endif
|
69
|
-
|
70
|
-
#if defined(__CLEANUP_C)
|
71
|
-
# include <setjmp.h>
|
72
|
-
#endif
|
73
|
-
|
74
|
-
#if !defined(INT_MAX)
|
75
|
-
#include <limits.h>
|
76
|
-
#endif
|
77
|
-
|
78
|
-
/* use local include files during development */
|
79
|
-
#include "semaphore.h"
|
80
|
-
#include "sched.h"
|
81
|
-
|
82
|
-
#if defined(HAVE_C_INLINE) || defined(__cplusplus)
|
83
|
-
#define INLINE inline
|
84
|
-
#else
|
85
|
-
#define INLINE
|
86
|
-
#endif
|
87
|
-
|
88
|
-
#if defined(_MSC_VER) && _MSC_VER < 1300
|
89
|
-
/*
|
90
|
-
* MSVC 6 does not use the "volatile" qualifier
|
91
|
-
*/
|
92
|
-
#define PTW32_INTERLOCKED_VOLATILE
|
93
|
-
#else
|
94
|
-
#define PTW32_INTERLOCKED_VOLATILE volatile
|
95
|
-
#endif
|
96
|
-
#define PTW32_INTERLOCKED_LONG long
|
97
|
-
#define PTW32_INTERLOCKED_SIZE size_t
|
98
|
-
#define PTW32_INTERLOCKED_PVOID PVOID
|
99
|
-
#define PTW32_INTERLOCKED_LONGPTR PTW32_INTERLOCKED_VOLATILE long*
|
100
|
-
#define PTW32_INTERLOCKED_SIZEPTR PTW32_INTERLOCKED_VOLATILE size_t*
|
101
|
-
#define PTW32_INTERLOCKED_PVOID_PTR PTW32_INTERLOCKED_VOLATILE PVOID*
|
102
|
-
|
103
|
-
#if defined(__MINGW64__) || defined(__MINGW32__)
|
104
|
-
# include <stdint.h>
|
105
|
-
#elif defined(__BORLANDC__)
|
106
|
-
# define int64_t ULONGLONG
|
107
|
-
#else
|
108
|
-
# define int64_t _int64
|
109
|
-
# if defined(_MSC_VER) && _MSC_VER < 1300
|
110
|
-
typedef long intptr_t;
|
111
|
-
# endif
|
112
|
-
#endif
|
113
|
-
|
114
|
-
typedef enum
|
115
|
-
{
|
116
|
-
/*
|
117
|
-
* This enumeration represents the state of the thread;
|
118
|
-
* The thread is still "alive" if the numeric value of the
|
119
|
-
* state is greater or equal "PThreadStateRunning".
|
120
|
-
*/
|
121
|
-
PThreadStateInitial = 0, /* Thread not running */
|
122
|
-
PThreadStateRunning, /* Thread alive & kicking */
|
123
|
-
PThreadStateSuspended, /* Thread alive but suspended */
|
124
|
-
PThreadStateCancelPending, /* Thread alive but */
|
125
|
-
/* has cancelation pending. */
|
126
|
-
PThreadStateCanceling, /* Thread alive but is */
|
127
|
-
/* in the process of terminating */
|
128
|
-
/* due to a cancellation request */
|
129
|
-
PThreadStateExiting, /* Thread alive but exiting */
|
130
|
-
/* due to an exception */
|
131
|
-
PThreadStateLast, /* All handlers have been run and now */
|
132
|
-
/* final cleanup can be done. */
|
133
|
-
PThreadStateReuse /* In reuse pool. */
|
134
|
-
}
|
135
|
-
PThreadState;
|
136
|
-
|
137
|
-
typedef struct ptw32_mcs_node_t_ ptw32_mcs_local_node_t;
|
138
|
-
typedef struct ptw32_mcs_node_t_* ptw32_mcs_lock_t;
|
139
|
-
typedef struct ptw32_robust_node_t_ ptw32_robust_node_t;
|
140
|
-
typedef struct ptw32_thread_t_ ptw32_thread_t;
|
141
|
-
|
142
|
-
|
143
|
-
struct ptw32_thread_t_
|
144
|
-
{
|
145
|
-
unsigned __int64 seqNumber; /* Process-unique thread sequence number */
|
146
|
-
HANDLE threadH; /* Win32 thread handle - POSIX thread is invalid if threadH == 0 */
|
147
|
-
pthread_t ptHandle; /* This thread's permanent pthread_t handle */
|
148
|
-
ptw32_thread_t * prevReuse; /* Links threads on reuse stack */
|
149
|
-
volatile PThreadState state;
|
150
|
-
ptw32_mcs_lock_t threadLock; /* Used for serialised access to public thread state */
|
151
|
-
ptw32_mcs_lock_t stateLock; /* Used for async-cancel safety */
|
152
|
-
HANDLE cancelEvent;
|
153
|
-
void *exitStatus;
|
154
|
-
void *parms;
|
155
|
-
void *keys;
|
156
|
-
void *nextAssoc;
|
157
|
-
#if defined(__CLEANUP_C)
|
158
|
-
jmp_buf start_mark; /* Jump buffer follows void* so should be aligned */
|
159
|
-
#endif /* __CLEANUP_C */
|
160
|
-
#if defined(HAVE_SIGSET_T)
|
161
|
-
sigset_t sigmask;
|
162
|
-
#endif /* HAVE_SIGSET_T */
|
163
|
-
ptw32_mcs_lock_t
|
164
|
-
robustMxListLock; /* robustMxList lock */
|
165
|
-
ptw32_robust_node_t*
|
166
|
-
robustMxList; /* List of currenty held robust mutexes */
|
167
|
-
int ptErrno;
|
168
|
-
int detachState;
|
169
|
-
int sched_priority; /* As set, not as currently is */
|
170
|
-
int cancelState;
|
171
|
-
int cancelType;
|
172
|
-
int implicit:1;
|
173
|
-
DWORD thread; /* Win32 thread ID */
|
174
|
-
#if defined(_UWIN)
|
175
|
-
DWORD dummy[5];
|
176
|
-
#endif
|
177
|
-
size_t align; /* Force alignment if this struct is packed */
|
178
|
-
};
|
179
|
-
|
180
|
-
|
181
|
-
/*
|
182
|
-
* Special value to mark attribute objects as valid.
|
183
|
-
*/
|
184
|
-
#define PTW32_ATTR_VALID ((unsigned long) 0xC4C0FFEE)
|
185
|
-
|
186
|
-
struct pthread_attr_t_
|
187
|
-
{
|
188
|
-
unsigned long valid;
|
189
|
-
void *stackaddr;
|
190
|
-
size_t stacksize;
|
191
|
-
int detachstate;
|
192
|
-
struct sched_param param;
|
193
|
-
int inheritsched;
|
194
|
-
int contentionscope;
|
195
|
-
#if defined(HAVE_SIGSET_T)
|
196
|
-
sigset_t sigmask;
|
197
|
-
#endif /* HAVE_SIGSET_T */
|
198
|
-
};
|
199
|
-
|
200
|
-
|
201
|
-
/*
|
202
|
-
* ====================
|
203
|
-
* ====================
|
204
|
-
* Semaphores, Mutexes and Condition Variables
|
205
|
-
* ====================
|
206
|
-
* ====================
|
207
|
-
*/
|
208
|
-
|
209
|
-
struct sem_t_
|
210
|
-
{
|
211
|
-
int value;
|
212
|
-
pthread_mutex_t lock;
|
213
|
-
HANDLE sem;
|
214
|
-
#if defined(NEED_SEM)
|
215
|
-
int leftToUnblock;
|
216
|
-
#endif
|
217
|
-
};
|
218
|
-
|
219
|
-
#define PTW32_OBJECT_AUTO_INIT ((void *)(size_t) -1)
|
220
|
-
#define PTW32_OBJECT_INVALID NULL
|
221
|
-
|
222
|
-
struct pthread_mutex_t_
|
223
|
-
{
|
224
|
-
LONG lock_idx; /* Provides exclusive access to mutex state
|
225
|
-
via the Interlocked* mechanism.
|
226
|
-
0: unlocked/free.
|
227
|
-
1: locked - no other waiters.
|
228
|
-
-1: locked - with possible other waiters.
|
229
|
-
*/
|
230
|
-
int recursive_count; /* Number of unlocks a thread needs to perform
|
231
|
-
before the lock is released (recursive
|
232
|
-
mutexes only). */
|
233
|
-
int kind; /* Mutex type. */
|
234
|
-
pthread_t ownerThread;
|
235
|
-
HANDLE event; /* Mutex release notification to waiting
|
236
|
-
threads. */
|
237
|
-
ptw32_robust_node_t*
|
238
|
-
robustNode; /* Extra state for robust mutexes */
|
239
|
-
};
|
240
|
-
|
241
|
-
enum ptw32_robust_state_t_
|
242
|
-
{
|
243
|
-
PTW32_ROBUST_CONSISTENT,
|
244
|
-
PTW32_ROBUST_INCONSISTENT,
|
245
|
-
PTW32_ROBUST_NOTRECOVERABLE
|
246
|
-
};
|
247
|
-
|
248
|
-
typedef enum ptw32_robust_state_t_ ptw32_robust_state_t;
|
249
|
-
|
250
|
-
/*
|
251
|
-
* Node used to manage per-thread lists of currently-held robust mutexes.
|
252
|
-
*/
|
253
|
-
struct ptw32_robust_node_t_
|
254
|
-
{
|
255
|
-
pthread_mutex_t mx;
|
256
|
-
ptw32_robust_state_t stateInconsistent;
|
257
|
-
ptw32_robust_node_t* prev;
|
258
|
-
ptw32_robust_node_t* next;
|
259
|
-
};
|
260
|
-
|
261
|
-
struct pthread_mutexattr_t_
|
262
|
-
{
|
263
|
-
int pshared;
|
264
|
-
int kind;
|
265
|
-
int robustness;
|
266
|
-
};
|
267
|
-
|
268
|
-
/*
|
269
|
-
* Possible values, other than PTW32_OBJECT_INVALID,
|
270
|
-
* for the "interlock" element in a spinlock.
|
271
|
-
*
|
272
|
-
* In this implementation, when a spinlock is initialised,
|
273
|
-
* the number of cpus available to the process is checked.
|
274
|
-
* If there is only one cpu then "interlock" is set equal to
|
275
|
-
* PTW32_SPIN_USE_MUTEX and u.mutex is an initialised mutex.
|
276
|
-
* If the number of cpus is greater than 1 then "interlock"
|
277
|
-
* is set equal to PTW32_SPIN_UNLOCKED and the number is
|
278
|
-
* stored in u.cpus. This arrangement allows the spinlock
|
279
|
-
* routines to attempt an InterlockedCompareExchange on "interlock"
|
280
|
-
* immediately and, if that fails, to try the inferior mutex.
|
281
|
-
*
|
282
|
-
* "u.cpus" isn't used for anything yet, but could be used at
|
283
|
-
* some point to optimise spinlock behaviour.
|
284
|
-
*/
|
285
|
-
#define PTW32_SPIN_INVALID (0)
|
286
|
-
#define PTW32_SPIN_UNLOCKED (1)
|
287
|
-
#define PTW32_SPIN_LOCKED (2)
|
288
|
-
#define PTW32_SPIN_USE_MUTEX (3)
|
289
|
-
|
290
|
-
struct pthread_spinlock_t_
|
291
|
-
{
|
292
|
-
long interlock; /* Locking element for multi-cpus. */
|
293
|
-
union
|
294
|
-
{
|
295
|
-
int cpus; /* No. of cpus if multi cpus, or */
|
296
|
-
pthread_mutex_t mutex; /* mutex if single cpu. */
|
297
|
-
} u;
|
298
|
-
};
|
299
|
-
|
300
|
-
/*
|
301
|
-
* MCS lock queue node - see ptw32_MCS_lock.c
|
302
|
-
*/
|
303
|
-
struct ptw32_mcs_node_t_
|
304
|
-
{
|
305
|
-
struct ptw32_mcs_node_t_ **lock; /* ptr to tail of queue */
|
306
|
-
struct ptw32_mcs_node_t_ *next; /* ptr to successor in queue */
|
307
|
-
HANDLE readyFlag; /* set after lock is released by
|
308
|
-
predecessor */
|
309
|
-
HANDLE nextFlag; /* set after 'next' ptr is set by
|
310
|
-
successor */
|
311
|
-
};
|
312
|
-
|
313
|
-
|
314
|
-
struct pthread_barrier_t_
|
315
|
-
{
|
316
|
-
unsigned int nCurrentBarrierHeight;
|
317
|
-
unsigned int nInitialBarrierHeight;
|
318
|
-
int pshared;
|
319
|
-
sem_t semBarrierBreeched;
|
320
|
-
ptw32_mcs_lock_t lock;
|
321
|
-
ptw32_mcs_local_node_t proxynode;
|
322
|
-
};
|
323
|
-
|
324
|
-
struct pthread_barrierattr_t_
|
325
|
-
{
|
326
|
-
int pshared;
|
327
|
-
};
|
328
|
-
|
329
|
-
struct pthread_key_t_
|
330
|
-
{
|
331
|
-
DWORD key;
|
332
|
-
void (*destructor) (void *);
|
333
|
-
ptw32_mcs_lock_t keyLock;
|
334
|
-
void *threads;
|
335
|
-
};
|
336
|
-
|
337
|
-
|
338
|
-
typedef struct ThreadParms ThreadParms;
|
339
|
-
|
340
|
-
struct ThreadParms
|
341
|
-
{
|
342
|
-
pthread_t tid;
|
343
|
-
void *(*start) (void *);
|
344
|
-
void *arg;
|
345
|
-
};
|
346
|
-
|
347
|
-
|
348
|
-
struct pthread_cond_t_
|
349
|
-
{
|
350
|
-
long nWaitersBlocked; /* Number of threads blocked */
|
351
|
-
long nWaitersGone; /* Number of threads timed out */
|
352
|
-
long nWaitersToUnblock; /* Number of threads to unblock */
|
353
|
-
sem_t semBlockQueue; /* Queue up threads waiting for the */
|
354
|
-
/* condition to become signalled */
|
355
|
-
sem_t semBlockLock; /* Semaphore that guards access to */
|
356
|
-
/* | waiters blocked count/block queue */
|
357
|
-
/* +-> Mandatory Sync.LEVEL-1 */
|
358
|
-
pthread_mutex_t mtxUnblockLock; /* Mutex that guards access to */
|
359
|
-
/* | waiters (to)unblock(ed) counts */
|
360
|
-
/* +-> Optional* Sync.LEVEL-2 */
|
361
|
-
pthread_cond_t next; /* Doubly linked list */
|
362
|
-
pthread_cond_t prev;
|
363
|
-
};
|
364
|
-
|
365
|
-
|
366
|
-
struct pthread_condattr_t_
|
367
|
-
{
|
368
|
-
int pshared;
|
369
|
-
};
|
370
|
-
|
371
|
-
#define PTW32_RWLOCK_MAGIC 0xfacade2
|
372
|
-
|
373
|
-
struct pthread_rwlock_t_
|
374
|
-
{
|
375
|
-
pthread_mutex_t mtxExclusiveAccess;
|
376
|
-
pthread_mutex_t mtxSharedAccessCompleted;
|
377
|
-
pthread_cond_t cndSharedAccessCompleted;
|
378
|
-
int nSharedAccessCount;
|
379
|
-
int nExclusiveAccessCount;
|
380
|
-
int nCompletedSharedAccessCount;
|
381
|
-
int nMagic;
|
382
|
-
};
|
383
|
-
|
384
|
-
struct pthread_rwlockattr_t_
|
385
|
-
{
|
386
|
-
int pshared;
|
387
|
-
};
|
388
|
-
|
389
|
-
typedef struct ThreadKeyAssoc ThreadKeyAssoc;
|
390
|
-
|
391
|
-
struct ThreadKeyAssoc
|
392
|
-
{
|
393
|
-
/*
|
394
|
-
* Purpose:
|
395
|
-
* This structure creates an association between a thread and a key.
|
396
|
-
* It is used to implement the implicit invocation of a user defined
|
397
|
-
* destroy routine for thread specific data registered by a user upon
|
398
|
-
* exiting a thread.
|
399
|
-
*
|
400
|
-
* Graphically, the arrangement is as follows, where:
|
401
|
-
*
|
402
|
-
* K - Key with destructor
|
403
|
-
* (head of chain is key->threads)
|
404
|
-
* T - Thread that has called pthread_setspecific(Kn)
|
405
|
-
* (head of chain is thread->keys)
|
406
|
-
* A - Association. Each association is a node at the
|
407
|
-
* intersection of two doubly-linked lists.
|
408
|
-
*
|
409
|
-
* T1 T2 T3
|
410
|
-
* | | |
|
411
|
-
* | | |
|
412
|
-
* K1 -----+-----A-----A----->
|
413
|
-
* | | |
|
414
|
-
* | | |
|
415
|
-
* K2 -----A-----A-----+----->
|
416
|
-
* | | |
|
417
|
-
* | | |
|
418
|
-
* K3 -----A-----+-----A----->
|
419
|
-
* | | |
|
420
|
-
* | | |
|
421
|
-
* V V V
|
422
|
-
*
|
423
|
-
* Access to the association is guarded by two locks: the key's
|
424
|
-
* general lock (guarding the row) and the thread's general
|
425
|
-
* lock (guarding the column). This avoids the need for a
|
426
|
-
* dedicated lock for each association, which not only consumes
|
427
|
-
* more handles but requires that the lock resources persist
|
428
|
-
* until both the key is deleted and the thread has called the
|
429
|
-
* destructor. The two-lock arrangement allows those resources
|
430
|
-
* to be freed as soon as either thread or key is concluded.
|
431
|
-
*
|
432
|
-
* To avoid deadlock, whenever both locks are required both the
|
433
|
-
* key and thread locks are acquired consistently in the order
|
434
|
-
* "key lock then thread lock". An exception to this exists
|
435
|
-
* when a thread calls the destructors, however, this is done
|
436
|
-
* carefully (but inelegantly) to avoid deadlock.
|
437
|
-
*
|
438
|
-
* An association is created when a thread first calls
|
439
|
-
* pthread_setspecific() on a key that has a specified
|
440
|
-
* destructor.
|
441
|
-
*
|
442
|
-
* An association is destroyed either immediately after the
|
443
|
-
* thread calls the key destructor function on thread exit, or
|
444
|
-
* when the key is deleted.
|
445
|
-
*
|
446
|
-
* Attributes:
|
447
|
-
* thread
|
448
|
-
* reference to the thread that owns the
|
449
|
-
* association. This is actually the pointer to the
|
450
|
-
* thread struct itself. Since the association is
|
451
|
-
* destroyed before the thread exits, this can never
|
452
|
-
* point to a different logical thread to the one that
|
453
|
-
* created the assoc, i.e. after thread struct reuse.
|
454
|
-
*
|
455
|
-
* key
|
456
|
-
* reference to the key that owns the association.
|
457
|
-
*
|
458
|
-
* nextKey
|
459
|
-
* The pthread_t->keys attribute is the head of a
|
460
|
-
* chain of associations that runs through the nextKey
|
461
|
-
* link. This chain provides the 1 to many relationship
|
462
|
-
* between a pthread_t and all pthread_key_t on which
|
463
|
-
* it called pthread_setspecific.
|
464
|
-
*
|
465
|
-
* prevKey
|
466
|
-
* Similarly.
|
467
|
-
*
|
468
|
-
* nextThread
|
469
|
-
* The pthread_key_t->threads attribute is the head of
|
470
|
-
* a chain of associations that runs through the
|
471
|
-
* nextThreads link. This chain provides the 1 to many
|
472
|
-
* relationship between a pthread_key_t and all the
|
473
|
-
* PThreads that have called pthread_setspecific for
|
474
|
-
* this pthread_key_t.
|
475
|
-
*
|
476
|
-
* prevThread
|
477
|
-
* Similarly.
|
478
|
-
*
|
479
|
-
* Notes:
|
480
|
-
* 1) As soon as either the key or the thread is no longer
|
481
|
-
* referencing the association, it can be destroyed. The
|
482
|
-
* association will be removed from both chains.
|
483
|
-
*
|
484
|
-
* 2) Under WIN32, an association is only created by
|
485
|
-
* pthread_setspecific if the user provided a
|
486
|
-
* destroyRoutine when they created the key.
|
487
|
-
*
|
488
|
-
*
|
489
|
-
*/
|
490
|
-
ptw32_thread_t * thread;
|
491
|
-
pthread_key_t key;
|
492
|
-
ThreadKeyAssoc *nextKey;
|
493
|
-
ThreadKeyAssoc *nextThread;
|
494
|
-
ThreadKeyAssoc *prevKey;
|
495
|
-
ThreadKeyAssoc *prevThread;
|
496
|
-
};
|
497
|
-
|
498
|
-
|
499
|
-
#if defined(__CLEANUP_SEH)
|
500
|
-
/*
|
501
|
-
* --------------------------------------------------------------
|
502
|
-
* MAKE_SOFTWARE_EXCEPTION
|
503
|
-
* This macro constructs a software exception code following
|
504
|
-
* the same format as the standard Win32 error codes as defined
|
505
|
-
* in WINERROR.H
|
506
|
-
* Values are 32 bit values laid out as follows:
|
507
|
-
*
|
508
|
-
* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
|
509
|
-
* +---+-+-+-----------------------+-------------------------------+
|
510
|
-
* |Sev|C|R| Facility | Code |
|
511
|
-
* +---+-+-+-----------------------+-------------------------------+
|
512
|
-
*
|
513
|
-
* Severity Values:
|
514
|
-
*/
|
515
|
-
#define SE_SUCCESS 0x00
|
516
|
-
#define SE_INFORMATION 0x01
|
517
|
-
#define SE_WARNING 0x02
|
518
|
-
#define SE_ERROR 0x03
|
519
|
-
|
520
|
-
#define MAKE_SOFTWARE_EXCEPTION( _severity, _facility, _exception ) \
|
521
|
-
( (DWORD) ( ( (_severity) << 30 ) | /* Severity code */ \
|
522
|
-
( 1 << 29 ) | /* MS=0, User=1 */ \
|
523
|
-
( 0 << 28 ) | /* Reserved */ \
|
524
|
-
( (_facility) << 16 ) | /* Facility Code */ \
|
525
|
-
( (_exception) << 0 ) /* Exception Code */ \
|
526
|
-
) )
|
527
|
-
|
528
|
-
/*
|
529
|
-
* We choose one specific Facility/Error code combination to
|
530
|
-
* identify our software exceptions vs. WIN32 exceptions.
|
531
|
-
* We store our actual component and error code within
|
532
|
-
* the optional information array.
|
533
|
-
*/
|
534
|
-
#define EXCEPTION_PTW32_SERVICES \
|
535
|
-
MAKE_SOFTWARE_EXCEPTION( SE_ERROR, \
|
536
|
-
PTW32_SERVICES_FACILITY, \
|
537
|
-
PTW32_SERVICES_ERROR )
|
538
|
-
|
539
|
-
#define PTW32_SERVICES_FACILITY 0xBAD
|
540
|
-
#define PTW32_SERVICES_ERROR 0xDEED
|
541
|
-
|
542
|
-
#endif /* __CLEANUP_SEH */
|
543
|
-
|
544
|
-
/*
|
545
|
-
* Services available through EXCEPTION_PTW32_SERVICES
|
546
|
-
* and also used [as parameters to ptw32_throw()] as
|
547
|
-
* generic exception selectors.
|
548
|
-
*/
|
549
|
-
|
550
|
-
#define PTW32_EPS_EXIT (1)
|
551
|
-
#define PTW32_EPS_CANCEL (2)
|
552
|
-
|
553
|
-
|
554
|
-
/* Useful macros */
|
555
|
-
#define PTW32_MAX(a,b) ((a)<(b)?(b):(a))
|
556
|
-
#define PTW32_MIN(a,b) ((a)>(b)?(b):(a))
|
557
|
-
|
558
|
-
|
559
|
-
/* Declared in pthread_cancel.c */
|
560
|
-
extern DWORD (*ptw32_register_cancelation) (PAPCFUNC, HANDLE, DWORD);
|
561
|
-
|
562
|
-
/* Thread Reuse stack bottom marker. Must not be NULL or any valid pointer to memory. */
|
563
|
-
#define PTW32_THREAD_REUSE_EMPTY ((ptw32_thread_t *)(size_t) 1)
|
564
|
-
|
565
|
-
extern int ptw32_processInitialized;
|
566
|
-
extern ptw32_thread_t * ptw32_threadReuseTop;
|
567
|
-
extern ptw32_thread_t * ptw32_threadReuseBottom;
|
568
|
-
extern pthread_key_t ptw32_selfThreadKey;
|
569
|
-
extern pthread_key_t ptw32_cleanupKey;
|
570
|
-
extern pthread_cond_t ptw32_cond_list_head;
|
571
|
-
extern pthread_cond_t ptw32_cond_list_tail;
|
572
|
-
|
573
|
-
extern int ptw32_mutex_default_kind;
|
574
|
-
|
575
|
-
extern unsigned __int64 ptw32_threadSeqNumber;
|
576
|
-
|
577
|
-
extern int ptw32_concurrency;
|
578
|
-
|
579
|
-
extern int ptw32_features;
|
580
|
-
|
581
|
-
extern ptw32_mcs_lock_t ptw32_thread_reuse_lock;
|
582
|
-
extern ptw32_mcs_lock_t ptw32_mutex_test_init_lock;
|
583
|
-
extern ptw32_mcs_lock_t ptw32_cond_list_lock;
|
584
|
-
extern ptw32_mcs_lock_t ptw32_cond_test_init_lock;
|
585
|
-
extern ptw32_mcs_lock_t ptw32_rwlock_test_init_lock;
|
586
|
-
extern ptw32_mcs_lock_t ptw32_spinlock_test_init_lock;
|
587
|
-
|
588
|
-
#if defined(_UWIN)
|
589
|
-
extern int pthread_count;
|
590
|
-
#endif
|
591
|
-
|
592
|
-
#if defined(__cplusplus)
|
593
|
-
extern "C"
|
594
|
-
{
|
595
|
-
#endif /* __cplusplus */
|
596
|
-
|
597
|
-
/*
|
598
|
-
* =====================
|
599
|
-
* =====================
|
600
|
-
* Forward Declarations
|
601
|
-
* =====================
|
602
|
-
* =====================
|
603
|
-
*/
|
604
|
-
|
605
|
-
int ptw32_is_attr (const pthread_attr_t * attr);
|
606
|
-
|
607
|
-
int ptw32_cond_check_need_init (pthread_cond_t * cond);
|
608
|
-
int ptw32_mutex_check_need_init (pthread_mutex_t * mutex);
|
609
|
-
int ptw32_rwlock_check_need_init (pthread_rwlock_t * rwlock);
|
610
|
-
int ptw32_spinlock_check_need_init (pthread_spinlock_t * lock);
|
611
|
-
|
612
|
-
int ptw32_robust_mutex_inherit(pthread_mutex_t * mutex);
|
613
|
-
void ptw32_robust_mutex_add(pthread_mutex_t* mutex, pthread_t self);
|
614
|
-
void ptw32_robust_mutex_remove(pthread_mutex_t* mutex, ptw32_thread_t* otp);
|
615
|
-
|
616
|
-
DWORD
|
617
|
-
ptw32_RegisterCancelation (PAPCFUNC callback,
|
618
|
-
HANDLE threadH, DWORD callback_arg);
|
619
|
-
|
620
|
-
int ptw32_processInitialize (void);
|
621
|
-
|
622
|
-
void ptw32_processTerminate (void);
|
623
|
-
|
624
|
-
void ptw32_threadDestroy (pthread_t tid);
|
625
|
-
|
626
|
-
void ptw32_pop_cleanup_all (int execute);
|
627
|
-
|
628
|
-
pthread_t ptw32_new (void);
|
629
|
-
|
630
|
-
pthread_t ptw32_threadReusePop (void);
|
631
|
-
|
632
|
-
void ptw32_threadReusePush (pthread_t thread);
|
633
|
-
|
634
|
-
int ptw32_getprocessors (int *count);
|
635
|
-
|
636
|
-
int ptw32_setthreadpriority (pthread_t thread, int policy, int priority);
|
637
|
-
|
638
|
-
void ptw32_rwlock_cancelwrwait (void *arg);
|
639
|
-
|
640
|
-
#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || (defined(__MSVCRT__) && ! defined(__DMC__))
|
641
|
-
unsigned __stdcall
|
642
|
-
#else
|
643
|
-
void
|
644
|
-
#endif
|
645
|
-
ptw32_threadStart (void *vthreadParms);
|
646
|
-
|
647
|
-
void ptw32_callUserDestroyRoutines (pthread_t thread);
|
648
|
-
|
649
|
-
int ptw32_tkAssocCreate (ptw32_thread_t * thread, pthread_key_t key);
|
650
|
-
|
651
|
-
void ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc);
|
652
|
-
|
653
|
-
int ptw32_semwait (sem_t * sem);
|
654
|
-
|
655
|
-
DWORD ptw32_relmillisecs (const struct timespec * abstime);
|
656
|
-
|
657
|
-
void ptw32_mcs_lock_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node);
|
658
|
-
|
659
|
-
int ptw32_mcs_lock_try_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node);
|
660
|
-
|
661
|
-
void ptw32_mcs_lock_release (ptw32_mcs_local_node_t * node);
|
662
|
-
|
663
|
-
void ptw32_mcs_node_transfer (ptw32_mcs_local_node_t * new_node, ptw32_mcs_local_node_t * old_node);
|
664
|
-
|
665
|
-
#if defined(NEED_FTIME)
|
666
|
-
void ptw32_timespec_to_filetime (const struct timespec *ts, FILETIME * ft);
|
667
|
-
void ptw32_filetime_to_timespec (const FILETIME * ft, struct timespec *ts);
|
668
|
-
#endif
|
669
|
-
|
670
|
-
/* Declared in misc.c */
|
671
|
-
#if defined(NEED_CALLOC)
|
672
|
-
#define calloc(n, s) ptw32_calloc(n, s)
|
673
|
-
void *ptw32_calloc (size_t n, size_t s);
|
674
|
-
#endif
|
675
|
-
|
676
|
-
/* Declared in private.c */
|
677
|
-
#if defined(_MSC_VER)
|
678
|
-
/*
|
679
|
-
* Ignore the warning:
|
680
|
-
* "C++ exception specification ignored except to indicate that
|
681
|
-
* the function is not __declspec(nothrow)."
|
682
|
-
*/
|
683
|
-
#pragma warning(disable:4290)
|
684
|
-
#endif
|
685
|
-
void ptw32_throw (DWORD exception)
|
686
|
-
#if defined(__CLEANUP_CXX)
|
687
|
-
throw(ptw32_exception_cancel,ptw32_exception_exit)
|
688
|
-
#endif
|
689
|
-
;
|
690
|
-
|
691
|
-
#if defined(__cplusplus)
|
692
|
-
}
|
693
|
-
#endif /* __cplusplus */
|
694
|
-
|
695
|
-
|
696
|
-
#if defined(_UWIN_)
|
697
|
-
# if defined(_MT)
|
698
|
-
# if defined(__cplusplus)
|
699
|
-
extern "C"
|
700
|
-
{
|
701
|
-
# endif
|
702
|
-
_CRTIMP unsigned long __cdecl _beginthread (void (__cdecl *) (void *),
|
703
|
-
unsigned, void *);
|
704
|
-
_CRTIMP void __cdecl _endthread (void);
|
705
|
-
_CRTIMP unsigned long __cdecl _beginthreadex (void *, unsigned,
|
706
|
-
unsigned (__stdcall *) (void *),
|
707
|
-
void *, unsigned, unsigned *);
|
708
|
-
_CRTIMP void __cdecl _endthreadex (unsigned);
|
709
|
-
# if defined(__cplusplus)
|
710
|
-
}
|
711
|
-
# endif
|
712
|
-
# endif
|
713
|
-
#else
|
714
|
-
# include <process.h>
|
715
|
-
# endif
|
716
|
-
|
717
|
-
|
718
|
-
/*
|
719
|
-
* Use intrinsic versions wherever possible. VC will do this
|
720
|
-
* automatically where possible and GCC define these if available:
|
721
|
-
* __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
|
722
|
-
* __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
|
723
|
-
* __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
|
724
|
-
* __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
|
725
|
-
* __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16
|
726
|
-
*
|
727
|
-
* The full set of Interlocked intrinsics in GCC are (check versions):
|
728
|
-
* type __sync_fetch_and_add (type *ptr, type value, ...)
|
729
|
-
* type __sync_fetch_and_sub (type *ptr, type value, ...)
|
730
|
-
* type __sync_fetch_and_or (type *ptr, type value, ...)
|
731
|
-
* type __sync_fetch_and_and (type *ptr, type value, ...)
|
732
|
-
* type __sync_fetch_and_xor (type *ptr, type value, ...)
|
733
|
-
* type __sync_fetch_and_nand (type *ptr, type value, ...)
|
734
|
-
* type __sync_add_and_fetch (type *ptr, type value, ...)
|
735
|
-
* type __sync_sub_and_fetch (type *ptr, type value, ...)
|
736
|
-
* type __sync_or_and_fetch (type *ptr, type value, ...)
|
737
|
-
* type __sync_and_and_fetch (type *ptr, type value, ...)
|
738
|
-
* type __sync_xor_and_fetch (type *ptr, type value, ...)
|
739
|
-
* type __sync_nand_and_fetch (type *ptr, type value, ...)
|
740
|
-
* bool __sync_bool_compare_and_swap (type *ptr, type oldval type newval, ...)
|
741
|
-
* type __sync_val_compare_and_swap (type *ptr, type oldval type newval, ...)
|
742
|
-
* __sync_synchronize (...) // Full memory barrier
|
743
|
-
* type __sync_lock_test_and_set (type *ptr, type value, ...) // Acquire barrier
|
744
|
-
* void __sync_lock_release (type *ptr, ...) // Release barrier
|
745
|
-
*
|
746
|
-
* These are all overloaded and take 1,2,4,8 byte scalar or pointer types.
|
747
|
-
*
|
748
|
-
* The above aren't available in Mingw32 as of gcc 4.5.2 so define our own.
|
749
|
-
*/
|
750
|
-
#if defined(__GNUC__)
|
751
|
-
# if defined(_WIN64)
|
752
|
-
# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_64(location, value, comparand) \
|
753
|
-
({ \
|
754
|
-
__typeof (value) _result; \
|
755
|
-
__asm__ __volatile__ \
|
756
|
-
( \
|
757
|
-
"lock\n\t" \
|
758
|
-
"cmpxchgq %2,(%1)" \
|
759
|
-
:"=a" (_result) \
|
760
|
-
:"r" (location), "r" (value), "a" (comparand) \
|
761
|
-
:"memory", "cc"); \
|
762
|
-
_result; \
|
763
|
-
})
|
764
|
-
# define PTW32_INTERLOCKED_EXCHANGE_64(location, value) \
|
765
|
-
({ \
|
766
|
-
__typeof (value) _result; \
|
767
|
-
__asm__ __volatile__ \
|
768
|
-
( \
|
769
|
-
"xchgq %0,(%1)" \
|
770
|
-
:"=r" (_result) \
|
771
|
-
:"r" (location), "0" (value) \
|
772
|
-
:"memory", "cc"); \
|
773
|
-
_result; \
|
774
|
-
})
|
775
|
-
# define PTW32_INTERLOCKED_EXCHANGE_ADD_64(location, value) \
|
776
|
-
({ \
|
777
|
-
__typeof (value) _result; \
|
778
|
-
__asm__ __volatile__ \
|
779
|
-
( \
|
780
|
-
"lock\n\t" \
|
781
|
-
"xaddq %0,(%1)" \
|
782
|
-
:"=r" (_result) \
|
783
|
-
:"r" (location), "0" (value) \
|
784
|
-
:"memory", "cc"); \
|
785
|
-
_result; \
|
786
|
-
})
|
787
|
-
# define PTW32_INTERLOCKED_INCREMENT_64(location) \
|
788
|
-
({ \
|
789
|
-
PTW32_INTERLOCKED_LONG _temp = 1; \
|
790
|
-
__asm__ __volatile__ \
|
791
|
-
( \
|
792
|
-
"lock\n\t" \
|
793
|
-
"xaddq %0,(%1)" \
|
794
|
-
:"+r" (_temp) \
|
795
|
-
:"r" (location) \
|
796
|
-
:"memory", "cc"); \
|
797
|
-
++_temp; \
|
798
|
-
})
|
799
|
-
# define PTW32_INTERLOCKED_DECREMENT_64(location) \
|
800
|
-
({ \
|
801
|
-
PTW32_INTERLOCKED_LONG _temp = -1; \
|
802
|
-
__asm__ __volatile__ \
|
803
|
-
( \
|
804
|
-
"lock\n\t" \
|
805
|
-
"xaddq %2,(%1)" \
|
806
|
-
:"+r" (_temp) \
|
807
|
-
:"r" (location) \
|
808
|
-
:"memory", "cc"); \
|
809
|
-
--_temp; \
|
810
|
-
})
|
811
|
-
#endif
|
812
|
-
# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG(location, value, comparand) \
|
813
|
-
({ \
|
814
|
-
__typeof (value) _result; \
|
815
|
-
__asm__ __volatile__ \
|
816
|
-
( \
|
817
|
-
"lock\n\t" \
|
818
|
-
"cmpxchgl %2,(%1)" \
|
819
|
-
:"=a" (_result) \
|
820
|
-
:"r" (location), "r" (value), "a" (comparand) \
|
821
|
-
:"memory", "cc"); \
|
822
|
-
_result; \
|
823
|
-
})
|
824
|
-
# define PTW32_INTERLOCKED_EXCHANGE_LONG(location, value) \
|
825
|
-
({ \
|
826
|
-
__typeof (value) _result; \
|
827
|
-
__asm__ __volatile__ \
|
828
|
-
( \
|
829
|
-
"xchgl %0,(%1)" \
|
830
|
-
:"=r" (_result) \
|
831
|
-
:"r" (location), "0" (value) \
|
832
|
-
:"memory", "cc"); \
|
833
|
-
_result; \
|
834
|
-
})
|
835
|
-
# define PTW32_INTERLOCKED_EXCHANGE_ADD_LONG(location, value) \
|
836
|
-
({ \
|
837
|
-
__typeof (value) _result; \
|
838
|
-
__asm__ __volatile__ \
|
839
|
-
( \
|
840
|
-
"lock\n\t" \
|
841
|
-
"xaddl %0,(%1)" \
|
842
|
-
:"=r" (_result) \
|
843
|
-
:"r" (location), "0" (value) \
|
844
|
-
:"memory", "cc"); \
|
845
|
-
_result; \
|
846
|
-
})
|
847
|
-
# define PTW32_INTERLOCKED_INCREMENT_LONG(location) \
|
848
|
-
({ \
|
849
|
-
PTW32_INTERLOCKED_LONG _temp = 1; \
|
850
|
-
__asm__ __volatile__ \
|
851
|
-
( \
|
852
|
-
"lock\n\t" \
|
853
|
-
"xaddl %0,(%1)" \
|
854
|
-
:"+r" (_temp) \
|
855
|
-
:"r" (location) \
|
856
|
-
:"memory", "cc"); \
|
857
|
-
++_temp; \
|
858
|
-
})
|
859
|
-
# define PTW32_INTERLOCKED_DECREMENT_LONG(location) \
|
860
|
-
({ \
|
861
|
-
PTW32_INTERLOCKED_LONG _temp = -1; \
|
862
|
-
__asm__ __volatile__ \
|
863
|
-
( \
|
864
|
-
"lock\n\t" \
|
865
|
-
"xaddl %0,(%1)" \
|
866
|
-
:"+r" (_temp) \
|
867
|
-
:"r" (location) \
|
868
|
-
:"memory", "cc"); \
|
869
|
-
--_temp; \
|
870
|
-
})
|
871
|
-
# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR(location, value, comparand) \
|
872
|
-
PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE((PTW32_INTERLOCKED_SIZEPTR)location, \
|
873
|
-
(PTW32_INTERLOCKED_SIZE)value, \
|
874
|
-
(PTW32_INTERLOCKED_SIZE)comparand)
|
875
|
-
# define PTW32_INTERLOCKED_EXCHANGE_PTR(location, value) \
|
876
|
-
PTW32_INTERLOCKED_EXCHANGE_SIZE((PTW32_INTERLOCKED_SIZEPTR)location, \
|
877
|
-
(PTW32_INTERLOCKED_SIZE)value)
|
878
|
-
#else
|
879
|
-
# if defined(_WIN64)
|
880
|
-
# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_64 InterlockedCompareExchange64
|
881
|
-
# define PTW32_INTERLOCKED_EXCHANGE_64 InterlockedExchange64
|
882
|
-
# define PTW32_INTERLOCKED_EXCHANGE_ADD_64 InterlockedExchangeAdd64
|
883
|
-
# define PTW32_INTERLOCKED_INCREMENT_64 InterlockedIncrement64
|
884
|
-
# define PTW32_INTERLOCKED_DECREMENT_64 InterlockedDecrement64
|
885
|
-
# endif
|
886
|
-
# if defined(_MSC_VER) && _MSC_VER < 1300 && !defined(_WIN64) /* MSVC 6 */
|
887
|
-
# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG(location, value, comparand) \
|
888
|
-
((LONG)InterlockedCompareExchange((PVOID *)(location), (PVOID)(value), (PVOID)(comparand)))
|
889
|
-
# else
|
890
|
-
# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG InterlockedCompareExchange
|
891
|
-
# endif
|
892
|
-
# define PTW32_INTERLOCKED_EXCHANGE_LONG InterlockedExchange
|
893
|
-
# define PTW32_INTERLOCKED_EXCHANGE_ADD_LONG InterlockedExchangeAdd
|
894
|
-
# define PTW32_INTERLOCKED_INCREMENT_LONG InterlockedIncrement
|
895
|
-
# define PTW32_INTERLOCKED_DECREMENT_LONG InterlockedDecrement
|
896
|
-
# if defined(_MSC_VER) && _MSC_VER < 1300 && !defined(_WIN64) /* MSVC 6 */
|
897
|
-
# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR InterlockedCompareExchange
|
898
|
-
# define PTW32_INTERLOCKED_EXCHANGE_PTR(location, value) \
|
899
|
-
((PVOID)InterlockedExchange((LPLONG)(location), (LONG)(value)))
|
900
|
-
# else
|
901
|
-
# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR InterlockedCompareExchangePointer
|
902
|
-
# define PTW32_INTERLOCKED_EXCHANGE_PTR InterlockedExchangePointer
|
903
|
-
# endif
|
904
|
-
#endif
|
905
|
-
#if defined(_WIN64)
|
906
|
-
# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE PTW32_INTERLOCKED_COMPARE_EXCHANGE_64
|
907
|
-
# define PTW32_INTERLOCKED_EXCHANGE_SIZE PTW32_INTERLOCKED_EXCHANGE_64
|
908
|
-
# define PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE PTW32_INTERLOCKED_EXCHANGE_ADD_64
|
909
|
-
# define PTW32_INTERLOCKED_INCREMENT_SIZE PTW32_INTERLOCKED_INCREMENT_64
|
910
|
-
# define PTW32_INTERLOCKED_DECREMENT_SIZE PTW32_INTERLOCKED_DECREMENT_64
|
911
|
-
#else
|
912
|
-
# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG
|
913
|
-
# define PTW32_INTERLOCKED_EXCHANGE_SIZE PTW32_INTERLOCKED_EXCHANGE_LONG
|
914
|
-
# define PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE PTW32_INTERLOCKED_EXCHANGE_ADD_LONG
|
915
|
-
# define PTW32_INTERLOCKED_INCREMENT_SIZE PTW32_INTERLOCKED_INCREMENT_LONG
|
916
|
-
# define PTW32_INTERLOCKED_DECREMENT_SIZE PTW32_INTERLOCKED_DECREMENT_LONG
|
917
|
-
#endif
|
918
|
-
|
919
|
-
#if defined(NEED_CREATETHREAD)
|
920
|
-
|
921
|
-
/*
|
922
|
-
* Macro uses args so we can cast start_proc to LPTHREAD_START_ROUTINE
|
923
|
-
* in order to avoid warnings because of return type
|
924
|
-
*/
|
925
|
-
|
926
|
-
#define _beginthreadex(security, \
|
927
|
-
stack_size, \
|
928
|
-
start_proc, \
|
929
|
-
arg, \
|
930
|
-
flags, \
|
931
|
-
pid) \
|
932
|
-
CreateThread(security, \
|
933
|
-
stack_size, \
|
934
|
-
(LPTHREAD_START_ROUTINE) start_proc, \
|
935
|
-
arg, \
|
936
|
-
flags, \
|
937
|
-
pid)
|
938
|
-
|
939
|
-
#define _endthreadex ExitThread
|
940
|
-
|
941
|
-
#endif /* NEED_CREATETHREAD */
|
942
|
-
|
943
|
-
|
944
|
-
#endif /* _IMPLEMENT_H */
|