interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / src / cudapp_freest_pathcopy.c

382 lines · 35104 bytes Raw Blame History
1/* Generated by om/native-freest.sh from om/components/pathcopy.om.
2 * omega-bridge tools/native --freestanding (stage-5 converter). Do not edit.
3 * AArch64 and x86-64 only. The unused half is not compiled. */
4#if defined(__aarch64__)
5/* Generated pure integer-scalar freestanding native ABI v1 binding. */
6#include <stdint.h>
7#if !defined(__ELF__)
8#error "omega-bridge freestanding binding: ELF objects only"
9#endif
10#define OMBR_SYM(n) #n
11#define OMBR_LOCAL(n) ".local " #n "\n"
12#define OMBR_HIDDEN(n) ".hidden " #n "\n"
13#define OMBR_CODE_SECTION ".section .text.omega_bridge,\"ax\",@progbits\n"
14#define OMBR_PREVIOUS ".previous\n"
15#define OMEGA_OK 0u
16#define OMEGA_BAD_ARG 32u
17#define OMEGA_BAD_RT 34u
18typedef struct ombr_rt { const void *entry[32]; } ombr_rt;
19uint32_t ombr_enter(const void *code, const uint64_t *args, const ombr_rt *rt, uint64_t *out, void *top)
20 __attribute__((visibility("hidden")));
21extern const unsigned char ombr_trap[] __attribute__((visibility("hidden")));
22extern const unsigned char ombr_no_entry[] __attribute__((visibility("hidden")));
23/* ombr_enter saves the callee-saved registers on the caller's stack, keeps that stack pointer in x19 and
24 * runs the pure scalar code on the caller's stack. A normal return stores x0 through out and
25 * returns 0. A runtime entry restores the stack pointer from x19 and returns a status; out is not
26 * written. A unit's code must not write x18, x19 or x29 and must keep sp balanced; it may write
27 * x0..x17, x20..x28 and v0..v31 (x20..x28 and d8..d15 are restored here). Runtime entries are reached by blr/br, so they
28 * start with bti jc. */
29__asm__(".text\n.balign 4\n.local ombr_enter\n.hidden ombr_enter\n.type ombr_enter,%function\nombr_enter:\n"
30 "hint #34\nstp x29,x30,[sp,#-176]!\nmov x29,sp\nstp x19,x20,[sp,#16]\nstp x21,x22,[sp,#32]\n"
31 "stp x23,x24,[sp,#48]\nstp x25,x26,[sp,#64]\nstp x27,x28,[sp,#80]\nstp d8,d9,[sp,#96]\n"
32 "stp d10,d11,[sp,#112]\nstp d12,d13,[sp,#128]\nstp d14,d15,[sp,#144]\nstr x3,[sp,#160]\n"
33 "mov x19,sp\nmov x16,x0\nmov x17,x1\nmov x7,x2\n"
34 "ldp x0,x1,[x17]\nldp x2,x3,[x17,#16]\nldp x4,x5,[x17,#32]\nblr x16\n"
35 "mov sp,x19\nldr x9,[sp,#160]\nstr x0,[x9]\nmov w0,#0\n"
36 "ombr_leave:\nldp d14,d15,[sp,#144]\nldp d12,d13,[sp,#128]\nldp d10,d11,[sp,#112]\n"
37 "ldp d8,d9,[sp,#96]\nldp x27,x28,[sp,#80]\nldp x25,x26,[sp,#64]\nldp x23,x24,[sp,#48]\n"
38 "ldp x21,x22,[sp,#32]\nldp x19,x20,[sp,#16]\nldp x29,x30,[sp],#176\nret\n.size ombr_enter,.-ombr_enter\n"
39 ".local ombr_trap\n.hidden ombr_trap\n.type ombr_trap,%function\nombr_trap:\nhint #38\n"
40 "mov sp,x19\nsub x2,x1,#1\nmov w3,#34\ncmp x2,#13\ncsel w0,w1,w3,ls\nb ombr_leave\n"
41 ".size ombr_trap,.-ombr_trap\n"
42 ".local ombr_no_entry\n.hidden ombr_no_entry\n.type ombr_no_entry,%function\nombr_no_entry:\nhint #38\n"
43 "mov sp,x19\nmov w0,#34\nb ombr_leave\n.size ombr_no_entry,.-ombr_no_entry\n");
44static const ombr_rt ombr_rt_table = {{ ombr_no_entry, ombr_no_entry, ombr_trap, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry }};
45static uint32_t ombr_run(const void *code, const uint64_t *args, uint64_t *result, int has_value)
46{
47 uint64_t v = 0;
48 uint32_t status = ombr_enter(code, args, &ombr_rt_table, &v, 0);
49 if (status == OMEGA_OK)
50 *result = has_value ? v : 0u;
51 return status;
52}
53/* ABI v2, freestanding (docs/NATIVE-ABI.md, ABI v2, output freest): OM-2 units on the caller's stack. The
54 * argument checks are those of output c. Each out parameter is written to a buffer in the calling
55 * function's frame (16-byte aligned, zero-filled) and copied to the caller only after status 0. No
56 * thread-local state, heap or stack mapping; no C library calls are required. */
57typedef struct ombr_span { uintptr_t lo, hi; int w; } ombr_span;
58typedef struct ombr2_out { unsigned slot; uint64_t n; void *dst; } ombr2_out;
59/* A binding of OM-2 units alone does not call the ABI v1 helper. */
60__attribute__((unused)) static void ombr2_keep(void)
61{
62 (void)ombr_run;
63}
64static int ombr_span_add(ombr_span *sp, unsigned *ns, const void *p, uint64_t n, uint64_t want, uint64_t es, int w)
65{
66 uintptr_t lo = (uintptr_t)p;
67 if (!p || n != want || lo % es != 0u || n > (UINTPTR_MAX - lo) / es)
68 return 1;
69 sp[*ns].lo = lo;
70 sp[*ns].hi = lo + n * es;
71 sp[*ns].w = w;
72 (*ns)++;
73 return 0;
74}
75/* An unsized view of n elements of es bytes, as in output c. */
76__attribute__((unused)) static int ombr2_view(ombr_span *sp, unsigned *ns, const void *p, uint64_t n, uint64_t es, int w)
77{
78 uintptr_t lo = (uintptr_t)p;
79 if (n == 0u)
80 return 0;
81 if (!p || lo % es != 0u || n > UINT64_MAX / es || n * es > UINTPTR_MAX - lo)
82 return 1;
83 sp[*ns].lo = lo;
84 sp[*ns].hi = lo + n * es;
85 sp[*ns].w = w;
86 (*ns)++;
87 return 0;
88}
89/* A fixed range of nb > 0 bytes (a layout or an out parameter) aligned to es. */
90__attribute__((unused)) static int ombr2_fixed(ombr_span *sp, unsigned *ns, const void *p, uint64_t nb, uint64_t es,
91 int w)
92{
93 uintptr_t lo = (uintptr_t)p;
94 if (!p || lo % es != 0u || nb > UINTPTR_MAX - lo)
95 return 1;
96 sp[*ns].lo = lo;
97 sp[*ns].hi = lo + nb;
98 sp[*ns].w = w;
99 (*ns)++;
100 return 0;
101}
102/* w: 0 view, 1 edit or the result, 2 out; refused overlaps as in output c. */
103static int ombr2_overlap(const ombr_span *sp, unsigned ns)
104{
105 for (unsigned i = 0; i < ns; i++)
106 for (unsigned j = i + 1; j < ns; j++)
107 if ((sp[i].w == 1 || sp[j].w == 1 || (sp[i].w == 2 && sp[j].w == 2))
108 && sp[i].lo < sp[j].hi && sp[j].lo < sp[i].hi)
109 return 1;
110 return 0;
111}
112/* Byte transport only: volatile stores prevent libc idiom substitution. The copy source is
113 * this entry's private out frame, disjoint from caller buffers checked by the wrapper. */
114static void ombr2_zero_bytes(unsigned char *p, uint64_t n) {
115 volatile unsigned char *d = p;
116 for (uint64_t i = 0; i < n; i++) d[i] = 0;
117}
118static void ombr2_copy_bytes(void *p, const unsigned char *s, uint64_t n) {
119 volatile unsigned char *d = p;
120 for (uint64_t i = 0; i < n; i++) d[i] = s[i];
121}
122/* As ombr_run; each out buffer is carved from ob (the entry's frame, 16-byte aligned, each buffer rounded
123 * up to 16 bytes), zero-filled, passed in its slot and copied to the caller only after status 0. */
124static uint32_t ombr2_run(const void *code, uint64_t *args, uint64_t *result, int has_value, const ombr2_out *o,
125 unsigned no, unsigned char *ob)
126{
127 unsigned char *buf[6] = {0};
128 for (unsigned i = 0; i < no; i++) {
129 ombr2_zero_bytes(ob, o[i].n);
130 buf[i] = ob;
131 args[o[i].slot] = (uint64_t)(uintptr_t)ob;
132 ob += (o[i].n + 15u) / 16u * 16u;
133 }
134 uint64_t v = 0;
135 uint32_t s = ombr_enter(code, args, &ombr_rt_table, &v, 0);
136 if (s == OMEGA_OK) {
137 for (unsigned i = 0; i < no; i++)
138 ombr2_copy_bytes(o[i].dst, buf[i], o[i].n);
139 *result = has_value ? v : 0u;
140 }
141 return s;
142}
143__asm__(OMBR_CODE_SECTION ".balign 4\n" OMBR_LOCAL(ombr2_code_pathcopy) OMBR_HIDDEN(ombr2_code_pathcopy) OMBR_SYM(ombr2_code_pathcopy) ":\n.byte 0x71,0x00,0x00,0x14,0x92,0x00,0x00,0x14,0x1f,0x84,0x01,0xf1,0xe1,0x37,0x9f,0x9a,0x1f,0xe8,0x01,0xf1,0xe2,0x87,0x9f,0x9a,0x23,0x00,0x02,0x8a,0x1f,0x04,0x01,0xf1,0xe4,0x37,0x9f,0x9a,0x1f,0x68,0x01,0xf1,0xe5,0x87,0x9f,0x9a,0x86,0x00,0x05,0x8a,0x68,0x00,0x06,0xaa,0x48,0x00,0x00,0xb4,0xc0,0x03,0x5f,0xd6,0x1f,0xc0,0x00,0xf1,0xe1,0x37,0x9f,0x9a,0x1f,0xe4,0x00,0xf1,0xe2,0x87,0x9f,0x9a,0x23,0x00,0x02,0x8a,0x43,0x00,0x00,0xb4,0xc0,0x03,0x5f,0xd6,0x1f,0xb8,0x00,0xf1,0xe1,0x17,0x9f,0x9a,0x1f,0x7c,0x01,0xf1,0xe2,0x17,0x9f,0x9a,0x23,0x00,0x02,0xaa,0x1f,0xb4,0x00,0xf1,0xe4,0x17,0x9f,0x9a,0x65,0x00,0x04,0xaa,0x1f,0xbc,0x00,0xf1,0xe6,0x17,0x9f,0x9a,0xa8,0x00,0x06,0xaa,0x48,0x00,0x00,0xb4,0xc0,0x03,0x5f,0xd6,0x1f,0xac,0x00,0xf1,0xe1,0x17,0x9f,0x9a,0x1f,0xb0,0x00,0xf1,0xe2,0x17,0x9f,0x9a,0x23,0x00,0x02,0xaa,0x1f,0xf4,0x00,0xf1,0xe4,0x17,0x9f,0x9a,0x65,0x00,0x04,0xaa,0x1f,0x00,0x01,0xf1,0xe6,0x17,0x9f,0x9a,0xa8,0x00,0x06,0xaa,0x48,0x00,0x00,0xb4,0xc0,0x03,0x5f,0xd6,0x1f,0xe8,0x00,0xf1,0xe1,0x17,0x9f,0x9a,0x1f,0xf8,0x01,0xf1,0xe2,0x17,0x9f,0x9a,0x23,0x00,0x02,0xaa,0x43,0x00,0x00,0xb4,0xc0,0x03,0x5f,0xd6,0x00,0x20,0x80,0xd2,0xc0,0x03,0x5f,0xd6,0x3f,0x00,0x00,0xf1,0x61,0x01,0x00,0x54,0x5f,0x00,0x00,0xf1,0xe4,0x17,0x9f,0x9a,0x1f,0x08,0x00,0xf1,0xe5,0x17,0x9f,0x9a,0x86,0x00,0x05,0xaa,0x66,0x00,0x00,0xb4,0x80,0x00,0x80,0xd2,0xc0,0x03,0x5f,0xd6,0xa0,0x00,0x80,0xd2,0xc0,0x03,0x5f,0xd6,0x5f,0x00,0x03,0xeb,0x63,0x00,0x00,0x54,0x80,0x00,0x80,0xd2,0xc0,0x03,0x5f,0xd6,0x64,0x04,0x00,0xd1,0x5f,0x00,0x04,0xeb,0x63,0x00,0x00,0x54,0x80,0x00,0x80,0xd2,0xc0,0x03,0x5f,0xd6,0xff,0xc3,0x00,0xd1,0xe0,0x03,0x00,0xf9,0xe1,0x07,0x00,0xf9,0xe2,0x0b,0x00,0xf9,0xe3,0x0f,0x00,0xf9,0xfe,0x13,0x00,0xf9,0xe0,0x07,0x40,0xf9,0xad,0xff,0xff,0x97,0xe4,0x03,0x00,0xaa,0xe0,0x03,0x40,0xf9,0xe1,0x07,0x40,0xf9,0xe2,0x0b,0x40,0xf9,0xe3,0x0f,0x40,0xf9,0xfe,0x13,0x40,0xf9,0xff,0xc3,0x00,0x91,0x9f,0x00,0x04,0xf1,0x61,0x00,0x00,0x54,0x80,0x00,0x80,0xd2,0xc0,0x03,0x5f,0xd6,0x3f,0xbc,0x00,0xf1,0xe1,0x00,0x00,0x54,0x1f,0x08,0x00,0xf1,0x61,0x00,0x00,0x54,0x80,0x00,0x80,0xd2,0xc0,0x03,0x5f,0xd6,0x00,0x00,0x80,0xd2,0xc0,0x03,0x5f,0xd6,0x3f,0xb8,0x00,0xf1,0xa1,0x00,0x00,0x54,0x1f,0x08,0x00,0xf1,0x62,0x00,0x00,0x54,0x00,0x04,0x00,0x91,0xc0,0x03,0x5f,0xd6,0x60,0x00,0x80,0xd2,0xc0,0x03,0x5f,0xd6,0xe2,0x03,0x01,0xaa,0x03,0x00,0x80,0xd2,0x04,0x00,0x80,0xd2,0x7f,0x00,0x02,0xeb,0x22,0x02,0x00,0x54,0x05,0x48,0x88,0xd2,0xe5,0x01,0xa0,0xf2,0x9f,0x00,0x05,0xeb,0xc2,0x02,0x00,0x54,0x84,0x04,0x00,0x91,0x7f,0x00,0x01,0xeb,0x22,0x02,0x00,0x54,0x05,0x68,0x63,0x38,0xbf,0x00,0x00,0xf1,0xa1,0x00,0x00,0x54,0x7f,0x00,0x01,0xeb,0x08,0x02,0x00,0x54,0xe0,0x03,0x03,0xaa,0xc0,0x03,0x5f,0xd6,0x63,0x04,0x00,0x91,0xef,0xff,0xff,0x17,0x5f,0x00,0x01,0xeb,0x48,0x01,0x00,0x54,0xe0,0x03,0x02,0xaa,0xc0,0x03,0x5f,0xd6,0xe0,0x03,0x07,0xaa,0xf0,0x08,0x40,0xf9,0x00,0x02,0x1f,0xd6,0x61,0x00,0x80,0xd2,0xfc,0xff,0xff,0x17,0x81,0x00,0x80,0xd2,0xfa,0xff,0xff,0x17,0x41,0x01,0x80,0xd2,0xf8,0xff,0xff,0x17,0xe4,0x03,0x01,0xaa,0xe5,0x03,0x03,0xaa,0x9f,0x00,0x00,0xf1,0xc1,0x00,0x00,0x54,0x06,0x00,0x80,0xd2,0xdf,0x04,0x00,0xf1,0xe8,0x09,0x00,0x54,0xe0,0x03,0x06,0xaa,0xc0,0x03,0x5f,0xd6,0x06,0x00,0x80,0xd2,0x08,0x00,0x80,0xd2,0x09,0x00,0x80,0xd2,0x1f,0x01,0x04,0xeb,0x82,0x07,0x00,0x54,0x0a,0x48,0x88,0xd2,0xea,0x01,0xa0,0xf2,0x3f,0x01,0x0a,0xeb,0x42,0x08,0x00,0x54,0x29,0x05,0x00,0x91,0x1f,0x01,0x01,0xeb,0xa2,0x07,0x00,0x54,0x0a,0x68,0x68,0x38,0xff,0x83,0x01,0xd1,0xe0,0x03,0x00,0xf9,0xe1,0x07,0x00,0xf9,0xe2,0x0b,0x00,0xf9,0xe3,0x0f,0x00,0xf9,0xe4,0x13,0x00,0xf9,0xe5,0x17,0x00,0xf9,0xe6,0x1b,0x00,0xf9,0xe8,0x1f,0x00,0xf9,0xe9,0x23,0x00,0xf9,0xea,0x27,0x00,0xf9,0xeb,0x2b,0x00,0xf9,0xfe,0x2f,0x00,0xf9,0xe0,0x1b,0x40,0xf9,0xe1,0x27,0x40,0xf9,0xe2,0x1f,0x40,0xf9,0xe3,0x17,0x40,0xf9,0x7f,0xff,0xff,0x97,0xeb,0x03,0x00,0xaa,0xe0,0x03,0x40,0xf9,0xe1,0x07,0x40,0xf9,0xe2,0x0b,0x40,0xf9,0xe3,0x0f,0x40,0xf9,0xe4,0x13,0x40,0xf9,0xe5,0x17,0x40,0xf9,0xe6,0x1b,0x40,0xf9,0xe8,0x1f,0x40,0xf9,0xe9,0x23,0x40,0xf9,0xea,0x27,0x40,0xf9,0xfe,0x2f,0x40,0xf9,0xff,0x83,0x01,0x91,0x7f,0x11,0x00,0xf1,0xc1,0x00,0x00,0x54,0x0c,0x00,0x80,0xd2,0x9f,0x05,0x00,0xf1,0x88,0x03,0x00,0x54,0xe0,0x03,0x0c,0xaa,0xc0,0x03,0x5f,0xd6,0x1f,0x01,0x03,0xeb,0x82,0x02,0x00,0x54,0x4a,0x68,0x28,0x38,0x7f,0x15,0x00,0xf1,0xc1,0x00,0x00,0x54,0x2c,0x00,0x80,0xd2,0x9f,0x05,0x00,0xf1,0x48,0x02,0x00,0x54,0xe0,0x03,0x0c,0xaa,0xc0,0x03,0x5f,0xd6,0xe6,0x03,0x0b,0xaa,0x08,0x05,0x00,0x91,0xc4,0xff,0xff,0x17,0x08,0x00,0x80,0xd2,0x1f,0x05,0x00,0xf1,0x48,0x01,0x00,0x54,0xe0,0x03,0x08,0xaa,0xc0,0x03,0x5f,0xd6,0xe0,0x03,0x07,0xaa,0xf0,0x08,0x40,0xf9,0x00,0x02,0x1f,0xd6,0x61,0x00,0x80,0xd2,0xfc,0xff,0xff,0x17,0x81,0x00,0x80,0xd2,0xfa,0xff,0xff,0x17,0x41,0x01,0x80,0xd2,0xf8,0xff,0xff,0x17\n" OMBR_PREVIOUS);
144static const char ombr2_ident_pathcopy[] = "omega-ident 1 unit=pathcopy abi=2 profile=OM-2 src=5e636828a24e58b93b5985c75636f5c5da3907f3a49c28cc0862d98c5c7c43a0 omc=2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f";
145__attribute__((visibility("default"))) const char *omega2_ident_pathcopy(void)
146{
147 return ombr2_ident_pathcopy;
148}
149__asm__(OMBR_CODE_SECTION ".balign 4\n" OMBR_LOCAL(ombr2_entry_pathlen) OMBR_HIDDEN(ombr2_entry_pathlen) OMBR_SYM(ombr2_entry_pathlen) ":\nhint #34\nb " OMBR_SYM(ombr2_code_pathcopy) "+0\n" OMBR_PREVIOUS);
150extern const unsigned char ombr2_entry_pathlen[] __attribute__((visibility("hidden")));
151/* export fn pathlen a view uchar * to ulong */
152__attribute__((visibility("default"))) uint32_t omega2_pathlen(uint64_t *result, const uint8_t *o_a, uint64_t o_a_len)
153{
154 ombr_span sp[7] = {{0}};
155 unsigned ns = 0;
156 uint64_t a[6] = {0};
157 ombr2_out ou[6] = {{0, 0, 0}};
158 unsigned no = 0;
159 if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1))
160 return OMEGA_BAD_ARG;
161 if (ombr2_view(sp, &ns, o_a, o_a_len, 1u, 0))
162 return OMEGA_BAD_ARG;
163 a[0] = (uint64_t)(uintptr_t)o_a;
164 a[1] = o_a_len;
165 if (ombr2_overlap(sp, ns))
166 return OMEGA_BAD_ARG;
167 return ombr2_run(ombr2_entry_pathlen, a, result, 1, ou, no, 0);
168}
169__asm__(OMBR_CODE_SECTION ".balign 4\n" OMBR_LOCAL(ombr2_entry_pathcopy) OMBR_HIDDEN(ombr2_entry_pathcopy) OMBR_SYM(ombr2_entry_pathcopy) ":\nhint #34\nb " OMBR_SYM(ombr2_code_pathcopy) "+4\n" OMBR_PREVIOUS);
170extern const unsigned char ombr2_entry_pathcopy[] __attribute__((visibility("hidden")));
171/* export fn pathcopy src view uchar * dst edit uchar * to ulong */
172__attribute__((visibility("default"))) uint32_t omega2_pathcopy(uint64_t *result, const uint8_t *o_src, uint64_t o_src_len, uint8_t *o_dst, uint64_t o_dst_len)
173{
174 ombr_span sp[7] = {{0}};
175 unsigned ns = 0;
176 uint64_t a[6] = {0};
177 ombr2_out ou[6] = {{0, 0, 0}};
178 unsigned no = 0;
179 if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1))
180 return OMEGA_BAD_ARG;
181 if (ombr2_view(sp, &ns, o_src, o_src_len, 1u, 0))
182 return OMEGA_BAD_ARG;
183 a[0] = (uint64_t)(uintptr_t)o_src;
184 a[1] = o_src_len;
185 if (ombr2_view(sp, &ns, o_dst, o_dst_len, 1u, 1))
186 return OMEGA_BAD_ARG;
187 a[2] = (uint64_t)(uintptr_t)o_dst;
188 a[3] = o_dst_len;
189 if (ombr2_overlap(sp, ns))
190 return OMEGA_BAD_ARG;
191 return ombr2_run(ombr2_entry_pathcopy, a, result, 1, ou, no, 0);
192}
193#elif defined(__x86_64__)
194/* Generated pure integer-scalar freestanding native ABI v1 binding. */
195#include <stdint.h>
196#if !defined(__ELF__)
197#error "omega-bridge freestanding binding: ELF objects only"
198#endif
199#define OMBR_SYM(n) #n
200#define OMBR_LOCAL(n) ".local " #n "\n"
201#define OMBR_HIDDEN(n) ".hidden " #n "\n"
202#define OMBR_CODE_SECTION ".section .text.omega_bridge,\"ax\",@progbits\n"
203#define OMBR_PREVIOUS ".previous\n"
204#define OMEGA_OK 0u
205#define OMEGA_BAD_ARG 32u
206#define OMEGA_BAD_RT 34u
207typedef struct ombr_rt { const void *entry[32]; } ombr_rt;
208uint32_t ombr_enter(const void *code, const uint64_t *args, const ombr_rt *rt, uint64_t *out, void *top)
209 __attribute__((visibility("hidden")));
210extern const unsigned char ombr_trap[] __attribute__((visibility("hidden")));
211extern const unsigned char ombr_no_entry[] __attribute__((visibility("hidden")));
212/* SysV AMD64 adapter to the pinned private Omega frame ABI on the caller's stack. ombr_enter saves
213 * the callee-saved registers there, keeps that stack pointer in R12, points R14 at the runtime table
214 * and sets the owned-stack floor R15 to 0, so, as in the AArch64 binding, the pure scalar code runs on
215 * the caller's stack with no bound check. A normal return stores RAX through out and returns 0. A
216 * runtime entry restores the stack pointer from R12 and returns a status; out is not written.
217 * CET shadow-stack enforcement is not supported by the nonlocal trap return. */
218__asm__(".text\n.balign 16\n.local ombr_enter\n.hidden ombr_enter\n.type ombr_enter,@function\nombr_enter:\n"
219 "endbr64\npush %rbx\npush %rbp\npush %r12\npush %r13\npush %r14\npush %r15\npush %rcx\n"
220 "mov %rsp,%r12\nmov %rdx,%r14\nxor %r15d,%r15d\nmov %rdi,%r10\n"
221 "mov %rsp,%rbp\nsub $256,%rsp\n"
222 "mov 0(%rsi),%rax\nmov %rax,-8(%rbp)\nmov 8(%rsi),%rax\nmov %rax,-16(%rbp)\n"
223 "mov 16(%rsi),%rax\nmov %rax,-24(%rbp)\nmov 24(%rsi),%rax\nmov %rax,-32(%rbp)\n"
224 "mov 32(%rsi),%rax\nmov %rax,-40(%rbp)\nmov 40(%rsi),%rax\nmov %rax,-48(%rbp)\n"
225 "call *%r10\nmov %r12,%rsp\nmov (%rsp),%rcx\nmov %rax,(%rcx)\nxor %eax,%eax\n"
226 "ombr_leave:\nadd $8,%rsp\npop %r15\npop %r14\npop %r13\npop %r12\npop %rbp\npop %rbx\nret\n"
227 ".size ombr_enter,.-ombr_enter\n.local ombr_trap\n.hidden ombr_trap\n.type ombr_trap,@function\nombr_trap:\n"
228 "endbr64\nmov %r12,%rsp\nlea -1(%rsi),%eax\ncmp $13,%eax\nmov $34,%eax\ncmovbe %esi,%eax\njmp ombr_leave\n"
229 ".size ombr_trap,.-ombr_trap\n.local ombr_no_entry\n.hidden ombr_no_entry\n.type ombr_no_entry,@function\nombr_no_entry:\n"
230 "endbr64\nmov %r12,%rsp\nmov $34,%eax\njmp ombr_leave\n.size ombr_no_entry,.-ombr_no_entry\n");
231static const ombr_rt ombr_rt_table = {{ ombr_no_entry, ombr_no_entry, ombr_trap, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry, ombr_no_entry }};
232static uint32_t ombr_run(const void *code, const uint64_t *args, uint64_t *result, int has_value)
233{
234 uint64_t v = 0;
235 uint32_t status = ombr_enter(code, args, &ombr_rt_table, &v, 0);
236 if (status == OMEGA_OK)
237 *result = has_value ? v : 0u;
238 return status;
239}
240/* ABI v2, freestanding (docs/NATIVE-ABI.md, ABI v2, output freest): OM-2 units on the caller's stack. The
241 * argument checks are those of output c. Each out parameter is written to a buffer in the calling
242 * function's frame (16-byte aligned, zero-filled) and copied to the caller only after status 0. No
243 * thread-local state, heap or stack mapping; no C library calls are required. */
244typedef struct ombr_span { uintptr_t lo, hi; int w; } ombr_span;
245typedef struct ombr2_out { unsigned slot; uint64_t n; void *dst; } ombr2_out;
246/* A binding of OM-2 units alone does not call the ABI v1 helper. */
247__attribute__((unused)) static void ombr2_keep(void)
248{
249 (void)ombr_run;
250}
251static int ombr_span_add(ombr_span *sp, unsigned *ns, const void *p, uint64_t n, uint64_t want, uint64_t es, int w)
252{
253 uintptr_t lo = (uintptr_t)p;
254 if (!p || n != want || lo % es != 0u || n > (UINTPTR_MAX - lo) / es)
255 return 1;
256 sp[*ns].lo = lo;
257 sp[*ns].hi = lo + n * es;
258 sp[*ns].w = w;
259 (*ns)++;
260 return 0;
261}
262/* An unsized view of n elements of es bytes, as in output c. */
263__attribute__((unused)) static int ombr2_view(ombr_span *sp, unsigned *ns, const void *p, uint64_t n, uint64_t es, int w)
264{
265 uintptr_t lo = (uintptr_t)p;
266 if (n == 0u)
267 return 0;
268 if (!p || lo % es != 0u || n > UINT64_MAX / es || n * es > UINTPTR_MAX - lo)
269 return 1;
270 sp[*ns].lo = lo;
271 sp[*ns].hi = lo + n * es;
272 sp[*ns].w = w;
273 (*ns)++;
274 return 0;
275}
276/* A fixed range of nb > 0 bytes (a layout or an out parameter) aligned to es. */
277__attribute__((unused)) static int ombr2_fixed(ombr_span *sp, unsigned *ns, const void *p, uint64_t nb, uint64_t es,
278 int w)
279{
280 uintptr_t lo = (uintptr_t)p;
281 if (!p || lo % es != 0u || nb > UINTPTR_MAX - lo)
282 return 1;
283 sp[*ns].lo = lo;
284 sp[*ns].hi = lo + nb;
285 sp[*ns].w = w;
286 (*ns)++;
287 return 0;
288}
289/* w: 0 view, 1 edit or the result, 2 out; refused overlaps as in output c. */
290static int ombr2_overlap(const ombr_span *sp, unsigned ns)
291{
292 for (unsigned i = 0; i < ns; i++)
293 for (unsigned j = i + 1; j < ns; j++)
294 if ((sp[i].w == 1 || sp[j].w == 1 || (sp[i].w == 2 && sp[j].w == 2))
295 && sp[i].lo < sp[j].hi && sp[j].lo < sp[i].hi)
296 return 1;
297 return 0;
298}
299/* Byte transport only: volatile stores prevent libc idiom substitution. The copy source is
300 * this entry's private out frame, disjoint from caller buffers checked by the wrapper. */
301static void ombr2_zero_bytes(unsigned char *p, uint64_t n) {
302 volatile unsigned char *d = p;
303 for (uint64_t i = 0; i < n; i++) d[i] = 0;
304}
305static void ombr2_copy_bytes(void *p, const unsigned char *s, uint64_t n) {
306 volatile unsigned char *d = p;
307 for (uint64_t i = 0; i < n; i++) d[i] = s[i];
308}
309/* As ombr_run; each out buffer is carved from ob (the entry's frame, 16-byte aligned, each buffer rounded
310 * up to 16 bytes), zero-filled, passed in its slot and copied to the caller only after status 0. */
311static uint32_t ombr2_run(const void *code, uint64_t *args, uint64_t *result, int has_value, const ombr2_out *o,
312 unsigned no, unsigned char *ob)
313{
314 unsigned char *buf[6] = {0};
315 for (unsigned i = 0; i < no; i++) {
316 ombr2_zero_bytes(ob, o[i].n);
317 buf[i] = ob;
318 args[o[i].slot] = (uint64_t)(uintptr_t)ob;
319 ob += (o[i].n + 15u) / 16u * 16u;
320 }
321 uint64_t v = 0;
322 uint32_t s = ombr_enter(code, args, &ombr_rt_table, &v, 0);
323 if (s == OMEGA_OK) {
324 for (unsigned i = 0; i < no; i++)
325 ombr2_copy_bytes(o[i].dst, buf[i], o[i].n);
326 *result = has_value ? v : 0u;
327 }
328 return s;
329}
330__asm__(OMBR_CODE_SECTION ".balign 4\n" OMBR_LOCAL(ombr2_code_pathcopy) OMBR_HIDDEN(ombr2_code_pathcopy) OMBR_SYM(ombr2_code_pathcopy) ":\n.quad 0x3fe99000000983e9,0x55eb89499000000b,0x0100ec8148e58948,0xfffff8838b490000,0xfffffff8858948ff,0x48fffffff8858b48,0x00000000000061b9,0x48c0930fc8394800,0xfff0858948c0b60f,0xfffff8858b48ffff,0x000000007ab948ff,0x960fc83948000000,0x858948c0b60f48c0,0xf0858b48ffffffe8,0xffe88d8b48ffffff,0x858948c82148ffff,0xf8858b48ffffffe0,0x000041b948ffffff,0xc839480000000000,0x48c0b60f48c0930f,0x8b48ffffffd88589,0x5ab948fffffff885,0x4800000000000000,0xb60f48c0960fc839,0xffffffd0858948c0,0x48ffffffd8858b48,0x2148ffffffd08d8b,0xffffffc8858948c8,0x48ffffffe0858b48,0x0948ffffffc88d8b,0xffffffb8858948c8,0x48ffffffb8858b48,0x00000000000000b9,0x0017840fc8394800,0xfffff8858b480000,0xfffffff8858948ff,0xc9fffffff8858b48,0xfffffff8858b48c3,0x000000000030b948,0xc0930fc839480000,0xf0858948c0b60f48,0xfff8858b48ffffff,0x00000039b948ffff,0x0fc8394800000000,0x8948c0b60f48c096,0x858b48ffffffe885,0xe88d8b48fffffff0,0x8948c82148ffffff,0x858b48ffffffe085,0x0000b948ffffffe0,0x3948000000000000,0x4800000017840fc8,0x8948fffffff8858b,0x858b48fffffff885,0x8b48c3c9fffffff8,0x2eb948fffffff885,0x4800000000000000,0xb60f48c0940fc839,0xfffffff0858948c0,0x48fffffff8858b48,0x0000000000005fb9,0x48c0940fc8394800,0xffe8858948c0b60f,0xfffff0858b48ffff,0xffffffe88d8b48ff,0xffe0858948c80948,0xfffff8858b48ffff,0x000000002db948ff,0x940fc83948000000,0x858948c0b60f48c0,0xe0858b48ffffffd8,0xffd88d8b48ffffff,0x858948c80948ffff,0xf8858b48ffffffd0,0x00002fb948ffffff,0xc839480000000000,0x48c0b60f48c0940f,0x8b48ffffffc88589,0x8d8b48ffffffd085,0x48c80948ffffffc8,0x8b48ffffffb88589,0x00b948ffffffb885,0x4800000000000000,0x00000017840fc839,0x48fffffff8858b48,0x8b48fffffff88589,0x48c3c9fffffff885,0xb948fffffff8858b,0x000000000000002b,0x0f48c0940fc83948,0xfffff0858948c0b6,0xfffffff8858b48ff,0x00000000002cb948,0xc0940fc839480000,0xe8858948c0b60f48,0xfff0858b48ffffff,0xffffe88d8b48ffff,0xe0858948c80948ff,0xfff8858b48ffffff,0x0000003db948ffff,0x0fc8394800000000,0x8948c0b60f48c094,0x858b48ffffffd885,0xd88d8b48ffffffe0,0x8948c80948ffffff,0x858b48ffffffd085,0x0040b948fffffff8,0x3948000000000000,0xc0b60f48c0940fc8,0x48ffffffc8858948,0x8b48ffffffd0858b,0xc80948ffffffc88d,0x48ffffffb8858948,0xb948ffffffb8858b,0x0000000000000000,0x000017840fc83948,0xfffffff8858b4800,0x48fffffff8858948,0xc3c9fffffff8858b,0x48fffffff8858b48,0x0000000000003ab9,0x48c0940fc8394800,0xfff0858948c0b60f,0xfffff8858b48ffff,0x000000007eb948ff,0x940fc83948000000,0x858948c0b60f48c0,0xf0858b48ffffffe8,0xffe88d8b48ffffff,0x858948c80948ffff,0xe0858b48ffffffe0,0x000000b948ffffff,0xc839480000000000,0x8b4800000017840f,0x858948fffffff885,0xf8858b48fffffff8,0x00b848c3c9ffffff,0x4800000000000001,0x8b48fffffff88589,0x49c3c9fffffff885,0x8148e5894855eb89,0x838b4900000100ec,0xf8858948fffffff8,0xfff0838b49ffffff,0xfffff0858948ffff,0xffffffe8838b49ff,0x49ffffffe8858948,0x8948ffffffe0838b,0x858b48ffffffe085,0x0000b948fffffff0,0x3948000000000000,0x48000000aa850fc8,0xb948ffffffe8858b,0x0000000000000000,0x0f48c0940fc83948,0xffffd8858948c0b6,0xfffffff8858b48ff,0x000000000002b948,0xc0940fc839480000,0xd0858948c0b60f48,0xffd8858b48ffffff,0xffffd08d8b48ffff,0xc8858948c80948ff,0xffc8858b48ffffff,0x00000000b948ffff,0x0fc8394800000000,0x04b8480000001a84,0x4800000000000000,0x8b48fffffff88589,0x48c3c9fffffff885,0x00000000000005b8,0xfffffff885894800,0xc9fffffff8858b48,0xffffffe8858b48c3,0x48ffffffe08d8b48,0x0000001a820fc839,0x000000000004b848,0xfffff88589480000,0xfffffff8858b48ff,0xffffe0858b48c3c9,0x0000000001b948ff,0x8948c82948000000,0x858b48ffffffd885,0xd8858948ffffffd8,0xffe8858b48ffffff,0xffffd88d8b48ffff,0x001a820fc83948ff,0x00000004b8480000,0xf885894800000000,0xfff8858b48ffffff,0x24848d48c3c9ffff,0x0ff8394cffffff00,0xec81480000037182,0xf8858b4800000100,0x0024848948ffffff,0xfff0858b48000000,0x000824848948ffff,0xffffe8858b480000,0x00001024848948ff,0xffffffe0858b4800,0x0000001824848948,0x48ffffffd8858b48,0x4800000020248489,0x8948ffffffd0858b,0x8b48000000282484,0x848948ffffffc885,0x858b480000003024,0x24848948ffffffc0,0xb8858b4800000038,0x4024848948ffffff,0xffb0858b48000000,0x004824848948ffff,0xffffa8858b480000,0x00005024848948ff,0xffffffa0858b4800,0x0000005824848948,0x48ffffff98858b48,0x4800000060248489,0x8948ffffff90858b,0x8b48000000682484,0x848948ffffff8885,0x858b480000007024,0x24848948ffffff80,0x78858b4800000078,0x8024848948ffffff,0xff70858b48000000,0x008824848948ffff,0xfef024848d480000,0x54820ff8394cffff,0x0824848b48000002,0xfff8858948000000,0x48fffff8cde8ffff,0x8b48ffffffd88589,0x8948000000002484,0x848b48fffffff885,0x8589480000000824,0x24848b48fffffff0,0xe885894800000010,0x1824848b48ffffff,0xffe0858948000000,0x002824848b48ffff,0xffffd08589480000,0x00003024848b48ff,0xffffffc885894800,0x0000003824848b48,0x48ffffffc0858948,0x480000004024848b,0x8b48ffffffb88589,0x8948000000482484,0x848b48ffffffb085,0x8589480000005024,0x24848b48ffffffa8,0xa085894800000058,0x6024848b48ffffff,0xff98858948000000,0x006824848b48ffff,0xffff908589480000,0x00007024848b48ff,0xffffff8885894800,0x0000007824848b48,0x48ffffff80858948,0x480000008024848b,0x8b48ffffff788589,0x8948000000882484,0xc48148ffffff7085,0xd8858b4800000100,0x000100b948ffffff,0xc839480000000000,0xb8480000001a850f,0x0000000000000004,0x48fffffff8858948,0xc3c9fffffff8858b,0x48fffffff0858b48,0x0000000000002fb9,0x004e850fc8394800,0xfffff8858b480000,0x0000000002b948ff,0x850fc83948000000,0x0004b8480000001a,0x8948000000000000,0x858b48fffffff885,0xb848c3c9fffffff8,0x0000000000000000,0x48fffffff8858948,0xc3c9fffffff8858b,0x48fffffff0858b48,0x0000000000002eb9,0x005a850fc8394800,0xfffff8858b480000,0x0000000002b948ff,0x830fc83948000000,0xf8858b4800000040,0x000001b948ffffff,0xc801480000000000,0x48fffffff8858948,0x8948fffffff8858b,0x858b48fffffff885,0xf8858948fffffff8,0xfff8858b48ffffff,0x0003b848c3c9ffff,0x8948000000000000,0x858b48fffffff885,0x06bec3c9fffffff8,0xbe1066ff41000000,0x1066ff4100000006,0x48e5894855eb8949,0x8b4900000100ec81,0x858948fffffff883,0xf0838b49fffffff8,0xfff0858948ffffff,0xfffff0858b48ffff,0xffffffe8858948ff,0x000000000000b848,0xffffe08589480000,0x0000000000b848ff,0xffd8858948000000,0xffffe0858b48ffff,0xffffffe88d8b48ff,0x0000ff830fc83948,0xffffffd8858b4800,0x0000000f4240b948,0x13830fc839480000,0xffd8858b48000001,0x00000001b948ffff,0x48c8014800000000,0x8b48ffffffd88589,0x858948ffffffd885,0xe0858b48ffffffd8,0xfff08d8b48ffffff,0xdc830fc83948ffff,0xfff8958b48000000,0xffffe08d8b48ffff,0xca014800e1c148ff,0xd085894802b60f48,0xffd0858b48ffffff,0xffffd0858948ffff,0xffffffd0858b48ff,0x000000000000b948,0x2e850fc839480000,0xffe0858b48000000,0xfffff08d8b48ffff,0x0086870fc83948ff,0xffffe0858b480000,0xfffffff8858948ff,0xc9fffffff8858b48,0xffffffe0858b48c3,0x000000000001b948,0x858948c801480000,0xe0858b48ffffffe0,0xffe0858948ffffff,0x90fffffeebe9ffff,0x48ffffffe8858b48,0x3948fffffff08d8b,0x4800000032870fc8,0x8948ffffffe8858b,0x858b48fffffff885,0x04bec3c9fffffff8,0xbe1066ff41000000,0x1066ff4100000003,0x66ff410000000abe,0xff410000000abe10,0x894855eb89491066,0x00000100ec8148e5,0x48fffffff8838b49,0x8b49fffffff88589,0x858948fffffff083,0xe8838b49fffffff0,0xffe8858948ffffff,0xffffe0838b49ffff,0xffffffe0858948ff,0x48fffffff0858b48,0x8b48ffffffd88589,0x858948ffffffe085,0xd8858b48ffffffd0,0x000000b948ffffff,0xc839480000000000,0xb84800000042850f,0x0000000000000000,0x48ffffffc8858948,0xb948ffffffc8858b,0x0000000000000001,0x0004e8870fc83948,0xffffffc8858b4800,0x48fffffff8858948,0xc3c9fffffff8858b,0x000000000000b848,0xffffc88589480000,0x0000000000b848ff,0xffb8858948000000,0x00000000b848ffff,0xb085894800000000,0xffb8858b48ffffff,0xffffd88d8b48ffff,0x0445830fc83948ff,0xffffb0858b480000,0x00000f4240b948ff,0x830fc83948000000,0xb0858b4800000476,0x000001b948ffffff,0xc801480000000000,0x48ffffffb0858948,0x8948ffffffb0858b,0x858b48ffffffb085,0xf08d8b48ffffffb8,0x830fc83948ffffff,0xf8958b480000043f,0xffb88d8b48ffffff,0x014800e1c148ffff,0x85894802b60f48ca,0xa8858b48ffffffa8,0xffa8858948ffffff,0xff0024848d48ffff,0x09820ff8394cffff,0x0100ec8148000004,0xfffff8858b480000,0x00000024848948ff,0xfffffff0858b4800,0x0000000824848948,0x48ffffffe8858b48,0x4800000010248489,0x8948ffffffe0858b,0x8b48000000182484,0x848948ffffffd885,0x858b480000002024,0x24848948ffffffd0,0xc8858b4800000028,0x3024848948ffffff,0xffc0858b48000000,0x003824848948ffff,0xffffb8858b480000,0x00004024848948ff,0xffffffb0858b4800,0x0000004824848948,0x48ffffffa8858b48,0x4800000050248489,0x8948ffffffa0858b,0x8b48000000582484,0x848948ffffff9885,0x858b480000006024,0x24848948ffffff90,0x88858b4800000068,0x7024848948ffffff,0xff80858b48000000,0x007824848948ffff,0xffff78858b480000,0x00008024848948ff,0xffffff70858b4800,0x0000008824848948,0xfffffef024848d48,0x0002ec820ff8394c,0x00003024848b4800,0xfffffff885894800,0x0000005024848b48,0x48fffffff0858948,0x480000004024848b,0x8b48ffffffe88589,0x8948000000282484,0xf60de8ffffffe085,0xffffa0858948ffff,0x00000024848b48ff,0xfffffff885894800,0x0000000824848b48,0x48fffffff0858948,0x480000001024848b,0x8b48ffffffe88589,0x8948000000182484,0x848b48ffffffe085,0x8589480000002024,0x24848b48ffffffd8,0xd085894800000028,0x3024848b48ffffff,0xffc8858948000000,0x003824848b48ffff,0xffffc08589480000,0x00004024848b48ff,0xffffffb885894800,0x0000004824848b48,0x48ffffffb0858948,0x480000005024848b,0x8b48ffffffa88589,0x8948000000602484,0x848b48ffffff9885,0x8589480000006824,0x24848b48ffffff90,0x8885894800000070,0x7824848b48ffffff,0xff80858948000000,0x008024848b48ffff,0xffff788589480000,0x00008824848b48ff,0xffffff7085894800,0x4800000100c48148,0x8948ffffffa0858b,0x858b48ffffffa085,0x0004b948ffffffa0,0x3948000000000000,0x4800000042850fc8,0x00000000000000b8,0xffffff9885894800,0x48ffffff98858b48,0x00000000000001b9,0x0154870fc8394800,0xffff98858b480000,0xfffffff8858948ff,0xc9fffffff8858b48,0xffffffb8858b48c3,0x48ffffffe08d8b48,0x0000012f830fc839,0x48ffffffe8958b48,0xc148ffffffb88d8b,0x858b48ca014800e1,0x8b480288ffffffa8,0x05b948ffffffa085,0x4800000000000000,0x00000042850fc839,0x000000000001b848,0xffff988589480000,0xffffff98858b48ff,0x000000000001b948,0xd5870fc839480000,0xff98858b48000000,0xfffff8858948ffff,0xfffffff8858b48ff,0xffffa0858b48c3c9,0xffffffc8858948ff,0x48ffffffb8858b48,0x00000000000001b9,0xb8858948c8014800,0xffb8858b48ffffff,0xffffb8858948ffff,0x4890fffffba5e9ff,0x00000000000000b8,0xffffffb885894800,0x48ffffffb8858b48,0x00000000000001b9,0x005f870fc8394800,0xffffb8858b480000,0xfffffff8858948ff,0xc9fffffff8858b48,0xff410000000abec3,0x4100000004be1066,0x00000003be1066ff,0x000006be1066ff41,0x0006be1066ff4100,0x0abe1066ff410000,0xbe1066ff41000000,0x1066ff4100000003,0x66ff410000000abe,0xff410000000abe10\n.byte 0x66,0x10\n" OMBR_PREVIOUS);
331static const char ombr2_ident_pathcopy[] = "omega-ident 1 unit=pathcopy abi=2 profile=OM-2 src=5e636828a24e58b93b5985c75636f5c5da3907f3a49c28cc0862d98c5c7c43a0 omc=be8c51301307555254fc59e351d281aae1aa096d91521777e33a41c8b446448a";
332__attribute__((visibility("default"))) const char *omega2_ident_pathcopy(void)
333{
334 return ombr2_ident_pathcopy;
335}
336__asm__(OMBR_CODE_SECTION ".balign 4\n" OMBR_LOCAL(ombr2_entry_pathlen) OMBR_HIDDEN(ombr2_entry_pathlen) OMBR_SYM(ombr2_entry_pathlen) ":\nendbr64\njmp " OMBR_SYM(ombr2_code_pathcopy) "+0\n" OMBR_PREVIOUS);
337extern const unsigned char ombr2_entry_pathlen[] __attribute__((visibility("hidden")));
338/* export fn pathlen a view uchar * to ulong */
339__attribute__((visibility("default"))) uint32_t omega2_pathlen(uint64_t *result, const uint8_t *o_a, uint64_t o_a_len)
340{
341 ombr_span sp[7] = {{0}};
342 unsigned ns = 0;
343 uint64_t a[6] = {0};
344 ombr2_out ou[6] = {{0, 0, 0}};
345 unsigned no = 0;
346 if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1))
347 return OMEGA_BAD_ARG;
348 if (ombr2_view(sp, &ns, o_a, o_a_len, 1u, 0))
349 return OMEGA_BAD_ARG;
350 a[0] = (uint64_t)(uintptr_t)o_a;
351 a[1] = o_a_len;
352 if (ombr2_overlap(sp, ns))
353 return OMEGA_BAD_ARG;
354 return ombr2_run(ombr2_entry_pathlen, a, result, 1, ou, no, 0);
355}
356__asm__(OMBR_CODE_SECTION ".balign 4\n" OMBR_LOCAL(ombr2_entry_pathcopy) OMBR_HIDDEN(ombr2_entry_pathcopy) OMBR_SYM(ombr2_entry_pathcopy) ":\nendbr64\njmp " OMBR_SYM(ombr2_code_pathcopy) "+6\n" OMBR_PREVIOUS);
357extern const unsigned char ombr2_entry_pathcopy[] __attribute__((visibility("hidden")));
358/* export fn pathcopy src view uchar * dst edit uchar * to ulong */
359__attribute__((visibility("default"))) uint32_t omega2_pathcopy(uint64_t *result, const uint8_t *o_src, uint64_t o_src_len, uint8_t *o_dst, uint64_t o_dst_len)
360{
361 ombr_span sp[7] = {{0}};
362 unsigned ns = 0;
363 uint64_t a[6] = {0};
364 ombr2_out ou[6] = {{0, 0, 0}};
365 unsigned no = 0;
366 if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1))
367 return OMEGA_BAD_ARG;
368 if (ombr2_view(sp, &ns, o_src, o_src_len, 1u, 0))
369 return OMEGA_BAD_ARG;
370 a[0] = (uint64_t)(uintptr_t)o_src;
371 a[1] = o_src_len;
372 if (ombr2_view(sp, &ns, o_dst, o_dst_len, 1u, 1))
373 return OMEGA_BAD_ARG;
374 a[2] = (uint64_t)(uintptr_t)o_dst;
375 a[3] = o_dst_len;
376 if (ombr2_overlap(sp, ns))
377 return OMEGA_BAD_ARG;
378 return ombr2_run(ombr2_entry_pathcopy, a, result, 1, ou, no, 0);
379}
380#else
381#error pathcopy freestanding binding is aarch64 or x86-64 only
382#endif