headers: Get glibc <libio.h> out of the default include path.

It's needed by GCC2 stdc++, but we shouldn't be including it
for all consumers of <stdio.h>, which we were. Drop it,
and adjust all the things that were relying on <stdio_pre.h>'s
definition of __PRINTFLIKE to use the _PRINTFLIKE defined
in BeBuild.h instead.

Hopefully should not cause any breakage; the libroot
implementation of __freading depended on this, but
I didn't see anything else which did.
This commit is contained in:
Augustin Cavalier
2025-03-13 15:57:25 -04:00
parent 80f7969714
commit 9769edfa33
9 changed files with 36 additions and 48 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ extern "C" {
char *fgetln(FILE *stream, size_t *_length); char *fgetln(FILE *stream, size_t *_length);
int asprintf(char **ret, char const *format, ...) __PRINTFLIKE(2,3); int asprintf(char **ret, char const *format, ...) _PRINTFLIKE(2,3);
int vasprintf(char **ret, char const *format, va_list ap); int vasprintf(char **ret, char const *format, va_list ap);
+6 -6
View File
@@ -53,8 +53,8 @@
typedef off_t fpos_t; typedef off_t fpos_t;
typedef struct _IO_FILE FILE;
#include <stdio_pre.h>
extern FILE *stdin; extern FILE *stdin;
extern FILE *stdout; extern FILE *stdout;
@@ -169,13 +169,13 @@ extern ssize_t getdelim(char **_line, size_t *_length, int delimiter,
extern ssize_t getline(char **_line, size_t *_length, FILE *stream); extern ssize_t getline(char **_line, size_t *_length, FILE *stream);
/* formatted I/O */ /* formatted I/O */
extern int printf(char const *format, ...) __PRINTFLIKE(1,2); extern int printf(char const *format, ...) _PRINTFLIKE(1,2);
#if !defined(_KERNEL_MODE) && !defined(_BOOT_MODE) && !defined(_LOADER_MODE) #if !defined(_KERNEL_MODE) && !defined(_BOOT_MODE) && !defined(_LOADER_MODE)
extern int dprintf(int fd, char const *format, ...) __PRINTFLIKE(2,3); extern int dprintf(int fd, char const *format, ...) _PRINTFLIKE(2,3);
#endif #endif
extern int fprintf(FILE *stream, char const *format, ...) __PRINTFLIKE(2,3); extern int fprintf(FILE *stream, char const *format, ...) _PRINTFLIKE(2,3);
extern int sprintf(char *string, char const *format, ...) __PRINTFLIKE(2,3); extern int sprintf(char *string, char const *format, ...) _PRINTFLIKE(2,3);
extern int snprintf(char *string, size_t size, char const *format, ...) __PRINTFLIKE(3,4); extern int snprintf(char *string, size_t size, char const *format, ...) _PRINTFLIKE(3,4);
extern int vprintf(char const *format, va_list ap); extern int vprintf(char const *format, va_list ap);
extern int vfprintf(FILE *stream, char const *format, va_list ap); extern int vfprintf(FILE *stream, char const *format, va_list ap);
extern int vsprintf(char *string, char const *format, va_list ap); extern int vsprintf(char *string, char const *format, va_list ap);
-20
View File
@@ -1,20 +0,0 @@
/*
* Copyright 2003-2012 Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _STDIO_PRE_H_
#define _STDIO_PRE_H_
#ifndef _STDIO_H_
# error "This file must be included from stdio.h!"
#endif
#include <libio.h>
typedef struct _IO_FILE FILE;
#define __PRINTFLIKE(format, varargs) __attribute__ ((__format__ (__printf__, format, varargs)))
#define __SCANFLIKE(format, varargs) __attribute__((__format__ (__scanf__, format, varargs)))
#endif /* _STDIO_PRE_H_ */
+2 -3
View File
@@ -10,7 +10,6 @@
#include <module.h> #include <module.h>
#include <stdio.h>
struct kernel_args; struct kernel_args;
@@ -32,8 +31,8 @@ extern "C" {
#endif #endif
int con_init(struct kernel_args *args); int con_init(struct kernel_args *args);
void kprintf(const char *fmt, ...) __PRINTFLIKE(1,2); void kprintf(const char *fmt, ...) _PRINTFLIKE(1,2);
void kprintf_xy(int x, int y, const char *fmt, ...) __PRINTFLIKE(3,4); void kprintf_xy(int x, int y, const char *fmt, ...) _PRINTFLIKE(3,4);
#ifdef __cplusplus #ifdef __cplusplus
} }
@@ -26,6 +26,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
MergeObject <$(architecture)>posix_gnu_libio.o : MergeObject <$(architecture)>posix_gnu_libio.o :
__fpurge.c __fpurge.c
__freading.c
__fsetlocking.c __fsetlocking.c
clearerr.c clearerr.c
clearerr_u.c clearerr_u.c
@@ -0,0 +1,26 @@
/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#include <stdio_ext.h>
int
__freading (FILE *fp)
{
return ((fp->_flags & _IO_NO_WRITES)
|| ((fp->_flags & (_IO_CURRENTLY_PUTTING | _IO_NO_READS)) == 0
&& fp->_IO_read_base != NULL));
}
-1
View File
@@ -10,7 +10,6 @@ for architectureObject in [ MultiArchSubDirSetup ] {
UsePrivateSystemHeaders ; UsePrivateSystemHeaders ;
MergeObject <$(architecture)>posix_stdio.o : MergeObject <$(architecture)>posix_stdio.o :
__freading.cpp
_fseek.c _fseek.c
remove.c remove.c
rename.c rename.c
@@ -1,17 +0,0 @@
/*
* Copyright 2008, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#include <libio.h>
#include <stdio_ext.h>
int
__freading(FILE* stream)
{
// Return true, if writing is not allowed or the last operation was a read.
return (stream->_flags & _IO_NO_WRITES) != 0
|| ((stream->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
&& stream->_IO_read_base != NULL);
}