xref: /openbmc/linux/tools/include/nolibc/errno.h (revision 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e)
145a794bfSWilly Tarreau /* SPDX-License-Identifier: LGPL-2.1 OR MIT */
245a794bfSWilly Tarreau /*
345a794bfSWilly Tarreau  * Minimal errno definitions for NOLIBC
445a794bfSWilly Tarreau  * Copyright (C) 2017-2022 Willy Tarreau <w@1wt.eu>
545a794bfSWilly Tarreau  */
645a794bfSWilly Tarreau 
745a794bfSWilly Tarreau #ifndef _NOLIBC_ERRNO_H
845a794bfSWilly Tarreau #define _NOLIBC_ERRNO_H
945a794bfSWilly Tarreau 
1045a794bfSWilly Tarreau #include <asm/errno.h>
1145a794bfSWilly Tarreau 
1245a794bfSWilly Tarreau #ifndef NOLIBC_IGNORE_ERRNO
1345a794bfSWilly Tarreau #define SET_ERRNO(v) do { errno = (v); } while (0)
14*1caa1154SWilly Tarreau int errno __attribute__((weak));
1545a794bfSWilly Tarreau #else
1645a794bfSWilly Tarreau #define SET_ERRNO(v) do { } while (0)
1745a794bfSWilly Tarreau #endif
1845a794bfSWilly Tarreau 
1945a794bfSWilly Tarreau 
2045a794bfSWilly Tarreau /* errno codes all ensure that they will not conflict with a valid pointer
2145a794bfSWilly Tarreau  * because they all correspond to the highest addressable memory page.
2245a794bfSWilly Tarreau  */
2345a794bfSWilly Tarreau #define MAX_ERRNO 4095
2445a794bfSWilly Tarreau 
2555abdd1fSWilly Tarreau /* make sure to include all global symbols */
2655abdd1fSWilly Tarreau #include "nolibc.h"
2755abdd1fSWilly Tarreau 
2845a794bfSWilly Tarreau #endif /* _NOLIBC_ERRNO_H */
29