Back to Jetson Inference

Jetson Inference: jetson

docs/html/Endian_8h_source.html

latest4.4 KB
Original Source

| | Jetson Inference

DNN Vision Library |

Endian.h

Go to the documentation of this file.

1 /*

2 * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.

3 *

4 * Permission is hereby granted, free of charge, to any person obtaining a

5 * copy of this software and associated documentation files (the "Software"),

6 * to deal in the Software without restriction, including without limitation

7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,

8 * and/or sell copies of the Software, and to permit persons to whom the

9 * Software is furnished to do so, subject to the following conditions:

10 *

11 * The above copyright notice and this permission notice shall be included in

12 * all copies or substantial portions of the Software.

13 *

14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL

17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER

20 * DEALINGS IN THE SOFTWARE.

21 */

22

23 #ifndef __NETWORK_ENDIAN_H_

24 #define __NETWORK_ENDIAN_H_

25

26

27 #include <endian.h>

28

29

30 /*

31 * endianess defines (big or little)

32 */

33 // #define __LITTLE_ENDIAN

34 // #define __BIG_ENDIAN

35

36

37 /*

38 * define byte-swap macros

39 */

40 inline uint64_t bswap64( uint64_t value ) { return __builtin_bswap64(value); }

41 inline uint32_t bswap32( uint32_t value ) { return __builtin_bswap32(value); }

42 inline uint16_t bswap16( uint16_t value ) { return ((value >> 8) | (value << 8)); }

43

44

45 /*

46 * define network swapping macros, based on endianness

47 */

48 #if (__BYTE_ORDER == __LITTLE_ENDIAN)

49

50 inline uint64_t netswap64( uint64_t value ) { return bswap64(value); }

51 inline uint32_t netswap32( uint32_t value ) { return bswap32(value); }

52 inline uint16_t netswap16( uint16_t value ) { return bswap16(value); }

53

54 #elif (__BYTE_ORDER == __BIG_ENDIAN)

55

56 inline uint64_t netswap64( uint64_t value ) { return value; }

57 inline uint32_t netswap32( uint32_t value ) { return value; }

58 inline uint16_t netswap16( uint16_t value ) { return value; }

59

60 #endif

61 #endif

netswap16

uint16_t netswap16(uint16_t value)

Definition: Endian.h:52

bswap32

uint32_t bswap32(uint32_t value)

Definition: Endian.h:41

netswap32

uint32_t netswap32(uint32_t value)

Definition: Endian.h:51

bswap16

uint16_t bswap16(uint16_t value)

Definition: Endian.h:42

netswap64

uint64_t netswap64(uint64_t value)

Definition: Endian.h:50

bswap64

uint64_t bswap64(uint64_t value)

Definition: Endian.h:40