Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(987)

Unified Diff: src/shared/srpc/rpc_serialize.c

Issue 5622003: Restructure the structs/unions involved in SRPC argument passing. This will... (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/shared/srpc/nacl_srpc.c ('k') | src/shared/srpc/rpc_service.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/shared/srpc/rpc_serialize.c
===================================================================
--- src/shared/srpc/rpc_serialize.c (revision 3898)
+++ src/shared/srpc/rpc_serialize.c (working copy)
@@ -351,7 +351,7 @@
1 != __NaClSrpcImcRead(buffer, \
sizeof(impl_type), \
1, \
- &arg->u.field)) { \
+ &arg->field)) { \
return 0; \
} \
return 1; \
@@ -361,7 +361,7 @@
int write_value, \
NaClSrpcImcBuffer* buffer) { \
if (write_value) { \
- return 1 == __NaClSrpcImcWrite(&arg->u.field, \
+ return 1 == __NaClSrpcImcWrite(&arg->field, \
sizeof(impl_type), \
1, \
buffer); \
@@ -370,7 +370,7 @@
} \
\
static void name##Print(const NaClSrpcArg* arg) { \
- dprintf(("%"format"", arg->u.field)); \
+ dprintf(("%"format"", arg->field)); \
} \
\
static uint32_t name##Length(const NaClSrpcArg* arg, \
@@ -396,12 +396,12 @@
/*
* The basic parameter types.
*/
-BASIC_TYPE_IO_DECLARE(Bool, char, bval, "1d")
-BASIC_TYPE_IO_DECLARE(Double, double, dval, "f")
-BASIC_TYPE_IO_DECLARE(Int, int32_t, ival, NACL_PRId32)
-BASIC_TYPE_IO_DECLARE(Long, int64_t, lval, NACL_PRId64)
+BASIC_TYPE_IO_DECLARE(Bool, char, u.bval, "1d")
+BASIC_TYPE_IO_DECLARE(Double, double, u.dval, "f")
+BASIC_TYPE_IO_DECLARE(Int, int32_t, u.ival, NACL_PRId32)
+BASIC_TYPE_IO_DECLARE(Long, int64_t, u.lval, NACL_PRId64)
-#define ARRAY_TYPE_IO_DECLARE(name, impl_type, field, array) \
+#define ARRAY_TYPE_IO_DECLARE(name, impl_type, array) \
static int name##ArrGet(NaClSrpcImcBuffer* buffer, \
int allocate_memory, \
int read_value, \
@@ -412,23 +412,23 @@
return 0; \
} \
if (allocate_memory) { \
- if (dim >= NACL_ABI_SIZE_T_MAX / sizeof(*arg->u.field.array)) { \
+ if (dim >= NACL_ABI_SIZE_T_MAX / sizeof(*arg->array)) { \
return 0; \
} \
- arg->u.field.array = \
- (impl_type*) malloc(dim * sizeof(*arg->u.field.array)); \
- if (NULL == arg->u.field.array) { \
+ arg->array = \
+ (impl_type*) malloc(dim * sizeof(*arg->array)); \
+ if (NULL == arg->array) { \
return 0; \
} \
- arg->u.field.count = dim; \
- } else if (arg->u.field.count < dim) { \
+ arg->u.count = dim; \
+ } else if (arg->u.count < dim) { \
return 0; \
} \
if (read_value && \
dim != __NaClSrpcImcRead(buffer, \
sizeof(impl_type), \
dim, \
- arg->u.field.array)) { \
+ arg->array)) { \
return 0; \
} \
return 1; \
@@ -438,14 +438,14 @@
int write_value, \
NaClSrpcImcBuffer* buffer) { \
if (1 != \
- __NaClSrpcImcWrite(&arg->u.field.count, sizeof(uint32_t), 1, buffer)) { \
+ __NaClSrpcImcWrite(&arg->u.count, sizeof(uint32_t), 1, buffer)) { \
return 0; \
} \
if (write_value) { \
- return arg->u.field.count == \
- __NaClSrpcImcWrite(arg->u.field.array, \
+ return arg->u.count == \
+ __NaClSrpcImcWrite(arg->array, \
sizeof(impl_type), \
- arg->u.field.count, \
+ arg->u.count, \
buffer); \
} \
return 1; \
@@ -453,8 +453,8 @@
\
static void name##ArrPrint(const NaClSrpcArg* arg) { \
dprintf(("[%"NACL_PRIu32"], array = %p", \
- arg->u.field.count, \
- (void*) arg->u.field.array)); \
+ arg->u.count, \
+ (void*) arg->array)); \
} \
\
static uint32_t name##ArrLength(const NaClSrpcArg* arg, \
@@ -462,15 +462,15 @@
int* handles) { \
*handles = 0; \
if (write_value) { \
- return sizeof(uint32_t) + sizeof(impl_type) * arg->u.field.count; \
+ return sizeof(uint32_t) + sizeof(impl_type) * arg->u.count; \
} else { \
return sizeof(uint32_t); \
} \
} \
\
static void name##ArrFree(NaClSrpcArg* arg) { \
- free(arg->u.field.array); \
- arg->u.field.array = NULL; \
+ free(arg->array); \
+ arg->array = NULL; \
} \
\
static const ArgEltInterface k##name##ArrIoInterface = { \
@@ -480,10 +480,10 @@
/*
* The three array parameter types.
*/
-ARRAY_TYPE_IO_DECLARE(Char, char, caval, carr)
-ARRAY_TYPE_IO_DECLARE(Double, double, daval, darr)
-ARRAY_TYPE_IO_DECLARE(Int, int32_t, iaval, iarr)
-ARRAY_TYPE_IO_DECLARE(Long, int64_t, laval, larr)
+ARRAY_TYPE_IO_DECLARE(Char, char, arrays.carr)
+ARRAY_TYPE_IO_DECLARE(Double, double, arrays.darr)
+ARRAY_TYPE_IO_DECLARE(Int, int32_t, arrays.iarr)
+ARRAY_TYPE_IO_DECLARE(Long, int64_t, arrays.larr)
/*
* Handle (descriptor) type I/O support.
@@ -559,14 +559,14 @@
if (dim >= NACL_ABI_SIZE_T_MAX) {
return 0;
}
- arg->u.sval.str = (char*) malloc(dim + 1);
- if (NULL == arg->u.sval.str) {
+ arg->arrays.str = (char*) malloc(dim + 1);
+ if (NULL == arg->arrays.str) {
return 0;
}
- if (dim != __NaClSrpcImcRead(buffer, sizeof(char), dim, arg->u.sval.str)) {
+ if (dim != __NaClSrpcImcRead(buffer, sizeof(char), dim, arg->arrays.str)) {
return 0;
}
- arg->u.sval.str[dim] = '\0';
+ arg->arrays.str[dim] = '\0';
}
return 1;
}
@@ -575,9 +575,9 @@
int write_value,
NaClSrpcImcBuffer* buffer) {
if (write_value) {
- uint32_t slen = (uint32_t) strlen(arg->u.sval.str);
+ uint32_t slen = (uint32_t) strlen(arg->arrays.str);
if (1 != __NaClSrpcImcWrite(&slen, sizeof(slen), 1, buffer) ||
- slen != __NaClSrpcImcWrite(arg->u.sval.str, 1,
+ slen != __NaClSrpcImcWrite(arg->arrays.str, 1,
(nacl_abi_size_t) slen, buffer)) {
return 0;
}
@@ -586,8 +586,8 @@
}
static void StringPrint(const NaClSrpcArg* arg) {
- dprintf((", strlen %u, '%s'", (unsigned) strlen(arg->u.sval.str),
- arg->u.sval.str));
+ dprintf((", strlen %u, '%s'", (unsigned) strlen(arg->arrays.str),
+ arg->arrays.str));
}
static uint32_t StringLength(const NaClSrpcArg* arg,
@@ -596,7 +596,7 @@
*handles = 0;
if (write_value) {
uint32_t size = nacl_abi_size_t_saturate(sizeof(uint32_t)
- + strlen(arg->u.sval.str));
+ + strlen(arg->arrays.str));
return size;
} else {
return 0;
@@ -604,8 +604,8 @@
}
static void StringFree(NaClSrpcArg* arg) {
- free(arg->u.sval.str);
- arg->u.sval.str = NULL;
+ free(arg->arrays.str);
+ arg->arrays.str = NULL;
}
static const ArgEltInterface kStringIoInterface = {
« no previous file with comments | « src/shared/srpc/nacl_srpc.c ('k') | src/shared/srpc/rpc_service.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698