diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lisp.h | 74 |
1 files changed, 70 insertions, 4 deletions
diff --git a/src/lisp.h b/src/lisp.h index e6ed92d6216..5dbc8505ba0 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -1486,7 +1486,18 @@ extern Lisp_Object memory_signal_data; | |||
| 1486 | Tells GC how to save a copy of the stack. */ | 1486 | Tells GC how to save a copy of the stack. */ |
| 1487 | extern char *stack_bottom; | 1487 | extern char *stack_bottom; |
| 1488 | 1488 | ||
| 1489 | /* Check quit-flag and quit if it is non-nil. */ | 1489 | /* Check quit-flag and quit if it is non-nil. |
| 1490 | Typing C-g does not directly cause a quit; it only sets Vquit_flag. | ||
| 1491 | So the program needs to do QUIT at times when it is safe to quit. | ||
| 1492 | Every loop that might run for a long time or might not exit | ||
| 1493 | ought to do QUIT at least once, at a safe place. | ||
| 1494 | Unless that is impossible, of course. | ||
| 1495 | But it is very desirable to avoid creating loops where QUIT is impossible. | ||
| 1496 | |||
| 1497 | Exception: if you set immediate_quit to nonzero, | ||
| 1498 | then the handler that responds to the C-g does the quit itself. | ||
| 1499 | This is a good thing to do around a loop that has no side effects | ||
| 1500 | and (in particular) cannot call arbitrary Lisp code. */ | ||
| 1490 | 1501 | ||
| 1491 | #define QUIT \ | 1502 | #define QUIT \ |
| 1492 | if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \ | 1503 | if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \ |
| @@ -1570,8 +1581,13 @@ struct gcpro | |||
| 1570 | struct gcpro *next; | 1581 | struct gcpro *next; |
| 1571 | Lisp_Object *var; /* Address of first protected variable */ | 1582 | Lisp_Object *var; /* Address of first protected variable */ |
| 1572 | int nvars; /* Number of consecutive protected variables */ | 1583 | int nvars; /* Number of consecutive protected variables */ |
| 1584 | #ifdef DEBUG_GCPRO | ||
| 1585 | int level; | ||
| 1586 | #endif | ||
| 1573 | }; | 1587 | }; |
| 1574 | 1588 | ||
| 1589 | #ifndef DEBUG_GCPRO | ||
| 1590 | |||
| 1575 | #define GCPRO1(varname) \ | 1591 | #define GCPRO1(varname) \ |
| 1576 | {gcpro1.next = gcprolist; gcpro1.var = &varname; gcpro1.nvars = 1; \ | 1592 | {gcpro1.next = gcprolist; gcpro1.var = &varname; gcpro1.nvars = 1; \ |
| 1577 | gcprolist = &gcpro1; } | 1593 | gcprolist = &gcpro1; } |
| @@ -1602,11 +1618,57 @@ struct gcpro | |||
| 1602 | gcpro5.next = &gcpro4; gcpro5.var = &varname5; gcpro5.nvars = 1; \ | 1618 | gcpro5.next = &gcpro4; gcpro5.var = &varname5; gcpro5.nvars = 1; \ |
| 1603 | gcprolist = &gcpro5; } | 1619 | gcprolist = &gcpro5; } |
| 1604 | 1620 | ||
| 1605 | /* Call staticpro (&var) to protect static variable `var'. */ | 1621 | #define UNGCPRO (gcprolist = gcpro1.next) |
| 1606 | 1622 | ||
| 1607 | void staticpro P_ ((Lisp_Object *)); | 1623 | #else |
| 1608 | 1624 | ||
| 1609 | #define UNGCPRO (gcprolist = gcpro1.next) | 1625 | extern int gcpro_level; |
| 1626 | |||
| 1627 | #define GCPRO1(varname) \ | ||
| 1628 | {gcpro1.next = gcprolist; gcpro1.var = &varname; gcpro1.nvars = 1; \ | ||
| 1629 | gcpro1.level = gcpro_level++; \ | ||
| 1630 | gcprolist = &gcpro1; } | ||
| 1631 | |||
| 1632 | #define GCPRO2(varname1, varname2) \ | ||
| 1633 | {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \ | ||
| 1634 | gcpro1.level = gcpro_level; \ | ||
| 1635 | gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \ | ||
| 1636 | gcpro2.level = gcpro_level++; \ | ||
| 1637 | gcprolist = &gcpro2; } | ||
| 1638 | |||
| 1639 | #define GCPRO3(varname1, varname2, varname3) \ | ||
| 1640 | {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \ | ||
| 1641 | gcpro1.level = gcpro_level; \ | ||
| 1642 | gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \ | ||
| 1643 | gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \ | ||
| 1644 | gcpro3.level = gcpro_level++; \ | ||
| 1645 | gcprolist = &gcpro3; } | ||
| 1646 | |||
| 1647 | #define GCPRO4(varname1, varname2, varname3, varname4) \ | ||
| 1648 | {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \ | ||
| 1649 | gcpro1.level = gcpro_level; \ | ||
| 1650 | gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \ | ||
| 1651 | gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \ | ||
| 1652 | gcpro4.next = &gcpro3; gcpro4.var = &varname4; gcpro4.nvars = 1; \ | ||
| 1653 | gcpro4.level = gcpro_level++; \ | ||
| 1654 | gcprolist = &gcpro4; } | ||
| 1655 | |||
| 1656 | #define GCPRO5(varname1, varname2, varname3, varname4, varname5) \ | ||
| 1657 | {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \ | ||
| 1658 | gcpro1.level = gcpro_level; \ | ||
| 1659 | gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \ | ||
| 1660 | gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \ | ||
| 1661 | gcpro4.next = &gcpro3; gcpro4.var = &varname4; gcpro4.nvars = 1; \ | ||
| 1662 | gcpro5.next = &gcpro4; gcpro5.var = &varname5; gcpro5.nvars = 1; \ | ||
| 1663 | gcpro5.level = gcpro_level++; \ | ||
| 1664 | gcprolist = &gcpro5; } | ||
| 1665 | |||
| 1666 | #define UNGCPRO \ | ||
| 1667 | ((--gcpro_level != gcpro1.level) \ | ||
| 1668 | ? (abort (), 0) \ | ||
| 1669 | : ((gcprolist = gcpro1.next), 0)) | ||
| 1670 | |||
| 1671 | #endif /* DEBUG_GCPRO */ | ||
| 1610 | 1672 | ||
| 1611 | /* Evaluate expr, UNGCPRO, and then return the value of expr. */ | 1673 | /* Evaluate expr, UNGCPRO, and then return the value of expr. */ |
| 1612 | #define RETURN_UNGCPRO(expr) \ | 1674 | #define RETURN_UNGCPRO(expr) \ |
| @@ -1618,6 +1680,10 @@ do \ | |||
| 1618 | return ret_ungc_val; \ | 1680 | return ret_ungc_val; \ |
| 1619 | } \ | 1681 | } \ |
| 1620 | while (0) | 1682 | while (0) |
| 1683 | |||
| 1684 | /* Call staticpro (&var) to protect static variable `var'. */ | ||
| 1685 | |||
| 1686 | void staticpro P_ ((Lisp_Object *)); | ||
| 1621 | 1687 | ||
| 1622 | /* Declare a Lisp-callable function. The MAXARGS parameter has the same | 1688 | /* Declare a Lisp-callable function. The MAXARGS parameter has the same |
| 1623 | meaning as in the DEFUN macro, and is used to construct a prototype. */ | 1689 | meaning as in the DEFUN macro, and is used to construct a prototype. */ |