mirror of
https://github.com/acpica/acpica/
synced 2025-01-13 12:59:18 +03:00
Make ACPI_THREAD_ID no longer configurable, always UINT64.
Change definition of ACPI_THREAD_ID to always be a UINT64. This simplifies the code, especially any printf output. UINT64 is the only common data type for all thread_id types across all operating systems. We now force the OSL to cast the native thread_id type to UINT64 before returning the value to ACPICA (via AcpiOsGetThreadId). Lin Ming, Bob Moore.
This commit is contained in:
parent
87bdbc7ec8
commit
b890ef7b6b
@ -567,14 +567,12 @@ AcpiDbMethodThread (
|
||||
if (Info->InitArgs)
|
||||
{
|
||||
AcpiDbUInt32ToHexString (Info->NumCreated, Info->IndexOfThreadStr);
|
||||
AcpiDbUInt32ToHexString (ACPI_TO_INTEGER (AcpiOsGetThreadId ()),
|
||||
Info->IdOfThreadStr);
|
||||
AcpiDbUInt32ToHexString ((UINT32) AcpiOsGetThreadId (), Info->IdOfThreadStr);
|
||||
}
|
||||
|
||||
if (Info->Threads && (Info->NumCreated < Info->NumThreads))
|
||||
{
|
||||
Info->Threads[Info->NumCreated++] =
|
||||
ACPI_TO_INTEGER (AcpiOsGetThreadId());
|
||||
Info->Threads[Info->NumCreated++] = AcpiOsGetThreadId();
|
||||
}
|
||||
|
||||
LocalInfo = *Info;
|
||||
@ -722,8 +720,8 @@ AcpiDbCreateExecutionThreads (
|
||||
/* Array to store IDs of threads */
|
||||
|
||||
AcpiGbl_DbMethodInfo.NumThreads = NumThreads;
|
||||
Size = 4 * AcpiGbl_DbMethodInfo.NumThreads;
|
||||
AcpiGbl_DbMethodInfo.Threads = (UINT32 *) AcpiOsAllocate (Size);
|
||||
Size = sizeof (ACPI_THREAD_ID) * AcpiGbl_DbMethodInfo.NumThreads;
|
||||
AcpiGbl_DbMethodInfo.Threads = AcpiOsAllocate (Size);
|
||||
if (AcpiGbl_DbMethodInfo.Threads == NULL)
|
||||
{
|
||||
AcpiOsPrintf ("No memory for thread IDs array\n");
|
||||
|
@ -513,10 +513,10 @@ AcpiExReleaseMutex (
|
||||
(ObjDesc != AcpiGbl_GlobalLockMutex))
|
||||
{
|
||||
ACPI_ERROR ((AE_INFO,
|
||||
"Thread %p cannot release Mutex [%4.4s] acquired by thread %p",
|
||||
ACPI_CAST_PTR (void, WalkState->Thread->ThreadId),
|
||||
"Thread %u cannot release Mutex [%4.4s] acquired by thread %u",
|
||||
(UINT32) WalkState->Thread->ThreadId,
|
||||
AcpiUtGetNodeName (ObjDesc->Mutex.Node),
|
||||
ACPI_CAST_PTR (void, OwnerThread->ThreadId)));
|
||||
(UINT32) OwnerThread->ThreadId));
|
||||
return_ACPI_STATUS (AE_AML_NOT_OWNER);
|
||||
}
|
||||
|
||||
|
@ -279,9 +279,8 @@ AcpiDebugPrint (
|
||||
if (ACPI_LV_THREADS & AcpiDbgLevel)
|
||||
{
|
||||
AcpiOsPrintf (
|
||||
"\n**** Context Switch from TID %p to TID %p ****\n\n",
|
||||
ACPI_CAST_PTR (void, AcpiGbl_PrevThreadId),
|
||||
ACPI_CAST_PTR (void, ThreadId));
|
||||
"\n**** Context Switch from TID %u to TID %u ****\n\n",
|
||||
(UINT32) AcpiGbl_PrevThreadId, (UINT32) ThreadId);
|
||||
}
|
||||
|
||||
AcpiGbl_PrevThreadId = ThreadId;
|
||||
@ -295,7 +294,7 @@ AcpiDebugPrint (
|
||||
|
||||
if (ACPI_LV_THREADS & AcpiDbgLevel)
|
||||
{
|
||||
AcpiOsPrintf ("[%p] ", ACPI_CAST_PTR (void, ThreadId));
|
||||
AcpiOsPrintf ("[%u] ", (UINT32) ThreadId);
|
||||
}
|
||||
|
||||
AcpiOsPrintf ("[%02ld] %-22.22s: ",
|
||||
|
@ -348,16 +348,16 @@ AcpiUtAcquireMutex (
|
||||
if (i == MutexId)
|
||||
{
|
||||
ACPI_ERROR ((AE_INFO,
|
||||
"Mutex [%s] already acquired by this thread [%p]",
|
||||
"Mutex [%s] already acquired by this thread [%u]",
|
||||
AcpiUtGetMutexName (MutexId),
|
||||
ACPI_CAST_PTR (void, ThisThreadId)));
|
||||
(UINT32) ThisThreadId));
|
||||
|
||||
return (AE_ALREADY_ACQUIRED);
|
||||
}
|
||||
|
||||
ACPI_ERROR ((AE_INFO,
|
||||
"Invalid acquire order: Thread %p owns [%s], wants [%s]",
|
||||
ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (i),
|
||||
"Invalid acquire order: Thread %u owns [%s], wants [%s]",
|
||||
(UINT32) ThisThreadId, AcpiUtGetMutexName (i),
|
||||
AcpiUtGetMutexName (MutexId)));
|
||||
|
||||
return (AE_ACQUIRE_DEADLOCK);
|
||||
@ -367,15 +367,15 @@ AcpiUtAcquireMutex (
|
||||
#endif
|
||||
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX,
|
||||
"Thread %p attempting to acquire Mutex [%s]\n",
|
||||
ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId)));
|
||||
"Thread %u attempting to acquire Mutex [%s]\n",
|
||||
(UINT32) ThisThreadId, AcpiUtGetMutexName (MutexId)));
|
||||
|
||||
Status = AcpiOsAcquireMutex (AcpiGbl_MutexInfo[MutexId].Mutex,
|
||||
ACPI_WAIT_FOREVER);
|
||||
if (ACPI_SUCCESS (Status))
|
||||
{
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %p acquired Mutex [%s]\n",
|
||||
ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId)));
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %u acquired Mutex [%s]\n",
|
||||
(UINT32) ThisThreadId, AcpiUtGetMutexName (MutexId)));
|
||||
|
||||
AcpiGbl_MutexInfo[MutexId].UseCount++;
|
||||
AcpiGbl_MutexInfo[MutexId].ThreadId = ThisThreadId;
|
||||
@ -383,8 +383,8 @@ AcpiUtAcquireMutex (
|
||||
else
|
||||
{
|
||||
ACPI_EXCEPTION ((AE_INFO, Status,
|
||||
"Thread %p could not acquire Mutex [0x%X]",
|
||||
ACPI_CAST_PTR (void, ThisThreadId), MutexId));
|
||||
"Thread %u could not acquire Mutex [0x%X]",
|
||||
(UINT32) ThisThreadId, MutexId));
|
||||
}
|
||||
|
||||
return (Status);
|
||||
@ -414,8 +414,8 @@ AcpiUtReleaseMutex (
|
||||
|
||||
|
||||
ThisThreadId = AcpiOsGetThreadId ();
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %p releasing Mutex [%s]\n",
|
||||
ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId)));
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %u releasing Mutex [%s]\n",
|
||||
(UINT32) ThisThreadId, AcpiUtGetMutexName (MutexId)));
|
||||
|
||||
if (MutexId > ACPI_MAX_MUTEX)
|
||||
{
|
||||
|
@ -1270,7 +1270,7 @@ typedef struct acpi_db_method_info
|
||||
ACPI_HANDLE MainThreadGate;
|
||||
ACPI_HANDLE ThreadCompleteGate;
|
||||
ACPI_HANDLE InfoGate;
|
||||
UINT32 *Threads;
|
||||
ACPI_THREAD_ID *Threads;
|
||||
UINT32 NumThreads;
|
||||
UINT32 NumCreated;
|
||||
UINT32 NumCompleted;
|
||||
|
@ -188,7 +188,6 @@
|
||||
*
|
||||
* ACPI_SIZE 16/32/64-bit unsigned value
|
||||
* ACPI_NATIVE_INT 16/32/64-bit signed value
|
||||
*
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
@ -205,6 +204,16 @@ typedef COMPILER_DEPENDENT_INT64 INT64;
|
||||
|
||||
/*! [End] no source code translation !*/
|
||||
|
||||
/*
|
||||
* Value returned by AcpiOsGetThreadId. There is no standard "thread_id"
|
||||
* across operating systems or even the various UNIX systems. Since ACPICA
|
||||
* only needs the thread ID as a unique thread identifier, we use a UINT64
|
||||
* as the only common data type - it will accommodate any type of pointer or
|
||||
* any type of integer. It is up to the host-dependent OSL to cast the
|
||||
* native thread ID type to a UINT64 (in AcpiOsGetThreadId).
|
||||
*/
|
||||
#define ACPI_THREAD_ID UINT64
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
@ -286,12 +295,6 @@ typedef UINT32 ACPI_PHYSICAL_ADDRESS;
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/* Value returned by AcpiOsGetThreadId */
|
||||
|
||||
#ifndef ACPI_THREAD_ID
|
||||
#define ACPI_THREAD_ID ACPI_SIZE
|
||||
#endif
|
||||
|
||||
/* Flags for AcpiOsAcquireLock/AcpiOsReleaseLock */
|
||||
|
||||
#ifndef ACPI_CPU_FLAGS
|
||||
|
@ -121,7 +121,6 @@
|
||||
*/
|
||||
#define ACPI_USE_SYSTEM_CLIBRARY
|
||||
#define ACPI_USE_DO_WHILE_0
|
||||
#define ACPI_THREAD_ID pthread_t
|
||||
#define ACPI_FLUSH_CPU_CACHE()
|
||||
/*
|
||||
* This is needed since sem_timedwait does not appear to work properly
|
||||
@ -154,6 +153,9 @@
|
||||
#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) if (GLptr) Acq=1; else Acq=0;
|
||||
#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Pending) Pending = 1
|
||||
|
||||
/* On Cygwin, pthread_t is a pointer */
|
||||
|
||||
#define ACPI_CAST_PTHREAD_T(pthread) ((ACPI_THREAD_ID) ACPI_TO_INTEGER (pthread))
|
||||
|
||||
/* Cygwin uses GCC */
|
||||
|
||||
|
@ -139,7 +139,6 @@
|
||||
|
||||
#include "opt_acpi.h"
|
||||
|
||||
#define ACPI_THREAD_ID lwpid_t
|
||||
#define ACPI_MUTEX_TYPE ACPI_OSL_MUTEX
|
||||
|
||||
#ifdef ACPI_DEBUG
|
||||
@ -166,8 +165,6 @@
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
#define ACPI_THREAD_ID pthread_t
|
||||
|
||||
#define ACPI_USE_STANDARD_HEADERS
|
||||
|
||||
#define ACPI_FLUSH_CPU_CACHE()
|
||||
|
@ -147,7 +147,6 @@
|
||||
#define ACPI_CACHE_T struct kmem_cache
|
||||
#define ACPI_SPINLOCK spinlock_t *
|
||||
#define ACPI_CPU_FLAGS unsigned long
|
||||
#define ACPI_THREAD_ID struct task_struct *
|
||||
|
||||
#else /* !__KERNEL__ */
|
||||
|
||||
@ -160,7 +159,7 @@
|
||||
/* Host-dependent types and defines for user-space ACPICA */
|
||||
|
||||
#define ACPI_FLUSH_CPU_CACHE()
|
||||
#define ACPI_THREAD_ID pthread_t
|
||||
#define ACPI_CAST_PTHREAD_T(pthread) ((ACPI_THREAD_ID) (pthread))
|
||||
|
||||
#if defined(__ia64__) || defined(__x86_64__)
|
||||
#define ACPI_MACHINE_WIDTH 64
|
||||
|
@ -1158,16 +1158,14 @@ AcpiOsWritable (
|
||||
*
|
||||
* DESCRIPTION: Get the Id of the current (running) thread
|
||||
*
|
||||
* NOTE: The environment header should contain this line:
|
||||
* #define ACPI_THREAD_ID pthread_t
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
ACPI_THREAD_ID
|
||||
AcpiOsGetThreadId (void)
|
||||
AcpiOsGetThreadId (
|
||||
void)
|
||||
{
|
||||
|
||||
return (pthread_self ());
|
||||
return (ACPI_CAST_PTHREAD_T (pthread_self()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1077,7 +1077,7 @@ AcpiOsGetThreadId (
|
||||
/* Ensure ID is never 0 */
|
||||
|
||||
ThreadId = GetCurrentThreadId ();
|
||||
return (ThreadId + 1);
|
||||
return ((ACPI_THREAD_ID) (ThreadId + 1));
|
||||
}
|
||||
|
||||
|
||||
|
@ -361,7 +361,7 @@ AeExceptionHandler (
|
||||
Arg[1].String.Length = ACPI_STRLEN (Exception);
|
||||
|
||||
Arg[2].Type = ACPI_TYPE_INTEGER;
|
||||
Arg[2].Integer.Value = ACPI_TO_INTEGER (AcpiOsGetThreadId());
|
||||
Arg[2].Integer.Value = AcpiOsGetThreadId();
|
||||
|
||||
/* Setup return buffer */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user