From 30ec44d3646f1eb6b6a4ef02d7589c53a84ee8fe Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Fri, 4 Mar 2016 15:43:26 -0800 Subject: [PATCH] Create the sys/types.h portability header Summary: Windows has it, but it doesn't define pid_t. It also doesn't define ssize_t, and it's not worth a separate header for a single typedef, so define it here as well. Reviewed By: yfeldblum Differential Revision: D3001168 fb-gh-sync-id: 3722270181c200bbcf39043960f81609c854b132 shipit-source-id: 3722270181c200bbcf39043960f81609c854b132 --- folly/Makefile.am | 1 + folly/Portability.h | 6 +----- folly/portability/SysTypes.h | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 5 deletions(-) create mode 100755 folly/portability/SysTypes.h diff --git a/folly/Makefile.am b/folly/Makefile.am index 3772e600..a66816e3 100644 --- a/folly/Makefile.am +++ b/folly/Makefile.am @@ -273,6 +273,7 @@ nobase_follyinclude_HEADERS = \ portability/Strings.h \ portability/Syscall.h \ portability/SysTime.h \ + portability/SysTypes.h \ portability/SysUio.h \ portability/Time.h \ Preprocessor.h \ diff --git a/folly/Portability.h b/folly/Portability.h index 98caa82c..63dcc5cf 100644 --- a/folly/Portability.h +++ b/folly/Portability.h @@ -307,11 +307,7 @@ namespace std { typedef ::max_align_t max_align_t; } // MSVC specific defines // mainly for posix compat #ifdef _MSC_VER - -// this definition is in a really silly place with a silly name -// and ifdefing it every time we want it is painful -#include -typedef SSIZE_T ssize_t; +#include // sprintf semantics are not exactly identical // but current usage is not a problem diff --git a/folly/portability/SysTypes.h b/folly/portability/SysTypes.h new file mode 100755 index 00000000..34c9198b --- /dev/null +++ b/folly/portability/SysTypes.h @@ -0,0 +1,36 @@ +/* + * 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 + +#include + +#ifdef _WIN32 +#include + +#define HAVE_MODE_T 1 + +// This is actually defined in our pthread implementation on +// Windows, but we don't want to include all of that just for this. +using pid_t = void*; +// This isn't actually supposed to be defined here, but it's the most +// appropriate place without defining a portability header for stdint.h +// with just this single typedef. +using ssize_t = SSIZE_T; +// The Windows headers don't define this anywhere, nor do any of the libs +// that Folly depends on, so define it here. +using mode_t = unsigned short; +#endif -- 2.34.1