Date: Tue, 15 Oct 2002 21:36:37 +0200 From: Laurynas Biveinis X-Mailer: The Bat! (v1.61) Personal X-Priority: 3 (Normal) Message-ID: <29272946195.20021015213637@softhome.net> To: djgpp-workers AT delorie DOT com Subject: Re: 2.03 vs 3.2 In-Reply-To: <51168290418.20021014163221@softhome.net> References: <51168290418 DOT 20021014163221 AT softhome DOT net> MIME-Version: 1.0 Content-Type: text/plain; charset=Windows-1257 Content-Transfer-Encoding: 8bit X-OriginalArrivalTime: 15 Oct 2002 19:34:50.0792 (UTC) FILETIME=[EDBC0280:01C27481] Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > FYI, I'm slowly making my way to get 2.03 compile without warnings. I've backported > lots of IMO safe patches from 2.04. Well, I'm sort of done with it. Below is the patch. All of djdev builds with -Werror. I'm not going to backport further fixes, as I've already spent too much time working on it. Troubles like bzero do not concern me much - I'm happy with this patch for my personal use :) Anyway here it is FYI: Critical fixes: - Rick's patches for va_list, complete with . - bcopy / bzero fixes. I've done slightly differently, maybe it's a nonsense - if GCC > 3, I provide both macro and function. Allows to compile bzero.c without changes. - dbgcomm.c: shut up GCC warning by removing 'static' from variable. Not sure if it's good or bad... - 'muliline blah blah deprecated' fixes - Andris's patches for missing #includes - Patches for avoiding 'mixing signed/unsigned' warnings - Link with -lstdc[xx|++] mkdoc.exe - s/-I/-isystem for system headers - Include GCC header files too. (-isystem .../lib/gcc-lib/djgpp/3.2/include ) - Remove -Wtraditional, change -malign-* to -falign-* (gcc*.opt diff shows several other changes but nothing important) Not so critical fixes: - Use djgpp-x.djl - Compile C++ with '-fno-exceptions -fno-rtti' - emudummy.c empty stubs for library functions. I've not included my patch for et al which I've mentioned previously, as -isystem seems sufficient. That's it. If the patch is OK, that's fine. If the patch is not OK, that's fine too :) Laurynas diff -rupN djgpp203mk2/include/libc/fsexthlp.h djgpp203mk3/include/libc/fsexthlp.h --- djgpp203mk2/include/libc/fsexthlp.h 1970-01-01 00:00:00.000000000 +0000 +++ djgpp203mk3/include/libc/fsexthlp.h 2002-06-14 16:27:14.000000000 +0000 @@ -0,0 +1,64 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_libc_fsexthlp_h__ +#define __dj_include_libc_fsexthlp_h__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +/* This is a wrapper for an FSEXT function that allows it to be called + * with a variable number of arguments. */ + +static inline int +__FSEXT_func_wrapper (__FSEXT_Function *func, + __FSEXT_Fnumber fnum, + int *rv, + ...) +{ + va_list args; + int ret; + + va_start(args, rv); + ret = func(fnum, rv, args); + va_end(args); + + return(ret); +} + +/* This is a wrapper for __FSEXT_call_open_handlers that allows it + * to be called with a variable number of arguments. */ + +static inline int +__FSEXT_call_open_handlers_wrapper (__FSEXT_Fnumber fnum, int *rv, ...) +{ + va_list args; + int ret; + + va_start(args, rv); + ret = __FSEXT_call_open_handlers(fnum, rv, args); + va_end(args); + + return(ret); +} + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* __dj_include_libc_fsexthlp_h__ */ diff -rupN djgpp203mk2/include/stdio.h djgpp203mk3/include/stdio.h --- djgpp203mk2/include/stdio.h 1998-11-15 08:37:28.000000000 +0000 +++ djgpp203mk3/include/stdio.h 2002-10-13 19:24:56.000000000 +0000 @@ -124,8 +124,8 @@ extern FILE __dj_stdprn, __dj_stdaux; void _djstat_describe_lossage(FILE *_to_where); int _doprnt(const char *_fmt, va_list _args, FILE *_f); -int _doscan(FILE *_f, const char *_fmt, void **_argp); -int _doscan_low(FILE *, int (*)(FILE *_get), int (*_unget)(int, FILE *), const char *_fmt, void **_argp); +int _doscan(FILE *_f, const char *_fmt, va_list _args); +int _doscan_low(FILE *, int (*)(FILE *_get), int (*_unget)(int, FILE *), const char *_fmt, va_list _args); int fpurge(FILE *_f); int getw(FILE *_f); int mkstemp(char *_template); diff -rupN djgpp203mk2/include/string.h djgpp203mk3/include/string.h --- djgpp203mk2/include/string.h 2002-06-10 22:10:40.000000000 +0000 +++ djgpp203mk3/include/string.h 2002-10-14 16:52:04.000000000 +0000 @@ -50,11 +50,10 @@ size_t strxfrm(char *_s1, const char *_s #include int bcmp(const void *_ptr1, const void *_ptr2, int _length); -void * bcopy(const void *_a, void *_b, size_t _len); +void bcopy(const void *_a, void *_b, size_t _len); +void bzero(void *ptr, size_t _len); #if __GNUC__ >= 3 #define bzero(s, n) __builtin_bzero(s, n) -#else -void * bzero(void *ptr, size_t _len); #endif int ffs(int _mask); char * index(const char *_string, int _c); diff -rupN djgpp203mk2/src/debug/common/dbgcom.c djgpp203mk3/src/debug/common/dbgcom.c --- djgpp203mk2/src/debug/common/dbgcom.c 2001-09-08 23:11:34.000000000 +0000 +++ djgpp203mk3/src/debug/common/dbgcom.c 2002-10-14 19:12:30.000000000 +0000 @@ -22,7 +22,7 @@ #include extern char __libdbg_ident_string[]; -static char *id = __libdbg_ident_string; +char *id = __libdbg_ident_string; #define MEM_HANDLE_COUNT 256 #define DESCRIPTOR_COUNT 128 @@ -99,18 +99,18 @@ void save_npx (void) int i; if ((__dpmi_get_coprocessor_status() & FPU_PRESENT) == 0) return; - asm ("movb $0x0b, %%al - outb %%al, $0xa0 - inb $0xa0, %%al - testb $0x20, %%al - jz 1f - xorb %%al, %%al - outb %%al, $0xf0 - movb $0x20, %%al - outb %%al, $0xa0 - outb %%al, $0x20 -1: - fnsave %0 + asm ("movb $0x0b, %%al \n\ + outb %%al, $0xa0 \n\ + inb $0xa0, %%al \n\ + testb $0x20, %%al \n\ + jz 1f \n\ + xorb %%al, %%al \n\ + outb %%al, $0xf0 \n\ + movb $0x20, %%al \n\ + outb %%al, $0xa0 \n\ + outb %%al, $0x20 \n\ +1: \n\ + fnsave %0 \n\ fwait" : "=m" (npx) : /* No input */ @@ -915,79 +915,79 @@ Lc21_exit: ); /* complete code to return from an exception */ -asm ( ".text - .balign 16,,7 - .globl _dbgcom_exception_return_to_debuggee -_dbgcom_exception_return_to_debuggee: /* remove errorcode from stack */ - /* we must also switch stack back !! */ - /* relative to ebp */ - /* 0 previous ebp */ - /* 4 exception number */ - /* 8 return eip */ - /* 12 return cs */ - /* 16 return eflags */ - /* 20 return esp */ - /* 24 return ss */ - /* -4 stored ds */ - /* -8 stored eax */ - /* -12 stored esi */ - pushl %ebp - movl %esp,%ebp - pushl %ds - pushl %eax - pushl %esi - movl %cs:___djgpp_our_DS,%eax - movw %ax,%ds - addl $32,_cur_pos - decl _child_exception_level - movl 24(%ebp),%eax - movw %ax,%ds - movl 20(%ebp),%esi - /* ds:esi points now to app stack */ - subl $28,%esi - movl %esi,20(%ebp) - /* eflags on app stack */ - movl 16(%ebp),%eax - movl %eax,%ds:24(%esi) - /* cs on app stack */ - movl 12(%ebp),%eax - movl %eax,%ds:20(%esi) - /* eip on app stack */ - movl 8(%ebp),%eax - movl %eax,%ds:16(%esi) - /* esi on app stack */ - movl -12(%ebp),%eax - movl %eax,%ds:12(%esi) - /* eax on app stack */ - movl -8(%ebp),%eax - movl %eax,%ds:8(%esi) - /* ds on app_stack */ - movl -4(%ebp),%eax - movl %eax,%ds:4(%esi) - /* ebp on app_stack */ - movl (%ebp),%eax - movl %eax,%ds:(%esi) - /* switch stack */ - movl 24(%ebp),%eax - movw %ax,%ss - movl %esi,%esp - /* now on app stack */ - popl %ebp - popl %eax - movw %ax,%ds - popl %eax - popl %esi - iret +asm ( ".text \n\ + .balign 16,,7 \n\ + .globl _dbgcom_exception_return_to_debuggee \n\ +_dbgcom_exception_return_to_debuggee: /* remove errorcode from stack */\n\ + /* we must also switch stack back !! */ \n\ + /* relative to ebp */ \n\ + /* 0 previous ebp */ \n\ + /* 4 exception number */ \n\ + /* 8 return eip */ \n\ + /* 12 return cs */ \n\ + /* 16 return eflags */ \n\ + /* 20 return esp */ \n\ + /* 24 return ss */ \n\ + /* -4 stored ds */ \n\ + /* -8 stored eax */ \n\ + /* -12 stored esi */ \n\ + pushl %ebp \n\ + movl %esp,%ebp \n\ + pushl %ds \n\ + pushl %eax \n\ + pushl %esi \n\ + movl %cs:___djgpp_our_DS,%eax \n\ + movw %ax,%ds \n\ + addl $32,_cur_pos \n\ + decl _child_exception_level \n\ + movl 24(%ebp),%eax \n\ + movw %ax,%ds \n\ + movl 20(%ebp),%esi \n\ + /* ds:esi points now to app stack */ \n\ + subl $28,%esi \n\ + movl %esi,20(%ebp) \n\ + /* eflags on app stack */ \n\ + movl 16(%ebp),%eax \n\ + movl %eax,%ds:24(%esi) \n\ + /* cs on app stack */ \n\ + movl 12(%ebp),%eax \n\ + movl %eax,%ds:20(%esi) \n\ + /* eip on app stack */ \n\ + movl 8(%ebp),%eax \n\ + movl %eax,%ds:16(%esi) \n\ + /* esi on app stack */ \n\ + movl -12(%ebp),%eax \n\ + movl %eax,%ds:12(%esi) \n\ + /* eax on app stack */ \n\ + movl -8(%ebp),%eax \n\ + movl %eax,%ds:8(%esi) \n\ + /* ds on app_stack */ \n\ + movl -4(%ebp),%eax \n\ + movl %eax,%ds:4(%esi) \n\ + /* ebp on app_stack */ \n\ + movl (%ebp),%eax \n\ + movl %eax,%ds:(%esi) \n\ + /* switch stack */ \n\ + movl 24(%ebp),%eax \n\ + movw %ax,%ss \n\ + movl %esi,%esp \n\ + /* now on app stack */ \n\ + popl %ebp \n\ + popl %eax \n\ + movw %ax,%ds \n\ + popl %eax \n\ + popl %esi \n\ + iret \n\ "); static jmp_buf here; /* simple code to return from an exception */ /* don't forget to increment cur_pos */ -asm ( ".text - .balign 16,,7 - .globl _dbgcom_exception_return_to_here -_dbgcom_exception_return_to_here: /* remove errorcode from stack */ +asm ( ".text \n\ + .balign 16,,7 \n\ + .globl _dbgcom_exception_return_to_here \n\ +_dbgcom_exception_return_to_here: /* remove errorcode from stack */\n\ movl %cs:___djgpp_our_DS,%eax \n\ movw %ax,%ds \n\ movw %ax,%es \n\ @@ -1003,10 +1003,11 @@ _dbgcom_exception_return_to_here: movw $0x7021,0xb0f00 \n\ */ /* do not set limit of ds selector two times */ -asm (".text - .global ___dbgcom_kbd_hdlr -___dbgcom_kbd_hdlr: - ljmp %cs:___djgpp_old_kbd"); +asm (".text \n\ + .global ___dbgcom_kbd_hdlr \n\ +___dbgcom_kbd_hdlr: \n\ + ljmp %cs:___djgpp_old_kbd \n\ + "); @@ -1100,8 +1101,8 @@ static void dbgsig(int sig) { unsigned int ds_size; int signum = __djgpp_exception_state->__signum; - asm ("movl _app_ds,%%eax - lsl %%eax,%%eax + asm ("movl _app_ds,%%eax \n\ + lsl %%eax,%%eax \n\ movl %%eax,%0" : "=g" (ds_size) ); @@ -1317,15 +1318,15 @@ int invalid_sel_addr(short sel, unsigned char read_allowed = 0; char write_allowed = 0; - asm(" - movw %2,%%ax - verr %%ax - jnz .Ldoes_not_has_read_right - movb $1,%0 -.Ldoes_not_has_read_right: - verw %%ax - jnz .Ldoes_not_has_write_right - movb $1,%1 + asm(" \n\ + movw %2,%%ax \n\ + verr %%ax \n\ + jnz .Ldoes_not_has_read_right \n\ + movb $1,%0 \n\ +.Ldoes_not_has_read_right: \n\ + verw %%ax \n\ + jnz .Ldoes_not_has_write_right \n\ + movb $1,%1 \n\ .Ldoes_not_has_write_right: " : "=g" (read_allowed), "=g" (write_allowed) : "g" (sel) diff -rupN djgpp203mk2/src/debug/edebug/ed.c djgpp203mk3/src/debug/edebug/ed.c --- djgpp203mk2/src/debug/edebug/ed.c 1997-10-28 14:32:12.000000000 +0000 +++ djgpp203mk3/src/debug/edebug/ed.c 2002-10-15 12:53:24.000000000 +0000 @@ -2,6 +2,7 @@ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include #include +#include #include #include "ed.h" #include "debug.h" diff -rupN djgpp203mk2/src/debug/edebug/unassmbl.c djgpp203mk3/src/debug/edebug/unassmbl.c --- djgpp203mk2/src/debug/edebug/unassmbl.c 1997-10-28 14:35:18.000000000 +0000 +++ djgpp203mk3/src/debug/edebug/unassmbl.c 2002-10-15 12:56:58.000000000 +0000 @@ -1,8 +1,9 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ /* -** Copyright (C) 1993 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** Copyright (C) 1993 DJ Delorie, 334 North Rd, Deerfield NH 03037-1110 ** ** This file is distributed under the terms listed in the document ** "copying.dj", available from DJ Delorie at the address above. @@ -14,6 +15,7 @@ ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ +#include #include #include @@ -340,8 +342,12 @@ static int sib(void) /*------------------------------------------------------------------------*/ static void uprintf(const char *s, ...) { - const char **a = &s; - vsprintf(ubufp, s, a+1); + va_list args; + + va_start(args, s); + vsprintf(ubufp, s, args); + va_end(args); + while (*ubufp) ubufp++; } diff -rupN djgpp203mk2/src/debug/fsdb/ed.c djgpp203mk3/src/debug/fsdb/ed.c --- djgpp203mk2/src/debug/fsdb/ed.c 1996-01-24 21:53:40.000000000 +0000 +++ djgpp203mk3/src/debug/fsdb/ed.c 2002-10-15 12:58:36.000000000 +0000 @@ -19,11 +19,11 @@ static void usage (char *myself) { fprintf (stderr, "\ -Usage: %s [debug args] debug-image [image args] - -Options: -p path Specify path for source files. - -d Enable dual monitor display. - -s file Load setup from specified file. +Usage: %s [debug args] debug-image [image args]\n\ +\n\ +Options: -p path Specify path for source files.\n\ + -d Enable dual monitor display.\n\ + -s file Load setup from specified file.\n\ ", myself); exit (1); } diff -rupN djgpp203mk2/src/debug/fsdb/fullscr.c djgpp203mk3/src/debug/fsdb/fullscr.c --- djgpp203mk2/src/debug/fsdb/fullscr.c 1999-09-23 06:19:36.000000000 +0000 +++ djgpp203mk3/src/debug/fsdb/fullscr.c 2002-10-15 13:01:10.000000000 +0000 @@ -1053,7 +1053,7 @@ step (KIND_TYPE kind) final = a_tss.tss_eip + len; } break; - default: + default:; /* Nothing. */ } @@ -1165,7 +1165,7 @@ step (KIND_TYPE kind) goto retry; bep->count = 0; } - error: + error:; } code_pane_goto (a_tss.tss_eip); @@ -1456,7 +1456,7 @@ redraw (int first) name = syms_val2name (breakpoint_table[b].addr, &delta); if (name[0] != '0') { - if (delta && strlen (name) < width) + if (delta && (int)strlen (name) < width) sprintf (buf, " %s+%#lx", name, delta); else sprintf (buf, " %-*s", width, name); @@ -1867,8 +1867,8 @@ redraw (int first) word32 limit; asm volatile - ("xorl %%eax,%%eax - sldt %%ax + ("xorl %%eax,%%eax \n\ + sldt %%ax \n\ movl %%eax,%0" : "=r" ((int)(ldt)) : /* no inputs. */ @@ -2013,7 +2013,7 @@ redraw (int first) if (evaluate (watch_pane_text[i], &val, &errtxt)) { valtxt = errtxt; - if (strlen (errtxt) > width - 5) + if ((int)strlen (errtxt) > width - 5) { valtxt = alloca (width - 4); strncpy (valtxt, errtxt, width - 4); @@ -3226,7 +3226,7 @@ gildt_pane_command (int key) case 0x0b: show_tss (&descr); break; - default: + default:; } break; } @@ -3631,7 +3631,7 @@ debugger(void) case 3: initdisplay (0); break; - case -1: + case -1:; /* Nothing. */ } redraw (0); diff -rupN djgpp203mk2/src/debug/fsdb/screen.c djgpp203mk3/src/debug/fsdb/screen.c --- djgpp203mk2/src/debug/fsdb/screen.c 1998-09-07 13:58:04.000000000 +0000 +++ djgpp203mk3/src/debug/fsdb/screen.c 2002-10-15 13:01:56.000000000 +0000 @@ -1,3 +1,4 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include @@ -10,6 +11,7 @@ #include #include #include +#include #include "ed.h" #include "screen.h" void *xmalloc (size_t); @@ -210,11 +212,15 @@ mysleep (int secs) void message (CL_TYPE class, char *fmt, ...) { + va_list args; char *save, *buf = alloca (cols); unsigned char saveattr = screen_attr; int len, y = rows / 2; - vsprintf (buf, fmt, (&fmt) + 1); + va_start(args, fmt); + vsprintf (buf, fmt, args); + va_end(args); + len = strlen (buf); save = debug_screen_save; debug_screen_save = get_screen (); diff -rupN djgpp203mk2/src/debug/fsdb/unassmbl.c djgpp203mk3/src/debug/fsdb/unassmbl.c --- djgpp203mk2/src/debug/fsdb/unassmbl.c 1998-09-07 14:12:42.000000000 +0000 +++ djgpp203mk3/src/debug/fsdb/unassmbl.c 2002-10-15 13:03:30.000000000 +0000 @@ -1,8 +1,9 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ /* -** Copyright (C) 1993 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** Copyright (C) 1993 DJ Delorie, 334 North Rd, Deerfield NH 03037-1110 ** ** This file is distributed under the terms listed in the document ** "copying.dj", available from DJ Delorie at the address above. @@ -17,6 +18,7 @@ /* Modified by Morten Welinder, terra AT diku DOT dk, for use with full screen debugger. These changes are copyright 1994 by Morten Welinder. */ +#include #include #include #include @@ -354,8 +356,12 @@ sib(void) void uprintf(char *s, ...) { - char **a = &s; - vsprintf(ubufp, s, a+1); + va_list args; + + va_start(args, s); + vsprintf(ubufp, s, args); + va_end(args); + while (*ubufp) ubufp++; } @@ -941,7 +947,10 @@ cache_fopen(char *name) while (f == NULL && s && *s) { t = index (s, ';'); - l = t ? t - s : strlen (s); + if (t) + l = t - s; + else + l = strlen (s); strncpy (u, s, l); if (l > 0 && u[l - 1] != '/' && u[l - 1] != '\\') u[l++] = '/'; diff -rupN djgpp203mk2/src/gcc-l.opt djgpp203mk3/src/gcc-l.opt --- djgpp203mk2/src/gcc-l.opt 1997-12-29 11:50:38.000000000 +0000 +++ djgpp203mk3/src/gcc-l.opt 2002-10-14 18:47:58.000000000 +0000 @@ -1,9 +1,9 @@ -MD -O2 --m486 --malign-loops=2 --malign-jumps=2 --malign-functions=2 --fno-strength-reduce +-mcpu=pentiumpro +-falign-loops=2 +-falign-jumps=2 +-falign-functions=2 -Wall -nostdinc +-Werror diff -rupN djgpp203mk2/src/gcc.opt djgpp203mk3/src/gcc.opt --- djgpp203mk2/src/gcc.opt 1997-12-29 11:50:24.000000000 +0000 +++ djgpp203mk3/src/gcc.opt 2002-10-15 18:34:52.000000000 +0000 @@ -1,20 +1,18 @@ -MD -O2 --fno-strength-reduce --m486 --malign-loops=2 --malign-jumps=2 --malign-functions=2 +-mcpu=pentiumpro +-falign-loops=2 +-falign-jumps=2 +-falign-functions=2 -Wall -Wbad-function-cast -Wcast-qual --Werror -Wmissing-declarations -Wmissing-prototypes -Wpointer-arith -Wshadow -Wstrict-prototypes --Wtraditional -Wwrite-strings -nostdinc +-Werror diff -rupN djgpp203mk2/src/libc/ansi/stdio/doscan.c djgpp203mk3/src/libc/ansi/stdio/doscan.c --- djgpp203mk2/src/libc/ansi/stdio/doscan.c 1999-08-03 04:49:24.000000000 +0000 +++ djgpp203mk3/src/libc/ansi/stdio/doscan.c 2002-10-13 19:32:32.000000000 +0000 @@ -1,7 +1,9 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include #include #include #include @@ -18,7 +20,7 @@ #define INT 0 #define FLOAT 1 -static int _innum(int **ptr, int type, int len, int size, FILE *iop, +static int _innum(int *ptr, int type, int len, int size, FILE *iop, int (*scan_getc)(FILE *), int (*scan_ungetc)(int, FILE *), int *eofptr); static int _instr(char *ptr, int type, int len, FILE *iop, @@ -40,18 +42,18 @@ static char _sctab[256] = { static int nchars = 0; int -_doscan(FILE *iop, const char *fmt, void **argp) +_doscan(FILE *iop, const char *fmt, va_list argp) { return(_doscan_low(iop, fgetc, ungetc, fmt, argp)); } int _doscan_low(FILE *iop, int (*scan_getc)(FILE *), int (*scan_ungetc)(int, FILE *), - const char *fmt, void **argp) + const char *fmt, va_list argp) { register int ch; int nmatch, len, ch1; - int **ptr, fileended, size; + int *ptr, fileended, size; nchars = 0; nmatch = 0; @@ -64,7 +66,7 @@ _doscan_low(FILE *iop, int (*scan_getc)( goto def; ptr = 0; if (ch != '*') - ptr = (int **)argp++; + ptr = va_arg(argp, int *); else ch = *fmt++; len = 0; @@ -122,13 +124,13 @@ _doscan_low(FILE *iop, int (*scan_getc)( if (!ptr) break; if (size==LONG) - **(long**)ptr = nchars; + *(long*)ptr = nchars; else if (size==SHORT) - **(short**)ptr = nchars; + *(short*)ptr = nchars; else if (size==LONGDOUBLE) - **(long long**)ptr = nchars; + *(long long*)ptr = nchars; else - **(int**)ptr = nchars; + *(int*)ptr = nchars; break; } @@ -176,7 +178,7 @@ _doscan_low(FILE *iop, int (*scan_getc)( } static int -_innum(int **ptr, int type, int len, int size, FILE *iop, +_innum(int *ptr, int type, int len, int size, FILE *iop, int (*scan_getc)(FILE *), int (*scan_ungetc)(int, FILE *), int *eofptr) { register char *np; @@ -187,7 +189,7 @@ _innum(int **ptr, int type, int len, int int cpos; if (type=='c' || type=='s' || type=='[') - return(_instr(ptr? *(char **)ptr: (char *)NULL, type, len, + return(_instr(ptr? (char *)ptr: (char *)NULL, type, len, iop, scan_getc, scan_ungetc, eofptr)); lcval = 0; ndigit = 0; @@ -281,31 +283,31 @@ _innum(int **ptr, int type, int len, int case (FLOAT<<4) | SHORT: case (FLOAT<<4) | REGULAR: - **(float **)ptr = atof(numbuf); + *(float *)ptr = atof(numbuf); break; case (FLOAT<<4) | LONG: - **(double **)ptr = atof(numbuf); + *(double *)ptr = atof(numbuf); break; case (FLOAT<<4) | LONGDOUBLE: - **(long double **)ptr = _atold(numbuf); + *(long double *)ptr = _atold(numbuf); break; case (INT<<4) | SHORT: - **(short **)ptr = (short)lcval; + *(short *)ptr = (short)lcval; break; case (INT<<4) | REGULAR: - **(int **)ptr = (int)lcval; + *(int *)ptr = (int)lcval; break; case (INT<<4) | LONG: - **(long **)ptr = (long)lcval; + *(long *)ptr = (long)lcval; break; case (INT<<4) | LONGDOUBLE: - **(long long **)ptr = lcval; + *(long long *)ptr = lcval; break; } return(1); @@ -366,7 +368,8 @@ _instr(char *ptr, int type, int len, FIL static const char * _getccl(const unsigned char *s) { - register int c, t; + register int t; + size_t c; t = 0; if (*s == '^') { diff -rupN djgpp203mk2/src/libc/ansi/stdio/fprintf.c djgpp203mk3/src/libc/ansi/stdio/fprintf.c --- djgpp203mk2/src/libc/ansi/stdio/fprintf.c 1994-12-26 15:34:46.000000000 +0000 +++ djgpp203mk3/src/libc/ansi/stdio/fprintf.c 2002-10-13 19:17:10.000000000 +0000 @@ -1,19 +1,24 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include #include #include int fprintf(register FILE *iop, const char *fmt, ...) { + va_list args; int len; char localbuf[BUFSIZ]; + va_start(args, fmt); + if (iop->_flag & _IONBF) { iop->_flag &= ~_IONBF; iop->_ptr = iop->_base = localbuf; iop->_bufsiz = BUFSIZ; - len = _doprnt(fmt, (&fmt)+1, iop); + len = _doprnt(fmt, args, iop); fflush(iop); iop->_flag |= _IONBF; iop->_base = NULL; @@ -21,6 +26,9 @@ fprintf(register FILE *iop, const char * iop->_cnt = 0; } else - len = _doprnt(fmt, (&fmt)+1, iop); + len = _doprnt(fmt, args, iop); + + va_end(args); + return ferror(iop) ? EOF : len; } diff -rupN djgpp203mk2/src/libc/ansi/stdio/printf.c djgpp203mk3/src/libc/ansi/stdio/printf.c --- djgpp203mk2/src/libc/ansi/stdio/printf.c 1998-01-01 18:05:02.000000000 +0000 +++ djgpp203mk3/src/libc/ansi/stdio/printf.c 2002-10-13 19:34:36.000000000 +0000 @@ -1,14 +1,19 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include #include #include int printf(const char *fmt, ...) { + va_list args; int len; - len = _doprnt(fmt, (&fmt)+1, stdout); + va_start(args, fmt); + len = _doprnt(fmt, args, stdout); + va_end(args); /* People were confused when printf() didn't flush stdout, so we'll do it to reduce confusion */ diff -rupN djgpp203mk2/src/libc/ansi/stdio/remove.c djgpp203mk3/src/libc/ansi/stdio/remove.c --- djgpp203mk2/src/libc/ansi/stdio/remove.c 1998-06-28 19:13:20.000000000 +0000 +++ djgpp203mk3/src/libc/ansi/stdio/remove.c 2002-10-13 19:43:56.000000000 +0000 @@ -1,3 +1,4 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ @@ -10,18 +11,19 @@ #include #include #include +#include int remove(const char *fn) { __dpmi_regs r; - unsigned attr; + int attr; int directory_p; int use_lfn = _USE_LFN; int rv; /* see if a file system extension wants to handle this */ - if (__FSEXT_call_open_handlers(__FSEXT_unlink, &rv, &fn)) + if (__FSEXT_call_open_handlers_wrapper(__FSEXT_unlink, &rv, fn)) return rv; /* Get the file attribute byte. */ @@ -43,7 +45,7 @@ remove(const char *fn) in addition to the Read-Only bit, or else 214301 will fail. */ _chmod(fn, 1, attr & 0xffe0); - /* Now delete it. Note, _chmod leaves dir name in tranfer buffer. */ + /* Now delete it. Note, _chmod leaves dir name in transfer buffer. */ if (directory_p) r.h.ah = 0x3a; /* DOS Remove Directory function */ else @@ -60,6 +62,12 @@ remove(const char *fn) { /* We failed. Leave the things as we've found them. */ int e = __doserr_to_errno(r.x.ax); + + /* We know the file exists, so ENOENT at this point means a bug. + Since write-protected floppies are the most probable cause, + return EACCES instead. */ + if(e == ENOENT) + e = EACCES; _chmod(fn, 1, attr & 0xffe7); errno = e; diff -rupN djgpp203mk2/src/libc/ansi/stdio/sprintf.c djgpp203mk3/src/libc/ansi/stdio/sprintf.c --- djgpp203mk2/src/libc/ansi/stdio/sprintf.c 1999-08-04 15:58:22.000000000 +0000 +++ djgpp203mk3/src/libc/ansi/stdio/sprintf.c 2002-10-14 15:39:18.000000000 +0000 @@ -1,5 +1,7 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include #include #include #include @@ -7,13 +9,18 @@ int sprintf(char *str, const char *fmt, ...) { + va_list args; FILE _strbuf; int len; _strbuf._flag = _IOWRT|_IOSTRG|_IONTERM; _strbuf._ptr = str; _strbuf._cnt = INT_MAX; - len = _doprnt(fmt, &(fmt)+1, &_strbuf); + + va_start(args, fmt); + len = _doprnt(fmt, args, &_strbuf); + va_end(args); + *_strbuf._ptr = 0; return len; } diff -rupN djgpp203mk2/src/libc/ansi/stdlib/qsort.c djgpp203mk3/src/libc/ansi/stdlib/qsort.c --- djgpp203mk2/src/libc/ansi/stdlib/qsort.c 1998-09-27 12:31:00.000000000 +0000 +++ djgpp203mk3/src/libc/ansi/stdlib/qsort.c 2002-10-14 16:37:00.000000000 +0000 @@ -1,3 +1,4 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 K.B. Williams, see COPYING.DJ for details */ /* ============ */ /* qsort.c */ @@ -5,6 +6,7 @@ #include #include #include +#include /* * This is an implementation of quicksort that partitions the array diff -rupN djgpp203mk2/src/libc/compat/bsd/bcopy.c djgpp203mk3/src/libc/compat/bsd/bcopy.c --- djgpp203mk2/src/libc/compat/bsd/bcopy.c 1995-08-23 00:48:00.000000000 +0000 +++ djgpp203mk3/src/libc/compat/bsd/bcopy.c 2002-10-14 16:55:14.000000000 +0000 @@ -1,10 +1,12 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include #undef bcopy -void * +void bcopy(const void *a, void *b, size_t len) { - return memmove(b, a, len); + memmove(b, a, len); } diff -rupN djgpp203mk2/src/libc/compat/bsd/bzero.c djgpp203mk3/src/libc/compat/bsd/bzero.c --- djgpp203mk2/src/libc/compat/bsd/bzero.c 1995-08-23 00:48:00.000000000 +0000 +++ djgpp203mk3/src/libc/compat/bsd/bzero.c 2002-10-14 16:36:58.000000000 +0000 @@ -1,10 +1,12 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include #undef bzero -void * +void bzero(void *a, size_t b) { - return memset(a,0,b); + memset(a,0,b); } diff -rupN djgpp203mk2/src/libc/compat/ioctl/ioctl.c djgpp203mk3/src/libc/compat/ioctl/ioctl.c --- djgpp203mk2/src/libc/compat/ioctl/ioctl.c 1998-06-28 13:25:20.000000000 +0000 +++ djgpp203mk3/src/libc/compat/ioctl/ioctl.c 2002-10-14 17:05:52.000000000 +0000 @@ -1,3 +1,4 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* @@ -69,37 +70,12 @@ ** and calls that if it exist. Otherwise we just return -1. ** ** -$Id: ioctl.c,v 1.2 1998/06/28 17:25:20 dj Exp $ -$Log: ioctl.c,v $ -Revision 1.2 1998/06/28 17:25:20 dj -import djgpp 2.02 - - * Revision 0.5 1996/07/30 09:42:23 DEMMER - * Minor code cleanups. Final beta. - * - * Revision 0.4 1996/07/29 13:03:29 DEMMER - * Added va_end(). Probably uneeded for Intel machines. Anyway. - * - * Revision 0.3 1996/07/29 12:44:55 DEMMER - * Split the header stuff from the source - * Changed encoding bits - * - * Revision 0.2 1996/07/04 11:17:37 DEMMER - * Revised flag scheme. - * Correct some minor bugs - * - * Revision 0.1 1996/07/03 15:42:01 DEMMER - * Cleaned up flag stuff. - * Added UNIX ioctl test routines - * - * Revision 0.0 1996/07/03 13:53:23 DEMMER - * Initial version - * */ #include +#include #include #include #include @@ -157,7 +133,7 @@ static int _dos_ioctl(int fd, int cmd, i ** I _do_ like clear APIs. */ if(cmd & DOS_XFER){ - if(argcx <= __tb_size){ /* Can we use transfer buffer ? */ + if(argcx <= (int)__tb_size){ /* Can we use transfer buffer ? */ dosmemput((void *)argdx,argcx, __tb); r.x.ds = (__tb>>4) &0xffff; r.x.dx = __tb &0xf; @@ -183,7 +159,7 @@ static int _dos_ioctl(int fd, int cmd, i ** parameter after all the registers and the buffer pointer. */ if( cmd & DOS_BRAINDEAD ){ - if(xarg <= __tb_size){ /* Can we use transfer buffer ? */ + if(xarg <= (int)__tb_size){ /* Can we use transfer buffer ? */ dosmemput((void *)argdx,xarg, __tb); r.x.ds = (__tb>>4) &0xffff; r.x.dx = __tb &0xf; @@ -255,7 +231,7 @@ static int _unix_ioctl(int fd,int cmd, i __FSEXT_Function *func = __FSEXT_get_function(fd); if(func){ int rv; - if(func(__FSEXT_ioctl,&rv, &fd)) + if (__FSEXT_func_wrapper(func, __FSEXT_ioctl, &rv, &fd)) return rv; } @@ -282,7 +258,8 @@ int ioctl(int fd, int cmd, ...){ ** see if this is a file system extension file ** */ - if (func && func(__FSEXT_ioctl, &rv, &fd)) + + if (func && __FSEXT_func_wrapper(func, __FSEXT_ioctl, &rv, &fd)) return rv; va_start(args,cmd); diff -rupN djgpp203mk2/src/libc/compat/stdio/mkstemp.c djgpp203mk3/src/libc/compat/stdio/mkstemp.c --- djgpp203mk2/src/libc/compat/stdio/mkstemp.c 1998-12-13 08:10:58.000000000 +0000 +++ djgpp203mk3/src/libc/compat/stdio/mkstemp.c 2002-10-14 17:08:54.000000000 +0000 @@ -1,5 +1,7 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include #include #include #include diff -rupN djgpp203mk2/src/libc/compat/stdlib/rand48.c djgpp203mk3/src/libc/compat/stdlib/rand48.c --- djgpp203mk2/src/libc/compat/stdlib/rand48.c 1999-03-20 16:25:02.000000000 +0000 +++ djgpp203mk3/src/libc/compat/stdlib/rand48.c 2002-10-14 17:12:02.000000000 +0000 @@ -1,6 +1,7 @@ /* * File rand48.c. * + * Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details * Copyright (C) 1999 Martin Str”mberg . * * This software may be used freely so long as this copyright notice is @@ -8,7 +9,8 @@ * */ -#include "stdlib.h" +#include +#include #define RAND48_MULT0 (0xe66d) #define RAND48_MULT1 (0xdeec) diff -rupN djgpp203mk2/src/libc/compat/time/select.c djgpp203mk3/src/libc/compat/time/select.c --- djgpp203mk2/src/libc/compat/time/select.c 2001-11-25 17:49:26.000000000 +0000 +++ djgpp203mk3/src/libc/compat/time/select.c 2002-10-14 17:14:56.000000000 +0000 @@ -1,3 +1,4 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ @@ -24,6 +25,7 @@ #include #include #include +#include inline static int fp_output_ready(FILE *fp) @@ -162,7 +164,7 @@ select(int nfds, int fsext_ready = -1; if (func) - func(__FSEXT_ready, &fsext_ready, &i); + __FSEXT_func_wrapper(func, __FSEXT_ready, &fsext_ready, i); if (readfds && FD_ISSET (i, readfds)) { diff -rupN djgpp203mk2/src/libc/dos/io/_close.c djgpp203mk3/src/libc/dos/io/_close.c --- djgpp203mk2/src/libc/dos/io/_close.c 1998-01-01 19:12:50.000000000 +0000 +++ djgpp203mk3/src/libc/dos/io/_close.c 2002-10-14 17:18:18.000000000 +0000 @@ -1,12 +1,14 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include #include #include #include #include #include #include - +#include #include int @@ -18,7 +20,7 @@ _close(int handle) if (func) { int rv; - if (func(__FSEXT_close, &rv, &handle)) + if (__FSEXT_func_wrapper(func, __FSEXT_close, &rv, handle)) { /* So that we don't try to use it later! The extension *should* do this itself! */ diff -rupN djgpp203mk2/src/libc/dos/io/_creat.c djgpp203mk3/src/libc/dos/io/_creat.c --- djgpp203mk2/src/libc/dos/io/_creat.c 2001-09-18 00:44:06.000000000 +0000 +++ djgpp203mk3/src/libc/dos/io/_creat.c 2002-10-14 17:19:58.000000000 +0000 @@ -1,7 +1,9 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include +#include #include #include #include @@ -11,6 +13,7 @@ #include #include #include +#include int _creat(const char* filename, int attrib) @@ -25,7 +28,7 @@ _creat(const char* filename, int attrib) return -1; } - if (__FSEXT_call_open_handlers(__FSEXT_creat, &rv, &filename)) + if (__FSEXT_call_open_handlers_wrapper(__FSEXT_creat, &rv, filename, attrib)) return rv; _put_path(filename); diff -rupN djgpp203mk2/src/libc/dos/io/_creat_n.c djgpp203mk3/src/libc/dos/io/_creat_n.c --- djgpp203mk2/src/libc/dos/io/_creat_n.c 2001-09-18 00:45:22.000000000 +0000 +++ djgpp203mk3/src/libc/dos/io/_creat_n.c 2002-10-14 17:23:16.000000000 +0000 @@ -1,6 +1,8 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ #include +#include #include #include #include @@ -10,6 +12,7 @@ #include #include #include +#include int _creatnew(const char* filename, int attrib, int flags) @@ -24,7 +27,8 @@ _creatnew(const char* filename, int attr return -1; } - if (__FSEXT_call_open_handlers(__FSEXT_creat, &rv, &filename)) + if (__FSEXT_call_open_handlers_wrapper(__FSEXT_creat, &rv, + filename, attrib, flags)) return rv; _put_path(filename); diff -rupN djgpp203mk2/src/libc/dos/io/_open.c djgpp203mk3/src/libc/dos/io/_open.c --- djgpp203mk2/src/libc/dos/io/_open.c 2001-08-21 22:30:18.000000000 +0000 +++ djgpp203mk3/src/libc/dos/io/_open.c 2002-10-14 17:25:10.000000000 +0000 @@ -1,7 +1,9 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include +#include #include #include #include @@ -11,6 +13,7 @@ #include #include #include +#include int _open(const char* filename, int oflag) @@ -25,7 +28,7 @@ _open(const char* filename, int oflag) return -1; } - if (__FSEXT_call_open_handlers(__FSEXT_open, &rv, &filename)) + if (__FSEXT_call_open_handlers_wrapper(__FSEXT_open, &rv, filename, oflag)) return rv; if(use_lfn && _osmajor == 5 && _get_dos_version(1) == 0x532) { diff -rupN djgpp203mk2/src/libc/dos/io/_read.c djgpp203mk3/src/libc/dos/io/_read.c --- djgpp203mk2/src/libc/dos/io/_read.c 1995-11-25 16:48:30.000000000 +0000 +++ djgpp203mk3/src/libc/dos/io/_read.c 2002-10-14 17:33:04.000000000 +0000 @@ -1,5 +1,7 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include +#include #include #include #include @@ -7,7 +9,7 @@ #include #include #include - +#include #include int @@ -22,7 +24,7 @@ _read(int handle, void* buffer, size_t c if (func) { int rv; - if (func(__FSEXT_read, &rv, &handle)) + if (__FSEXT_func_wrapper(func, __FSEXT_read, &rv, handle, buffer, count)) return rv; } diff -rupN djgpp203mk2/src/libc/dos/io/_write.c djgpp203mk3/src/libc/dos/io/_write.c --- djgpp203mk2/src/libc/dos/io/_write.c 1996-10-24 19:26:26.000000000 +0000 +++ djgpp203mk3/src/libc/dos/io/_write.c 2002-10-14 17:31:56.000000000 +0000 @@ -1,6 +1,9 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include +#include +#include #include #include #include @@ -23,7 +26,7 @@ _write(int handle, const void* buffer, s if (func) { int rv; - if (func(__FSEXT_write, &rv, &handle)) + if (__FSEXT_func_wrapper(func, __FSEXT_write, &rv, handle, buffer, count)) return rv; } diff -rupN djgpp203mk2/src/libc/pc_hw/co80/conio.c djgpp203mk3/src/libc/pc_hw/co80/conio.c --- djgpp203mk2/src/libc/pc_hw/co80/conio.c 1999-06-03 13:27:36.000000000 +0000 +++ djgpp203mk3/src/libc/pc_hw/co80/conio.c 2002-10-14 17:37:34.000000000 +0000 @@ -1,3 +1,4 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ @@ -722,8 +723,14 @@ cgets(char *string) int cscanf(const char *fmt, ...) { - return(_doscan_low(NULL, _scan_getche, _scan_ungetch, - fmt, (void **) unconst( ((&fmt)+1), char ** ))); + va_list args; + int ret; + + va_start(args, fmt); + ret = _doscan_low(NULL, _scan_getche, _scan_ungetch, fmt, args); + va_end(args); + + return(ret); } int diff -rupN djgpp203mk2/src/libc/posix/fcntl/fcntl.c djgpp203mk3/src/libc/posix/fcntl/fcntl.c --- djgpp203mk2/src/libc/posix/fcntl/fcntl.c 1999-06-03 13:27:38.000000000 +0000 +++ djgpp203mk3/src/libc/posix/fcntl/fcntl.c 2002-10-14 17:46:44.000000000 +0000 @@ -1,7 +1,9 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include +#include #include #include #include @@ -32,7 +34,7 @@ fcntl(int fd, int cmd, ...) if (func) { int rv; - if (func(__FSEXT_fcntl, &rv, &fd)) + if (__FSEXT_func_wrapper(func, __FSEXT_fcntl, &rv, &fd)) return rv; } diff -rupN djgpp203mk2/src/libc/posix/sys/stat/fstat.c djgpp203mk3/src/libc/posix/sys/stat/fstat.c --- djgpp203mk2/src/libc/posix/sys/stat/fstat.c 2001-08-27 10:47:34.000000000 +0000 +++ djgpp203mk3/src/libc/posix/sys/stat/fstat.c 2002-10-14 17:50:26.000000000 +0000 @@ -1,3 +1,4 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ @@ -95,6 +96,7 @@ */ #include +#include #include #include #include @@ -110,6 +112,7 @@ #include #include #include +#include #include "xstat.h" #define _STAT_INODE 1 /* should we bother getting inode numbers? */ @@ -850,7 +853,7 @@ fstat(int handle, struct stat *statbuf) /* see if this is file system extension file */ func = __FSEXT_get_function(handle); - if (func && func(__FSEXT_fstat, &rv, &handle)) + if (func && __FSEXT_func_wrapper(func, __FSEXT_fstat, &rv, handle, statbuf)) { return rv; } diff -rupN djgpp203mk2/src/libc/posix/sys/stat/stat.c djgpp203mk3/src/libc/posix/sys/stat/stat.c --- djgpp203mk2/src/libc/posix/sys/stat/stat.c 1999-06-03 13:27:40.000000000 +0000 +++ djgpp203mk3/src/libc/posix/sys/stat/stat.c 2002-10-14 18:05:10.000000000 +0000 @@ -1,3 +1,4 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ @@ -111,6 +112,7 @@ #include #include #include +#include #include #include #include @@ -880,8 +882,8 @@ stat(const char *path, struct stat *stat errno = ENOENT; /* since no such filename is possible */ return -1; } - - if (__FSEXT_call_open_handlers(__FSEXT_stat, &ret, &path)) + + if (__FSEXT_call_open_handlers_wrapper(__FSEXT_stat, &ret, path, statbuf)) return ret; if (stat_assist(path, statbuf) == -1) diff -rupN djgpp203mk2/src/libc/posix/unistd/access.c djgpp203mk3/src/libc/posix/unistd/access.c --- djgpp203mk2/src/libc/posix/unistd/access.c 1999-08-04 15:58:24.000000000 +0000 +++ djgpp203mk3/src/libc/posix/unistd/access.c 2002-10-14 18:09:52.000000000 +0000 @@ -1,4 +1,5 @@ /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ @@ -10,6 +11,7 @@ #include #include #include +#include int access(const char *fn, int flags) { diff -rupN djgpp203mk2/src/libc/posix/unistd/link.c djgpp203mk3/src/libc/posix/unistd/link.c --- djgpp203mk2/src/libc/posix/unistd/link.c 1998-06-28 13:27:32.000000000 +0000 +++ djgpp203mk3/src/libc/posix/unistd/link.c 2002-10-14 18:27:48.000000000 +0000 @@ -1,6 +1,8 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include +#include #include /* For stat() */ #include /* For O_RDONLY, etc. */ #include /* For read(), write(), etc. */ @@ -8,6 +10,7 @@ #include /* For utime() */ #include /* For errno */ #include +#include /* Of course, DOS can't really do a link. We just do a copy instead, which is as close as DOS gets. Alternatively, we could always fail @@ -33,7 +36,7 @@ link(const char *path1, const char *path } /* see if a file system extension implements the link */ - if (__FSEXT_call_open_handlers(__FSEXT_link, &rv, &path1)) + if (__FSEXT_call_open_handlers_wrapper(__FSEXT_link, &rv, path1, path2)) return rv; /* Fail if path1 does not exist - stat() will set errno */ diff -rupN djgpp203mk2/src/libc/posix/unistd/lseek.c djgpp203mk3/src/libc/posix/unistd/lseek.c --- djgpp203mk2/src/libc/posix/unistd/lseek.c 1998-06-28 13:29:36.000000000 +0000 +++ djgpp203mk3/src/libc/posix/unistd/lseek.c 2002-10-14 18:34:18.000000000 +0000 @@ -1,12 +1,15 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include #include +#include #include #include #include #include #include +#include off_t lseek(int handle, off_t offset, int whence) @@ -16,7 +19,7 @@ lseek(int handle, off_t offset, int when if (func) { int rv; - if (func(__FSEXT_lseek, &rv, &handle)) + if (__FSEXT_func_wrapper(func, __FSEXT_lseek, &rv, handle, offset, whence)) return rv; } diff -rupN djgpp203mk2/src/libc/posix/unistd/write.c djgpp203mk3/src/libc/posix/unistd/write.c --- djgpp203mk2/src/libc/posix/unistd/write.c 1997-08-31 13:49:14.000000000 +0000 +++ djgpp203mk3/src/libc/posix/unistd/write.c 2002-10-14 18:42:44.000000000 +0000 @@ -1,8 +1,10 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include #include +#include #include #include #include @@ -12,6 +14,7 @@ #include #include #include +#include #define tblen _go32_info_block.size_of_transfer_buffer @@ -22,8 +25,8 @@ ssize_t write(int handle, const void* buffer, size_t count) { const char *buf = (const char *)buffer; - int bytes_in_tb = 0; - int offset_into_buf = 0; + size_t bytes_in_tb = 0; + size_t offset_into_buf = 0; __dpmi_regs r; ssize_t rv; @@ -41,9 +44,10 @@ write(int handle, const void* buffer, si return _write(handle, buf, count); /* Let's handle FSEXT_write ! */ - if(func && /* if handler is installed, ...*/ - func(__FSEXT_write, &rv, &handle)) /* ... call extension ... */ - return rv; /* ... and exit if handled. */ + /* if handler is installed, call extension and exit if handled. */ + if(func && + __FSEXT_func_wrapper(func, __FSEXT_write, &rv, handle, buffer, count)) + return rv; while (offset_into_buf < count) { diff -rupN djgpp203mk2/src/libemu/src/emu387.cc djgpp203mk3/src/libemu/src/emu387.cc --- djgpp203mk2/src/libemu/src/emu387.cc 1999-12-02 09:43:22.000000000 +0000 +++ djgpp203mk3/src/libemu/src/emu387.cc 2002-10-13 18:11:38.000000000 +0000 @@ -1,9 +1,12 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include #include #include +#include #include asm(".long ___libemu_ident_string"); @@ -139,8 +142,11 @@ static inline int is_zero(reg a) #ifndef eprintf static void eprintf(const char *f, ...) { + va_list args; char buf[1000]; - vsprintf(buf, f, (&f)+1); + va_start(args, f); + vsprintf(buf, f, args); + va_end(args); _write(1, buf, strlen(buf)); } #endif @@ -369,9 +375,9 @@ static int getsib() int mod = modrm >> 6; int sib = *eip++; int ss = sib>>6; - int index = (sib>>3) & 7; + int s_index = (sib>>3) & 7; int base = sib & 7; - int rv = sregval(base, mod) + sregval(index, -1) * scale[ss]; + int rv = sregval(base, mod) + sregval(s_index, -1) * scale[ss]; int rv2; switch (mod) { diff -rupN djgpp203mk2/src/libemu/src/emudummy.c djgpp203mk3/src/libemu/src/emudummy.c --- djgpp203mk2/src/libemu/src/emudummy.c 1997-11-02 14:54:30.000000000 +0000 +++ djgpp203mk3/src/libemu/src/emudummy.c 2002-10-15 13:40:06.000000000 +0000 @@ -1,14 +1,38 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -/* Dummy routines to enable building of emu387.dxe from libemu.a - since we - can't do I/O, dummy the I/O routines out. */ + +/* Dummy routines to enable building of emu387.dxe from libemu.a. + * + * Since we can't do I/O, dummy the I/O routines out. Since we can't link + * against a profiled libc, dummy the profiling functions out. + */ + +#include +#include +#include +#include -void vsprintf(void); -void _write(void); +int +vsprintf (char *buf, const char *fmt, va_list args) +{ + return 0; +} + +ssize_t +_write (int fd, const void *buf, size_t nbyte) +{ + return 0; +} + +void mcount (int _to); -void vsprintf(void) {} -void _write(void) {} +void +mcount (int _to) +{ +} int __djgpp_exception_state_ptr; diff -rupN djgpp203mk2/src/makefile.def djgpp203mk3/src/makefile.def --- djgpp203mk2/src/makefile.def 1999-12-14 06:35:56.000000000 +0000 +++ djgpp203mk3/src/makefile.def 2002-10-13 18:34:04.000000000 +0000 @@ -1,3 +1,4 @@ +# Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details # Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details # -*- makefile -*- @@ -36,6 +37,7 @@ AR = ar LD = ld STRIP = strip BISON = bison +LIBSTDCXX = -lstdcxx else @@ -58,6 +60,7 @@ AR = ar LD = ld STRIP = strip BISON = bison +LIBSTDCXX = -lstdc++ # You may need to replace coff-go32 with coff-i386 in lib/djgpp.djl or # edit your cross_ld to replace coff-i386 with coff-go32 (as I did) diff -rupN djgpp203mk2/src/makefile.inc djgpp203mk3/src/makefile.inc --- djgpp203mk2/src/makefile.inc 1998-09-07 14:12:10.000000000 +0000 +++ djgpp203mk3/src/makefile.inc 2002-10-15 19:53:08.000000000 +0000 @@ -1,3 +1,4 @@ +# Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details # Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details # -*- makefile -*- @@ -7,14 +8,24 @@ MAKEFLAGS := --no-print-directory .SUFFIXES: .o .i .c .cc .s +# Find the directory of header files provided with GCC +ifeq ($(GCCHEADERS),) +GCCHEADERS := $(shell $(CROSS_GCC) -print-file-name=libgcc.a) +GCCHEADERS := $(subst libgcc.a,include,$(GCCHEADERS)) +GCCHEADERS := $(subst \,/,$(GCCHEADERS)) +export GCCHEADERS +endif + +XGCC_INCLUDES := -I. -I- -isystem $(GCCHEADERS) -isystem $(TOP)/../../include + ifneq ($(CROSS_BUILD),1) -XGCC = $(CROSS_GCC) @$(TOP)/../gcc.opt -I. -I- -I$(TOP)/../../include $(CFLAGS) -XLGCC = $(CROSS_GCC) -s @$(TOP)/../gcc-l.opt -I. -I- -I$(TOP)/../../include $(CFLAGS) +XGCC = $(CROSS_GCC) @$(TOP)/../gcc.opt $(XGCC_INCLUDES) $(CFLAGS) +XLGCC = $(CROSS_GCC) -s @$(TOP)/../gcc-l.opt $(XGCC_INCLUDES) $(CFLAGS) else GCC_OPT := $(shell cat $(TOP)/../gcc.opt) GCCL_OPT := $(shell cat $(TOP)/../gcc-l.opt) -XGCC = $(CROSS_GCC) $(GCC_OPT) -I. -I- -I$(TOP)/../../include $(CFLAGS) -XLGCC = $(CROSS_GCC) $(GCCL_OPT) -I. -I- -I$(TOP)/../../include $(CFLAGS) +XGCC = $(CROSS_GCC) $(GCC_OPT) $(XGCC_INCLUDES) $(CFLAGS) +XLGCC = $(CROSS_GCC) $(GCCL_OPT) $(XGCC_INCLUDES) $(CFLAGS) endif MISC = $(TOP)/../misc.exe @@ -23,8 +34,8 @@ MISC = $(TOP)/../misc.exe @$(MISC) echo - $(CROSS_GCC) '...' -c $< @$(XGCC) -c $< %.o : %.cc - @$(MISC) echo - $(CROSS_GCC) '...' -c $< - @$(XGCC) -c $< + @$(MISC) echo - $(CROSS_GCC) '...' -c -fno-exceptions -fno-rtti $< + @$(XGCC) -c -fno-exceptions -fno-rtti $< %.o : %.S @$(MISC) echo - $(CROSS_GCC) '...' -c $< @$(XGCC) -c $< @@ -65,7 +76,10 @@ export LIBGCCA endif ifeq ($(DJGPP_DJL),) -DJGPP_DJL := $(shell $(CROSS_GCC) -print-file-name=djgpp.djl) +DJGPP_DJL := $(shell $(CROSS_GCC) $(GCC_OPT) -print-file-name=djgpp-x.djl) +ifeq ($(DJGPP_DJL),djgpp-x.djl) +DJGPP_DJL := $(shell $(CROSS_GCC) $(GCC_OPT) -print-file-name=djgpp.djl) +endif DJGPP_DJL := $(subst \,/,$(DJGPP_DJL)) export DJGPP_DJL endif diff -rupN djgpp203mk2/src/mkdoc/makefile djgpp203mk3/src/mkdoc/makefile --- djgpp203mk2/src/mkdoc/makefile 1998-01-01 15:28:14.000000000 +0000 +++ djgpp203mk3/src/mkdoc/makefile 2002-10-13 18:33:50.000000000 +0000 @@ -1,3 +1,4 @@ +# Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details # Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details # Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details @@ -7,7 +8,7 @@ include $(TOP)/../makefile.inc all :: $(HOSTBIN)/mkdoc.exe $(HOSTBIN)/mkdoc.exe : mkdoc.cc - $(GCC) mkdoc.cc -o $@ + $(GCC) mkdoc.cc $(LIBSTDCXX) -o $@ clean :: @-$(MISC) rm $(HOSTBIN)/mkdoc.exe diff -rupN djgpp203mk2/src/utils/bin2h.c djgpp203mk3/src/utils/bin2h.c --- djgpp203mk2/src/utils/bin2h.c 1999-06-03 13:27:42.000000000 +0000 +++ djgpp203mk3/src/utils/bin2h.c 2002-10-15 13:53:30.000000000 +0000 @@ -3,6 +3,7 @@ /* 1998 -- Modified by Nils van den Heuvel (n DOT heuvel AT wxs DOT nl) */ #include +#include #include #include #include diff -rupN djgpp203mk2/src/utils/djecho.c djgpp203mk3/src/utils/djecho.c --- djgpp203mk2/src/utils/djecho.c 1996-08-12 19:55:54.000000000 +0000 +++ djgpp203mk3/src/utils/djecho.c 2002-10-15 13:54:40.000000000 +0000 @@ -1,6 +1,7 @@ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include +#include int main(int argc, char **argv) diff -rupN djgpp203mk2/src/utils/djmerge.c djgpp203mk3/src/utils/djmerge.c --- djgpp203mk2/src/utils/djmerge.c 1999-12-14 06:53:02.000000000 +0000 +++ djgpp203mk3/src/utils/djmerge.c 2002-10-15 19:05:40.000000000 +0000 @@ -1,7 +1,9 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include #include #include #include diff -rupN djgpp203mk2/src/utils/texi2ps/word.c djgpp203mk3/src/utils/texi2ps/word.c --- djgpp203mk2/src/utils/texi2ps/word.c 1999-02-20 16:56:08.000000000 +0000 +++ djgpp203mk3/src/utils/texi2ps/word.c 2002-10-15 19:07:38.000000000 +0000 @@ -1,3 +1,4 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ /* texi2ps -- convert texinfo format files into Postscript files. @@ -20,6 +21,7 @@ #include #include +#include #include #include "word.h" #include "ps.h" diff -rupN djgpp203mk2/src/utils/update.c djgpp203mk3/src/utils/update.c --- djgpp203mk2/src/utils/update.c 1995-07-12 05:27:14.000000000 +0000 +++ djgpp203mk3/src/utils/update.c 2002-10-15 19:06:26.000000000 +0000 @@ -1,7 +1,9 @@ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -/* This file is intended to be compiled with Turbo-C */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include #include +#include #include #include #include