Created
September 11, 2010 16:24
-
-
Save zaphar/575315 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define _XOPEN_SOURCE 500 | |
| #include <unistd.h> | |
| #include "output_buffer.h" | |
| void stdout_output_buffer ( int out_fd, uint8_t* buffer, size_t buffer_size ) | |
| { | |
| while ( buffer_size ) | |
| { | |
| const ssize_t r = write( out_fd, (void*) buffer, buffer_size ); | |
| buffer_size -= (size_t) r; | |
| buffer += (size_t) r; | |
| } | |
| // freebsd doesn't appear to have fdatasync | |
| // to get this to compile I had to patch this file | |
| // with some preprocessor directives conditionals | |
| // for freebsd. | |
| #ifndef __FreeBSD__ | |
| fdatasync( out_fd ); | |
| #else | |
| fsync( out_fd ); | |
| #endif | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment