#define BOUNDS_CHECK(x, MIN, MAX) x = (x < MIN || MAX < x) ? MAX : x
-#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
- #define UNUSED __attribute__((unused))
-#else
- #define UNUSED
-#endif
-
/* _Py_DEC_MINALLOC >= MPD_MINALLOC */
#define _Py_DEC_MINALLOC 4
return runtime_error_ptr("internal error in " funcname)
static void
-dec_traphandler(mpd_context_t *ctx UNUSED) /* GCOV_NOT_REACHED */
+dec_traphandler(mpd_context_t *Py_UNUSED(ctx)) /* GCOV_NOT_REACHED */
{ /* GCOV_NOT_REACHED */
return; /* GCOV_NOT_REACHED */
}
static const char *INVALID_SIGNALDICT_ERROR_MSG = "invalid signal dict";
static int
-signaldict_init(PyObject *self, PyObject *args UNUSED, PyObject *kwds UNUSED)
+signaldict_init(PyObject *self,
+ PyObject *Py_UNUSED(args), PyObject *Py_UNUSED(kwds))
{
SdFlagAddr(self) = NULL;
return 0;
}
static PyObject *
-signaldict_copy(PyObject *self, PyObject *args UNUSED)
+signaldict_copy(PyObject *self, PyObject *Py_UNUSED(dummy))
{
if (SdFlagAddr(self) == NULL) {
return value_error_ptr(INVALID_SIGNALDICT_ERROR_MSG);
static PyMethodDef signaldict_methods[] = {
- { "copy", (PyCFunction)signaldict_copy, METH_NOARGS, NULL},
+ { "copy", signaldict_copy, METH_NOARGS, NULL},
{NULL, NULL}
};
/* Context Object, Part 1 */
/******************************************************************************/
-#define Dec_CONTEXT_GET_SSIZE(mem) \
-static PyObject * \
-context_get##mem(PyObject *self, void *closure UNUSED) \
-{ \
- return PyLong_FromSsize_t(mpd_get##mem(CTX(self))); \
+#define Dec_CONTEXT_GET_SSIZE(mem) \
+static PyObject * \
+context_get##mem(PyObject *self, void *Py_UNUSED(closure)) \
+{ \
+ return PyLong_FromSsize_t(mpd_get##mem(CTX(self))); \
}
-#define Dec_CONTEXT_GET_ULONG(mem) \
-static PyObject * \
-context_get##mem(PyObject *self, void *closure UNUSED) \
-{ \
- return PyLong_FromUnsignedLong(mpd_get##mem(CTX(self))); \
+#define Dec_CONTEXT_GET_ULONG(mem) \
+static PyObject * \
+context_get##mem(PyObject *self, void *Py_UNUSED(closure)) \
+{ \
+ return PyLong_FromUnsignedLong(mpd_get##mem(CTX(self))); \
}
Dec_CONTEXT_GET_SSIZE(prec)
#endif
static PyObject *
-context_getround(PyObject *self, void *closure UNUSED)
+context_getround(PyObject *self, void *Py_UNUSED(closure))
{
int i = mpd_getround(CTX(self));
decimal_state *state = get_module_state_by_def(Py_TYPE(self));
}
static PyObject *
-context_getcapitals(PyObject *self, void *closure UNUSED)
+context_getcapitals(PyObject *self, void *Py_UNUSED(closure))
{
return PyLong_FromLong(CtxCaps(self));
}
#ifdef EXTRA_FUNCTIONALITY
static PyObject *
-context_getallcr(PyObject *self, void *closure UNUSED)
+context_getallcr(PyObject *self, void *Py_UNUSED(closure))
{
return PyLong_FromLong(mpd_getcr(CTX(self)));
}
#endif
static PyObject *
-context_getetiny(PyObject *self, PyObject *dummy UNUSED)
+context_getetiny(PyObject *self, PyObject *Py_UNUSED(dummy))
{
return PyLong_FromSsize_t(mpd_etiny(CTX(self)));
}
static PyObject *
-context_getetop(PyObject *self, PyObject *dummy UNUSED)
+context_getetop(PyObject *self, PyObject *Py_UNUSED(dummy))
{
return PyLong_FromSsize_t(mpd_etop(CTX(self)));
}
static int
-context_setprec(PyObject *self, PyObject *value, void *closure UNUSED)
+context_setprec(PyObject *self, PyObject *value, void *Py_UNUSED(closure))
{
mpd_context_t *ctx;
mpd_ssize_t x;
}
static int
-context_setemin(PyObject *self, PyObject *value, void *closure UNUSED)
+context_setemin(PyObject *self, PyObject *value, void *Py_UNUSED(closure))
{
mpd_context_t *ctx;
mpd_ssize_t x;
}
static int
-context_setemax(PyObject *self, PyObject *value, void *closure UNUSED)
+context_setemax(PyObject *self, PyObject *value, void *Py_UNUSED(closure))
{
mpd_context_t *ctx;
mpd_ssize_t x;
#endif
static int
-context_setround(PyObject *self, PyObject *value, void *closure UNUSED)
+context_setround(PyObject *self, PyObject *value, void *Py_UNUSED(closure))
{
mpd_context_t *ctx;
int x;
}
static int
-context_setcapitals(PyObject *self, PyObject *value, void *closure UNUSED)
+context_setcapitals(PyObject *self, PyObject *value, void *Py_UNUSED(closure))
{
mpd_ssize_t x;
#ifdef EXTRA_FUNCTIONALITY
static int
-context_settraps(PyObject *self, PyObject *value, void *closure UNUSED)
+context_settraps(PyObject *self, PyObject *value, void *Py_UNUSED(closure))
{
mpd_context_t *ctx;
uint32_t flags;
#ifdef EXTRA_FUNCTIONALITY
static int
-context_setstatus(PyObject *self, PyObject *value, void *closure UNUSED)
+context_setstatus(PyObject *self, PyObject *value, void *Py_UNUSED(closure))
{
mpd_context_t *ctx;
uint32_t flags;
}
static int
-context_setclamp(PyObject *self, PyObject *value, void *closure UNUSED)
+context_setclamp(PyObject *self, PyObject *value, void *Py_UNUSED(closure))
{
mpd_context_t *ctx;
mpd_ssize_t x;
#ifdef EXTRA_FUNCTIONALITY
static int
-context_setallcr(PyObject *self, PyObject *value, void *closure UNUSED)
+context_setallcr(PyObject *self, PyObject *value, void *Py_UNUSED(closure))
{
mpd_context_t *ctx;
mpd_ssize_t x;
}
static PyObject *
-context_clear_traps(PyObject *self, PyObject *dummy UNUSED)
+context_clear_traps(PyObject *self, PyObject *Py_UNUSED(dummy))
{
CTX(self)->traps = 0;
Py_RETURN_NONE;
}
static PyObject *
-context_clear_flags(PyObject *self, PyObject *dummy UNUSED)
+context_clear_flags(PyObject *self, PyObject *Py_UNUSED(dummy))
{
CTX(self)->status = 0;
Py_RETURN_NONE;
};
static PyObject *
-context_new(PyTypeObject *type, PyObject *args UNUSED, PyObject *kwds UNUSED)
+context_new(PyTypeObject *type,
+ PyObject *Py_UNUSED(args), PyObject *Py_UNUSED(kwds))
{
PyDecContextObject *self = NULL;
mpd_context_t *ctx;
#endif
static PyObject *
-context_copy(PyObject *self, PyObject *args UNUSED)
+context_copy(PyObject *self, PyObject *Py_UNUSED(dummy))
{
PyObject *copy;
}
static PyObject *
-context_reduce(PyObject *self, PyObject *args UNUSED)
+context_reduce(PyObject *self, PyObject *Py_UNUSED(dummy))
{
PyObject *flags;
PyObject *traps;
}
/* ctxobj := borrowed reference to the current context */
-#define CURRENT_CONTEXT(state, ctxobj) \
- ctxobj = current_context(state); \
- if (ctxobj == NULL) { \
- return NULL; \
- }
+#define CURRENT_CONTEXT(STATE, CTXOBJ) \
+ do { \
+ CTXOBJ = current_context(STATE); \
+ if (CTXOBJ == NULL) { \
+ return NULL; \
+ } \
+ } while (0)
/* Return a new reference to the current context */
static PyObject *
-PyDec_GetCurrentContext(PyObject *self, PyObject *args UNUSED)
+PyDec_GetCurrentContext(PyObject *self, PyObject *Py_UNUSED(dummy))
{
PyObject *context;
decimal_state *state = get_module_state(self);
}
/* ctxobj := borrowed reference to the current context */
-#define CURRENT_CONTEXT(state, ctxobj) \
- ctxobj = current_context(state); \
- if (ctxobj == NULL) { \
- return NULL; \
- } \
- Py_DECREF(ctxobj);
+#define CURRENT_CONTEXT(STATE, CTXOBJ) \
+ do { \
+ CTXOBJ = current_context(STATE); \
+ if (CTXOBJ == NULL) { \
+ return NULL; \
+ } \
+ Py_DECREF(CTXOBJ); \
+ } while (0)
/* Return a new reference to the current context */
static PyObject *
-PyDec_GetCurrentContext(PyObject *self, PyObject *args UNUSED)
+PyDec_GetCurrentContext(PyObject *self, PyObject *Py_UNUSED(dummy))
{
decimal_state *state = get_module_state(self);
return current_context(state);
}
static PyObject *
-ctxmanager_set_local(PyDecContextManagerObject *self, PyObject *args UNUSED)
+ctxmanager_set_local(PyDecContextManagerObject *self,
+ PyObject *Py_UNUSED(dummy))
{
PyObject *ret;
static PyObject *
ctxmanager_restore_global(PyDecContextManagerObject *self,
- PyObject *args UNUSED)
+ PyObject *Py_UNUSED(args))
{
PyObject *ret;
/* Convert a Decimal to its exact integer ratio representation. */
static PyObject *
-dec_as_integer_ratio(PyObject *self, PyObject *args UNUSED)
+dec_as_integer_ratio(PyObject *self, PyObject *Py_UNUSED(dummy))
{
PyObject *numerator = NULL;
PyObject *denominator = NULL;
/* Return the DecimalTuple representation of a PyDecObject. */
static PyObject *
-PyDec_AsTuple(PyObject *dec, PyObject *dummy UNUSED)
+PyDec_AsTuple(PyObject *dec, PyObject *Py_UNUSED(dummy))
{
PyObject *result = NULL;
PyObject *sign = NULL;
/* Boolean function without a context arg. */
#define Dec_BoolFunc(MPDFUNC) \
static PyObject * \
-dec_##MPDFUNC(PyObject *self, PyObject *dummy UNUSED) \
+dec_##MPDFUNC(PyObject *self, PyObject *Py_UNUSED(dummy)) \
{ \
return MPDFUNC(MPD(self)) ? incr_true() : incr_false(); \
}
/* Unary functions, no context arg */
static PyObject *
-dec_mpd_adjexp(PyObject *self, PyObject *dummy UNUSED)
+dec_mpd_adjexp(PyObject *self, PyObject *Py_UNUSED(dummy))
{
mpd_ssize_t retval;
}
static PyObject *
-dec_canonical(PyObject *self, PyObject *dummy UNUSED)
+dec_canonical(PyObject *self, PyObject *Py_UNUSED(dummy))
{
return Py_NewRef(self);
}
static PyObject *
-dec_conjugate(PyObject *self, PyObject *dummy UNUSED)
+dec_conjugate(PyObject *self, PyObject *Py_UNUSED(dummy))
{
return Py_NewRef(self);
}
static PyObject *
-dec_mpd_radix(PyObject *self, PyObject *dummy UNUSED)
+dec_mpd_radix(PyObject *self, PyObject *Py_UNUSED(dummy))
{
PyObject *result;
}
static PyObject *
-dec_mpd_qcopy_abs(PyObject *self, PyObject *dummy UNUSED)
+dec_mpd_qcopy_abs(PyObject *self, PyObject *Py_UNUSED(dummy))
{
PyObject *result;
uint32_t status = 0;
}
static PyObject *
-dec_mpd_qcopy_negate(PyObject *self, PyObject *dummy UNUSED)
+dec_mpd_qcopy_negate(PyObject *self, PyObject *Py_UNUSED(dummy))
{
PyObject *result;
uint32_t status = 0;
/* __ceil__ */
static PyObject *
-dec_ceil(PyObject *self, PyObject *dummy UNUSED)
+dec_ceil(PyObject *self, PyObject *Py_UNUSED(dummy))
{
PyObject *context;
/* __complex__ */
static PyObject *
-dec_complex(PyObject *self, PyObject *dummy UNUSED)
+dec_complex(PyObject *self, PyObject *Py_UNUSED(dummy))
{
PyObject *f;
double x;
return PyComplex_FromDoubles(x, 0);
}
-/* __copy__ and __deepcopy__ */
+/* __copy__ (METH_NOARGS) and __deepcopy__ (METH_O) */
static PyObject *
-dec_copy(PyObject *self, PyObject *dummy UNUSED)
+dec_copy(PyObject *self, PyObject *Py_UNUSED(dummy))
{
return Py_NewRef(self);
}
/* __floor__ */
static PyObject *
-dec_floor(PyObject *self, PyObject *dummy UNUSED)
+dec_floor(PyObject *self, PyObject *Py_UNUSED(dummy))
{
PyObject *context;
/* __reduce__ */
static PyObject *
-dec_reduce(PyObject *self, PyObject *dummy UNUSED)
+dec_reduce(PyObject *self, PyObject *Py_UNUSED(dummy))
{
PyObject *result, *str;
/* __sizeof__ */
static PyObject *
-dec_sizeof(PyObject *v, PyObject *dummy UNUSED)
+dec_sizeof(PyObject *v, PyObject *Py_UNUSED(dummy))
{
size_t res = _PyObject_SIZE(Py_TYPE(v));
if (mpd_isdynamic_data(MPD(v))) {
/* __trunc__ */
static PyObject *
-dec_trunc(PyObject *self, PyObject *dummy UNUSED)
+dec_trunc(PyObject *self, PyObject *Py_UNUSED(dummy))
{
PyObject *context;
/* real and imag */
static PyObject *
-dec_real(PyObject *self, void *closure UNUSED)
+dec_real(PyObject *self, void *Py_UNUSED(closure))
{
return Py_NewRef(self);
}
static PyObject *
-dec_imag(PyObject *self UNUSED, void *closure UNUSED)
+dec_imag(PyObject *self, void *Py_UNUSED(closure))
{
PyObject *result;
#endif
/* Miscellaneous */
- { "__copy__", (PyCFunction)context_copy, METH_NOARGS, NULL },
+ { "__copy__", context_copy, METH_NOARGS, NULL },
{ "__reduce__", context_reduce, METH_NOARGS, NULL },
- { "copy", (PyCFunction)context_copy, METH_NOARGS, doc_ctx_copy },
+ { "copy", context_copy, METH_NOARGS, doc_ctx_copy },
{ "create_decimal", ctx_create_decimal, METH_VARARGS, doc_ctx_create_decimal },
{ "create_decimal_from_float", ctx_from_float, METH_O, doc_ctx_create_decimal_from_float },
static PyMethodDef _decimal_methods [] =
{
- { "getcontext", (PyCFunction)PyDec_GetCurrentContext, METH_NOARGS, doc_getcontext},
- { "setcontext", (PyCFunction)PyDec_SetCurrentContext, METH_O, doc_setcontext},
+ { "getcontext", PyDec_GetCurrentContext, METH_NOARGS, doc_getcontext},
+ { "setcontext", PyDec_SetCurrentContext, METH_O, doc_setcontext},
{ "localcontext", _PyCFunction_CAST(ctxmanager_new), METH_VARARGS|METH_KEYWORDS, doc_localcontext},
#ifdef EXTRA_FUNCTIONALITY
- { "IEEEContext", (PyCFunction)ieee_context, METH_O, doc_ieee_context},
+ { "IEEEContext", ieee_context, METH_O, doc_ieee_context},
#endif
{ NULL, NULL, 1, NULL }
};