summaryrefslogtreecommitdiffabout
path: root/pwmanager/pwmanager/compiler.h
blob: a9422461e92dd70b9b8bf6f2f38813055f593330 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/***************************************************************************
 *                                                                         *
 *   Derived from the linux-2.6 tree                                       *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License version 2        *
 *   as published by the Free Software Foundation.                         *
 *                                                                         *
 ***************************************************************************/

#ifndef __PWMANAGER_COMPILER_H
#define __PWMANAGER_COMPILER_H

#ifdef _WIN32_
#  define __builtin_expect(x, expected_value) (x)
#define NOREGPARM	__attribute__((regparm(0)))
#define REGPARM		__attribute__((regparm(3)))
#define likely(x)	__builtin_expect(!!(x), 1)
#define unlikely(x)	__builtin_expect(!!(x), 0)

#else
#ifdef __deprecated
# undef __deprecated
#endif
#if __GNUC__ >= 3
# if __GNUC_MINOR__ > 0
#  define __deprecated	__attribute__((deprecated))
# endif
#elif __GNUC__ == 2
# if __GNUC_MINOR__ < 96
#  ifdef __builtin_expect
#   undef __builtin_expect
#  endif
#  define __builtin_expect(x, expected_value) (x)
# endif
#else
# error "Sorry, your compiler is too old/not supported."
#endif

/*
 * Allow us to mark functions as 'deprecated' and have gcc emit a nice
 * warning for each use, in hopes of speeding the functions removal.
 * Usage is:
 * 		int __deprecated foo(void)
 */
#ifndef __deprecated
# define __deprecated		/* unimplemented */
#endif

/* define likely() and unlikely() */
#ifdef likely
# undef likely
#endif
#ifdef unlikely
# undef unlikely
#endif
#define likely(x)	__builtin_expect(!!(x), 1)
#define unlikely(x)	__builtin_expect(!!(x), 0)

#ifdef NOREGPARM
# undef NOREGPARM
#endif
#define NOREGPARM	__attribute__((regparm(0)))
#ifdef REGPARM
# undef REGPARM
#endif
#define REGPARM		__attribute__((regparm(3)))
#endif
#endif // __PWMANAGER_COMPILER_H