]> git.ozlabs.org Git - ccan/commitdiff
Add configurator test for memmem()
authorDavid Gibson <david@gibson.dropbear.id.au>
Fri, 18 Mar 2011 08:29:16 +0000 (19:29 +1100)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 24 Mar 2011 06:03:40 +0000 (16:33 +1030)
memmem(), which searches for one bytestring in a longer
bytestring is one of those functions that should be standard, but
isn't.  This patch adds a ccan configurator test for the function
so that modules can use or replace it as necessary.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
config.h
tools/configurator/configurator.c

index b0e5b02a3428874f89b7d6219ffcaf3d44dd6996..25609f136f4d9a0a9f4b8ac3999bd2a3366ec7b5 100644 (file)
--- a/config.h
+++ b/config.h
@@ -32,6 +32,7 @@
 #define HAVE_FLEXIBLE_ARRAY_MEMBER 1
 #define HAVE_GETPAGESIZE 1
 #define HAVE_LITTLE_ENDIAN 1
 #define HAVE_FLEXIBLE_ARRAY_MEMBER 1
 #define HAVE_GETPAGESIZE 1
 #define HAVE_LITTLE_ENDIAN 1
+#define HAVE_MEMMEM 1
 #define HAVE_MMAP 1
 #define HAVE_NESTED_FUNCTIONS 1
 #define HAVE_STACK_GROWS_UPWARDS 0
 #define HAVE_MMAP 1
 #define HAVE_NESTED_FUNCTIONS 1
 #define HAVE_STACK_GROWS_UPWARDS 0
index e697d7759877793b19f8b57517b3a88153ee2671..af7955a3144449db4cb1d04fc82454c40558a8ae 100644 (file)
@@ -106,6 +106,12 @@ static struct test tests[] = {
          "union { int i; char c[sizeof(int)]; } u;\n"
          "u.i = 0x01020304;\n"
          "return u.c[0] == 0x04 && u.c[1] == 0x03 && u.c[2] == 0x02 && u.c[3] == 0x01 ? 0 : 1;" },
          "union { int i; char c[sizeof(int)]; } u;\n"
          "u.i = 0x01020304;\n"
          "return u.c[0] == 0x04 && u.c[1] == 0x03 && u.c[2] == 0x02 && u.c[3] == 0x01 ? 0 : 1;" },
+       { "HAVE_MEMMEM", DEFINES_FUNC, NULL,
+         "#define _GNU_SOURCE\n"
+         "#include <string.h>\n"
+         "static void *func(void *h, size_t hl, void *n, size_t nl) {\n"
+         "return memmem(h, hl, n, nl);"
+         "}\n", },
        { "HAVE_MMAP", DEFINES_FUNC, NULL,
          "#include <sys/mman.h>\n"
          "static void *func(int fd) {\n"
        { "HAVE_MMAP", DEFINES_FUNC, NULL,
          "#include <sys/mman.h>\n"
          "static void *func(int fd) {\n"