| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the qmake spec of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | #ifndef QPLATFORMDEFS_H |
| 41 | #define QPLATFORMDEFS_H |
| 42 | |
| 43 | // Get Qt defines/settings |
| 44 | |
| 45 | #include "qglobal.h" |
| 46 | |
| 47 | // Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs |
| 48 | #ifndef _POSIX_PTHREAD_SEMANTICS |
| 49 | #define _POSIX_PTHREAD_SEMANTICS |
| 50 | #endif |
| 51 | |
| 52 | #include <unistd.h> |
| 53 | |
| 54 | |
| 55 | // We are hot - unistd.h should have turned on the specific APIs we requested |
| 56 | |
| 57 | |
| 58 | #include <pthread.h> |
| 59 | #include <dirent.h> |
| 60 | #include <fcntl.h> |
| 61 | #include <grp.h> |
| 62 | #include <pwd.h> |
| 63 | #include <signal.h> |
| 64 | #include <dlfcn.h> |
| 65 | |
| 66 | #include <sys/types.h> |
| 67 | #include <sys/ioctl.h> |
| 68 | #include <sys/filio.h> |
| 69 | #include <sys/ipc.h> |
| 70 | #include <sys/time.h> |
| 71 | #include <sys/shm.h> |
| 72 | #include <sys/socket.h> |
| 73 | #include <sys/stat.h> |
| 74 | #include <sys/wait.h> |
| 75 | #include <netinet/in.h> |
| 76 | |
| 77 | #define QT_USE_XOPEN_LFS_EXTENSIONS |
| 78 | #include "../common/posix/qplatformdefs.h" |
| 79 | |
| 80 | #undef QT_SOCKLEN_T |
| 81 | #undef QT_SOCKET_CONNECT |
| 82 | #undef QT_SOCKET_BIND |
| 83 | |
| 84 | #define QT_SOCKET_CONNECT qt_socket_connect |
| 85 | #define QT_SOCKET_BIND qt_socket_bind |
| 86 | |
| 87 | #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE-0 >= 500) && (_XOPEN_VERSION-0 >= 500) |
| 88 | // Solaris 7 and better with specific feature test macros |
| 89 | #define QT_SOCKLEN_T socklen_t |
| 90 | #elif defined(_XOPEN_SOURCE_EXTENDED) && defined(_XOPEN_UNIX) |
| 91 | // Solaris 2.6 and better with specific feature test macros |
| 92 | #define QT_SOCKLEN_T size_t |
| 93 | #else |
| 94 | // always this case in practice |
| 95 | #define QT_SOCKLEN_T int |
| 96 | #endif |
| 97 | |
| 98 | // Solaris redefines connect -> __xnet_connect with _XOPEN_SOURCE_EXTENDED |
| 99 | static inline int qt_socket_connect(int s, struct sockaddr *addr, QT_SOCKLEN_T addrlen) |
| 100 | { return ::connect(s, addr, addrlen); } |
| 101 | #if defined (connect) |
| 102 | # undef connect |
| 103 | #endif |
| 104 | |
| 105 | // Solaris redefines bind -> __xnet_bind with _XOPEN_SOURCE_EXTENDED |
| 106 | static inline int qt_socket_bind(int s, struct sockaddr *addr, QT_SOCKLEN_T addrlen) |
| 107 | { return ::bind(s, addr, addrlen); } |
| 108 | #if defined(bind) |
| 109 | # undef bind |
| 110 | #endif |
| 111 | |
| 112 | #if !defined(_XOPEN_UNIX) |
| 113 | // Solaris 2.5.1 |
| 114 | // Function usleep() is defined in C library but not declared in header files |
| 115 | // on Solaris 2.5.1. Not really a surprise, usleep() is specified by XPG4v2 |
| 116 | // and XPG4v2 is only supported by Solaris 2.6 and better. |
| 117 | // Function gethostname() is also defined in C library but not declared in |
| 118 | // header files on Solaris 2.5.1. |
| 119 | typedef unsigned int useconds_t; |
| 120 | extern "C" int usleep(useconds_t); |
| 121 | extern "C" int gethostname(char *, int); |
| 122 | #endif |
| 123 | |
| 124 | #if defined(_XOPEN_UNIX) |
| 125 | // Solaris 2.6 and better |
| 126 | #define QT_SNPRINTF ::snprintf |
| 127 | #define QT_VSNPRINTF ::vsnprintf |
| 128 | #endif |
| 129 | |
| 130 | #endif // QPLATFORMDEFS_H |