Making topology.c more portable