CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
Toggle main menu visibility
Loading...
Searching...
No Matches
sdk
include
strings.h
1
// Copyright Microsoft and CHERIoT Contributors.
2
// SPDX-License-Identifier: MIT
3
4
#ifndef _STRINGS_H_
5
#define _STRINGS_H_
6
7
#include <cdefs.h>
8
#include <stddef.h>
9
#include <stdint.h>
10
11
__BEGIN_DECLS
12
#if defined(__riscv_zbb)
13
// If the the bitmanipulation extension is available then use the clang builtins
14
// as these will compile to a single instruction.
15
[[clang::always_inline]]
size_t
clz(uint32_t x)
16
{
17
return
__builtin_clz(x);
18
}
19
[[clang::always_inline]]
size_t
ctz(uint32_t x)
20
{
21
return
__builtin_ctz(x);
22
}
23
#else
24
// otherwise call the functions in arith64.c (saves space vs expanded builtin)
25
int
__cheri_libcall __ctzsi2(uint32_t a) __asm__(
"__ctzsi2"
);
26
int
__cheri_libcall __clzsi2(uint32_t a) __asm__(
"__clzsi2"
);
27
[[clang::always_inline]]
size_t
clz(uint32_t x)
28
{
29
return
__clzsi2(x);
30
}
31
[[clang::always_inline]]
size_t
ctz(uint32_t x)
32
{
33
return
__ctzsi2(x);
34
}
35
#endif
36
__END_DECLS
37
38
#endif
// _STRINGS_H_
Generated by
1.18.0