Including semaphore.h fails with an error about missing mode_t. The problem can be exhibited with
Various work-arounds are possible. Including sys/stat.h before semaphore.h seems to provide the required definition.
This was reported as a problem when building Poly/ML on Mingw. It uses autoconf to detect the header files and includes semaphore.h if it is
present. It does not actually use semaphores on native Windows, instead using native Windows functions so I have worked around this by only
including semaphore.h if it going to be used.