/bionic/libc/upstream-openbsd/lib/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 59 fp->_r = 0; /* largely a convenience for callers */ in __srefill() 62 if (fp->_flags & __SEOF) in __srefill() 66 if ((fp->_flags & __SRD) == 0) { in __srefill() 67 if ((fp->_flags & __SRW) == 0) { in __srefill() 69 fp->_flags |= __SERR; in __srefill() 73 if (fp->_flags & __SWR) { in __srefill() [all …]
|
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 | fseek.c | 49 fseeko(FILE *fp, off_t offset, int whence) in fseeko() argument 64 if ((seekfn = fp->_seek) == NULL) { in fseeko() 73 FLOCKFILE(fp); in fseeko() 82 __sflush(fp); /* may adjust seek offset on append stream */ in fseeko() 83 if (fp->_flags & __SOFF) in fseeko() 84 curoff = fp->_offset; in fseeko() 86 curoff = (*seekfn)(fp->_cookie, (fpos_t)0, SEEK_CUR); in fseeko() 88 FUNLOCKFILE(fp); in fseeko() 92 if (fp->_flags & __SRD) { in fseeko() 93 curoff -= fp->_r; in fseeko() [all …]
|
D | freopen.c | 50 freopen(const char *file, const char *mode, FILE *fp) in freopen() argument 56 (void) fclose(fp); in freopen() 63 FLOCKFILE(fp); in freopen() 73 if (fp->_flags == 0) { in freopen() 74 fp->_flags = __SEOF; /* hold on to it */ in freopen() 79 if (fp->_flags & __SWR) in freopen() 80 (void) __sflush(fp); in freopen() 82 isopen = fp->_close != NULL; in freopen() 83 if ((wantfd = fp->_file) < 0 && isopen) { in freopen() 84 (void) (*fp->_close)(fp->_cookie); in freopen() [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 | fclose.c | 40 fclose(FILE *fp) in fclose() argument 44 if (fp->_flags == 0) { /* not open! */ in fclose() 48 FLOCKFILE(fp); in fclose() 49 WCIO_FREE(fp); in fclose() 50 r = fp->_flags & __SWR ? __sflush(fp) : 0; in fclose() 51 if (fp->_close != NULL && (*fp->_close)(fp->_cookie) < 0) in fclose() 53 if (fp->_flags & __SMBF) in fclose() 54 free((char *)fp->_bf._base); in fclose() 55 if (HASUB(fp)) in fclose() 56 FREEUB(fp); in fclose() [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 | ftell.c | 43 ftello(FILE *fp) in ftello() argument 47 if (fp->_seek == NULL) { in ftello() 57 FLOCKFILE(fp); in ftello() 58 __sflush(fp); /* may adjust seek offset on append stream */ in ftello() 59 if (fp->_flags & __SOFF) in ftello() 60 pos = fp->_offset; in ftello() 62 pos = (*fp->_seek)(fp->_cookie, (fpos_t)0, SEEK_CUR); in ftello() 66 if (fp->_flags & __SRD) { in ftello() 72 pos -= fp->_r; in ftello() 73 if (HASUB(fp)) in ftello() [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 | fopen.c | 46 FILE *fp; in fopen() local 52 if ((fp = __sfp()) == NULL) in fopen() 55 fp->_flags = 0; /* release */ in fopen() 61 fp->_flags = 0; /* release */ in fopen() 67 fp->_file = f; in fopen() 68 fp->_flags = flags; in fopen() 69 fp->_cookie = fp; in fopen() 70 fp->_read = __sread; in fopen() 71 fp->_write = __swrite; in fopen() 72 fp->_seek = __sseek; in fopen() [all …]
|
D | fgets.c | 46 fgets(char *buf, int n, FILE *fp) 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 | funopen.c | 43 FILE *fp; in funopen() local 58 if ((fp = __sfp()) == NULL) in funopen() 60 fp->_flags = flags; in funopen() 61 fp->_file = -1; in funopen() 62 fp->_cookie = (void *)cookie; /* SAFE: cookie not modified */ in funopen() 63 fp->_read = readfn; in funopen() 64 fp->_write = writefn; in funopen() 65 fp->_seek = seekfn; in funopen() 66 fp->_close = closefn; in funopen() 67 return (fp); in funopen()
|
/bionic/tests/ |
D | stdio_ext_test.cpp | 35 FILE* fp = fopen("/proc/version", "r"); in TEST() local 38 ASSERT_EQ(0U, __fbufsize(fp)); in TEST() 42 fgets(buf, sizeof(buf), fp); in TEST() 43 ASSERT_EQ(1024U, __fbufsize(fp)); in TEST() 45 ASSERT_EQ(0, setvbuf(fp, buf, _IOFBF, 1)); in TEST() 46 ASSERT_EQ(1U, __fbufsize(fp)); in TEST() 48 ASSERT_EQ(0, setvbuf(fp, buf, _IOFBF, 8)); in TEST() 49 ASSERT_EQ(8U, __fbufsize(fp)); in TEST() 51 fclose(fp); in TEST() 55 FILE* fp = fopen("/proc/version", "r"); in TEST() local [all …]
|
D | stdio_test.cpp | 43 FILE* fp = fopen("/dev/null", "w"); in TEST() local 44 ASSERT_TRUE(fp != NULL); in TEST() 45 flockfile(fp); in TEST() 46 feof(fp); in TEST() 47 funlockfile(fp); in TEST() 48 fclose(fp); in TEST() 52 FILE* fp = tmpfile(); in TEST() local 53 ASSERT_TRUE(fp != NULL); in TEST() 55 int fd = fileno(fp); in TEST() 63 rc = fprintf(fp, "hello\n"); in TEST() [all …]
|
/bionic/libc/stdio/ |
D | stdio_ext.cpp | 35 size_t __fbufsize(FILE* fp) { in __fbufsize() argument 36 return fp->_bf._size; in __fbufsize() 51 int __freadable(FILE* fp) { in __freadable() argument 52 return (fp->_flags & (__SRD|__SRW)) != 0; in __freadable() 55 int __fwritable(FILE* fp) { in __fwritable() argument 56 return (fp->_flags & (__SWR|__SRW)) != 0; in __fwritable() 59 int __flbf(FILE* fp) { in __flbf() argument 60 return (fp->_flags & __SLBF) != 0; in __flbf() 63 void __fpurge(FILE* fp) { in __fpurge() argument 64 fpurge(fp); in __fpurge() [all …]
|
D | fread.c | 44 fread(void *buf, size_t size, size_t count, FILE *fp) 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 | fileext.h | 51 #define _EXT(fp) reinterpret_cast<__sfileext*>((fp)->_ext._base) argument 53 #define _EXT(fp) ((struct __sfileext *)((fp)->_ext._base)) argument 56 #define _UB(fp) _EXT(fp)->_ub argument 57 #define _FLOCK(fp) _EXT(fp)->_lock argument 59 #define _FILEEXT_INIT(fp) \ argument 61 _UB(fp)._base = NULL; \ 62 _UB(fp)._size = 0; \ 63 WCIO_INIT(fp); \ 67 pthread_mutex_init(&_FLOCK(fp), &attr); \ 69 _EXT(fp)->_stdio_handles_locking = true; \
|
D | stdio.c | 47 FILE *fp = cookie; in __sread() local 50 ret = TEMP_FAILURE_RETRY(read(fp->_file, buf, n)); in __sread() 53 fp->_offset += ret; in __sread() 55 fp->_flags &= ~__SOFF; /* paranoia */ in __sread() 62 FILE *fp = cookie; in __swrite() local 64 if (fp->_flags & __SAPP) in __swrite() 65 (void) TEMP_FAILURE_RETRY(lseek(fp->_file, (off_t)0, SEEK_END)); in __swrite() 66 fp->_flags &= ~__SOFF; /* in case FAPPEND mode is set */ in __swrite() 67 return TEMP_FAILURE_RETRY(write(fp->_file, buf, n)); in __swrite() 73 FILE *fp = cookie; in __sseek() local [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 43 if (fp != NULL) { in flockfile() 44 pthread_mutex_lock(&_FLOCK(fp)); in flockfile() 48 int ftrylockfile(FILE* fp) { in ftrylockfile() argument 55 if (fp == NULL) { in ftrylockfile() 59 return pthread_mutex_trylock(&_FLOCK(fp)); in ftrylockfile() 62 void funlockfile(FILE* fp) { in funlockfile() argument 67 if (fp != NULL) { in funlockfile() 68 pthread_mutex_unlock(&_FLOCK(fp)); in funlockfile()
|