1 //===-- Platform.cpp --------------------------------------------*- 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 // this file is only relevant for Visual C++
10 #if defined(_WIN32)
11
12 #include <assert.h>
13 #include <process.h>
14 #include <stdlib.h>
15
16 #include "Platform.h"
17 #include "llvm/Support/ErrorHandling.h"
18
ioctl(int d,int request,...)19 int ioctl(int d, int request, ...) {
20 switch (request) {
21 // request the console windows size
22 case (TIOCGWINSZ): {
23 va_list vl;
24 va_start(vl, request);
25 // locate the window size structure on stack
26 winsize *ws = va_arg(vl, winsize *);
27 // get screen buffer information
28 CONSOLE_SCREEN_BUFFER_INFO info;
29 if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info) ==
30 TRUE)
31 // fill in the columns
32 ws->ws_col = info.dwMaximumWindowSize.X;
33 va_end(vl);
34 return 0;
35 } break;
36 default:
37 llvm_unreachable("Not implemented!");
38 }
39 }
40
kill(pid_t pid,int sig)41 int kill(pid_t pid, int sig) {
42 // is the app trying to kill itself
43 if (pid == getpid())
44 exit(sig);
45 //
46 llvm_unreachable("Not implemented!");
47 }
48
tcsetattr(int fd,int optional_actions,const struct termios * termios_p)49 int tcsetattr(int fd, int optional_actions, const struct termios *termios_p) {
50 llvm_unreachable("Not implemented!");
51 }
52
tcgetattr(int fildes,struct termios * termios_p)53 int tcgetattr(int fildes, struct termios *termios_p) {
54 // assert( !"Not implemented!" );
55 // error return value (0=success)
56 return -1;
57 }
58
59 #endif
60