The header shuffling in here broke the workaround for gnulib defining
"open".  Move it back before the sim-specific includes to fix.  This
is because the callback struct in the headers has an "open" member and
this file tries to call that.
 #include <unistd.h>
 #endif
 
+#undef open
+
 #include "sim-main.h"
 #include "sim-io.h"
 #include "sim/callback.h"
 
-#undef open
-
 /* Define the rate at which the simulator should poll the host
    for a quit. */
 #ifndef POLL_QUIT_INTERVAL