• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ LLBC_SetLastError函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中LLBC_SetLastError函数的典型用法代码示例。如果您正苦于以下问题:C++ LLBC_SetLastError函数的具体用法?C++ LLBC_SetLastError怎么用?C++ LLBC_SetLastError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了LLBC_SetLastError函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: LLBC_SetConsoleColor

int LLBC_SetConsoleColor(FILE *file, int color)
{
#if LLBC_TARGET_PLATFORM_NON_WIN32
    LLBC_SetLastError(LLBC_ERROR_NOT_IMPL);
    return LLBC_FAILED;
#else
    const int fileNo = LLBC_File::GetFileNo(file);
    if (UNLIKELY(fileNo == -1))
    {
        return LLBC_FAILED;
    }
    else if (UNLIKELY(fileNo != 1 && fileNo != 2))
    {
        LLBC_SetLastError(LLBC_ERROR_INVALID);
        return LLBC_FAILED;
    }

    LLBC_INTERNAL_NS __g_consoleLock[(fileNo == 1 || fileNo == 2 ? 0 : 1)].Lock();

    HANDLE handle = (fileNo == 1 ? 
        ::GetStdHandle(STD_OUTPUT_HANDLE) : GetStdHandle(STD_ERROR_HANDLE));
    if (::SetConsoleTextAttribute(handle, color) == 0)
    {
        LLBC_INTERNAL_NS __g_consoleLock[(fileNo == 1 || fileNo == 2 ? 0 : 1)].Unlock();
        LLBC_SetLastError(LLBC_ERROR_OSAPI);
        return LLBC_FAILED;
    }
    
    LLBC_INTERNAL_NS __g_consoleLock[(fileNo == 1 || fileNo == 2 ? 0 : 1)].Unlock();
    return LLBC_OK;
#endif
}
开发者ID:lailongwei,项目名称:llbc,代码行数:32,代码来源:OS_Console.cpp


示例2: LLBC_FlushFile

int LLBC_FlushFile(FILE *file)
{
    if (UNLIKELY(!file))
    {
        LLBC_SetLastError(LLBC_ERROR_INVALID);
        return LLBC_FAILED;
    }

#if LLBC_TARGET_PLATFORM_NON_WIN32
    flockfile(file);
    if (UNLIKELY(::fflush(file) != 0))
    {
        funlockfile(file);
        LLBC_SetLastError(LLBC_ERROR_CLIB);
        return LLBC_FAILED;
    }

    funlockfile(file);
    return LLBC_OK;
#else // Win32
    const int fileNo = LLBC_File::GetFileNo(file);
    LLBC_INTERNAL_NS __g_consoleLock[(fileNo == 1 || fileNo == 2 ? 0 : 1)].Lock();
    if (UNLIKELY(::fflush(file) != 0))
    {
        LLBC_INTERNAL_NS __g_consoleLock[(fileNo == 1 || fileNo == 2 ? 0 : 1)].Unlock();
        LLBC_SetLastError(LLBC_ERROR_CLIB);
        return LLBC_FAILED;
    }

    LLBC_INTERNAL_NS __g_consoleLock[(fileNo == 1 || fileNo == 2 ? 0 : 1)].Unlock();
    return LLBC_OK;
#endif
}
开发者ID:lailongwei,项目名称:llbc,代码行数:33,代码来源:OS_Console.cpp


示例3: LLBC_GetQueuedCompletionStatus

int LLBC_GetQueuedCompletionStatus(LLBC_IocpHandle handle,
                                   void *numOfBytes,
                                   void **compKey,
                                   LLBC_POverlapped *ol,
                                   ulong milliSeconds)
{
    BOOL ret = ::GetQueuedCompletionStatus(handle,
                                           (LPDWORD)numOfBytes,
                                           (PULONG_PTR)compKey,
                                           (LPOVERLAPPED *)ol,
                                           milliSeconds);
    if (ret == FALSE)
    {
        if (::GetLastError() == WAIT_TIMEOUT)
        {
            LLBC_SetLastError(LLBC_ERROR_TIMEOUT);
        }
        else
        {
            LLBC_SetLastError(LLBC_ERROR_OSAPI);
        }

        return LLBC_RTN_FAILED;
    }

    return LLBC_RTN_OK;
}
开发者ID:mr-kelly,项目名称:llbc,代码行数:27,代码来源:OS_Iocp.cpp


示例4: LLBC_GetProcAddress

LLBC_LibraryFun LLBC_GetProcAddress(LLBC_LibraryHandle handle, const char *procName)
{
#if LLBC_TARGET_PLATFORM_NON_WIN32
    // Clear any existing error.
    dlerror();

    void *proc = dlsym(handle, procName);
    if (dlerror() != NULL)
    {
        LLBC_SetLastError(LLBC_ERROR_INVALID);
        return NULL;
    }

    if (!proc)
    {
        LLBC_SetLastError(LLBC_ERROR_NOT_FOUND);
        return NULL;
    }

    return (LLBC_LibraryFun)proc;
#else // LLBC_TARGET_PLATFORM_NON_WIN32
    FARPROC proc = ::GetProcAddress(handle, procName);
    if (!proc)
    {
        LLBC_SetLastError(LLBC_ERROR_OSAPI);
    }

    return (LLBC_LibraryFun)proc;
#endif // LLBC_TARGET_PLATFORM_WIN32
}
开发者ID:lailongwei,项目名称:llbc,代码行数:30,代码来源:OS_Library.cpp


示例5: LLBC_SetLastError

LLBC_Array::Iter LLBC_Array::Insert(LLBC_Array::Iter n0, LLBC_Array::Obj *o)
{
    if (UNLIKELY(!o))
    {
        LLBC_SetLastError(LLBC_ERROR_ARG);
        return End();
    }
    if (!(n0 >= Begin() && n0 <= End()))
    {
        LLBC_SetLastError(LLBC_ERROR_ARG);
        return End();
    }

    if (_size == _capacity)
    {
        Recapacity(MAX(1, _size * 2));
    }

    LLBC_MemCpy(_objs + n0._idx + 1, 
        _objs + n0._idx, (_size - n0._idx) * sizeof(Obj *));

    _objs[n0._idx] = o;
    _objs[n0._idx]->Retain();

    _size += 1;

    return Iter(_objs, n0._idx);
}
开发者ID:lailongwei,项目名称:llbc,代码行数:28,代码来源:Array.cpp


示例6: LLBC_KillThread

int LLBC_KillThread(LLBC_NativeThreadHandle handle, int signo)
{
    if (handle == LLBC_INVALID_NATIVE_THREAD_HANDLE)
    {
        LLBC_SetLastError(LLBC_ERROR_ARG);
        return LLBC_FAILED;
    }

#if LLBC_TARGET_PLATFORM_NON_WIN32
    int status = 0;
    if ((status = pthread_kill(handle, signo)) != 0)
    {
        errno = status;
        LLBC_SetLastError(LLBC_ERROR_CLIB);
        return LLBC_FAILED;
    }
    
    return LLBC_OK;
#else
    if (raise(signo) != 0)
    {
        LLBC_SetLastError(LLBC_ERROR_CLIB);
        return LLBC_FAILED;
    }

    return LLBC_OK;
#endif
}
开发者ID:lailongwei,项目名称:llbc,代码行数:28,代码来源:OS_Thread.cpp


示例7: LLBC_LoadLibrary

__LLBC_NS_BEGIN

LLBC_LibraryHandle LLBC_LoadLibrary(const char *fileName)
{
    LLBC_LibraryHandle handle = LLBC_INVALID_LIBRARY_HANDLE;
#if LLBC_TARGET_PLATFORM_NON_WIN32
    if ((handle = dlopen(fileName, RTLD_LAZY)) == LLBC_INVALID_LIBRARY_HANDLE)
    {
        LLBC_SetLastError(LLBC_ERROR_UNKNOWN);
    }

    return handle;
#else // LLBC_TARGET_PLATFORM_WIN32
    // Note, WIN32 API ::GetProcAddress not support slashes(/), so replace it.
    LLBC_String libName(fileName);
    libName.findreplace(LLBC_SLASH_A, LLBC_BACKLASH_A);
    if (libName.empty())
        libName = LLBC_Directory::ModuleFileName();

    if ((handle = ::LoadLibraryExA(libName.c_str(), NULL, 0)) == LLBC_INVALID_LIBRARY_HANDLE)
        LLBC_SetLastError(LLBC_ERROR_OSAPI);

    return handle;
#endif // LLBC_TARGET_PLATFORM_NON_WIN32
}
开发者ID:lailongwei,项目名称:llbc,代码行数:25,代码来源:OS_Library.cpp


示例8: LLBC_TlsSetValue

int LLBC_TlsSetValue(LLBC_TlsHandle handle, void *value)
{
    if (handle == LLBC_INVALID_TLS_HANDLE)
    {
        LLBC_SetLastError(LLBC_ERROR_ARG);
        return LLBC_FAILED;
    }

#if LLBC_TARGET_PLATFORM_NON_WIN32 
    int status = pthread_setspecific(handle, value);
    if (status != 0)
    {
        errno = status;
        LLBC_SetLastError(LLBC_ERROR_CLIB);
        return LLBC_FAILED;
    }

    return LLBC_OK;
#else
    if (::TlsSetValue(handle, value) == 0)
    {
        LLBC_SetLastError(LLBC_ERROR_OSAPI);
        return LLBC_FAILED;
    }

    return LLBC_OK;
#endif
}
开发者ID:lailongwei,项目名称:llbc,代码行数:28,代码来源:OS_Thread.cpp


示例9: LLBC_JoinThread

int LLBC_JoinThread(LLBC_NativeThreadHandle handle)
{
    if (handle == LLBC_INVALID_NATIVE_THREAD_HANDLE)
    {
        LLBC_SetLastError(LLBC_ERROR_ARG);
        return LLBC_FAILED;
    }

#if LLBC_TARGET_PLATFORM_NON_WIN32
    int status = pthread_join(handle, NULL);
    if (status != 0)
    {
        errno = status;
        LLBC_SetLastError(LLBC_ERROR_CLIB);
        return LLBC_FAILED;
    }

    return LLBC_OK;
#else
    if (::WaitForSingleObject(handle, INFINITE) != WAIT_OBJECT_0)
    {
        LLBC_SetLastError(LLBC_ERROR_OSAPI);
        return LLBC_FAILED;
    }

    return LLBC_OK;
#endif
}
开发者ID:lailongwei,项目名称:llbc,代码行数:28,代码来源:OS_Thread.cpp


示例10: LLBC_CancelThread

int LLBC_CancelThread(LLBC_NativeThreadHandle handle)
{
    if (handle == LLBC_INVALID_NATIVE_THREAD_HANDLE)
    {
        LLBC_SetLastError(LLBC_ERROR_ARG);
        return LLBC_FAILED;
    }

#if LLBC_TARGET_PLATFORM_NON_WIN32
    int status = 0;
    if ((status = pthread_cancel(handle)) != 0)
    {
        errno = status;
        LLBC_SetLastError(LLBC_ERROR_CLIB);
        return LLBC_FAILED;
    }

    return LLBC_OK;
#else
    if (::TerminateThread(handle, 0) == 0)
    {
        LLBC_SetLastError(LLBC_ERROR_OSAPI);
        return LLBC_FAILED;
    }

    return LLBC_OK;
#endif
}
开发者ID:lailongwei,项目名称:llbc,代码行数:28,代码来源:OS_Thread.cpp


示例11: LLBC_SetLastError

int LLBC_Dictionary::Insert(const LLBC_String &key, LLBC_Dictionary::Obj *o)
{
    if (UNLIKELY(!o))
    {
        LLBC_SetLastError(LLBC_ERROR_INVALID);
        return LLBC_RTN_FAILED;
    }

    if (this->Find(key) != this->End())
    {
        LLBC_SetLastError(LLBC_ERROR_REPEAT);
        return LLBC_RTN_FAILED;
    }

    // Check bucket size and auto expand it.
    if (_size >= _bucketSize * 100)
    {
        this->SetHashBucketSize(_bucketSize * 2);
    }

    LLBC_DictionaryElem *elem = new LLBC_DictionaryElem(key, o);

    // Hash to bucket.
    elem->Hash(_bucket, _bucketSize);
    // Link to doubly-linked list.
    this->AddToDoublyLinkedList(elem);

    _size += 1;

    return LLBC_RTN_OK;
}
开发者ID:mr-kelly,项目名称:llbc,代码行数:31,代码来源:Dictionary.cpp


示例12: LLBC_SetLastError

int LLBC_ThreadManager::SetPriority(LLBC_Handle handle, int priority)
{
    if (UNLIKELY(handle == LLBC_INVALID_HANDLE))
    {
        LLBC_SetLastError(LLBC_ERROR_ARG);
        return LLBC_FAILED;
    }

    LLBC_Guard guard(_lock);

    LLBC_ThreadDescriptor *threadDesc = FindThreadDescriptor(handle);
    if (!threadDesc)
    {
        LLBC_SetLastError(LLBC_ERROR_NOT_FOUND);
        return LLBC_FAILED;
    }

    if (threadDesc->GetPriority() == priority)
    {
        return LLBC_OK;
    }

    int rtn = LLBC_SetThreadPriority(threadDesc->GetNativeHandle(), priority);
    if (rtn == LLBC_OK)
    {
        threadDesc->SetPriority(priority);
    }

    return rtn;
}
开发者ID:lailongwei,项目名称:llbc,代码行数:30,代码来源:ThreadManager.cpp


示例13: LLBC_TlsAlloc

int LLBC_TlsAlloc(LLBC_TlsHandle *handle)
{
    if (!handle)
    {
        LLBC_SetLastError(LLBC_ERROR_ARG);
        return LLBC_FAILED;
    }

#if LLBC_TARGET_PLATFORM_NON_WIN32
    int status = pthread_key_create(handle, NULL);
    if (status != 0)
    {
        errno = status;
        LLBC_SetLastError(LLBC_ERROR_CLIB);
        return LLBC_FAILED;
    }
    
    return LLBC_OK;
#else
    if ((*handle = ::TlsAlloc()) == TLS_OUT_OF_INDEXES)
    {
        LLBC_SetLastError(LLBC_ERROR_OSAPI);
        return LLBC_FAILED;
    }

    return LLBC_OK;
#endif
}
开发者ID:lailongwei,项目名称:llbc,代码行数:28,代码来源:OS_Thread.cpp


示例14: LLBC_SetThreadPriority

int LLBC_SetThreadPriority(LLBC_NativeThreadHandle handle, int priority)
{
    if (handle == LLBC_INVALID_NATIVE_THREAD_HANDLE || 
        (priority < LLBC_ThreadPriority::Begin || priority >= LLBC_ThreadPriority::End))
    {
        LLBC_SetLastError(LLBC_ERROR_ARG);
        return LLBC_FAILED;
    }

#if LLBC_TARGET_PLATFORM_NON_WIN32
    int status = 0;
    int policy = 0;
    int priorityMin = 0;
    int priorityMax = 0;
    struct sched_param schedParam;
    if ((status = pthread_getschedparam(handle, &policy, &schedParam)) != 0)
    {
        errno = status;
        LLBC_SetLastError(LLBC_ERROR_CLIB);
        return LLBC_FAILED;
    }

    priorityMin = sched_get_priority_min(policy);
    priorityMax = sched_get_priority_max(policy);

 #if LLBC_TARGET_PLATFORM_LINUX
    schedParam.sched_priority = 
        LLBC_INTERNAL_NS __LLBCPriority2LinuxPriority(priority, priorityMin, priorityMax);
 #elif LLBC_TARGET_PLATFORM_IPHONE
    schedParam.sched_priority = 
        LLBC_INTERNAL_NS __LLBCPriority2IphonePriority(priority, priorityMin, priorityMax);
 #elif LLBC_TARGET_PLATFORM_MAC
    schedParam.sched_priority = 
        LLBC_INTERNAL_NS __LLBCPriority2MacPriority(priority, priorityMin, priorityMax);
 #elif LLBC_TARGET_PLATFORM_ANDROID
    schedParam.sched_priority = 
        LLBC_INTERNAL_NS __LLBCPriority2AndroidPriority(priority, priorityMin, priorityMax);
 #endif

    if ((status = pthread_setschedparam(handle, policy, &schedParam)) != 0)
    {
        errno = status;
        LLBC_SetLastError(LLBC_ERROR_CLIB);
        return LLBC_FAILED;
    }

    return LLBC_OK;
#else
    BOOL ret = ::SetThreadPriority(handle, LLBC_INTERNAL_NS __LLBCPriority2WinPriority(priority));
    if (ret == FALSE)
    {
        LLBC_SetLastError(LLBC_ERROR_OSAPI);
        return LLBC_FAILED;
    }

    return LLBC_OK;
#endif
}
开发者ID:lailongwei,项目名称:llbc,代码行数:58,代码来源:OS_Thread.cpp


示例15: LLBC_GetLastError

void LLBC_ConditionVariable::AfterWait(LLBC_ILock &lock)
{
    int errNo = LLBC_GetLastError();
    int subErrNo = LLBC_GetSubErrorNo();

    int signalsWasLeft = 0;

    ::EnterCriticalSection(&_cond.unblockLock);

    if ((signalsWasLeft = _cond.waitersToUnblock) != 0)
    {
        -- _cond.waitersToUnblock;
    }
    else if (_cond.waitersBlocked == ++ _cond.waitersGone)
    {
        ::WaitForSingleObject(_cond.blockLock, INFINITE);
        _cond.waitersBlocked -= _cond.waitersGone;
        ::ReleaseSemaphore(_cond.blockLock, 1, NULL);

        _cond.waitersGone = 0;
    }

    ::LeaveCriticalSection(&_cond.unblockLock);

    if (signalsWasLeft == 1)
    {
        ::ReleaseSemaphore(_cond.blockLock, 1, NULL);
    }

    lock.Lock();

    LLBC_SetLastError(errNo);
    LLBC_SetSubErrorNo(subErrNo);
}
开发者ID:lailongwei,项目名称:llbc,代码行数:34,代码来源:ConditionVariable.cpp


示例16: LLBC_GetTemporaryDirectory

LLBC_String LLBC_GetTemporaryDirectory(bool appendSlash)
{
 #if LLBC_TARGET_PLATFORM_NON_WIN32
    if (appendSlash)
    {
        return "/tmp/";
    }
    else
    {
        return "/tmp";
    }
 #else
    DWORD bufLen = 0;
    bufLen = ::GetTempPathA(0, NULL);
    bufLen += 1;

    LPSTR buf = reinterpret_cast<LPSTR>(::malloc(sizeof(CHAR) * bufLen));
    if (::GetTempPathA(bufLen, buf) == 0)
    {
        LLBC_SetLastError(LLBC_ERROR_OSAPI);
        ::free(buf);
        return "";
    }

    LLBC_String path = buf;
    ::free(buf);
    
    if (!appendSlash)
    {
        path = path.substr(0, path.size() - 1);
    }
    
    return path;
 #endif
}
开发者ID:mr-kelly,项目名称:llbc,代码行数:35,代码来源:OS_Directory_NonIphone.cpp


示例17: LLBC_GetCacheDirectory

LLBC_String LLBC_GetCacheDirectory(bool appendSlash)
{
 #if LLBC_TARGET_PLATFORM_NON_WIN32
    if (appendSlash)
    {
        return "/tmp/";
    }
    else
    {
        return "/tmp";
    }
 #else
    CHAR buf[MAX_PATH];
    memset(buf, 0, sizeof(CHAR) * MAX_PATH);
    if (::SHGetSpecialFolderPathA(NULL, buf, CSIDL_INTERNET_CACHE, FALSE) == FALSE)
    {
        LLBC_SetLastError(LLBC_ERROR_OSAPI);
        return "";
    }
    
    LLBC_String path = buf;
    if (appendSlash)
    {
        path.append(1, LLBC_BACKLASH_A);
    }

    return path;
 #endif
}
开发者ID:mr-kelly,项目名称:llbc,代码行数:29,代码来源:OS_Directory_NonIphone.cpp


示例18: LLBC_SetLastError

LLBC_String LLBC_Directory::TempDir()
{
#if LLBC_TARGET_PLATFORM_NON_WIN32
    return "/tmp";
#else // Win32
    DWORD bufLen = 0;
    bufLen = ::GetTempPathA(0, NULL);
    bufLen += 1;

    LPSTR buf = reinterpret_cast<LPSTR>(::malloc(sizeof(CHAR) * bufLen));
    if (::GetTempPathA(bufLen, buf) == 0)
    {
        LLBC_SetLastError(LLBC_ERROR_OSAPI);
        ::free(buf);
        return "";
    }

    LLBC_String path = buf;
    ::free(buf);

    if (path[path.length() - 1] == LLBC_BACKLASH_A)
        return path.substr(0, path.length() - 1);
    
    return path;
#endif // Non-Win32
}
开发者ID:lailongwei,项目名称:llbc,代码行数:26,代码来源:Directory_NonIphone.cpp


示例19: LLBC_SetLastError

int LLBC_IocpPoller::Start()
{
    if (_started)
    {
        LLBC_SetLastError(LLBC_ERROR_REENTRY);
        return LLBC_FAILED;
    }

    if ((_iocp = LLBC_CreateIocp()) == LLBC_INVALID_IOCP_HANDLE)
        return LLBC_FAILED;

    if (StartupMonitor() != LLBC_OK)
    {
        LLBC_CloseIocp(_iocp);
        _iocp = LLBC_INVALID_IOCP_HANDLE;

        return LLBC_FAILED;
    }

    if (Activate() != LLBC_OK)
    {
        StopMonitor();

        LLBC_CloseIocp(_iocp);
        _iocp = LLBC_INVALID_IOCP_HANDLE;

        return LLBC_FAILED;
    }

    _started = true;
    return LLBC_OK;
}
开发者ID:lailongwei,项目名称:llbc,代码行数:32,代码来源:IocpPoller.cpp


示例20: LLBC_GetHomeDirectory

__LLBC_NS_BEGIN

LLBC_String LLBC_GetHomeDirectory(bool appendSlash)
{
#if LLBC_TARGET_PLATFORM_NON_WIN32
    char *valStr = getenv("HOME");
#else
    char *valStr = getenv("HOMEPATH");
#endif
    if (!valStr)
    {
        LLBC_SetLastError(LLBC_ERROR_CLIB);
        return "";
    }
    
    LLBC_String path = valStr;
    if (appendSlash)
    {
#if LLBC_TARGET_PLATFORM_NON_WIN32
    path.append(1, LLBC_SLASH_A);
#else
    path.append(1, LLBC_BACKLASH_A);
#endif
    }

    return path;
}
开发者ID:mr-kelly,项目名称:llbc,代码行数:27,代码来源:OS_Directory_NonIphone.cpp



注:本文中的LLBC_SetLastError函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ LLColor3函数代码示例发布时间:2022-05-30
下一篇:
C++ LLADDR函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap