@@ -17,8 +17,10 @@ kncond_fail_io, kncond_overflow, kncond_underflow, kncond_bad_domain, + kncond_bad_base, + } kncond; /* this "hard" random number generator * returns a block of random data that @@ -60,35 +62,41 @@ * two's complement or one's complement * for signed */ typedef enum knmode { - knmode_saturate = 0x0001, /* 0b001 */ - knmode_wrap = 0x0002, /* 0b010 */ - knmode_fail = 0x0003, /* 0b011 */ + /* knmode operations may be or'd with a base; + * base will be inferred by prefix otherwise */ + knmode_saturate = 0x0001 << 7, /* 0b001 */ + knmode_wrap = 0x0002 << 7, /* 0b010 */ + knmode_fail = 0x0003 << 7, /* 0b011 */ - knmode_signed = 1 << 2, /* 0b100*/ + knmode_signed = 1 << 6, /* 0b100*/ knmode_unsigned = 0 /* default */ } knmode; -/* it is legal for src and dest to be the - * same location in memory. this will not - * produce incorrect output. although the - * functions formally take pointers to u8, - * they are converted appropriately with - * regard to sign and size within the fn */ +/* it is legal for src and dest to be the + * same location in memory. this will not + * produce incorrect output. although the + * functions formally take pointers to + * ubyte, they are converted appropriately + * with regard to sign and size within + * the fn */ -kncond kniadd(knmode, sz, u8* dest, u8* src, u8* delta); -kncond knisub(knmode, sz, u8* dest, u8* src, u8* delta); -kncond knimul(knmode, sz, u8* dest, u8* src, u8* delta); +kncond kniadd(knmode, sz, ubyte* dest, ubyte* src, ubyte* delta); +kncond knisub(knmode, sz, ubyte* dest, ubyte* src, ubyte* delta); +kncond knimul(knmode, sz, ubyte* dest, ubyte* src, ubyte* delta); kncond knidiv(knmode, sz, - /* output */ u8* ratio, u8* remainder, - /* input */ u8* src, u8* delta); + /* output */ ubyte* ratio, ubyte* remainder, + /* input */ ubyte* src, ubyte delta); /* we should probably also offer a bignum * type eventually, tho this will need to * be integrated with kmem for allocation. */ + +kncond knstr(knmode, sz, char* dest_begin, char* dest_end, ubyte* src); +kncond knparse(knmode, sz, ubyte* dest, ksraw src); #ifdef __cplusplus } #endif #endif