Currently, network.h includes a whole lot of platform specific headers (like u.h, windows.h, and unistd.h). We should confine these to a single file (or a few files).
I suggest we create a thin abstraction on the OS facilities for networking, and another on the ones for the monotonic clock. We could then have one file per platform kind (e.g. ${module}_win32.c, _unix.c, _osx.c, _posix.c, ...) and conditionally compile them according to preprocessor symbols, just like we do already. The downside is that it's a little bit more declaration overhead, because currently those #ifdefs are inside functions that will need to be redefined for each platform. The advantage is that there are no or few #ifdefs in the code itself, and the platform specific code is in a set of small files instead of (as it is now) in a 1100 line file mixing platform abstractions with application code.
Currently,
network.hincludes a whole lot of platform specific headers (likeu.h,windows.h, andunistd.h). We should confine these to a single file (or a few files).I suggest we create a thin abstraction on the OS facilities for networking, and another on the ones for the monotonic clock. We could then have one file per platform kind (e.g.
${module}_win32.c,_unix.c,_osx.c,_posix.c, ...) and conditionally compile them according to preprocessor symbols, just like we do already. The downside is that it's a little bit more declaration overhead, because currently those#ifdefs are inside functions that will need to be redefined for each platform. The advantage is that there are no or few#ifdefs in the code itself, and the platform specific code is in a set of small files instead of (as it is now) in a 1100 line file mixing platform abstractions with application code.