aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/reader.c9
-rw-r--r--src/serdi.c9
-rw-r--r--wscript14
3 files changed, 31 insertions, 1 deletions
diff --git a/src/reader.c b/src/reader.c
index 42c5093f..68b5446d 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -25,6 +25,10 @@
#include <stdlib.h>
#include <string.h>
+#if defined(HAVE_POSIX_FADVISE) && defined(HAVE_FILENO)
+# include <fcntl.h>
+#endif
+
#include "serd_internal.h"
#include "serd-config.h"
@@ -1485,7 +1489,6 @@ serd_reader_get_handle(const SerdReader* reader)
{
return reader->handle;
}
-
SERD_API
void
serd_reader_add_blank_prefix(SerdReader* reader,
@@ -1518,6 +1521,10 @@ serd_reader_read_file(SerdReader* reader,
fprintf(stderr, "Error opening file %s (%s)\n", path, strerror(errno));
return SERD_ERR_UNKNOWN;
}
+#if defined(HAVE_POSIX_FADVISE) && defined(HAVE_FILENO)
+ posix_fadvise(fileno(fd), 0, 0, POSIX_FADV_SEQUENTIAL);
+#endif
+
SerdStatus ret = serd_reader_read_file_handle(reader, fd, path);
fclose(fd);
return ret;
diff --git a/src/serdi.c b/src/serdi.c
index c8bb9242..b3261eac 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -14,11 +14,17 @@
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 <stdlib.h>
#include <string.h>
+#if defined(HAVE_POSIX_FADVISE) && defined(HAVE_FILENO)
+# include <fcntl.h>
+#endif
+
#include "serd/serd.h"
#include "serd-config.h"
@@ -176,6 +182,9 @@ main(int argc, char** argv)
input, strerror(errno));
return 1;
}
+#if defined(HAVE_POSIX_FADVISE) && defined(HAVE_FILENO)
+ posix_fadvise(fileno(in_fd), 0, 0, POSIX_FADV_SEQUENTIAL);
+#endif
}
}
diff --git a/wscript b/wscript
index 9bc371d3..9c893f70 100644
--- a/wscript
+++ b/wscript
@@ -66,6 +66,20 @@ def configure(conf):
cflags='-D_POSIX_C_SOURCE=201112L',
mandatory=False)
+ # Check for posix_fadvise
+ conf.check(function_name='posix_fadvise',
+ header_name='fcntl.h',
+ define_name='HAVE_POSIX_FADVISE',
+ cflags='-D_POSIX_C_SOURCE=201112L',
+ mandatory=False)
+
+ # Check for fileno
+ conf.check(function_name='fileno',
+ header_name='stdio.h',
+ define_name='HAVE_FILENO',
+ cflags='-D_POSIX_C_SOURCE=201112L',
+ mandatory=False)
+
autowaf.define(conf, 'SERD_VERSION', SERD_VERSION)
conf.write_config_header('serd-config.h', remove=False)