Changeset 3584
- Timestamp:
- Sep 3, 2007, 12:46:37 AM (18 years ago)
- Location:
- trunk/kStuff/kLdr
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kStuff/kLdr/Makefile.kmk
r3581 r3584 28 28 SUB_DEPTH = .. 29 29 include $(PATH_KBUILD)/subheader.kmk 30 31 #todo: include $(PATH_SUB_CURRENT)/testcase/Makefile.kmk 30 32 31 33 # -
trunk/kStuff/kLdr/testcase/Makefile.kmk
r2967 r3584 26 26 27 27 # generate rules. 28 DEPTH = ../.. 29 include $(PATH_KBUILD)/header.kmk 30 31 DEFAULT_PASSES := $(filter-out PACKING, $(DEFAULT_PASSES)) 28 DEPTH ?= ../../.. 29 SUB_DEPTH = ../.. 30 include $(PATH_KBUILD)/subheader.kmk 32 31 33 32 … … 78 77 endif 79 78 endif 80 TEMPLATE_TST_INCS = . ..79 TEMPLATE_TST_INCS := $(PATH_SUB_CURRENT) $(PATH_SUB_ROOT)/include 81 80 82 81 … … 129 128 endif 130 129 endif 131 TEMPLATE_TSTBARE_INCS = . ..130 TEMPLATE_TSTBARE_INCS := $(PATH_SUB_CURRENT) $(PATH_SUB_ROOT)/include 132 131 133 132 TEMPLATE_TSTBAREPROG = Bare bone testcase program template … … 274 273 else 275 274 DLLS += tst-3 276 LIBRARIES.win = tst-3-imp277 LIBRARIES.os2 = tst-3-imp275 LIBRARIES.win += tst-3-imp 276 LIBRARIES.os2 += tst-3-imp 278 277 endif 279 278 … … 299 298 300 299 # generate rules. 301 include $(PATH_KBUILD)/ footer.kmk302 300 include $(PATH_KBUILD)/subfooter.kmk 301 -
trunk/kStuff/kLdr/testcase/tst-0-driver.c
r2965 r3584 29 29 * Header Files * 30 30 *******************************************************************************/ 31 #include <kLdr.h>32 31 #include "tst.h" 33 32 #include <stdarg.h> … … 76 75 char szBuf[512]; 77 76 char *psz; 78 size_tcch;77 KSIZE cch; 79 78 HKLDRMOD hMod; 80 79 int rc; … … 145 144 szBuf[cch + 2] = '\0'; 146 145 rc = kLdrDyldGetName(hMod2, szBuf, cch); 147 if (rc == K LDR_ERR_BUFFER_OVERFLOW)146 if (rc == KERR_BUFFER_OVERFLOW) 148 147 { 149 148 if (!szBuf[0]) … … 155 154 } 156 155 else 157 Failure("kLdrDyldGetName(\"tst-0-d\",,,) -> rc=%d (%#x) instead of K LDR_ERR_BUFFER_OVERFLOW\n", rc, rc);156 Failure("kLdrDyldGetName(\"tst-0-d\",,,) -> rc=%d (%#x) instead of KERR_BUFFER_OVERFLOW\n", rc, rc); 158 157 159 158 /* check that we can query the module by the returned name. */ … … 183 182 szBuf[cch + 2] = '\0'; 184 183 rc = kLdrDyldGetFilename(hMod2, szBuf, cch); 185 if (rc == K LDR_ERR_BUFFER_OVERFLOW)184 if (rc == KERR_BUFFER_OVERFLOW) 186 185 { 187 186 if (!szBuf[0]) … … 193 192 } 194 193 else 195 Failure("kLdrDyldGetFilename(\"tst-0-d\",,,) -> rc=%d (%#x) instead of K LDR_ERR_BUFFER_OVERFLOW\n", rc, rc);194 Failure("kLdrDyldGetFilename(\"tst-0-d\",,,) -> rc=%d (%#x) instead of KERR_BUFFER_OVERFLOW\n", rc, rc); 196 195 197 196 /* check that we can query the module by the returned filename. */ … … 252 251 if (!g_cErrors) 253 252 { 254 uintptr_tuValue;255 uint32_tfKind;253 KUPTR uValue; 254 KU32 fKind; 256 255 257 256 fKind = 0xffeeffee; 258 uValue = ~( uintptr_t)42;259 rc = kLdrDyldQuerySymbol(hMod, NIL_KLDRMOD_SYM_ORDINAL, MY_NAME("FuncA"), &uValue, &fKind);260 if (!rc) 261 { 262 if (uValue == ~( uintptr_t)42)257 uValue = ~(KUPTR)42; 258 rc = kLdrDyldQuerySymbol(hMod, NIL_KLDRMOD_SYM_ORDINAL, MY_NAME("FuncA"), NULL, &uValue, &fKind); 259 if (!rc) 260 { 261 if (uValue == ~(KUPTR)42) 263 262 Failure("kLdrDyldQuerySymbol(\"tst-0-a\",,\"FuncA\",): uValue wasn't set.\n"); 264 263 if (fKind == 0xffeeffee) … … 289 288 if (!rc) 290 289 { 291 uintptr_toffSegment;292 uint32_tiSegment;290 KUPTR offSegment; 291 KU32 iSegment; 293 292 294 293 if (hMod3 != hMod) … … 316 315 iSegment = 0x42424242; 317 316 offSegment = 0x87654321; 318 rc = kLdrDyldFindByAddress(~( uintptr_t)16, &hMod3, &iSegment, &offSegment);317 rc = kLdrDyldFindByAddress(~(KUPTR)16, &hMod3, &iSegment, &offSegment); 319 318 if (!rc) 320 319 Failure("negative kLdrDyldFindByAddress test returned successfully!\n"); 321 if (iSegment != ~( uint32_t)0)320 if (iSegment != ~(KU32)0) 322 321 Failure("negative kLdrDyldFindByAddress: bad iSegment=%#x\n", iSegment); 323 if (offSegment != ~( uintptr_t)0)322 if (offSegment != ~(KUPTR)0) 324 323 Failure("negative kLdrDyldFindByAddress: bad offSegment=%p\n", (void *)offSegment); 325 324 if (hMod3 != NIL_HKLDRMOD) … … 334 333 335 334 fKind = 0xffeeffee; 336 uValue = ~( uintptr_t)42;337 rc = kLdrDyldQuerySymbol(hMod2, NIL_KLDRMOD_SYM_ORDINAL, MY_NAME("FuncD"), &uValue, &fKind);338 if (!rc) 339 { 340 if (uValue == ~( uintptr_t)42)335 uValue = ~(KUPTR)42; 336 rc = kLdrDyldQuerySymbol(hMod2, NIL_KLDRMOD_SYM_ORDINAL, MY_NAME("FuncD"), NULL, &uValue, &fKind); 337 if (!rc) 338 { 339 if (uValue == ~(KUPTR)42) 341 340 Failure("kLdrDyldQuerySymbol(\"tst-0-d\",,\"FuncD\",): uValue wasn't set.\n"); 342 341 if (fKind == 0xffeeffee) … … 407 406 HKLDRMOD hModC; 408 407 int (*pfnFuncC)(void); 409 uintptr_tuValue;408 KUPTR uValue; 410 409 411 410 rc = kLdrDyldLoad("tst-0-a", NULL, NULL, KLDRDYLD_SEARCH_HOST, 0, &hModA, NULL, 0); … … 426 425 if (!rc) 427 426 { 428 rc = kLdrDyldQuerySymbol(hModA, NIL_KLDRMOD_SYM_ORDINAL, MY_NAME("FuncA"), &uValue, NULL);427 rc = kLdrDyldQuerySymbol(hModA, NIL_KLDRMOD_SYM_ORDINAL, MY_NAME("FuncA"), NULL, &uValue, NULL); 429 428 if (!rc) 430 429 pfnFuncA = (int (*)(void))uValue; … … 434 433 if (!rc) 435 434 { 436 rc = kLdrDyldQuerySymbol(hModB, NIL_KLDRMOD_SYM_ORDINAL, MY_NAME("FuncB"), &uValue, NULL);435 rc = kLdrDyldQuerySymbol(hModB, NIL_KLDRMOD_SYM_ORDINAL, MY_NAME("FuncB"), NULL, &uValue, NULL); 437 436 if (!rc) 438 437 pfnFuncB = (int (*)(void))uValue; … … 442 441 if (!rc) 443 442 { 444 rc = kLdrDyldQuerySymbol(hModC, NIL_KLDRMOD_SYM_ORDINAL, MY_NAME("FuncC"), &uValue, NULL);443 rc = kLdrDyldQuerySymbol(hModC, NIL_KLDRMOD_SYM_ORDINAL, MY_NAME("FuncC"), NULL, &uValue, NULL); 445 444 if (!rc) 446 445 pfnFuncC = (int (*)(void))uValue; -
trunk/kStuff/kLdr/testcase/tst-3-driver.c
r3579 r3584 29 29 * Header Files * 30 30 *******************************************************************************/ 31 #include <kLdr.h>32 31 #include "tst.h" 32 #include <k/kErr.h> 33 33 34 #include <stdarg.h> 34 35 #include <stdio.h> … … 86 87 * Callback for resolving the Tst3Ext import. 87 88 */ 88 static int GetImport(PKLDRMOD pMod, uint32_t iImport, uint32_t iSymbol, const char *pchSymbol, size_tcchSymbol,89 const char *pszVersion, PKLDRADDR puValue, uint32_t*pfKind, void *pvUser)89 static int GetImport(PKLDRMOD pMod, KU32 iImport, KU32 iSymbol, const char *pchSymbol, KSIZE cchSymbol, 90 const char *pszVersion, PKLDRADDR puValue, KU32 *pfKind, void *pvUser) 90 91 { 91 92 if (*pfKind != KLDRSYMKIND_REQ_FLAT) … … 95 96 || !strncmp(pchSymbol, "_Tst3Ext", strlen("_Tst3Ext"))) 96 97 { 97 *puValue = ( uintptr_t)&Tst3Ext;98 *puValue = (KUPTR)&Tst3Ext; 98 99 *pfKind = KLDRSYMKIND_CODE | (sizeof(pfKind) == 4 ? KLDRSYMKIND_32BIT : KLDRSYMKIND_64BIT); 99 100 return 0; … … 124 125 /* get bits. */ 125 126 cbImage = kLdrModSize(pMod); 126 pvBits = malloc(( size_t)cbImage + 0xfff);127 pvBits = malloc((KSIZE)cbImage + 0xfff); 127 128 if (pvBits) 128 129 { 129 void *pvBits2 = (void *)( (( uintptr_t)pvBits + 0xfff) & ~(uintptr_t)0xfff );130 131 KLDRADDR BaseAddress = ( uintptr_t)pvBits2;130 void *pvBits2 = (void *)( ((KUPTR)pvBits + 0xfff) & ~(KUPTR)0xfff ); 131 132 KLDRADDR BaseAddress = (KUPTR)pvBits2; 132 133 rc = kLdrModGetBits(pMod, pvBits2, BaseAddress, GetImport, NULL); 133 134 if (!rc) … … 143 144 if (!rc) 144 145 { 145 int (*pfnEntryPoint)(int) = (int (*)(int)) (( uintptr_t)EntryPoint);146 int (*pfnEntryPoint)(int) = (int (*)(int)) ((KUPTR)EntryPoint); 146 147 rc = pfnEntryPoint(42); 147 148 if (rc == 42) -
trunk/kStuff/kLdr/testcase/tst.h
r2965 r3584 1 1 /* $Id$ */ 2 2 /** @file 3 * kLdr testcase header. 4 */ 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 3 8 * 4 * kLdr testcase.9 * This file is part of kStuff. 5 10 * 6 * Copyright (c) 2006 knut st. osmundsen <bird-kbuild-src@anduin.net> 11 * kStuff is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 7 15 * 16 * kStuff is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 8 20 * 9 * This file is part of kLdr. 10 * 11 * kLdr is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * kLdr is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with kLdr; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with kStuff; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 24 * 25 25 */ 26 26 27 #ifndef ___tst_h___ 28 #define ___tst_h___ 27 29 28 #i fndef __tst_h__29 # define __tst_h__30 #include <k/kLdr.h> 31 #include <k/kHlp.h> 30 32 31 #include "../kLdr.h" 32 #include "../kLdrHlp.h" 33 34 35 #if defined(__OS2__) || defined(__WIN__) || defined(__NT__) 33 #if K_OS == K_OS_OS2 \ 34 || K_OS == K_OS_WINDOWS 36 35 # define MY_EXPORT(type) __declspec(dllexport) type 37 36 /*# define MY_IMPORT(type) extern __declspec(dllimport) type*/ … … 42 41 #endif 43 42 44 #if defined(__OS2__) || defined(__DARWIN__) 43 #if K_OS == K_OS_OS2 \ 44 || K_OS == K_OS_DARWIN 45 45 # define MY_NAME(a) "_" a 46 46 #else -
trunk/kStuff/kLdr/testcase/tstDllMain.c
r2965 r3584 31 31 #include "tst.h" 32 32 33 #if def __OS2__33 #if K_OS == K_OS_OS2 34 34 # define INCL_BASE 35 35 # include <os2.h> 36 36 # include <string.h> 37 37 38 #elif defined(__WIN__)38 #elif K_OS == K_OS_WINDOWS 39 39 # include <windows.h> 40 40 # include <string.h> 41 41 42 #elif defined(__DARWIN__)42 #elif K_OS == K_OS_DARWIN 43 43 # include <unistd.h> 44 44 # include <string.h> … … 56 56 57 57 58 #if def __OS2__58 #if K_OS == K_OS_OS2 59 59 /** 60 60 * OS/2 DLL 'main' … … 84 84 } 85 85 86 #elif defined(__WIN__)86 #elif K_OS == K_OS_WINDOWS 87 87 88 88 /** … … 125 125 } 126 126 127 #elif defined(__DARWIN__)127 #elif K_OS == K_OS_DARWIN 128 128 /* later */ 129 129 … … 140 140 void tstWrite(const char *pszMsg) 141 141 { 142 #if defined(__OS2__) || defined(__WIN__)142 #if K_OS == K_OS_OS2 || K_OS == K_OS_WINDOWS 143 143 /* 144 144 * Line by line. … … 151 151 cbWritten = pszNl - pszMsg; 152 152 153 #if def __OS2__153 #if K_OS == K_OS_OS2 154 154 if (cbWritten) 155 155 DosWrite((HFILE)2, pszMsg, cbWritten, &cbWritten); 156 156 DosWrite((HFILE)2, "\r\n", 2, &cbWritten); 157 #else /* __WIN32__ */157 #else 158 158 if (cbWritten) 159 159 WriteFile((HANDLE)STD_ERROR_HANDLE, pszMsg, cbWritten, &cbWritten, NULL); … … 172 172 { 173 173 cbWritten = strlen(pszMsg); 174 #if def __OS2__174 #if K_OS == K_OS_OS2 175 175 DosWrite((HFILE)2, pszMsg, cbWritten, &cbWritten); 176 #else /* __WIN32__ */176 #else 177 177 WriteFile((HANDLE)STD_ERROR_HANDLE, pszMsg, cbWritten, &cbWritten, NULL); 178 178 #endif 179 179 } 180 180 181 #elif defined(__DARWIN__)181 #elif K_OS == K_OS_DARWIN 182 182 write(STDERR_FILENO, pszMsg, strlen(pszMsg)); 183 183 -
trunk/kStuff/kLdr/testcase/tstDllMainStub.c
r2965 r3584 31 31 #include "tst.h" 32 32 33 #if def __OS2__33 #if K_OS == K_OS_OS2 34 34 # define INCL_BASE 35 35 # include <os2.h> 36 36 37 #elif defined(__WIN__)37 #elif K_OS == K_OS_WINDOWS 38 38 # include <windows.h> 39 39 40 #elif defined(__DARWIN__)40 #elif K_OS == K_OS_DARWIN 41 41 /* later */ 42 42 … … 46 46 47 47 48 #if def __OS2__48 #if K_OS == K_OS_OS2 49 49 /** 50 50 * OS/2 DLL 'main' … … 55 55 } 56 56 57 #elif defined(__WIN__)57 #elif K_OS == K_OS_WINDOWS 58 58 59 59 /** … … 65 65 } 66 66 67 #elif defined(__DARWIN__)67 #elif K_OS == K_OS_DARWIN 68 68 /* later */ 69 69 -
trunk/kStuff/kLdr/testcase/tstExeMainStub.c
r2878 r3584 31 31 #include "tst.h" 32 32 33 #if def __OS2__33 #if K_OS == K_OS_OS2 34 34 # define INCL_BASE 35 35 # include <os2.h> 36 36 37 #elif defined(__WIN__)37 #elif K_OS == K_OS_WINDOWS 38 38 /* nothing */ 39 39 40 #elif defined(__NT__)40 #elif K_OS == K_OS_NT 41 41 # include <ddk/ntapi.h> /** @todo fix the nt port. */ 42 42 … … 49 49 50 50 51 #if def __OS2__51 #if K_OS == K_OS_OS2 52 52 /** 53 53 * OS/2 'main'. … … 60 60 } 61 61 62 #elif defined(__WIN__)62 #elif K_OS == K_OS_WINDOWS 63 63 /** 64 64 * Windows'main' … … 71 71 } 72 72 73 #elif defined(__NT__)73 #elif K_OS == K_OS_NT 74 74 /** 75 75 * Windows NT 'main'
Note:
See TracChangeset
for help on using the changeset viewer.