Skip to content

Commit 056c1e2

Browse files
committed
k+
1 parent be4a031 commit 056c1e2

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

k+/l.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
void reg(int64_t id, int64_t name, int32_t arity){
2+
int64_t l=ti(14,(uint32_t)l2(id, Ku(name)));
3+
SetI32((int32_t)l-12,arity);
4+
dx(Asn(sc(Ku(name)),l));
5+
}
6+
void libs(void){ //encode strings with: https://play.golang.org/p/4ethx6OEVCR
7+
reg(0,846033518ull,1); //nrm2
8+
//reg(1,...);
9+
//reg(2,...);
10+
}
11+
int64_t cnative(int64_t x, int64_t y){
12+
switch(x){ //switch registered function id
13+
case 0: printf("todo call blas nrm2\n"); return y; break;
14+
default: return y;
15+
}}
16+

k+/l.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#define NATIVE 1
2+
void libs(void);
3+
int64_t cnative(int64_t,int64_t);

k+/readme

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# extend k.c with some c-libraries using the native function type
2+
# blas lapack fftw lp_solve ..
3+
4+
set -e
5+
set -x
6+
CC=cc
7+
if [ "$1" = "get" ];then
8+
wget -Okc.orig https://github.com/ktye/i/releases/download/latest/k.c
9+
fi
10+
11+
sed -e 's/math.h>$/math.h>\n#include"l.h"/' -e 's/kinit()/kinit();libs()/' kc.orig>k.c
12+
cat l.c >>k.c
13+
14+
$CC -O3 -march=native -ok+ k.c -lm

0 commit comments

Comments
 (0)