xref: /llvm-project/lldb/tools/driver/Platform.cpp (revision 76e47d4887f456878c0e2f20ebfae36267006cd7)
1429222c1SDeepak Panickal //===-- Platform.cpp --------------------------------------------*- C++ -*-===//
2429222c1SDeepak Panickal //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6429222c1SDeepak Panickal //
7429222c1SDeepak Panickal //===----------------------------------------------------------------------===//
8429222c1SDeepak Panickal 
9429222c1SDeepak Panickal // this file is only relevant for Visual C++
106eff1019SHafiz Abid Qadeer #if defined(_WIN32)
11429222c1SDeepak Panickal 
12*76e47d48SRaphael Isemann #include <cassert>
13*76e47d48SRaphael Isemann #include <cstdlib>
14b9c1b51eSKate Stone #include <process.h>
15429222c1SDeepak Panickal 
16429222c1SDeepak Panickal #include "Platform.h"
17c523c38fSPavel Labath #include "llvm/Support/ErrorHandling.h"
18429222c1SDeepak Panickal 
ioctl(int d,int request,...)19b9c1b51eSKate Stone int ioctl(int d, int request, ...) {
20b9c1b51eSKate Stone   switch (request) {
21429222c1SDeepak Panickal   // request the console windows size
22b9c1b51eSKate Stone   case (TIOCGWINSZ): {
2399fbc076SDeepak Panickal     va_list vl;
2499fbc076SDeepak Panickal     va_start(vl, request);
25429222c1SDeepak Panickal     // locate the window size structure on stack
2699fbc076SDeepak Panickal     winsize *ws = va_arg(vl, winsize *);
27429222c1SDeepak Panickal     // get screen buffer information
28429222c1SDeepak Panickal     CONSOLE_SCREEN_BUFFER_INFO info;
29b9c1b51eSKate Stone     if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info) ==
30b9c1b51eSKate Stone         TRUE)
31429222c1SDeepak Panickal       // fill in the columns
32429222c1SDeepak Panickal       ws->ws_col = info.dwMaximumWindowSize.X;
3399fbc076SDeepak Panickal     va_end(vl);
34429222c1SDeepak Panickal     return 0;
35b9c1b51eSKate Stone   } break;
36429222c1SDeepak Panickal   default:
37a322f36cSDavid Blaikie     llvm_unreachable("Not implemented!");
38429222c1SDeepak Panickal   }
39429222c1SDeepak Panickal }
40429222c1SDeepak Panickal 
kill(pid_t pid,int sig)41b9c1b51eSKate Stone int kill(pid_t pid, int sig) {
42429222c1SDeepak Panickal   // is the app trying to kill itself
43429222c1SDeepak Panickal   if (pid == getpid())
44429222c1SDeepak Panickal     exit(sig);
45429222c1SDeepak Panickal   //
46a322f36cSDavid Blaikie   llvm_unreachable("Not implemented!");
47429222c1SDeepak Panickal }
48429222c1SDeepak Panickal 
tcsetattr(int fd,int optional_actions,const struct termios * termios_p)49b9c1b51eSKate Stone int tcsetattr(int fd, int optional_actions, const struct termios *termios_p) {
50a322f36cSDavid Blaikie   llvm_unreachable("Not implemented!");
51429222c1SDeepak Panickal }
52429222c1SDeepak Panickal 
tcgetattr(int fildes,struct termios * termios_p)53b9c1b51eSKate Stone int tcgetattr(int fildes, struct termios *termios_p) {
54429222c1SDeepak Panickal   //  assert( !"Not implemented!" );
55429222c1SDeepak Panickal   // error return value (0=success)
56429222c1SDeepak Panickal   return -1;
57429222c1SDeepak Panickal }
58429222c1SDeepak Panickal 
59429222c1SDeepak Panickal #endif
60