Home
last modified time | relevance | path

Searched refs:fp (Results 1 – 25 of 84) sorted by relevance

1234

/bionic/libc/stdio/
Drefill.c40 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 …]
Dstdio.cpp93 ScopedFileLock(FILE* fp) : fp_(fp) { in ScopedFileLock() argument
129 FILE *fp; in __sfp() local
135 for (fp = g->iobs, n = g->niobs; --n >= 0; fp++) in __sfp()
136 if (fp->_flags == 0) in __sfp()
147 fp = g->iobs; in __sfp()
149 fp->_flags = 1; /* reserve this slot; caller sets real flags */ in __sfp()
151 fp->_p = NULL; /* no current pointer */ in __sfp()
152 fp->_w = 0; /* nothing to read or write */ in __sfp()
153 fp->_r = 0; in __sfp()
154 fp->_bf._base = NULL; /* no buffer */ in __sfp()
[all …]
Dstdio_ext.cpp37 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 …]
Dfread.c44 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 …]
Dlocal.h151 #define _EXT(fp) reinterpret_cast<__sfileext*>((fp)->_ext._base) argument
153 #define _EXT(fp) ((struct __sfileext *)((fp)->_ext._base)) argument
156 #define _UB(fp) _EXT(fp)->_ub argument
157 #define _FLOCK(fp) _EXT(fp)->_lock argument
159 #define _FILEEXT_INIT(fp) \ argument
161 _UB(fp)._base = NULL; \
162 _UB(fp)._size = 0; \
163 WCIO_INIT(fp); \
167 pthread_mutex_init(&_FLOCK(fp), &attr); \
169 _EXT(fp)->_caller_handles_locking = false; \
[all …]
Dwcio.h52 #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))
/bionic/libc/upstream-openbsd/lib/libc/stdio/
Dungetc.c47 __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 …]
Dwsetup.c44 __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 …]
Dfgetln.c43 __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 …]
Dfpurge.c44 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 …]
Dfflush.c40 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 …]
Dsetvbuf.c43 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 …]
Dmakebuf.c49 __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 …]
Dwbuf.c44 __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 …]
Dfvwrite.c48 __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 …]
Dfgets.c46 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 …]
Dputc.c44 putc_unlocked(int c, FILE *fp) in putc_unlocked() argument
46 if (cantwrite(fp)) { in putc_unlocked()
50 _SET_ORIENTATION(fp, -1); in putc_unlocked()
51 return (__sputc(c, fp)); in putc_unlocked()
60 putc(int c, FILE *fp) in putc() argument
64 FLOCKFILE(fp); in putc()
65 ret = putc_unlocked(c, fp); in putc()
66 FUNLOCKFILE(fp); in putc()
Dfputws.c40 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);
Dvfscanf.c99 __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 …]
Dgetdelim.c47 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 …]
Dgetc.c43 getc_unlocked(FILE *fp) in getc_unlocked() argument
45 return (__sgetc(fp)); in getc_unlocked()
54 getc(FILE *fp) in getc() argument
58 FLOCKFILE(fp); in getc()
59 c = __sgetc(fp); in getc()
60 FUNLOCKFILE(fp); in getc()
/bionic/tests/
Dstdio_ext_test.cpp36 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 …]
Dstdio_test.cpp49 FILE* fp = fopen("/dev/null", "w"); in TEST() local
50 ASSERT_TRUE(fp != NULL); in TEST()
51 flockfile(fp); in TEST()
52 feof(fp); in TEST()
53 funlockfile(fp); in TEST()
54 fclose(fp); in TEST()
58 FILE* fp = tmpfile(); in TEST() local
59 ASSERT_TRUE(fp != NULL); in TEST()
61 int fd = fileno(fp); in TEST()
69 rc = fprintf(fp, "hello\n"); in TEST()
[all …]
/bionic/libc/bionic/
Dmalloc_info.cpp25 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 …]
Dflockfile.cpp38 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()

1234