LLDB  mainline
windows/PosixApi.h
Go to the documentation of this file.
1 //===-- windows/PosixApi.h --------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef liblldb_Host_windows_PosixApi_h
10 #define liblldb_Host_windows_PosixApi_h
11 
12 #include "llvm/Support/Compiler.h"
13 #if !defined(_WIN32)
14 #error "windows/PosixApi.h being #included on non Windows system!"
15 #endif
16 
17 // va_start, va_end, etc macros.
18 #include <stdarg.h>
19 
20 // time_t, timespec, etc.
21 #include <time.h>
22 
23 #ifndef PATH_MAX
24 #define PATH_MAX 32768
25 #endif
26 
27 #define O_NOCTTY 0
28 #define O_NONBLOCK 0
29 #define SIGTRAP 5
30 #define SIGKILL 9
31 #define SIGSTOP 20
32 
33 #if defined(_MSC_VER)
34 #define S_IRUSR S_IREAD /* read, user */
35 #define S_IWUSR S_IWRITE /* write, user */
36 #define S_IXUSR 0 /* execute, user */
37 #endif
38 #define S_IRGRP 0 /* read, group */
39 #define S_IWGRP 0 /* write, group */
40 #define S_IXGRP 0 /* execute, group */
41 #define S_IROTH 0 /* read, others */
42 #define S_IWOTH 0 /* write, others */
43 #define S_IXOTH 0 /* execute, others */
44 #define S_IRWXU 0
45 #define S_IRWXG 0
46 #define S_IRWXO 0
47 
48 #ifdef _MSC_VER
49 
50 // PRIxxx format macros for printf()
51 #include <inttypes.h>
52 
53 // open(), close(), creat(), etc.
54 #include <io.h>
55 
56 typedef unsigned short mode_t;
57 
58 // pyconfig.h typedefs this. We require python headers to be included before
59 // any LLDB headers, but there's no way to prevent python's pid_t definition
60 // from leaking, so this is the best option.
61 #ifndef NO_PID_T
62 typedef uint32_t pid_t;
63 #endif
64 
65 #define STDIN_FILENO 0
66 #define STDOUT_FILENO 1
67 #define STDERR_FILENO 2
68 
69 #define S_IFDIR _S_IFDIR
70 
71 #ifndef S_ISDIR
72 #define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
73 #endif
74 
75 #endif // _MSC_VER
76 
77 // Various useful posix functions that are not present in Windows. We provide
78 // custom implementations.
79 int vasprintf(char **ret, const char *fmt, va_list ap);
80 char *strcasestr(const char *s, const char *find);
81 char *realpath(const char *name, char *resolved);
82 
83 int usleep(uint32_t useconds);
84 char *basename(char *path);
85 char *dirname(char *path);
86 
87 int strcasecmp(const char *s1, const char *s2);
88 int strncasecmp(const char *s1, const char *s2, size_t n);
89 
90 // empty functions
91 inline int posix_openpt(int flag) { LLVM_BUILTIN_UNREACHABLE; }
92 
93 inline int strerror_r(int errnum, char *buf, size_t buflen) {
94  LLVM_BUILTIN_UNREACHABLE;
95 }
96 
97 inline int unlockpt(int fd) { LLVM_BUILTIN_UNREACHABLE; }
98 inline int grantpt(int fd) { LLVM_BUILTIN_UNREACHABLE; }
99 inline char *ptsname(int fd) { LLVM_BUILTIN_UNREACHABLE; }
100 
101 inline pid_t fork(void) { LLVM_BUILTIN_UNREACHABLE; }
102 inline pid_t setsid(void) { LLVM_BUILTIN_UNREACHABLE; }
103 
104 #endif
pid_t setsid(void)
int posix_openpt(int flag)
int grantpt(int fd)
int unlockpt(int fd)
char * realpath(const char *name, char *resolved)
Definition: Windows.cpp:90
int usleep(uint32_t useconds)
int strerror_r(int errnum, char *buf, size_t buflen)
char * dirname(char *path)
pid_t fork(void)
int strncasecmp(const char *s1, const char *s2, size_t n)
char * strcasestr(const char *s, const char *find)
Definition: Windows.cpp:72
char * ptsname(int fd)
char * basename(char *path)
uint64_t pid_t
Definition: lldb-types.h:85
int strcasecmp(const char *s1, const char *s2)
int vasprintf(char **ret, const char *fmt, va_list ap)
Definition: Windows.cpp:45