[A] review of the C standard library in practice,

All the numerous dangers of the standard libc. The article reviews many surfaces of the API and explains why they are misused in most of the case.

#api #c #library #libc

cynicalsecurity :cm_2:
5 months ago

I was looking at the 'Blinkenlights' project by Justine Tunney which is "a virtual machine that runs statically-compiled x86-64-linux programs on different operating systems and hardware architectures" (might as well let Justine describe it!) motivated by research on APE ("Actually Portable Executable")¹ ². #ActuallyPortableExecutable

After appreciating blink I looked at Justine's other repos, as one does, and… here's what I already bookmarked:

* "sectorlisp is a 512-byte implementation of LISP that's able to bootstrap John McCarthy's meta-circular evaluator on bare metal." - #Lisp

* "Cosmopolitan Libc 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." - #Libc #VirtualMachine #Polyglot (you should also look at the work by @Ange on the vast subject of polyglots)

* "Disaster lets you press C-c d to see the compiled assembly code for the C, C++ or Fortran file you're currently editing. It even jumps to and highlights the line of assembly corresponding to the line beneath your cursor." - #Emacs #EmacsLisp #Disassembler ( @anticomputer this one is for you…)

No apologies for sending you down this Github hole :flan_molotov:​ as it is more fun to go spelunking with friends!


Michael Connor Buchan
6 months ago

It's very annoying that #ISO #C has fixed-width integer types in stdint.h, but doesn't provide #libc functions for working with them, like for instance, strtoi32(). Heck, standard C doesn't even have strtoint() for regular ints!

the closest I've come is strtoi() which lets you specify bounds, so you could use E.G. INT32_MIN & INT32_MAX, but that's a nonstandard #BSD extension.

So you have to use a bunch of macro soup to fix this problem yourself and use strtoimax(), which defeats the entire point of the stdint types. 😤

IT News
7 months ago

Pretty Petite Picolibc Powers Processors - Many times when someone tells you that language X is “better” at something they re... - #softwaredevelopment #microcontrollers #standardlibrary #newlib #libc

Sungbin Jo
7 months ago

One of my frustrations with #macOS is that it has a broken wcwidth (a #libc function that gets the column width of a wide char).

It thinks each decomposed part of the character '국' (total 2 colums wide) is at least 1 column wide, hence thinking that the whole string needs 4 columns! (Left is the broken macOS, right is the correct Ubuntu.)

This wrecks the #shell line editor, and if I complete a Korean file name, I lose my cursor and the terminal starts erasing wrong characters. So frustrating…

The output of a test program ran on macOS that prints
7 for wcswidth "국어", 2 for wcwidth 'ᄀ' , 1for wcwidth 'ᅮ', 1for wcwidth 'ᆨ', 2 for wcwidth 'ᄋ', 1 for  wcwidth 'ᅥ'.
The output of a test program ran on Ubuntu that prints
4 for wcswidth "국어", 2 for wcwidth 'ᄀ' , 0 for wcwidth 'ᅮ', 0 for wcwidth 'ᆨ', 2 for wcwidth 'ᄋ', 0 for wcwidth 'ᅥ'.

Nice little adventure, but having limited precision can lead to more accumulated errors in your calculations 😬:

“Implementing Cosine In C From Scratch” [2020], Austin Henley (

Via HN:

#Math #Trigonometry #Cos #Cosine #LibC

1 year ago

#mlibc is a portable #libc.

mlibc is a #POSIX compatible standard library for #C that's specifically made to be portable between various platforms. Platform-specific code is isolated as much as possible, allowing porting to be as easy as possible. mlibc features support for #Linux as well as several hobby operating systems.

Website 🔗️:

#free #opensource #foss #fossmendations #programming

Boiling Steam
2 years ago

Linux Standard Library Implementations: X32 can be 10% faster, but musl Libc 40% slower: #linux #glibc #musl #libc #performance #comparison #standardlibrary #x32

2 years ago

#cosmopolitan #libc

We've just created a 336kb Lua interpreter binary that runs on seven operating systems, thanks to Cosmopolitan Libc.

2 years ago

#Cosmopolitan is a universal #C #libc.

Cosmopolitan is an optimized C #stdlib as well as compilation procedure that lets C programs run on #Linux, #Windows, #macOS, #FreeBSD, #OpenBSD, and even bare #BIOS with a single executable file. Cosmopolitan uses the Actually Portable Executable format to accomplish this, allowing for all supported platforms to run the code with no system modification.

Website 🔗️:

#free #opensource #foss #fossmendations #programming #development

3 years ago

Second patchset appears to work. Not nearly as complex as the first, turned out to be a couple of lines changed in exactly (I hope) the right places (after a week of what I like to call Staring Into The Void).

But still. This is all working too smoothly.

I'm getting The Fear.

#programming #libc

La communauté “Obsd4* - OpenBSD pour tous” annonce l’impérieuse nécessité de (sys)patcher OpenBSD !

#OpenBSD #obsd4a #syspatch #mesa #libc #xclock #xenodm
#amd64 #arm64 #i386 #multiarch #6.5 #6.6