PostgreSQL Source Code  git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
int.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static bool pg_add_s16_overflow (int16 a, int16 b, int16 *result)
 
static bool pg_sub_s16_overflow (int16 a, int16 b, int16 *result)
 
static bool pg_mul_s16_overflow (int16 a, int16 b, int16 *result)
 
static uint16 pg_abs_s16 (int16 a)
 
static bool pg_add_s32_overflow (int32 a, int32 b, int32 *result)
 
static bool pg_sub_s32_overflow (int32 a, int32 b, int32 *result)
 
static bool pg_mul_s32_overflow (int32 a, int32 b, int32 *result)
 
static uint32 pg_abs_s32 (int32 a)
 
static bool pg_add_s64_overflow (int64 a, int64 b, int64 *result)
 
static bool pg_sub_s64_overflow (int64 a, int64 b, int64 *result)
 
static bool pg_mul_s64_overflow (int64 a, int64 b, int64 *result)
 
static uint64 pg_abs_s64 (int64 a)
 
static bool pg_add_u16_overflow (uint16 a, uint16 b, uint16 *result)
 
static bool pg_sub_u16_overflow (uint16 a, uint16 b, uint16 *result)
 
static bool pg_mul_u16_overflow (uint16 a, uint16 b, uint16 *result)
 
static bool pg_neg_u16_overflow (uint16 a, int16 *result)
 
static bool pg_add_u32_overflow (uint32 a, uint32 b, uint32 *result)
 
static bool pg_sub_u32_overflow (uint32 a, uint32 b, uint32 *result)
 
static bool pg_mul_u32_overflow (uint32 a, uint32 b, uint32 *result)
 
static bool pg_neg_u32_overflow (uint32 a, int32 *result)
 
static bool pg_add_u64_overflow (uint64 a, uint64 b, uint64 *result)
 
static bool pg_sub_u64_overflow (uint64 a, uint64 b, uint64 *result)
 
static bool pg_mul_u64_overflow (uint64 a, uint64 b, uint64 *result)
 
static bool pg_neg_u64_overflow (uint64 a, int64 *result)
 
static int pg_cmp_s16 (int16 a, int16 b)
 
static int pg_cmp_u16 (uint16 a, uint16 b)
 
static int pg_cmp_s32 (int32 a, int32 b)
 
static int pg_cmp_u32 (uint32 a, uint32 b)
 
static int pg_cmp_s64 (int64 a, int64 b)
 
static int pg_cmp_u64 (uint64 a, uint64 b)
 
static int pg_cmp_size (size_t a, size_t b)
 

Function Documentation

◆ pg_abs_s16()

static uint16 pg_abs_s16 ( int16  a)
inlinestatic

Definition at line 121 of file int.h.

122 {
123  /*
124  * This first widens the argument from int16 to int32 for use with abs().
125  * The result is then narrowed from int32 to uint16. This prevents any
126  * possibility of overflow.
127  */
128  return (uint16) abs((int32) a);
129 }
unsigned short uint16
Definition: c.h:517
signed int int32
Definition: c.h:508
int a
Definition: isn.c:68

References a.

◆ pg_abs_s32()

static uint32 pg_abs_s32 ( int32  a)
inlinestatic

Definition at line 189 of file int.h.

190 {
191  /*
192  * This first widens the argument from int32 to int64 for use with
193  * i64abs(). The result is then narrowed from int64 to uint32. This
194  * prevents any possibility of overflow.
195  */
196  return (uint32) i64abs((int64) a);
197 }
unsigned int uint32
Definition: c.h:518
#define i64abs(i)
Definition: c.h:1310

References a, and i64abs.

Referenced by jsonb_array_element(), jsonb_array_element_text(), jsonb_delete_idx(), power_var_int(), and setPathArray().

◆ pg_abs_s64()

static uint64 pg_abs_s64 ( int64  a)
inlinestatic

Definition at line 304 of file int.h.

305 {
306  if (unlikely(a == PG_INT64_MIN))
307  return (uint64) PG_INT64_MAX + 1;
308  return (uint64) i64abs(a);
309 }
#define PG_INT64_MAX
Definition: c.h:595
#define PG_INT64_MIN
Definition: c.h:594
#define unlikely(x)
Definition: c.h:326

References a, i64abs, PG_INT64_MAX, PG_INT64_MIN, and unlikely.

Referenced by cash_out(), and int64_to_numericvar().

◆ pg_add_s16_overflow()

static bool pg_add_s16_overflow ( int16  a,
int16  b,
int16 result 
)
inlinestatic

Definition at line 67 of file int.h.

68 {
69 #if defined(HAVE__BUILTIN_OP_OVERFLOW)
70  return __builtin_add_overflow(a, b, result);
71 #else
72  int32 res = (int32) a + (int32) b;
73 
74  if (res > PG_INT16_MAX || res < PG_INT16_MIN)
75  {
76  *result = 0x5EED; /* to avoid spurious warnings */
77  return true;
78  }
79  *result = (int16) res;
80  return false;
81 #endif
82 }
signed short int16
Definition: c.h:507
#define PG_INT16_MIN
Definition: c.h:588
#define PG_INT16_MAX
Definition: c.h:589
int b
Definition: isn.c:69

References a, b, PG_INT16_MAX, PG_INT16_MIN, and res.

Referenced by AdjustNotNullInheritance(), ATExecAddColumn(), ATExecSetNotNull(), ConstraintSetParentConstraint(), int2pl(), MergeAttributesIntoExisting(), MergeCheckConstraint(), MergeConstraintsIntoExisting(), MergeInheritedAttribute(), and MergeWithExistingConstraint().

◆ pg_add_s32_overflow()

static bool pg_add_s32_overflow ( int32  a,
int32  b,
int32 result 
)
inlinestatic

Definition at line 135 of file int.h.

136 {
137 #if defined(HAVE__BUILTIN_OP_OVERFLOW)
138  return __builtin_add_overflow(a, b, result);
139 #else
140  int64 res = (int64) a + (int64) b;
141 
142  if (res > PG_INT32_MAX || res < PG_INT32_MIN)
143  {
144  *result = 0x5EED; /* to avoid spurious warnings */
145  return true;
146  }
147  *result = (int32) res;
148  return false;
149 #endif
150 }
#define PG_INT32_MAX
Definition: c.h:592
#define PG_INT32_MIN
Definition: c.h:591

References a, b, PG_INT32_MAX, PG_INT32_MIN, and res.

Referenced by AdjustDays(), AdjustFractDays(), AdjustFractYears(), AdjustMonths(), AdjustYears(), array_append(), array_set_element(), array_set_element_expanded(), array_set_slice(), ArrayCheckBoundsSafe(), bit_overlay(), bitsubstring(), bytea_overlay(), bytea_substring(), detoast_attr_slice(), finite_interval_pl(), generate_series_step_int4(), in_range_int2_int4(), in_range_int4_int4(), int24pl(), int42pl(), int4inc(), int4pl(), interval_div(), interval_justify_days(), interval_justify_hours(), interval_justify_interval(), interval_mul(), lpad(), make_interval(), ReadArrayDimensions(), repeat(), rpad(), text_format_parse_digits(), text_overlay(), text_substring(), timestamp_pl_interval(), timestamptz_pl_interval_internal(), translate(), and width_bucket_float8().

◆ pg_add_s64_overflow()

static bool pg_add_s64_overflow ( int64  a,
int64  b,
int64 *  result 
)
inlinestatic

Definition at line 203 of file int.h.

204 {
205 #if defined(HAVE__BUILTIN_OP_OVERFLOW)
206  return __builtin_add_overflow(a, b, result);
207 #elif defined(HAVE_INT128)
208  int128 res = (int128) a + (int128) b;
209 
210  if (res > PG_INT64_MAX || res < PG_INT64_MIN)
211  {
212  *result = 0x5EED; /* to avoid spurious warnings */
213  return true;
214  }
215  *result = (int64) res;
216  return false;
217 #else
218  if ((a > 0 && b > 0 && a > PG_INT64_MAX - b) ||
219  (a < 0 && b < 0 && a < PG_INT64_MIN - b))
220  {
221  *result = 0x5EED; /* to avoid spurious warnings */
222  return true;
223  }
224  *result = a + b;
225  return false;
226 #endif
227 }

References a, b, PG_INT64_MAX, PG_INT64_MIN, and res.

Referenced by AdjustFractMicroseconds(), AdjustIntervalForTypmod(), cash_pl_cash(), DecodeInterval(), evalStandardFunc(), finite_interval_pl(), generate_series_step_int8(), in_range_int4_int8(), in_range_int8_int8(), in_range_time_interval(), in_range_timetz_interval(), int28pl(), int48pl(), int64_multiply_add(), int82pl(), int84pl(), int8inc(), int8pl(), interval_part_common(), itm2interval(), make_interval(), make_timestamp_internal(), timestamp_bin(), timestamp_pl_interval(), timestamptz_bin(), timestamptz_pl_interval_internal(), and tm2timestamp().

◆ pg_add_u16_overflow()

static bool pg_add_u16_overflow ( uint16  a,
uint16  b,
uint16 result 
)
inlinestatic

Definition at line 320 of file int.h.

321 {
322 #if defined(HAVE__BUILTIN_OP_OVERFLOW)
323  return __builtin_add_overflow(a, b, result);
324 #else
325  uint16 res = a + b;
326 
327  if (res < a)
328  {
329  *result = 0x5EED; /* to avoid spurious warnings */
330  return true;
331  }
332  *result = res;
333  return false;
334 #endif
335 }

References a, b, and res.

◆ pg_add_u32_overflow()

static bool pg_add_u32_overflow ( uint32  a,
uint32  b,
uint32 result 
)
inlinestatic

Definition at line 393 of file int.h.

394 {
395 #if defined(HAVE__BUILTIN_OP_OVERFLOW)
396  return __builtin_add_overflow(a, b, result);
397 #else
398  uint32 res = a + b;
399 
400  if (res < a)
401  {
402  *result = 0x5EED; /* to avoid spurious warnings */
403  return true;
404  }
405  *result = res;
406  return false;
407 #endif
408 }

References a, b, and res.

◆ pg_add_u64_overflow()

static bool pg_add_u64_overflow ( uint64  a,
uint64  b,
uint64 *  result 
)
inlinestatic

Definition at line 466 of file int.h.

467 {
468 #if defined(HAVE__BUILTIN_OP_OVERFLOW)
469  return __builtin_add_overflow(a, b, result);
470 #else
471  uint64 res = a + b;
472 
473  if (res < a)
474  {
475  *result = 0x5EED; /* to avoid spurious warnings */
476  return true;
477  }
478  *result = res;
479  return false;
480 #endif
481 }

References a, b, and res.

Referenced by basic_archive_file(), and numericvar_to_uint64().

◆ pg_cmp_s16()

static int pg_cmp_s16 ( int16  a,
int16  b 
)
inlinestatic

Definition at line 586 of file int.h.

587 {
588  return (int32) a - (int32) b;
589 }

References a, and b.

Referenced by _bt_delitems_cmp(), _bt_splitcmp(), AttrDefaultCmp(), and cmpNodePtr().

◆ pg_cmp_s32()

static int pg_cmp_s32 ( int32  a,
int32  b 
)
inlinestatic

◆ pg_cmp_s64()

static int pg_cmp_s64 ( int64  a,
int64  b 
)
inlinestatic

Definition at line 610 of file int.h.

611 {
612  return (a > b) - (a < b);
613 }

References a, and b.

◆ pg_cmp_size()

static int pg_cmp_size ( size_t  a,
size_t  b 
)
inlinestatic

Definition at line 622 of file int.h.

623 {
624  return (a > b) - (a < b);
625 }

References a, and b.

Referenced by library_name_compare().

◆ pg_cmp_u16()

static int pg_cmp_u16 ( uint16  a,
uint16  b 
)
inlinestatic

Definition at line 592 of file int.h.

593 {
594  return (int32) a - (int32) b;
595 }

References a, and b.

Referenced by cmpOffsetNumbers().

◆ pg_cmp_u32()

static int pg_cmp_u32 ( uint32  a,
uint32  b 
)
inlinestatic

◆ pg_cmp_u64()

static int pg_cmp_u64 ( uint64  a,
uint64  b 
)
inlinestatic

Definition at line 616 of file int.h.

617 {
618  return (a > b) - (a < b);
619 }

References a, and b.

Referenced by cmp_lsn(), file_sort_by_lsn(), ginCompareItemPointers(), key_cmp(), and ListComparatorForWalSummaryFiles().

◆ pg_mul_s16_overflow()

static bool pg_mul_s16_overflow ( int16  a,
int16  b,
int16 result 
)
inlinestatic

Definition at line 103 of file int.h.

104 {
105 #if defined(HAVE__BUILTIN_OP_OVERFLOW)
106  return __builtin_mul_overflow(a, b, result);
107 #else
108  int32 res = (int32) a * (int32) b;
109 
110  if (res > PG_INT16_MAX || res < PG_INT16_MIN)
111  {
112  *result = 0x5EED; /* to avoid spurious warnings */
113  return true;
114  }
115  *result = (int16) res;
116  return false;
117 #endif
118 }

References a, b, PG_INT16_MAX, PG_INT16_MIN, and res.

Referenced by int2mul().

◆ pg_mul_s32_overflow()

static bool pg_mul_s32_overflow ( int32  a,
int32  b,
int32 result 
)
inlinestatic

Definition at line 171 of file int.h.

172 {
173 #if defined(HAVE__BUILTIN_OP_OVERFLOW)
174  return __builtin_mul_overflow(a, b, result);
175 #else
176  int64 res = (int64) a * (int64) b;
177 
178  if (res > PG_INT32_MAX || res < PG_INT32_MIN)
179  {
180  *result = 0x5EED; /* to avoid spurious warnings */
181  return true;
182  }
183  *result = (int32) res;
184  return false;
185 #endif
186 }

References a, b, PG_INT32_MAX, PG_INT32_MIN, and res.

Referenced by AdjustDays(), AdjustYears(), int24mul(), int42mul(), int4lcm(), int4mul(), lpad(), make_interval(), repeat(), rpad(), text_format_parse_digits(), text_substring(), and translate().

◆ pg_mul_s64_overflow()

static bool pg_mul_s64_overflow ( int64  a,
int64  b,
int64 *  result 
)
inlinestatic

Definition at line 261 of file int.h.

262 {
263 #if defined(HAVE__BUILTIN_OP_OVERFLOW)
264  return __builtin_mul_overflow(a, b, result);
265 #elif defined(HAVE_INT128)
266  int128 res = (int128) a * (int128) b;
267 
268  if (res > PG_INT64_MAX || res < PG_INT64_MIN)
269  {
270  *result = 0x5EED; /* to avoid spurious warnings */
271  return true;
272  }
273  *result = (int64) res;
274  return false;
275 #else
276  /*
277  * Overflow can only happen if at least one value is outside the range
278  * sqrt(min)..sqrt(max) so check that first as the division can be quite a
279  * bit more expensive than the multiplication.
280  *
281  * Multiplying by 0 or 1 can't overflow of course and checking for 0
282  * separately avoids any risk of dividing by 0. Be careful about dividing
283  * INT_MIN by -1 also, note reversing the a and b to ensure we're always
284  * dividing it by a positive value.
285  *
286  */
287  if ((a > PG_INT32_MAX || a < PG_INT32_MIN ||
288  b > PG_INT32_MAX || b < PG_INT32_MIN) &&
289  a != 0 && a != 1 && b != 0 && b != 1 &&
290  ((a > 0 && b > 0 && a > PG_INT64_MAX / b) ||
291  (a > 0 && b < 0 && b < PG_INT64_MIN / a) ||
292  (a < 0 && b > 0 && a < PG_INT64_MIN / b) ||
293  (a < 0 && b < 0 && a < PG_INT64_MAX / b)))
294  {
295  *result = 0x5EED; /* to avoid spurious warnings */
296  return true;
297  }
298  *result = a * b;
299  return false;
300 #endif
301 }

References a, b, PG_INT32_MAX, PG_INT32_MIN, PG_INT64_MAX, PG_INT64_MIN, and res.

Referenced by cash_in(), cash_mul_int64(), DecodeInterval(), evalStandardFunc(), int28mul(), int48mul(), int64_div_fast_to_numeric(), int64_multiply_add(), int82mul(), int84mul(), int8lcm(), int8mul(), interval_part_common(), itm2interval(), make_timestamp_internal(), numericvar_to_int64(), strtoint64(), timestamp_bin(), timestamptz_bin(), and tm2timestamp().

◆ pg_mul_u16_overflow()

static bool pg_mul_u16_overflow ( uint16  a,
uint16  b,
uint16 result 
)
inlinestatic

Definition at line 354 of file int.h.

355 {
356 #if defined(HAVE__BUILTIN_OP_OVERFLOW)
357  return __builtin_mul_overflow(a, b, result);
358 #else
359  uint32 res = (uint32) a * (uint32) b;
360 
361  if (res > PG_UINT16_MAX)
362  {
363  *result = 0x5EED; /* to avoid spurious warnings */
364  return true;
365  }
366  *result = (uint16) res;
367  return false;
368 #endif
369 }
#define PG_UINT16_MAX
Definition: c.h:590

References a, b, PG_UINT16_MAX, and res.

◆ pg_mul_u32_overflow()

static bool pg_mul_u32_overflow ( uint32  a,
uint32  b,
uint32 result 
)
inlinestatic

Definition at line 427 of file int.h.

428 {
429 #if defined(HAVE__BUILTIN_OP_OVERFLOW)
430  return __builtin_mul_overflow(a, b, result);
431 #else
432  uint64 res = (uint64) a * (uint64) b;
433 
434  if (res > PG_UINT32_MAX)
435  {
436  *result = 0x5EED; /* to avoid spurious warnings */
437  return true;
438  }
439  *result = (uint32) res;
440  return false;
441 #endif
442 }
#define PG_UINT32_MAX
Definition: c.h:593

References a, b, PG_UINT32_MAX, and res.

◆ pg_mul_u64_overflow()

static bool pg_mul_u64_overflow ( uint64  a,
uint64  b,
uint64 *  result 
)
inlinestatic

Definition at line 500 of file int.h.

501 {
502 #if defined(HAVE__BUILTIN_OP_OVERFLOW)
503  return __builtin_mul_overflow(a, b, result);
504 #elif defined(HAVE_INT128)
505  uint128 res = (uint128) a * (uint128) b;
506 
507  if (res > PG_UINT64_MAX)
508  {
509  *result = 0x5EED; /* to avoid spurious warnings */
510  return true;
511  }
512  *result = (uint64) res;
513  return false;
514 #else
515  uint64 res = a * b;
516 
517  if (a != 0 && b != res / a)
518  {
519  *result = 0x5EED; /* to avoid spurious warnings */
520  return true;
521  }
522  *result = res;
523  return false;
524 #endif
525 }
#define PG_UINT64_MAX
Definition: c.h:596

References a, b, PG_UINT64_MAX, and res.

Referenced by basic_archive_file(), and numericvar_to_uint64().

◆ pg_neg_u16_overflow()

static bool pg_neg_u16_overflow ( uint16  a,
int16 result 
)
inlinestatic

Definition at line 372 of file int.h.

373 {
374 #if defined(HAVE__BUILTIN_OP_OVERFLOW)
375  return __builtin_sub_overflow(0, a, result);
376 #else
377  int32 res = -((int32) a);
378 
379  if (unlikely(res < PG_INT16_MIN))
380  {
381  *result = 0x5EED; /* to avoid spurious warnings */
382  return true;
383  }
384  *result = res;
385  return false;
386 #endif
387 }

References a, PG_INT16_MIN, res, and unlikely.

Referenced by pg_strtoint16_safe().

◆ pg_neg_u32_overflow()

static bool pg_neg_u32_overflow ( uint32  a,
int32 result 
)
inlinestatic

Definition at line 445 of file int.h.

446 {
447 #if defined(HAVE__BUILTIN_OP_OVERFLOW)
448  return __builtin_sub_overflow(0, a, result);
449 #else
450  int64 res = -((int64) a);
451 
452  if (unlikely(res < PG_INT32_MIN))
453  {
454  *result = 0x5EED; /* to avoid spurious warnings */
455  return true;
456  }
457  *result = res;
458  return false;
459 #endif
460 }

References a, PG_INT32_MIN, res, and unlikely.

Referenced by pg_strtoint32_safe().

◆ pg_neg_u64_overflow()

static bool pg_neg_u64_overflow ( uint64  a,
int64 *  result 
)
inlinestatic

Definition at line 528 of file int.h.

529 {
530 #if defined(HAVE__BUILTIN_OP_OVERFLOW)
531  return __builtin_sub_overflow(0, a, result);
532 #elif defined(HAVE_INT128)
533  int128 res = -((int128) a);
534 
535  if (unlikely(res < PG_INT64_MIN))
536  {
537  *result = 0x5EED; /* to avoid spurious warnings */
538  return true;
539  }
540  *result = res;
541  return false;
542 #else
543  if (unlikely(a > (uint64) PG_INT64_MAX + 1))
544  {
545  *result = 0x5EED; /* to avoid spurious warnings */
546  return true;
547  }
548  if (unlikely(a == (uint64) PG_INT64_MAX + 1))
549  *result = PG_INT64_MIN;
550  else
551  *result = -((int64) a);
552  return false;
553 #endif
554 }

References a, PG_INT64_MAX, PG_INT64_MIN, res, and unlikely.

Referenced by pg_strtoint64_safe().

◆ pg_sub_s16_overflow()

static bool pg_sub_s16_overflow ( int16  a,
int16  b,
int16 result 
)
inlinestatic

Definition at line 85 of file int.h.

86 {
87 #if defined(HAVE__BUILTIN_OP_OVERFLOW)
88  return __builtin_sub_overflow(a, b, result);
89 #else
90  int32 res = (int32) a - (int32) b;
91 
92  if (res > PG_INT16_MAX || res < PG_INT16_MIN)
93  {
94  *result = 0x5EED; /* to avoid spurious warnings */
95  return true;
96  }
97  *result = (int16) res;
98  return false;
99 #endif
100 }

References a, b, PG_INT16_MAX, PG_INT16_MIN, and res.

Referenced by int2_dist(), and int2mi().

◆ pg_sub_s32_overflow()

static bool pg_sub_s32_overflow ( int32  a,
int32  b,
int32 result 
)
inlinestatic

Definition at line 153 of file int.h.

154 {
155 #if defined(HAVE__BUILTIN_OP_OVERFLOW)
156  return __builtin_sub_overflow(a, b, result);
157 #else
158  int64 res = (int64) a - (int64) b;
159 
160  if (res > PG_INT32_MAX || res < PG_INT32_MIN)
161  {
162  *result = 0x5EED; /* to avoid spurious warnings */
163  return true;
164  }
165  *result = (int32) res;
166  return false;
167 #endif
168 }

References a, b, PG_INT32_MAX, PG_INT32_MIN, and res.

Referenced by array_prepend(), array_set_element(), array_set_element_expanded(), array_set_slice(), finite_interval_mi(), int24mi(), int42mi(), int4_dist(), int4mi(), interval_um_internal(), and ReadArrayDimensions().

◆ pg_sub_s64_overflow()

static bool pg_sub_s64_overflow ( int64  a,
int64  b,
int64 *  result 
)
inlinestatic

Definition at line 230 of file int.h.

231 {
232 #if defined(HAVE__BUILTIN_OP_OVERFLOW)
233  return __builtin_sub_overflow(a, b, result);
234 #elif defined(HAVE_INT128)
235  int128 res = (int128) a - (int128) b;
236 
237  if (res > PG_INT64_MAX || res < PG_INT64_MIN)
238  {
239  *result = 0x5EED; /* to avoid spurious warnings */
240  return true;
241  }
242  *result = (int64) res;
243  return false;
244 #else
245  /*
246  * Note: overflow is also possible when a == 0 and b < 0 (specifically,
247  * when b == PG_INT64_MIN).
248  */
249  if ((a < 0 && b > 0 && a < PG_INT64_MIN + b) ||
250  (a >= 0 && b < 0 && a > PG_INT64_MAX + b))
251  {
252  *result = 0x5EED; /* to avoid spurious warnings */
253  return true;
254  }
255  *result = a - b;
256  return false;
257 #endif
258 }

References a, b, PG_INT64_MAX, PG_INT64_MIN, and res.

Referenced by AdjustIntervalForTypmod(), cash_dist(), cash_in(), cash_mi_cash(), evalStandardFunc(), finite_interval_mi(), generate_series_timestamp_support(), int28mi(), int48mi(), int82mi(), int84mi(), int8_dist(), int8dec(), int8mi(), interval_um_internal(), numericvar_to_int64(), strtoint64(), timestamp_bin(), timestamp_mi(), TimestampDifferenceMilliseconds(), and timestamptz_bin().

◆ pg_sub_u16_overflow()

static bool pg_sub_u16_overflow ( uint16  a,
uint16  b,
uint16 result 
)
inlinestatic

Definition at line 338 of file int.h.

339 {
340 #if defined(HAVE__BUILTIN_OP_OVERFLOW)
341  return __builtin_sub_overflow(a, b, result);
342 #else
343  if (b > a)
344  {
345  *result = 0x5EED; /* to avoid spurious warnings */
346  return true;
347  }
348  *result = a - b;
349  return false;
350 #endif
351 }

References a, and b.

◆ pg_sub_u32_overflow()

static bool pg_sub_u32_overflow ( uint32  a,
uint32  b,
uint32 result 
)
inlinestatic

Definition at line 411 of file int.h.

412 {
413 #if defined(HAVE__BUILTIN_OP_OVERFLOW)
414  return __builtin_sub_overflow(a, b, result);
415 #else
416  if (b > a)
417  {
418  *result = 0x5EED; /* to avoid spurious warnings */
419  return true;
420  }
421  *result = a - b;
422  return false;
423 #endif
424 }

References a, and b.

◆ pg_sub_u64_overflow()

static bool pg_sub_u64_overflow ( uint64  a,
uint64  b,
uint64 *  result 
)
inlinestatic

Definition at line 484 of file int.h.

485 {
486 #if defined(HAVE__BUILTIN_OP_OVERFLOW)
487  return __builtin_sub_overflow(a, b, result);
488 #else
489  if (b > a)
490  {
491  *result = 0x5EED; /* to avoid spurious warnings */
492  return true;
493  }
494  *result = a - b;
495  return false;
496 #endif
497 }

References a, and b.