summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLv Zheng <lv.zheng@intel.com>2016-05-23 23:06:54 +0800
committerLv Zheng <lv.zheng@intel.com>2016-06-06 12:58:28 +0800
commit70e41616567106527e9302496ec03a5e70d8cc53 (patch)
tree11d8fdca760bf999375ebd100f11a7028aef8dce
parent831b85c7b5e72e12dbc30df2b04e255e1accddb8 (diff)
downloadacpica-70e41616567106527e9302496ec03a5e70d8cc53.tar.gz
Clib: Add -nostdinc support for EFI layer
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. This patch also converts the entire EFI porting layer to use the standard system Clibrary and implements GNU EFI specific standard Clibrary stdio operations. -fno-builtin is required for GCC to avoid optimization performed printf(). This optimization cannot be automatically disabled by specifying -nostdlib. Please refer to the Link 1 for the details. -iwithprefix include is required to include <stdarg.h> which contains compiler specific implementation of vargs. It is unclear why there is the vargs macros defined for OSPMs that do not have ACPI_USE_SYSTEM_CLIBRARY defined. After applying this patch, this special vargs implementation should also get deleted. Standard C header files shouldn't be included here and there throughout the entire ACPICA code base. This patch corrects some of them. Lv Zheng. Link 1: http://www.ciselant.de/projects/gcc_printf/gcc_printf.html Signed-off-by: Lv Zheng <lv.zheng@intel.com>
-rw-r--r--generate/efi/Makefile.config6
-rw-r--r--generate/efi/acpidump/Makefile2
-rw-r--r--source/common/acfileio.c5
-rw-r--r--source/common/acgetline.c2
-rw-r--r--source/common/cmfsize.c1
-rw-r--r--source/components/debugger/dbfileio.c1
-rw-r--r--source/components/utilities/utbuffer.c26
-rw-r--r--source/components/utilities/utclib.c4
-rw-r--r--source/components/utilities/utdebug.c2
-rw-r--r--source/components/utilities/utpredef.c2
-rw-r--r--source/components/utilities/utprint.c122
-rw-r--r--source/include/acapps.h6
-rw-r--r--source/include/acclib.h57
-rw-r--r--source/include/accommon.h4
-rw-r--r--source/include/acutils.h42
-rw-r--r--source/include/platform/acefi.h34
-rw-r--r--source/include/platform/acenv.h57
-rw-r--r--source/include/platform/acgcc.h4
-rw-r--r--source/include/platform/aclinux.h6
-rw-r--r--source/include/platform/acmsvc.h4
-rw-r--r--source/os_specific/service_layers/osefixf.c2
-rw-r--r--source/tools/acpidump/acpidump.h6
-rw-r--r--source/tools/acpidump/apdump.c4
-rw-r--r--source/tools/acpidump/apfiles.c6
24 files changed, 269 insertions, 136 deletions
diff --git a/generate/efi/Makefile.config b/generate/efi/Makefile.config
index d7872c8ac..6c7c5950b 100644
--- a/generate/efi/Makefile.config
+++ b/generate/efi/Makefile.config
@@ -95,17 +95,23 @@ LD = ld
OBJCOPY = objcopy
CFLAGS = \
+ --save-temps\
+ -nostdinc\
+ -nostdlib\
-std=c99\
-U__linux__\
-U_LINUX\
-D_GNU_EFI\
-D_GNU_SOURCE\
+ -fno-builtin\
+ -iwithprefix include\
-fno-stack-protector\
-fno-strict-aliasing\
-fpic\
-fshort-wchar\
-I$(ACPICA_INCLUDE)
LDFLAGS = \
+ -nostdinc\
-nostdlib\
-znocombreloc\
-Bsymbolic
diff --git a/generate/efi/acpidump/Makefile b/generate/efi/acpidump/Makefile
index d7d5f48f8..672421d6e 100644
--- a/generate/efi/acpidump/Makefile
+++ b/generate/efi/acpidump/Makefile
@@ -38,8 +38,8 @@ OBJECTS = \
$(OBJDIR)/tbxfroot.o\
$(OBJDIR)/utascii.o\
$(OBJDIR)/utbuffer.o\
- $(OBJDIR)/utdebug.o\
$(OBJDIR)/utclib.o\
+ $(OBJDIR)/utdebug.o\
$(OBJDIR)/utexcep.o\
$(OBJDIR)/utglobal.o\
$(OBJDIR)/utmath.o\
diff --git a/source/common/acfileio.c b/source/common/acfileio.c
index c00580fc7..8b7d28360 100644
--- a/source/common/acfileio.c
+++ b/source/common/acfileio.c
@@ -118,7 +118,6 @@
#include "acapps.h"
#include "actables.h"
#include "acutils.h"
-#include <errno.h>
#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("acfileio")
@@ -352,7 +351,7 @@ AcGetOneTableFromFile (
/* Allocate a buffer for the entire table */
- Table = AcpiOsAllocate ((size_t) TableHeader.Length);
+ Table = AcpiOsAllocate ((ACPI_SIZE) TableHeader.Length);
if (!Table)
{
return (AE_NO_MEMORY);
@@ -460,7 +459,7 @@ AcValidateTableHeader (
long TableOffset)
{
ACPI_TABLE_HEADER TableHeader;
- size_t Actual;
+ ACPI_SIZE Actual;
long OriginalOffset;
UINT32 FileSize;
UINT32 i;
diff --git a/source/common/acgetline.c b/source/common/acgetline.c
index dfc065389..a28aaf78d 100644
--- a/source/common/acgetline.c
+++ b/source/common/acgetline.c
@@ -119,8 +119,6 @@
#include "acparser.h"
#include "acdebug.h"
-#include <stdio.h>
-
/*
* This is an os-independent implementation of line-editing services needed
* by the AcpiExec utility. It uses getchar() and putchar() and the existing
diff --git a/source/common/cmfsize.c b/source/common/cmfsize.c
index accdf225b..4d35105cb 100644
--- a/source/common/cmfsize.c
+++ b/source/common/cmfsize.c
@@ -116,7 +116,6 @@
#include "acpi.h"
#include "accommon.h"
#include "acapps.h"
-#include <stdio.h>
#define _COMPONENT ACPI_TOOLS
ACPI_MODULE_NAME ("cmfsize")
diff --git a/source/components/debugger/dbfileio.c b/source/components/debugger/dbfileio.c
index d7942b745..78e06eb86 100644
--- a/source/components/debugger/dbfileio.c
+++ b/source/components/debugger/dbfileio.c
@@ -118,7 +118,6 @@
#include "accommon.h"
#include "acdebug.h"
#include "actables.h"
-#include <stdio.h>
#ifdef ACPI_APPLICATION
#include "acapps.h"
#endif
diff --git a/source/components/utilities/utbuffer.c b/source/components/utilities/utbuffer.c
index 4a50e9e06..fe5c7d505 100644
--- a/source/components/utilities/utbuffer.c
+++ b/source/components/utilities/utbuffer.c
@@ -336,7 +336,7 @@ AcpiUtDumpBufferToFile (
if (!Buffer)
{
- AcpiUtFilePrintf (File, "Null Buffer Pointer in DumpBuffer!\n");
+ fprintf (File, "Null Buffer Pointer in DumpBuffer!\n");
return;
}
@@ -351,7 +351,7 @@ AcpiUtDumpBufferToFile (
{
/* Print current offset */
- AcpiUtFilePrintf (File, "%6.4X: ", (BaseOffset + i));
+ fprintf (File, "%6.4X: ", (BaseOffset + i));
/* Print 16 hex chars */
@@ -361,7 +361,7 @@ AcpiUtDumpBufferToFile (
{
/* Dump fill spaces */
- AcpiUtFilePrintf (File, "%*s", ((Display * 2) + 1), " ");
+ fprintf (File, "%*s", ((Display * 2) + 1), " ");
j += Display;
continue;
}
@@ -371,28 +371,28 @@ AcpiUtDumpBufferToFile (
case DB_BYTE_DISPLAY:
default: /* Default is BYTE display */
- AcpiUtFilePrintf (File, "%02X ", Buffer[(ACPI_SIZE) i + j]);
+ fprintf (File, "%02X ", Buffer[(ACPI_SIZE) i + j]);
break;
case DB_WORD_DISPLAY:
ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
- AcpiUtFilePrintf (File, "%04X ", Temp32);
+ fprintf (File, "%04X ", Temp32);
break;
case DB_DWORD_DISPLAY:
ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
- AcpiUtFilePrintf (File, "%08X ", Temp32);
+ fprintf (File, "%08X ", Temp32);
break;
case DB_QWORD_DISPLAY:
ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
- AcpiUtFilePrintf (File, "%08X", Temp32);
+ fprintf (File, "%08X", Temp32);
ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j + 4]);
- AcpiUtFilePrintf (File, "%08X ", Temp32);
+ fprintf (File, "%08X ", Temp32);
break;
}
@@ -403,29 +403,29 @@ AcpiUtDumpBufferToFile (
* Print the ASCII equivalent characters but watch out for the bad
* unprintable ones (printable chars are 0x20 through 0x7E)
*/
- AcpiUtFilePrintf (File, " ");
+ fprintf (File, " ");
for (j = 0; j < 16; j++)
{
if (i + j >= Count)
{
- AcpiUtFilePrintf (File, "\n");
+ fprintf (File, "\n");
return;
}
BufChar = Buffer[(ACPI_SIZE) i + j];
if (isprint (BufChar))
{
- AcpiUtFilePrintf (File, "%c", BufChar);
+ fprintf (File, "%c", BufChar);
}
else
{
- AcpiUtFilePrintf (File, ".");
+ fprintf (File, ".");
}
}
/* Done with that line. */
- AcpiUtFilePrintf (File, "\n");
+ fprintf (File, "\n");
i += 16;
}
diff --git a/source/components/utilities/utclib.c b/source/components/utilities/utclib.c
index 26fbaf958..7e61b980a 100644
--- a/source/components/utilities/utclib.c
+++ b/source/components/utilities/utclib.c
@@ -163,7 +163,7 @@
ACPI_MODULE_NAME ("utclib")
-#ifndef ACPI_USE_SYSTEM_CLIBRARY /* Entire module */
+#if defined(ACPI_USE_SYSTEM_CLIBRARY) && !defined(ACPI_USE_STANDARD_HEADERS)
/*******************************************************************************
@@ -987,4 +987,4 @@ const UINT8 AcpiGbl_Ctypes[257] = {
};
-#endif /* ACPI_USE_SYSTEM_CLIBRARY */
+#endif /* ACPI_USE_SYSTEM_CLIBRARY && !ACPI_USE_STANDARD_HEADERS */
diff --git a/source/components/utilities/utdebug.c b/source/components/utilities/utdebug.c
index 4d2b306a0..d13c0974e 100644
--- a/source/components/utilities/utdebug.c
+++ b/source/components/utilities/utdebug.c
@@ -804,7 +804,7 @@ AcpiLogError (
va_list Args;
va_start (Args, Format);
- (void) AcpiUtFileVprintf (ACPI_FILE_ERR, Format, Args);
+ (void) vfprintf (ACPI_FILE_ERR, Format, Args);
va_end (Args);
}
diff --git a/source/components/utilities/utpredef.c b/source/components/utilities/utpredef.c
index 01196bb03..a97064c7a 100644
--- a/source/components/utilities/utpredef.c
+++ b/source/components/utilities/utpredef.c
@@ -268,8 +268,6 @@ AcpiUtGetExpectedReturnTypes (
******************************************************************************/
#if (defined ACPI_ASL_COMPILER || defined ACPI_HELP_APP)
-#include <stdio.h>
-#include <string.h>
/* Local prototypes */
diff --git a/source/components/utilities/utprint.c b/source/components/utilities/utprint.c
index 5ca859ec4..ec7c0cce4 100644
--- a/source/components/utilities/utprint.c
+++ b/source/components/utilities/utprint.c
@@ -120,6 +120,8 @@
ACPI_MODULE_NAME ("utprint")
+#if defined(ACPI_USE_SYSTEM_CLIBRARY) && !defined(ACPI_USE_STANDARD_HEADERS)
+
#define ACPI_FORMAT_SIGN 0x01
#define ACPI_FORMAT_SIGN_PLUS 0x02
#define ACPI_FORMAT_SIGN_PLUS_SPACE 0x04
@@ -488,7 +490,7 @@ AcpiUtFormatNumber (
/*******************************************************************************
*
- * FUNCTION: AcpiUtVsnprintf
+ * FUNCTION: vsnprintf
*
* PARAMETERS: String - String with boundary
* Size - Boundary of the string
@@ -502,7 +504,7 @@ AcpiUtFormatNumber (
******************************************************************************/
int
-AcpiUtVsnprintf (
+vsnprintf (
char *String,
ACPI_SIZE Size,
const char *Format,
@@ -785,7 +787,7 @@ AcpiUtVsnprintf (
/*******************************************************************************
*
- * FUNCTION: AcpiUtSnprintf
+ * FUNCTION: snprintf
*
* PARAMETERS: String - String with boundary
* Size - Boundary of the string
@@ -798,7 +800,7 @@ AcpiUtVsnprintf (
******************************************************************************/
int
-AcpiUtSnprintf (
+snprintf (
char *String,
ACPI_SIZE Size,
const char *Format,
@@ -809,7 +811,38 @@ AcpiUtSnprintf (
va_start (Args, Format);
- Length = AcpiUtVsnprintf (String, Size, Format, Args);
+ Length = vsnprintf (String, Size, Format, Args);
+ va_end (Args);
+
+ return (Length);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: sprintf
+ *
+ * PARAMETERS: String - String with boundary
+ * Format, ... - Standard printf format
+ *
+ * RETURN: Number of bytes actually written.
+ *
+ * DESCRIPTION: Formatted output to a string.
+ *
+ ******************************************************************************/
+
+int
+sprintf (
+ char *String,
+ const char *Format,
+ ...)
+{
+ va_list Args;
+ int Length;
+
+
+ va_start (Args, Format);
+ Length = vsnprintf (String, ACPI_UINT32_MAX, Format, Args);
va_end (Args);
return (Length);
@@ -819,7 +852,69 @@ AcpiUtSnprintf (
#ifdef ACPI_APPLICATION
/*******************************************************************************
*
- * FUNCTION: AcpiUtFileVprintf
+ * FUNCTION: vprintf
+ *
+ * PARAMETERS: Format - Standard printf format
+ * Args - Argument list
+ *
+ * RETURN: Number of bytes actually written.
+ *
+ * DESCRIPTION: Formatted output to stdout using argument list pointer.
+ *
+ ******************************************************************************/
+
+int
+vprintf (
+ const char *Format,
+ va_list Args)
+{
+ ACPI_CPU_FLAGS Flags;
+ int Length;
+
+
+ Flags = AcpiOsAcquireLock (AcpiGbl_PrintLock);
+ Length = vsnprintf (AcpiGbl_PrintBuffer,
+ sizeof (AcpiGbl_PrintBuffer), Format, Args);
+
+ (void) AcpiOsWriteFile (ACPI_FILE_OUT, AcpiGbl_PrintBuffer, Length, 1);
+ AcpiOsReleaseLock (AcpiGbl_PrintLock, Flags);
+
+ return (Length);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: printf
+ *
+ * PARAMETERS: Format, ... - Standard printf format
+ *
+ * RETURN: Number of bytes actually written.
+ *
+ * DESCRIPTION: Formatted output to stdout.
+ *
+ ******************************************************************************/
+
+int
+printf (
+ const char *Format,
+ ...)
+{
+ va_list Args;
+ int Length;
+
+
+ va_start (Args, Format);
+ Length = vprintf (Format, Args);
+ va_end (Args);
+
+ return (Length);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: vfprintf
*
* PARAMETERS: File - File descriptor
* Format - Standard printf format
@@ -832,8 +927,8 @@ AcpiUtSnprintf (
******************************************************************************/
int
-AcpiUtFileVprintf (
- ACPI_FILE File,
+vfprintf (
+ FILE *File,
const char *Format,
va_list Args)
{
@@ -842,7 +937,7 @@ AcpiUtFileVprintf (
Flags = AcpiOsAcquireLock (AcpiGbl_PrintLock);
- Length = AcpiUtVsnprintf (AcpiGbl_PrintBuffer,
+ Length = vsnprintf (AcpiGbl_PrintBuffer,
sizeof (AcpiGbl_PrintBuffer), Format, Args);
(void) AcpiOsWriteFile (File, AcpiGbl_PrintBuffer, Length, 1);
@@ -854,7 +949,7 @@ AcpiUtFileVprintf (
/*******************************************************************************
*
- * FUNCTION: AcpiUtFilePrintf
+ * FUNCTION: fprintf
*
* PARAMETERS: File - File descriptor
* Format, ... - Standard printf format
@@ -866,8 +961,8 @@ AcpiUtFileVprintf (
******************************************************************************/
int
-AcpiUtFilePrintf (
- ACPI_FILE File,
+fprintf (
+ FILE *File,
const char *Format,
...)
{
@@ -876,9 +971,10 @@ AcpiUtFilePrintf (
va_start (Args, Format);
- Length = AcpiUtFileVprintf (File, Format, Args);
+ Length = vfprintf (File, Format, Args);
va_end (Args);
return (Length);
}
#endif
+#endif /* ACPI_USE_SYSTEM_CLIBRARY && !ACPI_USE_STANDARD_HEADERS */
diff --git a/source/include/acapps.h b/source/include/acapps.h
index b8ab5a3c6..8699dcbba 100644
--- a/source/include/acapps.h
+++ b/source/include/acapps.h
@@ -116,12 +116,6 @@
#ifndef _ACAPPS
#define _ACAPPS
-#include <stdio.h>
-
-#ifdef _MSC_VER /* disable some level-4 warnings */
-#pragma warning(disable:4100) /* warning C4100: unreferenced formal parameter */
-#endif
-
/* Common info for tool signons */
#define ACPICA_NAME "Intel ACPI Component Architecture"
diff --git a/source/include/acclib.h b/source/include/acclib.h
index 267c73d25..46919656b 100644
--- a/source/include/acclib.h
+++ b/source/include/acclib.h
@@ -236,4 +236,61 @@ int
toupper (
int c);
+/*
+ * utprint - printf/vprintf output functions
+ */
+const char *
+AcpiUtScanNumber (
+ const char *String,
+ UINT64 *NumberPtr);
+
+const char *
+AcpiUtPrintNumber (
+ char *String,
+ UINT64 Number);
+
+int
+vsnprintf (
+ char *String,
+ ACPI_SIZE Size,
+ const char *Format,
+ va_list Args);
+
+int
+snprintf (
+ char *String,
+ ACPI_SIZE Size,
+ const char *Format,
+ ...);
+
+int
+sprintf (
+ char *String,
+ const char *Format,
+ ...);
+
+#ifdef ACPI_APPLICATION
+int
+vprintf (
+ const char *Format,
+ va_list Args);
+
+int
+printf (
+ const char *Format,
+ ...);
+
+int
+vfprintf (
+ FILE *File,
+ const char *Format,
+ va_list Args);
+
+int
+fprintf (
+ FILE *File,
+ const char *Format,
+ ...);
+#endif
+
#endif /* _ACCLIB_H */
diff --git a/source/include/accommon.h b/source/include/accommon.h
index 76f76d62f..7e398b590 100644
--- a/source/include/accommon.h
+++ b/source/include/accommon.h
@@ -131,9 +131,9 @@
#include "acglobal.h" /* All global variables */
#include "achware.h" /* Hardware defines and interfaces */
#include "acutils.h" /* Utility interfaces */
-#ifndef ACPI_USE_SYSTEM_CLIBRARY
+#if defined(ACPI_USE_SYSTEM_CLIBRARY) && !defined(ACPI_USE_STANDARD_HEADERS)
#include "acclib.h" /* C library interfaces */
-#endif /* !ACPI_USE_SYSTEM_CLIBRARY */
+#endif /* ACPI_USE_SYSTEM_CLIBRARY && !ACPI_USE_STANDARD_HEADERS */
#endif /* __ACCOMMON_H__ */
diff --git a/source/include/acutils.h b/source/include/acutils.h
index 3fdca4599..358d1c8b7 100644
--- a/source/include/acutils.h
+++ b/source/include/acutils.h
@@ -1140,48 +1140,6 @@ AcpiAhMatchUuid (
/*
- * utprint - printf/vprintf output functions
- */
-const char *
-AcpiUtScanNumber (
- const char *String,
- UINT64 *NumberPtr);
-
-const char *
-AcpiUtPrintNumber (
- char *String,
- UINT64 Number);
-
-int
-AcpiUtVsnprintf (
- char *String,
- ACPI_SIZE Size,
- const char *Format,
- va_list Args);
-
-int
-AcpiUtSnprintf (
- char *String,
- ACPI_SIZE Size,
- const char *Format,
- ...);
-
-#ifdef ACPI_APPLICATION
-int
-AcpiUtFileVprintf (
- ACPI_FILE File,
- const char *Format,
- va_list Args);
-
-int
-AcpiUtFilePrintf (
- ACPI_FILE File,
- const char *Format,
- ...);
-#endif
-
-
-/*
* utuuid -- UUID support functions
*/
#if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP || defined ACPI_HELP_APP)
diff --git a/source/include/platform/acefi.h b/source/include/platform/acefi.h
index a252b2cd9..b251c1504 100644
--- a/source/include/platform/acefi.h
+++ b/source/include/platform/acefi.h
@@ -116,12 +116,6 @@
#ifndef __ACEFI_H__
#define __ACEFI_H__
-#include <stdarg.h>
-#if defined(_GNU_EFI)
-#include <stdint.h>
-#include <unistd.h>
-#endif
-
#if defined(__x86_64__)
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
#define USE_MS_ABI 1
@@ -136,16 +130,6 @@
#define EFIAPI
#endif
-typedef uint8_t UINT8;
-typedef uint16_t UINT16;
-typedef int16_t INT16;
-typedef uint32_t UINT32;
-typedef int32_t INT32;
-typedef uint64_t UINT64;
-typedef int64_t INT64;
-typedef uint8_t BOOLEAN;
-typedef uint16_t CHAR16;
-
#define VOID void
#if defined(__ia64__) || defined(__x86_64__)
@@ -166,8 +150,8 @@ typedef uint16_t CHAR16;
#endif
-typedef uint64_t UINTN;
-typedef int64_t INTN;
+#define UINTN uint64_t
+#define INTN int64_t
#define EFIERR(a) (0x8000000000000000 | a)
@@ -176,13 +160,14 @@ typedef int64_t INTN;
#define ACPI_MACHINE_WIDTH 32
#define ACPI_USE_NATIVE_DIVIDE
-typedef uint32_t UINTN;
-typedef int32_t INTN;
+#define UINTN uint32_t
+#define INTN int32_t
#define EFIERR(a) (0x80000000 | a)
#endif
+#define CHAR16 uint16_t
#ifdef USE_EFI_FUNCTION_WRAPPER
#define __VA_NARG__(...) \
@@ -306,10 +291,9 @@ UINT64 efi_call10(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3,
#include "acgcc.h"
-#undef ACPI_USE_SYSTEM_CLIBRARY
#undef ACPI_USE_STANDARD_HEADERS
#undef ACPI_USE_NATIVE_DIVIDE
-#define ACPI_USE_SYSTEM_INTTYPES
+#undef ACPI_USE_SYSTEM_INTTYPES
/*
* Math helpers
@@ -340,8 +324,8 @@ struct _EFI_SYSTEM_TABLE;
extern struct _EFI_SYSTEM_TABLE *ST;
extern struct _EFI_BOOT_SERVICES *BS;
-#define ACPI_FILE struct _SIMPLE_TEXT_OUTPUT_INTERFACE *
-#define ACPI_FILE_OUT ST->ConOut
-#define ACPI_FILE_ERR ST->ConOut
+#define FILE struct _SIMPLE_TEXT_OUTPUT_INTERFACE
+#define stdout ST->ConOut
+#define stderr ST->ConOut
#endif /* __ACEFI_H__ */
diff --git a/source/include/platform/acenv.h b/source/include/platform/acenv.h
index 41022a7e4..878be8c12 100644
--- a/source/include/platform/acenv.h
+++ b/source/include/platform/acenv.h
@@ -422,12 +422,47 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
+#ifdef ACPI_APPLICATION
+#include <stdio.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#endif
-#endif /* ACPI_USE_STANDARD_HEADERS */
+#else /* ACPI_USE_STANDARD_HEADERS */
-/* We will be linking to the standard Clib functions */
+#ifdef ACPI_USE_COMPILER_VA
-#else
+/*
+ * We will be linking to the standard Clib functions, but stdarg.h is
+ * compiler specific, this works for linux kernel.
+ */
+#include <stdarg.h>
+
+#else /* ACPI_USE_COMPILER_VA */
+
+#ifndef va_arg
+
+#ifndef _VALIST
+#define _VALIST
+typedef char *va_list;
+#endif /* _VALIST */
+
+/* Storage alignment properties */
+
+#define _AUPBND (sizeof (ACPI_NATIVE_INT) - 1)
+#define _ADNBND (sizeof (ACPI_NATIVE_INT) - 1)
+
+/* Variable argument list macro definitions */
+
+#define _Bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd)))
+#define va_arg(ap, T) (*(T *)(((ap) += (_Bnd (T, _AUPBND))) - (_Bnd (T,_ADNBND))))
+#define va_end(ap) (ap = (va_list) NULL)
+#define va_start(ap, A) (void) ((ap) = (((char *) &(A)) + (_Bnd (A,_AUPBND))))
+
+#endif /* va_arg */
+
+#endif /* ACPI_USE_COMPILER_VA */
/******************************************************************************
*
@@ -435,6 +470,19 @@
*
*****************************************************************************/
+typedef signed char int8_t;
+typedef short int int16_t;
+typedef int int32_t;
+typedef unsigned char uint8_t;
+typedef unsigned short int uint16_t;
+typedef unsigned int uint32_t;
+typedef COMPILER_DEPENDENT_INT64 int64_t;
+typedef COMPILER_DEPENDENT_UINT64 uint64_t;
+
+#endif /* ACPI_USE_STANDARD_HEADERS */
+
+#else /* ACPI_USE_SYSTEM_CLIBRARY */
+
/*
* Use local definitions of C library macros and functions. These function
* implementations may not be as efficient as an inline or assembly code
@@ -466,9 +514,7 @@ typedef char *va_list;
#endif /* ACPI_USE_SYSTEM_CLIBRARY */
-#ifndef ACPI_FILE
#ifdef ACPI_APPLICATION
-#include <stdio.h>
#define ACPI_FILE FILE *
#define ACPI_FILE_OUT stdout
#define ACPI_FILE_ERR stderr
@@ -477,6 +523,5 @@ typedef char *va_list;
#define ACPI_FILE_OUT NULL
#define ACPI_FILE_ERR NULL
#endif /* ACPI_APPLICATION */
-#endif /* ACPI_FILE */
#endif /* __ACENV_H__ */
diff --git a/source/include/platform/acgcc.h b/source/include/platform/acgcc.h
index 3d36a38a3..773bd8959 100644
--- a/source/include/platform/acgcc.h
+++ b/source/include/platform/acgcc.h
@@ -116,6 +116,10 @@
#ifndef __ACGCC_H__
#define __ACGCC_H__
+/* Allow inclusion of stdarg.h */
+
+#define ACPI_USE_COMPILER_VA
+
#define ACPI_INLINE __inline__
/* Function name is used for debug output. Non-ANSI, compiler-dependent */
diff --git a/source/include/platform/aclinux.h b/source/include/platform/aclinux.h
index 912773593..c948f6900 100644
--- a/source/include/platform/aclinux.h
+++ b/source/include/platform/aclinux.h
@@ -245,11 +245,9 @@
#else /* !__KERNEL__ */
-#include <stdarg.h>
-#include <string.h>
-#include <stdlib.h>
-#include <ctype.h>
#include <unistd.h>
+#define ACPI_USE_SYSTEM_CLIBRARY
+#define ACPI_USE_STANDARD_HEADERS
/* Define/disable kernel-specific declarators */
diff --git a/source/include/platform/acmsvc.h b/source/include/platform/acmsvc.h
index 133f449ef..c7cf21bc7 100644
--- a/source/include/platform/acmsvc.h
+++ b/source/include/platform/acmsvc.h
@@ -225,6 +225,10 @@
#pragma warning( disable : 4295 ) /* needed for acpredef.h array */
#endif
+#ifdef _MSC_VER /* disable some level-4 warnings */
+#pragma warning(disable:4100) /* warning C4100: unreferenced formal parameter */
+#endif
+
/* Debug support. */
diff --git a/source/os_specific/service_layers/osefixf.c b/source/os_specific/service_layers/osefixf.c
index fa111b508..1947197e1 100644
--- a/source/os_specific/service_layers/osefixf.c
+++ b/source/os_specific/service_layers/osefixf.c
@@ -827,7 +827,7 @@ AcpiOsVprintf (
va_list Args)
{
- (void) AcpiUtFileVprintf (ACPI_FILE_OUT, Format, Args);
+ (void) vfprintf (ACPI_FILE_OUT, Format, Args);
}
diff --git a/source/tools/acpidump/acpidump.h b/source/tools/acpidump/acpidump.h
index 76843da28..b15de1d86 100644
--- a/source/tools/acpidump/acpidump.h
+++ b/source/tools/acpidump/acpidump.h
@@ -128,12 +128,6 @@
#include "accommon.h"
#include "actables.h"
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/stat.h>
-
-
/* Globals */
EXTERN BOOLEAN INIT_GLOBAL (Gbl_SummaryMode, FALSE);
diff --git a/source/tools/acpidump/apdump.c b/source/tools/acpidump/apdump.c
index 783060080..bb5bd545b 100644
--- a/source/tools/acpidump/apdump.c
+++ b/source/tools/acpidump/apdump.c
@@ -295,13 +295,13 @@ ApDumpTableBuffer (
* Note: simplest to just always emit a 64-bit address. AcpiXtract
* utility can handle this.
*/
- AcpiUtFilePrintf (Gbl_OutputFile, "%4.4s @ 0x%8.8X%8.8X\n",
+ fprintf (Gbl_OutputFile, "%4.4s @ 0x%8.8X%8.8X\n",
Table->Signature, ACPI_FORMAT_UINT64 (Address));
AcpiUtDumpBufferToFile (Gbl_OutputFile,
ACPI_CAST_PTR (UINT8, Table), TableLength,
DB_BYTE_DISPLAY, 0);
- AcpiUtFilePrintf (Gbl_OutputFile, "\n");
+ fprintf (Gbl_OutputFile, "\n");
return (0);
}
diff --git a/source/tools/acpidump/apfiles.c b/source/tools/acpidump/apfiles.c
index 9394e98cf..04d9cf250 100644
--- a/source/tools/acpidump/apfiles.c
+++ b/source/tools/acpidump/apfiles.c
@@ -225,7 +225,7 @@ ApWriteToBinaryFile (
char Filename[ACPI_NAME_SIZE + 16];
char InstanceStr [16];
ACPI_FILE File;
- size_t Actual;
+ ACPI_SIZE Actual;
UINT32 TableLength;
@@ -254,7 +254,7 @@ ApWriteToBinaryFile (
if (Instance > 0)
{
- AcpiUtSnprintf (InstanceStr, sizeof (InstanceStr), "%u", Instance);
+ snprintf (InstanceStr, sizeof (InstanceStr), "%u", Instance);
strcat (Filename, InstanceStr);
}
@@ -311,7 +311,7 @@ ApGetTableFromFile (
ACPI_TABLE_HEADER *Buffer = NULL;
ACPI_FILE File;
UINT32 FileSize;
- size_t Actual;
+ ACPI_SIZE Actual;
/* Must use binary mode */