diff options
| author | Lv Zheng <lv.zheng@intel.com> | 2016-08-04 04:45:06 -0400 |
|---|---|---|
| committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-08-12 21:09:35 -0400 |
| commit | f173a7750eb188fd7d888d5950d58454bcfbd09b (patch) | |
| tree | 673af041d61caf1a783647422c3b81069f50cfcf /drivers/acpi/acpica | |
| parent | e323c02dee59af7da65637852f6fa95551325d80 (diff) | |
ACPICA: Clib: Add -nostdinc support for EFI layer
ACPICA commit d261d40ea168f8e4c4e3986de720b8651c4aba1c
This patch adds sprintf()/snprintf()/vsnprintf()/printf()/vfprintf()
support for OSPMs that have ACPI_USE_SYSTEM_CLIBRARY defined but do not
have ACPI_USE_STANDARD_HEADERS defined.
-iwithprefix include is required to include <stdarg.h> which contains
compiler specific implementation of vargs when -nostdinc is specified.
-fno-builtin is required for GCC to avoid optimization performed printf().
This optimization cannot be automatically disabled by specifying -nostdlib.
Please refer to the first link below for the details. However, the build
option changes do not affect Linux kernel builds and are not included.
Lv Zheng.
Link: http://www.ciselant.de/projects/gcc_printf/gcc_printf.html
Link: https://github.com/acpica/acpica/commit/d261d40e
Link: https://bugs.acpica.org/show_bug.cgi?id=1302
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/acpica')
| -rw-r--r-- | drivers/acpi/acpica/acutils.h | 19 | ||||
| -rw-r--r-- | drivers/acpi/acpica/utbuffer.c | 30 | ||||
| -rw-r--r-- | drivers/acpi/acpica/utdebug.c | 2 | ||||
| -rw-r--r-- | drivers/acpi/acpica/utprint.c | 104 |
4 files changed, 105 insertions, 50 deletions
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h index 91269a6efded..d899296eeb47 100644 --- a/drivers/acpi/acpica/acutils.h +++ b/drivers/acpi/acpica/acutils.h | |||
| @@ -724,25 +724,6 @@ const struct ah_device_id *acpi_ah_match_hardware_id(char *hid); | |||
| 724 | const char *acpi_ah_match_uuid(u8 *data); | 724 | const char *acpi_ah_match_uuid(u8 *data); |
| 725 | 725 | ||
| 726 | /* | 726 | /* |
| 727 | * utprint - printf/vprintf output functions | ||
| 728 | */ | ||
| 729 | const char *acpi_ut_scan_number(const char *string, u64 *number_ptr); | ||
| 730 | |||
| 731 | const char *acpi_ut_print_number(char *string, u64 number); | ||
| 732 | |||
| 733 | int | ||
| 734 | acpi_ut_vsnprintf(char *string, | ||
| 735 | acpi_size size, const char *format, va_list args); | ||
| 736 | |||
| 737 | int acpi_ut_snprintf(char *string, acpi_size size, const char *format, ...); | ||
| 738 | |||
| 739 | #ifdef ACPI_APPLICATION | ||
| 740 | int acpi_ut_file_vprintf(ACPI_FILE file, const char *format, va_list args); | ||
| 741 | |||
| 742 | int acpi_ut_file_printf(ACPI_FILE file, const char *format, ...); | ||
| 743 | #endif | ||
| 744 | |||
| 745 | /* | ||
| 746 | * utuuid -- UUID support functions | 727 | * utuuid -- UUID support functions |
| 747 | */ | 728 | */ |
| 748 | #if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP || defined ACPI_HELP_APP) | 729 | #if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP || defined ACPI_HELP_APP) |
diff --git a/drivers/acpi/acpica/utbuffer.c b/drivers/acpi/acpica/utbuffer.c index bd31faf5da7c..ff2981275b9a 100644 --- a/drivers/acpi/acpica/utbuffer.c +++ b/drivers/acpi/acpica/utbuffer.c | |||
| @@ -239,8 +239,7 @@ acpi_ut_dump_buffer_to_file(ACPI_FILE file, | |||
| 239 | u8 buf_char; | 239 | u8 buf_char; |
| 240 | 240 | ||
| 241 | if (!buffer) { | 241 | if (!buffer) { |
| 242 | acpi_ut_file_printf(file, | 242 | fprintf(file, "Null Buffer Pointer in DumpBuffer!\n"); |
| 243 | "Null Buffer Pointer in DumpBuffer!\n"); | ||
| 244 | return; | 243 | return; |
| 245 | } | 244 | } |
| 246 | 245 | ||
| @@ -254,7 +253,7 @@ acpi_ut_dump_buffer_to_file(ACPI_FILE file, | |||
| 254 | 253 | ||
| 255 | /* Print current offset */ | 254 | /* Print current offset */ |
| 256 | 255 | ||
| 257 | acpi_ut_file_printf(file, "%6.4X: ", (base_offset + i)); | 256 | fprintf(file, "%6.4X: ", (base_offset + i)); |
| 258 | 257 | ||
| 259 | /* Print 16 hex chars */ | 258 | /* Print 16 hex chars */ |
| 260 | 259 | ||
| @@ -263,8 +262,7 @@ acpi_ut_dump_buffer_to_file(ACPI_FILE file, | |||
| 263 | 262 | ||
| 264 | /* Dump fill spaces */ | 263 | /* Dump fill spaces */ |
| 265 | 264 | ||
| 266 | acpi_ut_file_printf(file, "%*s", | 265 | fprintf(file, "%*s", ((display * 2) + 1), " "); |
| 267 | ((display * 2) + 1), " "); | ||
| 268 | j += display; | 266 | j += display; |
| 269 | continue; | 267 | continue; |
| 270 | } | 268 | } |
| @@ -273,34 +271,34 @@ acpi_ut_dump_buffer_to_file(ACPI_FILE file, | |||
| 273 | case DB_BYTE_DISPLAY: | 271 | case DB_BYTE_DISPLAY: |
| 274 | default: /* Default is BYTE display */ | 272 | default: /* Default is BYTE display */ |
| 275 | 273 | ||
| 276 | acpi_ut_file_printf(file, "%02X ", | 274 | fprintf(file, "%02X ", |
| 277 | buffer[(acpi_size)i + j]); | 275 | buffer[(acpi_size)i + j]); |
| 278 | break; | 276 | break; |
| 279 | 277 | ||
| 280 | case DB_WORD_DISPLAY: | 278 | case DB_WORD_DISPLAY: |
| 281 | 279 | ||
| 282 | ACPI_MOVE_16_TO_32(&temp32, | 280 | ACPI_MOVE_16_TO_32(&temp32, |
| 283 | &buffer[(acpi_size)i + j]); | 281 | &buffer[(acpi_size)i + j]); |
| 284 | acpi_ut_file_printf(file, "%04X ", temp32); | 282 | fprintf(file, "%04X ", temp32); |
| 285 | break; | 283 | break; |
| 286 | 284 | ||
| 287 | case DB_DWORD_DISPLAY: | 285 | case DB_DWORD_DISPLAY: |
| 288 | 286 | ||
| 289 | ACPI_MOVE_32_TO_32(&temp32, | 287 | ACPI_MOVE_32_TO_32(&temp32, |
| 290 | &buffer[(acpi_size)i + j]); | 288 | &buffer[(acpi_size)i + j]); |
| 291 | acpi_ut_file_printf(file, "%08X ", temp32); | 289 | fprintf(file, "%08X ", temp32); |
| 292 | break; | 290 | break; |
| 293 | 291 | ||
| 294 | case DB_QWORD_DISPLAY: | 292 | case DB_QWORD_DISPLAY: |
| 295 | 293 | ||
| 296 | ACPI_MOVE_32_TO_32(&temp32, | 294 | ACPI_MOVE_32_TO_32(&temp32, |
| 297 | &buffer[(acpi_size)i + j]); | 295 | &buffer[(acpi_size)i + j]); |
| 298 | acpi_ut_file_printf(file, "%08X", temp32); | 296 | fprintf(file, "%08X", temp32); |
| 299 | 297 | ||
| 300 | ACPI_MOVE_32_TO_32(&temp32, | 298 | ACPI_MOVE_32_TO_32(&temp32, |
| 301 | &buffer[(acpi_size)i + j + | 299 | &buffer[(acpi_size)i + j + |
| 302 | 4]); | 300 | 4]); |
| 303 | acpi_ut_file_printf(file, "%08X ", temp32); | 301 | fprintf(file, "%08X ", temp32); |
| 304 | break; | 302 | break; |
| 305 | } | 303 | } |
| 306 | 304 | ||
| @@ -311,24 +309,24 @@ acpi_ut_dump_buffer_to_file(ACPI_FILE file, | |||
| 311 | * Print the ASCII equivalent characters but watch out for the bad | 309 | * Print the ASCII equivalent characters but watch out for the bad |
| 312 | * unprintable ones (printable chars are 0x20 through 0x7E) | 310 | * unprintable ones (printable chars are 0x20 through 0x7E) |
| 313 | */ | 311 | */ |
| 314 | acpi_ut_file_printf(file, " "); | 312 | fprintf(file, " "); |
| 315 | for (j = 0; j < 16; j++) { | 313 | for (j = 0; j < 16; j++) { |
| 316 | if (i + j >= count) { | 314 | if (i + j >= count) { |
| 317 | acpi_ut_file_printf(file, "\n"); | 315 | fprintf(file, "\n"); |
| 318 | return; | 316 | return; |
| 319 | } | 317 | } |
| 320 | 318 | ||
| 321 | buf_char = buffer[(acpi_size)i + j]; | 319 | buf_char = buffer[(acpi_size)i + j]; |
| 322 | if (isprint(buf_char)) { | 320 | if (isprint(buf_char)) { |
| 323 | acpi_ut_file_printf(file, "%c", buf_char); | 321 | fprintf(file, "%c", buf_char); |
| 324 | } else { | 322 | } else { |
| 325 | acpi_ut_file_printf(file, "."); | 323 | fprintf(file, "."); |
| 326 | } | 324 | } |
| 327 | } | 325 | } |
| 328 | 326 | ||
| 329 | /* Done with that line. */ | 327 | /* Done with that line. */ |
| 330 | 328 | ||
| 331 | acpi_ut_file_printf(file, "\n"); | 329 | fprintf(file, "\n"); |
| 332 | i += 16; | 330 | i += 16; |
| 333 | } | 331 | } |
| 334 | 332 | ||
diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c index 84c08539117d..005a4a2125a5 100644 --- a/drivers/acpi/acpica/utdebug.c +++ b/drivers/acpi/acpica/utdebug.c | |||
| @@ -646,7 +646,7 @@ void ACPI_INTERNAL_VAR_XFACE acpi_log_error(const char *format, ...) | |||
| 646 | va_list args; | 646 | va_list args; |
| 647 | 647 | ||
| 648 | va_start(args, format); | 648 | va_start(args, format); |
| 649 | (void)acpi_ut_file_vprintf(ACPI_FILE_ERR, format, args); | 649 | (void)vfprintf(ACPI_FILE_ERR, format, args); |
| 650 | va_end(args); | 650 | va_end(args); |
| 651 | } | 651 | } |
| 652 | 652 | ||
diff --git a/drivers/acpi/acpica/utprint.c b/drivers/acpi/acpica/utprint.c index dd084cf52502..13b861790896 100644 --- a/drivers/acpi/acpica/utprint.c +++ b/drivers/acpi/acpica/utprint.c | |||
| @@ -336,7 +336,7 @@ static char *acpi_ut_format_number(char *string, | |||
| 336 | 336 | ||
| 337 | /******************************************************************************* | 337 | /******************************************************************************* |
| 338 | * | 338 | * |
| 339 | * FUNCTION: acpi_ut_vsnprintf | 339 | * FUNCTION: vsnprintf |
| 340 | * | 340 | * |
| 341 | * PARAMETERS: string - String with boundary | 341 | * PARAMETERS: string - String with boundary |
| 342 | * size - Boundary of the string | 342 | * size - Boundary of the string |
| @@ -349,9 +349,7 @@ static char *acpi_ut_format_number(char *string, | |||
| 349 | * | 349 | * |
| 350 | ******************************************************************************/ | 350 | ******************************************************************************/ |
| 351 | 351 | ||
| 352 | int | 352 | int vsnprintf(char *string, acpi_size size, const char *format, va_list args) |
| 353 | acpi_ut_vsnprintf(char *string, | ||
| 354 | acpi_size size, const char *format, va_list args) | ||
| 355 | { | 353 | { |
| 356 | u8 base; | 354 | u8 base; |
| 357 | u8 type; | 355 | u8 type; |
| @@ -586,7 +584,7 @@ acpi_ut_vsnprintf(char *string, | |||
| 586 | 584 | ||
| 587 | /******************************************************************************* | 585 | /******************************************************************************* |
| 588 | * | 586 | * |
| 589 | * FUNCTION: acpi_ut_snprintf | 587 | * FUNCTION: snprintf |
| 590 | * | 588 | * |
| 591 | * PARAMETERS: string - String with boundary | 589 | * PARAMETERS: string - String with boundary |
| 592 | * size - Boundary of the string | 590 | * size - Boundary of the string |
| @@ -598,13 +596,38 @@ acpi_ut_vsnprintf(char *string, | |||
| 598 | * | 596 | * |
| 599 | ******************************************************************************/ | 597 | ******************************************************************************/ |
| 600 | 598 | ||
| 601 | int acpi_ut_snprintf(char *string, acpi_size size, const char *format, ...) | 599 | int snprintf(char *string, acpi_size size, const char *format, ...) |
| 602 | { | 600 | { |
| 603 | va_list args; | 601 | va_list args; |
| 604 | int length; | 602 | int length; |
| 605 | 603 | ||
| 606 | va_start(args, format); | 604 | va_start(args, format); |
| 607 | length = acpi_ut_vsnprintf(string, size, format, args); | 605 | length = vsnprintf(string, size, format, args); |
| 606 | va_end(args); | ||
| 607 | |||
| 608 | return (length); | ||
| 609 | } | ||
| 610 | |||
| 611 | /******************************************************************************* | ||
| 612 | * | ||
| 613 | * FUNCTION: sprintf | ||
| 614 | * | ||
| 615 | * PARAMETERS: string - String with boundary | ||
| 616 | * Format, ... - Standard printf format | ||
| 617 | * | ||
| 618 | * RETURN: Number of bytes actually written. | ||
| 619 | * | ||
| 620 | * DESCRIPTION: Formatted output to a string. | ||
| 621 | * | ||
| 622 | ******************************************************************************/ | ||
| 623 | |||
| 624 | int sprintf(char *string, const char *format, ...) | ||
| 625 | { | ||
| 626 | va_list args; | ||
| 627 | int length; | ||
| 628 | |||
| 629 | va_start(args, format); | ||
| 630 | length = vsnprintf(string, ACPI_UINT32_MAX, format, args); | ||
| 608 | va_end(args); | 631 | va_end(args); |
| 609 | 632 | ||
| 610 | return (length); | 633 | return (length); |
| @@ -613,7 +636,60 @@ int acpi_ut_snprintf(char *string, acpi_size size, const char *format, ...) | |||
| 613 | #ifdef ACPI_APPLICATION | 636 | #ifdef ACPI_APPLICATION |
| 614 | /******************************************************************************* | 637 | /******************************************************************************* |
| 615 | * | 638 | * |
| 616 | * FUNCTION: acpi_ut_file_vprintf | 639 | * FUNCTION: vprintf |
| 640 | * | ||
| 641 | * PARAMETERS: format - Standard printf format | ||
| 642 | * args - Argument list | ||
| 643 | * | ||
| 644 | * RETURN: Number of bytes actually written. | ||
| 645 | * | ||
| 646 | * DESCRIPTION: Formatted output to stdout using argument list pointer. | ||
| 647 | * | ||
| 648 | ******************************************************************************/ | ||
| 649 | |||
| 650 | int vprintf(const char *format, va_list args) | ||
| 651 | { | ||
| 652 | acpi_cpu_flags flags; | ||
| 653 | int length; | ||
| 654 | |||
| 655 | flags = acpi_os_acquire_lock(acpi_gbl_print_lock); | ||
| 656 | length = vsnprintf(acpi_gbl_print_buffer, | ||
| 657 | sizeof(acpi_gbl_print_buffer), format, args); | ||
| 658 | |||
| 659 | (void)acpi_os_write_file(ACPI_FILE_OUT, acpi_gbl_print_buffer, length, | ||
| 660 | 1); | ||
| 661 | acpi_os_release_lock(acpi_gbl_print_lock, flags); | ||
| 662 | |||
| 663 | return (length); | ||
| 664 | } | ||
| 665 | |||
| 666 | /******************************************************************************* | ||
| 667 | * | ||
| 668 | * FUNCTION: printf | ||
| 669 | * | ||
| 670 | * PARAMETERS: Format, ... - Standard printf format | ||
| 671 | * | ||
| 672 | * RETURN: Number of bytes actually written. | ||
| 673 | * | ||
| 674 | * DESCRIPTION: Formatted output to stdout. | ||
| 675 | * | ||
| 676 | ******************************************************************************/ | ||
| 677 | |||
| 678 | int printf(const char *format, ...) | ||
| 679 | { | ||
| 680 | va_list args; | ||
| 681 | int length; | ||
| 682 | |||
| 683 | va_start(args, format); | ||
| 684 | length = vprintf(format, args); | ||
| 685 | va_end(args); | ||
| 686 | |||
| 687 | return (length); | ||
| 688 | } | ||
| 689 | |||
| 690 | /******************************************************************************* | ||
| 691 | * | ||
| 692 | * FUNCTION: vfprintf | ||
| 617 | * | 693 | * |
| 618 | * PARAMETERS: file - File descriptor | 694 | * PARAMETERS: file - File descriptor |
| 619 | * format - Standard printf format | 695 | * format - Standard printf format |
| @@ -625,14 +701,14 @@ int acpi_ut_snprintf(char *string, acpi_size size, const char *format, ...) | |||
| 625 | * | 701 | * |
| 626 | ******************************************************************************/ | 702 | ******************************************************************************/ |
| 627 | 703 | ||
| 628 | int acpi_ut_file_vprintf(ACPI_FILE file, const char *format, va_list args) | 704 | int vfprintf(FILE * file, const char *format, va_list args) |
| 629 | { | 705 | { |
| 630 | acpi_cpu_flags flags; | 706 | acpi_cpu_flags flags; |
| 631 | int length; | 707 | int length; |
| 632 | 708 | ||
| 633 | flags = acpi_os_acquire_lock(acpi_gbl_print_lock); | 709 | flags = acpi_os_acquire_lock(acpi_gbl_print_lock); |
| 634 | length = acpi_ut_vsnprintf(acpi_gbl_print_buffer, | 710 | length = vsnprintf(acpi_gbl_print_buffer, |
| 635 | sizeof(acpi_gbl_print_buffer), format, args); | 711 | sizeof(acpi_gbl_print_buffer), format, args); |
| 636 | 712 | ||
| 637 | (void)acpi_os_write_file(file, acpi_gbl_print_buffer, length, 1); | 713 | (void)acpi_os_write_file(file, acpi_gbl_print_buffer, length, 1); |
| 638 | acpi_os_release_lock(acpi_gbl_print_lock, flags); | 714 | acpi_os_release_lock(acpi_gbl_print_lock, flags); |
| @@ -642,7 +718,7 @@ int acpi_ut_file_vprintf(ACPI_FILE file, const char *format, va_list args) | |||
| 642 | 718 | ||
| 643 | /******************************************************************************* | 719 | /******************************************************************************* |
| 644 | * | 720 | * |
| 645 | * FUNCTION: acpi_ut_file_printf | 721 | * FUNCTION: fprintf |
| 646 | * | 722 | * |
| 647 | * PARAMETERS: file - File descriptor | 723 | * PARAMETERS: file - File descriptor |
| 648 | * Format, ... - Standard printf format | 724 | * Format, ... - Standard printf format |
| @@ -653,13 +729,13 @@ int acpi_ut_file_vprintf(ACPI_FILE file, const char *format, va_list args) | |||
| 653 | * | 729 | * |
| 654 | ******************************************************************************/ | 730 | ******************************************************************************/ |
| 655 | 731 | ||
| 656 | int acpi_ut_file_printf(ACPI_FILE file, const char *format, ...) | 732 | int fprintf(FILE * file, const char *format, ...) |
| 657 | { | 733 | { |
| 658 | va_list args; | 734 | va_list args; |
| 659 | int length; | 735 | int length; |
| 660 | 736 | ||
| 661 | va_start(args, format); | 737 | va_start(args, format); |
| 662 | length = acpi_ut_file_vprintf(file, format, args); | 738 | length = vfprintf(file, format, args); |
| 663 | va_end(args); | 739 | va_end(args); |
| 664 | 740 | ||
| 665 | return (length); | 741 | return (length); |
