Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / native_client / src / trusted / service_runtime / sys_fdio.c
index 57ce5e9..807c651 100644 (file)
@@ -121,7 +121,7 @@ int32_t NaClSysIsatty(struct NaClAppThread *natp,
 
 int32_t NaClSysGetdents(struct NaClAppThread *natp,
                         int                  d,
-                        void                 *dirp,
+                        uint32_t             dirp,
                         size_t               count) {
   struct NaClApp  *nap = natp->nap;
   int32_t         retval = -NACL_ABI_EINVAL;
@@ -131,9 +131,9 @@ int32_t NaClSysGetdents(struct NaClAppThread *natp,
 
   NaClLog(3,
           ("Entered NaClSysGetdents(0x%08"NACL_PRIxPTR", "
-           "%d, 0x%08"NACL_PRIxPTR", "
+           "%d, 0x%08"NACL_PRIx32", "
            "%"NACL_PRIuS"[0x%"NACL_PRIxS"])\n"),
-          (uintptr_t) natp, d, (uintptr_t) dirp, count, count);
+          (uintptr_t) natp, d, dirp, count, count);
 
   ndp = NaClAppGetDesc(nap, d);
   if (NULL == ndp) {
@@ -146,7 +146,7 @@ int32_t NaClSysGetdents(struct NaClAppThread *natp,
    * |count| is arbitrary and we wouldn't want to have to allocate
    * memory in trusted address space to match.
    */
-  sysaddr = NaClUserToSysAddrRange(nap, (uintptr_t) dirp, count);
+  sysaddr = NaClUserToSysAddrRange(nap, dirp, count);
   if (kNaClBadAddress == sysaddr) {
     NaClLog(4, " illegal address for directory data\n");
     retval = -NACL_ABI_EFAULT;
@@ -196,8 +196,8 @@ cleanup:
 
 int32_t NaClSysRead(struct NaClAppThread  *natp,
                     int                   d,
-                    void                  *buf,
-                    size_t                count) {
+                    uint32_t              buf,
+                    uint32_t              count) {
   struct NaClApp  *nap = natp->nap;
   int32_t         retval = -NACL_ABI_EINVAL;
   ssize_t         read_result = -NACL_ABI_EINVAL;
@@ -208,9 +208,9 @@ int32_t NaClSysRead(struct NaClAppThread  *natp,
 
   NaClLog(3,
           ("Entered NaClSysRead(0x%08"NACL_PRIxPTR", "
-           "%d, 0x%08"NACL_PRIxPTR", "
-           "%"NACL_PRIuS"[0x%"NACL_PRIxS"])\n"),
-          (uintptr_t) natp, d, (uintptr_t) buf, count, count);
+           "%d, 0x%08"NACL_PRIx32", "
+           "%"NACL_PRIu32"[0x%"NACL_PRIx32"])\n"),
+          (uintptr_t) natp, d, buf, count, count);
 
   ndp = NaClAppGetDesc(nap, d);
   if (NULL == ndp) {
@@ -218,7 +218,7 @@ int32_t NaClSysRead(struct NaClAppThread  *natp,
     goto cleanup;
   }
 
-  sysaddr = NaClUserToSysAddrRange(nap, (uintptr_t) buf, count);
+  sysaddr = NaClUserToSysAddrRange(nap, buf, count);
   if (kNaClBadAddress == sysaddr) {
     NaClDescUnref(ndp);
     retval = -NACL_ABI_EFAULT;
@@ -234,14 +234,10 @@ int32_t NaClSysRead(struct NaClAppThread  *natp,
     count = INT32_MAX;
   }
 
-  NaClVmIoWillStart(nap,
-                    (uint32_t) (uintptr_t) buf,
-                    (uint32_t) (((uintptr_t) buf) + count - 1));
+  NaClVmIoWillStart(nap, buf, buf + count - 1);
   read_result = (*((struct NaClDescVtbl const *) ndp->base.vtbl)->
                  Read)(ndp, (void *) sysaddr, count);
-  NaClVmIoHasEnded(nap,
-                    (uint32_t) (uintptr_t) buf,
-                    (uint32_t) (((uintptr_t) buf) + count - 1));
+  NaClVmIoHasEnded(nap, buf, buf + count - 1);
   if (read_result > 0) {
     NaClLog(4, "read returned %"NACL_PRIdS" bytes\n", read_result);
     log_bytes = (size_t) read_result;
@@ -270,8 +266,8 @@ cleanup:
 
 int32_t NaClSysWrite(struct NaClAppThread *natp,
                      int                  d,
-                     void                 *buf,
-                     size_t               count) {
+                     uint32_t             buf,
+                     uint32_t             count) {
   struct NaClApp  *nap = natp->nap;
   int32_t         retval = -NACL_ABI_EINVAL;
   ssize_t         write_result = -NACL_ABI_EINVAL;
@@ -282,9 +278,9 @@ int32_t NaClSysWrite(struct NaClAppThread *natp,
 
   NaClLog(3,
           "Entered NaClSysWrite(0x%08"NACL_PRIxPTR", "
-          "%d, 0x%08"NACL_PRIxPTR", "
-          "%"NACL_PRIuS"[0x%"NACL_PRIxS"])\n",
-          (uintptr_t) natp, d, (uintptr_t) buf, count, count);
+          "%d, 0x%08"NACL_PRIx32", "
+          "%"NACL_PRIu32"[0x%"NACL_PRIx32"])\n",
+          (uintptr_t) natp, d, buf, count, count);
 
   ndp = NaClAppGetDesc(nap, d);
   NaClLog(4, " ndp = %"NACL_PRIxPTR"\n", (uintptr_t) ndp);
@@ -293,7 +289,7 @@ int32_t NaClSysWrite(struct NaClAppThread *natp,
     goto cleanup;
   }
 
-  sysaddr = NaClUserToSysAddrRange(nap, (uintptr_t) buf, count);
+  sysaddr = NaClUserToSysAddrRange(nap, buf, count);
   if (kNaClBadAddress == sysaddr) {
     NaClDescUnref(ndp);
     retval = -NACL_ABI_EFAULT;
@@ -311,7 +307,7 @@ int32_t NaClSysWrite(struct NaClAppThread *natp,
       ellipsis = "...";
     }
   }
-  NaClLog(8, "In NaClSysWrite(%d, %.*s%s, %"NACL_PRIuS")\n",
+  NaClLog(8, "In NaClSysWrite(%d, %.*s%s, %"NACL_PRIu32")\n",
           d, (int) log_bytes, (char *) sysaddr, ellipsis, count);
 
   /*
@@ -323,14 +319,10 @@ int32_t NaClSysWrite(struct NaClAppThread *natp,
     count = INT32_MAX;
   }
 
-  NaClVmIoWillStart(nap,
-                    (uint32_t) (uintptr_t) buf,
-                    (uint32_t) (((uintptr_t) buf) + count - 1));
+  NaClVmIoWillStart(nap, buf, buf + count - 1);
   write_result = (*((struct NaClDescVtbl const *) ndp->base.vtbl)->
                   Write)(ndp, (void *) sysaddr, count);
-  NaClVmIoHasEnded(nap,
-                   (uint32_t) (uintptr_t) buf,
-                   (uint32_t) (((uintptr_t) buf) + count - 1));
+  NaClVmIoHasEnded(nap, buf, buf + count - 1);
 
   NaClDescUnref(ndp);
 
@@ -347,7 +339,7 @@ cleanup:
  */
 int32_t NaClSysLseek(struct NaClAppThread *natp,
                      int                  d,
-                     nacl_abi_off_t       *offp,
+                     uint32_t             offp,
                      int                  whence) {
   struct NaClApp  *nap = natp->nap;
   nacl_abi_off_t  offset;
@@ -357,8 +349,8 @@ int32_t NaClSysLseek(struct NaClAppThread *natp,
 
   NaClLog(3,
           ("Entered NaClSysLseek(0x%08"NACL_PRIxPTR", %d,"
-           " 0x%08"NACL_PRIxPTR", %d)\n"),
-          (uintptr_t) natp, d, (uintptr_t) offp, whence);
+           " 0x%08"NACL_PRIx32", %d)\n"),
+          (uintptr_t) natp, d, offp, whence);
 
   ndp = NaClAppGetDesc(nap, d);
   if (NULL == ndp) {
@@ -366,18 +358,18 @@ int32_t NaClSysLseek(struct NaClAppThread *natp,
     goto cleanup;
   }
 
-  if (!NaClCopyInFromUser(nap, &offset, (uintptr_t) offp, sizeof offset)) {
+  if (!NaClCopyInFromUser(nap, &offset, offp, sizeof offset)) {
     retval = -NACL_ABI_EFAULT;
     goto cleanup_unref;
   }
-  NaClLog(4, "offset 0x%08"NACL_PRIxNACL_OFF"\n", offset);
+  NaClLog(4, "offset 0x%08"NACL_PRIx64"\n", (uint64_t) offset);
 
   retval64 = (*((struct NaClDescVtbl const *) ndp->base.vtbl)->
               Seek)(ndp, (nacl_off64_t) offset, whence);
   if (NaClOff64IsNegErrno(&retval64)) {
     retval = (int32_t) retval64;
   } else {
-    if (NaClCopyOutToUser(nap, (uintptr_t) offp, &retval64, sizeof retval64)) {
+    if (NaClCopyOutToUser(nap, offp, &retval64, sizeof retval64)) {
       retval = 0;
     } else {
       NaClLog(LOG_FATAL,
@@ -392,7 +384,7 @@ cleanup:
 
 int32_t NaClSysFstat(struct NaClAppThread *natp,
                      int                  d,
-                     struct nacl_abi_stat *nasp) {
+                     uint32_t             nasp) {
   struct NaClApp        *nap = natp->nap;
   int32_t               retval = -NACL_ABI_EINVAL;
   struct NaClDesc       *ndp;
@@ -400,13 +392,8 @@ int32_t NaClSysFstat(struct NaClAppThread *natp,
 
   NaClLog(3,
           ("Entered NaClSysFstat(0x%08"NACL_PRIxPTR
-           ", %d, 0x%08"NACL_PRIxPTR")\n"),
-          (uintptr_t) natp,
-          d, (uintptr_t) nasp);
-
-  NaClLog(4,
-          " sizeof(struct nacl_abi_stat) = %"NACL_PRIuS" (0x%"NACL_PRIxS")\n",
-          sizeof *nasp, sizeof *nasp);
+           ", %d, 0x%08"NACL_PRIx32")\n"),
+          (uintptr_t) natp, d, nasp);
 
   ndp = NaClAppGetDesc(nap, d);
   if (NULL == ndp) {
@@ -418,8 +405,7 @@ int32_t NaClSysFstat(struct NaClAppThread *natp,
   retval = (*((struct NaClDescVtbl const *) ndp->base.vtbl)->
             Fstat)(ndp, &result);
   if (0 == retval) {
-    if (!NaClCopyOutToUser(nap, (uintptr_t) nasp,
-                           &result, sizeof result)) {
+    if (!NaClCopyOutToUser(nap, nasp, &result, sizeof result)) {
       retval = -NACL_ABI_EFAULT;
     }
   }