Category: C
Safe Kernel Programming with Rust
The discussion on whether FreeBSD should eventually replace C with Rust, produced a link to “Safe Kernel Programming with Rust“, a degree project in computer science and engineering, written by Johannes Lundberg while at KTH in Sweden. If you aim for printing the PDF file as two-sided, then print the following pages in the following […]
Read More → Safe Kernel Programming with Rustnamei
(1) from util-linux
on FreeBSD
After a couple of crude attempts at making my own versions of namei(1) this spring, namei.c and namei.go, I decided to take a look at the original. My goals were to see if I had made any mistakes, and if possible, have the original properly working on FreeBSD.
Read More →namei
(1) from util-linux
on FreeBSD
esrever.c
I had some fun this afternoon, writing a small program that writes its reversed input to output. Beware, this program is not UTF-8 safe. Have fun.
Read More → esrever.cDetecting clang in C code
If you’re looking for a way to detect when your code is being compiled by clang, try the command clang -dM -E -x c /dev/null In the large list presented, you’ll find these macros the most interesting ones:
Read More → Detecting clang in C codeObserving leap seconds
I came across a blog post by Emil Mikulic on the leap second introduced by the IERS on 1 July 2012. Inspired by Emil Mikulic’s blog post, I created the following short programme.
Read More → Observing leap secondsEn pthreadimplementasjon av Donald Knuths vennlige troll med lamper i den ene neven
Her er en enda eldre utgave av Donald Knuths vennlige troll med lamper i den ene neven. Fila var opprinnelig datert 31. desember 2002.
Read More → En pthreadimplementasjon av Donald Knuths vennlige troll med lamper i den ene nevenDonald Knuths vennlige troll med lamper i den ene neven – rekursiv implementasjon
Det er mye rart man finner når man går gjennom gamle filer. Her er litt programkode som jeg knotta inn for 10 år siden. Denne fila var opprinnelig datert 4. januar 2003.
Read More → Donald Knuths vennlige troll med lamper i den ene neven – rekursiv implementasjonFizzBuzz
An acquaintant posted on IRC a link to Jeff Atwood’s Coding Horror blog and his post entitled “Why Can’t Programmers.. Program?“. The task should be straightforward: Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print […]
Read More → FizzBuzzColourful and informative diagnostic by clang
clang is a breath of fresh air when it comes to deliver meaningful diagnostic of errors in program code. Not only is the diagnostic colourful on screen, clang also points out where in the source file changes ought to be made.
Read More → Colourful and informative diagnostic by clangSecret splitting
A few days ago I resurrected all my files from a desktop system I haven’t used for almost six years. Below is my implementation of secret splitting as described in Bruce Schneier’s book “Applied Cryptography, 2nd edition”. The idea is basically: generate a random keystream, xor the plaintext with the random keystream, use separate couriers […]
Read More → Secret splitting