mirror of
https://github.com/jart/cosmopolitan.git
synced 2026-11-07 17:22:16 -10:00
Compare commits
408
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ace523c79b | ||
|
|
c70422586a | ||
|
|
cabb0a7ede | ||
|
|
38aece42ba | ||
|
|
f66ef5d58e | ||
|
|
0c6581f912 | ||
|
|
d522a88def | ||
|
|
795d6fd6cd | ||
|
|
d3a735702b | ||
|
|
214e3a68a9 | ||
|
|
3d0347e26e | ||
|
|
bc464a8898 | ||
|
|
59e1c245d1 | ||
|
|
916f19eea1 | ||
|
|
5029e20bef | ||
|
|
968474d291 | ||
|
|
228fb7428b | ||
|
|
1e5bd4d23e | ||
|
|
fe29710e4e | ||
|
|
579b597ded | ||
|
|
e963d9c8e3 | ||
|
|
9b29358511 | ||
|
|
71273bc5c9 | ||
|
|
1aa0df696c | ||
|
|
a22f0736d8 | ||
|
|
b420ed8248 | ||
|
|
20bb8db9f8 | ||
|
|
a2e443edd7 | ||
|
|
9454788223 | ||
|
|
31a37aeb1a | ||
|
|
79ba5233db | ||
|
|
d26d7ae0e4 | ||
|
|
ee7e296339 | ||
|
|
3bfb7580c5 | ||
|
|
b703eee96e | ||
|
|
5a441ea57f | ||
|
|
10aade69e3 | ||
|
|
53b9f83e1c | ||
|
|
d86027fe90 | ||
|
|
798d542f15 | ||
|
|
295b3d6ca5 | ||
|
|
f9eae9794a | ||
|
|
98f330b764 | ||
|
|
5ef64dbcdb | ||
|
|
0c4c56ff39 | ||
|
|
75fc601ff5 | ||
|
|
28a592f2d4 | ||
|
|
d8faadf44e | ||
|
|
4daafef63a | ||
|
|
2bc0901ce3 | ||
|
|
6bbb44c165 | ||
|
|
0cdba6878b | ||
|
|
1f766a332f | ||
|
|
aeeb851422 | ||
|
|
55a15c204e | ||
|
|
b142ea7176 | ||
|
|
fd76fa0016 | ||
|
|
533f3d1ef1 | ||
|
|
df8ab0aa0c | ||
|
|
344d2dc356 | ||
|
|
f7b4804251 | ||
|
|
64d87d4e5a | ||
|
|
0b317523a0 | ||
|
|
a73e808b25 | ||
|
|
3ac6576fe5 | ||
|
|
312ccc919b | ||
|
|
ea83cc0ad0 | ||
|
|
398f0c16fb | ||
|
|
f3e28aa192 | ||
|
|
8c4cce043c | ||
|
|
98c674d915 | ||
|
|
e99a4dcc8c | ||
|
|
c002e4ba76 | ||
|
|
fe881982b5 | ||
|
|
4178896aa0 | ||
|
|
3641e99042 | ||
|
|
45d72920ba | ||
|
|
feb0f9fb3a | ||
|
|
cc9366b200 | ||
|
|
c89bc56f6a | ||
|
|
36b2710e1a | ||
|
|
e51034bab3 | ||
|
|
f8b9bd2b47 | ||
|
|
0ecd71f697 | ||
|
|
c0bec24fa2 | ||
|
|
58fb2fb3d3 | ||
|
|
8d5f60a9cd | ||
|
|
0ea2907730 | ||
|
|
cfbd2afc19 | ||
|
|
a7bd4ed9ea | ||
|
|
300876ee50 | ||
|
|
e6b22f1f65 | ||
|
|
d6873f637f | ||
|
|
74200a0ea0 | ||
|
|
87222aad35 | ||
|
|
053ee714bd | ||
|
|
8e69cf133a | ||
|
|
3fe7b95fd0 | ||
|
|
014d4bdab2 | ||
|
|
a68cc690ff | ||
|
|
5a6c0f27c3 | ||
|
|
2d79ab6c15 | ||
|
|
5144c22189 | ||
|
|
86ab24ce56 | ||
|
|
cc1920749e | ||
|
|
1beeb7a829 | ||
|
|
d0ac995dc0 | ||
|
|
19bd27358a | ||
|
|
1ba33d233c | ||
|
|
fd0eefce17 | ||
|
|
4d8f884e76 | ||
|
|
4ce5664c4b | ||
|
|
98c53ae526 | ||
|
|
1f87640d17 | ||
|
|
e4ef38403b | ||
|
|
87d7010495 | ||
|
|
29cb53881e | ||
|
|
8d7d00af3a | ||
|
|
9504ebaf7e | ||
|
|
8b08e81a07 | ||
|
|
a3ccc5af1f | ||
|
|
f271ffcf90 | ||
|
|
88806b79b1 | ||
|
|
eb08b9fbeb | ||
|
|
248c6d54bb | ||
|
|
05350eca60 | ||
|
|
f721d61b54 | ||
|
|
cd2f984ec2 | ||
|
|
b3a08d9286 | ||
|
|
067c14891f | ||
|
|
b8f38cf55d | ||
|
|
7cbc2bc083 | ||
|
|
1a3d22b2fd | ||
|
|
3057315a1b | ||
|
|
6a8c21269f | ||
|
|
b3838173ec | ||
|
|
4864565198 | ||
|
|
221817e537 | ||
|
|
690be544da | ||
|
|
919b6fec10 | ||
|
|
644f290035 | ||
|
|
4577f7fe11 | ||
|
|
1b5a5719c3 | ||
|
|
b9187061a7 | ||
|
|
e56a9d0e23 | ||
|
|
2d34819779 | ||
|
|
6215c91e90 | ||
|
|
af59806a42 | ||
|
|
01e6b3ad8d | ||
|
|
daa32d27d4 | ||
|
|
84001a246c | ||
|
|
1f2288be6e | ||
|
|
fabf7f9f02 | ||
|
|
cef08d47b6 | ||
|
|
41801c9802 | ||
|
|
1966369e8e | ||
|
|
3aa8983ec1 | ||
|
|
c029e83dd8 | ||
|
|
472b95fea3 | ||
|
|
dc6d11a031 | ||
|
|
b107d2709f | ||
|
|
4effa23528 | ||
|
|
26ac6871da | ||
|
|
bf03b2e64c | ||
|
|
69c508729e | ||
|
|
7ed524ca31 | ||
|
|
052682c2c0 | ||
|
|
8a91518633 | ||
|
|
8f52c0d773 | ||
|
|
1fbfbb3192 | ||
|
|
f40f97bd07 | ||
|
|
24d79599cc | ||
|
|
da8a08fd58 | ||
|
|
59575f7e80 | ||
|
|
6c16f208b5 | ||
|
|
bb96099c65 | ||
|
|
2584a86ab4 | ||
|
|
9e98d6893d | ||
|
|
6682013d12 | ||
|
|
83abd68029 | ||
|
|
7abca1531f | ||
|
|
7dc8973567 | ||
|
|
1753b669cf | ||
|
|
ae300d0c40 | ||
|
|
c6f75bf95a | ||
|
|
52565e7af3 | ||
|
|
3c19b6e352 | ||
|
|
a1677d605a | ||
|
|
dcbd2b8668 | ||
|
|
4d21cd315d | ||
|
|
da36e7e256 | ||
|
|
09bcfa23d5 | ||
|
|
6b90ff60cd | ||
|
|
2f41b4dcc6 | ||
|
|
5af25f687a | ||
|
|
9c81729008 | ||
|
|
8a236433a2 | ||
|
|
ab64ef7364 | ||
|
|
4177489762 | ||
|
|
4e93750afd | ||
|
|
ca88ce5026 | ||
|
|
6388ef21f8 | ||
|
|
7ffeb29bfc | ||
|
|
da4dffccc5 | ||
|
|
807706a099 | ||
|
|
83d0c3b870 | ||
|
|
6cd1037692 | ||
|
|
e0566c9675 | ||
|
|
3f35b37b68 | ||
|
|
67c27d9e6e | ||
|
|
2a3037d4e8 | ||
|
|
0a61fe4ea0 | ||
|
|
33e8fc8687 | ||
|
|
0ad609268f | ||
|
|
816b0e1851 | ||
|
|
2bd1e72d5a | ||
|
|
5ce83b08c8 | ||
|
|
5f088cec23 | ||
|
|
a8945714e8 | ||
|
|
8a6ac6dd63 | ||
|
|
f5da4efcaf | ||
|
|
b16b332539 | ||
|
|
4d3195f57a | ||
|
|
aad841610e | ||
|
|
7583b3accc | ||
|
|
06a4e2d29b | ||
|
|
67b9675c81 | ||
|
|
4d4aa9e791 | ||
|
|
813e11b90b | ||
|
|
fb7b7c6e21 | ||
|
|
d769df3482 | ||
|
|
c3ed8d6c7f | ||
|
|
937d921018 | ||
|
|
bfef17eb6d | ||
|
|
11ec99931b | ||
|
|
cfd453d125 | ||
|
|
6fa049c9c7 | ||
|
|
3364fc5b03 | ||
|
|
f064183646 | ||
|
|
e26bdbec52 | ||
|
|
5141d00992 | ||
|
|
b9f73e6a4d | ||
|
|
43b2475aaa | ||
|
|
1a08594f95 | ||
|
|
e55e71ab48 | ||
|
|
3573814e45 | ||
|
|
2134ffe005 | ||
|
|
e3ee3c78e9 | ||
|
|
8af91bcbe7 | ||
|
|
754974faaa | ||
|
|
9367253b4d | ||
|
|
32e289b1d8 | ||
|
|
d53a344e18 | ||
|
|
3e19b96ab8 | ||
|
|
1831e3ccf7 | ||
|
|
4651962070 | ||
|
|
8a6a1e25b1 | ||
|
|
7e4021bf82 | ||
|
|
2596a59374 | ||
|
|
0eaad9dd7b | ||
|
|
f4298f10c2 | ||
|
|
d932948fb4 | ||
|
|
5e069a64d4 | ||
|
|
3c24c12068 | ||
|
|
839e2f4cfb | ||
|
|
c42dbe0e9e | ||
|
|
94afa982c3 | ||
|
|
cc56038b05 | ||
|
|
f3baa05195 | ||
|
|
1c9065510f | ||
|
|
da199b7a45 | ||
|
|
98fba078a3 | ||
|
|
5d334b9ce0 | ||
|
|
35c7edac49 | ||
|
|
218ef49147 | ||
|
|
19d0c15e03 | ||
|
|
3e17c7b20f | ||
|
|
fcfe7c1080 | ||
|
|
91f4167a45 | ||
|
|
40291c9db3 | ||
|
|
cdc54ea1fd | ||
|
|
edd9297eba | ||
|
|
ac3b1dfb21 | ||
|
|
537c21338b | ||
|
|
c6c9b5dfde | ||
|
|
4a5698b5c9 | ||
|
|
6c7b8facaa | ||
|
|
7a393c06fe | ||
|
|
e345b42d78 | ||
|
|
e85aeda4ba | ||
|
|
3e1fd1d962 | ||
|
|
b740cca642 | ||
|
|
c797f139bb | ||
|
|
adebc5e4c3 | ||
|
|
5f1415af3a | ||
|
|
02b4a5c824 | ||
|
|
45b994ea23 | ||
|
|
2c15efc249 | ||
|
|
667ab245fe | ||
|
|
08d3700c15 | ||
|
|
6f35bd47ab | ||
|
|
bfa8581537 | ||
|
|
ec69413f83 | ||
|
|
e75ffde09e | ||
|
|
0e36cb3ac4 | ||
|
|
760db8c5ad | ||
|
|
2f3bd90216 | ||
|
|
9f149e1de3 | ||
|
|
d7733579d3 | ||
|
|
e06c90fafc | ||
|
|
a91ba89d85 | ||
|
|
b2cd58a322 | ||
|
|
23ae9dfceb | ||
|
|
2fdc19e7a7 | ||
|
|
74d48f7cb6 | ||
|
|
3384a5a48c | ||
|
|
888cfa74d7 | ||
|
|
46d8fd8c3f | ||
|
|
dbd7edba10 | ||
|
|
c93a4661a3 | ||
|
|
d934f38c99 | ||
|
|
a37960a3af | ||
|
|
a8d7195777 | ||
|
|
46085797b6 | ||
|
|
28135b7a20 | ||
|
|
ec9bfd8c56 | ||
|
|
4e56d89dcd | ||
|
|
27c899af56 | ||
|
|
23a14b537c | ||
|
|
c843243322 | ||
|
|
7642710155 | ||
|
|
9841e2186a | ||
|
|
cbfd4ccd1e | ||
|
|
3ab76b2312 | ||
|
|
1ff9ab95ac | ||
|
|
fdc3fa9148 | ||
|
|
e6481efa80 | ||
|
|
39bb91fc44 | ||
|
|
4072e40bb8 | ||
|
|
393a642c22 | ||
|
|
95173645a1 | ||
|
|
417797d218 | ||
|
|
b8d26e2418 | ||
|
|
21e1023d28 | ||
|
|
eaca5b3e81 | ||
|
|
bf8b1623c8 | ||
|
|
6070319f84 | ||
|
|
36b4bf74f7 | ||
|
|
caee314a50 | ||
|
|
a5f3456333 | ||
|
|
f7c7b949fd | ||
|
|
b2260c2278 | ||
|
|
7ce8ccb94f | ||
|
|
971bc8147f | ||
|
|
d8fffd2123 | ||
|
|
b4dffa4726 | ||
|
|
efc66f8525 | ||
|
|
d7ac16a9ed | ||
|
|
de703b182c | ||
|
|
45b72485ad | ||
|
|
c20dad3534 | ||
|
|
23b1b462c9 | ||
|
|
78add3cb17 | ||
|
|
565edd051f | ||
|
|
92b794002b | ||
|
|
8fa47acecc | ||
|
|
2ad0d05d31 | ||
|
|
f0600a898c | ||
|
|
58d9659d53 | ||
|
|
eb5d094715 | ||
|
|
58d5cf1c27 | ||
|
|
9f68d6eee9 | ||
|
|
04f1d89f84 | ||
|
|
28316891e9 | ||
|
|
79ff43adf5 | ||
|
|
81ef162703 | ||
|
|
5eddadafbd | ||
|
|
1df136323b | ||
|
|
0e85b136ae | ||
|
|
12065100e1 | ||
|
|
de09bec215 | ||
|
|
37a4c70c36 | ||
|
|
548dcb9f08 | ||
|
|
1bc3a25505 | ||
|
|
13437dd19b | ||
|
|
117d0111ab | ||
|
|
830334d767 | ||
|
|
95b142e4e5 | ||
|
|
04caf6f9ad | ||
|
|
113eeabd85 | ||
|
|
14d0292732 | ||
|
|
921f63da68 | ||
|
|
b562d6fdb3 | ||
|
|
1fc91f3580 | ||
|
|
978b7858f9 | ||
|
|
15280753e2 | ||
|
|
2ed7956be4 | ||
|
|
9df2cef4c4 | ||
|
|
8da931a7f6 | ||
|
|
e44a0cf6f8 | ||
|
|
3e4fd4b0ad | ||
|
|
a9ea949df8 | ||
|
|
ea0b5d9d1c | ||
|
|
dba7552c1e | ||
|
|
db33973e0a | ||
|
|
aea89fe832 | ||
|
|
95bc650be8 | ||
|
|
9fe95ef12b |
No files matched your search
@@ -0,0 +1,3 @@
|
||||
# -*- conf -*-
|
||||
/build/bootstrap/*.com binary
|
||||
/usr/share/zoneinfo/* binary
|
||||
@@ -0,0 +1,3 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [jart]
|
||||
@@ -1,5 +1,10 @@
|
||||
# -*- conf -*-
|
||||
|
||||
/o
|
||||
|
||||
# TODO: Find some way to have Python write to o/
|
||||
__pycache__
|
||||
|
||||
*.tmp
|
||||
/.bochs.log
|
||||
/HTAGS
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
virt: lxd
|
||||
os: linux
|
||||
language: c
|
||||
script: make -j4 V=0
|
||||
notifications:
|
||||
email: false
|
||||
Vendored
+112
@@ -0,0 +1,112 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Win32",
|
||||
"includePath": [
|
||||
"${workspaceFolder}"
|
||||
],
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "c++11",
|
||||
"forcedInclude": ["${workspaceFolder}/.vscode/vscode.h"],
|
||||
"defines": [
|
||||
"libcesque=",
|
||||
"pureconst=",
|
||||
"paramsnonnull(x)=",
|
||||
"alignas(x)",
|
||||
"alignof(x)",
|
||||
"artificial=",
|
||||
"nodiscard=",
|
||||
"mayalias=",
|
||||
"forceinline=",
|
||||
"forcealign(x)=",
|
||||
"scanfesque(x)=",
|
||||
"strftimeesque(x)=",
|
||||
"wontreturn=",
|
||||
"textreal=",
|
||||
"mallocesque=",
|
||||
"callocesque=",
|
||||
"vallocesque=",
|
||||
"reallocesque=",
|
||||
"strlenesque=",
|
||||
"memcpyesque=",
|
||||
"hasatleast=",
|
||||
"noinline=",
|
||||
"textexit=",
|
||||
"returnstwice=",
|
||||
"textwindows=",
|
||||
"privileged=",
|
||||
"compatfn=",
|
||||
"noinstrument=",
|
||||
"nodebuginfo=",
|
||||
"interruptfn=",
|
||||
"optimizespeed=",
|
||||
"forcealignargpointer=",
|
||||
"noasan=",
|
||||
"noubsan=",
|
||||
"testonly=",
|
||||
"donothing=",
|
||||
"nosideeffect=",
|
||||
"unreachable=",
|
||||
"thatispacked=",
|
||||
"nothrow=",
|
||||
"nocallback=",
|
||||
"relegated=",
|
||||
"hidden=",
|
||||
"textstartup=",
|
||||
"initarray=",
|
||||
"returnsnonnull=",
|
||||
"returnspointerwithnoaliases=",
|
||||
"printfesque(x)=",
|
||||
"attributeallocsize(x)=",
|
||||
"returnsaligned(x)=",
|
||||
"attributeallocalign(x)=",
|
||||
"nullterminated(x)="
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Linux",
|
||||
"includePath": [
|
||||
"${workspaceFolder}"
|
||||
],
|
||||
"cStandard": "gnu17",
|
||||
"compilerPath": "${workspaceFolder}/o/third_party/gcc/bin/x86_64-linux-musl-gcc",
|
||||
"compilerArgs": [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"-fdebug-prefix-map=${workspaceFolder}=",
|
||||
"-frecord-gcc-switches",
|
||||
"-Wa,-W",
|
||||
"-Wa,-I.",
|
||||
"-Wa,--noexecstack",
|
||||
"-Wa,--nocompress-debug-sections",
|
||||
"-Og",
|
||||
"-g",
|
||||
"-gdescribe-dies",
|
||||
"-msse3",
|
||||
"-mno-red-zone",
|
||||
"-fno-math-errno",
|
||||
"-fno-trapping-math",
|
||||
"-fno-fp-int-builtin-inexact",
|
||||
"-fno-ident",
|
||||
"-fno-common",
|
||||
"-fno-gnu-unique",
|
||||
"-fstrict-aliasing",
|
||||
"-fstrict-overflow",
|
||||
"-fno-semantic-interposition",
|
||||
"-mno-omit-leaf-frame-pointer",
|
||||
"-fno-jump-tables",
|
||||
"-nostdinc",
|
||||
"-iquote."
|
||||
],
|
||||
"forcedInclude": [
|
||||
"libc/integral/normalize.inc"
|
||||
],
|
||||
"defines": [
|
||||
"COSMO",
|
||||
"MODE=",
|
||||
"IMAGE_BASE_VIRTUAL=0x400000"
|
||||
]
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
#define __VSCODE_INTELLISENSE__ 1
|
||||
#include "libc/integral/normalize.inc"
|
||||
@@ -0,0 +1,62 @@
|
||||
# Contributing Guidelines
|
||||
|
||||
We'd love to accept your patches! Please read this guide first.
|
||||
|
||||
## Copyright Assignment
|
||||
|
||||
Please send an email to Justine Tunney <jtunney@gmail.com> stating that
|
||||
you intend to assign her the copyright to the changes you contribute to
|
||||
Cosmopolitan. Please use the same email address you use for git commits
|
||||
which should only contain original source code from you or other people
|
||||
who are also assigning copyright. Please note that, if you're employed,
|
||||
you may need to get your employer's approval beforehand. If you can not
|
||||
assign copyright due to local laws, then you may alternatively consider
|
||||
disclaiming it using the language in [Unlicense](https://unlicense.org)
|
||||
or [CC-0](http://creativecommons.org/share-your-work/public-domain/cc0)
|
||||
|
||||
This is important because we can't produce 12kb single-file executables
|
||||
that comply with license requirements if we have to embed lots of them.
|
||||
Although that's less of an issue depending on the purpose of the files.
|
||||
For example, ownership is much less of a concern in the unit test files
|
||||
so you're encouraged to put your copyright on those, provided it's ISC.
|
||||
|
||||
## Style Guide
|
||||
|
||||
You can use clang-format to automatically format your files:
|
||||
|
||||
```sh
|
||||
clang-format -i -style=file tool/net/redbean.c
|
||||
```
|
||||
|
||||
If you use Emacs this can be automated on save for Cosmopolitan using
|
||||
[tool/emacs/cosmo-format.el]([tool/emacs/cosmo-format.el]).
|
||||
|
||||
### Source Files
|
||||
|
||||
- Must use include paths relative to the root of the repository
|
||||
- Must have comment at top of file documenting copyright and license
|
||||
- Must have notice embedding if not owned by Justine (exception: tests)
|
||||
- May use language extensions that are supported by both GCC and Clang
|
||||
- Should use Google indentation (otherwise use `/* clang-format off */`)
|
||||
- Should use asm() instead of compiler APIs (exception: ctz, clz, memcpy)
|
||||
|
||||
### Header Files
|
||||
|
||||
- Must not have copyright or license comments
|
||||
- Must have once guards (otherwise change `.h` to `.inc`)
|
||||
- Must be ANSI C89 compatible to be included in the amalgamation header
|
||||
- Must include its dependencies (exception: libc/integral/normalize.inc)
|
||||
- Must not define objects (i.e. `cc -c -xc foo.h` will produce empty `.o`)
|
||||
- Should not use typedefs
|
||||
- Should not use forward declarations
|
||||
- Should not include documentation comments
|
||||
- Should not include parameter names in prototypes
|
||||
- Should not pose problems if included by C++ or Assembly sources
|
||||
- Should not declare non-ANSI code, at all, when the user requests ANSI
|
||||
|
||||
### Build Config
|
||||
|
||||
- Must not write files outside `o/`
|
||||
- Must not communicate with Internet
|
||||
- Must not depend on system libraries
|
||||
- Must not depend on system commands (exception: sh, make, gzip, zip)
|
||||
@@ -0,0 +1,16 @@
|
||||
ISC License
|
||||
|
||||
Copyright 2020 Justine Alexandra Roberts Tunney
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for
|
||||
any purpose with or without fee is hereby granted, provided that the
|
||||
above copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
@@ -40,8 +40,7 @@
|
||||
# o/dbg/examples/crashreport.com
|
||||
# less examples/crashreport.c
|
||||
#
|
||||
# # extremely tiny binaries (scout's honor escape hatch)
|
||||
# # please pay the $1k for commercial license if you can
|
||||
# # extremely tiny binaries
|
||||
# make -j8 -O MODE=tiny \
|
||||
# LDFLAGS+=-s \
|
||||
# CPPFLAGS+=-DIM_FEELING_NAUGHTY \
|
||||
@@ -52,7 +51,7 @@
|
||||
#
|
||||
# TROUBLESHOOTING
|
||||
#
|
||||
# make -j8 -O SILENT=0 o//examples/hello.com
|
||||
# make -j8 -O V=1 o//examples/hello.com
|
||||
# make o//examples/life.elf -pn |& less
|
||||
# etc.
|
||||
#
|
||||
@@ -61,7 +60,7 @@
|
||||
# build/config.mk
|
||||
|
||||
SHELL = /bin/sh
|
||||
HOSTS ?= freebsd openbsd alpine
|
||||
HOSTS ?= freebsd openbsd netbsd rhel7 rhel5 xnu win7 win10
|
||||
SANITY := $(shell build/sanitycheck $$PPID)
|
||||
GNUMAKEFLAGS += --output-sync
|
||||
|
||||
@@ -71,57 +70,51 @@ GNUMAKEFLAGS += --output-sync
|
||||
.PHONY: all o bins check test depend tags
|
||||
|
||||
all: o
|
||||
o: o/$(MODE)/ape \
|
||||
o/$(MODE)/dsp \
|
||||
o/$(MODE)/net \
|
||||
o/$(MODE)/libc \
|
||||
o/$(MODE)/test \
|
||||
o/$(MODE)/tool \
|
||||
o/$(MODE)/examples \
|
||||
o: o/$(MODE)/ape \
|
||||
o/$(MODE)/dsp \
|
||||
o/$(MODE)/net \
|
||||
o/$(MODE)/libc \
|
||||
o/$(MODE)/test \
|
||||
o/$(MODE)/tool \
|
||||
o/$(MODE)/examples \
|
||||
o/$(MODE)/third_party
|
||||
|
||||
PKGS =
|
||||
|
||||
-include ~/.cosmo.mk #──No.1
|
||||
-include ~/.cosmo.mk
|
||||
include build/functions.mk #─┐
|
||||
include build/definitions.mk # ├──meta
|
||||
include build/config.mk # │
|
||||
include build/rules.mk # │
|
||||
include build/definitions.mk # ├──META
|
||||
include build/config.mk # │ You can build
|
||||
include build/rules.mk # │ You can topologically order
|
||||
include build/online.mk # │
|
||||
include libc/stubs/stubs.mk #─┘
|
||||
include libc/nexgen32e/nexgen32e.mk #─┐
|
||||
include libc/intrin/intrin.mk # │
|
||||
include libc/linux/linux.mk # │
|
||||
include libc/math/math.mk # ├──metal
|
||||
include libc/tinymath/tinymath.mk # │
|
||||
include libc/sysv/sysv.mk # ├──SYSTEM SUPPORT
|
||||
include libc/nt/nt.mk # │ You can do math
|
||||
include libc/intrin/intrin.mk # │ You can use the stack
|
||||
include libc/linux/linux.mk # │ You can manipulate arrays
|
||||
include libc/tinymath/tinymath.mk # │ You can issue raw system calls
|
||||
include third_party/compiler_rt/compiler_rt.mk # │
|
||||
include libc/bits/bits.mk # │
|
||||
include libc/str/str.mk # │
|
||||
include third_party/xed/xed.mk # │
|
||||
include third_party/zlib/zlib.mk # │
|
||||
include libc/elf/elf.mk # │
|
||||
include ape/lib/apelib.mk # │
|
||||
include ape/ape.mk #─┘
|
||||
include libc/sysv/sysv.mk #─┐
|
||||
include libc/nt/nt.mk # ├──system
|
||||
include libc/conv/conv.mk # │
|
||||
include libc/fmt/fmt.mk # │
|
||||
include libc/rand/rand.mk #─┘
|
||||
include ape/ape.mk # │
|
||||
include libc/fmt/fmt.mk #─┘
|
||||
include libc/calls/calls.mk #─┐
|
||||
include libc/runtime/runtime.mk # ├──systems
|
||||
include libc/crt/crt.mk # │
|
||||
include libc/runtime/runtime.mk # ├──SYSTEMS RUNTIME
|
||||
include libc/crt/crt.mk # │ You can issue system calls
|
||||
include libc/rand/rand.mk # │
|
||||
include libc/unicode/unicode.mk # │
|
||||
include third_party/dlmalloc/dlmalloc.mk # │
|
||||
include libc/mem/mem.mk # │
|
||||
include libc/ohmyplus/ohmyplus.mk # │
|
||||
include libc/zipos/zipos.mk # │
|
||||
include third_party/dtoa/dtoa.mk # │
|
||||
include third_party/dlmalloc/dlmalloc.mk #─┘
|
||||
include libc/mem/mem.mk #─┐
|
||||
include libc/ohmyplus/ohmyplus.mk # ├──DYNAMIC RUNTIME
|
||||
include libc/zipos/zipos.mk # │ You can now use stdio
|
||||
include third_party/gdtoa/gdtoa.mk # │ You can finally call malloc()
|
||||
include libc/time/time.mk # │
|
||||
include libc/alg/alg.mk # │
|
||||
include libc/calls/hefty/hefty.mk # │
|
||||
include libc/stdio/stdio.mk # │
|
||||
include third_party/f2c/f2c.mk # │
|
||||
include third_party/blas/blas.mk # │
|
||||
include net/net.mk # │
|
||||
include libc/log/log.mk # │
|
||||
include dsp/core/core.mk # │
|
||||
@@ -134,48 +127,44 @@ include third_party/musl/musl.mk # │
|
||||
include third_party/getopt/getopt.mk # │
|
||||
include libc/libc.mk #─┘
|
||||
include libc/sock/sock.mk #─┐
|
||||
include dsp/tty/tty.mk # ├──online
|
||||
include libc/dns/dns.mk # │
|
||||
include libc/crypto/crypto.mk # │
|
||||
include net/http/http.mk #─┘
|
||||
include third_party/lemon/lemon.mk
|
||||
include third_party/linenoise/linenoise.mk
|
||||
include third_party/editline/editline.mk
|
||||
include third_party/duktape/duktape.mk
|
||||
include third_party/regex/regex.mk
|
||||
include third_party/avir/avir.mk
|
||||
include third_party/ctags/ctags.mk
|
||||
include dsp/tty/tty.mk # ├──ONLINE RUNTIME
|
||||
include libc/dns/dns.mk # │ You can communicate with the network
|
||||
include net/http/http.mk # │
|
||||
include third_party/mbedtls/mbedtls.mk # │
|
||||
include net/https/https.mk # │
|
||||
include third_party/regex/regex.mk #─┘
|
||||
include third_party/third_party.mk
|
||||
include libc/testlib/testlib.mk
|
||||
include tool/viz/lib/vizlib.mk
|
||||
include examples/examples.mk
|
||||
include third_party/lex/lex.mk
|
||||
include third_party/m4/m4.mk
|
||||
include third_party/linenoise/linenoise.mk
|
||||
include third_party/lua/lua.mk
|
||||
include third_party/sqlite3/sqlite3.mk
|
||||
include third_party/mbedtls/test/test.mk
|
||||
include third_party/quickjs/quickjs.mk
|
||||
include third_party/lz4cli/lz4cli.mk
|
||||
include third_party/bzip2/bzip2.mk
|
||||
include third_party/infozip/infozip.mk
|
||||
include third_party/python/python.mk
|
||||
include tool/build/lib/buildlib.mk
|
||||
include third_party/chibicc/chibicc.mk
|
||||
include third_party/chibicc/test/test.mk
|
||||
include tool/build/emucrt/emucrt.mk
|
||||
include tool/build/emubin/emubin.mk
|
||||
include tool/build/build.mk
|
||||
include tool/calc/calc.mk
|
||||
include tool/tags/tags.mk
|
||||
include examples/examples.mk
|
||||
include tool/decode/lib/decodelib.mk
|
||||
include tool/decode/decode.mk
|
||||
include tool/hash/hash.mk
|
||||
include tool/net/net.mk
|
||||
include tool/viz/viz.mk
|
||||
include tool/cc/cc.mk
|
||||
include tool/tool.mk
|
||||
include test/libc/alg/test.mk
|
||||
include test/libc/tinymath/test.mk
|
||||
include test/libc/math/test.mk
|
||||
include test/libc/intrin/test.mk
|
||||
include test/libc/mem/test.mk
|
||||
include test/libc/nexgen32e/test.mk
|
||||
include test/libc/runtime/test.mk
|
||||
include test/libc/sock/test.mk
|
||||
include test/libc/bits/test.mk
|
||||
include test/libc/crypto/test.mk
|
||||
include test/libc/str/test.mk
|
||||
include test/libc/unicode/test.mk
|
||||
include test/libc/calls/test.mk
|
||||
@@ -186,16 +175,16 @@ include test/libc/dns/test.mk
|
||||
include test/libc/rand/test.mk
|
||||
include test/libc/time/test.mk
|
||||
include test/libc/stdio/test.mk
|
||||
include test/libc/conv/test.mk
|
||||
include test/libc/release/test.mk
|
||||
include test/libc/test.mk
|
||||
include test/ape/lib/test.mk
|
||||
include test/ape/test.mk
|
||||
include test/net/http/test.mk
|
||||
include test/net/https/test.mk
|
||||
include test/net/test.mk
|
||||
include test/tool/build/lib/test.mk
|
||||
include test/tool/build/test.mk
|
||||
include test/tool/viz/lib/test.mk
|
||||
include test/tool/viz/test.mk
|
||||
include test/tool/net/test.mk
|
||||
include test/tool/test.mk
|
||||
include test/dsp/core/test.mk
|
||||
include test/dsp/scale/test.mk
|
||||
@@ -206,55 +195,108 @@ include examples/package/build.mk
|
||||
#-φ-examples/package/new.sh
|
||||
include test/test.mk
|
||||
|
||||
OBJS = $(foreach x,$(PKGS),$($(x)_OBJS))
|
||||
SRCS = $(foreach x,$(PKGS),$($(x)_SRCS))
|
||||
HDRS = $(foreach x,$(PKGS),$($(x)_HDRS))
|
||||
BINS = $(foreach x,$(PKGS),$($(x)_BINS))
|
||||
TESTS = $(foreach x,$(PKGS),$($(x)_TESTS))
|
||||
CHECKS = $(foreach x,$(PKGS),$($(x)_CHECKS))
|
||||
OBJS = $(foreach x,$(PKGS),$($(x)_OBJS))
|
||||
SRCS := $(foreach x,$(PKGS),$($(x)_SRCS))
|
||||
HDRS := $(foreach x,$(PKGS),$($(x)_HDRS))
|
||||
INCS = $(foreach x,$(PKGS),$($(x)_INCS))
|
||||
BINS = $(foreach x,$(PKGS),$($(x)_BINS))
|
||||
TESTS = $(foreach x,$(PKGS),$($(x)_TESTS))
|
||||
CHECKS = $(foreach x,$(PKGS),$($(x)_CHECKS))
|
||||
|
||||
bins: $(BINS)
|
||||
check: $(CHECKS)
|
||||
test: $(TESTS)
|
||||
test: $(TESTS) all
|
||||
depend: o/$(MODE)/depend
|
||||
tags: TAGS HTAGS
|
||||
|
||||
o/$(MODE)/.x:
|
||||
@$(MKDIR) $(@D) && touch $@
|
||||
@mkdir -p $(@D) && touch $@
|
||||
|
||||
ifneq ($(findstring 4.,,$(MAKE_VERSION)),$(MAKE_VERSION))
|
||||
o/$(MODE)/srcs.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(SRCS),$(dir $(x))))
|
||||
$(file >$@) $(foreach x,$(SRCS),$(file >>$@,$(x)))
|
||||
o/$(MODE)/hdrs.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(HDRS) $(INCS),$(dir $(x))))
|
||||
$(file >$@) $(foreach x,$(HDRS) $(INCS),$(file >>$@,$(x)))
|
||||
o/$(MODE)/incs.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(INCS) $(INCS),$(dir $(x))))
|
||||
$(file >$@) $(foreach x,$(INCS) $(INCS),$(file >>$@,$(x)))
|
||||
else
|
||||
o/$(MODE)/srcs.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(SRCS),$(dir $(x))))
|
||||
$(MAKE) MODE=rel -j8 -pn bopit 2>/dev/null | sed -ne '/^SRCS/ {s/.*:= //;s/ */\n/g;p;q}' >$@
|
||||
o/$(MODE)/hdrs.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(HDRS) $(INCS),$(dir $(x))))
|
||||
$(MAKE) MODE=rel -j8 -pn bopit 2>/dev/null | sed -ne '/^HDRS/ {s/.*:= //;s/ */\n/g;p;q}' >$@
|
||||
o/$(MODE)/incs.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(INCS) $(INCS),$(dir $(x))))
|
||||
$(MAKE) MODE=rel -j8 -pn bopit 2>/dev/null | sed -ne '/^INCS/ {s/.*:= //;s/ */\n/g;p;q}' >$@
|
||||
endif
|
||||
|
||||
o/$(MODE)/hdrs.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(HDRS),$(dir $(x))))
|
||||
$(file >$@) $(foreach x,$(HDRS),$(file >>$@,$(x)))
|
||||
|
||||
o/$(MODE)/depend: o/$(MODE)/.x o/$(MODE)/srcs.txt o/$(MODE)/hdrs.txt $(SRCS) $(HDRS)
|
||||
@build/mkdeps -o $@ -r o/$(MODE)/ o/$(MODE)/srcs.txt o/$(MODE)/hdrs.txt
|
||||
o/$(MODE)/depend: o/$(MODE)/.x o/$(MODE)/srcs.txt o/$(MODE)/hdrs.txt o/$(MODE)/incs.txt $(SRCS) $(HDRS) $(INCS)
|
||||
@$(COMPILE) -AMKDEPS $(MKDEPS) -o $@ -r o/$(MODE)/ o/$(MODE)/srcs.txt o/$(MODE)/hdrs.txt o/$(MODE)/incs.txt
|
||||
|
||||
TAGS: o/$(MODE)/srcs.txt $(SRCS)
|
||||
@rm -f $@
|
||||
@ACTION=TAGS TARGET=$@ build/do $(TAGS) $(TAGSFLAGS) -L $< -o $@
|
||||
@$(COMPILE) -ATAGS -T$@ $(TAGS) $(TAGSFLAGS) -L $< -o $@
|
||||
|
||||
HTAGS: o/$(MODE)/hdrs.txt $(HDRS)
|
||||
@rm -f $@
|
||||
@ACTION=TAGS TARGET=$@ build/do build/htags -L $< -o $@
|
||||
@$(COMPILE) -ATAGS -T$@ build/htags -L $< -o $@
|
||||
|
||||
loc: o/$(MODE)/tool/build/summy.com
|
||||
find -name \*.h -or -name \*.c -or -name \*.S | \
|
||||
$(XARGS) wc -l | grep total | awk '{print $$1}' | $<
|
||||
|
||||
COSMOPOLITAN_OBJECTS = \
|
||||
APE_LIB \
|
||||
LIBC_DNS \
|
||||
LIBC_SOCK \
|
||||
LIBC_NT_WS2_32 \
|
||||
LIBC_NT_IPHLPAPI \
|
||||
LIBC_NT_MSWSOCK \
|
||||
LIBC_OHMYPLUS \
|
||||
LIBC_X \
|
||||
THIRD_PARTY_GETOPT \
|
||||
LIBC_LOG \
|
||||
LIBC_UNICODE \
|
||||
LIBC_TIME \
|
||||
LIBC_ZIPOS \
|
||||
THIRD_PARTY_ZLIB \
|
||||
THIRD_PARTY_MUSL \
|
||||
LIBC_STDIO \
|
||||
THIRD_PARTY_GDTOA \
|
||||
THIRD_PARTY_REGEX \
|
||||
LIBC_ALG \
|
||||
LIBC_MEM \
|
||||
THIRD_PARTY_DLMALLOC \
|
||||
LIBC_BITS \
|
||||
LIBC_RUNTIME \
|
||||
LIBC_ELF \
|
||||
LIBC_CALLS \
|
||||
LIBC_RAND \
|
||||
LIBC_SYSV_CALLS \
|
||||
LIBC_NT_KERNELBASE \
|
||||
LIBC_NT_SHELL32 \
|
||||
LIBC_NT_GDI32 \
|
||||
LIBC_NT_COMDLG32 \
|
||||
LIBC_NT_NETAPI32 \
|
||||
LIBC_NT_URL \
|
||||
LIBC_NT_USER32 \
|
||||
LIBC_NT_NTDLL \
|
||||
LIBC_NT_ADVAPI32 \
|
||||
LIBC_FMT \
|
||||
THIRD_PARTY_COMPILER_RT \
|
||||
LIBC_TINYMATH \
|
||||
LIBC_STR \
|
||||
LIBC_SYSV \
|
||||
LIBC_INTRIN \
|
||||
LIBC_NT_KERNEL32 \
|
||||
LIBC_NEXGEN32E
|
||||
|
||||
COSMOPOLITAN_HEADERS = \
|
||||
LIBC \
|
||||
LIBC_ALG \
|
||||
LIBC_BITS \
|
||||
LIBC_CALLS \
|
||||
LIBC_CALLS_HEFTY \
|
||||
LIBC_CONV \
|
||||
LIBC_CRYPTO \
|
||||
LIBC_DNS \
|
||||
LIBC_FMT \
|
||||
LIBC_ELF \
|
||||
LIBC_FMT \
|
||||
LIBC_INTRIN \
|
||||
LIBC_LOG \
|
||||
LIBC_MEM \
|
||||
LIBC_NEXGEN32E \
|
||||
@@ -265,48 +307,42 @@ COSMOPOLITAN_OBJECTS = \
|
||||
LIBC_SOCK \
|
||||
LIBC_STDIO \
|
||||
LIBC_STR \
|
||||
LIBC_STUBS \
|
||||
LIBC_SYSV \
|
||||
LIBC_TIME \
|
||||
LIBC_TINYMATH \
|
||||
LIBC_UNICODE \
|
||||
LIBC_X \
|
||||
LIBC_ZIPOS \
|
||||
THIRD_PARTY_DLMALLOC \
|
||||
THIRD_PARTY_DTOA \
|
||||
THIRD_PARTY_GDTOA \
|
||||
THIRD_PARTY_GETOPT \
|
||||
THIRD_PARTY_MUSL \
|
||||
THIRD_PARTY_ZLIB \
|
||||
THIRD_PARTY_REGEX
|
||||
|
||||
COSMOPOLITAN_HEADERS = \
|
||||
LIBC \
|
||||
LIBC_CALLS \
|
||||
LIBC_CONV \
|
||||
LIBC_CRYPTO \
|
||||
LIBC_DNS \
|
||||
LIBC_FMT \
|
||||
LIBC_MEM \
|
||||
LIBC_RAND \
|
||||
LIBC_RUNTIME \
|
||||
LIBC_SOCK \
|
||||
LIBC_STDIO \
|
||||
LIBC_STR \
|
||||
LIBC_TIME \
|
||||
LIBC_UNICODE \
|
||||
LIBC_ZIPOS \
|
||||
LIBC_SYSV \
|
||||
LIBC_NT \
|
||||
THIRD_PARTY_DLMALLOC \
|
||||
THIRD_PARTY_DTOA \
|
||||
THIRD_PARTY_GETOPT \
|
||||
THIRD_PARTY_MUSL \
|
||||
THIRD_PARTY_REGEX
|
||||
o/$(MODE)/cosmopolitan.a.txt:
|
||||
printf "%s\n" $(call reverse,$(call uniq,$(foreach x,$(COSMOPOLITAN_OBJECTS),$($(x)))))
|
||||
o/$(MODE)/cosmopolitan.a: $(filter-out o/libc/stubs/exit11.o,$(foreach x,$(COSMOPOLITAN_OBJECTS),$($(x)_A_OBJS)))
|
||||
o/cosmopolitan.h: \
|
||||
o/$(MODE)/tool/build/rollup.com \
|
||||
libc/integral/normalize.inc \
|
||||
$(foreach x,$(COSMOPOLITAN_HEADERS),$($(x)_HDRS))
|
||||
@$(COMPILE) -AROLLUP -T$@ $^ >$@
|
||||
|
||||
o/$(MODE)/cosmopolitan.a: $(filter-out o/libc/stubs/exit11.o,$(foreach x,$(COSMOPOLITAN_OBJECTS),$($(x)_OBJS)))
|
||||
o/$(MODE)/.cosmopolitan.h: $(foreach x,$(COSMOPOLITAN_HEADERS),$($(x)_HDRS))
|
||||
build/rollup $^ >$@
|
||||
o/$(MODE)/cosmopolitan.h: o/$(MODE)/.cosmopolitan.h
|
||||
build/compile $(PREPROCESS) -P $(OUTPUT_OPTION) $<
|
||||
clang-format-10 -i $@
|
||||
o/cosmopolitan.html: \
|
||||
o/$(MODE)/third_party/chibicc/chibicc.com.dbg \
|
||||
$(filter-out %.s,$(foreach x,$(COSMOPOLITAN_OBJECTS),$($(x)_SRCS)))
|
||||
o/$(MODE)/third_party/chibicc/chibicc.com.dbg -J \
|
||||
-fno-common -include libc/integral/normalize.inc -o $@ \
|
||||
$(filter-out %.s,$(foreach x,$(COSMOPOLITAN_OBJECTS),$($(x)_SRCS)))
|
||||
|
||||
$(SRCS): \
|
||||
libc/integral/normalize.inc \
|
||||
libc/integral/c.inc \
|
||||
libc/integral/cxx.inc \
|
||||
libc/integral/cxxtypescompat.inc \
|
||||
libc/integral/lp64arg.inc \
|
||||
libc/integral/lp64.inc
|
||||
|
||||
# UNSPECIFIED PREREQUISITES TUTORIAL
|
||||
#
|
||||
@@ -330,6 +366,7 @@ o/$(MODE)/cosmopolitan.h: o/$(MODE)/.cosmopolitan.h
|
||||
~/.cosmo.mk:
|
||||
$(SRCS):
|
||||
$(HDRS):
|
||||
$(INCS):
|
||||
.DEFAULT:
|
||||
@echo >&2
|
||||
@echo NOTE: deleting o/$(MODE)/depend because of an unspecified prerequisite: $@ >&2
|
||||
|
||||
@@ -1,341 +0,0 @@
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
@@ -1,314 +1,95 @@
|
||||

|
||||
|
||||
# Cosmopolitan
|
||||
|
||||
Fast portable static native textmode executable containers.
|
||||
[Cosmopolitan Libc](https://justine.lol/cosmopolitan/index.html) makes C
|
||||
a build-once run-anywhere language, like Java, except it doesn't need an
|
||||
interpreter or virtual machine. Instead, it reconfigures stock GCC and
|
||||
Clang to output a POSIX-approved polyglot format that runs natively on
|
||||
Linux + Mac + Windows + FreeBSD + OpenBSD + NetBSD + BIOS with the best
|
||||
possible performance and the tiniest footprint imaginable.
|
||||
|
||||
For an introduction to this project, please read the <a
|
||||
href="https://justine.storage.googleapis.com/ape.html">αcτµαlly pδrταblε
|
||||
εxεcµταblε</a> blog post.
|
||||
## Background
|
||||
|
||||
Cosmopolitan builds run natively on most platforms without dependencies,
|
||||
because it implements the subset of the C library, compiler runtimes and
|
||||
system call interfaces that've achieved near universal consensus amongst
|
||||
all major platforms, e.g. Linux/BSD/XNU/NT. Containerization is achieved
|
||||
by having binaries also be ZIP files. Modern static stock GNU toolchains
|
||||
are provided in a hermetic mono repo for the best historical determinism
|
||||
|
||||
Here's how you can get started by printing cat videos inside a terminal:
|
||||
|
||||
make -j8 o//tool/viz/printvideo.com
|
||||
wget https://justine.storage.googleapis.com/cats.mpg
|
||||
o//tool/viz/printvideo.com cats.mpg
|
||||
unzip -vl o//tool/viz/printvideo.com
|
||||
|
||||
Cosmopolitan provides a native development environment similar to those
|
||||
currently being offered by RedHat, Google, Apple, Microsoft, etc. We're
|
||||
different in two ways: (1) we're not a platform therefore we don't have
|
||||
any commercial interest in making our tooling work better on one rather
|
||||
than another; and (2) we cater primarily towards features having gained
|
||||
cross-platform agreement. Goal is software that stands the test of time
|
||||
without the costs and restrictions cross-platform distribution entails.
|
||||
|
||||
That makes Cosmopolitan an excellent fit for writing small CLI programs
|
||||
that do things like matrix multiplication relu stdio as a subprocess or
|
||||
perhaps a web server having the minimum surface area that you require.
|
||||
For an introduction to this project, please read the [αcτµαlly pδrταblε
|
||||
εxεcµταblε](https://justine.lol/ape.html) blog post and [cosmopolitan
|
||||
libc](https://justine.lol/cosmopolitan/index.html) website. We also have
|
||||
[API documentation](https://justine.lol/cosmopolitan/documentation.html).
|
||||
|
||||
## Getting Started
|
||||
|
||||
Just clone the repository and put your own folder in it. Please choose a
|
||||
name that's based on a .com or .org domain name registration you control
|
||||
which is scout's honor but could change to verify TXT records in future.
|
||||
If you're doing your development work on Linux or BSD then you need just
|
||||
five files to get started. Here's what you do on Linux:
|
||||
|
||||
We provide a script that makes it easy to start a new package:
|
||||
```sh
|
||||
wget https://justine.lol/cosmopolitan/cosmopolitan-amalgamation-1.0.zip
|
||||
unzip cosmopolitan-amalgamation-1.0.zip
|
||||
printf 'main() { printf("hello world\\n"); }\n' >hello.c
|
||||
gcc -g -Os -static -nostdlib -nostdinc -fno-pie -no-pie -mno-red-zone \
|
||||
-fno-omit-frame-pointer -pg -mnop-mcount \
|
||||
-o hello.com.dbg hello.c -fuse-ld=bfd -Wl,-T,ape.lds \
|
||||
-include cosmopolitan.h crt.o ape.o cosmopolitan.a
|
||||
objcopy -S -O binary hello.com.dbg hello.com
|
||||
```
|
||||
|
||||
examples/package/new.sh com/github/user/project
|
||||
emacs com/github/user/project/program.c
|
||||
make o//com/github/user/project/program.com
|
||||
o//com/github/user/project/program.com
|
||||
You now have a portable program. Please note that your APE binary will
|
||||
assimilate itself as a conventional resident of your platform after the
|
||||
first run, so it can be fast and efficient for subsequent executions.
|
||||
|
||||
Please note GNU Make is awesome. Little known fact: make is a functional
|
||||
programming language. We improved upon it too! In [tool/build/package.c]
|
||||
which performs strict dependency checking, to correct Google's published
|
||||
mistakes c. 2006 which was when they switched from using a GNU Make repo
|
||||
in favor of an inhouse derivative called Blaze which does graph checking
|
||||
thereby allowing the repository to grow gracefully with any requirements
|
||||
```sh
|
||||
./hello.com
|
||||
bash -c './hello.com' # zsh/fish workaround (we upstreamed patches)
|
||||
```
|
||||
|
||||
## Performance
|
||||
So if you intend to copy the binary to Windows or Mac then please do
|
||||
that before you run it, not after.
|
||||
|
||||
Your C Standard Library is designed to be competitive with glibc, which
|
||||
has historically been the best. Routines like [libc/nexgen32e/memcpy.S]
|
||||
are usually accompanied by microbenchmarks to demonstrate their merits.
|
||||
### MacOS
|
||||
|
||||
Where GNU, LLVM and MSVC got lazy is intrinsics. Cosmopolitan does that
|
||||
better. Your [ansitrinsics library] makes a 10x speedup so much easier,
|
||||
using Intel's new instructions, in such a way that only allows Intel to
|
||||
leverage their patents which have knowable expiry; rather than compiler
|
||||
intrinsics API copyrights, which might never expire like Walt Disney IP
|
||||
If you're developing on MacOS you can install the GNU compiler
|
||||
collection for x86_64-elf via homebrew:
|
||||
|
||||
See [dsp/scale/cdecimate2xuint8x8.c] and [tool/viz/lib/ycbcr2rgb3.c] as
|
||||
an example, of how 4k video convolutions needed to print cat videos can
|
||||
be done from a single core without threads on a cheap computer, without
|
||||
sacrificing backwards compatibility due to excellent microarchitectural
|
||||
dispatch like [libc/nexgen32e/kcpuids.S], [libc/nexgen32e/x86feature.h]
|
||||
```sh
|
||||
brew install x86_64-elf-gcc
|
||||
```
|
||||
|
||||
Furthermore Cosmopolitan provides you with Intel's official instruction
|
||||
length decoder Xed ravaged down to 3kb in size using Tim Patterson code
|
||||
stunts. So you can absolutely code high-performance lightweight fabless
|
||||
x86 microprocessors using any hobbyist board without royalties, because
|
||||
Xed tells us which parts of the encoding space now belong to the people.
|
||||
Please see [third_party/xed/x86ild.greg.c] to learn more.
|
||||
Then in the above scripts just replace `gcc` and `objcopy` with
|
||||
`x86_64-elf-gcc` and `x86_64-elf-objcopy` to compile your APE binary.
|
||||
|
||||
## Integrated Development Environment
|
||||
### Windows
|
||||
|
||||
Your Cosmopolitan IDE is based on whichever editor you love most. Emacs
|
||||
configs are provided, showing how `make tags` can be used to automate
|
||||
certain toil, such as adding include lines by typing `C-c C-h` over a
|
||||
symbol. We recommend trying the following:
|
||||
If you're developing on Windows then you need to download an
|
||||
x86_64-pc-linux-gnu toolchain beforehand. See the [Compiling on
|
||||
Windows](https://justine.lol/cosmopolitan/windows-compiling.html)
|
||||
tutorial. It's needed because the ELF object format is what makes
|
||||
universal binaries possible.
|
||||
|
||||
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
|
||||
sudo apt install gdb ragel ctags clang-format-10
|
||||
git clone git@github.com:jart/cosmopolitan.git && cd cosmopolitan
|
||||
tool/scripts/install-emacs.sh # Emacs 26.1 has a bug
|
||||
tool/scripts/configure-emacs.sh # adds load statements
|
||||
make tags # index all the symbol
|
||||
emacs # for power and glory!
|
||||
## Source Builds
|
||||
|
||||
See [tool/emacs/cosmo-stuff.el] for further details. Further note that
|
||||
this codebase might seem to have unusual numbers of include statements
|
||||
quoted and vendored code, but that's actually why the tools work since
|
||||
it gives them easy perfect knowledge of what exists, thus performance.
|
||||
Cosmopolitan can be compiled from source on any Linux distro. GNU make
|
||||
needs to be installed beforehand. This is a freestanding hermetic
|
||||
repository that bootstraps using a vendored static gcc9 executable.
|
||||
No further dependencies are required.
|
||||
|
||||
## Specimen
|
||||
```sh
|
||||
wget https://justine.lol/cosmopolitan/cosmopolitan-1.0.tar.gz
|
||||
tar xf cosmopolitan-1.0.tar.gz # see releases page
|
||||
cd cosmopolitan
|
||||
make -j16
|
||||
o//examples/hello.com
|
||||
find o -name \*.com | xargs ls -rShal | less
|
||||
```
|
||||
|
||||
Cosmopolitan encodes binaries respecting the intersection of reasonable
|
||||
platform requirements. RADIX-256 disassembly of [examples/life.c] below
|
||||
should explain how easy it is to do pe+sh+elf+macho+bootloader overlays
|
||||
enabling gnu ld.bfd to produce a simple portable 12kb .com program file
|
||||
## Support Vector
|
||||
|
||||
Please send feedback and concerns to <jtunney@gmail.com> since we would
|
||||
love to do an even better job. Please also let us know if some goofball
|
||||
is distributing without bundling their source code, so we can reach out
|
||||
and ask if they would like to purchase a commercial license.
|
||||
|
||||
make -j10 -O MODE=tiny CPPFLAGS=-DIM_FEELING_NAUGHTY
|
||||
o/tiny/tool/viz/bing.com <o/tiny/examples/life.com |
|
||||
o/tiny/tool/viz/fold.com
|
||||
|
||||
MZqFpD=‘◙ ► ° ☺ ◘@ JT p♂
|
||||
▓@δ δ◄ÉÉδ♥R1╥╜ δ♣Θ⌐☼ ⁿ┐ p1╔·Ä╫ë╠√♫XΦ ^üεh ▒♦╤εâΘ☺u∙╣ ☻┐ ♦Ä▐Ä╟
|
||||
1÷1λ≤ñΩï@ ╣ ■≤ñ1φÄ▌Φ Uëσ╣ 0╕ ☺Ä└1└1λ≤¬Ç·@t#Φ. ╕ ♦Ä└┐↑ 0÷1╔ë°Φ]
|
||||
î╞â╞ Ot•Hu≈Ä╞δ∞ë♫@2ë▬B2Ω3E ◙SR┤◘═‼r,ê╧Çτ⁇Çß└╨┴╨┴å═▲♠▼1÷Ä╞╛ 2ç≈
|
||||
ÑÑÑÑÑñ▼ô½æ½Æ½X¬Æ[├ZÇ≥Ç1└═‼r≈δ┴S1█è▲♀29├w☻ë╪QP╗ ►î└)├üπλ☼╣♣ ╤δâΘ☺
|
||||
u∙XYà█t♠9├w☻ë╪PQå═╨╔╨╔Ç╔☺1█┤☻═‼Y[r‼┤ 9├|♪A;♫♪2~♦1╔■╞[├P1└═‼Xδ╨
|
||||
|
||||
U¬
|
||||
‘◙#‘“◙o=“$(command -v “$0“)“◙set -- “$o“ “$@“◙if [ -d /Applicati
|
||||
ons ]; then◙dd if=“$o“ of=“$o“ bs=8 skip=“ 410“ count=“
|
||||
87“ conv=notrunc 2>/dev/null◙elif exec 7<> “$o“; then◙printf ‘╲
|
||||
177ELF╲2╲1╲1╲011╲0╲0╲0╲0╲0╲0╲0╲0╲2╲0╲076╲0╲1╲0╲0╲0╲134╲022╲100╲0
|
||||
00╲000╲000╲000╲000╲150╲012╲000╲000╲000╲000╲000╲000╲000╲000╲000╲0
|
||||
00╲000╲000╲000╲000╲0╲0╲0╲0╲100╲0╲070╲0╲004╲000╲0╲0╲000╲000╲000╲0
|
||||
00‘ >&7◙exec 7<&-◙fi◙exec “$@“◙R=$⁇◙if [ $R -eq 126 ] && [ “$(un
|
||||
ame -m)“ != x86_64 ]; then◙if Q=“$(command -v qemu-x86_64)“; the
|
||||
n◙exec “$Q“ “$@“◙else◙echo error: need qemu-x86_64 >&2◙fi◙fi◙exi
|
||||
t $R◙αcτμαlly pδrταblε εxεcμταblε♪◙ error: ♪◙ cpuid oldskool ds
|
||||
knfo e820 nomem nolong hello◙ ♀ Cf☼▼D 8 ╕D f☼▼D
|
||||
λλ Ü☼ λλ Æ☼ λλ Ü╧ λλ Æ╧ λλ ¢» λλ ô» ☻░¡← ☺ ■OQΣ≡♦
|
||||
► 0► @► ►♣ =☻░¡+☼à↑♪ j ¥▓@☼ └âα■☼“└fΩW@ ÉÉÉÉUëσΦ§♪Φ↓ ┐• î
|
||||
♠▬2ú↑2Φ(☺┐EDΦÑ Φ╨♀Φ→☻Uëσ╣♦ ╛ 0¼ê┬¼ê╞à╥t♀QVë╫╛€DΦ○ ^YâΘ☺uσ]├Uëσë·
|
||||
à╥t↑RV1╔▒♥☺╩¼^♀ÇεZ¼εâ┬☺âΘ☺y÷]├UëσΦ↕ Φ Uëσ┐ 0╛♦ ΦÇ ΦÉ☺Uëσï╖☻0à÷u
|
||||
♦ï6 01└PV╕lDPVWV╕dDP_àλt♠^Φ♦ δ⌡]├UëσWVΦ♂ ^_à÷t♥Φ↨ ]├Uëσë■─>▬2Φ╕
|
||||
î♠▬2ú↑2]├UëσSë√ç▐¼ç▐ä└t↑ë╟VP╕ δ◘XΦ. δ♦XΦ( ^δ▀[]├ë±ë■1╥¼ê┬¼ê╞à
|
||||
└t◄â┬♣┤@∞ α≤Ét∙âΘ☺uσ├PQRë≥â┬♣┤ ∞ αu♦≤Éδ≈ë°ë≥εZYX├UëσS┤╕░ Ä└ë°<♥t
|
||||
☻0φ1λj X═►┤☺░ ╡ ▒ ═►┤►░♥╖ │ ═►1└[]├Uëσâ∞►ûë∙ëμëτ¬ë╧j☺Zδ♫V¼ä└u√ë≥
|
||||
^)≥UëσSë╤ë·ÇΓ ÇμÇÇ┬áÇ╓☼╖ │á9·t)w↕¼<◙t↕<♪t↕¬░•¬âΘ☺uΦë°[]├☺▀δ≥ë°R1
|
||||
╥≈√)╫ZδμPQRVë▐P╕ δ◘XΦ♫ δ♦XΦ◘ ë╟^ZYXδ╞≈╥ë∙Çß ÇσÇç╧)±Q)∙ë■☺╬╕
|
||||
▲•≤ñX├Uëσ╕ S1█═§r→ü√MPu¶╕☺S1█═§1█1╔╕•S│☺▒♥═§Φ╢◙UëσΦ↔ Φy☺┐ ►╛ Φz
|
||||
r○Φ╟ Φ∞ Φ‘☻╕àDΦ♀■Uëσ£X% puMf£fXfë┴f╗ f1╪fPf¥f£fXf9┴t:f!╪fPf¥
|
||||
f┐ Çfë°fG☼óf9°|∟fë°☼óf┐ f!·f9·u○1└]├╕uDδ◙╕ÉDδ♣╕oDδ Φú²Uëσfh
|
||||
PAMSS┴∩♦Ä╟f1λf1█f╕ Φ f╣↑ fïVⁿ═§r&f;Fⁿu à╔t♫â∙§r♠÷E¶☺u♥â╟↑fà█t
|
||||
♦9≈r╦ë°[╔├∙δ·Uëσ·☼☺▬¿D☼ └♀☺☼“└δ ╣ Äß$■☼“└fΩrH √]├UëσSf╛ @ f
|
||||
╗ ► f╣↑ f┴ß○fâ╩ⁿfâ┬♦f9╤t♫dgfï♦▬dgfë♦‼δΘgfì∟‼┐ ╕ @Ä└ï♫@2ï▬B2à
|
||||
λt+ë°S1█ΦS°[)╟Që┴┴ß○1÷&fï♦dgfë♥fâ├♦â╞♦âΘ♦uδYδ╤[]├·▲1└Ä└HÄ╪┐ ♣╛►♣
|
||||
&è♣Pè♦P&╞♣ ╞♦λ&Ç=λXê♦X&ê♣▼u@╕☺ Φ, ░¡μdΦ% ░╨μdΦ% Σ`PΦ↑ ░╤μdΦ◄ X♀☻
|
||||
μ`Φ○ ░«μdΦ☻ δúΣd¿☻u·├Σd¿☺t·├√├Uëσ▲╕ lÄ╪f╟♠ 0♥α♠ f╟♠ ♥╨♠ f╟♠ ►♥└
|
||||
♠ ╣ ☺f╕♥ 1÷fë♦f♣ ► â╞◘âΘ☺u∩▼f╟♠ 2 └♠ f╕ ≡♠ ☼“╪]├·☼☺▲02Φóλ☼ αf
|
||||
♪á☻ ☼“αf╣Ç └☼2f♪☺☺ ☼0☼☺▬¿D☼ └f♪♥ Çfâα√☼“└Ω≥I( ╕0 Ä╪ÄαÄΦ1╥δ
|
||||
HâΣ≡1φ1λΦ]• ┐ ► Φ{• ┐ ► ╛ ≡♠ ║ 2 Φ≡♣ ┐ùD ï4% 0 Φ╠√λλ┐ 0
|
||||
╛♦ Φτ√λλΘΓ• Hì§█• Φλ• Θ╤• É☼▼D ☺ ♣ @
|
||||
► ► ☺ ♠ @ ►
|
||||
► ► Qσtd♠
|
||||
► ♦ ♦ P♂ P♂@ P♂► ↑ ↑
|
||||
◘ É☼▼Ç ◘ ♦ ☺ OpenBSD É☼▼Ç PE då☻ k↕d╲
|
||||
≡ #☻♂☻♫☼ ╞¶ @ ► ► ♠ ♠
|
||||
@ ► ♥ ☺ ► ♥ ◘ ► ►
|
||||
ä← (
|
||||
► @ .text
|
||||
► ► ► ► ` p.data ►
|
||||
└ └É☼▼Ç ╧·φ■• ☺♥ ☻ ♣ ÿ☻ ☺ ↓ H __PAGEZE
|
||||
RO ↓ ÿ
|
||||
__TEXT @ • ♣ ☺
|
||||
__text __TEXT ►@ ► ► ♀
|
||||
♦ ↓ Φ __DATA @
|
||||
► • ♥ ☻ __data __DATA @
|
||||
► ♀ __bss __DATA
|
||||
0@ ► ♀ ☺ ← ↑
|
||||
B)→☺&¿◘ºB)→☺&¿◘º♣ ╕ ♦ * @
|
||||
|
||||
S↕@
|
||||
Éf.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä
|
||||
f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f☼▼ä
|
||||
ZAR╕ Hà└t◙Hà└t♣Θ»♦ Θ@☻ UHë╤HëσAWIë≈AVA╛ @ AUIë²ATA╝ ► SHë
|
||||
√Hâ∞↑Hâ{◘ ☼ä╕ ïS►Hë╪Hâ├↑λ╩t○Hâ{◘ uδδ♥Hë├L9#L☼C#Iü─λ☼ IüΣ ≡λλH
|
||||
ïC◘H♥♥H% ≡λλI9─snIïU◘Hà╥t↓Aâ}►☺u♠Iâ┼↑δΩIïE H☺╨L9αrεIïE L9αw◄H☺╨L
|
||||
9αv○Lìáλ☼ δ½Lë·Lë≈╛♥ HëM╚Φ6 LëΓHïM╚Iü╞ ► Hâ╩♥Iü─ ► Hë►δÇH
|
||||
â├↑Θ=λλλHâ─↑[A╲A]A^A_]├I╣ ≡λλλλ♥ Ië╚╣‘ Hë°λ╬H╙Φ%λ☺ â■λu♣Hì♦┬├
|
||||
Hì¶┬Hâ: u‼Iï H- ► Ië Hâ╚♥Hë☻Hï☻âΘ○L!╚Hë┬δ╛U╣ 2 ║ ≡♠ ╛♥ HëσSH
|
||||
ë√PΦÅλλλHâ ■☼☺;Z[]├1÷ë≡Hk└↑Hâ|•◘ t♦λ╞δεA╕☺ HìW↑A9≡r☺├UHëσATSLï
|
||||
◙HïZ◘Hë╤Dë└DïZ►DïR¶Aë─λ╚L;IΦt→☼►AΦLïa°HâΘ↑☼◄A↑Lëa(à└u▌δ♥DëαHk└↑A
|
||||
λ└Hâ┬↑H☺°Lë◘HëX◘DëX►DëP¶A9≡rí[A╲]├1└├UëσSç█[fÉ╠·⌠δ²Uëσâ∞◘U^ì~°j◘
|
||||
Y1└≤¬·☼☺^°☼♂δ≈Uëσ]├╞♣ª↔ ◘δ►HàλH☼Eτt•╞♣ö↔ Lc$$Lìl$◘NìtΣ↑╕“↕@ ┐
|
||||
► @ ╣P @ H)∙┴Θ♥≤H½1└â╔λLë≈≥H»IëλΘ╧ UHëσ┐ 0@ ╛°←@ ╣00@ HìA►Hë☺╟
|
||||
A◘ ♥ SV÷•◘u<÷• u!÷•♦u◄Iâ⁇ t!j j☺╛ⁿ←@ δ*j“j♦╛☻∟@ δ▼j0j ╛∙←@ δ¶j*
|
||||
j►╛λ←@ δ○jEj◘╛♦∟@ ╣q↓@ XH½XH☺╚H½W┐↑0@ Iâ╔λ╗(0@ H9▀s51╔1╥¼Ië└Aâα⌂
|
||||
I╙αâ┴•L○┬ä└xδ¿@t○Lë╚H╙αH○┬Hë╨Hâ⁇ H☼E•H½δ╞_^[╔├╕* ├HâΣ≡1φ╗ @ Φ
|
||||
!λλλâ♪┴▼ ☺╕◘ @ ╣◘ @ H9┴t♀PQλ►YXHâ└◘δ∩ÉLëτLëεLë≥Φ╣λλλë╟Φ UHëσ
|
||||
ATAëⁿ1λPΦr DëτΦö♠ 1÷1╥UHëσAW╣00@ Ië╧Iï•IïO◘Hà╔t∟HâΘ↑Hë¶◘Hët◘◘
|
||||
Hë|◘►IëO◘1└A_]├╣ Hà╔t≥PWVj!_j►^λ╤^_YHà└t▀I╟└ ♥ Ië•Jë♀ Lë┴δ┤U
|
||||
HëσAVAUATHï5α← Ië■Ië⌠j YH¡HÆH¡HùH¡Hà└t↑Mà÷δ♣L9≥u♫VQQλ╨YY^1└HëF°
|
||||
âΘ☺u╘H¡Hà└t◄Mà÷t○PLëτΦfδ┐λ^δ╢A╲Mà÷u←╕► @ ╣► @ HâΦ◘H9╚|◘PQλ►YXδ∩A
|
||||
]A^]├╠U╣ ◘ 1└HëσAWAVAUATSHü∞Hα Hëà└▼λλHëà╚▼λλλ§C♂ Hâ─ à└uGHâ∞
|
||||
H╟┴⌠λλλλ§“♂ Hâ─↑A╕♠ Lìì╨⌂λλj Hë┴║⌐→@ Hâ∞ λ§♪♂ XZ╣☺ λ§╨◙
|
||||
Hâ─ Hâ∞ j♦Xë♣»→ λ§╔◙ Ië─λ§╚◙ LëτHâ─ A╕ ☻ Hìì╨/λλ║λ⁇ Hì╡╤⁇λλ
|
||||
Ië┼Φ╙☺ Aë─1└Hïì╨/λλH☺┴è◄ä╥t♪Ç·╲u♥╞☺/Hλ└δπA☼╖E f=λ╫w♪ëà╝▼λλ╕☺
|
||||
δ☼Hì╡╝▼λλLë∩Φ0♦ ë└Hìì╨⌂λλE1└1█H☺└Ië╦LìU╬A╛²⌂ IìT♣ Hì╡╝▼λλâ╜╝▼λ
|
||||
λ ☼äÅ Iλ└Iü°λ☺ w↕L9╤Hë╪H☼B┴Jëä┼╚▼λλDïì╝▼λλIc┴Aâ∙⌂v◘Dë╧ΦÉ♥ L9
|
||||
╤s♀Hλ┴êAλH┴Φ◘u∩☼╖☻f=λ╫w♪ëà╝▼λλ╕☺ δ◘Hë╫Φö♥ ë└H☺└H☺┬Eà╔u¼Hë╚L)╪
|
||||
H=²⌂ I☼G╞╞ä♣╨⌂λλ ΘdλλλL9╤s♠╞☺ Hλ┴L)┘╕■⌂ Lì╡╨▼λλHü∙■⌂ Lì╜└▼λλH
|
||||
☼G╚Iü°λ☺ ╕λ☺ L☼G└Hâ∞ ╞ä♪╨⌂λλ LëΘLì¡╨/λλJ╟ä┼╨▼λλ λ§↔○ Θtⁿλλ
|
||||
Hë·Hï⁇☼╖•f=λ╫w◙ëB↑╕☺ δ○Hìr↑Φ▀☻ ë└H☺└H☺☻├Hë·Hc╞ë≈LïB►â■⌂v♣Φì☻
|
||||
HïJ◘I9╚v►Hìq☺Hër◘ê☺H┴Φ◘uτ├UHì♦▬Ië╙Më┬HëσAWI┐ & ☺ AVAUIë⌡ATS1
|
||||
█Hâ∞8Hë}░Hì}░HëM¿Hëu╕HëE└Φbλλλâ}╚ t↔ïE╚à└t▬â° w╲I☼ú╟sVHì}░ΦAλλλδ
|
||||
π1÷Hì}░Φ_λλλMà█t↨HïE╕Iλ╦L)ΦL9╪I☼G├A╞D♣ Mà╥☼äf☺ Iλ╩HïE¿I9┌L☼G╙J
|
||||
╟♦╨ ΘK☺ Hλ├L9╙s§HïE╕H;E└r☻1└HïU¿HëD┌°E1÷ïu╚à÷☼ä►☺ Eä÷u¶â■ w
|
||||
☼I☼ú≈☼âσ Θ≈ â■“t○â■╲☼à╥ E1Σâ}╚╲u♫Hì}░Iλ─Φì■λλδ∞E1╔â}╚“u♫Hì
|
||||
}░Φy■λλIλ┴δ∞LëαMà╔u↓Iλ╠IâⁿλtÅ╛╲ Hì}░ΦÇ■λλδτHâ°☺v∟╛╲ Hì}░HëEá
|
||||
Φf■λλHïEáHâΦ☻δ▐AÇΣ☺t↨╛“ Hì}░ΦH■λλIλ╔☼ä@λλλAÇ■☺A╛♥ Iâ┘ Mìa☺M9
|
||||
⌠r¶╛“ Hì}░Iâ╞♥Φ▬■λλδτ1╥╣♥ Lë╚H≈±Hà╥A☼ö╞Θⁿ■λλHì}░Φ≥²λλHì}░Φ╛²
|
||||
λλΘσ■λλ1÷Hì}░Φ┘²λλΘG■λλHâ─8ë╪[A╲A]A^A_]├╠Hì♣╪↓ ├☼┐└à└x←Ië╩☼♣H=☺
|
||||
≡λλs☺├≈╪ë♣║↓ jλX∙├ï♣⌂▬ δφH┴Φ0δ•H┴Φ ☼╖└f=λ☼sσIë╩☼♣r╙├Aë├┴Φ►%λ☼
|
||||
A┴δ∟A┴π↑D○╪δ┌QRëλ1└âλ⌂v“☼╜╧║┐→@ ïLJ≥ë·┴∩♠ÇΓ⁇♀Ç◘╨H┴α◘■╔u∞◘ΦH○°ZY
|
||||
├U1└HëσWVSQRë┬ë├λ└☼╖¶Wë╤füß ⁿfü∙ ▄tΦfü∙ ╪t♦ë▬δ,☼╖♦Gë┴füß ⁿfü∙ ▄t
|
||||
♂╟♠²λ â╚λδ☼┴Γ◙ìä☻ $áⁿë♠ìC☻ZY[^_]├f☼▼D Éâ♪▄↑ ♦÷♣ë§ ♦t♪@☼╢╧λ§ì
|
||||
♣ δ°╠ï♣ö§ ☼♣·☼☺∟%Ü→@ ⌠δ² f☼▼D Énodll◙ KernelBase.dll ☺
|
||||
└☺└☺└☺└☻α☻α☻α☻α☻α♥≡♥≡♥≡♥≡♥≡♦°♦°♦°♦°♦°♣ⁿ♣ⁿ♣ⁿ♣ⁿ♣ⁿ♣ⁿÉÉ☼▼D ⁇♣ExitPr
|
||||
ocess æ☺FreeEnvironmentStringsW ╜☺GetCommandLineW ‼☻GetEnvironme
|
||||
ntStringsW ╘☻GetStdHandle ╫♣SetDefaultDllDirectories ▼•WriteF
|
||||
ile ░← ░→ ► ☼▼@ °→ ♠←
|
||||
← 2← L← ╲← x← É☼▼Ç É╬ ☺&τ☺╬
|
||||
☺☺⌂╬ üÇÇ►f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼
|
||||
ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä
|
||||
f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.
|
||||
☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä
|
||||
f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä
|
||||
f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼
|
||||
ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä
|
||||
f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.
|
||||
☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä
|
||||
f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä
|
||||
f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼
|
||||
ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä
|
||||
f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.
|
||||
☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä
|
||||
f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä
|
||||
f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä f.☼▼ä ☼▼@
|
||||
@ °→ ♠← ← 2← L← ╲←
|
||||
x←
|
||||
|
||||
See also `build/objdump -xd o/tiny/examples/life.com.dbg | less` to view
|
||||
assembly and the linker glue in [ape/ape.lds] that makes it all possible
|
||||
|
||||
## Licensing
|
||||
|
||||
Cosmopolitan is Free Software licensed under the GPLv2. The build config
|
||||
**will embed all linked sources inside your binaries** so the compliance
|
||||
is easy while facilitating trust and transparency similar to JavaScript.
|
||||
You can audit your source filesystem using ZIP GUIs e.g. Win10, InfoZip.
|
||||
That works easiest by changing the filename extension from .com to .zip.
|
||||
|
||||
### Commercial Support
|
||||
|
||||
If you want to be able to distribute binaries in binary only form, then
|
||||
please send $1,000 to Justine Tunney <jtunney@gmail.com> on PayPal, for
|
||||
a license lasting 1 year. This README will be updated in the event that
|
||||
this needs to change. Please reach out if there's anything you need.
|
||||
|
||||
## Contributing
|
||||
|
||||
We'd love to accept your patches! Before we can take them, we have to
|
||||
jump through one legal hurdle. Please write an email to Justine Tunney
|
||||
<jtunney@gmail.com> saying you agree to give her copyright ownership to
|
||||
any changes you contribute to Cosmopolitan. We need to do that in order
|
||||
to dual license Cosmopolitan. Otherwise we can't create incentives that
|
||||
encourage corporations to share their source code with the community.
|
||||
|
||||
## Volunteering
|
||||
|
||||
We also need volunteers who can help us further stabilize System Five's
|
||||
application binary interface. See our ABI scripts [libc/sysv/consts.sh]
|
||||
and [libc/sysv/syscalls.sh]. Magic numbers are usually stabler than API
|
||||
interfaces cf. NPM but we should ideally have fewer of them, similar to
|
||||
how SI has sought to have fewer defining physics constants.
|
||||
|
||||
## About
|
||||
|
||||
Cosmopolitan mostly stands on the shoulders of giants and has few novel
|
||||
ideas, aside from taking care of low-level build system toil, so coding
|
||||
can become more beautifully pleasant.
|
||||
|
||||
Cosmopolitan is maintained by Justine Tunney, who previously worked on
|
||||
projects like [TensorFlow], [Operation Rosehub], [Nomulus], and Google's
|
||||
tape backups SRE team. She's also helped activists by operating the
|
||||
[Occupy Wall Street] website. Justine Tunney currently isn't on the
|
||||
payroll of any company. She's been focusing on Cosmopolitan because she
|
||||
wants to give back to Free Software which helped her be successful. See
|
||||
her [LinkedIn] profile for further details on her professional history.
|
||||
|
||||
|
||||
[LinkedIn]: https://www.linkedin.com/in/jtunney
|
||||
[Nomulus]: https://github.com/google/nomulus
|
||||
[Occupy Wall Street]: https://www.newyorker.com/magazine/2011/11/28/pre-occupied
|
||||
[Operation Rosehub]: https://opensource.googleblog.com/2017/03/operation-rosehub.html
|
||||
[TensorFlow]: https://github.com/tensorflow/tensorflow
|
||||
[ansitrinsics library]: libc/intrin
|
||||
[ape/ape.lds]: ape/ape.lds
|
||||
[dsp/scale/cdecimate2xuint8x8.c]: dsp/scale/cdecimate2xuint8x8.c
|
||||
[examples/life.c]: examples/life.c
|
||||
[libc/nexgen32e/kcpuids.S]: libc/nexgen32e/kcpuids.S
|
||||
[libc/nexgen32e/memcpy.S]: libc/nexgen32e/memcpy.S
|
||||
[libc/nexgen32e/x86feature.h]: libc/nexgen32e/x86feature.h
|
||||
[libc/sysv/consts.sh]: libc/sysv/consts.sh
|
||||
[libc/sysv/syscalls.sh]: libc/sysv/syscalls.sh
|
||||
[third_party/xed/x86ild.greg.c]: third_party/xed/x86ild.greg.c
|
||||
[tool/build/package.c]: tool/build/package.c
|
||||
[tool/emacs/cosmo-stuff.el]: tool/emacs/cosmo-stuff.el
|
||||
[tool/viz/lib/ycbcr2rgb3.c]: tool/viz/lib/ycbcr2rgb3.c
|
||||
| Platform | Min Version | Circa |
|
||||
| :--- | ---: | ---: |
|
||||
| AMD | K8 Venus | 2005 |
|
||||
| Intel | Core | 2006 |
|
||||
| New Technology | Vista | 2006 |
|
||||
| GNU/Systemd | 2.6.18 | 2007 |
|
||||
| XNU's Not UNIX! | 15.6 | 2018 |
|
||||
| FreeBSD | 12 | 2018 |
|
||||
| OpenBSD | 6.4 | 2018 |
|
||||
| NetBSD | 9.1 | 2020 |
|
||||
| GNU Make | 3.80 | 2010 |
|
||||
+243
-240
@@ -3,19 +3,18 @@
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╠──────────────────────────────────────────────────────────────────────────────╣
|
||||
│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░█▀█░█▀█░▀█▀░█░█░█▀█░█░░░█░░░█░█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
@@ -37,7 +36,7 @@
|
||||
entails two steps: (1) create a .com.dbg binary w/ Linux toolchain and
|
||||
then (2) unwrap the .com binary embedded within:
|
||||
|
||||
objcopy -SO binary input.com.dbg output.com
|
||||
objcopy -S -O binary input.com.dbg output.com
|
||||
|
||||
Both executables will work fine, but only the .com format is portable.
|
||||
|
||||
@@ -175,28 +174,14 @@
|
||||
Until then, we can build for those platforms using Linux or WSL. */
|
||||
|
||||
#ifdef __LINKER__
|
||||
#include "ape/macros.h"
|
||||
#include "ape/config.h"
|
||||
#include "libc/nt/pedef.h"
|
||||
#include "ape/macros.internal.h"
|
||||
#include "ape/relocations.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/nt/pedef.internal.h"
|
||||
#include "libc/zip.h"
|
||||
|
||||
ENTRY(_start)
|
||||
|
||||
/* Plans real memory solution at linktime. */
|
||||
MEMORY {
|
||||
PageZero : org = 0x0000000000000000, len = 0x0000000000001000
|
||||
RealBss : org = XLM_BASE_REAL, len = XLM_SIZE
|
||||
RealProgram : org = IMAGE_BASE_REAL, len = 0x0000000000010000 - IMAGE_BASE_REAL
|
||||
RealScratch : org = REAL_SCRATCH_AREA, len = REAL_STACK_FRAME - REAL_SCRATCH_AREA
|
||||
RealStack : org = REAL_STACK_FRAME, len = 0x0000000000010000
|
||||
EbdaMemory : org = 0x0000000000080000, len = 0x0000000000020000
|
||||
VideoMemory : org = 0x00000000000a0000, len = 0x0000000000020000
|
||||
Romz : org = 0x00000000000c0000, len = 0x0000000000030000
|
||||
BiosMemory : org = 0x00000000000f0000, len = 0x0000000000010000
|
||||
SmallCode : org = IMAGE_BASE_PHYSICAL, len = 0x0000000040000000 - IMAGE_BASE_PHYSICAL
|
||||
ZipData : org = 0x0000000040000000, len = 0x0000000040000000
|
||||
}
|
||||
|
||||
PHDRS {
|
||||
Head PT_LOAD FLAGS(5);
|
||||
Rom PT_LOAD FLAGS(5);
|
||||
@@ -211,43 +196,43 @@ SECTIONS {
|
||||
/*BEGIN: linux addressability guarantee */
|
||||
/*BEGIN: bsd addressability guarantee */
|
||||
|
||||
.head SEGMENT_START("text-segment", IMAGE_BASE_VIRTUAL) : {
|
||||
.head SEGMENT_START("text-segment", IMAGE_BASE_VIRTUAL) : AT(IMAGE_BASE_REAL) {
|
||||
HIDDEN(_base = .);
|
||||
|
||||
/* Real Mode */
|
||||
KEEP(*(.head))
|
||||
. += 1;
|
||||
KEEP(*(.apesh))
|
||||
KEEP(*(.head2))
|
||||
KEEP(*(.text.head))
|
||||
|
||||
/* Executable & Linkable Format */
|
||||
. = ALIGN(. != 0 ? __SIZEOF_POINTER__ : 1);
|
||||
. = ALIGN(__SIZEOF_POINTER__);
|
||||
HIDDEN(ape_phdrs = .);
|
||||
KEEP(*(.elf.phdrs))
|
||||
HIDDEN(.Lape.phdrs.end = .);
|
||||
. += 1;
|
||||
HIDDEN(ape_phdrs_end = .);
|
||||
|
||||
/* OpenBSD */
|
||||
. = ALIGN(. != 0 ? __SIZEOF_POINTER__ : 1);
|
||||
HIDDEN(.Lape.note = .);
|
||||
. = ALIGN(__SIZEOF_POINTER__);
|
||||
HIDDEN(ape_note = .);
|
||||
KEEP(*(.note.openbsd.ident))
|
||||
HIDDEN(.Lape.note.end = .);
|
||||
. += 1;
|
||||
KEEP(*(.note.netbsd.ident))
|
||||
HIDDEN(ape_note_end = .);
|
||||
|
||||
/* Portable Executable */
|
||||
KEEP(*(.pe.header))
|
||||
HIDDEN(.Lape.pe.sections = .);
|
||||
HIDDEN(ape_pe_sections = .);
|
||||
KEEP(*(.pe.sections))
|
||||
HIDDEN(.Lape.pe.sections_end = .);
|
||||
. += 1;
|
||||
HIDDEN(ape_pe_sections_end = .);
|
||||
|
||||
/* Mach-O */
|
||||
KEEP(*(.macho))
|
||||
. = ALIGN(__SIZEOF_POINTER__);
|
||||
HIDDEN(.Lape.macho.end = .);
|
||||
. += 1;
|
||||
HIDDEN(ape_macho_end = .);
|
||||
|
||||
KEEP(*(.ape.pad.head))
|
||||
. = ALIGN(4096); /* alignments only mandatory when impossible otherwise */
|
||||
. = ALIGN(SupportsWindows() || SupportsMetal() ? PAGESIZE : 16);
|
||||
HIDDEN(_ehead = .);
|
||||
} AT>SmallCode :Head
|
||||
} :Head
|
||||
|
||||
/*BEGIN: nt addressability guarantee */
|
||||
|
||||
@@ -255,9 +240,8 @@ SECTIONS {
|
||||
/* Code that needs to be addressable in Real Mode */
|
||||
*(.text.real)
|
||||
KEEP(*(SORT_BY_NAME(.sort.text.real.*)))
|
||||
*(.rodata.real)
|
||||
KEEP(*(SORT_BY_NAME(.sort.rodata.real.*)))
|
||||
HIDDEN(_ereal = .);
|
||||
. += 1;
|
||||
|
||||
/*END: realmode addressability guarantee */
|
||||
|
||||
@@ -265,7 +249,7 @@ SECTIONS {
|
||||
*(.start)
|
||||
KEEP(*(.initprologue))
|
||||
KEEP(*(SORT_BY_NAME(.init.*)))
|
||||
KEEP(*(SORT_NONE(.init)))
|
||||
KEEP(*(.init))
|
||||
KEEP(*(.initepilogue))
|
||||
KEEP(*(.pltprologue))
|
||||
*(.plt)
|
||||
@@ -289,44 +273,26 @@ SECTIONS {
|
||||
*(.text .stub .text.*)
|
||||
KEEP(*(SORT_BY_NAME(.sort.text.*)))
|
||||
|
||||
/* Won't support NX bit DRM for tiny executables */
|
||||
HIDDEN(.Lape.piro.align = ABSOLUTE(. > APE_PIRO_THRESHOLD ? 0x1000 : 8));
|
||||
|
||||
/* Code that musn't be mapped in production */
|
||||
KEEP(*(.ape.pad.test));
|
||||
. = ALIGN(.Lape.piro.align);
|
||||
HIDDEN(__test_start = .);
|
||||
*(.test.unlikely)
|
||||
*(.test .test.*)
|
||||
|
||||
/* Privileged code invulnerable to magic */
|
||||
KEEP(*(.ape.pad.privileged));
|
||||
. = ALIGN(.Lape.piro.align);
|
||||
. += . > 0 ? 1 : 0;
|
||||
HIDDEN(__privileged_start = .);
|
||||
HIDDEN(__test_end = .);
|
||||
. += 1;
|
||||
. += . > 0 ? 1 : 0;
|
||||
*(.privileged)
|
||||
HIDDEN(__privileged_end = .);
|
||||
. += . > 0 ? 1 : 0;
|
||||
|
||||
/*BEGIN: Read Only Data */
|
||||
|
||||
KEEP(*(.ape.pad.rodata));
|
||||
. = ALIGN(.Lape.piro.align);
|
||||
. += 1;
|
||||
|
||||
/* Nonspecific Read-Only Data */
|
||||
*(.rodata .rodata.*)
|
||||
. += 1;
|
||||
|
||||
/* Undefined Behavior Sanitizer Types */
|
||||
HIDDEN(__ubsan_types_start = .);
|
||||
*(.ubsan.types)
|
||||
HIDDEN(__ubsan_types_end = .);
|
||||
. += 1;
|
||||
|
||||
/* Undefined Behavior Sanitizer Data */
|
||||
HIDDEN(__ubsan_data_start = .);
|
||||
*(.ubsan.data)
|
||||
HIDDEN(__ubsan_data_end = .);
|
||||
|
||||
/* Unit Test & Fixture Registry */
|
||||
|
||||
@@ -342,7 +308,22 @@ SECTIONS {
|
||||
/* Windows DLL Import Directory */
|
||||
KEEP(*(.idata.ro));
|
||||
KEEP(*(SORT_BY_NAME(.idata.ro.*)))
|
||||
. += 1;
|
||||
|
||||
. = ALIGN(__SIZEOF_POINTER__);
|
||||
PROVIDE_HIDDEN(__init_array_start = .);
|
||||
KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*)
|
||||
SORT_BY_INIT_PRIORITY(.ctors.*)))
|
||||
KEEP(*(.ctors))
|
||||
KEEP(*(.init_array))
|
||||
KEEP(*(.preinit_array))
|
||||
PROVIDE_HIDDEN(__init_array_end = .);
|
||||
|
||||
. = ALIGN(__SIZEOF_POINTER__);
|
||||
PROVIDE_HIDDEN(__fini_array_start = .);
|
||||
KEEP(*(SORT_BY_INIT_PRIORITY(.fini_array.*)
|
||||
SORT_BY_INIT_PRIORITY(.dtors.*)))
|
||||
KEEP(*(.dtors))
|
||||
PROVIDE_HIDDEN(__fini_array_end = .);
|
||||
|
||||
/* Encoded Data Structures w/ Linear Initialization Order */
|
||||
KEEP(*(.initroprologue))
|
||||
@@ -351,13 +332,12 @@ SECTIONS {
|
||||
KEEP(*(SORT_BY_NAME(.sort.rodata.*)))
|
||||
|
||||
KEEP(*(.ape.pad.text))
|
||||
HIDDEN(.Lape.data.align = ABSOLUTE(PAGESIZE));
|
||||
. = ALIGN(.Lape.data.align);
|
||||
. = ALIGN(PAGESIZE);
|
||||
HIDDEN(_etext = .);
|
||||
PROVIDE_HIDDEN(etext = .);
|
||||
/*END: Read Only Data (only needed for initialization) */
|
||||
/*END: Read Only Data */
|
||||
} AT>SmallCode :Rom
|
||||
} :Rom
|
||||
|
||||
.data . : {
|
||||
/*BEGIN: Read/Write Data */
|
||||
@@ -375,43 +355,34 @@ SECTIONS {
|
||||
KEEP(*(.gotpltepilogue))
|
||||
|
||||
/*BEGIN: Post-Initialization Read-Only */
|
||||
. = ALIGN(.Lape.piro.align);
|
||||
HIDDEN(__piro_start = .);
|
||||
|
||||
QUAD(IMAGE_BASE_VIRTUAL);
|
||||
|
||||
PROVIDE_HIDDEN(__init_array_start = .);
|
||||
KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*)
|
||||
SORT_BY_INIT_PRIORITY(.ctors.*)))
|
||||
KEEP(*(SORT_NONE(.ctors)))
|
||||
KEEP(*(SORT_NONE(.init_array)))
|
||||
KEEP(*(SORT_NONE(.preinit_array)))
|
||||
PROVIDE_HIDDEN(__init_array_end = .);
|
||||
|
||||
. += 1;
|
||||
. = ALIGN(__SIZEOF_POINTER__);
|
||||
PROVIDE_HIDDEN(__fini_array_start = .);
|
||||
KEEP(*(SORT_BY_INIT_PRIORITY(.fini_array.*)
|
||||
SORT_BY_INIT_PRIORITY(.dtors.*)))
|
||||
KEEP(*(SORT_NONE(.dtors)))
|
||||
PROVIDE_HIDDEN(__fini_array_end = .);
|
||||
|
||||
KEEP(*(SORT_BY_NAME(.piro.relo.sort.*)))
|
||||
PROVIDE_HIDDEN(__relo_end = .);
|
||||
. = ALIGN(__SIZEOF_POINTER__);
|
||||
KEEP(*(SORT_BY_NAME(.piro.data.sort.*)))
|
||||
KEEP(*(.piro.pad.data))
|
||||
. = ALIGN(.Lape.data.align);
|
||||
. = ALIGN(PAGESIZE);
|
||||
HIDDEN(_edata = .);
|
||||
PROVIDE_HIDDEN(edata = .);
|
||||
} AT>SmallCode :Ram
|
||||
} :Ram
|
||||
|
||||
.bss . : {
|
||||
/*END: file content that's loaded by o/s */
|
||||
/*BEGIN: bss memory void */
|
||||
|
||||
.zip . : {
|
||||
KEEP(*(SORT_BY_NAME(.zip.*)))
|
||||
HIDDEN(_ezip = .);
|
||||
}
|
||||
|
||||
/*END: file content */
|
||||
/*BEGIN: bss memory that's addressable */
|
||||
|
||||
.bss ALIGN(64) : {
|
||||
KEEP(*(SORT_BY_NAME(.piro.bss.init.*)))
|
||||
*(.piro.bss)
|
||||
KEEP(*(SORT_BY_NAME(.piro.bss.sort.*)))
|
||||
. += 1;
|
||||
. = ALIGN(.Lape.piro.align);
|
||||
HIDDEN(__piro_end = .);
|
||||
. += . > 0 ? 1 : 0;
|
||||
/*END: Post-Initialization Read-Only */
|
||||
|
||||
/* Statically Allocated Empty Space */
|
||||
@@ -421,20 +392,19 @@ SECTIONS {
|
||||
|
||||
KEEP(*(SORT_BY_NAME(.sort.bss.*)))
|
||||
|
||||
/* eXtreme Low Memory w/ Userspace Remapping */
|
||||
. = ALIGN(0x1000);
|
||||
*(.xlm)
|
||||
. = ALIGN(0x1000);
|
||||
|
||||
. = ALIGN(FRAMESIZE); /* for brk()/sbrk() allocation */
|
||||
HIDDEN(_end = .);
|
||||
PROVIDE_HIDDEN(end = .);
|
||||
} AT>SmallCode :Ram
|
||||
}
|
||||
|
||||
/*END: nt addressability guarantee */
|
||||
/*END: bsd addressability guarantee */
|
||||
/*END: linux addressability guarantee */
|
||||
/*END: xnu addressability guarantee */
|
||||
|
||||
.shstrtab : { *(.shstrtab) }
|
||||
.strtab : { *(.strtab) }
|
||||
.symtab : { *(.symtab) }
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
@@ -467,93 +437,122 @@ SECTIONS {
|
||||
.GCC.command.line 0 : { *(.GCC.command.line) }
|
||||
|
||||
/DISCARD/ : {
|
||||
*(__mcount_loc)
|
||||
*(.discard)
|
||||
*(.yoink)
|
||||
*(.*)
|
||||
}
|
||||
}
|
||||
|
||||
PFSTUB8(.Lape.elf.entry, _start);
|
||||
PFSTUB8(.Lape.elf.phoff, RVA(ape.phdrs));
|
||||
PFSTUB8(.Lape.elf.shoff, 0);
|
||||
PFSTUB4(.Lape.elf.phnum, (.Lape.phdrs.end - ape.phdrs) / 56);
|
||||
PFSTUB4(.Lape.elf.shnum, 0);
|
||||
PFSTUB4(.Lape.elf.shstrndx, 0);
|
||||
SHSTUB2(.Lape.macho.dd.skip, RVA(ape.macho) / 8);
|
||||
SHSTUB2(.Lape.macho.dd.count, (.Lape.macho.end - ape.macho) / 8);
|
||||
PFSTUB4(.Lape.pe.offset, ape.pe - ape.mz);
|
||||
PFSTUB8(ape_elf_entry, _start);
|
||||
PFSTUB8(ape_elf_phoff, RVA(ape_phdrs));
|
||||
PFSTUB8(ape_elf_shoff, 0);
|
||||
PFSTUB4(ape_elf_phnum, (ape_phdrs_end - ape_phdrs) / 56);
|
||||
PFSTUB4(ape_elf_shnum, 0);
|
||||
PFSTUB4(ape_elf_shstrndx, 0);
|
||||
|
||||
HIDDEN(.Lape.pe.optsz = .Lape.pe.sections - (ape.pe + 24));
|
||||
HIDDEN(.Lape.pe.shnum = (.Lape.pe.sections_end - .Lape.pe.sections) / 40);
|
||||
HIDDEN(.Lidata.idtsize = idata.idtend - idata.idt);
|
||||
HIDDEN(.Lidata.iatsize = idata.iatend - idata.iat);
|
||||
HIDDEN(__privileged_addr = ROUNDDOWN(__privileged_start, PAGESIZE));
|
||||
HIDDEN(__privileged_size = (ROUNDUP(__privileged_end, PAGESIZE) -
|
||||
ROUNDDOWN(__privileged_start, PAGESIZE)));
|
||||
|
||||
HIDDEN(.Lape.rom.offset = 0);
|
||||
HIDDEN(.Lape.rom.vaddr = ADDR(.head));
|
||||
HIDDEN(.Lape.rom.paddr = LOADADDR(.head));
|
||||
HIDDEN(.Lape.rom.filesz = LOADADDR(.data) - .Lape.rom.paddr);
|
||||
HIDDEN(.Lape.rom.memsz = ADDR(.data) - ADDR(.head));
|
||||
HIDDEN(.Lape.rom.align = 0x1000);
|
||||
HIDDEN(.Lape.rom.rva = RVA(.Lape.rom.vaddr));
|
||||
HIDDEN(ape_rom_offset = 0);
|
||||
HIDDEN(ape_rom_vaddr = ADDR(.head));
|
||||
HIDDEN(ape_rom_paddr = LOADADDR(.head));
|
||||
HIDDEN(ape_rom_filesz = LOADADDR(.data) - ape_rom_paddr);
|
||||
HIDDEN(ape_rom_memsz = ADDR(.data) - ADDR(.head));
|
||||
HIDDEN(ape_rom_align = PAGESIZE);
|
||||
HIDDEN(ape_rom_rva = RVA(ape_rom_vaddr));
|
||||
|
||||
HIDDEN(.Lape.ram.offset = .Lape.rom.offset + .Lape.rom.filesz);
|
||||
HIDDEN(.Lape.ram.vaddr = ADDR(.data));
|
||||
HIDDEN(.Lape.ram.paddr = LOADADDR(.data));
|
||||
HIDDEN(.Lape.ram.filesz = LOADADDR(.bss) - LOADADDR(.data));
|
||||
HIDDEN(.Lape.ram.memsz = ADDR(.bss) + SIZEOF(.bss) - .Lape.ram.vaddr);
|
||||
HIDDEN(.Lape.ram.align = 0x1000);
|
||||
HIDDEN(.Lape.ram.rva = RVA(.Lape.ram.vaddr));
|
||||
HIDDEN(ape_ram_offset = ape_rom_offset + ape_rom_filesz);
|
||||
HIDDEN(ape_ram_vaddr = ADDR(.data));
|
||||
HIDDEN(ape_ram_paddr = LOADADDR(.data));
|
||||
HIDDEN(ape_ram_filesz = SIZEOF(.data));
|
||||
HIDDEN(ape_ram_memsz = ADDR(.bss) + SIZEOF(.bss) - ape_ram_vaddr);
|
||||
HIDDEN(ape_ram_align = PAGESIZE);
|
||||
HIDDEN(ape_ram_rva = RVA(ape_ram_vaddr));
|
||||
|
||||
HIDDEN(.Lape.note.offset = .Lape.rom.offset + (.Lape.note - .Lape.rom.vaddr));
|
||||
HIDDEN(.Lape.note.vaddr = .Lape.note);
|
||||
HIDDEN(.Lape.note.paddr = .Lape.rom.paddr + .Lape.note.offset);
|
||||
HIDDEN(.Lape.note.filesz = .Lape.note.end - .Lape.note);
|
||||
HIDDEN(.Lape.note.memsz = .Lape.note.filesz);
|
||||
HIDDEN(.Lape.note.align = __SIZEOF_POINTER__);
|
||||
HIDDEN(ape_stack_offset = ape_ram_offset + ape_ram_filesz);
|
||||
HIDDEN(ape_stack_vaddr = 0x700000000000 - STACKSIZE);
|
||||
HIDDEN(ape_stack_paddr = ape_ram_paddr + ape_ram_filesz);
|
||||
HIDDEN(ape_stack_filesz = 0);
|
||||
HIDDEN(ape_stack_memsz = STACKSIZE);
|
||||
HIDDEN(ape_stack_align = 16);
|
||||
|
||||
HIDDEN(.Lape.text.offset = .Lape.rom.offset + LOADADDR(.text) - .Lape.rom.paddr);
|
||||
HIDDEN(.Lape.text.paddr = LOADADDR(.text));
|
||||
HIDDEN(.Lape.text.vaddr = ADDR(.text));
|
||||
HIDDEN(.Lape.text.filesz = SIZEOF(.text));
|
||||
HIDDEN(.Lape.text.memsz = SIZEOF(.text));
|
||||
HIDDEN(.Lape.text.align = 4096);
|
||||
HIDDEN(.Lape.text.rva = RVA(.Lape.text.vaddr));
|
||||
HIDDEN(ape_note_offset = ape_rom_offset + (ape_note - ape_rom_vaddr));
|
||||
HIDDEN(ape_note_vaddr = ape_note);
|
||||
HIDDEN(ape_note_paddr = ape_rom_paddr + ape_note_offset);
|
||||
HIDDEN(ape_note_filesz = ape_note_end - ape_note);
|
||||
HIDDEN(ape_note_memsz = ape_note_filesz);
|
||||
HIDDEN(ape_note_align = __SIZEOF_POINTER__);
|
||||
|
||||
HIDDEN(.Lape.data.offset = .Lape.ram.offset + LOADADDR(.data) - .Lape.ram.paddr);
|
||||
HIDDEN(.Lape.data.paddr = LOADADDR(.data));
|
||||
HIDDEN(.Lape.data.vaddr = ADDR(.data));
|
||||
HIDDEN(.Lape.data.filesz = SIZEOF(.data));
|
||||
HIDDEN(.Lape.data.memsz = SIZEOF(.data));
|
||||
HIDDEN(.Lape.data.align = 0x1000);
|
||||
HIDDEN(.Lape.data.rva = RVA(.Lape.data.vaddr));
|
||||
HIDDEN(ape_text_offset = ape_rom_offset + LOADADDR(.text) - ape_rom_paddr);
|
||||
HIDDEN(ape_text_paddr = LOADADDR(.text));
|
||||
HIDDEN(ape_text_vaddr = ADDR(.text));
|
||||
HIDDEN(ape_text_filesz = SIZEOF(.text));
|
||||
HIDDEN(ape_text_memsz = SIZEOF(.text));
|
||||
HIDDEN(ape_text_align = PAGESIZE);
|
||||
HIDDEN(ape_text_rva = RVA(ape_text_vaddr));
|
||||
|
||||
HIDDEN(.Lape.bss.offset = .Lape.ram.offset + LOADADDR(.bss) - .Lape.ram.paddr);
|
||||
HIDDEN(.Lape.bss.paddr = LOADADDR(.bss));
|
||||
HIDDEN(.Lape.bss.vaddr = ADDR(.bss));
|
||||
HIDDEN(.Lape.bss.filesz = 0);
|
||||
HIDDEN(.Lape.bss.memsz = SIZEOF(.bss));
|
||||
HIDDEN(.Lape.bss.align = .Lape.data.align);
|
||||
HIDDEN(ape_data_offset = ape_ram_offset + LOADADDR(.data) - ape_ram_paddr);
|
||||
HIDDEN(ape_data_paddr = LOADADDR(.data));
|
||||
HIDDEN(ape_data_vaddr = ADDR(.data));
|
||||
HIDDEN(ape_data_filesz = SIZEOF(.data));
|
||||
HIDDEN(ape_data_memsz = SIZEOF(.data));
|
||||
HIDDEN(ape_data_align = PAGESIZE);
|
||||
HIDDEN(ape_data_rva = RVA(ape_data_vaddr));
|
||||
|
||||
/* Program Loader Auto-Tune */
|
||||
HIDDEN(ape_bss_offset = ape_ram_offset + LOADADDR(.bss) - ape_ram_paddr);
|
||||
HIDDEN(ape_bss_paddr = LOADADDR(.bss));
|
||||
HIDDEN(ape_bss_vaddr = ADDR(.bss));
|
||||
HIDDEN(ape_bss_filesz = 0);
|
||||
HIDDEN(ape_bss_memsz = SIZEOF(.bss));
|
||||
HIDDEN(ape_bss_align = PAGESIZE);
|
||||
|
||||
#if SupportsXnu()
|
||||
SHSTUB2(ape_macho_dd_skip, RVA(ape_macho) / 8);
|
||||
SHSTUB2(ape_macho_dd_count, (ape_macho_end - ape_macho) / 8);
|
||||
#endif
|
||||
|
||||
#if SupportsWindows() || SupportsMetal()
|
||||
#define LINK_WINDOWS (SupportsWindows() && !DEFINED(EfiMain))
|
||||
PFSTUB4(ape_pe_offset, ape_pe - ape_mz);
|
||||
HIDDEN(ape_pe_optsz = ape_pe_sections - (ape_pe + 24));
|
||||
HIDDEN(ape_pe_shnum = (ape_pe_sections_end - ape_pe_sections) / 40);
|
||||
HIDDEN(ape_pe_base = IMAGE_BASE_VIRTUAL);
|
||||
HIDDEN(ape_idata = LINK_WINDOWS ? RVA(ape_idata_iat) : 0);
|
||||
HIDDEN(ape_idata_iatsize = LINK_WINDOWS ? ape_idata_iatend - ape_idata_iat : 0);
|
||||
HIDDEN(ape_idata = LINK_WINDOWS ? RVA(ape_idata_idt) : 0);
|
||||
HIDDEN(ape_idata_idtsize = LINK_WINDOWS ? ape_idata_idtend - ape_idata_idt : 0);
|
||||
HIDDEN(v_ntversion = LINK_WINDOWS ? 6 : 1);
|
||||
HIDDEN(v_ntdllchar = LINK_WINDOWS ? 288 : 0);
|
||||
HIDDEN(v_ntsubversion = LINK_WINDOWS ? 6 : 5);
|
||||
HIDDEN(v_ntsubsystem = (LINK_WINDOWS
|
||||
? (DEFINED(GetMessage)
|
||||
? kNtImageSubsystemWindowsGui
|
||||
: kNtImageSubsystemWindowsCui)
|
||||
: kNtImageSubsystemEfiApplication));
|
||||
HIDDEN(ape_pe_entry = LINK_WINDOWS ? WinMain : EfiMain);
|
||||
#endif
|
||||
|
||||
#if SupportsMetal()
|
||||
HIDDEN(v_ape_realsectors =
|
||||
MIN(REAL_SCRATCH_AREA - IMAGE_BASE_REAL,
|
||||
ROUNDUP(RVA(_edata), 512)) / 512);
|
||||
MIN(0x70000 - IMAGE_BASE_REAL,
|
||||
ROUNDUP(RVA(_edata), 4096)) / 512);
|
||||
HIDDEN(v_ape_realpages = v_ape_realsectors / (4096 / 512));
|
||||
HIDDEN(v_ape_highsectors =
|
||||
(ROUNDUP(RVA(_edata), 512) / 512) - v_ape_realsectors);
|
||||
|
||||
/* Windows NT Auto-Subsystem Embedding */
|
||||
HIDDEN(v_ntsubsystem = (DEFINED(GetMessage)
|
||||
? kNtImageSubsystemWindowsGui
|
||||
: kNtImageSubsystemWindowsCui));
|
||||
#endif
|
||||
|
||||
/* ZIP End of Central Directory header */
|
||||
#define ZIPCONST(NAME, VAL) HIDDEN(NAME = DEFINED(__zip_start) ? VAL : 0);
|
||||
ZIPCONST(v_zip_cdoffset, __zip_start - IMAGE_BASE_VIRTUAL);
|
||||
ZIPCONST(v_zip_cdirsize, __zip_end - __zip_start);
|
||||
ASSERT(v_zip_cdirsize % kZipCdirHdrLinkableSize == 0, "bad zip cdir");
|
||||
ZIPCONST(v_zip_records, v_zip_cdirsize / kZipCdirHdrLinkableSize);
|
||||
ZIPCONST(v_zip_commentsize, _edata - __zip_end - kZipCdirHdrMinSize);
|
||||
ZIPCONST(v_zip_commentsize, _ezip - __zip_end - kZipCdirHdrMinSize);
|
||||
|
||||
/* Generates deterministic ID for Mach-O. */
|
||||
#if SupportsXnu()
|
||||
/* Generates deterministic ID. */
|
||||
#define PHI 0x9e3779b9925d4c17
|
||||
#define XOR(X,Y) ((X | Y) - (X & Y))
|
||||
#define XORSHIFT(X,Y) \
|
||||
@@ -566,85 +565,89 @@ ZIPCONST(v_zip_commentsize, _edata - __zip_end - kZipCdirHdrMinSize);
|
||||
X = (X + (Y >> 020) & 0xFF) * PHI; \
|
||||
X = (X + (Y >> 030) & 0xFF) * PHI
|
||||
#define CHURN(X) \
|
||||
XORSHIFT(uuid1_, X); \
|
||||
KMH(uuid1_, X); \
|
||||
XORSHIFT(uuid2_, X); \
|
||||
KMH(uuid2_, X)
|
||||
|
||||
HIDDEN(uuid1_ = 88172645463325252);
|
||||
HIDDEN(uuid2_ = 88172645463325252);
|
||||
|
||||
CHURN(.Lape.bss.align);
|
||||
CHURN(.Lape.bss.filesz);
|
||||
CHURN(.Lape.bss.memsz);
|
||||
CHURN(.Lape.bss.offset);
|
||||
CHURN(.Lape.bss.paddr);
|
||||
CHURN(.Lape.data.align);
|
||||
CHURN(.Lape.data.filesz);
|
||||
CHURN(.Lape.data.memsz);
|
||||
CHURN(.Lape.data.offset);
|
||||
CHURN(.Lape.data.paddr);
|
||||
CHURN(.Lape.data.rva);
|
||||
CHURN(.Lape.data.vaddr);
|
||||
CHURN(.Lape.elf.entry);
|
||||
CHURN(.Lape.elf.phnum);
|
||||
CHURN(.Lape.elf.phoff);
|
||||
CHURN(.Lape.elf.shnum);
|
||||
CHURN(.Lape.elf.shoff);
|
||||
CHURN(.Lape.elf.shstrndx);
|
||||
CHURN(.Lape.macho.end);
|
||||
CHURN(.Lape.note);
|
||||
CHURN(.Lape.note.align);
|
||||
CHURN(.Lape.note.end);
|
||||
CHURN(.Lape.note.filesz);
|
||||
CHURN(.Lape.note.memsz);
|
||||
CHURN(.Lape.note.offset);
|
||||
CHURN(.Lape.note.paddr);
|
||||
CHURN(.Lape.note.vaddr);
|
||||
CHURN(.Lape.pe.offset);
|
||||
CHURN(.Lape.pe.optsz);
|
||||
CHURN(.Lape.pe.sections);
|
||||
CHURN(.Lape.pe.sections_end);
|
||||
CHURN(.Lape.pe.shnum);
|
||||
CHURN(.Lape.phdrs.end);
|
||||
CHURN(.Lape.ram.align);
|
||||
CHURN(.Lape.ram.filesz);
|
||||
CHURN(.Lape.ram.memsz);
|
||||
CHURN(.Lape.ram.offset);
|
||||
CHURN(.Lape.ram.paddr);
|
||||
CHURN(.Lape.ram.rva);
|
||||
CHURN(.Lape.ram.vaddr);
|
||||
CHURN(.Lape.rom.align);
|
||||
CHURN(.Lape.rom.filesz);
|
||||
CHURN(.Lape.rom.memsz);
|
||||
CHURN(.Lape.rom.offset);
|
||||
CHURN(.Lape.rom.paddr);
|
||||
CHURN(.Lape.rom.rva);
|
||||
CHURN(.Lape.rom.vaddr);
|
||||
CHURN(.Lape.text.align);
|
||||
CHURN(.Lape.text.filesz);
|
||||
CHURN(.Lape.text.memsz);
|
||||
CHURN(.Lape.text.offset);
|
||||
CHURN(.Lape.text.paddr);
|
||||
CHURN(.Lape.text.rva);
|
||||
CHURN(.Lape.text.vaddr);
|
||||
XORSHIFT(ape_uuid1, X); \
|
||||
KMH(ape_uuid1, X); \
|
||||
XORSHIFT(ape_uuid2, X); \
|
||||
KMH(ape_uuid2, X)
|
||||
HIDDEN(ape_uuid1 = 88172645463325252);
|
||||
HIDDEN(ape_uuid2 = 88172645463325252);
|
||||
CHURN(ape_bss_align);
|
||||
CHURN(ape_bss_filesz);
|
||||
CHURN(ape_bss_memsz);
|
||||
CHURN(ape_bss_offset);
|
||||
CHURN(ape_bss_paddr);
|
||||
CHURN(ape_data_filesz);
|
||||
CHURN(ape_data_memsz);
|
||||
CHURN(ape_data_offset);
|
||||
CHURN(ape_data_paddr);
|
||||
CHURN(ape_data_rva);
|
||||
CHURN(ape_data_vaddr);
|
||||
CHURN(ape_elf_entry);
|
||||
CHURN(ape_elf_phnum);
|
||||
CHURN(ape_elf_phoff);
|
||||
CHURN(ape_elf_shnum);
|
||||
CHURN(ape_elf_shoff);
|
||||
CHURN(ape_elf_shstrndx);
|
||||
CHURN(ape_macho_end);
|
||||
CHURN(ape_note);
|
||||
CHURN(ape_note_align);
|
||||
CHURN(ape_note_end);
|
||||
CHURN(ape_note_filesz);
|
||||
CHURN(ape_note_memsz);
|
||||
CHURN(ape_note_offset);
|
||||
CHURN(ape_note_paddr);
|
||||
CHURN(ape_note_vaddr);
|
||||
CHURN(ape_ram_align);
|
||||
CHURN(ape_ram_filesz);
|
||||
CHURN(ape_ram_memsz);
|
||||
CHURN(ape_ram_offset);
|
||||
CHURN(ape_ram_paddr);
|
||||
CHURN(ape_ram_rva);
|
||||
CHURN(ape_ram_vaddr);
|
||||
CHURN(ape_rom_align);
|
||||
CHURN(ape_rom_filesz);
|
||||
CHURN(ape_rom_memsz);
|
||||
CHURN(ape_rom_offset);
|
||||
CHURN(ape_rom_paddr);
|
||||
CHURN(ape_rom_rva);
|
||||
CHURN(ape_rom_vaddr);
|
||||
CHURN(ape_text_align);
|
||||
CHURN(ape_text_filesz);
|
||||
CHURN(ape_text_memsz);
|
||||
CHURN(ape_text_offset);
|
||||
CHURN(ape_text_paddr);
|
||||
CHURN(ape_text_rva);
|
||||
CHURN(ape_text_vaddr);
|
||||
CHURN(ADDR(.bss));
|
||||
CHURN(WinMain);
|
||||
CHURN(_start);
|
||||
CHURN(ape.macho);
|
||||
CHURN(ape.mz);
|
||||
CHURN(ape.pe);
|
||||
CHURN(ape.phdrs);
|
||||
CHURN(ape_phdrs);
|
||||
#if SupportsMetal()
|
||||
CHURN(v_ape_realsectors);
|
||||
#endif
|
||||
#if SupportsXnu()
|
||||
CHURN(ape_macho);
|
||||
#endif
|
||||
#if SupportsWindows() || SupportsMetal()
|
||||
CHURN(ape_mz);
|
||||
CHURN(ape_pe);
|
||||
CHURN(ape_pe_offset);
|
||||
CHURN(ape_pe_optsz);
|
||||
CHURN(ape_pe_sections);
|
||||
CHURN(ape_pe_sections_end);
|
||||
CHURN(ape_pe_shnum);
|
||||
CHURN(ape_phdrs_end);
|
||||
CHURN(WinMain);
|
||||
#endif /* SupportsWindows() */
|
||||
#endif /* SupportsXnu() */
|
||||
|
||||
ASSERT(ape.mz == IMAGE_BASE_VIRTUAL, "linker panic");
|
||||
ASSERT(DEFINED(ape_mz) ? ape_mz == IMAGE_BASE_VIRTUAL : 1, "linker panic");
|
||||
ASSERT((DEFINED(__init_bss_end) ? __init_bss_end : 0) % __SIZEOF_POINTER__ == 0,
|
||||
"__init_bss misalign");
|
||||
ASSERT(((DEFINED(__init_rodata_end) ? __init_rodata_end : 0) %
|
||||
__SIZEOF_POINTER__ == 0),
|
||||
"__init_rodata misalign");
|
||||
|
||||
ASSERT((!DEFINED(ape.grub) ? 1 : RVA(ape.grub) < 8192),
|
||||
ASSERT((!DEFINED(ape_grub) ? 1 : RVA(ape_grub) < 8192),
|
||||
"grub stub needs to be in first 8kb of image");
|
||||
|
||||
ASSERT(DEFINED(_start) || DEFINED(_start16),
|
||||
@@ -656,7 +659,7 @@ ASSERT(!DEFINED(_start16) || REAL(_end) < 65536,
|
||||
/* Let's not be like Knight Capital. */
|
||||
/* NOCROSSREFS_TO(.test .text) */
|
||||
|
||||
/* ASSERT(ape_sysv_start == .Lape.text.vaddr, */
|
||||
/* ASSERT(ape_sysv_start == ape_text_vaddr, */
|
||||
/* "ape_sysv_start() must be first in .text"); */
|
||||
|
||||
#endif /* __LINKER__ */
|
||||
+23
-11
@@ -19,33 +19,45 @@ APE = $(APE_DEPS) \
|
||||
$(APE_OBJS) \
|
||||
o/$(MODE)/ape/ape.lds
|
||||
|
||||
APE_BUILDSAFE = \
|
||||
$(APE_DEPS) \
|
||||
o/$(MODE)/ape/ape-buildsafe.o \
|
||||
o/$(MODE)/ape/ape.lds
|
||||
|
||||
APELINK = \
|
||||
ACTION=LINK.ape \
|
||||
$(MKDIR) $(@D) && \
|
||||
$(COMPILE) \
|
||||
-ALINK.ape \
|
||||
$(LINK) \
|
||||
$(LINKARGS) \
|
||||
$(OUTPUT_OPTION) && \
|
||||
$(STRIP) \
|
||||
-X $@ && \
|
||||
$(GZ) \
|
||||
$(ZFLAGS) \
|
||||
-f $@.map
|
||||
$(OUTPUT_OPTION)
|
||||
|
||||
APE_FILES := $(wildcard ape/*.*)
|
||||
APE_HDRS = $(filter %.h,$(APE_FILES))
|
||||
APE_INCS = $(filter %.inc,$(APE_FILES))
|
||||
APE_SRCS = $(filter %.S,$(APE_FILES))
|
||||
APE_OBJS = $(APE_SRCS:%.S=o/$(MODE)/%.o)
|
||||
APE_DEPS = $(APE_LIB)
|
||||
APE_CHECKS = $(APE_HDRS:%=o/%.ok)
|
||||
|
||||
o/$(MODE)/ape/ape.lds: \
|
||||
ape/ape.lds \
|
||||
ape/macros.internal.h \
|
||||
libc/dce.h \
|
||||
libc/zip.h
|
||||
|
||||
o/ape/idata.inc: \
|
||||
ape/idata.h \
|
||||
ape/idata.internal.h \
|
||||
ape/relocations.h
|
||||
|
||||
$(APE_OBJS): $(BUILD_FILES) \
|
||||
ape/ape.mk
|
||||
|
||||
o/$(MODE)/ape/ape-no-modify-self.o: ape/ape.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -DAPE_NO_MODIFY_SELF $<
|
||||
|
||||
o/$(MODE)/ape/ape-buildsafe.o: ape/ape.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -DAPE_BUILDSAFE $<
|
||||
|
||||
.PHONY: o/$(MODE)/ape
|
||||
o/$(MODE)/ape: $(APE) \
|
||||
$(APE_CHECKS) \
|
||||
o/$(MODE)/ape/lib
|
||||
o/$(MODE)/ape/ape-no-modify-self.o
|
||||
-137
@@ -1,137 +0,0 @@
|
||||
#ifndef APE_CONFIG_H_
|
||||
#define APE_CONFIG_H_
|
||||
#include "ape/relocations.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
/**
|
||||
* @fileverview αcτµαlly pδrταblε εxεcµταblε configuration.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Post-Initialization Read-Only Code Size Threshold.
|
||||
*
|
||||
* An executable needs to have at least this much code, before the
|
||||
* linker adds non-mandatory 4kb alignments. The benefit is better
|
||||
* memory protection. The tradeoff is sparser binaries.
|
||||
*/
|
||||
#ifndef APE_PIRO_THRESHOLD
|
||||
#ifdef CONFIG_DBG
|
||||
#define APE_PIRO_THRESHOLD 0x1000
|
||||
#else
|
||||
#define APE_PIRO_THRESHOLD 0x10000
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PC Standard I/O Configuration.
|
||||
*/
|
||||
#ifndef METAL_STDIN
|
||||
#define METAL_STDIN COM1
|
||||
#endif
|
||||
#ifndef METAL_STDOUT
|
||||
#define METAL_STDOUT COM1
|
||||
#endif
|
||||
#ifndef METAL_STDERR
|
||||
#define METAL_STDERR COM1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PC Display Configuration (MDA/CGA)
|
||||
* @see www.lammertbies.nl/comm/info/serial-uart.html
|
||||
* @see ape/lib/vidya.h
|
||||
*/
|
||||
#ifndef VIDYA_MODE
|
||||
#define VIDYA_MODE VIDYA_MODE_CGA
|
||||
#endif
|
||||
|
||||
/* FPU Control Word (x87) Exception Masks
|
||||
@see Intel Manual V1 §8.1.5
|
||||
|
||||
IM: Invalid Operation ───────────────┐
|
||||
DM: Denormal Operand ───────────────┐│
|
||||
ZM: Zero Divide ───────────────────┐││
|
||||
OM: Overflow ─────────────────────┐│││
|
||||
UM: Underflow ───────────────────┐││││
|
||||
PM: Precision ──────────────────┐│││││
|
||||
PC: Precision Control ────────┐ ││││││
|
||||
{float,∅,double,long double} │ ││││││
|
||||
RC: Rounding Control ───────┐ │ ││││││
|
||||
{even, →-∞, →+∞, →0} │┌┤ ││││││
|
||||
┌┤││ ││││││
|
||||
d││││rr││││││*/
|
||||
#define X87_NORMAL 0b000000000001101111111
|
||||
#define X87_DTOA 0b000000000001000000000
|
||||
#define X87_DTOA_MASK 0b000000000001100000000
|
||||
#ifndef X87_DEFAULT
|
||||
#define X87_DEFAULT X87_NORMAL
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Serial Line Configuration (8250 UART 16550)
|
||||
* @see ape/lib/uart.h
|
||||
*/
|
||||
#ifndef UART_BAUD_RATE
|
||||
#define UART_BAUD_RATE 9600 /* bits per second ∈ [50,115200] */
|
||||
#endif
|
||||
#define UART_CONF_DLR (1843200 /*hz*/ / 16 /*wut*/ / (UART_BAUD_RATE))
|
||||
#ifndef UART_CONF_IIR
|
||||
/* ┌interrupt trigger level {1,4,8,14}
|
||||
│ ┌enable 64 byte fifo (UART 16750+)
|
||||
│ │ ┌select dma mode
|
||||
│ │ │┌clear transmit fifo
|
||||
│ │ ││┌clear receive fifo
|
||||
├┐│ │││┌enable fifos*/
|
||||
#define UART_CONF_IIR 0b00000000
|
||||
#endif
|
||||
#ifndef UART_CONF_LCR
|
||||
/* ┌dlab: flips configuration mode state
|
||||
│┌enable break signal
|
||||
││ ┌parity {none,odd,even,high,low}
|
||||
││ │ ┌extra stop bit
|
||||
││ │ │┌data word length (bits+5)
|
||||
││┌┴┐│├┐*/
|
||||
#define UART_CONF_LCR 0b01000011
|
||||
#endif
|
||||
|
||||
/**
|
||||
* eXtreme Low Memory.
|
||||
*/
|
||||
#define XLM(VAR) (XLM_BASE_REAL + XLM_##VAR)
|
||||
#define XLMV(VAR) (__xlm + XLM_##VAR)
|
||||
#define XLM_BASE_REAL 0x1000
|
||||
#define XLM_E820 0
|
||||
#define XLM_E820_SIZE 0x2000
|
||||
#define XLM_BIOS_DATA_AREA 0x2000
|
||||
#define XLM_BIOS_DATA_AREA_SIZE 256
|
||||
#define XLM_DRIVE_BASE_TABLE 0x2200 /* drive values are contiguous */
|
||||
#define XLM_DRIVE_BASE_TABLE_SIZE 11
|
||||
#define XLM_DRIVE_TYPE 0x220b
|
||||
#define XLM_DRIVE_TYPE_SIZE 1
|
||||
#define XLM_DRIVE_LAST_SECTOR 0x220c /* 1-based inclusive, e.g. 18 */
|
||||
#define XLM_DRIVE_LAST_SECTOR_SIZE 1
|
||||
#define XLM_DRIVE_LAST_CYLINDER 0x220d /* 0-based incl, e.g. 79 */
|
||||
#define XLM_DRIVE_LAST_CYLINDER_SIZE 2
|
||||
#define XLM_DRIVE_ATTACHED 0x220f
|
||||
#define XLM_DRIVE_ATTACHED_SIZE 1
|
||||
#define XLM_DRIVE_LAST_HEAD 0x2210 /* 0-based inclusive, e.g. 1 */
|
||||
#define XLM_DRIVE_LAST_HEAD_SIZE 1
|
||||
#define XLM_DRIVE 0x2211
|
||||
#define XLM_DRIVE_SIZE 1
|
||||
#define XLM_HAVEEXTMEMKB 0x2212
|
||||
#define XLM_HAVEEXTMEMKB_SIZE 4
|
||||
#define XLM_VIDEO_POSITION_FAR_POINTER 0x2216 /* video cursor far pointer */
|
||||
#define XLM_VIDEO_POSITION_FAR_POINTER_SIZE 4
|
||||
#define XLM_PAGE_TABLE_STACK_POINTER 0x2220
|
||||
#define XLM_PAGE_TABLE_STACK_POINTER_SIZE 8
|
||||
#define XLM_BADIDT 0x2230
|
||||
#define XLM_BADIDT_SIZE 6
|
||||
#define XLM_LOADSTATE 0x2240
|
||||
#define XLM_LOADSTATE_SIZE 4
|
||||
#define XLM_SIZE ROUNDUP(XLM_LOADSTATE + XLM_LOADSTATE_SIZE, 0x1000)
|
||||
#define IMAGE_BASE_REAL (XLM_BASE_REAL + XLM_SIZE)
|
||||
|
||||
#if !defined(__LINKER__) && !defined(__ASSEMBLER__)
|
||||
extern char __xlm[XLM_SIZE];
|
||||
#endif /* !defined(__LINKER__) && !defined(__ASSEMBLER__) */
|
||||
|
||||
#endif /* APE_CONFIG_H_ */
|
||||
-1279
File diff suppressed because it is too large.
Load diff
-1294
File diff suppressed because it is too large.
Load diff
-115
@@ -1,115 +0,0 @@
|
||||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#ifndef APE_IDATA_H_
|
||||
#define APE_IDATA_H_
|
||||
#ifdef __ASSEMBLER__
|
||||
#include "ape/relocations.h"
|
||||
/* clang-format off */
|
||||
|
||||
/ Links function from external DLL.
|
||||
/
|
||||
/ This embeds a function pointer in the binary. The NT Executive
|
||||
/ fills its value before control is handed off to the program.
|
||||
/
|
||||
/ @note only ELF toolchains are powerful enough to use this
|
||||
/ @see libc/nt/master.sh
|
||||
/ @see ape/ape.lds
|
||||
/ @see winimp
|
||||
.macro .imp dll:req fn:req actual:req hint
|
||||
.dll \dll
|
||||
.section .piro.data.sort.iat.2.\dll\().2.\actual,"aw",@progbits
|
||||
.type \fn,@object
|
||||
.align __SIZEOF_POINTER__
|
||||
\fn: .quad RVA((\dll\().\actual))
|
||||
.size \fn,.-\fn
|
||||
.globl \fn
|
||||
.hidden \fn
|
||||
.previous
|
||||
.section .idata.ro.ilt.\dll\().2.\actual,"a",@progbits
|
||||
.Lidata.ilt.\dll\().\actual:
|
||||
.quad RVA((\dll\().\actual))
|
||||
.type .Lidata.ilt.\dll\().\actual,@object
|
||||
.size .Lidata.ilt.\dll\().\actual,.-.Lidata.ilt.\dll\().\actual
|
||||
.previous
|
||||
.section .idata.ro.hnt.\dll\().2.\actual,"a",@progbits
|
||||
\dll\().\actual:
|
||||
.ifnb \hint # hint i.e. guess function ordinal
|
||||
.short \hint
|
||||
.else
|
||||
.short 0
|
||||
.endif
|
||||
.asciz "\actual"
|
||||
.align 2 # documented requirement
|
||||
.globl \dll\().\actual
|
||||
.hidden \dll\().\actual
|
||||
.type \dll\().\actual,@object
|
||||
.size \dll\().\actual,.-\dll\().\actual
|
||||
.previous
|
||||
.endm
|
||||
|
||||
/ Defines DLL import.
|
||||
/ @note this is an implementation detail of .imp
|
||||
.macro .dll name:req
|
||||
.section .idata.ro.idt.2.\name,"aG",\name,comdat
|
||||
.equ .Lidata.idt.\name,.
|
||||
.long RVA(idata.ilt.\name) # ImportLookupTable
|
||||
.long 0 # TimeDateStamp
|
||||
.long 0 # ForwarderChain
|
||||
.long RVA(.Lidata.str.\name) # DllNameRva
|
||||
.long RVA(idata.iat.\name) # ImportAddressTable
|
||||
.type .Lidata.idt.\name,@object
|
||||
.size .Lidata.idt.\name,.-.Lidata.idt.\name
|
||||
.previous
|
||||
.section .idata.ro.ilt.\name\().1,"aG",\name,comdat
|
||||
.align __SIZEOF_POINTER__
|
||||
.type idata.ilt.\name,@object
|
||||
idata.ilt.\name:
|
||||
.previous/*
|
||||
...
|
||||
decentralized content
|
||||
...
|
||||
*/.section .idata.ro.ilt.\name\().3,"aG",\name,comdat
|
||||
.quad 0
|
||||
.previous
|
||||
.section .idata.ro.hnt.\name\().1,"aG",\name,comdat
|
||||
.align __SIZEOF_POINTER__
|
||||
.type idata.hnt.\name,@object
|
||||
.equ idata.hnt.\name,.
|
||||
.previous
|
||||
.section .piro.data.sort.iat.2.\name\().1,"awG",\name,comdat
|
||||
.align __SIZEOF_POINTER__
|
||||
.type idata.iat.\name,@object
|
||||
idata.iat.\name:
|
||||
.previous/*
|
||||
...
|
||||
decentralized content
|
||||
...
|
||||
*/.section .piro.data.sort.iat.2.\name\().3,"awG",\name,comdat
|
||||
.quad 0
|
||||
.previous
|
||||
.pushsection .rodata.str1.1,"aSM",@progbits,1
|
||||
.Lidata.str.\name:
|
||||
.asciz "\name\().dll"
|
||||
.popsection
|
||||
.endm
|
||||
|
||||
/* clang-format on */
|
||||
#endif /* __ASSEMBLER__ */
|
||||
#endif /* APE_IDATA_H_ */
|
||||
@@ -0,0 +1,114 @@
|
||||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#ifndef APE_IDATA_H_
|
||||
#define APE_IDATA_H_
|
||||
#ifdef __ASSEMBLER__
|
||||
#include "ape/relocations.h"
|
||||
/* clang-format off */
|
||||
|
||||
// Links function from external DLL.
|
||||
//
|
||||
// This embeds a function pointer in the binary. The NT Executive
|
||||
// fills its value before control is handed off to the program.
|
||||
//
|
||||
// @note only ELF toolchains are powerful enough to use this
|
||||
// @see libc/nt/master.sh
|
||||
// @see ape/ape.lds
|
||||
// @see winimp
|
||||
.macro .imp dll:req fn:req actual:req hint
|
||||
.dll \dll
|
||||
.section .piro.data.sort.iat.2.\dll\().2.\actual,"aw",@progbits
|
||||
.type \fn,@object
|
||||
.align __SIZEOF_POINTER__
|
||||
\fn: .quad RVA((\dll\().\actual))
|
||||
.size \fn,.-\fn
|
||||
.globl \fn
|
||||
.hidden \fn
|
||||
.previous
|
||||
.section .idata.ro.ilt.\dll\().2.\actual,"a",@progbits
|
||||
.Lidata.ilt.\dll\().\actual:
|
||||
.quad RVA((\dll\().\actual))
|
||||
.type .Lidata.ilt.\dll\().\actual,@object
|
||||
.size .Lidata.ilt.\dll\().\actual,.-.Lidata.ilt.\dll\().\actual
|
||||
.previous
|
||||
.section .idata.ro.hnt.\dll\().2.\actual,"a",@progbits
|
||||
\dll\().\actual:
|
||||
.ifnb \hint # hint i.e. guess function ordinal
|
||||
.short \hint
|
||||
.else
|
||||
.short 0
|
||||
.endif
|
||||
.asciz "\actual"
|
||||
.align 2 # documented requirement
|
||||
.globl \dll\().\actual
|
||||
.hidden \dll\().\actual
|
||||
.type \dll\().\actual,@object
|
||||
.size \dll\().\actual,.-\dll\().\actual
|
||||
.previous
|
||||
.endm
|
||||
|
||||
// Defines DLL import.
|
||||
// @note this is an implementation detail of .imp
|
||||
.macro .dll name:req
|
||||
.section .idata.ro.idt.2.\name,"aG",@progbits,\name,comdat
|
||||
.equ .Lidata.idt.\name,.
|
||||
.long RVA(idata.ilt.\name) # ImportLookupTable
|
||||
.long 0 # TimeDateStamp
|
||||
.long 0 # ForwarderChain
|
||||
.long RVA(.Lidata.str.\name) # DllNameRva
|
||||
.long RVA(idata.iat.\name) # ImportAddressTable
|
||||
.type .Lidata.idt.\name,@object
|
||||
.size .Lidata.idt.\name,.-.Lidata.idt.\name
|
||||
.previous
|
||||
.section .idata.ro.ilt.\name\().1,"aG",@progbits,\name,comdat
|
||||
.align __SIZEOF_POINTER__
|
||||
.type idata.ilt.\name,@object
|
||||
idata.ilt.\name:
|
||||
.previous/*
|
||||
...
|
||||
decentralized content
|
||||
...
|
||||
*/.section .idata.ro.ilt.\name\().3,"aG",@progbits,\name,comdat
|
||||
.quad 0
|
||||
.previous
|
||||
.section .idata.ro.hnt.\name\().1,"aG",@progbits,\name,comdat
|
||||
.align __SIZEOF_POINTER__
|
||||
.type idata.hnt.\name,@object
|
||||
.equ idata.hnt.\name,.
|
||||
.previous
|
||||
.section .piro.data.sort.iat.2.\name\().1,"awG",@progbits,\name,comdat
|
||||
.align __SIZEOF_POINTER__
|
||||
.type idata.iat.\name,@object
|
||||
idata.iat.\name:
|
||||
.previous/*
|
||||
...
|
||||
decentralized content
|
||||
...
|
||||
*/.section .piro.data.sort.iat.2.\name\().3,"awG",@progbits,\name,comdat
|
||||
.quad 0
|
||||
.previous
|
||||
.section .rodata.str1.1,"aSM",@progbits,1
|
||||
.Lidata.str.\name:
|
||||
.asciz "\name\().dll"
|
||||
.previous
|
||||
.endm
|
||||
|
||||
/* clang-format on */
|
||||
#endif /* __ASSEMBLER__ */
|
||||
#endif /* APE_IDATA_H_ */
|
||||
@@ -1,44 +0,0 @@
|
||||
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐
|
||||
#───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘
|
||||
|
||||
PKGS += APE_LIB
|
||||
|
||||
APE_LIB_ARTIFACTS += APE_LIB_A
|
||||
APE_LIB = $(APE_LIB_A_DEPS) $(APE_LIB_A)
|
||||
APE_LIB_A = o/$(MODE)/ape/lib/apelib.a
|
||||
APE_LIB_A_FILES := $(wildcard ape/lib/*)
|
||||
APE_LIB_A_HDRS = $(filter %.h,$(APE_LIB_A_FILES))
|
||||
APE_LIB_A_SRCS_S = $(filter %.S,$(APE_LIB_A_FILES))
|
||||
APE_LIB_A_SRCS_C = $(filter %.c,$(APE_LIB_A_FILES))
|
||||
|
||||
APE_LIB_A_SRCS = \
|
||||
$(APE_LIB_A_SRCS_S) \
|
||||
$(APE_LIB_A_SRCS_C)
|
||||
|
||||
APE_LIB_A_OBJS = \
|
||||
$(APE_LIB_A_SRCS_S:%.S=o/$(MODE)/%.o) \
|
||||
$(APE_LIB_A_SRCS_C:%.c=o/$(MODE)/%.o) \
|
||||
$(APE_LIB_A_SRCS:%=o/$(MODE)/%.zip.o) \
|
||||
o/$(MODE)/ape/ape.lds.zip.o \
|
||||
o/$(MODE)/ape/ape.S.zip.o \
|
||||
o/$(MODE)/NOTICE.zip.o
|
||||
|
||||
APE_LIB_A_CHECKS = $(APE_LIB_A_HDRS:%=o/$(MODE)/%.ok)
|
||||
APE_LIB_A_DIRECTDEPS = LIBC_STR LIBC_STUBS
|
||||
APE_LIB_A_DEPS = $(call uniq,$(foreach x,$(APE_LIB_A_DIRECTDEPS),$($(x))))
|
||||
|
||||
$(APE_LIB_A): ape/lib/ $(APE_LIB_A).pkg $(APE_LIB_A_OBJS)
|
||||
$(APE_LIB_A).pkg: $(APE_LIB_A_OBJS) $(foreach x,$(APE_LIB_A_DIRECTDEPS),$($(x)_A).pkg)
|
||||
|
||||
APE_LIB_LIBS = $(foreach x,$(APE_LIB_ARTIFACTS),$($(x)))
|
||||
APE_LIB_SRCS = $(foreach x,$(APE_LIB_ARTIFACTS),$($(x)_SRCS))
|
||||
APE_LIB_HDRS = $(foreach x,$(APE_LIB_ARTIFACTS),$($(x)_HDRS))
|
||||
APE_LIB_BINS = $(foreach x,$(APE_LIB_ARTIFACTS),$($(x)_BINS))
|
||||
APE_LIB_CHECKS = $(foreach x,$(APE_LIB_ARTIFACTS),$($(x)_CHECKS))
|
||||
APE_LIB_OBJS = $(foreach x,$(APE_LIB_ARTIFACTS),$($(x)_OBJS))
|
||||
$(APE_LIB_OBJS): $(BUILD_FILES) libc/str/str.mk
|
||||
|
||||
.PHONY: o/$(MODE)/ape/lib
|
||||
o/$(MODE)/ape/lib: \
|
||||
$(APE_LIB_CHECKS) \
|
||||
$(APE_LIB_A)
|
||||
@@ -1,59 +0,0 @@
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=8 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╠──────────────────────────────────────────────────────────────────────────────╣
|
||||
│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░█▀█░█▀█░▀█▀░█░█░█▀█░█░░░█░░░█░█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░█▀█░█░▄░░█░░█░█░█▀█░█░░░█░░░▀█▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░▀░▀░▀▀▀░░▀░░▀▀▀░▀░▀░▀▀▀░▀▀▀░░▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░█▀█░█▀█░█▀█░▀█▀░█▀█░█▀█░█░░░█▀▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░█▀▀░█ █░██▀░░█░░█▀█░█▀█░█░░░█▀▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░▀░░░▀▀▀░▀░▀░░▀░░▀░▀░▀▀▀░▀▀▀░▀▀▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░█▀▀░█░█░█▀▀░█▀█░█░█░▀█▀░█▀█░█▀█░█░░█▀▀░░░░░░░░░░░░░░░░░░░░░░░░▄▄░░░▐█░░│
|
||||
│░░░░░░░█▀▀░▄▀▄░█▀▀░█░▄░█░█░░█░░█▀█░█▀█░█░░█▀▀░░░░░░░░░░░░▄▄▄░░░▄██▄░░█▀░░░█░▄░│
|
||||
│░░░░░░░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀▀▀░░▀░░▀░▀░▀▀▀░▀▀░▀▀▀░░░░░░░░░░▄██▀█▌░██▄▄░░▐█▀▄░▐█▀░░│
|
||||
│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▐█▀▀▌░░░▄▀▌░▌░█░▌░░▌░▌░░│
|
||||
╠──────────────────────────────────────────────────────▌▀▄─▐──▀▄─▐▄─▐▄▐▄─▐▄─▐▄─│
|
||||
│ αcτµαlly pδrταblε εxεcµταblε § green energy │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#ifndef APE_LIB_APM_H_
|
||||
#define APE_LIB_APM_H_
|
||||
|
||||
/**
|
||||
* @fileoverview Advanced Power Management.
|
||||
*
|
||||
* <p>APM is useful for exiting programs, without needing to ask the
|
||||
* human to flip a physical switch or pass QEMU's -no-reboot flag.
|
||||
*
|
||||
* <p><b>Implementation Detail:</b> Supporting ACPI would literally
|
||||
* require implementing a programming language.
|
||||
*
|
||||
* @see APM BIOS Interface Specification v1.2
|
||||
* @since IBM PC/AT
|
||||
*/
|
||||
|
||||
#define APM_SERVICE 0x15
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
void apmoff(void) noreturn;
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* APE_LIB_APM_H_ */
|
||||
@@ -1,36 +0,0 @@
|
||||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/macros.h"
|
||||
#include "ape/notice.inc"
|
||||
.section .real,"ax",@progbits
|
||||
.source __FILE__
|
||||
.code16
|
||||
|
||||
/ Resets personal computer.
|
||||
/
|
||||
/ @param di drive number, e.g. A:\ is 0x00, C:\ is 0x80
|
||||
/ @mode real
|
||||
/ @noreturn
|
||||
bootdr: push %bp
|
||||
mov %sp,%bp
|
||||
mov %di,%dx
|
||||
int $0x19
|
||||
ljmp $0xf000,$0xfff0
|
||||
.endfn bootdr,globl
|
||||
@@ -1,38 +0,0 @@
|
||||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/lib/pc.h"
|
||||
#include "ape/config.h"
|
||||
#include "ape/macros.h"
|
||||
#include "ape/notice.inc"
|
||||
.section .real,"ax",@progbits
|
||||
.source __FILE__
|
||||
.code16
|
||||
|
||||
.globl e820map
|
||||
.hidden e820map
|
||||
.type e820map,@object
|
||||
.size e820map,XLM_E820_SIZE
|
||||
e820map = ape.xlm + XLM_E820
|
||||
|
||||
.globl e820map_xlm
|
||||
.hidden e820map_xlm
|
||||
.type e820map_xlm,@object
|
||||
.size e820map_xlm,XLM_E820_SIZE
|
||||
e820map_xlm = XLM(E820)
|
||||
@@ -1,59 +0,0 @@
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/config.h"
|
||||
#include "ape/lib/pc.h"
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/bits/safemacros.h"
|
||||
|
||||
/**
|
||||
* Virtualizes physical memory.
|
||||
*
|
||||
* This function removes memory holes (discovered by e820() earlier) and
|
||||
* creates the illusion of flat contiguous memory for as much RAM as the
|
||||
* BIOS reports usable. Memory is safe to use and remap afterwards.
|
||||
*
|
||||
* @see ape/ape.S
|
||||
*/
|
||||
textreal void flattenhighmemory(struct SmapEntry *e820, struct PageTable *pml4t,
|
||||
uint64_t *ptsp) {
|
||||
struct SmapEntry *smap = e820;
|
||||
struct SmapEntry *hole = e820;
|
||||
uint64_t paddr = IMAGE_BASE_PHYSICAL;
|
||||
uint64_t vaddr = IMAGE_BASE_VIRTUAL;
|
||||
while (smap->size) {
|
||||
while (smap->size && smap->type != kMemoryUsable) smap++;
|
||||
paddr = roundup(max(paddr, smap->addr), PAGESIZE);
|
||||
while (paddr < rounddown(smap->addr + smap->size, PAGESIZE)) {
|
||||
while (hole->size &&
|
||||
(hole->type == kMemoryUsable || hole->addr + hole->size < paddr)) {
|
||||
hole++;
|
||||
}
|
||||
if (paddr >= hole->addr && paddr < hole->addr + hole->size) {
|
||||
paddr = roundup(hole->addr + hole->size, PAGESIZE);
|
||||
} else {
|
||||
uint64_t *entry = getpagetableentry(vaddr, 3, pml4t, ptsp);
|
||||
*entry = paddr | PAGE_V | PAGE_RW;
|
||||
vaddr += 0x1000;
|
||||
paddr += 0x1000;
|
||||
}
|
||||
}
|
||||
smap++;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/lib/pc.h"
|
||||
#include "ape/config.h"
|
||||
#include "ape/macros.h"
|
||||
#include "ape/notice.inc"
|
||||
.section .real,"ax",@progbits
|
||||
.source __FILE__
|
||||
.code16
|
||||
|
||||
.globl g_pml4t
|
||||
.hidden g_pml4t
|
||||
.type g_pml4t,@object
|
||||
.size g_pml4t,0x1000
|
||||
g_pml4t = REAL_STACK_FRAME - 0x1000
|
||||
@@ -1,38 +0,0 @@
|
||||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/lib/pc.h"
|
||||
#include "ape/config.h"
|
||||
#include "ape/macros.h"
|
||||
#include "ape/notice.inc"
|
||||
.section .real,"ax",@progbits
|
||||
.source __FILE__
|
||||
.code16
|
||||
|
||||
.globl g_ptsp
|
||||
.hidden g_ptsp
|
||||
.type g_ptsp,@object
|
||||
.size g_ptsp,XLM_PAGE_TABLE_STACK_POINTER_SIZE
|
||||
g_ptsp = ape.xlm + XLM_PAGE_TABLE_STACK_POINTER
|
||||
|
||||
.globl g_ptsp_xlm
|
||||
.hidden g_ptsp_xlm
|
||||
.type g_ptsp_xlm,@object
|
||||
.size g_ptsp_xlm,XLM_PAGE_TABLE_STACK_POINTER_SIZE
|
||||
g_ptsp_xlm = XLM(PAGE_TABLE_STACK_POINTER)
|
||||
@@ -1,42 +0,0 @@
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/lib/pc.h"
|
||||
#include "libc/assert.h"
|
||||
|
||||
textreal static uint64_t pushpagetable(uint64_t *ptsp) {
|
||||
return (*ptsp -= PAGESIZE) | PAGE_V | PAGE_RW;
|
||||
}
|
||||
|
||||
textreal uint64_t *getpagetableentry(int64_t vaddr, unsigned depth,
|
||||
struct PageTable *pml4t, uint64_t *ptsp) {
|
||||
uint64_t *entry;
|
||||
unsigned char shift;
|
||||
assert(depth <= 3);
|
||||
assert(!(*ptsp & 0xfff));
|
||||
assert(!((uintptr_t)pml4t & 0xfff));
|
||||
shift = 39;
|
||||
for (;;) {
|
||||
entry = &pml4t->p[(vaddr >> shift) & 511];
|
||||
if (!depth--) return entry;
|
||||
shift -= 9;
|
||||
if (!*entry) *entry = pushpagetable(ptsp);
|
||||
pml4t = (void *)(*entry & PAGE_TA);
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/lib/pc.h"
|
||||
#include "ape/config.h"
|
||||
#include "ape/macros.h"
|
||||
#include "ape/notice.inc"
|
||||
.section .real,"ax",@progbits
|
||||
.source __FILE__
|
||||
.code16
|
||||
|
||||
.globl kBiosDataArea
|
||||
.hidden kBiosDataArea
|
||||
.type kBiosDataArea,@object
|
||||
.size kBiosDataArea,XLM_BIOS_DATA_AREA_SIZE
|
||||
kBiosDataArea = ape.xlm + XLM_BIOS_DATA_AREA
|
||||
|
||||
.globl kBiosDataAreaXlm
|
||||
.hidden kBiosDataAreaXlm
|
||||
.type kBiosDataAreaXlm,@object
|
||||
.size kBiosDataAreaXlm,XLM_BIOS_DATA_AREA_SIZE
|
||||
kBiosDataAreaXlm = XLM(BIOS_DATA_AREA)
|
||||
|
||||
.section .sort.text.real.init.2.kBiosDataArea,"ax",@progbits
|
||||
movpp %ds,%es # copy bios data to valid page
|
||||
mov $PC_BIOS_DATA_AREA,%si
|
||||
mov $XLM(BIOS_DATA_AREA),%di
|
||||
mov $XLM_BIOS_DATA_AREA_SIZE,%cx
|
||||
rep movsb
|
||||
.previous
|
||||
@@ -1,38 +0,0 @@
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/lib/pc.h"
|
||||
#include "ape/relocations.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
||||
textreal static void __map_segment(uint64_t k, uint64_t a, uint64_t b) {
|
||||
uint64_t *e;
|
||||
for (; a < b; a += 0x1000) {
|
||||
e = getpagetableentry(IMAGE_BASE_VIRTUAL + a, 3, &g_pml4t, &g_ptsp_xlm);
|
||||
*e = (IMAGE_BASE_PHYSICAL + a) | k;
|
||||
}
|
||||
}
|
||||
|
||||
textreal void __map_image(void) {
|
||||
pageunmap(0);
|
||||
__map_segment(PAGE_V | PAGE_U, 0, (uintptr_t)_etext - IMAGE_BASE_VIRTUAL);
|
||||
__map_segment(PAGE_V | PAGE_U | PAGE_RW | PAGE_XD,
|
||||
(uintptr_t)_etext - IMAGE_BASE_VIRTUAL,
|
||||
(uintptr_t)_end - IMAGE_BASE_VIRTUAL);
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/lib/pc.h"
|
||||
#include "libc/bits/bits.h"
|
||||
|
||||
textreal void pageunmap(int64_t vaddr) {
|
||||
uint64_t *entry;
|
||||
entry = getpagetableentry(vaddr, 3, &g_pml4t, &g_ptsp_xlm);
|
||||
*entry &= ~PAGE_V;
|
||||
invlpg(vaddr);
|
||||
}
|
||||
-242
@@ -1,242 +0,0 @@
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=8 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╠──────────────────────────────────────────────────────────────────────────────╣
|
||||
│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░█▀█░█▀█░▀█▀░█░█░█▀█░█░░░█░░░█░█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░█▀█░█░▄░░█░░█░█░█▀█░█░░░█░░░▀█▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░▀░▀░▀▀▀░░▀░░▀▀▀░▀░▀░▀▀▀░▀▀▀░░▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░█▀█░█▀█░█▀█░▀█▀░█▀█░█▀█░█░░░█▀▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░█▀▀░█ █░██▀░░█░░█▀█░█▀█░█░░░█▀▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░▀░░░▀▀▀░▀░▀░░▀░░▀░▀░▀▀▀░▀▀▀░▀▀▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░█▀▀░█░█░█▀▀░█▀█░█░█░▀█▀░█▀█░█▀█░█░░█▀▀░░░░░░░░░░░░░░░░░░░░░░░░▄▄░░░▐█░░│
|
||||
│░░░░░░░█▀▀░▄▀▄░█▀▀░█░▄░█░█░░█░░█▀█░█▀█░█░░█▀▀░░░░░░░░░░░░▄▄▄░░░▄██▄░░█▀░░░█░▄░│
|
||||
│░░░░░░░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀▀▀░░▀░░▀░▀░▀▀▀░▀▀░▀▀▀░░░░░░░░░░▄██▀█▌░██▄▄░░▐█▀▄░▐█▀░░│
|
||||
│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▐█▀▀▌░░░▄▀▌░▌░█░▌░░▌░▌░░│
|
||||
╠──────────────────────────────────────────────────────▌▀▄─▐──▀▄─▐▄─▐▄▐▄─▐▄─▐▄─│
|
||||
│ αcτµαlly pδrταblε εxεcµταblε § ibm personal computer │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#ifndef APE_LIB_PC_H_
|
||||
#define APE_LIB_PC_H_
|
||||
|
||||
#define BOOTSIG 0xaa55 /* master boot record signature */
|
||||
#define PC_BIOS_DATA_AREA 0x400
|
||||
|
||||
#define kInterruptFlag (1u << 9)
|
||||
|
||||
/* FPU Status Word (x87)
|
||||
@see Intel Manual V1 §8.1.3
|
||||
IE: Invalid Operation ────────────────┐
|
||||
DE: Denormalized Operand ────────────┐│
|
||||
ZE: Zero Divide ────────────────────┐││
|
||||
OE: Overflow Flag ─────────────────┐│││
|
||||
UE: Underflow Flag ───────────────┐││││
|
||||
PE: Precision Flag ──────────────┐│││││
|
||||
SF: Stack Fault ────────────────┐││││││
|
||||
ES: Exception Summary Status ──┐│││││││
|
||||
C0-3: Condition Codes ──┬────┐ ││││││││
|
||||
TOP of Stack Pointer ─────┐ │ ││││││││
|
||||
B: FPU Busy ───────────┐│ │ │ ││││││││
|
||||
││┌┴┐┌┼┐││││││││
|
||||
│↓│ │↓↓↓││││││││*/
|
||||
#define FPU_IE 0b0000000000100000000000001
|
||||
#define FPU_ZE 0b0000000000100000000000100
|
||||
#define FPU_SF 0b0000000000000000001000000
|
||||
#define FPU_C0 0b0000000000000000100000000
|
||||
#define FPU_C1 0b0000000000000001000000000
|
||||
#define FPU_C2 0b0000000000000010000000000
|
||||
#define FPU_C3 0b0000000000100000000000000
|
||||
|
||||
#define CR0_PE (1u << 0) /* protected mode enabled */
|
||||
#define CR0_MP (1u << 1) /* monitor coprocessor */
|
||||
#define CR0_EM (1u << 2) /* no x87 fpu present if set */
|
||||
#define CR0_TS (1u << 3) /* task switched x87 */
|
||||
#define CR0_ET (1u << 4) /* extension type 287 or 387 */
|
||||
#define CR0_NE (1u << 5) /* enable x87 error reporting */
|
||||
#define CR0_WP (1u << 16) /* write protect read-only pages @pl0 */
|
||||
#define CR0_AM (1u << 18) /* alignment mask */
|
||||
#define CR0_NW (1u << 29) /* global write-through cache disable */
|
||||
#define CR0_CD (1u << 30) /* global cache disable */
|
||||
#define CR0_PG (1u << 31) /* paging enabled */
|
||||
|
||||
#define CR4_VME (1u << 0) /* virtual 8086 mode extension */
|
||||
#define CR4_PVI (1u << 1) /* protected mode virtual interrupts */
|
||||
#define CR4_TSD (1u << 2) /* time stamp disable (rdtsc) */
|
||||
#define CR4_DE (1u << 3) /* debugging extensions */
|
||||
#define CR4_PSE (1u << 4) /* page size extension */
|
||||
#define CR4_PAE (1u << 5) /* physical address extension */
|
||||
#define CR4_MCE (1u << 6) /* machine check exception */
|
||||
#define CR4_PGE (1u << 7) /* page global enabled */
|
||||
#define CR4_OSFXSR (1u << 9) /* enable SSE and fxsave/fxrestor */
|
||||
#define CR4_OSXMMEXCPT (1u << 10) /* enable unmasked SSE exceptions */
|
||||
#define CR4_LA57 (1u << 12) /* enable level-5 paging */
|
||||
#define CR4_VMXE (1u << 13) /* enable VMX operations */
|
||||
#define CR4_SMXE (1u << 14) /* enable SMX operations */
|
||||
#define CR4_FSGSBASE (1u << 16) /* enable *FSBASE and *GSBASE instructions */
|
||||
#define CR4_PCIDE (1u << 17) /* enable process-context identifiers */
|
||||
#define CR4_OSXSAVE (1u << 18) /* enable XSAVE */
|
||||
|
||||
#define XCR0_X87 (1u << 0)
|
||||
#define XCR0_SSE (1u << 1)
|
||||
#define XCR0_AVX (1u << 2)
|
||||
#define XCR0_BNDREG (1u << 3)
|
||||
#define XCR0_BNDCSR (1u << 4)
|
||||
#define XCR0_OPMASK (1u << 5)
|
||||
#define XCR0_ZMM_HI256 (1u << 6)
|
||||
#define XCR0_HI16_ZMM (1u << 7)
|
||||
|
||||
#define EFER 0xC0000080 /* extended feature enable register */
|
||||
#define EFER_SCE (1u << 0) /* system call extensions */
|
||||
#define EFER_LME (1u << 8) /* long mode enable */
|
||||
#define EFER_LMA (1u << 10) /* long mode active */
|
||||
#define EFER_NXE (1u << 11) /* no-execute enable */
|
||||
|
||||
#define GDT_REAL_CODE 8
|
||||
#define GDT_REAL_DATA 16
|
||||
#define GDT_LEGACY_CODE 24
|
||||
#define GDT_LEGACY_DATA 32
|
||||
#define GDT_LONG_CODE 40
|
||||
#define GDT_LONG_DATA 48
|
||||
|
||||
#define PIC1 0x20 /* IO base address for master PIC */
|
||||
#define PIC2 0xA0 /* IO base address for slave PIC */
|
||||
#define PIC1_CMD PIC1
|
||||
#define PIC1_DATA (PIC1 + 1)
|
||||
#define PIC2_CMD PIC2
|
||||
#define PIC2_DATA (PIC2 + 1)
|
||||
#define PIC_EOI 0x20 /* End-of-interrupt command code */
|
||||
#define PIC_READ_IRR 0x0a /* OCW3 irq ready next CMD read */
|
||||
#define PIC_READ_ISR 0x0b /* OCW3 irq service next CMD read */
|
||||
|
||||
/* Long Mode Paging
|
||||
@see Intel Manual V.3A §4.1 §4.5
|
||||
IsValid (ignored on CR3) V┐
|
||||
┌XD:No Inst. Fetches (if NXE) IsWritable (ignored on CR3) RW┐│
|
||||
│ Permit User-Mode Access - u┐││
|
||||
│ Page-level Write-Through - PWT┐│││
|
||||
│ Page-level Cache Disable - PCD┐││││
|
||||
│ Set if has been read - Accessed┐│││││
|
||||
│ Set if has been written - Dirty┐││││││
|
||||
│ IsPage (if PDPTE/PDE) or PAT (if PT)┐│││││││
|
||||
│ (If this maps 2MB/1GB page and CR4.PGE) Global┐││││││││
|
||||
│ (If IsPage 2MB/1GB, see Intel V3A § 11.12) PAT │││││││││
|
||||
│ │ │││││││││
|
||||
│ ┌────────────────────────────────────┤ │││││││││
|
||||
│ Must Be 0┐│ Next Page Table Address (!IsPage) │ │││││││││
|
||||
│ │├────────────────────────────────────┤ │││││││││
|
||||
│ ││ Physical Address 4KB │ │││││││││
|
||||
│┌───┐┌─────┐│├───────────────────────────┐ │ign│││││││││
|
||||
││PKE││ ign │││ Physical Address 2MB │ │┌┴┐│││││││││
|
||||
││ ││ ││├──────────────────┐ │ ││ ││││││││││
|
||||
││ ││ │││ Phys. Addr. 1GB │ │ ││ ││││││││││
|
||||
││ ││ │││ │ │ ││ ││││││││││
|
||||
6666555555555544444444443333333333222222222211111111110000000000
|
||||
3210987654321098765432109876543210987654321098765432109876543210*/
|
||||
#define PAGE_V /* */ 0b000000001
|
||||
#define PAGE_RW /* */ 0b000000010
|
||||
#define PAGE_U /* */ 0b000000100
|
||||
#define PAGE_4KB /* */ 0b010000000
|
||||
#define PAGE_2MB /* */ 0b110000000
|
||||
#define PAGE_1GB /* */ 0b110000000
|
||||
#define PAGE_TA 0b11111111111111111111111111111111111111000000000000
|
||||
#define PAGE_PA2 0b11111111111111111111111111111000000000000000000000
|
||||
#define PAGE_XD 0x8000000000000000
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
#include "ape/config.h"
|
||||
|
||||
struct thatispacked GlobalDescriptorTable {
|
||||
uint16_t size;
|
||||
uint64_t *entries;
|
||||
};
|
||||
|
||||
/**
|
||||
* Memory hole map.
|
||||
* @see wiki.osdev.org/Detecting_Memory_(x86)
|
||||
* @since 2002
|
||||
*/
|
||||
struct SmapEntry {
|
||||
uint64_t addr;
|
||||
uint64_t size;
|
||||
enum {
|
||||
kMemoryUsable = 1,
|
||||
kMemoryUnusable = 2,
|
||||
kMemoryAcpiReclaimable = 3,
|
||||
kMemoryAcpiNvs = 4,
|
||||
kMemoryBad = 5
|
||||
} type;
|
||||
uint32_t __acpi3; /* is abstracted */
|
||||
};
|
||||
|
||||
struct IdtDescriptor {
|
||||
uint16_t offset_1; /* offset bits 0..15 */
|
||||
uint16_t selector; /* a code segment selector in GDT or LDT */
|
||||
uint8_t ist; /* bits 0..2 hold stack table offset, rest are zero */
|
||||
uint8_t type_attr; /* type and attributes */
|
||||
uint16_t offset_2; /* offset bits 16..31 */
|
||||
uint32_t offset_3; /* offset bits 32..63 */
|
||||
uint32_t zero; /* reserved */
|
||||
};
|
||||
|
||||
struct thatispacked PageTable {
|
||||
uint64_t p[512];
|
||||
} aligned(PAGESIZE);
|
||||
|
||||
extern struct PageTable g_pml4t;
|
||||
extern struct GlobalDescriptorTable gdt;
|
||||
|
||||
extern const unsigned char kBiosDataArea[256];
|
||||
extern const unsigned char kBiosDataAreaXlm[256];
|
||||
|
||||
extern struct SmapEntry e820map[XLM_E820_SIZE / sizeof(struct SmapEntry)];
|
||||
extern struct SmapEntry e820map_xlm[XLM_E820_SIZE / sizeof(struct SmapEntry)];
|
||||
|
||||
extern uint64_t g_ptsp;
|
||||
extern uint64_t g_ptsp_xlm;
|
||||
|
||||
void bootdr(char drive) noreturn;
|
||||
|
||||
void smapsort(struct SmapEntry *);
|
||||
uint64_t *getpagetableentry(int64_t, unsigned, struct PageTable *, uint64_t *);
|
||||
void flattenhighmemory(struct SmapEntry *, struct PageTable *, uint64_t *);
|
||||
void pageunmap(int64_t);
|
||||
|
||||
forceinline unsigned long eflags(void) {
|
||||
unsigned long res;
|
||||
asm("pushf\n\t"
|
||||
"pop\t%0"
|
||||
: "=rm"(res));
|
||||
return res;
|
||||
}
|
||||
|
||||
forceinline unsigned char inb(unsigned short port) {
|
||||
unsigned char al;
|
||||
asm volatile("inb\t%1,%0" : "=a"(al) : "dN"(port));
|
||||
return al;
|
||||
}
|
||||
|
||||
forceinline void outb(unsigned short port, unsigned char byte) {
|
||||
asm volatile("outb\t%0,%1"
|
||||
: /* no inputs */
|
||||
: "a"(byte), "dN"(port));
|
||||
}
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* APE_LIB_PC_H_ */
|
||||
-140
@@ -1,140 +0,0 @@
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/lib/pc.h"
|
||||
|
||||
#define ICW1_ICW4 0x01 /* ICW4 (not) needed */
|
||||
#define ICW1_SINGLE 0x02 /* Single (cascade) mode */
|
||||
#define ICW1_INTERVAL4 0x04 /* Call address interval 4 (8) */
|
||||
#define ICW1_LEVEL 0x08 /* Level triggered (edge) mode */
|
||||
#define ICW1_INIT 0x10 /* Initialization - required! */
|
||||
|
||||
#define ICW4_8086 0x01 /* 8086/88 (MCS-80/85) mode */
|
||||
#define ICW4_AUTO 0x02 /* Auto (normal) EOI */
|
||||
#define ICW4_BUF_SLAVE 0x08 /* Buffered mode/slave */
|
||||
#define ICW4_BUF_MASTER 0x0C /* Buffered mode/master */
|
||||
#define ICW4_SFNM 0x10 /* Special fully nested (not) */
|
||||
|
||||
static inline void io_wait(void) {
|
||||
/* Magic technique from Linux, according to:
|
||||
* wiki.osdev.org/index.php?title=Inline_Assembly/Examples&oldid=23541
|
||||
*/
|
||||
outb(0x80, 0);
|
||||
}
|
||||
|
||||
void PIC_sendEOI(unsigned char irq) {
|
||||
if (irq >= 8) outb(PIC2_CMD, PIC_EOI);
|
||||
outb(PIC1_CMD, PIC_EOI);
|
||||
}
|
||||
|
||||
bool AreInterruptsEnabled() {
|
||||
return (eflags() & kInterruptFlag) == kInterruptFlag;
|
||||
}
|
||||
|
||||
nodiscard forceinline unsigned long irqdisable(void) {
|
||||
unsigned long eflags;
|
||||
asm("pushf\n\t"
|
||||
"cli\n\t"
|
||||
"pop\t%0"
|
||||
: "=r"(eflags)
|
||||
: /* no inputs */
|
||||
: "cc");
|
||||
return eflags;
|
||||
}
|
||||
|
||||
forceinline void irqrestore(unsigned long eflags) {
|
||||
asm volatile(
|
||||
"push\t%0\n\t"
|
||||
"popf"
|
||||
: /* no outputs */
|
||||
: "rm"(eflags)
|
||||
: "cc");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param offset1 is vector offset for master PIC
|
||||
* vectors on the master become offset1..offset1+7
|
||||
* @param offset2 is same for slave PIC: offset2..offset2+7
|
||||
**/
|
||||
void PIC_remap(int offset1, int offset2) {
|
||||
unsigned char a1, a2;
|
||||
a1 = inb(PIC1_DATA); // save masks
|
||||
a2 = inb(PIC2_DATA);
|
||||
outb(PIC1_CMD,
|
||||
ICW1_INIT |
|
||||
ICW1_ICW4); // starts the initialization sequence (in cascade mode)
|
||||
io_wait();
|
||||
outb(PIC2_CMD, ICW1_INIT | ICW1_ICW4);
|
||||
io_wait();
|
||||
outb(PIC1_DATA, offset1); // ICW2: Master PIC vector offset
|
||||
io_wait();
|
||||
outb(PIC2_DATA, offset2); // ICW2: Slave PIC vector offset
|
||||
io_wait();
|
||||
outb(PIC1_DATA, 4); // ICW3: tell Master PIC that there is a slave PIC at
|
||||
// IRQ2 (0000 0100)
|
||||
io_wait();
|
||||
outb(PIC2_DATA, 2); // ICW3: tell Slave PIC its cascade identity (0000 0010)
|
||||
io_wait();
|
||||
outb(PIC1_DATA, ICW4_8086);
|
||||
io_wait();
|
||||
outb(PIC2_DATA, ICW4_8086);
|
||||
io_wait();
|
||||
outb(PIC1_DATA, a1); // restore saved masks.
|
||||
outb(PIC2_DATA, a2);
|
||||
}
|
||||
|
||||
void IRQ_set_mask(unsigned char IRQline) {
|
||||
uint16_t port;
|
||||
uint8_t value;
|
||||
if (IRQline < 8) {
|
||||
port = PIC1_DATA;
|
||||
} else {
|
||||
port = PIC2_DATA;
|
||||
IRQline -= 8;
|
||||
}
|
||||
value = inb(port) | (1 << IRQline);
|
||||
outb(port, value);
|
||||
}
|
||||
|
||||
void IRQ_clear_mask(unsigned char IRQline) {
|
||||
uint16_t port;
|
||||
uint8_t value;
|
||||
if (IRQline < 8) {
|
||||
port = PIC1_DATA;
|
||||
} else {
|
||||
port = PIC2_DATA;
|
||||
IRQline -= 8;
|
||||
}
|
||||
value = inb(port) & ~(1 << IRQline);
|
||||
outb(port, value);
|
||||
}
|
||||
|
||||
static uint16_t __pic_get_irq_reg(int ocw3) {
|
||||
/* OCW3 to PIC CMD to get the register values. PIC2 is chained, and
|
||||
* represents IRQs 8-15. PIC1 is IRQs 0-7, with 2 being the chain */
|
||||
outb(PIC1_CMD, ocw3);
|
||||
outb(PIC2_CMD, ocw3);
|
||||
return (inb(PIC2_CMD) << 8) | inb(PIC1_CMD);
|
||||
}
|
||||
|
||||
/* Returns the combined value of the cascaded PICs irq request register */
|
||||
uint16_t pic_get_irr(void) { return __pic_get_irq_reg(PIC_READ_IRR); }
|
||||
|
||||
/* Returns the combined value of the cascaded PICs in-service register */
|
||||
uint16_t pic_get_isr(void) { return __pic_get_irq_reg(PIC_READ_ISR); }
|
||||
@@ -1,47 +0,0 @@
|
||||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/lib/pc.h"
|
||||
|
||||
textreal static unsigned smapcount(const struct SmapEntry *se) {
|
||||
unsigned i = 0;
|
||||
while (se[i].size) ++i;
|
||||
return i;
|
||||
}
|
||||
|
||||
textreal static void smapsorter(size_t n, struct SmapEntry a[n]) {
|
||||
struct SmapEntry t;
|
||||
unsigned i, j;
|
||||
for (i = 1; i < n; ++i) {
|
||||
j = i;
|
||||
t = a[i];
|
||||
while (j > 0 && (intptr_t)t.addr - (intptr_t)a[j - 1].addr) {
|
||||
a[j] = a[j - 1];
|
||||
--j;
|
||||
}
|
||||
a[j] = t;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts BIOS e820 memory map.
|
||||
*/
|
||||
textreal void smapsort(struct SmapEntry *smap) {
|
||||
smapsorter(smapcount(smap), smap);
|
||||
}
|
||||
-281
@@ -1,281 +0,0 @@
|
||||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╠──────────────────────────────────────────────────────────────────────────────╣
|
||||
│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░█▀█░█▀█░▀█▀░█░█░█▀█░█░░░█░░░█░█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░█▀█░█░▄░░█░░█░█░█▀█░█░░░█░░░▀█▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░▀░▀░▀▀▀░░▀░░▀▀▀░▀░▀░▀▀▀░▀▀▀░░▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░█▀█░█▀█░█▀█░▀█▀░█▀█░█▀█░█░░░█▀▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░█▀▀░█ █░██▀░░█░░█▀█░█▀█░█░░░█▀▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░▀░░░▀▀▀░▀░▀░░▀░░▀░▀░▀▀▀░▀▀▀░▀▀▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
|
||||
│░░░░░░░█▀▀░█░█░█▀▀░█▀█░█░█░▀█▀░█▀█░█▀█░█░░█▀▀░░░░░░░░░░░░░░░░░░░░░░░░▄▄░░░▐█░░│
|
||||
│░░░░░░░█▀▀░▄▀▄░█▀▀░█░▄░█░█░░█░░█▀█░█▀█░█░░█▀▀░░░░░░░░░░░░▄▄▄░░░▄██▄░░█▀░░░█░▄░│
|
||||
│░░░░░░░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀▀▀░░▀░░▀░▀░▀▀▀░▀▀░▀▀▀░░░░░░░░░░▄██▀█▌░██▄▄░░▐█▀▄░▐█▀░░│
|
||||
│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▐█▀▀▌░░░▄▀▌░▌░█░▌░░▌░▌░░│
|
||||
╠──────────────────────────────────────────────────────▌▀▄─▐──▀▄─▐▄─▐▄▐▄─▐▄─▐▄─│
|
||||
│ αcτµαlly pδrταblε εxεcµταblε § macros │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#ifndef APE_MACROS_H_
|
||||
#define APE_MACROS_H_
|
||||
#include "libc/macros.h"
|
||||
#ifdef __ASSEMBLER__
|
||||
/* clang-format off */
|
||||
|
||||
/**
|
||||
* @fileoverview Macros relevant to αcτµαlly pδrταblε εxεcµταblε.
|
||||
*/
|
||||
|
||||
/ Calls near (i.e. pc+pcrel<64kB) FUNCTION.
|
||||
/ @mode long,legacy,real
|
||||
/ @cost 9 bytes overhead
|
||||
.macro rlcall function:req
|
||||
.byte 0x50 # push %[er]ax
|
||||
.byte 0xb8,0,0 # mov $?,%[e]ax
|
||||
jmp 911f
|
||||
.byte 0x58 # pop %[er]ax
|
||||
.byte 0xe8 # call Jvds
|
||||
.long \function\()-.-4
|
||||
jmp 912f
|
||||
911: .byte 0x58 # pop %[er]ax
|
||||
.byte 0xe8 # call Jvds
|
||||
.short \function\()-.-2
|
||||
912:
|
||||
.endm
|
||||
|
||||
/ Loads far (i.e. <1mb) abs constexpr ADDRESS into ES:DI+EDX+RDX.
|
||||
/ @mode long,legacy,real
|
||||
.macro movesdi address:req
|
||||
.byte 0xbf # mov $0x????xxxx,%[e]di
|
||||
.short \address>>4
|
||||
.byte 0x8e,0xc7 # mov %di,%es
|
||||
.byte 0xbf # mov $0x????xxxx,%[e]di
|
||||
.short \address&0xf
|
||||
jmp 297f
|
||||
.byte 0xbf # mov $0x????xxxx,%edi
|
||||
.long \address
|
||||
297:
|
||||
.endm
|
||||
|
||||
/ Loads 16-bit CONSTEXPR into Qw-register w/ optional zero-extend.
|
||||
/ @mode long,legacy,real
|
||||
.macro bbmov constexpr:req abcd abcd.hi:req abcd.lo:req
|
||||
.ifnb \abcd
|
||||
.if (\constexpr)<128 && (\constexpr)>=0
|
||||
pushpop \constexpr,\abcd
|
||||
.exitm
|
||||
.endif
|
||||
.endif
|
||||
movb $(\constexpr)>>8&0xff,\abcd.hi
|
||||
movb $(\constexpr)&0xff,\abcd.lo
|
||||
.endm
|
||||
|
||||
/ Compares 16-bit CONSTEXPR with Qw-register.
|
||||
/ @mode long,legacy,real
|
||||
.macro bbcmp constexpr:req abcd.hi:req abcd.lo:req
|
||||
cmpb $(\constexpr)>>8&0xff,\abcd.hi
|
||||
jnz 387f
|
||||
cmpb $(\constexpr)&0xff,\abcd.lo
|
||||
387:
|
||||
.endm
|
||||
|
||||
/ Adds 16-bit CONSTEXPR to Qw-register.
|
||||
/ @mode long,legacy,real
|
||||
.macro bbadd constexpr:req abcd.hi:req abcd.lo:req
|
||||
addb $(\constexpr)&0xff,\abcd.lo
|
||||
.if (\constexpr) != 0
|
||||
adcb $(\constexpr)>>8&0xff,\abcd.hi
|
||||
.endif
|
||||
.endm
|
||||
|
||||
/ Subtracts 16-bit CONSTEXPR from Qw-register.
|
||||
/ @mode long,legacy,real
|
||||
.macro bbsub constexpr:req abcd.hi:req abcd.lo:req
|
||||
subb $(\constexpr)&0xff,\abcd.lo
|
||||
.if (\constexpr) != 0
|
||||
sbbb $(\constexpr)>>8&0xff,\abcd.hi
|
||||
.endif
|
||||
.endm
|
||||
|
||||
/ Ands Qw-register with 16-bit CONSTEXPR.
|
||||
/ @mode long,legacy,real
|
||||
.macro bband constexpr:req abcd.hi:req abcd.lo:req
|
||||
.if ((\constexpr)&0xff) != 0xff || ((\constexpr)>>8&0xff) == 0xff
|
||||
andb $(\constexpr)&0xff,\abcd.lo
|
||||
.endif
|
||||
.if ((\constexpr)>>8&0xff) != 0xff
|
||||
andb $(\constexpr)>>8&0xff,\abcd.hi
|
||||
.endif
|
||||
.endm
|
||||
|
||||
/ Ors Qw-register with 16-bit CONSTEXPR.
|
||||
/ @mode long,legacy,real
|
||||
.macro bbor constexpr:req abcd.hi:req abcd.lo:req
|
||||
.if ((\constexpr)&0xff) != 0 || ((\constexpr)>>8&0xff) != 0
|
||||
orb $(\constexpr)&0xff,\abcd.lo
|
||||
.endif
|
||||
.if ((\constexpr)>>8&0xff) != 0
|
||||
orb $(\constexpr)>>8&0xff,\abcd.hi
|
||||
.endif
|
||||
.endm
|
||||
|
||||
/ Performs ACTION only if in real mode.
|
||||
/ @mode long,legacy,real
|
||||
.macro rlo clobber:req action:vararg
|
||||
990: mov $0,\clobber
|
||||
.if .-990b!=3
|
||||
.error "bad clobber or assembler mode"
|
||||
.endif
|
||||
991: \action
|
||||
.rept 2-(.-991b)
|
||||
nop
|
||||
.endr
|
||||
.if .-991b!=2
|
||||
.error "ACTION must be 1-2 bytes"
|
||||
.endif
|
||||
.endm
|
||||
|
||||
/ Initializes real mode stack.
|
||||
/ The most holiest of holy code.
|
||||
/ @mode real
|
||||
/ @see www.pcjs.org/pubs/pc/reference/intel/8086/
|
||||
.macro rlstack seg:req addr:req
|
||||
cli
|
||||
mov \seg,%ss
|
||||
mov \addr,%sp
|
||||
sti
|
||||
.endm
|
||||
|
||||
/ Symbolic Linker-Defined Binary Content.
|
||||
.macro .stub name:req kind:req default type=@object
|
||||
.ifnb \default
|
||||
.equ \name,\default
|
||||
.endif
|
||||
.\kind \name
|
||||
.type \name,\type
|
||||
.weak \name
|
||||
.hidden \name
|
||||
.endm
|
||||
|
||||
/ Symbolic Linker-Defined Binary-Encoded-Bourne Content.
|
||||
/ @param units is the number of encoded 32-bit values to insert,
|
||||
/ e.g. \000 can be encoded as 0x3030305c.
|
||||
.macro .shstub name:req units:req
|
||||
ss \name,0
|
||||
.if \units>1
|
||||
ss \name,1
|
||||
.if \units>2
|
||||
ss \name,2
|
||||
ss \name,3
|
||||
.if \units>4
|
||||
ss \name,4
|
||||
ss \name,5
|
||||
ss \name,6
|
||||
ss \name,7
|
||||
.endif
|
||||
.endif
|
||||
.endif
|
||||
.endm
|
||||
.macro ss name n
|
||||
.stub \name\()_bcs\n,long
|
||||
.endm
|
||||
|
||||
/* clang-format on */
|
||||
#elif defined(__LINKER__)
|
||||
|
||||
#define BCX_NIBBLE(X) ((((X)&0xf) > 0x9) ? ((X)&0xf) + 0x37 : ((X)&0xf) + 0x30)
|
||||
#define BCX_OCTET(X) ((BCX_NIBBLE((X) >> 4) << 8) | (BCX_NIBBLE((X) >> 0) << 0))
|
||||
#define BCX_INT16(X) ((BCX_OCTET((X) >> 8) << 16) | (BCX_OCTET((X) >> 0) << 0))
|
||||
#define BCXSTUB(SYM, X) \
|
||||
HIDDEN(SYM##_bcx0 = BCX_INT16((X) >> 48)); \
|
||||
HIDDEN(SYM##_bcx1 = BCX_INT16((X) >> 32)); \
|
||||
HIDDEN(SYM##_bcx2 = BCX_INT16((X) >> 16)); \
|
||||
HIDDEN(SYM##_bcx3 = BCX_INT16((X) >> 0))
|
||||
|
||||
/**
|
||||
* Binary coded backslash octet support.
|
||||
*
|
||||
* <p>This allows linker scripts to generate printf commands.
|
||||
*/
|
||||
#define BCO_OCTET(X) (((X)&0x7) + 0x30)
|
||||
#define BCOB_UNIT(X) \
|
||||
((BCO_OCTET((X) >> 0) << 24) | (BCO_OCTET((X) >> 3) << 16) | \
|
||||
(BCO_OCTET(((X)&0xff) >> 6) << 8) | 0x5c)
|
||||
|
||||
#define PFBYTE(SYM, X, I) HIDDEN(SYM##_bcs##I = BCOB_UNIT((X) >> ((I)*8)))
|
||||
#define PFSTUB2(SYM, X) \
|
||||
HIDDEN(SYM = (X)); \
|
||||
PFBYTE(SYM, X, 0); \
|
||||
PFBYTE(SYM, X, 1)
|
||||
#define PFSTUB4(SYM, X) \
|
||||
PFSTUB2(SYM, X); \
|
||||
PFBYTE(SYM, X, 2); \
|
||||
PFBYTE(SYM, X, 3)
|
||||
#define PFSTUB8(SYM, X) \
|
||||
PFSTUB4(SYM, X); \
|
||||
PFBYTE(SYM, X, 4); \
|
||||
PFBYTE(SYM, X, 5); \
|
||||
PFBYTE(SYM, X, 6); \
|
||||
PFBYTE(SYM, X, 7)
|
||||
|
||||
/**
|
||||
* Binary coded decimal support.
|
||||
*
|
||||
* <p>This allows linker scripts to generate dd commands. Leading spaces
|
||||
* need to be inserted so Mac doesn't consider them octal; therefore,
|
||||
* parameters must be quoted; and eight digits should be good enough.
|
||||
*/
|
||||
#define SHSTUB2(SYM, X) \
|
||||
HIDDEN(SYM##_bcs0 = BCD10K(X)); \
|
||||
HIDDEN(SYM##_bcs1 = BCD(X))
|
||||
#define BCD(X) \
|
||||
((X) == 0 \
|
||||
? 0x20202030 \
|
||||
: (X) < 10 ? 0x30202020 + (((X) % 10) << 24) \
|
||||
: (X) < 100 ? 0x30302020 + (((X) % 10) << 24) + \
|
||||
(((X) / 10 % 10) << 16) \
|
||||
: (X) < 1000 ? 0x30303020 + (((X) % 10) << 24) + \
|
||||
(((X) / 10 % 10) << 16) + \
|
||||
(((X) / 100 % 10) << 8) \
|
||||
: 0x30303030 + (((X) % 10) << 24) + \
|
||||
(((X) / 10 % 10) << 16) + \
|
||||
(((X) / 100 % 10) << 8) + \
|
||||
(((X) / 1000 % 10) << 0))
|
||||
#define BCD10K(X) \
|
||||
((X) < 10000 \
|
||||
? 0x20202020 \
|
||||
: (X) < 100000 \
|
||||
? 0x30202020 + (((X) / 10000 % 10) << 24) \
|
||||
: (X) < 1000000 \
|
||||
? 0x30302020 + (((X) / 10000 % 10) << 24) + \
|
||||
(((X) / 100000 % 10) << 16) \
|
||||
: (X) < 10000000 \
|
||||
? 0x30303020 + (((X) / 10000 % 10) << 24) + \
|
||||
(((X) / 100000 % 10) << 16) + \
|
||||
(((X) / 1000000 % 10) << 8) \
|
||||
: (X) < 100000000 \
|
||||
? 0x30303030 + (((X) / 10000 % 10) << 24) + \
|
||||
(((X) / 100000 % 10) << 16) + \
|
||||
(((X) / 1000000 % 10) << 8) + \
|
||||
(((X) / 10000000 % 10) << 0) \
|
||||
: 0xffffffffffffffff)
|
||||
|
||||
#endif /* __ASSEMBLER__ */
|
||||
#endif /* APE_MACROS_H_ */
|
||||
@@ -0,0 +1,264 @@
|
||||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#ifndef APE_MACROS_H_
|
||||
#define APE_MACROS_H_
|
||||
#include "libc/macros.internal.h"
|
||||
#ifdef __ASSEMBLER__
|
||||
/* clang-format off */
|
||||
|
||||
/**
|
||||
* @fileoverview Macros relevant to αcτµαlly pδrταblε εxεcµταblε.
|
||||
*/
|
||||
|
||||
// Calls near (i.e. pc+pcrel<64kB) FUNCTION.
|
||||
// @mode long,legacy,real
|
||||
// @cost 9 bytes overhead
|
||||
.macro rlcall function:req
|
||||
.byte 0x50 # push %[er]ax
|
||||
.byte 0xb8,0,0 # mov $?,%[e]ax
|
||||
jmp 911f
|
||||
.byte 0x58 # pop %[er]ax
|
||||
.byte 0xe8 # call Jvds
|
||||
.long \function\()-.-4
|
||||
jmp 912f
|
||||
911: .byte 0x58 # pop %[er]ax
|
||||
.byte 0xe8 # call Jvds
|
||||
.short \function\()-.-2
|
||||
912:
|
||||
.endm
|
||||
|
||||
// Loads far (i.e. <1mb) abs constexpr ADDRESS into ES:DI+EDX+RDX.
|
||||
// @mode long,legacy,real
|
||||
.macro movesdi address:req
|
||||
.byte 0xbf # mov $0x????xxxx,%[e]di
|
||||
.short \address>>4
|
||||
.byte 0x8e,0xc7 # mov %di,%es
|
||||
.byte 0xbf # mov $0x????xxxx,%[e]di
|
||||
.short \address&0xf
|
||||
jmp 297f
|
||||
.byte 0xbf # mov $0x????xxxx,%edi
|
||||
.long \address
|
||||
297:
|
||||
.endm
|
||||
|
||||
// Loads 16-bit CONSTEXPR into Qw-register w/ optional zero-extend.
|
||||
// @mode long,legacy,real
|
||||
.macro bbmov constexpr:req abcd abcd.hi:req abcd.lo:req
|
||||
.ifnb \abcd
|
||||
.if (\constexpr)<128 && (\constexpr)>=0
|
||||
pushpop \constexpr,\abcd
|
||||
.exitm
|
||||
.endif
|
||||
.endif
|
||||
movb $(\constexpr)>>8&0xff,\abcd.hi
|
||||
movb $(\constexpr)&0xff,\abcd.lo
|
||||
.endm
|
||||
|
||||
// Compares 16-bit CONSTEXPR with Qw-register.
|
||||
// @mode long,legacy,real
|
||||
.macro bbcmp constexpr:req abcd.hi:req abcd.lo:req
|
||||
cmpb $(\constexpr)>>8&0xff,\abcd.hi
|
||||
jnz 387f
|
||||
cmpb $(\constexpr)&0xff,\abcd.lo
|
||||
387:
|
||||
.endm
|
||||
|
||||
// Adds 16-bit CONSTEXPR to Qw-register.
|
||||
// @mode long,legacy,real
|
||||
.macro bbadd constexpr:req abcd.hi:req abcd.lo:req
|
||||
addb $(\constexpr)&0xff,\abcd.lo
|
||||
.if (\constexpr) != 0
|
||||
adcb $(\constexpr)>>8&0xff,\abcd.hi
|
||||
.endif
|
||||
.endm
|
||||
|
||||
// Subtracts 16-bit CONSTEXPR from Qw-register.
|
||||
// @mode long,legacy,real
|
||||
.macro bbsub constexpr:req abcd.hi:req abcd.lo:req
|
||||
subb $(\constexpr)&0xff,\abcd.lo
|
||||
.if (\constexpr) != 0
|
||||
sbbb $(\constexpr)>>8&0xff,\abcd.hi
|
||||
.endif
|
||||
.endm
|
||||
|
||||
// Ands Qw-register with 16-bit CONSTEXPR.
|
||||
// @mode long,legacy,real
|
||||
.macro bband constexpr:req abcd.hi:req abcd.lo:req
|
||||
.if ((\constexpr)&0xff) != 0xff || ((\constexpr)>>8&0xff) == 0xff
|
||||
andb $(\constexpr)&0xff,\abcd.lo
|
||||
.endif
|
||||
.if ((\constexpr)>>8&0xff) != 0xff
|
||||
andb $(\constexpr)>>8&0xff,\abcd.hi
|
||||
.endif
|
||||
.endm
|
||||
|
||||
// Ors Qw-register with 16-bit CONSTEXPR.
|
||||
// @mode long,legacy,real
|
||||
.macro bbor constexpr:req abcd.hi:req abcd.lo:req
|
||||
.if ((\constexpr)&0xff) != 0 || ((\constexpr)>>8&0xff) != 0
|
||||
orb $(\constexpr)&0xff,\abcd.lo
|
||||
.endif
|
||||
.if ((\constexpr)>>8&0xff) != 0
|
||||
orb $(\constexpr)>>8&0xff,\abcd.hi
|
||||
.endif
|
||||
.endm
|
||||
|
||||
// Performs ACTION only if in real mode.
|
||||
// @mode long,legacy,real
|
||||
.macro rlo clobber:req action:vararg
|
||||
990: mov $0,\clobber
|
||||
.if .-990b!=3
|
||||
.error "bad clobber or assembler mode"
|
||||
.endif
|
||||
991: \action
|
||||
.rept 2-(.-991b)
|
||||
nop
|
||||
.endr
|
||||
.if .-991b!=2
|
||||
.error "ACTION must be 1-2 bytes"
|
||||
.endif
|
||||
.endm
|
||||
|
||||
// Initializes real mode stack.
|
||||
// The most holiest of holy code.
|
||||
// @mode real
|
||||
// @see www.pcjs.org/pubs/pc/reference/intel/8086/
|
||||
.macro rlstack seg:req addr:req
|
||||
cli
|
||||
mov \seg,%ss
|
||||
mov \addr,%sp
|
||||
sti
|
||||
.endm
|
||||
|
||||
// Symbolic Linker-Defined Binary Content.
|
||||
.macro .stub name:req kind:req default type=@object
|
||||
.ifnb \default
|
||||
.equ \name,\default
|
||||
.endif
|
||||
.\kind \name
|
||||
.type \name,\type
|
||||
.weak \name
|
||||
.hidden \name
|
||||
.endm
|
||||
|
||||
// Symbolic Linker-Defined Binary-Encoded-Bourne Content.
|
||||
// @param units is the number of encoded 32-bit values to insert,
|
||||
// e.g. \000 can be encoded as 0x3030305c.
|
||||
.macro .shstub name:req num:req
|
||||
ss \name,0
|
||||
.if \num>1
|
||||
ss \name,1
|
||||
.if \num>2
|
||||
ss \name,2
|
||||
ss \name,3
|
||||
.if \num>4
|
||||
ss \name,4
|
||||
ss \name,5
|
||||
ss \name,6
|
||||
ss \name,7
|
||||
.endif
|
||||
.endif
|
||||
.endif
|
||||
.endm
|
||||
.macro ss name n
|
||||
.stub \name\()_bcs\n,long
|
||||
.endm
|
||||
|
||||
/* clang-format on */
|
||||
#elif defined(__LINKER__)
|
||||
|
||||
#define BCX_NIBBLE(X) ((((X)&0xf) > 0x9) ? ((X)&0xf) + 0x37 : ((X)&0xf) + 0x30)
|
||||
#define BCX_OCTET(X) ((BCX_NIBBLE((X) >> 4) << 8) | (BCX_NIBBLE((X) >> 0) << 0))
|
||||
#define BCX_INT16(X) ((BCX_OCTET((X) >> 8) << 16) | (BCX_OCTET((X) >> 0) << 0))
|
||||
#define BCXSTUB(SYM, X) \
|
||||
HIDDEN(SYM##_bcx0 = BCX_INT16((X) >> 48)); \
|
||||
HIDDEN(SYM##_bcx1 = BCX_INT16((X) >> 32)); \
|
||||
HIDDEN(SYM##_bcx2 = BCX_INT16((X) >> 16)); \
|
||||
HIDDEN(SYM##_bcx3 = BCX_INT16((X) >> 0))
|
||||
|
||||
/**
|
||||
* Binary coded backslash octet support.
|
||||
*
|
||||
* <p>This allows linker scripts to generate printf commands.
|
||||
*/
|
||||
#define BCO_OCTET(X) (((X)&0x7) + 0x30)
|
||||
#define BCOB_UNIT(X) \
|
||||
((BCO_OCTET((X) >> 0) << 24) | (BCO_OCTET((X) >> 3) << 16) | \
|
||||
(BCO_OCTET(((X)&0xff) >> 6) << 8) | 0x5c)
|
||||
|
||||
#define PFBYTE(SYM, X, I) HIDDEN(SYM##_bcs##I = BCOB_UNIT((X) >> ((I)*8)))
|
||||
#define PFSTUB2(SYM, X) \
|
||||
HIDDEN(SYM = (X)); \
|
||||
PFBYTE(SYM, X, 0); \
|
||||
PFBYTE(SYM, X, 1)
|
||||
#define PFSTUB4(SYM, X) \
|
||||
PFSTUB2(SYM, X); \
|
||||
PFBYTE(SYM, X, 2); \
|
||||
PFBYTE(SYM, X, 3)
|
||||
#define PFSTUB8(SYM, X) \
|
||||
PFSTUB4(SYM, X); \
|
||||
PFBYTE(SYM, X, 4); \
|
||||
PFBYTE(SYM, X, 5); \
|
||||
PFBYTE(SYM, X, 6); \
|
||||
PFBYTE(SYM, X, 7)
|
||||
|
||||
/**
|
||||
* Binary coded decimal support.
|
||||
*
|
||||
* <p>This allows linker scripts to generate dd commands. Leading spaces
|
||||
* need to be inserted so Mac doesn't consider them octal; therefore,
|
||||
* parameters must be quoted; and eight digits should be good enough.
|
||||
*/
|
||||
#define SHSTUB2(SYM, X) \
|
||||
HIDDEN(SYM##_bcs0 = BCD10K(X)); \
|
||||
HIDDEN(SYM##_bcs1 = BCD(X))
|
||||
#define BCD(X) \
|
||||
((X) == 0 \
|
||||
? 0x20202030 \
|
||||
: (X) < 10 ? 0x30202020 + (((X) % 10) << 24) \
|
||||
: (X) < 100 ? 0x30302020 + (((X) % 10) << 24) + \
|
||||
(((X) / 10 % 10) << 16) \
|
||||
: (X) < 1000 ? 0x30303020 + (((X) % 10) << 24) + \
|
||||
(((X) / 10 % 10) << 16) + \
|
||||
(((X) / 100 % 10) << 8) \
|
||||
: 0x30303030 + (((X) % 10) << 24) + \
|
||||
(((X) / 10 % 10) << 16) + \
|
||||
(((X) / 100 % 10) << 8) + \
|
||||
(((X) / 1000 % 10) << 0))
|
||||
#define BCD10K(X) \
|
||||
((X) < 10000 \
|
||||
? 0x20202020 \
|
||||
: (X) < 100000 \
|
||||
? 0x30202020 + (((X) / 10000 % 10) << 24) \
|
||||
: (X) < 1000000 \
|
||||
? 0x30302020 + (((X) / 10000 % 10) << 24) + \
|
||||
(((X) / 100000 % 10) << 16) \
|
||||
: (X) < 10000000 \
|
||||
? 0x30303020 + (((X) / 10000 % 10) << 24) + \
|
||||
(((X) / 100000 % 10) << 16) + \
|
||||
(((X) / 1000000 % 10) << 8) \
|
||||
: (X) < 100000000 \
|
||||
? 0x30303030 + (((X) / 10000 % 10) << 24) + \
|
||||
(((X) / 100000 % 10) << 16) + \
|
||||
(((X) / 1000000 % 10) << 8) + \
|
||||
(((X) / 10000000 % 10) << 0) \
|
||||
: 0xffffffffffffffff)
|
||||
|
||||
#endif /* __ASSEMBLER__ */
|
||||
#endif /* APE_MACROS_H_ */
|
||||
-41
@@ -1,41 +0,0 @@
|
||||
#ifndef COSMOPOLITAN_APE_MTIME_H_
|
||||
#define COSMOPOLITAN_APE_MTIME_H_
|
||||
#include "libc/dos.h"
|
||||
|
||||
/**
|
||||
* @fileoverview Deterministic last modified timestamp embedding.
|
||||
*/
|
||||
|
||||
#ifndef MTIME_YEAR
|
||||
#define MTIME_YEAR 2019
|
||||
#endif
|
||||
|
||||
#ifndef MTIME_MONTH
|
||||
#define MTIME_MONTH 1
|
||||
#endif
|
||||
|
||||
#ifndef MTIME_DAY
|
||||
#define MTIME_DAY 1
|
||||
#endif
|
||||
|
||||
#ifndef MTIME_HOUR
|
||||
#define MTIME_HOUR 0
|
||||
#endif
|
||||
|
||||
#ifndef MTIME_MINUTES
|
||||
#define MTIME_MINUTES 0
|
||||
#endif
|
||||
|
||||
#ifndef MTIME_SECONDS
|
||||
#define MTIME_SECONDS 0
|
||||
#endif
|
||||
|
||||
#ifndef ZIP_MTIME_DATE
|
||||
#define ZIP_MTIME_DATE DOS_DATE(MTIME_YEAR, MTIME_MONTH, MTIME_DAY)
|
||||
#endif
|
||||
|
||||
#ifndef ZIP_MTIME_TIME
|
||||
#define ZIP_MTIME_TIME DOS_TIME(MTIME_HOUR, MTIME_MINUTES, MTIME_SECONDS)
|
||||
#endif
|
||||
|
||||
#endif /* COSMOPOLITAN_APE_MTIME_H_ */
|
||||
+2
-20
@@ -11,6 +11,8 @@
|
||||
In some cases it's necessary to use addend macros that change virtual
|
||||
addresses into the other two types: physical and real. */
|
||||
|
||||
#define IMAGE_BASE_REAL 0x2000
|
||||
|
||||
#ifndef IMAGE_BASE_VIRTUAL
|
||||
#define IMAGE_BASE_VIRTUAL 0x400000
|
||||
#endif
|
||||
@@ -19,26 +21,6 @@
|
||||
#define IMAGE_BASE_PHYSICAL 0x100000
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Location of anything goes memory for real mode.
|
||||
*
|
||||
* The MBR won't load program content beyond this address, so we have
|
||||
* room for buffers, page tables, etc. before we reach the stack frame.
|
||||
*/
|
||||
#ifndef REAL_SCRATCH_AREA
|
||||
#define REAL_SCRATCH_AREA 0x40000
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Location of real mode 64kb stack frame.
|
||||
*
|
||||
* This address was chosen because memory beyond 0x80000 can't be
|
||||
* accessed safely without consulting e820.
|
||||
*/
|
||||
#ifndef REAL_STACK_FRAME
|
||||
#define REAL_STACK_FRAME 0x70000
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns Relative Virtual Address.
|
||||
*/
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# Program Deprioritizer
|
||||
#
|
||||
# OVERVIEW
|
||||
#
|
||||
# This is a drop-in replacement for the traditional Unix `nice`
|
||||
# command that also invokes `ionice`, which is important, since
|
||||
# network and traffic is usually what clobber the system.
|
||||
|
||||
if [ -z "$IONICE" ]; then
|
||||
if IONICE=$(command -v ionice 2>/dev/null); then
|
||||
IONICE="$IONICE -c3"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$NICE" ]; then
|
||||
NICE=$(command -v nice 2>/dev/null)
|
||||
fi
|
||||
|
||||
if [ -z "$IONICE$NICE" ]; then
|
||||
echo "error: can't be nice" >&2
|
||||
fi
|
||||
|
||||
exec $IONICE $NICE "$@"
|
||||
@@ -1,82 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
#
|
||||
# OVERVIEW
|
||||
#
|
||||
# GNU Archiver Veneer
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This script wraps normal archive commands that're transparently
|
||||
# passed-through. It adds value too, by addressing difficulties
|
||||
# that would normally cause a developer to need `make clean`.
|
||||
#
|
||||
# EXAMPLE
|
||||
#
|
||||
# build/archive ar rcsD library.a foo.o ...
|
||||
|
||||
if [ ! -d o/third_party/gcc ]; then
|
||||
third_party/gcc/unbundle.sh
|
||||
fi
|
||||
|
||||
export LC_ALL=C
|
||||
RM=${RM:-$(command -v rm) -f} || exit
|
||||
MKDIR=${MKDIR:-$(command -v mkdir) -p} || exit
|
||||
|
||||
AR=$1
|
||||
ARFLAGS=$2
|
||||
OUT=$3
|
||||
shift 3
|
||||
|
||||
# remove directory arguments (having .a targets depend on dirs is what
|
||||
# lets them be invalidated by deleted files)
|
||||
FIRST=1
|
||||
for x; do
|
||||
if [ $FIRST -eq 1 ]; then
|
||||
set --
|
||||
FIRST=0
|
||||
fi
|
||||
if [ -d "$x" ]; then
|
||||
if [ -f "$OUT" ] && [ "$x" -nt "$OUT" ]; then
|
||||
$RM "$OUT"
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
if [ "$x" != "${x%.o}" ]; then
|
||||
set -- "$@" "$x"
|
||||
fi
|
||||
done
|
||||
|
||||
set -- "$AR" "$ARFLAGS" "$OUT" "$@"
|
||||
printf %s\\n "$*" >"$OUT.cmd"
|
||||
|
||||
OUTDIR="${OUT%/*}"
|
||||
if [ "$OUTDIR" != "$OUT" ] && [ ! -d "$OUTDIR" ]; then
|
||||
$MKDIR "$OUTDIR" || exit 2
|
||||
fi
|
||||
|
||||
printf "$LOGFMT" "${ACTION:-ARCHIVE.a}" "$OUT" >&2
|
||||
# if [ "$SILENT" = "0" ]; then
|
||||
# # some of these windows nt archives are quite huge
|
||||
# COLUMNS=${COLUMNS:-80}
|
||||
# COLUMNS=$((COLUMNS - 4))
|
||||
# printf "%s\n" "$*" |
|
||||
# /usr/bin/fold -s -w $COLUMNS |
|
||||
# sed -e '1bb' -e 's/^/ /' -e ':b' -e '$b' -e 's/$/ \\/' >&2
|
||||
# else
|
||||
# printf "$LOGFMT" "${ACTION:-ARCHIVE.a}" "$OUT" >&2
|
||||
# fi
|
||||
|
||||
REASON=failed
|
||||
trap REASON=interrupted INT
|
||||
|
||||
"$@" >/dev/null && exit
|
||||
|
||||
if [ "$TERM" = "dumb" ]; then
|
||||
f='%s %s\r\n\r\n'
|
||||
else
|
||||
f='\033[91m%s\033[39m \033[94m%s\033[39m\r\n\r\n'
|
||||
fi
|
||||
printf "$f" "archive $REASON:" "$*" >&2
|
||||
exit 1
|
||||
@@ -1,50 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
#
|
||||
# OVERVIEW
|
||||
#
|
||||
# GNU Assembler Veneer
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This script wraps normal assembler commands that're transparently
|
||||
# passed-through. It adds ephemeral logging and directory creation.
|
||||
#
|
||||
# EXAMPLE
|
||||
#
|
||||
# TARGET=program build/assemble as -o program program.o
|
||||
#
|
||||
# SEE ALSO
|
||||
#
|
||||
# https://justine.storage.googleapis.com/perm/as.pdf
|
||||
|
||||
if [ ! -d o/third_party/gcc ]; then
|
||||
third_party/gcc/unbundle.sh
|
||||
fi
|
||||
|
||||
export LC_ALL=C
|
||||
MKDIR=${MKDIR:-$(command -v mkdir) -p} || exit
|
||||
|
||||
if [ "$SILENT" = "0" ]; then
|
||||
printf "%s\n" "$*" >&2
|
||||
else
|
||||
printf "$LOGFMT" "${ACTION:-OBJECTIFY.s}" "$TARGET" >&2
|
||||
fi
|
||||
|
||||
if [ "$TARGET" ]; then
|
||||
TARGETDIR="${TARGET%/*}"
|
||||
if [ "$TARGETDIR" != "$TARGET" ] && [ ! -d "$TARGETDIR" ]; then
|
||||
$MKDIR "$TARGETDIR" || exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
"$@" && exit
|
||||
|
||||
if [ "$TERM" = "dumb" ]; then
|
||||
f='%s %s\r\n\r\n'
|
||||
else
|
||||
f='\033[91m%s\033[39m \033[94m%s\033[39m\r\n\r\n'
|
||||
fi
|
||||
printf "$f" "assemble failed:" "$*" >&2
|
||||
exit 1
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
# -*- mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8 -*-
|
||||
# vi: set net ft=sh ts=2 sts=2 sw=2 fenc=utf-8 :vi
|
||||
|
||||
echo c |
|
||||
bochs \
|
||||
-q \
|
||||
-f ape/etc/bochsrc.dbg \
|
||||
floppya:1_44=$1,status=inserted
|
||||
@@ -1,51 +0,0 @@
|
||||
#!/bin/sh
|
||||
# -*- mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8 -*-
|
||||
# vi: set net ft=sh ts=2 sts=2 sw=2 fenc=utf-8 :vi
|
||||
#
|
||||
# bochs-scriptable executes a disk with serial uart stdio.
|
||||
#
|
||||
# USAGE
|
||||
#
|
||||
# build/bochs-scriptable IMAGE...
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This script is useful for end-to-end testing metal apps in <100ms.
|
||||
#
|
||||
# SEE ALSO
|
||||
#
|
||||
# build/boot(1)
|
||||
|
||||
while getopts h X; do
|
||||
case $X in
|
||||
h) exec less "$0" ;;
|
||||
\?) echo "$0: bad arg" >&2; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
trap '' INT
|
||||
|
||||
IMG=$1
|
||||
OUT=/tmp/$USER.$$.bochs.stdout
|
||||
ERR=/tmp/$USER.$$.bochs.stderr
|
||||
|
||||
mkfifo $OUT || exit
|
||||
|
||||
cat <$OUT &
|
||||
CAT=$!
|
||||
exec 4>$OUT
|
||||
rm -f $OUT
|
||||
|
||||
echo c |
|
||||
bochs \
|
||||
-q \
|
||||
-f ape/etc/bochsrc.ffs \
|
||||
display_library:nogui \
|
||||
floppya:1_44=$1,status=inserted \
|
||||
>>$ERR 2>>$ERR
|
||||
RC=$?
|
||||
|
||||
kill $CAT
|
||||
exec 4>&-
|
||||
rm -f $ERR
|
||||
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,21 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
#
|
||||
# OVERVIEW
|
||||
#
|
||||
# Source File Concatenation Tool
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This program is the same as cat, but inserts preprocessor directives
|
||||
# that allow compiler errors to point back to the original lines.
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
cat
|
||||
else
|
||||
for x; do
|
||||
printf '# 1 "%s"\n' "$x"
|
||||
cat "$x"
|
||||
done
|
||||
fi
|
||||
-284
@@ -1,284 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
#
|
||||
# OVERVIEW
|
||||
#
|
||||
# GNU/LLVM Compiler Frontend Frontend
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This wrapper script filters out certain flags so the compiler won't
|
||||
# whine, and passes extra information to the preprocessor.
|
||||
#
|
||||
# EXAMPLE
|
||||
#
|
||||
# build/compile cc -o program program.c
|
||||
|
||||
if [ ! -d o/third_party/gcc ]; then
|
||||
third_party/gcc/unbundle.sh
|
||||
fi
|
||||
|
||||
if [ "$1" = "clang-10" ]; then
|
||||
if ! command -v clang-10 >/dev/null; then
|
||||
shift
|
||||
set -- o/third_party/gcc/bin/x86_64-linux-musl-gcc "$@"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "clang++-10" ]; then
|
||||
if ! command -v clang++-10 >/dev/null; then
|
||||
shift
|
||||
set -- o/third_party/gcc/bin/x86_64-linux-musl-g++ "$@"
|
||||
fi
|
||||
fi
|
||||
|
||||
export LC_ALL=C
|
||||
MKDIR=${MKDIR:-$(command -v mkdir) -p} || exit
|
||||
|
||||
GZME=
|
||||
PLAT="${1%% *}"
|
||||
FDIAGNOSTIC_COLOR=
|
||||
CCNAME=${CCNAME:-gcc}
|
||||
CCVERSION=${CCVERSION:-4}
|
||||
COUNTERMAND=
|
||||
|
||||
# The GNU Compiler Collection passes a lot of CFLAGS to the preprocessor
|
||||
# (which we call CCFLAGS) but it should pass more; and we do just that.
|
||||
NOPG=0
|
||||
FIRST=1
|
||||
OUTARG=0
|
||||
INVISIBLE=0
|
||||
for x; do
|
||||
if [ $FIRST -eq 1 ]; then
|
||||
set --
|
||||
FIRST=0
|
||||
fi
|
||||
if [ $OUTARG -eq 1 ]; then
|
||||
OUTARG=0
|
||||
OUT="$x"
|
||||
fi
|
||||
case "$x" in
|
||||
-o)
|
||||
set -- "$@" "$x"
|
||||
OUTARG=1
|
||||
;;
|
||||
-w)
|
||||
set -- "$@" "$x" -D__W__
|
||||
;;
|
||||
-x-no-pg)
|
||||
NOPG=1
|
||||
;;
|
||||
-pg)
|
||||
if [ $NOPG -eq 0 ] && [ $INVISIBLE -eq 0 ]; then
|
||||
set -- "$@" "$x" -D__PG__ # @see libc/macros.h
|
||||
fi
|
||||
;;
|
||||
-mfentry)
|
||||
if [ $NOPG -eq 0 ] && [ $INVISIBLE -eq 0 ]; then
|
||||
set -- "$@" "$x" -D__MFENTRY__
|
||||
fi
|
||||
;;
|
||||
-fomit-frame-pointer)
|
||||
INVISIBLE=1
|
||||
set -- "$@" "$x"
|
||||
;;
|
||||
-mno-vzeroupper)
|
||||
set -- "$@" "$x" -Wa,-msse2avx -D__MNO_VZEROUPPER__
|
||||
;;
|
||||
-fsanitize=undefined)
|
||||
set -- "$@" "$x" -D__FSANITIZE_UNDEFINED__
|
||||
COUNTERMAND="$COUNTERMAND -fno-data-sections" # sqlite.o
|
||||
;;
|
||||
-mnop-mcount)
|
||||
if [ "$CCNAME" = "gcc" ] && [ "$CCVERSION" -ge 6 ]; then
|
||||
set -- "$@" "$x" -D__MNOP_MCOUNT__
|
||||
fi
|
||||
;;
|
||||
-mrecord-mcount)
|
||||
if [ "$CCNAME" = "gcc" ] && [ "$CCVERSION" -ge 6 ]; then
|
||||
set -- "$@" "$x" -D__MRECORD_MCOUNT__
|
||||
fi
|
||||
;;
|
||||
-fsanitize=implicit*integer*)
|
||||
if ! [ "$CCNAME" = "gcc" ]; then
|
||||
set -- "$@" "$x"
|
||||
fi
|
||||
;;
|
||||
-f*sanitize*|-gz*|-*stack-protector*|-fvect-cost*|-mstringop*)
|
||||
if [ "$CCNAME" = "gcc" ] && [ "$CCVERSION" -ge 6 ]; then
|
||||
set -- "$@" "$x"
|
||||
fi
|
||||
;;
|
||||
-freorder-blocks-and-partition|-fstack-clash-protection)
|
||||
if [ "$CCNAME" = "gcc" ] && [ "$CCVERSION" -ge 8 ]; then
|
||||
set -- "$@" "$x"
|
||||
fi
|
||||
;;
|
||||
-fdiagnostic-color=*)
|
||||
FDIAGNOSTIC_COLOR=$x
|
||||
;;
|
||||
-fopt-info*=*.optinfo)
|
||||
if [ "$CCNAME" = "gcc" ] && [ "$CCVERSION" -ge 9 ]; then
|
||||
GZME="$GZME ${x##*=}"
|
||||
set -- "$@" "$x"
|
||||
fi
|
||||
;;
|
||||
-R*) # e.g. clang's -Rpass-missed=all
|
||||
if [ "${PLAT#*clang}" != "${PLAT}" ]; then
|
||||
set -- "$@" "$x"
|
||||
fi
|
||||
;;
|
||||
-fsave-optimization-record) # clang only
|
||||
if [ "${PLAT#*clang}" != "${PLAT}" ]; then
|
||||
set -- "$@" "$x"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
set -- "$@" "$x"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [ -z "$FDIAGNOSTIC_COLOR" ] && [ "$TERM" != "dumb" ]; then
|
||||
FDIAGNOSTIC_COLOR=-fdiagnostics-color=always
|
||||
fi
|
||||
|
||||
if [ "${PLAT#*clang}" != "${PLAT}" ]; then
|
||||
FIRST=1
|
||||
for x; do
|
||||
# clang's assembler isn't complete yet
|
||||
if [ $FIRST -eq 1 ]; then
|
||||
set -- \
|
||||
"$x" \
|
||||
-fno-integrated-as \
|
||||
-Wno-unused-command-line-argument \
|
||||
-Wno-incompatible-pointer-types-discards-qualifiers
|
||||
FIRST=0
|
||||
continue
|
||||
fi
|
||||
TRAPV= # clang handles -f{,no-}{trap,wrap}v weird
|
||||
# removes flags clang whines about
|
||||
case "$x" in
|
||||
-gstabs) ;;
|
||||
-ftrapv) ;;
|
||||
-ffixed-*) ;;
|
||||
-fcall-saved*) ;;
|
||||
-fsignaling-nans) ;;
|
||||
-fcx-limited-range) ;;
|
||||
-fno-fp-int-builtin-inexact) ;;
|
||||
-Wno-unused-but-set-variable) ;;
|
||||
-Wunsafe-loop-optimizations) ;;
|
||||
-mdispatch-scheduler) ;;
|
||||
-ftracer) ;;
|
||||
-frounding-math) ;;
|
||||
-fmerge-constants) ;;
|
||||
-fmodulo-sched) ;;
|
||||
-msse2avx)
|
||||
set -- "$@" -Wa,-msse2avx
|
||||
;;
|
||||
-fopt-info-vec) ;;
|
||||
-fopt-info-vec-missed) ;;
|
||||
-fmodulo-sched-allow-regmoves) ;;
|
||||
-fgcse-*) ;;
|
||||
-freschedule-modulo-scheduled-loops) ;;
|
||||
-freschedule-modulo-scheduled-loops) ;;
|
||||
-fipa-pta) ;;
|
||||
-fsched2-use-superblocks) ;;
|
||||
-fbranch-target-load-optimize) ;;
|
||||
-fdelete-dead-exceptions) ;;
|
||||
-funsafe-loop-optimizations) ;;
|
||||
-fcall-used*) ;;
|
||||
-mmitigate-rop) ;;
|
||||
-mnop-mcount) ;;
|
||||
-fno-align-jumps) ;;
|
||||
-fno-align-labels) ;;
|
||||
-fno-align-loops) ;;
|
||||
-fivopts) ;;
|
||||
-fschedule-insns) ;;
|
||||
-fno-semantic-interposition) ;;
|
||||
-mno-fentry) ;;
|
||||
-f*shrink-wrap) ;;
|
||||
-f*schedule-insns2) ;;
|
||||
-fvect-cost-model=*) ;;
|
||||
-fsimd-cost-model=*) ;;
|
||||
-fversion-loops-for-strides) ;;
|
||||
-fopt-info*) ;;
|
||||
-f*var-tracking-assignments) ;;
|
||||
-femit-struct-debug-baseonly) ;;
|
||||
-ftree-loop-vectorize) ;;
|
||||
-gdescribe-dies) ;;
|
||||
-flimit-function-alignment) ;;
|
||||
-ftree-loop-im) ;;
|
||||
-fno-instrument-functions) ;;
|
||||
-fstack-clash-protection) ;;
|
||||
-mstringop-strategy=*) ;;
|
||||
-mpreferred-stack-boundary=*) ;;
|
||||
-*stack-protector*) ;; # clang requires segmented memory for this
|
||||
-f*gnu-unique) ;;
|
||||
-Wframe-larger-than=*) ;;
|
||||
-f*whole-program) ;;
|
||||
-Wa,--size-check=*) ;;
|
||||
-Wa,--listing*) ;;
|
||||
-mfpmath=sse+387) ;;
|
||||
-Wa,--noexecstack) ;;
|
||||
-freg-struct-return) ;;
|
||||
-mcall-ms2sysv-xlogues) ;;
|
||||
-mno-vzeroupper)
|
||||
set -- "$@" -mllvm -x86-use-vzeroupper=0
|
||||
;;
|
||||
-Wa,-a*)
|
||||
x="${x#*=}"
|
||||
if [ "$x" ] && [ -p "$x" ]; then
|
||||
printf '' >"$x"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
set -- "$@" "$x"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
set -- "$@" -fno-stack-protector
|
||||
else
|
||||
# removes flags only clang supports
|
||||
FIRST=1
|
||||
for x; do
|
||||
if [ $FIRST -eq 1 ]; then
|
||||
set --
|
||||
FIRST=0
|
||||
fi
|
||||
case "$x" in
|
||||
-Oz) set -- "$@" -Os ;;
|
||||
*) set -- "$@" "$x" ;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
set -- "$@" -no-canonical-prefixes $FDIAGNOSTIC_COLOR $COUNTERMAND
|
||||
|
||||
if [ "$SILENT" = "0" ]; then
|
||||
printf "%s\n" "$*" >&2
|
||||
else
|
||||
printf "$LOGFMT" "${ACTION:-COMPILE}" "${TARGET:-$OUT}" >&2
|
||||
fi
|
||||
|
||||
OUTDIR="${OUT%/*}"
|
||||
if [ "$OUTDIR" != "$OUT" ] && [ ! -d "$OUTDIR" ]; then
|
||||
$MKDIR "$OUTDIR" || exit 2
|
||||
fi
|
||||
|
||||
REASON=failed
|
||||
trap REASON=interrupted INT
|
||||
|
||||
if "$@"; then
|
||||
for f in $GZME; do
|
||||
if GZ=${GZ:-$(command -v gzip)}; then
|
||||
if [ -f "$f" ]; then
|
||||
build/actuallynice $GZ $ZFLAGS -qf $f &
|
||||
fi
|
||||
fi
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf "$LOGFMT" "$CCNAME $CCVERSION: compile $REASON:" "$*" >&2
|
||||
exit 1
|
||||
+172
-26
@@ -20,8 +20,6 @@ CONFIG_CCFLAGS += \
|
||||
TARGET_ARCH ?= \
|
||||
-msse3
|
||||
|
||||
RAGELFLAGS ?= -G2
|
||||
|
||||
endif
|
||||
|
||||
# Optimized Mode
|
||||
@@ -48,12 +46,12 @@ CONFIG_CCFLAGS += \
|
||||
TARGET_ARCH ?= \
|
||||
-march=native
|
||||
|
||||
RAGELFLAGS ?= -G2
|
||||
|
||||
endif
|
||||
|
||||
# Release Mode
|
||||
#
|
||||
# Follows traditional closed source release binary norms.
|
||||
#
|
||||
# - `make MODE=rel`
|
||||
# - More optimized
|
||||
# - Reasonably small
|
||||
@@ -73,7 +71,33 @@ CONFIG_CCFLAGS += \
|
||||
$(BACKTRACES) \
|
||||
-O2
|
||||
|
||||
RAGELFLAGS = -G2
|
||||
TARGET_ARCH ?= \
|
||||
-msse3
|
||||
|
||||
endif
|
||||
|
||||
# Asan Mode
|
||||
#
|
||||
# Safer binaries good for backend production serving.
|
||||
#
|
||||
# - `make MODE=asan`
|
||||
# - Memory safety
|
||||
# - Production worthy
|
||||
# - Backtraces
|
||||
# - Debuggability
|
||||
# - Larger binaries
|
||||
|
||||
ifeq ($(MODE), asan)
|
||||
|
||||
CONFIG_CCFLAGS += \
|
||||
$(BACKTRACES) \
|
||||
-O2
|
||||
|
||||
CONFIG_COPTS += \
|
||||
-fsanitize=address
|
||||
|
||||
TARGET_ARCH ?= \
|
||||
-msse3
|
||||
|
||||
endif
|
||||
|
||||
@@ -81,10 +105,11 @@ endif
|
||||
#
|
||||
# - `make MODE=dbg`
|
||||
# - Backtraces
|
||||
# - Zero optimization
|
||||
# - Enables sanitization
|
||||
# - Enables stack canaries
|
||||
# - Enormous binaries (b/c ubsan suboptimalities)
|
||||
# - Enables asan
|
||||
# - Enables ubsan (TODO)
|
||||
# - Stack canaries
|
||||
# - No optimization (TODO)
|
||||
# - Enormous binaries
|
||||
|
||||
ifeq ($(MODE), dbg)
|
||||
|
||||
@@ -94,17 +119,13 @@ CONFIG_CPPFLAGS += \
|
||||
CONFIG_CCFLAGS += \
|
||||
$(BACKTRACES) \
|
||||
$(FTRACE) \
|
||||
-fno-inline
|
||||
-O2
|
||||
|
||||
CONFIG_COPTS += \
|
||||
$(SECURITY_BLANKETS) \
|
||||
$(SANITIZER)
|
||||
|
||||
CONFIG_COPTS += \
|
||||
-ftrapv
|
||||
-fsanitize=address
|
||||
|
||||
TARGET_ARCH ?= \
|
||||
-march=k8-sse3
|
||||
-msse3
|
||||
|
||||
OVERRIDE_CCFLAGS += \
|
||||
-fno-pie
|
||||
@@ -124,22 +145,152 @@ endif
|
||||
# - YOLO
|
||||
|
||||
ifeq ($(MODE), tiny)
|
||||
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
-DNDEBUG \
|
||||
-DTRUSTWORTHY
|
||||
|
||||
CONFIG_CCFLAGS += \
|
||||
-Os \
|
||||
-fno-align-functions \
|
||||
-fno-align-jumps \
|
||||
-fno-align-labels \
|
||||
-fno-align-loops
|
||||
|
||||
TARGET_ARCH ?= \
|
||||
-march=k8-sse3
|
||||
-msse3
|
||||
endif
|
||||
|
||||
# Linux-Only Tiny Mode
|
||||
#
|
||||
# - `make MODE=tinylinux`
|
||||
# - No checks
|
||||
# - No asserts
|
||||
# - No canaries
|
||||
# - No paranoia
|
||||
# - No avx hooks
|
||||
# - No backtraces
|
||||
# - No portability
|
||||
# - No algorithmics
|
||||
# - YOLO
|
||||
|
||||
ifeq ($(MODE), tinylinux)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
-DNDEBUG \
|
||||
-DTRUSTWORTHY \
|
||||
-DSUPPORT_VECTOR=1
|
||||
CONFIG_CCFLAGS += \
|
||||
-Os \
|
||||
-fno-align-functions \
|
||||
-fno-align-jumps \
|
||||
-fno-align-labels \
|
||||
-fno-align-loops
|
||||
TARGET_ARCH ?= \
|
||||
-msse3
|
||||
endif
|
||||
|
||||
# Linux+BSD Tiny Mode
|
||||
#
|
||||
# - `make MODE=tinylinuxbsd`
|
||||
# - No apple
|
||||
# - No checks
|
||||
# - No asserts
|
||||
# - No canaries
|
||||
# - No paranoia
|
||||
# - No microsoft
|
||||
# - No avx hooks
|
||||
# - No backtraces
|
||||
# - No algorithmics
|
||||
# - YOLO
|
||||
|
||||
ifeq ($(MODE), tinylinuxbsd)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
-DNDEBUG \
|
||||
-DTRUSTWORTHY \
|
||||
-DSUPPORT_VECTOR=113
|
||||
CONFIG_CCFLAGS += \
|
||||
-Os \
|
||||
-fno-align-functions \
|
||||
-fno-align-jumps \
|
||||
-fno-align-labels \
|
||||
-fno-align-loops
|
||||
TARGET_ARCH ?= \
|
||||
-msse3
|
||||
endif
|
||||
|
||||
# Unix Tiny Mode
|
||||
#
|
||||
# - `make MODE=tinysysv`
|
||||
# - No checks
|
||||
# - No asserts
|
||||
# - No canaries
|
||||
# - No paranoia
|
||||
# - No microsoft
|
||||
# - No avx hooks
|
||||
# - No backtraces
|
||||
# - No algorithmics
|
||||
# - YOLO
|
||||
|
||||
ifeq ($(MODE), tinysysv)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
-DNDEBUG \
|
||||
-DTRUSTWORTHY \
|
||||
-DSUPPORT_VECTOR=121
|
||||
CONFIG_CCFLAGS += \
|
||||
-Os \
|
||||
-fno-align-functions \
|
||||
-fno-align-jumps \
|
||||
-fno-align-labels \
|
||||
-fno-align-loops
|
||||
TARGET_ARCH ?= \
|
||||
-msse3
|
||||
endif
|
||||
|
||||
# Tiny Metallic Unix Mode
|
||||
#
|
||||
# - `make MODE=tinynowin`
|
||||
# - No checks
|
||||
# - No asserts
|
||||
# - No canaries
|
||||
# - No paranoia
|
||||
# - No microsoft
|
||||
# - No avx hooks
|
||||
# - No backtraces
|
||||
# - No algorithmics
|
||||
# - YOLO
|
||||
|
||||
ifeq ($(MODE), tinynowin)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
-DNDEBUG \
|
||||
-DTRUSTWORTHY \
|
||||
-DSUPPORT_VECTOR=251
|
||||
CONFIG_CCFLAGS += \
|
||||
-Os \
|
||||
-fno-align-functions \
|
||||
-fno-align-jumps \
|
||||
-fno-align-labels \
|
||||
-fno-align-loops
|
||||
TARGET_ARCH ?= \
|
||||
-msse3
|
||||
endif
|
||||
|
||||
# LLVM Mode
|
||||
ifeq ($(MODE), llvm)
|
||||
TARGET_ARCH ?= -msse3
|
||||
CONFIG_CCFLAGS += $(BACKTRACES) $(FTRACE) -O2
|
||||
AS = clang
|
||||
CC = clang
|
||||
CXX = clang++
|
||||
CXXFILT = llvm-c++filt
|
||||
LD = ld.lld
|
||||
NM = llvm-nm
|
||||
GCC = clang
|
||||
STRIP = llvm-strip
|
||||
OBJCOPY = llvm-objcopy
|
||||
OBJDUMP = llvm-objdump
|
||||
ADDR2LINE = llvm-addr2line
|
||||
endif
|
||||
|
||||
# ANSI Mode
|
||||
@@ -166,17 +317,12 @@ endif
|
||||
# such as MSVC or XCode. You can run your binary objects through a tool
|
||||
# like objconv to convert them to COFF or MachO. Then use ANSI mode to
|
||||
# rollup one header file that'll enable linkage with minimal issues.
|
||||
#
|
||||
# Lastly note that in some cases, such as gc(), there simply isn't any
|
||||
# ANSI workaround available. It's only in cases like that when we'll use
|
||||
# the __asm__() header workaround, rather than simply removing it. We do
|
||||
# however try to do that much less often than mainstream C libraries.
|
||||
|
||||
ifeq ($(MODE), ansi)
|
||||
|
||||
CONFIG_CFLAGS += -std=c11
|
||||
#CONFIG_CPPFLAGS += -ansi
|
||||
CONFIG_CXXFLAGS += -std=c++11
|
||||
TARGET_ARCH ?= -march=k8-sse3
|
||||
TARGET_ARCH ?= -msse3
|
||||
|
||||
endif
|
||||
+35
-49
@@ -13,8 +13,8 @@
|
||||
#
|
||||
# When tuning the variables below, please note they're interpreted in
|
||||
# the strictest sense. For example, we don't pass CFLAGS to gcc if we
|
||||
# know it's compiling a .S file. This allows our `make SILENT=0` logs
|
||||
# to be succinct and informative, at the cost of being less forgiving.
|
||||
# know it's compiling a .S file. This enables our `make V=0` logging
|
||||
# to be succinct and informative at the cost of being less forgiving.
|
||||
#
|
||||
# Further note that link order is equally unforgiving in repositories
|
||||
# of this scale. We approach that by over-specifying dependencies, in
|
||||
@@ -42,30 +42,29 @@
|
||||
# ASFLAGS assembler flags (don't use -Wa, frontend prefix)
|
||||
# TARGET_ARCH microarchitecture flags (e.g. -march=native)
|
||||
|
||||
DD ?= /bin/dd
|
||||
CP ?= /bin/cp -f
|
||||
RM ?= /bin/rm -f
|
||||
SED ?= /bin/sed
|
||||
MKDIR ?= /bin/mkdir -p
|
||||
V ?= 1
|
||||
LC_ALL = C
|
||||
SOURCE_DATE_EPOCH = 0
|
||||
|
||||
TAGS ?= /usr/bin/ctags # emacs source builds or something breaks it
|
||||
ARFLAGS = rcsD
|
||||
SILENT ?= 1
|
||||
ZFLAGS ?=
|
||||
XARGS ?= xargs -P4 -rs8000
|
||||
NICE ?= build/actuallynice
|
||||
RAGEL ?= ragel
|
||||
DOT ?= dot
|
||||
GZ ?= gzip
|
||||
CLANG = clang-10
|
||||
CLANG = clang
|
||||
FC = gfortran #/opt/cross9f/bin/x86_64-linux-musl-gfortran
|
||||
|
||||
# see build/compile, etc. which run third_party/gcc/unbundle.sh
|
||||
AR = build/bootstrap/ar.com
|
||||
PKG = build/bootstrap/package.com
|
||||
MKDEPS = build/bootstrap/mkdeps.com
|
||||
ZIPOBJ = build/bootstrap/zipobj.com
|
||||
AS = o/third_party/gcc/bin/x86_64-linux-musl-as
|
||||
CC = o/third_party/gcc/bin/x86_64-linux-musl-gcc
|
||||
CXX = o/third_party/gcc/bin/x86_64-linux-musl-g++
|
||||
CXXFILT = o/third_party/gcc/bin/x86_64-linux-musl-c++filt
|
||||
LD = o/third_party/gcc/bin/x86_64-linux-musl-ld.bfd
|
||||
AR = o/third_party/gcc/bin/x86_64-linux-musl-ar
|
||||
NM = o/third_party/gcc/bin/x86_64-linux-musl-nm
|
||||
GCC = o/third_party/gcc/bin/x86_64-linux-musl-gcc
|
||||
STRIP = o/third_party/gcc/bin/x86_64-linux-musl-strip
|
||||
@@ -76,43 +75,29 @@ ADDR2LINE = o/third_party/gcc/bin/x86_64-linux-musl-addr2line
|
||||
COMMA := ,
|
||||
PWD := $(shell pwd)
|
||||
IMAGE_BASE_VIRTUAL ?= 0x400000
|
||||
HELLO := $(shell build/hello)
|
||||
TMPDIR := $(shell build/findtmp)
|
||||
LOGFMT := $(shell build/getlogfmt)
|
||||
CCNAME := $(shell build/getccname $(CC))
|
||||
CCVERSION := $(shell build/getccversion $(CC))
|
||||
BLAH1 := $(shell build/zipobj 2>/dev/null)
|
||||
BLAH2 := $(shell build/package 2>/dev/null)
|
||||
SPAWNER := $(shell build/getcompile) -V$(shell build/getccversion $(CC))
|
||||
COMPILE = $(SPAWNER) $(QUOTA)
|
||||
|
||||
export ADDR2LINE
|
||||
export OBJDUMP
|
||||
export CCNAME
|
||||
export CCVERSION
|
||||
export CP
|
||||
export DD
|
||||
export GZ
|
||||
export IMAGE_BASE_VIRTUAL
|
||||
export LOGFMT
|
||||
export MKDIR
|
||||
export LC_ALL
|
||||
export MODE
|
||||
export RM
|
||||
export SED
|
||||
export SILENT
|
||||
export SOURCE_DATE_EPOCH
|
||||
export TMPDIR
|
||||
export ZFLAGS
|
||||
export V
|
||||
|
||||
FTRACE = \
|
||||
-pg
|
||||
|
||||
SANITIZER = \
|
||||
-fsanitize=leak \
|
||||
-fsanitize=undefined \
|
||||
-fsanitize=implicit-signed-integer-truncation \
|
||||
-fsanitize=implicit-integer-sign-change
|
||||
-fsanitize=address
|
||||
|
||||
NO_MAGIC = \
|
||||
-mno-fentry \
|
||||
-fno-stack-protector \
|
||||
-fno-sanitize=all
|
||||
-fno-sanitize=all \
|
||||
-fwrapv
|
||||
|
||||
OLD_CODE = \
|
||||
-fno-strict-aliasing \
|
||||
@@ -126,7 +111,6 @@ TRADITIONAL = \
|
||||
DEFAULT_CCFLAGS = \
|
||||
-Wall \
|
||||
-Werror \
|
||||
-fmerge-all-constants \
|
||||
-fdebug-prefix-map="$(PWD)"= \
|
||||
-frecord-gcc-switches
|
||||
|
||||
@@ -142,7 +126,6 @@ DEFAULT_COPTS = \
|
||||
-fno-ident \
|
||||
-fno-common \
|
||||
-fno-gnu-unique \
|
||||
-fmerge-constants \
|
||||
-fstrict-aliasing \
|
||||
-fstrict-overflow \
|
||||
-fno-omit-frame-pointer \
|
||||
@@ -154,9 +137,11 @@ MATHEMATICAL = \
|
||||
-fwrapv
|
||||
|
||||
DEFAULT_CPPFLAGS = \
|
||||
-DCOSMO \
|
||||
-DMODE='"$(MODE)"' \
|
||||
-DIMAGE_BASE_VIRTUAL=$(IMAGE_BASE_VIRTUAL) \
|
||||
-nostdinc \
|
||||
-iquote .
|
||||
-iquote.
|
||||
|
||||
DEFAULT_CFLAGS = \
|
||||
-std=gnu2x
|
||||
@@ -173,7 +158,8 @@ DEFAULT_CXXFLAGS = \
|
||||
DEFAULT_ASFLAGS = \
|
||||
-W \
|
||||
-I. \
|
||||
--noexecstack
|
||||
--noexecstack \
|
||||
--nocompress-debug-sections
|
||||
|
||||
DEFAULT_LDFLAGS = \
|
||||
-static \
|
||||
@@ -181,12 +167,14 @@ DEFAULT_LDFLAGS = \
|
||||
-m elf_x86_64 \
|
||||
--gc-sections \
|
||||
--build-id=none \
|
||||
--cref -Map=$@.map \
|
||||
--no-dynamic-linker \
|
||||
-z max-page-size=0x1000 \
|
||||
-Ttext-segment=$(IMAGE_BASE_VIRTUAL)
|
||||
-z max-page-size=0x1000
|
||||
|
||||
ZIPOBJ_FLAGS = \
|
||||
-b$(IMAGE_BASE_VIRTUAL)
|
||||
|
||||
ASONLYFLAGS = \
|
||||
-c \
|
||||
-g \
|
||||
--debug-prefix-map="$(PWD)"=
|
||||
|
||||
@@ -194,7 +182,6 @@ DEFAULT_LDLIBS =
|
||||
|
||||
MCA = llvm-mca-10 \
|
||||
-mtriple=x86_64-pc-linux-gnu \
|
||||
-iterations=3 \
|
||||
-instruction-info \
|
||||
-iterations=3 \
|
||||
-all-stats \
|
||||
@@ -270,8 +257,8 @@ COMPILE.F.flags = $(cc.flags) $(cpp.flags) $(copt.flags) $(f.flags)
|
||||
COMPILE.i.flags = $(cc.flags) $(copt.flags) $(c.flags)
|
||||
COMPILE.ii.flags = $(cc.flags) $(copt.flags) $(cxx.flags)
|
||||
LINK.flags = $(DEFAULT_LDFLAGS) $(CONFIG_LDFLAGS) $(LDFLAGS)
|
||||
OBJECTIFY.c.flags = $(OBJECTIFY.S.flags) $(c.flags)
|
||||
OBJECTIFY.cxx.flags = $(OBJECTIFY.S.flags) $(cxx.flags)
|
||||
OBJECTIFY.c.flags = $(OBJECTIFY.S.flags) $(copt.flags) $(c.flags)
|
||||
OBJECTIFY.cxx.flags = $(OBJECTIFY.S.flags) $(copt.flags) $(cxx.flags)
|
||||
OBJECTIFY.s.flags = $(ASONLYFLAGS) $(s.flags)
|
||||
OBJECTIFY.S.flags = $(copt.flags) $(cc.flags) $(o.flags) $(cpp.flags) $(S.flags)
|
||||
OBJECTIFY.f.flags = $(copt.flags) $(cc.flags) $(o.flags) $(copt.flags) $(S.flags) $(f.flags)
|
||||
@@ -292,10 +279,9 @@ OBJECTIFY.c = $(CC) $(OBJECTIFY.c.flags) -c
|
||||
OBJECTIFY.cxx = $(CXX) $(OBJECTIFY.cxx.flags) -c
|
||||
PREPROCESS = $(CC) $(PREPROCESS.flags)
|
||||
PREPROCESS.lds = $(CC) $(PREPROCESS.lds.flags)
|
||||
LINK = build/link $(LD) $(LINK.flags)
|
||||
LINK = $(LD) $(LINK.flags)
|
||||
ELF = o/libc/elf/elf.lds
|
||||
ELFLINK = ACTION=LINK.elf $(LINK) $(LINKARGS) $(OUTPUT_OPTION)
|
||||
ARCHIVE = build/archive $(AR) $(ARFLAGS)
|
||||
ELFLINK = $(COMPILE) -ALINK.elf $(LINK) $(LINKARGS) $(OUTPUT_OPTION)
|
||||
LINKARGS = $(patsubst %.lds,-T %.lds,$(call uniqr,$(LD.libs) $(filter-out %.pkg,$^)))
|
||||
LOLSAN = build/lolsan -b $(IMAGE_BASE_VIRTUAL)
|
||||
|
||||
@@ -383,5 +369,5 @@ TAGSFLAGS = \
|
||||
--if0=no \
|
||||
--langmap=c:.c.h.i \
|
||||
--line-directives=yes \
|
||||
--exclude=libc/nt/struct/imagefileheader.h \
|
||||
--exclude=libc/nt/struct/imagefileheader.internal.h \
|
||||
--exclude=libc/nt/struct/filesegmentelement.h
|
||||
@@ -1,55 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
#
|
||||
# OVERVIEW
|
||||
#
|
||||
# Generic Command Runner
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This does auto mkdir and ephemeral logging.
|
||||
#
|
||||
# EXAMPLE
|
||||
#
|
||||
# build/do PROG [ARGS...]
|
||||
|
||||
MKDIR=${MKDIR:-$(command -v mkdir) -p} || exit
|
||||
|
||||
# Ensure directory creation if -o PATH flag is passed.
|
||||
OUT="$TARGET"
|
||||
FIRST=1
|
||||
OUTARG=0
|
||||
for x; do
|
||||
if [ $FIRST -eq 1 ]; then
|
||||
set --
|
||||
FIRST=0
|
||||
elif [ $OUTARG -eq 1 ]; then
|
||||
OUTARG=0
|
||||
OUT="$x"
|
||||
fi
|
||||
case "$x" in
|
||||
-o)
|
||||
OUTARG=1
|
||||
;;
|
||||
-o*)
|
||||
OUT=${x#-o}
|
||||
;;
|
||||
esac
|
||||
set -- "$@" "$x"
|
||||
done
|
||||
if [ "$OUT" ]; then
|
||||
OUTDIR="${OUT%/*}"
|
||||
if [ "$OUTDIR" != "$OUT" ] && [ ! -d "$OUTDIR" ]; then
|
||||
$MKDIR "$OUTDIR" || exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
# Log command.
|
||||
if [ "$SILENT" = "0" ]; then
|
||||
printf "%s\n" "$*" >&2
|
||||
else
|
||||
printf "$LOGFMT" "${ACTION:-BUILD}" "$TARGET" >&2
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
+2
-4
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
#
|
||||
@@ -13,7 +13,5 @@
|
||||
# environment variable. Many programs use it under the hood, e.g. gcc,
|
||||
# so it grants many small performance improvements.
|
||||
|
||||
MKDIR=${MKDIR:-$(command -v mkdir) -p} || exit
|
||||
|
||||
$MKDIR o/tmp
|
||||
mkdir -p o/tmp
|
||||
echo o/tmp
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
exec gdb -q -nh -i=mi $1 \
|
||||
-ex "set confirm off" \
|
||||
-ex "add-symbol-file $1.dbg 0x401000" \
|
||||
-ex "run"
|
||||
@@ -1,41 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
#
|
||||
# OVERVIEW
|
||||
#
|
||||
# Compiler Name Discovery
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# Cosmopolitan itself may be built using either GCC and Clang, and our
|
||||
# build irons out many of the differences between the two. This script
|
||||
# determines which one's in play, which is nontrivial, since they tend
|
||||
# to call themselves so many different names.
|
||||
|
||||
if [ ! -d o/third_party/gcc ]; then
|
||||
third_party/gcc/unbundle.sh
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
SPECIAL_TEXT=$(
|
||||
$1 --version |
|
||||
sed -n '
|
||||
/Free Software/ {
|
||||
i\
|
||||
gcc
|
||||
q
|
||||
}
|
||||
/clang/ {
|
||||
i\
|
||||
clang
|
||||
q
|
||||
}
|
||||
')
|
||||
|
||||
if [ -z "$SPECIAL_TEXT" ]; then
|
||||
echo gcc
|
||||
else
|
||||
printf '%s\n' "$SPECIAL_TEXT"
|
||||
fi
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
|
||||
if ! [ o/build/bootstrap/compile.com -nt build/bootstrap/compile.com ]; then
|
||||
mkdir -p o/build/bootstrap/
|
||||
cp -f build/bootstrap/compile.com o/build/bootstrap/compile.$$.com
|
||||
o/build/bootstrap/compile.$$.com -n
|
||||
mv -f o/build/bootstrap/compile.$$.com o/build/bootstrap/compile.com
|
||||
fi
|
||||
|
||||
echo o/build/bootstrap/compile.com
|
||||
@@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
#
|
||||
# OVERVIEW
|
||||
#
|
||||
# Printf Logger Initializer
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This program is invoked once by build/definitions.mk to choose the
|
||||
# most appropriate format string when logging command invocations.
|
||||
|
||||
if [ "$SILENT" = "0" ]; then
|
||||
printf "''"
|
||||
else
|
||||
W1=15
|
||||
if [ "$TERM" = "dumb" ]; then # e.g. emacs' dismal tty
|
||||
if [ "$COLUMNS" = "" ]; then
|
||||
if TPUT=$(command -v tput); then
|
||||
COLUMNS=$("$TPUT" cols)
|
||||
else
|
||||
COLUMNS=80
|
||||
fi
|
||||
fi
|
||||
COLUMNS=$((COLUMNS - 1))
|
||||
W2=$((COLUMNS - W1))
|
||||
printf '%%-%ds%%-%ds\\r' "$W1" "$W2"
|
||||
else
|
||||
echo ♥cosmo >&2
|
||||
printf '\\033[F\\033[K%%-%ds%%s\\r\\n' "$W1"
|
||||
fi
|
||||
fi
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# HELLO BUILD
|
||||
#
|
||||
# OVERVIEW
|
||||
#
|
||||
# We generate a line at the start of each Makefile run, because if we
|
||||
# use `make V=0` mode then the terminal logging trick we use in
|
||||
# tool/build/compile.c will delete the previous line, and we'd rather
|
||||
# have that line not be the bash prompt that ran make.
|
||||
#
|
||||
# This script is also useful for giving us an indicator each time the
|
||||
# build restarts itself from scratch, which can happen in cases like
|
||||
# when dependencies need to be regenerated by tool/build/mkdeps.c
|
||||
|
||||
echo ♥cosmo >&2
|
||||
+9
-9
@@ -59,13 +59,13 @@ set -- --regex-c='/^extern [^(]*(\*const \([^)]*\))(/\1/b' "$@"
|
||||
# struct WorstSoftwareEver;
|
||||
set -- --regex-c='/^struct.*;$/uehocruehcroue/b' "$@"
|
||||
|
||||
exec ${TAGS:-ctags} \
|
||||
-e \
|
||||
--langmap=c:.c.h \
|
||||
--exclude=libc/nt/struct/imagefileheader.h \
|
||||
--exclude=libc/nt/struct/imageseparatedebugheader.h \
|
||||
--exclude=libc/nt/struct/importobjectheader.h \
|
||||
--exclude=libc/nt/struct/nonpageddebuginfo.h \
|
||||
--exclude=libc/nt/struct/ansistring.h \
|
||||
--exclude=libc/nt/struct/filesegmentelement.h \
|
||||
exec ${TAGS:-ctags} \
|
||||
-e \
|
||||
--langmap=c:.c.h \
|
||||
--exclude=libc/nt/struct/imagefileheader.internal.h \
|
||||
--exclude=libc/nt/struct/imageseparatedebugheader.internal.h \
|
||||
--exclude=libc/nt/struct/importobjectheader.h \
|
||||
--exclude=libc/nt/struct/nonpageddebuginfo.h \
|
||||
--exclude=libc/nt/struct/ansistring.h \
|
||||
--exclude=libc/nt/struct/filesegmentelement.h \
|
||||
"$@"
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
|
||||
for x; do
|
||||
printf '#include "%s"\n' "$x"
|
||||
done
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
#
|
||||
# OVERVIEW
|
||||
#
|
||||
# GNU Linker Veneer
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This script wraps normal linker commands that're transparently
|
||||
# passed-through. It adds ephemeral logging and directory creation.
|
||||
#
|
||||
# EXAMPLE
|
||||
#
|
||||
# build/linker ld -o program program.o
|
||||
|
||||
if [ ! -d o/third_party/gcc ]; then
|
||||
third_party/gcc/unbundle.sh
|
||||
fi
|
||||
|
||||
export LC_ALL=C # very important for ld
|
||||
MKDIR=${MKDIR:-$(command -v mkdir) -p} || exit
|
||||
|
||||
OUT=
|
||||
FIRST=1
|
||||
OUTARG=0
|
||||
for x; do
|
||||
if [ $FIRST -eq 1 ]; then
|
||||
set --
|
||||
FIRST=0
|
||||
elif [ $OUTARG -eq 1 ]; then
|
||||
OUTARG=0
|
||||
OUT="$x"
|
||||
fi
|
||||
case "$x" in
|
||||
-o)
|
||||
OUTARG=1
|
||||
;;
|
||||
esac
|
||||
set -- "$@" "$x"
|
||||
done
|
||||
|
||||
if [ "$SILENT" = "0" ]; then
|
||||
printf "%s\n" "$*" >&2
|
||||
else
|
||||
printf "$LOGFMT" "${ACTION:-LINK.elf}" "$OUT" >&2
|
||||
fi
|
||||
|
||||
OUTDIR="${OUT%/*}"
|
||||
if [ "$OUTDIR" != "$OUT" ] && [ ! -d "$OUTDIR" ]; then
|
||||
$MKDIR "$OUTDIR" || exit 2
|
||||
fi
|
||||
|
||||
REASON=failed
|
||||
trap REASON=interrupted INT
|
||||
|
||||
"$@" && exit
|
||||
|
||||
if [ "$TERM" = "dumb" ]; then
|
||||
f='%s %s\r\n\r\n'
|
||||
else
|
||||
f='\033[91m%s\033[39m \033[94m%s\033[39m\r\n\r\n'
|
||||
fi
|
||||
printf "$f" "link $REASON:" "$*" >&2
|
||||
exit 1
|
||||
@@ -1,22 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
|
||||
if [ -x "o/$MODE/tool/build/mkdeps.com" ]; then
|
||||
set -- "o/$MODE/tool/build/mkdeps.com" "$@"
|
||||
else
|
||||
if [ ! -x o/build/bootstrap/mkdeps.com ]; then
|
||||
mkdir -p o/build/bootstrap &&
|
||||
cp -a build/bootstrap/mkdeps.com \
|
||||
o/build/bootstrap/mkdeps.com || exit
|
||||
fi
|
||||
set -- o/build/bootstrap/mkdeps.com "$@"
|
||||
fi
|
||||
|
||||
if [ "$SILENT" = "0" ]; then
|
||||
printf "%s\n" "$*" >&2
|
||||
else
|
||||
printf "$LOGFMT" "${ACTION:-MKDEPS}" "$3" >&2
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
@@ -1,22 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
#
|
||||
# OVERVIEW
|
||||
#
|
||||
# GNU Disassembly Veneer
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This script wraps normal objdump commands that're transparently
|
||||
# passed-through.
|
||||
#
|
||||
# EXAMPLE
|
||||
#
|
||||
# build/objdump -xd o/tiny/examples/life.com.dbg
|
||||
|
||||
if [ ! -d o/third_party/gcc ]; then
|
||||
third_party/gcc/unbundle.sh
|
||||
fi
|
||||
|
||||
exec o/third_party/gcc/bin/x86_64-linux-musl-objdump "$@"
|
||||
+4
-5
@@ -23,9 +23,8 @@
|
||||
# - tool/build/runitd.c
|
||||
|
||||
.PRECIOUS: o/$(MODE)/%.com.ok
|
||||
o/$(MODE)/%.com.ok: \
|
||||
o/$(MODE)/tool/build/runit.com.dbg \
|
||||
o/$(MODE)/tool/build/runitd.com \
|
||||
o/$(MODE)/%.com.ok: \
|
||||
o/$(MODE)/tool/build/runit.com \
|
||||
o/$(MODE)/tool/build/runitd.com \
|
||||
o/$(MODE)/%.com
|
||||
@ACTION=TEST TARGET=$@ build/do $^ $(HOSTS)
|
||||
@touch $@
|
||||
@$(COMPILE) -ATEST -tT$@ $^ $(HOSTS)
|
||||
@@ -1,33 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
|
||||
if [ "$TOOL_BUILD_PACKAGE" ]; then
|
||||
set -- "$TOOL_BUILD_PACKAGE" "$@"
|
||||
else
|
||||
if [ -x "o/tool/build/package.com" ]; then
|
||||
set -- "o/tool/build/package.com" "$@"
|
||||
else
|
||||
MKDIR=${MKDIR:-$(command -v mkdir) -p} || exit
|
||||
CP=${CP:-$(command -v cp) -f} || exit
|
||||
if [ ! -x o/build/bootstrap/package.com ]; then
|
||||
$MKDIR o/build/bootstrap &&
|
||||
$CP -a build/bootstrap/package.com \
|
||||
o/build/bootstrap/package.com || exit
|
||||
fi
|
||||
set -- o/build/bootstrap/package.com "$@"
|
||||
fi
|
||||
fi
|
||||
|
||||
printf "$LOGFMT" "${ACTION:-PACKAGE}" "$3" >&2
|
||||
# if [ "$SILENT" = "0" ]; then
|
||||
# COLUMNS=${COLUMNS:-80}
|
||||
# COLUMNS=$((COLUMNS - 4))
|
||||
# printf "%s\n" "$*" |
|
||||
# /usr/bin/fold -s -w $COLUMNS |
|
||||
# sed -e '1bb' -e 's/^/ /' -e ':b' -e '$b' -e 's/$/ \\/' >&2
|
||||
# else
|
||||
# printf "$LOGFMT" "${ACTION:-PACKAGE}" "$3" >&2
|
||||
# fi
|
||||
|
||||
exec "$@"
|
||||
-2186
File diff suppressed because it is too large.
Load diff
@@ -1,7 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
|
||||
for x; do
|
||||
printf '#include "%s"\n' "$x"
|
||||
done
|
||||
+64
-80
@@ -16,86 +16,70 @@
|
||||
|
||||
MAKEFLAGS += --no-builtin-rules
|
||||
|
||||
o/%.a:; @$(ARCHIVE) $@ $^
|
||||
o/%.o: %.s; @TARGET=$@ build/assemble $(OBJECTIFY.s) $(OUTPUT_OPTION) $<
|
||||
o/%.o: o/%.s; @TARGET=$@ build/assemble $(OBJECTIFY.s) $(OUTPUT_OPTION) $<
|
||||
o/%.s: %.S; @ACTION=PREPROCESS build/compile $(PREPROCESS) $(OUTPUT_OPTION) $<
|
||||
o/%.s: o/%.S; @ACTION=PREPROCESS build/compile $(PREPROCESS) $(OUTPUT_OPTION) $<
|
||||
o/%.i: %.S; @ACTION=PREPROCESS build/compile $(PREPROCESS) $(OUTPUT_OPTION) $<
|
||||
o/%.o: %.S; @ACTION=OBJECTIFY.S build/compile $(OBJECTIFY.S) $(OUTPUT_OPTION) $<
|
||||
o/%.o: o/%.S; @ACTION=OBJECTIFY.S build/compile $(OBJECTIFY.S) $(OUTPUT_OPTION) $<
|
||||
o/%.s: %.i; @ACTION=COMPILE.i build/compile $(COMPILE.i) $(OUTPUT_OPTION) $<
|
||||
o/%.s: o/%.i; @ACTION=COMPILE.i build/compile $(COMPILE.i) $(OUTPUT_OPTION) $<
|
||||
o/%.o: %.cc; @ACTION=OBJECTIFY.cxx build/compile $(OBJECTIFY.cxx) $(OUTPUT_OPTION) $<
|
||||
o/%.o: o/%.cc; @ACTION=OBJECTIFY.cxx build/compile $(OBJECTIFY.cxx) $(OUTPUT_OPTION) $<
|
||||
o/%.lds: %.lds; @ACTION=PREPROCESS build/compile $(PREPROCESS.lds) $(OUTPUT_OPTION) $<
|
||||
o/%.inc: %.h; @ACTION=PREPROCESS build/compile $(PREPROCESS) $(OUTPUT_OPTION) -D__ASSEMBLER__ -P $<
|
||||
o/%.pkg:; @build/package $(OUTPUT_OPTION) $(addprefix -d,$(filter %.pkg,$^)) $(filter %.o,$^)
|
||||
o/%.h.ok: %.h; @ACTION=CHECK.h build/compile $(COMPILE.c) -x c -g0 -o $@ $<
|
||||
o/%.h.okk: %.h; @ACTION=CHECK.h build/compile $(COMPILE.cxx) -x c++ -g0 -o $@ $<
|
||||
o/%.greg.o: %.greg.c; @ACTION=OBJECTIFY.greg build/compile $(OBJECTIFY.greg.c) $(OUTPUT_OPTION) $<
|
||||
o/%.zip.o: o/%; @build/zipobj $(OUTPUT_OPTION) $<
|
||||
o/%.a: ; @$(COMPILE) -AARCHIVE -T$@ $(AR) $(ARFLAGS) $@ $^
|
||||
o/%.o: %.s ; @$(COMPILE) -AOBJECTIFY.s $(OBJECTIFY.s) $(OUTPUT_OPTION) $<
|
||||
o/%.o: o/%.s ; @$(COMPILE) -AOBJECTIFY.s $(OBJECTIFY.s) $(OUTPUT_OPTION) $<
|
||||
o/%.s: %.S ; @$(COMPILE) -APREPROCESS $(PREPROCESS) $(OUTPUT_OPTION) $<
|
||||
o/%.s: o/%.S ; @$(COMPILE) -APREPROCESS $(PREPROCESS) $(OUTPUT_OPTION) $<
|
||||
o/%.i: %.S ; @$(COMPILE) -APREPROCESS $(PREPROCESS) $(OUTPUT_OPTION) $<
|
||||
o/%.o: %.S ; @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) $<
|
||||
o/%.o: o/%.S ; @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) $<
|
||||
o/%.s: %.i ; @$(COMPILE) -ACOMPILE.i $(COMPILE.i) $(OUTPUT_OPTION) $<
|
||||
o/%.s: o/%.i ; @$(COMPILE) -ACOMPILE.i $(COMPILE.i) $(OUTPUT_OPTION) $<
|
||||
o/%.o: %.cc ; @$(COMPILE) -AOBJECTIFY.cxx $(OBJECTIFY.cxx) $(OUTPUT_OPTION) $<
|
||||
o/%.o: o/%.cc ; @$(COMPILE) -AOBJECTIFY.cxx $(OBJECTIFY.cxx) $(OUTPUT_OPTION) $<
|
||||
o/%.lds: %.lds ; @$(COMPILE) -APREPROCESS $(PREPROCESS.lds) $(OUTPUT_OPTION) $<
|
||||
o/%.inc: %.h ; @$(COMPILE) -APREPROCESS $(PREPROCESS) $(OUTPUT_OPTION) -D__ASSEMBLER__ -P $<
|
||||
o/%.pkg: ; @$(COMPILE) -APACKAGE -T$@ $(PKG) $(OUTPUT_OPTION) $(addprefix -d,$(filter %.pkg,$^)) $(filter %.o,$^)
|
||||
o/%.h.ok: %.h ; @$(COMPILE) -ACHECK.h $(COMPILE.c) -x c -g0 -o $@ $<
|
||||
o/%.h.okk: %.h ; @$(COMPILE) -ACHECK.h $(COMPILE.cxx) -x c++ -g0 -o $@ $<
|
||||
o/%.greg.o: %.greg.c ; @$(COMPILE) -AOBJECTIFY.greg $(OBJECTIFY.greg.c) $(OUTPUT_OPTION) $<
|
||||
o/%.zip.o: o/% ; @$(COMPILE) -AZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) $(OUTPUT_OPTION) $<
|
||||
|
||||
o/$(MODE)/%.a:; @$(ARCHIVE) $@ $^
|
||||
o/$(MODE)/%: o/$(MODE)/%.dbg; @ACTION=OBJCOPY TARGET=$@ build/do $(OBJCOPY) -SO binary $< $@
|
||||
o/$(MODE)/%.o: %.s; @TARGET=$@ build/assemble $(OBJECTIFY.s) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.o: o/$(MODE)/%.s; @TARGET=$@ build/assemble $(OBJECTIFY.s) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.s: %.S; @ACTION=PREPROCESS build/compile $(PREPROCESS) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.s: o/$(MODE)/%.S; @ACTION=PREPROCESS build/compile $(PREPROCESS) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.o: %.c; @ACTION=OBJECTIFY.c build/compile $(OBJECTIFY.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.o: %.f; @ACTION=OBJECTIFY.f build/compile $(OBJECTIFY.f) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.o: %.F; @ACTION=OBJECTIFY.F build/compile $(OBJECTIFY.F) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.o: o/$(MODE)/%.c; @ACTION=OBJECTIFY.c build/compile $(OBJECTIFY.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.ss: %.c; @ACTION=COMPILE.c build/compile $(COMPILE.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.ss: o/$(MODE)/%.c; @ACTION=OBJECTIFY.s build/compile $(COMPILE.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.i: %.S; @ACTION=PREPROCESS build/compile $(PREPROCESS) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.i: %.c; @ACTION=PREPROCESS build/compile $(PREPROCESS) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.i: %.cc; @ACTION=PREPROCESS build/compile $(PREPROCESS) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.i: o/$(MODE)/%.c; @ACTION=PREPROCESS build/compile $(PREPROCESS) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.h: %.c; @ACTION=AMALGAMATE build/compile $(PREPROCESS) $(OUTPUT_OPTION) -fdirectives-only -P $<
|
||||
o/$(MODE)/%.h: o/$(MODE)/%.c; @ACTION=AMALGAMATE build/compile $(PREPROCESS) $(OUTPUT_OPTION) -fdirectives-only -P $<
|
||||
o/$(MODE)/%.o: %.S; @ACTION=OBJECTIFY.S build/compile $(OBJECTIFY.S) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.o: o/$(MODE)/%.S; @ACTION=OBJECTIFY.S build/compile $(OBJECTIFY.S) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.s: %.i; @ACTION=COMPILE.i build/compile $(COMPILE.i) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.s: o/$(MODE)/%.i; @ACTION=COMPILE.i build/compile $(COMPILE.i) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.o: %.cc; @ACTION=OBJECTIFY.cxx build/compile $(OBJECTIFY.cxx) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.o: o/$(MODE)/%.cc; @ACTION=OBJECTIFY.cxx build/compile $(OBJECTIFY.cxx) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.lds: %.lds; @ACTION=PREPROCESS build/compile $(PREPROCESS.lds) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.h.ok: %.h; @ACTION=CHECK.h build/compile $(COMPILE.c) -x c -g0 -o $@ $<
|
||||
o/$(MODE)/%.h.okk: %.h; @ACTION=CHECK.h build/compile $(COMPILE.cxx) -x c++ -g0 -o $@ $<
|
||||
o/$(MODE)/%.o: %.greg.c; @ACTION=OBJECTIFY.greg build/compile $(OBJECTIFY.greg.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.greg.o: %.greg.c; @ACTION=OBJECTIFY.greg build/compile $(OBJECTIFY.greg.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.ansi.o: %.ansi.c; @ACTION=OBJECTIFY.ansi build/compile $(OBJECTIFY.ansi.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.ansi.o: %.c; @ACTION=OBJECTIFY.ansi build/compile $(OBJECTIFY.ansi.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.c99.o: %.c99.c; @ACTION=OBJECTIFY.c99 build/compile $(OBJECTIFY.c99.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.c11.o: %.c11.c; @ACTION=OBJECTIFY.c11 build/compile $(OBJECTIFY.c11.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.c2x.o: %.c2x.c; @ACTION=OBJECTIFY.c2x build/compile $(OBJECTIFY.c2x.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.initabi.o: %.initabi.c; @ACTION=OBJECTIFY.init build/compile $(OBJECTIFY.initabi.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.ncabi.o: %.ncabi.c; @ACTION=OBJECTIFY.nc build/compile $(OBJECTIFY.ncabi.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.real.o: %.c; @ACTION=OBJECTIFY.real build/compile $(OBJECTIFY.real.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.runs: o/$(MODE)/%; @ACTION=CHECK.runs TARGET=$< build/runcom $< $(TESTARGS) && touch $@
|
||||
o/$(MODE)/%.pkg:; @build/package $(OUTPUT_OPTION) $(addprefix -d,$(filter %.pkg,$^)) $(filter %.o,$^)
|
||||
o/$(MODE)/%.zip.o: %; @build/zipobj $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.a: ; @$(COMPILE) -AARCHIVE -T$@ $(AR) $(ARFLAGS) $@ $^
|
||||
o/$(MODE)/%: o/$(MODE)/%.dbg ; @$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
|
||||
o/$(MODE)/%.o: %.s ; @$(COMPILE) -AOBJECTIFY.s $(OBJECTIFY.s) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.o: o/$(MODE)/%.s ; @$(COMPILE) -AOBJECTIFY.s $(OBJECTIFY.s) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.s: %.S ; @$(COMPILE) -APREPROCESS $(PREPROCESS) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.s: o/$(MODE)/%.S ; @$(COMPILE) -APREPROCESS $(PREPROCESS) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.o: %.c ; @$(COMPILE) -AOBJECTIFY.c $(OBJECTIFY.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.o: %.f ; @$(COMPILE) -AOBJECTIFY.f $(OBJECTIFY.f) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.o: %.F ; @$(COMPILE) -AOBJECTIFY.F $(OBJECTIFY.F) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.o: o/$(MODE)/%.c ; @$(COMPILE) -AOBJECTIFY.c $(OBJECTIFY.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.ss: %.c ; @$(COMPILE) -ACOMPILE.c $(COMPILE.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.ss: o/$(MODE)/%.c ; @$(COMPILE) -AOBJECTIFY.s $(COMPILE.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.i: %.S ; @$(COMPILE) -APREPROCESS $(PREPROCESS) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.i: %.c ; @$(COMPILE) -APREPROCESS $(PREPROCESS) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.i: %.cc ; @$(COMPILE) -APREPROCESS $(PREPROCESS) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.i: o/$(MODE)/%.c ; @$(COMPILE) -APREPROCESS $(PREPROCESS) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.h: %.c ; @$(COMPILE) -AAMALGAMATE $(PREPROCESS) $(OUTPUT_OPTION) -fdirectives-only -P $<
|
||||
o/$(MODE)/%.h: o/$(MODE)/%.c ; @$(COMPILE) -AAMALGAMATE $(PREPROCESS) $(OUTPUT_OPTION) -fdirectives-only -P $<
|
||||
o/$(MODE)/%.o: %.S ; @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.o: o/$(MODE)/%.S ; @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.s: %.i ; @$(COMPILE) -ACOMPILE.i $(COMPILE.i) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.s: o/$(MODE)/%.i ; @$(COMPILE) -ACOMPILE.i $(COMPILE.i) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.o: %.cc ; @$(COMPILE) -AOBJECTIFY.cxx $(OBJECTIFY.cxx) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.o: o/$(MODE)/%.cc ; @$(COMPILE) -AOBJECTIFY.cxx $(OBJECTIFY.cxx) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.lds: %.lds ; @$(COMPILE) -APREPROCESS $(PREPROCESS.lds) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.h.ok: %.h ; @$(COMPILE) -ACHECK.h $(COMPILE.c) -x c -g0 -o $@ $<
|
||||
o/$(MODE)/%.h.okk: %.h ; @$(COMPILE) -ACHECK.h $(COMPILE.cxx) -x c++ -g0 -o $@ $<
|
||||
o/$(MODE)/%.o: %.greg.c ; @$(COMPILE) -AOBJECTIFY.greg $(OBJECTIFY.greg.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.greg.o: %.greg.c ; @$(COMPILE) -AOBJECTIFY.greg $(OBJECTIFY.greg.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.ansi.o: %.ansi.c ; @$(COMPILE) -AOBJECTIFY.ansi $(OBJECTIFY.ansi.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.ansi.o: %.c ; @$(COMPILE) -AOBJECTIFY.ansi $(OBJECTIFY.ansi.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.c99.o: %.c99.c ; @$(COMPILE) -AOBJECTIFY.c99 $(OBJECTIFY.c99.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.c11.o: %.c11.c ; @$(COMPILE) -AOBJECTIFY.c11 $(OBJECTIFY.c11.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.c2x.o: %.c2x.c ; @$(COMPILE) -AOBJECTIFY.c2x $(OBJECTIFY.c2x.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.initabi.o: %.initabi.c ; @$(COMPILE) -AOBJECTIFY.init $(OBJECTIFY.initabi.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.ncabi.o: %.ncabi.c ; @$(COMPILE) -AOBJECTIFY.nc $(OBJECTIFY.ncabi.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.real.o: %.c ; @$(COMPILE) -AOBJECTIFY.real $(OBJECTIFY.real.c) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%.runs: o/$(MODE)/% ; @$(COMPILE) -ACHECK -tT$@ $< $(TESTARGS)
|
||||
o/$(MODE)/%.pkg: ; @$(COMPILE) -APACKAGE -T$@ $(PKG) $(OUTPUT_OPTION) $(addprefix -d,$(filter %.pkg,$^)) $(filter %.o,$^)
|
||||
o/$(MODE)/%.zip.o: % ; @$(COMPILE) -AZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%-gcc.asm: %.c ; @$(COMPILE) -AOBJECTIFY.c $(OBJECTIFY.c) -S -g0 $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%-clang.asm: %.c ; @$(COMPILE) -AOBJECTIFY.c $(OBJECTIFY.c) -S -g0 $(OUTPUT_OPTION) $< || echo / need $(CLANG) >$@
|
||||
|
||||
o/$(MODE)/%-gcc.asm: %.c; @ACTION=OBJECTIFY.c build/compile $(OBJECTIFY.c) -S -g0 $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%-clang.asm: CC = $(CLANG)
|
||||
o/$(MODE)/%-clang.asm: %.c; @ACTION=OBJECTIFY.c build/compile $(OBJECTIFY.c) -S -g0 $(OUTPUT_OPTION) $< || echo / need $(CLANG) >$@
|
||||
o/$(MODE)/%-gcc.asm: %.f; @ACTION=OBJECTIFY.f build/compile $(OBJECTIFY.f) -S -g0 $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%-clang.asm: CC = $(CLANG)
|
||||
o/$(MODE)/%-clang.asm: %.f; @ACTION=OBJECTIFY.f build/compile $(OBJECTIFY.f) -S -g0 $(OUTPUT_OPTION) $< || echo / need $(CLANG) >$@
|
||||
o/$(MODE)/%-gcc.asm: %.F; @ACTION=OBJECTIFY.F build/compile $(OBJECTIFY.F) -S -g0 $(OUTPUT_OPTION) $<
|
||||
o/$(MODE)/%-clang.asm: CC = $(CLANG)
|
||||
o/$(MODE)/%-clang.asm: %.F; @ACTION=OBJECTIFY.F build/compile $(OBJECTIFY.F) -S -g0 $(OUTPUT_OPTION) $< || echo / need $(CLANG) >$@
|
||||
o/$(MODE)/%.lua: %.lua o/$(MODE)/third_party/lua/luac.com
|
||||
@$(COMPILE) -ALUAC -T$@ o/$(MODE)/third_party/lua/luac.com -s -o $@ $<
|
||||
|
||||
# ragel state machine compiler
|
||||
.PRECIOUS: build/bootstrap/%.c.gz
|
||||
o/$(MODE)/%.c: %.rl build/bootstrap/%.c.gz
|
||||
@mkdir -p $(dir $@)
|
||||
@$(GZ) $(ZFLAGS) -dc $(<:%.rl=build/bootstrap/%.c.gz) >$@
|
||||
-@ACTION=RAGEL build/do $(RAGEL) $(RAGELFLAGS) $(OUTPUT_OPTION) $<
|
||||
build/bootstrap/%.c.gz: %.rl
|
||||
@mkdir -p $(dir $@)
|
||||
@$(RAGEL) -o $(@:%.gz=%) $<
|
||||
@$(GZ) $(ZFLAGS) -f $(@:%.gz=%)
|
||||
%.svgz: %.rl
|
||||
@$(RAGEL) -V -p $< | $(DOT) -Tsvg | $(GZ) $(ZFLAGS) >$@
|
||||
o/$(MODE)/%-clang.asm: CC = $(CLANG)
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
|
||||
DD=${DD:-$(command -v dd)} || exit
|
||||
$DD if="$1" of="$1.bak" bs=4096 count=1 conv=notrunc 2>/dev/null
|
||||
"$@"
|
||||
rc=$?
|
||||
$DD if="$1.bak" of="$1" bs=4096 count=1 conv=notrunc 2>/dev/null
|
||||
exit $rc
|
||||
@@ -1,14 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
#
|
||||
# OVERVIEW
|
||||
#
|
||||
# SSH Command Wrapper
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This script, like most of our wrappers, asks the tooling to whine
|
||||
# less often.
|
||||
|
||||
exec ${SSH:-ssh} -o LogLevel=QUIET "$@"
|
||||
@@ -1,51 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
|
||||
MKDIR=${MKDIR:-$(command -v mkdir) -p} || exit
|
||||
CP=${CP:-$(command -v cp) -f} || exit
|
||||
SED=${SED:-$(command -v sed)} || exit
|
||||
|
||||
MODE=
|
||||
|
||||
OUT=
|
||||
FIRST=1
|
||||
OUTARG=0
|
||||
for x; do
|
||||
if [ $FIRST -eq 1 ]; then
|
||||
set --
|
||||
FIRST=0
|
||||
elif [ $OUTARG -eq 1 ]; then
|
||||
OUTARG=0
|
||||
OUT="$x"
|
||||
fi
|
||||
case "$x" in
|
||||
-o)
|
||||
OUTARG=1
|
||||
;;
|
||||
esac
|
||||
set -- "$@" "$x"
|
||||
done
|
||||
OUTDIR="${OUT%/*}"
|
||||
if [ "$OUTDIR" != "$OUT" ] && [ ! -d "$OUTDIR" ]; then
|
||||
$MKDIR "$OUTDIR" || exit 2
|
||||
fi
|
||||
|
||||
if [ -x "o/$MODE/tool/build/zipobj.com.dbg" ]; then
|
||||
set -- "o/$MODE/tool/build/zipobj.com.dbg" "$@"
|
||||
else
|
||||
if [ ! -x o/build/bootstrap/zipobj.com ]; then
|
||||
$MKDIR o/build/bootstrap &&
|
||||
$CP -a build/bootstrap/zipobj.com \
|
||||
o/build/bootstrap/zipobj.com || exit
|
||||
fi
|
||||
set -- o/build/bootstrap/zipobj.com "$@"
|
||||
fi
|
||||
|
||||
if [ "$SILENT" = "0" ]; then
|
||||
printf "%s\n" "$*" >&2
|
||||
else
|
||||
printf "$LOGFMT" "${ACTION:-ZIPOBJ}" "$3" >&2
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
@@ -16,7 +16,6 @@ DSP_BMP_A_SRCS = \
|
||||
$(DSP_BMP_A_SRCS_C)
|
||||
|
||||
DSP_BMP_A_OBJS = \
|
||||
$(DSP_BMP_A_SRCS:%=o/$(MODE)/%.zip.o) \
|
||||
$(DSP_BMP_A_SRCS_S:%.S=o/$(MODE)/%.o) \
|
||||
$(DSP_BMP_A_SRCS_C:%.c=o/$(MODE)/%.o)
|
||||
|
||||
|
||||
+11
-12
@@ -3,19 +3,18 @@
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/core/core.h"
|
||||
#include "libc/mem/mem.h"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#ifndef COSMOPOLITAN_DSP_CORE_C161_H_
|
||||
#define COSMOPOLITAN_DSP_CORE_C161_H_
|
||||
#include "libc/macros.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
#define EXTRA_SHARP 2
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#ifndef COSMOPOLITAN_DSP_CORE_C161S_H_
|
||||
#define COSMOPOLITAN_DSP_CORE_C161S_H_
|
||||
#include "dsp/core/c161.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
forceinline pureconst artificial signed char C161S(signed char al,
|
||||
|
||||
+3
-8
@@ -16,7 +16,6 @@ DSP_CORE_A_SRCS = \
|
||||
$(DSP_CORE_A_SRCS_C)
|
||||
|
||||
DSP_CORE_A_OBJS = \
|
||||
$(DSP_CORE_A_SRCS:%=o/$(MODE)/%.zip.o) \
|
||||
$(DSP_CORE_A_SRCS_S:%.S=o/$(MODE)/%.o) \
|
||||
$(DSP_CORE_A_SRCS_C:%.c=o/$(MODE)/%.o)
|
||||
|
||||
@@ -25,8 +24,10 @@ DSP_CORE_A_CHECKS = \
|
||||
$(DSP_CORE_A_HDRS:%=o/$(MODE)/%.ok)
|
||||
|
||||
DSP_CORE_A_DIRECTDEPS = \
|
||||
LIBC_NEXGEN32E \
|
||||
LIBC_INTRIN \
|
||||
LIBC_MEM \
|
||||
LIBC_NEXGEN32E \
|
||||
LIBC_STR \
|
||||
LIBC_TINYMATH \
|
||||
LIBC_STUBS
|
||||
|
||||
@@ -58,12 +59,6 @@ o/$(MODE)/dsp/core/det3.o: \
|
||||
OVERRIDE_CFLAGS += \
|
||||
-ffast-math
|
||||
|
||||
ifeq (,$(MODE))
|
||||
$(DSP_CORE_OBJS): \
|
||||
OVERRIDE_CFLAGS += \
|
||||
-fsanitize=address
|
||||
endif
|
||||
|
||||
DSP_CORE_LIBS = $(foreach x,$(DSP_CORE_ARTIFACTS),$($(x)))
|
||||
DSP_CORE_SRCS = $(foreach x,$(DSP_CORE_ARTIFACTS),$($(x)_SRCS))
|
||||
DSP_CORE_HDRS = $(foreach x,$(DSP_CORE_ARTIFACTS),$($(x)_HDRS))
|
||||
|
||||
+11
-12
@@ -3,19 +3,18 @@
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/core/core.h"
|
||||
|
||||
|
||||
+11
-12
@@ -3,19 +3,18 @@
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/core/core.h"
|
||||
|
||||
|
||||
+11
-12
@@ -3,19 +3,18 @@
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/core/core.h"
|
||||
|
||||
|
||||
+11
-12
@@ -3,19 +3,18 @@
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/core/core.h"
|
||||
#include "dsp/core/q.h"
|
||||
|
||||
+12
-13
@@ -3,22 +3,21 @@
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/core/core.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/mem/mem.h"
|
||||
|
||||
|
||||
+12
-13
@@ -3,22 +3,21 @@
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
|
||||
+13
-12
@@ -3,19 +3,18 @@
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/core/core.h"
|
||||
#include "dsp/core/gamma.h"
|
||||
@@ -24,6 +23,7 @@
|
||||
double rgb2stdpc(double x, double g) {
|
||||
return COMPANDLUMA_SRGB(x, g);
|
||||
}
|
||||
|
||||
double rgb2linpc(double x, double g) {
|
||||
return UNCOMPANDLUMA_SRGB(x, g);
|
||||
}
|
||||
@@ -31,6 +31,7 @@ double rgb2linpc(double x, double g) {
|
||||
double rgb2stdtv(double x) {
|
||||
return COMPANDLUMA_BT1886(x);
|
||||
}
|
||||
|
||||
double rgb2lintv(double x) {
|
||||
return UNCOMPANDLUMA_BT1886(x);
|
||||
}
|
||||
|
||||
@@ -3,25 +3,24 @@
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/core/q.h"
|
||||
#include "libc/assert.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
|
||||
@@ -3,24 +3,23 @@
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/core/core.h"
|
||||
#include "dsp/core/q.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
#ifndef COSMOPOLITAN_DSP_CORE_HALF_H_
|
||||
#define COSMOPOLITAN_DSP_CORE_HALF_H_
|
||||
#include "libc/macros.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
/**
|
||||
* Divides integer in half w/ rounding.
|
||||
*/
|
||||
#define HALF(X) (((X) + 1) / (2 / TYPE_INTEGRAL(typeof(X))))
|
||||
#define HALF(X) (((X) + 1) / 2)
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_DSP_CORE_HALF_H_ */
|
||||
+11
-12
@@ -3,19 +3,18 @@
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/core/core.h"
|
||||
#include "dsp/core/illumination.h"
|
||||
|
||||
+11
-12
@@ -3,19 +3,18 @@
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/core/core.h"
|
||||
#include "libc/math.h"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#ifndef COSMOPOLITAN_DSP_CORE_KS8_H_
|
||||
#define COSMOPOLITAN_DSP_CORE_KS8_H_
|
||||
#include "libc/macros.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#ifndef COSMOPOLITAN_DSP_CORE_KSS8_H_
|
||||
#define COSMOPOLITAN_DSP_CORE_KSS8_H_
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
/**
|
||||
|
||||
+11
-12
@@ -3,19 +3,18 @@
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/core/core.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
+11
-12
@@ -3,19 +3,18 @@
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/core/core.h"
|
||||
|
||||
|
||||
+24
-25
@@ -3,36 +3,35 @@
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
#define BIAS 0x84
|
||||
|
||||
/ Encodes audio sample with µ-Law.
|
||||
/
|
||||
/ This is both the highest quality and most widely supported
|
||||
/ telephony codec, whose use was phased out in the 2000's in
|
||||
/ favor of cost-saving GSM audio compression that was so bad
|
||||
/ consumers were willing to pay more cash, for the privilege
|
||||
/ of saving telcos even more money w/ text messaging. Mu Law
|
||||
/ reduces PCM data to half its original size, by diminishing
|
||||
/ audio bands not vocalized by human voice.
|
||||
/
|
||||
/ @param %edi is pcm sample
|
||||
/ @return %eax is uint8_t encoded sample
|
||||
// Encodes audio sample with µ-Law.
|
||||
//
|
||||
// This is both the highest quality and most widely supported
|
||||
// telephony codec, whose use was phased out in the 2000's in
|
||||
// favor of cost-saving GSM audio compression that was so bad
|
||||
// consumers were willing to pay more cash, for the privilege
|
||||
// of saving telcos even more money w/ text messaging. Mu Law
|
||||
// reduces PCM data to half its original size, by diminishing
|
||||
// audio bands not vocalized by human voice.
|
||||
//
|
||||
// @param %edi is pcm sample
|
||||
// @return %eax is uint8_t encoded sample
|
||||
mulaw: .leafprologue
|
||||
.profilable
|
||||
mov $BIAS,%eax
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#ifndef COSMOPOLITAN_DSP_CORE_Q_H_
|
||||
#define COSMOPOLITAN_DSP_CORE_Q_H_
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/math.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
|
||||
+17
-18
@@ -3,28 +3,27 @@
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
#include "libc/macros.internal.h"
|
||||
.align 16
|
||||
|
||||
/ Mixes audio.
|
||||
/
|
||||
/ @param rdi is # aligned int16[16] sample chunks to process
|
||||
/ @param rsi points to aligned pcm s16le input/output memory
|
||||
/ @param rdx points to aligned pcm s16le [0..1] input memory
|
||||
// Mixes audio.
|
||||
//
|
||||
// @param rdi is # aligned int16[16] sample chunks to process
|
||||
// @param rsi points to aligned pcm s16le input/output memory
|
||||
// @param rdx points to aligned pcm s16le [0..1] input memory
|
||||
sad16x8n:
|
||||
.leafprologue
|
||||
.profilable
|
||||
|
||||
+13
-14
@@ -3,23 +3,22 @@
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/core/core.h"
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/limits.h"
|
||||
|
||||
/**
|
||||
@@ -43,7 +42,7 @@ void scalevolume(size_t n, int16_t pcm[n][8], int p) {
|
||||
if (p > 15) p = 15;
|
||||
for (i = 0; i < n; ++i) {
|
||||
for (j = 0; j < 8; ++j) {
|
||||
pcm[i][j] = SAR(pcm[i][j], p);
|
||||
pcm[i][j] = pcm[i][j] >> p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-12
@@ -3,19 +3,18 @@
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "dsp/core/core.h"
|
||||
|
||||
|
||||
@@ -3,21 +3,20 @@
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
#include "libc/macros.internal.h"
|
||||
.source __FILE__
|
||||
|
||||
clamp4int256$core:
|
||||
|
||||
Loaded 100 of 17277 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user