From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id D80D67803DA for ; Mon, 23 Oct 2023 12:19:59 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=EjMobONZj5mS/Z1XLshjPsHwcrffn6ASHrBsWSNlzCQ=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:User-Agent:Subject:To:CC:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1698063598; v=1; b=Ft5fFak2eWpjx32UvTs+Yrkda8uP8TIBxUOPtwAzjEFQElpru8wEy/NeIRVk2O1k1dTztRdt gJ9FaPRACis0o/Tl33vFYeuCmVAz/ZWcRtGcicq1BFg5YDjYeOKSCxeYHIl9jf3GhilpGsVKlyk NseErqrkV4chSt6/bBeGescQ= X-Received: by 127.0.0.2 with SMTP id FplwYY7687511xdYbqz6CL8J; Mon, 23 Oct 2023 05:19:58 -0700 X-Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by mx.groups.io with SMTP id smtpd.web10.118959.1698063597559576265 for ; Mon, 23 Oct 2023 05:19:57 -0700 X-Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39NCJsFk021218; Mon, 23 Oct 2023 12:19:54 GMT X-Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tv6873y0k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Oct 2023 12:19:54 +0000 X-Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 39NCJrNv026528 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Oct 2023 12:19:53 GMT X-Received: from [10.111.137.121] (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.39; Mon, 23 Oct 2023 05:19:50 -0700 Message-ID: <2151b03b-7447-4cfe-8e85-2f5432e9d7a8@quicinc.com> Date: Mon, 23 Oct 2023 13:19:47 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [edk2-libc Patch 1/1] ek2-libc: Enhance StdLib for supporting Aarch64 and ARM To: , , "Jayaprakash, N" CC: Rebecca Cran , Tyler Erickson , Ard Biesheuvel , Leif Lindholm References: <20231020140406.2432-1-n.jayaprakash@intel.com> <20231020140406.2432-2-n.jayaprakash@intel.com> From: "Leif Lindholm" In-Reply-To: X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-GUID: SgHzMEvmhnY1w6dk437WmQy5GaOtQZNM X-Proofpoint-ORIG-GUID: SgHzMEvmhnY1w6dk437WmQy5GaOtQZNM Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,quic_llindhol@quicinc.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: Mxk6NiK0KZBia0Ji7NHXMUmRx7686176AA= Content-Language: en-GB Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=Ft5fFak2; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=quicinc.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On the whole, I find edk2-libc creates more problems than it solves. So=20 I will not be reviewing patches for it. / Leif On 2023-10-20 20:54, Michael D Kinney wrote: > +Ard > +Leif >=20 >=20 >> -----Original Message----- >> From: Jayaprakash, N >> Sent: Friday, October 20, 2023 7:04 AM >> To: devel@edk2.groups.io >> Cc: Jayaprakash, N ; Rebecca Cran >> ; Kinney, Michael D ; >> Tyler Erickson >> Subject: [edk2-libc Patch 1/1] ek2-libc: Enhance StdLib for supporting >> Aarch64 and ARM >> >> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4570 >> >> This commit is for processing the below PR on edk2-libc repo >> https://github.com/tianocore/edk2-libc/pull/3 >> These are the changes introduced to StdLib to build >> an application for the UEFI shell. >> Added format macros for int types to Aarch64, ARM, and Ia32. >> Also modified the X64 macros so that everything would build >> when they are used. >> Added some macros that can be used for compatibility that define when >> socklen_t has been defined. >> Added getopt_long parser from OpenBSD to provide long and >> short option parsing capability with getopt. >> >> Cc: Rebecca Cran >> Cc: Michael D Kinney >> Cc: Jayaprakash N >> Signed-off-by: Tyler Erickson >> --- >> StdLib/Include/Aarch64/machine/int_fmtio.h | 211 +++++++++ >> StdLib/Include/Arm/machine/int_fmtio.h | 211 +++++++++ >> StdLib/Include/Ia32/machine/int_fmtio.h | 212 +++++++++ >> StdLib/Include/X64/machine/int_fmtio.h | 324 ++++++------- >> StdLib/Include/getopt.h | 76 +++ >> StdLib/Include/inttypes.h | 2 +- >> StdLib/Include/sys/socket.h | 6 + >> StdLib/Include/unistd.h | 7 +- >> StdLib/LibC/LibC.inf | 1 + >> StdLib/LibC/Uefi/Uefi.inf | 1 + >> StdLib/LibC/Uefi/compat.c | 40 +- >> StdLib/LibC/Uefi/getopt_long.c | 523 >> +++++++++++++++++++++ >> 12 files changed, 1406 insertions(+), 208 deletions(-) >> create mode 100644 StdLib/Include/Aarch64/machine/int_fmtio.h >> create mode 100644 StdLib/Include/Arm/machine/int_fmtio.h >> create mode 100644 StdLib/Include/Ia32/machine/int_fmtio.h >> create mode 100644 StdLib/Include/getopt.h >> create mode 100644 StdLib/LibC/Uefi/getopt_long.c >> >> diff --git a/StdLib/Include/Aarch64/machine/int_fmtio.h >> b/StdLib/Include/Aarch64/machine/int_fmtio.h >> new file mode 100644 >> index 0000000..f091a7d >> --- /dev/null >> +++ b/StdLib/Include/Aarch64/machine/int_fmtio.h >> @@ -0,0 +1,211 @@ >> +/* $NetBSD: int_fmtio.h,v 1.10 2018/07/15 00:36:13 christos Exp $ >> */ >> + >> +/*- >> + * Copyright (c) 2001 The NetBSD Foundation, Inc. >> + * All rights reserved. >> + * >> + * This code is derived from software contributed to The NetBSD >> Foundation >> + * by Klaus Klein. >> + * >> + * Redistribution and use in source and binary forms, with or without >> + * modification, are permitted provided that the following conditions >> + * are met: >> + * 1. Redistributions of source code must retain the above copyright >> + * notice, this list of conditions and the following disclaimer. >> + * 2. Redistributions in binary form must reproduce the above >> copyright >> + * notice, this list of conditions and the following disclaimer in >> the >> + * documentation and/or other materials provided with the >> distribution. >> + * >> + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND >> CONTRIBUTORS >> + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT >> NOT LIMITED >> + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A >> PARTICULAR >> + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR >> CONTRIBUTORS >> + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >> EXEMPLARY, OR >> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT >> OF >> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR >> BUSINESS >> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, >> WHETHER IN >> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR >> OTHERWISE) >> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF >> ADVISED OF THE >> + * POSSIBILITY OF SUCH DAMAGE. >> + */ >> + >> +#ifndef _ARM_INT_FMTIO_H_ >> +#define _ARM_INT_FMTIO_H_ >> + >> +/* >> + * 7.8.1 Macros for format specifiers >> + */ >> + >> +/* fprintf macros for signed integers */ >> +#define PRId8 "d" /* int8_t */ >> +#define PRId16 "d" /* int16_t */ >> +#define PRId32 "d" /* int32_t */ >> +#define PRId64 "lld" /* int64_t */ >> +#define PRIdLEAST8 "d" /* int_least8_t */ >> +#define PRIdLEAST16 "d" /* int_least16_t */ >> +#define PRIdLEAST32 "d" /* int_least32_t */ >> +#define PRIdLEAST64 "lld" /* int_least64_t */ >> +#define PRIdFAST8 "d" /* int_fast8_t */ >> +#define PRIdFAST16 "d" /* int_fast16_t */ >> +#define PRIdFAST32 "d" /* int_fast32_t */ >> +#define PRIdFAST64 "lld" /* int_fast64_t */ >> +#define PRIdMAX "lld" /* intmax_t */ >> +#define PRIdPTR "ld" /* intptr_t */ >> + >> +#define PRIi8 "i" /* int8_t */ >> +#define PRIi16 "i" /* int16_t */ >> +#define PRIi32 "i" /* int32_t */ >> +#define PRIi64 "lli" /* int64_t */ >> +#define PRIiLEAST8 "i" /* int_least8_t */ >> +#define PRIiLEAST16 "i" /* int_least16_t */ >> +#define PRIiLEAST32 "i" /* int_least32_t */ >> +#define PRIiLEAST64 "lli" /* int_least64_t */ >> +#define PRIiFAST8 "i" /* int_fast8_t */ >> +#define PRIiFAST16 "i" /* int_fast16_t */ >> +#define PRIiFAST32 "i" /* int_fast32_t */ >> +#define PRIiFAST64 "lli" /* int_fast64_t */ >> +#define PRIiMAX "lli" /* intmax_t */ >> +#define PRIiPTR "li" /* intptr_t */ >> + >> +/* fprintf macros for unsigned integers */ >> + >> +#define PRIo8 "o" /* uint8_t */ >> +#define PRIo16 "o" /* uint16_t */ >> +#define PRIo32 "o" /* uint32_t */ >> +#define PRIo64 "llo" /* uint64_t */ >> +#define PRIoLEAST8 "o" /* uint_least8_t */ >> +#define PRIoLEAST16 "o" /* uint_least16_t */ >> +#define PRIoLEAST32 "o" /* uint_least32_t */ >> +#define PRIoLEAST64 "llo" /* uint_least64_t */ >> +#define PRIoFAST8 "o" /* uint_fast8_t */ >> +#define PRIoFAST16 "o" /* uint_fast16_t */ >> +#define PRIoFAST32 "o" /* uint_fast32_t */ >> +#define PRIoFAST64 "llo" /* uint_fast64_t */ >> +#define PRIoMAX "llo" /* uintmax_t */ >> +#define PRIoPTR "lo" /* uintptr_t */ >> + >> +#define PRIu8 "u" /* uint8_t */ >> +#define PRIu16 "u" /* uint16_t */ >> +#define PRIu32 "u" /* uint32_t */ >> +#define PRIu64 "llu" /* uint64_t */ >> +#define PRIuLEAST8 "u" /* uint_least8_t */ >> +#define PRIuLEAST16 "u" /* uint_least16_t */ >> +#define PRIuLEAST32 "u" /* uint_least32_t */ >> +#define PRIuLEAST64 "llu" /* uint_least64_t */ >> +#define PRIuFAST8 "u" /* uint_fast8_t */ >> +#define PRIuFAST16 "u" /* uint_fast16_t */ >> +#define PRIuFAST32 "u" /* uint_fast32_t */ >> +#define PRIuFAST64 "llu" /* uint_fast64_t */ >> +#define PRIuMAX "llu" /* uintmax_t */ >> +#define PRIuPTR "lu" /* uintptr_t */ >> + >> +#define PRIx8 "x" /* uint8_t */ >> +#define PRIx16 "x" /* uint16_t */ >> +#define PRIx32 "x" /* uint32_t */ >> +#define PRIx64 "llx" /* uint64_t */ >> +#define PRIxLEAST8 "x" /* uint_least8_t */ >> +#define PRIxLEAST16 "x" /* uint_least16_t */ >> +#define PRIxLEAST32 "x" /* uint_least32_t */ >> +#define PRIxLEAST64 "llx" /* uint_least64_t */ >> +#define PRIxFAST8 "x" /* uint_fast8_t */ >> +#define PRIxFAST16 "x" /* uint_fast16_t */ >> +#define PRIxFAST32 "x" /* uint_fast32_t */ >> +#define PRIxFAST64 "llx" /* uint_fast64_t */ >> +#define PRIxMAX "llx" /* uintmax_t */ >> +#define PRIxPTR "lx" /* uintptr_t */ >> + >> +#define PRIX8 "X" /* uint8_t */ >> +#define PRIX16 "X" /* uint16_t */ >> +#define PRIX32 "X" /* uint32_t */ >> +#define PRIX64 "llX" /* uint64_t */ >> +#define PRIXLEAST8 "X" /* uint_least8_t */ >> +#define PRIXLEAST16 "X" /* uint_least16_t */ >> +#define PRIXLEAST32 "X" /* uint_least32_t */ >> +#define PRIXLEAST64 "llX" /* uint_least64_t */ >> +#define PRIXFAST8 "X" /* uint_fast8_t */ >> +#define PRIXFAST16 "X" /* uint_fast16_t */ >> +#define PRIXFAST32 "X" /* uint_fast32_t */ >> +#define PRIXFAST64 "llX" /* uint_fast64_t */ >> +#define PRIXMAX "llX" /* uintmax_t */ >> +#define PRIXPTR "lX" /* uintptr_t */ >> + >> +/* fscanf macros for signed integers */ >> + >> +#define SCNd8 "hhd" /* int8_t */ >> +#define SCNd16 "hd" /* int16_t */ >> +#define SCNd32 "d" /* int32_t */ >> +#define SCNd64 "lld" /* int64_t */ >> +#define SCNdLEAST8 "hhd" /* int_least8_t */ >> +#define SCNdLEAST16 "hd" /* int_least16_t */ >> +#define SCNdLEAST32 "d" /* int_least32_t */ >> +#define SCNdLEAST64 "lld" /* int_least64_t */ >> +#define SCNdFAST8 "d" /* int_fast8_t */ >> +#define SCNdFAST16 "d" /* int_fast16_t */ >> +#define SCNdFAST32 "d" /* int_fast32_t */ >> +#define SCNdFAST64 "lld" /* int_fast64_t */ >> +#define SCNdMAX "lld" /* intmax_t */ >> +#define SCNdPTR "ld" /* intptr_t */ >> + >> +#define SCNi8 "hhi" /* int8_t */ >> +#define SCNi16 "hi" /* int16_t */ >> +#define SCNi32 "i" /* int32_t */ >> +#define SCNi64 "lli" /* int64_t */ >> +#define SCNiLEAST8 "hhi" /* int_least8_t */ >> +#define SCNiLEAST16 "hi" /* int_least16_t */ >> +#define SCNiLEAST32 "i" /* int_least32_t */ >> +#define SCNiLEAST64 "lli" /* int_least64_t */ >> +#define SCNiFAST8 "i" /* int_fast8_t */ >> +#define SCNiFAST16 "i" /* int_fast16_t */ >> +#define SCNiFAST32 "i" /* int_fast32_t */ >> +#define SCNiFAST64 "lli" /* int_fast64_t */ >> +#define SCNiMAX "lli" /* intmax_t */ >> +#define SCNiPTR "li" /* intptr_t */ >> + >> +/* fscanf macros for unsigned integers */ >> + >> +#define SCNo8 "hho" /* uint8_t */ >> +#define SCNo16 "ho" /* uint16_t */ >> +#define SCNo32 "o" /* uint32_t */ >> +#define SCNo64 "llo" /* uint64_t */ >> +#define SCNoLEAST8 "hho" /* uint_least8_t */ >> +#define SCNoLEAST16 "ho" /* uint_least16_t */ >> +#define SCNoLEAST32 "o" /* uint_least32_t */ >> +#define SCNoLEAST64 "llo" /* uint_least64_t */ >> +#define SCNoFAST8 "o" /* uint_fast8_t */ >> +#define SCNoFAST16 "o" /* uint_fast16_t */ >> +#define SCNoFAST32 "o" /* uint_fast32_t */ >> +#define SCNoFAST64 "llo" /* uint_fast64_t */ >> +#define SCNoMAX "llo" /* uintmax_t */ >> +#define SCNoPTR "lo" /* uintptr_t */ >> + >> +#define SCNu8 "hhu" /* uint8_t */ >> +#define SCNu16 "hu" /* uint16_t */ >> +#define SCNu32 "u" /* uint32_t */ >> +#define SCNu64 "llu" /* uint64_t */ >> +#define SCNuLEAST8 "hhu" /* uint_least8_t */ >> +#define SCNuLEAST16 "hu" /* uint_least16_t */ >> +#define SCNuLEAST32 "u" /* uint_least32_t */ >> +#define SCNuLEAST64 "llu" /* uint_least64_t */ >> +#define SCNuFAST8 "u" /* uint_fast8_t */ >> +#define SCNuFAST16 "u" /* uint_fast16_t */ >> +#define SCNuFAST32 "u" /* uint_fast32_t */ >> +#define SCNuFAST64 "llu" /* uint_fast64_t */ >> +#define SCNuMAX "llu" /* uintmax_t */ >> +#define SCNuPTR "lu" /* uintptr_t */ >> + >> +#define SCNx8 "hhx" /* uint8_t */ >> +#define SCNx16 "hx" /* uint16_t */ >> +#define SCNx32 "x" /* uint32_t */ >> +#define SCNx64 "llx" /* uint64_t */ >> +#define SCNxLEAST8 "hhx" /* uint_least8_t */ >> +#define SCNxLEAST16 "hx" /* uint_least16_t */ >> +#define SCNxLEAST32 "x" /* uint_least32_t */ >> +#define SCNxLEAST64 "llx" /* uint_least64_t */ >> +#define SCNxFAST8 "x" /* uint_fast8_t */ >> +#define SCNxFAST16 "x" /* uint_fast16_t */ >> +#define SCNxFAST32 "x" /* uint_fast32_t */ >> +#define SCNxFAST64 "llx" /* uint_fast64_t */ >> +#define SCNxMAX "llx" /* uintmax_t */ >> +#define SCNxPTR "lx" /* uintptr_t */ >> + >> +#endif /* !_ARM_INT_FMTIO_H_ */ >> diff --git a/StdLib/Include/Arm/machine/int_fmtio.h >> b/StdLib/Include/Arm/machine/int_fmtio.h >> new file mode 100644 >> index 0000000..f091a7d >> --- /dev/null >> +++ b/StdLib/Include/Arm/machine/int_fmtio.h >> @@ -0,0 +1,211 @@ >> +/* $NetBSD: int_fmtio.h,v 1.10 2018/07/15 00:36:13 christos Exp $ >> */ >> + >> +/*- >> + * Copyright (c) 2001 The NetBSD Foundation, Inc. >> + * All rights reserved. >> + * >> + * This code is derived from software contributed to The NetBSD >> Foundation >> + * by Klaus Klein. >> + * >> + * Redistribution and use in source and binary forms, with or without >> + * modification, are permitted provided that the following conditions >> + * are met: >> + * 1. Redistributions of source code must retain the above copyright >> + * notice, this list of conditions and the following disclaimer. >> + * 2. Redistributions in binary form must reproduce the above >> copyright >> + * notice, this list of conditions and the following disclaimer in >> the >> + * documentation and/or other materials provided with the >> distribution. >> + * >> + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND >> CONTRIBUTORS >> + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT >> NOT LIMITED >> + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A >> PARTICULAR >> + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR >> CONTRIBUTORS >> + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >> EXEMPLARY, OR >> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT >> OF >> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR >> BUSINESS >> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, >> WHETHER IN >> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR >> OTHERWISE) >> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF >> ADVISED OF THE >> + * POSSIBILITY OF SUCH DAMAGE. >> + */ >> + >> +#ifndef _ARM_INT_FMTIO_H_ >> +#define _ARM_INT_FMTIO_H_ >> + >> +/* >> + * 7.8.1 Macros for format specifiers >> + */ >> + >> +/* fprintf macros for signed integers */ >> +#define PRId8 "d" /* int8_t */ >> +#define PRId16 "d" /* int16_t */ >> +#define PRId32 "d" /* int32_t */ >> +#define PRId64 "lld" /* int64_t */ >> +#define PRIdLEAST8 "d" /* int_least8_t */ >> +#define PRIdLEAST16 "d" /* int_least16_t */ >> +#define PRIdLEAST32 "d" /* int_least32_t */ >> +#define PRIdLEAST64 "lld" /* int_least64_t */ >> +#define PRIdFAST8 "d" /* int_fast8_t */ >> +#define PRIdFAST16 "d" /* int_fast16_t */ >> +#define PRIdFAST32 "d" /* int_fast32_t */ >> +#define PRIdFAST64 "lld" /* int_fast64_t */ >> +#define PRIdMAX "lld" /* intmax_t */ >> +#define PRIdPTR "ld" /* intptr_t */ >> + >> +#define PRIi8 "i" /* int8_t */ >> +#define PRIi16 "i" /* int16_t */ >> +#define PRIi32 "i" /* int32_t */ >> +#define PRIi64 "lli" /* int64_t */ >> +#define PRIiLEAST8 "i" /* int_least8_t */ >> +#define PRIiLEAST16 "i" /* int_least16_t */ >> +#define PRIiLEAST32 "i" /* int_least32_t */ >> +#define PRIiLEAST64 "lli" /* int_least64_t */ >> +#define PRIiFAST8 "i" /* int_fast8_t */ >> +#define PRIiFAST16 "i" /* int_fast16_t */ >> +#define PRIiFAST32 "i" /* int_fast32_t */ >> +#define PRIiFAST64 "lli" /* int_fast64_t */ >> +#define PRIiMAX "lli" /* intmax_t */ >> +#define PRIiPTR "li" /* intptr_t */ >> + >> +/* fprintf macros for unsigned integers */ >> + >> +#define PRIo8 "o" /* uint8_t */ >> +#define PRIo16 "o" /* uint16_t */ >> +#define PRIo32 "o" /* uint32_t */ >> +#define PRIo64 "llo" /* uint64_t */ >> +#define PRIoLEAST8 "o" /* uint_least8_t */ >> +#define PRIoLEAST16 "o" /* uint_least16_t */ >> +#define PRIoLEAST32 "o" /* uint_least32_t */ >> +#define PRIoLEAST64 "llo" /* uint_least64_t */ >> +#define PRIoFAST8 "o" /* uint_fast8_t */ >> +#define PRIoFAST16 "o" /* uint_fast16_t */ >> +#define PRIoFAST32 "o" /* uint_fast32_t */ >> +#define PRIoFAST64 "llo" /* uint_fast64_t */ >> +#define PRIoMAX "llo" /* uintmax_t */ >> +#define PRIoPTR "lo" /* uintptr_t */ >> + >> +#define PRIu8 "u" /* uint8_t */ >> +#define PRIu16 "u" /* uint16_t */ >> +#define PRIu32 "u" /* uint32_t */ >> +#define PRIu64 "llu" /* uint64_t */ >> +#define PRIuLEAST8 "u" /* uint_least8_t */ >> +#define PRIuLEAST16 "u" /* uint_least16_t */ >> +#define PRIuLEAST32 "u" /* uint_least32_t */ >> +#define PRIuLEAST64 "llu" /* uint_least64_t */ >> +#define PRIuFAST8 "u" /* uint_fast8_t */ >> +#define PRIuFAST16 "u" /* uint_fast16_t */ >> +#define PRIuFAST32 "u" /* uint_fast32_t */ >> +#define PRIuFAST64 "llu" /* uint_fast64_t */ >> +#define PRIuMAX "llu" /* uintmax_t */ >> +#define PRIuPTR "lu" /* uintptr_t */ >> + >> +#define PRIx8 "x" /* uint8_t */ >> +#define PRIx16 "x" /* uint16_t */ >> +#define PRIx32 "x" /* uint32_t */ >> +#define PRIx64 "llx" /* uint64_t */ >> +#define PRIxLEAST8 "x" /* uint_least8_t */ >> +#define PRIxLEAST16 "x" /* uint_least16_t */ >> +#define PRIxLEAST32 "x" /* uint_least32_t */ >> +#define PRIxLEAST64 "llx" /* uint_least64_t */ >> +#define PRIxFAST8 "x" /* uint_fast8_t */ >> +#define PRIxFAST16 "x" /* uint_fast16_t */ >> +#define PRIxFAST32 "x" /* uint_fast32_t */ >> +#define PRIxFAST64 "llx" /* uint_fast64_t */ >> +#define PRIxMAX "llx" /* uintmax_t */ >> +#define PRIxPTR "lx" /* uintptr_t */ >> + >> +#define PRIX8 "X" /* uint8_t */ >> +#define PRIX16 "X" /* uint16_t */ >> +#define PRIX32 "X" /* uint32_t */ >> +#define PRIX64 "llX" /* uint64_t */ >> +#define PRIXLEAST8 "X" /* uint_least8_t */ >> +#define PRIXLEAST16 "X" /* uint_least16_t */ >> +#define PRIXLEAST32 "X" /* uint_least32_t */ >> +#define PRIXLEAST64 "llX" /* uint_least64_t */ >> +#define PRIXFAST8 "X" /* uint_fast8_t */ >> +#define PRIXFAST16 "X" /* uint_fast16_t */ >> +#define PRIXFAST32 "X" /* uint_fast32_t */ >> +#define PRIXFAST64 "llX" /* uint_fast64_t */ >> +#define PRIXMAX "llX" /* uintmax_t */ >> +#define PRIXPTR "lX" /* uintptr_t */ >> + >> +/* fscanf macros for signed integers */ >> + >> +#define SCNd8 "hhd" /* int8_t */ >> +#define SCNd16 "hd" /* int16_t */ >> +#define SCNd32 "d" /* int32_t */ >> +#define SCNd64 "lld" /* int64_t */ >> +#define SCNdLEAST8 "hhd" /* int_least8_t */ >> +#define SCNdLEAST16 "hd" /* int_least16_t */ >> +#define SCNdLEAST32 "d" /* int_least32_t */ >> +#define SCNdLEAST64 "lld" /* int_least64_t */ >> +#define SCNdFAST8 "d" /* int_fast8_t */ >> +#define SCNdFAST16 "d" /* int_fast16_t */ >> +#define SCNdFAST32 "d" /* int_fast32_t */ >> +#define SCNdFAST64 "lld" /* int_fast64_t */ >> +#define SCNdMAX "lld" /* intmax_t */ >> +#define SCNdPTR "ld" /* intptr_t */ >> + >> +#define SCNi8 "hhi" /* int8_t */ >> +#define SCNi16 "hi" /* int16_t */ >> +#define SCNi32 "i" /* int32_t */ >> +#define SCNi64 "lli" /* int64_t */ >> +#define SCNiLEAST8 "hhi" /* int_least8_t */ >> +#define SCNiLEAST16 "hi" /* int_least16_t */ >> +#define SCNiLEAST32 "i" /* int_least32_t */ >> +#define SCNiLEAST64 "lli" /* int_least64_t */ >> +#define SCNiFAST8 "i" /* int_fast8_t */ >> +#define SCNiFAST16 "i" /* int_fast16_t */ >> +#define SCNiFAST32 "i" /* int_fast32_t */ >> +#define SCNiFAST64 "lli" /* int_fast64_t */ >> +#define SCNiMAX "lli" /* intmax_t */ >> +#define SCNiPTR "li" /* intptr_t */ >> + >> +/* fscanf macros for unsigned integers */ >> + >> +#define SCNo8 "hho" /* uint8_t */ >> +#define SCNo16 "ho" /* uint16_t */ >> +#define SCNo32 "o" /* uint32_t */ >> +#define SCNo64 "llo" /* uint64_t */ >> +#define SCNoLEAST8 "hho" /* uint_least8_t */ >> +#define SCNoLEAST16 "ho" /* uint_least16_t */ >> +#define SCNoLEAST32 "o" /* uint_least32_t */ >> +#define SCNoLEAST64 "llo" /* uint_least64_t */ >> +#define SCNoFAST8 "o" /* uint_fast8_t */ >> +#define SCNoFAST16 "o" /* uint_fast16_t */ >> +#define SCNoFAST32 "o" /* uint_fast32_t */ >> +#define SCNoFAST64 "llo" /* uint_fast64_t */ >> +#define SCNoMAX "llo" /* uintmax_t */ >> +#define SCNoPTR "lo" /* uintptr_t */ >> + >> +#define SCNu8 "hhu" /* uint8_t */ >> +#define SCNu16 "hu" /* uint16_t */ >> +#define SCNu32 "u" /* uint32_t */ >> +#define SCNu64 "llu" /* uint64_t */ >> +#define SCNuLEAST8 "hhu" /* uint_least8_t */ >> +#define SCNuLEAST16 "hu" /* uint_least16_t */ >> +#define SCNuLEAST32 "u" /* uint_least32_t */ >> +#define SCNuLEAST64 "llu" /* uint_least64_t */ >> +#define SCNuFAST8 "u" /* uint_fast8_t */ >> +#define SCNuFAST16 "u" /* uint_fast16_t */ >> +#define SCNuFAST32 "u" /* uint_fast32_t */ >> +#define SCNuFAST64 "llu" /* uint_fast64_t */ >> +#define SCNuMAX "llu" /* uintmax_t */ >> +#define SCNuPTR "lu" /* uintptr_t */ >> + >> +#define SCNx8 "hhx" /* uint8_t */ >> +#define SCNx16 "hx" /* uint16_t */ >> +#define SCNx32 "x" /* uint32_t */ >> +#define SCNx64 "llx" /* uint64_t */ >> +#define SCNxLEAST8 "hhx" /* uint_least8_t */ >> +#define SCNxLEAST16 "hx" /* uint_least16_t */ >> +#define SCNxLEAST32 "x" /* uint_least32_t */ >> +#define SCNxLEAST64 "llx" /* uint_least64_t */ >> +#define SCNxFAST8 "x" /* uint_fast8_t */ >> +#define SCNxFAST16 "x" /* uint_fast16_t */ >> +#define SCNxFAST32 "x" /* uint_fast32_t */ >> +#define SCNxFAST64 "llx" /* uint_fast64_t */ >> +#define SCNxMAX "llx" /* uintmax_t */ >> +#define SCNxPTR "lx" /* uintptr_t */ >> + >> +#endif /* !_ARM_INT_FMTIO_H_ */ >> diff --git a/StdLib/Include/Ia32/machine/int_fmtio.h >> b/StdLib/Include/Ia32/machine/int_fmtio.h >> new file mode 100644 >> index 0000000..061d594 >> --- /dev/null >> +++ b/StdLib/Include/Ia32/machine/int_fmtio.h >> @@ -0,0 +1,212 @@ >> +/* $NetBSD: int_fmtio.h,v 1.9 2014/07/28 11:22:46 joerg Exp $ */ >> + >> +/*- >> + * Copyright (c) 2001 The NetBSD Foundation, Inc. >> + * All rights reserved. >> + * >> + * This code is derived from software contributed to The NetBSD >> Foundation >> + * by Klaus Klein. >> + * >> + * Redistribution and use in source and binary forms, with or without >> + * modification, are permitted provided that the following conditions >> + * are met: >> + * 1. Redistributions of source code must retain the above copyright >> + * notice, this list of conditions and the following disclaimer. >> + * 2. Redistributions in binary form must reproduce the above >> copyright >> + * notice, this list of conditions and the following disclaimer in >> the >> + * documentation and/or other materials provided with the >> distribution. >> + * >> + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND >> CONTRIBUTORS >> + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT >> NOT LIMITED >> + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A >> PARTICULAR >> + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR >> CONTRIBUTORS >> + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >> EXEMPLARY, OR >> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT >> OF >> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR >> BUSINESS >> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, >> WHETHER IN >> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR >> OTHERWISE) >> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF >> ADVISED OF THE >> + * POSSIBILITY OF SUCH DAMAGE. >> + */ >> + >> +#ifndef _I386_INT_FMTIO_H_ >> +#define _I386_INT_FMTIO_H_ >> + >> +/* >> + * 7.8.1 Macros for format specifiers >> + */ >> + >> +/* fprintf macros for signed integers */ >> + >> +#define PRId8 "d" /* int8_t */ >> +#define PRId16 "d" /* int16_t */ >> +#define PRId32 "d" /* int32_t */ >> +#define PRId64 "lld" /* int64_t */ >> +#define PRIdLEAST8 "d" /* int_least8_t */ >> +#define PRIdLEAST16 "d" /* int_least16_t */ >> +#define PRIdLEAST32 "d" /* int_least32_t */ >> +#define PRIdLEAST64 "lld" /* int_least64_t */ >> +#define PRIdFAST8 "d" /* int_fast8_t */ >> +#define PRIdFAST16 "d" /* int_fast16_t */ >> +#define PRIdFAST32 "d" /* int_fast32_t */ >> +#define PRIdFAST64 "lld" /* int_fast64_t */ >> +#define PRIdMAX "lld" /* intmax_t */ >> +#define PRIdPTR "d" /* intptr_t */ >> + >> +#define PRIi8 "i" /* int8_t */ >> +#define PRIi16 "i" /* int16_t */ >> +#define PRIi32 "i" /* int32_t */ >> +#define PRIi64 "lli" /* int64_t */ >> +#define PRIiLEAST8 "i" /* int_least8_t */ >> +#define PRIiLEAST16 "i" /* int_least16_t */ >> +#define PRIiLEAST32 "i" /* int_least32_t */ >> +#define PRIiLEAST64 "lli" /* int_least64_t */ >> +#define PRIiFAST8 "i" /* int_fast8_t */ >> +#define PRIiFAST16 "i" /* int_fast16_t */ >> +#define PRIiFAST32 "i" /* int_fast32_t */ >> +#define PRIiFAST64 "lli" /* int_fast64_t */ >> +#define PRIiMAX "lli" /* intmax_t */ >> +#define PRIiPTR "i" /* intptr_t */ >> + >> +/* fprintf macros for unsigned integers */ >> + >> +#define PRIo8 "o" /* uint8_t */ >> +#define PRIo16 "o" /* uint16_t */ >> +#define PRIo32 "o" /* uint32_t */ >> +#define PRIo64 "llo" /* uint64_t */ >> +#define PRIoLEAST8 "o" /* uint_least8_t */ >> +#define PRIoLEAST16 "o" /* uint_least16_t */ >> +#define PRIoLEAST32 "o" /* uint_least32_t */ >> +#define PRIoLEAST64 "llo" /* uint_least64_t */ >> +#define PRIoFAST8 "o" /* uint_fast8_t */ >> +#define PRIoFAST16 "o" /* uint_fast16_t */ >> +#define PRIoFAST32 "o" /* uint_fast32_t */ >> +#define PRIoFAST64 "llo" /* uint_fast64_t */ >> +#define PRIoMAX "llo" /* uintmax_t */ >> +#define PRIoPTR "o" /* uintptr_t */ >> + >> +#define PRIu8 "u" /* uint8_t */ >> +#define PRIu16 "u" /* uint16_t */ >> +#define PRIu32 "u" /* uint32_t */ >> +#define PRIu64 "llu" /* uint64_t */ >> +#define PRIuLEAST8 "u" /* uint_least8_t */ >> +#define PRIuLEAST16 "u" /* uint_least16_t */ >> +#define PRIuLEAST32 "u" /* uint_least32_t */ >> +#define PRIuLEAST64 "llu" /* uint_least64_t */ >> +#define PRIuFAST8 "u" /* uint_fast8_t */ >> +#define PRIuFAST16 "u" /* uint_fast16_t */ >> +#define PRIuFAST32 "u" /* uint_fast32_t */ >> +#define PRIuFAST64 "llu" /* uint_fast64_t */ >> +#define PRIuMAX "llu" /* uintmax_t */ >> +#define PRIuPTR "u" /* uintptr_t */ >> + >> +#define PRIx8 "x" /* uint8_t */ >> +#define PRIx16 "x" /* uint16_t */ >> +#define PRIx32 "x" /* uint32_t */ >> +#define PRIx64 "llx" /* uint64_t */ >> +#define PRIxLEAST8 "x" /* uint_least8_t */ >> +#define PRIxLEAST16 "x" /* uint_least16_t */ >> +#define PRIxLEAST32 "x" /* uint_least32_t */ >> +#define PRIxLEAST64 "llx" /* uint_least64_t */ >> +#define PRIxFAST8 "x" /* uint_fast8_t */ >> +#define PRIxFAST16 "x" /* uint_fast16_t */ >> +#define PRIxFAST32 "x" /* uint_fast32_t */ >> +#define PRIxFAST64 "llx" /* uint_fast64_t */ >> +#define PRIxMAX "llx" /* uintmax_t */ >> +#define PRIxPTR "x" /* uintptr_t */ >> + >> +#define PRIX8 "X" /* uint8_t */ >> +#define PRIX16 "X" /* uint16_t */ >> +#define PRIX32 "X" /* uint32_t */ >> +#define PRIX64 "llX" /* uint64_t */ >> +#define PRIXLEAST8 "X" /* uint_least8_t */ >> +#define PRIXLEAST16 "X" /* uint_least16_t */ >> +#define PRIXLEAST32 "X" /* uint_least32_t */ >> +#define PRIXLEAST64 "llX" /* uint_least64_t */ >> +#define PRIXFAST8 "X" /* uint_fast8_t */ >> +#define PRIXFAST16 "X" /* uint_fast16_t */ >> +#define PRIXFAST32 "X" /* uint_fast32_t */ >> +#define PRIXFAST64 "llX" /* uint_fast64_t */ >> +#define PRIXMAX "llX" /* uintmax_t */ >> +#define PRIXPTR "X" /* uintptr_t */ >> + >> +/* fscanf macros for signed integers */ >> + >> +#define SCNd8 "hhd" /* int8_t */ >> +#define SCNd16 "hd" /* int16_t */ >> +#define SCNd32 "d" /* int32_t */ >> +#define SCNd64 "lld" /* int64_t */ >> +#define SCNdLEAST8 "hhd" /* int_least8_t */ >> +#define SCNdLEAST16 "hd" /* int_least16_t */ >> +#define SCNdLEAST32 "d" /* int_least32_t */ >> +#define SCNdLEAST64 "lld" /* int_least64_t */ >> +#define SCNdFAST8 "d" /* int_fast8_t */ >> +#define SCNdFAST16 "d" /* int_fast16_t */ >> +#define SCNdFAST32 "d" /* int_fast32_t */ >> +#define SCNdFAST64 "lld" /* int_fast64_t */ >> +#define SCNdMAX "lld" /* intmax_t */ >> +#define SCNdPTR "d" /* intptr_t */ >> + >> +#define SCNi8 "hhi" /* int8_t */ >> +#define SCNi16 "hi" /* int16_t */ >> +#define SCNi32 "i" /* int32_t */ >> +#define SCNi64 "lli" /* int64_t */ >> +#define SCNiLEAST8 "hhi" /* int_least8_t */ >> +#define SCNiLEAST16 "hi" /* int_least16_t */ >> +#define SCNiLEAST32 "i" /* int_least32_t */ >> +#define SCNiLEAST64 "lli" /* int_least64_t */ >> +#define SCNiFAST8 "i" /* int_fast8_t */ >> +#define SCNiFAST16 "i" /* int_fast16_t */ >> +#define SCNiFAST32 "i" /* int_fast32_t */ >> +#define SCNiFAST64 "lli" /* int_fast64_t */ >> +#define SCNiMAX "lli" /* intmax_t */ >> +#define SCNiPTR "i" /* intptr_t */ >> + >> +/* fscanf macros for unsigned integers */ >> + >> +#define SCNo8 "hho" /* uint8_t */ >> +#define SCNo16 "ho" /* uint16_t */ >> +#define SCNo32 "o" /* uint32_t */ >> +#define SCNo64 "llo" /* uint64_t */ >> +#define SCNoLEAST8 "hho" /* uint_least8_t */ >> +#define SCNoLEAST16 "ho" /* uint_least16_t */ >> +#define SCNoLEAST32 "o" /* uint_least32_t */ >> +#define SCNoLEAST64 "llo" /* uint_least64_t */ >> +#define SCNoFAST8 "o" /* uint_fast8_t */ >> +#define SCNoFAST16 "o" /* uint_fast16_t */ >> +#define SCNoFAST32 "o" /* uint_fast32_t */ >> +#define SCNoFAST64 "llo" /* uint_fast64_t */ >> +#define SCNoMAX "llo" /* uintmax_t */ >> +#define SCNoPTR "o" /* uintptr_t */ >> + >> +#define SCNu8 "hhu" /* uint8_t */ >> +#define SCNu16 "hu" /* uint16_t */ >> +#define SCNu32 "u" /* uint32_t */ >> +#define SCNu64 "llu" /* uint64_t */ >> +#define SCNuLEAST8 "hhu" /* uint_least8_t */ >> +#define SCNuLEAST16 "hu" /* uint_least16_t */ >> +#define SCNuLEAST32 "u" /* uint_least32_t */ >> +#define SCNuLEAST64 "llu" /* uint_least64_t */ >> +#define SCNuFAST8 "u" /* uint_fast8_t */ >> +#define SCNuFAST16 "u" /* uint_fast16_t */ >> +#define SCNuFAST32 "u" /* uint_fast32_t */ >> +#define SCNuFAST64 "llu" /* uint_fast64_t */ >> +#define SCNuMAX "llu" /* uintmax_t */ >> +#define SCNuPTR "u" /* uintptr_t */ >> + >> +#define SCNx8 "hhx" /* uint8_t */ >> +#define SCNx16 "hx" /* uint16_t */ >> +#define SCNx32 "x" /* uint32_t */ >> +#define SCNx64 "llx" /* uint64_t */ >> +#define SCNxLEAST8 "hhx" /* uint_least8_t */ >> +#define SCNxLEAST16 "hx" /* uint_least16_t */ >> +#define SCNxLEAST32 "x" /* uint_least32_t */ >> +#define SCNxLEAST64 "llx" /* uint_least64_t */ >> +#define SCNxFAST8 "x" /* uint_fast8_t */ >> +#define SCNxFAST16 "x" /* uint_fast16_t */ >> +#define SCNxFAST32 "x" /* uint_fast32_t */ >> +#define SCNxFAST64 "llx" /* uint_fast64_t */ >> +#define SCNxMAX "llx" /* uintmax_t */ >> +#define SCNxPTR "x" /* uintptr_t */ >> + >> +#endif /* !_I386_INT_FMTIO_H_ */ >> diff --git a/StdLib/Include/X64/machine/int_fmtio.h >> b/StdLib/Include/X64/machine/int_fmtio.h >> index 181cc26..c2ebb30 100644 >> --- a/StdLib/Include/X64/machine/int_fmtio.h >> +++ b/StdLib/Include/X64/machine/int_fmtio.h >> @@ -1,4 +1,4 @@ >> -/* $NetBSD: int_fmtio.h,v 1.4 2005/12/11 12:16:25 christos Exp $ */ >> +/* $NetBSD: int_fmtio.h,v 1.4 2005/12/11 12:16:25 christos Exp $ >> */ >> >> /*- >> * Copyright (c) 2001 The NetBSD Foundation, Inc. >> @@ -45,175 +45,175 @@ >> >> /* fprintf macros for signed integers */ >> >> -#define PRId8 "d" /* int8_t */ >> -#define PRId16 "d" /* int16_t */ >> -#define PRId32 "d" /* int32_t */ >> -#define PRId64 "ld" /* int64_t */ >> -#define PRIdLEAST8 "d" /* int_least8_t */ >> -#define PRIdLEAST16 "d" /* int_least16_t */ >> -#define PRIdLEAST32 "d" /* int_least32_t */ >> -#define PRIdLEAST64 "ld" /* int_least64_t */ >> -#define PRIdFAST8 "d" /* int_fast8_t */ >> -#define PRIdFAST16 "d" /* int_fast16_t */ >> -#define PRIdFAST32 "d" /* int_fast32_t */ >> -#define PRIdFAST64 "ld" /* int_fast64_t */ >> -#define PRIdMAX "ld" /* intmax_t */ >> -#define PRIdPTR "ld" /* intptr_t */ >> - >> -#define PRIi8 "i" /* int8_t */ >> -#define PRIi16 "i" /* int16_t */ >> -#define PRIi32 "i" /* int32_t */ >> -#define PRIi64 "li" /* int64_t */ >> -#define PRIiLEAST8 "i" /* int_least8_t */ >> -#define PRIiLEAST16 "i" /* int_least16_t */ >> -#define PRIiLEAST32 "i" /* int_least32_t */ >> -#define PRIiLEAST64 "li" /* int_least64_t */ >> -#define PRIiFAST8 "i" /* int_fast8_t */ >> -#define PRIiFAST16 "i" /* int_fast16_t */ >> -#define PRIiFAST32 "i" /* int_fast32_t */ >> -#define PRIiFAST64 "li" /* int_fast64_t */ >> -#define PRIiMAX "li" /* intmax_t */ >> -#define PRIiPTR "li" /* intptr_t */ >> +#define PRId8 "d" /* int8_t */ >> +#define PRId16 "d" /* int16_t */ >> +#define PRId32 "d" /* int32_t */ >> +#define PRId64 "lld" /* int64_t */ /*ll* for GCC build >> with EDK2 */ >> +#define PRIdLEAST8 "d" /* int_least8_t */ >> +#define PRIdLEAST16 "d" /* int_least16_t */ >> +#define PRIdLEAST32 "d" /* int_least32_t */ >> +#define PRIdLEAST64 "ld" /* int_least64_t */ >> +#define PRIdFAST8 "d" /* int_fast8_t */ >> +#define PRIdFAST16 "d" /* int_fast16_t */ >> +#define PRIdFAST32 "d" /* int_fast32_t */ >> +#define PRIdFAST64 "lld" /* int_fast64_t */ >> +#define PRIdMAX "lld" /* intmax_t */ >> +#define PRIdPTR "ld" /* intptr_t */ >> + >> +#define PRIi8 "i" /* int8_t */ >> +#define PRIi16 "i" /* int16_t */ >> +#define PRIi32 "i" /* int32_t */ >> +#define PRIi64 "lli" /* int64_t */ /*ll* for GCC build >> with EDK2 */ >> +#define PRIiLEAST8 "i" /* int_least8_t */ >> +#define PRIiLEAST16 "i" /* int_least16_t */ >> +#define PRIiLEAST32 "i" /* int_least32_t */ >> +#define PRIiLEAST64 "lli" /* int_least64_t */ >> +#define PRIiFAST8 "i" /* int_fast8_t */ >> +#define PRIiFAST16 "i" /* int_fast16_t */ >> +#define PRIiFAST32 "i" /* int_fast32_t */ >> +#define PRIiFAST64 "lli" /* int_fast64_t */ >> +#define PRIiMAX "lli" /* intmax_t */ >> +#define PRIiPTR "li" /* intptr_t */ >> >> /* fprintf macros for unsigned integers */ >> >> -#define PRIo8 "o" /* uint8_t */ >> -#define PRIo16 "o" /* uint16_t */ >> -#define PRIo32 "o" /* uint32_t */ >> -#define PRIo64 "lo" /* uint64_t */ >> -#define PRIoLEAST8 "o" /* uint_least8_t */ >> -#define PRIoLEAST16 "o" /* uint_least16_t */ >> -#define PRIoLEAST32 "o" /* uint_least32_t */ >> -#define PRIoLEAST64 "lo" /* uint_least64_t */ >> -#define PRIoFAST8 "o" /* uint_fast8_t */ >> -#define PRIoFAST16 "o" /* uint_fast16_t */ >> -#define PRIoFAST32 "o" /* uint_fast32_t */ >> -#define PRIoFAST64 "lo" /* uint_fast64_t */ >> -#define PRIoMAX "lo" /* uintmax_t */ >> -#define PRIoPTR "lo" /* uintptr_t */ >> - >> -#define PRIu8 "u" /* uint8_t */ >> -#define PRIu16 "u" /* uint16_t */ >> -#define PRIu32 "u" /* uint32_t */ >> -#define PRIu64 "lu" /* uint64_t */ >> -#define PRIuLEAST8 "u" /* uint_least8_t */ >> -#define PRIuLEAST16 "u" /* uint_least16_t */ >> -#define PRIuLEAST32 "u" /* uint_least32_t */ >> -#define PRIuLEAST64 "lu" /* uint_least64_t */ >> -#define PRIuFAST8 "u" /* uint_fast8_t */ >> -#define PRIuFAST16 "u" /* uint_fast16_t */ >> -#define PRIuFAST32 "u" /* uint_fast32_t */ >> -#define PRIuFAST64 "lu" /* uint_fast64_t */ >> -#define PRIuMAX "lu" /* uintmax_t */ >> -#define PRIuPTR "lu" /* uintptr_t */ >> - >> -#define PRIx8 "x" /* uint8_t */ >> -#define PRIx16 "x" /* uint16_t */ >> -#define PRIx32 "x" /* uint32_t */ >> -#define PRIx64 "lx" /* uint64_t */ >> -#define PRIxLEAST8 "x" /* uint_least8_t */ >> -#define PRIxLEAST16 "x" /* uint_least16_t */ >> -#define PRIxLEAST32 "x" /* uint_least32_t */ >> -#define PRIxLEAST64 "lx" /* uint_least64_t */ >> -#define PRIxFAST8 "x" /* uint_fast8_t */ >> -#define PRIxFAST16 "x" /* uint_fast16_t */ >> -#define PRIxFAST32 "x" /* uint_fast32_t */ >> -#define PRIxFAST64 "lx" /* uint_fast64_t */ >> -#define PRIxMAX "lx" /* uintmax_t */ >> -#define PRIxPTR "lx" /* uintptr_t */ >> - >> -#define PRIX8 "X" /* uint8_t */ >> -#define PRIX16 "X" /* uint16_t */ >> -#define PRIX32 "X" /* uint32_t */ >> -#define PRIX64 "lX" /* uint64_t */ >> -#define PRIXLEAST8 "X" /* uint_least8_t */ >> -#define PRIXLEAST16 "X" /* uint_least16_t */ >> -#define PRIXLEAST32 "X" /* uint_least32_t */ >> -#define PRIXLEAST64 "lX" /* uint_least64_t */ >> -#define PRIXFAST8 "X" /* uint_fast8_t */ >> -#define PRIXFAST16 "X" /* uint_fast16_t */ >> -#define PRIXFAST32 "X" /* uint_fast32_t */ >> -#define PRIXFAST64 "lX" /* uint_fast64_t */ >> -#define PRIXMAX "lX" /* uintmax_t */ >> -#define PRIXPTR "lX" /* uintptr_t */ >> +#define PRIo8 "o" /* uint8_t */ >> +#define PRIo16 "o" /* uint16_t */ >> +#define PRIo32 "o" /* uint32_t */ >> +#define PRIo64 "llo" /* uint64_t */ /*ll* for GCC build >> with EDK2 */ >> +#define PRIoLEAST8 "o" /* uint_least8_t */ >> +#define PRIoLEAST16 "o" /* uint_least16_t */ >> +#define PRIoLEAST32 "o" /* uint_least32_t */ >> +#define PRIoLEAST64 "llo" /* uint_least64_t */ >> +#define PRIoFAST8 "o" /* uint_fast8_t */ >> +#define PRIoFAST16 "o" /* uint_fast16_t */ >> +#define PRIoFAST32 "o" /* uint_fast32_t */ >> +#define PRIoFAST64 "llo" /* uint_fast64_t */ >> +#define PRIoMAX "llo" /* uintmax_t */ >> +#define PRIoPTR "lo" /* uintptr_t */ >> + >> +#define PRIu8 "u" /* uint8_t */ >> +#define PRIu16 "u" /* uint16_t */ >> +#define PRIu32 "u" /* uint32_t */ >> +#define PRIu64 "llu" /* uint64_t */ /*ll* for GCC build >> with EDK2 */ >> +#define PRIuLEAST8 "u" /* uint_least8_t */ >> +#define PRIuLEAST16 "u" /* uint_least16_t */ >> +#define PRIuLEAST32 "u" /* uint_least32_t */ >> +#define PRIuLEAST64 "llu" /* uint_least64_t */ >> +#define PRIuFAST8 "u" /* uint_fast8_t */ >> +#define PRIuFAST16 "u" /* uint_fast16_t */ >> +#define PRIuFAST32 "u" /* uint_fast32_t */ >> +#define PRIuFAST64 "llu" /* uint_fast64_t */ >> +#define PRIuMAX "llu" /* uintmax_t */ >> +#define PRIuPTR "lu" /* uintptr_t */ >> + >> +#define PRIx8 "x" /* uint8_t */ >> +#define PRIx16 "x" /* uint16_t */ >> +#define PRIx32 "x" /* uint32_t */ >> +#define PRIx64 "llx" /* uint64_t */ /*ll* for GCC build >> with EDK2 */ >> +#define PRIxLEAST8 "x" /* uint_least8_t */ >> +#define PRIxLEAST16 "x" /* uint_least16_t */ >> +#define PRIxLEAST32 "x" /* uint_least32_t */ >> +#define PRIxLEAST64 "llx" /* uint_least64_t */ >> +#define PRIxFAST8 "x" /* uint_fast8_t */ >> +#define PRIxFAST16 "x" /* uint_fast16_t */ >> +#define PRIxFAST32 "x" /* uint_fast32_t */ >> +#define PRIxFAST64 "llx" /* uint_fast64_t */ >> +#define PRIxMAX "llx" /* uintmax_t */ >> +#define PRIxPTR "lx" /* uintptr_t */ >> + >> +#define PRIX8 "X" /* uint8_t */ >> +#define PRIX16 "X" /* uint16_t */ >> +#define PRIX32 "X" /* uint32_t */ >> +#define PRIX64 "llX" /* uint64_t */ /*ll* for GCC build >> with EDK2 */ >> +#define PRIXLEAST8 "X" /* uint_least8_t */ >> +#define PRIXLEAST16 "X" /* uint_least16_t */ >> +#define PRIXLEAST32 "X" /* uint_least32_t */ >> +#define PRIXLEAST64 "llX" /* uint_least64_t */ >> +#define PRIXFAST8 "X" /* uint_fast8_t */ >> +#define PRIXFAST16 "X" /* uint_fast16_t */ >> +#define PRIXFAST32 "X" /* uint_fast32_t */ >> +#define PRIXFAST64 "llX" /* uint_fast64_t */ >> +#define PRIXMAX "llX" /* uintmax_t */ >> +#define PRIXPTR "lX" /* uintptr_t */ >> >> /* fscanf macros for signed integers */ >> >> -#define SCNd8 "hhd" /* int8_t */ >> -#define SCNd16 "hd" /* int16_t */ >> -#define SCNd32 "d" /* int32_t */ >> -#define SCNd64 "ld" /* int64_t */ >> -#define SCNdLEAST8 "hhd" /* int_least8_t */ >> -#define SCNdLEAST16 "hd" /* int_least16_t */ >> -#define SCNdLEAST32 "d" /* int_least32_t */ >> -#define SCNdLEAST64 "ld" /* int_least64_t */ >> -#define SCNdFAST8 "d" /* int_fast8_t */ >> -#define SCNdFAST16 "d" /* int_fast16_t */ >> -#define SCNdFAST32 "d" /* int_fast32_t */ >> -#define SCNdFAST64 "ld" /* int_fast64_t */ >> -#define SCNdMAX "ld" /* intmax_t */ >> -#define SCNdPTR "ld" /* intptr_t */ >> - >> -#define SCNi8 "hhi" /* int8_t */ >> -#define SCNi16 "hi" /* int16_t */ >> -#define SCNi32 "i" /* int32_t */ >> -#define SCNi64 "li" /* int64_t */ >> -#define SCNiLEAST8 "hhi" /* int_least8_t */ >> -#define SCNiLEAST16 "hi" /* int_least16_t */ >> -#define SCNiLEAST32 "i" /* int_least32_t */ >> -#define SCNiLEAST64 "li" /* int_least64_t */ >> -#define SCNiFAST8 "i" /* int_fast8_t */ >> -#define SCNiFAST16 "i" /* int_fast16_t */ >> -#define SCNiFAST32 "i" /* int_fast32_t */ >> -#define SCNiFAST64 "li" /* int_fast64_t */ >> -#define SCNiMAX "li" /* intmax_t */ >> -#define SCNiPTR "li" /* intptr_t */ >> +#define SCNd8 "hhd" /* int8_t */ >> +#define SCNd16 "hd" /* int16_t */ >> +#define SCNd32 "d" /* int32_t */ >> +#define SCNd64 "lld" /* int64_t */ /*ll* for GCC build >> with EDK2 */ >> +#define SCNdLEAST8 "hhd" /* int_least8_t */ >> +#define SCNdLEAST16 "hd" /* int_least16_t */ >> +#define SCNdLEAST32 "d" /* int_least32_t */ >> +#define SCNdLEAST64 "lld" /* int_least64_t */ >> +#define SCNdFAST8 "d" /* int_fast8_t */ >> +#define SCNdFAST16 "d" /* int_fast16_t */ >> +#define SCNdFAST32 "d" /* int_fast32_t */ >> +#define SCNdFAST64 "lld" /* int_fast64_t */ >> +#define SCNdMAX "lld" /* intmax_t */ >> +#define SCNdPTR "ld" /* intptr_t */ >> + >> +#define SCNi8 "hhi" /* int8_t */ >> +#define SCNi16 "hi" /* int16_t */ >> +#define SCNi32 "i" /* int32_t */ >> +#define SCNi64 "lli" /* int64_t */ /*ll* for GCC build >> with EDK2 */ >> +#define SCNiLEAST8 "hhi" /* int_least8_t */ >> +#define SCNiLEAST16 "hi" /* int_least16_t */ >> +#define SCNiLEAST32 "i" /* int_least32_t */ >> +#define SCNiLEAST64 "lli" /* int_least64_t */ >> +#define SCNiFAST8 "i" /* int_fast8_t */ >> +#define SCNiFAST16 "i" /* int_fast16_t */ >> +#define SCNiFAST32 "i" /* int_fast32_t */ >> +#define SCNiFAST64 "lli" /* int_fast64_t */ >> +#define SCNiMAX "lli" /* intmax_t */ >> +#define SCNiPTR "li" /* intptr_t */ >> >> /* fscanf macros for unsigned integers */ >> >> -#define SCNo8 "hho" /* uint8_t */ >> -#define SCNo16 "ho" /* uint16_t */ >> -#define SCNo32 "o" /* uint32_t */ >> -#define SCNo64 "lo" /* uint64_t */ >> -#define SCNoLEAST8 "hho" /* uint_least8_t */ >> -#define SCNoLEAST16 "ho" /* uint_least16_t */ >> -#define SCNoLEAST32 "o" /* uint_least32_t */ >> -#define SCNoLEAST64 "lo" /* uint_least64_t */ >> -#define SCNoFAST8 "o" /* uint_fast8_t */ >> -#define SCNoFAST16 "o" /* uint_fast16_t */ >> -#define SCNoFAST32 "o" /* uint_fast32_t */ >> -#define SCNoFAST64 "lo" /* uint_fast64_t */ >> -#define SCNoMAX "lo" /* uintmax_t */ >> -#define SCNoPTR "lo" /* uintptr_t */ >> - >> -#define SCNu8 "hhu" /* uint8_t */ >> -#define SCNu16 "hu" /* uint16_t */ >> -#define SCNu32 "u" /* uint32_t */ >> -#define SCNu64 "lu" /* uint64_t */ >> -#define SCNuLEAST8 "hhu" /* uint_least8_t */ >> -#define SCNuLEAST16 "hu" /* uint_least16_t */ >> -#define SCNuLEAST32 "u" /* uint_least32_t */ >> -#define SCNuLEAST64 "lu" /* uint_least64_t */ >> -#define SCNuFAST8 "u" /* uint_fast8_t */ >> -#define SCNuFAST16 "u" /* uint_fast16_t */ >> -#define SCNuFAST32 "u" /* uint_fast32_t */ >> -#define SCNuFAST64 "lu" /* uint_fast64_t */ >> -#define SCNuMAX "lu" /* uintmax_t */ >> -#define SCNuPTR "lu" /* uintptr_t */ >> - >> -#define SCNx8 "hhx" /* uint8_t */ >> -#define SCNx16 "hx" /* uint16_t */ >> -#define SCNx32 "x" /* uint32_t */ >> -#define SCNx64 "lx" /* uint64_t */ >> -#define SCNxLEAST8 "hhx" /* uint_least8_t */ >> -#define SCNxLEAST16 "hx" /* uint_least16_t */ >> -#define SCNxLEAST32 "x" /* uint_least32_t */ >> -#define SCNxLEAST64 "lx" /* uint_least64_t */ >> -#define SCNxFAST8 "x" /* uint_fast8_t */ >> -#define SCNxFAST16 "x" /* uint_fast16_t */ >> -#define SCNxFAST32 "x" /* uint_fast32_t */ >> -#define SCNxFAST64 "lx" /* uint_fast64_t */ >> -#define SCNxMAX "lx" /* uintmax_t */ >> -#define SCNxPTR "lx" /* uintptr_t */ >> +#define SCNo8 "hho" /* uint8_t */ >> +#define SCNo16 "ho" /* uint16_t */ >> +#define SCNo32 "o" /* uint32_t */ >> +#define SCNo64 "llo" /* uint64_t */ /*ll* for GCC build >> with EDK2 */ >> +#define SCNoLEAST8 "hho" /* uint_least8_t */ >> +#define SCNoLEAST16 "ho" /* uint_least16_t */ >> +#define SCNoLEAST32 "o" /* uint_least32_t */ >> +#define SCNoLEAST64 "llo" /* uint_least64_t */ >> +#define SCNoFAST8 "o" /* uint_fast8_t */ >> +#define SCNoFAST16 "o" /* uint_fast16_t */ >> +#define SCNoFAST32 "o" /* uint_fast32_t */ >> +#define SCNoFAST64 "llo" /* uint_fast64_t */ >> +#define SCNoMAX "llo" /* uintmax_t */ >> +#define SCNoPTR "lo" /* uintptr_t */ >> + >> +#define SCNu8 "hhu" /* uint8_t */ >> +#define SCNu16 "hu" /* uint16_t */ >> +#define SCNu32 "u" /* uint32_t */ >> +#define SCNu64 "llu" /* uint64_t */ /*ll* for GCC build >> with EDK2 */ >> +#define SCNuLEAST8 "hhu" /* uint_least8_t */ >> +#define SCNuLEAST16 "hu" /* uint_least16_t */ >> +#define SCNuLEAST32 "u" /* uint_least32_t */ >> +#define SCNuLEAST64 "llu" /* uint_least64_t */ >> +#define SCNuFAST8 "u" /* uint_fast8_t */ >> +#define SCNuFAST16 "u" /* uint_fast16_t */ >> +#define SCNuFAST32 "u" /* uint_fast32_t */ >> +#define SCNuFAST64 "llu" /* uint_fast64_t */ >> +#define SCNuMAX "llu" /* uintmax_t */ >> +#define SCNuPTR "lu" /* uintptr_t */ >> + >> +#define SCNx8 "hhx" /* uint8_t */ >> +#define SCNx16 "hx" /* uint16_t */ >> +#define SCNx32 "x" /* uint32_t */ >> +#define SCNx64 "llx" /* uint64_t */ /*ll* for GCC build >> with EDK2 */ >> +#define SCNxLEAST8 "hhx" /* uint_least8_t */ >> +#define SCNxLEAST16 "hx" /* uint_least16_t */ >> +#define SCNxLEAST32 "x" /* uint_least32_t */ >> +#define SCNxLEAST64 "llx" /* uint_least64_t */ >> +#define SCNxFAST8 "x" /* uint_fast8_t */ >> +#define SCNxFAST16 "x" /* uint_fast16_t */ >> +#define SCNxFAST32 "x" /* uint_fast32_t */ >> +#define SCNxFAST64 "llx" /* uint_fast64_t */ >> +#define SCNxMAX "llx" /* uintmax_t */ >> +#define SCNxPTR "lx" /* uintptr_t */ >> >> #endif /* !_AMD64_INT_FMTIO_H_ */ >> diff --git a/StdLib/Include/getopt.h b/StdLib/Include/getopt.h >> new file mode 100644 >> index 0000000..efe16d1 >> --- /dev/null >> +++ b/StdLib/Include/getopt.h >> @@ -0,0 +1,76 @@ >> +/* $OpenBSD: getopt.h,v 1.3 2013/11/22 21:32:49 millert Exp $ */ >> +/* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */ >> + >> +/*- >> + * Copyright (c) 2000 The NetBSD Foundation, Inc. >> + * All rights reserved. >> + * >> + * This code is derived from software contributed to The NetBSD >> Foundation >> + * by Dieter Baron and Thomas Klausner. >> + * >> + * Redistribution and use in source and binary forms, with or without >> + * modification, are permitted provided that the following conditions >> + * are met: >> + * 1. Redistributions of source code must retain the above copyright >> + * notice, this list of conditions and the following disclaimer. >> + * 2. Redistributions in binary form must reproduce the above >> copyright >> + * notice, this list of conditions and the following disclaimer in >> the >> + * documentation and/or other materials provided with the >> distribution. >> + * >> + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND >> CONTRIBUTORS >> + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT >> NOT LIMITED >> + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A >> PARTICULAR >> + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR >> CONTRIBUTORS >> + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >> EXEMPLARY, OR >> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT >> OF >> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR >> BUSINESS >> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, >> WHETHER IN >> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR >> OTHERWISE) >> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF >> ADVISED OF THE >> + * POSSIBILITY OF SUCH DAMAGE. >> + */ >> + >> +#ifndef _GETOPT_H_ >> +#define _GETOPT_H_ >> + >> +#include >> + >> +/* >> + * GNU-like getopt_long() >> + */ >> +#define no_argument 0 >> +#define required_argument 1 >> +#define optional_argument 2 >> + >> +struct option { >> + /* name of long option */ >> + const char *name; >> + /* >> + * one of no_argument, required_argument, and optional_argument: >> + * whether option takes an argument >> + */ >> + int has_arg; >> + /* if not NULL, set *flag to val when option found */ >> + int *flag; >> + /* if flag not NULL, value to set *flag to; else return value */ >> + int val; >> +}; >> + >> +__BEGIN_DECLS >> +int getopt_long(int, char * const *, const char *, >> + const struct option *, int *); >> +int getopt_long_only(int, char * const *, const char *, >> + const struct option *, int *); >> +#ifndef _GETOPT_DEFINED_ >> +#define _GETOPT_DEFINED_ >> +int getopt(int, char * const *, const char *); >> + >> +extern char *optarg; /* getopt(3) external >> variables */ >> +extern int opterr; >> +extern int optind; >> +extern int optopt; >> +extern int optreset; >> +#endif >> +__END_DECLS >> + >> +#endif /* !_GETOPT_H_ */ >> diff --git a/StdLib/Include/inttypes.h b/StdLib/Include/inttypes.h >> index 51cdb5b..4854214 100644 >> --- a/StdLib/Include/inttypes.h >> +++ b/StdLib/Include/inttypes.h >> @@ -39,7 +39,7 @@ >> #define _INTTYPES_H_ >> >> #include >> -//#include >> +#include >> #include >> #include >> >> diff --git a/StdLib/Include/sys/socket.h b/StdLib/Include/sys/socket.h >> index 11434ed..b9ace77 100644 >> --- a/StdLib/Include/sys/socket.h >> +++ b/StdLib/Include/sys/socket.h >> @@ -82,6 +82,12 @@ typedef __sa_family_t sa_family_t; >> #ifndef socklen_t >> typedef __socklen_t socklen_t; >> #define socklen_t __socklen_t >> +/*add some defines that some applications may look for to check for >> socklen_t type*/ >> +#define _SOCKLEN_T_DEFINED_ >> +#define _SOCKLEN_T_DECLARED >> +#define __socklen_t_defined >> +#define _SOCKLEN_T >> +#define __DEFINED_socklen_t >> #endif >> >> #include >> diff --git a/StdLib/Include/unistd.h b/StdLib/Include/unistd.h >> index b2fd923..5fb2fa7 100644 >> --- a/StdLib/Include/unistd.h >> +++ b/StdLib/Include/unistd.h >> @@ -37,9 +37,7 @@ int dup(int); >> int rename(const char *, const char *); >> >> /* Functions implemented for compatibility. */ >> -int getopt(int, char * const [], const char *); >> -extern char *optarg; /* getopt(3) external variables */ >> -extern int optind; >> +#include >> pid_t getpgrp(void); >> pid_t tcgetpgrp(int); >> char *getpass(const char *); >> @@ -156,9 +154,6 @@ long sysconf(int); >> int tcsetpgrp(int, pid_t); >> __aconst char *ttyname(int); >> >> -extern int opterr; >> -extern int optopt; >> -extern int optreset; >> extern char *suboptarg; >> >> int setegid(gid_t); >> diff --git a/StdLib/LibC/LibC.inf b/StdLib/LibC/LibC.inf >> index ad6a117..9539de6 100644 >> --- a/StdLib/LibC/LibC.inf >> +++ b/StdLib/LibC/LibC.inf >> @@ -104,6 +104,7 @@ >> LibStdLib >> LibStdio >> LibString >> + LibErr >> DevConsole >> >> ################################################################ >> diff --git a/StdLib/LibC/Uefi/Uefi.inf b/StdLib/LibC/Uefi/Uefi.inf >> index 1982dd9..817c985 100644 >> --- a/StdLib/LibC/Uefi/Uefi.inf >> +++ b/StdLib/LibC/Uefi/Uefi.inf >> @@ -31,6 +31,7 @@ >> Xform.c >> compat.c >> StubFunctions.c >> + getopt_long.c >> >> [Packages] >> StdLib/StdLib.dec >> diff --git a/StdLib/LibC/Uefi/compat.c b/StdLib/LibC/Uefi/compat.c >> index 251863f..ff62654 100644 >> --- a/StdLib/LibC/Uefi/compat.c >> +++ b/StdLib/LibC/Uefi/compat.c >> @@ -97,45 +97,7 @@ >> #include >> >> #ifndef HAVE_GETOPT >> -char *optarg; >> -int optind =3D 1; >> -int >> -getopt(int argc, char **argv, char *args) >> -{ >> - size_t n; >> - size_t nlen =3D strlen(args); >> - char cmd; >> - char rv; >> - >> - if (argv[optind] && *argv[optind] =3D=3D '-') { >> - cmd =3D *(argv[optind] + 1); >> - >> - for (n =3D 0; n < nlen; n++) { >> - if (args[n] =3D=3D ':') >> - continue; >> - if (args[n] =3D=3D cmd) { >> - rv =3D *(argv[optind] + 1); >> - if (args[n+1] =3D=3D ':') { >> - if (*(argv[optind] + 2) !=3D '\0') { >> - optarg =3D argv[optind] + 2; >> - optind +=3D 1; >> - } else { >> - optarg =3D argv[optind + 1]; >> - optind +=3D 2; >> - } >> - if (!optarg) >> - optarg=3D""; >> - return rv; >> - } else { >> - optarg =3D NULL; >> - optind +=3D 1; >> - return rv; >> - } >> - } >> - } >> - } >> - return -1; >> -} >> +#include //functionality for getopt and getopt_long >> provided in getopt_long.c >> #endif >> >> #define ISPATHSEPARATOR(x) ((x =3D=3D '/') || (x =3D=3D '\\')) >> diff --git a/StdLib/LibC/Uefi/getopt_long.c >> b/StdLib/LibC/Uefi/getopt_long.c >> new file mode 100644 >> index 0000000..c76fd43 >> --- /dev/null >> +++ b/StdLib/LibC/Uefi/getopt_long.c >> @@ -0,0 +1,523 @@ >> +/* $OpenBSD: getopt_long.c,v 1.28 2015/09/19 04:02:21 guenther Exp $ >> */ >> +/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */ >> + >> +/* >> + * Copyright (c) 2002 Todd C. Miller >> + * >> + * Permission to use, copy, modify, and distribute this software for >> any >> + * purpose with or without fee is hereby granted, provided that the >> above >> + * copyright notice and this permission notice appear in all copies. >> + * >> + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL >> WARRANTIES >> + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF >> + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE >> LIABLE FOR >> + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY >> DAMAGES >> + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN >> AN >> + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING >> OUT OF >> + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. >> + * >> + * Sponsored in part by the Defense Advanced Research Projects >> + * Agency (DARPA) and Air Force Research Laboratory, Air Force >> + * Materiel Command, USAF, under agreement number F39502-99-1-0512. >> + */ >> +/*- >> + * Copyright (c) 2000 The NetBSD Foundation, Inc. >> + * All rights reserved. >> + * >> + * This code is derived from software contributed to The NetBSD >> Foundation >> + * by Dieter Baron and Thomas Klausner. >> + * >> + * Redistribution and use in source and binary forms, with or without >> + * modification, are permitted provided that the following conditions >> + * are met: >> + * 1. Redistributions of source code must retain the above copyright >> + * notice, this list of conditions and the following disclaimer. >> + * 2. Redistributions in binary form must reproduce the above >> copyright >> + * notice, this list of conditions and the following disclaimer in >> the >> + * documentation and/or other materials provided with the >> distribution. >> + * >> + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND >> CONTRIBUTORS >> + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT >> NOT LIMITED >> + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A >> PARTICULAR >> + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR >> CONTRIBUTORS >> + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >> EXEMPLARY, OR >> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT >> OF >> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR >> BUSINESS >> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, >> WHETHER IN >> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR >> OTHERWISE) >> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF >> ADVISED OF THE >> + * POSSIBILITY OF SUCH DAMAGE. >> + */ >> + >> +#include /*warnx*/ >> +#include >> +#include >> +#include >> +#include >> + >> +int opterr =3D 1; /* if error message should be printed */ >> +int optind =3D 1; /* index into parent argv vector */ >> +int optopt =3D '?'; /* character checked for validity */ >> +int optreset; /* reset getopt */ >> +char *optarg; /* argument associated with option */ >> + >> +#if 0 >> +/* DEF_* only work on initialized (non-COMMON) variables */ >> +DEF_WEAK(opterr); >> +DEF_WEAK(optind); >> +DEF_WEAK(optopt); >> +#endif >> + >> +#define PRINT_ERROR ((opterr) && (*options !=3D ':')) >> + >> +#define FLAG_PERMUTE 0x01 /* permute non-options to the end of >> argv */ >> +#define FLAG_ALLARGS 0x02 /* treat non-options as args to >> option "-1" */ >> +#define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */ >> + >> +/* return values */ >> +#define BADCH (int)'?' >> +#define BADARG ((*options =3D=3D ':') ? (int)':' : (int)'?') >> +#define INORDER (int)1 >> + >> +#define EMSG "" >> + >> +static int getopt_internal(int, char * const *, const char *, >> + const struct option *, int *, int); >> +static int parse_long_options(char * const *, const char *, >> + const struct option *, int *, int, int); >> +static int gcd(int, int); >> +static void permute_args(int, int, int, char * const *); >> + >> +static char *place =3D EMSG; /* option letter processing */ >> + >> +/* XXX: set optreset to 1 rather than these two */ >> +static int nonopt_start =3D -1; /* first non option argument (for >> permute) */ >> +static int nonopt_end =3D -1; /* first option after non options (for >> permute) */ >> + >> +/* Error messages */ >> +static const char recargchar[] =3D "option requires an argument -- %c"; >> +static const char recargstring[] =3D "option requires an argument -- >> %s"; >> +static const char ambig[] =3D "ambiguous option -- %.*s"; >> +static const char noarg[] =3D "option doesn't take an argument -- >> %.*s"; >> +static const char illoptchar[] =3D "unknown option -- %c"; >> +static const char illoptstring[] =3D "unknown option -- %s"; >> + >> +/* >> + * Compute the greatest common divisor of a and b. >> + */ >> +static int >> +gcd(int a, int b) >> +{ >> + int c; >> + >> + c =3D a % b; >> + while (c !=3D 0) { >> + a =3D b; >> + b =3D c; >> + c =3D a % b; >> + } >> + >> + return (b); >> +} >> + >> +/* >> + * Exchange the block from nonopt_start to nonopt_end with the block >> + * from nonopt_end to opt_end (keeping the same order of arguments >> + * in each block). >> + */ >> +static void >> +permute_args(int panonopt_start, int panonopt_end, int opt_end, >> + char * const *nargv) >> +{ >> + int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos; >> + char *swap; >> + >> + /* >> + * compute lengths of blocks and number and size of cycles >> + */ >> + nnonopts =3D panonopt_end - panonopt_start; >> + nopts =3D opt_end - panonopt_end; >> + ncycle =3D gcd(nnonopts, nopts); >> + cyclelen =3D (opt_end - panonopt_start) / ncycle; >> + >> + for (i =3D 0; i < ncycle; i++) { >> + cstart =3D panonopt_end+i; >> + pos =3D cstart; >> + for (j =3D 0; j < cyclelen; j++) { >> + if (pos >=3D panonopt_end) >> + pos -=3D nnonopts; >> + else >> + pos +=3D nopts; >> + swap =3D nargv[pos]; >> + ((char **)nargv)[pos] =3D nargv[cstart]; >> + ((char **)nargv)[cstart] =3D swap; >> + } >> + } >> +} >> + >> +/* >> + * parse_long_options -- >> + * Parse long options in argc/argv argument vector. >> + * Returns -1 if short_too is set and the option does not match >> long_options. >> + */ >> +static int >> +parse_long_options(char * const *nargv, const char *options, >> + const struct option *long_options, int *idx, int short_too, int >> flags) >> +{ >> + char *current_argv, *has_equal; >> + size_t current_argv_len; >> + int i, match, exact_match, second_partial_match; >> + >> + current_argv =3D place; >> + match =3D -1; >> + exact_match =3D 0; >> + second_partial_match =3D 0; >> + >> + optind++; >> + >> + if ((has_equal =3D strchr(current_argv, '=3D')) !=3D NULL) { >> + /* argument found (--option=3Darg) */ >> + current_argv_len =3D has_equal - current_argv; >> + has_equal++; >> + } else >> + current_argv_len =3D strlen(current_argv); >> + >> + for (i =3D 0; long_options[i].name; i++) { >> + /* find matching long option */ >> + if (strncmp(current_argv, long_options[i].name, >> + current_argv_len)) >> + continue; >> + >> + if (strlen(long_options[i].name) =3D=3D current_argv_len) { >> + /* exact match */ >> + match =3D i; >> + exact_match =3D 1; >> + break; >> + } >> + /* >> + * If this is a known short option, don't allow >> + * a partial match of a single character. >> + */ >> + if (short_too && current_argv_len =3D=3D 1) >> + continue; >> + >> + if (match =3D=3D -1) /* first partial match */ >> + match =3D i; >> + else if ((flags & FLAG_LONGONLY) || >> + long_options[i].has_arg !=3D long_options[match].has_arg || >> + long_options[i].flag !=3D long_options[match].flag || >> + long_options[i].val !=3D long_options[match].val) >> + second_partial_match =3D 1; >> + } >> + if (!exact_match && second_partial_match) { >> + /* ambiguous abbreviation */ >> + if (PRINT_ERROR) >> + warnx(ambig, (int)current_argv_len, current_argv); >> + optopt =3D 0; >> + return (BADCH); >> + } >> + if (match !=3D -1) { /* option found */ >> + if (long_options[match].has_arg =3D=3D no_argument >> + && has_equal) { >> + if (PRINT_ERROR) >> + warnx(noarg, (int)current_argv_len, >> + current_argv); >> + /* >> + * XXX: GNU sets optopt to val regardless of flag >> + */ >> + if (long_options[match].flag =3D=3D NULL) >> + optopt =3D long_options[match].val; >> + else >> + optopt =3D 0; >> + return (BADARG); >> + } >> + if (long_options[match].has_arg =3D=3D required_argument || >> + long_options[match].has_arg =3D=3D optional_argument) { >> + if (has_equal) >> + optarg =3D has_equal; >> + else if (long_options[match].has_arg =3D=3D >> + required_argument) { >> + /* >> + * optional argument doesn't use next nargv >> + */ >> + optarg =3D nargv[optind++]; >> + } >> + } >> + if ((long_options[match].has_arg =3D=3D required_argument) >> + && (optarg =3D=3D NULL)) { >> + /* >> + * Missing argument; leading ':' indicates no error >> + * should be generated. >> + */ >> + if (PRINT_ERROR) >> + warnx(recargstring, >> + current_argv); >> + /* >> + * XXX: GNU sets optopt to val regardless of flag >> + */ >> + if (long_options[match].flag =3D=3D NULL) >> + optopt =3D long_options[match].val; >> + else >> + optopt =3D 0; >> + --optind; >> + return (BADARG); >> + } >> + } else { /* unknown option */ >> + if (short_too) { >> + --optind; >> + return (-1); >> + } >> + if (PRINT_ERROR) >> + warnx(illoptstring, current_argv); >> + optopt =3D 0; >> + return (BADCH); >> + } >> + if (idx) >> + *idx =3D match; >> + if (long_options[match].flag) { >> + *long_options[match].flag =3D long_options[match].val; >> + return (0); >> + } else >> + return (long_options[match].val); >> +} >> + >> +/* >> + * getopt_internal -- >> + * Parse argc/argv argument vector. Called by user level routines. >> + */ >> +static int >> +getopt_internal(int nargc, char * const *nargv, const char *options, >> + const struct option *long_options, int *idx, int flags) >> +{ >> + char *oli; /* option letter list index */ >> + int optchar, short_too; >> + static int posixly_correct =3D -1; >> + >> + if (options =3D=3D NULL) >> + return (-1); >> + >> + /* >> + * XXX Some GNU programs (like cvs) set optind to 0 instead of >> + * XXX using optreset. Work around this braindamage. >> + */ >> + if (optind =3D=3D 0) >> + optind =3D optreset =3D 1; >> + >> + /* >> + * Disable GNU extensions if POSIXLY_CORRECT is set or options >> + * string begins with a '+'. >> + */ >> + if (posixly_correct =3D=3D -1 || optreset) >> + posixly_correct =3D (getenv("POSIXLY_CORRECT") !=3D NULL); >> + if (*options =3D=3D '-') >> + flags |=3D FLAG_ALLARGS; >> + else if (posixly_correct || *options =3D=3D '+') >> + flags &=3D ~FLAG_PERMUTE; >> + if (*options =3D=3D '+' || *options =3D=3D '-') >> + options++; >> + >> + optarg =3D NULL; >> + if (optreset) >> + nonopt_start =3D nonopt_end =3D -1; >> +start: >> + if (optreset || !*place) { /* update scanning pointer */ >> + optreset =3D 0; >> + if (optind >=3D nargc) { /* end of argument vector */ >> + place =3D EMSG; >> + if (nonopt_end !=3D -1) { >> + /* do permutation, if we have to */ >> + permute_args(nonopt_start, nonopt_end, >> + optind, nargv); >> + optind -=3D nonopt_end - nonopt_start; >> + } >> + else if (nonopt_start !=3D -1) { >> + /* >> + * If we skipped non-options, set optind >> + * to the first of them. >> + */ >> + optind =3D nonopt_start; >> + } >> + nonopt_start =3D nonopt_end =3D -1; >> + return (-1); >> + } >> + if (*(place =3D nargv[optind]) !=3D '-' || >> + (place[1] =3D=3D '\0' && strchr(options, '-') =3D=3D NULL))= { >> + place =3D EMSG; /* found non-option */ >> + if (flags & FLAG_ALLARGS) { >> + /* >> + * GNU extension: >> + * return non-option as argument to option 1 >> + */ >> + optarg =3D nargv[optind++]; >> + return (INORDER); >> + } >> + if (!(flags & FLAG_PERMUTE)) { >> + /* >> + * If no permutation wanted, stop parsing >> + * at first non-option. >> + */ >> + return (-1); >> + } >> + /* do permutation */ >> + if (nonopt_start =3D=3D -1) >> + nonopt_start =3D optind; >> + else if (nonopt_end !=3D -1) { >> + permute_args(nonopt_start, nonopt_end, >> + optind, nargv); >> + nonopt_start =3D optind - >> + (nonopt_end - nonopt_start); >> + nonopt_end =3D -1; >> + } >> + optind++; >> + /* process next argument */ >> + goto start; >> + } >> + if (nonopt_start !=3D -1 && nonopt_end =3D=3D -1) >> + nonopt_end =3D optind; >> + >> + /* >> + * If we have "-" do nothing, if "--" we are done. >> + */ >> + if (place[1] !=3D '\0' && *++place =3D=3D '-' && place[1] =3D= =3D '\0') >> { >> + optind++; >> + place =3D EMSG; >> + /* >> + * We found an option (--), so if we skipped >> + * non-options, we have to permute. >> + */ >> + if (nonopt_end !=3D -1) { >> + permute_args(nonopt_start, nonopt_end, >> + optind, nargv); >> + optind -=3D nonopt_end - nonopt_start; >> + } >> + nonopt_start =3D nonopt_end =3D -1; >> + return (-1); >> + } >> + } >> + >> + /* >> + * Check long options if: >> + * 1) we were passed some >> + * 2) the arg is not just "-" >> + * 3) either the arg starts with -- we are getopt_long_only() >> + */ >> + if (long_options !=3D NULL && place !=3D nargv[optind] && >> + (*place =3D=3D '-' || (flags & FLAG_LONGONLY))) { >> + short_too =3D 0; >> + if (*place =3D=3D '-') >> + place++; /* --foo long option */ >> + else if (*place !=3D ':' && strchr(options, *place) !=3D NULL) >> + short_too =3D 1; /* could be short option too */ >> + >> + optchar =3D parse_long_options(nargv, options, long_options, >> + idx, short_too, flags); >> + if (optchar !=3D -1) { >> + place =3D EMSG; >> + return (optchar); >> + } >> + } >> + >> + if ((optchar =3D (int)*place++) =3D=3D (int)':' || >> + (optchar =3D=3D (int)'-' && *place !=3D '\0') || >> + (oli =3D strchr(options, optchar)) =3D=3D NULL) { >> + /* >> + * If the user specified "-" and '-' isn't listed in >> + * options, return -1 (non-option) as per POSIX. >> + * Otherwise, it is an unknown option character (or ':'). >> + */ >> + if (optchar =3D=3D (int)'-' && *place =3D=3D '\0') >> + return (-1); >> + if (!*place) >> + ++optind; >> + if (PRINT_ERROR) >> + warnx(illoptchar, optchar); >> + optopt =3D optchar; >> + return (BADCH); >> + } >> + if (long_options !=3D NULL && optchar =3D=3D 'W' && oli[1] =3D=3D '= ;') { >> + /* -W long-option */ >> + if (*place) /* no space */ >> + /* NOTHING */; >> + else if (++optind >=3D nargc) { /* no arg */ >> + place =3D EMSG; >> + if (PRINT_ERROR) >> + warnx(recargchar, optchar); >> + optopt =3D optchar; >> + return (BADARG); >> + } else /* white space */ >> + place =3D nargv[optind]; >> + optchar =3D parse_long_options(nargv, options, long_options, >> + idx, 0, flags); >> + place =3D EMSG; >> + return (optchar); >> + } >> + if (*++oli !=3D ':') { /* doesn't take argument */ >> + if (!*place) >> + ++optind; >> + } else { /* takes (optional) argument */ >> + optarg =3D NULL; >> + if (*place) /* no white space */ >> + optarg =3D place; >> + else if (oli[1] !=3D ':') { /* arg not optional */ >> + if (++optind >=3D nargc) { /* no arg */ >> + place =3D EMSG; >> + if (PRINT_ERROR) >> + warnx(recargchar, optchar); >> + optopt =3D optchar; >> + return (BADARG); >> + } else >> + optarg =3D nargv[optind]; >> + } >> + place =3D EMSG; >> + ++optind; >> + } >> + /* dump back option letter */ >> + return (optchar); >> +} >> + >> +/* >> + * getopt -- >> + * Parse argc/argv argument vector. >> + * >> + * [eventually this will replace the BSD getopt] >> + */ >> +int >> +getopt(int nargc, char * const *nargv, const char *options) >> +{ >> + >> + /* >> + * We don't pass FLAG_PERMUTE to getopt_internal() since >> + * the BSD getopt(3) (unlike GNU) has never done this. >> + * >> + * Furthermore, since many privileged programs call getopt() >> + * before dropping privileges it makes sense to keep things >> + * as simple (and bug-free) as possible. >> + */ >> + return (getopt_internal(nargc, nargv, options, NULL, NULL, 0)); >> +} >> + >> +/* >> + * getopt_long -- >> + * Parse argc/argv argument vector. >> + */ >> +int >> +getopt_long(int nargc, char * const *nargv, const char *options, >> + const struct option *long_options, int *idx) >> +{ >> + >> + return (getopt_internal(nargc, nargv, options, long_options, idx, >> + FLAG_PERMUTE)); >> +} >> + >> +/* >> + * getopt_long_only -- >> + * Parse argc/argv argument vector. >> + */ >> +int >> +getopt_long_only(int nargc, char * const *nargv, const char *options, >> + const struct option *long_options, int *idx) >> +{ >> + >> + return (getopt_internal(nargc, nargv, options, long_options, idx, >> + FLAG_PERMUTE|FLAG_LONGONLY)); >> +} >> -- >> 2.40.0.windows.1 >=20 >=20 >=20 >=20 >=20 >=20 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109907): https://edk2.groups.io/g/devel/message/109907 Mute This Topic: https://groups.io/mt/102081650/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-