summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-05-15 19:05:43 +0000
committermidipix <writeonce@midipix.org>2018-05-15 18:40:05 -0400
commite29bcec693268225f9e66aaa13d1e3a54f55c18f (patch)
tree1a1a5bfaf6b4bd9caa8919dc8dafc3214d47dad2 /src
parentad58de287d1c25c8bc143803b978c4bc5b0955f2 (diff)
downloadntapi-e29bcec693268225f9e66aaa13d1e3a54f55c18f.tar.bz2
ntapi-e29bcec693268225f9e66aaa13d1e3a54f55c18f.tar.xz
string interfaces: __ntapi_tt_aligned_block_memlock(): initial integration.
Diffstat (limited to 'src')
-rw-r--r--src/internal/ntapi.c1
-rw-r--r--src/internal/ntapi_fnapi.h1
-rw-r--r--src/string/ntapi_tt_aligned_block_memlock.c23
3 files changed, 25 insertions, 0 deletions
diff --git a/src/internal/ntapi.c b/src/internal/ntapi.c
index 9361338..a53ca80 100644
--- a/src/internal/ntapi.c
+++ b/src/internal/ntapi.c
@@ -253,6 +253,7 @@ static int32_t __fastcall __ntapi_init_once(ntapi_vtbl ** pvtbl)
__ntapi->tt_strncmp_utf16 = __ntapi_tt_strncmp_utf16;
__ntapi->tt_aligned_block_memset = __ntapi_tt_aligned_block_memset;
__ntapi->tt_aligned_block_memcpy = __ntapi_tt_aligned_block_memcpy;
+ __ntapi->tt_aligned_block_memlock = __ntapi_tt_aligned_block_memlock;
__ntapi->tt_memcpy_utf16 = __ntapi_tt_memcpy_utf16;
__ntapi->tt_aligned_memcpy_utf16 = __ntapi_tt_aligned_memcpy_utf16;
__ntapi->tt_generic_memset = __ntapi_tt_generic_memset;
diff --git a/src/internal/ntapi_fnapi.h b/src/internal/ntapi_fnapi.h
index 7c744c9..8280f55 100644
--- a/src/internal/ntapi_fnapi.h
+++ b/src/internal/ntapi_fnapi.h
@@ -115,6 +115,7 @@ ntapi_tt_strncmp_multibyte __ntapi_tt_strncmp_multibyte;
ntapi_tt_strncmp_utf16 __ntapi_tt_strncmp_utf16;
ntapi_tt_aligned_block_memset __ntapi_tt_aligned_block_memset;
ntapi_tt_aligned_block_memcpy __ntapi_tt_aligned_block_memcpy;
+ntapi_tt_aligned_block_memlock __ntapi_tt_aligned_block_memlock;
ntapi_tt_init_unicode_string_from_utf16 __ntapi_tt_init_unicode_string_from_utf16;
ntapi_tt_memcpy_utf16 __ntapi_tt_memcpy_utf16;
ntapi_tt_aligned_memcpy_utf16 __ntapi_tt_aligned_memcpy_utf16;
diff --git a/src/string/ntapi_tt_aligned_block_memlock.c b/src/string/ntapi_tt_aligned_block_memlock.c
new file mode 100644
index 0000000..5aa3a7e
--- /dev/null
+++ b/src/string/ntapi_tt_aligned_block_memlock.c
@@ -0,0 +1,23 @@
+/********************************************************/
+/* ntapi: Native API core library */
+/* Copyright (C) 2013--2018 Z. Gilboa */
+/* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */
+/********************************************************/
+
+#include <psxtypes/psxtypes.h>
+#include <ntapi/nt_string.h>
+#include <ntapi/nt_sync.h>
+#include <ntapi/nt_atomic.h>
+
+uintptr_t * __cdecl __ntapi_tt_aligned_block_memlock(
+ __in uintptr_t * dst,
+ __in size_t bytes)
+{
+ size_t addr = (size_t)dst & ~(size_t)(NT_SYNC_BLOCK_SIZE);
+ size_t cap = addr + bytes;
+
+ for (; addr<cap; addr+=NT_SYNC_BLOCK_SIZE)
+ at_locked_xadd((intptr_t *)addr,0);
+
+ return dst;
+}