Changeset 3906 for trunk


Ignore:
Timestamp:
Oct 24, 2014, 1:50:44 AM (11 years ago)
Author:
bird
Message:

0.6,trunk: DosLoadModuleEx and DosFreeModuleEx should make an effort to preserve the FPU control word in addition to FS. Added a couple of common macros for doing both in one go. Fixed DosRead and DosWrite wrappers on trunk, they weren't restoring the registers.

Location:
trunk/libc
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/libc/include/klibc/os2/os2.h

    r3897 r3906  
    44 * Wrapper for the OS/2 API headers.
    55 *
    6  * Copyright (c) 2006 knut st. osmundsen <bird@innotek.de>
     6 * Copyright (c) 2006-2014 knut st. osmundsen <bird@innotek.de>
    77 *
    88 *
     
    3636#define INCL_FSMACROS
    3737#define INCL_FPCWMACROS
     38#define INCL_PRESERVE_REGISTER_MACROS
    3839#define INCL_EXAPIS
    3940
  • trunk/libc/include/os2emx.h

    r3897 r3906  
    1335013350
    1335113351
    13352 /* --------------------- FS Save/Load/Restore macros ---------------------- */
    13353 
    13354 #if defined(INCL_FSMACROS)
     13352/* --------------------- Register preservation macros ---------------------- */
     13353
     13354#if defined(INCL_FSMACROS) || defined(INCL_PRESERVE_REGISTER_MACROS)
    1335513355
    1335613356#ifndef FS_DISABLED
     
    1338413384#endif
    1338513385
    13386 #endif /* INCL_FSMACROS */
    13387 
    13388 #if defined(INCL_FPCWMACROS)
     13386#endif /* INCL_FSMACROS || INCL_PRESERVE_REGISTER_MACROS */
     13387
     13388#if defined(INCL_FPCWMACROS) || defined(INCL_PRESERVE_REGISTER_MACROS)
    1338913389
    1339013390#ifndef FSCW_DISABLED
     
    1341213412#endif
    1341313413
    13414 #endif /* INCL_FPCWMACROS */
     13414#endif /* INCL_FPCWMACROS || INCL_PRESERVE_REGISTER_MACROS */
     13415
     13416#if defined(INCL_PRESERVE_REGISTER_MACROS) || (defined(INCL_FSMACROS) && defined(INCL_FPCWMACROS))
     13417# define PRESERVE_REGS_SAVE_LOAD_SAFE()       FS_VAR(); FSCW_VAR(); PRESERVE_REGS_SAVE_LOAD_SAFE_AGAIN()
     13418# define PRESERVE_REGS_SAVE_LOAD_SAFE_AGAIN() do { FS_SAVE_LOAD(); FSCW_SAVE(); } while (0)
     13419# define PRESERVE_REGS_RESTORE()              do { FSCW_RESTORE(); FS_RESTORE(); } while (0)
     13420#endif
    1341513421
    1341613422
  • trunk/libc/src/kNIX/os2/DosFreeModuleEx.c

    r3862 r3906  
    44 * kNIX - DosFreeModuleEx.
    55 *
    6  * Copyright (c) 2004-2006 knut st. osmundsen <bird-src-spam@anduin.net>
     6 * Copyright (c) 2004-2014 knut st. osmundsen <bird-src-spam@anduin.net>
    77 *
    88 *
     
    3737    LIBCLOG_ENTER("hmod=%lx\n", hmod);
    3838    int         rc;
    39     FS_VAR();
    4039
    4140    /*
     
    4847     * Free module.
    4948     */
    50     FS_SAVE_LOAD();
    5149    rc = __libc_dosexFree(DOSEX_TYPE_LOAD_MODULE, (unsigned)hmod);
    5250    if (rc == -1)
     51    {
     52        PRESERVE_REGS_SAVE_LOAD_SAFE();
    5353        rc = DosFreeModule(hmod);
    54     FS_RESTORE();
     54        PRESERVE_REGS_RESTORE();
     55    }
    5556    if (!rc)
    5657        LIBCLOG_RETURN_INT(rc);
  • trunk/libc/src/kNIX/os2/DosLoadModuleEx.c

    r3862 r3906  
    22/** @file
    33 *
    4  * kNIX - DosCreateEventSemEx.
     4 * kNIX - DosLoadModuleEx.
    55 *
    6  * Copyright (c) 2004-2006 knut st. osmundsen <bird-src-spam@anduin.net>
     6 * Copyright (c) 2004-2014 knut st. osmundsen <bird-src-spam@anduin.net>
    77 *
    88 *
     
    2525 */
    2626
     27#define INCL_PRESERVE_REGISTER_MACROS
    2728#include "kNIX.h"
    2829#include "DosEx.h"
     
    4243    HMODULE     hmte;
    4344    int         rc;
    44     FS_VAR();
    4545
    4646    /*
    4747     * Create the semaphore.
    4848     */
    49     FS_SAVE_LOAD();
     49    PRESERVE_REGS_SAVE_LOAD_SAFE();
    5050    rc = DosLoadModule(pszObject, cbObject, pszModule, phmod);
     51    PRESERVE_REGS_RESTORE();
    5152    if (rc)
    52     {
    53         FS_RESTORE();
    5453        LIBCLOG_ERROR_RETURN_INT(rc);
    55     }
    5654
    5755    /*
     
    7472        if (!pDosEx)
    7573        {
     74            PRESERVE_REGS_SAVE_LOAD_SAFE_AGAIN();
    7675            DosFreeModule(hmte);
    77             FS_RESTORE();
     76            PRESERVE_REGS_RESTORE();
    7877            LIBCLOG_ERROR_RETURN_INT(ERROR_NOT_ENOUGH_MEMORY);
    7978        }
     
    8685    }
    8786
    88     FS_RESTORE();
    8987    LIBCLOG_RETURN_MSG(0, "ret 0 *phmod=%#lx\n", hmte);
    9088}
  • trunk/libc/src/kNIX/os2/fhOS2File.c

    r3861 r3906  
    8484{
    8585    LIBCLOG_ENTER("pFH=%p:{.fh=%d} pvBuf=%p cbToRead=%zu pcbRead=%p\n", pFH, pFH->fh, pvBuf, cbToRead, pcbRead);
    86     FS_VAR_SAVE_LOAD();
    87     FSCW_VAR();
    88     FSCW_SAVE();
    8986
    9087    /*
     
    9289     * Allocate a buffer in the low heap.
    9390     */
     91    PRESERVE_REGS_SAVE_LOAD_SAFE();
    9492    int     rc;
    9593    ULONG   cbActuallyRead = 0;
     
    110108    else
    111109        rc = DosRead(pFH->hNative, pvBuf, cbToRead, &cbActuallyRead);
    112 
     110    PRESERVE_REGS_RESTORE();
    113111
    114112    /* deal with the return code. */
     
    136134{
    137135    LIBCLOG_ENTER("pFH=%p:{.fh=%d} pvBuf=%p cbToWrite=%zu pcbWritten=%p\n", pFH, pFH->fh, pvBuf, cbToWrite, (void *)pcbWritten);
    138     FS_VAR_SAVE_LOAD();
    139     FSCW_VAR();
    140     FSCW_SAVE();
    141136
    142137    /*
     
    144139     * Allocate a buffer in the low heap.
    145140     */
     141    PRESERVE_REGS_SAVE_LOAD_SAFE();
    146142    int     rc;
    147143    ULONG   cbActuallyWritten = 0;
     
    161157    else
    162158        rc = DosWrite(pFH->hNative, pvBuf, cbToWrite, &cbActuallyWritten);
     159    PRESERVE_REGS_RESTORE();
    163160
    164161    /* deal with the return code. */
Note: See TracChangeset for help on using the changeset viewer.