Commit e4e8f4ed

e4e8f4ed9d7cMerged

Richard Ramsden <[email protected]> · 6 months ago · 2 files · +2 added

Description

examples(ffi/libm): libc + libm smoke demo

The smallest possible FFI example — calls cos / sqrt / pow / strlen / getpid through the always-linked libc and libm. README documents the build line for fresh users.

Details

Commit
e4e8f4ed9d7c
Parent
9f22f06bc9b9

examples/ffi/libm/README.mdaddedView file

1+# libc / libm FFI demo
2+
3+Calls a handful of libc and libm functions directly. libc and libm are
4+linked into every Spinel binary by default, so no `ffi_lib` declaration
5+is needed for these.
6+
7+## Build & run
8+
9+From the repo root:
10+
11+```sh
12+./spinel examples/ffi/libm/libm.rb
13+./libm
14+```
15+
16+Expected output:
17+
18+```
19+1
20+4
21+1024
22+12
23+pid > 0: true
24+```