1 #serial 1 -*- autoconf -*-
4 AC_DEFUN(jm_SYS_OFF_T_PRINTF_FORMAT,
6 AC_REQUIRE([AC_TYPE_OFF_T])
7 AC_CHECK_HEADERS(string.h stdlinb.h)
8 AC_CACHE_CHECK([for printf format that works with type off_t],
9 jm_cv_sys_off_t_printf_format,
11 jm_cv_sys_off_t_printf_format=undef
12 for jm_fmt in '' L ll q; do
13 jm_OFF_T_FORMAT="$jm_fmt"
14 export jm_OFF_T_FORMAT
16 # include <sys/types.h>
27 static off_t x[] = {1, 255, 65535, 99999999};
28 char buf[50], fmt[50];
30 /* this should be one of these values: "", "L", "ll", "q" */
31 char *f = getenv ("jm_OFF_T_FORMAT");
33 sprintf (fmt, "%%%sd %%%sx %%%sx %%%sd", f, f, f, f);
34 sprintf (buf, fmt, x[0], x[1], x[2], x[3]);
35 exit (strcmp (buf, "1 ff ffff 99999999"));
37 ], jm_cv_sys_off_t_printf_format=$jm_fmt; break
39 dnl Cross compiling -- you lose. Specify it via the cache.
43 # Die if none of the above worked.
44 # FIXME: If this failure become a problem that we can't work around,
45 # an alternative would be to arrange not to build od.
46 if test "$jm_cv_sys_off_t_printf_format" = undef; then
48 [couldn't find a printf format that works with the type, off_t])
52 AC_DEFINE_UNQUOTED(OFF_T_PRINTF_FORMAT_STRING,
53 "$jm_cv_sys_off_t_printf_format",
54 [printf format string for type off_t, without the `%'])