Release 6.1.7
This commit is contained in:
94
utility/rtos_compatibility_layers/posix/px_pth_self.c
Normal file
94
utility/rtos_compatibility_layers/posix/px_pth_self.c
Normal file
@@ -0,0 +1,94 @@
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* Copyright (c) Microsoft Corporation. All rights reserved. */
|
||||
/* */
|
||||
/* This software is licensed under the Microsoft Software License */
|
||||
/* Terms for Microsoft Azure RTOS. Full text of the license can be */
|
||||
/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
|
||||
/* and in the root directory of this software. */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** POSIX wrapper for THREADX */
|
||||
/** */
|
||||
/** */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
/* Include necessary system files. */
|
||||
|
||||
#include "tx_api.h" /* Threadx API */
|
||||
#include "pthread.h" /* Posix API */
|
||||
#include "px_int.h" /* Posix helper functions */
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* pthread_self PORTABLE C */
|
||||
/* 6.x */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* */
|
||||
/* This function returns thread ID of the calling pthread . */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* Nothing */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* thread_ID pthread handle of the calling thread */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* xx-xx-xxxx William E. Lamie Initial Version 6.x */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
pthread_t pthread_self(VOID)
|
||||
{
|
||||
|
||||
TX_THREAD *thread_ptr;
|
||||
pthread_t thread_ID;
|
||||
|
||||
/* Get the thread identifier of the currently running thread */
|
||||
thread_ptr = tx_thread_identify();
|
||||
|
||||
/* Convert thread identifier to posix thread ID */
|
||||
|
||||
thread_ID = posix_thread2tid(thread_ptr);
|
||||
|
||||
/* Determine if this thread is actually the signal thread helper. */
|
||||
if (((POSIX_TCB *) thread_ptr) -> signals.signal_handler)
|
||||
{
|
||||
|
||||
/* Yes, override the thread_ID with the non-signal thread ID. */
|
||||
thread_ID = (pthread_t) ((POSIX_TCB *) thread_ptr) -> signals.base_thread_ptr;
|
||||
}
|
||||
|
||||
|
||||
/* All done. */
|
||||
return(thread_ID);
|
||||
}
|
||||
Reference in New Issue
Block a user