Changeset 3906 for branches/libc-0.6


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:
branches/libc-0.6/src/emx
Files:
5 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)
Note: See TracChangeset for help on using the changeset viewer.