Skip to content

Commit

Permalink
windows arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
bilam committed Oct 29, 2024
1 parent a6f2fc5 commit 5a227ef
Show file tree
Hide file tree
Showing 29 changed files with 426 additions and 142 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/jsource.yml
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,6 @@ jobs:
# windows --------------------------------------------------------------
jewinarm64:
name: JE (Windows arm64)
if: ${{ false }}
runs-on: windows-2022
steps:
- name: Checkout Git repository
Expand Down Expand Up @@ -975,7 +974,7 @@ jobs:
name: Test Results
runs-on: ubuntu-20.04
# needs: [jelinux, jelinux-gcc, jemacos, jerpi64, jerpi32, jewin, jewin32, jeandroid, jefreebsd2, jefreebsdarm64, jeopenbsd2, jeopenbsdarm64 ]
needs: [jelinux, jelinux-gcc, jemacos, jemacosarm, jerpi64, jerpi32, jewin, jewin32, jeandroid, jefreebsd2, jefreebsdarm64, jeopenbsdarm64 ]
needs: [jelinux, jelinux-gcc, jemacos, jemacosarm, jerpi64, jerpi32, jewin, jewin32, jewinarm64, jeandroid, jefreebsd2, jefreebsdarm64, jeopenbsdarm64 ]
steps:
- name: Checkout Git repository
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion hostdefs/hostdefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <winsock.h>
#include "../regex/rxposix.h"
#include "pcre2posix.h"
#endif
#include <sys/types.h>
#include <fcntl.h>
Expand Down
39 changes: 39 additions & 0 deletions hostdefs/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
ifeq (ARM64,$(TARGET_CPU))
CFLAGS= -target arm64-pc-windows-msvc -Wno-format /W1 /MT
FLAGS= /MACHINE:ARM64 /SUBSYSTEM:CONSOLE,5.02
else ifeq (x64,$(TARGET_CPU))
CFLAGS= /W1 /MT
FLAGS= /MACHINE:X64 /SUBSYSTEM:CONSOLE,5.02
else
CFLAGS= -m32 /W1 /MT
FLAGS= /MACHINE:X86 /SUBSYSTEM:CONSOLE,5.01
endif

.SUFFIXES: .o

OBJS= hostdefs.o

ifndef LD
LD=lld-link
endif

%.o: %.c
$(CC) $(CFLAGS) /Fo$@ /c $<

ifeq (ARM64,$(TARGET_CPU))
TARGET= hostdefs-arm64.exe
else ifeq (x64,$(TARGET_CPU))
TARGET= hostdefs.exe
else
TARGET= hostdefs32.exe
endif

$(TARGET) : $(OBJS)
$(LD) /NOLOGO $(FLAGS) /out:$@ $(OBJS)

all: $(TARGET)

clean:
rm -f *.res *.ilk *.pdb $(OBJS)

.PHONY: all clean
187 changes: 187 additions & 0 deletions hostdefs/pcre2posix.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/

/* PCRE2 is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language. This is
the public header file to be #included by applications that call PCRE2 via the
POSIX wrapper interface.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2016-2023 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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 PCRE2POSIX_H_IDEMPOTENT_GUARD
#define PCRE2POSIX_H_IDEMPOTENT_GUARD

/* Have to include stdlib.h in order to ensure that size_t is defined. */

#include <stdlib.h>

/* Allow for C++ users */

#ifdef __cplusplus
extern "C" {
#endif

/* Options, mostly defined by POSIX, but with some extras. */

#define REG_ICASE 0x0001 /* Maps to PCRE2_CASELESS */
#define REG_NEWLINE 0x0002 /* Maps to PCRE2_MULTILINE */
#define REG_NOTBOL 0x0004 /* Maps to PCRE2_NOTBOL */
#define REG_NOTEOL 0x0008 /* Maps to PCRE2_NOTEOL */
#define REG_DOTALL 0x0010 /* NOT defined by POSIX; maps to PCRE2_DOTALL */
#define REG_NOSUB 0x0020 /* Do not report what was matched */
#define REG_UTF 0x0040 /* NOT defined by POSIX; maps to PCRE2_UTF */
#define REG_STARTEND 0x0080 /* BSD feature: pass subject string by so,eo */
#define REG_NOTEMPTY 0x0100 /* NOT defined by POSIX; maps to PCRE2_NOTEMPTY */
#define REG_UNGREEDY 0x0200 /* NOT defined by POSIX; maps to PCRE2_UNGREEDY */
#define REG_UCP 0x0400 /* NOT defined by POSIX; maps to PCRE2_UCP */
#define REG_PEND 0x0800 /* GNU feature: pass end pattern by re_endp */
#define REG_NOSPEC 0x1000 /* Maps to PCRE2_LITERAL */

/* This is not used by PCRE2, but by defining it we make it easier
to slot PCRE2 into existing programs that make POSIX calls. */

#define REG_EXTENDED 0

/* Error values. Not all these are relevant or used by the wrapper. */

enum {
REG_ASSERT = 1, /* internal error ? */
REG_BADBR, /* invalid repeat counts in {} */
REG_BADPAT, /* pattern error */
REG_BADRPT, /* ? * + invalid */
REG_EBRACE, /* unbalanced {} */
REG_EBRACK, /* unbalanced [] */
REG_ECOLLATE, /* collation error - not relevant */
REG_ECTYPE, /* bad class */
REG_EESCAPE, /* bad escape sequence */
REG_EMPTY, /* empty expression */
REG_EPAREN, /* unbalanced () */
REG_ERANGE, /* bad range inside [] */
REG_ESIZE, /* expression too big */
REG_ESPACE, /* failed to get memory */
REG_ESUBREG, /* bad back reference */
REG_INVARG, /* bad argument */
REG_NOMATCH /* match failed */
};


/* The structure representing a compiled regular expression. It is also used
for passing the pattern end pointer when REG_PEND is set. */

typedef struct {
void *re_pcre2_code;
void *re_match_data;
const char *re_endp;
size_t re_nsub;
size_t re_erroffset;
int re_cflags;
} regex_t;

/* The structure in which a captured offset is returned. */

typedef int regoff_t;

typedef struct {
regoff_t rm_so;
regoff_t rm_eo;
} regmatch_t;

/* When compiling with the MSVC compiler, it is sometimes necessary to include
a "calling convention" before exported function names. (This is secondhand
information; I know nothing about MSVC myself). For example, something like
void __cdecl function(....)
might be needed. In order to make this easy, all the exported functions have
PCRE2_CALL_CONVENTION just before their names. It is rarely needed; if not
set, we ensure here that it has no effect. */

#ifndef PCRE2_CALL_CONVENTION
#define PCRE2_CALL_CONVENTION
#endif

#ifndef PCRE2_EXPORT
#define PCRE2_EXPORT
#endif

/* When an application links to a PCRE2 DLL in Windows, the symbols that are
imported have to be identified as such. When building PCRE2, the appropriate
export settings are needed, and are set in pcre2posix.c before including this
file. */

/* By default, we use the standard "extern" declarations. */

#ifndef PCRE2POSIX_EXP_DECL
# if defined(_WIN32) && defined(PCRE2POSIX_SHARED) && !defined(PCRE2_STATIC)
# define PCRE2POSIX_EXP_DECL extern __declspec(dllimport)
# define PCRE2POSIX_EXP_DEFN __declspec(dllimport)
# else
# define PCRE2POSIX_EXP_DECL extern PCRE2_EXPORT
# define PCRE2POSIX_EXP_DEFN
# endif
#endif

/* The functions. The actual code is in functions with pcre2_xxx names for
uniqueness. POSIX names are provided as macros for API compatibility with POSIX
regex functions. It's done this way to ensure to they are always linked from
the PCRE2 library and not by accident from elsewhere (regex_t differs in size
elsewhere). */

PCRE2POSIX_EXP_DECL int PCRE2_CALL_CONVENTION pcre2_regcomp(regex_t *, const char *, int);
PCRE2POSIX_EXP_DECL int PCRE2_CALL_CONVENTION pcre2_regexec(const regex_t *, const char *, size_t,
regmatch_t *, int);
PCRE2POSIX_EXP_DECL size_t PCRE2_CALL_CONVENTION pcre2_regerror(int, const regex_t *, char *, size_t);
PCRE2POSIX_EXP_DECL void PCRE2_CALL_CONVENTION pcre2_regfree(regex_t *);

#define regcomp pcre2_regcomp
#define regexec pcre2_regexec
#define regerror pcre2_regerror
#define regfree pcre2_regfree

/* Debian had a patch that used different names. These are now here to save
them having to maintain their own patch, but are not documented by PCRE2. */

#define PCRE2regcomp pcre2_regcomp
#define PCRE2regexec pcre2_regexec
#define PCRE2regerror pcre2_regerror
#define PCRE2regfree pcre2_regfree

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* PCRE2POSIX_H_IDEMPOTENT_GUARD */

/* End of pcre2posix.h */
4 changes: 4 additions & 0 deletions jsrc/aes-ni.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include "j.h"

#if defined(__i386__) || defined(__x86_64__) || defined(_M_X64) || defined(_M_IX86)

#include <stdint.h>
#include <wmmintrin.h>
#ifndef __USE_XOPEN2K
Expand Down Expand Up @@ -360,3 +362,5 @@ int aes_ni(I decrypt,I mode,UC *key,I keyn,UC* ivec,UC* out,I len)

R 0; // success
}

#endif
4 changes: 2 additions & 2 deletions jsrc/avxintrin-neon.h
Original file line number Diff line number Diff line change
Expand Up @@ -2829,7 +2829,7 @@ FORCE_INLINE __m256d _mm256_maskload_pd(double const* mem_addr, __m256i mask)
{
__m256d ret;
int i;
int64_t sign_bit = 1L << (8*sizeof( int64_t ) - 1);
int64_t sign_bit = 1LL << (8*sizeof( int64_t ) - 1);

for (i=0; i<2; i++){
if (sign_bit & mask.vect_s64[0][i])
Expand All @@ -2850,7 +2850,7 @@ FORCE_INLINE __m256d _mm256_maskload_pd(double const* mem_addr, __m256i mask)
FORCE_INLINE void _mm256_maskstore_pd(double * mem_addr, __m256i mask, __m256d a)
{
int i;
int64_t sign_bit = 1L << (8*sizeof( int64_t ) - 1);
int64_t sign_bit = 1LL << (8*sizeof( int64_t ) - 1);
for (i=0; i<2; i++){
if (sign_bit & mask.vect_s64[0][i])
mem_addr[i] = a.vect_f64[0][i];
Expand Down
2 changes: 1 addition & 1 deletion jsrc/sse2neon.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ FORCE_INLINE int64_t sse2neon_recast_f64_s64(double f64)
#include <windows.h>
#endif

#if !defined(__cplusplus) && (!defined(__clang__))
#if !defined(__cplusplus) && !defined(_MSC_VER)
#error SSE2NEON only supports C++ compilation with this compiler
#endif

Expand Down
28 changes: 14 additions & 14 deletions makemsvc/jamalgam/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ FAVX2= /DC_AVX2=1 -DHAVE_AVX2=1 -DBASE64_AVX2_USE_ASM=1 -march=haswell -mno-vzer
endif
ifeq (1,$(USE_OPENMP))
FOPENMP= -Xclang -fopenmp
ifeq (1,$(JARM64))
ifeq (ARM64,$(TARGET_CPU))
OBJS_OPENMP=../../openmp/obj/windows/libomparm64.lib
else ifeq (1,$(x64))
else ifeq (x64,$(TARGET_CPU))
OBJS_OPENMP=../../openmp/obj/windows/libomp.lib
else
OBJS_OPENMP=../../openmp/obj/windows/libomp32.lib
endif
endif
USE_SLEEF=1
ifeq (1,$(JARM64))
ifeq (ARM64,$(TARGET_CPU))
FSLEEF= /DSLEEF=1 /DENABLE_ADVSIMD /DSLEEF_STATIC_LIBS /DDORENAME=1 -I../../sleef/src/common -I../../sleef/src/arch
else ifeq (1,$(x64))
else ifeq (x64,$(TARGET_CPU))
ifeq (1,$(JAVX512))
FSLEEF= /DSLEEF=1 /DENABLE_AVX2 /DSLEEF_STATIC_LIBS /DDORENAME=1 -I../../sleef/src/common -I../../sleef/src/arch
else ifeq (1,$(JAVX2))
Expand All @@ -29,19 +29,19 @@ FSLEEF= /DSLEEF=1 /DENABLE_SSE2 /DSLEEF_STATIC_LIBS /DDORENAME=1 -I../../sleef/s
endif
ifeq (1,$(USE_PYXES))
PTHREADINC = -I../../pthreads4w/include -DPYXES=1
ifeq (1,$(JARM64))
ifeq (ARM64,$(TARGET_CPU))
PTHREADLIB = ../../pthreads4w/lib/pthreadVC3-arm64.lib
else ifeq (1,$(x64))
else ifeq (x64,$(TARGET_CPU))
PTHREADLIB = ../../pthreads4w/lib/pthreadVC3.lib
else
PTHREADLIB = ../../pthreads4w/lib/pthreadVC3-w32.lib
endif
endif
MPIRINC = -I../../mpir/include

ifeq (1,$(JARM64))
ifeq (ARM64,$(TARGET_CPU))
# MPIRLIB = ../../mpir/dll/arm64/mpir.lib
else ifeq (1,$(x64))
else ifeq (x64,$(TARGET_CPU))
# MPIRLIB = ../../mpir/dll/x64/mpir.lib
else
# MPIRLIB = ../../mpir/dll/win32/mpir.lib
Expand All @@ -58,12 +58,12 @@ ifeq (1,$(USE_BOXEDSPARSE))
FBOXEDSPARSE = /DBOXEDSPARSE
endif

ifeq (1,$(JARM64))
ifeq (ARM64,$(TARGET_CPU))
CF1= -fno-strict-aliasing -Wno-unknown-warning-option -Wsign-compare -Wno-int-conversion -Wno-incompatible-function-pointer-types -Wno-parentheses -Wno-unused-variable -Wno-pointer-sign -Wno-missing-braces -Wno-missing-field-initializers -Wno-null-pointer-arithmetic -Wno-char-subscripts -Wno-pointer-to-int-cast -Wno-unused-but-set-variable -Wno-unused-value -Wno-unused-function -Wno-empty-body -Wno-sometimes-uninitialized -Wno-string-plus-int -Wno-unknown-pragmas -Wno-delete-non-abstract-non-virtual-dtor -Wno-deprecated-non-prototype
CFLAGS= $(FDEBUG) -target arm64-pc-windows-msvc /D JAMALGAM /DC_NA=0 /DEMU_AVX2=1 $(FAVX2) $(FAVX512) $(FOPENMP) $(FSLEEF) $(FNOSYNCHLIB) $(FBOXEDSPARSE) $(PTHREADINC) $(MPIRINC) /WX /W3 /O2 /GS- /Zc:strictStrings /D_USING_V110_SDK71_ /D_CRT_SECURE_NO_WARNINGS /MT $(CF1)
FLAGS= $(LDEBUG) /NOLOGO /STACK:0xc00000 /MACHINE:ARM64 /SUBSYSTEM:CONSOLE,5.02
ASMFLAGS= /Cx
else ifeq (1,$(x64))
else ifeq (x64,$(TARGET_CPU))
CF1= -maes -msse3 -fno-strict-aliasing -Wno-unknown-warning-option -Wsign-compare -Wno-int-conversion -Wno-incompatible-function-pointer-types -Wno-parentheses -Wno-unused-variable -Wno-pointer-sign -Wno-missing-braces -Wno-missing-field-initializers -Wno-null-pointer-arithmetic -Wno-char-subscripts -Wno-pointer-to-int-cast -Wno-unused-but-set-variable -Wno-unused-value -Wno-unused-function -Wno-empty-body -Wno-sometimes-uninitialized -Wno-string-plus-int -Wno-unknown-pragmas -Wno-delete-non-abstract-non-virtual-dtor -Wno-deprecated-non-prototype
CFLAGS= $(FDEBUG) /D JAMALGAM /DC_NA=0 /DEMU_AVX2=1 $(FAVX2) $(FAVX512) $(FOPENMP) $(FSLEEF) $(FNOSYNCHLIB) $(FBOXEDSPARSE) $(PTHREADINC) $(MPIRINC) /WX /W3 /O2 /GS- /Zc:strictStrings /D_USING_V110_SDK71_ /D_CRT_SECURE_NO_WARNINGS /MT $(CF1)
FLAGS= $(LDEBUG) /NOLOGO /STACK:0xc00000 /MACHINE:X64 /SUBSYSTEM:CONSOLE,5.02
Expand Down Expand Up @@ -260,14 +260,14 @@ OBJS= \

ifdef NO_SHA_ASM
CFLAGS1= /DNO_SHA_ASM
else ifeq (1,$(JARM64))
else ifeq (ARM64,$(TARGET_CPU))
OBJS_ASM= \
../../openssl-asm/md5-aarch64-nasm.o \
../../openssl-asm/keccak1600-armv8-nasm.o \
../../openssl-asm/sha1-armv8-nasm.o \
../../openssl-asm/sha256-armv8-nasm.o \
../../openssl-asm/sha512-armv8-nasm.o "
else ifeq (1,$(x64))
else ifeq (x64,$(TARGET_CPU))
OBJS_ASM= \
../../openssl-asm/md5-x86_64-nasm.o \
../../openssl-asm/keccak1600-x86_64-nasm.o \
Expand Down Expand Up @@ -320,9 +320,9 @@ endif
%.o: %.asm
$(ML) $(ASMFLAGS) /Fo$@ /c $<

ifeq (1,$(JARM64))
ifeq (ARM64,$(TARGET_CPU))
TARGET= jamalgam-arm64.exe
else ifeq (1,$(x64))
else ifeq (x64,$(TARGET_CPU))
ifeq (1,$(JAVX2))
TARGET= jamalgam-avx2.exe
else
Expand Down
Loading

0 comments on commit 5a227ef

Please sign in to comment.