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