delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2020/12/15/20:24:22

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net;
s=badeba3b8450; t=1608081619;
bh=6JFL+pn0+Kifk6HWVULNnIn0TCyJN0s2jF+kPP1AAik=;
h=X-UI-Sender-Class:Date:From:To:Subject:References:In-Reply-To;
b=OquGWH5l7VX7cz5vDZTrx9ayOMWAG3EY48KE0jmLmchgaS/1ZKokyHsKAuf7AIaet
nkmkmCaC8yufjRFCVZdIOLBAujGN4DS1fSqPtZv+kni4bD1ySU8nEm+iRwQvKJySOy
hiw/SXJVDyS512gnsoHEOpk9ofQf1hTW6AqXOIW0=
X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c
Message-ID: <5FD960D1.3010008@gmx.de>
Date: Wed, 16 Dec 2020 02:20:17 +0100
From: "Juan Manuel Guerrero (juan DOT guerrero AT gmx DOT de) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.13) Gecko/20101206 SUSE/3.1.7 Thunderbird/3.1.7
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: Difficulties compiling libc from repository using gcc 10.N.0
References: <5FD1FEA1 DOT 7010304 AT gmx DOT de> <CAA2C=vB2FUmrC_iboB7Mp3Uu2hLoTxWB2ptEOkjc69Az3FZU1A AT mail DOT gmail DOT com> <5FD2C0B9 DOT 8080208 AT gmx DOT de> <CAA2C=vAj+1p9PNXSB3sJvrxFUn9SvgG6uHRSbxsx48+OsyYiwg AT mail DOT gmail DOT com> <CAA2C=vBU+YB_x_rkpmEc8G_8yccXK5MivRLMf5wGO2-jTwuWVQ AT mail DOT gmail DOT com>
In-Reply-To: <CAA2C=vBU+YB_x_rkpmEc8G_8yccXK5MivRLMf5wGO2-jTw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K
j7RLZmHO4foV1N7vxZhoWeLVrZHDTrdnmGsdrwYavYTk1SVlC+id/MPcziKu0lOG0tiS34zU7
TBNI5mzcBivCvkYxwUgy+zfFQuLYDFKwRlOBIKKzQ0DI3StvWG3u8nCPaCfXpB3haK6Qj+cm8
vqLGsXFC0/UEtZVUpOHA==
Reply-To: djgpp AT delorie DOT com

Am 13.12.2020 18:52, schrieb Ozkan Sezer (sezeroz AT gmail DOT com) [via djgpp AT delorie DOT com]:
> On 12/11/20, Ozkan Sezer<sezeroz AT gmail DOT com>  wrote:
>> On 12/11/20, Juan Manuel Guerrero (juan DOT guerrero AT gmx DOT de) [via djgpp AT delorie DOT com]<djgpp AT delorie DOT com>  wrote:
>>>> As far as I can see, this particular case is intending this
>>>> using a nasty shortcut?
>>> What is today a nasty shortcut was a cool one 30 years ago.
>>
>> No arguments there.
>>
>>>> Correct?  Any others like this?
>>> Looks ok to me.  Will do the job; alternatively we would have to disable
>>> that check.
>>
>> Attached a patch that applies to current CVS.
>>
>> However, the asm outputs differ.  Tried gcc-3.4.6 and gcc-8.2.0,
>> asm outputs from both are attached here (*_0.s for original and
>> *_1.s for patched.)  Also attached diffs of *.s for convenience.
>> Someone good with x86 asm should verify.
>
> Has anyone had a chance to look at this?

IMHO it makes not to much sense to compare the assembly code.  It is clear that
different code will produce different assembly output.  I do not even know how
the va_* macros are implemented and if they are provided by the libc code or by
the compiler as build-in features.  The only important thing is that the proposed
code is functional equivalent to the one that shall be substituted.  I have
tried to prove this with the small modification shown below and with a test
program that first reads the attribute then sets the read-only bit and writes
back the attribute.  I have done this with gcc345 and gcc1020 and in both case
it did work for me.  From my point of view the proposed fix is ok but it is only
opinion.

Regards,
Juan M. Guerrero





OFYI, the small check code:


diff -aprNU3 djgpp.orig/src/1.c djgpp/src/1.c
--- djgpp.orig/src/1.c	1970-01-01 00:00:00 +0000
+++ djgpp/src/1.c	2020-12-15 12:51:32 +0000
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <io.h>
+
+int main(void)
+{
+  int f, m, rc;
+
+  f = 0;
+  rc = _chmod("1.c", f);
+  if (rc != -1)
+  {
+    m = rc | 0x00000001;
+    f = 1;
+    rc = _chmod("1.c", f, m);
+  }
+  if (rc == -1)
+    printf("failed");
+
+  return rc;
+}
diff -aprNU3 djgpp.orig/src/libc/dos/io/_chmod.c djgpp/src/libc/dos/io/_chmod.c
--- djgpp.orig/src/libc/dos/io/_chmod.c	2018-05-14 16:56:40 +0000
+++ djgpp/src/libc/dos/io/_chmod.c	2020-12-15 12:51:26 +0000
@@ -9,7 +9,9 @@
  #include <dpmi.h>
  #include <fcntl.h>
  #include <libc/dosio.h>
-
+#include <stdarg.h>
+#include <stdlib.h>
+
  int
  _chmod(const char *filename, int func, ...)
  {
@@ -25,7 +27,16 @@ _chmod(const char *filename, int func, .
      r.x.ax = 0x4300 + func;
    _put_path(filename);
    if (func == 1)
-    r.x.cx = *(&func + 1);		/* Value to set */
+  {
+    int v1, v2 = *(&func + 1);		/* Value to set */
+    va_list ap;
+    va_start (ap, func);
+    r.x.cx = v1 = va_arg(ap, int);		/* Value to set */
+    va_end (ap);
+
+    if (v1 != v2)
+      abort();
+  }
    r.x.dx = __tb_offset;
    r.x.ds = __tb_segment;
    __dpmi_int(0x21, &r);

- Raw text -


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