atomic.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef SCM_ATOMIC_H
  2. #define SCM_ATOMIC_H
  3. /* Copyright 2016,2018
  4. Free Software Foundation, Inc.
  5. This file is part of Guile.
  6. Guile is free software: you can redistribute it and/or modify it
  7. under the terms of the GNU Lesser General Public License as published
  8. by the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Guile is distributed in the hope that it will be useful, but WITHOUT
  11. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  13. License for more details.
  14. You should have received a copy of the GNU Lesser General Public
  15. License along with Guile. If not, see
  16. <https://www.gnu.org/licenses/>. */
  17. #include "libguile/gc.h"
  18. static inline int
  19. scm_is_atomic_box (SCM obj)
  20. {
  21. return SCM_HAS_TYP7 (obj, scm_tc7_atomic_box);
  22. }
  23. static inline SCM*
  24. scm_atomic_box_loc (SCM obj)
  25. {
  26. return SCM_CELL_OBJECT_LOC (obj, 1);
  27. }
  28. #define SCM_VALIDATE_ATOMIC_BOX(pos, var) \
  29. do { \
  30. SCM_ASSERT_TYPE (scm_is_atomic_box (var), var, pos, FUNC_NAME, \
  31. "atomic box"); \
  32. } while (0)
  33. #ifdef BUILDING_LIBGUILE
  34. SCM_INTERNAL SCM scm_make_atomic_box (SCM init);
  35. SCM_INTERNAL SCM scm_atomic_box_p (SCM obj);
  36. SCM_INTERNAL SCM scm_atomic_box_ref (SCM box);
  37. SCM_INTERNAL SCM scm_atomic_box_set_x (SCM box, SCM val);
  38. SCM_INTERNAL SCM scm_atomic_box_swap_x (SCM box, SCM val);
  39. SCM_INTERNAL SCM scm_atomic_box_compare_and_swap_x (SCM box, SCM expected, SCM desired);
  40. SCM_INTERNAL void scm_i_atomic_box_print (SCM box, SCM port, scm_print_state *pstate);
  41. SCM_INTERNAL void scm_register_atomic (void);
  42. #endif /* BUILDING_LIBGUILE */
  43. #endif /* SCM_ATOMIC_H */