Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / native_client_sdk / src / libraries / nacl_io / kernel_wrap_newlib.cc
index be1d759..049e53b 100644 (file)
@@ -6,7 +6,7 @@
 
 // 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"
 
@@ -47,6 +47,7 @@ EXTERN_C_BEGIN
 
 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;
@@ -54,6 +55,7 @@ extern struct nacl_irt_memory __libnacl_irt_memory;
 
 // 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); \
@@ -67,6 +69,7 @@ extern struct nacl_irt_memory __libnacl_irt_memory;
   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); \
@@ -103,6 +106,10 @@ int WRAP(dup2)(int fd, int newfd) {
   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);
@@ -152,6 +159,13 @@ int WRAP(ftruncate)(int fd, off_t length) {
   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)
@@ -261,11 +275,21 @@ int _real_close(int fd) {
   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);
@@ -314,12 +338,6 @@ int _real_write(int fd, const void* buf, size_t count, size_t* nwrote) {
   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() {
@@ -339,4 +357,4 @@ void kernel_wrap_uninit() {
 
 EXTERN_C_END
 
-#endif  // defined(__native_client__) && !defined(__GLIBC__)
+#endif  // defined(__native_client__) && !defined(__GLIBC__) ...