missing.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. *
  3. * Embedded Linux library
  4. *
  5. * Copyright (C) 2011-2014 Intel Corporation. All rights reserved.
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. */
  22. #include <sys/syscall.h>
  23. #include <sys/socket.h>
  24. #ifndef __NR_getrandom
  25. # if defined __x86_64__
  26. # define __NR_getrandom 318
  27. # elif defined(__i386__)
  28. # define __NR_getrandom 355
  29. # elif defined(__arm__)
  30. # define __NR_getrandom 384
  31. # elif defined(__aarch64__)
  32. # define __NR_getrandom 278
  33. # elif defined(__ia64__)
  34. # define __NR_getrandom 1339
  35. # elif defined(__m68k__)
  36. # define __NR_getrandom 352
  37. # elif defined(__s390x__)
  38. # define __NR_getrandom 349
  39. # elif defined(__powerpc__)
  40. # define __NR_getrandom 359
  41. # elif defined _MIPS_SIM
  42. # if _MIPS_SIM == _MIPS_SIM_ABI32
  43. # define __NR_getrandom 4353
  44. # endif
  45. # if _MIPS_SIM == _MIPS_SIM_NABI32
  46. # define __NR_getrandom 6317
  47. # endif
  48. # if _MIPS_SIM == _MIPS_SIM_ABI64
  49. # define __NR_getrandom 5313
  50. # endif
  51. # else
  52. # warning "__NR_getrandom unknown for your architecture"
  53. # define __NR_getrandom 0xffffffff
  54. # endif
  55. #endif
  56. #ifndef HAVE_EXPLICIT_BZERO
  57. static inline void explicit_bzero(void *s, size_t n)
  58. {
  59. memset(s, 0, n);
  60. __asm__ __volatile__ ("" : : "r"(s) : "memory");
  61. }
  62. #endif
  63. #ifndef SO_BINDTOIFINDEX
  64. #define SO_BINDTOIFINDEX 62
  65. #endif
  66. #ifndef HAVE_RAWMEMCHR
  67. static inline void *rawmemchr(const void *s, int c)
  68. {
  69. _Pragma("GCC diagnostic push")
  70. _Pragma("GCC diagnostic ignored \"-Wstringop-overflow=\"")
  71. return memchr(s, c, (size_t) -1);
  72. _Pragma("GCC diagnostic pop")
  73. }
  74. #endif