tst-cmsghdr.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* Test ancillary data header creation.
  2. Copyright (C) 2022-2026 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. <https://www.gnu.org/licenses/>. */
  15. #include <sys/socket.h>
  16. #include <gnu/lib-names.h>
  17. #include <support/xdlfcn.h>
  18. #include <support/check.h>
  19. #define PAYLOAD "Hello, World!"
  20. /* CMSG_NXTHDR is a macro that calls an inline function defined in
  21. bits/socket.h. In case the function cannot be inlined, libc.so carries
  22. a copy. Both versions need to be tested. */
  23. #define CMSG_NXTHDR_IMPL CMSG_NXTHDR
  24. #include "tst-cmsghdr-skeleton.c"
  25. #undef CMSG_NXTHDR_IMPL
  26. static struct cmsghdr * (* cmsg_nxthdr) (struct msghdr *, struct cmsghdr *);
  27. #define CMSG_NXTHDR_IMPL cmsg_nxthdr
  28. #include "tst-cmsghdr-skeleton.c"
  29. #undef CMSG_NXTHDR_IMPL
  30. static int
  31. do_test (void)
  32. {
  33. static void *handle;
  34. run_test_CMSG_NXTHDR ();
  35. handle = xdlopen (LIBC_SO, RTLD_LAZY);
  36. cmsg_nxthdr = (struct cmsghdr * (*) (struct msghdr *, struct cmsghdr *))
  37. xdlsym (handle, "__cmsg_nxthdr");
  38. run_test_cmsg_nxthdr ();
  39. return 0;
  40. }
  41. #include <support/test-driver.c>