Warning, file /sdk/dferry/transport/platform.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 Copyright (C) 2013 Andreas Hartmetz <ahartmetz@gmail.com> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LGPL. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 Boston, MA 02110-1301, USA. 0018 0019 Alternatively, this file is available under the Mozilla Public License 0020 Version 1.1. You may obtain a copy of the License at 0021 http://www.mozilla.org/MPL/ 0022 */ 0023 0024 #ifndef PLATFORM_H 0025 #define PLATFORM_H 0026 0027 // Note about invalid descriptors: On Unix they are -1 signed, on Windows they are 0028 // ~0 unsigned. Same bit pattern, not directly interchangeable in use. 0029 0030 #ifdef __unix__ 0031 typedef int FileDescriptor; 0032 #endif 0033 0034 #ifdef _WIN32 0035 // this is ugly, but including all of winsock2.h in lots of headers is also ugly... 0036 #ifdef _WIN64 0037 typedef unsigned long long int FileDescriptor; 0038 #else 0039 typedef unsigned int FileDescriptor; 0040 #endif 0041 #endif 0042 0043 enum InvalidFileDescriptorEnum : FileDescriptor { 0044 #ifdef _WIN32 0045 InvalidFileDescriptor = ~ FileDescriptor(0) 0046 #else 0047 InvalidFileDescriptor = -1 0048 #endif 0049 }; 0050 0051 static inline bool isValidFileDescriptor(FileDescriptor fd) 0052 { 0053 #ifdef _WIN32 0054 return fd != InvalidFileDescriptor; 0055 #else 0056 return fd >= 0; 0057 #endif 0058 } 0059 0060 #endif // PLATFORM_H