VirtualBox

source: vbox/trunk/src/libs/openssl-1.1.0g/e_os.h@ 69881

Last change on this file since 69881 was 69881, checked in by vboxsync, 7 years ago

Update OpenSSL to 1.1.0g.
bugref:8070: src/libs maintenance

  • Property svn:eol-style set to native
File size: 15.2 KB
Line 
1/*
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10#ifndef HEADER_E_OS_H
11# define HEADER_E_OS_H
12
13# include <openssl/opensslconf.h>
14
15# include <openssl/e_os2.h>
16/*
17 * <openssl/e_os2.h> contains what we can justify to make visible to the
18 * outside; this file e_os.h is not part of the exported interface.
19 */
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/* Used to checking reference counts, most while doing perl5 stuff :-) */
26# if defined(OPENSSL_NO_STDIO)
27# if defined(REF_PRINT)
28# error "REF_PRINT requires stdio"
29# endif
30# endif
31
32/*
33 * BIO_printf format modifier for [u]int64_t.
34 */
35# if defined(__LP64__) || (defined(__SIZEOF_LONG__) && __SIZEOF_LONG__==8)
36# define BIO_PRI64 "l" /* 'll' does work "universally", but 'l' is
37 * here to shut -Wformat warnings in LP64... */
38# else
39# define BIO_PRI64 "ll"
40# endif
41
42# if !defined(NDEBUG) && !defined(OPENSSL_NO_STDIO)
43# define REF_ASSERT_ISNT(test) \
44 (void)((test) ? (OPENSSL_die("refcount error", __FILE__, __LINE__), 1) : 0)
45# else
46# define REF_ASSERT_ISNT(i)
47# endif
48# ifdef REF_PRINT
49# define REF_PRINT_COUNT(a, b) \
50 fprintf(stderr, "%p:%4d:%s\n", b, b->references, a)
51# else
52# define REF_PRINT_COUNT(a, b)
53# endif
54
55# define osslargused(x) (void)x
56# define OPENSSL_CONF "openssl.cnf"
57
58# ifndef DEVRANDOM
59/*
60 * set this to a comma-separated list of 'random' device files to try out. My
61 * default, we will try to read at least one of these files
62 */
63# define DEVRANDOM "/dev/urandom","/dev/random","/dev/srandom"
64# endif
65# if !defined(OPENSSL_NO_EGD) && !defined(DEVRANDOM_EGD)
66/*
67 * set this to a comma-separated list of 'egd' sockets to try out. These
68 * sockets will be tried in the order listed in case accessing the device
69 * files listed in DEVRANDOM did not return enough entropy.
70 */
71# define DEVRANDOM_EGD "/var/run/egd-pool","/dev/egd-pool","/etc/egd-pool","/etc/entropy"
72# endif
73
74# if defined(OPENSSL_SYS_VXWORKS)
75# define NO_SYS_PARAM_H
76# define NO_CHMOD
77# define NO_SYSLOG
78# endif
79
80/********************************************************************
81 The Microsoft section
82 ********************************************************************/
83# if defined(OPENSSL_SYS_WIN32) && !defined(WIN32)
84# define WIN32
85# endif
86# if defined(OPENSSL_SYS_WINDOWS) && !defined(WINDOWS)
87# define WINDOWS
88# endif
89# if defined(OPENSSL_SYS_MSDOS) && !defined(MSDOS)
90# define MSDOS
91# endif
92
93# if (defined(MSDOS) || defined(OPENSSL_SYS_UEFI)) && !defined(GETPID_IS_MEANINGLESS)
94# define GETPID_IS_MEANINGLESS
95# endif
96
97# ifdef WIN32
98# define NO_SYS_UN_H
99# define get_last_sys_error() GetLastError()
100# define clear_sys_error() SetLastError(0)
101# if !defined(WINNT)
102# define WIN_CONSOLE_BUG
103# endif
104# else
105# define get_last_sys_error() errno
106# define clear_sys_error() errno=0
107# endif
108
109# if defined(WINDOWS)
110# define get_last_socket_error() WSAGetLastError()
111# define clear_socket_error() WSASetLastError(0)
112# define readsocket(s,b,n) recv((s),(b),(n),0)
113# define writesocket(s,b,n) send((s),(b),(n),0)
114# elif defined(__DJGPP__)
115# define WATT32
116# define WATT32_NO_OLDIES
117# define get_last_socket_error() errno
118# define clear_socket_error() errno=0
119# define closesocket(s) close_s(s)
120# define readsocket(s,b,n) read_s(s,b,n)
121# define writesocket(s,b,n) send(s,b,n,0)
122# elif defined(OPENSSL_SYS_VMS)
123# define get_last_socket_error() errno
124# define clear_socket_error() errno=0
125# define ioctlsocket(a,b,c) ioctl(a,b,c)
126# define closesocket(s) close(s)
127# define readsocket(s,b,n) recv((s),(b),(n),0)
128# define writesocket(s,b,n) send((s),(b),(n),0)
129# elif defined(OPENSSL_SYS_VXWORKS)
130# define get_last_socket_error() errno
131# define clear_socket_error() errno=0
132# define ioctlsocket(a,b,c) ioctl((a),(b),(int)(c))
133# define closesocket(s) close(s)
134# define readsocket(s,b,n) read((s),(b),(n))
135# define writesocket(s,b,n) write((s),(char *)(b),(n))
136# else
137# define get_last_socket_error() errno
138# define clear_socket_error() errno=0
139# define ioctlsocket(a,b,c) ioctl(a,b,c)
140# define closesocket(s) close(s)
141# define readsocket(s,b,n) read((s),(b),(n))
142# define writesocket(s,b,n) write((s),(b),(n))
143# endif
144
145# if (defined(WINDOWS) || defined(MSDOS))
146
147# ifdef __DJGPP__
148# include <unistd.h>
149# include <sys/stat.h>
150# include <sys/socket.h>
151# include <sys/un.h>
152# include <tcp.h>
153# include <netdb.h>
154# define _setmode setmode
155# define _O_TEXT O_TEXT
156# define _O_BINARY O_BINARY
157# define HAS_LFN_SUPPORT(name) (pathconf((name), _PC_NAME_MAX) > 12)
158# undef DEVRANDOM_EGD /* Neither MS-DOS nor FreeDOS provide 'egd' sockets. */
159# undef DEVRANDOM
160# define DEVRANDOM "/dev/urandom\x24"
161# endif /* __DJGPP__ */
162
163# ifndef S_IFDIR
164# define S_IFDIR _S_IFDIR
165# endif
166
167# ifndef S_IFMT
168# define S_IFMT _S_IFMT
169# endif
170
171# if !defined(WINNT) && !defined(__DJGPP__)
172# define NO_SYSLOG
173# endif
174
175# ifdef WINDOWS
176# if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT)
177 /*
178 * Defining _WIN32_WINNT here in e_os.h implies certain "discipline."
179 * Most notably we ought to check for availability of each specific
180 * routine that was introduced after denoted _WIN32_WINNT with
181 * GetProcAddress(). Normally newer functions are masked with higher
182 * _WIN32_WINNT in SDK headers. So that if you wish to use them in
183 * some module, you'd need to override _WIN32_WINNT definition in
184 * the target module in order to "reach for" prototypes, but replace
185 * calls to new functions with indirect calls. Alternatively it
186 * might be possible to achieve the goal by /DELAYLOAD-ing .DLLs
187 * and check for current OS version instead.
188 */
189# define _WIN32_WINNT 0x0501
190# endif
191# ifndef IN_RING0 /* bird */
192# if defined(_WIN32_WINNT) || defined(_WIN32_WCE)
193 /*
194 * Just like defining _WIN32_WINNT including winsock2.h implies
195 * certain "discipline" for maintaining [broad] binary compatibility.
196 * As long as structures are invariant among Winsock versions,
197 * it's sufficient to check for specific Winsock2 API availability
198 * at run-time [DSO_global_lookup is recommended]...
199 */
200# include <winsock2.h>
201# include <ws2tcpip.h>
202 /* yes, they have to be #included prior to <windows.h> */
203# endif
204# include <windows.h>
205# endif /* bird */
206# include <stdio.h>
207# include <stddef.h>
208# include <errno.h>
209# if defined(_WIN32_WCE) && !defined(EACCES)
210# define EACCES 13
211# endif
212# include <string.h>
213# ifdef _WIN64
214# define strlen(s) _strlen31(s)
215/* cut strings to 2GB */
216# ifndef VBOX
217static __inline unsigned int _strlen31(const char *str)
218# else
219static __inline size_t _strlen31(const char *str)
220# endif
221{
222 unsigned int len = 0;
223 while (*str && len < 0x80000000U)
224 str++, len++;
225 return len & 0x7FFFFFFF;
226}
227# endif
228# include <malloc.h>
229# if defined(_MSC_VER) && _MSC_VER<=1200 && defined(_MT) && defined(isspace)
230 /* compensate for bug in VC6 ctype.h */
231# undef isspace
232# undef isdigit
233# undef isalnum
234# undef isupper
235# undef isxdigit
236# endif
237# if defined(_MSC_VER) && !defined(_WIN32_WCE) && !defined(_DLL) && defined(stdin)
238# if _MSC_VER>=1300 && _MSC_VER<1600
239# undef stdin
240# undef stdout
241# undef stderr
242FILE * __cdecl __iob_func(); /* vbox/bird: added __cdecl */
243# define stdin (&__iob_func()[0])
244# define stdout (&__iob_func()[1])
245# define stderr (&__iob_func()[2])
246# elif _MSC_VER<1300 && defined(I_CAN_LIVE_WITH_LNK4049)
247# undef stdin
248# undef stdout
249# undef stderr
250 /*
251 * pre-1300 has __p__iob(), but it's available only in msvcrt.lib,
252 * or in other words with /MD. Declaring implicit import, i.e. with
253 * _imp_ prefix, works correctly with all compiler options, but
254 * without /MD results in LINK warning LNK4049: 'locally defined
255 * symbol "__iob" imported'.
256 */
257extern FILE *_imp___iob;
258# define stdin (&_imp___iob[0])
259# define stdout (&_imp___iob[1])
260# define stderr (&_imp___iob[2])
261# endif
262# endif
263# endif
264# include <io.h>
265# include <fcntl.h>
266
267# ifdef OPENSSL_SYS_WINCE
268# define OPENSSL_NO_POSIX_IO
269# endif
270
271# define EXIT(n) exit(n)
272# define LIST_SEPARATOR_CHAR ';'
273# ifndef X_OK
274# define X_OK 0
275# endif
276# ifndef W_OK
277# define W_OK 2
278# endif
279# ifndef R_OK
280# define R_OK 4
281# endif
282# ifdef OPENSSL_SYS_WINCE
283# define DEFAULT_HOME ""
284# else
285# define DEFAULT_HOME "C:"
286# endif
287
288/* Avoid Visual Studio 13 GetVersion deprecated problems */
289# if defined(_MSC_VER) && _MSC_VER>=1800
290# define check_winnt() (1)
291# define check_win_minplat(x) (1)
292# else
293# define check_winnt() (GetVersion() < 0x80000000)
294# define check_win_minplat(x) (LOBYTE(LOWORD(GetVersion())) >= (x))
295# endif
296
297# else /* The non-microsoft world */
298
299# ifdef OPENSSL_SYS_VMS
300# define VMS 1
301 /*
302 * some programs don't include stdlib, so exit() and others give implicit
303 * function warnings
304 */
305# include <stdlib.h>
306# if defined(__DECC)
307# include <unistd.h>
308# else
309# include <unixlib.h>
310# endif
311# define LIST_SEPARATOR_CHAR ','
312 /* We don't have any well-defined random devices on VMS, yet... */
313# undef DEVRANDOM
314 /*-
315 We need to do this since VMS has the following coding on status codes:
316
317 Bits 0-2: status type: 0 = warning, 1 = success, 2 = error, 3 = info ...
318 The important thing to know is that odd numbers are considered
319 good, while even ones are considered errors.
320 Bits 3-15: actual status number
321 Bits 16-27: facility number. 0 is considered "unknown"
322 Bits 28-31: control bits. If bit 28 is set, the shell won't try to
323 output the message (which, for random codes, just looks ugly)
324
325 So, what we do here is to change 0 to 1 to get the default success status,
326 and everything else is shifted up to fit into the status number field, and
327 the status is tagged as an error, which is what is wanted here.
328
329 Finally, we add the VMS C facility code 0x35a000, because there are some
330 programs, such as Perl, that will reinterpret the code back to something
331 POSIXly. 'man perlvms' explains it further.
332
333 NOTE: the perlvms manual wants to turn all codes 2 to 255 into success
334 codes (status type = 1). I couldn't disagree more. Fortunately, the
335 status type doesn't seem to bother Perl.
336 -- Richard Levitte
337 */
338# define EXIT(n) exit((n) ? (((n) << 3) | 2 | 0x10000000 | 0x35a000) : 1)
339
340# define NO_SYS_PARAM_H
341# define NO_SYS_UN_H
342
343# define DEFAULT_HOME "SYS$LOGIN:"
344
345# else
346 /* !defined VMS */
347# ifdef OPENSSL_UNISTD
348# include OPENSSL_UNISTD
349# else
350# include <unistd.h>
351# endif
352# include <sys/types.h>
353# ifdef OPENSSL_SYS_WIN32_CYGWIN
354# include <io.h>
355# include <fcntl.h>
356# endif
357
358# define LIST_SEPARATOR_CHAR ':'
359# define EXIT(n) exit(n)
360# endif
361
362# endif
363
364/*************/
365
366# ifdef USE_SOCKETS
367# ifdef OPENSSL_NO_SOCK
368# elif defined(WINDOWS) || defined(MSDOS)
369 /* windows world */
370# if !defined(__DJGPP__)
371# if defined(_WIN32_WCE) && _WIN32_WCE<410
372# define getservbyname _masked_declaration_getservbyname
373# endif
374# if !defined(IPPROTO_IP)
375 /* winsock[2].h was included already? */
376# include <winsock.h>
377# endif
378# ifdef getservbyname
379# undef getservbyname
380 /* this is used to be wcecompat/include/winsock_extras.h */
381struct servent *PASCAL getservbyname(const char *, const char *);
382# endif
383
384# ifdef _WIN64
385/*
386 * Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because
387 * the value constitutes an index in per-process table of limited size
388 * and not a real pointer. And we also depend on fact that all processors
389 * Windows run on happen to be two's-complement, which allows to
390 * interchange INVALID_SOCKET and -1.
391 */
392# define socket(d,t,p) ((int)socket(d,t,p))
393# define accept(s,f,l) ((int)accept(s,f,l))
394# endif
395# else
396# endif
397
398# else
399
400# ifndef NO_SYS_PARAM_H
401# include <sys/param.h>
402# endif
403# ifdef OPENSSL_SYS_VXWORKS
404# include <time.h>
405# endif
406
407# include <netdb.h>
408# if defined(OPENSSL_SYS_VMS_NODECC)
409# include <socket.h>
410# include <in.h>
411# include <inet.h>
412# else
413# include <sys/socket.h>
414# ifndef NO_SYS_UN_H
415# ifdef OPENSSL_SYS_VXWORKS
416# include <streams/un.h>
417# else
418# include <sys/un.h>
419# endif
420# ifndef UNIX_PATH_MAX
421# define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)NULL)->sun_path)
422# endif
423# endif
424# ifdef FILIO_H
425# include <sys/filio.h> /* FIONBIO in some SVR4, e.g. unixware, solaris */
426# endif
427# include <netinet/in.h>
428# include <arpa/inet.h>
429# include <netinet/tcp.h>
430# endif
431
432# ifdef OPENSSL_SYS_AIX
433# include <sys/select.h>
434# endif
435
436# ifdef __QNX__
437# include <sys/select.h>
438# endif
439
440# ifndef VMS
441# include <sys/ioctl.h>
442# else
443 /* ioctl is only in VMS > 7.0 and when socketshr is not used */
444# if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000)
445# include <sys/ioctl.h>
446# endif
447# endif
448
449# ifdef VMS
450# include <unixio.h>
451# if defined(TCPIP_TYPE_SOCKETSHR)
452# include <socketshr.h>
453# endif
454# endif
455
456# ifndef INVALID_SOCKET
457# define INVALID_SOCKET (-1)
458# endif /* INVALID_SOCKET */
459# endif
460
461/*
462 * Some IPv6 implementations are broken, disable them in known bad versions.
463 */
464# if !defined(OPENSSL_USE_IPV6)
465# if defined(AF_INET6) && !defined(NETWARE_CLIB)
466# define OPENSSL_USE_IPV6 1
467# else
468# define OPENSSL_USE_IPV6 0
469# endif
470# endif
471
472# endif
473
474# ifndef OPENSSL_EXIT
475# if defined(MONOLITH) && !defined(OPENSSL_C)
476# define OPENSSL_EXIT(n) return(n)
477# else
478# define OPENSSL_EXIT(n) do { EXIT(n); return(n); } while(0)
479# endif
480# endif
481
482/***********************************************/
483
484# if defined(OPENSSL_SYS_WINDOWS)
485# define strcasecmp _stricmp
486# define strncasecmp _strnicmp
487# if (_MSC_VER >= 1310)
488# define open _open
489# define fdopen _fdopen
490# define close _close
491# ifndef strdup
492# define strdup _strdup
493# endif
494# define unlink _unlink
495# endif
496# else
497# include <strings.h>
498# endif
499
500/* vxworks */
501# if defined(OPENSSL_SYS_VXWORKS)
502# include <ioLib.h>
503# include <tickLib.h>
504# include <sysLib.h>
505
506# define TTY_STRUCT int
507
508# define sleep(a) taskDelay((a) * sysClkRateGet())
509
510# include <vxWorks.h>
511# include <sockLib.h>
512# include <taskLib.h>
513
514# define getpid taskIdSelf
515
516/*
517 * NOTE: these are implemented by helpers in database app! if the database is
518 * not linked, we need to implement them elswhere
519 */
520struct hostent *gethostbyname(const char *name);
521struct hostent *gethostbyaddr(const char *addr, int length, int type);
522struct servent *getservbyname(const char *name, const char *proto);
523
524# endif
525/* end vxworks */
526
527#define OSSL_NELEM(x) (sizeof(x)/sizeof((x)[0]))
528
529#ifdef __cplusplus
530}
531#endif
532
533#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette