From: Christopher Dykes Date: Sat, 5 Mar 2016 01:55:27 +0000 (-0800) Subject: Create the Windows portability header X-Git-Tag: deprecate-dynamic-initializer~2 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f3605199abacbda476c0f22e7fbe9cc28be0349c;p=folly.git Create the Windows portability header Summary: Because Windows' defines seem to get in the way more than they help. Reviewed By: yfeldblum Differential Revision: D2989507 fb-gh-sync-id: 148f390ef6adf977bffa2262aa76839b2bf4f507 shipit-source-id: 148f390ef6adf977bffa2262aa76839b2bf4f507 --- diff --git a/folly/Makefile.am b/folly/Makefile.am index a66816e3..70de07e0 100644 --- a/folly/Makefile.am +++ b/folly/Makefile.am @@ -276,6 +276,7 @@ nobase_follyinclude_HEADERS = \ portability/SysTypes.h \ portability/SysUio.h \ portability/Time.h \ + portability/Windows.h \ Preprocessor.h \ ProducerConsumerQueue.h \ Random.h \ diff --git a/folly/portability/Windows.h b/folly/portability/Windows.h new file mode 100755 index 00000000..3b488586 --- /dev/null +++ b/folly/portability/Windows.h @@ -0,0 +1,82 @@ +/* + * Copyright 2016 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. + */ + +#pragma once + +// Only do anything if we are on windows. +#ifdef _WIN32 +// This header is intended to be used in-place of including , +// , or . +// It includes all of them, and undefines certain names defined by them that +// are used in places in Folly. +// +// These have to be this way because we define our own versions +// of close(), because the normal Windows versions don't handle +// sockets at all. +#ifndef __STDC__ +/* nolint */ +#define __STDC__ 1 +#include // nolint +#include // nolint +#undef __STDC__ +#else +#include // nolint +#include // nolint +#endif + +#include +#include + +#ifdef CAL_GREGORIAN +#undef CAL_GREGORIAN +#endif + +// Defined in winnt.h +#ifdef DELETE +#undef DELETE +#endif + +// Defined in the GDI interface. +#ifdef ERROR +#undef ERROR +#endif + +// Defined in minwindef.h +#ifdef IN +#undef IN +#endif + +// Defined in winerror.h +#ifdef NO_ERROR +#undef NO_ERROR +#endif + +// Defined in minwindef.h +#ifdef OUT +#undef OUT +#endif + +// Defined in minwindef.h +#ifdef STRICT +#undef STRICT +#endif + +// Defined in Winbase.h +#ifdef Yield +#undef Yield +#endif + +#endif