extern void __cudaRegisterFatBinaryEnd(void *);

extern void *__pgi_cuda_register_fat_binaryA(void *fatCubin0, void **nv_cuda_loc);

extern void *__NV_CUDA_LOC;

#define __REGISTERFUNCNAME_CORE(X) __cudaRegisterLinkedBinary##X
#define __REGISTERFUNCNAME(X) __REGISTERFUNCNAME_CORE(X)

#define DEFINE_REGISTER_FUNC(id)                                                                \
    void __REGISTERFUNCNAME(id)(void (*callback_fp)(void **),                                   \
                                void *prelinked_fatbinc, void *foo,                             \
                                void (*dummy_ref)(void *))                                      \
    {                                                                                           \
        void *fathandle = __pgi_cuda_register_fat_binaryA(prelinked_fatbinc, &__NV_CUDA_LOC);   \
                                                                                                \
        (*callback_fp)(fathandle);                                                              \
                                                                                                \
        if (fathandle != (void *)0)                                                             \
            __cudaRegisterFatBinaryEnd(fathandle);                                              \
    }

#include REGFILE
