| OLD | NEW |
| 1 // Copyright (c) 2004, Google Inc. | 1 // Copyright (c) 2004, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // __rdtsc intrinsic, declared in <intrin.h>. Unfortunately, in some | 60 // __rdtsc intrinsic, declared in <intrin.h>. Unfortunately, in some |
| 61 // environments, <windows.h> and <intrin.h> have conflicting | 61 // environments, <windows.h> and <intrin.h> have conflicting |
| 62 // declarations of some other intrinsics, breaking compilation. | 62 // declarations of some other intrinsics, breaking compilation. |
| 63 // Therefore, we simply declare __rdtsc ourselves. See also | 63 // Therefore, we simply declare __rdtsc ourselves. See also |
| 64 // http://connect.microsoft.com/VisualStudio/feedback/details/262047 | 64 // http://connect.microsoft.com/VisualStudio/feedback/details/262047 |
| 65 #if defined(_MSC_VER) && !defined(_M_IX86) | 65 #if defined(_MSC_VER) && !defined(_M_IX86) |
| 66 extern "C" uint64 __rdtsc(); | 66 extern "C" uint64 __rdtsc(); |
| 67 #pragma intrinsic(__rdtsc) | 67 #pragma intrinsic(__rdtsc) |
| 68 #endif | 68 #endif |
| 69 #if defined(ARMV3) || defined(__mips__) | 69 #if defined(ARMV3) || defined(__mips__) |
| 70 #ifdef HAVE_SYS_TIME_H |
| 70 #include <sys/time.h> | 71 #include <sys/time.h> |
| 71 #endif | 72 #endif |
| 73 #endif |
| 72 | 74 |
| 73 // NOTE: only i386 and x86_64 have been well tested. | 75 // NOTE: only i386 and x86_64 have been well tested. |
| 74 // PPC, sparc, alpha, and ia64 are based on | 76 // PPC, sparc, alpha, and ia64 are based on |
| 75 // http://peter.kuscsik.com/wordpress/?p=14 | 77 // http://peter.kuscsik.com/wordpress/?p=14 |
| 76 // with modifications by m3b. See also | 78 // with modifications by m3b. See also |
| 77 // https://setisvn.ssl.berkeley.edu/svn/lib/fftw-3.0.1/kernel/cycle.h | 79 // https://setisvn.ssl.berkeley.edu/svn/lib/fftw-3.0.1/kernel/cycle.h |
| 78 struct CycleClock { | 80 struct CycleClock { |
| 79 // This should return the number of cycles since power-on. Thread-safe. | 81 // This should return the number of cycles since power-on. Thread-safe. |
| 80 static inline int64 Now() { | 82 static inline int64 Now() { |
| 81 #if defined(__MACH__) && defined(__APPLE__) | 83 #if defined(__MACH__) && defined(__APPLE__) |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 // The soft failover to a generic implementation is automatic only for ARM. | 156 // The soft failover to a generic implementation is automatic only for ARM. |
| 155 // For other platforms the developer is expected to make an attempt to create | 157 // For other platforms the developer is expected to make an attempt to create |
| 156 // a fast implementation and use generic version if nothing better is available. | 158 // a fast implementation and use generic version if nothing better is available. |
| 157 #error You need to define CycleTimer for your O/S and CPU | 159 #error You need to define CycleTimer for your O/S and CPU |
| 158 #endif | 160 #endif |
| 159 } | 161 } |
| 160 }; | 162 }; |
| 161 | 163 |
| 162 | 164 |
| 163 #endif // GOOGLE_BASE_CYCLECLOCK_H_ | 165 #endif // GOOGLE_BASE_CYCLECLOCK_H_ |
| OLD | NEW |