From: Jim Meyering Date: Tue, 15 Oct 2013 17:23:46 +0000 (-0700) Subject: folly, tao: don't impose C constraints on folly's Portability.h X-Git-Tag: v0.22.0~817 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=796bfa8006d6a89889f07e663e763d7cb4a77578;p=folly.git folly, tao: don't impose C constraints on folly's Portability.h Summary: * folly/Portability.h: Move the definitions that Tao uses into a new file, and include that new file here. * folly/AddressSanitizer.h: New file. * tao/server/config.h: Include that small new file, rather than all of folly's Portability.h Test Plan: fbconfig -r tao/server && tao/server/tests/run_unit_tests.sh -d --save-log=log For folly, watch the arc-run tests. Reviewed By: pgriess@fb.com FB internal diff: D1011800 @override-unit-failures --- diff --git a/folly/CPortability.h b/folly/CPortability.h new file mode 100644 index 00000000..8089ae92 --- /dev/null +++ b/folly/CPortability.h @@ -0,0 +1,56 @@ +/* + * Copyright 2013 Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CPORTABILITY_H +#define CPORTABILITY_H + +/* These definitions are in a separate file so that they + * may be included from C- as well as C++-based projects. */ + +/* Define a convenience macro to test when address sanitizer is being used + * across the different compilers (e.g. clang, gcc) */ +#if defined(__clang__) +# if __has_feature(address_sanitizer) +# define FOLLY_SANITIZE_ADDRESS 1 +# endif +#elif defined (__GNUC__) && \ + (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || (__GNUC__ >= 5)) && \ + __SANITIZE_ADDRESS__ +# define FOLLY_SANITIZE_ADDRESS 1 +#endif + +/* Define attribute wrapper for function attribute used to disable + * address sanitizer instrumentation. Unfortunately, this attribute + * has issues when inlining is used, so disable that as well. */ +#ifdef FOLLY_SANITIZE_ADDRESS +# if defined(__clang__) +# if __has_attribute(__no_address_safety_analysis__) +# define FOLLY_DISABLE_ADDRESS_SANITIZER \ + __attribute__((__no_address_safety_analysis__, __noinline__)) +# elif __has_attribute(__no_sanitize_address__) +# define FOLLY_DISABLE_ADDRESS_SANITIZER \ + __attribute__((__no_sanitize_address__, __noinline__)) +# endif +# elif defined(__GNUC__) +# define FOLLY_DISABLE_ADDRESS_SANITIZER \ + __attribute__((__no_address_safety_analysis__, __noinline__)) +# endif +#endif +#ifndef FOLLY_DISABLE_ADDRESS_SANITIZER +# define FOLLY_DISABLE_ADDRESS_SANITIZER +#endif + +#endif diff --git a/folly/Portability.h b/folly/Portability.h index 6d5ab9c9..1bec1699 100644 --- a/folly/Portability.h +++ b/folly/Portability.h @@ -25,6 +25,7 @@ #include #endif +#include "CPortability.h" #if FOLLY_HAVE_SCHED_H #include @@ -84,40 +85,6 @@ struct MaxAlign { char c; } __attribute__((aligned)); # endif #endif - -/* Define a convenience macro to test when address sanitizer is being used - * across the different compilers (e.g. clang, gcc) */ -#if defined(__clang__) -# if __has_feature(address_sanitizer) -# define FOLLY_SANITIZE_ADDRESS 1 -# endif -#elif defined (__GNUC__) && \ - (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || (__GNUC__ >= 5)) && \ - __SANITIZE_ADDRESS__ -# define FOLLY_SANITIZE_ADDRESS 1 -#endif - -/* Define attribute wrapper for function attribute used to disable - * address sanitizer instrumentation. Unfortunately, this attribute - * has issues when inlining is used, so disable that as well. */ -#ifdef FOLLY_SANITIZE_ADDRESS -# if defined(__clang__) -# if __has_attribute(__no_address_safety_analysis__) -# define FOLLY_DISABLE_ADDRESS_SANITIZER \ - __attribute__((__no_address_safety_analysis__, __noinline__)) -# elif __has_attribute(__no_sanitize_address__) -# define FOLLY_DISABLE_ADDRESS_SANITIZER \ - __attribute__((__no_sanitize_address__, __noinline__)) -# endif -# elif defined(__GNUC__) -# define FOLLY_DISABLE_ADDRESS_SANITIZER \ - __attribute__((__no_address_safety_analysis__, __noinline__)) -# endif -#endif -#ifndef FOLLY_DISABLE_ADDRESS_SANITIZER -# define FOLLY_DISABLE_ADDRESS_SANITIZER -#endif - // It turns out that GNU libstdc++ and LLVM libc++ differ on how they implement // the 'std' namespace; the latter uses inline namepsaces. Wrap this decision // up in a macro to make forward-declarations easier.