Add p_strnlen wrapper and mingw implementation

Apparently MinGW can't be bothered to support POSIX strnlen so
this adds a p_strnlen wrapper which is a #define everywhere but
on MinGW, along with a quick little MinGW implementation.