本文整理汇总了C++中LLBC_SetLastError函数的典型用法代码示例。如果您正苦于以下问题:C++ LLBC_SetLastError函数的具体用法?C++ LLBC_SetLastError怎么用?C++ LLBC_SetLastError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LLBC_SetLastError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
示例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
}
示例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;
}
示例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
}
示例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);
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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;
}
示例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;
}
示例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
}
示例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
}
示例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);
}