OSSP CVS Repository

ossp - Check-in [2113]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 2113
Date: 2002-Apr-28 20:58:01 (local)
2002-Apr-28 18:58:01 (UTC)
User:rse
Branch:
Comment: first cut for a real documentation
Tickets:
Inspections:
Files:
ossp-pkg/ui64/ui64.c      1.1 -> 1.2     6 inserted, 1 deleted
ossp-pkg/ui64/ui64.h      1.1 -> 1.2     1 inserted, 1 deleted
ossp-pkg/ui64/ui64.pod      1.2 -> 1.3     170 inserted, 6 deleted

ossp-pkg/ui64/ui64.c 1.1 -> 1.2

--- ui64.c       2002/04/28 13:22:49     1.1
+++ ui64.c       2002/04/28 18:58:01     1.2
@@ -37,6 +37,7 @@
 #define UI64_DIGITS 8   /* 8*8 = 64 bit */
 #define UIXX_T(n) struct { unsigned char x[n]; }
 
+/* fill an ui64_t with a sequence of a particular digit */
 #define ui64_fill(__x, __n) \
     do { int __i; \
       for (__i = 0; __i < UI64_DIGITS; __i++) \
@@ -77,7 +78,7 @@
 }
 
 /* convert internal format into ISO-C "unsigned long";
-   truncates if sizeof(unsigned long) is less than 8!) */
+   truncates if sizeof(unsigned long) is less than UI64_DIGITS! */
 unsigned long ui64_i2n(ui64_t x)
 {
     unsigned long n;
@@ -159,6 +160,7 @@
         return str;
 }
 
+/* addition of two ui64_t */
 ui64_t ui64_add(ui64_t x, ui64_t y, ui64_t *ov)
 {
     ui64_t z;
@@ -176,6 +178,7 @@
     return z;
 }
 
+/* addition of an ui64_t and a single digit */
 ui64_t ui64_addn(ui64_t x, int y, int *ov)
 {
     ui64_t z;
@@ -191,6 +194,7 @@
     return z;
 }
 
+/* subtraction of two ui64_t */
 ui64_t ui64_sub(ui64_t x, ui64_t y, ui64_t *ov)
 {
     ui64_t z;
@@ -209,6 +213,7 @@
     return z;
 }
 
+/* subtraction of an ui64_t and a single digit */
 ui64_t ui64_subn(ui64_t x, int y, int *ov)
 {
     ui64_t z;


ossp-pkg/ui64/ui64.h 1.1 -> 1.2

--- ui64.h       2002/04/28 13:22:49     1.1
+++ ui64.h       2002/04/28 18:58:01     1.2
@@ -37,7 +37,7 @@
     unsigned char x[8]; /* x_0, ..., x_7 */
 } ui64_t;
 
-/* minimum/maximum values */
+/* particular values */
 extern ui64_t        ui64_zero (void);
 extern ui64_t        ui64_max  (void);
 


ossp-pkg/ui64/ui64.pod 1.2 -> 1.3

--- ui64.pod     2002/04/28 13:27:24     1.2
+++ ui64.pod     2002/04/28 18:58:01     1.3
@@ -40,19 +40,183 @@
 
 =head1 SYNOPSIS
 
-...
+B<ui64_zero>, 
+B<ui64_max>,  
+B<ui64_n2i>,  
+B<ui64_i2n>,  
+B<ui64_s2i>,  
+B<ui64_i2s>,  
+B<ui64_add>,  
+B<ui64_addn>, 
+B<ui64_sub>,  
+B<ui64_subn>, 
+B<ui64_mul>,  
+B<ui64_muln>, 
+B<ui64_div>,  
+B<ui64_divn>, 
+B<ui64_and>,  
+B<ui64_or>,   
+B<ui64_xor>,  
+B<ui64_not>,  
+B<ui64_rol>,  
+B<ui64_ror>,  
+B<ui64_len>,  
+B<ui64_cmp>.  
 
 =head1 DESCRIPTION
 
-B<OSSP ui64> is a ...
+B<OSSP ui64> is a small B<ISO-C> library for portable 64-bit arithmetic.
 
-=head2 APPLICATION PROGRAMMER INTERFACE (API)
+=head1 APPLICATION PROGRAMMER INTERFACE (API)
 
-=head1 EXAMPLE
+=head2 Particular Values
 
-=head1 SEE ALSO
+API functions providing particular values:
 
-B<ISO-C> unsigned long long.
+=over 4
+
+=item ui64_t B<ui64_zero>(void);
+
+The value 0, expressed as an ui64_t.
+
+=item ui64_t B<ui64_max>(void);
+
+The maximum value expressable as an ui64_t.
+
+=back
+
+=head2 Import & Export
+
+API functions providing value importing and exporting to and from native
+B<ISO-C> representations:
+
+=over 4
+
+=item ui64_t B<ui64_n2i>(unsigned long I<n>);
+
+Import value from B<ISO-C> C<unsigned long> I<n>.
+
+=item unsigned long B<ui64_i2n>(ui64_t I<x>);
+
+Export value of I<x> to B<ISO-C> C<unsigned long>. This operation is not
+less-less if the 64-bit value in I<x> exceeds the B<ISO-C> value
+C<LONG_MAX>.
+
+=item ui64_t B<ui64_s2i>(const char *I<str>, char **I<end>, int I<base>);
+
+Import value from C<NUL>-terminated B<ISO-C> string representation
+starting at I<str>. The representation can have leading whitespaces and
+its (case-insensitive) digits (C<0>, ..., C<9>, C<A>, ..., C<Z>) are
+interpreted to base I<base>. I<base> has to be greater or equal 2 and
+less than 36. If I<end> is not C<NULL>, it is set to the first character
+after the imported value representation.
+
+=item char *B<ui64_i2s>(ui64_t I<x>, char *I<str>, size_t I<len>, int I<base>);
+
+Export value of I<x> to B<ISO-C> string representation. The
+representation consists of digits (C<0>, ..., C<9>, C<A>, ..., C<Z>) and
+form the value to base I<base>. I<base> has to be greater or equal 2 and
+less than 36. The representation is stored into the buffer starting at
+I<str> and lasting I<len> bytes.
+
+=back
+
+=head2 Arithmetical Operations
+
+API functions performing the standard arithmetical operations:
+
+=over 4
+
+=item ui64_t B<ui64_add>(ui64_t I<x>, ui64_t I<y>, ui64_t *I<ov>);
+
+Addition of I<x> and I<y>. 
+If I<ov> is not C<NULL>, it receives the overflow value of
+this operation (carry).
+
+=item ui64_t B<ui64_addn>(ui64_t I<x>, int I<y>, int *I<ov>);
+
+Same as B<ui64_add>, but I<y> and I<ov> are single digits to base 2^8.
+
+=item ui64_t B<ui64_sub>(ui64_t I<x>, ui64_t I<y>, ui64_t *I<ov>);
+
+Subtraction of I<y> from I<x>. 
+If I<ov> is not C<NULL>, it receives the overflow value of
+this operation (borrow).
+
+=item ui64_t B<ui64_subn>(ui64_t I<x>, int I<y>, int *I<ov>);
+
+Same as B<ui64_sub>, but I<y> and I<ov> are single digits to base 2^8.
+
+=item ui64_t B<ui64_mul>(ui64_t I<x>, ui64_t I<y>, ui64_t *I<ov>);
+
+Multiplication of I<x> and I<y>. 
+If I<ov> is not C<NULL>, it receives the overflow value of
+this operation).
+
+=item ui64_t B<ui64_muln>(ui64_t I<x>, int I<y>, int *I<ov>);
+
+Same as B<ui64_mul>, but I<y> and I<ov> are single digits to base 2^8.
+
+=item ui64_t B<ui64_div>(ui64_t I<x>, ui64_t I<y>, ui64_t *I<ov>);
+
+Division of I<x> by I<y>. 
+If I<ov> is not C<NULL>, it receives the overflow value of
+this operation (remainder).
+
+=item ui64_t B<ui64_divn>(ui64_t I<x>, int I<y>, int *I<ov>);
+
+Same as B<ui64_div>, but I<y> and I<ov> are single digits to base 2^8.
+
+=back
+
+=head2 Bit Operations
+
+API functions performing the standard bit-wise operations:
+
+=over 4
+
+=item ui64_t B<ui64_and>(ui64_t I<x>, ui64_t I<y>);
+
+Bit-wise I<AND> operation between I<x> and I<y>.
+
+=item ui64_t B<ui64_or>(ui64_t I<x>, ui64_t I<y>);
+
+Bit-wise I<OR> operation between I<x> and I<y>.
+
+=item ui64_t B<ui64_xor>(ui64_t I<x>, ui64_t I<y>);
+
+Bit-wise I<Exclusive-OR> operation between I<x> and I<y>.
+
+=item ui64_t B<ui64_not>(ui64_t I<x>);
+
+Bit-wise I<NOT> operation of I<x>.
+
+=item ui64_t B<ui64_rol>(ui64_t I<x>, int I<s>, ui64_t *I<ov>);
+
+Bit-wise I<Rotate-Left> operation by I<s> bits of I<x>.
+If I<ov> is not C<NULL>, it contains the out-rotated bits.
+
+=item ui64_t B<ui64_ror>(ui64_t I<x>, int I<s>, ui64_t *I<ov>);
+
+Bit-wise I<Rotate-Right> operation by I<s> bits of I<x>.
+If I<ov> is not C<NULL>, it contains the out-rotated bits.
+
+=back
+
+=head2 Other Operations
+
+=over 4
+
+=item int B<ui64_len>(ui64_t I<x>);
+
+Number of digits (1-8) to base 2^8 in I<x>.
+
+=item int B<ui64_cmp>(ui64_t I<x>, ui64_t I<y>);
+
+Comparison of I<x> and I<y> values. Returns C<-1>, C<0>
+or C<+1> if I<x> is less/equal/greater than I<y>.
+
+=back
 
 =head1 HISTORY
 

CVSTrac 2.0.1