/* Generated by Cython 0.29.33 */

#ifndef __PYX_HAVE_API__dpctl__memory___memory
#define __PYX_HAVE_API__dpctl__memory___memory
#ifdef __MINGW64__
#define MS_WIN64
#endif
#include "Python.h"
#include "_memory.h"

static PyTypeObject *__pyx_ptype_5dpctl_6memory_7_memory__Memory = 0;
#define Py_MemoryType (*__pyx_ptype_5dpctl_6memory_7_memory__Memory)
static PyTypeObject *__pyx_ptype_5dpctl_6memory_7_memory_MemoryUSMShared = 0;
#define PyMemoryUSMSharedType (*__pyx_ptype_5dpctl_6memory_7_memory_MemoryUSMShared)
static PyTypeObject *__pyx_ptype_5dpctl_6memory_7_memory_MemoryUSMHost = 0;
#define PyMemoryUSMHostType (*__pyx_ptype_5dpctl_6memory_7_memory_MemoryUSMHost)
static PyTypeObject *__pyx_ptype_5dpctl_6memory_7_memory_MemoryUSMDevice = 0;
#define PyMemoryUSMDeviceType (*__pyx_ptype_5dpctl_6memory_7_memory_MemoryUSMDevice)

static DPCTLSyclUSMRef (*__pyx_api_f_5dpctl_6memory_7_memory_Memory_GetUsmPointer)(struct Py_MemoryObject *) = 0;
#define Memory_GetUsmPointer __pyx_api_f_5dpctl_6memory_7_memory_Memory_GetUsmPointer
static DPCTLSyclContextRef (*__pyx_api_f_5dpctl_6memory_7_memory_Memory_GetContextRef)(struct Py_MemoryObject *) = 0;
#define Memory_GetContextRef __pyx_api_f_5dpctl_6memory_7_memory_Memory_GetContextRef
static DPCTLSyclQueueRef (*__pyx_api_f_5dpctl_6memory_7_memory_Memory_GetQueueRef)(struct Py_MemoryObject *) = 0;
#define Memory_GetQueueRef __pyx_api_f_5dpctl_6memory_7_memory_Memory_GetQueueRef
static size_t (*__pyx_api_f_5dpctl_6memory_7_memory_Memory_GetNumBytes)(struct Py_MemoryObject *) = 0;
#define Memory_GetNumBytes __pyx_api_f_5dpctl_6memory_7_memory_Memory_GetNumBytes
static PyObject *(*__pyx_api_f_5dpctl_6memory_7_memory_Memory_Make)(DPCTLSyclUSMRef, size_t, DPCTLSyclQueueRef, PyObject *) = 0;
#define Memory_Make __pyx_api_f_5dpctl_6memory_7_memory_Memory_Make
#if !defined(__Pyx_PyIdentifier_FromString)
#if PY_MAJOR_VERSION < 3
  #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
#else
  #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
#endif
#endif

#ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, funcname);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C function %.200s",
                PyModule_GetName(module), funcname);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    tmp.p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, desc);
        goto bad;
    }
    tmp.p = PyCObject_AsVoidPtr(cobj);}
#endif
    *f = tmp.fp;
    if (!(*f))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

#ifndef __PYX_HAVE_RT_ImportType_proto
#define __PYX_HAVE_RT_ImportType_proto
enum __Pyx_ImportType_CheckSize {
   __Pyx_ImportType_CheckSize_Error = 0,
   __Pyx_ImportType_CheckSize_Warn = 1,
   __Pyx_ImportType_CheckSize_Ignore = 2
};
static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
#endif

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
    size_t size, enum __Pyx_ImportType_CheckSize check_size)
{
    PyObject *result = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    result = PyObject_GetAttrString(module, class_name);
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%.200s.%.200s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifndef Py_LIMITED_API
    basicsize = ((PyTypeObject *)result)->tp_basicsize;
#else
    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
    if (!py_basicsize)
        goto bad;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = 0;
    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
        goto bad;
#endif
    if ((size_t)basicsize < size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(result);
    return NULL;
}
#endif


static int import_dpctl__memory___memory(void) {
  PyObject *module = 0;
  module = PyImport_ImportModule("dpctl.memory._memory");
  if (!module) goto bad;
  if (__Pyx_ImportFunction(module, "Memory_GetUsmPointer", (void (**)(void))&__pyx_api_f_5dpctl_6memory_7_memory_Memory_GetUsmPointer, "DPCTLSyclUSMRef (struct Py_MemoryObject *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "Memory_GetContextRef", (void (**)(void))&__pyx_api_f_5dpctl_6memory_7_memory_Memory_GetContextRef, "DPCTLSyclContextRef (struct Py_MemoryObject *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "Memory_GetQueueRef", (void (**)(void))&__pyx_api_f_5dpctl_6memory_7_memory_Memory_GetQueueRef, "DPCTLSyclQueueRef (struct Py_MemoryObject *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "Memory_GetNumBytes", (void (**)(void))&__pyx_api_f_5dpctl_6memory_7_memory_Memory_GetNumBytes, "size_t (struct Py_MemoryObject *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "Memory_Make", (void (**)(void))&__pyx_api_f_5dpctl_6memory_7_memory_Memory_Make, "PyObject *(DPCTLSyclUSMRef, size_t, DPCTLSyclQueueRef, PyObject *)") < 0) goto bad;
  __pyx_ptype_5dpctl_6memory_7_memory__Memory = __Pyx_ImportType(module, "dpctl.memory._memory", "_Memory", sizeof(struct Py_MemoryObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5dpctl_6memory_7_memory__Memory) goto bad;
  __pyx_ptype_5dpctl_6memory_7_memory_MemoryUSMShared = __Pyx_ImportType(module, "dpctl.memory._memory", "MemoryUSMShared", sizeof(struct PyMemoryUSMSharedObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5dpctl_6memory_7_memory_MemoryUSMShared) goto bad;
  __pyx_ptype_5dpctl_6memory_7_memory_MemoryUSMHost = __Pyx_ImportType(module, "dpctl.memory._memory", "MemoryUSMHost", sizeof(struct PyMemoryUSMHostObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5dpctl_6memory_7_memory_MemoryUSMHost) goto bad;
  __pyx_ptype_5dpctl_6memory_7_memory_MemoryUSMDevice = __Pyx_ImportType(module, "dpctl.memory._memory", "MemoryUSMDevice", sizeof(struct PyMemoryUSMDeviceObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5dpctl_6memory_7_memory_MemoryUSMDevice) goto bad;
  Py_DECREF(module); module = 0;
  return 0;
  bad:
  Py_XDECREF(module);
  return -1;
}

#endif /* !__PYX_HAVE_API__dpctl__memory___memory */
