| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 The Native Client Authors. All rights reserved. | 2 * Copyright 2008 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can | 3 * Use of this source code is governed by a BSD-style license that can |
| 4 * be found in the LICENSE file. | 4 * be found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /* | 7 /* |
| 8 * A Fibonacci RPC method. | 8 * A Fibonacci RPC method. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 | 11 |
| 12 #include <stdlib.h> | 12 #include <stdlib.h> |
| 13 #include <stdio.h> | 13 #include <stdio.h> |
| 14 | 14 |
| 15 #include <nacl/nacl_srpc.h> | 15 #include <nacl/nacl_srpc.h> |
| 16 | 16 |
| 17 /* | 17 /* |
| 18 * FibonacciArray is an rpc method that computes the vitally important | 18 * FibonacciArray is an rpc method that computes the vitally important |
| 19 * fibonacci recurrence. The two input arguments are the first two | 19 * fibonacci recurrence. The two input arguments are the first two |
| 20 * values of the sequence. The size of the output array determines how many | 20 * values of the sequence. The size of the output array determines how many |
| 21 * elements of the sequence to compute, which are returned in the output array. | 21 * elements of the sequence to compute, which are returned in the output array. |
| 22 */ | 22 */ |
| 23 void FibonacciArray(NaClSrpcRpc *rpc, | 23 void FibonacciArray(NaClSrpcRpc *rpc, |
| 24 NaClSrpcArg **in_args, | 24 NaClSrpcArg **in_args, |
| 25 NaClSrpcArg **out_args, | 25 NaClSrpcArg **out_args, |
| 26 NaClSrpcClosure *done) { | 26 NaClSrpcClosure *done) { |
| 27 int v0 = in_args[0]->u.ival; | 27 int v0 = in_args[0]->u.ival; |
| 28 int v1 = in_args[1]->u.ival; | 28 int v1 = in_args[1]->u.ival; |
| 29 int v2; | 29 int v2; |
| 30 int num = out_args[0]->u.iaval.count; | 30 int num = out_args[0]->u.count; |
| 31 int32_t *dest = out_args[0]->u.iaval.iarr; | 31 int32_t *dest = out_args[0]->arrays.iarr; |
| 32 int i; | 32 int i; |
| 33 | 33 |
| 34 if (num < 2) { | 34 if (num < 2) { |
| 35 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 35 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 36 done->Run(done); | 36 done->Run(done); |
| 37 return; | 37 return; |
| 38 } | 38 } |
| 39 *dest++ = v0; | 39 *dest++ = v0; |
| 40 *dest++ = v1; | 40 *dest++ = v1; |
| 41 for (i = 2; i < num; ++i) { | 41 for (i = 2; i < num; ++i) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 55 int main() { | 55 int main() { |
| 56 if (!NaClSrpcModuleInit()) { | 56 if (!NaClSrpcModuleInit()) { |
| 57 return 1; | 57 return 1; |
| 58 } | 58 } |
| 59 if (!NaClSrpcAcceptClientConnection(srpc_methods)) { | 59 if (!NaClSrpcAcceptClientConnection(srpc_methods)) { |
| 60 return 1; | 60 return 1; |
| 61 } | 61 } |
| 62 NaClSrpcModuleFini(); | 62 NaClSrpcModuleFini(); |
| 63 return 0; | 63 return 0; |
| 64 } | 64 } |
| OLD | NEW |