1 // Copyright (c) 1999-2018 David Muse
2 // See the COPYING file for more information.
3 
4 #include <rudiments/private/dll.h>
5 #include <rudiments/filedescriptor.h>
6 
7 #include <sys/types.h>
8 
9 // some systems need this for key_t
10 #ifdef RUDIMENTS_HAVE_SYS_IPC_H
11 	#ifndef RUDIMENTS_SYS_IPC_H
12 	#define RUDIMENTS_SYS_IPC_H
13 		#include <sys/ipc.h>
14 	#endif
15 #endif
16 
17 // for open flags
18 #ifdef RUDIMENTS_HAVE_FCNTL_H
19 	// for open flags with msvc/mingw32...
20 	// make sure to undefine _POSIX_ if it wasn't already defined though,
21 	// as it will prevent various process-related functions from being
22 	// found later if it's still defined
23 	#ifdef _WIN32
24 		#ifndef _POSIX_
25 			#define _POSIX_
26 			#define RUDIMENTS_UNDEFPOSIX
27 		#endif
28 	#endif
29 	#include <fcntl.h>
30 	#ifdef _WIN32
31 		#ifdef RUDIMENTS_UNDEFPOSIX
32 			#undef _POSIX_
33 		#endif
34 	#endif
35 #endif
36 
37 #ifndef RUDIMENTS_HAVE_BLKSIZE_T
38 	typedef long blksize_t;
39 #endif
40 #ifndef RUDIMENTS_HAVE_BLKCNT_T
41 	typedef long blkcnt_t;
42 #endif
43 
44 // windows doesn't define these but we need them to be able to lock files
45 #ifndef F_RDLCK
46 	#define F_RDLCK	0
47 #endif
48 #ifndef F_WRLCK
49 	#define F_WRLCK	1
50 #endif
51 #ifndef F_UNLCK
52 	#define F_UNLCK	2
53 #endif
54 
55 // most platforms don't define O_BINARY but it's
56 // helpful to have it for portability
57 #ifndef O_BINARY
58 	#define O_BINARY 0
59 #endif
60 
61 class fileprivate;
62