forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

abi-probe.c90 lines, 2.9 KiBHistoryRawDownload
1/*
2 * ABI probe for the hand-written libva FFI in src/sys.rs.
3 *
4 * src/sys.rs transcribes libva struct layouts by hand (no bindgen, family rule).
5 * This probe is the evidence for that transcription: it prints the sizes,
6 * alignments and field offsets that the *system* headers produce, so the
7 * `const _: () = assert!(...)` block in sys.rs can be checked against a real
8 * compiler instead of against a reading of the header.
9 *
10 * Run:
11 * cc -o /tmp/ec-va-abi-probe crates/ec-va/abi-probe.c $(pkg-config --cflags --libs libva) \
12 * && /tmp/ec-va-abi-probe
13 *
14 * Recorded output (libva 1.23.0, x86_64-unknown-linux-gnu, gcc 15) is pasted
15 * into the assertion block in sys.rs. Any mismatch after a libva upgrade means
16 * the transcription drifted — the exact failure mode that broke cros-libva at
17 * libva >= 1.23.
18 */
19#include <stdio.h>
20#include <stddef.h>
21#include <va/va.h>
22#include <va/va_drmcommon.h>
23
24#define SA(T) printf("%-32s size=%-5zu align=%zu\n", #T, sizeof(T), _Alignof(T))
25#define OF(T, F) printf(" %-30s offset=%zu\n", #T "." #F, offsetof(T, F))
26
27int main(void)
28{
29 printf("libva headers: %s\n", VA_VERSION_S);
30
31 SA(VAStatus);
32 SA(VAGenericID);
33 SA(VAProfile);
34 SA(VAEntrypoint);
35 SA(VAConfigAttribType);
36 SA(VAConfigAttrib);
37 OF(VAConfigAttrib, type);
38 OF(VAConfigAttrib, value);
39
40 SA(VAGenericValue);
41 OF(VAGenericValue, type);
42 OF(VAGenericValue, value);
43
44 SA(VASurfaceAttrib);
45 OF(VASurfaceAttrib, type);
46 OF(VASurfaceAttrib, flags);
47 OF(VASurfaceAttrib, value);
48
49 SA(VAImageFormat);
50 OF(VAImageFormat, fourcc);
51 OF(VAImageFormat, byte_order);
52 OF(VAImageFormat, bits_per_pixel);
53 OF(VAImageFormat, depth);
54 OF(VAImageFormat, red_mask);
55 OF(VAImageFormat, alpha_mask);
56 OF(VAImageFormat, va_reserved);
57
58 SA(VAImage);
59 OF(VAImage, image_id);
60 OF(VAImage, format);
61 OF(VAImage, buf);
62 OF(VAImage, width);
63 OF(VAImage, height);
64 OF(VAImage, data_size);
65 OF(VAImage, num_planes);
66 OF(VAImage, pitches);
67 OF(VAImage, offsets);
68 OF(VAImage, num_palette_entries);
69 OF(VAImage, entry_bytes);
70 OF(VAImage, component_order);
71 OF(VAImage, va_reserved);
72
73 SA(VADRMPRIMESurfaceDescriptor);
74 OF(VADRMPRIMESurfaceDescriptor, fourcc);
75 OF(VADRMPRIMESurfaceDescriptor, width);
76 OF(VADRMPRIMESurfaceDescriptor, height);
77 OF(VADRMPRIMESurfaceDescriptor, num_objects);
78 OF(VADRMPRIMESurfaceDescriptor, objects);
79 OF(VADRMPRIMESurfaceDescriptor, num_layers);
80 OF(VADRMPRIMESurfaceDescriptor, layers);
81 printf(" object elem size=%zu align=%zu\n",
82 sizeof(((VADRMPRIMESurfaceDescriptor *)0)->objects[0]),
83 _Alignof(((VADRMPRIMESurfaceDescriptor *)0)->objects[0]));
84 printf(" layer elem size=%zu align=%zu\n",
85 sizeof(((VADRMPRIMESurfaceDescriptor *)0)->layers[0]),
86 _Alignof(((VADRMPRIMESurfaceDescriptor *)0)->layers[0]));
87
88 SA(VARectangle);
89 return 0;
90}