common: use uint64_t as return type of g_time[23]

This commit is contained in:
Koichiro IWAO 2018-04-16 00:34:42 +09:00
parent 9f0e40e728
commit e97b9352f4
No known key found for this signature in database
GPG Key ID: 9F72CDBC01BF10EB
2 changed files with 7 additions and 7 deletions

View File

@ -3538,24 +3538,24 @@ g_time1(void)
/*****************************************************************************/ /*****************************************************************************/
/* returns the number of milliseconds since the machine was /* returns the number of milliseconds since the machine was
started. */ started. */
long long uint64_t
g_time2(void) g_time2(void)
{ {
#if defined(_WIN32) #if defined(_WIN32)
return (long long)GetTickCount(); return (uint64_t)GetTickCount();
#else #else
struct tms tm; struct tms tm;
clock_t num_ticks = 0; clock_t num_ticks = 0;
g_memset(&tm, 0, sizeof(struct tms)); g_memset(&tm, 0, sizeof(struct tms));
num_ticks = times(&tm); num_ticks = times(&tm);
return (long long)(num_ticks * 10); return (uint64_t)(num_ticks * 10);
#endif #endif
} }
/*****************************************************************************/ /*****************************************************************************/
/* returns time in milliseconds, uses gettimeofday /* returns time in milliseconds, uses gettimeofday
does not work in win32 */ does not work in win32 */
long long uint64_t
g_time3(void) g_time3(void)
{ {
#if defined(_WIN32) #if defined(_WIN32)
@ -3564,7 +3564,7 @@ g_time3(void)
struct timeval tp; struct timeval tp;
gettimeofday(&tp, 0); gettimeofday(&tp, 0);
return ((long long)tp.tv_sec * 1000) + ((long long)tp.tv_usec / 1000); return ((uint64_t)tp.tv_sec * 1000) + ((uint64_t)tp.tv_usec / 1000);
#endif #endif
} }

View File

@ -174,8 +174,8 @@ int g_getuser_info(const char* username, int* gid, int* uid, char** shell,
int g_getgroup_info(const char* groupname, int* gid); int g_getgroup_info(const char* groupname, int* gid);
int g_check_user_in_group(const char* username, int gid, int* ok); int g_check_user_in_group(const char* username, int gid, int* ok);
int g_time1(void); int g_time1(void);
long long g_time2(void); uint64_t g_time2(void);
long long g_time3(void); uint64_t g_time3(void);
int g_save_to_bmp(const char* filename, char* data, int stride_bytes, int g_save_to_bmp(const char* filename, char* data, int stride_bytes,
int width, int height, int depth, int bits_per_pixel); int width, int height, int depth, int bits_per_pixel);
int g_text2bool(const char *s); int g_text2bool(const char *s);