diff options
| author | Paul Eggert | 2014-10-01 13:34:55 -0700 |
|---|---|---|
| committer | Paul Eggert | 2014-10-01 13:34:55 -0700 |
| commit | c59ef5ef53f8e33a693f1107c1d61535bbd3a187 (patch) | |
| tree | c905d3664db636dc64b2253e24f990592edd5208 | |
| parent | a57fa9642d4953dd6b249f563776e8e9ed60ced5 (diff) | |
| download | emacs-c59ef5ef53f8e33a693f1107c1d61535bbd3a187.tar.gz emacs-c59ef5ef53f8e33a693f1107c1d61535bbd3a187.zip | |
Improve doc for use of 'int', and discuss 'ssize_t'.
* internals.texi (C Integer Types): Mention 'int' for other
randomish values that lie in 'int' range. Mention 'ssize_t'. See:
http://lists.gnu.org/archive/html/emacs-devel/2014-10/msg00019.html
| -rw-r--r-- | doc/lispref/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/lispref/internals.texi | 13 |
2 files changed, 18 insertions, 0 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 4a27ce5d40b..c60b7c38838 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,5 +1,10 @@ | |||
| 1 | 2014-10-01 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2014-10-01 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | Improve doc for use of 'int', and discuss 'ssize_t'. | ||
| 4 | * internals.texi (C Integer Types): Mention 'int' for other | ||
| 5 | randomish values that lie in 'int' range. Mention 'ssize_t'. See: | ||
| 6 | http://lists.gnu.org/archive/html/emacs-devel/2014-10/msg00019.html | ||
| 7 | |||
| 3 | Use AUTO_CONS instead of SCOPED_CONS, etc. | 8 | Use AUTO_CONS instead of SCOPED_CONS, etc. |
| 4 | * internals.texi (Stack-allocated Objects): | 9 | * internals.texi (Stack-allocated Objects): |
| 5 | Adjust to match the revised, less error-prone macros. | 10 | Adjust to match the revised, less error-prone macros. |
diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi index 849779b6a7b..db6ed41268c 100644 --- a/doc/lispref/internals.texi +++ b/doc/lispref/internals.texi | |||
| @@ -1625,6 +1625,8 @@ of @code{intptr_t}). | |||
| 1625 | 1625 | ||
| 1626 | @item | 1626 | @item |
| 1627 | Prefer @code{int} for Emacs character codes, in the range 0 ..@: 0x3FFFFF. | 1627 | Prefer @code{int} for Emacs character codes, in the range 0 ..@: 0x3FFFFF. |
| 1628 | More generally, prefer @code{int} for integers known to be in | ||
| 1629 | @code{int} range, e.g., screen column counts. | ||
| 1628 | 1630 | ||
| 1629 | @item | 1631 | @item |
| 1630 | Prefer @code{ptrdiff_t} for sizes, i.e., for integers bounded by the | 1632 | Prefer @code{ptrdiff_t} for sizes, i.e., for integers bounded by the |
| @@ -1636,6 +1638,17 @@ anyway since they would break pointer subtraction, so this does not | |||
| 1636 | impose an arbitrary limit. | 1638 | impose an arbitrary limit. |
| 1637 | 1639 | ||
| 1638 | @item | 1640 | @item |
| 1641 | Avoid @code{ssize_t} except when communicating to low-level APIs that | ||
| 1642 | have @code{ssize_t}-related limitations. Although it's equivalent to | ||
| 1643 | @code{ptrdiff_t} on typical platforms, @code{ssize_t} is occasionally | ||
| 1644 | narrower, so using it for size-related calculations could overflow. | ||
| 1645 | Also, @code{ptrdiff_t} is more ubiquitous and better-standardized, has | ||
| 1646 | standard @code{printf} formats, and is the basis for Emacs's internal | ||
| 1647 | size-overflow checking. When using @code{ssize_t}, please note that | ||
| 1648 | POSIX requires support only for values in the range @minus{}1 ..@: | ||
| 1649 | @code{SSIZE_MAX}. | ||
| 1650 | |||
| 1651 | @item | ||
| 1639 | Prefer @code{intptr_t} for internal representations of pointers, or | 1652 | Prefer @code{intptr_t} for internal representations of pointers, or |
| 1640 | for integers bounded only by the number of objects that can exist at | 1653 | for integers bounded only by the number of objects that can exist at |
| 1641 | any given time or by the total number of bytes that can be allocated. | 1654 | any given time or by the total number of bytes that can be allocated. |