/bionic/libc/stdio/ |
D | refill.c | 40 lflush(FILE *fp) in lflush() argument 42 if ((fp->_flags & (__SLBF|__SWR)) == (__SLBF|__SWR)) in lflush() 43 return (__sflush_locked(fp)); /* ignored... */ in lflush() 52 __srefill(FILE *fp) in __srefill() argument 54 fp->_r = 0; /* largely a convenience for callers */ in __srefill() 58 if (fp->_flags & __SEOF) in __srefill() 63 if ((fp->_flags & __SRD) == 0) { in __srefill() 64 if ((fp->_flags & __SRW) == 0) { in __srefill() 66 fp->_flags |= __SERR; in __srefill() 70 if (fp->_flags & __SWR) { in __srefill() [all …]
|
D | stdio.cpp | 103 explicit ScopedFileLock(FILE* fp) : fp_(fp) { in ScopedFileLock() argument 139 FILE *fp; in __sfp() local 145 for (fp = g->iobs, n = g->niobs; --n >= 0; fp++) in __sfp() 146 if (fp->_flags == 0) in __sfp() 157 fp = g->iobs; in __sfp() 159 fp->_flags = 1; /* reserve this slot; caller sets real flags */ in __sfp() 161 fp->_p = NULL; /* no current pointer */ in __sfp() 162 fp->_w = 0; /* nothing to read or write */ in __sfp() 163 fp->_r = 0; in __sfp() 164 fp->_bf._base = NULL; /* no buffer */ in __sfp() [all …]
|
D | stdio_ext.cpp | 37 size_t __fbufsize(FILE* fp) { in __fbufsize() argument 38 return fp->_bf._size; in __fbufsize() 53 int __freadable(FILE* fp) { in __freadable() argument 54 return (fp->_flags & (__SRD|__SRW)) != 0; in __freadable() 57 int __fwritable(FILE* fp) { in __fwritable() argument 58 return (fp->_flags & (__SWR|__SRW)) != 0; in __fwritable() 61 int __flbf(FILE* fp) { in __flbf() argument 62 return (fp->_flags & __SLBF) != 0; in __flbf() 65 void __fpurge(FILE* fp) { in __fpurge() argument 66 fpurge(fp); in __fpurge() [all …]
|
D | fread.c | 44 fread(void *buf, size_t size, size_t count, FILE *fp) __overloadable in fread() argument 52 fp->_flags |= __SERR; in fread() 66 FLOCKFILE(fp); in fread() 67 _SET_ORIENTATION(fp, -1); in fread() 70 if (fp->_r < 0) in fread() 71 fp->_r = 0; in fread() 76 if (fp->_bf._base == NULL) { in fread() 77 __smakebuf(fp); in fread() 86 size_t buffered_bytes = MIN((size_t) fp->_r, total); in fread() 87 memcpy(dst, fp->_p, buffered_bytes); in fread() [all …]
|
D | local.h | 150 #define _EXT(fp) __BIONIC_CAST(reinterpret_cast, struct __sfileext*, (fp)->_ext._base) argument 152 #define _UB(fp) _EXT(fp)->_ub argument 153 #define _FLOCK(fp) _EXT(fp)->_lock argument 155 #define _FILEEXT_INIT(fp) \ argument 157 _UB(fp)._base = NULL; \ 158 _UB(fp)._size = 0; \ 159 WCIO_INIT(fp); \ 163 pthread_mutex_init(&_FLOCK(fp), &attr); \ 165 _EXT(fp)->_caller_handles_locking = false; \ 212 #define cantwrite(fp) \ argument [all …]
|
D | wcio.h | 52 #define WCIO_GET(fp) \ argument 53 (_EXT(fp) ? &(_EXT(fp)->_wcio) : (struct wchar_io_data *)0) 55 #define _SET_ORIENTATION(fp, mode) \ argument 57 struct wchar_io_data *_wcio = WCIO_GET(fp); \ 65 #define WCIO_FREE(fp) \ argument 67 struct wchar_io_data *_wcio = WCIO_GET(fp); \ 74 #define WCIO_FREEUB(fp) \ argument 76 struct wchar_io_data *_wcio = WCIO_GET(fp); \ 82 #define WCIO_INIT(fp) \ argument 83 memset(&(_EXT(fp)->_wcio), 0, sizeof(struct wchar_io_data))
|
D | vfscanf.c | 99 __svfscanf(FILE *fp, const char *fmt0, __va_list ap) in __svfscanf() argument 123 _SET_ORIENTATION(fp, -1); in __svfscanf() 133 while ((fp->_r > 0 || __srefill(fp) == 0) && in __svfscanf() 134 isspace(*fp->_p)) in __svfscanf() 135 nread++, fp->_r--, fp->_p++; in __svfscanf() 150 if (fp->_r <= 0 && __srefill(fp)) in __svfscanf() 152 if (*fp->_p != c) in __svfscanf() 154 fp->_r--, fp->_p++; in __svfscanf() 310 if (fp->_r <= 0 && __srefill(fp)) in __svfscanf() 318 while (isspace(*fp->_p)) { in __svfscanf() [all …]
|
/bionic/libc/upstream-openbsd/lib/libc/stdio/ |
D | ungetc.c | 47 __submore(FILE *fp) in __submore() argument 52 if (_UB(fp)._base == fp->_ubuf) { in __submore() 58 _UB(fp)._base = p; in __submore() 59 _UB(fp)._size = BUFSIZ; in __submore() 60 p += BUFSIZ - sizeof(fp->_ubuf); in __submore() 61 for (i = sizeof(fp->_ubuf); --i >= 0;) in __submore() 62 p[i] = fp->_ubuf[i]; in __submore() 63 fp->_p = p; in __submore() 66 i = _UB(fp)._size; in __submore() 67 p = reallocarray(_UB(fp)._base, i, 2); in __submore() [all …]
|
D | wsetup.c | 44 __swsetup(FILE *fp) in __swsetup() argument 53 if ((fp->_flags & __SWR) == 0) { in __swsetup() 54 if ((fp->_flags & __SRW) == 0) in __swsetup() 56 if (fp->_flags & __SRD) { in __swsetup() 58 if (HASUB(fp)) in __swsetup() 59 FREEUB(fp); in __swsetup() 60 fp->_flags &= ~(__SRD|__SEOF); in __swsetup() 61 fp->_r = 0; in __swsetup() 62 fp->_p = fp->_bf._base; in __swsetup() 64 fp->_flags |= __SWR; in __swsetup() [all …]
|
D | fgetln.c | 43 __slbexpand(FILE *fp, size_t newsize) in __slbexpand() argument 47 if (fp->_lb._size >= newsize) in __slbexpand() 49 if ((p = realloc(fp->_lb._base, newsize)) == NULL) in __slbexpand() 51 fp->_lb._base = p; in __slbexpand() 52 fp->_lb._size = newsize; in __slbexpand() 64 fgetln(FILE *fp, size_t *lenp) in fgetln() argument 71 FLOCKFILE(fp); in fgetln() 72 _SET_ORIENTATION(fp, -1); in fgetln() 75 if (fp->_r <= 0 && __srefill(fp)) in fgetln() 79 if ((p = memchr((void *)fp->_p, '\n', fp->_r)) != NULL) { in fgetln() [all …]
|
D | fpurge.c | 44 fpurge(FILE *fp) in fpurge() argument 46 FLOCKFILE(fp); in fpurge() 47 if (!fp->_flags) { in fpurge() 48 FUNLOCKFILE(fp); in fpurge() 53 if (HASUB(fp)) in fpurge() 54 FREEUB(fp); in fpurge() 55 WCIO_FREE(fp); in fpurge() 56 fp->_p = fp->_bf._base; in fpurge() 57 fp->_r = 0; in fpurge() 58 fp->_w = fp->_flags & (__SLBF|__SNBF) ? 0 : fp->_bf._size; in fpurge() [all …]
|
D | fflush.c | 40 fflush(FILE *fp) in fflush() argument 44 if (fp == NULL) in fflush() 46 FLOCKFILE(fp); in fflush() 47 if ((fp->_flags & (__SWR | __SRW)) == 0) { in fflush() 51 r = __sflush(fp); in fflush() 52 FUNLOCKFILE(fp); in fflush() 57 __sflush(FILE *fp) in __sflush() argument 62 t = fp->_flags; in __sflush() 66 if ((p = fp->_bf._base) == NULL) in __sflush() 69 n = fp->_p - p; /* write this much */ in __sflush() [all …]
|
D | setvbuf.c | 43 setvbuf(FILE *fp, char *buf, int mode, size_t size) in setvbuf() argument 64 FLOCKFILE(fp); in setvbuf() 66 (void)__sflush(fp); in setvbuf() 67 if (HASUB(fp)) in setvbuf() 68 FREEUB(fp); in setvbuf() 69 WCIO_FREE(fp); in setvbuf() 70 fp->_r = fp->_lbfsize = 0; in setvbuf() 71 flags = fp->_flags; in setvbuf() 73 free((void *)fp->_bf._base); in setvbuf() 85 flags |= __swhatbuf(fp, &iosize, &ttyflag); in setvbuf() [all …]
|
D | makebuf.c | 49 __smakebuf(FILE *fp) in __smakebuf() argument 56 if (fp->_flags & __SNBF) { in __smakebuf() 57 fp->_bf._base = fp->_p = fp->_nbuf; in __smakebuf() 58 fp->_bf._size = 1; in __smakebuf() 61 flags = __swhatbuf(fp, &size, &couldbetty); in __smakebuf() 63 fp->_flags |= __SNBF; in __smakebuf() 64 fp->_bf._base = fp->_p = fp->_nbuf; in __smakebuf() 65 fp->_bf._size = 1; in __smakebuf() 69 fp->_bf._base = fp->_p = p; in __smakebuf() 70 fp->_bf._size = size; in __smakebuf() [all …]
|
D | wbuf.c | 44 __swbuf(int c, FILE *fp) in __swbuf() argument 48 _SET_ORIENTATION(fp, -1); in __swbuf() 56 fp->_w = fp->_lbfsize; in __swbuf() 57 if (cantwrite(fp)) { in __swbuf() 72 n = fp->_p - fp->_bf._base; in __swbuf() 73 if (n >= fp->_bf._size) { in __swbuf() 74 if (__sflush(fp)) in __swbuf() 78 fp->_w--; in __swbuf() 79 *fp->_p++ = c; in __swbuf() 80 if (++n == fp->_bf._size || (fp->_flags & __SLBF && c == '\n')) in __swbuf() [all …]
|
D | fvwrite.c | 48 __sfvwrite(FILE *fp, struct __suio *uio) in __sfvwrite() argument 60 if (cantwrite(fp)) { in __sfvwrite() 66 #define COPY(n) (void)memcpy((void *)fp->_p, (void *)p, (size_t)(n)) in __sfvwrite() 79 if (fp->_flags & __SNBF) { in __sfvwrite() 85 w = (*fp->_write)(fp->_cookie, p, MIN(len, BUFSIZ)); in __sfvwrite() 91 } else if ((fp->_flags & __SLBF) == 0) { in __sfvwrite() 105 if ((fp->_flags & (__SALC | __SSTR)) == in __sfvwrite() 106 (__SALC | __SSTR) && fp->_w < len) { in __sfvwrite() 107 size_t blen = fp->_p - fp->_bf._base; in __sfvwrite() 112 _size = fp->_bf._size; in __sfvwrite() [all …]
|
D | fgets.c | 46 fgets(char *buf, int n, FILE *fp) __overloadable in fgets() argument 57 FLOCKFILE(fp); in fgets() 58 _SET_ORIENTATION(fp, -1); in fgets() 65 if (fp->_r <= 0) { in fgets() 66 if (__srefill(fp)) { in fgets() 69 FUNLOCKFILE(fp); in fgets() 75 len = fp->_r; in fgets() 76 p = fp->_p; in fgets() 89 fp->_r -= len; in fgets() 90 fp->_p = t; in fgets() [all …]
|
D | fputws.c | 40 fputws(ws, fp) in fputws() argument 42 FILE * __restrict fp; 44 FLOCKFILE(fp); 45 _SET_ORIENTATION(fp, 1); 48 if (__fputwc_unlock(*ws++, fp) == WEOF) { 49 FUNLOCKFILE(fp); 54 FUNLOCKFILE(fp);
|
D | getdelim.c | 47 int sep, FILE *__restrict fp) in getdelim() argument 53 FLOCKFILE(fp); in getdelim() 64 _SET_ORIENTATION(fp, -1); in getdelim() 68 if (fp->_r <= 0 && __srefill(fp)) { in getdelim() 69 if (__sferror(fp)) in getdelim() 76 p = memchr(fp->_p, sep, (size_t)fp->_r); in getdelim() 78 len = fp->_r; in getdelim() 80 len = (p - fp->_p) + 1; in getdelim() 113 (void)memcpy((*buf + off), fp->_p, len); in getdelim() 115 fp->_r -= (int)len; in getdelim() [all …]
|
D | ungetwc.c | 38 __ungetwc(wint_t wc, FILE *fp) in __ungetwc() argument 45 _SET_ORIENTATION(fp, 1); in __ungetwc() 52 wcio = WCIO_GET(fp); in __ungetwc() 63 __sclearerr(fp); in __ungetwc() 69 ungetwc(wint_t wc, FILE *fp) in ungetwc() argument 73 FLOCKFILE(fp); in ungetwc() 74 r = __ungetwc(wc, fp); in ungetwc() 75 FUNLOCKFILE(fp); in ungetwc()
|
D | rget.c | 43 __srget(FILE *fp) in __srget() argument 45 _SET_ORIENTATION(fp, -1); in __srget() 46 if (__srefill(fp) == 0) { in __srget() 47 fp->_r--; in __srget() 48 return (*fp->_p++); in __srget()
|
/bionic/tests/ |
D | stdio_ext_test.cpp | 36 FILE* fp = fopen("/proc/version", "r"); in TEST() local 39 ASSERT_EQ(0U, __fbufsize(fp)); in TEST() 43 fgets(buf, sizeof(buf), fp); in TEST() 44 ASSERT_EQ(1024U, __fbufsize(fp)); in TEST() 46 ASSERT_EQ(0, setvbuf(fp, buf, _IOFBF, 1)); in TEST() 47 ASSERT_EQ(1U, __fbufsize(fp)); in TEST() 49 ASSERT_EQ(0, setvbuf(fp, buf, _IOFBF, 8)); in TEST() 50 ASSERT_EQ(8U, __fbufsize(fp)); in TEST() 52 fclose(fp); in TEST() 56 FILE* fp = fopen("/proc/version", "r"); in TEST() local [all …]
|
D | stdio_test.cpp | 47 static void AssertFileIs(FILE* fp, const char* expected, bool is_fmemopen = false) { in AssertFileIs() argument 48 rewind(fp); in AssertFileIs() 52 ASSERT_EQ(line, fgets(line, sizeof(line), fp)); in AssertFileIs() 58 ASSERT_EQ(line, fgets(line, sizeof(line), fp)); in AssertFileIs() 63 ASSERT_EQ(nullptr, fgets(line, sizeof(line), fp)) << "junk at end of file: " << line; in AssertFileIs() 75 FILE* fp = fopen("/dev/null", "w"); in TEST() local 76 ASSERT_TRUE(fp != NULL); in TEST() 77 flockfile(fp); in TEST() 78 feof(fp); in TEST() 79 funlockfile(fp); in TEST() [all …]
|
/bionic/libc/bionic/ |
D | malloc_info.cpp | 25 explicit Elem(FILE* fp, const char* name, in Elem() argument 27 this->fp = fp; in Elem() 30 fprintf(fp, "<%s", name); in Elem() 34 fputc(' ', fp); in Elem() 35 vfprintf(fp, attr_fmt, args); in Elem() 38 fputc('>', fp); in Elem() 42 fprintf(fp, "</%s>", name); in ~Elem() 48 vfprintf(fp, fmt, args); in contents() 53 FILE* fp; member in Elem 59 int malloc_info(int options, FILE* fp) { in malloc_info() argument [all …]
|
D | flockfile.cpp | 38 void flockfile(FILE* fp) { in flockfile() argument 39 if (fp != nullptr) { in flockfile() 40 pthread_mutex_lock(&_FLOCK(fp)); in flockfile() 44 int ftrylockfile(FILE* fp) { in ftrylockfile() argument 47 if (fp == nullptr) { in ftrylockfile() 51 return pthread_mutex_trylock(&_FLOCK(fp)); in ftrylockfile() 54 void funlockfile(FILE* fp) { in funlockfile() argument 55 if (fp != nullptr) { in funlockfile() 56 pthread_mutex_unlock(&_FLOCK(fp)); in funlockfile()
|