| 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 "ust-helper.h" |
| 21 | #include "various.h" |
| 22 | #include "wcio.h" |
| 23 | #include "fileext.h" |
| 24 | |
| 25 | LTTNG_HIDDEN |
| 26 | int __sflush(LTTNG_UST_LFILE *); |
| 27 | LTTNG_HIDDEN |
| 28 | LTTNG_UST_LFILE *__sfp(void); |
| 29 | LTTNG_HIDDEN |
| 30 | int __srefill(LTTNG_UST_LFILE *); |
| 31 | LTTNG_HIDDEN |
| 32 | int __sread(void *, char *, int); |
| 33 | LTTNG_HIDDEN |
| 34 | int __swrite(void *, const char *, int); |
| 35 | LTTNG_HIDDEN |
| 36 | fpos_t __sseek(void *, fpos_t, int); |
| 37 | LTTNG_HIDDEN |
| 38 | int __sclose(void *); |
| 39 | LTTNG_HIDDEN |
| 40 | void __sinit(void); |
| 41 | LTTNG_HIDDEN |
| 42 | void _cleanup(void); |
| 43 | LTTNG_HIDDEN |
| 44 | void __smakebuf(LTTNG_UST_LFILE *); |
| 45 | LTTNG_HIDDEN |
| 46 | int __swhatbuf(LTTNG_UST_LFILE *, size_t *, int *); |
| 47 | LTTNG_HIDDEN |
| 48 | int _fwalk(int (*)(LTTNG_UST_LFILE *)); |
| 49 | LTTNG_HIDDEN |
| 50 | int __swsetup(LTTNG_UST_LFILE *); |
| 51 | LTTNG_HIDDEN |
| 52 | int __sflags(const char *, int *); |
| 53 | LTTNG_HIDDEN |
| 54 | wint_t __fgetwc_unlock(LTTNG_UST_LFILE *); |
| 55 | |
| 56 | LTTNG_HIDDEN |
| 57 | extern void __atexit_register_cleanup(void (*)(void)); |
| 58 | LTTNG_HIDDEN |
| 59 | extern int __sdidinit; |
| 60 | |
| 61 | /* |
| 62 | * Return true if the given LTTNG_UST_LFILE cannot be written now. |
| 63 | */ |
| 64 | #define cantwrite(fp) \ |
| 65 | ((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \ |
| 66 | __swsetup(fp)) |
| 67 | |
| 68 | /* |
| 69 | * Test whether the given stdio file has an active ungetc buffer; |
| 70 | * release such a buffer, without restoring ordinary unread data. |
| 71 | */ |
| 72 | #define HASUB(fp) (_UB(fp)._base != NULL) |
| 73 | #define FREEUB(fp) { \ |
| 74 | if (_UB(fp)._base != (fp)->_ubuf) \ |
| 75 | free(_UB(fp)._base); \ |
| 76 | _UB(fp)._base = NULL; \ |
| 77 | } |
| 78 | |
| 79 | /* |
| 80 | * test for an fgetln() buffer. |
| 81 | */ |
| 82 | #define HASLB(fp) ((fp)->_lb._base != NULL) |
| 83 | #define FREELB(fp) { \ |
| 84 | free((char *)(fp)->_lb._base); \ |
| 85 | (fp)->_lb._base = NULL; \ |
| 86 | } |