diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4 index 5f98a9ae884af..b36748131c13e 100644 --- a/make/autoconf/flags-cflags.m4 +++ b/make/autoconf/flags-cflags.m4 @@ -629,7 +629,7 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER], STATIC_LIBS_CFLAGS="-DSTATIC_BUILD=1" if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then STATIC_LIBS_CFLAGS="$STATIC_LIBS_CFLAGS -ffunction-sections -fdata-sections \ - -DJNIEXPORT='__attribute__((visibility(\"hidden\")))'" + -DJNIEXPORT='[[gnu::visibility(\"hidden\")]]'" else STATIC_LIBS_CFLAGS="$STATIC_LIBS_CFLAGS -DJNIEXPORT=" fi diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk index 1f38d1bdcea30..dade7ba8bfef3 100644 --- a/make/hotspot/lib/CompileJvm.gmk +++ b/make/hotspot/lib/CompileJvm.gmk @@ -61,11 +61,6 @@ else OPENJDK_TARGET_CPU_VM_VERSION := $(OPENJDK_TARGET_CPU) endif -ifeq ($(VERSION_BUILD), ) - # Hotspot cannot handle an empty build number - VERSION_BUILD := 0 -endif - ifeq ($(HOTSPOT_BUILD_TIME), ) HOTSPOT_BUILD_TIME := $(call EpochToISO8601, $(shell $(DATE) +"%s")) endif diff --git a/src/hotspot/cpu/aarch64/assembler_aarch64.hpp b/src/hotspot/cpu/aarch64/assembler_aarch64.hpp index 2667e5dc471c8..40e46cd803c70 100644 --- a/src/hotspot/cpu/aarch64/assembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/assembler_aarch64.hpp @@ -208,7 +208,7 @@ class Instruction_aarch64 { return extend(uval, msb - lsb); } - static ALWAYSINLINE void patch(address a, int msb, int lsb, uint64_t val) { + ALWAYSINLINE static void patch(address a, int msb, int lsb, uint64_t val) { int nbits = msb - lsb + 1; guarantee(val < (1ULL << nbits), "Field too big for insn"); assert_cond(msb >= lsb); diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp index 148baafba8131..d7e5b25a3f03d 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp @@ -178,7 +178,7 @@ class RelocActions { virtual int immediate(address insn_addr, address &target) = 0; virtual void verify(address insn_addr, address &target) = 0; - int ALWAYSINLINE run(address insn_addr, address &target) { + ALWAYSINLINE int run(address insn_addr, address &target) { int instructions = 1; uint32_t dispatch = Instruction_aarch64::extract(_insn, 30, 25); diff --git a/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp b/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp index 4b00e6a9a302a..c82c9366f6d69 100644 --- a/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp +++ b/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp @@ -3386,7 +3386,7 @@ do { \ // in A Cryptographic Library for the Motorola DSP56000, // Dusse and Kaliski, Proc. EUROCRYPT 90, pp. 230-237. -static void NOINLINE +NOINLINE static void montgomery_multiply(julong a[], julong b[], julong n[], julong m[], julong inv, int len) { julong t0 = 0, t1 = 0, t2 = 0; // Triple-precision accumulator @@ -3428,7 +3428,7 @@ montgomery_multiply(julong a[], julong b[], julong n[], // multiplication. However, its loop control is more complex and it // may actually run slower on some machines. -static void NOINLINE +NOINLINE static void montgomery_square(julong a[], julong n[], julong m[], julong inv, int len) { julong t0 = 0, t1 = 0, t2 = 0; // Triple-precision accumulator diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index e41e0d1fea371..07195574d33a3 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -601,7 +601,7 @@ void os::Linux::libpthread_init() { // _expand_stack_to() assumes its frame size is less than page size, which // should always be true if the function is not inlined. -static void NOINLINE _expand_stack_to(address bottom) { +NOINLINE static void _expand_stack_to(address bottom) { address sp; size_t size; volatile char *p; diff --git a/src/hotspot/os/linux/os_perf_linux.cpp b/src/hotspot/os/linux/os_perf_linux.cpp index 851434fb3243d..1d1867ab69107 100644 --- a/src/hotspot/os/linux/os_perf_linux.cpp +++ b/src/hotspot/os/linux/os_perf_linux.cpp @@ -230,7 +230,8 @@ static double get_cpu_load(int which_logical_cpu, CPUPerfCounters* counters, dou /** reads /proc//stat data, with some checks and some skips. * Ensure that 'fmt' does _NOT_ contain the first two "%d %s" */ -static int SCANF_ARGS(2, 0) vread_statdata(const char* procfile, _SCANFMT_ const char* fmt, va_list args) { +SCANF_ARGS(2, 0) +static int vread_statdata(const char* procfile, _SCANFMT_ const char* fmt, va_list args) { FILE*f; int n; char buf[2048]; @@ -259,7 +260,8 @@ static int SCANF_ARGS(2, 0) vread_statdata(const char* procfile, _SCANFMT_ const return n; } -static int SCANF_ARGS(2, 3) read_statdata(const char* procfile, _SCANFMT_ const char* fmt, ...) { +SCANF_ARGS(2, 3) +static int read_statdata(const char* procfile, _SCANFMT_ const char* fmt, ...) { int n; va_list args; @@ -394,7 +396,8 @@ static double get_cpu_load(int which_logical_cpu, CPUPerfCounters* counters, dou return user_load; } -static int SCANF_ARGS(1, 2) parse_stat(_SCANFMT_ const char* fmt, ...) { +SCANF_ARGS(1, 2) +static int parse_stat(_SCANFMT_ const char* fmt, ...) { FILE *f; va_list args; diff --git a/src/hotspot/os/windows/os_windows.hpp b/src/hotspot/os/windows/os_windows.hpp index 94d7c3c5e2dc0..3adb297b6b6cf 100644 --- a/src/hotspot/os/windows/os_windows.hpp +++ b/src/hotspot/os/windows/os_windows.hpp @@ -32,6 +32,8 @@ class outputStream; class Thread; +static unsigned __stdcall thread_native_entry(Thread*); + typedef void (*signal_handler_t)(int); class os::win32 { diff --git a/src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp b/src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp index 70196d40c1cb0..2b380230ce7a8 100644 --- a/src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp +++ b/src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp @@ -65,7 +65,7 @@ void os::os_exception_wrapper(java_call_t f, JavaValue* value, const methodHandl f(value, method, args, thread); } -PRAGMA_DISABLE_MSVC_WARNING(4172) +PRAGMA_DISABLE_VISCPP_WARNING(4172) // Returns an estimate of the current stack pointer. Result must be guaranteed // to point into the calling threads stack, and be no lower than the current // stack pointer. diff --git a/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp b/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp index a1def3f8fa77c..85e6e2547406c 100644 --- a/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp +++ b/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp @@ -332,7 +332,7 @@ frame os::fetch_frame_from_context(const void* ucVoid) { #ifndef AMD64 // Ignore "C4172: returning address of local variable or temporary" on 32bit PRAGMA_DIAG_PUSH -PRAGMA_DISABLE_MSVC_WARNING(4172) +PRAGMA_DISABLE_VISCPP_WARNING(4172) // Returns an estimate of the current stack pointer. Result must be guaranteed // to point into the calling threads stack, and be no lower than the current // stack pointer. diff --git a/src/hotspot/share/c1/c1_CFGPrinter.hpp b/src/hotspot/share/c1/c1_CFGPrinter.hpp index 9467e27101840..922653f70aac1 100644 --- a/src/hotspot/share/c1/c1_CFGPrinter.hpp +++ b/src/hotspot/share/c1/c1_CFGPrinter.hpp @@ -62,7 +62,8 @@ class CFGPrinterOutput : public CHeapObj { void inc_indent(); void dec_indent(); - void print(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); + ATTRIBUTE_PRINTF(2, 3) + void print(const char* format, ...); void print_begin(const char* tag); void print_end(const char* tag); diff --git a/src/hotspot/share/cds/filemap.hpp b/src/hotspot/share/cds/filemap.hpp index 233a4e8e5b368..a705e88ea76c7 100644 --- a/src/hotspot/share/cds/filemap.hpp +++ b/src/hotspot/share/cds/filemap.hpp @@ -479,8 +479,8 @@ class FileMapInfo : public CHeapObj { bool remap_shared_readonly_as_readwrite(); // Errors. - static void fail_stop(const char *msg, ...) ATTRIBUTE_PRINTF(1, 2); - static void fail_continue(const char *msg, ...) ATTRIBUTE_PRINTF(1, 2); + ATTRIBUTE_PRINTF(1, 2) static void fail_stop(const char *msg, ...); + ATTRIBUTE_PRINTF(1, 2) static void fail_continue(const char *msg, ...); static bool memory_mapping_failed() { CDS_ONLY(return _memory_mapping_failed;) NOT_CDS(return false;) diff --git a/src/hotspot/share/classfile/verifier.hpp b/src/hotspot/share/classfile/verifier.hpp index c50e2f7c21789..6f98580d5f4f5 100644 --- a/src/hotspot/share/classfile/verifier.hpp +++ b/src/hotspot/share/classfile/verifier.hpp @@ -432,8 +432,8 @@ class ClassVerifier : public StackObj { // Called when verify or class format errors are encountered. // May throw an exception based upon the mode. - void verify_error(ErrorContext ctx, const char* fmt, ...) ATTRIBUTE_PRINTF(3, 4); - void class_format_error(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3); + ATTRIBUTE_PRINTF(3, 4) void verify_error(ErrorContext ctx, const char* fmt, ...); + ATTRIBUTE_PRINTF(2, 3) void class_format_error(const char* fmt, ...); Klass* load_class(Symbol* name, TRAPS); diff --git a/src/hotspot/share/compiler/compileLog.hpp b/src/hotspot/share/compiler/compileLog.hpp index d91819104a5d6..bc2e265ce2a06 100644 --- a/src/hotspot/share/compiler/compileLog.hpp +++ b/src/hotspot/share/compiler/compileLog.hpp @@ -55,7 +55,7 @@ class CompileLog : public xmlStream { static CompileLog* _first; // head of static chain - void va_tag(bool push, const char* format, va_list ap) ATTRIBUTE_PRINTF(3, 0); + ATTRIBUTE_PRINTF(3, 0) void va_tag(bool push, const char* format, va_list ap); public: CompileLog(const char* file_name, FILE* fp, intx thread_id); @@ -69,7 +69,8 @@ class CompileLog : public xmlStream { // or reset, context string will be silently ignored stringStream* context() { return &_context; } void clear_context() { context()->reset(); } - void set_context(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); + ATTRIBUTE_PRINTF(2, 3) + void set_context(const char* format, ...); void name(ciSymbol* s); // name='s' void name(Symbol* s) { xmlStream::name(s); } diff --git a/src/hotspot/share/gc/shared/gcLogPrecious.hpp b/src/hotspot/share/gc/shared/gcLogPrecious.hpp index ec8b1c670f321..b019c24342b79 100644 --- a/src/hotspot/share/gc/shared/gcLogPrecious.hpp +++ b/src/hotspot/share/gc/shared/gcLogPrecious.hpp @@ -60,22 +60,25 @@ class GCLogPrecious : public AllStatic { // Protects the buffers static Mutex* _lock; + ATTRIBUTE_PRINTF(2, 0) static void vwrite_inner(LogTargetHandle log, const char* format, - va_list args) ATTRIBUTE_PRINTF(2, 0); + va_list args); public: static void initialize(); + ATTRIBUTE_PRINTF(2, 0) static void vwrite(LogTargetHandle log, const char* format, - va_list args) ATTRIBUTE_PRINTF(2, 0); + va_list args); + ATTRIBUTE_PRINTF(2, 0) static void vwrite_and_debug(LogTargetHandle log, const char* format, va_list args DEBUG_ONLY(COMMA const char* file) - DEBUG_ONLY(COMMA int line)) ATTRIBUTE_PRINTF(2, 0); + DEBUG_ONLY(COMMA int line)); static void print_on_error(outputStream* st); }; @@ -94,14 +97,16 @@ class GCLogPreciousHandle { DEBUG_ONLY(COMMA _line(line)) {} - void write(const char* format, ...) ATTRIBUTE_PRINTF(2, 3) { + ATTRIBUTE_PRINTF(2, 3) + void write(const char* format, ...) { va_list args; va_start(args, format); GCLogPrecious::vwrite(_log, format, args); va_end(args); } - void write_and_debug(const char* format, ...) ATTRIBUTE_PRINTF(2, 3) { + ATTRIBUTE_PRINTF(2, 3) + void write_and_debug(const char* format, ...) { va_list args; va_start(args, format); GCLogPrecious::vwrite_and_debug(_log, format, args DEBUG_ONLY(COMMA _file COMMA _line)); diff --git a/src/hotspot/share/gc/z/zStat.cpp b/src/hotspot/share/gc/z/zStat.cpp index 540c171ae9f7f..dd184ab45c26e 100644 --- a/src/hotspot/share/gc/z/zStat.cpp +++ b/src/hotspot/share/gc/z/zStat.cpp @@ -984,7 +984,8 @@ class ZStatTablePrinter { _width(width), _width_next(width_next) {} - ZColumn left(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3) { + ATTRIBUTE_PRINTF(2, 3) + ZColumn left(const char* fmt, ...) { va_list va; va_start(va, fmt); @@ -999,7 +1000,8 @@ class ZStatTablePrinter { return next(); } - ZColumn right(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3) { + ATTRIBUTE_PRINTF(2, 3) + ZColumn right(const char* fmt, ...) { va_list va; va_start(va, fmt); @@ -1022,7 +1024,8 @@ class ZStatTablePrinter { return next(); } - ZColumn center(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3) { + ATTRIBUTE_PRINTF(2, 3) + ZColumn center(const char* fmt, ...) { va_list va; va_start(va, fmt); diff --git a/src/hotspot/share/jvmci/jvmci.hpp b/src/hotspot/share/jvmci/jvmci.hpp index 0ddfc76197e7a..c8325a68265f6 100644 --- a/src/hotspot/share/jvmci/jvmci.hpp +++ b/src/hotspot/share/jvmci/jvmci.hpp @@ -173,18 +173,18 @@ class JVMCI : public AllStatic { static JVMCIRuntime* compiler_runtime(JavaThread* thread, bool create=true); // Appends an event to the JVMCI event log if JVMCIEventLogLevel >= `level` - static void vlog(int level, const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0); + ATTRIBUTE_PRINTF(2, 0) static void vlog(int level, const char* format, va_list ap); // Traces an event to tty if JVMCITraceLevel >= `level` - static void vtrace(int level, const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0); + ATTRIBUTE_PRINTF(2, 0) static void vtrace(int level, const char* format, va_list ap); public: // Log/trace a JVMCI event - static void event(int level, const char* format, ...) ATTRIBUTE_PRINTF(2, 3); - static void event1(const char* format, ...) ATTRIBUTE_PRINTF(1, 2); - static void event2(const char* format, ...) ATTRIBUTE_PRINTF(1, 2); - static void event3(const char* format, ...) ATTRIBUTE_PRINTF(1, 2); - static void event4(const char* format, ...) ATTRIBUTE_PRINTF(1, 2); + ATTRIBUTE_PRINTF(2, 3) static void event(int level, const char* format, ...); + ATTRIBUTE_PRINTF(1, 2) static void event1(const char* format, ...); + ATTRIBUTE_PRINTF(1, 2) static void event2(const char* format, ...); + ATTRIBUTE_PRINTF(1, 2) static void event3(const char* format, ...); + ATTRIBUTE_PRINTF(1, 2) static void event4(const char* format, ...); }; // JVMCI event macros. diff --git a/src/hotspot/share/jvmci/jvmciEnv.hpp b/src/hotspot/share/jvmci/jvmciEnv.hpp index fa76dfae3a2fd..6a90e30dca5c4 100644 --- a/src/hotspot/share/jvmci/jvmciEnv.hpp +++ b/src/hotspot/share/jvmci/jvmciEnv.hpp @@ -344,7 +344,7 @@ class JVMCIEnv : public ResourceObj { #undef DO_THROW - void fthrow_error(const char* file, int line, const char* format, ...) ATTRIBUTE_PRINTF(4, 5); + ATTRIBUTE_PRINTF(4, 5) void fthrow_error(const char* file, int line, const char* format, ...); // Given an instance of HotSpotInstalledCode return the corresponding CodeBlob*. CodeBlob* get_code_blob(JVMCIObject code); diff --git a/src/hotspot/share/logging/log.hpp b/src/hotspot/share/logging/log.hpp index 8455ed814baa1..7b22231cabe5f 100644 --- a/src/hotspot/share/logging/log.hpp +++ b/src/hotspot/share/logging/log.hpp @@ -153,7 +153,7 @@ class LogImpl { vwrite(LogLevel::level, fmt, args); \ return *this; \ } \ - LogImpl& name(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3) { \ + ATTRIBUTE_PRINTF(2, 3) LogImpl& name(const char* fmt, ...) { \ va_list args; \ va_start(args, fmt); \ vwrite(LogLevel::level, fmt, args); \ @@ -189,7 +189,8 @@ class LogTargetImpl { PRODUCT_ONLY(return false); } - static void print(const char* fmt, ...) ATTRIBUTE_PRINTF(1, 2) { + ATTRIBUTE_PRINTF(1, 2) + static void print(const char* fmt, ...) { va_list args; va_start(args, fmt); LogTagSetMapping::tagset().vwrite(level, fmt, args); diff --git a/src/hotspot/share/logging/logHandle.hpp b/src/hotspot/share/logging/logHandle.hpp index 41d0ecd407eba..264e0f387548f 100644 --- a/src/hotspot/share/logging/logHandle.hpp +++ b/src/hotspot/share/logging/logHandle.hpp @@ -52,7 +52,7 @@ class LogHandle { _tagset.vwrite(LogLevel::level, fmt, args); \ return *this; \ } \ - LogHandle& name(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3) { \ + ATTRIBUTE_PRINTF(2, 3) LogHandle& name(const char* fmt, ...) { \ va_list args; \ va_start(args, fmt); \ _tagset.vwrite(LogLevel::level, fmt, args); \ @@ -90,7 +90,8 @@ class LogTargetHandle { return LogTargetHandle(LogTargetImpl()); } - void print(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3) { + ATTRIBUTE_PRINTF(2, 3) + void print(const char* fmt, ...) { va_list args; va_start(args, fmt); if (is_enabled()) { diff --git a/src/hotspot/share/logging/logMessageBuffer.hpp b/src/hotspot/share/logging/logMessageBuffer.hpp index a7f94ecf72d49..17b85e541585c 100644 --- a/src/hotspot/share/logging/logMessageBuffer.hpp +++ b/src/hotspot/share/logging/logMessageBuffer.hpp @@ -121,8 +121,8 @@ class LogMessageBuffer : public StackObj { virtual void vwrite(LogLevelType level, const char* fmt, va_list args); #define LOG_LEVEL(level, name) \ - LogMessageBuffer& v##name(const char* fmt, va_list args) ATTRIBUTE_PRINTF(2, 0); \ - LogMessageBuffer& name(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3); + ATTRIBUTE_PRINTF(2, 0) LogMessageBuffer& v##name(const char* fmt, va_list args); \ + ATTRIBUTE_PRINTF(2, 3) LogMessageBuffer& name(const char* fmt, ...); LOG_LEVEL_LIST #undef LOG_LEVEL }; diff --git a/src/hotspot/share/logging/logStream.hpp b/src/hotspot/share/logging/logStream.hpp index 66e7b638d502a..cc88ece3b234d 100644 --- a/src/hotspot/share/logging/logStream.hpp +++ b/src/hotspot/share/logging/logStream.hpp @@ -148,7 +148,8 @@ class LogMessageHandle { return _lm.is_level(_level); } - void print(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3) { + ATTRIBUTE_PRINTF(2, 3) + void print(const char* fmt, ...) { va_list args; va_start(args, fmt); if (is_enabled()) { diff --git a/src/hotspot/share/oops/generateOopMap.hpp b/src/hotspot/share/oops/generateOopMap.hpp index 8ab15c92b8426..029be2847353e 100644 --- a/src/hotspot/share/oops/generateOopMap.hpp +++ b/src/hotspot/share/oops/generateOopMap.hpp @@ -407,9 +407,12 @@ class GenerateOopMap { int copy_cts (CellTypeState *dst, CellTypeState *src); // Error handling - void error_work (const char *format, va_list ap) ATTRIBUTE_PRINTF(2, 0); - void report_error (const char *format, ...) ATTRIBUTE_PRINTF(2, 3); - void verify_error (const char *format, ...) ATTRIBUTE_PRINTF(2, 3); + ATTRIBUTE_PRINTF(2, 0) + void error_work (const char *format, va_list ap); + ATTRIBUTE_PRINTF(2, 3) + void report_error (const char *format, ...); + ATTRIBUTE_PRINTF(2, 3) + void verify_error (const char *format, ...); bool got_error() { return _got_error; } // Create result set diff --git a/src/hotspot/share/runtime/abstract_vm_version.cpp b/src/hotspot/share/runtime/abstract_vm_version.cpp index 8f62996da5409..1bc977ac51d3a 100644 --- a/src/hotspot/share/runtime/abstract_vm_version.cpp +++ b/src/hotspot/share/runtime/abstract_vm_version.cpp @@ -80,13 +80,21 @@ VirtualizationType Abstract_VM_Version::_detected_virtualization = NoDetectedVir #define VM_RELEASE HOTSPOT_VERSION_STRING +#define EMPTY(ARG) (0-ARG-1)==1 && (ARG+0)!=-2 + // HOTSPOT_VERSION_STRING equals the JDK VERSION_STRING (unless overridden // in a standalone build). int Abstract_VM_Version::_vm_major_version = VERSION_FEATURE; int Abstract_VM_Version::_vm_minor_version = VERSION_INTERIM; int Abstract_VM_Version::_vm_security_version = VERSION_UPDATE; int Abstract_VM_Version::_vm_patch_version = VERSION_PATCH; +#if EMPTY(VERSION_BUILD) +int Abstract_VM_Version::_vm_build_number = 0; +#else int Abstract_VM_Version::_vm_build_number = VERSION_BUILD; +#endif + +#undef EMPTY #if defined(_LP64) #define VMLP "64-Bit " diff --git a/src/hotspot/share/runtime/arguments.hpp b/src/hotspot/share/runtime/arguments.hpp index a1c42a4318ccb..51bff5272346b 100644 --- a/src/hotspot/share/runtime/arguments.hpp +++ b/src/hotspot/share/runtime/arguments.hpp @@ -43,7 +43,7 @@ class JVMFlag; extern "C" { typedef void (JNICALL *abort_hook_t)(void); typedef void (JNICALL *exit_hook_t)(jint code); - typedef jint (JNICALL *vfprintf_hook_t)(FILE *fp, const char *format, va_list args) ATTRIBUTE_PRINTF(2, 0); + typedef jint (JNICALL *vfprintf_hook_t ATTRIBUTE_PRINTF(2, 0))(FILE *fp, const char *format, va_list args); } // Obsolete or deprecated -XX flag. diff --git a/src/hotspot/share/runtime/flags/jvmFlag.hpp b/src/hotspot/share/runtime/flags/jvmFlag.hpp index bee086d16c20f..23a49e04edf20 100644 --- a/src/hotspot/share/runtime/flags/jvmFlag.hpp +++ b/src/hotspot/share/runtime/flags/jvmFlag.hpp @@ -319,7 +319,8 @@ class JVMFlag { // printRanges will print out flags type, name and range values as expected by -XX:+PrintFlagsRanges static void printFlags(outputStream* out, bool withComments, bool printRanges = false, bool skipDefaults = false); - static void printError(bool verbose, const char* msg, ...) ATTRIBUTE_PRINTF(2, 3); + ATTRIBUTE_PRINTF(2, 3) + static void printError(bool verbose, const char* msg, ...); static void verify() PRODUCT_RETURN; }; diff --git a/src/hotspot/share/runtime/nonJavaThread.hpp b/src/hotspot/share/runtime/nonJavaThread.hpp index 5eb26e429241a..780b4b7ccc95b 100644 --- a/src/hotspot/share/runtime/nonJavaThread.hpp +++ b/src/hotspot/share/runtime/nonJavaThread.hpp @@ -89,7 +89,7 @@ class NamedThread: public NonJavaThread { NamedThread(); ~NamedThread(); // May only be called once per thread. - void set_name(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); + ATTRIBUTE_PRINTF(2, 3) void set_name(const char* format, ...); virtual bool is_Named_thread() const { return true; } virtual const char* name() const { return _name == NULL ? "Unknown Thread" : _name; } virtual const char* type_name() const { return "NamedThread"; } diff --git a/src/hotspot/share/runtime/os.hpp b/src/hotspot/share/runtime/os.hpp index 1399f17e2c2fc..d0c683da41b81 100644 --- a/src/hotspot/share/runtime/os.hpp +++ b/src/hotspot/share/runtime/os.hpp @@ -737,8 +737,8 @@ class os: AllStatic { // Provide C99 compliant versions of these functions, since some versions // of some platforms don't. - static int vsnprintf(char* buf, size_t len, const char* fmt, va_list args) ATTRIBUTE_PRINTF(3, 0); - static int snprintf(char* buf, size_t len, const char* fmt, ...) ATTRIBUTE_PRINTF(3, 4); + ATTRIBUTE_PRINTF(3, 0) static int vsnprintf(char* buf, size_t len, const char* fmt, va_list args); + ATTRIBUTE_PRINTF(3, 4) static int snprintf(char* buf, size_t len, const char* fmt, ...); // Get host name in buffer provided static bool get_host_name(char* buf, size_t buflen); diff --git a/src/hotspot/share/utilities/compilerWarnings.hpp b/src/hotspot/share/utilities/compilerWarnings.hpp index c3de6863f8aa4..2c46088567a6c 100644 --- a/src/hotspot/share/utilities/compilerWarnings.hpp +++ b/src/hotspot/share/utilities/compilerWarnings.hpp @@ -41,11 +41,11 @@ #endif #ifndef PRAGMA_DISABLE_GCC_WARNING -#define PRAGMA_DISABLE_GCC_WARNING(name) +#define PRAGMA_DISABLE_GCC_WARNING(opt) #endif -#ifndef PRAGMA_DISABLE_MSVC_WARNING -#define PRAGMA_DISABLE_MSVC_WARNING(num) +#ifndef PRAGMA_DISABLE_VISCPP_WARNING +#define PRAGMA_DISABLE_VISCPP_WARNING(num) #endif #ifndef ATTRIBUTE_PRINTF diff --git a/src/hotspot/share/utilities/compilerWarnings_gcc.hpp b/src/hotspot/share/utilities/compilerWarnings_gcc.hpp index 8cf0ad571f011..764b37fb2541e 100644 --- a/src/hotspot/share/utilities/compilerWarnings_gcc.hpp +++ b/src/hotspot/share/utilities/compilerWarnings_gcc.hpp @@ -28,15 +28,23 @@ // Macros related to control of compiler warnings. #ifndef ATTRIBUTE_PRINTF -#define ATTRIBUTE_PRINTF(fmt,vargs) __attribute__((format(printf, fmt, vargs))) +#define ATTRIBUTE_PRINTF(fmt,vargs) [[gnu::format(printf, fmt, vargs)]] #endif #ifndef ATTRIBUTE_SCANF -#define ATTRIBUTE_SCANF(fmt,vargs) __attribute__((format(scanf, fmt, vargs))) +#define ATTRIBUTE_SCANF(fmt,vargs) [[gnu::format(scanf, fmt, vargs)]] #endif -#define PRAGMA_DISABLE_GCC_WARNING_AUX(x) _Pragma(#x) -#define PRAGMA_DISABLE_GCC_WARNING(option_string) \ - PRAGMA_DISABLE_GCC_WARNING_AUX(GCC diagnostic ignored option_string) +#if defined(__clang_major__) && \ + (__clang_major__ >= 4 || \ + (__clang_major__ >= 3 && __clang_minor__ >= 1)) || \ + ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4) +// Tested to work with clang version 3.1 and better. +#define PRAGMA_DIAG_PUSH _Pragma("GCC diagnostic push") +#define PRAGMA_DIAG_POP _Pragma("GCC diagnostic pop") + +#endif // clang/gcc version check + +#define PRAGMA_DISABLE_GCC_WARNING(opt) PRAGMA(GCC diagnostic ignored opt) #define PRAGMA_FORMAT_NONLITERAL_IGNORED \ PRAGMA_DISABLE_GCC_WARNING("-Wformat-nonliteral") \ @@ -56,18 +64,7 @@ #define PRAGMA_STRINGOP_OVERFLOW_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wstringop-overflow") #endif -#define PRAGMA_NONNULL_IGNORED \ - PRAGMA_DISABLE_GCC_WARNING("-Wnonnull") - -#if defined(__clang_major__) && \ - (__clang_major__ >= 4 || \ - (__clang_major__ >= 3 && __clang_minor__ >= 1)) || \ - ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4) -// Tested to work with clang version 3.1 and better. -#define PRAGMA_DIAG_PUSH _Pragma("GCC diagnostic push") -#define PRAGMA_DIAG_POP _Pragma("GCC diagnostic pop") - -#endif // clang/gcc version check +#define PRAGMA_NONNULL_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wnonnull") #if (__GNUC__ >= 10) // TODO: Re-enable warning attribute for Clang once @@ -85,7 +82,7 @@ // so uses of functions that are both forbidden and fortified won't cause // forbidden warnings in such builds. #define FORBID_C_FUNCTION(signature, alternative) \ - extern "C" __attribute__((__warning__(alternative))) signature; + extern "C" [[gnu::warning(alternative)]] signature; // Disable warning attribute over the scope of the affected statement. // The name serves only to document the intended function. diff --git a/src/hotspot/share/utilities/compilerWarnings_visCPP.hpp b/src/hotspot/share/utilities/compilerWarnings_visCPP.hpp index 0b52fa5adf34f..5f56d3f1ec9ef 100644 --- a/src/hotspot/share/utilities/compilerWarnings_visCPP.hpp +++ b/src/hotspot/share/utilities/compilerWarnings_visCPP.hpp @@ -25,10 +25,10 @@ #ifndef SHARE_UTILITIES_COMPILERWARNINGS_VISCPP_HPP #define SHARE_UTILITIES_COMPILERWARNINGS_VISCPP_HPP -#define PRAGMA_DIAG_PUSH __pragma(warning(push)) -#define PRAGMA_DIAG_POP __pragma(warning(pop)) +#define PRAGMA_DIAG_PUSH _Pragma("warning(push)") +#define PRAGMA_DIAG_POP _Pragma("warning(pop)") -#define PRAGMA_DISABLE_MSVC_WARNING(num) __pragma(warning(disable : num)) +#define PRAGMA_DISABLE_VISCPP_WARNING(num) PRAGMA(warning(disable : num)) // The Visual Studio implementation of FORBID_C_FUNCTION explicitly does // nothing, because there doesn't seem to be a way to implement it for Visual @@ -61,7 +61,7 @@ #define ALLOW_C_FUNCTION(name, ...) \ PRAGMA_DIAG_PUSH \ - PRAGMA_DISABLE_MSVC_WARNING(4996) \ + PRAGMA_DISABLE_VISCPP_WARNING(4996) \ __VA_ARGS__ \ PRAGMA_DIAG_POP diff --git a/src/hotspot/share/utilities/debug.hpp b/src/hotspot/share/utilities/debug.hpp index 773bae206bddd..70531044b1bd8 100644 --- a/src/hotspot/share/utilities/debug.hpp +++ b/src/hotspot/share/utilities/debug.hpp @@ -163,19 +163,22 @@ extern bool Debugging; // error reporting helper functions void report_vm_error(const char* file, int line, const char* error_msg); +ATTRIBUTE_PRINTF(4, 5) void report_vm_error(const char* file, int line, const char* error_msg, - const char* detail_fmt, ...) ATTRIBUTE_PRINTF(4, 5); + const char* detail_fmt, ...); void report_vm_status_error(const char* file, int line, const char* error_msg, int status, const char* detail); -void report_fatal(VMErrorType error_type, const char* file, int line, const char* detail_fmt, ...) ATTRIBUTE_PRINTF(4, 5); +ATTRIBUTE_PRINTF(4, 5) +void report_fatal(VMErrorType error_type, const char* file, int line, const char* detail_fmt, ...); +ATTRIBUTE_PRINTF(5, 6) void report_vm_out_of_memory(const char* file, int line, size_t size, VMErrorType vm_err_type, - const char* detail_fmt, ...) ATTRIBUTE_PRINTF(5, 6); + const char* detail_fmt, ...); void report_should_not_call(const char* file, int line); void report_should_not_reach_here(const char* file, int line); void report_unimplemented(const char* file, int line); void report_untested(const char* file, int line, const char* message); -void warning(const char* format, ...) ATTRIBUTE_PRINTF(1, 2); +ATTRIBUTE_PRINTF(1, 2) void warning(const char* format, ...); #define STATIC_ASSERT(Cond) static_assert((Cond), #Cond) diff --git a/src/hotspot/share/utilities/events.hpp b/src/hotspot/share/utilities/events.hpp index 8b6e715060623..882a2a51ec315 100644 --- a/src/hotspot/share/utilities/events.hpp +++ b/src/hotspot/share/utilities/events.hpp @@ -169,7 +169,8 @@ class FormatStringEventLog : public EventLogBase< FormatStringLogMessage FormatStringEventLog(const char* name, const char* short_name, int count = LogEventsBufferEntries) : EventLogBase< FormatStringLogMessage >(name, short_name, count) {} - void logv(Thread* thread, const char* format, va_list ap) ATTRIBUTE_PRINTF(3, 0) { + ATTRIBUTE_PRINTF(3, 0) + void logv(Thread* thread, const char* format, va_list ap) { if (!this->should_log()) return; double timestamp = this->fetch_timestamp(); @@ -180,7 +181,8 @@ class FormatStringEventLog : public EventLogBase< FormatStringLogMessage this->_records[index].data.printv(format, ap); } - void log(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(3, 4) { + ATTRIBUTE_PRINTF(3, 4) + void log(Thread* thread, const char* format, ...) { va_list ap; va_start(ap, format); this->logv(thread, format, ap); @@ -254,23 +256,30 @@ class Events : AllStatic { static void print(); // Logs a generic message with timestamp and format as printf. - static void log(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3); + ATTRIBUTE_PRINTF(2, 3) + static void log(Thread* thread, const char* format, ...); - static void log_vm_operation(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3); + ATTRIBUTE_PRINTF(2, 3) + static void log_vm_operation(Thread* thread, const char* format, ...); // Log exception related message - static void log_exception(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3); + ATTRIBUTE_PRINTF(2, 3) + static void log_exception(Thread* thread, const char* format, ...); static void log_exception(Thread* thread, Handle h_exception, const char* message, const char* file, int line); - static void log_redefinition(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3); + ATTRIBUTE_PRINTF(2, 3) + static void log_redefinition(Thread* thread, const char* format, ...); static void log_class_unloading(Thread* thread, InstanceKlass* ik); - static void log_class_loading(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3); + ATTRIBUTE_PRINTF(2, 3) + static void log_class_loading(Thread* thread, const char* format, ...); - static void log_deopt_message(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3); + ATTRIBUTE_PRINTF(2, 3) + static void log_deopt_message(Thread* thread, const char* format, ...); - static void log_dll_message(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3); + ATTRIBUTE_PRINTF(2, 3) + static void log_dll_message(Thread* thread, const char* format, ...); // Register default loggers static void init(); @@ -465,7 +474,8 @@ class EventMarkBase : public StackObj { NONCOPYABLE(EventMarkBase); protected: - void log_start(const char* format, va_list argp) ATTRIBUTE_PRINTF(2, 0); + ATTRIBUTE_PRINTF(2, 0) + void log_start(const char* format, va_list argp); void log_end(); EventMarkBase(EventLogFunction log_function); @@ -478,8 +488,8 @@ class EventMarkWithLogFunction : public EventMarkBase { public: // log a begin event, format as printf - EventMarkWithLogFunction(const char* format, ...) ATTRIBUTE_PRINTF(2, 3) : - EventMarkBase(log_function) { + ATTRIBUTE_PRINTF(2, 3) + EventMarkWithLogFunction(const char* format, ...) : EventMarkBase(log_function) { if (LogEvents) { va_list ap; va_start(ap, format); diff --git a/src/hotspot/share/utilities/exceptions.hpp b/src/hotspot/share/utilities/exceptions.hpp index 703f07b2ec191..5d7a771488785 100644 --- a/src/hotspot/share/utilities/exceptions.hpp +++ b/src/hotspot/share/utilities/exceptions.hpp @@ -144,8 +144,9 @@ class Exceptions { // There is no THROW... macro for this method. Caller should remember // to do a return after calling it. + ATTRIBUTE_PRINTF(5, 6) static void fthrow(JavaThread* thread, const char* file, int line, Symbol* name, - const char* format, ...) ATTRIBUTE_PRINTF(5, 6); + const char* format, ...); // Create and initialize a new exception static Handle new_exception(JavaThread* thread, Symbol* name, diff --git a/src/hotspot/share/utilities/formatBuffer.hpp b/src/hotspot/share/utilities/formatBuffer.hpp index 92ce9528457cb..d8181c7940b04 100644 --- a/src/hotspot/share/utilities/formatBuffer.hpp +++ b/src/hotspot/share/utilities/formatBuffer.hpp @@ -42,7 +42,8 @@ class FormatBufferBase { // Use resource area for buffer class FormatBufferResource : public FormatBufferBase { public: - FormatBufferResource(const char * format, ...) ATTRIBUTE_PRINTF(2, 3); + ATTRIBUTE_PRINTF(2, 3) + FormatBufferResource(const char * format, ...); }; class FormatBufferDummy {}; @@ -51,12 +52,12 @@ class FormatBufferDummy {}; template class FormatBuffer : public FormatBufferBase { public: - inline FormatBuffer(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); + ATTRIBUTE_PRINTF(2, 3) inline FormatBuffer(const char* format, ...); // since va_list is unspecified type (can be char*), we use FormatBufferDummy to disambiguate these constructors - inline FormatBuffer(FormatBufferDummy dummy, const char* format, va_list ap) ATTRIBUTE_PRINTF(3, 0); - inline void append(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); - inline void print(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); - inline void printv(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0); + ATTRIBUTE_PRINTF(3, 0) inline FormatBuffer(FormatBufferDummy dummy, const char* format, va_list ap); + ATTRIBUTE_PRINTF(2, 3) inline void append(const char* format, ...); + ATTRIBUTE_PRINTF(2, 3) inline void print(const char* format, ...); + ATTRIBUTE_PRINTF(2, 0) inline void printv(const char* format, va_list ap); char* buffer() { return _buf; } int size() { return bufsz; } diff --git a/src/hotspot/share/utilities/globalDefinitions.hpp b/src/hotspot/share/utilities/globalDefinitions.hpp index f21bb89d0a0bd..15cfb4a31659b 100644 --- a/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/src/hotspot/share/utilities/globalDefinitions.hpp @@ -47,7 +47,7 @@ class oopDesc; #endif #ifndef ATTRIBUTE_ALIGNED -#define ATTRIBUTE_ALIGNED(x) +#define ATTRIBUTE_ALIGNED(x) alignas(x) #endif #ifndef ATTRIBUTE_FLATTEN @@ -437,7 +437,7 @@ typedef unsigned int uint; NEEDS_CLEANUP // All kinds of 'plain' byte addresses typedef signed char s_char; typedef unsigned char u_char; -typedef u_char* address; +typedef uint8_t* address; typedef uintptr_t address_word; // unsigned integer which will hold a pointer // except for some implementations of a C++ // linkage pointer to function. Should never diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp index 4aed8605182f3..74e29d5cc1426 100644 --- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp +++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp @@ -152,12 +152,8 @@ inline int g_isfinite(jdouble f) { return isfinite(f); } #define THREAD_LOCAL __thread // Inlining support -#define NOINLINE __attribute__ ((noinline)) -#define ALWAYSINLINE inline __attribute__ ((always_inline)) -#define ATTRIBUTE_FLATTEN __attribute__ ((flatten)) - -// Alignment -// -#define ATTRIBUTE_ALIGNED(x) __attribute__((aligned(x))) +#define NOINLINE [[gnu::noinline]] +#define ALWAYSINLINE [[gnu::always_inline]] +#define ATTRIBUTE_FLATTEN [[gnu::flatten]] #endif // SHARE_UTILITIES_GLOBALDEFINITIONS_GCC_HPP diff --git a/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp b/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp index 2208953ee8bc3..236949954575b 100644 --- a/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp +++ b/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp @@ -122,9 +122,6 @@ inline int g_isfinite(jdouble f) { return _finite(f); } #define NOINLINE __declspec(noinline) #define ALWAYSINLINE __forceinline -// Alignment -#define ATTRIBUTE_ALIGNED(x) __declspec(align(x)) - #ifdef _M_ARM64 #define USE_VECTORED_EXCEPTION_HANDLING #endif diff --git a/src/hotspot/share/utilities/json.hpp b/src/hotspot/share/utilities/json.hpp index 7dc8f4c921407..64af0d3e3c80c 100644 --- a/src/hotspot/share/utilities/json.hpp +++ b/src/hotspot/share/utilities/json.hpp @@ -68,7 +68,7 @@ class JSON : public ResourceObj { VALUE_ERROR } JSON_ERROR; - void error(JSON_ERROR e, const char* format, ...) ATTRIBUTE_PRINTF(3, 4); + ATTRIBUTE_PRINTF(3, 4) void error(JSON_ERROR e, const char* format, ...); outputStream* _st; private: diff --git a/src/hotspot/share/utilities/macros.hpp b/src/hotspot/share/utilities/macros.hpp index bfbaaa58acc2c..6eee606900860 100644 --- a/src/hotspot/share/utilities/macros.hpp +++ b/src/hotspot/share/utilities/macros.hpp @@ -25,6 +25,10 @@ #ifndef SHARE_UTILITIES_MACROS_HPP #define SHARE_UTILITIES_MACROS_HPP +// For when Pragmas need to be reliably nested in macros. Also handles +// quotation marks, so use sites are not required to pass string literals +#define PRAGMA(str) _Pragma(#str) + // Use this to mark code that needs to be cleaned up (for development only) #define NEEDS_CLEANUP diff --git a/src/hotspot/share/utilities/ostream.hpp b/src/hotspot/share/utilities/ostream.hpp index db1a020e787d1..c3be700e5c251 100644 --- a/src/hotspot/share/utilities/ostream.hpp +++ b/src/hotspot/share/utilities/ostream.hpp @@ -56,17 +56,18 @@ class outputStream : public CHeapObjBase { // Returns whether a newline was seen or not bool update_position(const char* s, size_t len); + ATTRIBUTE_PRINTF(3, 0) static const char* do_vsnprintf(char* buffer, size_t buflen, const char* format, va_list ap, bool add_cr, - size_t& result_len) ATTRIBUTE_PRINTF(3, 0); + size_t& result_len); // calls do_vsnprintf and writes output to stream; uses an on-stack buffer. - void do_vsnprintf_and_write_with_automatic_buffer(const char* format, va_list ap, bool add_cr) ATTRIBUTE_PRINTF(2, 0); + ATTRIBUTE_PRINTF(2, 0) void do_vsnprintf_and_write_with_automatic_buffer(const char* format, va_list ap, bool add_cr); // calls do_vsnprintf and writes output to stream; uses the user-provided buffer; - void do_vsnprintf_and_write_with_scratch_buffer(const char* format, va_list ap, bool add_cr) ATTRIBUTE_PRINTF(2, 0); + ATTRIBUTE_PRINTF(2, 0) void do_vsnprintf_and_write_with_scratch_buffer(const char* format, va_list ap, bool add_cr); // calls do_vsnprintf, then writes output to stream. - void do_vsnprintf_and_write(const char* format, va_list ap, bool add_cr) ATTRIBUTE_PRINTF(2, 0); + ATTRIBUTE_PRINTF(2, 0) void do_vsnprintf_and_write(const char* format, va_list ap, bool add_cr); public: // creation @@ -91,10 +92,10 @@ class outputStream : public CHeapObjBase { void set_position(int pos) { _position = pos; } // printing - void print(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); - void print_cr(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); - void vprint(const char *format, va_list argptr) ATTRIBUTE_PRINTF(2, 0); - void vprint_cr(const char* format, va_list argptr) ATTRIBUTE_PRINTF(2, 0); + ATTRIBUTE_PRINTF(2, 3) void print(const char* format, ...); + ATTRIBUTE_PRINTF(2, 3) void print_cr(const char* format, ...); + ATTRIBUTE_PRINTF(2, 0) void vprint(const char *format, va_list argptr); + ATTRIBUTE_PRINTF(2, 0) void vprint_cr(const char* format, va_list argptr); void print_raw(const char* str) { write(str, strlen(str)); } void print_raw(const char* str, size_t len) { write(str, len); } void print_raw_cr(const char* str) { write(str, strlen(str)); cr(); } diff --git a/src/hotspot/share/utilities/vmError.hpp b/src/hotspot/share/utilities/vmError.hpp index f13c5b7faf3af..b3e79c6379793 100644 --- a/src/hotspot/share/utilities/vmError.hpp +++ b/src/hotspot/share/utilities/vmError.hpp @@ -154,22 +154,26 @@ class VMError : public AllStatic { static void print_vm_info(outputStream* st); // main error reporting function + ATTRIBUTE_PRINTF(6, 7) static void report_and_die(Thread* thread, unsigned int sig, address pc, void* siginfo, - void* context, const char* detail_fmt, ...) ATTRIBUTE_PRINTF(6, 7); + void* context, const char* detail_fmt, ...); + ATTRIBUTE_PRINTF(3, 0) static void report_and_die(int id, const char* message, const char* detail_fmt, va_list detail_args, Thread* thread, address pc, void* siginfo, void* context, - const char* filename, int lineno, size_t size) ATTRIBUTE_PRINTF(3, 0); + const char* filename, int lineno, size_t size); static void report_and_die(Thread* thread, unsigned int sig, address pc, void* siginfo, void* context); + ATTRIBUTE_PRINTF(6, 0) static void report_and_die(Thread* thread, void* context, const char* filename, int lineno, const char* message, - const char* detail_fmt, va_list detail_args) ATTRIBUTE_PRINTF(6, 0); + const char* detail_fmt, va_list detail_args); + ATTRIBUTE_PRINTF(6, 0) static void report_and_die(Thread* thread, const char* filename, int lineno, size_t size, VMErrorType vm_err_type, const char* detail_fmt, - va_list detail_args) ATTRIBUTE_PRINTF(6, 0); + va_list detail_args); // reporting OutOfMemoryError static void report_java_out_of_memory(const char* message); diff --git a/src/hotspot/share/utilities/xmlstream.hpp b/src/hotspot/share/utilities/xmlstream.hpp index 9978e64a82ec3..293eb9b727c30 100644 --- a/src/hotspot/share/utilities/xmlstream.hpp +++ b/src/hotspot/share/utilities/xmlstream.hpp @@ -80,7 +80,8 @@ class xmlStream : public outputStream { outputStream* out() { return _out; } // helpers for writing XML elements - void va_tag(bool push, const char* format, va_list ap) ATTRIBUTE_PRINTF(3, 0); + ATTRIBUTE_PRINTF(3, 0) + void va_tag(bool push, const char* format, va_list ap); virtual void see_tag(const char* tag, bool push) NOT_DEBUG({}); virtual void pop_tag(const char* tag) NOT_DEBUG({}); @@ -109,29 +110,43 @@ class xmlStream : public outputStream { int unflushed_count() { return (int)(out()->count() - _last_flush); } // writing complete XML elements - void elem(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); - void begin_elem(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); - void end_elem(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); + ATTRIBUTE_PRINTF(2, 3) + void elem(const char* format, ...); + ATTRIBUTE_PRINTF(2, 3) + void begin_elem(const char* format, ...); + ATTRIBUTE_PRINTF(2, 3) + void end_elem(const char* format, ...); void end_elem(); - void head(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); - void begin_head(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); - void end_head(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); + ATTRIBUTE_PRINTF(2, 3) + void head(const char* format, ...); + ATTRIBUTE_PRINTF(2, 3) + void begin_head(const char* format, ...); + ATTRIBUTE_PRINTF(2, 3) + void end_head(const char* format, ...); void end_head(); - void done(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); // xxx_done event, plus tail + ATTRIBUTE_PRINTF(2, 3) + void done(const char* format, ...); // xxx_done event, plus tail void done_raw(const char * kind); void tail(const char* kind); // va_list versions - void va_elem(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0); - void va_begin_elem(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0); - void va_head(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0); - void va_begin_head(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0); - void va_done(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0); + ATTRIBUTE_PRINTF(2, 0) + void va_elem(const char* format, va_list ap); + ATTRIBUTE_PRINTF(2, 0) + void va_begin_elem(const char* format, va_list ap); + ATTRIBUTE_PRINTF(2, 0) + void va_head(const char* format, va_list ap); + ATTRIBUTE_PRINTF(2, 0) + void va_begin_head(const char* format, va_list ap); + ATTRIBUTE_PRINTF(2, 0) + void va_done(const char* format, va_list ap); // write text (with quoting of special XML characters <>&'" etc.) outputStream* text() { return _text; } - void text(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); - void va_text(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0) { + ATTRIBUTE_PRINTF(2, 3) + void text(const char* format, ...); + ATTRIBUTE_PRINTF(2, 0) + void va_text(const char* format, va_list ap) { text()->vprint(format, ap); } diff --git a/src/java.prefs/windows/native/libprefs/WindowsPreferences.c b/src/java.prefs/windows/native/libprefs/WindowsPreferences.c index 7f5a74ac59061..adcf7491dae6d 100644 --- a/src/java.prefs/windows/native/libprefs/WindowsPreferences.c +++ b/src/java.prefs/windows/native/libprefs/WindowsPreferences.c @@ -23,6 +23,7 @@ * questions. */ +#include #include #include #include "jni.h" @@ -49,7 +50,7 @@ Java_java_util_prefs_WindowsPreferences_WindowsRegOpenKey(JNIEnv* env, int errorCode = RegOpenKeyEx((HKEY) hKey, str, 0, securityMask, &handle); (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0); - __declspec(align(8)) jlong tmp[2]; + alignas(8) jlong tmp[2]; tmp[0] = (jlong) handle; tmp[1] = errorCode; jlongArray result = (*env)->NewLongArray(env, 2); @@ -78,7 +79,7 @@ Java_java_util_prefs_WindowsPreferences_WindowsRegCreateKeyEx(JNIEnv* env, NULL, &handle, &lpdwDisposition); (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0); - __declspec(align(8)) jlong tmp[3]; + alignas(8) jlong tmp[3]; tmp[0] = (jlong) handle; tmp[1] = errorCode; tmp[2] = lpdwDisposition; @@ -196,7 +197,7 @@ Java_java_util_prefs_WindowsPreferences_WindowsRegQueryInfoKey(JNIEnv* env, &valuesNumber, &maxValueNameLength, NULL, NULL, NULL); - __declspec(align(8)) jlong tmp[5]; + alignas(8) jlong tmp[5]; tmp[0] = subKeysNumber; tmp[1] = errorCode; tmp[2] = valuesNumber; diff --git a/src/java.security.jgss/share/native/libj2gss/GSSLibStub.c b/src/java.security.jgss/share/native/libj2gss/GSSLibStub.c index 308879f3a8d8a..228c19f443a4e 100644 --- a/src/java.security.jgss/share/native/libj2gss/GSSLibStub.c +++ b/src/java.security.jgss/share/native/libj2gss/GSSLibStub.c @@ -23,6 +23,8 @@ * questions. */ +#include + #include "sun_security_jgss_wrapper_GSSLibStub.h" #include "NativeUtil.h" #include "NativeFunc.h" @@ -1188,8 +1190,8 @@ Java_sun_security_jgss_wrapper_GSSLibStub_inquireContext(JNIEnv *env, OM_uint32 time; OM_uint32 flags; int isInitiator, isEstablished; -#if defined (_WIN32) && defined (_MSC_VER) - __declspec(align(8)) +#ifdef _WIN32 + alignas(8) #endif jlong result[6]; jlongArray jresult; diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/ArrayReferenceImpl.c b/src/jdk.jdwp.agent/share/native/libjdwp/ArrayReferenceImpl.c index e200de0df002c..1516d0593fcae 100644 --- a/src/jdk.jdwp.agent/share/native/libjdwp/ArrayReferenceImpl.c +++ b/src/jdk.jdwp.agent/share/native/libjdwp/ArrayReferenceImpl.c @@ -23,6 +23,8 @@ * questions. */ +#include + #include "util.h" #include "ArrayReferenceImpl.h" #include "inStream.h" @@ -415,8 +417,8 @@ readLongComponents(JNIEnv *env, PacketInputStream *in, jarray array, int index, int length) { int i; -#if defined (_WIN32) && defined (_MSC_VER) - __declspec(align(8)) +#ifdef _WIN32 + alignas(8) #endif jlong component; @@ -446,8 +448,8 @@ readDoubleComponents(JNIEnv *env, PacketInputStream *in, jarray array, int index, int length) { int i; -#if defined (_WIN32) && defined (_MSC_VER) - __declspec(align(8)) +#ifdef _WIN32 + alignas(8) #endif jdouble component; diff --git a/src/jdk.jpackage/windows/native/common/MsiCA.h b/src/jdk.jpackage/windows/native/common/MsiCA.h index 67dfde82c9123..d2eb783cb0de0 100644 --- a/src/jdk.jpackage/windows/native/common/MsiCA.h +++ b/src/jdk.jpackage/windows/native/common/MsiCA.h @@ -238,6 +238,9 @@ class MsiLogTrigger { } // namespace msi +// For reliable macro expansion involving pragmas +#define JP_PRAGMA(str) _Pragma(#str) + // // Helpers to define CA functions. // @@ -268,7 +271,7 @@ class MsiLogTrigger { #define JP_CA_BASE(name, ca_type) \ static void name ## Body(ca_type&); \ extern "C" UINT __stdcall name(MSIHANDLE hInstall) { \ - __pragma(comment(linker, "/EXPORT:" __FUNCTION__ "=" __FUNCDNAME__)); \ + JP_PRAGMA(comment(linker, "/EXPORT:" __FUNCTION__ "=" __FUNCDNAME__)); \ const msi::MsiLogTrigger logTrigger(hInstall); \ JP_DEBUG_BREAK(JP_CA_DEBUG_BREAK, name); \ LOG_TRACE_FUNCTION(); \ @@ -287,7 +290,7 @@ class MsiLogTrigger { #define JP_CA_DECLARE(name) \ extern "C" UINT __stdcall name(MSIHANDLE); \ - __pragma(comment(linker, "/INCLUDE:" JP_CA_MANGLED_NAME(name))) + JP_PRAGMA(comment(linker, "/INCLUDE:" JP_CA_MANGLED_NAME(name))) #ifdef _WIN64 #define JP_CA_MANGLED_NAME(name) #name diff --git a/test/hotspot/gtest/utilities/test_json.cpp b/test/hotspot/gtest/utilities/test_json.cpp index 7113988adf9e1..7a54cbbb00329 100644 --- a/test/hotspot/gtest/utilities/test_json.cpp +++ b/test/hotspot/gtest/utilities/test_json.cpp @@ -36,7 +36,7 @@ class JSON_GTest : public JSON { JSON_GTest(const char* text); stringStream output; - void log(uint level, const char* format, ...) ATTRIBUTE_PRINTF(3, 4); + ATTRIBUTE_PRINTF(3, 4) void log(uint level, const char* format, ...); bool callback(JSON_TYPE t, JSON_VAL* v, uint level); JSON_TYPE prev;