StdLib: Fix some build problems and obscure bugs.
StdLib\
  BsdSocketLib\
    ns_print.c
      Use "%lu" format instead of "%Lu".  A capital 'L' specifies (long double) in print formats.
      Add a cast from char to (unsigned int) to match its sprintf format.
    res_debug.c
      Use "%lu" format instead of "%Lu".  A capital 'L' specifies (long double) in print formats.
  EfiSocketLib\
    Socket.c
      Update copyright & correct formatting
  Include\
    sys\
      EfiCdefs.h
        Update copyright date
        Change type of LONGN and ULONGN to INTN and UINTN, respectively.
      errno.h
        Update copyright date
        Add enum member '__ESUCCESS = 0'
      fcntl.h
        Update copyright date
        Improve comment for O_EXCL
      stat.h
        Update copyright date
        Reorder the S_* flags
        Put the S_* predicate macros in the same order as their flag definitions
        Add a function header comment to the stat() function declaration.
    errno.h
      Update copyright date
      Define new ESUCCESS error code
    wchar.h
      Update copyright date
      Correct the description of the Nptr parameter to the wcstol, wcstoll, wcstoul, and wcstoull functions.
    x86\float.h
      Update copyright date
      Define 'long double' limits for non-Microsoft compilers
  LibC\
    Containers\Queues\Fifo.c
      Rewrite to make more robust and secure (zeros out old data)
    StdLib\realpath.c
      Update copyright date
      Reformat descriptive comment for realpath()
      Add terminating CRLF
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by:  daryl.mcdaniel@intel.com
Reviewed-by:  Erik Bjorge <erik.c.bjorge@intel.com>
Reviewed-by:  Jaben Carsey <Jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16096 6f19259b-4bc3-4df7-8a09-765794883524
			
			
This commit is contained in:
		
				
					committed by
					
						
						darylm503
					
				
			
			
				
	
			
			
			
						parent
						
							9fc9f4d8b4
						
					
				
				
					commit
					0164fc8e76
				
			
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -536,7 +536,7 @@ p_option(u_long option) {
 | 
				
			|||||||
    case RES_DNSRCH:    return "dnsrch";
 | 
					    case RES_DNSRCH:    return "dnsrch";
 | 
				
			||||||
    case RES_INSECURE1: return "insecure1";
 | 
					    case RES_INSECURE1: return "insecure1";
 | 
				
			||||||
    case RES_INSECURE2: return "insecure2";
 | 
					    case RES_INSECURE2: return "insecure2";
 | 
				
			||||||
    default:        sprintf(nbuf, "?0x%Lx?", (u_long)option);
 | 
					    default:        sprintf(nbuf, "?0x%lx?", (u_long)option);
 | 
				
			||||||
                return (nbuf);
 | 
					                return (nbuf);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,10 +5,10 @@
 | 
				
			|||||||
  * Bound - pSocket->PortList is not NULL
 | 
					  * Bound - pSocket->PortList is not NULL
 | 
				
			||||||
  * Listen - AcceptWait event is not NULL
 | 
					  * Listen - AcceptWait event is not NULL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Copyright (c) 2011, Intel Corporation
 | 
					  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
 | 
				
			||||||
  All rights reserved. This program and the accompanying materials
 | 
					  This program and the accompanying materials are licensed and made available under
 | 
				
			||||||
  are licensed and made available under the terms and conditions of the BSD License
 | 
					  the terms and conditions of the BSD License that accompanies this distribution.
 | 
				
			||||||
  which accompanies this distribution.  The full text of the license may be found at
 | 
					  The full text of the license may be found at
 | 
				
			||||||
  http://opensource.org/licenses/bsd-license.php
 | 
					  http://opensource.org/licenses/bsd-license.php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 | 
					  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 | 
				
			||||||
@@ -19,22 +19,22 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  <code><pre>
 | 
					  <code><pre>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                +-------------+   +-------------+   +-------------+   
 | 
					                +---------------+   +-------------+   +-------------+
 | 
				
			||||||
  Service Lists | ::ESL_SERVICE |-->| ESL_SERVICE |-->| ESL_SERVICE |--> NULL (pNext)
 | 
					  Service Lists | ::ESL_SERVICE |-->| ESL_SERVICE |-->| ESL_SERVICE |--> NULL (pNext)
 | 
				
			||||||
                +-------------+   +-------------+   +-------------+   
 | 
					                +---------------+   +-------------+   +-------------+
 | 
				
			||||||
                  ^                       | (pPortList)    |
 | 
					                  ^                       | (pPortList)    |
 | 
				
			||||||
    pUdp4List ^   | pTcp4List             |                |
 | 
					    pUdp4List ^   | pTcp4List             |                |
 | 
				
			||||||
              |   |                       |                |
 | 
					              |   |                       |                |
 | 
				
			||||||
          ^   |   |                       |                |
 | 
					          ^   |   |                       |                |
 | 
				
			||||||
 pIp4List |   |   |                       |                |
 | 
					 pIp4List |   |   |                       |                |
 | 
				
			||||||
        +---------------+                 |                |
 | 
					        +---------------+                 |                |
 | 
				
			||||||
        |   ::ESL_LAYER   |   ::mEslLayer     |                |
 | 
					        | ::ESL_LAYER   | ::mEslLayer     |                |
 | 
				
			||||||
        +---------------+                 |                |
 | 
					        +---------------+                 |                |
 | 
				
			||||||
                  | (pSocketList)         |                |
 | 
					                  | (pSocketList)         |                |
 | 
				
			||||||
    Socket List   V                       V                V
 | 
					    Socket List   V                       V                V
 | 
				
			||||||
                +-------------+   +-------------+   +-------------+   
 | 
					                +---------------+   +-------------+   +-------------+
 | 
				
			||||||
                | ::ESL_SOCKET  |-->|   ::ESL_PORT  |-->|   ESL_PORT  |--> NULL (pLinkSocket)
 | 
					                | ::ESL_SOCKET  |-->| ::ESL_PORT  |-->|   ESL_PORT  |--> NULL (pLinkSocket)
 | 
				
			||||||
                +-------------+   +-------------+   +-------------+   
 | 
					                +---------------+   +-------------+   +-------------+
 | 
				
			||||||
                  |                       |                |
 | 
					                  |                       |                |
 | 
				
			||||||
                  |                       |                V
 | 
					                  |                       |                V
 | 
				
			||||||
                  V                       V               NULL
 | 
					                  V                       V               NULL
 | 
				
			||||||
@@ -53,9 +53,9 @@
 | 
				
			|||||||
                       | `---------------.                  |                |
 | 
					                       | `---------------.                  |                |
 | 
				
			||||||
  pTxOobPacketListHead |                 |                  |                |
 | 
					  pTxOobPacketListHead |                 |                  |                |
 | 
				
			||||||
                       V                 V                  V                V
 | 
					                       V                 V                  V                V
 | 
				
			||||||
                  +------------+    +------------+    +------------+    +------------+
 | 
					                  +--------------+    +------------+    +------------+    +------------+
 | 
				
			||||||
                  | ::ESL_PACKET |    | ESL_PACKET |    | ESL_PACKET |    | ESL_PACKET |
 | 
					                  | ::ESL_PACKET |    | ESL_PACKET |    | ESL_PACKET |    | ESL_PACKET |
 | 
				
			||||||
                  +------------+    +------------+    +------------+    +------------+
 | 
					                  +--------------+    +------------+    +------------+    +------------+
 | 
				
			||||||
                         |                 |                |                |
 | 
					                         |                 |                |                |
 | 
				
			||||||
                         V                 V                V                V
 | 
					                         V                 V                V                V
 | 
				
			||||||
                  +------------+    +------------+    +------------+    +------------+
 | 
					                  +------------+    +------------+    +------------+    +------------+
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,7 +26,7 @@
 | 
				
			|||||||
  All macro definitions in this list must begin with the letter 'E'
 | 
					  All macro definitions in this list must begin with the letter 'E'
 | 
				
			||||||
  and be followed by a digit or an uppercase letter.
 | 
					  and be followed by a digit or an uppercase letter.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
 | 
					  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
 | 
				
			||||||
  This program and the accompanying materials are licensed and made available under
 | 
					  This program and the accompanying materials are licensed and made available under
 | 
				
			||||||
  the terms and conditions of the BSD License that accompanies this distribution.
 | 
					  the terms and conditions of the BSD License that accompanies this distribution.
 | 
				
			||||||
  The full text of the license may be found at
 | 
					  The full text of the license may be found at
 | 
				
			||||||
@@ -46,6 +46,7 @@ extern  RETURN_STATUS   EFIerrno;
 | 
				
			|||||||
// Define error number in terms of the ENUM in <sys/errno.h>
 | 
					// Define error number in terms of the ENUM in <sys/errno.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define ERESTART          -1                      /* restart syscall */
 | 
					#define ERESTART          -1                      /* restart syscall */
 | 
				
			||||||
 | 
					#define ESUCCESS          __ESUCCESS              /* No Problems */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define EMINERRORVAL      __EMINERRORVAL          /*  1   The lowest valid error value */
 | 
					#define EMINERRORVAL      __EMINERRORVAL          /*  1   The lowest valid error value */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,7 +22,7 @@
 | 
				
			|||||||
    This file and its contents are inspired by the <sys/cdefs.h> files in Berkeley
 | 
					    This file and its contents are inspired by the <sys/cdefs.h> files in Berkeley
 | 
				
			||||||
    Unix.  They have been re-implemented to be specific to the EFI environment.
 | 
					    Unix.  They have been re-implemented to be specific to the EFI environment.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
 | 
					    Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
 | 
				
			||||||
    This program and the accompanying materials are licensed and made available under
 | 
					    This program and the accompanying materials are licensed and made available under
 | 
				
			||||||
    the terms and conditions of the BSD License that accompanies this distribution.
 | 
					    the terms and conditions of the BSD License that accompanies this distribution.
 | 
				
			||||||
    The full text of the license may be found at
 | 
					    The full text of the license may be found at
 | 
				
			||||||
@@ -360,8 +360,8 @@ typedef  UINTN   EFI_ULONG_T;
 | 
				
			|||||||
#if defined(__GNUC__)
 | 
					#if defined(__GNUC__)
 | 
				
			||||||
  #if __GNUC_PREREQ__(4,4)
 | 
					  #if __GNUC_PREREQ__(4,4)
 | 
				
			||||||
    /* GCC 4.4 or later */
 | 
					    /* GCC 4.4 or later */
 | 
				
			||||||
    typedef   INT64   LONGN;
 | 
					    typedef   INTN    LONGN;
 | 
				
			||||||
    typedef  UINT64   ULONGN;
 | 
					    typedef  UINTN    ULONGN;
 | 
				
			||||||
  #else
 | 
					  #else
 | 
				
			||||||
    /* minGW gcc variant */
 | 
					    /* minGW gcc variant */
 | 
				
			||||||
    typedef   INT32   LONGN;
 | 
					    typedef   INT32   LONGN;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,7 +7,7 @@
 | 
				
			|||||||
  directives.  These default values are specified as an enum in order to ease
 | 
					  directives.  These default values are specified as an enum in order to ease
 | 
				
			||||||
  the maintenance of the values.
 | 
					  the maintenance of the values.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
 | 
					  Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
 | 
				
			||||||
  This program and the accompanying materials are licensed and made available under
 | 
					  This program and the accompanying materials are licensed and made available under
 | 
				
			||||||
  the terms and conditions of the BSD License that accompanies this distribution.
 | 
					  the terms and conditions of the BSD License that accompanies this distribution.
 | 
				
			||||||
  The full text of the license may be found at
 | 
					  The full text of the license may be found at
 | 
				
			||||||
@@ -22,6 +22,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* Define the error numbers, sequentially, beginning at 1. */
 | 
					/* Define the error numbers, sequentially, beginning at 1. */
 | 
				
			||||||
enum {
 | 
					enum {
 | 
				
			||||||
 | 
					  __ESUCCESS      = 0,              /*  0   For those rare times one needs to say all is OK */
 | 
				
			||||||
  __EMINERRORVAL  = 1,              /* The lowest valid error value */
 | 
					  __EMINERRORVAL  = 1,              /* The lowest valid error value */
 | 
				
			||||||
  __EPERM         = __EMINERRORVAL, /*  1   Operation not permitted */
 | 
					  __EPERM         = __EMINERRORVAL, /*  1   Operation not permitted */
 | 
				
			||||||
  __ENOENT,                         /*  2   No such file or directory */
 | 
					  __ENOENT,                         /*  2   No such file or directory */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,7 @@
 | 
				
			|||||||
    This file includes the definitions for open and fcntl described by POSIX
 | 
					    This file includes the definitions for open and fcntl described by POSIX
 | 
				
			||||||
    for <fcntl.h>; it also includes related kernel definitions.
 | 
					    for <fcntl.h>; it also includes related kernel definitions.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
 | 
					    Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
 | 
				
			||||||
    This program and the accompanying materials are licensed and made
 | 
					    This program and the accompanying materials are licensed and made
 | 
				
			||||||
    available under the terms and conditions of the BSD License which
 | 
					    available under the terms and conditions of the BSD License which
 | 
				
			||||||
    accompanies this distribution.  The full text of the license may be found
 | 
					    accompanies this distribution.  The full text of the license may be found
 | 
				
			||||||
@@ -70,7 +70,7 @@
 | 
				
			|||||||
#define O_APPEND    0x00000008  ///< set append mode
 | 
					#define O_APPEND    0x00000008  ///< set append mode
 | 
				
			||||||
#define O_CREAT     0x00000200  ///< create if nonexistent
 | 
					#define O_CREAT     0x00000200  ///< create if nonexistent
 | 
				
			||||||
#define O_TRUNC     0x00000400  ///< truncate to zero length
 | 
					#define O_TRUNC     0x00000400  ///< truncate to zero length
 | 
				
			||||||
#define O_EXCL      0x00000800  ///< error if already exists
 | 
					#define O_EXCL      0x00000800  ///< Grant EXCLusive access, or error if already exists and O_CREAT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define O_DIRECTORY 0x00001000  ///< error if path is not a directory
 | 
					#define O_DIRECTORY 0x00001000  ///< error if path is not a directory
 | 
				
			||||||
#define O_NOCTTY    0x00002000  ///< Don't make this the controlling TTY
 | 
					#define O_NOCTTY    0x00002000  ///< Don't make this the controlling TTY
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
/** @file
 | 
					/** @file
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
 | 
					    Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
 | 
				
			||||||
    This program and the accompanying materials are licensed and made
 | 
					    This program and the accompanying materials are licensed and made
 | 
				
			||||||
    available under  the terms and conditions of the BSD License that
 | 
					    available under  the terms and conditions of the BSD License that
 | 
				
			||||||
    accompanies this distribution. The full text of the license may be found at
 | 
					    accompanies this distribution. The full text of the license may be found at
 | 
				
			||||||
@@ -119,21 +119,24 @@ struct stat {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#define S_EFISHIFT    20            // LS bit of the UEFI attributes
 | 
					#define S_EFISHIFT    20            // LS bit of the UEFI attributes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define S_IFMT   _S_IFMT
 | 
					#define S_IFMT      _S_IFMT
 | 
				
			||||||
#define S_IFBLK  _S_IFBLK
 | 
					#define S_IFIFO     _S_IFIFO
 | 
				
			||||||
#define S_IFREG  _S_IFREG
 | 
					#define S_IFCHR     _S_IFCHR
 | 
				
			||||||
#define S_IFIFO  _S_IFIFO
 | 
					#define S_IFDIR     _S_IFDIR
 | 
				
			||||||
#define S_IFCHR  _S_IFCHR
 | 
					#define S_IFBLK     _S_IFBLK
 | 
				
			||||||
#define S_IFDIR  _S_IFDIR
 | 
					#define S_IFREG     _S_IFREG
 | 
				
			||||||
#define S_IFSOCK _S_IFSOCK
 | 
					#define S_IFSOCK    _S_IFSOCK
 | 
				
			||||||
 | 
					#define S_ITTY      _S_ITTY
 | 
				
			||||||
#define S_ISDIR(m)  ((m & _S_IFMT) == _S_IFDIR)   ///< directory
 | 
					#define S_IWTTY     _S_IWTTY
 | 
				
			||||||
#define S_ISCHR(m)  ((m & _S_IFMT) == _S_IFCHR)   ///< char special
 | 
					#define S_ICONSOLE  _S_ICONSOLE
 | 
				
			||||||
#define S_ISREG(m)  ((m & _S_IFMT) == _S_IFREG)   ///< regular file
 | 
					 | 
				
			||||||
#define S_ISBLK(m)  ((m & _S_IFMT) == _S_IFBLK)   ///< block special
 | 
					 | 
				
			||||||
#define S_ISSOCK(m) ((m & _S_IFMT) == _S_IFSOCK)  ///< socket
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define S_ISFIFO(m) ((m & _S_IFMT) == _S_IFIFO)   ///< fifo
 | 
					#define S_ISFIFO(m) ((m & _S_IFMT) == _S_IFIFO)   ///< fifo
 | 
				
			||||||
 | 
					#define S_ISCHR(m)  ((m & _S_IFMT) == _S_IFCHR)   ///< char special
 | 
				
			||||||
 | 
					#define S_ISDIR(m)  ((m & _S_IFMT) == _S_IFDIR)   ///< directory
 | 
				
			||||||
 | 
					#define S_ISBLK(m)  ((m & _S_IFMT) == _S_IFBLK)   ///< block special
 | 
				
			||||||
 | 
					#define S_ISREG(m)  ((m & _S_IFMT) == _S_IFREG)   ///< regular file
 | 
				
			||||||
 | 
					#define S_ISSOCK(m) ((m & _S_IFMT) == _S_IFSOCK)  ///< socket
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*  The following three macros have been changed to reflect
 | 
					/*  The following three macros have been changed to reflect
 | 
				
			||||||
    access permissions that better reflect the UEFI FAT file system.
 | 
					    access permissions that better reflect the UEFI FAT file system.
 | 
				
			||||||
@@ -191,8 +194,18 @@ __BEGIN_DECLS
 | 
				
			|||||||
  **/
 | 
					  **/
 | 
				
			||||||
  int     lstat (const char *, struct stat *);
 | 
					  int     lstat (const char *, struct stat *);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					/** Obtains information about the file pointed to by path.
 | 
				
			||||||
  **/
 | 
					
 | 
				
			||||||
 | 
					    Opens the file pointed to by path, calls _EFI_FileInfo with the file's handle,
 | 
				
			||||||
 | 
					    then closes the file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @param[in]    path      Path to the file to obtain information about.
 | 
				
			||||||
 | 
					    @param[out]   statbuf   Buffer in which the file status is put.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @retval    0  Successful Completion.
 | 
				
			||||||
 | 
					    @retval   -1  An error has occurred and errno has been set to
 | 
				
			||||||
 | 
					                  identify the error.
 | 
				
			||||||
 | 
					**/
 | 
				
			||||||
  int     stat  (const char *, struct stat *);
 | 
					  int     stat  (const char *, struct stat *);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -150,7 +150,7 @@
 | 
				
			|||||||
              - WEOF might not be negative.
 | 
					              - WEOF might not be negative.
 | 
				
			||||||
              - mbstate_t objects are not intended to be inspected by programs.
 | 
					              - mbstate_t objects are not intended to be inspected by programs.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
 | 
					    Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
 | 
				
			||||||
    This program and the accompanying materials are licensed and made available under
 | 
					    This program and the accompanying materials are licensed and made available under
 | 
				
			||||||
    the terms and conditions of the BSD License that accompanies this distribution.
 | 
					    the terms and conditions of the BSD License that accompanies this distribution.
 | 
				
			||||||
    The full text of the license may be found at
 | 
					    The full text of the license may be found at
 | 
				
			||||||
@@ -1089,7 +1089,7 @@ by the value of base, and a final wide string of one or more unrecognized wide
 | 
				
			|||||||
characters, including the terminating null wide character of the input wide string. Then,
 | 
					characters, including the terminating null wide character of the input wide string. Then,
 | 
				
			||||||
they attempt to convert the subject sequence to an integer, and return the result.
 | 
					they attempt to convert the subject sequence to an integer, and return the result.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @param[in]  Nptr    Pointer to the string to convert to a floating-point value.
 | 
					    @param[in]  Nptr    Pointer to the string to convert.
 | 
				
			||||||
    @param[in]  EndPtr  Optional pointer to an object in which to store a pointer
 | 
					    @param[in]  EndPtr  Optional pointer to an object in which to store a pointer
 | 
				
			||||||
                        to the final wide string.
 | 
					                        to the final wide string.
 | 
				
			||||||
    @param[in]  Base    Base, 0 to 36, of the value represented by the string
 | 
					    @param[in]  Base    Base, 0 to 36, of the value represented by the string
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
/** @file
 | 
					/** @file
 | 
				
			||||||
    Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
 | 
					    Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
 | 
				
			||||||
    This program and the accompanying materials are licensed and made available under
 | 
					    This program and the accompanying materials are licensed and made available under
 | 
				
			||||||
    the terms and conditions of the BSD License that accompanies this distribution.
 | 
					    the terms and conditions of the BSD License that accompanies this distribution.
 | 
				
			||||||
    The full text of the license may be found at
 | 
					    The full text of the license may be found at
 | 
				
			||||||
@@ -13,22 +13,22 @@
 | 
				
			|||||||
#ifndef _X86_FLOAT_H_
 | 
					#ifndef _X86_FLOAT_H_
 | 
				
			||||||
#define _X86_FLOAT_H_
 | 
					#define _X86_FLOAT_H_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 0   /* Force all compilers to have the same limits */
 | 
					/* long double and double are the same in Microsoft compilers.
 | 
				
			||||||
/* long double and double are the same in Microsoft compilers. */
 | 
					    In GCC long double is fully supported.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
#if !defined(_MSC_VER)        /* Non-Microsoft compiler specifics. */
 | 
					#if !defined(_MSC_VER)        /* Non-Microsoft compiler specifics. */
 | 
				
			||||||
  #define LDBL_MANT_DIG 64
 | 
					  #define LDBL_MANT_DIG   64
 | 
				
			||||||
  #define LDBL_EPSILON  1.0842021724855044340E-19L
 | 
					  #define LDBL_EPSILON    1.0842021724855044340E-19L
 | 
				
			||||||
  #define LDBL_DIG  18
 | 
					  #define LDBL_DIG        18
 | 
				
			||||||
  #define LDBL_MIN_EXP  (-16381)
 | 
					  #define LDBL_MIN_EXP    (-16381)
 | 
				
			||||||
  #define LDBL_MIN  3.3621031431120935063E-4932L
 | 
					  #define LDBL_MIN        3.3621031431120935063E-4932L
 | 
				
			||||||
  #define LDBL_MIN_10_EXP (-4931)
 | 
					  #define LDBL_MIN_10_EXP (-4931)
 | 
				
			||||||
  #define LDBL_MAX_EXP  16384
 | 
					  #define LDBL_MAX_EXP    16384
 | 
				
			||||||
  #define LDBL_MAX  1.1897314953572317650E+4932L
 | 
					  #define LDBL_MAX        1.1897314953572317650E+4932L
 | 
				
			||||||
  #define LDBL_MAX_10_EXP 4932
 | 
					  #define LDBL_MAX_10_EXP 4932
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  #define DECIMAL_DIG 21
 | 
					  #define DECIMAL_DIG     21
 | 
				
			||||||
#endif  // !defined(_MSC_VER)
 | 
					#endif  // !defined(_MSC_VER)
 | 
				
			||||||
#endif  // if 0
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <sys/float_ieee754.h>
 | 
					#include <sys/float_ieee754.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,7 +15,7 @@
 | 
				
			|||||||
  One element of the FIFO is always reserved as the "terminator" element.  Thus,
 | 
					  One element of the FIFO is always reserved as the "terminator" element.  Thus,
 | 
				
			||||||
  the capacity of a FIFO is actually NumElements-1.
 | 
					  the capacity of a FIFO is actually NumElements-1.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
 | 
					  Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>
 | 
				
			||||||
  This program and the accompanying materials are licensed and made available
 | 
					  This program and the accompanying materials are licensed and made available
 | 
				
			||||||
  under the terms and conditions of the BSD License which accompanies this
 | 
					  under the terms and conditions of the BSD License which accompanies this
 | 
				
			||||||
  distribution.  The full text of the license may be found at
 | 
					  distribution.  The full text of the license may be found at
 | 
				
			||||||
@@ -102,10 +102,10 @@ FIFO_FreeSpace (
 | 
				
			|||||||
  WDex = Self->WriteIndex;
 | 
					  WDex = Self->WriteIndex;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if(RDex <= WDex) {
 | 
					  if(RDex <= WDex) {
 | 
				
			||||||
    Count = Self->NumElements - ((WDex - RDex) - 1);
 | 
					    Count = (Self->NumElements - (WDex - RDex)) - 1;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else {
 | 
					  else {
 | 
				
			||||||
    Count = (RDex - WDex);
 | 
					    Count = (RDex - WDex)-1;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if(As == AsBytes) {
 | 
					  if(As == AsBytes) {
 | 
				
			||||||
    Count *= Self->ElementSize;
 | 
					    Count *= Self->ElementSize;
 | 
				
			||||||
@@ -221,32 +221,31 @@ FIFO_Enqueue (
 | 
				
			|||||||
  assert(Self != NULL);
 | 
					  assert(Self != NULL);
 | 
				
			||||||
  assert(pElement != NULL);
 | 
					  assert(pElement != NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if(FIFO_IsFull(Self)) {
 | 
					  if(FIFO_IsFull(Self)) {                                                 // FIFO is full so can't add to it
 | 
				
			||||||
    Count = 0;
 | 
					    Count = 0;                                                              // Zero characters added
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else {
 | 
					  else {                                                                  // Otherwise, FIFO is not full...
 | 
				
			||||||
    Count = MIN(Count, Self->FreeSpace(Self, AsElements));
 | 
					    Count = MIN(Count, Self->FreeSpace(Self, AsElements));                  // Smaller of requested or available space
 | 
				
			||||||
    SizeOfElement = Self->ElementSize;
 | 
					    SizeOfElement = Self->ElementSize;                                      // Size of Elements, in bytes
 | 
				
			||||||
    Windex = Self->WriteIndex;
 | 
					    Windex = Self->WriteIndex;                                              // Index of first writable slot in FIFO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ElemPtr = (uintptr_t)pElement;
 | 
					    ElemPtr = (uintptr_t)pElement;                                          // Addr. of element to add, as an integer
 | 
				
			||||||
 | 
					    QPtr    = (uintptr_t)Self->Queue + (SizeOfElement * Windex);            // Addr. in FIFO to write, as an integer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QPtr   = (uintptr_t)Self->Queue + (SizeOfElement * Windex);
 | 
					    for(i = 0; i < Count; ++i) {                                            // For Count elements...
 | 
				
			||||||
    for(i = 0; i < Count; ++i) {
 | 
					      (void)CopyMem((void *)QPtr, (const void *)ElemPtr, SizeOfElement);      // Copy an element into the FIFO
 | 
				
			||||||
      (void)CopyMem((void *)QPtr, (const void *)ElemPtr, SizeOfElement);
 | 
					      Windex = (UINT32)ModuloIncrement(Windex, Self->NumElements);            // Increment the Write index, wrap if necessary
 | 
				
			||||||
      Windex = (UINT32)ModuloIncrement(Windex, Self->NumElements);
 | 
					      if(Windex == 0) {                                                       // If the index wrapped
 | 
				
			||||||
      if(Windex == 0) {   // If the index wrapped
 | 
					        QPtr = (uintptr_t)Self->Queue;                                          // Go to the beginning
 | 
				
			||||||
        QPtr = (uintptr_t)Self->Queue;
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      else {
 | 
					      else {
 | 
				
			||||||
        QPtr += SizeOfElement;
 | 
					        QPtr += SizeOfElement;                                                // Otherwise, point to next in FIFO
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      ElemPtr += SizeOfElement;
 | 
					      ElemPtr += SizeOfElement;                                               // And also point to next Element to add
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    (void)ZeroMem((void*)QPtr, SizeOfElement);
 | 
					    Self->WriteIndex = Windex;                                              // Finally, save the new Write Index
 | 
				
			||||||
    Self->WriteIndex = Windex;
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return Count;
 | 
					  return Count;                                                           // Number of elements added to FIFO
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** Read or copy elements from the FIFO.
 | 
					/** Read or copy elements from the FIFO.
 | 
				
			||||||
@@ -277,7 +276,6 @@ FIFO_Dequeue (
 | 
				
			|||||||
  BOOLEAN   Consume
 | 
					  BOOLEAN   Consume
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  UINTN         ElemPtr;
 | 
					 | 
				
			||||||
  UINTN         QPtr;
 | 
					  UINTN         QPtr;
 | 
				
			||||||
  UINT32        RDex;
 | 
					  UINT32        RDex;
 | 
				
			||||||
  UINT32        SizeOfElement;
 | 
					  UINT32        SizeOfElement;
 | 
				
			||||||
@@ -285,38 +283,40 @@ FIFO_Dequeue (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  assert(Self != NULL);
 | 
					  assert(Self != NULL);
 | 
				
			||||||
  assert(pElement != NULL);
 | 
					  assert(pElement != NULL);
 | 
				
			||||||
  assert(Count != 0);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if(FIFO_IsEmpty(Self)) {
 | 
					  if(FIFO_IsEmpty(Self)) {
 | 
				
			||||||
    Count = 0;
 | 
					    Count = 0;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else {
 | 
					  else {
 | 
				
			||||||
    RDex          = Self->ReadIndex;
 | 
					    RDex          = Self->ReadIndex;                                  // Get this FIFO's Read Index
 | 
				
			||||||
    SizeOfElement = Self->ElementSize;
 | 
					    SizeOfElement = Self->ElementSize;                                // Get size of this FIFO's elements
 | 
				
			||||||
    ElemPtr       = (UINTN)pElement;
 | 
					    Count         = MIN(Count, Self->Count(Self, AsElements));        // Lesser of requested or actual
 | 
				
			||||||
    Count         = MIN(Count, Self->Count(Self, AsElements));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QPtr = (UINTN)Self->Queue + (RDex * Self->ElementSize);
 | 
					    QPtr = (UINTN)Self->Queue + (RDex * Self->ElementSize);           // Point to Read location in FIFO
 | 
				
			||||||
    for(i = 0; i < Count; ++i) {
 | 
					    for(i = 0; i < Count; ++i) {                                      // Iterate Count times...
 | 
				
			||||||
      (void)CopyMem((void *)ElemPtr, (const void *)QPtr, Self->ElementSize);
 | 
					      (void)CopyMem(pElement, (const void *)QPtr, Self->ElementSize);   // Copy element from FIFO to caller's buffer
 | 
				
			||||||
      RDex = (UINT32)ModuloIncrement(RDex, Self->NumElements);
 | 
					      RDex = (UINT32)ModuloIncrement(RDex, Self->NumElements);          // Increment Read Index
 | 
				
			||||||
      if(RDex == 0) {   // If the index wrapped
 | 
					      if(RDex == 0) {                                                   // If the index wrapped
 | 
				
			||||||
        QPtr = (UINTN)Self->Queue;
 | 
					        QPtr = (UINTN)Self->Queue;                                        // Point back to beginning of data
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      else {
 | 
					      else {                                                            // Otherwise
 | 
				
			||||||
        QPtr += Self->ElementSize;
 | 
					        QPtr += Self->ElementSize;                                        // Point to the next element in FIFO
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      ElemPtr += Self->ElementSize;
 | 
					      pElement = (char*)pElement + Self->ElementSize;                   // Point to next element in caller's buffer
 | 
				
			||||||
    }
 | 
					    }                                                                 // Iterate: for loop
 | 
				
			||||||
    if(Consume) {
 | 
					    if(Consume) {                                                     // If caller requests data consumption
 | 
				
			||||||
      Self->ReadIndex = RDex;
 | 
					      Self->ReadIndex = RDex;                                           // Set FIFO's Read Index to new Index
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return Count;
 | 
					  return Count;                                                     // Return number of elements actually read
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** Read elements from the FIFO.
 | 
					/** Read elements from the FIFO.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Read the specified number of elements from the FIFO, removing each element read.
 | 
				
			||||||
 | 
					    The number of elements actually read from the FIFO is returned.  This number can differ
 | 
				
			||||||
 | 
					    from the Count requested if more elements are requested than are in the FIFO.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @param[in]    Self        Pointer to the FIFO instance.
 | 
					    @param[in]    Self        Pointer to the FIFO instance.
 | 
				
			||||||
    @param[out]   pElement    Pointer to where to store the element read from the FIFO.
 | 
					    @param[out]   pElement    Pointer to where to store the element read from the FIFO.
 | 
				
			||||||
    @param[in]    Count       Number of elements to dequeue.
 | 
					    @param[in]    Count       Number of elements to dequeue.
 | 
				
			||||||
@@ -338,7 +338,7 @@ FIFO_Read (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/** Make a copy of the FIFO's data.
 | 
					/** Make a copy of the FIFO's data.
 | 
				
			||||||
    The contents of the FIFO is copied out and linearized without affecting the
 | 
					    The contents of the FIFO is copied out and linearized without affecting the
 | 
				
			||||||
    FIFO contents.
 | 
					    FIFO contents.  This function is idempotent.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @param[in]    Self        Pointer to the FIFO instance.
 | 
					    @param[in]    Self        Pointer to the FIFO instance.
 | 
				
			||||||
    @param[out]   pElement    Pointer to where to store the elements copied from the FIFO.
 | 
					    @param[out]   pElement    Pointer to where to store the elements copied from the FIFO.
 | 
				
			||||||
@@ -435,7 +435,7 @@ FIFO_Flush (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  assert(Self != NULL);
 | 
					  assert(Self != NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  NumInQ = FIFO_FreeSpace(Self, AsElements);
 | 
					  NumInQ = FIFO_NumInQueue(Self, AsElements);
 | 
				
			||||||
  if(NumToFlush >= NumInQ) {
 | 
					  if(NumToFlush >= NumInQ) {
 | 
				
			||||||
    Self->ReadIndex   = 0;
 | 
					    Self->ReadIndex   = 0;
 | 
				
			||||||
    Self->WriteIndex  = 0;
 | 
					    Self->WriteIndex  = 0;
 | 
				
			||||||
@@ -464,7 +464,7 @@ FIFO_Truncate (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  assert(Self != NULL);
 | 
					  assert(Self != NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Remainder = Self->Count(Self, AsElements);
 | 
					  Remainder = FIFO_NumInQueue(Self, AsElements);
 | 
				
			||||||
  if(Remainder > 0) {
 | 
					  if(Remainder > 0) {
 | 
				
			||||||
    Self->WriteIndex = (UINT32)ModuloDecrement(Self->WriteIndex, Self->NumElements);
 | 
					    Self->WriteIndex = (UINT32)ModuloDecrement(Self->WriteIndex, Self->NumElements);
 | 
				
			||||||
    --Remainder;
 | 
					    --Remainder;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
/** @file
 | 
					/** @file
 | 
				
			||||||
  Implement the realpath function.
 | 
					  Implement the realpath function.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Copyright (c) 2011, Intel Corporation
 | 
					  Copyright (c) 2011 - 2014, Intel Corporation
 | 
				
			||||||
  All rights reserved. This program and the accompanying materials
 | 
					  All rights reserved. This program and the accompanying materials
 | 
				
			||||||
  are licensed and made available under the terms and conditions of the BSD License
 | 
					  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
 | 
					  which accompanies this distribution.  The full text of the license may be found at
 | 
				
			||||||
@@ -9,24 +9,22 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 | 
					  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 | 
				
			||||||
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 | 
					  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 | 
				
			||||||
 | 
					 | 
				
			||||||
**/
 | 
					**/
 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <LibConfig.h>
 | 
					#include <LibConfig.h>
 | 
				
			||||||
#include <Library/BaseLib.h>
 | 
					#include <Library/BaseLib.h>
 | 
				
			||||||
#include <Library/PathLib.h>
 | 
					 | 
				
			||||||
#include <Library/MemoryAllocationLib.h>
 | 
					#include <Library/MemoryAllocationLib.h>
 | 
				
			||||||
 | 
					#include <Library/PathLib.h>
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/** The realpath() function shall derive, from the pathname pointed to by
 | 
				
			||||||
  The realpath() function shall derive, from the pathname pointed to by 
 | 
					    file_name, an absolute pathname that names the same file, whose resolution
 | 
				
			||||||
  file_name, an absolute pathname that names the same file, whose resolution 
 | 
					    does not involve '.', '..', or symbolic links.
 | 
				
			||||||
  does not involve '.', '..', or symbolic links. The generated pathname shall
 | 
					 | 
				
			||||||
  be stored as a null-terminated string, up to a maximum of {PATH_MAX} bytes,
 | 
					 | 
				
			||||||
  in the buffer pointed to by resolved_name.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  If resolved_name is a null pointer, the behavior of realpath() is 
 | 
					    The generated pathname shall be stored as a null-terminated string, up to a
 | 
				
			||||||
  implementation-defined.
 | 
					    maximum of {PATH_MAX} bytes, in the buffer pointed to by resolved_name.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    If resolved_name is a null pointer, the behavior of realpath() is
 | 
				
			||||||
 | 
					    implementation-defined.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @param[in] file_name            The filename to convert.
 | 
					  @param[in] file_name            The filename to convert.
 | 
				
			||||||
  @param[in,out] resolved_name    The resultant name.
 | 
					  @param[in,out] resolved_name    The resultant name.
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user