root/trunk/libffado/src/libutil/Time.h

Revision 445, 2.0 kB (checked in by pieterpalmers, 17 years ago)

* name change from FreeBoB to FFADO
* replaced tabs by 4 spaces
* got rid of end-of-line spaces
* made all license and copyrights conform

library becomes LGPL, apps become GPL
explicitly state LGPL v2.1 and GPL v2 (don't like v3 draft)

copyrights are 2005-2007 Daniel & Pieter
except for the MotU stuff (C) Jonathan, Pieter

Line 
1 /*
2     Copyright (C) 2005-2007 by Pieter Palmers
3
4     This file is part of FFADO
5     FFADO = Free Firewire (pro-)audio drivers for linux
6
7     FFADO is based upon FreeBoB.
8
9     Based upon JackTime.h from the jackdmp package.
10     Original Copyright:
11
12     Copyright (C) 2001-2003 Paul Davis
13     Copyright (C) 2004-2006 Grame
14
15     This program is free software; you can redistribute it and/or modify
16     it under the terms of the GNU General Public License as published by
17     the Free Software Foundation; either version 2 of the License, or
18     (at your option) any later version.
19
20     This program is distributed in the hope that it will be useful,
21     but WITHOUT ANY WARRANTY; without even the implied warranty of
22     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23     GNU General Public License for more details.
24
25     You should have received a copy of the GNU General Public License
26     along with this program; if not, write to the Free Software
27     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28
29 */
30
31 #ifndef __Time__
32 #define __Time__
33
34 #include <stdio.h>
35 #include <inttypes.h>
36
37 // #define GETCYCLE_TIME
38
39 /**
40  * Type used to represent the value of free running
41  * monotonic clock with units of microseconds.
42  */
43
44 typedef uint64_t ffado_microsecs_t;
45
46
47 #ifdef __cplusplus
48 extern "C"
49 {
50 #endif
51
52
53 #include <unistd.h>
54
55     static inline void FFADOSleep(long usec) {
56         usleep(usec);
57     }
58
59 #ifdef GETCYCLE_TIME
60     #include "cycles.h"
61     extern ffado_microsecs_t __ffado_cpu_mhz;
62     extern ffado_microsecs_t GetMhz();
63     extern void InitTime();
64     static inline ffado_microsecs_t GetMicroSeconds (void) {
65         return get_cycles() / __ffado_cpu_mhz;
66     }
67 #else
68     #include <time.h>
69     extern void InitTime();
70     static inline ffado_microsecs_t GetMicroSeconds (void) {
71         struct timespec ts;
72         clock_gettime(CLOCK_MONOTONIC, &ts);
73         return (ffado_microsecs_t)ts.tv_sec * 1000000LL + ts.tv_nsec / 1000;
74     }
75 #endif
76
77
78 #ifdef __cplusplus
79 }
80 #endif
81
82
83 #endif
84
85
86
Note: See TracBrowser for help on using the browser.