-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[libc][stdio] Use proxy headers of stdio.h in src and test folders. #110067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
|
||
#else // Overlay mode | ||
|
||
#include <stdio.h> | ||
#include "stdio_overlay.h" | ||
|
||
#endif // LLVM_LIBC_FULL_BUILD | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//===-- Including stdio.h in overlay mode ---------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_LIBC_HDR_STDIO_OVERLAY_H | ||
#define LLVM_LIBC_HDR_STDIO_OVERLAY_H | ||
|
||
#ifdef LIBC_FULL_BUILD | ||
#error "This header should only be included in overlay mode" | ||
#endif | ||
|
||
// Overlay mode | ||
|
||
// glibc <stdio.h> header might provide extern inline definitions for few | ||
// functions, causing external alias errors. They are guarded by | ||
// `__USE_EXTERN_INLINES` macro. We temporarily disable `__USE_EXTERN_INLINES` | ||
// macro by defining `__NO_INLINE__` before including <stdio.h>. | ||
// And the same with `__USE_FORTIFY_LEVEL`, which will be temporarily disabled | ||
// with `_FORTIFY_SOURCE`. | ||
|
||
#ifdef _FORTIFY_SOURCE | ||
#define LIBC_OLD_FORTIFY_SOURCE _FORTIFY_SOURCE | ||
#undef _FORTIFY_SOURCE | ||
#endif | ||
|
||
#ifndef __NO_INLINE__ | ||
#define __NO_INLINE__ 1 | ||
#define LIBC_SET_NO_INLINE | ||
#endif | ||
|
||
#include <stdio.h> | ||
|
||
#ifdef LIBC_OLD_FORTIFY_SOURCE | ||
#define _FORTIFY_SOURCE LIBC_OLD_FORTIFY_SOURCE | ||
#undef LIBC_OLD_FORTIFY_SOURCE | ||
#endif | ||
|
||
#ifdef LIBC_SET_NO_INLINE | ||
#undef __NO_INLINE__ | ||
#undef LIBC_SET_NO_INLINE | ||
#endif | ||
|
||
#endif // LLVM_LIBC_HDR_STDIO_OVERLAY_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,30 @@ | |
#ifndef LLVM_LIBC_MACROS_STDIO_MACROS_H | ||
#define LLVM_LIBC_MACROS_STDIO_MACROS_H | ||
|
||
#include "../llvm-libc-types/FILE.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" FILE *stdin; | ||
extern "C" FILE *stdout; | ||
extern "C" FILE *stderr; | ||
#else | ||
extern FILE *stdin; | ||
extern FILE *stdout; | ||
extern FILE *stderr; | ||
#endif | ||
Comment on lines
+14
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. C99 (and C++) define these as macros https://en.cppreference.com/w/c/io/std_streams, and so I put their definition here together with the macros. Probably we could factor them out to |
||
|
||
#ifndef stdin | ||
#define stdin stdin | ||
#endif | ||
|
||
#ifndef stdout | ||
#define stdout stdout | ||
#endif | ||
|
||
#ifndef stderr | ||
#define stderr stderr | ||
#endif | ||
|
||
#ifndef EOF | ||
#define EOF (-1) | ||
#endif | ||
|
@@ -19,4 +43,16 @@ | |
#define _IOLBF 1 | ||
#define _IOFBF 0 | ||
|
||
#ifndef SEEK_SET | ||
#define SEEK_SET 0 | ||
#endif | ||
|
||
#ifndef SEEK_CUR | ||
#define SEEK_CUR 1 | ||
#endif | ||
|
||
#ifndef SEEK_END | ||
#define SEEK_END 2 | ||
#endif | ||
|
||
#endif // LLVM_LIBC_MACROS_STDIO_MACROS_H |
Uh oh!
There was an error while loading. Please reload this page.