This patch fixes m2 bootstrap failure on x86_64-darwin. libc_open
is defined with three parameters the last of which is an int for
portability (rather than a vararg). This avoids portability
problems by promoting mode_t to an int. In the future it could
be tidied up by using the m2 optarg extension.
gcc/m2/ChangeLog:
PR modula2/116378
* gm2-libs-iso/TermFile.mod (termOpen): Add third argument
for open.
* gm2-libs/libc.def (open): Remove vararg and use INTEGER for
mode parameter three.
* mc-boot-ch/Glibc.c (tracedb_open): Replace mode_t with int.
(libc_open): Rewrite without varargs.
* mc-boot/Glibc.h (libc_open): Replace varargs with int mode.
* pge-boot/Glibc.cc (libc_open): Rewrite.
* pge-boot/Glibc.h (libc_open): Replace varargs with int mode.
gcc/testsuite/ChangeLog:
PR modula2/116378
* gm2/extensions/run/pass/testopen.mod: Add third argument
for open.
* gm2/isolib/run/pass/openlibc.mod: Ditto.
* gm2/pim/run/pass/testaddr3.mod: Ditto.
(cherry picked from commit
9cdde72d1cefdf2ffff52ad2eec1ff465dccb3ab)
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
THEN
fd := libc.open(ADR("/dev/tty"), O_WRONLY, 0600B)
ELSE
- fd := libc.open(ADR("/dev/tty"), O_RDONLY)
+ fd := libc.open(ADR("/dev/tty"), O_RDONLY, 0)
END ;
IF tcgetattr(fd, new)=0
THEN
open - open the file, filename with flag and mode.
*)
-PROCEDURE open (filename: ADDRESS; oflag: INTEGER; ...) : INTEGER ;
+PROCEDURE open (filename: ADDRESS; oflag: INTEGER; mode: INTEGER) : INTEGER ;
(*
static
void
-tracedb_open (const void *p, int flags, mode_t mode)
+tracedb_open (const void *p, int flags, int mode)
{
#if defined(BUILD_MC_LIBC_TRACE)
bool item_written = false;
EXTERN
int
-libc_open (void *p, int oflag, ...)
+libc_open (void *p, int oflag, int mode)
{
- va_list arg;
- va_start (arg, oflag);
- mode_t mode = va_arg (arg, mode_t);
tracedb_open (p, oflag, mode);
int result = open (reinterpret_cast <char *> (p), oflag, mode);
tracedb_result (result);
- va_end (arg);
return result;
}
open - open the file, filename with flag and mode.
*/
-EXTERN int libc_open (void * filename, int oflag, ...);
+EXTERN int libc_open (void * filename, int oflag, int mode);
/*
creat - creates a new file
EXTERN
int
-libc_open (void *p, int oflag, ...)
+libc_open (void *p, int oflag, int mode)
{
- va_list arg;
- va_start (arg, oflag);
- mode_t mode = va_arg (arg, mode_t);
- int result = open (reinterpret_cast <char *> (p), oflag, mode);
- va_end (arg);
- return result;
+ return open (reinterpret_cast <char *> (p), oflag, mode);
}
EXTERN
open - open the file, filename with flag and mode.
*/
-EXTERN int libc_open (void * filename, int oflag, ...);
+EXTERN int libc_open (void * filename, int oflag, int mode);
/*
creat - creates a new file
VAR
fd: INTEGER ;
BEGIN
- fd := open(ADR("/dev/tty"), 0)
+ fd := open(ADR("/dev/tty"), 0, 0)
END foo ;
BEGIN
VAR
fd: INTEGER ;
BEGIN
- fd := libc.open(ADR("/dev/tty"), O_RDONLY) ;
+ fd := libc.open(ADR("/dev/tty"), O_RDONLY, 0) ;
libc.printf("fd = %d\n", fd)
END openlibc.
VAR
fd: INTEGER ;
BEGIN
- fd := open(ADR(__FILE__), 0)
+ fd := open(ADR(__FILE__), 0, 0)
END testaddr3.