Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. // -*- C++ -*- header wrapper.
  2.  
  3. // Copyright (C) 1997-1999, 2000 Free Software Foundation, Inc.
  4. //
  5. // This file is part of the GNU ISO C++ Library.  This library is free
  6. // software; you can redistribute it and/or modify it under the
  7. // terms of the GNU General Public License as published by the
  8. // Free Software Foundation; either version 2, or (at your option)
  9. // any later version.
  10.  
  11. // This library is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. // GNU General Public License for more details.
  15.  
  16. // You should have received a copy of the GNU General Public License along
  17. // with this library; see the file COPYING.  If not, write to the Free
  18. // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  19. // USA.
  20.  
  21. // As a special exception, you may use this file as part of a free software
  22. // library without restriction.  Specifically, if other files instantiate
  23. // templates or use macros or inline functions from this file, or you compile
  24. // this file and link it with other files to produce an executable, this
  25. // file does not by itself cause the resulting executable to be covered by
  26. // the GNU General Public License.  This exception does not however
  27. // invalidate any other reasons why the executable file might be covered by
  28. // the GNU General Public License.
  29.  
  30. //
  31. // ISO C++ 14882: 20.5  Date and time
  32. //
  33.  
  34. #ifndef _CPP_CTIME
  35. #define _CPP_CTIME 1
  36.  
  37. # include <bits/std_cstddef.h>  
  38.  
  39. namespace _C_legacy {
  40.   extern "C" {
  41. #     define _IN_C_LEGACY_
  42. #     pragma GCC system_header
  43.  
  44.       // XXX
  45.       // glibc 2.1.x time.h is on crack
  46. #     undef __need_time_t
  47. #     undef __need_clock_t
  48. #     undef __need_timespec
  49.  
  50. #     include_next <time.h>
  51.   }
  52.  
  53.   typedef clock_t       _CPP_clock_t_capture;
  54.   typedef time_t        _CPP_time_t_capture;
  55.   typedef tm            _CPP_tm_capture;
  56.  
  57. } // namespace _C_legacy
  58.  
  59. #  undef clock_t
  60. #  undef time_t
  61. #  undef tm
  62. #  undef clock
  63. #  undef difftime
  64. #  undef mktime
  65. #  undef time
  66. #  undef asctime
  67. #  undef ctime
  68. #  undef gmtime
  69. #  undef localtime
  70. #  undef strftime
  71.  
  72. namespace std {
  73.  
  74.   // Adopt C names into std::
  75.   typedef _C_legacy::_CPP_clock_t_capture  clock_t;
  76.   typedef _C_legacy::_CPP_time_t_capture   time_t;
  77.   struct tm : _C_legacy::_CPP_tm_capture  { };
  78.  
  79.   using _C_legacy::clock;
  80.   using _C_legacy::difftime;
  81.   using _C_legacy::mktime;
  82.   using _C_legacy::time;
  83.   using _C_legacy::ctime;
  84.  
  85.   inline char*
  86.   asctime(const tm* __t)
  87.   { return _C_legacy::asctime(static_cast<_C_legacy::_CPP_tm_capture const*>(__t)); }
  88.  
  89.   inline tm*
  90.   gmtime(time_t const* __tp)
  91.   { return reinterpret_cast<tm*>(_C_legacy::gmtime(__tp)); }
  92.  
  93.   inline tm*
  94.   localtime(const time_t* __tp)
  95.   { return reinterpret_cast<tm*>(_C_legacy::localtime(__tp)); }
  96.    
  97.   inline size_t
  98.   strftime(char* __buf, size_t __maxsz, char const* __fmt, tm const* __tp)
  99.   { return _C_legacy::strftime(__buf, __maxsz, __fmt,
  100.                        static_cast<_C_legacy::_CPP_tm_capture const*>(__tp)); }
  101.  
  102. } // namespace std
  103.  
  104. # undef _IN_C_LEGACY_
  105.  
  106. #endif
  107.  
  108.