From a5f0c0db9af1abe6bac7623b39cb4792ee018aca Mon Sep 17 00:00:00 2001 From: Olivia Appleton Date: Sun, 7 Jul 2024 19:35:44 -0500 Subject: [PATCH] More progress on C documentation --- docs/c/bcd.rst | 6 +++--- docs/c/fibonacci.rst | 2 +- docs/c/iterator.rst | 2 +- docs/c/macros.rst | 37 +++++++++++++++++++++---------------- docs/c/math.rst | 6 ++---- docs/c/p0002.rst | 7 +++---- docs/c/p0003.rst | 7 +++---- docs/c/p0004.rst | 7 +++---- docs/c/p0005.rst | 8 ++++---- docs/c/p0006.rst | 6 ------ docs/c/p0007.rst | 7 +++---- docs/c/p0008.rst | 7 +++---- docs/c/p0009.rst | 6 ------ docs/c/p0010.rst | 7 +++---- docs/c/p0011.rst | 7 +++---- docs/c/p0012.rst | 11 +++++++---- docs/c/p0013.rst | 7 +++---- docs/c/p0014.rst | 7 +++---- docs/c/p0015.rst | 7 +++---- docs/c/p0016.rst | 7 +++---- docs/c/p0034.rst | 8 ++++---- docs/c/p0076.rst | 7 +++---- docs/c/primes.rst | 11 +++++------ 23 files changed, 84 insertions(+), 103 deletions(-) diff --git a/docs/c/bcd.rst b/docs/c/bcd.rst index eb708948..2b5a7b8a 100644 --- a/docs/c/bcd.rst +++ b/docs/c/bcd.rst @@ -72,12 +72,12 @@ It was also a good exercise in x86 assembly, as several portions are accellerate Returns ``x ** y``. .. c:function:: BCD_int mul_bcd_pow_10(BCD_int x, uintmax_t tens) -.. c:function:: BCD_int shift_bcd_left(BCD_int x, uintmax_t tens) + BCD_int shift_bcd_left(BCD_int x, uintmax_t tens) Returns ``x * 10**tens``. .. c:function:: BCD_int div_bcd_pow_10(BCD_int a, uintmax_t tens) -.. c:function:: BCD_int shift_bcd_right(BCD_int a, uintmax_t tens) + BCD_int shift_bcd_right(BCD_int a, uintmax_t tens) Returns ``x // 10**tens``. @@ -86,7 +86,7 @@ It was also a good exercise in x86 assembly, as several portions are accellerate Returns 1 if ``x > y``, -1 if ``y > x``, and otherwise 0. .. c:function:: void print_bcd(BCD_int x) -.. c:function:: void print_bcd_ln(BCD_int x) + void print_bcd_ln(BCD_int x) Writes a :c:type:`BCD_int` to `stdout`, and optionally adds a newline. diff --git a/docs/c/fibonacci.rst b/docs/c/fibonacci.rst index 18a2b190..3db3649e 100644 --- a/docs/c/fibonacci.rst +++ b/docs/c/fibonacci.rst @@ -25,7 +25,7 @@ fibonacci.h An indicator that flips every time the iterator moves. .. c:member:: uintmax_t a - .. c:member:: uintmax_t b + uintmax_t b .. c:member:: uintmax_t limit diff --git a/docs/c/iterator.rst b/docs/c/iterator.rst index a817ddf2..894be617 100644 --- a/docs/c/iterator.rst +++ b/docs/c/iterator.rst @@ -49,7 +49,7 @@ iterator.h argument should be a pointer to its iteration function. .. c:macro:: next(state) -.. c:macro:: next_p(state) + next_p(state) These macros implement the iteration operation. The only difference between them is that :c:macro:`next` takes in a struct and diff --git a/docs/c/macros.rst b/docs/c/macros.rst index ffe12da8..5f6fca6a 100644 --- a/docs/c/macros.rst +++ b/docs/c/macros.rst @@ -4,12 +4,12 @@ macros.h .. c:namespace-push:: macros .. c:macro:: CL_COMPILER -.. c:macro:: CLANG_COMPILER -.. c:macro:: GCC_COMPILER -.. c:macro:: INTEL_COMPILER -.. c:macro:: AMD_COMPILER -.. c:macro:: PCC_COMPILER -.. c:macro:: TCC_COMPILER + CLANG_COMPILER + GCC_COMPILER + INTEL_COMPILER + AMD_COMPILER + PCC_COMPILER + TCC_COMPILER These macros detect which compiler the program is being made with. They will be 1 if it is that compiler, and 0 otherwise. @@ -21,9 +21,9 @@ macros.h ``clang`` or ``aocc``. .. c:macro:: X64_COMPILER -.. c:macro:: X86_COMPILER -.. c:macro:: ARM_COMPILER -.. c:macro:: ARM_THUMB + X86_COMPILER + ARM_COMPILER + ARM_THUMB These macros attempt to detect the architecture the program is being compiled for. @@ -35,26 +35,31 @@ macros.h with static variables. .. c:macro:: max(a, b) -.. c:macro:: min(a, b) + min(a, b) If these were not already defined, this header makes them .. c:macro:: likely(x) -.. c:macro:: unlikely(x) + unlikely(x) These macros implement the ``likely()`` and ``unlikely()`` flags, as in the Linux kernel to assist in branch prediction. On ``tcc`` and ``cl`` it has no effect. .. c:macro:: MAX_FACTORIAL_64 20 -.. c:macro:: MAX_FACTORIAL_128 34 + MAX_FACTORIAL_128 34 + .. c:macro:: PCC_SQRT_ACCURACY 8 + .. c:macro:: MAX_POW_10_16 10000U -.. c:macro:: POW_OF_MAX_POW_10_16 4 + POW_OF_MAX_POW_10_16 4 + .. c:macro:: MAX_POW_10_32 1000000000UL -.. c:macro:: POW_OF_MAX_POW_10_32 9 + POW_OF_MAX_POW_10_32 9 + .. c:macro:: MAX_POW_10_64 10000000000000000000ULL -.. c:macro:: POW_OF_MAX_POW_10_64 19 + POW_OF_MAX_POW_10_64 19 + .. c:macro:: MAX_POW_10_128 ((uintmax_t) MAX_POW_10_64 * (uintmax_t) MAX_POW_10_64) -.. c:macro:: POW_OF_MAX_POW_10_128 38 + POW_OF_MAX_POW_10_128 38 .. c:namespace-pop:: diff --git a/docs/c/math.rst b/docs/c/math.rst index 63e8b1cf..55699e78 100644 --- a/docs/c/math.rst +++ b/docs/c/math.rst @@ -27,9 +27,7 @@ math.h a hard time including ````. .. c:function:: unsigned char imprecise_log10(uintmax_t x) - -.. c:function:: double sqrt(double S) - -.. c:function:: uintmax_t ceil(double x) + double sqrt(double S) + uintmax_t ceil(double x) .. c:namespace-pop:: diff --git a/docs/c/p0002.rst b/docs/c/p0002.rst index 33b443a5..2fe3bea2 100644 --- a/docs/c/p0002.rst +++ b/docs/c/p0002.rst @@ -3,11 +3,10 @@ C Implementation of Problem 2 View source code `here on GitHub! `_ -.. c:autosection:: Project Euler Problem 2 - :file: p0002.c +Includes +-------- -.. c:autodoc:: p0002.c - :clang: -std=c11 -DAMD_COMPILER=0 +- `fibonacci.h <./fibonacci.html>`__ .. literalinclude:: ../../c/p0002.c :language: C diff --git a/docs/c/p0003.rst b/docs/c/p0003.rst index e2053165..8a1f68a1 100644 --- a/docs/c/p0003.rst +++ b/docs/c/p0003.rst @@ -3,11 +3,10 @@ C Implementation of Problem 3 View source code `here on GitHub! `_ -.. c:autosection:: Project Euler Problem 3 - :file: p0003.c +Includes +-------- -.. c:autodoc:: p0003.c - :clang: -std=c11 -DAMD_COMPILER=0 +- `primes.h <./primes.html>`__ .. literalinclude:: ../../c/p0003.c :language: C diff --git a/docs/c/p0004.rst b/docs/c/p0004.rst index 39cf43e4..e9864353 100644 --- a/docs/c/p0004.rst +++ b/docs/c/p0004.rst @@ -3,11 +3,10 @@ C Implementation of Problem 4 View source code `here on GitHub! `_ -.. c:autosection:: Project Euler Problem 4 - :file: p0004.c +Includes +-------- -.. c:autodoc:: p0004.c - :clang: -std=c11 -DAMD_COMPILER=0 +- `iterator.h <./digits.html>`__ .. literalinclude:: ../../c/p0004.c :language: C diff --git a/docs/c/p0005.rst b/docs/c/p0005.rst index 0ef72c88..969b7851 100644 --- a/docs/c/p0005.rst +++ b/docs/c/p0005.rst @@ -3,11 +3,11 @@ C Implementation of Problem 5 View source code `here on GitHub! `_ -.. c:autosection:: Project Euler Problem 5 - :file: p0005.c +Includes +-------- -.. c:autodoc:: p0005.c - :clang: -std=c11 -DAMD_COMPILER=0 +- `macros.h <./macros.html>`__ +- `primes.h <./primes.html>`__ .. literalinclude:: ../../c/p0005.c :language: C diff --git a/docs/c/p0006.rst b/docs/c/p0006.rst index 22b43db4..fcb11a11 100644 --- a/docs/c/p0006.rst +++ b/docs/c/p0006.rst @@ -3,12 +3,6 @@ C Implementation of Problem 6 View source code `here on GitHub! `_ -.. c:autosection:: Project Euler Problem 1 - :file: p0006.c - -.. c:autodoc:: p0006.c - :clang: -std=c11 -DAMD_COMPILER=0 - .. literalinclude:: ../../c/p0006.c :language: C :linenos: diff --git a/docs/c/p0007.rst b/docs/c/p0007.rst index 50fbbefc..55c58c2a 100644 --- a/docs/c/p0007.rst +++ b/docs/c/p0007.rst @@ -3,11 +3,10 @@ C Implementation of Problem 7 View source code `here on GitHub! `_ -.. c:autosection:: Project Euler Problem 7 - :file: p0007.c +Includes +-------- -.. c:autodoc:: p0007.c - :clang: -std=c11 -DAMD_COMPILER=0 +- `primes.h <./primes.html>`__ .. literalinclude:: ../../c/p0007.c :language: C diff --git a/docs/c/p0008.rst b/docs/c/p0008.rst index f91a6103..568ae808 100644 --- a/docs/c/p0008.rst +++ b/docs/c/p0008.rst @@ -3,11 +3,10 @@ C Implementation of Problem 8 View source code `here on GitHub! `_ -.. c:autosection:: Project Euler Problem 8 - :file: p0008.c +Includes +-------- -.. c:autodoc:: p0008.c - :clang: -std=c11 -DAMD_COMPILER=0 +- `macros.h <./macros.html>`__ .. literalinclude:: ../../c/p0008.c :language: C diff --git a/docs/c/p0009.rst b/docs/c/p0009.rst index be2cddd9..151d2593 100644 --- a/docs/c/p0009.rst +++ b/docs/c/p0009.rst @@ -3,12 +3,6 @@ C Implementation of Problem 9 View source code `here on GitHub! `_ -.. c:autosection:: Project Euler Problem 9 - :file: p0009.c - -.. c:autodoc:: p0009.c - :clang: -std=c11 -DAMD_COMPILER=0 - .. literalinclude:: ../../c/p0009.c :language: C :linenos: diff --git a/docs/c/p0010.rst b/docs/c/p0010.rst index 7056ee42..c9fcf096 100644 --- a/docs/c/p0010.rst +++ b/docs/c/p0010.rst @@ -3,11 +3,10 @@ C Implementation of Problem 10 View source code `here on GitHub! `_ -.. c:autosection:: Project Euler Problem 10 - :file: p0010.c +Includes +-------- -.. c:autodoc:: p0010.c - :clang: -std=c11 -DAMD_COMPILER=0 +- `primes.h <./primes.html>`__ .. literalinclude:: ../../c/p0010.c :language: C diff --git a/docs/c/p0011.rst b/docs/c/p0011.rst index 19f1d04c..365c0452 100644 --- a/docs/c/p0011.rst +++ b/docs/c/p0011.rst @@ -3,11 +3,10 @@ C Implementation of Problem 11 View source code `here on GitHub! `_ -.. c:autosection:: Project Euler Problem 11 - :file: p0011.c +Includes +-------- -.. c:autodoc:: p0011.c - :clang: -std=c11 -DAMD_COMPILER=0 +- `macros.h <./macros.html>`__ .. literalinclude:: ../../c/p0011.c :language: C diff --git a/docs/c/p0012.rst b/docs/c/p0012.rst index 54702088..53b45c0c 100644 --- a/docs/c/p0012.rst +++ b/docs/c/p0012.rst @@ -3,11 +3,14 @@ C Implementation of Problem 12 (port in progress) View source code `here on GitHub! `_ -.. c:autosection:: Project Euler Problem 12 - :file: p0012.c +Includes +-------- -.. c:autodoc:: p0012.c - :clang: -std=c11 -DAMD_COMPILER=0 +- `macros.h <./macros.html>`__ + +.. note:: + + The port of this problem is still in progress .. literalinclude:: ../../c/p0012.c :language: C diff --git a/docs/c/p0013.rst b/docs/c/p0013.rst index 0efc677b..43500d48 100644 --- a/docs/c/p0013.rst +++ b/docs/c/p0013.rst @@ -3,11 +3,10 @@ C Implementation of Problem 13 View source code `here on GitHub! `_ -.. c:autosection:: Project Euler Problem 13 - :file: p0013.c +Includes +-------- -.. c:autodoc:: p0013.c - :clang: -std=c11 -DAMD_COMPILER=0 +- `bcd.h <./bcd.html>`__ .. literalinclude:: ../../c/p0013.c :language: C diff --git a/docs/c/p0014.rst b/docs/c/p0014.rst index 56fac882..1cf1c445 100644 --- a/docs/c/p0014.rst +++ b/docs/c/p0014.rst @@ -3,11 +3,10 @@ C Implementation of Problem 14 View source code `here on GitHub! `_ -.. c:autosection:: Project Euler Problem 14 - :file: p0014.c +Includes +-------- -.. c:autodoc:: p0014.c - :clang: -std=c11 -DAMD_COMPILER=0 +- `macros.h <./macros.html>`__ .. literalinclude:: ../../c/p0014.c :language: C diff --git a/docs/c/p0015.rst b/docs/c/p0015.rst index b5b0f90a..be0dc53f 100644 --- a/docs/c/p0015.rst +++ b/docs/c/p0015.rst @@ -3,11 +3,10 @@ C Implementation of Problem 15 View source code `here on GitHub! `_ -.. c:autosection:: Project Euler Problem 15 - :file: p0015.c +Includes +-------- -.. c:autodoc:: p0015.c - :clang: -std=c11 -DAMD_COMPILER=0 +- `math.h <./math.html>`__ .. literalinclude:: ../../c/p0015.c :language: C diff --git a/docs/c/p0016.rst b/docs/c/p0016.rst index 584c5fdf..b91e6a04 100644 --- a/docs/c/p0016.rst +++ b/docs/c/p0016.rst @@ -3,11 +3,10 @@ C Implementation of Problem 16 View source code `here on GitHub! `_ -.. c:autosection:: Project Euler Problem 16 - :file: p0016.c +Includes +-------- -.. c:autodoc:: p0016.c - :clang: -std=c11 -DAMD_COMPILER=0 +- `bcd.h <./bcd.html>`__ .. literalinclude:: ../../c/p0016.c :language: C diff --git a/docs/c/p0034.rst b/docs/c/p0034.rst index 8c5def4f..fd9fd538 100644 --- a/docs/c/p0034.rst +++ b/docs/c/p0034.rst @@ -3,11 +3,11 @@ C Implementation of Problem 34 View source code `here on GitHub! `_ -.. c:autosection:: Project Euler Problem 34 - :file: p0034.c +Includes +-------- -.. c:autodoc:: p0034.c - :clang: -std=c11 -DAMD_COMPILER=0 +- `digits.h <./digits.html>`__ +- `math.h <./math.html>`__ .. literalinclude:: ../../c/p0034.c :language: C diff --git a/docs/c/p0076.rst b/docs/c/p0076.rst index 151be5ad..8a8dc7ea 100644 --- a/docs/c/p0076.rst +++ b/docs/c/p0076.rst @@ -3,11 +3,10 @@ C Implementation of Problem 76 View source code `here on GitHub! `_ -.. c:autosection:: Project Euler Problem 76 - :file: p00076.c +Includes +-------- -.. c:autodoc:: p0076.c - :clang: -std=c11 -DAMD_COMPILER=0 +- `macros.h <./macros.html>`__ .. literalinclude:: ../../c/p0076.c :language: C diff --git a/docs/c/primes.rst b/docs/c/primes.rst index 520fa110..20bd6f88 100644 --- a/docs/c/primes.rst +++ b/docs/c/primes.rst @@ -8,7 +8,7 @@ primes.h Implements the :c:macro:`Iterator ` API and yields successive prime numbers. - .. c:member:: uintmax_t (*iterator_function)(*prime_counter) + .. c:member:: uintmax_t (*iterator_function)(*prime_counter pc) The function to advance the iterator and return the next element. @@ -35,8 +35,7 @@ primes.h .. c:member:: prime_sieve *ps .. c:function:: prime_counter prime_counter1(uintmax_t stop) - - .. c:function:: prime_counter prime_counter0() + prime_counter prime_counter0() .. c:function:: void free_prime_counter(prime_counter pc) @@ -44,7 +43,7 @@ primes.h An :c:macro:`Iterator ` that implements a modified sieve of eratosthenes - .. c:member:: uintmax_t (*iterator_function)(*prime_sieve) + .. c:member:: uintmax_t (*iterator_function)(*prime_sieve ps) The function to advance the iterator and return the next element. @@ -93,7 +92,7 @@ primes.h Implements the :c:macro:`Iterator ` API and yields successive prime factors. - .. c:member:: uintmax_t (*iterator_function)(*prime_factor_counter) + .. c:member:: uintmax_t (*iterator_function)(*prime_factor_counter pfc) The function to advance the iterator and return the next element. @@ -123,7 +122,7 @@ primes.h .. c:function:: prime_factor_counter prime_factors(uintmax_t n) - .. c:macro:: free_prime_factor_counter(pfc) + .. c:macro:: free_prime_factor_counter(pfc x) .. c:function:: uintmax_t is_composite(uintmax_t n)