8327460: Compile tests with the same visibility rules as product code

Reviewed-by: erikj, jvernee, dholmes, alanb
This commit is contained in:
Magnus Ihse Bursie 2024-03-13 08:09:22 +00:00
parent 3b18c5dc5d
commit cc9a8aba67
39 changed files with 145 additions and 235 deletions

View File

@ -56,22 +56,34 @@ define SetupTestFilesCompilationBody
$$(error There are duplicate test file names for $1: $$($1_DUPLICATED_NAMES)) $$(error There are duplicate test file names for $1: $$($1_DUPLICATED_NAMES))
endif endif
# Always include common test functionality
TEST_CFLAGS := -I$(TOPDIR)/test/lib/native
ifeq ($(TOOLCHAIN_TYPE), gcc)
TEST_CFLAGS += -fvisibility=hidden
TEST_LDFLAGS += -Wl,--exclude-libs,ALL
else ifeq ($(TOOLCHAIN_TYPE), clang)
TEST_CFLAGS += -fvisibility=hidden
else ifeq ($(TOOLCHAIN_TYPE), xlc)
TEST_CFLAGS += -qvisibility=hidden
endif
# The list to depend on starts out empty # The list to depend on starts out empty
$1 := $1 :=
ifeq ($$($1_TYPE), LIBRARY) ifeq ($$($1_TYPE), LIBRARY)
$1_PREFIX = lib $1_PREFIX = lib
$1_OUTPUT_SUBDIR := lib $1_OUTPUT_SUBDIR := lib
$1_BASE_CFLAGS := $(CFLAGS_JDKLIB) $1_BASE_CFLAGS := $(CFLAGS_JDKLIB) $$(TEST_CFLAGS)
$1_BASE_CXXFLAGS := $(CXXFLAGS_JDKLIB) $1_BASE_CXXFLAGS := $(CXXFLAGS_JDKLIB) $$(TEST_CFLAGS)
$1_LDFLAGS := $(LDFLAGS_JDKLIB) $$(call SET_SHARED_LIBRARY_ORIGIN) $1_LDFLAGS := $(LDFLAGS_JDKLIB) $$(TEST_LDFLAGS) $$(call SET_SHARED_LIBRARY_ORIGIN)
$1_COMPILATION_TYPE := LIBRARY $1_COMPILATION_TYPE := LIBRARY
$1_LOG_TYPE := library $1_LOG_TYPE := library
else ifeq ($$($1_TYPE), PROGRAM) else ifeq ($$($1_TYPE), PROGRAM)
$1_PREFIX = exe $1_PREFIX = exe
$1_OUTPUT_SUBDIR := bin $1_OUTPUT_SUBDIR := bin
$1_BASE_CFLAGS := $(CFLAGS_JDKEXE) $1_BASE_CFLAGS := $(CFLAGS_JDKEXE) $$(TEST_CFLAGS)
$1_BASE_CXXFLAGS := $(CXXFLAGS_JDKEXE) $1_BASE_CXXFLAGS := $(CXXFLAGS_JDKEXE) $$(TEST_CFLAGS)
$1_LDFLAGS := $(LDFLAGS_JDKEXE) $(LDFLAGS_TESTEXE) $1_LDFLAGS := $(LDFLAGS_JDKEXE) $$(TEST_LDFLAGS) $(LDFLAGS_TESTEXE)
$1_COMPILATION_TYPE := EXECUTABLE $1_COMPILATION_TYPE := EXECUTABLE
$1_LOG_TYPE := executable $1_LOG_TYPE := executable
else else

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
@ -53,8 +53,6 @@ BUILD_JDK_JTREG_EXECUTABLES_CFLAGS_exeJliLaunchTest := \
-I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjli \ -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjli \
-I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libjli -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libjli
TEST_LIB_NATIVE_SRC := $(TOPDIR)/test/lib/native
# Platform specific setup # Platform specific setup
ifeq ($(call isTargetOs, windows), true) ifeq ($(call isTargetOs, windows), true)
BUILD_JDK_JTREG_EXCLUDE += libDirectIO.c libInheritedChannel.c \ BUILD_JDK_JTREG_EXCLUDE += libDirectIO.c libInheritedChannel.c \
@ -69,14 +67,6 @@ ifeq ($(call isTargetOs, windows), true)
BUILD_JDK_JTREG_EXECUTABLES_LIBS_exeNullCallerTest := $(LIBCXX) jvm.lib BUILD_JDK_JTREG_EXECUTABLES_LIBS_exeNullCallerTest := $(LIBCXX) jvm.lib
BUILD_JDK_JTREG_EXECUTABLES_LIBS_exerevokeall := advapi32.lib BUILD_JDK_JTREG_EXECUTABLES_LIBS_exerevokeall := advapi32.lib
BUILD_JDK_JTREG_EXECUTABLES_CFLAGS_exeNullCallerTest := /EHsc BUILD_JDK_JTREG_EXECUTABLES_CFLAGS_exeNullCallerTest := /EHsc
# java.lang.foreign tests
BUILD_JDK_JTREG_LIBRARIES_CFLAGS_libAsyncStackWalk := -I$(TEST_LIB_NATIVE_SRC)
BUILD_JDK_JTREG_LIBRARIES_CFLAGS_libLinkerInvokerUnnamed := -I$(TEST_LIB_NATIVE_SRC)
BUILD_JDK_JTREG_LIBRARIES_CFLAGS_libLinkerInvokerModule := -I$(TEST_LIB_NATIVE_SRC)
BUILD_JDK_JTREG_LIBRARIES_CFLAGS_libLoaderLookupInvoker := -I$(TEST_LIB_NATIVE_SRC)
BUILD_JDK_JTREG_LIBRARIES_CFLAGS_libAsyncInvokers := -I$(TEST_LIB_NATIVE_SRC)
BUILD_JDK_JTREG_LIBRARIES_LIBS_libTracePinnedThreads := jvm.lib BUILD_JDK_JTREG_LIBRARIES_LIBS_libTracePinnedThreads := jvm.lib
BUILD_JDK_JTREG_LIBRARIES_LIBS_libNewDirectByteBuffer := $(WIN_LIB_JAVA) BUILD_JDK_JTREG_LIBRARIES_LIBS_libNewDirectByteBuffer := $(WIN_LIB_JAVA)
BUILD_JDK_JTREG_LIBRARIES_LIBS_libGetXSpace := $(WIN_LIB_JAVA) BUILD_JDK_JTREG_LIBRARIES_LIBS_libGetXSpace := $(WIN_LIB_JAVA)
@ -88,15 +78,10 @@ else
BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libNativeThread := -pthread BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libNativeThread := -pthread
# java.lang.foreign tests # java.lang.foreign tests
BUILD_JDK_JTREG_LIBRARIES_CFLAGS_libAsyncStackWalk := -I$(TEST_LIB_NATIVE_SRC)
BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libAsyncStackWalk := -pthread BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libAsyncStackWalk := -pthread
BUILD_JDK_JTREG_LIBRARIES_CFLAGS_libAsyncInvokers := -I$(TEST_LIB_NATIVE_SRC)
BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libAsyncInvokers := -pthread BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libAsyncInvokers := -pthread
BUILD_JDK_JTREG_LIBRARIES_CFLAGS_libLinkerInvokerUnnamed := -I$(TEST_LIB_NATIVE_SRC)
BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libLinkerInvokerUnnamed := -pthread BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libLinkerInvokerUnnamed := -pthread
BUILD_JDK_JTREG_LIBRARIES_CFLAGS_libLinkerInvokerModule := -I$(TEST_LIB_NATIVE_SRC)
BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libLinkerInvokerModule := -pthread BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libLinkerInvokerModule := -pthread
BUILD_JDK_JTREG_LIBRARIES_CFLAGS_libLoaderLookupInvoker := -I$(TEST_LIB_NATIVE_SRC)
BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libLoaderLookupInvoker := -pthread BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libLoaderLookupInvoker := -pthread
BUILD_JDK_JTREG_LIBRARIES_LIBS_libExplicitAttach := -ljvm BUILD_JDK_JTREG_LIBRARIES_LIBS_libExplicitAttach := -ljvm

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,13 +23,14 @@
* questions. * questions.
*/ */
#include "AppLauncher.h"
#include "app.h" #include "app.h"
#include "AppLauncher.h"
#include "ErrorHandling.h"
#include "FileUtils.h" #include "FileUtils.h"
#include "jni.h"
#include "JvmLauncher.h"
#include "PackageFile.h" #include "PackageFile.h"
#include "UnixSysInfo.h" #include "UnixSysInfo.h"
#include "JvmLauncher.h"
#include "ErrorHandling.h"
namespace { namespace {
@ -89,7 +90,7 @@ void initJvmLauncher() {
} // namespace } // namespace
int main(int argc, char *argv[]) { JNIEXPORT int main(int argc, char *argv[]) {
if (jvmLauncher) { if (jvmLauncher) {
// This is the call from the thread spawned by JVM. // This is the call from the thread spawned by JVM.
// Skip initialization phase as we have done this already in the first // Skip initialization phase as we have done this already in the first

View File

@ -21,11 +21,7 @@
* questions. * questions.
*/ */
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT int foo() { EXPORT int foo() {
return 0; return 0;

View File

@ -125,7 +125,7 @@ public class TestDwarf {
new DwarfConstraint(1, "Java_TestDwarf_crashNativeMultipleMethods", "libTestDwarf.c", 70)); new DwarfConstraint(1, "Java_TestDwarf_crashNativeMultipleMethods", "libTestDwarf.c", 70));
} }
runAndCheck(new Flags(TestDwarf.class.getCanonicalName(), "nativeDereferenceNull"), runAndCheck(new Flags(TestDwarf.class.getCanonicalName(), "nativeDereferenceNull"),
new DwarfConstraint(0, "dereference_null", "libTestDwarfHelper.h", 44)); new DwarfConstraint(0, "dereference_null", "libTestDwarfHelper.h", 46));
} }
// The full pattern accepts lines like: // The full pattern accepts lines like:

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,9 +21,11 @@
* questions. * questions.
*/ */
#include "jni.h"
#include <stdio.h> #include <stdio.h>
#include "export.h"
#include "jni.h"
void unused1() { void unused1() {
} }
@ -39,7 +41,7 @@ void unused4() {
void unused5() { void unused5() {
} }
void dereference_null() { EXPORT void dereference_null() {
int* x = (int*)0; int* x = (int*)0;
*x = 34; // Crash *x = 34; // Crash
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -213,11 +213,7 @@ public class CallGeneratorHelper extends NativeTestHelper {
static void generateDowncalls(boolean header) { static void generateDowncalls(boolean header) {
if (header) { if (header) {
System.out.println( System.out.println(
"#ifdef _WIN64\n" + "#include \"export.h\"\n"
"#define EXPORT __declspec(dllexport)\n" +
"#else\n" +
"#define EXPORT\n" +
"#endif\n"
); );
for (int j = 1; j <= MAX_FIELDS; j++) { for (int j = 1; j <= MAX_FIELDS; j++) {
@ -267,11 +263,7 @@ public class CallGeneratorHelper extends NativeTestHelper {
static void generateUpcalls(boolean header) { static void generateUpcalls(boolean header) {
if (header) { if (header) {
System.out.println( System.out.println(
"#ifdef _WIN64\n" + "#include \"export.h\"\n"
"#define EXPORT __declspec(dllexport)\n" +
"#else\n" +
"#define EXPORT\n" +
"#endif\n"
); );
for (int j = 1; j <= MAX_FIELDS; j++) { for (int j = 1; j <= MAX_FIELDS; j++) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,11 +21,7 @@
* questions. * questions.
*/ */
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
struct S1 { char f0[1]; }; struct S1 { char f0[1]; };
struct S2 { char f0[2]; }; struct S2 { char f0[2]; };

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,11 +23,7 @@
#include <errno.h> #include <errno.h>
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT void set_errno_V(int value) { EXPORT void set_errno_V(int value) {
errno = value; errno = value;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,11 +23,7 @@
#include <errno.h> #include <errno.h>
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT void empty() {} EXPORT void empty() {}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,10 +21,6 @@
* questions. * questions.
*/ */
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT void test_ptr(void* ptr) {} EXPORT void test_ptr(void* ptr) {}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,11 +22,7 @@
* *
*/ */
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT void* get_addr(void* align) { EXPORT void* get_addr(void* align) {
return align; return align;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,11 +24,7 @@
#include <stdbool.h> #include <stdbool.h>
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT void empty() { EXPORT void empty() {
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,11 +21,7 @@
* questions. * questions.
*/ */
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
int count = 0; int count = 0;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,12 +21,7 @@
* questions. * questions.
*/ */
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT void f() { }
EXPORT int c = 42;
EXPORT void f() { }
EXPORT int c = 42;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,12 +21,8 @@
* questions. * questions.
*/ */
#ifdef _WIN64
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
#include <stddef.h> #include <stddef.h>
#include "export.h"
EXPORT void* get_null() { return NULL; } EXPORT void* get_null() { return NULL; }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,11 +21,7 @@
* questions. * questions.
*/ */
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
struct Point { struct Point {
int x; int x;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,11 +21,7 @@
* questions. * questions.
*/ */
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
struct S_PDI { void* p0; double p1; int p2; }; struct S_PDI { void* p0; double p1; int p2; };

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,11 +21,7 @@
* questions. * questions.
*/ */
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
struct S_PDI { void* p0; double p1; int p2; }; struct S_PDI { void* p0; double p1; int p2; };

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,11 +23,7 @@
#include <stdio.h> #include <stdio.h>
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT void foo(void) { EXPORT void foo(void) {
// do nothing // do nothing

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,11 +21,8 @@
* questions. * questions.
*/ */
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
#ifdef _AIX #ifdef _AIX
#pragma align (natural) #pragma align (natural)
#endif #endif

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,11 +21,7 @@
* questions. * questions.
*/ */
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
// we use 'int' here to make sure the native code doesn't touch any of the bits // we use 'int' here to make sure the native code doesn't touch any of the bits
// the important part is that our Java code performs argument normalization // the important part is that our Java code performs argument normalization

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,11 +21,7 @@
* questions. * questions.
*/ */
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT void test_args(void* ptr) {} EXPORT void test_args(void* ptr) {}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,6 +21,8 @@
* questions. * questions.
*/ */
#include "export.h"
#ifdef __clang__ #ifdef __clang__
#pragma clang optimize off #pragma clang optimize off
#elif defined __GNUC__ #elif defined __GNUC__
@ -29,11 +31,6 @@
#pragma optimize( "", off ) #pragma optimize( "", off )
#endif #endif
#ifdef _WIN64
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
#ifdef _AIX #ifdef _AIX
#pragma align (natural) #pragma align (natural)
#endif #endif

View File

@ -21,14 +21,9 @@
* questions. * questions.
*/ */
#include "export.h"
#include "testlib_threads.hpp" #include "testlib_threads.hpp"
#ifdef _WIN64
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
typedef void (*CB_t)(void); typedef void (*CB_t)(void);
static void start(void* ctxt) { static void start(void* ctxt) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,11 +21,7 @@
* questions. * questions.
*/ */
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT void do_recurse(int depth, void (*cb)(int, void*)) { EXPORT void do_recurse(int depth, void (*cb)(int, void*)) {
cb(depth, cb); cb(depth, cb);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,11 +21,7 @@
* questions. * questions.
*/ */
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT void foo(void (*cb)(void)) { EXPORT void foo(void (*cb)(void)) {
cb(); cb();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,11 +21,7 @@
* questions. * questions.
*/ */
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT void foo(void (*cb)(int, int, int, int), int a0, int a1, int a2, int a3) { EXPORT void foo(void (*cb)(int, int, int, int), int a0, int a1, int a2, int a3) {
cb(a0, a1, a2, a3); cb(a0, a1, a2, a3);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,11 +22,7 @@
* *
*/ */
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT int funcA() { EXPORT int funcA() {
return 1; return 1;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -20,15 +20,18 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
#include <stdio.h>
#include <pthread.h> #include <pthread.h>
#include <stdio.h>
#include "export.h"
#define STACK_SIZE 0x100000 #define STACK_SIZE 0x100000
/** /**
* Creates n threads to execute the given function. * Creates n threads to execute the given function.
*/ */
void start_threads(int n, void *(*f)(void *)) { EXPORT void start_threads(int n, void *(*f)(void *)) {
pthread_t tid; pthread_t tid;
pthread_attr_t attr; pthread_attr_t attr;
int i; int i;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,9 +28,10 @@
* tools. The rest of the files will be linked in. * tools. The rest of the files will be linked in.
*/ */
#include "export.h"
#include "java.h" #include "java.h"
int EXPORT int
main(int argc, char **args) main(int argc, char **args)
{ {
//avoid null-terminated array of arguments to test JDK-8303669 //avoid null-terminated array of arguments to test JDK-8303669

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,11 +23,7 @@
#include <stdio.h> #include <stdio.h>
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
/* /*
* Call a function with the given function pointer. * Call a function with the given function pointer.

35
test/lib/native/export.h Normal file
View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#ifndef TEST_LIB_NATIVE_EXPORT_H
#define TEST_LIB_NATIVE_EXPORT_H
#ifdef _WIN64
#define EXPORT __declspec(dllexport)
#elif defined(__GNUC__)
#define EXPORT __attribute__((visibility("default")))
#else
#define EXPORT
#endif
#endif // TEST_LIB_NATIVE_EXPORT_H

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,11 +21,7 @@
* questions. * questions.
*/ */
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT void func() {} EXPORT void func() {}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,11 +21,7 @@
* questions. * questions.
*/ */
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT int sum_ints(int* arr, int size) { EXPORT int sum_ints(int* arr, int size) {
int sum = 0; int sum = 0;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,14 +21,10 @@
* questions. * questions.
*/ */
#ifdef _WIN64
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
#include <stddef.h> #include <stddef.h>
#include "export.h"
EXPORT long long id_long_long(long long value) { EXPORT long long id_long_long(long long value) {
return value; return value;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,12 +21,7 @@
* questions. * questions.
*/ */
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT int compar(const void* e0, const void* e1) { EXPORT int compar(const void* e0, const void* e1) {
int i0 = *((int*) e0); int i0 = *((int*) e0);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,11 +21,7 @@
* questions. * questions.
*/ */
#ifdef _WIN64 #include "export.h"
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT void blank(void (*cb)(void)) { EXPORT void blank(void (*cb)(void)) {
cb(); cb();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -20,17 +20,13 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
#include <stdlib.h>
#include <math.h> #include <math.h>
#include <stdlib.h>
#include "export.h"
#include "points.h" #include "points.h"
#ifdef _WIN64
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT double distance(Point p1, Point p2) { EXPORT double distance(Point p1, Point p2) {
int xDist = abs(p1.x - p2.x); int xDist = abs(p1.x - p2.x);
int yDist = abs(p1.y - p2.y); int yDist = abs(p1.y - p2.y);