Blame sysdeps/generic/stdio-lock.h

Packit 6c4009
/* Thread package specific definitions of stream lock type.  Generic version.
Packit 6c4009
   Copyright (C) 2000-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#ifndef _STDIO_LOCK_H
Packit 6c4009
#define _STDIO_LOCK_H 1
Packit 6c4009
Packit 6c4009
#include <libc-lock.h>
Packit 6c4009
Packit 6c4009
__libc_lock_define_recursive (typedef, _IO_lock_t)
Packit 6c4009
#define _IO_lock_t_defined 1
Packit 6c4009
Packit 6c4009
/* We need recursive (counting) mutexes.  */
Packit 6c4009
#ifdef _LIBC_LOCK_RECURSIVE_INITIALIZER
Packit 6c4009
# define _IO_lock_initializer _LIBC_LOCK_RECURSIVE_INITIALIZER
Packit 6c4009
#elif _IO_MTSAFE_IO
Packit 6c4009
 #error libio needs recursive mutexes for _IO_MTSAFE_IO
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#define _IO_lock_init(_name)	__libc_lock_init_recursive (_name)
Packit 6c4009
#define _IO_lock_fini(_name)	__libc_lock_fini_recursive (_name)
Packit 6c4009
#define _IO_lock_lock(_name)	__libc_lock_lock_recursive (_name)
Packit 6c4009
#define _IO_lock_trylock(_name)	__libc_lock_trylock_recursive (_name)
Packit 6c4009
#define _IO_lock_unlock(_name)	__libc_lock_unlock_recursive (_name)
Packit 6c4009
Packit 6c4009
Packit 6c4009
#define _IO_cleanup_region_start(_fct, _fp) \
Packit 6c4009
  __libc_cleanup_region_start (((_fp)->_flags & _IO_USER_LOCK) == 0, _fct, _fp)
Packit 6c4009
#define _IO_cleanup_region_start_noarg(_fct) \
Packit 6c4009
  __libc_cleanup_region_start (1, _fct, NULL)
Packit 6c4009
#define _IO_cleanup_region_end(_doit) \
Packit 6c4009
  __libc_cleanup_region_end (_doit)
Packit 6c4009
Packit 6c4009
#if defined _LIBC && IS_IN (libc)
Packit 6c4009
Packit 6c4009
# ifdef __EXCEPTIONS
Packit 6c4009
# define _IO_acquire_lock(_fp) \
Packit 6c4009
  do {									      \
Packit 6c4009
    FILE *_IO_acquire_lock_file						      \
Packit 6c4009
	__attribute__((cleanup (_IO_acquire_lock_fct)))			      \
Packit 6c4009
	= (_fp);							      \
Packit 6c4009
    _IO_flockfile (_IO_acquire_lock_file);
Packit 6c4009
#  define _IO_acquire_lock_clear_flags2(_fp) \
Packit 6c4009
  do {									      \
Packit 6c4009
    FILE *_IO_acquire_lock_file						      \
Packit 6c4009
	__attribute__((cleanup (_IO_acquire_lock_clear_flags2_fct)))	      \
Packit 6c4009
	= (_fp);							      \
Packit 6c4009
    _IO_flockfile (_IO_acquire_lock_file);
Packit 6c4009
# else
Packit 6c4009
#  define _IO_acquire_lock(_fp) _IO_acquire_lock_needs_exceptions_enabled
Packit 6c4009
#  define _IO_acquire_lock_clear_flags2(_fp) _IO_acquire_lock (_fp)
Packit 6c4009
# endif
Packit 6c4009
# define _IO_release_lock(_fp) ; } while (0)
Packit 6c4009
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#endif /* stdio-lock.h */