Skip to content

[WIP #3844 #3767] update std.c and std.os.linux functions to use null-terminated pointer types #3899

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

Closed
wants to merge 0 commits into from

Conversation

raulgrell
Copy link
Contributor

@raulgrell raulgrell commented Dec 13, 2019

Shoutout to @stratact for the first attempt!

I'm fairly confident the signatures are correct. Are there any tests that need to be created?

Closes #3884

lib/std/c.zig Outdated
pub extern "c" fn symlink(existing: [*:0]const u8, new: [*:0]const u8) c_int;
pub extern "c" fn rename(old: [*:0]const u8, new: [*:0]const u8) c_int;
pub extern "c" fn chdir(path: [*:0]const u8) c_int;
pub extern "c" fn execve(path: [*:0]const u8, argv: [*:0]const ?[*]const u8, envp: [*:0]const ?[*]const u8) c_int;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this be:
pub extern "c" fn execve(path: [:0]const u8, argv: [:0]const ?[]const u8, envp: [:0]const ?[]const u8) c_int;
or
pub extern "c" fn execve(path: [
:0]const u8, argv: [:0]const [:0]const u8, envp: [:0]const [:0]const u8) c_int;

Copy link
Member

Choose a reason for hiding this comment

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

I think you want something like this:

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

That is, an "array" of null-terminated strings, where the last string is always null.

@andrewrk
Copy link
Member

You might have to fix some callsites, which may involve some @ptrCast until #3770 is implemented.

@raulgrell
Copy link
Contributor Author

I'm going through the corresponding function in std.os.linux - I'll make sure it's all updated.

It should eventually close #3767

@raulgrell raulgrell changed the title #3844 update std.c functions to use null-terminated pointer types [WIP #3844 #3767] update std.c and std.os.linux functions to use null-terminated pointer types Dec 13, 2019
@raulgrell raulgrell closed this Dec 13, 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.

update std.c functions to use null-terminated pointer types
3 participants