00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __ZByteSwap__
00026 #define __ZByteSwap__ 1
00027 #include "zconfig.h"
00028
00029 #include "ZDebug.h"
00030 #include "ZTypes.h"
00031
00032
00033
00034
00035
00036
00037 #if 0
00038
00039
00040
00041 int16 ZByteSwap_16(int16 iValue);
00042 int32 ZByteSwap_32(int32 iValue);
00043 int64 ZByteSwap_64(int64 iValue);
00044
00045 void ZByteSwap_16(volatile void* iValueAddress);
00046 void ZByteSwap_32(volatile void* iValueAddress);
00047 void ZByteSwap_64(volatile void* iValueAddress);
00048
00049 int16 ZByteSwap_Read16(const volatile void* iValueAddress);
00050 int32 ZByteSwap_Read32(const volatile void* iValueAddress);
00051 int64 ZByteSwap_Read64(const volatile void* iValueAddress);
00052
00053 void ZByteSwap_Write16(volatile void* iValueAddress, int16 iValue);
00054 void ZByteSwap_Write32(volatile void* iValueAddress, int32 iValue);
00055 void ZByteSwap_Write64(volatile void* iValueAddress, int64 iValue);
00056
00057
00058
00059
00060
00061
00062
00063
00064 int16 ZByteSwap_BigToLittle16(int16 iValue);
00065 int32 ZByteSwap_BigToLittle32(int32 iValue);
00066 int64 ZByteSwap_BigToLittle64(int64 iValue);
00067
00068 void ZByteSwap_BigToLittle16(int16* iValueAddress);
00069 void ZByteSwap_BigToLittle32(int32* iValueAddress);
00070 void ZByteSwap_BigToLittle64(int64* iValueAddress);
00071
00072
00073
00074 int16 ZByteSwap_LittleToBig16(int16 iValue);
00075 int32 ZByteSwap_LittleToBig32(int32 iValue);
00076 int64 ZByteSwap_LittleToBig64(int64 iValue);
00077
00078 void ZByteSwap_LittleToBig16(int16* iValueAddress);
00079 void ZByteSwap_LittleToBig32(int32* iValueAddress);
00080 void ZByteSwap_LittleToBig64(int64* iValueAddress);
00081
00082
00083
00084 int16 ZByteSwap_HostToBig16(int16 iValue);
00085 int32 ZByteSwap_HostToBig32(int32 iValue);
00086 int64 ZByteSwap_HostToBig64(int64 iValue);
00087
00088 void ZByteSwap_HostToBig16(int16* iValueAddress);
00089 void ZByteSwap_HostToBig32(int32* iValueAddress);
00090 void ZByteSwap_HostToBig64(int64* iValueAddress);
00091
00092
00093
00094 int16 ZByteSwap_HostToLittle16(int16 iValue);
00095 int32 ZByteSwap_HostToLittle32(int32 iValue);
00096 int64 ZByteSwap_HostToLittle64(int64 iValue);
00097
00098 void ZByteSwap_HostToLittle16(int16* iValueAddress);
00099 void ZByteSwap_HostToLittle32(int32* iValueAddress);
00100 void ZByteSwap_HostToLittle64(int64* iValueAddress);
00101
00102
00103
00104 int16 ZByteSwap_BigToHost16(int16 iValue);
00105 int32 ZByteSwap_BigToHost32(int32 iValue);
00106 int64 ZByteSwap_BigToHost64(int64 iValue);
00107
00108 void ZByteSwap_BigToHost16(int16* iValueAddress);
00109 void ZByteSwap_BigToHost32(int32* iValueAddress);
00110 void ZByteSwap_BigToHost64(int64* iValueAddress);
00111
00112
00113
00114 int16 ZByteSwap_LittleToHost16(int16 iValue);
00115 int32 ZByteSwap_LittleToHost32(int32 iValue);
00116 int64 ZByteSwap_LittleToHost64(int64 iValue);
00117
00118 void ZByteSwap_LittleToHost16(int16* iValueAddress);
00119 void ZByteSwap_LittleToHost32(int32* iValueAddress);
00120 void ZByteSwap_LittleToHost64(int64* iValueAddress);
00121
00122
00123
00124 int16 ZByteSwap_ReadBig16(const volatile void* iValueAddress);
00125 int32 ZByteSwap_ReadBig32(const volatile void* iValueAddress);
00126 int64 ZByteSwap_ReadBig64(const volatile void* iValueAddress);
00127
00128 int16 ZByteSwap_ReadLittle16(const volatile void* iValueAddress);
00129 int32 ZByteSwap_ReadLittle32(const volatile void* iValueAddress);
00130 int64 ZByteSwap_ReadLittle64(const volatile void* iValueAddress);
00131
00132
00133 void ZByteSwap_WriteBig16(volatile void* iValueAddress, int16 iValue);
00134 void ZByteSwap_WriteBig32(volatile void* iValueAddress, int32 iValue);
00135 void ZByteSwap_WriteBig64(volatile void* iValueAddress, int64 iValue);
00136
00137 void ZByteSwap_WriteLittle16(volatile void* iValueAddress, int16 iValue);
00138 void ZByteSwap_WriteLittle32(volatile void* iValueAddress, int32 iValue);
00139 void ZByteSwap_WriteLittle64(volatile void* iValueAddress, int64 iValue);
00140
00141 #endif // 0
00142
00143
00144 #if ZCONFIG(Processor, 68K)
00145 #pragma mark -
00146 #pragma mark * Processor is 68K
00147
00148 #define ZByteSwap_EndianBig 1
00149
00150 #if ZCONFIG(Compiler, CodeWarrior)
00151 asm inline int16 ZByteSwap_16(int16 : __D0)
00152 {
00153 rol.w #8, d0
00154 }
00155
00156 asm inline int32 ZByteSwap_32(int32 : __D0)
00157 {
00158 rol.w #8, d0
00159 swap d0
00160 rol.w #8, d0
00161 }
00162
00163
00164
00165 asm inline void ZByteSwap_16(volatile void* : __A0)
00166 {
00167 move.w (a0), d0
00168 rol.w #8, d0
00169 move.w d0, (a0)
00170 }
00171
00172 asm inline void ZByteSwap_32(volatile void* : __A0)
00173 {
00174 move.l (a0), d0
00175 rol.w #8, d0
00176 swap d0
00177 rol.w #8, d0
00178 move.l d0, (a0)
00179 }
00180
00181
00182
00183 asm inline int16 ZByteSwap_Read16(const volatile void* iValueAddress : __A0)
00184 {
00185 move.w (a0), d0
00186 rol.w #8, d0
00187 }
00188
00189 asm inline int32 ZByteSwap_Read32(const volatile void* iValueAddress)
00190 {
00191 move.l (a0), d0
00192 rol.w #8, d0
00193 swap d0
00194 rol.w #8, d0
00195 }
00196
00197
00198
00199 asm inline void ZByteSwap_Write16(volatile void* iValueAddress : __A0, int16 iValue : __D0)
00200 {
00201 rol.w #8, d0
00202 move.w d0, (a0)
00203 }
00204
00205 asm inline void ZByteSwap_Write32(volatile void* iValueAddress : __A0, int32 iValue : __D0)
00206 {
00207 rol.w #8, d0
00208 swap d0
00209 rol.w #8, d0
00210 move.l d0, (a0)
00211 }
00212 #endif
00213 #endif
00214
00215
00216 #pragma mark -
00217 #pragma mark * Processor is PPC
00218
00219 #if ZCONFIG(Processor, PPC)
00220
00221 #define ZByteSwap_EndianBig 1
00222
00223 #if ZCONFIG(Compiler, CodeWarrior)
00224
00225 inline int16 ZByteSwap_Read16(register const volatile void* iValueAddress)
00226 {
00227 register int16 result;
00228 asm
00229 {
00230 lhbrx result, r0, iValueAddress
00231 }
00232 return result;
00233 }
00234
00235 inline int32 ZByteSwap_Read32(register const volatile void* iValueAddress)
00236 {
00237 register int32 result;
00238 asm
00239 {
00240 lwbrx result, r0, iValueAddress
00241 }
00242 return result;
00243 }
00244
00245 inline void ZByteSwap_Write16(register volatile void* iValueAddress, register int16 iValue)
00246 {
00247 asm
00248 {
00249 sthbrx iValue, r0, iValueAddress
00250 }
00251 }
00252
00253 inline void ZByteSwap_Write32(register volatile void* iValueAddress, register int32 iValue)
00254 {
00255 asm
00256 {
00257 stwbrx iValue, r0, iValueAddress
00258 }
00259 }
00260
00261 #elif ZCONFIG(Compiler, GCC)
00262
00263 inline int16 ZByteSwap_Read16(const volatile void* iValueAddress)
00264 {
00265 int16 result;
00266 __asm__
00267 (
00268 "lhbrx %0, 0, %1\n"
00269 : "=r" (result)
00270 : "r" (iValueAddress)
00271 : "memory"
00272 );
00273 return result;
00274 }
00275
00276 inline int32 ZByteSwap_Read32(const volatile void* iValueAddress)
00277 {
00278 int32 result;
00279 __asm__
00280 (
00281 "lwbrx %0, 0, %1\n"
00282 : "=r" (result)
00283 : "r" (iValueAddress)
00284 : "memory"
00285 );
00286 return result;
00287 }
00288
00289 inline void ZByteSwap_Write16(volatile void* iValueAddress, int16 iValue)
00290 {
00291 __asm__
00292 (
00293 "sthbrx %0, 0, %1\n"
00294 :
00295 : "r" (iValue), "r" (iValueAddress)
00296 : "memory"
00297 );
00298 }
00299
00300 inline void ZByteSwap_Write32(volatile void* iValueAddress, int32 iValue)
00301 {
00302 __asm__
00303 (
00304 "stwbrx %0, 0, %1\n"
00305 :
00306 : "r" (iValue), "r" (iValueAddress)
00307 : "memory"
00308 );
00309 }
00310
00311 #else // ZCONFIG(Compiler)
00312
00313
00314
00315 inline int16 ZByteSwap_Read16(const volatile void* iValueAddress)
00316 {
00317 uint16 theValue = *static_cast<const volatile uint16*>(iValueAddress);
00318 return (theValue >> 8) | (theValue << 8);
00319 }
00320
00321 inline int32 ZByteSwap_Read32(const volatile void* iValueAddress)
00322 {
00323 uint32 theValue = *static_cast<const volatile uint32*>(iValueAddress);
00324 return (theValue >> 24)
00325 | ((theValue >> 8) & 0xFF00)
00326 | ((theValue << 8) & 0xFF0000)
00327 | (theValue << 24);
00328 }
00329
00330 inline void ZByteSwap_Write16(volatile void* iValueAddress, int16 iValue)
00331 {
00332 uint16 theValue = iValue;
00333 *static_cast<volatile uint16*>(iValueAddress) = (theValue >> 8) | (theValue << 8);
00334 }
00335
00336 inline void ZByteSwap_Write32(volatile void* iValueAddress, int32 iValue)
00337 {
00338 uint32 theValue = iValue;
00339 *static_cast<volatile uint32*>(iValueAddress) =
00340 (theValue >> 24)
00341 | ((theValue >> 8) & 0xFF00)
00342 | ((theValue << 8) & 0xFF0000)
00343 | (theValue << 24);
00344 }
00345
00346 #endif // ZCONFIG(Compiler)
00347
00348
00349
00350 inline int16 ZByteSwap_16(int16 iValue)
00351 { return ZByteSwap_Read16(&iValue); }
00352
00353 inline int32 ZByteSwap_32(int32 iValue)
00354 { return ZByteSwap_Read32(&iValue); }
00355
00356
00357 inline void ZByteSwap_16(volatile void* iValueAddress)
00358 { *static_cast<volatile int16*>(iValueAddress) = ZByteSwap_Read16(iValueAddress); }
00359
00360 inline void ZByteSwap_32(volatile void* iValueAddress)
00361 { *static_cast<volatile int32*>(iValueAddress) = ZByteSwap_Read32(iValueAddress); }
00362
00363 inline int64 ZByteSwap_64(int64 iValue)
00364 {
00365 union
00366 {
00367 uint64 fInt64;
00368 uint32 fInt32[2];
00369 } u;
00370
00371 u.fInt32[1] = ZByteSwap_Read32(&iValue);
00372 u.fInt32[0] = ZByteSwap_Read32(reinterpret_cast<uint32*>(&iValue) + 1);
00373 return u.fInt64;
00374 }
00375
00376 inline void ZByteSwap_64(volatile void* iValueAddress)
00377 {
00378 union u_t
00379 {
00380 uint64 fInt64;
00381 uint32 fInt32[2];
00382 };
00383
00384 volatile u_t* theU = static_cast<volatile u_t*>(iValueAddress);
00385 int32 temp = ZByteSwap_Read32(&theU->fInt32[1]);
00386 theU->fInt32[1] = ZByteSwap_Read32(&theU->fInt32[0]);
00387 theU->fInt32[0] = temp;
00388 }
00389
00390 inline int64 ZByteSwap_Read64(const volatile void* iValueAddress)
00391 {
00392 union
00393 {
00394 uint64 fInt64;
00395 uint32 fInt32[2];
00396 } u;
00397
00398 const volatile uint32* source = static_cast<const volatile uint32*>(iValueAddress);
00399 u.fInt32[1] = ZByteSwap_Read32(&source[0]);
00400 u.fInt32[0] = ZByteSwap_Read32(&source[1]);
00401 return u.fInt64;
00402 }
00403
00404 inline void ZByteSwap_Write64(volatile void* iValueAddress, int64 iValue)
00405 { *static_cast<volatile int64*>(iValueAddress) = ZByteSwap_64(iValue); }
00406
00407 #endif // ZCONFIG(Processor, PPC)
00408
00409
00410 #pragma mark -
00411 #pragma mark * Processor is x86
00412
00413 #if ZCONFIG(Processor, x86)
00414
00415 #define ZByteSwap_EndianBig 0
00416
00417
00418 #if ZCONFIG(Compiler, CodeWarrior)
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428 inline int16 ZByteSwap_16(int16 iValue)
00429 {
00430 asm
00431 {
00432 mov ax, iValue
00433 xchg ah, al
00434 mov iValue, ax
00435 }
00436 return iValue;
00437 }
00438
00439 inline int32 ZByteSwap_32(int32 iValue)
00440 {
00441 asm
00442 {
00443 mov eax, iValue
00444 bswap eax
00445 mov iValue, eax
00446 }
00447 return iValue;
00448 }
00449
00450
00451
00452 inline void ZByteSwap_16(volatile void* iValueAddress)
00453 {
00454 asm
00455 {
00456 mov edx, iValueAddress
00457 mov ax, [edx]
00458 xchg ah, al
00459 mov [edx], ax
00460 }
00461 }
00462
00463 inline void ZByteSwap_32(volatile void* iValueAddress)
00464 {
00465 asm
00466 {
00467 mov edx, iValueAddress
00468 mov eax, [edx]
00469 bswap eax
00470 mov [edx], eax
00471 }
00472 }
00473
00474
00475
00476 inline int16 ZByteSwap_Read16(const volatile void* iValueAddress)
00477 {
00478 int16 result;
00479 asm
00480 {
00481 mov edx, iValueAddress
00482 mov ax, [edx]
00483 xchg ah, al
00484 mov result, ax
00485 }
00486 return result;
00487 }
00488
00489 inline int32 ZByteSwap_Read32(const volatile void* iValueAddress)
00490 {
00491 int32 result;
00492 asm
00493 {
00494 mov edx, iValueAddress
00495 mov eax, [edx]
00496 bswap eax
00497 mov result, eax
00498 }
00499 return result;
00500 }
00501
00502
00503
00504 inline void ZByteSwap_Write16(volatile void* iValueAddress, int16 iValue)
00505 {
00506 asm
00507 {
00508 mov ax, iValue
00509 xchg ah, al
00510 mov edx, iValueAddress
00511 mov [edx], ax
00512 }
00513 }
00514
00515 inline void ZByteSwap_Write32(volatile void* iValueAddress, int32 iValue)
00516 {
00517 asm
00518 {
00519 mov eax, iValue
00520 bswap eax
00521 mov edx, iValueAddress
00522 mov [edx], eax
00523 }
00524 }
00525
00526 #else // ZCONFIG(Compiler, CodeWarrior)
00527
00528 #if ZCONFIG(Compiler, GCC)
00529
00530 inline int16 ZByteSwap_16(int16 iValue)
00531 {
00532 __asm__ ("xchgb %b0, %h0" : "+q" (iValue));
00533 return iValue;
00534 }
00535
00536 inline int32 ZByteSwap_32(int32 iValue)
00537 {
00538 #if defined(__i486__) || defined(__i586__) || defined(__i686__)
00539 __asm__ ("bswap %0" : "+r" (iValue));
00540 #else
00541 __asm__
00542 (
00543 "xchgb %b0, %h0\n"
00544 "rorl $16, %0\n"
00545 "xchgb %b0, %h0"
00546 : "+q" (iValue)
00547 );
00548 #endif
00549 return iValue;
00550 }
00551
00552 #elif ZCONFIG(Compiler, MSVC)
00553
00554 inline int16 ZByteSwap_16(int16 iValue)
00555 {
00556 __asm
00557 {
00558 mov ax, iValue
00559 xchg ah, al
00560 mov iValue, ax
00561 }
00562 return iValue;
00563 }
00564
00565 inline int32 ZByteSwap_32(int32 iValue)
00566 {
00567 __asm
00568 {
00569 mov eax, iValue
00570 bswap eax
00571 mov iValue, eax
00572 }
00573 return iValue;
00574 }
00575
00576 #else // ZCONFIG(Compiler)
00577
00578
00579
00580 inline int16 ZByteSwap_16(int16 iValue)
00581 {
00582 uint16 theValue = iValue;
00583 return (theValue >> 8) | (theValue << 8);
00584 }
00585
00586 inline int32 ZByteSwap_32(int32 iValue)
00587 {
00588 uint32 theValue = iValue;
00589 return
00590 (theValue >> 24)
00591 | ((theValue >> 8) & 0xFF00)
00592 | ((theValue << 8) & 0xFF0000)
00593 | (theValue << 24);
00594 }
00595
00596 #endif // ZCONFIG(Compiler)
00597
00598 inline int16 ZByteSwap_Read16(const volatile void* iValueAddress)
00599 { return ZByteSwap_16(*static_cast<const volatile int16*>(iValueAddress)); }
00600
00601 inline int32 ZByteSwap_Read32(const volatile void* iValueAddress)
00602 { return ZByteSwap_32(*static_cast<const volatile int32*>(iValueAddress)); }
00603
00604 inline void ZByteSwap_Write16(volatile void* iValueAddress, int16 iValue)
00605 { *static_cast<volatile int16*>(iValueAddress) = ZByteSwap_16(iValue); }
00606
00607 inline void ZByteSwap_Write32(volatile void* iValueAddress, int32 iValue)
00608 { *static_cast<volatile int32*>(iValueAddress) = ZByteSwap_32(iValue); }
00609
00610 inline void ZByteSwap_16(volatile void* iValueAddress)
00611 { *static_cast<volatile int16*>(iValueAddress) = ZByteSwap_Read16(iValueAddress); }
00612
00613 inline void ZByteSwap_32(volatile void* iValueAddress)
00614 { *static_cast<volatile int32*>(iValueAddress) = ZByteSwap_Read32(iValueAddress); }
00615
00616 #endif // ZCONFIG(Compiler, CodeWarrior)
00617
00618 inline int64 ZByteSwap_64(int64 iValue)
00619 {
00620 union
00621 {
00622 uint64 fInt64;
00623 uint32 fInt32[2];
00624 } u;
00625
00626 u.fInt32[1] = ZByteSwap_32(iValue & 0xffffffff);
00627 u.fInt32[0] = ZByteSwap_32(iValue >> 32);
00628 return u.fInt64;
00629 }
00630
00631 inline void ZByteSwap_64(volatile void* iValueAddress)
00632 {
00633 union u_t
00634 {
00635 uint64 fInt64;
00636 uint32 fInt32[2];
00637 };
00638
00639 volatile u_t* theU = static_cast<volatile u_t*>(iValueAddress);
00640 int32 temp = theU->fInt32[1];
00641 theU->fInt32[1] = ZByteSwap_32(theU->fInt32[0]);
00642 theU->fInt32[0] = ZByteSwap_32(temp);
00643 }
00644
00645 inline int64 ZByteSwap_Read64(const volatile void* iValueAddress)
00646 {
00647 union
00648 {
00649 uint64 fInt64;
00650 uint32 fInt32[2];
00651 } u;
00652
00653 const volatile uint32* source = static_cast<const volatile uint32*>(iValueAddress);
00654 u.fInt32[1] = source[0];
00655 u.fInt32[0] = source[1];
00656 u.fInt32[1] = ZByteSwap_32(u.fInt32[1]);
00657 u.fInt32[0] = ZByteSwap_32(u.fInt32[0]);
00658 return u.fInt64;
00659 }
00660
00661 inline void ZByteSwap_Write64(volatile void* iValueAddress, int64 iValue)
00662 { *static_cast<volatile int64*>(iValueAddress) = ZByteSwap_64(iValue); }
00663
00664 #endif // ZCONFIG(Processor, x86)
00665
00666
00667 #pragma mark -
00668 #pragma mark * The Real Calls
00669
00670 #if ZByteSwap_EndianBig
00671
00672
00673 ZAssertCompile(ZCONFIG(Endian, Big));
00674
00675 inline int16 ZByteSwap_BigToLittle16(int16 iValue) { return ZByteSwap_16(iValue); }
00676 inline void ZByteSwap_BigToLittle16(int16* iValueAddress) { ZByteSwap_16(iValueAddress); }
00677 inline void ZByteSwap_BigToLittle16(uint16* iValueAddress) { ZByteSwap_16(iValueAddress); }
00678
00679 inline int32 ZByteSwap_BigToLittle32(int32 iValue) { return ZByteSwap_32(iValue); }
00680 inline void ZByteSwap_BigToLittle32(int32* iValueAddress) { ZByteSwap_32(iValueAddress); }
00681 inline void ZByteSwap_BigToLittle32(uint32* iValueAddress) { ZByteSwap_32(iValueAddress); }
00682
00683 inline int64 ZByteSwap_BigToLittle64(int64 iValue) { return ZByteSwap_64(iValue); }
00684 inline void ZByteSwap_BigToLittle64(int64* iValueAddress) { ZByteSwap_64(iValueAddress); }
00685 inline void ZByteSwap_BigToLittle64(uint64* iValueAddress) { ZByteSwap_64(iValueAddress); }
00686
00687
00688
00689 inline int16 ZByteSwap_LittleToBig16(int16 iValue) { return ZByteSwap_16(iValue); }
00690 inline void ZByteSwap_LittleToBig16(int16* iValueAddress) { ZByteSwap_16(iValueAddress); }
00691 inline void ZByteSwap_LittleToBig16(uint16* iValueAddress) { ZByteSwap_16(iValueAddress); }
00692
00693 inline int32 ZByteSwap_LittleToBig32(int32 iValue) { return ZByteSwap_32(iValue); }
00694 inline void ZByteSwap_LittleToBig32(int32* iValueAddress) { ZByteSwap_32(iValueAddress); }
00695 inline void ZByteSwap_LittleToBig32(uint32* iValueAddress) { ZByteSwap_32(iValueAddress); }
00696
00697 inline int64 ZByteSwap_LittleToBig64(int64 iValue) { return ZByteSwap_64(iValue); }
00698 inline void ZByteSwap_LittleToBig64(int64* iValueAddress) { ZByteSwap_64(iValueAddress); }
00699 inline void ZByteSwap_LittleToBig64(uint64* iValueAddress) { ZByteSwap_64(iValueAddress); }
00700
00701
00702
00703 inline int16 ZByteSwap_HostToBig16(int16 iValue) { return iValue; }
00704 inline void ZByteSwap_HostToBig16(int16* iValueAddress) {}
00705 inline void ZByteSwap_HostToBig16(uint16* iValueAddress) {}
00706
00707 inline int32 ZByteSwap_HostToBig32(int32 iValue) { return iValue; }
00708 inline void ZByteSwap_HostToBig32(int32* iValueAddress) {}
00709 inline void ZByteSwap_HostToBig32(uint32* iValueAddress) {}
00710
00711 inline int64 ZByteSwap_HostToBig64(int64 iValue) { return iValue; }
00712 inline void ZByteSwap_HostToBig64(int64* iValueAddress) {}
00713 inline void ZByteSwap_HostToBig64(uint64* iValueAddress) {}
00714
00715
00716
00717 inline int16 ZByteSwap_HostToLittle16(int16 iValue) { return ZByteSwap_16(iValue); }
00718 inline void ZByteSwap_HostToLittle16(int16* iValueAddress) { ZByteSwap_16(iValueAddress); }
00719 inline void ZByteSwap_HostToLittle16(uint16* iValueAddress) { ZByteSwap_16(iValueAddress); }
00720
00721 inline int32 ZByteSwap_HostToLittle32(int32 iValue) { return ZByteSwap_32(iValue); }
00722 inline void ZByteSwap_HostToLittle32(int32* iValueAddress) { ZByteSwap_32(iValueAddress); }
00723 inline void ZByteSwap_HostToLittle32(uint32* iValueAddress) { ZByteSwap_32(iValueAddress); }
00724
00725 inline int64 ZByteSwap_HostToLittle64(int64 iValue) { return ZByteSwap_64(iValue); }
00726 inline void ZByteSwap_HostToLittle64(int64* iValueAddress) { ZByteSwap_64(iValueAddress); }
00727 inline void ZByteSwap_HostToLittle64(uint64* iValueAddress) { ZByteSwap_64(iValueAddress); }
00728
00729
00730
00731 inline int16 ZByteSwap_BigToHost16(int16 iValue) { return iValue; }
00732 inline void ZByteSwap_BigToHost16(int16* iValueAddress) {}
00733 inline void ZByteSwap_BigToHost16(uint16* iValueAddress) {}
00734
00735 inline int32 ZByteSwap_BigToHost32(int32 iValue) { return iValue; }
00736 inline void ZByteSwap_BigToHost32(int32* iValueAddress) {}
00737 inline void ZByteSwap_BigToHost32(uint32* iValueAddress) {}
00738
00739 inline int64 ZByteSwap_BigToHost64(int64 iValue) { return iValue; }
00740 inline void ZByteSwap_BigToHost64(int64* iValueAddress) {}
00741 inline void ZByteSwap_BigToHost64(uint64* iValueAddress) {}
00742
00743
00744
00745 inline int16 ZByteSwap_LittleToHost16(int16 iValue) { return ZByteSwap_16(iValue); }
00746 inline void ZByteSwap_LittleToHost16(int16* iValueAddress) { ZByteSwap_16(iValueAddress); }
00747 inline void ZByteSwap_LittleToHost16(uint16* iValueAddress) { ZByteSwap_16(iValueAddress); }
00748
00749 inline int32 ZByteSwap_LittleToHost32(int32 iValue) { return ZByteSwap_32(iValue); }
00750 inline void ZByteSwap_LittleToHost32(int32* iValueAddress) { ZByteSwap_32(iValueAddress); }
00751 inline void ZByteSwap_LittleToHost32(uint32* iValueAddress) { ZByteSwap_32(iValueAddress); }
00752
00753 inline int64 ZByteSwap_LittleToHost64(int64 iValue) { return ZByteSwap_64(iValue); }
00754 inline void ZByteSwap_LittleToHost64(int64* iValueAddress) { ZByteSwap_64(iValueAddress); }
00755 inline void ZByteSwap_LittleToHost64(uint64* iValueAddress) { ZByteSwap_64(iValueAddress); }
00756
00757
00758
00759 inline int16 ZByteSwap_ReadBig16(const volatile void* iValueAddress)
00760 { return *static_cast<const volatile int16*>(iValueAddress); }
00761 inline int32 ZByteSwap_ReadBig32(const volatile void* iValueAddress)
00762 { return *static_cast<const volatile int32*>(iValueAddress); }
00763 inline int64 ZByteSwap_ReadBig64(const volatile void* iValueAddress)
00764 { return *static_cast<const volatile int64*>(iValueAddress); }
00765
00766 inline int16 ZByteSwap_ReadLittle16(const volatile void* iValueAddress)
00767 { return ZByteSwap_Read16(iValueAddress); }
00768 inline int32 ZByteSwap_ReadLittle32(const volatile void* iValueAddress)
00769 { return ZByteSwap_Read32(iValueAddress); }
00770 inline int64 ZByteSwap_ReadLittle64(const volatile void* iValueAddress)
00771 { return ZByteSwap_Read64(iValueAddress); }
00772
00773
00774
00775 inline void ZByteSwap_WriteBig16(volatile void* iValueAddress, int16 iValue)
00776 { *static_cast<volatile int16*>(iValueAddress) = iValue; }
00777 inline void ZByteSwap_WriteBig32(volatile void* iValueAddress, int32 iValue)
00778 { *static_cast<volatile int32*>(iValueAddress) = iValue; }
00779 inline void ZByteSwap_WriteBig64(volatile void* iValueAddress, int64 iValue)
00780 { *static_cast<volatile int64*>(iValueAddress) = iValue; }
00781
00782 inline void ZByteSwap_WriteLittle16(volatile void* iValueAddress, int16 iValue)
00783 { ZByteSwap_Write16(iValueAddress, iValue); }
00784 inline void ZByteSwap_WriteLittle32(volatile void* iValueAddress, int32 iValue)
00785 { ZByteSwap_Write32(iValueAddress, iValue); }
00786 inline void ZByteSwap_WriteLittle64(volatile void* iValueAddress, int64 iValue)
00787 { ZByteSwap_Write64(iValueAddress, iValue); }
00788
00789
00790 #else // ZByteSwap_EndianBig
00791
00792
00793 ZAssertCompile(ZCONFIG(Endian, Little));
00794
00795 inline int16 ZByteSwap_BigToLittle16(int16 iValue) { return ZByteSwap_16(iValue); }
00796 inline void ZByteSwap_BigToLittle16(int16* iValueAddress) { ZByteSwap_16(iValueAddress); }
00797 inline void ZByteSwap_BigToLittle16(uint16* iValueAddress) { ZByteSwap_16(iValueAddress); }
00798
00799 inline int32 ZByteSwap_BigToLittle32(int32 iValue) { return ZByteSwap_32(iValue); }
00800 inline void ZByteSwap_BigToLittle32(int32* iValueAddress) { ZByteSwap_32(iValueAddress); }
00801 inline void ZByteSwap_BigToLittle32(uint32* iValueAddress) { ZByteSwap_32(iValueAddress); }
00802
00803 inline int64 ZByteSwap_BigToLittle64(int64 iValue) { return ZByteSwap_64(iValue); }
00804 inline void ZByteSwap_BigToLittle64(int64* iValueAddress) { ZByteSwap_64(iValueAddress); }
00805 inline void ZByteSwap_BigToLittle64(uint64* iValueAddress) { ZByteSwap_64(iValueAddress); }
00806
00807
00808
00809 inline int16 ZByteSwap_LittleToBig16(int16 iValue) { return ZByteSwap_16(iValue); }
00810 inline void ZByteSwap_LittleToBig16(int16* iValueAddress) { ZByteSwap_16(iValueAddress); }
00811 inline void ZByteSwap_LittleToBig16(uint16* iValueAddress) { ZByteSwap_16(iValueAddress); }
00812
00813 inline int32 ZByteSwap_LittleToBig32(int32 iValue) { return ZByteSwap_32(iValue); }
00814 inline void ZByteSwap_LittleToBig32(int32* iValueAddress) { ZByteSwap_32(iValueAddress); }
00815 inline void ZByteSwap_LittleToBig32(uint32* iValueAddress) { ZByteSwap_32(iValueAddress); }
00816
00817 inline int64 ZByteSwap_LittleToBig64(int64 iValue) { return ZByteSwap_64(iValue); }
00818 inline void ZByteSwap_LittleToBig64(int64* iValueAddress) { ZByteSwap_64(iValueAddress); }
00819 inline void ZByteSwap_LittleToBig64(uint64* iValueAddress) { ZByteSwap_64(iValueAddress); }
00820
00821
00822
00823 inline int16 ZByteSwap_HostToBig16(int16 iValue) { return ZByteSwap_16(iValue); }
00824 inline void ZByteSwap_HostToBig16(int16* iValueAddress) { ZByteSwap_16(iValueAddress); }
00825 inline void ZByteSwap_HostToBig16(uint16* iValueAddress) { ZByteSwap_16(iValueAddress); }
00826
00827 inline int32 ZByteSwap_HostToBig32(int32 iValue) { return ZByteSwap_32(iValue); }
00828 inline void ZByteSwap_HostToBig32(int32* iValueAddress) { ZByteSwap_32(iValueAddress); }
00829 inline void ZByteSwap_HostToBig32(uint32* iValueAddress) { ZByteSwap_32(iValueAddress); }
00830
00831 inline int64 ZByteSwap_HostToBig64(int64 iValue) { return ZByteSwap_64(iValue); }
00832 inline void ZByteSwap_HostToBig64(int64* iValueAddress) { ZByteSwap_64(iValueAddress); }
00833 inline void ZByteSwap_HostToBig64(uint64* iValueAddress) { ZByteSwap_64(iValueAddress); }
00834
00835
00836
00837 inline int16 ZByteSwap_HostToLittle16(int16 iValue) { return iValue; }
00838 inline void ZByteSwap_HostToLittle16(int16* iValueAddress) {}
00839 inline void ZByteSwap_HostToLittle16(uint16* iValueAddress) {}
00840
00841 inline int32 ZByteSwap_HostToLittle32(int32 iValue) { return iValue; }
00842 inline void ZByteSwap_HostToLittle32(int32* iValueAddress) {}
00843 inline void ZByteSwap_HostToLittle32(uint32* iValueAddress) {}
00844
00845 inline int64 ZByteSwap_HostToLittle64(int64 iValue) { return iValue; }
00846 inline void ZByteSwap_HostToLittle64(int64* iValueAddress) {}
00847 inline void ZByteSwap_HostToLittle64(uint64* iValueAddress) {}
00848
00849
00850
00851 inline int16 ZByteSwap_BigToHost16(int16 iValue) { return ZByteSwap_16(iValue); }
00852 inline void ZByteSwap_BigToHost16(int16* iValueAddress) { ZByteSwap_16(iValueAddress); }
00853 inline void ZByteSwap_BigToHost16(uint16* iValueAddress) { ZByteSwap_16(iValueAddress); }
00854
00855 inline int32 ZByteSwap_BigToHost32(int32 iValue) { return ZByteSwap_32(iValue); }
00856 inline void ZByteSwap_BigToHost32(int32* iValueAddress) { ZByteSwap_32(iValueAddress); }
00857 inline void ZByteSwap_BigToHost32(uint32* iValueAddress) { ZByteSwap_32(iValueAddress); }
00858
00859 inline int64 ZByteSwap_BigToHost64(int64 iValue) { return ZByteSwap_64(iValue); }
00860 inline void ZByteSwap_BigToHost64(int64* iValueAddress) { ZByteSwap_64(iValueAddress); }
00861 inline void ZByteSwap_BigToHost64(uint64* iValueAddress) { ZByteSwap_64(iValueAddress); }
00862
00863
00864
00865 inline int16 ZByteSwap_LittleToHost16(int16 iValue) { return iValue; }
00866 inline void ZByteSwap_LittleToHost16(int16* iValueAddress) {}
00867 inline void ZByteSwap_LittleToHost16(uint16* iValueAddress) {}
00868
00869 inline int32 ZByteSwap_LittleToHost32(int32 iValue) { return iValue; }
00870 inline void ZByteSwap_LittleToHost32(int32* iValueAddress) {}
00871 inline void ZByteSwap_LittleToHost32(uint32* iValueAddress) {}
00872
00873 inline int64 ZByteSwap_LittleToHost64(int64 iValue) { return iValue; }
00874 inline void ZByteSwap_LittleToHost64(int64* iValueAddress) {}
00875 inline void ZByteSwap_LittleToHost64(uint64* iValueAddress) {}
00876
00877
00878
00879 inline int16 ZByteSwap_ReadBig16(const volatile void* iValueAddress)
00880 { return ZByteSwap_Read16(iValueAddress); }
00881 inline int32 ZByteSwap_ReadBig32(const volatile void* iValueAddress)
00882 { return ZByteSwap_Read32(iValueAddress); }
00883 inline int64 ZByteSwap_ReadBig64(const volatile void* iValueAddress)
00884 { return ZByteSwap_Read64(iValueAddress); }
00885
00886 inline int16 ZByteSwap_ReadLittle16(const volatile void* iValueAddress)
00887 { return *static_cast<const volatile int16*>(iValueAddress); }
00888 inline int32 ZByteSwap_ReadLittle32(const volatile void* iValueAddress)
00889 { return *static_cast<const volatile int32*>(iValueAddress); }
00890 inline int64 ZByteSwap_ReadLittle64(const volatile void* iValueAddress)
00891 { return *static_cast<const volatile int64*>(iValueAddress); }
00892
00893
00894
00895 inline void ZByteSwap_WriteBig16(volatile void* iValueAddress, int16 iValue)
00896 { ZByteSwap_Write16(iValueAddress, iValue); }
00897 inline void ZByteSwap_WriteBig32(volatile void* iValueAddress, int32 iValue)
00898 { ZByteSwap_Write32(iValueAddress, iValue); }
00899 inline void ZByteSwap_WriteBig64(volatile void* iValueAddress, int64 iValue)
00900 { ZByteSwap_Write64(iValueAddress, iValue); }
00901
00902 inline void ZByteSwap_WriteLittle16(volatile void* iValueAddress, int16 iValue)
00903 { *static_cast<volatile int16*>(iValueAddress) = iValue; }
00904 inline void ZByteSwap_WriteLittle32(volatile void* iValueAddress, int32 iValue)
00905 { *static_cast<volatile int32*>(iValueAddress) = iValue; }
00906 inline void ZByteSwap_WriteLittle64(volatile void* iValueAddress, int64 iValue)
00907 { *static_cast<volatile int64*>(iValueAddress) = iValue; }
00908
00909
00910 #endif // ZByteSwap_EndianBig
00911
00912 #undef ZByteSwap_EndianBig
00913
00914 #endif // __ZByteSwap__