📄 tls.c
字号:
/**************************************************************************
* Name : services_calls.c
* Author : BCB
* Created : 11/08/2003
*
* Copyright : 2003-2004 by Imagination Technologies Limited. All rights reserved.
* : No part of this software, either material or conceptual
* : may be copied or distributed, transmitted, transcribed,
* : stored in a retrieval system or translated into any
* : human or computer language in any form by any means,
* : electronic, mechanical, manual or other-wise, or
* : disclosed to third parties without the express written
* : permission of Imagination Technologies Limited, Unit 8, HomePark
* : Industrial Estate, King's Langley, Hertfordshire,
* : WD4 8LZ, U.K.
*
* Platform : ANSI
*
* $Date: 2004/07/20 11:07:26 $ $Revision: 1.6 $
* $Log: tls.c $
*
***************************************************************************/
#define MODULE_ID MODID_TLS
#include "ogles_types.h"
#include "servicesglue.h"
#include "ws.h"
#include "wsglue.h"
#include "osglue.h"
#include "tls.h"
#include "debug.h"
#include "modid.h"
/*----------------------------------------------------------------------------*/
/* Functions for use by EGL only */
/* TODO: Consider moving EGL functions to a separate file */
/***********************************************************************************
Function Name : EGLGetTLSValue
Inputs : -
Outputs : -
Returns : The TLS value
Description : Retrieves EGL's thread local storage value
************************************************************************************/
IMG_VOID* EGLGetTLSValue(IMG_VOID)
{
return ENV_GetTLSValue(TLS_ID_EGL);
}
/******************************************************************************
Function Name : EGLGetTLSValue
Inputs : pvA - The value to set
Outputs : -
Returns : -
Description : Sets EGL's thread local storage value
******************************************************************************/
IMG_BOOL
EGLSetTLSValue(IMG_VOID *pvA)
{
return ENV_SetTLSValue(TLS_ID_EGL, pvA);
}
/***************************************************************************
*
* FUNCTION : tls_alloc ()
* PURPOSE : Create and initialise our thread local storage.
* PARAMETERS : None
* RETURNS : Pointer to thread local storage state structure.
*
***************************************************************************/
static struct tls_tag *tls_alloc (void)
{
return (GLESCalloc (0,sizeof (struct tls_tag)));
}
/***************************************************************************
*
* FUNCTION : TLS_Open ()
* PURPOSE : todo
* PARAMETERS : None.
* RETURNS : Pointer to this threads local storage structure.
*
***************************************************************************/
TLS
TLS_Open (EGLBoolean (*init) (TLS tls))
{
TLS tls;
DPF ((DBG_MESSAGE, "TLS_Open()"));
tls = (TLS)EGLGetTLSValue();
if (tls!=IMG_NULL)
{
tls->count++;
}
else
{
tls = tls_alloc ();
if (tls!=IMG_NULL)
{
if (!init (tls))
{
GLESFree (0,tls);
return IMG_NULL;
}
}
EGLSetTLSValue (tls);
}
return tls;
}
/****************************************************************************
*
* FUNCTION : TLS_Close ()
* PURPOSE : Close the thread local storage, when all openers have closed,
* thread local storage is deallocated.
* PARAMETERS : None.
* RETURNS : Pointer to this threads local storage structure.
*
***************************************************************************/
IMG_VOID TLS_Close (void)
{
TLS tls = (TLS)EGLGetTLSValue();
if (tls!=IMG_NULL)
{
tls->count--;
if (tls->count==0)
{
EGLSetTLSValue(IMG_NULL);
GLESFree (0,tls->dpys);
GLESFree (0,tls);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -