| 253 |
theseven |
1 |
//
|
|
|
2 |
//
|
|
|
3 |
// Copyright 2009 TheSeven
|
|
|
4 |
//
|
|
|
5 |
//
|
|
|
6 |
// This file is part of the Linux4Nano toolkit.
|
|
|
7 |
//
|
|
|
8 |
// TheSeven's iBugger is free software: you can redistribute it and/or
|
|
|
9 |
// modify it under the terms of the GNU General Public License as
|
|
|
10 |
// published by the Free Software Foundation, either version 2 of the
|
|
|
11 |
// License, or (at your option) any later version.
|
|
|
12 |
//
|
|
|
13 |
// TheSeven's iBugger is distributed in the hope that it will be useful,
|
|
|
14 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
15 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
16 |
// See the GNU General Public License for more details.
|
|
|
17 |
//
|
|
|
18 |
// You should have received a copy of the GNU General Public License along
|
|
|
19 |
// with the Linux4Nano toolkit. If not, see <http://www.gnu.org/licenses/>.
|
|
|
20 |
//
|
|
|
21 |
//
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
#include <toolkit.h>
|
|
|
25 |
#include <util.h>
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
void* memcpy(void* destination, const void* source, size_t size)
|
|
|
29 |
{
|
|
|
30 |
while (size > 0)
|
|
|
31 |
{
|
|
|
32 |
((uint8_t*)destination)[0] = ((uint8_t*)source)[0];
|
|
|
33 |
source = (void*)((uint32_t)source + 1);
|
|
|
34 |
destination = (void*)((uint32_t)destination + 1);
|
|
|
35 |
size--;
|
|
|
36 |
}
|
|
|
37 |
return destination;
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
void* memset(void* destination, int value, size_t size)
|
|
|
41 |
{
|
|
|
42 |
while (size > 0)
|
|
|
43 |
{
|
|
|
44 |
((uint8_t*)destination)[0] = value;
|
|
|
45 |
destination = (void*)((uint32_t)destination + 1);
|
|
|
46 |
size--;
|
|
|
47 |
}
|
|
|
48 |
return destination;
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
int memcmp(const void* destination, const void* source, size_t size)
|
|
|
52 |
{
|
|
|
53 |
while (size > 0)
|
|
|
54 |
{
|
|
|
55 |
if (((uint8_t*)destination)[0] != ((uint8_t*)source)[0]) return 1;
|
|
|
56 |
source = (void*)((uint32_t)source + 1);
|
|
|
57 |
destination = (void*)((uint32_t)destination + 1);
|
|
|
58 |
size--;
|
|
|
59 |
}
|
|
|
60 |
return 0;
|
|
|
61 |
}
|