PostgreSQL Source Code  git master
pg_bswap.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define pg_hton16(x)   pg_bswap16(x)
 
#define pg_hton32(x)   pg_bswap32(x)
 
#define pg_hton64(x)   pg_bswap64(x)
 
#define pg_ntoh16(x)   pg_bswap16(x)
 
#define pg_ntoh32(x)   pg_bswap32(x)
 
#define pg_ntoh64(x)   pg_bswap64(x)
 
#define DatumBigEndianToNative(x)   pg_bswap32(x)
 

Functions

static uint16 pg_bswap16 (uint16 x)
 
static uint32 pg_bswap32 (uint32 x)
 
static uint64 pg_bswap64 (uint64 x)
 

Macro Definition Documentation

◆ DatumBigEndianToNative

#define DatumBigEndianToNative (   x)    pg_bswap32(x)

Definition at line 149 of file pg_bswap.h.

Referenced by macaddr_abbrev_convert(), uuid_abbrev_convert(), and varstr_abbrev_convert().

◆ pg_hton16

#define pg_hton16 (   x)    pg_bswap16(x)

◆ pg_hton32

◆ pg_hton64

#define pg_hton64 (   x)    pg_bswap64(x)

Definition at line 122 of file pg_bswap.h.

Referenced by fe_sendint64(), and pq_writeint64().

◆ pg_ntoh16

#define pg_ntoh16 (   x)    pg_bswap16(x)

◆ pg_ntoh32

◆ pg_ntoh64

#define pg_ntoh64 (   x)    pg_bswap64(x)

Definition at line 126 of file pg_bswap.h.

Referenced by fe_recvint64(), pq_getmsgint64(), and receiveFileChunks().

Function Documentation

◆ pg_bswap16()

static uint16 pg_bswap16 ( uint16  x)
inlinestatic

Definition at line 42 of file pg_bswap.h.

43 {
44  return
45  ((x << 8) & 0xff00) |
46  ((x >> 8) & 0x00ff);
47 }

◆ pg_bswap32()

static uint32 pg_bswap32 ( uint32  x)
inlinestatic

Definition at line 64 of file pg_bswap.h.

65 {
66  return
67  ((x << 24) & 0xff000000) |
68  ((x << 8) & 0x00ff0000) |
69  ((x >> 8) & 0x0000ff00) |
70  ((x >> 24) & 0x000000ff);
71 }

◆ pg_bswap64()

static uint64 pg_bswap64 ( uint64  x)
inlinestatic

Definition at line 89 of file pg_bswap.h.

Referenced by uuid_2_double().

90 {
91  return
92  ((x << 56) & UINT64CONST(0xff00000000000000)) |
93  ((x << 40) & UINT64CONST(0x00ff000000000000)) |
94  ((x << 24) & UINT64CONST(0x0000ff0000000000)) |
95  ((x << 8) & UINT64CONST(0x000000ff00000000)) |
96  ((x >> 8) & UINT64CONST(0x00000000ff000000)) |
97  ((x >> 24) & UINT64CONST(0x0000000000ff0000)) |
98  ((x >> 40) & UINT64CONST(0x000000000000ff00)) |
99  ((x >> 56) & UINT64CONST(0x00000000000000ff));
100 }