shithub: docs.9front.org

Download patch

ref: a01b8642c3fd319efd13a5f90680fab759f627ee
parent: 85b81a8a5802d56f60a77e2477a019f0792fe1fb
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Mar 3 06:48:12 EST 2021

porting: add more stuff

--- a/porting.md
+++ b/porting.md
@@ -1,5 +1,17 @@
 # Porting alien software *without* APE
 
+Before getting started, make sure you wrote a decent amount of C and
+(mostly) aware of what you're doing.
+
+Ask around, perhaps someone already made the port.
+
+Consider writing a native program (or library) from scratch before
+approaching a port.
+
+Do NOT port anything for the sake of "porting" alone.
+
+## Process
+
 To get started on an easy port of a POSIX library (or a program), one
 can use
 [helpmeport](https://git.sr.ht/~ft/snippets/blob/master/helpmeport)
@@ -64,6 +76,10 @@
 In most of the cases, you can just add it to `src/plan9/plan9.h`.  Be
 careful if the size depends on the CPU you're targetting.
 
+### Some POSIX standard function is missing
+
+You could copy it from APE (`/sys/src/ape`) or just roll out your own.
+
 ### Some weird stuff with types/signatures not matching during linking
 
 This is probably caused by the compiler getting confused with forward
@@ -79,3 +95,17 @@
 
 placed after the type declaration.  It will tell the compiler not to
 bother too much.
+
+## Uncommon issues
+
+Your program builds fine, runs fine, doesn't crash, but produces
+incorrect result.  Chances are, you missed a `#pragma pack ...`, or
+perhaps there is a comparison between shorter (one or two-byte) types
+of different signedness.  That produces different result in Plan 9 C
+compiler.
+
+## Issues nobody wants to help you with
+
+* `wchar_t`. No.
+* `int128_t`. Just give up.
+* `pthread_*`.  Best is to give up.  If you *really* know what you're doing, take a look at [these ones](https://git.sr.ht/~ft/dav1d/blob/master/src/plan9_thread.c).