Skip to content

Commit e947d82

Browse files
Kenta Tadapcmoore
authored andcommitted
golang: add defines for RISCV64 goloang bindings
Signed-off-by: Kenta Tada <[email protected]> Acked-by: Tom Hromatka <[email protected]> Signed-off-by: Paul Moore <[email protected]>
1 parent ef01546 commit e947d82

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

seccomp.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ const (
185185
ArchPARISC ScmpArch = iota
186186
// ArchPARISC64 represents 64-bit PA-RISC
187187
ArchPARISC64 ScmpArch = iota
188+
// ArchRISCV64 represents RISCV64
189+
ArchRISCV64 ScmpArch = iota
188190
)
189191

190192
const (
@@ -313,6 +315,8 @@ func GetArchFromString(arch string) (ScmpArch, error) {
313315
return ArchPARISC, nil
314316
case "parisc64":
315317
return ArchPARISC64, nil
318+
case "riscv64":
319+
return ArchRISCV64, nil
316320
default:
317321
return ArchInvalid, fmt.Errorf("cannot convert unrecognized string %q", arch)
318322
}
@@ -357,6 +361,8 @@ func (a ScmpArch) String() string {
357361
return "parisc"
358362
case ArchPARISC64:
359363
return "parisc64"
364+
case ArchRISCV64:
365+
return "riscv64"
360366
case ArchNative:
361367
return "native"
362368
case ArchInvalid:

seccomp_internal.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ const uint32_t C_ARCH_BAD = ARCH_BAD;
6565
#define SCMP_ARCH_PARISC64 ARCH_BAD
6666
#endif
6767
68+
#ifndef SCMP_ARCH_RISCV64
69+
#define SCMP_ARCH_RISCV64 ARCH_BAD
70+
#endif
71+
6872
const uint32_t C_ARCH_NATIVE = SCMP_ARCH_NATIVE;
6973
const uint32_t C_ARCH_X86 = SCMP_ARCH_X86;
7074
const uint32_t C_ARCH_X86_64 = SCMP_ARCH_X86_64;
@@ -84,6 +88,7 @@ const uint32_t C_ARCH_S390 = SCMP_ARCH_S390;
8488
const uint32_t C_ARCH_S390X = SCMP_ARCH_S390X;
8589
const uint32_t C_ARCH_PARISC = SCMP_ARCH_PARISC;
8690
const uint32_t C_ARCH_PARISC64 = SCMP_ARCH_PARISC64;
91+
const uint32_t C_ARCH_RISCV64 = SCMP_ARCH_RISCV64;
8792
8893
#ifndef SCMP_ACT_LOG
8994
#define SCMP_ACT_LOG 0x7ffc0000U
@@ -282,7 +287,7 @@ const (
282287
scmpError C.int = -1
283288
// Comparison boundaries to check for architecture validity
284289
archStart ScmpArch = ArchNative
285-
archEnd ScmpArch = ArchPARISC64
290+
archEnd ScmpArch = ArchRISCV64
286291
// Comparison boundaries to check for action validity
287292
actionStart ScmpAction = ActKill
288293
actionEnd ScmpAction = ActKillProcess
@@ -538,6 +543,8 @@ func archFromNative(a C.uint32_t) (ScmpArch, error) {
538543
return ArchPARISC, nil
539544
case C.C_ARCH_PARISC64:
540545
return ArchPARISC64, nil
546+
case C.C_ARCH_RISCV64:
547+
return ArchRISCV64, nil
541548
default:
542549
return 0x0, fmt.Errorf("unrecognized architecture %#x", uint32(a))
543550
}
@@ -582,6 +589,8 @@ func (a ScmpArch) toNative() C.uint32_t {
582589
return C.C_ARCH_PARISC
583590
case ArchPARISC64:
584591
return C.C_ARCH_PARISC64
592+
case ArchRISCV64:
593+
return C.C_ARCH_RISCV64
585594
case ArchNative:
586595
return C.C_ARCH_NATIVE
587596
default:

0 commit comments

Comments
 (0)