1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

install pthread_atfork handlers for guile's static mutexen

* libguile/async.c:
* libguile/deprecation.c:
* libguile/fluids.c:
* libguile/gc.c:
* libguile/instructions.c:
* libguile/ports.c:
* libguile/posix.c:
* libguile/strings.c:
* libguile/threads.c: Use the SCM_PTHREAD_ATFORK_LOCK_STATIC_MUTEX
  mechanism to lock a number of static mutexen.
This commit is contained in:
Andy Wingo 2012-02-08 19:57:41 +01:00
parent 2f745b64a1
commit 6a97b1f93a
9 changed files with 16 additions and 5 deletions

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2002, 2004, 2006, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. /* Copyright (C) 1995,1996,1997,1998,2000,2001, 2002, 2004, 2006, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -133,6 +133,7 @@ SCM_DEFINE (scm_run_asyncs, "run-asyncs", 1, 0, 0,
static scm_i_pthread_mutex_t async_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER; static scm_i_pthread_mutex_t async_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER;
SCM_PTHREAD_ATFORK_LOCK_STATIC_MUTEX (async_mutex);
/* System asyncs. */ /* System asyncs. */

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2001, 2006, 2010, 2011 Free Software Foundation, Inc. /* Copyright (C) 2001, 2006, 2010, 2011, 2012 Free Software Foundation, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -48,6 +48,7 @@ struct issued_warning {
}; };
static scm_i_pthread_mutex_t warn_lock = SCM_I_PTHREAD_MUTEX_INITIALIZER; static scm_i_pthread_mutex_t warn_lock = SCM_I_PTHREAD_MUTEX_INITIALIZER;
SCM_PTHREAD_ATFORK_LOCK_STATIC_MUTEX (warn_lock);
static struct issued_warning *issued_warnings; static struct issued_warning *issued_warnings;
static int print_summary = 0; static int print_summary = 0;

View file

@ -44,6 +44,7 @@ static void **allocated_fluids = NULL;
static size_t allocated_fluids_len = 0; static size_t allocated_fluids_len = 0;
static scm_i_pthread_mutex_t fluid_admin_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER; static scm_i_pthread_mutex_t fluid_admin_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER;
SCM_PTHREAD_ATFORK_LOCK_STATIC_MUTEX (fluid_admin_mutex);
#define IS_FLUID(x) SCM_FLUID_P (x) #define IS_FLUID(x) SCM_FLUID_P (x)
#define FLUID_NUM(x) SCM_I_FLUID_NUM (x) #define FLUID_NUM(x) SCM_I_FLUID_NUM (x)

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2006, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. /* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2006, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -647,6 +647,7 @@ scm_storage_prehistory ()
} }
scm_i_pthread_mutex_t scm_i_gc_admin_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER; scm_i_pthread_mutex_t scm_i_gc_admin_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER;
SCM_PTHREAD_ATFORK_LOCK_STATIC_MUTEX (scm_i_gc_admin_mutex);
void void
scm_init_gc_protect_object () scm_init_gc_protect_object ()

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2001, 2009, 2010, 2011 Free Software Foundation, Inc. /* Copyright (C) 2001, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -48,6 +48,7 @@ struct scm_instruction {
static scm_i_pthread_mutex_t itable_lock = SCM_I_PTHREAD_MUTEX_INITIALIZER; static scm_i_pthread_mutex_t itable_lock = SCM_I_PTHREAD_MUTEX_INITIALIZER;
SCM_PTHREAD_ATFORK_LOCK_STATIC_MUTEX (itable_lock);
static struct scm_instruction* static struct scm_instruction*

View file

@ -103,6 +103,7 @@ static long scm_numptob = 0; /* Number of port types. */
static long scm_ptobs_size = 0; /* Number of slots in the port type static long scm_ptobs_size = 0; /* Number of slots in the port type
table. */ table. */
static scm_i_pthread_mutex_t scm_ptobs_lock = SCM_I_PTHREAD_MUTEX_INITIALIZER; static scm_i_pthread_mutex_t scm_ptobs_lock = SCM_I_PTHREAD_MUTEX_INITIALIZER;
SCM_PTHREAD_ATFORK_LOCK_STATIC_MUTEX (scm_ptobs_lock);
long long
scm_c_num_port_types (void) scm_c_num_port_types (void)

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. /* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -1493,6 +1493,7 @@ SCM_DEFINE (scm_putenv, "putenv", 1, 0, 0,
is also acquired before calls to `nl_langinfo ()'. See `i18n.c' for is also acquired before calls to `nl_langinfo ()'. See `i18n.c' for
details. */ details. */
scm_i_pthread_mutex_t scm_i_locale_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER; scm_i_pthread_mutex_t scm_i_locale_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER;
SCM_PTHREAD_ATFORK_LOCK_STATIC_MUTEX (scm_i_locale_mutex);
#ifdef HAVE_SETLOCALE #ifdef HAVE_SETLOCALE

View file

@ -226,6 +226,7 @@ narrow_stringbuf (SCM buf)
} }
scm_i_pthread_mutex_t stringbuf_write_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER; scm_i_pthread_mutex_t stringbuf_write_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER;
SCM_PTHREAD_ATFORK_LOCK_STATIC_MUTEX (stringbuf_write_mutex);
/* Copy-on-write strings. /* Copy-on-write strings.

View file

@ -500,6 +500,7 @@ SCM_THREAD_LOCAL scm_i_thread *scm_i_current_thread = NULL;
static scm_i_pthread_mutex_t thread_admin_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER; static scm_i_pthread_mutex_t thread_admin_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER;
SCM_PTHREAD_ATFORK_LOCK_STATIC_MUTEX (thread_admin_mutex);
static scm_i_thread *all_threads = NULL; static scm_i_thread *all_threads = NULL;
static int thread_count; static int thread_count;
@ -2134,6 +2135,7 @@ static int threads_initialized_p = 0;
/* This mutex is used by SCM_CRITICAL_SECTION_START/END. /* This mutex is used by SCM_CRITICAL_SECTION_START/END.
*/ */
scm_i_pthread_mutex_t scm_i_critical_section_mutex; scm_i_pthread_mutex_t scm_i_critical_section_mutex;
SCM_PTHREAD_ATFORK_LOCK_STATIC_MUTEX (scm_i_critical_section_mutex);
static SCM dynwind_critical_section_mutex; static SCM dynwind_critical_section_mutex;
@ -2149,6 +2151,7 @@ scm_dynwind_critical_section (SCM mutex)
/*** Initialization */ /*** Initialization */
scm_i_pthread_mutex_t scm_i_misc_mutex; scm_i_pthread_mutex_t scm_i_misc_mutex;
SCM_PTHREAD_ATFORK_LOCK_STATIC_MUTEX (scm_i_misc_mutex);
#if SCM_USE_PTHREAD_THREADS #if SCM_USE_PTHREAD_THREADS
pthread_mutexattr_t scm_i_pthread_mutexattr_recursive[1]; pthread_mutexattr_t scm_i_pthread_mutexattr_recursive[1];