uintn-identity.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Inline functions to return unsigned integer values unchanged.
  2. Copyright (C) 2017-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #if !defined _NETINET_IN_H && !defined _ENDIAN_H
  16. # error "Never use <bits/uintn-identity.h> directly; include <netinet/in.h> or <endian.h> instead."
  17. #endif
  18. #ifndef _BITS_UINTN_IDENTITY_H
  19. #define _BITS_UINTN_IDENTITY_H 1
  20. #include <bits/types.h>
  21. /* These inline functions are to ensure the appropriate type
  22. conversions and associated diagnostics from macros that convert to
  23. a given endianness. */
  24. static __inline __uint16_t
  25. __uint16_identity (__uint16_t __x)
  26. {
  27. return __x;
  28. }
  29. static __inline __uint32_t
  30. __uint32_identity (__uint32_t __x)
  31. {
  32. return __x;
  33. }
  34. static __inline __uint64_t
  35. __uint64_identity (__uint64_t __x)
  36. {
  37. return __x;
  38. }
  39. #endif /* _BITS_UINTN_IDENTITY_H. */