summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac10
-rw-r--r--openbsd-compat/bsd-misc.c16
-rw-r--r--openbsd-compat/bsd-misc.h4
3 files changed, 30 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 70e72be77..d2fb4469c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2059,6 +2059,16 @@ AC_CHECK_FUNCS([realpath], [
2059 ) 2059 )
2060]) 2060])
2061 2061
2062AC_MSG_CHECKING([for working fflush(NULL)])
2063AC_RUN_IFELSE(
2064 [AC_LANG_PROGRAM([[#include <stdio.h>]], [[fflush(NULL); exit(0);]])],
2065 AC_MSG_RESULT([yes]),
2066 [AC_MSG_RESULT([no])
2067 AC_DEFINE([FFLUSH_NULL_BUG], [1],
2068 [define if fflush(NULL) does not work])],
2069 AC_MSG_WARN([cross compiling: assuming working])
2070)
2071
2062dnl Checks for time functions 2072dnl Checks for time functions
2063AC_CHECK_FUNCS([gettimeofday time]) 2073AC_CHECK_FUNCS([gettimeofday time])
2064dnl Checks for utmp functions 2074dnl Checks for utmp functions
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c
index f7187daf8..3daf61071 100644
--- a/openbsd-compat/bsd-misc.c
+++ b/openbsd-compat/bsd-misc.c
@@ -308,3 +308,19 @@ getsid(pid_t pid)
308} 308}
309#endif 309#endif
310 310
311#ifdef FFLUSH_NULL_BUG
312#undef fflush
313int _ssh_compat_fflush(FILE *f)
314{
315 int r1, r2, r3;
316
317 if (f == NULL) {
318 r2 = fflush(stdout);
319 r3 = fflush(stderr);
320 if (r1 == -1 || r2 == -1 || r3 == -1)
321 return -1;
322 return 0;
323 }
324 return fflush(f);
325}
326#endif
diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h
index fb81e6c72..52ec52853 100644
--- a/openbsd-compat/bsd-misc.h
+++ b/openbsd-compat/bsd-misc.h
@@ -153,4 +153,8 @@ pid_t getsid(pid_t);
153int flock(int, int); 153int flock(int, int);
154#endif 154#endif
155 155
156#ifdef FFLUSH_NULL_BUG
157# define fflush(x) (_ssh_compat_fflush(x))
158#endif
159
156#endif /* _BSD_MISC_H */ 160#endif /* _BSD_MISC_H */