Commit a7426cc4 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

cut macro FOLLY_HAVE_EVENTFD

Summary: No place which defines this nominally owns the name.

Reviewed By: Gownta

Differential Revision: D32632858

fbshipit-source-id: ab5ee161b7c80f08a177c752c4bfe693cf9c9de3
parent 9549eeb5
...@@ -28,7 +28,7 @@ EventBaseAtomicNotificationQueue<Task, Consumer>:: ...@@ -28,7 +28,7 @@ EventBaseAtomicNotificationQueue<Task, Consumer>::
: pid_(get_cached_pid()), : pid_(get_cached_pid()),
notificationQueue_(), notificationQueue_(),
consumer_(std::move(consumer)) { consumer_(std::move(consumer)) {
#ifdef FOLLY_HAVE_EVENTFD #if __has_include(<sys/eventfd.h>)
eventfd_ = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); eventfd_ = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
if (eventfd_ == -1) { if (eventfd_ == -1) {
if (errno == ENOSYS || errno == EINVAL) { if (errno == ENOSYS || errno == EINVAL) {
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include <folly/portability/Unistd.h> #include <folly/portability/Unistd.h>
#if __has_include(<sys/eventfd.h>) #if __has_include(<sys/eventfd.h>)
#define FOLLY_HAVE_EVENTFD
#include <sys/eventfd.h> #include <sys/eventfd.h>
#endif #endif
......
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
#include <folly/system/Pid.h> #include <folly/system/Pid.h>
#if __has_include(<sys/eventfd.h>) #if __has_include(<sys/eventfd.h>)
#define FOLLY_HAVE_EVENTFD
#include <sys/eventfd.h> #include <sys/eventfd.h>
#endif #endif
...@@ -236,10 +235,8 @@ class NotificationQueue { ...@@ -236,10 +235,8 @@ class NotificationQueue {
}; };
enum class FdType { enum class FdType {
PIPE, PIPE = 1,
#ifdef FOLLY_HAVE_EVENTFD
EVENTFD, EVENTFD,
#endif
}; };
/** /**
...@@ -258,18 +255,18 @@ class NotificationQueue { ...@@ -258,18 +255,18 @@ class NotificationQueue {
* mostly for testing purposes. * mostly for testing purposes.
*/ */
explicit NotificationQueue( explicit NotificationQueue(
uint32_t maxSize = 0, uint32_t maxSize = 0, FdType fdType = FdType::EVENTFD)
#ifdef FOLLY_HAVE_EVENTFD
FdType fdType = FdType::EVENTFD)
#else
FdType fdType = FdType::PIPE)
#endif
: eventfd_(-1), : eventfd_(-1),
pipeFds_{-1, -1}, pipeFds_{-1, -1},
advisoryMaxQueueSize_(maxSize), advisoryMaxQueueSize_(maxSize),
pid_(folly::get_cached_pid()) { pid_(folly::get_cached_pid()) {
#if !__has_include(<sys/eventfd.h>)
if (fdType == FdType::EVENTFD) {
fdType = FdType::PIPE;
}
#endif
#ifdef FOLLY_HAVE_EVENTFD #if __has_include(<sys/eventfd.h>)
if (fdType == FdType::EVENTFD) { if (fdType == FdType::EVENTFD) {
eventfd_ = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); eventfd_ = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
if (eventfd_ == -1) { if (eventfd_ == -1) {
...@@ -289,6 +286,7 @@ class NotificationQueue { ...@@ -289,6 +286,7 @@ class NotificationQueue {
} }
} }
#endif #endif
if (fdType == FdType::PIPE) { if (fdType == FdType::PIPE) {
if (pipe(pipeFds_)) { if (pipe(pipeFds_)) {
folly::throwSystemError( folly::throwSystemError(
......
...@@ -499,7 +499,6 @@ TEST(NotificationQueueTest, ConsumeUntilDrainedStress) { ...@@ -499,7 +499,6 @@ TEST(NotificationQueueTest, ConsumeUntilDrainedStress) {
} }
} }
#ifdef FOLLY_HAVE_EVENTFD
TEST(NotificationQueueTest, SendOneEventFD) { TEST(NotificationQueueTest, SendOneEventFD) {
QueueTest qt(0, IntQueue::FdType::EVENTFD); QueueTest qt(0, IntQueue::FdType::EVENTFD);
qt.sendOne(); qt.sendOne();
...@@ -529,7 +528,6 @@ TEST(NotificationQueueTest, DestroyCallbackEventFD) { ...@@ -529,7 +528,6 @@ TEST(NotificationQueueTest, DestroyCallbackEventFD) {
QueueTest qt(0, IntQueue::FdType::EVENTFD); QueueTest qt(0, IntQueue::FdType::EVENTFD);
qt.destroyCallback(); qt.destroyCallback();
} }
#endif
TEST(NotificationQueueTest, SendOnePipe) { TEST(NotificationQueueTest, SendOnePipe) {
QueueTest qt(0, IntQueue::FdType::PIPE); QueueTest qt(0, IntQueue::FdType::PIPE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment