]> www.ginac.de Git - cln.git/blob - src/integer/elem/cl_I_plus1.cc
Distinguish between cl_word_size and the ABI's pointer size.
[cln.git] / src / integer / elem / cl_I_plus1.cc
1 // plus1().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cl_integer.h"
8
9
10 // Implementation.
11
12 #include "cl_I.h"
13 #include "cl_DS.h"
14
15 const cl_I plus1 (const cl_I& x)
16 {
17         if (fixnump(x))
18           { // x ist Fixnum
19             if (x.word != cl_combine(cl_FN_tag,bit(cl_value_len-1)-1))
20                 // bleibt Fixnum: direkt 1 addieren
21                 // This assumes cl_value_shift + cl_value_len == cl_pointer_size.
22                 { return cl_I_from_word(x.word + cl_combine(0,1)); }
23           }
24         // die sichere Methode
25         { CL_ALLOCA_STACK;
26           var uintD* MSDptr;
27           var uintC len;
28           var uintD* LSDptr;
29           I_to_NDS_1(x, MSDptr=,len=,LSDptr=); // NDS zu x bilden.
30           DS_1_plus(LSDptr,len); // zur NDS 1 addieren
31           return DS_to_I(MSDptr,len); // wieder zum Integer machen
32         }
33 }