Skip to content

Commit

Permalink
rename to Neopolitan, update copyright year
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholatian committed Feb 12, 2021
1 parent 4b3c2db commit 0058223
Show file tree
Hide file tree
Showing 75 changed files with 263 additions and 299 deletions.
112 changes: 6 additions & 106 deletions COMPILING
Original file line number Diff line number Diff line change
@@ -1,113 +1,13 @@
Unilib Build Instructions
Neopolitan Build Instructions

Written by Alexander Nicholi

§1. PREREQUISITES
------------------
Copyright © 2019-2021 Aquefir
Released under BSD-2-Clause.

1. Arch Linux: base-devel, clang-format
2. Debian: gcc, g++, make, clang-format
3. macOS: XCode tools (note 1), clang-format

§2. BUILD COMMAND
------------------

As of October 2020, unilib has been restructured as a collection of smaller,
modular subfolders in this monorepo. Whenever calling ‘make’, use the -C flag
to tell it to change directories into the desired module’s folder. Note that
each module has a new DEPENDS file in its etc/ directory listing what other
modules it depends on at link time. Makefiles in unilib only build static
libraries.
-----

Use a POSIX-compliant shell, and run ‘make’ to build the default target
(debug). The ‘-j’ option is fully supported for job control, and can be given
an argument for the number of parallel jobs with the form ‘-j$(nproc)’ (on
Linux) or ‘-j$(sysctl -n hw.ncpu)’ (on macOS). The ‘-j$(nproc)’ form works on
macOS too if GNU coreutils is installed.

Several targets are available: debug, release, check, cov, and asan. Below is
a breakdown of each:

debug:
- default for daily development
- consumed nicely by GDB and LLDB
- all asserts enabled
- is unoptimised (-O0) for compilation speed

release:
- for shipping
- has no extra symbols at all
- uses -O2 or -O3 for maximum optimisation

check:
- run for sanity check before diving into the debugger
- turns on ALL warnings, and treats them as errors too
- a successful build is a happy codebase :o)

cov:
- the basic option for unit testing
- actual code coverage is still a WIP
- uses -O1 to provide unobtrusive optimisations

asan:
- a cheap but effective alternative to Valgrind
- requires rebuilding all 3rd-party dependencies with asan (tedious)
- also brings in the unit tests like ‘cov’

The default target is ‘debug’. There are also two additional phony targets,
‘clean’ and ‘format’: the former removes all build artefacts, while the latter
invokes the auto-formatter (usually clang-format, it’s defined as $(FMT) in
base.mk) to run on all the source and header files.

§3. TARGET PLATFORMS
---------------------

Development only happens on one of two platforms: macOS or Linux. All other
platforms are target-only, and macOS and Linux may be targets as well, of
course. The steps for each target will be described below.

Before compiling this repository, be sure to address each subfolder of the
3rdparty/ directory and compile them first. If you just cloned this repository
and the folder is empty, its README file will contain a list of dependencies
and their online locations. Download, clone or symlink them into that folder
to check them in.

§3.1. APPLE macOS
------------------

Targeting macOS is only supported natively. The process uses XCode command
line utilities along with GNU coreutils and binutils (obtainable by Homebrew).
Valgrind, LLDB, and normal debug/release/check builds are supported. On recent
versions of macOS (esp. Mojave and Catalina) you may need to dig around for a
patched Valgrind that runs on those versions.

§3.2. GNU/LINUX
----------------

Targeting Linux is only supported natively. The process can use GCC or LLVM
based tools, and both GCC and Clang are actively used in development. As with
macOS, Valgrind, LLDB, and the usual debug/release/check builds are supported.
GDB is used on Linux as the debugger of choice.

For its simplicity and sheer compilation speed, TinyCC is also used in
development builds. Set ‘CC=tcc’ in the make invocation to try it out.

§3.3. MICROSOFT WINDOWS
------------------------

Windows may be targeted for cross-compilation from either macOS or Linux.
MinGW-W64 is used to achieve this (provided by the system’s package manager),
and runtime testing is done in WINE. For now, this target is still very much a
work-in-progress.

§3.4. ANDROID (AOSP)
---------------------

Currently unevaluated. Pending support checks for a Google-free
cross-compilation environment.

§3.5. APPLE iOS
----------------

Currently unevaluated. Pending examination of Apple toolchains and C-friendly
APIs.
This is a big work-in-progress. integration of Cosmopolitan tooling is still
being investigated and worked on.
8 changes: 4 additions & 4 deletions CONTRIBUTING
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Unilib Contributor’s Guide
Neopolitan Contributor’s Guide

Written by Alexander Nicholi

Expand Down Expand Up @@ -28,9 +28,9 @@ order of abstraction:
§2. APPLICATION OF MODULARITY
------------------------------

1. Modules are in play with unilib, using Brian Will’s distinction of ‘state
modules’ and ‘logic modules’. This status is affixed onto every interface
(header file) when possible, for coordination.
1. Modules are in play with Neopolitan, using Brian Will’s distinction of
‘state modules’ and ‘logic modules’. This status is affixed onto every
interface (header file) when possible, for coordination.

2. Summary of Will’s video:
a. ‘state modules’: internally and externally stateful
Expand Down
85 changes: 65 additions & 20 deletions README
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
unilib
Neopolitan C
“A new city of code on a cosmopolitan foundation.”

<https://aquefir.co/neopolitan>
<https://github.com/aquefir/neopolitan>

Created by Alexander Nicholi
Copyright © 2019-2021 Aquefir
Expand All @@ -7,24 +11,59 @@ Released under BSD-2-Clause.
§1. WHAT IS THIS?
------------------

Unilib is one of the most heavily developed projects under the Aquefir
namesake. Its purpose is simple: provide primitive support functionality
Some time in 2019, I began work on a scratch-built libc surrogate that, for
lack of a better name, I called “unilib”. It was put under the Aquefir name,
and I took great care of its structure and quality. unilib was similar in
purpose to GLib, but with better attention paid to handling very old
platforms, chiefly the IBM PC and the Nintendo Game Boy Advance. It is also a
strictly ANSI C library, adhering to the standard as laid out by the ANSI
committee in 1989. Call me old-fashioned, but I love the language as it
originally was. Most of the “rough edges” I find quite beneficial from a
hygiene standpoint. Later features have shown to be superfluous at best, one
way or another.

Around the beginning of 2021, I discovered Justine Tunney’s work on her APE
format and libc implementation supporting it, and I recognised it for the
incredible research work on ABIs that it is. It has been awkward for me to
apply, given that it is strongly tied to the x86 ISA and I have actively cared
for targeting ARM. Despite that, I knew that the one big feature API that
Cosmopolitan was lacking was a good way to handle graphics. Neopolitan C is a
step on the path to making that happen.

For years I have had in pre-planning a graphics innovation called OAM, and
have not created it yet as I need to work out what exactly it depends on
first. Cosmopolitan C provides a wonderful generalisation of all the great x86
operating systems, and this generalisation is needed to avoid spending so much
more time targeting those as separate platforms. However, Cosmopolitan
provides the well-established C libraries most of these platforms can share -
it does not try to give any sort of new interface with better design. This is
where unilib comes in to play. Neopolitan is simply unilib-on-cosmopolitan.
With that in hand, the complexities of OAM can be worked through much more
quickly and effectively. Yeah, I think the library is really that much better
- there’s hardly a point otherwise!

Neopolitan is written in ANSI C, and always will be. The project uses the
Slick Makefiles for tooling out the development process, and SLI for
documentation.

§1.1. WHAT IS UNILIB?
----------------------

Unilib was one of the most heavily developed projects under the Aquefir
namesake. Its purpose was simple: provide primitive support functionality
for programs on a variety of platforms. These features are similar in nature
to the standard C library, and unilib does work without libc where it is
unavailable. The growing list of platforms it supports includes Microsoft
Windows (via Win32 APIs), Apple macOS, GNU/Linux, and the Nintendo Game Boy
Advance. Support for DOS systems on the IBM-PC is in planning too.

Unilib is written in ANSI C, and always will be. The project uses Slick
Makefiles for tooling out the development process.
unavailable. After much development, Cosmopolitan libc was discovered, and
unilib was migrated to target that platform with its APE format exclusively.
This is what is now known as Neopolitan.

§2. WHAT’S INSIDE THE BOX
--------------------------

Unilib provides shorthands for all kinds of primitive data types. These are
a good deal cleaner and quicker to type than those of <stdint.h>:
Neopolitan provides shorthands for all kinds of primitive data types. These
are a good deal cleaner and quicker to type than those of <stdint.h>:

unilib:
neopolitan:
u32, s16, u8, u64, ...

stdint:
Expand All @@ -34,15 +73,15 @@ There is also another shorthand called ptri (pronounced like ‘petri’). It is
an integer the same size as a pointer, and is used in place of size_t and the
like. There are also shorthands for exact-size floating point primitives.

Unilib provides math primitive structs for basic geometry in the 2D and 3D
Neopolitan provides math primitive structs for basic geometry in the 2D and 3D
contexts. It also includes structs for ranges (signed) and bounds (unsigned).
Additionally, there are also primitives for ‘vector types’; these use SIMD
intrinsics provided by the compiler where available, and transparently fall
back to plain array semantics otherwise.

Checked math macros are available to ensure against integer overflow. There
are also macros for endianness conversion operations. Unilib also provides a
portable uni_die() function that aborts the program, which is ideal for
are also macros for endianness conversion operations. Neopolitan also provides
a portable uni_die() function that aborts the program, which is ideal for
dealing with programmer errors.

UTF-8 validation, conversion, and inspection routines are also available.
Expand All @@ -55,10 +94,10 @@ which either wrap or implement logging and malloc where necessary.
§3. FOOTNOTES
--------------

Unilib is released under the BSD-2-Clause licence. See the COPYING file for
full terms.
Neopolitan is released under the BSD-2-Clause licence. See the COPYING file
for full terms.

Unilib adheres to ADP 1 for its repository layout, and ADP 2 for its
Neopolitan adheres to ADP 1 for its repository layout, and ADP 2 for its
documentation.

§4. REFERENCES & ADDITIONAL READING
Expand All @@ -67,11 +106,17 @@ documentation.
ISO/IEC 9899:1990. Programming Languages – C.
<https://www.iso.org/standard/17782.html>

Nicholi, Alexander. Slick.
<https://github.com/aquefir/slick>
Nicholi, Alexander. Slick Makefiles.
<https://github.com/adp4>

Nicholi, Alexander. Project repository filesystem schema.
<https://aquefir.co/adp1>

Nicholi, Alexander. Slick documentation format.
<https://aquefir.co/adp2>

Tunney, Justine. Cosmopolitan libc.
<https://justine.lol/cosmopolitan/index.html>

Tunney, Justine. Actually Portable Executable.
<https://justine.lol/ape.html>
4 changes: 2 additions & 2 deletions arr/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##############################################################################
## unilib arrays. ##
## neopolitan arrays. ##
## ##
## Copyright © 2019-2020 Aquefir ##
## Copyright © 2019-2021 Aquefir ##
## Released under BSD-2-Clause. ##
##############################################################################

Expand Down
8 changes: 4 additions & 4 deletions arr/etc/BOILERPLATE
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ This file contains the project’s copypastable boilerplate comment headers.
Boilerplate for C-like languages:

/****************************************************************************\
* unilib arrays. *
* neopolitan arrays. *
* *
* Copyright © 2019-2020 Aquefir *
* Copyright © 2019-2021 Aquefir *
* Released under BSD-2-Clause. *
\****************************************************************************/

Hash-based boilerplate (Python, POSIX shell, Makefile):

##############################################################################
## unilib arrays. ##
## neopolitan arrays. ##
## ##
## Copyright © 2019-2020 Aquefir ##
## Copyright © 2019-2021 Aquefir ##
## Released under BSD-2-Clause. ##
##############################################################################
8 changes: 4 additions & 4 deletions arr/etc/DEPENDS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
github.com/aquefir/unilib/decl
github.com/aquefir/unilib/err
github.com/aquefir/unilib/log
github.com/aquefir/unilib/himem
github.com/aquefir/neopolitan/decl
github.com/aquefir/neopolitan/err
github.com/aquefir/neopolitan/log
github.com/aquefir/neopolitan/himem
4 changes: 2 additions & 2 deletions arr/include/uni/arr.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/****************************************************************************\
* unilib arrays. *
* neopolitan arrays. *
* *
* Copyright © 2019-2020 Aquefir *
* Copyright © 2019-2021 Aquefir *
* Released under BSD-2-Clause. *
\****************************************************************************/

Expand Down
4 changes: 2 additions & 2 deletions arr/src/arr.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/****************************************************************************\
* unilib arrays. *
* neopolitan arrays. *
* *
* Copyright © 2019-2020 Aquefir *
* Copyright © 2019-2021 Aquefir *
* Released under BSD-2-Clause. *
\****************************************************************************/

Expand Down
4 changes: 2 additions & 2 deletions arr/src/arr.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/****************************************************************************\
* unilib arrays. *
* neopolitan arrays. *
* *
* Copyright © 2019-2020 Aquefir *
* Copyright © 2019-2021 Aquefir *
* Released under BSD-2-Clause. *
\****************************************************************************/

Expand Down
4 changes: 2 additions & 2 deletions arr/src/arr.tes.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/****************************************************************************\
* unilib arrays. *
* neopolitan arrays. *
* *
* Copyright © 2019-2020 Aquefir *
* Copyright © 2019-2021 Aquefir *
* Released under BSD-2-Clause. *
\****************************************************************************/

Expand Down
8 changes: 4 additions & 4 deletions chkmath/etc/BOILERPLATE
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ This file contains the project’s copypastable boilerplate comment headers.
Boilerplate for C-like languages:

/****************************************************************************\
* unilib checked maths *
* neopolitan checked maths *
* *
* Copyright © 2019-2020 Aquefir *
* Copyright © 2019-2021 Aquefir *
* Released under BSD-2-Clause. *
\****************************************************************************/

Hash-based boilerplate (Python, POSIX shell, Makefile):

##############################################################################
## unilib checked maths ##
## neopolitan checked maths ##
## ##
## Copyright © 2019-2020 Aquefir ##
## Copyright © 2019-2021 Aquefir ##
## Released under BSD-2-Clause. ##
##############################################################################
4 changes: 2 additions & 2 deletions chkmath/include/uni/chkmath.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/****************************************************************************\
* unilib checked maths *
* neopolitan checked maths *
* *
* Copyright © 2019-2020 Aquefir *
* Copyright © 2019-2021 Aquefir *
* Released under BSD-2-Clause. *
\****************************************************************************/

Expand Down
4 changes: 2 additions & 2 deletions decl/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##############################################################################
## unilib base declarations ##
## neopolitan base declarations ##
## ##
## Copyright © 2019-2020 Aquefir ##
## Copyright © 2019-2021 Aquefir ##
## Released under BSD-2-Clause. ##
##############################################################################

Expand Down
Loading

0 comments on commit 0058223

Please sign in to comment.