(root)/
glib-2.79.0/
glib/
gstdioprivate.h
       1  /* gstdioprivate.h - Private GLib stdio functions
       2   *
       3   * Copyright 2017 Руслан Ижбулатов
       4   *
       5   * SPDX-License-Identifier: LGPL-2.1-or-later
       6   *
       7   * This library is free software; you can redistribute it and/or
       8   * modify it under the terms of the GNU Lesser General Public
       9   * License as published by the Free Software Foundation; either
      10   * version 2.1 of the License, or (at your option) any later version.
      11   *
      12   * This library is distributed in the hope that it will be useful,
      13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15   * Lesser General Public License for more details.
      16   *
      17   * You should have received a copy of the GNU Lesser General Public License
      18   * along with this library; if not, see <http://www.gnu.org/licenses/>.
      19   */
      20  
      21  #ifndef __G_STDIOPRIVATE_H__
      22  #define __G_STDIOPRIVATE_H__
      23  
      24  G_BEGIN_DECLS
      25  
      26  #if defined (G_OS_WIN32)
      27  
      28  typedef struct _gtimespec {
      29    guint64 tv_sec;
      30    guint32 tv_nsec;
      31  } gtimespec;
      32  
      33  struct _GWin32PrivateStat
      34  {
      35    guint32 volume_serial;
      36    guint64 file_index;
      37    guint64 attributes;
      38    guint64 allocated_size;
      39    guint32 reparse_tag;
      40  
      41    guint32 st_dev;
      42    guint32 st_ino;
      43    guint16 st_mode;
      44    guint16 st_uid;
      45    guint16 st_gid;
      46    guint32 st_nlink;
      47    guint64 st_size;
      48    gtimespec st_ctim;
      49    gtimespec st_atim;
      50    gtimespec st_mtim;
      51  };
      52  
      53  typedef struct _GWin32PrivateStat GWin32PrivateStat;
      54  
      55  int g_win32_stat_utf8     (const gchar       *filename,
      56                             GWin32PrivateStat *buf);
      57  
      58  int g_win32_lstat_utf8    (const gchar       *filename,
      59                             GWin32PrivateStat *buf);
      60  
      61  int g_win32_readlink_utf8 (const gchar       *filename,
      62                             gchar             *buf,
      63                             gsize              buf_size,
      64                             gchar            **alloc_buf,
      65                             gboolean           terminate);
      66  
      67  int g_win32_fstat         (int                fd,
      68                             GWin32PrivateStat *buf);
      69  
      70  #endif
      71  /* The POSIX standard specifies that if close() fails with EINTR the
      72   * file descriptor may or may not be in fact closed. Since another
      73   * thread might have already reused the FD if it was in fact closed
      74   * either a test of FD to ensure that it's closed nor a second
      75   * call to close() may indicate the wrong FD, so the error must be
      76   * ignored.
      77   *
      78   * However, since Mac OS X 10.5 (Leopard) Apple provdes a hidden
      79   * implementation of close that doesn't allow another thread
      80   * to cancel the close so it never fails with EINTR.
      81   *
      82   * The official way to enable this is to set __DARWIN_NON_CANCELABLE
      83   * in the build, but that applies to all system calls, not just
      84   * close(). Following Chromium's example (see
      85   * https://chromium.googlesource.com/chromium/src/base/+/refs/heads/main/mac/close_nocancel.cc )
      86   * we choose to expose and use the hidden close variant only.
      87   */
      88  #ifdef __APPLE__
      89  #include <sys/cdefs.h>
      90  #include <unistd.h>
      91  # if !__DARWIN_NON_CANCELABLE
      92  #  if !__DARWIN_ONLY_UNIX_CONFORMANCE
      93  #   define close close$NOCANCEL$UNIX2003
      94  int close$NOCANCEL$UNIX2003 (int fd);
      95  #  else
      96  #   define close close$NOCANCEL
      97  int close$NOCANCEL (int fd);
      98  #  endif
      99  # endif
     100  #endif
     101  G_END_DECLS
     102  
     103  #endif /* __G_STDIOPRIVATE_H__ */