6 * This software is part of the SBCL system. See the README file for
9 * This software is derived from the CMU CL system, which was
10 * written at Carnegie Mellon University and released into the
11 * public domain. The software is in the public domain and is
12 * provided with absolutely no warranty. See the COPYING and CREDITS
13 * files for more information.
16 #include "genesis/sc-offset.h"
19 sc_offset_extract_bits(int sc_offset
,
20 unsigned int bytes_count
,
21 struct sc_offset_byte
* bytes
) {
22 unsigned int result
= 0, i
= 0, position
, size
, mask
, index
= 0;
23 for (; i
< bytes_count
; ++i
, index
+= size
) {
24 position
= bytes
[i
].position
;
26 mask
= (1 << size
) - 1;
27 result
|= ((sc_offset
>> position
) & mask
) << index
;
33 sc_offset_sc_number(int sc_offset
) {
34 return sc_offset_extract_bits
36 sizeof(sc_offset_sc_number_bytes
) / sizeof(struct sc_offset_byte
),
37 sc_offset_sc_number_bytes
);
41 sc_offset_offset(int sc_offset
) {
42 return sc_offset_extract_bits
44 sizeof(sc_offset_offset_bytes
) / sizeof(struct sc_offset_byte
),
45 sc_offset_offset_bytes
);