00001 /* -*- mode: C++; c-file-style: "stroustrup"; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ 00002 /********************************************************************* 00003 * 00004 * Filename : platform.h (base) 00005 * C header. 00006 * 00007 * Platform dependant code abstraction layer. This API gives access 00008 * to miscellanous platform dependent code, such as: 00009 * - getting time 00010 * - ... TODO 00011 * 00012 * NOTE: C interface and implementation 00013 * 00014 * This file is a part of the UPPAAL toolkit. 00015 * Copyright (c) 1995 - 2003, Uppsala University and Aalborg University. 00016 * All right reserved. 00017 * 00018 * v 1.3 reviewed. 00019 * $Id: platform.h,v 1.4 2005/01/25 22:05:19 behrmann Exp $ 00020 * 00021 **********************************************************************/ 00022 00023 #ifndef INCLUDE_BASE_PLATFORM_H 00024 #define INCLUDE_BASE_PLATFORM_H 00025 00026 #ifdef __cplusplus 00027 extern "C" { 00028 #endif 00029 00030 /* Define ARCH_APPLE_DARWIN on Mac OS X. 00031 */ 00032 #if defined(__ppc__) && defined(__APPLE__) && defined(__MACH__) 00033 #define ARCH_APPLE_DARWIN 00034 #endif 00035 00036 /** Time access function 00037 * @return some time reference in second. 00038 * The meaning of the time reference does not matter but computing 00039 * the difference value of consecutive calls will give the real 00040 * elapsed time. 00041 */ 00042 double base_getTime(); 00043 00044 00045 /** Finer grain time measure function. 00046 * @return number of CPU cycles (TSC asm call). 00047 * This is implemented only for i386 platforms. 00048 */ 00049 static inline 00050 unsigned long long gettsc(void) 00051 { 00052 #if defined(__GNUG__) && defined(i386) 00053 unsigned long ax, dx; 00054 asm volatile("rdtsc" : "=a" (ax), "=d" (dx)); 00055 return ((unsigned long long)dx << 32) + ax; 00056 #else 00057 return 0; 00058 #endif 00059 } 00060 00061 00062 #ifdef __cplusplus 00063 } 00064 #endif 00065 00066 #endif /* INCLUDE_BASE_PLATFORM_H */