-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
No functional change intended. This just rearranges some pieces of stdio so we can build them with the NDK (as part of libandroid_support). The definition of struct __sFILE is moved to stdio/bits/struct_file.h. When building for older API levels, stdio.h includes the public version of this header and gets a definition which conflicts with ours. Match the public header name so we can shadow it. The definition of fpos_t moves into bits/fpos_t.h to accommodate for the above. Move __sglue into its own source file. We don't need the rest of stdio.cpp (and don't want duplicates of things like __sF). Move the *wprintf family into their own source file for the same reason. We may end up doing this with more functions, but for now all libandroid_support needs is the *wprintf family. Test: make checkbuild Test: Able to add vswprintf.c and wprintf.cpp (and everything they need) to libandroid_support and pass libc++ tests in the NDK. Bug: android/ndk#300 Change-Id: I4127071906fc9dacf40e41cff35e403b48ba297c
- Loading branch information
Showing
10 changed files
with
273 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (C) 2017 The Android Open Source Project | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in | ||
* the documentation and/or other materials provided with the | ||
* distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | ||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef BIONIC_BITS_FPOS_T_H | ||
#define BIONIC_BITS_FPOS_T_H | ||
|
||
#include <sys/cdefs.h> | ||
#include <sys/types.h> | ||
|
||
__BEGIN_DECLS | ||
|
||
typedef off_t fpos_t; | ||
typedef off64_t fpos64_t; | ||
|
||
__END_DECLS | ||
|
||
#endif /* BIONIC_BITS_FPOS_T_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* $OpenBSD: local.h,v 1.12 2005/10/10 17:37:44 espie Exp $ */ | ||
|
||
/*- | ||
* Copyright (c) 1990, 1993 | ||
* The Regents of the University of California. All rights reserved. | ||
* | ||
* This code is derived from software contributed to Berkeley by | ||
* Chris Torek. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. Neither the name of the University nor the names of its contributors | ||
* may be used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef BIONIC_STDIO_BITS_STRUCT_FILE_H | ||
#define BIONIC_STDIO_BITS_STRUCT_FILE_H | ||
|
||
#include <bits/fpos_t.h> | ||
#include <sys/cdefs.h> | ||
|
||
__BEGIN_DECLS | ||
|
||
struct __sbuf { | ||
unsigned char* _base; | ||
#if defined(__LP64__) | ||
size_t _size; | ||
#else | ||
int _size; | ||
#endif | ||
}; | ||
|
||
struct __sFILE { | ||
unsigned char* _p; /* current position in (some) buffer */ | ||
int _r; /* read space left for getc() */ | ||
int _w; /* write space left for putc() */ | ||
#if defined(__LP64__) | ||
int _flags; /* flags, below; this FILE is free if 0 */ | ||
int _file; /* fileno, if Unix descriptor, else -1 */ | ||
#else | ||
short _flags; /* flags, below; this FILE is free if 0 */ | ||
short _file; /* fileno, if Unix descriptor, else -1 */ | ||
#endif | ||
struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */ | ||
int _lbfsize; /* 0 or -_bf._size, for inline putc */ | ||
|
||
// Function pointers used by `funopen`. | ||
// Note that `_seek` is ignored if `_seek64` (in __sfileext) is set. | ||
// TODO: NetBSD has `funopen2` which corrects the `int`s to `size_t`s. | ||
// TODO: glibc has `fopencookie` which passes the function pointers in a struct. | ||
void* _cookie; /* cookie passed to io functions */ | ||
int (*_close)(void*); | ||
int (*_read)(void*, char*, int); | ||
fpos_t (*_seek)(void*, fpos_t, int); | ||
int (*_write)(void*, const char*, int); | ||
|
||
/* extension data, to avoid further ABI breakage */ | ||
struct __sbuf _ext; | ||
/* data for long sequences of ungetc() */ | ||
unsigned char* _up; /* saved _p when _p is doing ungetc data */ | ||
int _ur; /* saved _r when _r is counting ungetc data */ | ||
|
||
/* tricks to meet minimum requirements even when malloc() fails */ | ||
unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */ | ||
unsigned char _nbuf[1]; /* guarantee a getc() buffer */ | ||
|
||
/* separate buffer for fgetln() when line crosses buffer boundary */ | ||
struct __sbuf _lb; /* buffer for fgetln() */ | ||
|
||
/* Unix stdio files get aligned to block boundaries on fseek() */ | ||
int _blksize; /* stat.st_blksize (may be != _bf._size) */ | ||
|
||
fpos_t _unused_0; // This was the `_offset` field (see below). | ||
|
||
// Do not add new fields here. (Or remove or change the size of any above.) | ||
// Although bionic currently exports `stdin`, `stdout`, and `stderr` symbols, | ||
// that still hasn't made it to the NDK. All NDK-built apps index directly | ||
// into an array of this struct (which was in <stdio.h> historically), so if | ||
// you need to make any changes, they need to be in the `__sfileext` struct | ||
// below, and accessed via `_EXT`. | ||
}; | ||
|
||
__END_DECLS | ||
|
||
#endif /* BIONIC_STDIO_BITS_STRUCT_FILE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* $OpenBSD: findfp.c,v 1.15 2013/12/17 16:33:27 deraadt Exp $ */ | ||
/*- | ||
* Copyright (c) 1990, 1993 | ||
* The Regents of the University of California. All rights reserved. | ||
* | ||
* This code is derived from software contributed to Berkeley by | ||
* Chris Torek. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3. Neither the name of the University nor the names of its contributors | ||
* may be used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGE. | ||
*/ | ||
#include "glue.h" | ||
|
||
extern FILE __sF[3]; | ||
struct glue __sglue = { NULL, 3, __sF }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
* SUCH DAMAGE. | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <sys/cdefs.h> | ||
|
||
__BEGIN_DECLS | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (C) 2017 The Android Open Source Project | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in | ||
* the documentation and/or other materials provided with the | ||
* distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | ||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGE. | ||
*/ | ||
#ifndef BIONIC_STDIO_PRINTF_IMPL_H | ||
#define BIONIC_STDIO_PRINTF_IMPL_H | ||
|
||
#define PRINTF_IMPL(expr) \ | ||
va_list ap; \ | ||
va_start(ap, fmt); \ | ||
int result = (expr); \ | ||
va_end(ap); \ | ||
return result; | ||
|
||
#endif /* BIONIC_STDIO_PRINTF_IMPL_H */ |
Oops, something went wrong.