Take __weak out of the compiler namespace
authorBruce Cran <BCran@fusionio.com>
Sun, 10 Jul 2011 18:56:23 +0000 (20:56 +0200)
committerJens Axboe <jaxboe@fusionio.com>
Sun, 10 Jul 2011 18:56:23 +0000 (20:56 +0200)
With Xcode 4 on OS X shipping LLVM by default, I tried building fio with
clang and found that the definition of __weak conflicts with something
clang defines.  I've attached a patch which replaces the double
underscores with a single underscore, removing it from the
compiler-dependant namespace.

Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
compiler/compiler.h
helpers.c
helpers.h

index 33500a9b02a53c4259c307d69fff96d8c7369646..8dec350b9f9eb4e1c495e5c7aa1174b60169cbd3 100644 (file)
 
 #define uninitialized_var(x) x = x
 
-#ifndef __weak
+#ifndef _weak
 #ifndef __CYGWIN__
-#define __weak __attribute__((weak))
+#define _weak  __attribute__((weak))
 #else
-#define __weak
+#define _weak
 #endif
 #endif
 
index 377dd02ab66196f52e2dfbd6f12497002947ada7..1b6dea8e19b684862233a9814c82e9f299fb71c9 100644 (file)
--- a/helpers.c
+++ b/helpers.c
 #include "os/os.h"
 
 #ifndef __NR_fallocate
-int __weak posix_fallocate(int fd, off_t offset, off_t len)
+int _weak posix_fallocate(int fd, off_t offset, off_t len)
 {
        return 0;
 }
 #endif
 
-int __weak inet_aton(const char *cp, struct in_addr *inp)
+int _weak inet_aton(const char *cp, struct in_addr *inp)
 {
        return 0;
 }
 
-int __weak clock_gettime(clockid_t clk_id, struct timespec *ts)
+int _weak clock_gettime(clockid_t clk_id, struct timespec *ts)
 {
        struct timeval tv;
        int ret;
@@ -35,7 +35,7 @@ int __weak clock_gettime(clockid_t clk_id, struct timespec *ts)
 }
 
 #ifndef __NR_sync_file_range
-int __weak sync_file_range(int fd, off64_t offset, off64_t nbytes,
+int _weak sync_file_range(int fd, off64_t offset, off64_t nbytes,
                           unsigned int flags)
 {
        errno = ENOSYS;
index 607296328362b50d2c349c5a1dd481495310a299..7b1ad3493c60624863e60f67602b03cab86aa145 100644 (file)
--- a/helpers.h
+++ b/helpers.h
@@ -7,11 +7,11 @@
 
 struct in_addr;
 
-extern int __weak posix_memalign(void **ptr, size_t align, size_t size);
-extern int __weak posix_fallocate(int fd, off_t offset, off_t len);
-extern int __weak inet_aton(const char *cp, struct in_addr *inp);
-extern int __weak clock_gettime(clockid_t clk_id, struct timespec *ts);
-extern int __weak sync_file_range(int fd, off64_t offset, off64_t nbytes,
+extern int _weak posix_memalign(void **ptr, size_t align, size_t size);
+extern int _weak posix_fallocate(int fd, off_t offset, off_t len);
+extern int _weak inet_aton(const char *cp, struct in_addr *inp);
+extern int _weak clock_gettime(clockid_t clk_id, struct timespec *ts);
+extern int _weak sync_file_range(int fd, off64_t offset, off64_t nbytes,
                                        unsigned int flags);
 
 #endif /* FIO_HELPERS_H_ */