aboutsummaryrefslogtreecommitdiff
path: root/arch/all/compiler-renesas/bits/compiler.h
blob: 591e36ed35dc03618be5af6fb96bea46a9b2aedd (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
/* ****************************************************************************
 * compiler.h -- SHC identification macros.
 *
 * Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
 *
 * This file is part of the 'all/compiler-renesas' module in libcarrot, an
 * experimental modular libc project.
 *
 * This file is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option)
 * any later version.
 *
 * This file is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Lesser Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this file. If not, see <http://www.gnu.org/licenses/>.
 * ************************************************************************* */
/* Identify the compiler. */
#if !defined(__HITACHI__)
# error "This header should only be used with the Renesas C/C++ Compiler!"
#endif
/* ************************************************************************* */
/*  Detection and version checking                                           */
/* ************************************************************************* */
/* In case you didn't know, Renesas bought Hitachi in 2003 (?).
 * That's why they changed the __HITACHI__ compiler defined macro to
 * __RENESAS__, although they're also defining __HITACHI__ (and the
 * associated version macro). This is just in case. */

#if defined(__RENESAS__) && !defined(__HITACHI__)
# define __HITACHI__         __RENESAS__
# define __HITACHI_VERSION__ __RENESAS_VERSION__
#endif
#if defined(__HITACHI__) && !defined(__RENESAS__)
# define __RENESAS__         __HITACHI__
# define __RENESAS_VERSION__ __HITACHI_VERSION__
#endif

/* Also, this macro is here for quick version checking.
 * It is inspired from glibc's `__GNUC_PREREQ` macro. */

#ifdef  __RENESAS_PREREQ
# undef __RENESAS_PREREQ
#endif
#if defined(__HITACHI__) && __HITACHI_VERSION__ >= 0xFFFF
# define __RENESAS_PREREQ(_MAJ, _MIN) \
	(__HITACHI_VERSION__ >= ((_MAJ) << 24) + ((_MIN) << 16))
#elif defined(__HITACHI__)
# define __RENESAS_PREREQ(_MAJ, _MIN) \
	(__HITACHI_VERSION__ >= ((_MAJ) << 8) + (_MIN))
#endif