Skip to content

[#3844 + #3767] update std.c and std.os.linux to use null-terminated pointer types #3900

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

Merged
merged 8 commits into from
Dec 17, 2019

Conversation

raulgrell
Copy link
Contributor

@raulgrell raulgrell commented Dec 13, 2019

Resubmitting the pull request in a separate branch, and as a draft. Apologies for the clutter.

I wasn't sure how to handle the execve function.

error: integer value 0 cannot be coerced to type '[*]const u8'
pub fn execve(path: [*:0]const u8, argv: [*:0]const ?[*]const u8, envp: [*:0]const ?[*]const u8) usize

error: expected type '[*:0]const u8', found 'comptime_int'
pub fn execve(path: [*:0]const u8, argv: [*:0]const [*:0]const u8, envp: [*:0]const [*:0]const u8) usize

Thanks to @fengb I settled on

pub extern "c" fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) c_int;

@raulgrell raulgrell marked this pull request as ready for review December 15, 2019 00:30
@raulgrell
Copy link
Contributor Author

raulgrell commented Dec 15, 2019

zig build test-std -Dskip-release ran with no issues. The full test suite is huge. I was convinced I was doing something wrong until I realized it was my VM that was running out of RAM.

Thanks to @tiehuis for also pointing me to the right signature for execve.

EDIT: Let me know if I should squash the commits

@raulgrell
Copy link
Contributor Author

Thanks for the speedy review.

In one commit, I left the port cast in. In the next, I added a allocPrintCstr function that returns a null terminated slice. Not sure it's in the right place or if it's the best name.

Copy link
Contributor

@daurnimator daurnimator left a comment

Choose a reason for hiding this comment

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

LGTM

@andrewrk
Copy link
Member

Still WIP?

@raulgrell raulgrell changed the title [WIP #3844 + #3767] update std.c and std.os.linux to use null-terminated pointer types [#3844 + #3767] update std.c and std.os.linux to use null-terminated pointer types Dec 17, 2019
@raulgrell
Copy link
Contributor Author

No longer WIP!

@andrewrk andrewrk merged commit 62c8174 into ziglang:master Dec 17, 2019
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.

3 participants