rabbitizer/include/common/Utils.h

39 lines
993 B
C
Raw Normal View History

2022-06-04 00:19:58 +00:00
/* SPDX-FileCopyrightText: © 2022 Decompollaborate */
/* SPDX-License-Identifier: MIT */
2022-06-04 02:39:10 +00:00
#ifndef RABBITIZER_UTILS_H
#define RABBITIZER_UTILS_H
2022-06-04 05:24:59 +00:00
#include <stddef.h>
2022-06-04 02:39:10 +00:00
#include <stdint.h>
2022-06-04 00:19:58 +00:00
2022-06-06 05:59:38 +00:00
#if !defined(__GNUC__) && !defined(__clang__)
#define __attribute__(x)
#endif
#if __STDC_VERSION__ >= 202300L
#define DEPRECATED(reason) [[deprecated (reason)]]
#define FALLTHROUGH [[fallthrough]]
#define NODISCARD(reason) [[nodiscard (reason)]]
#define NORETURN [[noreturn]]
#define UNUSED [[maybe_unused]]
#else
#define DEPRECATED(reason) __attribute__((deprecated (reason)))
#define FALLTHROUGH __attribute__((fallthrough))
#define NODISCARD(reason) __attribute__((warn_unused_result))
#define NORETURN _Noreturn
#define UNUSED __attribute__((unused))
#endif
#define PURE __attribute__((pure))
2022-06-04 00:19:58 +00:00
#define ARRAY_COUNT(arr) (sizeof(arr) / sizeof(arr[0]))
2022-06-04 02:39:10 +00:00
int32_t RabbitizerUtils_From2Complement(uint32_t number, int bits);
2022-06-04 05:24:59 +00:00
size_t RabbitizerUtils_CharFill(char *dst, int count, char fillchar);
2022-06-04 02:39:10 +00:00
2022-06-04 00:19:58 +00:00
#endif