SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SysUtils.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // A few system-specific functions
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
10 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #ifdef _MSC_VER
24 #include <windows_config.h>
25 #else
26 #include <config.h>
27 #endif
28 
29 #include "SysUtils.h"
30 
31 #ifndef WIN32
32 #include <sys/time.h>
33 #else
34 #define NOMINMAX
35 #include <windows.h>
36 #undef NOMINMAX
37 #endif
38 
39 #ifdef CHECK_MEMORY_LEAKS
40 #include <foreign/nvwa/debug_new.h>
41 #endif // CHECK_MEMORY_LEAKS
42 
43 
44 // ===========================================================================
45 // member method definitions
46 // ===========================================================================
47 long
49 #ifndef WIN32
50  timeval current;
51  gettimeofday(&current, 0);
52  long nanosecs =
53  (long) current.tv_sec * 1000L + (long) current.tv_usec / 1000L;
54  return nanosecs;
55 #else
56  LARGE_INTEGER val, val2;
57  BOOL check = QueryPerformanceCounter(&val);
58  check = QueryPerformanceFrequency(&val2);
59  return (long)(val.QuadPart * 1000 / val2.QuadPart);
60 #endif
61 }
62 
63 
64 #ifdef _MSC_VER
65 long
66 SysUtils::getWindowsTicks() {
67  return (long) GetTickCount();
68 }
69 #endif
70 
71 
72 
73 /****************************************************************************/
74