xref: /freebsd/contrib/llvm-project/lldb/tools/driver/Platform.h (revision dd41de95a84d979615a2ef11df6850622bf6184e)
1 //===-- Platform.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 LLDB_TOOLS_DRIVER_PLATFORM_H
10 #define LLDB_TOOLS_DRIVER_PLATFORM_H
11 
12 #include "lldb/Host/Config.h"
13 
14 #if defined(_WIN32)
15 
16 #include <io.h>
17 #if defined(_MSC_VER)
18 #include <signal.h>
19 #endif
20 #if HAVE_SYS_TYPES_H
21 #include <sys/types.h>
22 #endif
23 #include "lldb/Host/windows/windows.h"
24 #include <inttypes.h>
25 
26 struct winsize {
27   long ws_col;
28 };
29 
30 typedef unsigned char cc_t;
31 typedef unsigned int speed_t;
32 typedef unsigned int tcflag_t;
33 
34 // fcntl.h
35 #define O_NOCTTY 0400
36 
37 // ioctls.h
38 #define TIOCGWINSZ 0x5413
39 
40 // signal.h
41 #define SIGPIPE 13
42 #define SIGCONT 18
43 #define SIGTSTP 20
44 #define SIGWINCH 28
45 
46 // tcsetattr arguments
47 #define TCSANOW 0
48 
49 #define NCCS 32
50 struct termios {
51   tcflag_t c_iflag; // input mode flags
52   tcflag_t c_oflag; // output mode flags
53   tcflag_t c_cflag; // control mode flags
54   tcflag_t c_lflag; // local mode flags
55   cc_t c_line;      // line discipline
56   cc_t c_cc[NCCS];  // control characters
57   speed_t c_ispeed; // input speed
58   speed_t c_ospeed; // output speed
59 };
60 
61 #ifdef _MSC_VER
62 struct timeval {
63   long tv_sec;
64   long tv_usec;
65 };
66 typedef long pid_t;
67 #define PATH_MAX MAX_PATH
68 #endif
69 
70 #define STDIN_FILENO 0
71 
72 extern int ioctl(int d, int request, ...);
73 extern int kill(pid_t pid, int sig);
74 extern int tcsetattr(int fd, int optional_actions,
75                      const struct termios *termios_p);
76 extern int tcgetattr(int fildes, struct termios *termios_p);
77 
78 #else
79 #include <inttypes.h>
80 
81 #include <libgen.h>
82 #include <sys/ioctl.h>
83 #include <termios.h>
84 #include <unistd.h>
85 
86 #include <pthread.h>
87 #include <sys/time.h>
88 #endif
89 
90 #endif // LLDB_TOOLS_DRIVER_PLATFORM_H
91