ETL  0.04.19
_clock_system.h
Go to the documentation of this file.
1 
25 /* === S T A R T =========================================================== */
26 
27 #ifndef __ETL__CLOCK_SYSTEM_H
28 #define __ETL__CLOCK_SYSTEM_H
29 
30 /* === H E A D E R S ======================================================= */
31 
32 #ifndef _WIN32
33 # include <time.h>
34 # define __sys_clock ::clock
35 # define __sys_time ::time
36 #else
37 # ifdef __GNUG__
38 # include <time.h>
39 # define __sys_clock ::clock
40 # define __sys_time ::time
41 # else
42 typedef int clock_t;
43 typedef int time_t;
44 extern clock_t _clock();
45 extern time_t _time(time_t *);
46 # define CLOCKS_PER_SEC 1000
47 # define __sys_clock _clock
48 # define __sys_time _time
49 # endif
50 #endif
51 
52 /* === M A C R O S ========================================================= */
53 
54 /* === T Y P E D E F S ===================================================== */
55 
56 /* === C L A S S E S & S T R U C T S ======================================= */
57 
59 
61 {
62 public:
63  typedef float value_type;
64 
65  inline static bool realtime()
66  { return false; }
67 
68  inline static bool proctime()
69  { return true; }
70 
71  inline static value_type
73  { return 1.0f; }
74 
75  inline static value_type precision()
76  { return one_second()/(value_type)CLOCKS_PER_SEC; }
77 
78  inline static const char *description()
79  { return "ANSI C clock()"; };
80 
81 protected:
82  typedef clock_t timestamp;
83 
84  static void
86  { time=__sys_clock(); }
87 
88  static timestamp
90  { return __sys_clock(); }
91 
92  static value_type
94  { return precision()*x; }
95 
96  static timestamp
98  { return (timestamp)(x*(value_type)CLOCKS_PER_SEC+0.5); }
99 
100 };
101 
103 {
104 public:
105  typedef float value_type;
106 
107  inline static bool realtime()
108  { return true; }
109 
110  inline static bool proctime()
111  { return false; }
112 
113  inline static value_type
115  { return 1.0f; }
116 
117  inline static value_type precision()
118  { return one_second(); }
119 
120  inline static const char *description()
121  { return "ANSI C time()"; };
122 
123 protected:
124  typedef time_t timestamp;
125 
126  static void
128  { __sys_time(&time); }
129 
130  static timestamp
132  { return __sys_time(NULL); }
133 
134  static value_type
136  { return (value_type)x; }
137 
138  static timestamp
140  { return (timestamp)(x+(value_type)0.5f); }
141 };
142 
144 
145 /* === E N D =============================================================== */
146 
147 #endif