1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Collabora Ltd, author <robin.burchell@collabora.co.uk>
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtCore module 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 
49 // 1) need to reset default environment if _BSD_SOURCE is defined
50 // 2) need to specify POSIX thread interfaces explicitly in glibc 2.0
51 // 3) it seems older glibc need this to include the X/Open stuff
52 
53 #include <unistd.h>
54 
55 // We are hot - unistd.h should have turned on the specific APIs we requested
56 
57 #include <features.h>
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/ipc.h>
69 #include <sys/time.h>
70 #include <sys/stat.h>
71 #include <sys/wait.h>
72 
73 #ifndef _GNU_SOURCE
74 #  define _GNU_SOURCE
75 #endif
76 
77 #define QT_STATBUF              struct stat
78 #define QT_STATBUF4TSTAT        struct stat
79 #define QT_STAT                 ::stat
80 #define QT_FSTAT                ::fstat
81 #define QT_LSTAT                ::lstat
82 #define QT_OPEN                 ::open
83 #define QT_TRUNCATE             ::truncate
84 #define QT_FTRUNCATE            ::ftruncate
85 #define QT_LSEEK                ::lseek
86 
87 #define QT_FOPEN                ::fopen
88 #define QT_FSEEK                ::fseek
89 #define QT_FTELL                ::ftell
90 #define QT_FGETPOS              ::fgetpos
91 #define QT_FSETPOS              ::fsetpos
92 #define QT_MMAP                 ::mmap
93 #define QT_FPOS_T               fpos_t
94 #define QT_OFF_T                long
95 
96 #define QT_STAT_REG             S_IFREG
97 #define QT_STAT_DIR             S_IFDIR
98 #define QT_STAT_MASK            S_IFMT
99 #define QT_STAT_LNK             S_IFLNK
100 #define QT_SOCKET_CONNECT       ::connect
101 #define QT_SOCKET_BIND          ::bind
102 #define QT_FILENO               fileno
103 #define QT_CLOSE                ::close
104 #define QT_READ                 ::read
105 #define QT_WRITE                ::write
106 #define QT_ACCESS               ::access
107 #define QT_GETCWD               ::getcwd
108 #define QT_CHDIR                ::chdir
109 #define QT_MKDIR                ::mkdir
110 #define QT_RMDIR                ::rmdir
111 #define QT_OPEN_LARGEFILE       O_LARGEFILE
112 #define QT_OPEN_RDONLY          O_RDONLY
113 #define QT_OPEN_WRONLY          O_WRONLY
114 #define QT_OPEN_RDWR            O_RDWR
115 #define QT_OPEN_CREAT           O_CREAT
116 #define QT_OPEN_TRUNC           O_TRUNC
117 #define QT_OPEN_APPEND          O_APPEND
118 #define QT_OPEN_EXCL            O_EXCL
119 
120 // Directory iteration
121 #define QT_DIR                  DIR
122 
123 
124 #define QT_OPENDIR              ::opendir
125 #define QT_CLOSEDIR             ::closedir
126 
127 #if defined(QT_LARGEFILE_SUPPORT) \
128         && defined(QT_USE_XOPEN_LFS_EXTENSIONS) \
129         && !defined(QT_NO_READDIR64)
130 #define QT_DIRENT               struct dirent64
131 #define QT_READDIR              ::readdir64
132 #define QT_READDIR_R            ::readdir64_r
133 #else
134 #define QT_DIRENT               struct dirent
135 #define QT_READDIR              ::readdir
136 #define QT_READDIR_R            ::readdir_r
137 #endif
138 
139 #define QT_SOCKET_CONNECT       ::connect
140 #define QT_SOCKET_BIND          ::bind
141 
142 
143 #define QT_SIGNAL_RETTYPE       void
144 #define QT_SIGNAL_ARGS          int
145 #define QT_SIGNAL_IGNORE        SIG_IGN
146 
147 #define QT_SOCKLEN_T            socklen_t
148 
149 #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
150 #define QT_SNPRINTF             ::snprintf
151 #define QT_VSNPRINTF            ::vsnprintf
152 #endif
153 
154 
155 #endif // QPLATFORMDEFS_H
156