Prepare for forthcoming stdio opaque diffs. Don't access the internal

of the FILE object and use the functions from <stdio_ext.h> instead.

ok sthen
This commit is contained in:
yasuoka
2025-07-16 06:27:27 +00:00
parent 9ef5025ae4
commit d0873ca6c0
13 changed files with 202 additions and 11 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ SITES= http://www.arcane-labs.net/download/OpenBSD/
PERMIT_PACKAGE= No
PERMIT_DISTFILES= No
REVISION = 2
REVISION = 3
WANTLIB= c
CONFIGURE_STYLE= gnu dest
+27
View File
@@ -0,0 +1,27 @@
Disable replacing {get,put}c() by accessing FILE internal.
Index: freeze.h
--- freeze.h.orig
+++ freeze.h
@@ -5,21 +5,6 @@
# include <sys/stdtypes.h>
#endif
-#ifndef getc
-# ifdef m88k /* Green Hill C library bug. */
-# define getc(p) (--(p)->_cnt < 0 ? __filbuf(p) : (int) *(p)->_ptr++)
-# else
-# define getc(p) (--(p)->_cnt < 0 ? _filbuf(p) : (int) *(p)->_ptr++)
-# endif
-#endif
-#ifndef putc
-# ifdef m88k /* Green Hill C library bug. */
-# define putc(x, p) (--(p)->_cnt < 0 ? __flsbuf((unsigned char) (x), (p)) : (int) (*(p)->_ptr++ = (unsigned char) (x)))
-# else
-# define putc(x, p) (--(p)->_cnt < 0 ? _flsbuf((unsigned char) (x), (p)) : (int) (*(p)->_ptr++ = (unsigned char) (x)))
-# endif
-#endif
-
#if !defined(MSDOS) && defined(__MSDOS__)
# define MSDOS
#endif
+1 -1
View File
@@ -5,7 +5,7 @@ DISTNAME= sox_ng-${V}
PKGNAME= sox-${V}
SHARED_LIBS += sox_ng 0.0 # 3.0
REVISION= 2
REVISION= 3
CATEGORIES= audio
HOMEPAGE= https://sox.sourceforge.net/
+34 -1
View File
@@ -1,7 +1,20 @@
Use functions from stdio_ext.h instead of using inside FILE object
Index: src/formats.c
--- src/formats.c.orig
+++ src/formats.c
@@ -392,7 +392,7 @@ static FILE * xfopen(char const * identifier, char con
@@ -33,6 +33,10 @@
#include <io.h>
#endif
+#ifdef __OpenBSD__
+ #include <stdio_ext.h>
+#endif
+
#if HAVE_MAGIC
#include <magic.h>
#endif
@@ -392,7 +396,7 @@ static FILE * xfopen(char const * identifier, char con
else if (is_url(identifier)) {
FILE * f = NULL;
#ifdef HAVE_POPEN
@@ -10,3 +23,23 @@ Index: src/formats.c
char * command = lsx_malloc(strlen(command_format) + strlen(identifier));
sprintf(command, command_format, identifier);
f = popen(command, POPEN_MODE);
@@ -410,6 +414,11 @@ static FILE * xfopen(char const * identifier, char con
* Works by resetting the FILE buffer pointer */
static void UNUSED rewind_pipe(FILE * fp)
{
+#ifdef __OpenBSD__
+ size_t sz;
+ if (__freadptr(fp, &sz) != NULL && sz >= PIPE_AUTO_DETECT_SIZE)
+ __freadptrinc(fp, -PIPE_AUTO_DETECT_SIZE);
+#else
/* _FSTDIO is for Torek stdio (i.e. most BSD-derived libc's)
* In theory, we no longer need to check _NEWLIB_VERSION or __APPLE__ */
#if defined _FSTDIO || defined _NEWLIB_VERSION || defined __APPLE__
@@ -427,6 +436,7 @@ static void UNUSED rewind_pipe(FILE * fp)
* or add support for your compiler in the lines above.
* Test with cat monkey.wav | ./sox --info - */
# define NO_REWIND_PIPE
+#endif
#endif
(void)fp;
}
+1 -1
View File
@@ -4,7 +4,7 @@ PKGNAME = kermit-9.0.302
DISTNAME = cku302
CATEGORIES = comms
HOMEPAGE = https://www.kermitproject.org/
REVISION = 0
REVISION = 1
# THE C-KERMIT 9.0 LICENSE (Revised 3-Clause BSD License)
PERMIT_PACKAGE = Yes
+45
View File
@@ -0,0 +1,45 @@
Use __freadahead instead of accessing internal FILE
Index: ckucmd.c
--- ckucmd.c.orig
+++ ckucmd.c
@@ -212,6 +212,10 @@ modules would have to be changed...
#include <io.h>
#endif /* OS2 */
+#ifdef __OpenBSD__
+#include <stdio_ext.h>
+#endif
+
#ifdef OSK
#define cc ccount /* OS-9/68K compiler bug */
#endif /* OSK */
@@ -7328,7 +7332,9 @@ cmdgetc(timelimit) int timelimit; { /* Get a character
#ifndef USE_FILE_CNT
#ifndef USE_FILE__CNT
#ifdef BSD44 /* {Free,Open,Net}BSD, BSDI */
+#ifndef __OpenBSD__ /* recent OpenBSD hides __sFILE */
#define USE_FILE_R
+#endif
#endif /* BSD44 */
#endif /* USE_FILE__CNT */
#endif /* USE_FILE_CNT */
@@ -7362,6 +7368,9 @@ cmdconchk() {
#ifdef OS2
x = conchk(); /* Check device-driver buffer */
if (x < 0) x = 0;
+#elif defined(__OpenBSD__)
+ x = __freadahead(stdin);
+ if (x < 0) x = 0;
#else /* OS2 */
#ifdef CMD_CONINC /* See cmdgetc() */
x = conchk(); /* Check device-driver buffer */
@@ -7395,7 +7404,7 @@ cmdconchk() {
if (x == 0) x = conchk();
if (x < 0) x = 0;
#else /* USE_FILE_CNT */
-#ifdef USE_FILE_R /* FreeBSD, OpenBSD, etc */
+#ifdef USE_FILE_R /* FreeBSD, etc */
debug(F101,"cmdconchk stdin->_r","",stdin->_r);
x = stdin->_r;
if (x == 0) x = conchk();
+1 -1
View File
@@ -6,7 +6,7 @@ COMMENT-wnn4-canna= library for Japanese Input Method canna or wnn4
FULLPKGNAME= ja-onew${FLAVOR_EXT}-2.2.10
DISTNAME= jvim2.0r+onew2.2.10
REVISION= 4
REVISION= 5
CATEGORIES= japanese
SITES= ftp://ftp.lab.kdd.co.jp/Japan/onew/ \
+10 -4
View File
@@ -1,5 +1,8 @@
--- sys/sys.h.orig Fri Jun 30 06:56:38 1995
+++ sys/sys.h Sun Dec 8 15:57:59 2013
Use __freadahead() instead of accessing inside FILE object.
Index: sys/sys.h
--- sys/sys.h.orig
+++ sys/sys.h
@@ -23,6 +23,11 @@
* terminal control: {USE_SGTTY, USE_TERMIO, USE_TERMIOS}
*/
@@ -12,12 +15,15 @@
#if defined(sunos) \
|| defined(pureBSD43) \
|| defined(ultrix) \
@@ -69,7 +74,7 @@
@@ -69,7 +74,10 @@
#define READYCC(fp) (fp->_egptr - fp->_gptr)
#endif
#else
-#if defined(bsdi) || defined(__FreeBSD__)
+#if defined(bsdi) || defined(__FreeBSD__) || defined(__OpenBSD__)
+#ifdef __OpenBSD__
+#include <stdio_ext.h>
+#define READYCC(fp) __freadahead(fp)
+#elif defined(bsdi) || defined(__FreeBSD__)
#define READYCC(fp) (fp->_r)
#else
#define READYCC(fp) (fp->_cnt)
+1 -1
View File
@@ -5,7 +5,7 @@ COMMENT= Scheme interpreter with Tk interface
STK_VERSION= 4.0.1
DISTNAME= STk-${STK_VERSION}
REVISION= 19
REVISION= 20
CATEGORIES= lang
HOMEPAGE= http://kaolin.unice.fr/STk/
+26
View File
@@ -0,0 +1,26 @@
Use __fpending() instead of accessing FILE object internal.
Index: Snow/io.c
--- Snow/io.c.orig
+++ Snow/io.c
@@ -60,6 +60,11 @@
#endif
#define max(a,b) ((a)>(b)? (a) : (b))
+#ifdef __OpenBSD__
+#include <stdio_ext.h>
+# define READ_DATA_PENDING(fp) __fpending(fp)
+#else
+
#ifdef _STDIO_USES_IOSTREAM /* GNU libc */
# if defined(_IO_STDIO_H) || defined (linux)
# define READ_DATA_PENDING(fp) (max(0,(fp)->_IO_read_end - (fp)->_IO_read_ptr))
@@ -76,6 +81,8 @@
# else
# define READ_DATA_PENDING(fp) (fp->_cnt)
# endif
+#endif
+
#endif
+26
View File
@@ -0,0 +1,26 @@
Use __fpending() instead of accessing FILE object internal.
Index: Src/io.c
--- Src/io.c.orig
+++ Src/io.c
@@ -60,6 +60,11 @@
#endif
#define max(a,b) ((a)>(b)? (a) : (b))
+#ifdef __OpenBSD__
+#include <stdio_ext.h>
+# define READ_DATA_PENDING(fp) __fpending(fp)
+#else
+
#ifdef _STDIO_USES_IOSTREAM /* GNU libc */
# if defined(_IO_STDIO_H) || defined (linux)
# define READ_DATA_PENDING(fp) (max(0,(fp)->_IO_read_end - (fp)->_IO_read_ptr))
@@ -76,6 +81,8 @@
# else
# define READ_DATA_PENDING(fp) (fp->_cnt)
# endif
+#endif
+
#endif
static char static_buffer[BUFFER_SIZE+1], *buffer = static_buffer;
+2 -1
View File
@@ -6,11 +6,12 @@ DISTNAME = icon-v951src
CATEGORIES = lang
SITES = http://www.cs.arizona.edu/icon/ftp/packages/unix/
DISTFILES = icon-v951src.tgz
REVISION= 0
MULTI_PACKAGES = -main #-compiler
PKGNAME-main = icon-interp-${VERSION}
REVISION-main = 0
REVISION-main = 1
# Public domain
PERMIT_PACKAGE = Yes
@@ -0,0 +1,27 @@
Use __freadahead() instead of accessing inside FILE object.
Index: ipl/cfuncs/fpoll.c
--- ipl/cfuncs/fpoll.c.orig
+++ ipl/cfuncs/fpoll.c
@@ -32,6 +32,9 @@
#include <string.h> /* for memset call from FD_ZERO (solaris gcc) */
#include <sys/types.h>
#include <sys/time.h>
+#if defined(__OpenBSD__)
+#include <stdio_ext.h>
+#endif
#include "icall.h"
@@ -60,7 +63,10 @@ int fpoll(int argc, descriptor *argv) /*: await data f
/* check for data already in buffer */
/* there's no legal way to do this in C; we cheat */
-#if defined(__GLIBC__) && defined(_STDIO_USES_IOSTREAM) /* new GCC library */
+#if defined(__OpenBSD__)
+ if (__freadahead(f) > 0)
+ RetArg(1);
+#elif defined(__GLIBC__) && defined(_STDIO_USES_IOSTREAM) /* new GCC library */
if (f->_IO_read_ptr < f->_IO_read_end)
RetArg(1);
#elif defined(__GLIBC__) /* old GCC library */