(root)/
tar-1.35/
gnu/
sys_time.in.h
       1  /* Provide a more complete sys/time.h.
       2  
       3     Copyright (C) 2007-2023 Free Software Foundation, Inc.
       4  
       5     This file is free software: you can redistribute it and/or modify
       6     it under the terms of the GNU Lesser General Public License as
       7     published by the Free Software Foundation; either version 2.1 of the
       8     License, or (at your option) any later version.
       9  
      10     This file is distributed in the hope that it will be useful,
      11     but WITHOUT ANY WARRANTY; without even the implied warranty of
      12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      13     GNU Lesser General Public License for more details.
      14  
      15     You should have received a copy of the GNU Lesser General Public License
      16     along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
      17  
      18  /* Written by Paul Eggert.  */
      19  
      20  #ifndef _@GUARD_PREFIX@_SYS_TIME_H
      21  
      22  #if __GNUC__ >= 3
      23  @PRAGMA_SYSTEM_HEADER@
      24  #endif
      25  @PRAGMA_COLUMNS@
      26  
      27  /* This file uses #include_next of a system file that defines time_t.
      28     For the 'year2038' module to work right, <config.h> needs to have been
      29     included before.  */
      30  #if !_GL_CONFIG_H_INCLUDED
      31   #error "Please include config.h first."
      32  #endif
      33  
      34  /* On Cygwin and on many BSDish systems, <sys/time.h> includes itself
      35     recursively via <sys/select.h>.
      36     Simply delegate to the system's header in this case; it is a no-op.
      37     Without this extra ifdef, the C++ gettimeofday declaration below
      38     would be a forward declaration in gnulib's nested <sys/time.h>.  */
      39  #if defined _CYGWIN_SYS_TIME_H || defined _SYS_TIME_H || defined _SYS_TIME_H_
      40  # @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
      41  #else
      42  
      43  /* The include_next requires a split double-inclusion guard.  */
      44  #if @HAVE_SYS_TIME_H@
      45  # @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
      46  #endif
      47  
      48  #ifndef _@GUARD_PREFIX@_SYS_TIME_H
      49  #define _@GUARD_PREFIX@_SYS_TIME_H
      50  
      51  /* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*.  */
      52  #if !_GL_CONFIG_H_INCLUDED
      53   #error "Please include config.h first."
      54  #endif
      55  
      56  #if ! @HAVE_SYS_TIME_H@
      57  # include <time.h>
      58  #endif
      59  
      60  /* On native Windows with MSVC, get the 'struct timeval' type.
      61     Also, on native Windows with a 64-bit time_t, where we are overriding the
      62     'struct timeval' type, get all declarations of system functions whose
      63     signature contains 'struct timeval'.  */
      64  #if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H
      65  # define _GL_INCLUDING_WINSOCK2_H
      66  # include <winsock2.h>
      67  # undef _GL_INCLUDING_WINSOCK2_H
      68  #endif
      69  
      70  /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
      71  
      72  /* The definition of _GL_ARG_NONNULL is copied here.  */
      73  
      74  /* The definition of _GL_WARN_ON_USE is copied here.  */
      75  
      76  #ifdef __cplusplus
      77  extern "C" {
      78  #endif
      79  
      80  #if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@
      81  
      82  # if @REPLACE_STRUCT_TIMEVAL@
      83  #  define timeval rpl_timeval
      84  # endif
      85  
      86  # if !GNULIB_defined_struct_timeval
      87  struct timeval
      88  {
      89    time_t tv_sec;
      90    long int tv_usec;
      91  };
      92  #  define GNULIB_defined_struct_timeval 1
      93  # endif
      94  
      95  #endif
      96  
      97  #ifdef __cplusplus
      98  }
      99  #endif
     100  
     101  #if @GNULIB_GETTIMEOFDAY@
     102  # if @REPLACE_GETTIMEOFDAY@
     103  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     104  #   undef gettimeofday
     105  #   define gettimeofday rpl_gettimeofday
     106  #  endif
     107  _GL_FUNCDECL_RPL (gettimeofday, int,
     108                    (struct timeval *restrict, void *restrict)
     109                    _GL_ARG_NONNULL ((1)));
     110  _GL_CXXALIAS_RPL (gettimeofday, int,
     111                    (struct timeval *restrict, void *restrict));
     112  # else
     113  #  if !@HAVE_GETTIMEOFDAY@
     114  _GL_FUNCDECL_SYS (gettimeofday, int,
     115                    (struct timeval *restrict, void *restrict)
     116                    _GL_ARG_NONNULL ((1)));
     117  #  endif
     118  /* Need to cast, because on glibc systems, by default, the second argument is
     119                                                    struct timezone *.  */
     120  _GL_CXXALIAS_SYS_CAST (gettimeofday, int,
     121                         (struct timeval *restrict, void *restrict));
     122  # endif
     123  _GL_CXXALIASWARN (gettimeofday);
     124  # if defined __cplusplus && defined GNULIB_NAMESPACE
     125  namespace GNULIB_NAMESPACE {
     126    typedef ::timeval
     127  #  undef timeval
     128      timeval;
     129  #  if @REPLACE_STRUCT_TIMEVAL@
     130  #   define timeval rpl_timeval
     131    typedef ::timeval timeval;
     132  #  endif
     133  }
     134  # endif
     135  #elif defined GNULIB_POSIXCHECK
     136  # undef gettimeofday
     137  # if HAVE_RAW_DECL_GETTIMEOFDAY
     138  _GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - "
     139                   "use gnulib module gettimeofday for portability");
     140  # endif
     141  #endif
     142  
     143  /* Hide some function declarations from <winsock2.h>.  */
     144  
     145  #if defined _MSC_VER && @HAVE_WINSOCK2_H@
     146  # if !defined _@GUARD_PREFIX@_UNISTD_H
     147  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     148  #   undef close
     149  #   define close close_used_without_including_unistd_h
     150  #  elif !defined __clang__
     151       _GL_WARN_ON_USE (close,
     152                        "close() used without including <unistd.h>");
     153  #  endif
     154  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     155  #   undef gethostname
     156  #   define gethostname gethostname_used_without_including_unistd_h
     157  #  else
     158       _GL_WARN_ON_USE (gethostname,
     159                        "gethostname() used without including <unistd.h>");
     160  #  endif
     161  # endif
     162  # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
     163  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     164  #   undef socket
     165  #   define socket              socket_used_without_including_sys_socket_h
     166  #   undef connect
     167  #   define connect             connect_used_without_including_sys_socket_h
     168  #   undef accept
     169  #   define accept              accept_used_without_including_sys_socket_h
     170  #   undef bind
     171  #   define bind                bind_used_without_including_sys_socket_h
     172  #   undef getpeername
     173  #   define getpeername         getpeername_used_without_including_sys_socket_h
     174  #   undef getsockname
     175  #   define getsockname         getsockname_used_without_including_sys_socket_h
     176  #   undef getsockopt
     177  #   define getsockopt          getsockopt_used_without_including_sys_socket_h
     178  #   undef listen
     179  #   define listen              listen_used_without_including_sys_socket_h
     180  #   undef recv
     181  #   define recv                recv_used_without_including_sys_socket_h
     182  #   undef send
     183  #   define send                send_used_without_including_sys_socket_h
     184  #   undef recvfrom
     185  #   define recvfrom            recvfrom_used_without_including_sys_socket_h
     186  #   undef sendto
     187  #   define sendto              sendto_used_without_including_sys_socket_h
     188  #   undef setsockopt
     189  #   define setsockopt          setsockopt_used_without_including_sys_socket_h
     190  #   undef shutdown
     191  #   define shutdown            shutdown_used_without_including_sys_socket_h
     192  #  else
     193       _GL_WARN_ON_USE (socket,
     194                        "socket() used without including <sys/socket.h>");
     195       _GL_WARN_ON_USE (connect,
     196                        "connect() used without including <sys/socket.h>");
     197       _GL_WARN_ON_USE (accept,
     198                        "accept() used without including <sys/socket.h>");
     199       _GL_WARN_ON_USE (bind,
     200                        "bind() used without including <sys/socket.h>");
     201       _GL_WARN_ON_USE (getpeername,
     202                        "getpeername() used without including <sys/socket.h>");
     203       _GL_WARN_ON_USE (getsockname,
     204                        "getsockname() used without including <sys/socket.h>");
     205       _GL_WARN_ON_USE (getsockopt,
     206                        "getsockopt() used without including <sys/socket.h>");
     207       _GL_WARN_ON_USE (listen,
     208                        "listen() used without including <sys/socket.h>");
     209       _GL_WARN_ON_USE (recv,
     210                        "recv() used without including <sys/socket.h>");
     211       _GL_WARN_ON_USE (send,
     212                        "send() used without including <sys/socket.h>");
     213       _GL_WARN_ON_USE (recvfrom,
     214                        "recvfrom() used without including <sys/socket.h>");
     215       _GL_WARN_ON_USE (sendto,
     216                        "sendto() used without including <sys/socket.h>");
     217       _GL_WARN_ON_USE (setsockopt,
     218                        "setsockopt() used without including <sys/socket.h>");
     219       _GL_WARN_ON_USE (shutdown,
     220                        "shutdown() used without including <sys/socket.h>");
     221  #  endif
     222  # endif
     223  # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
     224  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     225  #   undef select
     226  #   define select select_used_without_including_sys_select_h
     227  #  else
     228       _GL_WARN_ON_USE (select,
     229                        "select() used without including <sys/select.h>");
     230  #  endif
     231  # endif
     232  #endif
     233  
     234  #endif /* _@GUARD_PREFIX@_SYS_TIME_H */
     235  #endif /* _CYGWIN_SYS_TIME_H */
     236  #endif /* _@GUARD_PREFIX@_SYS_TIME_H */