Use #if rather than #ifdef to check autoconf guards.
authorPeter Griess <pgriess@fb.com>
Mon, 7 Oct 2013 15:38:11 +0000 (08:38 -0700)
committerPeter Griess <pgriess@fb.com>
Tue, 15 Oct 2013 01:47:07 +0000 (18:47 -0700)
Summary:
- Replace instances of '#ifdef FOLLY_*' guards with '#if FOLLY_*'. This
allows the configuration system to disable the guard by defining the
value to 0 using the -D compiler flag.

Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Ubuntu/FC/Mac

Reviewed By: delong.j@fb.com

FB internal diff: D999129

folly/FileUtil.cpp
folly/FileUtil.h
folly/Malloc.h
folly/Portability.h
folly/io/RecordIO.cpp
folly/small_vector.h
folly/test/FileUtilTest.cpp

index 0c719a875358254d0136707c432c30aa4356ce0a..2977757fcbf3b7571b3a73295e1eb8e5bb4848ad 100644 (file)
@@ -132,7 +132,7 @@ ssize_t readvFull(int fd, iovec* iov, int count) {
   return wrapvFull(readv, fd, iov, count);
 }
 
-#ifdef FOLLY_HAVE_PREADV
+#if FOLLY_HAVE_PREADV
 ssize_t preadvFull(int fd, iovec* iov, int count, off_t offset) {
   return wrapvFull(preadv, fd, iov, count, offset);
 }
@@ -142,7 +142,7 @@ ssize_t writevFull(int fd, iovec* iov, int count) {
   return wrapvFull(writev, fd, iov, count);
 }
 
-#ifdef FOLLY_HAVE_PWRITEV
+#if FOLLY_HAVE_PWRITEV
 ssize_t pwritevFull(int fd, iovec* iov, int count, off_t offset) {
   return wrapvFull(pwritev, fd, iov, count, offset);
 }
index 93b843bf5646844e7b3805b194cd1992c27907eb..6b9325aef06c32d34b24e70d976994b8d981a572 100644 (file)
@@ -77,7 +77,7 @@ ssize_t writevNoInt(int fd, const iovec* iov, int count);
 ssize_t readFull(int fd, void* buf, size_t n);
 ssize_t preadFull(int fd, void* buf, size_t n, off_t offset);
 ssize_t readvFull(int fd, iovec* iov, int count);
-#ifdef FOLLY_HAVE_PREADV
+#if FOLLY_HAVE_PREADV
 ssize_t preadvFull(int fd, iovec* iov, int count, off_t offset);
 #endif
 
@@ -98,7 +98,7 @@ ssize_t preadvFull(int fd, iovec* iov, int count, off_t offset);
 ssize_t writeFull(int fd, const void* buf, size_t n);
 ssize_t pwriteFull(int fd, const void* buf, size_t n, off_t offset);
 ssize_t writevFull(int fd, iovec* iov, int count);
-#ifdef FOLLY_HAVE_PWRITEV
+#if FOLLY_HAVE_PWRITEV
 ssize_t pwritevFull(int fd, iovec* iov, int count, off_t offset);
 #endif
 
index 94a172b3bdc2552ee5fd3b8b766536e15f6811d0..f7c94ca1896f79cb707c04501db606134dd0e5cd 100644 (file)
@@ -49,7 +49,7 @@ namespace folly {
 // for malloc_usable_size
 // NOTE: FreeBSD 9 doesn't have malloc.h.  It's defitions
 // are found in stdlib.h.
-#ifdef FOLLY_HAVE_MALLOC_H
+#if FOLLY_HAVE_MALLOC_H
 #include <malloc.h>
 #else
 #include <stdlib.h>
index fe38d6b5bbbc682f47ca3e152f65ce0544e1d0f0..1095164f4474a85c7624b348f00d0ce1145e0900 100644 (file)
 #include "folly-config.h"
 #endif
 
-#ifdef FOLLY_HAVE_FEATURES_H
+#if FOLLY_HAVE_FEATURES_H
 #include <features.h>
 #endif
 
 
-#ifdef FOLLY_HAVE_SCHED_H
+#if FOLLY_HAVE_SCHED_H
  #include <sched.h>
  #ifndef FOLLY_HAVE_PTHREAD_YIELD
   #define pthread_yield sched_yield
index a407505736b9b6a211e2afd3729661da28857cdb..9dcf3c917227df2fa3f1993f3df8b0ac38bfd679 100644 (file)
@@ -56,7 +56,7 @@ void RecordIOWriter::write(std::unique_ptr<IOBuf> buf) {
   // We're going to write.  Reserve space for ourselves.
   off_t pos = filePos_.fetch_add(totalLength);
 
-#ifdef FOLLY_HAVE_PWRITEV
+#if FOLLY_HAVE_PWRITEV
   auto iov = buf->getIov();
   ssize_t bytes = pwritevFull(file_.fd(), iov.data(), iov.size(), pos);
 #else
index ed2c44f1ebe8cac78930b7cd10b88e7500209691..373b839311f80aaecab8da24f2289427753de6b1 100644 (file)
@@ -54,9 +54,9 @@
 # define FB_PACKED
 #endif
 
-#ifdef FOLLY_HAVE_MALLOC_SIZE
+#if FOLLY_HAVE_MALLOC_SIZE
   extern "C" std::size_t malloc_size(const void*);
-# ifndef FOLLY_HAVE_MALLOC_USABLE_SIZE
+# if !FOLLY_HAVE_MALLOC_USABLE_SIZE
 #  define malloc_usable_size malloc_size
 # endif
 # ifndef malloc_usable_size
index b35a3abe2c1d354875dc0ec94fd9e3b316472894..f466f11fbba0b1e78aee6d175b47bb77b905ae92 100644 (file)
@@ -222,7 +222,7 @@ TEST_F(FileUtilTest, readv) {
   }
 }
 
-#ifdef FOLLY_HAVE_PREADV
+#if FOLLY_HAVE_PREADV
 TEST_F(FileUtilTest, preadv) {
   for (auto& p : readers_) {
     IovecBuffers buf({12, 19, 31});