1295 |
# AC_FUNC_SETVBUF_REVERSED |
# AC_FUNC_SETVBUF_REVERSED |
1296 |
# ------------------------ |
# ------------------------ |
1297 |
AC_DEFUN([AC_FUNC_SETVBUF_REVERSED], |
AC_DEFUN([AC_FUNC_SETVBUF_REVERSED], |
1298 |
[AC_CACHE_CHECK(whether setvbuf arguments are reversed, |
[AC_REQUIRE([AC_C_PROTOTYPES])dnl |
1299 |
|
AC_CACHE_CHECK(whether setvbuf arguments are reversed, |
1300 |
ac_cv_func_setvbuf_reversed, |
ac_cv_func_setvbuf_reversed, |
1301 |
[AC_TRY_RUN([#include <stdio.h> |
[ac_cv_func_setvbuf_reversed=no |
1302 |
/* If setvbuf has the reversed format, exit 0. */ |
AC_LINK_IFELSE( |
1303 |
int |
[AC_LANG_PROGRAM( |
1304 |
main () |
[[#include <stdio.h> |
1305 |
{ |
# if PROTOTYPES |
1306 |
/* This call has the arguments reversed. |
int (setvbuf) (FILE *, int, char *, size_t); |
1307 |
A reversed system may check and see that the address of main |
# endif]], |
1308 |
is not _IOLBF, _IONBF, or _IOFBF, and return nonzero. */ |
[[char buf; return setvbuf (stdout, _IOLBF, &buf, 1);]])], |
1309 |
if (setvbuf(stdout, _IOLBF, (char *) main, BUFSIZ) != 0) |
[AC_LINK_IFELSE( |
1310 |
exit(1); |
[AC_LANG_PROGRAM( |
1311 |
putc('\r', stdout); |
[[#include <stdio.h> |
1312 |
exit(0); /* Non-reversed systems segv here. */ |
# if PROTOTYPES |
1313 |
}], ac_cv_func_setvbuf_reversed=yes, ac_cv_func_setvbuf_reversed=no) |
int (setvbuf) (FILE *, int, char *, size_t); |
1314 |
rm -f core core.* *.core]) |
# endif]], |
1315 |
|
[[char buf; return setvbuf (stdout, &buf, _IOLBF, 1);]])], |
1316 |
|
[# It compiles and links either way, so it must not be declared |
1317 |
|
# with a prototype and most likely this is a K&R C compiler. |
1318 |
|
# Try running it. |
1319 |
|
AC_RUN_IFELSE( |
1320 |
|
[AC_LANG_PROGRAM( |
1321 |
|
[[#include <stdio.h>]], |
1322 |
|
[[/* This call has the arguments reversed. |
1323 |
|
A reversed system may check and see that the address of buf |
1324 |
|
is not _IOLBF, _IONBF, or _IOFBF, and return nonzero. */ |
1325 |
|
char buf; |
1326 |
|
if (setvbuf (stdout, _IOLBF, &buf, 1) != 0) |
1327 |
|
exit (1); |
1328 |
|
putchar ('\r'); |
1329 |
|
exit (0); /* Non-reversed systems SEGV here. */]])], |
1330 |
|
ac_cv_func_setvbuf_reversed=yes, |
1331 |
|
rm -f core core.* *.core, |
1332 |
|
[[: # Assume setvbuf is not reversed when cross-compiling.]])] |
1333 |
|
ac_cv_func_setvbuf_reversed=yes)])]) |
1334 |
if test $ac_cv_func_setvbuf_reversed = yes; then |
if test $ac_cv_func_setvbuf_reversed = yes; then |
1335 |
AC_DEFINE(SETVBUF_REVERSED, 1, |
AC_DEFINE(SETVBUF_REVERSED, 1, |
1336 |
[Define to 1 if the `setvbuf' function takes the buffering type as |
[Define to 1 if the `setvbuf' function takes the buffering type as |