| 1 |
#!/usr/bin/gawk -f |
| 2 |
# Generate constants from eBPF for Windows headers. |
| 3 |
# |
| 4 |
# This script expects include/ebpf_structs.h as input. |
| 5 |
|
| 6 |
BEGIN { |
| 7 |
print "// Code generated by internal/cmd/genwinfunctions.awk; DO NOT EDIT." |
| 8 |
print "" |
| 9 |
print "package asm" |
| 10 |
print "" |
| 11 |
print "// Code in this file is derived from eBPF for Windows, available under the MIT License." |
| 12 |
print "" |
| 13 |
print "import \"github.com/cilium/ebpf/internal/platform\"" |
| 14 |
print "" |
| 15 |
print "// Built-in functions (Windows)." |
| 16 |
print "const (" |
| 17 |
} |
| 18 |
|
| 19 |
/BPF_FUNC_[[:alnum:]_]+ *= *[0-9]+,/ { |
| 20 |
name = gensub(/.*BPF_FUNC_([[:alnum:]_]+) *=.*/, "\\1", 1) |
| 21 |
id = gensub(/.*BPF_FUNC_[[:alnum:]_]+ *= *([0-9]+),.*/, "\\1", 1) |
| 22 |
|
| 23 |
split(tolower(name), parts, "_") |
| 24 |
result = "WindowsFn" |
| 25 |
for (i in parts) { |
| 26 |
part = parts[i] |
| 27 |
result = result substr(toupper(substr(part,1,1)), 1, 1) substr(part, 2) |
| 28 |
} |
| 29 |
|
| 30 |
print "\t" result " = BuiltinFunc(platform.WindowsTag | " id ")" |
| 31 |
} |
| 32 |
|
| 33 |
END { |
| 34 |
print ")" |
| 35 |
print "" |
| 36 |
} |