source: trunk/src/gcc/libobjc/objc/thr.h@ 1468

Last change on this file since 1468 was 1392, checked in by bird, 22 years ago

This commit was generated by cvs2svn to compensate for changes in r1391,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 5.4 KB
Line 
1/* Thread and mutex controls for Objective C.
2 Copyright (C) 1996, 1997, 2002 Free Software Foundation, Inc.
3 Contributed by Galen C. Hunt ([email protected])
4
5This file is part of GNU CC.
6
7GNU CC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU CC is distributed in the hope that it will be useful,
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
17GNU CC is free software; you can redistribute it and/or modify it under the
18terms of the GNU General Public License as published by the Free Software
19Foundation; either version 2, or (at your option) any later version.
20
21GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY
22WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
23FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
24details.
25
26You should have received a copy of the GNU General Public License along with
27GNU CC; see the file COPYING. If not, write to the Free Software
28Foundation, 59 Temple Place - Suite 330,
29Boston, MA 02111-1307, USA. */
30
31/* As a special exception, if you link this library with files
32 compiled with GCC to produce an executable, this does not cause
33 the resulting executable to be covered by the GNU General Public License.
34 This exception does not however invalidate any other reasons why
35 the executable file might be covered by the GNU General Public License. */
36
37
38#ifndef __thread_INCLUDE_GNU
39#define __thread_INCLUDE_GNU
40
41#include "objc/objc.h"
42
43/*************************************************************************
44 * Universal static variables:
45 */
46extern int __objc_thread_exit_status; /* Global exit status. */
47
48/********
49 * Thread safe implementation types and functions.
50 */
51
52/* Thread priorities */
53#define OBJC_THREAD_INTERACTIVE_PRIORITY 2
54#define OBJC_THREAD_BACKGROUND_PRIORITY 1
55#define OBJC_THREAD_LOW_PRIORITY 0
56
57/* A thread */
58typedef void * objc_thread_t;
59
60/* This structure represents a single mutual exclusion lock. */
61struct objc_mutex
62{
63 volatile objc_thread_t owner; /* Id of thread that owns. */
64 volatile int depth; /* # of acquires. */
65 void * backend; /* Specific to backend */
66};
67typedef struct objc_mutex *objc_mutex_t;
68
69/* This structure represents a single condition mutex */
70struct objc_condition
71{
72 void * backend; /* Specific to backend */
73};
74typedef struct objc_condition *objc_condition_t;
75
76/* Frontend mutex functions */
77objc_mutex_t objc_mutex_allocate (void);
78int objc_mutex_deallocate (objc_mutex_t mutex);
79int objc_mutex_lock (objc_mutex_t mutex);
80int objc_mutex_unlock (objc_mutex_t mutex);
81int objc_mutex_trylock (objc_mutex_t mutex);
82
83/* Frontend condition mutex functions */
84objc_condition_t objc_condition_allocate (void);
85int objc_condition_deallocate (objc_condition_t condition);
86int objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex);
87int objc_condition_signal (objc_condition_t condition);
88int objc_condition_broadcast (objc_condition_t condition);
89
90/* Frontend thread functions */
91objc_thread_t objc_thread_detach (SEL selector, id object, id argument);
92void objc_thread_yield (void);
93int objc_thread_exit (void);
94int objc_thread_set_priority (int priority);
95int objc_thread_get_priority (void);
96void * objc_thread_get_data (void);
97int objc_thread_set_data (void *value);
98objc_thread_t objc_thread_id (void);
99void objc_thread_add (void);
100void objc_thread_remove (void);
101
102/*
103 Use this to set the hook function that will be called when the
104 runtime initially becomes multi threaded.
105 The hook function is only called once, meaning only when the
106 2nd thread is spawned, not for each and every thread.
107
108 It returns the previous hook function or NULL if there is none.