]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Make memcheck/tests/stpncpy be dependent on the presence/absence of
authorJulian Seward <jseward@acm.org>
Fri, 14 Dec 2012 10:30:57 +0000 (10:30 +0000)
committerJulian Seward <jseward@acm.org>
Fri, 14 Dec 2012 10:30:57 +0000 (10:30 +0000)
stpncpy in libc, as determined by a configure test.  n-i-bz.
(Mark Wielaard, mjw@redhat.com)

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13180

configure.in
memcheck/tests/Makefile.am
memcheck/tests/stpncpy.c
memcheck/tests/stpncpy.vgtest

index 1c383ffdf857b77666e89141517d0b7e5af9a31c..da0f5d4086e2fe5793ee6824e2eec47a662c4bed 100644 (file)
@@ -1016,6 +1016,29 @@ AC_MSG_RESULT([no])
 
 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
 
+# Check for stpncpy function definition in string.h
+# This explicitly checks with _GNU_SOURCE defined since that is also
+# used in the test case (some systems might define it without anyway
+# since stpncpy is part of The Open Group Base Specifications Issue 7
+# IEEE Std 1003.1-2008.
+AC_MSG_CHECKING([for stpncpy])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#define _GNU_SOURCE
+#include <string.h>
+]], [[
+  char *d;
+  char *s;
+  size_t n = 0;
+  char *r = stpncpy(d, s, n);
+]])], [
+ac_have_gnu_stpncpy=yes
+AC_MSG_RESULT([yes])
+], [
+ac_have_gnu_stpncpy=no
+AC_MSG_RESULT([no])
+])
+
+AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
 
 # Check for CLOCK_MONOTONIC
 
index 018ecc01566b179693b0b2c84ebf308e5e5c5e7c..2c752843088cbd79344405ebb755217a9eaabb88 100644 (file)
@@ -288,7 +288,6 @@ check_PROGRAMS = \
        sbfragment \
        sh-mem sh-mem-random \
        sigaltstack signal2 sigprocmask static_malloc sigkill \
-       stpncpy \
        strchr \
        str_tester \
        supp_unknown supp1 supp2 suppfree \
@@ -307,6 +306,10 @@ if DWARF4
 check_PROGRAMS += dw4
 endif
 
+if HAVE_GNU_STPNCPY
+check_PROGRAMS += stpncpy
+endif
+
 AM_CFLAGS   += $(AM_FLAG_M3264_PRI)
 AM_CXXFLAGS += $(AM_FLAG_M3264_PRI)
 
index 4c8341932d85f2d142157143cbf5c0af8221bea4..fe348f847bc82c86534054fa065bf591b309465d 100644 (file)
@@ -1,5 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
+
+#define _GNU_SOURCE
 #include <string.h>
 
 int main(int argc, char **argv)
index fbfcaa7dc4103d6b223269269a40bee14f17d2cc..a54595ab473ade6bbecb6e168fe2f2f6cde6a619 100644 (file)
@@ -1,2 +1,3 @@
 prog: stpncpy
+prereq: test -e ./stpncpy
 vgopts: -q