Skip to content

std.elf: stronger typing #23600

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dotcarmen
Copy link
Contributor

@dotcarmen dotcarmen commented Apr 18, 2025

supercedes #23178

This PR attempts to make std.elf a bit easier for API consumers:

  1. many constants have instead been converted to bitfields or enums where compatible and as appropriate
  2. ELF32_* and ELF64_* types have been moved/renamed into elf32 and elf64 namespaces
  3. all pub const x = switch (@sizeOf(usize)) { ... }; declarations have been consolidated into a single pub const native_elf which selects either elf32 or elf64

note: to optimize the reviewer's experience, i'll keep this PR as 2 commits: the first commit will be the API changes to std.elf, and the 2nd commit will be downstream changes

@dotcarmen
Copy link
Contributor Author

yes i know i still have to update references elsewhere in the codebase :)

2 questions i have:

  1. is it preferred to rename enum fields to lower case?
  2. is it preferred to have more descriptive names for the various types? (eg ET -> FileType)

@dotcarmen
Copy link
Contributor Author

also note that i didn't convert all groups of values to enums/bitfields - for example, AT_ constants can be compared against either u32 or u64 values. if it's preferred that these are also type-ified, I'd be happy to include that in this pr

@dotcarmen dotcarmen force-pushed the elf-stronger-typing branch 4 times, most recently from 3f37b69 to 4bf9545 Compare April 24, 2025 19:13
@dotcarmen dotcarmen force-pushed the elf-stronger-typing branch from 4bf9545 to 170ac8d Compare April 25, 2025 13:19
@dotcarmen dotcarmen force-pushed the elf-stronger-typing branch from 170ac8d to 63745ce Compare April 25, 2025 13:26
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

Successfully merging this pull request may close these issues.

1 participant