148fb7bfaSmrg /* GNU Objective C Runtime @synchronized implementation 2*b1e83836Smrg Copyright (C) 2010-2022 Free Software Foundation, Inc. 348fb7bfaSmrg Contributed by Nicola Pero <nicola.pero@meta-innovation.com> 448fb7bfaSmrg 548fb7bfaSmrg This file is part of GCC. 648fb7bfaSmrg 748fb7bfaSmrg GCC is free software; you can redistribute it and/or modify 848fb7bfaSmrg it under the terms of the GNU General Public License as published by 948fb7bfaSmrg the Free Software Foundation; either version 3, or (at your option) 1048fb7bfaSmrg any later version. 1148fb7bfaSmrg 1248fb7bfaSmrg GCC is distributed in the hope that it will be useful, 1348fb7bfaSmrg but WITHOUT ANY WARRANTY; without even the implied warranty of 1448fb7bfaSmrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1548fb7bfaSmrg GNU General Public License for more details. 1648fb7bfaSmrg 1748fb7bfaSmrg Under Section 7 of GPL version 3, you are granted additional 1848fb7bfaSmrg permissions described in the GCC Runtime Library Exception, version 1948fb7bfaSmrg 3.1, as published by the Free Software Foundation. 2048fb7bfaSmrg 2148fb7bfaSmrg You should have received a copy of the GNU General Public License and 2248fb7bfaSmrg a copy of the GCC Runtime Library Exception along with this program; 2348fb7bfaSmrg see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 2448fb7bfaSmrg <http://www.gnu.org/licenses/>. */ 2548fb7bfaSmrg 2648fb7bfaSmrg #ifndef __objc_sync_INCLUDE_GNU 2748fb7bfaSmrg #define __objc_sync_INCLUDE_GNU 2848fb7bfaSmrg 2948fb7bfaSmrg #include "objc.h" 3048fb7bfaSmrg #include "objc-decls.h" 3148fb7bfaSmrg 3248fb7bfaSmrg #ifdef __cplusplus 3348fb7bfaSmrg extern "C" { 3448fb7bfaSmrg #endif 3548fb7bfaSmrg 3648fb7bfaSmrg /* These functions are automatically called by @synchronized(). */ 3748fb7bfaSmrg 3848fb7bfaSmrg /* 'objc_sync_enter' is automatically called when entering a 3948fb7bfaSmrg @synchronized() block. It locks the recursive lock associated with 4048fb7bfaSmrg 'object'. If 'object' is nil, it does nothing. It returns 4148fb7bfaSmrg OBJC_SYNC_SUCCESS on success; see the enumeration below for error 4248fb7bfaSmrg values. 4348fb7bfaSmrg 4448fb7bfaSmrg Note that you should not rely on the behaviour when 'object' is nil 4548fb7bfaSmrg because it could change. */ 4648fb7bfaSmrg objc_EXPORT int objc_sync_enter (id object); 4748fb7bfaSmrg 4848fb7bfaSmrg /* 'objc_sync_exit' is automatically called when exiting from a 4948fb7bfaSmrg @synchronized() block. It unlocks the recursive lock associated 5048fb7bfaSmrg with 'object'. If 'object' is nil, it does nothing. It returns 5148fb7bfaSmrg OBJC_SYNC_SUCCESS on success; see the enumeration below for error 5248fb7bfaSmrg values. */ 5348fb7bfaSmrg objc_EXPORT int objc_sync_exit (id object); 5448fb7bfaSmrg 5548fb7bfaSmrg /* All the possible return values for objc_sync_enter() and 5648fb7bfaSmrg objc_sync_exit(). 5748fb7bfaSmrg */ 5848fb7bfaSmrg enum { 5948fb7bfaSmrg OBJC_SYNC_SUCCESS = 0, 6048fb7bfaSmrg OBJC_SYNC_NOT_OWNING_THREAD_ERROR = -1, 6148fb7bfaSmrg OBJC_SYNC_TIMED_OUT = -2, 6248fb7bfaSmrg OBJC_SYNC_NOT_INITIALIZED = -3 6348fb7bfaSmrg }; 6448fb7bfaSmrg 6548fb7bfaSmrg #ifdef __cplusplus 6648fb7bfaSmrg } 6748fb7bfaSmrg #endif 6848fb7bfaSmrg 6948fb7bfaSmrg #endif /* not __objc_sync_INCLUDE_GNU */ 70