Back to index

glibc  2.9
libc-lock.h
Go to the documentation of this file.
00001 /* libc-internal interface for mutex locks.  Stub version.
00002    Copyright (C) 1996,97,99,2000-2002,2003 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #ifndef _BITS_LIBC_LOCK_H
00021 #define _BITS_LIBC_LOCK_H 1
00022 
00023 
00024 /* Define a lock variable NAME with storage class CLASS.  The lock must be
00025    initialized with __libc_lock_init before it can be used (or define it
00026    with __libc_lock_define_initialized, below).  Use `extern' for CLASS to
00027    declare a lock defined in another module.  In public structure
00028    definitions you must use a pointer to the lock structure (i.e., NAME
00029    begins with a `*'), because its storage size will not be known outside
00030    of libc.  */
00031 #define __libc_lock_define(CLASS,NAME)
00032 #define __libc_lock_define_recursive(CLASS,NAME)
00033 #define __rtld_lock_define_recursive(CLASS,NAME)
00034 #define __libc_rwlock_define(CLASS,NAME)
00035 
00036 /* Define an initialized lock variable NAME with storage class CLASS.  */
00037 #define __libc_lock_define_initialized(CLASS,NAME)
00038 #define __libc_rwlock_define_initialized(CLASS,NAME)
00039 
00040 /* Define an initialized recursive lock variable NAME with storage
00041    class CLASS.  */
00042 #define __libc_lock_define_initialized_recursive(CLASS,NAME)
00043 #define __rtld_lock_define_initialized_recursive(CLASS,NAME)
00044 
00045 /* Initialize the named lock variable, leaving it in a consistent, unlocked
00046    state.  */
00047 #define __libc_lock_init(NAME)
00048 #define __libc_rwlock_init(NAME)
00049 
00050 /* Same as last but this time we initialize a recursive mutex.  */
00051 #define __libc_lock_init_recursive(NAME)
00052 #define __rtld_lock_init_recursive(NAME)
00053 
00054 /* Finalize the named lock variable, which must be locked.  It cannot be
00055    used again until __libc_lock_init is called again on it.  This must be
00056    called on a lock variable before the containing storage is reused.  */
00057 #define __libc_lock_fini(NAME)
00058 #define __libc_rwlock_fini(NAME)
00059 
00060 /* Finalize recursive named lock.  */
00061 #define __libc_lock_fini_recursive(NAME)
00062 
00063 /* Lock the named lock variable.  */
00064 #define __libc_lock_lock(NAME)
00065 #define __libc_rwlock_rdlock(NAME)
00066 #define __libc_rwlock_wrlock(NAME)
00067 
00068 /* Lock the recursive named lock variable.  */
00069 #define __libc_lock_lock_recursive(NAME)
00070 #define __rtld_lock_lock_recursive(NAME)
00071 
00072 /* Try to lock the named lock variable.  */
00073 #define __libc_lock_trylock(NAME) 0
00074 #define __libc_rwlock_tryrdlock(NAME) 0
00075 #define __libc_rwlock_trywrlock(NAME) 0
00076 
00077 /* Try to lock the recursive named lock variable.  */
00078 #define __libc_lock_trylock_recursive(NAME) 0
00079 
00080 /* Unlock the named lock variable.  */
00081 #define __libc_lock_unlock(NAME)
00082 #define __libc_rwlock_unlock(NAME)
00083 
00084 /* Unlock the recursive named lock variable.  */
00085 #define __libc_lock_unlock_recursive(NAME)
00086 #define __rtld_lock_unlock_recursive(NAME)
00087 
00088 
00089 /* Define once control variable.  */
00090 #define __libc_once_define(CLASS, NAME) CLASS int NAME = 0
00091 
00092 /* Call handler iff the first call.  */
00093 #define __libc_once(ONCE_CONTROL, INIT_FUNCTION) \
00094   do {                                                               \
00095     if ((ONCE_CONTROL) == 0) {                                              \
00096       INIT_FUNCTION ();                                                     \
00097       (ONCE_CONTROL) = 1;                                            \
00098     }                                                                \
00099   } while (0)
00100 
00101 
00102 /* Start a critical region with a cleanup function */
00103 #define __libc_cleanup_region_start(DOIT, FCT, ARG)                       \
00104 {                                                                  \
00105   typeof (***(FCT)) *__save_FCT = (DOIT) ? (FCT) : 0;                     \
00106   typeof (ARG) __save_ARG = ARG;                                   \
00107   /* close brace is in __libc_cleanup_region_end below. */
00108 
00109 /* End a critical region started with __libc_cleanup_region_start. */
00110 #define __libc_cleanup_region_end(DOIT)                                   \
00111   if ((DOIT) && __save_FCT != 0)                                   \
00112     (*__save_FCT)(__save_ARG);                                            \
00113 }
00114 
00115 /* Sometimes we have to exit the block in the middle.  */
00116 #define __libc_cleanup_end(DOIT)                                   \
00117   if ((DOIT) && __save_FCT != 0)                                   \
00118     (*__save_FCT)(__save_ARG);                                            \
00119 
00120 #define __libc_cleanup_push(fct, arg) __libc_cleanup_region_start (1, fct, arg)
00121 #define __libc_cleanup_pop(execute) __libc_cleanup_region_end (execute)
00122 
00123 /* We need portable names for some of the functions.  */
00124 #define __libc_mutex_unlock
00125 
00126 /* Type for key of thread specific data.  */
00127 typedef int __libc_key_t;
00128 
00129 /* Create key for thread specific data.  */
00130 #define __libc_key_create(KEY,DEST) -1
00131 
00132 /* Set thread-specific data associated with KEY to VAL.  */
00133 #define __libc_setspecific(KEY,VAL) ((void)0)
00134 
00135 /* Get thread-specific data associated with KEY.  */
00136 #define __libc_getspecific(KEY) 0
00137 
00138 #endif /* bits/libc-lock.h */