xref: /netbsd-src/external/gpl3/gcc.old/dist/libobjc/objc/objc-sync.h (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
136ac495dSmrg /* GNU Objective C Runtime @synchronized implementation
2*8feb0f0bSmrg    Copyright (C) 2010-2020 Free Software Foundation, Inc.
336ac495dSmrg    Contributed by Nicola Pero <nicola.pero@meta-innovation.com>
436ac495dSmrg 
536ac495dSmrg This file is part of GCC.
636ac495dSmrg 
736ac495dSmrg GCC is free software; you can redistribute it and/or modify
836ac495dSmrg it under the terms of the GNU General Public License as published by
936ac495dSmrg the Free Software Foundation; either version 3, or (at your option)
1036ac495dSmrg any later version.
1136ac495dSmrg 
1236ac495dSmrg GCC is distributed in the hope that it will be useful,
1336ac495dSmrg but WITHOUT ANY WARRANTY; without even the implied warranty of
1436ac495dSmrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1536ac495dSmrg GNU General Public License for more details.
1636ac495dSmrg 
1736ac495dSmrg Under Section 7 of GPL version 3, you are granted additional
1836ac495dSmrg permissions described in the GCC Runtime Library Exception, version
1936ac495dSmrg 3.1, as published by the Free Software Foundation.
2036ac495dSmrg 
2136ac495dSmrg You should have received a copy of the GNU General Public License and
2236ac495dSmrg a copy of the GCC Runtime Library Exception along with this program;
2336ac495dSmrg see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
2436ac495dSmrg <http://www.gnu.org/licenses/>.  */
2536ac495dSmrg 
2636ac495dSmrg #ifndef __objc_sync_INCLUDE_GNU
2736ac495dSmrg #define __objc_sync_INCLUDE_GNU
2836ac495dSmrg 
2936ac495dSmrg #include "objc.h"
3036ac495dSmrg #include "objc-decls.h"
3136ac495dSmrg 
3236ac495dSmrg #ifdef __cplusplus
3336ac495dSmrg extern "C" {
3436ac495dSmrg #endif
3536ac495dSmrg 
3636ac495dSmrg /* These functions are automatically called by @synchronized().  */
3736ac495dSmrg 
3836ac495dSmrg /* 'objc_sync_enter' is automatically called when entering a
3936ac495dSmrg    @synchronized() block.  It locks the recursive lock associated with
4036ac495dSmrg    'object'.  If 'object' is nil, it does nothing.  It returns
4136ac495dSmrg    OBJC_SYNC_SUCCESS on success; see the enumeration below for error
4236ac495dSmrg    values.
4336ac495dSmrg 
4436ac495dSmrg    Note that you should not rely on the behaviour when 'object' is nil
4536ac495dSmrg    because it could change.  */
4636ac495dSmrg objc_EXPORT int objc_sync_enter (id object);
4736ac495dSmrg 
4836ac495dSmrg /* 'objc_sync_exit' is automatically called when exiting from a
4936ac495dSmrg    @synchronized() block.  It unlocks the recursive lock associated
5036ac495dSmrg    with 'object'.  If 'object' is nil, it does nothing.  It returns
5136ac495dSmrg    OBJC_SYNC_SUCCESS on success; see the enumeration below for error
5236ac495dSmrg    values.  */
5336ac495dSmrg objc_EXPORT int objc_sync_exit (id object);
5436ac495dSmrg 
5536ac495dSmrg /* All the possible return values for objc_sync_enter() and
5636ac495dSmrg    objc_sync_exit().
5736ac495dSmrg  */
5836ac495dSmrg enum {
5936ac495dSmrg   OBJC_SYNC_SUCCESS = 0,
6036ac495dSmrg   OBJC_SYNC_NOT_OWNING_THREAD_ERROR = -1,
6136ac495dSmrg   OBJC_SYNC_TIMED_OUT = -2,
6236ac495dSmrg   OBJC_SYNC_NOT_INITIALIZED = -3
6336ac495dSmrg };
6436ac495dSmrg 
6536ac495dSmrg #ifdef __cplusplus
6636ac495dSmrg }
6736ac495dSmrg #endif
6836ac495dSmrg 
6936ac495dSmrg #endif /* not __objc_sync_INCLUDE_GNU */
70