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