-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcompiler.h
executable file
·79 lines (64 loc) · 1.9 KB
/
compiler.h
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
70
71
72
73
74
75
76
77
78
/***
* libccd
* ---------------------------------
* Copyright (c)2010 Daniel Fiser <[email protected]>
*
*
* This file is part of libccd.
*
* Distributed under the OSI-approved BSD License (the "License");
* see accompanying file BDS-LICENSE for details or see
* <http://www.opensource.org/licenses/bsd-license.php>.
*
* This software is distributed WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the License for more information.
*/
#ifndef __CCD_COMPILER_H__
#define __CCD_COMPILER_H__
#include <stddef.h>
#define ccd_offsetof(TYPE, MEMBER) offsetof(TYPE, MEMBER)
#define ccd_container_of(ptr, type, member) \
(type *)( (char *)ptr - ccd_offsetof(type, member))
/**
* Marks exported function.
*/
#ifdef _WIN32
# ifdef ccd_EXPORTS
# define _ccd_export __declspec(dllexport)
# else /* ccd_EXPORTS */
# define _ccd_export __declspec(dllimport)
# endif /* ccd_EXPORTS */
#else /* _WIN32 */
# define _ccd_export
#endif /* _WIN32 */
/**
* Marks inline function.
*/
#ifdef __GNUC__
# define _ccd_inline static inline __attribute__((always_inline))
#else /* __GNUC__ */
# define _ccd_inline static __inline
#endif /* __GNUC__ */
/**
* __prefetch(x) - prefetches the cacheline at "x" for read
* __prefetchw(x) - prefetches the cacheline at "x" for write
*/
#ifdef __GNUC__
# define _ccd_prefetch(x) __builtin_prefetch(x)
# define _ccd_prefetchw(x) __builtin_prefetch(x,1)
#else /* __GNUC__ */
# define _ccd_prefetch(x) ((void)0)
# define _ccd_prefetchw(x) ((void)0)
#endif /* __GNUC__ */
#ifdef __ICC
// disable unused parameter warning
# pragma warning(disable:869)
// disable annoying "operands are evaluated in unspecified order" warning
# pragma warning(disable:981)
#endif /* __ICC */
#ifdef _MSC_VER
// disable unsafe function warning
# define _CRT_SECURE_NO_WARNINGS
#endif /* _MSC_VER */
#endif /* __CCD_COMPILER_H__ */