Blame src/string/ntapi_tt_aligned_block_memlock.c

e29bce
/********************************************************/
e29bce
/*  ntapi: Native API core library                      */
64e606
/*  Copyright (C) 2013--2021  SysDeer Technologies, LLC */
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
6445d5
#define __CPU_CACHE_SIZE 64
6445d5
766a63
__attr_protected__
e29bce
uintptr_t * __cdecl __ntapi_tt_aligned_block_memlock(
e29bce
	__in	uintptr_t *	dst,
e29bce
	__in	size_t		bytes)
e29bce
{
6445d5
	size_t addr = (size_t)dst & ~(size_t)(__CPU_CACHE_SIZE);
e29bce
	size_t cap  = addr + bytes;
e29bce
6445d5
	for (; addr
e29bce
		at_locked_xadd((intptr_t *)addr,0);
e29bce
e29bce
	return dst;
e29bce
}