Skip to content

Commit 5f539d9

Browse files
committed
fix valgrind t_vfprintf_s
1 parent 39bb43f commit 5f539d9

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ check_include_file("altivec.h" HAVE_ALTIVEC_H)
224224
check_include_file("spe.h" HAVE_SPE_H)
225225
check_include_file("mbarrier.h" HAVE_MBARRIER_H)
226226
check_include_file("stdbool.h" HAVE_STDBOOL_H)
227+
check_include_file("valgrind/valgrind.h" HAVE_VALGRIND_VALGRIND_H)
227228

228229
# Check types
229230
set(CMAKE_EXTRA_INCLUDE_FILES "stddef.h")

cmakeconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@
9191
/* Define to 1 if you have the <stdbool.h> header file. */
9292
#cmakedefine HAVE_STDBOOL_H 1
9393

94+
/* Define to 1 if you have the <valgrind/valgrind.h> header file. */
95+
#cmakedefine HAVE_VALGRIND_VALGRIND_H 1
96+
9497
/* Define to 1 if the compiler supports C99 */
9598
#cmakedefine SAFECLIB_HAVE_C99 1
9699

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,7 @@ AC_CHECK_HEADERS([stdlib.h \
833833
altivec.h \
834834
spe.h \
835835
mbarrier.h \
836+
valgrind/valgrind.h \
836837
])
837838

838839
INSERT_SYS_TYPES_H=""

tests/test_vfprintf_s.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#ifdef HAVE_SYS_STAT_H
1313
#include <sys/stat.h>
1414
#endif
15+
#ifdef HAVE_VALGRIND_VALGRIND_H
16+
#include <valgrind/valgrind.h>
17+
#endif
1518

1619
#include "test_msvcrt.h"
1720

@@ -222,6 +225,13 @@ int test_vfprintf_s(void) {
222225

223226
fclose(out);
224227

228+
#ifdef HAVE_VALGRIND_VALGRIND_H
229+
if (RUNNING_ON_VALGRIND) {
230+
unlink(TMP);
231+
return errs;
232+
}
233+
#endif
234+
225235
/* print to closed stream: across libc's unportable, and not valgrind-safe */
226236
rc = vtfprintf_s(out, "%s", str1);
227237
ANYERR(); // Windows may produce EOF, most others EBADF

0 commit comments

Comments
 (0)