Back to index

glibc  2.9
stdio-lock.h
Go to the documentation of this file.
00001 /* Thread package specific definitions of stream lock type.  Generic version.
00002    Copyright (C) 2000, 2001, 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_STDIO_LOCK_H
00021 #define _BITS_STDIO_LOCK_H 1
00022 
00023 #include <bits/libc-lock.h>
00024 
00025 __libc_lock_define_recursive (typedef, _IO_lock_t)
00026 
00027 /* We need recursive (counting) mutexes.  */
00028 #ifdef _LIBC_LOCK_RECURSIVE_INITIALIZER
00029 # define _IO_lock_initializer _LIBC_LOCK_RECURSIVE_INITIALIZER
00030 #elif _IO_MTSAFE_IO
00031  #error libio needs recursive mutexes for _IO_MTSAFE_IO
00032 #endif
00033 
00034 #define _IO_lock_init(_name)       __libc_lock_init_recursive (_name)
00035 #define _IO_lock_fini(_name)       __libc_lock_fini_recursive (_name)
00036 #define _IO_lock_lock(_name)       __libc_lock_lock_recursive (_name)
00037 #define _IO_lock_trylock(_name)    __libc_lock_trylock_recursive (_name)
00038 #define _IO_lock_unlock(_name)     __libc_lock_unlock_recursive (_name)
00039 
00040 
00041 #define _IO_cleanup_region_start(_fct, _fp) \
00042   __libc_cleanup_region_start (((_fp)->_flags & _IO_USER_LOCK) == 0, _fct, _fp)
00043 #define _IO_cleanup_region_start_noarg(_fct) \
00044   __libc_cleanup_region_start (1, _fct, NULL)
00045 #define _IO_cleanup_region_end(_doit) \
00046   __libc_cleanup_region_end (_doit)
00047 
00048 #if defined _LIBC && !defined NOT_IN_libc
00049 # define _IO_acquire_lock(_fp) \
00050   _IO_cleanup_region_start ((void (*) (void *)) _IO_funlockfile, (_fp));      \
00051   _IO_flockfile (_fp)
00052 
00053 # define _IO_release_lock(_fp) \
00054   _IO_funlockfile (_fp);                                             \
00055   _IO_cleanup_region_end (0)
00056 #endif
00057 
00058 #endif /* bits/stdio-lock.h */