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.posix.iovec: use .base and .len instead of .iov_base and .iov_len #19768

Merged
merged 1 commit into from
Apr 28, 2024

Conversation

truemedian
Copy link
Contributor

@truemedian truemedian commented Apr 25, 2024

Also uses the opportunity to apply this change to windows' WSABUF.

This removes the posix-y field names in favor of more concise names.

@@ -173,13 +173,13 @@ pub const W_OK = system.W_OK;
pub const X_OK = system.X_OK;

pub const iovec = extern struct {
iov_base: [*]u8,
iov_len: usize,
ptr: [*]u8,
Copy link
Member

Choose a reason for hiding this comment

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

The naming convention is to keep the posix name, but remove the prefix. I understand that this type fulfills the same purpose as a Zig language slice, however, I don't see why that means an exception to the naming convention.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I decided to use the zig naming here made more sense because the primary goal was to be able to interop between posix's iovec and windows's WSABUF. posix calls it base, windows calls it buf, so I decided to adopt the zig name here.

Would you prefer to use base for posix.iovec and WSABUF instead of ptr?

Copy link
Member

Choose a reason for hiding this comment

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

WSABUF should continue to use len and buf, matching the API definitions in windows.h, and iovec should continue to use base and len, matching the POSIX API definitions.

The cross-platform abstractions offered by the zig standard library must be implemented on top of that.

@truemedian truemedian force-pushed the iovec-ptr-len branch 3 times, most recently from 5686f7a to 4d6a6a6 Compare April 26, 2024 21:09
@truemedian truemedian changed the title std.posix.iovec: use .ptr and .len instead of .iov_base and .iov_len std.posix.iovec: use .base and .len instead of .iov_base and .iov_len Apr 26, 2024
@andrewrk andrewrk added breaking Implementing this issue could cause existing code to no longer compile or have different behavior. standard library This issue involves writing Zig code for the standard library. release notes This PR should be mentioned in the release notes. labels Apr 28, 2024
@andrewrk andrewrk merged commit aecd9cc into ziglang:master Apr 28, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Implementing this issue could cause existing code to no longer compile or have different behavior. release notes This PR should be mentioned in the release notes. standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants