├── .gitignore ├── ChangeLog ├── LICENSE ├── Makefile ├── README.md ├── build.sh ├── demo ├── ios │ ├── .gitignore │ ├── deps │ │ ├── include │ │ │ ├── IKit │ │ │ │ ├── IButton.h │ │ │ │ ├── IImage.h │ │ │ │ ├── IInput.h │ │ │ │ ├── IKit.h │ │ │ │ ├── IKitUtil.h │ │ │ │ ├── ILabel.h │ │ │ │ ├── IPopover.h │ │ │ │ ├── IPullRefresh.h │ │ │ │ ├── IRefreshControl.h │ │ │ │ ├── IStyle.h │ │ │ │ ├── ISwitch.h │ │ │ │ ├── ITable.h │ │ │ │ ├── ITableRow.h │ │ │ │ └── IView.h │ │ │ └── curl │ │ │ │ ├── curl.h │ │ │ │ ├── curlbuild.h │ │ │ │ ├── curlrules.h │ │ │ │ ├── curlver.h │ │ │ │ ├── easy.h │ │ │ │ ├── mprintf.h │ │ │ │ ├── multi.h │ │ │ │ ├── stdcheaders.h │ │ │ │ └── typecheck-gcc.h │ │ ├── libIKit.a │ │ └── libcurl.a │ ├── ios.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ └── ios │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── ViewController.h │ │ ├── ViewController.m │ │ └── main.m ├── python │ ├── README.md │ └── test.py └── web │ ├── chat.css │ ├── chat.html │ ├── emoticons.png │ ├── forever-iframe.html │ ├── js │ ├── chat.js │ ├── icomet.js │ ├── jquery-1.9.1.js │ └── json2.js │ ├── long-polling.html │ ├── php │ ├── push.php │ └── sign.php │ ├── sending.gif │ └── sse.html ├── deps ├── jemalloc-3.4.0 │ ├── .gitignore │ ├── COPYING │ ├── ChangeLog │ ├── INSTALL │ ├── Makefile.in │ ├── README │ ├── autogen.sh │ ├── bin │ │ ├── jemalloc.sh.in │ │ └── pprof │ ├── config.guess │ ├── config.stamp.in │ ├── config.sub │ ├── configure │ ├── configure.ac │ ├── doc │ │ ├── html.xsl.in │ │ ├── jemalloc.xml.in │ │ ├── manpages.xsl.in │ │ └── stylesheet.xsl │ ├── include │ │ ├── jemalloc │ │ │ ├── internal │ │ │ │ ├── arena.h │ │ │ │ ├── atomic.h │ │ │ │ ├── base.h │ │ │ │ ├── bitmap.h │ │ │ │ ├── chunk.h │ │ │ │ ├── chunk_dss.h │ │ │ │ ├── chunk_mmap.h │ │ │ │ ├── ckh.h │ │ │ │ ├── ctl.h │ │ │ │ ├── extent.h │ │ │ │ ├── hash.h │ │ │ │ ├── huge.h │ │ │ │ ├── jemalloc_internal.h.in │ │ │ │ ├── mb.h │ │ │ │ ├── mutex.h │ │ │ │ ├── private_namespace.h │ │ │ │ ├── prng.h │ │ │ │ ├── prof.h │ │ │ │ ├── ql.h │ │ │ │ ├── qr.h │ │ │ │ ├── quarantine.h │ │ │ │ ├── rb.h │ │ │ │ ├── rtree.h │ │ │ │ ├── size_classes.sh │ │ │ │ ├── stats.h │ │ │ │ ├── tcache.h │ │ │ │ ├── tsd.h │ │ │ │ └── util.h │ │ │ ├── jemalloc.h.in │ │ │ └── jemalloc_defs.h.in │ │ └── msvc_compat │ │ │ ├── inttypes.h │ │ │ ├── stdbool.h │ │ │ ├── stdint.h │ │ │ └── strings.h │ ├── install-sh │ ├── src │ │ ├── arena.c │ │ ├── atomic.c │ │ ├── base.c │ │ ├── bitmap.c │ │ ├── chunk.c │ │ ├── chunk_dss.c │ │ ├── chunk_mmap.c │ │ ├── ckh.c │ │ ├── ctl.c │ │ ├── extent.c │ │ ├── hash.c │ │ ├── huge.c │ │ ├── jemalloc.c │ │ ├── mb.c │ │ ├── mutex.c │ │ ├── prof.c │ │ ├── quarantine.c │ │ ├── rtree.c │ │ ├── stats.c │ │ ├── tcache.c │ │ ├── tsd.c │ │ ├── util.c │ │ └── zone.c │ └── test │ │ ├── ALLOCM_ARENA.c │ │ ├── ALLOCM_ARENA.exp │ │ ├── aligned_alloc.c │ │ ├── aligned_alloc.exp │ │ ├── allocated.c │ │ ├── allocated.exp │ │ ├── allocm.c │ │ ├── allocm.exp │ │ ├── bitmap.c │ │ ├── bitmap.exp │ │ ├── jemalloc_test.h.in │ │ ├── mremap.c │ │ ├── mremap.exp │ │ ├── posix_memalign.c │ │ ├── posix_memalign.exp │ │ ├── rallocm.c │ │ ├── rallocm.exp │ │ ├── thread_arena.c │ │ ├── thread_arena.exp │ │ ├── thread_tcache_enabled.c │ │ └── thread_tcache_enabled.exp └── libevent-2.0.21-stable │ ├── ChangeLog │ ├── Doxyfile │ ├── LICENSE │ ├── Makefile.am │ ├── Makefile.in │ ├── Makefile.nmake │ ├── README │ ├── WIN32-Code │ ├── event2 │ │ └── event-config.h │ └── tree.h │ ├── aclocal.m4 │ ├── arc4random.c │ ├── autogen.sh │ ├── buffer.c │ ├── buffer_iocp.c │ ├── bufferevent-internal.h │ ├── bufferevent.c │ ├── bufferevent_async.c │ ├── bufferevent_filter.c │ ├── bufferevent_openssl.c │ ├── bufferevent_pair.c │ ├── bufferevent_ratelim.c │ ├── bufferevent_sock.c │ ├── changelist-internal.h │ ├── compat │ └── sys │ │ └── queue.h │ ├── compile │ ├── config.guess │ ├── config.h.in │ ├── config.sub │ ├── configure │ ├── configure.in │ ├── defer-internal.h │ ├── depcomp │ ├── devpoll.c │ ├── epoll.c │ ├── epoll_sub.c │ ├── evbuffer-internal.h │ ├── evdns.c │ ├── evdns.h │ ├── event-internal.h │ ├── event.c │ ├── event.h │ ├── event_iocp.c │ ├── event_rpcgen.py │ ├── event_tagging.c │ ├── evhttp.h │ ├── evmap-internal.h │ ├── evmap.c │ ├── evport.c │ ├── evrpc-internal.h │ ├── evrpc.c │ ├── evrpc.h │ ├── evsignal-internal.h │ ├── evthread-internal.h │ ├── evthread.c │ ├── evthread_pthread.c │ ├── evthread_win32.c │ ├── evutil.c │ ├── evutil.h │ ├── evutil_rand.c │ ├── ht-internal.h │ ├── http-internal.h │ ├── http.c │ ├── include │ ├── Makefile.am │ ├── Makefile.in │ └── event2 │ │ ├── buffer.h │ │ ├── buffer_compat.h │ │ ├── bufferevent.h │ │ ├── bufferevent_compat.h │ │ ├── bufferevent_ssl.h │ │ ├── bufferevent_struct.h │ │ ├── dns.h │ │ ├── dns_compat.h │ │ ├── dns_struct.h │ │ ├── event.h │ │ ├── event_compat.h │ │ ├── event_struct.h │ │ ├── http.h │ │ ├── http_compat.h │ │ ├── http_struct.h │ │ ├── keyvalq_struct.h │ │ ├── listener.h │ │ ├── rpc.h │ │ ├── rpc_compat.h │ │ ├── rpc_struct.h │ │ ├── tag.h │ │ ├── tag_compat.h │ │ ├── thread.h │ │ └── util.h │ ├── install-sh │ ├── iocp-internal.h │ ├── ipv6-internal.h │ ├── kqueue.c │ ├── libevent.pc.in │ ├── libevent_openssl.pc.in │ ├── libevent_pthreads.pc.in │ ├── listener.c │ ├── log-internal.h │ ├── log.c │ ├── ltmain.sh │ ├── m4 │ ├── acx_pthread.m4 │ ├── libtool.m4 │ ├── ltoptions.m4 │ ├── ltsugar.m4 │ ├── ltversion.m4 │ └── lt~obsolete.m4 │ ├── make-event-config.sed │ ├── minheap-internal.h │ ├── missing │ ├── mm-internal.h │ ├── poll.c │ ├── ratelim-internal.h │ ├── sample │ ├── Makefile.am │ ├── Makefile.in │ ├── dns-example.c │ ├── event-test.c │ ├── hello-world.c │ ├── http-server.c │ ├── le-proxy.c │ ├── signal-test.c │ └── time-test.c │ ├── select.c │ ├── signal.c │ ├── strlcpy-internal.h │ ├── strlcpy.c │ ├── test │ ├── Makefile.am │ ├── Makefile.in │ ├── Makefile.nmake │ ├── bench.c │ ├── bench_cascade.c │ ├── bench_http.c │ ├── bench_httpclient.c │ ├── regress.c │ ├── regress.gen.c │ ├── regress.gen.h │ ├── regress.h │ ├── regress.rpc │ ├── regress_buffer.c │ ├── regress_bufferevent.c │ ├── regress_dns.c │ ├── regress_et.c │ ├── regress_http.c │ ├── regress_iocp.c │ ├── regress_listener.c │ ├── regress_main.c │ ├── regress_minheap.c │ ├── regress_rpc.c │ ├── regress_ssl.c │ ├── regress_testutils.c │ ├── regress_testutils.h │ ├── regress_thread.c │ ├── regress_util.c │ ├── regress_zlib.c │ ├── rpcgen_wrapper.sh │ ├── test-changelist.c │ ├── test-eof.c │ ├── test-init.c │ ├── test-ratelim.c │ ├── test-time.c │ ├── test-weof.c │ ├── test.sh │ ├── tinytest.c │ ├── tinytest.h │ ├── tinytest_local.h │ └── tinytest_macros.h │ ├── util-internal.h │ ├── whatsnew-2.0.txt │ └── win32select.c ├── docs └── README.md ├── icomet.conf ├── src ├── comet │ ├── Makefile │ ├── README.md │ ├── channel.cpp │ ├── channel.h │ ├── http_query.h │ ├── icomet-server.cpp │ ├── presence.cpp │ ├── presence.h │ ├── server.cpp │ ├── server.h │ ├── server_config.h │ ├── subscriber.cpp │ └── subscriber.h ├── presence │ └── README.md └── util │ ├── Makefile │ ├── bytes.cpp │ ├── bytes.h │ ├── config.cpp │ ├── config.h │ ├── daemon.h │ ├── file.h │ ├── ip_filter.h │ ├── list.h │ ├── log.cpp │ ├── log.h │ ├── sorted_set.cpp │ ├── sorted_set.h │ ├── strings.h │ ├── test_sorted_set.cpp │ └── thread.h ├── test_icomet.conf ├── tools ├── Makefile └── benchmark.cpp └── version /.gitignore: -------------------------------------------------------------------------------- 1 | version.h 2 | build.h 3 | build.mk 4 | log.txt 5 | comet-server 6 | comet-server-* 7 | icomet-server 8 | icomet-server-* 9 | online-server 10 | dev_icomet.conf 11 | patch 12 | *.dSYM 13 | *.pid 14 | *.o 15 | *.lo 16 | *.a 17 | *.la 18 | *.so 19 | *.class 20 | tools/benchmark 21 | .DS_Store 22 | *.pyc 23 | *.swp 24 | *.exe 25 | *.patch 26 | icomet 27 | config.mk 28 | deps/libevent-2.0.21-stable/test 29 | deps/libevent-2.0.21-stable/.deps 30 | deps/libevent-2.0.21-stable/.libs 31 | deps/libevent-2.0.21-stable/Makefile 32 | deps/libevent-2.0.21-stable/config.h 33 | deps/libevent-2.0.21-stable/config.log 34 | deps/libevent-2.0.21-stable/config.status 35 | deps/libevent-2.0.21-stable/include/Makefile 36 | deps/libevent-2.0.21-stable/include/event2/event-config.h 37 | deps/libevent-2.0.21-stable/libevent.pc 38 | deps/libevent-2.0.21-stable/libevent_openssl.pc 39 | deps/libevent-2.0.21-stable/libevent_pthreads.pc 40 | deps/libevent-2.0.21-stable/libtool 41 | deps/libevent-2.0.21-stable/sample/.libs/ 42 | deps/libevent-2.0.21-stable/sample/Makefile 43 | deps/libevent-2.0.21-stable/sample/dns-example 44 | deps/libevent-2.0.21-stable/sample/event-test 45 | deps/libevent-2.0.21-stable/sample/hello-world 46 | deps/libevent-2.0.21-stable/sample/http-server 47 | deps/libevent-2.0.21-stable/sample/le-proxy 48 | deps/libevent-2.0.21-stable/sample/signal-test 49 | deps/libevent-2.0.21-stable/sample/time-test 50 | deps/libevent-2.0.21-stable/stamp-h1 51 | deps/libevent-2.0.21-stable/autom4te.cache 52 | 53 | 54 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | * 0.2.5 2 | * Bug fixes: 3 | - Fix memory leak bug again, call evhttp_send_reply_end in connection_closecb(2017-09-07) 4 | * 0.2.3 5 | * New features: 6 | - Support HTML 5 EventSource(2017-05-17) 7 | - icomet.js uses HTML 5 EventSource if available(2017-05-17) 8 | - Reliable deliver of broadcast during reconnect(2016-05-13) 9 | - /pub supports POST(2016-02-25) 10 | - Add icomet-server start options(2014-11-29) 11 | - Send periodical presence online events(2014-11-29) 12 | * Incompatible changes: 13 | - /broadcast will automatically encode content(2015-07-25) 14 | * Bug fixes: 15 | - Fix noop_seq bug(2017-05-17) 16 | - Fix Logger bug on multi-threads(2016-01-25) 17 | * 0.2.2.2 18 | * New features: 19 | - Add /broadcast, broadcast message to all channels(2014-08-28) 20 | - Add /push, to push message without json encoded, the server will do the encoding(2014-04-15) 21 | * Incompatible changes: 22 | - Change some logs(2014-06-17) 23 | - Message seq number starts from 1, not 0. History messages are not sent if sub seq is 0(2014-04-28) 24 | 25 | * 0.2.2.1 (2014-04-09) 26 | * New features: 27 | - Refactor source code 28 | * Bug fixes: 29 | - Fix memory leak bug, MUST call evhttp_send_reply_end in connection_closecb(2014-04-12) 30 | 31 | * 0.2.2 (2014-03-24) 32 | * New features: 33 | - Use new/delete instead of custom memory pool 34 | - Deprecate Channel.id property 35 | * Incompatible changes: 36 | - Wrap json object property names in quotes(2014-04-07) 37 | * Bug fixes: 38 | - Fix bug on HttpQuery(evhttp_parse_query without evhttp_clear_headers)(2014-04-02) 39 | 40 | * 0.2.1 (2014-03-20) 41 | * New features: 42 | - Add web demos: long-polling.html forever-iframe.html 43 | * Incompatible changes: 44 | - The data type of seq in response is changed to int(previousely string) 45 | 46 | * 0.2.0 (2014-02-26) 47 | Init this file. 48 | 49 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 iComet Authors 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | 3. Neither the name of the iComet nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 13 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | $(shell sh build.sh 1>&2) 2 | include build.mk 3 | 4 | .PHONY: all tools clean 5 | 6 | all: 7 | mkdir -p logs 8 | cd src/util; make 9 | cd src/comet; make 10 | cp -f icomet-server icomet-server-`cat version` 11 | 12 | tools: 13 | cd tools; make 14 | 15 | clean: 16 | rm -f *.exe.stackdump 17 | cd src/util; make clean 18 | cd src/comet; make clean 19 | rm -f icomet-server-* 20 | 21 | clean_all: clean 22 | cd $(JEMALLOC_PATH); make clean 23 | cd $(LIBEVENT_PATH); make clean 24 | rm -f $(JEMALLOC_PATH)/Makefile $(LIBEVENT_PATH)/Makefile 25 | 26 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | BASE_DIR=`pwd` 3 | TARGET_OS=`uname -s` 4 | JEMALLOC_PATH="$BASE_DIR/deps/jemalloc-3.4.0" 5 | LIBEVENT_PATH="$BASE_DIR/deps/libevent-2.0.21-stable" 6 | 7 | if test -z "$TARGET_OS"; then 8 | TARGET_OS=`uname -s` 9 | fi 10 | if test -z "$MAKE"; then 11 | MAKE=make 12 | fi 13 | if test -z "$CC"; then 14 | CC=gcc 15 | fi 16 | if test -z "$CXX"; then 17 | CXX=g++ 18 | fi 19 | 20 | case "$TARGET_OS" in 21 | Darwin) 22 | ;; 23 | Linux) 24 | PLATFORM_LIBS="-lrt -pthread" 25 | ;; 26 | CYGWIN_*) 27 | ;; 28 | SunOS) 29 | PLATFORM_LIBS="-lrt" 30 | ;; 31 | FreeBSD) 32 | PLATFORM_LIBS="" 33 | ;; 34 | NetBSD) 35 | PLATFORM_LIBS=" -lgcc_s" 36 | ;; 37 | OpenBSD) 38 | ;; 39 | DragonFly) 40 | PLATFORM_LIBS="" 41 | ;; 42 | OS_ANDROID_CROSSCOMPILE) 43 | ;; 44 | HP-UX) 45 | ;; 46 | *) 47 | echo "Unknown platform!" >&2 48 | exit 1 49 | esac 50 | 51 | 52 | ######### build jemalloc ######### 53 | 54 | case "$TARGET_OS" in 55 | CYGWIN*|FreeBSD|OS_ANDROID_CROSSCOMPILE) 56 | echo "not using jemalloc on $TARGET_OS" 57 | ;; 58 | *) 59 | DIR=`pwd` 60 | cd $JEMALLOC_PATH 61 | if [ ! -f Makefile ]; then 62 | echo "" 63 | echo "##### building jemalloc... #####" 64 | ./configure 65 | make 66 | echo "##### building jemalloc finished #####" 67 | echo "" 68 | fi 69 | cd "$DIR" 70 | ;; 71 | esac 72 | 73 | 74 | ######### build libevent ######### 75 | 76 | DIR=`pwd` 77 | cd "$LIBEVENT_PATH" 78 | if [ ! -f Makefile ]; then 79 | ./configure 80 | make 81 | fi 82 | cd "$DIR" 83 | 84 | 85 | ######### generate build.h ######### 86 | 87 | rm -f build.h 88 | rm -f src/version.h 89 | echo "#ifndef ICOMET_CONFIG_H" >> build.h 90 | echo "#define ICOMET_HTTP_HEADER_SERVER \"icomet `cat version`\"" >> build.h 91 | echo "#define ICOMET_VERSION \"`cat version`\"" >> build.h 92 | echo "#endif" >> build.h 93 | case "$TARGET_OS" in 94 | CYGWIN*|FreeBSD) 95 | ;; 96 | OS_ANDROID_CROSSCOMPILE) 97 | echo "#define OS_ANDROID 1" >> build.h 98 | ;; 99 | *) 100 | echo "#include " >> build.h 101 | echo "#include " >> build.h 102 | ;; 103 | esac 104 | 105 | 106 | ######### generate build.mk ######### 107 | 108 | rm -f build.mk 109 | 110 | echo C=$C >> build.mk 111 | echo CC=$CC >> build.mk 112 | echo CXX=$CXX >> build.mk 113 | echo CFLAGS := >> build.mk 114 | echo CFLAGS += -O2 -Wall -Wno-sign-compare >> build.mk 115 | echo CFLAGS += -D__STDC_FORMAT_MACROS >> build.mk 116 | echo CFLAGS += -I \"$LIBEVENT_PATH\" >> build.mk 117 | echo CFLAGS += -I \"$LIBEVENT_PATH/include\" >> build.mk 118 | echo CFLAGS += -I \"$LIBEVENT_PATH/compact\" >> build.mk 119 | 120 | echo CLIBS := >> build.mk 121 | echo CLIBS += $PLATFORM_LIBS >> build.mk 122 | 123 | case "$TARGET_OS" in 124 | CYGWIN*|FreeBSD|OS_ANDROID_CROSSCOMPILE) 125 | ;; 126 | *) 127 | echo "CLIBS += \"$JEMALLOC_PATH/lib/libjemalloc.a\"" >> build.mk 128 | echo "CFLAGS += -I \"$JEMALLOC_PATH/include\"" >> build.mk 129 | ;; 130 | esac 131 | 132 | echo LIBEVENT_PATH = $LIBEVENT_PATH >> build.mk 133 | echo JEMALLOC_PATH = $JEMALLOC_PATH >> build.mk 134 | 135 | -------------------------------------------------------------------------------- /demo/ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.xcuserstate 2 | ios.xcodeproj/project.xcworkspace/xcuserdata 3 | ios.xcodeproj/xcuserdata 4 | -------------------------------------------------------------------------------- /demo/ios/deps/include/IKit/IButton.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 ideawu. All rights reserved. 3 | Use of this source code is governed by a license that can be 4 | found in the LICENSE file. 5 | 6 | @author: ideawu 7 | @website: http://www.cocoaui.com/ 8 | */ 9 | 10 | #import "IView.h" 11 | 12 | @interface IButton : IView 13 | 14 | @property (nonatomic, readonly) UIButton *button; 15 | @property (nonatomic) NSString *text; 16 | 17 | + (IButton *)buttonWithText:(NSString *)text; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /demo/ios/deps/include/IKit/IImage.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 ideawu. All rights reserved. 3 | Use of this source code is governed by a license that can be 4 | found in the LICENSE file. 5 | 6 | @author: ideawu 7 | @website: http://www.cocoaui.com/ 8 | */ 9 | 10 | #import "IView.h" 11 | 12 | @interface IImage : IView 13 | 14 | @property (nonatomic) UIImageView *imageView; 15 | 16 | @property (nonatomic) NSString *src; 17 | @property (nonatomic) UIImage *image; 18 | 19 | + (IImage *)imageNamed:(NSString *)name; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /demo/ios/deps/include/IKit/IInput.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 ideawu. All rights reserved. 3 | Use of this source code is governed by a license that can be 4 | found in the LICENSE file. 5 | 6 | @author: ideawu 7 | @website: http://www.cocoaui.com/ 8 | */ 9 | 10 | #import "IView.h" 11 | 12 | @interface IInput : IView 13 | 14 | + (IInput *)textInput; 15 | + (IInput *)passwordInput; 16 | 17 | @property (nonatomic, readonly) UITextField *textField; 18 | @property (nonatomic) NSString *value; 19 | @property (nonatomic) NSString *placeholder; 20 | 21 | - (BOOL)isPasswordInput; 22 | - (void)setIsPasswordInput:(BOOL)yesno; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /demo/ios/deps/include/IKit/IKit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 ideawu. All rights reserved. 3 | Use of this source code is governed by a license that can be 4 | found in the LICENSE file. 5 | 6 | @author: ideawu 7 | @website: http://www.cocoaui.com/ 8 | */ 9 | 10 | #ifndef IKit_h 11 | #define IKit_h 12 | 13 | #import 14 | 15 | #import "IKit/IKitUtil.h" 16 | #import "IKit/IStyle.h" 17 | #import "IKit/IView.h" 18 | #import "IKit/ITable.h" 19 | #import "IKit/ITableRow.h" 20 | #import "IKit/ILabel.h" 21 | #import "IKit/IInput.h" 22 | #import "IKit/IButton.h" 23 | #import "IKit/ISwitch.h" 24 | #import "IKit/IImage.h" 25 | #import "IKit/IPullRefresh.h" 26 | #import "IKit/IRefreshControl.h" 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /demo/ios/deps/include/IKit/IKitUtil.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 ideawu. All rights reserved. 3 | Use of this source code is governed by a license that can be 4 | found in the LICENSE file. 5 | 6 | @author: ideawu 7 | @website: http://www.cocoaui.com/ 8 | */ 9 | 10 | #ifndef IKit_IKitUtil_h 11 | #define IKit_IKitUtil_h 12 | 13 | #import 14 | #import 15 | 16 | @interface IKitUtil : NSObject 17 | 18 | + (UIColor *) colorFromHex:(NSString *)hex; 19 | 20 | + (BOOL)isHTML:(NSString *)str; 21 | + (BOOL)isHttpUrl:(NSString *)src; 22 | 23 | + (NSArray *)parsePath:(NSString *)path; 24 | // combine basePath + src, src may be URL or absolute file path 25 | + (NSString *)buildPath:(NSString *)basePath src:(NSString *)src; 26 | 27 | + (UIImage *)loadImageFromPath:(NSString *)path; 28 | 29 | + (BOOL)isDataURI:(NSString *)src; 30 | + (UIImage *)loadImageFromDataURI:(NSString *)src; 31 | 32 | @end 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /demo/ios/deps/include/IKit/ILabel.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 ideawu. All rights reserved. 3 | Use of this source code is governed by a license that can be 4 | found in the LICENSE file. 5 | 6 | @author: ideawu 7 | @website: http://www.cocoaui.com/ 8 | */ 9 | 10 | #import "IView.h" 11 | 12 | @interface ILabel : IView 13 | 14 | @property (nonatomic, readonly) UILabel *label; 15 | @property (nonatomic) NSString *text; 16 | @property (nonatomic) NSAttributedString *attributedText; 17 | 18 | + (ILabel *)labelWithText:(NSString *)text; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /demo/ios/deps/include/IKit/IPopover.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 ideawu. All rights reserved. 3 | Use of this source code is governed by a license that can be 4 | found in the LICENSE file. 5 | 6 | @author: ideawu 7 | @website: http://www.cocoaui.com/ 8 | */ 9 | 10 | #ifndef IKit_IPopover_h 11 | #define IKit_IPopover_h 12 | 13 | #import "IView.h" 14 | 15 | @interface IPopover : IView 16 | 17 | - (void)presentView:(IView *)view onView:(UIView *)containerView; 18 | - (void)presentView:(IView *)view onViewController:(UIViewController *)controller; 19 | 20 | @end 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /demo/ios/deps/include/IKit/IPullRefresh.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 ideawu. All rights reserved. 3 | Use of this source code is governed by a license that can be 4 | found in the LICENSE file. 5 | 6 | @author: ideawu 7 | @website: http://www.cocoaui.com/ 8 | */ 9 | 10 | #ifndef IKit_IPullRefresh_h 11 | #define IKit_IPullRefresh_h 12 | 13 | #import 14 | #import "IView.h" 15 | 16 | typedef enum{ 17 | IRefreshTriggerPull, 18 | IRefreshTriggerScroll, 19 | }IRefreshTriggerMode; 20 | 21 | 22 | @protocol IPullRefreshDelegate; 23 | 24 | @interface IPullRefresh : NSObject 25 | 26 | @property (nonatomic, weak) id delegate; 27 | @property (nonatomic) IView *headerView; 28 | @property (nonatomic) IView *footerView; 29 | 30 | // default: IRefreshTriggerPull 31 | @property (nonatomic) IRefreshTriggerMode headerTriggerMode; 32 | // default: IRefreshTriggerScroll 33 | @property (nonatomic) IRefreshTriggerMode footerTriggerMode; 34 | 35 | /** 36 | * The visible portion of headerView to trigger a IRefreshBegin event, default is 1.0 37 | */ 38 | @property (nonatomic) CGFloat headerVisibleRateToRefresh; 39 | /** 40 | * The visible portion of footerView to trigger a IRefreshBegin event, default is 1.0 41 | */ 42 | @property (nonatomic) CGFloat footerVisibleRateToRefresh; 43 | 44 | - (id)initWithScrollView:(UIScrollView *)scrollView; 45 | 46 | // these are the methods that a UIScrollViewDelegate should call 47 | - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate; 48 | - (void)scrollViewDidScroll:(UIScrollView*)scrollView; 49 | 50 | - (void)endRefresh:(IView *)view; 51 | - (void)beginHeaderRefresh; 52 | - (void)beginFooterRefresh; 53 | 54 | @end 55 | 56 | 57 | @protocol IPullRefreshDelegate 58 | 59 | //@optional 60 | - (void)onRefresh:(IView *)view state:(IRefreshState)state; 61 | 62 | @end 63 | 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /demo/ios/deps/include/IKit/IRefreshControl.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 ideawu. All rights reserved. 3 | Use of this source code is governed by a license that can be 4 | found in the LICENSE file. 5 | 6 | @author: ideawu 7 | @website: http://www.cocoaui.com/ 8 | */ 9 | 10 | #ifndef IKit_IRefreshControl_h 11 | #define IKit_IRefreshControl_h 12 | 13 | #import "IView.h" 14 | 15 | @interface IRefreshControl : IView 16 | 17 | @property (nonatomic, readonly) IView *indicatorView; 18 | @property (nonatomic, readonly) IView *contentView; 19 | @property (nonatomic) IRefreshState state; 20 | 21 | - (void)setStateTextForNone:(NSString *)none maybe:(NSString *)maybe begin:(NSString *)begin; 22 | 23 | @end 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /demo/ios/deps/include/IKit/IStyle.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 ideawu. All rights reserved. 3 | Use of this source code is governed by a license that can be 4 | found in the LICENSE file. 5 | 6 | @author: ideawu 7 | @website: http://www.cocoaui.com/ 8 | */ 9 | 10 | #ifndef IKit_IStyle_h 11 | #define IKit_IStyle_h 12 | 13 | #import 14 | 15 | // groupTableViewBackgroundColor: #efeff4 16 | 17 | // outerBox: 包含 margin, border, padding, content 18 | // frameBox: 包含 border, padding, content 19 | // innerBox: 包含 content 20 | 21 | @interface IStyle : NSObject 22 | 23 | /** 24 | * The width, including border, padding, content 25 | */ 26 | @property (nonatomic) CGFloat width; 27 | /** 28 | * The height, including border, padding, content 29 | */ 30 | @property (nonatomic) CGFloat height; 31 | /** 32 | * The size, both width and height include border, padding, content 33 | */ 34 | @property (nonatomic, readonly) CGSize size; 35 | /** 36 | * The content width 37 | */ 38 | @property (nonatomic, readonly) CGFloat innerWidth; 39 | /** 40 | * The content height 41 | */ 42 | @property (nonatomic, readonly) CGFloat innerHeight; 43 | /** 44 | * The width, including margin, border, padding, content 45 | */ 46 | @property (nonatomic, readonly) CGFloat outerWidth; 47 | /** 48 | * The height, including margin, border, padding, content 49 | */ 50 | @property (nonatomic, readonly) CGFloat outerHeight; 51 | 52 | /** 53 | * supported property names: float, clear, width, height, margin 54 | * float=center will implicitly apply clear=right 55 | * float=center in a resizeWidth view, the behaviour is undefined 56 | */ 57 | - (void)set:(NSString *)css; 58 | 59 | /** 60 | * remove current classes(if any), and set the new one 61 | */ 62 | - (void)setClass:(NSString *)clz; 63 | /** 64 | * add a new class 65 | */ 66 | - (void)addClass:(NSString *)clz; 67 | - (void)removeClass:(NSString *)clz; 68 | - (BOOL)hasClass:(NSString *)clz; 69 | 70 | @end 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /demo/ios/deps/include/IKit/ISwitch.h: -------------------------------------------------------------------------------- 1 | // 2 | // ISwitch.h 3 | // IKit 4 | // 5 | // Created by ideawu on 7/29/15. 6 | // Copyright (c) 2015 ideawu. All rights reserved. 7 | // 8 | 9 | #import "IView.h" 10 | 11 | @interface ISwitch : IView 12 | 13 | @property (nonatomic, readonly) UISwitch *uiswitch; 14 | 15 | @property (nonatomic,getter=isOn) BOOL on; 16 | 17 | - (void)setOn:(BOOL)on animated:(BOOL)animated; // does not send action 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /demo/ios/deps/include/IKit/ITable.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 ideawu. All rights reserved. 3 | Use of this source code is governed by a license that can be 4 | found in the LICENSE file. 5 | 6 | @author: ideawu 7 | @website: http://www.cocoaui.com/ 8 | */ 9 | 10 | #ifndef IKit_ITable_h 11 | #define IKit_ITable_h 12 | 13 | #import 14 | #import "IView.h" 15 | 16 | @class IPullRefresh; 17 | @class IRefreshControl; 18 | 19 | @interface ITable : UIViewController 20 | 21 | @property (nonatomic, readonly) IPullRefresh *pullRefresh; 22 | @property (nonatomic) IRefreshControl *headerRefreshControl; 23 | @property (nonatomic) IRefreshControl *footerRefreshControl; 24 | 25 | @property (nonatomic) IView *headerView; 26 | @property (nonatomic) IView *footerView; 27 | 28 | - (void)clear; 29 | - (void)reload; 30 | - (NSUInteger)count; 31 | 32 | - (void)removeRowAtIndex:(NSUInteger)index; 33 | 34 | - (void)registerViewClass:(Class)ivClass forTag:(NSString *)tag; 35 | 36 | - (void)addIViewRow:(IView *)view; 37 | - (void)addIViewRow:(IView *)view defaultHeight:(CGFloat)height; 38 | - (void)addDataRow:(id)data forTag:(NSString *)tag; 39 | - (void)addDataRow:(id)data forTag:(NSString *)tag defaultHeight:(CGFloat)height; 40 | 41 | - (void)prependIViewRow:(IView *)view; 42 | - (void)prependIViewRow:(IView *)view defaultHeight:(CGFloat)height; 43 | - (void)prependDataRow:(id)data forTag:(NSString *)tag; 44 | - (void)prependDataRow:(id)data forTag:(NSString *)tag defaultHeight:(CGFloat)height; 45 | 46 | - (void)updateIViewRow:(IView *)view atIndex:(NSUInteger)index; 47 | - (void)updateDataRow:(id)data forTag:(NSString *)tag atIndex:(NSUInteger)index; 48 | 49 | - (void)insertIViewRow:(IView *)view atIndex:(NSUInteger)index; 50 | - (void)insertIViewRow:(IView *)view atIndex:(NSUInteger)index defaultHeight:(CGFloat)height; 51 | - (void)insertDataRow:(id)data forTag:(NSString *)tag atIndex:(NSUInteger)index; 52 | - (void)insertDataRow:(id)data forTag:(NSString *)tag atIndex:(NSUInteger)index defaultHeight:(CGFloat)height; 53 | 54 | 55 | - (void)addDivider:(NSString *)css; 56 | - (void)addDivider:(NSString *)css height:(CGFloat)height; 57 | 58 | - (void)onHighlight:(IView *)view atIndex:(NSUInteger)index; 59 | - (void)onUnhighlight:(IView *)view atIndex:(NSUInteger)index; 60 | - (void)onClick:(IView *)view atIndex:(NSUInteger)index; 61 | 62 | 63 | - (void)onRefresh:(IRefreshControl *)refreshControl state:(IRefreshState)state; 64 | /** 65 | * Must call this method in onRefresh() when state is IRefreshBegin 66 | */ 67 | - (void)endRefresh:(IRefreshControl *)refreshControl; 68 | 69 | 70 | 71 | 72 | 73 | // @deprecated, use addDivider instead 74 | - (void)addSeparator:(NSString *)css; 75 | - (void)addSeparator:(NSString *)css height:(CGFloat)height; 76 | 77 | // @deprecated 78 | - (void)onHighlight:(IView *)view; 79 | - (void)onUnhighlight:(IView *)view; 80 | - (void)onClick:(IView *)view; 81 | 82 | @end 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /demo/ios/deps/include/IKit/ITableRow.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 ideawu. All rights reserved. 3 | Use of this source code is governed by a license that can be 4 | found in the LICENSE file. 5 | 6 | @author: ideawu 7 | @website: http://www.cocoaui.com/ 8 | */ 9 | 10 | #import "IView.h" 11 | 12 | @interface ITableRow : IView 13 | 14 | - (id)initWithNumberOfColumns:(NSUInteger)num; 15 | 16 | - (void)column:(NSUInteger)column setText:(NSString *)text; 17 | - (IView *)columnView:(NSUInteger)column; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /demo/ios/deps/include/IKit/IView.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 ideawu. All rights reserved. 3 | Use of this source code is governed by a license that can be 4 | found in the LICENSE file. 5 | 6 | @author: ideawu 7 | @website: http://www.cocoaui.com/ 8 | */ 9 | 10 | #ifndef IKit_IView_h 11 | #define IKit_IView_h 12 | 13 | #import 14 | #import "IStyle.h" 15 | 16 | typedef enum{ 17 | IEventHighlight = 1<<0, 18 | IEventUnhighlight = 1<<1, 19 | IEventClick = 1<<2, 20 | IEventTap = IEventClick, 21 | IEventChange = 1<<3, 22 | IEventReturn = 1<<4, 23 | }IEventType; 24 | 25 | typedef enum{ 26 | IRefreshNone, 27 | IRefreshMaybe, 28 | IRefreshBegin, 29 | }IRefreshState; 30 | 31 | @class ITable; 32 | 33 | @interface IView : UIView 34 | 35 | @property (nonatomic, readonly) IStyle *style; 36 | 37 | + (IView *)viewWithUIView:(UIView *)view; 38 | + (IView *)viewWithUIView:(UIView *)view style:(NSString *)css; 39 | 40 | + (IView *)namedView:(NSString *)name; 41 | + (IView *)viewFromXml:(NSString *)xml; 42 | + (void)loadUrl:(NSString *)url callback:(void (^)(IView *view))callback; 43 | 44 | /** 45 | * Return the ITable which this view is in, if and only if this view is 46 | * an instance of the view class registered by ITable.registerViewClass. 47 | * NOTICE: become nil after this view is removed from ITable. 48 | */ 49 | - (ITable *)table; 50 | 51 | - (id)data; 52 | /** 53 | * override this method when IView is used as ITable row(MUST call [super setData]) 54 | */ 55 | - (void)setData:(id)data; 56 | 57 | // only available when init with xml or file 58 | - (IView *)getViewById:(NSString *)vid; 59 | 60 | /** 61 | * Add a view(instance of UIView or IView subclass) into subviews list, 62 | * apply style on the added view. 63 | */ 64 | - (void)addSubview:(UIView *)view style:(NSString *)css; 65 | /** 66 | * This method will traverse up the view hierarchy to find and return 67 | * the first UIViewController, if not any found, it will return nil. 68 | */ 69 | - (UIViewController *)viewController; 70 | 71 | 72 | - (void)show; 73 | - (void)hide; 74 | - (void)toggle; 75 | 76 | - (void)bindEvent:(IEventType)event handler:(void (^)(IEventType event, IView *view))handler; 77 | /** 78 | * event can be combined by | operator. 79 | */ 80 | - (void)addEvent:(IEventType)event handler:(void (^)(IEventType event, IView *view))handler; 81 | /** 82 | * event can not be combined. 83 | */ 84 | - (BOOL)fireEvent:(IEventType)event; 85 | 86 | @end 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /demo/ios/deps/include/curl/curlver.h: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_CURLVER_H 2 | #define __CURL_CURLVER_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at http://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | 25 | /* This header file contains nothing but libcurl version info, generated by 26 | a script at release-time. This was made its own header file in 7.11.2 */ 27 | 28 | /* This is the global package copyright */ 29 | #define LIBCURL_COPYRIGHT "1996 - 2015 Daniel Stenberg, ." 30 | 31 | /* This is the version number of the libcurl package from which this header 32 | file origins: */ 33 | #define LIBCURL_VERSION "7.40.0" 34 | 35 | /* The numeric version number is also available "in parts" by using these 36 | defines: */ 37 | #define LIBCURL_VERSION_MAJOR 7 38 | #define LIBCURL_VERSION_MINOR 40 39 | #define LIBCURL_VERSION_PATCH 0 40 | 41 | /* This is the numeric version of the libcurl version number, meant for easier 42 | parsing and comparions by programs. The LIBCURL_VERSION_NUM define will 43 | always follow this syntax: 44 | 45 | 0xXXYYZZ 46 | 47 | Where XX, YY and ZZ are the main version, release and patch numbers in 48 | hexadecimal (using 8 bits each). All three numbers are always represented 49 | using two digits. 1.2 would appear as "0x010200" while version 9.11.7 50 | appears as "0x090b07". 51 | 52 | This 6-digit (24 bits) hexadecimal number does not show pre-release number, 53 | and it is always a greater number in a more recent release. It makes 54 | comparisons with greater than and less than work. 55 | */ 56 | #define LIBCURL_VERSION_NUM 0x072800 57 | 58 | /* 59 | * This is the date and time when the full source package was created. The 60 | * timestamp is not stored in git, as the timestamp is properly set in the 61 | * tarballs by the maketgz script. 62 | * 63 | * The format of the date should follow this template: 64 | * 65 | * "Mon Feb 12 11:35:33 UTC 2007" 66 | */ 67 | #define LIBCURL_TIMESTAMP "Thu Jan 8 08:17:17 UTC 2015" 68 | 69 | #endif /* __CURL_CURLVER_H */ 70 | -------------------------------------------------------------------------------- /demo/ios/deps/include/curl/mprintf.h: -------------------------------------------------------------------------------- 1 | #ifndef __CURL_MPRINTF_H 2 | #define __CURL_MPRINTF_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at http://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | 25 | #include 26 | #include /* needed for FILE */ 27 | 28 | #include "curl.h" 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | CURL_EXTERN int curl_mprintf(const char *format, ...); 35 | CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...); 36 | CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...); 37 | CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength, 38 | const char *format, ...); 39 | CURL_EXTERN int curl_mvprintf(const char *format, va_list args); 40 | CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args); 41 | CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args); 42 | CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength, 43 | const char *format, va_list args); 44 | CURL_EXTERN char *curl_maprintf(const char *format, ...); 45 | CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args); 46 | 47 | #ifdef _MPRINTF_REPLACE 48 | # undef printf 49 | # undef fprintf 50 | # undef sprintf 51 | # undef vsprintf 52 | # undef snprintf 53 | # undef vprintf 54 | # undef vfprintf 55 | # undef vsnprintf 56 | # undef aprintf 57 | # undef vaprintf 58 | # define printf curl_mprintf 59 | # define fprintf curl_mfprintf 60 | #ifdef CURLDEBUG 61 | /* When built with CURLDEBUG we define away the sprintf functions since we 62 | don't want internal code to be using them */ 63 | # define sprintf sprintf_was_used 64 | # define vsprintf vsprintf_was_used 65 | #else 66 | # define sprintf curl_msprintf 67 | # define vsprintf curl_mvsprintf 68 | #endif 69 | # define snprintf curl_msnprintf 70 | # define vprintf curl_mvprintf 71 | # define vfprintf curl_mvfprintf 72 | # define vsnprintf curl_mvsnprintf 73 | # define aprintf curl_maprintf 74 | # define vaprintf curl_mvaprintf 75 | #endif 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif /* __CURL_MPRINTF_H */ 82 | -------------------------------------------------------------------------------- /demo/ios/deps/include/curl/stdcheaders.h: -------------------------------------------------------------------------------- 1 | #ifndef __STDC_HEADERS_H 2 | #define __STDC_HEADERS_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at http://curl.haxx.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | ***************************************************************************/ 24 | 25 | #include 26 | 27 | size_t fread (void *, size_t, size_t, FILE *); 28 | size_t fwrite (const void *, size_t, size_t, FILE *); 29 | 30 | int strcasecmp(const char *, const char *); 31 | int strncasecmp(const char *, const char *, size_t); 32 | 33 | #endif /* __STDC_HEADERS_H */ 34 | -------------------------------------------------------------------------------- /demo/ios/deps/libIKit.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/icomet/e842345af22b49cc00226ba4378bf1f2e377a597/demo/ios/deps/libIKit.a -------------------------------------------------------------------------------- /demo/ios/deps/libcurl.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/icomet/e842345af22b49cc00226ba4378bf1f2e377a597/demo/ios/deps/libcurl.a -------------------------------------------------------------------------------- /demo/ios/ios.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /demo/ios/ios/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ios 4 | // 5 | // Created by ideawu on 12/4/15. 6 | // Copyright © 2015 ideawu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /demo/ios/ios/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ios 4 | // 5 | // Created by ideawu on 12/4/15. 6 | // Copyright © 2015 ideawu. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "ViewController.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @property ViewController *viewController; 15 | 16 | @end 17 | 18 | @implementation AppDelegate 19 | 20 | 21 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 22 | NSLog(@"%s", __func__); 23 | 24 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 25 | //UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:table]; 26 | UINavigationController *nav = [[UINavigationController alloc] init]; 27 | nav.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor blackColor]}; 28 | nav.navigationBar.translucent = NO; 29 | nav.view.backgroundColor = [UIColor groupTableViewBackgroundColor]; 30 | [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 31 | 32 | self.window.rootViewController = nav; 33 | [self.window makeKeyAndVisible]; 34 | 35 | _viewController = [[ViewController alloc] init]; 36 | [nav pushViewController:_viewController animated:YES]; 37 | 38 | return YES; 39 | } 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | NSLog(@"%s", __func__); 43 | [_viewController start]; 44 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 45 | } 46 | 47 | - (void)applicationWillResignActive:(UIApplication *)application { 48 | NSLog(@"%s", __func__); 49 | [_viewController shutdown]; 50 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 51 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 52 | } 53 | 54 | - (void)applicationDidEnterBackground:(UIApplication *)application { 55 | NSLog(@"%s", __func__); 56 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 57 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 58 | } 59 | 60 | - (void)applicationWillEnterForeground:(UIApplication *)application { 61 | NSLog(@"%s", __func__); 62 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 63 | } 64 | 65 | - (void)applicationWillTerminate:(UIApplication *)application { 66 | NSLog(@"%s", __func__); 67 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /demo/ios/ios/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /demo/ios/ios/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /demo/ios/ios/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /demo/ios/ios/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /demo/ios/ios/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // ios 4 | // 5 | // Created by ideawu on 12/4/15. 6 | // Copyright © 2015 ideawu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | - (void)start; 14 | - (void)shutdown; 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /demo/ios/ios/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ios 4 | // 5 | // Created by ideawu on 12/4/15. 6 | // Copyright © 2015 ideawu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /demo/python/README.md: -------------------------------------------------------------------------------- 1 | # python icomet 2 | 3 | Maitained by: [@yuexiajiayan](https://github.com/yuexiajiayan/) 4 | 5 | 1. 安装pycurl类库 6 | 7 | 2. 编写pytest.py 8 | 9 | ``` 10 | import pycurl 11 | 12 | class Test: 13 | def body_callback(self, buf): 14 | if buf!="" : 15 | print buf#此处为接受到数据后的逻辑处理 略。。 16 | 17 | if __name__ == "__main__": 18 | url = 'http://127.0.0.1:8100/stream?cname=12' 19 | t = Test() 20 | c = pycurl.Curl() 21 | c.setopt(c.URL, url) 22 | c.setopt(c.WRITEFUNCTION, t.body_callback) 23 | c.perform() 24 | c.close() 25 | ``` 26 | 27 | 3. 打开浏览器请求 http://127.0.0.1:8000/push?cname=12&content=hi便会输出内容 28 | 29 | -------------------------------------------------------------------------------- /demo/python/test.py: -------------------------------------------------------------------------------- 1 | #author 609419323@qq.com 2 | import pycurl 3 | 4 | class Test: 5 | def body_callback(self, buf): 6 | if buf!="" : 7 | print buf#此处为接受到数据后的逻辑处理 略。。 8 | 9 | if __name__ == "__main__": 10 | url = 'http://127.0.0.1:8100/stream?cname=12'#stream不能变 cname可变 11 | t = Test() 12 | c = pycurl.Curl() 13 | c.setopt(c.URL, url) 14 | c.setopt(c.WRITEFUNCTION, t.body_callback) 15 | c.perform() 16 | c.close() 17 | -------------------------------------------------------------------------------- /demo/web/chat.css: -------------------------------------------------------------------------------- 1 | body{ 2 | margin: 0; 3 | padding: 0 12px; 4 | font-size: 14px; 5 | font-family: arial; 6 | background: #fff; 7 | } 8 | 9 | #login_form *{ 10 | font-size: 16px; 11 | } 12 | #login_form{ 13 | font-size: 18px; 14 | margin: 120px auto; 15 | padding: 40px 0px; 16 | width: 420px; 17 | text-align: center; 18 | border: 2px solid #996; 19 | background: #cfc; 20 | } 21 | input{ 22 | padding: 3px; 23 | } 24 | button{ 25 | font-size: 14px; 26 | } 27 | 28 | #chat_window{ 29 | margin: 10px auto; 30 | } 31 | #chat_window textarea{ 32 | margin: 0 auto; height: 100px; 33 | } 34 | .chat_window{ 35 | margin: 0 auto; 36 | padding: 4px; 37 | height: 500px; 38 | border: 1px solid #ccc; 39 | overflow-y: scroll; 40 | } 41 | #recv_chat_window{ 42 | margin-bottom: 6px; 43 | font-size: 12px; 44 | } 45 | .chat_names{ 46 | text-align: right; 47 | color: #ED145B; 48 | word-wrap: break-word; 49 | vertical-align: top; 50 | font-weight: bold; 51 | width: 70px; 52 | } 53 | .chat_content{ 54 | text-align: left; 55 | word-wrap: break-word; 56 | width: 100%; 57 | } 58 | 59 | .sent { 60 | background:url(sending.gif); 61 | background-size: 16px 16px; 62 | } 63 | 64 | .emoticon { 65 | display:inline-block; 66 | text-indent:-9999px; 67 | width:16px; 68 | height:16px; 69 | background:url(emoticons.png); 70 | background-repeat:no-repeat; 71 | } 72 | 73 | .emoticon{ 74 | background-position:0 0; margin-top:-2px; 75 | } 76 | #emoticonDropDown { 77 | position:absolute; 78 | z-index:100; 79 | border:2px solid #eee; 80 | background-color: #fff; 81 | padding:2px; 82 | } 83 | #emoticonDropDown li{ 84 | display: inline; 85 | float:right; 86 | list-style-type: none; 87 | padding: 0; 88 | margin:0; 89 | height:20px; 90 | width:20px; 91 | } 92 | #emoticonDropDown ul{ 93 | line-height:16px; 94 | width: 120px; 95 | margin: 0; 96 | padding: 0; 97 | } 98 | #emoticonDropDown a{ 99 | display: block; 100 | text-align: center; 101 | text-decoration: none; 102 | color: #000; 103 | height:16px; 104 | width:16px; 105 | padding-top:2px; 106 | } 107 | #emoticonDropDown a:hover{ 108 | background-color: #888; 109 | } 110 | #emoticonDropDown a.closeLink{ 111 | color:#aaa; 112 | clear: both; 113 | width:100%; 114 | height:10px; 115 | font-size:0.6em; 116 | padding:0; 117 | margin:0; 118 | } 119 | -------------------------------------------------------------------------------- /demo/web/chat.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | iComet Example Chat 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 27 | 28 |
Nickname
Channel 25 | 26 |
29 |

Join the public channel with others

30 | 31 |
32 | 33 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /demo/web/emoticons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/icomet/e842345af22b49cc00226ba4378bf1f2e377a597/demo/web/emoticons.png -------------------------------------------------------------------------------- /demo/web/forever-iframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | iComet forever-iframe demo 6 | 7 | 8 | 9 |
10 | ## How to Use?
11 | 
12 | 1. start icomet-server
13 | 
14 | 2. assuming you are running nginx listening on port 8080, if not,
15 | you will have to modify "8080" in this file to the exact port number,
16 | configure your nginx.conf, add the lines below and restart:
17 | 
18 | location ~ ^/icomet/.* {
19 | 	rewrite ^/icomet/(.*) /$1 break;
20 | 
21 | 	proxy_buffering off;
22 | 	proxy_read_timeout 60;
23 | 	proxy_connect_timeout 60;
24 | 	proxy_pass   http://127.0.0.1:8100;
25 | }
26 | 
27 | 3. navigate your web browser to http://127.0.0.1:8080/web/long-polling.html
28 | or http://127.0.0.1:8080/web/forever-iframe.html
29 | 
30 | 4. open a command line terminal, execute
31 | 
32 | curl "http://127.0.0.1:8000/push?cname=a&content=hello"
33 | 
34 | 35 | 55 | 56 |

Server push messages:

57 |
58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /demo/web/long-polling.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | iComet long-polling demo 6 | 7 | 8 | 9 | 10 | 11 |
12 | ## How to Use?
13 | 
14 | 1. start icomet-server
15 | 
16 | 2. open long-polling.html in web browser(Firefox, Chrome, Safari, etc)
17 | 
18 | 3. open a command line terminal, execute
19 | 
20 | curl "http://127.0.0.1:8000/push?cname=a&content=hello"
21 | 
22 | 23 |

Server push messages:

24 |
25 | 26 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /demo/web/php/push.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 13 |
14 |             Event Source Listen on "http://127.0.0.1:8100/sse?cname=12&seq=1"
15 |             Publish Message :
16 |                 curl -v "http://127.0.0.1:8000/push?cname=12&content=HelloSSE"
17 |         
18 | 19 | 20 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/.gitignore: -------------------------------------------------------------------------------- 1 | /autom4te.cache/ 2 | /config.stamp 3 | /config.log 4 | /config.status 5 | /doc/html.xsl 6 | /doc/manpages.xsl 7 | /doc/jemalloc.xml 8 | /doc/jemalloc.html 9 | /doc/jemalloc.3 10 | /lib/ 11 | /Makefile 12 | /include/jemalloc/internal/jemalloc_internal\.h 13 | /include/jemalloc/internal/size_classes\.h 14 | /include/jemalloc/jemalloc\.h 15 | /include/jemalloc/jemalloc_defs\.h 16 | /test/jemalloc_test\.h 17 | /src/*.[od] 18 | /test/*.[od] 19 | /test/*.out 20 | /test/[a-zA-Z_]* 21 | !test/*.c 22 | !test/*.in 23 | !test/*.exp 24 | /VERSION 25 | /bin/jemalloc.sh 26 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/COPYING: -------------------------------------------------------------------------------- 1 | Unless otherwise specified, files in the jemalloc source distribution are 2 | subject to the following license: 3 | -------------------------------------------------------------------------------- 4 | Copyright (C) 2002-2013 Jason Evans . 5 | All rights reserved. 6 | Copyright (C) 2007-2012 Mozilla Foundation. All rights reserved. 7 | Copyright (C) 2009-2013 Facebook, Inc. All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | 1. Redistributions of source code must retain the above copyright notice(s), 12 | this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright notice(s), 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY EXPRESS 18 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- 28 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/README: -------------------------------------------------------------------------------- 1 | jemalloc is a general-purpose scalable concurrent malloc(3) implementation. 2 | This distribution is a "portable" implementation that currently targets 3 | FreeBSD, Linux, Apple OS X, and MinGW. jemalloc is included as the default 4 | allocator in the FreeBSD and NetBSD operating systems, and it is used by the 5 | Mozilla Firefox web browser on Microsoft Windows-related platforms. Depending 6 | on your needs, one of the other divergent versions may suit your needs better 7 | than this distribution. 8 | 9 | The COPYING file contains copyright and licensing information. 10 | 11 | The INSTALL file contains information on how to configure, build, and install 12 | jemalloc. 13 | 14 | The ChangeLog file contains a brief summary of changes for each release. 15 | 16 | URL: http://www.canonware.com/jemalloc/ 17 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for i in autoconf; do 4 | echo "$i" 5 | $i 6 | if [ $? -ne 0 ]; then 7 | echo "Error $? in $i" 8 | exit 1 9 | fi 10 | done 11 | 12 | echo "./configure --enable-autogen $@" 13 | ./configure --enable-autogen $@ 14 | if [ $? -ne 0 ]; then 15 | echo "Error $? in ./configure" 16 | exit 1 17 | fi 18 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/bin/jemalloc.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | prefix=@prefix@ 4 | exec_prefix=@exec_prefix@ 5 | libdir=@libdir@ 6 | 7 | @LD_PRELOAD_VAR@=${libdir}/libjemalloc.@SOREV@ 8 | export @LD_PRELOAD_VAR@ 9 | exec "$@" 10 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/config.stamp.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ideawu/icomet/e842345af22b49cc00226ba4378bf1f2e377a597/deps/jemalloc-3.4.0/config.stamp.in -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/doc/html.xsl.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/doc/manpages.xsl.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/doc/stylesheet.xsl: -------------------------------------------------------------------------------- 1 | 2 | ansi 3 | 4 | 5 | "" 6 | 7 | 8 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/include/jemalloc/internal/base.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | #endif /* JEMALLOC_H_TYPES */ 5 | /******************************************************************************/ 6 | #ifdef JEMALLOC_H_STRUCTS 7 | 8 | #endif /* JEMALLOC_H_STRUCTS */ 9 | /******************************************************************************/ 10 | #ifdef JEMALLOC_H_EXTERNS 11 | 12 | void *base_alloc(size_t size); 13 | void *base_calloc(size_t number, size_t size); 14 | extent_node_t *base_node_alloc(void); 15 | void base_node_dealloc(extent_node_t *node); 16 | bool base_boot(void); 17 | void base_prefork(void); 18 | void base_postfork_parent(void); 19 | void base_postfork_child(void); 20 | 21 | #endif /* JEMALLOC_H_EXTERNS */ 22 | /******************************************************************************/ 23 | #ifdef JEMALLOC_H_INLINES 24 | 25 | #endif /* JEMALLOC_H_INLINES */ 26 | /******************************************************************************/ 27 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/include/jemalloc/internal/chunk.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | /* 5 | * Size and alignment of memory chunks that are allocated by the OS's virtual 6 | * memory system. 7 | */ 8 | #define LG_CHUNK_DEFAULT 22 9 | 10 | /* Return the chunk address for allocation address a. */ 11 | #define CHUNK_ADDR2BASE(a) \ 12 | ((void *)((uintptr_t)(a) & ~chunksize_mask)) 13 | 14 | /* Return the chunk offset of address a. */ 15 | #define CHUNK_ADDR2OFFSET(a) \ 16 | ((size_t)((uintptr_t)(a) & chunksize_mask)) 17 | 18 | /* Return the smallest chunk multiple that is >= s. */ 19 | #define CHUNK_CEILING(s) \ 20 | (((s) + chunksize_mask) & ~chunksize_mask) 21 | 22 | #endif /* JEMALLOC_H_TYPES */ 23 | /******************************************************************************/ 24 | #ifdef JEMALLOC_H_STRUCTS 25 | 26 | #endif /* JEMALLOC_H_STRUCTS */ 27 | /******************************************************************************/ 28 | #ifdef JEMALLOC_H_EXTERNS 29 | 30 | extern size_t opt_lg_chunk; 31 | extern const char *opt_dss; 32 | 33 | /* Protects stats_chunks; currently not used for any other purpose. */ 34 | extern malloc_mutex_t chunks_mtx; 35 | /* Chunk statistics. */ 36 | extern chunk_stats_t stats_chunks; 37 | 38 | extern rtree_t *chunks_rtree; 39 | 40 | extern size_t chunksize; 41 | extern size_t chunksize_mask; /* (chunksize - 1). */ 42 | extern size_t chunk_npages; 43 | extern size_t map_bias; /* Number of arena chunk header pages. */ 44 | extern size_t arena_maxclass; /* Max size class for arenas. */ 45 | 46 | void *chunk_alloc(size_t size, size_t alignment, bool base, bool *zero, 47 | dss_prec_t dss_prec); 48 | void chunk_unmap(void *chunk, size_t size); 49 | void chunk_dealloc(void *chunk, size_t size, bool unmap); 50 | bool chunk_boot(void); 51 | void chunk_prefork(void); 52 | void chunk_postfork_parent(void); 53 | void chunk_postfork_child(void); 54 | 55 | #endif /* JEMALLOC_H_EXTERNS */ 56 | /******************************************************************************/ 57 | #ifdef JEMALLOC_H_INLINES 58 | 59 | #endif /* JEMALLOC_H_INLINES */ 60 | /******************************************************************************/ 61 | 62 | #include "jemalloc/internal/chunk_dss.h" 63 | #include "jemalloc/internal/chunk_mmap.h" 64 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/include/jemalloc/internal/chunk_dss.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | typedef enum { 5 | dss_prec_disabled = 0, 6 | dss_prec_primary = 1, 7 | dss_prec_secondary = 2, 8 | 9 | dss_prec_limit = 3 10 | } dss_prec_t ; 11 | #define DSS_PREC_DEFAULT dss_prec_secondary 12 | #define DSS_DEFAULT "secondary" 13 | 14 | #endif /* JEMALLOC_H_TYPES */ 15 | /******************************************************************************/ 16 | #ifdef JEMALLOC_H_STRUCTS 17 | 18 | extern const char *dss_prec_names[]; 19 | 20 | #endif /* JEMALLOC_H_STRUCTS */ 21 | /******************************************************************************/ 22 | #ifdef JEMALLOC_H_EXTERNS 23 | 24 | dss_prec_t chunk_dss_prec_get(void); 25 | bool chunk_dss_prec_set(dss_prec_t dss_prec); 26 | void *chunk_alloc_dss(size_t size, size_t alignment, bool *zero); 27 | bool chunk_in_dss(void *chunk); 28 | bool chunk_dss_boot(void); 29 | void chunk_dss_prefork(void); 30 | void chunk_dss_postfork_parent(void); 31 | void chunk_dss_postfork_child(void); 32 | 33 | #endif /* JEMALLOC_H_EXTERNS */ 34 | /******************************************************************************/ 35 | #ifdef JEMALLOC_H_INLINES 36 | 37 | #endif /* JEMALLOC_H_INLINES */ 38 | /******************************************************************************/ 39 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/include/jemalloc/internal/chunk_mmap.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | #endif /* JEMALLOC_H_TYPES */ 5 | /******************************************************************************/ 6 | #ifdef JEMALLOC_H_STRUCTS 7 | 8 | #endif /* JEMALLOC_H_STRUCTS */ 9 | /******************************************************************************/ 10 | #ifdef JEMALLOC_H_EXTERNS 11 | 12 | bool pages_purge(void *addr, size_t length); 13 | 14 | void *chunk_alloc_mmap(size_t size, size_t alignment, bool *zero); 15 | bool chunk_dealloc_mmap(void *chunk, size_t size); 16 | 17 | #endif /* JEMALLOC_H_EXTERNS */ 18 | /******************************************************************************/ 19 | #ifdef JEMALLOC_H_INLINES 20 | 21 | #endif /* JEMALLOC_H_INLINES */ 22 | /******************************************************************************/ 23 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/include/jemalloc/internal/ckh.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | typedef struct ckh_s ckh_t; 5 | typedef struct ckhc_s ckhc_t; 6 | 7 | /* Typedefs to allow easy function pointer passing. */ 8 | typedef void ckh_hash_t (const void *, size_t[2]); 9 | typedef bool ckh_keycomp_t (const void *, const void *); 10 | 11 | /* Maintain counters used to get an idea of performance. */ 12 | /* #define CKH_COUNT */ 13 | /* Print counter values in ckh_delete() (requires CKH_COUNT). */ 14 | /* #define CKH_VERBOSE */ 15 | 16 | /* 17 | * There are 2^LG_CKH_BUCKET_CELLS cells in each hash table bucket. Try to fit 18 | * one bucket per L1 cache line. 19 | */ 20 | #define LG_CKH_BUCKET_CELLS (LG_CACHELINE - LG_SIZEOF_PTR - 1) 21 | 22 | #endif /* JEMALLOC_H_TYPES */ 23 | /******************************************************************************/ 24 | #ifdef JEMALLOC_H_STRUCTS 25 | 26 | /* Hash table cell. */ 27 | struct ckhc_s { 28 | const void *key; 29 | const void *data; 30 | }; 31 | 32 | struct ckh_s { 33 | #ifdef CKH_COUNT 34 | /* Counters used to get an idea of performance. */ 35 | uint64_t ngrows; 36 | uint64_t nshrinks; 37 | uint64_t nshrinkfails; 38 | uint64_t ninserts; 39 | uint64_t nrelocs; 40 | #endif 41 | 42 | /* Used for pseudo-random number generation. */ 43 | #define CKH_A 1103515241 44 | #define CKH_C 12347 45 | uint32_t prng_state; 46 | 47 | /* Total number of items. */ 48 | size_t count; 49 | 50 | /* 51 | * Minimum and current number of hash table buckets. There are 52 | * 2^LG_CKH_BUCKET_CELLS cells per bucket. 53 | */ 54 | unsigned lg_minbuckets; 55 | unsigned lg_curbuckets; 56 | 57 | /* Hash and comparison functions. */ 58 | ckh_hash_t *hash; 59 | ckh_keycomp_t *keycomp; 60 | 61 | /* Hash table with 2^lg_curbuckets buckets. */ 62 | ckhc_t *tab; 63 | }; 64 | 65 | #endif /* JEMALLOC_H_STRUCTS */ 66 | /******************************************************************************/ 67 | #ifdef JEMALLOC_H_EXTERNS 68 | 69 | bool ckh_new(ckh_t *ckh, size_t minitems, ckh_hash_t *hash, 70 | ckh_keycomp_t *keycomp); 71 | void ckh_delete(ckh_t *ckh); 72 | size_t ckh_count(ckh_t *ckh); 73 | bool ckh_iter(ckh_t *ckh, size_t *tabind, void **key, void **data); 74 | bool ckh_insert(ckh_t *ckh, const void *key, const void *data); 75 | bool ckh_remove(ckh_t *ckh, const void *searchkey, void **key, 76 | void **data); 77 | bool ckh_search(ckh_t *ckh, const void *seachkey, void **key, void **data); 78 | void ckh_string_hash(const void *key, size_t r_hash[2]); 79 | bool ckh_string_keycomp(const void *k1, const void *k2); 80 | void ckh_pointer_hash(const void *key, size_t r_hash[2]); 81 | bool ckh_pointer_keycomp(const void *k1, const void *k2); 82 | 83 | #endif /* JEMALLOC_H_EXTERNS */ 84 | /******************************************************************************/ 85 | #ifdef JEMALLOC_H_INLINES 86 | 87 | #endif /* JEMALLOC_H_INLINES */ 88 | /******************************************************************************/ 89 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/include/jemalloc/internal/extent.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | typedef struct extent_node_s extent_node_t; 5 | 6 | #endif /* JEMALLOC_H_TYPES */ 7 | /******************************************************************************/ 8 | #ifdef JEMALLOC_H_STRUCTS 9 | 10 | /* Tree of extents. */ 11 | struct extent_node_s { 12 | /* Linkage for the size/address-ordered tree. */ 13 | rb_node(extent_node_t) link_szad; 14 | 15 | /* Linkage for the address-ordered tree. */ 16 | rb_node(extent_node_t) link_ad; 17 | 18 | /* Profile counters, used for huge objects. */ 19 | prof_ctx_t *prof_ctx; 20 | 21 | /* Pointer to the extent that this tree node is responsible for. */ 22 | void *addr; 23 | 24 | /* Total region size. */ 25 | size_t size; 26 | 27 | /* True if zero-filled; used by chunk recycling code. */ 28 | bool zeroed; 29 | }; 30 | typedef rb_tree(extent_node_t) extent_tree_t; 31 | 32 | #endif /* JEMALLOC_H_STRUCTS */ 33 | /******************************************************************************/ 34 | #ifdef JEMALLOC_H_EXTERNS 35 | 36 | rb_proto(, extent_tree_szad_, extent_tree_t, extent_node_t) 37 | 38 | rb_proto(, extent_tree_ad_, extent_tree_t, extent_node_t) 39 | 40 | #endif /* JEMALLOC_H_EXTERNS */ 41 | /******************************************************************************/ 42 | #ifdef JEMALLOC_H_INLINES 43 | 44 | #endif /* JEMALLOC_H_INLINES */ 45 | /******************************************************************************/ 46 | 47 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/include/jemalloc/internal/huge.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | #endif /* JEMALLOC_H_TYPES */ 5 | /******************************************************************************/ 6 | #ifdef JEMALLOC_H_STRUCTS 7 | 8 | #endif /* JEMALLOC_H_STRUCTS */ 9 | /******************************************************************************/ 10 | #ifdef JEMALLOC_H_EXTERNS 11 | 12 | /* Huge allocation statistics. */ 13 | extern uint64_t huge_nmalloc; 14 | extern uint64_t huge_ndalloc; 15 | extern size_t huge_allocated; 16 | 17 | /* Protects chunk-related data structures. */ 18 | extern malloc_mutex_t huge_mtx; 19 | 20 | void *huge_malloc(size_t size, bool zero); 21 | void *huge_palloc(size_t size, size_t alignment, bool zero); 22 | void *huge_ralloc_no_move(void *ptr, size_t oldsize, size_t size, 23 | size_t extra); 24 | void *huge_ralloc(void *ptr, size_t oldsize, size_t size, size_t extra, 25 | size_t alignment, bool zero, bool try_tcache_dalloc); 26 | void huge_dalloc(void *ptr, bool unmap); 27 | size_t huge_salloc(const void *ptr); 28 | prof_ctx_t *huge_prof_ctx_get(const void *ptr); 29 | void huge_prof_ctx_set(const void *ptr, prof_ctx_t *ctx); 30 | bool huge_boot(void); 31 | void huge_prefork(void); 32 | void huge_postfork_parent(void); 33 | void huge_postfork_child(void); 34 | 35 | #endif /* JEMALLOC_H_EXTERNS */ 36 | /******************************************************************************/ 37 | #ifdef JEMALLOC_H_INLINES 38 | 39 | #endif /* JEMALLOC_H_INLINES */ 40 | /******************************************************************************/ 41 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/include/jemalloc/internal/mb.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | #endif /* JEMALLOC_H_TYPES */ 5 | /******************************************************************************/ 6 | #ifdef JEMALLOC_H_STRUCTS 7 | 8 | #endif /* JEMALLOC_H_STRUCTS */ 9 | /******************************************************************************/ 10 | #ifdef JEMALLOC_H_EXTERNS 11 | 12 | #endif /* JEMALLOC_H_EXTERNS */ 13 | /******************************************************************************/ 14 | #ifdef JEMALLOC_H_INLINES 15 | 16 | #ifndef JEMALLOC_ENABLE_INLINE 17 | void mb_write(void); 18 | #endif 19 | 20 | #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_MB_C_)) 21 | #ifdef __i386__ 22 | /* 23 | * According to the Intel Architecture Software Developer's Manual, current 24 | * processors execute instructions in order from the perspective of other 25 | * processors in a multiprocessor system, but 1) Intel reserves the right to 26 | * change that, and 2) the compiler's optimizer could re-order instructions if 27 | * there weren't some form of barrier. Therefore, even if running on an 28 | * architecture that does not need memory barriers (everything through at least 29 | * i686), an "optimizer barrier" is necessary. 30 | */ 31 | JEMALLOC_INLINE void 32 | mb_write(void) 33 | { 34 | 35 | # if 0 36 | /* This is a true memory barrier. */ 37 | asm volatile ("pusha;" 38 | "xor %%eax,%%eax;" 39 | "cpuid;" 40 | "popa;" 41 | : /* Outputs. */ 42 | : /* Inputs. */ 43 | : "memory" /* Clobbers. */ 44 | ); 45 | #else 46 | /* 47 | * This is hopefully enough to keep the compiler from reordering 48 | * instructions around this one. 49 | */ 50 | asm volatile ("nop;" 51 | : /* Outputs. */ 52 | : /* Inputs. */ 53 | : "memory" /* Clobbers. */ 54 | ); 55 | #endif 56 | } 57 | #elif (defined(__amd64__) || defined(__x86_64__)) 58 | JEMALLOC_INLINE void 59 | mb_write(void) 60 | { 61 | 62 | asm volatile ("sfence" 63 | : /* Outputs. */ 64 | : /* Inputs. */ 65 | : "memory" /* Clobbers. */ 66 | ); 67 | } 68 | #elif defined(__powerpc__) 69 | JEMALLOC_INLINE void 70 | mb_write(void) 71 | { 72 | 73 | asm volatile ("eieio" 74 | : /* Outputs. */ 75 | : /* Inputs. */ 76 | : "memory" /* Clobbers. */ 77 | ); 78 | } 79 | #elif defined(__sparc64__) 80 | JEMALLOC_INLINE void 81 | mb_write(void) 82 | { 83 | 84 | asm volatile ("membar #StoreStore" 85 | : /* Outputs. */ 86 | : /* Inputs. */ 87 | : "memory" /* Clobbers. */ 88 | ); 89 | } 90 | #elif defined(__tile__) 91 | JEMALLOC_INLINE void 92 | mb_write(void) 93 | { 94 | 95 | __sync_synchronize(); 96 | } 97 | #else 98 | /* 99 | * This is much slower than a simple memory barrier, but the semantics of mutex 100 | * unlock make this work. 101 | */ 102 | JEMALLOC_INLINE void 103 | mb_write(void) 104 | { 105 | malloc_mutex_t mtx; 106 | 107 | malloc_mutex_init(&mtx); 108 | malloc_mutex_lock(&mtx); 109 | malloc_mutex_unlock(&mtx); 110 | } 111 | #endif 112 | #endif 113 | 114 | #endif /* JEMALLOC_H_INLINES */ 115 | /******************************************************************************/ 116 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/include/jemalloc/internal/mutex.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | typedef struct malloc_mutex_s malloc_mutex_t; 5 | 6 | #ifdef _WIN32 7 | # define MALLOC_MUTEX_INITIALIZER 8 | #elif (defined(JEMALLOC_OSSPIN)) 9 | # define MALLOC_MUTEX_INITIALIZER {0} 10 | #elif (defined(JEMALLOC_MUTEX_INIT_CB)) 11 | # define MALLOC_MUTEX_INITIALIZER {PTHREAD_MUTEX_INITIALIZER, NULL} 12 | #else 13 | # if (defined(PTHREAD_MUTEX_ADAPTIVE_NP) && \ 14 | defined(PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP)) 15 | # define MALLOC_MUTEX_TYPE PTHREAD_MUTEX_ADAPTIVE_NP 16 | # define MALLOC_MUTEX_INITIALIZER {PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP} 17 | # else 18 | # define MALLOC_MUTEX_TYPE PTHREAD_MUTEX_DEFAULT 19 | # define MALLOC_MUTEX_INITIALIZER {PTHREAD_MUTEX_INITIALIZER} 20 | # endif 21 | #endif 22 | 23 | #endif /* JEMALLOC_H_TYPES */ 24 | /******************************************************************************/ 25 | #ifdef JEMALLOC_H_STRUCTS 26 | 27 | struct malloc_mutex_s { 28 | #ifdef _WIN32 29 | CRITICAL_SECTION lock; 30 | #elif (defined(JEMALLOC_OSSPIN)) 31 | OSSpinLock lock; 32 | #elif (defined(JEMALLOC_MUTEX_INIT_CB)) 33 | pthread_mutex_t lock; 34 | malloc_mutex_t *postponed_next; 35 | #else 36 | pthread_mutex_t lock; 37 | #endif 38 | }; 39 | 40 | #endif /* JEMALLOC_H_STRUCTS */ 41 | /******************************************************************************/ 42 | #ifdef JEMALLOC_H_EXTERNS 43 | 44 | #ifdef JEMALLOC_LAZY_LOCK 45 | extern bool isthreaded; 46 | #else 47 | # undef isthreaded /* Undo private_namespace.h definition. */ 48 | # define isthreaded true 49 | #endif 50 | 51 | bool malloc_mutex_init(malloc_mutex_t *mutex); 52 | void malloc_mutex_prefork(malloc_mutex_t *mutex); 53 | void malloc_mutex_postfork_parent(malloc_mutex_t *mutex); 54 | void malloc_mutex_postfork_child(malloc_mutex_t *mutex); 55 | bool mutex_boot(void); 56 | 57 | #endif /* JEMALLOC_H_EXTERNS */ 58 | /******************************************************************************/ 59 | #ifdef JEMALLOC_H_INLINES 60 | 61 | #ifndef JEMALLOC_ENABLE_INLINE 62 | void malloc_mutex_lock(malloc_mutex_t *mutex); 63 | void malloc_mutex_unlock(malloc_mutex_t *mutex); 64 | #endif 65 | 66 | #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_MUTEX_C_)) 67 | JEMALLOC_INLINE void 68 | malloc_mutex_lock(malloc_mutex_t *mutex) 69 | { 70 | 71 | if (isthreaded) { 72 | #ifdef _WIN32 73 | EnterCriticalSection(&mutex->lock); 74 | #elif (defined(JEMALLOC_OSSPIN)) 75 | OSSpinLockLock(&mutex->lock); 76 | #else 77 | pthread_mutex_lock(&mutex->lock); 78 | #endif 79 | } 80 | } 81 | 82 | JEMALLOC_INLINE void 83 | malloc_mutex_unlock(malloc_mutex_t *mutex) 84 | { 85 | 86 | if (isthreaded) { 87 | #ifdef _WIN32 88 | LeaveCriticalSection(&mutex->lock); 89 | #elif (defined(JEMALLOC_OSSPIN)) 90 | OSSpinLockUnlock(&mutex->lock); 91 | #else 92 | pthread_mutex_unlock(&mutex->lock); 93 | #endif 94 | } 95 | } 96 | #endif 97 | 98 | #endif /* JEMALLOC_H_INLINES */ 99 | /******************************************************************************/ 100 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/include/jemalloc/internal/prng.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | /* 5 | * Simple linear congruential pseudo-random number generator: 6 | * 7 | * prng(y) = (a*x + c) % m 8 | * 9 | * where the following constants ensure maximal period: 10 | * 11 | * a == Odd number (relatively prime to 2^n), and (a-1) is a multiple of 4. 12 | * c == Odd number (relatively prime to 2^n). 13 | * m == 2^32 14 | * 15 | * See Knuth's TAOCP 3rd Ed., Vol. 2, pg. 17 for details on these constraints. 16 | * 17 | * This choice of m has the disadvantage that the quality of the bits is 18 | * proportional to bit position. For example. the lowest bit has a cycle of 2, 19 | * the next has a cycle of 4, etc. For this reason, we prefer to use the upper 20 | * bits. 21 | * 22 | * Macro parameters: 23 | * uint32_t r : Result. 24 | * unsigned lg_range : (0..32], number of least significant bits to return. 25 | * uint32_t state : Seed value. 26 | * const uint32_t a, c : See above discussion. 27 | */ 28 | #define prng32(r, lg_range, state, a, c) do { \ 29 | assert(lg_range > 0); \ 30 | assert(lg_range <= 32); \ 31 | \ 32 | r = (state * (a)) + (c); \ 33 | state = r; \ 34 | r >>= (32 - lg_range); \ 35 | } while (false) 36 | 37 | /* Same as prng32(), but 64 bits of pseudo-randomness, using uint64_t. */ 38 | #define prng64(r, lg_range, state, a, c) do { \ 39 | assert(lg_range > 0); \ 40 | assert(lg_range <= 64); \ 41 | \ 42 | r = (state * (a)) + (c); \ 43 | state = r; \ 44 | r >>= (64 - lg_range); \ 45 | } while (false) 46 | 47 | #endif /* JEMALLOC_H_TYPES */ 48 | /******************************************************************************/ 49 | #ifdef JEMALLOC_H_STRUCTS 50 | 51 | #endif /* JEMALLOC_H_STRUCTS */ 52 | /******************************************************************************/ 53 | #ifdef JEMALLOC_H_EXTERNS 54 | 55 | #endif /* JEMALLOC_H_EXTERNS */ 56 | /******************************************************************************/ 57 | #ifdef JEMALLOC_H_INLINES 58 | 59 | #endif /* JEMALLOC_H_INLINES */ 60 | /******************************************************************************/ 61 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/include/jemalloc/internal/ql.h: -------------------------------------------------------------------------------- 1 | /* 2 | * List definitions. 3 | */ 4 | #define ql_head(a_type) \ 5 | struct { \ 6 | a_type *qlh_first; \ 7 | } 8 | 9 | #define ql_head_initializer(a_head) {NULL} 10 | 11 | #define ql_elm(a_type) qr(a_type) 12 | 13 | /* List functions. */ 14 | #define ql_new(a_head) do { \ 15 | (a_head)->qlh_first = NULL; \ 16 | } while (0) 17 | 18 | #define ql_elm_new(a_elm, a_field) qr_new((a_elm), a_field) 19 | 20 | #define ql_first(a_head) ((a_head)->qlh_first) 21 | 22 | #define ql_last(a_head, a_field) \ 23 | ((ql_first(a_head) != NULL) \ 24 | ? qr_prev(ql_first(a_head), a_field) : NULL) 25 | 26 | #define ql_next(a_head, a_elm, a_field) \ 27 | ((ql_last(a_head, a_field) != (a_elm)) \ 28 | ? qr_next((a_elm), a_field) : NULL) 29 | 30 | #define ql_prev(a_head, a_elm, a_field) \ 31 | ((ql_first(a_head) != (a_elm)) ? qr_prev((a_elm), a_field) \ 32 | : NULL) 33 | 34 | #define ql_before_insert(a_head, a_qlelm, a_elm, a_field) do { \ 35 | qr_before_insert((a_qlelm), (a_elm), a_field); \ 36 | if (ql_first(a_head) == (a_qlelm)) { \ 37 | ql_first(a_head) = (a_elm); \ 38 | } \ 39 | } while (0) 40 | 41 | #define ql_after_insert(a_qlelm, a_elm, a_field) \ 42 | qr_after_insert((a_qlelm), (a_elm), a_field) 43 | 44 | #define ql_head_insert(a_head, a_elm, a_field) do { \ 45 | if (ql_first(a_head) != NULL) { \ 46 | qr_before_insert(ql_first(a_head), (a_elm), a_field); \ 47 | } \ 48 | ql_first(a_head) = (a_elm); \ 49 | } while (0) 50 | 51 | #define ql_tail_insert(a_head, a_elm, a_field) do { \ 52 | if (ql_first(a_head) != NULL) { \ 53 | qr_before_insert(ql_first(a_head), (a_elm), a_field); \ 54 | } \ 55 | ql_first(a_head) = qr_next((a_elm), a_field); \ 56 | } while (0) 57 | 58 | #define ql_remove(a_head, a_elm, a_field) do { \ 59 | if (ql_first(a_head) == (a_elm)) { \ 60 | ql_first(a_head) = qr_next(ql_first(a_head), a_field); \ 61 | } \ 62 | if (ql_first(a_head) != (a_elm)) { \ 63 | qr_remove((a_elm), a_field); \ 64 | } else { \ 65 | ql_first(a_head) = NULL; \ 66 | } \ 67 | } while (0) 68 | 69 | #define ql_head_remove(a_head, a_type, a_field) do { \ 70 | a_type *t = ql_first(a_head); \ 71 | ql_remove((a_head), t, a_field); \ 72 | } while (0) 73 | 74 | #define ql_tail_remove(a_head, a_type, a_field) do { \ 75 | a_type *t = ql_last(a_head, a_field); \ 76 | ql_remove((a_head), t, a_field); \ 77 | } while (0) 78 | 79 | #define ql_foreach(a_var, a_head, a_field) \ 80 | qr_foreach((a_var), ql_first(a_head), a_field) 81 | 82 | #define ql_reverse_foreach(a_var, a_head, a_field) \ 83 | qr_reverse_foreach((a_var), ql_first(a_head), a_field) 84 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/include/jemalloc/internal/qr.h: -------------------------------------------------------------------------------- 1 | /* Ring definitions. */ 2 | #define qr(a_type) \ 3 | struct { \ 4 | a_type *qre_next; \ 5 | a_type *qre_prev; \ 6 | } 7 | 8 | /* Ring functions. */ 9 | #define qr_new(a_qr, a_field) do { \ 10 | (a_qr)->a_field.qre_next = (a_qr); \ 11 | (a_qr)->a_field.qre_prev = (a_qr); \ 12 | } while (0) 13 | 14 | #define qr_next(a_qr, a_field) ((a_qr)->a_field.qre_next) 15 | 16 | #define qr_prev(a_qr, a_field) ((a_qr)->a_field.qre_prev) 17 | 18 | #define qr_before_insert(a_qrelm, a_qr, a_field) do { \ 19 | (a_qr)->a_field.qre_prev = (a_qrelm)->a_field.qre_prev; \ 20 | (a_qr)->a_field.qre_next = (a_qrelm); \ 21 | (a_qr)->a_field.qre_prev->a_field.qre_next = (a_qr); \ 22 | (a_qrelm)->a_field.qre_prev = (a_qr); \ 23 | } while (0) 24 | 25 | #define qr_after_insert(a_qrelm, a_qr, a_field) \ 26 | do \ 27 | { \ 28 | (a_qr)->a_field.qre_next = (a_qrelm)->a_field.qre_next; \ 29 | (a_qr)->a_field.qre_prev = (a_qrelm); \ 30 | (a_qr)->a_field.qre_next->a_field.qre_prev = (a_qr); \ 31 | (a_qrelm)->a_field.qre_next = (a_qr); \ 32 | } while (0) 33 | 34 | #define qr_meld(a_qr_a, a_qr_b, a_field) do { \ 35 | void *t; \ 36 | (a_qr_a)->a_field.qre_prev->a_field.qre_next = (a_qr_b); \ 37 | (a_qr_b)->a_field.qre_prev->a_field.qre_next = (a_qr_a); \ 38 | t = (a_qr_a)->a_field.qre_prev; \ 39 | (a_qr_a)->a_field.qre_prev = (a_qr_b)->a_field.qre_prev; \ 40 | (a_qr_b)->a_field.qre_prev = t; \ 41 | } while (0) 42 | 43 | /* qr_meld() and qr_split() are functionally equivalent, so there's no need to 44 | * have two copies of the code. */ 45 | #define qr_split(a_qr_a, a_qr_b, a_field) \ 46 | qr_meld((a_qr_a), (a_qr_b), a_field) 47 | 48 | #define qr_remove(a_qr, a_field) do { \ 49 | (a_qr)->a_field.qre_prev->a_field.qre_next \ 50 | = (a_qr)->a_field.qre_next; \ 51 | (a_qr)->a_field.qre_next->a_field.qre_prev \ 52 | = (a_qr)->a_field.qre_prev; \ 53 | (a_qr)->a_field.qre_next = (a_qr); \ 54 | (a_qr)->a_field.qre_prev = (a_qr); \ 55 | } while (0) 56 | 57 | #define qr_foreach(var, a_qr, a_field) \ 58 | for ((var) = (a_qr); \ 59 | (var) != NULL; \ 60 | (var) = (((var)->a_field.qre_next != (a_qr)) \ 61 | ? (var)->a_field.qre_next : NULL)) 62 | 63 | #define qr_reverse_foreach(var, a_qr, a_field) \ 64 | for ((var) = ((a_qr) != NULL) ? qr_prev(a_qr, a_field) : NULL; \ 65 | (var) != NULL; \ 66 | (var) = (((var) != (a_qr)) \ 67 | ? (var)->a_field.qre_prev : NULL)) 68 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/include/jemalloc/internal/quarantine.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************/ 2 | #ifdef JEMALLOC_H_TYPES 3 | 4 | typedef struct quarantine_obj_s quarantine_obj_t; 5 | typedef struct quarantine_s quarantine_t; 6 | 7 | /* Default per thread quarantine size if valgrind is enabled. */ 8 | #define JEMALLOC_VALGRIND_QUARANTINE_DEFAULT (ZU(1) << 24) 9 | 10 | #endif /* JEMALLOC_H_TYPES */ 11 | /******************************************************************************/ 12 | #ifdef JEMALLOC_H_STRUCTS 13 | 14 | struct quarantine_obj_s { 15 | void *ptr; 16 | size_t usize; 17 | }; 18 | 19 | struct quarantine_s { 20 | size_t curbytes; 21 | size_t curobjs; 22 | size_t first; 23 | #define LG_MAXOBJS_INIT 10 24 | size_t lg_maxobjs; 25 | quarantine_obj_t objs[1]; /* Dynamically sized ring buffer. */ 26 | }; 27 | 28 | #endif /* JEMALLOC_H_STRUCTS */ 29 | /******************************************************************************/ 30 | #ifdef JEMALLOC_H_EXTERNS 31 | 32 | quarantine_t *quarantine_init(size_t lg_maxobjs); 33 | void quarantine(void *ptr); 34 | void quarantine_cleanup(void *arg); 35 | bool quarantine_boot(void); 36 | 37 | #endif /* JEMALLOC_H_EXTERNS */ 38 | /******************************************************************************/ 39 | #ifdef JEMALLOC_H_INLINES 40 | 41 | #ifndef JEMALLOC_ENABLE_INLINE 42 | malloc_tsd_protos(JEMALLOC_ATTR(unused), quarantine, quarantine_t *) 43 | 44 | void quarantine_alloc_hook(void); 45 | #endif 46 | 47 | #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_QUARANTINE_C_)) 48 | malloc_tsd_externs(quarantine, quarantine_t *) 49 | malloc_tsd_funcs(JEMALLOC_ALWAYS_INLINE, quarantine, quarantine_t *, NULL, 50 | quarantine_cleanup) 51 | 52 | JEMALLOC_ALWAYS_INLINE void 53 | quarantine_alloc_hook(void) 54 | { 55 | quarantine_t *quarantine; 56 | 57 | assert(config_fill && opt_quarantine); 58 | 59 | quarantine = *quarantine_tsd_get(); 60 | if (quarantine == NULL) 61 | quarantine_init(LG_MAXOBJS_INIT); 62 | } 63 | #endif 64 | 65 | #endif /* JEMALLOC_H_INLINES */ 66 | /******************************************************************************/ 67 | 68 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/include/msvc_compat/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef stdbool_h 2 | #define stdbool_h 3 | 4 | #include 5 | 6 | /* MSVC doesn't define _Bool or bool in C, but does have BOOL */ 7 | /* Note this doesn't pass autoconf's test because (bool) 0.5 != true */ 8 | typedef BOOL _Bool; 9 | 10 | #define bool _Bool 11 | #define true 1 12 | #define false 0 13 | 14 | #define __bool_true_false_are_defined 1 15 | 16 | #endif /* stdbool_h */ 17 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/include/msvc_compat/strings.h: -------------------------------------------------------------------------------- 1 | #ifndef strings_h 2 | #define strings_h 3 | 4 | /* MSVC doesn't define ffs/ffsl. This dummy strings.h header is provided 5 | * for both */ 6 | #include 7 | #pragma intrinsic(_BitScanForward) 8 | static __forceinline int ffsl(long x) 9 | { 10 | unsigned long i; 11 | 12 | if (_BitScanForward(&i, x)) 13 | return (i + 1); 14 | return (0); 15 | } 16 | 17 | static __forceinline int ffs(int x) 18 | { 19 | 20 | return (ffsl(x)); 21 | } 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/src/atomic.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_ATOMIC_C_ 2 | #include "jemalloc/internal/jemalloc_internal.h" 3 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/src/bitmap.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_BITMAP_C_ 2 | #include "jemalloc/internal/jemalloc_internal.h" 3 | 4 | /******************************************************************************/ 5 | /* Function prototypes for non-inline static functions. */ 6 | 7 | static size_t bits2groups(size_t nbits); 8 | 9 | /******************************************************************************/ 10 | 11 | static size_t 12 | bits2groups(size_t nbits) 13 | { 14 | 15 | return ((nbits >> LG_BITMAP_GROUP_NBITS) + 16 | !!(nbits & BITMAP_GROUP_NBITS_MASK)); 17 | } 18 | 19 | void 20 | bitmap_info_init(bitmap_info_t *binfo, size_t nbits) 21 | { 22 | unsigned i; 23 | size_t group_count; 24 | 25 | assert(nbits > 0); 26 | assert(nbits <= (ZU(1) << LG_BITMAP_MAXBITS)); 27 | 28 | /* 29 | * Compute the number of groups necessary to store nbits bits, and 30 | * progressively work upward through the levels until reaching a level 31 | * that requires only one group. 32 | */ 33 | binfo->levels[0].group_offset = 0; 34 | group_count = bits2groups(nbits); 35 | for (i = 1; group_count > 1; i++) { 36 | assert(i < BITMAP_MAX_LEVELS); 37 | binfo->levels[i].group_offset = binfo->levels[i-1].group_offset 38 | + group_count; 39 | group_count = bits2groups(group_count); 40 | } 41 | binfo->levels[i].group_offset = binfo->levels[i-1].group_offset 42 | + group_count; 43 | binfo->nlevels = i; 44 | binfo->nbits = nbits; 45 | } 46 | 47 | size_t 48 | bitmap_info_ngroups(const bitmap_info_t *binfo) 49 | { 50 | 51 | return (binfo->levels[binfo->nlevels].group_offset << LG_SIZEOF_BITMAP); 52 | } 53 | 54 | size_t 55 | bitmap_size(size_t nbits) 56 | { 57 | bitmap_info_t binfo; 58 | 59 | bitmap_info_init(&binfo, nbits); 60 | return (bitmap_info_ngroups(&binfo)); 61 | } 62 | 63 | void 64 | bitmap_init(bitmap_t *bitmap, const bitmap_info_t *binfo) 65 | { 66 | size_t extra; 67 | unsigned i; 68 | 69 | /* 70 | * Bits are actually inverted with regard to the external bitmap 71 | * interface, so the bitmap starts out with all 1 bits, except for 72 | * trailing unused bits (if any). Note that each group uses bit 0 to 73 | * correspond to the first logical bit in the group, so extra bits 74 | * are the most significant bits of the last group. 75 | */ 76 | memset(bitmap, 0xffU, binfo->levels[binfo->nlevels].group_offset << 77 | LG_SIZEOF_BITMAP); 78 | extra = (BITMAP_GROUP_NBITS - (binfo->nbits & BITMAP_GROUP_NBITS_MASK)) 79 | & BITMAP_GROUP_NBITS_MASK; 80 | if (extra != 0) 81 | bitmap[binfo->levels[1].group_offset - 1] >>= extra; 82 | for (i = 1; i < binfo->nlevels; i++) { 83 | size_t group_count = binfo->levels[i].group_offset - 84 | binfo->levels[i-1].group_offset; 85 | extra = (BITMAP_GROUP_NBITS - (group_count & 86 | BITMAP_GROUP_NBITS_MASK)) & BITMAP_GROUP_NBITS_MASK; 87 | if (extra != 0) 88 | bitmap[binfo->levels[i+1].group_offset - 1] >>= extra; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/src/extent.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_EXTENT_C_ 2 | #include "jemalloc/internal/jemalloc_internal.h" 3 | 4 | /******************************************************************************/ 5 | 6 | static inline int 7 | extent_szad_comp(extent_node_t *a, extent_node_t *b) 8 | { 9 | int ret; 10 | size_t a_size = a->size; 11 | size_t b_size = b->size; 12 | 13 | ret = (a_size > b_size) - (a_size < b_size); 14 | if (ret == 0) { 15 | uintptr_t a_addr = (uintptr_t)a->addr; 16 | uintptr_t b_addr = (uintptr_t)b->addr; 17 | 18 | ret = (a_addr > b_addr) - (a_addr < b_addr); 19 | } 20 | 21 | return (ret); 22 | } 23 | 24 | /* Generate red-black tree functions. */ 25 | rb_gen(, extent_tree_szad_, extent_tree_t, extent_node_t, link_szad, 26 | extent_szad_comp) 27 | 28 | static inline int 29 | extent_ad_comp(extent_node_t *a, extent_node_t *b) 30 | { 31 | uintptr_t a_addr = (uintptr_t)a->addr; 32 | uintptr_t b_addr = (uintptr_t)b->addr; 33 | 34 | return ((a_addr > b_addr) - (a_addr < b_addr)); 35 | } 36 | 37 | /* Generate red-black tree functions. */ 38 | rb_gen(, extent_tree_ad_, extent_tree_t, extent_node_t, link_ad, 39 | extent_ad_comp) 40 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/src/hash.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_HASH_C_ 2 | #include "jemalloc/internal/jemalloc_internal.h" 3 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/src/mb.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_MB_C_ 2 | #include "jemalloc/internal/jemalloc_internal.h" 3 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/src/rtree.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_RTREE_C_ 2 | #include "jemalloc/internal/jemalloc_internal.h" 3 | 4 | rtree_t * 5 | rtree_new(unsigned bits) 6 | { 7 | rtree_t *ret; 8 | unsigned bits_per_level, height, i; 9 | 10 | bits_per_level = ffs(pow2_ceil((RTREE_NODESIZE / sizeof(void *)))) - 1; 11 | height = bits / bits_per_level; 12 | if (height * bits_per_level != bits) 13 | height++; 14 | assert(height * bits_per_level >= bits); 15 | 16 | ret = (rtree_t*)base_alloc(offsetof(rtree_t, level2bits) + 17 | (sizeof(unsigned) * height)); 18 | if (ret == NULL) 19 | return (NULL); 20 | memset(ret, 0, offsetof(rtree_t, level2bits) + (sizeof(unsigned) * 21 | height)); 22 | 23 | if (malloc_mutex_init(&ret->mutex)) { 24 | /* Leak the rtree. */ 25 | return (NULL); 26 | } 27 | ret->height = height; 28 | if (bits_per_level * height > bits) 29 | ret->level2bits[0] = bits % bits_per_level; 30 | else 31 | ret->level2bits[0] = bits_per_level; 32 | for (i = 1; i < height; i++) 33 | ret->level2bits[i] = bits_per_level; 34 | 35 | ret->root = (void**)base_alloc(sizeof(void *) << ret->level2bits[0]); 36 | if (ret->root == NULL) { 37 | /* 38 | * We leak the rtree here, since there's no generic base 39 | * deallocation. 40 | */ 41 | return (NULL); 42 | } 43 | memset(ret->root, 0, sizeof(void *) << ret->level2bits[0]); 44 | 45 | return (ret); 46 | } 47 | 48 | void 49 | rtree_prefork(rtree_t *rtree) 50 | { 51 | 52 | malloc_mutex_prefork(&rtree->mutex); 53 | } 54 | 55 | void 56 | rtree_postfork_parent(rtree_t *rtree) 57 | { 58 | 59 | malloc_mutex_postfork_parent(&rtree->mutex); 60 | } 61 | 62 | void 63 | rtree_postfork_child(rtree_t *rtree) 64 | { 65 | 66 | malloc_mutex_postfork_child(&rtree->mutex); 67 | } 68 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/src/tsd.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_TSD_C_ 2 | #include "jemalloc/internal/jemalloc_internal.h" 3 | 4 | /******************************************************************************/ 5 | /* Data. */ 6 | 7 | static unsigned ncleanups; 8 | static malloc_tsd_cleanup_t cleanups[MALLOC_TSD_CLEANUPS_MAX]; 9 | 10 | /******************************************************************************/ 11 | 12 | void * 13 | malloc_tsd_malloc(size_t size) 14 | { 15 | 16 | /* Avoid choose_arena() in order to dodge bootstrapping issues. */ 17 | return (arena_malloc(arenas[0], size, false, false)); 18 | } 19 | 20 | void 21 | malloc_tsd_dalloc(void *wrapper) 22 | { 23 | 24 | idalloc(wrapper); 25 | } 26 | 27 | void 28 | malloc_tsd_no_cleanup(void *arg) 29 | { 30 | 31 | not_reached(); 32 | } 33 | 34 | #if defined(JEMALLOC_MALLOC_THREAD_CLEANUP) || defined(_WIN32) 35 | #ifndef _WIN32 36 | JEMALLOC_EXPORT 37 | #endif 38 | void 39 | _malloc_thread_cleanup(void) 40 | { 41 | bool pending[MALLOC_TSD_CLEANUPS_MAX], again; 42 | unsigned i; 43 | 44 | for (i = 0; i < ncleanups; i++) 45 | pending[i] = true; 46 | 47 | do { 48 | again = false; 49 | for (i = 0; i < ncleanups; i++) { 50 | if (pending[i]) { 51 | pending[i] = cleanups[i](); 52 | if (pending[i]) 53 | again = true; 54 | } 55 | } 56 | } while (again); 57 | } 58 | #endif 59 | 60 | void 61 | malloc_tsd_cleanup_register(bool (*f)(void)) 62 | { 63 | 64 | assert(ncleanups < MALLOC_TSD_CLEANUPS_MAX); 65 | cleanups[ncleanups] = f; 66 | ncleanups++; 67 | } 68 | 69 | void 70 | malloc_tsd_boot(void) 71 | { 72 | 73 | ncleanups = 0; 74 | } 75 | 76 | #ifdef _WIN32 77 | static BOOL WINAPI 78 | _tls_callback(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) 79 | { 80 | 81 | switch (fdwReason) { 82 | #ifdef JEMALLOC_LAZY_LOCK 83 | case DLL_THREAD_ATTACH: 84 | isthreaded = true; 85 | break; 86 | #endif 87 | case DLL_THREAD_DETACH: 88 | _malloc_thread_cleanup(); 89 | break; 90 | default: 91 | break; 92 | } 93 | return (true); 94 | } 95 | 96 | #ifdef _MSC_VER 97 | # ifdef _M_IX86 98 | # pragma comment(linker, "/INCLUDE:__tls_used") 99 | # else 100 | # pragma comment(linker, "/INCLUDE:_tls_used") 101 | # endif 102 | # pragma section(".CRT$XLY",long,read) 103 | #endif 104 | JEMALLOC_SECTION(".CRT$XLY") JEMALLOC_ATTR(used) 105 | static const BOOL (WINAPI *tls_callback)(HINSTANCE hinstDLL, 106 | DWORD fdwReason, LPVOID lpvReserved) = _tls_callback; 107 | #endif 108 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/test/ALLOCM_ARENA.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_MANGLE 2 | #include "jemalloc_test.h" 3 | 4 | #define NTHREADS 10 5 | 6 | void * 7 | je_thread_start(void *arg) 8 | { 9 | unsigned thread_ind = (unsigned)(uintptr_t)arg; 10 | unsigned arena_ind; 11 | int r; 12 | void *p; 13 | size_t rsz, sz; 14 | 15 | sz = sizeof(arena_ind); 16 | if (mallctl("arenas.extend", &arena_ind, &sz, NULL, 0) 17 | != 0) { 18 | malloc_printf("Error in arenas.extend\n"); 19 | abort(); 20 | } 21 | 22 | if (thread_ind % 4 != 3) { 23 | size_t mib[3]; 24 | size_t miblen = sizeof(mib) / sizeof(size_t); 25 | const char *dss_precs[] = {"disabled", "primary", "secondary"}; 26 | const char *dss = dss_precs[thread_ind % 4]; 27 | if (mallctlnametomib("arena.0.dss", mib, &miblen) != 0) { 28 | malloc_printf("Error in mallctlnametomib()\n"); 29 | abort(); 30 | } 31 | mib[1] = arena_ind; 32 | if (mallctlbymib(mib, miblen, NULL, NULL, (void *)&dss, 33 | sizeof(const char *))) { 34 | malloc_printf("Error in mallctlbymib()\n"); 35 | abort(); 36 | } 37 | } 38 | 39 | r = allocm(&p, &rsz, 1, ALLOCM_ARENA(arena_ind)); 40 | if (r != ALLOCM_SUCCESS) { 41 | malloc_printf("Unexpected allocm() error\n"); 42 | abort(); 43 | } 44 | dallocm(p, 0); 45 | 46 | return (NULL); 47 | } 48 | 49 | int 50 | main(void) 51 | { 52 | je_thread_t threads[NTHREADS]; 53 | unsigned i; 54 | 55 | malloc_printf("Test begin\n"); 56 | 57 | for (i = 0; i < NTHREADS; i++) { 58 | je_thread_create(&threads[i], je_thread_start, 59 | (void *)(uintptr_t)i); 60 | } 61 | 62 | for (i = 0; i < NTHREADS; i++) 63 | je_thread_join(threads[i], NULL); 64 | 65 | malloc_printf("Test end\n"); 66 | return (0); 67 | } 68 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/test/ALLOCM_ARENA.exp: -------------------------------------------------------------------------------- 1 | Test begin 2 | Test end 3 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/test/aligned_alloc.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_MANGLE 2 | #include "jemalloc_test.h" 3 | 4 | #define CHUNK 0x400000 5 | /* #define MAXALIGN ((size_t)UINT64_C(0x80000000000)) */ 6 | #define MAXALIGN ((size_t)0x2000000LU) 7 | #define NITER 4 8 | 9 | int 10 | main(void) 11 | { 12 | size_t alignment, size, total; 13 | unsigned i; 14 | void *p, *ps[NITER]; 15 | 16 | malloc_printf("Test begin\n"); 17 | 18 | /* Test error conditions. */ 19 | alignment = 0; 20 | set_errno(0); 21 | p = aligned_alloc(alignment, 1); 22 | if (p != NULL || get_errno() != EINVAL) { 23 | malloc_printf( 24 | "Expected error for invalid alignment %zu\n", alignment); 25 | } 26 | 27 | for (alignment = sizeof(size_t); alignment < MAXALIGN; 28 | alignment <<= 1) { 29 | set_errno(0); 30 | p = aligned_alloc(alignment + 1, 1); 31 | if (p != NULL || get_errno() != EINVAL) { 32 | malloc_printf( 33 | "Expected error for invalid alignment %zu\n", 34 | alignment + 1); 35 | } 36 | } 37 | 38 | #if LG_SIZEOF_PTR == 3 39 | alignment = UINT64_C(0x8000000000000000); 40 | size = UINT64_C(0x8000000000000000); 41 | #else 42 | alignment = 0x80000000LU; 43 | size = 0x80000000LU; 44 | #endif 45 | set_errno(0); 46 | p = aligned_alloc(alignment, size); 47 | if (p != NULL || get_errno() != ENOMEM) { 48 | malloc_printf( 49 | "Expected error for aligned_alloc(%zu, %zu)\n", 50 | alignment, size); 51 | } 52 | 53 | #if LG_SIZEOF_PTR == 3 54 | alignment = UINT64_C(0x4000000000000000); 55 | size = UINT64_C(0x8400000000000001); 56 | #else 57 | alignment = 0x40000000LU; 58 | size = 0x84000001LU; 59 | #endif 60 | set_errno(0); 61 | p = aligned_alloc(alignment, size); 62 | if (p != NULL || get_errno() != ENOMEM) { 63 | malloc_printf( 64 | "Expected error for aligned_alloc(%zu, %zu)\n", 65 | alignment, size); 66 | } 67 | 68 | alignment = 0x10LU; 69 | #if LG_SIZEOF_PTR == 3 70 | size = UINT64_C(0xfffffffffffffff0); 71 | #else 72 | size = 0xfffffff0LU; 73 | #endif 74 | set_errno(0); 75 | p = aligned_alloc(alignment, size); 76 | if (p != NULL || get_errno() != ENOMEM) { 77 | malloc_printf( 78 | "Expected error for aligned_alloc(&p, %zu, %zu)\n", 79 | alignment, size); 80 | } 81 | 82 | for (i = 0; i < NITER; i++) 83 | ps[i] = NULL; 84 | 85 | for (alignment = 8; 86 | alignment <= MAXALIGN; 87 | alignment <<= 1) { 88 | total = 0; 89 | malloc_printf("Alignment: %zu\n", alignment); 90 | for (size = 1; 91 | size < 3 * alignment && size < (1U << 31); 92 | size += (alignment >> (LG_SIZEOF_PTR-1)) - 1) { 93 | for (i = 0; i < NITER; i++) { 94 | ps[i] = aligned_alloc(alignment, size); 95 | if (ps[i] == NULL) { 96 | char buf[BUFERROR_BUF]; 97 | 98 | buferror(buf, sizeof(buf)); 99 | malloc_printf( 100 | "Error for size %zu (%#zx): %s\n", 101 | size, size, buf); 102 | exit(1); 103 | } 104 | total += malloc_usable_size(ps[i]); 105 | if (total >= (MAXALIGN << 1)) 106 | break; 107 | } 108 | for (i = 0; i < NITER; i++) { 109 | if (ps[i] != NULL) { 110 | free(ps[i]); 111 | ps[i] = NULL; 112 | } 113 | } 114 | } 115 | } 116 | 117 | malloc_printf("Test end\n"); 118 | return (0); 119 | } 120 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/test/aligned_alloc.exp: -------------------------------------------------------------------------------- 1 | Test begin 2 | Alignment: 8 3 | Alignment: 16 4 | Alignment: 32 5 | Alignment: 64 6 | Alignment: 128 7 | Alignment: 256 8 | Alignment: 512 9 | Alignment: 1024 10 | Alignment: 2048 11 | Alignment: 4096 12 | Alignment: 8192 13 | Alignment: 16384 14 | Alignment: 32768 15 | Alignment: 65536 16 | Alignment: 131072 17 | Alignment: 262144 18 | Alignment: 524288 19 | Alignment: 1048576 20 | Alignment: 2097152 21 | Alignment: 4194304 22 | Alignment: 8388608 23 | Alignment: 16777216 24 | Alignment: 33554432 25 | Test end 26 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/test/allocated.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_MANGLE 2 | #include "jemalloc_test.h" 3 | 4 | void * 5 | je_thread_start(void *arg) 6 | { 7 | int err; 8 | void *p; 9 | uint64_t a0, a1, d0, d1; 10 | uint64_t *ap0, *ap1, *dp0, *dp1; 11 | size_t sz, usize; 12 | 13 | sz = sizeof(a0); 14 | if ((err = mallctl("thread.allocated", &a0, &sz, NULL, 0))) { 15 | if (err == ENOENT) { 16 | #ifdef JEMALLOC_STATS 17 | assert(false); 18 | #endif 19 | goto label_return; 20 | } 21 | malloc_printf("%s(): Error in mallctl(): %s\n", __func__, 22 | strerror(err)); 23 | exit(1); 24 | } 25 | sz = sizeof(ap0); 26 | if ((err = mallctl("thread.allocatedp", &ap0, &sz, NULL, 0))) { 27 | if (err == ENOENT) { 28 | #ifdef JEMALLOC_STATS 29 | assert(false); 30 | #endif 31 | goto label_return; 32 | } 33 | malloc_printf("%s(): Error in mallctl(): %s\n", __func__, 34 | strerror(err)); 35 | exit(1); 36 | } 37 | assert(*ap0 == a0); 38 | 39 | sz = sizeof(d0); 40 | if ((err = mallctl("thread.deallocated", &d0, &sz, NULL, 0))) { 41 | if (err == ENOENT) { 42 | #ifdef JEMALLOC_STATS 43 | assert(false); 44 | #endif 45 | goto label_return; 46 | } 47 | malloc_printf("%s(): Error in mallctl(): %s\n", __func__, 48 | strerror(err)); 49 | exit(1); 50 | } 51 | sz = sizeof(dp0); 52 | if ((err = mallctl("thread.deallocatedp", &dp0, &sz, NULL, 0))) { 53 | if (err == ENOENT) { 54 | #ifdef JEMALLOC_STATS 55 | assert(false); 56 | #endif 57 | goto label_return; 58 | } 59 | malloc_printf("%s(): Error in mallctl(): %s\n", __func__, 60 | strerror(err)); 61 | exit(1); 62 | } 63 | assert(*dp0 == d0); 64 | 65 | p = malloc(1); 66 | if (p == NULL) { 67 | malloc_printf("%s(): Error in malloc()\n", __func__); 68 | exit(1); 69 | } 70 | 71 | sz = sizeof(a1); 72 | mallctl("thread.allocated", &a1, &sz, NULL, 0); 73 | sz = sizeof(ap1); 74 | mallctl("thread.allocatedp", &ap1, &sz, NULL, 0); 75 | assert(*ap1 == a1); 76 | assert(ap0 == ap1); 77 | 78 | usize = malloc_usable_size(p); 79 | assert(a0 + usize <= a1); 80 | 81 | free(p); 82 | 83 | sz = sizeof(d1); 84 | mallctl("thread.deallocated", &d1, &sz, NULL, 0); 85 | sz = sizeof(dp1); 86 | mallctl("thread.deallocatedp", &dp1, &sz, NULL, 0); 87 | assert(*dp1 == d1); 88 | assert(dp0 == dp1); 89 | 90 | assert(d0 + usize <= d1); 91 | 92 | label_return: 93 | return (NULL); 94 | } 95 | 96 | int 97 | main(void) 98 | { 99 | int ret = 0; 100 | je_thread_t thread; 101 | 102 | malloc_printf("Test begin\n"); 103 | 104 | je_thread_start(NULL); 105 | 106 | je_thread_create(&thread, je_thread_start, NULL); 107 | je_thread_join(thread, (void *)&ret); 108 | 109 | je_thread_start(NULL); 110 | 111 | je_thread_create(&thread, je_thread_start, NULL); 112 | je_thread_join(thread, (void *)&ret); 113 | 114 | je_thread_start(NULL); 115 | 116 | malloc_printf("Test end\n"); 117 | return (ret); 118 | } 119 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/test/allocated.exp: -------------------------------------------------------------------------------- 1 | Test begin 2 | Test end 3 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/test/allocm.exp: -------------------------------------------------------------------------------- 1 | Test begin 2 | Alignment: 8 3 | Alignment: 16 4 | Alignment: 32 5 | Alignment: 64 6 | Alignment: 128 7 | Alignment: 256 8 | Alignment: 512 9 | Alignment: 1024 10 | Alignment: 2048 11 | Alignment: 4096 12 | Alignment: 8192 13 | Alignment: 16384 14 | Alignment: 32768 15 | Alignment: 65536 16 | Alignment: 131072 17 | Alignment: 262144 18 | Alignment: 524288 19 | Alignment: 1048576 20 | Alignment: 2097152 21 | Alignment: 4194304 22 | Alignment: 8388608 23 | Alignment: 16777216 24 | Alignment: 33554432 25 | Test end 26 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/test/bitmap.exp: -------------------------------------------------------------------------------- 1 | Test begin 2 | Test end 3 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/test/jemalloc_test.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * This header should be included by tests, rather than directly including 3 | * jemalloc/jemalloc.h, because --with-install-suffix may cause the header to 4 | * have a different name. 5 | */ 6 | #include "jemalloc/jemalloc@install_suffix@.h" 7 | #include "jemalloc/internal/jemalloc_internal.h" 8 | 9 | /* Abstraction layer for threading in tests */ 10 | #ifdef _WIN32 11 | #include 12 | 13 | typedef HANDLE je_thread_t; 14 | 15 | void 16 | je_thread_create(je_thread_t *thread, void *(*proc)(void *), void *arg) 17 | { 18 | LPTHREAD_START_ROUTINE routine = (LPTHREAD_START_ROUTINE)proc; 19 | *thread = CreateThread(NULL, 0, routine, arg, 0, NULL); 20 | if (*thread == NULL) { 21 | malloc_printf("Error in CreateThread()\n"); 22 | exit(1); 23 | } 24 | } 25 | 26 | void 27 | je_thread_join(je_thread_t thread, void **ret) 28 | { 29 | WaitForSingleObject(thread, INFINITE); 30 | } 31 | 32 | #else 33 | #include 34 | 35 | typedef pthread_t je_thread_t; 36 | 37 | void 38 | je_thread_create(je_thread_t *thread, void *(*proc)(void *), void *arg) 39 | { 40 | 41 | if (pthread_create(thread, NULL, proc, arg) != 0) { 42 | malloc_printf("Error in pthread_create()\n"); 43 | exit(1); 44 | } 45 | } 46 | 47 | void 48 | je_thread_join(je_thread_t thread, void **ret) 49 | { 50 | 51 | pthread_join(thread, ret); 52 | } 53 | #endif 54 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/test/mremap.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_MANGLE 2 | #include "jemalloc_test.h" 3 | 4 | int 5 | main(void) 6 | { 7 | int ret, err; 8 | size_t sz, lg_chunk, chunksize, i; 9 | char *p, *q; 10 | 11 | malloc_printf("Test begin\n"); 12 | 13 | sz = sizeof(lg_chunk); 14 | if ((err = mallctl("opt.lg_chunk", &lg_chunk, &sz, NULL, 0))) { 15 | assert(err != ENOENT); 16 | malloc_printf("%s(): Error in mallctl(): %s\n", __func__, 17 | strerror(err)); 18 | ret = 1; 19 | goto label_return; 20 | } 21 | chunksize = ((size_t)1U) << lg_chunk; 22 | 23 | p = (char *)malloc(chunksize); 24 | if (p == NULL) { 25 | malloc_printf("malloc(%zu) --> %p\n", chunksize, p); 26 | ret = 1; 27 | goto label_return; 28 | } 29 | memset(p, 'a', chunksize); 30 | 31 | q = (char *)realloc(p, chunksize * 2); 32 | if (q == NULL) { 33 | malloc_printf("realloc(%p, %zu) --> %p\n", p, chunksize * 2, 34 | q); 35 | ret = 1; 36 | goto label_return; 37 | } 38 | for (i = 0; i < chunksize; i++) { 39 | assert(q[i] == 'a'); 40 | } 41 | 42 | p = q; 43 | 44 | q = (char *)realloc(p, chunksize); 45 | if (q == NULL) { 46 | malloc_printf("realloc(%p, %zu) --> %p\n", p, chunksize, q); 47 | ret = 1; 48 | goto label_return; 49 | } 50 | for (i = 0; i < chunksize; i++) { 51 | assert(q[i] == 'a'); 52 | } 53 | 54 | free(q); 55 | 56 | ret = 0; 57 | label_return: 58 | malloc_printf("Test end\n"); 59 | return (ret); 60 | } 61 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/test/mremap.exp: -------------------------------------------------------------------------------- 1 | Test begin 2 | Test end 3 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/test/posix_memalign.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_MANGLE 2 | #include "jemalloc_test.h" 3 | 4 | #define CHUNK 0x400000 5 | /* #define MAXALIGN ((size_t)UINT64_C(0x80000000000)) */ 6 | #define MAXALIGN ((size_t)0x2000000LU) 7 | #define NITER 4 8 | 9 | int 10 | main(void) 11 | { 12 | size_t alignment, size, total; 13 | unsigned i; 14 | int err; 15 | void *p, *ps[NITER]; 16 | 17 | malloc_printf("Test begin\n"); 18 | 19 | /* Test error conditions. */ 20 | for (alignment = 0; alignment < sizeof(void *); alignment++) { 21 | err = posix_memalign(&p, alignment, 1); 22 | if (err != EINVAL) { 23 | malloc_printf( 24 | "Expected error for invalid alignment %zu\n", 25 | alignment); 26 | } 27 | } 28 | 29 | for (alignment = sizeof(size_t); alignment < MAXALIGN; 30 | alignment <<= 1) { 31 | err = posix_memalign(&p, alignment + 1, 1); 32 | if (err == 0) { 33 | malloc_printf( 34 | "Expected error for invalid alignment %zu\n", 35 | alignment + 1); 36 | } 37 | } 38 | 39 | #if LG_SIZEOF_PTR == 3 40 | alignment = UINT64_C(0x8000000000000000); 41 | size = UINT64_C(0x8000000000000000); 42 | #else 43 | alignment = 0x80000000LU; 44 | size = 0x80000000LU; 45 | #endif 46 | err = posix_memalign(&p, alignment, size); 47 | if (err == 0) { 48 | malloc_printf( 49 | "Expected error for posix_memalign(&p, %zu, %zu)\n", 50 | alignment, size); 51 | } 52 | 53 | #if LG_SIZEOF_PTR == 3 54 | alignment = UINT64_C(0x4000000000000000); 55 | size = UINT64_C(0x8400000000000001); 56 | #else 57 | alignment = 0x40000000LU; 58 | size = 0x84000001LU; 59 | #endif 60 | err = posix_memalign(&p, alignment, size); 61 | if (err == 0) { 62 | malloc_printf( 63 | "Expected error for posix_memalign(&p, %zu, %zu)\n", 64 | alignment, size); 65 | } 66 | 67 | alignment = 0x10LU; 68 | #if LG_SIZEOF_PTR == 3 69 | size = UINT64_C(0xfffffffffffffff0); 70 | #else 71 | size = 0xfffffff0LU; 72 | #endif 73 | err = posix_memalign(&p, alignment, size); 74 | if (err == 0) { 75 | malloc_printf( 76 | "Expected error for posix_memalign(&p, %zu, %zu)\n", 77 | alignment, size); 78 | } 79 | 80 | for (i = 0; i < NITER; i++) 81 | ps[i] = NULL; 82 | 83 | for (alignment = 8; 84 | alignment <= MAXALIGN; 85 | alignment <<= 1) { 86 | total = 0; 87 | malloc_printf("Alignment: %zu\n", alignment); 88 | for (size = 1; 89 | size < 3 * alignment && size < (1U << 31); 90 | size += (alignment >> (LG_SIZEOF_PTR-1)) - 1) { 91 | for (i = 0; i < NITER; i++) { 92 | err = posix_memalign(&ps[i], 93 | alignment, size); 94 | if (err) { 95 | malloc_printf( 96 | "Error for size %zu (%#zx): %s\n", 97 | size, size, strerror(err)); 98 | exit(1); 99 | } 100 | total += malloc_usable_size(ps[i]); 101 | if (total >= (MAXALIGN << 1)) 102 | break; 103 | } 104 | for (i = 0; i < NITER; i++) { 105 | if (ps[i] != NULL) { 106 | free(ps[i]); 107 | ps[i] = NULL; 108 | } 109 | } 110 | } 111 | } 112 | 113 | malloc_printf("Test end\n"); 114 | return (0); 115 | } 116 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/test/posix_memalign.exp: -------------------------------------------------------------------------------- 1 | Test begin 2 | Alignment: 8 3 | Alignment: 16 4 | Alignment: 32 5 | Alignment: 64 6 | Alignment: 128 7 | Alignment: 256 8 | Alignment: 512 9 | Alignment: 1024 10 | Alignment: 2048 11 | Alignment: 4096 12 | Alignment: 8192 13 | Alignment: 16384 14 | Alignment: 32768 15 | Alignment: 65536 16 | Alignment: 131072 17 | Alignment: 262144 18 | Alignment: 524288 19 | Alignment: 1048576 20 | Alignment: 2097152 21 | Alignment: 4194304 22 | Alignment: 8388608 23 | Alignment: 16777216 24 | Alignment: 33554432 25 | Test end 26 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/test/rallocm.exp: -------------------------------------------------------------------------------- 1 | Test begin 2 | Test end 3 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/test/thread_arena.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_MANGLE 2 | #include "jemalloc_test.h" 3 | 4 | #define NTHREADS 10 5 | 6 | void * 7 | je_thread_start(void *arg) 8 | { 9 | unsigned main_arena_ind = *(unsigned *)arg; 10 | void *p; 11 | unsigned arena_ind; 12 | size_t size; 13 | int err; 14 | 15 | p = malloc(1); 16 | if (p == NULL) { 17 | malloc_printf("%s(): Error in malloc()\n", __func__); 18 | return (void *)1; 19 | } 20 | free(p); 21 | 22 | size = sizeof(arena_ind); 23 | if ((err = mallctl("thread.arena", &arena_ind, &size, &main_arena_ind, 24 | sizeof(main_arena_ind)))) { 25 | malloc_printf("%s(): Error in mallctl(): %s\n", __func__, 26 | strerror(err)); 27 | return (void *)1; 28 | } 29 | 30 | size = sizeof(arena_ind); 31 | if ((err = mallctl("thread.arena", &arena_ind, &size, NULL, 32 | 0))) { 33 | malloc_printf("%s(): Error in mallctl(): %s\n", __func__, 34 | strerror(err)); 35 | return (void *)1; 36 | } 37 | assert(arena_ind == main_arena_ind); 38 | 39 | return (NULL); 40 | } 41 | 42 | int 43 | main(void) 44 | { 45 | int ret = 0; 46 | void *p; 47 | unsigned arena_ind; 48 | size_t size; 49 | int err; 50 | je_thread_t threads[NTHREADS]; 51 | unsigned i; 52 | 53 | malloc_printf("Test begin\n"); 54 | 55 | p = malloc(1); 56 | if (p == NULL) { 57 | malloc_printf("%s(): Error in malloc()\n", __func__); 58 | ret = 1; 59 | goto label_return; 60 | } 61 | 62 | size = sizeof(arena_ind); 63 | if ((err = mallctl("thread.arena", &arena_ind, &size, NULL, 0))) { 64 | malloc_printf("%s(): Error in mallctl(): %s\n", __func__, 65 | strerror(err)); 66 | ret = 1; 67 | goto label_return; 68 | } 69 | 70 | for (i = 0; i < NTHREADS; i++) { 71 | je_thread_create(&threads[i], je_thread_start, 72 | (void *)&arena_ind); 73 | } 74 | 75 | for (i = 0; i < NTHREADS; i++) 76 | je_thread_join(threads[i], (void *)&ret); 77 | 78 | label_return: 79 | malloc_printf("Test end\n"); 80 | return (ret); 81 | } 82 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/test/thread_arena.exp: -------------------------------------------------------------------------------- 1 | Test begin 2 | Test end 3 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/test/thread_tcache_enabled.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_MANGLE 2 | #include "jemalloc_test.h" 3 | 4 | void * 5 | je_thread_start(void *arg) 6 | { 7 | int err; 8 | size_t sz; 9 | bool e0, e1; 10 | 11 | sz = sizeof(bool); 12 | if ((err = mallctl("thread.tcache.enabled", &e0, &sz, NULL, 0))) { 13 | if (err == ENOENT) { 14 | #ifdef JEMALLOC_TCACHE 15 | assert(false); 16 | #endif 17 | } 18 | goto label_return; 19 | } 20 | 21 | if (e0) { 22 | e1 = false; 23 | assert(mallctl("thread.tcache.enabled", &e0, &sz, &e1, sz) 24 | == 0); 25 | assert(e0); 26 | } 27 | 28 | e1 = true; 29 | assert(mallctl("thread.tcache.enabled", &e0, &sz, &e1, sz) == 0); 30 | assert(e0 == false); 31 | 32 | e1 = true; 33 | assert(mallctl("thread.tcache.enabled", &e0, &sz, &e1, sz) == 0); 34 | assert(e0); 35 | 36 | e1 = false; 37 | assert(mallctl("thread.tcache.enabled", &e0, &sz, &e1, sz) == 0); 38 | assert(e0); 39 | 40 | e1 = false; 41 | assert(mallctl("thread.tcache.enabled", &e0, &sz, &e1, sz) == 0); 42 | assert(e0 == false); 43 | 44 | free(malloc(1)); 45 | e1 = true; 46 | assert(mallctl("thread.tcache.enabled", &e0, &sz, &e1, sz) == 0); 47 | assert(e0 == false); 48 | 49 | free(malloc(1)); 50 | e1 = true; 51 | assert(mallctl("thread.tcache.enabled", &e0, &sz, &e1, sz) == 0); 52 | assert(e0); 53 | 54 | free(malloc(1)); 55 | e1 = false; 56 | assert(mallctl("thread.tcache.enabled", &e0, &sz, &e1, sz) == 0); 57 | assert(e0); 58 | 59 | free(malloc(1)); 60 | e1 = false; 61 | assert(mallctl("thread.tcache.enabled", &e0, &sz, &e1, sz) == 0); 62 | assert(e0 == false); 63 | 64 | free(malloc(1)); 65 | label_return: 66 | return (NULL); 67 | } 68 | 69 | int 70 | main(void) 71 | { 72 | int ret = 0; 73 | je_thread_t thread; 74 | 75 | malloc_printf("Test begin\n"); 76 | 77 | je_thread_start(NULL); 78 | 79 | je_thread_create(&thread, je_thread_start, NULL); 80 | je_thread_join(thread, (void *)&ret); 81 | 82 | je_thread_start(NULL); 83 | 84 | je_thread_create(&thread, je_thread_start, NULL); 85 | je_thread_join(thread, (void *)&ret); 86 | 87 | je_thread_start(NULL); 88 | 89 | malloc_printf("Test end\n"); 90 | return (ret); 91 | } 92 | -------------------------------------------------------------------------------- /deps/jemalloc-3.4.0/test/thread_tcache_enabled.exp: -------------------------------------------------------------------------------- 1 | Test begin 2 | Test end 3 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/Makefile.nmake: -------------------------------------------------------------------------------- 1 | # WATCH OUT! This makefile is a work in progress. It is probably missing 2 | # tons of important things. DO NOT RELY ON IT TO BUILD A GOOD LIBEVENT. 3 | 4 | # Needed for correctness 5 | CFLAGS=/IWIN32-Code /Iinclude /Icompat /DWIN32 /DHAVE_CONFIG_H /I. 6 | 7 | # For optimization and warnings 8 | CFLAGS=$(CFLAGS) /Ox /W3 /wd4996 /nologo 9 | 10 | # XXXX have a debug mode 11 | 12 | LIBFLAGS=/nologo 13 | 14 | CORE_OBJS=event.obj buffer.obj bufferevent.obj bufferevent_sock.obj \ 15 | bufferevent_pair.obj listener.obj evmap.obj log.obj evutil.obj \ 16 | strlcpy.obj signal.obj bufferevent_filter.obj evthread.obj \ 17 | bufferevent_ratelim.obj evutil_rand.obj 18 | WIN_OBJS=win32select.obj evthread_win32.obj buffer_iocp.obj \ 19 | event_iocp.obj bufferevent_async.obj 20 | EXTRA_OBJS=event_tagging.obj http.obj evdns.obj evrpc.obj 21 | 22 | ALL_OBJS=$(CORE_OBJS) $(WIN_OBJS) $(EXTRA_OBJS) 23 | STATIC_LIBS=libevent_core.lib libevent_extras.lib libevent.lib 24 | 25 | 26 | all: static_libs tests 27 | 28 | static_libs: $(STATIC_LIBS) 29 | 30 | libevent_core.lib: $(CORE_OBJS) $(WIN_OBJS) 31 | lib $(LIBFLAGS) $(CORE_OBJS) $(WIN_OBJS) /out:libevent_core.lib 32 | 33 | libevent_extras.lib: $(EXTRA_OBJS) 34 | lib $(LIBFLAGS) $(EXTRA_OBJS) /out:libevent_extras.lib 35 | 36 | libevent.lib: $(CORE_OBJS) $(WIN_OBJS) $(EXTRA_OBJS) 37 | lib $(LIBFLAGS) $(CORE_OBJS) $(EXTRA_OBJS) $(WIN_OBJS) /out:libevent.lib 38 | 39 | clean: 40 | del $(ALL_OBJS) 41 | del $(STATIC_LIBS) 42 | cd test 43 | $(MAKE) /F Makefile.nmake clean 44 | 45 | tests: 46 | cd test 47 | $(MAKE) /F Makefile.nmake 48 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ -x "`which autoreconf 2>/dev/null`" ] ; then 3 | exec autoreconf -ivf 4 | fi 5 | 6 | LIBTOOLIZE=libtoolize 7 | SYSNAME=`uname` 8 | if [ "x$SYSNAME" = "xDarwin" ] ; then 9 | LIBTOOLIZE=glibtoolize 10 | fi 11 | aclocal -I m4 && \ 12 | autoheader && \ 13 | $LIBTOOLIZE && \ 14 | autoconf && \ 15 | automake --add-missing --force-missing --copy 16 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/epoll_sub.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2003-2009 Niels Provos 3 | * Copyright 2009-2012 Niels Provos and Nick Mathewson 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 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | int 36 | epoll_create(int size) 37 | { 38 | return (syscall(__NR_epoll_create, size)); 39 | } 40 | 41 | int 42 | epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) 43 | { 44 | 45 | return (syscall(__NR_epoll_ctl, epfd, op, fd, event)); 46 | } 47 | 48 | int 49 | epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout) 50 | { 51 | return (syscall(__NR_epoll_wait, epfd, events, maxevents, timeout)); 52 | } 53 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/evdns.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2007 Niels Provos 3 | * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 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 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef _EVDNS_H_ 28 | #define _EVDNS_H_ 29 | 30 | /** @file evdns.h 31 | 32 | A dns subsystem for Libevent. 33 | 34 | The header is deprecated in Libevent 2.0 and later; please 35 | use instead. Depending on what functionality you 36 | need, you may also want to include more of the other 37 | headers. 38 | */ 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #endif /* _EVDNS_H_ */ 46 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/event.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2007 Niels Provos 3 | * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 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 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef _EVENT_H_ 28 | #define _EVENT_H_ 29 | 30 | /** @file event.h 31 | 32 | A library for writing event-driven network servers. 33 | 34 | The header is deprecated in Libevent 2.0 and later; please 35 | use instead. Depending on what functionality you 36 | need, you may also want to include more of the other event2/ 37 | headers. 38 | */ 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | #include 45 | #ifdef _EVENT_HAVE_SYS_TYPES_H 46 | #include 47 | #endif 48 | #ifdef _EVENT_HAVE_SYS_TIME_H 49 | #include 50 | #endif 51 | #ifdef _EVENT_HAVE_STDINT_H 52 | #include 53 | #endif 54 | #include 55 | 56 | /* For int types. */ 57 | #include 58 | 59 | #ifdef WIN32 60 | #ifndef WIN32_LEAN_AND_MEAN 61 | #define WIN32_LEAN_AND_MEAN 62 | #endif 63 | #include 64 | #include 65 | #undef WIN32_LEAN_AND_MEAN 66 | typedef unsigned char u_char; 67 | typedef unsigned short u_short; 68 | #endif 69 | 70 | #include 71 | #include 72 | #include 73 | #include 74 | #include 75 | #include 76 | #include 77 | #include 78 | #include 79 | #include 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif /* _EVENT_H_ */ 86 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/evhttp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2007 Niels Provos 3 | * Copyright 2007-2012 Niels Provos and Nick Mathewson 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 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef _EVHTTP_H_ 28 | #define _EVHTTP_H_ 29 | 30 | /** @file evhttp.h 31 | 32 | An http implementation subsystem for Libevent. 33 | 34 | The header is deprecated in Libevent 2.0 and later; please 35 | use instead. Depending on what functionality you 36 | need, you may also want to include more of the other 37 | headers. 38 | */ 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #endif /* _EVHTTP_H_ */ 46 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/evrpc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2007 Niels Provos 3 | * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 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 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef _EVRPC_H_ 28 | #define _EVRPC_H_ 29 | 30 | /** @file evrpc.h 31 | 32 | An RPC system for Libevent. 33 | 34 | The header is deprecated in Libevent 2.0 and later; please 35 | use instead. Depending on what functionality you 36 | need, you may also want to include more of the other 37 | headers. 38 | */ 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #endif /* _EVRPC_H_ */ 46 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/evsignal-internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2007 Niels Provos 3 | * Copyright 2007-2012 Niels Provos and Nick Mathewson 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 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef _EVSIGNAL_H_ 28 | #define _EVSIGNAL_H_ 29 | 30 | #ifndef evutil_socket_t 31 | #include "event2/util.h" 32 | #endif 33 | #include 34 | 35 | typedef void (*ev_sighandler_t)(int); 36 | 37 | /* Data structure for the default signal-handling implementation in signal.c 38 | */ 39 | struct evsig_info { 40 | /* Event watching ev_signal_pair[1] */ 41 | struct event ev_signal; 42 | /* Socketpair used to send notifications from the signal handler */ 43 | evutil_socket_t ev_signal_pair[2]; 44 | /* True iff we've added the ev_signal event yet. */ 45 | int ev_signal_added; 46 | /* Count of the number of signals we're currently watching. */ 47 | int ev_n_signals_added; 48 | 49 | /* Array of previous signal handler objects before Libevent started 50 | * messing with them. Used to restore old signal handlers. */ 51 | #ifdef _EVENT_HAVE_SIGACTION 52 | struct sigaction **sh_old; 53 | #else 54 | ev_sighandler_t **sh_old; 55 | #endif 56 | /* Size of sh_old. */ 57 | int sh_old_max; 58 | }; 59 | int evsig_init(struct event_base *); 60 | void evsig_dealloc(struct event_base *); 61 | 62 | void evsig_set_base(struct event_base *base); 63 | 64 | #endif /* _EVSIGNAL_H_ */ 65 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/evutil.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. The name of the author may not be used to endorse or promote products 13 | * derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | #ifndef _EVUTIL_H_ 27 | #define _EVUTIL_H_ 28 | 29 | /** @file evutil.h 30 | 31 | Utility and compatibility functions for Libevent. 32 | 33 | The header is deprecated in Libevent 2.0 and later; please 34 | use instead. 35 | */ 36 | 37 | #include 38 | 39 | #endif /* _EVUTIL_H_ */ 40 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/include/Makefile.am: -------------------------------------------------------------------------------- 1 | # include/Makefile.am for libevent 2 | # Copyright 2000-2007 Niels Provos 3 | # Copyright 2007-2012 Niels Provos and Nick Mathewson 4 | # 5 | # See LICENSE for copying information. 6 | 7 | AUTOMAKE_OPTIONS = foreign 8 | 9 | EVENT2_EXPORT = \ 10 | event2/buffer.h \ 11 | event2/buffer_compat.h \ 12 | event2/bufferevent.h \ 13 | event2/bufferevent_compat.h \ 14 | event2/bufferevent_ssl.h \ 15 | event2/bufferevent_struct.h \ 16 | event2/dns.h \ 17 | event2/dns_compat.h \ 18 | event2/dns_struct.h \ 19 | event2/event.h \ 20 | event2/event_compat.h \ 21 | event2/event_struct.h \ 22 | event2/http.h \ 23 | event2/http_compat.h \ 24 | event2/http_struct.h \ 25 | event2/keyvalq_struct.h \ 26 | event2/listener.h \ 27 | event2/rpc.h \ 28 | event2/rpc_compat.h \ 29 | event2/rpc_struct.h \ 30 | event2/tag.h \ 31 | event2/tag_compat.h \ 32 | event2/thread.h \ 33 | event2/util.h 34 | 35 | EXTRA_SRC = $(EVENT2_EXPORT) 36 | 37 | ## Without the nobase_ prefixing, Automake would strip "event2/" from 38 | ## the source header filename to derive the installed header filename. 39 | ## With nobase_ the installed path is $(includedir)/event2/ev*.h. 40 | 41 | if INSTALL_LIBEVENT 42 | nobase_include_HEADERS = $(EVENT2_EXPORT) 43 | nobase_nodist_include_HEADERS = ./event2/event-config.h 44 | else 45 | noinst_HEADERS = $(EVENT2_EXPORT) 46 | nodist_noinst_HEADERS = ./event2/event-config.h 47 | endif 48 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/include/event2/dns_struct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2007 Niels Provos 3 | * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 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 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef _EVENT2_DNS_STRUCT_H_ 28 | #define _EVENT2_DNS_STRUCT_H_ 29 | 30 | /** @file event2/dns_struct.h 31 | 32 | Data structures for dns. Using these structures may hurt forward 33 | compatibility with later versions of Libevent: be careful! 34 | 35 | */ 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | #include 42 | #ifdef _EVENT_HAVE_SYS_TYPES_H 43 | #include 44 | #endif 45 | #ifdef _EVENT_HAVE_SYS_TIME_H 46 | #include 47 | #endif 48 | 49 | /* For int types. */ 50 | #include 51 | 52 | /* 53 | * Structures used to implement a DNS server. 54 | */ 55 | 56 | struct evdns_server_request { 57 | int flags; 58 | int nquestions; 59 | struct evdns_server_question **questions; 60 | }; 61 | struct evdns_server_question { 62 | int type; 63 | #ifdef __cplusplus 64 | int dns_question_class; 65 | #else 66 | /* You should refer to this field as "dns_question_class". The 67 | * name "class" works in C for backward compatibility, and will be 68 | * removed in a future version. (1.5 or later). */ 69 | int class; 70 | #define dns_question_class class 71 | #endif 72 | char name[1]; 73 | }; 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | #endif /* _EVENT2_DNS_STRUCT_H_ */ 80 | 81 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/include/event2/keyvalq_struct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2007 Niels Provos 3 | * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 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 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef _EVENT2_EVENT_KEYVALQ_STRUCT_H_ 28 | #define _EVENT2_EVENT_KEYVALQ_STRUCT_H_ 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /* Fix so that people don't have to run with */ 35 | /* XXXX This code is duplicated with event_struct.h */ 36 | #ifndef TAILQ_ENTRY 37 | #define _EVENT_DEFINED_TQENTRY 38 | #define TAILQ_ENTRY(type) \ 39 | struct { \ 40 | struct type *tqe_next; /* next element */ \ 41 | struct type **tqe_prev; /* address of previous next element */ \ 42 | } 43 | #endif /* !TAILQ_ENTRY */ 44 | 45 | #ifndef TAILQ_HEAD 46 | #define _EVENT_DEFINED_TQHEAD 47 | #define TAILQ_HEAD(name, type) \ 48 | struct name { \ 49 | struct type *tqh_first; \ 50 | struct type **tqh_last; \ 51 | } 52 | #endif 53 | 54 | /* 55 | * Key-Value pairs. Can be used for HTTP headers but also for 56 | * query argument parsing. 57 | */ 58 | struct evkeyval { 59 | TAILQ_ENTRY(evkeyval) next; 60 | 61 | char *key; 62 | char *value; 63 | }; 64 | 65 | TAILQ_HEAD (evkeyvalq, evkeyval); 66 | 67 | /* XXXX This code is duplicated with event_struct.h */ 68 | #ifdef _EVENT_DEFINED_TQENTRY 69 | #undef TAILQ_ENTRY 70 | #endif 71 | 72 | #ifdef _EVENT_DEFINED_TQHEAD 73 | #undef TAILQ_HEAD 74 | #endif 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/include/event2/rpc_compat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2007 Niels Provos 3 | * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 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 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef _EVENT2_RPC_COMPAT_H_ 28 | #define _EVENT2_RPC_COMPAT_H_ 29 | 30 | /** @file event2/rpc_compat.h 31 | 32 | Deprecated versions of the functions in rpc.h: provided only for 33 | backwards compatibility. 34 | 35 | */ 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | /** backwards compatible accessors that work only with gcc */ 42 | #if defined(__GNUC__) && !defined(__STRICT_ANSI__) 43 | 44 | #undef EVTAG_ASSIGN 45 | #undef EVTAG_GET 46 | #undef EVTAG_ADD 47 | 48 | #define EVTAG_ASSIGN(msg, member, args...) \ 49 | (*(msg)->base->member##_assign)(msg, ## args) 50 | #define EVTAG_GET(msg, member, args...) \ 51 | (*(msg)->base->member##_get)(msg, ## args) 52 | #define EVTAG_ADD(msg, member, args...) \ 53 | (*(msg)->base->member##_add)(msg, ## args) 54 | #endif 55 | #define EVTAG_LEN(msg, member) ((msg)->member##_length) 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* _EVENT2_EVENT_COMPAT_H_ */ 62 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/include/event2/tag_compat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2007 Niels Provos 3 | * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 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 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef _EVENT2_TAG_COMPAT_H_ 28 | #define _EVENT2_TAG_COMPAT_H_ 29 | 30 | /** @file event2/tag_compat.h 31 | 32 | Obsolete/deprecated functions from tag.h; provided only for backwards 33 | compatibility. 34 | */ 35 | 36 | /** 37 | @name Misnamed functions 38 | 39 | @deprecated These macros are deprecated because their names don't follow 40 | Libevent's naming conventions. Use evtag_encode_int and 41 | evtag_encode_int64 instead. 42 | 43 | @{ 44 | */ 45 | #define encode_int(evbuf, number) evtag_encode_int((evbuf), (number)) 46 | #define encode_int64(evbuf, number) evtag_encode_int64((evbuf), (number)) 47 | /**@}*/ 48 | 49 | #endif /* _EVENT2_TAG_H_ */ 50 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/ipv6-internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2012 Niels Provos and Nick Mathewson 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. The name of the author may not be used to endorse or promote products 13 | * derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | /* Internal use only: Fake IPv6 structures and values on platforms that 28 | * do not have them */ 29 | 30 | #ifndef _EVENT_IPV6_INTERNAL_H 31 | #define _EVENT_IPV6_INTERNAL_H 32 | 33 | #include 34 | #ifdef _EVENT_HAVE_SYS_SOCKET_H 35 | #include 36 | #endif 37 | #include "event2/event-config.h" 38 | #include "event2/util.h" 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /** @file ipv6-internal.h 45 | * 46 | * Replacement types and functions for platforms that don't support ipv6 47 | * properly. 48 | */ 49 | 50 | #ifndef _EVENT_HAVE_STRUCT_IN6_ADDR 51 | struct in6_addr { 52 | ev_uint8_t s6_addr[16]; 53 | }; 54 | #endif 55 | 56 | #ifndef _EVENT_HAVE_SA_FAMILY_T 57 | typedef int sa_family_t; 58 | #endif 59 | 60 | #ifndef _EVENT_HAVE_STRUCT_SOCKADDR_IN6 61 | struct sockaddr_in6 { 62 | /* This will fail if we find a struct sockaddr that doesn't have 63 | * sa_family as the first element. */ 64 | sa_family_t sin6_family; 65 | ev_uint16_t sin6_port; 66 | struct in6_addr sin6_addr; 67 | }; 68 | #endif 69 | 70 | #ifndef AF_INET6 71 | #define AF_INET6 3333 72 | #endif 73 | #ifndef PF_INET6 74 | #define PF_INET6 AF_INET6 75 | #endif 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/libevent.pc.in: -------------------------------------------------------------------------------- 1 | #libevent pkg-config source file 2 | 3 | prefix=@prefix@ 4 | exec_prefix=@exec_prefix@ 5 | libdir=@libdir@ 6 | includedir=@includedir@ 7 | 8 | Name: libevent 9 | Description: libevent is an asynchronous notification event loop library 10 | Version: @VERSION@ 11 | Requires: 12 | Conflicts: 13 | Libs: -L${libdir} -levent 14 | Libs.private: @LIBS@ 15 | Cflags: -I${includedir} 16 | 17 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/libevent_openssl.pc.in: -------------------------------------------------------------------------------- 1 | #libevent pkg-config source file 2 | 3 | prefix=@prefix@ 4 | exec_prefix=@exec_prefix@ 5 | libdir=@libdir@ 6 | includedir=@includedir@ 7 | 8 | Name: libevent_openssl 9 | Description: libevent_openssl adds openssl-based TLS support to libevent 10 | Version: @VERSION@ 11 | Requires: libevent 12 | Conflicts: 13 | Libs: -L${libdir} -levent_openssl 14 | Libs.private: @LIBS@ -lssl -lcrypto 15 | Cflags: -I${includedir} 16 | 17 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/libevent_pthreads.pc.in: -------------------------------------------------------------------------------- 1 | #libevent pkg-config source file 2 | 3 | prefix=@prefix@ 4 | exec_prefix=@exec_prefix@ 5 | libdir=@libdir@ 6 | includedir=@includedir@ 7 | 8 | Name: libevent_pthreads 9 | Description: libevent_pthreads adds pthreads-based threading support to libevent 10 | Version: @VERSION@ 11 | Requires: libevent 12 | Conflicts: 13 | Libs: -L${libdir} -levent_pthreads 14 | Libs.private: @LIBS@ @PTHREAD_LIBS@ 15 | Cflags: -I${includedir} @PTHREAD_CFLAGS@ 16 | 17 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/log-internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2007 Niels Provos 3 | * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 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 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef _LOG_H_ 28 | #define _LOG_H_ 29 | 30 | #include "event2/util.h" 31 | 32 | #ifdef __GNUC__ 33 | #define EV_CHECK_FMT(a,b) __attribute__((format(printf, a, b))) 34 | #define EV_NORETURN __attribute__((noreturn)) 35 | #else 36 | #define EV_CHECK_FMT(a,b) 37 | #define EV_NORETURN 38 | #endif 39 | 40 | #define _EVENT_ERR_ABORT ((int)0xdeaddead) 41 | 42 | void event_err(int eval, const char *fmt, ...) EV_CHECK_FMT(2,3) EV_NORETURN; 43 | void event_warn(const char *fmt, ...) EV_CHECK_FMT(1,2); 44 | void event_sock_err(int eval, evutil_socket_t sock, const char *fmt, ...) EV_CHECK_FMT(3,4) EV_NORETURN; 45 | void event_sock_warn(evutil_socket_t sock, const char *fmt, ...) EV_CHECK_FMT(2,3); 46 | void event_errx(int eval, const char *fmt, ...) EV_CHECK_FMT(2,3) EV_NORETURN; 47 | void event_warnx(const char *fmt, ...) EV_CHECK_FMT(1,2); 48 | void event_msgx(const char *fmt, ...) EV_CHECK_FMT(1,2); 49 | void _event_debugx(const char *fmt, ...) EV_CHECK_FMT(1,2); 50 | 51 | #ifdef USE_DEBUG 52 | #define event_debug(x) _event_debugx x 53 | #else 54 | #define event_debug(x) do {;} while (0) 55 | #endif 56 | 57 | #undef EV_CHECK_FMT 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # @configure_input@ 11 | 12 | # serial 3337 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.4.2]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3337]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.4.2' 20 | macro_revision='1.3337' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/make-event-config.sed: -------------------------------------------------------------------------------- 1 | # Sed script to postprocess config.h into event-config.h. 2 | 3 | 1i\ 4 | /* event2/event-config.h\ 5 | *\ 6 | * This file was generated by autoconf when libevent was built, and post-\ 7 | * processed by Libevent so that its macros would have a uniform prefix.\ 8 | *\ 9 | * DO NOT EDIT THIS FILE.\ 10 | *\ 11 | * Do not rely on macros in this file existing in later versions.\ 12 | */\ 13 | \ 14 | #ifndef _EVENT2_EVENT_CONFIG_H_\ 15 | #define _EVENT2_EVENT_CONFIG_H_\ 16 | 17 | $a\ 18 | \ 19 | #endif /* event2/event-config.h */ 20 | 21 | s/#define /#define _EVENT_/ 22 | s/#undef /#undef _EVENT_/ 23 | s/#ifndef /#ifndef _EVENT_/ 24 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/mm-internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. The name of the author may not be used to endorse or promote products 13 | * derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | #ifndef _EVENT_MM_INTERNAL_H 27 | #define _EVENT_MM_INTERNAL_H 28 | 29 | #include 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | #ifndef _EVENT_DISABLE_MM_REPLACEMENT 36 | /* Internal use only: Memory allocation functions. We give them nice short 37 | * mm_names for our own use, but make sure that the symbols have longer names 38 | * so they don't conflict with other libraries (like, say, libmm). */ 39 | void *event_mm_malloc_(size_t sz); 40 | void *event_mm_calloc_(size_t count, size_t size); 41 | char *event_mm_strdup_(const char *s); 42 | void *event_mm_realloc_(void *p, size_t sz); 43 | void event_mm_free_(void *p); 44 | #define mm_malloc(sz) event_mm_malloc_(sz) 45 | #define mm_calloc(count, size) event_mm_calloc_((count), (size)) 46 | #define mm_strdup(s) event_mm_strdup_(s) 47 | #define mm_realloc(p, sz) event_mm_realloc_((p), (sz)) 48 | #define mm_free(p) event_mm_free_(p) 49 | #else 50 | #define mm_malloc(sz) malloc(sz) 51 | #define mm_calloc(n, sz) calloc((n), (sz)) 52 | #define mm_strdup(s) strdup(s) 53 | #define mm_realloc(p, sz) realloc((p), (sz)) 54 | #define mm_free(p) free(p) 55 | #endif 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/sample/Makefile.am: -------------------------------------------------------------------------------- 1 | # sample/Makefile.am for libevent 2 | # Copyright 2000-2007 Niels Provos 3 | # Copyright 2007-2012 Niels Provos and Nick Mathewson 4 | # 5 | # See LICENSE for copying information. 6 | 7 | AUTOMAKE_OPTIONS = foreign no-dependencies 8 | 9 | LDADD = $(LIBEVENT_GC_SECTIONS) ../libevent.la 10 | AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/compat -I$(top_srcdir)/include -I../include 11 | 12 | noinst_PROGRAMS = event-test time-test signal-test dns-example hello-world http-server 13 | 14 | event_test_SOURCES = event-test.c 15 | time_test_SOURCES = time-test.c 16 | signal_test_SOURCES = signal-test.c 17 | dns_example_SOURCES = dns-example.c 18 | hello_world_SOURCES = hello-world.c 19 | http_server_SOURCES = http-server.c 20 | 21 | if OPENSSL 22 | noinst_PROGRAMS += le-proxy 23 | le_proxy_SOURCES = le-proxy.c 24 | le_proxy_LDADD = $(LDADD) ../libevent_openssl.la -lssl -lcrypto ${OPENSSL_LIBADD} 25 | endif 26 | 27 | verify: 28 | 29 | DISTCLEANFILES = *~ 30 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/sample/signal-test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Compile with: 3 | * cc -I/usr/local/include -o signal-test \ 4 | * signal-test.c -L/usr/local/lib -levent 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | #ifndef WIN32 13 | #include 14 | #include 15 | #include 16 | #else 17 | #include 18 | #include 19 | #endif 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | #ifdef _EVENT___func__ 30 | #define __func__ _EVENT___func__ 31 | #endif 32 | 33 | int called = 0; 34 | 35 | static void 36 | signal_cb(evutil_socket_t fd, short event, void *arg) 37 | { 38 | struct event *signal = arg; 39 | 40 | printf("%s: got signal %d\n", __func__, EVENT_SIGNAL(signal)); 41 | 42 | if (called >= 2) 43 | event_del(signal); 44 | 45 | called++; 46 | } 47 | 48 | int 49 | main(int argc, char **argv) 50 | { 51 | struct event signal_int; 52 | struct event_base* base; 53 | #ifdef WIN32 54 | WORD wVersionRequested; 55 | WSADATA wsaData; 56 | 57 | wVersionRequested = MAKEWORD(2, 2); 58 | 59 | (void) WSAStartup(wVersionRequested, &wsaData); 60 | #endif 61 | 62 | /* Initalize the event library */ 63 | base = event_base_new(); 64 | 65 | /* Initalize one event */ 66 | event_assign(&signal_int, base, SIGINT, EV_SIGNAL|EV_PERSIST, signal_cb, 67 | &signal_int); 68 | 69 | event_add(&signal_int, NULL); 70 | 71 | event_base_dispatch(base); 72 | event_base_free(base); 73 | 74 | return (0); 75 | } 76 | 77 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/sample/time-test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * XXX This sample code was once meant to show how to use the basic Libevent 3 | * interfaces, but it never worked on non-Unix platforms, and some of the 4 | * interfaces have changed since it was first written. It should probably 5 | * be removed or replaced with something better. 6 | * 7 | * Compile with: 8 | * cc -I/usr/local/include -o time-test time-test.c -L/usr/local/lib -levent 9 | */ 10 | 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | #ifndef WIN32 17 | #include 18 | #include 19 | #endif 20 | #include 21 | #ifdef _EVENT_HAVE_SYS_TIME_H 22 | #include 23 | #endif 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #ifdef WIN32 35 | #include 36 | #endif 37 | 38 | struct timeval lasttime; 39 | 40 | int event_is_persistent; 41 | 42 | static void 43 | timeout_cb(evutil_socket_t fd, short event, void *arg) 44 | { 45 | struct timeval newtime, difference; 46 | struct event *timeout = arg; 47 | double elapsed; 48 | 49 | evutil_gettimeofday(&newtime, NULL); 50 | evutil_timersub(&newtime, &lasttime, &difference); 51 | elapsed = difference.tv_sec + 52 | (difference.tv_usec / 1.0e6); 53 | 54 | printf("timeout_cb called at %d: %.3f seconds elapsed.\n", 55 | (int)newtime.tv_sec, elapsed); 56 | lasttime = newtime; 57 | 58 | if (! event_is_persistent) { 59 | struct timeval tv; 60 | evutil_timerclear(&tv); 61 | tv.tv_sec = 2; 62 | event_add(timeout, &tv); 63 | } 64 | } 65 | 66 | int 67 | main(int argc, char **argv) 68 | { 69 | struct event timeout; 70 | struct timeval tv; 71 | struct event_base *base; 72 | int flags; 73 | 74 | #ifdef WIN32 75 | WORD wVersionRequested; 76 | WSADATA wsaData; 77 | 78 | wVersionRequested = MAKEWORD(2, 2); 79 | 80 | (void)WSAStartup(wVersionRequested, &wsaData); 81 | #endif 82 | 83 | if (argc == 2 && !strcmp(argv[1], "-p")) { 84 | event_is_persistent = 1; 85 | flags = EV_PERSIST; 86 | } else { 87 | event_is_persistent = 0; 88 | flags = 0; 89 | } 90 | 91 | /* Initalize the event library */ 92 | base = event_base_new(); 93 | 94 | /* Initalize one event */ 95 | event_assign(&timeout, base, -1, flags, timeout_cb, (void*) &timeout); 96 | 97 | evutil_timerclear(&tv); 98 | tv.tv_sec = 2; 99 | event_add(&timeout, &tv); 100 | 101 | evutil_gettimeofday(&lasttime, NULL); 102 | 103 | event_base_dispatch(base); 104 | 105 | return (0); 106 | } 107 | 108 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/strlcpy-internal.h: -------------------------------------------------------------------------------- 1 | #ifndef _STRLCPY_INTERNAL_H_ 2 | #define _STRLCPY_INTERNAL_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "event2/event-config.h" 9 | 10 | #ifndef _EVENT_HAVE_STRLCPY 11 | #include 12 | size_t _event_strlcpy(char *dst, const char *src, size_t siz); 13 | #define strlcpy _event_strlcpy 14 | #endif 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/strlcpy.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1998 Todd C. Miller 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 20 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 21 | * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 24 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #if defined(LIBC_SCCS) && !defined(lint) 31 | static char *rcsid = "$OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp $"; 32 | #endif /* LIBC_SCCS and not lint */ 33 | 34 | #include 35 | 36 | #include "event2/event-config.h" 37 | 38 | #ifndef _EVENT_HAVE_STRLCPY 39 | #include "strlcpy-internal.h" 40 | 41 | /* 42 | * Copy src to string dst of size siz. At most siz-1 characters 43 | * will be copied. Always NUL terminates (unless siz == 0). 44 | * Returns strlen(src); if retval >= siz, truncation occurred. 45 | */ 46 | size_t 47 | _event_strlcpy(dst, src, siz) 48 | char *dst; 49 | const char *src; 50 | size_t siz; 51 | { 52 | register char *d = dst; 53 | register const char *s = src; 54 | register size_t n = siz; 55 | 56 | /* Copy as many bytes as will fit */ 57 | if (n != 0 && --n != 0) { 58 | do { 59 | if ((*d++ = *s++) == 0) 60 | break; 61 | } while (--n != 0); 62 | } 63 | 64 | /* Not enough room in dst, add NUL and traverse rest of src */ 65 | if (n == 0) { 66 | if (siz != 0) 67 | *d = '\0'; /* NUL-terminate dst */ 68 | while (*s++) 69 | ; 70 | } 71 | 72 | return (s - src - 1); /* count does not include NUL */ 73 | } 74 | #endif 75 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/test/Makefile.nmake: -------------------------------------------------------------------------------- 1 | 2 | CFLAGS=/I.. /I../WIN32-Code /I../include /I../compat /DWIN32 /DHAVE_CONFIG_H /DTINYTEST_LOCAL 3 | 4 | CFLAGS=$(CFLAGS) /Ox /W3 /wd4996 /nologo 5 | 6 | REGRESS_OBJS=regress.obj regress_buffer.obj regress_http.obj regress_dns.obj \ 7 | regress_testutils.obj \ 8 | regress_rpc.obj regress.gen.obj \ 9 | regress_et.obj regress_bufferevent.obj \ 10 | regress_listener.obj regress_util.obj tinytest.obj \ 11 | regress_main.obj regress_minheap.obj regress_iocp.obj \ 12 | regress_thread.obj 13 | 14 | OTHER_OBJS=test-init.obj test-eof.obj test-weof.obj test-time.obj \ 15 | bench.obj bench_cascade.obj bench_http.obj bench_httpclient.obj \ 16 | test-changelist.obj 17 | 18 | PROGRAMS=regress.exe \ 19 | test-init.exe test-eof.exe test-weof.exe test-time.exe \ 20 | test-changelist.exe 21 | 22 | # Disabled for now: 23 | # bench.exe bench_cascade.exe bench_http.exe bench_httpclient.exe 24 | 25 | 26 | LIBS=..\libevent.lib ws2_32.lib shell32.lib advapi32.lib 27 | 28 | all: $(PROGRAMS) 29 | 30 | regress.exe: $(REGRESS_OBJS) 31 | $(CC) $(CFLAGS) $(LIBS) $(REGRESS_OBJS) 32 | 33 | test-init.exe: test-init.obj 34 | $(CC) $(CFLAGS) $(LIBS) test-init.obj 35 | test-eof.exe: test-eof.obj 36 | $(CC) $(CFLAGS) $(LIBS) test-eof.obj 37 | test-changelist.exe: test-changelist.obj 38 | $(CC) $(CFLAGS) $(LIBS) test-changelist.obj 39 | test-weof.exe: test-weof.obj 40 | $(CC) $(CFLAGS) $(LIBS) test-weof.obj 41 | test-time.exe: test-time.obj 42 | $(CC) $(CFLAGS) $(LIBS) test-time.obj 43 | 44 | bench.exe: bench.obj 45 | $(CC) $(CFLAGS) $(LIBS) bench.obj 46 | bench_cascade.exe: bench_cascade.obj 47 | $(CC) $(CFLAGS) $(LIBS) bench_cascade.obj 48 | bench_http.exe: bench_http.obj 49 | $(CC) $(CFLAGS) $(LIBS) bench_http.obj 50 | bench_httpclient.exe: bench_httpclient.obj 51 | $(CC) $(CFLAGS) $(LIBS) bench_httpclient.obj 52 | 53 | regress.gen.c regress.gen.h: regress.rpc ../event_rpcgen.py 54 | echo // > regress.gen.c 55 | echo #define NO_PYTHON_EXISTS > regress.gen.h 56 | -python ..\event_rpcgen.py regress.rpc 57 | 58 | clean: 59 | -del $(REGRESS_OBJS) 60 | -del $(OTHER_OBJS) 61 | -del regress.exe 62 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/test/regress.rpc: -------------------------------------------------------------------------------- 1 | /* tests data packing and unpacking */ 2 | 3 | struct msg { 4 | string /* sender */ from_name = 1; /* be verbose */ 5 | string to_name = 2; 6 | optional struct[kill] attack = 3; 7 | array struct[run] run = 4; 8 | } 9 | 10 | struct kill { 11 | string weapon = 0x10121; 12 | string action = 2; 13 | array int how_often = 3; 14 | } 15 | 16 | struct run { 17 | string how = 1; 18 | optional bytes some_bytes = 2; 19 | 20 | bytes fixed_bytes[24] = 3; 21 | array string notes = 4; 22 | 23 | optional int64 large_number = 5; 24 | array int other_numbers = 6; 25 | } 26 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/test/regress_testutils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2012 Niels Provos and Nick Mathewson 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. The name of the author may not be used to endorse or promote products 13 | * derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef _TESTUTILS_H 28 | #define _TESTUTILS_H 29 | 30 | #include "event2/dns.h" 31 | 32 | struct regress_dns_server_table { 33 | const char *q; 34 | const char *anstype; 35 | const char *ans; 36 | int seen; 37 | }; 38 | 39 | struct evdns_server_port * 40 | regress_get_dnsserver(struct event_base *base, 41 | ev_uint16_t *portnum, 42 | evutil_socket_t *psock, 43 | evdns_request_callback_fn_type cb, 44 | void *arg); 45 | 46 | /* Helper: return the port that a socket is bound on, in host order. */ 47 | int regress_get_socket_port(evutil_socket_t fd); 48 | 49 | /* used to look up pre-canned responses in a search table */ 50 | void regress_dns_server_cb( 51 | struct evdns_server_request *req, void *data); 52 | 53 | /* globally allocates a dns server that serves from a search table */ 54 | int regress_dnsserver(struct event_base *base, ev_uint16_t *port, 55 | struct regress_dns_server_table *seach_table); 56 | 57 | /* clean up the global dns server resources */ 58 | void regress_clean_dnsserver(void); 59 | 60 | struct evconnlistener; 61 | struct sockaddr; 62 | int regress_get_listener_addr(struct evconnlistener *lev, 63 | struct sockaddr *sa, ev_socklen_t *socklen); 64 | 65 | #endif /* _TESTUTILS_H */ 66 | 67 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/test/rpcgen_wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # libevent rpcgen_wrapper.sh 3 | # Transforms event_rpcgen.py failure into success for make, only if 4 | # regress.gen.c and regress.gen.h already exist in $srcdir. This 5 | # is needed for "make distcheck" to pass the read-only $srcdir build, 6 | # as with read-only sources fresh from tarball, regress.gen.[ch] will 7 | # be correct in $srcdir but unwritable. This previously triggered 8 | # Makefile.am to create stub regress.gen.c and regress.gen.h in the 9 | # distcheck _build directory, which were then detected as leftover 10 | # files in the build tree after distclean, breaking distcheck. 11 | # Note that regress.gen.[ch] are not in fresh git clones, making 12 | # working Python a requirement for make distcheck of a git tree. 13 | 14 | exit_updated() { 15 | echo "Updated ${srcdir}\regress.gen.c and ${srcdir}\regress.gen.h" 16 | exit 0 17 | } 18 | 19 | exit_reuse() { 20 | echo "event_rpcgen.py failed, ${srcdir}\regress.gen.\[ch\] will be reused." >&2 21 | exit 0 22 | } 23 | 24 | exit_failed() { 25 | echo "Could not generate regress.gen.\[ch\] using event_rpcgen.sh" >&2 26 | exit 1 27 | } 28 | 29 | if [ -x /usr/bin/python2 ] ; then 30 | PYTHON2=/usr/bin/python2 31 | elif [ "x`which python2`" != x ] ; then 32 | PYTHON2=python2 33 | else 34 | PYTHON2=python 35 | fi 36 | 37 | srcdir=$1 38 | srcdir=${srcdir:-.} 39 | ${PYTHON2} ${srcdir}/../event_rpcgen.py ${srcdir}/regress.rpc 40 | case "$?" in 41 | 0) 42 | exit_updated 43 | ;; 44 | *) 45 | test -r ${srcdir}/regress.gen.c -a -r ${srcdir}/regress.gen.h && \ 46 | exit_reuse 47 | exit_failed 48 | ;; 49 | esac 50 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/test/test-init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003-2007 Niels Provos 3 | * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson 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 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #include "event2/event-config.h" 28 | 29 | #include 30 | #include 31 | #ifdef _EVENT_HAVE_SYS_TIME_H 32 | #include 33 | #endif 34 | #ifdef _EVENT_HAVE_SYS_SOCKET_H 35 | #include 36 | #endif 37 | #include 38 | #include 39 | #include 40 | #include 41 | #ifndef WIN32 42 | #include 43 | #endif 44 | #include 45 | 46 | #include 47 | 48 | int 49 | main(int argc, char **argv) 50 | { 51 | #ifdef WIN32 52 | WORD wVersionRequested; 53 | WSADATA wsaData; 54 | 55 | wVersionRequested = MAKEWORD(2, 2); 56 | 57 | (void) WSAStartup(wVersionRequested, &wsaData); 58 | #endif 59 | 60 | /* Initalize the event library */ 61 | event_init(); 62 | 63 | return (0); 64 | } 65 | 66 | -------------------------------------------------------------------------------- /deps/libevent-2.0.21-stable/test/tinytest_local.h: -------------------------------------------------------------------------------- 1 | 2 | #ifdef WIN32 3 | #include 4 | #endif 5 | 6 | #include "event2/util.h" 7 | #include "util-internal.h" 8 | 9 | #ifdef snprintf 10 | #undef snprintf 11 | #endif 12 | #define snprintf evutil_snprintf 13 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | see [https://github.com/ideawu/icomet/wiki](https://github.com/ideawu/icomet/wiki) 2 | 3 | -------------------------------------------------------------------------------- /icomet.conf: -------------------------------------------------------------------------------- 1 | # icomet config file 2 | # MUST indent by TAB 3 | 4 | pidfile = ./icomet.pid 5 | 6 | logger: 7 | level: debug 8 | #output: stdout 9 | output: ./logs/log.txt 10 | rotate: 11 | size: 1000000000 12 | 13 | admin: 14 | #listen: 127.0.0.1:8000 15 | listen: 0.0.0.0:8000 16 | # allowed ip prefix, one ip each line 17 | allow: 127.0.0.1 18 | allow: 192.168 19 | deny: all 20 | #allow: all 21 | 22 | front: 23 | listen: 0.0.0.0:8100 24 | # none|token 25 | auth: none 26 | max_channels: 100000 27 | max_subscribers_per_channel: 16 28 | # number of messages buffered 29 | channel_buffer_size: 10 30 | # in seconds 31 | channel_timeout: 30 32 | # the idle time to send noop message, in seconds 33 | polling_timeout: 30 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/comet/Makefile: -------------------------------------------------------------------------------- 1 | include ../../build.mk 2 | 3 | OBJS = subscriber.o presence.o channel.o server.o 4 | CFLAGS += -I ../ 5 | 6 | all: $(OBJS) 7 | ${CXX} -o ../../icomet-server $(CFLAGS) \ 8 | icomet-server.cpp $(OBJS) \ 9 | ../util/libutil.a \ 10 | $(LIBEVENT_PATH)/.libs/libevent.a \ 11 | $(CLIBS) 12 | 13 | subscriber.o: subscriber.h subscriber.cpp 14 | ${CXX} -c $(CFLAGS) subscriber.cpp 15 | presence.o: presence.h presence.cpp 16 | ${CXX} -c $(CFLAGS) presence.cpp 17 | channel.o: channel.h channel.cpp 18 | ${CXX} -c $(CFLAGS) channel.cpp 19 | server.o: server.h server.cpp 20 | ${CXX} -c $(CFLAGS) server.cpp 21 | 22 | clean: 23 | rm -f *.o ../../icomet-server 24 | 25 | -------------------------------------------------------------------------------- /src/comet/README.md: -------------------------------------------------------------------------------- 1 | Periodically ship most recent presence activities(presence, offline) to presence servers. But before this, send each presence activity(sub, offline) to presence subscribers at once. 2 | -------------------------------------------------------------------------------- /src/comet/channel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2014 The icomet Authors. All rights reserved. 3 | Use of this source code is governed by a BSD-style license that can be 4 | found in the LICENSE file. 5 | */ 6 | #include "channel.h" 7 | #include 8 | #include 9 | #include "util/log.h" 10 | #include "util/list.h" 11 | #include "server.h" 12 | #include "subscriber.h" 13 | #include "server_config.h" 14 | 15 | Channel::Channel(){ 16 | serv = NULL; 17 | idle = 0; 18 | seq_next = 1; 19 | presence_idle = 0; 20 | } 21 | 22 | Channel::~Channel(){ 23 | } 24 | 25 | void Channel::add_subscriber(Subscriber *sub){ 26 | sub->channel = this; 27 | subs.push_back(sub); 28 | } 29 | 30 | void Channel::del_subscriber(Subscriber *sub){ 31 | sub->channel = NULL; 32 | subs.remove(sub); 33 | } 34 | 35 | void Channel::create_token(){ 36 | // TODO: rand() is not safe? 37 | struct timeval tv; 38 | gettimeofday(&tv, NULL); 39 | token.resize(33); 40 | char *buf = (char *)token.data(); 41 | int offset = 0; 42 | while(1){ 43 | int r = rand() + tv.tv_usec; 44 | int len = snprintf(buf + offset, token.size() - offset, "%08x", r); 45 | if(len == -1){ 46 | break; 47 | } 48 | offset += len; 49 | if(offset >= token.size() - 1){ 50 | break; 51 | } 52 | } 53 | token.resize(32); 54 | } 55 | 56 | void Channel::clear(){ 57 | msg_list.clear(); 58 | } 59 | 60 | void Channel::close(){ 61 | this->send("close", ""); 62 | LinkedList::Iterator it = subs.iterator(); 63 | while(Subscriber *sub = it.next()){ 64 | sub->close(); 65 | } 66 | } 67 | 68 | static std::string json_encode(const char *str){ 69 | std::string ret; 70 | int len = strlen(str); 71 | for(int i=0; i::Iterator it = subs.iterator(); 99 | while(Subscriber *sub = it.next()){ 100 | sub->send_chunk(msg.seq, type, msg.content.c_str()); 101 | } 102 | 103 | if(msg.type == Message::DATA || msg.type == Message::BROADCAST){ 104 | msg_list.push_back(msg); 105 | seq_next ++; 106 | } 107 | 108 | if(msg_list.size() >= ServerConfig::channel_buffer_size * 1.5){ 109 | std::vector::iterator it; 110 | it = msg_list.end() - ServerConfig::channel_buffer_size; 111 | msg_list.assign(it, msg_list.end()); 112 | log_trace("resize msg_list to %d, seq_next: %d", msg_list.size(), seq_next); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/comet/channel.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2014 The icomet Authors. All rights reserved. 3 | Use of this source code is governed by a BSD-style license that can be 4 | found in the LICENSE file. 5 | */ 6 | #ifndef ICOMET_CHANNEL_H 7 | #define ICOMET_CHANNEL_H 8 | 9 | #include "../build.h" 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "util/list.h" 15 | 16 | #define CHANNEL_MSG_LIST_SIZE 10 17 | 18 | class Server; 19 | class Subscriber; 20 | 21 | class Message{ 22 | public: 23 | const static int NOOP = 0; 24 | const static int DATA = 1; 25 | const static int BROADCAST = 2; 26 | 27 | int seq; 28 | int type; 29 | std::string content; 30 | 31 | void set_type_text(const char *type){ 32 | if(strcmp(type, "data") == 0){ 33 | this->type = DATA; 34 | }else if(strcmp(type, "broadcast") == 0){ 35 | this->type = BROADCAST; 36 | }else{ 37 | this->type = NOOP; 38 | } 39 | } 40 | 41 | const char* get_type_text() const{ 42 | if(this->type == DATA){ 43 | return "data"; 44 | }else if(this->type == BROADCAST){ 45 | return "broadcast"; 46 | }else{ 47 | return "noop"; 48 | } 49 | } 50 | }; 51 | 52 | 53 | class Channel{ 54 | private: 55 | public: 56 | inline static bool SEQ_GT(int a, int b){ 57 | return a - b > 0; 58 | } 59 | inline static bool SEQ_GE(int a, int b){ 60 | return a - b >= 0; 61 | } 62 | inline static bool SEQ_LT(int a, int b){ 63 | return a - b < 0; 64 | } 65 | inline static bool SEQ_LE(int a, int b){ 66 | return a - b <= 0; 67 | } 68 | public: 69 | Channel *prev; 70 | Channel *next; 71 | 72 | Server *serv; 73 | LinkedList subs; 74 | 75 | // idle < 0: offline 76 | // idle >= 0 && subs.empty(): away 77 | // idle >= 0 && !subs.empty(): online 78 | int idle; 79 | int seq_next; 80 | std::string name; 81 | std::string token; 82 | 83 | int presence_idle; 84 | 85 | std::vector msg_list; 86 | 87 | Channel(); 88 | ~Channel(); 89 | 90 | inline int msg_seq_min() const{ 91 | if(msg_list.empty()){ 92 | return seq_next; 93 | }else if(msg_list.size() > CHANNEL_MSG_LIST_SIZE){ 94 | return seq_next - CHANNEL_MSG_LIST_SIZE; 95 | }else{ 96 | return seq_next - msg_list.size(); 97 | } 98 | } 99 | void create_token(); 100 | 101 | void add_subscriber(Subscriber *sub); 102 | void del_subscriber(Subscriber *sub); 103 | void send(const char *type, const char *content, bool encoded=true); 104 | void clear(); 105 | void close(); 106 | }; 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /src/comet/http_query.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2017 The icomet Authors. All rights reserved. 3 | Use of this source code is governed by a BSD-style license that can be 4 | found in the LICENSE file. 5 | */ 6 | #ifndef ICOMET_HTTP_QUERY_H 7 | #define ICOMET_HTTP_QUERY_H 8 | 9 | #include 10 | #include 11 | 12 | class HttpQuery{ 13 | private: 14 | struct evkeyvalq _get; 15 | struct evkeyvalq _post; 16 | bool _has_post; 17 | public: 18 | HttpQuery(struct evhttp_request *req){ 19 | _has_post = false; 20 | if(evhttp_request_get_command(req) == EVHTTP_REQ_POST){ 21 | evbuffer *body_evb = evhttp_request_get_input_buffer(req); 22 | size_t len = evbuffer_get_length(body_evb); 23 | if(len > 0){ 24 | _has_post = true; 25 | char *data = (char *)malloc(len + 1); 26 | evbuffer_copyout(body_evb, data, len); 27 | data[len] = '\0'; 28 | evhttp_parse_query_str(data, &_post); 29 | free(data); 30 | } 31 | } 32 | evhttp_parse_query(evhttp_request_get_uri(req), &_get); 33 | } 34 | ~HttpQuery(){ 35 | evhttp_clear_headers(&_get); 36 | if(_has_post){ 37 | evhttp_clear_headers(&_post); 38 | } 39 | } 40 | int get_int(const char *name, int def){ 41 | if(_has_post){ 42 | const char *val = evhttp_find_header(&_post, name); 43 | if(val){ 44 | return atoi(val); 45 | } 46 | } 47 | const char *val = evhttp_find_header(&_get, name); 48 | return val? atoi(val) : def; 49 | } 50 | const char* get_str(const char *name, const char *def){ 51 | if(_has_post){ 52 | const char *val = evhttp_find_header(&_post, name); 53 | if(val){ 54 | return val; 55 | } 56 | } 57 | const char *val = evhttp_find_header(&_get, name); 58 | return val? val : def; 59 | } 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/comet/presence.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2017 The icomet Authors. All rights reserved. 3 | Use of this source code is governed by a BSD-style license that can be 4 | found in the LICENSE file. 5 | */ 6 | #include "presence.h" 7 | #include "server.h" 8 | #include "util/log.h" 9 | #include "server_config.h" 10 | #include 11 | 12 | static void connection_closecb(struct evhttp_connection *evcon, void *arg){ 13 | log_info("presence subscriber disconnected"); 14 | PresenceSubscriber *psub = (PresenceSubscriber *)arg; 15 | psub->close(); 16 | } 17 | 18 | void PresenceSubscriber::start(){ 19 | log_info("%s:%d psub, psubs: %d", req->remote_host, req->remote_port, serv->psubs.size); 20 | bufferevent_enable(req->evcon->bufev, EV_READ); 21 | evhttp_connection_set_closecb(req->evcon, connection_closecb, this); 22 | 23 | evhttp_send_reply_start(req, HTTP_OK, "OK"); 24 | } 25 | 26 | void PresenceSubscriber::close(){ 27 | log_info("%s:%d psub_end", req->remote_host, req->remote_port); 28 | if(req->evcon){ 29 | evhttp_connection_set_closecb(req->evcon, NULL, NULL); 30 | } 31 | evhttp_send_reply_end(req); 32 | serv->psub_end(this); 33 | } 34 | -------------------------------------------------------------------------------- /src/comet/presence.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2014 The icomet Authors. All rights reserved. 3 | Use of this source code is governed by a BSD-style license that can be 4 | found in the LICENSE file. 5 | */ 6 | #ifndef ICOMET_PRESENCE_H 7 | #define ICOMET_PRESENCE_H 8 | 9 | #include 10 | #include 11 | 12 | class Server; 13 | 14 | enum PresenceType{ 15 | PresenceOffline = 0, 16 | PresenceOnline = 1 17 | }; 18 | 19 | class PresenceSubscriber 20 | { 21 | public: 22 | PresenceSubscriber *prev; 23 | PresenceSubscriber *next; 24 | 25 | Server *serv; 26 | struct evhttp_request *req; 27 | 28 | void start(); 29 | void close(); 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/comet/server.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2014 The icomet Authors. All rights reserved. 3 | Use of this source code is governed by a BSD-style license that can be 4 | found in the LICENSE file. 5 | */ 6 | #ifndef ICOMET_SERVER_H 7 | #define ICOMET_SERVER_H 8 | 9 | #include "../build.h" 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "util/list.h" 16 | #include "channel.h" 17 | #include "subscriber.h" 18 | #include "presence.h" 19 | 20 | #define DEFAULT_JSONP_CALLBACK "icomet_cb" 21 | #define CHANNEL_CHECK_INTERVAL 1 22 | 23 | class Server 24 | { 25 | private: 26 | // mapping cname(channel_name) to channel 27 | std::map cname_channels; 28 | 29 | int subscribers; 30 | LinkedList used_channels; 31 | LinkedList free_channels; 32 | 33 | Channel* get_channel_by_name(const std::string &name); 34 | Channel* new_channel(const std::string &cname); 35 | void free_channel(Channel *channel); 36 | 37 | void add_presence(PresenceType type, const std::string &cname); 38 | //void flush_presence(); 39 | 40 | int sub(struct evhttp_request *req, Subscriber::Type sub_type); 41 | public: 42 | enum{ 43 | AUTH_NONE = 0, 44 | AUTH_TOKEN = 1 45 | }; 46 | 47 | int auth; 48 | LinkedList psubs; 49 | 50 | Server(); 51 | ~Server(); 52 | 53 | int check_timeout(); 54 | 55 | int sub_end(Subscriber *sub); 56 | int ping(struct evhttp_request *req); 57 | int poll(struct evhttp_request *req); 58 | int iframe(struct evhttp_request *req); 59 | int stream(struct evhttp_request *req); 60 | int sse(struct evhttp_request *req); 61 | 62 | int pub(struct evhttp_request *req, bool encoded); 63 | int broadcast(struct evhttp_request *req); 64 | int sign(struct evhttp_request *req); 65 | int close(struct evhttp_request *req); 66 | int clear(struct evhttp_request *req); 67 | int info(struct evhttp_request *req); 68 | int check(struct evhttp_request *req); 69 | 70 | int psub(struct evhttp_request *req); 71 | int psub_end(PresenceSubscriber *psub); 72 | 73 | }; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /src/comet/server_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2014 The icomet Authors. All rights reserved. 3 | Use of this source code is governed by a BSD-style license that can be 4 | found in the LICENSE file. 5 | */ 6 | #ifndef ICOMET_SERVER_CONFIG_H 7 | #define ICOMET_SERVER_CONFIG_H 8 | 9 | #include 10 | #include "util/config.h" 11 | 12 | // initialized in icomet-server.cpp 13 | class ServerConfig{ 14 | public: 15 | static int max_channels; 16 | static int max_subscribers_per_channel; 17 | static int polling_timeout; 18 | static int polling_idles; // max idle count to reconnect 19 | static int channel_buffer_size; 20 | static int channel_timeout; 21 | // rename max_channel_idles 22 | static int channel_idles; // max idle count to offline 23 | 24 | /* 25 | static std::string iframe_header; 26 | static std::string iframe_chunk_prefix; 27 | static std::string iframe_chunk_suffix; 28 | */ 29 | 30 | //int load(Config *conf); 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/comet/subscriber.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2014 The icomet Authors. All rights reserved. 3 | Use of this source code is governed by a BSD-style license that can be 4 | found in the LICENSE file. 5 | */ 6 | #ifndef ICOMET_SUBSCRIBER_H 7 | #define ICOMET_SUBSCRIBER_H 8 | 9 | #include "../build.h" 10 | #include 11 | #include 12 | 13 | class Server; 14 | class Channel; 15 | 16 | 17 | class Subscriber{ 18 | public: 19 | enum Type{ 20 | POLL = 0, 21 | STREAM = 1, 22 | IFRAME = 2, 23 | SSE = 3 24 | }; 25 | public: 26 | Subscriber(); 27 | ~Subscriber(); 28 | 29 | Subscriber *prev; 30 | Subscriber *next; 31 | 32 | Channel *channel; 33 | std::string callback; 34 | int type; 35 | int idle; 36 | // 当类型是 data 时的 seq, 和类型是 noop 时用的不是同一套 seq. 37 | int seq_next; 38 | // seq_noop 用于 js long-polling 判断重复连接 39 | int seq_noop; 40 | struct evhttp_request *req; 41 | 42 | void start(); 43 | void close(); 44 | 45 | void noop(); 46 | void send_old_msgs(); 47 | void sync_next_seq(); 48 | 49 | void send_chunk(int seq, const char *type, const char *content); 50 | static void send_error_reply(int sub_type, struct evhttp_request *req, const char *cb, const std::string &cname, const char *type, const char *content); 51 | 52 | private: 53 | static void send_start(int sub_type, struct evhttp_request *req, const char *cb, bool is_arr=false); 54 | static void send_end(int sub_type, struct evhttp_request *req, const char *cb, bool is_arr=false); 55 | static void send_msg(struct evhttp_request *req, const char *type, const std::string &cname, int seq, const char *content, bool is_arr=false); 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/presence/README.md: -------------------------------------------------------------------------------- 1 | Connect to comet servers, subscribe presence activities to build presence table. 2 | 3 | # How to use? 4 | 5 | Write HTTP client to connect to the icomet-server, and subscribe to presence events like: 6 | 7 | curl "http://127.0.0.1:8000/psub" 8 | 9 | The HTTP client will receive endless chunks like this: 10 | 11 | 1 public 12 | 0 public 13 | 14 | * 0: offline event 15 | * 1: online event 16 | * public: channel name 17 | 18 | Online events will be received periodically(since version 0.2.3, configured with ServerConfig::polling_timeout) 19 | 20 | -------------------------------------------------------------------------------- /src/util/Makefile: -------------------------------------------------------------------------------- 1 | include ../../build.mk 2 | 3 | OBJS = log.o config.o bytes.o sorted_set.o 4 | EXES = 5 | 6 | all: ${OBJS} 7 | ar -cru ./libutil.a ${OBJS} 8 | 9 | log.o: log.h log.cpp 10 | ${CXX} ${CFLAGS} -c log.cpp 11 | 12 | config.o: config.h config.cpp 13 | ${CXX} ${CFLAGS} -c config.cpp 14 | 15 | bytes.o: bytes.h bytes.cpp 16 | ${CXX} ${CFLAGS} -c bytes.cpp 17 | 18 | sorted_set.o: sorted_set.h sorted_set.cpp 19 | ${CXX} ${CFLAGS} -c sorted_set.cpp 20 | 21 | clean: 22 | rm -f ${EXES} ${OBJS} *.o *.exe *.a 23 | 24 | -------------------------------------------------------------------------------- /src/util/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2014 The SSDB Authors. All rights reserved. 3 | Use of this source code is governed by a BSD-style license that can be 4 | found in the LICENSE file. 5 | */ 6 | #ifndef UTIL__CONFIG_H 7 | #define UTIL__CONFIG_H 8 | 9 | /* 10 | 语法定义: 11 | 空白字符为 '\t \r\n'(制表符, 空格, 回车, 换行) 12 | 忽略只包含空白字符的行 13 | 有效行以 '\t*' 开头 14 | 注释行以 '\t*#' 开头 15 | key 和 value 之间可以用等号'='或者冒号':'分隔 16 | key 不包含任何空白字符, 两端的空白字符被忽略 17 | value 两端的空白字符被忽略 18 | 配置项可以有包含关系, 用一个 TAB 缩进表示父子关系 19 | 20 | 配置读取: 21 | 用键名获取子配置项 22 | 用斜杠'/'或者句号'.'分隔的配置项路径获取配置项 23 | 把配置项的值作为整形(int)返回 24 | 把配置项的值作为字符串(char *)返回 25 | */ 26 | 27 | #include 28 | #include 29 | 30 | #define CONFIG_MAX_LINE 4096 31 | 32 | /* special filenames: stdin, stdout, stderr */ 33 | class Config{ 34 | private: 35 | Config *parent; 36 | int depth; 37 | 38 | Config* build_key_path(const char *key); 39 | Config* add_child(const char *key, const char *val="", int lineno=0); 40 | const Config* find_child(const char *key) const; 41 | public: 42 | Config(const char *key=NULL, const char *val=NULL); 43 | ~Config(); 44 | 45 | static Config* load(const char *filename); 46 | int save(FILE *fp) const; 47 | int save(const char *filename) const; 48 | 49 | std::vector children; 50 | std::string key; 51 | std::string val; 52 | 53 | Config* set(const char *key, const char *val); 54 | const Config* get(const char *key) const; 55 | int num() const; 56 | int get_num(const char *key) const; 57 | const char* str() const; 58 | const char* get_str(const char *key) const; 59 | 60 | bool is_comment() const{ 61 | return key[0] == '#'; 62 | } 63 | std::string ToString() const{ 64 | return key + ": " + val; 65 | } 66 | }; 67 | 68 | #endif 69 | 70 | /* 71 | 配置文件示例: 72 | 73 | # this is a comment 74 | 75 | author : ideawu 76 | url: http://www.ideawu.net 77 | 78 | proxy : 79 | php = 80 | host = 127.0.0.1 81 | port = 8088 82 | py : 83 | host = 127.0.0.1 84 | port = 8080 85 | 86 | cgi = 87 | pl = /usr/bin/perl 88 | 89 | 应用程序示例: 90 | 91 | #include 92 | #include "config.h" 93 | 94 | int main(int argc, char **argv){ 95 | struct config *cfg, *c; 96 | 97 | cfg = cfg_load_file("cfg_test.conf"); 98 | if(!cfg){ 99 | return 0; 100 | } 101 | 102 | printf("\n"); 103 | printf("proxy.php.host = %s\n", cfg_getstr(cfg, "proxy.php.host")); 104 | printf("proxy.php.port = %d\n", cfg_getnum(cfg, "proxy.php.port")); 105 | printf("cgi.pl = %s\n", cfg_getstr(cfg, "cgi.pl")); 106 | printf("\n"); 107 | 108 | c = cfg_get(cfg, "author"); 109 | printf("author: %s\n", cfg_str(c)); 110 | printf("url: %s\n", cfg_getstr(c, "url")); 111 | printf("\n"); 112 | 113 | cfg_free(cfg); 114 | return 0; 115 | } 116 | 117 | */ 118 | -------------------------------------------------------------------------------- /src/util/daemon.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2014 The SSDB Authors. All rights reserved. 3 | Use of this source code is governed by a BSD-style license that can be 4 | found in the LICENSE file. 5 | */ 6 | #ifndef UTIL_DAEMON_H 7 | #define UTIL_DAEMON_H 8 | 9 | int daemonize(const char *dir=NULL){ 10 | switch(fork()){ 11 | case -1: 12 | return -1; 13 | case 0: 14 | break; 15 | default: 16 | exit(0); 17 | } 18 | if(setsid() == -1){ 19 | exit(0); 20 | } 21 | if(dir != NULL){ 22 | if(chdir(dir) == -1){ 23 | exit(0); 24 | } 25 | } 26 | 27 | if(close(STDIN_FILENO) == -1){ 28 | exit(0); 29 | } 30 | if(close(STDOUT_FILENO) == -1){ 31 | exit(0); 32 | } 33 | if(close(STDERR_FILENO) == -1){ 34 | exit(0); 35 | } 36 | 37 | int fd = open("/dev/null", O_RDWR, 0); 38 | if(fd == -1){ 39 | exit(0); 40 | } 41 | if(dup2(fd, STDIN_FILENO) == -1){ 42 | exit(0); 43 | } 44 | if(dup2(fd, STDOUT_FILENO) == -1){ 45 | exit(0); 46 | } 47 | if(dup2(fd, STDERR_FILENO) == -1){ 48 | exit(0); 49 | } 50 | 51 | return 0; 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/util/file.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2014 The SSDB Authors. All rights reserved. 3 | Use of this source code is governed by a BSD-style license that can be 4 | found in the LICENSE file. 5 | */ 6 | #ifndef UTIL_FILE_H_ 7 | #define UTIL_FILE_H_ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | static inline 15 | bool file_exists(const std::string &filename){ 16 | struct stat st; 17 | return stat(filename.c_str(), &st) == 0; 18 | } 19 | 20 | static inline 21 | bool is_dir(const std::string &filename){ 22 | struct stat st; 23 | if(stat(filename.c_str(), &st) == -1){ 24 | return false; 25 | } 26 | return (bool)S_ISDIR(st.st_mode); 27 | } 28 | 29 | static inline 30 | bool is_file(const std::string &filename){ 31 | struct stat st; 32 | if(stat(filename.c_str(), &st) == -1){ 33 | return false; 34 | } 35 | return (bool)S_ISREG(st.st_mode); 36 | } 37 | 38 | // return number of bytes read 39 | static inline 40 | int file_get_contents(const std::string &filename, std::string *content){ 41 | char buf[8192]; 42 | FILE *fp = fopen(filename.c_str(), "rb"); 43 | if(!fp){ 44 | return -1; 45 | } 46 | int ret = 0; 47 | while(!feof(fp) && !ferror(fp)){ 48 | int n = fread(buf, 1, sizeof(buf), fp); 49 | if(n > 0){ 50 | ret += n; 51 | content->append(buf, n); 52 | } 53 | } 54 | fclose(fp); 55 | return ret; 56 | } 57 | 58 | // return number of bytes written 59 | static inline 60 | int file_put_contents(const std::string &filename, const std::string &content){ 61 | FILE *fp = fopen(filename.c_str(), "wb"); 62 | if(!fp){ 63 | return -1; 64 | } 65 | int ret = fwrite(content.data(), 1, content.size(), fp); 66 | fclose(fp); 67 | return ret == (int)content.size()? ret : -1; 68 | } 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /src/util/ip_filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2014 The SSDB Authors. All rights reserved. 3 | Use of this source code is governed by a BSD-style license that can be 4 | found in the LICENSE file. 5 | */ 6 | #ifndef ICOMET_IPFILTER_H 7 | #define ICOMET_IPFILTER_H 8 | 9 | #include 10 | #include 11 | 12 | // filter ip address 13 | class IpFilter{ 14 | private: 15 | bool deny_all; 16 | bool allow_all; 17 | bool empty_; 18 | std::set deny; 19 | std::set allow; 20 | 21 | bool check_hit(const std::set &m, const std::string &ip){ 22 | if(m.empty()){ 23 | return false; 24 | } 25 | std::set::const_iterator it; 26 | it = m.upper_bound(ip); 27 | if(it == m.end()){ 28 | return false; 29 | } 30 | const std::string &prefix = *it; 31 | 32 | int len = prefix.size() - 1; 33 | if(prefix[len] == '='){ 34 | return prefix.compare(0, len, ip) == 0; 35 | }else if(ip.size() > len){ 36 | return ip.compare(0, len, prefix, 0, len) == 0; 37 | } 38 | return false; 39 | } 40 | 41 | bool is_full_ip(const std::string &ip_prefix){ 42 | int n = 0; 43 | for(int i=0; i<(int)ip_prefix.size(); i++){ 44 | if(ip_prefix[i] == '.'){ 45 | n ++; 46 | } 47 | } 48 | return n == 3; 49 | } 50 | 51 | public: 52 | 53 | IpFilter(){ 54 | deny_all = false; 55 | allow_all = false; 56 | empty_ = true; 57 | } 58 | 59 | bool empty(){ 60 | return empty_; 61 | } 62 | 63 | void add_allow(const std::string &ip_prefix){ 64 | if(ip_prefix == "all" || ip_prefix == "*"){ 65 | allow_all = true; 66 | }else{ 67 | // '@' and '=' is greater than any char in ip 68 | std::string prefix = ip_prefix + (is_full_ip(ip_prefix)? "=" : "@"); 69 | allow.insert(prefix); 70 | } 71 | empty_ = false; 72 | } 73 | 74 | void add_deny(const std::string &ip_prefix){ 75 | if(ip_prefix == "all" || ip_prefix == "*"){ 76 | deny_all = true; 77 | }else{ 78 | // '@' and '=' is greater than any char in ip 79 | std::string prefix = ip_prefix + (is_full_ip(ip_prefix)? "=" : "@"); 80 | deny.insert(prefix); 81 | } 82 | empty_ = false; 83 | } 84 | 85 | bool check_pass(const std::string &ip){ 86 | if(empty_){ 87 | return true; 88 | } 89 | // check specified allow/deny 90 | if(check_hit(allow, ip)){ 91 | return true; 92 | } 93 | if(check_hit(deny, ip)){ 94 | return false; 95 | } 96 | if(deny_all){ 97 | return false; 98 | } 99 | if(allow_all){ 100 | return true; 101 | } 102 | return false; 103 | } 104 | }; 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /src/util/list.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2014 The icomet Authors. All rights reserved. 3 | Use of this source code is governed by a BSD-style license that can be 4 | found in the LICENSE file. 5 | */ 6 | #ifndef UTIL_LIST_H 7 | #define UTIL_LIST_H 8 | 9 | template 10 | class LinkedList{ 11 | public: 12 | class Iterator{ 13 | private: 14 | T p; 15 | public: 16 | friend class LinkedList; 17 | 18 | T next(){ 19 | T ret = p; 20 | if(p){ 21 | p = p->next; 22 | } 23 | return ret; 24 | } 25 | }; 26 | friend class Iterator; 27 | public: 28 | int size; 29 | T head; 30 | T tail; 31 | 32 | LinkedList(){ 33 | size = 0; 34 | head = NULL; 35 | tail = NULL; 36 | } 37 | 38 | Iterator iterator(){ 39 | Iterator it; 40 | it.p = this->head; 41 | return it; 42 | } 43 | 44 | bool empty() const{ 45 | return size == 0; 46 | } 47 | 48 | void remove(T t){ 49 | this->size --; 50 | if(t->prev){ 51 | t->prev->next = t->next; 52 | } 53 | if(t->next){ 54 | t->next->prev = t->prev; 55 | } 56 | if(this->head == t){ 57 | this->head = t->next; 58 | } 59 | if(this->tail == t){ 60 | this->tail = t->prev; 61 | } 62 | } 63 | 64 | T pop_front(){ 65 | T t = this->head; 66 | this->remove(t); 67 | return t; 68 | } 69 | 70 | void push_back(T t){ 71 | this->size ++; 72 | t->prev = this->tail; 73 | t->next = NULL; 74 | if(this->tail){ 75 | this->tail->next = t; 76 | }else{ // both head and tail is empty 77 | this->head = t; 78 | } 79 | this->tail = t; 80 | } 81 | }; 82 | 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /src/util/sorted_set.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2014 The SSDB Authors. All rights reserved. 3 | Use of this source code is governed by a BSD-style license that can be 4 | found in the LICENSE file. 5 | */ 6 | #include "sorted_set.h" 7 | 8 | int SortedSet::size() const{ 9 | return (int)sorted_set.size(); 10 | } 11 | 12 | int SortedSet::add(const std::string &key, int64_t score){ 13 | int ret; 14 | std::map::iterator>::iterator it; 15 | 16 | it = existed.find(key); 17 | if(it == existed.end()){ 18 | // new item 19 | ret = 1; 20 | }else{ 21 | ret = 0; 22 | std::set::iterator it2 = it->second; 23 | const Item &item = *it2; 24 | if(item.score == score){ 25 | // not updated 26 | return 0; 27 | } 28 | // remove existing item 29 | sorted_set.erase(it2); 30 | } 31 | 32 | Item item; 33 | item.key = key; 34 | item.score = score; 35 | 36 | std::pair::iterator, bool> p = sorted_set.insert(item); 37 | existed[key] = p.first; 38 | 39 | return ret; 40 | } 41 | 42 | int SortedSet::del(const std::string &key){ 43 | int ret; 44 | std::map::iterator>::iterator it; 45 | 46 | it = existed.find(key); 47 | if(it == existed.end()){ 48 | // new item 49 | ret = 0; 50 | }else{ 51 | ret = 1; 52 | sorted_set.erase(it->second); 53 | existed.erase(it); 54 | } 55 | return ret; 56 | } 57 | 58 | int SortedSet::front(std::string *key, int64_t *score) const{ 59 | std::set::iterator it2 = sorted_set.begin(); 60 | if(it2 == sorted_set.end()){ 61 | return 0; 62 | } 63 | const Item &item = *it2; 64 | *key = item.key; 65 | if(score){ 66 | *score = item.score; 67 | } 68 | return 1; 69 | } 70 | 71 | int SortedSet::back(std::string *key, int64_t *score) const{ 72 | std::set::reverse_iterator it2 = sorted_set.rbegin(); 73 | if(it2 == sorted_set.rend()){ 74 | return 0; 75 | } 76 | const Item &item = *it2; 77 | *key = item.key; 78 | if(score){ 79 | *score = item.score; 80 | } 81 | return 1; 82 | } 83 | 84 | int64_t SortedSet::max_score() const{ 85 | int64_t score = 0; 86 | std::string key; 87 | this->back(&key, &score); 88 | return score; 89 | } 90 | 91 | 92 | int SortedSet::pop_front(){ 93 | if(sorted_set.empty()){ 94 | return 0; 95 | } 96 | std::set::iterator it = sorted_set.begin(); 97 | const Item &item = *it; 98 | existed.erase(item.key); 99 | sorted_set.erase(it); 100 | return 1; 101 | } 102 | 103 | int SortedSet::pop_back(){ 104 | if(sorted_set.empty()){ 105 | return 0; 106 | } 107 | std::set::iterator it = sorted_set.end(); 108 | it --; 109 | const Item &item = *it; 110 | existed.erase(item.key); 111 | sorted_set.erase(it); 112 | return 1; 113 | } 114 | -------------------------------------------------------------------------------- /src/util/sorted_set.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2014 The SSDB Authors. All rights reserved. 3 | Use of this source code is governed by a BSD-style license that can be 4 | found in the LICENSE file. 5 | */ 6 | #ifndef UTIL_SORTED_SET_H 7 | #define UTIL_SORTED_SET_H 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | class SortedSet 15 | { 16 | public: 17 | bool empty() const{ 18 | return size() == 0; 19 | } 20 | int size() const; 21 | int add(const std::string &key, int64_t score); 22 | // 0: not found, 1: found and deleted 23 | int del(const std::string &key); 24 | // the first item is copied into key if SortedSet not empty 25 | int front(std::string *key, int64_t *score=NULL) const; 26 | int back(std::string *key, int64_t *score=NULL) const; 27 | int64_t max_score() const; 28 | int pop_front(); 29 | int pop_back(); 30 | 31 | /* 32 | class Iterator 33 | { 34 | public: 35 | bool next(); 36 | const std::string& key(); 37 | int64_t score(); 38 | }; 39 | 40 | Iterator begin(); 41 | */ 42 | 43 | private: 44 | struct Item 45 | { 46 | std::string key; 47 | int64_t score; 48 | 49 | bool operator<(const Item& b) const{ 50 | return this->score < b.score 51 | || (this->score == b.score && this->key < b.key); 52 | } 53 | }; 54 | 55 | std::map::iterator> existed; 56 | std::set sorted_set; 57 | }; 58 | 59 | 60 | /* 61 | TODO: HashedWheel 62 | Each item is linked in two list, one is slot list, the other 63 | one is total list. 64 | */ 65 | /* 66 | template 67 | class SortedList 68 | { 69 | public: 70 | void add(const T data, int64_t score); 71 | T front(); 72 | void pop_front(); 73 | 74 | class Item 75 | { 76 | public: 77 | int64_t score; 78 | Item *prev; 79 | Item *next; 80 | //Item *slot_prev; 81 | //Item *slot_next; 82 | T data; 83 | }; 84 | }; 85 | */ 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /src/util/test_sorted_set.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2014 The SSDB Authors. All rights reserved. 3 | Use of this source code is governed by a BSD-style license that can be 4 | found in the LICENSE file. 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "log.h" 11 | #include "sorted_set.h" 12 | 13 | int main(int argc, char **argv){ 14 | SortedSet zset; 15 | 16 | std::vector keys; 17 | for(int i='a'; i<='z'; i++){ 18 | char buf[10]; 19 | snprintf(buf, sizeof(buf), "%c", i); 20 | keys.push_back(buf); 21 | } 22 | 23 | log_debug(""); 24 | srand(time(NULL)); 25 | for(int i=0; i<1000 * 1000; i++){ 26 | std::string &key = keys[rand() % keys.size()]; 27 | zset.add(key, rand()%30 - 15); 28 | } 29 | log_debug(""); 30 | 31 | const std::string *key; 32 | int64_t score; 33 | int n = 0; 34 | while(zset.front(&key, &score)){ 35 | printf("%s : %4lld\n", key->c_str(), score); 36 | zset.pop_front(); 37 | n ++; 38 | } 39 | log_debug("%d", n); 40 | 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /test_icomet.conf: -------------------------------------------------------------------------------- 1 | # icomet config file 2 | 3 | pidfile = ./icomet.pid 4 | 5 | logger: 6 | level: debug 7 | output: stdout 8 | #output: ./logs/log.txt 9 | rotate: 10 | size: 1000000000 11 | 12 | admin: 13 | #listen: 127.0.0.1:8000 14 | listen: 0.0.0.0:8000 15 | 16 | front: 17 | listen: 0.0.0.0:8100 18 | # none|token 19 | auth: none 20 | max_channels: 100000 21 | max_subscribers_per_channel: 16 22 | # number of messages buffered 23 | channel_buffer_size: 10 24 | # in seconds 25 | channel_timeout: 30 26 | # the idle time to send noop message, in seconds 27 | polling_timeout: 10 28 | 29 | 30 | -------------------------------------------------------------------------------- /tools/Makefile: -------------------------------------------------------------------------------- 1 | include ../build.mk 2 | 3 | 4 | all: 5 | $(CXX) -o ./benchmark \ 6 | $(CFLAGS) \ 7 | -I../src \ 8 | ../src/util/*.o benchmark.cpp \ 9 | $(LIBEVENT_PATH)/.libs/libevent.a \ 10 | $(CLIBS) 11 | 12 | clean: 13 | rm -f *.o 14 | -------------------------------------------------------------------------------- /tools/benchmark.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "util/log.h" 11 | 12 | #define MAX_BIND_PORTS 1 13 | 14 | void chunk_cb(struct evhttp_request *req, void *arg){ 15 | static int num = 0; 16 | if(++num % 1000 == 1){ 17 | char buf[1024]; 18 | int s = evbuffer_remove(req->input_buffer, &buf, sizeof(buf) - 1); 19 | buf[s] = '\0'; 20 | printf("< %s", buf); 21 | } 22 | } 23 | 24 | void http_request_done(struct evhttp_request *req, void *arg){ 25 | static int num = 0; 26 | if(++num % 1000 == 1){ 27 | log_debug("request done %d", num); 28 | } 29 | } 30 | 31 | int main(int argc, char **argv){ 32 | if(argc < 3){ 33 | printf("Usage: %s ip port\n", argv[0]); 34 | exit(0); 35 | } 36 | const char *host = argv[1]; 37 | int port = atoi(argv[2]); 38 | 39 | srand(time(NULL)); 40 | signal(SIGPIPE, SIG_IGN); 41 | 42 | struct event_base *base = event_base_new(); 43 | if(!base){ 44 | fprintf(stderr, "event_base_new() error!\n"); 45 | exit(0); 46 | } 47 | 48 | struct evhttp_connection *conn; 49 | struct evhttp_request *req; 50 | 51 | int num = 0; 52 | while(1){ 53 | if(num % 100000 == 0){ 54 | printf("press Enter to continue: "); 55 | getchar(); 56 | } 57 | if(num % 1000 == 1){ 58 | log_debug("sub: %d", num); 59 | } 60 | conn = evhttp_connection_base_new(base, NULL, host, port + num % MAX_BIND_PORTS); 61 | req = evhttp_request_new(http_request_done, NULL); 62 | evhttp_request_set_chunked_cb(req, chunk_cb); 63 | 64 | char buf[128]; 65 | snprintf(buf, sizeof(buf), "/sub?cname=%d", rand()); 66 | evhttp_make_request(conn, req, EVHTTP_REQ_GET, buf); 67 | evhttp_connection_set_timeout(req->evcon, 864000); 68 | event_base_loop(base, EVLOOP_NONBLOCK); 69 | 70 | num ++; 71 | usleep(1 * 1000); 72 | } 73 | 74 | event_base_dispatch(base); 75 | 76 | log_debug("quit"); 77 | return 0; 78 | } 79 | 80 | -------------------------------------------------------------------------------- /version: -------------------------------------------------------------------------------- 1 | 0.2.5 2 | --------------------------------------------------------------------------------