Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Simon Glass | 00e9e6d | 2016-05-08 16:55:17 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2014 Samsung Electronics |
| 4 | * Przemyslaw Marczak <p.marczak@samsung.com> |
Simon Glass | 00e9e6d | 2016-05-08 16:55:17 -0600 | [diff] [blame] | 5 | */ |
Wolfgang Denk | 65cd3fa | 2010-06-12 00:19:46 +0200 | [diff] [blame] | 6 | #ifndef _ERRNO_H |
Simon Glass | 00e9e6d | 2016-05-08 16:55:17 -0600 | [diff] [blame] | 7 | #define _ERRNO_H |
Wolfgang Denk | 65cd3fa | 2010-06-12 00:19:46 +0200 | [diff] [blame] | 8 | |
Masahiro Yamada | 5d97dff | 2016-09-21 11:28:57 +0900 | [diff] [blame] | 9 | #include <linux/errno.h> |
Wolfgang Denk | 65cd3fa | 2010-06-12 00:19:46 +0200 | [diff] [blame] | 10 | |
Marek BehĂșn | be1e77f | 2021-05-20 13:24:05 +0200 | [diff] [blame] | 11 | #ifdef __SANDBOX__ |
| 12 | #define __errno_asm_label asm("__u_boot_errno") |
| 13 | #else |
| 14 | #define __errno_asm_label |
| 15 | #endif |
| 16 | |
| 17 | extern int errno __errno_asm_label; |
Wolfgang Denk | 65cd3fa | 2010-06-12 00:19:46 +0200 | [diff] [blame] | 18 | |
| 19 | #define __set_errno(val) do { errno = val; } while (0) |
| 20 | |
Heinrich Schuchardt | f279e1d | 2019-10-06 13:58:57 +0200 | [diff] [blame] | 21 | /** |
| 22 | * errno_str() - get description for error number |
| 23 | * |
| 24 | * @errno: error number (negative in case of error) |
| 25 | * Return: string describing the error. If CONFIG_ERRNO_STR is not |
| 26 | * defined an empty string is returned. |
| 27 | */ |
Simon Glass | 64aefc4 | 2022-02-28 12:08:21 -0700 | [diff] [blame^] | 28 | #if CONFIG_IS_ENABLED(ERRNO_STR) |
Przemyslaw Marczak | 59345b1 | 2014-10-08 22:48:37 +0200 | [diff] [blame] | 29 | const char *errno_str(int errno); |
Simon Glass | 862887d | 2016-05-08 16:55:18 -0600 | [diff] [blame] | 30 | #else |
Heinrich Schuchardt | f279e1d | 2019-10-06 13:58:57 +0200 | [diff] [blame] | 31 | static const char error_message[] = ""; |
| 32 | |
Simon Glass | 862887d | 2016-05-08 16:55:18 -0600 | [diff] [blame] | 33 | static inline const char *errno_str(int errno) |
| 34 | { |
Heinrich Schuchardt | f279e1d | 2019-10-06 13:58:57 +0200 | [diff] [blame] | 35 | return error_message; |
Simon Glass | 862887d | 2016-05-08 16:55:18 -0600 | [diff] [blame] | 36 | } |
Przemyslaw Marczak | 59345b1 | 2014-10-08 22:48:37 +0200 | [diff] [blame] | 37 | #endif |
Wolfgang Denk | 65cd3fa | 2010-06-12 00:19:46 +0200 | [diff] [blame] | 38 | #endif /* _ERRNO_H */ |