blob: 3bd4a702ee70999e1bcc87db17abe214bb39ff27 [file] [log] [blame]
Antonio Nino Diaz1b465f82018-08-13 19:51:26 +01001/*
Manish V Badarkhecc9f3932025-01-21 10:27:45 +00002 * Copyright (c) 2018-2025, Arm Limited and Contributors. All rights reserved.
Antonio Nino Diaz1b465f82018-08-13 19:51:26 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef CDEFS_H
8#define CDEFS_H
9
10#define __dead2 __attribute__((__noreturn__))
11#define __deprecated __attribute__((__deprecated__))
12#define __packed __attribute__((__packed__))
13#define __used __attribute__((__used__))
14#define __unused __attribute__((__unused__))
Yann Gautierc92490b2022-08-29 09:33:46 +020015#define __maybe_unused __attribute__((__unused__))
Antonio Nino Diaz1b465f82018-08-13 19:51:26 +010016#define __aligned(x) __attribute__((__aligned__(x)))
17#define __section(x) __attribute__((__section__(x)))
Andre Przywara108e30b2023-02-21 12:05:29 +000018#define __fallthrough __attribute__((__fallthrough__))
Boyan Karatotevc25cf632025-04-07 15:23:09 +010019#define __noinline __attribute__((__noinline__))
Boyan Karatotevb34fd002025-04-02 11:02:44 +010020#define __no_pauth __attribute__((target("branch-protection=none")))
Daniel Boulby468f0d72018-09-18 11:45:51 +010021#if RECLAIM_INIT_CODE
22/*
23 * Add each function to a section that is unique so the functions can still
Boyan Karatotevc25cf632025-04-07 15:23:09 +010024 * be garbage collected.
25 *
26 * NOTICE: for this to work, these functions will NOT be inlined.
27 * TODO: the noinline attribute can be removed if RECLAIM_INIT_CODE is made
28 * platform agnostic and called after bl31_main(). Then, top-level functions
29 * (those that can't be inlined like bl31_main()) can be annotated with __init
30 * and noinline can be removed.
Daniel Boulby468f0d72018-09-18 11:45:51 +010031 */
Boyan Karatotevc25cf632025-04-07 15:23:09 +010032#define __init __section(".text.init." __FILE__ "." __XSTRING(__LINE__)) __noinline
Daniel Boulby468f0d72018-09-18 11:45:51 +010033#else
34#define __init
35#endif
Antonio Nino Diaz1b465f82018-08-13 19:51:26 +010036
37#define __printflike(fmtarg, firstvararg) \
38 __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
39
40#define __weak_reference(sym, alias) \
41 __asm__(".weak alias"); \
42 __asm__(".equ alias, sym")
43
44#define __STRING(x) #x
45#define __XSTRING(x) __STRING(x)
46
Manish V Badarkhecc9f3932025-01-21 10:27:45 +000047#define __predict_true(exp) (exp)
48#define __predict_false(exp) (exp)
49
Antonio Nino Diaz1b465f82018-08-13 19:51:26 +010050#endif /* CDEFS_H */