1 /* 2 * Public domain 3 * unistd.h compatibility shim 4 */ 5 module libressl_d.compat.unistd; 6 7 8 private static import core.sys.windows.winbase; 9 private static import libressl_d.compat.stdio; 10 private static import libressl_d.compat.sys.types; 11 public import core.sys.posix.unistd; 12 13 extern (C): 14 nothrow @nogc: 15 16 version (Posix) { 17 //#if defined(__MINGW32__) 18 //int ftruncate(int fd, libressl_d.compat.stdio.off_t length_); 19 //libressl_d.compat.sys.types.uid_t getuid(); 20 //libressl_d.compat.sys.types.ssize_t pread(int d, void* buf, size_t nbytes, libressl_d.compat.stdio.off_t offset); 21 //libressl_d.compat.sys.types.ssize_t pwrite(int d, const (void)* buf, size_t nbytes, libressl_d.compat.stdio.off_t offset); 22 //#endif 23 } else { 24 public import libressl_d.compat.stdlib; 25 //#include <io.h> 26 //#include <process.h> 27 28 enum STDOUT_FILENO = 1; 29 enum STDERR_FILENO = 2; 30 31 enum R_OK = 4; 32 enum W_OK = 2; 33 enum X_OK = 0; 34 enum F_OK = 0; 35 36 enum SEEK_SET = 0; 37 enum SEEK_CUR = 1; 38 enum SEEK_END = 2; 39 40 version (Windows) { 41 public import core.sys.windows.windows; 42 43 int _access(const char* path, const int access_mode); 44 45 alias access = ._access; 46 47 pragma(inline, true) 48 nothrow @nogc 49 uint sleep(uint seconds) 50 51 do 52 { 53 core.sys.windows.winbase.Sleep(seconds * 1000); 54 55 return seconds; 56 } 57 } else { 58 //alias access = ._access; 59 } 60 61 int ftruncate(int fd, libressl_d.compat.stdio.off_t length_); 62 libressl_d.compat.sys.types.uid_t getuid(); 63 libressl_d.compat.sys.types.ssize_t pread(int d, void* buf, size_t nbytes, libressl_d.compat.stdio.off_t offset); 64 libressl_d.compat.sys.types.ssize_t pwrite(int d, const (void)* buf, size_t nbytes, libressl_d.compat.stdio.off_t offset); 65 } 66 67 static if (!__traits(compiles, getentropy)) { 68 int getentropy(void* buf, size_t buflen); 69 } else { 70 /* 71 * Solaris 11.3 adds getentropy(2), but defines the function in sys/random.h 72 */ 73 //#if defined(__sun) 74 //public import core.sys.posix.sys.random; 75 //#endif 76 } 77 78 static if (!__traits(compiles, getpagesize)) { 79 int getpagesize(); 80 } 81 82 pragma(inline, true) 83 pure nothrow @safe @nogc @live 84 int pledge(REQUEST, PATHS)(REQUEST request, PATHS paths) 85 86 do 87 { 88 return 0; 89 } 90 91 pragma(inline, true) 92 pure nothrow @safe @nogc @live 93 int unveil(PATH, PERMISSIONS)(PATH path, PERMISSIONS permissions) 94 95 do 96 { 97 return 0; 98 } 99 100 //#if !defined(HAVE_PIPE2) 101 //int pipe2(int[2] fildes, int flags); 102 //#endif