From 41b152c5f6ec3a5a6e51b4f8f0f90291a5895edc Mon Sep 17 00:00:00 2001 From: darylm503 Date: Mon, 3 Oct 2011 18:54:12 +0000 Subject: StdLib: Improve robustness of stat() and make basename() a public function. AppPkg: Refinements to pyconfig.h and port of getpath.c to EDK II. Signed-off-by: darylm503 Reviewed-by: geekboy15a Reviewed-by: jljusten git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12508 6f19259b-4bc3-4df7-8a09-765794883524 --- StdLib/Include/sys/EfiSysCall.h | 2 +- StdLib/Include/unistd.h | 1 + StdLib/LibC/Uefi/Devices/UefiShell/daShell.c | 4 ++-- StdLib/LibC/Uefi/SysCalls.c | 2 +- StdLib/LibC/Uefi/compat.c | 5 +---- StdLib/StdLib.inc | 23 ++++++++++++++++------- 6 files changed, 22 insertions(+), 15 deletions(-) (limited to 'StdLib') diff --git a/StdLib/Include/sys/EfiSysCall.h b/StdLib/Include/sys/EfiSysCall.h index bfbd14e1c5..1d01328609 100644 --- a/StdLib/Include/sys/EfiSysCall.h +++ b/StdLib/Include/sys/EfiSysCall.h @@ -291,7 +291,7 @@ __BEGIN_DECLS @return **/ - int stat (const char *, void *); + int stat (const char *, struct stat *); /** @param[in] diff --git a/StdLib/Include/unistd.h b/StdLib/Include/unistd.h index 2134f15765..4d738c64b6 100644 --- a/StdLib/Include/unistd.h +++ b/StdLib/Include/unistd.h @@ -39,6 +39,7 @@ pid_t tcgetpgrp(int); char *getpass(const char *); int usleep(useconds_t); unsigned int sleep(unsigned int); +char *basename(char *path); // Networking long gethostid(void); diff --git a/StdLib/LibC/Uefi/Devices/UefiShell/daShell.c b/StdLib/LibC/Uefi/Devices/UefiShell/daShell.c index d0abb8dd5b..de14ef31c5 100644 --- a/StdLib/LibC/Uefi/Devices/UefiShell/daShell.c +++ b/StdLib/LibC/Uefi/Devices/UefiShell/daShell.c @@ -304,14 +304,14 @@ da_ShellStat( } else { Status = RETURN_DEVICE_ERROR; + errno = EIO; } - errno = EFI2errno(Status); EFIerrno = Status; if(FileInfo != NULL) { FreePool(FileInfo); // Release the buffer allocated by the GetInfo function } - return errno? -1 : 0; + return (Status == RETURN_SUCCESS)? 0 : -1; } static diff --git a/StdLib/LibC/Uefi/SysCalls.c b/StdLib/LibC/Uefi/SysCalls.c index d52249b58b..b5079e2c3a 100644 --- a/StdLib/LibC/Uefi/SysCalls.c +++ b/StdLib/LibC/Uefi/SysCalls.c @@ -923,7 +923,7 @@ fstat (int fd, struct stat *statbuf) identify the error. **/ int -stat (const char *path, void *statbuf) +stat (const char *path, struct stat *statbuf) { int fd; int retval = -1; diff --git a/StdLib/LibC/Uefi/compat.c b/StdLib/LibC/Uefi/compat.c index 7f250d15ff..8ce4783a6a 100644 --- a/StdLib/LibC/Uefi/compat.c +++ b/StdLib/LibC/Uefi/compat.c @@ -94,6 +94,7 @@ #include #include #include +#include #ifndef HAVE_GETOPT char *optarg; @@ -138,11 +139,7 @@ getopt(int argc, char **argv, char *args) } #endif -#ifdef WIN32 #define ISPATHSEPARATOR(x) ((x == '/') || (x == '\\')) -#else -#define ISPATHSEPARATOR(x) (x == '/') -#endif #ifndef HAVE_BASENAME #ifndef PATH_MAX diff --git a/StdLib/StdLib.inc b/StdLib/StdLib.inc index 5446ecd35f..c2cf12856b 100644 --- a/StdLib/StdLib.inc +++ b/StdLib/StdLib.inc @@ -4,6 +4,15 @@ # # The including DSC file must DEFINE the EMULATE macro if # the application is to be run in an emulation environment. +# +# Copyright (c) 2011, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. ################################################################ ########## @@ -53,10 +62,12 @@ !ifndef $(EMULATE) # Not running in an Emulation Environment [LibraryClasses.IA32.UEFI_APPLICATION] - TimerLib|PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf + TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf +# TimerLib|PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf [LibraryClasses.X64.UEFI_APPLICATION] - TimerLib|PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf + TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf +# TimerLib|PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf [LibraryClasses.IPF.UEFI_APPLICATION] PalLib|MdePkg/Library/UefiPalLib/UefiPalLib.inf @@ -108,9 +119,9 @@ !ifndef $(EMULATE) # These Build Options are used when building the Standard Libraries to be run # on real hardware. - INTEL:*_*_*_CC_FLAGS = /Qfreestanding - MSFT:*_*_*_CC_FLAGS = /X /Zc:wchar_t - GCC:*_*_*_CC_FLAGS = -nostdinc -nostdlib + INTEL:*_*_*_CC_FLAGS = /Qfreestanding + MSFT:*_*_*_CC_FLAGS = /X /Zc:wchar_t /D NT32dvm + GCC:*_*_*_CC_FLAGS = -nostdinc -nostdlib RVCT:*_*_*_CC_FLAGS = --library_interface=none -J$(WORKSPACE)/StdLib/Include -J$(WORKSPACE)/StdLib/Include/Arm -DNT32dvm ARMGCC:*_*_*_CC_FLAGS = -nostdinc -nostdlib -Wno-unknown-pragmas -Wno-unused -Wno-format-zero-length -DNT32dvm @@ -123,5 +134,3 @@ MSFT:*_*_IA32_CC_FLAGS = /Od /D NT32dvm GCC:*_*_IA32_CC_FLAGS = -O0 -DNT32dvm !endif - - -- cgit v1.2.3