flag.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Copyright (C) 2015-2022 Free Software Foundation, Inc.
  2. This file is part of the GNU Atomic Library (libatomic).
  3. Libatomic is free software; you can redistribute it and/or modify it
  4. under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
  8. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  10. more details.
  11. Under Section 7 of GPL version 3, you are granted additional
  12. permissions described in the GCC Runtime Library Exception, version
  13. 3.1, as published by the Free Software Foundation.
  14. You should have received a copy of the GNU General Public License and
  15. a copy of the GCC Runtime Library Exception along with this program;
  16. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  17. <http://www.gnu.org/licenses/>. */
  18. #include "libatomic_i.h"
  19. #include <stdatomic.h>
  20. /* Out-of-line versions of <stdatomic.h> flag functions. */
  21. /* Atomically set *OBJECT to true, returning the previous value. */
  22. _Bool
  23. (atomic_flag_test_and_set) (volatile atomic_flag *object)
  24. {
  25. return atomic_flag_test_and_set (object);
  26. }
  27. /* Atomically set *OBJECT to true, returning the previous value, with
  28. memory affected according to ORDER. */
  29. _Bool
  30. (atomic_flag_test_and_set_explicit) (volatile atomic_flag *object,
  31. memory_order order)
  32. {
  33. return atomic_flag_test_and_set_explicit (object, order);
  34. }
  35. /* Atomically set *OBJECT to false. */
  36. void
  37. (atomic_flag_clear) (volatile atomic_flag *object)
  38. {
  39. atomic_flag_clear (object);
  40. }
  41. /* Atomically set *OBJECT to false, with memory affected according to
  42. ORDER. */
  43. void
  44. (atomic_flag_clear_explicit) (volatile atomic_flag *object,
  45. memory_order order)
  46. {
  47. return atomic_flag_clear_explicit (object, order);
  48. }