socket2.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* Checking macros for socket functions.
  2. Copyright (C) 2005, 2007 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, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. #ifndef _SYS_SOCKET_H
  17. # error "Never include <bits/socket2.h> directly; use <sys/socket.h> instead."
  18. #endif
  19. extern ssize_t __recv_chk (int __fd, void *__buf, size_t __n, size_t __buflen,
  20. int __flags);
  21. extern ssize_t __REDIRECT (__recv_alias, (int __fd, void *__buf, size_t __n,
  22. int __flags), recv);
  23. extern ssize_t __REDIRECT (__recv_chk_warn,
  24. (int __fd, void *__buf, size_t __n, size_t __buflen,
  25. int __flags), __recv_chk)
  26. __warnattr ("recv called with bigger length than size of destination "
  27. "buffer");
  28. __extern_always_inline ssize_t
  29. recv (int __fd, void *__buf, size_t __n, int __flags)
  30. {
  31. if (__bos0 (__buf) != (size_t) -1)
  32. {
  33. if (!__builtin_constant_p (__n))
  34. return __recv_chk (__fd, __buf, __n, __bos0 (__buf), __flags);
  35. if (__n > __bos0 (__buf))
  36. return __recv_chk_warn (__fd, __buf, __n, __bos0 (__buf), __flags);
  37. }
  38. return __recv_alias (__fd, __buf, __n, __flags);
  39. }
  40. extern ssize_t __recvfrom_chk (int __fd, void *__restrict __buf, size_t __n,
  41. size_t __buflen, int __flags,
  42. __SOCKADDR_ARG __addr,
  43. socklen_t *__restrict __addr_len);
  44. extern ssize_t __REDIRECT (__recvfrom_alias,
  45. (int __fd, void *__restrict __buf, size_t __n,
  46. int __flags, __SOCKADDR_ARG __addr,
  47. socklen_t *__restrict __addr_len), recvfrom);
  48. extern ssize_t __REDIRECT (__recvfrom_chk_warn,
  49. (int __fd, void *__restrict __buf, size_t __n,
  50. size_t __buflen, int __flags,
  51. __SOCKADDR_ARG __addr,
  52. socklen_t *__restrict __addr_len), __recvfrom_chk)
  53. __warnattr ("recvfrom called with bigger length than size of "
  54. "destination buffer");
  55. __extern_always_inline ssize_t
  56. recvfrom (int __fd, void *__restrict __buf, size_t __n, int __flags,
  57. __SOCKADDR_ARG __addr, socklen_t *__restrict __addr_len)
  58. {
  59. if (__bos0 (__buf) != (size_t) -1)
  60. {
  61. if (!__builtin_constant_p (__n))
  62. return __recvfrom_chk (__fd, __buf, __n, __bos0 (__buf), __flags,
  63. __addr, __addr_len);
  64. if (__n > __bos0 (__buf))
  65. return __recvfrom_chk_warn (__fd, __buf, __n, __bos0 (__buf), __flags,
  66. __addr, __addr_len);
  67. }
  68. return __recvfrom_alias (__fd, __buf, __n, __flags, __addr, __addr_len);
  69. }