Changeset 86


Ignore:
Timestamp:
Jul 15, 2001, 10:57:25 AM (24 years ago)
Author:
umoeller
Message:

Misc changes.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/helpers/threads.h

    r70 r86  
    1313
    1414/*
    15  *      Copyright (C) 1997-2000 Ulrich M”ller.
     15 *      Copyright (C) 1997-2001 Ulrich M”ller.
    1616 *      This file is part of the "XWorkplace helpers" source package.
    1717 *      This is free software; you can redistribute it and/or modify
     
    4040     *@@ THREADINFO:
    4141     *      thread info structure passed to secondary threads.
     42     *      See thrCreate.
    4243     */
    4344
    4445    typedef struct _THREADINFO
    4546    {
    46             // data maintained by thr* functions
    47             ULONG   cbStruct;
    48             void*   pThreadFunc;    // as passed to thrCreate, really a PTHREADFUNC
    49             PULONG  ptidRunning;      // as passed to thrCreate V0.9.12 (2001-05-20) [umoeller]
    50             const char *pcszThreadName; // as passed to thrCreate
    51             ULONG   flFlags;        // as passed to thrCreate
    52             ULONG   ulData;         // as passed to thrCreate
     47        // data maintained by thr* functions
     48        ULONG   cbStruct;
     49        void*   pThreadFunc;    // as passed to thrCreate, really a PTHREADFUNC
     50        PULONG  ptidRunning;      // as passed to thrCreate V0.9.12 (2001-05-20) [umoeller]
     51        const char *pcszThreadName; // as passed to thrCreate
     52        ULONG   flFlags;        // as passed to thrCreate
     53        ULONG   ulData;         // as passed to thrCreate
    5354
    54             TID     tid;
    55             ULONG   hevRunning;     // this is a HEV really
     55        TID     tid;
     56        ULONG   hevRunning;     // this is a HEV really
    5657
    57             // data maintained by thr_fntGeneric
    58             HAB     hab;            // for PM threads
    59             HMQ     hmq;            // for PM threads
    60             BOOL    fExitComplete;
     58        // data maintained by thr_fntGeneric
     59        HAB     hab;            // for PM threads
     60        HMQ     hmq;            // for PM threads
     61        BOOL    fExitComplete;
    6162
    62             // data to be maintained by application
    63             BOOL    fExit;
    64             ULONG   ulResult;
    65             ULONG   ulFuncInfo;
    66             HWND    hwndNotify;
     63        // data to be maintained by application
     64        BOOL    fExit;
     65        ULONG   ulResult;
     66        ULONG   ulFuncInfo;
     67        HWND    hwndNotify;
    6768    } THREADINFO, *PTHREADINFO;
    6869
     
    7071    typedef THREADFUNC *PTHREADFUNC;
    7172
    72     ULONG thrCreate(PTHREADINFO pti,
    73                     PTHREADFUNC pfn,
    74                     PBOOL pfRunning,
    75                     const char *pcszThreadName,
    76                     ULONG flFlags,
    77                     ULONG ulData);
     73    ULONG XWPENTRY thrCreate(PTHREADINFO pti,
     74                             PTHREADFUNC pfn,
     75                             PULONG pfRunning,
     76                             const char *pcszThreadName,
     77                             ULONG flFlags,
     78                             ULONG ulData);
     79    // this function is exported, so add definition here V0.9.13 (2001-06-13) [lafaix]
     80    typedef BOOL XWPENTRY THRCREATE(PTHREADINFO, PTHREADFUNC, PULONG, const char *, ULONG, ULONG);
     81    typedef THRCREATE *PTHRCREATE;
    7882
    79     ULONG thrRunSync(HAB hab,
    80                      PTHREADFUNC pfn,
    81                      const char *pcszThreadName,
    82                      ULONG ulData);
     83    ULONG XWPENTRY thrRunSync(HAB hab,
     84                              PTHREADFUNC pfn,
     85                              const char *pcszThreadName,
     86                              ULONG ulData);
    8387
    84     PTHREADINFO thrListThreads(PULONG pcThreads);
     88    PTHREADINFO XWPENTRY thrListThreads(PULONG pcThreads);
    8589
    86     BOOL thrFindThread(PTHREADINFO pti,
    87                        ULONG tid);
     90    BOOL XWPENTRY thrFindThread(PTHREADINFO pti,
     91                                ULONG tid);
    8892
    89     BOOL thrClose(PTHREADINFO pti);
     93    BOOL XWPENTRY thrClose(PTHREADINFO pti);
    9094
    91     BOOL thrWait(PTHREADINFO pti);
     95    BOOL XWPENTRY thrWait(PTHREADINFO pti);
    9296
    93     BOOL thrFree(PTHREADINFO pti);
     97    BOOL XWPENTRY thrFree(PTHREADINFO pti);
    9498
    95     BOOL thrKill(PTHREADINFO pti);
     99    BOOL XWPENTRY thrKill(PTHREADINFO pti);
    96100
    97     TID thrQueryID(const THREADINFO* pti);
     101    TID XWPENTRY thrQueryID(const THREADINFO* pti);
    98102
    99     ULONG thrQueryPriority(VOID);
     103    ULONG XWPENTRY thrQueryPriority(VOID);
    100104
    101105#endif
  • trunk/src/helpers/dialog.c

    r85 r86  
    11801180 +          }
    11811181 *
    1182  *
     1182 *@@changed V0.9.14 (2001-07-07) [umoeller]: fixed disabled mouse with hwndOwner == HWND_DESKTOP
    11831183 */
    11841184
     
    13811381            // add "clip siblings" style
    13821382            flStyle |= WS_CLIPSIBLINGS;
     1383
     1384        if (hwndOwner == HWND_DESKTOP)
     1385            // there's some dumb XWorkplace code left
     1386            // which uses this, and this disables the
     1387            // mouse for some reason
     1388            // V0.9.14 (2001-07-07) [umoeller]
     1389            hwndOwner = NULLHANDLE;
    13831390
    13841391        pDlgData->hwndDlg = WinCreateWindow(HWND_DESKTOP,
  • trunk/src/helpers/dosh.c

    r82 r86  
    22702270                                        else
    22712271                                        {
    2272             // **patrick, this was missing...
    2273             // wonder if you ever tested this, this crashes in
    2274             // doshPerfGet otherwise ;-)
    2275             /*   -----------> */            pPerfSys->palIntrs = (PLONG)malloc(pPerfSys->cProcessors * sizeof(LONG));
     2272                                            pPerfSys->palIntrs = (PLONG)malloc(pPerfSys->cProcessors * sizeof(LONG));
    22762273                                            if (!pPerfSys->palIntrs)
    22772274                                                arc = ERROR_NOT_ENOUGH_MEMORY;
     
    22842281                                                    pPerfSys->padIntrPrev[ul] = 0.0;
    22852282                                                    pPerfSys->palLoads[ul] = 0;
    2286             /* and this one too */                  pPerfSys->palIntrs[ul] = 0;
     2283                                                    pPerfSys->palIntrs[ul] = 0;
    22872284                                                }
    22882285                                            }
  • trunk/src/helpers/helpers_pre.in

    r76 r86  
    4242$(OUTPUTDIR)\encodings.obj \
    4343$(OUTPUTDIR)\linklist.obj \
     44$(OUTPUTDIR)\math.obj \
    4445$(OUTPUTDIR)\tree.obj \
    4546$(OUTPUTDIR)\xml.obj \
  • trunk/src/helpers/linklist.c

    r74 r86  
    263263}
    264264
    265 #endif      // __DEBUG_MALLOC_ENABLED__
     265#else       // __DEBUG_MALLOC_ENABLED__
    266266
    267267/*
     
    286286 */
    287287
    288 PLINKLIST (lstCreate)(BOOL fItemsFreeable)    // in: invoke free() on the data
     288PLINKLIST lstCreate(BOOL fItemsFreeable)    // in: invoke free() on the data
    289289                                            // item pointers upon destruction?
    290290{
     
    294294    return (pNewList);
    295295}
     296
     297#endif      // __DEBUG_MALLOC_ENABLED__
    296298
    297299/*
     
    614616}
    615617
    616 #endif // __DEBUG_MALLOC_ENABLED__
     618#else // __DEBUG_MALLOC_ENABLED__
    617619
    618620/*
     
    626628 */
    627629
    628 PLISTNODE (lstAppendItem)(PLINKLIST pList,
     630PLISTNODE lstAppendItem(PLINKLIST pList,
    629631                        void* pNewItemData)     // in: data to store in list node
    630632{
     
    668670}
    669671
     672#endif // __DEBUG_MALLOC_ENABLED__
     673
    670674/*
    671675 *@@ lstInsertItemBefore:
     
    688692 *      This returns the LISTNODE of the new list item,
    689693 *      or NULL upon errors.
     694 *
     695 *@@changed V0.9.14 (2001-07-14) [umoeller]: this never worked on empty lists, fixed
    690696 */
    691697
     
    716722                    pList->pFirst = pNewNode;
    717723
    718                     pList->ulCount++;
     724                    if (!pList->pLast)
     725                        // the list was empty:
     726                        pList->pLast = pNewNode;        // V0.9.14 (2001-07-14) [umoeller]
     727
     728                    (pList->ulCount)++;
    719729                }
    720730                else
     
    744754                            pList->pLast = pNewNode;
    745755
    746                         pList->ulCount++;
     756                        (pList->ulCount)++;
    747757                    }
    748758                    else
  • trunk/src/helpers/timer.c

    r74 r86  
    7171
    7272/*
    73  *      Copyright (C) 2000 Ulrich M”ller.
     73 *      Copyright (C) 2000-2001 Ulrich M”ller.
    7474 *      This file is part of the "XWorkplace helpers" source package.
    7575 *      This is free software; you can redistribute it and/or modify
     
    109109#include "helpers\except.h"
    110110#include "helpers\linklist.h"
     111#include "helpers\math.h"
    111112#include "helpers\threads.h"
    112113#include "helpers\timer.h"
     
    241242 *
    242243 *@@added V0.9.9 (2001-03-07) [umoeller]
     244 *@@changed V0.9.14 (2001-07-07) [umoeller]: added GCD optimizations
    243245 */
    244246
     
    265267    {
    266268        // we have timers:
     269
    267270        ULONG ulOldPMTimeout = pSet->ulPMTimeout;
    268         pSet->ulPMTimeout = 1000;
    269 
    270         while (pNode)
    271         {
     271
     272        if (!pNode->pNext)
     273        {
     274            // only one timer:
     275            // that's easy
    272276            PXTIMER pTimer = (PXTIMER)pNode->pItemData;
    273 
    274             if ( (pTimer->ulTimeout / 2) < pSet->ulPMTimeout )
    275                 pSet->ulPMTimeout = pTimer->ulTimeout / 2;
    276 
    277             pNode = pNode->pNext;
     277            pSet->ulPMTimeout = pTimer->ulTimeout;
     278        }
     279        else if (!pNode->pNext->pNext)
     280        {
     281            // exactly two timers:
     282            // find the greatest common denominator
     283            PXTIMER pTimer1 = (PXTIMER)pNode->pItemData,
     284                    pTimer2 = (PXTIMER)pNode->pNext->pItemData;
     285
     286            pSet->ulPMTimeout = mathGCD(pTimer1->ulTimeout,
     287                                        pTimer2->ulTimeout);
     288        }
     289        else
     290        {
     291            // several timers:
     292            // run through all timers and find the greatest
     293            // common denominator of all frequencies...
     294
     295            ULONG   cTimers = lstCountItems(pllXTimers);
     296            int     *paInts = (int*)_alloca(sizeof(int) * cTimers),
     297                    i = 0;
     298
     299            _Pmpf(("Recalculating, got %d timers %d", cTimers));
     300
     301            // fill an array of integers with the
     302            // timer frequencies
     303            while (pNode)
     304            {
     305                PXTIMER pTimer = (PXTIMER)pNode->pItemData;
     306
     307                _Pmpf(("  timeout %d is %d", i, pTimer->ulTimeout));
     308
     309                paInts[i++] = pTimer->ulTimeout;
     310
     311                pNode = pNode->pNext;
     312            }
     313
     314            pSet->ulPMTimeout = mathGCDMulti(paInts,
     315                                             cTimers);
     316            _Pmpf(("--> GCD is %d", pSet->ulPMTimeout));
    278317        }
    279318
     
    518557 *      when the window is destroyed.
    519558 *
     559 *      Note: Unless you own the timer set that
     560 *      your timer runs on, it is strongly recommended
     561 *      that your timer frequency is set to a multiple
     562 *      of 125. The PM master timer behind the timer
     563 *      set will be set to the greatest common divisor
     564 *      of all frequencies, and if you set one timer
     565 *      to 2000 and the other one to 2001, you will
     566 *      cause quite a lot of overhead. This applies
     567 *      especially to timers started by XCenter widgets.
     568 *
     569 *      For security, all timer frequencies will be
     570 *      rounded to multiples of 25 anyway. Still,
     571 *      running two timers at 1000 and 1025 will cause
     572 *      the master timer to be set to 25, which is
     573 *      overkill.
     574 *
    520575 *@@changed V0.9.7 (2000-12-08) [umoeller]: got rid of dtGetULongTime
    521576 *@@changed V0.9.12 (2001-05-12) [umoeller]: added mutex protection
     577 *@@changed V0.9.14 (2001-07-12) [umoeller]: now rounding freq's to multiples of 25
    522578 */
    523579
     
    540596            {
    541597                PXTIMER pTimer;
     598
     599                // fix the timeout... we allow only multiples of
     600                // 20, and it must be at least 20 (otherwise our
     601                // internal master timer calculations will fail)
     602                // V0.9.14 (2001-07-07) [umoeller]
     603                if (ulTimeout < 25)
     604                    ulTimeout = 25;
     605                else
     606                    ulTimeout = (ulTimeout + 10) / 25 * 25;
    542607
    543608                // check if this timer exists already
  • trunk/src/helpers/tree.c

    r85 r86  
    883883 *@@ treeFind:
    884884 *      finds the tree node with the specified key.
     885 *      Returns NULL if none exists.
    885886 */
    886887
  • trunk/src/helpers/xstring.c

    r74 r86  
    705705 *      "cReplaceWithLen" characters from pcszReplaceWith.
    706706 *
     707 *      If cReplaceWithLen is 0, characters are removed only.
     708 *
    707709 *      Returns the new length of the string, excluding
    708710 *      the null terminator, or 0 if the replacement failed
     
    739741 *@@changed V0.9.9 (2001-03-09) [umoeller]: now using xstrReserve
    740742 *@@changed V0.9.11 (2001-04-22) [umoeller]: replaced replacement XSTRING with PCSZ
     743 *@@changed V0.9.14 (2001-07-07) [umoeller]: this did nothing if cReplaceWithLen == 0, fixed
    741744 */
    742745
     
    753756    if (    (pxstr)         // V0.9.9 (2001-02-14) [umoeller]
    754757         && (ulFirstReplOfs + cReplLen <= pxstr->ulLength)
    755          && (pcszReplaceWith)
     758         && (    (pcszReplaceWith)
     759              || (cReplaceWithLen == 0)     // fixed V0.9.14 (2001-07-07) [umoeller]
     760            )
    756761       )
    757762    {
Note: See TracChangeset for help on using the changeset viewer.