Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings #11

Open
wants to merge 2 commits into
base: unstable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
# Dependencies are stored in the Makefile.dep file. To rebuild this file
# Just use 'make dep', but this is only needed by developers.

# h7: 创建编译信息
release_hdr := $(shell sh -c './mkreleasehdr.sh')
# h7: sh -c 'uname -s 2>/dev/null || echo not' 这一句在linux下执行的结果为 Linux,在mac下执行的结果为 Darwin
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
OPTIMIZATION?=-O2
DEPENDENCY_TARGETS=hiredis linenoise lua
Expand All @@ -26,6 +28,10 @@ PREFIX?=/usr/local
INSTALL_BIN=$(PREFIX)/bin
INSTALL=install

# h7: 根据上面系统信息,确定动态内存分配器类型,下面定义了使用facebook的jemalloc,此外,也可以选择libc原生的malloc,但需要在每次内存分配前加4个字节记录内存分配的长度信息,以实现malloc_size的功能。源码中已经自带了jemalloc的源码,可以看出官方还是比较推崇使用jemalloc的。
# h7: linux 下默认使用 jemalloc
# h7: 详细信息可以参考: http://m.blog.csdn.net/blog/kaixin89/42217109 ;http://blog.sina.com.cn/s/blog_6f5b220601012x3x.html

# Default allocator
ifeq ($(uname_S),Linux)
MALLOC=jemalloc
Expand Down Expand Up @@ -82,6 +88,7 @@ ifeq ($(MALLOC),tcmalloc_minimal)
FINAL_LIBS+= -ltcmalloc_minimal
endif

# h7: 引入 jemalloc 的静态库
ifeq ($(MALLOC),jemalloc)
DEPENDENCY_TARGETS+= jemalloc
FINAL_CFLAGS+= -DUSE_JEMALLOC -I../deps/jemalloc/include
Expand Down
2 changes: 2 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ void setproctitle(const char *fmt, ...);
#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/

// h7: 使用小端系统的平台
#if defined(__i386__) || defined(__x86_64__) || defined(__amd64__) || \
defined(vax) || defined(ns32000) || defined(sun386) || \
defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
Expand Down Expand Up @@ -185,6 +186,7 @@ void setproctitle(const char *fmt, ...);
#error "Undefined or invalid BYTE_ORDER"
#endif

// h7: 这里和后面在zmalloc.c中的定义有关,用于实现内存统计
#if (__i386 || __amd64) && __GNUC__
#define GNUC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#if (GNUC_VERSION >= 40100) || defined(__clang__)
Expand Down