*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307 USA
*
* As a special exception, the Free Software Foundation gives permission
* for additional uses of the text contained in its release of GUILE.
*
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
- * If you do not wish that, delete this exception notice.
- */
+ * If you do not wish that, delete this exception notice. */
+
+/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
+ gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
+
\f
#include "libguile/__scm.h"
#define SCM_CAR(x) (((scm_cell *)(SCM2PTR(x)))->car)
#define SCM_CDR(x) (((scm_cell *)(SCM2PTR(x)))->cdr)
#define SCM_GCCDR(x) (~1L & SCM_CDR(x))
-#define SCM_SETCDR(x, v) SCM_CDR(x) = (SCM)(v)
-#define SCM_SETCAR(x, v) SCM_CAR(x) = (SCM)(v)
+#define SCM_SETCAR(x, v) (SCM_CAR(x) = (SCM)(v))
+#define SCM_SETCDR(x, v) (SCM_CDR(x) = (SCM)(v))
+
+#define SCM_CARLOC(x) (&SCM_CAR (x))
+#define SCM_CDRLOC(x) (&SCM_CDR (x))
+
+#define SCM_SETAND_CAR(x, y) (SCM_CAR (x) &= (y))
+#define SCM_SETAND_CDR(x, y) (SCM_CDR (x) &= (y))
+#define SCM_SETOR_CAR(x, y) (SCM_CAR (x) |= (y))
+#define SCM_SETOR_CDR(x, y) (SCM_CDR (x) |= (y))
#define SCM_CAAR(OBJ) SCM_CAR (SCM_CAR (OBJ))
#define SCM_CDAR(OBJ) SCM_CDR (SCM_CAR (OBJ))
#define SCM_CADDDR(OBJ) SCM_CAR (SCM_CDR (SCM_CDR (SCM_CDR (OBJ))))
#define SCM_CDDDDR(OBJ) SCM_CDR (SCM_CDR (SCM_CDR (SCM_CDR (OBJ))))
+/* the allocated thing: The car of newcells are set to
+ scm_tc16_allocated to avoid the fragile state of newcells wrt the
+ gc. If it stays as a freecell, any allocation afterwards could
+ cause the cell to go back on the freelist, which will bite you
+ sometime afterwards */
+#ifdef GUILE_DEBUG_FREELIST
+#define SCM_NEWCELL(_into) do { _into = scm_debug_newcell (); } while (0)
+#else
#define SCM_NEWCELL(_into) \
- { \
+ do { \
if (SCM_IMP(scm_freelist)) \
_into = scm_gc_for_newcell();\
else \
{ \
_into = scm_freelist; \
scm_freelist = SCM_CDR(scm_freelist);\
+ SCM_SETCAR(_into, scm_tc16_allocated); \
++scm_cells_allocated; \
} \
- }
+ } while(0)
+#endif
\f
-#ifdef __STDC__
-extern SCM scm_cons (SCM x, SCM y);
-extern SCM scm_cons2 (SCM w, SCM x, SCM y);
-extern SCM scm_pair_p(SCM x);
-extern SCM scm_set_car_x(SCM pair, SCM value);
-extern SCM scm_set_cdr_x(SCM pair, SCM value);
-extern void scm_init_pairs (void);
-
-#else /* STDC */
-extern SCM scm_cons ();
-extern SCM scm_cons2 ();
-extern SCM scm_pair_p();
-extern SCM scm_set_car_x();
-extern SCM scm_set_cdr_x();
-extern void scm_init_pairs ();
-
-#endif /* STDC */
+
+extern SCM scm_cons SCM_P ((SCM x, SCM y));
+extern SCM scm_cons2 SCM_P ((SCM w, SCM x, SCM y));
+extern SCM scm_pair_p SCM_P ((SCM x));
+extern SCM scm_set_car_x SCM_P ((SCM pair, SCM value));
+extern SCM scm_set_cdr_x SCM_P ((SCM pair, SCM value));
+extern void scm_init_pairs SCM_P ((void));
+
#endif /* PAIRSH */