diff options
-rw-r--r-- | src/internal/ntapi_pty.h | 32 | ||||
-rw-r--r-- | src/pty/ntapi_pty_fd.c | 11 |
2 files changed, 24 insertions, 19 deletions
diff --git a/src/internal/ntapi_pty.h b/src/internal/ntapi_pty.h index 711c5f5..a71a750 100644 --- a/src/internal/ntapi_pty.h +++ b/src/internal/ntapi_pty.h @@ -1,6 +1,6 @@ /********************************************************/ /* ntapi: Native API core library */ -/* Copyright (C) 2013--2017 Z. Gilboa */ +/* Copyright (C) 2013--2019 Z. Gilboa */ /* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */ /********************************************************/ @@ -17,21 +17,21 @@ #define __PTY_WRITE 1 typedef struct nt_pty_context { - nt_sync_block sync[2]; - void * addr; - size_t size; - void * hport; - void * hpty; - void * section; - void * section_addr; - size_t section_size; - nt_guid guid; - nt_luid luid; - uint32_t access; - uint32_t flags; - uint32_t share; - uint32_t options; - nt_iosb iosb; + int32_t volatile lock[2]; + void * addr; + size_t size; + void * hport; + void * hpty; + void * section; + void * section_addr; + size_t section_size; + nt_guid guid; + nt_luid luid; + uint32_t access; + uint32_t flags; + uint32_t share; + uint32_t options; + nt_iosb iosb; } nt_pty; #endif diff --git a/src/pty/ntapi_pty_fd.c b/src/pty/ntapi_pty_fd.c index 45a58ff..2e79417 100644 --- a/src/pty/ntapi_pty_fd.c +++ b/src/pty/ntapi_pty_fd.c @@ -5,6 +5,7 @@ /********************************************************/ #include <psxtypes/psxtypes.h> +#include <ntapi/nt_atomic.h> #include <ntapi/nt_port.h> #include <ntapi/nt_tty.h> #include <ntapi/ntapi.h> @@ -111,6 +112,10 @@ static int32_t __fastcall __ntapi_pty_alloc(nt_pty ** pty) ctx->addr = ctx; ctx->size = ctx_size; + /* atomic lock reset */ + at_store_32(&ctx->lock[__PTY_READ],0); + at_store_32(&ctx->lock[__PTY_WRITE],0); + *pty = ctx; return NT_STATUS_SUCCESS; } @@ -155,9 +160,9 @@ static int32_t __ntapi_pty_connect( NT_PAGE_READWRITE))) return __ntapi_pty_fail(ctx,status); - /* assume conforming clients, config for single lock try */ - __ntapi->tt_sync_block_init(&ctx->sync[__PTY_READ],0,0,1,0,0); - __ntapi->tt_sync_block_init(&ctx->sync[__PTY_WRITE],0,0,1,0,0); + /* atomic lock reset */ + at_store_32(&ctx->lock[__PTY_READ],0); + at_store_32(&ctx->lock[__PTY_WRITE],0); return NT_STATUS_SUCCESS; } |