xref: /freebsd/contrib/llvm-project/lldb/tools/driver/Platform.cpp (revision 0b57cec536236d46e3dba9bd041533462f33dbb7)
1*0b57cec5SDimitry Andric //===-- Platform.cpp --------------------------------------------*- C++ -*-===//
2*0b57cec5SDimitry Andric //
3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0b57cec5SDimitry Andric //
7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
8*0b57cec5SDimitry Andric 
9*0b57cec5SDimitry Andric // this file is only relevant for Visual C++
10*0b57cec5SDimitry Andric #if defined(_WIN32)
11*0b57cec5SDimitry Andric 
12*0b57cec5SDimitry Andric #include <assert.h>
13*0b57cec5SDimitry Andric #include <process.h>
14*0b57cec5SDimitry Andric #include <stdlib.h>
15*0b57cec5SDimitry Andric 
16*0b57cec5SDimitry Andric #include "Platform.h"
17*0b57cec5SDimitry Andric #include "llvm/Support/ErrorHandling.h"
18*0b57cec5SDimitry Andric 
19*0b57cec5SDimitry Andric int ioctl(int d, int request, ...) {
20*0b57cec5SDimitry Andric   switch (request) {
21*0b57cec5SDimitry Andric   // request the console windows size
22*0b57cec5SDimitry Andric   case (TIOCGWINSZ): {
23*0b57cec5SDimitry Andric     va_list vl;
24*0b57cec5SDimitry Andric     va_start(vl, request);
25*0b57cec5SDimitry Andric     // locate the window size structure on stack
26*0b57cec5SDimitry Andric     winsize *ws = va_arg(vl, winsize *);
27*0b57cec5SDimitry Andric     // get screen buffer information
28*0b57cec5SDimitry Andric     CONSOLE_SCREEN_BUFFER_INFO info;
29*0b57cec5SDimitry Andric     if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info) ==
30*0b57cec5SDimitry Andric         TRUE)
31*0b57cec5SDimitry Andric       // fill in the columns
32*0b57cec5SDimitry Andric       ws->ws_col = info.dwMaximumWindowSize.X;
33*0b57cec5SDimitry Andric     va_end(vl);
34*0b57cec5SDimitry Andric     return 0;
35*0b57cec5SDimitry Andric   } break;
36*0b57cec5SDimitry Andric   default:
37*0b57cec5SDimitry Andric     llvm_unreachable("Not implemented!");
38*0b57cec5SDimitry Andric   }
39*0b57cec5SDimitry Andric }
40*0b57cec5SDimitry Andric 
41*0b57cec5SDimitry Andric int kill(pid_t pid, int sig) {
42*0b57cec5SDimitry Andric   // is the app trying to kill itself
43*0b57cec5SDimitry Andric   if (pid == getpid())
44*0b57cec5SDimitry Andric     exit(sig);
45*0b57cec5SDimitry Andric   //
46*0b57cec5SDimitry Andric   llvm_unreachable("Not implemented!");
47*0b57cec5SDimitry Andric }
48*0b57cec5SDimitry Andric 
49*0b57cec5SDimitry Andric int tcsetattr(int fd, int optional_actions, const struct termios *termios_p) {
50*0b57cec5SDimitry Andric   llvm_unreachable("Not implemented!");
51*0b57cec5SDimitry Andric }
52*0b57cec5SDimitry Andric 
53*0b57cec5SDimitry Andric int tcgetattr(int fildes, struct termios *termios_p) {
54*0b57cec5SDimitry Andric   //  assert( !"Not implemented!" );
55*0b57cec5SDimitry Andric   // error return value (0=success)
56*0b57cec5SDimitry Andric   return -1;
57*0b57cec5SDimitry Andric }
58*0b57cec5SDimitry Andric 
59*0b57cec5SDimitry Andric #endif
60