]> git.saurik.com Git - apple/libc.git/blob - stdio/FreeBSD/findfp.c.patch
f3ec96d7b7eb8eec3958851392d917e529d928d9
[apple/libc.git] / stdio / FreeBSD / findfp.c.patch
1 --- findfp.c.orig Wed Dec 10 13:02:27 2003
2 +++ findfp.c Wed Dec 10 13:04:25 2003
3 @@ -47,6 +47,7 @@
4 #include <stdlib.h>
5 #include <string.h>
6
7 +#include <pthread.h>
8 #include <spinlock.h>
9
10 #include "libc_private.h"
11 @@ -62,12 +63,13 @@
12 {0}, __sFX + file}
13 /* p r w flags file _bf z cookie close read seek write */
14 /* _ub _extra */
15 +#define __sFXInit {0, PTHREAD_MUTEX_INITIALIZER}
16 /* the usual - (stdin + stdout + stderr) */
17 static FILE usual[FOPEN_MAX - 3];
18 static struct __sFILEX usual_extra[FOPEN_MAX - 3];
19 static struct glue uglue = { NULL, FOPEN_MAX - 3, usual };
20
21 -static struct __sFILEX __sFX[3];
22 +static struct __sFILEX __sFX[3] = {__sFXInit, __sFXInit, __sFXInit};
23
24 /*
25 * We can't make this 'static' until 6.0-current due to binary
26 @@ -113,7 +115,7 @@
27 {
28 struct glue *g;
29 static FILE empty;
30 - static struct __sFILEX emptyx;
31 + static struct __sFILEX emptyx = __sFXInit;
32 FILE *p;
33 struct __sFILEX *fx;
34
35 @@ -179,6 +181,7 @@
36 fp->_lb._base = NULL; /* no line buffer */
37 fp->_lb._size = 0;
38 /* fp->_lock = NULL; */ /* once set always set (reused) */
39 + fp->_extra->fl_mutex = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;
40 fp->_extra->orientation = 0;
41 #ifdef notdef
42 /* Stateful encoding/decoding is not yet supported. */