author | mikek |
Wed, 30 Jun 2010 18:53:50 +0100 | |
branch | GCC_SURGE |
changeset 188 | 38a7352e23d3 |
parent 0 | a41df078684a |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// e32\common\mem.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include "common.h" |
|
19 |
||
20 |
//This is used in heap.cpp and it is defined here, as a requirement for patchdata |
|
21 |
EXPORT_D extern const TInt KHeapMinCellSize = 0; |
|
22 |
EXPORT_D extern const TInt KHeapShrinkHysRatio = RHeap::EShrinkRatioDflt; |
|
23 |
//NOTE - if these values are changed then the WINS test case value must be updated |
|
24 |
||
25 |
#ifndef __MEM_MACHINE_CODED__ |
|
26 |
extern "C" { |
|
27 |
||
28 |
// See header file e32cmn.h for the in-source documentation. |
|
29 |
EXPORT_C TAny* memcpy(TAny* aTrg, const TAny* aSrc, unsigned int aLength) |
|
30 |
{ |
|
31 |
return memmove(aTrg, aSrc, aLength); |
|
32 |
} |
|
33 |
||
34 |
||
35 |
||
36 |
// See header file e32cmn.h for the in-source documentation. |
|
37 |
EXPORT_C TAny* memmove(TAny* aTrg, const TAny* aSrc, unsigned int aLength) |
|
38 |
{ |
|
39 |
if (aLength==0) |
|
40 |
return((TUint8*)aTrg); |
|
41 |
TInt aLen32=0; |
|
42 |
TUint32* pT32=(TUint32*)aTrg; |
|
43 |
const TUint32* pS32=(TUint32 *)aSrc; |
|
44 |
if (((TInt)pT32&3)==0 && ((TInt)pS32&3)==0) |
|
45 |
aLen32=aLength>>2; |
|
46 |
TInt aLen8=aLength-(aLen32<<2); |
|
47 |
TUint32* pE32=pT32+aLen32; |
|
48 |
TUint8* pT; |
|
49 |
TUint8* pE; |
|
50 |
TUint8* pS; |
|
51 |
if (aTrg<aSrc) |
|
52 |
{ |
|
53 |
pS32=(TUint32*)aSrc; |
|
54 |
while (pT32<pE32) |
|
55 |
*pT32++=(*pS32++); |
|
56 |
pT=(TUint8*)pT32; |
|
57 |
pS=(TUint8*)pS32; |
|
58 |
pE=(TUint8*)aTrg+aLength; |
|
59 |
while (pT<pE) |
|
60 |
*pT++=(*pS++); |
|
61 |
} |
|
62 |
else if (aTrg>aSrc) |
|
63 |
{ |
|
64 |
pT=(TUint8*)(pT32+aLen32); |
|
65 |
pE=pT+aLen8; |
|
66 |
pS=(TUint8*)aSrc+aLength; |
|
67 |
while (pE>pT) |
|
68 |
*--pE=(*--pS); |
|
69 |
pS32=(TUint32*)pS; |
|
70 |
while (pE32>pT32) |
|
71 |
*--pE32=(*--pS32); |
|
72 |
} |
|
73 |
return aTrg; |
|
74 |
} |
|
75 |
||
76 |
||
77 |
||
78 |
// See header file e32cmn.h for the in-source documentation. |
|
79 |
EXPORT_C TAny* memclr(TAny* aTrg, unsigned int aLength) |
|
80 |
{ |
|
81 |
return memset(aTrg, 0, aLength); |
|
82 |
} |
|
83 |
||
84 |
||
85 |
||
86 |
// See header file e32cmn.h for the in-source documentation. |
|
87 |
EXPORT_C TAny* memset(TAny* aTrg, TInt aValue, unsigned int aLength) |
|
88 |
{ |
|
89 |
TInt aLen32=0; |
|
90 |
TUint32 *pM32=(TUint32 *)aTrg; |
|
91 |
if (((TInt)aTrg&3)==0) |
|
92 |
{ |
|
93 |
aLen32=aLength>>2; |
|
94 |
TUint32 *pE32=pM32+aLen32; |
|
95 |
TUint c = aValue & 0xff; |
|
96 |
TUint32 fillChar=c+(c<<8)+(c<<16)+(c<<24); |
|
97 |
while (pM32<pE32) |
|
98 |
*pM32++=fillChar; |
|
99 |
} |
|
100 |
TInt aLen8=aLength-(aLen32<<2); |
|
101 |
TUint8 *pM=(TUint8 *)pM32; |
|
102 |
TUint8 *pE=pM+aLen8; |
|
103 |
while (pM<pE) |
|
104 |
*pM++=TUint8(aValue); |
|
105 |
return aTrg; |
|
106 |
} |
|
107 |
||
108 |
} // extern "C" |
|
109 |
||
110 |
extern "C" { |
|
111 |
||
112 |
||
113 |
||
114 |
// See header file e32cmn.h for the in-source documentation. |
|
115 |
EXPORT_C TAny* wordmove(TAny* aTrg, const TAny* aSrc, unsigned int aLength) |
|
116 |
{ |
|
117 |
__ASSERT_DEBUG((aLength&3)==0,Panic(EWordMoveLengthNotMultipleOf4)); |
|
118 |
__ASSERT_DEBUG((((TUint)aSrc)&3)==0,Panic(EWordMoveSourceNotAligned)); |
|
119 |
__ASSERT_DEBUG((((TUint)aTrg)&3)==0,Panic(EWordMoveTargetNotAligned)); |
|
120 |
if (aLength==0) |
|
121 |
return((TUint8*)aTrg); |
|
122 |
TInt len=aLength>>2; |
|
123 |
TUint32* pT=(TUint32*)aTrg; |
|
124 |
const TUint32* pS=(const TUint32*)aSrc; |
|
125 |
const TUint32* pE=pS+len; |
|
126 |
if (pT<pS) |
|
127 |
{ |
|
128 |
while (pS<pE) |
|
129 |
*pT++=(*pS++); |
|
130 |
} |
|
131 |
else if (pT>pS) |
|
132 |
{ |
|
133 |
pT+=len; |
|
134 |
while (pE>pS) |
|
135 |
*--pT=(*--pE); |
|
136 |
} |
|
137 |
return aTrg; |
|
138 |
} |
|
139 |
||
140 |
||
141 |
||
142 |
||
143 |
// See header file e32cmn.h for the in-source documentation. |
|
144 |
EXPORT_C TInt memcompare(const TUint8* aLeft, TInt aLeftL, const TUint8* aRight, TInt aRightL) |
|
145 |
{ |
|
146 |
||
147 |
__ASSERT_DEBUG(aLeftL>=0,Panic(EMemLeftNegative)); |
|
148 |
__ASSERT_DEBUG(aRightL>=0,Panic(EMemRightNegative)); |
|
149 |
const TUint8 *pE=aLeft+Min(aLeftL,aRightL); |
|
150 |
while (aLeft<pE) |
|
151 |
{ |
|
152 |
TInt d=(*aLeft++)-(*aRight++); |
|
153 |
if (d!=0) |
|
154 |
return(d); |
|
155 |
} |
|
156 |
return(aLeftL-aRightL); |
|
157 |
} |
|
158 |
||
159 |
} // extern "C" |
|
160 |
||
161 |
||
162 |
||
188
38a7352e23d3
1) Fix for Bug 3117 - [GCCE] Missing symbols in linkage of template_ekern.exe
mikek
parents:
0
diff
changeset
|
163 |
//IMK: Should this __GCC32__ should be __GCCE__ now? |
0 | 164 |
#if defined(__GCC32__) && !defined(__KERNEL_MODE__) |
165 |
/** |
|
166 |
Compares a block of data at one specified location with a block of data at |
|
167 |
another specified location. |
|
168 |
||
169 |
The comparison proceeds on a byte for byte basis, the result of the comparison |
|
170 |
is based on the difference of the first bytes to disagree. |
|
171 |
||
172 |
The data at the two locations are equal if they have the same length and content. |
|
173 |
Where the lengths are different and the shorter section of data is the same |
|
174 |
as the first part of the longer section of data, the shorter is considered |
|
175 |
to be less than the longer. |
|
176 |
||
177 |
@param aLeft A pointer to the first (or left) block of 8 bit data |
|
178 |
to be compared. |
|
179 |
@param aLeftL The length of the first (or left) block of data to be compared, |
|
180 |
i.e. the number of bytes. |
|
181 |
@param aRight A pointer to the second (or right) block of 8 bit data to be |
|
182 |
compared. |
|
183 |
@param aRightL The length of the second (or right) block of data to be compared |
|
184 |
i.e. the number of bytes. |
|
185 |
||
186 |
@return Positive, if the first (or left) block of data is greater than the |
|
187 |
second (or right) block of data. |
|
188 |
Negative, if the first (or left) block of data is less than the |
|
189 |
second (or right) block of data. |
|
190 |
Zero, if both the first (or left) and second (or right) blocks of data |
|
191 |
have the same length and the same content. |
|
192 |
*/ |
|
193 |
EXPORT_C TInt Mem::Compare(const TUint8* aLeft, TInt aLeftL, const TUint8* aRight, TInt aRightL) |
|
194 |
{ |
|
195 |
memcompare(aLeft, aLeftL, aRight, aRightL); |
|
196 |
} |
|
197 |
#endif |
|
198 |
||
199 |
#else // __MEM_MACHINE_CODED__ |
|
200 |
||
201 |
#if defined(_DEBUG) && defined(__CPU_ARM) |
|
202 |
||
203 |
GLDEF_C void PanicEWordMoveLengthNotMultipleOf4() |
|
204 |
{ |
|
205 |
Panic(EWordMoveLengthNotMultipleOf4); |
|
206 |
} |
|
207 |
||
208 |
GLDEF_C void PanicEWordMoveSourceNotAligned() |
|
209 |
{ |
|
210 |
Panic(EWordMoveSourceNotAligned); |
|
211 |
} |
|
212 |
||
213 |
GLDEF_C void PanicEWordMoveTargetNotAligned() |
|
214 |
{ |
|
215 |
Panic(EWordMoveTargetNotAligned); |
|
216 |
} |
|
217 |
||
218 |
#endif |
|
219 |
||
220 |
#endif // __MEM_MACHINE_CODED__ |
|
221 |
||
222 |
#ifndef __KERNEL_MODE__ |
|
223 |
// |
|
224 |
// Dummy class for Binary Compatibility purposes |
|
225 |
// |
|
226 |
class Mem1 |
|
227 |
{ |
|
228 |
public: |
|
229 |
IMPORT_C static TUint8* Copy(TAny* aTrg,const TAny* aSrc,TInt aLength); |
|
230 |
IMPORT_C static TUint8* Move(TAny* aTrg,const TAny* aSrc,TInt aLength); |
|
231 |
IMPORT_C static void Fill(TAny* aTrg,TInt aLength,TChar aChar); |
|
232 |
}; |
|
233 |
EXPORT_C void Mem1::Fill(TAny* aTrg,TInt aLength,TChar aChar) |
|
234 |
{ Mem::Fill(aTrg,aLength,aChar); } |
|
235 |
EXPORT_C TUint8* Mem1::Copy(TAny* aTrg, const TAny* aSrc, TInt aLength) |
|
236 |
{ return Mem::Copy(aTrg, aSrc, aLength); } |
|
237 |
EXPORT_C TUint8* Mem1::Move(TAny* aTrg, const TAny* aSrc, TInt aLength) |
|
238 |
{ return Mem::Move(aTrg, aSrc, aLength); } |
|
239 |
||
240 |
#endif // __KERNEL_MODE__ |