2000-07-20 09:27:26 +02:00
|
|
|
/* Threads compatibility routines for libgcc2 and libobjc. */
|
1997-12-25 00:56:08 +01:00
|
|
|
/* Compile this one with gcc. */
|
2003-07-31 14:01:07 +02:00
|
|
|
/* Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003
|
|
|
|
Free Software Foundation, Inc.
|
1997-12-25 00:56:08 +01:00
|
|
|
|
Makefile.in, [...]: replace "GNU CC" with "GCC".
* Makefile.in, alias.c, basic-block.h, bb-reorder.c, bitmap.c,
bitmap.h, builtin-types.def, builtins.c, builtins.def,
c-aux-info.c, c-common.c, c-common.def, c-common.h,
c-convert.c, c-decl.c, c-dump.c, c-dump.h, c-errors.c,
c-format.c, c-lang.c, c-lex.c, c-lex.h, c-parse.in,
c-pragma.c, c-pragma.h, c-semantics.c, c-tree.h, c-typeck.c,
caller-save.c, calls.c, collect2.c, collect2.h, combine.c,
conditions.h, config.gcc, configure.frag, configure.in,
conflict.c, convert.c, convert.h, cppspec.c, crtstuff.c,
cse.c, cselib.c, cselib.h, dbxout.c, dbxout.h, defaults.h,
dependence.c, df.c, df.h, diagnostic.c, diagnostic.h,
doloop.c, dominance.c, dwarf.h, dwarf2.h, dwarf2asm.c,
dwarf2asm.h, dwarf2out.c, dwarf2out.h, dwarfout.c,
emit-rtl.c, errors.c, errors.h, except.c, except.h,
exgettext, explow.c, expmed.c, expr.c, expr.h, final.c,
fixproto, flags.h, flow.c, fold-const.c, fp-test.c,
function.c, function.h, gbl-ctors.h, gcc.c, gcc.h, gcc.hlp,
gccspec.c, gcov-io.h, gcse.c, genattr.c, genattrtab.c,
gencheck.c, gencodes.c, genconfig.c, genemit.c,
genextract.c, genflags.c, gengenrtl.c, genmultilib,
genopinit.c, genoutput.c, genpeep.c, genrecog.c,
gensupport.c, gensupport.h, ggc-callbacks.c, ggc-common.c,
ggc-none.c, ggc-page.c, ggc-simple.c, ggc.h, global.c,
graph.c, graph.h, gthr-aix.h, gthr-dce.h, gthr-posix.h,
gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h,
gthr-win32.h, gthr.h, haifa-sched.c, halfpic.c, halfpic.h,
hard-reg-set.h, hwint.h, ifcvt.c, input.h, insn-addr.h,
integrate.c, integrate.h, jump.c, lcm.c, libgcc2.c,
libgcc2.h, lists.c, local-alloc.c, loop.c, loop.h,
machmode.def, machmode.h, main.c, mbchar.c, mbchar.h,
mips-tdump.c, mips-tfile.c, mklibgcc.in, mkmap-flat.awk,
mkmap-symver.awk, optabs.c, output.h, params.c, params.def,
params.h, predict.c, predict.def, predict.h, prefix.c,
prefix.h, print-rtl.c, print-tree.c, profile.c, protoize.c,
read-rtl.c, real.c, real.h, recog.c, recog.h, reg-stack.c,
regclass.c, regmove.c, regrename.c, regs.h, reload.c,
reload.h, reload1.c, reorg.c, resource.c, resource.h, rtl.c,
rtl.def, rtl.h, rtlanal.c, sbitmap.c, sbitmap.h,
sched-deps.c, sched-ebb.c, sched-int.h, sched-rgn.c,
sched-vis.c, sdbout.c, sdbout.h, sibcall.c, simplify-rtx.c,
ssa-ccp.c, ssa-dce.c, ssa.c, ssa.h, stmt.c, stor-layout.c,
stringpool.c, system.h, timevar.c, timevar.def, timevar.h,
tlink.c, toplev.c, toplev.h, tree.c, tree.def, tree.h,
tsystem.h, unroll.c, unwind-dw2-fde.c, unwind-dw2-fde.h,
unwind-dw2.c, unwind-pe.h, unwind-sjlj.c, unwind.h,
unwind.inc, varasm.c, varray.c, varray.h, xcoffout.c,
xcoffout.h: replace "GNU CC" with "GCC".
From-SVN: r45105
2001-08-22 16:35:51 +02:00
|
|
|
This file is part of GCC.
|
1997-12-25 00:56:08 +01:00
|
|
|
|
Makefile.in, [...]: replace "GNU CC" with "GCC".
* Makefile.in, alias.c, basic-block.h, bb-reorder.c, bitmap.c,
bitmap.h, builtin-types.def, builtins.c, builtins.def,
c-aux-info.c, c-common.c, c-common.def, c-common.h,
c-convert.c, c-decl.c, c-dump.c, c-dump.h, c-errors.c,
c-format.c, c-lang.c, c-lex.c, c-lex.h, c-parse.in,
c-pragma.c, c-pragma.h, c-semantics.c, c-tree.h, c-typeck.c,
caller-save.c, calls.c, collect2.c, collect2.h, combine.c,
conditions.h, config.gcc, configure.frag, configure.in,
conflict.c, convert.c, convert.h, cppspec.c, crtstuff.c,
cse.c, cselib.c, cselib.h, dbxout.c, dbxout.h, defaults.h,
dependence.c, df.c, df.h, diagnostic.c, diagnostic.h,
doloop.c, dominance.c, dwarf.h, dwarf2.h, dwarf2asm.c,
dwarf2asm.h, dwarf2out.c, dwarf2out.h, dwarfout.c,
emit-rtl.c, errors.c, errors.h, except.c, except.h,
exgettext, explow.c, expmed.c, expr.c, expr.h, final.c,
fixproto, flags.h, flow.c, fold-const.c, fp-test.c,
function.c, function.h, gbl-ctors.h, gcc.c, gcc.h, gcc.hlp,
gccspec.c, gcov-io.h, gcse.c, genattr.c, genattrtab.c,
gencheck.c, gencodes.c, genconfig.c, genemit.c,
genextract.c, genflags.c, gengenrtl.c, genmultilib,
genopinit.c, genoutput.c, genpeep.c, genrecog.c,
gensupport.c, gensupport.h, ggc-callbacks.c, ggc-common.c,
ggc-none.c, ggc-page.c, ggc-simple.c, ggc.h, global.c,
graph.c, graph.h, gthr-aix.h, gthr-dce.h, gthr-posix.h,
gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h,
gthr-win32.h, gthr.h, haifa-sched.c, halfpic.c, halfpic.h,
hard-reg-set.h, hwint.h, ifcvt.c, input.h, insn-addr.h,
integrate.c, integrate.h, jump.c, lcm.c, libgcc2.c,
libgcc2.h, lists.c, local-alloc.c, loop.c, loop.h,
machmode.def, machmode.h, main.c, mbchar.c, mbchar.h,
mips-tdump.c, mips-tfile.c, mklibgcc.in, mkmap-flat.awk,
mkmap-symver.awk, optabs.c, output.h, params.c, params.def,
params.h, predict.c, predict.def, predict.h, prefix.c,
prefix.h, print-rtl.c, print-tree.c, profile.c, protoize.c,
read-rtl.c, real.c, real.h, recog.c, recog.h, reg-stack.c,
regclass.c, regmove.c, regrename.c, regs.h, reload.c,
reload.h, reload1.c, reorg.c, resource.c, resource.h, rtl.c,
rtl.def, rtl.h, rtlanal.c, sbitmap.c, sbitmap.h,
sched-deps.c, sched-ebb.c, sched-int.h, sched-rgn.c,
sched-vis.c, sdbout.c, sdbout.h, sibcall.c, simplify-rtx.c,
ssa-ccp.c, ssa-dce.c, ssa.c, ssa.h, stmt.c, stor-layout.c,
stringpool.c, system.h, timevar.c, timevar.def, timevar.h,
tlink.c, toplev.c, toplev.h, tree.c, tree.def, tree.h,
tsystem.h, unroll.c, unwind-dw2-fde.c, unwind-dw2-fde.h,
unwind-dw2.c, unwind-pe.h, unwind-sjlj.c, unwind.h,
unwind.inc, varasm.c, varray.c, varray.h, xcoffout.c,
xcoffout.h: replace "GNU CC" with "GCC".
From-SVN: r45105
2001-08-22 16:35:51 +02:00
|
|
|
GCC is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free
|
|
|
|
Software Foundation; either version 2, or (at your option) any later
|
|
|
|
version.
|
1997-12-25 00:56:08 +01:00
|
|
|
|
Makefile.in, [...]: replace "GNU CC" with "GCC".
* Makefile.in, alias.c, basic-block.h, bb-reorder.c, bitmap.c,
bitmap.h, builtin-types.def, builtins.c, builtins.def,
c-aux-info.c, c-common.c, c-common.def, c-common.h,
c-convert.c, c-decl.c, c-dump.c, c-dump.h, c-errors.c,
c-format.c, c-lang.c, c-lex.c, c-lex.h, c-parse.in,
c-pragma.c, c-pragma.h, c-semantics.c, c-tree.h, c-typeck.c,
caller-save.c, calls.c, collect2.c, collect2.h, combine.c,
conditions.h, config.gcc, configure.frag, configure.in,
conflict.c, convert.c, convert.h, cppspec.c, crtstuff.c,
cse.c, cselib.c, cselib.h, dbxout.c, dbxout.h, defaults.h,
dependence.c, df.c, df.h, diagnostic.c, diagnostic.h,
doloop.c, dominance.c, dwarf.h, dwarf2.h, dwarf2asm.c,
dwarf2asm.h, dwarf2out.c, dwarf2out.h, dwarfout.c,
emit-rtl.c, errors.c, errors.h, except.c, except.h,
exgettext, explow.c, expmed.c, expr.c, expr.h, final.c,
fixproto, flags.h, flow.c, fold-const.c, fp-test.c,
function.c, function.h, gbl-ctors.h, gcc.c, gcc.h, gcc.hlp,
gccspec.c, gcov-io.h, gcse.c, genattr.c, genattrtab.c,
gencheck.c, gencodes.c, genconfig.c, genemit.c,
genextract.c, genflags.c, gengenrtl.c, genmultilib,
genopinit.c, genoutput.c, genpeep.c, genrecog.c,
gensupport.c, gensupport.h, ggc-callbacks.c, ggc-common.c,
ggc-none.c, ggc-page.c, ggc-simple.c, ggc.h, global.c,
graph.c, graph.h, gthr-aix.h, gthr-dce.h, gthr-posix.h,
gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h,
gthr-win32.h, gthr.h, haifa-sched.c, halfpic.c, halfpic.h,
hard-reg-set.h, hwint.h, ifcvt.c, input.h, insn-addr.h,
integrate.c, integrate.h, jump.c, lcm.c, libgcc2.c,
libgcc2.h, lists.c, local-alloc.c, loop.c, loop.h,
machmode.def, machmode.h, main.c, mbchar.c, mbchar.h,
mips-tdump.c, mips-tfile.c, mklibgcc.in, mkmap-flat.awk,
mkmap-symver.awk, optabs.c, output.h, params.c, params.def,
params.h, predict.c, predict.def, predict.h, prefix.c,
prefix.h, print-rtl.c, print-tree.c, profile.c, protoize.c,
read-rtl.c, real.c, real.h, recog.c, recog.h, reg-stack.c,
regclass.c, regmove.c, regrename.c, regs.h, reload.c,
reload.h, reload1.c, reorg.c, resource.c, resource.h, rtl.c,
rtl.def, rtl.h, rtlanal.c, sbitmap.c, sbitmap.h,
sched-deps.c, sched-ebb.c, sched-int.h, sched-rgn.c,
sched-vis.c, sdbout.c, sdbout.h, sibcall.c, simplify-rtx.c,
ssa-ccp.c, ssa-dce.c, ssa.c, ssa.h, stmt.c, stor-layout.c,
stringpool.c, system.h, timevar.c, timevar.def, timevar.h,
tlink.c, toplev.c, toplev.h, tree.c, tree.def, tree.h,
tsystem.h, unroll.c, unwind-dw2-fde.c, unwind-dw2-fde.h,
unwind-dw2.c, unwind-pe.h, unwind-sjlj.c, unwind.h,
unwind.inc, varasm.c, varray.c, varray.h, xcoffout.c,
xcoffout.h: replace "GNU CC" with "GCC".
From-SVN: r45105
2001-08-22 16:35:51 +02:00
|
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
for more details.
|
1997-12-25 00:56:08 +01:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
Makefile.in, [...]: replace "GNU CC" with "GCC".
* Makefile.in, alias.c, basic-block.h, bb-reorder.c, bitmap.c,
bitmap.h, builtin-types.def, builtins.c, builtins.def,
c-aux-info.c, c-common.c, c-common.def, c-common.h,
c-convert.c, c-decl.c, c-dump.c, c-dump.h, c-errors.c,
c-format.c, c-lang.c, c-lex.c, c-lex.h, c-parse.in,
c-pragma.c, c-pragma.h, c-semantics.c, c-tree.h, c-typeck.c,
caller-save.c, calls.c, collect2.c, collect2.h, combine.c,
conditions.h, config.gcc, configure.frag, configure.in,
conflict.c, convert.c, convert.h, cppspec.c, crtstuff.c,
cse.c, cselib.c, cselib.h, dbxout.c, dbxout.h, defaults.h,
dependence.c, df.c, df.h, diagnostic.c, diagnostic.h,
doloop.c, dominance.c, dwarf.h, dwarf2.h, dwarf2asm.c,
dwarf2asm.h, dwarf2out.c, dwarf2out.h, dwarfout.c,
emit-rtl.c, errors.c, errors.h, except.c, except.h,
exgettext, explow.c, expmed.c, expr.c, expr.h, final.c,
fixproto, flags.h, flow.c, fold-const.c, fp-test.c,
function.c, function.h, gbl-ctors.h, gcc.c, gcc.h, gcc.hlp,
gccspec.c, gcov-io.h, gcse.c, genattr.c, genattrtab.c,
gencheck.c, gencodes.c, genconfig.c, genemit.c,
genextract.c, genflags.c, gengenrtl.c, genmultilib,
genopinit.c, genoutput.c, genpeep.c, genrecog.c,
gensupport.c, gensupport.h, ggc-callbacks.c, ggc-common.c,
ggc-none.c, ggc-page.c, ggc-simple.c, ggc.h, global.c,
graph.c, graph.h, gthr-aix.h, gthr-dce.h, gthr-posix.h,
gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h,
gthr-win32.h, gthr.h, haifa-sched.c, halfpic.c, halfpic.h,
hard-reg-set.h, hwint.h, ifcvt.c, input.h, insn-addr.h,
integrate.c, integrate.h, jump.c, lcm.c, libgcc2.c,
libgcc2.h, lists.c, local-alloc.c, loop.c, loop.h,
machmode.def, machmode.h, main.c, mbchar.c, mbchar.h,
mips-tdump.c, mips-tfile.c, mklibgcc.in, mkmap-flat.awk,
mkmap-symver.awk, optabs.c, output.h, params.c, params.def,
params.h, predict.c, predict.def, predict.h, prefix.c,
prefix.h, print-rtl.c, print-tree.c, profile.c, protoize.c,
read-rtl.c, real.c, real.h, recog.c, recog.h, reg-stack.c,
regclass.c, regmove.c, regrename.c, regs.h, reload.c,
reload.h, reload1.c, reorg.c, resource.c, resource.h, rtl.c,
rtl.def, rtl.h, rtlanal.c, sbitmap.c, sbitmap.h,
sched-deps.c, sched-ebb.c, sched-int.h, sched-rgn.c,
sched-vis.c, sdbout.c, sdbout.h, sibcall.c, simplify-rtx.c,
ssa-ccp.c, ssa-dce.c, ssa.c, ssa.h, stmt.c, stor-layout.c,
stringpool.c, system.h, timevar.c, timevar.def, timevar.h,
tlink.c, toplev.c, toplev.h, tree.c, tree.def, tree.h,
tsystem.h, unroll.c, unwind-dw2-fde.c, unwind-dw2-fde.h,
unwind-dw2.c, unwind-pe.h, unwind-sjlj.c, unwind.h,
unwind.inc, varasm.c, varray.c, varray.h, xcoffout.c,
xcoffout.h: replace "GNU CC" with "GCC".
From-SVN: r45105
2001-08-22 16:35:51 +02:00
|
|
|
along with GCC; see the file COPYING. If not, write to the Free
|
|
|
|
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
02111-1307, USA. */
|
1997-12-25 00:56:08 +01:00
|
|
|
|
|
|
|
/* As a special exception, if you link this library with other files,
|
|
|
|
some of which are compiled with GCC, to produce an executable,
|
|
|
|
this library does not by itself cause the resulting executable
|
|
|
|
to be covered by the GNU General Public License.
|
|
|
|
This exception does not however invalidate any other reasons why
|
|
|
|
the executable file might be covered by the GNU General Public License. */
|
|
|
|
|
2001-05-26 03:31:47 +02:00
|
|
|
#ifndef GCC_GTHR_POSIX_H
|
|
|
|
#define GCC_GTHR_POSIX_H
|
1997-12-25 00:56:08 +01:00
|
|
|
|
|
|
|
/* POSIX threads specific definitions.
|
2001-10-12 15:10:33 +02:00
|
|
|
Easy, since the interface is just one-to-one mapping. */
|
1997-12-25 00:56:08 +01:00
|
|
|
|
|
|
|
#define __GTHREADS 1
|
|
|
|
|
2003-07-31 14:01:07 +02:00
|
|
|
/* Some implementations of <pthread.h> require this to be defined. */
|
|
|
|
#ifndef _REENTRANT
|
|
|
|
#define _REENTRANT 1
|
|
|
|
#endif
|
|
|
|
|
1997-12-25 00:56:08 +01:00
|
|
|
#include <pthread.h>
|
2002-10-29 19:23:02 +01:00
|
|
|
#include <unistd.h>
|
1997-12-25 00:56:08 +01:00
|
|
|
|
|
|
|
typedef pthread_key_t __gthread_key_t;
|
|
|
|
typedef pthread_once_t __gthread_once_t;
|
|
|
|
typedef pthread_mutex_t __gthread_mutex_t;
|
2004-08-28 04:33:54 +02:00
|
|
|
typedef pthread_mutex_t __gthread_recursive_mutex_t;
|
1997-12-25 00:56:08 +01:00
|
|
|
|
|
|
|
#define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
|
|
|
|
#define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
|
2004-08-28 04:33:54 +02:00
|
|
|
#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
|
|
|
|
#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
|
|
|
|
#elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
|
|
|
|
#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
|
|
|
|
#else
|
|
|
|
#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
|
|
|
|
#endif
|
1997-12-25 00:56:08 +01:00
|
|
|
|
|
|
|
#if SUPPORTS_WEAK && GTHREAD_USE_WEAK
|
|
|
|
|
2000-07-20 09:27:26 +02:00
|
|
|
#pragma weak pthread_once
|
|
|
|
#pragma weak pthread_key_create
|
|
|
|
#pragma weak pthread_key_delete
|
|
|
|
#pragma weak pthread_getspecific
|
|
|
|
#pragma weak pthread_setspecific
|
|
|
|
#pragma weak pthread_create
|
bb-reorder.c (get_next_bb_note, [...]): Prototype.
* bb-reorder.c (get_next_bb_note, get_prev_bb_note): Prototype.
* diagnostic (vbuild_message_string, build_message_string,
build_location_prefix, output_get_prefix, init_output_buffer,
output_notice, vline_wrapper_message_with_location,
v_message_with_decl, default_print_error_function): De-constify.
(set_real_maximum_length): Prototype.
* diagnostic.h (struct output_buffer, init_output_buffer,
output_get_prefix, output_set_prefix): De-constify.
* function.c (init_function_start): Constify.
* gensupport.c (remove_constraints, process_rtx): Prototype.
* gthr-posix.h: Indent uses of #pragma.
* objc/objc-act.c (ggc_mark_imp_list, ggc_mark_hash_table):
Prototype.
* predict.c (find_expected_value): Delete prototype.
(expected_value_to_br_prob): Initialize variable `ev_reg'.
* sbitmap.h (debug_sbitmap): Prototype.
* ssa.c (compute_coalesced_reg_partition): Prototype.
* stor-layout.c (debug_rli): Prototype.
* tree.h (round_down): Prototype.
(init_function_start): Constify.
ch:
* ch-tree.h (init_function_start): Constify.
From-SVN: r33675
2000-05-04 19:58:40 +02:00
|
|
|
|
2002-06-04 13:30:46 +02:00
|
|
|
#pragma weak pthread_mutex_lock
|
|
|
|
#pragma weak pthread_mutex_trylock
|
|
|
|
#pragma weak pthread_mutex_unlock
|
2000-07-20 09:27:26 +02:00
|
|
|
|
2003-07-31 14:01:07 +02:00
|
|
|
#if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
|
2002-09-27 00:25:14 +02:00
|
|
|
/* Objective-C. */
|
2000-07-20 09:27:26 +02:00
|
|
|
#pragma weak pthread_cond_broadcast
|
|
|
|
#pragma weak pthread_cond_destroy
|
|
|
|
#pragma weak pthread_cond_init
|
|
|
|
#pragma weak pthread_cond_signal
|
|
|
|
#pragma weak pthread_cond_wait
|
|
|
|
#pragma weak pthread_exit
|
|
|
|
#pragma weak pthread_mutex_init
|
|
|
|
#pragma weak pthread_mutex_destroy
|
|
|
|
#pragma weak pthread_self
|
2004-05-28 22:18:23 +02:00
|
|
|
#ifdef _POSIX_PRIORITY_SCHEDULING
|
2002-10-29 19:23:02 +01:00
|
|
|
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
|
2001-06-28 14:57:55 +02:00
|
|
|
#pragma weak sched_get_priority_max
|
|
|
|
#pragma weak sched_get_priority_min
|
2002-10-29 19:23:02 +01:00
|
|
|
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
|
2004-05-28 22:18:23 +02:00
|
|
|
#endif /* _POSIX_PRIORITY_SCHEDULING */
|
2000-07-20 09:27:26 +02:00
|
|
|
#pragma weak sched_yield
|
2001-05-15 18:29:06 +02:00
|
|
|
#pragma weak pthread_attr_destroy
|
|
|
|
#pragma weak pthread_attr_init
|
|
|
|
#pragma weak pthread_attr_setdetachstate
|
2002-10-29 19:23:02 +01:00
|
|
|
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
|
2001-05-15 18:29:06 +02:00
|
|
|
#pragma weak pthread_getschedparam
|
|
|
|
#pragma weak pthread_setschedparam
|
2002-10-29 19:23:02 +01:00
|
|
|
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
|
2003-07-31 14:01:07 +02:00
|
|
|
#endif /* _LIBOBJC || _LIBOBJC_WEAK */
|
1997-12-25 00:56:08 +01:00
|
|
|
|
|
|
|
static inline int
|
2000-02-12 20:19:01 +01:00
|
|
|
__gthread_active_p (void)
|
1997-12-25 00:56:08 +01:00
|
|
|
{
|
2002-03-13 18:15:46 +01:00
|
|
|
static void *const __gthread_active_ptr = (void *) &pthread_create;
|
1997-12-25 00:56:08 +01:00
|
|
|
return __gthread_active_ptr != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else /* not SUPPORTS_WEAK */
|
|
|
|
|
|
|
|
static inline int
|
2000-02-12 20:19:01 +01:00
|
|
|
__gthread_active_p (void)
|
1997-12-25 00:56:08 +01:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* SUPPORTS_WEAK */
|
|
|
|
|
2000-07-20 09:27:26 +02:00
|
|
|
#ifdef _LIBOBJC
|
|
|
|
|
2000-08-15 09:36:33 +02:00
|
|
|
/* This is the config.h file in libobjc/ */
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_SCHED_H
|
|
|
|
# include <sched.h>
|
|
|
|
#endif
|
|
|
|
|
2000-07-20 09:27:26 +02:00
|
|
|
/* Key structure for maintaining thread specific storage */
|
|
|
|
static pthread_key_t _objc_thread_storage;
|
2000-08-06 20:54:00 +02:00
|
|
|
static pthread_attr_t _objc_thread_attribs;
|
2000-07-20 09:27:26 +02:00
|
|
|
|
|
|
|
/* Thread local storage for a single thread */
|
|
|
|
static void *thread_local_storage = NULL;
|
|
|
|
|
|
|
|
/* Backend initialization functions */
|
|
|
|
|
2001-10-12 15:10:33 +02:00
|
|
|
/* Initialize the threads subsystem. */
|
2000-07-20 09:27:26 +02:00
|
|
|
static inline int
|
2002-11-13 06:09:51 +01:00
|
|
|
__gthread_objc_init_thread_system (void)
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
|
|
|
if (__gthread_active_p ())
|
2000-08-06 20:54:00 +02:00
|
|
|
{
|
|
|
|
/* Initialize the thread storage key */
|
2002-11-13 06:09:51 +01:00
|
|
|
if (pthread_key_create (&_objc_thread_storage, NULL) == 0)
|
2002-06-04 13:30:46 +02:00
|
|
|
{
|
|
|
|
/* The normal default detach state for threads is
|
|
|
|
* PTHREAD_CREATE_JOINABLE which causes threads to not die
|
|
|
|
* when you think they should. */
|
2002-11-13 06:09:51 +01:00
|
|
|
if (pthread_attr_init (&_objc_thread_attribs) == 0
|
|
|
|
&& pthread_attr_setdetachstate (&_objc_thread_attribs,
|
|
|
|
PTHREAD_CREATE_DETACHED) == 0)
|
2002-06-04 13:30:46 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2000-08-06 20:54:00 +02:00
|
|
|
}
|
2001-06-09 20:05:09 +02:00
|
|
|
|
|
|
|
return -1;
|
2000-07-20 09:27:26 +02:00
|
|
|
}
|
|
|
|
|
2001-10-12 15:10:33 +02:00
|
|
|
/* Close the threads subsystem. */
|
2000-07-20 09:27:26 +02:00
|
|
|
static inline int
|
2002-11-13 06:09:51 +01:00
|
|
|
__gthread_objc_close_thread_system (void)
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
2000-08-06 20:54:00 +02:00
|
|
|
if (__gthread_active_p ()
|
2002-11-13 06:09:51 +01:00
|
|
|
&& pthread_key_delete (_objc_thread_storage) == 0
|
|
|
|
&& pthread_attr_destroy (&_objc_thread_attribs) == 0)
|
2000-07-20 09:27:26 +02:00
|
|
|
return 0;
|
2000-08-06 20:54:00 +02:00
|
|
|
|
|
|
|
return -1;
|
2000-07-20 09:27:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Backend thread functions */
|
|
|
|
|
2001-10-12 15:10:33 +02:00
|
|
|
/* Create a new thread of execution. */
|
2000-07-20 09:27:26 +02:00
|
|
|
static inline objc_thread_t
|
2002-11-13 06:09:51 +01:00
|
|
|
__gthread_objc_thread_detach (void (*func)(void *), void *arg)
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
|
|
|
objc_thread_t thread_id;
|
|
|
|
pthread_t new_thread_handle;
|
|
|
|
|
|
|
|
if (!__gthread_active_p ())
|
|
|
|
return NULL;
|
2002-06-04 13:30:46 +02:00
|
|
|
|
2002-11-13 06:09:51 +01:00
|
|
|
if (!(pthread_create (&new_thread_handle, NULL, (void *) func, arg)))
|
2001-06-07 19:22:20 +02:00
|
|
|
thread_id = (objc_thread_t) new_thread_handle;
|
2000-07-20 09:27:26 +02:00
|
|
|
else
|
|
|
|
thread_id = NULL;
|
2002-06-04 13:30:46 +02:00
|
|
|
|
2000-07-20 09:27:26 +02:00
|
|
|
return thread_id;
|
|
|
|
}
|
|
|
|
|
2001-10-12 15:10:33 +02:00
|
|
|
/* Set the current thread's priority. */
|
2000-07-20 09:27:26 +02:00
|
|
|
static inline int
|
2002-11-13 06:09:51 +01:00
|
|
|
__gthread_objc_thread_set_priority (int priority)
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
2002-11-13 06:09:51 +01:00
|
|
|
if (!__gthread_active_p ())
|
2000-08-06 20:54:00 +02:00
|
|
|
return -1;
|
2002-11-13 06:09:51 +01:00
|
|
|
else
|
|
|
|
{
|
2004-05-28 22:18:23 +02:00
|
|
|
#ifdef _POSIX_PRIORITY_SCHEDULING
|
2002-10-29 19:23:02 +01:00
|
|
|
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
|
2002-11-13 06:09:51 +01:00
|
|
|
pthread_t thread_id = pthread_self ();
|
|
|
|
int policy;
|
|
|
|
struct sched_param params;
|
|
|
|
int priority_min, priority_max;
|
2002-06-04 13:30:46 +02:00
|
|
|
|
2002-11-13 06:09:51 +01:00
|
|
|
if (pthread_getschedparam (thread_id, &policy, ¶ms) == 0)
|
|
|
|
{
|
|
|
|
if ((priority_max = sched_get_priority_max (policy)) == -1)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if ((priority_min = sched_get_priority_min (policy)) == -1)
|
|
|
|
return -1;
|
2002-06-04 13:30:46 +02:00
|
|
|
|
2002-11-13 06:09:51 +01:00
|
|
|
if (priority > priority_max)
|
|
|
|
priority = priority_max;
|
|
|
|
else if (priority < priority_min)
|
|
|
|
priority = priority_min;
|
|
|
|
params.sched_priority = priority;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The solaris 7 and several other man pages incorrectly state that
|
|
|
|
* this should be a pointer to policy but pthread.h is universally
|
|
|
|
* at odds with this.
|
|
|
|
*/
|
|
|
|
if (pthread_setschedparam (thread_id, policy, ¶ms) == 0)
|
|
|
|
return 0;
|
|
|
|
}
|
2002-10-29 19:23:02 +01:00
|
|
|
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
|
2004-05-28 22:18:23 +02:00
|
|
|
#endif /* _POSIX_PRIORITY_SCHEDULING */
|
2002-11-13 06:09:51 +01:00
|
|
|
return -1;
|
|
|
|
}
|
2000-07-20 09:27:26 +02:00
|
|
|
}
|
|
|
|
|
2001-10-12 15:10:33 +02:00
|
|
|
/* Return the current thread's priority. */
|
2000-07-20 09:27:26 +02:00
|
|
|
static inline int
|
2002-11-13 06:09:51 +01:00
|
|
|
__gthread_objc_thread_get_priority (void)
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
2004-05-28 22:18:23 +02:00
|
|
|
#ifdef _POSIX_PRIORITY_SCHEDULING
|
2002-10-29 19:23:02 +01:00
|
|
|
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
|
2000-07-20 09:27:26 +02:00
|
|
|
if (__gthread_active_p ())
|
2000-08-06 20:54:00 +02:00
|
|
|
{
|
|
|
|
int policy;
|
|
|
|
struct sched_param params;
|
|
|
|
|
2002-11-13 06:09:51 +01:00
|
|
|
if (pthread_getschedparam (pthread_self (), &policy, ¶ms) == 0)
|
2002-06-04 13:30:46 +02:00
|
|
|
return params.sched_priority;
|
2000-08-06 20:54:00 +02:00
|
|
|
else
|
2002-06-04 13:30:46 +02:00
|
|
|
return -1;
|
2000-08-06 20:54:00 +02:00
|
|
|
}
|
2000-07-20 09:27:26 +02:00
|
|
|
else
|
2002-10-29 19:23:02 +01:00
|
|
|
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
|
2004-05-28 22:18:23 +02:00
|
|
|
#endif /* _POSIX_PRIORITY_SCHEDULING */
|
2000-07-20 09:27:26 +02:00
|
|
|
return OBJC_THREAD_INTERACTIVE_PRIORITY;
|
|
|
|
}
|
|
|
|
|
2001-10-12 15:10:33 +02:00
|
|
|
/* Yield our process time to another thread. */
|
2000-07-20 09:27:26 +02:00
|
|
|
static inline void
|
2002-11-13 06:09:51 +01:00
|
|
|
__gthread_objc_thread_yield (void)
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
|
|
|
if (__gthread_active_p ())
|
2002-11-13 06:09:51 +01:00
|
|
|
sched_yield ();
|
2000-07-20 09:27:26 +02:00
|
|
|
}
|
|
|
|
|
2001-10-12 15:10:33 +02:00
|
|
|
/* Terminate the current thread. */
|
2000-07-20 09:27:26 +02:00
|
|
|
static inline int
|
2002-11-13 06:09:51 +01:00
|
|
|
__gthread_objc_thread_exit (void)
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
|
|
|
if (__gthread_active_p ())
|
|
|
|
/* exit the thread */
|
2002-11-13 06:09:51 +01:00
|
|
|
pthread_exit (&__objc_thread_exit_status);
|
2000-07-20 09:27:26 +02:00
|
|
|
|
|
|
|
/* Failed if we reached here */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2001-10-12 15:10:33 +02:00
|
|
|
/* Returns an integer value which uniquely describes a thread. */
|
2000-07-20 09:27:26 +02:00
|
|
|
static inline objc_thread_t
|
2002-11-13 06:09:51 +01:00
|
|
|
__gthread_objc_thread_id (void)
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
|
|
|
if (__gthread_active_p ())
|
2002-11-13 06:09:51 +01:00
|
|
|
return (objc_thread_t) pthread_self ();
|
2000-07-20 09:27:26 +02:00
|
|
|
else
|
2001-06-07 19:22:20 +02:00
|
|
|
return (objc_thread_t) 1;
|
2000-07-20 09:27:26 +02:00
|
|
|
}
|
|
|
|
|
2001-10-12 15:10:33 +02:00
|
|
|
/* Sets the thread's local storage pointer. */
|
2000-07-20 09:27:26 +02:00
|
|
|
static inline int
|
2002-11-13 06:09:51 +01:00
|
|
|
__gthread_objc_thread_set_data (void *value)
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
|
|
|
if (__gthread_active_p ())
|
2002-11-13 06:09:51 +01:00
|
|
|
return pthread_setspecific (_objc_thread_storage, value);
|
2000-07-20 09:27:26 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
thread_local_storage = value;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-12 15:10:33 +02:00
|
|
|
/* Returns the thread's local storage pointer. */
|
2000-07-20 09:27:26 +02:00
|
|
|
static inline void *
|
2002-11-13 06:09:51 +01:00
|
|
|
__gthread_objc_thread_get_data (void)
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
|
|
|
if (__gthread_active_p ())
|
2002-11-13 06:09:51 +01:00
|
|
|
return pthread_getspecific (_objc_thread_storage);
|
2000-07-20 09:27:26 +02:00
|
|
|
else
|
|
|
|
return thread_local_storage;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Backend mutex functions */
|
|
|
|
|
2001-10-12 15:10:33 +02:00
|
|
|
/* Allocate a mutex. */
|
2000-07-20 09:27:26 +02:00
|
|
|
static inline int
|
2002-11-13 06:09:51 +01:00
|
|
|
__gthread_objc_mutex_allocate (objc_mutex_t mutex)
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
|
|
|
if (__gthread_active_p ())
|
|
|
|
{
|
2002-11-13 06:09:51 +01:00
|
|
|
mutex->backend = objc_malloc (sizeof (pthread_mutex_t));
|
2000-07-20 09:27:26 +02:00
|
|
|
|
2002-11-13 06:09:51 +01:00
|
|
|
if (pthread_mutex_init ((pthread_mutex_t *) mutex->backend, NULL))
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
2002-11-13 06:09:51 +01:00
|
|
|
objc_free (mutex->backend);
|
2000-07-20 09:27:26 +02:00
|
|
|
mutex->backend = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-10-12 15:10:33 +02:00
|
|
|
/* Deallocate a mutex. */
|
2000-07-20 09:27:26 +02:00
|
|
|
static inline int
|
2002-11-13 06:09:51 +01:00
|
|
|
__gthread_objc_mutex_deallocate (objc_mutex_t mutex)
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
|
|
|
if (__gthread_active_p ())
|
|
|
|
{
|
|
|
|
int count;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Posix Threads specifically require that the thread be unlocked
|
|
|
|
* for pthread_mutex_destroy to work.
|
|
|
|
*/
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2002-11-13 06:09:51 +01:00
|
|
|
count = pthread_mutex_unlock ((pthread_mutex_t *) mutex->backend);
|
2000-07-20 09:27:26 +02:00
|
|
|
if (count < 0)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
while (count);
|
|
|
|
|
2002-11-13 06:09:51 +01:00
|
|
|
if (pthread_mutex_destroy ((pthread_mutex_t *) mutex->backend))
|
2000-07-20 09:27:26 +02:00
|
|
|
return -1;
|
|
|
|
|
2002-11-13 06:09:51 +01:00
|
|
|
objc_free (mutex->backend);
|
2000-07-20 09:27:26 +02:00
|
|
|
mutex->backend = NULL;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-10-12 15:10:33 +02:00
|
|
|
/* Grab a lock on a mutex. */
|
2000-07-20 09:27:26 +02:00
|
|
|
static inline int
|
2002-11-13 06:09:51 +01:00
|
|
|
__gthread_objc_mutex_lock (objc_mutex_t mutex)
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
2002-06-04 13:30:46 +02:00
|
|
|
if (__gthread_active_p ()
|
2002-11-13 06:09:51 +01:00
|
|
|
&& pthread_mutex_lock ((pthread_mutex_t *) mutex->backend) != 0)
|
2001-07-18 13:21:20 +02:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2000-07-20 09:27:26 +02:00
|
|
|
}
|
|
|
|
|
2001-10-12 15:10:33 +02:00
|
|
|
/* Try to grab a lock on a mutex. */
|
2000-07-20 09:27:26 +02:00
|
|
|
static inline int
|
2002-11-13 06:09:51 +01:00
|
|
|
__gthread_objc_mutex_trylock (objc_mutex_t mutex)
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
2002-06-04 13:30:46 +02:00
|
|
|
if (__gthread_active_p ()
|
2002-11-13 06:09:51 +01:00
|
|
|
&& pthread_mutex_trylock ((pthread_mutex_t *) mutex->backend) != 0)
|
2001-07-18 13:21:20 +02:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2000-07-20 09:27:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Unlock the mutex */
|
|
|
|
static inline int
|
2002-11-13 06:09:51 +01:00
|
|
|
__gthread_objc_mutex_unlock (objc_mutex_t mutex)
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
2002-06-04 13:30:46 +02:00
|
|
|
if (__gthread_active_p ()
|
2002-11-13 06:09:51 +01:00
|
|
|
&& pthread_mutex_unlock ((pthread_mutex_t *) mutex->backend) != 0)
|
2001-07-18 13:21:20 +02:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2000-07-20 09:27:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Backend condition mutex functions */
|
|
|
|
|
2001-10-12 15:10:33 +02:00
|
|
|
/* Allocate a condition. */
|
2000-07-20 09:27:26 +02:00
|
|
|
static inline int
|
2002-11-13 06:09:51 +01:00
|
|
|
__gthread_objc_condition_allocate (objc_condition_t condition)
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
|
|
|
if (__gthread_active_p ())
|
|
|
|
{
|
2002-11-13 06:09:51 +01:00
|
|
|
condition->backend = objc_malloc (sizeof (pthread_cond_t));
|
2000-07-20 09:27:26 +02:00
|
|
|
|
2002-11-13 06:09:51 +01:00
|
|
|
if (pthread_cond_init ((pthread_cond_t *) condition->backend, NULL))
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
2002-11-13 06:09:51 +01:00
|
|
|
objc_free (condition->backend);
|
2000-07-20 09:27:26 +02:00
|
|
|
condition->backend = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-10-12 15:10:33 +02:00
|
|
|
/* Deallocate a condition. */
|
2000-07-20 09:27:26 +02:00
|
|
|
static inline int
|
2002-11-13 06:09:51 +01:00
|
|
|
__gthread_objc_condition_deallocate (objc_condition_t condition)
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
|
|
|
if (__gthread_active_p ())
|
|
|
|
{
|
2002-11-13 06:09:51 +01:00
|
|
|
if (pthread_cond_destroy ((pthread_cond_t *) condition->backend))
|
2000-07-20 09:27:26 +02:00
|
|
|
return -1;
|
|
|
|
|
2002-11-13 06:09:51 +01:00
|
|
|
objc_free (condition->backend);
|
2000-07-20 09:27:26 +02:00
|
|
|
condition->backend = NULL;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Wait on the condition */
|
|
|
|
static inline int
|
2002-11-13 06:09:51 +01:00
|
|
|
__gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
|
|
|
if (__gthread_active_p ())
|
2002-11-13 06:09:51 +01:00
|
|
|
return pthread_cond_wait ((pthread_cond_t *) condition->backend,
|
|
|
|
(pthread_mutex_t *) mutex->backend);
|
2000-07-20 09:27:26 +02:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-10-12 15:10:33 +02:00
|
|
|
/* Wake up all threads waiting on this condition. */
|
2000-07-20 09:27:26 +02:00
|
|
|
static inline int
|
2002-11-13 06:09:51 +01:00
|
|
|
__gthread_objc_condition_broadcast (objc_condition_t condition)
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
|
|
|
if (__gthread_active_p ())
|
2002-11-13 06:09:51 +01:00
|
|
|
return pthread_cond_broadcast ((pthread_cond_t *) condition->backend);
|
2000-07-20 09:27:26 +02:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-10-12 15:10:33 +02:00
|
|
|
/* Wake up one thread waiting on this condition. */
|
2000-07-20 09:27:26 +02:00
|
|
|
static inline int
|
2002-11-13 06:09:51 +01:00
|
|
|
__gthread_objc_condition_signal (objc_condition_t condition)
|
2000-07-20 09:27:26 +02:00
|
|
|
{
|
|
|
|
if (__gthread_active_p ())
|
2002-11-13 06:09:51 +01:00
|
|
|
return pthread_cond_signal ((pthread_cond_t *) condition->backend);
|
2000-07-20 09:27:26 +02:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else /* _LIBOBJC */
|
|
|
|
|
1997-12-25 00:56:08 +01:00
|
|
|
static inline int
|
2000-02-12 20:19:01 +01:00
|
|
|
__gthread_once (__gthread_once_t *once, void (*func) (void))
|
1997-12-25 00:56:08 +01:00
|
|
|
{
|
|
|
|
if (__gthread_active_p ())
|
|
|
|
return pthread_once (once, func);
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
__gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
|
|
|
|
{
|
|
|
|
return pthread_key_create (key, dtor);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
__gthread_key_delete (__gthread_key_t key)
|
|
|
|
{
|
|
|
|
return pthread_key_delete (key);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *
|
|
|
|
__gthread_getspecific (__gthread_key_t key)
|
|
|
|
{
|
|
|
|
return pthread_getspecific (key);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
__gthread_setspecific (__gthread_key_t key, const void *ptr)
|
|
|
|
{
|
|
|
|
return pthread_setspecific (key, ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
__gthread_mutex_lock (__gthread_mutex_t *mutex)
|
|
|
|
{
|
|
|
|
if (__gthread_active_p ())
|
|
|
|
return pthread_mutex_lock (mutex);
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
__gthread_mutex_trylock (__gthread_mutex_t *mutex)
|
|
|
|
{
|
|
|
|
if (__gthread_active_p ())
|
|
|
|
return pthread_mutex_trylock (mutex);
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
__gthread_mutex_unlock (__gthread_mutex_t *mutex)
|
|
|
|
{
|
|
|
|
if (__gthread_active_p ())
|
|
|
|
return pthread_mutex_unlock (mutex);
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-08-28 04:33:54 +02:00
|
|
|
#ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
|
|
|
|
static inline int
|
|
|
|
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *mutex)
|
|
|
|
{
|
|
|
|
if (__gthread_active_p ())
|
|
|
|
{
|
|
|
|
pthread_mutexattr_t attr;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
r = pthread_mutexattr_init (&attr);
|
|
|
|
if (!r)
|
|
|
|
r = pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
|
|
|
|
if (!r)
|
|
|
|
r = pthread_mutex_init (mutex, &attr);
|
|
|
|
if (!r)
|
|
|
|
r = pthread_mutexattr_destroy (&attr);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
|
|
|
|
{
|
|
|
|
return __gthread_mutex_lock (mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
|
|
|
|
{
|
|
|
|
return __gthread_mutex_trylock (mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
|
|
|
|
{
|
|
|
|
return __gthread_mutex_unlock (mutex);
|
|
|
|
}
|
|
|
|
|
2000-07-20 09:27:26 +02:00
|
|
|
#endif /* _LIBOBJC */
|
|
|
|
|
2001-05-26 03:31:47 +02:00
|
|
|
#endif /* ! GCC_GTHR_POSIX_H */
|