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