1 | /* $Id: kHlpString.h 3545 2007-08-25 17:15:18Z bird $ */
|
---|
2 | /** @file
|
---|
3 | * kHlpString - String And Memory Routines.
|
---|
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 modify
|
---|
12 | * it under the terms of the GNU Lesser General Public License as published
|
---|
13 | * by the Free Software Foundation; either version 2 of the License, or
|
---|
14 | * (at your option) any later version.
|
---|
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
|
---|
19 | * GNU Lesser General Public License for more details.
|
---|
20 | *
|
---|
21 | * You should have received a copy of the GNU Lesser General Public License
|
---|
22 | * along with kStuff; if not, write to the Free Software
|
---|
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
24 | *
|
---|
25 | */
|
---|
26 |
|
---|
27 | #ifndef ___k_kHlpString_h___
|
---|
28 | #define ___k_kHlpString_h___
|
---|
29 |
|
---|
30 | #ifdef __cplusplus
|
---|
31 | extern "C" {
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #ifdef __GNUC__
|
---|
35 | /** memchr */
|
---|
36 | # define kHlpMemChr(a,b,c) __builtin_memchr(a,b,c)
|
---|
37 | /** memcmp */
|
---|
38 | # define kHlpMemComp(a,b,c) __builtin_memcmp(a,b,c)
|
---|
39 | /** memcpy */
|
---|
40 | # define kHlpMemCopy(a,b,c) __builtin_memcpy(a,b,c)
|
---|
41 | /** memset */
|
---|
42 | # define kHlpMemSet(a,b,c) __builtin_memset(a,b,c)
|
---|
43 | /** strchr */
|
---|
44 | # define kHlpStrChr(a, b) __builtin_strchr(a, b)
|
---|
45 | /** strcmp */
|
---|
46 | # define kHlpStrComp(a, b) __builtin_strcmp(a, b)
|
---|
47 | /** strncmp */
|
---|
48 | # define kHlpStrNComp(a,b,c) __builtin_strncmp(a, b, c)
|
---|
49 | /** strlen */
|
---|
50 | # define kHlpStrLen(a) __builtin_strlen(a)
|
---|
51 |
|
---|
52 | #elif defined(_MSC_VER)
|
---|
53 | # pragma intrinsic(memcmp, memcpy, memset, strcmp, strlen)
|
---|
54 | /** memcmp */
|
---|
55 | # define kHlpMemComp(a,b,c) memcmp(a,b,c)
|
---|
56 | /** memcpy */
|
---|
57 | # define kHlpMemCopy(a,b,c) memcpy(a,b,c)
|
---|
58 | /** memset */
|
---|
59 | # define kHlpMemSet(a,b,c) memset(a,b,c)
|
---|
60 | /** strcmp */
|
---|
61 | # define kHlpStrComp(a, b) strcmp(a, b)
|
---|
62 | /** strlen */
|
---|
63 | # define kHlpStrLen(a) strlen(a)
|
---|
64 | #else
|
---|
65 | # error "Port Me"
|
---|
66 | #endif
|
---|
67 |
|
---|
68 | #ifdef __cplusplus
|
---|
69 | extern "C" {
|
---|
70 | #endif
|
---|
71 |
|
---|
72 | #ifndef kHlpMemChr
|
---|
73 | void *kHlpMemChr(const void *pv, int ch, KSIZE cb);
|
---|
74 | #endif
|
---|
75 | #ifndef kHlpMemComp
|
---|
76 | int kHlpMemComp(const void *pv1, const void *pv2, KSIZE cb);
|
---|
77 | #endif
|
---|
78 | #ifndef kHlpMemCopy
|
---|
79 | void *kHlpMemMopy(void *pv1, const void *pv2, KSIZE cb);
|
---|
80 | #endif
|
---|
81 | #ifndef kHlpMemMove
|
---|
82 | void *kHlpMemMove(void *pv1, const void *pv2, KSIZE cb);
|
---|
83 | #endif
|
---|
84 | #ifndef kHlpMemSet
|
---|
85 | void *kHlpMemSet(void *pv1, int ch, KSIZE cb);
|
---|
86 | #endif
|
---|
87 | int kHlpMemIComp(const void *pv1, const void *pv2, KSIZE cb);
|
---|
88 |
|
---|
89 | #ifndef kHlpStrChr
|
---|
90 | char *kHlpStrChr(const char *psz, int ch);
|
---|
91 | #endif
|
---|
92 | #ifndef kHlpStrComp
|
---|
93 | int kHlpStrComp(const char *psz1, const char *psz2);
|
---|
94 | #endif
|
---|
95 | #ifndef kHlpStrNComp
|
---|
96 | int kHlpStrNComp(const char *psz1, const char *psz2, KSIZE cch);
|
---|
97 | #endif
|
---|
98 | #ifndef kHlpStrLen
|
---|
99 | KSIZE kHlpStrLen(const char *psz1);
|
---|
100 | #endif
|
---|
101 | KSIZE kHlpStrNLen(const char *psz, KSIZE cchMax);
|
---|
102 | int kHlpStrIComp(const char *pv1, const char *pv2);
|
---|
103 |
|
---|
104 | #ifdef __cplusplus
|
---|
105 | }
|
---|
106 | #endif
|
---|
107 |
|
---|
108 | #endif
|
---|
109 |
|
---|