Index: minilibc/common.h |
— | — | @@ -25,4 +25,8 @@ |
26 | 26 |
|
27 | 27 | extern void* (*memset_ptr)(void *dest, int c, size_t count);
|
28 | 28 | void *memset_init(void *dest, int c, size_t count);
|
29 | | -void *memset_386(void *dest, int c, size_t count); |
\ No newline at end of file |
| 29 | +void *memset_386(void *dest, int c, size_t count);
|
| 30 | +
|
| 31 | +extern void* (*memcpy_ptr)(void *dest, const void *src, size_t count);
|
| 32 | +void *memcpy_init(void *dest, const void *src, size_t count);
|
| 33 | +void *memcpy_386(void *dest, const void *src, size_t count);
|
Index: minilibc/common.inc |
— | — | @@ -17,4 +17,7 @@ |
18 | 18 |
|
19 | 19 | EXTERN C itoachars:ptr byte
|
20 | 20 | EXTERN C memset_ptr:ptr dword
|
21 | | -EXTERN C memcpy:proc |
\ No newline at end of file |
| 21 | +EXTERN C memcpy_ptr:ptr dword
|
| 22 | +ifndef MEMCPY_ASM
|
| 23 | +EXTERN C memcpy:proc
|
| 24 | +endif |
\ No newline at end of file |
Index: minilibc/file.c |
— | — | @@ -320,7 +320,7 @@ |
321 | 321 | int _fcloseall()
|
322 | 322 | {
|
323 | 323 | int i;
|
324 | | - int count;
|
| 324 | + int count = 0;
|
325 | 325 | if(!minilibc_files) return 0;
|
326 | 326 | for(i = 0; i < filecount; i++)
|
327 | 327 | {
|
Index: minilibc/memcpy.c |
— | — | @@ -0,0 +1,27 @@ |
| 2 | +// DXGL
|
| 3 | +// Copyright (C) 2012 William Feely
|
| 4 | +
|
| 5 | +// This library is free software; you can redistribute it and/or
|
| 6 | +// modify it under the terms of the GNU Lesser General Public
|
| 7 | +// License as published by the Free Software Foundation; either
|
| 8 | +// version 2.1 of the License, or (at your option) any later version.
|
| 9 | +
|
| 10 | +// This library is distributed in the hope that it will be useful,
|
| 11 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 | +// Lesser General Public License for more details.
|
| 14 | +
|
| 15 | +// You should have received a copy of the GNU Lesser General Public
|
| 16 | +// License along with this library; if not, write to the Free Software
|
| 17 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 18 | +
|
| 19 | +#include "common.h"
|
| 20 | +
|
| 21 | +void* (*memcpy_ptr)(void *dest, const void *src, size_t count) = memcpy_init;
|
| 22 | +
|
| 23 | +
|
| 24 | +void *memcpy_init(void *dest, const void *src, size_t count)
|
| 25 | +{
|
| 26 | + minilibc_init();
|
| 27 | + return memcpy_ptr(dest,src,count);
|
| 28 | +} |
\ No newline at end of file |
Index: minilibc/memcpy_x86.asm |
— | — | @@ -0,0 +1,43 @@ |
| 2 | +; DXGL
|
| 3 | +; Copyright (C) 2012 William Feely
|
| 4 | +
|
| 5 | +; This library is free software; you can redistribute it and/or
|
| 6 | +; modify it under the terms of the GNU Lesser General Public
|
| 7 | +; License as published by the Free Software Foundation; either
|
| 8 | +; version 2.1 of the License, or (at your option) any later version.
|
| 9 | +
|
| 10 | +; This library is distributed in the hope that it will be useful,
|
| 11 | +; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 | +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 | +; Lesser General Public License for more details.
|
| 14 | +
|
| 15 | +; You should have received a copy of the GNU Lesser General Public
|
| 16 | +; License along with this library; if not, write to the Free Software
|
| 17 | +; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 18 | +
|
| 19 | +.model flat, c
|
| 20 | +.code
|
| 21 | +
|
| 22 | +MEMCPY_ASM = 1
|
| 23 | +
|
| 24 | +INCLUDE common.inc
|
| 25 | +
|
| 26 | +memcpy PROC dest: ptr byte, src: ptr byte, count: dword
|
| 27 | + jmp dword ptr memcpy_ptr
|
| 28 | +memcpy ENDP
|
| 29 | +
|
| 30 | +memcpy_386 PROC dest: ptr byte, src: ptr byte, count: dword
|
| 31 | + push esi
|
| 32 | + push edi
|
| 33 | + push ecx
|
| 34 | + mov esi, src
|
| 35 | + mov edi, dest
|
| 36 | + mov ecx, count
|
| 37 | + rep movsb
|
| 38 | + mov eax, dest
|
| 39 | + pop ecx
|
| 40 | + pop edi
|
| 41 | + pop esi
|
| 42 | +memcpy_386 ENDP
|
| 43 | +
|
| 44 | +end
|
Index: minilibc/minilibc.vcxproj |
— | — | @@ -92,6 +92,9 @@ |
93 | 93 | <CustomBuild Include="memset_x86.asm">
|
94 | 94 | <FileType>Document</FileType>
|
95 | 95 | </CustomBuild>
|
| 96 | + <CustomBuild Include="memcpy_x86.asm">
|
| 97 | + <FileType>Document</FileType>
|
| 98 | + </CustomBuild>
|
96 | 99 | <None Include="ReadMe.txt" />
|
97 | 100 | <CustomBuild Include="_itoa_x86.asm">
|
98 | 101 | <FileType>Document</FileType>
|
— | — | @@ -112,6 +115,7 @@ |
113 | 116 | <ClCompile Include="exit.c" />
|
114 | 117 | <ClCompile Include="file.c" />
|
115 | 118 | <ClCompile Include="init.c" />
|
| 119 | + <ClCompile Include="memcpy.c" />
|
116 | 120 | <ClCompile Include="memory.c" />
|
117 | 121 | <ClCompile Include="memset.c" />
|
118 | 122 | </ItemGroup>
|
Index: minilibc/minilibc.vcxproj.filters |
— | — | @@ -36,6 +36,9 @@ |
37 | 37 | <CustomBuild Include="string_x86.asm">
|
38 | 38 | <Filter>Source Files</Filter>
|
39 | 39 | </CustomBuild>
|
| 40 | + <CustomBuild Include="memcpy_x86.asm">
|
| 41 | + <Filter>Source Files</Filter>
|
| 42 | + </CustomBuild>
|
40 | 43 | </ItemGroup>
|
41 | 44 | <ItemGroup>
|
42 | 45 | <ClCompile Include="exit.c">
|
— | — | @@ -59,6 +62,9 @@ |
60 | 63 | <ClCompile Include="memory.c">
|
61 | 64 | <Filter>Source Files</Filter>
|
62 | 65 | </ClCompile>
|
| 66 | + <ClCompile Include="memcpy.c">
|
| 67 | + <Filter>Source Files</Filter>
|
| 68 | + </ClCompile>
|
63 | 69 | </ItemGroup>
|
64 | 70 | <ItemGroup>
|
65 | 71 | <ClInclude Include="common.h">
|