Changeset 1967 for cpio


Ignore:
Timestamp:
Feb 3, 2017, 3:11:53 PM (8 years ago)
Author:
Silvan Scherrer
Message:

cpio: update several gnulib tools to latest gnulib

Location:
cpio/trunk
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified cpio/trunk/gnu/closedir.c

    r1966 r1967  
    11/* Stop reading the entries of a directory.
    2    Copyright (C) 2006-2015 Free Software Foundation, Inc.
     2   Copyright (C) 2006-2016 Free Software Foundation, Inc.
    33
    44   This program is free software: you can redistribute it and/or modify
     
    4040closedir (DIR *dirp)
    4141{
    42 # if REPLACE_FCHDIR
     42# if REPLACE_FCHDIR || REPLACE_DIRFD
    4343  int fd = dirfd (dirp);
    4444# endif
     
    5050  retval = closedir (dirp);
    5151
     52# ifdef __KLIBC__
     53  if (!retval)
     54    _gl_unregister_dirp_fd (fd);
     55# endif
    5256#else
    5357
  • TabularUnified cpio/trunk/gnu/dirent.in.h

    r1966 r1967  
    11/* A GNU-like <dirent.h>.
    2    Copyright (C) 2006-2015 Free Software Foundation, Inc.
     2   Copyright (C) 2006-2016 Free Software Foundation, Inc.
    33
    44   This program is free software: you can redistribute it and/or modify
     
    159159_GL_FUNCDECL_RPL (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
    160160_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
    161168# else
    162169#  if defined __cplusplus && defined GNULIB_NAMESPACE && defined dirfd
  • TabularUnified cpio/trunk/gnu/dirfd.c

    r1966 r1967  
    11/* dirfd.c -- return the file descriptor associated with an open DIR*
    22
    3    Copyright (C) 2001, 2006, 2008-2015 Free Software Foundation, Inc.
     3   Copyright (C) 2001, 2006, 2008-2016 Free Software Foundation, Inc.
    44
    55   This program is free software: you can redistribute it and/or modify
     
    2323#include <errno.h>
    2424
     25#ifdef __KLIBC__
     26# include <stdlib.h>
     27# include <io.h>
     28
     29static 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. */
     37int
     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 */
     54void
     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
    2578int
    2679dirfd (DIR *dir_p)
     
    2881  int fd = DIR_TO_FD (dir_p);
    2982  if (fd == -1)
     83#ifndef __KLIBC__
    3084    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
    3197  return fd;
    3298}
  • TabularUnified cpio/trunk/gnu/dup.c

    r1966 r1967  
    11/* Duplicate an open file descriptor.
    22
    3    Copyright (C) 2011-2015 Free Software Foundation, Inc.
     3   Copyright (C) 2011-2016 Free Software Foundation, Inc.
    44
    55   This program is free software: you can redistribute it and/or modify
     
    4646  return result;
    4747}
     48#elif defined __KLIBC__
     49# include <fcntl.h>
     50# include <sys/stat.h>
     51
     52# include <InnoTekLIBC/backend.h>
     53
     54static int
     55dup_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}
    4873#else
    4974# define dup_nothrow dup
  • TabularUnified cpio/trunk/gnu/dup2.c

    r1966 r1967  
    11/* Duplicate an open file descriptor to a specified file descriptor.
    22
    3    Copyright (C) 1999, 2004-2007, 2009-2015 Free Software Foundation, Inc.
     3   Copyright (C) 1999, 2004-2007, 2009-2016 Free Software Foundation, Inc.
    44
    55   This program is free software: you can redistribute it and/or modify
     
    8686#  define dup2 ms_windows_dup2
    8787
     88# elif defined __KLIBC__
     89
     90#  include <InnoTekLIBC/backend.h>
     91
     92static int
     93klibc_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
     120static int
     121klibc_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
    88139# endif
    89140
  • TabularUnified cpio/trunk/gnu/fcntl.c

    r1966 r1967  
    11/* Provide file descriptor control.
    22
    3    Copyright (C) 2009-2015 Free Software Foundation, Inc.
     3   Copyright (C) 2009-2016 Free Software Foundation, Inc.
    44
    55   This program is free software: you can redistribute it and/or modify
     
    162162}
    163163#endif /* W32 */
     164
     165#ifdef __KLIBC__
     166
     167# define INCL_DOS
     168# include <os2.h>
     169
     170static int
     171klibc_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
    164251
    165252/* Perform the specified ACTION on the file descriptor FD, possibly
  • TabularUnified cpio/trunk/gnu/fdopendir.c

    r1966 r1967  
    11/* provide a replacement fdopendir function
    2    Copyright (C) 2004-2015 Free Software Foundation, Inc.
     2   Copyright (C) 2004-2016 Free Software Foundation, Inc.
    33
    44   This program is free software: you can redistribute it and/or modify
     
    6363   dirent.h system, and the caller should not close or modify the state of
    6464   FD other than by the dirent.h functions.  */
     65# ifdef __KLIBC__
     66#  include <InnoTekLIBC/backend.h>
     67
     68DIR *
     69fdopendir (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
    65100DIR *
    66101fdopendir (int fd)
     
    85120  return dir;
    86121}
     122# endif
    87123
    88124/* Like fdopendir, except that if OLDER_DUPFD is not -1, it is known
  • TabularUnified cpio/trunk/gnu/openat-proc.c

    r1966 r1967  
    11/* Create /proc/self/fd-related names for subfiles of open directories.
    22
    3    Copyright (C) 2006, 2009-2015 Free Software Foundation, Inc.
     3   Copyright (C) 2006, 2009-2016 Free Software Foundation, Inc.
    44
    55   This program is free software: you can redistribute it and/or modify
     
    3131#include <unistd.h>
    3232
     33#ifdef __KLIBC__
     34# include <InnoTekLIBC/backend.h>
     35#endif
     36
    3337#include "intprops.h"
    3438
    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.  */
    4743char *
    4844openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file)
    4945{
    50   static int proc_status = 0;
     46  char *result = buf;
     47  int dirlen;
    5148
    5249  /* Make sure the caller gets ENOENT when appropriate.  */
     
    5754    }
    5855
    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    };
    6864
    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.  */
    8675
    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;
    102134}
  • TabularUnified cpio/trunk/gnu/opendir.c

    r1966 r1967  
    11/* Start reading the entries of a directory.
    2    Copyright (C) 2006-2015 Free Software Foundation, Inc.
     2   Copyright (C) 2006-2016 Free Software Foundation, Inc.
    33
    44   This program is free software: you can redistribute it and/or modify
     
    4141#endif
    4242
     43#ifdef __KLIBC__
     44# include <io.h>
     45# include <fcntl.h>
     46#endif
     47
    4348DIR *
    4449opendir (const char *dir_name)
     
    5257    return NULL;
    5358
     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
    5475#else
    5576
  • TabularUnified cpio/trunk/gnu/wchar.in.h

    r1966 r1967  
    11/* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
    22
    3    Copyright (C) 2007-2015 Free Software Foundation, Inc.
     3   Copyright (C) 2007-2016 Free Software Foundation, Inc.
    44
    55   This program is free software; you can redistribute it and/or modify
     
    3232
    3333#if (((defined __need_mbstate_t || defined __need_wint_t)               \
    34       && !defined __MINGW32__)                                          \
     34      && !defined __MINGW32__ && !defined __KLIBC__)                    \
    3535     || (defined __hpux                                                 \
    3636         && ((defined _INTTYPES_INCLUDED && !defined strtoimax)         \
    3737             || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H))               \
     38     || (defined __MINGW32__ && defined __STRING_H_SOURCED__)           \
    3839     || defined _GL_ALREADY_INCLUDING_WCHAR_H)
    3940/* Special invocation convention:
     
    4546     therefore we cannot provide the function overrides; instead include only
    4647     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'.
    4750   - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
    4851     the latter includes <wchar.h>.  But here, we have no way to detect whether
     
    446449/* wcwidth exists but is not declared.  */
    447450_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
    448456#  endif
    449457_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
  • TabularUnified cpio/trunk/m4/closedir.m4

    r1966 r1967  
    1 # closedir.m4 serial 2
    2 dnl Copyright (C) 2011-2015 Free Software Foundation, Inc.
     1# closedir.m4 serial 5
     2dnl Copyright (C) 2011-2016 Free Software Foundation, Inc.
    33dnl This file is free software; the Free Software Foundation
    44dnl gives unlimited permission to copy and/or distribute it,
     
    2323    fi
    2424  ])
     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
    2530])
  • TabularUnified cpio/trunk/m4/dirfd.m4

    r1966 r1967  
    1 # serial 22   -*- Autoconf -*-
     1# serial 24   -*- Autoconf -*-
    22
    33dnl Find out how to get the file descriptor associated with an open DIR*.
    44
    5 # Copyright (C) 2001-2006, 2008-2015 Free Software Foundation, Inc.
     5# Copyright (C) 2001-2006, 2008-2016 Free Software Foundation, Inc.
    66# This file is free software; the Free Software Foundation
    77# gives unlimited permission to copy and/or distribute it,
     
    3636       gl_cv_func_dirfd_macro=no)])
    3737
    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)
    4243      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
    4547])
    4648
  • TabularUnified cpio/trunk/m4/dup.m4

    r1966 r1967  
    1 # dup.m4 serial 3
    2 dnl Copyright (C) 2011-2015 Free Software Foundation, Inc.
     1# dup.m4 serial 4
     2dnl Copyright (C) 2011-2016 Free Software Foundation, Inc.
    33dnl This file is free software; the Free Software Foundation
    44dnl gives unlimited permission to copy and/or distribute it,
     
    2020    fi
    2121  ])
     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
    2242])
    2343
  • TabularUnified cpio/trunk/m4/dup2.m4

    r1966 r1967  
    1 #serial 24
    2 dnl Copyright (C) 2002, 2005, 2007, 2009-2015 Free Software Foundation, Inc.
     1#serial 25
     2dnl Copyright (C) 2002, 2005, 2007, 2009-2016 Free Software Foundation, Inc.
    33dnl This file is free software; the Free Software Foundation
    44dnl gives unlimited permission to copy and/or distribute it,
     
    6363             dup2 (2, 255);
    6464             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             }
    6575             return result;]])
    6676        ],
     
    7888             gl_cv_func_dup2_works="guessing no" ;;
    7989           *-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.
    8092             gl_cv_func_dup2_works="guessing no" ;;
    8193           *) gl_cv_func_dup2_works="guessing yes" ;;
  • TabularUnified cpio/trunk/m4/extern-inline.m4

    r1966 r1967  
    11dnl 'extern inline' a la ISO C99.
    22
    3 dnl Copyright 2012-2015 Free Software Foundation, Inc.
     3dnl Copyright 2012-2014 Free Software Foundation, Inc.
    44dnl This file is free software; the Free Software Foundation
    55dnl gives unlimited permission to copy and/or distribute it,
     
    2020   This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16.
    2121
    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>.
    3925   OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and
    4026   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__ \
    4429     && (defined __header_inline \
    4530         ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \
     
    4934            || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
    5035                && defined __GNUC__ && ! defined __cplusplus))))
    51 # define _GL_EXTERN_INLINE_STDHEADER_BUG
     36# define _GL_EXTERN_INLINE_APPLE_BUG
    5237#endif
    5338#if ((__GNUC__ \
     
    5641         && !defined __HP_cc \
    5742         && !(defined __SUNPRO_C && __STDC__))) \
    58      && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
     43     && !defined _GL_EXTERN_INLINE_APPLE_BUG)
    5944# define _GL_INLINE inline
    6045# define _GL_EXTERN_INLINE extern inline
    6146# define _GL_EXTERN_INLINE_IN_USE
    6247#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \
    63        && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
     48       && !defined _GL_EXTERN_INLINE_APPLE_BUG)
    6449# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__
    6550   /* __gnu_inline__ suppresses a GCC 4.2 diagnostic.  */
     
    7560#endif
    7661
    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__)
    8463# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__
    8564#  define _GL_INLINE_HEADER_CONST_PRAGMA
     
    8867     _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"")
    8968# 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>.  */
    9073# define _GL_INLINE_HEADER_BEGIN \
    9174    _Pragma ("GCC diagnostic push") \
  • TabularUnified cpio/trunk/m4/fcntl.m4

    r1966 r1967  
    1 # fcntl.m4 serial 8
    2 dnl Copyright (C) 2009-2015 Free Software Foundation, Inc.
     1# fcntl.m4 serial 9
     2dnl Copyright (C) 2009-2016 Free Software Foundation, Inc.
    33dnl This file is free software; the Free Software Foundation
    44dnl gives unlimited permission to copy and/or distribute it,
     
    5555              if (fcntl (0, F_DUPFD, bad_fd) != -1) result |= 4;
    5656              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              }
    5768              return result;]])],
    5869         [gl_cv_func_fcntl_f_dupfd_works=yes],
  • TabularUnified cpio/trunk/m4/opendir.m4

    r1966 r1967  
    1 # opendir.m4 serial 2
    2 dnl Copyright (C) 2011-2015 Free Software Foundation, Inc.
     1# opendir.m4 serial 4
     2dnl Copyright (C) 2011-2016 Free Software Foundation, Inc.
    33dnl This file is free software; the Free Software Foundation
    44dnl gives unlimited permission to copy and/or distribute it,
     
    2323    fi
    2424  ])
     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
    2531])
  • TabularUnified cpio/trunk/m4/utimes.m4

    r1966 r1967  
    11# Detect some bugs in glibc's implementation of utimes.
    2 # serial 3
     2# serial 4
    33
    4 dnl Copyright (C) 2003-2005, 2009-2015 Free Software Foundation, Inc.
     4dnl Copyright (C) 2003-2005, 2009-2016 Free Software Foundation, Inc.
    55dnl This file is free software; the Free Software Foundation
    66dnl gives unlimited permission to copy and/or distribute it,
     
    3434#include <stdio.h>
    3535#include <utime.h>
     36#include <errno.h>
    3637
    3738static int
     
    8687        else if (fstat (fd, &st0) != 0)
    8788          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))
    8995          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))
    91102          result |= 8;
    92103        else if (fstat (fd, &st1) != 0)
     
    135146
    136147  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.])
    138149  fi
    139150])
Note: See TracChangeset for help on using the changeset viewer.