source: rtems-libbsd/freebsd/lib/libc/stdio/local.h @ 2404264

4.1155-freebsd-126-freebsd-12freebsd-9.3
Last change on this file since 2404264 was e599318, checked in by Sebastian Huber <sebastian.huber@…>, on 10/09/13 at 20:52:54

Update files to match FreeBSD layout

Add compatibility with Newlib header files. Some FreeBSD header files
are mapped by the translation script:

o rtems/bsd/sys/_types.h
o rtems/bsd/sys/errno.h
o rtems/bsd/sys/lock.h
o rtems/bsd/sys/param.h
o rtems/bsd/sys/resource.h
o rtems/bsd/sys/time.h
o rtems/bsd/sys/timespec.h
o rtems/bsd/sys/types.h
o rtems/bsd/sys/unistd.h

It is now possible to include <sys/socket.h> directly for example.

Generate one Makefile which builds everything including tests.

  • Property mode set to 100644
File size: 4.7 KB
Line 
1/*-
2 * Copyright (c) 1990, 1993
3 *      The Regents of the University of California.  All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 * 4. Neither the name of the University nor the names of its contributors
17 *    may be used to endorse or promote products derived from this software
18 *    without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 *      @(#)local.h     8.3 (Berkeley) 7/3/94
33 * $FreeBSD$
34 */
35
36#include <rtems/bsd/sys/types.h>        /* for off_t */
37#include <pthread.h>
38#include <string.h>
39#include <wchar.h>
40
41/*
42 * Information local to this implementation of stdio,
43 * in particular, macros and private variables.
44 */
45
46extern int      _sread(FILE *, char *, int);
47extern int      _swrite(FILE *, char const *, int);
48extern fpos_t   _sseek(FILE *, fpos_t, int);
49extern int      _ftello(FILE *, fpos_t *);
50extern int      _fseeko(FILE *, off_t, int, int);
51extern int      __fflush(FILE *fp);
52extern void     __fcloseall(void);
53extern wint_t   __fgetwc(FILE *);
54extern wint_t   __fputwc(wchar_t, FILE *);
55extern int      __sflush(FILE *);
56extern FILE     *__sfp(void);
57extern int      __slbexpand(FILE *, size_t);
58#ifndef __rtems__
59extern int      __srefill(FILE *);
60#else
61/*
62 * __srefill is used by fgetln().  The method is in newlib but the
63 * prototype is in a private .h which is not installed.
64 * allows it to be pulled from newlib.
65 */
66extern int __srefill_r(struct _reent *,FILE *);
67
68#define __srefill(_x) __srefill_r(__getreent(), _x)
69#endif
70extern int      __sread(void *, char *, int);
71extern int      __swrite(void *, char const *, int);
72extern fpos_t   __sseek(void *, fpos_t, int);
73extern int      __sclose(void *);
74extern void     __sinit(void);
75extern void     _cleanup(void);
76extern void     __smakebuf(FILE *);
77extern int      __swhatbuf(FILE *, size_t *, int *);
78extern int      _fwalk(int (*)(FILE *));
79extern int      __svfscanf(FILE *, const char *, __va_list);
80extern int      __swsetup(FILE *);
81extern int      __sflags(const char *, int *);
82extern int      __ungetc(int, FILE *);
83extern wint_t   __ungetwc(wint_t, FILE *);
84extern int      __vfprintf(FILE *, const char *, __va_list);
85extern int      __vfscanf(FILE *, const char *, __va_list);
86extern int      __vfwprintf(FILE *, const wchar_t *, __va_list);
87extern int      __vfwscanf(FILE * __restrict, const wchar_t * __restrict,
88                    __va_list);
89extern size_t   __fread(void * __restrict buf, size_t size, size_t count,
90                FILE * __restrict fp);
91extern int      __sdidinit;
92
93
94/*
95 * Prepare the given FILE for writing, and return 0 iff it
96 * can be written now.  Otherwise, return EOF and set errno.
97 */
98#define prepwrite(fp) \
99        ((((fp)->_flags & __SWR) == 0 || \
100            ((fp)->_bf._base == NULL && ((fp)->_flags & __SSTR) == 0)) && \
101         __swsetup(fp))
102
103/*
104 * Test whether the given stdio file has an active ungetc buffer;
105 * release such a buffer, without restoring ordinary unread data.
106 */
107#define HASUB(fp) ((fp)->_ub._base != NULL)
108#define FREEUB(fp) { \
109        if ((fp)->_ub._base != (fp)->_ubuf) \
110                free((char *)(fp)->_ub._base); \
111        (fp)->_ub._base = NULL; \
112}
113
114/*
115 * test for an fgetln() buffer.
116 */
117#define HASLB(fp) ((fp)->_lb._base != NULL)
118#define FREELB(fp) { \
119        free((char *)(fp)->_lb._base); \
120        (fp)->_lb._base = NULL; \
121}
122
123/*
124 * Structure initializations for 'fake' FILE objects.
125 */
126#define FAKE_FILE {                             \
127        ._file = -1,                            \
128        ._fl_mutex = PTHREAD_MUTEX_INITIALIZER, \
129}
130
131/*
132 * Set the orientation for a stream. If o > 0, the stream has wide-
133 * orientation. If o < 0, the stream has byte-orientation.
134 */
135#ifdef __rtems__
136#define ORIENT(fp, o)
137#else
138#define ORIENT(fp, o)   do {                            \
139        if ((fp)->_orientation == 0)                    \
140                (fp)->_orientation = (o);               \
141} while (0)
142#endif
Note: See TracBrowser for help on using the repository browser.