changeset 1793:82e19ad18784 HEAD

If we don't have function foo, do it always as #define foo my_foo and create your own my_foo. Did this to pread/pwrite/madvise.
author Timo Sirainen <tss@iki.fi>
date Fri, 03 Oct 2003 17:50:48 +0300
parents ccd30c24201a
children e1a7e38c17ed
files src/lib/compat.c src/lib/compat.h src/lib/mmap-util.c src/lib/mmap-util.h
diffstat 4 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/compat.c	Mon Sep 29 17:15:05 2003 +0300
+++ b/src/lib/compat.c	Fri Oct 03 17:50:48 2003 +0300
@@ -97,14 +97,14 @@
 #endif
 
 #ifndef HAVE_PWRITE
-ssize_t pread(int fd, void *buf, size_t count, off_t offset)
+ssize_t my_pread(int fd, void *buf, size_t count, off_t offset)
 {
 	if (lseek(fd, offset, SEEK_SET) < 0)
 		return -1;
 	return read(fd, buf, count);
 }
 
-ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset)
+ssize_t my_pwrite(int fd, const void *buf, size_t count, off_t offset)
 {
 	if (lseek(fd, offset, SEEK_SET) < 0)
 		return -1;
--- a/src/lib/compat.h	Mon Sep 29 17:15:05 2003 +0300
+++ b/src/lib/compat.h	Fri Oct 03 17:50:48 2003 +0300
@@ -95,8 +95,10 @@
 #endif
 
 #ifndef HAVE_PWRITE
-ssize_t pread(int fd, void *buf, size_t count, off_t offset);
-ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
+#  define pread my_pread
+#  define pwrite my_pwrite
+ssize_t my_pread(int fd, void *buf, size_t count, off_t offset);
+ssize_t my_pwrite(int fd, const void *buf, size_t count, off_t offset);
 #endif
 
 /* ctype.h isn't safe with signed chars,
--- a/src/lib/mmap-util.c	Mon Sep 29 17:15:05 2003 +0300
+++ b/src/lib/mmap-util.c	Fri Oct 03 17:50:48 2003 +0300
@@ -38,8 +38,8 @@
 }
 
 #ifndef HAVE_MADVISE
-int madvise(void *start __attr_unused__, size_t length __attr_unused__,
-	    int advice __attr_unused__)
+int my_madvise(void *start __attr_unused__, size_t length __attr_unused__,
+	       int advice __attr_unused__)
 {
 }
 #endif
--- a/src/lib/mmap-util.h	Mon Sep 29 17:15:05 2003 +0300
+++ b/src/lib/mmap-util.h	Fri Oct 03 17:50:48 2003 +0300
@@ -15,7 +15,8 @@
 #endif
 
 #ifndef HAVE_MADVISE
-int madvise(void *start, size_t length, int advice);
+#  define madvise my_madvise
+int my_madvise(void *start, size_t length, int advice);
 #  ifndef MADV_NORMAL
 #    define MADV_NORMAL 0
 #    define MADV_RANDOM 0