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

std: Replace use of stage1 function pointers #12761

Merged
merged 4 commits into from
Sep 29, 2022

Conversation

ominitay
Copy link
Contributor

@ominitay ominitay commented Sep 6, 2022

Many parts of std still use stage1-style function pointers. This PR removes all instances of this, replacing them with the use of std.meta.FnPtr. Additionally, manually-written if statements have been replaced with FnPtr for clarity, conciseness, and to be guarantee detection and removal when stage1 support is removed from std.

I'll give this another check over before it's ready to merge.

Copy link
Contributor

@matu3ba matu3ba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relevant search entries (escaping missing): grep 'builtin.zig_backend', grep '.stage1', grep ': fn (', grep '*const fn (', grep '*fn ('

  1. The alignment is also missing in a few other places.
  2. Can you comment on where alignment is necessary and where not? I do see align(8) and align(1) in a couple of places. Might be worth double checking those for ABI problems, when there are many eyes on this change anyway.

lib/std/zig/c_translation.zig Show resolved Hide resolved
lib/std/os/linux/arm-eabi.zig Show resolved Hide resolved
@hazeycode
Copy link
Contributor

related: #12813

@ominitay
Copy link
Contributor Author

This should be ready to merge, I'll just rebase to get the checks to run correctly.

@ominitay ominitay force-pushed the fix-function-pointers branch from e8699ce to 10c76e3 Compare September 11, 2022 19:32
@ominitay
Copy link
Contributor Author

Looks like I missed a few function pointers for Windows, will fix them.

@ominitay ominitay force-pushed the fix-function-pointers branch 3 times, most recently from a0b47b3 to bf23dde Compare September 16, 2022 12:30
@ominitay
Copy link
Contributor Author

Tests passing, ready to be merged.

@ominitay
Copy link
Contributor Author

Found a couple of mistakes in this PR, and also a merge conflict, will get those fixed. Please merge soon!

@ominitay ominitay force-pushed the fix-function-pointers branch from bf23dde to f752dee Compare September 28, 2022 19:31
@ominitay
Copy link
Contributor Author

@andrewrk Can this be merged before it goes stale again?

@Vexu Vexu merged commit 295451d into ziglang:master Sep 29, 2022
@ominitay ominitay deleted the fix-function-pointers branch September 29, 2022 19:00
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.

4 participants