Commit 70d84dd8 authored by Henry Wang's avatar Henry Wang Committed by Facebook GitHub Bot

Use #if FOLLY_HAVE_SO_TIMESTAMPING

Summary:
D24094832 (https://github.com/facebook/folly/commit/842ecea531e8d6a90559f213be3793f7cd36781b) enabled code blocks which were currently not supported with SGX build mode, resulting in fbenclave build errs [T85891699].

Our SGX targets depend on folly and are built with a custom toolchain. Because of our dep constraints we don't support all features. We typically try to toggle certain folly features, for example: https://www.internalfb.com/intern/diffusion/FBS/browsefile/master/tools/buckconfigs/fbcode/sgx.bcfg?commit=8981fc7187d8b2484a764e9277a1efa082a13f50&lines=36

We were unable to disable these blocks of code because this macro was defined to be 1. We would typically just add the compiler flag: -DFOLLY_HAVE_SO_TIMESTAMPING=0. But doing causes redefinition.

Reviewed By: bschlinker

Differential Revision: D26765404

fbshipit-source-id: 06d800efa7f23d9235a019ed7cc8fe4cde53c91c
parent 694a416e
...@@ -79,7 +79,7 @@ static AsyncSocketException const& getSocketShutdownForWritesEx() { ...@@ -79,7 +79,7 @@ static AsyncSocketException const& getSocketShutdownForWritesEx() {
} }
namespace { namespace {
#ifdef FOLLY_HAVE_SO_TIMESTAMPING #if FOLLY_HAVE_SO_TIMESTAMPING
const sock_extended_err* FOLLY_NULLABLE const sock_extended_err* FOLLY_NULLABLE
cmsgToSockExtendedErr(const cmsghdr& cmsg) { cmsgToSockExtendedErr(const cmsghdr& cmsg) {
if ((cmsg.cmsg_level == SOL_IP && cmsg.cmsg_type == IP_RECVERR) || if ((cmsg.cmsg_level == SOL_IP && cmsg.cmsg_type == IP_RECVERR) ||
...@@ -322,7 +322,7 @@ void AsyncSocket::SendMsgParamsCallback::getAncillaryData( ...@@ -322,7 +322,7 @@ void AsyncSocket::SendMsgParamsCallback::getAncillaryData(
if (!ancillaryDataSize) { if (!ancillaryDataSize) {
return; return;
} }
#ifdef FOLLY_HAVE_MSG_ERRQUEUE #if FOLLY_HAVE_SO_TIMESTAMPING
CHECK_NOTNULL(data); CHECK_NOTNULL(data);
// this function only handles ancillary data for timestamping // this function only handles ancillary data for timestamping
// //
...@@ -353,7 +353,7 @@ void AsyncSocket::SendMsgParamsCallback::getAncillaryData( ...@@ -353,7 +353,7 @@ void AsyncSocket::SendMsgParamsCallback::getAncillaryData(
memcpy(CMSG_DATA(cmsg), &sofFlags, sizeof(sofFlags)); memcpy(CMSG_DATA(cmsg), &sofFlags, sizeof(sofFlags));
#else #else
(void)data; (void)data;
#endif #endif // FOLLY_HAVE_SO_TIMESTAMPING
return; return;
} }
...@@ -374,7 +374,7 @@ uint32_t AsyncSocket::SendMsgParamsCallback::getAncillaryDataSize( ...@@ -374,7 +374,7 @@ uint32_t AsyncSocket::SendMsgParamsCallback::getAncillaryDataSize(
folly::Optional<AsyncSocket::ByteEvent> folly::Optional<AsyncSocket::ByteEvent>
AsyncSocket::ByteEventHelper::processCmsg( AsyncSocket::ByteEventHelper::processCmsg(
const cmsghdr& cmsg, const size_t rawBytesWritten) { const cmsghdr& cmsg, const size_t rawBytesWritten) {
#ifdef FOLLY_HAVE_SO_TIMESTAMPING #if FOLLY_HAVE_SO_TIMESTAMPING
if (!byteEventsEnabled || maybeEx.has_value()) { if (!byteEventsEnabled || maybeEx.has_value()) {
return folly::none; return folly::none;
} }
...@@ -1312,7 +1312,7 @@ void AsyncSocket::enableByteEvents() { ...@@ -1312,7 +1312,7 @@ void AsyncSocket::enableByteEvents() {
} }
try { try {
#ifdef FOLLY_HAVE_SO_TIMESTAMPING #if FOLLY_HAVE_SO_TIMESTAMPING
// make sure we have a connected IP socket that supports error queues // make sure we have a connected IP socket that supports error queues
// (Unix sockets do not support error queues) // (Unix sockets do not support error queues)
if (NetworkSocket() == fd_ || !good()) { if (NetworkSocket() == fd_ || !good()) {
......
...@@ -2984,7 +2984,7 @@ TEST(AsyncSSLSocketTest, SendMsgParamsCallback) { ...@@ -2984,7 +2984,7 @@ TEST(AsyncSSLSocketTest, SendMsgParamsCallback) {
cerr << "SendMsgParamsCallback test completed" << endl; cerr << "SendMsgParamsCallback test completed" << endl;
} }
#ifdef FOLLY_HAVE_SO_TIMESTAMPING #if FOLLY_HAVE_SO_TIMESTAMPING
class AsyncSSLSocketByteEventTest : public ::testing::Test { class AsyncSSLSocketByteEventTest : public ::testing::Test {
protected: protected:
......
...@@ -3282,7 +3282,7 @@ TEST_P(AsyncSocketErrMessageCallbackTest, ErrMessageCallback) { ...@@ -3282,7 +3282,7 @@ TEST_P(AsyncSocketErrMessageCallbackTest, ErrMessageCallback) {
#endif // FOLLY_HAVE_MSG_ERRQUEUE #endif // FOLLY_HAVE_MSG_ERRQUEUE
#ifdef FOLLY_HAVE_SO_TIMESTAMPING #if FOLLY_HAVE_SO_TIMESTAMPING
class AsyncSocketByteEventTest : public ::testing::Test { class AsyncSocketByteEventTest : public ::testing::Test {
protected: protected:
......
...@@ -116,7 +116,9 @@ struct mmsghdr { ...@@ -116,7 +116,9 @@ struct mmsghdr {
#ifdef MSG_ERRQUEUE #ifdef MSG_ERRQUEUE
#define FOLLY_HAVE_MSG_ERRQUEUE 1 #define FOLLY_HAVE_MSG_ERRQUEUE 1
#ifndef FOLLY_HAVE_SO_TIMESTAMPING
#define FOLLY_HAVE_SO_TIMESTAMPING 1 #define FOLLY_HAVE_SO_TIMESTAMPING 1
#endif
/* for struct sock_extended_err*/ /* for struct sock_extended_err*/
#include <linux/errqueue.h> #include <linux/errqueue.h>
#endif #endif
......
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