github.com/LaevusDexter/asmcgocall@v0.0.0-20200220061330-f484a47e9b97/examples/sum.go (about) 1 package main 2 3 /* 4 int sum(struct { 5 int p0; 6 int p1; 7 int p2; 8 int p3; 9 int p4; 10 int r; 11 } *a) { 12 13 //printf("p1 = %d, p2 = %d, p3 = %d, p4 = %d, p5 = %d, r = %d\n", a->p0, a->p1, a->p2, a->p3, a->p4, a->r); 14 15 a->r = a->p0 + a->p1 + a->p2 + a->p3 + a->p4; 16 17 // error code 18 return 0; 19 } 20 21 int regular_sum(int p0, int p1, int p2, int p3, int p4) { 22 return p0 + p1 + p2 + p3 + p4; 23 } 24 25 26 */ 27 import "C" 28 29 import ( 30 "github.com/LaevusDexter/asmcgocall" 31 ) 32 33 var sumAsmcgocall = func() (result func(C.int, C.int, C.int, C.int, C.int) C.int) { 34 asmcgocall.Register(C.sum, &result) 35 36 return 37 }() 38 39 func sumCgocall(p0, p1, p2, p3, p4 C.int) C.int { 40 return C.regular_sum(p0, p1, p2, p3, p4) 41 }