Add WIN32 pseudo console APIs

See #999
This commit is contained in:
Justine Tunney 2023-12-10 01:29:25 -08:00
parent 1bd69867d1
commit 4f66d7f2dd
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
7 changed files with 72 additions and 2 deletions

View file

@ -106,6 +106,11 @@ bool32 SetConsoleCursorInfo(
int64_t hConsoleOutput,
const struct NtConsoleCursorInfo *lpConsoleCursorInfo);
long CreatePseudoConsole(struct NtCoord size, int64_t hInput, int64_t hOutput,
uint32_t dwFlags, int64_t *out_phPC);
long ResizePseudoConsole(int64_t hPC, struct NtCoord size);
void ClosePseudoConsole(int64_t hPC);
#if ShouldUseMsabiAttribute()
#include "libc/nt/thunk/console.inc"
#endif /* ShouldUseMsabiAttribute() */

View file

@ -0,0 +1,6 @@
#ifndef COSMOPOLITAN_LIBC_NT_ENUM_PSEUDOCONSOLE_H_
#define COSMOPOLITAN_LIBC_NT_ENUM_PSEUDOCONSOLE_H_
#define kNtPseudoconsoleInheritCursor 1
#endif /* COSMOPOLITAN_LIBC_NT_ENUM_PSEUDOCONSOLE_H_ */

View file

@ -0,0 +1,20 @@
#include "libc/nt/codegen.h"
.imp kernel32,__imp_ClosePseudoConsole,ClosePseudoConsole
.text.windows
.ftrace1
ClosePseudoConsole:
.ftrace2
#ifdef __x86_64__
push %rbp
mov %rsp,%rbp
mov %rdi,%rcx
sub $32,%rsp
call *__imp_ClosePseudoConsole(%rip)
leave
#elif defined(__aarch64__)
mov x0,#0
#endif
ret
.endfn ClosePseudoConsole,globl
.previous

View file

@ -0,0 +1,18 @@
#include "libc/nt/codegen.h"
.imp kernel32,__imp_CreatePseudoConsole,CreatePseudoConsole
.text.windows
.ftrace1
CreatePseudoConsole:
.ftrace2
#ifdef __x86_64__
push %rbp
mov %rsp,%rbp
mov __imp_CreatePseudoConsole(%rip),%rax
jmp __sysv2nt6
#elif defined(__aarch64__)
mov x0,#0
ret
#endif
.endfn CreatePseudoConsole,globl
.previous

View file

@ -0,0 +1,18 @@
#include "libc/nt/codegen.h"
.imp kernel32,__imp_ResizePseudoConsole,ResizePseudoConsole
.text.windows
.ftrace1
ResizePseudoConsole:
.ftrace2
#ifdef __x86_64__
push %rbp
mov %rsp,%rbp
mov __imp_ResizePseudoConsole(%rip),%rax
jmp __sysv2nt
#elif defined(__aarch64__)
mov x0,#0
ret
#endif
.endfn ResizePseudoConsole,globl
.previous

View file

@ -58,6 +58,7 @@ imp 'CancelSynchronousIo' CancelSynchronousIo kernel32 1
imp 'CheckRemoteDebuggerPresent' CheckRemoteDebuggerPresent kernel32 2
imp 'ClearCommBreak' ClearCommBreak kernel32 1
imp 'CloseHandle' CloseHandle kernel32 1
imp 'ClosePseudoConsole' ClosePseudoConsole kernel32 1 # Windows 10+
imp 'ConnectNamedPipe' ConnectNamedPipe kernel32 2
imp 'ContinueDebugEvent' ContinueDebugEvent kernel32 3
imp 'CopyFile' CopyFileW kernel32 3
@ -65,6 +66,7 @@ imp 'CreateEvent' CreateEventW kernel32 4
imp 'CreateEventEx' CreateEventExW kernel32 4
imp 'CreateHardLink' CreateHardLinkW kernel32 3
imp 'CreateIoCompletionPort' CreateIoCompletionPort kernel32 4
imp 'CreatePseudoConsole' CreatePseudoConsole kernel32 5 # Windows 10+
imp 'CreateSemaphore' CreateSemaphoreW kernel32 4
imp 'CreateToolhelp32Snapshot' CreateToolhelp32Snapshot kernel32 2
imp 'CreateWaitableTimer' CreateWaitableTimerW kernel32 3
@ -227,6 +229,7 @@ imp 'ReleaseSemaphore' ReleaseSemaphore kernel32 3
imp 'RemoveVectoredContinueHandler' RemoveVectoredContinueHandler kernel32 1
imp 'RemoveVectoredExceptionHandler' RemoveVectoredExceptionHandler kernel32 1
imp 'ResetEvent' ResetEvent kernel32 1
imp 'ResizePseudoConsole' ResizePseudoConsole kernel32 2 # Windows 10+
imp 'ResumeThread' ResumeThread kernel32 1
imp 'SetConsoleActiveScreenBuffer' SetConsoleActiveScreenBuffer kernel32 1 # TODO(jart): 6.2 and higher
imp 'SetConsoleCP' SetConsoleCP kernel32 1 # TODO(jart): 6.2 and higher

View file

@ -507,10 +507,10 @@
#define HAVE_WORKING_VFORK 1
/* Default C++ compiler. */
#define MAKE_CXX "/opt/cosmocc/bin/aarch64-unknown-cosmo-c++"
#define MAKE_CXX "c++"
/* Build host information. */
#define MAKE_HOST "x86_64-pc-linux-musl"
#define MAKE_HOST "x86_64-linux-cosmo"
/* Define to 1 to enable job server support in GNU Make. */
#define MAKE_JOBSERVER 1