@Override public void afterRegistration(AfterRegistrationAccess access) { /** * Search for headers in a directory, relative to the current working directory, that * contains the Substrate VM projects. Using the "../substratevm*" relative path * accounts for running SVM from sibling suites. */ HeaderResolversRegistry.registerAdditionalResolver(new FallbackHeaderResolver("../../graal/substratevm/src")); } }
/** * Same as {@link #createBytes(IntSupplier)}, and additionally creates a symbol with the * provided name for the allocated bytes. */ public static <T extends PointerBase> CGlobalData<T> createBytes(IntSupplier sizeSupplier, String symbolName) { return new CGlobalDataImpl<>(symbolName, sizeSupplier); }
/** * Create a chunk of zero-initialized bytes with at least the length that is provided by the * specified supplier. */ public static <T extends PointerBase> CGlobalData<T> createBytes(IntSupplier sizeSupplier) { return createBytes(sizeSupplier, null); }
static void leave() { int code = CEntryPointActions.leave(); if (code != 0) { CEntryPointActions.failFatally(code, errorMessage.get()); } } }
static void leave() { int code = CEntryPointActions.leaveDetachThread(); if (code != 0) { CEntryPointActions.failFatally(code, errorMessage.get()); } } }
static void leave() { int code = CEntryPointActions.leaveTearDownIsolate(); if (code != 0) { CEntryPointActions.failFatally(code, errorMessage.get()); } } }
/** * Same as {@link #createWord()}, and additionally creates a symbol with the provided name for * the allocated word. */ public static <T extends PointerBase> CGlobalData<T> createWord(String symbolName) { return new CGlobalDataImpl<>(symbolName, () -> ConfigurationValues.getTarget().wordSize); }
/** * Create a single word that is initialized to zero. */ public static <T extends PointerBase> CGlobalData<T> createWord() { return createWord((String) null); }
@Override public CCharPointerHolder toCString(CharSequence javaString) { if (javaString == null) { return NULL_HOLDER; } return new CCharPointerHolderImpl(javaString); }
/** * Create a chunk of data that is dimensioned and initialized to contain the provided string's * contents as {@linkplain Utf8#stringToUtf8(String, boolean) zero-terminated modified UTF-8}. */ public static <T extends PointerBase> CGlobalData<T> createCString(String content) { return createCString(content, null); }
public static List<String> read(ClassLoader imageClassloader, String preambleResource) { return getResource(imageClassloader, preambleResource); }
public static PointerBase unbox(BoxedPointer boxed) { return boxed.getPointer(); }
@Override public List<String> getHeaderFiles() { return Collections.singletonList(ProjectHeaderFile.resolve("com.oracle.svm.native.libchelper", "include/cpufeatures.h")); } }
@Override public void afterRegistration(AfterRegistrationAccess access) { ImageSingletons.add(HeaderResolversRegistry.class, new HeaderResolversRegistry()); } }
/** * Resolves the path to a C header file that is located in a Substrate VM project. */ public static String resolve(String projectName, String headerFile) { HeaderResolversRegistry resolvers = ImageSingletons.lookup(HeaderResolversRegistry.class); return resolvers.resolve(projectName, headerFile); }
@Override public void afterRegistration(AfterRegistrationAccess access) { ImageSingletons.add(CTypeConversionSupport.class, new CTypeConversionSupportImpl()); } }
/** * Create a reference to the symbol with the specified name. Calling {@link CGlobalData#get()} * on the returned object at runtime returns the referenced symbol's address. */ public static <T extends PointerBase> CGlobalData<T> forSymbol(String symbolName) { return new CGlobalDataImpl<>(symbolName); }
/** * Create a chunk of bytes that is dimensioned and initialized to contain the bytes provided by * the specified supplier. */ public static <T extends PointerBase> CGlobalData<T> createBytes(Supplier<byte[]> contentSupplier) { return createBytes(contentSupplier, null); }
/** * Create a single word that is initialized to the specified value. */ public static <T extends PointerBase> CGlobalData<T> createWord(WordBase initialValue) { return createWord(initialValue, null); }
/** * Same as {@link #createBytes(Supplier)}, and additionally creates a symbol with the provided * name for the allocated bytes. */ public static <T extends PointerBase> CGlobalData<T> createBytes(Supplier<byte[]> contentSupplier, String symbolName) { return new CGlobalDataImpl<>(symbolName, contentSupplier); }