summaryrefslogtreecommitdiffhomepage
path: root/src/string/ntapi_tt_aligned_block_memcpy.c
blob: dda33b6b907f04f94f8719cf11bac4d4691bfc56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/********************************************************/
/*  ntapi: Native API core library                      */
/*  Copyright (C) 2013--2017  Z. Gilboa                 */
/*  Released under GPLv2 and GPLv3; see COPYING.NTAPI.  */
/********************************************************/

#include <psxtypes/psxtypes.h>
#include <ntapi/nt_string.h>

__attr_protected__
uintptr_t * __cdecl __ntapi_tt_aligned_block_memcpy(
	__in	uintptr_t *	dst,
	__in	uintptr_t *	src,
	__in	size_t		bytes)
{
	uintptr_t * ptr = (uintptr_t *)dst;

	for (bytes/=sizeof(uintptr_t); bytes; bytes--)
		*dst++ = *src++;

	return ptr;
}


__attr_protected__
void * __cdecl __ntapi_tt_generic_memcpy(
	__in	void *		dst,
	__in	const void *	src,
	__in	size_t		bytes)
{
	char *		ch_dst;
	const char *	ch_src;

	if (!bytes)
		return dst;

	else if (!(bytes % sizeof(size_t))
			&& (!(uintptr_t)dst % sizeof(size_t))
			&& (!(uintptr_t)src % sizeof(size_t)))
		return __ntapi_tt_aligned_block_memcpy(
			(uintptr_t *)dst,
			(uintptr_t *)src,
			bytes);

	ch_dst = (char *)dst;
	ch_src = (const char *)src;

	for (; bytes; bytes--)
		*ch_dst++ = *ch_src++;

	return dst;
}