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
13c52b82
Commit
13c52b82
authored
Dec 11, 2014
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support Android.
parent
177fb269
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
10 deletions
+31
-10
serialize-test.c++
c++/src/capnp/serialize-test.c++
+1
-1
async-io-test.c++
c++/src/kj/async-io-test.c++
+4
-0
async-io.c++
c++/src/kj/async-io.c++
+7
-7
async-unix-test.c++
c++/src/kj/async-unix-test.c++
+5
-1
async-unix.h
c++/src/kj/async-unix.h
+2
-1
mutex.c++
c++/src/kj/mutex.c++
+12
-0
No files found.
c++/src/capnp/serialize-test.c++
View file @
13c52b82
...
...
@@ -343,7 +343,7 @@ int mkstemp(char *tpl) {
#endif
TEST
(
Serialize
,
FileDescriptors
)
{
#if _WIN32
#if _WIN32
|| __ANDROID__
// TODO(cleanup): Find the Windows temp directory? Seems overly difficult.
char
filename
[]
=
"capnproto-serialize-test-XXXXXX"
;
#else
...
...
c++/src/kj/async-io-test.c++
View file @
13c52b82
...
...
@@ -99,16 +99,20 @@ TEST(AsyncIo, AddressParsing) {
EXPECT_EQ
(
"unix:foo/bar/baz"
,
tryParse
(
w
,
network
,
"unix:foo/bar/baz"
));
// We can parse services by name...
#if !__ANDROID__ // Service names not supported on Android for some reason?
EXPECT_EQ
(
"1.2.3.4:80"
,
tryParse
(
w
,
network
,
"1.2.3.4:http"
,
5678
));
EXPECT_EQ
(
"*:80"
,
tryParse
(
w
,
network
,
"*:http"
,
5678
));
#endif
// IPv6 tests. Annoyingly, these don't work on machines that don't have IPv6 configured on any
// interfaces.
if
(
hasIpv6
())
{
EXPECT_EQ
(
"[::]:123"
,
tryParse
(
w
,
network
,
"0::0"
,
123
));
EXPECT_EQ
(
"[12ab:cd::34]:321"
,
tryParse
(
w
,
network
,
"[12ab:cd:0::0:34]:321"
,
432
));
#if !__ANDROID__ // Service names not supported on Android for some reason?
EXPECT_EQ
(
"[::]:80"
,
tryParse
(
w
,
network
,
"[::]:http"
,
5678
));
EXPECT_EQ
(
"[12ab:cd::34]:80"
,
tryParse
(
w
,
network
,
"[12ab:cd::34]:http"
,
5678
));
#endif
}
// It would be nice to test DNS lookup here but the test would not be very hermetic. Even
...
...
c++/src/kj/async-io.c++
View file @
13c52b82
...
...
@@ -61,7 +61,7 @@ void setCloseOnExec(int fd) {
}
static
constexpr
uint
NEW_FD_FLAGS
=
#if __linux__
#if __linux__
&& !__BIONIC__
LowLevelAsyncIoProvider
::
ALREADY_CLOEXEC
|
LowLevelAsyncIoProvider
::
ALREADY_NONBLOCK
|
#endif
LowLevelAsyncIoProvider
::
TAKE_OWNERSHIP
;
...
...
@@ -344,7 +344,7 @@ public:
bool
isStream
=
type
==
SOCK_STREAM
;
int
result
;
#if __linux__
#if __linux__
&& !__BIONIC__
type
|=
SOCK_NONBLOCK
|
SOCK_CLOEXEC
;
#endif
KJ_SYSCALL
(
result
=
::
socket
(
addr
.
generic
.
sa_family
,
type
,
0
));
...
...
@@ -644,7 +644,7 @@ Promise<Array<SocketAddress>> SocketAddress::lookupHost(
// a custom DNS resolver...
int
fds
[
2
];
#if __linux__
#if __linux__
&& !__BIONIC__
KJ_SYSCALL
(
pipe2
(
fds
,
O_NONBLOCK
|
O_CLOEXEC
));
#else
KJ_SYSCALL
(
pipe
(
fds
));
...
...
@@ -736,7 +736,7 @@ public:
int
newFd
;
retry
:
#if __linux__
#if __linux__
&& !__BIONIC__
newFd
=
::
accept4
(
fd
,
nullptr
,
nullptr
,
SOCK_NONBLOCK
|
SOCK_CLOEXEC
);
#else
newFd
=
::
accept
(
fd
,
nullptr
,
nullptr
);
...
...
@@ -964,7 +964,7 @@ public:
OneWayPipe
newOneWayPipe
()
override
{
int
fds
[
2
];
#if __linux__
#if __linux__
&& !__BIONIC__
KJ_SYSCALL
(
pipe2
(
fds
,
O_NONBLOCK
|
O_CLOEXEC
));
#else
KJ_SYSCALL
(
pipe
(
fds
));
...
...
@@ -978,7 +978,7 @@ public:
TwoWayPipe
newTwoWayPipe
()
override
{
int
fds
[
2
];
int
type
=
SOCK_STREAM
;
#if __linux__
#if __linux__
&& !__BIONIC__
type
|=
SOCK_NONBLOCK
|
SOCK_CLOEXEC
;
#endif
KJ_SYSCALL
(
socketpair
(
AF_UNIX
,
type
,
0
,
fds
));
...
...
@@ -996,7 +996,7 @@ public:
Function
<
void
(
AsyncIoProvider
&
,
AsyncIoStream
&
,
WaitScope
&
)
>
startFunc
)
override
{
int
fds
[
2
];
int
type
=
SOCK_STREAM
;
#if __linux__
#if __linux__
&& !__BIONIC__
type
|=
SOCK_NONBLOCK
|
SOCK_CLOEXEC
;
#endif
KJ_SYSCALL
(
socketpair
(
AF_UNIX
,
type
,
0
,
fds
));
...
...
c++/src/kj/async-unix-test.c++
View file @
13c52b82
...
...
@@ -65,12 +65,14 @@ TEST_F(AsyncUnixTest, Signals) {
EXPECT_SI_CODE
(
SI_USER
,
info
.
si_code
);
}
#if
def SIGRTMIN
#if
defined(SIGRTMIN) && !__BIONIC__
TEST_F
(
AsyncUnixTest
,
SignalWithValue
)
{
// This tests that if we use sigqueue() to attach a value to the signal, that value is received
// correctly. Note that this only works on platforms that support real-time signals -- even
// though the signal we're sending is SIGURG, the sigqueue() system call is introduced by RT
// signals. Hence this test won't run on e.g. Mac OSX.
//
// Also, Android's bionic does not appear to support sigqueue() even though the kernel does.
UnixEventPort
port
;
EventLoop
loop
(
port
);
...
...
@@ -92,6 +94,8 @@ TEST_F(AsyncUnixTest, SignalWithPointerValue) {
// correctly. Note that this only works on platforms that support real-time signals -- even
// though the signal we're sending is SIGURG, the sigqueue() system call is introduced by RT
// signals. Hence this test won't run on e.g. Mac OSX.
//
// Also, Android's bionic does not appear to support sigqueue() even though the kernel does.
UnixEventPort
port
;
EventLoop
loop
(
port
);
...
...
c++/src/kj/async-unix.h
View file @
13c52b82
...
...
@@ -32,7 +32,8 @@
#include "io.h"
#include <signal.h>
#if __linux__ && !defined(KJ_USE_EPOLL)
#if __linux__ && !__BIONIC__ && !defined(KJ_USE_EPOLL)
// Default to epoll on Linux, except on Bionic (Android) which doesn't have signalfd.h.
#define KJ_USE_EPOLL 1
#endif
...
...
c++/src/kj/mutex.c++
View file @
13c52b82
...
...
@@ -33,6 +33,18 @@
#include <sys/syscall.h>
#include <linux/futex.h>
#include <limits.h>
#ifndef SYS_futex
// Missing on Android/Bionic.
#define SYS_futex __NR_futex
#endif
#ifndef FUTEX_WAIT_PRIVATE
// Missing on Android/Bionic.
#define FUTEX_WAIT_PRIVATE FUTEX_WAIT
#define FUTEX_WAKE_PRIVATE FUTEX_WAKE
#endif
#elif _WIN32
#include <windows.h>
#endif
...
...
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