| 1 | /* $OpenBSD: local.h,v 1.14 2009/10/22 01:23:16 guenther Exp $ */ |
| 2 | |
| 3 | /* |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | * Copyright (C) 1990, 1993 |
| 7 | * The Regents of the University of California. All rights reserved. |
| 8 | * |
| 9 | * This code is derived from software contributed to Berkeley by |
| 10 | * Chris Torek. |
| 11 | */ |
| 12 | |
| 13 | /* |
| 14 | * Information local to this implementation of stdio, |
| 15 | * in particular, macros and private variables. |
| 16 | */ |
| 17 | |
| 18 | #include <stdio.h> |
| 19 | #include <wchar.h> |
| 20 | #include "various.h" |
| 21 | #include "wcio.h" |
| 22 | #include "fileext.h" |
| 23 | |
| 24 | int __sflush(LTTNG_UST_LFILE *) |
| 25 | __attribute__((visibility("hidden"))); |
| 26 | |
| 27 | LTTNG_UST_LFILE *__sfp(void) |
| 28 | __attribute__((visibility("hidden"))); |
| 29 | |
| 30 | int __srefill(LTTNG_UST_LFILE *) |
| 31 | __attribute__((visibility("hidden"))); |
| 32 | |
| 33 | int __sread(void *, char *, int) |
| 34 | __attribute__((visibility("hidden"))); |
| 35 | |
| 36 | int __swrite(void *, const char *, int) |
| 37 | __attribute__((visibility("hidden"))); |
| 38 | |
| 39 | fpos_t __sseek(void *, fpos_t, int) |
| 40 | __attribute__((visibility("hidden"))); |
| 41 | |
| 42 | int __sclose(void *) |
| 43 | __attribute__((visibility("hidden"))); |
| 44 | |
| 45 | void __sinit(void) |
| 46 | __attribute__((visibility("hidden"))); |
| 47 | |
| 48 | void _cleanup(void) |
| 49 | __attribute__((visibility("hidden"))); |
| 50 | |
| 51 | void __smakebuf(LTTNG_UST_LFILE *) |
| 52 | __attribute__((visibility("hidden"))); |
| 53 | |
| 54 | int __swhatbuf(LTTNG_UST_LFILE *, size_t *, int *) |
| 55 | __attribute__((visibility("hidden"))); |
| 56 | |
| 57 | int _fwalk(int (*)(LTTNG_UST_LFILE *)) |
| 58 | __attribute__((visibility("hidden"))); |
| 59 | |
| 60 | int __swsetup(LTTNG_UST_LFILE *) |
| 61 | __attribute__((visibility("hidden"))); |
| 62 | |
| 63 | int __sflags(const char *, int *) |
| 64 | __attribute__((visibility("hidden"))); |
| 65 | |
| 66 | wint_t __fgetwc_unlock(LTTNG_UST_LFILE *) |
| 67 | __attribute__((visibility("hidden"))); |
| 68 | |
| 69 | extern void __atexit_register_cleanup(void (*)(void)) |
| 70 | __attribute__((visibility("hidden"))); |
| 71 | |
| 72 | extern int __sdidinit |
| 73 | __attribute__((visibility("hidden"))); |
| 74 | |
| 75 | /* |
| 76 | * Return true if the given LTTNG_UST_LFILE cannot be written now. |
| 77 | */ |
| 78 | #define cantwrite(fp) \ |
| 79 | ((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \ |
| 80 | __swsetup(fp)) |
| 81 | |
| 82 | /* |
| 83 | * Test whether the given stdio file has an active ungetc buffer; |
| 84 | * release such a buffer, without restoring ordinary unread data. |
| 85 | */ |
| 86 | #define HASUB(fp) (_UB(fp)._base != NULL) |
| 87 | #define FREEUB(fp) { \ |
| 88 | if (_UB(fp)._base != (fp)->_ubuf) \ |
| 89 | free(_UB(fp)._base); \ |
| 90 | _UB(fp)._base = NULL; \ |
| 91 | } |
| 92 | |
| 93 | /* |
| 94 | * test for an fgetln() buffer. |
| 95 | */ |
| 96 | #define HASLB(fp) ((fp)->_lb._base != NULL) |
| 97 | #define FREELB(fp) { \ |
| 98 | free((char *)(fp)->_lb._base); \ |
| 99 | (fp)->_lb._base = NULL; \ |
| 100 | } |