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

Add socklen_t #62

Closed
dmik opened this issue Feb 14, 2020 · 3 comments
Closed

Add socklen_t #62

dmik opened this issue Feb 14, 2020 · 3 comments
Assignees

Comments

@dmik
Copy link
Contributor

dmik commented Feb 14, 2020

This is missing since long. We have __socklen_t which is an unsigned 32-bit integer (__uint32_t) and in place of socklen_t our headers use u_int in structs (eg and cmsghdr) and int in function calls. Ie for structs it’s completely safe to replace u_int with socklen_t while for functions some thinking is needed because of the difference in signedness.

As POSIX suggests, socklen_t should not be larger than 2^31-1 which is a 32 bit signed integer. And this is what TCP/IP for OS/2 (which LIBC internally uses) implies too. For msghdr it’s a terrible mess there though, according to the TCP/IP 4.21 Programming Reference at least. Ie msg_namelen is int (which matches socklen_t) but msg_controllen is u_int (should be socklen_t too in POSIX). The OS/2 Toolkit headers define both as u_int though. Even more messy.

@dmik dmik self-assigned this Feb 14, 2020
@dmik
Copy link
Contributor Author

dmik commented Feb 14, 2020

I actually think that we should just redefine everything to socklen_t (signed int) to be POSIX compatible on the source level. I don’t think that these length fields are expected to carry values more than 2^31-1 in the TCP/IP stack code anyway so we should end up binary level compatible too.

@SilvanScherrer
Copy link
Contributor

just to give your brain a little boost :) this is done here already https://github.com/bitwiseworks/libcx/blob/master/src/net/libcx/net.h

dmik added a commit that referenced this issue Feb 19, 2020
This seems more appropriate on OS/2.

Needed for #62.
@dmik dmik closed this as completed in bff48d7 Feb 19, 2020
dmik added a commit to bitwiseworks/libcx that referenced this issue Feb 19, 2020
@dmik
Copy link
Contributor Author

dmik commented Feb 19, 2020

Note that I also added sa_family_t and sockaddr_storage definitions which are part of the modern POSIX too.

Note however that I did not change the socket function prototypes to use socklen_t instead of int as it's too much work for now (and also requires a lot of changes in the underlying backend code). I will create a new ticket for it.

dmik added a commit to bitwiseworks/qtbase-os2 that referenced this issue Mar 4, 2021
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

No branches or pull requests

2 participants