OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [sys/] [linux/] [linuxthreads/] [lockfile.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/* lockfile - Handle locking and unlocking of stream.
2
   Copyright (C) 1996, 1998, 2000 Free Software Foundation, Inc.
3
   This file is part of the GNU C Library.
4
 
5
   The GNU C Library is free software; you can redistribute it and/or
6
   modify it under the terms of the GNU Library General Public License as
7
   published by the Free Software Foundation; either version 2 of the
8
   License, or (at your option) any later version.
9
 
10
   The GNU C Library is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
   Library General Public License for more details.
14
 
15
   You should have received a copy of the GNU Library General Public
16
   License along with the GNU C Library; see the file COPYING.LIB.  If not,
17
   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
   Boston, MA 02111-1307, USA.  */
19
 
20
#include <sys/lock.h>
21
#include <stdio.h>
22
#include <pthread.h>
23
#include "internals.h"
24
 
25
#ifdef USE_IN_LIBIO
26
#include "../libio/libioP.h"
27
#endif
28
 
29
#ifndef SHARED
30
/* We need a hook to force this file to be linked in when static
31
   libpthread is used.  */
32
const int __pthread_provide_lockfile = 0;
33
#endif
34
 
35
void
36
__flockfile (FILE *stream)
37
{
38
  __lock_acquire_recursive (*(_LOCK_RECURSIVE_T *)&stream->_lock);
39
}
40
#undef _IO_flockfile
41
strong_alias (__flockfile, _IO_flockfile)
42
weak_alias (__flockfile, flockfile);
43
 
44
 
45
void
46
__funlockfile (FILE *stream)
47
{
48
  __lock_release_recursive (*(_LOCK_RECURSIVE_T *)&stream->_lock);
49
}
50
#undef _IO_funlockfile
51
strong_alias (__funlockfile, _IO_funlockfile)
52
weak_alias (__funlockfile, funlockfile);
53
 
54
 
55
int
56
__ftrylockfile (FILE *stream)
57
{
58
  return __lock_try_acquire_recursive (*(_LOCK_RECURSIVE_T *)&stream->_lock);
59
}
60
strong_alias (__ftrylockfile, _IO_ftrylockfile)
61
weak_alias (__ftrylockfile, ftrylockfile);
62
 
63
void
64
__flockfilelist(void)
65
{
66
#ifdef USE_IN_LIBIO
67
  _IO_list_lock();
68
#endif
69
}
70
 
71
void
72
__funlockfilelist(void)
73
{
74
#ifdef USE_IN_LIBIO
75
  _IO_list_unlock();
76
#endif
77
}
78
 
79
void
80
__fresetlockfiles (void)
81
{
82
#ifdef USE_IN_LIBIO
83
  _IO_ITER i;
84
 
85
  pthread_mutexattr_t attr;
86
 
87
  __pthread_mutexattr_init (&attr);
88
  __pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE_NP);
89
 
90
  for (i = _IO_iter_begin(); i != _IO_iter_end(); i = _IO_iter_next(i))
91
    __pthread_mutex_init (_IO_iter_file(i)->_lock, &attr);
92
 
93
  __pthread_mutexattr_destroy (&attr);
94
 
95
  _IO_list_resetlock();
96
#endif
97
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.