ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/XML-DB/DB.xs
(Generate patch)

Comparing XML-DB/DB.xs (file contents):
Revision 1.2 by root, Sun Apr 21 17:30:08 2002 UTC vs.
Revision 1.3 by root, Sun Apr 21 17:30:20 2002 UTC

16#endif 16#endif
17#if PATCHLEVEL < 6 17#if PATCHLEVEL < 6
18# define call_sv perl_call_sv 18# define call_sv perl_call_sv
19#endif 19#endif
20 20
21#define KEYLEN 8 // number of bytes in the l, m, r fields
22
23static SV *
24new_key (void)
25{
26 SV *new = NEWSV(0, KEYLEN);
27 SvPOK_only (new);
28 SvCUR_set (new, KEYLEN);
29
30 return new;
31}
32
33MODULE = XML::DB PACKAGE = XML::DB::Key 21MODULE = XML::DB PACKAGE = XML::DB::Key
34 22
35PROTOTYPES: ENABLE 23PROTOTYPES: ENABLE
36 24
37int
38KEYLEN()
39 CODE:
40 RETVAL = KEYLEN;
41 OUTPUT:
42 RETVAL
43 25
44SV *
450()
46 ALIAS:
47 1 = 255
48 CODE:
49 RETVAL = new_key ();
50 memset (SvPVX (RETVAL), ix, KEYLEN);
51 OUTPUT:
52 RETVAL
53
54# calculcate l + r
55SV *
56m(ls,rs)
57 SV * ls
58 SV * rs
59 CODE:
60 unsigned char *l, *m, *r, *me;
61 unsigned int mx, carry;
62
63 RETVAL = new_key ();
64
65 l = SvPVX (ls ) + KEYLEN;
66 r = SvPVX (rs ) + KEYLEN;
67 m = (me = SvPVX (RETVAL)) + KEYLEN;
68
69 me [0] = 'U';
70 me [1] = 'U';
71
72 mx = (unsigned int)*--l + (unsigned int)*--r + 1; *--m = (mx & 0x0ff) >> 1;
73 carry = mx & 0x100;
74
75 do
76 {
77 mx = (unsigned int)*--l + (unsigned int)*--r + (carry >> 8); *--m = (mx & 0x0ff) >> 1;
78
79 m[1] |= (mx & 0x001) << 7;
80 carry = (mx & 0x100);
81 }
82 while (me < m);
83
84 m[0] |= carry >> 1;
85
86 OUTPUT:
87 RETVAL
88
89

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines