diff options
-rw-r--r-- | src/reader.c | 9 | ||||
-rw-r--r-- | wscript | 7 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/reader.c b/src/reader.c index d035448e..7c083dd6 100644 --- a/src/reader.c +++ b/src/reader.c @@ -14,6 +14,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#define _POSIX_C_SOURCE 201112L /* for posix_memalign */ + #include <assert.h> #include <errno.h> #include <stdarg.h> @@ -24,6 +26,7 @@ #include <string.h> #include "serd_internal.h" +#include "serd-config.h" #define NS_XSD "http://www.w3.org/2001/XMLSchema#" #define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#" @@ -1530,11 +1533,15 @@ serd_reader_read_file_handle(SerdReader* me, FILE* file, const uint8_t* name) { const Cursor cur = { name, 1, 1 }; me->fd = file; - me->read_buf = (uint8_t*)malloc(READ_BUF_LEN * 2); me->read_head = 0; me->cur = cur; me->from_file = true; me->eof = false; +#ifdef HAVE_POSIX_MEMALIGN + posix_memalign((void**)&me->read_buf, 4096, READ_BUF_LEN * 2); +#else + me->read_buf = (uint8_t*)malloc(READ_BUF_LEN * 2); +#endif /* Read into the second page of the buffer. Occasionally peek_string will move the read_head to before this point when readahead causes @@ -59,6 +59,13 @@ def configure(conf): if Options.options.largefile: conf.env.append_unique('CFLAGS', '-D_FILE_OFFSET_BITS=64') + # Check for posix_memalign + conf.check(function_name='posix_memalign', + header_name='stdlib.h', + define_name='HAVE_POSIX_MEMALIGN', + cflags='-D_POSIX_C_SOURCE=201112L', + mandatory=False) + autowaf.define(conf, 'SERD_VERSION', SERD_VERSION) conf.write_config_header('serd-config.h', remove=False) |