diff options
Diffstat (limited to 'source/os_specific/service_layers/osunixxf.c')
| -rw-r--r-- | source/os_specific/service_layers/osunixxf.c | 63 |
1 files changed, 54 insertions, 9 deletions
diff --git a/source/os_specific/service_layers/osunixxf.c b/source/os_specific/service_layers/osunixxf.c index 9ae2465366ce1..2afc54e9df13d 100644 --- a/source/os_specific/service_layers/osunixxf.c +++ b/source/os_specific/service_layers/osunixxf.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2012, Intel Corp. + * Copyright (C) 2000 - 2013, Intel Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -84,6 +84,10 @@ AeTableOverride ( typedef void* (*PTHREAD_CALLBACK) (void *); +/* Buffer used by AcpiOsVprintf */ + +#define ACPI_VPRINTF_BUFFER_SIZE 512 + /* Apple-specific */ #ifdef __APPLE__ @@ -268,7 +272,8 @@ AcpiOsRedirectOutput ( * * RETURN: None * - * DESCRIPTION: Formatted output + * DESCRIPTION: Formatted output. Note: very similar to AcpiOsVprintf + * (performance), changes should be tracked in both functions. * *****************************************************************************/ @@ -278,11 +283,36 @@ AcpiOsPrintf ( ...) { va_list Args; + UINT8 Flags; + + + Flags = AcpiGbl_DbOutputFlags; + if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT) + { + /* Output is directable to either a file (if open) or the console */ + if (AcpiGbl_DebugFile) + { + /* Output file is open, send the output there */ - va_start (Args, Fmt); - AcpiOsVprintf (Fmt, Args); - va_end (Args); + va_start (Args, Fmt); + vfprintf (AcpiGbl_DebugFile, Fmt, Args); + va_end (Args); + } + else + { + /* No redirection, send output to console (once only!) */ + + Flags |= ACPI_DB_CONSOLE_OUTPUT; + } + } + + if (Flags & ACPI_DB_CONSOLE_OUTPUT) + { + va_start (Args, Fmt); + vfprintf (AcpiGbl_OutputFile, Fmt, Args); + va_end (Args); + } } @@ -295,7 +325,9 @@ AcpiOsPrintf ( * * RETURN: None * - * DESCRIPTION: Formatted output with argument list pointer + * DESCRIPTION: Formatted output with argument list pointer. Note: very + * similar to AcpiOsPrintf, changes should be tracked in both + * functions. * *****************************************************************************/ @@ -305,8 +337,21 @@ AcpiOsVprintf ( va_list Args) { UINT8 Flags; + char Buffer[ACPI_VPRINTF_BUFFER_SIZE]; + /* + * We build the output string in a local buffer because we may be + * outputting the buffer twice. Using vfprintf is problematic because + * some implementations modify the args pointer/structure during + * execution. Thus, we use the local buffer for portability. + * + * Note: Since this module is intended for use by the various ACPICA + * utilities/applications, we can safely declare the buffer on the stack. + * Also, This function is used for relatively small error messages only. + */ + vsnprintf (Buffer, ACPI_VPRINTF_BUFFER_SIZE, Fmt, Args); + Flags = AcpiGbl_DbOutputFlags; if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT) { @@ -316,7 +361,7 @@ AcpiOsVprintf ( { /* Output file is open, send the output there */ - vfprintf (AcpiGbl_DebugFile, Fmt, Args); + fputs (Buffer, AcpiGbl_DebugFile); } else { @@ -328,7 +373,7 @@ AcpiOsVprintf ( if (Flags & ACPI_DB_CONSOLE_OUTPUT) { - vfprintf (AcpiGbl_OutputFile, Fmt, Args); + fputs (Buffer, AcpiGbl_OutputFile); } } @@ -929,7 +974,7 @@ AcpiOsSleep ( * Sleep for remaining microseconds. * Arg to usleep() is in usecs and must be less than 1,000,000 (1 second). */ - usleep ((milliseconds % ACPI_MSEC_PER_SEC) * ACPI_USEC_PER_MSEC); + usleep ((milliseconds % ACPI_MSEC_PER_SEC) * ACPI_USEC_PER_MSEC); } |
