diff options
| author | Jim Blandy | 1993-04-10 08:05:07 +0000 |
|---|---|---|
| committer | Jim Blandy | 1993-04-10 08:05:07 +0000 |
| commit | 51cf3e317c4a5e5664218b6fe7a1c09f1c81631b (patch) | |
| tree | 36b81604db79c05fa628d67aabefa89eaa25f2ae /src/data.c | |
| parent | 6904bdcd0874054d3992319455cf049e5f01c69d (diff) | |
| download | emacs-51cf3e317c4a5e5664218b6fe7a1c09f1c81631b.tar.gz emacs-51cf3e317c4a5e5664218b6fe7a1c09f1c81631b.zip | |
long_to_cons and cons_to_long are generally useful things; they're
needed whether or not X is defined.
* xselect.c (long_to_cons, cons_to_long): Moved from here...
* data.c (long_to_cons, cons_to_long): ... to here.
* lisp.h (long_to_cons, cons_to_long): Add extern declaration.
Diffstat (limited to 'src/data.c')
| -rw-r--r-- | src/data.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/data.c b/src/data.c index 4b2fa3cebbf..66b4e90157b 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -1425,6 +1425,35 @@ DEFUN ("zerop", Fzerop, Szerop, 1, 1, 0, "T if NUMBER is zero.") | |||
| 1425 | return Qnil; | 1425 | return Qnil; |
| 1426 | } | 1426 | } |
| 1427 | 1427 | ||
| 1428 | /* Convert between 32-bit values and pairs of lispy 24-bit values. */ | ||
| 1429 | |||
| 1430 | Lisp_Object | ||
| 1431 | long_to_cons (i) | ||
| 1432 | unsigned long i; | ||
| 1433 | { | ||
| 1434 | unsigned int top = i >> 16; | ||
| 1435 | unsigned int bot = i & 0xFFFF; | ||
| 1436 | if (top == 0) | ||
| 1437 | return make_number (bot); | ||
| 1438 | if (top == 0xFFFF) | ||
| 1439 | return Fcons (make_number (-1), make_number (bot)); | ||
| 1440 | return Fcons (make_number (top), make_number (bot)); | ||
| 1441 | } | ||
| 1442 | |||
| 1443 | unsigned long | ||
| 1444 | cons_to_long (c) | ||
| 1445 | Lisp_Object c; | ||
| 1446 | { | ||
| 1447 | int top, bot; | ||
| 1448 | if (INTEGERP (c)) | ||
| 1449 | return XINT (c); | ||
| 1450 | top = XCONS (c)->car; | ||
| 1451 | bot = XCONS (c)->cdr; | ||
| 1452 | if (CONSP (bot)) | ||
| 1453 | bot = XCONS (bot)->car; | ||
| 1454 | return ((XINT (top) << 16) | XINT (bot)); | ||
| 1455 | } | ||
| 1456 | |||
| 1428 | DEFUN ("number-to-string", Fnumber_to_string, Snumber_to_string, 1, 1, 0, | 1457 | DEFUN ("number-to-string", Fnumber_to_string, Snumber_to_string, 1, 1, 0, |
| 1429 | "Convert NUM to a string by printing it in decimal.\n\ | 1458 | "Convert NUM to a string by printing it in decimal.\n\ |
| 1430 | Uses a minus sign if negative.\n\ | 1459 | Uses a minus sign if negative.\n\ |