亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? mlock.c

?? C語言庫函數的原型,有用的拿去
?? C
字號:
/***
*mlock.c - Multi-thread locking routines
*
*       Copyright (c) Microsoft Corporation. All rights reserved.
*
*Purpose:
*
*******************************************************************************/

#include <cruntime.h>
#include <oscalls.h>
#include <internal.h>
#include <mtdll.h>
#include <rterr.h>
#include <stddef.h>
#include <malloc.h>
#include <limits.h>
#include <stdio.h>
#include <dbgint.h>
#include <errno.h>
#include <winheap.h>


/*
 * Local routines
 */
void __cdecl _lockerr_exit(char *);


/*
 * Global Data
 */

/*
 * Statically allocated critical section structures for all preallocated locks.
 * These are most of the named locks before _STREAM_LOCKS, along with the locks
 * for stdin/stdout/stderr.  These must be preallocated so we do not hit fatal
 * memory conditions on failing to initialize a critical section, except at
 * runtime startup, since these locks may be taken where we have no good way
 * to return a non-fatal error.
 */
#define NUM_STD_FILE_LOCKS     3

/*
 *  _DEBUG_LOCK is preallocated in _DEBUG & not in Retail
 */

#ifdef _DEBUG
#define NUM_NON_PREALLOC_LOCKS 4
#else  /* _DEBUG */
#define NUM_NON_PREALLOC_LOCKS 5
#endif  /* _DEBUG */

#define NUM_PREALLOC_LOCKS \
        ( _STREAM_LOCKS + NUM_STD_FILE_LOCKS - NUM_NON_PREALLOC_LOCKS )
static CRITICAL_SECTION lclcritsects[NUM_PREALLOC_LOCKS];

/*
 * Lock Table
 * This table contains a pointer to the critical section management structure
 * for each lock.
 *
 * Locks marked lkPrealloc have their critical sections statically allocated
 * and initialized at startup in _mtinitlocks.  Locks marked lkNormal must
 * be allocated when first used, via a call to _mtinitlocknum.
 */
static struct {
        PCRITICAL_SECTION lock;
        enum { lkNormal = 0, lkPrealloc, lkDeleted } kind;
} _locktable[_TOTAL_LOCKS] = {
        { NULL, lkPrealloc }, /* 0  == _SIGNAL_LOCK      */
        { NULL, lkPrealloc }, /* 1  == _IOB_SCAN_LOCK    */
        { NULL, lkNormal   }, /* 2  == _TMPNAM_LOCK      - not preallocated */
        { NULL, lkPrealloc }, /* 3  == _CONIO_LOCK       */
        { NULL, lkPrealloc }, /* 4  == _HEAP_LOCK        */
        { NULL, lkNormal   }, /* 5  == _UNDNAME_LOCK     - not preallocated */
        { NULL, lkPrealloc }, /* 6  == _TIME_LOCK        */
        { NULL, lkPrealloc }, /* 7  == _ENV_LOCK         */
        { NULL, lkPrealloc }, /* 8  == _EXIT_LOCK1       */
        { NULL, lkNormal   }, /* 9  == _POPEN_LOCK       - not preallocated */
        { NULL, lkPrealloc }, /* 10 == _LOCKTAB_LOCK     */
        { NULL, lkNormal   }, /* 11 == _OSFHND_LOCK      - not preallocated */
        { NULL, lkPrealloc }, /* 12 == _SETLOCALE_LOCK   */
        { NULL, lkPrealloc }, /* 13 == _MB_CP_LOCK       */
        { NULL, lkPrealloc }, /* 14 == _TYPEINFO_LOCK    */
#ifdef _DEBUG
        { NULL, lkPrealloc }, /* 15 == _DEBUG_LOCK       */
#else  /* _DEBUG */
        { NULL, lkNormal },   /* 15 == _DEBUG_LOCK       */
#endif  /* _DEBUG */

        { NULL, lkPrealloc }, /* 16 == _STREAM_LOCKS+0 - stdin  */
        { NULL, lkPrealloc }, /* 17 == _STREAM_LOCKS+1 - stdout */
        { NULL, lkPrealloc }, /* 18 == _STREAM_LOCKS+2 - stderr */
/*      { NULL, lkNormal   }, /* ... */
};

#ifdef _M_IX86
#pragma optimize("y",off)
#endif  /* _M_IX86 */

/***
*_mtinitlocks() - Initialize multi-thread lock scheme
*
*Purpose:
*       Perform whatever initialization is required for the multi-thread
*       locking (synchronization) scheme. This routine should be called
*       exactly once, during startup, and this must be before any requests
*       are made to assert locks.
*
*       NOTES: In Win32, the multi-thread locks are created individually,
*       each upon its first use. That is when any particular lock is asserted
*       for the first time, the underlying critical section is then allocated,
*       initialized and (finally) entered. This allocation and initialization
*       is protected under _LOCKTAB_LOCK. It is _mtinitlocks' job to set up
*       _LOCKTAB_LOCK.
*
*       All other named (non-FILE) locks are also preallocated in _mtinitlocks.
*       That is because a failure to allocate a lock on its first use in _lock
*       triggers a fatal error, which cannot be permitted since that can bring
*       down a long-lived app without warning.
*
*Entry:
*       <none>
*
*Exit:
*       returns FALSE on failure
*
*Exceptions:
*
*******************************************************************************/

int __cdecl _mtinitlocks (
        void
        )
{
        int locknum;
        int idxPrealloc = 0;

        /*
         * Scan _locktable[] and allocate all entries marked lkPrealloc.
         */
        for ( locknum = 0 ; locknum < _TOTAL_LOCKS ; locknum++ ) {
            if ( _locktable[locknum].kind == lkPrealloc ) {
                _locktable[locknum].lock = &lclcritsects[idxPrealloc++];
                if ( !InitializeCriticalSectionAndSpinCount( _locktable[locknum].lock,
                                                             _CRT_SPINCOUNT ))
                {
                    _locktable[locknum].lock = NULL;
                    return FALSE;
                }
            }
        }


        return TRUE;
}


/***
*_mtdeletelocks() - Delete all initialized locks
*
*Purpose:
*       Walks _locktable[] and _lockmap, and deletes every 'lock' (i.e.,
*       critical section) which has been initialized.
*
*       This function is intended for use in DLLs containing the C runtime
*       (i.e., crtdll.dll and user DLLs built using libcmt.lib and the
*       special startup objects). It is to be called from within the DLL's
*       entrypoint function when that function is called with
*       DLL_PROCESS_DETACH.
*
*Entry:
*       <none>
*
*Exit:
*
*Exceptions:
*       behavior undefined/unknown if a lock is being held when this routine
*       is called.
*
*******************************************************************************/

void __cdecl _mtdeletelocks(
        void
        )
{
        int locknum;

        /*
         * Delete and free all normal locks that have been created.
         */
        for ( locknum = 0 ; locknum < _TOTAL_LOCKS ; locknum++ ) {
            if ( _locktable[locknum].lock != NULL &&
                 _locktable[locknum].kind != lkPrealloc )
            {
                PCRITICAL_SECTION pcs = _locktable[locknum].lock;

                DeleteCriticalSection(pcs);

                /*
                 * Free the memory for the CritSect after deleting it.
                 */

                _free_crt(pcs);
                _locktable[locknum].lock = NULL;
            }
        }

        /*
         * Delete all preallocated locks after all normal ones are
         * freed (so preallocated _HEAP_LOCK outlives all heap usages).
         */
        for ( locknum = 0 ; locknum < _TOTAL_LOCKS ; locknum++ ) {
            if ( _locktable[locknum].lock != NULL &&
                 _locktable[locknum].kind == lkPrealloc )
            {
                PCRITICAL_SECTION pcs = _locktable[locknum].lock;

                DeleteCriticalSection(pcs);
            }
        }
}

/***
* _mtinitlocknum - Allocate a non-preallocated multi-thread lock
*
*Purpose:
*       Allocate a new, non-preallocated multi-thread lock.  This should be
*       used whenever a new lock is known to be needed, so that failure to
*       allocate can return an error, instead of allowing _lock() to issue
*       a fatal _RT_LOCK instead.
*
*       It is not an error to call this on a normal lock which has already
*       been allocated.  It is used to ensure that certain named locks which
*       are not preallocated are available.
*
*       It is also called by _lock, in case any other paths exist which call
*       _lock without calling _mtinitlocknum first.  This is not expected,
*       and can allow fatal _RT_LOCK errors to be issued.
*
*       Since a failure sets errno to ENOMEM, this should only be called
*       after the per-thread data has been set up (after _mtinit).
*
*Entry:
*       locknum = number of the lock to aquire
*
*Exit:
*       Returns FALSE on failure, and sets errno to ENOMEM.
*
*Exceptions:
*
*******************************************************************************/

int __cdecl _mtinitlocknum (
        int locknum
        )
{
        PCRITICAL_SECTION pcs;
        int retval=TRUE;

        /*
         * Check if CRT is initialized. The check if _crtheap is initialized
         * will do the job. More over we had to add this test in initlocks because
         * in debug version we don't endup calling lock before calling malloc_base,
         * where we check for crtheap.
         */
        if (_crtheap == 0) {
            _FF_MSGBANNER();    /* write run-time error banner */
            _NMSG_WRITE(_RT_CRT_NOTINIT);  /* write message */
            __crtExitProcess(255);  /* normally _exit(255) */
        }


        if ( _locktable[locknum].lock != NULL )
            return TRUE;

        if ( (pcs = _malloc_crt(sizeof(CRITICAL_SECTION))) == NULL ) {
            errno = ENOMEM;
            return FALSE;
        }

        _mlock(_LOCKTAB_LOCK);
        __TRY

            if ( _locktable[locknum].lock == NULL ) {
                if ( !InitializeCriticalSectionAndSpinCount(pcs, _CRT_SPINCOUNT) ) {
                    _free_crt(pcs);
                    errno = ENOMEM;
                    retval=FALSE;
                } else {
                    _locktable[locknum].lock = pcs;
                }
            }
            else {
                _free_crt(pcs);
            }

        __FINALLY
            _munlock(_LOCKTAB_LOCK);
        __END_TRY_FINALLY

        return retval;
}


/***
* _lock - Acquire a multi-thread lock
*
*Purpose:
*       Acquire a multi-thread lock.  If the lock has not already been
*       allocated, do so, but that is an internal CRT error, since all locks
*       should be allocated before first being acquired, either in
*       _mtinitlocks or individually in _mtinitlocknum.
*
*       Note that it is legal for a thread to aquire _EXIT_LOCK1
*       multiple times.
*
*Entry:
*       locknum = number of the lock to aquire
*
*Exit:
*
*Exceptions:
*       A failure to allocate a new lock results in a fatal _RT_LOCK error.
*
*******************************************************************************/

void __cdecl _lock (
        int locknum
        )
{

        /*
         * Create/open the lock, if necessary
         */
        if ( _locktable[locknum].lock == NULL ) {

            if ( !_mtinitlocknum(locknum) )
                _amsg_exit( _RT_LOCK );
        }

        /*
         * Enter the critical section.
         */

        EnterCriticalSection( _locktable[locknum].lock );
}


/***
* _unlock - Release multi-thread lock
*
*Purpose:
*       Note that it is legal for a thread to aquire _EXIT_LOCK1
*       multiple times.
*
*Entry:
*       locknum = number of the lock to release
*
*Exit:
*
*Exceptions:
*
*******************************************************************************/

void __cdecl _unlock (
        int locknum
        )
{
        /*
         * leave the critical section.
         */
        LeaveCriticalSection( _locktable[locknum].lock );
}


#ifdef _M_IX86
#pragma optimize("y",on)
#endif  /* _M_IX86 */

/***
*_lockerr_exit() - Write error message and die
*
*Purpose:
*       Attempt to write out the unexpected lock error message, then terminate
*       the program by a direct API call.  This function is used in place of
*       amsg_exit(_RT_LOCK) when it is judged unsafe to allow further lock
*       or unlock calls.
*
*Entry:
*
*Exit:
*
*Exceptions:
*
*******************************************************************************/

void __cdecl _lockerr_exit (
        char *msg
        )
{
        FatalAppExit(0, msg);       /* Die with message box */
        __crtExitProcess(255);      /* Just die */
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧美一区二区三区孕妇| 亚洲国产精品一区二区尤物区| 久久9热精品视频| 欧美一区二区视频观看视频| 天堂成人免费av电影一区| 欧美色精品在线视频| 免费人成黄页网站在线一区二区| 欧美日韩一区二区在线观看| 日韩**一区毛片| 日韩码欧中文字| 久久久精品一品道一区| 精品一二三四区| 国产精品久久久久aaaa樱花 | 国产成人av电影| 亚洲视频资源在线| 精品国产一区二区三区久久久蜜月| 国产精品99久| 老司机精品视频一区二区三区| 国产亚洲欧美日韩在线一区| 在线观看欧美黄色| 91在线精品一区二区三区| 日本午夜一本久久久综合| 精品国产91久久久久久久妲己| 91在线云播放| 国产成人自拍高清视频在线免费播放| 亚洲资源中文字幕| 国产精品视频一二三| 精品国产一区二区亚洲人成毛片| 在线免费av一区| 色吧成人激情小说| 一本色道**综合亚洲精品蜜桃冫 | 五月天激情综合| 一区二区三区加勒比av| 中文字幕永久在线不卡| 精品电影一区二区| 精品国产一区二区三区av性色| 91福利资源站| 欧美精品高清视频| 日韩丝袜美女视频| 久久综合一区二区| 日韩精品久久久久久| 久久久国际精品| 中文字幕av在线一区二区三区| 日韩女优电影在线观看| 2020国产精品| 最新日韩在线视频| 亚洲韩国精品一区| 加勒比av一区二区| 99久久久精品| 欧美一二三在线| 亚洲国产成人私人影院tom| 亚洲人成7777| 亚洲超碰精品一区二区| 国产伦精品一区二区三区免费 | 国产欧美一二三区| 136国产福利精品导航| 一区二区三区国产豹纹内裤在线| 亚洲图片欧美色图| av一区二区三区四区| 欧美一区二区三区在线看| 中文字幕成人在线观看| 天天综合天天综合色| 国产91精品一区二区麻豆亚洲| 日本高清不卡一区| 最近中文字幕一区二区三区| 另类小说视频一区二区| 欧美日韩精品二区第二页| 中文av一区特黄| 国产**成人网毛片九色 | 欧美日韩免费不卡视频一区二区三区| 久久精品视频在线看| 激情都市一区二区| 欧美videofree性高清杂交| 国产亚洲人成网站| 国产传媒久久文化传媒| 久久女同精品一区二区| 国产精品一区二区久久不卡| 日韩精品一区二区三区在线观看| 中文字幕一区二区三区在线观看| 国产剧情av麻豆香蕉精品| xnxx国产精品| 成人激情电影免费在线观看| 久久天堂av综合合色蜜桃网| 国产在线观看一区二区| 精品盗摄一区二区三区| 99国产欧美另类久久久精品| 欧美国产一区在线| 欧美三级日本三级少妇99| 亚洲777理论| 精品国产三级a在线观看| 国产电影精品久久禁18| 中文字幕日韩精品一区 | 欧美自拍偷拍一区| 久久精品免费观看| 亚洲欧美日韩中文播放| 91精品中文字幕一区二区三区| 男女男精品视频网| 亚洲美女电影在线| 欧美成人精品3d动漫h| 99r国产精品| 国产精品自拍av| 日本不卡不码高清免费观看| 精品国产91亚洲一区二区三区婷婷| 国产一区二区三区视频在线播放| 国产精品久久看| 91黄色免费观看| 波多野结衣一区二区三区| 日本亚洲最大的色成网站www| 国产精品日产欧美久久久久| 欧美日韩中文字幕一区| 丝袜脚交一区二区| 欧美视频你懂的| 在线观看三级视频欧美| 国产a级毛片一区| 国产精一区二区三区| 日韩精品乱码免费| 午夜精品久久久久久久久| 亚洲精品成人在线| 亚洲欧洲精品天堂一级| 亚洲国产精品ⅴa在线观看| 精品国免费一区二区三区| 日本韩国一区二区| 欧美精品xxxxbbbb| 制服丝袜av成人在线看| 欧美人动与zoxxxx乱| 3751色影院一区二区三区| 欧美日韩一区二区三区四区五区 | 精品国产在天天线2019| 久久影院电视剧免费观看| 久久久综合九色合综国产精品| 2020国产精品| 亚洲视频每日更新| 午夜视频一区二区| 国产麻豆91精品| 91美女蜜桃在线| 精品日韩一区二区| 亚洲精品亚洲人成人网在线播放| 五月婷婷综合网| www.欧美日韩| 26uuu久久综合| 久久久综合精品| 日韩一级在线观看| 亚洲欧美日韩小说| 麻豆国产91在线播放| 99久久国产综合精品麻豆| 日韩一区二区三区免费看| 国产精品色哟哟网站| 日韩电影一区二区三区| 91色视频在线| 国产精品电影一区二区三区| 日韩电影网1区2区| 欧美一区二区三区在线观看| 国产精品久久久久毛片软件| 黄色精品一二区| 日韩视频一区二区三区| 三级欧美韩日大片在线看| 色8久久人人97超碰香蕉987| 久久亚洲欧美国产精品乐播| 日本系列欧美系列| 日韩欧美一区二区视频| 男女男精品视频| 日韩女优电影在线观看| 免费欧美在线视频| 欧美成人精品福利| 韩国v欧美v日本v亚洲v| 久久嫩草精品久久久精品一| 国产精品一二三四区| 国产精品热久久久久夜色精品三区| 国产一区二区在线观看免费| 精品sm捆绑视频| av电影天堂一区二区在线观看| 亚洲免费观看高清在线观看| 99久久综合色| 紧缚奴在线一区二区三区| 91福利国产成人精品照片| 天天综合网天天综合色| 欧美精品一区二区三区蜜桃视频| 亚洲图片一区二区| 久久影院视频免费| 色哟哟国产精品免费观看| 奇米777欧美一区二区| 久久久精品欧美丰满| 欧美三级电影网站| 成人一二三区视频| 亚洲综合在线观看视频| 久久久九九九九| 91精品国产欧美一区二区成人 | 久久久久一区二区三区四区| caoporn国产一区二区| 九九**精品视频免费播放| 一区二区三区视频在线看| 久久九九国产精品| 欧美成人在线直播| 欧美草草影院在线视频| 欧美亚洲动漫精品| 在线视频国产一区| 99久久国产综合色|国产精品| 国产一区二区三区精品视频| 紧缚捆绑精品一区二区| 日韩国产精品91|