[PATCH v2 28/32] mpi: Match the comments and layout of GCC's longlong.h.
Matt Turner
mattst88 at gmail.com
Wed Nov 25 21:20:05 CET 2026
* mpi/longlong.h: Remove the per-section banners. Take GCC's
wording for the introductory comments.
(__CLOBBER_CC, __AND_CLOBBER_CC, __ll_check_output): Do not indent
#define.
--
These are the remaining differences from GCC's copy that are not
libgcrypt's own code. This fixes the "multipler" typo along the way.
The object code is unchanged for x86-64 with GCC and Clang, and with
GCC for AArch64, Alpha, ARM, LoongArch, m68k, MIPS, PowerPC64, RISC-V,
s390x, SH4, 32-bit SPARC and 64-bit SPARC.
Signed-off-by: Matt Turner <mattst88 at gmail.com>
---
mpi/longlong.h | 116 ++++++++++-----------------------------------------------
1 file changed, 19 insertions(+), 97 deletions(-)
diff --git a/mpi/longlong.h b/mpi/longlong.h
index 3b905a03..43d8f66e 100644
--- a/mpi/longlong.h
+++ b/mpi/longlong.h
@@ -1,7 +1,6 @@
/* longlong.h -- definitions for mixed size 32/64 bit arithmetic.
Note: This is the Libgcrypt version
-
Copyright (C) 1991, 1992, 1993, 1994, 1996, 1998,
2000, 2001, 2002, 2003, 2004, 2011 Free Software Foundation, Inc.
@@ -34,18 +33,17 @@ SPDX-License-Identifier: LGPL-2.1-or-later
/* You have to define the following before including this file:
- UWtype -- An unsigned type, default type for operations (typically a "word").
+ UWtype -- An unsigned type, default type for operations (typically a "word")
UHWtype -- An unsigned type, at least half the size of UWtype.
- UDWtype -- An unsigned type, at least twice as large a UWtype.
- W_TYPE_SIZE -- size in bits of UWtype.
+ UDWtype -- An unsigned type, at least twice as large a UWtype
+ W_TYPE_SIZE -- size in bits of UWtype
UQItype -- Unsigned 8 bit type.
SItype, USItype -- Signed and unsigned 32 bit types.
DItype, UDItype -- Signed and unsigned 64 bit types.
- On a 32 bit machine UWtype should typically be USItype.
- On a 64 bit machine, UWtype should typically be UDItype.
-*/
+ On a 32 bit machine UWtype should typically be USItype;
+ on a 64 bit machine, UWtype should typically be UDItype. */
#define __BITS4 (W_TYPE_SIZE / 4)
#define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2))
@@ -71,8 +69,8 @@ extern const UQItype __clz_tab[256] attribute_hidden;
/* Define auxiliary asm macros.
- 1) umul_ppmm(high_prod, low_prod, multipler, multiplicand) multiplies two
- UWtype integers MULTIPLER and MULTIPLICAND, and generates a two UWtype
+ 1) umul_ppmm(high_prod, low_prod, multiplier, multiplicand) multiplies two
+ UWtype integers MULTIPLIER and MULTIPLICAND, and generates a two UWtype
word product in HIGH_PROD and LOW_PROD.
2) __umulsidi3(a,b) multiplies two UWtype integers A and B, and returns a
@@ -81,7 +79,7 @@ extern const UQItype __clz_tab[256] attribute_hidden;
3) udiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
denominator) divides a UDWtype, composed by the UWtype integers
HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and places the quotient
- in QUOTIENT and the remainder in REMAINDER. HIGH_NUMERATOR must be less
+ in QUOTIENT and the remainder in REMAINDER. HIGH_NUMERATOR must be less
than DENOMINATOR for correct operation. If, in addition, the most
significant bit of DENOMINATOR must be 1, then the pre-processor symbol
UDIV_NEEDS_NORMALIZATION is defined to 1.
@@ -91,7 +89,7 @@ extern const UQItype __clz_tab[256] attribute_hidden;
is rounded towards 0.
5) count_leading_zeros(count, x) counts the number of zero-bits from the
- msb to the first non-zero bit in the UWtype X. This is the number of
+ msb to the first nonzero bit in the UWtype X. This is the number of
steps X needs to be shifted left to set the msb. Undefined for X == 0,
unless the symbol COUNT_LEADING_ZEROS_0 is defined to some value.
@@ -108,7 +106,7 @@ extern const UQItype __clz_tab[256] attribute_hidden;
high_subtrahend, low_subtrahend) subtracts two two-word UWtype integers,
composed by HIGH_MINUEND_1 and LOW_MINUEND_1, and HIGH_SUBTRAHEND_2 and
LOW_SUBTRAHEND_2 respectively. The result is placed in HIGH_DIFFERENCE
- and LOW_DIFFERENCE. Overflow (i.e. carry out) is not stored anywhere,
+ and LOW_DIFFERENCE. Overflow (i.e. carry out) is not stored anywhere,
and is lost.
If any of these macros are left undefined for a particular CPU,
@@ -117,7 +115,8 @@ extern const UQItype __clz_tab[256] attribute_hidden;
/* The CPUs come in alphabetical order below.
Please add support for more CPUs here, or improve the current support
- for the CPUs below! */
+ for the CPUs below!
+ (E.g. WE32100, IBM360.) */
#ifdef __riscos__
#pragma continue_after_hash_error
@@ -125,13 +124,13 @@ extern const UQItype __clz_tab[256] attribute_hidden;
#if defined (__GNUC__) && !defined (NO_ASM)
/* We sometimes need to clobber "cc" with gcc2, but that would not be
- understood by gcc1. Use cpp to avoid major code duplication. */
+ understood by gcc1. Use cpp to avoid major code duplication. */
#if __GNUC__ < 2
-# define __CLOBBER_CC
-# define __AND_CLOBBER_CC
+#define __CLOBBER_CC
+#define __AND_CLOBBER_CC
#else /* __GNUC__ >= 2 */
-# define __CLOBBER_CC : "cc"
-# define __AND_CLOBBER_CC , "cc"
+#define __CLOBBER_CC : "cc"
+#define __AND_CLOBBER_CC , "cc"
#endif /* __GNUC__ < 2 */
/* Asm output operand X, written as "=r" __ll_check_output (TYPE, X).
@@ -139,15 +138,11 @@ extern const UQItype __clz_tab[256] attribute_hidden;
which catches outputs of the wrong type. Clang rejects such casts, so
use X as is. */
#ifdef __clang__
-# define __ll_check_output(type, x) (x)
+#define __ll_check_output(type, x) (x)
#else
-# define __ll_check_output(type, x) ((type) (x))
+#define __ll_check_output(type, x) ((type) (x))
#endif
-/***************************************
- **** Begin CPU Specific Versions ****
- ***************************************/
-
#if defined (__aarch64__)
#if W_TYPE_SIZE == 32
@@ -218,9 +213,6 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
#endif /* __alpha_cix__ */
#endif /* __alpha */
-/***************************************
- ************** ARM ******************
- ***************************************/
#if defined (__arm__) && (defined (__thumb2__) || !defined (__thumb__)) \
&& W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
@@ -284,9 +276,6 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
#define COUNT_LEADING_ZEROS_0 32
#endif
-/***************************************
- ********** ARM64 / Aarch64 **********
- ***************************************/
#if defined(__aarch64__) && W_TYPE_SIZE == 64
# define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("adds %1, %4, %5\n" \
@@ -318,9 +307,6 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
} while (0)
#endif /* __aarch64__ */
-/***************************************
- ************** HPPA *****************
- ***************************************/
#if defined (__hppa) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add %4,%5,%1\n\taddc %2,%3,%0" \
@@ -389,10 +375,6 @@ extern USItype __udiv_qrnnd (USItype *, USItype, USItype, USItype);
} while (0)
#endif
-
-/***************************************
- ************** I370 *****************
- ***************************************/
#if (defined (__i370__) || defined (__s390__) || defined (__mvs__)) && W_TYPE_SIZE == 32
#if !defined (__zarch__)
#define smul_ppmm(xh, xl, m0, m1) \
@@ -441,11 +423,6 @@ extern USItype __udiv_qrnnd (USItype *, USItype, USItype, USItype);
#endif /* __zarch__ */
#endif
-
-
-/***************************************
- ************** I386 *****************
- ***************************************/
#if (defined (__i386__) || defined (__i486__)) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add{l} {%5,%1|%1,%5}\n\tadc{l} {%3,%0|%0,%3}" \
@@ -482,9 +459,6 @@ extern USItype __udiv_qrnnd (USItype *, USItype, USItype, USItype);
#define UDIV_TIME 40
#endif /* 80x86 */
-/***************************************
- *********** AMD64 / x86-64 ************
- ***************************************/
#if defined (__x86_64__) && W_TYPE_SIZE == 64
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add{q} {%5,%1|%1,%5}\n\tadc{q} {%3,%0|%0,%3}" \
@@ -521,10 +495,6 @@ extern USItype __udiv_qrnnd (USItype *, USItype, USItype, USItype);
#define UDIV_TIME 40
#endif /* x86_64 */
-
-/***************************************
- ************** I960 *****************
- ***************************************/
#if defined (__i960__) && W_TYPE_SIZE == 32
#define umul_ppmm(w1, w0, u, v) \
({union {UDItype __ll; \
@@ -552,10 +522,6 @@ extern USItype __udiv_qrnnd (USItype *, USItype, USItype, USItype);
# endif
#endif
-
-/***************************************
- ************** 68000 ****************
- ***************************************/
#if defined (__mc68000__) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add%.l %5,%1\n\taddx%.l %3,%0" \
@@ -689,10 +655,6 @@ extern USItype __udiv_qrnnd (USItype *, USItype, USItype, USItype);
#endif
#endif /* mc68000 */
-
-/***************************************
- ************** 88000 ****************
- ***************************************/
#if defined (__m88000__) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("addu.co %1,%r4,%r5\n\taddu.ci %0,%r2,%r3" \
@@ -751,9 +713,6 @@ extern USItype __udiv_qrnnd (USItype *, USItype, USItype, USItype);
#endif /* __m88110__ */
#endif /* __m88000__ */
-/***************************************
- ************** MIPS *****************
- ***************************************/
#if defined (__mips__) && W_TYPE_SIZE == 32
#define umul_ppmm(w1, w0, u, v) \
do { \
@@ -770,9 +729,6 @@ extern USItype __udiv_qrnnd (USItype *, USItype, USItype, USItype);
#endif
#endif /* __mips__ */
-/***************************************
- ************** MIPS/64 **************
- ***************************************/
#if (defined (__mips) && __mips >= 3) && W_TYPE_SIZE == 64
# if defined (__clang__) || (__GNUC__ >= 5) || (__GNUC__ == 4 && \
__GNUC_MINOR__ >= 4)
@@ -805,10 +761,6 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
# define UDIV_TIME 140
#endif /* __mips__ */
-
-/***************************************
- ************** PPC ******************
- ***************************************/
#if __GNUC__ >= 2 && (defined (_ARCH_PPC) || defined (_ARCH_PPC64) \
|| defined (__powerpc__) || defined (__powerpc64__))
# define __PPC_CLOBBER_CC : "cc", "xer"
@@ -956,9 +908,6 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
#define UDIV_TIME 120 /* ??? */
#endif /* 64-bit PowerPC. */
-/***************************************
- ************** RT/ROMP **************
- ***************************************/
#if defined (__ibm032__) /* RT/ROMP */ && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("a %1,%5\n\tae %0,%3" \
@@ -1063,10 +1012,6 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
#endif /* __riscv_mul */
#endif /* __riscv */
-
-/***************************************
- ************** SH2 ******************
- ***************************************/
#if defined(__sh__) && W_TYPE_SIZE == 32
#ifndef __sh1__
#define umul_ppmm(w1, w0, u, v) \
@@ -1140,9 +1085,6 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
#endif /* __sh__ */
-/***************************************
- ************** SPARC ****************
- ***************************************/
#if defined (__sparc__) && !defined (__arch64__) && !defined (__sparcv9) \
&& W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
@@ -1417,10 +1359,6 @@ extern USItype __udiv_qrnnd (USItype *, USItype, USItype, USItype);
#define UDIV_TIME 230
#endif /* sparc64 */
-
-/***************************************
- ************** VAX ******************
- ***************************************/
#if defined (__vax__) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("addl2 %5,%1\n\tadwc %3,%0" \
@@ -1466,10 +1404,6 @@ extern USItype __udiv_qrnnd (USItype *, USItype, USItype, USItype);
} while (0)
#endif /* __vax__ */
-
-/***************************************
- *********** s390x/zSeries ************
- ***************************************/
#if defined (__s390x__) && !defined (__MVS__) && W_TYPE_SIZE == 64 && __GNUC__ >= 4
# define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("algr %1,%5\n" \
@@ -1514,18 +1448,9 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
} while (0)
#endif /* __s390x__ */
-
-/***************************************
- ***** End CPU Specific Versions *****
- ***************************************/
-
#endif /* __GNUC__ */
#endif /* !__riscos__ */
-
-/***************************************
- *********** Generic Versions ********
- ***************************************/
#if !defined (umul_ppmm) && defined (__umulsidi3)
# define umul_ppmm(ph, pl, m0, m1) \
{ \
@@ -1780,6 +1705,3 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
# define UDIV_NEEDS_NORMALIZATION 0
#endif
-/***************************************
- ****** longlong.h ends here *********
- ***************************************/
--
2.56.1
More information about the Gcrypt-devel
mailing list