Get Cosmopolitan into releasable state

A new rollup tool now exists for flattening out the headers in a way
that works better for our purposes than cpp. A lot of the API clutter
has been removed. APIs that aren't a sure thing in terms of general
recommendation are now marked internal.

There's now a smoke test for the amalgamation archive and gigantic
header file. So we can now guarantee you can use this project on the
easiest difficulty setting without the gigantic repository.

A website is being created, which is currently a work in progress:
https://justine.storage.googleapis.com/cosmopolitan/index.html
This commit is contained in:
Justine Tunney 2020-11-25 08:19:00 -08:00
parent dba7552c1e
commit ea0b5d9d1c
775 changed files with 6864 additions and 3963 deletions

View file

@ -28,6 +28,10 @@ TEST(bitreverse, test) {
EXPECT_EQ(0xde00, (bitreverse16)(123));
EXPECT_EQ(0xde000000u, bitreverse32(123));
EXPECT_EQ(0xde000000u, (bitreverse32)(123));
EXPECT_EQ(0xde00000000000000ul, bitreverse64(123));
EXPECT_EQ(0xde00000000000000ul, (bitreverse64)(123));
EXPECT_EQ(0x482d96c305f7c697ul, bitreverse64(0xe963efa0c369b412));
EXPECT_EQ(0x482d96c305f7c697ul, (bitreverse64)(0xe963efa0c369b412));
}
BENCH(bitreverse, bench) {

View file

@ -1,66 +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 "libc/bits/bits.h"
#include "libc/testlib/testlib.h"
TEST(bt_uint16x4, test) {
uint16_t v[4] = {0};
EXPECT_FALSE(bt(v, 0));
EXPECT_FALSE(bt(v, 63));
EXPECT_FALSE(bts(v, 63));
EXPECT_TRUE(bt(v, 63));
EXPECT_TRUE(bts(v, 63));
}
TEST(bt_uint32x2, test) {
uint32_t v[2] = {0};
EXPECT_FALSE(bt(v, 0));
EXPECT_FALSE(bt(v, 63));
EXPECT_FALSE(bts(v, 63));
EXPECT_TRUE(bt(v, 63));
EXPECT_TRUE(bts(v, 63));
}
TEST(bt_uint64x1, test) {
uint64_t v = 0;
EXPECT_FALSE(bt(&v, 0));
EXPECT_FALSE(bt(&v, 63));
EXPECT_FALSE(bts(&v, 63));
EXPECT_TRUE(bt(&v, 63));
EXPECT_TRUE(bts(&v, 63));
}
TEST(bt_uint64, testPresent) {
uint64_t v = 1;
EXPECT_TRUE(bt(&v, 0));
EXPECT_FALSE(bt(&v, 63));
v = 0x8000000000000001;
EXPECT_TRUE(bt(&v, 0));
EXPECT_TRUE(bt(&v, 63));
}
TEST(bt_uint64, testPresent_avoidingDeadCodeElimination) {
volatile uint64_t v = 1;
EXPECT_TRUE(bt(&v, 0));
EXPECT_FALSE(bt(&v, 63));
v = 0x8000000000000001;
EXPECT_TRUE(bt(&v, 0));
EXPECT_TRUE(bt(&v, 63));
}

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/bits/bits.h"
#include "libc/bits/progn.h"
#include "libc/bits/progn.internal.h"
#include "libc/testlib/ezbench.h"
#include "libc/testlib/testlib.h"

View file

@ -22,6 +22,9 @@
#include "libc/macros.h"
#include "libc/testlib/testlib.h"
#define ROR(w, k) (CheckUnsigned(w) >> (k) | (w) << (sizeof(w) * 8 - (k)))
#define ROL(w, k) ((w) << (k) | CheckUnsigned(w) >> (sizeof(w) * 8 - (k)))
TEST(TwosComplementBane, LiteralsThatAreLiterallyTheSameNumber) {
EXPECT_EQ(4, sizeof(INT_MIN));
EXPECT_EQ(8, sizeof(-2147483648));
@ -30,12 +33,6 @@ TEST(TwosComplementBane, LiteralsThatAreLiterallyTheSameNumber) {
EXPECT_FALSE(TYPE_SIGNED(-0x80000000));
}
TEST(ShiftArithmeticRight, DeclassifiedByGuySteele) {
EXPECT_EQ(-1u, SAR(-2u, 1u));
EXPECT_EQ(-1u, SAR(-1u, 1u));
EXPECT_EQ(0xc0000000u, SAR(0x80000000u, 1u));
}
TEST(RotateRight, Test) {
EXPECT_EQ(0x41122334u, ROR(0x11223344u, 4));
EXPECT_EQ(0x44112233u, ROR(0x11223344u, 8));

View file

@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/bits/safemacros.h"
#include "libc/bits/safemacros.internal.h"
#include "libc/testlib/testlib.h"
TEST(unsignedsubtract, testMacro) {