There is similar code in Emacs. Look at the s-gnu.h file in the Emacs sources and and what it does for this. Make sure to conditionalize properly on _STDIO_USES_IOSTREAM, since the iolib definition (the one you cited for linux) will eventually become the right one for hurd too.