beta-0.89.2
[luatex.git] / source / libs / cairo / cairo-src / src / cairo-time-private.h
blob06dc912b4314071de953641bb53e367010d39b00
1 /* cairo - a vector graphics library with display and print output
3 * Copyright (C) 2011 Andrea Canciani
5 * Permission to use, copy, modify, distribute, and sell this software
6 * and its documentation for any purpose is hereby granted without
7 * fee, provided that the above copyright notice appear in all copies
8 * and that both that copyright notice and this permission notice
9 * appear in supporting documentation, and that the name of the
10 * copyright holders not be used in advertising or publicity
11 * pertaining to distribution of the software without specific,
12 * written prior permission. The copyright holders make no
13 * representations about the suitability of this software for any
14 * purpose. It is provided "as is" without express or implied
15 * warranty.
17 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
18 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
21 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
22 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
23 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
24 * SOFTWARE.
26 * Authors: Andrea Canciani <ranma42@gmail.com>
30 #ifndef CAIRO_TIME_PRIVATE_H
31 #define CAIRO_TIME_PRIVATE_H
33 #include "cairo-compiler-private.h"
34 #include "cairo-wideint-private.h"
36 /* Make the base type signed for easier arithmetic */
37 typedef cairo_int64_t cairo_time_t;
39 #define _cairo_time_add _cairo_int64_add
40 #define _cairo_time_sub _cairo_int64_sub
41 #define _cairo_time_gt _cairo_int64_gt
42 #define _cairo_time_lt _cairo_int64_lt
44 #define _cairo_time_to_double _cairo_int64_to_double
45 #define _cairo_time_from_double _cairo_double_to_int64
47 cairo_private int
48 _cairo_time_cmp (const void *a,
49 const void *b);
51 cairo_private double
52 _cairo_time_to_s (cairo_time_t t);
54 cairo_private cairo_time_t
55 _cairo_time_from_s (double t);
57 cairo_private cairo_time_t
58 _cairo_time_get (void);
60 static cairo_always_inline cairo_time_t
61 _cairo_time_get_delta (cairo_time_t t)
63 cairo_time_t now;
65 now = _cairo_time_get ();
67 return _cairo_time_sub (now, t);
70 static cairo_always_inline double
71 _cairo_time_to_ns (cairo_time_t t)
73 return 1.e9 * _cairo_time_to_s (t);
76 static cairo_always_inline cairo_time_t
77 _cairo_time_max (cairo_time_t a, cairo_time_t b)
79 if (_cairo_int64_gt (a, b))
80 return a;
81 else
82 return b;
85 static cairo_always_inline cairo_time_t
86 _cairo_time_min (cairo_time_t a, cairo_time_t b)
88 if (_cairo_int64_lt (a, b))
89 return a;
90 else
91 return b;
94 #endif