tst-rwlock13.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* Copyright (C) 2004 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library 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 GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. #include <pthread.h>
  15. #include <stdio.h>
  16. #include <string.h>
  17. static int
  18. do_test (void)
  19. {
  20. pthread_rwlock_t r;
  21. int ret;
  22. memset (&r, 0xaa, sizeof (r));
  23. if ((ret = pthread_rwlock_init (&r, NULL)) != 0)
  24. {
  25. printf ("rwlock_init failed: %d\n", ret);
  26. return 1;
  27. }
  28. if ((ret = pthread_rwlock_rdlock (&r)) != 0)
  29. {
  30. printf ("rwlock_rdlock failed: %d\n", ret);
  31. return 1;
  32. }
  33. if ((ret = pthread_rwlock_unlock (&r)) != 0)
  34. {
  35. printf ("rwlock_unlock failed: %d\n", ret);
  36. return 1;
  37. }
  38. if ((ret = pthread_rwlock_wrlock (&r)) != 0)
  39. {
  40. printf ("rwlock_wrlock failed: %d\n", ret);
  41. return 1;
  42. }
  43. if ((ret = pthread_rwlock_unlock (&r)) != 0)
  44. {
  45. printf ("second rwlock_unlock failed: %d\n", ret);
  46. return 1;
  47. }
  48. if ((ret = pthread_rwlock_destroy (&r)) != 0)
  49. {
  50. printf ("second rwlock_destroy failed: %d\n", ret);
  51. return 1;
  52. }
  53. return 0;
  54. }
  55. #define TEST_FUNCTION do_test ()
  56. #include "../test-skeleton.c"