(In the attached patch, the removal of 'const' from casts in a couple of files is only to remove a few cosmetic compiler warnings)
This patch should, so far as I can tell, be portable across all platforms.
With these changes, the test-suite has only one failure:
ERROR during test_streams
... which is caused by src/test_streams/test_streams, which fails silently.