- Timestamp:
- Feb 3, 2017, 3:11:53 PM (8 years ago)
- Location:
- cpio/trunk
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified cpio/trunk/gnu/closedir.c ¶
r1966 r1967 1 1 /* Stop reading the entries of a directory. 2 Copyright (C) 2006-201 5Free Software Foundation, Inc.2 Copyright (C) 2006-2016 Free Software Foundation, Inc. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 40 40 closedir (DIR *dirp) 41 41 { 42 # if REPLACE_FCHDIR 42 # if REPLACE_FCHDIR || REPLACE_DIRFD 43 43 int fd = dirfd (dirp); 44 44 # endif … … 50 50 retval = closedir (dirp); 51 51 52 # ifdef __KLIBC__ 53 if (!retval) 54 _gl_unregister_dirp_fd (fd); 55 # endif 52 56 #else 53 57 -
TabularUnified cpio/trunk/gnu/dirent.in.h ¶
r1966 r1967 1 1 /* A GNU-like <dirent.h>. 2 Copyright (C) 2006-201 5Free Software Foundation, Inc.2 Copyright (C) 2006-2016 Free Software Foundation, Inc. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 159 159 _GL_FUNCDECL_RPL (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1))); 160 160 _GL_CXXALIAS_RPL (dirfd, int, (DIR *)); 161 162 # ifdef __KLIBC__ 163 /* Gnulib internal hooks needed to maintain the dirfd metadata. */ 164 _GL_EXTERN_C int _gl_register_dirp_fd (int fd, DIR *dirp) 165 _GL_ARG_NONNULL ((2)); 166 _GL_EXTERN_C void _gl_unregister_dirp_fd (int fd); 167 # endif 161 168 # else 162 169 # if defined __cplusplus && defined GNULIB_NAMESPACE && defined dirfd -
TabularUnified cpio/trunk/gnu/dirfd.c ¶
r1966 r1967 1 1 /* dirfd.c -- return the file descriptor associated with an open DIR* 2 2 3 Copyright (C) 2001, 2006, 2008-201 5Free Software Foundation, Inc.3 Copyright (C) 2001, 2006, 2008-2016 Free Software Foundation, Inc. 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 23 23 #include <errno.h> 24 24 25 #ifdef __KLIBC__ 26 # include <stdlib.h> 27 # include <io.h> 28 29 static struct dirp_fd_list 30 { 31 DIR *dirp; 32 int fd; 33 struct dirp_fd_list *next; 34 } *dirp_fd_start = NULL; 35 36 /* Register fd associated with dirp to dirp_fd_list. */ 37 int 38 _gl_register_dirp_fd (int fd, DIR *dirp) 39 { 40 struct dirp_fd_list *new_dirp_fd = malloc (sizeof *new_dirp_fd); 41 if (!new_dirp_fd) 42 return -1; 43 44 new_dirp_fd->dirp = dirp; 45 new_dirp_fd->fd = fd; 46 new_dirp_fd->next = dirp_fd_start; 47 48 dirp_fd_start = new_dirp_fd; 49 50 return 0; 51 } 52 53 /* Unregister fd from dirp_fd_list with closing it */ 54 void 55 _gl_unregister_dirp_fd (int fd) 56 { 57 struct dirp_fd_list *dirp_fd; 58 struct dirp_fd_list *dirp_fd_prev; 59 60 for (dirp_fd_prev = NULL, dirp_fd = dirp_fd_start; dirp_fd; 61 dirp_fd_prev = dirp_fd, dirp_fd = dirp_fd->next) 62 { 63 if (dirp_fd->fd == fd) 64 { 65 if (dirp_fd_prev) 66 dirp_fd_prev->next = dirp_fd->next; 67 else /* dirp_fd == dirp_fd_start */ 68 dirp_fd_start = dirp_fd_start->next; 69 70 close (fd); 71 free (dirp_fd); 72 break; 73 } 74 } 75 } 76 #endif 77 25 78 int 26 79 dirfd (DIR *dir_p) … … 28 81 int fd = DIR_TO_FD (dir_p); 29 82 if (fd == -1) 83 #ifndef __KLIBC__ 30 84 errno = ENOTSUP; 85 #else 86 { 87 struct dirp_fd_list *dirp_fd; 88 89 for (dirp_fd = dirp_fd_start; dirp_fd; dirp_fd = dirp_fd->next) 90 if (dirp_fd->dirp == dir_p) 91 return dirp_fd->fd; 92 93 errno = EINVAL; 94 } 95 #endif 96 31 97 return fd; 32 98 } -
TabularUnified cpio/trunk/gnu/dup.c ¶
r1966 r1967 1 1 /* Duplicate an open file descriptor. 2 2 3 Copyright (C) 2011-201 5Free Software Foundation, Inc.3 Copyright (C) 2011-2016 Free Software Foundation, Inc. 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 46 46 return result; 47 47 } 48 #elif defined __KLIBC__ 49 # include <fcntl.h> 50 # include <sys/stat.h> 51 52 # include <InnoTekLIBC/backend.h> 53 54 static int 55 dup_nothrow (int fd) 56 { 57 int dupfd; 58 struct stat sbuf; 59 60 dupfd = dup (fd); 61 if (dupfd == -1 && errno == ENOTSUP \ 62 && !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode)) 63 { 64 char path[_MAX_PATH]; 65 66 /* Get a path from fd */ 67 if (!__libc_Back_ioFHToPath (fd, path, sizeof (path))) 68 dupfd = open (path, O_RDONLY); 69 } 70 71 return dupfd; 72 } 48 73 #else 49 74 # define dup_nothrow dup -
TabularUnified cpio/trunk/gnu/dup2.c ¶
r1966 r1967 1 1 /* Duplicate an open file descriptor to a specified file descriptor. 2 2 3 Copyright (C) 1999, 2004-2007, 2009-201 5Free Software Foundation, Inc.3 Copyright (C) 1999, 2004-2007, 2009-2016 Free Software Foundation, Inc. 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 86 86 # define dup2 ms_windows_dup2 87 87 88 # elif defined __KLIBC__ 89 90 # include <InnoTekLIBC/backend.h> 91 92 static int 93 klibc_dup2dirfd (int fd, int desired_fd) 94 { 95 int tempfd; 96 int dupfd; 97 98 tempfd = open ("NUL", O_RDONLY); 99 if (tempfd == -1) 100 return -1; 101 102 if (tempfd == desired_fd) 103 { 104 close (tempfd); 105 106 char path[_MAX_PATH]; 107 if (__libc_Back_ioFHToPath (fd, path, sizeof (path))) 108 return -1; 109 110 return open(path, O_RDONLY); 111 } 112 113 dupfd = klibc_dup2dirfd (fd, desired_fd); 114 115 close (tempfd); 116 117 return dupfd; 118 } 119 120 static int 121 klibc_dup2 (int fd, int desired_fd) 122 { 123 int dupfd; 124 struct stat sbuf; 125 126 dupfd = dup2 (fd, desired_fd); 127 if (dupfd == -1 && errno == ENOTSUP \ 128 && !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode)) 129 { 130 close (desired_fd); 131 132 return klibc_dup2dirfd (fd, desired_fd); 133 } 134 135 return dupfd; 136 } 137 138 # define dup2 klibc_dup2 88 139 # endif 89 140 -
TabularUnified cpio/trunk/gnu/fcntl.c ¶
r1966 r1967 1 1 /* Provide file descriptor control. 2 2 3 Copyright (C) 2009-201 5Free Software Foundation, Inc.3 Copyright (C) 2009-2016 Free Software Foundation, Inc. 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 162 162 } 163 163 #endif /* W32 */ 164 165 #ifdef __KLIBC__ 166 167 # define INCL_DOS 168 # include <os2.h> 169 170 static int 171 klibc_fcntl (int fd, int action, /* arg */...) 172 { 173 va_list arg_ptr; 174 int arg; 175 struct stat sbuf; 176 int result = -1; 177 178 va_start (arg_ptr, action); 179 arg = va_arg (arg_ptr, int); 180 result = fcntl (fd, action, arg); 181 /* EPERM for F_DUPFD, ENOTSUP for others */ 182 if (result == -1 && (errno == EPERM || errno == ENOTSUP) 183 && !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode)) 184 { 185 ULONG ulMode; 186 187 switch (action) 188 { 189 case F_DUPFD: 190 /* Find available fd */ 191 while (fcntl (arg, F_GETFL) != -1 || errno != EBADF) 192 arg++; 193 194 result = dup2 (fd, arg); 195 break; 196 197 /* Using underlying APIs is right ? */ 198 case F_GETFD: 199 if (DosQueryFHState (fd, &ulMode)) 200 break; 201 202 result = (ulMode & OPEN_FLAGS_NOINHERIT) ? FD_CLOEXEC : 0; 203 break; 204 205 case F_SETFD: 206 if (arg & ~FD_CLOEXEC) 207 break; 208 209 if (DosQueryFHState (fd, &ulMode)) 210 break; 211 212 if (arg & FD_CLOEXEC) 213 ulMode |= OPEN_FLAGS_NOINHERIT; 214 else 215 ulMode &= ~OPEN_FLAGS_NOINHERIT; 216 217 /* Filter supported flags. */ 218 ulMode &= (OPEN_FLAGS_WRITE_THROUGH | OPEN_FLAGS_FAIL_ON_ERROR 219 | OPEN_FLAGS_NO_CACHE | OPEN_FLAGS_NOINHERIT); 220 221 if (DosSetFHState (fd, ulMode)) 222 break; 223 224 result = 0; 225 break; 226 227 case F_GETFL: 228 result = 0; 229 break; 230 231 case F_SETFL: 232 if (arg != 0) 233 break; 234 235 result = 0; 236 break; 237 238 default : 239 errno = EINVAL; 240 break; 241 } 242 } 243 244 va_end (arg_ptr); 245 246 return result; 247 } 248 249 # define fcntl klibc_fcntl 250 #endif 164 251 165 252 /* Perform the specified ACTION on the file descriptor FD, possibly -
TabularUnified cpio/trunk/gnu/fdopendir.c ¶
r1966 r1967 1 1 /* provide a replacement fdopendir function 2 Copyright (C) 2004-201 5Free Software Foundation, Inc.2 Copyright (C) 2004-2016 Free Software Foundation, Inc. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 63 63 dirent.h system, and the caller should not close or modify the state of 64 64 FD other than by the dirent.h functions. */ 65 # ifdef __KLIBC__ 66 # include <InnoTekLIBC/backend.h> 67 68 DIR * 69 fdopendir (int fd) 70 { 71 char path[_MAX_PATH]; 72 DIR *dirp; 73 74 /* Get a path from fd */ 75 if (__libc_Back_ioFHToPath (fd, path, sizeof (path))) 76 return NULL; 77 78 dirp = opendir (path); 79 if (!dirp) 80 return NULL; 81 82 /* Unregister fd registered by opendir() */ 83 _gl_unregister_dirp_fd (dirfd (dirp)); 84 85 /* Register our fd */ 86 if (_gl_register_dirp_fd (fd, dirp)) 87 { 88 int saved_errno = errno; 89 90 closedir (dirp); 91 92 errno = saved_errno; 93 94 dirp = NULL; 95 } 96 97 return dirp; 98 } 99 # else 65 100 DIR * 66 101 fdopendir (int fd) … … 85 120 return dir; 86 121 } 122 # endif 87 123 88 124 /* Like fdopendir, except that if OLDER_DUPFD is not -1, it is known -
TabularUnified cpio/trunk/gnu/openat-proc.c ¶
r1966 r1967 1 1 /* Create /proc/self/fd-related names for subfiles of open directories. 2 2 3 Copyright (C) 2006, 2009-201 5Free Software Foundation, Inc.3 Copyright (C) 2006, 2009-2016 Free Software Foundation, Inc. 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 31 31 #include <unistd.h> 32 32 33 #ifdef __KLIBC__ 34 # include <InnoTekLIBC/backend.h> 35 #endif 36 33 37 #include "intprops.h" 34 38 35 #define PROC_SELF_FD_FORMAT "/proc/self/fd/%d/%s" 36 37 #define PROC_SELF_FD_NAME_SIZE_BOUND(len) \ 38 (sizeof PROC_SELF_FD_FORMAT - sizeof "%d%s" \ 39 + INT_STRLEN_BOUND (int) + (len) + 1) 40 41 42 /* Set BUF to the expansion of PROC_SELF_FD_FORMAT, using FD and FILE 43 respectively for %d and %s. If successful, return BUF if the 44 result fits in BUF, dynamically allocated memory otherwise. But 45 return NULL if /proc is not reliable, either because the operating 46 system support is lacking or because memory is low. */ 39 /* Set BUF to the name of the subfile of the directory identified by 40 FD, where the subfile is named FILE. If successful, return BUF if 41 the result fits in BUF, dynamically allocated memory otherwise. 42 Return NULL (setting errno) on error. */ 47 43 char * 48 44 openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file) 49 45 { 50 static int proc_status = 0; 46 char *result = buf; 47 int dirlen; 51 48 52 49 /* Make sure the caller gets ENOENT when appropriate. */ … … 57 54 } 58 55 59 if (! proc_status) 60 { 61 /* Set PROC_STATUS to a positive value if /proc/self/fd is 62 reliable, and a negative value otherwise. Solaris 10 63 /proc/self/fd mishandles "..", and any file name might expand 64 to ".." after symbolic link expansion, so avoid /proc/self/fd 65 if it mishandles "..". Solaris 10 has openat, but this 66 problem is exhibited on code that built on Solaris 8 and 67 running on Solaris 10. */ 56 #ifndef __KLIBC__ 57 # define PROC_SELF_FD_FORMAT "/proc/self/fd/%d/" 58 { 59 enum { 60 PROC_SELF_FD_DIR_SIZE_BOUND 61 = (sizeof PROC_SELF_FD_FORMAT - (sizeof "%d" - 1) 62 + INT_STRLEN_BOUND (int)) 63 }; 68 64 69 int proc_self_fd = open ("/proc/self/fd", 70 O_SEARCH | O_DIRECTORY | O_NOCTTY | O_NONBLOCK); 71 if (proc_self_fd < 0) 72 proc_status = -1; 73 else 74 { 75 /* Detect whether /proc/self/fd/%i/../fd exists, where %i is the 76 number of a file descriptor open on /proc/self/fd. On Linux, 77 that name resolves to /proc/self/fd, which was opened above. 78 However, on Solaris, it may resolve to /proc/self/fd/fd, which 79 cannot exist, since all names in /proc/self/fd are numeric. */ 80 char dotdot_buf[PROC_SELF_FD_NAME_SIZE_BOUND (sizeof "../fd" - 1)]; 81 sprintf (dotdot_buf, PROC_SELF_FD_FORMAT, proc_self_fd, "../fd"); 82 proc_status = access (dotdot_buf, F_OK) ? -1 : 1; 83 close (proc_self_fd); 84 } 85 } 65 static int proc_status = 0; 66 if (! proc_status) 67 { 68 /* Set PROC_STATUS to a positive value if /proc/self/fd is 69 reliable, and a negative value otherwise. Solaris 10 70 /proc/self/fd mishandles "..", and any file name might expand 71 to ".." after symbolic link expansion, so avoid /proc/self/fd 72 if it mishandles "..". Solaris 10 has openat, but this 73 problem is exhibited on code that built on Solaris 8 and 74 running on Solaris 10. */ 86 75 87 if (proc_status < 0) 88 return NULL; 89 else 90 { 91 size_t bufsize = PROC_SELF_FD_NAME_SIZE_BOUND (strlen (file)); 92 char *result = buf; 93 if (OPENAT_BUFFER_SIZE < bufsize) 94 { 95 result = malloc (bufsize); 96 if (! result) 97 return NULL; 98 } 99 sprintf (result, PROC_SELF_FD_FORMAT, fd, file); 100 return result; 101 } 76 int proc_self_fd = open ("/proc/self/fd", 77 O_SEARCH | O_DIRECTORY | O_NOCTTY | O_NONBLOCK); 78 if (proc_self_fd < 0) 79 proc_status = -1; 80 else 81 { 82 /* Detect whether /proc/self/fd/%i/../fd exists, where %i is the 83 number of a file descriptor open on /proc/self/fd. On Linux, 84 that name resolves to /proc/self/fd, which was opened above. 85 However, on Solaris, it may resolve to /proc/self/fd/fd, which 86 cannot exist, since all names in /proc/self/fd are numeric. */ 87 char dotdot_buf[PROC_SELF_FD_DIR_SIZE_BOUND + sizeof "../fd" - 1]; 88 sprintf (dotdot_buf, PROC_SELF_FD_FORMAT "../fd", proc_self_fd); 89 proc_status = access (dotdot_buf, F_OK) ? -1 : 1; 90 close (proc_self_fd); 91 } 92 } 93 94 if (proc_status < 0) 95 return NULL; 96 else 97 { 98 size_t bufsize = PROC_SELF_FD_DIR_SIZE_BOUND + strlen (file); 99 if (OPENAT_BUFFER_SIZE < bufsize) 100 { 101 result = malloc (bufsize); 102 if (! result) 103 return NULL; 104 } 105 106 dirlen = sprintf (result, PROC_SELF_FD_FORMAT, fd); 107 } 108 } 109 #else 110 /* OS/2 kLIBC provides a function to retrieve a path from a fd. */ 111 { 112 char dir[_MAX_PATH]; 113 size_t bufsize; 114 115 if (__libc_Back_ioFHToPath (fd, dir, sizeof dir)) 116 return NULL; 117 118 dirlen = strlen (dir); 119 bufsize = dirlen + 1 + strlen (file) + 1; /* 1 for '/', 1 for null */ 120 if (OPENAT_BUFFER_SIZE < bufsize) 121 { 122 result = malloc (bufsize); 123 if (! result) 124 return NULL; 125 } 126 127 strcpy (result, dir); 128 result[dirlen++] = '/'; 129 } 130 #endif 131 132 strcpy (result + dirlen, file); 133 return result; 102 134 } -
TabularUnified cpio/trunk/gnu/opendir.c ¶
r1966 r1967 1 1 /* Start reading the entries of a directory. 2 Copyright (C) 2006-201 5Free Software Foundation, Inc.2 Copyright (C) 2006-2016 Free Software Foundation, Inc. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 41 41 #endif 42 42 43 #ifdef __KLIBC__ 44 # include <io.h> 45 # include <fcntl.h> 46 #endif 47 43 48 DIR * 44 49 opendir (const char *dir_name) … … 52 57 return NULL; 53 58 59 # ifdef __KLIBC__ 60 { 61 int fd = open (dir_name, O_RDONLY); 62 if (fd == -1 || _gl_register_dirp_fd (fd, dirp)) 63 { 64 int saved_errno = errno; 65 66 close (fd); 67 closedir (dirp); 68 69 errno = saved_errno; 70 71 return NULL; 72 } 73 } 74 # endif 54 75 #else 55 76 -
TabularUnified cpio/trunk/gnu/wchar.in.h ¶
r1966 r1967 1 1 /* A substitute for ISO C99 <wchar.h>, for platforms that have issues. 2 2 3 Copyright (C) 2007-201 5Free Software Foundation, Inc.3 Copyright (C) 2007-2016 Free Software Foundation, Inc. 4 4 5 5 This program is free software; you can redistribute it and/or modify … … 32 32 33 33 #if (((defined __need_mbstate_t || defined __need_wint_t) \ 34 && !defined __MINGW32__ )\34 && !defined __MINGW32__ && !defined __KLIBC__) \ 35 35 || (defined __hpux \ 36 36 && ((defined _INTTYPES_INCLUDED && !defined strtoimax) \ 37 37 || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \ 38 || (defined __MINGW32__ && defined __STRING_H_SOURCED__) \ 38 39 || defined _GL_ALREADY_INCLUDING_WCHAR_H) 39 40 /* Special invocation convention: … … 45 46 therefore we cannot provide the function overrides; instead include only 46 47 the system's <wchar.h>. 48 - With MinGW 3.22, when <string.h> includes <wchar.h>, only some part of 49 <wchar.h> is actually processed, and that doesn't include 'mbstate_t'. 47 50 - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and 48 51 the latter includes <wchar.h>. But here, we have no way to detect whether … … 446 449 /* wcwidth exists but is not declared. */ 447 450 _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE); 451 # elif defined __KLIBC__ 452 /* On OS/2 kLIBC, wcwidth is a macro that expands to the name of a 453 static inline function. The implementation of wcwidth in wcwidth.c 454 causes a "conflicting types" error. */ 455 # undef wcwidth 448 456 # endif 449 457 _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t)); -
TabularUnified cpio/trunk/m4/closedir.m4 ¶
r1966 r1967 1 # closedir.m4 serial 22 dnl Copyright (C) 2011-201 5Free Software Foundation, Inc.1 # closedir.m4 serial 5 2 dnl Copyright (C) 2011-2016 Free Software Foundation, Inc. 3 3 dnl This file is free software; the Free Software Foundation 4 4 dnl gives unlimited permission to copy and/or distribute it, … … 23 23 fi 24 24 ]) 25 dnl Replace closedir() for supporting the gnulib-defined dirfd() function. 26 case $host_os,$HAVE_CLOSEDIR in 27 os2*,1) 28 REPLACE_CLOSEDIR=1;; 29 esac 25 30 ]) -
TabularUnified cpio/trunk/m4/dirfd.m4 ¶
r1966 r1967 1 # serial 2 2-*- Autoconf -*-1 # serial 24 -*- Autoconf -*- 2 2 3 3 dnl Find out how to get the file descriptor associated with an open DIR*. 4 4 5 # Copyright (C) 2001-2006, 2008-201 5Free Software Foundation, Inc.5 # Copyright (C) 2001-2006, 2008-2016 Free Software Foundation, Inc. 6 6 # This file is free software; the Free Software Foundation 7 7 # gives unlimited permission to copy and/or distribute it, … … 36 36 gl_cv_func_dirfd_macro=no)]) 37 37 38 # Use the replacement only if we have no function or macro with that name. 39 if test $ac_cv_func_dirfd = no && test $gl_cv_func_dirfd_macro = no; then 40 if test $ac_cv_have_decl_dirfd = yes; then 41 # If the system declares dirfd already, let's declare rpl_dirfd instead. 38 # Use the replacement if we have no function or macro with that name, 39 # or if OS/2 kLIBC whose dirfd() does not work. 40 # Replace only if the system declares dirfd already. 41 case $ac_cv_func_dirfd,$gl_cv_func_dirfd_macro,$host_os,$ac_cv_have_decl_dirfd in 42 no,no,*,yes | *,*,os2*,yes) 42 43 REPLACE_DIRFD=1 43 fi 44 fi 44 AC_DEFINE([REPLACE_DIRFD], [1], 45 [Define to 1 if gnulib's dirfd() replacement is used.]);; 46 esac 45 47 ]) 46 48 -
TabularUnified cpio/trunk/m4/dup.m4 ¶
r1966 r1967 1 # dup.m4 serial 32 dnl Copyright (C) 2011-201 5Free Software Foundation, Inc.1 # dup.m4 serial 4 2 dnl Copyright (C) 2011-2016 Free Software Foundation, Inc. 3 3 dnl This file is free software; the Free Software Foundation 4 4 dnl gives unlimited permission to copy and/or distribute it, … … 20 20 fi 21 21 ]) 22 AC_CACHE_CHECK([whether dup works], [gl_cv_func_dup_works], 23 [AC_RUN_IFELSE( 24 [AC_LANG_PROGRAM([[#include <unistd.h> 25 #include <fcntl.h> 26 #include <errno.h>]], 27 [[/* On OS/2 kLIBC, dup does not work on a directory fd. */ 28 int fd = open (".", O_RDONLY); 29 return fd < 0 ? 1 : dup (fd) < 0 ? 2 : 0; 30 ]]) 31 ], 32 [gl_cv_func_dup_works=yes], 33 [gl_cv_func_dup_works=no], 34 [gl_cv_func_dup_works='guessing yes']) 35 ]) 36 case "$gl_cv_func_dup_works" in 37 *yes) ;; 38 *) 39 REPLACE_DUP=1 40 ;; 41 esac 22 42 ]) 23 43 -
TabularUnified cpio/trunk/m4/dup2.m4 ¶
r1966 r1967 1 #serial 2 42 dnl Copyright (C) 2002, 2005, 2007, 2009-201 5Free Software Foundation, Inc.1 #serial 25 2 dnl Copyright (C) 2002, 2005, 2007, 2009-2016 Free Software Foundation, Inc. 3 3 dnl This file is free software; the Free Software Foundation 4 4 dnl gives unlimited permission to copy and/or distribute it, … … 63 63 dup2 (2, 255); 64 64 dup2 (2, 256); 65 /* On OS/2 kLIBC, dup2() does not work on a directory fd. */ 66 { 67 int fd = open (".", O_RDONLY); 68 if (fd == -1) 69 result |= 64; 70 else if (dup2 (fd, fd + 1) == -1) 71 result |= 128; 72 73 close (fd); 74 } 65 75 return result;]]) 66 76 ], … … 78 88 gl_cv_func_dup2_works="guessing no" ;; 79 89 *-android*) # implemented using dup3(), which fails if oldfd == newfd 90 gl_cv_func_dup2_works="guessing no" ;; 91 os2*) # on OS/2 kLIBC, dup2() does not work on a directory fd. 80 92 gl_cv_func_dup2_works="guessing no" ;; 81 93 *) gl_cv_func_dup2_works="guessing yes" ;; -
TabularUnified cpio/trunk/m4/extern-inline.m4 ¶
r1966 r1967 1 1 dnl 'extern inline' a la ISO C99. 2 2 3 dnl Copyright 2012-201 5Free Software Foundation, Inc.3 dnl Copyright 2012-2014 Free Software Foundation, Inc. 4 4 dnl This file is free software; the Free Software Foundation 5 5 dnl gives unlimited permission to copy and/or distribute it, … … 20 20 This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16. 21 21 22 Suppress extern inline (with or without __attribute__ ((__gnu_inline__))) 23 on configurations that mistakenly use 'static inline' to implement 24 functions or macros in standard C headers like <ctype.h>. For example, 25 if isdigit is mistakenly implemented via a static inline function, 26 a program containing an extern inline function that calls isdigit 27 may not work since the C standard prohibits extern inline functions 28 from calling static functions. This bug is known to occur on: 29 30 OS X 10.8 and earlier; see: 31 http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html 32 33 DragonFly; see 34 http://muscles.dragonflybsd.org/bulk/bleeding-edge-potential/latest-per-pkg/ah-tty-0.3.12.log 35 36 FreeBSD; see: 37 http://lists.gnu.org/archive/html/bug-gnulib/2014-07/msg00104.html 38 22 Suppress the use of extern inline on problematic Apple configurations. 23 OS X 10.8 and earlier mishandle it; see, e.g., 24 <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>. 39 25 OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and 40 26 for clang but remains for g++; see <http://trac.macports.org/ticket/41033>. 41 Assume DragonFly and FreeBSD will be similar. */ 42 #if (((defined __APPLE__ && defined __MACH__) \ 43 || defined __DragonFly__ || defined __FreeBSD__) \ 27 Perhaps Apple will fix this some day. */ 28 #if (defined __APPLE__ \ 44 29 && (defined __header_inline \ 45 30 ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \ … … 49 34 || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \ 50 35 && defined __GNUC__ && ! defined __cplusplus)))) 51 # define _GL_EXTERN_INLINE_ STDHEADER_BUG36 # define _GL_EXTERN_INLINE_APPLE_BUG 52 37 #endif 53 38 #if ((__GNUC__ \ … … 56 41 && !defined __HP_cc \ 57 42 && !(defined __SUNPRO_C && __STDC__))) \ 58 && !defined _GL_EXTERN_INLINE_ STDHEADER_BUG)43 && !defined _GL_EXTERN_INLINE_APPLE_BUG) 59 44 # define _GL_INLINE inline 60 45 # define _GL_EXTERN_INLINE extern inline 61 46 # define _GL_EXTERN_INLINE_IN_USE 62 47 #elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \ 63 && !defined _GL_EXTERN_INLINE_ STDHEADER_BUG)48 && !defined _GL_EXTERN_INLINE_APPLE_BUG) 64 49 # if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__ 65 50 /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */ … … 75 60 #endif 76 61 77 /* In GCC 4.6 (inclusive) to 5.1 (exclusive), 78 suppress bogus "no previous prototype for 'FOO'" 79 and "no previous declaration for 'FOO'" diagnostics, 80 when FOO is an inline function in the header; see 81 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113> and 82 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63877>. */ 83 #if __GNUC__ == 4 && 6 <= __GNUC_MINOR__ 62 #if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) 84 63 # if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ 85 64 # define _GL_INLINE_HEADER_CONST_PRAGMA … … 88 67 _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") 89 68 # endif 69 /* Suppress GCC's bogus "no previous prototype for 'FOO'" 70 and "no previous declaration for 'FOO'" diagnostics, 71 when FOO is an inline function in the header; see 72 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>. */ 90 73 # define _GL_INLINE_HEADER_BEGIN \ 91 74 _Pragma ("GCC diagnostic push") \ -
TabularUnified cpio/trunk/m4/fcntl.m4 ¶
r1966 r1967 1 # fcntl.m4 serial 82 dnl Copyright (C) 2009-201 5Free Software Foundation, Inc.1 # fcntl.m4 serial 9 2 dnl Copyright (C) 2009-2016 Free Software Foundation, Inc. 3 3 dnl This file is free software; the Free Software Foundation 4 4 dnl gives unlimited permission to copy and/or distribute it, … … 55 55 if (fcntl (0, F_DUPFD, bad_fd) != -1) result |= 4; 56 56 if (errno != EINVAL) result |= 8; 57 /* On OS/2 kLIBC, F_DUPFD does not work on a directory fd */ 58 { 59 int fd; 60 fd = open (".", O_RDONLY); 61 if (fd == -1) 62 result |= 16; 63 else if (fcntl (fd, F_DUPFD, STDERR_FILENO + 1) == -1) 64 result |= 32; 65 66 close (fd); 67 } 57 68 return result;]])], 58 69 [gl_cv_func_fcntl_f_dupfd_works=yes], -
TabularUnified cpio/trunk/m4/opendir.m4 ¶
r1966 r1967 1 # opendir.m4 serial 22 dnl Copyright (C) 2011-201 5Free Software Foundation, Inc.1 # opendir.m4 serial 4 2 dnl Copyright (C) 2011-2016 Free Software Foundation, Inc. 3 3 dnl This file is free software; the Free Software Foundation 4 4 dnl gives unlimited permission to copy and/or distribute it, … … 23 23 fi 24 24 ]) 25 dnl Replace opendir() on OS/2 kLIBC to support dirfd() function replaced 26 dnl by gnulib. 27 case $host_os,$HAVE_OPENDIR in 28 os2*,1) 29 REPLACE_OPENDIR=1;; 30 esac 25 31 ]) -
TabularUnified cpio/trunk/m4/utimes.m4 ¶
r1966 r1967 1 1 # Detect some bugs in glibc's implementation of utimes. 2 # serial 32 # serial 4 3 3 4 dnl Copyright (C) 2003-2005, 2009-201 5Free Software Foundation, Inc.4 dnl Copyright (C) 2003-2005, 2009-2016 Free Software Foundation, Inc. 5 5 dnl This file is free software; the Free Software Foundation 6 6 dnl gives unlimited permission to copy and/or distribute it, … … 34 34 #include <stdio.h> 35 35 #include <utime.h> 36 #include <errno.h> 36 37 37 38 static int … … 86 87 else if (fstat (fd, &st0) != 0) 87 88 result |= 1; 88 else if (utimes (file, timeval) != 0) 89 else if (utimes (file, timeval) != 0 90 && (errno != EACCES 91 /* OS/2 kLIBC utimes fails on opened files. */ 92 || close (fd) != 0 93 || utimes (file, timeval) != 0 94 || (fd = open (file, O_WRONLY)) < 0)) 89 95 result |= 2; 90 else if (utimes (file, NULL) != 0) 96 else if (utimes (file, NULL) != 0 97 && (errno != EACCES 98 /* OS/2 kLIBC utimes fails on opened files. */ 99 || close (fd) != 0 100 || utimes (file, NULL) != 0 101 || (fd = open (file, O_WRONLY)) < 0)) 91 102 result |= 8; 92 103 else if (fstat (fd, &st1) != 0) … … 135 146 136 147 if test $gl_cv_func_working_utimes = yes; then 137 AC_DEFINE([HAVE_WORKING_UTIMES], [1], [Define if utimes works properly. 148 AC_DEFINE([HAVE_WORKING_UTIMES], [1], [Define if utimes works properly.]) 138 149 fi 139 150 ])
Note:
See TracChangeset
for help on using the changeset viewer.