-
Notifications
You must be signed in to change notification settings - Fork 29
/
uint.h
38 lines (30 loc) · 1002 Bytes
/
uint.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <postgres.h>
#include <fmgr.h>
#include <catalog/catversion.h>
#ifdef GET_1_BYTE
#define DatumGetInt8(X) ((int8) GET_1_BYTE(X)) /* XXX */
#else
#define DatumGetInt8(X) ((int8) (X))
#endif
#if PG_VERSION_NUM < 90600
#ifdef USE_FLOAT8_BYVAL
#define DatumGetUInt64(X) ((uint64) GET_8_BYTES(X))
#else
#define DatumGetUInt64(X) (* ((uint64 *) DatumGetPointer(X)))
#endif
#ifdef USE_FLOAT8_BYVAL
#define UInt64GetDatum(X) ((Datum) SET_8_BYTES(X))
#else
#define UInt64GetDatum(X) Int64GetDatum((int64) (X))
#endif
#endif
#define PG_GETARG_INT8(n) DatumGetInt8(PG_GETARG_DATUM(n))
#define PG_RETURN_INT8(x) return Int8GetDatum(x)
#define PG_GETARG_UINT8(n) DatumGetUInt8(PG_GETARG_DATUM(n))
#define PG_RETURN_UINT8(x) return UInt8GetDatum(x)
#ifndef PG_RETURN_UINT16
#define PG_RETURN_UINT16(x) return UInt16GetDatum(x)
#endif
#define PG_GETARG_UINT64(n) DatumGetUInt64(PG_GETARG_DATUM(n))
#define PG_RETURN_UINT64(x) return UInt64GetDatum(x)
#define SAMESIGN(a,b) (((a) < 0) == ((b) < 0))