Skip to content

Commit

Permalink
More progress on C documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Jul 8, 2024
1 parent 125042b commit a5f0c0d
Show file tree
Hide file tree
Showing 23 changed files with 84 additions and 103 deletions.
6 changes: 3 additions & 3 deletions docs/c/bcd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/c/fibonacci.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/c/iterator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 21 additions & 16 deletions docs/c/macros.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.

Expand All @@ -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::
6 changes: 2 additions & 4 deletions docs/c/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ math.h
a hard time including ``<stdlib.h>``.
.. 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::
7 changes: 3 additions & 4 deletions docs/c/p0002.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ C Implementation of Problem 2

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/c/p0002.c>`_

.. 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
Expand Down
7 changes: 3 additions & 4 deletions docs/c/p0003.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ C Implementation of Problem 3

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/c/p0003.c>`_

.. 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
Expand Down
7 changes: 3 additions & 4 deletions docs/c/p0004.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ C Implementation of Problem 4

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/c/p0004.c>`_

.. 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
Expand Down
8 changes: 4 additions & 4 deletions docs/c/p0005.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ C Implementation of Problem 5

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/c/p0005.c>`_

.. 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
Expand Down
6 changes: 0 additions & 6 deletions docs/c/p0006.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ C Implementation of Problem 6

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/c/p0006.c>`_

.. 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:
7 changes: 3 additions & 4 deletions docs/c/p0007.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ C Implementation of Problem 7

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/c/p0007.c>`_

.. 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
Expand Down
7 changes: 3 additions & 4 deletions docs/c/p0008.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ C Implementation of Problem 8

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/c/p0008.c>`_

.. 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
Expand Down
6 changes: 0 additions & 6 deletions docs/c/p0009.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ C Implementation of Problem 9

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/c/p0009.c>`_

.. 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:
7 changes: 3 additions & 4 deletions docs/c/p0010.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ C Implementation of Problem 10

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/c/p0010.c>`_

.. 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
Expand Down
7 changes: 3 additions & 4 deletions docs/c/p0011.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ C Implementation of Problem 11

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/c/p0011.c>`_

.. 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
Expand Down
11 changes: 7 additions & 4 deletions docs/c/p0012.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ C Implementation of Problem 12 (port in progress)

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/c/p0012.c>`_

.. 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
Expand Down
7 changes: 3 additions & 4 deletions docs/c/p0013.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ C Implementation of Problem 13

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/c/p0013.c>`_

.. 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
Expand Down
7 changes: 3 additions & 4 deletions docs/c/p0014.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ C Implementation of Problem 14

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/c/p0014.c>`_

.. 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
Expand Down
7 changes: 3 additions & 4 deletions docs/c/p0015.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ C Implementation of Problem 15

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/c/p0015.c>`_

.. 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
Expand Down
7 changes: 3 additions & 4 deletions docs/c/p0016.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ C Implementation of Problem 16

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/c/p0016.c>`_

.. 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
Expand Down
8 changes: 4 additions & 4 deletions docs/c/p0034.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ C Implementation of Problem 34

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/c/p0034.c>`_

.. 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
Expand Down
7 changes: 3 additions & 4 deletions docs/c/p0076.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ C Implementation of Problem 76

View source code `here on GitHub! <https://github.com/LivInTheLookingGlass/Euler/blob/master/c/p0076.c>`_

.. 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
Expand Down
Loading

0 comments on commit a5f0c0d

Please sign in to comment.