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" |
| 18 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 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 | assert(!"Not implemented!"); |
| 38 | } |
| 39 | return -1; |
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 | // |
| 47 | assert(!"Not implemented!"); |
| 48 | return -1; |
Deepak Panickal | 429222c | 2013-10-15 15:46:40 +0000 | [diff] [blame] | 49 | } |
| 50 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 51 | int tcsetattr(int fd, int optional_actions, const struct termios *termios_p) { |
| 52 | assert(!"Not implemented!"); |
| 53 | return -1; |
Deepak Panickal | 429222c | 2013-10-15 15:46:40 +0000 | [diff] [blame] | 54 | } |
| 55 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 56 | int tcgetattr(int fildes, struct termios *termios_p) { |
| 57 | // assert( !"Not implemented!" ); |
| 58 | // error return value (0=success) |
| 59 | return -1; |
Deepak Panickal | 429222c | 2013-10-15 15:46:40 +0000 | [diff] [blame] | 60 | } |
| 61 | |
Deepak Panickal | 99fbc07 | 2014-03-03 15:39:47 +0000 | [diff] [blame] | 62 | #endif |