Changeset 3906


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.

Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/include/os2emx.h

    r3839 r3906  
    1334713347
    1334813348
    13349 /* --------------------- FS Save/Load/Restore macros ---------------------- */
    13350 
    13351 #if defined(INCL_FSMACROS)
     13349/* --------------------- Register preservation macros ---------------------- */
     13350
     13351#if defined(INCL_FSMACROS) || defined(INCL_PRESERVE_REGISTER_MACROS)
    1335213352
    1335313353#ifndef FS_DISABLED
     
    1336413364#endif
    1336513365
    13366 #endif /* INCL_FSMACROS */
    13367 
    13368 #if defined(INCL_FPCWMACROS)
    13369 
    13370 #ifndef FSCW_DISABLED
     13366#endif /* INCL_FSMACROS || INCL_PRESERVE_REGISTER_MACROS */
     13367
     13368#if defined(INCL_FPCWMACROS) || defined(INCL_PRESERVE_REGISTER_MACROS)
     13369
     13370#ifndef FPCW_DISABLED
    1337113371#define FSCW_VAR()        volatile unsigned __fpcw__;
    1337213372#define FSCW_SAVE()       __asm__ __volatile__ ("fnstcw %0;" : : "m" (__fpcw__) )
     
    1337813378#endif
    1337913379
    13380 #endif /* INCL_FPCWMACROS */
     13380#endif /* INCL_FPCWMACROS || INCL_PRESERVE_REGISTER_MACROS */
     13381
     13382#if defined(INCL_PRESERVE_REGISTER_MACROS) || (defined(INCL_FSMACROS) && defined(INCL_FPCWMACROS))
     13383# define PRESERVE_REGS_SAVE_LOAD_SAFE()       FS_VAR(); FSCW_VAR(); PRESERVE_REGS_SAVE_LOAD_SAFE_AGAIN()
     13384# define PRESERVE_REGS_SAVE_LOAD_SAFE_AGAIN() do { FS_SAVE_LOAD(); FSCW_SAVE(); } while (0)
     13385# define PRESERVE_REGS_RESTORE()              do { FSCW_RESTORE(); FS_RESTORE(); } while (0)
     13386#endif
     13387
    1338113388
    1338213389
  • branches/libc-0.6/src/emx/src/lib/sys/DosFreeModuleEx.c

    r2254 r3906  
    44 * DosFreeModuleEx.
    55 *
    6  * Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
     6 * Copyright (c) 2004-2014 knut st. osmundsen <bird-srcspam@anduin.net>
    77 *
    88 *
     
    3131#define INCL_ERRORS
    3232#define INCL_DOSMODULEMGR
    33 #define INCL_FSMACROS
     33#define INCL_PRESERVE_REGISTER_MACROS
    3434#define INCL_EXAPIS
    3535#include <os2emx.h>
     
    4545{
    4646    LIBCLOG_ENTER("hmod=%lx\n", hmod);
    47     int         rc;
    48     FS_VAR();
     47    int rc;
    4948
    5049    /*
     
    5756     * Free module.
    5857     */
    59     FS_SAVE_LOAD();
    6058    rc = __libc_dosexFree(DOSEX_TYPE_LOAD_MODULE, (unsigned)hmod);
    6159    if (rc == -1)
     60    {
     61        PRESERVE_REGS_SAVE_LOAD_SAFE();
    6262        rc = DosFreeModule(hmod);
    63     FS_RESTORE();
     63        PRESERVE_REGS_RESTORE();
     64    }
    6465    if (!rc)
    6566        LIBCLOG_RETURN_INT(rc);
  • branches/libc-0.6/src/emx/src/lib/sys/DosLoadModuleEx.c

    r2254 r3906  
    44 * DosCreateEventSemEx.
    55 *
    6  * Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
     6 * Copyright (c) 2004-2014 knut st. osmundsen <bird-srcspam@anduin.net>
    77 *
    88 *
     
    3131#define INCL_ERRORS
    3232#define INCL_DOSMODULEMGR
    33 #define INCL_FSMACROS
     33#define INCL_PRESERVE_REGISTER_MACROS
    3434#define INCL_EXAPIS
    3535#include <os2emx.h>
     
    5050    HMODULE     hmte;
    5151    int         rc;
    52     FS_VAR();
    5352
    5453    /*
    5554     * Create the semaphore.
    5655     */
    57     FS_SAVE_LOAD();
     56    PRESERVE_REGS_SAVE_LOAD_SAFE();
    5857    rc = DosLoadModule(pszObject, cbObject, pszModule, phmod);
     58    PRESERVE_REGS_RESTORE();
    5959    if (rc)
    60     {
    61         FS_RESTORE();
    6260        LIBCLOG_ERROR_RETURN_INT(rc);
    63     }
    6461
    6562    /*
     
    8279        if (!pDosEx)
    8380        {
     81            PRESERVE_REGS_SAVE_LOAD_SAFE_AGAIN();
    8482            DosFreeModule(hmte);
    85             FS_RESTORE();
     83            PRESERVE_REGS_RESTORE();
    8684            LIBCLOG_ERROR_RETURN_INT(ERROR_NOT_ENOUGH_MEMORY);
    8785        }
     
    9492    }
    9593
    96     FS_RESTORE();
    9794    LIBCLOG_RETURN_MSG(0, "ret 0 *phmod=%#lx\n", hmte);
    9895}
  • branches/libc-0.6/src/emx/src/lib/sys/__read.c

    r3776 r3906  
    33
    44#include "libc-alias.h"
    5 #define INCL_FSMACROS
    6 #define INCL_FPCWMACROS
     5#define INCL_PRESERVE_REGISTER_MACROS
    76#define INCL_ERRORS
    87#include <os2emx.h>
     
    4140         */
    4241        void   *pvBuf_safe = NULL;
    43         FS_VAR();
    44         FSCW_VAR();
    4542
    4643        /*
     
    6057        }
    6158
    62         FS_SAVE_LOAD();
    63         FSCW_SAVE();
     59        PRESERVE_REGS_SAVE_LOAD_SAFE();
    6460        rc = DosRead(handle, pvBuf_safe ? pvBuf_safe : buf, cbToRead, &cbRead);
    65         FSCW_RESTORE();
    66         FS_RESTORE();
     61        PRESERVE_REGS_RESTORE();
    6762        if (pvBuf_safe)
    6863        {
  • branches/libc-0.6/src/emx/src/lib/sys/__write.c

    r2647 r3906  
    33
    44#include "libc-alias.h"
    5 #define INCL_FSMACROS
    6 #define INCL_FPCWMACROS
     5#define INCL_PRESERVE_REGISTER_MACROS
    76#define INCL_ERRORS
    87#include <os2emx.h>
     
    2423    int     rc;
    2524    ULONG   cbWritten;
    26     FS_VAR();
    27     FSCW_VAR();
    28 
    2925
    3026    /*
     
    7167        }
    7268
    73         FS_SAVE_LOAD();
    74         FSCW_SAVE();
     69        PRESERVE_REGS_SAVE_LOAD_SAFE();
    7570        rc = DosWrite(handle, buf, cbToWrite, &cbWritten);
    76         FSCW_RESTORE();
    77         FS_RESTORE();
     71        PRESERVE_REGS_RESTORE();
    7872
    7973        if (pvBuf_safe)
  • 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.