| Revision 4253,
1.4 KB
checked in by sam, 3 years ago
(diff) |
|
Fix copyright information and remove Id tag everywhere.
|
-
Property svn:keywords set to
Id
|
| Line | |
|---|
| 1 | /* |
|---|
| 2 | * zzuf - general purpose fuzzer |
|---|
| 3 | * Copyright (c) 2006-2010 Sam Hocevar <sam@hocevar.net> |
|---|
| 4 | * All Rights Reserved |
|---|
| 5 | * |
|---|
| 6 | * This program is free software. It comes without any warranty, to |
|---|
| 7 | * the extent permitted by applicable law. You can redistribute it |
|---|
| 8 | * and/or modify it under the terms of the Do What The Fuck You Want |
|---|
| 9 | * To Public License, Version 2, as published by Sam Hocevar. See |
|---|
| 10 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
|---|
| 11 | */ |
|---|
| 12 | |
|---|
| 13 | /* |
|---|
| 14 | * timer.c: timing functions |
|---|
| 15 | */ |
|---|
| 16 | |
|---|
| 17 | #include "config.h" |
|---|
| 18 | |
|---|
| 19 | #if defined HAVE_STDINT_H |
|---|
| 20 | # include <stdint.h> |
|---|
| 21 | #elif defined HAVE_INTTYPES_H |
|---|
| 22 | # include <inttypes.h> |
|---|
| 23 | #endif |
|---|
| 24 | #if defined HAVE_WINDOWS_H |
|---|
| 25 | # include <windows.h> |
|---|
| 26 | #endif |
|---|
| 27 | #if defined HAVE_SYS_TIME_H |
|---|
| 28 | # include <sys/time.h> |
|---|
| 29 | #endif |
|---|
| 30 | #include <stdio.h> |
|---|
| 31 | #include <time.h> |
|---|
| 32 | |
|---|
| 33 | #include "timer.h" |
|---|
| 34 | |
|---|
| 35 | int64_t _zz_time(void) |
|---|
| 36 | { |
|---|
| 37 | #if defined HAVE_GETTIMEOFDAY |
|---|
| 38 | struct timeval tv; |
|---|
| 39 | gettimeofday(&tv, NULL); |
|---|
| 40 | return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec; |
|---|
| 41 | #else |
|---|
| 42 | static CRITICAL_SECTION cs; |
|---|
| 43 | static unsigned long int prev; |
|---|
| 44 | static int64_t tv_base = 0; |
|---|
| 45 | unsigned long int tv_msec; |
|---|
| 46 | |
|---|
| 47 | if(tv_base == 0) |
|---|
| 48 | { |
|---|
| 49 | tv_base = 1; |
|---|
| 50 | prev = 0; |
|---|
| 51 | InitializeCriticalSection(&cs); |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | EnterCriticalSection(&cs); |
|---|
| 55 | tv_msec = GetTickCount(); |
|---|
| 56 | if(tv_msec < prev) |
|---|
| 57 | tv_base += 0x100000000LL; /* We wrapped */ |
|---|
| 58 | prev = tv_msec; |
|---|
| 59 | LeaveCriticalSection(&cs); |
|---|
| 60 | |
|---|
| 61 | return (tv_base + tv_msec) * 1000; |
|---|
| 62 | #endif |
|---|
| 63 | } |
|---|
| 64 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.