1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

builtin: support -d trace_vmemset, -d trace_vmemcmp, -d trace_vmemmove and -d trace_vmemcpy too

This commit is contained in:
Delyan Angelov 2022-12-22 20:05:08 +02:00
parent b67705f568
commit 8f8a186158
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -19,6 +19,9 @@ pub fn vstrlen_char(s &char) int {
// areas do overlap. vmemcpy returns a pointer to `dest`.
[inline; unsafe]
pub fn vmemcpy(dest voidptr, const_src voidptr, n isize) voidptr {
$if trace_vmemcpy ? {
C.fprintf(C.stderr, c'vmemcpy dest: %p src: %p n: %6ld\n', dest, const_src, n)
}
unsafe {
return C.memcpy(dest, const_src, n)
}
@ -31,6 +34,9 @@ pub fn vmemcpy(dest voidptr, const_src voidptr, n isize) voidptr {
// to `dest`. vmemmove returns a pointer to `dest`.
[inline; unsafe]
pub fn vmemmove(dest voidptr, const_src voidptr, n isize) voidptr {
$if trace_vmemmove ? {
C.fprintf(C.stderr, c'vmemmove dest: %p src: %p n: %6ld\n', dest, const_src, n)
}
unsafe {
return C.memmove(dest, const_src, n)
}
@ -50,6 +56,9 @@ pub fn vmemmove(dest voidptr, const_src voidptr, n isize) voidptr {
// this.
[inline; unsafe]
pub fn vmemcmp(const_s1 voidptr, const_s2 voidptr, n isize) int {
$if trace_vmemcmp ? {
C.fprintf(C.stderr, c'vmemcmp s1: %p s2: %p n: %6ld\n', const_s1, const_s2, n)
}
unsafe {
return C.memcmp(const_s1, const_s2, n)
}
@ -59,6 +68,9 @@ pub fn vmemcmp(const_s1 voidptr, const_s2 voidptr, n isize) int {
// with the constant byte `c`. It returns a pointer to the memory area `s`.
[inline; unsafe]
pub fn vmemset(s voidptr, c int, n isize) voidptr {
$if trace_vmemset ? {
C.fprintf(C.stderr, c'vmemset s: %p c: %d n: %6ld\n', s, c, n)
}
unsafe {
return C.memset(s, c, n)
}