Changeset 3573 for trunk/kStuff/kHlp
- Timestamp:
- Aug 31, 2007, 6:09:23 AM (18 years ago)
- Location:
- trunk/kStuff/kHlp
- Files:
-
- 7 added
- 7 moved
-
Bare (added)
-
Bare/kHlpBare-gcc.c (moved) (moved from trunk/kStuff/kLdr/kLdrHlp-gcc.c ) (1 diff)
-
Bare/kHlpBareAssert.c (added)
-
Bare/kHlpBareEnv.c (added)
-
Bare/kHlpBareHeap.c (moved) (moved from trunk/kStuff/kLdr/kLdrHlpHeap.c ) (12 diffs)
-
Bare/kHlpBareMem.c (moved) (moved from trunk/kStuff/kLdr/kLdrHlpMem.c ) (17 diffs)
-
Bare/kHlpBarePath.c (moved) (moved from trunk/kStuff/kLdr/kLdrHlpPath.c ) (5 diffs)
-
Bare/kHlpBareProcess.c (added)
-
Bare/kHlpBareSem.c (moved) (moved from trunk/kStuff/kLdr/kLdrHlpSem.c ) (9 diffs)
-
Bare/kHlpBareStr.c (moved) (moved from trunk/kStuff/kLdr/kLdrHlpStr.c ) (7 diffs)
-
Bare/kHlpBareThread.c (added)
-
Generic (added)
-
Generic/kHlpInt2Ascii.c (added)
-
Makefile.kmk (moved) (moved from trunk/kStuff/kHlp/CRT/Makefile.kmk ) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/kStuff/kHlp/Bare/kHlpBare-gcc.c
r3570 r3573 26 26 27 27 #include <k/kLdr.h> 28 #include "k LdrHlp.h"28 #include "kHlp.h" 29 29 30 30 -
trunk/kStuff/kHlp/Bare/kHlpBareHeap.c
r3570 r3573 1 1 /* $Id$ */ 2 2 /** @file 3 * 4 * kLdr - The Dynamic Loader, Helper Functions, Heap.5 * 6 * Copyright (c) 2006 knut st. osmundsen <bird-kbuild-src@anduin.net> 7 * 8 * 9 * This file is part of k Ldr.10 * 11 * k Ldr is free software; you can redistribute it and/or modify12 * it under the terms of the GNU General Public License as published by13 * the Free Software Foundation; either version 2 of the License, or14 * (at your option) any later version.15 * 16 * k Ldris distributed in the hope that it will be useful,3 * kHlpBare - Heap. 4 */ 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 8 * 9 * This file is part of kStuff. 10 * 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. 15 * 16 * kStuff is distributed in the hope that it will be useful, 17 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNUGeneral Public License for more details.20 * 21 * You should have received a copy of the GNU General Public License22 * along with kLdr; if not, write to the Free Software23 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 20 * 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 */ … … 30 30 * Header Files * 31 31 *******************************************************************************/ 32 #ifdef __OS2__ 32 #include <k/kHlpAlloc.h> 33 34 #if K_OS == K_OS_OS2 33 35 # define INCL_BASE 34 36 # define INCL_ERRORS 35 37 # include <os2.h> 36 #elif defined(__WIN__)38 #elif K_OS == K_OS_WINDOWS 37 39 # include <Windows.h> 38 40 #else 39 41 # error "port me" 40 42 #endif 41 42 #include <k/kLdr.h>43 #include "kLdrHlp.h"44 45 43 46 44 … … 87 85 * Assert that a heap free block is valid. */ 88 86 #ifdef KLDRHEAP_STRICT 89 # define KLDRHEAP_ASSERT(expr) k ldrHlpAssert(expr)87 # define KLDRHEAP_ASSERT(expr) kHlpAssert(expr) 90 88 91 89 # define KLDRHEAP_ASSERT_BLOCK(pHeap, pBlock) \ … … 193 191 * @returns 0 on success, non-zero OS specific status code on failure. 194 192 */ 195 int kldrHlpHeapInit(void)193 KHLP_DECL(int) kHlpHeapInit(void) 196 194 { 197 195 return kLdrHeapInit(&g_Heap); … … 202 200 * Terminates the kLdr heap. 203 201 */ 204 void kldrHlpHeapTerm(void)202 KHLP_DECL(void) kHlpHeapTerm(void) 205 203 { 206 204 kLdrHeapDelete(&g_Heap); … … 214 212 * @param cb The requested heap block size. 215 213 */ 216 void *kldrHlpAlloc(KSIZE cb)214 KHLP_DECL(void *) kHlpAlloc(KSIZE cb) 217 215 { 218 216 return kLdrHeapAlloc(&g_Heap, cb); … … 226 224 * @param cb The requested heap block size. 227 225 */ 228 void *kldrHlpAllocZ(KSIZE cb)226 KHLP_DECL(void *) kHlpAllocZ(KSIZE cb) 229 227 { 230 228 void *pv = kLdrHeapAlloc(&g_Heap, cb); 231 229 if (pv) 232 k LdrHlpMemSet(pv, 0, cb);230 kHlpMemSet(pv, 0, cb); 233 231 return pv; 234 232 } … … 238 236 * Frees memory allocated off the kLdr heap. 239 237 * 240 * @param pv Pointer to the heap block returned by k ldrHlpAlloc().241 */ 242 void kldrHlpFree(void *pv)238 * @param pv Pointer to the heap block returned by kHlpAlloc(). 239 */ 240 KHLP_DECL(void) kHlpFree(void *pv) 243 241 { 244 242 kLdrHeapFree(&g_Heap, pv); … … 252 250 * @param cb The amount of memory. 253 251 */ 254 void kldrHlpHeapDonate(void *pv, KSIZE cb)252 KHLP_DECL(void) kHlpHeapDonate(void *pv, KSIZE cb) 255 253 { 256 254 kLdrHeapDonate(&g_Heap, pv, cb); … … 652 650 static int kLdrHeapSegAlloc(PKLDRHEAPSEG pSeg, KSIZE cbMin) 653 651 { 654 #if def __OS2__652 #if K_OS == K_OS_OS2 655 653 APIRET rc; 656 654 … … 667 665 } 668 666 669 #elif defined(__WIN__)667 #elif K_OS == K_OS_WINDOWS 670 668 pSeg->cb = (cbMin + 0xffff) & ~(KSIZE)0xffff; 671 669 pSeg->pvBase = VirtualAlloc(NULL, pSeg->cb, MEM_COMMIT, PAGE_READWRITE); … … 691 689 static void kLdrHeapSegFree(PKLDRHEAPSEG pSeg) 692 690 { 693 #if def __OS2__691 #if K_OS == K_OS_OS2 694 692 APIRET rc = DosFreeMem(pSeg->pvBase); 695 693 KLDRHEAP_ASSERT(!rc); (void)rc; 696 694 697 #elif defined(__WIN__)695 #elif K_OS == K_OS_WINDOWS 698 696 BOOL fRc = VirtualFree(pSeg->pvBase, 0 /*pSeg->cb*/, MEM_RELEASE); 699 697 KLDRHEAP_ASSERT(fRc); (void)fRc; -
trunk/kStuff/kHlp/Bare/kHlpBareMem.c
r3571 r3573 1 1 /* $Id$ */ 2 2 /** @file 3 * 4 * kLdr - The Dynamic Loader, Memory Helper Functions.5 * 6 * Copyright (c) 2006-2007 knut st. osmundsen <bird-kbuild-src@anduin.net> 7 * 8 * 9 * This file is part of k Ldr.10 * 11 * k Ldr is free software; you can redistribute it and/or modify12 * it under the terms of the GNU General Public License as published by13 * the Free Software Foundation; either version 2 of the License, or14 * (at your option) any later version.15 * 16 * k Ldris distributed in the hope that it will be useful,3 * kHlp - Generic Page Memory Functions. 4 */ 5 6 /* 7 * Copyright (c) 2007 knut st. osmundsen <bird-src-spam@anduin.net> 8 * 9 * This file is part of kStuff. 10 * 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. 15 * 16 * kStuff is distributed in the hope that it will be useful, 17 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 24 * 25 */ 26 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 20 * 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 * 25 */ 27 26 28 27 /******************************************************************************* 29 28 * Header Files * 30 29 *******************************************************************************/ 31 #ifdef __OS2__ 30 #include <k/kHlpAlloc.h> 31 32 #if K_OS == K_OS_OS2 32 33 # define INCL_BASE 33 34 # define INCL_ERRORS 34 35 # include <os2.h> 35 #elif defined(__WIN__)36 #elif K_OS == K_OS_WINDOWS 36 37 # include <Windows.h> 37 38 #else 38 39 # error "port me" 39 40 #endif 40 41 #include <k/kLdr.h>42 #include "kLdrHlp.h"43 41 44 42 … … 46 44 * Global Variables * 47 45 *******************************************************************************/ 48 #if def __OS2__46 #if K_OS == K_OS_OS2 49 47 /** The base of the stub object. 50 48 * The OS/2 exe stub consists of a single data object. When allocating memory … … 54 52 static KSIZE g_cbStub = 0; 55 53 56 #elif defined(__WIN__)54 #elif K_OS == K_OS_WINDOWS 57 55 /** The system info. */ 58 56 static SYSTEM_INFO g_SystemInfo; … … 63 61 64 62 65 #if def __OS2__66 static ULONG k ldrHlpPageProtToNative(KPROT enmProt)63 #if K_OS == K_OS_OS2 64 static ULONG kHlpPageProtToNative(KPROT enmProt) 67 65 { 68 66 switch (enmProt) … … 75 73 case KPROT_EXECUTE_READWRITE: return PAG_COMMIT | PAG_EXECUTE | PAG_READ | PAG_WRITE; 76 74 default: 77 k ldrHlpAssert(0);75 kHlpAssert(0); 78 76 return ~0U; 79 77 } 80 78 } 81 #elif defined(__WIN__)82 static DWORD k ldrHlpPageProtToNative(KPROT enmProt)79 #elif K_OS == K_OS_WINDOWS 80 static DWORD kHlpPageProtToNative(KPROT enmProt) 83 81 { 84 82 switch (enmProt) … … 91 89 case KPROT_EXECUTE_READWRITE: return PAGE_EXECUTE_READWRITE; 92 90 default: 93 k ldrHlpAssert(0);91 kHlpAssert(0); 94 92 return ~0U; 95 93 } … … 107 105 * @param enmProt The new protection. Copy-on-write is invalid. 108 106 */ 109 int kldrHlpPageAlloc(void **ppv, KSIZE cb, KPROT enmProt, unsignedfFixed)110 { 111 #if def __OS2__107 KHLP_DECL(int) kHlpPageAlloc(void **ppv, KSIZE cb, KPROT enmProt, KBOOL fFixed) 108 { 109 #if K_OS == K_OS_OS2 112 110 APIRET rc; 113 ULONG fFlags = k ldrHlpPageProtToNative(enmProt);;111 ULONG fFlags = kHlpPageProtToNative(enmProt);; 114 112 115 113 if (!fFixed) … … 128 126 if (!rc) 129 127 return 0; 130 k ldrHlpAssert(0);131 return rc; 132 133 #elif defined(__WIN__)128 kHlpAssert(0); 129 return rc; 130 131 #elif K_OS == K_OS_WINDOWS 134 132 /* (We don't have to care about the stub here, because the stub will be unmapped before we get here.) */ 135 133 int rc; 136 DWORD fProt = k ldrHlpPageProtToNative(enmProt);134 DWORD fProt = kHlpPageProtToNative(enmProt); 137 135 138 136 if (!g_SystemInfo.dwPageSize) … … 143 141 return 0; 144 142 rc = GetLastError(); 145 k ldrHlpAssert(0);143 kHlpAssert(0); 146 144 return rc; 147 145 … … 155 153 * Change the protection of one or more pages in an allocation. 156 154 * 157 * (This will of course only work correctly on memory allocated by k ldrHlpPageAlloc().)155 * (This will of course only work correctly on memory allocated by kHlpPageAlloc().) 158 156 * 159 157 * @returns 0 on success, non-zero OS status code on failure. … … 162 160 * @param enmProt The new protection. Copy-on-write is invalid. 163 161 */ 164 int kldrHlpPageProtect(void *pv, KSIZE cb, KPROT enmProt)165 { 166 #if def __OS2__162 KHLP_DECL(int) kHlpPageProtect(void *pv, KSIZE cb, KPROT enmProt) 163 { 164 #if K_OS == K_OS_OS2 167 165 APIRET rc; 168 ULONG fFlags = k ldrHlpPageProtToNative(enmProt);;166 ULONG fFlags = kHlpPageProtToNative(enmProt);; 169 167 170 168 /* … … 188 186 } 189 187 } 190 k ldrHlpAssert(!rc);191 return rc; 192 193 #elif defined(__WIN__)188 kHlpAssert(!rc); 189 return rc; 190 191 #elif K_OS == K_OS_WINDOWS 194 192 DWORD fOldProt = 0; 195 DWORD fProt = k ldrHlpPageProtToNative(enmProt);193 DWORD fProt = kHlpPageProtToNative(enmProt); 196 194 int rc = 0; 197 195 … … 199 197 { 200 198 rc = GetLastError(); 201 k ldrHlpAssert(0);199 kHlpAssert(0); 202 200 } 203 201 return rc; … … 209 207 210 208 /** 211 * Free memory allocated by k ldrHlpPageAlloc().209 * Free memory allocated by kHlpPageAlloc(). 212 210 * 213 211 * @returns 0 on success, non-zero OS status code on failure. 214 * @param pv The address returned by k ldrHlpPageAlloc().215 * @param cb The byte count requested from k ldrHlpPageAlloc().216 */ 217 int kldrHlpPageFree(void *pv, KSIZE cb)218 { 219 #if def __OS2__212 * @param pv The address returned by kHlpPageAlloc(). 213 * @param cb The byte count requested from kHlpPageAlloc(). 214 */ 215 KHLP_DECL(int) skHlpPageFree(void *pv, KSIZE cb) 216 { 217 #if K_OS == K_OS_OS2 220 218 APIRET rc; 221 219 … … 242 240 if (rc) 243 241 { 244 k ldrHlpAssert(!rc);242 kHlpAssert(!rc); 245 243 return rc; 246 244 } … … 259 257 */ 260 258 rc = DosFreeMem(pv); 261 k ldrHlpAssert(!rc);262 return rc; 263 264 #elif defined(__WIN__)259 kHlpAssert(!rc); 260 return rc; 261 262 #elif K_OS == K_OS_WINDOWS 265 263 /* 266 264 * Free the object. … … 270 268 { 271 269 rc = GetLastError(); 272 k ldrHlpAssert(0);273 } 274 return rc; 275 276 #else 277 # error "port me" 278 #endif 279 } 280 270 kHlpAssert(0); 271 } 272 return rc; 273 274 #else 275 # error "port me" 276 #endif 277 } 278 -
trunk/kStuff/kHlp/Bare/kHlpBarePath.c
r3570 r3573 29 29 * Header Files * 30 30 *******************************************************************************/ 31 #include <k/k Ldr.h>32 #include "kLdrHlp.h"31 #include <k/kHlpPath.h> 32 #include <k/kHlpString.h> 33 33 34 34 … … 40 40 * @param pszFilename The filename to parse. 41 41 */ 42 char *k ldrHlpGetFilename(const char *pszFilename)42 char *kHlpGetFilename(const char *pszFilename) 43 43 { 44 44 const char *pszLast = NULL; … … 75 75 * @param pszFilename The filename to parse. 76 76 */ 77 char *k ldrHlpGetSuff(const char *pszFilename)77 char *kHlpGetSuff(const char *pszFilename) 78 78 { 79 79 const char *pszDot = NULL; 80 pszFilename = k ldrHlpGetFilename(pszFilename);80 pszFilename = kHlpGetFilename(pszFilename); 81 81 for (;;) 82 82 { … … 103 103 * @param pszFilename The filename to parse. 104 104 */ 105 char *k ldrHlpGetExt(const char *pszFilename)105 char *kHlpGetExt(const char *pszFilename) 106 106 { 107 char *psz = k ldrHlpGetSuff(pszFilename);107 char *psz = kHlpGetSuff(pszFilename); 108 108 return *psz ? psz + 1 : psz; 109 109 } … … 118 118 * @param pszFilename The filename to parse. 119 119 */ 120 int k ldrHlpIsFilenameOnly(const char *pszFilename)120 int kHlpIsFilenameOnly(const char *pszFilename) 121 121 { 122 122 for (;;) -
trunk/kStuff/kHlp/Bare/kHlpBareSem.c
r3570 r3573 29 29 * Header Files * 30 30 *******************************************************************************/ 31 #ifdef __OS2__ 31 #include <k/kDefs.h> 32 #include <k/kHlpSem.h> 33 34 #if K_OS == K_OS_OS2 32 35 # define INCL_BASE 33 36 # define INCL_ERRORS 34 37 # include <os2.h> 35 #elif defined(__WIN__)38 #elif K_OS == K_OS_WINDOWS 36 39 # include <Windows.h> 37 40 #else … … 39 42 #endif 40 43 41 #include <k/kLdr.h>42 #include "kLdrHlp.h"43 44 44 45 … … 46 47 * Global Variables * 47 48 *******************************************************************************/ 48 #if def __OS2__49 #if K_OS == K_OS_OS2 49 50 /** The loader sempahore. */ 50 51 static HMTX g_hmtx; 51 52 52 #elif defined(__WIN__)53 #elif K_OS == K_OS_WINDOWS 53 54 /** The loader sempahore. */ 54 55 static CRITICAL_SECTION g_CritSect; … … 63 64 * @returns 0 on success, non-zero OS status code on failure. 64 65 */ 65 int k ldrHlpSemInit(void)66 int kHlpSemInit(void) 66 67 { 67 #if def __OS2__68 #if K_OS == K_OS_OS2 68 69 APIRET rc; 69 70 g_hmtx = NULLHANDLE; … … 72 73 return rc; 73 74 74 #elif defined(__WIN__)75 #elif K_OS == K_OS_WINDOWS 75 76 InitializeCriticalSection(&g_CritSect); 76 77 … … 85 86 * Terminates the loader semaphore. 86 87 */ 87 void k ldrHlpSemTerm(void)88 void kHlpSemTerm(void) 88 89 { 89 #if def __OS2__90 #if K_OS == K_OS_OS2 90 91 HMTX hmtx = g_hmtx; 91 92 g_hmtx = NULLHANDLE; 92 93 DosCloseMutexSem(hmtx); 93 94 94 #elif defined(__WIN__)95 #elif K_OS == K_OS_WINDOWS 95 96 DeleteCriticalSection(&g_CritSect); 96 97 … … 107 108 * @returns 0 on success, non-zero OS status code on failure. 108 109 */ 109 int k ldrHlpSemRequest(void)110 int kHlpSemRequest(void) 110 111 { 111 #if def __OS2__112 #if K_OS == K_OS_OS2 112 113 APIRET rc = DosRequestMutexSem(g_hmtx, 5000); 113 114 if (rc == ERROR_TIMEOUT || rc == ERROR_SEM_TIMEOUT || rc == ERROR_INTERRUPT) … … 125 126 return rc; 126 127 127 #elif defined(__WIN__)128 #elif K_OS == K_OS_WINDOWS 128 129 EnterCriticalSection(&g_CritSect); 129 130 return 0; … … 139 140 * The caller is responsible for making sure it's the semaphore owner! 140 141 */ 141 void k ldrHlpSemRelease(void)142 void kHlpSemRelease(void) 142 143 { 143 #if def __OS2__144 #if K_OS == K_OS_OS2 144 145 APIRET rc = DosReleaseMutexSem(g_hmtx); 145 k ldrHlpAssert(!rc); (void)rc;146 kHlpAssert(!rc); (void)rc; 146 147 147 #elif defined(__WIN__)148 #elif K_OS == K_OS_WINDOWS 148 149 LeaveCriticalSection(&g_CritSect); 149 150 -
trunk/kStuff/kHlp/Bare/kHlpBareStr.c
r3570 r3573 1 1 /* $Id$ */ 2 2 /** @file 3 * kHlpBare - String Manipulation. 4 */ 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 3 8 * 4 * kLdr - The Dynamic Loader, String Helper Functions.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 27 26 28 27 /******************************************************************************* 29 28 * Header Files * 30 29 *******************************************************************************/ 31 #include <k/kLdr.h> 32 #include "kLdrHlp.h" 30 #include <k/kHlpString.h> 33 31 34 32 35 /** 36 * Converts an signed integer to an ascii string. 37 * 38 * @returns psz. 39 * @param psz Pointer to the output buffer. 40 * @param cch The size of the output buffer. 41 * @param lVal The value. 42 * @param iBase The base to format it. (2,8,10 or 16) 43 */ 44 char *kldrHlpInt2Ascii(char *psz, KSIZE cch, long lVal, unsigned iBase) 45 { 46 static const char s_szDigits[] = "0123456789abcdefghijklmnopqrstuvwxyz"; 47 char *pszRet = psz; 48 49 if (cch >= (lVal < 0 ? 3U : 2U) && psz) 50 { 51 /* prefix */ 52 if (lVal < 0) 53 { 54 *psz++ = '-'; 55 cch--; 56 lVal = -lVal; 57 } 58 59 /* the digits */ 60 do 61 { 62 *psz++ = s_szDigits[lVal % iBase]; 63 cch--; 64 lVal /= iBase; 65 } while (lVal && cch > 1); 66 67 /* overflow indicator */ 68 if (lVal) 69 psz[-1] = '+'; 70 } 71 else if (!pszRet) 72 return pszRet; 73 else if (cch < 1 || !pszRet) 74 return pszRet; 75 else 76 *psz++ = '+'; 77 *psz = '\0'; 78 79 return pszRet; 80 } 81 82 83 KSIZE kLdrHlpStrNLen(const char *psz, KSIZE cchMax) 33 KSIZE kHlpStrNLen(const char *psz, KSIZE cchMax) 84 34 { 85 35 const char * const pszStart = psz; … … 90 40 91 41 92 int k LdrHlpMemIComp(const void *pv1, const void *pv2, KSIZE cb)42 int kHlpMemIComp(const void *pv1, const void *pv2, KSIZE cb) 93 43 { 94 44 const KU8 *pb1 = (const KU8 *)pv1; … … 110 60 111 61 112 int k LdrHlpStrIComp(const char *pv1, const char *pv2)62 int kHlpStrIComp(const char *pv1, const char *pv2) 113 63 { 114 64 const KU8 *pb1 = (const KU8 *)pv1; … … 132 82 133 83 134 #ifdef k LdrHlpStrChr_needed135 char *k LdrHlpStrChr(const char *psz, int ch)84 #ifdef kHlpStrChr_needed 85 char *kHlpStrChr(const char *psz, int ch) 136 86 { 137 87 while (*psz) … … 146 96 147 97 148 #ifdef k LdrHlpMemChr_needed149 void *k LdrHlpMemChr(const void *pv, int ch, KSIZE cb)98 #ifdef kHlpMemChr_needed 99 void *kHlpMemChr(const void *pv, int ch, KSIZE cb) 150 100 { 151 101 const KU8 *pb = (const KU8 *)pv; … … 162 112 163 113 164 #ifdef k LdrHlpMemMove_needed165 void *k LdrHlpMemMove(void *pv1, const void *pv2, KSIZE cb)114 #ifdef kHlpMemMove_needed 115 void *kHlpMemMove(void *pv1, const void *pv2, KSIZE cb) 166 116 { 167 117 KU8 *pbDst = (KU8 *)pv1; … … 177 127 178 128 179 #ifdef k LdrHlpStrNComp_needed180 int k LdrHlpStrNComp(const char *psz1, const char *psz2, KSIZE cch)129 #ifdef kHlpStrNComp_needed 130 int kHlpStrNComp(const char *psz1, const char *psz2, KSIZE cch) 181 131 { 182 132 while (cch-- > 0) -
trunk/kStuff/kHlp/Makefile.kmk
r3572 r3573 1 1 # $Id$ 2 2 ## @file 3 # kHlp CRT - The CRT BasedHelper API.3 # kHlp - The Helper API. 4 4 # 5 5 … … 25 25 # 26 26 27 DEPTH = ../.. /..27 DEPTH = ../.. 28 28 include $(PATH_KBUILD)/header.kmk 29 30 # 31 # kHlpBaseStatic 32 # 33 LIBRARIES += kHlpBaseStatic 34 kHlpBaseStatic_TEMPLATE = kStuffLIB 35 kHlpBaseStatic_SOURCES = \ 36 Generic/kHlpInt2Ascii.c \ 37 \ 38 Bare/kHlpBareAssert.c \ 39 Bare/kHlpBareHeap.c \ 40 Bare/kHlpBareEnv.c \ 41 Bare/kHlpBareMem.c \ 42 Bare/kHlpBarePath.c \ 43 Bare/kHlpBareProcess.c \ 44 Bare/kHlpBareSem.c \ 45 Bare/kHlpBareStr.c \ 46 Bare/kHlpBareThread.c \ 29 47 30 48 # … … 34 52 kHlpCRTStatic_TEMPLATE = kStuffLIB 35 53 kHlpCRTStatic_SOURCES = \ 36 kHlpCRTAlloc.cpp \ 37 kHlpCRTString.cpp \ 54 \ 55 CRT/kHlpCRTAlloc.cpp \ 56 CRT/kHlpCRTString.cpp \ 38 57 39 58 # Generate the rules
Note:
See TracChangeset
for help on using the changeset viewer.
