Go to the source code of this file.
Defines | |
#define | ppmsTod(mstime) ((mstime)/1000.0) |
#define | ppdToms(fvalue) ((mstime)((fvalue)*1000)) |
Functions | |
ppCPP (extern"C"{) typedef int64 mstime | |
A memory mapped file (Read Only) Basically get a const pointer to a file. | |
mstime | ctl_mstime (void) |
Get time in milliseconds since midnight, January 1, 1970 UTC (mstime/1000 == time_t) Though this would *seem* to be simple, it's not. You can't separately poll clock() and then time(NULL), because there is an unspecifiable time period between these two invokations due to interrupt, IO and threading. It's very easy to get one time and another confused, and return a past time from a subsequent call. | |
int | ctl_mstime_print_seconds (char *buff, size_t bufflen, mstime ms) |
Concisely format millisecond time as fractions of seconds. | |
bool | ctl_mstime_local (struct tm *ptm, mstime ms) |
Convert mstime to C runtime struct tm - LOCAL time. | |
bool | ctl_mstime_gm (struct tm *ptm, mstime ms) |
Convert mstime to C runtime struct tm - GMT. | |
int | ctl_mstime_print_time_local (char *buff, size_t bufflen, mstime ms) |
Format milliseconds as date/time. | |
int | ctl_mstime_print_time_gm (char *buff, size_t bufflen, mstime ms) |
Format milliseconds as date/time. | |
ustime | ctl_ustime (void) |
Get time in microseconds since midnight, January 1, 1970 UTC (mstime/1000000 == time_t) Though this would *seem* to be simple, it's not. You can't separately poll clock() and then time(NULL), because there is an unspecifiable time period between these two invokations due to interrupt, IO and threading. It's very easy to get one time and another confused, and return a past time from a subsequent call. | |
int | ctl_ustime_print_seconds (char *buff, size_t bufflen, ustime us) |
Concisely format microsecond time as fractions of seconds. |
Definition in file mstime.h.
#define ppdToms | ( | fvalue | ) | ((mstime)((fvalue)*1000)) |
#define ppmsTod | ( | mstime | ) | ((mstime)/1000.0) |
bool ctl_mstime_gm | ( | struct tm * | ptm, | |
mstime | ms | |||
) |
Convert mstime to C runtime struct tm - GMT.
ptm | Pointer to struct tm to receive time | |
ms | Milliseconds to print |
Definition at line 157 of file mstime.c.
References assertobjptr.
00158 { 00159 time_t time = ms/1000; 00160 struct tm* ret = gmtime(&time); 00161 assertobjptr(ptm); 00162 if( NULL == ret ) 00163 { 00164 memset(ptm,0,sizeof(*ptm)); 00165 return false; 00166 } 00167 *ptm = *ret; 00168 return true; 00169 }
bool ctl_mstime_local | ( | struct tm * | ptm, | |
mstime | ms | |||
) |
Convert mstime to C runtime struct tm - LOCAL time.
ptm | Pointer to struct tm to receive time | |
ms | Milliseconds to print |
Definition at line 135 of file mstime.c.
References assertobjptr.
00136 { 00137 time_t time = ms/1000; 00138 struct tm* ret = localtime(&time); 00139 assertobjptr(ptm); 00140 if( NULL == ret ) 00141 { 00142 memset(ptm,0,sizeof(*ptm)); 00143 return false; 00144 } 00145 *ptm = *ret; 00146 return true; 00147 }
int ctl_mstime_print_seconds | ( | char * | buff, | |
size_t | bufflen, | |||
mstime | ms | |||
) |
Concisely format millisecond time as fractions of seconds.
buff | Buffer to receive text | |
bufflen | Length of buff | |
ms | Milliseconds to print |
Definition at line 121 of file mstime.c.
References assertptr.
00122 { 00123 assertptr(buff,bufflen); 00124 return snprintf( buff, bufflen, "%lld.%03lld", ms/1000, ms%1000 ); 00125 }
int ctl_mstime_print_time_gm | ( | char * | buff, | |
size_t | bufflen, | |||
mstime | ms | |||
) |
Format milliseconds as date/time.
buff | Buffer to receive text | |
bufflen | Length of buff | |
ms | Milliseconds to print CAUTION: C runtime library may not support -times or times in distant future Format: YYYY/MM/DD HH:MM:SS.mmm or 1999/12/31 23:59:59.999 |
Definition at line 197 of file mstime.c.
References assertptr.
00198 { 00199 time_t time = ms/1000; 00200 struct tm* tmtime = gmtime(&time); 00201 assertptr(buff,bufflen); 00202 if( NULL == tmtime ) 00203 return snprintf( buff, bufflen, "%lld: %s", (long long)ms, strerror(errno) ); 00204 return snprintf( buff, bufflen, "%04d/%02d/%02d %2.2d:%2.2d:%2.2d.%03d GMT", 1900+tmtime->tm_year, 1+tmtime->tm_mon, tmtime->tm_mday, tmtime->tm_hour, tmtime->tm_min, tmtime->tm_sec, (int)(ms%1000) ); 00205 }
int ctl_mstime_print_time_local | ( | char * | buff, | |
size_t | bufflen, | |||
mstime | ms | |||
) |
Format milliseconds as date/time.
buff | Buffer to receive text | |
bufflen | Length of buff | |
ms | Milliseconds to print CAUTION: C runtime library may not support -times or times in distant future Format: YYYY/MM/DD HH:MM:SS.mmm or 1999/12/31 23:59:59.999 |
Definition at line 179 of file mstime.c.
References assertptr.
00180 { 00181 time_t time = ms/1000; 00182 struct tm* tmtime = localtime(&time); 00183 assertptr(buff,bufflen); 00184 if( NULL == tmtime ) 00185 return snprintf( buff, bufflen, "%lld: %s", (long long)ms, strerror(errno) ); 00186 return snprintf( buff, bufflen, "%04d/%02d/%02d %2.2d:%2.2d:%2.2d.%03d", 1900+tmtime->tm_year, 1+tmtime->tm_mon, tmtime->tm_mday, tmtime->tm_hour, tmtime->tm_min, tmtime->tm_sec, (int)(ms%1000) ); 00187 }
int ctl_ustime_print_seconds | ( | char * | buff, | |
size_t | bufflen, | |||
ustime | us | |||
) |
Concisely format microsecond time as fractions of seconds.
buff | Buffer to receive text | |
bufflen | Length of buff | |
us | Microseconds to print |
Definition at line 65 of file mstime.c.
Referenced by ctl_profiles_dump_averages_sheet().
ppCPP | ( | ) |
A memory mapped file (Read Only) Basically get a const pointer to a file.
TODO: Make tchar templates of these
< Where the memory is
< Length of it
< File descriptor to close when finished
Definition at line 9 of file mmap.h.
References ctl_mmap_close(), ctl_mmap_open(), and ppCPP().
Referenced by ppCPP().
00009 {) 00010 00015 typedef struct ctl_mmap 00016 { 00017 void* base; 00018 size_t size; 00019 #ifdef WIN32 00020 void* hFile; 00021 void* hMap; 00022 #else /* LINUX */ 00023 int fd; 00024 #endif 00025 } ctl_mmap;