Blame src/string/ntapi_tt_aligned_block_memcpy.c

dd89bb
/********************************************************/
dd89bb
/*  ntapi: Native API core library                      */
dde53a
/*  Copyright (C) 2013--2017  Z. Gilboa                 */
dd89bb
/*  Released under GPLv2 and GPLv3; see COPYING.NTAPI.  */
dd89bb
/********************************************************/
dd89bb
dd89bb
#include <psxtypes/psxtypes.h>
dd89bb
#include <ntapi/nt_string.h>
dd89bb
dd89bb
uintptr_t * __cdecl __ntapi_tt_aligned_block_memcpy(
dd89bb
	__in	uintptr_t *	dst,
dd89bb
	__in	uintptr_t *	src,
dd89bb
	__in	size_t		bytes)
dd89bb
{
dd89bb
	uintptr_t * ptr = (uintptr_t *)dst;
dd89bb
dd89bb
	for (bytes/=sizeof(uintptr_t); bytes; bytes--)
dd89bb
		*dst++ = *src++;
dd89bb
dd89bb
	return ptr;
dd89bb
}
dd89bb
dd89bb
dd89bb
void * __cdecl __ntapi_tt_generic_memcpy(
dd89bb
	__in	void *		dst,
dd89bb
	__in	const void *	src,
dd89bb
	__in	size_t		bytes)
dd89bb
{
dd89bb
	char *		ch_dst;
dd89bb
	const char *	ch_src;
dd89bb
dd89bb
	if (!bytes)
dd89bb
		return dst;
dd89bb
dd89bb
	else if (!(bytes % sizeof(size_t))
dd89bb
			&& (!(uintptr_t)dst % sizeof(size_t))
dd89bb
			&& (!(uintptr_t)src % sizeof(size_t)))
dd89bb
		return __ntapi_tt_aligned_block_memcpy(
dd89bb
			(uintptr_t *)dst,
dd89bb
			(uintptr_t *)src,
dd89bb
			bytes);
dd89bb
dd89bb
	ch_dst = (char *)dst;
dd89bb
	ch_src = (const char *)src;
dd89bb
dd89bb
	for (; bytes; bytes--)
dd89bb
		*ch_dst++ = *ch_src++;
dd89bb
dd89bb
	return dst;
dd89bb
}