delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2016/03/16/10:30:10

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: "Wiktor S. (wswiktorSP AT Mpoczta DOT fm) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: how to unlock locked memory
Date: Wed, 16 Mar 2016 15:15:30 +0100
Organization: INTERIA.PL S.A.
Lines: 57
Message-ID: <ncbpq2$uo7$1@usenet.news.interia.pl>
References: <nbs7v1$3da$1 AT usenet DOT news DOT interia DOT pl> <20160316000317 DOT 329b9cf8 AT _> <ncbagh$v79$1 AT usenet DOT news DOT interia DOT pl> <56E949FA DOT 2070703 AT yahoo DOT no>
NNTP-Posting-Host: user-164-127-34-93.play-internet.pl
Mime-Version: 1.0
X-Trace: usenet.news.interia.pl 1458137731 31495 164.127.34.93 (16 Mar 2016 14:15:31 GMT)
X-Complaints-To: usenet AT firma DOT interia DOT pl
NNTP-Posting-Date: Wed, 16 Mar 2016 14:15:31 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5931
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157
Bytes: 2518
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

>> Thanks. Weird that there is no _go32_dpmi_unlock_code/data.

> You can use '__dpmi_unlock_linear_region()'.

Yes, I've modified _go32_dpmi_lock_data to use unlock_linear_region, like 
this:

==============
int _go32_dpmi_unlock_data( void *lockaddr, unsigned long locksize )
    {
    unsigned long baseaddr;
    __dpmi_meminfo memregion;

    if( __dpmi_get_segment_base_address( _go32_my_ds(), &baseaddr) == -1 ) 
return( -1 );

    memset( &memregion, 0, sizeof(memregion) );

    memregion.address = baseaddr + (unsigned long) lockaddr;
    memregion.size    = locksize;

    if( __dpmi_unlock_linear_region( &memregion ) == -1 ) return( -1 );

    return( 0 );
    }


int _go32_dpmi_unlock_code( void *lockaddr, unsigned long locksize )
    {
    unsigned long baseaddr;
    __dpmi_meminfo memregion;

    if( __dpmi_get_segment_base_address( _go32_my_cs(), &baseaddr) == -1 ) 
return( -1 );

    memset( &memregion, 0, sizeof(memregion) );

    memregion.address = baseaddr + (unsigned long) lockaddr;
    memregion.size    = locksize;

    if( __dpmi_unlock_linear_region( &memregion ) == -1 ) return( -1 );

    return( 0 );
    }

==============

Seems to work, but it's a bit inconvenient because the project is in Ada, 
and this is now the only .c file.

Any reason why it's not in libc?


-- 
Wiktor S.


- Raw text -


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