utcache.c (151937) | utcache.c (167802) |
---|---|
1/****************************************************************************** 2 * 3 * Module Name: utcache - local cache allocation routines | 1/****************************************************************************** 2 * 3 * Module Name: utcache - local cache allocation routines |
4 * $Revision: 1.2 $ | 4 * $Revision: 1.8 $ |
5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * | 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * |
12 * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. | 12 * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. |
13 * All rights reserved. 14 * 15 * 2. License 16 * 17 * 2.1. This is your license from Intel Corp. under its intellectual property 18 * rights. You may have additional license terms from the party that provided 19 * you this software, covering your right to use that party's intellectual 20 * property rights. --- 186 unchanged lines hidden (view full) --- 207 /* Walk the list of objects in this cache */ 208 209 while (Cache->ListHead) 210 { 211 /* Delete and unlink one cached state object */ 212 213 Next = *(ACPI_CAST_INDIRECT_PTR (char, 214 &(((char *) Cache->ListHead)[Cache->LinkOffset]))); | 13 * All rights reserved. 14 * 15 * 2. License 16 * 17 * 2.1. This is your license from Intel Corp. under its intellectual property 18 * rights. You may have additional license terms from the party that provided 19 * you this software, covering your right to use that party's intellectual 20 * property rights. --- 186 unchanged lines hidden (view full) --- 207 /* Walk the list of objects in this cache */ 208 209 while (Cache->ListHead) 210 { 211 /* Delete and unlink one cached state object */ 212 213 Next = *(ACPI_CAST_INDIRECT_PTR (char, 214 &(((char *) Cache->ListHead)[Cache->LinkOffset]))); |
215 ACPI_MEM_FREE (Cache->ListHead); | 215 ACPI_FREE (Cache->ListHead); |
216 217 Cache->ListHead = Next; 218 Cache->CurrentDepth--; 219 } 220 221 return (AE_OK); 222} 223 --- 65 unchanged lines hidden (view full) --- 289 { 290 return (AE_BAD_PARAMETER); 291 } 292 293 /* If cache is full, just free this object */ 294 295 if (Cache->CurrentDepth >= Cache->MaxDepth) 296 { | 216 217 Cache->ListHead = Next; 218 Cache->CurrentDepth--; 219 } 220 221 return (AE_OK); 222} 223 --- 65 unchanged lines hidden (view full) --- 289 { 290 return (AE_BAD_PARAMETER); 291 } 292 293 /* If cache is full, just free this object */ 294 295 if (Cache->CurrentDepth >= Cache->MaxDepth) 296 { |
297 ACPI_MEM_FREE (Object); | 297 ACPI_FREE (Object); |
298 ACPI_MEM_TRACKING (Cache->TotalFreed++); 299 } 300 301 /* Otherwise put this object back into the cache */ 302 303 else 304 { 305 Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); --- 37 unchanged lines hidden (view full) --- 343void * 344AcpiOsAcquireObject ( 345 ACPI_MEMORY_LIST *Cache) 346{ 347 ACPI_STATUS Status; 348 void *Object; 349 350 | 298 ACPI_MEM_TRACKING (Cache->TotalFreed++); 299 } 300 301 /* Otherwise put this object back into the cache */ 302 303 else 304 { 305 Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); --- 37 unchanged lines hidden (view full) --- 343void * 344AcpiOsAcquireObject ( 345 ACPI_MEMORY_LIST *Cache) 346{ 347 ACPI_STATUS Status; 348 void *Object; 349 350 |
351 ACPI_FUNCTION_NAME ("OsAcquireObject"); | 351 ACPI_FUNCTION_NAME (OsAcquireObject); |
352 353 354 if (!Cache) 355 { 356 return (NULL); 357 } 358 359 Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); --- 12 unchanged lines hidden (view full) --- 372 373 Object = Cache->ListHead; 374 Cache->ListHead = *(ACPI_CAST_INDIRECT_PTR (char, 375 &(((char *) Object)[Cache->LinkOffset]))); 376 377 Cache->CurrentDepth--; 378 379 ACPI_MEM_TRACKING (Cache->Hits++); | 352 353 354 if (!Cache) 355 { 356 return (NULL); 357 } 358 359 Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); --- 12 unchanged lines hidden (view full) --- 372 373 Object = Cache->ListHead; 374 Cache->ListHead = *(ACPI_CAST_INDIRECT_PTR (char, 375 &(((char *) Object)[Cache->LinkOffset]))); 376 377 Cache->CurrentDepth--; 378 379 ACPI_MEM_TRACKING (Cache->Hits++); |
380 ACPI_MEM_TRACKING (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 381 "Object %p from %s cache\n", Object, Cache->ListName))); | 380 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 381 "Object %p from %s cache\n", Object, Cache->ListName)); |
382 383 Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES); 384 if (ACPI_FAILURE (Status)) 385 { 386 return (NULL); 387 } 388 389 /* Clear (zero) the previously used Object */ 390 391 ACPI_MEMSET (Object, 0, Cache->ObjectSize); 392 } 393 else 394 { 395 /* The cache is empty, create a new object */ 396 397 ACPI_MEM_TRACKING (Cache->TotalAllocated++); 398 | 382 383 Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES); 384 if (ACPI_FAILURE (Status)) 385 { 386 return (NULL); 387 } 388 389 /* Clear (zero) the previously used Object */ 390 391 ACPI_MEMSET (Object, 0, Cache->ObjectSize); 392 } 393 else 394 { 395 /* The cache is empty, create a new object */ 396 397 ACPI_MEM_TRACKING (Cache->TotalAllocated++); 398 |
399 /* Avoid deadlock with ACPI_MEM_CALLOCATE */ | 399#ifdef ACPI_DBG_TRACK_ALLOCATIONS 400 if ((Cache->TotalAllocated - Cache->TotalFreed) > Cache->MaxOccupied) 401 { 402 Cache->MaxOccupied = Cache->TotalAllocated - Cache->TotalFreed; 403 } 404#endif |
400 | 405 |
406 /* Avoid deadlock with ACPI_ALLOCATE_ZEROED */ 407 |
|
401 Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES); 402 if (ACPI_FAILURE (Status)) 403 { 404 return (NULL); 405 } 406 | 408 Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES); 409 if (ACPI_FAILURE (Status)) 410 { 411 return (NULL); 412 } 413 |
407 Object = ACPI_MEM_CALLOCATE (Cache->ObjectSize); | 414 Object = ACPI_ALLOCATE_ZEROED (Cache->ObjectSize); |
408 if (!Object) 409 { 410 return (NULL); 411 } 412 } 413 414 return (Object); 415} 416#endif /* ACPI_USE_LOCAL_CACHE */ 417 418 | 415 if (!Object) 416 { 417 return (NULL); 418 } 419 } 420 421 return (Object); 422} 423#endif /* ACPI_USE_LOCAL_CACHE */ 424 425 |