From: Bruno H. <br...@cl...> - 2005-01-25 16:48:05
|
Sam wrote: > digits points to a sequence of bytes, so it should probably be uint8*. Yes. uint8* or uintB*, it's the same. (I use uint8 only when the number of bits matters, whereas uintB is more the elementary unit of addressable memory.) > > is len > 0 or can it be 0 ? > > dunno. it depends on the behavior of UDS_to_I() UDS_to_I() is specified to take an UDS as input; this term is defined in arilev1.d. > BTW, what does "there must be room for 1 digit below of MSDptr" mean? It means that MSDptr[-1] may be written to. That's also the reason why the argument is not a 'const' pointer. > > Is the input in big-endian or little-endian order?) > > I don't know what "big-endian" and "little-endian" are. > In my kindergarten they taught only one way to record numbers with > digits: 123 = 1*100 + 2*10 + 3*1 > So, byte sequence "123" represents the integer 1*256^2 + 2*256 + 3*1. This is big-endian. Little-endian would be the opposite: when the byte sequence 1 2 3, ordered from low to high addresses, represents the integer 1*1 + 2*256 + 3*256^2. > > If not, then why is the 'digits' pointer not 'const'? > > because I don't know what "const" means If a function takes a 'const uintB *' argument, it promises to not write to memory through that pointer. So that means a :IN parameter, whereas 'uintB *' means a :IN-OUT or :OUT parameter (in our FFI's notation). > Maybe you could fix the comments of UDS_to_I() first? I'm updating the definitions in arilev1.d. For the implementation of udigits_to_I: Note that you cannot always interpret an array of type uint8[] as an array of type uintD[]: The number of elements may not be a multiple of sizeof(uintD)/sizeof(uint8) (what do you want to do with the last few bytes in that case?), and the alignment of the memory may not be a multiple of alignof(uintD). Bruno |