v0.11.1 15800b5

callback_packing_test.c RawHistoryFolder

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: 2026 The Ebitengine Authors
3
4#include <stdint.h>
5#include <stdbool.h>
6
7// Test: 12 int32 arguments - fills 8 int registers, then 4 go to stack
8// With tight packing, the 4 stack args pack into 16 bytes (4x4)
9// Without tight packing, they would use 32 bytes (4x8)
10typedef int32_t (*callback_12_int32)(int32_t, int32_t, int32_t, int32_t,
11                                      int32_t, int32_t, int32_t, int32_t,
12                                      int32_t, int32_t, int32_t, int32_t);
13
14int32_t callCallback12Int32(const void *fp) {
15    // Using prime numbers to detect argument misalignment
16    return ((callback_12_int32)(fp))(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37);
17}
18
19// Test: mixed int64 and int32 arguments with stack spillover
20// 8 int64s fill registers, then int32/int64/int32 go to stack
21// Tests alignment handling when mixing sizes on stack
22typedef int64_t (*callback_mixed_stack)(int64_t, int64_t, int64_t, int64_t,
23                                         int64_t, int64_t, int64_t, int64_t,
24                                         int32_t, int64_t, int32_t);
25
26int64_t callCallbackMixedStack(const void *fp) {
27    return ((callback_mixed_stack)(fp))(1, 2, 3, 4, 5, 6, 7, 8, 100, 200, 300);
28}
29
30// Test: various small types on stack
31// 8 int64s fill registers, then bool/int8/uint8/int16/uint16/int32 go to stack
32// Tests byte-level packing of different small types
33typedef int64_t (*callback_small_types)(int64_t, int64_t, int64_t, int64_t,
34                                         int64_t, int64_t, int64_t, int64_t,
35                                         bool, int8_t, uint8_t, int16_t, uint16_t, int32_t);
36
37int64_t callCallbackSmallTypes(const void *fp) {
38    return ((callback_small_types)(fp))(1, 2, 3, 4, 5, 6, 7, 8,
39                                        true, -42, 200, -1000, 50000, 123456);
40}
41
42// Test: 10 int32 arguments - simpler case
43// 8 fill registers, 2 go to stack (8 bytes packed vs 16 unpacked)
44typedef int32_t (*callback_10_int32)(int32_t, int32_t, int32_t, int32_t,
45                                      int32_t, int32_t, int32_t, int32_t,
46                                      int32_t, int32_t);
47
48int32_t callCallback10Int32(const void *fp) {
49    return ((callback_10_int32)(fp))(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
50}
51
52// Test: 10 float64 arguments - fills 8 float registers, then 2 go to stack
53// Callback returns int64 since purego callbacks don't support float returns
54typedef int64_t (*callback_10_float64)(double, double, double, double,
55                                        double, double, double, double,
56                                        double, double);
57
58int64_t callCallback10Float64(const void *fp) {
59    return ((callback_10_float64)(fp))(1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5);
60}
61
62// Test: 12 float32 arguments - fills 8 float registers, then 4 go to stack
63// Callback returns int64 since purego callbacks don't support float returns
64typedef int64_t (*callback_12_float32)(float, float, float, float,
65                                        float, float, float, float,
66                                        float, float, float, float);
67
68int64_t callCallback12Float32(const void *fp) {
69    return ((callback_12_float32)(fp))(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f,
70                                        7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f);
71}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close