mirror of
https://github.com/python/cpython
synced 2026-09-29 09:55:31 +03:00
Reuse Py_MIN and Py_MAX macros: remove duplicate MIN/MAX macros
multiprocessing.h: remove unused MIN and MAX macros
This commit is contained in:
parent
e0b99ba140
commit
640c35ce13
9 changed files with 25 additions and 66 deletions
|
|
@ -9,11 +9,6 @@
|
|||
#include <ctype.h>
|
||||
#include <float.h>
|
||||
|
||||
#undef MAX
|
||||
#undef MIN
|
||||
#define MAX(x, y) ((x) < (y) ? (y) : (x))
|
||||
#define MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||
|
||||
|
||||
/* Special free list
|
||||
free_list is a singly-linked list of available PyFloatObjects, linked
|
||||
|
|
@ -1131,7 +1126,7 @@ float_hex(PyObject *v)
|
|||
}
|
||||
|
||||
m = frexp(fabs(x), &e);
|
||||
shift = 1 - MAX(DBL_MIN_EXP - e, 0);
|
||||
shift = 1 - Py_MAX(DBL_MIN_EXP - e, 0);
|
||||
m = ldexp(m, shift);
|
||||
e -= shift;
|
||||
|
||||
|
|
@ -1285,8 +1280,8 @@ float_fromhex(PyObject *cls, PyObject *arg)
|
|||
fdigits = coeff_end - s_store;
|
||||
if (ndigits == 0)
|
||||
goto parse_error;
|
||||
if (ndigits > MIN(DBL_MIN_EXP - DBL_MANT_DIG - LONG_MIN/2,
|
||||
LONG_MAX/2 + 1 - DBL_MAX_EXP)/4)
|
||||
if (ndigits > Py_MIN(DBL_MIN_EXP - DBL_MANT_DIG - LONG_MIN/2,
|
||||
LONG_MAX/2 + 1 - DBL_MAX_EXP)/4)
|
||||
goto insane_length_error;
|
||||
|
||||
/* [p <exponent>] */
|
||||
|
|
@ -1342,7 +1337,7 @@ float_fromhex(PyObject *cls, PyObject *arg)
|
|||
|
||||
/* lsb = exponent of least significant bit of the *rounded* value.
|
||||
This is top_exp - DBL_MANT_DIG unless result is subnormal. */
|
||||
lsb = MAX(top_exp, (long)DBL_MIN_EXP) - DBL_MANT_DIG;
|
||||
lsb = Py_MAX(top_exp, (long)DBL_MIN_EXP) - DBL_MANT_DIG;
|
||||
|
||||
x = 0.0;
|
||||
if (exp >= lsb) {
|
||||
|
|
|
|||
|
|
@ -7,11 +7,6 @@
|
|||
#include "opcode.h"
|
||||
#include "structmember.h"
|
||||
|
||||
#undef MIN
|
||||
#undef MAX
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
#define OFF(x) offsetof(PyFrameObject, x)
|
||||
|
||||
static PyMemberDef frame_memberlist[] = {
|
||||
|
|
@ -160,8 +155,8 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
|
|||
|
||||
/* We're now ready to look at the bytecode. */
|
||||
PyBytes_AsStringAndSize(f->f_code->co_code, (char **)&code, &code_len);
|
||||
min_addr = MIN(new_lasti, f->f_lasti);
|
||||
max_addr = MAX(new_lasti, f->f_lasti);
|
||||
min_addr = Py_MIN(new_lasti, f->f_lasti);
|
||||
max_addr = Py_MAX(new_lasti, f->f_lasti);
|
||||
|
||||
/* You can't jump onto a line with an 'except' statement on it -
|
||||
* they expect to have an exception on the top of the stack, which
|
||||
|
|
@ -293,7 +288,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
|
|||
break;
|
||||
}
|
||||
|
||||
min_delta_iblock = MIN(min_delta_iblock, delta_iblock);
|
||||
min_delta_iblock = Py_MIN(min_delta_iblock, delta_iblock);
|
||||
|
||||
if (op >= HAVE_ARGUMENT) {
|
||||
addr += 2;
|
||||
|
|
|
|||
|
|
@ -89,11 +89,6 @@ maybe_small_long(PyLongObject *v)
|
|||
*/
|
||||
#define FIVEARY_CUTOFF 8
|
||||
|
||||
#undef MIN
|
||||
#undef MAX
|
||||
#define MAX(x, y) ((x) < (y) ? (y) : (x))
|
||||
#define MIN(x, y) ((x) > (y) ? (y) : (x))
|
||||
|
||||
#define SIGCHECK(PyTryBlock) \
|
||||
do { \
|
||||
if (PyErr_CheckSignals()) PyTryBlock \
|
||||
|
|
@ -3029,7 +3024,7 @@ kmul_split(PyLongObject *n,
|
|||
Py_ssize_t size_lo, size_hi;
|
||||
const Py_ssize_t size_n = ABS(Py_SIZE(n));
|
||||
|
||||
size_lo = MIN(size_n, size);
|
||||
size_lo = Py_MIN(size_n, size);
|
||||
size_hi = size_n - size_lo;
|
||||
|
||||
if ((hi = _PyLong_New(size_hi)) == NULL)
|
||||
|
|
@ -3300,7 +3295,7 @@ k_lopsided_mul(PyLongObject *a, PyLongObject *b)
|
|||
nbdone = 0;
|
||||
while (bsize > 0) {
|
||||
PyLongObject *product;
|
||||
const Py_ssize_t nbtouse = MIN(bsize, asize);
|
||||
const Py_ssize_t nbtouse = Py_MIN(bsize, asize);
|
||||
|
||||
/* Multiply the next slice of b by a. */
|
||||
memcpy(bslice->ob_digit, b->ob_digit + nbdone,
|
||||
|
|
@ -3591,7 +3586,7 @@ long_true_divide(PyObject *v, PyObject *w)
|
|||
goto underflow_or_zero;
|
||||
|
||||
/* Choose value for shift; see comments for step 1 above. */
|
||||
shift = MAX(diff, DBL_MIN_EXP) - DBL_MANT_DIG - 2;
|
||||
shift = Py_MAX(diff, DBL_MIN_EXP) - DBL_MANT_DIG - 2;
|
||||
|
||||
inexact = 0;
|
||||
|
||||
|
|
@ -3662,7 +3657,7 @@ long_true_divide(PyObject *v, PyObject *w)
|
|||
x_bits = (x_size-1)*PyLong_SHIFT+bits_in_digit(x->ob_digit[x_size-1]);
|
||||
|
||||
/* The number of extra bits that have to be rounded away. */
|
||||
extra_bits = MAX(x_bits, DBL_MIN_EXP - shift) - DBL_MANT_DIG;
|
||||
extra_bits = Py_MAX(x_bits, DBL_MIN_EXP - shift) - DBL_MANT_DIG;
|
||||
assert(extra_bits == 2 || extra_bits == 3);
|
||||
|
||||
/* Round by directly modifying the low digit of x. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue