delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/05/24/13:22:06

Date: Sun, 24 May 1998 20:21:51 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: DJ Delorie <dj AT delorie DOT com>
cc: djgpp-workers AT delorie DOT com
Subject: errno and ANSI compliance
Message-ID: <Pine.SUN.3.91.980524202048.12971b-100000@is>
MIME-Version: 1.0

ANSI requires that errno be zero at program startup.  This simple change 
makes us comply:

*** src/libc/crt0/crt1.c~0	Mon Dec 29 22:09:42 1997
--- src/libc/crt0/crt1.c	Sat May 23 17:02:52 1998
***************
*** 5,10 ****
--- 5,11 ----
  #include <string.h>
  #include <libc/internal.h>
  #include <stdlib.h>
+ #include <errno.h>
  #include <go32.h>
  #include <stubinfo.h>
  #include <dpmi.h>
*************** __crt1_startup(void)
*** 167,172 ****
--- 168,174 ----
    _npxsetup(pn);
    _crt0_init_mcount();
    __main();
+   errno = 0;	/* ANSI says errno should be zero at program startup */
    exit(main(__crt0_argc, __crt0_argv, environ));
  }
  
*** src/docs/kb/wc202.t~9	Sat Apr 18 17:09:08 1998
--- src/docs/kb/wc202.txi	Sat May 23 17:34:56 1998
***************
*** 362,364 ****
--- 362,370 ----
  @code{system} is now compliant with ANSI C Standard when its argument is
  a NULL pointer.
  @findex system
+ 
+ Previously, at program startup @code{errno} would retain whatever value
+ it was assigned by the DJGPP startup code.  ANSI C Standard requires
+ @code{errno} to be zero at the beginning of @code{main}, so it is now
+ reset to zero before calling @code{main}.
+ @vindex errno

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019