Skip to content

Commit b1fa61d

Browse files
authored
Merge pull request #698 from enginelesscc/develop
Fix build of aesni on msvc
2 parents 5edb54e + 4d84f53 commit b1fa61d

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

appveyor.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,13 @@ build_script:
3535
ninja
3636
cd..
3737
nmake -f makefile.msvc all
38+
cp test.exe test-stock.exe
39+
cp timing.exe timing-stock.exe
40+
nmake -f makefile.msvc clean
41+
nmake -f makefile.msvc all CFLAGS="/Ox /DUSE_LTM /DLTM_DESC /DLTC_AES_NI /I../libtommath"
3842
test_script:
39-
- cmd: test.exe
43+
- cmd: >-
44+
test-stock.exe
45+
test.exe
46+
timing-stock.exe cipher_ecb
47+
timing.exe cipher_ecb

makefile.msvc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,15 @@ test.exe: $(LIBMAIN_S) $(TOBJECTS)
294294
cl $(LTC_CFLAGS) $(TOBJECTS) $(LIBMAIN_S) $(LTC_LDFLAGS) /Fe$@
295295
@echo NOTICE: start the tests by launching test.exe
296296

297-
all: $(LIBMAIN_S) hashsum.exe crypt.exe small.exe tv_gen.exe sizes.exe constants.exe timing.exe test.exe
297+
ALL_TEST=hashsum.exe crypt.exe small.exe tv_gen.exe sizes.exe constants.exe timing.exe test.exe
298+
299+
all: $(LIBMAIN_S) $(ALL_TEST)
298300

299301
test: test.exe
300302

301303
clean:
302304
@-cmd /c del /Q *_tv.txt 2>nul
303-
@-cmd /c del /Q /S *.OBJ *.LIB *.EXE *.DLL 2>nul
305+
@-cmd /c del /Q /S *.OBJ *.LIB $(ALL_TEST) *.DLL 2>nul
304306

305307
#Install the library + headers
306308
install: $(LIBMAIN_S)

src/ciphers/aes/aes_desc.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,19 @@ static LTC_INLINE int s_aesni_is_supported(void)
6363
a = 1;
6464
c = 0;
6565

66+
#if defined(_MSC_VER) && !defined(__clang__)
67+
int arr[4];
68+
__cpuidex(arr, a, c);
69+
a = arr[0];
70+
b = arr[1];
71+
c = arr[2];
72+
d = arr[3];
73+
#else
6674
__asm__ volatile ("cpuid"
6775
:"=a"(a), "=b"(b), "=c"(c), "=d"(d)
6876
:"a"(a), "c"(c)
6977
);
78+
#endif
7079

7180
is_supported = ((c >> 19) & 1) && ((c >> 25) & 1);
7281
initialized = 1;

0 commit comments

Comments
 (0)