Index: mojo/nacl/mojo_syscall_internal.h |
diff --git a/mojo/nacl/mojo_syscall_internal.h b/mojo/nacl/mojo_syscall_internal.h |
index f0795e63ba72c92dc7ec3629b93c3ca7c72440a0..959bdd812a52f17cb237ce1732df9da974f4b10b 100644 |
--- a/mojo/nacl/mojo_syscall_internal.h |
+++ b/mojo/nacl/mojo_syscall_internal.h |
@@ -32,6 +32,14 @@ static inline uintptr_t NaClUserToSysAddrArray( |
return NaClUserToSysAddrRange(nap, uaddr, range); |
} |
+void memcpy_volatile_out(void volatile* dst, const void* src, size_t n) { |
Mark Seaborn
2014/12/08 22:24:12
Shouldn't this be static and/or inline, since it's
Nick Bray (chromium)
2014/12/09 22:14:31
Done.
|
+ char volatile* c_dst = reinterpret_cast<char volatile*>(dst); |
+ const char* c_src = reinterpret_cast<const char*>(src); |
+ for (size_t i = 0; i < n; i++) { |
+ c_dst[i] = c_src[i]; |
+ } |
+} |
+ |
template <typename T> bool ConvertScalarInput( |
struct NaClApp* nap, |
uint32_t user_ptr, |
@@ -49,12 +57,16 @@ template <typename T> bool ConvertScalarInput( |
template <typename T> bool ConvertScalarOutput( |
struct NaClApp* nap, |
uint32_t user_ptr, |
+ bool optional, |
T volatile** sys_ptr) { |
if (user_ptr) { |
uintptr_t temp = NaClUserToSysAddrRange(nap, user_ptr, sizeof(T)); |
if (temp != kNaClBadAddress) { |
*sys_ptr = reinterpret_cast<T volatile*>(temp); |
return true; |
+ } else if (optional) { |
+ *sys_ptr = 0; |
+ return true; |
} |
} |
*sys_ptr = 0; // Paranoia. |
@@ -127,7 +139,7 @@ template <typename T> bool ConvertBytes( |
// TODO(ncbray): size validation and complete copy. |
// TODO(ncbray): ensure non-null / missized structs are covered by a test case. |
-template <typename T> bool ConvertStruct( |
+template <typename T> bool ConvertExtensibleStructInput( |
struct NaClApp* nap, |
uint32_t user_ptr, |
bool optional, |