Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
ffi_test_functions.cc
Go to the documentation of this file.
1// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
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 file.
4
5// This file contains test functions for the dart:ffi test cases.
6// This file is not allowed to depend on any symbols from the embedder and is
7// therefore not allowed to use `dart_api.h`. (The flutter/flutter integration
8// tests will run dart tests using this library only.)
9
10#include <stdarg.h>
11#include <stddef.h>
12#include <stdlib.h>
13#include <sys/types.h>
14
15#include <cmath>
16#include <iostream>
17#include <limits>
18#include <thread> // NOLINT
19
20#if defined(_WIN32)
21#include <windows.h>
22#else
23#include <sys/mman.h>
24#endif
25
27
28#if defined(_WIN32)
29#define DART_EXPORT extern "C" __declspec(dllexport)
30#else
31#define DART_EXPORT \
32 extern "C" __attribute__((visibility("default"))) __attribute((used))
33#endif
34
35namespace dart {
36
37#define CHECK(X) \
38 if (!(X)) { \
39 fprintf(stderr, "%s\n", "Check failed: " #X); \
40 return 1; \
41 }
42
43#define CHECK_EQ(X, Y) CHECK((X) == (Y))
44
45////////////////////////////////////////////////////////////////////////////////
46// Tests for Dart -> native calls.
47//
48// Note: If this interface is changed please also update
49// sdk/runtime/tools/dartfuzz/dartfuzz_ffi_api.dart
50
52 *reinterpret_cast<int*>(InduceACrash) = 123;
53}
54
55DART_EXPORT void SetGlobalVar(int32_t v) {
56 globalInt = v;
57}
58
60 return globalInt;
61}
62
66
67// Sums two ints and adds 42.
68// Simple function to test trampolines.
69// Also used for testing argument exception on passing null instead of a Dart
70// int.
71DART_EXPORT int32_t SumPlus42(int32_t a, int32_t b) {
72 std::cout << "SumPlus42(" << a << ", " << b << ")\n";
73 const int32_t retval = 42 + a + b;
74 std::cout << "returning " << retval << "\n";
75 return retval;
76}
77
78// Tests for sign and zero extension return values when passed to Dart.
80 return 0xff;
81}
82
84 return 0xffff;
85}
86
88 return 0xffffffff;
89}
90
92 return 0x80;
93}
94
96 return 0x8000;
97}
98
100 return 0x80000000;
101}
102
103// Test that return values are truncated by callee before passed to Dart.
105 uint64_t v = 0xabcff;
106 // Truncated to 8 bits and zero extended, or truncated to 32 bits, depending
107 // on ABI.
108 return v;
109}
110
112 uint64_t v = 0xabcffff;
113 return v;
114}
115
117 uint64_t v = 0xabcffffffff;
118 return v;
119}
120
122 int64_t v = 0x8abc80;
123 return v;
124}
125
127 int64_t v = 0x8abc8000;
128 return v;
129}
130
132 int64_t v = 0x8abc80000000;
133 return v;
134}
135
136// Test that arguments are truncated correctly.
137DART_EXPORT intptr_t TakeMaxUint8(uint8_t x) {
138 std::cout << "TakeMaxUint8(" << static_cast<int>(x) << ")\n";
139 return x == 0xff ? 1 : 0;
140}
141
142DART_EXPORT intptr_t TakeMaxUint16(uint16_t x) {
143 std::cout << "TakeMaxUint16(" << x << ")\n";
144 return x == 0xffff ? 1 : 0;
145}
146
147DART_EXPORT intptr_t TakeMaxUint32(uint32_t x) {
148 std::cout << "TakeMaxUint32(" << x << ")\n";
149 return x == 0xffffffff ? 1 : 0;
150}
151
152DART_EXPORT intptr_t TakeMinInt8(int8_t x) {
153 std::cout << "TakeMinInt8(" << static_cast<int>(x) << ")\n";
154 const int64_t expected = -0x80;
155 const int64_t received = x;
156 return expected == received ? 1 : 0;
157}
158
159DART_EXPORT intptr_t TakeMinInt16(int16_t x) {
160 std::cout << "TakeMinInt16(" << x << ")\n";
161 const int64_t expected = -0x8000;
162 const int64_t received = x;
163 return expected == received ? 1 : 0;
164}
165
166DART_EXPORT intptr_t TakeMinInt32(int32_t x) {
167 std::cout << "TakeMinInt32(" << x << ")\n";
168 const int64_t expected = INT32_MIN;
169 const int64_t received = x;
170 return expected == received ? 1 : 0;
171}
172
173// Test that arguments are truncated correctly, including stack arguments
175 uint8_t b,
176 uint8_t c,
177 uint8_t d,
178 uint8_t e,
179 uint8_t f,
180 uint8_t g,
181 uint8_t h,
182 uint8_t i,
183 uint8_t j) {
184 std::cout << "TakeMaxUint8x10(" << static_cast<int>(a) << ", "
185 << static_cast<int>(b) << ", " << static_cast<int>(c) << ", "
186 << static_cast<int>(d) << ", " << static_cast<int>(e) << ", "
187 << static_cast<int>(f) << ", " << static_cast<int>(g) << ", "
188 << static_cast<int>(h) << ", " << static_cast<int>(i) << ", "
189 << static_cast<int>(j) << ")\n";
190 return (a == 0xff && b == 0xff && c == 0xff && d == 0xff && e == 0xff &&
191 f == 0xff && g == 0xff && h == 0xff && i == 0xff && j == 0xff)
192 ? 1
193 : 0;
194}
195
196// Performs some computation on various sized signed ints.
197// Used for testing value ranges for signed ints.
198DART_EXPORT int64_t IntComputation(int8_t a, int16_t b, int32_t c, int64_t d) {
199 std::cout << "IntComputation(" << static_cast<int>(a) << ", " << b << ", "
200 << c << ", " << d << ")\n";
201 const int64_t retval = d - c + b - a;
202 std::cout << "returning " << retval << "\n";
203 return retval;
204}
205
206// Used in regress_39044_test.dart.
207DART_EXPORT int64_t Regress39044(int64_t a, int8_t b) {
208 std::cout << "Regress39044(" << a << ", " << static_cast<int>(b) << ")\n";
209 const int64_t retval = a - b;
210 std::cout << "returning " << retval << "\n";
211 return retval;
212}
213
214DART_EXPORT intptr_t Regress40537(uint8_t x) {
215 std::cout << "Regress40537(" << static_cast<int>(x) << ")\n";
216 return x == 249 ? 1 : 0;
217}
218
220 std::cout << "Regress40537Variant2(" << static_cast<int>(x) << ")\n";
221 return x;
222}
223
225 std::cout << "Regress40537Variant3(" << static_cast<int>(x) << ")\n";
226 return x;
227}
228
229// Performs some computation on various sized unsigned ints.
230// Used for testing value ranges for unsigned ints.
232 uint16_t b,
233 uint32_t c,
234 uint64_t d) {
235 std::cout << "UintComputation(" << static_cast<int>(a) << ", " << b << ", "
236 << c << ", " << d << ")\n";
237 const uint64_t retval = d - c + b - a;
238 std::cout << "returning " << retval << "\n";
239 return retval;
240}
241
242// Multiplies pointer sized intptr_t by three.
243// Used for testing pointer sized parameter and return value.
244DART_EXPORT intptr_t Times3(intptr_t a) {
245 std::cout << "Times3(" << a << ")\n";
246 const intptr_t retval = a * 3;
247 std::cout << "returning " << retval << "\n";
248 return retval;
249}
250
251// Multiples a double by 1.337.
252// Used for testing double parameter and return value.
253// Also used for testing argument exception on passing null instead of a Dart
254// double.
256 std::cout << "Times1_337Double(" << a << ")\n";
257 const double retval = a * 1.337;
258 std::cout << "returning " << retval << "\n";
259 return retval;
260}
261
262// Multiples a float by 1.337.
263// Used for testing float parameter and return value.
265 std::cout << "Times1_337Float(" << a << ")\n";
266 const float retval = a * 1.337f;
267 std::cout << "returning " << retval << "\n";
268 return retval;
269}
270
271// Sums many ints.
272// Used for testing calling conventions. With so many integers we are using all
273// normal parameter registers and some stack slots.
274DART_EXPORT intptr_t SumManyInts(intptr_t a,
275 intptr_t b,
276 intptr_t c,
277 intptr_t d,
278 intptr_t e,
279 intptr_t f,
280 intptr_t g,
281 intptr_t h,
282 intptr_t i,
283 intptr_t j) {
284 std::cout << "SumManyInts(" << a << ", " << b << ", " << c << ", " << d
285 << ", " << e << ", " << f << ", " << g << ", " << h << ", " << i
286 << ", " << j << ")\n";
287 const intptr_t retval = a + b + c + d + e + f + g + h + i + j;
288 std::cout << "returning " << retval << "\n";
289 return retval;
290}
291
292// Sums many ints.
293// Used for testing calling conventions. With small integers on stack slots we
294// test stack alignment.
296 int16_t b,
297 int8_t c,
298 int16_t d,
299 int8_t e,
300 int16_t f,
301 int8_t g,
302 int16_t h,
303 int8_t i,
304 int16_t j) {
305 std::cout << "SumManySmallInts(" << static_cast<int>(a) << ", " << b << ", "
306 << static_cast<int>(c) << ", " << d << ", " << static_cast<int>(e)
307 << ", " << f << ", " << static_cast<int>(g) << ", " << h << ", "
308 << static_cast<int>(i) << ", " << j << ")\n";
309 const int16_t retval = a + b + c + d + e + f + g + h + i + j;
310 std::cout << "returning " << retval << "\n";
311 return retval;
312}
313
314// Used for testing floating point argument backfilling on Arm32 in hardfp.
315DART_EXPORT double SumFloatsAndDoubles(float a, double b, float c) {
316 std::cout << "SumFloatsAndDoubles(" << a << ", " << b << ", " << c << ")\n";
317 const double retval = a + b + c;
318 std::cout << "returning " << retval << "\n";
319 return retval;
320}
321
322// Very many small integers, tests alignment on stack.
324 int16_t a02,
325 int8_t a03,
326 int16_t a04,
327 int8_t a05,
328 int16_t a06,
329 int8_t a07,
330 int16_t a08,
331 int8_t a09,
332 int16_t a10,
333 int8_t a11,
334 int16_t a12,
335 int8_t a13,
336 int16_t a14,
337 int8_t a15,
338 int16_t a16,
339 int8_t a17,
340 int16_t a18,
341 int8_t a19,
342 int16_t a20,
343 int8_t a21,
344 int16_t a22,
345 int8_t a23,
346 int16_t a24,
347 int8_t a25,
348 int16_t a26,
349 int8_t a27,
350 int16_t a28,
351 int8_t a29,
352 int16_t a30,
353 int8_t a31,
354 int16_t a32,
355 int8_t a33,
356 int16_t a34,
357 int8_t a35,
358 int16_t a36,
359 int8_t a37,
360 int16_t a38,
361 int8_t a39,
362 int16_t a40) {
363 std::cout << "SumVeryManySmallInts(" << static_cast<int>(a01) << ", " << a02
364 << ", " << static_cast<int>(a03) << ", " << a04 << ", "
365 << static_cast<int>(a05) << ", " << a06 << ", "
366 << static_cast<int>(a07) << ", " << a08 << ", "
367 << static_cast<int>(a09) << ", " << a10 << ", "
368 << static_cast<int>(a11) << ", " << a12 << ", "
369 << static_cast<int>(a13) << ", " << a14 << ", "
370 << static_cast<int>(a15) << ", " << a16 << ", "
371 << static_cast<int>(a17) << ", " << a18 << ", "
372 << static_cast<int>(a19) << ", " << a20 << ", "
373 << static_cast<int>(a21) << ", " << a22 << ", "
374 << static_cast<int>(a23) << ", " << a24 << ", "
375 << static_cast<int>(a25) << ", " << a26 << ", "
376 << static_cast<int>(a27) << ", " << a28 << ", "
377 << static_cast<int>(a29) << ", " << a30 << ", "
378 << static_cast<int>(a31) << ", " << a32 << ", "
379 << static_cast<int>(a33) << ", " << a34 << ", "
380 << static_cast<int>(a35) << ", " << a36 << ", "
381 << static_cast<int>(a37) << ", " << a38 << ", "
382 << static_cast<int>(a39) << ", " << a40 << ")\n";
383 const int16_t retval = a01 + a02 + a03 + a04 + a05 + a06 + a07 + a08 + a09 +
384 a10 + a11 + a12 + a13 + a14 + a15 + a16 + a17 + a18 +
385 a19 + a20 + a21 + a22 + a23 + a24 + a25 + a26 + a27 +
386 a28 + a29 + a30 + a31 + a32 + a33 + a34 + a35 + a36 +
387 a37 + a38 + a39 + a40;
388 std::cout << "returning " << retval << "\n";
389 return retval;
390}
391
392// Very many floating points, tests alignment on stack, and packing in
393// floating point registers in hardfp.
395 double a02,
396 float a03,
397 double a04,
398 float a05,
399 double a06,
400 float a07,
401 double a08,
402 float a09,
403 double a10,
404 float a11,
405 double a12,
406 float a13,
407 double a14,
408 float a15,
409 double a16,
410 float a17,
411 double a18,
412 float a19,
413 double a20,
414 float a21,
415 double a22,
416 float a23,
417 double a24,
418 float a25,
419 double a26,
420 float a27,
421 double a28,
422 float a29,
423 double a30,
424 float a31,
425 double a32,
426 float a33,
427 double a34,
428 float a35,
429 double a36,
430 float a37,
431 double a38,
432 float a39,
433 double a40) {
434 std::cout << "SumVeryManyFloatsDoubles(" << a01 << ", " << a02 << ", " << a03
435 << ", " << a04 << ", " << a05 << ", " << a06 << ", " << a07 << ", "
436 << a08 << ", " << a09 << ", " << a10 << ", " << a11 << ", " << a12
437 << ", " << a13 << ", " << a14 << ", " << a15 << ", " << a16 << ", "
438 << a17 << ", " << a18 << ", " << a19 << ", " << a20 << ", " << a21
439 << ", " << a22 << ", " << a23 << ", " << a24 << ", " << a25 << ", "
440 << a26 << ", " << a27 << ", " << a28 << ", " << a29 << ", " << a30
441 << ", " << a31 << ", " << a32 << ", " << a33 << ", " << a34 << ", "
442 << a35 << ", " << a36 << ", " << a37 << ", " << a38 << ", " << a39
443 << ", " << a40 << ")\n";
444 const double retval = a01 + a02 + a03 + a04 + a05 + a06 + a07 + a08 + a09 +
445 a10 + a11 + a12 + a13 + a14 + a15 + a16 + a17 + a18 +
446 a19 + a20 + a21 + a22 + a23 + a24 + a25 + a26 + a27 +
447 a28 + a29 + a30 + a31 + a32 + a33 + a34 + a35 + a36 +
448 a37 + a38 + a39 + a40;
449 std::cout << "returning " << retval << "\n";
450 return retval;
451}
452
453// Sums an odd number of ints.
454// Used for testing calling conventions. With so many arguments, and an odd
455// number of arguments, we are testing stack alignment on various architectures.
456DART_EXPORT intptr_t SumManyIntsOdd(intptr_t a,
457 intptr_t b,
458 intptr_t c,
459 intptr_t d,
460 intptr_t e,
461 intptr_t f,
462 intptr_t g,
463 intptr_t h,
464 intptr_t i,
465 intptr_t j,
466 intptr_t k) {
467 std::cout << "SumManyInts(" << a << ", " << b << ", " << c << ", " << d
468 << ", " << e << ", " << f << ", " << g << ", " << h << ", " << i
469 << ", " << j << ", " << k << ")\n";
470 const intptr_t retval =
471 static_cast<uintptr_t>(a) + static_cast<uintptr_t>(b) +
472 static_cast<uintptr_t>(c) + static_cast<uintptr_t>(d) +
473 static_cast<uintptr_t>(e) + static_cast<uintptr_t>(f) +
474 static_cast<uintptr_t>(g) + static_cast<uintptr_t>(h) +
475 static_cast<uintptr_t>(i) + static_cast<uintptr_t>(j) +
476 static_cast<uintptr_t>(k);
477 std::cout << "returning " << retval << "\n";
478 return retval;
479}
480
481// Sums many doubles.
482// Used for testing calling conventions. With so many doubles we are using all
483// xmm parameter registers and some stack slots.
485 double b,
486 double c,
487 double d,
488 double e,
489 double f,
490 double g,
491 double h,
492 double i,
493 double j) {
494 std::cout << "SumManyDoubles(" << a << ", " << b << ", " << c << ", " << d
495 << ", " << e << ", " << f << ", " << g << ", " << h << ", " << i
496 << ", " << j << ")\n";
497 const double retval = a + b + c + d + e + f + g + h + i + j;
498 std::cout << "returning " << retval << "\n";
499 return retval;
500}
501
502// Sums many numbers.
503// Used for testing calling conventions. With so many parameters we are using
504// both registers and stack slots.
506 float b,
507 intptr_t c,
508 double d,
509 intptr_t e,
510 float f,
511 intptr_t g,
512 double h,
513 intptr_t i,
514 float j,
515 intptr_t k,
516 double l,
517 intptr_t m,
518 float n,
519 intptr_t o,
520 double p,
521 intptr_t q,
522 float r,
523 intptr_t s,
524 double t) {
525 std::cout << "SumManyNumbers(" << a << ", " << b << ", " << c << ", " << d
526 << ", " << e << ", " << f << ", " << g << ", " << h << ", " << i
527 << ", " << j << ", " << k << ", " << l << ", " << m << ", " << n
528 << ", " << o << ", " << p << ", " << q << ", " << r << ", " << s
529 << ", " << t << ")\n";
530 const double retval = a + b + c + d + e + f + g + h + i + j + k + l + m + n +
531 o + p + q + r + s + t;
532 std::cout << "returning " << retval << "\n";
533 return retval;
534}
535
536// Assigns 1337 to the second element and returns the address of that element.
537// Used for testing Pointer parameters and return values.
538DART_EXPORT int64_t* Assign1337Index1(int64_t* a) {
539 std::cout << "Assign1337Index1(" << a << ")\n";
540 std::cout << "val[0] = " << a[0] << "\n";
541 std::cout << "val[1] = " << a[1] << "\n";
542 a[1] = 1337;
543 std::cout << "val[1] = " << a[1] << "\n";
544 int64_t* retval = a + 1;
545 std::cout << "returning " << retval << "\n";
546 return retval;
547}
548
549// Transposes Coordinate by (10, 10) and returns next Coordinate.
550// Used for testing struct pointer parameter, struct pointer return value,
551// struct field access, and struct pointer field dereference.
553 std::cout << "TransposeCoordinate(" << coord << " {" << coord->x << ", "
554 << coord->y << ", " << coord->next << "})\n";
555 coord->x = coord->x + 10.0;
556 coord->y = coord->y + 10.0;
557 std::cout << "returning " << coord->next << "\n";
558 return coord->next;
559}
560
561// Takes a Coordinate array and returns a Coordinate pointer to the next
562// element.
563// Used for testing struct arrays.
565 std::cout << "CoordinateElemAt1(" << coord << ")\n";
566 std::cout << "sizeof(Coord): " << sizeof(Coord) << "\n";
567 std::cout << "coord[0] = {" << coord[0].x << ", " << coord[0].y << ", "
568 << coord[0].next << "}\n";
569 std::cout << "coord[1] = {" << coord[1].x << ", " << coord[1].y << ", "
570 << coord[1].next << "}\n";
571 Coord* retval = coord + 1;
572 std::cout << "returning " << retval << "\n";
573 return retval;
574}
575
576typedef Coord* (*CoordUnOp)(Coord* coord);
577
578// Takes a Coordinate Function(Coordinate) and applies it three times to a
579// Coordinate.
580// Used for testing function pointers with structs.
582 std::cout << "CoordinateUnOpTrice(" << &unop << ", " << coord << ")\n";
583 Coord* retval = unop(unop(unop(coord)));
584 std::cout << "returning " << retval << "\n";
585 return retval;
586}
587
588typedef intptr_t (*IntptrBinOp)(intptr_t a, intptr_t b);
589
590// Returns a closure.
591// Note this closure is not properly marked as DART_EXPORT or extern "C".
592// Used for testing passing a pointer to a closure to Dart.
594 std::cout << "IntptrAdditionClosure()\n";
595 IntptrBinOp retval = [](intptr_t a, intptr_t b) { return a + b; };
596 std::cout << "returning " << &retval << "\n";
597 return retval;
598}
599
600// Applies an intptr binop function to 42 and 74.
601// Used for testing passing a function pointer to C.
603 std::cout << "ApplyTo42And74()\n";
604 intptr_t retval = binop(42, 74);
605 std::cout << "returning " << retval << "\n";
606 return retval;
607}
608
609// Returns next element in the array, unless a null pointer is passed.
610// When a null pointer is passed, a null pointer is returned.
611// Used for testing null pointers.
613 std::cout << "NullableInt64ElemAt1(" << a << ")\n";
614 int64_t* retval;
615 if (a != nullptr) {
616 std::cout << "not null pointer, address: " << a << "\n";
617 retval = a + 1;
618 } else {
619 std::cout << "null pointer, address: " << a << "\n";
620 retval = nullptr;
621 }
622 std::cout << "returning " << retval << "\n";
623 return retval;
624}
625
626// A struct designed to exercise all kinds of alignment rules.
627// Note that offset32A (System V ia32, iOS arm) aligns doubles on 4 bytes while
628// offset32B (Arm 32 bit and MSVC ia32) aligns on 8 bytes.
629// TODO(37470): Add uncommon primitive data types when we want to support them.
631 // size32 size64 offset32A offset32B offset64
632 int8_t a; // 1 0 0 0
633 int16_t b; // 2 2 2 2
634 int32_t c; // 4 4 4 4
635 int64_t d; // 8 8 8 8
636 uint8_t e; // 1 16 16 16
637 uint16_t f; // 2 18 18 18
638 uint32_t g; // 4 20 20 20
639 uint64_t h; // 8 24 24 24
640 intptr_t i; // 4 8 32 32 32
641 double j; // 8 36 40 40
642 float k; // 4 44 48 48
643 VeryLargeStruct* parent; // 4 8 48 52 56
644 intptr_t numChildren; // 4 8 52 56 64
645 VeryLargeStruct* children; // 4 8 56 60 72
646 int8_t smallLastField; // 1 60 64 80
647 // sizeof 64 72 88
648};
649
650// Sums the fields of a very large struct, including the first field (a) from
651// the parent and children.
652// Used for testing alignment and padding in structs.
654 std::cout << "SumVeryLargeStruct(" << vls << ")\n";
655 std::cout << "offsetof(a): " << offsetof(VeryLargeStruct, a) << "\n";
656 std::cout << "offsetof(b): " << offsetof(VeryLargeStruct, b) << "\n";
657 std::cout << "offsetof(c): " << offsetof(VeryLargeStruct, c) << "\n";
658 std::cout << "offsetof(d): " << offsetof(VeryLargeStruct, d) << "\n";
659 std::cout << "offsetof(e): " << offsetof(VeryLargeStruct, e) << "\n";
660 std::cout << "offsetof(f): " << offsetof(VeryLargeStruct, f) << "\n";
661 std::cout << "offsetof(g): " << offsetof(VeryLargeStruct, g) << "\n";
662 std::cout << "offsetof(h): " << offsetof(VeryLargeStruct, h) << "\n";
663 std::cout << "offsetof(i): " << offsetof(VeryLargeStruct, i) << "\n";
664 std::cout << "offsetof(j): " << offsetof(VeryLargeStruct, j) << "\n";
665 std::cout << "offsetof(k): " << offsetof(VeryLargeStruct, k) << "\n";
666 std::cout << "offsetof(parent): " << offsetof(VeryLargeStruct, parent)
667 << "\n";
668 std::cout << "offsetof(numChildren): "
669 << offsetof(VeryLargeStruct, numChildren) << "\n";
670 std::cout << "offsetof(children): " << offsetof(VeryLargeStruct, children)
671 << "\n";
672 std::cout << "offsetof(smallLastField): "
673 << offsetof(VeryLargeStruct, smallLastField) << "\n";
674 std::cout << "sizeof(VeryLargeStruct): " << sizeof(VeryLargeStruct) << "\n";
675
676 std::cout << "vls->a: " << static_cast<int>(vls->a) << "\n";
677 std::cout << "vls->b: " << vls->b << "\n";
678 std::cout << "vls->c: " << vls->c << "\n";
679 std::cout << "vls->d: " << vls->d << "\n";
680 std::cout << "vls->e: " << static_cast<int>(vls->e) << "\n";
681 std::cout << "vls->f: " << vls->f << "\n";
682 std::cout << "vls->g: " << vls->g << "\n";
683 std::cout << "vls->h: " << vls->h << "\n";
684 std::cout << "vls->i: " << vls->i << "\n";
685 std::cout << "vls->j: " << vls->j << "\n";
686 std::cout << "vls->k: " << vls->k << "\n";
687 std::cout << "vls->parent: " << vls->parent << "\n";
688 std::cout << "vls->numChildren: " << vls->numChildren << "\n";
689 std::cout << "vls->children: " << vls->children << "\n";
690 std::cout << "vls->smallLastField: " << static_cast<int>(vls->smallLastField)
691 << "\n";
692
693 int64_t retval = 0;
694 retval += 0x0L + vls->a;
695 retval += vls->b;
696 retval += vls->c;
697 retval += vls->d;
698 retval += vls->e;
699 retval += vls->f;
700 retval += vls->g;
701 retval += vls->h;
702 retval += vls->i;
703 retval += vls->j;
704 retval += vls->k;
705 retval += vls->smallLastField;
706 std::cout << retval << "\n";
707 if (vls->parent != nullptr) {
708 std::cout << "has parent\n";
709 retval += vls->parent->a;
710 }
711 std::cout << "has " << vls->numChildren << " children\n";
712 for (intptr_t i = 0; i < vls->numChildren; i++) {
713 retval += vls->children[i].a;
714 }
715 std::cout << "returning " << retval << "\n";
716 return retval;
717}
718
720 uint8_t a0;
721 uint8_t a1;
722 uint8_t a2;
723 uint8_t a3;
724 uint8_t a4;
725 uint8_t a5;
726 uint8_t a6;
727 uint8_t a7;
728 uint8_t a8;
729};
730
732 return s9.a0 + s9.a1 + s9.a2 + s9.a3 + s9.a4 + s9.a5 + s9.a6 + s9.a7 + s9.a8;
733}
734
735DART_EXPORT int64_t
737 Struct9Uint8* in) {
738 std::cout << "SumReturnStruct9Uint8 in (" << in->a0 << ", " << in->a1 << ", "
739 << in->a2 << ", " << in->a3 << ", " << in->a4 << ", " << in->a5
740 << ", " << in->a6 << ", " << in->a7 << ", " << in->a8 << ")\n";
741
742 Struct9Uint8 out = callback(in);
743
744 std::cout << "SumReturnStruct9Uint8 out (" << out.a0 << ", " << out.a1 << ", "
745 << out.a2 << ", " << out.a3 << ", " << out.a4 << ", " << out.a5
746 << ", " << out.a6 << ", " << out.a7 << ", " << out.a8 << ")\n";
747
748 return out.a0 + out.a1 + out.a2 + out.a3 + out.a4 + out.a5 + out.a6 + out.a7 +
749 out.a8;
750}
751
752// Allocates a multiple of the larest page size, so the last element of the
753// array is right at a page boundary. Explicitly allocate and make inaccessible
754// the next page to avoid flaky false-successes if the next page happens to be
755// allocated.
757 size_t size = sizeof(Struct9Uint8) * 64 * 1024;
758#if defined(_WIN32)
759 void* result =
760 VirtualAlloc(nullptr, size * 2, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
761 void* guard_page =
762 reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(result) + size);
763 DWORD old_prot;
764 if (VirtualProtect(guard_page, size, PAGE_NOACCESS, &old_prot) == 0) {
765 fprintf(stderr, "VirtualProtect failed\n");
766 abort();
767 }
768#else
769 void* result = mmap(nullptr, size * 2, PROT_READ | PROT_WRITE,
770 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
771 void* guard_page =
772 reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(result) + size);
773 if (mprotect(guard_page, size, PROT_NONE) != 0) {
774 fprintf(stderr, "mprotect failed\n");
775 abort();
776 }
777#endif
778 return reinterpret_cast<Struct9Uint8*>(result);
779}
780
782#if defined(_WIN32)
783 VirtualFree(address, 0, MEM_RELEASE);
784#else
785 size_t size = sizeof(Struct9Uint8) * 64 * 1024;
786 munmap(address, size * 2);
787#endif
788}
789
790// Sums numbers of various sizes.
791// Used for testing truncation and sign extension of non 64 bit parameters.
793 int16_t b,
794 int32_t c,
795 uint8_t d,
796 uint16_t e,
797 uint32_t f) {
798 std::cout << "SumSmallNumbers(" << static_cast<int>(a) << ", " << b << ", "
799 << c << ", " << static_cast<int>(d) << ", " << e << ", " << f
800 << ")\n";
801 int64_t retval = 0;
802 retval += a;
803 retval += b;
804 retval += c;
805 retval += d;
806 retval += e;
807 retval += f;
808 std::cout << "returning " << retval << "\n";
809 return retval;
810}
811
812// Checks whether the float is between 1336.0f and 1338.0f.
813// Used for testing rounding of Dart Doubles to floats in Pointer.store().
814DART_EXPORT uint8_t IsRoughly1337(float* a) {
815 std::cout << "IsRoughly1337(" << a[0] << ")\n";
816 uint8_t retval = (1336.0f < a[0] && a[0] < 1338.0f) ? 1 : 0;
817 std::cout << "returning " << static_cast<int>(retval) << "\n";
818 return retval;
819}
820
821// Does nothing with input.
822// Used for testing functions that return void
824 std::cout << "DevNullFloat(" << a << ")\n";
825 std::cout << "returning nothing\n";
826}
827
828// Invents an elite floating pointptr_t number.
829// Used for testing functions that do not take any arguments.
831 std::cout << "InventFloatValue()\n";
832 const float retval = 1337.0f;
833 std::cout << "returning " << retval << "\n";
834 return retval;
835}
836
837// Can't easily share this with the generated file.
839 int32_t a0;
840 int32_t a1;
841 int32_t a2;
842 int32_t a3;
843 int32_t a4;
844};
845
847 int64_t recursionCounter,
851 std::cout << "PassStruct20BytesHomogeneousInt32x10" << "(" << recursionCounter
852 << ", (" << a0.a0 << ", " << a0.a1 << ", " << a0.a2 << ", " << a0.a3
853 << ", " << a0.a4 << "), " << reinterpret_cast<void*>(f) << ")\n";
854 a0.a0++;
855 const int32_t a0_a0_saved = a0.a0;
856
857 if (recursionCounter <= 0) {
858 return a0;
859 }
860
861 Struct20BytesHomogeneousInt32Copy result = f(recursionCounter - 1, a0);
862 result.a0++;
863 if (a0_a0_saved != a0.a0) {
864 result.a4 = 0;
865 }
866
867 return result;
868}
869
870// Can't easily share this with the generated file.
872 int16_t a0;
873 int16_t a1;
874};
875
876// Can't easily share this with the generated file.
881
883 std::cout << "CallbackWithStruct" << "(" << reinterpret_cast<void*>(f)
884 << ")\n";
885
887 arg.a0.a0 = 10;
888 arg.a0.a1 = 11;
889 arg.a1.a0 = 12;
890 arg.a1.a1 = 13;
891
892 f(arg);
893}
894
895////////////////////////////////////////////////////////////////////////////////
896// Tests for callbacks.
897
898// Sanity test.
899DART_EXPORT intptr_t TestSimpleAddition(intptr_t (*add)(int, int)) {
900 const intptr_t result = add(10, 20);
901 std::cout << "result " << result << "\n";
902 CHECK_EQ(result, 30);
903 return 0;
904}
905
906//// Following tests are copied from above, with the role of Dart and C++ code
907//// reversed.
908
909DART_EXPORT intptr_t
910TestIntComputation(int64_t (*fn)(int8_t, int16_t, int32_t, int64_t)) {
911 const int64_t result = fn(125, 250, 500, 1000);
912 std::cout << "result " << result << "\n";
913 CHECK_EQ(result, 625);
914 CHECK_EQ(0x7FFFFFFFFFFFFFFFLL, fn(0, 0, 0, 0x7FFFFFFFFFFFFFFFLL));
915 CHECK_EQ(((int64_t)0x8000000000000000LL), fn(0, 0, 0, 0x8000000000000000LL));
916 return 0;
917}
918
919DART_EXPORT intptr_t
920TestUintComputation(uint64_t (*fn)(uint8_t, uint16_t, uint32_t, uint64_t)) {
921 CHECK_EQ(0x7FFFFFFFFFFFFFFFLL, fn(0, 0, 0, 0x7FFFFFFFFFFFFFFFLL));
922 CHECK_EQ(0x8000000000000000LL, fn(0, 0, 0, 0x8000000000000000LL));
923 CHECK_EQ(-1, (int64_t)fn(0, 0, 0, -1));
924 return 0;
925}
926
927DART_EXPORT intptr_t TestSimpleMultiply(double (*fn)(double)) {
928 CHECK_EQ(fn(2.0), 2.0 * 1.337);
929 return 0;
930}
931
932DART_EXPORT intptr_t TestSimpleMultiplyFloat(float (*fn)(float)) {
933 CHECK(::std::abs(fn(2.0) - 2.0 * 1.337) < 0.001);
934 return 0;
935}
936
937DART_EXPORT intptr_t TestManyInts(intptr_t (*fn)(intptr_t,
938 intptr_t,
939 intptr_t,
940 intptr_t,
941 intptr_t,
942 intptr_t,
943 intptr_t,
944 intptr_t,
945 intptr_t,
946 intptr_t)) {
947 CHECK_EQ(55, fn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
948 return 0;
949}
950
951DART_EXPORT intptr_t TestManyDoubles(double (*fn)(double,
952 double,
953 double,
954 double,
955 double,
956 double,
957 double,
958 double,
959 double,
960 double)) {
961 CHECK_EQ(55, fn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
962 return 0;
963}
964
965DART_EXPORT intptr_t TestManyArgs(double (*fn)(intptr_t a,
966 float b,
967 intptr_t c,
968 double d,
969 intptr_t e,
970 float f,
971 intptr_t g,
972 double h,
973 intptr_t i,
974 float j,
975 intptr_t k,
976 double l,
977 intptr_t m,
978 float n,
979 intptr_t o,
980 double p,
981 intptr_t q,
982 float r,
983 intptr_t s,
984 double t)) {
985 CHECK(210.0 == fn(1, 2.0, 3, 4.0, 5, 6.0, 7, 8.0, 9, 10.0, 11, 12.0, 13, 14.0,
986 15, 16.0, 17, 18.0, 19, 20.0));
987 return 0;
988}
989
990// Used for testing floating point argument backfilling on Arm32 in hardfp.
991DART_EXPORT intptr_t TestSumFloatsAndDoubles(double (*fn)(float,
992 double,
993 float)) {
994 CHECK_EQ(6.0, fn(1.0, 2.0, 3.0));
995 return 0;
996}
997
998// Very many small integers, tests alignment on stack.
999DART_EXPORT intptr_t TestSumVeryManySmallInts(int16_t (*fn)(int8_t,
1000 int16_t,
1001 int8_t,
1002 int16_t,
1003 int8_t,
1004 int16_t,
1005 int8_t,
1006 int16_t,
1007 int8_t,
1008 int16_t,
1009 int8_t,
1010 int16_t,
1011 int8_t,
1012 int16_t,
1013 int8_t,
1014 int16_t,
1015 int8_t,
1016 int16_t,
1017 int8_t,
1018 int16_t,
1019 int8_t,
1020 int16_t,
1021 int8_t,
1022 int16_t,
1023 int8_t,
1024 int16_t,
1025 int8_t,
1026 int16_t,
1027 int8_t,
1028 int16_t,
1029 int8_t,
1030 int16_t,
1031 int8_t,
1032 int16_t,
1033 int8_t,
1034 int16_t,
1035 int8_t,
1036 int16_t,
1037 int8_t,
1038 int16_t)) {
1039 CHECK_EQ(40 * 41 / 2, fn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
1040 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
1041 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40));
1042 return 0;
1043}
1044
1045// Very many floating points, tests alignment on stack, and packing in
1046// floating point registers in hardfp.
1047DART_EXPORT intptr_t TestSumVeryManyFloatsDoubles(double (*fn)(float,
1048 double,
1049 float,
1050 double,
1051 float,
1052 double,
1053 float,
1054 double,
1055 float,
1056 double,
1057 float,
1058 double,
1059 float,
1060 double,
1061 float,
1062 double,
1063 float,
1064 double,
1065 float,
1066 double,
1067 float,
1068 double,
1069 float,
1070 double,
1071 float,
1072 double,
1073 float,
1074 double,
1075 float,
1076 double,
1077 float,
1078 double,
1079 float,
1080 double,
1081 float,
1082 double,
1083 float,
1084 double,
1085 float,
1086 double)) {
1087 CHECK_EQ(40 * 41 / 2,
1088 fn(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0,
1089 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0,
1090 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0, 33.0, 34.0,
1091 35.0, 36.0, 37.0, 38.0, 39.0, 40.0));
1092 return 0;
1093}
1094
1095DART_EXPORT intptr_t TestStore(int64_t* (*fn)(int64_t* a)) {
1096 int64_t p[2] = {42, 1000};
1097 int64_t* result = fn(p);
1098 CHECK_EQ(*result, 1337);
1099 CHECK_EQ(p[1], 1337);
1100 CHECK_EQ(result, p + 1);
1101 return 0;
1102}
1103
1104DART_EXPORT intptr_t TestReturnNull(int32_t (*fn)()) {
1105 CHECK_EQ(fn(), 42);
1106 return 0;
1107}
1108
1109DART_EXPORT intptr_t TestNullPointers(int64_t* (*fn)(int64_t* ptr)) {
1110 CHECK_EQ(fn(nullptr), reinterpret_cast<void*>(sizeof(int64_t)));
1111 int64_t p[2] = {0};
1112 CHECK_EQ(fn(p), p + 1);
1113 return 0;
1114}
1115
1116DART_EXPORT intptr_t TestReturnVoid(intptr_t (*return_void)()) {
1117 CHECK_EQ(return_void(), 0);
1118 return 0;
1119}
1120
1121DART_EXPORT intptr_t TestThrowExceptionDouble(double (*fn)()) {
1122 CHECK_EQ(fn(), 42.0);
1123 return 0;
1124}
1125
1127 CHECK_EQ(fn(), nullptr);
1128 return 0;
1129}
1130
1131DART_EXPORT intptr_t TestThrowException(intptr_t (*fn)()) {
1132 CHECK_EQ(fn(), 42);
1133 return 0;
1134}
1135
1136DART_EXPORT intptr_t TestTakeMaxUint8x10(intptr_t (*fn)(uint8_t,
1137 uint8_t,
1138 uint8_t,
1139 uint8_t,
1140 uint8_t,
1141 uint8_t,
1142 uint8_t,
1143 uint8_t,
1144 uint8_t,
1145 uint8_t)) {
1146 CHECK_EQ(1, fn(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF));
1147 // Check the argument values are properly truncated.
1148 uint64_t v = 0xabcFF;
1149 CHECK_EQ(1, fn(v, v, v, v, v, v, v, v, v, v));
1150 return 0;
1151}
1152
1153DART_EXPORT intptr_t TestReturnMaxUint8(uint8_t (*fn)()) {
1154 std::cout << "TestReturnMaxUint8(fn): " << static_cast<int>(fn()) << "\n";
1155 CHECK_EQ(0xFF, fn());
1156 return 0;
1157}
1158
1159// Receives some pointer (Pointer<NativeType> in Dart) and writes some bits.
1161 uint8_t* p2 = reinterpret_cast<uint8_t*>(p);
1162 p2[0] = 42;
1163}
1164
1165// Manufactures some pointer (Pointer<NativeType> in Dart) with a bogus address.
1167 uint64_t bogus_address = 0x13370000;
1168 return reinterpret_cast<void*>(bogus_address);
1169}
1170
1171// Passes some pointer (Pointer<NativeType> in Dart) to Dart as argument.
1173 void* pointer = malloc(sizeof(int64_t));
1174 f(pointer);
1175 free(pointer);
1176}
1177
1178// Receives some pointer (Pointer<NativeType> in Dart) from Dart as return
1179// value.
1181 void* p = f();
1182 uint8_t* p2 = reinterpret_cast<uint8_t*>(p);
1183 p2[0] = 42;
1184}
1185
1186DART_EXPORT int32_t PassStruct(void*) {
1187 return 42;
1188}
1189
1192 uint64_t someValue;
1193};
1194
1196 return my_struct->someValue;
1197}
1198
1200 uint64_t val;
1201};
1202
1204 struct Struct46127 myStruct;
1205 myStruct.val = 123;
1206 return myStruct;
1207}
1208
1209#pragma pack(push, 1)
1211 int8_t a0;
1212 int16_t a1;
1213};
1214#pragma pack(pop)
1215
1219
1220// Define ssize_t for Windows as intptr_t.
1221#if defined(_WIN32)
1222typedef intptr_t ssize_t;
1223#endif
1224
1225#define DEFINE_SIZE_OF_AND_SIGN_OF(type_modifier, type, type2) \
1226 DART_EXPORT uint64_t FfiSizeOf_##type_modifier##_##type##_##type2() { \
1227 return sizeof(type_modifier type type2); \
1228 } \
1229 \
1230 DART_EXPORT uint64_t FfiSignOf_##type_modifier##_##type##_##type2() { \
1231 return std::numeric_limits<type_modifier type type2>::is_signed; \
1232 }
1233
1234#define TYPES(F) \
1235 F(, char, ) /* NOLINT */ \
1236 F(signed, char, ) /* NOLINT */ \
1237 F(unsigned, char, ) /* NOLINT */ \
1238 F(, short, ) /* NOLINT */ \
1239 F(unsigned, short, ) /* NOLINT */ \
1240 F(, int, ) /* NOLINT */ \
1241 F(unsigned, int, ) /* NOLINT */ \
1242 F(, long, ) /* NOLINT */ \
1243 F(unsigned, long, ) /* NOLINT */ \
1244 F(, long, long) /* NOLINT */ \
1245 F(unsigned, long, long) /* NOLINT */ \
1246 F(, intptr_t, ) /* NOLINT */ \
1247 F(, uintptr_t, ) /* NOLINT */ \
1248 F(, size_t, ) /* NOLINT */ \
1249 F(, wchar_t, ) /* NOLINT */
1250
1252
1253#undef DEFINE_SIZE_OF_AND_SIGN_OF
1254#undef TYPES
1255
1257 return WCHAR_MIN;
1258}
1260 return WCHAR_MAX;
1261}
1262
1263struct VarArgs {
1264 int32_t a;
1265};
1266
1268 va_list var_args;
1269 va_start(var_args, a0);
1270 VarArgs a1 = va_arg(var_args, VarArgs);
1271 va_end(var_args);
1272
1273 std::cout << "VariadicStructVarArgs" << "(" << a0.a << ", " << a1.a << ")"
1274 << "\n";
1275
1276 int64_t result = 0;
1277
1278 result += a0.a;
1279 result += a1.a;
1280
1281 std::cout << "result = " << result << "\n";
1282
1283 return result;
1284}
1285
1286////////////////////////////////////////////////////////////////////////////////
1287// Tests for async callbacks.
1288
1289DART_EXPORT void CallFunctionOnSameThread(int64_t response_id,
1290 void (*fn)(int64_t, int32_t)) {
1291 fn(response_id, 123);
1292}
1293
1295 void (*fn)(int64_t, int32_t)) {
1296 std::thread thread(fn, response_id, 123);
1297 thread.join();
1298}
1299
1301 void (*fn)(int64_t,
1302 int32_t)) {
1303 std::thread thread(fn, response_id, 123);
1304 thread.detach();
1305}
1306
1307////////////////////////////////////////////////////////////////////////////////
1308// Tests for isolate local callbacks.
1309
1310DART_EXPORT int32_t CallTwoIntFunction(int32_t (*fn)(int32_t, int32_t),
1311 int32_t a,
1312 int32_t b) {
1313 return fn(a, b);
1314}
1315
1316DART_EXPORT void CallTwoIntVoidFunction(void (*fn)(int32_t, int32_t),
1317 int32_t a,
1318 int32_t b) {
1319 fn(a, b);
1320}
1321
1322DART_EXPORT void* CallTwoIntPointerFunction(void* (*fn)(int32_t, int32_t),
1323 int32_t a,
1324 int32_t b) {
1325 return fn(a, b);
1326}
1327
1328DART_EXPORT int32_t CallTwoPointerIntFunction(int32_t (*fn)(void*, void*),
1329 void* a,
1330 void* b) {
1331 return fn(a, b);
1332}
1333
1334DART_EXPORT char TakeString(char* my_string) {
1335 std::cout << "TakeString(" << my_string << ")\n";
1336 return my_string[4];
1337}
1338
1339} // namespace dart
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition main.cc:19
static bool b
struct MyStruct s
struct MyStruct a[10]
#define DART_EXPORT
DART_EXPORT_FIELD struct Coord globalStruct
DART_EXPORT_FIELD int32_t globalInt
#define CHECK_EQ(X, Y)
#define TYPES(F)
#define DEFINE_SIZE_OF_AND_SIGN_OF(type_modifier, type, type2)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
GAsyncResult * result
double x
DART_EXPORT int32_t SumPlus42(int32_t a, int32_t b)
DART_EXPORT void NativeTypePointerParam(void *p)
DART_EXPORT double SumVeryManyFloatsDoubles(float a01, double a02, float a03, double a04, float a05, double a06, float a07, double a08, float a09, double a10, float a11, double a12, float a13, double a14, float a15, double a16, float a17, double a18, float a19, double a20, float a21, double a22, float a23, double a24, float a25, double a26, float a27, double a28, float a29, double a30, float a31, double a32, float a33, double a34, float a35, double a36, float a37, double a38, float a39, double a40)
DART_EXPORT int32_t ReturnMinInt32v2()
DART_EXPORT int64_t WCharMaxValue()
DART_EXPORT intptr_t TestReturnVoid(intptr_t(*return_void)())
DART_EXPORT int32_t ReturnMinInt32()
DART_EXPORT intptr_t TestManyDoubles(double(*fn)(double, double, double, double, double, double, double, double, double, double))
DART_EXPORT int64_t * NullableInt64ElemAt1(int64_t *a)
DART_EXPORT int32_t PassStruct(void *)
DART_EXPORT void CallbackNativeTypePointerParam(void(*f)(void *))
DART_EXPORT intptr_t TestUintComputation(uint64_t(*fn)(uint8_t, uint16_t, uint32_t, uint64_t))
DART_EXPORT uint32_t ReturnMaxUint32v2()
DART_EXPORT uint8_t IsRoughly1337(float *a)
DART_EXPORT intptr_t TakeMinInt8(int8_t x)
DART_EXPORT char TakeString(char *my_string)
DART_EXPORT int16_t SumManySmallInts(int8_t a, int16_t b, int8_t c, int16_t d, int8_t e, int16_t f, int8_t g, int16_t h, int8_t i, int16_t j)
DART_EXPORT int64_t Regress39044(int64_t a, int8_t b)
DART_EXPORT int32_t GetGlobalVar()
DART_EXPORT uint8_t ReturnMaxUint8()
DART_EXPORT intptr_t TestThrowExceptionDouble(double(*fn)())
DART_EXPORT intptr_t TestReturnMaxUint8(uint8_t(*fn)())
DART_EXPORT intptr_t TestManyArgs(double(*fn)(intptr_t a, float b, intptr_t c, double d, intptr_t e, float f, intptr_t g, double h, intptr_t i, float j, intptr_t k, double l, intptr_t m, float n, intptr_t o, double p, intptr_t q, float r, intptr_t s, double t))
DART_EXPORT int16_t ReturnMinInt16()
DART_EXPORT double Times1_337Double(double a)
DART_EXPORT intptr_t TestThrowExceptionPointer(void *(*fn)())
DART_EXPORT void * NativeTypePointerReturn()
DART_EXPORT int32_t CallTwoIntFunction(int32_t(*fn)(int32_t, int32_t), int32_t a, int32_t b)
void * malloc(size_t size)
Definition allocation.cc:19
DART_EXPORT void CallTwoIntVoidFunction(void(*fn)(int32_t, int32_t), int32_t a, int32_t b)
DART_EXPORT Struct20BytesHomogeneousInt32Copy PassStructRecursive(int64_t recursionCounter, Struct20BytesHomogeneousInt32Copy a0, Struct20BytesHomogeneousInt32Copy(*f)(int64_t, Struct20BytesHomogeneousInt32Copy))
DART_EXPORT uint64_t SizeOfStruct3BytesPackedInt()
DART_EXPORT void FreeStruct9Uint8(Struct9Uint8 *address)
DART_EXPORT int64_t SumVeryLargeStruct(VeryLargeStruct *vls)
DART_EXPORT intptr_t TestSimpleMultiplyFloat(float(*fn)(float))
DART_EXPORT intptr_t TakeMaxUint8x10(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t e, uint8_t f, uint8_t g, uint8_t h, uint8_t i, uint8_t j)
DART_EXPORT uint64_t Regress43693(Struct43693 *my_struct)
DART_EXPORT intptr_t ApplyTo42And74(IntptrBinOp binop)
DART_EXPORT intptr_t Regress40537Variant2(uint8_t x)
DART_EXPORT double SumFloatsAndDoubles(float a, double b, float c)
DART_EXPORT intptr_t TakeMinInt16(int16_t x)
DART_EXPORT uint32_t ReturnMaxUint32()
DART_EXPORT Struct46127 Regress46127()
DART_EXPORT intptr_t TakeMaxUint8(uint8_t x)
DART_EXPORT int64_t * Assign1337Index1(int64_t *a)
DART_EXPORT intptr_t TestSimpleAddition(intptr_t(*add)(int, int))
DART_EXPORT void CallFunctionOnSameThread(int64_t response_id, void(*fn)(int64_t, int32_t))
DART_EXPORT intptr_t Times3(intptr_t a)
DART_EXPORT uint16_t ReturnMaxUint16()
DART_EXPORT void DevNullFloat(float a)
DART_EXPORT intptr_t TestTakeMaxUint8x10(intptr_t(*fn)(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t))
DART_EXPORT uint16_t ReturnMaxUint16v2()
DART_EXPORT intptr_t TestSumVeryManySmallInts(int16_t(*fn)(int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t, int8_t, int16_t))
DART_EXPORT int16_t SumVeryManySmallInts(int8_t a01, int16_t a02, int8_t a03, int16_t a04, int8_t a05, int16_t a06, int8_t a07, int16_t a08, int8_t a09, int16_t a10, int8_t a11, int16_t a12, int8_t a13, int16_t a14, int8_t a15, int16_t a16, int8_t a17, int16_t a18, int8_t a19, int16_t a20, int8_t a21, int16_t a22, int8_t a23, int16_t a24, int8_t a25, int16_t a26, int8_t a27, int16_t a28, int8_t a29, int16_t a30, int8_t a31, int16_t a32, int8_t a33, int16_t a34, int8_t a35, int16_t a36, int8_t a37, int16_t a38, int8_t a39, int16_t a40)
DART_EXPORT void CallFunctionOnNewThreadNonBlocking(int64_t response_id, void(*fn)(int64_t, int32_t))
DART_EXPORT int8_t ReturnMinInt8()
DART_EXPORT intptr_t TestManyInts(intptr_t(*fn)(intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t))
DART_EXPORT intptr_t TestSimpleMultiply(double(*fn)(double))
DART_EXPORT intptr_t TestSumVeryManyFloatsDoubles(double(*fn)(float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double, float, double))
DART_EXPORT void CallbackNativeTypePointerReturn(void *(*f)())
DART_EXPORT Coord * CoordinateElemAt1(Coord *coord)
DART_EXPORT float InventFloatValue()
DART_EXPORT intptr_t TestThrowException(intptr_t(*fn)())
DART_EXPORT intptr_t TakeMinInt32(int32_t x)
DART_EXPORT intptr_t TestStore(int64_t *(*fn)(int64_t *a))
Coord *(* CoordUnOp)(Coord *coord)
DART_EXPORT Struct9Uint8 * AllocStruct9Uint8()
DART_EXPORT double SumManyDoubles(double a, double b, double c, double d, double e, double f, double g, double h, double i, double j)
DART_EXPORT intptr_t TestIntComputation(int64_t(*fn)(int8_t, int16_t, int32_t, int64_t))
DART_EXPORT int64_t SumSmallNumbers(int8_t a, int16_t b, int32_t c, uint8_t d, uint16_t e, uint32_t f)
DART_EXPORT float Times1_337Float(float a)
DART_EXPORT void CallFunctionOnNewThreadBlocking(int64_t response_id, void(*fn)(int64_t, int32_t))
DART_EXPORT intptr_t Regress40537(uint8_t x)
DART_EXPORT int64_t UintComputation(uint8_t a, uint16_t b, uint32_t c, uint64_t d)
DART_EXPORT intptr_t SumManyInts(intptr_t a, intptr_t b, intptr_t c, intptr_t d, intptr_t e, intptr_t f, intptr_t g, intptr_t h, intptr_t i, intptr_t j)
DART_EXPORT Coord GetGlobalStruct()
DART_EXPORT int64_t WCharMinValue()
DART_EXPORT uint8_t Regress40537Variant3(intptr_t x)
DART_EXPORT int64_t VariadicStructVarArgs(VarArgs a0,...)
DART_EXPORT int64_t SumReturnStruct9Uint8(Struct9Uint8(*callback)(Struct9Uint8 *), Struct9Uint8 *in)
DART_EXPORT void * CallTwoIntPointerFunction(void *(*fn)(int32_t, int32_t), int32_t a, int32_t b)
DART_EXPORT intptr_t SumManyIntsOdd(intptr_t a, intptr_t b, intptr_t c, intptr_t d, intptr_t e, intptr_t f, intptr_t g, intptr_t h, intptr_t i, intptr_t j, intptr_t k)
DART_EXPORT void InduceACrash()
DART_EXPORT int32_t CallTwoPointerIntFunction(int32_t(*fn)(void *, void *), void *a, void *b)
DART_EXPORT intptr_t TakeMaxUint32(uint32_t x)
DART_EXPORT double SumManyNumbers(intptr_t a, float b, intptr_t c, double d, intptr_t e, float f, intptr_t g, double h, intptr_t i, float j, intptr_t k, double l, intptr_t m, float n, intptr_t o, double p, intptr_t q, float r, intptr_t s, double t)
DART_EXPORT intptr_t TestNullPointers(int64_t *(*fn)(int64_t *ptr))
DART_EXPORT intptr_t TestReturnNull(int32_t(*fn)())
DART_EXPORT IntptrBinOp IntptrAdditionClosure()
DART_EXPORT int8_t ReturnMinInt8v2()
DART_EXPORT uint8_t ReturnMaxUint8v2()
DART_EXPORT int16_t ReturnMinInt16v2()
DART_EXPORT Coord * CoordinateUnOpTrice(CoordUnOp unop, Coord *coord)
DART_EXPORT int64_t SumStruct9Uint8(Struct9Uint8 s9)
DART_EXPORT int64_t IntComputation(int8_t a, int16_t b, int32_t c, int64_t d)
DART_EXPORT intptr_t TakeMaxUint16(uint16_t x)
DART_EXPORT intptr_t TestSumFloatsAndDoubles(double(*fn)(float, double, float))
DART_EXPORT void CallbackWithStruct(void(*f)(Struct8BytesNestedIntCopy))
intptr_t(* IntptrBinOp)(intptr_t a, intptr_t b)
DART_EXPORT void SetGlobalVar(int32_t v)
DART_EXPORT Coord * TransposeCoordinate(Coord *coord)
SkScalar h
double x
struct Coord * next
double y
Struct4BytesHomogeneousInt16Copy a1
Struct4BytesHomogeneousInt16Copy a0
#define CHECK(value)
unsigned long DWORD