66 lines
1.7 KiB
C
66 lines
1.7 KiB
C
/* Copyright (C) 2021,2022 fef <owo@fef.moe>. All rights reserved. */
|
|
|
|
#pragma once
|
|
|
|
#include <gay/cdefs.h>
|
|
#include <gay/types.h>
|
|
|
|
#if __BSD_VISIBLE || _POSIX_C_SOURCE <= 200112L
|
|
__pure int bcmp(const void *, const void *, usize); /* LEGACY */
|
|
void bcopy(const void *, void *, usize); /* LEGACY */
|
|
void bzero(void *, usize); /* LEGACY */
|
|
__pure char *index(const char *, int); /* LEGACY */
|
|
__pure char *rindex(const char *, int); /* LEGACY */
|
|
#endif /* __BSD_VISIBLE || _POSIX_C_SOURCE <= 200112L */
|
|
|
|
#if _GAY_SOURCE >= 202109L || __BSD_VISIBLE
|
|
|
|
/**
|
|
* @brief Find the first set bit in a bitmask.
|
|
*
|
|
* @param mask The bitmask
|
|
* @return The 0-based index of the first 1 bit, or 0 if `mask` was zero.
|
|
*/
|
|
__pure2 int ffs(int mask);
|
|
|
|
/**
|
|
* @brief Find the first set bit in a bitmask.
|
|
*
|
|
* @param mask The bitmask
|
|
* @return The 0-based index of the first 1 bit, or 0 if `mask` was zero.
|
|
*/
|
|
__pure2 int ffsl(long mask);
|
|
|
|
/**
|
|
* @brief Find the first set bit in a bitmask.
|
|
*
|
|
* @param mask The bitmask
|
|
* @return The 0-based index of the first 1 bit, or 0 if `mask` was zero.
|
|
*/
|
|
__pure2 int ffsll(long long mask);
|
|
|
|
/**
|
|
* @brief Find the last set bit in a bitmask.
|
|
*
|
|
* @param mask The bitmask
|
|
* @return The 0-based index of the last 1 bit, or 0 if `mask` was zero.
|
|
*/
|
|
__pure2 int fls(int mask);
|
|
|
|
/**
|
|
* @brief Find the last set bit in a bitmask.
|
|
*
|
|
* @param mask The bitmask
|
|
* @return The 0-based index of the last 1 bit, or 0 if `mask` was zero.
|
|
*/
|
|
__pure2 int flsl(long mask);
|
|
|
|
/**
|
|
* @brief Find the last set bit in a bitmask.
|
|
*
|
|
* @param mask The bitmask
|
|
* @return The 0-based index of the last 1 bit, or 0 if `mask` was zero.
|
|
*/
|
|
__pure2 int flsll(long long mask);
|
|
|
|
#endif /* _GAY_SOURCE >= 202109L || __BSD_VISIBLE */
|