From 8a1aa284ba544521614b7fa878fd7a0e601026e9 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Thu, 26 May 2016 09:26:09 +0100 Subject: [PATCH] Have a small reformatting session. * Outdent `.macro' and `.endm' directives. Firstly, this makes them more prominent, similar to `FUNC' and `ENDFUNC'. Secondly, though, it has the effect of moving the macro name into the mnemonic column. * Remove the second `External definitions' banner from `symm/ rijndael-x86ish-aesni.S'. * Reflow the various `CPU_DISPATCH' stanze. --- base/asm-common.h | 46 ++++++++++++++++++++++---------------------- symm/chacha.c | 8 +++----- symm/rijndael-base.c | 4 ++-- symm/rijndael-x86ish-aesni.S | 11 ++++------- symm/rijndael.c | 10 ++++------ symm/salsa20.c | 8 +++----- 6 files changed, 39 insertions(+), 48 deletions(-) diff --git a/base/asm-common.h b/base/asm-common.h index 64d679f6..bf42e4fe 100644 --- a/base/asm-common.h +++ b/base/asm-common.h @@ -38,7 +38,7 @@ #define FUNC(name) \ .globl F(name); \ TYPE_FUNC(name); \ - .macro ENDFUNC; _ENDFUNC(name); .endm; \ + .macro ENDFUNC; _ENDFUNC(name); .endm; \ FUNC_PREHOOK(name); \ F(name): \ FUNC_POSTHOOK(name) @@ -92,13 +92,13 @@ F(name): \ .intel_syntax noprefix // Call external subroutine at ADDR, possibly via PLT. - .macro callext addr +.macro callext addr #if WANT_PIC call \addr@PLT #else call \addr #endif - .endm +.endm // Do I need to arrange a spare GOT register? #if WANT_PIC && CPUFAM_X86 @@ -107,25 +107,25 @@ F(name): \ #define GOTREG ebx // Not needed in AMD64 so don't care. // Maybe load GOT address into GOT. - .macro ldgot got=GOTREG +.macro ldgot got=GOTREG #if WANT_PIC && CPUFAM_X86 call _where_am_i.\got add \got, offset _GLOBAL_OFFSET_TABLE_ #endif - .endm +.endm // Maybe build a helper subroutine for `ldgot GOT'. - .macro gotaux got=GOTREG +.macro gotaux got=GOTREG #if WANT_PIC && CPUFAM_X86 .align 16 _where_am_i.\got : mov \got, [esp] ret #endif - .endm +.endm // Load address of external symbol ADDR into REG, maybe using GOT. - .macro leaext reg, addr, got=GOTREG +.macro leaext reg, addr, got=GOTREG #if WANT_PIC # if CPUFAM_X86 mov \reg, [\got + \addr@GOT] @@ -141,7 +141,7 @@ _where_am_i.\got : lea \reg, \addr[rip] # endif #endif - .endm +.endm // Address expression (possibly using a base register, and a displacement) // referring to ADDR, which is within our module, maybe using GOT. @@ -172,13 +172,13 @@ _where_am_i.\got : #define ENDFUNC_HOOK(name) .ltorg // Call external subroutine at ADDR, possibly via PLT. - .macro callext addr, cond= +.macro callext addr, cond= #if WANT_PIC bl\cond \addr(PLT) #else bl\cond \addr #endif - .endm +.endm // Do I need to arrange a spare GOT register? #if WANT_PIC @@ -187,36 +187,36 @@ _where_am_i.\got : #define GOTREG r9 // Maybe load GOT address into GOT. - .macro ldgot cond=, got=GOTREG +.macro ldgot cond=, got=GOTREG #if WANT_PIC ldr\cond \got, .L$_ldgot$\@ .L$_ldgot_pc$\@: add\cond \got, pc, \got - _LIT + _LIT .balign 4 .L$_ldgot$\@: .word _GLOBAL_OFFSET_TABLE_ - .L$_ldgot_pc$\@ - .L$_pcoff - _ENDLIT + _ENDLIT #endif - .endm +.endm // Load address of external symbol ADDR into REG, maybe using GOT. - .macro leaext reg, addr, cond=, got=GOTREG +.macro leaext reg, addr, cond=, got=GOTREG #if WANT_PIC ldr\cond \reg, .L$_leaext$\@ ldr\cond \reg, [\got, \reg] - _LIT + _LIT .balign 4 .L$_leaext$\@: .word \addr(GOT) - _ENDLIT + _ENDLIT #else ldr\cond \reg, =\addr #endif - .endm +.endm // Load address of external symbol ADDR into REG directly. - .macro leaextq reg, addr, cond= +.macro leaextq reg, addr, cond= #if WANT_PIC ldr\cond \reg, .L$_leaextq$\@ .L$_leaextq_pc$\@: @@ -226,15 +226,15 @@ _where_am_i.\got : add\cond \reg, pc ldr\cond \reg, [\reg] .endif - _LIT + _LIT .balign 4 .L$_leaextq$\@: .word \addr(GOT_PREL) + (. - .L$_leaextq_pc$\@ - .L$_pcoff) - _ENDLIT + _ENDLIT #else ldr\cond \reg, =\addr #endif - .endm +.endm #endif diff --git a/symm/chacha.c b/symm/chacha.c index cb879e3c..abcc1bd4 100644 --- a/symm/chacha.c +++ b/symm/chacha.c @@ -62,11 +62,9 @@ const octet chacha_keysz[] = { KSZ_SET, 32, 16, 10, 0 }; * the feedforward step. */ -CPU_DISPATCH(static, (void), - void, core, (unsigned r, const chacha_matrix src, - chacha_matrix dest), - (r, src, dest), - pick_core, simple_core); +CPU_DISPATCH(static, (void), void, core, + (unsigned r, const chacha_matrix src, chacha_matrix dest), + (r, src, dest), pick_core, simple_core); static void simple_core(unsigned r, const chacha_matrix src, chacha_matrix dest) diff --git a/symm/rijndael-base.c b/symm/rijndael-base.c index b0505a66..b5490c1d 100644 --- a/symm/rijndael-base.c +++ b/symm/rijndael-base.c @@ -112,8 +112,8 @@ static void simple_setup(rijndael_ctx *k, unsigned nb, k->wi[i] = k->w[j + jj++]; } -CPU_DISPATCH(static, EMPTY, void, setup, (rijndael_ctx *k, unsigned nb, - const void *buf, unsigned nk), +CPU_DISPATCH(static, EMPTY, void, setup, + (rijndael_ctx *k, unsigned nb, const void *buf, unsigned nk), (k, nb, buf, nk), pick_setup, simple_setup) #if CPUFAM_X86 || CPUFAM_AMD64 diff --git a/symm/rijndael-x86ish-aesni.S b/symm/rijndael-x86ish-aesni.S index 09543172..520a72e4 100644 --- a/symm/rijndael-x86ish-aesni.S +++ b/symm/rijndael-x86ish-aesni.S @@ -30,9 +30,6 @@ #include "config.h" #include "asm-common.h" -///-------------------------------------------------------------------------- -/// External definitions. - .globl F(abort) .globl F(rijndael_rcon) @@ -431,8 +428,8 @@ ENDFUNC ///-------------------------------------------------------------------------- /// Encrypting and decrypting blocks. - .macro encdec op, aes, koff -FUNC(rijndael_\op\()_x86ish_aesni) +.macro encdec op, aes, koff + FUNC(rijndael_\op\()_x86ish_aesni) // Find the magic endianness-swapping table. ldgot ecx @@ -569,8 +566,8 @@ FUNC(rijndael_\op\()_x86ish_aesni) #undef DST #undef NR -ENDFUNC - .endm + ENDFUNC +.endm encdec eblk, aesenc, w encdec dblk, aesdec, wi diff --git a/symm/rijndael.c b/symm/rijndael.c index 293f28da..58d896f9 100644 --- a/symm/rijndael.c +++ b/symm/rijndael.c @@ -72,14 +72,12 @@ void rijndael_init(rijndael_ctx *k, const void *buf, size_t sz) * Use: Low-level block encryption and decryption. */ -CPU_DISPATCH(EMPTY, EMPTY, void, rijndael_eblk, (const rijndael_ctx *k, - const uint32 s[4], - uint32 d[4]), +CPU_DISPATCH(EMPTY, EMPTY, void, rijndael_eblk, + (const rijndael_ctx *k, const uint32 s[4], uint32 d[4]), (k, s, d), pick_eblk, simple_eblk) -CPU_DISPATCH(EMPTY, EMPTY, void, rijndael_dblk, (const rijndael_ctx *k, - const uint32 s[4], - uint32 d[4]), +CPU_DISPATCH(EMPTY, EMPTY, void, rijndael_dblk, + (const rijndael_ctx *k, const uint32 s[4], uint32 d[4]), (k, s, d), pick_dblk, simple_dblk) #if CPUFAM_X86 || CPUFAM_AMD64 diff --git a/symm/salsa20.c b/symm/salsa20.c index 0afad2cb..29a43f0e 100644 --- a/symm/salsa20.c +++ b/symm/salsa20.c @@ -42,11 +42,9 @@ const octet salsa20_keysz[] = { KSZ_SET, 32, 16, 10, 0 }; * the feedforward step. */ -CPU_DISPATCH(static, (void), - void, core, (unsigned r, const salsa20_matrix src, - salsa20_matrix dest), - (r, src, dest), - pick_core, simple_core); +CPU_DISPATCH(static, (void), void, core, + (unsigned r, const salsa20_matrix src, salsa20_matrix dest), + (r, src, dest), pick_core, simple_core); static void simple_core(unsigned r, const salsa20_matrix src, salsa20_matrix dest) -- 2.11.0