Deepak Panickal | 429222c | 2013-10-15 15:46:40 +0000 | [diff] [blame] | 1 | //===-- Platform.cpp --------------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // this file is only relevant for Visual C++ |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 11 | #if defined(_WIN32) |
Deepak Panickal | 429222c | 2013-10-15 15:46:40 +0000 | [diff] [blame] | 12 | |
Deepak Panickal | 429222c | 2013-10-15 15:46:40 +0000 | [diff] [blame] | 13 | #include <assert.h> |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 14 | #include <process.h> |
Hafiz Abid Qadeer | bdb5159 | 2014-03-12 10:39:46 +0000 | [diff] [blame] | 15 | #include <stdlib.h> |
Deepak Panickal | 429222c | 2013-10-15 15:46:40 +0000 | [diff] [blame] | 16 | |
| 17 | #include "Platform.h" |
Pavel Labath | c523c38 | 2017-01-06 13:07:09 +0000 | [diff] [blame] | 18 | #include "llvm/Support/ErrorHandling.h" |
Deepak Panickal | 429222c | 2013-10-15 15:46:40 +0000 | [diff] [blame] | 19 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 20 | int ioctl(int d, int request, ...) { |
| 21 | switch (request) { |
| 22 | // request the console windows size |
| 23 | case (TIOCGWINSZ): { |
| 24 | va_list vl; |
| 25 | va_start(vl, request); |
| 26 | // locate the window size structure on stack |
| 27 | winsize *ws = va_arg(vl, winsize *); |
| 28 | // get screen buffer information |
| 29 | CONSOLE_SCREEN_BUFFER_INFO info; |
| 30 | if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info) == |
| 31 | TRUE) |
| 32 | // fill in the columns |
| 33 | ws->ws_col = info.dwMaximumWindowSize.X; |
| 34 | va_end(vl); |
| 35 | return 0; |
| 36 | } break; |
| 37 | default: |
David Blaikie | a322f36 | 2017-01-06 00:38:06 +0000 | [diff] [blame] | 38 | llvm_unreachable("Not implemented!"); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 39 | } |
Deepak Panickal | 429222c | 2013-10-15 15:46:40 +0000 | [diff] [blame] | 40 | } |
| 41 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 42 | int kill(pid_t pid, int sig) { |
| 43 | // is the app trying to kill itself |
| 44 | if (pid == getpid()) |
| 45 | exit(sig); |
| 46 | // |
David Blaikie | a322f36 | 2017-01-06 00:38:06 +0000 | [diff] [blame] | 47 | llvm_unreachable("Not implemented!"); |
Deepak Panickal | 429222c | 2013-10-15 15:46:40 +0000 | [diff] [blame] | 48 | } |
| 49 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 50 | int tcsetattr(int fd, int optional_actions, const struct termios *termios_p) { |
David Blaikie | a322f36 | 2017-01-06 00:38:06 +0000 | [diff] [blame] | 51 | llvm_unreachable("Not implemented!"); |
Deepak Panickal | 429222c | 2013-10-15 15:46:40 +0000 | [diff] [blame] | 52 | } |
| 53 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 54 | int tcgetattr(int fildes, struct termios *termios_p) { |
| 55 | // assert( !"Not implemented!" ); |
| 56 | // error return value (0=success) |
| 57 | return -1; |
Deepak Panickal | 429222c | 2013-10-15 15:46:40 +0000 | [diff] [blame] | 58 | } |
| 59 | |
Deepak Panickal | 99fbc07 | 2014-03-03 15:39:47 +0000 | [diff] [blame] | 60 | #endif |