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