noderb 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +19 -0
- data/README.md +25 -0
- data/ext/noderb_extension/extconf.rb +11 -0
- data/ext/noderb_extension/libuv/AUTHORS +11 -0
- data/ext/noderb_extension/libuv/LICENSE +48 -0
- data/ext/noderb_extension/libuv/Makefile +119 -0
- data/ext/noderb_extension/libuv/README +45 -0
- data/ext/noderb_extension/libuv/build/all.gyp +254 -0
- data/ext/noderb_extension/libuv/build/common.gypi +13 -0
- data/ext/noderb_extension/libuv/build/gyp_uv +43 -0
- data/ext/noderb_extension/libuv/config-mingw.mk +67 -0
- data/ext/noderb_extension/libuv/config-unix.mk +121 -0
- data/ext/noderb_extension/libuv/create-msvs-files.bat +14 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ANNOUNCE +482 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/BUGS +141 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/Bmakefile +268 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/CONTRIBUTORS +140 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/COPYING +150 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/COPYING.LIB +504 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ChangeLog +5194 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/FAQ +451 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/GNUmakefile +593 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/MAINTAINERS +4 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/Makefile +516 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/NEWS +1245 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/Nmakefile +24 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/Nmakefile.tests +260 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/PROGRESS +4 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/README +601 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.Borland +57 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.CV +3036 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.NONPORTABLE +783 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.Watcom +62 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.WinCE +6 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/TODO +7 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/WinCE-PORT +222 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/attr.c +53 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/autostatic.c +69 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/barrier.c +47 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/build/all.gyp +207 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/builddmc.bat +9 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/cancel.c +44 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/cleanup.c +148 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/condvar.c +50 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/config.h +153 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/context.h +74 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/create.c +308 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/dll.c +92 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/errno.c +94 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/exit.c +44 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/fork.c +39 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/global.c +107 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/implement.h +944 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/misc.c +50 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/mutex.c +62 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/need_errno.h +145 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/nonportable.c +47 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/private.c +54 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.c +66 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.dsp +142 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.dsw +29 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.h +1368 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_destroy.c +79 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getdetachstate.c +86 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getinheritsched.c +51 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getschedparam.c +52 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getschedpolicy.c +61 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getscope.c +54 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getstackaddr.c +97 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getstacksize.c +100 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_init.c +117 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setdetachstate.c +91 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setinheritsched.c +57 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setschedparam.c +63 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setschedpolicy.c +55 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setscope.c +62 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setstackaddr.c +97 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setstacksize.c +110 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrier_destroy.c +103 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrier_init.c +69 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrier_wait.c +104 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_destroy.c +83 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_getpshared.c +95 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_init.c +85 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_setpshared.c +119 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cancel.c +189 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_destroy.c +253 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_init.c +167 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_signal.c +231 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_wait.c +567 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_destroy.c +86 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_getpshared.c +97 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_init.c +87 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_setpshared.c +117 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_delay_np.c +172 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_detach.c +136 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_equal.c +76 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_exit.c +106 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getconcurrency.c +45 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getschedparam.c +75 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getspecific.c +87 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getunique_np.c +47 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getw32threadhandle_np.c +65 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_join.c +157 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_key_create.c +108 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_key_delete.c +125 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_kill.c +105 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_consistent.c +187 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_destroy.c +148 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_init.c +130 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_lock.c +269 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_timedlock.c +324 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_trylock.c +154 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_unlock.c +175 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_destroy.c +83 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_getkind_np.c +44 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_getpshared.c +95 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_getrobust.c +113 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_gettype.c +56 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_init.c +86 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_setkind_np.c +44 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_setpshared.c +119 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_setrobust.c +119 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_settype.c +143 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_num_processors_np.c +56 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_once.c +79 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_destroy.c +143 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_init.c +109 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_rdlock.c +102 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_timedrdlock.c +109 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_timedwrlock.c +139 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_tryrdlock.c +102 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_trywrlock.c +122 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_unlock.c +93 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_wrlock.c +133 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_destroy.c +84 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_getpshared.c +97 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_init.c +83 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_setpshared.c +120 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_self.c +141 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setcancelstate.c +125 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setcanceltype.c +126 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setconcurrency.c +53 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setschedparam.c +123 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setspecific.c +167 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_destroy.c +111 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_init.c +123 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_lock.c +80 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_trylock.c +77 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_unlock.c +71 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_testcancel.c +103 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_timechange_handler_np.c +108 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_win32_attach_detach_np.c +258 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_MCS_lock.c +278 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_callUserDestroyRoutines.c +232 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_calloc.c +56 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_cond_check_need_init.c +78 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_getprocessors.c +91 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_is_attr.c +47 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_mutex_check_need_init.c +92 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_new.c +94 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_processInitialize.c +92 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_processTerminate.c +105 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_relmillisecs.c +132 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_reuse.c +151 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_rwlock_cancelwrwait.c +50 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_rwlock_check_need_init.c +77 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_semwait.c +135 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_spinlock_check_need_init.c +78 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_threadDestroy.c +79 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_threadStart.c +357 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_throw.c +189 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_timespec.c +83 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_tkAssocCreate.c +118 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_tkAssocDestroy.c +114 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/rwlock.c +51 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched.c +53 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched.h +183 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_get_priority_max.c +134 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_get_priority_min.c +135 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_getscheduler.c +71 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_setscheduler.c +83 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_yield.c +71 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_close.c +58 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_destroy.c +144 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_getvalue.c +110 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_init.c +169 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_open.c +58 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_post.c +128 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_post_multiple.c +142 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_timedwait.c +238 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_trywait.c +117 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_unlink.c +58 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_wait.c +187 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/semaphore.c +69 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/semaphore.h +169 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/signal.c +179 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/spin.c +46 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sync.c +43 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/tsd.c +44 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/version.rc +388 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/w32_CancelableWait.c +161 -0
- data/ext/noderb_extension/libuv/doc/desired-api.md +159 -0
- data/ext/noderb_extension/libuv/doc/iocp-links.html +574 -0
- data/ext/noderb_extension/libuv/include/ares.h +582 -0
- data/ext/noderb_extension/libuv/include/ares_version.h +24 -0
- data/ext/noderb_extension/libuv/include/eio.h +376 -0
- data/ext/noderb_extension/libuv/include/ev.h +835 -0
- data/ext/noderb_extension/libuv/include/ngx-queue.h +102 -0
- data/ext/noderb_extension/libuv/include/tree.h +762 -0
- data/ext/noderb_extension/libuv/include/uv-unix.h +138 -0
- data/ext/noderb_extension/libuv/include/uv-win.h +187 -0
- data/ext/noderb_extension/libuv/include/uv.h +635 -0
- data/ext/noderb_extension/libuv/src/ares/AUTHORS +37 -0
- data/ext/noderb_extension/libuv/src/ares/CHANGES +1198 -0
- data/ext/noderb_extension/libuv/src/ares/CMakeLists.txt +22 -0
- data/ext/noderb_extension/libuv/src/ares/NEWS +21 -0
- data/ext/noderb_extension/libuv/src/ares/README +60 -0
- data/ext/noderb_extension/libuv/src/ares/README.cares +13 -0
- data/ext/noderb_extension/libuv/src/ares/README.msvc +118 -0
- data/ext/noderb_extension/libuv/src/ares/README.node +21 -0
- data/ext/noderb_extension/libuv/src/ares/RELEASE-NOTES +25 -0
- data/ext/noderb_extension/libuv/src/ares/TODO +23 -0
- data/ext/noderb_extension/libuv/src/ares/ares__close_sockets.c +66 -0
- data/ext/noderb_extension/libuv/src/ares/ares__get_hostent.c +263 -0
- data/ext/noderb_extension/libuv/src/ares/ares__read_line.c +71 -0
- data/ext/noderb_extension/libuv/src/ares/ares__timeval.c +111 -0
- data/ext/noderb_extension/libuv/src/ares/ares_cancel.c +63 -0
- data/ext/noderb_extension/libuv/src/ares/ares_data.c +190 -0
- data/ext/noderb_extension/libuv/src/ares/ares_data.h +65 -0
- data/ext/noderb_extension/libuv/src/ares/ares_destroy.c +105 -0
- data/ext/noderb_extension/libuv/src/ares/ares_dns.h +90 -0
- data/ext/noderb_extension/libuv/src/ares/ares_expand_name.c +193 -0
- data/ext/noderb_extension/libuv/src/ares/ares_expand_string.c +75 -0
- data/ext/noderb_extension/libuv/src/ares/ares_fds.c +62 -0
- data/ext/noderb_extension/libuv/src/ares/ares_free_hostent.c +39 -0
- data/ext/noderb_extension/libuv/src/ares/ares_free_string.c +25 -0
- data/ext/noderb_extension/libuv/src/ares/ares_gethostbyaddr.c +292 -0
- data/ext/noderb_extension/libuv/src/ares/ares_gethostbyname.c +515 -0
- data/ext/noderb_extension/libuv/src/ares/ares_getnameinfo.c +426 -0
- data/ext/noderb_extension/libuv/src/ares/ares_getopt.c +122 -0
- data/ext/noderb_extension/libuv/src/ares/ares_getopt.h +53 -0
- data/ext/noderb_extension/libuv/src/ares/ares_getsock.c +72 -0
- data/ext/noderb_extension/libuv/src/ares/ares_init.c +1665 -0
- data/ext/noderb_extension/libuv/src/ares/ares_ipv6.h +78 -0
- data/ext/noderb_extension/libuv/src/ares/ares_library_init.c +132 -0
- data/ext/noderb_extension/libuv/src/ares/ares_library_init.h +39 -0
- data/ext/noderb_extension/libuv/src/ares/ares_llist.c +86 -0
- data/ext/noderb_extension/libuv/src/ares/ares_llist.h +42 -0
- data/ext/noderb_extension/libuv/src/ares/ares_mkquery.c +195 -0
- data/ext/noderb_extension/libuv/src/ares/ares_nowarn.c +59 -0
- data/ext/noderb_extension/libuv/src/ares/ares_nowarn.h +24 -0
- data/ext/noderb_extension/libuv/src/ares/ares_options.c +253 -0
- data/ext/noderb_extension/libuv/src/ares/ares_parse_a_reply.c +260 -0
- data/ext/noderb_extension/libuv/src/ares/ares_parse_aaaa_reply.c +256 -0
- data/ext/noderb_extension/libuv/src/ares/ares_parse_mx_reply.c +170 -0
- data/ext/noderb_extension/libuv/src/ares/ares_parse_ns_reply.c +182 -0
- data/ext/noderb_extension/libuv/src/ares/ares_parse_ptr_reply.c +208 -0
- data/ext/noderb_extension/libuv/src/ares/ares_parse_srv_reply.c +179 -0
- data/ext/noderb_extension/libuv/src/ares/ares_parse_txt_reply.c +201 -0
- data/ext/noderb_extension/libuv/src/ares/ares_private.h +351 -0
- data/ext/noderb_extension/libuv/src/ares/ares_process.c +1296 -0
- data/ext/noderb_extension/libuv/src/ares/ares_query.c +183 -0
- data/ext/noderb_extension/libuv/src/ares/ares_rules.h +144 -0
- data/ext/noderb_extension/libuv/src/ares/ares_search.c +322 -0
- data/ext/noderb_extension/libuv/src/ares/ares_send.c +134 -0
- data/ext/noderb_extension/libuv/src/ares/ares_setup.h +191 -0
- data/ext/noderb_extension/libuv/src/ares/ares_strcasecmp.c +66 -0
- data/ext/noderb_extension/libuv/src/ares/ares_strcasecmp.h +30 -0
- data/ext/noderb_extension/libuv/src/ares/ares_strdup.c +42 -0
- data/ext/noderb_extension/libuv/src/ares/ares_strdup.h +26 -0
- data/ext/noderb_extension/libuv/src/ares/ares_strerror.c +56 -0
- data/ext/noderb_extension/libuv/src/ares/ares_timeout.c +80 -0
- data/ext/noderb_extension/libuv/src/ares/ares_version.c +11 -0
- data/ext/noderb_extension/libuv/src/ares/ares_writev.c +79 -0
- data/ext/noderb_extension/libuv/src/ares/ares_writev.h +36 -0
- data/ext/noderb_extension/libuv/src/ares/bitncmp.c +59 -0
- data/ext/noderb_extension/libuv/src/ares/bitncmp.h +26 -0
- data/ext/noderb_extension/libuv/src/ares/config_cygwin/ares_config.h +510 -0
- data/ext/noderb_extension/libuv/src/ares/config_darwin/ares_config.h +510 -0
- data/ext/noderb_extension/libuv/src/ares/config_freebsd/ares_config.h +510 -0
- data/ext/noderb_extension/libuv/src/ares/config_linux/ares_config.h +510 -0
- data/ext/noderb_extension/libuv/src/ares/config_openbsd/ares_config.h +510 -0
- data/ext/noderb_extension/libuv/src/ares/config_sunos/ares_config.h +510 -0
- data/ext/noderb_extension/libuv/src/ares/config_win32/ares_config.h +369 -0
- data/ext/noderb_extension/libuv/src/ares/get_ver.awk +35 -0
- data/ext/noderb_extension/libuv/src/ares/inet_net_pton.c +450 -0
- data/ext/noderb_extension/libuv/src/ares/inet_net_pton.h +31 -0
- data/ext/noderb_extension/libuv/src/ares/inet_ntop.c +232 -0
- data/ext/noderb_extension/libuv/src/ares/inet_ntop.h +27 -0
- data/ext/noderb_extension/libuv/src/ares/nameser.h +193 -0
- data/ext/noderb_extension/libuv/src/ares/setup_once.h +488 -0
- data/ext/noderb_extension/libuv/src/ares/windows_port.c +22 -0
- data/ext/noderb_extension/libuv/src/eio/Changes +63 -0
- data/ext/noderb_extension/libuv/src/eio/LICENSE +36 -0
- data/ext/noderb_extension/libuv/src/eio/Makefile.am +15 -0
- data/ext/noderb_extension/libuv/src/eio/aclocal.m4 +8957 -0
- data/ext/noderb_extension/libuv/src/eio/autogen.sh +3 -0
- data/ext/noderb_extension/libuv/src/eio/config.h.in +86 -0
- data/ext/noderb_extension/libuv/src/eio/config_cygwin.h +77 -0
- data/ext/noderb_extension/libuv/src/eio/config_darwin.h +137 -0
- data/ext/noderb_extension/libuv/src/eio/config_freebsd.h +78 -0
- data/ext/noderb_extension/libuv/src/eio/config_linux.h +101 -0
- data/ext/noderb_extension/libuv/src/eio/config_sunos.h +81 -0
- data/ext/noderb_extension/libuv/src/eio/configure.ac +22 -0
- data/ext/noderb_extension/libuv/src/eio/demo.c +194 -0
- data/ext/noderb_extension/libuv/src/eio/ecb.h +370 -0
- data/ext/noderb_extension/libuv/src/eio/eio.3 +3428 -0
- data/ext/noderb_extension/libuv/src/eio/eio.c +2562 -0
- data/ext/noderb_extension/libuv/src/eio/eio.pod +969 -0
- data/ext/noderb_extension/libuv/src/eio/libeio.m4 +195 -0
- data/ext/noderb_extension/libuv/src/eio/xthread.h +164 -0
- data/ext/noderb_extension/libuv/src/ev/Changes +388 -0
- data/ext/noderb_extension/libuv/src/ev/LICENSE +36 -0
- data/ext/noderb_extension/libuv/src/ev/Makefile.am +18 -0
- data/ext/noderb_extension/libuv/src/ev/Makefile.in +771 -0
- data/ext/noderb_extension/libuv/src/ev/README +58 -0
- data/ext/noderb_extension/libuv/src/ev/aclocal.m4 +8957 -0
- data/ext/noderb_extension/libuv/src/ev/autogen.sh +6 -0
- data/ext/noderb_extension/libuv/src/ev/config.guess +1526 -0
- data/ext/noderb_extension/libuv/src/ev/config.h.in +125 -0
- data/ext/noderb_extension/libuv/src/ev/config.sub +1658 -0
- data/ext/noderb_extension/libuv/src/ev/config_cygwin.h +123 -0
- data/ext/noderb_extension/libuv/src/ev/config_darwin.h +122 -0
- data/ext/noderb_extension/libuv/src/ev/config_freebsd.h +120 -0
- data/ext/noderb_extension/libuv/src/ev/config_linux.h +130 -0
- data/ext/noderb_extension/libuv/src/ev/config_sunos.h +122 -0
- data/ext/noderb_extension/libuv/src/ev/configure +13037 -0
- data/ext/noderb_extension/libuv/src/ev/configure.ac +18 -0
- data/ext/noderb_extension/libuv/src/ev/depcomp +630 -0
- data/ext/noderb_extension/libuv/src/ev/ev++.h +816 -0
- data/ext/noderb_extension/libuv/src/ev/ev.3 +5311 -0
- data/ext/noderb_extension/libuv/src/ev/ev.c +3913 -0
- data/ext/noderb_extension/libuv/src/ev/ev.pod +5243 -0
- data/ext/noderb_extension/libuv/src/ev/ev_epoll.c +266 -0
- data/ext/noderb_extension/libuv/src/ev/ev_kqueue.c +198 -0
- data/ext/noderb_extension/libuv/src/ev/ev_poll.c +148 -0
- data/ext/noderb_extension/libuv/src/ev/ev_port.c +179 -0
- data/ext/noderb_extension/libuv/src/ev/ev_select.c +310 -0
- data/ext/noderb_extension/libuv/src/ev/ev_vars.h +203 -0
- data/ext/noderb_extension/libuv/src/ev/ev_win32.c +153 -0
- data/ext/noderb_extension/libuv/src/ev/ev_wrap.h +196 -0
- data/ext/noderb_extension/libuv/src/ev/event.c +402 -0
- data/ext/noderb_extension/libuv/src/ev/event.h +170 -0
- data/ext/noderb_extension/libuv/src/ev/install-sh +294 -0
- data/ext/noderb_extension/libuv/src/ev/libev.m4 +39 -0
- data/ext/noderb_extension/libuv/src/ev/ltmain.sh +8413 -0
- data/ext/noderb_extension/libuv/src/ev/missing +336 -0
- data/ext/noderb_extension/libuv/src/ev/mkinstalldirs +111 -0
- data/ext/noderb_extension/libuv/src/uv-common.c +172 -0
- data/ext/noderb_extension/libuv/src/uv-common.h +53 -0
- data/ext/noderb_extension/libuv/src/uv-cygwin.c +52 -0
- data/ext/noderb_extension/libuv/src/uv-darwin.c +64 -0
- data/ext/noderb_extension/libuv/src/uv-eio.c +113 -0
- data/ext/noderb_extension/libuv/src/uv-eio.h +13 -0
- data/ext/noderb_extension/libuv/src/uv-freebsd.c +65 -0
- data/ext/noderb_extension/libuv/src/uv-linux.c +51 -0
- data/ext/noderb_extension/libuv/src/uv-sunos.c +60 -0
- data/ext/noderb_extension/libuv/src/uv-unix.c +2408 -0
- data/ext/noderb_extension/libuv/src/win/async.c +129 -0
- data/ext/noderb_extension/libuv/src/win/cares.c +304 -0
- data/ext/noderb_extension/libuv/src/win/core.c +155 -0
- data/ext/noderb_extension/libuv/src/win/error.c +140 -0
- data/ext/noderb_extension/libuv/src/win/getaddrinfo.c +341 -0
- data/ext/noderb_extension/libuv/src/win/handle.c +176 -0
- data/ext/noderb_extension/libuv/src/win/internal.h +237 -0
- data/ext/noderb_extension/libuv/src/win/loop-watcher.c +128 -0
- data/ext/noderb_extension/libuv/src/win/pipe.c +828 -0
- data/ext/noderb_extension/libuv/src/win/process.c +936 -0
- data/ext/noderb_extension/libuv/src/win/req.c +141 -0
- data/ext/noderb_extension/libuv/src/win/stdio.c +75 -0
- data/ext/noderb_extension/libuv/src/win/stream.c +149 -0
- data/ext/noderb_extension/libuv/src/win/tcp.c +895 -0
- data/ext/noderb_extension/libuv/src/win/timer.c +269 -0
- data/ext/noderb_extension/libuv/src/win/util.c +82 -0
- data/ext/noderb_extension/libuv/test/benchmark-ares.c +117 -0
- data/ext/noderb_extension/libuv/test/benchmark-getaddrinfo.c +90 -0
- data/ext/noderb_extension/libuv/test/benchmark-list.h +77 -0
- data/ext/noderb_extension/libuv/test/benchmark-ping-pongs.c +210 -0
- data/ext/noderb_extension/libuv/test/benchmark-pound.c +237 -0
- data/ext/noderb_extension/libuv/test/benchmark-pump.c +459 -0
- data/ext/noderb_extension/libuv/test/benchmark-sizes.c +39 -0
- data/ext/noderb_extension/libuv/test/benchmark-spawn.c +154 -0
- data/ext/noderb_extension/libuv/test/dns-server.c +323 -0
- data/ext/noderb_extension/libuv/test/echo-server.c +299 -0
- data/ext/noderb_extension/libuv/test/run-benchmarks.c +64 -0
- data/ext/noderb_extension/libuv/test/run-tests.c +82 -0
- data/ext/noderb_extension/libuv/test/runner-unix.c +335 -0
- data/ext/noderb_extension/libuv/test/runner-unix.h +36 -0
- data/ext/noderb_extension/libuv/test/runner-win.c +343 -0
- data/ext/noderb_extension/libuv/test/runner-win.h +42 -0
- data/ext/noderb_extension/libuv/test/runner.c +311 -0
- data/ext/noderb_extension/libuv/test/runner.h +155 -0
- data/ext/noderb_extension/libuv/test/task.h +111 -0
- data/ext/noderb_extension/libuv/test/test-async.c +218 -0
- data/ext/noderb_extension/libuv/test/test-callback-stack.c +205 -0
- data/ext/noderb_extension/libuv/test/test-connection-fail.c +149 -0
- data/ext/noderb_extension/libuv/test/test-delayed-accept.c +198 -0
- data/ext/noderb_extension/libuv/test/test-fail-always.c +29 -0
- data/ext/noderb_extension/libuv/test/test-get-currentexe.c +53 -0
- data/ext/noderb_extension/libuv/test/test-getaddrinfo.c +110 -0
- data/ext/noderb_extension/libuv/test/test-gethostbyname.c +192 -0
- data/ext/noderb_extension/libuv/test/test-getsockname.c +196 -0
- data/ext/noderb_extension/libuv/test/test-hrtime.c +51 -0
- data/ext/noderb_extension/libuv/test/test-idle.c +83 -0
- data/ext/noderb_extension/libuv/test/test-list.h +165 -0
- data/ext/noderb_extension/libuv/test/test-loop-handles.c +361 -0
- data/ext/noderb_extension/libuv/test/test-pass-always.c +28 -0
- data/ext/noderb_extension/libuv/test/test-ping-pong.c +256 -0
- data/ext/noderb_extension/libuv/test/test-pipe-bind-error.c +148 -0
- data/ext/noderb_extension/libuv/test/test-ref.c +91 -0
- data/ext/noderb_extension/libuv/test/test-shutdown-eof.c +183 -0
- data/ext/noderb_extension/libuv/test/test-spawn.c +345 -0
- data/ext/noderb_extension/libuv/test/test-tcp-bind-error.c +204 -0
- data/ext/noderb_extension/libuv/test/test-tcp-bind6-error.c +164 -0
- data/ext/noderb_extension/libuv/test/test-tcp-writealot.c +198 -0
- data/ext/noderb_extension/libuv/test/test-timer-again.c +141 -0
- data/ext/noderb_extension/libuv/test/test-timer.c +134 -0
- data/ext/noderb_extension/noderb.c +340 -0
- data/ext/noderb_extension/noderb.h +2 -0
- data/lib/noderb/connection.rb +21 -0
- data/lib/noderb/process.rb +17 -0
- data/lib/noderb.rb +25 -0
- metadata +470 -0
@@ -0,0 +1,762 @@
|
|
1
|
+
/*-
|
2
|
+
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
3
|
+
* All rights reserved.
|
4
|
+
*
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
6
|
+
* modification, are permitted provided that the following conditions
|
7
|
+
* are met:
|
8
|
+
* 1. Redistributions of source code must retain the above copyright
|
9
|
+
* notice, this list of conditions and the following disclaimer.
|
10
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer in the
|
12
|
+
* documentation and/or other materials provided with the distribution.
|
13
|
+
*
|
14
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
15
|
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
16
|
+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
17
|
+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
18
|
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
19
|
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
20
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
21
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
22
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
23
|
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
24
|
+
*/
|
25
|
+
|
26
|
+
#ifndef _UV_TREE_H_
|
27
|
+
#define _UV_TREE_H_
|
28
|
+
|
29
|
+
#define __unused
|
30
|
+
|
31
|
+
/*
|
32
|
+
* This file defines data structures for different types of trees:
|
33
|
+
* splay trees and red-black trees.
|
34
|
+
*
|
35
|
+
* A splay tree is a self-organizing data structure. Every operation
|
36
|
+
* on the tree causes a splay to happen. The splay moves the requested
|
37
|
+
* node to the root of the tree and partly rebalances it.
|
38
|
+
*
|
39
|
+
* This has the benefit that request locality causes faster lookups as
|
40
|
+
* the requested nodes move to the top of the tree. On the other hand,
|
41
|
+
* every lookup causes memory writes.
|
42
|
+
*
|
43
|
+
* The Balance Theorem bounds the total access time for m operations
|
44
|
+
* and n inserts on an initially empty tree as O((m + n)lg n). The
|
45
|
+
* amortized cost for a sequence of m accesses to a splay tree is O(lg n);
|
46
|
+
*
|
47
|
+
* A red-black tree is a binary search tree with the node color as an
|
48
|
+
* extra attribute. It fulfills a set of conditions:
|
49
|
+
* - every search path from the root to a leaf consists of the
|
50
|
+
* same number of black nodes,
|
51
|
+
* - each red node (except for the root) has a black parent,
|
52
|
+
* - each leaf node is black.
|
53
|
+
*
|
54
|
+
* Every operation on a red-black tree is bounded as O(lg n).
|
55
|
+
* The maximum height of a red-black tree is 2lg (n+1).
|
56
|
+
*/
|
57
|
+
|
58
|
+
#define SPLAY_HEAD(name, type) \
|
59
|
+
struct name { \
|
60
|
+
struct type *sph_root; /* root of the tree */ \
|
61
|
+
}
|
62
|
+
|
63
|
+
#define SPLAY_INITIALIZER(root) \
|
64
|
+
{ NULL }
|
65
|
+
|
66
|
+
#define SPLAY_INIT(root) do { \
|
67
|
+
(root)->sph_root = NULL; \
|
68
|
+
} while (/*CONSTCOND*/ 0)
|
69
|
+
|
70
|
+
#define SPLAY_ENTRY(type) \
|
71
|
+
struct { \
|
72
|
+
struct type *spe_left; /* left element */ \
|
73
|
+
struct type *spe_right; /* right element */ \
|
74
|
+
}
|
75
|
+
|
76
|
+
#define SPLAY_LEFT(elm, field) (elm)->field.spe_left
|
77
|
+
#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right
|
78
|
+
#define SPLAY_ROOT(head) (head)->sph_root
|
79
|
+
#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL)
|
80
|
+
|
81
|
+
/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */
|
82
|
+
#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \
|
83
|
+
SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \
|
84
|
+
SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
|
85
|
+
(head)->sph_root = tmp; \
|
86
|
+
} while (/*CONSTCOND*/ 0)
|
87
|
+
|
88
|
+
#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \
|
89
|
+
SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \
|
90
|
+
SPLAY_LEFT(tmp, field) = (head)->sph_root; \
|
91
|
+
(head)->sph_root = tmp; \
|
92
|
+
} while (/*CONSTCOND*/ 0)
|
93
|
+
|
94
|
+
#define SPLAY_LINKLEFT(head, tmp, field) do { \
|
95
|
+
SPLAY_LEFT(tmp, field) = (head)->sph_root; \
|
96
|
+
tmp = (head)->sph_root; \
|
97
|
+
(head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \
|
98
|
+
} while (/*CONSTCOND*/ 0)
|
99
|
+
|
100
|
+
#define SPLAY_LINKRIGHT(head, tmp, field) do { \
|
101
|
+
SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
|
102
|
+
tmp = (head)->sph_root; \
|
103
|
+
(head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \
|
104
|
+
} while (/*CONSTCOND*/ 0)
|
105
|
+
|
106
|
+
#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \
|
107
|
+
SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \
|
108
|
+
SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field); \
|
109
|
+
SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \
|
110
|
+
SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \
|
111
|
+
} while (/*CONSTCOND*/ 0)
|
112
|
+
|
113
|
+
/* Generates prototypes and inline functions */
|
114
|
+
|
115
|
+
#define SPLAY_PROTOTYPE(name, type, field, cmp) \
|
116
|
+
void name##_SPLAY(struct name *, struct type *); \
|
117
|
+
void name##_SPLAY_MINMAX(struct name *, int); \
|
118
|
+
struct type *name##_SPLAY_INSERT(struct name *, struct type *); \
|
119
|
+
struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \
|
120
|
+
\
|
121
|
+
/* Finds the node with the same key as elm */ \
|
122
|
+
static __inline struct type * \
|
123
|
+
name##_SPLAY_FIND(struct name *head, struct type *elm) \
|
124
|
+
{ \
|
125
|
+
if (SPLAY_EMPTY(head)) \
|
126
|
+
return(NULL); \
|
127
|
+
name##_SPLAY(head, elm); \
|
128
|
+
if ((cmp)(elm, (head)->sph_root) == 0) \
|
129
|
+
return (head->sph_root); \
|
130
|
+
return (NULL); \
|
131
|
+
} \
|
132
|
+
\
|
133
|
+
static __inline struct type * \
|
134
|
+
name##_SPLAY_NEXT(struct name *head, struct type *elm) \
|
135
|
+
{ \
|
136
|
+
name##_SPLAY(head, elm); \
|
137
|
+
if (SPLAY_RIGHT(elm, field) != NULL) { \
|
138
|
+
elm = SPLAY_RIGHT(elm, field); \
|
139
|
+
while (SPLAY_LEFT(elm, field) != NULL) { \
|
140
|
+
elm = SPLAY_LEFT(elm, field); \
|
141
|
+
} \
|
142
|
+
} else \
|
143
|
+
elm = NULL; \
|
144
|
+
return (elm); \
|
145
|
+
} \
|
146
|
+
\
|
147
|
+
static __inline struct type * \
|
148
|
+
name##_SPLAY_MIN_MAX(struct name *head, int val) \
|
149
|
+
{ \
|
150
|
+
name##_SPLAY_MINMAX(head, val); \
|
151
|
+
return (SPLAY_ROOT(head)); \
|
152
|
+
}
|
153
|
+
|
154
|
+
/* Main splay operation.
|
155
|
+
* Moves node close to the key of elm to top
|
156
|
+
*/
|
157
|
+
#define SPLAY_GENERATE(name, type, field, cmp) \
|
158
|
+
struct type * \
|
159
|
+
name##_SPLAY_INSERT(struct name *head, struct type *elm) \
|
160
|
+
{ \
|
161
|
+
if (SPLAY_EMPTY(head)) { \
|
162
|
+
SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \
|
163
|
+
} else { \
|
164
|
+
int __comp; \
|
165
|
+
name##_SPLAY(head, elm); \
|
166
|
+
__comp = (cmp)(elm, (head)->sph_root); \
|
167
|
+
if(__comp < 0) { \
|
168
|
+
SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field); \
|
169
|
+
SPLAY_RIGHT(elm, field) = (head)->sph_root; \
|
170
|
+
SPLAY_LEFT((head)->sph_root, field) = NULL; \
|
171
|
+
} else if (__comp > 0) { \
|
172
|
+
SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field); \
|
173
|
+
SPLAY_LEFT(elm, field) = (head)->sph_root; \
|
174
|
+
SPLAY_RIGHT((head)->sph_root, field) = NULL; \
|
175
|
+
} else \
|
176
|
+
return ((head)->sph_root); \
|
177
|
+
} \
|
178
|
+
(head)->sph_root = (elm); \
|
179
|
+
return (NULL); \
|
180
|
+
} \
|
181
|
+
\
|
182
|
+
struct type * \
|
183
|
+
name##_SPLAY_REMOVE(struct name *head, struct type *elm) \
|
184
|
+
{ \
|
185
|
+
struct type *__tmp; \
|
186
|
+
if (SPLAY_EMPTY(head)) \
|
187
|
+
return (NULL); \
|
188
|
+
name##_SPLAY(head, elm); \
|
189
|
+
if ((cmp)(elm, (head)->sph_root) == 0) { \
|
190
|
+
if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \
|
191
|
+
(head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \
|
192
|
+
} else { \
|
193
|
+
__tmp = SPLAY_RIGHT((head)->sph_root, field); \
|
194
|
+
(head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \
|
195
|
+
name##_SPLAY(head, elm); \
|
196
|
+
SPLAY_RIGHT((head)->sph_root, field) = __tmp; \
|
197
|
+
} \
|
198
|
+
return (elm); \
|
199
|
+
} \
|
200
|
+
return (NULL); \
|
201
|
+
} \
|
202
|
+
\
|
203
|
+
void \
|
204
|
+
name##_SPLAY(struct name *head, struct type *elm) \
|
205
|
+
{ \
|
206
|
+
struct type __node, *__left, *__right, *__tmp; \
|
207
|
+
int __comp; \
|
208
|
+
\
|
209
|
+
SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL; \
|
210
|
+
__left = __right = &__node; \
|
211
|
+
\
|
212
|
+
while ((__comp = (cmp)(elm, (head)->sph_root)) != 0) { \
|
213
|
+
if (__comp < 0) { \
|
214
|
+
__tmp = SPLAY_LEFT((head)->sph_root, field); \
|
215
|
+
if (__tmp == NULL) \
|
216
|
+
break; \
|
217
|
+
if ((cmp)(elm, __tmp) < 0){ \
|
218
|
+
SPLAY_ROTATE_RIGHT(head, __tmp, field); \
|
219
|
+
if (SPLAY_LEFT((head)->sph_root, field) == NULL) \
|
220
|
+
break; \
|
221
|
+
} \
|
222
|
+
SPLAY_LINKLEFT(head, __right, field); \
|
223
|
+
} else if (__comp > 0) { \
|
224
|
+
__tmp = SPLAY_RIGHT((head)->sph_root, field); \
|
225
|
+
if (__tmp == NULL) \
|
226
|
+
break; \
|
227
|
+
if ((cmp)(elm, __tmp) > 0){ \
|
228
|
+
SPLAY_ROTATE_LEFT(head, __tmp, field); \
|
229
|
+
if (SPLAY_RIGHT((head)->sph_root, field) == NULL) \
|
230
|
+
break; \
|
231
|
+
} \
|
232
|
+
SPLAY_LINKRIGHT(head, __left, field); \
|
233
|
+
} \
|
234
|
+
} \
|
235
|
+
SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
|
236
|
+
} \
|
237
|
+
\
|
238
|
+
/* Splay with either the minimum or the maximum element \
|
239
|
+
* Used to find minimum or maximum element in tree. \
|
240
|
+
*/ \
|
241
|
+
void name##_SPLAY_MINMAX(struct name *head, int __comp) \
|
242
|
+
{ \
|
243
|
+
struct type __node, *__left, *__right, *__tmp; \
|
244
|
+
\
|
245
|
+
SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL; \
|
246
|
+
__left = __right = &__node; \
|
247
|
+
\
|
248
|
+
while (1) { \
|
249
|
+
if (__comp < 0) { \
|
250
|
+
__tmp = SPLAY_LEFT((head)->sph_root, field); \
|
251
|
+
if (__tmp == NULL) \
|
252
|
+
break; \
|
253
|
+
if (__comp < 0){ \
|
254
|
+
SPLAY_ROTATE_RIGHT(head, __tmp, field); \
|
255
|
+
if (SPLAY_LEFT((head)->sph_root, field) == NULL) \
|
256
|
+
break; \
|
257
|
+
} \
|
258
|
+
SPLAY_LINKLEFT(head, __right, field); \
|
259
|
+
} else if (__comp > 0) { \
|
260
|
+
__tmp = SPLAY_RIGHT((head)->sph_root, field); \
|
261
|
+
if (__tmp == NULL) \
|
262
|
+
break; \
|
263
|
+
if (__comp > 0) { \
|
264
|
+
SPLAY_ROTATE_LEFT(head, __tmp, field); \
|
265
|
+
if (SPLAY_RIGHT((head)->sph_root, field) == NULL) \
|
266
|
+
break; \
|
267
|
+
} \
|
268
|
+
SPLAY_LINKRIGHT(head, __left, field); \
|
269
|
+
} \
|
270
|
+
} \
|
271
|
+
SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
|
272
|
+
}
|
273
|
+
|
274
|
+
#define SPLAY_NEGINF -1
|
275
|
+
#define SPLAY_INF 1
|
276
|
+
|
277
|
+
#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y)
|
278
|
+
#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y)
|
279
|
+
#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y)
|
280
|
+
#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y)
|
281
|
+
#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \
|
282
|
+
: name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF))
|
283
|
+
#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \
|
284
|
+
: name##_SPLAY_MIN_MAX(x, SPLAY_INF))
|
285
|
+
|
286
|
+
#define SPLAY_FOREACH(x, name, head) \
|
287
|
+
for ((x) = SPLAY_MIN(name, head); \
|
288
|
+
(x) != NULL; \
|
289
|
+
(x) = SPLAY_NEXT(name, head, x))
|
290
|
+
|
291
|
+
/* Macros that define a red-black tree */
|
292
|
+
#define RB_HEAD(name, type) \
|
293
|
+
struct name { \
|
294
|
+
struct type *rbh_root; /* root of the tree */ \
|
295
|
+
}
|
296
|
+
|
297
|
+
#define RB_INITIALIZER(root) \
|
298
|
+
{ NULL }
|
299
|
+
|
300
|
+
#define RB_INIT(root) do { \
|
301
|
+
(root)->rbh_root = NULL; \
|
302
|
+
} while (/*CONSTCOND*/ 0)
|
303
|
+
|
304
|
+
#define RB_BLACK 0
|
305
|
+
#define RB_RED 1
|
306
|
+
#define RB_ENTRY(type) \
|
307
|
+
struct { \
|
308
|
+
struct type *rbe_left; /* left element */ \
|
309
|
+
struct type *rbe_right; /* right element */ \
|
310
|
+
struct type *rbe_parent; /* parent element */ \
|
311
|
+
int rbe_color; /* node color */ \
|
312
|
+
}
|
313
|
+
|
314
|
+
#define RB_LEFT(elm, field) (elm)->field.rbe_left
|
315
|
+
#define RB_RIGHT(elm, field) (elm)->field.rbe_right
|
316
|
+
#define RB_PARENT(elm, field) (elm)->field.rbe_parent
|
317
|
+
#define RB_COLOR(elm, field) (elm)->field.rbe_color
|
318
|
+
#define RB_ROOT(head) (head)->rbh_root
|
319
|
+
#define RB_EMPTY(head) (RB_ROOT(head) == NULL)
|
320
|
+
|
321
|
+
#define RB_SET(elm, parent, field) do { \
|
322
|
+
RB_PARENT(elm, field) = parent; \
|
323
|
+
RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \
|
324
|
+
RB_COLOR(elm, field) = RB_RED; \
|
325
|
+
} while (/*CONSTCOND*/ 0)
|
326
|
+
|
327
|
+
#define RB_SET_BLACKRED(black, red, field) do { \
|
328
|
+
RB_COLOR(black, field) = RB_BLACK; \
|
329
|
+
RB_COLOR(red, field) = RB_RED; \
|
330
|
+
} while (/*CONSTCOND*/ 0)
|
331
|
+
|
332
|
+
#ifndef RB_AUGMENT
|
333
|
+
#define RB_AUGMENT(x) do {} while (0)
|
334
|
+
#endif
|
335
|
+
|
336
|
+
#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \
|
337
|
+
(tmp) = RB_RIGHT(elm, field); \
|
338
|
+
if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != NULL) { \
|
339
|
+
RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \
|
340
|
+
} \
|
341
|
+
RB_AUGMENT(elm); \
|
342
|
+
if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \
|
343
|
+
if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
|
344
|
+
RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
|
345
|
+
else \
|
346
|
+
RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \
|
347
|
+
} else \
|
348
|
+
(head)->rbh_root = (tmp); \
|
349
|
+
RB_LEFT(tmp, field) = (elm); \
|
350
|
+
RB_PARENT(elm, field) = (tmp); \
|
351
|
+
RB_AUGMENT(tmp); \
|
352
|
+
if ((RB_PARENT(tmp, field))) \
|
353
|
+
RB_AUGMENT(RB_PARENT(tmp, field)); \
|
354
|
+
} while (/*CONSTCOND*/ 0)
|
355
|
+
|
356
|
+
#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \
|
357
|
+
(tmp) = RB_LEFT(elm, field); \
|
358
|
+
if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != NULL) { \
|
359
|
+
RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \
|
360
|
+
} \
|
361
|
+
RB_AUGMENT(elm); \
|
362
|
+
if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \
|
363
|
+
if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
|
364
|
+
RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
|
365
|
+
else \
|
366
|
+
RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \
|
367
|
+
} else \
|
368
|
+
(head)->rbh_root = (tmp); \
|
369
|
+
RB_RIGHT(tmp, field) = (elm); \
|
370
|
+
RB_PARENT(elm, field) = (tmp); \
|
371
|
+
RB_AUGMENT(tmp); \
|
372
|
+
if ((RB_PARENT(tmp, field))) \
|
373
|
+
RB_AUGMENT(RB_PARENT(tmp, field)); \
|
374
|
+
} while (/*CONSTCOND*/ 0)
|
375
|
+
|
376
|
+
/* Generates prototypes and inline functions */
|
377
|
+
#define RB_PROTOTYPE(name, type, field, cmp) \
|
378
|
+
RB_PROTOTYPE_INTERNAL(name, type, field, cmp,)
|
379
|
+
#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \
|
380
|
+
RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __unused static)
|
381
|
+
#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \
|
382
|
+
attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \
|
383
|
+
attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\
|
384
|
+
attr struct type *name##_RB_REMOVE(struct name *, struct type *); \
|
385
|
+
attr struct type *name##_RB_INSERT(struct name *, struct type *); \
|
386
|
+
attr struct type *name##_RB_FIND(struct name *, struct type *); \
|
387
|
+
attr struct type *name##_RB_NFIND(struct name *, struct type *); \
|
388
|
+
attr struct type *name##_RB_NEXT(struct type *); \
|
389
|
+
attr struct type *name##_RB_PREV(struct type *); \
|
390
|
+
attr struct type *name##_RB_MINMAX(struct name *, int); \
|
391
|
+
\
|
392
|
+
|
393
|
+
/* Main rb operation.
|
394
|
+
* Moves node close to the key of elm to top
|
395
|
+
*/
|
396
|
+
#define RB_GENERATE(name, type, field, cmp) \
|
397
|
+
RB_GENERATE_INTERNAL(name, type, field, cmp,)
|
398
|
+
#define RB_GENERATE_STATIC(name, type, field, cmp) \
|
399
|
+
RB_GENERATE_INTERNAL(name, type, field, cmp, __unused static)
|
400
|
+
#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \
|
401
|
+
attr void \
|
402
|
+
name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \
|
403
|
+
{ \
|
404
|
+
struct type *parent, *gparent, *tmp; \
|
405
|
+
while ((parent = RB_PARENT(elm, field)) != NULL && \
|
406
|
+
RB_COLOR(parent, field) == RB_RED) { \
|
407
|
+
gparent = RB_PARENT(parent, field); \
|
408
|
+
if (parent == RB_LEFT(gparent, field)) { \
|
409
|
+
tmp = RB_RIGHT(gparent, field); \
|
410
|
+
if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
|
411
|
+
RB_COLOR(tmp, field) = RB_BLACK; \
|
412
|
+
RB_SET_BLACKRED(parent, gparent, field); \
|
413
|
+
elm = gparent; \
|
414
|
+
continue; \
|
415
|
+
} \
|
416
|
+
if (RB_RIGHT(parent, field) == elm) { \
|
417
|
+
RB_ROTATE_LEFT(head, parent, tmp, field); \
|
418
|
+
tmp = parent; \
|
419
|
+
parent = elm; \
|
420
|
+
elm = tmp; \
|
421
|
+
} \
|
422
|
+
RB_SET_BLACKRED(parent, gparent, field); \
|
423
|
+
RB_ROTATE_RIGHT(head, gparent, tmp, field); \
|
424
|
+
} else { \
|
425
|
+
tmp = RB_LEFT(gparent, field); \
|
426
|
+
if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
|
427
|
+
RB_COLOR(tmp, field) = RB_BLACK; \
|
428
|
+
RB_SET_BLACKRED(parent, gparent, field); \
|
429
|
+
elm = gparent; \
|
430
|
+
continue; \
|
431
|
+
} \
|
432
|
+
if (RB_LEFT(parent, field) == elm) { \
|
433
|
+
RB_ROTATE_RIGHT(head, parent, tmp, field); \
|
434
|
+
tmp = parent; \
|
435
|
+
parent = elm; \
|
436
|
+
elm = tmp; \
|
437
|
+
} \
|
438
|
+
RB_SET_BLACKRED(parent, gparent, field); \
|
439
|
+
RB_ROTATE_LEFT(head, gparent, tmp, field); \
|
440
|
+
} \
|
441
|
+
} \
|
442
|
+
RB_COLOR(head->rbh_root, field) = RB_BLACK; \
|
443
|
+
} \
|
444
|
+
\
|
445
|
+
attr void \
|
446
|
+
name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, \
|
447
|
+
struct type *elm) \
|
448
|
+
{ \
|
449
|
+
struct type *tmp; \
|
450
|
+
while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \
|
451
|
+
elm != RB_ROOT(head)) { \
|
452
|
+
if (RB_LEFT(parent, field) == elm) { \
|
453
|
+
tmp = RB_RIGHT(parent, field); \
|
454
|
+
if (RB_COLOR(tmp, field) == RB_RED) { \
|
455
|
+
RB_SET_BLACKRED(tmp, parent, field); \
|
456
|
+
RB_ROTATE_LEFT(head, parent, tmp, field); \
|
457
|
+
tmp = RB_RIGHT(parent, field); \
|
458
|
+
} \
|
459
|
+
if ((RB_LEFT(tmp, field) == NULL || \
|
460
|
+
RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) && \
|
461
|
+
(RB_RIGHT(tmp, field) == NULL || \
|
462
|
+
RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) { \
|
463
|
+
RB_COLOR(tmp, field) = RB_RED; \
|
464
|
+
elm = parent; \
|
465
|
+
parent = RB_PARENT(elm, field); \
|
466
|
+
} else { \
|
467
|
+
if (RB_RIGHT(tmp, field) == NULL || \
|
468
|
+
RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) { \
|
469
|
+
struct type *oleft; \
|
470
|
+
if ((oleft = RB_LEFT(tmp, field)) \
|
471
|
+
!= NULL) \
|
472
|
+
RB_COLOR(oleft, field) = RB_BLACK; \
|
473
|
+
RB_COLOR(tmp, field) = RB_RED; \
|
474
|
+
RB_ROTATE_RIGHT(head, tmp, oleft, field); \
|
475
|
+
tmp = RB_RIGHT(parent, field); \
|
476
|
+
} \
|
477
|
+
RB_COLOR(tmp, field) = RB_COLOR(parent, field); \
|
478
|
+
RB_COLOR(parent, field) = RB_BLACK; \
|
479
|
+
if (RB_RIGHT(tmp, field)) \
|
480
|
+
RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK; \
|
481
|
+
RB_ROTATE_LEFT(head, parent, tmp, field); \
|
482
|
+
elm = RB_ROOT(head); \
|
483
|
+
break; \
|
484
|
+
} \
|
485
|
+
} else { \
|
486
|
+
tmp = RB_LEFT(parent, field); \
|
487
|
+
if (RB_COLOR(tmp, field) == RB_RED) { \
|
488
|
+
RB_SET_BLACKRED(tmp, parent, field); \
|
489
|
+
RB_ROTATE_RIGHT(head, parent, tmp, field); \
|
490
|
+
tmp = RB_LEFT(parent, field); \
|
491
|
+
} \
|
492
|
+
if ((RB_LEFT(tmp, field) == NULL || \
|
493
|
+
RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) && \
|
494
|
+
(RB_RIGHT(tmp, field) == NULL || \
|
495
|
+
RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) { \
|
496
|
+
RB_COLOR(tmp, field) = RB_RED; \
|
497
|
+
elm = parent; \
|
498
|
+
parent = RB_PARENT(elm, field); \
|
499
|
+
} else { \
|
500
|
+
if (RB_LEFT(tmp, field) == NULL || \
|
501
|
+
RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) { \
|
502
|
+
struct type *oright; \
|
503
|
+
if ((oright = RB_RIGHT(tmp, field)) \
|
504
|
+
!= NULL) \
|
505
|
+
RB_COLOR(oright, field) = RB_BLACK; \
|
506
|
+
RB_COLOR(tmp, field) = RB_RED; \
|
507
|
+
RB_ROTATE_LEFT(head, tmp, oright, field); \
|
508
|
+
tmp = RB_LEFT(parent, field); \
|
509
|
+
} \
|
510
|
+
RB_COLOR(tmp, field) = RB_COLOR(parent, field); \
|
511
|
+
RB_COLOR(parent, field) = RB_BLACK; \
|
512
|
+
if (RB_LEFT(tmp, field)) \
|
513
|
+
RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK; \
|
514
|
+
RB_ROTATE_RIGHT(head, parent, tmp, field); \
|
515
|
+
elm = RB_ROOT(head); \
|
516
|
+
break; \
|
517
|
+
} \
|
518
|
+
} \
|
519
|
+
} \
|
520
|
+
if (elm) \
|
521
|
+
RB_COLOR(elm, field) = RB_BLACK; \
|
522
|
+
} \
|
523
|
+
\
|
524
|
+
attr struct type * \
|
525
|
+
name##_RB_REMOVE(struct name *head, struct type *elm) \
|
526
|
+
{ \
|
527
|
+
struct type *child, *parent, *old = elm; \
|
528
|
+
int color; \
|
529
|
+
if (RB_LEFT(elm, field) == NULL) \
|
530
|
+
child = RB_RIGHT(elm, field); \
|
531
|
+
else if (RB_RIGHT(elm, field) == NULL) \
|
532
|
+
child = RB_LEFT(elm, field); \
|
533
|
+
else { \
|
534
|
+
struct type *left; \
|
535
|
+
elm = RB_RIGHT(elm, field); \
|
536
|
+
while ((left = RB_LEFT(elm, field)) != NULL) \
|
537
|
+
elm = left; \
|
538
|
+
child = RB_RIGHT(elm, field); \
|
539
|
+
parent = RB_PARENT(elm, field); \
|
540
|
+
color = RB_COLOR(elm, field); \
|
541
|
+
if (child) \
|
542
|
+
RB_PARENT(child, field) = parent; \
|
543
|
+
if (parent) { \
|
544
|
+
if (RB_LEFT(parent, field) == elm) \
|
545
|
+
RB_LEFT(parent, field) = child; \
|
546
|
+
else \
|
547
|
+
RB_RIGHT(parent, field) = child; \
|
548
|
+
RB_AUGMENT(parent); \
|
549
|
+
} else \
|
550
|
+
RB_ROOT(head) = child; \
|
551
|
+
if (RB_PARENT(elm, field) == old) \
|
552
|
+
parent = elm; \
|
553
|
+
(elm)->field = (old)->field; \
|
554
|
+
if (RB_PARENT(old, field)) { \
|
555
|
+
if (RB_LEFT(RB_PARENT(old, field), field) == old) \
|
556
|
+
RB_LEFT(RB_PARENT(old, field), field) = elm; \
|
557
|
+
else \
|
558
|
+
RB_RIGHT(RB_PARENT(old, field), field) = elm; \
|
559
|
+
RB_AUGMENT(RB_PARENT(old, field)); \
|
560
|
+
} else \
|
561
|
+
RB_ROOT(head) = elm; \
|
562
|
+
RB_PARENT(RB_LEFT(old, field), field) = elm; \
|
563
|
+
if (RB_RIGHT(old, field)) \
|
564
|
+
RB_PARENT(RB_RIGHT(old, field), field) = elm; \
|
565
|
+
if (parent) { \
|
566
|
+
left = parent; \
|
567
|
+
do { \
|
568
|
+
RB_AUGMENT(left); \
|
569
|
+
} while ((left = RB_PARENT(left, field)) != NULL); \
|
570
|
+
} \
|
571
|
+
goto color; \
|
572
|
+
} \
|
573
|
+
parent = RB_PARENT(elm, field); \
|
574
|
+
color = RB_COLOR(elm, field); \
|
575
|
+
if (child) \
|
576
|
+
RB_PARENT(child, field) = parent; \
|
577
|
+
if (parent) { \
|
578
|
+
if (RB_LEFT(parent, field) == elm) \
|
579
|
+
RB_LEFT(parent, field) = child; \
|
580
|
+
else \
|
581
|
+
RB_RIGHT(parent, field) = child; \
|
582
|
+
RB_AUGMENT(parent); \
|
583
|
+
} else \
|
584
|
+
RB_ROOT(head) = child; \
|
585
|
+
color: \
|
586
|
+
if (color == RB_BLACK) \
|
587
|
+
name##_RB_REMOVE_COLOR(head, parent, child); \
|
588
|
+
return (old); \
|
589
|
+
} \
|
590
|
+
\
|
591
|
+
/* Inserts a node into the RB tree */ \
|
592
|
+
attr struct type * \
|
593
|
+
name##_RB_INSERT(struct name *head, struct type *elm) \
|
594
|
+
{ \
|
595
|
+
struct type *tmp; \
|
596
|
+
struct type *parent = NULL; \
|
597
|
+
int comp = 0; \
|
598
|
+
tmp = RB_ROOT(head); \
|
599
|
+
while (tmp) { \
|
600
|
+
parent = tmp; \
|
601
|
+
comp = (cmp)(elm, parent); \
|
602
|
+
if (comp < 0) \
|
603
|
+
tmp = RB_LEFT(tmp, field); \
|
604
|
+
else if (comp > 0) \
|
605
|
+
tmp = RB_RIGHT(tmp, field); \
|
606
|
+
else \
|
607
|
+
return (tmp); \
|
608
|
+
} \
|
609
|
+
RB_SET(elm, parent, field); \
|
610
|
+
if (parent != NULL) { \
|
611
|
+
if (comp < 0) \
|
612
|
+
RB_LEFT(parent, field) = elm; \
|
613
|
+
else \
|
614
|
+
RB_RIGHT(parent, field) = elm; \
|
615
|
+
RB_AUGMENT(parent); \
|
616
|
+
} else \
|
617
|
+
RB_ROOT(head) = elm; \
|
618
|
+
name##_RB_INSERT_COLOR(head, elm); \
|
619
|
+
return (NULL); \
|
620
|
+
} \
|
621
|
+
\
|
622
|
+
/* Finds the node with the same key as elm */ \
|
623
|
+
attr struct type * \
|
624
|
+
name##_RB_FIND(struct name *head, struct type *elm) \
|
625
|
+
{ \
|
626
|
+
struct type *tmp = RB_ROOT(head); \
|
627
|
+
int comp; \
|
628
|
+
while (tmp) { \
|
629
|
+
comp = cmp(elm, tmp); \
|
630
|
+
if (comp < 0) \
|
631
|
+
tmp = RB_LEFT(tmp, field); \
|
632
|
+
else if (comp > 0) \
|
633
|
+
tmp = RB_RIGHT(tmp, field); \
|
634
|
+
else \
|
635
|
+
return (tmp); \
|
636
|
+
} \
|
637
|
+
return (NULL); \
|
638
|
+
} \
|
639
|
+
\
|
640
|
+
/* Finds the first node greater than or equal to the search key */ \
|
641
|
+
attr struct type * \
|
642
|
+
name##_RB_NFIND(struct name *head, struct type *elm) \
|
643
|
+
{ \
|
644
|
+
struct type *tmp = RB_ROOT(head); \
|
645
|
+
struct type *res = NULL; \
|
646
|
+
int comp; \
|
647
|
+
while (tmp) { \
|
648
|
+
comp = cmp(elm, tmp); \
|
649
|
+
if (comp < 0) { \
|
650
|
+
res = tmp; \
|
651
|
+
tmp = RB_LEFT(tmp, field); \
|
652
|
+
} \
|
653
|
+
else if (comp > 0) \
|
654
|
+
tmp = RB_RIGHT(tmp, field); \
|
655
|
+
else \
|
656
|
+
return (tmp); \
|
657
|
+
} \
|
658
|
+
return (res); \
|
659
|
+
} \
|
660
|
+
\
|
661
|
+
/* ARGSUSED */ \
|
662
|
+
attr struct type * \
|
663
|
+
name##_RB_NEXT(struct type *elm) \
|
664
|
+
{ \
|
665
|
+
if (RB_RIGHT(elm, field)) { \
|
666
|
+
elm = RB_RIGHT(elm, field); \
|
667
|
+
while (RB_LEFT(elm, field)) \
|
668
|
+
elm = RB_LEFT(elm, field); \
|
669
|
+
} else { \
|
670
|
+
if (RB_PARENT(elm, field) && \
|
671
|
+
(elm == RB_LEFT(RB_PARENT(elm, field), field))) \
|
672
|
+
elm = RB_PARENT(elm, field); \
|
673
|
+
else { \
|
674
|
+
while (RB_PARENT(elm, field) && \
|
675
|
+
(elm == RB_RIGHT(RB_PARENT(elm, field), field))) \
|
676
|
+
elm = RB_PARENT(elm, field); \
|
677
|
+
elm = RB_PARENT(elm, field); \
|
678
|
+
} \
|
679
|
+
} \
|
680
|
+
return (elm); \
|
681
|
+
} \
|
682
|
+
\
|
683
|
+
/* ARGSUSED */ \
|
684
|
+
attr struct type * \
|
685
|
+
name##_RB_PREV(struct type *elm) \
|
686
|
+
{ \
|
687
|
+
if (RB_LEFT(elm, field)) { \
|
688
|
+
elm = RB_LEFT(elm, field); \
|
689
|
+
while (RB_RIGHT(elm, field)) \
|
690
|
+
elm = RB_RIGHT(elm, field); \
|
691
|
+
} else { \
|
692
|
+
if (RB_PARENT(elm, field) && \
|
693
|
+
(elm == RB_RIGHT(RB_PARENT(elm, field), field))) \
|
694
|
+
elm = RB_PARENT(elm, field); \
|
695
|
+
else { \
|
696
|
+
while (RB_PARENT(elm, field) && \
|
697
|
+
(elm == RB_LEFT(RB_PARENT(elm, field), field))) \
|
698
|
+
elm = RB_PARENT(elm, field); \
|
699
|
+
elm = RB_PARENT(elm, field); \
|
700
|
+
} \
|
701
|
+
} \
|
702
|
+
return (elm); \
|
703
|
+
} \
|
704
|
+
\
|
705
|
+
attr struct type * \
|
706
|
+
name##_RB_MINMAX(struct name *head, int val) \
|
707
|
+
{ \
|
708
|
+
struct type *tmp = RB_ROOT(head); \
|
709
|
+
struct type *parent = NULL; \
|
710
|
+
while (tmp) { \
|
711
|
+
parent = tmp; \
|
712
|
+
if (val < 0) \
|
713
|
+
tmp = RB_LEFT(tmp, field); \
|
714
|
+
else \
|
715
|
+
tmp = RB_RIGHT(tmp, field); \
|
716
|
+
} \
|
717
|
+
return (parent); \
|
718
|
+
}
|
719
|
+
|
720
|
+
#define RB_NEGINF -1
|
721
|
+
#define RB_INF 1
|
722
|
+
|
723
|
+
#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y)
|
724
|
+
#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y)
|
725
|
+
#define RB_FIND(name, x, y) name##_RB_FIND(x, y)
|
726
|
+
#define RB_NFIND(name, x, y) name##_RB_NFIND(x, y)
|
727
|
+
#define RB_NEXT(name, x, y) name##_RB_NEXT(y)
|
728
|
+
#define RB_PREV(name, x, y) name##_RB_PREV(y)
|
729
|
+
#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF)
|
730
|
+
#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF)
|
731
|
+
|
732
|
+
#define RB_FOREACH(x, name, head) \
|
733
|
+
for ((x) = RB_MIN(name, head); \
|
734
|
+
(x) != NULL; \
|
735
|
+
(x) = name##_RB_NEXT(x))
|
736
|
+
|
737
|
+
#define RB_FOREACH_FROM(x, name, y) \
|
738
|
+
for ((x) = (y); \
|
739
|
+
((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \
|
740
|
+
(x) = (y))
|
741
|
+
|
742
|
+
#define RB_FOREACH_SAFE(x, name, head, y) \
|
743
|
+
for ((x) = RB_MIN(name, head); \
|
744
|
+
((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \
|
745
|
+
(x) = (y))
|
746
|
+
|
747
|
+
#define RB_FOREACH_REVERSE(x, name, head) \
|
748
|
+
for ((x) = RB_MAX(name, head); \
|
749
|
+
(x) != NULL; \
|
750
|
+
(x) = name##_RB_PREV(x))
|
751
|
+
|
752
|
+
#define RB_FOREACH_REVERSE_FROM(x, name, y) \
|
753
|
+
for ((x) = (y); \
|
754
|
+
((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \
|
755
|
+
(x) = (y))
|
756
|
+
|
757
|
+
#define RB_FOREACH_REVERSE_SAFE(x, name, head, y) \
|
758
|
+
for ((x) = RB_MAX(name, head); \
|
759
|
+
((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \
|
760
|
+
(x) = (y))
|
761
|
+
|
762
|
+
#endif /* _UV_TREE_H_ */
|