/* confdefs.h */ #define PACKAGE_NAME "GNU coreutils" #define PACKAGE_TARNAME "coreutils" #define PACKAGE_VERSION "8.23.75-78202-dirty" #define PACKAGE_STRING "GNU coreutils 8.23.75-78202-dirty" #define PACKAGE_BUGREPORT "address@hidden" #define PACKAGE_URL "http://www.gnu.org/software/coreutils/" #define PACKAGE "coreutils" #define VERSION "8.23.75-78202-dirty" #define STDC_HEADERS 1 #define HAVE_SYS_TYPES_H 1 #define HAVE_SYS_STAT_H 1 #define HAVE_STDLIB_H 1 #define HAVE_STRING_H 1 #define HAVE_MEMORY_H 1 #define HAVE_STRINGS_H 1 #define HAVE_INTTYPES_H 1 #define HAVE_STDINT_H 1 #define HAVE_UNISTD_H 1 #define __EXTENSIONS__ 1 #define _ALL_SOURCE 1 #define _DARWIN_C_SOURCE 1 #define _GNU_SOURCE 1 #define _POSIX_PTHREAD_SEMANTICS 1 #define _TANDEM_SOURCE 1 #define HAVE_FSEEKO 1 #define _DARWIN_USE_64_BIT_INODE 1 #define _REENTRANT 1 #define _THREAD_SAFE 1 #define HAVE_ALLOCA_H 1 #define HAVE_ALLOCA 1 #define HAVE_ARPA_INET_H 1 #define HAVE_FEATURES_H 1 #define HAVE_UNISTD_H 1 #define HAVE_SYS_PARAM_H 1 #define HAVE_SYS_SOCKET_H 1 #define HAVE_DIRENT_H 1 #define HAVE_WCTYPE_H 1 #define HAVE_STDIO_EXT_H 1 #define HAVE_SYS_STAT_H 1 #define HAVE_SYS_VFS_H 1 #define HAVE_NETDB_H 1 #define HAVE_NETINET_IN_H 1 #define HAVE_GETOPT_H 1 #define HAVE_TERMIOS_H 1 #define HAVE_SYS_TIME_H 1 #define HAVE_GRP_H 1 #define HAVE_ICONV_H 1 #define HAVE_WCHAR_H 1 #define HAVE_STDINT_H 1 #define HAVE_INTTYPES_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_SYS_STATVFS_H 1 #define HAVE_SYS_SELECT_H 1 #define HAVE_PTHREAD_H 1 #define HAVE_UTMP_H 1 #define HAVE_UTMPX_H 1 #define HAVE_MALLOC_H 1 #define HAVE_SCHED_H 1 #define HAVE_SELINUX_SELINUX_H 1 #define HAVE_SYS_IOCTL_H 1 #define HAVE_SYS_RESOURCE_H 1 #define HAVE_SYS_UIO_H 1 #define HAVE_SYS_UTSNAME_H 1 #define HAVE_SYS_WAIT_H 1 #define HAVE_UTIME_H 1 #define HAVE_LINUX_FALLOC_H 1 #define HAVE_PATHS_H 1 #define HAVE_SYSLOG_H 1 #define HAVE_PWD_H 1 #define HAVE_GMP_H 1 #define D_INO_IN_DIRENT 1 #define HAVE_LONG_FILE_NAMES 1 #define HAVE_PATHCONF 1 #define HAVE_BTOWC 1 #define HAVE_CANONICALIZE_FILE_NAME 1 #define HAVE_REALPATH 1 #define HAVE_READLINKAT 1 #define HAVE_CHOWN 1 #define HAVE_FCHOWN 1 #define HAVE_FCHDIR 1 #define HAVE_FDOPENDIR 1 #define HAVE_GETDTABLESIZE 1 #define HAVE_FACCESSAT 1 #define HAVE_POSIX_FADVISE 1 #define HAVE_FCHMODAT 1 #define HAVE_FCNTL 1 #define HAVE_SYMLINK 1 #define HAVE_MEMPCPY 1 #define HAVE_ISBLANK 1 #define HAVE_ISWCTYPE 1 #define HAVE_MBSRTOWCS 1 #define HAVE_WMEMCHR 1 #define HAVE_WMEMCPY 1 #define HAVE_WMEMPCPY 1 #define HAVE___FPURGE 1 #define HAVE___FREADING 1 #define HAVE_FSTATAT 1 #define HAVE_FSYNC 1 #define HAVE_STRTOF 1 #define HAVE_FTRUNCATE 1 #define HAVE_OPENAT 1 #define HAVE_FSTATFS 1 #define HAVE_FUTIMENS 1 #define HAVE_GETDELIM 1 #define HAVE_GETLOGIN 1 #define HAVE_FLOCKFILE 1 #define HAVE_FUNLOCKFILE 1 #define HAVE___FSETLOCKING 1 #define HAVE_TCGETATTR 1 #define HAVE_TCSETATTR 1 #define HAVE_GETTIMEOFDAY 1 #define HAVE_GETUSERSHELL 1 #define HAVE_ISWCNTRL 1 #define HAVE_ISWBLANK 1 #define HAVE_LINK 1 #define HAVE_READLINK 1 #define HAVE_LINKAT 1 #define HAVE_LSTAT 1 #define HAVE_MBSINIT 1 #define HAVE_MBRTOWC 1 #define HAVE_MBRLEN 1 #define HAVE_ISASCII 1 #define HAVE_MPROTECT 1 #define HAVE_GETGROUPLIST 1 #define HAVE_FCHMOD 1 #define HAVE_MKFIFO 1 #define HAVE_MKNOD 1 #define HAVE_MKSTEMP 1 #define HAVE_NL_LANGINFO 1 #define HAVE_PIPE 1 #define HAVE_UTMPNAME 1 #define HAVE_UTMPXNAME 1 #define HAVE_SECURE_GETENV 1 #define HAVE_SETENV 1 #define HAVE_SETTIMEOFDAY 1 #define HAVE_STIME 1 #define HAVE_SIGACTION 1 #define HAVE_SIGALTSTACK 1 #define HAVE_SIGINTERRUPT 1 #define HAVE_SNPRINTF 1 #define HAVE_STPNCPY 1 #define HAVE_STRDUP 1 #define HAVE_STRERROR_R 1 #define HAVE___XPG_STRERROR_R 1 #define HAVE_TZSET 1 #define HAVE_STRNDUP 1 #define HAVE_STRTOIMAX 1 #define HAVE_STRTOUMAX 1 #define HAVE_LOCALTIME_R 1 #define HAVE_UNLINKAT 1 #define HAVE_FUTIMES 1 #define HAVE_FUTIMESAT 1 #define HAVE_UTIMENSAT 1 #define HAVE_LUTIMES 1 #define HAVE_WCRTOMB 1 #define HAVE_WCWIDTH 1 #define HAVE_WCSWIDTH 1 #define HAVE_GETEGID 1 #define HAVE_TTYNAME 1 #define HAVE_NEWLOCALE 1 #define HAVE_SLEEP 1 #define HAVE_CATGETS 1 #define HAVE_SYMLINKAT 1 #define HAVE_SHUTDOWN 1 #define HAVE_WCTOB 1 #define HAVE_SETRLIMIT 1 #define HAVE_PRCTL 1 #define HAVE_ENDGRENT 1 #define HAVE_ENDPWENT 1 #define HAVE_FALLOCATE 1 #define HAVE_ISWSPACE 1 #define HAVE_SETGROUPS 1 #define HAVE_SETHOSTNAME 1 #define HAVE_SYNC 1 #define HAVE_SYSCTL 1 #define HAVE_SYSINFO 1 #define HAVE_TCGETPGRP 1 #define restrict __restrict #define HAVE_LANGINFO_CODESET 1 #define HAVE_C99_STRTOLD 1 #define FUNC_REALPATH_WORKS 1 #define HAVE_UNISTD_H 1 #define HAVE_CHOWN 1 #define HAVE_ENVIRON_DECL 1 #define HAVE_DECL_STRERROR_R 1 #define HAVE_STRERROR_R 1 #define STRERROR_R_CHAR_P 1 #define GETGROUPS_T gid_t #define HAVE_DECL_FCHDIR 1 #define HAVE_WORKING_O_NOATIME 1 #define HAVE_WORKING_O_NOFOLLOW 1 #define PROMOTED_MODE_T mode_t #define HAVE_DECL_FDATASYNC 1 #define HAVE_DECL_STRMODE 0 #define HAVE_MBSTATE_T 1 #define HAVE_DECL_ALARM 1 #define HAVE_DECL_FSEEKO 1 #define FUNC_FFLUSH_STDIN 0 #define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 #define HAVE_DECL_FTELLO 1 #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_GETHOSTBYNAME 1 #define HAVE_GETSERVBYNAME 1 #define HAVE_DECL_INET_NTOP 1 #define HAVE_IPV4 1 #define HAVE_IPV6 1 #define HAVE_DECL_GETCWD 1 #define HAVE_DECL_GETDELIM 1 #define HAVE_UNSIGNED_LONG_LONG_INT 1 #define HAVE_LONG_LONG_INT 1 #define HAVE_DECL_GETLINE 1 #define HAVE_GETOPT_H 1 #define HAVE_GETOPT_LONG_ONLY 1 #define HAVE_DECL_GETENV 1 #define HAVE_DECL_GETPASS 1 #define HAVE_DECL_FFLUSH_UNLOCKED 1 #define HAVE_DECL_FLOCKFILE 1 #define HAVE_DECL_FPUTS_UNLOCKED 1 #define HAVE_DECL_FUNLOCKFILE 1 #define HAVE_DECL_PUTC_UNLOCKED 1 #define HAVE_ICONV 1 #define ICONV_CONST #define HAVE_INTTYPES_H 1 #define DBL_EXPBIT0_WORD 1 #define DBL_EXPBIT0_BIT 20 #define FLT_EXPBIT0_WORD 0 #define FLT_EXPBIT0_BIT 23 #define HAVE_WINT_T 1 #define HAVE_TOWLOWER 1 #define HAVE_DECL_GETC_UNLOCKED 1 #define HAVE_WCHAR_T 1 #define USE_POSIX_THREADS 1 #define USE_POSIX_THREADS_WEAK 1 #define HAVE_STDLIB_H 1 #define MALLOC_0_IS_NONNULL 1 #define MBRTOWC_EMPTY_INPUT_BUG 1 #define HAVE_MAP_ANONYMOUS 1 #define HAVE_DECL_MEMRCHR 1 #define HAVE__BOOL 1 #define HAVE_COMPOUND_LITERALS 1 #define HAVE_TM_GMTOFF 1 #define HAVE_SIGSET_T 1 #define HAVE_DECL_SETENV 1 #define HAVE_SEARCH_H 1 #define HAVE_TSEARCH 1 #define HAVE_DECL_SNPRINTF 1 #define HAVE_DECL_STPNCPY 1 #define HAVE_DECL_STRDUP 1 #define HAVE_MAP_ANONYMOUS 1 #define HAVE_DECL_STRNDUP 1 #define HAVE_DECL_STRNLEN 1 #define HAVE_DECL_STRSIGNAL 1 #define HAVE_DECL_SYS_SIGLIST 1 #define HAVE_DECL_STRTOIMAX 1 #define HAVE_DECL_STRTOUMAX 1 #define HAVE_DECL_CLEARERR_UNLOCKED 1 #define HAVE_DECL_FEOF_UNLOCKED 1 #define HAVE_DECL_FERROR_UNLOCKED 1 #define HAVE_DECL_FGETS_UNLOCKED 1 #define HAVE_DECL_FPUTC_UNLOCKED 1 #define HAVE_DECL_FREAD_UNLOCKED 1 #define HAVE_DECL_FWRITE_UNLOCKED 1 #define HAVE_DECL_GETCHAR_UNLOCKED 1 #define HAVE_DECL_PUTCHAR_UNLOCKED 1 #define HAVE_DECL_UNSETENV 1 #define HAVE_WORKING_UTIMES 1 #define HAVE_STRUCT_UTIMBUF 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_STRNLEN 1 #define HAVE_WCSLEN 1 #define HAVE_WCSNLEN 1 #define HAVE_MBRTOWC 1 #define HAVE_WCRTOMB 1 #define HAVE_DECL__SNPRINTF 0 #define HAVE_SNPRINTF_RETVAL_C99 1 #define CHECK_PRINTF_SAFE 1 /* end confdefs.h. */ #include #if defined __MACH__ && defined __APPLE__ /* Avoid a crash on Mac OS X. */ #include #include #include #include #include #include /* The exception port on which our thread listens. */ static mach_port_t our_exception_port; /* The main function of the thread listening for exceptions of type EXC_BAD_ACCESS. */ static void * mach_exception_thread (void *arg) { /* Buffer for a message to be received. */ struct { mach_msg_header_t head; mach_msg_body_t msgh_body; char data[1024]; } msg; mach_msg_return_t retval; /* Wait for a message on the exception port. */ retval = mach_msg (&msg.head, MACH_RCV_MSG | MACH_RCV_LARGE, 0, sizeof (msg), our_exception_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (retval != MACH_MSG_SUCCESS) abort (); exit (1); } static void nocrash_init (void) { mach_port_t self = mach_task_self (); /* Allocate a port on which the thread shall listen for exceptions. */ if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port) == KERN_SUCCESS) { /* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */ if (mach_port_insert_right (self, our_exception_port, our_exception_port, MACH_MSG_TYPE_MAKE_SEND) == KERN_SUCCESS) { /* The exceptions we want to catch. Only EXC_BAD_ACCESS is interesting for us. */ exception_mask_t mask = EXC_MASK_BAD_ACCESS; /* Create the thread listening on the exception port. */ pthread_attr_t attr; pthread_t thread; if (pthread_attr_init (&attr) == 0 && pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) == 0 && pthread_create (&thread, &attr, mach_exception_thread, NULL) == 0) { pthread_attr_destroy (&attr); /* Replace the exception port info for these exceptions with our own. Note that we replace the exception port for the entire task, not only for a particular thread. This has the effect that when our exception port gets the message, the thread specific exception port has already been asked, and we don't need to bother about it. See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */ task_set_exception_ports (self, mask, our_exception_port, EXCEPTION_DEFAULT, MACHINE_THREAD_STATE); } } } } #elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* Avoid a crash on native Windows. */ #define WIN32_LEAN_AND_MEAN #include #include static LONG WINAPI exception_filter (EXCEPTION_POINTERS *ExceptionInfo) { switch (ExceptionInfo->ExceptionRecord->ExceptionCode) { case EXCEPTION_ACCESS_VIOLATION: case EXCEPTION_IN_PAGE_ERROR: case EXCEPTION_STACK_OVERFLOW: case EXCEPTION_GUARD_PAGE: case EXCEPTION_PRIV_INSTRUCTION: case EXCEPTION_ILLEGAL_INSTRUCTION: case EXCEPTION_DATATYPE_MISALIGNMENT: case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: case EXCEPTION_NONCONTINUABLE_EXCEPTION: exit (1); } return EXCEPTION_CONTINUE_SEARCH; } static void nocrash_init (void) { SetUnhandledExceptionFilter ((LPTOP_LEVEL_EXCEPTION_FILTER) exception_filter); } #else /* Avoid a crash on POSIX systems. */ #include /* A POSIX signal handler. */ static void exception_handler (int sig) { exit (1); } static void nocrash_init (void) { #ifdef SIGSEGV signal (SIGSEGV, exception_handler); #endif #ifdef SIGBUS signal (SIGBUS, exception_handler); #endif } #endif #include #include #include static int strisnan (const char *string, size_t start_index, size_t end_index) { if (start_index < end_index) { if (string[start_index] == '-') start_index++; if (start_index + 3 <= end_index && memcmp (string + start_index, "nan", 3) == 0) { start_index += 3; if (start_index == end_index || (string[start_index] == '(' && string[end_index - 1] == ')')) return 1; } } return 0; } static char buf[10000]; static long double zeroL = 0.0L; int main () { int result = 0; nocrash_init(); if (sprintf (buf, "%Lf", 1.0L / zeroL) < 0 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) result |= 1; if (sprintf (buf, "%Lf", -1.0L / zeroL) < 0 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) result |= 1; if (sprintf (buf, "%Lf", zeroL / zeroL) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 1; if (sprintf (buf, "%Le", 1.0L / zeroL) < 0 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) result |= 1; if (sprintf (buf, "%Le", -1.0L / zeroL) < 0 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) result |= 1; if (sprintf (buf, "%Le", zeroL / zeroL) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 1; if (sprintf (buf, "%Lg", 1.0L / zeroL) < 0 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) result |= 1; if (sprintf (buf, "%Lg", -1.0L / zeroL) < 0 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) result |= 1; if (sprintf (buf, "%Lg", zeroL / zeroL) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 1; #if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE /* Representation of an 80-bit 'long double' as an initializer for a sequence of 'unsigned int' words. */ # ifdef WORDS_BIGENDIAN # define LDBL80_WORDS(exponent,manthi,mantlo) { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), ((unsigned int) (manthi) << 16) | ((unsigned int) (mantlo) >> 16), (unsigned int) (mantlo) << 16 } # else # define LDBL80_WORDS(exponent,manthi,mantlo) { mantlo, manthi, exponent } # endif { /* Quiet NaN. */ static union { unsigned int word[4]; long double value; } x = { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) }; if (sprintf (buf, "%Lf", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 2; if (sprintf (buf, "%Le", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 2; if (sprintf (buf, "%Lg", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 2; } { /* Signalling NaN. */ static union { unsigned int word[4]; long double value; } x = { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) }; if (sprintf (buf, "%Lf", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 2; if (sprintf (buf, "%Le", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 2; if (sprintf (buf, "%Lg", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 2; } { /* Pseudo-NaN. */ static union { unsigned int word[4]; long double value; } x = { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; if (sprintf (buf, "%Lf", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 4; if (sprintf (buf, "%Le", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 4; if (sprintf (buf, "%Lg", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 4; } { /* Pseudo-Infinity. */ static union { unsigned int word[4]; long double value; } x = { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; if (sprintf (buf, "%Lf", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 8; if (sprintf (buf, "%Le", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 8; if (sprintf (buf, "%Lg", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 8; } { /* Pseudo-Zero. */ static union { unsigned int word[4]; long double value; } x = { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; if (sprintf (buf, "%Lf", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 16; if (sprintf (buf, "%Le", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 16; if (sprintf (buf, "%Lg", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 16; } { /* Unnormalized number. */ static union { unsigned int word[4]; long double value; } x = { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; if (sprintf (buf, "%Lf", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 32; if (sprintf (buf, "%Le", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 32; if (sprintf (buf, "%Lg", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 32; } { /* Pseudo-Denormal. */ static union { unsigned int word[4]; long double value; } x = { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; if (sprintf (buf, "%Lf", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 64; if (sprintf (buf, "%Le", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 64; if (sprintf (buf, "%Lg", x.value) < 0 || !strisnan (buf, 0, strlen (buf))) result |= 64; } #endif return result; }