Commit 4c3e7459 authored by Jim Fulton's avatar Jim Fulton

Rewrote a macro and it's calls to avoid confusing optimizing

compilers.
parent 57145891
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
****************************************************************************/ ****************************************************************************/
#define BTREETEMPLATE_C "$Id: BTreeTemplate.c,v 1.12 2001/03/20 13:52:00 jim Exp $\n" #define BTREETEMPLATE_C "$Id: BTreeTemplate.c,v 1.13 2001/03/21 14:16:58 jim Exp $\n"
/* /*
** _BTree_get ** _BTree_get
...@@ -96,7 +96,7 @@ _BTree_get(BTree *self, PyObject *keyarg, int has_key) ...@@ -96,7 +96,7 @@ _BTree_get(BTree *self, PyObject *keyarg, int has_key)
PyObject *r; PyObject *r;
KEY_TYPE key; KEY_TYPE key;
COPY_KEY_FROM_ARG(key, keyarg, &copied); COPY_KEY_FROM_ARG(key, keyarg, copied);
UNLESS (copied) return NULL; UNLESS (copied) return NULL;
PER_USE_OR_RETURN(self, NULL); PER_USE_OR_RETURN(self, NULL);
...@@ -409,7 +409,7 @@ _BTree_set(BTree *self, PyObject *keyarg, PyObject *value, ...@@ -409,7 +409,7 @@ _BTree_set(BTree *self, PyObject *keyarg, PyObject *value,
BTreeItem *d; BTreeItem *d;
KEY_TYPE key; KEY_TYPE key;
COPY_KEY_FROM_ARG(key, keyarg, &copied); COPY_KEY_FROM_ARG(key, keyarg, copied);
UNLESS (copied) return -1; UNLESS (copied) return -1;
PER_USE_OR_RETURN(self, -1); PER_USE_OR_RETURN(self, -1);
...@@ -754,7 +754,7 @@ _BTree_setstate(BTree *self, PyObject *state, int noval) ...@@ -754,7 +754,7 @@ _BTree_setstate(BTree *self, PyObject *state, int noval)
{ {
if (i) if (i)
{ {
COPY_KEY_FROM_ARG(d->key, PyTuple_GET_ITEM(items,l), &copied); COPY_KEY_FROM_ARG(d->key, PyTuple_GET_ITEM(items,l), copied);
l++; l++;
UNLESS (&copied) return -1; UNLESS (&copied) return -1;
INCREF_KEY(d->key); INCREF_KEY(d->key);
...@@ -873,7 +873,7 @@ BTree_findRangeEnd(BTree *self, PyObject *keyarg, int low, ...@@ -873,7 +873,7 @@ BTree_findRangeEnd(BTree *self, PyObject *keyarg, int low,
int min, max, i=0, cmp, copied=1; int min, max, i=0, cmp, copied=1;
KEY_TYPE key; KEY_TYPE key;
COPY_KEY_FROM_ARG(key, keyarg, &copied); COPY_KEY_FROM_ARG(key, keyarg, copied);
UNLESS (copied) return -1; UNLESS (copied) return -1;
/* We don't need to: PER_USE_OR_RETURN(self, -1); /* We don't need to: PER_USE_OR_RETURN(self, -1);
...@@ -1124,7 +1124,7 @@ BTree_byValue(BTree *self, PyObject *args) ...@@ -1124,7 +1124,7 @@ BTree_byValue(BTree *self, PyObject *args)
PER_USE_OR_RETURN(self, NULL); PER_USE_OR_RETURN(self, NULL);
UNLESS (PyArg_ParseTuple(args, "O", &omin)) return NULL; UNLESS (PyArg_ParseTuple(args, "O", &omin)) return NULL;
COPY_VALUE_FROM_ARG(min, omin, &copied); COPY_VALUE_FROM_ARG(min, omin, copied);
UNLESS(copied) return NULL; UNLESS(copied) return NULL;
UNLESS (r=PyList_New(0)) goto err; UNLESS (r=PyList_New(0)) goto err;
......
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
****************************************************************************/ ****************************************************************************/
#define BUCKETTEMPLATE_C "$Id: BucketTemplate.c,v 1.9 2001/03/20 13:52:00 jim Exp $\n" #define BUCKETTEMPLATE_C "$Id: BucketTemplate.c,v 1.10 2001/03/21 14:16:58 jim Exp $\n"
/* /*
** _bucket_get ** _bucket_get
...@@ -102,7 +102,7 @@ _bucket_get(Bucket *self, PyObject *keyarg, int has_key) ...@@ -102,7 +102,7 @@ _bucket_get(Bucket *self, PyObject *keyarg, int has_key)
PyObject *r; PyObject *r;
KEY_TYPE key; KEY_TYPE key;
COPY_KEY_FROM_ARG(key, keyarg, &copied); COPY_KEY_FROM_ARG(key, keyarg, copied);
UNLESS (copied) return NULL; UNLESS (copied) return NULL;
PER_USE_OR_RETURN(self, NULL); PER_USE_OR_RETURN(self, NULL);
...@@ -194,7 +194,7 @@ _bucket_set(Bucket *self, PyObject *keyarg, PyObject *v, ...@@ -194,7 +194,7 @@ _bucket_set(Bucket *self, PyObject *keyarg, PyObject *v,
int min, max, i, l, cmp, copied=1; int min, max, i, l, cmp, copied=1;
KEY_TYPE key; KEY_TYPE key;
COPY_KEY_FROM_ARG(key, keyarg, &copied); COPY_KEY_FROM_ARG(key, keyarg, copied);
UNLESS(copied) return -1; UNLESS(copied) return -1;
PER_USE_OR_RETURN(self, -1); PER_USE_OR_RETURN(self, -1);
...@@ -210,7 +210,7 @@ _bucket_set(Bucket *self, PyObject *keyarg, PyObject *v, ...@@ -210,7 +210,7 @@ _bucket_set(Bucket *self, PyObject *keyarg, PyObject *v,
{ {
VALUE_TYPE value; VALUE_TYPE value;
COPY_VALUE_FROM_ARG(value, v, &copied); COPY_VALUE_FROM_ARG(value, v, copied);
UNLESS(copied) return -1; UNLESS(copied) return -1;
#ifdef VALUE_SAME #ifdef VALUE_SAME
...@@ -295,7 +295,7 @@ _bucket_set(Bucket *self, PyObject *keyarg, PyObject *v, ...@@ -295,7 +295,7 @@ _bucket_set(Bucket *self, PyObject *keyarg, PyObject *v,
UNLESS (noval) UNLESS (noval)
{ {
COPY_VALUE_FROM_ARG(self->values[i], v, &copied); COPY_VALUE_FROM_ARG(self->values[i], v, copied);
UNLESS(copied) return -1; UNLESS(copied) return -1;
INCREF_VALUE(self->values[i]); INCREF_VALUE(self->values[i]);
} }
...@@ -487,7 +487,7 @@ Bucket_findRangeEnd(Bucket *self, PyObject *keyarg, int low, int *offset) ...@@ -487,7 +487,7 @@ Bucket_findRangeEnd(Bucket *self, PyObject *keyarg, int low, int *offset)
Bucket *release = NULL; Bucket *release = NULL;
KEY_TYPE key; KEY_TYPE key;
COPY_KEY_FROM_ARG(key, keyarg, &copied); COPY_KEY_FROM_ARG(key, keyarg, copied);
UNLESS (copied) return -1; UNLESS (copied) return -1;
PER_USE_OR_RETURN(self, -1); PER_USE_OR_RETURN(self, -1);
...@@ -768,7 +768,7 @@ bucket_byValue(Bucket *self, PyObject *args) ...@@ -768,7 +768,7 @@ bucket_byValue(Bucket *self, PyObject *args)
PER_USE_OR_RETURN(self, NULL); PER_USE_OR_RETURN(self, NULL);
UNLESS (PyArg_ParseTuple(args, "O", &omin)) return NULL; UNLESS (PyArg_ParseTuple(args, "O", &omin)) return NULL;
COPY_VALUE_FROM_ARG(min, omin, &copied); COPY_VALUE_FROM_ARG(min, omin, copied);
UNLESS(copied) return NULL; UNLESS(copied) return NULL;
for (i=0, l=0; i < self->len; i++) for (i=0, l=0; i < self->len; i++)
...@@ -994,9 +994,9 @@ _bucket_setstate(Bucket *self, PyObject *args) ...@@ -994,9 +994,9 @@ _bucket_setstate(Bucket *self, PyObject *args)
v=PyTuple_GET_ITEM(items, l); v=PyTuple_GET_ITEM(items, l);
l++; l++;
COPY_KEY_FROM_ARG(self->keys[i], k, &copied); COPY_KEY_FROM_ARG(self->keys[i], k, copied);
UNLESS (copied) return -1; UNLESS (copied) return -1;
COPY_VALUE_FROM_ARG(self->values[i], v, &copied); COPY_VALUE_FROM_ARG(self->values[i], v, copied);
UNLESS (copied) return -1; UNLESS (copied) return -1;
INCREF_KEY(self->keys[i]); INCREF_KEY(self->keys[i]);
INCREF_VALUE(self->values[i]); INCREF_VALUE(self->values[i]);
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
Set operations Set operations
****************************************************************************/ ****************************************************************************/
#define SETOPTEMPLATE_C "$Id: SetOpTemplate.c,v 1.5 2001/03/20 13:52:00 jim Exp $\n" #define SETOPTEMPLATE_C "$Id: SetOpTemplate.c,v 1.6 2001/03/21 14:16:58 jim Exp $\n"
#ifdef INTSET_H #ifdef INTSET_H
static int static int
...@@ -202,7 +202,7 @@ initSetIteration(SetIteration *i, PyObject *s, int w, int *merge) ...@@ -202,7 +202,7 @@ initSetIteration(SetIteration *i, PyObject *s, int w, int *merge)
Py_INCREF(s); Py_INCREF(s);
i->next=nextKeyAsSet; i->next=nextKeyAsSet;
i->hasValue=0; i->hasValue=0;
COPY_KEY_FROM_ARG(i->key, s, &copied); COPY_KEY_FROM_ARG(i->key, s, copied);
UNLESS (copied) return -1; UNLESS (copied) return -1;
} }
#endif #endif
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
****************************************************************************/ ****************************************************************************/
#define SETTEMPLATE_C "$Id: SetTemplate.c,v 1.9 2001/03/20 13:52:00 jim Exp $\n" #define SETTEMPLATE_C "$Id: SetTemplate.c,v 1.10 2001/03/21 14:16:58 jim Exp $\n"
static PyObject * static PyObject *
Set_insert(Bucket *self, PyObject *args) Set_insert(Bucket *self, PyObject *args)
...@@ -179,7 +179,7 @@ _set_setstate(Bucket *self, PyObject *args) ...@@ -179,7 +179,7 @@ _set_setstate(Bucket *self, PyObject *args)
for (i=0; i<l; i++) for (i=0; i<l; i++)
{ {
k=PyTuple_GET_ITEM(items, i); k=PyTuple_GET_ITEM(items, i);
COPY_KEY_FROM_ARG(self->keys[i], k, &copied); COPY_KEY_FROM_ARG(self->keys[i], k, copied);
UNLESS (copied) return -1; UNLESS (copied) return -1;
INCREF_KEY(self->keys[i]); INCREF_KEY(self->keys[i]);
} }
......
#define KEYMACROS_H "$Id: intkeymacros.h,v 1.4 2001/03/20 13:52:00 jim Exp $\n" #define KEYMACROS_H "$Id: intkeymacros.h,v 1.5 2001/03/21 14:16:58 jim Exp $\n"
#define KEY_TYPE int #define KEY_TYPE int
#define KEY_CHECK PyInt_Check #define KEY_CHECK PyInt_Check
...@@ -11,4 +11,4 @@ ...@@ -11,4 +11,4 @@
#define COPY_KEY_FROM_ARG(TARGET, ARG, STATUS) \ #define COPY_KEY_FROM_ARG(TARGET, ARG, STATUS) \
if (PyInt_Check(ARG)) TARGET=PyInt_AsLong(ARG); else { \ if (PyInt_Check(ARG)) TARGET=PyInt_AsLong(ARG); else { \
PyErr_SetString(PyExc_TypeError, "expected integer key"); \ PyErr_SetString(PyExc_TypeError, "expected integer key"); \
*(STATUS)=0; } (STATUS)=0; }
#define VALUEMACROS_H "$Id: intvaluemacros.h,v 1.5 2001/03/20 13:52:00 jim Exp $\n" #define VALUEMACROS_H "$Id: intvaluemacros.h,v 1.6 2001/03/21 14:16:58 jim Exp $\n"
#define VALUE_TYPE int #define VALUE_TYPE int
#define TEST_VALUE(K, T) (((K) < (T)) ? -1 : (((K) > (T)) ? 1: 0)) #define TEST_VALUE(K, T) (((K) < (T)) ? -1 : (((K) > (T)) ? 1: 0))
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#define COPY_VALUE_FROM_ARG(TARGET, ARG, STATUS) \ #define COPY_VALUE_FROM_ARG(TARGET, ARG, STATUS) \
if (PyInt_Check(ARG)) TARGET=PyInt_AsLong(ARG); else { \ if (PyInt_Check(ARG)) TARGET=PyInt_AsLong(ARG); else { \
PyErr_SetString(PyExc_TypeError, "expected integer value"); \ PyErr_SetString(PyExc_TypeError, "expected integer value"); \
*(STATUS)=0; } (STATUS)=0; }
#define NORMALIZE_VALUE(V, MIN) ((MIN) > 0) ? ((V)/=(MIN)) : 0 #define NORMALIZE_VALUE(V, MIN) ((MIN) > 0) ? ((V)/=(MIN)) : 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment