libk  Diff

Differences From Artifact [982620d249]:

To Artifact [91c37b49e7]:


14
15
16
17
18
19
20


21
22
23
24
25
26
27
..
57
58
59
60
61
62
63


64
65
66
67
68
69
70
71
72
73
74
75
76

77
78
79
80
81
82
83

84
85
86
87
88



89
90
91
92
93
94

	/* error states */
	kncond_fail,
	kncond_fail_io,
	kncond_overflow,
	kncond_underflow,
	kncond_bad_domain,


} kncond;

/* this "hard" random number generator
 * returns a block of random data that
 * can be used safely in cryptographic
 * pseudorandom number algorithms such
 * as e.g. knrands() */
................................................................................
 * fixed point & floating point numbers
 * should also be added eventually.
 * note that these functions use either
 * 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_signed   = 1 << 2, /* 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 */

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 knidiv(knmode, sz,
	/* output */ u8* ratio, u8* remainder,

	/*  input */ u8* src, u8* delta);

/* we should probably also offer a bignum
 * type eventually, tho this will need to
 * be integrated with kmem for allocation. */




#ifdef __cplusplus
	}
#endif

#endif







>
>







 







>
>
|
|
|

|



|
|
|
|
|
>
|

|
|
|

<
>
|




>
>
>






14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
..
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

88
89
90
91
92
93
94
95
96
97
98
99
100
101
102

	/* error states */
	kncond_fail,
	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
 * can be used safely in cryptographic
 * pseudorandom number algorithms such
 * as e.g. knrands() */
................................................................................
 * fixed point & floating point numbers
 * should also be added eventually.
 * note that these functions use either
 * two's complement or one's complement
 * for signed */

typedef enum knmode {
	/* 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 << 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
 * ubyte, they are converted appropriately
 * with  regard  to sign  and  size within
 * the fn */

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 */ 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