rb_fiddle_handle_close(VALUE self)
{
    struct dl_handle *fiddle_handle;

    TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);
    if(fiddle_handle->open) {
	int ret = dlclose(fiddle_handle->ptr);
	fiddle_handle->open = 0;

	/* Check dlclose for successful return value */
	if(ret) {
#if defined(HAVE_DLERROR)
	    rb_raise(rb_eFiddleError, "%s", dlerror());
#else
	    rb_raise(rb_eFiddleError, "could not close handle");
#endif
	}
	return INT2NUM(ret);
    }
    rb_raise(rb_eFiddleError, "dlclose() called too many times");

    UNREACHABLE;
}
rb_fiddle_handle_close(VALUE self)
{
    struct dl_handle *fiddle_handle;

    TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);
    if(fiddle_handle->open) {
	int ret = dlclose(fiddle_handle->ptr);
	fiddle_handle->open = 0;

	 
	if(ret) {
#if defined(HAVE_DLERROR)
	    rb_raise(rb_eFiddleError, "%s", dlerror());
#else
	    rb_raise(rb_eFiddleError, "could not close handle");
#endif
	}
	return INT2NUM(ret);
    }
    rb_raise(rb_eFiddleError, "dlclose() called too many times");

    UNREACHABLE;
}