Antonio Nino Diaz | 1b465f8 | 2018-08-13 19:51:26 +0100 | [diff] [blame] | 1 | /* |
Manish V Badarkhe | cc9f393 | 2025-01-21 10:27:45 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2025, Arm Limited and Contributors. All rights reserved. |
Antonio Nino Diaz | 1b465f8 | 2018-08-13 19:51:26 +0100 | [diff] [blame] | 3 | * |
| 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 Gautier | c92490b | 2022-08-29 09:33:46 +0200 | [diff] [blame] | 15 | #define __maybe_unused __attribute__((__unused__)) |
Antonio Nino Diaz | 1b465f8 | 2018-08-13 19:51:26 +0100 | [diff] [blame] | 16 | #define __aligned(x) __attribute__((__aligned__(x))) |
| 17 | #define __section(x) __attribute__((__section__(x))) |
Andre Przywara | 108e30b | 2023-02-21 12:05:29 +0000 | [diff] [blame] | 18 | #define __fallthrough __attribute__((__fallthrough__)) |
Boyan Karatotev | c25cf63 | 2025-04-07 15:23:09 +0100 | [diff] [blame^] | 19 | #define __noinline __attribute__((__noinline__)) |
Daniel Boulby | 468f0d7 | 2018-09-18 11:45:51 +0100 | [diff] [blame] | 20 | #if RECLAIM_INIT_CODE |
| 21 | /* |
| 22 | * Add each function to a section that is unique so the functions can still |
Boyan Karatotev | c25cf63 | 2025-04-07 15:23:09 +0100 | [diff] [blame^] | 23 | * be garbage collected. |
| 24 | * |
| 25 | * NOTICE: for this to work, these functions will NOT be inlined. |
| 26 | * TODO: the noinline attribute can be removed if RECLAIM_INIT_CODE is made |
| 27 | * platform agnostic and called after bl31_main(). Then, top-level functions |
| 28 | * (those that can't be inlined like bl31_main()) can be annotated with __init |
| 29 | * and noinline can be removed. |
Daniel Boulby | 468f0d7 | 2018-09-18 11:45:51 +0100 | [diff] [blame] | 30 | */ |
Boyan Karatotev | c25cf63 | 2025-04-07 15:23:09 +0100 | [diff] [blame^] | 31 | #define __init __section(".text.init." __FILE__ "." __XSTRING(__LINE__)) __noinline |
Daniel Boulby | 468f0d7 | 2018-09-18 11:45:51 +0100 | [diff] [blame] | 32 | #else |
| 33 | #define __init |
| 34 | #endif |
Antonio Nino Diaz | 1b465f8 | 2018-08-13 19:51:26 +0100 | [diff] [blame] | 35 | |
| 36 | #define __printflike(fmtarg, firstvararg) \ |
| 37 | __attribute__((__format__ (__printf__, fmtarg, firstvararg))) |
| 38 | |
| 39 | #define __weak_reference(sym, alias) \ |
| 40 | __asm__(".weak alias"); \ |
| 41 | __asm__(".equ alias, sym") |
| 42 | |
| 43 | #define __STRING(x) #x |
| 44 | #define __XSTRING(x) __STRING(x) |
| 45 | |
Manish V Badarkhe | cc9f393 | 2025-01-21 10:27:45 +0000 | [diff] [blame] | 46 | #define __predict_true(exp) (exp) |
| 47 | #define __predict_false(exp) (exp) |
| 48 | |
Antonio Nino Diaz | 1b465f8 | 2018-08-13 19:51:26 +0100 | [diff] [blame] | 49 | #endif /* CDEFS_H */ |