1*a7c91847Schristos# eoverflow.m4 serial 1 2*a7c91847Schristosdnl Copyright (C) 2004 Free Software Foundation, Inc. 3*a7c91847Schristosdnl This file is free software; the Free Software Foundation 4*a7c91847Schristosdnl gives unlimited permission to copy and/or distribute it, 5*a7c91847Schristosdnl with or without modifications, as long as this notice is preserved. 6*a7c91847Schristos 7*a7c91847Schristosdnl From Bruno Haible. 8*a7c91847Schristos 9*a7c91847Schristos# The EOVERFLOW errno value ought to be defined in <errno.h>, according to 10*a7c91847Schristos# POSIX. But some systems (like AIX 3) don't define it, and some systems 11*a7c91847Schristos# (like OSF/1) define it when _XOPEN_SOURCE_EXTENDED is defined. 12*a7c91847Schristos 13*a7c91847Schristos# Define EOVERFLOW as a C macro and as a substituted macro in such a way that 14*a7c91847Schristos# 1. on all systems, after inclusion of <errno.h>, EOVERFLOW is usable, 15*a7c91847Schristos# 2. on systems where EOVERFLOW is defined elsewhere, we use the same numeric 16*a7c91847Schristos# value. 17*a7c91847Schristos 18*a7c91847SchristosAC_DEFUN([gl_EOVERFLOW], 19*a7c91847Schristos[ 20*a7c91847Schristos AC_REQUIRE([AC_PROG_CC])dnl 21*a7c91847Schristos 22*a7c91847Schristos AC_CACHE_CHECK([for EOVERFLOW], ac_cv_decl_EOVERFLOW, [ 23*a7c91847Schristos AC_EGREP_CPP(yes,[ 24*a7c91847Schristos#include <errno.h> 25*a7c91847Schristos#ifdef EOVERFLOW 26*a7c91847Schristosyes 27*a7c91847Schristos#endif 28*a7c91847Schristos ], have_eoverflow=1) 29*a7c91847Schristos if test -n "$have_eoverflow"; then 30*a7c91847Schristos dnl EOVERFLOW exists in <errno.h>. Don't need to define EOVERFLOW ourselves. 31*a7c91847Schristos ac_cv_decl_EOVERFLOW=yes 32*a7c91847Schristos else 33*a7c91847Schristos AC_EGREP_CPP(yes,[ 34*a7c91847Schristos#define _XOPEN_SOURCE_EXTENDED 1 35*a7c91847Schristos#include <errno.h> 36*a7c91847Schristos#ifdef EOVERFLOW 37*a7c91847Schristosyes 38*a7c91847Schristos#endif 39*a7c91847Schristos ], have_eoverflow=1) 40*a7c91847Schristos if test -n "$have_eoverflow"; then 41*a7c91847Schristos dnl EOVERFLOW exists but is hidden. 42*a7c91847Schristos dnl Define it to the same value. 43*a7c91847Schristos _AC_COMPUTE_INT([EOVERFLOW], ac_cv_decl_EOVERFLOW, [ 44*a7c91847Schristos#define _XOPEN_SOURCE_EXTENDED 1 45*a7c91847Schristos#include <errno.h> 46*a7c91847Schristos/* The following two lines are a workaround against an autoconf-2.52 bug. */ 47*a7c91847Schristos#include <stdio.h> 48*a7c91847Schristos#include <stdlib.h> 49*a7c91847Schristos]) 50*a7c91847Schristos else 51*a7c91847Schristos dnl EOVERFLOW isn't defined by the system. Define EOVERFLOW ourselves, but 52*a7c91847Schristos dnl don't define it as EINVAL, because snprintf() callers want to 53*a7c91847Schristos dnl distinguish EINVAL and EOVERFLOW. 54*a7c91847Schristos ac_cv_decl_EOVERFLOW=E2BIG 55*a7c91847Schristos fi 56*a7c91847Schristos fi 57*a7c91847Schristos ]) 58*a7c91847Schristos if test "$ac_cv_decl_EOVERFLOW" != yes; then 59*a7c91847Schristos AC_DEFINE_UNQUOTED([EOVERFLOW], [$ac_cv_decl_EOVERFLOW], 60*a7c91847Schristos [Define as good substitute value for EOVERFLOW.]) 61*a7c91847Schristos EOVERFLOW="$ac_cv_decl_EOVERFLOW" 62*a7c91847Schristos AC_SUBST(EOVERFLOW) 63*a7c91847Schristos fi 64*a7c91847Schristos]) 65