Endian.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  1. {
  2. File: CarbonCore/Endian.h
  3. Contains: Endian swapping utilties
  4. Version: CarbonCore-654.0.85~1
  5. Copyright: © 1997-2005 by Apple Computer, Inc., all rights reserved
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://www.freepascal.org/bugs.html
  9. }
  10. { Pascal Translation Updated: Peter N Lewis, <[email protected]>, November 2005 }
  11. {
  12. Modified for use with Free Pascal
  13. Version 200
  14. Please report any bugs to <[email protected]>
  15. }
  16. {$mode macpas}
  17. {$packenum 1}
  18. {$macro on}
  19. {$inline on}
  20. {$CALLING MWPASCAL}
  21. unit Endian;
  22. interface
  23. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  24. {$setc GAP_INTERFACES_VERSION := $0200}
  25. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  26. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  27. {$endc}
  28. {$ifc defined CPUPOWERPC and defined CPUI386}
  29. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  30. {$endc}
  31. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  32. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  33. {$endc}
  34. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  35. {$setc __ppc__ := 1}
  36. {$elsec}
  37. {$setc __ppc__ := 0}
  38. {$endc}
  39. {$ifc not defined __i386__ and defined CPUI386}
  40. {$setc __i386__ := 1}
  41. {$elsec}
  42. {$setc __i386__ := 0}
  43. {$endc}
  44. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  45. {$error Conflicting definitions for __ppc__ and __i386__}
  46. {$endc}
  47. {$ifc defined __ppc__ and __ppc__}
  48. {$setc TARGET_CPU_PPC := TRUE}
  49. {$setc TARGET_CPU_X86 := FALSE}
  50. {$elifc defined __i386__ and __i386__}
  51. {$setc TARGET_CPU_PPC := FALSE}
  52. {$setc TARGET_CPU_X86 := TRUE}
  53. {$elsec}
  54. {$error Neither __ppc__ nor __i386__ is defined.}
  55. {$endc}
  56. {$setc TARGET_CPU_PPC_64 := FALSE}
  57. {$ifc defined FPC_BIG_ENDIAN}
  58. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  59. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  60. {$elifc defined FPC_LITTLE_ENDIAN}
  61. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  62. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  63. {$elsec}
  64. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  65. {$endc}
  66. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  67. {$setc CALL_NOT_IN_CARBON := FALSE}
  68. {$setc OLDROUTINENAMES := FALSE}
  69. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  70. {$setc OPAQUE_UPP_TYPES := TRUE}
  71. {$setc OTCARBONAPPLICATION := TRUE}
  72. {$setc OTKERNEL := FALSE}
  73. {$setc PM_USE_SESSION_APIS := TRUE}
  74. {$setc TARGET_API_MAC_CARBON := TRUE}
  75. {$setc TARGET_API_MAC_OS8 := FALSE}
  76. {$setc TARGET_API_MAC_OSX := TRUE}
  77. {$setc TARGET_CARBON := TRUE}
  78. {$setc TARGET_CPU_68K := FALSE}
  79. {$setc TARGET_CPU_MIPS := FALSE}
  80. {$setc TARGET_CPU_SPARC := FALSE}
  81. {$setc TARGET_OS_MAC := TRUE}
  82. {$setc TARGET_OS_UNIX := FALSE}
  83. {$setc TARGET_OS_WIN32 := FALSE}
  84. {$setc TARGET_RT_MAC_68881 := FALSE}
  85. {$setc TARGET_RT_MAC_CFM := FALSE}
  86. {$setc TARGET_RT_MAC_MACHO := TRUE}
  87. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  88. {$setc TYPE_BOOL := FALSE}
  89. {$setc TYPE_EXTENDED := FALSE}
  90. {$setc TYPE_LONGLONG := TRUE}
  91. uses MacTypes;
  92. {$ALIGN MAC68K}
  93. {
  94. This file provides Endian Flipping routines for dealing with converting data
  95. between Big-Endian and Little-Endian machines. These routines are useful
  96. when writing code to compile for both Big and Little Endian machines and
  97. which must handle other endian number formats, such as reading or writing
  98. to a file or network packet.
  99. These routines are named as follows:
  100. Endian<U><W>_<S>to<D>
  101. where
  102. <U> is whether the integer is signed ('S') or unsigned ('U')
  103. <W> is integer bit width: 16, 32, or 64
  104. <S> is the source endian format: 'B' for big, 'L' for little, or 'N' for native
  105. <D> is the destination endian format: 'B' for big, 'L' for little, or 'N' for native
  106. For example, to convert a Big Endian 32-bit unsigned integer to the current native format use:
  107. long i = EndianU32_BtoN(data);
  108. This file is set up so that the function macro to nothing when the target runtime already
  109. is the desired format (e.g. on Big Endian machines, EndianU32_BtoN() macros away).
  110. If long long's are not supported, you cannot get 64-bit quantities as a single value.
  111. The macros are not defined in that case.
  112. For gcc, the macros build on top of the inline byte swapping
  113. routines from <libkern/OSByteOrder.h>, which may have better performance.
  114. <<< W A R N I N G >>>
  115. It is very important not to put any autoincrements inside the macros. This
  116. will produce erroneous results because each time the address is accessed in the macro,
  117. the increment occurs.
  118. }
  119. // Macros might be better solutions
  120. function Endian16_Swap( arg: UInt16 ): UInt16; inline;
  121. function Endian32_Swap( arg: UInt32 ): UInt32; inline;
  122. function Endian64_Swap_Pascal( arg: UInt64 ): UInt64; inline;
  123. function EndianS16_Swap( arg: SInt16 ): SInt16; inline;
  124. function EndianS32_Swap( arg: SInt32 ): SInt32; inline;
  125. function EndianS64_Swap( arg: SInt64 ): SInt64; inline;
  126. function Endian64_Swap( arg: UInt64 ): UInt64; inline;
  127. // Macro away no-op functions
  128. {$ifc TARGET_RT_BIG_ENDIAN}
  129. function EndianS16_BtoN( arg: SInt16 ): SInt16; inline;
  130. function EndianS16_NtoB( arg: SInt16 ): SInt16; inline;
  131. function EndianU16_BtoN( arg: UInt16 ): UInt16; inline;
  132. function EndianU16_NtoB( arg: UInt16 ): UInt16; inline;
  133. function EndianS32_BtoN( arg: SInt32 ): SInt32; inline;
  134. function EndianS32_NtoB( arg: SInt32 ): SInt32; inline;
  135. function EndianU32_BtoN( arg: UInt32 ): UInt32; inline;
  136. function EndianU32_NtoB( arg: UInt32 ): UInt32; inline;
  137. function EndianS64_BtoN( arg: SInt64 ): SInt64; inline;
  138. function EndianS64_NtoB( arg: SInt64 ): SInt64; inline;
  139. function EndianU64_BtoN( arg: UInt64 ): UInt64; inline;
  140. function EndianU64_NtoB( arg: UInt64 ): UInt64; inline;
  141. {$elsec}
  142. function EndianS16_LtoN( arg: SInt16 ): SInt16; inline;
  143. function EndianS16_NtoL( arg: SInt16 ): SInt16; inline;
  144. function EndianU16_LtoN( arg: UInt16 ): UInt16; inline;
  145. function EndianU16_NtoL( arg: UInt16 ): UInt16; inline;
  146. function EndianS32_LtoN( arg: SInt32 ): SInt32; inline;
  147. function EndianS32_NtoL( arg: SInt32 ): SInt32; inline;
  148. function EndianU32_LtoN( arg: UInt32 ): UInt32; inline;
  149. function EndianU32_NtoL( arg: UInt32 ): UInt32; inline;
  150. function EndianS64_LtoN( arg: SInt64 ): SInt64; inline;
  151. function EndianS64_NtoL( arg: SInt64 ): SInt64; inline;
  152. function EndianU64_LtoN( arg: UInt64 ): UInt64; inline;
  153. function EndianU64_NtoL( arg: UInt64 ): UInt64; inline;
  154. {$endc}
  155. // Map native to actual
  156. {$ifc TARGET_RT_BIG_ENDIAN}
  157. function EndianS16_LtoN( arg: SInt16 ): SInt16; inline;
  158. function EndianS16_NtoL( arg: SInt16 ): SInt16; inline;
  159. function EndianU16_LtoN( arg: UInt16 ): UInt16; inline;
  160. function EndianU16_NtoL( arg: UInt16 ): UInt16; inline;
  161. function EndianS32_LtoN( arg: SInt32 ): SInt32; inline;
  162. function EndianS32_NtoL( arg: SInt32 ): SInt32; inline;
  163. function EndianU32_LtoN( arg: UInt32 ): UInt32; inline;
  164. function EndianU32_NtoL( arg: UInt32 ): UInt32; inline;
  165. function EndianS64_LtoN( arg: SInt64 ): SInt64; inline;
  166. function EndianS64_NtoL( arg: SInt64 ): SInt64; inline;
  167. function EndianU64_LtoN( arg: UInt64 ): UInt64; inline;
  168. function EndianU64_NtoL( arg: UInt64 ): UInt64; inline;
  169. {$elsec}
  170. function EndianS16_BtoN( arg: SInt16 ): SInt16; inline;
  171. function EndianS16_NtoB( arg: SInt16 ): SInt16; inline;
  172. function EndianU16_BtoN( arg: UInt16 ): UInt16; inline;
  173. function EndianU16_NtoB( arg: UInt16 ): UInt16; inline;
  174. function EndianS32_BtoN( arg: SInt32 ): SInt32; inline;
  175. function EndianS32_NtoB( arg: SInt32 ): SInt32; inline;
  176. function EndianU32_BtoN( arg: UInt32 ): UInt32; inline;
  177. function EndianU32_NtoB( arg: UInt32 ): UInt32; inline;
  178. function EndianS64_BtoN( arg: SInt64 ): SInt64; inline;
  179. function EndianS64_NtoB( arg: SInt64 ): SInt64; inline;
  180. function EndianU64_BtoN( arg: UInt64 ): UInt64; inline;
  181. function EndianU64_NtoB( arg: UInt64 ): UInt64; inline;
  182. {$endc}
  183. // Implement *LtoB and *BtoL
  184. function EndianS16_LtoB( arg: SInt16 ): SInt16; inline;
  185. function EndianS16_BtoL( arg: SInt16 ): SInt16; inline;
  186. function EndianU16_LtoB( arg: UInt16 ): UInt16; inline;
  187. function EndianU16_BtoL( arg: UInt16 ): UInt16; inline;
  188. function EndianS32_LtoB( arg: SInt32 ): SInt32; inline;
  189. function EndianS32_BtoL( arg: SInt32 ): SInt32; inline;
  190. function EndianU32_LtoB( arg: UInt32 ): UInt32; inline;
  191. function EndianU32_BtoL( arg: UInt32 ): UInt32; inline;
  192. function EndianS64_LtoB( arg: SInt64 ): SInt64; inline;
  193. function EndianS64_BtoL( arg: SInt64 ): SInt64; inline;
  194. function EndianU64_LtoB( arg: UInt64 ): UInt64; inline;
  195. function EndianU64_BtoL( arg: UInt64 ): UInt64; inline;
  196. {
  197. These types are used for structures that contain data that is
  198. always in BigEndian format. This extra typing prevents little
  199. endian code from directly changing the data, thus saving much
  200. time in the debugger.
  201. }
  202. {$ifc TARGET_RT_LITTLE_ENDIAN}
  203. type
  204. BigEndianLong = record
  205. bigEndianValue: SInt32;
  206. end;
  207. BigEndianUnsignedLong = record
  208. bigEndianValue: UInt32;
  209. end;
  210. BigEndianShort = record
  211. bigEndianValue: SInt16;
  212. end;
  213. BigEndianUnsignedShort = record
  214. bigEndianValue: UInt16;
  215. end;
  216. BigEndianFixed = record
  217. bigEndianValue: Fixed;
  218. end;
  219. BigEndianUnsignedFixed = record
  220. bigEndianValue: UnsignedFixed;
  221. end;
  222. BigEndianOSType = record
  223. bigEndianValue: OSType;
  224. end;
  225. {$elsec}
  226. type
  227. BigEndianLong = SInt32;
  228. BigEndianUnsignedLong = UInt32;
  229. BigEndianShort = SInt16;
  230. BigEndianUnsignedShort = UInt16;
  231. BigEndianFixed = Fixed;
  232. BigEndianUnsignedFixed = UnsignedFixed;
  233. BigEndianOSType = OSType;
  234. {$endc} {TARGET_RT_LITTLE_ENDIAN}
  235. type
  236. BigEndianLongPtr = ^BigEndianLong;
  237. BigEndianUnsignedLongPtr = ^BigEndianUnsignedLong;
  238. BigEndianShortPtr = ^BigEndianShort;
  239. BigEndianUnsignedShortPtr = ^BigEndianUnsignedShort;
  240. BigEndianFixedPtr = ^BigEndianFixed;
  241. BigEndianUnsignedFixedPtr = ^BigEndianUnsignedFixed;
  242. BigEndianOSTypePtr = ^BigEndianOSType;
  243. {
  244. CoreEndian flipping API.
  245. This API is used to generically massage data buffers, in
  246. place, from one endian architecture to another. In effect,
  247. the API supports registering a set of callbacks that can
  248. effect this translation.
  249. The data types have specific meanings within their domain,
  250. although some data types can be registered with the same
  251. callback in several domains. There is no wildcard domain.
  252. A set of pre-defined flippers are implemented by the Carbon
  253. frameworks for most common resource manager and AppleEvent data
  254. types.
  255. }
  256. const
  257. kCoreEndianResourceManagerDomain = $72737263 (* 'rsrc' *);
  258. kCoreEndianAppleEventManagerDomain = $61657674 (* 'aevt' *);
  259. {
  260. * CoreEndianFlipProc
  261. *
  262. * Discussion:
  263. * Callback use to flip endian-ness of typed data
  264. *
  265. * Parameters:
  266. *
  267. * dataDomain:
  268. * Domain of the data type
  269. *
  270. * dataType:
  271. * Type of data being flipped
  272. *
  273. * id:
  274. * resource id (if being flipped on behalf of the resource
  275. * manager, otherwise will be zero)
  276. *
  277. * dataPtr:
  278. * Pointer to the data
  279. *
  280. * dataSize:
  281. * Length of the data
  282. *
  283. * currentlyNative:
  284. * Boolean indicating which direction to flip: false means flip
  285. * from disk big endian to native (from disk), true means flip
  286. * from native to disk big endian (to disk)
  287. *
  288. * refcon:
  289. * An optional user reference supplied when the flipper is
  290. * installed
  291. *
  292. * Result:
  293. * Error code indicating whether the data was flipped. noErr would
  294. * indicate that the data was flipped as appropriate; any other
  295. * error will be propagated back to the caller.
  296. }
  297. type
  298. CoreEndianFlipProc = function( dataDomain: OSType; dataType: OSType; id: SInt16; dataPtr: UnivPtr; dataSize: UInt32; currentlyNative: Boolean; refcon: UnivPtr ): OSStatus;
  299. {
  300. * Install a flipper for this application
  301. }
  302. {
  303. * CoreEndianInstallFlipper()
  304. *
  305. * Summary:
  306. * Installs a flipper proc for the given data type. If the flipper
  307. * is already registered, this flipper will take replace it.
  308. *
  309. * Mac OS X threading:
  310. * Thread safe since version 10.3
  311. *
  312. * Parameters:
  313. *
  314. * dataDomain:
  315. * Domain of the data type
  316. *
  317. * dataType:
  318. * Type of data for which this flipper should be installed
  319. *
  320. * proc:
  321. * Flipper callback to be called for data of this type
  322. *
  323. * refcon:
  324. * Optional user reference for the flipper
  325. *
  326. * Result:
  327. * Error code indicating whether or not the flipper could be
  328. * installed
  329. *
  330. * Availability:
  331. * Mac OS X: in version 10.3 and later in CoreServices.framework
  332. * CarbonLib: not available
  333. * Non-Carbon CFM: not available
  334. }
  335. function CoreEndianInstallFlipper( dataDomain: OSType; dataType: OSType; proc: CoreEndianFlipProc; refcon: UnivPtr { can be NULL } ): OSStatus; external name '_CoreEndianInstallFlipper';
  336. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  337. {
  338. * CoreEndianGetFlipper()
  339. *
  340. * Summary:
  341. * Gets an existing data flipper proc for the given data type
  342. *
  343. * Mac OS X threading:
  344. * Thread safe since version 10.3
  345. *
  346. * Parameters:
  347. *
  348. * dataDomain:
  349. * Domain of the data type
  350. *
  351. * dataType:
  352. * Type of the data for which this flipper should be installed
  353. *
  354. * proc:
  355. * Pointer to a flipper callback
  356. *
  357. * refcon:
  358. * Pointer to the callback refcon
  359. *
  360. * Result:
  361. * noErr if the given flipper could be found; otherwise
  362. * handlerNotFoundErr will be returned.
  363. *
  364. * Availability:
  365. * Mac OS X: in version 10.3 and later in CoreServices.framework
  366. * CarbonLib: not available
  367. * Non-Carbon CFM: not available
  368. }
  369. function CoreEndianGetFlipper( dataDomain: OSType; dataType: OSType; var proc: CoreEndianFlipProc; refcon: UnivPtrPtr ): OSStatus; external name '_CoreEndianGetFlipper';
  370. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  371. {
  372. * CoreEndianFlipData()
  373. *
  374. * Summary:
  375. * Calls the flipper for the given data type with the associated data
  376. *
  377. * Mac OS X threading:
  378. * Thread safe since version 10.3
  379. *
  380. * Parameters:
  381. *
  382. * dataDomain:
  383. * Domain of the data type
  384. *
  385. * dataType:
  386. * type of the data
  387. *
  388. * id:
  389. * resource id (if not a resource, pass zero)
  390. *
  391. * data:
  392. * a pointer to the data to be flipped (in place)
  393. *
  394. * dataLen:
  395. * length of the data to flip
  396. *
  397. * currentlyNative:
  398. * a boolean indicating the direction to flip (whether the data is
  399. * currently native endian or big-endian)
  400. *
  401. * Result:
  402. * Error code indicating whether the data was flipped. If
  403. * handlerNotFound is returned, then no flipping took place (which
  404. * is not necessarily an error condtion)
  405. *
  406. * Availability:
  407. * Mac OS X: in version 10.3 and later in CoreServices.framework
  408. * CarbonLib: not available
  409. * Non-Carbon CFM: not available
  410. }
  411. function CoreEndianFlipData( dataDomain: OSType; dataType: OSType; id: SInt16; data: UnivPtr; dataLen: UInt32; currentlyNative: Boolean ): OSStatus; external name '_CoreEndianFlipData';
  412. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  413. implementation
  414. {$R-}
  415. function Endian16_Swap( arg: UInt16 ): UInt16; inline;
  416. begin
  417. Endian16_Swap := (( arg shl 8) and $0FF00) or (( arg shr 8) and $00FF);
  418. end;
  419. function Endian32_Swap( arg: UInt32 ): UInt32; inline;
  420. begin
  421. Endian32_Swap := ((arg and $FF) shl 24) or ((arg and $0FF00) shl 8) or ((arg shr 8) and $0FF00) or ((arg shr 24) and $FF);
  422. end;
  423. function Endian64_Swap_Pascal( arg: UInt64 ): UInt64; inline;
  424. begin
  425. Endian64_Swap_Pascal := (Endian32_Swap( arg and $FFFFFFFF ) shl 32) or Endian32_Swap( (arg shr 32) and $FFFFFFFF );
  426. end;
  427. function Endian64_Swap( arg: UInt64 ): UInt64; inline;
  428. begin
  429. Endian64_Swap := Endian64_Swap_Pascal(arg);
  430. end;
  431. function EndianS16_Swap( arg: SInt16 ): SInt16; inline;
  432. begin
  433. EndianS16_Swap := (( arg shl 8) and $0FF00) or (( arg shr 8) and $00FF);
  434. end;
  435. function EndianS32_Swap( arg: SInt32 ): SInt32; inline;
  436. begin
  437. EndianS32_Swap := ((arg and $FF) shl 24) or ((arg and $0FF00) shl 8) or ((arg shr 8) and $0FF00) or ((arg shr 24) and $FF);
  438. end;
  439. function EndianS64_Swap( arg: SInt64 ): SInt64; inline;
  440. begin
  441. EndianS64_Swap := (Endian32_Swap( arg and $FFFFFFFF ) shl 32) or Endian32_Swap( (arg shr 32) and $FFFFFFFF );
  442. end;
  443. {$ifc TARGET_RT_BIG_ENDIAN}
  444. function EndianS16_BtoN( arg: SInt16 ): SInt16; inline;
  445. begin
  446. EndianS16_BtoN := arg;
  447. end;
  448. function EndianS16_NtoB( arg: SInt16 ): SInt16; inline;
  449. begin
  450. EndianS16_NtoB := arg;
  451. end;
  452. function EndianU16_BtoN( arg: UInt16 ): UInt16; inline;
  453. begin
  454. EndianU16_BtoN := arg;
  455. end;
  456. function EndianU16_NtoB( arg: UInt16 ): UInt16; inline;
  457. begin
  458. EndianU16_NtoB := arg;
  459. end;
  460. function EndianS32_BtoN( arg: SInt32 ): SInt32; inline;
  461. begin
  462. EndianS32_BtoN := arg;
  463. end;
  464. function EndianS32_NtoB( arg: SInt32 ): SInt32; inline;
  465. begin
  466. EndianS32_NtoB := arg;
  467. end;
  468. function EndianU32_BtoN( arg: UInt32 ): UInt32; inline;
  469. begin
  470. EndianU32_BtoN := arg;
  471. end;
  472. function EndianU32_NtoB( arg: UInt32 ): UInt32; inline;
  473. begin
  474. EndianU32_NtoB := arg;
  475. end;
  476. function EndianS64_BtoN( arg: SInt64 ): SInt64; inline;
  477. begin
  478. EndianS64_BtoN := arg;
  479. end;
  480. function EndianS64_NtoB( arg: SInt64 ): SInt64; inline;
  481. begin
  482. EndianS64_NtoB := arg;
  483. end;
  484. function EndianU64_BtoN( arg: UInt64 ): UInt64; inline;
  485. begin
  486. EndianU64_BtoN := arg;
  487. end;
  488. function EndianU64_NtoB( arg: UInt64 ): UInt64; inline;
  489. begin
  490. EndianU64_NtoB := arg;
  491. end;
  492. function EndianS16_LtoN( arg: SInt16 ): SInt16; inline;
  493. begin
  494. EndianS16_LtoN := EndianS16_Swap(arg);
  495. end;
  496. function EndianS16_NtoL( arg: SInt16 ): SInt16; inline;
  497. begin
  498. EndianS16_NtoL := EndianS16_Swap(arg);
  499. end;
  500. function EndianU16_LtoN( arg: UInt16 ): UInt16; inline;
  501. begin
  502. EndianU16_LtoN := Endian16_Swap(arg);
  503. end;
  504. function EndianU16_NtoL( arg: UInt16 ): UInt16; inline;
  505. begin
  506. EndianU16_NtoL := Endian16_Swap(arg);
  507. end;
  508. function EndianS32_LtoN( arg: SInt32 ): SInt32; inline;
  509. begin
  510. EndianS32_LtoN := EndianS32_Swap(arg);
  511. end;
  512. function EndianS32_NtoL( arg: SInt32 ): SInt32; inline;
  513. begin
  514. EndianS32_NtoL := EndianS32_Swap(arg);
  515. end;
  516. function EndianU32_LtoN( arg: UInt32 ): UInt32; inline;
  517. begin
  518. EndianU32_LtoN := Endian32_Swap(arg);
  519. end;
  520. function EndianU32_NtoL( arg: UInt32 ): UInt32; inline;
  521. begin
  522. EndianU32_NtoL := Endian32_Swap(arg);
  523. end;
  524. function EndianS64_LtoN( arg: SInt64 ): SInt64; inline;
  525. begin
  526. EndianS64_LtoN := EndianS64_Swap(arg);
  527. end;
  528. function EndianS64_NtoL( arg: SInt64 ): SInt64; inline;
  529. begin
  530. EndianS64_NtoL := EndianS64_Swap(arg);
  531. end;
  532. function EndianU64_LtoN( arg: UInt64 ): UInt64; inline;
  533. begin
  534. EndianU64_LtoN := Endian64_Swap(arg);
  535. end;
  536. function EndianU64_NtoL( arg: UInt64 ): UInt64; inline;
  537. begin
  538. EndianU64_NtoL := Endian64_Swap(arg);
  539. end;
  540. {$elsec}
  541. function EndianS16_BtoN( arg: SInt16 ): SInt16; inline;
  542. begin
  543. EndianS16_BtoN := EndianS16_Swap(arg);
  544. end;
  545. function EndianS16_NtoB( arg: SInt16 ): SInt16; inline;
  546. begin
  547. EndianS16_NtoB := EndianS16_Swap(arg);
  548. end;
  549. function EndianU16_BtoN( arg: UInt16 ): UInt16; inline;
  550. begin
  551. EndianU16_BtoN := Endian16_Swap(arg);
  552. end;
  553. function EndianU16_NtoB( arg: UInt16 ): UInt16; inline;
  554. begin
  555. EndianU16_NtoB := Endian16_Swap(arg);
  556. end;
  557. function EndianS32_BtoN( arg: SInt32 ): SInt32; inline;
  558. begin
  559. EndianS32_BtoN := EndianS32_Swap(arg);
  560. end;
  561. function EndianS32_NtoB( arg: SInt32 ): SInt32; inline;
  562. begin
  563. EndianS32_NtoB := EndianS32_Swap(arg);
  564. end;
  565. function EndianU32_BtoN( arg: UInt32 ): UInt32; inline;
  566. begin
  567. EndianU32_BtoN := Endian32_Swap(arg);
  568. end;
  569. function EndianU32_NtoB( arg: UInt32 ): UInt32; inline;
  570. begin
  571. EndianU32_NtoB := Endian32_Swap(arg);
  572. end;
  573. function EndianS64_BtoN( arg: SInt64 ): SInt64; inline;
  574. begin
  575. EndianS64_BtoN := EndianS64_Swap(arg);
  576. end;
  577. function EndianS64_NtoB( arg: SInt64 ): SInt64; inline;
  578. begin
  579. EndianS64_NtoB := EndianS64_Swap(arg);
  580. end;
  581. function EndianU64_BtoN( arg: UInt64 ): UInt64; inline;
  582. begin
  583. EndianU64_BtoN := Endian64_Swap(arg);
  584. end;
  585. function EndianU64_NtoB( arg: UInt64 ): UInt64; inline;
  586. begin
  587. EndianU64_NtoB := Endian64_Swap(arg);
  588. end;
  589. function EndianS16_LtoN( arg: SInt16 ): SInt16; inline;
  590. begin
  591. EndianS16_LtoN := arg;
  592. end;
  593. function EndianS16_NtoL( arg: SInt16 ): SInt16; inline;
  594. begin
  595. EndianS16_NtoL := arg;
  596. end;
  597. function EndianU16_LtoN( arg: UInt16 ): UInt16; inline;
  598. begin
  599. EndianU16_LtoN := arg;
  600. end;
  601. function EndianU16_NtoL( arg: UInt16 ): UInt16; inline;
  602. begin
  603. EndianU16_NtoL := arg;
  604. end;
  605. function EndianS32_LtoN( arg: SInt32 ): SInt32; inline;
  606. begin
  607. EndianS32_LtoN := arg;
  608. end;
  609. function EndianS32_NtoL( arg: SInt32 ): SInt32; inline;
  610. begin
  611. EndianS32_NtoL := arg;
  612. end;
  613. function EndianU32_LtoN( arg: UInt32 ): UInt32; inline;
  614. begin
  615. EndianU32_LtoN := arg;
  616. end;
  617. function EndianU32_NtoL( arg: UInt32 ): UInt32; inline;
  618. begin
  619. EndianU32_NtoL := arg;
  620. end;
  621. function EndianS64_LtoN( arg: SInt64 ): SInt64; inline;
  622. begin
  623. EndianS64_LtoN := arg;
  624. end;
  625. function EndianS64_NtoL( arg: SInt64 ): SInt64; inline;
  626. begin
  627. EndianS64_NtoL := arg;
  628. end;
  629. function EndianU64_LtoN( arg: UInt64 ): UInt64; inline;
  630. begin
  631. EndianU64_LtoN := arg;
  632. end;
  633. function EndianU64_NtoL( arg: UInt64 ): UInt64; inline;
  634. begin
  635. EndianU64_NtoL := arg;
  636. end;
  637. {$endc}
  638. end.