#else
#define SWITCH_ENUM_CAST(x) (x)
#endif
+
+/* Loop over Lisp list LIST. Signal an error if LIST is not a proper
+ list, or if it contains circles.
+
+ HARE and TORTOISE should be the names of Lisp_Object variables, and
+ N should be the name of an EMACS_INT variable declared in the
+ function where the macro is used. Each nested loop should use
+ its own variables.
+
+ In the loop body, HARE is set to each cons of LIST, and N is the
+ length of the list processed so far. */
+
+#define LIST_END_P(list, obj) \
+ (NILP (obj) \
+ ? 1 \
+ : (CONSP (obj) \
+ ? 0 \
+ : (wrong_type_argument (Qlistp, (list), 0)), 1))
+
+#define FOREACH(hare, list, tortoise, n) \
+ for (tortoise = hare = (list), n = 0; \
+ !LIST_END_P (list, hare); \
+ (hare = XCDR (hare), ++n, \
+ ((n & 1) != 0 \
+ ? (tortoise = XCDR (tortoise), \
+ (EQ (hare, tortoise) \
+ && (circular_list_error ((list)), 1))) \
+ : 0)))