/* * Copyright (C) 2017 - This file is part of libecc project * * Authors: * Ryad BENADJILA * Arnaud EBALARD * Jean-Pierre FLORI * * Contributors: * Nicolas VIVET * Karim KHALFALLAH * * This software is licensed under a dual BSD and GPL v2 license. * See LICENSE file at the root folder of the project. */ #include /* Unix and compatible case (including macOS) */ #if defined(WITH_STDLIB) && (defined(__unix__) || defined(__APPLE__)) #include #include int get_ms_time(u64 *time) { struct timeval tv; int ret; if (time == NULL) { ret = -1; goto err; } ret = gettimeofday(&tv, NULL); if (ret < 0) { ret = -1; goto err; } (*time) = (u64)(((tv.tv_sec) * 1000) + ((tv.tv_usec) / 1000)); ret = 0; err: return ret; } /* Windows case */ #elif defined(WITH_STDLIB) && defined(__WIN32__) #include #include int get_ms_time(u64 *time) { int ret; SYSTEMTIME st; if (time == NULL) { ret = -1; goto err; } GetSystemTime(&st); (*time) = (u64)((((st.wMinute * 60) + st.wSecond) * 1000) + st.wMilliseconds); ret = 0; err: return ret; } /* No platform detected, the used must provide an implementation! */ #else #error "time.c: you have to implement get_ms_time()" #endif