From cf07510211bc5d2e00f192e6399a84520ec1de68 Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Sun, 7 Jul 2024 14:26:57 +0200 Subject: [PATCH] bindings/go/blst.tgo: add SrcRoot() helper. --- bindings/go/blst.go | 7 +++++++ bindings/go/blst.tgo | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/bindings/go/blst.go b/bindings/go/blst.go index b0713780..88d6b5a9 100644 --- a/bindings/go/blst.go +++ b/bindings/go/blst.go @@ -16,6 +16,7 @@ package blst // #cgo loong64 mips64 mips64le ppc64 ppc64le riscv64 s390x CFLAGS: -D__BLST_NO_ASM__ // // #include "blst.h" +// const char *go_blst_src_server_c(); // // #if defined(__x86_64__) && (defined(__unix__) || defined(__APPLE__)) // # include @@ -156,6 +157,7 @@ import "C" import ( "fmt" "math/bits" + "path/filepath" "runtime" "sync" "sync/atomic" @@ -217,6 +219,11 @@ var cgo_p1Generator = *C.blst_p1_generator() var cgo_p2Generator = *C.blst_p2_generator() var cgo_fp12One = *C.blst_fp12_one() +func SrcRoot() string { + path := C.GoString(C.go_blst_src_server_c()) + return filepath.Dir(filepath.Dir(path)) +} + // Secret key func (sk *SecretKey) Zeroize() { var zero SecretKey diff --git a/bindings/go/blst.tgo b/bindings/go/blst.tgo index 32887e06..8a04c9d5 100644 --- a/bindings/go/blst.tgo +++ b/bindings/go/blst.tgo @@ -12,6 +12,7 @@ package blst // #cgo loong64 mips64 mips64le ppc64 ppc64le riscv64 s390x CFLAGS: -D__BLST_NO_ASM__ // // #include "blst.h" +// const char *go_blst_src_server_c(); // // #if defined(__x86_64__) && (defined(__unix__) || defined(__APPLE__)) // # include @@ -207,6 +208,11 @@ var cgo_p1Generator = *C.blst_p1_generator() var cgo_p2Generator = *C.blst_p2_generator() var cgo_fp12One = *C.blst_fp12_one() +func SrcRoot() string { + path := C.GoString(C.go_blst_src_server_c()) + return filepath.Dir(filepath.Dir(path)) +} + // // Secret key //