Create the sys/types.h portability header
authorChristopher Dykes <cdykes@fb.com>
Fri, 4 Mar 2016 23:43:26 +0000 (15:43 -0800)
committerFacebook Github Bot 8 <facebook-github-bot-8-bot@fb.com>
Fri, 4 Mar 2016 23:50:25 +0000 (15:50 -0800)
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
folly/Portability.h
folly/portability/SysTypes.h [new file with mode: 0755]

index 3772e600b2c655352e44d7712b6190b68778a60c..a66816e3e55235481aefd52b09f79680fc5b1aad 100644 (file)
@@ -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 \
index 98caa82c0769e02bc08490353667ba3e4614c846..63dcc5cfb0bdd4a21c824c44be97c624c387f628 100644 (file)
@@ -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 <basetsd.h>
-typedef SSIZE_T ssize_t;
+#include <folly/portability/SysTypes.h>
 
 // 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 (executable)
index 0000000..34c9198
--- /dev/null
@@ -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 <sys/types.h>
+
+#ifdef _WIN32
+#include <basetsd.h>
+
+#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