Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
d204be56
Commit
d204be56
authored
Apr 21, 2019
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try to fix Mac build.
parent
8f43164a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
4 deletions
+18
-4
async-io-unix.c++
c++/src/kj/async-io-unix.c++
+18
-4
No files found.
c++/src/kj/async-io-unix.c++
View file @
d204be56
...
...
@@ -322,9 +322,16 @@ private:
msg
.
msg_iovlen
=
1
;
// Allocate space to receive a cmsg.
// On Linux, CMSG_SPACE will align to a word-size boundary, but on Mac it always aligns to a
// 32-bit boundary. I guess aligning to 32 bits helps avoid the problem where you
// surprisingly end up with space for two file descriptors when you only wanted one. However,
// cmsghdr's preferred alignment is word-size (it contains a size_t). If we stack-allocate
// the buffer, we need to make sure it is aligned properly (maybe not on x64, but maybe on
// other platforms), so we want to allocate an array of words (we use void*). So... we use
// CMSG_SPACE() and then additionally round up to deal with Mac.
size_t
msgBytes
=
CMSG_SPACE
(
sizeof
(
int
)
*
maxFds
);
KJ_ASSERT
(
msgBytes
%
sizeof
(
void
*
)
==
0
);
// CMSG_SPACE guarantees alignment
KJ_STACK_ARRAY
(
void
*
,
cmsgSpace
,
msg
Bytes
/
sizeof
(
void
*
)
,
16
,
256
);
size_t
msgWords
=
(
msgBytes
+
sizeof
(
void
*
)
-
1
)
/
sizeof
(
void
*
);
KJ_STACK_ARRAY
(
void
*
,
cmsgSpace
,
msg
Words
,
16
,
256
);
auto
cmsgBytes
=
cmsgSpace
.
asBytes
();
memset
(
cmsgBytes
.
begin
(),
0
,
cmsgBytes
.
size
());
msg
.
msg_control
=
cmsgBytes
.
begin
();
...
...
@@ -470,8 +477,15 @@ private:
// Allocate space to receive a cmsg.
size_t
msgBytes
=
CMSG_SPACE
(
sizeof
(
int
)
*
fds
.
size
());
KJ_ASSERT
(
msgBytes
%
sizeof
(
void
*
)
==
0
);
// CMSG_SPACE guarantees alignment
KJ_STACK_ARRAY
(
void
*
,
cmsgSpace
,
msgBytes
/
sizeof
(
void
*
),
16
,
256
);
// On Linux, CMSG_SPACE will align to a word-size boundary, but on Mac it always aligns to a
// 32-bit boundary. I guess aligning to 32 bits helps avoid the problem where you
// surprisingly end up with space for two file descriptors when you only wanted one. However,
// cmsghdr's preferred alignment is word-size (it contains a size_t). If we stack-allocate
// the buffer, we need to make sure it is aligned properly (maybe not on x64, but maybe on
// other platforms), so we want to allocate an array of words (we use void*). So... we use
// CMSG_SPACE() and then additionally round up to deal with Mac.
size_t
msgWords
=
(
msgBytes
+
sizeof
(
void
*
)
-
1
)
/
sizeof
(
void
*
);
KJ_STACK_ARRAY
(
void
*
,
cmsgSpace
,
msgWords
,
16
,
256
);
auto
cmsgBytes
=
cmsgSpace
.
asBytes
();
memset
(
cmsgBytes
.
begin
(),
0
,
cmsgBytes
.
size
());
msg
.
msg_control
=
cmsgBytes
.
begin
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment