Mercurial > emacs
comparison src/lisp.h @ 26296:e5c745f5a9fc
(struct gcpro) [DEBUG_GCPRO]: New field `level'.
(gcpro_level): Declare it extern.
[DEBUG_GCPRO] (GCPRO1, GCPRO2, GCPRO3, GCPRO4, GCPRO5):
Alternate definitions that set `level' and increment `gcpro_level'.
[DEBUG_GCPRO] (UNGCPRO): Alternate definition that checks gcpro_level.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 01 Nov 1999 23:16:22 +0000 |
parents | 0a50b06a5aa7 |
children | 8817f3f80755 |
comparison
equal
deleted
inserted
replaced
26295:d479e0daeb07 | 26296:e5c745f5a9fc |
---|---|
1484 | 1484 |
1485 /* An address near the bottom of the stack. | 1485 /* An address near the bottom of the stack. |
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)) \ |
1493 { Vquit_flag = Qnil; Fsignal (Qquit, Qnil); } | 1504 { Vquit_flag = Qnil; Fsignal (Qquit, Qnil); } |
1494 | 1505 |
1568 struct gcpro | 1579 struct gcpro |
1569 { | 1580 { |
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 }; |
1588 | |
1589 #ifndef DEBUG_GCPRO | |
1574 | 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; } |
1578 | 1594 |
1600 gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \ | 1616 gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \ |
1601 gcpro4.next = &gcpro3; gcpro4.var = &varname4; gcpro4.nvars = 1; \ | 1617 gcpro4.next = &gcpro3; gcpro4.var = &varname4; gcpro4.nvars = 1; \ |
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'. */ | |
1606 | |
1607 void staticpro P_ ((Lisp_Object *)); | |
1608 | |
1609 #define UNGCPRO (gcprolist = gcpro1.next) | 1621 #define UNGCPRO (gcprolist = gcpro1.next) |
1622 | |
1623 #else | |
1624 | |
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) \ |
1613 do \ | 1675 do \ |
1614 { \ | 1676 { \ |
1616 ret_ungc_val = (expr); \ | 1678 ret_ungc_val = (expr); \ |
1617 UNGCPRO; \ | 1679 UNGCPRO; \ |
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. */ |
1624 #if !defined (__STDC__) || defined (USE_NONANSI_DEFUN) | 1690 #if !defined (__STDC__) || defined (USE_NONANSI_DEFUN) |
1625 #define EXFUN(fnname, maxargs) \ | 1691 #define EXFUN(fnname, maxargs) \ |