ext/numo/linalg/blas/blas.c in numo-linalg-0.1.1 vs ext/numo/linalg/blas/blas.c in numo-linalg-0.1.2

- old
+ new

@@ -257,16 +257,22 @@ rb_raise(rb_eRuntimeError,"CBLAS prefix is not set"); } s = alloca(strlen(blas_prefix)+strlen(name)+1); strcpy(s,blas_prefix); strcat(s,name); +#if defined(HAVE_DLFCN_H) dlerror(); +#endif *func = dlsym(blas_handle, s); - error = dlerror(); - if (error != NULL) { - rb_raise(rb_eRuntimeError, "%s", error); +#if defined(HAVE_DLFCN_H) + if ((error = dlerror()) != 0) { + func = 0; } +#endif + if ( !func ) { + rb_raise(rb_eRuntimeError, "unknown symbol \"%s\"", s); + } } } /* module definition: Numo::Linalg @@ -289,17 +295,25 @@ i = rb_scan_args(argc, argv, "11", &lib, &flag); if (i==2) { f = NUM2INT(flag); } else { - f = RTLD_LAZY | RTLD_LOCAL; + f = RTLD_LAZY; } +#if defined(HAVE_DLFCN_H) dlerror(); +#endif handle = dlopen(StringValueCStr(lib), f); - error = dlerror(); - if (error != NULL) { +#if defined(HAVE_DLFCN_H) + if ( !handle && (error = dlerror()) ) { rb_raise(rb_eRuntimeError, "%s", error); } +#else + if ( !handle ) { + error = dlerror(); + rb_raise(rb_eRuntimeError, "%s", error); + } +#endif blas_handle = handle; return Qnil; }