git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] compat: add memrchr()

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Oct 15, 2010, 06:06 UTC
Message-ID
<20101015060654.GD21830@burratino>
In-Reply-To
<AANLkTinBuAhLLUMLd6ZWtVFWCjnFAxYwVSo1Pkja7bT4@mail.gmail.com>
Ævar Arnfjörð Bjarmason wrote:
Show 9 quoted lines
> Maybe something like this for configure.ac:
> 
>     AC_CHECK_LIB([c], [memchr],
>     [HAVE_MEMRCHR=YesPlease],
>     [HAVE_MEMRCHR=])
>     AC_SUBST(HAVE_MEMRCHR)
> 
> And documentation with the other HAVE_* variables at the top of the
> Makefile?

Hmm, the BSDs and plan 9 have an memrchr() apparently. Any idea for taking advantage of that (the makefile support part) that's less ugly than this?

If we miss a platform, that's no big deal. The 1-char-at-a-time loop is not so slow, and the "#define memrchr gitmemrchr" ensures that it would not conflict with the libc version. ---

diff --git a/Makefile b/Makefile
index 1f1ce04..fa91530 100644
--- a/Makefile
+++ b/Makefile
@@ -211,6 +211,8 @@ all::
 #
 # Define NO_REGEX if you have no or inferior regex support in your C library.
 #
+# Define HAVE_MEMRCHR if you have memrchr() in your C library.
+#
 # Define JSMIN to point to JavaScript minifier that functions as
 # a filter to have gitweb.js minified.
 #
@@ -1388,6 +1390,9 @@ endif
 ifdef NO_UINTMAX_T
 	BASIC_CFLAGS += -Duintmax_t=uint32_t
 endif
+ifdef HAVE_MEMRCHR
+	BASIC_CFLAGS += -DHAVE_MEMRCHR
+endif
 ifdef NO_SOCKADDR_STORAGE
 ifdef NO_IPV6
 	BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in
diff --git a/git-compat-util.h b/git-compat-util.h
index 6f1020e..45aaebc 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -366,7 +366,7 @@ extern int git_vsnprintf(char *str, size_t maxsize,
 #define HAVE_STRCHRNUL
 #define HAVE_MEMPCPY
 #endif
-#if __GLIBC_PREREQ(2, 2)
+#if __GLIBC_PREREQ(2, 2) && !defined(HAVE_MEMRCHR)
 #define HAVE_MEMRCHR
 #endif
 #endif
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 10 of 17 in “Detection of directory renames”
  1. 0/5 Detection of directory renamesYann Dirson, Oct 14, 2010
  2. 1/5 Introduce bulk-move detection in diffcore.Yann Dirson, Oct 14, 2010
  3. 2/5 Add testcases for the --detect-bulk-moves diffcore flag.Yann Dirson, Oct 14, 2010
  4. 3/5 [RFC] Handle the simpler case of a subdir invalidating bulk move.Yann Dirson, Oct 14, 2010
  5. 4/5 [RFC] Consider all parents of a file as candidates for bulk rename.Yann Dirson, Oct 14, 2010
  6. 5/5 [WIP] Allow hiding renames of individual files involved in a directory rename.Yann Dirson, Oct 14, 2010
  7. [RFC] Consider all parents of a file as candidates for bulk rename.Yann Dirson, Oct 17, 2010
  8. compat: add memrchr()Jonathan Nieder, Oct 15, 2010
  9. Ævar Arnfjörð BjarmasonOct 15, 2010
  10. Jonathan NiederOct 15, 2010
  11. Ævar Arnfjörð BjarmasonOct 15, 2010
  12. Junio C HamanoOct 15, 2010
  13. Johannes SixtOct 15, 2010
  14. Ludvig StrigeusOct 15, 2010
  15. compat: add memrchr()Jonathan Nieder, Oct 15, 2010
  16. Erik Faye-LundOct 15, 2010
  17. Johannes SixtOct 15, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.