Subversion Repositories Kolibri OS

Rev

Rev 1693 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1693 Rev 3065
Line 25... Line 25...
25
#include 
25
#include 
26
#include 
26
#include 
27
#include 
27
#include 
28
#include "local.h"
28
#include "local.h"
Line 29... Line 29...
29
 
29
 
30
static int
30
int
31
_DEFUN(__fwalk, (ptr, function),
31
_DEFUN(_fwalk, (ptr, function),
32
       struct _reent *ptr _AND
32
       struct _reent *ptr _AND
33
       register int (*function) (FILE *))
33
       register int (*function) (FILE *))
34
{
34
{
35
  register FILE *fp;
35
  register FILE *fp;
36
  register int n, ret = 0;
36
  register int n, ret = 0;
Line -... Line 37...
-
 
37
  register struct _glue *g;
-
 
38
 
-
 
39
  /*
-
 
40
   * It should be safe to walk the list without locking it;
-
 
41
   * new nodes are only added to the end and none are ever
-
 
42
   * removed.
-
 
43
   *
-
 
44
   * Avoid locking this list while walking it or else you will
37
  register struct _glue *g;
45
   * introduce a potential deadlock in [at least] refill.c.
38
 
46
   */
39
  for (g = &ptr->__sglue; g != NULL; g = g->_next)
47
  for (g = &ptr->__sglue; g != NULL; g = g->_next)
40
    for (fp = g->_iobs, n = g->_niobs; --n >= 0; fp++)
48
    for (fp = g->_iobs, n = g->_niobs; --n >= 0; fp++)
41
      if (fp->_flags != 0)
49
      if (fp->_flags != 0)
42
        {
50
        {
43
          if (fp->_flags != 0 && fp->_file != -1)
51
          if (fp->_flags != 0 && fp->_flags != 1 && fp->_file != -1)
Line 44... Line 52...
44
            ret |= (*function) (fp);
52
            ret |= (*function) (fp);
45
        }
53
        }
Line 46... Line 54...
46
 
54
 
47
  return ret;
55
  return ret;
48
}
56
}
49
 
57
 
50
/* Special version of __fwalk where the function pointer is a reentrant
58
/* Special version of __fwalk where the function pointer is a reentrant
51
   I/O function (e.g. _fclose_r).  */
59
   I/O function (e.g. _fclose_r).  */
52
static int
60
int
53
_DEFUN(__fwalk_reent, (ptr, reent_function),
61
_DEFUN(_fwalk_reent, (ptr, reent_function),
54
       struct _reent *ptr _AND
62
       struct _reent *ptr _AND
55
       register int (*reent_function) (struct _reent *, FILE *))
63
       register int (*reent_function) (struct _reent *, FILE *))
Line -... Line 64...
-
 
64
{
-
 
65
  register FILE *fp;
-
 
66
  register int n, ret = 0;
-
 
67
  register struct _glue *g;
-
 
68
 
-
 
69
  /*
-
 
70
   * It should be safe to walk the list without locking it;
-
 
71
   * new nodes are only added to the end and none are ever
56
{
72
   * removed.
57
  register FILE *fp;
73
   *
58
  register int n, ret = 0;
74
   * Avoid locking this list while walking it or else you will
59
  register struct _glue *g;
75
   * introduce a potential deadlock in [at least] refill.c.
60
 
76
   */
61
  for (g = &ptr->__sglue; g != NULL; g = g->_next)
77
  for (g = &ptr->__sglue; g != NULL; g = g->_next)
62
    for (fp = g->_iobs, n = g->_niobs; --n >= 0; fp++)
78
    for (fp = g->_iobs, n = g->_niobs; --n >= 0; fp++)
Line 63... Line 79...
63
      if (fp->_flags != 0)
79
      if (fp->_flags != 0)
64
        {
80
        {
65
          if (fp->_flags != 0 && fp->_file != -1)
-
 
66
            ret |= (*reent_function) (ptr, fp);
-
 
67
        }
-
 
68
 
-
 
69
  return ret;
-
 
70
}
-
 
71
 
-
 
72
int
-
 
73
_DEFUN(_fwalk, (ptr, function),
-
 
74
       struct _reent *ptr _AND
-
 
75
       register int (*function)(FILE *))
-
 
76
{
-
 
77
  register int ret = 0;
-
 
78
 
-
 
79
  __sfp_lock_acquire ();
-
 
80
 
-
 
81
  /* Must traverse given list for streams.  Note that _GLOBAL_REENT
-
 
82
     only walked once in exit().  */
-
 
83
  ret |= __fwalk (ptr, function);
-
 
84
 
-
 
85
  __sfp_lock_release ();
-
 
86
 
-
 
87
  return ret;
-
 
88
}
-
 
89
 
-
 
90
/* Special version of _fwalk which handles a function pointer to a
-
 
91
   reentrant I/O function (e.g. _fclose_r).  */
-
 
92
int
-
 
93
_DEFUN(_fwalk_reent, (ptr, reent_function),
-
 
94
       struct _reent *ptr _AND
-
 
95
       register int (*reent_function) (struct _reent *, FILE *))
-
 
96
{
-
 
97
  register int ret = 0;
-
 
98
 
-
 
99
  __sfp_lock_acquire ();
-
 
100
 
-
 
101
  /* Must traverse given list for streams.  Note that _GLOBAL_REENT
-
 
102
     only walked once in exit().  */
-