mirror of
https://github.com/eclipse-threadx/threadx.git
synced 2025-11-16 12:34:48 +00:00
94 lines
4.9 KiB
C
94 lines
4.9 KiB
C
/***************************************************************************
|
|
* Copyright (c) 2024 Microsoft Corporation
|
|
*
|
|
* This program and the accompanying materials are made available under the
|
|
* terms of the MIT License which is available at
|
|
* https://opensource.org/licenses/MIT.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
**************************************************************************/
|
|
|
|
|
|
/**************************************************************************/
|
|
/**************************************************************************/
|
|
/** */
|
|
/** 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.1.7 */
|
|
/* 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 */
|
|
/* */
|
|
/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
|
|
/* */
|
|
/**************************************************************************/
|
|
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);
|
|
}
|