]> Pileus Git - ~andy/gtk/blob - gtk/fallback-c89.c
stylecontext: Do invalidation on first resize container
[~andy/gtk] / gtk / fallback-c89.c
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 2011 Chun-wei Fan <fanc999@yahoo.com.tw>
3  *
4  * Author: Chun-wei Fan <fanc999@yahoo.com.tw>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #include <math.h>
21  
22 /* Workaround for round() for non-GCC/non-C99 compilers */
23 #ifndef HAVE_ROUND
24 static inline double
25 round (double x)
26 {
27   if (x >= 0)
28     return floor (x + 0.5);
29   else
30     return ceil (x - 0.5);
31 }
32 #endif
33
34 /* Workaround for rint() for non-GCC/non-C99 compilers */
35 #ifndef HAVE_RINT
36 static inline double
37 rint (double x)
38 {
39   if (ceil (x + 0.5) == floor (x + 0.5))
40   {
41     int a;
42     a = (int) ceil (x);
43     if (a % 2 == 0)
44       return ceil (x);
45     else
46       return floor (x);
47   }
48   else
49   {
50     if (x >= 0)
51       return floor (x + 0.5);
52     else
53       return ceil (x - 0.5);
54   }
55 }
56 #endif
57
58 #ifndef HAVE_NEARBYINT
59 /* Workaround for nearbyint() for non-GCC/non-C99 compilers */
60 /* This is quite similar to rint() in most respects */
61
62 static inline double
63 nearbyint (double x)
64 {
65   return floor (x + 0.5);
66 }
67 #endif