Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Fix Issue 23157 - undefined reference to `__cmsg_nxthdr' on Alpine Li…
Browse files Browse the repository at this point in the history
…nux (musl libc)
  • Loading branch information
tom-tan committed Jun 4, 2022
1 parent 94bd5bc commit 3e4cf77
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions src/core/sys/posix/sys/socket.d
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,40 @@ version (linux)

extern (D) inout(ubyte)* CMSG_DATA( return scope inout(cmsghdr)* cmsg ) pure nothrow @nogc { return cast(ubyte*)( cmsg + 1 ); }

private inout(cmsghdr)* __cmsg_nxthdr(inout(msghdr)*, inout(cmsghdr)*) pure nothrow @nogc;
extern (D) inout(cmsghdr)* CMSG_NXTHDR(inout(msghdr)* msg, inout(cmsghdr)* cmsg) pure nothrow @nogc
version (CRuntime_Musl)
{
return __cmsg_nxthdr(msg, cmsg);
extern (D)
{
size_t __CMSG_LEN(inout(cmsghdr)* cmsg) pure nothrow @nogc
{
return (cmsg.cmsg_len + size_t.sizeof -1) & cast(size_t)(~(size_t.sizeof - 1));
}

inout(cmsghdr)* __CMSG_NEXT(inout(cmsghdr)* cmsg) pure nothrow @nogc
{
return cmsg + __CMSG_LEN(cmsg);
}

inout(msghdr)* __MHDR_END(inout(msghdr)* mhdr) pure nothrow @nogc
{
return cast(inout(msghdr)*)(mhdr.msg_control + mhdr.msg_controllen);
}

inout(cmsghdr)* CMSG_NXTHDR(inout(msghdr)* msg, inout(cmsghdr)* cmsg) pure nothrow @nogc
{
return cmsg.cmsg_len < cmsghdr.sizeof ||
__CMSG_LEN(cmsg) + cmsghdr.sizeof >= __MHDR_END(msg) - cast(inout(msghdr)*)(cmsg)
? cast(inout(cmsghdr)*) null : cast(inout(cmsghdr)*) __CMSG_NEXT(cmsg);
}
}
}
else
{
private inout(cmsghdr)* __cmsg_nxthdr(inout(msghdr)*, inout(cmsghdr)*) pure nothrow @nogc;
extern (D) inout(cmsghdr)* CMSG_NXTHDR(inout(msghdr)* msg, inout(cmsghdr)* cmsg) pure nothrow @nogc
{
return __cmsg_nxthdr(msg, cmsg);
}
}

extern (D) inout(cmsghdr)* CMSG_FIRSTHDR( inout(msghdr)* mhdr ) pure nothrow @nogc
Expand Down

0 comments on commit 3e4cf77

Please sign in to comment.