/* poly1305-avx2-amd64.S - AMD64/AVX2 implementation of Poly1305 * * Copyright (C) 2014 Jussi Kivilinna * * This file is part of Libgcrypt. * * Libgcrypt is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * Libgcrypt is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, see . */ /* * Based on public domain implementation by Andrew Moon at * https://github.com/floodyberry/poly1305-opt */ #include #if defined(__x86_64__) && (defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS) || \ defined(HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS)) && \ defined(ENABLE_AVX2_SUPPORT) #ifdef HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS # define ELF(...) __VA_ARGS__ #else # define ELF(...) /*_*/ #endif .text .align 8 .globl _gcry_poly1305_amd64_avx2_init_ext ELF(.type _gcry_poly1305_amd64_avx2_init_ext,@function;) _gcry_poly1305_amd64_avx2_init_ext: .Lpoly1305_init_ext_avx2_local: xor %edx, %edx vzeroupper pushq %r12 pushq %r13 pushq %r14 pushq %r15 pushq %rbx movq %rdx, %rcx vpxor %ymm0, %ymm0, %ymm0 movq $-1, %r8 testq %rcx, %rcx vmovdqu %ymm0, (%rdi) vmovdqu %ymm0, 32(%rdi) vmovdqu %ymm0, 64(%rdi) vmovdqu %ymm0, 96(%rdi) vmovdqu %ymm0, 128(%rdi) movq 8(%rsi), %r9 cmove %r8, %rcx movq $0xffc0fffffff, %r8 movq %r9, %r13 movq (%rsi), %r10 andq %r10, %r8 shrq $44, %r10 movq %r8, %r14 shlq $20, %r13 orq %r13, %r10 movq $0xfffffc0ffff, %r13 shrq $24, %r9 andq %r13, %r10 movq $0xffffffc0f, %r13 andq %r13, %r9 movl %r8d, %r13d andl $67108863, %r13d movl %r13d, 164(%rdi) movq %r10, %r13 shrq $26, %r14 shlq $18, %r13 orq %r13, %r14 movq %r10, %r13 shrq $8, %r13 andl $67108863, %r14d andl $67108863, %r13d movl %r14d, 172(%rdi) movq %r10, %r14 movl %r13d, 180(%rdi) movq %r9, %r13 shrq $34, %r14 shlq $10, %r13 orq %r13, %r14 movq %r9, %r13 shrq $16, %r13 andl $67108863, %r14d movl %r14d, 188(%rdi) movl %r13d, 196(%rdi) cmpq $16, %rcx jbe .Lpoly1305_init_ext_avx2_continue lea (%r9,%r9,4), %r11 shlq $2, %r11 lea (%r10,%r10), %rax mulq %r11 movq %rax, %r13 movq %r8, %rax movq %rdx, %r14 mulq %r8 addq %rax, %r13 lea (%r8,%r8), %rax movq %r13, %r12 adcq %rdx, %r14 mulq %r10 shlq $20, %r14 movq %rax, %r15 shrq $44, %r12 movq %r11, %rax orq %r12, %r14 movq %rdx, %r12 mulq %r9 addq %rax, %r15 movq %r8, %rax adcq %rdx, %r12 addq %r15, %r14 lea (%r9,%r9), %r15 movq %r14, %rbx adcq $0, %r12 mulq %r15 shlq $20, %r12 movq %rdx, %r11 shrq $44, %rbx orq %rbx, %r12 movq %rax, %rbx movq %r10, %rax mulq %r10 addq %rax, %rbx adcq %rdx, %r11 addq %rbx, %r12 movq $0xfffffffffff, %rbx movq %r12, %r15 adcq $0, %r11 andq %rbx, %r13 shlq $22, %r11 andq %rbx, %r14 shrq $42, %r15 orq %r15, %r11 lea (%r11,%r11,4), %r11 addq %r11, %r13 movq %rbx, %r11 andq %r13, %r11 shrq $44, %r13 movq %r11, %r15 addq %r13, %r14 movq $0x3ffffffffff, %r13 andq %r14, %rbx andq %r13, %r12 movq %rbx, %r13 shrq $26, %r15 shlq $18, %r13 orq %r13, %r15 movq %rbx, %r13 shrq $44, %r14 shrq $8, %r13 addq %r14, %r12 movl %r11d, %r14d andl $67108863, %r15d andl $67108863, %r14d andl $67108863, %r13d movl %r14d, 204(%rdi) movq %rbx, %r14 movl %r13d, 220(%rdi) movq %r12, %r13 shrq $34, %r14 shlq $10, %r13 orq %r13, %r14 movq %r12, %r13 shrq $16, %r13 andl $67108863, %r14d movl %r15d, 212(%rdi) movl %r14d, 228(%rdi) movl %r13d, 236(%rdi) cmpq $32, %rcx jbe .Lpoly1305_init_ext_avx2_continue movq %r9, %rax lea (%rbx,%rbx,4), %r14 shlq $2, %r14 mulq %r14 movq %rdi, -32(%rsp) lea (%r12,%r12,4), %rdi shlq $2, %rdi movq %rax, %r14 movq %r10, %rax movq %rdx, %r15 mulq %rdi movq %rax, %r13 movq %r11, %rax movq %rcx, -16(%rsp) movq %rdx, %rcx mulq %r8 addq %rax, %r13 movq %rdi, %rax movq %rsi, -24(%rsp) adcq %rdx, %rcx addq %r13, %r14 adcq %rcx, %r15 movq %r14, %rcx mulq %r9 shlq $20, %r15 movq %rax, %r13 shrq $44, %rcx movq %r11, %rax orq %rcx, %r15 movq %rdx, %rcx mulq %r10 movq %rax, %rsi movq %rbx, %rax movq %rdx, %rdi mulq %r8 addq %rax, %rsi movq %r11, %rax adcq %rdx, %rdi addq %rsi, %r13 adcq %rdi, %rcx addq %r13, %r15 movq %r15, %rdi adcq $0, %rcx mulq %r9 shlq $20, %rcx movq %rdx, %rsi shrq $44, %rdi orq %rdi, %rcx movq %rax, %rdi movq %rbx, %rax mulq %r10 movq %rax, %r9 movq %r8, %rax movq %rdx, %r10 movq $0xfffffffffff, %r8 mulq %r12 addq %rax, %r9 adcq %rdx, %r10 andq %r8, %r14 addq %r9, %rdi adcq %r10, %rsi andq %r8, %r15 addq %rdi, %rcx movq $0x3ffffffffff, %rdi movq %rcx, %r10 adcq $0, %rsi andq %rdi, %rcx shlq $22, %rsi shrq $42, %r10 orq %r10, %rsi movq -32(%rsp), %rdi lea (%rsi,%rsi,4), %r9 movq %r8, %rsi addq %r9, %r14 andq %r14, %rsi shrq $44, %r14 addq %r14, %r15 andq %r15, %r8 shrq $44, %r15 movq %r8, %r14 addq %r15, %rcx movl %esi, %r15d movq %rcx, %r10 movq %r8, %r9 shrq $26, %rsi andl $67108863, %r15d shlq $18, %r14 shrq $34, %r8 orq %r14, %rsi shlq $10, %r10 shrq $8, %r9 orq %r10, %r8 shrq $16, %rcx andl $67108863, %esi movl %esi, 252(%rdi) andl $67108863, %r9d movl %ecx, 276(%rdi) andl $67108863, %r8d movl %r15d, 244(%rdi) movl %r9d, 260(%rdi) movl %r8d, 268(%rdi) movq -16(%rsp), %rcx
/* X-Tray
 * Copyright (C) 2005 Michael Hotaling <Mike.Hotaling@SinisterDevelopments.com>
 *
 * X-Tray is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * X-Tray is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with X-Tray; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef _H_UTILITY_H
#define _H_UTILITY_H

WORD					HotkeyfToMod	(WORD);
WORD					ModToHotkeyf	(WORD);

int						SetOption		(HWND, unsigned int, unsigned int);
int						SetCheck		(HWND, unsigned int, unsigned int);
int						SetToggle		(HWND, unsigned int, unsigned int, bool);
void					ErrorDebug		(LPTSTR lpszFunction);
void					SetDialog		(HWND, int);
void					CheckPrefs		(HWND, int);
bool					FileExists		(TCHAR *);
DWORD WINAPI			HoldCloseThread	(LPVOID);
void					SavePrefs		(int);
void					LoadPrefs		();
void					HoldClose		();

void ConvertString(const char *in,		wchar_t *out,	int size);
void ConvertString(const wchar_t *in,	char *out,		int size);
void ConvertString(const char *in,		char *out,		int size);

int WritePrivateProfileIntA(char *, char *, int, char *);
int WritePrivateProfileIntW(wchar_t *, wchar_t *, int, wchar_t *);

#ifdef UNICODE
#define WritePrivateProfileInt WritePrivateProfileIntW
#else
#define WritePrivateProfileInt WritePrivateProfileIntA
#endif

struct HOTKEY
{
	WORD key;
	WORD mod;
};
#endif
(%rbx), %rdx shrq $20, %rax movl $24, %edi shlx %rdi, 16(%rbx), %rcx orq %rcx, %rax movl 292(%rbx), %ecx salq $32, %rcx movl 284(%rbx), %esi orq %rsi, %rcx movl 308(%rbx), %esi salq $32, %rsi movl 300(%rbx), %edi orq %rdi, %rsi addq %rcx, %rdx adcq %rsi, %rax movq %rdx, (%r12) movq %rax, 8(%r12) vpxor %xmm0, %xmm0, %xmm0 vmovdqu %ymm0, (%rbx) vmovdqu %ymm0, 32(%rbx) vmovdqu %ymm0, 64(%rbx) vmovdqu %ymm0, 96(%rbx) vmovdqu %ymm0, 128(%rbx) vmovdqu %ymm0, 160(%rbx) vmovdqu %ymm0, 192(%rbx) vmovdqu %ymm0, 224(%rbx) jmp .Lpoly1305_finish_ext_avx2_49 .Lpoly1305_finish_ext_avx2_46: movl $3, %r9d movl $1, %edi movl $10, %eax jmp .Lpoly1305_finish_ext_avx2_39 .Lpoly1305_finish_ext_avx2_47: movl $3, %r9d movl $0, %edi movl $10, %eax .Lpoly1305_finish_ext_avx2_39: leaq 164(%rbx,%rax,8), %rdx leaq 160(%rbx,%rdi,8), %rax movq %rdi, %rcx jmp .Lpoly1305_finish_ext_avx2_41 .Lpoly1305_finish_ext_avx2_49: movq %rbp, %rax subq %rsp, %rax leaq -24(%rbp), %rsp vzeroall popq %rbx popq %r12 popq %r13 popq %rbp addq $(8*5), %rax ret ELF(.size _gcry_poly1305_amd64_avx2_finish_ext,.-_gcry_poly1305_amd64_avx2_finish_ext;) #endif