stdckdint.in.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /* stdckdint.h -- checked integer arithmetic
  2. Copyright 2022-2024 Free Software Foundation, Inc.
  3. This program is free software: you can redistribute it and/or modify it
  4. under the terms of the GNU Lesser General Public License as published
  5. by the Free Software Foundation; either version 2.1 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program. If not, see <https://www.gnu.org/licenses/>. */
  13. #ifndef _GL_STDCKDINT_H
  14. #define _GL_STDCKDINT_H
  15. #include "intprops-internal.h"
  16. /* Store into *R the low-order bits of A + B, A - B, A * B, respectively.
  17. Return 1 if the result overflows, 0 otherwise.
  18. A, B, and *R can have any integer type other than char, bool, a
  19. bit-precise integer type, or an enumeration type.
  20. These are like the standard macros introduced in C23, except that
  21. arguments should not have side effects. */
  22. #define ckd_add(r, a, b) ((bool) _GL_INT_ADD_WRAPV (a, b, r))
  23. #define ckd_sub(r, a, b) ((bool) _GL_INT_SUBTRACT_WRAPV (a, b, r))
  24. #define ckd_mul(r, a, b) ((bool) _GL_INT_MULTIPLY_WRAPV (a, b, r))
  25. #endif /* _GL_STDCKDINT_H */