Blame src/string/ntapi_tt_aligned_block_memlock.c

e29bce
/********************************************************/
e29bce
/*  ntapi: Native API core library                      */
e29bce
/*  Copyright (C) 2013--2018  Z. Gilboa                 */
e29bce
/*  Released under GPLv2 and GPLv3; see COPYING.NTAPI.  */
e29bce
/********************************************************/
e29bce
e29bce
#include <psxtypes/psxtypes.h>
e29bce
#include <ntapi/nt_string.h>
e29bce
#include <ntapi/nt_sync.h>
e29bce
#include <ntapi/nt_atomic.h>
e29bce
e29bce
uintptr_t * __cdecl __ntapi_tt_aligned_block_memlock(
e29bce
	__in	uintptr_t *	dst,
e29bce
	__in	size_t		bytes)
e29bce
{
e29bce
	size_t addr = (size_t)dst & ~(size_t)(NT_SYNC_BLOCK_SIZE);
e29bce
	size_t cap  = addr + bytes;
e29bce
e29bce
	for (; addr
e29bce
		at_locked_xadd((intptr_t *)addr,0);
e29bce
e29bce
	return dst;
e29bce
}