]> git.ipfire.org Git - thirdparty/gcc.git/blame - libobjc/objc/thr.h
Update copyright years.
[thirdparty/gcc.git] / libobjc / objc / thr.h
CommitLineData
88e17b57 1/* Thread and mutex controls for Objective C.
818ab71a 2 Copyright (C) 1996-2016 Free Software Foundation, Inc.
88e17b57
BE
3 Contributed by Galen C. Hunt (gchunt@cs.rochester.edu)
4
6c82ad25 5This file is part of GCC.
88e17b57 6
6c82ad25 7GCC is free software; you can redistribute it and/or modify
88e17b57 8it under the terms of the GNU General Public License as published by
748086b7 9the Free Software Foundation; either version 3, or (at your option)
88e17b57
BE
10any later version.
11
6c82ad25 12GCC is distributed in the hope that it will be useful,
88e17b57
BE
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
748086b7
JJ
17Under Section 7 of GPL version 3, you are granted additional
18permissions described in the GCC Runtime Library Exception, version
193.1, as published by the Free Software Foundation.
88e17b57 20
748086b7
JJ
21You should have received a copy of the GNU General Public License and
22a copy of the GCC Runtime Library Exception along with this program;
23see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24<http://www.gnu.org/licenses/>. */
88e17b57
BE
25
26#ifndef __thread_INCLUDE_GNU
27#define __thread_INCLUDE_GNU
28
cf223603 29#include "objc.h"
88e17b57 30
6f0aa5e1
AP
31#ifdef __cplusplus
32extern "C" {
33#endif /* __cplusplus */
34
88e17b57
BE
35/*************************************************************************
36 * Universal static variables:
37 */
38extern int __objc_thread_exit_status; /* Global exit status. */
39
40/********
41 * Thread safe implementation types and functions.
42 */
43
44/* Thread priorities */
45#define OBJC_THREAD_INTERACTIVE_PRIORITY 2
46#define OBJC_THREAD_BACKGROUND_PRIORITY 1
47#define OBJC_THREAD_LOW_PRIORITY 0
48
49/* A thread */
50typedef void * objc_thread_t;
51
52/* This structure represents a single mutual exclusion lock. */
53struct objc_mutex
54{
55 volatile objc_thread_t owner; /* Id of thread that owns. */
56 volatile int depth; /* # of acquires. */
57 void * backend; /* Specific to backend */
58};
59typedef struct objc_mutex *objc_mutex_t;
60
61/* This structure represents a single condition mutex */
62struct objc_condition
63{
64 void * backend; /* Specific to backend */
65};
66typedef struct objc_condition *objc_condition_t;
67
68/* Frontend mutex functions */
40165636
RB
69objc_mutex_t objc_mutex_allocate (void);
70int objc_mutex_deallocate (objc_mutex_t mutex);
71int objc_mutex_lock (objc_mutex_t mutex);
72int objc_mutex_unlock (objc_mutex_t mutex);
73int objc_mutex_trylock (objc_mutex_t mutex);
88e17b57
BE
74
75/* Frontend condition mutex functions */
40165636
RB
76objc_condition_t objc_condition_allocate (void);
77int objc_condition_deallocate (objc_condition_t condition);
78int objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex);
79int objc_condition_signal (objc_condition_t condition);
80int objc_condition_broadcast (objc_condition_t condition);
88e17b57
BE
81
82/* Frontend thread functions */
40165636
RB
83objc_thread_t objc_thread_detach (SEL selector, id object, id argument);
84void objc_thread_yield (void);
85int objc_thread_exit (void);
86int objc_thread_set_priority (int priority);
87int objc_thread_get_priority (void);
88void * objc_thread_get_data (void);
89int objc_thread_set_data (void *value);
90objc_thread_t objc_thread_id (void);
91void objc_thread_add (void);
92void objc_thread_remove (void);
88e17b57
BE
93
94/*
95 Use this to set the hook function that will be called when the
96 runtime initially becomes multi threaded.
97 The hook function is only called once, meaning only when the
98 2nd thread is spawned, not for each and every thread.
99
100 It returns the previous hook function or NULL if there is none.
101
102 A program outside of the runtime could set this to some function so
103 it can be informed; for example, the GNUstep Base Library sets it
104 so it can implement the NSBecomingMultiThreaded notification.
105 */
40165636
RB
106typedef void (*objc_thread_callback) (void);
107objc_thread_callback objc_set_thread_callback (objc_thread_callback func);
88e17b57
BE
108
109/* Backend initialization functions */
40165636 110int __objc_init_thread_system (void);
88e17b57 111
6f0aa5e1
AP
112#ifdef __cplusplus
113}
114#endif /* __cplusplus */
115
88e17b57 116#endif /* not __thread_INCLUDE_GNU */