From: Junio C Hamano Date: Mon, 21 Jul 2014 18:17:47 +0000 (-0700) Subject: Merge branch 'ak/profile-feedback-build' X-Git-Tag: v2.1.0-rc0~24 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/3b3b61c5d5ef93a68e9af3c17eebc09c96b71d08?ds=inline;hp=-c Merge branch 'ak/profile-feedback-build' * ak/profile-feedback-build: Fix profile feedback with -jN and add profile-fast Run the perf test suite for profile feedback too Don't define away __attribute__ on gcc Use BASIC_FLAGS for profile feedback --- 3b3b61c5d5ef93a68e9af3c17eebc09c96b71d08 diff --combined Makefile index 840057cba7,a760402370..a49acb5ec6 --- a/Makefile +++ b/Makefile @@@ -552,7 -552,6 +552,7 @@@ TEST_PROGRAMS_NEED_X += test-ctyp TEST_PROGRAMS_NEED_X += test-date TEST_PROGRAMS_NEED_X += test-delta TEST_PROGRAMS_NEED_X += test-dump-cache-tree +TEST_PROGRAMS_NEED_X += test-dump-split-index TEST_PROGRAMS_NEED_X += test-genrandom TEST_PROGRAMS_NEED_X += test-hashmap TEST_PROGRAMS_NEED_X += test-index-version @@@ -876,7 -875,6 +876,7 @@@ LIB_OBJS += sha1_name. LIB_OBJS += shallow.o LIB_OBJS += sideband.o LIB_OBJS += sigchain.o +LIB_OBJS += split-index.o LIB_OBJS += strbuf.o LIB_OBJS += streaming.o LIB_OBJS += string-list.o @@@ -1001,7 -999,6 +1001,7 @@@ BUILTIN_OBJS += builtin/update-ref. BUILTIN_OBJS += builtin/update-server-info.o BUILTIN_OBJS += builtin/upload-archive.o BUILTIN_OBJS += builtin/var.o +BUILTIN_OBJS += builtin/verify-commit.o BUILTIN_OBJS += builtin/verify-pack.o BUILTIN_OBJS += builtin/verify-tag.o BUILTIN_OBJS += builtin/write-tree.o @@@ -1555,13 -1552,13 +1555,13 @@@ endi PROFILE_DIR := $(CURDIR) ifeq ("$(PROFILE)","GEN") - CFLAGS += -fprofile-generate=$(PROFILE_DIR) -DNO_NORETURN=1 + BASIC_CFLAGS += -fprofile-generate=$(PROFILE_DIR) -DNO_NORETURN=1 EXTLIBS += -lgcov export CCACHE_DISABLE = t V = 1 else ifneq ("$(PROFILE)","") - CFLAGS += -fprofile-use=$(PROFILE_DIR) -fprofile-correction -DNO_NORETURN=1 + BASIC_CFLAGS += -fprofile-use=$(PROFILE_DIR) -fprofile-correction -DNO_NORETURN=1 export CCACHE_DISABLE = t V = 1 endif @@@ -1646,12 -1643,20 +1646,20 @@@ SHELL = $(SHELL_PATH all:: shell_compatibility_test ifeq "$(PROFILE)" "BUILD" - ifeq ($(filter all,$(MAKECMDGOALS)),all) - all:: profile-clean + all:: profile + endif + + profile:: profile-clean $(MAKE) PROFILE=GEN all $(MAKE) PROFILE=GEN -j1 test - endif - endif + $(MAKE) PROFILE=GEN -j1 perf + $(MAKE) PROFILE=USE all + + profile-fast: profile-clean + $(MAKE) PROFILE=GEN all + $(MAKE) PROFILE=GEN -j1 perf + $(MAKE) PROFILE=USE all + all:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS ifneq (,$X) @@@ -2338,6 -2343,12 +2346,12 @@@ mergetools_instdir_SQ = $(subst ','\'', install_bindir_programs := $(patsubst %,%$X,$(BINDIR_PROGRAMS_NEED_X)) $(BINDIR_PROGRAMS_NO_X) + profile-install: profile + $(MAKE) install + + profile-fast-install: profile-fast + $(MAKE) install + install: all $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)' $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' diff --combined git-compat-util.h index 0b53c9a4af,01e8695a2d..63d72db553 --- a/git-compat-util.h +++ b/git-compat-util.h @@@ -291,10 -291,12 +291,12 @@@ extern char *gitbasename(char *) #else #define NORETURN #define NORETURN_PTR + #ifndef __GNUC__ #ifndef __attribute__ #define __attribute__(x) #endif #endif + #endif /* The sentinel attribute is valid from gcc version 4.0 */ #if defined(__GNUC__) && (__GNUC__ >= 4) @@@ -347,66 -349,15 +349,66 @@@ extern void set_error_routine(void (*ro extern void set_die_is_recursing_routine(int (*routine)(void)); extern int starts_with(const char *str, const char *prefix); -extern int ends_with(const char *str, const char *suffix); -static inline const char *skip_prefix(const char *str, const char *prefix) +/* + * If the string "str" begins with the string found in "prefix", return 1. + * The "out" parameter is set to "str + strlen(prefix)" (i.e., to the point in + * the string right after the prefix). + * + * Otherwise, return 0 and leave "out" untouched. + * + * Examples: + * + * [extract branch name, fail if not a branch] + * if (!skip_prefix(ref, "refs/heads/", &branch) + * return -1; + * + * [skip prefix if present, otherwise use whole string] + * skip_prefix(name, "refs/heads/", &name); + */ +static inline int skip_prefix(const char *str, const char *prefix, + const char **out) { do { - if (!*prefix) - return str; + if (!*prefix) { + *out = str; + return 1; + } } while (*str++ == *prefix++); - return NULL; + return 0; +} + +/* + * If buf ends with suffix, return 1 and subtract the length of the suffix + * from *len. Otherwise, return 0 and leave *len untouched. + */ +static inline int strip_suffix_mem(const char *buf, size_t *len, + const char *suffix) +{ + size_t suflen = strlen(suffix); + if (*len < suflen || memcmp(buf + (*len - suflen), suffix, suflen)) + return 0; + *len -= suflen; + return 1; +} + +/* + * If str ends with suffix, return 1 and set *len to the size of the string + * without the suffix. Otherwise, return 0 and set *len to the size of the + * string. + * + * Note that we do _not_ NUL-terminate str to the new length. + */ +static inline int strip_suffix(const char *str, const char *suffix, size_t *len) +{ + *len = strlen(str); + return strip_suffix_mem(str, len, suffix); +} + +static inline int ends_with(const char *str, const char *suffix) +{ + size_t len; + return strip_suffix(str, suffix, &len); } #if defined(NO_MMAP) || defined(USE_WIN32_MMAP) @@@ -613,6 -564,13 +615,6 @@@ static inline size_t xsize_t(off_t len return (size_t)len; } -static inline int has_extension(const char *filename, const char *ext) -{ - size_t len = strlen(filename); - size_t extlen = strlen(ext); - return len > extlen && !memcmp(filename + len - extlen, ext, extlen); -} - /* in ctype.c, for kwset users */ extern const char tolower_trans_tbl[256];