mailing list of musl libc
 help / color / mirror / code / Atom feed
blob 8e36d0f9275d4879ab6880bc3197278a273768a7 886 bytes (raw)
name: src/string/riscv64/memset_dispatch.c 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 
#include <stddef.h>
#include <stdint.h>
#include <sys/auxv.h>
#include "libc.h"

void *__memset_scalar(void *s, int c, size_t n);
void *__memset_vect(void *s, int c, size_t n);

/* memset function pointer, runtime-dispatched based on RVV support */
__attribute__((visibility("hidden")))
#ifndef __riscv_vector
void *(*__memset_ptr)(void *, int, size_t) = __memset_scalar;
#else
void *(*__memset_ptr)(void *, int, size_t) = __memset_vect;
#endif

void *memset(void *s, int c, size_t n)
{
	return __memset_ptr(s, c, n);
}

static __inline int __has_rvv_via_hwcap(void)
{
	const unsigned long V_bit = (1ul << ('V' - 'A'));
	unsigned long hwcap = __getauxval(AT_HWCAP);
	return (hwcap & V_bit) != 0;
}

__attribute__((visibility("hidden")))
void __init_riscv_string_optimizations(void)
{
	if (__has_rvv_via_hwcap())
		__memset_ptr = __memset_vect;
	else
		__memset_ptr = __memset_scalar;
}

debug log:

solving 8e36d0f9 ...
found 8e36d0f9 in https://inbox.vuxu.org/musl/20251030120908.47909-2-pincheng.plct@isrc.iscas.ac.cn/ ||
	https://inbox.vuxu.org/musl/20251113161518.57357-2-pincheng.plct@isrc.iscas.ac.cn/

applying [1/1] https://inbox.vuxu.org/musl/20251030120908.47909-2-pincheng.plct@isrc.iscas.ac.cn/
diff --git a/src/string/riscv64/memset_dispatch.c b/src/string/riscv64/memset_dispatch.c
new file mode 100644
index 00000000..8e36d0f9

Checking patch src/string/riscv64/memset_dispatch.c...
Applied patch src/string/riscv64/memset_dispatch.c cleanly.

skipping https://inbox.vuxu.org/musl/20251113161518.57357-2-pincheng.plct@isrc.iscas.ac.cn/ for 8e36d0f9
index at:
100644 8e36d0f9275d4879ab6880bc3197278a273768a7	src/string/riscv64/memset_dispatch.c

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).