DXGL r279 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r278‎ | r279 | r280 >
Date:17:31, 21 October 2012
Author:admin
Status:new
Tags:
Comment:
minilibc: Add memcpy
minilibc: Fix _fcloseall
Modified paths:
  • /minilibc/common.h (modified) (history)
  • /minilibc/common.inc (modified) (history)
  • /minilibc/file.c (modified) (history)
  • /minilibc/memcpy.c (added) (history)
  • /minilibc/memcpy_x86.asm (added) (history)
  • /minilibc/minilibc.vcxproj (modified) (history)
  • /minilibc/minilibc.vcxproj.filters (modified) (history)

Diff [purge]

Index: minilibc/common.h
@@ -25,4 +25,8 @@
2626
2727 extern void* (*memset_ptr)(void *dest, int c, size_t count);
2828 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 @@
1818
1919 EXTERN C itoachars:ptr byte
2020 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 @@
321321 int _fcloseall()
322322 {
323323 int i;
324 - int count;
 324+ int count = 0;
325325 if(!minilibc_files) return 0;
326326 for(i = 0; i < filecount; i++)
327327 {
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 @@
9393 <CustomBuild Include="memset_x86.asm">
9494 <FileType>Document</FileType>
9595 </CustomBuild>
 96+ <CustomBuild Include="memcpy_x86.asm">
 97+ <FileType>Document</FileType>
 98+ </CustomBuild>
9699 <None Include="ReadMe.txt" />
97100 <CustomBuild Include="_itoa_x86.asm">
98101 <FileType>Document</FileType>
@@ -112,6 +115,7 @@
113116 <ClCompile Include="exit.c" />
114117 <ClCompile Include="file.c" />
115118 <ClCompile Include="init.c" />
 119+ <ClCompile Include="memcpy.c" />
116120 <ClCompile Include="memory.c" />
117121 <ClCompile Include="memset.c" />
118122 </ItemGroup>
Index: minilibc/minilibc.vcxproj.filters
@@ -36,6 +36,9 @@
3737 <CustomBuild Include="string_x86.asm">
3838 <Filter>Source Files</Filter>
3939 </CustomBuild>
 40+ <CustomBuild Include="memcpy_x86.asm">
 41+ <Filter>Source Files</Filter>
 42+ </CustomBuild>
4043 </ItemGroup>
4144 <ItemGroup>
4245 <ClCompile Include="exit.c">
@@ -59,6 +62,9 @@
6063 <ClCompile Include="memory.c">
6164 <Filter>Source Files</Filter>
6265 </ClCompile>
 66+ <ClCompile Include="memcpy.c">
 67+ <Filter>Source Files</Filter>
 68+ </ClCompile>
6369 </ItemGroup>
6470 <ItemGroup>
6571 <ClInclude Include="common.h">