kern/lib/c/include/strings.h
fef 0f9e9f91a6
libc: port FreeBSD string library routines
Oh my fucking god this was by far the most awful
and boring and tedious day in my entire life.

Also, dear FreeBSD people: please don't sue me.
I tried really hard to comply with all the
copyright stuff, but it is absolutely possible i
made a mistake.  Just DM me and i'll do everything
in my power to fix it, even if that means
releasing entire portions of GayBSD under the BSD
license.  I don't care, i just want stuff to work.

(i'm including this message to use it as possible
evidence in case i get sued to show my good will)
2021-10-10 05:41:16 +02:00

80 lines
2.2 KiB
C

/* See the end of this file for copyright and license terms. */
#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 */
/*
* This file is part of GayBSD.
* Copyright (c) 2021 fef <owo@fef.moe>.
*
* GayBSD is nonviolent software: you may only use, redistribute, and/or
* modify it under the terms of the Cooperative Nonviolent Public License
* (CNPL) as found in the LICENSE file in the source code root directory
* or at <https://git.pixie.town/thufie/npl-builder>; either version 7
* of the license, or (at your option) any later version.
*
* GayBSD comes with ABSOLUTELY NO WARRANTY, to the extent
* permitted by applicable law. See the CNPL for details.
*/