cosmopolitan/examples
Justine Tunney 5e8c928f1a
Introduce dlopen() support
Every program built using Cosmopolitan is statically-linked. However
there are some cases, e.g. GUIs and video drivers, where linking the
host platform libraries is desirable. So what we do in such cases is
launch a stub executable using the host platform's libc, and longjmp
back into this executable. The stub executable passes back to us the
platform-specific dlopen() implementation, which we shall then wrap.

Here's the list of platforms that are supported so far:

- x86-64 Linux w/ Glibc
- x86-64 Linux w/ Musl Libc
- x86-64 FreeBSD
- x86-64 Windows
- aarch64 Linux w/ Glibc
- aarch64 MacOS

What this means is your Cosmo programs can call foreign functions on
your host operating system. However, it's important to note that any
foreign library you link won't have the ability to call functions in
your Cosmopolitan program. For example it's now technically possible
that Lua can load a module, however that almost certainly won't work
since the Lua module won't have access to Cosmo's Lua API.

Kudos to @jacereda for figuring out how to do this.
2023-11-03 06:37:18 -07:00
..
package Clean up more code 2023-06-18 01:00:05 -07:00
pyapp Fix V=0 make mode 2022-06-21 01:32:31 -07:00
pylife Cherry-pick bug fixes and Landlock Make 1.0.2 2022-08-10 12:56:45 -07:00
clear.c Overhaul process spawning 2023-09-10 08:17:44 -07:00
crashreport.c Make improvements 2023-09-18 21:04:47 -07:00
ctrlc.c Fix some additional Windows TTY issues 2023-10-04 02:17:25 -07:00
date.c Make improvements to cosmocc toolchain 2023-06-10 15:50:01 -07:00
dlopen.c Introduce dlopen() support 2023-11-03 06:37:18 -07:00
examples.mk Introduce dlopen() support 2023-11-03 06:37:18 -07:00
greenbean.c Release Cosmopolitan v3.0 2023-10-15 23:53:36 -07:00
gui.c Make examples folder somewhat more focused 2021-03-05 06:09:12 -08:00
hangman.c Fix warnings 2023-09-01 20:50:18 -07:00
hello.c Remove printf() linking hack 2023-06-17 10:13:50 -07:00
hello2.c Introduce new linker for fat ape binaries 2023-08-11 04:39:19 -07:00
hellolua.c Fix warnings 2023-09-01 20:50:18 -07:00
hellolua.lua Add Hello World example for LUA C API (#97) 2021-03-08 14:15:59 -08:00
hiredis.c Add a new example showing how to use hiredis. 2023-01-01 16:30:10 -08:00
kilo.c Fix warnings 2023-09-01 20:50:18 -07:00
life.c Always initialize thread local storage 2022-07-19 00:21:46 -07:00
linenoise.c Clean up some code 2023-10-11 11:45:31 -07:00
ls.c Replace COSMO define with _COSMO_SOURCE 2023-08-13 20:55:04 -07:00
nc.c Fix warnings 2023-09-01 20:50:18 -07:00
nesemu1.cc Make improvements 2023-10-08 08:59:53 -07:00
pause.c Write more tests and improve kill() on Windows 2023-10-13 04:38:45 -07:00
picol.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
portscan.c Disable linker map generation and improve tinyness 2023-06-09 03:29:26 -07:00
print-struct.c Cull the examples folder 2023-10-11 21:45:32 -07:00
printargs.c Make improvements 2022-04-24 10:06:05 -07:00
rusage.c Simplify the rusage.com command 2023-09-07 05:41:18 -07:00
script.c Fix warnings 2023-09-01 20:50:18 -07:00
script.txt Add script.com and whois.com courtesy of FreeBSD 2022-09-13 20:26:13 -07:00
seq.c Cull the examples folder 2023-10-11 21:45:32 -07:00
setcontext.c Implement swapcontext() and makecontext() 2023-07-02 09:01:44 -07:00
setitimer.c Cull the examples folder 2023-10-11 21:45:32 -07:00
spawn_bench.c Make improvements 2023-09-18 21:04:47 -07:00
stackexplorer.c Mint APE Loader v1.7 2023-08-17 09:04:50 -07:00
stackoverflow.c Improve stack overflow recovery 2023-10-04 07:35:17 -07:00
stat.c Mint APE Loader v1.7 2023-08-17 09:04:50 -07:00
statfs.c Mint APE Loader v1.7 2023-08-17 09:04:50 -07:00
stringbuffer.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
sysconf.c Clean up some code 2023-10-11 11:45:31 -07:00
sysinfo.c Clean up some code 2023-10-11 11:45:31 -07:00
system.c Mint APE Loader v1.5 2023-07-26 13:54:49 -07:00
ttyinfo.c Make improvements 2023-10-08 08:59:53 -07:00
ucontext-sigfpe-recovery.c Cull the examples folder 2023-10-11 21:45:32 -07:00
uname.c Improve quality of uname/gethostname/getdomainname 2022-09-03 20:20:40 -07:00
unbourne.c Simplify the rusage.com command 2023-09-07 05:41:18 -07:00
vga.c Mint APE Loader v1.5 2023-07-26 13:54:49 -07:00
vga2.c [metal] Add a uprintf() routine, for non-emergency boot logging (#905) 2023-10-25 14:32:20 -07:00
walk.c Make fixes and improvements 2023-07-09 05:21:11 -07:00
wall.c Fix warnings 2023-09-01 20:50:18 -07:00
whois.c Perform inconsequential code cleanup 2023-08-07 20:24:50 -07:00