OLD | NEW |
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 // Testing library for testing the foreign function interface. | 5 // Testing library for testing the foreign function interface. |
6 // There are no tests in this file, but we keep this to have a single place | 6 // There are no tests in this file, but we keep this to have a single place |
7 // for functionality that we want to test in the FFI implementation. | 7 // for functionality that we want to test in the FFI implementation. |
8 | 8 |
9 #include <errno.h> | 9 #include <errno.h> |
10 #include <string.h> | 10 #include <string.h> |
11 #include <stdint.h> | 11 #include <stdint.h> |
12 #include <stdio.h> | 12 #include <stdio.h> |
13 #include <stdlib.h> | 13 #include <stdlib.h> |
14 | 14 |
15 #include "ffi_test_library.h" | 15 #include "ffi_test_library.h" |
16 | 16 |
17 // Copied from globals.h to have consistent values | 17 // Copied from globals.h to have consistent values |
18 // TODO(ricow): we could split globals into a c only part and a c++ part. | 18 // TODO(ricow): we could split globals into a c only part and a c++ part. |
19 typedef signed char int8; | 19 typedef signed char int8; |
20 typedef short int16; // NOLINT | 20 typedef short int16; // NOLINT |
21 typedef int int32; | 21 typedef int int32; |
22 | 22 |
23 typedef unsigned char uint8; | 23 typedef unsigned char uint8; |
24 typedef unsigned short uint16; // NOLINT | 24 typedef unsigned short uint16; // NOLINT |
25 typedef unsigned int uint32; | 25 typedef unsigned int uint32; |
26 | 26 |
27 #ifdef FLETCH64 | 27 #ifdef DARTINO64 |
28 typedef long int64; // NOLINT | 28 typedef long int64; // NOLINT |
29 typedef unsigned long uint64; // NOLINT | 29 typedef unsigned long uint64; // NOLINT |
30 typedef char foobar; | 30 typedef char foobar; |
31 #else | 31 #else |
32 typedef long long int int64; // NOLINT | 32 typedef long long int int64; // NOLINT |
33 typedef long long unsigned uint64; | 33 typedef long long unsigned uint64; |
34 typedef int foobar; | 34 typedef int foobar; |
35 #endif | 35 #endif |
36 | 36 |
37 void setup() { | 37 void setup() { |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 int bufferWrite(char* buffer, int value) { | 350 int bufferWrite(char* buffer, int value) { |
351 uint32_t* size_pointer = (uint32_t*)(buffer + kSizeIndex); | 351 uint32_t* size_pointer = (uint32_t*)(buffer + kSizeIndex); |
352 uint32_t size = *size_pointer; | 352 uint32_t size = *size_pointer; |
353 int* head_pointer = (int*)buffer; | 353 int* head_pointer = (int*)buffer; |
354 int head = *head_pointer; | 354 int head = *head_pointer; |
355 char* value_pointer = buffer + kDataIndex + head; | 355 char* value_pointer = buffer + kDataIndex + head; |
356 *value_pointer = value; | 356 *value_pointer = value; |
357 *head_pointer = (head + 1) % size; | 357 *head_pointer = (head + 1) % size; |
358 return value; | 358 return value; |
359 } | 359 } |
OLD | NEW |