// The entire file is wrapped in this #if. We do this so this .cc file can be
// compiled, even on a non-newlib build.
-#if defined(__native_client__) && !defined(__GLIBC__)
+#if defined(__native_client__) && !defined(__GLIBC__) && !defined(__BIONIC__)
#include "nacl_io/kernel_wrap.h"
extern void __libnacl_irt_dev_filename_init(void);
+extern struct nacl_irt_basic __libnacl_irt_basic;
extern struct nacl_irt_fdio __libnacl_irt_fdio;
extern struct nacl_irt_dev_fdio __libnacl_irt_dev_fdio;
extern struct nacl_irt_dev_filename __libnacl_irt_dev_filename;
// Create function pointers to the REAL implementation
#define EXPAND_SYMBOL_LIST_OPERATION(OP) \
+ OP(basic, exit); \
OP(fdio, close); \
OP(fdio, dup); \
OP(fdio, dup2); \
OP(dev_fdio, fsync); \
OP(dev_fdio, fdatasync); \
OP(dev_fdio, ftruncate); \
+ OP(dev_fdio, isatty); \
OP(dev_filename, open); \
OP(dev_filename, stat); \
OP(dev_filename, mkdir); \
return (newfd < 0) ? errno : 0;
}
+void WRAP(exit)(int status) {
+ ki_exit(status);
+}
+
int WRAP(read)(int fd, void* buf, size_t count, size_t* nread) {
ssize_t signed_nread = ki_read(fd, buf, count);
*nread = static_cast<size_t>(signed_nread);
return (ki_ftruncate(fd, length) < 0) ? errno : 0;
}
+int WRAP(isatty)(int fd, int* result) {
+ *result = ki_isatty(fd);
+ if (*result == 0)
+ return errno;
+ return 0;
+}
+
int WRAP(mmap)(void** addr, size_t length, int prot, int flags, int fd,
off_t offset) {
if (flags & MAP_ANONYMOUS)
return REAL(close)(fd);
}
+void _real_exit(int status) {
+ CHECK_REAL(exit);
+ REAL(exit)(status);
+}
+
int _real_fstat(int fd, struct stat* buf) {
CHECK_REAL(fstat);
return REAL(fstat)(fd, buf);
}
+int _real_isatty(int fd, int* result) {
+ CHECK_REAL(isatty);
+ return REAL(isatty)(fd, result);
+}
+
int _real_getdents(int fd, void* nacl_buf, size_t nacl_count, size_t* nread) {
CHECK_REAL(getdents);
return REAL(getdents)(fd, static_cast<dirent*>(nacl_buf), nacl_count, nread);
return REAL(write)(fd, buf, count, nwrote);
}
-uint64_t usec_since_epoch() {
- struct timeval tv;
- gettimeofday(&tv, NULL);
- return tv.tv_usec + (tv.tv_sec * 1000000);
-}
-
static bool s_wrapped = false;
void kernel_wrap_init() {
EXTERN_C_END
-#endif // defined(__native_client__) && !defined(__GLIBC__)
+#endif // defined(__native_client__) && !defined(__GLIBC__) ...