PostgreSQL Source Code: src/include/c.h Source File (original) (raw)

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

39

40

41

42

43

44

45

46

47#ifndef C_H

48#define C_H

49

50

51

52

53

54

55

56

57#include "pg_config.h"

59#include "pg_config_os.h"

60

61

62#include <inttypes.h>

63#include <stdio.h>

64#include <stdlib.h>

66#include <stddef.h>

67#include <stdarg.h>

68#ifdef HAVE_STRINGS_H

70#endif

71#include <stdint.h>

72#include <sys/types.h>

73#include <errno.h>

74#if defined(WIN32) || defined(__CYGWIN__)

75#include <fcntl.h>

76#endif

77#include <locale.h>

78#ifdef HAVE_XLOCALE_H

79#include <xlocale.h>

80#endif

81#ifdef ENABLE_NLS

82#include <libintl.h>

83#endif

84

85

87

88

89#ifdef HAVE_LIBZ

90#define ZLIB_CONST

91#endif

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106#ifdef PG_FORCE_DISABLE_INLINE

107#undef inline

108#define inline

109#endif

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125#ifndef __has_attribute

126#define __has_attribute(attribute) 0

127#endif

128

129

130#ifdef __GNUC__

131#define pg_attribute_unused() __attribute__((unused))

132#else

133#define pg_attribute_unused()

134#endif

135

136

137

138

139

140

141

142#ifdef __GNUC__

143#define pg_nodiscard __attribute__((warn_unused_result))

144#else

145#define pg_nodiscard

146#endif

147

148

149

150

151

152

153

154

155

156

157

158#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L

159#define pg_noreturn _Noreturn

160#elif defined(__GNUC__) || defined(__SUNPRO_C)

161#define pg_noreturn __attribute__((noreturn))

162#elif defined(_MSC_VER)

163#define pg_noreturn __declspec(noreturn)

164#else

165#define pg_noreturn

166#endif

167

168

169

170

171

172#if defined(__clang__) || __GNUC__ >= 8

173#define pg_attribute_no_sanitize_address() __attribute__((no_sanitize("address")))

174#elif __has_attribute(no_sanitize_address)

175

176#define pg_attribute_no_sanitize_address() __attribute__((no_sanitize_address))

177#else

178#define pg_attribute_no_sanitize_address()

179#endif

180

181

182

183

184

185

186

187#if __clang_major__ >= 7 || __GNUC__ >= 8

188#define pg_attribute_no_sanitize_alignment() __attribute__((no_sanitize("alignment")))

189#else

190#define pg_attribute_no_sanitize_alignment()

191#endif

192

193

194

195

196

197

198#if __has_attribute (nonnull)

199#define pg_attribute_nonnull(...) __attribute__((nonnull(__VA_ARGS__)))

200#else

201#define pg_attribute_nonnull(...)

202#endif

203

204

205

206

207

208

209

210#if __has_attribute (target)

211#define pg_attribute_target(...) __attribute__((target(__VA_ARGS__)))

212#else

213#define pg_attribute_target(...)

214#endif

215

216

217

218

219

220

221#ifdef USE_ASSERT_CHECKING

222#define PG_USED_FOR_ASSERTS_ONLY

223#else

224#define PG_USED_FOR_ASSERTS_ONLY pg_attribute_unused()

225#endif

226

227

228#if defined(__GNUC__)

229#define pg_attribute_format_arg(a) __attribute__((format_arg(a)))

230#define pg_attribute_printf(f,a) __attribute__((format(PG_PRINTF_ATTRIBUTE, f, a)))

231#else

232#define pg_attribute_format_arg(a)

233#define pg_attribute_printf(f,a)

234#endif

235

236

237#if defined(__GNUC__) || defined(__SUNPRO_C)

238#define pg_attribute_aligned(a) __attribute__((aligned(a)))

239#define pg_attribute_packed() __attribute__((packed))

240#elif defined(_MSC_VER)

241

242

243

244

245

246

247#define pg_attribute_aligned(a) __declspec(align(a))

248#else

249

250

251

252

253

254#endif

255

256

257

258

259

260

261

262#if (defined(__GNUC__) && __GNUC__ > 3 && defined(__OPTIMIZE__)) || defined(__SUNPRO_C)

263

264#define pg_attribute_always_inline __attribute__((always_inline)) inline

265#elif defined(_MSC_VER)

266

267#define pg_attribute_always_inline __forceinline

268#else

269

270#define pg_attribute_always_inline inline

271#endif

272

273

274

275

276

277

278

279

280#if (defined(__GNUC__) && __GNUC__ > 2) || defined(__SUNPRO_C)

281#define pg_noinline __attribute__((noinline))

282

283#elif defined(_MSC_VER)

284#define pg_noinline __declspec(noinline)

285#else

286#define pg_noinline

287#endif

288

289

290

291

292

293

294

295

296

297

298#if defined(__MINGW64__) && __GNUC__ == 8 && __GNUC_MINOR__ == 1

299

300#define pg_attribute_cold

301#define pg_attribute_hot

302

303#else

304

305

306

307

308#if __has_attribute (cold)

309#define pg_attribute_cold __attribute__((cold))

310#else

311#define pg_attribute_cold

312#endif

313

314#if __has_attribute (hot)

315#define pg_attribute_hot __attribute__((hot))

316#else

317#define pg_attribute_hot

318#endif

319

320#endif

321

322

323

324

325

326

327#if defined(HAVE__BUILTIN_UNREACHABLE) && !defined(USE_ASSERT_CHECKING)

328#define pg_unreachable() __builtin_unreachable()

329#elif defined(_MSC_VER) && !defined(USE_ASSERT_CHECKING)

330#define pg_unreachable() __assume(0)

331#else

332#define pg_unreachable() abort()

333#endif

334

335

336

337

338

339

340

341

342#if __GNUC__ >= 3

343#define likely(x) __builtin_expect((x) != 0, 1)

344#define unlikely(x) __builtin_expect((x) != 0, 0)

345#else

346#define likely(x) ((x) != 0)

347#define unlikely(x) ((x) != 0)

348#endif

349

350

351

352

353

354

355

356

357

358

359

360

361

362#define CppAsString(identifier) #identifier

363#define CppAsString2(x) CppAsString(x)

364#define CppConcat(x, y) x##y

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385#ifdef _MSC_VER

386#define EXPAND(args) args

387#define VA_ARGS_NARGS(...) \

388 VA_ARGS_NARGS_ EXPAND((__VA_ARGS__, \

389 63,62,61,60, \

390 59,58,57,56,55,54,53,52,51,50, \

391 49,48,47,46,45,44,43,42,41,40, \

392 39,38,37,36,35,34,33,32,31,30, \

393 29,28,27,26,25,24,23,22,21,20, \

394 19,18,17,16,15,14,13,12,11,10, \

395 9, 8, 7, 6, 5, 4, 3, 2, 1, 0))

396#else

397

398#define VA_ARGS_NARGS(...) \

399 VA_ARGS_NARGS_(__VA_ARGS__, \

400 63,62,61,60, \

401 59,58,57,56,55,54,53,52,51,50, \

402 49,48,47,46,45,44,43,42,41,40, \

403 39,38,37,36,35,34,33,32,31,30, \

404 29,28,27,26,25,24,23,22,21,20, \

405 19,18,17,16,15,14,13,12,11,10, \

406 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)

407#endif

408

409#define VA_ARGS_NARGS_( \

410 _01,_02,_03,_04,_05,_06,_07,_08,_09,_10, \

411 _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \

412 _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \

413 _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \

414 _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \

415 _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \

416 _61,_62,_63, N, ...) \

417 (N)

418

419

420

421

422

423

425

426

427

428

429

430

431

432

433

434#define FLEXIBLE_ARRAY_MEMBER

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460#ifdef __GNUC__

461#define HAVE_PRAGMA_GCC_SYSTEM_HEADER 1

462#endif

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478#include <stdbool.h>

479

480

481

482

483

484

485

486

487

488

489

490

491

492

494

495

504

505

506

507

508

512

513

514

515

516#define INT64CONST(x) INT64_C(x)

517#define UINT64CONST(x) UINT64_C(x)

518

519

520#define INT64_FORMAT "%" PRId64

521#define UINT64_FORMAT "%" PRIu64

522#define INT64_HEX_FORMAT "%" PRIx64

523#define UINT64_HEX_FORMAT "%" PRIx64

524

525

526

527

528

529

530

531

532

533#if defined(PG_INT128_TYPE)

534#if defined(pg_attribute_aligned) || ALIGNOF_PG_INT128_TYPE <= MAXIMUM_ALIGNOF

535#define HAVE_INT128 1

536

537typedef PG_INT128_TYPE int128

538#if defined(pg_attribute_aligned)

540#endif

541 ;

542

543typedef unsigned PG_INT128_TYPE uint128

544#if defined(pg_attribute_aligned)

546#endif

547 ;

548

549#endif

550#endif

551

552

553#define PG_INT8_MIN INT8_MIN

554#define PG_INT8_MAX INT8_MAX

555#define PG_UINT8_MAX UINT8_MAX

556#define PG_INT16_MIN INT16_MIN

557#define PG_INT16_MAX INT16_MAX

558#define PG_UINT16_MAX UINT16_MAX

559#define PG_INT32_MIN INT32_MIN

560#define PG_INT32_MAX INT32_MAX

561#define PG_UINT32_MAX UINT32_MAX

562#define PG_INT64_MIN INT64_MIN

563#define PG_INT64_MAX INT64_MAX

564#define PG_UINT64_MAX UINT64_MAX

565

566

567

568

569

570#define HAVE_INT64_TIMESTAMP

571

572

573

574

575

577

578

579

580

581

582

583

584

586

587

588

589

590

591

592

593

594

596

597

598

599

602

603#ifdef USE_FLOAT8_BYVAL

604#define FLOAT8PASSBYVAL true

605#else

606#define FLOAT8PASSBYVAL false

607#endif

608

609

610

611

612

613

614

615

616

617

618

619

622

624

626

628

629#define InvalidSubTransactionId ((SubTransactionId) 0)

630#define TopSubTransactionId ((SubTransactionId) 1)

631

632

634

636

638

639#define FirstCommandId ((CommandId) 0)

640#define InvalidCommandId (~(CommandId)0)

641

642

643

644

645

646

647

648

649

650

651

652

653

654

655

656

658{

659 char vl_len_[4];

661};

662

663#define VARHDRSZ ((int32) sizeof(int32))

664

665

666

667

668

669

672typedef struct varlena BpChar;

673typedef struct varlena VarChar;

674

675

676

677

678

679

680

681

682

683

684

685typedef struct

686{

688 int ndim;

695

696typedef struct

697{

699 int ndim;

706

707

708

709

710

712{

716

717#define NameStr(name) ((name).data)

718

719

720

721

722

723

724

725

726

727

728#define BoolIsValid(boolean) ((boolean) == false || (boolean) == true)

729

730

731

732

733

734#define PointerIsValid(pointer) ((const void*)(pointer) != NULL)

735

736

737

738

739

740#define PointerIsAligned(pointer, type) \

741 (((uintptr_t)(pointer) % (sizeof (type))) == 0)

742

743#define OffsetToPointer(base, offset) \

744 ((void *)((char *) base + offset))

745

746#define OidIsValid(objectId) ((bool) ((objectId) != InvalidOid))

747

748#define RegProcedureIsValid(p) OidIsValid(p)

749

750

751

752

753

754

755

756

757

758

759#define lengthof(array) (sizeof (array) / sizeof ((array)[0]))

760

761

762

763

764

765

766

767

768

769

770

771

772

773

774

775#define TYPEALIGN(ALIGNVAL,LEN) \

776 (((uintptr_t) (LEN) + ((ALIGNVAL) - 1)) & ~((uintptr_t) ((ALIGNVAL) - 1)))

777

778#define SHORTALIGN(LEN) TYPEALIGN(ALIGNOF_SHORT, (LEN))

779#define INTALIGN(LEN) TYPEALIGN(ALIGNOF_INT, (LEN))

780#define LONGALIGN(LEN) TYPEALIGN(ALIGNOF_LONG, (LEN))

781#define DOUBLEALIGN(LEN) TYPEALIGN(ALIGNOF_DOUBLE, (LEN))

782#define MAXALIGN(LEN) TYPEALIGN(MAXIMUM_ALIGNOF, (LEN))

783

784#define BUFFERALIGN(LEN) TYPEALIGN(ALIGNOF_BUFFER, (LEN))

785#define CACHELINEALIGN(LEN) TYPEALIGN(PG_CACHE_LINE_SIZE, (LEN))

786

787#define TYPEALIGN_DOWN(ALIGNVAL,LEN) \

788 (((uintptr_t) (LEN)) & ~((uintptr_t) ((ALIGNVAL) - 1)))

789

790#define SHORTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_SHORT, (LEN))

791#define INTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_INT, (LEN))

792#define LONGALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_LONG, (LEN))

793#define DOUBLEALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_DOUBLE, (LEN))

794#define MAXALIGN_DOWN(LEN) TYPEALIGN_DOWN(MAXIMUM_ALIGNOF, (LEN))

795#define BUFFERALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_BUFFER, (LEN))

796

797

798

799

800

801

802

803#define TYPEALIGN64(ALIGNVAL,LEN) \

804 (((uint64) (LEN) + ((ALIGNVAL) - 1)) & ~((uint64) ((ALIGNVAL) - 1)))

805

806

807#define MAXALIGN64(LEN) TYPEALIGN64(MAXIMUM_ALIGNOF, (LEN))

808

809

810

811

812

813

814

815

816

817

818

819

820

821

822

823

824

825

826

827#ifndef USE_ASSERT_CHECKING

828

829#define Assert(condition) ((void)true)

830#define AssertMacro(condition) ((void)true)

831

832#elif defined(FRONTEND)

833

834#include <assert.h>

835#define Assert(p) assert(p)

836#define AssertMacro(p) ((void) assert(p))

837

838#else

839

840

841

842

843

844#define Assert(condition) \

845 do { \

846 if (!(condition)) \

847 ExceptionalCondition(#condition, __FILE__, __LINE__); \

848 } while (0)

849

850

851

852

853

854

855

856#define AssertMacro(condition) \

857 ((void) ((condition) || \

858 (ExceptionalCondition(#condition, __FILE__, __LINE__), 0)))

859

860#endif

861

862

863

864

865#define AssertPointerAlignment(ptr, bndr) \

866 Assert(TYPEALIGN(bndr, (uintptr_t)(ptr)) == (uintptr_t)(ptr))

867

868

869

870

871

872

873

874#ifndef FRONTEND

876 const char *fileName, int lineNumber);

877#endif

878

879

880

881

882

883

884

885

886

887

888

889

890

891

892

893

894

895

896

897

898#ifndef __cplusplus

899#ifdef HAVE__STATIC_ASSERT

900#define StaticAssertDecl(condition, errmessage) \

901 _Static_assert(condition, errmessage)

902#define StaticAssertStmt(condition, errmessage) \

903 do { _Static_assert(condition, errmessage); } while(0)

904#define StaticAssertExpr(condition, errmessage) \

905 ((void) ({ StaticAssertStmt(condition, errmessage); true; }))

906#else

907#define StaticAssertDecl(condition, errmessage) \

908 extern void static_assert_func(int static_assert_failure[(condition) ? 1 : -1])

909#define StaticAssertStmt(condition, errmessage) \

910 ((void) sizeof(struct { int static_assert_failure : (condition) ? 1 : -1; }))

911#define StaticAssertExpr(condition, errmessage) \

912 StaticAssertStmt(condition, errmessage)

913#endif

914#else

915#if defined(__cpp_static_assert) && __cpp_static_assert >= 200410

916#define StaticAssertDecl(condition, errmessage) \

917 static_assert(condition, errmessage)

918#define StaticAssertStmt(condition, errmessage) \

919 static_assert(condition, errmessage)

920#define StaticAssertExpr(condition, errmessage) \

921 ({ static_assert(condition, errmessage); })

922#else

923#define StaticAssertDecl(condition, errmessage) \

924 extern void static_assert_func(int static_assert_failure[(condition) ? 1 : -1])

925#define StaticAssertStmt(condition, errmessage) \

926 do { struct static_assert_struct { int static_assert_failure : (condition) ? 1 : -1; }; } while(0)

927#define StaticAssertExpr(condition, errmessage) \

928 ((void) ({ StaticAssertStmt(condition, errmessage); }))

929#endif

930#endif

931

932

933

934

935

936

937

938

939

940

941

942

943

944#ifdef HAVE__BUILTIN_TYPES_COMPATIBLE_P

945#define AssertVariableIsOfType(varname, typename) \

946 StaticAssertStmt(__builtin_types_compatible_p(__typeof__(varname), typename), \

947 CppAsString(varname) " does not have type " CppAsString(typename))

948#define AssertVariableIsOfTypeMacro(varname, typename) \

949 (StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \

950 CppAsString(varname) " does not have type " CppAsString(typename)))

951#else

952#define AssertVariableIsOfType(varname, typename) \

953 StaticAssertStmt(sizeof(varname) == sizeof(typename), \

954 CppAsString(varname) " does not have type " CppAsString(typename))

955#define AssertVariableIsOfTypeMacro(varname, typename) \

956 (StaticAssertExpr(sizeof(varname) == sizeof(typename), \

957 CppAsString(varname) " does not have type " CppAsString(typename)))

958#endif

959

960

961

962

963

964

965

966

967

968

969#define Max(x, y) ((x) > (y) ? (x) : (y))

970

971

972

973

974

975#define Min(x, y) ((x) < (y) ? (x) : (y))

976

977

978

979#define LONG_ALIGN_MASK (sizeof(long) - 1)

980

981

982

983

984

985

986

987

988

989

990

991#define MemSet(start, val, len) \

992 do \

993 { \

994 \

995 void *_vstart = (void *) (start); \

996 int _val = (val); \

997 Size _len = (len); \

998\

999 if ((((uintptr_t) _vstart) & LONG_ALIGN_MASK) == 0 && \

1000 (_len & LONG_ALIGN_MASK) == 0 && \

1001 _val == 0 && \

1002 _len <= MEMSET_LOOP_LIMIT && \

1003

1004

1005

1006 \

1007 MEMSET_LOOP_LIMIT != 0) \

1008 { \

1009 long *_start = (long *) _vstart; \

1010 long *_stop = (long *) ((char *) _start + _len); \

1011 while (_start < _stop) \

1012 *_start++ = 0; \

1013 } \

1014 else \

1015 memset(_vstart, _val, _len); \

1016 } while (0)

1017

1018

1019

1020

1021

1022

1023

1024#define MemSetAligned(start, val, len) \

1025 do \

1026 { \

1027 long *_start = (long *) (start); \

1028 int _val = (val); \

1029 Size _len = (len); \

1030\

1031 if ((_len & LONG_ALIGN_MASK) == 0 && \

1032 _val == 0 && \

1033 _len <= MEMSET_LOOP_LIMIT && \

1034 MEMSET_LOOP_LIMIT != 0) \

1035 { \

1036 long *_stop = (long *) ((char *) _start + _len); \

1037 while (_start < _stop) \

1038 *_start++ = 0; \

1039 } \

1040 else \

1041 memset(_start, _val, _len); \

1042 } while (0)

1043

1044

1045

1046

1047

1048

1049

1050

1051

1052

1053

1054

1056#define FLOAT4_FITS_IN_INT16(num) \

1057 ((num) >= (float4) PG_INT16_MIN && (num) < -((float4) PG_INT16_MIN))

1058#define FLOAT4_FITS_IN_INT32(num) \

1059 ((num) >= (float4) PG_INT32_MIN && (num) < -((float4) PG_INT32_MIN))

1060#define FLOAT4_FITS_IN_INT64(num) \

1061 ((num) >= (float4) PG_INT64_MIN && (num) < -((float4) PG_INT64_MIN))

1062#define FLOAT8_FITS_IN_INT16(num) \

1063 ((num) >= (float8) PG_INT16_MIN && (num) < -((float8) PG_INT16_MIN))

1064#define FLOAT8_FITS_IN_INT32(num) \

1065 ((num) >= (float8) PG_INT32_MIN && (num) < -((float8) PG_INT32_MIN))

1066#define FLOAT8_FITS_IN_INT64(num) \

1067 ((num) >= (float8) PG_INT64_MIN && (num) < -((float8) PG_INT64_MIN))

1068

1069

1070

1071

1072

1073

1074

1075

1076

1077

1078

1079

1080#define INVERT_COMPARE_RESULT(var) \

1081 ((var) = ((var) < 0) ? 1 : -(var))

1082

1083

1084

1085

1086

1087

1088

1089

1097

1098

1099

1100

1101

1102

1103

1104

1105

1107{

1108#ifdef pg_attribute_aligned

1115

1116

1118{

1119#ifdef pg_attribute_aligned

1127

1128#define HIGHBIT (0x80)

1129#define IS_HIGHBIT_SET(ch) ((unsigned char)(ch) & HIGHBIT)

1130

1131

1132

1133

1134

1135

1136

1137#define SQL_STR_DOUBLE(ch, escape_backslash) \

1138 ((ch) == '\'' || ((ch) == '\\' && (escape_backslash)))

1139

1140#define ESCAPE_STRING_SYNTAX 'E'

1143#define STATUS_OK (0)

1144#define STATUS_ERROR (-1)

1145#define STATUS_EOF (-2)

1146

1147

1148

1149

1151#ifndef ENABLE_NLS

1152

1153#define gettext(x) (x)

1154#define dgettext(d,x) (x)

1155#define ngettext(s,p,n) ((n) == 1 ? (s) : (p))

1156#define dngettext(d,s,p,n) ((n) == 1 ? (s) : (p))

1157#endif

1158

1159#define _(x) gettext(x)

1160

1161

1162

1163

1164

1165

1166

1168

1169

1170#define gettext_noop(x) (x)

1171

1172

1173

1174

1175

1176

1177

1178

1179

1180

1181

1182

1183

1184

1185#ifdef SO_MAJOR_VERSION

1186#define PG_TEXTDOMAIN(domain) (domain CppAsString2(SO_MAJOR_VERSION) "-" PG_MAJORVERSION)

1187#else

1188#define PG_TEXTDOMAIN(domain) (domain "-" PG_MAJORVERSION)

1189#endif

1190

1191

1192

1193

1194

1195

1196

1197

1198

1199

1200

1201

1202

1203

1204

1205

1206#if defined(__cplusplus)

1207#define unconstify(underlying_type, expr) const_cast<underlying_type>(expr)

1208#define unvolatize(underlying_type, expr) const_cast<underlying_type>(expr)

1209#elif defined(HAVE__BUILTIN_TYPES_COMPATIBLE_P)

1210#define unconstify(underlying_type, expr) \

1211 (StaticAssertExpr(__builtin_types_compatible_p(__typeof(expr), const underlying_type), \

1212 "wrong cast"), \

1213 (underlying_type) (expr))

1214#define unvolatize(underlying_type, expr) \

1215 (StaticAssertExpr(__builtin_types_compatible_p(__typeof(expr), volatile underlying_type), \

1216 "wrong cast"), \

1217 (underlying_type) (expr))

1219#define unconstify(underlying_type, expr) \

1220 ((underlying_type) (expr))

1221#define unvolatize(underlying_type, expr) \

1222 ((underlying_type) (expr))

1223#endif

1224

1225

1226

1227

1228

1229

1230

1231

1232

1233

1234

1235

1236

1237

1238

1239

1240

1241#if defined(WIN32) || defined(__CYGWIN__)

1242#define PG_BINARY O_BINARY

1243#define PG_BINARY_A "ab"

1244#define PG_BINARY_R "rb"

1245#define PG_BINARY_W "wb"

1247#define PG_BINARY 0

1248#define PG_BINARY_A "a"

1249#define PG_BINARY_R "r"

1250#define PG_BINARY_W "w"

1251#endif

1252

1253

1254

1255

1256

1257

1258#if !HAVE_DECL_FDATASYNC

1259extern int fdatasync(int fildes);

1260#endif

1261

1262

1263

1264

1265

1266

1267#if SIZEOF_LONG == 8

1268#define strtoi64(str, endptr, base) ((int64) strtol(str, endptr, base))

1269#define strtou64(str, endptr, base) ((uint64) strtoul(str, endptr, base))

1270#elif SIZEOF_LONG_LONG == 8

1271#define strtoi64(str, endptr, base) ((int64) strtoll(str, endptr, base))

1272#define strtou64(str, endptr, base) ((uint64) strtoull(str, endptr, base))

1273#else

1274#error "cannot find integer type of the same size as int64_t"

1275#endif

1276

1277

1278

1279

1280#if SIZEOF_LONG == 8

1281#define i64abs(i) ((int64) labs(i))

1282#elif SIZEOF_LONG_LONG == 8

1283#define i64abs(i) ((int64) llabs(i))

1284#else

1285#error "cannot find integer type of the same size as int64_t"

1286#endif

1287

1288

1289

1290

1291

1292

1293#ifndef PGDLLIMPORT

1294#define PGDLLIMPORT

1295#endif

1296

1297

1298

1299

1300

1301

1302

1303

1304

1305#ifndef PGDLLEXPORT

1306#ifdef HAVE_VISIBILITY_ATTRIBUTE

1307#define PGDLLEXPORT __attribute__((visibility("default")))

1308#else

1309#define PGDLLEXPORT

1310#endif

1311#endif

1312

1313

1314

1315

1316

1317

1318

1319

1321

1322#ifndef SIGNAL_ARGS

1323#define SIGNAL_ARGS int postgres_signal_arg

1324#endif

1325

1326

1327

1328

1329

1330

1331

1332#ifdef WIN32

1333#ifdef __MINGW64__

1334typedef intptr_t sigjmp_buf[5];

1335#define sigsetjmp(x,y) __builtin_setjmp(x)

1336#define siglongjmp __builtin_longjmp

1337#else

1338#define sigjmp_buf jmp_buf

1339#define sigsetjmp(x,y) setjmp(x)

1340#define siglongjmp longjmp

1341#endif

1342#endif

1343

1344

1346

1347

1348

1349#endif

static Datum values[MAXATTR]

union PGAlignedBlock PGAlignedBlock

union PGAlignedXLogBlock PGAlignedXLogBlock

pg_noreturn void ExceptionalCondition(const char *conditionName, const char *fileName, int lineNumber)

TransactionId MultiXactId

#define FLEXIBLE_ARRAY_MEMBER

uint32 LocalTransactionId

union PGIOAlignedBlock PGIOAlignedBlock

int fdatasync(int fildes)

void(* pg_funcptr_t)(void)

struct pg_attribute_aligned(8) pg_atomic_uint64

char vl_dat[FLEXIBLE_ARRAY_MEMBER]