Commit fc120ac3 authored by Julian Kranz's avatar Julian Kranz

.dylib

parent 10f8e641
......@@ -19,7 +19,7 @@ static char *backend_get(char *file) {
char *prefix = "libgdsl-";
size_t prefix_length = strlen(prefix);
char *suffix = ".so";
char *suffix = ".dylib";
size_t suffix_length = strlen(suffix);
if(!strncmp(file, prefix, prefix_length) && length > suffix_length
......@@ -34,7 +34,7 @@ static char *backend_get(char *file) {
}
size_t gdsl_multiplex_backends_list(char ***backends) {
char *base = getenv("GDSL_BACKENDS");
char *base = getenv("GDSL_FRONTENDS");
if(!base)
return 0;
......@@ -70,14 +70,14 @@ size_t gdsl_multiplex_backends_list(char ***backends) {
#define ADD_FUNCTION(CAT,FUNC) ADD_FUNCTION_GENERIC(CAT,FUNC,"gdsl_" #FUNC)
char gdsl_multiplex_backend_get(struct backend *backend, const char *name) {
char *base = getenv("GDSL_BACKENDS");
char *base = getenv("GDSL_FRONTENDS");
if(!base)
return GDSL_MULTIPLEX_ERROR_BACKENDS_PATH_NOT_SET;
char *lib;
size_t lib_length;
FILE *libf = open_memstream(&lib, &lib_length);
fprintf(libf, "%s/libgdsl-%s.so", base, name);
fprintf(libf, "%s/libgdsl-%s.dylib", base, name);
fputc(0, libf);
fclose(libf);
......
......@@ -22,30 +22,30 @@ public class Program {
DefaultRReilBuilder builder = new DefaultRReilBuilder();
NativeInterface n = new NativeInterface(builder);
String[] backends = n.getBackends();
String[] frontends = n.getFrontends();
if (backends.length == 0)
throw new RuntimeException("No backends available");
if (frontends.length == 0)
throw new RuntimeException("No frontends available");
int backend_ind = 0;
if (backends.length > 1) {
System.out.println("Available backends:");
for (int i = 0; i < backends.length; i++)
System.out.println("\t[" + i + "] " + backends[i]);
if (frontends.length > 1) {
System.out.println("Available frontends:");
for (int i = 0; i < frontends.length; i++)
System.out.println("\t[" + i + "] " + frontends[i]);
System.out.print("Your choice? ");
Scanner in = new Scanner(System.in);
backend_ind = in.nextInt();
if(backend_ind >= backends.length)
throw new RuntimeException("Invalid backend");
if(backend_ind >= frontends.length)
throw new RuntimeException("Invalid frontend");
}
System.out
.println("Using backend " + backends[backend_ind] + "...");
.println("Using frontend " + frontends[backend_ind] + "...");
n.useBackend(backends[backend_ind]);
n.useBackend(frontends[backend_ind]);
String line = reader.readLine();
if (line == null)
......
......@@ -33,8 +33,8 @@ public class NativeInterface {
return (IRReilCollection<IStatement>) decodeAndTranslateNative(bytes);
}
public String[] getBackends() {
return getBackendsNative();
public String[] getFrontends() {
return getFrontendsNative();
}
public void useBackend(String backend) {
......@@ -620,7 +620,7 @@ public class NativeInterface {
private native Object decodeAndTranslateNative(byte[] bytes);
private native String[] getBackendsNative();
private native String[] getFrontendsNative();
private native void useBackendNative(String backend);
......
......@@ -860,7 +860,7 @@ JNICALL Java_rnati_NativeInterface_decodeAndTranslateNative(JNIEnv *env, jobject
JNIEXPORT
jobjectArray
JNICALL Java_rnati_NativeInterface_getBackendsNative(JNIEnv *env, jobject obj) {
JNICALL Java_rnati_NativeInterface_getFrontendsNative(JNIEnv *env, jobject obj) {
char **backends;
size_t backends_length = gdsl_multiplex_backends_list(&backends);
......
......@@ -14,7 +14,7 @@ extern "C" {
*/
JNIEXPORT jobject JNICALL Java_rnati_NativeInterface_decodeAndTranslateNative(JNIEnv *, jobject, jbyteArray);
JNIEXPORT jobjectArray JNICALL Java_rnati_NativeInterface_getBackendsNative(JNIEnv *, jobject);
JNIEXPORT jobjectArray JNICALL Java_rnati_NativeInterface_getFrontendsNative(JNIEnv *, jobject);
JNIEXPORT void JNICALL Java_rnati_NativeInterface_useBackendNative(JNIEnv *, jobject, jstring);
JNIEXPORT void JNICALL Java_rnati_NativeInterface_closeBackendNative(JNIEnv *, jobject);
......
......@@ -20,11 +20,11 @@ int main(int argc, char** argv) {
size_t backend_ind = 0;
if(!backends_count) {
fprintf(stderr, "No backends available.\n");
fprintf(stderr, "No frontends available.\n");
return 1;
}
if(backends_count > 1) {
printf("Available backends:\n");
printf("Available frontends:\n");
for(size_t i = 0; i < backends_count; ++i)
printf("\t[%zu] %s\n", i, backends[i]);
printf("Your choice? ");
......@@ -32,11 +32,11 @@ int main(int argc, char** argv) {
}
if(backend_ind >= backends_count) {
fprintf(stderr, "Backend %zu is invalid.\n", backend_ind);
fprintf(stderr, "Frontend %zu is invalid.\n", backend_ind);
return 1;
}
printf("Using backend %s...\n", backends[backend_ind]);
printf("Using frontend %s...\n", backends[backend_ind]);
// __fpurge(stdin);
......@@ -45,7 +45,7 @@ int main(int argc, char** argv) {
struct backend backend;
if(gdsl_multiplex_backend_get(&backend, backends[backend_ind])) {
fprintf(stderr, "Unable to open backend.\n");
fprintf(stderr, "Unable to open frontend.\n");
return 1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment