* commit '471fdb7d70b712699762adf66b8789dc4777b2cd': Support poll for MIPS.
This commit is contained in:
@@ -35,6 +35,7 @@ libportable_arch_src_files += \
|
||||
arch-mips/stat.c \
|
||||
arch-mips/statfs.c \
|
||||
arch-mips/open.c \
|
||||
arch-mips/poll.c \
|
||||
arch-mips/socket.c \
|
||||
arch-mips/sockopt.c \
|
||||
arch-mips/fcntl.c \
|
||||
|
||||
68
ndk/sources/android/libportable/arch-mips/poll.c
Normal file
68
ndk/sources/android/libportable/arch-mips/poll.c
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright 2012, The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <poll.h>
|
||||
#include <poll_portable.h>
|
||||
|
||||
#if POLLWRNORM_PORTABLE==POLLWRNORM
|
||||
#error Bad build environment
|
||||
#endif
|
||||
|
||||
static inline short mips_change_portable_events(short portable_events)
|
||||
{
|
||||
/* MIPS has different POLLWRNORM and POLLWRBAND. */
|
||||
if (portable_events & POLLWRNORM_PORTABLE) {
|
||||
portable_events &= ~POLLWRNORM_PORTABLE;
|
||||
portable_events |= POLLWRNORM;
|
||||
}
|
||||
if (portable_events & POLLWRBAND_PORTABLE) {
|
||||
portable_events &= ~POLLWRBAND_PORTABLE;
|
||||
portable_events |= POLLWRBAND;
|
||||
}
|
||||
|
||||
return portable_events;
|
||||
}
|
||||
|
||||
static inline short change_mips_events(short mips_events)
|
||||
{
|
||||
/* MIPS POLLWRNORM equals POLLOUT that is the same as POLLOUT_PORTABLE, so we just update POLLWRBNAD_PORTABLE. */
|
||||
if (mips_events & POLLWRBAND) {
|
||||
mips_events &= ~POLLWRBAND;
|
||||
mips_events |= POLLWRBAND_PORTABLE;
|
||||
}
|
||||
|
||||
return mips_events;
|
||||
}
|
||||
|
||||
extern int poll(struct pollfd *, nfds_t, long);
|
||||
|
||||
int poll_portable(struct pollfd *fds, nfds_t nfds, long timeout)
|
||||
{
|
||||
nfds_t i;
|
||||
int ret;
|
||||
|
||||
for (i = 0; i < nfds; i++)
|
||||
fds->events = mips_change_portable_events(fds->events);
|
||||
|
||||
ret = poll(fds, nfds, timeout);
|
||||
|
||||
for (i = 0; i < nfds; i++) {
|
||||
fds->events = change_mips_events(fds->events);
|
||||
fds->revents = change_mips_events(fds->revents);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2012, The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _POLL_PORTABLE_H_
|
||||
#define _POLL_PORTABLE_H_
|
||||
|
||||
/* Derived from development/ndk/platforms/android-3/arch-arm/include/asm/poll.h */
|
||||
|
||||
#define POLLIN_PORTABLE 0x0001
|
||||
#define POLLPRI_PORTABLE 0x0002
|
||||
#define POLLOUT_PORTABLE 0x0004
|
||||
#define POLLERR_PORTABLE 0x0008
|
||||
#define POLLHUP_PORTABLE 0x0010
|
||||
#define POLLNVAL_PORTABLE 0x0020
|
||||
|
||||
#define POLLRDNORM_PORTABLE 0x0040
|
||||
#define POLLRDBAND_PORTABLE 0x0080
|
||||
#define POLLWRNORM_PORTABLE 0x0100
|
||||
#define POLLWRBAND_PORTABLE 0x0200
|
||||
#define POLLMSG_PORTABLE 0x0400
|
||||
#define POLLREMOVE_PORTABLE 0x1000
|
||||
#define POLLRDHUP_PORTABLE 0x2000
|
||||
|
||||
#endif /* _POLL_PORTABLE_H_ */
|
||||
Reference in New Issue
Block a user