build/stlport/src/_stdio_file.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/build/stlport/src/_stdio_file.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,117 @@
     1.4 +/*
     1.5 + * Copyright (c) 1999
     1.6 + * Silicon Graphics Computer Systems, Inc.
     1.7 + *
     1.8 + * Copyright (c) 1999
     1.9 + * Boris Fomitchev
    1.10 + *
    1.11 + * This material is provided "as is", with absolutely no warranty expressed
    1.12 + * or implied. Any use is at your own risk.
    1.13 + *
    1.14 + * Permission to use or copy this software for any purpose is hereby granted
    1.15 + * without fee, provided the above notices are retained on all copies.
    1.16 + * Permission to modify the code and to distribute modified code is granted,
    1.17 + * provided the above notices are retained, and a notice that the code was
    1.18 + * modified is included with the above copyright notice.
    1.19 + *
    1.20 + */
    1.21 +
    1.22 +#ifndef _STLP_STDIO_FILE_H
    1.23 +#define _STLP_STDIO_FILE_H
    1.24 +
    1.25 +/* This file provides a low-level interface between the internal
    1.26 + * representation of struct FILE, from the C stdio library, and
    1.27 + * the C++ I/O library. */
    1.28 +
    1.29 +#ifndef _STLP_CSTDIO
    1.30 +#  include <cstdio>
    1.31 +#endif
    1.32 +#ifndef _STLP_CSTDDEF
    1.33 +#  include <cstddef>
    1.34 +#endif
    1.35 +
    1.36 +#if defined (__MSL__)
    1.37 +#  include <unix.h>  /* get the definition of fileno */
    1.38 +#endif
    1.39 +
    1.40 +_STLP_BEGIN_NAMESPACE
    1.41 +
    1.42 +#if defined (_STLP_WCE)
    1.43 +
    1.44 +inline int _FILE_fd(const FILE *__f) {
    1.45 +  /* Check if FILE is one of the three standard streams
    1.46 +     We do this check first, because invoking _fileno() on one of them
    1.47 +     causes a terminal window to be created. This also happens if you do
    1.48 +     any IO on them, but merely retrieving the filedescriptor shouldn't
    1.49 +     already do that.
    1.50 +
    1.51 +     Obviously this is pretty implementation-specific because it requires
    1.52 +     that indeed the first three FDs are always the same, but that is not
    1.53 +     only common but almost guaranteed. */
    1.54 +  for (int __fd = 0; __fd != 3; ++__fd) {
    1.55 +    if (__f == _getstdfilex(__fd))
    1.56 +      return __fd;
    1.57 +  }
    1.58 +
    1.59 +  /* Normal files. */
    1.60 +  return (int)::_fileno((FILE*)__f); 
    1.61 +}
    1.62 +
    1.63 +# elif defined (_STLP_SCO_OPENSERVER) || defined (__NCR_SVR)
    1.64 +
    1.65 +inline int _FILE_fd(const FILE *__f) { return __f->__file; }
    1.66 +
    1.67 +# elif defined (__sun) && defined (_LP64)
    1.68 +
    1.69 +inline int _FILE_fd(const FILE *__f) { return (int) __f->__pad[2]; }
    1.70 +
    1.71 +#elif defined (__hpux) /* && defined(__hppa) && defined(__HP_aCC)) */ || \
    1.72 +      defined (__MVS__) || \
    1.73 +      defined (_STLP_USE_UCLIBC) /* should be before _STLP_USE_GLIBC */
    1.74 +
    1.75 +inline int _FILE_fd(const FILE *__f) { return fileno(__CONST_CAST(FILE*, __f)); }
    1.76 +
    1.77 +#elif defined (_STLP_USE_GLIBC)
    1.78 +
    1.79 +inline int _FILE_fd(const FILE *__f) { return __f->_fileno; }
    1.80 +
    1.81 +#elif defined (__BORLANDC__)
    1.82 +
    1.83 +inline int _FILE_fd(const FILE *__f) { return __f->fd; }
    1.84 +
    1.85 +#elif defined (__MWERKS__)
    1.86 +
    1.87 +/* using MWERKS-specific defines here to detect other OS targets
    1.88 + * dwa: I'm not sure they provide fileno for all OS's, but this should
    1.89 + * work for Win32 and WinCE
    1.90 +
    1.91 + * Hmm, at least for Novell NetWare __dest_os == __mac_os true too..
    1.92 + * May be both __dest_os and __mac_os defined and empty?   - ptr */
    1.93 +#  if __dest_os == __mac_os
    1.94 +inline int _FILE_fd(const FILE *__f) { return ::fileno(__CONST_CAST(FILE*, __f)); }
    1.95 +#  else
    1.96 +inline int _FILE_fd(const FILE *__f) { return ::_fileno(__CONST_CAST(FILE*, __f)); }
    1.97 +#  endif
    1.98 +
    1.99 +#elif defined (__QNXNTO__) || defined (__WATCOMC__) || defined (__EMX__)
   1.100 +
   1.101 +inline int _FILE_fd(const FILE *__f) { return __f->_handle; }
   1.102 +
   1.103 +#elif defined (__Lynx__)
   1.104 +
   1.105 +/* the prototypes are taken from LynxOS patch for STLport 4.0 */
   1.106 +inline int _FILE_fd(const FILE *__f) { return __f->_fd; }
   1.107 +
   1.108 +#else  /* The most common access to file descriptor. */
   1.109 +
   1.110 +inline int _FILE_fd(const FILE *__f) { return __f->_file; }
   1.111 +
   1.112 +#endif
   1.113 +
   1.114 +_STLP_END_NAMESPACE
   1.115 +
   1.116 +#endif /* _STLP_STDIO_FILE_H */
   1.117 +
   1.118 +/* Local Variables:
   1.119 + * mode:C++
   1.120 + * End: */

mercurial