]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/tools/lldb/tools/driver/Platform.cpp
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / tools / lldb / tools / driver / Platform.cpp
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++
11 #if defined( _MSC_VER )
12
13 #include <process.h>
14 #include <assert.h>
15
16 #include "Platform.h"
17
18 // index one of the variable arguments
19 //  presuming "(EditLine *el, ..." is first in the argument list
20 #define GETARG( Y, X ) ( (void* ) *( ( (int**) &(Y) ) + (X) ) )
21
22 // the control handler or SIGINT handler
23 static sighandler_t _ctrlHandler = NULL;
24
25 // the default console control handler
26 BOOL
27 WINAPI CtrlHandler (DWORD ctrlType)
28 {
29     if ( _ctrlHandler != NULL )
30     {
31         _ctrlHandler( 0 );
32         return TRUE;
33     }
34     return FALSE;
35 }
36
37 int
38 ioctl (int d, int request, ...)
39 {
40     switch ( request )
41     {
42     // request the console windows size
43     case ( TIOCGWINSZ ):
44         {
45             // locate the window size structure on stack
46             winsize *ws = (winsize*) GETARG( d, 2 );
47             // get screen buffer information
48             CONSOLE_SCREEN_BUFFER_INFO info;
49             GetConsoleScreenBufferInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &info );
50             // fill in the columns
51             ws->ws_col = info.dwMaximumWindowSize.X;
52             //
53             return 0;
54         }
55         break;
56     default:
57         assert( !"Not implemented!" );
58     }
59     return -1;
60 }
61
62 int
63 kill (pid_t pid, int sig)
64 {
65     // is the app trying to kill itself
66     if ( pid == getpid( ) )
67         exit( sig );
68     //
69     assert( !"Not implemented!" );
70     return -1;
71 }
72
73 int
74 tcsetattr (int fd, int optional_actions, const struct termios *termios_p)
75 {
76     assert( !"Not implemented!" );
77     return -1;
78 }
79
80 int
81 tcgetattr (int fildes, struct termios *termios_p)
82 {
83 //  assert( !"Not implemented!" );
84     // error return value (0=success)
85     return -1;
86 }
87
88 sighandler_t
89 signal (int sig, sighandler_t sigFunc)
90 {
91     switch ( sig )
92     {
93     case ( SIGINT ):
94         {
95             _ctrlHandler = sigFunc;
96             SetConsoleCtrlHandler( CtrlHandler, TRUE );
97         }
98         break;
99     case ( SIGPIPE  ):
100     case ( SIGWINCH ):
101     case ( SIGTSTP  ):
102     case ( SIGCONT  ):
103         // ignore these for now
104         break;
105     default:
106         assert( !"Not implemented!" );
107     }
108     return 0;
109 }
110
111 #endif