tdf#154546 skip dispatch when presenter controller is not set
[LibreOffice.git] / sal / osl / unx / system.hxx
blobf70887c8c42fac988a598a0c224684145bb5030c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <limits.h>
25 #include <string.h>
26 #include <errno.h>
27 #include <stdarg.h>
29 #include <unistd.h>
30 #include <fcntl.h>
31 #include <dirent.h>
32 #include <signal.h>
33 #include <utime.h>
35 #include <pwd.h>
37 #include <netdb.h>
39 #include <sys/stat.h>
40 #include <sys/wait.h>
42 #include <sys/types.h>
44 /* Make sockets of type AF_UNIX use underlying FS rights */
45 #if defined(__sun) && !defined(_XOPEN_SOURCE)
46 # define _XOPEN_SOURCE 500
47 # include <sys/socket.h>
48 # undef _XOPEN_SOURCE
49 #else
50 # include <sys/socket.h>
51 #endif
53 #include <netinet/in.h>
54 #include <arpa/inet.h>
56 #ifdef SYSV
57 # include <sys/utsname.h>
58 #endif
60 #ifdef LINUX
61 # ifndef __USE_GNU
62 # define __USE_GNU
63 # endif
65 # include <shadow.h>
66 # include <pthread.h>
67 # include <sys/file.h>
68 # include <sys/ioctl.h>
69 # include <sys/uio.h>
70 # include <sys/un.h>
71 # include <netinet/tcp.h>
72 # include <dlfcn.h>
73 # include <endian.h>
74 # include <sys/time.h>
75 # define IORESOURCE_TRANSFER_BSD
76 # define IOCHANNEL_TRANSFER_BSD_RENO
77 # define pthread_testcancel()
78 # define NO_PTHREAD_PRIORITY
79 # define PTHREAD_SIGACTION pthread_sigaction
81 # ifndef ETIME
82 # define ETIME ETIMEDOUT
83 # endif
85 #endif
87 #ifdef HAIKU
88 # include <shadow.h>
89 # include <pthread.h>
90 # include <sys/file.h>
91 # include <sys/ioctl.h>
92 # include <sys/uio.h>
93 # include <sys/un.h>
94 # include <netinet/tcp.h>
95 # include <dlfcn.h>
96 # include <endian.h>
97 # include <sys/time.h>
98 # define IORESOURCE_TRANSFER_BSD
99 # define IOCHANNEL_TRANSFER_BSD_RENO
100 # define pthread_testcancel()
101 # define NO_PTHREAD_PRIORITY
102 # define NO_PTHREAD_RTL
103 # define PTHREAD_SIGACTION pthread_sigaction
105 # ifndef ETIME
106 # define ETIME ETIMEDOUT
107 # endif
108 # define SIGIOT SIGABRT
109 # define SOCK_RDM 0
110 // hack: Haiku defines SOL_SOCKET as -1, but this makes GCC complain about
111 // narrowing conversion
112 # undef SOL_SOCKET
113 # define SOL_SOCKET (sal_uInt32) -1
115 #endif
117 #if defined(ANDROID)
118 # include <pthread.h>
119 # include <sys/file.h>
120 # include <sys/ioctl.h>
121 # include <sys/uio.h>
122 # include <sys/un.h>
123 # include <netinet/tcp.h>
124 # include <dlfcn.h>
125 # include <endian.h>
126 # include <sys/time.h>
127 # define IORESOURCE_TRANSFER_BSD
128 # define IOCHANNEL_TRANSFER_BSD_RENO
129 # define pthread_testcancel()
130 # define NO_PTHREAD_PRIORITY
131 #endif
133 #ifdef NETBSD
134 # define NO_PTHREAD_RTL
135 #endif
137 #ifdef FREEBSD
138 # ifndef ETIME
139 # define ETIME ETIMEDOUT
140 # endif
141 # include <pthread.h>
142 # include <sys/sem.h>
143 # include <dlfcn.h>
144 # include <sys/filio.h>
145 # include <sys/ioctl.h>
146 # include <sys/param.h>
147 # include <sys/time.h>
148 # include <sys/uio.h>
149 # include <sys/exec.h>
150 # include <vm/vm.h>
151 # include <vm/vm_param.h>
152 # include <vm/pmap.h>
153 # include <vm/swap_pager.h>
154 # include <sys/un.h>
155 # include <netinet/tcp.h>
156 # define IORESOURCE_TRANSFER_BSD
157 # include <machine/endian.h>
158 # define NO_PTHREAD_RTL
159 #endif
161 #ifdef OPENBSD
162 # define ETIME ETIMEDOUT
163 # include <pthread.h>
164 # include <sys/sem.h>
165 # include <dlfcn.h>
166 # include <sys/filio.h>
167 # include <sys/ioctl.h>
168 # include <sys/param.h>
169 # include <sys/time.h>
170 # include <sys/uio.h>
171 # include <sys/exec.h>
172 # include <sys/un.h>
173 # include <netinet/tcp.h>
174 # define IORESOURCE_TRANSFER_BSD
175 # include <machine/endian.h>
176 # define PTR_SIZE_T(s) ((size_t *)&(s))
177 # define IORESOURCE_TRANSFER_BSD
178 # define IOCHANNEL_TRANSFER_BSD_RENO
179 # define pthread_testcancel()
180 # define NO_PTHREAD_PRIORITY
181 # define NO_PTHREAD_RTL
182 # define PTHREAD_SIGACTION pthread_sigaction
183 #endif
185 #if defined(DRAGONFLY) || defined(NETBSD)
186 # define ETIME ETIMEDOUT
187 # include <pthread.h>
188 # include <sys/sem.h>
189 # include <dlfcn.h>
190 # include <sys/filio.h>
191 # include <sys/ioctl.h>
192 # include <sys/param.h>
193 # include <sys/time.h>
194 # include <sys/uio.h>
195 # include <sys/exec.h>
196 # include <sys/un.h>
197 # include <netinet/tcp.h>
198 # include <machine/endian.h>
199 # define IORESOURCE_TRANSFER_BSD
200 # define IOCHANNEL_TRANSFER_BSD_RENO
201 #endif
203 #ifdef __sun
204 # include <shadow.h>
205 # include <sys/un.h>
206 # include <stropts.h>
207 # include <pthread.h>
208 # include <netinet/tcp.h>
209 # include <sys/filio.h>
210 # include <dlfcn.h>
211 # include <sys/isa_defs.h>
212 # define IORESOURCE_TRANSFER_SYSV
213 # define IOCHANNEL_TRANSFER_BSD
214 # define LIBPATH "LD_LIBRARY_PATH"
215 #endif
217 #ifdef MACOSX
218 #define TimeValue CFTimeValue // Do not conflict with TimeValue in sal/inc/osl/time.h
219 #include <Carbon/Carbon.h>
220 #undef TimeValue
221 # ifndef ETIME
222 # define ETIME ETIMEDOUT
223 # endif
224 # include <dlfcn.h>
225 # include <pthread.h>
226 # include <sys/file.h>
227 # include <sys/ioctl.h>
228 # include <sys/uio.h>
229 # include <sys/un.h>
230 # include <netinet/tcp.h>
231 # include <machine/endian.h>
232 # include <sys/time.h>
233 # include <mach-o/dyld.h>
234 # define IOCHANNEL_TRANSFER_BSD_RENO
235 # define NO_PTHREAD_RTL
236 /* for NSGetArgc/Argv/Environ */
237 # include <crt_externs.h>
238 int macxp_resolveAlias(char *path, int buflen);
239 #endif
241 #ifdef IOS
242 # ifndef ETIME
243 # define ETIME ETIMEDOUT
244 # endif
245 # include <dlfcn.h>
246 # include <pthread.h>
247 # include <sys/file.h>
248 # include <sys/ioctl.h>
249 # include <sys/uio.h>
250 # include <sys/un.h>
251 # include <netinet/tcp.h>
252 # include <machine/endian.h>
253 # include <sys/time.h>
254 # define IOCHANNEL_TRANSFER_BSD_RENO
255 # define NO_PTHREAD_RTL
256 #endif
258 #ifdef EMSCRIPTEN
259 # ifndef ETIME
260 # define ETIME ETIMEDOUT
261 # endif
262 # include <pthread.h>
263 # include <sys/file.h>
264 # include <sys/ioctl.h>
265 # include <sys/uio.h>
266 # include <sys/un.h>
267 # include <netinet/tcp.h>
268 # include <dlfcn.h>
269 # include <endian.h>
270 # include <sys/time.h>
271 # define IORESOURCE_TRANSFER_BSD
272 # define IOCHANNEL_TRANSFER_BSD_RENO
273 # define pthread_testcancel()
274 # define NO_PTHREAD_PRIORITY
275 # define INIT_GROUPS(name, gid) false
276 #endif
278 #if !defined(_WIN32) && \
279 !defined(LINUX) && !defined(NETBSD) && !defined(FREEBSD) && \
280 !defined(__sun) && !defined(MACOSX) && \
281 !defined(OPENBSD) && !defined(DRAGONFLY) && \
282 !defined(IOS) && !defined(ANDROID) && \
283 !defined(HAIKU) && !defined(EMSCRIPTEN)
284 # error "Target platform not specified!"
285 #endif
287 #ifndef PTR_FD_SET
288 # define PTR_FD_SET(s) (&(s))
289 #endif
291 #ifndef NORMALIZE_TIMESPEC
292 # define NORMALIZE_TIMESPEC(timespec) \
293 timespec . tv_sec += timespec . tv_nsec / 1000000000; \
294 timespec . tv_nsec %= 1000000000;
295 #endif
297 #ifndef SET_TIMESPEC
298 # define SET_TIMESPEC(timespec, sec, nsec) \
299 timespec . tv_sec = (sec); \
300 timespec . tv_nsec = (nsec); \
301 NORMALIZE_TIMESPEC(timespec);
302 #endif
304 #ifndef SLEEP_TIMESPEC
305 # define SLEEP_TIMESPEC(timespec) nanosleep(&timespec, nullptr)
306 #endif
308 #ifndef INIT_GROUPS
309 # define INIT_GROUPS(name, gid) ((setgid((gid)) == 0) && (initgroups((name), (gid)) == 0))
310 #endif
312 #ifndef PTHREAD_NONE
313 # define PTHREAD_NONE _pthread_none_
314 # ifndef PTHREAD_NONE_INIT
315 # define PTHREAD_NONE_INIT ((pthread_t)-1)
316 # endif
317 #endif
319 #ifndef PTHREAD_ATTR_DEFAULT
320 # define PTHREAD_ATTR_DEFAULT nullptr
321 #endif
322 #ifndef PTHREAD_MUTEXATTR_DEFAULT
323 # define PTHREAD_MUTEXATTR_DEFAULT nullptr
324 #endif
325 #ifndef PTHREAD_CONDATTR_DEFAULT
326 # define PTHREAD_CONDATTR_DEFAULT nullptr
327 #endif
329 #ifndef PTHREAD_SIGACTION
330 # define PTHREAD_SIGACTION sigaction
331 #endif
333 #ifndef STAT_PARENT
334 # define STAT_PARENT lstat
335 #endif
337 /* socket options which might not be defined on all unx flavors */
338 #ifndef SO_ACCEPTCONN
339 # define SO_ACCEPTCONN 0
340 #endif
341 #ifndef SO_SNDLOWAT
342 # define SO_SNDLOWAT 0
343 #endif
344 #ifndef SO_RCVLOWAT
345 # define SO_RCVLOWAT 0
346 #endif
347 #ifndef SO_SNDTIMEO
348 # define SO_SNDTIMEO 0
349 #endif
350 #ifndef SO_RCVTIMEO
351 # define SO_RCVTIMEO 0
352 #endif
353 #ifndef SO_USELOOPBACK
354 # define SO_USELOOPBACK 0
355 #endif
356 #ifndef MSG_MAXIOVLEN
357 # define MSG_MAXIOVLEN 0
358 #endif
360 /* BEGIN HACK */
361 /* dummy define and declarations for IPX should be replaced by */
362 /* original ipx headers when these are available for this platform */
364 #ifndef SA_FAMILY_DECL
365 # define SA_FAMILY_DECL short sa_family
366 #endif
368 #define NSPROTO_IPX 1000
369 #define NSPROTO_SPX 1256
370 #define NSPROTO_SPXII 1257
372 /* END HACK */
374 #ifdef NO_PTHREAD_RTL
375 #if !defined FREEBSD
376 #if !defined NETBSD
377 struct passwd *getpwent_r(struct passwd *pwd, char *buffer, int buflen);
378 #endif
379 extern struct spwd *getspnam_r(const char *name, struct spwd *result,
380 char *buffer, int buflen);
382 #if !defined MACOSX
383 struct tm *localtime_r(const time_t *timep, struct tm *buffer);
384 struct tm *gmtime_r(const time_t *timep, struct tm *buffer);
385 #endif
386 #endif /* !defined(FREEBSD) */
387 #endif
389 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */