aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas "Cakeisalie5" Touhey <thomas@touhey.fr>2018-06-20 05:44:18 +0200
committerThomas "Cakeisalie5" Touhey <thomas@touhey.fr>2018-06-20 05:44:18 +0200
commit313c7fdfb6257db3c847aeab44336b8c57da643b (patch)
treef4a859bf3dce81d6b33ee18fe8d1b54df805b9aa
parentc018b58150b67300e1f281568675beda2dc6ea9b (diff)
Still going on.
-rw-r--r--LICENSE.md11
-rw-r--r--LICENSE.rst14
-rwxr-xr-xMakefile3
-rw-r--r--README.md17
-rw-r--r--README.rst18
-rw-r--r--copyright.yml2
-rw-r--r--docs/authors.en.md8
-rw-r--r--docs/authors.en.rst12
-rw-r--r--docs/building.en.md84
-rw-r--r--docs/building.en.rst86
-rw-r--r--docs/coding.en.rst (renamed from docs/coding.en.md)14
-rw-r--r--docs/config.en.rst (renamed from docs/config.en.md)8
-rw-r--r--docs/contributing.en.md238
-rw-r--r--docs/contributing.en.rst292
-rw-r--r--docs/docs.en.md51
-rw-r--r--docs/docs.en.rst46
-rw-r--r--docs/index.en.rst (renamed from docs/index.en.md)44
-rw-r--r--docs/licensing.en.rst (renamed from docs/licensing.en.md)32
-rw-r--r--docs/preprocessor.en.md101
-rw-r--r--docs/preprocessor.en.rst228
-rw-r--r--docs/todo.en.rst (renamed from docs/todo.en.md)37
-rw-r--r--docs/tools/build-tools.en.rst (renamed from docs/tools/build-tools.en.md)183
-rw-r--r--docs/tools/index.en.md29
-rw-r--r--docs/tools/index.en.rst31
-rw-r--r--modules/all/core-sh/bits/byteswap.h14
-rw-r--r--modules/all/core-sh/copyright.yml2
-rw-r--r--modules/all/core-sh/docs/bits.en.md90
-rw-r--r--modules/all/core-sh/docs/bits.en.rst103
-rw-r--r--modules/all/core-sh/docs/index.en.md16
-rw-r--r--modules/all/core-sh/docs/index.en.rst18
-rw-r--r--modules/all/core-sh/docs/intrinsics.en.md242
-rw-r--r--modules/all/core-sh/docs/intrinsics.en.rst290
-rw-r--r--modules/all/core-sh/include/smachine.h20
-rw-r--r--modules/all/core-sh/info.yml2
-rw-r--r--modules/all/core-sh/roles.yml9
-rw-r--r--modules/all/core-sh/src/bswap16.s8
-rw-r--r--modules/all/core-sh/src/bswap32.s8
-rw-r--r--modules/all/core/copyright.yml4
-rw-r--r--modules/all/core/docs/bits.en.md152
-rw-r--r--modules/all/core/docs/bits.en.rst172
-rw-r--r--modules/all/core/docs/index.en.md11
-rw-r--r--modules/all/core/docs/index.en.rst16
-rw-r--r--modules/all/core/include/cdefs.h21
-rw-r--r--modules/all/core/include/endian.h9
-rw-r--r--modules/all/core/include/features.h46
-rw-r--r--modules/all/core/include/limits.h18
-rw-r--r--modules/all/core/include/stdarg.h1
-rw-r--r--modules/all/core/info.yml8
-rw-r--r--modules/all/core/roles.yml49
-rw-r--r--modules/all/ctype/copyright.yml2
-rw-r--r--modules/all/ctype/docs/index.en.rst (renamed from modules/all/ctype/docs/index.en.md)6
-rw-r--r--modules/all/errno-renesas/copyright.yml5
-rw-r--r--modules/all/errno-renesas/docs/index.en.md65
-rw-r--r--modules/all/errno/bits/string.h12
-rw-r--r--modules/all/errno/docs/index.en.rst4
-rw-r--r--modules/all/errno/include/errno.h29
-rw-r--r--modules/all/errno/info.yml5
-rw-r--r--modules/all/errno/roles.yml (renamed from modules/all/errno-renesas/roles.yml)0
-rw-r--r--modules/all/helloworld/copyright.yml2
-rw-r--r--modules/all/helloworld/docs/index.en.md13
-rw-r--r--modules/all/helloworld/docs/index.en.rst13
-rw-r--r--modules/all/hosted-sh/bits/setjmp.h (renamed from modules/all/core-sh/bits/setjmp.h)0
-rw-r--r--modules/all/hosted-sh/copyright.yml5
-rw-r--r--modules/all/hosted-sh/docs/index.en.rst4
-rw-r--r--modules/all/hosted-sh/info.yml7
-rw-r--r--modules/all/hosted-sh/roles.yml7
-rw-r--r--modules/all/hosted-sh/src/longjmp.s (renamed from modules/all/core-sh/src/longjmp.s)0
-rw-r--r--modules/all/hosted-sh/src/setjmp.s (renamed from modules/all/core-sh/src/setjmp.s)0
-rw-r--r--modules/all/hosted/copyright.yml10
-rw-r--r--modules/all/hosted/docs/bits.en.rst14
-rw-r--r--modules/all/hosted/docs/index.en.rst13
-rw-r--r--modules/all/hosted/include/assert.h (renamed from modules/all/core/include/assert.h)20
-rw-r--r--modules/all/hosted/include/complex.h (renamed from modules/all/core/include/complex.h)0
-rw-r--r--modules/all/hosted/include/errno.h (renamed from modules/all/core/include/errno.h)0
-rw-r--r--modules/all/hosted/include/fenv.h (renamed from modules/all/core/include/fenv.h)0
-rw-r--r--modules/all/hosted/include/inttypes.h (renamed from modules/all/core/include/inttypes.h)0
-rw-r--r--modules/all/hosted/include/locale.h (renamed from modules/all/core/include/locale.h)0
-rw-r--r--modules/all/hosted/include/setjmp.h (renamed from modules/all/core/include/setjmp.h)0
-rw-r--r--modules/all/hosted/include/signal.h (renamed from modules/all/core/include/signal.h)0
-rw-r--r--modules/all/hosted/include/stdatomic.h (renamed from modules/all/core/include/stdatomic.h)0
-rw-r--r--modules/all/hosted/include/stdfix.h (renamed from modules/all/core/include/stdfix.h)0
-rw-r--r--modules/all/hosted/include/stdlib.h (renamed from modules/all/core/include/stdlib.h)0
-rw-r--r--modules/all/hosted/info.yml5
-rw-r--r--modules/all/hosted/roles.yml46
-rw-r--r--modules/all/hosted/src/byteswap.c (renamed from modules/all/core/src/byteswap.c)0
-rw-r--r--modules/all/hosted/src/errno.c (renamed from modules/all/core/src/errno.c)0
-rw-r--r--modules/all/hosted/src/locales.c (renamed from modules/all/core/src/locales.c)0
-rw-r--r--modules/all/hosted/src/stdlib/div.c (renamed from modules/all/core/src/stdlib/div.c)0
-rw-r--r--modules/all/hosted/src/stdlib/rand.c (renamed from modules/all/core/src/stdlib/rand.c)0
-rw-r--r--modules/all/hosted/src/stdlib/wchar.c (renamed from modules/all/core/src/stdlib/wchar.c)0
-rw-r--r--modules/all/iconv-unicode/bits/iconv_proto.h18
-rw-r--r--modules/all/iconv-unicode/bits/iconv_route.h34
-rw-r--r--modules/all/iconv-unicode/copyright.yml5
-rw-r--r--modules/all/iconv-unicode/docs/index.en.rst13
-rw-r--r--modules/all/iconv-unicode/info.yml5
-rw-r--r--modules/all/iconv-unicode/roles.yml8
-rw-r--r--modules/all/iconv-unicode/src/utf8_to_utf32.c76
-rw-r--r--modules/all/iconv-unicode/src/utf8_to_wchar.c (renamed from modules/all/iconv/src/conv/utf8_to_wchar.c)53
-rw-r--r--modules/all/iconv-unicode/src/wchar_to_utf8.c (renamed from modules/all/iconv/src/conv/wchar_to_utf8.c)122
-rw-r--r--modules/all/iconv/copyright.yml2
-rw-r--r--modules/all/iconv/docs/index.en.md12
-rw-r--r--modules/all/iconv/docs/index.en.rst17
-rw-r--r--modules/all/iconv/include/iconv.h109
-rw-r--r--modules/all/iconv/roles.yml3
-rw-r--r--modules/all/iconv/src/iconv.h42
-rw-r--r--modules/all/iconv/src/open.c3
-rw-r--r--modules/all/iconv/src/routes.c24
-rw-r--r--modules/all/info.yml9
-rw-r--r--modules/all/io/copyright.yml4
-rw-r--r--modules/all/io/docs/index.en.md4
-rw-r--r--modules/all/io/docs/index.en.rst4
-rw-r--r--modules/all/io/include/stdio.h3
-rw-r--r--modules/all/math/copyright.yml2
-rw-r--r--modules/all/math/docs/index.en.rst (renamed from modules/all/math/docs/index.en.md)6
-rw-r--r--modules/all/mem/copyright.yml2
-rw-r--r--modules/all/mem/docs/index.en.rst (renamed from modules/all/mem/docs/index.en.md)54
-rw-r--r--modules/all/mem/docs/tweaking.en.md32
-rw-r--r--modules/all/mem/docs/tweaking.en.rst32
-rw-r--r--modules/all/stdcocorico/copyright.yml4
-rw-r--r--modules/all/stdcocorico/docs/index.en.md8
-rw-r--r--modules/all/stdcocorico/docs/index.en.rst8
-rw-r--r--modules/all/stdcocorico/include/stdcocorico.h3
-rw-r--r--modules/all/string-sh/copyright.yml2
-rw-r--r--modules/all/string/docs/index.en.rst (renamed from modules/all/string/docs/index.en.md)18
-rw-r--r--modules/all/string/docs/memory.en.md63
-rw-r--r--modules/all/string/docs/memory.en.rst71
-rw-r--r--modules/all/string/docs/strings.en.md94
-rw-r--r--modules/all/string/docs/strings.en.rst109
-rw-r--r--modules/all/time/copyright.yml2
-rw-r--r--modules/all/time/docs/bits.en.md7
-rw-r--r--modules/all/time/docs/bits.en.rst11
-rw-r--r--modules/all/time/docs/index.en.rst (renamed from modules/all/time/docs/index.en.md)12
-rw-r--r--modules/casiowin/copyright.yml2
-rw-r--r--modules/casiowin/core-crt/copyright.yml2
-rw-r--r--modules/casiowin/core-crt/docs/index.en.md6
-rw-r--r--modules/casiowin/core-crt/docs/index.en.rst6
-rw-r--r--modules/casiowin/core-crt/src/crt0.c55
-rw-r--r--modules/casiowin/core/copyright.yml2
-rw-r--r--modules/casiowin/core/docs/index.en.rst (renamed from modules/casiowin/core/docs/index.en.md)10
-rw-r--r--modules/casiowin/core/src/assert/assert.c31
-rw-r--r--modules/casiowin/core/src/dirent/error.c1
-rw-r--r--modules/casiowin/core/src/dirent/open.c28
-rw-r--r--modules/casiowin/core/src/io/open.c4
-rw-r--r--modules/casiowin/easy-input/copyright.yml4
-rw-r--r--modules/casiowin/easy-input/docs/index.en.md9
-rw-r--r--modules/casiowin/easy-input/docs/index.en.rst8
-rw-r--r--modules/casiowin/easy-input/include/EasyInput.h23
-rw-r--r--modules/casiowin/easy-input/src/main.c397
-rw-r--r--modules/casiowin/fxlib/bits/cdefs.h17
-rw-r--r--modules/casiowin/fxlib/bits/fxlib/app.h (renamed from modules/casiowin/fxlib/include/fxlib/app.h)57
-rw-r--r--modules/casiowin/fxlib/bits/fxlib/battery.h (renamed from modules/casiowin/fxlib/include/fxlib/battery.h)7
-rw-r--r--modules/casiowin/fxlib/bits/fxlib/bcd.h (renamed from modules/casiowin/fxlib/include/fxlib/bcd.h)41
-rw-r--r--modules/casiowin/fxlib/bits/fxlib/clock.h (renamed from modules/casiowin/fxlib/include/fxlib/clock.h)1
-rw-r--r--modules/casiowin/fxlib/bits/fxlib/comm.h (renamed from modules/casiowin/fxlib/include/fxlib/comm.h)84
-rw-r--r--modules/casiowin/fxlib/bits/fxlib/display.h (renamed from modules/casiowin/fxlib/include/fxlib/display.h)121
-rw-r--r--modules/casiowin/fxlib/bits/fxlib/file.h (renamed from modules/casiowin/fxlib/include/fxlib/file.h)59
-rw-r--r--modules/casiowin/fxlib/bits/fxlib/keyboard.h (renamed from modules/casiowin/fxlib/include/fxlib/keyboard.h)48
-rw-r--r--modules/casiowin/fxlib/bits/fxlib/serial.h (renamed from modules/casiowin/fxlib/include/fxlib/serial.h)20
-rw-r--r--modules/casiowin/fxlib/bits/fxlib/timer.h (renamed from modules/casiowin/fxlib/include/fxlib/timer.h)21
-rw-r--r--modules/casiowin/fxlib/copyright.yml2
-rw-r--r--modules/casiowin/fxlib/docs/char.en.rst (renamed from modules/casiowin/fxlib/docs/char.en.md)16
-rw-r--r--modules/casiowin/fxlib/docs/clock.en.rst (renamed from modules/casiowin/fxlib/docs/clock.en.md)6
-rw-r--r--modules/casiowin/fxlib/docs/comm.en.md85
-rw-r--r--modules/casiowin/fxlib/docs/comm.en.rst93
-rw-r--r--modules/casiowin/fxlib/docs/draw.en.md301
-rw-r--r--modules/casiowin/fxlib/docs/draw.en.rst323
-rw-r--r--modules/casiowin/fxlib/docs/file.en.md322
-rw-r--r--modules/casiowin/fxlib/docs/file.en.rst357
-rw-r--r--modules/casiowin/fxlib/docs/index.en.rst (renamed from modules/casiowin/fxlib/docs/index.en.md)55
-rw-r--r--modules/casiowin/fxlib/docs/keys.en.rst (renamed from modules/casiowin/fxlib/docs/keys.en.md)80
-rw-r--r--modules/casiowin/fxlib/docs/timer.en.rst (renamed from modules/casiowin/fxlib/docs/timer.en.md)34
-rw-r--r--modules/casiowin/fxlib/include/commbios.h113
-rw-r--r--modules/casiowin/fxlib/include/fxlib.h31
-rw-r--r--modules/casiowin/fxlib/include/fxlib/cdefs.h47
-rw-r--r--modules/casiowin/fxlib/include/fxlib/syscall.h42
-rw-r--r--modules/casiowin/fxlib/roles.yml3
-rw-r--r--modules/casiowin/info.yml7
-rw-r--r--modules/casiowin/io/copyright.yml2
-rw-r--r--modules/casiowin/io/src/io.h16
-rw-r--r--modules/casiowin/io/src/open.c9
-rw-r--r--modules/casiowin/io/src/read.c1
-rw-r--r--modules/casiowin/libfxsys/copyright.yml2
-rw-r--r--modules/casiowin/libfxsys/docs/index.en.rst (renamed from modules/casiowin/libfxsys/docs/index.en.md)6
-rw-r--r--modules/casiowin/monochromelib/copyright.yml2
-rw-r--r--modules/casiowin/monochromelib/docs/bmp.en.rst (renamed from modules/casiowin/monochromelib/docs/bmp.en.md)6
-rw-r--r--modules/casiowin/monochromelib/docs/draw.en.rst (renamed from modules/casiowin/monochromelib/docs/draw.en.md)6
-rw-r--r--modules/casiowin/monochromelib/docs/index.en.rst (renamed from modules/casiowin/monochromelib/docs/index.en.md)22
-rw-r--r--modules/casiowin/monochromelib/docs/screen.en.md34
-rw-r--r--modules/casiowin/monochromelib/docs/screen.en.rst40
-rw-r--r--modules/casiowin/monochromelib/docs/vram.en.md72
-rw-r--r--modules/casiowin/monochromelib/docs/vram.en.rst82
-rw-r--r--modules/compiler/host-gcc-sh/copyright.yml2
-rw-r--r--modules/compiler/host-gcc-sh/docs/index.en.rst (renamed from modules/compiler/host-gcc-sh/docs/index.en.md)6
-rw-r--r--modules/compiler/host-gcc/copyright.yml2
-rw-r--r--modules/compiler/host-gcc/docs/index.en.rst (renamed from modules/compiler/host-gcc/docs/index.en.md)6
-rw-r--r--modules/compiler/host-renesas/bits/compiler.h10
-rw-r--r--modules/compiler/host-renesas/bits/endian.h2
-rw-r--r--modules/compiler/host-renesas/copyright.yml2
-rw-r--r--modules/compiler/host-renesas/docs/index.en.rst (renamed from modules/compiler/host-renesas/docs/index.en.md)9
-rw-r--r--modules/compiler/info.yml9
-rw-r--r--modules/compiler/target-renesas/bits/primitive.h11
-rw-r--r--modules/compiler/target-renesas/copyright.yml2
-rw-r--r--modules/renesas/errno/bits/errno.h (renamed from modules/all/errno-renesas/bits/errno.h)30
-rw-r--r--modules/renesas/errno/copyright.yml5
-rw-r--r--modules/renesas/errno/docs/index.en.rst65
-rw-r--r--modules/renesas/errno/info.yml (renamed from modules/all/errno-renesas/info.yml)2
-rw-r--r--modules/renesas/errno/roles.yml6
-rw-r--r--modules/renesas/errno/src/errlist.c45
-rw-r--r--modules/renesas/info.yml9
-rwxr-xr-xtools/Internals/arch.py3
-rwxr-xr-xtools/Internals/project.py17
-rwxr-xr-xtools/configure.py22
212 files changed, 4400 insertions, 3461 deletions
diff --git a/LICENSE.md b/LICENSE.md
deleted file mode 100644
index 973a5d3..0000000
--- a/LICENSE.md
+++ /dev/null
@@ -1,11 +0,0 @@
-# libcarrot license
-![][flg-en] All of the files do not necessarily belong to the same
-people/organizations, and are not always placed under the same licenses,
-see <docs/licensing.en.md> for more details.
-
-![][flg-fr] Tous les fichiers ne sont pas nécessairement détenus par les
-mêmes personnes/organisations, et ne sont pas toujours placés sous les
-mêmes licences, voyez <docs/licensing.fr.md> pour plus d'informations.
-
-[flg-en]: docs/flags/gb.png
-[flg-fr]: docs/flags/fr.png
diff --git a/LICENSE.rst b/LICENSE.rst
new file mode 100644
index 0000000..4b1bdac
--- /dev/null
+++ b/LICENSE.rst
@@ -0,0 +1,14 @@
+libcarrot license
+=================
+
+|flag-en| All of the files do not necessarily belong to the same
+people/organizations, and are not always placed under the same licenses,
+see `licensing <docs/licensing.en.rst>`_ for more details.
+
+|flag-fr| Tous les fichiers ne sont pas nécessairement détenus par les
+mêmes personnes/organisations, et ne sont pas toujours placés sous les
+mêmes licences, voyez `licensing <docs/licensing.fr.rst>`_ pour
+davantage d'informations.
+
+.. |flag-en| image:: docs/flags/gb.png
+.. |flag-fr| image:: docs/flags/fr.png
diff --git a/Makefile b/Makefile
index dd69b61..ee23a39 100755
--- a/Makefile
+++ b/Makefile
@@ -5,10 +5,9 @@
define make-rule
$1:
$(MK) $1
-
-.PHONY: $1
endef
$(foreach cmd,$(CMDS),\
$(eval $(call make-rule,$(cmd))))
+.PHONY: $(CMDS)
# End of file.
diff --git a/README.md b/README.md
deleted file mode 100644
index a3ed616..0000000
--- a/README.md
+++ /dev/null
@@ -1,17 +0,0 @@
-# libcarrot - an experimental and modular libc for learning
-![][flg-en] The description and documentation of this project have moved to
-the <docs/> folder, with the other documentation files (except module-specific
-ones); check the files ending with `.en.md`. You can also check out
-[the official website][web-en]!
-
-![][flg-fr] La description et la documentation de ce projet ont été déplacées
-dans le dossier <docs/>, avec les autres pages de documentation (excepté
-les pages spécifiques à un module) ; cherchez les fichiers dont le nom
-se termine par `.fr.md`. Vous pouvez également jeter un œil
-[au site officiel][web-fr] !
-
-[flg-en]: /assets/flags/gb-3e37637a7e86a060c93293e062a5529ba164b5b9ce9b8e2a27eb9a7f5865142f.png
-[web-en]: https://libcarrot.touhey.fr/index.en.html
-
-[flg-fr]: /assets/flags/fr-1b06ee231b699f404732068f52a5686870aa35b9c3261b4ce4e7dbf576804beb.png
-[web-fr]: https://libcarrot.touhey.fr/index.fr.html
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..2dddbbe
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,18 @@
+libcarrot - an experimental and modular libc for learning
+=========================================================
+
+|flag-en| The description and documentation of this project have moved to
+the <docs/> folder, with the other documentation files (except module-specific
+ones); check the files ending with ``.en.rst``. You can also check out
+`the official website <web-en_>`_!
+
+|flag-fr| La description et la documentation de ce projet ont été déplacées
+dans le dossier <docs/>, avec les autres pages de documentation (excepté
+les pages spécifiques à un module) ; cherchez les fichiers dont le nom
+se termine par ``.fr.rst``. Vous pouvez également jeter un œil
+`au site officiel <web-fr_>`_ !
+
+.. _web-en: https://libcarrot.touhey.fr/index.en.html
+.. _web-fr: https://libcarrot.touhey.fr/index.fr.html
+.. |flag-en| image:: docs/flags/gb.png
+.. |flag-fr| image:: docs/flags/fr.png
diff --git a/copyright.yml b/copyright.yml
index 857b607..feaa23c 100644
--- a/copyright.yml
+++ b/copyright.yml
@@ -16,4 +16,4 @@ files:
- 'make.bat'
- 'requirements.txt'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
diff --git a/docs/authors.en.md b/docs/authors.en.md
deleted file mode 100644
index 5a081ae..0000000
--- a/docs/authors.en.md
+++ /dev/null
@@ -1,8 +0,0 @@
----
-title: libcarrot authors and maintainers
----
-This version, commonly called "the upstream", of libcarrot is maintained by
-its original author, Thomas "Cakeisalie5" Touhey <<thomas@touhey.fr>>.
-
-If not stated otherwise, each file belongs to its author(s), which are
-determined through the `copyright.yml` files (see <licensing.en.md>).
diff --git a/docs/authors.en.rst b/docs/authors.en.rst
new file mode 100644
index 0000000..6c1e65a
--- /dev/null
+++ b/docs/authors.en.rst
@@ -0,0 +1,12 @@
+libcarrot authors and maintainers
+=================================
+
+The version of libcarrot at <https//forge.touhey.fr/libcarrot.git>_, commonly
+called “the upstream”, is maintained by its original author,
+`Thomas Touhey`_ <thomas@touhey.fr>.
+
+If not stated otherwise, each file belongs to its author(s), who are
+determined through the ``copyright.yml`` files (see :ref:`licensing`).
+
+.. _Thomas Touhey: https://thomas.touhey.fr/
+.. _licensing: licensing.en
diff --git a/docs/building.en.md b/docs/building.en.md
deleted file mode 100644
index 37164f2..0000000
--- a/docs/building.en.md
+++ /dev/null
@@ -1,84 +0,0 @@
----
-title: Building libcarrot
----
-Once you've acknowledged [the basic principles of libcarrot](index.en.md),
-you can start building it.
-
-# Requirements
-You will need Python 3.x to run the build tool, with the modules described
-in the `requirements.txt` file, which you can install using
-`pip3 install -r requirements.txt` as root/administrator.
-
-Other dependencies (compilers, assemblers, linkers, packers, ...) are optional,
-and should be tipped off by the tools.
-
-# Configuring
-This project uses the Unix building flow, which means you shall first
-configure with the options that suit your needs, then make (build), then
-install, in three different commands. On Unix-like OSes, this can be achieved
-using the famous `./configure && make && sudo make install` bash command;
-but I'll suppose you want to go a little deeper into its options.
-
-The 'real' configure script is in `tool/configure.py`, though it can be
-accessed under Unix-like OSes through the `configure` bash script and under
-Microsoft Windows' command shell through the `configure.bat` script,
-for simplicity. `-h`/`--help` prints the help message, listing the options
-and a little help message, `-v`/`--version` prints the project version.
-
-libcarrot is built for a target, which is a combination of the following
-elements, separated by dashes:
-
-- **an architecture**, which represents the hardware (or hardware
- emulation layer) on which the code will run, more specifically the
- processor (e.g. the Intel i686 microprocessor or the SuperH Core 3);
-- **a system**, which is the kernel/OS (or kernel/OS emulation layer)
- on which the code will run (e.g. Linux);
-- **an ABI**, which represents the binary format and calling conventions
- that will be used for the system (every system supported by libcarrot
- has a default ABI).
-
-To select the target, you shall use the `--target` option with the value
-being the architecture then the system, separated with a dash, e.g.
-`sh3eb-casiowin` for CASIOWIN on a SuperH Core 3 microprocessor on
-big-endian mode.
-
-Out of the target, there is something important you will probably want to set
-the set of formats used for development files. These are regrouped in
-libcarrot under the `--flavour` option. The default flavour uses the 'elf'
-style of development files (ELF for objects, COFF for archives).
-
-You can also select the programming languages libcarrot shall support with
-the `--languages` option, with the languages being separated with commas,
-for example, `--languages=c,c++`. libcarrot currently only supports C.
-
-In addition to this, there is the `--add` option to add additional modules
-to the usual selected one. For example, if you're allowing yourself some
-fantasy, you can add the `all/stdcocorico` module, which will add the
-joke `stdcocorico.h` header to your programs so you can code in a french
-C or C++ dialect.
-
-Once you've fiddled with the configure options, you can select the
-installation directories and options! (TODO: document these once they're ready)
-
-Here are some examples:
-
-```bash
-# shared libraries for linux, with some more modules
-./configure --target=x86_64-linux --shared \
- --add all/stdcocorico --add all/helloworld
-
-# static libraries for casiowin for use by the Renesas toolchain
-./configure --target=sh3eb-casiowin --flavour=renesas
-```
-
-# Building and installing
-Once the project is configured, you can `make` under UNIX-like OSes,
-`make.bat` under Microsoft Windows (using the command shell), or
-`tools/make.py` on any other system.
-
-There are actually a few other commands you can do with `make`, such as
-`clean` to remove generated files (excepted the configuration),
-`mrproper` or `distclean` to remove everything (including the configuration),
-`re` to remake everything (expected the configuration).
-
-To install the library, use `make install`.
diff --git a/docs/building.en.rst b/docs/building.en.rst
new file mode 100644
index 0000000..c120f4e
--- /dev/null
+++ b/docs/building.en.rst
@@ -0,0 +1,86 @@
+Building libcarrot
+==================
+
+Once you've acknowledged `the basic principles of libcarrot <index>`_,
+you can start building it.
+
+Requirements
+------------
+
+You will need Python 3.x to run the build tool, with the modules described
+in the ``requirements.txt`` file, which you can install using
+``pip3 install -r requirements.txt`` as root/administrator.
+
+Other dependencies (compilers, assemblers, linkers, packers, ...) are optional,
+and should be tipped off by the tools.
+
+Configuring
+-----------
+
+This project uses the Unix building flow, which means you shall first
+configure with the options that suit your needs, then make (build), then
+install, in three different commands. On Unix-like OSes, this can be achieved
+using the famous ``./configure && make && sudo make install`` bash command;
+but I'll suppose you want to go a little deeper into its options.
+
+The 'real' configure script is in ``tool/configure.py``, though it can be
+accessed under Unix-like OSes through the `configure` bash script and under
+Microsoft Windows' command shell through the ``configure.bat`` script,
+for simplicity. ``-h``/``--help`` prints the help message, listing the options
+and a little help message, ``-v``/``--version`` prints the project version.
+
+libcarrot is built for a target, which is a combination of the following
+elements, separated by dashes:
+
+- **an architecture**, which represents the hardware (or hardware
+ emulation layer) on which the code will run, more specifically the
+ processor (e.g. the Intel i686 microprocessor or the SuperH Core 3);
+- **a system**, which is the kernel/OS (or kernel/OS emulation layer)
+ on which the code will run (e.g. Linux);
+- **an ABI**, which represents the binary format and calling conventions
+ that will be used for the system (every system supported by libcarrot
+ has a default ABI).
+
+To select the target, you shall use the ``--target`` option with the value
+being the architecture then the system, separated with a dash, e.g.
+``sh3eb-casiowin`` for CASIOWIN on a SuperH Core 3 microprocessor on
+big-endian mode.
+
+Out of the target, there is something important you will probably want to set
+the set of formats used for development files. These are regrouped in
+libcarrot under the ``--flavour`` option. The default flavour uses the 'elf'
+style of development files (ELF for objects, COFF for archives).
+
+In addition to this, there is the ``--add`` option to add additional modules
+to the usual selected one. For example, if you're allowing yourself some
+fantasy, you can add the ``all/stdcocorico`` module, which will add the
+joke ``stdcocorico.h`` header to your programs so you can code in a french
+C dialect.
+
+Once you've fiddled with the configure options, you can select the
+installation directories and options! (TODO: document these once they're ready)
+
+Here are some examples:
+
+.. code-block:: bash
+
+ # shared libraries for linux, with some more modules
+ ./configure --target=x86_64-linux --shared \
+ --add all/stdcocorico --add all/helloworld
+
+ # static libraries for casiowin for use by the Renesas toolchain
+ ./configure --target=sh3eb-casiowin --flavour=renesas
+
+Building and installing
+-----------------------
+
+Once the project is configured, you can ``make`` under UNIX-like OSes,
+``make.bat`` under Microsoft Windows (using the command shell), or
+``tools/make.py`` on any other system.
+
+There are actually a few other commands you can do with ``make``, such as
+``clean`` to remove generated files (excepted the configuration),
+``mrproper`` or ``distclean`` to remove everything (including the
+configuration), ``re`` to remake everything (expected the configuration).
+
+To install the library, use ``make install``.
diff --git a/docs/coding.en.md b/docs/coding.en.rst
index 6a965c8..790ca1f 100644
--- a/docs/coding.en.md
+++ b/docs/coding.en.rst
@@ -1,14 +1,16 @@
----
-title: The libcarrot coding style
----
+The libcarrot coding style
+==========================
+
This coding style is the one the libcarrot project uses — see
-<contributing.en.md> for a more general guide about how
-to contribute, or the rest of this guide for how to code in this project.
+:ref:`contributing` for a more general guide about how to
+contribute, or the rest of this guide for how to code in this project.
-A good place to start is
+A good place to start is `the libcarrot preprocessor guide`
[the libcarrot preprocessor guide](preprocessor.en.md).
This file is to re-write (TODO), as many things have been rethought
(top comments are now generated, the super-preprocessor has been
introducted with include guards, many macros for internal use such as `_OF`
have to be used, and stuff).
+
+.. _the contributing guide: contributing.en
diff --git a/docs/config.en.md b/docs/config.en.rst
index 33e0c6d..dea3b5a 100644
--- a/docs/config.en.md
+++ b/docs/config.en.rst
@@ -1,6 +1,6 @@
----
-title: libcarrot configuration format
----
+libcarrot configuration format
+==============================
+
In [the build process](building.en.md), the first step is configuration
using the `tools/configure.py` utility. This file describes the configuration
format that this utility produces, and that the other utilities will
@@ -37,7 +37,7 @@ This property is splitted into two different properties:
- `params`: the tools configuration.
Each one of these is a dictionary, linking tool types (`cc` for C compilers,
-`cxx` for C++ compilers, ...) to tool identifiers for `ids` (a two-element
+…) to tool identifiers for `ids` (a two-element
list containing the manufacturer and tool name as strings) and a
tool-dependant configuration in `params` (could be a dictionary or anything).
diff --git a/docs/contributing.en.md b/docs/contributing.en.md
deleted file mode 100644
index 70d7dc2..0000000
--- a/docs/contributing.en.md
+++ /dev/null
@@ -1,238 +0,0 @@
----
-title: Contributing to libcarrot
----
-First of all, thanks for reading this! It probably means you think libcarrot
-might be worth the effort you are going to put in it, and that rocks! :D
-
-As I want to keep things clean and organized for anyone using this library,
-I'm defining this set of rules (from my own personal coding style, as it is
-how I started this project). Some are justified from a technical point of view,
-and some are not. Don't think it's against you or anything: I just don't
-want this project to be a coding style mess, where you have to learn a new
-coding style before contributing to any new header/source file.
-
-Any disrespect to those rules in your contribution will make your contribution
-not merged upstream until you respect them (this doesn't mean it will always
-be accepted if you respect them, don't get me wrong). If you think one of the
-rules should really be abolished/is not productive at all, you should discuss
-with the current maintainer(s) about it: they have the authority here.
-
-If you have any questions about some obscure point of this contribution guide,
-or you have deduced something from the existing codebase and noticed it was
-not described here (it should, but writing a contribution guide is far from
-being easy), please suggest the changes (by proposing commits or tipping off
-the maintainer(s))!
-
-# File organization
-The modules (see [the introduction](index.en.md) for more about modules and
-systems) are located in `./modules`. They are grouped by systems (folders
-representing them). Here's an example `./modules` arborescence:
-
- info.yml (global information file)
- all/
- info.yml (`all` system information file)
- core/
- (`all/core` module related stuff)
- other/
- (`all/other` module related stuff)
- mysys/
- info.yml (`mysys` system information file)
- core/
- (`mysys/core` module related stuff)
-
-Every system has an information file, described in its own section.
-
-Modules have the following organization ("opt." means "optional", "req." means
-"required", "rec." means "recommended"):
-
-- `include/` (opt.): the C/C++ source headers folder;
-- `bits/` (opt.): the C/C++ header bits folder;
-- `src/` (opt.): the C/C++/ASM source files folder;
-- `docs/` (opt.): the documentation folder;
-- `man/` (opt.): the manpages corresponding to the module;
-- `info.yml` (req.): the module information file;
-- `copyright.yml` (rec.): machine-readable copyright information file;
-- `roles.yml` (rec.): machine-readable roles for your source files.
-
-In order not to make a coding style patchwork out of this project, you really
-should follow the project's coding style — see <coding.en.md>.
-
-`copyright.yml` defines the license of each file (see <licensing.en.md>).
-The other files' roles and structures are defined below.
-
-## Global information file
-The global information file gives information about libcarrot. It is located
-at `modules/info.yml`, and is a YAML-encoded configuration, with the
-following properties:
-
-- `magic`: should be equal to `potatosdk-1.0`;
-- `version`: the version details, with the following properties:
-
- - `major`: the major version (integer);
- - `minor`: the minor version (integer);
- - `indev`: whether the current version is in development or not (default:
- `false`).
-
-An example configuration is the following:
-
-```yaml
-%YAML 1.2
----
-magic: potatosdk-1.0
-version:
- major: 5
- minor: 11
- indev: true
-```
-
-## System and meta-system information file
-Every system has a few properties, regrouped in a system information file and
-located at `modules/<system>/info.yml`. It is a YAML-encoded configuration,
-with the following properties:
-
-- `magic`: should be equal to `potatosdk-1.0`;
-- `description`: the platform description;
-- `abi`: the list of binary interfaces for applications (file formats, calling
- conventions, ...), with keywords the build tools will understand;
-- `default`: the {language => modules list} dictionary defining the system
- default modules, that will be included if the system is targetted or if it
- is a meta-system and it's imported by the targetted system. Modules from
- meta-systems should not be included directly, please use the `meta` property
- described below to import all of the defaults from the meta-system;
-- `import`: the list of meta-systems to import. Default modules from this other
- platform are included in this one's;
-- `requires`: the requirements for this platform to be targetted or imported,
- with the following propreties:
-
- - `arch`: the list of architectures the system supports (if not precised,
- all architectures are accepted).
-
-If the list of ABIs is empty (or the ABI property is simply not defined), the
-system is considered to be a meta-system. An example configuration is the
-following:
-
-```yaml
-%YAML 1.2
----
-magic: potatosdk-1.0
-description: >-
- That incredible system we should all switch to.
-default:
- c:
- - mysys/somepackage
- - mysys/someotherpackage
- c++:
- - mysys/thatpackage
- - another/thatotherpackage
-import:
-- all
-requires:
- arch:
- - sh3
- - sh4a
-```
-
-Notice that C dependencies will be considered C++ dependencies too.
-
-## Module information file
-Every module has a set of properties too, regrouped in a module information
-file located at `modules/<system>/<module>/info.yml`. It is a YAML-encoded
-configuration, with the following properties:
-
-- `magic`: should be equal to `potatosdk-1.0`;
-- `description`: the module description (what features it brings, for which
- constraints, etc);
-- `deps`: the module dependencies (preferably excluding language-related
- dependencies);
-- `license`: the license for the module (either `free` or `proprietary`,
- default is `free`). See <licensing.en.md> for more details;
-- `conflicts`: the module(s) this module shouldn't be selected with;
-- `requires`: the requirements for this module to be selected to be selected,
- with the following properties:
-
- - `arch`: the subset of architectures the module supports (from the system
- ones). If not precised, all the system architectures are selected;
- - `compiler`: the list of compilers the module supports, e.g. `[GNU, GCC]`.
-
-An example configuration is the following:
-
-```yaml
-%YAML 1.2
----
-magic: potatosdk-1.0
-description: some incredible module bringing the future to your home.
-deps:
-- all/some_general_useful_library
-conflicts:
-- mysystem/some_anonymous_hater
-- all/some_general_module_that_defines_the_same_thing_as_me
-requires:
- arch:
- - sh3
- - sh4a
- compiler:
- - [GNU, GCC]
- - [Renesas, SHC]
-```
-
-## Roles file (top comments)
-**The top comment of each source/include file is NOT hand-written**,
-it is generated by a script, `tools/updatesource.py`, which reads the
-copyright and licences from the machine-readable copyright information files
-(see [Licensing](licensing)), and the short description of each file
-from the roles files `roles.yml` present in every module root.
-
-A roles file is YAML-encoded, and simply represents an arborescence with
-dictionaries, leading to the description. Here's an example roles file:
-
-```yaml
-%YAML 1.2
----
-bits:
- stdio.h: description for the `bits/stdio.h` file
- stdlib.h: description for the `bits/stdlib.h` file
-include:
- subfolder:
- something.h: description for the `include/subfolder/something.h` file
- other.h: description for the `include/other.h` file
-```
-
-## C/C++ headers and header bits
-libcarrot uses a C superpreprocessor, which role is to:
-
-- find the header files in all of the selected modules (usually ending by
- `.h`, `.hpp`, or not having any extension (C++ standard headers));
-- regroup those headers into one folder, the header output folder
- (usually `./include` from the project root);
-- make the top comment including the authors and licensing information;
-- add the appropriate include guards;
-- include the appropriate bits at the appropriate places;
-- profile and optimize the headers.
-
-The idea behind header bits comes from the glibc `bits/` subfolder, where
-machine or system specific code is located; for example, `bits/endian.h`
-defines `__BYTE_ORDER` to `__LITTLE_ENDIAN` when the glibc is compiled for
-the x86 or x86_64 architecture.
-
-That's what I did first, but then thought it could be quite heavy and
-not optimized enough to include other headers when their content could just
-be in the final header. Furthermore, I also wanted to be able to include
-zero, one or more headers at one place, using a path; that's how the bits
-header came to what it is today.
-
-To include all of the bits with a certain name, you just have to use
-`#include_bits <the/bit.h>`, which will include all of the bits having a
-relative path `the/bit.h` to the bits directories in the bits path (all of
-the found `bits/` directories in the selected modules).
-
-To know which bits are expected, in what sort of modules they should be
-defined and what they are expected to define, the modules using this
-instruction should have a `BITS.md` documentation at their root (e.g.
-in `modules/all/core/`).
-
-## C/C++/ASM source files
-Sources are found automatically in the `src` folder, using their extensions
-(`c` for C source files, `cpp`, `cc`, `cxx` and others for C++ source files,
-and assembler/dialect-specific extensions for assembly source files).
-If you don't want a source file to be found, append `.draft` to the complete
-file name (e.g. `source.c.draft`).
diff --git a/docs/contributing.en.rst b/docs/contributing.en.rst
new file mode 100644
index 0000000..96e1cbc
--- /dev/null
+++ b/docs/contributing.en.rst
@@ -0,0 +1,292 @@
+:title: Contributing to libcarrot
+
+First of all, thanks for reading this! It probably means you think libcarrot
+might be worth the effort you are going to put in it, and that rocks! :D
+
+As I want to keep things clean and organized for anyone using this library,
+I'm defining this set of rules (from my own personal coding style, as it is
+how I started this project). Some are justified from a technical point of view,
+and some are not. Don't think it's against you or anything: I just don't
+want this project to be a coding style mess, where you have to learn a new
+coding style before contributing to any new header/source file.
+
+Any disrespect to those rules in your contribution will make your contribution
+not merged upstream until you respect them (this doesn't mean it will always
+be accepted if you respect them, don't get me wrong). If you think one of the
+rules should really be abolished/is not productive at all, you should discuss
+with the current maintainer(s) about it: they have the authority here.
+
+If you have any questions about some obscure point of this contribution guide,
+or you have deduced something from the existing codebase and noticed it was
+not described here (it should, but writing a contribution guide is far from
+being easy), please suggest the changes (by proposing commits or tipping off
+the maintainer(s))!
+
+File organization
+=================
+
+The modules (see `the introduction <index.en.rst>`_ for more about modules and
+systems) are located in ``./modules``. They are grouped by systems (folders
+representing them). Here's an example ``./modules`` arborescence:
+
+::
+ info.yml (global information file)
+ all/
+ info.yml (`all` system information file)
+ core/
+ (`all/core` module related stuff)
+ other/
+ (`all/other` module related stuff)
+ mysys/
+ info.yml (`mysys` system information file)
+ core/
+ (`mysys/core` module related stuff)
+
+Every system has an information file, described in its own section.
+
+Modules have the following organization ("opt." means "optional", "req." means
+"required", "rec." means "recommended"):
+
+``include/``
+ (opt.) The C source headers folder.
+
+``bits/``
+ (opt.) The C header bits folder.
+
+``src/``
+ (opt.) The C/ASM source files folder.
+
+``docs/``
+ (opt.) The documentation folder.
+
+``man/``
+ (opt.) The manpages corresponding to the module.
+
+``info.yml``
+ (req.) The module information file.
+
+``copyright.yml``
+ (rec.) The machine-readable copyright information file.
+
+``roles.yml``
+ (rec.) The machine-readable roles for your source files.
+
+In order not to make a coding style patchwork out of this project, you really
+should follow `the project's coding style <coding.en.rst>`_.
+
+``copyright.yml`` defines the license of each file (see `the libcarrot
+licensing method <licensing.en.md>`_). The other files' roles and structures
+are defined below.
+
+Global information file
+-----------------------
+
+The global information file gives information about libcarrot. It is located
+at `modules/info.yml`, and is a YAML-encoded configuration, with the
+following properties:
+
+``magic``
+ Should be equal to `potatosdk-1.0`.
+
+``version``
+ The version details, with the following properties:
+
+ ``major``
+ The major version (as an integer).
+
+ ``minor``
+ The minor version (as an integer).
+
+ ``indev``
+ Whether the current version is in development or not (default: false).
+
+An example configuration is the following:
+
+.. code:: yaml
+ %YAML 1.2
+ ---
+ magic: potatosdk-1.0
+ version:
+ major: 5
+ minor: 11
+ indev: true
+
+System and meta-system information file
+---------------------------------------
+
+Every system has a few properties, regrouped in a system information file and
+located at ``modules/<system>/info.yml``. It is a YAML-encoded configuration,
+with the following properties:
+
+``magic``
+ Should be equal to `potatosdk-1.0`.
+
+``description``
+ The platform description.
+
+``abi``
+ The list of binary interfaces for applications (file formats, calling
+ conventions, …), with keywords the build tools will understand.
+
+``default``
+ The ``{language => modules list}`` dictionary defining the system
+ default modules, that will be included if the system is targetted or
+ if it is a meta-system and it's imported by the targetted system.
+ Modules from meta-systems should not be included directly, please use
+ the ``meta`` property described below to import all of the defaults
+ from the meta-system.
+
+``import``
+ The list of meta-systems to import. Default modules from this other
+ platform are included in this one's.
+
+``requires``
+ The requirements for this platform to be targetted or imported,
+ with the following properties:
+
+ ``arch``
+ The list of architectures the system supports (if not precised,
+ all architectures are accepted).
+
+If the list of ABIs is empty (or the ABI property is simply not defined), the
+system is considered to be a meta-system. An example configuration is the
+following:
+
+.. code:: yaml
+ %YAML 1.2
+ ---
+ magic: potatosdk-1.0
+ description: >-
+ That incredible system we should all switch to.
+ default:
+ - mysys/somepackage
+ - mysys/someotherpackage
+ import:
+ - all
+ requires:
+ arch:
+ - sh3
+ - sh4a
+
+Module information file
+-----------------------
+
+Every module has a set of properties too, regrouped in a module information
+file located at ``modules/<system>/<module>/info.yml``. It is a YAML-encoded
+configuration, with the following properties:
+
+``magic``
+ Should be equal to ``potatosdk-1.0``.
+
+``description``
+ The module description (what features it brings, for which constraints,
+ etc).
+
+``deps``
+ The module dependencies (preferably excluding language-related
+ dependencies.
+
+``license``
+ The license for the module (either ``free`` or ``proprietary``, default
+ is ``free``). See `the libcarrot licensing method <licensing.en.rst>`_.
+
+``conflicts``
+ The module(s) this module shouldn't be selected with.
+
+``requires``
+ The requirements for this module to be selected, with the following
+ properties:
+
+ ``arch``
+ The subset of architectures the module supports (from the system
+ ones). If not given, all the system architectures are selected.
+
+ ``compiler``
+ The list of compilers the module supports, e.g. ``[GNU, GCC]``.
+
+An example configuration is the following:
+
+.. code:: yaml
+ %YAML 1.2
+ ---
+ magic: potatosdk-1.0
+ description: some incredible module bringing the future to your home.
+ deps:
+ - all/some_general_useful_library
+ conflicts:
+ - mysystem/some_anonymous_hater
+ - all/some_general_module_that_defines_the_same_thing_as_me
+ requires:
+ arch:
+ - sh3
+ - sh4a
+ compiler:
+ - [GNU, GCC]
+ - [Renesas, SHC]
+
+Roles files (top comments)
+--------------------------
+
+**The top comment of each source/include file is NOT hand-written**,
+it is generated by a script, ``tools/updatesource.py``, which reads the
+copyright and licences from the machine-readable copyright information files
+(see `the libcarrot licensing method <licensing.en.rst>`_), and the short
+description of each file from the roles files ``roles.yml`` present in every
+module root.
+
+A roles file is YAML-encoded, and simply represents an arborescence with
+dictionaries, leading to the description. Here's an example roles file:
+
+.. code:: yaml
+ %YAML 1.2
+ ---
+ bits:
+ stdio.h: description for the `bits/stdio.h` file
+ stdlib.h: description for the `bits/stdlib.h` file
+ include:
+ subfolder:
+ something.h: description for the `include/subfolder/something.h` file
+ other.h: description for the `include/other.h` file
+
+C headers and header bits
+-------------------------
+
+libcarrot uses a C superpreprocessor, which role is to:
+
+- find the header files in all of the selected modules (usually ending by
+ ``.h``);
+- regroup those headers into one folder, the header output folder
+ (usually ``./include`` from the project root);
+- make the top comment including the authors and licensing information;
+- add the appropriate include guards;
+- include the appropriate bits at the appropriate places;
+- profile and optimize the headers.
+
+The idea behind header bits comes from the glibc ``bits/`` subfolder, where
+machine or system specific code is located; for example, ``bits/endian.h``
+defines ``__BYTE_ORDER`` to ``__LITTLE_ENDIAN`` when the glibc is compiled for
+the x86 or x86_64 architecture.
+
+That's what I did first, but then thought it could be quite heavy and
+not optimized enough to include other headers when their content could just
+be in the final header. Furthermore, I also wanted to be able to include
+zero, one or more headers at one place, using a path; that's how the bits
+header came to what it is today.
+
+To include all of the bits with a certain name, you just have to use
+``#include_bits <the/bit.h>``, which will include all of the bits having a
+relative path ``the/bit.h`` to the bits directories in the bits path (all of
+the found ``bits/`` directories in the selected modules).
+
+To know which bits are expected, in what sort of modules they should be
+defined and what they are expected to define, the modules using this
+instruction should have a ``BITS.md`` documentation at their root (e.g.
+in ``modules/all/core/``).
+
+C/ASM source files
+----------------------
+
+Sources are found automatically in the ``src/`` folder, using their extensions
+(``c`` for C source files, and assembler/dialect-specific extensions for
+assembly source files). If you don't want a source file to be found,
+append ``.draft`` to the complete file name (e.g. ``source.c.draft``).
diff --git a/docs/docs.en.md b/docs/docs.en.md
deleted file mode 100644
index 3e5184e..0000000
--- a/docs/docs.en.md
+++ /dev/null
@@ -1,51 +0,0 @@
----
-title: The libcarrot documentation guide
----
-This project contains its own documentation. There are two type of
-documentation:
-
-- general documentation, that you can find in `<project root>/docs/`;
-- module-specific documentation, that you can find in
- `<project root>/modules/<system>/<module>/docs/`.
-
-There is no platform-only specific documentation. The platform documentation
-is usually found in its first default module documentation, usually
-`<system>/core`.
-
-The documentation folders contain various files corresponding to the pages
-in the final archive/web root. Each file has a double extension, representing
-the language (e.g. `en` for English) and the format (`md` for markdown, as it
-is the only supported format for now). Each file has a YAML Front Matter (YFM),
-which is a YAML block of metadata put between `---` lines at the beginning
-of the file. Supported properties are:
-
-- `title` (man.): the page title;
-- `chapters` (opt.): the list of subchapters to this page.
-
-For special things such as blocks, there is a Liquid-like preprocessor that
-supports blocks and properties.
-
-For example, in the `all/helloworld` documentation (i.e. the
-`modules/all/helloworld/docs/` folder), there is a file called `index.en.md`,
-which contains something like this:
-
- ---
- title: The hello world module Thomas is so excited about.
- chapters:
- - history
- - cultural_impact
- - copyrights
- ---
- Some text about how great this module and the `helloworld()` function it
- contains are.
-
- ```c
- void helloworld(const char *string);
- ```
-
- Some more remarks about how awesome this function is.
-
-Notice that for links, you can just link the markdown file (for an easier
-read of the web interface to the repository), with the current language.
-What they point at will be processed to look something like
-`/en/sys/module/hi.html` or `/sys/module/hi.en.html`.
diff --git a/docs/docs.en.rst b/docs/docs.en.rst
new file mode 100644
index 0000000..f98c90a
--- /dev/null
+++ b/docs/docs.en.rst
@@ -0,0 +1,46 @@
+The libcarrot documentation guide
+=================================
+
+This project contains its own documentation. There are two type of
+documentation:
+
+- general documentation, that you can find in ``<project root>/docs/``;
+- module-specific documentation, that you can find in
+ ``<project root>/modules/<system>/<module>/docs/``.
+
+There is no platform-only specific documentation. The platform documentation
+is usually found in its first default module documentation, usually
+``<system>/core``.
+
+The documentation folders contain various files corresponding to the pages
+in the final archive/web root. Each file has a double extension, representing
+the language (e.g. ``en`` for English) and the format (e.g. ``rst`` for
+*reStructuredText*).
+
+For example, in the ``all/helloworld`` documentation (i.e. the
+``modules/all/helloworld/docs/`` folder), there is a file called
+``index.en.rst``, which contains something like this:
+
+.. code-block:: rst
+
+ The hello world module Thomas is so excited about
+ =================================================
+
+ Some text about how great this module and the ``helloworld()`` function
+ it contains are.
+
+ .. code-block::
+
+ void helloworld(const char *string);
+
+ Some more remarks about how awesome this function is.
+
+ .. chapters::
+
+ history
+ compatibility
+
+Notice that for links, you can just link the reStructuredFile file
+(for an easier read of the web interface to the repository), with the
+current language. What they point at will be processed to look something like
+``/en/sys/module/hi.html`` or ``/sys/module/hi.en.html``.
diff --git a/docs/index.en.md b/docs/index.en.rst
index 32d4bac..251200f 100644
--- a/docs/index.en.md
+++ b/docs/index.en.rst
@@ -1,20 +1,18 @@
----
-title: libcarrot — an experimental and modular libc for learning
-chapters:
-- building
-- contributing
----
-libcarrot is a modular C/C++ library.
+libcarrot — an experimental and modular libc for learning
+=========================================================
+
+libcarrot is a modular C library.
Although originally made to replace CASIO's fxlib under Linux (see
-`casiowin/fxlib` for more information about that), libcarrot has now become
-a more global standard library for C and C++, originally targetting the
+``casiowin/fxlib`` for more information about that), libcarrot has now become
+a more global standard library for the C language, originally targetting the
SuperH/J-Core system with extensions for the CASIO fx-9860G, but now
aiming to have extensions for more systems and languages.
-The library aims at being compatible with the ISO C and C++ standards,
+The library aims at being compatible with the ISO C standards,
POSIX/Single Unix Specification (for compliant systems), other standards
-the GNU C Library supports, and at being usable with several compilers such as:
+the GNU C Library supports, and at being usable with several compilers
+such as:
- Renesas' C/C++ Compiler (SHC);
- the GNU Compiler Collection (GCC);
@@ -23,13 +21,16 @@ the GNU C Library supports, and at being usable with several compilers such as:
- IBM's XL C/C++ Compiler (XLC);
- many more!
-# Modules
+Modules
+-------
+
The library is thought around modules. Modules in libcarrot are a logicial
division of it, containing sources (symbols, ...) and headers that bring one
or more features to the library.
-For example, one could make a `helloworld` module that could bring a
+
+For example, one could make a ``helloworld`` module that could bring a
function printing "hello world" and what is required to run with it
-(a `all/helloworld` demo module serves as an example).
+(an ``all/helloworld`` demo module serves as an example).
A module, like any package, has dependencies, conflicts, and requirements.
Among the requirements are the architecture, the compiler, etc.
@@ -38,16 +39,23 @@ modules will be transparent, only the set of features they bring will be
available to the user (unless the module defines some preprocessor macro
for the user to use).
-# Systems
+Systems
+-------
+
Modules are grouped by system, for which they are suitable.
A system generally represents a kernel/OS; for example, Linux with the
-`linux` system, which regroup the Linux syscalls and the standard libraries
+``linux`` system, which regroup the Linux syscalls and the standard libraries
that are suitable for Linux.
-Systems have various _default modules_ depending on the languages and binary
+Systems have various *default modules* depending on the languages and binary
executable formats you ought to prepare it for.
-Among the available systems are meta-systems such as `all`. These systems
+Among the available systems are meta-systems such as ``all``. These systems
are untargettable as their only purpose is to bring modules to several other
systems, such as standard-compliant modules, in order to reduce the
system-specific code (and thereby, the error rate).
+
+.. chapters::
+
+ building
+ contributing
diff --git a/docs/licensing.en.md b/docs/licensing.en.rst
index 49afc32..0566666 100644
--- a/docs/licensing.en.md
+++ b/docs/licensing.en.rst
@@ -1,13 +1,13 @@
----
-title: Licensing in libcarrot
----
+Licensing in libcarrot
+======================
+
libcarrot is thought to having a common core under free license, and allowing
proprietary extensions to it, so for each module, there are currently
two licensing modes:
-- `free`: the files under this mode are subject to the libcarrot free
+- ``free``: the files under this mode are subject to the libcarrot free
software license;
-- `proprietary`: all rights on the files are reserved by the owners.
+- ``proprietary``: all rights on the files are reserved by the owners.
The trunk, tools and related documentation are and must stay under
the libcarrot free software license at all times.
@@ -19,30 +19,34 @@ Any proprietary extension should be free'd before being proposed (and merged).
The libcarrot free software license currently is the CeCILL-C license,
written by french people and compliant with french law.
-# Copyright files
-The copyright details are given by the `copyright.yml` files.
+Copyright files
+---------------
+
+The copyright details are given by the ``copyright.yml`` files.
These files are machine-readable, and used to generate the top comments of
the source files, and generated text files (headers, ...) — see
[Contributing](contributing.en.md) for more information about that.
Each one of them defines a set of rules for the files at the same level
-and beneath, using wildcard patterns (e.g. `folder/**/*.ext`).
+and beneath, using wildcard patterns (e.g. ``folder/**/*.ext``).
The copyright file shall contain one rule per division ("document").
Each division shall define the following properties:
-- `files`: the wildcard pattern(s) from the current directory of the
+- ``files``: the wildcard pattern(s) from the current directory of the
group of files. If you only define one, you shall use a string, otherwise,
please use a list of strings.
-- `copyright`: the people this file belong to, usually the original author
+- ``copyright``: the people this file belong to, usually the original author
and the contributors who don't give their rights to the original author.
-A `copyright` entry consists of the copyright starting year, ending year,
+A ``copyright`` entry consists of the copyright starting year, ending year,
owner and owner e-mail address. It is defined as a list of either four
-elements, as `[<start year>, <end year>, <name>, <mail>]` or, if the ending
+elements, as ``[<start year>, <end year>, <name>, <mail>]`` or, if the ending
year is the same than the starting year, of three elements, as
-`[<start and end year>, <name>, <mail>]`. The e-mail address is mandatory.
+``[<start and end year>, <name>, <mail>]``. The e-mail address is mandatory.
+
+An example ``copyright.yml`` file is the following:
-An example `copyright.yml` file is the following:
+.. code-block:: yaml
%YAML 1.2
---
diff --git a/docs/preprocessor.en.md b/docs/preprocessor.en.md
deleted file mode 100644
index 35c72c5..0000000
--- a/docs/preprocessor.en.md
+++ /dev/null
@@ -1,101 +0,0 @@
----
-title: Using the libcarrot preprocessor
----
-> The C preprocessor, often known as _cpp_, is a _macro processor_ that is
-> used automatically by the C compiler to transform your program before
-> compilation. It is called a macro processor because it allows you to
-> define _macros_, which are brief abbreviations for longer constructs.
->
-> — [The C Preprocessor (GNU), 1. Overview][gnucpp]
-
-A preprocessing directive is a line starting with a `#`, followed by the
-instruction, and some arguments related to it, separated with whitespace
-characters (once the whitespace characters at the beginning and the end
-of the lines have been removed).
-
-The libcarrot uses a special preprocessor that implements everything the
-standard/GNU C preprocessor does, and adds more things that are specific
-to the libcarrot's needs (plus little touches for tolerance).
-
-This page describes the libcarrot preprocessor and best practices.
-
-# Defining macros
-As in standard C, to manage the macros definition, the two basic instructions
-are `#define` and `#undef`. They shall be used like this:
-
- #define NAME content
- #define NAME(arg0) content
- #define NAME(arg0, arg1) content
- #undef NAME
-
-As the libcarrot preprocessor will try to optimize preprocessor instructions,
-these in libcarrot have two properties:
-
-- **internal macros**: these instructions are to use by modules within
- libcarrot itself at compilation time. As libcarrot optimizes expressions
- and conditions when possible, you can sort of use these macros in “runtime”;
-- **raw macros**: normally, macros allow other macros to be used in their
- content. Raw macros disallow this, which means that the content of the
- macro will not be interpreted by the preprocessor. Raw macros will
- also be set as internal macros.
-
-These properties are important to have in mind while naming your macros:
-
-- macros starting with two underscores, e.g. `__SOMETHING`, will automatically
- be defined as an internal macro;
-- other macros will not, but for private use at runtime, according to the
- C standards, your macro's name shall start with a `_` followed by an
- uppercase letter (with exceptions).
-
-If your macro doesn't start with two underscores but you want your macro to
-be defined as an internal macro, you can use one of the two instructions:
-
- #defint NAME content
- #define_int NAME content
- #define_int NAME(arg0, arg1) content
-
-If you want to define your macro as a raw macro, you can define of the
-following two instructions:
-
- #defraw NAME content
- #define_raw NAME content
-
-Obviously, you cannot define raw macros with arguments as the arguments
-cannot be interpreted within the content of the macro.
-
-# Conditional code
-You can produce conditional content (including preprocessor instructions) by
-using the basic instructions given below:
-
- #if expr
- #elif expr
- #else
- #endif
-
-Where `expr` represents an expression to evaluate. Expressions evaluated to
-0 or equivalent will be interpreted as false, others will be interpreted as
-true. If the expression depends on unknown objects or objects of unknown
-values at superprocessing time, the libcarrot preprocessor will not optimize
-
- #ifdef name
- #ifndef name
- #elifdef name
- #elifndef name
-
-# File inclusion
-
- #include <file.h>
- #include "file.h"
- #include FILE_PATH
-
-# Bits inclusion
-
- #include_bits <file.h>
- #include_bits FILE_PATH
-
-# Errors
-
- #error "message"
- #error MESSAGE
-
-[gnucpp]: https://gcc.gnu.org/onlinedocs/cpp/Overview.html#Overview
diff --git a/docs/preprocessor.en.rst b/docs/preprocessor.en.rst
new file mode 100644
index 0000000..13c0ae4
--- /dev/null
+++ b/docs/preprocessor.en.rst
@@ -0,0 +1,228 @@
+Using the libcarrot preprocessor
+================================
+
+.. quote::
+ :author: `The C Preprocessor (GNU), 1. Overview <gnucpp_>`_
+
+ The C preprocessor, often known as *cpp*, is a *macro processor* that is
+ used automatically by the C compiler to transform your program before
+ compilation. It is called a macro processor because it allows you to
+ define *macros*, which are brief abbreviations for longer constructs.
+
+A preprocessing directive is a line starting with a ``#``, followed by the
+instruction, and some arguments related to it, separated with whitespace
+characters (once the whitespace characters at the beginning and the end
+of the lines have been removed). It can be multiline if each line which is
+part of the macro ends with a backslash ``\``, which makes the preprocessor
+ignore the newline.
+
+The libcarrot uses a special preprocessor that implements everything the
+standard/GNU C preprocessor does, and adds more things that are specific
+to the libcarrot's needs (plus little touches for tolerance).
+
+This page describes how to use the libcarrot preprocessor and best practices.
+
+Defining macros
+---------------
+
+As in standard C, to manage the macros definition, the two basic instructions
+are `#define` and `#undef`. They shall be used like this:
+
+.. code-block:: c
+
+ #define NAME content
+ #define NAME(arg0) content using arg0 or not
+ #define NAME(arg0, arg1) content using arg0 and arg1 \
+ or either one or none and one more than one line
+ #undef NAME
+
+As the libcarrot preprocessor will try to optimize preprocessor instructions,
+these in libcarrot have two properties:
+
+- **internal macros**: these instructions are to use by modules within
+ libcarrot itself at compilation time. As libcarrot optimizes expressions
+ and conditions when possible, you can sort of use these macros in “runtime”;
+- **raw macros**: normally, macros allow other macros to be used in their
+ content. Raw macros disallow this, which means that the content of the
+ macro will not be interpreted by the preprocessor. Raw macros will
+ also be set as internal macros.
+
+These properties are important to have in mind while naming your macros:
+
+- macros starting with two underscores, e.g. ``__SOMETHING``, will
+ automatically be defined as an internal macro;
+- other macros will not, but for private use at runtime, according to the
+ C standards, your macro's name shall start with a ``_`` followed by an
+ uppercase letter (with exceptions).
+
+If your macro doesn't start with two underscores but you want your macro to
+be defined as an internal macro, you can use one of the two instructions:
+
+.. code-block:: c
+
+ #defint NAME content
+ #define_int NAME content
+ #define_int NAME(arg0, arg1) content
+
+If you want to define your macro as a raw macro, you can define of the
+following two instructions:
+
+.. code-block:: c
+
+ #defraw NAME content
+ #define_raw NAME content
+
+You cannot define raw macros with arguments as the arguments cannot be
+interpreted within the content of the macro.
+
+Conditional code
+----------------
+
+You can produce conditional content (including preprocessor instructions) by
+using the basic instructions given below:
+
+.. code-block:: c
+
+ #if expr
+ #elif expr
+ #else
+ #endif
+
+Where ``expr`` represents an expression to evaluate. Expressions evaluated to
+0 or equivalent will be interpreted as false, others will be interpreted as
+true. If the expression depends on unknown objects or objects of unknown
+values at superprocessing time, the libcarrot preprocessor will not optimize
+the expression.
+
+In such expressions, an native expression is added, the ``defined(<name>)``
+macro, which returns 1 if the macro is defined and 0 otherwise. For example,
+the following code will print 2:
+
+.. code-block:: c
+
+ #define MACRO1 5
+ #define MACRO2(_WITH, _ARGUMENTS) ((_WITH) - (_ARGUMENTS))
+ #define MACRO3 4
+ #undef MACRO3
+
+ int main(void)
+ {
+ int count = 0;
+
+ #if defined(MACRO1)
+ count++;
+ #endif
+ #if defined(MACRO2)
+ count++;
+ #endif
+ #if defined(MACRO3)
+ count++;
+ #endif
+ #if defined(MACRO4)
+ count++;
+ #endif
+
+ printf("%d\n", count);
+ return (0);
+ }
+
+Shortcuts, taken or inspired from the C standards, are available to make
+conditional code depending on a macro being defined or not:
+
+.. code-block:: c
+
+ #ifdef name
+ #ifndef name
+ #elifdef name
+ #elifndef name
+
+File inclusion
+--------------
+
+The C preprocessor allows you to include another file at a given position in
+your file. Although technically you are allowed to include any text file,
+including other C source files is considered a bad practice, that's why you
+usually only include files called “header files” (with a ``.h`` extension).
+
+These files are specifically designed to be included, and shall not contain
+anything more than function and globals declarations, type definitions
+and macros. Header files require special attention, especially if they
+are public, as they will be included in user code and must interfere the
+least with it. This is done in C++ using namespaces, but since the C language
+doesn't have namespaces, a set of prefixes must be chosen for the interface
+you are defining. In libcarrot, the standard C library namespace
+is used, with ``_`` followed by an uppercase letter for public macro
+definitions, with other names strictly conforming to standards and nothing
+more to avoid interfering with function names the user could have chosen.
+
+Usually, header files also have what is called an include guard to avoid
+the double-inclusion problem: if the user includes the file twice, function,
+global and macro definitions shall not be defined twice (that would be a
+compilation error). The technique here is to use a macro to check if the
+file has already been included or not: if it is not defined, then the file
+hasn't been included yet and the declarations shall be made, otherwise,
+the declarations shall not be made.
+
+There are three forms to include a file, all using the ``include`` preprocessor
+instruction:
+
+.. code-block:: c
+
+ #include <file.h>
+ #include "file.h"
+ #include FILE_PATH
+
+The first form finds the header using a path, i.e. a list of folders where
+header files are to be found. While building libcarrot, the result of all the
+public headers in the ``include`` folder of each selected module is taken
+as the path, so you don't have to know the complete path to the public
+header file to include it.
+
+The second form starts from the same folder the C source file is in. This
+shall be used for a header internal to a module, to be able to share various
+utilities between source files.
+
+The third form uses the value of a macro, which can be surrounded by
+``<>`` for public header inclusion or ``""`` for internal header inclusion.
+It is very rarely used (not at all while I'm writing this). If it is not,
+the path is used (public header inclusion).
+
+Bits inclusion
+--------------
+
+Most of the modular aspect of libcarrot is made possible by the concept of
+header bits. The concept is inspired from the GNU C Library, which stores
+bits corresponding to processor architectures and systems in the ``bits/``
+folder. These header bits musn't be included directly, that's why there are
+guards in the GNU C Library; in libcarrot, as the bits are not installed as
+independant files, it is impossible for the user to include the bits, as
+their content is imported into the headers.
+
+Where with an ``#include``, there must be exactly one potential header,
+with bits, there can be any number (zero to many), which are included in
+any order.
+
+There is an equivalent path system for the bits as there is for the headers.
+libcarrot uses all the ``bits/`` folder of the selected modules as the
+bits path.
+
+To include the bits corresponding to a path/name, use the instruction below
+that matches your case:
+
+.. code-block:: c
+
+ #include_bits <file.h>
+ #include_bits FILE_PATH
+
+Errors
+------
+
+In some cases (required macro left undefined, …), you may want to raise an
+error. In order to do this, use the instruction below that matches your case:
+
+.. code-block:: c
+
+ #error "message"
+ #error MESSAGE
+
+.. _gnucpp: https://gcc.gnu.org/onlinedocs/cpp/Overview.html#Overview
diff --git a/docs/todo.en.md b/docs/todo.en.rst
index c6894cf..3cba595 100644
--- a/docs/todo.en.md
+++ b/docs/todo.en.rst
@@ -1,9 +1,9 @@
----
-title: To do in libcarrot
----
-If you're new to the project, you should read [the main page](index.en.md)
-and [the contributing guide](contributing.en.md) beforehand, or else,
-you probably won't understand a damn word.
+Left to do in libcarrot
+=======================
+
+If you're new to the project, you should read :ref:`index` and
+:ref:`contributing` beforehand, or else, you probably won't understand
+a damn word.
What I've done was mostly defining the project structure and organization,
using Makefiles and headers. The source is highly incomplete, and should be
@@ -18,24 +18,23 @@ So what is to be done is (in order of what I feel is important):
- correct the libcarrot `printf` implementation, add the missing standard
specifiers;
- add specifier registering for the `printf` implementation;
-- make/adapt the `casiowin/monochromelib` sources;
-- finish implementing `string.h`;
-- add the headers and sources required for C++ to work with libcarrot;
-- finish implementing `dirent.h`;
-- make the `math.h`/`mathf.h` implementation;
-- fix the `README.md` by describing more precise dependencies;
-- make cleaner macros for C99 features (like `lldiv`) and for GNU
- extensions (e.g. `asm` used in `machine.h` headers);
-- continue implementing syscalls and fxlib wrappers (e.g. `fx/file.h`,
- `fx/keyboard.h`);
+- make/adapt the ``casiowin/monochromelib`` sources;
+- finish implementing ``string.h``;
+- finish implementing ``dirent.h``;
+- make the ``math.h``/``mathf.h`` implementation;
+- fix the README by describing more precise dependencies;
+- make cleaner macros for C99 features (like ``lldiv``) and for GNU
+ extensions (e.g. ``asm`` used in ``machine.h`` headers);
+- continue implementing syscalls and fxlib wrappers (e.g. ``fx/file.h``,
+ ``fx/keyboard.h``);
And here's for compatibility or advanced features. It's less urgent:
-- finish adapting the SuperH `machine.h` headers for GCC;
-- make standard headers temporarily provided by GCC such as `stddef.h`,
+- finish adapting the SuperH ``machine.h`` headers for GCC;
+- make standard headers temporarily provided by GCC such as ``stddef.h``,
for the library to compile using Hitachi's compiler;
- make or correct the libcarrot make utilities, headers and sources to compile
on Microsoft Windows using GNU (MinGW) or Hitachi/Renesas build utilities;
- fix the fixed-point implementation and documentation (make a tutorial for
compiling GCC with fixed-point enabled?);
-- implement and document the Ensigma DSP library (`ensigdsp.h`).
+- implement and document the Ensigma DSP library (``ensigdsp.h``).
diff --git a/docs/tools/build-tools.en.md b/docs/tools/build-tools.en.rst
index 90ca1d6..bc765af 100644
--- a/docs/tools/build-tools.en.md
+++ b/docs/tools/build-tools.en.rst
@@ -1,8 +1,8 @@
----
-title: Build tools management
----
-The module for managing the tools is `Internals.build`, which the content is
-imported by `Internals` so you don't have to include the module directly.
+Build tools management
+======================
+
+The module for managing the tools is ``Internals.build``, which the content is
+imported by ``Internals`` so you don't have to include the module directly.
The module is thought for a two-time usage:
- configuration: find the required tools for a given architecture, system
@@ -11,133 +11,113 @@ The module is thought for a two-time usage:
The kinds of tools are:
-- `cc`: a C compiler;
-- `cxx`: a C++ compiler;
-- `asm`: an assembler;
-- `pack`: a static library maker (packer);
-- `link`: a dynamic library maker (linker);
-- `bin`: an executable maker.
+- ``cc``: a C compiler;
+- ``asm``: an assembler;
+- ``pack``: a static library maker (packer);
+- ``link``: a dynamic library maker (linker);
+- ``bin``: an executable maker.
Tools are identified by their manufacturer, e.g. "GNU" or "Borland", and by
-their name, e.g. "GCC" or "Turbo C++", as a tuple/list, e.g. `["GNU", "GCC"]`.
+their name, e.g. "GCC", as a tuple/list, e.g. ``["GNU", "GCC"]``.
+
+Configuring
+-----------
-# Configuring
A tool is defined by a dictionary, which links properties to methods. The
names defined earlier are the main functions, and the names defined earlier
-prefixed by `conf_` are the configuration function. The configuration
+prefixed by ``conf_`` are the configuration function. The configuration
functions should produce a set of parameters that will be sent to the main
functions. For example, they can contain the path to the compiler, some
architecture-specific flags, etc.
-For example, the definition of a C/C++ compiler (with non-exported functions,
+For example, the definition of a C compiler (with non-exported functions,
all that is exported is the dictionary) is:
-```python
-Carrot_Compiler = {
- 'conf_cc': _configure_cc,
- 'cc': _cc,
+.. code-block:: python
- 'conf_cxx': _configure_cxx,
- 'cxx': _cxx
-}
-```
+ Carrot_Compiler = {
+ 'conf_cc': _configure_cc,
+ 'cc': _cc
+ }
-Once your tool is done, you shall import it in `Internals/build/__init__.py`
-and add its correspondance table to the `__tools` dictionary.
+Once your tool is done, you shall import it in ``Internals/build/__init__.py``
+and add its correspondance table to the ``__tools`` dictionary.
+
+Common parameters
+-----------------
-## Common parameters
All of the methods take these four first arguments:
-- `arch`: the architecture for which to build, generally a sub-architecture;
-- `endian`: the endianness of the architecture for which to build, useful
+- ``arch``: the architecture for which to build, generally a sub-architecture;
+- ``endian``: the endianness of the architecture for which to build, useful
when it is bi-endian;
-- `system`: the system for which to build;
-- `abi`: the system ABI against which to build;
-- `flavour`: the category for the development files formats.
+- ``system``: the system for which to build;
+- ``abi``: the system ABI against which to build;
+- ``flavour``: the category for the development files formats.
All of these are strings.
-## C Compiler
+C Compiler
+----------
+
libcarrot requires a C compiler to produce an object out of a C source file,
and a few include directories, for a given C standard. Higher and
entirely retrocompatible standards (C11) will be tried before the older
ones (C99, C89).
-The `conf_cc` method will be called to configure the C compiler. It should
+The ``conf_cc`` method will be called to configure the C compiler. It should
be defined this way:
-```python
-def <conf_cc>(arch, endian, system, flavour, standard)
-```
-
-Where the standard parameter is a string, usually one of `"c89"`, `"c95"`,
-`"c99"`, `"c11"`.
-
-As for the other functions, the configuration function will generate a set
-of options that the main compiling function will take as a first argument.
-This main function is defined as is:
-
-```python
-def <cc>(params, object_path, source_path, include_dirs)
-```
-
-Where the include directories parameter is a list of paths.
-
-## C++ Compiler
-For modules containing C++, libcarrot also requires a C++ compiler to produce
-an object, out of a C++ source file this time (and a few headers too),
-for a given C++ standard. As for C, higher and retrocompatible standards
-(C++17) will be tried before the older ones (C++11, C++03, C++98).
-
-The `conf_cxx` method will be called to configure the C++ compiler. It should
-be defined this way:
+.. code-block:: python
-```python
-def <conf_cxx>(arch, endian, system, flavour, standard)
-```
+ def <conf_cc>(arch, endian, system, flavour, standard)
-Where the standard parameter is a string, usually one of `"c++98"`, `"c++03"`,
-`"c++11"`, `"c++17"`.
+Where the standard parameter is a string, usually one of ``"c89"``, ``"c95"``,
+``"c99"``, ``"c11"``.
As for the other functions, the configuration function will generate a set
of options that the main compiling function will take as a first argument.
This main function is defined as is:
-```python
-def <cxx>(params, object_path, source_path, include_dirs)
-```
+.. code-block:: python
+
+ def <cc>(params, object_path, source_path, include_dirs)
Where the include directories parameter is a list of paths.
-## Assembler
+Assembler
+---------
+
Some modules do low-level system interactions (or very optimized code,
although it is not recommended) and need to use assembly to do so.
-As it has not been standardized, assembly is a different language from C
-and C++: even if the instructions for assemblers compiling for the same
+As it has not been standardized, assembly is a different language from C:
+even if the instructions for assemblers compiling for the same
architecture are the same, the different assemblers use different syntaxes.
For now, libcarrot requires the developer to implement source files for all
of them (maybe that, in the future, libcarrot will make a common syntax for
all files to simplify this).
-The `conf_asm` method will be called to configure the assembler. It should
+The ``conf_asm`` method will be called to configure the assembler. It should
be defined this way:
-```python
-def <conf_asm>(arch, endian, system, flavour, syntax)
-```
+.. code-block:: python
+
+ def <conf_asm>(arch, endian, system, flavour, syntax)
Where the syntax is a string representing the syntax name, including (but not
-limited to) `gnu`, `nasm`, `asmsh`, etc.
+limited to) ``gnu``, ``nasm``, ``asmsh``, etc.
As for the other functions, the configuration function will generate a set
of options that the main compiling function will take as a first argument.
This main function is defined as is:
-```python
-def <asm>(params, object_path, source_path)
-```
+.. code-block:: python
+
+ def <asm>(params, object_path, source_path)
+
+Archiver (packer)
+-----------------
-## Archiver (packer)
libcarrot was primarily made to build static libraries. Static libraries are
usually a collection of objects, and are development files, which makes their
format defined by the flavour.
@@ -146,58 +126,63 @@ The `conf_pack` method will be called to configure the static library
generator (also called “packer” or “archiver”). It should be defined
this way:
-```python
-def <conf_pack>(arch, endian, system, flavour)
-```
+.. code-block:: python
+
+ def <conf_pack>(arch, endian, system, flavour)
As for the other functions, the configuration function will generate a set
of options that the main function will take as a first argument.
This main function is defined as is:
-```python
-def <pack>(params, library_path, objects_path)
-```
+.. code-block:: python
+
+ def <pack>(params, library_path, objects_path)
Where the objects path is a list of paths leading to the objects.
-## Linker
+Linker
+------
+
libcarrot can also generate shared libraries. Shared libraries are usually
implemented as shared objects (ELF), and are read by the kernel, which makes
their format defined by the ABI.
-The `conf_link` method will be called to configure the shared/dynamic
+The ``conf_link`` method will be called to configure the shared/dynamic
library. It should be defined this way:
-```python
-def <conf_link>(arch, endian, system, flavour, abi)
-```
+.. code-block:: python
+
+ def <conf_link>(arch, endian, system, flavour, abi)
As for the other functions, the configuration function will generate a set
of options that the main function will take as a first argument.
This main function is defined as is:
-```python
-def <link>(params, library_path, object_paths)
-```
+.. code-block:: python
+
+ def <link>(params, library_path, object_paths)
Where, as for the packer, the objects path is a list of paths leading to
the objects (flavour format).
-## Binary maker
+Binary maker
+------------
+
And finally, libcarrot will also be able to generate binary executables.
A binary executable is executed by the kernel, and uses a native format
(usually ELF nowadays).
-The `conf_bin` method will be called to configure the binary executable
+The ``conf_bin`` method will be called to configure the binary executable
maker. It should be defined this way:
-```python
-def <conf_bin>(arch, endian, system, flavour, abi)
-```
+.. code-block:: python
+
+ def <conf_bin>(arch, endian, system, flavour, abi)
As for the other functions, the configuration function will generate a set
of options that the main function will take as a first argument.
This main function is defined as is:
-```python
-def <bin>(params, binary_path, object_paths)
+.. code-block:: python
+
+ def <bin>(params, binary_path, object_paths)
diff --git a/docs/tools/index.en.md b/docs/tools/index.en.md
deleted file mode 100644
index 688b2dc..0000000
--- a/docs/tools/index.en.md
+++ /dev/null
@@ -1,29 +0,0 @@
----
-title: The libcarrot tools
-chapters:
-- build-tools
----
-The build tools are the foundation on which libcarrot is built. It defines its
-structure, its possibilities, and part of its performance. It is crucial to
-maintain and enhance them when possible. This series of documents describes
-them as carefully as possible.
-
-First of all, let's describe the general organization of it all. The tools
-are in the `tools` folder at the project root (which is taken as the base
-folder for pretty much everything, usually). The files right there are the
-executables, which the functions are described in the general documentation.
-All of these utilities include the `Internals` module, which contain all of
-the libcarrot mechanisms.
-
-In the `Internals` folder:
-
-- `headers` is the super-preprocessor;
-- `locales` contains the translations;
-- `tools` contains the tools to external build tools (compilers, ...);
-- `arch.py` is the architecture reference;
-- `args.py` is the libcarrot argument parser;
-- `cache.py` is the cache file management;
-- `copyright.py` is the licensing utilities;
-- `exceptions.py` defines all of the exceptions common to all submodules;
-- `module.py` contains the module/system management objects;
-- `topc.py` manages the top comment for each file.
diff --git a/docs/tools/index.en.rst b/docs/tools/index.en.rst
new file mode 100644
index 0000000..8e6229e
--- /dev/null
+++ b/docs/tools/index.en.rst
@@ -0,0 +1,31 @@
+The libcarrot tools
+===================
+
+.. chapters::
+
+ build-tools
+
+The build tools are the foundation on which libcarrot is built. It defines its
+structure, its possibilities, and part of its performance. It is crucial to
+maintain and enhance them when possible. This series of documents describes
+them as carefully as possible.
+
+First of all, let's describe the general organization of it all. The tools
+are in the ``tools/`` folder at the project root (which is taken as the base
+folder for pretty much everything, usually). The files right there are the
+executables, which the functions are described in the general documentation.
+All of these utilities include the `Internals` module, which contain all of
+the libcarrot mechanisms.
+
+In the ``Internals`` folder:
+
+- ``headers/`` is the super-preprocessor;
+- ``locales/`` contains the translations;
+- ``tools/`` contains the tools to external build tools (compilers, ...);
+- ``arch.py`` is the architecture reference;
+- ``args.py`` is the libcarrot argument parser;
+- ``cache.py`` is the cache file management;
+- ``copyright.py`` is the licensing utilities;
+- ``exceptions.py`` defines all of the exceptions common to all submodules;
+- ``module.py`` contains the module/system management objects;
+- ``topc.py`` manages the top comment for each file.
diff --git a/modules/all/core-sh/bits/byteswap.h b/modules/all/core-sh/bits/byteswap.h
index dcfa988..b8fa5d5 100644
--- a/modules/all/core-sh/bits/byteswap.h
+++ b/modules/all/core-sh/bits/byteswap.h
@@ -36,11 +36,11 @@
# define __bswap_32(_X) _builtin_swapb(_builtin_swapw(_builtin_swapb(_X)))
#elif __GNUC_ASM
-static __asm_inline __uint16_t __byteswap_swapb(__uint16_t __data) {
- __uint16_t __res; asm("swap.b %1, %0":"=r"(__res):"r"(__data));
+static __asm_inline uint16_t __byteswap_swapb(uint16_t __data) {
+ uint16_t __res; asm("swap.b %1, %0":"=r"(__res):"r"(__data));
return (__res); }
-static __asm_inline __uint32_t __byteswap_swapw(__uint32_t __data) {
- __uint32_t __res; asm("swap.w %1, %0":"=r"(__res):"r"(__data));
+static __asm_inline uint32_t __byteswap_swapw(uint32_t __data) {
+ uint32_t __res; asm("swap.w %1, %0":"=r"(__res):"r"(__data));
return (__res); }
# define __bswap_16(_X) __byteswap_swapb(_X)
@@ -51,4 +51,10 @@ static __asm_inline __uint32_t __byteswap_swapw(__uint32_t __data) {
# define __bswap_16(_X) __builtin_bswap16(_X)
# define __bswap_32(_X) __builtin_bswap32(_X)
+#elif !__FREESTANDING
+extern uint16_t __bswap_16 _OF((uint16_t __data));
+extern uint32_t __bswap_32 _OF((uint32_t __data));
+
+# define __bswap_16(_X) __bswap_16(_X)
+# define __bswap_32(_X) __bswap_32(_X)
#endif
diff --git a/modules/all/core-sh/copyright.yml b/modules/all/core-sh/copyright.yml
index 94e925f..ce52c6a 100644
--- a/modules/all/core-sh/copyright.yml
+++ b/modules/all/core-sh/copyright.yml
@@ -2,4 +2,4 @@
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/all/core-sh/docs/bits.en.md b/modules/all/core-sh/docs/bits.en.md
deleted file mode 100644
index 8b0bf81..0000000
--- a/modules/all/core-sh/docs/bits.en.md
+++ /dev/null
@@ -1,90 +0,0 @@
----
-title: Bits required for SuperH compatibility
----
-Your C/C++ compiler supports the SuperH architecture? That's great, not
-every one does! Once you have fulfilled
-[the requirements for the core module][c], here is what you shall define in
-your compiler's specific headers.
-
-# CPU type
-You shall define the `_SH` macro, and exactly one of these macros,
-representing your system:
-
- _SH1, _SH2, _SH2A, _SH2E, _SH2AFPU, _SH3, _SH3DSP,
- _SH4, _SH4A, _SHALDSP, _SH5
-
-# DSP-C interface
-The DSP-C interface from the original Hitachi compiler is optional and has to
-be enabled using an option, `-dspc`. If your compiler currently supports
-fixed-point types, the `_DSPC` macro should be defined, otherwise, not.
-
-Then, if they are not already defined, it should define the following macros:
-
-- `__fixed`: the unsigned fract fixed-point type;
-- `__accum`: the unsigned accum fixed-point type;
-- `__sat`: saturated arithmetic qualifier;
-- `__circ`: modulo adressing qualifier;
-- `__X`: X memory data qualifier;
-- `__Y`: Y memory data qualifier.
-
-# Intrinsics
-Headers `<umachine.h>` and `<smachine.h>` are used to define SuperH intrinsics.
-They define the `__NDIC_*` macros, literally, "No Define Intrinsic Condition",
-the condition for the intrinsic not to be defined (generally an ISA-related
-condition), then include the respective bit (same name as the header),
-then they define the fallbacks. You shall define everything you can using
-the NDIC macros. For example, here is how you shall define the `trace()`
-intrinsic in your bit:
-
-```c
-#if __NDIC_TRACE
-#else
-/* compiler-specific definition of the `trace()` macro. */
-#endif
-```
-
-The correspondance is the following in `<smachine.h>`:
-
-- `__NDIC_CR`: `set_cr()`, `get_cr()`, `set_imask()`, `get_imask()`;
-- `__NDIC_VBR`: `set_vbr()`, `get_vbr()`;
-- `__NDIC_SLEEP`: `sleep()`;
-- `__NDIC_LDTLB`: `ldtlb()`;
-- `__NDIC_CIRC`: `set_circ_x()`, `set_circ_y()`, `clr_circ()`;
-- `__NDIC_SRJSR`: `sr_jsr()`.
-
-And in `<umachine.h>`:
-
-- `__NDIC_SPC`: `set_spc()`, `get_spc()`;
-- `__NDIC_GBR`: `set_gbr()`, `get_gbr()`;
-- `__NDIC_GBR_RW`: `gbr_read_byte()`, `gbr_read_word()`, `gbr_read_long()`,
- `gbr_write_byte()`, `gbr_write_word()`, `gbr_write_long()`,
- `gbr_and_byte()`, `gbr_or_byte()`, `gbr_xor_byte()`, `gbr_tst_byte()`;
-- `__NDIC_TAS`: `tas()`;
-- `__NDIC_TRAPA`: `trapa()`, `trapa_svc()`;
-- `__NDIC_MAC`: `macw()`, `macwl()`, `macl()`, `macll()`;
-- `__NDIC_PREF`: `prefetch()`;
-- `__NDIC_FPSCR`: `set_fpscr()`, `get_fpscr()`;
-- `__NDIC_FPU_ADD`: `add4()`, `sub4()`;
-- `__NDIC_FPU_MTRX`: `ld_ext()`, `st_ext()`, `fipr()`, `ftrv()`,
- `ftrvadd()`, `ftrvsub()`, `mtrx4mul()`, `mtrx4muladd()`, `mtrx4mulsub()`;
-- `__NDIC_TRACE`: `trace()`;
-- `__NDIC_SWAP`: `swapb()`, `swapw()`, `end_cnvw()`, `end_cnvl()`;
-- `__NDIC_DMUL`: `dmulu_h()`, `dmulu_l()`, `dmuls_h()`, `dmuls_l()`;
-- `__NDIC_FSC`: `fsca()`, `fsrra()`;
-- `__NDIC_DSP`: `pabs_lf()`, `pabs_la()`, `pdmsb_lf()`, `pdmsb_la()`,
- `psha_lf()`, `psha_la()`, `long_as_lfixed()`, `lfixed_as_long()`,
- `rndtoa()`, `rndtof()`, `set_cs()`;
-- `__NDIC_CACHE`: `icbi()`, `ocbi()`, `ocbp()`, `ocbwb()`, `prefi()`,
- `sleep_i()`, `synco()`;
-- `__NDIC_T`: `movt()`, `clrt()`, `sett()`;
-- `__NDIC_CARRY`: `xtrct()`, `addc()`, `addv()`, `subc()`, `subv()`,
- `negc()`, `ovf_addc()`, `ovf_addv()`, `unf_subc()`, `unf_subv()`;
-- `__NDIC_DIV`: `div1()`, `div0s()`, `div0u()`;
-- `__NDIC_ROT`: `rotl()`, `rotr()`, `rotcl()`, `rotcr()`;
-- `__NDIC_SHIFT`: `shll()`, `shlr()`, `shar()`;
-- `__NDIC_CLIP`: `clipsb()`, `clipsw()`, `clipub()`, `clipuw()`;
-- `__NDIC_TBR`: `set_tbr()`, `get_tbr()`;
-- `__NDIC_BSET`: `bset()`, `bclr()`, `bcopy()`, `bnotcopy()`;
-- (none): `nop()`.
-
-[c]: ../core/bits.en.md
diff --git a/modules/all/core-sh/docs/bits.en.rst b/modules/all/core-sh/docs/bits.en.rst
new file mode 100644
index 0000000..b960596
--- /dev/null
+++ b/modules/all/core-sh/docs/bits.en.rst
@@ -0,0 +1,103 @@
+Bits required for SuperH compatibility
+======================================
+
+Your C compiler supports the SuperH architecture? That's great, not
+every one does! Once you have fulfilled the requirements in :ref:`all/core`,
+here is what you shall define in your compiler's specific headers.
+
+CPU type
+--------
+
+You shall define the ``_SH`` macro, and exactly one of these macros,
+representing your system:
+
+.. code-block:: c
+
+ _SH1, _SH2, _SH2A, _SH2E, _SH2AFPU, _SH3, _SH3DSP,
+ _SH4, _SH4A, _SHALDSP, _SH5
+
+DSP-C interface
+---------------
+
+The DSP-C interface from the original Hitachi compiler is optional and has to
+be enabled using an option, ``-dspc``. If your compiler currently supports
+fixed-point types, the ``_DSPC`` macro should be defined, otherwise, not.
+
+Then, if they are not already defined, it should define the following macros:
+
+- ``__fixed``: the unsigned fract fixed-point type;
+- ``__accum``: the unsigned accum fixed-point type;
+- ``__sat``: saturated arithmetic qualifier;
+- ``__circ``: modulo adressing qualifier;
+- ``__X``: X memory data qualifier;
+- ``__Y``: Y memory data qualifier.
+
+Intrinsics
+----------
+
+Headers ``<umachine.h>`` and ``<smachine.h>`` are used to define SuperH
+intrinsics. They define the `__NDIC_*` macros, literally,
+"No Define Intrinsic Condition", the condition for the intrinsic not to be
+defined (generally an ISA-related condition), then include the respective
+bit (same name as the header), then they define the fallbacks. You shall
+define everything you can using the NDIC macros. For example, here is how
+you shall define the ``trace()`` intrinsic in your bit:
+
+.. code-block:: c
+
+ #if __NDIC_TRACE
+ #else
+ /* compiler-specific definition of the `trace()` macro. */
+ #endif
+
+The correspondance is the following in ``<smachine.h>``:
+
+- ``__NDIC_CR``: ``set_cr()``, ``get_cr()``, ``set_imask()``, ``get_imask()``;
+- ``__NDIC_VBR``: ``set_vbr()``, ``get_vbr()``;
+- ``__NDIC_SLEEP``: ``sleep()``;
+- ``__NDIC_LDTLB``: ``ldtlb()``;
+- ``__NDIC_CIRC``: ``set_circ_x()``, ``set_circ_y()``, ``clr_circ()``;
+- ``__NDIC_SRJSR``: ``sr_jsr()``.
+
+And in ``<umachine.h>``:
+
+- ``__NDIC_SPC``: ``set_spc()``, ``get_spc()``;
+- ``__NDIC_GBR``: ``set_gbr()``, ``get_gbr()``;
+- ``__NDIC_GBR_RW``: ``gbr_read_byte()``, ``gbr_read_word()``,
+ ``gbr_read_long()``, ``gbr_write_byte()``, ``gbr_write_word()``,
+ ``gbr_write_long()``, ``gbr_and_byte()``, ``gbr_or_byte()``,
+ ``gbr_xor_byte()``, ``gbr_tst_byte()``;
+- ``__NDIC_TAS``: ``tas()``;
+- ``__NDIC_TRAPA``: ``trapa()``, ``trapa_svc()``;
+- ``__NDIC_MAC``: ``macw()``, ``macwl()``, ``macl()``, ``macll()``;
+- ``__NDIC_PREF``: ``prefetch()``;
+- ``__NDIC_FPSCR``: ``set_fpscr()``, ``get_fpscr()``;
+- ``__NDIC_FPU_ADD``: ``add4()``, ``sub4()``;
+- ``__NDIC_FPU_MTRX``: ``ld_ext()``, ``st_ext()``, ``fipr()``, ``ftrv()``,
+ ``ftrvadd()``, ``ftrvsub()``, ``mtrx4mul()``, ``mtrx4muladd()``,
+ ``mtrx4mulsub()``;
+- ``__NDIC_TRACE``: ``trace()``;
+- ``__NDIC_SWAP``: ``swapb()``, ``swapw()``, ``end_cnvw()``, ``end_cnvl()``;
+- ``__NDIC_DMUL``: ``dmulu_h()``, ``dmulu_l()``, ``dmuls_h()``, ``dmuls_l()``;
+- ``__NDIC_FSC``: ``fsca()``, ``fsrra()``;
+- ``__NDIC_DSP``: ``pabs_lf()``, ``pabs_la()``, ``pdmsb_lf()``, ``pdmsb_la()``,
+ ``psha_lf()``, ``psha_la()``, ``long_as_lfixed()``, ``lfixed_as_long()``,
+ ``rndtoa()``, ``rndtof()``, ``set_cs()``;
+- ``__NDIC_CACHE``: ``icbi()``, ``ocbi()``, ``ocbp()``, ``ocbwb()``,
+ ``prefi()``, ``sleep_i()``, ``synco()``;
+- ``__NDIC_T``: ``movt()``, ``clrt()``, ``sett()``;
+- ``__NDIC_CARRY``: ``xtrct()``, ``addc()``, ``addv()``, ``subc()``,
+ ``subv()``, ``negc()``, ``ovf_addc()``, ``ovf_addv()``, ``unf_subc()``,
+ ``unf_subv()``;
+- ``__NDIC_DIV``: ``div1()``, ``div0s()``, ``div0u()``;
+- ``__NDIC_ROT``: ``rotl()``, ``rotr()``, ``rotcl()``, ``rotcr()``;
+- ``__NDIC_SHIFT``: ``shll()``, ``shlr()``, ``shar()``;
+- ``__NDIC_CLIP``: ``clipsb()``, ``clipsw()``, ``clipub()``, ``clipuw()``;
+- ``__NDIC_TBR``: ``set_tbr()``, ``get_tbr()``;
+- ``__NDIC_BSET``: ``bset()``, ``bclr()``, ``bcopy()``, ``bnotcopy()``;
+- (none): ``nop()``.
+
+If ``__FREESTANDING`` is true and your macros are defined, they must work
+without code attached!
+
+[c]: ../core/bits.en.md
diff --git a/modules/all/core-sh/docs/index.en.md b/modules/all/core-sh/docs/index.en.md
deleted file mode 100644
index d8cbffb..0000000
--- a/modules/all/core-sh/docs/index.en.md
+++ /dev/null
@@ -1,16 +0,0 @@
----
-title: SuperH-specific parts of the core libc.
-chapters:
-- intrinsics
-- bits
----
-SuperH (also named SH, or J-core) is a 32-bit RISC architecture developed
-by Hitachi (later bought by Renesas) from the 90s. Among the machines using
-this are Sega (Sega Saturn, Sega 32X, Dreamcast) and CASIO (calculators such
-as the fx-9860G series). [Read more at the Wikipedia page.][wikipedia]
-
-This module brings the SuperH-specific type and macros to the core libc
-modules.
-
-[wikipedia]: https://en.wikipedia.org/wiki/SuperH
-[gcc-intrinsic]: https://gcc-renesas.com/migration-guides/sh/index.html
diff --git a/modules/all/core-sh/docs/index.en.rst b/modules/all/core-sh/docs/index.en.rst
new file mode 100644
index 0000000..0a41add
--- /dev/null
+++ b/modules/all/core-sh/docs/index.en.rst
@@ -0,0 +1,18 @@
+SuperH-specific parts of the core libc
+======================================
+
+.. chapters::
+
+ intrinsics
+ bits
+
+SuperH (also named SH, or J-core) is a 32-bit RISC architecture developed
+by Hitachi (later bought by Renesas) from the 90s. Among the machines using
+this are Sega (Sega Saturn, Sega 32X, Dreamcast) and CASIO (calculators such
+as the fx-9860G series).
+`Read more on the Wikipedia page <SuperH on Wikipedia_>`_
+
+This module brings the SuperH-specific type and macros to the freestanding libc
+modules.
+
+.. _SuperH on Wikipedia: https://en.wikipedia.org/wiki/SuperH
diff --git a/modules/all/core-sh/docs/intrinsics.en.md b/modules/all/core-sh/docs/intrinsics.en.md
deleted file mode 100644
index 7c9756d..0000000
--- a/modules/all/core-sh/docs/intrinsics.en.md
+++ /dev/null
@@ -1,242 +0,0 @@
----
-title: SuperH Intrinsics
----
-Hitachi introduced intrinsics for using some SuperH assembly into C. These
-are usually defined as macros using built-ins or other compiler-specific
-tricks. This document will describe the intrinsics and how you can use them.
-
-# <smachine.h> — privileged mode intrinsics.
-## Interacting with the status register (SR, CR)
-For interacting with the status register directly, you can use the following
-functions:
-
-```c
-uint32_t get_cr(void);
-void set_cr(uint32_t cr);
-```
-
-libcarrot also defines aliases for these (not available with Renesas'
-intrinsics):
-
-```c
-uint32_t get_sr(void);
-void set_sr(uint32_t sr);
-```
-
-For just setting the 4-bit interrupt mask in the status register, you can
-use the following functions:
-
-```c
-uint32_t get_imask(void);
-void set_imask(uint32_t mask);
-```
-
-## Interacting with the saved status register (SSR)
-libcarrot also allows you to interact with the saved status register (this
-is not available with Renesas' intrinsics), using the following functions:
-
-```
-uint32_t get_ssr(void);
-void set_ssr(uint32_t ssr);
-```
-
-## Interacting with the vector base register (VBR)
-For setting the vector base register, you can use the following functions:
-
-```c
-void** get_vbr(void);
-void set_vbr(void** base);
-```
-
-## Sleeping
-Sleeping means switching to idle mode until an interruption or exception
-occurs. It can be done by simply using this macro:
-
-```c
-void sleep(void);
-```
-
-## Load the TLB page from PTEH/PTEL
-If you are interacting with virtual memory, and filled PTEH/PTEL with your
-page information, you can use the following to load your page (equivalent
-to the `ldtlb` instruction):
-
-```c
-void ldtlb(void);
-```
-
-Please don't use this if you don't know what it is.
-
-## Modulo addressing
-These specifies and cancels modulo addressing (??).
-
-```c
-void set_circ_x(array, size);
-void set_circ_y(array, size);
-void clr_circ();
-```
-
-## Set the interrupt mask level and jump to subroutine
-If I am right on the macro signification, then I don't understand why
-it's useful. I thought it was basically there to force the 'store to control
-register' to be in the delayed branch of the 'jump to subroutine', which
-may not be enforced by default by Hitachi's compiler...?
-
-```c
-void sr_jsr(int (*func)(), uint32_t imask);
-```
-
-# <umachine.h> — user mode intrinsics.
-## Interacting with the saved process counter (SPC)
-You might want to tweak some function returning behaviour using these
-functions:
-
-```c
-uint32_t get_spc(void);
-void set_spc(uint32_t spc);
-```
-
-## Interacting with and using the global base register (GBR)
-First, for interacting directly with the GBR, you can use the following
-functions:
-
-```c
-void set_gbr(void* base);
-void* get_gbr(void);
-```
-
-Then, once set, you can read using it:
-
-```c
-uint8_t gbr_read_byte(int offset);
-uint16_t gbr_read_word(int offset);
-uint32_t gbr_read_long(int offset);
-```
-
-But also write:
-
-```c
-void gbr_write_byte(int offset, uint8_t data);
-void gbr_write_word(int offset, uint16_t data);
-void gbr_write_long(int offset, uint32_t data);
-
-void gbr_and_byte(int offset, uint8_t mask);
-void gbr_or_byte(int offset, uint8_t mask);
-void gbr_xor_byte(int offset, uint8_t mask);
-void gbr_tst_byte(int offset, uint8_t mask);
-```
-
-## Purge a cache block
-This function corresponds to the `TAS.B` instruction, and purges the
-cache block corresponding to a memory area.
-
-```c
-void tas(void* addr);
-```
-
-## Trap
-A trap is a user-made exception that can be used for system calls. There are
-two different types of traps:
-
-```c
-int trapa(int trap_no);
-int trapa_svc(int trap_no, int code, ...);
-```
-
-The first simply is an alias for assembly `TRAPA #NO`, the second one is
-a **s**uper**v**isor **c**all: it places the arguments (max. 4 arguments)
-in r4 to r7, the syscall code in r0, and traps using the trap number.
-
-## Multiply and accumulate
-This instruction performs signed multiplication of two operands.
-
-```c
-uint32_t macw(uint16_t* ptr1, uint16_t* ptr2, int count);
-uint32_t macwl(uint16_t* ptr1, uint16_t* ptr2, int count, uint16_t mask);
-uint32_t macl(uint32_t* ptr1, uint32_t* ptr2, int count);
-uint32_t macll(uint32_t* ptr1, uint32_t* ptr2, int count, uint32_t mask);
-```
-
-## Prefetch a memory area
-This instruction loads data to cache on software prefetching:
-
-```c
-void prefetch(void* addr);
-```
-
-## Interact with the FPU System Register
-
-```c
-uint32_t get_fpscr(void);
-void set_fpscr(uint32_t cr);
-```
-
-## Floating-point operations
-These, someone should describe someday. (TODO)
-
-```c
-void add4(float vec1[4], float vec2[4]);
-void sub4(float vec1[4], float vec2[4]);
-
-void ld_ext(float vec[4][4]);
-void st_ext(float vec[4][4]);
-
-void fipr(float vec1[4], float vec2[4]);
-void ftrv(float vec1[4], float vec2[4]);
-void ftrvadd(float vec1[4], float vec2[4], float vec3[4]);
-void ftrvsub(float vec1[4], float vec2[4], float vec3[4]);
-
-void mtrx4mul(float mat1[4][4], float mat2[4][4]);
-void mtrx4muladd(float mat1[4][4], float mat2[4][4]);
-void mtrx4mulsub(float mat1[4][4], float mat2[4][4]);
-```
-
-## Trace a register (variable) on the emulator
-Yes, this instruction is specific to the emulator. Why not after all?
-
-```c
-void trace(<variable>);
-```
-
-## No operation
-Do nothing.
-
-```c
-void nop(void);
-```
-
-## Swap bytes
-There are assembly instructions for swapping bytes, please use them instead of
-doing it yourself!
-
-```c
-uint16_t swapb(uint16_t data);
-uint32_t swapw(uint32_t data);
-```
-
-There are also equivalents I can't seem to understand…?
-
-```c
-uint16_t end_cnvw(uint16_t rm);
-uint32_t end_cnvl(uint32_t data);
-```
-
-## Double-length Multiply As Signed
-These instructions perform 32-bit mutliplications of two operations, and
-stores the 64-bit result in the MACH and MACL.
-
-```c
-uint32_t dmulu_h(uint32_t a, uint32_t b);
-uint32_t dmulu_l(uint32_t a, uint32_t b);
-uint32_t dmuls_h(uint32_t a, uint32_t b);
-uint32_t dmuls_l(uint32_t a, uint32_t b);
-```
-
-## Floating-point sine, cosine and square reciprocal approximate
-Calculates the sine, the cosine or the square reciprocal approximation
-of FPUL.
-
-```c
-void fsca(int32_t angle, float *sinv, float *cosv);
-void fsrra(float data);
-```
diff --git a/modules/all/core-sh/docs/intrinsics.en.rst b/modules/all/core-sh/docs/intrinsics.en.rst
new file mode 100644
index 0000000..6b5856c
--- /dev/null
+++ b/modules/all/core-sh/docs/intrinsics.en.rst
@@ -0,0 +1,290 @@
+SuperH Intrinsics
+=================
+
+Hitachi introduced intrinsics for using some SuperH assembly into C. These
+are usually defined as macros using built-ins or other compiler-specific
+tricks. This document will describe the intrinsics and how you can use them.
+
+Some of the intrinsics are defined for GCC using the
+`GNUSH Migration Guide`_.
+
+``<smachine.h>`` — privileged mode intrinsics
+---------------------------------------------
+
+Interacting with the status register (SR, CR)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+For interacting with the status register directly, you can use the following
+functions:
+
+.. code-block:: c
+
+ uint32_t get_cr(void);
+ void set_cr(uint32_t cr);
+
+libcarrot also defines aliases for these (not available with Renesas'
+intrinsics):
+
+.. code-block:: c
+
+ uint32_t get_sr(void);
+ void set_sr(uint32_t sr);
+
+For just setting the 4-bit interrupt mask in the status register, you can
+use the following functions:
+
+.. code-block:: c
+
+ uint32_t get_imask(void);
+ void set_imask(uint32_t mask);
+
+Interacting with the saved status register (SSR)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+libcarrot also allows you to interact with the saved status register (this
+is not available with Renesas' intrinsics), using the following functions:
+
+.. code-block:: c
+
+ uint32_t get_ssr(void);
+ void set_ssr(uint32_t ssr);
+
+Interacting with the vector base register (VBR)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+For setting the vector base register, you can use the following functions:
+
+.. code-block:: c
+
+ void** get_vbr(void);
+ void set_vbr(void** base);
+
+Sleeping
+~~~~~~~~
+
+Sleeping means switching to idle mode until an interruption or exception
+occurs. It can be done by simply using this macro:
+
+.. code-block:: c
+
+ void sleep(void);
+
+Load the TLB page from PTEH/PTEL
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+If you are interacting with virtual memory, and filled PTEH/PTEL with your
+page information, you can use the following to load your page (equivalent
+to the `ldtlb` instruction):
+
+.. code-block:: c
+
+ void ldtlb(void);
+
+Please don't use this if you don't know what it is.
+
+Modulo addressing
+~~~~~~~~~~~~~~~~~
+
+These specifies and cancels modulo addressing (??).
+
+.. code-block:: c
+
+ void set_circ_x(array, size);
+ void set_circ_y(array, size);
+ void clr_circ();
+
+Set the interrupt mask level and jump to subroutine
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+If I am right on the macro signification, then I don't understand why
+it's useful. I thought it was basically there to force the 'store to control
+register' to be in the delayed branch of the 'jump to subroutine', which
+may not be enforced by default by Hitachi's compiler...?
+
+.. code-block:: c
+
+ void sr_jsr(int (*func)(), uint32_t imask);
+
+``<umachine.h>`` — user mode intrinsics
+---------------------------------------
+
+Interacting with the saved process counter (SPC)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You might want to tweak some function returning behaviour using these
+functions:
+
+.. code-block:: c
+
+ uint32_t get_spc(void);
+ void set_spc(uint32_t spc);
+
+Interacting with and using the global base register (GBR)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+First, for interacting directly with the GBR, you can use the following
+functions:
+
+.. code-block:: c
+
+ void set_gbr(void* base);
+ void* get_gbr(void);
+
+Then, once set, you can read using it:
+
+.. code-block:: c
+
+ uint8_t gbr_read_byte(int offset);
+ uint16_t gbr_read_word(int offset);
+ uint32_t gbr_read_long(int offset);
+
+But also write:
+
+.. code-block:: c
+
+ void gbr_write_byte(int offset, uint8_t data);
+ void gbr_write_word(int offset, uint16_t data);
+ void gbr_write_long(int offset, uint32_t data);
+
+ void gbr_and_byte(int offset, uint8_t mask);
+ void gbr_or_byte(int offset, uint8_t mask);
+ void gbr_xor_byte(int offset, uint8_t mask);
+ void gbr_tst_byte(int offset, uint8_t mask);
+
+Purge a cache block
+~~~~~~~~~~~~~~~~~~~
+
+This function corresponds to the ``TAS.B`` instruction, and purges the
+cache block corresponding to a memory area.
+
+.. code-block:: c
+
+ void tas(void* addr);
+
+Trap
+~~~~
+
+A trap is a user-made exception that can be used for system calls. There are
+two different types of traps:
+
+.. code-block:: c
+
+ int trapa(int trap_no);
+ int trapa_svc(int trap_no, int code, ...);
+
+The first simply is an alias for assembly ``TRAPA #NO``, the second one is
+a **s**uper**v**isor **c**all: it places the arguments (max. 4 arguments)
+in r4 to r7, the syscall code in r0, and traps using the trap number.
+
+Multiply and accumulate
+~~~~~~~~~~~~~~~~~~~~~~~
+
+This instruction performs signed multiplication of two operands.
+
+.. code-block:: c
+
+ uint32_t macw(uint16_t* ptr1, uint16_t* ptr2, int count);
+ uint32_t macwl(uint16_t* ptr1, uint16_t* ptr2, int count, uint16_t mask);
+ uint32_t macl(uint32_t* ptr1, uint32_t* ptr2, int count);
+ uint32_t macll(uint32_t* ptr1, uint32_t* ptr2, int count, uint32_t mask);
+
+Prefetch a memory area
+~~~~~~~~~~~~~~~~~~~~~~
+
+This instruction loads data to cache on software prefetching:
+
+.. code-block:: c
+
+ void prefetch(void* addr);
+
+Interact with the FPU System Register
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: c
+
+ uint32_t get_fpscr(void);
+ void set_fpscr(uint32_t cr);
+
+Floating-point operations
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+These, someone should describe someday. (TODO)
+
+.. code-block:: c
+
+ void add4(float vec1[4], float vec2[4]);
+ void sub4(float vec1[4], float vec2[4]);
+
+ void ld_ext(float vec[4][4]);
+ void st_ext(float vec[4][4]);
+
+ void fipr(float vec1[4], float vec2[4]);
+ void ftrv(float vec1[4], float vec2[4]);
+ void ftrvadd(float vec1[4], float vec2[4], float vec3[4]);
+ void ftrvsub(float vec1[4], float vec2[4], float vec3[4]);
+
+ void mtrx4mul(float mat1[4][4], float mat2[4][4]);
+ void mtrx4muladd(float mat1[4][4], float mat2[4][4]);
+ void mtrx4mulsub(float mat1[4][4], float mat2[4][4]);
+
+Trace a register (variable) on the emulator
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Yes, this instruction is specific to the emulator. Why not after all?
+
+.. code-block:: c
+
+ void trace(<variable>);
+
+No Operation
+~~~~~~~~~~~~
+
+Do nothing.
+
+.. code-block:: c
+
+ void nop(void);
+
+Swap bytes
+~~~~~~~~~~
+
+There are assembly instructions for swapping bytes, please use them instead of
+doing it yourself!
+
+.. code-block:: c
+
+ uint16_t swapb(uint16_t data);
+ uint32_t swapw(uint32_t data);
+
+There are also equivalents I can't seem to understand…?
+
+.. code-block:: c
+
+ uint16_t end_cnvw(uint16_t rm);
+ uint32_t end_cnvl(uint32_t data);
+
+Double-length Multiply As Signed
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+These instructions perform 32-bit mutliplications of two operations, and
+stores the 64-bit result in the MACH and MACL.
+
+.. code-block:: c
+
+ uint32_t dmulu_h(uint32_t a, uint32_t b);
+ uint32_t dmulu_l(uint32_t a, uint32_t b);
+ uint32_t dmuls_h(uint32_t a, uint32_t b);
+ uint32_t dmuls_l(uint32_t a, uint32_t b);
+
+Floating-point sine, cosine and square reciprocal approximate
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Calculates the sine, the cosine or the square reciprocal approximation
+of FPUL.
+
+.. code-block:: c
+
+ void fsca(int32_t angle, float *sinv, float *cosv);
+ void fsrra(float data);
+
+.. _GNUSH Migration Guide: https://gcc-renesas.com/migration-guides/sh/index.html
diff --git a/modules/all/core-sh/include/smachine.h b/modules/all/core-sh/include/smachine.h
index 799abd5..c6c56a6 100644
--- a/modules/all/core-sh/include/smachine.h
+++ b/modules/all/core-sh/include/smachine.h
@@ -19,3 +19,23 @@ _BEGIN_DECLS
#define __NDIC_SRJSR 0
#include_bits <smachine.h>
+
+/* Define code replacements for non-freestanding environments. */
+
+#if !__FREESTANDING
+#if !__NDIC_SSR && !defined(get_ssr)
+extern uint32_t __asm_get_ssr _OF((void));
+extern void __asm_set_ssr _OF((uint32_t __x));
+
+# define get_ssr() __asm_get_ssr()
+# define set_ssr(_SSR) __asm_set_ssr(_SSR)
+#endif
+
+#if !defined(get_spc)
+extern uint32_t __asm_get_spc _OF((void));
+extern void __asm_set_spc _OF((uint32_t __x));
+
+# define get_spc() __asm_get_spc()
+# define set_spc(_SPC) __asm_set_spc(_SPC)
+#endif
+#endif
diff --git a/modules/all/core-sh/info.yml b/modules/all/core-sh/info.yml
index 11f1e4e..394578d 100644
--- a/modules/all/core-sh/info.yml
+++ b/modules/all/core-sh/info.yml
@@ -1,7 +1,7 @@
%YAML 1.2
---
magic: potatosdk-1.0
-description: The core libc, SuperH-specific parts.
+description: The freestanding libc, SuperH-specific parts.
license: free
requires:
arch: [sh]
diff --git a/modules/all/core-sh/roles.yml b/modules/all/core-sh/roles.yml
index 5cc3fa3..e8220aa 100644
--- a/modules/all/core-sh/roles.yml
+++ b/modules/all/core-sh/roles.yml
@@ -2,10 +2,17 @@
---
bits:
byteswap.h: Optimized byteswapping utilities for SuperH.
- setjmp.h: Non-local jump buffer type.
include:
builtin.h: Built-ins for SHC.
fixed.h: Fixed-point numbers, Renesas' way.
machine.h: SuperH intrinsics.
smachine.h: SuperH intrinsics, privileged mode.
umachine.h: SuperH intrinsics, user mode.
+src:
+ bswap16.s: Hosted bswap_16 fallback.
+ bswap32.s: Hosted bswap_32 fallback.
+ smachine:
+ spc.src: Hosted get_spc and set_spc fallbacks for Asmsh.
+ spc.s: Hosted get_spc and set_spc fallbacks for GNU AS.
+ ssr.src: Hosted get_ssr and set_ssr fallbacks for Asmsh.
+ ssr.s: Hosted get_ssr and set_ssr fallbacks for GNU AS.
diff --git a/modules/all/core-sh/src/bswap16.s b/modules/all/core-sh/src/bswap16.s
index ba8a490..df49a18 100644
--- a/modules/all/core-sh/src/bswap16.s
+++ b/modules/all/core-sh/src/bswap16.s
@@ -1,9 +1,9 @@
-/* `bswap16(integer)`: swap bytes in a 16-bit integer. */
+/* `__bswap16(integer)`: swap bytes in a 16-bit integer. */
.section .text
-.global _bswap_16
-.type _bswap_16, @function
-_bswap_16:
+.global ___bswap_16
+.type ___bswap_16, @function
+___bswap_16:
swap.b r4, r4
rts
mov r4, r0
diff --git a/modules/all/core-sh/src/bswap32.s b/modules/all/core-sh/src/bswap32.s
index e85b2cc..d5f34c6 100644
--- a/modules/all/core-sh/src/bswap32.s
+++ b/modules/all/core-sh/src/bswap32.s
@@ -1,9 +1,9 @@
-/* `bswap16(integer)`: swap bytes in a 32-bit integer. */
+/* `__bswap32(integer)`: swap bytes in a 32-bit integer. */
.section .text
-.global _bswap_32
-.type _bswap_32, @function
-_bswap_32:
+.global ___bswap_32
+.type ___bswap_32, @function
+___bswap_32:
swap.b r4, r4
swap.w r4, r4
swap.b r4, r4
diff --git a/modules/all/core/copyright.yml b/modules/all/core/copyright.yml
index 52437d8..546a0ed 100644
--- a/modules/all/core/copyright.yml
+++ b/modules/all/core/copyright.yml
@@ -2,9 +2,9 @@
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
---
files: 'src/ctype/tab.c'
copyright:
- [1991, 2016, "Free Software Foundation, Inc", "info@fsf.org"]
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/all/core/docs/bits.en.md b/modules/all/core/docs/bits.en.md
deleted file mode 100644
index a80b5a3..0000000
--- a/modules/all/core/docs/bits.en.md
+++ /dev/null
@@ -1,152 +0,0 @@
----
-title: Bits used by the core libc.
----
-For compiler, architecture or system specific content, this module includes
-a few header bits. Please define them in your compiler, architecture and
-system default modules.
-
-# Compiler-specific headers
-## `compiler.h` — compiler identification and additional features.
-This header bit defines the compiler identification macro, usually
-`__<COMPILER>_PREREQ(major, minor)`, as 1 if we are indeed using a compiler
-that is compatible with this version of the compiler, or 0 if this version
-doesn't exist or the current compiler or version of the compiler
-aren't compatible.
-
-It also defines some non-standard attributes the headers can use to generate
-warnings or optimized code. The attributes are usually used this way:
-
-```c
-extern __my_attr void bake_bread(int bread);
-
-__my_attr void bake_bread(int bread)
-{
- /* ... */
-}
-```
-
-Here are the different attributes you can set:
-
-- `__inline`: force the inlining of a function;
-- `__pure`: produce a value out of others, with no side effect whatsoever;
-- `__wur`: warn if the result is unused (might have side effects);
-- `__malloc`: is a memory allocation function;
-- `__deprecated`: this function or element should not be used;
-- `__noreturn`: the function doesn't return (makes a long jump);
-- `__nothrow`: the function won't throw (C++ thingy);
-- `__unroll_loops`: should unroll the loops with constant number of passes
- if possible;
-- `__nonnull(index, name)`:
- an argument with name `name` and index `index` (starting from 1) should not
- have an invalid pointer value;
-- `__printf_format(format_index, args_index)`:
- the function is a printf-like function, where `format_index` is the index
- (starting from 1) of the format string, and `args_index` is the index
- (also starting from 1) of the `...`;
-
-The header bit can also define some utilities:
-
-- `likely(expr)`, `unlikely(expr)`:
- optimize the branching structure for a likely or unlikely condition.
-
-Don't set the macros that your compiler won't support, they will be reset.
-
-## `endian.h` — endianness identification.
-This header bit defines the `__BYTE_ORDER` macro, which can expand to
-those values:
-
-- `__LITTLE_ENDIAN`: the architecture is little endian;
-- `__BIG_ENDIAN`: the architecture is big endian;
-- `__PDP_ENDIAN`: the architecture is PDP endian.
-
-## `stdarg.h` — ISO C variable argument lists.
-This header bit defines the ISO C type `__stdarg_va_list`, and the
-following macros:
-
-- `__stdarg_va_start(ap, param)`
-- `__stdarg_va_end(ap)`
-- `__stdarg_va_arg(ap, arg_type)`
-- `__stdarg_va_copy(dest, src)`
-
-## `types/primitive.h` — details about primitive types.
-For each one of the `char` (`CHAR`), `short` (`SHRT`), `int` (`INT`),
-`long` (`LONG`) and `long long` (`LLONG`) types, the following macros
-should be provided in this header bit:
-
-- `__<TYPE>_WIDTH`: the bit width of the type;
-- `__<TYPE>_MIN`: the minimum value of the signed version of the type;
-- `__<TYPE>_MAX`: the maximum value of the signed version of the type;
-- `__U<TYPE>_MIN`: the minimum value of the unsigned version of the type;
-- `__U<TYPE>_MAX`: the maximum value of the unsigned version of the type.
-
-In addition, the following macros should be provided in this header bit:
-
-- `__CHAR_IS_SIGNED`: whether the `char` type is signed by default (1)
- or not (0).
-
-## `types/exact.h` — exact-width integer types.
-This header bit provides the types and type details for the exactly 8-bit,
-16-bit and 32-bit integer types, using these macros:
-
-- `__int<N>_t`: signed version of the exactly N-bit integer type;
-- `__uint<N>_t`: unsigned version of the exactly N-bit integer type;
-- `__INT<N>_MIN`: the minimum value for the signed version of the type;
-- `__INT<N>_MAX`: the maximum value for the signed version of the type;
-- `__UINT<N>_MIN`: the minimum value for the unsigned version of the type;
-- `__UINT<N>_MAX`: the maximum value for the unsigned version of the type;
-- `__PRI<N>`: the string prefix for printf (e.g. `"hh"` for `char`).
-
-## `types/least.h` — least-width integer types.
-This header bit provides the types and type details for the least 8-bit,
-16-bit and 32-bit integer types, using these macros:
-
-- `__int_least<N>_t`: signed version of the least N-bit integer type;
-- `__uint_least<N>_t`: unsigned version of the least N-bit integer type;
-- `__INT_LEAST<N>_WIDTH`: the bit width of the type (e.g. 32);
-- `__INT_LEAST<N>_MIN`: the minimum value for the signed version of the type;
-- `__INT_LEAST<N>_MAX`: the maximum value for the signed version of the type;
-- `__INT<N>_C(num)`: cast a number to the signed version of the type;
-- `__UINT_LEAST<N>_MIN`: the minimum value for the unsigned version
- of the type;
-- `__UINT_LEAST<N>_MAX`: the maximum value for the unsigned version
- of the type;
-- `__UINT<N>_C(num)`: cast a number to the unsigned version of the type;
-- `__PRILEAST<N>`: the string prefix for printf.
-
-## `types/fast.h` — fast least-width integer types.
-This header bit provides the types and type details for the fast 8-bit,
-16-bit and 32-bit integer types, using these macros:
-
-- `__int_fast<N>_t`: signed version of the least N-bit integer type;
-- `__uint_fast<N>_t`: unsigned version of the least N-bit integer type;
-- `__INT_FAST<N>_WIDTH`: the bit width of the type (e.g. 32);
-- `__INT_FAST<N>_MIN`: the minimum value for the signed version of the type;
-- `__INT_FAST<N>_MAX`: the maximum value for the signed version of the type;
-- `__UINT_FAST<N>_MIN`: the minimum value for the unsigned version
- of the type;
-- `__UINT_FAST<N>_MAX`: the maximum value for the unsigned version
- of the type;
-- `__PRIFAST<N>`: the string prefix for printf.
-
-## `types/max.h` — maximum-width integer types.
-This header bit provides the types and type details for the maximum-width
-integer types, using these macros:
-
-- `__intmax_t`: signed version of the maximum integer type;
-- `__uintmax_t`: unsigned version of the maximum integer type;
-- `__INTMAX_WIDTH`: the bit width of the type;
-- `__INTMAX_MIN`: the minimum value of the signed version of the type;
-- `__INTMAX_MAX`: the maximum value of the signed version of the type;
-- `__INTMAX_C(num)`: cast a number to the signed version of the type;
-- `__UINTMAX_MIN`: the minimum value of the unsigned version of the type;
-- `__UINTMAX_MAX`: the maximum value of the unsigned version of the type;
-- `__UINTMAX_C(num)`: cast a number to the unsigned version of the type;
-- `__PRIMAX`: the string prefix for printf.
-
-# Architecture-specific headers
-## `byteswap.h` — byteswap utilities.
-This header bit can define the `__bswap_16` and `__bswap_32` macros, optimized
-for the system.
-
-## `setjmp.h` — long jumps.
-This header bit defines the `jmp_buf` type for `setjmp.h`.
diff --git a/modules/all/core/docs/bits.en.rst b/modules/all/core/docs/bits.en.rst
new file mode 100644
index 0000000..c2e8d55
--- /dev/null
+++ b/modules/all/core/docs/bits.en.rst
@@ -0,0 +1,172 @@
+Bits used by the freestanding libc headers
+==========================================
+
+For compiler, architecture or system specific content, this module includes
+a few header bits. Please define them in your compiler, architecture and
+system default modules.
+
+Compiler-specific headers
+-------------------------
+
+``compiler.h`` — compiler identification and additional features
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This header bit defines the compiler identification macro, usually
+``__<COMPILER>_PREREQ(major, minor)``, as 1 if we are indeed using a compiler
+that is compatible with this version of the compiler, or 0 if this version
+doesn't exist or the current compiler or version of the compiler
+aren't compatible.
+
+It also defines some non-standard attributes the headers can use to generate
+warnings or optimized code. The attributes are usually used this way:
+
+.. code-block:: c
+
+ extern __my_attr void bake_bread(int bread);
+
+ __my_attr void bake_bread(int bread)
+ {
+ /* ... */
+ }
+
+Here are the different attributes you can set:
+
+- ``__inline``: force the inlining of a function;
+- ``__pure``: produce a value out of others, with no side effect whatsoever;
+- ``__wur``: warn if the result is unused (might have side effects);
+- ``__malloc``: is a memory allocation function;
+- ``__deprecated``: this function or element should not be used;
+- ``__noreturn``: the function doesn't return (makes a long jump);
+- ``__nothrow``: the function won't throw (C++ thingy);
+- ``__unroll_loops``: should unroll the loops with constant number of passes
+ if possible;
+- ``__nonnull(index, name)``:
+ an argument with name `name` and index ``index`` (starting from 1) should not
+ have an invalid pointer value;
+- ``__printf_format(format_index, args_index)``:
+ the function is a printf-like function, where ``format_index`` is the index
+ (starting from 1) of the format string, and ``args_index`` is the index
+ (also starting from 1) of the ``...``;
+
+The header bit can also define some utilities:
+
+- ``likely(expr)``, ``unlikely(expr)``:
+ optimize the branching structure for a likely or unlikely condition.
+
+Don't set the macros that your compiler won't support, they will be reset.
+
+``endian.h`` — endianness identification
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This header bit defines the ``__BYTE_ORDER`` macro, which can expand to
+those values:
+
+- ``__LITTLE_ENDIAN``: the architecture is little endian;
+- ``__BIG_ENDIAN``: the architecture is big endian;
+- ``__PDP_ENDIAN``: the architecture is PDP endian.
+
+``stdarg.h`` — ISO C variable argument lists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This header bit defines the ISO C type ``__stdarg_va_list``, and the
+following macros:
+
+- ``__stdarg_va_start(ap, param)``
+- ``__stdarg_va_end(ap)``
+- ``__stdarg_va_arg(ap, arg_type)``
+- ``__stdarg_va_copy(dest, src)``
+
+``types/primitive.h`` — details about primitive types
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+For each one of the ``char`` (``CHAR``), ``short`` (``SHRT``),
+``int`` (``INT``), ``long`` (``LONG``) and ``long long`` (``LLONG``) types,
+the following macros should be provided in this header bit:
+
+- ``__<TYPE>_WIDTH``: the bit width of the type;
+- ``__<TYPE>_MIN``: the minimum value of the signed version of the type;
+- ``__<TYPE>_MAX``: the maximum value of the signed version of the type;
+- ``__U<TYPE>_MIN``: the minimum value of the unsigned version of the type;
+- ``__U<TYPE>_MAX``: the maximum value of the unsigned version of the type.
+
+In addition, the following macros should be provided in this header bit:
+
+- ``__CHAR_IS_SIGNED``: whether the `char` type is signed by default (1)
+ or not (0).
+
+``types/exact.h`` — exact-width integer types
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This header bit provides the types and type details for the exactly 8-bit,
+16-bit and 32-bit integer types, using these macros:
+
+- ``__int<N>_t``: signed version of the exactly N-bit integer type;
+- ``__uint<N>_t``: unsigned version of the exactly N-bit integer type;
+- ``__INT<N>_MIN``: the minimum value for the signed version of the type;
+- ``__INT<N>_MAX``: the maximum value for the signed version of the type;
+- ``__UINT<N>_MIN``: the minimum value for the unsigned version of the type;
+- ``__UINT<N>_MAX``: the maximum value for the unsigned version of the type;
+- ``__PRI<N>``: the string prefix for printf (e.g. `"hh"` for `char`).
+
+``types/least.h`` — least-width integer types
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This header bit provides the types and type details for the least 8-bit,
+16-bit and 32-bit integer types, using these macros:
+
+- ``__int_least<N>_t``: signed version of the least N-bit integer type;
+- ``__uint_least<N>_t``: unsigned version of the least N-bit integer type;
+- ``__INT_LEAST<N>_WIDTH``: the bit width of the type (e.g. 32);
+- ``__INT_LEAST<N>_MIN``: the minimum value for the signed version of the type;
+- ``__INT_LEAST<N>_MAX``: the maximum value for the signed version of the type;
+- ``__INT<N>_C(num)``: cast a number to the signed version of the type;
+- ``__UINT_LEAST<N>_MIN``: the minimum value for the unsigned version
+ of the type;
+- ``__UINT_LEAST<N>_MAX``: the maximum value for the unsigned version
+ of the type;
+- ``__UINT<N>_C(num)``: cast a number to the unsigned version of the type;
+- ``__PRILEAST<N>``: the string prefix for printf.
+
+``types/fast.h`` — fast least-width integer types
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This header bit provides the types and type details for the fast 8-bit,
+16-bit and 32-bit integer types, using these macros:
+
+- ``__int_fast<N>_t``: signed version of the least N-bit integer type;
+- ``__uint_fast<N>_t``: unsigned version of the least N-bit integer type;
+- ``__INT_FAST<N>_WIDTH``: the bit width of the type (e.g. 32);
+- ``__INT_FAST<N>_MIN``: the minimum value for the signed version of the type;
+- ``__INT_FAST<N>_MAX``: the maximum value for the signed version of the type;
+- ``__UINT_FAST<N>_MIN``: the minimum value for the unsigned version
+ of the type;
+- ``__UINT_FAST<N>_MAX``: the maximum value for the unsigned version
+ of the type;
+- ``__PRIFAST<N>``: the string prefix for printf.
+
+``types/max.h`` — maximum-width integer types
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This header bit provides the types and type details for the maximum-width
+integer types, using these macros:
+
+- ``__intmax_t``: signed version of the maximum integer type;
+- ``__uintmax_t``: unsigned version of the maximum integer type;
+- ``__INTMAX_WIDTH``: the bit width of the type;
+- ``__INTMAX_MIN``: the minimum value of the signed version of the type;
+- ``__INTMAX_MAX``: the maximum value of the signed version of the type;
+- ``__INTMAX_C(num)``: cast a number to the signed version of the type;
+- ``__UINTMAX_MIN``: the minimum value of the unsigned version of the type;
+- ``__UINTMAX_MAX``: the maximum value of the unsigned version of the type;
+- ``__UINTMAX_C(num)``: cast a number to the unsigned version of the type;
+- ``__PRIMAX``: the string prefix for printf.
+
+Architecture-specific headers
+-----------------------------
+
+``byteswap.h`` — byteswap utilities
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This header bit can define the ``__bswap_16`` and ``__bswap_32`` macros,
+optimized for the architecture. If defined and ``__FREESTANDING`` is true,
+they must work without code attached!
diff --git a/modules/all/core/docs/index.en.md b/modules/all/core/docs/index.en.md
deleted file mode 100644
index 3422bf6..0000000
--- a/modules/all/core/docs/index.en.md
+++ /dev/null
@@ -1,11 +0,0 @@
----
-title: The core libc module.
-chapters:
-- bits
----
-This is the system-independant libc core. It aims at being C89, C99 and C11
-compliant, using the standard C macros.
-
-The system-specific macros and types are taken from the header bits,
-which are usually defined by `core-<arch>`, `compiler-<comp>` and
-the system default modules.
diff --git a/modules/all/core/docs/index.en.rst b/modules/all/core/docs/index.en.rst
new file mode 100644
index 0000000..29284f0
--- /dev/null
+++ b/modules/all/core/docs/index.en.rst
@@ -0,0 +1,16 @@
+The core libc module
+====================
+
+.. chapters::
+
+ bits
+
+This is the freestanding, therefore system-independant, libc core. It only
+provides headers, and, once generated, can be provided without a binary
+library to link against.
+
+It aims at being C89, C99 and C11 compliant, using the standard C macros.
+
+The system-specific macros and types are taken from the header bits,
+which are usually defined by ``all/core-<arch>``, ``compiler/host-<comp>``
+and ``compiler/target-<comp>``.
diff --git a/modules/all/core/include/cdefs.h b/modules/all/core/include/cdefs.h
index 7288d0d..7fbb71c 100644
--- a/modules/all/core/include/cdefs.h
+++ b/modules/all/core/include/cdefs.h
@@ -38,9 +38,7 @@
/* ************************************************************************* */
/* `_THROW`: optimize function calls for C++. */
-#if _USE_CXX98
-# define _THROW throw()
-#elif defined(__nothrow)
+#if defined(__nothrow)
# define _THROW __nothrow
#else
# define _THROW
@@ -175,16 +173,20 @@
# define _OF(_ARGS) ()
#endif
-/* Some compilers have different versions of `extern` and `static` (local). */
+/* Some compilers have different versions of `extern` and `static` (local),
+ * or the library might want to add attributes to this. */
#define _LOCAL static
#define _EXTERN extern
/* C++ needs to know that types and declarations are C, not C++. */
-#if _USE_CXX98
-# define _BEGIN_DECLS extern "C" {
-# define _END_DECLS }
+#if 0
+/* If libcarrot supports C++ one day, these definitions behind
+ * a C++ feature test would be great. */
+
+# define _BEGIN_DECLS extern "C" {
+# define _END_DECLS }
#else
# define _BEGIN_DECLS
# define _END_DECLS
@@ -199,7 +201,10 @@
* The C++ wrapper header take case of adding the definition to
* the global namespace. */
-#if _USE_CXX98
+#if 0
+/* If libcarrot supports C++ one day, these definitions behind
+ * a C++ feature test would be great. */
+
# define _BEGIN_NAMESPACE_STD namespace std {
# define _USING_NAMESPACE_STD(_NAME) using std::_NAME;
# define _END_NAMESPACE_STD }
diff --git a/modules/all/core/include/endian.h b/modules/all/core/include/endian.h
index a012924..a8ccc57 100644
--- a/modules/all/core/include/endian.h
+++ b/modules/all/core/include/endian.h
@@ -32,14 +32,17 @@
#include <byteswap.h>
/* Get the current architecture's endianness. */
+
#define __LITTLE_ENDIAN 4321
#define __BIG_ENDIAN 1234
#define __PDP_ENDIAN 3412
#include_bits <endian.h>
-/* ************************************************************************* */
-/* Endian swapping utilities */
-/* ************************************************************************* */
+
+/* ---
+ * Endian swapping utilities.
+ * --- */
+
#if __BYTE_ORDER == __LITTLE_ENDIAN
# define htobe16(i) (bswap_16(i))
# define htole16(i) (i)
diff --git a/modules/all/core/include/features.h b/modules/all/core/include/features.h
index 7d2d8b5..6aab5ec 100644
--- a/modules/all/core/include/features.h
+++ b/modules/all/core/include/features.h
@@ -108,33 +108,6 @@
* `_REENTRANT`, `_THREAD_SAFE`:
* Obsolete; equivalent to `_POSIX_C_SOURCE=199506L. */
/* ************************************************************************* */
-/* C++ features */
-/* ************************************************************************* */
-/* There are different versions for the C++ language:
- * - ISO C++98 (_USE_CXX98 defined);
- * - ISO C++11 (_USE_CXX11 defined).
- *
- * Each version of the language offers a different level of support
- * from libcarrot. */
-
-#ifdef _USE_CXX98
-# undef _USE_CXX98
-#endif
-#if !defined(__cplusplus)
-# define _USE_CXX98 0
-#else
-# define _USE_CXX98 1
-#endif
-
-#ifdef _USE_CXX11
-# undef _USE_CXX11
-#endif
-#if __cplusplus >= 201103L
-# define _USE_CXX11 1
-#else
-# define _USE_CXX11 0
-#endif
-/* ************************************************************************* */
/* C features */
/* ************************************************************************* */
/* There are different versions for the C language:
@@ -186,3 +159,22 @@
#else
# define _USE_C11 0
#endif
+
+/* ************************************************************************* */
+/* C++ features */
+/* ************************************************************************* */
+/* Actually, as C++ is not managed by libcarrot yet, this is only a
+ * placeholder. */
+
+#define _USE_CXX98 0
+
+#define _USE_CXX03 0
+
+#define _USE_CXX11 0
+#define _USE_CXX1X _USE_CXX11
+
+#define _USE_CXX14 0
+#define _USE_CXX1Y _USE_CXX14
+
+#define _USE_CXX17 0
+#define _USE_CXX1Z _USE_CXX17
diff --git a/modules/all/core/include/limits.h b/modules/all/core/include/limits.h
index df7a13f..fe1c41b 100644
--- a/modules/all/core/include/limits.h
+++ b/modules/all/core/include/limits.h
@@ -31,10 +31,12 @@
#include <cdefs.h>
#include <stddef.h>
-/* Max lengths */
+/* Max lengths. */
+
#define MB_LEN_MAX 1
-/* Char limits */
+/* Char limits. */
+
#define CHAR_BIT __CHAR_BIT
#define SCHAR_MIN __CHAR_MIN
#define SCHAR_MAX __CHAR_MAX
@@ -48,22 +50,26 @@
# define CHAR_MAX __UCHAR_MAX
#endif
-/* Short limits */
+/* Short limits. */
+
#define SHRT_MIN __SHRT_MIN
#define SHRT_MAX __SHRT_MAX
#define USHRT_MAX __USHRT_MAX
-/* Int limits */
+/* Integer limits. */
+
#define INT_MIN __INT_MIN
#define INT_MAX __INT_MAX
#define UINT_MAX __UINT_MAX
-/* Long limits */
+/* Long integer limits. */
+
#define LONG_MIN __LONG_MIN
#define LONG_MAX __LONG_MAX
#define ULONG_MAX __ULONG_MAX
-/* Long long limits */
+/* Long long integer limits. */
+
#define LLONG_MIN __LLONG_MIN
#define LLONG_MAX __LLONG_MAX
#define ULLONG_MAX __ULLONG_MAX
diff --git a/modules/all/core/include/stdarg.h b/modules/all/core/include/stdarg.h
index 7a9eddd..9ccd70f 100644
--- a/modules/all/core/include/stdarg.h
+++ b/modules/all/core/include/stdarg.h
@@ -59,6 +59,7 @@ _BEGIN_NAMESPACE_STD
* from objects compiled using other compilers, so be careful with this. */
typedef __stdarg_va_list va_list;
+
#define va_start(_AP, _PARAM) __stdarg_va_start(_AP, _PARAM)
#define va_end(_AP) __stdarg_va_end(_AP)
#define va_arg(_AP, _TYPE) __stdarg_va_arg(_AP, _TYPE)
diff --git a/modules/all/core/info.yml b/modules/all/core/info.yml
index b9e2e87..81edce1 100644
--- a/modules/all/core/info.yml
+++ b/modules/all/core/info.yml
@@ -1,11 +1,5 @@
%YAML 1.2
---
magic: potatosdk-1.0
-description: The core libc.
+description: The freestanding libc environment.
license: free
-depends:
-- io
-- math
-- mem
-- string
-- ctype
diff --git a/modules/all/core/roles.yml b/modules/all/core/roles.yml
index 2a6a9ce..7956e67 100644
--- a/modules/all/core/roles.yml
+++ b/modules/all/core/roles.yml
@@ -1,58 +1,17 @@
%YAML 1.2
---
include:
- assert.h: Assertions.
byteswap.h: Byte swapping utilities.
- cdefs.h: C definitions.
- complex.h: Complex utilities.
- dirent.h: Directory listing.
- endian.h: Endian conversion utilities.
- errno.h: libc error codes.
+ cdefs.h: Basic C definitions for all other headers.
+ endian.h: Endian detection and conversion.
features.h: C features.
- fenv.h: Floating environment.
float.h: Floating constants.
- inttypes.h: Things using types from `stdint.h`.
iso646.h: English words.
limits.h: Integer limits.
- locale.h: Locales.
- printf.h: printf-related utilities.
- setjmp.h: Non-local jumps.
- signal.h: Signals.
stdarg.h: Variable argument lists.
- stdatomic.h: Atomic integer types.
stdbool.h: Booleans.
stddef.h: Standard definitions.
- stdfix.h: Standard fix integers.
stdint.h: Standard integer types.
- stdlib.h: Standard library utilities.
- string.h: String utilities.
- strings.h: BSD-compatible string utilities.
- time.h: Time utilities.
varargs.h: Old variable argument lists.
-src:
- stdio:
- printf:
- default.c: Default printf callbacks.
- fprintf.c: Print formatted in a stream.
- prinf.h: Internal header for printf-related utilities.
- register.c: Manage printf callbacks.
- sprintf.c: String front-end to [v]s[n]printf.
- vfprintf.c: The core of all.
- read.c: Read from a stream.
- seek.c: Seek on a stream.
- stdio.h: Internal header for standard I/O utilities.
- stdout.c: Standard output and error streams definition.
- write.c: Write to a stream.
- stdlib:
- div.c: Division utilities.
- rand.c: Basic random utilities.
- wchar.c: Wide char-related utilities.
- string:
- memchr.c: Look for a character in a memory area.
- memcpy.c: Copy the content of a memory area into another.
- memset.c: Initialize the content of a memory area.
- strchr.c: Look for a character in a string.
- strlen.c: Find out the length of a string.
- byteswap.c: default byte swapping utilities.
- errno.c: errno management.
- locales.c: Localization register.
+bits:
+ version.h: libcarrot version definition.
diff --git a/modules/all/ctype/copyright.yml b/modules/all/ctype/copyright.yml
index 94e925f..ce52c6a 100644
--- a/modules/all/ctype/copyright.yml
+++ b/modules/all/ctype/copyright.yml
@@ -2,4 +2,4 @@
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/all/ctype/docs/index.en.md b/modules/all/ctype/docs/index.en.rst
index fe6414c..28c036b 100644
--- a/modules/all/ctype/docs/index.en.md
+++ b/modules/all/ctype/docs/index.en.rst
@@ -1,6 +1,6 @@
----
-title: Character type
----
+Character type
+==============
+
This module brings single-byte character interactions, such as testing the
character category (upper/lowercase, digit, …) or changing the character
case
diff --git a/modules/all/errno-renesas/copyright.yml b/modules/all/errno-renesas/copyright.yml
deleted file mode 100644
index 94e925f..0000000
--- a/modules/all/errno-renesas/copyright.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-%YAML 1.2
----
-files: '*'
-copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
diff --git a/modules/all/errno-renesas/docs/index.en.md b/modules/all/errno-renesas/docs/index.en.md
deleted file mode 100644
index 0bfaf88..0000000
--- a/modules/all/errno-renesas/docs/index.en.md
+++ /dev/null
@@ -1,65 +0,0 @@
----
-title: Renesas' style of error numbers.
----
-This module provides Renesas-compatible error codes.
-Version 6.00 errors are:
-
-- `ERANGE`: “data out of **range**”, the result of a function cannot be
- represented as a float type value, or if overflow or underflow occurs;
-- `EDOM`: “data out of **dom**ain”, the value of a parameter input to a
- function is outside the range of values defined in the function;
-- `EDIV`: ???;
-- `ESTRN`: “too long **str**ing”, the length of the string literal exceeds
- the upper limit;
-- `PTRERR`: “invalid file pointer”, the NULL pointer constant is specified
- as the file pointer value;
-- `SEQERR`: ???;
-- `ECBASE`: “invalid radix”, an invalid radix was specified;
-- `ETLN`: “number too long”, the specified number exceeds the number of
- significant digits;
-- `EEXP`: “**exp**onent too large”, the specified exponent exceeds three
- digits;
-- `EEXPN`: “**n**ormalized **exp**onent too large”, the exponent exceeds
- three digits when the string literal is normalized to the IEEE standard
- decimal format;
-- `ENUM`: ???;
-- `EFLOATO`: “**o**verflow out of **float**”, a float-type decimal value
- is out-of-range (overflow);
-- `EFLOATU`: “**u**nderflow out of **float**”, a float-type decimal value
- is out of range (underflow);
-- `EDBLO`: “**o**verflow out of **d**ou**bl**e”, a double-type decimal value
- is out of range (overflow);
-- `EDBLU`: “**u**nderflow out of **d**ou**bl**e”, a double-type decimal value
- is out of range (underflow);
-- `ELDBLO`: “**o**verflow out of **l**ong **d**ou**bl**e”, a long double-type
- decimal value is out of range (overflow);
-- `ELDBLU`: “**u**nderflow out of **l**ong **d**ou**bl**e”, a long double-type
- decimal value is out of range (underflow);
-- `NOTOPN`: “file **not** **op**e**n**”, the file is not open;
-- `EBADF`: “**bad** **f**ile number”, an output function was issued for
- an input-only file, or an input file was issued for an output-only file;
-- `ECSPEC`: “error in format”, an erroneous format was specified for
- an input/output function using format.
-
-Added in version 9.00 (manual):
-
-- `EFIXEDO`: “**o**verflow out of __**fixed**”;
-- `EFIXEDU`: “**u**nderflow out of __**fixed**”;
-- `EACCUMO`: “**o**verflow out of __**accum**”;
-- `EACCUMU`: “**u**nderflow out of __**accum**”;
-- `ELFIXEDO`: “**o**verflow out of **l**ong __**fixed**”;
-- `ELFIXEDU`: “**u**nderflow out of **l**ong __**fixed**”;
-- `ELACCUMO`: “**o**verflow out of **l**ong __**accum**”;
-- `ELACCUMU`: “**u**nderflow out of **l**ong __**accum**”;
-- `EMALRESM`: “error in waiting semaphore”, failed to define semaphore
- resources for malloc;
-- `EMALFRSM`: “error in signaling semaphore”, failed to release semaphore
- resources for malloc;
-- `ETOKRESM`: “error in waiting semaphore”, failed to define semaphore
- resources for strtok;
-- `ETOKFRSM`: “error in signaling semaphore”, failed to release semaphore
- resources for strtok;
-- `EIOBRESM`: “error in waiting semaphore”, failed to define semaphore
- resources for _iob (fopen);
-- `EIOBFRSM`: “error in signaling semaphore”, failed to release semaphore
- resources for _iob (fopen).
diff --git a/modules/all/errno/bits/string.h b/modules/all/errno/bits/string.h
new file mode 100644
index 0000000..4561428
--- /dev/null
+++ b/modules/all/errno/bits/string.h
@@ -0,0 +1,12 @@
+/* `strerror()`: return the string corresponding to an error code.
+ * This function is NOT thread-safe. */
+
+extern char *strerror _OF((int __errnum));
+
+/* `strerror_r()`: thread-safe version of `strerror()`. */
+
+extern int strerror_r _OF((int __errnum, char *__buf, size_t __buflen));
+
+/* `strerror_l()`: locale-dependant version of `strerror()`. */
+
+extern char *strerror_l _OF((int __errnum, locale_t __locale));
diff --git a/modules/all/errno/docs/index.en.rst b/modules/all/errno/docs/index.en.rst
new file mode 100644
index 0000000..f5c5b58
--- /dev/null
+++ b/modules/all/errno/docs/index.en.rst
@@ -0,0 +1,4 @@
+Error numbers management
+========================
+
+This module provides basic utilities for managing the global error number.
diff --git a/modules/all/errno/include/errno.h b/modules/all/errno/include/errno.h
new file mode 100644
index 0000000..aaa1717
--- /dev/null
+++ b/modules/all/errno/include/errno.h
@@ -0,0 +1,29 @@
+#include <cdefs.h>
+
+_BEGIN_NAMESPACE_STD
+
+/* The main global lvalue representing the error code (as an `int`).
+ * By default, it is defined as a global int, otherwise it is a pointer which
+ * might differ between threads.
+ *
+ * And since `errno` might be required to be a macro, we ought to define the
+ * macro as itself if it doesn't exist. */
+
+#ifndef _REENTRANT
+extern volatile int errno;
+
+# define errno errno
+#else
+extern int *__errno_addr _OF((void));
+
+# define errno (*__errno_addr())
+#endif
+
+/* Error descriptions.
+ * This is non-standard, however it is used internally for compatibility
+ * with old programs. */
+
+extern char const * const sys_errlist[];
+extern int sys_nerr;
+
+_END_NAMESPACE_STD
diff --git a/modules/all/errno/info.yml b/modules/all/errno/info.yml
new file mode 100644
index 0000000..f2f148b
--- /dev/null
+++ b/modules/all/errno/info.yml
@@ -0,0 +1,5 @@
+%YAML 1.2
+---
+magic: potatosdk-1.0
+description: General utilities for error numbers.
+license: free
diff --git a/modules/all/errno-renesas/roles.yml b/modules/all/errno/roles.yml
index 46f8745..46f8745 100644
--- a/modules/all/errno-renesas/roles.yml
+++ b/modules/all/errno/roles.yml
diff --git a/modules/all/helloworld/copyright.yml b/modules/all/helloworld/copyright.yml
index 94e925f..ce52c6a 100644
--- a/modules/all/helloworld/copyright.yml
+++ b/modules/all/helloworld/copyright.yml
@@ -2,4 +2,4 @@
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/all/helloworld/docs/index.en.md b/modules/all/helloworld/docs/index.en.md
deleted file mode 100644
index 5c7293d..0000000
--- a/modules/all/helloworld/docs/index.en.md
+++ /dev/null
@@ -1,13 +0,0 @@
----
-title: Hello, world!
----
-This module is a demonstration module for new contributors. It implements
-a demonstration function, `helloworld()`, that puts _a sample string_ to
-standard output. It is defined this way:
-
-```c
-void helloworld(const char *string);
-```
-
-A newline is printed after the string. If the given string is `NULL`,
-`"hello, world"` is printed, followed by a newline.
diff --git a/modules/all/helloworld/docs/index.en.rst b/modules/all/helloworld/docs/index.en.rst
new file mode 100644
index 0000000..d1f70b0
--- /dev/null
+++ b/modules/all/helloworld/docs/index.en.rst
@@ -0,0 +1,13 @@
+Hello, world!
+=============
+
+This module is a demonstration module for new contributors. It implements
+a demonstration function, ``helloworld()``, that puts *a sample string* to
+standard output. It is defined this way:
+
+.. code-block:: c
+
+ void helloworld(const char *string);
+
+A newline is printed after the string. If the given string is ``NULL``,
+``"hello, world"`` is printed, followed by a newline.
diff --git a/modules/all/core-sh/bits/setjmp.h b/modules/all/hosted-sh/bits/setjmp.h
index 5c0fea5..5c0fea5 100644
--- a/modules/all/core-sh/bits/setjmp.h
+++ b/modules/all/hosted-sh/bits/setjmp.h
diff --git a/modules/all/hosted-sh/copyright.yml b/modules/all/hosted-sh/copyright.yml
new file mode 100644
index 0000000..ce52c6a
--- /dev/null
+++ b/modules/all/hosted-sh/copyright.yml
@@ -0,0 +1,5 @@
+%YAML 1.2
+---
+files: '*'
+copyright:
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/all/hosted-sh/docs/index.en.rst b/modules/all/hosted-sh/docs/index.en.rst
new file mode 100644
index 0000000..6eea59b
--- /dev/null
+++ b/modules/all/hosted-sh/docs/index.en.rst
@@ -0,0 +1,4 @@
+SuperH-specific parts of the hosted libc
+========================================
+
+This module completes the freestanding SuperH module, :ref:`all/core-sh`.
diff --git a/modules/all/hosted-sh/info.yml b/modules/all/hosted-sh/info.yml
new file mode 100644
index 0000000..11f1e4e
--- /dev/null
+++ b/modules/all/hosted-sh/info.yml
@@ -0,0 +1,7 @@
+%YAML 1.2
+---
+magic: potatosdk-1.0
+description: The core libc, SuperH-specific parts.
+license: free
+requires:
+ arch: [sh]
diff --git a/modules/all/hosted-sh/roles.yml b/modules/all/hosted-sh/roles.yml
new file mode 100644
index 0000000..50f6386
--- /dev/null
+++ b/modules/all/hosted-sh/roles.yml
@@ -0,0 +1,7 @@
+%YAML 1.2
+---
+bits:
+ setjmp.h: Non-local jump buffer type.
+src:
+ longjmp.s: Non-local jump.
+ setjmp.s: Non-local jump preparation.
diff --git a/modules/all/core-sh/src/longjmp.s b/modules/all/hosted-sh/src/longjmp.s
index c57e0b1..c57e0b1 100644
--- a/modules/all/core-sh/src/longjmp.s
+++ b/modules/all/hosted-sh/src/longjmp.s
diff --git a/modules/all/core-sh/src/setjmp.s b/modules/all/hosted-sh/src/setjmp.s
index 88671c7..88671c7 100644
--- a/modules/all/core-sh/src/setjmp.s
+++ b/modules/all/hosted-sh/src/setjmp.s
diff --git a/modules/all/hosted/copyright.yml b/modules/all/hosted/copyright.yml
new file mode 100644
index 0000000..546a0ed
--- /dev/null
+++ b/modules/all/hosted/copyright.yml
@@ -0,0 +1,10 @@
+%YAML 1.2
+---
+files: '*'
+copyright:
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
+---
+files: 'src/ctype/tab.c'
+copyright:
+- [1991, 2016, "Free Software Foundation, Inc", "info@fsf.org"]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/all/hosted/docs/bits.en.rst b/modules/all/hosted/docs/bits.en.rst
new file mode 100644
index 0000000..efcdb0d
--- /dev/null
+++ b/modules/all/hosted/docs/bits.en.rst
@@ -0,0 +1,14 @@
+Bits used by the hosted part of the libc
+========================================
+
+For compiler, architecture or system specific content, this module includes
+a few header bits. Please define them in your compiler, architecture and
+system default modules.
+
+Architecture-specific headers
+-----------------------------
+
+``setjmp.h`` — long jumps
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This header bit defines the ``jmp_buf`` type for ``setjmp.h``.
diff --git a/modules/all/hosted/docs/index.en.rst b/modules/all/hosted/docs/index.en.rst
new file mode 100644
index 0000000..90cbbfa
--- /dev/null
+++ b/modules/all/hosted/docs/index.en.rst
@@ -0,0 +1,13 @@
+The core libc module
+====================
+
+.. chapters::
+
+ bits
+
+This is the system-independant but hosted libc core. On the contrary to the
+freestanding :ref:`all/core` module which it includes, it provides code.
+
+The system-specific macros and types are taken from the header bits,
+which are usually defined by ``all/core-<arch>``, ``compiler/host-<comp>``
+and ``compiler/target-<comp>``.
diff --git a/modules/all/core/include/assert.h b/modules/all/hosted/include/assert.h
index 73ca4d5..90ae20c 100644
--- a/modules/all/core/include/assert.h
+++ b/modules/all/hosted/include/assert.h
@@ -32,6 +32,7 @@
#include <stddef.h>
/* Here is the nice way to get the function name. */
+
#if defined(__cplusplus) ? __GNUC_PREREQ(2, 6) : __GNUC_PREREQ(2, 4)
# define __ASSERT_FUNC __PRETTY_FUNCTION__
#elif _USE_C99
@@ -39,18 +40,22 @@
#else
# define __ASSERT_FUNC NULL
#endif
-/* ************************************************************************* */
-/* Main functions */
-/* ************************************************************************* */
+
+/* ---
+ * Main functions.
+ * --- */
+
_BEGIN_DECLS
_EXTERN void _NORETURN __assert_fail _OF((const char *__assertion,
const char *__file, uint __line, const char *__function)) _THROW;
_END_DECLS
-/* ************************************************************************* */
-/* Macro definition */
-/* ************************************************************************* */
+
+/* ---
+ * Macro definition.
+ * --- */
+
#ifdef assert
# undef assert
#endif
@@ -58,7 +63,6 @@ _END_DECLS
# define assert(_IGN) ((void)0)
#else
# define assert(_EXPR) \
- ((_EXPR) \
- ? (void)0 \
+ ((_EXPR) ? (void)0 \
: __assert_fail(#_EXPR, __FILE__, __LINE__, __ASSERT_FUNC))
#endif
diff --git a/modules/all/core/include/complex.h b/modules/all/hosted/include/complex.h
index 13b548e..13b548e 100644
--- a/modules/all/core/include/complex.h
+++ b/modules/all/hosted/include/complex.h
diff --git a/modules/all/core/include/errno.h b/modules/all/hosted/include/errno.h
index e9a86fa..e9a86fa 100644
--- a/modules/all/core/include/errno.h
+++ b/modules/all/hosted/include/errno.h
diff --git a/modules/all/core/include/fenv.h b/modules/all/hosted/include/fenv.h
index 9a216d1..9a216d1 100644
--- a/modules/all/core/include/fenv.h
+++ b/modules/all/hosted/include/fenv.h
diff --git a/modules/all/core/include/inttypes.h b/modules/all/hosted/include/inttypes.h
index a931dfc..a931dfc 100644
--- a/modules/all/core/include/inttypes.h
+++ b/modules/all/hosted/include/inttypes.h
diff --git a/modules/all/core/include/locale.h b/modules/all/hosted/include/locale.h
index 64e76a5..64e76a5 100644
--- a/modules/all/core/include/locale.h
+++ b/modules/all/hosted/include/locale.h
diff --git a/modules/all/core/include/setjmp.h b/modules/all/hosted/include/setjmp.h
index b89f667..b89f667 100644
--- a/modules/all/core/include/setjmp.h
+++ b/modules/all/hosted/include/setjmp.h
diff --git a/modules/all/core/include/signal.h b/modules/all/hosted/include/signal.h
index 3262b66..3262b66 100644
--- a/modules/all/core/include/signal.h
+++ b/modules/all/hosted/include/signal.h
diff --git a/modules/all/core/include/stdatomic.h b/modules/all/hosted/include/stdatomic.h
index 1d3a0ec..1d3a0ec 100644
--- a/modules/all/core/include/stdatomic.h
+++ b/modules/all/hosted/include/stdatomic.h
diff --git a/modules/all/core/include/stdfix.h b/modules/all/hosted/include/stdfix.h
index c5db232..c5db232 100644
--- a/modules/all/core/include/stdfix.h
+++ b/modules/all/hosted/include/stdfix.h
diff --git a/modules/all/core/include/stdlib.h b/modules/all/hosted/include/stdlib.h
index 38a1f5c..38a1f5c 100644
--- a/modules/all/core/include/stdlib.h
+++ b/modules/all/hosted/include/stdlib.h
diff --git a/modules/all/hosted/info.yml b/modules/all/hosted/info.yml
new file mode 100644
index 0000000..6b8def8
--- /dev/null
+++ b/modules/all/hosted/info.yml
@@ -0,0 +1,5 @@
+%YAML 1.2
+---
+magic: potatosdk-1.0
+description: The base hosted libc environment.
+license: free
diff --git a/modules/all/hosted/roles.yml b/modules/all/hosted/roles.yml
new file mode 100644
index 0000000..28ee578
--- /dev/null
+++ b/modules/all/hosted/roles.yml
@@ -0,0 +1,46 @@
+%YAML 1.2
+---
+include:
+ assert.h: Assertions.
+ complex.h: Complex utilities.
+ dirent.h: Directory listing.
+ errno.h: libc error codes.
+ fenv.h: Floating environment.
+ inttypes.h: Things using types from `stdint.h`.
+ locale.h: Locales.
+ printf.h: printf-related utilities.
+ setjmp.h: Non-local jumps.
+ signal.h: Signals.
+ stdatomic.h: Atomic integer types.
+ stdfix.h: Standard fix integers.
+ stdlib.h: Standard library utilities.
+ string.h: String utilities.
+ strings.h: BSD-compatible string utilities.
+ time.h: Time utilities.
+src:
+ stdio:
+ printf:
+ default.c: Default printf callbacks.
+ fprintf.c: Print formatted in a stream.
+ prinf.h: Internal header for printf-related utilities.
+ register.c: Manage printf callbacks.
+ sprintf.c: String front-end to [v]s[n]printf.
+ vfprintf.c: The core of all.
+ read.c: Read from a stream.
+ seek.c: Seek on a stream.
+ stdio.h: Internal header for standard I/O utilities.
+ stdout.c: Standard output and error streams definition.
+ write.c: Write to a stream.
+ stdlib:
+ div.c: Division utilities.
+ rand.c: Basic random utilities.
+ wchar.c: Wide char-related utilities.
+ string:
+ memchr.c: Look for a character in a memory area.
+ memcpy.c: Copy the content of a memory area into another.
+ memset.c: Initialize the content of a memory area.
+ strchr.c: Look for a character in a string.
+ strlen.c: Find out the length of a string.
+ byteswap.c: default byte swapping utilities.
+ errno.c: errno management.
+ locales.c: Localization register.
diff --git a/modules/all/core/src/byteswap.c b/modules/all/hosted/src/byteswap.c
index bf12b1a..bf12b1a 100644
--- a/modules/all/core/src/byteswap.c
+++ b/modules/all/hosted/src/byteswap.c
diff --git a/modules/all/core/src/errno.c b/modules/all/hosted/src/errno.c
index ee7c4ac..ee7c4ac 100644
--- a/modules/all/core/src/errno.c
+++ b/modules/all/hosted/src/errno.c
diff --git a/modules/all/core/src/locales.c b/modules/all/hosted/src/locales.c
index a3d8dac..a3d8dac 100644
--- a/modules/all/core/src/locales.c
+++ b/modules/all/hosted/src/locales.c
diff --git a/modules/all/core/src/stdlib/div.c b/modules/all/hosted/src/stdlib/div.c
index 8ef426d..8ef426d 100644
--- a/modules/all/core/src/stdlib/div.c
+++ b/modules/all/hosted/src/stdlib/div.c
diff --git a/modules/all/core/src/stdlib/rand.c b/modules/all/hosted/src/stdlib/rand.c
index 3cb7355..3cb7355 100644
--- a/modules/all/core/src/stdlib/rand.c
+++ b/modules/all/hosted/src/stdlib/rand.c
diff --git a/modules/all/core/src/stdlib/wchar.c b/modules/all/hosted/src/stdlib/wchar.c
index 44fe4e4..44fe4e4 100644
--- a/modules/all/core/src/stdlib/wchar.c
+++ b/modules/all/hosted/src/stdlib/wchar.c
diff --git a/modules/all/iconv-unicode/bits/iconv_proto.h b/modules/all/iconv-unicode/bits/iconv_proto.h
new file mode 100644
index 0000000..0ef5730
--- /dev/null
+++ b/modules/all/iconv-unicode/bits/iconv_proto.h
@@ -0,0 +1,18 @@
+/* UTF-8 <> wide char */
+
+ICONV_PROTO(__iconv_utf8_to_wchar)
+ICONV_PROTO(__iconv_wchar_to_utf8)
+
+/* UTF-32 <> UTF-8 */
+
+ICONV_PROTO(__iconv_utf8_to_utf32be)
+ICONV_PROTO(__iconv_utf8_to_utf32le)
+ICONV_PROTO(__iconv_utf32be_to_utf8)
+ICONV_PROTO(__iconv_utf32le_to_utf8)
+
+/* UTF-16 <> UTF-8 */
+
+ICONV_PROTO(__iconv_utf8_to_utf16be)
+ICONV_PROTO(__iconv_utf8_to_utf16le)
+ICONV_PROTO(__iconv_utf16be_to_utf8)
+ICONV_PROTO(__iconv_utf16le_to_utf8)
diff --git a/modules/all/iconv-unicode/bits/iconv_route.h b/modules/all/iconv-unicode/bits/iconv_route.h
new file mode 100644
index 0000000..312507b
--- /dev/null
+++ b/modules/all/iconv-unicode/bits/iconv_route.h
@@ -0,0 +1,34 @@
+/* UTF-8 <> wide char */
+
+ICONV_ROUTE("utf8", "wchar_t", __iconv_utf8_to_wchar)
+ICONV_ROUTE("wchar_t", "utf8", __iconv_wchar_to_utf8)
+
+/* UTF-32 <> UTF-8 */
+
+ICONV_ROUTE("utf8", "utf32be", __iconv_utf8_to_utf32be)
+ICONV_ROUTE("utf8", "utf32le", __iconv_utf8_to_utf32le)
+ICONV_ROUTE("utf32be", "utf8", __iconv_utf32be_to_utf8)
+ICONV_ROUTE("utf32le", "utf8", __iconv_utf32le_to_utf8)
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ICONV_ROUTE("utf8", "utf32", __iconv_utf8_to_utf32le)
+ICONV_ROUTE("utf32", "utf8", __iconv_utf32le_to_utf8)
+#else
+ICONV_ROUTE("utf8", "utf32", __iconv_utf8_to_utf32be)
+ICONV_ROUTE("utf32", "utf8", __iconv_utf32be_to_utf8)
+#endif
+
+/* UTF-16 <> UTF-8 */
+
+ICONV_ROUTE("utf8", "utf16be", __iconv_utf8_to_utf16be)
+ICONV_ROUTE("utf8", "utf16le", __iconv_utf8_to_utf16le)
+ICONV_ROUTE("utf16be", "utf8", __iconv_utf16be_to_utf8)
+ICONV_ROUTE("utf16le", "utf8", __iconv_utf16le_to_utf8)
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ICONV_ROUTE("utf8", "utf16", __iconv_utf8_to_utf16le)
+ICONV_ROUTE("utf16", "utf8", __iconv_utf16le_to_utf8)
+#else
+ICONV_ROUTE("utf8", "utf16", __iconv_utf8_to_utf16be)
+ICONV_ROUTE("utf16", "utf8", __iconv_utf16be_to_utf8)
+#endif
diff --git a/modules/all/iconv-unicode/copyright.yml b/modules/all/iconv-unicode/copyright.yml
new file mode 100644
index 0000000..36f270f
--- /dev/null
+++ b/modules/all/iconv-unicode/copyright.yml
@@ -0,0 +1,5 @@
+%YAML 1.2
+---
+files: '*'
+copyright:
+- [2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/all/iconv-unicode/docs/index.en.rst b/modules/all/iconv-unicode/docs/index.en.rst
new file mode 100644
index 0000000..a4b057b
--- /dev/null
+++ b/modules/all/iconv-unicode/docs/index.en.rst
@@ -0,0 +1,13 @@
+Handling of Unicode encodings for the iconv interface
+=====================================================
+
+This module aims at bringing the various Unicode interfaces to the
+``all/iconv`` module. It aims at implementing the following encodings:
+
+- UCS-2, the historical fixed 16-bit encoding;
+- UTF-16, the variable size encoding compatible with UCS-2;
+- UCS-4/UTF-32, the fixed 32-bit encoding;
+- UTF-8, the reference variable size encoding;
+- UTF-7, the Unicode-over-ASCII encoding.
+
+Of course, the byte order mark shall be managed.
diff --git a/modules/all/iconv-unicode/info.yml b/modules/all/iconv-unicode/info.yml
new file mode 100644
index 0000000..aa7df5e
--- /dev/null
+++ b/modules/all/iconv-unicode/info.yml
@@ -0,0 +1,5 @@
+%YAML 1.2
+---
+magic: potatosdk-1.0
+description: Unicode encodings for the generic character conversion interface.
+license: free
diff --git a/modules/all/iconv-unicode/roles.yml b/modules/all/iconv-unicode/roles.yml
new file mode 100644
index 0000000..d7d7ad5
--- /dev/null
+++ b/modules/all/iconv-unicode/roles.yml
@@ -0,0 +1,8 @@
+%YAML 1.2
+---
+bits:
+ iconv_proto.h: Prototypes for the Unicode encodings for the iconv interface.
+ iconv_route.h: Routes for the Unicode encodings for the iconv interface.
+src:
+ utf8_to_wchar.c: "UTF-8 to wide chars."
+ wchar_to_utf8.c: "Wide chars to UTF-8."
diff --git a/modules/all/iconv-unicode/src/utf8_to_utf32.c b/modules/all/iconv-unicode/src/utf8_to_utf32.c
new file mode 100644
index 0000000..7efb752
--- /dev/null
+++ b/modules/all/iconv-unicode/src/utf8_to_utf32.c
@@ -0,0 +1,76 @@
+#include "../iconv.h"
+#define set_utf8_cookie(c_count, c_ini) { count = (c_count); val = (c_ini); }
+
+/* Template function.
+ * Takes a step and returns the error code (0 if ok). */
+
+#define __iconv_utf8_to_utf32(HTOF) \
+{ \
+ const unsigned char *in; \
+ int left, proc = 1, byte; \
+ uint32_t val; \
+\
+ __I_HASIN(step, 1) \
+ __I_CHECK(step, sizeof(val)) \
+\
+ in = __I_IN(step); \
+ left = __I_INSIZE(step); \
+ byte = *in; \
+\
+ /* Check if it's special. */ \
+\
+ if (byte & 0x80) { \
+ if (~byte & 0x40) { \
+ /* error: not a starting byte! */ \
+\
+ return (I_EILSEQ); \
+ } \
+\
+ /* Make the cookie. */ \
+\
+ if (~byte & 0x20) \
+ set_utf8_cookie(1, byte & 0x1F) \
+ else if (~byte & 0x10) \
+ set_utf8_cookie(2, byte & 0x0F) \
+ else if (~byte & 0x08) \
+ set_utf8_cookie(3, byte & 0x07) \
+ else if (~byte & 0x04) \
+ set_utf8_cookie(4, byte & 0x03) \
+ else if (~byte & 0x02) \
+ set_utf8_cookie(5, byte & 0x01) \
+ else { \
+ /* error: not a valid starting byte */ \
+\
+ return (I_EILSEQ); \
+ } \
+\
+ /* Get the data. */ \
+\
+ if (left - 1 < count) \
+ return (I_EINVAL); \
+\
+ in += count; \
+ left -= count; \
+ proc += count; \
+ while (--count) { \
+ int byte = *++in; \
+ if (~byte & 0x80 || byte & 0x40) { \
+ /* not a valid continuation byte! */ \
+\
+ return (I_EILSEQ); \
+ } \
+\
+ val = (val << 6) | (byte & 0x3F); \
+ } \
+ } else \
+ val = byte; \
+\
+ /* Return the buffer. */ \
+\
+ __I_RETURN(step, proc, HTOF(val), sizeof(val)) \
+}
+
+int __iconv_utf8_to_utf32be(struct __iconv_step *step)
+ __iconv_utf8_to_utf32(htobe32)
+int __iconv_utf8_to_utf32le(struct __iconv_step *step)
+ __iconv_utf8_to_utf32(htole32)
diff --git a/modules/all/iconv/src/conv/utf8_to_wchar.c b/modules/all/iconv-unicode/src/utf8_to_wchar.c
index 22654ef..4290f6a 100644
--- a/modules/all/iconv/src/conv/utf8_to_wchar.c
+++ b/modules/all/iconv-unicode/src/utf8_to_wchar.c
@@ -1,5 +1,5 @@
/* ****************************************************************************
- * conv/utf8_to_wchar.c -- UTF-8 to `wchar_t`.
+ * utf8_to_wchar.c -- UTF-8 to `wchar_t`.
* Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
*
* This file is part of the 'all/iconv' module in libcarrot, an experimental
@@ -43,35 +43,20 @@
int __iconv_utf8_to_wchar(struct __iconv_step *step)
{
- int byte = *step->in;
- wchar_t *out; wchar_t val;
- int outleft;
+ const unsigned char *in;
+ int left, proc = 1, byte;
+ wchar_t val;
- /* Initialize the output. */
- if (step->next) {
- /* Next step input buffer. */
- step->next->in = (void*)&val;
- step->next->inleft = sizeof(wchar_t);
- outleft = sizeof(wchar_t);
- out = &val;
+ __I_HASIN(step, 1)
+ __I_CHECK(step, sizeof(wchar_t))
- /* Next step output buffer. */
- step->next->out = step->out;
- step->next->outleft = step->outleft;
- } else {
- out = (wchar_t*)step->out;
- outleft = step->outleft;
- }
-
- /* Check if too big. */
- if (outleft < (int)sizeof(wchar_t))
- return (I_E2BIG);
+ in = __I_IN(step);
+ left = __I_INSIZE(step);
+ byte = *in;
/* Check if it's special. */
- if (byte & 0x80) {
- unsigned char *in = (void*)step->in;
- int count;
+ if (byte & 0x80) {
if (~byte & 0x40) {
/* error: not a starting byte! */
return (I_EILSEQ);
@@ -94,11 +79,12 @@ int __iconv_utf8_to_wchar(struct __iconv_step *step)
}
/* Get the data. */
- if (step->inleft - 1 < count)
+ if (left - 1 < count)
return (I_EINVAL);
- step->in += count;
- step->inleft -= count;
+ in += count;
+ left -= count;
+ proc += count;
while (--count) {
int byte = *++in;
if (~byte & 0x80 || byte & 0x40) {
@@ -108,13 +94,10 @@ int __iconv_utf8_to_wchar(struct __iconv_step *step)
val = (val << 6) | (byte & 0x3F);
}
- } else val = byte;
+ } else
+ val = byte;
- /* Put into the final thing. */
- *out = val;
+ /* Return the buffer. */
- /* Call next step, end otherwise. */
- if (step->next)
- return ((*step->next_func)(step->next));
- return (0);
+ __I_RETURN(step, proc, &val, sizeof(wchar_t))
}
diff --git a/modules/all/iconv/src/conv/wchar_to_utf8.c b/modules/all/iconv-unicode/src/wchar_to_utf8.c
index 27499f8..5da6726 100644
--- a/modules/all/iconv/src/conv/wchar_to_utf8.c
+++ b/modules/all/iconv-unicode/src/wchar_to_utf8.c
@@ -1,5 +1,5 @@
/* ****************************************************************************
- * conv/wchar_to_utf8.c -- `wchar_t` to UTF-8.
+ * wchar_to_utf8.c -- `wchar_t` to UTF-8.
* Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
*
* This file is part of the 'all/iconv' module in libcarrot, an experimental
@@ -38,78 +38,66 @@
* @return the error code (0 if ok).
*/
-int __iconv_utf8_to_wchar(struct __iconv_step *step)
+int __iconv_wchar_to_utf8(struct __iconv_step *step)
{
- unsigned char *out;
- int outleft; wchar_t c;
- unsigned char outbuf[6];
+ wchar_t val;
+ unsigned char seq[6];
+ int length;
- /* Initialize the output. */
- if (step->next) {
- /* Next step input buffer. */
- step->next->in = (void*)outbuf;
- step->next->inleft = 6;
- out = outbuf;
- outleft = 6;
+ __I_HASIN(step, sizeof(wchar_t))
+ val = *(wchar_t)__I_IN(step);
- /* Next step output buffer. */
- step->next->out = step->out;
- step->next->outleft = step->outleft;
- } else {
- out = (unsigned char*)step->out;
- outleft = step->outleft;
- }
+ /* Make the buffer. */
- /* Get the character. */
- if (step->inleft < (int)sizeof(wchar_t))
- return (I_EINVAL);
- c = *(wchar_t*)step->in;
+ if (val <= 0x7F) {
+ __I_CHECK(step, 1)
- /* Check the category. */
- if (c < 0x80) {
- if (outleft < 1)
- return (I_E2BIG);
- *out = c;
- } else if (c < 0x800) {
- if (outleft < 2)
- return (I_E2BIG);
- *out++ = 0xC0 | (c >> 6);
- *out = 0x80 | (c & 0x3F);
- } else if (c < 0x10000) {
- if (outleft < 3)
- return (I_E2BIG);
- *out++ = 0xE0 | (c >> 12);
- *out++ = 0x80 | ((c >> 6) & 0x3F);
- *out = 0x80 | (c & 0x3F);
- } else if (c < 0x200000) {
- if (outleft < 4)
- return (I_E2BIG);
- *out++ = 0xF0 | (c >> 18);
- *out++ = 0x80 | ((c >> 12) & 0x3F);
- *out++ = 0x80 | ((c >> 6) & 0x3F);
- *out = 0x80 | (c & 0x3F);
- } else if (c < 0x4000000) {
- if (outleft < 5)
- return (I_E2BIG);
- *out++ = 0xF8 | (c >> 24);
- *out++ = 0x80 | ((c >> 18) & 0x3F);
- *out++ = 0x80 | ((c >> 12) & 0x3F);
- *out++ = 0x80 | ((c >> 6) & 0x3F);
- *out = 0x80 | (c & 0x3F);
- } else if (c < 0x80000000) {
- if (outleft < 6)
- return (I_E2BIG);
- *out++ = 0xFC | (c >> 30);
- *out++ = 0x80 | ((c >> 24) & 0x3F);
- *out++ = 0x80 | ((c >> 18) & 0x3F);
- *out++ = 0x80 | ((c >> 12) & 0x3F);
- *out++ = 0x80 | ((c >> 6) & 0x3F);
- *out = 0x80 | (c & 0x3F);
+ seq[0] = (unsigned char)val & 0x7F;
+ length = 1;
+ } else if (val <= 0x7FF) {
+ __I_CHECK(step, 2)
+
+ seq[0] = 0xC0 | (unsigned char)(val >> 6);
+ seq[1] = 0x80 | (unsigned char)(val & 0x3F);
+ length = 2;
+ } else if (val <= 0xFFFF) {
+ __I_CHECK(step, 3)
+
+ seq[0] = 0xE0 | (unsigned char)(val >> 12);
+ seq[1] = 0x80 | (unsigned char)((val >> 6) & 0x3F);
+ seq[2] = 0x80 | (unsigned char)(val & 0x3F);
+ length = 3;
+ } else if (val <= 0x1FFFFF) {
+ __I_CHECK(step, 4)
+
+ seq[0] = 0xF0 | (unsigned char)(val >> 18);
+ seq[1] = 0x80 | (unsigned char)((val >> 12) & 0x3F);
+ seq[2] = 0x80 | (unsigned char)((val >> 6) & 0x3F);
+ seq[3] = 0x80 | (unsigned char)(val & 0x3F);
+ length = 4;
+ } else if (val <= 0x3FFFFFF) {
+ __I_CHECK(step, 5)
+
+ seq[0] = 0xF8 | (unsigned char)(val >> 24);
+ seq[1] = 0x80 | (unsigned char)((val >> 18) & 0x3F);
+ seq[2] = 0x80 | (unsigned char)((val >> 12) & 0x3F);
+ seq[3] = 0x80 | (unsigned char)((val >> 6) & 0x3F);
+ seq[4] = 0x80 | (unsigned char)(val & 0x3F);
+ length = 5;
+ } else if (val <= 0x7FFFFFFF) {
+ __I_CHECK(step, 6)
+
+ seq[0] = 0xF8 | (unsigned char)(val >> 30);
+ seq[1] = 0x80 | (unsigned char)((val >> 24) & 0x3F);
+ seq[2] = 0x80 | (unsigned char)((val >> 18) & 0x3F);
+ seq[3] = 0x80 | (unsigned char)((val >> 12) & 0x3F);
+ seq[4] = 0x80 | (unsigned char)((val >> 6) & 0x3F);
+ seq[5] = 0x80 | (unsigned char)(val & 0x3F);
+ length = 6;
} else
return (I_EILSEQ);
- /* Call next step, end otherwise. */
- if (step->next)
- return ((*step->next_func)(step->next));
- return (0);
+ /* Return the buffer. */
+
+ __I_RETURN(step, sizeof(wchar_t), seq, length)
}
diff --git a/modules/all/iconv/copyright.yml b/modules/all/iconv/copyright.yml
index 94e925f..ce52c6a 100644
--- a/modules/all/iconv/copyright.yml
+++ b/modules/all/iconv/copyright.yml
@@ -2,4 +2,4 @@
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/all/iconv/docs/index.en.md b/modules/all/iconv/docs/index.en.md
deleted file mode 100644
index c6d91ed..0000000
--- a/modules/all/iconv/docs/index.en.md
+++ /dev/null
@@ -1,12 +0,0 @@
----
-title: Character encoding conversions.
----
-`iconv` is the generic character conversion interface defined by the
-Single Unix Specification (SUS) [here][sus_iconv].
-More documentation about an other example of iconv implementation
-is [in the GNU libc documentation][gnu_iconv].
-
-TODO: someday, I should describe how this module sort of works.
-
-[sus_iconv]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/iconv.h.html
-[gnu_iconv]: https://www.gnu.org/software/libc/manual/html_node/glibc-iconv-Implementation.html
diff --git a/modules/all/iconv/docs/index.en.rst b/modules/all/iconv/docs/index.en.rst
new file mode 100644
index 0000000..0d3ef35
--- /dev/null
+++ b/modules/all/iconv/docs/index.en.rst
@@ -0,0 +1,17 @@
+Character encoding conversions
+==============================
+
+``iconv`` is the generic character conversion interface defined
+`by the Single Unix Specification (SUS) here <sus_>`_.
+More documentation about an other example of iconv implementation
+is `in the GNU libc documentation <gnu_>`_.
+
+.. todo::
+ Describe how this module sort of works.
+ Also, try to implement the ``iconv_open()`` function as seen by IBM,
+ which is described here:
+
+ https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_71/apis/iconvopn.htm
+
+.. _sus: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/iconv.h.html
+.. _gnu: https://www.gnu.org/software/libc/manual/html_node/glibc-iconv-Implementation.html
diff --git a/modules/all/iconv/include/iconv.h b/modules/all/iconv/include/iconv.h
index 3cea155..1cc9840 100644
--- a/modules/all/iconv/include/iconv.h
+++ b/modules/all/iconv/include/iconv.h
@@ -34,18 +34,119 @@
/* This conversion interface converts from one character encoding to an other,
* using a handle and buffers.
*
- * `iconv_t` is the conversion descriptor.
- * Input and output encodings are defined once, while you're opening the
+ * `iconv_t` is the conversion descriptor. */
+
+#if __INTERNAL
+
+/* The conversion works while using steps.
+ * A step corresponds to the decoding of a character sequence. */
+
+struct __iconv_step;
+
+typedef int __iconv_step_func _OF((struct __iconv_step *__step));
+
+struct __iconv_step {
+ struct __iconv_step *next;
+ __iconv_step_func *next_func;
+
+ char *in, *out;
+ int inleft, outleft;
+};
+
+/* iconv internal errors:
+ * `I_EILSEQ`: Invalid byte sequence in the input.
+ * `I_E2BIG`: Ran out of space in the output buffer;
+ * `I_EINVAL`: Incomplete byte sequence at the end of the input buffer;
+ * `I_EBADF`: Invalid conversion descriptor.
+ *
+ * FIXME: use the real codes for errno. */
+
+# if 0
+# define I_EILSEQ EILSEQ
+# define I_E2BIG E2BIG
+# define I_EINVAL EINVAL
+# define I_EBADF EBADF
+# else
+# define I_EILSEQ 1
+# define I_E2BIG 2
+# define I_EINVAL 3
+# define I_EBADF 4
+# endif
+
+/* Define the type and the macro to return an output buffer from a
+ * conversion function.
+ * `__I_TYPE`: type of the conversion thingy.
+ * `__I_IN`: macro to get the input buffer from the step.
+ * `__I_INSIZE`: macro to get the input buffer size from the step.
+ * `__I_CHECK`: check that there are at least _SIZE bytes in output buffer.
+ * `__I_RETURN`: return the buffer for the step.
+ * `_PROC` represents the number of processed bytes in the
+ * input buffer, `_OUT` is the output buffer, `_SIZE` is the number
+ * of bytes to read from the output buffer.
+ * `__I_HASIN`: check if has at least _SIZE bytes in the input buffer. */
+
+# define __I_TYPE __iconv_t
+# define __I_IN(_STEP) ((const void*)(_STEP)->in)
+# define __I_INSIZE(_STEP) ((_STEP)->inleft)
+
+# define __I_CHECK(_STEP, _SIZE) \
+ { \
+ __iconv_step *__I_step = (_STEP); \
+ int __I_sz = (_SIZE); \
+ \
+ if (__I_step->outleft < __I_sz) \
+ return (I_E2BIG); \
+ }
+
+# define __I_RETURN(_STEP, _PROC, _OUT, _SIZE) \
+ { \
+ __iconv_step *__I_step = (_STEP); \
+ int __I_sz = (_SIZE); \
+ int __I_proc = (_PROC); \
+ char *__I_out = (_OUT); \
+ \
+ __I_step->in += __I_proc; \
+ __I_step->inleft -= __I_proc; \
+ if (__I_step->next) { \
+ __I_step->next->in = __I_out; \
+ __I_step->next->inleft = __I_sz; \
+ __I_step->next->out = __I_step->out; \
+ __I_step->next->outleft = __I_step->outleft; \
+ return ((*__I_step->next_func)(__I_step->next)); \
+ } else { \
+ if (__I_sz > __I_step->outleft) \
+ return (I_E2BIG); \
+ memcpy(__I_step->out, __I_out, __I_sz); \
+ } \
+ return (0); \
+ }
+
+# define __I_HASIN(_STEP, _SIZE) \
+ { \
+ __iconv_step *__Ih_step = (_STEP); \
+ int __Ih_sz = (_SIZE); \
+ \
+ if (!__Ih_step->inleft) \
+ __I_RETURN(__Ih_step, 0, NULL, 0) \
+ if (__Ih_step->inleft < __Ih_sz) \
+ return (I_EINVAL);
+ }
+
+#else
+# define __I_TYPE const void
+#endif
+
+/* Input and output encodings are defined once, while you're opening the
* conversion descriptor. If you want to change encodings, you will have to
* define a new conversion descriptor.
*
* If `iconv_open` fails, it returns (iconv_t)-1 and sets errno with the
* correct error code. */
-typedef const void *iconv_t;
+typedef __I_TYPE *iconv_t;
extern iconv_t iconv_open
- _OF((const char *__tocode, const char *__fromcode));
+ _OF((char const *__tocode, char const *__fromcode));
extern int iconv_close
_OF((iconv_t __cd));
diff --git a/modules/all/iconv/roles.yml b/modules/all/iconv/roles.yml
index 948f964..bef2d65 100644
--- a/modules/all/iconv/roles.yml
+++ b/modules/all/iconv/roles.yml
@@ -3,9 +3,6 @@
include:
iconv.h: Generic Conversion Interface.
src:
- conv:
- utf8_to_wchar.c: "UTF-8 to `wchar_t`."
- wchar_to_utf8.c: "`wchar_t` to UTF-8."
iconv.c: Main conversion function.
iconv.h: iconv internals.
open.c: Open and close an iconv descriptor.
diff --git a/modules/all/iconv/src/iconv.h b/modules/all/iconv/src/iconv.h
index 4ade7a7..565fae8 100644
--- a/modules/all/iconv/src/iconv.h
+++ b/modules/all/iconv/src/iconv.h
@@ -21,48 +21,8 @@
# include <iconv.h>
# include <string.h>
# include <errno.h>
-# define I_MAGIC 0x1256347F
-
-/* Step mechanism.
- * A step corresponds to the decoding of a character sequence. */
-
-struct __iconv_step;
-
-typedef int __iconv_step_func _OF((struct __iconv_step *__step));
-
-struct __iconv_step {
- struct __iconv_step *next;
- __iconv_step_func *next_func;
-
- char *in, *out;
- int inleft, outleft;
-};
-
-/* Internal conversion functions. */
-
-extern int __iconv_utf8_to_wchar
- _OF((struct __iconv_step *__step));
-extern int __iconv_wchar_to_utf8
- _OF((struct __iconv_step *__step));
-
-/* iconv errors:
- * `I_EILSEQ`: Invalid byte sequence in the input.
- * `I_E2BIG`: Ran out of space in the output buffer;
- * `I_EINVAL`: Incomplete byte sequence at the end of the input buffer;
- * `I_EBADF`: Invalid conversion descriptor. */
-
-# if 0
-# define I_EILSEQ EILSEQ
-# define I_E2BIG E2BIG
-# define I_EINVAL EINVAL
-# define I_EBADF EBADF
-# else
-# define I_EILSEQ 1
-# define I_E2BIG 2
-# define I_EINVAL 3
-# define I_EBADF 4
-# endif
+# define I_MAGIC 0x1256347F
/* Conversion routes types and occurrences. */
diff --git a/modules/all/iconv/src/open.c b/modules/all/iconv/src/open.c
index 5e426e2..e7ca3b0 100644
--- a/modules/all/iconv/src/open.c
+++ b/modules/all/iconv/src/open.c
@@ -39,7 +39,7 @@
* @return the conversion descriptor.
*/
-iconv_t iconv_open(const char *tocode, const char *fromcode)
+iconv_t iconv_open(char const *tocode, char const *fromcode)
{
const struct iconv_route *r = &__iconvs[0];
@@ -65,6 +65,7 @@ iconv_t iconv_open(const char *tocode, const char *fromcode)
int iconv_close(iconv_t cd)
{
/* Nothing to deallocate... is this normal? */
+
(void)cd;
return (0);
}
diff --git a/modules/all/iconv/src/routes.c b/modules/all/iconv/src/routes.c
index 9ec3b32..0b8ce1f 100644
--- a/modules/all/iconv/src/routes.c
+++ b/modules/all/iconv/src/routes.c
@@ -29,18 +29,22 @@
* the CeCILL-C license and that you accept its terms.
* ************************************************************************* */
#include "iconv.h"
-#define ENT(FROM, TO, FUNC) \
- {FROM, TO, &FUNC, I_MAGIC}
-#define END \
+#define ICONV_PROTO(_NAME) \
+ extern int _NAME _OF((struct __iconv_step *__step));
+#define ICONV_ROUTE(_FROM, _TO, _FUNC) \
+ {_FROM, _TO, &_FUNC, I_MAGIC},
+#define ICONV_END \
{NULL, NULL, NULL, 0}
-/* If you make a conversion from an encoding to an other,
- * add your conversion here!
- *
- * Magic are for conversion route descriptor checking. */
+/* Make the prototypes using the `iconv_proto.h` bits.
+ * Such bits shall use the `ICONV_PROTO(FUNC_NAME)` macro. */
+
+#include_bits <iconv_proto.h>
+
+/* Make the routes using the `iconv_routes.h` bits.
+ * Such bits shall use the `ICONV_ROUTE(FROM, TO, FUNC_NAME)` macro. */
const struct iconv_route __iconvs[] = {
- ENT("utf8", "wchar_t", __iconv_utf8_to_wchar),
- ENT("wchar_t", "utf8", __iconv_wchar_to_utf8),
- END
+#include_bits <iconv_route.h>
+ ICONV_END
};
diff --git a/modules/all/info.yml b/modules/all/info.yml
index aa67d2c..6a04789 100644
--- a/modules/all/info.yml
+++ b/modules/all/info.yml
@@ -4,11 +4,8 @@ magic: potatosdk-1.0
description: >-
Meta-system for modules that are suitable for all systems.
default:
- c:
- - all/core
- - all/core-sh
- - all/iconv
- c++:
- - all/cpp
+- all/core
+- all/core-sh
+- all/iconv
import:
- compiler
diff --git a/modules/all/io/copyright.yml b/modules/all/io/copyright.yml
index 52437d8..546a0ed 100644
--- a/modules/all/io/copyright.yml
+++ b/modules/all/io/copyright.yml
@@ -2,9 +2,9 @@
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
---
files: 'src/ctype/tab.c'
copyright:
- [1991, 2016, "Free Software Foundation, Inc", "info@fsf.org"]
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/all/io/docs/index.en.md b/modules/all/io/docs/index.en.md
deleted file mode 100644
index 4f60676..0000000
--- a/modules/all/io/docs/index.en.md
+++ /dev/null
@@ -1,4 +0,0 @@
----
-title: Input/Output
----
-TODO
diff --git a/modules/all/io/docs/index.en.rst b/modules/all/io/docs/index.en.rst
new file mode 100644
index 0000000..5d1cc68
--- /dev/null
+++ b/modules/all/io/docs/index.en.rst
@@ -0,0 +1,4 @@
+Input/Output
+============
+
+TODO
diff --git a/modules/all/io/include/stdio.h b/modules/all/io/include/stdio.h
index 2e45a6f..ab428b9 100644
--- a/modules/all/io/include/stdio.h
+++ b/modules/all/io/include/stdio.h
@@ -122,6 +122,7 @@ _END_NAMESPACE_STD
# define __IO_MODE_KWCOOKIE_KBUFSIZE 32
# define __IO_MODE_KWCOOKIE_VBUFSIZE 128
+
typedef struct {
const char* raw;
char kbuf[__IO_MODE_KWCOOKIE_KBUFSIZE];
@@ -198,6 +199,7 @@ typedef int __file_close_t
_OF((void* __cookie));
/* Please don't fill this structure directly, see below. */
+
typedef struct {
__file_read_t* read;
__file_write_t* write;
@@ -207,6 +209,7 @@ typedef struct {
/* Prefer using this macro directly, in case the order of the
* function pointers change. */
+
# define __FILEFUNCS(_RD, _WR, _SK, _CL) \
{_RD, _WR, _SK, _CL}
diff --git a/modules/all/math/copyright.yml b/modules/all/math/copyright.yml
index 94e925f..ce52c6a 100644
--- a/modules/all/math/copyright.yml
+++ b/modules/all/math/copyright.yml
@@ -2,4 +2,4 @@
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/all/math/docs/index.en.md b/modules/all/math/docs/index.en.rst
index a51fcb0..f44cf3b 100644
--- a/modules/all/math/docs/index.en.md
+++ b/modules/all/math/docs/index.en.rst
@@ -1,5 +1,5 @@
----
-title: Mathematical functions.
----
+Mathematical functions
+======================
+
This is the system-independent module containing mathematic headers and
utilities.
diff --git a/modules/all/mem/copyright.yml b/modules/all/mem/copyright.yml
index 94e925f..ce52c6a 100644
--- a/modules/all/mem/copyright.yml
+++ b/modules/all/mem/copyright.yml
@@ -2,4 +2,4 @@
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/all/mem/docs/index.en.md b/modules/all/mem/docs/index.en.rst
index 1744ec7..bcd2817 100644
--- a/modules/all/mem/docs/index.en.md
+++ b/modules/all/mem/docs/index.en.rst
@@ -1,13 +1,17 @@
----
-title: Standard memory management.
-chapters:
-- tweaking
----
+Standard memory management
+==========================
+
+.. chapters::
+
+ tweaking
+
This module manages the standard memory management interface, while adding
settings to interact with it.
-# Static memory allocation
-The `alloca.h` header bit should provide the `alloca(size)` macro.
+Static memory allocation
+------------------------
+
+The ``alloca.h`` header bit should provide the ``alloca(size)`` macro.
If this macro fails, the whole program stops (producing a stack overflow,
or segmentation fault).
@@ -15,39 +19,41 @@ Memory allocated this way is free'd automatically at the end of the function
calling it. Reentrant functions shall not use this macro to allocate memory
for parent functions.
-# Dynamic memory allocation
+Dynamic memory allocation
+-------------------------
+
This module provides the standard memory allocation interface. To allocate
memory, any of the following functions can be used:
-```c
-void *malloc(size_t size);
-void *calloc(size_t nmemb, size_t size);
-```
+.. code-block:: c
+
+ void *malloc(size_t size);
+ void *calloc(size_t nmemb, size_t size);
-`malloc()` is the generic function for allocating memory, and
-`calloc()` takes the number of elements, `nmemb`, and the size of each
-element, `size`.
+``malloc()`` is the generic function for allocating memory, and
+``calloc()`` takes the number of elements, ``nmemb``, and the size of each
+element, ``size``.
-The returned pointer is either `NULL` if the memory allocation has failed,
+The returned pointer is either ``NULL`` if the memory allocation has failed,
or a pointer, serving both as an identifier for the allocated memory area,
and as the lower address of the memory area for further usage.
Once the allocated memory area is no longer used, you shall free the memory
area by using the following function:
-```c
-void free(void *ptr);
-```
+.. code-block:: c
+
+ void free(void *ptr);
You are supposed to pass the memory area identifier, i.e. the lowest memory
-address, to `free()`, and **not** “any pointer in the area”.
+address, to ``free()``, and **not** “any pointer in the area”.
To re-allocate memory, i.e. extending or reducing an existing memory area,
use the `realloc()` function defined below:
-```c
-void *realloc(void *ptr, size_t size);
-```
+.. code-block:: c
+
+ void *realloc(void *ptr, size_t size);
Notice that the pointer will very likely change, so please update your
-pointer using the return value from `realloc()`.
+pointer using the return value from ``realloc()``.
diff --git a/modules/all/mem/docs/tweaking.en.md b/modules/all/mem/docs/tweaking.en.md
deleted file mode 100644
index 66307d6..0000000
--- a/modules/all/mem/docs/tweaking.en.md
+++ /dev/null
@@ -1,32 +0,0 @@
----
-title: Tweaking the libcarrot memory allocation
----
-The memory allocation module is a very lite and basic module, and uses hooks
-to actually do something. These hooks are inspired from the GNU C library,
-and this document is a description of them.
-
-# malloc() related hooks
-To initialize
-
-```c
-typedef void __malloc_initialize_hook_t(void);
-
-__malloc_initialize_hook_t __malloc_initialize_hook;
-```
-
-Once the malloc implementation is initialized, these callbacks
-
-```c
-typedef void *__malloc_hook_t(size_t size, const void *caller);
-typedef void *__realloc_hook_t(void *ptr, size_t size, const void *caller);
-typedef void *__memalign_hook_t(size_t alignment, size_t size,
- const void *caller);
-typedef void *__free_hook_t(void *ptr, const void *caller);
-
-__malloc_hook_t __malloc_hook;
-__realloc_hook_t __realloc_hook;
-__memalign_hook_t __memalign_hook;
-__free_hook_t __free_hook;
-```
-
-
diff --git a/modules/all/mem/docs/tweaking.en.rst b/modules/all/mem/docs/tweaking.en.rst
new file mode 100644
index 0000000..018b446
--- /dev/null
+++ b/modules/all/mem/docs/tweaking.en.rst
@@ -0,0 +1,32 @@
+Tweaking the libcarrot memory allocation
+========================================
+
+The memory allocation module is a very lite and basic module, and uses hooks
+to actually do something. These hooks are inspired from the GNU C library,
+and this document is a description of them.
+
+``malloc()`` related hooks
+--------------------------
+
+To initialize
+
+.. code-block:: c
+
+ typedef void __malloc_initialize_hook_t(void);
+
+ __malloc_initialize_hook_t __malloc_initialize_hook;
+
+Once the malloc implementation is initialized, these callbacks
+
+.. code-block:: c
+
+ typedef void *__malloc_hook_t(size_t size, const void *caller);
+ typedef void *__realloc_hook_t(void *ptr, size_t size, const void *caller);
+ typedef void *__memalign_hook_t(size_t alignment, size_t size,
+ const void *caller);
+ typedef void *__free_hook_t(void *ptr, const void *caller);
+
+ __malloc_hook_t __malloc_hook;
+ __realloc_hook_t __realloc_hook;
+ __memalign_hook_t __memalign_hook;
+ __free_hook_t __free_hook;
diff --git a/modules/all/stdcocorico/copyright.yml b/modules/all/stdcocorico/copyright.yml
index d592ee3..5f2f4b6 100644
--- a/modules/all/stdcocorico/copyright.yml
+++ b/modules/all/stdcocorico/copyright.yml
@@ -2,9 +2,9 @@
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
---
files: 'include/stdcocorico.h'
copyright:
- [2014, Simon "Gee" Giraudot, contact@ptilouk.net]
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/all/stdcocorico/docs/index.en.md b/modules/all/stdcocorico/docs/index.en.md
deleted file mode 100644
index 67464b9..0000000
--- a/modules/all/stdcocorico/docs/index.en.md
+++ /dev/null
@@ -1,8 +0,0 @@
----
-title: Cocorico — code in french!
----
-The Cocorico Standard is a humoristic standard to code in french, using macros
-from the `stdcocorico.h` header. It was invented by Simon "Gee" Giraudot,
-see [his post about it][art].
-
-[art]: https://leblocnotesdegee.wordpress.com/2014/05/06/standard-cocorico-codez-en-francais/
diff --git a/modules/all/stdcocorico/docs/index.en.rst b/modules/all/stdcocorico/docs/index.en.rst
new file mode 100644
index 0000000..01fae27
--- /dev/null
+++ b/modules/all/stdcocorico/docs/index.en.rst
@@ -0,0 +1,8 @@
+Cocorico — code in French!
+==========================
+
+The Cocorico Standard is a humoristic standard to code in french, using macros
+from the ``stdcocorico.h`` header. It was invented by Simon "Gee" Giraudot,
+see `his post about it <stdcocorico_>`_.
+
+.. _stdcocorico: https://leblocnotesdegee.wordpress.com/2014/05/06/standard-cocorico-codez-en-francais/
diff --git a/modules/all/stdcocorico/include/stdcocorico.h b/modules/all/stdcocorico/include/stdcocorico.h
index bf3fbd8..35cf1a8 100644
--- a/modules/all/stdcocorico/include/stdcocorico.h
+++ b/modules/all/stdcocorico/include/stdcocorico.h
@@ -33,6 +33,7 @@
#include <stdlib.h>
/* Should we use "Wesh Mode"? */
+
#if defined(_USE_WESH)
#elif defined(WESH_MODE)
# define _USE_WESH 1
@@ -41,6 +42,7 @@
#endif
/* Basic C things. */
+
#define interrompre break
#define cas case
#define attraper catch
@@ -79,6 +81,7 @@
#define tantque while
/* C++ things. */
+
#define classe class
#define entreec cin
#define sortiec cout
diff --git a/modules/all/string-sh/copyright.yml b/modules/all/string-sh/copyright.yml
index 94e925f..ce52c6a 100644
--- a/modules/all/string-sh/copyright.yml
+++ b/modules/all/string-sh/copyright.yml
@@ -2,4 +2,4 @@
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/all/string/docs/index.en.md b/modules/all/string/docs/index.en.rst
index 7bca20b..fcfc105 100644
--- a/modules/all/string/docs/index.en.md
+++ b/modules/all/string/docs/index.en.rst
@@ -1,14 +1,16 @@
----
-title: Memory interactions
-chapters:
-- memory
-- strings
----
+Memory interactions
+===================
+
+.. chapters::
+
+ memory
+ strings
+
This module brings functions to manipulate strings. It brings a really
basic and non-optimized but widely supported version of it — optimized
versions of it exist for a few architectures.
-As a complement to standard functions defined in `<string.h>`, it adds the
+As a complement to standard functions defined in ``<string.h>``, it adds the
BSD-compliant string functions. This is only added for compatibility, please
use the standard C functions for portability.
@@ -17,7 +19,7 @@ the way the memory area length is given:
- raw memory: the length of the area is given aside;
- string: the length of the area is determined by a particular ending
- byte/character, usually `\0`.
+ character, usually ``\0``.
Why use this module instead of implementing your own functions? Well, these
functions are usually optimized for your platform, whatever your C library
diff --git a/modules/all/string/docs/memory.en.md b/modules/all/string/docs/memory.en.md
deleted file mode 100644
index 23339e5..0000000
--- a/modules/all/string/docs/memory.en.md
+++ /dev/null
@@ -1,63 +0,0 @@
----
-title: Raw memory utilities
----
-A few functions are thought for raw and uninterpreted memory, where the length
-of the area(s) to interact with is/are given aside. This is a reference of
-these.
-
-The size of the memory areas is usually required using a `size_t` parameter.
-
-# Initialize a memory area
-To initialize the content of a memory area with the value of a character,
-use the following standard function:
-
-```c
-void *memset(void *s, int c, size_t n);
-```
-
-Where `c` is the value to set to each byte in the area, and therefore should
-fit in a byte (usually 0 to 255).
-
-# Copy memory
-There are two standard functions for copying raw memory:
-
-```c
-void *memcpy(void *dst, const void *src, size_t n);
-void *memmove(void *dst, const void *src, size_t n);
-```
-
-`memcpy()` will always copy from the lower address (`src`) to the higher
-one (`src + n`), whereas `memmove()` will adapt the way it is copying,
-in case the memory areas are overlapping.
-
-If you ought to copy until a certain character is encountered, you can
-use the following function:
-
-```c
-void *memccpy(void *dst, const void *src, int c, size_t n);
-```
-
-Where `c` is the ending byte value, which can be stored in a byte.
-
-# Compare memory areas
-You may want to compare the content of two memory areas, usually to check
-if they are the same. The following function does this:
-
-```c
-int memcmp(const void *s, const void *t, size_t n);
-```
-
-The returned value is either zero if no difference has been found between
-the two memory areas, or the difference between the values (first minus second)
-of the bytes in the first position where the areas differ.
-
-# Find a character in a memory area
-To find the first position of a character in a memory area, use the
-following function:
-
-```c
-void *memchr(const void *s, int c, size_t n);
-```
-
-This function returns the pointer to the first occurrence of this value in
-the memory area, or `NULL` if the character has not been found.
diff --git a/modules/all/string/docs/memory.en.rst b/modules/all/string/docs/memory.en.rst
new file mode 100644
index 0000000..7e26df1
--- /dev/null
+++ b/modules/all/string/docs/memory.en.rst
@@ -0,0 +1,71 @@
+Raw memory utilities
+====================
+
+A few functions are thought for raw and uninterpreted memory, where the length
+of the area(s) to interact with is/are given aside. This is a reference of
+these.
+
+The size of the memory areas is usually required using a ``size_t`` parameter.
+
+Initialize a memory area
+------------------------
+
+To initialize the content of a memory area with the value of a character,
+use the following standard function:
+
+.. code-block:: c
+
+ void *memset(void *s, int c, size_t n);
+
+Where ``c`` is the value to set to each byte in the area, and therefore should
+fit in a byte (usually 0 to 255).
+
+Copy memory
+-----------
+
+There are two standard functions for copying raw memory:
+
+.. code-block:: c
+
+ void *memcpy(void *dst, const void *src, size_t n);
+ void *memmove(void *dst, const void *src, size_t n);
+
+``memcpy()`` will always copy from the lower address (``src``) to the higher
+one (``src + n``), whereas ``memmove()`` will adapt the way it is copying,
+in case the memory areas are overlapping.
+
+If you ought to copy until a certain character is encountered, you can
+use the following function:
+
+.. code-block:: c
+
+ void *memccpy(void *dst, const void *src, int c, size_t n);
+
+Where ``c`` is the ending byte value, which can be stored in a byte.
+
+Compare memory areas
+--------------------
+
+You may want to compare the content of two memory areas, usually to check
+if they are the same. The following function does this:
+
+.. code-block:: c
+
+ int memcmp(const void *s, const void *t, size_t n);
+
+The returned value is either zero if no difference has been found between
+the two memory areas, or the difference between the values (first minus second)
+of the bytes in the first position where the areas differ.
+
+Find a character in a memory area
+---------------------------------
+
+To find the first position of a character in a memory area, use the
+following function:
+
+.. code-block:: c
+
+ void *memchr(const void *s, int c, size_t n);
+
+This function returns the pointer to the first occurrence of this value in
+the memory area, or ``NULL`` if the character has not been found.
diff --git a/modules/all/string/docs/strings.en.md b/modules/all/string/docs/strings.en.md
deleted file mode 100644
index 93c6342..0000000
--- a/modules/all/string/docs/strings.en.md
+++ /dev/null
@@ -1,94 +0,0 @@
----
-title: Strings utilities
----
-A string usually represents a character string terminated by the ASCII NUL
-character (code zero), usually represented as `\0`.
-
-# Calculate the string length
-As the length is not given aside the string, you have to calculate it by
-finding the NUL character, by using this function:
-
-```c
-size_t strlen(const char *s);
-```
-
-# Copy a string into another
-To copy the content of a string into another, including the NUL byte, you
-can use the following function:
-
-```c
-char *strcpy(char *dst, const char *src);
-```
-
-The destination buffer has to be big enough.
-
-# Concatenate strings
-To copy a string at the end of another, you can use the following two
-functions:
-
-```c
-char *strcat(char *dst, const char *src);
-char *strncat(char *dst, const char *src, size_t n);
-```
-
-The NUL byte at the end of the initial string is overwritten, and a NUL
-byte is always added at the end of the destination with the additional string
-appended.
-
-`strncat()` will take an additional information about the source string: its
-maximum length. If there is no NUL character within the `n` first characters
-of the source string, the `n` first characters of the source string will be
-copied.
-
-# Compare strings
-To check if strings are equivalent, use one of the following functions:
-
-```c
-int strcmp(const char *s, const char *t);
-int strncmp(const char *s, const char *t, size_t n);
-```
-
-This function returns zero if the strings are equal, or the difference between
-the first and second character at the first position where the strings differ.
-
-# Search a string for one or more characters
-To look for a character in a string, you can use one of the following
-functions:
-
-```c
-char *strchr(const char *s, int c);
-char *strrchr(const char *s, int c);
-```
-
-`strchr()` searches the string from lower to upper, and `strrchr()` searches
-the string from upper to lower. It returns the address if it finds the
-character, or `NULL` if it doesn't.
-
-To look for more than one character, you can use this function instead:
-
-```c
-char *strpbrk(const char *s, const char *accept);
-```
-
-This function searches the string from lower to upper, returns the address
-if it finds one of the characters in `accept` (excluding the NUL character),
-or `NULL` if none of the characters were found.
-
-# Search a string for another string
-To look for a string in another string, you can use the following function:
-
-```c
-char *strstr(const char *haystack, const char *needle);
-```
-
-This function returns `NULL` if `needle` has not been found in `haystack`, or
-a pointer to the first found occurrence of `needle` in `haystack`.
-
-# Calculate the length of a prefix
-To calculate the length of a prefix, made of a set of characters (or everything
-but a set of characters), in a string, you can use the following functions:
-
-```c
-size_t strspn(const char *s, const char *accept);
-size_t strcspn(const char *s, const char *reject);
-```
diff --git a/modules/all/string/docs/strings.en.rst b/modules/all/string/docs/strings.en.rst
new file mode 100644
index 0000000..4b956c4
--- /dev/null
+++ b/modules/all/string/docs/strings.en.rst
@@ -0,0 +1,109 @@
+String utilities
+================
+
+A string usually represents a character string terminated by the ASCII NUL
+character (code zero), usually represented as ``\0``.
+
+Calculate the string length
+---------------------------
+
+As the length is not given aside the string, you have to calculate it by
+finding the NUL character, by using this function:
+
+.. code-block:: c
+
+ size_t strlen(const char *s);
+
+Copy a string into another
+--------------------------
+
+To copy the content of a string into another, including the NUL byte, you
+can use the following function:
+
+.. code-block:: c
+
+ char *strcpy(char *dst, const char *src);
+
+The destination buffer has to be big enough.
+
+Concatenate strings
+-------------------
+
+To copy a string at the end of another, you can use the following two
+functions:
+
+.. code-block:: c
+
+ char *strcat(char *dst, const char *src);
+ char *strncat(char *dst, const char *src, size_t n);
+
+The NUL byte at the end of the initial string is overwritten, and a NUL
+byte is always added at the end of the destination with the additional string
+appended.
+
+``strncat()`` will take an additional information about the source string: its
+maximum length. If there is no NUL character within the ``n`` first characters
+of the source string, the ``n`` first characters of the source string will be
+copied.
+
+Compare strings
+---------------
+
+To check if strings are equivalent, use one of the following functions:
+
+.. code-block:: c
+
+ int strcmp(const char *s, const char *t);
+ int strncmp(const char *s, const char *t, size_t n);
+
+This function returns zero if the strings are equal, or the difference between
+the first and second character at the first position where the strings differ.
+
+Search a string for one or more characters
+------------------------------------------
+
+To look for a character in a string, you can use one of the following
+functions:
+
+.. code-block:: c
+
+ char *strchr(const char *s, int c);
+ char *strrchr(const char *s, int c);
+
+``strchr()`` searches the string from lower to upper, and ``strrchr()``
+searches the string from upper to lower. It returns the address if it finds
+the character, or ``NULL`` if it doesn't.
+
+To look for more than one character, you can use this function instead:
+
+.. code-block:: c
+
+ char *strpbrk(const char *s, const char *accept);
+
+This function searches the string from lower to upper, returns the address
+if it finds one of the characters in ``accept`` (excluding the NUL character),
+or ``NULL`` if none of the characters were found.
+
+Search a string for another string
+----------------------------------
+
+To look for a string in another string, you can use the following function:
+
+.. code-block:: c
+
+ char *strstr(const char *haystack, const char *needle);
+
+This function returns ``NULL`` if ``needle`` has not been found in
+``haystack``, or a pointer to the first found occurrence of ``needle``
+in ``haystack``.
+
+Calculate the length of a prefix
+--------------------------------
+
+To calculate the length of a prefix, made of a set of characters (or everything
+but a set of characters), in a string, you can use the following functions:
+
+.. code-block:: c
+
+ size_t strspn(const char *s, const char *accept);
+ size_t strcspn(const char *s, const char *reject);
diff --git a/modules/all/time/copyright.yml b/modules/all/time/copyright.yml
index 94e925f..ce52c6a 100644
--- a/modules/all/time/copyright.yml
+++ b/modules/all/time/copyright.yml
@@ -2,4 +2,4 @@
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/all/time/docs/bits.en.md b/modules/all/time/docs/bits.en.md
deleted file mode 100644
index c131adf..0000000
--- a/modules/all/time/docs/bits.en.md
+++ /dev/null
@@ -1,7 +0,0 @@
----
-title: Bits required by the standard time module.
----
-# System-specific headers.
-## `time.h` — time constants.
-This header bit defines the `CLOCKS_PER_SEC` constant, which corresponds to
-the number of ticks per second.
diff --git a/modules/all/time/docs/bits.en.rst b/modules/all/time/docs/bits.en.rst
new file mode 100644
index 0000000..8c9122b
--- /dev/null
+++ b/modules/all/time/docs/bits.en.rst
@@ -0,0 +1,11 @@
+Bits required by the standard time module
+=========================================
+
+System-specific headers
+-----------------------
+
+``time.h`` — time constants
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This header bit defines the ``CLOCKS_PER_SEC`` constant, which corresponds to
+the number of ticks per second.
diff --git a/modules/all/time/docs/index.en.md b/modules/all/time/docs/index.en.rst
index b2b08ee..901f9c2 100644
--- a/modules/all/time/docs/index.en.md
+++ b/modules/all/time/docs/index.en.rst
@@ -1,7 +1,9 @@
----
-title: Standard time module.
-chapters:
-- bits
----
+Standard time module
+====================
+
+.. chapters::
+
+ bits
+
This module is the common standard time module, which provides all of the
standard time operations.
diff --git a/modules/casiowin/copyright.yml b/modules/casiowin/copyright.yml
index 94e925f..ce52c6a 100644
--- a/modules/casiowin/copyright.yml
+++ b/modules/casiowin/copyright.yml
@@ -2,4 +2,4 @@
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/casiowin/core-crt/copyright.yml b/modules/casiowin/core-crt/copyright.yml
index 94e925f..ce52c6a 100644
--- a/modules/casiowin/core-crt/copyright.yml
+++ b/modules/casiowin/core-crt/copyright.yml
@@ -2,4 +2,4 @@
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/casiowin/core-crt/docs/index.en.md b/modules/casiowin/core-crt/docs/index.en.md
deleted file mode 100644
index 39969e5..0000000
--- a/modules/casiowin/core-crt/docs/index.en.md
+++ /dev/null
@@ -1,6 +0,0 @@
----
-title: C runtime objects for the fx-9860G.
----
-This module provides the C runtime objects (such as `crt0.o`), that shall
-always be merged into the final binary, as they initialize the environment,
-prepare the libraries, etc, for CASIOWIN.
diff --git a/modules/casiowin/core-crt/docs/index.en.rst b/modules/casiowin/core-crt/docs/index.en.rst
new file mode 100644
index 0000000..99cbe7e
--- /dev/null
+++ b/modules/casiowin/core-crt/docs/index.en.rst
@@ -0,0 +1,6 @@
+C runtime objects for the fx-9860G
+==================================
+
+This module provides the C runtime objects (such as ``crt0.o``), that shall
+always be merged into the final binary, as they initialize the environment,
+prepare the libraries, etc, for CASIOWIN.
diff --git a/modules/casiowin/core-crt/src/crt0.c b/modules/casiowin/core-crt/src/crt0.c
index c4d6f46..db0ab2e 100644
--- a/modules/casiowin/core-crt/src/crt0.c
+++ b/modules/casiowin/core-crt/src/crt0.c
@@ -33,32 +33,40 @@
#include <setjmp.h>
#define ATEXIT_MAX 32
-/* External symbols */
+/* External symbols. */
+
extern unsigned int romdata, bbss, ebss, bdata, edata;
extern void (*bctors)(void), (*ectors)(void);
extern void (*bdtors)(void), (*edtors)(void);
-/* Undeclared external functions */
+/* Undeclared external functions. */
+
extern void __Hmem_SetMMU(unsigned int, unsigned int, int);
extern void __GLibAddinAplExecutionCheck(int, int, int);
extern void __SetQuitHandler(void (*callback)(void));
extern int main(int, const char**);
-/* Exit code */
+/* Exit code. */
+
static int exit_code;
-/* Exit jump buffer */
+/* Exit jump buffer. */
+
static jmp_buf env;
-/* 'Quit' handler */
+/* 'Quit' handler. */
+
static void (*quit_handler)(void) = NULL;
-/* Atexit handlers */
+/* Atexit handlers. */
+
static void (*atexit_handlers[ATEXIT_MAX])(void);
static int atexit_count = 0;
-/* ************************************************************************* */
-/* Functions callable from the user program */
-/* ************************************************************************* */
+
+/* ---
+ * Functions callable from the user program.
+ * --- */
+
/**
* abort:
* End the program without invoking the exit handlers.
@@ -112,9 +120,11 @@ void SetQuitHandler(void (*callback)(void))
{
quit_handler = callback;
}
-/* ************************************************************************* */
-/* Initialization */
-/* ************************************************************************* */
+
+/* ---
+ * Initialization.
+ * --- */
+
/**
* __end:
* System SetQuitHandler callback.
@@ -164,26 +174,33 @@ void __start(int isAppli, unsigned short OptionNum)
void (**func)(void);
/* TODO: use them? */
- (void)isAppli; (void)OptionNum;
- /* set up the TLB */
+ (void)isAppli;
+ (void)OptionNum;
+
+ /* Set up the TLB */
__Hmem_SetMMU(0x08102000, 0x8801e000, 108);
- /* clear the .bss section, copy the .data section */
+ /* Clear the .bss section, copy the .data section */
+
memset(&bbss, 0, &ebss - &bbss);
memcpy(&bdata, &romdata, &edata - &bdata);
- /* probably kept for compatibility with the emulator */
+ /* Probably kept for compatibility with the emulator. */
+
__GLibAddinAplExecutionCheck(0, 1, 1);
- /* set up the quit handler */
+ /* Set up the quit handler. */
+
__SetQuitHandler(&__end);
- /* call constructors */
+ /* Call constructors. */
+
for (func = &bctors; func < &ectors; func++)
(*(*func))();
- /* invoke main */
+ /* Invoke main. */
+
if (!setjmp(env))
main(1, args);
diff --git a/modules/casiowin/core/copyright.yml b/modules/casiowin/core/copyright.yml
index 94e925f..ce52c6a 100644
--- a/modules/casiowin/core/copyright.yml
+++ b/modules/casiowin/core/copyright.yml
@@ -2,4 +2,4 @@
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/casiowin/core/docs/index.en.md b/modules/casiowin/core/docs/index.en.rst
index f6015ef..cc045e3 100644
--- a/modules/casiowin/core/docs/index.en.md
+++ b/modules/casiowin/core/docs/index.en.rst
@@ -1,6 +1,6 @@
----
-title: CASIOWIN, the firmware-like OS on CASIO calculators
----
+CASIOWIN, the firmware-like OS on CASIO calculators
+===================================================
+
CASIOWIN is the name of several OSes from CASIO, used on their graphical
calculators. This system is the CASIOWIN from the fx-9860G series,
including:
@@ -22,7 +22,7 @@ including:
- fx-9860GII-2 SD (Graph 95 SH4);
- Graph 75+E (french model).
-Notice that the models finishing by `-2` aren't officially named like that,
+Notice that the models finishing by ``-2`` aren't officially named like that,
and usually have a notice resembling "Power Graphic 2". They introduced a
microprocessor change, from SH7355/SH7337 (very similar) to SH7305. The first
set of microprocessors has an SH-3 core, where the second has a SH-4A core,
@@ -44,5 +44,5 @@ valid for OS 2.xx as G2A doesn't exist) proprietary format. It is valid for
external applications as well as for integrated applications (within the OS).
This module contains the bits and tricks that are part of the libc, not fxlib.
-They should be able to work without the `fxlib` module, by re-implementing
+They should be able to work without the ``fxlib`` module, by re-implementing
the syscalls manually.
diff --git a/modules/casiowin/core/src/assert/assert.c b/modules/casiowin/core/src/assert/assert.c
index 0e452ca..6e3929b 100644
--- a/modules/casiowin/core/src/assert/assert.c
+++ b/modules/casiowin/core/src/assert/assert.c
@@ -34,7 +34,7 @@
#include <string.h>
extern void __assert_PopUpWin _OF((int __n)) __THROW;
-extern void __assert_Print _OF((const unsigned char *__str)) __THROW;
+extern void __assert_Print _OF((unsigned char const *__str)) __THROW;
extern void __assert_locate _OF((int __x, int __y)) __THROW;
extern void __assert_putdisp _OF((void)) __THROW;
@@ -51,29 +51,40 @@ extern void __assert_putdisp _OF((void)) __THROW;
void __assert_fail(const char *expr, const char *file,
unsigned int line, const char *func)
{
- char f[22]; size_t n, fn;
+ char f[22];
+ size_t n, fn;
+
(void)func;
- /* prepare the top line */
+ /* Prepare the top line. */
+
sprintf(f, "%d", line);
- n = strlen(f); fn = strlen(file);
+ n = strlen(f);
+ fn = strlen(file);
if (fn <= 21 - 1 - n)
sprintf(f, "%s:%d", file, line);
else {
size_t newfn = 21 - 3 - 1 - n;
+
file = &file[fn - newfn];
fn = newfn;
sprintf(f, "...%s:%d", file, line);
}
- /* make the pop-up window */
+ /* Make the pop-up window. */
+
__assert_PopUpWin(4);
- __assert_locate(3, 2); __assert_Print((unsigned char*)f);
- __assert_locate(3, 3); __assert_Print((unsigned char*)"Assertion failed:");
- __assert_locate(4, 4); __assert_Print((unsigned char*)expr);
- __assert_locate(5, 3); __assert_Print((unsigned char*)"Exiting now.");
+ __assert_locate(3, 2);
+ __assert_Print((unsigned char*)f);
+ __assert_locate(3, 3);
+ __assert_Print((unsigned char*)"Assertion failed:");
+ __assert_locate(4, 4);
+ __assert_Print((unsigned char*)expr);
+ __assert_locate(5, 3);
+ __assert_Print((unsigned char*)"Exiting now.");
__assert_putdisp();
- /* exit */
+ /* Exit. */
+
abort();
}
diff --git a/modules/casiowin/core/src/dirent/error.c b/modules/casiowin/core/src/dirent/error.c
index 4eff00b..1e1dcd5 100644
--- a/modules/casiowin/core/src/dirent/error.c
+++ b/modules/casiowin/core/src/dirent/error.c
@@ -41,5 +41,6 @@
int __errno_from_fileerr(int ferr)
{
(void)ferr;
+
return (NOTOPN); /* FIXME */
}
diff --git a/modules/casiowin/core/src/dirent/open.c b/modules/casiowin/core/src/dirent/open.c
index 01cf31e..f5f1566 100644
--- a/modules/casiowin/core/src/dirent/open.c
+++ b/modules/casiowin/core/src/dirent/open.c
@@ -37,22 +37,35 @@
* The fx-9860G syscall interfaces forces the first find to be made while
* opening, so we'll always be one entry ahead. */
-DIR *opendir(const char *path)
+DIR *opendir(char const *path)
{
- __dirent_fontchar *fpath = NULL; size_t fsize;
- DIR *dir; int ret;
+ __dirent_fontchar *fpath = NULL;
+ size_t fsize;
+ DIR *dir;
+ int ret;
/* Get the FONTCHARACTER encoded path. */
fsize = mbstowcs(NULL, path, 0);
- if (fsize == (size_t)-1) { errno = EDOM; goto fail; }
+ if (fsize == (size_t)-1) {
+ errno = EDOM;
+ goto fail;
+ }
+
fpath = malloc(fsize + 1);
- if (!fpath) { errno = ENOMEM; return (NULL); }
+ if (!fpath) {
+ errno = ENOMEM;
+ return (NULL);
+ }
/* Initialize the handle. */
dir = malloc(sizeof(DIR));
- if (!dir) { errno = ENOMEM; goto fail; }
+ if (!dir) {
+ errno = ENOMEM;
+ goto fail;
+ }
+
memset(dir, 0, sizeof(DIR));
dir->handle = -1;
@@ -62,6 +75,7 @@ DIR *opendir(const char *path)
free(fpath);
if (ret < 0 && ret != _ENUMRATEEND) {
/* FIXME: return success if empty directory? */
+
__set_errno(__errno_from_fileerr(ret));
free(dir);
return (NULL);
@@ -84,6 +98,7 @@ int closedir(DIR *dir)
int ret;
/* Close the handle. */
+
ret = __dirent_findclose(dir->handle);
if (ret < 0) {
errno = __errno_from_fileerr(ret);
@@ -91,6 +106,7 @@ int closedir(DIR *dir)
}
/* Free and exit. */
+
free(dir);
return (0);
}
diff --git a/modules/casiowin/core/src/io/open.c b/modules/casiowin/core/src/io/open.c
index be105b9..4e83970 100644
--- a/modules/casiowin/core/src/io/open.c
+++ b/modules/casiowin/core/src/io/open.c
@@ -1,6 +1,6 @@
#include "io.h"
-int __bfile_fopen(FILE** stream, const char* filename, struct _IO_MODE* mode)
+int __bfile_fopen(FILE **stream, char const *filename, struct _IO_MODE* mode)
{
uint16_t path[2] = {0};
int handle, omode = 0;
@@ -8,6 +8,7 @@ int __bfile_fopen(FILE** stream, const char* filename, struct _IO_MODE* mode)
/* TODO: convert filename here */
/* Open the file. */
+
if (mode->flags & _IO_OPEN_FLAG_READ)
omode |= __openmode_read;
if (mode->flags & _IO_OPEN_FLAG_WRITE)
@@ -17,6 +18,7 @@ int __bfile_fopen(FILE** stream, const char* filename, struct _IO_MODE* mode)
return (__errno_from_fileerr(handle));
/* Make the stream. */
+
*stream = __make_file();
diff --git a/modules/casiowin/easy-input/copyright.yml b/modules/casiowin/easy-input/copyright.yml
index 8a390b1..296cb53 100644
--- a/modules/casiowin/easy-input/copyright.yml
+++ b/modules/casiowin/easy-input/copyright.yml
@@ -3,8 +3,8 @@
files: 'src/*'
copyright:
- [2015, 2016, Louis "Dark Storm" Gatin, l.gatin@neuf.fr]
-- [2016, 2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2016, 2018, Thomas Touhey, thomas@touhey.fr]
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/casiowin/easy-input/docs/index.en.md b/modules/casiowin/easy-input/docs/index.en.md
deleted file mode 100644
index 86ced12..0000000
--- a/modules/casiowin/easy-input/docs/index.en.md
+++ /dev/null
@@ -1,9 +0,0 @@
----
-title: Easy input utilities for the fx-9860G.
----
-This library was made by Louis "Dark Storm" Gatin for easy dialogs.
-The original version was `3.2`.
-
-[You can find the original library here][lib].
-
-lib: http://www.planet-casio.com/Fr/logiciels/voir_un_logiciel_casio.php?showid=117
diff --git a/modules/casiowin/easy-input/docs/index.en.rst b/modules/casiowin/easy-input/docs/index.en.rst
new file mode 100644
index 0000000..9d142cd
--- /dev/null
+++ b/modules/casiowin/easy-input/docs/index.en.rst
@@ -0,0 +1,8 @@
+Easy input utilities
+====================
+
+This library was made by Louis "Dark Storm" Gatin for easy dialogs.
+The original version was ``3.2``.
+
+You can find the original library here:
+http://www.planet-casio.com/Fr/logiciels/voir_un_logiciel_casio.php?showid=117
diff --git a/modules/casiowin/easy-input/include/EasyInput.h b/modules/casiowin/easy-input/include/EasyInput.h
index 5ed4fe4..d4402e5 100644
--- a/modules/casiowin/easy-input/include/EasyInput.h
+++ b/modules/casiowin/easy-input/include/EasyInput.h
@@ -31,9 +31,10 @@
#include <cdefs.h>
#include <fxlib.h>
-/* ************************************************************************* */
-/* Settings, main operations */
-/* ************************************************************************* */
+/* ---
+ * Settings, main operations.
+ * --- */
+
/* Among the settings are:
* - the position you want to have the dialog (column, row);
* - the box length;
@@ -85,23 +86,25 @@ typedef struct __EI_config {
_EXTERN void EI_init
_OF((void)) _THROW;
-_EXTERN const void* EI_manage_config
+_EXTERN void const *EI_manage_config
_OF((enum __EI_PARAM_TYPE __param, int __value)) _THROW;
/* And here is the central function to get a string, hurray! */
_EXTERN char* EI_input_string
- _OF((int __length, const char *__allowed)) _THROW;
-/* ************************************************************************* */
-/* Private functions */
-/* ************************************************************************* */
+ _OF((int __length, char const *__allowed)) _THROW;
+
+/* ---
+ * Private functions.
+ * --- */
+
/* These are utilities the author left in the original public header.
* First, here is to check the string. */
_EXTERN int EI_str_length
- _OF((const char *__str)) _THROW;
+ _OF((char const *__str)) _THROW;
_EXTERN int EI_check_char
- _OF((char __c, const char *__allowed));
+ _OF((char __c, char const *__allowed));
/* Manage the cursor. */
diff --git a/modules/casiowin/easy-input/src/main.c b/modules/casiowin/easy-input/src/main.c
index fa677cf..6eeb005 100644
--- a/modules/casiowin/easy-input/src/main.c
+++ b/modules/casiowin/easy-input/src/main.c
@@ -31,250 +31,268 @@
* ************************************************************************* */
#include <EasyInput.h>
-char *EI_input_string(int string_length, const char *chars_allowed)
+char *EI_input_string(int string_length, char const *chars_allowed)
{
char *string = (void*)(0);
EI_config *config = (void*)(0);
EI_cursor_settings cursor_settings;
-
unsigned int key = 0;
-
int i;
int char_deleted = 0;
int text_displacement = 0;
int cap = 0;
-
char arrow[] = {0xE6, 0x9A, 0};
+ /* Get the actual configuration. */
- /* Get actual configuration */
- config = (EI_config*)EI_manage_config(EI_GET_ALL, 0);
+ config = (EI_config *)EI_manage_config(EI_GET_ALL, 0);
- /* Allocate RAM for string */
- string = (char*)malloc(sizeof(char) * string_length + 1);
+ /* Allocate RAM for string. */
- /* Initialize string */
- for(i = 0; i <= string_length; i++) string[i] = 0;
+ string = (char *)malloc(sizeof(char) * string_length + 1);
- /* Setup cursor flash */
- switch(config->align)
- {
- default:
- case EI_ALIGN_LEFT:
- EI_Cursor_SetPosition(config->column, config->row);
- break;
+ /* Initialize the string. */
- case EI_ALIGN_CENTER:
- EI_Cursor_SetPosition(config->column + (config->box_length >> 1),
- config->row);
- break;
+ for (i = 0; i <= string_length; i++)
+ string[i] = 0;
- case EI_ALIGN_RIGHT:
- EI_Cursor_SetPosition(config->column + config->box_length - 1,
- config->row);
- break;
+ /* Setup the cursor flash. */
+
+ switch (config->align) {
+ default:
+ case EI_ALIGN_LEFT:
+ EI_Cursor_SetPosition(config->column, config->row);
+ break;
+
+ case EI_ALIGN_CENTER:
+ EI_Cursor_SetPosition(config->column + (config->box_length >> 1),
+ config->row);
+ break;
+
+ case EI_ALIGN_RIGHT:
+ EI_Cursor_SetPosition(config->column + config->box_length - 1,
+ config->row);
+ break;
}
- if(config->start_mode == EI_ALPHA_LOCKED)
- {
+ if (config->start_mode == EI_ALPHA_LOCKED) {
EI_KBD_PutKey(KEY_CTRL_SHIFT, 0);
GetKey(&key);
}
- if(config->start_mode >= EI_ALPHA)
- {
+ if (config->start_mode >= EI_ALPHA) {
EI_KBD_PutKey(KEY_CTRL_ALPHA, 0);
GetKey(&key);
EI_Cursor_SetFlashOn(3);
- }
- else
- {
+ } else
EI_Cursor_SetFlashOn(0);
- }
+ /* Main loop. */
- /* Main loop */
- i = 0;
- while(key != KEY_CTRL_EXE && key != KEY_CTRL_AC)
- {
+ for (i = 0; key != KEY_CTRL_EXE && key != KEY_CTRL_AC;) {
EI_Cursor_GetSettings(&cursor_settings);
- if(cursor_settings.flashstyle == 3 && !cap)
+ if (cursor_settings.flashstyle == 3 && !cap)
EI_Cursor_SetFlashOn(4);
- GetKey(&key); /* Getting key pressed */
+ /* Get and analyze the pressed key. */
- switch(key) /* Analyse key pressed */
- {
- case KEY_CTRL_F1:
- cap = !cap;
+ GetKey(&key);
+ switch (key) {
+ case KEY_CTRL_F1:
+ cap = !cap;
+ break;
+
+ case KEY_CTRL_DEL:
+ if (i > 0) {
+ string[--i] = 0;
+ char_deleted = 1;
+ }
+ break;
+
+ default:
+ /* Give correct value to keys with a non-ascii return values. */
+
+ switch (key) {
+ case KEY_CHAR_PLUS:
+ key = '+';
+ break;
+ case KEY_CHAR_MINUS:
+ case KEY_CHAR_PMINUS:
+ key = '-';
+ break;
+ case KEY_CHAR_MULT:
+ key = '*';
+ break;
+ case KEY_CHAR_DIV:
+ key = '/';
+ break;
+ case KEY_CHAR_ANS:
+ key = '_';
break;
+ case KEY_CTRL_XTT:
+ key = '#';
+ break;
+ }
- case KEY_CTRL_DEL:
- if(i > 0)
- {
- i--;
- string[i] = 0;
- char_deleted = 1;
- }
+ if (key > 127) /* KEY_CTRL_***, etc. */
break;
-
- default:
- /* Give correct value to keys with a non-ascii return values */
- if(key == KEY_CHAR_PLUS) key = '+';
- if(key == KEY_CHAR_MINUS || key == KEY_CHAR_PMINUS) key = '-';
- if(key == KEY_CHAR_MULT) key = '*';
- if(key == KEY_CHAR_DIV) key = '/';
- if(key == KEY_CHAR_ANS) key = '_';
- if(key == KEY_CTRL_XTT) key = '#';
-
- if(key > 127) /* KEY_CTRL_***, etc. */
- break;
-
- /* Switch between caps */
- if(key >= 'A' && key <= 'Z') key += !cap * 32;
-
- if (EI_check_char(key, chars_allowed)
- && EI_str_length(string) != string_length)
- {
- string[i] = key;
- i++;
- }
+
+ /* Switch between caps. */
+
+ if (key >= 'A' && key <= 'Z')
+ key += !cap * 32;
+
+ if (EI_check_char(key, chars_allowed)
+ && EI_str_length(string) != string_length) {
+ string[i] = key;
+ i++;
+ }
}
- switch(config->align) /* Print string */
- {
- default:
- case EI_ALIGN_LEFT:
- if(EI_str_length(string) < config->box_length)
- {
- EI_Cursor_SetPosition(config->column, config->row);
- Print((unsigned char*)string);
- if(char_deleted && EI_str_length(string)
- != config->box_length - 1)
- {
- Print((unsigned char*)" ");
- EI_Cursor_SetPosition(cursor_settings.column - 2,
- config->row);
- char_deleted = 0;
- }
- }
- else
- {
- EI_Cursor_SetPosition(config->column, config->row);
- Print((unsigned char*)arrow);
- Print((unsigned char*)(string + EI_str_length(string)
- - config->box_length + 2));
- }
- break;
+ /* Print the string. */
- case EI_ALIGN_CENTER:
- if(EI_str_length(string) < config->box_length)
- {
- if(char_deleted && EI_str_length(string)
- != config->box_length - 1 && (config->box_length - EI_str_length(string)) >> 1 != ((config->box_length - EI_str_length(string) - 1) >> 1))
- {
- EI_Cursor_SetPosition(config->column + ((config->box_length - EI_str_length(string)) >> 1) - 1, config->row);
- Print((unsigned char*)" ");
- Print((unsigned char*)string);
- char_deleted = 0;
- }
- else if(char_deleted && EI_str_length(string) != config->box_length - 1 && (config->box_length - EI_str_length(string)) >> 1 == ((config->box_length - EI_str_length(string) - 1) >> 1))
- {
- EI_Cursor_SetPosition(config->column + ((config->box_length - EI_str_length(string)) >> 1), config->row);
- Print((unsigned char*)string);
- Print((unsigned char*)" ");
- EI_Cursor_SetPosition(cursor_settings.column - 2, config->row);
- char_deleted = 0;
- }
- else
- {
- EI_Cursor_SetPosition(config->column + ((config->box_length - EI_str_length(string)) >> 1), config->row);
- Print((unsigned char*)string);
- }
- }
- else
- {
- EI_Cursor_SetPosition(config->column, config->row);
- Print((unsigned char*)arrow);
- Print((unsigned char*)(string + EI_str_length(string) - config->box_length + 2));
+ switch (config->align) {
+ default:
+ case EI_ALIGN_LEFT:
+ if (EI_str_length(string) < config->box_length) {
+ EI_Cursor_SetPosition(config->column, config->row);
+ Print((unsigned char *)string);
+
+ if(char_deleted && EI_str_length(string)
+ != config->box_length - 1) {
+ Print((unsigned char *)" ");
+ EI_Cursor_SetPosition(cursor_settings.column - 2,
+ config->row);
+ char_deleted = 0;
}
- break;
+ } else {
+ EI_Cursor_SetPosition(config->column, config->row);
+ Print((unsigned char *)arrow);
+ Print((unsigned char *)(string + EI_str_length(string)
+ - config->box_length + 2));
+ }
+ break;
- case EI_ALIGN_RIGHT:
- if(EI_str_length(string) < config->box_length)
- {
- EI_Cursor_SetPosition(config->column + config->box_length - EI_str_length(string) - (char_deleted && EI_str_length(string) != config->box_length - 1) - 1, config->row);
- if(char_deleted && EI_str_length(string) != config->box_length - 1)
- {
- Print((unsigned char*)" ");
- char_deleted = 0;
- }
- Print((unsigned char*)string);
+ case EI_ALIGN_CENTER:
+ if (EI_str_length(string) < config->box_length) {
+ if (char_deleted && EI_str_length(string)
+ != config->box_length - 1 && (config->box_length
+ - EI_str_length(string)) >> 1 != ((config->box_length
+ - EI_str_length(string) - 1) >> 1)) {
+ EI_Cursor_SetPosition(config->column +
+ ((config->box_length - EI_str_length(string)) >> 1)
+ - 1, config->row);
+ Print((unsigned char *)" ");
+ Print((unsigned char *)string);
+ char_deleted = 0;
+ } else if (char_deleted && EI_str_length(string)
+ != config->box_length - 1 && (config->box_length -
+ EI_str_length(string)) >> 1 == ((config->box_length -
+ EI_str_length(string) - 1) >> 1)) {
+ EI_Cursor_SetPosition(config->column +
+ ((config->box_length - EI_str_length(string)) >> 1),
+ config->row);
+ Print((unsigned char *)string);
+ Print((unsigned char *)" ");
+ EI_Cursor_SetPosition(cursor_settings.column - 2,
+ config->row);
+ char_deleted = 0;
+ } else {
+ EI_Cursor_SetPosition(config->column +
+ ((config->box_length - EI_str_length(string)) >> 1),
+ config->row);
+ Print((unsigned char *)string);
}
- else
- {
- EI_Cursor_SetPosition(config->column, config->row);
- Print((unsigned char*)arrow);
- Print((unsigned char*)(string + EI_str_length(string) - config->box_length + 2));
+ } else {
+ EI_Cursor_SetPosition(config->column, config->row);
+ Print((unsigned char *)arrow);
+ Print((unsigned char *)(string + EI_str_length(string)
+ - config->box_length + 2));
+ }
+ break;
+
+ case EI_ALIGN_RIGHT:
+ if (EI_str_length(string) < config->box_length) {
+ EI_Cursor_SetPosition(config->column + config->box_length
+ - EI_str_length(string) - (char_deleted
+ && EI_str_length(string) != config->box_length - 1) - 1,
+ config->row);
+ if (char_deleted && EI_str_length(string)
+ != config->box_length - 1) {
+ Print((unsigned char *)" ");
+ char_deleted = 0;
}
- break;
+ Print((unsigned char *)string);
+ } else {
+ EI_Cursor_SetPosition(config->column, config->row);
+ Print((unsigned char *)arrow);
+ Print((unsigned char *)(string + EI_str_length(string)
+ - config->box_length + 2));
+ }
+ break;
}
}
- /* Set off cursor mode */
+ /* Set off cursor mode. */
+
EI_Cursor_SetFlashOff();
+ /* Return NULL in case of an input break. */
- /* Return NULL in case of an input break */
- if(key == KEY_CTRL_AC)
- {
+ if (key == KEY_CTRL_AC) {
free(string);
- return (char*)(0);
+ return (NULL);
}
+ /* Return the string. */
- /* Return the string */
- return string;
+ return (string);
}
const void *EI_manage_config(enum __EI_PARAM_TYPE parameter, int value)
{
static EI_config config;
- if(value)
- {
- switch(parameter)
- {
- case EI_SET_COLUMN: config.column = value - 1;
- break;
- case EI_SET_ROW: config.row = value - 1;
- break;
- case EI_SET_BOX_LENGTH: config.box_length = (value < 3 ? 3 : value); /* Minimal size is 3 */
- break;
- case EI_SET_ALIGN: config.align = value;
- break;
- case EI_SET_START_MODE: config.start_mode = value;
- break;
- case EI_SET_Aa_KEY: config.Aa_key = value;
- break;
- }
- }
- else
- {
- switch(parameter)
- {
- case EI_GET_ALL: return (const void*)(&config);
- case EI_SET_COLUMN: return (const void*)&config.column;
- case EI_SET_ROW: return (const void*)&config.row;
- case EI_SET_BOX_LENGTH: return (const void*)&config.box_length;
- case EI_SET_ALIGN: return (const void*)&config.align;
- case EI_SET_START_MODE: return (const void*)&config.start_mode;
- case EI_SET_Aa_KEY: return (const void*)&config.Aa_key;
- }
+ if (value) switch (parameter) {
+ case EI_SET_COLUMN:
+ config.column = value - 1;
+ break;
+ case EI_SET_ROW:
+ config.row = value - 1;
+ break;
+ case EI_SET_BOX_LENGTH:
+ /* Minimal size is 3. */
+
+ config.box_length = (value < 3 ? 3 : value);
+ break;
+ case EI_SET_ALIGN:
+ config.align = value;
+ break;
+ case EI_SET_START_MODE:
+ config.start_mode = value;
+ break;
+ case EI_SET_Aa_KEY:
+ config.Aa_key = value;
+ break;
+ } else switch (parameter) {
+ case EI_GET_ALL:
+ return (const void*)(&config);
+ case EI_SET_COLUMN:
+ return (const void*)&config.column;
+ case EI_SET_ROW:
+ return (const void*)&config.row;
+ case EI_SET_BOX_LENGTH:
+ return (const void*)&config.box_length;
+ case EI_SET_ALIGN:
+ return (const void*)&config.align;
+ case EI_SET_START_MODE:
+ return (const void*)&config.start_mode;
+ case EI_SET_Aa_KEY:
+ return (const void*)&config.Aa_key;
}
- return (void*)(0);
+ return (NULL);
}
void EI_init(void)
@@ -289,23 +307,12 @@ void EI_init(void)
int EI_str_length(const char *str)
{
- int i = 0;
-
- while(str[i]) i++;
-
- return i;
+ return (strlen(str));
}
int EI_check_char(char c, const char *chars_allowed)
{
int i = 0;
- while(chars_allowed[i])
- {
- if(c == chars_allowed[i])
- return 1;
- i++;
- }
-
- return 0;
+ return (!!strchr(chars_allowed, c));
}
diff --git a/modules/casiowin/fxlib/bits/cdefs.h b/modules/casiowin/fxlib/bits/cdefs.h
new file mode 100644
index 0000000..504f96c
--- /dev/null
+++ b/modules/casiowin/fxlib/bits/cdefs.h
@@ -0,0 +1,17 @@
+/* Namespace -- none for now, but maybe some day? */
+
+#undef _BEGIN_NAMESPACE_FXLIB
+#undef _END_NAMESPACE_FXLIB
+#if _USE_CXX98
+# define _BEGIN_NAMESPACE_FXLIB /* namespace "fx" { */
+# define _END_NAMESPACE_FXLIB /* } */
+#else
+# define _BEGIN_NAMESPACE_FXLIB
+# define _END_NAMESPACE_FXLIB
+#endif
+
+/* Should we use non-official thingies? */
+
+#if !defined(_USE_FXLIB_UNOFFICIAL)
+# define _USE_FXLIB_UNOFFICIAL 1
+#endif
diff --git a/modules/casiowin/fxlib/include/fxlib/app.h b/modules/casiowin/fxlib/bits/fxlib/app.h
index a3990ac..52d08f7 100644
--- a/modules/casiowin/fxlib/include/fxlib/app.h
+++ b/modules/casiowin/fxlib/bits/fxlib/app.h
@@ -28,24 +28,26 @@
* The fact that you are presently reading this means you have had knowledge of
* the CeCILL-C license and that you accept its terms.
* ************************************************************************* */
-#include <fxlib/cdefs.h>
#if _USE_FXLIB_UNOFFICIAL
_BEGIN_NAMESPACE_FXLIB
_BEGIN_DECLS
-/* Add-in e-strip information. */
+/* Add-in e-strip information.
+ *
+ * `id`: ?
+ * `addin_array_start`: RAM address of the queried add-in in the
+ * add-in array;
+ * `estrip_location`: address of the queried e-strip in storage memory;
+ * `addin_smem_location`: address of the queried add-in in storage memory;
+ * `estrip_icon_location`: address of the queried e-strip icon in smem. */
typedef struct {
__uint16_t _unused;
__uint16_t id;
- /* RAM address of the queried add-in in the add-in array */
void *addin_array_start;
- /* Address of the queried e-strip in storage memory */
void *estrip_location;
- /* Address of the queried add-in in storage memory */
void *addin_smem_location;
- /* Address of the queried e-strip icon in storage memory */
void *estrip_icon_location;
} addin_estrip_info_t;
@@ -67,26 +69,35 @@ _EXTERN int App_BuiltInCount
/* Run system apps.
* In general, _R4 = 0 and _R5 = 0 is advised. */
-# define _FXAPP(_NAME) \
-_EXTERN int App_##NAME \
- _OF((int __R4, int __R5)) _THROW;
-
_EXTERN int App_Start
_OF((int __R4, int __R5, int __index, int __force)) _THROW;
-_FXAPP(CONICS)
-_FXAPP(DYNA)
-_FXAPP(EACT)
-_FXAPP(EQUA)
-_FXAPP(PROG)
-_FXAPP(FINANCE)
-_FXAPP(GRAPH_TABLE)
-_FXAPP(LINK)
-_FXAPP(MEMORY)
-_FXAPP(RECUR)
-_FXAPP(RUN_MAT)
-_FXAPP(RUN_STAT)
-_FXAPP(SYSTEM)
+_EXTERN int App_CONICS
+ OF((int __R4, int __R5)) _THROW;
+_EXTERN int App_DYNA
+ OF((int __R4, int __R5)) _THROW;
+_EXTERN int App_EACT
+ OF((int __R4, int __R5)) _THROW;
+_EXTERN int App_EQUA
+ OF((int __R4, int __R5)) _THROW;
+_EXTERN int App_PROG
+ OF((int __R4, int __R5)) _THROW;
+_EXTERN int App_FINANCE
+ OF((int __R4, int __R5)) _THROW;
+_EXTERN int App_GRAPH_TABLE
+ OF((int __R4, int __R5)) _THROW;
+_EXTERN int App_LINK
+ OF((int __R4, int __R5)) _THROW;
+_EXTERN int App_MEMORY
+ OF((int __R4, int __R5)) _THROW;
+_EXTERN int App_RECUR
+ OF((int __R4, int __R5)) _THROW;
+_EXTERN int App_RUN_MAT
+ OF((int __R4, int __R5)) _THROW;
+_EXTERN int App_RUN_STAT
+ OF((int __R4, int __R5)) _THROW;
+_EXTERN int App_SYSTEM
+ OF((int __R4, int __R5)) _THROW;
_END_DECLS
_END_NAMESPACE_FXLIB
diff --git a/modules/casiowin/fxlib/include/fxlib/battery.h b/modules/casiowin/fxlib/bits/fxlib/battery.h
index 31e5513..351b34d 100644
--- a/modules/casiowin/fxlib/include/fxlib/battery.h
+++ b/modules/casiowin/fxlib/bits/fxlib/battery.h
@@ -28,7 +28,6 @@
* The fact that you are presently reading this means you have had knowledge of
* the CeCILL-C license and that you accept its terms.
* ************************************************************************* */
-#include <fxlib/cdefs.h>
#if _USE_FXLIB_UNOFFICIAL
_BEGIN_NAMESPACE_FXLIB
_BEGIN_DECLS
@@ -50,13 +49,15 @@ _BEGIN_DECLS
# define battery_flag_delay 0x0001
-/* Get the status */
+/* Get the status. */
+
_EXTERN int Battery_IsLow_Delay
_OF((int __flags)) _THROW;
_EXTERN int Battery_GetStatus
_OF((int __flags)) _THROW;
-/* Do that, and print a message */
+/* Do that, and print a message. */
+
_EXTERN int Battery_DisplayLowStatus
_OF((int __flags)) _THROW;
diff --git a/modules/casiowin/fxlib/include/fxlib/bcd.h b/modules/casiowin/fxlib/bits/fxlib/bcd.h
index c699c34..3ac8a14 100644
--- a/modules/casiowin/fxlib/include/fxlib/bcd.h
+++ b/modules/casiowin/fxlib/bits/fxlib/bcd.h
@@ -28,15 +28,16 @@
* The fact that you are presently reading this means you have had knowledge of
* the CeCILL-C license and that you accept its terms.
* ************************************************************************* */
-#include <fxlib/cdefs.h>
#if _USE_FXLIB_UNOFFICIAL
_BEGIN_NAMESPACE_FXLIB
_BEGIN_DECLS
-/* ************************************************************************* */
-/* BCD structures */
-/* ************************************************************************* */
-/* Storage structure */
+/* ---
+ * BCD structures.
+ * --- */
+
+/* Storage structure. */
+
# define bcdv_BCDval BCDval
struct tag_BCDval {
unsigned char BCDval[9];
@@ -45,7 +46,9 @@ struct tag_BCDval {
typedef struct tag_BCDval bcdval_t;
typedef struct tag_BCDval BCDVAL;
-/* Internal structure (the structure that is actually used for calculations) */
+/* Internal structure (the structure that is actually used for
+ * calculations). */
+
# define bcd_exponent exponent
# define bcd_sign sign
# define bcd_mantissa mantissa
@@ -57,27 +60,33 @@ struct tag_BCD {
};
typedef struct tag_BCD bcd_t;
typedef struct tag_BCD BCD;
-/* ************************************************************************* */
-/* Methods */
-/* ************************************************************************* */
-/* BCD to internal */
+
+/* ---
+ * Methods.
+ * --- */
+
+/* BCD to internal. */
+
_EXTERN _NONNULL(1, __internal) _NONNULL(2, __source) int BCDtoInternal
- _OF((bcd_t *__internal, const bcdval_t *__source)) _THROW;
+ _OF((bcd_t *__internal, bcdval_t const *__source)) _THROW;
+
+/* Conversions from and to unsigned int (FIXME: probably wrong prototypes). */
-/* Conversions from and to unsigned int (FIXME: probably wrong prototypes) */
_EXTERN _NONNULL(1, __source) _NONNULL(2, __dest) int Num_UIntToBCD
- _OF((const unsigned int *__source, bcd_t *__dest)) _THROW;
+ _OF((unsigned int const *__source, bcd_t *__dest)) _THROW;
_EXTERN _NONNULL(1, __dest) _NONNULL(2, __source) int Num_BCDToUint
_OF((unsigned int *__dest, bcd_t *__source)) _THROW;
-/* calculate an expression */
+/* Calculate an expression. */
+
_EXTERN _NONNULL(1, __formula) _NONNULL(3, __opcode) void CalculateExpression
_OF((char **__formula, char __opcode[2], bcdval_t *__result,
int __copyfirst)) _THROW;
-/* get not a number value */
+/* Get not a number value. */
+
_EXTERN _NONNULL(1, __value) _NONNULL(2, __result) int BCD_GetNotANumberValue
- _OF((const unsigned char *__value, unsigned char *__result)) _THROW;
+ _OF((unsigned char const *__value, unsigned char *__result)) _THROW;
_END_DECLS
_END_NAMESPACE_FXLIB
diff --git a/modules/casiowin/fxlib/include/fxlib/clock.h b/modules/casiowin/fxlib/bits/fxlib/clock.h
index 9fd3614..2077cb3 100644
--- a/modules/casiowin/fxlib/include/fxlib/clock.h
+++ b/modules/casiowin/fxlib/bits/fxlib/clock.h
@@ -28,7 +28,6 @@
* The fact that you are presently reading this means you have had knowledge of
* the CeCILL-C license and that you accept its terms.
* ************************************************************************* */
-#include <fxlib/cdefs.h>
#if _USE_FXLIB_UNOFFICIAL
_BEGIN_NAMESPACE_FXLIB
_BEGIN_DECLS
diff --git a/modules/casiowin/fxlib/include/fxlib/comm.h b/modules/casiowin/fxlib/bits/fxlib/comm.h
index e5c606c..441feff 100644
--- a/modules/casiowin/fxlib/include/fxlib/comm.h
+++ b/modules/casiowin/fxlib/bits/fxlib/comm.h
@@ -28,38 +28,44 @@
* The fact that you are presently reading this means you have had knowledge of
* the CeCILL-C license and that you accept its terms.
* ************************************************************************* */
-#include <fxlib/cdefs.h>
-#include <commbios.h>
#if _USE_FXLIB_UNOFFICIAL
_BEGIN_NAMESPACE_FXLIB
_BEGIN_DECLS
-/* ************************************************************************* */
-/* Basic functions */
-/* ************************************************************************* */
-/* Open the communication, using flags */
+/* ---
+ * Basic functions.
+ * --- */
+
+/* Open the communication, using flags. */
+
_EXTERN int Comm_Open
_OF((unsigned short __flags)) _THROW;
_EXTERN int Comm_OpenSerial
_OF((unsigned short __flags)) _THROW;
+
# define Serial_OpenFromComm(_FLAGS) \
Comm_OpenSerial(_FLAGS)
# define Serial_Open2(_FLAGS) \
Comm_OpenSerial(_FLAGS)
-/* Close the communication */
+/* Close the communication. */
+
_EXTERN int Comm_Close
_OF((int __immediate)) _THROW;
-/* Check the communication status */
+/* Check the communication status. */
+
_EXTERN int Comm_IsUSB
_OF((void)) _THROW;
# define Comm_GetCurrentSelector() \
Comm_IsUSB()
-/* ************************************************************************* */
-/* Raw communication utilities */
-/* ************************************************************************* */
-/* receive data */
+
+/* ---
+ * Raw communication utilities.
+ * --- */
+
+/* Receive data. */
+
_EXTERN _NONNULL(1, __result) int Comm_SpyByte
_OF((unsigned char *__result)) _THROW;
_EXTERN _NONNULL(1, __result) int Comm_ReadByte
@@ -73,7 +79,8 @@ _EXTERN _NONNULL(1, __buffer) int Comm_ReadBytes
# define Comm_WaitForAndReadNBytes(__BUF, __COUNT) \
Comm_ReadBytes(__BUF, __COUNT)
-/* send data */
+/* Send data. */
+
_EXTERN int Comm_SendByte
_OF((unsigned char __byte)) _THROW;
_EXTERN _NONNULL(1, __buffer) int Comm_SendBytes
@@ -85,17 +92,21 @@ _EXTERN _NONNULL(1, __buffer) int Comm_SendBytes
# define Comm_TransmitBytes(_BUF, _COUNT) \
Comm_SendBytes(_BUF, _COUNT)
-/* wait for data to be transmitted, or for a buffer to be sent */
+/* Wait for data to be transmitted, or for a buffer to be sent. */
+
_EXTERN int Comm_WaitForAnyBuffer
_OF((int __timeout, int __receive, int* __time)) _THROW;
# define Comm_Drain(_TIMEOUT, _TIME) \
Comm_WaitForAnyBuffer(_TIMEOUT, 0, _TIME)
# define Comm_Wait(_TIMEOUT, _TIME) \
Comm_WaitForAnyBuffer(_TIMEOUT, 1, _TIME)
-/* ************************************************************************* */
-/* Protocol 7 utilities */
-/* ************************************************************************* */
-/* ASCII-HEX/binary conversions */
+
+/* ---
+ * Protocol 7.00 utilities.
+ * --- */
+
+/* ASCII-HEX/binary conversions. */
+
_EXTERN _NONNULL(1, __value) _NONNULL(2, __result) void Comm_HexToByte
_OF((unsigned char *__value, unsigned char *__result)) _THROW;
_EXTERN _NONNULL(1, __value) _NONNULL(2, __result) void Comm_HexToWord
@@ -105,24 +116,33 @@ _EXTERN _NONNULL(2, __result) void Comm_ByteToHex
_EXTERN _NONNULL(2, __result) void Comm_WordToHex
_OF((unsigned short __value, unsigned char *__result)) _THROW;
-/* And some macros */
-# define HexToByte(_VAL, _RES) Comm_HexToByte(_VAL, _RES)
-# define HexToWord(_VAL, _RES) Comm_HexToWord(_VAL, _RES)
-# define ByteToHex(_VAL, _RES) Comm_ByteToHex(_VAL, _RES)
-# define WordToHex(_VAL, _RES) Comm_WordToHex(_VAL, _RES)
+/* And some macros. */
+
+# define HexToByte(_VAL, _RES) \
+ Comm_HexToByte(_VAL, _RES)
+# define HexToWord(_VAL, _RES) \
+ Comm_HexToWord(_VAL, _RES)
+# define ByteToHex(_VAL, _RES) \
+ Comm_ByteToHex(_VAL, _RES)
+# define WordToHex(_VAL, _RES) \
+ Comm_WordToHex(_VAL, _RES)
+
+/* Padding utilities (useful for data packet content). */
-/* Padding utilities (useful for data packet content) */
_EXTERN _NONNULL(1, __source) _NONNULL(3, __dest) _NONNULL(4, __count)
int Comm_Padding_5C
- _OF((const unsigned char *__source, unsigned short __n,
+ _OF((unsigned char const *__source, unsigned short __n,
unsigned char *__dest, unsigned short *__count)) _THROW;
+
_EXTERN _NONNULL(1, __source) _NONNULL(3, __dest) _NONNULL(4, __count)
int Comm_ReversePadding_5C
- _OF((const unsigned char *__source, unsigned short __n,
+ _OF((unsigned char const *__source, unsigned short __n,
unsigned char *__dest, unsigned short *__count)) _THROW;
-/* ************************************************************************* */
-/* Protocol 7 packet management functions */
-/* ************************************************************************* */
+
+/* ---
+ * Protocol 7.00 packet management functions.
+ * --- */
+
/* Get a packet. */
_EXTERN _NONNULL(1, __type) int Comm_IsValidPacketAvailable
@@ -150,11 +170,13 @@ _EXTERN _NONNULL(1, __packet) _NONNULL(3, __data) int Comm_PrepareDataPacket
_OF((comm_packet_t *__packet, unsigned char subtype,
void *__data, unsigned short __size)) _THROW;
-/* Send a prepared packet */
+/* Send a prepared packet. */
+
_EXTERN int Comm_SendPacket
_OF((comm_packet_t *__packet)) _THROW;
-/* Send an OHP (TYP01) packet */
+/* Send an OHP (TYP01) packet. */
+
_EXTERN void AutoImageTransfer_OHP
_OF((void)) _THROW;
_EXTERN void USB_CaptureDisplay
diff --git a/modules/casiowin/fxlib/include/fxlib/display.h b/modules/casiowin/fxlib/bits/fxlib/display.h
index dde6cb6..febb9dd 100644
--- a/modules/casiowin/fxlib/include/fxlib/display.h
+++ b/modules/casiowin/fxlib/bits/fxlib/display.h
@@ -28,15 +28,15 @@
* The fact that you are presently reading this means you have had knowledge of
* the CeCILL-C license and that you accept its terms.
* ************************************************************************* */
-#include <fxlib/cdefs.h>
-#include <dispbios.h>
__BEGIN_NAMESPACE_FXLIB
__BEGIN_DECLS
-/* ************************************************************************* */
-/* Interact with the VRAM/display driver */
-/* ************************************************************************* */
-/* Clear the screen/VRAM */
+/* ---
+ * Interact with the VRAM/display driver.
+ * --- */
+
+/* Clear the screen/VRAM. */
+
_EXTERN void Bdisp_AllClr_DD
_OF((void)) _THROW;
_EXTERN void Bdisp_AllClr_VRAM
@@ -44,42 +44,49 @@ _EXTERN void Bdisp_AllClr_VRAM
_EXTERN void Bdisp_AllClr_DDVRAM
_OF((void)) _THROW;
-/* Clear an area of the screen/vram */
+/* Clear an area of the screen/vram. */
+
_EXTERN _NONNULL(1, __pArea) void Bdisp_AreaClr_DD
- _OF((const DISPBOX *__pArea)) _THROW;
+ _OF((DISPBOX const *__pArea)) _THROW;
_EXTERN _NONNULL(1, __pArea) void Bdisp_AreaClr_VRAM
- _OF((const DISPBOX *__pArea)) _THROW;
+ _OF((DISPBOX const *__pArea)) _THROW;
_EXTERN _NONNULL(1, __pArea) void Bdisp_AreaClr_DDVRAM
- _OF((const DISPBOX *__pArea)) _THROW;
+ _OF((DISPBOX const *__pArea)) _THROW;
+
+/* Reverse an area of the VRAM. */
-/* Reverse an area of the VRAM */
_EXTERN void Bdisp_AreaReverseVRAM
_OF((int __x1, int __y1, int __x2, int __y2)) _THROW;
-/* Update the display */
+/* Update the display. */
+
_EXTERN void Bdisp_PutDisp_DD
_OF((void)) _THROW;
_EXTERN _NONNULL(1, __PutDispArea) void Bdisp_PutDispArea_DD
- _OF((const DISPBOX *__PutDispArea)) _THROW;
+ _OF((DISPBOX const *__PutDispArea)) _THROW;
+
+/* Get the content of the display/VRAM. */
-/* Get the content of the display/VRAM */
_EXTERN _NONNULL(1, __pData) void Bdisp_GetDisp_DD
_OF((unsigned char *__pData)) _THROW;
_EXTERN _NONNULL(1, __pData) void Bdisp_GetDisp_VRAM
_OF((unsigned char *__pData)) _THROW;
-/* Get an area from the display/VRAM */
+/* Get an area from the display/VRAM. */
+
_EXTERN _NONNULL(1, __ReadArea) _NONNULL(2, __ReadData) void Bdisp_ReadArea_DD
- _OF((const DISPBOX *__ReadArea, unsigned char *__ReadData)) _THROW;
+ _OF((DISPBOX const *__ReadArea, unsigned char *__ReadData)) _THROW;
_EXTERN _NONNULL(1, __ReadArea) _NONNULL(2, __ReadData)
void Bdisp_ReadArea_VRAM
- _OF((const DISPBOX *__ReadArea, unsigned char *__ReadData)) _THROW;
+ _OF((DISPBOX const *__ReadArea, unsigned char *__ReadData)) _THROW;
-/* Get the VRAM address */
-_EXTERN void* Bdisp_GetVRAMAddress
+/* Get the VRAM address. */
+
+_EXTERN void *Bdisp_GetVRAMAddress
_OF((void)) _THROW;
-/* Set a point (pixel) */
+/* Set a point (pixel). */
+
_EXTERN void Bdisp_SetPoint_DD
_OF((int __x, int __y, unsigned char __point)) _THROW;
_EXTERN void Bdisp_SetPoint_VRAM
@@ -87,28 +94,34 @@ _EXTERN void Bdisp_SetPoint_VRAM
_EXTERN void Bdisp_SetPoint_DDVRAM
_OF((int __x, int __y, unsigned char __point)) _THROW;
-/* Get a point (pixel) */
+/* Get a point (pixel). */
+
_EXTERN _WUR int Bdisp_GetPoint_VRAM
_OF((int __x, int __y)) _THROW;
-/* ************************************************************************* */
-/* Drawing functions */
-/* ************************************************************************* */
-/* write a graph */
+
+/* ---
+ * Drawing functions.
+ * --- */
+
+/* Write a graph. */
+
_EXTERN _NONNULL(1, __WriteGraph) void Bdisp_WriteGraph_DD
- _OF((const DISPGRAPH *__WriteGraph)) _THROW;
+ _OF((DISPGRAPH const *__WriteGraph)) _THROW;
_EXTERN _NONNULL(1, __WriteGraph) void Bdisp_WriteGraph_VRAM
- _OF((const DISPGRAPH *__WriteGraph)) _THROW;
+ _OF((DISPGRAPH const *__WriteGraph)) _THROW;
_EXTERN _NONNULL(1, __WriteGraph) void Bdisp_WriteGraph_DDVRAM
- _OF((const DISPGRAPH *__WriteGraph)) _THROW;
+ _OF((DISPGRAPH const *__WriteGraph)) _THROW;
+
+/* Draw/clear a line. */
-/* Draw/clear a line */
_EXTERN void Bdisp_DrawLineVRAM
_OF((int __x1, int __y1, int __x2, int __y2)) _THROW;
_EXTERN void Bdisp_ClearLineVRAM
_OF((int __x1, int __y1, int __x2, int __y2)) _THROW;
# if _USE_FXLIB_UNOFFICIAL
-/* Put a shape */
+/* Put a shape. */
+
_EXTERN _NONNULL(1, __shape) void Bdisp_ShapeToVRAM
_OF((shape_t *__shape)) _THROW;
_EXTERN _NONNULL(1, __shape) void Bdisp_ShapeToDD
@@ -116,48 +129,58 @@ _EXTERN _NONNULL(1, __shape) void Bdisp_ShapeToDD
_EXTERN _NONNULL(1, __shape) void Bdisp_ShapeToVRAM_DD
_OF((shape_t *__shape)) _THROW;
-/* Put a rectangle */
+/* Put a rectangle. */
+
_EXTERN void Bdisp_DrawRectangle
_OF((int __x1, int __y1, int __x2, int __y2)) _THROW;
# endif
-/* ************************************************************************* */
-/* Text printing */
-/* ************************************************************************* */
-/* Change the cursor position */
+
+/* ---
+ * Text printing.
+ * --- */
+
+/* Change the cursor position. */
+
_EXTERN void locate
_OF((int __x, int __y)) _THROW;
-/* Print a string */
+/* Print a string. */
+
_EXTERN _NONNULL(1, __str) void Print
- _OF((const unsigned char *__str)) _THROW;
+ _OF((unsigned char const *__str)) _THROW;
_EXTERN _NONNULL(1, __str) void PrintRev
- _OF((const unsigned char *__str)) _THROW;
+ _OF((unsigned char const *__str)) _THROW;
+
+/* Print a character. */
-/* Print a character */
_EXTERN _NONNULL(1, __chr) void PrintC
- _OF((const unsigned char *__chr)) _THROW;
+ _OF((unsigned char const *__chr)) _THROW;
_EXTERN _NONNULL(1, __str) void PrintRevC
- _OF((const unsigned char *__chr)) _THROW;
+ _OF((unsigned char const *__chr)) _THROW;
+
+/* Print a line. */
-/* Print a line */
_EXTERN _NONNULL(1, __str) void PrintLine
- _OF((const unsigned char *__str, int __max)) _THROW;
+ _OF((unsigned char const *__str, int __max)) _THROW;
_EXTERN _NONNULL(1, __str) void PrintRLine
- _OF((const unsigned char *__str, int __max)) _THROW;
+ _OF((unsigned char const *__str, int __max)) _THROW;
+
+/* Print at a position. */
-/* Print at a position */
_EXTERN _NONNULL(3, __str) void PrintXY
- _OF((int __x, int __y, const unsigned char *__str, int __type)) _THROW;
+ _OF((int __x, int __y, unsigned char const *__str, int __type)) _THROW;
_EXTERN _NONNULL(3, __str) int PrintMini
- _OF((int __x, int __y, const unsigned char *__str, int __type)) _THROW;
+ _OF((int __x, int __y, unsigned char const *__str, int __type)) _THROW;
+
+/* Save and restore the display. */
-/* Save and restore the display */
_EXTERN void SaveDisp
_OF((unsigned char __num)) _THROW;
_EXTERN void RestoreDisp
_OF((unsigned char __num)) _THROW;
-/* Make a pop-up window */
+/* Make a pop-up window. */
+
_EXTERN void PopUpWin
_OF((int __n)) _THROW;
diff --git a/modules/casiowin/fxlib/include/fxlib/file.h b/modules/casiowin/fxlib/bits/fxlib/file.h
index bc88e5a..41bdeb0 100644
--- a/modules/casiowin/fxlib/include/fxlib/file.h
+++ b/modules/casiowin/fxlib/bits/fxlib/file.h
@@ -28,15 +28,14 @@
* The fact that you are presently reading this means you have had knowledge of
* the CeCILL-C license and that you accept its terms.
* ************************************************************************* */
-#include <fxlib/cdefs.h>
-#include <filebios.h>
#define MAX_PATH 50 /* a quick estimation */
_BEGIN_NAMESPACE_FXLIB
_BEGIN_DECLS
-/* ************************************************************************* */
-/* Open and close files */
-/* ************************************************************************* */
+/* ---
+ * Open and close files.
+ * --- */
+
/* Identify the device:
* Tries to detect the device referenced by `filename`, skips first
* reverse solidus if present.
@@ -46,23 +45,23 @@ _BEGIN_DECLS
#if _USE_FXLIB_UNOFFICIAL
_EXTERN _NONNULL(1, __filename) int Bfile_identify_device_OS
- _OF((const FONTCHARACTER *__filename)) _THROW;
+ _OF((FONTCHARACTER const *__filename)) _THROW;
#endif
/* Open a handle; for `Bfile_OpenFile_OS`, `mode2` was probably reserved for a
* future use, and should be set to zero. */
_EXTERN _NONNULL(1, __filename) _WUR int Bfile_OpenFile
- _OF((const FONTCHARACTER *__filename, int __mode)) _THROW;
+ _OF((FONTCHARACTER const *__filename, int __mode)) _THROW;
#if _USE_FXLIB_UNOFFICIAL
_EXTERN _NONNULL(1, __filename) int Bfile_OpenFile_OS
- _OF((const FONTCHARACTER *__filename, int __mode, int __mode2)) _THROW;
+ _OF((FONTCHARACTER const *__filename, int __mode, int __mode2)) _THROW;
#endif
/* Open a handle on the main memory (MCS): */
_EXTERN _NONNULL(1, __name) _WUR int Bfile_OpenMainMemory
- _OF((const unsigned char *__name)) _THROW;
+ _OF((unsigned char const *__name)) _THROW;
/* Close a handle; should not be used to close a main memory handle! */
@@ -72,9 +71,11 @@ _EXTERN int Bfile_CloseFile
_EXTERN int Bfile_CloseFile_OS
_OF((int __handle)) _THROW;
#endif
-/* ************************************************************************* */
-/* Basic interactions on the file */
-/* ************************************************************************* */
+
+/* ---
+ * Basic interactions on the file.
+ * --- */
+
/* Read, write, seek: */
_EXTERN _NONNULL(2, __buf) int Bfile_ReadFile
@@ -85,10 +86,10 @@ _EXTERN _NONNULL(2, __buf) int Bfile_ReadFile_OS
#endif
_EXTERN _NONNULL(2, __buf) int Bfile_WriteFile
- _OF((int __handle, const void *__buf, int __size)) _THROW;
+ _OF((int __handle, void const *__buf, int __size)) _THROW;
#if _USE_FXLIB_UNOFFICIAL
_EXTERN _NONNULL(2, __buf) int Bfile_WriteFile_OS
- _OF((int __handle, const void *__buf, int __size)) _THROW;
+ _OF((int __handle, void const *__buf, int __size)) _THROW;
#endif
_EXTERN int Bfile_SeekFile
@@ -106,48 +107,52 @@ _EXTERN int Bfile_GetFileSize
_EXTERN _WUR int Bfile_GetFileSize_OS
_OF((int __handle)) _THROW;
#endif
-/* ************************************************************************* */
-/* Interact with storage devices */
-/* ************************************************************************* */
+
+/* ---
+ * Interact with storage devices.
+ * --- */
+
/* Create files or directories: */
_EXTERN _NONNULL(1, __filename) int Bfile_CreateFile
- _OF((const FONTCHARACTER *__filename, int __size)) _THROW;
+ _OF((FONTCHARACTER const *__filename, int __size)) _THROW;
_EXTERN _NONNULL(1, __pathname) int Bfile_CreateDirectory
- _OF((const FONTCHARACTER *__pathname, int __size)) _THROW;
+ _OF((FONTCHARACTER const *__pathname, int __size)) _THROW;
_EXTERN _NONNULL(1, __name) int Bfile_CreateMainMemory
- _OF((const unsigned char *__name)) _THROW;
+ _OF((unsigned char const *__name)) _THROW;
/* Rename a file: */
_EXTERN _NONNULL(1, __old) _NONNULL(2, __new) int Bfile_RenameEntry
- _OF((const FONTCHARACTER *__old, const FONTCHARACTER *__new)) _THROW;
+ _OF((FONTCHARACTER const *__old, FONTCHARACTER const *__new)) _THROW;
_EXTERN _NONNULL(1, __old) _NONNULL(2, __new) int Bfile_RenameMainMemory
- _OF((const unsigned char *__old, const unsigned char *__new)) _THROW;
+ _OF((unsigned char const *__old, unsigned char const *__new)) _THROW;
/* Delete files: */
_EXTERN _NONNULL(1, __filename) int Bfile_DeleteEntry
- _OF((const FONTCHARACTER *__filename, int __mode)) _THROW;
+ _OF((FONTCHARACTER const *__filename, int __mode)) _THROW;
_EXTERN _NONNULL(1, __filename) int Bfile_DeleteFile
- _OF((const FONTCHARACTER *__filename)) _THROW;
+ _OF((FONTCHARACTER const *__filename)) _THROW;
_EXTERN _NONNULL(1, __pathname) int Bfile_DeleteDirectory
- _OF((const FONTCHARACTER *__pathname)) _THROW;
+ _OF((FONTCHARACTER const *__pathname)) _THROW;
_EXTERN _NONNULL(1, __name) int Bfile_DeleteMainMemory
- _OF((const unsigned char *__name)) _THROW;
+ _OF((unsigned char const *__name)) _THROW;
/* Get the free space on a media */
_EXTERN _NONNULL(2, __freebytes) int Bfile_GetMediaFree
_OF((enum DEVICE_TYPE __devicetype, int *__freebytes)) _THROW;
+#if _USE_FXLIB_UNOFFICIAL
_EXTERN _NONNULL(1, __media) _NONNULL(2, __freebytes) int Bfile_GetMediaFree_OS
_OF((FONTCHARACTER *__media, int *__freebytes)) _THROW;
+#endif
/* Find elements on a storage device: */
_EXTERN _NONNULL(1, __pathname) _NONNULL(2, __FindHandle)
_NONNULL(3, __foundfile) _NONNULL(4, __fileinfo) int Bfile_FindFirst
- _OF((const FONTCHARACTER *__pathname, int *__FindHandle,
+ _OF((FONTCHARACTER const *__pathname, int *__FindHandle,
FONTCHARACTER *__foundfile, FILE_INFO *__fileinfo)) _THROW;
_EXTERN _NONNULL(2, __foundfile) _NONNULL(3, __fileinfo) int Bfile_FindNext
_OF((int __FindHandle, FONTCHARACTER *__foundfile,
diff --git a/modules/casiowin/fxlib/include/fxlib/keyboard.h b/modules/casiowin/fxlib/bits/fxlib/keyboard.h
index a9f032b..77d2904 100644
--- a/modules/casiowin/fxlib/include/fxlib/keyboard.h
+++ b/modules/casiowin/fxlib/bits/fxlib/keyboard.h
@@ -28,38 +28,44 @@
* The fact that you are presently reading this means you have had knowledge of
* the CeCILL-C license and that you accept its terms.
* ************************************************************************* */
-#include <fxlib/cdefs.h>
-#include <keybios.h>
_BEGIN_NAMESPACE_FXLIB
_BEGIN_DECLS
-/* ************************************************************************* */
-/* Configure the keyboard */
-/* ************************************************************************* */
-/* Repeat types */
+/* ---
+ * Configure the keyboard.
+ * --- */
+
+/* Repeat types. */
+
#define KEYREP_NOEVENT 0
#define KEYREP_KEYEVENT 1
#define KEYREP_TIMEREVENT 2
-/* Set the repeat time */
+/* Set the repeat time. */
+
_EXTERN void Bkey_Set_RepeatTime
_OF((long __FirstCount, long __NextCount)) _THROW;
_EXTERN void Bkey_Set_RepeatTime_Default
_OF((void)) _THROW;
-/* Get the current repeat time */
+/* Get the current repeat time. */
+
_EXTERN _NONNULL(1, __FirstCount) _NONNULL(2, __NextCount)
void Bkey_Get_RepeatTime
_OF((long *__FirstCount, long *__NextCount)) _THROW;
-/* ************************************************************************* */
-/* Get key presses, check key statuses */
-/* ************************************************************************* */
-/* Waiting types */
+
+/* ---
+ * Get key presses, check key statuses.
+ * --- */
+
+/* Waiting types. */
+
#define KEYWAIT_HALTON_TIMEROFF 0
#define KEYWAIT_HALTOFF_TIMEROFF 1
#define KEYWAIT_HALTON_TIMERON 2
-/* Get key presses */
+/* Get key presses. */
+
_EXTERN int GetKey
_OF((unsigned int *__keycode)) _THROW;
_EXTERN _NONNULL(4, __keycode) int GetKeyWait
@@ -70,17 +76,20 @@ int GetKeyWait_OS
_OF((int *__column, int *__row, int __waiting_type, int __timeout,
int __menu, unsigned short *__keycode)) _THROW;
-/* Check key statuses */
+/* Check key statuses. */
+
_EXTERN _WUR int IsKeyDown
_OF((int __keycode)) _THROW;
_EXTERN _WUR int IsKeyUp
_OF((int __keycode)) _THROW;
-/* ************************************************************************* */
-/* Syscalls */
-/* ************************************************************************* */
+
+/* ---
+ * Syscalls.
+ * --- */
+
#if _USE_FXLIB_UNOFFICIAL
+/* Get key. */
-/* Get key */
_EXTERN _NONNULL(1, __column) _NONNULL(2, __row) _NONNULL(6, __keycode)
int Keyboard_GetKeyWait
_OF((int *__column, int *__row, int __type_of_waiting,
@@ -93,7 +102,8 @@ _EXTERN _NONNULL(1, __matrixcode) int Keyboard_IsKeyPressed
_EXTERN _WUR int Keyboard_KeyDown
_OF((void)) _THROW;
-/* Put key */
+/* Put key. */
+
_EXTERN int PutKey
_OF((int __keycode, int __mode)) _THROW;
_EXTERN int Keyboard_PutKeycode
diff --git a/modules/casiowin/fxlib/include/fxlib/serial.h b/modules/casiowin/fxlib/bits/fxlib/serial.h
index b5b10b6..c0be52c 100644
--- a/modules/casiowin/fxlib/include/fxlib/serial.h
+++ b/modules/casiowin/fxlib/bits/fxlib/serial.h
@@ -28,16 +28,16 @@
* The fact that you are presently reading this means you have had knowledge of
* the CeCILL-C license and that you accept its terms.
* ************************************************************************* */
-#include <fxlib/cdefs.h>
-#include <fxlib/comm.h>
#if _USE_FXLIB_UNOFFICIAL
_BEGIN_NAMESPACE_FXLIB
_BEGIN_DECLS
-/* ************************************************************************* */
-/* Basic functions */
-/* ************************************************************************* */
-/* serial interrupt handler prototype */
+/* ---
+ * Basic functions.
+ * --- */
+
+/* Serial interrupt handler prototype. */
+
typedef void* __sinth_t _OF((void));
/* Open the serial port -- function behind the Comm_Open with no USB. */
@@ -78,9 +78,11 @@ _EXTERN void* Serial_CallTransmitIntErrorResetHandler
_OF((void)) _THROW;
_EXTERN void* Serial_CallTransmitIntHandler
_OF((void)) _THROW;
-/* ************************************************************************* */
-/* Raw communication utilities */
-/* ************************************************************************* */
+
+/* ---
+ * Raw communication utilities.
+ * --- */
+
/* Receive data. */
_EXTERN _NONNULL(2, __dest) int Serial_SpyByte
diff --git a/modules/casiowin/fxlib/include/fxlib/timer.h b/modules/casiowin/fxlib/bits/fxlib/timer.h
index e870254..f79669e 100644
--- a/modules/casiowin/fxlib/include/fxlib/timer.h
+++ b/modules/casiowin/fxlib/bits/fxlib/timer.h
@@ -28,16 +28,17 @@
* The fact that you are presently reading this means you have had knowledge of
* the CeCILL-C license and that you accept its terms.
* ************************************************************************* */
-#include <fxlib/cdefs.h>
-#include <timer.h>
_BEGIN_NAMESPACE_FXLIB
_BEGIN_DECLS
-/* Callback prototype */
+/* Callback prototype. */
+
typedef void __timer_callback_t _OF((void));
-/* ************************************************************************* */
-/* SDK interface */
-/* ************************************************************************* */
+
+/* ---
+ * SDK interface.
+ * --- */
+
/* Set a timer. */
_EXTERN int SetTimer
@@ -48,9 +49,11 @@ _EXTERN int KillTimer
/* sleep for some time */
_EXTERN void Sleep
_OF((int __ms)) _THROW;
-/* ************************************************************************* */
-/* Syscalls */
-/* ************************************************************************* */
+
+/* ---
+ * Syscalls.
+ * --- */
+
#if _USE_FXLIB_UNOFFICIAL
/* Basic things. */
diff --git a/modules/casiowin/fxlib/copyright.yml b/modules/casiowin/fxlib/copyright.yml
index 94e925f..ce52c6a 100644
--- a/modules/casiowin/fxlib/copyright.yml
+++ b/modules/casiowin/fxlib/copyright.yml
@@ -2,4 +2,4 @@
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/casiowin/fxlib/docs/char.en.md b/modules/casiowin/fxlib/docs/char.en.rst
index b6e7600..033a0df 100644
--- a/modules/casiowin/fxlib/docs/char.en.md
+++ b/modules/casiowin/fxlib/docs/char.en.rst
@@ -1,6 +1,6 @@
----
-title: Character encoding
----
+Character encoding
+==================
+
CASIOWIN uses a proprietary 16-bit character encoding for everything:
displaying text on the screen, naming files and folders, etc.
It has been named "FONTCHARACTER" by the community, because of the name of
@@ -20,11 +20,11 @@ the leader characters were 0x7F, 0xF7, 0xF9, 0xE5, 0xE6 and 0xE7.
For example, "ΔList " (Δ is character 0xE543 in FONTCHARACTER) is expressed:
- in the fixed-width encoding:
- `E5 43 00 4C 00 69 00 73 00 74 00 20 00 00`
+ ``E5 43 00 4C 00 69 00 73 00 74 00 20 00 00``
- in the multibyte encoding:
- `E5 43 4C 69 73 74 20 00`
+ ``E5 43 4C 69 73 74 20 00``
-The FONTCHARACTER codepoints and history is documented in
-[the FONTCHARACTER reference][refc].
+The FONTCHARACTER codepoints and history is documented in the
+`FONTCHARACTER reference`_.
-[refc]: https://github.com/PlaneteCasio/fontcharacter_reference
+.. _FONTCHARACTER reference: https://github.com/PlaneteCasio/fontcharacter_reference
diff --git a/modules/casiowin/fxlib/docs/clock.en.md b/modules/casiowin/fxlib/docs/clock.en.rst
index 114ab8d..5f463ba 100644
--- a/modules/casiowin/fxlib/docs/clock.en.md
+++ b/modules/casiowin/fxlib/docs/clock.en.rst
@@ -1,6 +1,6 @@
----
-title: Managing the clock
----
+Managing the clock
+==================
+
The fx-9860G series have a real-time clock (RTC) which you can't rely on to
give you the current time (as it is never set by the user, and because of
battery problems), but which you can use to time events.
diff --git a/modules/casiowin/fxlib/docs/comm.en.md b/modules/casiowin/fxlib/docs/comm.en.md
deleted file mode 100644
index 5f35a76..0000000
--- a/modules/casiowin/fxlib/docs/comm.en.md
+++ /dev/null
@@ -1,85 +0,0 @@
----
-title: Communicate with other devices
----
-{% warning %}
-This part of the fxlib is entirely non-official, and has been unraveled
-through reverse-engineering. The names are specific to the fxlib
-implementation (although some compatibility has been added with other
-libraries implementing these syscalls).
-{% endwarning %}
-
-The fx-9860G series can communicate through different ports: serial port,
-and USB port. There is an interface to communicate directly with the device
-on the other side (as a serial device), and an interface to communicate with
-the other device using Protocol 7.00, a proprietary protocol only used by
-the fx-9860G (and ulterior devices on the serial interface).
-
-The communication layer uses its own errors, the `IML_COMMERR_*` ones.
-There can only be **zero or one communications opened simultaneously**.
-
-# Opening and closing
-To open and close the communication, you can use the following functions:
-
-```c
-int Comm_Open(unsigned short flags);
-int Comm_Close(int imm);
-```
-
-The communication opening flags contain all of the information about the
-connexion:
-
-- if the connexion is valid: `COMM_FLAG_VALID` (mandatory);
-- if we should use the USB port: `COMM_FLAG_USB`;
-- if serial, the baud speed for the serial line:
-
- - `COMM_BAUD_9600` for 9600 bauds;
- - `COMM_BAUD_19200` for 19200 bauds;
- - `COMM_BAUD_38400` for 38400 bauds;
- - `COMM_BAUD_57600` for 57600 bauds;
- - `COMM_BAUD_115200` for 115200 bauds.
-- if serial, the bit parity:
-
- - `COMM_PARITY_NONE` if no parity;
- - `COMM_PARITY_EVEN` if even parity;
- - `COMM_PARITY_ODD` if odd parity.
-- if serial, the number of stop bits:
-
- - `COMM_FLAG_STOPB` if two stop bits;
- - nothing if only one.
-
-The default flags used for Protocol 7.00 on the serial line are:
-
- COMM_FLAG_VALID | COMM_BAUD_9600 | CASIO_PARITY_NONE | CASIO_FLAG_STOPB
-
-When ending a communication, the parameter means whether the communication
-should be ended directly (1) or when the buffered data is sent (0).
-
-When up, you can test if the current communication is on USB or not using:
-
-```c
-int Comm_IsUSB(void);
-```
-
-# Reading from the communication port
-There are three different functions for reading data from the communication
-port:
-
-```c
-int Comm_SpyByte(unsigned char *result);
-int Comm_ReadByte(unsigned char *result);
-int Comm_ReadBytes(char *buffer, int count);
-```
-
-`Comm_ReadByte()` and `Comm_ReadBytes()` read one or more bytes in the
-incoming buffer while popping them out of it.
-
-`Comm_SpyByte()` reads the next byte without popping it out of the incoming
-buffer.
-
-# Writing to the communication port
-There are two functions for transmitting data to the communication port:
-
-```c
-int Comm_SendByte(unsigned char byte);
-int Comm_SendBytes(unsigned char *buf, int count);
-```
diff --git a/modules/casiowin/fxlib/docs/comm.en.rst b/modules/casiowin/fxlib/docs/comm.en.rst
new file mode 100644
index 0000000..74d45b7
--- /dev/null
+++ b/modules/casiowin/fxlib/docs/comm.en.rst
@@ -0,0 +1,93 @@
+Communicate with other devices
+==============================
+
+.. warning::
+
+ This part of the fxlib is entirely non-official, and has been unraveled
+ through reverse-engineering. The names are specific to the fxlib
+ implementation (although some compatibility has been added with other
+ libraries implementing these syscalls).
+
+The fx-9860G series can communicate through different ports: serial port,
+and USB port. There is an interface to communicate directly with the device
+on the other side (as a serial device), and an interface to communicate with
+the other device using Protocol 7.00, a proprietary protocol only used by
+the fx-9860G (and ulterior devices on the serial interface).
+
+The communication layer uses its own errors, the ``IML_COMMERR_*`` ones.
+There can only be **zero or one communications opened simultaneously**.
+
+Opening and closing
+-------------------
+
+To open and close the communication, you can use the following functions:
+
+.. code-block:: c
+
+ int Comm_Open(unsigned short flags);
+ int Comm_Close(int imm);
+
+The communication opening flags contain all of the information about the
+connexion:
+
+- if the connexion is valid: ``COMM_FLAG_VALID`` (mandatory);
+- if we should use the USB port: ``COMM_FLAG_USB``;
+- if serial, the baud speed for the serial line:
+
+ - ``COMM_BAUD_9600`` for 9600 bauds;
+ - ``COMM_BAUD_19200`` for 19200 bauds;
+ - ``COMM_BAUD_38400`` for 38400 bauds;
+ - ``COMM_BAUD_57600`` for 57600 bauds;
+ - ``COMM_BAUD_115200`` for 115200 bauds.
+- if serial, the bit parity:
+
+ - ``COMM_PARITY_NONE`` if no parity;
+ - ``COMM_PARITY_EVEN`` if even parity;
+ - ``COMM_PARITY_ODD`` if odd parity.
+- if serial, the number of stop bits:
+
+ - ``COMM_FLAG_STOPB`` if two stop bits;
+ - nothing if only one.
+
+The default flags used for Protocol 7.00 on the serial line are:
+
+.. code-block:: c
+
+ COMM_FLAG_VALID | COMM_BAUD_9600 | CASIO_PARITY_NONE | CASIO_FLAG_STOPB
+
+When ending a communication, the parameter means whether the communication
+should be ended directly (1) or when the buffered data is sent (0).
+
+When up, you can test if the current communication is on USB or not using:
+
+.. code-block:: c
+
+ int Comm_IsUSB(void);
+
+Reading from the communication port
+-----------------------------------
+
+There are three different functions for reading data from the communication
+port:
+
+.. code-block:: c
+
+ int Comm_SpyByte(unsigned char *result);
+ int Comm_ReadByte(unsigned char *result);
+ int Comm_ReadBytes(char *buffer, int count);
+
+``Comm_ReadByte()`` and ``Comm_ReadBytes()`` read one or more bytes in the
+incoming buffer while popping them out of it.
+
+``Comm_SpyByte()`` reads the next byte without popping it out of the incoming
+buffer.
+
+Writing to the communication port
+---------------------------------
+
+There are two functions for transmitting data to the communication port:
+
+.. code-block:: c
+
+ int Comm_SendByte(unsigned char byte);
+ int Comm_SendBytes(unsigned char *buf, int count);
diff --git a/modules/casiowin/fxlib/docs/draw.en.md b/modules/casiowin/fxlib/docs/draw.en.md
deleted file mode 100644
index 00b4dba..0000000
--- a/modules/casiowin/fxlib/docs/draw.en.md
+++ /dev/null
@@ -1,301 +0,0 @@
----
-title: Drawing with fxlib
----
-On the fx-9860G, the screen is not made for a program to write directly on
-it, so the logical choice is to use double buffering to only write on the
-screen once the video memory is ready. Instead of doing this, the CASIO
-developers implemented the all three "write in VRAM",
-"write on the Display Driver" and "write on the two of them" versions of
-many drawing functions in the fxlib (not all).
-
-The versions that have different versions can usually be recognized by
-the `_DD` (Display Driver), `_VRAM` (Video memory) and `_DDVRAM` (both)
-suffixes. It is recommended to use the functions that use the VRAM only
-(`_VRAM`, `VRAM` or no suffix) for performance, although if you really
-want performance, you might want to check the
-[MonochromeLib]([casiowin/monochromelib]).
-
-# Get the content of the VRAM or display driver
-If you want to get the current content of the VRAM (which you can't access
-directly), or want to get the content of the screen, you can use these
-functions:
-
-```c
-void Bdisp_GetDisp_DD(unsigned char *data);
-void Bdisp_GetDisp_VRAM(unsigned char *data);
-```
-
-In the two cases, the `data` parameter should be pointing to a memory area
-containing at least `IM_VRAM_SIZE` (1024) bytes.
-
-The output format is a 128x64 1 bit per pixel monochrome image, organized
-per line and from left to right, where a '0' is white and a '1' is black.
-
-# Update the display
-When the VRAM is ready, you can update the screen with its content using
-the following function:
-
-```c
-void Bdisp_PutDisp_DD(void);
-```
-
-If you only want to update an area of the screen, even though it is not
-recommended, you can use the following function:
-
-```c
-void Bdisp_PutDispArea_DD(const DISPBOX *area);
-```
-
-The `DISPBOX` structure defines a rectangle using the upper-left and the
-lower-right corners, defined by their coordinates.
-It has the following properties, in that order:
-
-```c
-typedef struct {
- int left; /* upper-left x, 0 to 127 */
- int top; /* upper-left y, 0 to 63 */
- int right; /* lower-right x, 0 to 127 */
- int bottom; /* lower-right y, 0 to 63 */
-} DISPBOX;
-```
-
-# Read the display
-Although it is _not recommended_, you can read data from the VRAM or the
-screen, using one of these functions:
-
-```c
-void Bdisp_ReadArea_DD(const DISPBOX *area, unsigned char *data);
-void Bdisp_ReadArea_VRAM(const DISPBOX *area, unsigned char *data);
-```
-
-`area` is the rectangle coordinates, and has the previously described
-structure. `data` is the buffer.
-
-TODO: how is the data stored in the buffer exactly, in what conditions?
-This is not given by the manual...
-
-# Clear some pixels
-These functions turn all pixels on the VRAM/screen to white.
-
-```c
-void Bdisp_AllClr_DD(void);
-void Bdisp_AllClr_VRAM(void);
-void Bdisp_AllClr_DDVRAM(void);
-```
-
-If you only want to clear an area, you can use the following functions
-instead:
-
-```c
-void Bdisp_AreaClr_DD(const DISPBOX *area);
-void Bdisp_AreaClr_VRAM(const DISPBOX *area);
-void Bdisp_AreaClr_DDVRAM(const DISPBOX *area);
-```
-
-The `DISPBOX` was described previously.
-
-# Reverse pixels in an area
-This function turn all black pixels to white and white pixels to black in
-an area in the VRAM:
-
-```c
-void Bdisp_AreaReverseVRAM(int x1, int y1, int x2, int y2);
-```
-
-Notice that the name and the arguments follow a different logic to
-`Bdisp_AreaClr_VRAM` for example, but that the current prototype is maintained
-for compatibility.
-
-# Interact with pixels on the screen
-If you simply want to set the color of a pixel on the screen, you can
-use one of the following functions:
-
-```c
-void Bdisp_SetPoint_DD(int x, int y, unsigned char point);
-void Bdisp_SetPoint_VRAM(int x, int y, unsigned char point);
-void Bdisp_SetPoint_DDVRAM(int x, int y, unsigned char point);
-```
-
-`point` should be either 0 if the dot should be set to white, or 1 if it
-should be set to black.
-
-If you want to get the status of a pixel on the screen, you can use
-the following function:
-
-```c
-int Bdisp_GetPoint_VRAM(int x, int y);
-```
-
-This function returns 0 if the dot is white, or 1 if the dot is black.
-
-# Display a bitmap on the screen
-If you want to display a bitmap on the screen, you can use one of the
-following functions:
-
-```c
-void Bdisp_WriteGraph_DD(const DISPGRAPH *graph);
-void Bdisp_WriteGraph_VRAM(const DISPGRAPH *graph);
-void Bdisp_WriteGraph_DDVRAM(const DISPGRAPH *graph);
-```
-
-The `DISPGRAPH` is the set of coordinates, display style, and bitmap data.
-It has the following properties:
-
-```c
-typedef struct {
- int x; /* 0 to 127 */
- int y; /* 0 to 63 */
- GRAPHDATA GraphData;
- WRITEMODIFY WriteModify;
- WRITEKIND WriteKind;
-} DISPGRAPH;
-```
-
-`GRAPHDATA` represents bitmap data. It has the following properties:
-
-```c
-typedef struct {
- int width;
- int height;
- unsigned char *pBitmap;
-} GRAPHDATA;
-```
-
-`WRITEMODIFY` represents the write modification graphic. Any element of this
-type can have one of these values:
-
-- `IMB_WRITEMODIFY_NORMAL`: normal;
-- `IMB_WRITEMODIFY_REVERSE`: reverse;
-- `IMB_WRITEMODIFY_MESH`: half-tone dot meshing.
-
-`WRITEKIND` represents the kind of writing. Any element of this type can
-have one of these values:
-
-- `IMB_WRITEKIND_OVER`: overwrite (fill);
-- `IMB_WRITEKIND_OR`: OR;
-- `IMB_WRITEKIND_AND`: AND;
-- `IMB_WRITEKIND_XOR`: XOR.
-
-# Draw and clear a line on the screen
-To draw a line, the following function is provided:
-
-```c
-void Bdisp_DrawLineVRAM(int x1, int y1, int x2, int y2);
-```
-
-`x1` and `y1` being the coordinates of the line's starting point, and
-`x2` and `y2` being the coordinates of the line's ending point.
-
-If you want to draw a white line instead of a black line, use the following
-function:
-
-```c
-void Bdisp_ClearLineVRAM(int x1, int y1, int x2, int y2);
-```
-
-# Drawing text on the screen
-The character interface from fxlib uses a 21x8 character matrix (which is
-the same as in CASIO BASIC, although a line is added in the C interface).
-Notice that the character set used in CASIOWIN is **not ASCII** or any
-standard encoding, it is an encoding called "FONTCHARACTER" (see
-[Character encoding](char)). These functions use the multi-byte form of
-this encoding, which is partially ASCII-compatible, that's why some ASCII
-characters are actually correctly displayed (such as the basic latin alphabet,
-ponctuation, and others).
-
-This character interface uses a cursor that most functions will use as a
-starting point, and move accordingly. There is no 'default' value for the
-cursor, so update the cursor before using it for the first time.
-To update the position of this cursor, you can use the following function:
-
-```c
-void locate(int col, int row);
-```
-
-Notice that the grid coordinates don't start from 0, but 1. So it goes from
-1 to 21 for the column, and from 1 to 8 for the row.
-
-Once the cursor is located where you want the string to start, use one of the
-following functions to print a multi-byte FONTCHARACTER string:
-
-```c
-void Print(const unsigned char *str);
-void PrintRev(const unsigned char *str);
-void PrintC(const unsigned char *c);
-void PrintRevC(const unsigned char *c);
-```
-
-The `Print`/`PrintRev` functions take strings, print them and move the cursor
-to the character directly at the right of the string. It the end of line is
-reached, the function **does not** jump to the next line (so the string will
-only be partially printed). You have to `locate()` to jump to the next line.
-
-The `Rev` versions of the functions prints the character in reversed color.
-The `C` versions are weird, as the official documentation basically says
-they take a one-character string, multi-byte encoded (so I can't explain
-what the difference is exactly with `Print`).
-
-If you want to print a line, you can use one of the following functions:
-
-```c
-void PrintLine(const unsigned char *str, int max);
-void PrintRLine(const unsigned char *str, int max);
-```
-
-It displays a character string (the 'R' version prints it in reversed color)
-from the current cursor position to the specified ending x position.
-If the character string ends before the ending position, the space up to
-the specified position is padded with blanks.
-
-If you don't want to use the cursor, or want to print characters out of the
-matrix positions, you can use this function directly:
-
-```c
-void PrintXY(int x, int y, const unsigned char *str, int type);
-```
-
-Where the `x` and `y` parameters are the screen coordinates (x going from
-0 to 127, y going from 0 to 63), `str` being the multi-byte FONTCHARACTER
-string, and `type` being either 0 for normal color, or 1 for reverse
-color.
-
-There is an equivalent of this for the 'mini' font (smaller):
-
-```c
-void PrintMini(int x, int y, const unsigned char *str, int type);
-```
-
-But the `type` field doesn't have the same value, as it must be one of these:
-
-- `MINI_OVER`: overwrite (fill);
-- `MINI_OR`: OR;
-- `MINI_REV`: overwrite in reverse color;
-- `MINI_REVOR`: OR in reverse color.
-
-Also, be careful, not all displayable FONTCHARACTER characters have an
-equivalent in the 'mini' font!
-
-# Saving and restoring displays
-It is possible to save and recall screen images using the system, with the
-following functions:
-
-```c
-void SaveDisp(unsigned char num);
-void RestoreDisp(unsigned char num);
-```
-
-The display number can be one of `SAVEDISP_PAGE1`, `SAVEDISP_PAGE2` or
-`SAVEDISP_PAGE3`. These functions only interact with the VRAM, so once
-you've restored a display, you shall use `Bdisp_PutDisp_DD()` to update
-the screen with the restored image.
-
-# Make a pop-up window
-This function makes a pop-up window, appropriate for the use of the character
-matrix (see "Drawing text on the screen"). It has the following prototype:
-
-```c
-void PopUpWin(int number_of_lines);
-```
-
-The parameter is the number of lines you want to have in the pop-up,
-between 1 and 5.
diff --git a/modules/casiowin/fxlib/docs/draw.en.rst b/modules/casiowin/fxlib/docs/draw.en.rst
new file mode 100644
index 0000000..80a5ad2
--- /dev/null
+++ b/modules/casiowin/fxlib/docs/draw.en.rst
@@ -0,0 +1,323 @@
+Drawing with fxlib
+==================
+
+On the fx-9860G, the screen is not made for a program to write directly on
+it, so the logical choice is to use double buffering to only write on the
+screen once the video memory is ready. Instead of doing this, the CASIO
+developers implemented the all three "write in VRAM",
+"write on the Display Driver" and "write on the two of them" versions of
+many drawing functions in the fxlib (not all).
+
+The versions that have different versions can usually be recognized by
+the ``_DD`` (Display Driver), ``_VRAM`` (Video memory) and ``_DDVRAM`` (both)
+suffixes. It is recommended to use the functions that use the VRAM only
+(``_VRAM``, ``VRAM`` or no suffix) for performance, although if you really
+want performance, you might want to check :ref:`../monochromelib`.
+
+Get the content of the VRAM or display driver
+---------------------------------------------
+
+If you want to get the current content of the VRAM (which you can't access
+directly), or want to get the content of the screen, you can use these
+functions:
+
+.. code-block:: c
+
+ void Bdisp_GetDisp_DD(unsigned char *data);
+ void Bdisp_GetDisp_VRAM(unsigned char *data);
+
+In the two cases, the ``data`` parameter should be pointing to a memory area
+containing at least ``IM_VRAM_SIZE`` (1024) bytes.
+
+The output format is a 128x64 1 bit per pixel monochrome image, organized
+per line and from left to right, where a '0' is white and a '1' is black.
+
+Update the display
+------------------
+
+When the VRAM is ready, you can update the screen with its content using
+the following function:
+
+.. code-block:: c
+
+ void Bdisp_PutDisp_DD(void);
+
+If you only want to update an area of the screen, even though it is not
+recommended, you can use the following function:
+
+.. code-block:: c
+
+ void Bdisp_PutDispArea_DD(const DISPBOX *area);
+
+The ``DISPBOX`` structure defines a rectangle using the upper-left and the
+lower-right corners, defined by their coordinates.
+It has the following properties, in that order:
+
+.. code-block:: c
+
+ typedef struct {
+ int left; /* upper-left x, 0 to 127 */
+ int top; /* upper-left y, 0 to 63 */
+ int right; /* lower-right x, 0 to 127 */
+ int bottom; /* lower-right y, 0 to 63 */
+ } DISPBOX;
+
+Read the display
+----------------
+
+Although it is *not recommended*, you can read data from the VRAM or the
+screen, using one of these functions:
+
+.. code-block:: c
+
+ void Bdisp_ReadArea_DD(const DISPBOX *area, unsigned char *data);
+ void Bdisp_ReadArea_VRAM(const DISPBOX *area, unsigned char *data);
+
+``area`` is the rectangle coordinates, and has the previously described
+structure. ``data`` is the buffer.
+
+TODO: how is the data stored in the buffer exactly, in what conditions?
+This is not given by the manual...
+
+Clear some pixels
+-----------------
+
+These functions turn all pixels on the VRAM/screen to white.
+
+.. code-block:: c
+
+ void Bdisp_AllClr_DD(void);
+ void Bdisp_AllClr_VRAM(void);
+ void Bdisp_AllClr_DDVRAM(void);
+
+If you only want to clear an area, you can use the following functions
+instead:
+
+.. code-block:: c
+
+ void Bdisp_AreaClr_DD(const DISPBOX *area);
+ void Bdisp_AreaClr_VRAM(const DISPBOX *area);
+ void Bdisp_AreaClr_DDVRAM(const DISPBOX *area);
+
+The ``DISPBOX`` was described previously.
+
+Reverse pixels in an area
+-------------------------
+
+This function turn all black pixels to white and white pixels to black in
+an area in the VRAM:
+
+.. code-block:: c
+
+ void Bdisp_AreaReverseVRAM(int x1, int y1, int x2, int y2);
+
+Notice that the name and the arguments follow a different logic to
+``Bdisp_AreaClr_VRAM`` for example, but that the current prototype is
+maintained for compatibility.
+
+Interact with pixels on the screen
+----------------------------------
+
+If you simply want to set the color of a pixel on the screen, you can
+use one of the following functions:
+
+.. code-block:: c
+
+ void Bdisp_SetPoint_DD(int x, int y, unsigned char point);
+ void Bdisp_SetPoint_VRAM(int x, int y, unsigned char point);
+ void Bdisp_SetPoint_DDVRAM(int x, int y, unsigned char point);
+
+``point`` should be either 0 if the dot should be set to white, or 1 if it
+should be set to black.
+
+If you want to get the status of a pixel on the screen, you can use
+the following function:
+
+.. code-block:: c
+
+ int Bdisp_GetPoint_VRAM(int x, int y);
+
+This function returns 0 if the dot is white, or 1 if the dot is black.
+
+Display a bitmap on the screen
+------------------------------
+
+If you want to display a bitmap on the screen, you can use one of the
+following functions:
+
+.. code-block:: c
+
+ void Bdisp_WriteGraph_DD(const DISPGRAPH *graph);
+ void Bdisp_WriteGraph_VRAM(const DISPGRAPH *graph);
+ void Bdisp_WriteGraph_DDVRAM(const DISPGRAPH *graph);
+
+The ``DISPGRAPH`` is the set of coordinates, display style, and bitmap data.
+It has the following properties:
+
+.. code-block:: c
+
+ typedef struct {
+ int x; /* 0 to 127 */
+ int y; /* 0 to 63 */
+ GRAPHDATA GraphData;
+ WRITEMODIFY WriteModify;
+ WRITEKIND WriteKind;
+ } DISPGRAPH;
+
+``GRAPHDATA`` represents bitmap data. It has the following properties:
+
+.. code-block:: c
+
+ typedef struct {
+ int width;
+ int height;
+ unsigned char *pBitmap;
+ } GRAPHDATA;
+
+``WRITEMODIFY`` represents the write modification graphic. Any element of this
+type can have one of these values:
+
+- ``IMB_WRITEMODIFY_NORMAL``: normal;
+- ``IMB_WRITEMODIFY_REVERSE``: reverse;
+- ``IMB_WRITEMODIFY_MESH``: half-tone dot meshing.
+
+``WRITEKIND`` represents the kind of writing. Any element of this type can
+have one of these values:
+
+- ``IMB_WRITEKIND_OVER``: overwrite (fill);
+- ``IMB_WRITEKIND_OR``: OR;
+- ``IMB_WRITEKIND_AND``: AND;
+- ``IMB_WRITEKIND_XOR``: XOR.
+
+Draw and clear a line on the screen
+-----------------------------------
+
+To draw a line, the following function is provided:
+
+.. code-block:: c
+
+ void Bdisp_DrawLineVRAM(int x1, int y1, int x2, int y2);
+
+With ``x1`` and ``y1`` being the coordinates of the line's starting point, and
+``x2`` and ``y2`` being the coordinates of the line's ending point.
+
+If you want to draw a white line instead of a black line, use the following
+function:
+
+.. code-block:: c
+
+ void Bdisp_ClearLineVRAM(int x1, int y1, int x2, int y2);
+
+Drawing text on the screen
+--------------------------
+
+The character interface from fxlib uses a 21x8 character matrix (which is
+the same as in CASIO BASIC, although a line is added in the C interface).
+Notice that the character set used in CASIOWIN is **not ASCII** or any
+standard encoding, it is an encoding called "FONTCHARACTER" (see
+[Character encoding](char)). These functions use the multi-byte form of
+this encoding, which is partially ASCII-compatible, that's why some ASCII
+characters are actually correctly displayed (such as the basic latin alphabet,
+ponctuation, and others).
+
+This character interface uses a cursor that most functions will use as a
+starting point, and move accordingly. There is no 'default' value for the
+cursor, so update the cursor before using it for the first time.
+To update the position of this cursor, you can use the following function:
+
+.. code-block:: c
+
+ void locate(int col, int row);
+
+Notice that the grid coordinates don't start from 0, but 1. So it goes from
+1 to 21 for the column, and from 1 to 8 for the row.
+
+Once the cursor is located where you want the string to start, use one of the
+following functions to print a multi-byte FONTCHARACTER string:
+
+.. code-block:: c
+
+ void Print(const unsigned char *str);
+ void PrintRev(const unsigned char *str);
+ void PrintC(const unsigned char *c);
+ void PrintRevC(const unsigned char *c);
+
+The ``Print``/``PrintRev`` functions take strings, print them and move the
+cursor to the character directly at the right of the string. It the end of
+line is reached, the function **does not** jump to the next line (so the
+string will only be partially printed). You have to `locate()` to jump to
+the next line.
+
+The ``Rev`` versions of the functions prints the character in reversed color.
+The ``C`` versions are weird, as the official documentation basically says
+they take a one-character string, multi-byte encoded (so I can't explain
+what the difference is exactly with ``Print``).
+
+If you want to print a line, you can use one of the following functions:
+
+.. code-block:: c
+
+ void PrintLine(const unsigned char *str, int max);
+ void PrintRLine(const unsigned char *str, int max);
+
+It displays a character string (the 'R' version prints it in reversed color)
+from the current cursor position to the specified ending x position.
+If the character string ends before the ending position, the space up to
+the specified position is padded with blanks.
+
+If you don't want to use the cursor, or want to print characters out of the
+matrix positions, you can use this function directly:
+
+.. code-block:: c
+
+ void PrintXY(int x, int y, const unsigned char *str, int type);
+
+Where the ``x`` and ``y`` parameters are the screen coordinates (x going from
+0 to 127, y going from 0 to 63), ``str`` being the multi-byte FONTCHARACTER
+string, and ``type`` being either 0 for normal color, or 1 for reverse
+color.
+
+There is an equivalent of this for the 'mini' font (smaller):
+
+.. code-block:: c
+
+ void PrintMini(int x, int y, const unsigned char *str, int type);
+
+But the ``type`` field doesn't have the same value, as it must be one of these:
+
+- ``MINI_OVER``: overwrite (fill);
+- ``MINI_OR``: OR;
+- ``MINI_REV``: overwrite in reverse color;
+- ``MINI_REVOR``: OR in reverse color.
+
+Also, be careful, not all displayable FONTCHARACTER characters have an
+equivalent in the 'mini' font!
+
+Saving and restoring displays
+-----------------------------
+
+It is possible to save and recall screen images using the system, with the
+following functions:
+
+.. code-block:: c
+
+ void SaveDisp(unsigned char num);
+ void RestoreDisp(unsigned char num);
+
+The display number can be one of ``SAVEDISP_PAGE1``, ``SAVEDISP_PAGE2`` or
+``SAVEDISP_PAGE3``. These functions only interact with the VRAM, so once
+you've restored a display, you shall use ``Bdisp_PutDisp_DD()`` to update
+the screen with the restored image.
+
+Make a pop-up window
+--------------------
+
+This function makes a pop-up window, appropriate for the use of the character
+matrix (see "Drawing text on the screen"). It has the following prototype:
+
+.. code-block:: c
+
+ void PopUpWin(int number_of_lines);
+
+The parameter is the number of lines you want to have in the pop-up,
+between 1 and 5.
diff --git a/modules/casiowin/fxlib/docs/file.en.md b/modules/casiowin/fxlib/docs/file.en.md
deleted file mode 100644
index eb2c067..0000000
--- a/modules/casiowin/fxlib/docs/file.en.md
+++ /dev/null
@@ -1,322 +0,0 @@
----
-title: Interacting with the filesystem.
----
-CASIOWIN has a filesystem that resembles the Windows one, with devices
-(one for the flash, and sometimes, one for the SD card). The file separator
-is the backslash `\` (you'll have to escape it in strings), and the character
-encoding is a proprietary one, the "FONTCHARACTER" (see
-[Character encoding](char)). The functions here will usually use the
-fixed-width FONTCHARACTER encoding.
-
-Paths are usually something like `\\dev0\folder\filename.ext`. Known devices
-are `fls0` (flash memory, up to 1.5 MiB when it's there), and `crd0`
-(memory card, up to 2 GiB). The system doesn't support deeper than one
-folder down (so `\\dev0\folder0\folder1\filename.ext` is an invalid path here).
-
-The Bfile interface also supports a very odd filesystem, which is the
-Main Memory (also named 'MCS' by the community). From your add-in's point of
-view, you can see it as some kind of RAM filesystem (made persistent by the
-system, as it is copied to the ROM when the calculator is turned off, and
-copied from the ROM when the calculator is turned on) with no folders and
-no extensions, case-sensitive, and limited to 64 KiB (not adapted for big
-data files or applications, only small data files).
-
-# Getting the amount of free space on a device
-To get the amount of free bytes on a device, use the following function:
-
-```c
-int Bfile_GetMediaFree(enum DEVICE_TYPE device, int *freebytes);
-```
-
-The device value can be one of:
-
-- `DEVICE_MAIN_MEMORY`: main memory;
-- `DEVICE_STORAGE`: storage memory (flash);
-- `DEVICE_SD_CARD`: SD card.
-
-If an error occurs, this function returns a negative value, which is one of
-the `IML_FILEERR_*` error codes. Otherwise, `freebytes` is filled with the
-requested amount, and 0 is returned.
-
-# Creating and deleting directories
-To create and delete directories, you can use the following functions:
-
-```c
-int Bfile_CreateDirectory(const FONTCHARACTER *path);
-int Bfile_DeleteDirectory(const FONTCHARACTER *path);
-```
-
-TODO: if there are files in a directory, does the deletion fail or deletes
-the files as well? (... or does something else?)
-
-# Creating and deleting files
-If you only want to create a file without setting its content, or at least
-for reserving space (and check if there is enough) to write to it afterwards,
-you can use the following function:
-
-```c
-int Bfile_CreateFile(const FONTCHARACTER *path, int size);
-```
-
-It returns a negative value if an error has occured (being one of the
-`IML_FILEERR_*` error codes), or 0 if everything went well.
-
-On the other side, if you want to delete files, you shall use the following
-function:
-
-```c
-int Bfile_DeleteFile(const FONTCHARACTER *path);
-```
-
-This function has the same return code logic as for the creating function.
-Of course, it is not recommended to delete a currently opened file.
-
-# Getting the size of a file
-In order to gather the size of a file, use the following function:
-
-```c
-int Bfile_GetFileSize(int handle);
-```
-
-If an error occurs, a negative value is returned, which is one of the
-`IML_FILEERR_*` error codes. Otherwise, the requested size is returned.
-
-# Creating, renaming and deleting main memory files
-To manage main memory files, you can use the following functions:
-
-```c
-int Bfile_CreateMainMemory(const unsigned char *name);
-int Bfile_RenameMainMemory(const unsigned char *old, const unsigned char *new);
-int Bfile_DeleteMainMemory(const unsigned char *name);
-```
-
-Each of these functions will return a negative value if an error occurs,
-which is one of the `IML_FILEERR_*` error codes, or 0 if everything went well.
-
-# Opening and closing a file descriptor
-File descriptors are actually integers. To open a file descriptor, use
-the following function:
-
-```c
-int Bfile_OpenFile(const FONTCHARACTER *path, int mode);
-```
-
-Where the open mode is among these ones:
-
-- `_OPENMODE_READ`: reading only;
-- `_OPENMODE_READ_SHARE`: reading only, denies read access to other processes;
-- `_OPENMODE_WRITE`: writing only;
-- `_OPENMODE_READWRITE`: reading and writing;
-- `_OPENMODE_READWRITE_SHARE`: exclusive mode, denying both read and write
- access to other processes.
-
-The return code, if negative, is one of the `IML_FILEERR_*` error codes,
-otherwise, the file descriptor.
-
-Once you are done with the file descriptor, you **must** close it using
-the following function:
-
-```c
-int Bfile_CloseFile(int handle);
-```
-
-Here's an example for reading and writing a save:
-
-```c
-static const FONTCHARACTER save_path = {
- '\\', '\\', 'f', 'l', 's', '0', '\\',
- 'g', 'a', 'm', 'e', 's', 'a', 'v', 'e', '.', 's', 'a', 'v', 0};
-struct save {
- int magic;
- int lives;
- int power;
-};
-
-int read_save(struct save *save)
-{
- int ret = 0;
- int handle, err;
-
- /* Open the file. */
- handle = Bfile_OpenFile(save_path, _OPENMODE_READ);
- if (handle < 0) {
- /* Here, you can check the error, and do things. */
- return (1);
- }
-
- /* Read the content. */
- err = Bfile_ReadFile(handle, save, sizeof(*save), -1);
- if (err < sizeof(*save))
- ret = 1;
-
- /* Close the file and return. */
- Bfile_CloseFile(handle);
- return (ret);
-}
-
-int write_save(const struct save *save)
-{
- int ret = 0;
- int handle, err;
-
- /* Open the file. */
- handle = Bfile_OpenFile(save_path, _OPENMODE_WRITE);
- if (handle < 0) {
- /* Here you can check the error, and do things. */
- return (1);
- }
-
- /* Write the content. */
- err = Bfile_WriteFile(handle, save, sizeof(*save));
- if (err < sizeof(*save)) {
- /* `Bfile_WriteFile()` doesn't return the number of written bytes,
- * but the current position in the file. If everything was written
- * correctly, we should be at 0 (initial position) + sizeof(*save),
- * so this test works only in this situation :) */
-
- ret = 1;
- }
-
- /* Close the file and return. */
- Bfile_CloseFile(handle);
- return (ret);
-}
-```
-
-# Opening a file in the main memory
-Opening a Bfile handle for the main memory is different than for
-"normal files", so it requires a special function, which is the following:
-
-```c
-int Bfile_OpenMainMemory(const unsigned char *name);
-```
-
-Where the name is multi-byte FONTCHARACTER encoded, and limited to eight bytes.
-The return code is the same than for `Bfile_OpenFile()`.
-
-The handle is automatically opened for reading and writing (since it has
-almost no cost, as it is a RAM filesystem). You can read, write, seek and
-close it using the same functions as for 'normal' files.
-
-# Read data from a file
-To read from a file descriptor, you shall use the following function:
-
-```c
-int Bfile_ReadFile(int handle, void *buf, int size, int readpos);
-```
-
-The read position is the point from where to read the file. To read from
-the current position, set this value to -1. The cursor will be set to right
-after the current read.
-
-If this function fails, it returns a negative value which is the
-`IML_FILEERR_*` error code. Otherwise, it returns the number of bytes actually
-read. An EOF (End Of File) is indicated by the `IML_FILEERR_ENDOFFILE` error.
-
-# Write data to a file
-To write data to a file descriptor, use the following function:
-
-```c
-int Bfile_WriteFile(int handle, const void *buf, int size);
-```
-
-Same as before, except you can only write from the current position.
-If an error has occured, returns a negative value which is the
-`IML_FILEERR_*` error code, otherwise, it returns the position indicated
-by the file pointer (and **NOT** the number of written bytes, for some reason).
-
-# Move the file cursor
-To move the file cursor, use the following function:
-
-```c
-int Bfile_SeekFile(int handle, int pos);
-```
-
-If an error has occured, returns a negative value which is the
-`IML_FILEERR_*` error code, otherwise, it returns the number of bytes that
-can continuously be read (TODO: check this).
-
-# Listing files in directories
-Finding file information in a directory is accomplished using these functions:
-
-```c
-int Bfile_FindFirst(const FONTCHARACTER *path, int *handle,
- FONTCHARACTER *found, FILE_INFO *file);
-int Bfile_FindNext(int handle, FONTCHARACTER *found, FILE_INFO *info);
-int Bfile_FindClose(int handle);
-```
-
-You first open a find handle by looking for the first entry in a directory,
-then look for all the others until there is none left, then
-**close the find handle** (this is important, many problems have
-occured because of people not closing their find handle...).
-As for the file descriptors, find handles are represented as integers.
-
-The `found` fixed-width FONTCHARACTER buffer should be at least 13 elements.
-The `FILE_INFO` structure contains the following elements:
-
-```c
-typedef struct {
- unsigned short id; /* file index */
- unsigned short type; /* file type (see below) */
- unsigned long filesize; /* file size */
- unsigned long datasize; /* data size (except the header) */
- unsigned int property; /* the file is still opened (0 if not) */
- unsigned long address; /* top address of the data (don't use this) */
-} FILE_INFO;
-```
-
-As you have probably guessed by now, the CASIOWIN filesystem preprocesses the
-files when they are saved, to check if the built-in applications will be
-able to use them or not. The file size/data size distinction is also because
-of that. Here are the possible file types (`type` field):
-
-- `DT_DIRECTORY`: directory;
-- `DT_FILE`: file of an unmanaged format;
-- `DT_ADDIN_APP`: add-in application (g1a);
-- `DT_EACT`: eActivity document (g1e/g2e);
-- `DT_LANGUAGE`: language file (g1l/g2l);
-- `DT_BITMAP`: bitmap file (g1n/g2n);
-- `DT_MAINMEM`: main memory data (g1m/g1r/g2m/g2r);
-- `DT_TEMP`: temporary data;
-- `DT_DOT`: current directory (".");
-- `DT_DOTDOT`: parent directory ("..");
-- `DT_VOLUME`: volume label.
-
-If `FindFirst` or `FindNext` return `IML_FILEERR_ENUMRATEEND`, then there is
-no more file to enumerate, and if one has been opened, you should close
-the find handle.
-
-Here's a function that lists the files in an unknown format of the
-root directory in the storage memory, using a callback that only
-takes the path:
-
-```c
-static FONTCHARACTER flash_root = {'\\', '\\', 'f', 'l', 's', '0', '\\'};
-
-void list_files(void (*callback)(const FONTCHARACTER *name))
-{
- FONTCHARACTER found[13] = {0}; /* initialized just in case */
- FILE_INFO found_info;
- int handle, err;
-
- /* First iteration, creation of the handle. */
- err = Bfile_FindFirst(flash_root, &handle, found, &found_info);
- if (err < 0)
- goto end;
- if (found_info.type == DT_FILE)
- (*callback)(found);
-
- /* Other iterations */
- while (Bfile_FindNext(handle, found, &found_info) >= 0)
- if (found_info.type == DT_FILE)
- (*callback)(found);
-
- /* Close the handle. */
- Bfile_FindClose(handle);
-
-end:
- /* Call the callback to tell we're done. */
- (*callback)(NULL);
-}
-```
diff --git a/modules/casiowin/fxlib/docs/file.en.rst b/modules/casiowin/fxlib/docs/file.en.rst
new file mode 100644
index 0000000..720d52d
--- /dev/null
+++ b/modules/casiowin/fxlib/docs/file.en.rst
@@ -0,0 +1,357 @@
+Interacting with the filesystem
+===============================
+
+CASIOWIN has a filesystem that resembles the Windows one, with devices
+(one for the flash, and sometimes, one for the SD card). The file separator
+is the backslash ``\`` (you'll have to escape it in strings), and the
+character encoding is a proprietary one, the "FONTCHARACTER" (see
+:ref:`char`). The functions here will usually use the fixed-width
+FONTCHARACTER encoding.
+
+Paths are usually something like ``\\dev0\folder\filename.ext``. Known devices
+are ``fls0`` (flash memory, up to 1.5 MiB when it's there), and ``crd0``
+(memory card, up to 2 GiB). The system doesn't support deeper than one
+folder down (so ``\\dev0\folder0\folder1\filename.ext`` is an invalid path
+here).
+
+The Bfile interface also supports a very odd filesystem, which is the
+Main Memory (also named 'MCS' by the community). From your add-in's point of
+view, you can see it as some kind of RAM filesystem (made persistent by the
+system, as it is copied to the ROM when the calculator is turned off, and
+copied from the ROM when the calculator is turned on) with no folders and
+no extensions, case-sensitive, and limited to 64 KiB (not adapted for big
+data files or applications, only small data files).
+
+Getting the amount of free space on a device
+--------------------------------------------
+
+To get the amount of free bytes on a device, use the following function:
+
+.. code-block:: c
+
+ int Bfile_GetMediaFree(enum DEVICE_TYPE device, int *freebytes);
+
+The device value can be one of:
+
+- ``DEVICE_MAIN_MEMORY``: main memory;
+- ``DEVICE_STORAGE``: storage memory (flash);
+- ``DEVICE_SD_CARD``: SD card.
+
+If an error occurs, this function returns a negative value, which is one of
+the ``IML_FILEERR_*`` error codes. Otherwise, ``freebytes`` is filled with the
+requested amount, and 0 is returned.
+
+Creating and deleting directories
+---------------------------------
+
+To create and delete directories, you can use the following functions:
+
+.. code-block:: c
+
+ int Bfile_CreateDirectory(const FONTCHARACTER *path);
+ int Bfile_DeleteDirectory(const FONTCHARACTER *path);
+
+In the case of ``Bfile_DeleteDirectory()``, if the directory contained files,
+they will be deleted as well.
+
+Creating and deleting files
+---------------------------
+
+If you only want to create a file without setting its content, or at least
+for reserving space (and check if there is enough) to write to it afterwards,
+you can use the following function:
+
+.. code-block:: c
+
+ int Bfile_CreateFile(const FONTCHARACTER *path, int size);
+
+It returns a negative value if an error has occured (being one of the
+``IML_FILEERR_*`` error codes), or 0 if everything went well.
+
+On the other side, if you want to delete files, you shall use the following
+function:
+
+.. code-block:: c
+
+ int Bfile_DeleteFile(const FONTCHARACTER *path);
+
+This function has the same return code logic as for the creating function.
+Of course, it is not recommended to delete a currently opened file.
+
+Getting the size of a file
+--------------------------
+
+In order to gather the size of a file, use the following function:
+
+.. code-block:: c
+
+ int Bfile_GetFileSize(int handle);
+
+If an error occurs, a negative value is returned, which is one of the
+``IML_FILEERR_*`` error codes. Otherwise, the requested size is returned.
+
+Creating, renaming and deleting main memory files
+-------------------------------------------------
+
+To manage main memory files, you can use the following functions:
+
+.. code-block:: c
+
+ int Bfile_CreateMainMemory(const unsigned char *name);
+ int Bfile_RenameMainMemory(const unsigned char *old,
+ const unsigned char *new);
+ int Bfile_DeleteMainMemory(const unsigned char *name);
+
+Each of these functions will return a negative value if an error occurs,
+which is one of the ``IML_FILEERR_*`` error codes, or 0 if everything
+went well.
+
+Opening and closing a file descriptor
+-------------------------------------
+
+File descriptors are actually integers. To open a file descriptor, use
+the following function:
+
+.. code-block:: c
+
+ int Bfile_OpenFile(const FONTCHARACTER *path, int mode);
+
+Where the open mode is among these ones:
+
+- ``_OPENMODE_READ``: reading only;
+- ``_OPENMODE_READ_SHARE``: reading only, denies read access to
+ other processes;
+- ``_OPENMODE_WRITE``: writing only;
+- ``_OPENMODE_READWRITE``: reading and writing;
+- ``_OPENMODE_READWRITE_SHARE``: exclusive mode, denying both read and write
+ access to other processes.
+
+The return code, if negative, is one of the ``IML_FILEERR_*`` error codes,
+otherwise, the file descriptor.
+
+Once you are done with the file descriptor, you **must** close it using
+the following function:
+
+.. code-block:: c
+
+ int Bfile_CloseFile(int handle);
+
+Here's an example for reading and writing a save:
+
+.. code-block:: c
+
+ static const FONTCHARACTER save_path = {
+ '\\', '\\', 'f', 'l', 's', '0', '\\',
+ 'g', 'a', 'm', 'e', 's', 'a', 'v', 'e', '.', 's', 'a', 'v', 0};
+
+ struct save {
+ int magic;
+ int lives;
+ int power;
+ };
+
+ int read_save(struct save *save)
+ {
+ int ret = 0;
+ int handle, err;
+
+ /* Open the file. */
+
+ handle = Bfile_OpenFile(save_path, _OPENMODE_READ);
+ if (handle < 0) {
+ /* Here, you can check the error, and do things. */
+
+ return (1);
+ }
+
+ /* Read the content. */
+
+ err = Bfile_ReadFile(handle, save, sizeof(*save), -1);
+ if (err < sizeof(*save))
+ ret = 1;
+
+ /* Close the file and return. */
+
+ Bfile_CloseFile(handle);
+ return (ret);
+ }
+
+ int write_save(const struct save *save)
+ {
+ int ret = 0;
+ int handle, err;
+
+ /* Open the file. */
+
+ handle = Bfile_OpenFile(save_path, _OPENMODE_WRITE);
+ if (handle < 0) {
+ /* Here you can check the error, and do things. */
+ return (1);
+ }
+
+ /* Write the content. */
+
+ err = Bfile_WriteFile(handle, save, sizeof(*save));
+ if (err < sizeof(*save)) {
+ /* `Bfile_WriteFile()` doesn't return the number of written bytes,
+ * but the current position in the file. If everything was written
+ * correctly, we should be at 0 (initial position) + sizeof(*save),
+ * so this test works only in this situation :) */
+
+ ret = 1;
+ }
+
+ /* Close the file and return. */
+
+ Bfile_CloseFile(handle);
+ return (ret);
+ }
+
+Opening a file in the main memory
+---------------------------------
+
+Opening a Bfile handle for the main memory is different than for
+"normal files", so it requires a special function, which is the following:
+
+.. code-block:: c
+
+ int Bfile_OpenMainMemory(const unsigned char *name);
+
+Where the name is multi-byte FONTCHARACTER encoded, and limited to eight bytes.
+The return code is the same than for ``Bfile_OpenFile()``.
+
+The handle is automatically opened for reading and writing (since it has
+almost no cost, as it is a RAM filesystem). You can read, write, seek and
+close it using the same functions as for 'normal' files.
+
+Read data from a file
+---------------------
+
+To read from a file descriptor, you shall use the following function:
+
+.. code-block:: c
+
+ int Bfile_ReadFile(int handle, void *buf, int size, int readpos);
+
+The read position is the point from where to read the file. To read from
+the current position, set this value to -1. The cursor will be set to right
+after the current read.
+
+If this function fails, it returns a negative value which is the
+``IML_FILEERR_*`` error code. Otherwise, it returns the number of bytes
+actually read. An EOF (End Of File) is indicated by the
+``IML_FILEERR_ENDOFFILE`` error.
+
+Write data to a file
+--------------------
+
+To write data to a file descriptor, use the following function:
+
+.. code-block:: c
+
+ int Bfile_WriteFile(int handle, const void *buf, int size);
+
+Same as before, except you can only write from the current position.
+If an error has occured, returns a negative value which is the
+``IML_FILEERR_*`` error code, otherwise, it returns the position indicated
+by the file pointer (and **NOT** the number of written bytes, for some reason).
+
+Move the file cursor
+--------------------
+
+To move the file cursor, use the following function:
+
+.. code-block:: c
+
+ int Bfile_SeekFile(int handle, int pos);
+
+If an error has occured, returns a negative value which is the
+``IML_FILEERR_*`` error code, otherwise, it returns the number of bytes that
+can continuously be read (TODO: check this).
+
+Listing files in directories
+----------------------------
+
+Finding file information in a directory is accomplished using these functions:
+
+.. code-block:: c
+
+ int Bfile_FindFirst(const FONTCHARACTER *path, int *handle,
+ FONTCHARACTER *found, FILE_INFO *file);
+ int Bfile_FindNext(int handle, FONTCHARACTER *found, FILE_INFO *info);
+ int Bfile_FindClose(int handle);
+
+You first open a find handle by looking for the first entry in a directory,
+then look for all the others until there is none left, then
+**close the find handle** (this is important, many problems have
+occured because of people not closing their find handle...).
+As for the file descriptors, find handles are represented as integers.
+
+The ``found`` fixed-width FONTCHARACTER buffer should be at least 13 elements.
+The ``FILE_INFO`` structure contains the following elements:
+
+.. code-block:: c
+
+ typedef struct {
+ unsigned short id; /* file index */
+ unsigned short type; /* file type (see below) */
+ unsigned long filesize; /* file size */
+ unsigned long datasize; /* data size (except the header) */
+ unsigned int property; /* the file is still opened (0 if not) */
+ unsigned long address; /* top address of the data (don't use this) */
+ } FILE_INFO;
+
+As you have probably guessed by now, the CASIOWIN filesystem preprocesses the
+files when they are saved, to check if the built-in applications will be
+able to use them or not. The file size/data size distinction is also because
+of that. Here are the possible file types (``type`` field):
+
+- ``DT_DIRECTORY``: directory;
+- ``DT_FILE``: file of an unmanaged format;
+- ``DT_ADDIN_APP``: add-in application (g1a);
+- ``DT_EACT``: eActivity document (g1e/g2e);
+- ``DT_LANGUAGE``: language file (g1l/g2l);
+- ``DT_BITMAP``: bitmap file (g1n/g2n);
+- ``DT_MAINMEM``: main memory data (g1m/g1r/g2m/g2r);
+- ``DT_TEMP``: temporary data;
+- ``DT_DOT``: current directory (".");
+- ``DT_DOTDOT``: parent directory ("..");
+- ``DT_VOLUME``: volume label.
+
+If ``FindFirst`` or ``FindNext`` return ``IML_FILEERR_ENUMRATEEND``, then
+there is no more file to enumerate, and if one has been opened, you should
+close the find handle.
+
+Here's a function that lists the files in an unknown format of the
+root directory in the storage memory, using a callback that only
+takes the path:
+
+.. code-block:: c
+
+ static FONTCHARACTER flash_root = {'\\', '\\', 'f', 'l', 's', '0', '\\'};
+
+ void list_files(void (*callback)(const FONTCHARACTER *name))
+ {
+ FONTCHARACTER found[13] = {0}; /* initialized just in case */
+ FILE_INFO found_info;
+ int handle, err;
+
+ /* First iteration, creation of the handle. */
+ err = Bfile_FindFirst(flash_root, &handle, found, &found_info);
+ if (err < 0)
+ goto end;
+ if (found_info.type == DT_FILE)
+ (*callback)(found);
+
+ /* Other iterations */
+ while (Bfile_FindNext(handle, found, &found_info) >= 0)
+ if (found_info.type == DT_FILE)
+ (*callback)(found);
+
+ /* Close the handle. */
+ Bfile_FindClose(handle);
+
+ end:
+ /* Call the callback to tell we're done. */
+ (*callback)(NULL);
+ }
diff --git a/modules/casiowin/fxlib/docs/index.en.md b/modules/casiowin/fxlib/docs/index.en.rst
index 1e217e4..3494191 100644
--- a/modules/casiowin/fxlib/docs/index.en.md
+++ b/modules/casiowin/fxlib/docs/index.en.rst
@@ -1,28 +1,31 @@
----
-title: CASIO fx-9860G Library
-chapters:
-- draw
-- file
-- keys
-- clock
-- timer
-- comm
----
+CASIO fx-9860G Library
+======================
+
+.. chapters::
+ draw
+ file
+ keys
+ clock
+ timer
+ comm
+
In 2006, CASIO released a SDK for the fx-9860G series' calculators.
This SDK included a graphical application, an emulator, a compiler
(Hitachi's SHC), an assembler (Hitachi's Asmsh), Hitachi's libc,
and some headers and functions specific to the fx-9860G, called by the
name of the main header of it, fxlib.
-This module not only re-implements the "official" headers and functions
+This module not only re-implements the “official” headers and functions
as found in the fx-9860G SDK from 2006, but also adds the various syscalls
that have been discovered and documented through reverse-engineering and
some experimenting.
To use the functions and other definitions in the fxlib, please
-`#include <fxlib.h>`.
+``#include <fxlib.h>``.
+
+Technical note: about syscalls
+------------------------------
-### Technical notes: about syscalls
Many of the functions that are considered a part of it are actually "syscalls"
or simple wrapper around "syscalls". "Syscalls" in the case of CASIOWIN
is a language abuse that is common among the community, as everything is
@@ -33,16 +36,16 @@ CASIOWIN block at the beginning of the OS (at <flash> + 0x10070).
Here's a syscall example using the GNU assembler syntax:
-```gnu-asm
-.section .text
-.global _sys_call
-.type _sys_call, @function
-.align 2
-_sys_call:
- mov.l 1f, r2
- mov.l 2f, r0
- jsr @r2
- nop ; delayed branch
-1: .long 0x80010070
-2: .long <syscall no.>
-```
+.. code-block:: gnu-asm
+
+ .section .text
+ .global _sys_call
+ .type _sys_call, @function
+ .align 2
+ _sys_call:
+ mov.l 1f, r2
+ mov.l 2f, r0
+ jsr @r2
+ nop ; delayed branch
+ 1: .long 0x80010070
+ 2: .long <syscall no.>
diff --git a/modules/casiowin/fxlib/docs/keys.en.md b/modules/casiowin/fxlib/docs/keys.en.rst
index 9b53f70..e972955 100644
--- a/modules/casiowin/fxlib/docs/keys.en.md
+++ b/modules/casiowin/fxlib/docs/keys.en.rst
@@ -1,6 +1,6 @@
----
-title: Managing the keyboard with fxlib
----
+Managing the keyboard with fxlib
+================================
+
fxlib has a few functions to manage the keyboard, and get the pressed keys.
It distinguishes two different type of keys:
@@ -8,34 +8,38 @@ It distinguishes two different type of keys:
- the control keys, which don't.
Interestingly enough, the character keys codes correspond to the FONTCHARACTER
-codes they should generate. All keycodes are defined in `<keybios.h>`.
+codes they should generate. All keycodes are defined in ``<keybios.h>``.
+
+Repeating the cursor key
+------------------------
-# Repeating the cursor key
Arrow keys (named 'cursor key' by CASIO, and 'Replay' by the community)
can be repeated if pressed continuously, using system functions.
There is a first count (how long before the first repetition occurs),
and a next count (how long between repetitions).
Here are the function to manage these intervals:
-```c
-void Bkey_Set_RepeatTime_Default(void);
-void Bkey_Set_RepeatTime(long first_count, long next_count);
-void Bkey_Get_RepeatTime(long *first_count, long *next_count);
-```
+.. code-block:: c
+
+ void Bkey_Set_RepeatTime_Default(void);
+ void Bkey_Set_RepeatTime(long first_count, long next_count);
+ void Bkey_Get_RepeatTime(long *first_count, long *next_count);
The delays are in milliseconds divided by 25 (basically, the count of
40 milliseconds spans). Notice that this will **only** work with
the arrow keys.
-The defaults (which can be restored using `Bkey_SetRepeatTime_Default()`)
+The defaults (which can be restored using ``Bkey_SetRepeatTime_Default()``)
are 500 milliseconds for the first count and 125 between repetitions.
-# Get pressed keys
+Get pressed keys
+----------------
+
The main function to get a key is the following:
-```c
-int GetKey(unsigned int *keycode);
-```
+.. code-block:: c
+
+ int GetKey(unsigned int *keycode);
This function is blocking (waits for a key press event to happen). The 'menu'
key is processed by the system (to return to the menu), as the power off
@@ -49,43 +53,45 @@ still the proper way of doing it.
For a greater control over gathering keyboard events, you should use the
following function:
-```c
-int GetKeyWait(int sel, int time, int menu, unsigned int *keycode);
-```
+.. code-block:: c
+
+ int GetKeyWait(int sel, int time, int menu, unsigned int *keycode);
-The `sel` parameter is the type of waiting. Their behaviour change when
+The ``sel`` parameter is the type of waiting. Their behaviour change when
there is no new event in the key event buffer:
-- `KEYWAIT_HALTON_TIMEROFF`: wait until a key event arrives;
-- `KEYWAIT_HALTOFF_TIMEROFF`: return immediately;
-- `KEYWAIT_HALTON_TIMERON`: if no key is pressed within the time specified
- by the `time` parameter, this function times out.
+- ``KEYWAIT_HALTON_TIMEROFF``: wait until a key event arrives;
+- ``KEYWAIT_HALTOFF_TIMEROFF``: return immediately;
+- ``KEYWAIT_HALTON_TIMERON``: if no key is pressed within the time specified
+ by the ``time`` parameter, this function times out.
-If the `KEYWAIT_HALTON_TIMERON` (third possibility) type of waiting is
-selected, the `time` parameter should be the time out period in seconds.
+If the ``KEYWAIT_HALTON_TIMERON`` (third possibility) type of waiting is
+selected, the ``time`` parameter should be the time out period in seconds.
-The `menu` parameter depends on if you want the system to return to the menu
+The ``menu`` parameter depends on if you want the system to return to the menu
when the menu key is pressed (0), or if you want it to be returned to you (1).
The function returns one of these three event codes:
-- `KEYREP_NOEVENT` (only with the `KEYWAIT_HALTOFF_TIMEROFF` waiting type):
+- ``KEYREP_NOEVENT`` (only with the ``KEYWAIT_HALTOFF_TIMEROFF`` waiting type):
there were no key presses, the function returned immediately;
-- `KEYREP_KEYEVENT`: a key was pressed, and its code is in `keycode`;
-- `KEYREP_TIMEREVENT`: the function has timed out.
+- ``KEYREP_KEYEVENT``: a key was pressed, and its code is in ``keycode``;
+- ``KEYREP_TIMEREVENT``: the function has timed out.
+
+Check if a key is pressed
+-------------------------
-# Check if a key is pressed
If you simply want to check if a key is pressed/released, you can use one
of these two functions:
-```c
-int IsKeyDown(int keycode);
-int IsKeyUp(int keycode);
-```
+.. code-block:: c
+
+ int IsKeyDown(int keycode);
+ int IsKeyUp(int keycode);
-`IsKeyDown()` returns 1 if the key is pressed, and 0 if it is not the case.
-`IsKeyUp()` returns 1 if the key is released, and 0 if it is not the case.
+``IsKeyDown()`` returns 1 if the key is pressed, and 0 if it is not the case.
+``IsKeyUp()`` returns 1 if the key is released, and 0 if it is not the case.
Using this function is not recommended, as it means the calculator won't sleep,
so it will consume battery faster than when you use a blocking function,
-e.g. `GetKey()`.
+e.g. ``GetKey()``.
diff --git a/modules/casiowin/fxlib/docs/timer.en.md b/modules/casiowin/fxlib/docs/timer.en.rst
index 01805a7..99dae25 100644
--- a/modules/casiowin/fxlib/docs/timer.en.md
+++ b/modules/casiowin/fxlib/docs/timer.en.rst
@@ -1,30 +1,34 @@
----
-title: Timers
----
+Timers
+======
+
In CASIOWIN, there is no such thing as processes or threads. There are only
timers, which allow you to run tasks in a parallel fashion to the main thread.
-# Setting up a timer
+Setting up a timer
+------------------
+
In order to set up a timer, you will need to use the following function:
-```c
-int SetTimer(int id, int elapse, void (*handler)(void));
-```
+.. code-block:: c
+
+ int SetTimer(int id, int elapse, void (*handler)(void));
The ID is the timer identifier. You have access to five user timers:
-`ID_USER_TIMER1`, `ID_USER_TIMER2`, `ID_USER_TIMER3`, `ID_USER_TIMER4` and
-`ID_USER_TIMER5`.
+``ID_USER_TIMER1``, ``ID_USER_TIMER2``, ``ID_USER_TIMER3``,
+``ID_USER_TIMER4`` and ``ID_USER_TIMER5``.
-`elapse` is the time-out value, in numbers of 25 milliseconds lapses.
-`handler` is the function that will actually be called every `elapse`.
+``elapse`` is the time-out value, in numbers of 25 milliseconds lapses.
+``handler`` is the function that will actually be called every ``elapse``.
If this function returns a negative value, then the specified timer is in
use or the parameter is illegal. Otherwise, the timer identifier is returned.
-# Killing a timer
+Killing a timer
+---------------
+
You've had enough of your auxiliar threads? Then just kill your timer
using the following function:
-```c
-int KillTimer(int id);
-```
+.. code-block:: c
+
+ int KillTimer(int id);
diff --git a/modules/casiowin/fxlib/include/commbios.h b/modules/casiowin/fxlib/include/commbios.h
index 3a9a6c4..aa249f4 100644
--- a/modules/casiowin/fxlib/include/commbios.h
+++ b/modules/casiowin/fxlib/include/commbios.h
@@ -33,13 +33,20 @@
_BEGIN_NAMESPACE_FXLIB
_BEGIN_DECLS
-/* Flags, masks. */
+/* Flags, masks.
+ *
+ * `MASK_BAUD`: speed is stored in those bits.
+ * `MASK_PARITY`: parity is stored in those bits.
+ *
+ * `FLAG_STOPB`: two stop bits instead of one.
+ * `FLAG_USB`: use USB instead of serial.
+ * `FLAG_VALID`: base flags (to use systematically). */
-# define COMM_MASK_BAUD 0x0007 /* speed is stored in those bits */
-# define COMM_MASK_PARITY 0xC000 /* parity is stored in those bits */
-# define COMM_FLAG_STOPB 0x1000 /* two stop bits instead of one */
-# define COMM_FLAG_USB 0x0020 /* use USB instead of serial */
-# define COMM_FLAG_VALID 0x0010 /* base flags (use systematically) */
+# define COMM_MASK_BAUD 0x0007
+# define COMM_MASK_PARITY 0xC000
+# define COMM_FLAG_STOPB 0x1000
+# define COMM_FLAG_USB 0x0020
+# define COMM_FLAG_VALID 0x0010
/* Communication speeds. */
@@ -49,18 +56,27 @@ _BEGIN_DECLS
# define COMM_BAUD_57600 0x0003
# define COMM_BAUD_115200 0x0004
-/* Parity. */
+/* Parity.
+ *
+ * `NONE`: no parity.
+ * `EVEN`: even parity.
+ * `ODD`: odd parity. */
-# define COMM_PARITY_NONE 0x0000 /* no parity */
-# define COMM_PARITY_EVEN 0x4000 /* even parity */
-# define COMM_PARITY_ODD 0x8000 /* odd parity */
+# define COMM_PARITY_NONE 0x0000
+# define COMM_PARITY_EVEN 0x4000
+# define COMM_PARITY_ODD 0x8000
-/* Interrupt handler type. */
+/* Interrupt handler type.
+ *
+ * `RECEIVE`: receive callback.
+ * `TRANSMIT`: transmit callback.
+ * `RECEIVE_RESET`: ?
+ * `TRANSMIT_RESET`: ? */
-# define SERIAL_INTTYPE_RECEIVE 0x00 /* receive callback*/
-# define SERIAL_INTTYPE_TRANSMIT 0x01 /* transmit callback */
-# define SERIAL_INTTYPE_RECEIVE_RESET 0x02 /* ? */
-# define SERIAL_INTTYPE_TRANSMIT_RESET 0x03 /* ? */
+# define SERIAL_INTTYPE_RECEIVE 0x00
+# define SERIAL_INTTYPE_TRANSMIT 0x01
+# define SERIAL_INTTYPE_RECEIVE_RESET 0x02
+# define SERIAL_INTTYPE_TRANSMIT_RESET 0x03
/* Serial communication speeds. */
@@ -75,17 +91,27 @@ _BEGIN_DECLS
# define SERIAL_BAUD_57600 0x08
# define SERIAL_BAUD_115200 0x09
-/* Serial status flags. */
-
-# define SERIAL_STATUS_ER 0x0001 /* receive error */
-# define SERIAL_STATUS_TEND 0x0002 /* transmit end */
-# define SERIAL_STATUS_TDFE 0x0004 /* transmit FIFO data empty */
-# define SERIAL_STATUS_BRK 0x0008 /* break detected */
-# define SERIAL_STATUS_RDF 0x0010 /* received FIFO full */
-# define SERIAL_STATUS_DR 0x0020 /* received data ready */
-# define SERIAL_STATUS_ORER 0x0040 /* overrun error */
-# define SERIAL_STATUS_FER 0x1000 /* framing error */
-# define SERIAL_STATUS_PER 0x2000 /* parity error */
+/* Serial status flags.
+ *
+ * `ER`: receive error.
+ * `TEND`: transmit end.
+ * `TDFE`: transmit FIFO data empty.
+ * `BRK`: break detected.
+ * `RDF`: received FIFO full.
+ * `DR`: received data ready.
+ * `ORER`: overrun error.
+ * `FER`: framing error.
+ * `PER`: parity error. */
+
+# define SERIAL_STATUS_ER 0x0001
+# define SERIAL_STATUS_TEND 0x0002
+# define SERIAL_STATUS_TDFE 0x0004
+# define SERIAL_STATUS_BRK 0x0008
+# define SERIAL_STATUS_RDF 0x0010
+# define SERIAL_STATUS_DR 0x0020
+# define SERIAL_STATUS_ORER 0x0040
+# define SERIAL_STATUS_FER 0x1000
+# define SERIAL_STATUS_PER 0x2000
/* Protocol 7.00 packet structure. */
@@ -102,18 +128,29 @@ typedef struct tag_COMM_PACKET {
unsigned char checksum _DEPRECATED;
} COMM_PACKET;
-/* Communication errors. */
-
-# define IML_COMMERR_NOERROR 0 /* everything went great! */
-# define IML_COMMERR_UNKNOWN 1 /* something bad happened */
-# define IML_COMMERR_SERIAL 3 /* serial not open */
-# define IML_COMMERR_IO 5 /* comm not open */
-# define IML_COMMERR_TIME 6 /* timeout */
-# define IML_COMMERR_NODEVICE 8 /* no such device */
-# define IML_COMMERR_INVALID 9 /* input error */
-# define IML_COMMERR_BREAK 10 /* break/terminated */
-# define IML_COMMERR_INVALID_DATA 17 /* invalid checksum/data too big */
-# define IML_COMMERR_EMPTY 18 /* no data available */
+/* Communication errors.
+ *
+ * `NOERROR`: everything went great!
+ * `UNKNOWN`: something bad happened.
+ * `SERIAL`: serial not open.
+ * `IO`: comm not open.
+ * `TIME`: timeout.
+ * `NODEVICE`: no such device.
+ * `INVALID`: input error.
+ * `BREAK`: break/terminated.
+ * `INVALID_DATA`: invalid checksum/data too big.
+ * `EMPTY`: no data available. */
+
+# define IML_COMMERR_NOERROR 0
+# define IML_COMMERR_UNKNOWN 1
+# define IML_COMMERR_SERIAL 3
+# define IML_COMMERR_IO 5
+# define IML_COMMERR_TIME 6
+# define IML_COMMERR_NODEVICE 8
+# define IML_COMMERR_INVALID 9
+# define IML_COMMERR_BREAK 10
+# define IML_COMMERR_INVALID_DATA 17
+# define IML_COMMERR_EMPTY 18
_END_DECLS
_END_NAMESPACE_FXLIB
diff --git a/modules/casiowin/fxlib/include/fxlib.h b/modules/casiowin/fxlib/include/fxlib.h
index 1995f30..a69c304 100644
--- a/modules/casiowin/fxlib/include/fxlib.h
+++ b/modules/casiowin/fxlib/include/fxlib.h
@@ -28,22 +28,31 @@
* The fact that you are presently reading this means you have had knowledge of
* the CeCILL-C license and that you accept its terms.
* ************************************************************************* */
-#include <fxlib/cdefs.h>
+#include <cdefs.h>
#include <stdlib.h>
+/* Include the macro/type definitions first, for the bits (as the original
+ * header). */
+
+#include <commbios.h>
+#include <dispbios.h>
+#include <filebios.h>
+#include <keybios.h>
+#include <timer.h>
+
/* This header, on the contrary to the original one, is divided into
* several thematic subheaders, which are all included here. */
-#include <fxlib/app.h>
-#include <fxlib/battery.h>
-#include <fxlib/bcd.h>
-#include <fxlib/clock.h>
-#include <fxlib/comm.h>
-#include <fxlib/display.h>
-#include <fxlib/file.h>
-#include <fxlib/keyboard.h>
-#include <fxlib/serial.h>
-#include <fxlib/timer.h>
+#include_bits <fxlib/app.h>
+#include_bits <fxlib/battery.h>
+#include_bits <fxlib/bcd.h>
+#include_bits <fxlib/clock.h>
+#include_bits <fxlib/comm.h>
+#include_bits <fxlib/display.h>
+#include_bits <fxlib/file.h>
+#include_bits <fxlib/keyboard.h>
+#include_bits <fxlib/serial.h>
+#include_bits <fxlib/timer.h>
/* One function that could not exactly fit in one or the other category
* is defined here. `SetQuitHandler()` is used to set a quit callback
diff --git a/modules/casiowin/fxlib/include/fxlib/cdefs.h b/modules/casiowin/fxlib/include/fxlib/cdefs.h
deleted file mode 100644
index 6ca5060..0000000
--- a/modules/casiowin/fxlib/include/fxlib/cdefs.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* ****************************************************************************
- * fxlib/cdefs.h -- fxlib's C definitions.
- * Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
- *
- * This file is part of the 'casiowin/fxlib' module in libcarrot, an
- * experimental modular libc project.
- *
- * This file is governed by the CeCILL-C license under French law and abiding
- * by the rules of distribution of free software. You can use, modify and or
- * redistribute it under the terms of the CeCILL-C license as circulated by
- * CEA, CNRS and INRIA at the following URL: http://www.cecill.info
- *
- * As a counterpart to the access to the source code and rights to copy, modify
- * and redistribute granted by the license, users are provided only with a
- * limited warranty and the software's author, the holder of the economic
- * rights, and the successive licensors have only limited liability.
- *
- * In this respect, the user's attention is drawn to the risks associated with
- * loading, using, modifying and/or developing and reproducing the software by
- * the user in light of its specific status of free software, that may mean
- * that it is complicated to manipulate, and that also therefore means that it
- * is reserved for developers and experienced professionals having in-depth
- * computer knowledge. Users are therefore encouraged to load and test the
- * software's suitability as regards their requirements in conditions enabling
- * the security of their systems and/or data to be ensured and, more generally,
- * to use and operate it in the same conditions as regards security.
- *
- * The fact that you are presently reading this means you have had knowledge of
- * the CeCILL-C license and that you accept its terms.
- * ************************************************************************* */
-#include <cdefs.h>
-
-/* Namespace -- none for now, but maybe some day? */
-#undef _BEGIN_NAMESPACE_FXLIB
-#undef _END_NAMESPACE_FXLIB
-#ifdef _USE_CXX98
-# define _BEGIN_NAMESPACE_FXLIB /* namespace "fx" { */
-# define _END_NAMESPACE_FXLIB /* } */
-#else
-# define _BEGIN_NAMESPACE_FXLIB
-# define _END_NAMESPACE_FXLIB
-#endif
-
-/* Should we use non-official thingies? */
-#if !defined(_USE_FXLIB_UNOFFICIAL)
-# define _USE_FXLIB_UNOFFICIAL 1
-#endif
diff --git a/modules/casiowin/fxlib/include/fxlib/syscall.h b/modules/casiowin/fxlib/include/fxlib/syscall.h
deleted file mode 100644
index a691ee5..0000000
--- a/modules/casiowin/fxlib/include/fxlib/syscall.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* ****************************************************************************
- * fxlib/syscall.h -- fxlib's syscall definition for ASM-C.
- * Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
- *
- * This file is part of the 'casiowin/fxlib' module in libcarrot, an
- * experimental modular libc project.
- *
- * This file is governed by the CeCILL-C license under French law and abiding
- * by the rules of distribution of free software. You can use, modify and or
- * redistribute it under the terms of the CeCILL-C license as circulated by
- * CEA, CNRS and INRIA at the following URL: http://www.cecill.info
- *
- * As a counterpart to the access to the source code and rights to copy, modify
- * and redistribute granted by the license, users are provided only with a
- * limited warranty and the software's author, the holder of the economic
- * rights, and the successive licensors have only limited liability.
- *
- * In this respect, the user's attention is drawn to the risks associated with
- * loading, using, modifying and/or developing and reproducing the software by
- * the user in light of its specific status of free software, that may mean
- * that it is complicated to manipulate, and that also therefore means that it
- * is reserved for developers and experienced professionals having in-depth
- * computer knowledge. Users are therefore encouraged to load and test the
- * software's suitability as regards their requirements in conditions enabling
- * the security of their systems and/or data to be ensured and, more generally,
- * to use and operate it in the same conditions as regards security.
- *
- * The fact that you are presently reading this means you have had knowledge of
- * the CeCILL-C license and that you accept its terms.
- * ************************************************************************* */
-/* Make a syscall. */
-
-# define __SYSCALL(_X, _NAME) \
-.section .text; .global _NAME; \
-.type _NAME, @function; \
-.align 2; _NAME: \
- mov.l 1f, r2; \
- mov.l 2f, r0; \
- jmp @r2; \
- nop; \
-1: .long 0x80010070; \
-2: .long _X
diff --git a/modules/casiowin/fxlib/roles.yml b/modules/casiowin/fxlib/roles.yml
index 1af6f07..478f4ca 100644
--- a/modules/casiowin/fxlib/roles.yml
+++ b/modules/casiowin/fxlib/roles.yml
@@ -5,7 +5,6 @@ include:
app.h: fxlib's app management.
battery.h: fxlib's battery management.
bcd.h: fxlib's BCD numbers management.
- cdefs.h: fxlib's C definitions.
clock.h: fxlib's clock management.
comm.h: fxlib's communication management.
display.h: fxlib's display management.
@@ -20,6 +19,8 @@ include:
fxlib.h: library for interacting with CASIO's fx calculators.
keybios.h: fxlib's keyboard definitions.
timer.h: fxlib's timer definitions.
+bits:
+ cdefs.h: fxlib-specific C definitions.
src:
comm:
comm.s: General communication-related syscalls.
diff --git a/modules/casiowin/info.yml b/modules/casiowin/info.yml
index 52cc914..549bfbe 100644
--- a/modules/casiowin/info.yml
+++ b/modules/casiowin/info.yml
@@ -7,12 +7,11 @@ description: >-
abi:
- g1a
default:
- c:
- - casiowin/core
- - casiowin/core-crt
- - all/errno-renesas
+- casiowin/core
+- casiowin/core-crt
import:
- all
+- renesas
requires:
arch:
- [sh3, big]
diff --git a/modules/casiowin/io/copyright.yml b/modules/casiowin/io/copyright.yml
index 94e925f..ce52c6a 100644
--- a/modules/casiowin/io/copyright.yml
+++ b/modules/casiowin/io/copyright.yml
@@ -2,4 +2,4 @@
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/casiowin/io/src/io.h b/modules/casiowin/io/src/io.h
index 242d211..377f5d4 100644
--- a/modules/casiowin/io/src/io.h
+++ b/modules/casiowin/io/src/io.h
@@ -4,28 +4,30 @@
/* Used syscalls. */
+_EXTERN int __bfile_createfile
+ _OF((__uint16_t const *__filename, int __size)) _THROW;
_EXTERN int __bfile_openfile
- _OF((const __uint16_t* __filename, int __mode, int __mode2)) _THROW;
+ _OF((__uint16_t const *__filename, int __mode, int __mode2)) _THROW;
_EXTERN int __bfile_closefile
_OF((int __handle)) _THROW;
_EXTERN int __bfile_readfile
- _OF((int __handle, void* __buf, int __size, int __readpos)) _THROW;
+ _OF((int __handle, void *__buf, int __size, int __readpos)) _THROW;
_EXTERN int __bfile_writefile
- _OF((int __handle, const void* __buf, int __size)) _THROW;
+ _OF((int __handle, void const *__buf, int __size)) _THROW;
_EXTERN int __bfile_seekfile
_OF((int __handle, int __pos)) _THROW;
/* Internal functions. */
_EXTERN long __bfile_ioread
- _OF((void* __cookie, char* __buf, size_t __size));
+ _OF((void *__cookie, char *__buf, size_t __size));
_EXTERN long __bfile_iowrite
- _OF((void* __cookie, const char* __buf, size_t __size));
+ _OF((void *__cookie, char const *__buf, size_t __size));
_EXTERN int __bfile_ioseek
- _OF((void* __cookie, long* __pos, int __whence));
+ _OF((void *__cookie, long *__pos, int __whence));
_EXTERN int __bfile_ioclose
- _OF((void* __cookie));
+ _OF((void *__cookie));
/* Cookie. */
diff --git a/modules/casiowin/io/src/open.c b/modules/casiowin/io/src/open.c
index dec6e76..9d36a60 100644
--- a/modules/casiowin/io/src/open.c
+++ b/modules/casiowin/io/src/open.c
@@ -7,7 +7,7 @@ _EXTERN cookie_io_functions_t __bfile_funcs = {
(cookie_close_function_t*)&__bfile_close
};
-_EXTERN int __bfile_fopen(FILE** stream, const char* filename,
+_EXTERN int __bfile_fopen(FILE** stream, char const *filename,
struct _IO_MODE* mode)
{
uint16_t path[2] = {0};
@@ -17,6 +17,7 @@ _EXTERN int __bfile_fopen(FILE** stream, const char* filename,
/* TODO: convert filename here */
/* Open the file. */
+
if (mode->flags & _IO_OPEN_FLAG_READ)
omode |= __openmode_read;
if (mode->flags & _IO_OPEN_FLAG_WRITE)
@@ -26,8 +27,10 @@ _EXTERN int __bfile_fopen(FILE** stream, const char* filename,
return (__errno_from_fileerr(handle));
/* Make the stream. */
- err = __carrot_open(stream, sizeof(_Bfile_Cookie), mode, &__bfile_funcs);
- if (err) return (err);
+
+ if ((err = __carrot_open(stream, sizeof(_Bfile_Cookie), mode,
+ &__bfile_funcs)))
+ return (err);
cookie = (*stream)->cookie;
cookie->handle = handle;
diff --git a/modules/casiowin/io/src/read.c b/modules/casiowin/io/src/read.c
index 97df5bf..69822fa 100644
--- a/modules/casiowin/io/src/read.c
+++ b/modules/casiowin/io/src/read.c
@@ -6,6 +6,7 @@ _EXTERN long __bfile_ioread(struct _Bfile_Cookie* cookie, char* buf,
int ret;
/* Make the call. */
+
ret = __bfile_readfile(cookie->handle, buf, size, -1);
if (err < 0)
return (-__errno_from_fileerr(err));
diff --git a/modules/casiowin/libfxsys/copyright.yml b/modules/casiowin/libfxsys/copyright.yml
index 94e925f..ce52c6a 100644
--- a/modules/casiowin/libfxsys/copyright.yml
+++ b/modules/casiowin/libfxsys/copyright.yml
@@ -2,4 +2,4 @@
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/casiowin/libfxsys/docs/index.en.md b/modules/casiowin/libfxsys/docs/index.en.rst
index e819ee7..0a5fda0 100644
--- a/modules/casiowin/libfxsys/docs/index.en.md
+++ b/modules/casiowin/libfxsys/docs/index.en.rst
@@ -1,6 +1,6 @@
----
-title: Compatibility layer with Andreas Bertheussen's fxlib
----
+Compatibility layer with Andreas Bertheussen's fxlib
+====================================================
+
While making his own utilities on Linux, Andreas Bertheussen also made a
little libc with some headers more or less equivalents to the fxlib's ones.
This module brings compatibility with the very few add-ins using this library.
diff --git a/modules/casiowin/monochromelib/copyright.yml b/modules/casiowin/monochromelib/copyright.yml
index e595491..f022178 100644
--- a/modules/casiowin/monochromelib/copyright.yml
+++ b/modules/casiowin/monochromelib/copyright.yml
@@ -5,4 +5,4 @@ files:
- 'include/*'
copyright:
- [2011, Pierre Le Gall, legallpierre89@gmail.com]
-- [2016, 2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2016, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/casiowin/monochromelib/docs/bmp.en.md b/modules/casiowin/monochromelib/docs/bmp.en.rst
index 6c0cf5a..18482da 100644
--- a/modules/casiowin/monochromelib/docs/bmp.en.md
+++ b/modules/casiowin/monochromelib/docs/bmp.en.rst
@@ -1,5 +1,5 @@
----
-title: Bitmaps with MonochromeLib
----
+Bitmaps with MonochromeLib
+==========================
+
There are a few bitmap functions in MonochromeLib and their documentation
is TODO.
diff --git a/modules/casiowin/monochromelib/docs/draw.en.md b/modules/casiowin/monochromelib/docs/draw.en.rst
index c1d97e5..138e9aa 100644
--- a/modules/casiowin/monochromelib/docs/draw.en.md
+++ b/modules/casiowin/monochromelib/docs/draw.en.rst
@@ -1,4 +1,4 @@
----
-title: Drawing with MonochromeLib
----
+Drawing with MonochromeLib
+==========================
+
There are many drawing function and their documentation is TODO.
diff --git a/modules/casiowin/monochromelib/docs/index.en.md b/modules/casiowin/monochromelib/docs/index.en.rst
index 23086a9..c343534 100644
--- a/modules/casiowin/monochromelib/docs/index.en.md
+++ b/modules/casiowin/monochromelib/docs/index.en.rst
@@ -1,13 +1,15 @@
----
-title: MonochromeLib
-chapters:
-- vram
-- screen
-- draw
-- bmp
----
+MonochromeLib
+=============
+
+.. chapters::
+
+ vram
+ screen
+ draw
+ bmp
+
MonochromeLib is a graphics library for the CASIO fx-9860G made by PierrotLL
-in 2011 for the game [Gravity Duck][gduck].
+in 2011 for the game `Gravity Duck`_.
It replaced the graphics part of CASIO's fxlib, published in 2006
along with the CASIO fx-9860G SDK, which the community found to be inefficient.
@@ -20,4 +22,4 @@ making all drawing operations in some video memory (VRAM) before copying it
on the real screen. This prevents screen flickering, and any under
construction image to be displayed.
-[gduck]: http://www.planet-casio.com/Fr/programmes/programme1795-last-gravity-duck-pierrotll-a7.html
+.. _Gravity Duck: http://www.planet-casio.com/Fr/programmes/programme1795-last-gravity-duck-pierrotll-a7.html
diff --git a/modules/casiowin/monochromelib/docs/screen.en.md b/modules/casiowin/monochromelib/docs/screen.en.md
deleted file mode 100644
index aeb1df6..0000000
--- a/modules/casiowin/monochromelib/docs/screen.en.md
+++ /dev/null
@@ -1,34 +0,0 @@
----
-title: Screen interactions
----
-As described in [the introduction](index), MonochromeLib uses the double
-buffering technique, so that the number of interactions with the screen
-(which are slow) is limited. So there are very few things you can actually do
-with the screen in the MonochromeLib.
-
-### Updating the screen
-Once the VRAM is ready to be displayed (see [VRAM interactions](vram) for more
-explanations), use the following function to update the screen using the VRAM:
-
-```c
-void ML_display_vram(void);
-```
-
-### Clear the screen
-If you want to clear the screen but not the VRAM, although it isn't
-recommended, you can use the following function:
-
-```c
-void ML_clear_screen(void);
-```
-
-### Set and get the screen contrast
-You can set the contrast using these two functions:
-
-```c
-void ML_set_contrast(unsigned char contrast);
-unsigned char ML_get_contrast(void);
-```
-
-The contrast is a value between `ML_CONTRAST_MIN` and `ML_CONTRAST_MAX`,
-ideally `ML_CONTRAST_NORMAL`.
diff --git a/modules/casiowin/monochromelib/docs/screen.en.rst b/modules/casiowin/monochromelib/docs/screen.en.rst
new file mode 100644
index 0000000..4881e5b
--- /dev/null
+++ b/modules/casiowin/monochromelib/docs/screen.en.rst
@@ -0,0 +1,40 @@
+Screen interactions
+===================
+
+As described in the introduction (:ref:`index`), MonochromeLib uses the double
+buffering technique, so that the number of interactions with the screen
+(which are slow) is limited. So there are very few things you can actually do
+with the screen in the MonochromeLib.
+
+Updating the screen
+-------------------
+
+Once the VRAM is ready to be displayed (see :ref:`vram` for more
+explanations), use the following function to update the screen using the VRAM:
+
+.. code-block:: c
+
+ void ML_display_vram(void);
+
+Clear the screen
+----------------
+
+If you want to clear the screen but not the VRAM, although it isn't
+recommended, you can use the following function:
+
+.. code-block:: c
+
+ void ML_clear_screen(void);
+
+Set and get the screen contrast
+-------------------------------
+
+You can set the contrast using these two functions:
+
+.. code-block:: c
+
+ void ML_set_contrast(unsigned char contrast);
+ unsigned char ML_get_contrast(void);
+
+The contrast is a value between ``ML_CONTRAST_MIN`` and ``ML_CONTRAST_MAX``,
+ideally ``ML_CONTRAST_NORMAL``.
diff --git a/modules/casiowin/monochromelib/docs/vram.en.md b/modules/casiowin/monochromelib/docs/vram.en.md
deleted file mode 100644
index a44f1b6..0000000
--- a/modules/casiowin/monochromelib/docs/vram.en.md
+++ /dev/null
@@ -1,72 +0,0 @@
----
-title: VRAM interactions
----
-As described in [the introduction](index), MonochromeLib uses video memory
-as the primary way of drawing on the screen. Instead of defining its own,
-MonochromeLib uses the system one, which can change according to the version
-of the OS the add-in is running on.
-
-The screen of the fx-9860G is 128 pixels long and 64 pixels tall. It's a
-1-bit monochrome screen, where a '1' represents a black pixel and a '0'
-represents a white pixel. The VRAM is organized as a set of 64 groups of
-128 pixels (16 bytes), going from top to bottom, then, in a line, from left to
-right (the highest bit in a byte, 128, is at the left of the 8 pixel group,
-whereas the lowest bit, 1, is at the right of it).
-
-Don't forget to [update the screen](screen#update) once the VRAM is ready
-to be displayed!
-
-### Getting the VRAM address
-As the VRAM address can vary, it is **imperative** that you use this function
-if you ought to interact with the VRAM directly, instead of hardcoding the
-address, which lead many add-ins to compatibility problems.
-
-```c
-char *ML_vram_address();
-```
-
-The `char*` return type is used for compatibility. As you might want to use
-bitwise operations, it is recommended to cast the return value as
-`unsigned char` or make the compiler assume unsigned char by default,
-for example, using `-funsigned-char` on GCC.
-
-### Colors
-MonochromeLib defines the following set of colors and meta-colors:
-
-```c
-typedef enum {
- ML_TRANSPARENT = -1,
- ML_WHITE,
- ML_BLACK,
- ML_XOR,
- ML_CHECKER
-} ML_Color
-```
-
-`ML_BLACK` and `ML_WHITE` correspond to the 'raw' colors, `ML_XOR` changes the
-color of every affected pixel, and `ML_CHECKER` makes a "checkerboard" color,
-that sets one pixel out of two black, and the other one white.
-
-For an example of `ML_CHECKER`, see [the ML_rectangle example](draw#rectangle).
-
-### Interacting with pixels
-If you don't want to interact with the VRAM directly, you can use these
-simple functions to set and get the status of a pixel in the VRAM using
-these functions:
-
-```c
-void ML_pixel(int x, int y, ML_Color color);
-ML_Color ML_pixel_test(int x, int y);
-```
-
-All of the [drawing functions](draw) can be done using these functions,
-although the library functions interact directly with the VRAM, so they
-are quicker and should be used if possible.
-
-### Clear the VRAM
-If you want to have an empty VRAM to redraw it, you can use the following
-function:
-
-```c
-void ML_clear_vram(void);
-```
diff --git a/modules/casiowin/monochromelib/docs/vram.en.rst b/modules/casiowin/monochromelib/docs/vram.en.rst
new file mode 100644
index 0000000..d88be41
--- /dev/null
+++ b/modules/casiowin/monochromelib/docs/vram.en.rst
@@ -0,0 +1,82 @@
+VRAM interactions
+=================
+
+As described in the introduction(:ref:`index`), MonochromeLib uses
+video memory as the primary way of drawing on the screen. Instead of
+defining its own, MonochromeLib uses the system one, which can change
+according to the version of the OS the add-in is running on.
+
+The screen of the fx-9860G is 128 pixels long and 64 pixels tall. It's a
+1-bit monochrome screen, where a '1' represents a black pixel and a '0'
+represents a white pixel. The VRAM is organized as a set of 64 groups of
+128 pixels (16 bytes), going from top to bottom, then, in a line, from left to
+right (the highest bit in a byte, 128, is at the left of the 8 pixel group,
+whereas the lowest bit, 1, is at the right of it).
+
+Don't forget to `update the screen <screen#update>`_ once the VRAM is ready
+to be displayed!
+
+Getting the VRAM address
+------------------------
+
+As the VRAM address can vary, it is **imperative** that you use this function
+if you ought to interact with the VRAM directly, instead of hardcoding the
+address, which lead many add-ins to compatibility problems.
+
+.. code-block:: c
+
+ char *ML_vram_address();
+
+The ``char*`` return type is used for compatibility. As you might want to use
+bitwise operations, it is recommended to cast the return value as
+``unsigned char`` or make the compiler assume unsigned char by default,
+for example, using ``-funsigned-char`` on GCC.
+
+Colors
+------
+
+MonochromeLib defines the following set of colors and meta-colors:
+
+.. code-block:: c
+
+ typedef enum {
+ ML_TRANSPARENT = -1,
+ ML_WHITE,
+ ML_BLACK,
+ ML_XOR,
+ ML_CHECKER
+ } ML_Color
+
+``ML_BLACK`` and ``ML_WHITE`` correspond to the 'raw' colors, ``ML_XOR``
+changes the color of every affected pixel, and ``ML_CHECKER`` makes a
+"checkerboard" color, that sets one pixel out of two black, and the other
+one white.
+
+For an example of ``ML_CHECKER``, see
+`the ML_rectangle example <draw#rectangle>`_.
+
+Interacting with pixels
+-----------------------
+
+If you don't want to interact with the VRAM directly, you can use these
+simple functions to set and get the status of a pixel in the VRAM using
+these functions:
+
+.. code-block:: c
+
+ void ML_pixel(int x, int y, ML_Color color);
+ ML_Color ML_pixel_test(int x, int y);
+
+All of the drawing functions described in :ref:`draw` can be done using
+these functions, although the library functions interact directly with the
+VRAM, so they are quicker and should be used if possible.
+
+Clear the VRAM
+--------------
+
+If you want to have an empty VRAM to redraw it, you can use the following
+function:
+
+.. code-block:: c
+
+ void ML_clear_vram(void);
diff --git a/modules/compiler/host-gcc-sh/copyright.yml b/modules/compiler/host-gcc-sh/copyright.yml
index 94e925f..ce52c6a 100644
--- a/modules/compiler/host-gcc-sh/copyright.yml
+++ b/modules/compiler/host-gcc-sh/copyright.yml
@@ -2,4 +2,4 @@
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/compiler/host-gcc-sh/docs/index.en.md b/modules/compiler/host-gcc-sh/docs/index.en.rst
index 8a4bd48..36ea7db 100644
--- a/modules/compiler/host-gcc-sh/docs/index.en.md
+++ b/modules/compiler/host-gcc-sh/docs/index.en.rst
@@ -1,6 +1,6 @@
----
-title: The GNU C Compiler
----
+The GNU C Compiler
+==================
+
GCC is the main compiler of the GNU project. It has been created in 1986
by Richard Stallman and Len Tower to manage ANSI C, and has been maintained
ever since while being ported to other languages and architectures.
diff --git a/modules/compiler/host-gcc/copyright.yml b/modules/compiler/host-gcc/copyright.yml
index 94e925f..ce52c6a 100644
--- a/modules/compiler/host-gcc/copyright.yml
+++ b/modules/compiler/host-gcc/copyright.yml
@@ -2,4 +2,4 @@
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/compiler/host-gcc/docs/index.en.md b/modules/compiler/host-gcc/docs/index.en.rst
index 8a4bd48..36ea7db 100644
--- a/modules/compiler/host-gcc/docs/index.en.md
+++ b/modules/compiler/host-gcc/docs/index.en.rst
@@ -1,6 +1,6 @@
----
-title: The GNU C Compiler
----
+The GNU C Compiler
+==================
+
GCC is the main compiler of the GNU project. It has been created in 1986
by Richard Stallman and Len Tower to manage ANSI C, and has been maintained
ever since while being ported to other languages and architectures.
diff --git a/modules/compiler/host-renesas/bits/compiler.h b/modules/compiler/host-renesas/bits/compiler.h
index 193b39b..2d37747 100644
--- a/modules/compiler/host-renesas/bits/compiler.h
+++ b/modules/compiler/host-renesas/bits/compiler.h
@@ -22,13 +22,15 @@
/* Also, this macro is here for quick version checking.
* It is inspired from glibc's `__GNUC_PREREQ` macro. */
-#ifdef __RENESAS_PREREQ
-# undef __RENESAS_PREREQ
+#ifdef _RENESAS_PREREQ
+# undef _RENESAS_PREREQ
#endif
#if defined(__HITACHI__) && __HITACHI_VERSION__ >= 0xFFFF
-# define __RENESAS_PREREQ(_MAJ, _MIN) \
+# define _RENESAS_PREREQ(_MAJ, _MIN) \
(__HITACHI_VERSION__ >= ((_MAJ) << 24) + ((_MIN) << 16))
#elif defined(__HITACHI__)
-# define __RENESAS_PREREQ(_MAJ, _MIN) \
+# define _RENESAS_PREREQ(_MAJ, _MIN) \
(__HITACHI_VERSION__ >= ((_MAJ) << 8) + (_MIN))
+#else
+# define _RENESAS_PREREQ(_MAJ, _MIN) (0)
#endif
diff --git a/modules/compiler/host-renesas/bits/endian.h b/modules/compiler/host-renesas/bits/endian.h
index 3157736..b4211ff 100644
--- a/modules/compiler/host-renesas/bits/endian.h
+++ b/modules/compiler/host-renesas/bits/endian.h
@@ -1,7 +1,7 @@
/* Renesas' SuperH compiler defines the `_LIT` or `_BIG` macros
* if it's configured for little or big endian. */
-#if __RENESAS_PREREQ(1, 0)
+#if _RENESAS_PREREQ(1, 0)
# if defined(_LIT)
# define __BYTE_ORDER __LITTLE_ENDIAN
# else /* defined(_BIG) */
diff --git a/modules/compiler/host-renesas/copyright.yml b/modules/compiler/host-renesas/copyright.yml
index 94e925f..ce52c6a 100644
--- a/modules/compiler/host-renesas/copyright.yml
+++ b/modules/compiler/host-renesas/copyright.yml
@@ -2,4 +2,4 @@
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/compiler/host-renesas/docs/index.en.md b/modules/compiler/host-renesas/docs/index.en.rst
index cbac093..f74397c 100644
--- a/modules/compiler/host-renesas/docs/index.en.md
+++ b/modules/compiler/host-renesas/docs/index.en.rst
@@ -1,9 +1,10 @@
----
-title: Renesas C/C++ Compiler header bits
----
+Renesas C/C++ Compiler header bits
+==================================
+
In 1998, Hitachi provided a C/C++ compiler, an assembler, and an optimizing
linkage editor for the SuperH RISC engine microcomputers. In 2003, Renesas
bought Hitachi, that's why we know deal with the Renesas C/C++ compiler.
This module provides the header bits for this compiler, required by
-[the core module]([all/core]) and [the SuperH core module]([all/core-sh]).
+`the core module <../../all/core>`_ and
+`the SuperH core module <../../all/core-sh>`_.
diff --git a/modules/compiler/info.yml b/modules/compiler/info.yml
index 78ce1f4..6dfaa3f 100644
--- a/modules/compiler/info.yml
+++ b/modules/compiler/info.yml
@@ -4,8 +4,7 @@ magic: potatosdk-1.0
description: >-
Meta-system for modules that are compiler-dependant.
default:
- c:
- - compiler/host-gcc
- - compiler/host-renesas
- - compiler/target-gcc-sh
- - compiler/target-renesas
+- compiler/host-gcc
+- compiler/host-renesas
+- compiler/target-gcc-sh
+- compiler/target-renesas
diff --git a/modules/compiler/target-renesas/bits/primitive.h b/modules/compiler/target-renesas/bits/primitive.h
index 550fc30..e1b3410 100644
--- a/modules/compiler/target-renesas/bits/primitive.h
+++ b/modules/compiler/target-renesas/bits/primitive.h
@@ -3,10 +3,7 @@
* preprocessor macros, so we'd need GCC to make him tell his secrets.
*
* -> check if the values change between versions?
- * -> check if I can hardcode values for architectures?
- *
- * FIXME: `__CHAR_IS_SIGNED` used to be defined as
- * `!defined(__CHAR_UNSIGNED__)` here, shall we define it somewhere else? */
+ * -> check if I can hardcode values for architectures? */
/* Char type. */
@@ -20,6 +17,12 @@
#define __UCHAR_MIN ( 0)
#define __UCHAR_MAX ( 255)
+#if defined(__CHAR_UNSIGNED)
+# define __CHAR_IS_SIGNED 0
+#else
+# define __CHAR_IS_SIGNED 1
+#endif
+
/* Short type. */
#define short __int16_t
diff --git a/modules/compiler/target-renesas/copyright.yml b/modules/compiler/target-renesas/copyright.yml
index 94e925f..ce52c6a 100644
--- a/modules/compiler/target-renesas/copyright.yml
+++ b/modules/compiler/target-renesas/copyright.yml
@@ -2,4 +2,4 @@
---
files: '*'
copyright:
-- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/all/errno-renesas/bits/errno.h b/modules/renesas/errno/bits/errno.h
index 5db05ed..7515ff4 100644
--- a/modules/all/errno-renesas/bits/errno.h
+++ b/modules/renesas/errno/bits/errno.h
@@ -1,4 +1,4 @@
-/* Errors from the Renesas/Hitachi C/C++ library (version 06.00). */
+/* Errors from the Renesas/Hitachi C library (version 06.00). */
#define ERANGE 1100
#define EDOM 1101
@@ -25,18 +25,18 @@
/* Some more functions extracted from the 09.00 manual. */
-# define EFIXEDO 1400
-# define EFIXEDU 1410
-# define EACCUMO 1420
-# define EACCUMU 1430
-# define ELFIXEDO 1440
-# define ELFIXEDU 1450
-# define ELACCUMO 1460
-# define ELACCUMU 1470
+#define EFIXEDO 1400
+#define EFIXEDU 1410
+#define EACCUMO 1420
+#define EACCUMU 1430
+#define ELFIXEDO 1440
+#define ELFIXEDU 1450
+#define ELACCUMO 1460
+#define ELACCUMU 1470
-# define EMALRESM 2100
-# define EMALFRSM 2101
-# define ETOKRESM 2110
-# define ETOKFRSM 2111
-# define EIOBRESM 2120
-# define EIOBFRSM 2121
+#define EMALRESM 2100
+#define EMALFRSM 2101
+#define ETOKRESM 2110
+#define ETOKFRSM 2111
+#define EIOBRESM 2120
+#define EIOBFRSM 2121
diff --git a/modules/renesas/errno/copyright.yml b/modules/renesas/errno/copyright.yml
new file mode 100644
index 0000000..ce52c6a
--- /dev/null
+++ b/modules/renesas/errno/copyright.yml
@@ -0,0 +1,5 @@
+%YAML 1.2
+---
+files: '*'
+copyright:
+- [2017, 2018, Thomas Touhey, thomas@touhey.fr]
diff --git a/modules/renesas/errno/docs/index.en.rst b/modules/renesas/errno/docs/index.en.rst
new file mode 100644
index 0000000..be59830
--- /dev/null
+++ b/modules/renesas/errno/docs/index.en.rst
@@ -0,0 +1,65 @@
+Renesas' style of error numbers
+===============================
+
+This module provides Renesas-compatible error codes.
+Version 6.00 errors are:
+
+- ``ERANGE``: “data out of **range**”, the result of a function cannot be
+ represented as a float type value, or if overflow or underflow occurs;
+- ``EDOM``: “data out of **dom**ain”, the value of a parameter input to a
+ function is outside the range of values defined in the function;
+- ``EDIV``: ???;
+- ``ESTRN``: “too long **str**ing”, the length of the string literal exceeds
+ the upper limit;
+- ``PTRERR``: “invalid file pointer”, the NULL pointer constant is specified
+ as the file pointer value;
+- ``SEQERR``: ???;
+- ``ECBASE``: “invalid radix”, an invalid radix was specified;
+- ``ETLN``: “number too long”, the specified number exceeds the number of
+ significant digits;
+- ``EEXP``: “**exp**onent too large”, the specified exponent exceeds three
+ digits;
+- ``EEXPN``: “**n**ormalized **exp**onent too large”, the exponent exceeds
+ three digits when the string literal is normalized to the IEEE standard
+ decimal format;
+- ``ENUM``: ???;
+- ``EFLOATO``: “**o**verflow out of **float**”, a float-type decimal value
+ is out-of-range (overflow);
+- ``EFLOATU``: “**u**nderflow out of **float**”, a float-type decimal value
+ is out of range (underflow);
+- ``EDBLO``: “**o**verflow out of **d**ou**bl**e”, a double-type decimal value
+ is out of range (overflow);
+- ``EDBLU``: “**u**nderflow out of **d**ou**bl**e”, a double-type decimal value
+ is out of range (underflow);
+- ``ELDBLO``: “**o**verflow out of **l**ong **d**ou**bl**e”, a long double-type
+ decimal value is out of range (overflow);
+- ``ELDBLU``: “**u**nderflow out of **l**ong **d**ou**bl**e”, a long double-type
+ decimal value is out of range (underflow);
+- ``NOTOPN``: “file **not** **op**e**n**”, the file is not open;
+- ``EBADF``: “**bad** **f**ile number”, an output function was issued for
+ an input-only file, or an input file was issued for an output-only file;
+- ``ECSPEC``: “error in format”, an erroneous format was specified for
+ an input/output function using format.
+
+Added in version 9.00 (manual):
+
+- ``EFIXEDO``: “**o**verflow out of __**fixed**”;
+- ``EFIXEDU``: “**u**nderflow out of __**fixed**”;
+- ``EACCUMO``: “**o**verflow out of __**accum**”;
+- ``EACCUMU``: “**u**nderflow out of __**accum**”;
+- ``ELFIXEDO``: “**o**verflow out of **l**ong __**fixed**”;
+- ``ELFIXEDU``: “**u**nderflow out of **l**ong __**fixed**”;
+- ``ELACCUMO``: “**o**verflow out of **l**ong __**accum**”;
+- ``ELACCUMU``: “**u**nderflow out of **l**ong __**accum**”;
+- ``EMALRESM``: “error in waiting semaphore”, failed to define semaphore
+ resources for malloc;
+- ``EMALFRSM``: “error in signaling semaphore”, failed to release semaphore
+ resources for malloc;
+- ``ETOKRESM``: “error in waiting semaphore”, failed to define semaphore
+ resources for strtok;
+- ``ETOKFRSM``: “error in signaling semaphore”, failed to release semaphore
+ resources for strtok;
+- ``EIOBRESM``: “error in waiting semaphore”, failed to define semaphore
+ resources for _iob (fopen);
+- ``EIOBFRSM``: “error in signaling semaphore”, failed to release semaphore
+ resources for _iob (fopen).
diff --git a/modules/all/errno-renesas/info.yml b/modules/renesas/errno/info.yml
index 0f0523c..2028021 100644
--- a/modules/all/errno-renesas/info.yml
+++ b/modules/renesas/errno/info.yml
@@ -3,3 +3,5 @@
magic: potatosdk-1.0
description: The Renesas style of error numbers.
license: free
+requires:
+ deps: ['all/errno']
diff --git a/modules/renesas/errno/roles.yml b/modules/renesas/errno/roles.yml
new file mode 100644
index 0000000..a5c0814
--- /dev/null
+++ b/modules/renesas/errno/roles.yml
@@ -0,0 +1,6 @@
+%YAML 1.2
+---
+bits:
+ errno.h: Renesas' error codes.
+src:
+ errlist.c: Renesas' error descriptions.
diff --git a/modules/renesas/errno/src/errlist.c b/modules/renesas/errno/src/errlist.c
new file mode 100644
index 0000000..a8feb5b
--- /dev/null
+++ b/modules/renesas/errno/src/errlist.c
@@ -0,0 +1,45 @@
+#include <errno.h>
+#define DEFAULT __default_errstring
+
+#define R5(E) E, E, E, E, E
+#define R8(E) R5(E), E, E, E
+#define R9(E) R8(E), E
+#define R10(E) R5(E), R5(E)
+#define R50(E) R10(E), R10(E), R10(E), R10(E), R10(E)
+#define R90(E) R50(E), R10(E), R10(E), R10(E), R10(E)
+#define R100(E) R50(E), R50(E)
+#define R500(E) R100(E), R100(E), R100(E), R100(E), R100(E)
+
+#define D DEFAULT
+#define D5 R5(DEFAULT)
+#define D8 R8(DEFAULT)
+#define D9 R9(DEFAULT)
+#define D10 R10(DEFAULT)
+#define D50 R50(DEFAULT)
+#define D90 R90(DEFAULT)
+#define D100 R100(DEFAULT)
+#define D500 R500(DEFAULT)
+
+int sys_nerr = 2122;
+char const *sys_errlist[] = {
+ D500, D500, D100,
+
+ "ERANGE", "EDOM", "EDIV", "ESTRN", D, "PTRERR", D, "SEQERR", D, D,
+ D90,
+
+ "ECBASE", D, "ETLN", D, "EEXP", D, "EEXPN", D, "ENUM", D,
+ "EFLOATO", D9, "EFLOATU", D9, D10, D10,
+ "EDBLO", D9, "EDBLU", D9,
+ "ELDBLO", D9, "ELDBLU", D9, D10,
+
+ "NOTOPN", D, "EBADF", D, "ECSPEC", D5, D90,
+
+ "EFIXEDO", D9, "EFIXEDU", D9, "EACCUMO", D9, "EACCUMU", D9,
+ "ELFIXEDO", D9, "ELFIXEDU", D9, "ELACCUMO", D9, "ELACCUMU", D9, D10, D10,
+
+ D500, D100,
+
+ "EMALRESM", "EMALFRSM", D8,
+ "ETOKRESM", "ETOKFRSM", D8,
+ "EIOBRESM", "EIOBFRSM"
+};
diff --git a/modules/renesas/info.yml b/modules/renesas/info.yml
new file mode 100644
index 0000000..2d39bda
--- /dev/null
+++ b/modules/renesas/info.yml
@@ -0,0 +1,9 @@
+%YAML 1.2
+---
+magic: potatosdk-1.0
+description: >-
+ Meta-system for modules representing bits of Renesas' generated C libraries.
+default:
+- renesas/errno
+import:
+- all
diff --git a/tools/Internals/arch.py b/tools/Internals/arch.py
index 6c41ec2..2aee0f4 100755
--- a/tools/Internals/arch.py
+++ b/tools/Internals/arch.py
@@ -6,6 +6,7 @@ __all__ = ["get_arch_detail"]
_arch_detail = {
# Intel's x86 (8080).
+
'x86': ('x86', 'i386', 'little'),
'i286': ('x86', 'i286', 'little'),
'i386': ('x86', 'i386', 'little'),
@@ -15,9 +16,11 @@ _arch_detail = {
'i786': ('x86', 'i786', 'little'),
# Intel's x86_64 (64-bit version of the x86).
+
'x86_64': ('x86_64', None, 'little'),
# Hitachi's SuperH, J-Core.
+
'sh': ('sh', None, None),
'sh1': ('sh', 'sh1', None),
'sh2': ('sh', 'sh2', None),
diff --git a/tools/Internals/project.py b/tools/Internals/project.py
index 6e4a155..57de154 100755
--- a/tools/Internals/project.py
+++ b/tools/Internals/project.py
@@ -211,14 +211,12 @@ class Project:
def findmodules(self, arch, endian, system = None,
compiler = ('GNU', 'GCC'), hcompiler = ('GNU', 'GCC'),
- languages = ['c', 'c++'], addition = []):
+ addition = []):
""" Find modules corresponding to a query, based on:
- `arch`: the architecture for which to build;
- `system`: the system for which to build;
- - `compiler`: the C/C++ compiler for which to build;
- - `hcompiler`: the C/C++ compiler with which to build;
- - `languages`: the programming languages for which to
- offer support;
+ - `compiler`: the C compiler for which to build;
+ - `hcompiler`: the C compiler with which to build;
- `addition`: the additional modules to include. """
modules = {}
@@ -231,7 +229,7 @@ class Project:
# Get the language defaults for the systems.
# 'ds' means 'default systems', 'ls' means 'loaded systems',
# 'sn' means 'system name'.
- default = {'c': [], 'c++': []}
+ default = []
ds = [system]
ls = []
while ds:
@@ -244,11 +242,8 @@ class Project:
ds.extend(sys.deps)
if sys.arch and not (arch, endian) in sys.arch:
Raise(UnsupportedArchForSystemException(arch, endian, sn))
- if 'c' in sys.defaults:
- default['c'] += sys.defaults['c']
- default['c++'] += sys.defaults['c']
- if 'c++' in sys.defaults:
- default['c++'] += sys.defaults['c++']
+ if sys.defaults:
+ default += sys.defaults
# Gather the additional modules.
for name in set(addition):
diff --git a/tools/configure.py b/tools/configure.py
index d8fcdc8..ec97348 100755
--- a/tools/configure.py
+++ b/tools/configure.py
@@ -1,9 +1,8 @@
#!/usr/bin/env python3
""" This tool serves for user configuration of the libcarrot.
Basically, it takes the user parameters (architecture, system,
- programming languages, additional modules, build tools), and makes
- a configuration that the actual tool, 'make.py', can read to know
- what he is supposed to do.
+ additional modules, build tools), and makes a configuration that the
+ actual tool, 'make.py', can read to know what he is supposed to do.
It is responsible for finding the modules corresponding to what the
user asks, finding a configuration of the build tools that work and
@@ -87,8 +86,6 @@ def get_args(argv = sys.argv[1:]):
grp.add_argument('/-abi', dest='abi', default=None)
grp.add_argument('-e', '--endian', '/-endianness', dest='endian',
default=None, help=_("the architecture endianness"))
- grp.add_argument('-l', '--languages', dest='lang', default='c',
- help=_("languages that libcarrot should support"))
grp.add_argument('-a', '--add', dest='modules',
default=[], action='append', help=_("add a module in the configuration "
"(cumulative)"))
@@ -215,15 +212,6 @@ def main():
if not endian: raise MissingEndiannessException
args.endian = endian
- # Get the languages.
-
- args.lang = set(args.lang.split(','))
- try:
- lang = next(lang for lang in args.lang if not lang in ['c', 'c++'])
- Raise(UnsupportedLanguageException(lang))
- except StopIteration:
- pass
-
# Get the additional modules.
addm = []
@@ -259,14 +247,14 @@ def main():
# Find the tools.
- found_tools = tools.find(args.lang, args.arch, args.endian,
- args.system, args.abi, args.flavour)
+ found_tools = tools.find(args.arch, args.endian, args.system,
+ args.abi, args.flavour)
tools.setup(found_tools)
# List the modules.
mods = g.findmodules(args.arch, args.endian, args.system,
- tools.get('compiler'), tools.get('compiler'), args.lang, args.modules)
+ tools.get('compiler'), tools.get('compiler'), args.modules)
modules = list(mods.keys())
# XXX: shall we order modules by output type?