]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
internal/bytealg: support systems that don't have memmem
authorIan Lance Taylor <ian@gcc.gnu.org>
Tue, 2 Oct 2018 16:45:51 +0000 (16:45 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Tue, 2 Oct 2018 16:45:51 +0000 (16:45 +0000)
    Reviewed-on: https://go-review.googlesource.com/138839

From-SVN: r264798

gcc/go/gofrontend/MERGE
libgo/config.h.in
libgo/configure
libgo/configure.ac
libgo/go/internal/bytealg/bytealg.c

index b9528721ad3a49ae9cb13c7c5055088099cccc97..c697cb697be77e98eafd2531a8235faf2f38e3b7 100644 (file)
@@ -1,4 +1,4 @@
-098e36f4ddfcf50aeb34509b5f25b86d7050749c
+bde5ac90e0b4efdf3e9a4d72af4eb23250608611
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index de57d0cc837de81923c2420e51cfdfe94aad7995..d47969dc8f1417785f7f9ffed270a1312239f0d6 100644 (file)
 /* Define to 1 if you have the `matherr' function. */
 #undef HAVE_MATHERR
 
+/* Define to 1 if you have the `memmem' function. */
+#undef HAVE_MEMMEM
+
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
index f7996e115ebda1a9dc276364b4d340b5230a5181..356ad2b2a1604c6b9afc06a5d41b48a8fade6d24 100755 (executable)
@@ -14781,7 +14781,7 @@ else
 fi
 
 
-for ac_func in strerror_r strsignal wait4 mincore setenv unsetenv dl_iterate_phdr
+for ac_func in strerror_r strsignal wait4 mincore setenv unsetenv dl_iterate_phdr memmem
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
index 20ce205f2f434d266f2201d1b2360641ee35bb65..e2193a52f4aa0fbf345cee510f397b4a5b511b8e 100644 (file)
@@ -544,7 +544,7 @@ AC_CHECK_HEADERS([linux/filter.h linux/if_addr.h linux/if_ether.h linux/if_tun.h
 
 AM_CONDITIONAL(HAVE_SYS_MMAN_H, test "$ac_cv_header_sys_mman_h" = yes)
 
-AC_CHECK_FUNCS(strerror_r strsignal wait4 mincore setenv unsetenv dl_iterate_phdr)
+AC_CHECK_FUNCS(strerror_r strsignal wait4 mincore setenv unsetenv dl_iterate_phdr memmem)
 AM_CONDITIONAL(HAVE_STRERROR_R, test "$ac_cv_func_strerror_r" = yes)
 AM_CONDITIONAL(HAVE_WAIT4, test "$ac_cv_func_wait4" = yes)
 
index 39c060faf0bd7fda6327c6e7a38459c5e8d3d6f3..988dfaacf0c8a3f4216dcaceb193bf3e759227a4 100644 (file)
 #include "runtime.h"
 #include "array.h"
 
+#ifndef HAVE_MEMMEM
+
+#define memmem goMemmem
+
+static const void *goMemmem(const void *in, size_t inl, const void *s, size_t sl) {
+       const char *p;
+       char first;
+       const char *stop;
+
+       if (sl == 0) {
+               return in;
+       }
+       if (inl < sl) {
+               return nil;
+       }
+       first = *(const char *)(s);
+       stop = (const char *)(in) + (inl - sl);
+       for (p = (const char *)(in); p <= stop; p++) {
+               if (*p == first && __builtin_memcmp(p + 1, (const char *)(s) + 1, sl - 1) == 0) {
+                       return (const void *)(p);
+               }
+       }
+       return nil;
+}
+
+#endif
+
 intgo Compare(struct __go_open_array, struct __go_open_array)
   __asm__(GOSYM_PREFIX "internal_bytealg.Compare")
   __attribute__((no_split_stack));