• Re: Error handling of ECX in __dpmi_set_page_attributes()

    From [via djgpp@delorie.com]" @21:1/5 to Pali on Thu Mar 21 09:22:17 2024
    To: cwsdpmi@earthlink.net (Charles Sandmann)
    Copy: dj@delorie.com
    Copy: sezeroz@gmail.com
    Copy: djgpp@delorie.com

    Date: Thu, 21 Mar 2024 00:15:22 +0100
    From: Pali <pali@pali.im>
    Cc: djgpp@delorie.com

    In function __dpmi_set_page_attributes implemented in d0507.S assembly
    file is missing propagation of ECX register on error.

    DPMI 1.0 spec says that if function 0507H is unsuccessful then it sets
    ECX to number of pages that have been set.

    It is not clear from the spec whether ECX is _always_ set, regardless
    of the error code returned in AX. Some error codes don't sound like
    they could happen after successfully setting attributes of several
    pages. Do we have any information about what the various DPMI 1.0
    hosts actually do in this case? Should we at least check in the
    function's code that the value in ECX is non-negative and smaller than
    the value of ECX set by the caller?

    I also question the wisdom of writing into the input structure
    provided by the caller -- the caller might not expect that. What
    other DPMI functions do something like that?

    But DJGPP's wrapper for DPMI 0507H in __dpmi_set_page_attributes
    propagates ECX register value to caller only if DPMI function success.
    Value stay unmodified if function fails.

    Maybe I'm missing something, but I don't see where the DPMI macro
    propagates ECX back to the caller when the DPMI call succeeds. What I
    see is that the value of info->count stays unmodified regardless of
    whether the call succeeds or fails. What did I miss?

    Could you look at this problem?

    I have there a simple fix for it. The following change propagates ECX register back to the caller not only on success, but also on failure.

    Any real-life situation where you need this enhancement?

    (I added Charles to the addressees in the hope that he could find a
    moment to look at this and comment.)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [via djgpp@delorie.com]" @21:1/5 to Pali on Fri Apr 12 16:32:40 2024
    Copy: cwsdpmi@earthlink.net
    Copy: dj@delorie.com
    Copy: sezeroz@gmail.com
    Copy: djgpp@delorie.com

    Date: Thu, 4 Apr 2024 20:48:44 +0200
    From: Pali <pali@pali.im>
    Cc: Charles Sandmann <cwsdpmi@earthlink.net>, dj@delorie.com,
    sezeroz@gmail.com, djgpp@delorie.com

    On Thursday 21 March 2024 09:22:17 Eli Zaretskii wrote:
    Should we at least check in the
    function's code that the value in ECX is non-negative and smaller than
    the value of ECX set by the caller?

    That is a good idea. Here is an alternative change which does this check:

    Thanks, installed.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [via djgpp@delorie.com]" @21:1/5 to Pali on Sat Apr 13 10:12:25 2024
    Copy: cwsdpmi@earthlink.net
    Copy: dj@delorie.com
    Copy: sezeroz@gmail.com
    Copy: djgpp@delorie.com

    Date: Sat, 13 Apr 2024 02:37:17 +0200
    From: Pali <pali@pali.im>
    Cc: cwsdpmi@earthlink.net, dj@delorie.com, sezeroz@gmail.com,
    djgpp@delorie.com

    On Friday 12 April 2024 16:32:40 Eli Zaretskii wrote:
    Date: Thu, 4 Apr 2024 20:48:44 +0200
    From: Pali <pali@pali.im>
    Cc: Charles Sandmann <cwsdpmi@earthlink.net>, dj@delorie.com,
    sezeroz@gmail.com, djgpp@delorie.com

    On Thursday 21 March 2024 09:22:17 Eli Zaretskii wrote:
    Should we at least check in the
    function's code that the value in ECX is non-negative and smaller than the value of ECX set by the caller?

    That is a good idea. Here is an alternative change which does this check:

    Thanks, installed.

    I would propose to extend documentation for DPMI 0507h function to
    include information about modifying the size member.

    --- src/libc/dpmi/api/d0507.txh
    +++ src/libc/dpmi/api/d0507.txh
    @@ -27,2 +27,10 @@ attribute word.

    +On error this function changes @code{@var{info}->size} to the number
    +of modified pages as reported by DPMI function AX = 0x0507. If DPMI +function reports that all input pages were modified or even more
    +number of pages than the input number of pages were modified then it
    +is treated as invalid value reported by DPMI function and so this
    +functions changes @code{@var{info}->size} to 0 as probably no page
    +was modified.
    +
    The DJGPP startup code calls this function to uncommit the so-called

    Thanks, installed (with some punctuation and wording changes).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)