Bitcoin Core 30.99.0
P2P Digital Currency
tests_common.h
Go to the documentation of this file.
1/***********************************************************************
2 * Distributed under the MIT software license, see the accompanying *
3 * file COPYING or https://www.opensource.org/licenses/mit-license.php.*
4 ***********************************************************************/
5
6#ifndef SECP256K1_TESTS_COMMON_H
7#define SECP256K1_TESTS_COMMON_H
8
9/***********************************************************************
10 * Test Support Utilities
11 *
12 * This file provides general-purpose functions for tests and benchmark
13 * programs. Unlike testutil.h, this file is not linked to the library,
14 * allowing each program to choose whether to run against the production
15 * API or access library internals directly.
16 ***********************************************************************/
17
18#include <stdint.h>
19
20#if (defined(_MSC_VER) && _MSC_VER >= 1900)
21# include <time.h>
22#else
23# include <sys/time.h>
24#endif
25
26static int64_t gettime_i64(void) {
27#if (defined(_MSC_VER) && _MSC_VER >= 1900)
28 /* C11 way to get wallclock time */
29 struct timespec tv;
30 if (!timespec_get(&tv, TIME_UTC)) {
31 fputs("timespec_get failed!", stderr);
32 exit(EXIT_FAILURE);
33 }
34 return (int64_t)tv.tv_nsec / 1000 + (int64_t)tv.tv_sec * 1000000LL;
35#else
36 struct timeval tv;
37 gettimeofday(&tv, NULL);
38 return (int64_t)tv.tv_usec + (int64_t)tv.tv_sec * 1000000LL;
39#endif
40}
41
42#endif /* SECP256K1_TESTS_COMMON_H */
static int64_t gettime_i64(void)
Definition: tests_common.h:26