Print this page
update to acpica-unix2-20131218
update to acpica-unix2-20130927
acpica-unix2-20130823
PANKOVs restructure

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/io/acpica/utilities/utalloc.c
          +++ new/usr/src/common/acpica/components/utilities/utalloc.c
   1    1  /******************************************************************************
   2    2   *
   3    3   * Module Name: utalloc - local memory allocation routines
   4    4   *
   5    5   *****************************************************************************/
   6    6  
   7    7  /*
   8      - * Copyright (C) 2000 - 2011, Intel Corp.
        8 + * Copyright (C) 2000 - 2013, Intel Corp.
   9    9   * All rights reserved.
  10   10   *
  11   11   * Redistribution and use in source and binary forms, with or without
  12   12   * modification, are permitted provided that the following conditions
  13   13   * are met:
  14   14   * 1. Redistributions of source code must retain the above copyright
  15   15   *    notice, this list of conditions, and the following disclaimer,
  16   16   *    without modification.
  17   17   * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18   18   *    substantially similar to the "NO WARRANTY" disclaimer below
↓ open down ↓ 25 lines elided ↑ open up ↑
  44   44  #define __UTALLOC_C__
  45   45  
  46   46  #include "acpi.h"
  47   47  #include "accommon.h"
  48   48  #include "acdebug.h"
  49   49  
  50   50  #define _COMPONENT          ACPI_UTILITIES
  51   51          ACPI_MODULE_NAME    ("utalloc")
  52   52  
  53   53  
       54 +#if !defined (USE_NATIVE_ALLOCATE_ZEROED)
  54   55  /*******************************************************************************
  55   56   *
       57 + * FUNCTION:    AcpiOsAllocateZeroed
       58 + *
       59 + * PARAMETERS:  Size                - Size of the allocation
       60 + *
       61 + * RETURN:      Address of the allocated memory on success, NULL on failure.
       62 + *
       63 + * DESCRIPTION: Subsystem equivalent of calloc. Allocate and zero memory.
       64 + *              This is the default implementation. Can be overridden via the
       65 + *              USE_NATIVE_ALLOCATE_ZEROED flag.
       66 + *
       67 + ******************************************************************************/
       68 +
       69 +void *
       70 +AcpiOsAllocateZeroed (
       71 +    ACPI_SIZE               Size)
       72 +{
       73 +    void                    *Allocation;
       74 +
       75 +
       76 +    ACPI_FUNCTION_ENTRY ();
       77 +
       78 +
       79 +    Allocation = AcpiOsAllocate (Size);
       80 +    if (Allocation)
       81 +    {
       82 +        /* Clear the memory block */
       83 +
       84 +        ACPI_MEMSET (Allocation, 0, Size);
       85 +    }
       86 +
       87 +    return (Allocation);
       88 +}
       89 +
       90 +#endif /* !USE_NATIVE_ALLOCATE_ZEROED */
       91 +
       92 +
       93 +/*******************************************************************************
       94 + *
  56   95   * FUNCTION:    AcpiUtCreateCaches
  57   96   *
  58   97   * PARAMETERS:  None
  59   98   *
  60   99   * RETURN:      Status
  61  100   *
  62  101   * DESCRIPTION: Create all local caches
  63  102   *
  64  103   ******************************************************************************/
  65  104  
↓ open down ↓ 212 lines elided ↑ open up ↑
 278  317       */
 279  318      switch (InputBufferLength)
 280  319      {
 281  320      case ACPI_NO_BUFFER:
 282  321  
 283  322          /* Return the exception (and the required buffer length) */
 284  323  
 285  324          return (AE_BUFFER_OVERFLOW);
 286  325  
 287  326      case ACPI_ALLOCATE_BUFFER:
 288      -
 289      -        /* Allocate a new buffer */
 290      -
      327 +        /*
      328 +         * Allocate a new buffer. We directectly call AcpiOsAllocate here to
      329 +         * purposefully bypass the (optionally enabled) internal allocation
      330 +         * tracking mechanism since we only want to track internal
      331 +         * allocations. Note: The caller should use AcpiOsFree to free this
      332 +         * buffer created via ACPI_ALLOCATE_BUFFER.
      333 +         */
 291  334          Buffer->Pointer = AcpiOsAllocate (RequiredLength);
 292  335          break;
 293  336  
 294  337      case ACPI_ALLOCATE_LOCAL_BUFFER:
 295  338  
 296  339          /* Allocate a new buffer with local interface to allow tracking */
 297  340  
 298  341          Buffer->Pointer = ACPI_ALLOCATE (RequiredLength);
 299  342          break;
 300  343  
↓ open down ↓ 13 lines elided ↑ open up ↑
 314  357      if (!Buffer->Pointer)
 315  358      {
 316  359          return (AE_NO_MEMORY);
 317  360      }
 318  361  
 319  362      /* Have a valid buffer, clear it */
 320  363  
 321  364      ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
 322  365      return (AE_OK);
 323  366  }
 324      -
 325      -
 326      -/*******************************************************************************
 327      - *
 328      - * FUNCTION:    AcpiUtAllocate
 329      - *
 330      - * PARAMETERS:  Size                - Size of the allocation
 331      - *              Component           - Component type of caller
 332      - *              Module              - Source file name of caller
 333      - *              Line                - Line number of caller
 334      - *
 335      - * RETURN:      Address of the allocated memory on success, NULL on failure.
 336      - *
 337      - * DESCRIPTION: Subsystem equivalent of malloc.
 338      - *
 339      - ******************************************************************************/
 340      -
 341      -void *
 342      -AcpiUtAllocate (
 343      -    ACPI_SIZE               Size,
 344      -    UINT32                  Component,
 345      -    const char              *Module,
 346      -    UINT32                  Line)
 347      -{
 348      -    void                    *Allocation;
 349      -
 350      -
 351      -    ACPI_FUNCTION_TRACE_U32 (UtAllocate, Size);
 352      -
 353      -
 354      -    /* Check for an inadvertent size of zero bytes */
 355      -
 356      -    if (!Size)
 357      -    {
 358      -        ACPI_WARNING ((Module, Line,
 359      -            "Attempt to allocate zero bytes, allocating 1 byte"));
 360      -        Size = 1;
 361      -    }
 362      -
 363      -    Allocation = AcpiOsAllocate (Size);
 364      -    if (!Allocation)
 365      -    {
 366      -        /* Report allocation error */
 367      -
 368      -        ACPI_WARNING ((Module, Line,
 369      -            "Could not allocate size %u", (UINT32) Size));
 370      -
 371      -        return_PTR (NULL);
 372      -    }
 373      -
 374      -    return_PTR (Allocation);
 375      -}
 376      -
 377      -
 378      -/*******************************************************************************
 379      - *
 380      - * FUNCTION:    AcpiUtAllocateZeroed
 381      - *
 382      - * PARAMETERS:  Size                - Size of the allocation
 383      - *              Component           - Component type of caller
 384      - *              Module              - Source file name of caller
 385      - *              Line                - Line number of caller
 386      - *
 387      - * RETURN:      Address of the allocated memory on success, NULL on failure.
 388      - *
 389      - * DESCRIPTION: Subsystem equivalent of calloc. Allocate and zero memory.
 390      - *
 391      - ******************************************************************************/
 392      -
 393      -void *
 394      -AcpiUtAllocateZeroed (
 395      -    ACPI_SIZE               Size,
 396      -    UINT32                  Component,
 397      -    const char              *Module,
 398      -    UINT32                  Line)
 399      -{
 400      -    void                    *Allocation;
 401      -
 402      -
 403      -    ACPI_FUNCTION_ENTRY ();
 404      -
 405      -
 406      -    Allocation = AcpiUtAllocate (Size, Component, Module, Line);
 407      -    if (Allocation)
 408      -    {
 409      -        /* Clear the memory block */
 410      -
 411      -        ACPI_MEMSET (Allocation, 0, Size);
 412      -    }
 413      -
 414      -    return (Allocation);
 415      -}
 416      -
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX