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

Commit 0c2400e

Browse files
authored
Fix issue 23060: MacOS: core.sys.posix.sys.socket missing some definitions (#3812)
Fix issue 23060: MacOS: core.sys.posix.sys.socket missing some definitions Signed-off-by: Dennis <dkorpel@users.noreply.github.com> Merged-on-behalf-of: Dennis <dkorpel@users.noreply.github.com>
1 parent 360d3e7 commit 0c2400e

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

src/core/sys/posix/sys/socket.d

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -589,28 +589,31 @@ else version (Darwin)
589589

590590
struct cmsghdr
591591
{
592-
socklen_t cmsg_len;
593-
int cmsg_level;
594-
int cmsg_type;
592+
socklen_t cmsg_len;
593+
int cmsg_level;
594+
int cmsg_type;
595+
}
596+
597+
598+
extern (D)
599+
{
600+
socklen_t CMSG_ALIGN(socklen_t len) pure nothrow @nogc { return (len + socklen_t.sizeof - 1) & cast(socklen_t) (~(socklen_t.sizeof - 1)); }
601+
socklen_t CMSG_SPACE(socklen_t len) pure nothrow @nogc { return CMSG_ALIGN(len) + CMSG_ALIGN(cmsghdr.sizeof); }
602+
socklen_t CMSG_LEN(socklen_t len) pure nothrow @nogc { return CMSG_ALIGN(cmsghdr.sizeof) + len; }
603+
604+
inout(ubyte)* CMSG_DATA( return scope inout(cmsghdr)* cmsg ) pure nothrow @nogc { return cast(ubyte*)( cmsg + 1 ); }
605+
606+
inout(cmsghdr)* CMSG_FIRSTHDR( inout(msghdr)* mhdr ) pure nothrow @nogc
607+
{
608+
return ( cast(socklen_t)mhdr.msg_controllen >= cmsghdr.sizeof ? cast(inout(cmsghdr)*) mhdr.msg_control : cast(inout(cmsghdr)*) null );
609+
}
595610
}
596611

597612
enum : uint
598613
{
599614
SCM_RIGHTS = 0x01
600615
}
601616

602-
/+
603-
CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \
604-
ALIGN(sizeof(struct cmsghdr)))
605-
CMSG_NXTHDR(mhdr, cmsg) \
606-
(((unsigned char *)(cmsg) + ALIGN((cmsg)->cmsg_len) + \
607-
ALIGN(sizeof(struct cmsghdr)) > \
608-
(unsigned char *)(mhdr)->msg_control +(mhdr)->msg_controllen) ? \
609-
(struct cmsghdr *)0 /* NULL */ : \
610-
(struct cmsghdr *)((unsigned char *)(cmsg) + ALIGN((cmsg)->cmsg_len)))
611-
CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control)
612-
+/
613-
614617
struct linger
615618
{
616619
int l_onoff;

0 commit comments

Comments
 (0)