Useful UNIX API:s

Had an interesting conversation with a buddy last night. It started out as a shift-reduce problem with Bison and ended up a ping-pong of useful UNIX API:s. We concluded that despite having worked professionally with UNIX for over a decade, it is still very satisfying finding gems like these.

Most people are completely unaware they exist and end up rolling their own (buggy) implementations. For instance, string manipulation and various forms of linked lists. Which is why I many years ago extracted the frog DNA from Finit to a separate library called libite, or -lite for short. It imports the OpenBSD strlcpy() family of API:s, up-to-date queue.h with the _SAFE iterators, and more. Some people like libbsd for this, but I’ve found many of the ports incomplete and unsafe and prefer to stay closer to the upstream *BSD versions.

Update: This post was originally written Nov 14, 2015. It was a Saturday and I remember being extremely inspired when I wrote it. I’ve continued adding to it over the years, and still do. So, as of Jul 2, 2017 I’m bumping the modification date each time I add something new :-)

[Read More]

Threads vs Event Loop, Again ...

I still get asked this, from time to time. Maybe it’s because I only use event loops, maybe it’s because I’ve written libuEv, or maybe people still don’t understand:

Why an event loop, why not use threads?

So here’s my response, once more.

[Read More]

Summer of Code 2015

Summer is now slowly fading away, and what a summer it has been here in Sweden! For someone who isn’t a fan of the summer heat it has been an awesome time for brain work, and in my case work on my open source projects! :-) Due to my not really taking much vacation previous years I had saved up for ten weeks (10) this year! It was really worth it, and for the first time in many years I actually feel rested. [Read More]

Rant: All the C Compiler Warnings ...

Enable all the warnings!

This is one of the truths you learn when you start working with C. Most of the time adding CPPFLAGS="-W -Wall -Werror" is all you need to find all the nasty bugs. And if that’s not enough, there are tons of tools for static code analysis, like scan-build in Clang, and Coverity Scan, to help you find all the bugs!

However, these pesky warnings (some of which cannot even be disabled!) are sometimes more of a nuisance than help. Sometimes you know that some parameters to a function will remain unused – it’s a callback, and you don’t need all the data given to you. So you start adding all kinds of voodoo, like __attribute__ ((unused)) … seriously?

[Read More]

Just a Programmer

Sometimes people ask me what I do for a living. Usually I tend to pause and think, real hard, becuase the people asking me this aren’t programmers. They use computers, but are mostly limited to a Windows machine, writing in MS Word and browsing the Internet, mostly for Facebook.

I often start off with: “It’s a bit complicated to explain … “, by which time I’ve lost most of the people in the room listening to me. Sometimes I say: “I’m a software architect.”, because people seem to know what architects do for a living, they draw houses, design stuff and drive SAAB’s. Much like dentists. The prefix “software” however does confuse people.

[Read More]

Programming as an Artform

This is a response to the excellent post by Jani Gorše, titled Why is Programming an Art?

Ever since I began studying Computer Engineering at university back in 1995 I have struggled to find the “proper” ways to format my code, name functions and variables appropriately, structure functions into files and files into directories with Makefiles and Makefile snippets, using both recursive and non-recursive make. Formatting of code, for instance, was for a while a bit of an obsession of mine, and it sort of is still. But today I am more concerned with the overall structure and how components interact. Even though I can still get very annoyed at people naming their local variables obtrusively.

[Read More]

Brief libev update

I have now updated the libev examples. It took me a while, but during that time I have been hard at work converting two of our network daemons to use libev. As of today the upcoming Westermo WeOS uses libev in both its rstpd and igmpd implementations. Updated example code: timer test message queue test Enjoy, and feel free to [contact me][6] if you have any questions or comments on the code. [Read More]

The Marvellous libev

A very good friend mine recently told me about a neat event library, libev. Usually when he drops me links like that it takes me a couple of years to react and finally adopt. This time it only took me about a month. He has actually showed me lots of very useful stuff throughout the years, and even though we used GNU/Linux at university, he was one those hard core people who showed me the path into a successful full-time career as a Linux developer. [Read More]

Why I Like C

I thought I was alone, but it turns out I’m not. Scott James Remnant describes exactly what I’ve been feeling the last couple of years. Read his blog entry on the subject. I couldn’t agree more.

Netork Programming -- Link Collection

This is a first effort at collecting information about network programming structs and APIs available in UNIX. I plan on updating this as I find more. Linux Journal: Linux Network Programming, Part I, II, III. Linux Journal: Multicast Routing Code in the Linux Kernel Linux Journal: Inside the Linux Packet Filter, Part I, II /usr/include/netinet/in.h There are of course, in addition to these fine sources, the entire catalogue of work by Richard M. [Read More]