/usr/include/python2.7/mx/mxQueue.h is in python-egenix-mx-base-dev 3.2.9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | #ifndef MXQUEUE_H
#define MXQUEUE_H
/*
mxQueue -- A queue implementation
Copyright (c) 1998-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
Copyright (c) 2000-2015, eGenix.com Software GmbH; mailto:info@egenix.com
See the documentation for further copyright information or contact
the author (mailto:mal@lemburg.com).
*/
/* The extension's name; must be the same as the init function's suffix */
#define MXQUEUE_MODULE "mxQueue"
/* Name of the package or module that provides the extensions C API.
If the extension is used inside a package, provide the complete
import path. */
#define MXQUEUE_API_MODULE "mx.Queue"
/* --- No servicable parts below this line ----------------------*/
/* Include generic mx extension header file */
#include "mxh.h"
/* Include Python compatibility header file */
#include "mxpyapi.h"
#ifdef MX_BUILDING_MXQUEUE
# define MXQUEUE_EXTERNALIZE MX_EXPORT
#else
# define MXQUEUE_EXTERNALIZE MX_IMPORT
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* --- Queue Object ------------------------------------------*/
typedef struct {
PyObject_HEAD
Py_ssize_t size; /* Number of items allocated */
Py_ssize_t head; /* Index of head element */
Py_ssize_t tail; /* Index of tail element */
PyObject **array; /* Pointer to the queue array */
} mxQueueObject;
/* Fast access */
#define mxQueue_GET_SIZE(v) \
((((mxQueueObject *)(v))->head - ((mxQueueObject *)(v))->tail) \
% ((mxQueueObject *)(v))->size)
#define mxQueue_EMPTY(v) \
(((((mxQueueObject *)(v))->head - ((mxQueueObject *)(v))->tail)) == 0)
/* Type checking macro */
#define mxQueue_Check(v) \
(((mxQueueObject *)(v))->ob_type == mxQueue.Queue_Type)
/* --- C API ----------------------------------------------------*/
/* C API for usage by other Python modules */
typedef struct {
/* Type object for Queue() */
PyTypeObject *Queue_Type;
/* Create a new empty queue object with at least size entries
alredy allocated. */
mxQueueObject *(*mxQueue_New)(Py_ssize_t size);
/* Push a Python object onto the queue. The reference count is increased
by one. Queues only grow, they never shrink again. */
int (*mxQueue_Push)(mxQueueObject *queue,
PyObject *v);
/* Pop an object from the queue. Ownership is passed to the caller.
Note: This doesn't cause the allocated queue size to change. */
PyObject *(*mxQueue_Pop)(mxQueueObject *queue);
/* Clear the queue. */
int (*mxQueue_Clear)(mxQueueObject *queue);
/* Get the number of entries in the queue. */
Py_ssize_t (*mxQueue_Length)(mxQueueObject *queue);
/* Create a new empty queue object from the sequence v */
mxQueueObject *(*mxQueue_FromSequence)(PyObject *v);
/* Return a the queues content as tuple. */
PyObject *(*mxQueue_AsTuple)(mxQueueObject *queue);
/* Return a the queues content as list. */
PyObject *(*mxQueue_AsList)(mxQueueObject *queue);
/* Pop the topmost n entries from the queue and return them as
tuple. If there are not enough entries only the available ones
are returned. */
PyObject *(*mxQueue_PopMany)(mxQueueObject *queue,
Py_ssize_t n);
/* Push the entries from sequence onto the queue. */
int (*mxQueue_PushMany)(mxQueueObject *queue,
PyObject *sequence);
} mxQueueModule_APIObject;
#ifndef MX_BUILDING_MXQUEUE
/* Interfacestructure to C API for other modules.
Call mxQueue_ImportModuleAPI() to initialize this
structure. After that usage is simple:
PyObject *v;
v = mxQueue.Queue_New(0);
if (!v)
goto onError;
...
*/
static
mxQueueModule_APIObject mxQueue;
/* You *must* call this before using any of the functions in
mxQueue and check its outcome; otherwise all accesses will
result in a segfault. Returns 0 on success. */
#ifndef DPRINTF
# define DPRINTF if (0) printf
#endif
static
int mxQueue_ImportModuleAndAPI(void)
{
PyObject *mod, *v = 0;
void *api;
DPRINTF("Importing the %s C API...\n",MXQUEUE_API_MODULE);
mod = PyImport_ImportModule(MXQUEUE_API_MODULE);
if (mod == NULL)
goto onError;
DPRINTF(" module found\n");
v = PyObject_GetAttrString(mod,MXQUEUE_MODULE"API");
if (v == NULL)
goto onError;
Py_CLEAR(mod);
DPRINTF(" API object found\n");
api = PyCObject_AsVoidPtr(v);
if (api == NULL)
goto onError;
Py_CLEAR(v);
memcpy(&mxQueue,api,sizeof(mxQueue));
DPRINTF(" API object initialized.\n");
return 0;
onError:
DPRINTF(" not found.\n");
Py_XDECREF(mod);
Py_XDECREF(v);
return -1;
}
#endif
/* EOF */
#ifdef __cplusplus
}
#endif
#endif
|