Skip to content

Instantly share code, notes, and snippets.

@zaphar
Created September 11, 2010 16:24
Show Gist options
  • Select an option

  • Save zaphar/575315 to your computer and use it in GitHub Desktop.

Select an option

Save zaphar/575315 to your computer and use it in GitHub Desktop.
#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