/* confdefs.h */
#define PACKAGE_NAME "GNU M4"
#define PACKAGE_TARNAME "m4"
#define PACKAGE_VERSION "1.4.19"
#define PACKAGE_STRING "GNU M4 1.4.19"
#define PACKAGE_BUGREPORT "bug-m4@gnu.org"
#define PACKAGE_URL "https://www.gnu.org/software/m4/"
#define PACKAGE "m4"
#define VERSION "1.4.19"
#define HAVE_STDIO_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#define HAVE_STRINGS_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_UNISTD_H 1
#define HAVE_WCHAR_H 1
#define HAVE_PTHREAD_H 1
#define HAVE_SYS_PARAM_H 1
#define HAVE_SYS_SOCKET_H 1
#define HAVE_DIRENT_H 1
#define HAVE_GETOPT_H 1
#define HAVE_SYS_CDEFS_H 1
#define HAVE_ICONV_H 1
#define HAVE_LIMITS_H 1
#define HAVE_WCTYPE_H 1
#define HAVE_LANGINFO_H 1
#define HAVE_XLOCALE_H 1
#define HAVE_MATH_H 1
#define HAVE_SYS_MMAN_H 1
#define HAVE_SPAWN_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_RANDOM_H 1
#define HAVE_SYS_WAIT_H 1
#define HAVE_ARPA_INET_H 1
#define HAVE_SEMAPHORE_H 1
#define HAVE_NETDB_H 1
#define HAVE_NETINET_IN_H 1
#define HAVE_SYS_SELECT_H 1
#define HAVE_SYS_IOCTL_H 1
#define HAVE_SYS_UIO_H 1
#define STDC_HEADERS 1
#define _ALL_SOURCE 1
#define _DARWIN_C_SOURCE 1
#define _GNU_SOURCE 1
#define _HPUX_ALT_XOPEN_SOCKET_API 1
#define _NETBSD_SOURCE 1
#define _OPENBSD_SOURCE 1
#define _POSIX_PTHREAD_SEMANTICS 1
#define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1
#define __STDC_WANT_IEC_60559_BFP_EXT__ 1
#define __STDC_WANT_IEC_60559_DFP_EXT__ 1
#define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1
#define __STDC_WANT_IEC_60559_TYPES_EXT__ 1
#define __STDC_WANT_LIB_EXT2__ 1
#define __STDC_WANT_MATH_SPEC_FUNCS__ 1
#define _TANDEM_SOURCE 1
#define __EXTENSIONS__ 1
#define HAVE_FSEEKO 1
#define GNULIB_REGEX_SINGLE_THREAD 1
#define GNULIB_MBRTOWC_SINGLE_THREAD 1
#define GNULIB_WCHAR_SINGLE_LOCALE 1
#define HAVE_UNSIGNED_LONG_LONG_INT 1
#define HAVE_LONG_LONG_INT 1
#define HAVE_UNSIGNED_LONG_LONG_INT 1
#define HAVE_ALLOCA_H 1
#define HAVE_ALLOCA 1
#define HAVE_BTOWC 1
#define HAVE_REALPATH 1
#define HAVE_LSTAT 1
#define HAVE_FCHDIR 1
#define HAVE_FCNTL 1
#define HAVE_SYMLINK 1
#define HAVE_FPURGE 1
#define HAVE_GETDTABLESIZE 1
#define HAVE_GETPROGNAME 1
#define HAVE_ISWCNTRL 1
#define HAVE_ISWBLANK 1
#define HAVE_USELOCALE 1
#define HAVE_NEWLOCALE 1
#define HAVE_DUPLOCALE 1
#define HAVE_FREELOCALE 1
#define HAVE_MBSINIT 1
#define HAVE_MBRTOWC 1
#define HAVE_MPROTECT 1
#define HAVE_MKSTEMP 1
#define HAVE_NL_LANGINFO 1
#define HAVE_PIPE 1
#define HAVE_READLINK 1
#define HAVE_ISBLANK 1
#define HAVE_ISWCTYPE 1
#define HAVE_LINK 1
#define HAVE_GETUID 1
#define HAVE_GETEUID 1
#define HAVE_GETGID 1
#define HAVE_GETEGID 1
#define HAVE_SIGACTION 1
#define HAVE_SIGALTSTACK 1
#define HAVE_SIGINTERRUPT 1
#define HAVE_SETRLIMIT 1
#define HAVE_GETRLIMIT 1
#define HAVE_SNPRINTF 1
#define HAVE_STRERROR_R 1
#define HAVE_WCRTOMB 1
#define HAVE_WCWIDTH 1
#define HAVE_FTRUNCATE 1
#define HAVE_GETTIMEOFDAY 1
#define HAVE_PTHREAD_SIGMASK 1
#define HAVE_SETENV 1
#define HAVE_SLEEP 1
#define HAVE_CATGETS 1
#define HAVE_SHUTDOWN 1
#define HAVE_WCTOB 1
#define HAVE_LANGINFO_CODESET 1
#define HAVE_MALLOC_POSIX 1
#define HAVE_GETCWD 1
#define HAVE_DECL_STRERROR_R 1
#define HAVE_STRERROR_R 1
#define HAVE_SIG_ATOMIC_T 1
#define HAVE_DECL_FCHDIR 1
#define HAVE_WORKING_O_NOATIME 0
#define HAVE_WORKING_O_NOFOLLOW 1
#define eaccess access
#define HAVE_DECL_ALARM 1
#define _USE_STD_STAT 1
#define HAVE_DECL_FSEEKO 1
#define FUNC_FFLUSH_STDIN 0
#define restrict /**/
#define HAVE_DECL_FTELLO 1
#define HAVE_DECL_GETCWD 1
#define HAVE_DECL_GETDTABLESIZE 1
#define HAVE_GETOPT_H 1
#define HAVE_GETOPT_LONG_ONLY 1
#define HAVE_PTHREAD_API 1
#define SETLOCALE_NULL_ALL_MTSAFE 0
#define SETLOCALE_NULL_ONE_MTSAFE 1
#ifndef __powerpc__
#define __powerpc__ 1
#endif
#ifndef __powerpc__
#define __powerpc__ 1
#endif
#define HAVE_ICONV 1
#define ICONV_CONST 
#define HAVE_WINT_T 1
#define HAVE_LONG_LONG_INT 1
#define HAVE_UNSIGNED_LONG_LONG_INT 1
#define BITSIZEOF_PTRDIFF_T 32
#define BITSIZEOF_SIZE_T 32
#define BITSIZEOF_SIG_ATOMIC_T 32
#define BITSIZEOF_WCHAR_T 32
#define BITSIZEOF_WINT_T 32
#define HAVE_SIGNED_SIG_ATOMIC_T 1
#define HAVE_SIGNED_WCHAR_T 1
#define HAVE_SIGNED_WINT_T 1
#define PTRDIFF_T_SUFFIX 
#define SIZE_T_SUFFIX ul
#define SIG_ATOMIC_T_SUFFIX 
#define WCHAR_T_SUFFIX 
#define WINT_T_SUFFIX 
#define DBL_EXPBIT0_WORD 0
#define DBL_EXPBIT0_BIT 20
#define FLT_EXPBIT0_WORD 0
#define FLT_EXPBIT0_BIT 23
#define WORDS_BIGENDIAN 1
#define HAVE_TOWLOWER 1
#define HAVE_WCHAR_T 1
#define HAVE_LC_MESSAGES 1
#define HAVE_WORKING_USELOCALE 1
#define HAVE_GOOD_USELOCALE 1
#define HAVE_CFPREFERENCESCOPYAPPVALUE 1
#define HAVE_CFLOCALECOPYPREFERREDLANGUAGES 1
#define MALLOC_0_IS_NONNULL 1
#define HAVE_MBSTATE_T 1
#define MAP_ANONYMOUS MAP_ANON
#define HAVE_MAP_ANONYMOUS 1
#define HAVE_DECL_MEMRCHR 0
#define HAVE_MINMAX_IN_SYS_PARAM_H 1
#define PROMOTED_MODE_T int
#define HAVE_POSIX_SPAWN 1
#define HAVE_DECL_POSIX_SPAWN 1
#define REPLACE_POSIX_SPAWN 1
#define HAVE_SIGSET_T 1
#define HAVE_SCHED_H 1
#define USER_LABEL_PREFIX _
#define HAVE_DECL_SNPRINTF 1
#define HAVE_POSIX_SPAWNATTR_T 1
#define HAVE_POSIX_SPAWN_FILE_ACTIONS_T 1
#define HAVE__BOOL 1
#define HAVE_DECL_FCLOSEALL 0
#define __USE_MINGW_ANSI_STDIO 1
#define HAVE_DECL_ECVT 1
#define HAVE_DECL_FCVT 1
#define HAVE_DECL_GCVT 1
#define HAVE_DECL_STRDUP 1
#define REPLACE_STRERROR_0 1
#define HAVE_DECL_STRNDUP 0
#define HAVE_DECL_STRNLEN 0
#define HAVE_DECL_STRSIGNAL 1
#define HAVE_DECL_EXECVPE 0
#define HAVE_DECL_CLEARERR_UNLOCKED 1
#define HAVE_DECL_FEOF_UNLOCKED 1
#define HAVE_DECL_FERROR_UNLOCKED 1
#define HAVE_DECL_FFLUSH_UNLOCKED 0
#define HAVE_DECL_FGETS_UNLOCKED 0
#define HAVE_DECL_FPUTC_UNLOCKED 0
#define HAVE_DECL_FPUTS_UNLOCKED 0
#define HAVE_DECL_FREAD_UNLOCKED 0
#define HAVE_DECL_FWRITE_UNLOCKED 0
#define HAVE_DECL_GETC_UNLOCKED 1
#define HAVE_DECL_GETCHAR_UNLOCKED 1
#define HAVE_DECL_PUTC_UNLOCKED 1
#define HAVE_DECL_PUTCHAR_UNLOCKED 1
#define HAVE_INTTYPES_H_WITH_UINTMAX 1
#define HAVE_STDINT_H_WITH_UINTMAX 1
#define HAVE_INTMAX_T 1
#define HAVE_SNPRINTF 1
#define HAVE_WCSLEN 1
#define HAVE_MBRTOWC 1
#define HAVE_WCRTOMB 1
#define HAVE_DECL__SNPRINTF 0
#define HAVE_SNPRINTF_RETVAL_C99 1
#define HAVE_SNPRINTF_TRUNCATION_C99 1
#define CHECK_PRINTF_SAFE 1
#define HAVE_DECL_WCSDUP 0
#define HAVE_SHUTDOWN 1
#define HAVE_STRUCT_SOCKADDR_STORAGE 1
#define HAVE_SA_FAMILY_T 1
#define HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1
#define HAVE_IPV4 1
#define HAVE_IPV6 1
#define HAVE_PTHREAD_T 1
#define HAVE_DECL_SETENV 1
#define HAVE_SEARCH_H 1
#define HAVE_TSEARCH 1
#define HAVE_DECL_UNSETENV 1
#define GNULIB_TEST_ACCESS 1
#define HAVE_ALLOCA 1
#define GNULIB_TEST_BTOWC 1
#define HAVE___BUILTIN_EXPECT 1
#define GNULIB_TEST_CALLOC_POSIX 1
#define GNULIB_CANONICALIZE 1
#define GNULIB_TEST_CANONICALIZE 1
#define GNULIB_TEST_CANONICALIZE_FILE_NAME 1
#define GNULIB_CANONICALIZE_LGPL 1
#define GNULIB_TEST_CANONICALIZE_FILE_NAME 1
#define GNULIB_TEST_REALPATH 1
#define GNULIB_TEST_CHDIR 1
#define SIGNAL_SAFE_LIST 1
#define GNULIB_TEST_CLOEXEC 1
#define GNULIB_TEST_CLOSE 1
#define GNULIB_CLOSE_STREAM 1
#define HAVE_CLOSEDIR 1
#define GNULIB_TEST_CLOSEDIR 1
#define D_INO_IN_DIRENT 1
#define HAVE_DECL_DIRFD 1
#define GNULIB_TEST_DIRFD 1
#define GNULIB_DIRNAME 1
#define GNULIB_TEST_DUP 1
#define GNULIB_TEST_DUP2 1
#define GNULIB_TEST_ENVIRON 1
#define GNULIB_TEST_FCHDIR 1
#define FUNC_FFLUSH_STDIN 0
#define GNULIB_TEST_FCLOSE 1
#define GNULIB_TEST_FCNTL 1
#define GNULIB_FD_SAFER_FLAG 1
#define HAVE_DECL_FDOPENDIR 0
#define GNULIB_TEST_FDOPENDIR 1
#define GNULIB_FDOPENDIR 1
#define FUNC_FFLUSH_STDIN 0
#define GNULIB_FFLUSH 1
#define GNULIB_TEST_FFLUSH 1
#define GNULIB_FILENAMECAT 1
#define FLEXIBLE_ARRAY_MEMBER /**/
#define GNULIB_TEST_FOPEN 1
#define GNULIB_FOPEN_GNU 1
#define GNULIB_FOPEN_SAFER 1
#define HAVE_DECL_FPURGE 1
#define GNULIB_TEST_FPURGE 1
#define GNULIB_TEST_FREE_POSIX 1
#define HAVE_FREXP_IN_LIBC 1
#define GNULIB_TEST_FREXP 1
#define GNULIB_TEST_FREXPL 1
#define GNULIB_TEST_FSEEK 1
#define FUNC_FFLUSH_STDIN 0
#define GNULIB_TEST_FSEEKO 1
#define GNULIB_TEST_FSTAT 1
#define GNULIB_TEST_FSTATAT 1
#define GNULIB_TEST_FTELL 1
#define GNULIB_TEST_FTELLO 1
#define HAVE_GETPAGESIZE 1
/* end confdefs.h.  */

#include <errno.h>
#include <stdlib.h>
#if HAVE_UNISTD_H
# include <unistd.h>
#else /* on Windows with MSVC */
# include <direct.h>
#endif
#include <string.h>
#include <sys/stat.h>


/* Arrange to define PATH_MAX, like "pathmax.h" does. */
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <limits.h>
#if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN
# include <sys/param.h>
#endif
#if !defined PATH_MAX && defined MAXPATHLEN
# define PATH_MAX MAXPATHLEN
#endif
#ifdef __hpux
# undef PATH_MAX
# define PATH_MAX 1024
#endif
#if defined _WIN32 && ! defined __CYGWIN__
# undef PATH_MAX
# define PATH_MAX 260
#endif




#if defined _WIN32 && !defined __CYGWIN__
#define access    _access
#define chdir     _chdir
#define chmod     _chmod
#define close     _close
#define creat     _creat
#define dup       _dup
#define dup2      _dup2
#define ecvt      _ecvt
#define execl     _execl
#define execle    _execle
#define execlp    _execlp
#define execv     _execv
#define execve    _execve
#define execvp    _execvp
#define execvpe   _execvpe
#define fcloseall _fcloseall
#define fcvt      _fcvt
#define fdopen    _fdopen
#define fileno    _fileno
#define gcvt      _gcvt
#define getcwd    _getcwd
#define getpid    _getpid
#define getw      _getw
#define isatty    _isatty
#define j0        _j0
#define j1        _j1
#define jn        _jn
#define lfind     _lfind
#define lsearch   _lsearch
#define lseek     _lseek
#define memccpy   _memccpy
#define mkdir     _mkdir
#define mktemp    _mktemp
#define open      _open
#define putenv    _putenv
#define putw      _putw
#define read      _read
#define rmdir     _rmdir
#define strdup    _strdup
#define swab      _swab
#define tempnam   _tempnam
#define tzset     _tzset
#define umask     _umask
#define unlink    _unlink
#define utime     _utime
#define wcsdup    _wcsdup
#define write     _write
#define y0        _y0
#define y1        _y1
#define yn        _yn
#endif



#ifndef S_IRWXU
# define S_IRWXU 0700
#endif

/* FIXME: skip the run-test altogether on systems without getpagesize.  */
#if ! HAVE_GETPAGESIZE
# define getpagesize() 0
#endif

/* This size is chosen to be larger than PATH_MAX (4k), yet smaller than
   the 16kB pagesize on ia64 linux.  Those conditions make the code below
   trigger a bug in glibc's getcwd implementation before 2.4.90-10.  */
#define TARGET_LEN (5 * 1024)

int
main ()
{
  char *cwd;
  size_t initial_cwd_len;
  int fail = 0;

  /* The bug is triggered when PATH_MAX < getpagesize (), so skip
     this relatively expensive and invasive test if that's not true.  */
#ifdef PATH_MAX
  int bug_possible = PATH_MAX < getpagesize ();
#else
  int bug_possible = 0;
#endif
  if (! bug_possible)
    return 0;

  cwd = getcwd (NULL, 0);
  if (cwd == NULL)
    return 2;

  initial_cwd_len = strlen (cwd);
  free (cwd);

  if (1)
    {
      static char const dir_name[] = "confdir-14B---";
      size_t desired_depth = ((TARGET_LEN - 1 - initial_cwd_len)
                              / sizeof dir_name);
      size_t d;
      for (d = 0; d < desired_depth; d++)
        {
          if (mkdir (dir_name, S_IRWXU) < 0 || chdir (dir_name) < 0)
            {
              if (! (errno == ERANGE || errno == ENAMETOOLONG
                     || errno == ENOENT))
                fail = 3; /* Unable to construct deep hierarchy.  */
              break;
            }
        }

      /* If libc has the bug in question, this invocation of getcwd
         results in a failed assertion.  */
      cwd = getcwd (NULL, 0);
      if (cwd == NULL)
        fail = 4; /* getcwd didn't assert, but it failed for a long name
                     where the answer could have been learned.  */
      free (cwd);

      /* Call rmdir first, in case the above chdir failed.  */
      rmdir (dir_name);
      while (0 < d--)
        {
          if (chdir ("..") < 0)
            {
              fail = 5;
              break;
            }
          rmdir (dir_name);
        }
    }

  return fail;
}

