+2018-08-07 Tom de Vries <tdevries@suse.de>
+
+ * plugin/plugin-nvptx.c (DO_PRAGMA): Define.
+ (struct cuda_lib_s): Add def/undef of CUDA_ONE_CALL_MAYBE_NULL.
+ (init_cuda_lib): Add new param to CUDA_ONE_CALL_1. Add arg to
+ corresponding call in CUDA_ONE_CALL. Add def/undef of
+ CUDA_ONE_CALL_MAYBE_NULL.
+ (CUDA_CALL_EXISTS): Define.
+
2018-08-07 Tom de Vries <tdevries@suse.de>
* plugin/plugin-nvptx.c (struct cuda_lib_s, init_cuda_lib): Put
#include <assert.h>
#include <errno.h>
+#define DO_PRAGMA(x) _Pragma (#x)
+
#if PLUGIN_NVPTX_DYNAMIC
# include <dlfcn.h>
# define CUDA_ONE_CALL(call) \
__typeof (call) *call;
+# define CUDA_ONE_CALL_MAYBE_NULL(call) \
+ CUDA_ONE_CALL (call)
#include "cuda-lib.def"
# undef CUDA_ONE_CALL
+# undef CUDA_ONE_CALL_MAYBE_NULL
} cuda_lib;
if (h == NULL)
return false;
-# define CUDA_ONE_CALL(call) CUDA_ONE_CALL_1 (call)
-# define CUDA_ONE_CALL_1(call) \
+# define CUDA_ONE_CALL(call) CUDA_ONE_CALL_1 (call, false)
+# define CUDA_ONE_CALL_MAYBE_NULL(call) CUDA_ONE_CALL_1 (call, true)
+# define CUDA_ONE_CALL_1(call, allow_null) \
cuda_lib.call = dlsym (h, #call); \
- if (cuda_lib.call == NULL) \
+ if (!allow_null && cuda_lib.call == NULL) \
return false;
#include "cuda-lib.def"
# undef CUDA_ONE_CALL
# undef CUDA_ONE_CALL_1
+# undef CUDA_ONE_CALL_MAYBE_NULL
cuda_lib_inited = true;
return true;
}
# define CUDA_CALL_PREFIX cuda_lib.
#else
+
+# define CUDA_ONE_CALL(call)
+# define CUDA_ONE_CALL_MAYBE_NULL(call) DO_PRAGMA (weak call)
+#include "cuda-lib.def"
+#undef CUDA_ONE_CALL_MAYBE_NULL
+#undef CUDA_ONE_CALL
+
# define CUDA_CALL_PREFIX
# define init_cuda_lib() true
#endif
#define CUDA_CALL_NOCHECK(FN, ...) \
CUDA_CALL_PREFIX FN (__VA_ARGS__)
+#define CUDA_CALL_EXISTS(FN) \
+ CUDA_CALL_PREFIX FN
+
static const char *
cuda_error (CUresult r)
{