Skip to content

Commit 8867b42

Browse files
committed
Add random module
1 parent 750e2c1 commit 8867b42

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

exec/cnex/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ add_executable(cnex
1212
number.c
1313
stack.c
1414
util.c
15+
lib/random.c
1516
)
1617
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
1718
set_target_properties(cnex PROPERTIES COMPILE_FLAGS "-std=c99 -Wall -Werror")

exec/cnex/SConstruct

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ else:
2222
"-g",
2323
])
2424

25+
envcnex.Append(CPPPATH=[Dir(".")])
26+
27+
rtl_c = ([
28+
"lib/random.c",
29+
])
30+
2531
cnex = envcnex.Program("cnex", [
2632
"array.c",
2733
"bytecode.c",
@@ -34,6 +40,7 @@ cnex = envcnex.Program("cnex", [
3440
"number.c",
3541
"stack.c",
3642
"util.c",
43+
rtl_c,
3744
],
3845
)
3946

exec/cnex/global.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "global.h"
22

3+
#include "lib/random.h"
4+
35
#include <assert.h>
46
#include <stdarg.h>
57
#include <stdint.h>
@@ -17,7 +19,6 @@
1719
#include "util.h"
1820

1921

20-
2122
#define PDFUNC(name, func) { name, (void (*)(TExecutor *))(func) }
2223

2324
TDispatch gfuncDispatch[] = {
@@ -36,6 +37,8 @@ TDispatch gfuncDispatch[] = {
3637

3738
PDFUNC("io$fprint", io_fprint),
3839

40+
PDFUNC("random$uint32", random_uint32),
41+
3942
PDFUNC("sys$exit", sys_exit),
4043

4144
PDFUNC("array__append", array__append),

0 commit comments

Comments
 (0)