thread-os2.cpp revision 71955773a7f477f9a159a491f765ba97e1f00e1a
/* $Id$ */
/** @file
* IPRT - Threads, OS/2.
*/
/*
* Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP RTLOGGROUP_THREAD
#define INCL_BASE
#include <os2.h>
#include <errno.h>
#include <process.h>
#include <stdlib.h>
#include <signal.h>
#include <InnoTekLIBC/FastInfoBlocks.h>
#include <InnoTekLIBC/thread.h>
#include <iprt/asm-amd64-x86.h>
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** Pointer to thread local memory which points to the current thread. */
static PRTTHREADINT *g_ppCurThread;
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
static void rtThreadNativeMain(void *pvArgs);
DECLHIDDEN(int) rtThreadNativeInit(void)
{
/*
* Allocate thread local memory.
*/
if (rc)
return VERR_NO_TLS_FOR_SELF;
return VINF_SUCCESS;
}
static void rtThreadOs2BlockSigAlarm(void)
{
/*
* Block SIGALRM - required for timer-posix.cpp.
* This is done to limit harm done by OSes which doesn't do special SIGALRM scheduling.
* It will not help much if someone creates threads directly using pthread_create. :/
*/
}
DECLHIDDEN(void) rtThreadNativeReInitObtrusive(void)
{
}
{
*g_ppCurThread = pThread;
return VINF_SUCCESS;
}
{
if (pThread == *g_ppCurThread)
*g_ppCurThread = NULL;
}
/**
* Wrapper which unpacks the params and calls thread function.
*/
static void rtThreadNativeMain(void *pvArgs)
{
/*
* Call common main.
*/
*g_ppCurThread = pThread;
#ifdef fibGetTidPid
#else
#endif
*g_ppCurThread = NULL;
_endthread();
}
{
/*
* Default stack size.
*/
/*
* Create the thread.
*/
if (iThreadId > 0)
{
#ifdef fibGetTidPid
#else
#endif
return VINF_SUCCESS;
}
return RTErrConvertFromErrno(errno);
}
{
if (pThread)
/** @todo import alien threads? */
return NULL;
}
{
#ifdef fibGetTidPid
return fibGetTidPid();
#else
return _gettid();
#endif
}
{
return VINF_SUCCESS;
}
{
return VINF_SUCCESS;
}
RTDECL(bool) RTThreadYield(void)
{
DosSleep(0);
return fRc;
}
{
union
{
} u;
if (!rc)
{
return VINF_SUCCESS;
}
return RTErrConvertFromOS2(rc);
}
{
union
{
} u;
if (!rc)
return VINF_SUCCESS;
return RTErrConvertFromOS2(rc);
}
{
return __libc_TLSAlloc();
}
{
int rc;
int iTls = __libc_TLSAlloc();
if (iTls != -1)
{
if ( !pfnDestructor
{
return VINF_SUCCESS;
}
}
else
return rc;
}
{
return VINF_SUCCESS;
return VINF_SUCCESS;
return RTErrConvertFromErrno(errno);
}
{
return __libc_TLSGet(iTls);
}
{
int rc = VINF_SUCCESS;
if (RT_UNLIKELY(!pv))
{
errno = 0;
}
return rc;
}
{
return VINF_SUCCESS;
return RTErrConvertFromErrno(errno);
}
{
return VERR_NOT_IMPLEMENTED;
}