objc-sync.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* GNU Objective C Runtime @synchronized implementation
  2. Copyright (C) 2010-2019 Free Software Foundation, Inc.
  3. Contributed by Nicola Pero <nicola.pero@meta-innovation.com>
  4. This file is part of GCC.
  5. GCC is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3, or (at your option)
  8. any later version.
  9. GCC is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. Under Section 7 of GPL version 3, you are granted additional
  14. permissions described in the GCC Runtime Library Exception, version
  15. 3.1, as published by the Free Software Foundation.
  16. You should have received a copy of the GNU General Public License and
  17. a copy of the GCC Runtime Library Exception along with this program;
  18. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. <http://www.gnu.org/licenses/>. */
  20. #ifndef __objc_sync_INCLUDE_GNU
  21. #define __objc_sync_INCLUDE_GNU
  22. #include "objc.h"
  23. #include "objc-decls.h"
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /* These functions are automatically called by @synchronized(). */
  28. /* 'objc_sync_enter' is automatically called when entering a
  29. @synchronized() block. It locks the recursive lock associated with
  30. 'object'. If 'object' is nil, it does nothing. It returns
  31. OBJC_SYNC_SUCCESS on success; see the enumeration below for error
  32. values.
  33. Note that you should not rely on the behaviour when 'object' is nil
  34. because it could change. */
  35. objc_EXPORT int objc_sync_enter (id object);
  36. /* 'objc_sync_exit' is automatically called when exiting from a
  37. @synchronized() block. It unlocks the recursive lock associated
  38. with 'object'. If 'object' is nil, it does nothing. It returns
  39. OBJC_SYNC_SUCCESS on success; see the enumeration below for error
  40. values. */
  41. objc_EXPORT int objc_sync_exit (id object);
  42. /* All the possible return values for objc_sync_enter() and
  43. objc_sync_exit().
  44. */
  45. enum {
  46. OBJC_SYNC_SUCCESS = 0,
  47. OBJC_SYNC_NOT_OWNING_THREAD_ERROR = -1,
  48. OBJC_SYNC_TIMED_OUT = -2,
  49. OBJC_SYNC_NOT_INITIALIZED = -3
  50. };
  51. #ifdef __cplusplus
  52. }
  53. #endif
  54. #endif /* not __objc_sync_INCLUDE_GNU */