diff --git a/src/c_wrapper/error.h b/src/c_wrapper/error.h index 3a7ed85e07d909d28a7771050235f2c8b256dab4..5730f361c50d0442a735297c83dbbca91406cc22 100644 --- a/src/c_wrapper/error.h +++ b/src/c_wrapper/error.h @@ -21,6 +21,13 @@ #define PYOPENCL_CL_CASTABLE_THIS data() #endif +#define PYOPENCL_UNSUPPORTED(ROUTINE, VERSION) \ + auto err = (error*)malloc(sizeof(error)); \ + err->routine = strdup(#ROUTINE); \ + err->msg = strdup("unsupported in " VERSION); \ + err->code = CL_INVALID_VALUE \ + err->other = 0; \ + return err; class clerror : public std::runtime_error { private: diff --git a/src/c_wrapper/image.cpp b/src/c_wrapper/image.cpp index 427f1e344da3ebf15823974ac7c67d6cb1f4559e..12f0f563e5340e841f14aca3c91bd40ebfb6c1b7 100644 --- a/src/c_wrapper/image.cpp +++ b/src/c_wrapper/image.cpp @@ -81,21 +81,23 @@ create_image_3d(clobj_t *img, clobj_t _ctx, cl_mem_flags flags, }); } -#if PYOPENCL_CL_VERSION >= 0x1020 error* create_image_from_desc(clobj_t *img, clobj_t _ctx, cl_mem_flags flags, cl_image_format *fmt, cl_image_desc *desc, void *buf) { +#if PYOPENCL_CL_VERSION >= 0x1020 auto ctx = static_cast(_ctx); return c_handle_error([&] { auto mem = pyopencl_call_guarded(clCreateImage, ctx, flags, fmt, desc, buf); *img = new_image(mem, fmt); }); +#else + PYOPENCL_UNSUPPORTED(clCreateImage, "CL 1.1 and below") +#endif } -#endif error* image__get_image_info(clobj_t _img, cl_image_info param, generic_info *out)