summaryrefslogtreecommitdiff
path: root/libpam/include/pam_cc_compat.h
blob: c43989f7e0c71ed8a5d96954a67dc81035a4793c (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
/*
 * Copyright (c) 2020 Dmitry V. Levin <ldv@altlinux.org>
 */

#ifndef PAM_CC_COMPAT_H
#define PAM_CC_COMPAT_H

#include "config.h"
#include <security/_pam_types.h>

#if defined __clang__ && defined __clang_major__ && defined __clang_minor__
# define PAM_CLANG_PREREQ(maj, min)					\
	((__clang_major__ << 16) + __clang_minor__ >= ((maj) << 16) + (min))
#else
# define PAM_CLANG_PREREQ(maj, min)	0
#endif

#if PAM_GNUC_PREREQ(2, 7)
# define PAM_ATTRIBUTE_ALIGNED(arg)	__attribute__((__aligned__(arg)))
#else
# define PAM_ATTRIBUTE_ALIGNED(arg)	/* empty */
#endif

#if PAM_GNUC_PREREQ(4, 6)
# define DIAG_PUSH_IGNORE_CAST_QUAL					\
	_Pragma("GCC diagnostic push");					\
	_Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
# define DIAG_POP_IGNORE_CAST_QUAL					\
	_Pragma("GCC diagnostic pop")
# define DIAG_PUSH_IGNORE_CAST_ALIGN					\
	_Pragma("GCC diagnostic push");					\
	_Pragma("GCC diagnostic ignored \"-Wcast-align\"")
# define DIAG_POP_IGNORE_CAST_ALIGN					\
	_Pragma("GCC diagnostic pop")
#elif PAM_CLANG_PREREQ(2, 6)
# define DIAG_PUSH_IGNORE_CAST_QUAL					\
	_Pragma("clang diagnostic push");				\
	_Pragma("clang diagnostic ignored \"-Wcast-qual\"")
# define DIAG_POP_IGNORE_CAST_QUAL					\
	_Pragma("clang diagnostic pop")
# define DIAG_PUSH_IGNORE_CAST_ALIGN					\
	_Pragma("clang diagnostic push");				\
	_Pragma("clang diagnostic ignored \"-Wcast-align\"")
# define DIAG_POP_IGNORE_CAST_ALIGN					\
	_Pragma("clang diagnostic pop")
#else
# define DIAG_PUSH_IGNORE_CAST_QUAL	/* empty */
# define DIAG_POP_IGNORE_CAST_QUAL	/* empty */
# define DIAG_PUSH_IGNORE_CAST_ALIGN	/* empty */
# define DIAG_POP_IGNORE_CAST_ALIGN	/* empty */
#endif

#endif /* PAM_CC_COMPAT_H */