diff options
| author | Paul Eggert | 2016-02-09 13:43:13 -0800 |
|---|---|---|
| committer | Paul Eggert | 2016-02-09 14:17:01 -0800 |
| commit | f65ef80fed9813903559345a9f7eb89d712fa3fc (patch) | |
| tree | 3c2705841cc8f4345c633ecbfcc878251ecbe433 /src | |
| parent | 7777e8089fe3ea260b3f591e67c0e66c44d9969e (diff) | |
| download | emacs-f65ef80fed9813903559345a9f7eb89d712fa3fc.tar.gz emacs-f65ef80fed9813903559345a9f7eb89d712fa3fc.zip | |
Add lmalloc commentary and tweak laligned
* src/alloc.c (laligned): Help compiler in a tiny way by putting
the more-commonly-failing disjunct first.
Diffstat (limited to 'src')
| -rw-r--r-- | src/alloc.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/alloc.c b/src/alloc.c index 668bbc75947..6bc1b8afe17 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -1375,8 +1375,8 @@ lisp_align_free (void *block) | |||
| 1375 | static bool | 1375 | static bool |
| 1376 | laligned (void *p, size_t size) | 1376 | laligned (void *p, size_t size) |
| 1377 | { | 1377 | { |
| 1378 | return (MALLOC_IS_GC_ALIGNED || size % GCALIGNMENT != 0 | 1378 | return (MALLOC_IS_GC_ALIGNED || (intptr_t) p % GCALIGNMENT == 0 |
| 1379 | || (intptr_t) p % GCALIGNMENT == 0); | 1379 | || size % GCALIGNMENT != 0); |
| 1380 | } | 1380 | } |
| 1381 | 1381 | ||
| 1382 | /* Like malloc and realloc except that if SIZE is Lisp-aligned, make | 1382 | /* Like malloc and realloc except that if SIZE is Lisp-aligned, make |
| @@ -1385,7 +1385,15 @@ laligned (void *p, size_t size) | |||
| 1385 | Lisp-aligned pointer. Code that needs to allocate C heap memory | 1385 | Lisp-aligned pointer. Code that needs to allocate C heap memory |
| 1386 | for a Lisp object should use one of these functions to obtain a | 1386 | for a Lisp object should use one of these functions to obtain a |
| 1387 | pointer P; that way, if T is an enum Lisp_Type value and L == | 1387 | pointer P; that way, if T is an enum Lisp_Type value and L == |
| 1388 | make_lisp_ptr (P, T), then XPNTR (L) == P and XTYPE (L) == T. */ | 1388 | make_lisp_ptr (P, T), then XPNTR (L) == P and XTYPE (L) == T. |
| 1389 | |||
| 1390 | On typical modern platforms these functions' loops do not iterate. | ||
| 1391 | On now-rare (and perhaps nonexistent) platforms, the loops in | ||
| 1392 | theory could repeat forever. If an infinite loop is possible on a | ||
| 1393 | platform, a build would surely loop and the builder can then send | ||
| 1394 | us a bug report. Adding a counter to try to detect any such loop | ||
| 1395 | would complicate the code (and possibly introduce bugs, in code | ||
| 1396 | that's never really exercised) for little benefit. */ | ||
| 1389 | 1397 | ||
| 1390 | static void * | 1398 | static void * |
| 1391 | lmalloc (size_t size) | 1399 | lmalloc (size_t size) |