findfp.c (1a0fda2b547365c9453523592a445dfe21266d4b) | findfp.c (1b0181df2f46ef73a41ea8c9b7026718f8eec3a1) |
---|---|
1/*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Chris Torek. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 47 unchanged lines hidden (view full) --- 56#define std(flags, file) { \ 57 ._flags = (flags), \ 58 ._file = (file), \ 59 ._cookie = __sF + (file), \ 60 ._close = __sclose, \ 61 ._read = __sread, \ 62 ._seek = __sseek, \ 63 ._write = __swrite, \ | 1/*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Chris Torek. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 47 unchanged lines hidden (view full) --- 56#define std(flags, file) { \ 57 ._flags = (flags), \ 58 ._file = (file), \ 59 ._cookie = __sF + (file), \ 60 ._close = __sclose, \ 61 ._read = __sread, \ 62 ._seek = __sseek, \ 63 ._write = __swrite, \ |
64 ._fl_mutex = PTHREAD_MUTEX_INITIALIZER, \ |
|
64} 65 /* the usual - (stdin + stdout + stderr) */ 66static FILE usual[FOPEN_MAX - 3]; 67static struct glue uglue = { NULL, FOPEN_MAX - 3, usual }; 68 69static FILE __sF[3] = { 70 std(__SRD, STDIN_FILENO), 71 std(__SWR, STDOUT_FILENO), --- 19 unchanged lines hidden (view full) --- 91#define SET_GLUE_PTR(ptr, val) ptr = val 92#endif 93 94static struct glue * 95moreglue(n) 96 int n; 97{ 98 struct glue *g; | 65} 66 /* the usual - (stdin + stdout + stderr) */ 67static FILE usual[FOPEN_MAX - 3]; 68static struct glue uglue = { NULL, FOPEN_MAX - 3, usual }; 69 70static FILE __sF[3] = { 71 std(__SRD, STDIN_FILENO), 72 std(__SWR, STDOUT_FILENO), --- 19 unchanged lines hidden (view full) --- 92#define SET_GLUE_PTR(ptr, val) ptr = val 93#endif 94 95static struct glue * 96moreglue(n) 97 int n; 98{ 99 struct glue *g; |
99 static FILE empty; | 100 static FILE empty = { ._fl_mutex = PTHREAD_MUTEX_INITIALIZER }; |
100 FILE *p; 101 102 g = (struct glue *)malloc(sizeof(*g) + ALIGNBYTES + n * sizeof(FILE)); 103 if (g == NULL) 104 return (NULL); 105 p = (FILE *)ALIGN(g + 1); 106 g->next = NULL; 107 g->niobs = n; --- 41 unchanged lines hidden (view full) --- 149 fp->_bf._size = 0; 150 fp->_lbfsize = 0; /* not line buffered */ 151 fp->_file = -1; /* no file */ 152/* fp->_cookie = <any>; */ /* caller sets cookie, _read/_write etc */ 153 fp->_ub._base = NULL; /* no ungetc buffer */ 154 fp->_ub._size = 0; 155 fp->_lb._base = NULL; /* no line buffer */ 156 fp->_lb._size = 0; | 101 FILE *p; 102 103 g = (struct glue *)malloc(sizeof(*g) + ALIGNBYTES + n * sizeof(FILE)); 104 if (g == NULL) 105 return (NULL); 106 p = (FILE *)ALIGN(g + 1); 107 g->next = NULL; 108 g->niobs = n; --- 41 unchanged lines hidden (view full) --- 150 fp->_bf._size = 0; 151 fp->_lbfsize = 0; /* not line buffered */ 152 fp->_file = -1; /* no file */ 153/* fp->_cookie = <any>; */ /* caller sets cookie, _read/_write etc */ 154 fp->_ub._base = NULL; /* no ungetc buffer */ 155 fp->_ub._size = 0; 156 fp->_lb._base = NULL; /* no line buffer */ 157 fp->_lb._size = 0; |
157/* fp->_lock = NULL; */ /* once set always set (reused) */ | 158/* fp->_fl_mutex = NULL; */ /* once set always set (reused) */ |
158 fp->_orientation = 0; 159 memset(&fp->_mbstate, 0, sizeof(mbstate_t)); 160 return (fp); 161} 162 163/* 164 * XXX. Force immediate allocation of internal memory. Not used by stdio, 165 * but documented historically for certain applications. Bad applications. --- 51 unchanged lines hidden --- | 159 fp->_orientation = 0; 160 memset(&fp->_mbstate, 0, sizeof(mbstate_t)); 161 return (fp); 162} 163 164/* 165 * XXX. Force immediate allocation of internal memory. Not used by stdio, 166 * but documented historically for certain applications. Bad applications. --- 51 unchanged lines hidden --- |