xref: /freebsd/contrib/llvm-project/lldb/tools/driver/Platform.h (revision fe6060f10f634930ff71b7c50291ddc610da2475)
10b57cec5SDimitry Andric //===-- Platform.h ----------------------------------------------*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
95ffd83dbSDimitry Andric #ifndef LLDB_TOOLS_DRIVER_PLATFORM_H
105ffd83dbSDimitry Andric #define LLDB_TOOLS_DRIVER_PLATFORM_H
110b57cec5SDimitry Andric 
129dba64beSDimitry Andric #include "lldb/Host/Config.h"
139dba64beSDimitry Andric 
140b57cec5SDimitry Andric #if defined(_WIN32)
150b57cec5SDimitry Andric 
160b57cec5SDimitry Andric #include <io.h>
170b57cec5SDimitry Andric #if defined(_MSC_VER)
18*fe6060f1SDimitry Andric #include <csignal>
190b57cec5SDimitry Andric #endif
209dba64beSDimitry Andric #if HAVE_SYS_TYPES_H
219dba64beSDimitry Andric #include <sys/types.h>
229dba64beSDimitry Andric #endif
230b57cec5SDimitry Andric #include "lldb/Host/windows/windows.h"
24*fe6060f1SDimitry Andric #include <cinttypes>
250b57cec5SDimitry Andric 
260b57cec5SDimitry Andric struct winsize {
270b57cec5SDimitry Andric   long ws_col;
280b57cec5SDimitry Andric };
290b57cec5SDimitry Andric 
300b57cec5SDimitry Andric typedef unsigned char cc_t;
310b57cec5SDimitry Andric typedef unsigned int speed_t;
320b57cec5SDimitry Andric typedef unsigned int tcflag_t;
330b57cec5SDimitry Andric 
340b57cec5SDimitry Andric // fcntl.h
350b57cec5SDimitry Andric #define O_NOCTTY 0400
360b57cec5SDimitry Andric 
370b57cec5SDimitry Andric // ioctls.h
380b57cec5SDimitry Andric #define TIOCGWINSZ 0x5413
390b57cec5SDimitry Andric 
400b57cec5SDimitry Andric // signal.h
410b57cec5SDimitry Andric #define SIGPIPE 13
420b57cec5SDimitry Andric #define SIGCONT 18
430b57cec5SDimitry Andric #define SIGTSTP 20
440b57cec5SDimitry Andric #define SIGWINCH 28
450b57cec5SDimitry Andric 
460b57cec5SDimitry Andric // tcsetattr arguments
470b57cec5SDimitry Andric #define TCSANOW 0
480b57cec5SDimitry Andric 
490b57cec5SDimitry Andric #define NCCS 32
500b57cec5SDimitry Andric struct termios {
510b57cec5SDimitry Andric   tcflag_t c_iflag; // input mode flags
520b57cec5SDimitry Andric   tcflag_t c_oflag; // output mode flags
530b57cec5SDimitry Andric   tcflag_t c_cflag; // control mode flags
540b57cec5SDimitry Andric   tcflag_t c_lflag; // local mode flags
550b57cec5SDimitry Andric   cc_t c_line;      // line discipline
560b57cec5SDimitry Andric   cc_t c_cc[NCCS];  // control characters
570b57cec5SDimitry Andric   speed_t c_ispeed; // input speed
580b57cec5SDimitry Andric   speed_t c_ospeed; // output speed
590b57cec5SDimitry Andric };
600b57cec5SDimitry Andric 
610b57cec5SDimitry Andric #ifdef _MSC_VER
620b57cec5SDimitry Andric struct timeval {
630b57cec5SDimitry Andric   long tv_sec;
640b57cec5SDimitry Andric   long tv_usec;
650b57cec5SDimitry Andric };
660b57cec5SDimitry Andric typedef long pid_t;
670b57cec5SDimitry Andric #define PATH_MAX MAX_PATH
680b57cec5SDimitry Andric #endif
690b57cec5SDimitry Andric 
700b57cec5SDimitry Andric #define STDIN_FILENO 0
710b57cec5SDimitry Andric 
720b57cec5SDimitry Andric extern int ioctl(int d, int request, ...);
730b57cec5SDimitry Andric extern int kill(pid_t pid, int sig);
740b57cec5SDimitry Andric extern int tcsetattr(int fd, int optional_actions,
750b57cec5SDimitry Andric                      const struct termios *termios_p);
760b57cec5SDimitry Andric extern int tcgetattr(int fildes, struct termios *termios_p);
770b57cec5SDimitry Andric 
780b57cec5SDimitry Andric #else
79*fe6060f1SDimitry Andric #include <cinttypes>
800b57cec5SDimitry Andric 
810b57cec5SDimitry Andric #include <libgen.h>
820b57cec5SDimitry Andric #include <sys/ioctl.h>
830b57cec5SDimitry Andric #include <termios.h>
840b57cec5SDimitry Andric #include <unistd.h>
850b57cec5SDimitry Andric 
860b57cec5SDimitry Andric #include <pthread.h>
870b57cec5SDimitry Andric #include <sys/time.h>
880b57cec5SDimitry Andric #endif
890b57cec5SDimitry Andric 
905ffd83dbSDimitry Andric #endif // LLDB_TOOLS_DRIVER_PLATFORM_H
91