├── tests
├── tmp
│ └── .gitignore
├── unit
│ ├── introspection.tcl
│ ├── printver.tcl
│ ├── type
│ │ ├── list-common.tcl
│ │ ├── list-2.tcl
│ │ └── list-3.tcl
│ ├── auth.tcl
│ ├── quit.tcl
│ ├── slowlog.tcl
│ └── protocol.tcl
├── support
│ └── tmpfile.tcl
└── integration
│ ├── replication-2.tcl
│ ├── replication-3.tcl
│ ├── aof-race.tcl
│ └── replication.tcl
├── deps
├── jemalloc
│ ├── config.stamp.in
│ ├── test
│ │ ├── bitmap.exp
│ │ ├── mremap.exp
│ │ ├── rallocm.exp
│ │ ├── allocated.exp
│ │ ├── thread_arena.exp
│ │ ├── jemalloc_test.h.in
│ │ ├── allocm.exp
│ │ ├── posix_memalign.exp
│ │ ├── mremap.c
│ │ ├── thread_arena.c
│ │ └── posix_memalign.c
│ ├── VERSION
│ ├── src
│ │ ├── mb.c
│ │ ├── hash.c
│ │ ├── atomic.c
│ │ ├── extent.c
│ │ ├── rtree.c
│ │ ├── mutex.c
│ │ ├── bitmap.c
│ │ └── base.c
│ ├── doc
│ │ ├── jemalloc.html
│ │ ├── html.xsl.in
│ │ ├── manpages.xsl.in
│ │ └── stylesheet.xsl
│ ├── autogen.sh
│ ├── .gitignore
│ ├── README
│ ├── include
│ │ └── jemalloc
│ │ │ ├── internal
│ │ │ ├── zone.h
│ │ │ ├── chunk_mmap.h
│ │ │ ├── base.h
│ │ │ ├── chunk_dss.h
│ │ │ ├── chunk_swap.h
│ │ │ ├── huge.h
│ │ │ ├── extent.h
│ │ │ ├── hash.h
│ │ │ ├── prn.h
│ │ │ ├── chunk.h
│ │ │ ├── mutex.h
│ │ │ ├── qr.h
│ │ │ ├── ql.h
│ │ │ ├── mb.h
│ │ │ └── ckh.h
│ │ │ └── jemalloc.h.in
│ └── COPYING
├── linenoise
│ ├── .gitignore
│ ├── Makefile
│ ├── example.c
│ ├── linenoise.h
│ └── README.markdown
├── hiredis
│ ├── TODO
│ ├── .gitignore
│ ├── fmacros.h
│ ├── COPYING
│ ├── example-libev.c
│ ├── example-libevent.c
│ ├── example-ae.c
│ ├── util.h
│ ├── example.c
│ ├── net.h
│ └── adapters
│ │ ├── libevent.h
│ │ └── ae.h
├── lua
│ ├── etc
│ │ ├── lua.ico
│ │ ├── lua.hpp
│ │ ├── lua.pc
│ │ ├── all.c
│ │ ├── min.c
│ │ ├── Makefile
│ │ ├── strict.lua
│ │ ├── README
│ │ ├── luavs.bat
│ │ └── noparser.c
│ ├── doc
│ │ ├── cover.png
│ │ ├── logo.gif
│ │ ├── amazon.gif
│ │ ├── contents.html
│ │ ├── manual.css
│ │ ├── lua.css
│ │ └── readme.html
│ ├── test
│ │ ├── life.lua
│ │ ├── echo.lua
│ │ ├── hello.lua
│ │ ├── printf.lua
│ │ ├── env.lua
│ │ ├── luac.lua
│ │ ├── fibfor.lua
│ │ ├── readonly.lua
│ │ ├── table.lua
│ │ ├── cf.lua
│ │ ├── xd.lua
│ │ ├── globals.lua
│ │ ├── bisect.lua
│ │ ├── fib.lua
│ │ ├── factorial.lua
│ │ ├── sieve.lua
│ │ ├── trace-calls.lua
│ │ ├── trace-globals.lua
│ │ ├── README
│ │ └── sort.lua
│ ├── src
│ │ ├── lapi.h
│ │ ├── linit.c
│ │ ├── lstring.h
│ │ ├── lundump.h
│ │ ├── ldebug.h
│ │ ├── ltm.h
│ │ ├── lualib.h
│ │ ├── lfunc.h
│ │ ├── lvm.h
│ │ ├── ltable.h
│ │ ├── lmem.h
│ │ ├── lzio.h
│ │ ├── ltm.c
│ │ ├── lzio.c
│ │ ├── ldo.h
│ │ ├── llex.h
│ │ ├── lmem.c
│ │ ├── lparser.h
│ │ ├── llimits.h
│ │ └── lcode.h
│ ├── README
│ └── COPYRIGHT
└── Makefile
├── src
├── version.h
├── rand.h
├── valgrind.sup
├── fmacros.h
├── release.c
├── bio.h
├── pqsort.h
├── util.h
├── mkreleasehdr.sh
├── endian.h
├── sha1.h
├── slowlog.h
├── intset.h
├── solarisfixes.h
├── ziplist.h
├── rio.h
├── asciilogo.h
├── endian.c
├── ae_select.c
├── testhelp.h
├── zipmap.h
├── anet.h
├── config.h
└── zmalloc.h
├── BUGS
├── Makefile
├── runtest
├── utils
├── mkrelease.sh
├── whatisdoing.sh
├── build-static-symbols.tcl
├── redis_init_script.tpl
├── redis_init_script
├── redis-sha1.rb
├── redis-copy.rb
└── generate-command-help.rb
├── .gitignore
├── CONTRIBUTING
├── INSTALL
├── COPYING
└── TODO
/tests/tmp/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 |
--------------------------------------------------------------------------------
/deps/jemalloc/config.stamp.in:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/deps/linenoise/.gitignore:
--------------------------------------------------------------------------------
1 | linenoise_example*
2 |
--------------------------------------------------------------------------------
/src/version.h:
--------------------------------------------------------------------------------
1 | #define REDIS_VERSION "2.9.2"
2 |
--------------------------------------------------------------------------------
/deps/jemalloc/test/bitmap.exp:
--------------------------------------------------------------------------------
1 | Test begin
2 | Test end
3 |
--------------------------------------------------------------------------------
/deps/jemalloc/test/mremap.exp:
--------------------------------------------------------------------------------
1 | Test begin
2 | Test end
3 |
--------------------------------------------------------------------------------
/deps/jemalloc/test/rallocm.exp:
--------------------------------------------------------------------------------
1 | Test begin
2 | Test end
3 |
--------------------------------------------------------------------------------
/BUGS:
--------------------------------------------------------------------------------
1 | Plese check https://github.com/antirez/redis/issues
2 |
--------------------------------------------------------------------------------
/deps/jemalloc/test/allocated.exp:
--------------------------------------------------------------------------------
1 | Test begin
2 | Test end
3 |
--------------------------------------------------------------------------------
/deps/jemalloc/test/thread_arena.exp:
--------------------------------------------------------------------------------
1 | Test begin
2 | Test end
3 |
--------------------------------------------------------------------------------
/deps/jemalloc/VERSION:
--------------------------------------------------------------------------------
1 | 2.2.5-0-gfc1bb70e5f0d9a58b39efa39cc549b5af5104760
2 |
--------------------------------------------------------------------------------
/deps/hiredis/TODO:
--------------------------------------------------------------------------------
1 | - add redisCommandVector()
2 | - add support for pipelining
3 |
--------------------------------------------------------------------------------
/deps/lua/etc/lua.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pl/redis/unstable/deps/lua/etc/lua.ico
--------------------------------------------------------------------------------
/deps/lua/doc/cover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pl/redis/unstable/deps/lua/doc/cover.png
--------------------------------------------------------------------------------
/deps/lua/doc/logo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pl/redis/unstable/deps/lua/doc/logo.gif
--------------------------------------------------------------------------------
/deps/lua/test/life.lua:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pl/redis/unstable/deps/lua/test/life.lua
--------------------------------------------------------------------------------
/deps/lua/doc/amazon.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pl/redis/unstable/deps/lua/doc/amazon.gif
--------------------------------------------------------------------------------
/deps/jemalloc/src/mb.c:
--------------------------------------------------------------------------------
1 | #define JEMALLOC_MB_C_
2 | #include "jemalloc/internal/jemalloc_internal.h"
3 |
--------------------------------------------------------------------------------
/deps/lua/doc/contents.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pl/redis/unstable/deps/lua/doc/contents.html
--------------------------------------------------------------------------------
/deps/hiredis/.gitignore:
--------------------------------------------------------------------------------
1 | /hiredis-test
2 | /hiredis-example*
3 | /*.o
4 | /*.so
5 | /*.dylib
6 | /*.a
7 |
--------------------------------------------------------------------------------
/deps/jemalloc/src/hash.c:
--------------------------------------------------------------------------------
1 | #define JEMALLOC_HASH_C_
2 | #include "jemalloc/internal/jemalloc_internal.h"
3 |
--------------------------------------------------------------------------------
/deps/jemalloc/doc/jemalloc.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pl/redis/unstable/deps/jemalloc/doc/jemalloc.html
--------------------------------------------------------------------------------
/deps/jemalloc/src/atomic.c:
--------------------------------------------------------------------------------
1 | #define JEMALLOC_ATOMIC_C_
2 | #include "jemalloc/internal/jemalloc_internal.h"
3 |
--------------------------------------------------------------------------------
/deps/lua/test/echo.lua:
--------------------------------------------------------------------------------
1 | -- echo command line arguments
2 |
3 | for i=0,table.getn(arg) do
4 | print(i,arg[i])
5 | end
6 |
--------------------------------------------------------------------------------
/deps/lua/test/hello.lua:
--------------------------------------------------------------------------------
1 | -- the first program in every language
2 |
3 | io.write("Hello world, from ",_VERSION,"!\n")
4 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | # Top level makefile, the real shit is at src/Makefile
2 |
3 | default: all
4 |
5 | .DEFAULT:
6 | cd src && $(MAKE) $@
7 |
8 |
--------------------------------------------------------------------------------
/src/rand.h:
--------------------------------------------------------------------------------
1 | #ifndef REDIS_RANDOM_H
2 | #define REDIS_RANDOM_H
3 |
4 | int32_t redisLrand48();
5 | void redisSrand48(int32_t seedval);
6 |
7 | #define REDIS_LRAND48_MAX INT32_MAX
8 |
9 | #endif
10 |
--------------------------------------------------------------------------------
/deps/lua/doc/manual.css:
--------------------------------------------------------------------------------
1 | h3 code {
2 | font-family: inherit ;
3 | }
4 |
5 | pre {
6 | font-size: 105% ;
7 | }
8 |
9 | span.apii {
10 | float: right ;
11 | font-family: inherit ;
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/runtest:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | TCL=tclsh8.5
3 | which $TCL
4 | if [ "$?" != "0" ]
5 | then
6 | echo "You need '$TCL' in order to run the Redis test"
7 | exit 1
8 | fi
9 | $TCL tests/test_helper.tcl $*
10 |
--------------------------------------------------------------------------------
/deps/lua/test/printf.lua:
--------------------------------------------------------------------------------
1 | -- an implementation of printf
2 |
3 | function printf(...)
4 | io.write(string.format(...))
5 | end
6 |
7 | printf("Hello %s from %s on %s\n",os.getenv"USER" or "there",_VERSION,os.date())
8 |
--------------------------------------------------------------------------------
/deps/lua/test/env.lua:
--------------------------------------------------------------------------------
1 | -- read environment variables as if they were global variables
2 |
3 | local f=function (t,i) return os.getenv(i) end
4 | setmetatable(getfenv(),{__index=f})
5 |
6 | -- an example
7 | print(a,USER,PATH)
8 |
--------------------------------------------------------------------------------
/tests/unit/introspection.tcl:
--------------------------------------------------------------------------------
1 | start_server {tags {"introspection"}} {
2 | test {CLIENT LIST} {
3 | r client list
4 | } {*addr=*:* fd=* idle=* flags=N db=9 sub=0 psub=0 qbuf=0 obl=0 oll=0 events=r cmd=client*}
5 | }
6 |
--------------------------------------------------------------------------------
/tests/unit/printver.tcl:
--------------------------------------------------------------------------------
1 | start_server {} {
2 | set i [r info]
3 | regexp {redis_version:(.*?)\r\n} $i - version
4 | regexp {redis_git_sha1:(.*?)\r\n} $i - sha1
5 | puts "Testing Redis version $version ($sha1)"
6 | }
7 |
--------------------------------------------------------------------------------
/deps/jemalloc/doc/html.xsl.in:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/deps/jemalloc/doc/manpages.xsl.in:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/deps/lua/etc/lua.hpp:
--------------------------------------------------------------------------------
1 | // lua.hpp
2 | // Lua header files for C++
3 | // <> not supplied automatically because Lua also compiles as C++
4 |
5 | extern "C" {
6 | #include "lua.h"
7 | #include "lualib.h"
8 | #include "lauxlib.h"
9 | }
10 |
--------------------------------------------------------------------------------
/deps/hiredis/fmacros.h:
--------------------------------------------------------------------------------
1 | #ifndef __HIREDIS_FMACRO_H
2 | #define __HIREDIS_FMACRO_H
3 |
4 | #ifndef _BSD_SOURCE
5 | #define _BSD_SOURCE
6 | #endif
7 |
8 | #ifdef __linux__
9 | #define _XOPEN_SOURCE 700
10 | #else
11 | #define _XOPEN_SOURCE
12 | #endif
13 |
14 | #endif
15 |
--------------------------------------------------------------------------------
/deps/lua/test/luac.lua:
--------------------------------------------------------------------------------
1 | -- bare-bones luac in Lua
2 | -- usage: lua luac.lua file.lua
3 |
4 | assert(arg[1]~=nil and arg[2]==nil,"usage: lua luac.lua file.lua")
5 | f=assert(io.open("luac.out","wb"))
6 | assert(f:write(string.dump(assert(loadfile(arg[1])))))
7 | assert(f:close())
8 |
--------------------------------------------------------------------------------
/tests/unit/type/list-common.tcl:
--------------------------------------------------------------------------------
1 | # We need a value larger than list-max-ziplist-value to make sure
2 | # the list has the right encoding when it is swapped in again.
3 | array set largevalue {}
4 | set largevalue(ziplist) "hello"
5 | set largevalue(linkedlist) [string repeat "hello" 4]
6 |
--------------------------------------------------------------------------------
/deps/jemalloc/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 |
--------------------------------------------------------------------------------
/deps/linenoise/Makefile:
--------------------------------------------------------------------------------
1 | linenoise_example: linenoise.h linenoise.c
2 |
3 | linenoise_example: linenoise.o example.o
4 | $(CC) $(ARCH) -Wall -W -Os -g -o linenoise_example linenoise.o example.o
5 |
6 | .c.o:
7 | $(CC) $(ARCH) -c -Wall -W -Os -g $<
8 |
9 | clean:
10 | rm -f linenoise_example *.o
11 |
--------------------------------------------------------------------------------
/src/valgrind.sup:
--------------------------------------------------------------------------------
1 | {
2 |
3 | Memcheck:Cond
4 | fun:lzf_compress
5 | }
6 |
7 | {
8 |
9 | Memcheck:Value4
10 | fun:lzf_compress
11 | }
12 |
13 | {
14 |
15 | Memcheck:Value8
16 | fun:lzf_compress
17 | }
18 |
--------------------------------------------------------------------------------
/src/fmacros.h:
--------------------------------------------------------------------------------
1 | #ifndef _REDIS_FMACRO_H
2 | #define _REDIS_FMACRO_H
3 |
4 | #define _BSD_SOURCE
5 |
6 | #if defined(__linux__) || defined(__OpenBSD__)
7 | #define _XOPEN_SOURCE 700
8 | #else
9 | #define _XOPEN_SOURCE
10 | #endif
11 |
12 | #define _LARGEFILE_SOURCE
13 | #define _FILE_OFFSET_BITS 64
14 |
15 | #endif
16 |
--------------------------------------------------------------------------------
/deps/lua/test/fibfor.lua:
--------------------------------------------------------------------------------
1 | -- example of for with generator functions
2 |
3 | function generatefib (n)
4 | return coroutine.wrap(function ()
5 | local a,b = 1, 1
6 | while a <= n do
7 | coroutine.yield(a)
8 | a, b = b, a+b
9 | end
10 | end)
11 | end
12 |
13 | for i in generatefib(1000) do print(i) end
14 |
--------------------------------------------------------------------------------
/deps/lua/test/readonly.lua:
--------------------------------------------------------------------------------
1 | -- make global variables readonly
2 |
3 | local f=function (t,i) error("cannot redefine global variable `"..i.."'",2) end
4 | local g={}
5 | local G=getfenv()
6 | setmetatable(g,{__index=G,__newindex=f})
7 | setfenv(1,g)
8 |
9 | -- an example
10 | rawset(g,"x",3)
11 | x=2
12 | y=1 -- cannot redefine `y'
13 |
--------------------------------------------------------------------------------
/deps/jemalloc/doc/stylesheet.xsl:
--------------------------------------------------------------------------------
1 |
2 | ansi
3 |
4 |
5 | ""
6 |
7 |
8 |
--------------------------------------------------------------------------------
/deps/lua/src/lapi.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Auxiliary functions from Lua API
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lapi_h
8 | #define lapi_h
9 |
10 |
11 | #include "lobject.h"
12 |
13 |
14 | LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o);
15 |
16 | #endif
17 |
--------------------------------------------------------------------------------
/deps/lua/test/table.lua:
--------------------------------------------------------------------------------
1 | -- make table, grouping all data for the same item
2 | -- input is 2 columns (item, data)
3 |
4 | local A
5 | while 1 do
6 | local l=io.read()
7 | if l==nil then break end
8 | local _,_,a,b=string.find(l,'"?([_%w]+)"?%s*(.*)$')
9 | if a~=A then A=a io.write("\n",a,":") end
10 | io.write(" ",b)
11 | end
12 | io.write("\n")
13 |
--------------------------------------------------------------------------------
/deps/jemalloc/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 |
--------------------------------------------------------------------------------
/utils/mkrelease.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | if [ $# != "1" ]
3 | then
4 | echo "Usage: ./mkrelease.sh "
5 | exit 1
6 | fi
7 |
8 | TAG=$1
9 | TARNAME="redis-${TAG}.tar"
10 | echo "Generating /tmp/${TARNAME}"
11 | git archive $TAG --prefix redis-${TAG}/ > /tmp/$TARNAME || exit 1
12 | echo "Gizipping the archive"
13 | rm -f /tmp/$TARNAME.gz
14 | gzip -9 /tmp/$TARNAME
15 |
--------------------------------------------------------------------------------
/deps/lua/test/cf.lua:
--------------------------------------------------------------------------------
1 | -- temperature conversion table (celsius to farenheit)
2 |
3 | for c0=-20,50-1,10 do
4 | io.write("C ")
5 | for c=c0,c0+10-1 do
6 | io.write(string.format("%3.0f ",c))
7 | end
8 | io.write("\n")
9 |
10 | io.write("F ")
11 | for c=c0,c0+10-1 do
12 | f=(9/5)*c+32
13 | io.write(string.format("%3.0f ",f))
14 | end
15 | io.write("\n\n")
16 | end
17 |
--------------------------------------------------------------------------------
/src/release.c:
--------------------------------------------------------------------------------
1 | /* Every time the Redis Git SHA1 or Dirty status changes only this file
2 | * small file is recompiled, as we access this information in all the other
3 | * files using this functions. */
4 |
5 | #include "release.h"
6 |
7 | char *redisGitSHA1(void) {
8 | return REDIS_GIT_SHA1;
9 | }
10 |
11 | char *redisGitDirty(void) {
12 | return REDIS_GIT_DIRTY;
13 | }
14 |
--------------------------------------------------------------------------------
/deps/lua/test/xd.lua:
--------------------------------------------------------------------------------
1 | -- hex dump
2 | -- usage: lua xd.lua < file
3 |
4 | local offset=0
5 | while true do
6 | local s=io.read(16)
7 | if s==nil then return end
8 | io.write(string.format("%08X ",offset))
9 | string.gsub(s,"(.)",
10 | function (c) io.write(string.format("%02X ",string.byte(c))) end)
11 | io.write(string.rep(" ",3*(16-string.len(s))))
12 | io.write(" ",string.gsub(s,"%c","."),"\n")
13 | offset=offset+16
14 | end
15 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .*.swp
2 | *.o
3 | *.rdb
4 | *.log
5 | redis-cli
6 | redis-server
7 | redis-benchmark
8 | redis-check-dump
9 | redis-check-aof
10 | doc-tools
11 | release
12 | misc/*
13 | src/release.h
14 | appendonly.aof
15 | SHORT_TERM_TODO
16 | release.h
17 | src/transfer.sh
18 | src/configs
19 | src/redis-server.dSYM
20 | redis.ds
21 | src/redis.conf
22 | deps/lua/src/lua
23 | deps/lua/src/luac
24 | deps/lua/src/liblua.a
25 | .make-*
26 | .prerequisites
27 |
--------------------------------------------------------------------------------
/tests/support/tmpfile.tcl:
--------------------------------------------------------------------------------
1 | set ::tmpcounter 0
2 | set ::tmproot "./tests/tmp"
3 | file mkdir $::tmproot
4 |
5 | # returns a dirname unique to this process to write to
6 | proc tmpdir {basename} {
7 | set dir [file join $::tmproot $basename.[pid].[incr ::tmpcounter]]
8 | file mkdir $dir
9 | set _ $dir
10 | }
11 |
12 | # return a filename unique to this process to write to
13 | proc tmpfile {basename} {
14 | file join $::tmproot $basename.[pid].[incr ::tmpcounter]
15 | }
16 |
--------------------------------------------------------------------------------
/deps/lua/test/globals.lua:
--------------------------------------------------------------------------------
1 | -- reads luac listings and reports global variable usage
2 | -- lines where a global is written to are marked with "*"
3 | -- typical usage: luac -p -l file.lua | lua globals.lua | sort | lua table.lua
4 |
5 | while 1 do
6 | local s=io.read()
7 | if s==nil then break end
8 | local ok,_,l,op,g=string.find(s,"%[%-?(%d*)%]%s*([GS])ETGLOBAL.-;%s+(.*)$")
9 | if ok then
10 | if op=="S" then op="*" else op="" end
11 | io.write(g,"\t",l,op,"\n")
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/src/bio.h:
--------------------------------------------------------------------------------
1 | /* Exported API */
2 | void bioInit(void);
3 | void bioCreateBackgroundJob(int type, void *arg1, void *arg2, void *arg3);
4 | unsigned long long bioPendingJobsOfType(int type);
5 | void bioWaitPendingJobsLE(int type, unsigned long long num);
6 | time_t bioOlderJobOfType(int type);
7 |
8 | /* Background job opcodes */
9 | #define REDIS_BIO_CLOSE_FILE 0 /* Deferred close(2) syscall. */
10 | #define REDIS_BIO_AOF_FSYNC 1 /* Deferred AOF fsync. */
11 | #define REDIS_BIO_NUM_OPS 2
12 |
--------------------------------------------------------------------------------
/src/pqsort.h:
--------------------------------------------------------------------------------
1 | /* The following is the NetBSD libc qsort implementation modified in order to
2 | * support partial sorting of ranges for Redis.
3 | *
4 | * Copyright(C) 2009-2010 Salvatore Sanfilippo. All rights reserved.
5 | *
6 | * See the pqsort.c file for the original copyright notice. */
7 |
8 | #ifndef __PQSORT_H
9 | #define __PQSORT_H
10 |
11 | void
12 | pqsort(void *a, size_t n, size_t es,
13 | int (*cmp) (const void *, const void *), size_t lrange, size_t rrange);
14 |
15 | #endif
16 |
--------------------------------------------------------------------------------
/src/util.h:
--------------------------------------------------------------------------------
1 | #ifndef __REDIS_UTIL_H
2 | #define __REDIS_UTIL_H
3 |
4 | int stringmatchlen(const char *p, int plen, const char *s, int slen, int nocase);
5 | int stringmatch(const char *p, const char *s, int nocase);
6 | long long memtoll(const char *p, int *err);
7 | int ll2string(char *s, size_t len, long long value);
8 | int string2ll(char *s, size_t slen, long long *value);
9 | int string2l(char *s, size_t slen, long *value);
10 | int d2string(char *buf, size_t len, double value);
11 |
12 | #endif
13 |
--------------------------------------------------------------------------------
/deps/jemalloc/.gitignore:
--------------------------------------------------------------------------------
1 | /autom4te.cache/
2 | /config.stamp
3 | /config.log
4 | /config.status
5 | /configure
6 | /doc/html.xsl
7 | /doc/manpages.xsl
8 | /doc/jemalloc.xml
9 | /doc/jemalloc.html
10 | /doc/jemalloc.3
11 | /lib/
12 | /Makefile
13 | /include/jemalloc/internal/jemalloc_internal\.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-z]*
21 | !test/*.c
22 | !test/*.exp
23 | /VERSION
24 |
--------------------------------------------------------------------------------
/src/mkreleasehdr.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | GIT_SHA1=`(git show-ref --head --hash=8 2> /dev/null || echo 00000000) | head -n1`
3 | GIT_DIRTY=`git diff 2> /dev/null | wc -l`
4 | test -f release.h || touch release.h
5 | (cat release.h | grep SHA1 | grep $GIT_SHA1) && \
6 | (cat release.h | grep DIRTY | grep $GIT_DIRTY) && exit 0 # Already uptodate
7 | echo "#define REDIS_GIT_SHA1 \"$GIT_SHA1\"" > release.h
8 | echo "#define REDIS_GIT_DIRTY \"$GIT_DIRTY\"" >> release.h
9 | touch release.c # Force recompile of release.c
10 |
--------------------------------------------------------------------------------
/utils/whatisdoing.sh:
--------------------------------------------------------------------------------
1 | # This script is from http://poormansprofiler.org/
2 |
3 | #!/bin/bash
4 | nsamples=1
5 | sleeptime=0
6 | pid=$(pidof redis-server)
7 |
8 | for x in $(seq 1 $nsamples)
9 | do
10 | gdb -ex "set pagination 0" -ex "thread apply all bt" -batch -p $pid
11 | sleep $sleeptime
12 | done | \
13 | awk '
14 | BEGIN { s = ""; }
15 | /Thread/ { print s; s = ""; }
16 | /^\#/ { if (s != "" ) { s = s "," $4} else { s = $4 } }
17 | END { print s }' | \
18 | sort | uniq -c | sort -r -n -k 1,1
19 |
--------------------------------------------------------------------------------
/deps/jemalloc/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 |
--------------------------------------------------------------------------------
/src/endian.h:
--------------------------------------------------------------------------------
1 | #ifndef __ENDIAN_H
2 | #define __ENDIAN_H
3 |
4 | void memrev16(void *p);
5 | void memrev32(void *p);
6 | void memrev64(void *p);
7 |
8 | /* variants of the function doing the actual convertion only if the target
9 | * host is big endian */
10 | #if (BYTE_ORDER == LITTLE_ENDIAN)
11 | #define memrev16ifbe(p)
12 | #define memrev32ifbe(p)
13 | #define memrev64ifbe(p)
14 | #else
15 | #define memrev16ifbe(p) memrev16(p)
16 | #define memrev32ifbe(p) memrev32(p)
17 | #define memrev64ifbe(p) memrev64(p)
18 | #endif
19 |
20 | #endif
21 |
--------------------------------------------------------------------------------
/deps/jemalloc/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 |
--------------------------------------------------------------------------------
/src/sha1.h:
--------------------------------------------------------------------------------
1 | /* ================ sha1.h ================ */
2 | /*
3 | SHA-1 in C
4 | By Steve Reid
5 | 100% Public Domain
6 | */
7 |
8 | typedef struct {
9 | u_int32_t state[5];
10 | u_int32_t count[2];
11 | unsigned char buffer[64];
12 | } SHA1_CTX;
13 |
14 | void SHA1Transform(u_int32_t state[5], const unsigned char buffer[64]);
15 | void SHA1Init(SHA1_CTX* context);
16 | void SHA1Update(SHA1_CTX* context, const unsigned char* data, u_int32_t len);
17 | void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
18 |
--------------------------------------------------------------------------------
/src/slowlog.h:
--------------------------------------------------------------------------------
1 | /* This structure defines an entry inside the slow log list */
2 | typedef struct slowlogEntry {
3 | robj **argv;
4 | int argc;
5 | long long id; /* Unique entry identifier. */
6 | long long duration; /* Time spent by the query, in nanoseconds. */
7 | time_t time; /* Unix time at which the query was executed. */
8 | } slowlogEntry;
9 |
10 | /* Exported API */
11 | void slowlogInit(void);
12 | void slowlogPushEntryIfNeeded(robj **argv, int argc, long long duration);
13 |
14 | /* Exported commands */
15 | void slowlogCommand(redisClient *c);
16 |
--------------------------------------------------------------------------------
/src/intset.h:
--------------------------------------------------------------------------------
1 | #ifndef __INTSET_H
2 | #define __INTSET_H
3 | #include
4 |
5 | typedef struct intset {
6 | uint32_t encoding;
7 | uint32_t length;
8 | int8_t contents[];
9 | } intset;
10 |
11 | intset *intsetNew(void);
12 | intset *intsetAdd(intset *is, int64_t value, uint8_t *success);
13 | intset *intsetRemove(intset *is, int64_t value, int *success);
14 | uint8_t intsetFind(intset *is, int64_t value);
15 | int64_t intsetRandom(intset *is);
16 | uint8_t intsetGet(intset *is, uint32_t pos, int64_t *value);
17 | uint32_t intsetLen(intset *is);
18 | size_t intsetBlobLen(intset *is);
19 |
20 | #endif // __INTSET_H
21 |
--------------------------------------------------------------------------------
/src/solarisfixes.h:
--------------------------------------------------------------------------------
1 | /* Solaris specific fixes */
2 |
3 | #if defined(__GNUC__)
4 | #include
5 | #undef isnan
6 | #define isnan(x) \
7 | __extension__({ __typeof (x) __x_a = (x); \
8 | __builtin_expect(__x_a != __x_a, 0); })
9 |
10 | #undef isfinite
11 | #define isfinite(x) \
12 | __extension__ ({ __typeof (x) __x_f = (x); \
13 | __builtin_expect(!isnan(__x_f - __x_f), 1); })
14 |
15 | #undef isinf
16 | #define isinf(x) \
17 | __extension__ ({ __typeof (x) __x_i = (x); \
18 | __builtin_expect(!isnan(__x_i) && !isfinite(__x_i), 0); })
19 |
20 | #define u_int uint
21 | #define u_int32_t uint32_t
22 | #endif /* __GNUC__ */
23 |
--------------------------------------------------------------------------------
/utils/build-static-symbols.tcl:
--------------------------------------------------------------------------------
1 | # Build a symbol table for static symbols of redis.c
2 | # Useful to get stack traces on segfault without a debugger. See redis.c
3 | # for more information.
4 | #
5 | # Copyright(C) 2009 Salvatore Sanfilippo, under the BSD license.
6 |
7 | set fd [open redis.c]
8 | set symlist {}
9 | while {[gets $fd line] != -1} {
10 | if {[regexp {^static +[A-z0-9]+[ *]+([A-z0-9]*)\(} $line - sym]} {
11 | lappend symlist $sym
12 | }
13 | }
14 | set symlist [lsort -unique $symlist]
15 | puts "static struct redisFunctionSym symsTable\[\] = {"
16 | foreach sym $symlist {
17 | puts "{\"$sym\",(unsigned long)$sym},"
18 | }
19 | puts "{NULL,0}"
20 | puts "};"
21 |
22 | close $fd
23 |
--------------------------------------------------------------------------------
/CONTRIBUTING:
--------------------------------------------------------------------------------
1 | 1. Enter irc.freenode.org #redis and start talking with 'antirez' and/or 'pietern' to check if there is interest for such a feature and to understand the probability of it being merged. We'll try hard to keep Redis simple... so you'll likely encounter high resistance.
2 |
3 | 2. Drop a message to the Redis Google Group with a proposal of semantics/API.
4 |
5 | 3. If steps 1 and 2 are ok, use the following procedure to submit a patch:
6 |
7 | a. Fork Redis on github ( http://help.github.com/fork-a-repo/ )
8 | b. Create a topic branch (git checkout -b my_branch)
9 | c. Push to your branch (git push origin my_branch)
10 | d. Initiate a pull request on github ( http://help.github.com/send-pull-requests/ )
11 | e. Done :)
12 |
13 | Thanks!
14 |
--------------------------------------------------------------------------------
/deps/lua/test/bisect.lua:
--------------------------------------------------------------------------------
1 | -- bisection method for solving non-linear equations
2 |
3 | delta=1e-6 -- tolerance
4 |
5 | function bisect(f,a,b,fa,fb)
6 | local c=(a+b)/2
7 | io.write(n," c=",c," a=",a," b=",b,"\n")
8 | if c==a or c==b or math.abs(a-b)
2 | #include
3 | #include "linenoise.h"
4 |
5 |
6 | void completion(const char *buf, linenoiseCompletions *lc) {
7 | if (buf[0] == 'h') {
8 | linenoiseAddCompletion(lc,"hello");
9 | linenoiseAddCompletion(lc,"hello there");
10 | }
11 | }
12 |
13 | int main(void) {
14 | char *line;
15 |
16 | linenoiseSetCompletionCallback(completion);
17 | linenoiseHistoryLoad("history.txt"); /* Load the history at startup */
18 | while((line = linenoise("hello> ")) != NULL) {
19 | if (line[0] != '\0') {
20 | printf("echo: '%s'\n", line);
21 | linenoiseHistoryAdd(line);
22 | linenoiseHistorySave("history.txt"); /* Save every new entry */
23 | }
24 | free(line);
25 | }
26 | return 0;
27 | }
28 |
--------------------------------------------------------------------------------
/deps/lua/etc/all.c:
--------------------------------------------------------------------------------
1 | /*
2 | * all.c -- Lua core, libraries and interpreter in a single file
3 | */
4 |
5 | #define luaall_c
6 |
7 | #include "lapi.c"
8 | #include "lcode.c"
9 | #include "ldebug.c"
10 | #include "ldo.c"
11 | #include "ldump.c"
12 | #include "lfunc.c"
13 | #include "lgc.c"
14 | #include "llex.c"
15 | #include "lmem.c"
16 | #include "lobject.c"
17 | #include "lopcodes.c"
18 | #include "lparser.c"
19 | #include "lstate.c"
20 | #include "lstring.c"
21 | #include "ltable.c"
22 | #include "ltm.c"
23 | #include "lundump.c"
24 | #include "lvm.c"
25 | #include "lzio.c"
26 |
27 | #include "lauxlib.c"
28 | #include "lbaselib.c"
29 | #include "ldblib.c"
30 | #include "liolib.c"
31 | #include "linit.c"
32 | #include "lmathlib.c"
33 | #include "loadlib.c"
34 | #include "loslib.c"
35 | #include "lstrlib.c"
36 | #include "ltablib.c"
37 |
38 | #include "lua.c"
39 |
--------------------------------------------------------------------------------
/deps/lua/test/factorial.lua:
--------------------------------------------------------------------------------
1 | -- function closures are powerful
2 |
3 | -- traditional fixed-point operator from functional programming
4 | Y = function (g)
5 | local a = function (f) return f(f) end
6 | return a(function (f)
7 | return g(function (x)
8 | local c=f(f)
9 | return c(x)
10 | end)
11 | end)
12 | end
13 |
14 |
15 | -- factorial without recursion
16 | F = function (f)
17 | return function (n)
18 | if n == 0 then return 1
19 | else return n*f(n-1) end
20 | end
21 | end
22 |
23 | factorial = Y(F) -- factorial is the fixed point of F
24 |
25 | -- now test it
26 | function test(x)
27 | io.write(x,"! = ",factorial(x),"\n")
28 | end
29 |
30 | for n=0,16 do
31 | test(n)
32 | end
33 |
--------------------------------------------------------------------------------
/tests/unit/auth.tcl:
--------------------------------------------------------------------------------
1 | start_server {tags {"auth"}} {
2 | test {AUTH fails if there is no password configured server side} {
3 | catch {r auth foo} err
4 | set _ $err
5 | } {ERR*no password*}
6 | }
7 |
8 | start_server {tags {"auth"} overrides {requirepass foobar}} {
9 | test {AUTH fails when a wrong password is given} {
10 | catch {r auth wrong!} err
11 | set _ $err
12 | } {ERR*invalid password}
13 |
14 | test {Arbitrary command gives an error when AUTH is required} {
15 | catch {r set foo bar} err
16 | set _ $err
17 | } {ERR*operation not permitted}
18 |
19 | test {AUTH succeeds when the right password is given} {
20 | r auth foobar
21 | } {OK}
22 |
23 | test {Once AUTH succeeded we can actually send commands to the server} {
24 | r set foo 100
25 | r incr foo
26 | } {101}
27 | }
28 |
--------------------------------------------------------------------------------
/deps/lua/test/sieve.lua:
--------------------------------------------------------------------------------
1 | -- the sieve of of Eratosthenes programmed with coroutines
2 | -- typical usage: lua -e N=1000 sieve.lua | column
3 |
4 | -- generate all the numbers from 2 to n
5 | function gen (n)
6 | return coroutine.wrap(function ()
7 | for i=2,n do coroutine.yield(i) end
8 | end)
9 | end
10 |
11 | -- filter the numbers generated by `g', removing multiples of `p'
12 | function filter (p, g)
13 | return coroutine.wrap(function ()
14 | while 1 do
15 | local n = g()
16 | if n == nil then return end
17 | if math.mod(n, p) ~= 0 then coroutine.yield(n) end
18 | end
19 | end)
20 | end
21 |
22 | N=N or 1000 -- from command line
23 | x = gen(N) -- generate primes up to N
24 | while 1 do
25 | local n = x() -- pick a number until done
26 | if n == nil then break end
27 | print(n) -- must be a prime number
28 | x = filter(n, x) -- now remove its multiples
29 | end
30 |
--------------------------------------------------------------------------------
/deps/lua/test/trace-calls.lua:
--------------------------------------------------------------------------------
1 | -- trace calls
2 | -- example: lua -ltrace-calls bisect.lua
3 |
4 | local level=0
5 |
6 | local function hook(event)
7 | local t=debug.getinfo(3)
8 | io.write(level," >>> ",string.rep(" ",level))
9 | if t~=nil and t.currentline>=0 then io.write(t.short_src,":",t.currentline," ") end
10 | t=debug.getinfo(2)
11 | if event=="call" then
12 | level=level+1
13 | else
14 | level=level-1 if level<0 then level=0 end
15 | end
16 | if t.what=="main" then
17 | if event=="call" then
18 | io.write("begin ",t.short_src)
19 | else
20 | io.write("end ",t.short_src)
21 | end
22 | elseif t.what=="Lua" then
23 | -- table.foreach(t,print)
24 | io.write(event," ",t.name or "(Lua)"," <",t.linedefined,":",t.short_src,">")
25 | else
26 | io.write(event," ",t.name or "(C)"," [",t.what,"] ")
27 | end
28 | io.write("\n")
29 | end
30 |
31 | debug.sethook(hook,"cr")
32 | level=0
33 |
--------------------------------------------------------------------------------
/deps/lua/test/trace-globals.lua:
--------------------------------------------------------------------------------
1 | -- trace assigments to global variables
2 |
3 | do
4 | -- a tostring that quotes strings. note the use of the original tostring.
5 | local _tostring=tostring
6 | local tostring=function(a)
7 | if type(a)=="string" then
8 | return string.format("%q",a)
9 | else
10 | return _tostring(a)
11 | end
12 | end
13 |
14 | local log=function (name,old,new)
15 | local t=debug.getinfo(3,"Sl")
16 | local line=t.currentline
17 | io.write(t.short_src)
18 | if line>=0 then io.write(":",line) end
19 | io.write(": ",name," is now ",tostring(new)," (was ",tostring(old),")","\n")
20 | end
21 |
22 | local g={}
23 | local set=function (t,name,value)
24 | log(name,g[name],value)
25 | g[name]=value
26 | end
27 | setmetatable(getfenv(),{__index=g,__newindex=set})
28 | end
29 |
30 | -- an example
31 |
32 | a=1
33 | b=2
34 | a=10
35 | b=20
36 | b=nil
37 | b=200
38 | print(a,b,c)
39 |
--------------------------------------------------------------------------------
/deps/jemalloc/include/jemalloc/internal/zone.h:
--------------------------------------------------------------------------------
1 | #ifndef JEMALLOC_ZONE
2 | # error "This source file is for zones on Darwin (OS X)."
3 | #endif
4 | /******************************************************************************/
5 | #ifdef JEMALLOC_H_TYPES
6 |
7 | #endif /* JEMALLOC_H_TYPES */
8 | /******************************************************************************/
9 | #ifdef JEMALLOC_H_STRUCTS
10 |
11 | #endif /* JEMALLOC_H_STRUCTS */
12 | /******************************************************************************/
13 | #ifdef JEMALLOC_H_EXTERNS
14 |
15 | malloc_zone_t *create_zone(void);
16 | void szone2ozone(malloc_zone_t *zone);
17 |
18 | #endif /* JEMALLOC_H_EXTERNS */
19 | /******************************************************************************/
20 | #ifdef JEMALLOC_H_INLINES
21 |
22 | #endif /* JEMALLOC_H_INLINES */
23 | /******************************************************************************/
24 |
--------------------------------------------------------------------------------
/deps/jemalloc/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 | void *chunk_alloc_mmap(size_t size);
13 | void *chunk_alloc_mmap_noreserve(size_t size);
14 | void chunk_dealloc_mmap(void *chunk, size_t size);
15 |
16 | bool chunk_mmap_boot(void);
17 |
18 | #endif /* JEMALLOC_H_EXTERNS */
19 | /******************************************************************************/
20 | #ifdef JEMALLOC_H_INLINES
21 |
22 | #endif /* JEMALLOC_H_INLINES */
23 | /******************************************************************************/
24 |
--------------------------------------------------------------------------------
/deps/jemalloc/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 | extern malloc_mutex_t base_mtx;
13 |
14 | void *base_alloc(size_t size);
15 | extent_node_t *base_node_alloc(void);
16 | void base_node_dealloc(extent_node_t *node);
17 | bool base_boot(void);
18 |
19 | #endif /* JEMALLOC_H_EXTERNS */
20 | /******************************************************************************/
21 | #ifdef JEMALLOC_H_INLINES
22 |
23 | #endif /* JEMALLOC_H_INLINES */
24 | /******************************************************************************/
25 |
--------------------------------------------------------------------------------
/deps/lua/src/linit.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Initialization of libraries for lua.c
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 |
8 | #define linit_c
9 | #define LUA_LIB
10 |
11 | #include "lua.h"
12 |
13 | #include "lualib.h"
14 | #include "lauxlib.h"
15 |
16 |
17 | static const luaL_Reg lualibs[] = {
18 | {"", luaopen_base},
19 | {LUA_LOADLIBNAME, luaopen_package},
20 | {LUA_TABLIBNAME, luaopen_table},
21 | {LUA_IOLIBNAME, luaopen_io},
22 | {LUA_OSLIBNAME, luaopen_os},
23 | {LUA_STRLIBNAME, luaopen_string},
24 | {LUA_MATHLIBNAME, luaopen_math},
25 | {LUA_DBLIBNAME, luaopen_debug},
26 | {NULL, NULL}
27 | };
28 |
29 |
30 | LUALIB_API void luaL_openlibs (lua_State *L) {
31 | const luaL_Reg *lib = lualibs;
32 | for (; lib->func; lib++) {
33 | lua_pushcfunction(L, lib->func);
34 | lua_pushstring(L, lib->name);
35 | lua_call(L, 1, 0);
36 | }
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/deps/lua/src/lstring.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** String table (keep all strings handled by Lua)
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lstring_h
8 | #define lstring_h
9 |
10 |
11 | #include "lgc.h"
12 | #include "lobject.h"
13 | #include "lstate.h"
14 |
15 |
16 | #define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char))
17 |
18 | #define sizeudata(u) (sizeof(union Udata)+(u)->len)
19 |
20 | #define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s)))
21 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \
22 | (sizeof(s)/sizeof(char))-1))
23 |
24 | #define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT)
25 |
26 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
27 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e);
28 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
29 |
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/src/ziplist.h:
--------------------------------------------------------------------------------
1 | #define ZIPLIST_HEAD 0
2 | #define ZIPLIST_TAIL 1
3 |
4 | unsigned char *ziplistNew(void);
5 | unsigned char *ziplistPush(unsigned char *zl, unsigned char *s, unsigned int slen, int where);
6 | unsigned char *ziplistIndex(unsigned char *zl, int index);
7 | unsigned char *ziplistNext(unsigned char *zl, unsigned char *p);
8 | unsigned char *ziplistPrev(unsigned char *zl, unsigned char *p);
9 | unsigned int ziplistGet(unsigned char *p, unsigned char **sval, unsigned int *slen, long long *lval);
10 | unsigned char *ziplistInsert(unsigned char *zl, unsigned char *p, unsigned char *s, unsigned int slen);
11 | unsigned char *ziplistDelete(unsigned char *zl, unsigned char **p);
12 | unsigned char *ziplistDeleteRange(unsigned char *zl, unsigned int index, unsigned int num);
13 | unsigned int ziplistCompare(unsigned char *p, unsigned char *s, unsigned int slen);
14 | unsigned int ziplistLen(unsigned char *zl);
15 | size_t ziplistBlobLen(unsigned char *zl);
16 |
--------------------------------------------------------------------------------
/utils/redis_init_script.tpl:
--------------------------------------------------------------------------------
1 |
2 | case "$1" in
3 | start)
4 | if [ -f $$PIDFILE ]
5 | then
6 | echo "$PIDFILE exists, process is already running or crashed"
7 | else
8 | echo "Starting Redis server..."
9 | $EXEC $CONF
10 | fi
11 | ;;
12 | stop)
13 | if [ ! -f $PIDFILE ]
14 | then
15 | echo "$PIDFILE does not exist, process is not running"
16 | else
17 | PID=$(cat $PIDFILE)
18 | echo "Stopping ..."
19 | $CLIEXEC -p $REDISPORT shutdown
20 | while [ -x /proc/${PID} ]
21 | do
22 | echo "Waiting for Redis to shutdown ..."
23 | sleep 1
24 | done
25 | echo "Redis stopped"
26 | fi
27 | ;;
28 | *)
29 | echo "Please use start or stop as first argument"
30 | ;;
31 | esac
32 |
--------------------------------------------------------------------------------
/deps/lua/etc/min.c:
--------------------------------------------------------------------------------
1 | /*
2 | * min.c -- a minimal Lua interpreter
3 | * loads stdin only with minimal error handling.
4 | * no interaction, and no standard library, only a "print" function.
5 | */
6 |
7 | #include
8 |
9 | #include "lua.h"
10 | #include "lauxlib.h"
11 |
12 | static int print(lua_State *L)
13 | {
14 | int n=lua_gettop(L);
15 | int i;
16 | for (i=1; i<=n; i++)
17 | {
18 | if (i>1) printf("\t");
19 | if (lua_isstring(L,i))
20 | printf("%s",lua_tostring(L,i));
21 | else if (lua_isnil(L,i))
22 | printf("%s","nil");
23 | else if (lua_isboolean(L,i))
24 | printf("%s",lua_toboolean(L,i) ? "true" : "false");
25 | else
26 | printf("%s:%p",luaL_typename(L,i),lua_topointer(L,i));
27 | }
28 | printf("\n");
29 | return 0;
30 | }
31 |
32 | int main(void)
33 | {
34 | lua_State *L=lua_open();
35 | lua_register(L,"print",print);
36 | if (luaL_dofile(L,NULL)!=0) fprintf(stderr,"%s\n",lua_tostring(L,-1));
37 | lua_close(L);
38 | return 0;
39 | }
40 |
--------------------------------------------------------------------------------
/deps/lua/doc/readme.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Lua documentation
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | Documentation
13 |
14 |
15 | This is the documentation included in the source distribution of Lua 5.1.4.
16 |
17 |
25 |
26 | Lua's
27 | official web site
28 | contains updated documentation,
29 | especially the
30 | reference manual.
31 |
32 |
33 |
34 |
35 | Last update:
36 | Tue Aug 12 14:46:07 BRT 2008
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/deps/lua/src/lundump.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** load precompiled Lua chunks
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lundump_h
8 | #define lundump_h
9 |
10 | #include "lobject.h"
11 | #include "lzio.h"
12 |
13 | /* load one chunk; from lundump.c */
14 | LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name);
15 |
16 | /* make header; from lundump.c */
17 | LUAI_FUNC void luaU_header (char* h);
18 |
19 | /* dump one chunk; from ldump.c */
20 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
21 |
22 | #ifdef luac_c
23 | /* print one chunk; from print.c */
24 | LUAI_FUNC void luaU_print (const Proto* f, int full);
25 | #endif
26 |
27 | /* for header of binary files -- this is Lua 5.1 */
28 | #define LUAC_VERSION 0x51
29 |
30 | /* for header of binary files -- this is the official format */
31 | #define LUAC_FORMAT 0
32 |
33 | /* size of header of binary files */
34 | #define LUAC_HEADERSIZE 12
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/tests/integration/replication-2.tcl:
--------------------------------------------------------------------------------
1 | start_server {tags {"repl"}} {
2 | start_server {} {
3 | test {First server should have role slave after SLAVEOF} {
4 | r -1 slaveof [srv 0 host] [srv 0 port]
5 | after 1000
6 | s -1 role
7 | } {slave}
8 |
9 | test {MASTER and SLAVE dataset should be identical after complex ops} {
10 | createComplexDataset r 10000
11 | after 500
12 | if {[r debug digest] ne [r -1 debug digest]} {
13 | set csv1 [csvdump r]
14 | set csv2 [csvdump {r -1}]
15 | set fd [open /tmp/repldump1.txt w]
16 | puts -nonewline $fd $csv1
17 | close $fd
18 | set fd [open /tmp/repldump2.txt w]
19 | puts -nonewline $fd $csv2
20 | close $fd
21 | puts "Master - Slave inconsistency"
22 | puts "Run diff -u against /tmp/repldump*.txt for more info"
23 | }
24 | assert_equal [r debug digest] [r -1 debug digest]
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/deps/lua/etc/Makefile:
--------------------------------------------------------------------------------
1 | # makefile for Lua etc
2 |
3 | TOP= ..
4 | LIB= $(TOP)/src
5 | INC= $(TOP)/src
6 | BIN= $(TOP)/src
7 | SRC= $(TOP)/src
8 | TST= $(TOP)/test
9 |
10 | CC= gcc
11 | CFLAGS= -O2 -Wall -I$(INC) $(MYCFLAGS)
12 | MYCFLAGS=
13 | MYLDFLAGS= -Wl,-E
14 | MYLIBS= -lm
15 | #MYLIBS= -lm -Wl,-E -ldl -lreadline -lhistory -lncurses
16 | RM= rm -f
17 |
18 | default:
19 | @echo 'Please choose a target: min noparser one strict clean'
20 |
21 | min: min.c
22 | $(CC) $(CFLAGS) $@.c -L$(LIB) -llua $(MYLIBS)
23 | echo 'print"Hello there!"' | ./a.out
24 |
25 | noparser: noparser.o
26 | $(CC) noparser.o $(SRC)/lua.o -L$(LIB) -llua $(MYLIBS)
27 | $(BIN)/luac $(TST)/hello.lua
28 | -./a.out luac.out
29 | -./a.out -e'a=1'
30 |
31 | one:
32 | $(CC) $(CFLAGS) all.c $(MYLIBS)
33 | ./a.out $(TST)/hello.lua
34 |
35 | strict:
36 | -$(BIN)/lua -e 'print(a);b=2'
37 | -$(BIN)/lua -lstrict -e 'print(a)'
38 | -$(BIN)/lua -e 'function f() b=2 end f()'
39 | -$(BIN)/lua -lstrict -e 'function f() b=2 end f()'
40 |
41 | clean:
42 | $(RM) a.out core core.* *.o luac.out
43 |
44 | .PHONY: default min noparser one strict clean
45 |
--------------------------------------------------------------------------------
/deps/lua/etc/strict.lua:
--------------------------------------------------------------------------------
1 | --
2 | -- strict.lua
3 | -- checks uses of undeclared global variables
4 | -- All global variables must be 'declared' through a regular assignment
5 | -- (even assigning nil will do) in a main chunk before being used
6 | -- anywhere or assigned to inside a function.
7 | --
8 |
9 | local getinfo, error, rawset, rawget = debug.getinfo, error, rawset, rawget
10 |
11 | local mt = getmetatable(_G)
12 | if mt == nil then
13 | mt = {}
14 | setmetatable(_G, mt)
15 | end
16 |
17 | mt.__declared = {}
18 |
19 | local function what ()
20 | local d = getinfo(3, "S")
21 | return d and d.what or "C"
22 | end
23 |
24 | mt.__newindex = function (t, n, v)
25 | if not mt.__declared[n] then
26 | local w = what()
27 | if w ~= "main" and w ~= "C" then
28 | error("assign to undeclared variable '"..n.."'", 2)
29 | end
30 | mt.__declared[n] = true
31 | end
32 | rawset(t, n, v)
33 | end
34 |
35 | mt.__index = function (t, n)
36 | if not mt.__declared[n] and what() ~= "C" then
37 | error("variable '"..n.."' is not declared", 2)
38 | end
39 | return rawget(t, n)
40 | end
41 |
42 |
--------------------------------------------------------------------------------
/deps/lua/etc/README:
--------------------------------------------------------------------------------
1 | This directory contains some useful files and code.
2 | Unlike the code in ../src, everything here is in the public domain.
3 |
4 | If any of the makes fail, you're probably not using the same libraries
5 | used to build Lua. Set MYLIBS in Makefile accordingly.
6 |
7 | all.c
8 | Full Lua interpreter in a single file.
9 | Do "make one" for a demo.
10 |
11 | lua.hpp
12 | Lua header files for C++ using 'extern "C"'.
13 |
14 | lua.ico
15 | A Lua icon for Windows (and web sites: save as favicon.ico).
16 | Drawn by hand by Markus Gritsch .
17 |
18 | lua.pc
19 | pkg-config data for Lua
20 |
21 | luavs.bat
22 | Script to build Lua under "Visual Studio .NET Command Prompt".
23 | Run it from the toplevel as etc\luavs.bat.
24 |
25 | min.c
26 | A minimal Lua interpreter.
27 | Good for learning and for starting your own.
28 | Do "make min" for a demo.
29 |
30 | noparser.c
31 | Linking with noparser.o avoids loading the parsing modules in lualib.a.
32 | Do "make noparser" for a demo.
33 |
34 | strict.lua
35 | Traps uses of undeclared global variables.
36 | Do "make strict" for a demo.
37 |
38 |
--------------------------------------------------------------------------------
/tests/unit/quit.tcl:
--------------------------------------------------------------------------------
1 | start_server {tags {"quit"}} {
2 | proc format_command {args} {
3 | set cmd "*[llength $args]\r\n"
4 | foreach a $args {
5 | append cmd "$[string length $a]\r\n$a\r\n"
6 | }
7 | set _ $cmd
8 | }
9 |
10 | test "QUIT returns OK" {
11 | reconnect
12 | assert_equal OK [r quit]
13 | assert_error * {r ping}
14 | }
15 |
16 | test "Pipelined commands after QUIT must not be executed" {
17 | reconnect
18 | r write [format_command quit]
19 | r write [format_command set foo bar]
20 | r flush
21 | assert_equal OK [r read]
22 | assert_error * {r read}
23 |
24 | reconnect
25 | assert_equal {} [r get foo]
26 | }
27 |
28 | test "Pipelined commands after QUIT that exceed read buffer size" {
29 | reconnect
30 | r write [format_command quit]
31 | r write [format_command set foo [string repeat "x" 1024]]
32 | r flush
33 | assert_equal OK [r read]
34 | assert_error * {r read}
35 |
36 | reconnect
37 | assert_equal {} [r get foo]
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/deps/jemalloc/include/jemalloc/internal/chunk_dss.h:
--------------------------------------------------------------------------------
1 | #ifdef JEMALLOC_DSS
2 | /******************************************************************************/
3 | #ifdef JEMALLOC_H_TYPES
4 |
5 | #endif /* JEMALLOC_H_TYPES */
6 | /******************************************************************************/
7 | #ifdef JEMALLOC_H_STRUCTS
8 |
9 | #endif /* JEMALLOC_H_STRUCTS */
10 | /******************************************************************************/
11 | #ifdef JEMALLOC_H_EXTERNS
12 |
13 | /*
14 | * Protects sbrk() calls. This avoids malloc races among threads, though it
15 | * does not protect against races with threads that call sbrk() directly.
16 | */
17 | extern malloc_mutex_t dss_mtx;
18 |
19 | void *chunk_alloc_dss(size_t size, bool *zero);
20 | bool chunk_in_dss(void *chunk);
21 | bool chunk_dealloc_dss(void *chunk, size_t size);
22 | bool chunk_dss_boot(void);
23 |
24 | #endif /* JEMALLOC_H_EXTERNS */
25 | /******************************************************************************/
26 | #ifdef JEMALLOC_H_INLINES
27 |
28 | #endif /* JEMALLOC_H_INLINES */
29 | /******************************************************************************/
30 | #endif /* JEMALLOC_DSS */
31 |
--------------------------------------------------------------------------------
/deps/lua/etc/luavs.bat:
--------------------------------------------------------------------------------
1 | @rem Script to build Lua under "Visual Studio .NET Command Prompt".
2 | @rem Do not run from this directory; run it from the toplevel: etc\luavs.bat .
3 | @rem It creates lua51.dll, lua51.lib, lua.exe, and luac.exe in src.
4 | @rem (contributed by David Manura and Mike Pall)
5 |
6 | @setlocal
7 | @set MYCOMPILE=cl /nologo /MD /O2 /W3 /c /D_CRT_SECURE_NO_DEPRECATE
8 | @set MYLINK=link /nologo
9 | @set MYMT=mt /nologo
10 |
11 | cd src
12 | %MYCOMPILE% /DLUA_BUILD_AS_DLL l*.c
13 | del lua.obj luac.obj
14 | %MYLINK% /DLL /out:lua51.dll l*.obj
15 | if exist lua51.dll.manifest^
16 | %MYMT% -manifest lua51.dll.manifest -outputresource:lua51.dll;2
17 | %MYCOMPILE% /DLUA_BUILD_AS_DLL lua.c
18 | %MYLINK% /out:lua.exe lua.obj lua51.lib
19 | if exist lua.exe.manifest^
20 | %MYMT% -manifest lua.exe.manifest -outputresource:lua.exe
21 | %MYCOMPILE% l*.c print.c
22 | del lua.obj linit.obj lbaselib.obj ldblib.obj liolib.obj lmathlib.obj^
23 | loslib.obj ltablib.obj lstrlib.obj loadlib.obj
24 | %MYLINK% /out:luac.exe *.obj
25 | if exist luac.exe.manifest^
26 | %MYMT% -manifest luac.exe.manifest -outputresource:luac.exe
27 | del *.obj *.manifest
28 | cd ..
29 |
--------------------------------------------------------------------------------
/deps/lua/src/ldebug.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Auxiliary functions from Debug Interface module
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef ldebug_h
8 | #define ldebug_h
9 |
10 |
11 | #include "lstate.h"
12 |
13 |
14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1)
15 |
16 | #define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0)
17 |
18 | #define resethookcount(L) (L->hookcount = L->basehookcount)
19 |
20 |
21 | LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o,
22 | const char *opname);
23 | LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2);
24 | LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1,
25 | const TValue *p2);
26 | LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1,
27 | const TValue *p2);
28 | LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...);
29 | LUAI_FUNC void luaG_errormsg (lua_State *L);
30 | LUAI_FUNC int luaG_checkcode (const Proto *pt);
31 | LUAI_FUNC int luaG_checkopenop (Instruction i);
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/deps/jemalloc/src/extent.c:
--------------------------------------------------------------------------------
1 | #define JEMALLOC_EXTENT_C_
2 | #include "jemalloc/internal/jemalloc_internal.h"
3 |
4 | /******************************************************************************/
5 |
6 | #if (defined(JEMALLOC_SWAP) || defined(JEMALLOC_DSS))
7 | static inline int
8 | extent_szad_comp(extent_node_t *a, extent_node_t *b)
9 | {
10 | int ret;
11 | size_t a_size = a->size;
12 | size_t b_size = b->size;
13 |
14 | ret = (a_size > b_size) - (a_size < b_size);
15 | if (ret == 0) {
16 | uintptr_t a_addr = (uintptr_t)a->addr;
17 | uintptr_t b_addr = (uintptr_t)b->addr;
18 |
19 | ret = (a_addr > b_addr) - (a_addr < b_addr);
20 | }
21 |
22 | return (ret);
23 | }
24 |
25 | /* Generate red-black tree functions. */
26 | rb_gen(, extent_tree_szad_, extent_tree_t, extent_node_t, link_szad,
27 | extent_szad_comp)
28 | #endif
29 |
30 | static inline int
31 | extent_ad_comp(extent_node_t *a, extent_node_t *b)
32 | {
33 | uintptr_t a_addr = (uintptr_t)a->addr;
34 | uintptr_t b_addr = (uintptr_t)b->addr;
35 |
36 | return ((a_addr > b_addr) - (a_addr < b_addr));
37 | }
38 |
39 | /* Generate red-black tree functions. */
40 | rb_gen(, extent_tree_ad_, extent_tree_t, extent_node_t, link_ad,
41 | extent_ad_comp)
42 |
--------------------------------------------------------------------------------
/src/rio.h:
--------------------------------------------------------------------------------
1 | #ifndef __REDIS_RIO_H
2 | #define __REDIS_RIO_H
3 |
4 | #include
5 | #include "sds.h"
6 |
7 | struct _rio {
8 | /* Backend functions.
9 | * Since this functions do not tolerate short writes or reads the return
10 | * value is simplified to: zero on error, non zero on complete success. */
11 | size_t (*read)(struct _rio *, void *buf, size_t len);
12 | size_t (*write)(struct _rio *, const void *buf, size_t len);
13 | off_t (*tell)(struct _rio *);
14 |
15 | /* Backend-specific vars. */
16 | union {
17 | struct {
18 | sds ptr;
19 | off_t pos;
20 | } buffer;
21 | struct {
22 | FILE *fp;
23 | } file;
24 | } io;
25 | };
26 |
27 | typedef struct _rio rio;
28 |
29 | #define rioWrite(rio,buf,len) ((rio)->write((rio),(buf),(len)))
30 | #define rioRead(rio,buf,len) ((rio)->read((rio),(buf),(len)))
31 |
32 | void rioInitWithFile(rio *r, FILE *fp);
33 | void rioInitWithBuffer(rio *r, sds s);
34 |
35 | size_t rioWriteBulkCount(rio *r, char prefix, int count);
36 | size_t rioWriteBulkString(rio *r, const char *buf, size_t len);
37 | size_t rioWriteBulkLongLong(rio *r, long long l);
38 | size_t rioWriteBulkDouble(rio *r, double d);
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/deps/lua/src/ltm.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Tag methods
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef ltm_h
8 | #define ltm_h
9 |
10 |
11 | #include "lobject.h"
12 |
13 |
14 | /*
15 | * WARNING: if you change the order of this enumeration,
16 | * grep "ORDER TM"
17 | */
18 | typedef enum {
19 | TM_INDEX,
20 | TM_NEWINDEX,
21 | TM_GC,
22 | TM_MODE,
23 | TM_EQ, /* last tag method with `fast' access */
24 | TM_ADD,
25 | TM_SUB,
26 | TM_MUL,
27 | TM_DIV,
28 | TM_MOD,
29 | TM_POW,
30 | TM_UNM,
31 | TM_LEN,
32 | TM_LT,
33 | TM_LE,
34 | TM_CONCAT,
35 | TM_CALL,
36 | TM_N /* number of elements in the enum */
37 | } TMS;
38 |
39 |
40 |
41 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \
42 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
43 |
44 | #define fasttm(l,et,e) gfasttm(G(l), et, e)
45 |
46 | LUAI_DATA const char *const luaT_typenames[];
47 |
48 |
49 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
50 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o,
51 | TMS event);
52 | LUAI_FUNC void luaT_init (lua_State *L);
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/deps/lua/src/lualib.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Lua standard libraries
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 |
8 | #ifndef lualib_h
9 | #define lualib_h
10 |
11 | #include "lua.h"
12 |
13 |
14 | /* Key to file-handle type */
15 | #define LUA_FILEHANDLE "FILE*"
16 |
17 |
18 | #define LUA_COLIBNAME "coroutine"
19 | LUALIB_API int (luaopen_base) (lua_State *L);
20 |
21 | #define LUA_TABLIBNAME "table"
22 | LUALIB_API int (luaopen_table) (lua_State *L);
23 |
24 | #define LUA_IOLIBNAME "io"
25 | LUALIB_API int (luaopen_io) (lua_State *L);
26 |
27 | #define LUA_OSLIBNAME "os"
28 | LUALIB_API int (luaopen_os) (lua_State *L);
29 |
30 | #define LUA_STRLIBNAME "string"
31 | LUALIB_API int (luaopen_string) (lua_State *L);
32 |
33 | #define LUA_MATHLIBNAME "math"
34 | LUALIB_API int (luaopen_math) (lua_State *L);
35 |
36 | #define LUA_DBLIBNAME "debug"
37 | LUALIB_API int (luaopen_debug) (lua_State *L);
38 |
39 | #define LUA_LOADLIBNAME "package"
40 | LUALIB_API int (luaopen_package) (lua_State *L);
41 |
42 |
43 | /* open all previous libraries */
44 | LUALIB_API void (luaL_openlibs) (lua_State *L);
45 |
46 |
47 |
48 | #ifndef lua_assert
49 | #define lua_assert(x) ((void)0)
50 | #endif
51 |
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/deps/lua/src/lfunc.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Auxiliary functions to manipulate prototypes and closures
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lfunc_h
8 | #define lfunc_h
9 |
10 |
11 | #include "lobject.h"
12 |
13 |
14 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \
15 | cast(int, sizeof(TValue)*((n)-1)))
16 |
17 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \
18 | cast(int, sizeof(TValue *)*((n)-1)))
19 |
20 |
21 | LUAI_FUNC Proto *luaF_newproto (lua_State *L);
22 | LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e);
23 | LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e);
24 | LUAI_FUNC UpVal *luaF_newupval (lua_State *L);
25 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
26 | LUAI_FUNC void luaF_close (lua_State *L, StkId level);
27 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
28 | LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c);
29 | LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv);
30 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,
31 | int pc);
32 |
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/deps/lua/test/README:
--------------------------------------------------------------------------------
1 | These are simple tests for Lua. Some of them contain useful code.
2 | They are meant to be run to make sure Lua is built correctly and also
3 | to be read, to see how Lua programs look.
4 |
5 | Here is a one-line summary of each program:
6 |
7 | bisect.lua bisection method for solving non-linear equations
8 | cf.lua temperature conversion table (celsius to farenheit)
9 | echo.lua echo command line arguments
10 | env.lua environment variables as automatic global variables
11 | factorial.lua factorial without recursion
12 | fib.lua fibonacci function with cache
13 | fibfor.lua fibonacci numbers with coroutines and generators
14 | globals.lua report global variable usage
15 | hello.lua the first program in every language
16 | life.lua Conway's Game of Life
17 | luac.lua bare-bones luac
18 | printf.lua an implementation of printf
19 | readonly.lua make global variables readonly
20 | sieve.lua the sieve of of Eratosthenes programmed with coroutines
21 | sort.lua two implementations of a sort function
22 | table.lua make table, grouping all data for the same item
23 | trace-calls.lua trace calls
24 | trace-globals.lua trace assigments to global variables
25 | xd.lua hex dump
26 |
27 |
--------------------------------------------------------------------------------
/src/asciilogo.h:
--------------------------------------------------------------------------------
1 | char *ascii_logo =
2 | " _._ \n"
3 | " _.-``__ ''-._ \n"
4 | " _.-`` `. `_. ''-._ Redis %s (%s/%d) %s bit\n"
5 | " .-`` .-```. ```\\/ _.,_ ''-._ \n"
6 | " ( ' , .-` | `, ) Running in %s mode\n"
7 | " |`-._`-...-` __...-.``-._|'` _.-'| Port: %d\n"
8 | " | `-._ `._ / _.-' | PID: %ld\n"
9 | " `-._ `-._ `-./ _.-' _.-' \n"
10 | " |`-._`-._ `-.__.-' _.-'_.-'| \n"
11 | " | `-._`-._ _.-'_.-' | http://redis.io \n"
12 | " `-._ `-._`-.__.-'_.-' _.-' \n"
13 | " |`-._`-._ `-.__.-' _.-'_.-'| \n"
14 | " | `-._`-._ _.-'_.-' | \n"
15 | " `-._ `-._`-.__.-'_.-' _.-' \n"
16 | " `-._ `-.__.-' _.-' \n"
17 | " `-._ _.-' \n"
18 | " `-.__.-' \n\n";
19 |
--------------------------------------------------------------------------------
/utils/redis_init_script:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Simple Redis init.d script conceived to work on Linux systems
4 | # as it does use of the /proc filesystem.
5 |
6 | REDISPORT=6379
7 | EXEC=/usr/local/bin/redis-server
8 | CLIEXEC=/usr/local/bin/redis-cli
9 |
10 | PIDFILE=/var/run/redis_${REDISPORT}.pid
11 | CONF="/etc/redis/${REDISPORT}.conf"
12 |
13 | case "$1" in
14 | start)
15 | if [ -f $PIDFILE ]
16 | then
17 | echo "$PIDFILE exists, process is already running or crashed"
18 | else
19 | echo "Starting Redis server..."
20 | $EXEC $CONF
21 | fi
22 | ;;
23 | stop)
24 | if [ ! -f $PIDFILE ]
25 | then
26 | echo "$PIDFILE does not exist, process is not running"
27 | else
28 | PID=$(cat $PIDFILE)
29 | echo "Stopping ..."
30 | $CLIEXEC -p $REDISPORT shutdown
31 | while [ -x /proc/${PID} ]
32 | do
33 | echo "Waiting for Redis to shutdown ..."
34 | sleep 1
35 | done
36 | echo "Redis stopped"
37 | fi
38 | ;;
39 | *)
40 | echo "Please use start or stop as first argument"
41 | ;;
42 | esac
43 |
--------------------------------------------------------------------------------
/deps/jemalloc/include/jemalloc/internal/chunk_swap.h:
--------------------------------------------------------------------------------
1 | #ifdef JEMALLOC_SWAP
2 | /******************************************************************************/
3 | #ifdef JEMALLOC_H_TYPES
4 |
5 | #endif /* JEMALLOC_H_TYPES */
6 | /******************************************************************************/
7 | #ifdef JEMALLOC_H_STRUCTS
8 |
9 | #endif /* JEMALLOC_H_STRUCTS */
10 | /******************************************************************************/
11 | #ifdef JEMALLOC_H_EXTERNS
12 |
13 | extern malloc_mutex_t swap_mtx;
14 | extern bool swap_enabled;
15 | extern bool swap_prezeroed;
16 | extern size_t swap_nfds;
17 | extern int *swap_fds;
18 | #ifdef JEMALLOC_STATS
19 | extern size_t swap_avail;
20 | #endif
21 |
22 | void *chunk_alloc_swap(size_t size, bool *zero);
23 | bool chunk_in_swap(void *chunk);
24 | bool chunk_dealloc_swap(void *chunk, size_t size);
25 | bool chunk_swap_enable(const int *fds, unsigned nfds, bool prezeroed);
26 | bool chunk_swap_boot(void);
27 |
28 | #endif /* JEMALLOC_H_EXTERNS */
29 | /******************************************************************************/
30 | #ifdef JEMALLOC_H_INLINES
31 |
32 | #endif /* JEMALLOC_H_INLINES */
33 | /******************************************************************************/
34 | #endif /* JEMALLOC_SWAP */
35 |
--------------------------------------------------------------------------------
/deps/lua/src/lvm.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Lua virtual machine
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lvm_h
8 | #define lvm_h
9 |
10 |
11 | #include "ldo.h"
12 | #include "lobject.h"
13 | #include "ltm.h"
14 |
15 |
16 | #define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o)))
17 |
18 | #define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \
19 | (((o) = luaV_tonumber(o,n)) != NULL))
20 |
21 | #define equalobj(L,o1,o2) \
22 | (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2))
23 |
24 |
25 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
26 | LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2);
27 | LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n);
28 | LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj);
29 | LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key,
30 | StkId val);
31 | LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key,
32 | StkId val);
33 | LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls);
34 | LUAI_FUNC void luaV_concat (lua_State *L, int total, int last);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/deps/lua/src/ltable.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Lua tables (hash)
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef ltable_h
8 | #define ltable_h
9 |
10 | #include "lobject.h"
11 |
12 |
13 | #define gnode(t,i) (&(t)->node[i])
14 | #define gkey(n) (&(n)->i_key.nk)
15 | #define gval(n) (&(n)->i_val)
16 | #define gnext(n) ((n)->i_key.nk.next)
17 |
18 | #define key2tval(n) (&(n)->i_key.tvk)
19 |
20 |
21 | LUAI_FUNC const TValue *luaH_getnum (Table *t, int key);
22 | LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key);
23 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
24 | LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key);
25 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
26 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key);
27 | LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash);
28 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize);
29 | LUAI_FUNC void luaH_free (lua_State *L, Table *t);
30 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key);
31 | LUAI_FUNC int luaH_getn (Table *t);
32 |
33 |
34 | #if defined(LUA_DEBUG)
35 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
36 | LUAI_FUNC int luaH_isdummy (Node *n);
37 | #endif
38 |
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/src/endian.c:
--------------------------------------------------------------------------------
1 | /* Toggle the 16 bit unsigned integer pointed by *p from little endian to
2 | * big endian */
3 | void memrev16(void *p) {
4 | unsigned char *x = p, t;
5 |
6 | t = x[0];
7 | x[0] = x[1];
8 | x[1] = t;
9 | }
10 |
11 | /* Toggle the 32 bit unsigned integer pointed by *p from little endian to
12 | * big endian */
13 | void memrev32(void *p) {
14 | unsigned char *x = p, t;
15 |
16 | t = x[0];
17 | x[0] = x[3];
18 | x[3] = t;
19 | t = x[1];
20 | x[1] = x[2];
21 | x[2] = t;
22 | }
23 |
24 | /* Toggle the 64 bit unsigned integer pointed by *p from little endian to
25 | * big endian */
26 | void memrev64(void *p) {
27 | unsigned char *x = p, t;
28 |
29 | t = x[0];
30 | x[0] = x[7];
31 | x[7] = t;
32 | t = x[1];
33 | x[1] = x[6];
34 | x[6] = t;
35 | t = x[2];
36 | x[2] = x[5];
37 | x[5] = t;
38 | t = x[3];
39 | x[3] = x[4];
40 | x[4] = t;
41 | }
42 |
43 | #ifdef TESTMAIN
44 | #include
45 |
46 | int main(void) {
47 | char buf[32];
48 |
49 | sprintf(buf,"ciaoroma");
50 | memrev16(buf);
51 | printf("%s\n", buf);
52 |
53 | sprintf(buf,"ciaoroma");
54 | memrev32(buf);
55 | printf("%s\n", buf);
56 |
57 | sprintf(buf,"ciaoroma");
58 | memrev64(buf);
59 | printf("%s\n", buf);
60 |
61 | return 0;
62 | }
63 | #endif
64 |
--------------------------------------------------------------------------------
/tests/integration/replication-3.tcl:
--------------------------------------------------------------------------------
1 | start_server {tags {"repl"}} {
2 | start_server {} {
3 | test {First server should have role slave after SLAVEOF} {
4 | r -1 slaveof [srv 0 host] [srv 0 port]
5 | after 1000
6 | s -1 role
7 | } {slave}
8 |
9 | if {$::accurate} {set numops 50000} else {set numops 5000}
10 |
11 | test {MASTER and SLAVE consistency with expire} {
12 | createComplexDataset r $numops useexpire
13 | after 4000 ;# Make sure everything expired before taking the digest
14 | r keys * ;# Force DEL syntesizing to slave
15 | after 1000 ;# Wait another second. Now everything should be fine.
16 | if {[r debug digest] ne [r -1 debug digest]} {
17 | set csv1 [csvdump r]
18 | set csv2 [csvdump {r -1}]
19 | set fd [open /tmp/repldump1.txt w]
20 | puts -nonewline $fd $csv1
21 | close $fd
22 | set fd [open /tmp/repldump2.txt w]
23 | puts -nonewline $fd $csv2
24 | close $fd
25 | puts "Master - Slave inconsistency"
26 | puts "Run diff -u against /tmp/repldump*.txt for more info"
27 | }
28 | assert_equal [r debug digest] [r -1 debug digest]
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/deps/jemalloc/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 |
--------------------------------------------------------------------------------
/tests/integration/aof-race.tcl:
--------------------------------------------------------------------------------
1 | set defaults { appendonly {yes} appendfilename {appendonly.aof} }
2 | set server_path [tmpdir server.aof]
3 | set aof_path "$server_path/appendonly.aof"
4 |
5 | proc start_server_aof {overrides code} {
6 | upvar defaults defaults srv srv server_path server_path
7 | set config [concat $defaults $overrides]
8 | start_server [list overrides $config] $code
9 | }
10 |
11 | tags {"aof"} {
12 | # Specific test for a regression where internal buffers were not properly
13 | # cleaned after a child responsible for an AOF rewrite exited. This buffer
14 | # was subsequently appended to the new AOF, resulting in duplicate commands.
15 | start_server_aof [list dir $server_path] {
16 | set client [redis [srv host] [srv port]]
17 | set bench [open "|src/redis-benchmark -q -p [srv port] -c 20 -n 20000 incr foo" "r+"]
18 | after 100
19 |
20 | # Benchmark should be running by now: start background rewrite
21 | $client bgrewriteaof
22 |
23 | # Read until benchmark pipe reaches EOF
24 | while {[string length [read $bench]] > 0} {}
25 |
26 | # Check contents of foo
27 | assert_equal 20000 [$client get foo]
28 | }
29 |
30 | # Restart server to replay AOF
31 | start_server_aof [list dir $server_path] {
32 | set client [redis [srv host] [srv port]]
33 | assert_equal 20000 [$client get foo]
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/tests/unit/slowlog.tcl:
--------------------------------------------------------------------------------
1 | start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} {
2 | test {SLOWLOG - check that it starts with an empty log} {
3 | r slowlog len
4 | } {0}
5 |
6 | test {SLOWLOG - only logs commands taking more time than specified} {
7 | r config set slowlog-log-slower-than 100000
8 | r ping
9 | assert_equal [r slowlog len] 0
10 | r debug sleep 0.2
11 | assert_equal [r slowlog len] 1
12 | }
13 |
14 | test {SLOWLOG - max entries is correctly handled} {
15 | r config set slowlog-log-slower-than 0
16 | r config set slowlog-max-len 10
17 | for {set i 0} {$i < 100} {incr i} {
18 | r ping
19 | }
20 | r slowlog len
21 | } {10}
22 |
23 | test {SLOWLOG - GET optional argument to limit output len works} {
24 | llength [r slowlog get 5]
25 | } {5}
26 |
27 | test {SLOWLOG - RESET subcommand works} {
28 | r config set slowlog-log-slower-than 100000
29 | r slowlog reset
30 | r slowlog len
31 | } {0}
32 |
33 | test {SLOWLOG - logged entry sanity check} {
34 | r debug sleep 0.2
35 | set e [lindex [r slowlog get] 0]
36 | assert_equal [llength $e] 4
37 | assert_equal [lindex $e 0] 105
38 | assert_equal [expr {[lindex $e 2] > 100000}] 1
39 | assert_equal [lindex $e 3] {debug sleep 0.2}
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/deps/lua/etc/noparser.c:
--------------------------------------------------------------------------------
1 | /*
2 | * The code below can be used to make a Lua core that does not contain the
3 | * parsing modules (lcode, llex, lparser), which represent 35% of the total core.
4 | * You'll only be able to load binary files and strings, precompiled with luac.
5 | * (Of course, you'll have to build luac with the original parsing modules!)
6 | *
7 | * To use this module, simply compile it ("make noparser" does that) and list
8 | * its object file before the Lua libraries. The linker should then not load
9 | * the parsing modules. To try it, do "make luab".
10 | *
11 | * If you also want to avoid the dump module (ldump.o), define NODUMP.
12 | * #define NODUMP
13 | */
14 |
15 | #define LUA_CORE
16 |
17 | #include "llex.h"
18 | #include "lparser.h"
19 | #include "lzio.h"
20 |
21 | LUAI_FUNC void luaX_init (lua_State *L) {
22 | UNUSED(L);
23 | }
24 |
25 | LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) {
26 | UNUSED(z);
27 | UNUSED(buff);
28 | UNUSED(name);
29 | lua_pushliteral(L,"parser not loaded");
30 | lua_error(L);
31 | return NULL;
32 | }
33 |
34 | #ifdef NODUMP
35 | #include "lundump.h"
36 |
37 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip) {
38 | UNUSED(f);
39 | UNUSED(w);
40 | UNUSED(data);
41 | UNUSED(strip);
42 | #if 1
43 | UNUSED(L);
44 | return 0;
45 | #else
46 | lua_pushliteral(L,"dumper not loaded");
47 | lua_error(L);
48 | #endif
49 | }
50 | #endif
51 |
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
1 | Copyright (c) 2006-2009, Salvatore Sanfilippo
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 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7 | * 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.
8 | * Neither the name of Redis nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9 |
10 | 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 OWNER 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.
11 |
--------------------------------------------------------------------------------
/deps/hiredis/COPYING:
--------------------------------------------------------------------------------
1 | Copyright (c) 2006-2009, Salvatore Sanfilippo
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 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7 | * 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.
8 | * Neither the name of Redis nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9 |
10 | 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 OWNER 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.
11 |
--------------------------------------------------------------------------------
/deps/hiredis/example-libev.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include "hiredis.h"
6 | #include "async.h"
7 | #include "adapters/libev.h"
8 |
9 | void getCallback(redisAsyncContext *c, void *r, void *privdata) {
10 | redisReply *reply = r;
11 | if (reply == NULL) return;
12 | printf("argv[%s]: %s\n", (char*)privdata, reply->str);
13 |
14 | /* Disconnect after receiving the reply to GET */
15 | redisAsyncDisconnect(c);
16 | }
17 |
18 | void connectCallback(const redisAsyncContext *c) {
19 | ((void)c);
20 | printf("connected...\n");
21 | }
22 |
23 | void disconnectCallback(const redisAsyncContext *c, int status) {
24 | if (status != REDIS_OK) {
25 | printf("Error: %s\n", c->errstr);
26 | }
27 | printf("disconnected...\n");
28 | }
29 |
30 | int main (int argc, char **argv) {
31 | signal(SIGPIPE, SIG_IGN);
32 |
33 | redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6379);
34 | if (c->err) {
35 | /* Let *c leak for now... */
36 | printf("Error: %s\n", c->errstr);
37 | return 1;
38 | }
39 |
40 | redisLibevAttach(EV_DEFAULT_ c);
41 | redisAsyncSetConnectCallback(c,connectCallback);
42 | redisAsyncSetDisconnectCallback(c,disconnectCallback);
43 | redisAsyncCommand(c, NULL, NULL, "SET key %b", argv[argc-1], strlen(argv[argc-1]));
44 | redisAsyncCommand(c, getCallback, (char*)"end-1", "GET key");
45 | ev_loop(EV_DEFAULT_ 0);
46 | return 0;
47 | }
48 |
--------------------------------------------------------------------------------
/deps/lua/README:
--------------------------------------------------------------------------------
1 | README for Lua 5.1
2 |
3 | See INSTALL for installation instructions.
4 | See HISTORY for a summary of changes since the last released version.
5 |
6 | * What is Lua?
7 | ------------
8 | Lua is a powerful, light-weight programming language designed for extending
9 | applications. Lua is also frequently used as a general-purpose, stand-alone
10 | language. Lua is free software.
11 |
12 | For complete information, visit Lua's web site at http://www.lua.org/ .
13 | For an executive summary, see http://www.lua.org/about.html .
14 |
15 | Lua has been used in many different projects around the world.
16 | For a short list, see http://www.lua.org/uses.html .
17 |
18 | * Availability
19 | ------------
20 | Lua is freely available for both academic and commercial purposes.
21 | See COPYRIGHT and http://www.lua.org/license.html for details.
22 | Lua can be downloaded at http://www.lua.org/download.html .
23 |
24 | * Installation
25 | ------------
26 | Lua is implemented in pure ANSI C, and compiles unmodified in all known
27 | platforms that have an ANSI C compiler. In most Unix-like platforms, simply
28 | do "make" with a suitable target. See INSTALL for detailed instructions.
29 |
30 | * Origin
31 | ------
32 | Lua is developed at Lua.org, a laboratory of the Department of Computer
33 | Science of PUC-Rio (the Pontifical Catholic University of Rio de Janeiro
34 | in Brazil).
35 | For more information about the authors, see http://www.lua.org/authors.html .
36 |
37 | (end of README)
38 |
--------------------------------------------------------------------------------
/deps/jemalloc/test/mremap.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | #define JEMALLOC_MANGLE
8 | #include "jemalloc_test.h"
9 |
10 | int
11 | main(void)
12 | {
13 | int ret, err;
14 | size_t sz, lg_chunk, chunksize, i;
15 | char *p, *q;
16 |
17 | fprintf(stderr, "Test begin\n");
18 |
19 | sz = sizeof(lg_chunk);
20 | if ((err = JEMALLOC_P(mallctl)("opt.lg_chunk", &lg_chunk, &sz, NULL,
21 | 0))) {
22 | assert(err != ENOENT);
23 | fprintf(stderr, "%s(): Error in mallctl(): %s\n", __func__,
24 | strerror(err));
25 | ret = 1;
26 | goto RETURN;
27 | }
28 | chunksize = ((size_t)1U) << lg_chunk;
29 |
30 | p = (char *)malloc(chunksize);
31 | if (p == NULL) {
32 | fprintf(stderr, "malloc(%zu) --> %p\n", chunksize, p);
33 | ret = 1;
34 | goto RETURN;
35 | }
36 | memset(p, 'a', chunksize);
37 |
38 | q = (char *)realloc(p, chunksize * 2);
39 | if (q == NULL) {
40 | fprintf(stderr, "realloc(%p, %zu) --> %p\n", p, chunksize * 2,
41 | q);
42 | ret = 1;
43 | goto RETURN;
44 | }
45 | for (i = 0; i < chunksize; i++) {
46 | assert(q[i] == 'a');
47 | }
48 |
49 | p = q;
50 |
51 | q = (char *)realloc(p, chunksize);
52 | if (q == NULL) {
53 | fprintf(stderr, "realloc(%p, %zu) --> %p\n", p, chunksize, q);
54 | ret = 1;
55 | goto RETURN;
56 | }
57 | for (i = 0; i < chunksize; i++) {
58 | assert(q[i] == 'a');
59 | }
60 |
61 | free(q);
62 |
63 | ret = 0;
64 | RETURN:
65 | fprintf(stderr, "Test end\n");
66 | return (ret);
67 | }
68 |
--------------------------------------------------------------------------------
/deps/hiredis/example-libevent.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include "hiredis.h"
6 | #include "async.h"
7 | #include "adapters/libevent.h"
8 |
9 | void getCallback(redisAsyncContext *c, void *r, void *privdata) {
10 | redisReply *reply = r;
11 | if (reply == NULL) return;
12 | printf("argv[%s]: %s\n", (char*)privdata, reply->str);
13 |
14 | /* Disconnect after receiving the reply to GET */
15 | redisAsyncDisconnect(c);
16 | }
17 |
18 | void connectCallback(const redisAsyncContext *c) {
19 | ((void)c);
20 | printf("connected...\n");
21 | }
22 |
23 | void disconnectCallback(const redisAsyncContext *c, int status) {
24 | if (status != REDIS_OK) {
25 | printf("Error: %s\n", c->errstr);
26 | }
27 | printf("disconnected...\n");
28 | }
29 |
30 | int main (int argc, char **argv) {
31 | signal(SIGPIPE, SIG_IGN);
32 | struct event_base *base = event_base_new();
33 |
34 | redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6379);
35 | if (c->err) {
36 | /* Let *c leak for now... */
37 | printf("Error: %s\n", c->errstr);
38 | return 1;
39 | }
40 |
41 | redisLibeventAttach(c,base);
42 | redisAsyncSetConnectCallback(c,connectCallback);
43 | redisAsyncSetDisconnectCallback(c,disconnectCallback);
44 | redisAsyncCommand(c, NULL, NULL, "SET key %b", argv[argc-1], strlen(argv[argc-1]));
45 | redisAsyncCommand(c, getCallback, (char*)"end-1", "GET key");
46 | event_base_dispatch(base);
47 | return 0;
48 | }
49 |
--------------------------------------------------------------------------------
/deps/jemalloc/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 | #ifdef JEMALLOC_STATS
13 | /* Huge allocation statistics. */
14 | extern uint64_t huge_nmalloc;
15 | extern uint64_t huge_ndalloc;
16 | extern size_t huge_allocated;
17 | #endif
18 |
19 | /* Protects chunk-related data structures. */
20 | extern malloc_mutex_t huge_mtx;
21 |
22 | void *huge_malloc(size_t size, bool zero);
23 | void *huge_palloc(size_t size, size_t alignment, bool zero);
24 | void *huge_ralloc_no_move(void *ptr, size_t oldsize, size_t size,
25 | size_t extra);
26 | void *huge_ralloc(void *ptr, size_t oldsize, size_t size, size_t extra,
27 | size_t alignment, bool zero);
28 | void huge_dalloc(void *ptr, bool unmap);
29 | size_t huge_salloc(const void *ptr);
30 | #ifdef JEMALLOC_PROF
31 | prof_ctx_t *huge_prof_ctx_get(const void *ptr);
32 | void huge_prof_ctx_set(const void *ptr, prof_ctx_t *ctx);
33 | #endif
34 | bool huge_boot(void);
35 |
36 | #endif /* JEMALLOC_H_EXTERNS */
37 | /******************************************************************************/
38 | #ifdef JEMALLOC_H_INLINES
39 |
40 | #endif /* JEMALLOC_H_INLINES */
41 | /******************************************************************************/
42 |
--------------------------------------------------------------------------------
/tests/unit/type/list-2.tcl:
--------------------------------------------------------------------------------
1 | start_server {
2 | tags {"list"}
3 | overrides {
4 | "list-max-ziplist-value" 16
5 | "list-max-ziplist-entries" 256
6 | }
7 | } {
8 | source "tests/unit/type/list-common.tcl"
9 |
10 | foreach {type large} [array get largevalue] {
11 | tags {"slow"} {
12 | test "LTRIM stress testing - $type" {
13 | set mylist {}
14 | set startlen 32
15 | r del mylist
16 |
17 | # Start with the large value to ensure the
18 | # right encoding is used.
19 | r rpush mylist $large
20 | lappend mylist $large
21 |
22 | for {set i 0} {$i < $startlen} {incr i} {
23 | set str [randomInt 9223372036854775807]
24 | r rpush mylist $str
25 | lappend mylist $str
26 | }
27 |
28 | for {set i 0} {$i < 1000} {incr i} {
29 | set min [expr {int(rand()*$startlen)}]
30 | set max [expr {$min+int(rand()*$startlen)}]
31 | set mylist [lrange $mylist $min $max]
32 | r ltrim mylist $min $max
33 | assert_equal $mylist [r lrange mylist 0 -1]
34 |
35 | for {set j [r llen mylist]} {$j < $startlen} {incr j} {
36 | set str [randomInt 9223372036854775807]
37 | r rpush mylist $str
38 | lappend mylist $str
39 | }
40 | }
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/deps/jemalloc/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 | #if (defined(JEMALLOC_SWAP) || defined(JEMALLOC_DSS))
13 | /* Linkage for the size/address-ordered tree. */
14 | rb_node(extent_node_t) link_szad;
15 | #endif
16 |
17 | /* Linkage for the address-ordered tree. */
18 | rb_node(extent_node_t) link_ad;
19 |
20 | #ifdef JEMALLOC_PROF
21 | /* Profile counters, used for huge objects. */
22 | prof_ctx_t *prof_ctx;
23 | #endif
24 |
25 | /* Pointer to the extent that this tree node is responsible for. */
26 | void *addr;
27 |
28 | /* Total region size. */
29 | size_t size;
30 | };
31 | typedef rb_tree(extent_node_t) extent_tree_t;
32 |
33 | #endif /* JEMALLOC_H_STRUCTS */
34 | /******************************************************************************/
35 | #ifdef JEMALLOC_H_EXTERNS
36 |
37 | #if (defined(JEMALLOC_SWAP) || defined(JEMALLOC_DSS))
38 | rb_proto(, extent_tree_szad_, extent_tree_t, extent_node_t)
39 | #endif
40 |
41 | rb_proto(, extent_tree_ad_, extent_tree_t, extent_node_t)
42 |
43 | #endif /* JEMALLOC_H_EXTERNS */
44 | /******************************************************************************/
45 | #ifdef JEMALLOC_H_INLINES
46 |
47 | #endif /* JEMALLOC_H_INLINES */
48 | /******************************************************************************/
49 |
50 |
--------------------------------------------------------------------------------
/deps/hiredis/example-ae.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include "hiredis.h"
6 | #include "async.h"
7 | #include "adapters/ae.h"
8 |
9 | /* Put event loop in the global scope, so it can be explicitly stopped */
10 | static aeEventLoop *loop;
11 |
12 | void getCallback(redisAsyncContext *c, void *r, void *privdata) {
13 | redisReply *reply = r;
14 | if (reply == NULL) return;
15 | printf("argv[%s]: %s\n", (char*)privdata, reply->str);
16 |
17 | /* Disconnect after receiving the reply to GET */
18 | redisAsyncDisconnect(c);
19 | }
20 |
21 | void connectCallback(const redisAsyncContext *c) {
22 | ((void)c);
23 | printf("connected...\n");
24 | }
25 |
26 | void disconnectCallback(const redisAsyncContext *c, int status) {
27 | if (status != REDIS_OK) {
28 | printf("Error: %s\n", c->errstr);
29 | }
30 | printf("disconnected...\n");
31 | aeStop(loop);
32 | }
33 |
34 | int main (int argc, char **argv) {
35 | signal(SIGPIPE, SIG_IGN);
36 |
37 | redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6379);
38 | if (c->err) {
39 | /* Let *c leak for now... */
40 | printf("Error: %s\n", c->errstr);
41 | return 1;
42 | }
43 |
44 | loop = aeCreateEventLoop();
45 | redisAeAttach(loop, c);
46 | redisAsyncSetConnectCallback(c,connectCallback);
47 | redisAsyncSetDisconnectCallback(c,disconnectCallback);
48 | redisAsyncCommand(c, NULL, NULL, "SET key %b", argv[argc-1], strlen(argv[argc-1]));
49 | redisAsyncCommand(c, getCallback, (char*)"end-1", "GET key");
50 | aeMain(loop);
51 | return 0;
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/deps/lua/COPYRIGHT:
--------------------------------------------------------------------------------
1 | Lua License
2 | -----------
3 |
4 | Lua is licensed under the terms of the MIT license reproduced below.
5 | This means that Lua is free software and can be used for both academic
6 | and commercial purposes at absolutely no cost.
7 |
8 | For details and rationale, see http://www.lua.org/license.html .
9 |
10 | ===============================================================================
11 |
12 | Copyright (C) 1994-2008 Lua.org, PUC-Rio.
13 |
14 | Permission is hereby granted, free of charge, to any person obtaining a copy
15 | of this software and associated documentation files (the "Software"), to deal
16 | in the Software without restriction, including without limitation the rights
17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 | copies of the Software, and to permit persons to whom the Software is
19 | furnished to do so, subject to the following conditions:
20 |
21 | The above copyright notice and this permission notice shall be included in
22 | all copies or substantial portions of the Software.
23 |
24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30 | THE SOFTWARE.
31 |
32 | ===============================================================================
33 |
34 | (end of COPYRIGHT)
35 |
--------------------------------------------------------------------------------
/deps/lua/src/lmem.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Interface to Memory Manager
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lmem_h
8 | #define lmem_h
9 |
10 |
11 | #include
12 |
13 | #include "llimits.h"
14 | #include "lua.h"
15 |
16 | #define MEMERRMSG "not enough memory"
17 |
18 |
19 | #define luaM_reallocv(L,b,on,n,e) \
20 | ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \
21 | luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \
22 | luaM_toobig(L))
23 |
24 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0)
25 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0)
26 | #define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t))
27 |
28 | #define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t))
29 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t)))
30 | #define luaM_newvector(L,n,t) \
31 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t)))
32 |
33 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \
34 | if ((nelems)+1 > (size)) \
35 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e)))
36 |
37 | #define luaM_reallocvector(L, v,oldn,n,t) \
38 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
39 |
40 |
41 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
42 | size_t size);
43 | LUAI_FUNC void *luaM_toobig (lua_State *L);
44 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size,
45 | size_t size_elem, int limit,
46 | const char *errormsg);
47 |
48 | #endif
49 |
50 |
--------------------------------------------------------------------------------
/deps/lua/test/sort.lua:
--------------------------------------------------------------------------------
1 | -- two implementations of a sort function
2 | -- this is an example only. Lua has now a built-in function "sort"
3 |
4 | -- extracted from Programming Pearls, page 110
5 | function qsort(x,l,u,f)
6 | if ly end)
58 | show("after reverse selection sort",x)
59 | qsort(x,1,n,function (x,y) return xn--)>0 ? char2int(*(z)->p++) : luaZ_fill(z))
23 |
24 | typedef struct Mbuffer {
25 | char *buffer;
26 | size_t n;
27 | size_t buffsize;
28 | } Mbuffer;
29 |
30 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
31 |
32 | #define luaZ_buffer(buff) ((buff)->buffer)
33 | #define luaZ_sizebuffer(buff) ((buff)->buffsize)
34 | #define luaZ_bufflen(buff) ((buff)->n)
35 |
36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0)
37 |
38 |
39 | #define luaZ_resizebuffer(L, buff, size) \
40 | (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \
41 | (buff)->buffsize = size)
42 |
43 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
44 |
45 |
46 | LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n);
47 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
48 | void *data);
49 | LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */
50 | LUAI_FUNC int luaZ_lookahead (ZIO *z);
51 |
52 |
53 |
54 | /* --------- Private Part ------------------ */
55 |
56 | struct Zio {
57 | size_t n; /* bytes still unread */
58 | const char *p; /* current position in buffer */
59 | lua_Reader reader;
60 | void* data; /* additional data */
61 | lua_State *L; /* Lua state (for reader) */
62 | };
63 |
64 |
65 | LUAI_FUNC int luaZ_fill (ZIO *z);
66 |
67 | #endif
68 |
--------------------------------------------------------------------------------
/deps/hiredis/util.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009-2010, Salvatore Sanfilippo
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions are met:
7 | *
8 | * * Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * * 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 | * * Neither the name of Redis nor the names of its contributors may be used
14 | * to endorse or promote products derived from this software without
15 | * specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 | * POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | #ifndef __UTIL_H
31 | #define __UTIL_H
32 | #include
33 |
34 | /* Abort on out of memory */
35 | static void redisOOM(void) {
36 | fprintf(stderr,"Out of memory in hiredis");
37 | exit(1);
38 | }
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/deps/Makefile:
--------------------------------------------------------------------------------
1 | # Redis dependency Makefile
2 |
3 | UNAME_S:=$(shell sh -c 'uname -s 2> /dev/null || echo not')
4 |
5 | LUA_CFLAGS=-O2 -Wall $(ARCH)
6 | ifeq ($(UNAME_S),SunOS)
7 | # Make isinf() available
8 | LUA_CFLAGS+= -D__C99FEATURES__=1
9 | endif
10 |
11 | JEMALLOC_CFLAGS=
12 | ifeq ($(ARCH),-m32)
13 | JEMALLOC_CFLAGS+=CFLAGS="-std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -m32"
14 | endif
15 |
16 | CCCOLOR="\033[34m"
17 | LINKCOLOR="\033[34;1m"
18 | SRCCOLOR="\033[33m"
19 | BINCOLOR="\033[37;1m"
20 | MAKECOLOR="\033[32;1m"
21 | ENDCOLOR="\033[0m"
22 |
23 | default:
24 | @echo "Explicit target required"
25 |
26 | # Clean everything when ARCH is different
27 | ifneq ($(shell sh -c '[ -f .make-arch ] && cat .make-arch'), $(ARCH))
28 | .make-arch: distclean
29 | else
30 | .make-arch:
31 | endif
32 |
33 | .make-arch:
34 | -(echo $(ARCH) > .make-arch)
35 |
36 | distclean:
37 | -(cd hiredis && $(MAKE) clean) > /dev/null || true
38 | -(cd linenoise && $(MAKE) clean) > /dev/null || true
39 | -(cd lua && $(MAKE) clean) > /dev/null || true
40 | -(cd jemalloc && [ -f Makefile ] && $(MAKE) distclean) > /dev/null || true
41 | -(rm -f .make-arch)
42 |
43 | hiredis: .make-arch
44 | @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)hiredis$(ENDCOLOR)
45 | cd hiredis && $(MAKE) static ARCH="$(ARCH)"
46 |
47 | linenoise: .make-arch
48 | @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)linenoise$(ENDCOLOR)
49 | cd linenoise && $(MAKE) ARCH="$(ARCH)"
50 |
51 | lua: .make-arch
52 | @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)lua$(ENDCOLOR)
53 | cd lua && $(MAKE) CFLAGS="$(LUA_CFLAGS)" MYLDFLAGS="$(ARCH)" ansi
54 |
55 | jemalloc: .make-arch
56 | @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)jemalloc$(ENDCOLOR)
57 | cd jemalloc && ./configure $(JEMALLOC_CFLAGS) --with-jemalloc-prefix=je_ --enable-cc-silence && $(MAKE) lib/libjemalloc.a
58 |
59 | .PHONY: default conditional_clean hiredis linenoise lua jemalloc
60 |
--------------------------------------------------------------------------------
/utils/redis-sha1.rb:
--------------------------------------------------------------------------------
1 | # redis-sha1.rb - Copyright (C) 2009 Salvatore Sanfilippo
2 | # BSD license, See the COPYING file for more information.
3 | #
4 | # Performs the SHA1 sum of the whole datset.
5 | # This is useful to spot bugs in persistence related code and to make sure
6 | # Slaves and Masters are in SYNC.
7 | #
8 | # If you hack this code make sure to sort keys and set elements as this are
9 | # unsorted elements. Otherwise the sum may differ with equal dataset.
10 |
11 | require 'rubygems'
12 | require 'redis'
13 | require 'digest/sha1'
14 |
15 | def redisSha1(opts={})
16 | sha1=""
17 | r = Redis.new(opts)
18 | r.keys('*').sort.each{|k|
19 | vtype = r.type?(k)
20 | if vtype == "string"
21 | len = 1
22 | sha1 = Digest::SHA1.hexdigest(sha1+k)
23 | sha1 = Digest::SHA1.hexdigest(sha1+r.get(k))
24 | elsif vtype == "list"
25 | len = r.llen(k)
26 | if len != 0
27 | sha1 = Digest::SHA1.hexdigest(sha1+k)
28 | sha1 = Digest::SHA1.hexdigest(sha1+r.list_range(k,0,-1).join("\x01"))
29 | end
30 | elsif vtype == "set"
31 | len = r.scard(k)
32 | if len != 0
33 | sha1 = Digest::SHA1.hexdigest(sha1+k)
34 | sha1 = Digest::SHA1.hexdigest(sha1+r.set_members(k).to_a.sort.join("\x02"))
35 | end
36 | elsif vtype == "zset"
37 | len = r.zcard(k)
38 | if len != 0
39 | sha1 = Digest::SHA1.hexdigest(sha1+k)
40 | sha1 = Digest::SHA1.hexdigest(sha1+r.zrange(k,0,-1).join("\x01"))
41 | end
42 | end
43 | # puts "#{k} => #{sha1}" if len != 0
44 | }
45 | sha1
46 | end
47 |
48 | host = ARGV[0] || "127.0.0.1"
49 | port = ARGV[1] || "6379"
50 | db = ARGV[2] || "0"
51 | puts "Performing SHA1 of Redis server #{host} #{port} DB: #{db}"
52 | p "Dataset SHA1: #{redisSha1(:host => host, :port => port.to_i, :db => db)}"
53 |
--------------------------------------------------------------------------------
/deps/lua/src/ltm.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Tag methods
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 |
8 | #include
9 |
10 | #define ltm_c
11 | #define LUA_CORE
12 |
13 | #include "lua.h"
14 |
15 | #include "lobject.h"
16 | #include "lstate.h"
17 | #include "lstring.h"
18 | #include "ltable.h"
19 | #include "ltm.h"
20 |
21 |
22 |
23 | const char *const luaT_typenames[] = {
24 | "nil", "boolean", "userdata", "number",
25 | "string", "table", "function", "userdata", "thread",
26 | "proto", "upval"
27 | };
28 |
29 |
30 | void luaT_init (lua_State *L) {
31 | static const char *const luaT_eventname[] = { /* ORDER TM */
32 | "__index", "__newindex",
33 | "__gc", "__mode", "__eq",
34 | "__add", "__sub", "__mul", "__div", "__mod",
35 | "__pow", "__unm", "__len", "__lt", "__le",
36 | "__concat", "__call"
37 | };
38 | int i;
39 | for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]);
41 | luaS_fix(G(L)->tmname[i]); /* never collect these names */
42 | }
43 | }
44 |
45 |
46 | /*
47 | ** function to be used with macro "fasttm": optimized for absence of
48 | ** tag methods
49 | */
50 | const TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
51 | const TValue *tm = luaH_getstr(events, ename);
52 | lua_assert(event <= TM_EQ);
53 | if (ttisnil(tm)) { /* no tag method? */
54 | events->flags |= cast_byte(1u<metatable;
66 | break;
67 | case LUA_TUSERDATA:
68 | mt = uvalue(o)->metatable;
69 | break;
70 | default:
71 | mt = G(L)->mt[ttype(o)];
72 | }
73 | return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject);
74 | }
75 |
76 |
--------------------------------------------------------------------------------
/deps/lua/src/lzio.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** a generic input stream interface
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 |
8 | #include
9 |
10 | #define lzio_c
11 | #define LUA_CORE
12 |
13 | #include "lua.h"
14 |
15 | #include "llimits.h"
16 | #include "lmem.h"
17 | #include "lstate.h"
18 | #include "lzio.h"
19 |
20 |
21 | int luaZ_fill (ZIO *z) {
22 | size_t size;
23 | lua_State *L = z->L;
24 | const char *buff;
25 | lua_unlock(L);
26 | buff = z->reader(L, z->data, &size);
27 | lua_lock(L);
28 | if (buff == NULL || size == 0) return EOZ;
29 | z->n = size - 1;
30 | z->p = buff;
31 | return char2int(*(z->p++));
32 | }
33 |
34 |
35 | int luaZ_lookahead (ZIO *z) {
36 | if (z->n == 0) {
37 | if (luaZ_fill(z) == EOZ)
38 | return EOZ;
39 | else {
40 | z->n++; /* luaZ_fill removed first byte; put back it */
41 | z->p--;
42 | }
43 | }
44 | return char2int(*z->p);
45 | }
46 |
47 |
48 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
49 | z->L = L;
50 | z->reader = reader;
51 | z->data = data;
52 | z->n = 0;
53 | z->p = NULL;
54 | }
55 |
56 |
57 | /* --------------------------------------------------------------- read --- */
58 | size_t luaZ_read (ZIO *z, void *b, size_t n) {
59 | while (n) {
60 | size_t m;
61 | if (luaZ_lookahead(z) == EOZ)
62 | return n; /* return number of missing bytes */
63 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */
64 | memcpy(b, z->p, m);
65 | z->n -= m;
66 | z->p += m;
67 | b = (char *)b + m;
68 | n -= m;
69 | }
70 | return 0;
71 | }
72 |
73 | /* ------------------------------------------------------------------------ */
74 | char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) {
75 | if (n > buff->buffsize) {
76 | if (n < LUA_MINBUFFER) n = LUA_MINBUFFER;
77 | luaZ_resizebuffer(L, buff, n);
78 | }
79 | return buff->buffer;
80 | }
81 |
82 |
83 |
--------------------------------------------------------------------------------
/TODO:
--------------------------------------------------------------------------------
1 | Redis TODO
2 | ----------
3 |
4 | WARNING: are you a possible Redis contributor?
5 | Before implementing what is listed in this file
6 | please drop a message in the Redis google group or chat with
7 | antirez or pietern on irc.freenode.org #redis to check if the work
8 | is already in progress and if the feature is still interesting for
9 | us, and *how* exactly this can be implemented to have good changes
10 | of a merge. Otherwise it is probably wasted work! Thank you
11 |
12 |
13 | CLUSTER
14 | =======
15 |
16 | * Implement rehashing and cluster check in redis-trib.
17 | * Reimplement MIGRATE / RESTORE to use just in memory buffers (no disk at
18 | all). This will require touching a lot of the RDB stuff around, but we may
19 | hand with faster persistence for RDB.
20 | * Implement the slave nodes semantics and election.
21 | * Allow redis-trib to create a cluster-wide snapshot (using SYNC).
22 | * Allow redis-trib to restore a cluster-wide snapshot (implement UPLOAD?).
23 |
24 | SCRIPTING
25 | =========
26 |
27 | * SCRIPT FLUSH or alike to start a fresh interpreter?
28 |
29 | OPTIMIZATIONS
30 | =============
31 |
32 | * SORT: Don't copy the list into a vector when BY argument is constant.
33 | * Write the hash table size of every db in the dump, so that Redis can resize the hash table just one time when loading a big DB.
34 | * Read-only mode for slaves.
35 | * Redis big lists as linked lists of small ziplists?
36 | Possibly a simple heuristic that join near nodes when some node gets smaller than the low_level, and split it into two if gets bigger than high_level.
37 |
38 | KNOWN BUGS
39 | ==========
40 |
41 | * #519: Slave may have expired keys that were never read in the master (so a DEL
42 | is not sent in the replication channel) but are already expired since
43 | a lot of time. Maybe after a given delay that is undoubtably greater than
44 | the replication link latency we should expire this key on the slave on
45 | access?
46 |
--------------------------------------------------------------------------------
/deps/lua/src/ldo.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Stack and Call structure of Lua
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef ldo_h
8 | #define ldo_h
9 |
10 |
11 | #include "lobject.h"
12 | #include "lstate.h"
13 | #include "lzio.h"
14 |
15 |
16 | #define luaD_checkstack(L,n) \
17 | if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \
18 | luaD_growstack(L, n); \
19 | else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1));
20 |
21 |
22 | #define incr_top(L) {luaD_checkstack(L,1); L->top++;}
23 |
24 | #define savestack(L,p) ((char *)(p) - (char *)L->stack)
25 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n)))
26 |
27 | #define saveci(L,p) ((char *)(p) - (char *)L->base_ci)
28 | #define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n)))
29 |
30 |
31 | /* results from luaD_precall */
32 | #define PCRLUA 0 /* initiated a call to a Lua function */
33 | #define PCRC 1 /* did a call to a C function */
34 | #define PCRYIELD 2 /* C funtion yielded */
35 |
36 |
37 | /* type of protected functions, to be ran by `runprotected' */
38 | typedef void (*Pfunc) (lua_State *L, void *ud);
39 |
40 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name);
41 | LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line);
42 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults);
43 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
44 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
45 | ptrdiff_t oldtop, ptrdiff_t ef);
46 | LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult);
47 | LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize);
48 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
49 | LUAI_FUNC void luaD_growstack (lua_State *L, int n);
50 |
51 | LUAI_FUNC void luaD_throw (lua_State *L, int errcode);
52 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
53 |
54 | LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop);
55 |
56 | #endif
57 |
58 |
--------------------------------------------------------------------------------
/deps/hiredis/example.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "hiredis.h"
6 |
7 | int main(void) {
8 | unsigned int j;
9 | redisContext *c;
10 | redisReply *reply;
11 |
12 | struct timeval timeout = { 1, 500000 }; // 1.5 seconds
13 | c = redisConnectWithTimeout((char*)"127.0.0.2", 6379, timeout);
14 | if (c->err) {
15 | printf("Connection error: %s\n", c->errstr);
16 | exit(1);
17 | }
18 |
19 | /* PING server */
20 | reply = redisCommand(c,"PING");
21 | printf("PING: %s\n", reply->str);
22 | freeReplyObject(reply);
23 |
24 | /* Set a key */
25 | reply = redisCommand(c,"SET %s %s", "foo", "hello world");
26 | printf("SET: %s\n", reply->str);
27 | freeReplyObject(reply);
28 |
29 | /* Set a key using binary safe API */
30 | reply = redisCommand(c,"SET %b %b", "bar", 3, "hello", 5);
31 | printf("SET (binary API): %s\n", reply->str);
32 | freeReplyObject(reply);
33 |
34 | /* Try a GET and two INCR */
35 | reply = redisCommand(c,"GET foo");
36 | printf("GET foo: %s\n", reply->str);
37 | freeReplyObject(reply);
38 |
39 | reply = redisCommand(c,"INCR counter");
40 | printf("INCR counter: %lld\n", reply->integer);
41 | freeReplyObject(reply);
42 | /* again ... */
43 | reply = redisCommand(c,"INCR counter");
44 | printf("INCR counter: %lld\n", reply->integer);
45 | freeReplyObject(reply);
46 |
47 | /* Create a list of numbers, from 0 to 9 */
48 | reply = redisCommand(c,"DEL mylist");
49 | freeReplyObject(reply);
50 | for (j = 0; j < 10; j++) {
51 | char buf[64];
52 |
53 | snprintf(buf,64,"%d",j);
54 | reply = redisCommand(c,"LPUSH mylist element-%s", buf);
55 | freeReplyObject(reply);
56 | }
57 |
58 | /* Let's check what we have inside the list */
59 | reply = redisCommand(c,"LRANGE mylist 0 -1");
60 | if (reply->type == REDIS_REPLY_ARRAY) {
61 | for (j = 0; j < reply->elements; j++) {
62 | printf("%u) %s\n", j, reply->element[j]->str);
63 | }
64 | }
65 | freeReplyObject(reply);
66 |
67 | return 0;
68 | }
69 |
--------------------------------------------------------------------------------
/deps/jemalloc/include/jemalloc/internal/hash.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 | uint64_t hash(const void *key, size_t len, uint64_t seed);
18 | #endif
19 |
20 | #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_HASH_C_))
21 | /*
22 | * The following hash function is based on MurmurHash64A(), placed into the
23 | * public domain by Austin Appleby. See http://murmurhash.googlepages.com/ for
24 | * details.
25 | */
26 | JEMALLOC_INLINE uint64_t
27 | hash(const void *key, size_t len, uint64_t seed)
28 | {
29 | const uint64_t m = 0xc6a4a7935bd1e995LLU;
30 | const int r = 47;
31 | uint64_t h = seed ^ (len * m);
32 | const uint64_t *data = (const uint64_t *)key;
33 | const uint64_t *end = data + (len/8);
34 | const unsigned char *data2;
35 |
36 | assert(((uintptr_t)key & 0x7) == 0);
37 |
38 | while(data != end) {
39 | uint64_t k = *data++;
40 |
41 | k *= m;
42 | k ^= k >> r;
43 | k *= m;
44 |
45 | h ^= k;
46 | h *= m;
47 | }
48 |
49 | data2 = (const unsigned char *)data;
50 | switch(len & 7) {
51 | case 7: h ^= ((uint64_t)(data2[6])) << 48;
52 | case 6: h ^= ((uint64_t)(data2[5])) << 40;
53 | case 5: h ^= ((uint64_t)(data2[4])) << 32;
54 | case 4: h ^= ((uint64_t)(data2[3])) << 24;
55 | case 3: h ^= ((uint64_t)(data2[2])) << 16;
56 | case 2: h ^= ((uint64_t)(data2[1])) << 8;
57 | case 1: h ^= ((uint64_t)(data2[0]));
58 | h *= m;
59 | }
60 |
61 | h ^= h >> r;
62 | h *= m;
63 | h ^= h >> r;
64 |
65 | return (h);
66 | }
67 | #endif
68 |
69 | #endif /* JEMALLOC_H_INLINES */
70 | /******************************************************************************/
71 |
--------------------------------------------------------------------------------
/tests/integration/replication.tcl:
--------------------------------------------------------------------------------
1 | start_server {tags {"repl"}} {
2 | start_server {} {
3 | test {First server should have role slave after SLAVEOF} {
4 | r -1 slaveof [srv 0 host] [srv 0 port]
5 | after 1000
6 | s -1 role
7 | } {slave}
8 |
9 | test {BRPOPLPUSH replication, when blocking against empty list} {
10 | set rd [redis_deferring_client]
11 | $rd brpoplpush a b 5
12 | r lpush a foo
13 | after 1000
14 | assert_equal [r debug digest] [r -1 debug digest]
15 | }
16 |
17 | test {BRPOPLPUSH replication, list exists} {
18 | set rd [redis_deferring_client]
19 | r lpush c 1
20 | r lpush c 2
21 | r lpush c 3
22 | $rd brpoplpush c d 5
23 | after 1000
24 | assert_equal [r debug digest] [r -1 debug digest]
25 | }
26 | }
27 | }
28 |
29 | start_server {tags {"repl"}} {
30 | r set mykey foo
31 |
32 | start_server {} {
33 | test {Second server should have role master at first} {
34 | s role
35 | } {master}
36 |
37 | test {SLAVEOF should start with link status "down"} {
38 | r slaveof [srv -1 host] [srv -1 port]
39 | s master_link_status
40 | } {down}
41 |
42 | test {The role should immediately be changed to "slave"} {
43 | s role
44 | } {slave}
45 |
46 | wait_for_sync r
47 | test {Sync should have transferred keys from master} {
48 | r get mykey
49 | } {foo}
50 |
51 | test {The link status should be up} {
52 | s master_link_status
53 | } {up}
54 |
55 | test {SET on the master should immediately propagate} {
56 | r -1 set mykey bar
57 | if {$::valgrind} {after 2000}
58 | r 0 get mykey
59 | } {bar}
60 |
61 | test {FLUSHALL should replicate} {
62 | r -1 flushall
63 | if {$::valgrind} {after 2000}
64 | list [r -1 dbsize] [r 0 dbsize]
65 | } {0 0}
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/deps/jemalloc/test/thread_arena.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | #define JEMALLOC_MANGLE
8 | #include "jemalloc_test.h"
9 |
10 | #define NTHREADS 10
11 |
12 | void *
13 | thread_start(void *arg)
14 | {
15 | unsigned main_arena_ind = *(unsigned *)arg;
16 | void *p;
17 | unsigned arena_ind;
18 | size_t size;
19 | int err;
20 |
21 | p = JEMALLOC_P(malloc)(1);
22 | if (p == NULL) {
23 | fprintf(stderr, "%s(): Error in malloc()\n", __func__);
24 | return (void *)1;
25 | }
26 |
27 | size = sizeof(arena_ind);
28 | if ((err = JEMALLOC_P(mallctl)("thread.arena", &arena_ind, &size,
29 | &main_arena_ind, sizeof(main_arena_ind)))) {
30 | fprintf(stderr, "%s(): Error in mallctl(): %s\n", __func__,
31 | strerror(err));
32 | return (void *)1;
33 | }
34 |
35 | size = sizeof(arena_ind);
36 | if ((err = JEMALLOC_P(mallctl)("thread.arena", &arena_ind, &size, NULL,
37 | 0))) {
38 | fprintf(stderr, "%s(): Error in mallctl(): %s\n", __func__,
39 | strerror(err));
40 | return (void *)1;
41 | }
42 | assert(arena_ind == main_arena_ind);
43 |
44 | return (NULL);
45 | }
46 |
47 | int
48 | main(void)
49 | {
50 | int ret = 0;
51 | void *p;
52 | unsigned arena_ind;
53 | size_t size;
54 | int err;
55 | pthread_t threads[NTHREADS];
56 | unsigned i;
57 |
58 | fprintf(stderr, "Test begin\n");
59 |
60 | p = JEMALLOC_P(malloc)(1);
61 | if (p == NULL) {
62 | fprintf(stderr, "%s(): Error in malloc()\n", __func__);
63 | ret = 1;
64 | goto RETURN;
65 | }
66 |
67 | size = sizeof(arena_ind);
68 | if ((err = JEMALLOC_P(mallctl)("thread.arena", &arena_ind, &size, NULL,
69 | 0))) {
70 | fprintf(stderr, "%s(): Error in mallctl(): %s\n", __func__,
71 | strerror(err));
72 | ret = 1;
73 | goto RETURN;
74 | }
75 |
76 | for (i = 0; i < NTHREADS; i++) {
77 | if (pthread_create(&threads[i], NULL, thread_start,
78 | (void *)&arena_ind) != 0) {
79 | fprintf(stderr, "%s(): Error in pthread_create()\n",
80 | __func__);
81 | ret = 1;
82 | goto RETURN;
83 | }
84 | }
85 |
86 | for (i = 0; i < NTHREADS; i++)
87 | pthread_join(threads[i], (void *)&ret);
88 |
89 | RETURN:
90 | fprintf(stderr, "Test end\n");
91 | return (ret);
92 | }
93 |
--------------------------------------------------------------------------------
/deps/jemalloc/include/jemalloc/internal/prn.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************/
2 | #ifdef JEMALLOC_H_TYPES
3 |
4 | /*
5 | * Simple linear congruential pseudo-random number generator:
6 | *
7 | * prn(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 prn32(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 prn32(), but 64 bits of pseudo-randomness, using uint64_t. */
38 | #define prn64(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/hiredis/net.h:
--------------------------------------------------------------------------------
1 | /* Extracted from anet.c to work properly with Hiredis error reporting.
2 | *
3 | * Copyright (c) 2006-2010, Salvatore Sanfilippo
4 | * Copyright (c) 2010, Pieter Noordhuis
5 | *
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without
9 | * modification, are permitted provided that the following conditions are met:
10 | *
11 | * * Redistributions of source code must retain the above copyright notice,
12 | * this list of conditions and the following disclaimer.
13 | * * Redistributions in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in the
15 | * documentation and/or other materials provided with the distribution.
16 | * * Neither the name of Redis nor the names of its contributors may be used
17 | * to endorse or promote products derived from this software without
18 | * specific prior written permission.
19 | *
20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 | * POSSIBILITY OF SUCH DAMAGE.
31 | */
32 |
33 | #ifndef __NET_H
34 | #define __NET_H
35 |
36 | #include "hiredis.h"
37 |
38 | #if defined(__sun)
39 | #define AF_LOCAL AF_UNIX
40 | #endif
41 |
42 | int redisContextSetTimeout(redisContext *c, struct timeval tv);
43 | int redisContextConnectTcp(redisContext *c, const char *addr, int port, struct timeval *timeout);
44 | int redisContextConnectUnix(redisContext *c, const char *path, struct timeval *timeout);
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/deps/jemalloc/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 | #ifdef JEMALLOC_SWAP
32 | extern bool opt_overcommit;
33 | #endif
34 |
35 | #if (defined(JEMALLOC_STATS) || defined(JEMALLOC_PROF))
36 | /* Protects stats_chunks; currently not used for any other purpose. */
37 | extern malloc_mutex_t chunks_mtx;
38 | /* Chunk statistics. */
39 | extern chunk_stats_t stats_chunks;
40 | #endif
41 |
42 | #ifdef JEMALLOC_IVSALLOC
43 | extern rtree_t *chunks_rtree;
44 | #endif
45 |
46 | extern size_t chunksize;
47 | extern size_t chunksize_mask; /* (chunksize - 1). */
48 | extern size_t chunk_npages;
49 | extern size_t map_bias; /* Number of arena chunk header pages. */
50 | extern size_t arena_maxclass; /* Max size class for arenas. */
51 |
52 | void *chunk_alloc(size_t size, bool base, bool *zero);
53 | void chunk_dealloc(void *chunk, size_t size, bool unmap);
54 | bool chunk_boot(void);
55 |
56 | #endif /* JEMALLOC_H_EXTERNS */
57 | /******************************************************************************/
58 | #ifdef JEMALLOC_H_INLINES
59 |
60 | #endif /* JEMALLOC_H_INLINES */
61 | /******************************************************************************/
62 |
63 | #include "jemalloc/internal/chunk_swap.h"
64 | #include "jemalloc/internal/chunk_dss.h"
65 | #include "jemalloc/internal/chunk_mmap.h"
66 |
--------------------------------------------------------------------------------
/tests/unit/protocol.tcl:
--------------------------------------------------------------------------------
1 | start_server {tags {"protocol"}} {
2 | test "Handle an empty query" {
3 | reconnect
4 | r write "\r\n"
5 | r flush
6 | assert_equal "PONG" [r ping]
7 | }
8 |
9 | test "Negative multibulk length" {
10 | reconnect
11 | r write "*-10\r\n"
12 | r flush
13 | assert_equal PONG [r ping]
14 | }
15 |
16 | test "Out of range multibulk length" {
17 | reconnect
18 | r write "*20000000\r\n"
19 | r flush
20 | assert_error "*invalid multibulk length*" {r read}
21 | }
22 |
23 | test "Wrong multibulk payload header" {
24 | reconnect
25 | r write "*3\r\n\$3\r\nSET\r\n\$1\r\nx\r\nfooz\r\n"
26 | r flush
27 | assert_error "*expected '$', got 'f'*" {r read}
28 | }
29 |
30 | test "Negative multibulk payload length" {
31 | reconnect
32 | r write "*3\r\n\$3\r\nSET\r\n\$1\r\nx\r\n\$-10\r\n"
33 | r flush
34 | assert_error "*invalid bulk length*" {r read}
35 | }
36 |
37 | test "Out of range multibulk payload length" {
38 | reconnect
39 | r write "*3\r\n\$3\r\nSET\r\n\$1\r\nx\r\n\$2000000000\r\n"
40 | r flush
41 | assert_error "*invalid bulk length*" {r read}
42 | }
43 |
44 | test "Non-number multibulk payload length" {
45 | reconnect
46 | r write "*3\r\n\$3\r\nSET\r\n\$1\r\nx\r\n\$blabla\r\n"
47 | r flush
48 | assert_error "*invalid bulk length*" {r read}
49 | }
50 |
51 | test "Multi bulk request not followed by bulk arguments" {
52 | reconnect
53 | r write "*1\r\nfoo\r\n"
54 | r flush
55 | assert_error "*expected '$', got 'f'*" {r read}
56 | }
57 |
58 | test "Generic wrong number of args" {
59 | reconnect
60 | assert_error "*wrong*arguments*ping*" {r ping x y z}
61 | }
62 | }
63 |
64 | start_server {tags {"regression"}} {
65 | test "Regression for a crash with blocking ops and pipelining" {
66 | set rd [redis_deferring_client]
67 | set fd [r channel]
68 | set proto "*3\r\n\$5\r\nBLPOP\r\n\$6\r\nnolist\r\n\$1\r\n0\r\n"
69 | puts -nonewline $fd $proto$proto
70 | flush $fd
71 | set res {}
72 |
73 | $rd rpush nolist a
74 | $rd read
75 | $rd rpush nolist a
76 | $rd read
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/deps/jemalloc/include/jemalloc/internal/mutex.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************/
2 | #ifdef JEMALLOC_H_TYPES
3 |
4 | #ifdef JEMALLOC_OSSPIN
5 | typedef OSSpinLock malloc_mutex_t;
6 | #else
7 | typedef pthread_mutex_t malloc_mutex_t;
8 | #endif
9 |
10 | #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
11 | # define MALLOC_MUTEX_INITIALIZER PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
12 | #else
13 | # define MALLOC_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
14 | #endif
15 |
16 | #endif /* JEMALLOC_H_TYPES */
17 | /******************************************************************************/
18 | #ifdef JEMALLOC_H_STRUCTS
19 |
20 | #endif /* JEMALLOC_H_STRUCTS */
21 | /******************************************************************************/
22 | #ifdef JEMALLOC_H_EXTERNS
23 |
24 | #ifdef JEMALLOC_LAZY_LOCK
25 | extern bool isthreaded;
26 | #else
27 | # define isthreaded true
28 | #endif
29 |
30 | bool malloc_mutex_init(malloc_mutex_t *mutex);
31 | void malloc_mutex_destroy(malloc_mutex_t *mutex);
32 |
33 | #endif /* JEMALLOC_H_EXTERNS */
34 | /******************************************************************************/
35 | #ifdef JEMALLOC_H_INLINES
36 |
37 | #ifndef JEMALLOC_ENABLE_INLINE
38 | void malloc_mutex_lock(malloc_mutex_t *mutex);
39 | bool malloc_mutex_trylock(malloc_mutex_t *mutex);
40 | void malloc_mutex_unlock(malloc_mutex_t *mutex);
41 | #endif
42 |
43 | #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_MUTEX_C_))
44 | JEMALLOC_INLINE void
45 | malloc_mutex_lock(malloc_mutex_t *mutex)
46 | {
47 |
48 | if (isthreaded) {
49 | #ifdef JEMALLOC_OSSPIN
50 | OSSpinLockLock(mutex);
51 | #else
52 | pthread_mutex_lock(mutex);
53 | #endif
54 | }
55 | }
56 |
57 | JEMALLOC_INLINE bool
58 | malloc_mutex_trylock(malloc_mutex_t *mutex)
59 | {
60 |
61 | if (isthreaded) {
62 | #ifdef JEMALLOC_OSSPIN
63 | return (OSSpinLockTry(mutex) == false);
64 | #else
65 | return (pthread_mutex_trylock(mutex) != 0);
66 | #endif
67 | } else
68 | return (false);
69 | }
70 |
71 | JEMALLOC_INLINE void
72 | malloc_mutex_unlock(malloc_mutex_t *mutex)
73 | {
74 |
75 | if (isthreaded) {
76 | #ifdef JEMALLOC_OSSPIN
77 | OSSpinLockUnlock(mutex);
78 | #else
79 | pthread_mutex_unlock(mutex);
80 | #endif
81 | }
82 | }
83 | #endif
84 |
85 | #endif /* JEMALLOC_H_INLINES */
86 | /******************************************************************************/
87 |
--------------------------------------------------------------------------------
/src/ae_select.c:
--------------------------------------------------------------------------------
1 | /* Select()-based ae.c module
2 | * Copyright (C) 2009-2010 Salvatore Sanfilippo - antirez@gmail.com
3 | * Released under the BSD license. See the COPYING file for more info. */
4 |
5 | #include
6 |
7 | typedef struct aeApiState {
8 | fd_set rfds, wfds;
9 | /* We need to have a copy of the fd sets as it's not safe to reuse
10 | * FD sets after select(). */
11 | fd_set _rfds, _wfds;
12 | } aeApiState;
13 |
14 | static int aeApiCreate(aeEventLoop *eventLoop) {
15 | aeApiState *state = zmalloc(sizeof(aeApiState));
16 |
17 | if (!state) return -1;
18 | FD_ZERO(&state->rfds);
19 | FD_ZERO(&state->wfds);
20 | eventLoop->apidata = state;
21 | return 0;
22 | }
23 |
24 | static void aeApiFree(aeEventLoop *eventLoop) {
25 | zfree(eventLoop->apidata);
26 | }
27 |
28 | static int aeApiAddEvent(aeEventLoop *eventLoop, int fd, int mask) {
29 | aeApiState *state = eventLoop->apidata;
30 |
31 | if (mask & AE_READABLE) FD_SET(fd,&state->rfds);
32 | if (mask & AE_WRITABLE) FD_SET(fd,&state->wfds);
33 | return 0;
34 | }
35 |
36 | static void aeApiDelEvent(aeEventLoop *eventLoop, int fd, int mask) {
37 | aeApiState *state = eventLoop->apidata;
38 |
39 | if (mask & AE_READABLE) FD_CLR(fd,&state->rfds);
40 | if (mask & AE_WRITABLE) FD_CLR(fd,&state->wfds);
41 | }
42 |
43 | static int aeApiPoll(aeEventLoop *eventLoop, struct timeval *tvp) {
44 | aeApiState *state = eventLoop->apidata;
45 | int retval, j, numevents = 0;
46 |
47 | memcpy(&state->_rfds,&state->rfds,sizeof(fd_set));
48 | memcpy(&state->_wfds,&state->wfds,sizeof(fd_set));
49 |
50 | retval = select(eventLoop->maxfd+1,
51 | &state->_rfds,&state->_wfds,NULL,tvp);
52 | if (retval > 0) {
53 | for (j = 0; j <= eventLoop->maxfd; j++) {
54 | int mask = 0;
55 | aeFileEvent *fe = &eventLoop->events[j];
56 |
57 | if (fe->mask == AE_NONE) continue;
58 | if (fe->mask & AE_READABLE && FD_ISSET(j,&state->_rfds))
59 | mask |= AE_READABLE;
60 | if (fe->mask & AE_WRITABLE && FD_ISSET(j,&state->_wfds))
61 | mask |= AE_WRITABLE;
62 | eventLoop->fired[numevents].fd = j;
63 | eventLoop->fired[numevents].mask = mask;
64 | numevents++;
65 | }
66 | }
67 | return numevents;
68 | }
69 |
70 | static char *aeApiName(void) {
71 | return "select";
72 | }
73 |
--------------------------------------------------------------------------------
/deps/jemalloc/src/mutex.c:
--------------------------------------------------------------------------------
1 | #define JEMALLOC_MUTEX_C_
2 | #include "jemalloc/internal/jemalloc_internal.h"
3 |
4 | /******************************************************************************/
5 | /* Data. */
6 |
7 | #ifdef JEMALLOC_LAZY_LOCK
8 | bool isthreaded = false;
9 | #endif
10 |
11 | #ifdef JEMALLOC_LAZY_LOCK
12 | static void pthread_create_once(void);
13 | #endif
14 |
15 | /******************************************************************************/
16 | /*
17 | * We intercept pthread_create() calls in order to toggle isthreaded if the
18 | * process goes multi-threaded.
19 | */
20 |
21 | #ifdef JEMALLOC_LAZY_LOCK
22 | static int (*pthread_create_fptr)(pthread_t *__restrict, const pthread_attr_t *,
23 | void *(*)(void *), void *__restrict);
24 |
25 | static void
26 | pthread_create_once(void)
27 | {
28 |
29 | pthread_create_fptr = dlsym(RTLD_NEXT, "pthread_create");
30 | if (pthread_create_fptr == NULL) {
31 | malloc_write(": Error in dlsym(RTLD_NEXT, "
32 | "\"pthread_create\")\n");
33 | abort();
34 | }
35 |
36 | isthreaded = true;
37 | }
38 |
39 | JEMALLOC_ATTR(visibility("default"))
40 | int
41 | pthread_create(pthread_t *__restrict thread,
42 | const pthread_attr_t *__restrict attr, void *(*start_routine)(void *),
43 | void *__restrict arg)
44 | {
45 | static pthread_once_t once_control = PTHREAD_ONCE_INIT;
46 |
47 | pthread_once(&once_control, pthread_create_once);
48 |
49 | return (pthread_create_fptr(thread, attr, start_routine, arg));
50 | }
51 | #endif
52 |
53 | /******************************************************************************/
54 |
55 | bool
56 | malloc_mutex_init(malloc_mutex_t *mutex)
57 | {
58 | #ifdef JEMALLOC_OSSPIN
59 | *mutex = 0;
60 | #else
61 | pthread_mutexattr_t attr;
62 |
63 | if (pthread_mutexattr_init(&attr) != 0)
64 | return (true);
65 | #ifdef PTHREAD_MUTEX_ADAPTIVE_NP
66 | pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
67 | #else
68 | pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_DEFAULT);
69 | #endif
70 | if (pthread_mutex_init(mutex, &attr) != 0) {
71 | pthread_mutexattr_destroy(&attr);
72 | return (true);
73 | }
74 | pthread_mutexattr_destroy(&attr);
75 |
76 | #endif
77 | return (false);
78 | }
79 |
80 | void
81 | malloc_mutex_destroy(malloc_mutex_t *mutex)
82 | {
83 |
84 | #ifndef JEMALLOC_OSSPIN
85 | if (pthread_mutex_destroy(mutex) != 0) {
86 | malloc_write(": Error in pthread_mutex_destroy()\n");
87 | abort();
88 | }
89 | #endif
90 | }
91 |
--------------------------------------------------------------------------------
/deps/lua/src/llex.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Lexical Analyzer
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef llex_h
8 | #define llex_h
9 |
10 | #include "lobject.h"
11 | #include "lzio.h"
12 |
13 |
14 | #define FIRST_RESERVED 257
15 |
16 | /* maximum length of a reserved word */
17 | #define TOKEN_LEN (sizeof("function")/sizeof(char))
18 |
19 |
20 | /*
21 | * WARNING: if you change the order of this enumeration,
22 | * grep "ORDER RESERVED"
23 | */
24 | enum RESERVED {
25 | /* terminal symbols denoted by reserved words */
26 | TK_AND = FIRST_RESERVED, TK_BREAK,
27 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION,
28 | TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT,
29 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
30 | /* other terminal symbols */
31 | TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER,
32 | TK_NAME, TK_STRING, TK_EOS
33 | };
34 |
35 | /* number of reserved words */
36 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))
37 |
38 |
39 | /* array with token `names' */
40 | LUAI_DATA const char *const luaX_tokens [];
41 |
42 |
43 | typedef union {
44 | lua_Number r;
45 | TString *ts;
46 | } SemInfo; /* semantics information */
47 |
48 |
49 | typedef struct Token {
50 | int token;
51 | SemInfo seminfo;
52 | } Token;
53 |
54 |
55 | typedef struct LexState {
56 | int current; /* current character (charint) */
57 | int linenumber; /* input line counter */
58 | int lastline; /* line of last token `consumed' */
59 | Token t; /* current token */
60 | Token lookahead; /* look ahead token */
61 | struct FuncState *fs; /* `FuncState' is private to the parser */
62 | struct lua_State *L;
63 | ZIO *z; /* input stream */
64 | Mbuffer *buff; /* buffer for tokens */
65 | TString *source; /* current source name */
66 | char decpoint; /* locale decimal point */
67 | } LexState;
68 |
69 |
70 | LUAI_FUNC void luaX_init (lua_State *L);
71 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z,
72 | TString *source);
73 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);
74 | LUAI_FUNC void luaX_next (LexState *ls);
75 | LUAI_FUNC void luaX_lookahead (LexState *ls);
76 | LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token);
77 | LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s);
78 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token);
79 |
80 |
81 | #endif
82 |
--------------------------------------------------------------------------------
/deps/lua/src/lmem.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Interface to Memory Manager
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 |
8 | #include
9 |
10 | #define lmem_c
11 | #define LUA_CORE
12 |
13 | #include "lua.h"
14 |
15 | #include "ldebug.h"
16 | #include "ldo.h"
17 | #include "lmem.h"
18 | #include "lobject.h"
19 | #include "lstate.h"
20 |
21 |
22 |
23 | /*
24 | ** About the realloc function:
25 | ** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize);
26 | ** (`osize' is the old size, `nsize' is the new size)
27 | **
28 | ** Lua ensures that (ptr == NULL) iff (osize == 0).
29 | **
30 | ** * frealloc(ud, NULL, 0, x) creates a new block of size `x'
31 | **
32 | ** * frealloc(ud, p, x, 0) frees the block `p'
33 | ** (in this specific case, frealloc must return NULL).
34 | ** particularly, frealloc(ud, NULL, 0, 0) does nothing
35 | ** (which is equivalent to free(NULL) in ANSI C)
36 | **
37 | ** frealloc returns NULL if it cannot create or reallocate the area
38 | ** (any reallocation to an equal or smaller size cannot fail!)
39 | */
40 |
41 |
42 |
43 | #define MINSIZEARRAY 4
44 |
45 |
46 | void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems,
47 | int limit, const char *errormsg) {
48 | void *newblock;
49 | int newsize;
50 | if (*size >= limit/2) { /* cannot double it? */
51 | if (*size >= limit) /* cannot grow even a little? */
52 | luaG_runerror(L, errormsg);
53 | newsize = limit; /* still have at least one free place */
54 | }
55 | else {
56 | newsize = (*size)*2;
57 | if (newsize < MINSIZEARRAY)
58 | newsize = MINSIZEARRAY; /* minimum size */
59 | }
60 | newblock = luaM_reallocv(L, block, *size, newsize, size_elems);
61 | *size = newsize; /* update only when everything else is OK */
62 | return newblock;
63 | }
64 |
65 |
66 | void *luaM_toobig (lua_State *L) {
67 | luaG_runerror(L, "memory allocation error: block too big");
68 | return NULL; /* to avoid warnings */
69 | }
70 |
71 |
72 |
73 | /*
74 | ** generic allocation routine.
75 | */
76 | void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) {
77 | global_State *g = G(L);
78 | lua_assert((osize == 0) == (block == NULL));
79 | block = (*g->frealloc)(g->ud, block, osize, nsize);
80 | if (block == NULL && nsize > 0)
81 | luaD_throw(L, LUA_ERRMEM);
82 | lua_assert((nsize == 0) == (block == NULL));
83 | g->totalbytes = (g->totalbytes - osize) + nsize;
84 | return block;
85 | }
86 |
87 |
--------------------------------------------------------------------------------
/deps/jemalloc/include/jemalloc/jemalloc.h.in:
--------------------------------------------------------------------------------
1 | #ifndef JEMALLOC_H_
2 | #define JEMALLOC_H_
3 | #ifdef __cplusplus
4 | extern "C" {
5 | #endif
6 |
7 | #include
8 | #include
9 |
10 | #define JEMALLOC_VERSION "@jemalloc_version@"
11 | #define JEMALLOC_VERSION_MAJOR @jemalloc_version_major@
12 | #define JEMALLOC_VERSION_MINOR @jemalloc_version_minor@
13 | #define JEMALLOC_VERSION_BUGFIX @jemalloc_version_bugfix@
14 | #define JEMALLOC_VERSION_NREV @jemalloc_version_nrev@
15 | #define JEMALLOC_VERSION_GID "@jemalloc_version_gid@"
16 |
17 | #include "jemalloc_defs@install_suffix@.h"
18 | #ifndef JEMALLOC_P
19 | # define JEMALLOC_P(s) s
20 | #endif
21 |
22 | #define ALLOCM_LG_ALIGN(la) (la)
23 | #if LG_SIZEOF_PTR == 2
24 | #define ALLOCM_ALIGN(a) (ffs(a)-1)
25 | #else
26 | #define ALLOCM_ALIGN(a) ((a < (size_t)INT_MAX) ? ffs(a)-1 : ffs(a>>32)+31)
27 | #endif
28 | #define ALLOCM_ZERO ((int)0x40)
29 | #define ALLOCM_NO_MOVE ((int)0x80)
30 |
31 | #define ALLOCM_SUCCESS 0
32 | #define ALLOCM_ERR_OOM 1
33 | #define ALLOCM_ERR_NOT_MOVED 2
34 |
35 | extern const char *JEMALLOC_P(malloc_conf);
36 | extern void (*JEMALLOC_P(malloc_message))(void *, const char *);
37 |
38 | void *JEMALLOC_P(malloc)(size_t size) JEMALLOC_ATTR(malloc);
39 | void *JEMALLOC_P(calloc)(size_t num, size_t size) JEMALLOC_ATTR(malloc);
40 | int JEMALLOC_P(posix_memalign)(void **memptr, size_t alignment, size_t size)
41 | JEMALLOC_ATTR(nonnull(1));
42 | void *JEMALLOC_P(realloc)(void *ptr, size_t size);
43 | void JEMALLOC_P(free)(void *ptr);
44 |
45 | size_t JEMALLOC_P(malloc_usable_size)(const void *ptr);
46 | void JEMALLOC_P(malloc_stats_print)(void (*write_cb)(void *, const char *),
47 | void *cbopaque, const char *opts);
48 | int JEMALLOC_P(mallctl)(const char *name, void *oldp, size_t *oldlenp,
49 | void *newp, size_t newlen);
50 | int JEMALLOC_P(mallctlnametomib)(const char *name, size_t *mibp,
51 | size_t *miblenp);
52 | int JEMALLOC_P(mallctlbymib)(const size_t *mib, size_t miblen, void *oldp,
53 | size_t *oldlenp, void *newp, size_t newlen);
54 |
55 | int JEMALLOC_P(allocm)(void **ptr, size_t *rsize, size_t size, int flags)
56 | JEMALLOC_ATTR(nonnull(1));
57 | int JEMALLOC_P(rallocm)(void **ptr, size_t *rsize, size_t size,
58 | size_t extra, int flags) JEMALLOC_ATTR(nonnull(1));
59 | int JEMALLOC_P(sallocm)(const void *ptr, size_t *rsize, int flags)
60 | JEMALLOC_ATTR(nonnull(1));
61 | int JEMALLOC_P(dallocm)(void *ptr, int flags) JEMALLOC_ATTR(nonnull(1));
62 |
63 | #ifdef __cplusplus
64 | };
65 | #endif
66 | #endif /* JEMALLOC_H_ */
67 |
--------------------------------------------------------------------------------
/src/testhelp.h:
--------------------------------------------------------------------------------
1 | /* This is a really minimal testing framework for C.
2 | *
3 | * Example:
4 | *
5 | * test_cond("Check if 1 == 1", 1==1)
6 | * test_cond("Check if 5 > 10", 5 > 10)
7 | * test_report()
8 | *
9 | * Copyright (c) 2010, Salvatore Sanfilippo
10 | * All rights reserved.
11 | *
12 | * Redistribution and use in source and binary forms, with or without
13 | * modification, are permitted provided that the following conditions are met:
14 | *
15 | * * Redistributions of source code must retain the above copyright notice,
16 | * this list of conditions and the following disclaimer.
17 | * * Redistributions in binary form must reproduce the above copyright
18 | * notice, this list of conditions and the following disclaimer in the
19 | * documentation and/or other materials provided with the distribution.
20 | * * Neither the name of Redis nor the names of its contributors may be used
21 | * to endorse or promote products derived from this software without
22 | * specific prior written permission.
23 | *
24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGE.
35 | */
36 |
37 | #ifndef __TESTHELP_H
38 | #define __TESTHELP_H
39 |
40 | int __failed_tests = 0;
41 | int __test_num = 0;
42 | #define test_cond(descr,_c) do { \
43 | __test_num++; printf("%d - %s: ", __test_num, descr); \
44 | if(_c) printf("PASSED\n"); else {printf("FAILED\n"); __failed_tests++;} \
45 | } while(0);
46 | #define test_report() do { \
47 | printf("%d tests, %d passed, %d failed\n", __test_num, \
48 | __test_num-__failed_tests, __failed_tests); \
49 | if (__failed_tests) { \
50 | printf("=== WARNING === We have failed tests here...\n"); \
51 | exit(1); \
52 | } \
53 | } while(0);
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/deps/jemalloc/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/hiredis/adapters/libevent.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "../hiredis.h"
4 | #include "../async.h"
5 |
6 | typedef struct redisLibeventEvents {
7 | redisAsyncContext *context;
8 | struct event rev, wev;
9 | } redisLibeventEvents;
10 |
11 | void redisLibeventReadEvent(int fd, short event, void *arg) {
12 | ((void)fd); ((void)event);
13 | redisLibeventEvents *e = (redisLibeventEvents*)arg;
14 | redisAsyncHandleRead(e->context);
15 | }
16 |
17 | void redisLibeventWriteEvent(int fd, short event, void *arg) {
18 | ((void)fd); ((void)event);
19 | redisLibeventEvents *e = (redisLibeventEvents*)arg;
20 | redisAsyncHandleWrite(e->context);
21 | }
22 |
23 | void redisLibeventAddRead(void *privdata) {
24 | redisLibeventEvents *e = (redisLibeventEvents*)privdata;
25 | event_add(&e->rev,NULL);
26 | }
27 |
28 | void redisLibeventDelRead(void *privdata) {
29 | redisLibeventEvents *e = (redisLibeventEvents*)privdata;
30 | event_del(&e->rev);
31 | }
32 |
33 | void redisLibeventAddWrite(void *privdata) {
34 | redisLibeventEvents *e = (redisLibeventEvents*)privdata;
35 | event_add(&e->wev,NULL);
36 | }
37 |
38 | void redisLibeventDelWrite(void *privdata) {
39 | redisLibeventEvents *e = (redisLibeventEvents*)privdata;
40 | event_del(&e->wev);
41 | }
42 |
43 | void redisLibeventCleanup(void *privdata) {
44 | redisLibeventEvents *e = (redisLibeventEvents*)privdata;
45 | event_del(&e->rev);
46 | event_del(&e->wev);
47 | free(e);
48 | }
49 |
50 | int redisLibeventAttach(redisAsyncContext *ac, struct event_base *base) {
51 | redisContext *c = &(ac->c);
52 | redisLibeventEvents *e;
53 |
54 | /* Nothing should be attached when something is already attached */
55 | if (ac->_adapter_data != NULL)
56 | return REDIS_ERR;
57 |
58 | /* Create container for context and r/w events */
59 | e = (redisLibeventEvents*)malloc(sizeof(*e));
60 | e->context = ac;
61 |
62 | /* Register functions to start/stop listening for events */
63 | ac->evAddRead = redisLibeventAddRead;
64 | ac->evDelRead = redisLibeventDelRead;
65 | ac->evAddWrite = redisLibeventAddWrite;
66 | ac->evDelWrite = redisLibeventDelWrite;
67 | ac->evCleanup = redisLibeventCleanup;
68 | ac->_adapter_data = e;
69 |
70 | /* Initialize and install read/write events */
71 | event_set(&e->rev,c->fd,EV_READ,redisLibeventReadEvent,e);
72 | event_set(&e->wev,c->fd,EV_WRITE,redisLibeventWriteEvent,e);
73 | event_base_set(base,&e->rev);
74 | event_base_set(base,&e->wev);
75 | return REDIS_OK;
76 | }
77 |
--------------------------------------------------------------------------------
/utils/redis-copy.rb:
--------------------------------------------------------------------------------
1 | # redis-copy.rb - Copyright (C) 2009-2010 Salvatore Sanfilippo
2 | # BSD license, See the COPYING file for more information.
3 | #
4 | # Copy the whole dataset from one Redis instance to another one
5 | #
6 | # WARNING: currently hashes and sorted sets are not supported! This
7 | # program should be updated.
8 |
9 | require 'rubygems'
10 | require 'redis'
11 | require 'digest/sha1'
12 |
13 | def redisCopy(opts={})
14 | sha1=""
15 | src = Redis.new(:host => opts[:srchost], :port => opts[:srcport])
16 | dst = Redis.new(:host => opts[:dsthost], :port => opts[:dstport])
17 | puts "Loading key names..."
18 | keys = src.keys('*')
19 | puts "Copying #{keys.length} keys..."
20 | c = 0
21 | keys.each{|k|
22 | vtype = src.type?(k)
23 | ttl = src.ttl(k).to_i if vtype != "none"
24 |
25 | if vtype == "string"
26 | dst[k] = src[k]
27 | elsif vtype == "list"
28 | list = src.lrange(k,0,-1)
29 | if list.length == 0
30 | # Empty list special case
31 | dst.lpush(k,"")
32 | dst.lpop(k)
33 | else
34 | list.each{|ele|
35 | dst.rpush(k,ele)
36 | }
37 | end
38 | elsif vtype == "set"
39 | set = src.smembers(k)
40 | if set.length == 0
41 | # Empty set special case
42 | dst.sadd(k,"")
43 | dst.srem(k,"")
44 | else
45 | set.each{|ele|
46 | dst.sadd(k,ele)
47 | }
48 | end
49 | elsif vtype == "none"
50 | puts "WARNING: key '#{k}' was removed in the meanwhile."
51 | end
52 |
53 | # Handle keys with an expire time set
54 | if ttl != -1 and vtype != "none"
55 | dst.expire(k,ttl)
56 | end
57 |
58 | c = c+1
59 | if (c % 1000) == 0
60 | puts "#{c}/#{keys.length} completed"
61 | end
62 | }
63 | puts "DONE!"
64 | end
65 |
66 | if ARGV.length != 4
67 | puts "Usage: redis-copy.rb "
68 | exit 1
69 | end
70 | puts "WARNING: it's up to you to FLUSHDB the destination host before to continue, press any key when ready."
71 | STDIN.gets
72 | srchost = ARGV[0]
73 | srcport = ARGV[1]
74 | dsthost = ARGV[2]
75 | dstport = ARGV[3]
76 | puts "Copying #{srchost}:#{srcport} into #{dsthost}:#{dstport}"
77 | redisCopy(:srchost => srchost, :srcport => srcport.to_i,
78 | :dsthost => dsthost, :dstport => dstport.to_i)
79 |
--------------------------------------------------------------------------------
/deps/lua/src/lparser.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Lua Parser
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lparser_h
8 | #define lparser_h
9 |
10 | #include "llimits.h"
11 | #include "lobject.h"
12 | #include "lzio.h"
13 |
14 |
15 | /*
16 | ** Expression descriptor
17 | */
18 |
19 | typedef enum {
20 | VVOID, /* no value */
21 | VNIL,
22 | VTRUE,
23 | VFALSE,
24 | VK, /* info = index of constant in `k' */
25 | VKNUM, /* nval = numerical value */
26 | VLOCAL, /* info = local register */
27 | VUPVAL, /* info = index of upvalue in `upvalues' */
28 | VGLOBAL, /* info = index of table; aux = index of global name in `k' */
29 | VINDEXED, /* info = table register; aux = index register (or `k') */
30 | VJMP, /* info = instruction pc */
31 | VRELOCABLE, /* info = instruction pc */
32 | VNONRELOC, /* info = result register */
33 | VCALL, /* info = instruction pc */
34 | VVARARG /* info = instruction pc */
35 | } expkind;
36 |
37 | typedef struct expdesc {
38 | expkind k;
39 | union {
40 | struct { int info, aux; } s;
41 | lua_Number nval;
42 | } u;
43 | int t; /* patch list of `exit when true' */
44 | int f; /* patch list of `exit when false' */
45 | } expdesc;
46 |
47 |
48 | typedef struct upvaldesc {
49 | lu_byte k;
50 | lu_byte info;
51 | } upvaldesc;
52 |
53 |
54 | struct BlockCnt; /* defined in lparser.c */
55 |
56 |
57 | /* state needed to generate code for a given function */
58 | typedef struct FuncState {
59 | Proto *f; /* current function header */
60 | Table *h; /* table to find (and reuse) elements in `k' */
61 | struct FuncState *prev; /* enclosing function */
62 | struct LexState *ls; /* lexical state */
63 | struct lua_State *L; /* copy of the Lua state */
64 | struct BlockCnt *bl; /* chain of current blocks */
65 | int pc; /* next position to code (equivalent to `ncode') */
66 | int lasttarget; /* `pc' of last `jump target' */
67 | int jpc; /* list of pending jumps to `pc' */
68 | int freereg; /* first free register */
69 | int nk; /* number of elements in `k' */
70 | int np; /* number of elements in `p' */
71 | short nlocvars; /* number of elements in `locvars' */
72 | lu_byte nactvar; /* number of active local variables */
73 | upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */
74 | unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */
75 | } FuncState;
76 |
77 |
78 | LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
79 | const char *name);
80 |
81 |
82 | #endif
83 |
--------------------------------------------------------------------------------
/deps/linenoise/linenoise.h:
--------------------------------------------------------------------------------
1 | /* linenoise.h -- guerrilla line editing library against the idea that a
2 | * line editing lib needs to be 20,000 lines of C code.
3 | *
4 | * See linenoise.c for more information.
5 | *
6 | * Copyright (c) 2010, Salvatore Sanfilippo
7 | * Copyright (c) 2010, Pieter Noordhuis
8 | *
9 | * All rights reserved.
10 | *
11 | * Redistribution and use in source and binary forms, with or without
12 | * modification, are permitted provided that the following conditions are met:
13 | *
14 | * * Redistributions of source code must retain the above copyright notice,
15 | * this list of conditions and the following disclaimer.
16 | * * Redistributions in binary form must reproduce the above copyright
17 | * notice, this list of conditions and the following disclaimer in the
18 | * documentation and/or other materials provided with the distribution.
19 | * * Neither the name of Redis nor the names of its contributors may be used
20 | * to endorse or promote products derived from this software without
21 | * specific prior written permission.
22 | *
23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 | * POSSIBILITY OF SUCH DAMAGE.
34 | */
35 |
36 | #ifndef __LINENOISE_H
37 | #define __LINENOISE_H
38 |
39 | typedef struct linenoiseCompletions {
40 | size_t len;
41 | char **cvec;
42 | } linenoiseCompletions;
43 |
44 | typedef void(linenoiseCompletionCallback)(const char *, linenoiseCompletions *);
45 | void linenoiseSetCompletionCallback(linenoiseCompletionCallback *);
46 | void linenoiseAddCompletion(linenoiseCompletions *, char *);
47 |
48 | char *linenoise(const char *prompt);
49 | int linenoiseHistoryAdd(const char *line);
50 | int linenoiseHistorySetMaxLen(int len);
51 | int linenoiseHistorySave(char *filename);
52 | int linenoiseHistoryLoad(char *filename);
53 | void linenoiseClearScreen(void);
54 |
55 | #endif /* __LINENOISE_H */
56 |
--------------------------------------------------------------------------------
/utils/generate-command-help.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | GROUPS = [
4 | "generic",
5 | "string",
6 | "list",
7 | "set",
8 | "sorted_set",
9 | "hash",
10 | "pubsub",
11 | "transactions",
12 | "connection",
13 | "server"
14 | ].freeze
15 |
16 | GROUPS_BY_NAME = Hash[*
17 | GROUPS.each_with_index.map do |n,i|
18 | [n,i]
19 | end.flatten
20 | ].freeze
21 |
22 | def argument arg
23 | name = arg["name"].is_a?(Array) ? arg["name"].join(" ") : arg["name"]
24 | name = arg["enum"].join "|" if "enum" == arg["type"]
25 | name = arg["command"] + " " + name if arg["command"]
26 | if arg["multiple"]
27 | name = "#{name} [#{name} ...]"
28 | end
29 | if arg["optional"]
30 | name = "[#{name}]"
31 | end
32 | name
33 | end
34 |
35 | def arguments command
36 | return "-" unless command["arguments"]
37 | command["arguments"].map do |arg|
38 | argument arg
39 | end.join " "
40 | end
41 |
42 | def commands
43 | return @commands if @commands
44 |
45 | require "rubygems"
46 | require "net/http"
47 | require "net/https"
48 | require "json"
49 | require "uri"
50 |
51 | url = URI.parse "https://github.com/antirez/redis-doc/raw/master/commands.json"
52 | client = Net::HTTP.new url.host, url.port
53 | client.use_ssl = true
54 | response = client.get url.path
55 | if response.is_a?(Net::HTTPSuccess)
56 | @commands = JSON.parse(response.body)
57 | else
58 | response.error!
59 | end
60 | end
61 |
62 | def generate_groups
63 | GROUPS.map do |n|
64 | "\"#{n}\""
65 | end.join(",\n ");
66 | end
67 |
68 | def generate_commands
69 | commands.to_a.sort do |x,y|
70 | x[0] <=> y[0]
71 | end.map do |key, command|
72 | group = GROUPS_BY_NAME[command["group"]]
73 | if group.nil?
74 | STDERR.puts "Please update groups array in #{__FILE__}"
75 | raise "Unknown group #{command["group"]}"
76 | end
77 |
78 | ret = <<-SPEC
79 | { "#{key}",
80 | "#{arguments(command)}",
81 | "#{command["summary"]}",
82 | #{group},
83 | "#{command["since"]}" }
84 | SPEC
85 | ret.strip
86 | end.join(",\n ")
87 | end
88 |
89 | # Write to stdout
90 | puts <<-HELP_H
91 | /* Automatically generated by #{__FILE__}, do not edit. */
92 |
93 | #ifndef __REDIS_HELP_H
94 | #define __REDIS_HELP_H
95 |
96 | static char *commandGroups[] = {
97 | #{generate_groups}
98 | };
99 |
100 | struct commandHelp {
101 | char *name;
102 | char *params;
103 | char *summary;
104 | int group;
105 | char *since;
106 | } commandHelp[] = {
107 | #{generate_commands}
108 | };
109 |
110 | #endif
111 | HELP_H
112 |
113 |
--------------------------------------------------------------------------------
/deps/jemalloc/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 |
--------------------------------------------------------------------------------
/src/zipmap.h:
--------------------------------------------------------------------------------
1 | /* String -> String Map data structure optimized for size.
2 | *
3 | * See zipmap.c for more info.
4 | *
5 | * --------------------------------------------------------------------------
6 | *
7 | * Copyright (c) 2009-2010, Salvatore Sanfilippo
8 | * All rights reserved.
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions are met:
12 | *
13 | * * Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * * Redistributions in binary form must reproduce the above copyright
16 | * notice, this list of conditions and the following disclaimer in the
17 | * documentation and/or other materials provided with the distribution.
18 | * * Neither the name of Redis nor the names of its contributors may be used
19 | * to endorse or promote products derived from this software without
20 | * specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 | * POSSIBILITY OF SUCH DAMAGE.
33 | */
34 |
35 | #ifndef _ZIMMAP_H
36 | #define _ZIPMAP_H
37 |
38 | unsigned char *zipmapNew(void);
39 | unsigned char *zipmapSet(unsigned char *zm, unsigned char *key, unsigned int klen, unsigned char *val, unsigned int vlen, int *update);
40 | unsigned char *zipmapDel(unsigned char *zm, unsigned char *key, unsigned int klen, int *deleted);
41 | unsigned char *zipmapRewind(unsigned char *zm);
42 | unsigned char *zipmapNext(unsigned char *zm, unsigned char **key, unsigned int *klen, unsigned char **value, unsigned int *vlen);
43 | int zipmapGet(unsigned char *zm, unsigned char *key, unsigned int klen, unsigned char **value, unsigned int *vlen);
44 | int zipmapExists(unsigned char *zm, unsigned char *key, unsigned int klen);
45 | unsigned int zipmapLen(unsigned char *zm);
46 | size_t zipmapBlobLen(unsigned char *zm);
47 | void zipmapRepr(unsigned char *p);
48 |
49 | #endif
50 |
--------------------------------------------------------------------------------
/src/anet.h:
--------------------------------------------------------------------------------
1 | /* anet.c -- Basic TCP socket stuff made a bit less boring
2 | *
3 | * Copyright (c) 2006-2010, Salvatore Sanfilippo
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions are met:
8 | *
9 | * * Redistributions of source code must retain the above copyright notice,
10 | * this list of conditions and the following disclaimer.
11 | * * Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * * Neither the name of Redis nor the names of its contributors may be used
15 | * to endorse or promote products derived from this software without
16 | * specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 | * POSSIBILITY OF SUCH DAMAGE.
29 | */
30 |
31 | #ifndef ANET_H
32 | #define ANET_H
33 |
34 | #define ANET_OK 0
35 | #define ANET_ERR -1
36 | #define ANET_ERR_LEN 256
37 |
38 | #if defined(__sun)
39 | #define AF_LOCAL AF_UNIX
40 | #endif
41 |
42 | int anetTcpConnect(char *err, char *addr, int port);
43 | int anetTcpNonBlockConnect(char *err, char *addr, int port);
44 | int anetUnixConnect(char *err, char *path);
45 | int anetUnixNonBlockConnect(char *err, char *path);
46 | int anetRead(int fd, char *buf, int count);
47 | int anetResolve(char *err, char *host, char *ipbuf);
48 | int anetTcpServer(char *err, int port, char *bindaddr);
49 | int anetUnixServer(char *err, char *path, mode_t perm);
50 | int anetTcpAccept(char *err, int serversock, char *ip, int *port);
51 | int anetUnixAccept(char *err, int serversock);
52 | int anetWrite(int fd, char *buf, int count);
53 | int anetNonBlock(char *err, int fd);
54 | int anetTcpNoDelay(char *err, int fd);
55 | int anetTcpKeepAlive(char *err, int fd);
56 | int anetPeerToString(int fd, char *ip, int *port);
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/deps/jemalloc/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/hiredis/adapters/ae.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "../hiredis.h"
4 | #include "../async.h"
5 |
6 | typedef struct redisAeEvents {
7 | redisAsyncContext *context;
8 | aeEventLoop *loop;
9 | int fd;
10 | int reading, writing;
11 | } redisAeEvents;
12 |
13 | void redisAeReadEvent(aeEventLoop *el, int fd, void *privdata, int mask) {
14 | ((void)el); ((void)fd); ((void)mask);
15 |
16 | redisAeEvents *e = (redisAeEvents*)privdata;
17 | redisAsyncHandleRead(e->context);
18 | }
19 |
20 | void redisAeWriteEvent(aeEventLoop *el, int fd, void *privdata, int mask) {
21 | ((void)el); ((void)fd); ((void)mask);
22 |
23 | redisAeEvents *e = (redisAeEvents*)privdata;
24 | redisAsyncHandleWrite(e->context);
25 | }
26 |
27 | void redisAeAddRead(void *privdata) {
28 | redisAeEvents *e = (redisAeEvents*)privdata;
29 | aeEventLoop *loop = e->loop;
30 | if (!e->reading) {
31 | e->reading = 1;
32 | aeCreateFileEvent(loop,e->fd,AE_READABLE,redisAeReadEvent,e);
33 | }
34 | }
35 |
36 | void redisAeDelRead(void *privdata) {
37 | redisAeEvents *e = (redisAeEvents*)privdata;
38 | aeEventLoop *loop = e->loop;
39 | if (e->reading) {
40 | e->reading = 0;
41 | aeDeleteFileEvent(loop,e->fd,AE_READABLE);
42 | }
43 | }
44 |
45 | void redisAeAddWrite(void *privdata) {
46 | redisAeEvents *e = (redisAeEvents*)privdata;
47 | aeEventLoop *loop = e->loop;
48 | if (!e->writing) {
49 | e->writing = 1;
50 | aeCreateFileEvent(loop,e->fd,AE_WRITABLE,redisAeWriteEvent,e);
51 | }
52 | }
53 |
54 | void redisAeDelWrite(void *privdata) {
55 | redisAeEvents *e = (redisAeEvents*)privdata;
56 | aeEventLoop *loop = e->loop;
57 | if (e->writing) {
58 | e->writing = 0;
59 | aeDeleteFileEvent(loop,e->fd,AE_WRITABLE);
60 | }
61 | }
62 |
63 | void redisAeCleanup(void *privdata) {
64 | redisAeEvents *e = (redisAeEvents*)privdata;
65 | redisAeDelRead(privdata);
66 | redisAeDelWrite(privdata);
67 | free(e);
68 | }
69 |
70 | int redisAeAttach(aeEventLoop *loop, redisAsyncContext *ac) {
71 | redisContext *c = &(ac->c);
72 | redisAeEvents *e;
73 |
74 | /* Nothing should be attached when something is already attached */
75 | if (ac->_adapter_data != NULL)
76 | return REDIS_ERR;
77 |
78 | /* Create container for context and r/w events */
79 | e = (redisAeEvents*)malloc(sizeof(*e));
80 | e->context = ac;
81 | e->loop = loop;
82 | e->fd = c->fd;
83 | e->reading = e->writing = 0;
84 |
85 | /* Register functions to start/stop listening for events */
86 | ac->evAddRead = redisAeAddRead;
87 | ac->evDelRead = redisAeDelRead;
88 | ac->evAddWrite = redisAeAddWrite;
89 | ac->evDelWrite = redisAeDelWrite;
90 | ac->evCleanup = redisAeCleanup;
91 | ac->_adapter_data = e;
92 |
93 | return REDIS_OK;
94 | }
95 |
96 |
--------------------------------------------------------------------------------
/deps/jemalloc/src/base.c:
--------------------------------------------------------------------------------
1 | #define JEMALLOC_BASE_C_
2 | #include "jemalloc/internal/jemalloc_internal.h"
3 |
4 | /******************************************************************************/
5 | /* Data. */
6 |
7 | malloc_mutex_t base_mtx;
8 |
9 | /*
10 | * Current pages that are being used for internal memory allocations. These
11 | * pages are carved up in cacheline-size quanta, so that there is no chance of
12 | * false cache line sharing.
13 | */
14 | static void *base_pages;
15 | static void *base_next_addr;
16 | static void *base_past_addr; /* Addr immediately past base_pages. */
17 | static extent_node_t *base_nodes;
18 |
19 | /******************************************************************************/
20 | /* Function prototypes for non-inline static functions. */
21 |
22 | static bool base_pages_alloc(size_t minsize);
23 |
24 | /******************************************************************************/
25 |
26 | static bool
27 | base_pages_alloc(size_t minsize)
28 | {
29 | size_t csize;
30 | bool zero;
31 |
32 | assert(minsize != 0);
33 | csize = CHUNK_CEILING(minsize);
34 | zero = false;
35 | base_pages = chunk_alloc(csize, true, &zero);
36 | if (base_pages == NULL)
37 | return (true);
38 | base_next_addr = base_pages;
39 | base_past_addr = (void *)((uintptr_t)base_pages + csize);
40 |
41 | return (false);
42 | }
43 |
44 | void *
45 | base_alloc(size_t size)
46 | {
47 | void *ret;
48 | size_t csize;
49 |
50 | /* Round size up to nearest multiple of the cacheline size. */
51 | csize = CACHELINE_CEILING(size);
52 |
53 | malloc_mutex_lock(&base_mtx);
54 | /* Make sure there's enough space for the allocation. */
55 | if ((uintptr_t)base_next_addr + csize > (uintptr_t)base_past_addr) {
56 | if (base_pages_alloc(csize)) {
57 | malloc_mutex_unlock(&base_mtx);
58 | return (NULL);
59 | }
60 | }
61 | /* Allocate. */
62 | ret = base_next_addr;
63 | base_next_addr = (void *)((uintptr_t)base_next_addr + csize);
64 | malloc_mutex_unlock(&base_mtx);
65 |
66 | return (ret);
67 | }
68 |
69 | extent_node_t *
70 | base_node_alloc(void)
71 | {
72 | extent_node_t *ret;
73 |
74 | malloc_mutex_lock(&base_mtx);
75 | if (base_nodes != NULL) {
76 | ret = base_nodes;
77 | base_nodes = *(extent_node_t **)ret;
78 | malloc_mutex_unlock(&base_mtx);
79 | } else {
80 | malloc_mutex_unlock(&base_mtx);
81 | ret = (extent_node_t *)base_alloc(sizeof(extent_node_t));
82 | }
83 |
84 | return (ret);
85 | }
86 |
87 | void
88 | base_node_dealloc(extent_node_t *node)
89 | {
90 |
91 | malloc_mutex_lock(&base_mtx);
92 | *(extent_node_t **)node = base_nodes;
93 | base_nodes = node;
94 | malloc_mutex_unlock(&base_mtx);
95 | }
96 |
97 | bool
98 | base_boot(void)
99 | {
100 |
101 | base_nodes = NULL;
102 | if (malloc_mutex_init(&base_mtx))
103 | return (true);
104 |
105 | return (false);
106 | }
107 |
--------------------------------------------------------------------------------
/tests/unit/type/list-3.tcl:
--------------------------------------------------------------------------------
1 | start_server {
2 | tags {list ziplist}
3 | overrides {
4 | "list-max-ziplist-value" 200000
5 | "list-max-ziplist-entries" 256
6 | }
7 | } {
8 | test {Explicit regression for a list bug} {
9 | set mylist {49376042582 {BkG2o\pIC]4YYJa9cJ4GWZalG[4tin;1D2whSkCOW`mX;SFXGyS8sedcff3fQI^tgPCC@^Nu1J6o]meM@Lko]t_jRyotK?tH[\EvWqS]b`o2OCtjg:?nUTwdjpcUm]y:pg5q24q7LlCOwQE^}}
10 | r del l
11 | r rpush l [lindex $mylist 0]
12 | r rpush l [lindex $mylist 1]
13 | assert_equal [r lindex l 0] [lindex $mylist 0]
14 | assert_equal [r lindex l 1] [lindex $mylist 1]
15 | }
16 |
17 | tags {slow} {
18 | test {ziplist implementation: value encoding and backlink} {
19 | if {$::accurate} {set iterations 100} else {set iterations 10}
20 | for {set j 0} {$j < $iterations} {incr j} {
21 | r del l
22 | set l {}
23 | for {set i 0} {$i < 200} {incr i} {
24 | randpath {
25 | set data [string repeat x [randomInt 100000]]
26 | } {
27 | set data [randomInt 65536]
28 | } {
29 | set data [randomInt 4294967296]
30 | } {
31 | set data [randomInt 18446744073709551616]
32 | }
33 | lappend l $data
34 | r rpush l $data
35 | }
36 | assert_equal [llength $l] [r llen l]
37 | # Traverse backward
38 | for {set i 199} {$i >= 0} {incr i -1} {
39 | if {[lindex $l $i] ne [r lindex l $i]} {
40 | assert_equal [lindex $l $i] [r lindex l $i]
41 | }
42 | }
43 | }
44 | }
45 |
46 | test {ziplist implementation: encoding stress testing} {
47 | for {set j 0} {$j < 200} {incr j} {
48 | r del l
49 | set l {}
50 | set len [randomInt 400]
51 | for {set i 0} {$i < $len} {incr i} {
52 | set rv [randomValue]
53 | randpath {
54 | lappend l $rv
55 | r rpush l $rv
56 | } {
57 | set l [concat [list $rv] $l]
58 | r lpush l $rv
59 | }
60 | }
61 | assert_equal [llength $l] [r llen l]
62 | for {set i 0} {$i < $len} {incr i} {
63 | if {[lindex $l $i] ne [r lindex l $i]} {
64 | assert_equal [lindex $l $i] [r lindex l $i]
65 | }
66 | }
67 | }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/deps/lua/src/llimits.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Limits, basic types, and some other `installation-dependent' definitions
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef llimits_h
8 | #define llimits_h
9 |
10 |
11 | #include
12 | #include
13 |
14 |
15 | #include "lua.h"
16 |
17 |
18 | typedef LUAI_UINT32 lu_int32;
19 |
20 | typedef LUAI_UMEM lu_mem;
21 |
22 | typedef LUAI_MEM l_mem;
23 |
24 |
25 |
26 | /* chars used as small naturals (so that `char' is reserved for characters) */
27 | typedef unsigned char lu_byte;
28 |
29 |
30 | #define MAX_SIZET ((size_t)(~(size_t)0)-2)
31 |
32 | #define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2)
33 |
34 |
35 | #define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */
36 |
37 | /*
38 | ** conversion of pointer to integer
39 | ** this is for hashing only; there is no problem if the integer
40 | ** cannot hold the whole pointer value
41 | */
42 | #define IntPoint(p) ((unsigned int)(lu_mem)(p))
43 |
44 |
45 |
46 | /* type to ensure maximum alignment */
47 | typedef LUAI_USER_ALIGNMENT_T L_Umaxalign;
48 |
49 |
50 | /* result of a `usual argument conversion' over lua_Number */
51 | typedef LUAI_UACNUMBER l_uacNumber;
52 |
53 |
54 | /* internal assertions for in-house debugging */
55 | #ifdef lua_assert
56 |
57 | #define check_exp(c,e) (lua_assert(c), (e))
58 | #define api_check(l,e) lua_assert(e)
59 |
60 | #else
61 |
62 | #define lua_assert(c) ((void)0)
63 | #define check_exp(c,e) (e)
64 | #define api_check luai_apicheck
65 |
66 | #endif
67 |
68 |
69 | #ifndef UNUSED
70 | #define UNUSED(x) ((void)(x)) /* to avoid warnings */
71 | #endif
72 |
73 |
74 | #ifndef cast
75 | #define cast(t, exp) ((t)(exp))
76 | #endif
77 |
78 | #define cast_byte(i) cast(lu_byte, (i))
79 | #define cast_num(i) cast(lua_Number, (i))
80 | #define cast_int(i) cast(int, (i))
81 |
82 |
83 |
84 | /*
85 | ** type for virtual-machine instructions
86 | ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
87 | */
88 | typedef lu_int32 Instruction;
89 |
90 |
91 |
92 | /* maximum stack for a Lua function */
93 | #define MAXSTACK 250
94 |
95 |
96 |
97 | /* minimum size for the string table (must be power of 2) */
98 | #ifndef MINSTRTABSIZE
99 | #define MINSTRTABSIZE 32
100 | #endif
101 |
102 |
103 | /* minimum size for string buffer */
104 | #ifndef LUA_MINBUFFER
105 | #define LUA_MINBUFFER 32
106 | #endif
107 |
108 |
109 | #ifndef lua_lock
110 | #define lua_lock(L) ((void) 0)
111 | #define lua_unlock(L) ((void) 0)
112 | #endif
113 |
114 | #ifndef luai_threadyield
115 | #define luai_threadyield(L) {lua_unlock(L); lua_lock(L);}
116 | #endif
117 |
118 |
119 | /*
120 | ** macro to control inclusion of some hard tests on stack reallocation
121 | */
122 | #ifndef HARDSTACKTESTS
123 | #define condhardstacktests(x) ((void)0)
124 | #else
125 | #define condhardstacktests(x) x
126 | #endif
127 |
128 | #endif
129 |
--------------------------------------------------------------------------------
/deps/lua/src/lcode.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Code generator for Lua
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lcode_h
8 | #define lcode_h
9 |
10 | #include "llex.h"
11 | #include "lobject.h"
12 | #include "lopcodes.h"
13 | #include "lparser.h"
14 |
15 |
16 | /*
17 | ** Marks the end of a patch list. It is an invalid value both as an absolute
18 | ** address, and as a list link (would link an element to itself).
19 | */
20 | #define NO_JUMP (-1)
21 |
22 |
23 | /*
24 | ** grep "ORDER OPR" if you change these enums
25 | */
26 | typedef enum BinOpr {
27 | OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW,
28 | OPR_CONCAT,
29 | OPR_NE, OPR_EQ,
30 | OPR_LT, OPR_LE, OPR_GT, OPR_GE,
31 | OPR_AND, OPR_OR,
32 | OPR_NOBINOPR
33 | } BinOpr;
34 |
35 |
36 | typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
37 |
38 |
39 | #define getcode(fs,e) ((fs)->f->code[(e)->u.s.info])
40 |
41 | #define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx)
42 |
43 | #define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET)
44 |
45 | LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx);
46 | LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C);
47 | LUAI_FUNC void luaK_fixline (FuncState *fs, int line);
48 | LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n);
49 | LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n);
50 | LUAI_FUNC void luaK_checkstack (FuncState *fs, int n);
51 | LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s);
52 | LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r);
53 | LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e);
54 | LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e);
55 | LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e);
56 | LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e);
57 | LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e);
58 | LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key);
59 | LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k);
60 | LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e);
61 | LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e);
62 | LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults);
63 | LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e);
64 | LUAI_FUNC int luaK_jump (FuncState *fs);
65 | LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret);
66 | LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target);
67 | LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list);
68 | LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2);
69 | LUAI_FUNC int luaK_getlabel (FuncState *fs);
70 | LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v);
71 | LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v);
72 | LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2);
73 | LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore);
74 |
75 |
76 | #endif
77 |
--------------------------------------------------------------------------------
/deps/jemalloc/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 | #else
91 | /*
92 | * This is much slower than a simple memory barrier, but the semantics of mutex
93 | * unlock make this work.
94 | */
95 | JEMALLOC_INLINE void
96 | mb_write(void)
97 | {
98 | malloc_mutex_t mtx;
99 |
100 | malloc_mutex_init(&mtx);
101 | malloc_mutex_lock(&mtx);
102 | malloc_mutex_unlock(&mtx);
103 | }
104 | #endif
105 | #endif
106 |
107 | #endif /* JEMALLOC_H_INLINES */
108 | /******************************************************************************/
109 |
--------------------------------------------------------------------------------
/deps/jemalloc/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 *, unsigned, size_t *, size_t *);
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 JEMALLOC_DEBUG
34 | #define CKH_MAGIC 0x3af2489d
35 | uint32_t magic;
36 | #endif
37 |
38 | #ifdef CKH_COUNT
39 | /* Counters used to get an idea of performance. */
40 | uint64_t ngrows;
41 | uint64_t nshrinks;
42 | uint64_t nshrinkfails;
43 | uint64_t ninserts;
44 | uint64_t nrelocs;
45 | #endif
46 |
47 | /* Used for pseudo-random number generation. */
48 | #define CKH_A 1103515241
49 | #define CKH_C 12347
50 | uint32_t prn_state;
51 |
52 | /* Total number of items. */
53 | size_t count;
54 |
55 | /*
56 | * Minimum and current number of hash table buckets. There are
57 | * 2^LG_CKH_BUCKET_CELLS cells per bucket.
58 | */
59 | unsigned lg_minbuckets;
60 | unsigned lg_curbuckets;
61 |
62 | /* Hash and comparison functions. */
63 | ckh_hash_t *hash;
64 | ckh_keycomp_t *keycomp;
65 |
66 | /* Hash table with 2^lg_curbuckets buckets. */
67 | ckhc_t *tab;
68 | };
69 |
70 | #endif /* JEMALLOC_H_STRUCTS */
71 | /******************************************************************************/
72 | #ifdef JEMALLOC_H_EXTERNS
73 |
74 | bool ckh_new(ckh_t *ckh, size_t minitems, ckh_hash_t *hash,
75 | ckh_keycomp_t *keycomp);
76 | void ckh_delete(ckh_t *ckh);
77 | size_t ckh_count(ckh_t *ckh);
78 | bool ckh_iter(ckh_t *ckh, size_t *tabind, void **key, void **data);
79 | bool ckh_insert(ckh_t *ckh, const void *key, const void *data);
80 | bool ckh_remove(ckh_t *ckh, const void *searchkey, void **key,
81 | void **data);
82 | bool ckh_search(ckh_t *ckh, const void *seachkey, void **key, void **data);
83 | void ckh_string_hash(const void *key, unsigned minbits, size_t *hash1,
84 | size_t *hash2);
85 | bool ckh_string_keycomp(const void *k1, const void *k2);
86 | void ckh_pointer_hash(const void *key, unsigned minbits, size_t *hash1,
87 | size_t *hash2);
88 | bool ckh_pointer_keycomp(const void *k1, const void *k2);
89 |
90 | #endif /* JEMALLOC_H_EXTERNS */
91 | /******************************************************************************/
92 | #ifdef JEMALLOC_H_INLINES
93 |
94 | #endif /* JEMALLOC_H_INLINES */
95 | /******************************************************************************/
96 |
--------------------------------------------------------------------------------
/src/config.h:
--------------------------------------------------------------------------------
1 | #ifndef __CONFIG_H
2 | #define __CONFIG_H
3 |
4 | #ifdef __APPLE__
5 | #include
6 | #endif
7 |
8 | /* Define redis_fstat to fstat or fstat64() */
9 | #if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_6)
10 | #define redis_fstat fstat64
11 | #define redis_stat stat64
12 | #else
13 | #define redis_fstat fstat
14 | #define redis_stat stat
15 | #endif
16 |
17 | /* Test for proc filesystem */
18 | #ifdef __linux__
19 | #define HAVE_PROCFS 1
20 | #endif
21 |
22 | /* Test for task_info() */
23 | #if defined(__APPLE__)
24 | #define HAVE_TASKINFO 1
25 | #endif
26 |
27 | /* Test for backtrace() */
28 | #if defined(__APPLE__) || defined(__linux__)
29 | #define HAVE_BACKTRACE 1
30 | #endif
31 |
32 | /* Test for polling API */
33 | #ifdef __linux__
34 | #define HAVE_EPOLL 1
35 | #endif
36 |
37 | #if (defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_6)) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined (__NetBSD__)
38 | #define HAVE_KQUEUE 1
39 | #endif
40 |
41 | /* Define aof_fsync to fdatasync() in Linux and fsync() for all the rest */
42 | #ifdef __linux__
43 | #define aof_fsync fdatasync
44 | #else
45 | #define aof_fsync fsync
46 | #endif
47 |
48 | /* Byte ordering detection */
49 | #include /* This will likely define BYTE_ORDER */
50 |
51 | #ifndef BYTE_ORDER
52 | #if (BSD >= 199103)
53 | # include
54 | #else
55 | #if defined(linux) || defined(__linux__)
56 | # include
57 | #else
58 | #define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
59 | #define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
60 | #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/
61 |
62 | #if defined(vax) || defined(ns32000) || defined(sun386) || defined(__i386__) || \
63 | defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
64 | defined(__alpha__) || defined(__alpha)
65 | #define BYTE_ORDER LITTLE_ENDIAN
66 | #endif
67 |
68 | #if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
69 | defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
70 | defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
71 | defined(apollo) || defined(__convex__) || defined(_CRAY) || \
72 | defined(__hppa) || defined(__hp9000) || \
73 | defined(__hp9000s300) || defined(__hp9000s700) || \
74 | defined (BIT_ZERO_ON_LEFT) || defined(m68k) || defined(__sparc)
75 | #define BYTE_ORDER BIG_ENDIAN
76 | #endif
77 | #endif /* linux */
78 | #endif /* BSD */
79 | #endif /* BYTE_ORDER */
80 |
81 | #if defined(__BYTE_ORDER) && !defined(BYTE_ORDER)
82 | #if (__BYTE_ORDER == __LITTLE_ENDIAN)
83 | #define BYTE_ORDER LITTLE_ENDIAN
84 | #else
85 | #define BYTE_ORDER BIG_ENDIAN
86 | #endif
87 | #endif
88 |
89 | #if !defined(BYTE_ORDER) || \
90 | (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN)
91 | /* you must determine what the correct bit order is for
92 | * your compiler - the next line is an intentional error
93 | * which will force your compiles to bomb until you fix
94 | * the above macros.
95 | */
96 | #error "Undefined or invalid BYTE_ORDER"
97 | #endif
98 |
99 | #endif
100 |
--------------------------------------------------------------------------------
/deps/jemalloc/COPYING:
--------------------------------------------------------------------------------
1 | Unless otherwise specified, files in the jemalloc source distribution are
2 | subject to the following licenses:
3 | --------------------------------------------------------------------------------
4 | Copyright (C) 2002-2010 Jason Evans .
5 | All rights reserved.
6 | Copyright (C) 2007-2010 Mozilla Foundation. All rights reserved.
7 |
8 | Redistribution and use in source and binary forms, with or without
9 | modification, are permitted provided that the following conditions are met:
10 | 1. Redistributions of source code must retain the above copyright notice(s),
11 | this list of conditions and the following disclaimer.
12 | 2. Redistributions in binary form must reproduce the above copyright notice(s),
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY EXPRESS
17 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 | EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
24 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | --------------------------------------------------------------------------------
27 | Copyright (C) 2009-2010 Facebook, Inc.
28 | All rights reserved.
29 |
30 | Redistribution and use in source and binary forms, with or without modification,
31 | are permitted provided that the following conditions are met:
32 | * Redistributions of source code must retain the above copyright notice, this
33 | list of conditions and the following disclaimer.
34 | * Redistributions in binary form must reproduce the above copyright notice, this
35 | list of conditions and the following disclaimer in the documentation and/or
36 | other materials provided with the distribution.
37 | * Neither the name of Facebook, Inc. nor the names of its contributors may be
38 | used to endorse or promote products derived from this software without
39 | specific prior written permission.
40 |
41 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
42 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
43 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
44 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
45 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
46 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
48 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
50 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51 | --------------------------------------------------------------------------------
52 |
--------------------------------------------------------------------------------
/deps/jemalloc/test/posix_memalign.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | #define JEMALLOC_MANGLE
8 | #include "jemalloc_test.h"
9 |
10 | #define CHUNK 0x400000
11 | /* #define MAXALIGN ((size_t)0x80000000000LLU) */
12 | #define MAXALIGN ((size_t)0x2000000LLU)
13 | #define NITER 4
14 |
15 | int
16 | main(void)
17 | {
18 | size_t alignment, size, total;
19 | unsigned i;
20 | int err;
21 | void *p, *ps[NITER];
22 |
23 | fprintf(stderr, "Test begin\n");
24 |
25 | /* Test error conditions. */
26 | for (alignment = 0; alignment < sizeof(void *); alignment++) {
27 | err = JEMALLOC_P(posix_memalign)(&p, alignment, 1);
28 | if (err != EINVAL) {
29 | fprintf(stderr,
30 | "Expected error for invalid alignment %zu\n",
31 | alignment);
32 | }
33 | }
34 |
35 | for (alignment = sizeof(size_t); alignment < MAXALIGN;
36 | alignment <<= 1) {
37 | err = JEMALLOC_P(posix_memalign)(&p, alignment + 1, 1);
38 | if (err == 0) {
39 | fprintf(stderr,
40 | "Expected error for invalid alignment %zu\n",
41 | alignment + 1);
42 | }
43 | }
44 |
45 | #if LG_SIZEOF_PTR == 3
46 | alignment = 0x8000000000000000LLU;
47 | size = 0x8000000000000000LLU;
48 | #else
49 | alignment = 0x80000000LU;
50 | size = 0x80000000LU;
51 | #endif
52 | err = JEMALLOC_P(posix_memalign)(&p, alignment, size);
53 | if (err == 0) {
54 | fprintf(stderr,
55 | "Expected error for posix_memalign(&p, %zu, %zu)\n",
56 | alignment, size);
57 | }
58 |
59 | #if LG_SIZEOF_PTR == 3
60 | alignment = 0x4000000000000000LLU;
61 | size = 0x8400000000000001LLU;
62 | #else
63 | alignment = 0x40000000LU;
64 | size = 0x84000001LU;
65 | #endif
66 | err = JEMALLOC_P(posix_memalign)(&p, alignment, size);
67 | if (err == 0) {
68 | fprintf(stderr,
69 | "Expected error for posix_memalign(&p, %zu, %zu)\n",
70 | alignment, size);
71 | }
72 |
73 | alignment = 0x10LLU;
74 | #if LG_SIZEOF_PTR == 3
75 | size = 0xfffffffffffffff0LLU;
76 | #else
77 | size = 0xfffffff0LU;
78 | #endif
79 | err = JEMALLOC_P(posix_memalign)(&p, alignment, size);
80 | if (err == 0) {
81 | fprintf(stderr,
82 | "Expected error for posix_memalign(&p, %zu, %zu)\n",
83 | alignment, size);
84 | }
85 |
86 | for (i = 0; i < NITER; i++)
87 | ps[i] = NULL;
88 |
89 | for (alignment = 8;
90 | alignment <= MAXALIGN;
91 | alignment <<= 1) {
92 | total = 0;
93 | fprintf(stderr, "Alignment: %zu\n", alignment);
94 | for (size = 1;
95 | size < 3 * alignment && size < (1U << 31);
96 | size += (alignment >> (LG_SIZEOF_PTR-1)) - 1) {
97 | for (i = 0; i < NITER; i++) {
98 | err = JEMALLOC_P(posix_memalign)(&ps[i],
99 | alignment, size);
100 | if (err) {
101 | fprintf(stderr,
102 | "Error for size %zu (0x%zx): %s\n",
103 | size, size, strerror(err));
104 | exit(1);
105 | }
106 | total += JEMALLOC_P(malloc_usable_size)(ps[i]);
107 | if (total >= (MAXALIGN << 1))
108 | break;
109 | }
110 | for (i = 0; i < NITER; i++) {
111 | if (ps[i] != NULL) {
112 | JEMALLOC_P(free)(ps[i]);
113 | ps[i] = NULL;
114 | }
115 | }
116 | }
117 | }
118 |
119 | fprintf(stderr, "Test end\n");
120 | return (0);
121 | }
122 |
--------------------------------------------------------------------------------
/src/zmalloc.h:
--------------------------------------------------------------------------------
1 | /* zmalloc - total amount of allocated memory aware version of malloc()
2 | *
3 | * Copyright (c) 2009-2010, Salvatore Sanfilippo
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions are met:
8 | *
9 | * * Redistributions of source code must retain the above copyright notice,
10 | * this list of conditions and the following disclaimer.
11 | * * Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * * Neither the name of Redis nor the names of its contributors may be used
15 | * to endorse or promote products derived from this software without
16 | * specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 | * POSSIBILITY OF SUCH DAMAGE.
29 | */
30 |
31 | #ifndef __ZMALLOC_H
32 | #define __ZMALLOC_H
33 |
34 | /* Double expansion needed for stringification of macro values. */
35 | #define __xstr(s) __str(s)
36 | #define __str(s) #s
37 |
38 | #if defined(USE_TCMALLOC)
39 | #define ZMALLOC_LIB ("tcmalloc-" __xstr(TC_VERSION_MAJOR) "." __xstr(TC_VERSION_MINOR))
40 | #include
41 | #if TC_VERSION_MAJOR >= 1 && TC_VERSION_MINOR >= 6
42 | #define HAVE_MALLOC_SIZE 1
43 | #define zmalloc_size(p) tc_malloc_size(p)
44 | #else
45 | #error "Newer version of tcmalloc required"
46 | #endif
47 |
48 | #elif defined(USE_JEMALLOC)
49 | #define ZMALLOC_LIB ("jemalloc-" __xstr(JEMALLOC_VERSION_MAJOR) "." __xstr(JEMALLOC_VERSION_MINOR) "." __xstr(JEMALLOC_VERSION_BUGFIX))
50 | #define JEMALLOC_MANGLE
51 | #include
52 | #if JEMALLOC_VERSION_MAJOR >= 2 && JEMALLOC_VERSION_MINOR >= 1
53 | #define HAVE_MALLOC_SIZE 1
54 | #define zmalloc_size(p) JEMALLOC_P(malloc_usable_size)(p)
55 | #else
56 | #error "Newer version of jemalloc required"
57 | #endif
58 |
59 | #elif defined(__APPLE__)
60 | #include
61 | #define HAVE_MALLOC_SIZE 1
62 | #define zmalloc_size(p) malloc_size(p)
63 | #endif
64 |
65 | #ifndef ZMALLOC_LIB
66 | #define ZMALLOC_LIB "libc"
67 | #endif
68 |
69 | void *zmalloc(size_t size);
70 | void *zcalloc(size_t size);
71 | void *zrealloc(void *ptr, size_t size);
72 | void zfree(void *ptr);
73 | char *zstrdup(const char *s);
74 | size_t zmalloc_used_memory(void);
75 | void zmalloc_enable_thread_safeness(void);
76 | float zmalloc_get_fragmentation_ratio(void);
77 | size_t zmalloc_get_rss(void);
78 |
79 | #endif /* __ZMALLOC_H */
80 |
--------------------------------------------------------------------------------
/deps/linenoise/README.markdown:
--------------------------------------------------------------------------------
1 | # Linenoise
2 |
3 | A minimal, zero-config, BSD licensed, readline replacement.
4 |
5 | News: linenoise is now part of [Android](http://android.git.kernel.org/?p=platform/system/core.git;a=tree;f=liblinenoise;h=56450eaed7f783760e5e6a5993ef75cde2e29dea;hb=HEAD Android)!
6 |
7 | ## Can a line editing library be 20k lines of code?
8 |
9 | Line editing with some support for history is a really important feature for command line utilities. Instead of retyping almost the same stuff again and again it's just much better to hit the up arrow and edit on syntax errors, or in order to try a slightly different command. But apparently code dealing with terminals is some sort of Black Magic: readline is 30k lines of code, libedit 20k. Is it reasonable to link small utilities to huge libraries just to get a minimal support for line editing?
10 |
11 | So what usually happens is either:
12 |
13 | * Large programs with configure scripts disabling line editing if readline is not present in the system, or not supporting it at all since readline is GPL licensed and libedit (the BSD clone) is not as known and available as readline is (Readl world example of this problem: Tclsh).
14 | * Smaller programs not using a configure script not supporting line editing at all (A problem we had with Redis-cli for instance).
15 |
16 | The result is a pollution of binaries without line editing support.
17 |
18 | So I spent more or less two hours doing a reality check resulting in this little library: is it *really* needed for a line editing library to be 20k lines of code? Apparently not, it is possibe to get a very small, zero configuration, trivial to embed library, that solves the problem. Smaller programs will just include this, supporing line editing out of the box. Larger programs may use this little library or just checking with configure if readline/libedit is available and resorting to linenoise if not.
19 |
20 | ## Terminals, in 2010.
21 |
22 | Apparently almost every terminal you can happen to use today has some kind of support for VT100 alike escape sequences. So I tried to write a lib using just very basic VT100 features. The resulting library appears to work everywhere I tried to use it.
23 |
24 | Since it's so young I guess there are a few bugs, or the lib may not compile or work with some operating system, but it's a matter of a few weeks and eventually we'll get it right, and there will be no excuses for not shipping command line tools without built-in line editing support.
25 |
26 | The library is currently less than 400 lines of code. In order to use it in your project just look at the *example.c* file in the source distribution, it is trivial. Linenoise is BSD code, so you can use both in free software and commercial software.
27 |
28 | ## Tested with...
29 |
30 | * Linux text only console ($TERM = linux)
31 | * Linux KDE terminal application ($TERM = xterm)
32 | * Linux xterm ($TERM = xterm)
33 | * Mac OS X iTerm ($TERM = xterm)
34 | * Mac OS X default Terminal.app ($TERM = xterm)
35 | * OpenBSD 4.5 through an OSX Terminal.app ($TERM = screen)
36 | * IBM AIX 6.1
37 | * FreeBSD xterm ($TERM = xterm)
38 |
39 | Please test it everywhere you can and report back!
40 |
41 | ## Let's push this forward!
42 |
43 | Please fork it and add something interesting and send me a pull request. What's especially interesting are fixes, new key bindings, completion.
44 |
45 | Send feedbacks to antirez at gmail
46 |
--------------------------------------------------------------------------------