162306a36Sopenharmony_ci/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Minimal errno definitions for NOLIBC
462306a36Sopenharmony_ci * Copyright (C) 2017-2022 Willy Tarreau <w@1wt.eu>
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#ifndef _NOLIBC_ERRNO_H
862306a36Sopenharmony_ci#define _NOLIBC_ERRNO_H
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#include <asm/errno.h>
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#ifndef NOLIBC_IGNORE_ERRNO
1362306a36Sopenharmony_ci#define SET_ERRNO(v) do { errno = (v); } while (0)
1462306a36Sopenharmony_ciint errno __attribute__((weak));
1562306a36Sopenharmony_ci#else
1662306a36Sopenharmony_ci#define SET_ERRNO(v) do { } while (0)
1762306a36Sopenharmony_ci#endif
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci/* errno codes all ensure that they will not conflict with a valid pointer
2162306a36Sopenharmony_ci * because they all correspond to the highest addressable memory page.
2262306a36Sopenharmony_ci */
2362306a36Sopenharmony_ci#define MAX_ERRNO 4095
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci/* make sure to include all global symbols */
2662306a36Sopenharmony_ci#include "nolibc.h"
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci#endif /* _NOLIBC_ERRNO_H */
29