From 8b412cc1a1ff7f5b5d283451f2d02573d9f100fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Wed, 9 Sep 2020 09:45:36 +0100 Subject: [PATCH] Export `jl_test_cpu_feature` and generate Julia list of CPU features Co-authored-by: Elliot Saba --- base/.gitignore | 1 + base/Makefile | 15 ++++++++++++++- src/processor.h | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/base/.gitignore b/base/.gitignore index 49b6f3f2d7808b..e572b8ea229d0c 100644 --- a/base/.gitignore +++ b/base/.gitignore @@ -1,3 +1,4 @@ +/features_h.jl /pcre_h.jl /errno_h.jl /build_h.jl diff --git a/base/Makefile b/base/Makefile index b3845753fe74ca..9ba9ee4be2a78a 100644 --- a/base/Makefile +++ b/base/Makefile @@ -12,7 +12,7 @@ else CPP_STDOUT := $(CPP) -E endif -all: $(addprefix $(BUILDDIR)/,pcre_h.jl errno_h.jl build_h.jl.phony file_constants.jl uv_constants.jl version_git.jl.phony) +all: $(addprefix $(BUILDDIR)/,pcre_h.jl errno_h.jl build_h.jl.phony features_h.jl file_constants.jl uv_constants.jl version_git.jl.phony) PCRE_CONST := 0x[0-9a-fA-F]+|[0-9]+|\([\-0-9]+\) ifeq ($(USE_SYSTEM_PCRE), 1) @@ -21,6 +21,18 @@ else PCRE_INCL_PATH := $(build_includedir)/pcre2.h endif +define parse_features +@echo "# $(2) features" >> $@ +@$(call PRINT_PERL, cat ../src/features_$(1).h | perl -lne 'print "const JL_$(2)_$$1 = UInt32($$2)" if /^\s*JL_FEATURE_DEF(?:_NAME)?\(\s*(\w+)\s*,\s*([^,]+)\s*,.*\)\s*(?:\/\/.*)?$$/' >> $@) +@echo >> $@ +endef + +$(BUILDDIR)/features_h.jl: ../src/features_x86.h ../src/features_aarch32.h ../src/features_aarch64.h + @-rm -f $@ + @$(call parse_features,x86,X86) + @$(call parse_features,aarch32,AArch32) + @$(call parse_features,aarch64,AArch64) + $(BUILDDIR)/pcre_h.jl: $(PCRE_INCL_PATH) @$(call PRINT_PERL, $(CPP) -D PCRE2_CODE_UNIT_WIDTH=8 -dM $< | perl -nle '/^\s*#define\s+PCRE2_(\w*)\s*\(?($(PCRE_CONST))\)?u?\s*$$/ and print index($$1, "ERROR_") == 0 ? "const $$1 = Cint($$2)" : "const $$1 = UInt32($$2)"' | LC_ALL=C sort > $@) @@ -236,6 +248,7 @@ clean: -rm -f $(BUILDDIR)/errno_h.jl -rm -f $(BUILDDIR)/build_h.jl -rm -f $(BUILDDIR)/build_h.jl.phony + -rm -f $(BUILDDIR)/features_h.jl -rm -f $(BUILDDIR)/uv_constants.jl -rm -f $(BUILDDIR)/file_constants.jl -rm -f $(BUILDDIR)/version_git.jl diff --git a/src/processor.h b/src/processor.h index 114e46912c2a9c..6c95a0b6003b62 100644 --- a/src/processor.h +++ b/src/processor.h @@ -123,7 +123,7 @@ typedef enum { } jl_cpu_feature_t; #undef JL_FEATURE_DEF_NAME -int jl_test_cpu_feature(jl_cpu_feature_t feature); +JL_DLLEXPORT int jl_test_cpu_feature(jl_cpu_feature_t feature); static const uint32_t jl_sysimg_tag_mask = 0x80000000u; static const uint32_t jl_sysimg_val_mask = ~((uint32_t)0x80000000u);