Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change size-related usages of int -> size_t #29

Open
apsun opened this issue Oct 16, 2021 · 0 comments
Open

Change size-related usages of int -> size_t #29

apsun opened this issue Oct 16, 2021 · 0 comments

Comments

@apsun
Copy link
Owner

apsun commented Oct 16, 2021

Arguments for doing this:

  • Casting sizeof() everywhere is ugly (counterpoint: maybe this means we should make a #define isizeof(x) ((int)sizeof(x)) macro instead?
  • Improve standards conformance of libc string functions (counterpoint: we use char instead of int and some non-standard function signatures already)
  • Compiler builtins assume memcpy/memmove/memset take size_t and synthesize calls accordingly, so on the off chance we ever want to support 64-bit, we'll get mismatched argument types (although I guess since x64 uses fastcall, it probably won't explode immediately?)
  • malloc() and friends are odd-ones-out (since myalloc was originally an external project)
  • I think getting the OS to compile with -Wconversion would be pretty cool, and using int makes it a lot harder

I don't want to change the return type of syscalls (for uniformity/OCD reasons); this effectively means that all syscalls are still limited to reading 2GB at a time. Which is fine; we need to limit the range to half of size_t anyways since the return value needs to encode an error bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant