| 1 |
739 |
jeremybenn |
/* GNU Objective C Runtime @synchronized implementation
|
| 2 |
|
|
Copyright (C) 2010 Free Software Foundation, Inc.
|
| 3 |
|
|
Contributed by Nicola Pero <nicola.pero@meta-innovation.com>
|
| 4 |
|
|
|
| 5 |
|
|
This file is part of GCC.
|
| 6 |
|
|
|
| 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)
|
| 10 |
|
|
any later version.
|
| 11 |
|
|
|
| 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.
|
| 16 |
|
|
|
| 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.
|
| 20 |
|
|
|
| 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/>. */
|
| 25 |
|
|
|
| 26 |
|
|
#ifndef __objc_sync_INCLUDE_GNU
|
| 27 |
|
|
#define __objc_sync_INCLUDE_GNU
|
| 28 |
|
|
|
| 29 |
|
|
#include "objc.h"
|
| 30 |
|
|
#include "objc-decls.h"
|
| 31 |
|
|
|
| 32 |
|
|
#ifdef __cplusplus
|
| 33 |
|
|
extern "C" {
|
| 34 |
|
|
#endif
|
| 35 |
|
|
|
| 36 |
|
|
/* These functions are automatically called by @synchronized(). */
|
| 37 |
|
|
|
| 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
|
| 42 |
|
|
values.
|
| 43 |
|
|
|
| 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);
|
| 47 |
|
|
|
| 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
|
| 52 |
|
|
values. */
|
| 53 |
|
|
objc_EXPORT int objc_sync_exit (id object);
|
| 54 |
|
|
|
| 55 |
|
|
/* All the possible return values for objc_sync_enter() and
|
| 56 |
|
|
objc_sync_exit().
|
| 57 |
|
|
*/
|
| 58 |
|
|
enum {
|
| 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
|
| 63 |
|
|
};
|
| 64 |
|
|
|
| 65 |
|
|
#ifdef __cplusplus
|
| 66 |
|
|
}
|
| 67 |
|
|
#endif
|
| 68 |
|
|
|
| 69 |
|
|
#endif /* not __objc_sync_INCLUDE_GNU */
|