Repository navigation
Declare libc socket calls as Mosaad-M/tcp does - #139
Merged
Merged
Conversation
Mojo allows one signature per C symbol in a program, so a binary importing dista and tcp or tls failed with "existing function with conflicting signature". send, recv, connect, close, setsockopt, getsockopt, poll and getaddrinfo now go through helpers with tcp's types (Int addresses, Int32 ints). Adds test-libc-abi, which declares them tcp's way next to dista's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017TycszSbyw92Efu4ZeCYL6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #134
Mojo allows one signature per C symbol in a program, so a binary importing dista and Mosaad-M/tcp or tls (so Mosaad-M/requests) failed to compile: "existing function with conflicting signature".
dista's socket code now calls libc through small helpers declared exactly as tcp declares them (
Intaddresses and lengths,Int32ints):_send,_recv,_c_connect,close_fd,_setsockopt,_getsockopt,_c_poll. Behaviour, errno handling and the MSG_* flags are unchanged.Declarations checked against tcp.mojo and tls:
send,recv(the four sites in Match tcp's external_call declarations (recv) so dista links beside Mosaad-M/requests #134), and alsoconnect,setsockopt,getsockopt,pollandgetaddrinfo, which used pointer andc_uinttypes.closewas alreadyInt32but had 16 separate declarations; they now call oneclose_fd(also used by executors.mojo and signals.mojo).socket,freeaddrinfo.accept,bind,listen,getsockname,getpeername,socketpair,fcntl(tcp usesioctl),read,write.Tests:
pixi run testpasses in full (default env, macOS arm64), before the new test was added.test-libc-abideclares the symbols tcp's way in the same program as dista's and uses them on a dista socket; it fails to build on main.TcpSocketechoing a message compiles and runs (it fails to compile on main with the send/recv conflict); dista withtls.socket.TlsSocketcompiles (not run to completion).Changelog entry under Unreleased (the repo uses CHANGELOG.md, not changes/).
🤖 Generated with Claude Code
https://claude.ai/code/session_017TycszSbyw92Efu4ZeCYL6