Skip to content

Commit

Permalink
Simplify strchrnul() compat code
Browse files Browse the repository at this point in the history
strchrnul() was introduced in glibc in April 1999 and included in
glibc-2.1. Checking for that version means the majority of all git
users would get to use the optimized version in glibc. Of the
remaining few some might get to use a slightly slower version
than necessary but probably not slower than what we have today.

Unfortunately, __GLIBC_PREREQ() macro was not available in glibc 2.1.1
which was short lived but already supported strchrnul().  Odd minority
users of that library needs to live with our compatibility inline version.

Rediffed-against-next-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Andreas Ericsson authored and Junio C Hamano committed Nov 11, 2007
1 parent b9c6232 commit 9e79f00
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 23 deletions.
13 changes: 0 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ all::
#
# Define NO_MEMMEM if you don't have memmem.
#
# Define NO_STRCHRNUL if you don't have strchrnul.
#
# Define NO_STRLCPY if you don't have strlcpy.
#
# Define NO_STRTOUMAX if you don't have strtoumax in the C library.
Expand Down Expand Up @@ -408,15 +406,13 @@ ifeq ($(uname_S),Darwin)
OLD_ICONV = UnfortunatelyYes
NO_STRLCPY = YesPlease
NO_MEMMEM = YesPlease
NO_STRCHRNUL = YesPlease
endif
ifeq ($(uname_S),SunOS)
NEEDS_SOCKET = YesPlease
NEEDS_NSL = YesPlease
SHELL_PATH = /bin/bash
NO_STRCASESTR = YesPlease
NO_MEMMEM = YesPlease
NO_STRCHRNUL = YesPlease
NO_HSTRERROR = YesPlease
ifeq ($(uname_R),5.8)
NEEDS_LIBICONV = YesPlease
Expand All @@ -442,7 +438,6 @@ ifeq ($(uname_O),Cygwin)
NO_D_INO_IN_DIRENT = YesPlease
NO_STRCASESTR = YesPlease
NO_MEMMEM = YesPlease
NO_STRCHRNUL = YesPlease
NO_SYMLINK_HEAD = YesPlease
NEEDS_LIBICONV = YesPlease
NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
Expand All @@ -457,14 +452,12 @@ endif
ifeq ($(uname_S),FreeBSD)
NEEDS_LIBICONV = YesPlease
NO_MEMMEM = YesPlease
NO_STRCHRNUL = YesPlease
BASIC_CFLAGS += -I/usr/local/include
BASIC_LDFLAGS += -L/usr/local/lib
endif
ifeq ($(uname_S),OpenBSD)
NO_STRCASESTR = YesPlease
NO_MEMMEM = YesPlease
NO_STRCHRNUL = YesPlease
NEEDS_LIBICONV = YesPlease
BASIC_CFLAGS += -I/usr/local/include
BASIC_LDFLAGS += -L/usr/local/lib
Expand All @@ -480,7 +473,6 @@ endif
ifeq ($(uname_S),AIX)
NO_STRCASESTR=YesPlease
NO_MEMMEM = YesPlease
NO_STRCHRNUL = YesPlease
NO_STRLCPY = YesPlease
NEEDS_LIBICONV=YesPlease
endif
Expand All @@ -493,7 +485,6 @@ ifeq ($(uname_S),IRIX64)
NO_SETENV=YesPlease
NO_STRCASESTR=YesPlease
NO_MEMMEM = YesPlease
NO_STRCHRNUL = YesPlease
NO_STRLCPY = YesPlease
NO_SOCKADDR_STORAGE=YesPlease
SHELL_PATH=/usr/gnu/bin/bash
Expand Down Expand Up @@ -704,10 +695,6 @@ ifdef NO_MEMMEM
COMPAT_CFLAGS += -DNO_MEMMEM
COMPAT_OBJS += compat/memmem.o
endif
ifdef NO_STRCHRNUL
COMPAT_CFLAGS += -DNO_STRCHRNUL
COMPAT_OBJS += compat/strchrnul.o
endif

ifdef THREADED_DELTA_SEARCH
BASIC_CFLAGS += -DTHREADED_DELTA_SEARCH
Expand Down
8 changes: 0 additions & 8 deletions compat/strchrnul.c

This file was deleted.

9 changes: 7 additions & 2 deletions git-compat-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,14 @@ void *gitmemmem(const void *haystack, size_t haystacklen,
const void *needle, size_t needlelen);
#endif

#ifdef NO_STRCHRNUL
#if !defined(__GLIBC_PREREQ) && !__GLIBC_PREREQ(2, 1)
#define strchrnul gitstrchrnul
char *gitstrchrnul(const char *s, int c);
static inline char *gitstrchrnul(const char *s, int c)
{
while (*s && *s != c)
s++;
return (char *)s;
}
#endif

extern void release_pack_memory(size_t, int);
Expand Down

0 comments on commit 9e79f00

Please sign in to comment.