Page MenuHomeFreeBSD

libc/string/bcopy.c: Use intptr_t as the copy type
ClosedPublic

Authored by arichardson on Apr 1 2021, 2:36 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 1, 1:16 PM
Unknown Object (File)
Thu, Oct 24, 3:00 AM
Unknown Object (File)
Sun, Oct 20, 3:50 AM
Unknown Object (File)
Oct 5 2024, 8:16 PM
Unknown Object (File)
Oct 2 2024, 8:22 PM
Unknown Object (File)
Oct 2 2024, 4:14 PM
Unknown Object (File)
Sep 30 2024, 6:08 AM
Unknown Object (File)
Sep 29 2024, 11:36 AM
Subscribers

Details

Summary

While most 64-bit architectures have an assembly implementation of this
file RISC-V does not. As we now copy 8 bytes instead of 4 it should speed
up RISC-V. Using intptr_t instead of int also allows using this file for
CHERI pure-capability code since trying to copy pointers using integer
loads/stores will invalidate pointers.

Obtained from: CheriBSD (partially)

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 38679
Build 35568: arc lint + arc unit

Event Timeline

intptr_t isn't sufficient for hybrid CHERI though, so we'd still need the diff to make it intcap_t downstream...

lib/libc/string/bcopy.c
104–105

I don't see why the void * casts are needed? Is this just because of bogus char -> intptr_t alignment warnings?

intptr_t isn't sufficient for hybrid CHERI though, so we'd still need the diff to make it intcap_t downstream...

Yes, but that diff can't really be upstreamed.

lib/libc/string/bcopy.c
104–105

Yeah, I'm trying to include this outside of libc and that means -Wcast-align is enabled.

lib/libc/string/bcopy.c
42–43

Add assert along this comment?

104–105

Is the line too long?

139

Why do you need these ?

lib/libc/string/bcopy.c
42–43

I could add that but I think if sizeof(intptr_t) is not a power-of-two, we would have much bigger problems.

Alternatively I could change the line below to !__is_aligned((t | (uintptr_t)dst), wsize), in which case Clang 10+ will give an error if it isn't.

104–105

Yes, will reformat.

139

Will drop those, I added that to allow including the file twice in the same source.

lib/libc/string/bcopy.c
42–43

Or drop the comment. It stating more or less trivial property IN CAPS definitely not matching our current approach to style.

arichardson marked 5 inline comments as done.

address review feedback

This revision is now accepted and ready to land.Apr 19 2021, 10:50 AM