not_unlocked_mutex_test.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * StarPU --- Runtime system for heterogeneous multicore architectures.
  3. *
  4. * Copyright (C) 2012 inria
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. static pthread_mutex_t m;
  18. int
  19. bad_0(void)
  20. {
  21. blah();
  22. _STARPU_PTHREAD_MUTEX_LOCK(&m);
  23. if (err)
  24. return 1;
  25. if (err2)
  26. return 2;
  27. if (err3)
  28. {
  29. lol();
  30. return 3;
  31. }
  32. _STARPU_PTHREAD_MUTEX_UNLOCK(&m);
  33. }
  34. int
  35. good_0(void)
  36. {
  37. _STARPU_PTHREAD_MUTEX_lock(&m);
  38. if (brol)
  39. {
  40. _STARPU_PTHREAD_MUTEX_unlock(&m);
  41. return;
  42. }
  43. _STARPU_PTHREAD_MUTEX_unlock(&m);
  44. }