aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas "Cakeisalie5" Touhey <thomas@touhey.fr>2017-10-13 20:18:40 +0200
committerThomas "Cakeisalie5" Touhey <thomas@touhey.fr>2017-10-13 20:18:40 +0200
commit3fb51fff9c48f35f8a699a799921abaffd698831 (patch)
treeda9d78c5152851468d73fb7064fbba4f5d80cca8
parent071943d8daf5f8bcb0f277d5bda3e6ed1f43b008 (diff)
Still going on
-rw-r--r--arch/all/compiler-gcc/bits/compiler/end.h1
-rw-r--r--arch/all/compiler-gcc/bits/compiler/start.h1
l---------arch/all/compiler-gcc/docs1
-rw-r--r--arch/all/compiler-gcc/docs/index.en.md (renamed from docs/all/compiler-gcc/index.en.md)0
l---------arch/all/compiler-renesas/docs1
-rw-r--r--arch/all/compiler-renesas/docs/index.en.md (renamed from docs/all/compiler-renesas/index.en.md)0
l---------arch/all/core-sh/docs1
-rw-r--r--arch/all/core-sh/docs/bits.en.md (renamed from docs/all/core-sh/bits.en.md)0
-rw-r--r--arch/all/core-sh/docs/index.en.md (renamed from docs/all/core-sh/index.en.md)0
l---------arch/all/core/docs1
-rw-r--r--arch/all/core/docs/bits.en.md (renamed from docs/all/core/bits.en.md)0
-rw-r--r--arch/all/core/docs/index.en.md (renamed from docs/all/core/index.en.md)0
-rw-r--r--arch/all/helloworld/docs/index.en.md13
-rw-r--r--arch/all/helloworld/include/helloworld.h5
-rw-r--r--arch/all/helloworld/info.yml2
-rw-r--r--arch/all/helloworld/src/helloworld.c10
l---------arch/all/iconv/docs1
-rw-r--r--arch/all/iconv/docs/index.en.md (renamed from docs/all/iconv/index.en.md)0
-rw-r--r--arch/all/info.yml3
l---------arch/all/io/docs1
-rw-r--r--arch/all/io/docs/index.en.md (renamed from docs/all/io/index.en.md)0
l---------arch/all/math/docs1
-rw-r--r--arch/all/math/docs/index.en.md (renamed from docs/all/math/index.en.md)0
l---------arch/all/mem/docs1
-rw-r--r--arch/all/mem/docs/index.en.md (renamed from docs/all/mem/index.en.md)0
-rw-r--r--arch/all/mem/docs/tweaking.en.md (renamed from docs/all/mem/tweaking.en.md)0
l---------arch/all/stdcocorico/docs1
-rw-r--r--arch/all/stdcocorico/docs/index.en.md (renamed from docs/all/stdcocorico/index.en.md)0
l---------arch/all/string/docs1
-rw-r--r--arch/all/string/docs/index.en.md (renamed from docs/all/string/index.en.md)0
-rw-r--r--arch/all/string/docs/memory.en.md (renamed from docs/all/string/memory.en.md)0
-rw-r--r--arch/all/string/docs/strings.en.md (renamed from docs/all/string/strings.en.md)0
-rw-r--r--arch/all/string/include/string.h3
-rw-r--r--arch/all/string/src/bsd/strlcat.c25
-rw-r--r--arch/casiowin/README.md2
-rw-r--r--arch/casiowin/copyright.yml5
l---------arch/casiowin/core-crt/docs1
-rw-r--r--arch/casiowin/core-crt/docs/index.en.md (renamed from docs/casiowin/core-crt/index.en.md)0
l---------arch/casiowin/core/docs1
-rw-r--r--arch/casiowin/core/docs/index.en.md (renamed from docs/casiowin/index.en.md)4
-rw-r--r--arch/casiowin/core/src/dirent/dirent.h37
-rw-r--r--arch/casiowin/core/src/dirent/open.c53
-rw-r--r--arch/casiowin/core/src/dirent/read.c18
-rw-r--r--arch/casiowin/core/src/dirent/syscalls.s5
l---------arch/casiowin/easy-input/docs1
-rw-r--r--arch/casiowin/easy-input/docs/index.en.md (renamed from docs/casiowin/easy-input/index.en.md)5
-rw-r--r--arch/casiowin/easy-input/include/EasyInput.h29
-rw-r--r--arch/casiowin/easy-input/src/_syscalls.s25
-rw-r--r--arch/casiowin/easy-input/src/_syscalls.src18
-rw-r--r--arch/casiowin/easy-input/src/_syscalls.sx26
l---------arch/casiowin/fxlib/docs1
-rw-r--r--arch/casiowin/fxlib/docs/char.en.md (renamed from docs/casiowin/fxlib/char.en.md)0
-rw-r--r--arch/casiowin/fxlib/docs/clock.en.md (renamed from docs/casiowin/fxlib/clock.en.md)0
-rw-r--r--arch/casiowin/fxlib/docs/comm.en.md (renamed from docs/casiowin/fxlib/comm.en.md)0
-rw-r--r--arch/casiowin/fxlib/docs/draw.en.md (renamed from docs/casiowin/fxlib/draw.en.md)0
-rw-r--r--arch/casiowin/fxlib/docs/file.en.md (renamed from docs/casiowin/fxlib/file.en.md)0
-rw-r--r--arch/casiowin/fxlib/docs/index.en.md (renamed from docs/casiowin/fxlib/index.en.md)0
-rw-r--r--arch/casiowin/fxlib/docs/keys.en.md (renamed from docs/casiowin/fxlib/keys.en.md)0
-rw-r--r--arch/casiowin/fxlib/docs/timer.en.md (renamed from docs/casiowin/fxlib/timer.en.md)0
-rw-r--r--arch/casiowin/fxlib/include/fxlib/battery.h17
-rw-r--r--arch/casiowin/fxlib/include/fxlib/bcd.h31
-rw-r--r--arch/casiowin/fxlib/include/fxlib/clock.h22
-rw-r--r--arch/casiowin/fxlib/include/fxlib/comm.h149
-rw-r--r--arch/casiowin/fxlib/include/fxlib/display.h158
-rw-r--r--arch/casiowin/fxlib/include/fxlib/file.h138
-rw-r--r--arch/casiowin/fxlib/include/fxlib/keyboard.h80
-rw-r--r--arch/casiowin/g1a.ld4
-rw-r--r--arch/casiowin/info.yml2
l---------arch/casiowin/libfxsys/docs1
-rw-r--r--arch/casiowin/libfxsys/docs/index.en.md (renamed from docs/casiowin/libfxsys/index.en.md)0
l---------arch/casiowin/monochromelib/docs1
-rw-r--r--arch/casiowin/monochromelib/docs/bmp.en.md (renamed from docs/casiowin/monochromelib/bmp.en.md)0
-rw-r--r--arch/casiowin/monochromelib/docs/draw.en.md (renamed from docs/casiowin/monochromelib/draw.en.md)0
-rw-r--r--arch/casiowin/monochromelib/docs/index.en.md (renamed from docs/casiowin/monochromelib/index.en.md)0
-rw-r--r--arch/casiowin/monochromelib/docs/screen.en.md (renamed from docs/casiowin/monochromelib/screen.en.md)0
-rw-r--r--arch/casiowin/monochromelib/docs/vram.en.md (renamed from docs/casiowin/monochromelib/vram.en.md)0
-rw-r--r--arch/info.yml1
-rw-r--r--copyright.yml15
-rw-r--r--docs/authors.en.md3
-rw-r--r--docs/building.en.md4
-rw-r--r--docs/casiowin/core/index.en.md6
-rw-r--r--docs/coding.en.md4
-rw-r--r--docs/contributing.en.md8
-rw-r--r--docs/docs.en.md47
-rw-r--r--docs/licensing.en.md2
-rw-r--r--docs/todo.en.md4
-rwxr-xr-xtools/Internals/args.py7
-rwxr-xr-xtools/Internals/build/__init__.py16
-rwxr-xr-xtools/Internals/build/gnu_ar.py22
-rwxr-xr-xtools/Internals/build/gnu_as.py32
-rwxr-xr-xtools/Internals/build/gnu_gcc.py2
-rwxr-xr-xtools/Internals/build/utils/bfd.py7
-rw-r--r--tools/Internals/headers/__init__.py407
-rw-r--r--tools/Internals/headers/manager.py409
-rwxr-xr-xtools/Internals/module.py74
-rw-r--r--tools/Internals/topc.py96
-rwxr-xr-xtools/configure.py17
l---------tools/docs1
-rwxr-xr-xtools/make.py23
99 files changed, 1144 insertions, 970 deletions
diff --git a/arch/all/compiler-gcc/bits/compiler/end.h b/arch/all/compiler-gcc/bits/compiler/end.h
deleted file mode 100644
index 69331c3..0000000
--- a/arch/all/compiler-gcc/bits/compiler/end.h
+++ /dev/null
@@ -1 +0,0 @@
-#endif
diff --git a/arch/all/compiler-gcc/bits/compiler/start.h b/arch/all/compiler-gcc/bits/compiler/start.h
deleted file mode 100644
index 32778d9..0000000
--- a/arch/all/compiler-gcc/bits/compiler/start.h
+++ /dev/null
@@ -1 +0,0 @@
-#if __GNUC_PREREQ(0, 0)
diff --git a/arch/all/compiler-gcc/docs b/arch/all/compiler-gcc/docs
deleted file mode 120000
index f192e0e..0000000
--- a/arch/all/compiler-gcc/docs
+++ /dev/null
@@ -1 +0,0 @@
-../../../docs/all/compiler-gcc \ No newline at end of file
diff --git a/docs/all/compiler-gcc/index.en.md b/arch/all/compiler-gcc/docs/index.en.md
index 58bae30..58bae30 100644
--- a/docs/all/compiler-gcc/index.en.md
+++ b/arch/all/compiler-gcc/docs/index.en.md
diff --git a/arch/all/compiler-renesas/docs b/arch/all/compiler-renesas/docs
deleted file mode 120000
index 720e2a8..0000000
--- a/arch/all/compiler-renesas/docs
+++ /dev/null
@@ -1 +0,0 @@
-../../../docs/all/compiler-renesas \ No newline at end of file
diff --git a/docs/all/compiler-renesas/index.en.md b/arch/all/compiler-renesas/docs/index.en.md
index cbac093..cbac093 100644
--- a/docs/all/compiler-renesas/index.en.md
+++ b/arch/all/compiler-renesas/docs/index.en.md
diff --git a/arch/all/core-sh/docs b/arch/all/core-sh/docs
deleted file mode 120000
index ff1b9c8..0000000
--- a/arch/all/core-sh/docs
+++ /dev/null
@@ -1 +0,0 @@
-../../../docs/all/core-sh \ No newline at end of file
diff --git a/docs/all/core-sh/bits.en.md b/arch/all/core-sh/docs/bits.en.md
index 2dbbc79..2dbbc79 100644
--- a/docs/all/core-sh/bits.en.md
+++ b/arch/all/core-sh/docs/bits.en.md
diff --git a/docs/all/core-sh/index.en.md b/arch/all/core-sh/docs/index.en.md
index 8e90b9d..8e90b9d 100644
--- a/docs/all/core-sh/index.en.md
+++ b/arch/all/core-sh/docs/index.en.md
diff --git a/arch/all/core/docs b/arch/all/core/docs
deleted file mode 120000
index 3513ac8..0000000
--- a/arch/all/core/docs
+++ /dev/null
@@ -1 +0,0 @@
-../../../docs/all/core/ \ No newline at end of file
diff --git a/docs/all/core/bits.en.md b/arch/all/core/docs/bits.en.md
index 9973adc..9973adc 100644
--- a/docs/all/core/bits.en.md
+++ b/arch/all/core/docs/bits.en.md
diff --git a/docs/all/core/index.en.md b/arch/all/core/docs/index.en.md
index 3422bf6..3422bf6 100644
--- a/docs/all/core/index.en.md
+++ b/arch/all/core/docs/index.en.md
diff --git a/arch/all/helloworld/docs/index.en.md b/arch/all/helloworld/docs/index.en.md
new file mode 100644
index 0000000..728d943
--- /dev/null
+++ b/arch/all/helloworld/docs/index.en.md
@@ -0,0 +1,13 @@
+---
+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:
+
+{% highlight c linenos %}
+void helloworld(const char *string);
+{% endhighlight %}
+
+A newline is printed after the string. If the given string is `NULL`,
+`"hello, world"` is printed, followed by a newline.
diff --git a/arch/all/helloworld/include/helloworld.h b/arch/all/helloworld/include/helloworld.h
index 6e777fd..b6ba92d 100644
--- a/arch/all/helloworld/include/helloworld.h
+++ b/arch/all/helloworld/include/helloworld.h
@@ -28,4 +28,7 @@
* The fact that you are presently reading this means you have had knowledge of
* the CeCILL-C license and that you accept its terms.
* ************************************************************************* */
-extern void helloworld _OF((void));
+#include <cdefs.h>
+
+_EXTERN void helloworld
+ _OF((const char *__string));
diff --git a/arch/all/helloworld/info.yml b/arch/all/helloworld/info.yml
index 5ac25b5..346efea 100644
--- a/arch/all/helloworld/info.yml
+++ b/arch/all/helloworld/info.yml
@@ -1,5 +1,5 @@
%YAML 1.2
---
magic: potatosdk-1.0
-description: The "Hello world" module, for demonstration purposes.
+description: The "hello, world" module, for demonstration purposes.
license: free
diff --git a/arch/all/helloworld/src/helloworld.c b/arch/all/helloworld/src/helloworld.c
index 20562d8..22cd61e 100644
--- a/arch/all/helloworld/src/helloworld.c
+++ b/arch/all/helloworld/src/helloworld.c
@@ -31,10 +31,12 @@
#include <helloworld.h>
#include <stdio.h>
-/* This function prints the traditional "hello, world" message to
- * standard output. */
+/* This function prints a message to the standard output.
+ * By default, the traditional "hello, world" message. */
-void hello_world(void)
+void hello_world(const char *string)
{
- printf("hello, world\n");
+ if (!string)
+ string = "hello, world";
+ puts(string);
}
diff --git a/arch/all/iconv/docs b/arch/all/iconv/docs
deleted file mode 120000
index 751f18d..0000000
--- a/arch/all/iconv/docs
+++ /dev/null
@@ -1 +0,0 @@
-../../../docs/all/iconv \ No newline at end of file
diff --git a/docs/all/iconv/index.en.md b/arch/all/iconv/docs/index.en.md
index c6d91ed..c6d91ed 100644
--- a/docs/all/iconv/index.en.md
+++ b/arch/all/iconv/docs/index.en.md
diff --git a/arch/all/info.yml b/arch/all/info.yml
index 9c712ba..b3a7ca1 100644
--- a/arch/all/info.yml
+++ b/arch/all/info.yml
@@ -9,9 +9,6 @@ default:
- all/core-sh
- all/compiler-gcc
- all/compiler-renesas
- - all/compiler-sdcc
- - all/compiler-turbo
- - all/compiler-xlc
- all/iconv
c++:
- all/cpp
diff --git a/arch/all/io/docs b/arch/all/io/docs
deleted file mode 120000
index 2ef0407..0000000
--- a/arch/all/io/docs
+++ /dev/null
@@ -1 +0,0 @@
-../../../docs/all/io \ No newline at end of file
diff --git a/docs/all/io/index.en.md b/arch/all/io/docs/index.en.md
index 4f60676..4f60676 100644
--- a/docs/all/io/index.en.md
+++ b/arch/all/io/docs/index.en.md
diff --git a/arch/all/math/docs b/arch/all/math/docs
deleted file mode 120000
index c519b51..0000000
--- a/arch/all/math/docs
+++ /dev/null
@@ -1 +0,0 @@
-../../../docs/all/math \ No newline at end of file
diff --git a/docs/all/math/index.en.md b/arch/all/math/docs/index.en.md
index a51fcb0..a51fcb0 100644
--- a/docs/all/math/index.en.md
+++ b/arch/all/math/docs/index.en.md
diff --git a/arch/all/mem/docs b/arch/all/mem/docs
deleted file mode 120000
index 895dd70..0000000
--- a/arch/all/mem/docs
+++ /dev/null
@@ -1 +0,0 @@
-../../../docs/all/mem \ No newline at end of file
diff --git a/docs/all/mem/index.en.md b/arch/all/mem/docs/index.en.md
index 9b190b8..9b190b8 100644
--- a/docs/all/mem/index.en.md
+++ b/arch/all/mem/docs/index.en.md
diff --git a/docs/all/mem/tweaking.en.md b/arch/all/mem/docs/tweaking.en.md
index 10aff32..10aff32 100644
--- a/docs/all/mem/tweaking.en.md
+++ b/arch/all/mem/docs/tweaking.en.md
diff --git a/arch/all/stdcocorico/docs b/arch/all/stdcocorico/docs
deleted file mode 120000
index f4b8be9..0000000
--- a/arch/all/stdcocorico/docs
+++ /dev/null
@@ -1 +0,0 @@
-../../../docs/all/stdcocorico \ No newline at end of file
diff --git a/docs/all/stdcocorico/index.en.md b/arch/all/stdcocorico/docs/index.en.md
index 67464b9..67464b9 100644
--- a/docs/all/stdcocorico/index.en.md
+++ b/arch/all/stdcocorico/docs/index.en.md
diff --git a/arch/all/string/docs b/arch/all/string/docs
deleted file mode 120000
index 890a62c..0000000
--- a/arch/all/string/docs
+++ /dev/null
@@ -1 +0,0 @@
-../../../docs/all/string \ No newline at end of file
diff --git a/docs/all/string/index.en.md b/arch/all/string/docs/index.en.md
index 7bca20b..7bca20b 100644
--- a/docs/all/string/index.en.md
+++ b/arch/all/string/docs/index.en.md
diff --git a/docs/all/string/memory.en.md b/arch/all/string/docs/memory.en.md
index 11e23ce..11e23ce 100644
--- a/docs/all/string/memory.en.md
+++ b/arch/all/string/docs/memory.en.md
diff --git a/docs/all/string/strings.en.md b/arch/all/string/docs/strings.en.md
index 7ebcf35..7ebcf35 100644
--- a/docs/all/string/strings.en.md
+++ b/arch/all/string/docs/strings.en.md
diff --git a/arch/all/string/include/string.h b/arch/all/string/include/string.h
index d01bf10..ea03a6b 100644
--- a/arch/all/string/include/string.h
+++ b/arch/all/string/include/string.h
@@ -57,6 +57,9 @@ _EXTERN _NONNULL(1, __dst) _NONNULL(2, __src) char* strcat
_EXTERN _NONNULL(1, __dst) _NONNULL(2, __src) char* strncat
_OF((char *__dst, const char *__src, size_t __n)) _THROW;
+_EXTERN _NONNULL(1, __dst) _NONNULL(2, __src) size_t strlcat
+ _OF((char *__dst, const char *__src, size_t __n)) _THROW;
+
/* Compare nul-terminated strings. */
_EXTERN _NONNULL(1, __s) _NONNULL(2, __t) _WUR int strcmp
diff --git a/arch/all/string/src/bsd/strlcat.c b/arch/all/string/src/bsd/strlcat.c
new file mode 100644
index 0000000..661fc56
--- /dev/null
+++ b/arch/all/string/src/bsd/strlcat.c
@@ -0,0 +1,25 @@
+#include <string.h>
+#ifndef __NO_STRLCAT
+
+/**
+ * strlcat:
+ * Catenate in a secure way.
+ *
+ * @arg dst the destination buffer.
+ * @arg src the source string.
+ * @arg n the destination buffer size.
+ * @return the full length.
+ */
+
+size_t strlcat(char *dst, const char *src, size_t n)
+{
+ size_t dl, sl;
+
+ dl = strnlen(dst, n);
+ sl = strlen(src);
+ if (n > dl + 1)
+ strncpy(dst + dl, src, n - dl);
+ return (dl + sl);
+}
+
+#endif
diff --git a/arch/casiowin/README.md b/arch/casiowin/README.md
deleted file mode 100644
index d1a0eff..0000000
--- a/arch/casiowin/README.md
+++ /dev/null
@@ -1,2 +0,0 @@
-# CASIOWIN (by CASIO)
-See `docs/casiowin/index.en.md`.
diff --git a/arch/casiowin/copyright.yml b/arch/casiowin/copyright.yml
new file mode 100644
index 0000000..94e925f
--- /dev/null
+++ b/arch/casiowin/copyright.yml
@@ -0,0 +1,5 @@
+%YAML 1.2
+---
+files: '*'
+copyright:
+- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
diff --git a/arch/casiowin/core-crt/docs b/arch/casiowin/core-crt/docs
deleted file mode 120000
index a49d3ae..0000000
--- a/arch/casiowin/core-crt/docs
+++ /dev/null
@@ -1 +0,0 @@
-../../../docs/casiowin/core-crt \ No newline at end of file
diff --git a/docs/casiowin/core-crt/index.en.md b/arch/casiowin/core-crt/docs/index.en.md
index 39969e5..39969e5 100644
--- a/docs/casiowin/core-crt/index.en.md
+++ b/arch/casiowin/core-crt/docs/index.en.md
diff --git a/arch/casiowin/core/docs b/arch/casiowin/core/docs
deleted file mode 120000
index a416bb2..0000000
--- a/arch/casiowin/core/docs
+++ /dev/null
@@ -1 +0,0 @@
-../../../docs/casiowin/core \ No newline at end of file
diff --git a/docs/casiowin/index.en.md b/arch/casiowin/core/docs/index.en.md
index 2119066..f6015ef 100644
--- a/docs/casiowin/index.en.md
+++ b/arch/casiowin/core/docs/index.en.md
@@ -42,3 +42,7 @@ All of these calculators use a simple and proprietary apps system, that
execute files under the G1A (« Graph OS 1.xx Application », although also
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
+the syscalls manually.
diff --git a/arch/casiowin/core/src/dirent/dirent.h b/arch/casiowin/core/src/dirent/dirent.h
index fb70891..edd3440 100644
--- a/arch/casiowin/core/src/dirent/dirent.h
+++ b/arch/casiowin/core/src/dirent/dirent.h
@@ -18,23 +18,50 @@
* ************************************************************************* */
#ifndef _LOCAL_DIRENT_H
# define _LOCAL_DIRENT_H
+# include <cdefs.h>
# include <dirent.h>
# include <errno.h>
-# include <fxlib/file.h>
-/* utility */
+typedef __uint16_t __dirent_fontchar;
+typedef struct {
+ unsigned short id;
+ unsigned short type;
+ unsigned long fsize;
+ unsigned long dsize;
+ unsigned long property;
+ unsigned long address;
+} __dirent_file_info;
+
+/* Errors for all functions. */
+
+# define _ENUMRATEEND -16
+
+/* Error conversion utility. */
+
extern int __errno_from_fileerr(int __ferr)
__THROW __pure;
-/* directory stream structure */
+/* Directory stream structure. */
+
struct _IO_DIR {
/* the find handle */
int handle;
int lasterr;
/* the information */
- FONTCHARACTER path[MAX_PATH];
- FILE_INFO info;
+ __dirent_file_info info;
+ __dirent_fontchar path[MAX_PATH];
};
+/* fxlib duplicates. */
+
+_EXTERN int __dirent_findfirst
+ _OF((const __dirent_fontchar* __pathname, int* __findhandle,
+ FONTCHARACTER* __foundfile, __dirent_file_info* __fileinfo)) _THROW;
+_EXTERN int __dirent_findnext
+ _OF((int __findhandle, __dirent_fontchar* __foundfile,
+ __dirent_file_info* __fileinfo)) _THROW;
+_EXTERN int __dirent_findclose
+ _OF((int __findhandle)) _THROW;
+
#endif /* _LOCAL_DIRENT_H */
diff --git a/arch/casiowin/core/src/dirent/open.c b/arch/casiowin/core/src/dirent/open.c
index c3152f5..e209e66 100644
--- a/arch/casiowin/core/src/dirent/open.c
+++ b/arch/casiowin/core/src/dirent/open.c
@@ -33,63 +33,60 @@
#include <string.h>
#define ENOMEM 10 /* FIXME */
-/**
- * opendir:
- * Open a directory stream.
- *
- * @arg path the stream path.
- * @return the stream pointer.
- */
+/* opendir: open the directory stream.
+ * 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)
{
- FONTCHARACTER *fpath; size_t fsize;
+ __dirent_fontchar *fpath = NULL; size_t fsize;
DIR *dir; int ret;
- /* get the FONTCHARACTER encoded path */
+ /* Get the FONTCHARACTER encoded path. */
fsize = mbstowcs(NULL, path, 0);
- if (fsize == (size_t)-1) { errno = EDOM; return (NULL); }
+ if (fsize == (size_t)-1) { errno = EDOM; goto fail; }
fpath = malloc(fsize + 1);
if (!fpath) { errno = ENOMEM; return (NULL); }
- /* initialize the handle */
+ /* Initialize the handle. */
dir = malloc(sizeof(DIR));
- if (!dir) { errno = ENOMEM; free(fpath); return (NULL); }
+ if (!dir) { errno = ENOMEM; goto fail; }
memset(dir, 0, sizeof(DIR));
dir->handle = -1;
- /* find the first file */
- ret = Bfile_FindFirst(fpath, &dir->handle, dir->path, &dir->info);
- free(fpath); dir->lasterr = ret;
- if (ret < 0 && dir->lasterr != IML_FILEERR_ENUMRATEEND) {
+ /* Find the first file. */
+ ret = __dirent_findfirst(fpath, &dir->handle, dir->path, &dir->info);
+ free(fpath);
+ if (ret < 0 && ret != _ENUMRATEEND) {
/* FIXME: return success if empty directory? */
- errno = __errno_from_fileerr(ret);
+ __set_errno(__errno_from_fileerr(ret));
free(dir);
return (NULL);
}
- /* the stream has been opened! */
+ /* The stream has been opened! */
+ dir->lasterr = ret;
return (dir);
+fail:
+ if (fpath)
+ free(fpath);
+ return (NULL);
}
-/**
- * closedir:
- * Close a directory stream.
- *
- * @arg dir the directory stream pointer.
- * @return 0 on success, -1 on error.
- */
+/* closedir: close the directory stream. */
int closedir(DIR *dir)
{
- /* close the handle */
- int ret = Bfile_FindClose(dir->handle);
+ int ret;
+
+ /* Close the handle. */
+ ret = __dirent_findclose(dir->handle);
if (ret < 0) {
errno = __errno_from_fileerr(ret);
return (-1);
}
- /* free and exit */
+ /* Free and exit. */
free(dir);
return (0);
}
diff --git a/arch/casiowin/core/src/dirent/read.c b/arch/casiowin/core/src/dirent/read.c
new file mode 100644
index 0000000..1ac2882
--- /dev/null
+++ b/arch/casiowin/core/src/dirent/read.c
@@ -0,0 +1,18 @@
+#include "dirent.h"
+
+/* readdir: read a directory entry.
+ * We're always one entry ahead: we'll read the next one, and spit the
+ * last one. */
+
+struct dirent* readdir(DIR *dirp)
+{
+ int ret;
+
+ ret = __dirent_findnext(dirp->handle, dirp->path, dirp->info);
+ if (ret < 0 && ret != _ENUMRATEEND) {
+ __set_errno(__errno_from_fileerr(ret));
+ return (NULL);
+ }
+
+
+}
diff --git a/arch/casiowin/core/src/dirent/syscalls.s b/arch/casiowin/core/src/dirent/syscalls.s
new file mode 100644
index 0000000..f0dd37b
--- /dev/null
+++ b/arch/casiowin/core/src/dirent/syscalls.s
@@ -0,0 +1,5 @@
+.include "../syscall.inc"
+
+syscall 0x43B ___dirent_findfirst
+syscall 0x43C ___dirent_findnext
+syscall 0x43D ___dirent_findclose
diff --git a/arch/casiowin/easy-input/docs b/arch/casiowin/easy-input/docs
deleted file mode 120000
index 53ce7e1..0000000
--- a/arch/casiowin/easy-input/docs
+++ /dev/null
@@ -1 +0,0 @@
-../../../docs/casiowin/easy-input \ No newline at end of file
diff --git a/docs/casiowin/easy-input/index.en.md b/arch/casiowin/easy-input/docs/index.en.md
index 6b5edbf..86ced12 100644
--- a/docs/casiowin/easy-input/index.en.md
+++ b/arch/casiowin/easy-input/docs/index.en.md
@@ -4,5 +4,6 @@ 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:
-http://www.planet-casio.com/Fr/logiciels/voir_un_logiciel_casio.php?showid=117
+[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/arch/casiowin/easy-input/include/EasyInput.h b/arch/casiowin/easy-input/include/EasyInput.h
index 6e5d287..5ed4fe4 100644
--- a/arch/casiowin/easy-input/include/EasyInput.h
+++ b/arch/casiowin/easy-input/include/EasyInput.h
@@ -83,22 +83,25 @@ typedef struct __EI_config {
/* Initialize the settings, edit one parameter. */
-extern void EI_init _OF((void)) __THROW;
-extern const void *EI_manage_config _OF((enum __EI_PARAM_TYPE __param,
- int __value)) __THROW;
+_EXTERN void EI_init
+ _OF((void)) _THROW;
+_EXTERN const void* 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;
+_EXTERN char* EI_input_string
+ _OF((int __length, const char *__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));
-extern int EI_check_char _OF((char __c, const char *__allowed));
+_EXTERN int EI_str_length
+ _OF((const char *__str)) _THROW;
+_EXTERN int EI_check_char
+ _OF((char __c, const char *__allowed));
/* Manage the cursor. */
@@ -109,7 +112,11 @@ typedef struct {
int graphic_mode;
} EI_cursor_settings;
-extern int EI_Cursor_SetPosition _OF((char __column, int __mode));
-extern int EI_Cursor_SetFlashOn _OF((char __flashstyle));
-extern void EI_Cursor_SetFlashOff _OF((void));
-extern int EI_Cursor_GetSettings _OF((EI_cursor_settings *__cursor_settings));
+_EXTERN int EI_Cursor_SetPosition
+ _OF((char __column, int __mode)) _THROW;
+_EXTERN int EI_Cursor_SetFlashOn
+ _OF((char __flashstyle)) _THROW;
+_EXTERN void EI_Cursor_SetFlashOff
+ _OF((void)) _THROW;
+_EXTERN int EI_Cursor_GetSettings
+ _OF((EI_cursor_settings *__cursor_settings)) _THROW;
diff --git a/arch/casiowin/easy-input/src/_syscalls.s b/arch/casiowin/easy-input/src/_syscalls.s
new file mode 100644
index 0000000..e875d1e
--- /dev/null
+++ b/arch/casiowin/easy-input/src/_syscalls.s
@@ -0,0 +1,25 @@
+/* Syscall macro, taken from the 'syscall.inc' file from the
+ * `casiowin/fxlib` module. */
+
+.macro syscall CODE NAME
+.section text
+.align 2
+.global \NAME
+.type \NAME , @function
+
+\NAME :
+ mov.l 1f, r2
+ mov.l 2f, r0
+ jmp @r2
+ nop
+1: .long 0x80010070
+2: .long \CODE
+.endm
+
+/* Local syscalls to EasyInput. */
+
+syscall 0x138 _EI_Cursor_SetPosition
+syscall 0x80F _EI_Cursor_GetSettings
+syscall 0x811 _EI_Cursor_SetFlashOn
+syscall 0x812 _EI_Cursor_SetFlashOff
+syscall 0x910 _EI_KBD_PutKey
diff --git a/arch/casiowin/easy-input/src/_syscalls.src b/arch/casiowin/easy-input/src/_syscalls.src
index 8af8244..597566a 100644
--- a/arch/casiowin/easy-input/src/_syscalls.src
+++ b/arch/casiowin/easy-input/src/_syscalls.src
@@ -1,21 +1,3 @@
-; *****************************************************************************
-; _syscalls.s -- Easy Input syscalls.
-; Copyright (C) 2015-2016 Louis "Dark Storm" Gatin <l.gatin@neuf.fr>
-;
-; This file is part of libcarrot.
-; libcarrot is free software; you can redistribute it and/or modify it
-; under the terms of the GNU Lesser General Public License as published by
-; the Free Software Foundation; either version 3.0 of the License,
-; or (at your option) any later version.
-;
-; libcarrot is distributed in the hope that it will be useful,
-; but WITHOUT ANY WARRANTY; without even the implied warranty of
-; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-; See the GNU Lesser General Public License for more details.
-;
-; You should have received a copy of the GNU Lesser General Public License
-; along with the libcarrot; if not, see <http://www.gnu.org/licenses/>.
-; *****************************************************************************
.SECTION P,CODE,ALIGN=4
.MACRO SYSCALL FUNO, SYSCALLNAME, TAIL=nop
diff --git a/arch/casiowin/easy-input/src/_syscalls.sx b/arch/casiowin/easy-input/src/_syscalls.sx
deleted file mode 100644
index 0860fdd..0000000
--- a/arch/casiowin/easy-input/src/_syscalls.sx
+++ /dev/null
@@ -1,26 +0,0 @@
-/* ****************************************************************************
- * _syscalls.sx -- Easy Input syscalls.
- * Copyright (C) 2015-2016 Louis "Dark Storm" Gatin <l.gatin@neuf.fr>
- * Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
- *
- * This file is part of libcarrot.
- * libcarrot is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3.0 of the License,
- * or (at your option) any later version.
- *
- * libcarrot is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with the libcarrot; if not, see <http://www.gnu.org/licenses/>.
- * ************************************************************************* */
-# include <fxlib/syscall.h>
-
-__SYSCALL(0x138, _EI_Cursor_SetPosition)
-__SYSCALL(0x80F, _EI_Cursor_GetSettings)
-__SYSCALL(0x811, _EI_Cursor_SetFlashOn)
-__SYSCALL(0x812, _EI_Cursor_SetFlashOff)
-__SYSCALL(0x910, _EI_KBD_PutKey)
diff --git a/arch/casiowin/fxlib/docs b/arch/casiowin/fxlib/docs
deleted file mode 120000
index 158290c..0000000
--- a/arch/casiowin/fxlib/docs
+++ /dev/null
@@ -1 +0,0 @@
-../../../docs/casiowin/fxlib \ No newline at end of file
diff --git a/docs/casiowin/fxlib/char.en.md b/arch/casiowin/fxlib/docs/char.en.md
index b6e7600..b6e7600 100644
--- a/docs/casiowin/fxlib/char.en.md
+++ b/arch/casiowin/fxlib/docs/char.en.md
diff --git a/docs/casiowin/fxlib/clock.en.md b/arch/casiowin/fxlib/docs/clock.en.md
index 114ab8d..114ab8d 100644
--- a/docs/casiowin/fxlib/clock.en.md
+++ b/arch/casiowin/fxlib/docs/clock.en.md
diff --git a/docs/casiowin/fxlib/comm.en.md b/arch/casiowin/fxlib/docs/comm.en.md
index af4f5a7..af4f5a7 100644
--- a/docs/casiowin/fxlib/comm.en.md
+++ b/arch/casiowin/fxlib/docs/comm.en.md
diff --git a/docs/casiowin/fxlib/draw.en.md b/arch/casiowin/fxlib/docs/draw.en.md
index 07df963..07df963 100644
--- a/docs/casiowin/fxlib/draw.en.md
+++ b/arch/casiowin/fxlib/docs/draw.en.md
diff --git a/docs/casiowin/fxlib/file.en.md b/arch/casiowin/fxlib/docs/file.en.md
index 8ffacd9..8ffacd9 100644
--- a/docs/casiowin/fxlib/file.en.md
+++ b/arch/casiowin/fxlib/docs/file.en.md
diff --git a/docs/casiowin/fxlib/index.en.md b/arch/casiowin/fxlib/docs/index.en.md
index 8853592..8853592 100644
--- a/docs/casiowin/fxlib/index.en.md
+++ b/arch/casiowin/fxlib/docs/index.en.md
diff --git a/docs/casiowin/fxlib/keys.en.md b/arch/casiowin/fxlib/docs/keys.en.md
index 88f88d4..88f88d4 100644
--- a/docs/casiowin/fxlib/keys.en.md
+++ b/arch/casiowin/fxlib/docs/keys.en.md
diff --git a/docs/casiowin/fxlib/timer.en.md b/arch/casiowin/fxlib/docs/timer.en.md
index 781398c..781398c 100644
--- a/docs/casiowin/fxlib/timer.en.md
+++ b/arch/casiowin/fxlib/docs/timer.en.md
diff --git a/arch/casiowin/fxlib/include/fxlib/battery.h b/arch/casiowin/fxlib/include/fxlib/battery.h
index b299999..31e5513 100644
--- a/arch/casiowin/fxlib/include/fxlib/battery.h
+++ b/arch/casiowin/fxlib/include/fxlib/battery.h
@@ -30,8 +30,8 @@
* ************************************************************************* */
#include <fxlib/cdefs.h>
#if _USE_FXLIB_UNOFFICIAL
-__BEGIN_NAMESPACE_FXLIB
-__BEGIN_DECLS
+_BEGIN_NAMESPACE_FXLIB
+_BEGIN_DECLS
/* Get the battery status.
* If you want to have a delay before accessing the AD converter for more
@@ -51,12 +51,15 @@ __BEGIN_DECLS
# define battery_flag_delay 0x0001
/* Get the status */
-extern int Battery_IsLow_Delay _OF((int __flags)) __THROW;
-extern int Battery_GetStatus _OF((int __flags)) __THROW;
+_EXTERN int Battery_IsLow_Delay
+ _OF((int __flags)) _THROW;
+_EXTERN int Battery_GetStatus
+ _OF((int __flags)) _THROW;
/* Do that, and print a message */
-extern int Battery_DisplayLowStatus _OF((int __flags)) __THROW;
+_EXTERN int Battery_DisplayLowStatus
+ _OF((int __flags)) _THROW;
-__END_DECLS
-__END_NAMESPACE_FXLIB
+_END_DECLS
+_END_NAMESPACE_FXLIB
#endif
diff --git a/arch/casiowin/fxlib/include/fxlib/bcd.h b/arch/casiowin/fxlib/include/fxlib/bcd.h
index 713167f..c699c34 100644
--- a/arch/casiowin/fxlib/include/fxlib/bcd.h
+++ b/arch/casiowin/fxlib/include/fxlib/bcd.h
@@ -30,8 +30,8 @@
* ************************************************************************* */
#include <fxlib/cdefs.h>
#if _USE_FXLIB_UNOFFICIAL
-__BEGIN_NAMESPACE_FXLIB
-__BEGIN_DECLS
+_BEGIN_NAMESPACE_FXLIB
+_BEGIN_DECLS
/* ************************************************************************* */
/* BCD structures */
@@ -61,25 +61,24 @@ typedef struct tag_BCD BCD;
/* Methods */
/* ************************************************************************* */
/* BCD to internal */
-extern __nonnull(1, __internal) __nonnull(2, __source)
-int BCDtoInternal _OF((bcd_t *__internal, const bcdval_t *__source)) __THROW;
+_EXTERN _NONNULL(1, __internal) _NONNULL(2, __source) int BCDtoInternal
+ _OF((bcd_t *__internal, const bcdval_t *__source)) _THROW;
/* 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;
-extern __nonnull(1, __dest) __nonnull(2, __source)
-int Num_BCDToUint _OF((unsigned int *__dest, bcd_t *__source)) __THROW;
+_EXTERN _NONNULL(1, __source) _NONNULL(2, __dest) int Num_UIntToBCD
+ _OF((const unsigned int *__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 */
-extern __nonnull(1, __formula) __nonnull(3, __opcode)
-void CalculateExpression _OF((char **__formula, char __opcode[2],
- bcdval_t *__result, int __copyfirst)) __THROW;
+_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 */
-extern __nonnull(1, __value) __nonnull(2, __result)
-int BCD_GetNotANumberValue _OF((const unsigned char *__value,
- unsigned char *__result)) __THROW;
+_EXTERN _NONNULL(1, __value) _NONNULL(2, __result) int BCD_GetNotANumberValue
+ _OF((const unsigned char *__value, unsigned char *__result)) _THROW;
-__END_DECLS
-__END_NAMESPACE_FXLIB
+_END_DECLS
+_END_NAMESPACE_FXLIB
#endif
diff --git a/arch/casiowin/fxlib/include/fxlib/clock.h b/arch/casiowin/fxlib/include/fxlib/clock.h
index 92e3018..9fd3614 100644
--- a/arch/casiowin/fxlib/include/fxlib/clock.h
+++ b/arch/casiowin/fxlib/include/fxlib/clock.h
@@ -30,15 +30,19 @@
* ************************************************************************* */
#include <fxlib/cdefs.h>
#if _USE_FXLIB_UNOFFICIAL
-__BEGIN_NAMESPACE_FXLIB
-__BEGIN_DECLS
+_BEGIN_NAMESPACE_FXLIB
+_BEGIN_DECLS
-extern void RTC_Reset _OF((int __unknown)) __THROW;
-extern void RTC_GetTime _OF((unsigned int *__a, unsigned int *__b,
- unsigned int *__c, unsigned int *__d)) __THROW;
-extern int RTC_GetTicks _OF((void)) __THROW;
-extern void RTC_SetDateTime _OF((unsigned char *__a)) __THROW;
+_EXTERN void RTC_Reset
+ _OF((int __unknown)) _THROW;
+_EXTERN void RTC_GetTime
+ _OF((unsigned int *__a, unsigned int *__b,
+ unsigned int *__c, unsigned int *__d)) _THROW;
+_EXTERN int RTC_GetTicks
+ _OF((void)) _THROW;
+_EXTERN void RTC_SetDateTime
+ _OF((unsigned char *__a)) _THROW;
-__END_DECLS
-__END_NAMESPACE_FXLIB
+_END_DECLS
+_END_NAMESPACE_FXLIB
#endif
diff --git a/arch/casiowin/fxlib/include/fxlib/comm.h b/arch/casiowin/fxlib/include/fxlib/comm.h
index f556a94..e5c606c 100644
--- a/arch/casiowin/fxlib/include/fxlib/comm.h
+++ b/arch/casiowin/fxlib/include/fxlib/comm.h
@@ -31,34 +31,41 @@
#include <fxlib/cdefs.h>
#include <commbios.h>
#if _USE_FXLIB_UNOFFICIAL
-__BEGIN_NAMESPACE_FXLIB
-__BEGIN_DECLS
+_BEGIN_NAMESPACE_FXLIB
+_BEGIN_DECLS
/* ************************************************************************* */
/* 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)
+_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 */
-extern int Comm_Close _OF((int __immediate)) __THROW;
+_EXTERN int Comm_Close
+ _OF((int __immediate)) _THROW;
/* Check the communication status */
-extern int Comm_IsUSB _OF((void)) __THROW;
-# define Comm_GetCurrentSelector() Comm_IsUSB()
+_EXTERN int Comm_IsUSB
+ _OF((void)) _THROW;
+# define Comm_GetCurrentSelector() \
+ Comm_IsUSB()
/* ************************************************************************* */
/* Raw communication utilities */
/* ************************************************************************* */
/* receive data */
-extern __nonnull(1, __result) int Comm_SpyByte _OF((unsigned char *__result))
- __THROW;
-extern __nonnull(1, __result) int Comm_ReadByte _OF((unsigned char *__result))
- __THROW;
-extern __nonnull(1, __buffer) int Comm_ReadBytes _OF((char *__buffer,
- int __count)) __THROW;
+_EXTERN _NONNULL(1, __result) int Comm_SpyByte
+ _OF((unsigned char *__result)) _THROW;
+_EXTERN _NONNULL(1, __result) int Comm_ReadByte
+ _OF((unsigned char *__result)) _THROW;
+_EXTERN _NONNULL(1, __buffer) int Comm_ReadBytes
+ _OF((char *__buffer, int __count)) _THROW;
# define Comm_Spy0thByte(_RES) \
Comm_SpyByte(_RES)
# define Comm_ReadOneByte(__BUF) \
@@ -67,9 +74,10 @@ extern __nonnull(1, __buffer) int Comm_ReadBytes _OF((char *__buffer,
Comm_ReadBytes(__BUF, __COUNT)
/* send data */
-extern int Comm_SendByte _OF((unsigned char __byte)) __THROW;
-extern __nonnull(1, __buffer) int Comm_SendBytes OF((unsigned char *__buffer,
- int __requested_count)) __THROW;
+_EXTERN int Comm_SendByte
+ _OF((unsigned char __byte)) _THROW;
+_EXTERN _NONNULL(1, __buffer) int Comm_SendBytes
+ _OF((unsigned char *__buffer, int __requested_count)) _THROW;
# define Comm_TransmitOneByte(_BYTE) \
Comm_SendByte(_BYTE)
# define Comm_TransmitNBytes(_BUF, _COUNT) \
@@ -78,8 +86,8 @@ extern __nonnull(1, __buffer) int Comm_SendBytes OF((unsigned char *__buffer,
Comm_SendBytes(_BUF, _COUNT)
/* 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;
+_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) \
@@ -88,18 +96,14 @@ extern int Comm_WaitForAnyBuffer _OF((int __timeout, int __receive,
/* Protocol 7 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 _OF((unsigned short *__value,
- unsigned short *__result)) __THROW;
-extern __nonnull(2, __result)
-void Comm_ByteToHex _OF((unsigned char __value,
- unsigned char *__result)) __THROW;
-extern __nonnull(2, __result)
-void Comm_WordToHex _OF((unsigned short __value,
- unsigned char *__result)) __THROW;
+_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
+ _OF((unsigned short *__value, unsigned short *__result)) _THROW;
+_EXTERN _NONNULL(2, __result) void Comm_ByteToHex
+ _OF((unsigned char __value, unsigned char *__result)) _THROW;
+_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)
@@ -108,53 +112,54 @@ void Comm_WordToHex _OF((unsigned short __value,
# define WordToHex(_VAL, _RES) Comm_WordToHex(_VAL, _RES)
/* 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, 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, unsigned char *__dest, unsigned short *__count))
- __THROW;
+_EXTERN _NONNULL(1, __source) _NONNULL(3, __dest) _NONNULL(4, __count)
+int Comm_Padding_5C
+ _OF((const unsigned char *__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,
+ unsigned char *__dest, unsigned short *__count)) _THROW;
/* ************************************************************************* */
/* Protocol 7 packet management functions */
/* ************************************************************************* */
-/* Get a packet */
-extern __nonnull(1, __type)
-int Comm_IsValidPacketAvailable _OF((unsigned char *__type)) __THROW;
-extern __nonnull(1, __packet)
-int Comm_GetPacket _OF((comm_packet_t *__packet)) __THROW;
+/* Get a packet. */
-/* Prepare a packet */
-extern __nonnull(1, __packet) __nonnull(3, __data)
-int Comm_PrepareAckPacket _OF((comm_packet_t *__packet,
- unsigned char __subtype, void *__data, unsigned short __size)) __THROW;
-extern __nonnull(1, __packet)
-int Comm_PrepareErrorPacket _OF((comm_packet_t *__packet,
- unsigned char __subtype)) __THROW;
-extern __nonnull(1, __packet)
-int Comm_PrepareTerminatePacket _OF((comm_packet_t *__packet,
- unsigned char __subtype)) __THROW;
-extern __nonnull(1, __packet)
-int Comm_PrepareRoleswapPacket _OF((comm_packet_t *__packet,
- unsigned char __subtype)) __THROW;
-extern __nonnull(1, __packet)
-int Comm_PrepareCheckPacket _OF((comm_packet_t *__packet,
- unsigned char __subtype)) __THROW;
-extern __nonnull(1, __packet) __nonnull(3, __data)
-int Comm_PrepareCommandPacket _OF((comm_packet_t *__packet,
- unsigned char __subtype, void *__data, unsigned short __size)) __THROW;
-extern __nonnull(1, __packet) __nonnull(3, __data)
-int Comm_PrepareDataPacket _OF((comm_packet_t *__packet,
- unsigned char subtype, void *__data, unsigned short __size)) __THROW;
+_EXTERN _NONNULL(1, __type) int Comm_IsValidPacketAvailable
+ _OF((unsigned char *__type)) _THROW;
+_EXTERN _NONNULL(1, __packet) int Comm_GetPacket
+ _OF((comm_packet_t *__packet)) _THROW;
+
+/* Prepare a packet. */
+
+_EXTERN _NONNULL(1, __packet) _NONNULL(3, __data) int Comm_PrepareAckPacket
+ _OF((comm_packet_t *__packet, unsigned char __subtype,
+ void *__data, unsigned short __size)) _THROW;
+_EXTERN _NONNULL(1, __packet) int Comm_PrepareErrorPacket
+ _OF((comm_packet_t *__packet, unsigned char __subtype)) _THROW;
+_EXTERN _NONNULL(1, __packet) int Comm_PrepareTerminatePacket
+ _OF((comm_packet_t *__packet, unsigned char __subtype)) _THROW;
+_EXTERN _NONNULL(1, __packet) int Comm_PrepareRoleswapPacket
+ _OF((comm_packet_t *__packet, unsigned char __subtype)) _THROW;
+_EXTERN _NONNULL(1, __packet) int Comm_PrepareCheckPacket
+ _OF((comm_packet_t *__packet, unsigned char __subtype)) _THROW;
+_EXTERN _NONNULL(1, __packet) _NONNULL(3, __data) int Comm_PrepareCommandPacket
+ _OF((comm_packet_t *__packet, unsigned char __subtype,
+ void *__data, unsigned short __size)) _THROW;
+_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 */
-extern int Comm_SendPacket _OF((comm_packet_t *__packet));
+_EXTERN int Comm_SendPacket
+ _OF((comm_packet_t *__packet)) _THROW;
/* Send an OHP (TYP01) packet */
-extern void AutoImageTransfer_OHP _OF((void));
-extern void USB_CaptureDisplay _OF((void));
+_EXTERN void AutoImageTransfer_OHP
+ _OF((void)) _THROW;
+_EXTERN void USB_CaptureDisplay
+ _OF((void)) _THROW;
-__END_DECLS
-__END_NAMESPACE_FXLIB
+_END_DECLS
+_END_NAMESPACE_FXLIB
#endif
diff --git a/arch/casiowin/fxlib/include/fxlib/display.h b/arch/casiowin/fxlib/include/fxlib/display.h
index 8c11a7a..dde6cb6 100644
--- a/arch/casiowin/fxlib/include/fxlib/display.h
+++ b/arch/casiowin/fxlib/include/fxlib/display.h
@@ -37,125 +37,129 @@ __BEGIN_DECLS
/* Interact with the VRAM/display driver */
/* ************************************************************************* */
/* Clear the screen/VRAM */
-extern void Bdisp_AllClr_DD _OF((void)) __THROW;
-extern void Bdisp_AllClr_VRAM _OF((void)) __THROW;
-extern void Bdisp_AllClr_DDVRAM _OF((void)) __THROW;
+_EXTERN void Bdisp_AllClr_DD
+ _OF((void)) _THROW;
+_EXTERN void Bdisp_AllClr_VRAM
+ _OF((void)) _THROW;
+_EXTERN void Bdisp_AllClr_DDVRAM
+ _OF((void)) _THROW;
/* Clear an area of the screen/vram */
-extern __nonnull(1, __pArea)
-void Bdisp_AreaClr_DD _OF((const DISPBOX *__pArea)) __THROW;
-extern __nonnull(1, __pArea)
-void Bdisp_AreaClr_VRAM _OF((const DISPBOX *__pArea)) __THROW;
-extern __nonnull(1, __pArea)
-void Bdisp_AreaClr_DDVRAM _OF((const DISPBOX *__pArea)) __THROW;
+_EXTERN _NONNULL(1, __pArea) void Bdisp_AreaClr_DD
+ _OF((const DISPBOX *__pArea)) _THROW;
+_EXTERN _NONNULL(1, __pArea) void Bdisp_AreaClr_VRAM
+ _OF((const DISPBOX *__pArea)) _THROW;
+_EXTERN _NONNULL(1, __pArea) void Bdisp_AreaClr_DDVRAM
+ _OF((const DISPBOX *__pArea)) _THROW;
/* Reverse an area of the VRAM */
-extern void Bdisp_AreaReverseVRAM _OF((int __x1, int __y1, int __x2, int __y2))
- __THROW;
+_EXTERN void Bdisp_AreaReverseVRAM
+ _OF((int __x1, int __y1, int __x2, int __y2)) _THROW;
/* Update the display */
-extern void Bdisp_PutDisp_DD _OF((void)) __THROW;
-extern __nonnull(1, __PutDispArea)
-void Bdisp_PutDispArea_DD _OF((const DISPBOX *__PutDispArea))
- __THROW;
+_EXTERN void Bdisp_PutDisp_DD
+ _OF((void)) _THROW;
+_EXTERN _NONNULL(1, __PutDispArea) void Bdisp_PutDispArea_DD
+ _OF((const DISPBOX *__PutDispArea)) _THROW;
/* 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;
+_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 */
-extern __nonnull(1, __ReadArea) __nonnull(2, __ReadData)
-void Bdisp_ReadArea_DD _OF((const DISPBOX *__ReadArea,
- unsigned char *__ReadData)) __THROW;
-extern __nonnull(1, __ReadArea) __nonnull(2, __ReadData)
-void Bdisp_ReadArea_VRAM _OF((const DISPBOX *__ReadArea,
- unsigned char *__ReadData)) __THROW;
+_EXTERN _NONNULL(1, __ReadArea) _NONNULL(2, __ReadData) void Bdisp_ReadArea_DD
+ _OF((const DISPBOX *__ReadArea, unsigned char *__ReadData)) _THROW;
+_EXTERN _NONNULL(1, __ReadArea) _NONNULL(2, __ReadData)
+void Bdisp_ReadArea_VRAM
+ _OF((const DISPBOX *__ReadArea, unsigned char *__ReadData)) _THROW;
/* Get the VRAM address */
-extern void *Bdisp_GetVRAMAddress _OF((void)) __THROW;
+_EXTERN void* Bdisp_GetVRAMAddress
+ _OF((void)) _THROW;
/* Set a point (pixel) */
-extern void Bdisp_SetPoint_DD _OF((int __x, int __y,
- unsigned char __point)) __THROW;
-extern void Bdisp_SetPoint_VRAM _OF((int __x, int __y,
- unsigned char __point)) __THROW;
-extern void Bdisp_SetPoint_DDVRAM _OF((int __x, int __y,
- unsigned char __point)) __THROW;
+_EXTERN void Bdisp_SetPoint_DD
+ _OF((int __x, int __y, unsigned char __point)) _THROW;
+_EXTERN void Bdisp_SetPoint_VRAM
+ _OF((int __x, int __y, unsigned char __point)) _THROW;
+_EXTERN void Bdisp_SetPoint_DDVRAM
+ _OF((int __x, int __y, unsigned char __point)) _THROW;
/* Get a point (pixel) */
-extern __wur int Bdisp_GetPoint_VRAM _OF((int __x, int __y)) __THROW;
+_EXTERN _WUR int Bdisp_GetPoint_VRAM
+ _OF((int __x, int __y)) _THROW;
/* ************************************************************************* */
/* Drawing functions */
/* ************************************************************************* */
/* write a graph */
-extern __nonnull(1, __WriteGraph)
-void Bdisp_WriteGraph_DD _OF((const DISPGRAPH *__WriteGraph)) __THROW;
-extern __nonnull(1, __WriteGraph)
-void Bdisp_WriteGraph_VRAM _OF((const DISPGRAPH *__WriteGraph)) __THROW;
-extern __nonnull(1, __WriteGraph)
-void Bdisp_WriteGraph_DDVRAM _OF((const DISPGRAPH *__WriteGraph)) __THROW;
+_EXTERN _NONNULL(1, __WriteGraph) void Bdisp_WriteGraph_DD
+ _OF((const DISPGRAPH *__WriteGraph)) _THROW;
+_EXTERN _NONNULL(1, __WriteGraph) void Bdisp_WriteGraph_VRAM
+ _OF((const DISPGRAPH *__WriteGraph)) _THROW;
+_EXTERN _NONNULL(1, __WriteGraph) void Bdisp_WriteGraph_DDVRAM
+ _OF((const DISPGRAPH *__WriteGraph)) _THROW;
/* 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;
+_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 */
-extern __nonnull(1, __shape) void Bdisp_ShapeToVRAM _OF((shape_t *__shape))
- __THROW;
-extern __nonnull(1, __shape) void Bdisp_ShapeToDD _OF((shape_t *__shape))
- __THROW;
-extern __nonnull(1, __shape) void Bdisp_ShapeToVRAM_DD _OF((shape_t *__shape))
- __THROW;
+_EXTERN _NONNULL(1, __shape) void Bdisp_ShapeToVRAM
+ _OF((shape_t *__shape)) _THROW;
+_EXTERN _NONNULL(1, __shape) void Bdisp_ShapeToDD
+ _OF((shape_t *__shape)) _THROW;
+_EXTERN _NONNULL(1, __shape) void Bdisp_ShapeToVRAM_DD
+ _OF((shape_t *__shape)) _THROW;
/* Put a rectangle */
-extern void Bdisp_DrawRectangle _OF((int __x1, int __y1, int __x2, int __y2))
- __THROW;
+_EXTERN void Bdisp_DrawRectangle
+ _OF((int __x1, int __y1, int __x2, int __y2)) _THROW;
# endif
/* ************************************************************************* */
/* Text printing */
/* ************************************************************************* */
/* Change the cursor position */
-extern void locate _OF((int __x, int __y)) __THROW;
+_EXTERN void locate
+ _OF((int __x, int __y)) _THROW;
/* Print a string */
-extern __nonnull(1, __str) void Print _OF((const unsigned char *__str))
- __THROW;
-extern __nonnull(1, __str) void PrintRev _OF((const unsigned char *__str))
- __THROW;
+_EXTERN _NONNULL(1, __str) void Print
+ _OF((const unsigned char *__str)) _THROW;
+_EXTERN _NONNULL(1, __str) void PrintRev
+ _OF((const unsigned char *__str)) _THROW;
/* Print a character */
-extern __nonnull(1, __chr) void PrintC _OF((const unsigned char *__chr))
- __THROW;
-extern __nonnull(1, __str) void PrintRevC _OF((const unsigned char *__chr))
- __THROW;
+_EXTERN _NONNULL(1, __chr) void PrintC
+ _OF((const unsigned char *__chr)) _THROW;
+_EXTERN _NONNULL(1, __str) void PrintRevC
+ _OF((const unsigned char *__chr)) _THROW;
/* Print a line */
-extern __nonnull(1, __str)
-void PrintLine _OF((const unsigned char *__str, int __max)) __THROW;
-extern __nonnull(1, __str)
-void PrintRLine _OF((const unsigned char *__str, int __max)) __THROW;
+_EXTERN _NONNULL(1, __str) void PrintLine
+ _OF((const unsigned char *__str, int __max)) _THROW;
+_EXTERN _NONNULL(1, __str) void PrintRLine
+ _OF((const unsigned char *__str, int __max)) _THROW;
/* Print at a position */
-extern __nonnull(3, __str)
-void PrintXY _OF((int __x, int __y, const unsigned char *__str,
- int __type)) __THROW;
-extern __nonnull(3, __str)
-int PrintMini _OF((int __x, int __y, const unsigned char *__str,
- int __type)) __THROW;
+_EXTERN _NONNULL(3, __str) void PrintXY
+ _OF((int __x, int __y, const unsigned char *__str, int __type)) _THROW;
+_EXTERN _NONNULL(3, __str) int PrintMini
+ _OF((int __x, int __y, const unsigned char *__str, int __type)) _THROW;
/* Save and restore the display */
-extern void SaveDisp _OF((unsigned char __num)) __THROW;
-extern void RestoreDisp _OF((unsigned char __num)) __THROW;
+_EXTERN void SaveDisp
+ _OF((unsigned char __num)) _THROW;
+_EXTERN void RestoreDisp
+ _OF((unsigned char __num)) _THROW;
/* Make a pop-up window */
-extern void PopUpWin _OF((int __n)) __THROW;
+_EXTERN void PopUpWin
+ _OF((int __n)) _THROW;
-__END_DECLS
-__END_NAMESPACE_FXLIB
+_END_DECLS
+_END_NAMESPACE_FXLIB
diff --git a/arch/casiowin/fxlib/include/fxlib/file.h b/arch/casiowin/fxlib/include/fxlib/file.h
index b383d74..bc88e5a 100644
--- a/arch/casiowin/fxlib/include/fxlib/file.h
+++ b/arch/casiowin/fxlib/include/fxlib/file.h
@@ -31,8 +31,8 @@
#include <fxlib/cdefs.h>
#include <filebios.h>
#define MAX_PATH 50 /* a quick estimation */
-__BEGIN_NAMESPACE_FXLIB
-__BEGIN_DECLS
+_BEGIN_NAMESPACE_FXLIB
+_BEGIN_DECLS
/* ************************************************************************* */
/* Open and close files */
@@ -45,125 +45,115 @@ __BEGIN_DECLS
* or the error (one of the `IML_FILEERR_*` constants). */
#if _USE_FXLIB_UNOFFICIAL
-extern __nonnull(1, __filename)
-int Bfile_identify_device_OS _OF((const FONTCHARACTER *__filename))
- __THROW;
+_EXTERN _NONNULL(1, __filename) int Bfile_identify_device_OS
+ _OF((const FONTCHARACTER *__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;
+_EXTERN _NONNULL(1, __filename) _WUR int Bfile_OpenFile
+ _OF((const FONTCHARACTER *__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;
+_EXTERN _NONNULL(1, __filename) int Bfile_OpenFile_OS
+ _OF((const FONTCHARACTER *__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;
+_EXTERN _NONNULL(1, __name) _WUR int Bfile_OpenMainMemory
+ _OF((const unsigned char *__name)) _THROW;
/* Close a handle; should not be used to close a main memory handle! */
-extern int Bfile_CloseFile _OF((int __HANDLE)) __THROW;
+_EXTERN int Bfile_CloseFile
+ _OF((int __handle)) _THROW;
#if _USE_FXLIB_UNOFFICIAL
-extern int Bfile_CloseFile_OS _OF((int __HANDLE)) __THROW;
+_EXTERN int Bfile_CloseFile_OS
+ _OF((int __handle)) _THROW;
#endif
/* ************************************************************************* */
/* Basic interactions on the file */
/* ************************************************************************* */
/* Read, write, seek: */
-extern __nonnull(2, __buf)
-int Bfile_ReadFile _OF((int __HANDLE, void *__buf, int __size,
- int __readpos)) __THROW;
+_EXTERN _NONNULL(2, __buf) int Bfile_ReadFile
+ _OF((int __handle, void *__buf, int __size, int __readpos)) _THROW;
#if _USE_FXLIB_UNOFFICIAL
-extern __nonnull(2, __buf)
-int Bfile_ReadFile_OS _OF((int __HANDLE, void *__buf, int __size,
- int __readpos)) __THROW;
+_EXTERN _NONNULL(2, __buf) int Bfile_ReadFile_OS
+ _OF((int __handle, void *__buf, int __size, int __readpos)) _THROW;
#endif
-extern __nonnull(2, __buf)
-int Bfile_WriteFile _OF((int __HANDLE, const void *__buf, int __size))
- __THROW;
+_EXTERN _NONNULL(2, __buf) int Bfile_WriteFile
+ _OF((int __handle, const void *__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;
+_EXTERN _NONNULL(2, __buf) int Bfile_WriteFile_OS
+ _OF((int __handle, const void *__buf, int __size)) _THROW;
#endif
-extern int Bfile_SeekFile _OF((int __HANDLE, int __pos)) __THROW;
+_EXTERN int Bfile_SeekFile
+ _OF((int __handle, int __pos)) _THROW;
#if _USE_FXLIB_UNOFFICIAL
-extern int Bfile_SeekFile_OS _OF((int __HANDLE, int __pos)) __THROW;
+_EXTERN int Bfile_SeekFile_OS
+ _OF((int __handle, int __pos)) _THROW;
#endif
/* Get the file size: */
#if _USE_FXLIB_UNOFFICIAL
-extern int Bfile_GetFileSize _OF((int __HANDLE)) __THROW;
-extern __wur int Bfile_GetFileSize_OS _OF((int __HANDLE)) __THROW;
+_EXTERN int Bfile_GetFileSize
+ _OF((int __handle)) _THROW;
+_EXTERN _WUR int Bfile_GetFileSize_OS
+ _OF((int __handle)) _THROW;
#endif
/* ************************************************************************* */
/* Interact with storage devices */
/* ************************************************************************* */
/* Create files or directories: */
-extern __nonnull(1, __filename)
-int Bfile_CreateFile _OF((const FONTCHARACTER *__filename,
- int __size)) __THROW;
-extern __nonnull(1, __pathname)
-int Bfile_CreateDirectory _OF((const FONTCHARACTER *__pathname,
- int __size)) __THROW;
-extern __nonnull(1, __name)
-int Bfile_CreateMainMemory _OF((const unsigned char *__name))
- __THROW;
+_EXTERN _NONNULL(1, __filename) int Bfile_CreateFile
+ _OF((const FONTCHARACTER *__filename, int __size)) _THROW;
+_EXTERN _NONNULL(1, __pathname) int Bfile_CreateDirectory
+ _OF((const FONTCHARACTER *__pathname, int __size)) _THROW;
+_EXTERN _NONNULL(1, __name) int Bfile_CreateMainMemory
+ _OF((const unsigned char *__name)) _THROW;
/* Rename a file: */
-extern __nonnull(1, __oldname) __nonnull(2, __newname)
-int Bfile_RenameEntry _OF((const FONTCHARACTER *__oldname,
- const FONTCHARACTER *__newname)) __THROW;
-extern __nonnull(1, __oldname) __nonnull(2, __newname)
-int Bfile_RenameMainMemory _OF((const unsigned char *__oldname,
- const unsigned char *__newname)) __THROW;
+_EXTERN _NONNULL(1, __old) _NONNULL(2, __new) int Bfile_RenameEntry
+ _OF((const FONTCHARACTER *__old, const FONTCHARACTER *__new)) _THROW;
+_EXTERN _NONNULL(1, __old) _NONNULL(2, __new) int Bfile_RenameMainMemory
+ _OF((const unsigned char *__old, const unsigned char *__new)) _THROW;
/* Delete files: */
-extern __nonnull(1, __filename)
-int Bfile_DeleteEntry _OF((const FONTCHARACTER *__filename,
- int __mode)) __THROW;
-extern __nonnull(1, __filename)
-int Bfile_DeleteFile _OF((const FONTCHARACTER *__filename)) __THROW;
-extern __nonnull(1, __pathname)
-int Bfile_DeleteDirectory _OF((const FONTCHARACTER *__pathname)) __THROW;
-extern __nonnull(1, __name)
-int Bfile_DeleteMainMemory _OF((const unsigned char *__name)) __THROW;
+_EXTERN _NONNULL(1, __filename) int Bfile_DeleteEntry
+ _OF((const FONTCHARACTER *__filename, int __mode)) _THROW;
+_EXTERN _NONNULL(1, __filename) int Bfile_DeleteFile
+ _OF((const FONTCHARACTER *__filename)) _THROW;
+_EXTERN _NONNULL(1, __pathname) int Bfile_DeleteDirectory
+ _OF((const FONTCHARACTER *__pathname)) _THROW;
+_EXTERN _NONNULL(1, __name) int Bfile_DeleteMainMemory
+ _OF((const unsigned char *__name)) _THROW;
/* Get the free space on a media */
-extern __nonnull(2, __freebytes)
-int Bfile_GetMediaFree _OF((enum DEVICE_TYPE __devicetype,
- int *__freebytes)) __THROW;
-extern __nonnull(1, __media) __nonnull(2, __freebytes)
-int Bfile_GetMediaFree_OS _OF((FONTCHARACTER *__media, int *__freebytes))
- __THROW;
+_EXTERN _NONNULL(2, __freebytes) int Bfile_GetMediaFree
+ _OF((enum DEVICE_TYPE __devicetype, int *__freebytes)) _THROW;
+_EXTERN _NONNULL(1, __media) _NONNULL(2, __freebytes) int Bfile_GetMediaFree_OS
+ _OF((FONTCHARACTER *__media, int *__freebytes)) _THROW;
/* 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, FONTCHARACTER *__foundfile, FILE_INFO *__fileinfo))
- __THROW;
-extern __nonnull(2, __foundfile) __nonnull(3, __fileinfo)
-int Bfile_FindNext _OF((int __FindHandle, FONTCHARACTER *__foundfile,
- FILE_INFO *__fileinfo)) __THROW;
-extern int Bfile_FindClose _OF((int __FindHandle)) __THROW;
-
-__END_DECLS
-__END_NAMESPACE_FXLIB
+_EXTERN _NONNULL(1, __pathname) _NONNULL(2, __FindHandle)
+_NONNULL(3, __foundfile) _NONNULL(4, __fileinfo) int Bfile_FindFirst
+ _OF((const FONTCHARACTER *__pathname, int *__FindHandle,
+ FONTCHARACTER *__foundfile, FILE_INFO *__fileinfo)) _THROW;
+_EXTERN _NONNULL(2, __foundfile) _NONNULL(3, __fileinfo) int Bfile_FindNext
+ _OF((int __FindHandle, FONTCHARACTER *__foundfile,
+ FILE_INFO *__fileinfo)) _THROW;
+_EXTERN int Bfile_FindClose
+ _OF((int __FindHandle)) _THROW;
+
+_END_DECLS
+_END_NAMESPACE_FXLIB
diff --git a/arch/casiowin/fxlib/include/fxlib/keyboard.h b/arch/casiowin/fxlib/include/fxlib/keyboard.h
index 8d34642..a9f032b 100644
--- a/arch/casiowin/fxlib/include/fxlib/keyboard.h
+++ b/arch/casiowin/fxlib/include/fxlib/keyboard.h
@@ -30,69 +30,75 @@
* ************************************************************************* */
#include <fxlib/cdefs.h>
#include <keybios.h>
-__BEGIN_NAMESPACE_FXLIB
-__BEGIN_DECLS
+_BEGIN_NAMESPACE_FXLIB
+_BEGIN_DECLS
/* ************************************************************************* */
/* Configure the keyboard */
/* ************************************************************************* */
/* Repeat types */
-#define KEYREP_NOEVENT 0
-#define KEYREP_KEYEVENT 1
-#define KEYREP_TIMEREVENT 2
+#define KEYREP_NOEVENT 0
+#define KEYREP_KEYEVENT 1
+#define KEYREP_TIMEREVENT 2
/* Set the repeat time */
-extern void Bkey_Set_RepeatTime _OF((long __FirstCount, long __NextCount))
- __THROW;
-extern void Bkey_Set_RepeatTime_Default _OF((void)) __THROW;
+_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 */
-extern __nonnull(1, __FirstCount) __nonnull(2, __NextCount)
-void Bkey_Get_RepeatTime _OF((long *__FirstCount, long *__NextCount))
- __THROW;
+_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 */
-#define KEYWAIT_HALTON_TIMEROFF 0
-#define KEYWAIT_HALTOFF_TIMEROFF 1
-#define KEYWAIT_HALTON_TIMERON 2
+#define KEYWAIT_HALTON_TIMEROFF 0
+#define KEYWAIT_HALTOFF_TIMEROFF 1
+#define KEYWAIT_HALTON_TIMERON 2
/* Get key presses */
-extern int GetKey _OF((unsigned int *__keycode)) __THROW;
-extern __nonnull(4, __keycode)
-int GetKeyWait _OF((int __sel, int __time, int __menu,
- unsigned int *__keycode)) __THROW;
+_EXTERN int GetKey
+ _OF((unsigned int *__keycode)) _THROW;
+_EXTERN _NONNULL(4, __keycode) int GetKeyWait
+ _OF((int __sel, int __time, int __menu, unsigned int *__keycode)) _THROW;
-extern __nonnull(1, __column) __nonnull(2, __row) __nonnull(6, __keycode)
-int GetKeyWait_OS _OF((int *__column, int *__row, int __waiting_type,
- int __timeout, int __menu, unsigned short *__keycode))
- __THROW;
+_EXTERN _NONNULL(1, __column) _NONNULL(2, __row) _NONNULL(6, __keycode)
+int GetKeyWait_OS
+ _OF((int *__column, int *__row, int __waiting_type, int __timeout,
+ int __menu, unsigned short *__keycode)) _THROW;
/* Check key statuses */
-extern __wur int IsKeyDown _OF((int __keycode)) __THROW;
-extern __wur int IsKeyUp _OF((int __keycode)) __THROW;
+_EXTERN _WUR int IsKeyDown
+ _OF((int __keycode)) _THROW;
+_EXTERN _WUR int IsKeyUp
+ _OF((int __keycode)) _THROW;
/* ************************************************************************* */
/* Syscalls */
/* ************************************************************************* */
#if _USE_FXLIB_UNOFFICIAL
/* Get key */
-extern __nonnull(1, __column) __nonnull(2, __row) __nonnull(6, __keycode)
-int Keyboard_GetKeyWait _OF((int *__column, int *__row,
- int __type_of_waiting, int __timeout_period, int __menu,
- unsigned short *__keycode)) __THROW;
+_EXTERN _NONNULL(1, __column) _NONNULL(2, __row) _NONNULL(6, __keycode)
+int Keyboard_GetKeyWait
+ _OF((int *__column, int *__row, int __type_of_waiting,
+ int __timeout_period, int __menu, unsigned short *__keycode)) _THROW;
-extern __nonnull(1, __matrixcode)
-int Keyboard_GetPressedKey _OF((short *__matrixcode)) __THROW;
-extern __nonnull(1, __matrixcode)
-int Keyboard_IsKeyPressed _OF((short *__matrixcode)) __THROW;
-extern __wur int Keyboard_KeyDown OF((void)) __THROW;
+_EXTERN _NONNULL(1, __matrixcode) int Keyboard_GetPressedKey
+ _OF((short *__matrixcode)) _THROW;
+_EXTERN _NONNULL(1, __matrixcode) int Keyboard_IsKeyPressed
+ _OF((short *__matrixcode)) _THROW;
+_EXTERN _WUR int Keyboard_KeyDown
+ _OF((void)) _THROW;
/* Put key */
-extern int PutKey _OF((int __keycode, int __mode)) __THROW;
-extern int Keyboard_PutKeycode _OF((int __x, int __y, int __keycode)) __THROW;
+_EXTERN int PutKey
+ _OF((int __keycode, int __mode)) _THROW;
+_EXTERN int Keyboard_PutKeycode
+ _OF((int __x, int __y, int __keycode)) _THROW;
#endif
-__END_DECLS
-__END_NAMESPACE_FXLIB
+_END_DECLS
+_END_NAMESPACE_FXLIB
diff --git a/arch/casiowin/g1a.ld b/arch/casiowin/g1a.ld
index 752cc5c..e56dc1a 100644
--- a/arch/casiowin/g1a.ld
+++ b/arch/casiowin/g1a.ld
@@ -28,6 +28,8 @@ SECTIONS {
/* ************************************************************************* */
/* ROM sections: binary code and read-only data */
/* ************************************************************************* */
+/* Initialization code, constructors, text. */
+
.text : {
/* Initialization code. */
*(.pretext)
@@ -52,12 +54,14 @@ SECTIONS {
_romdata = ALIGN(4) ;
} > rom
+
/* ************************************************************************* */
/* RAM sections: BSS and read/write data */
/* ************************************************************************* */
/* The BSS section is meant to be stripped off the ELF file to reduce binary
* size, and initialize with zeroes in the initialization routine;
* therefore its location is undefined. */
+
.bss : {
/* BSS */
_bbss = . ; /* Begin */
diff --git a/arch/casiowin/info.yml b/arch/casiowin/info.yml
index 34b004a..7286e7f 100644
--- a/arch/casiowin/info.yml
+++ b/arch/casiowin/info.yml
@@ -10,7 +10,7 @@ default:
c:
- casiowin/core
- casiowin/core-crt
-meta:
+import:
- all
requires:
arch:
diff --git a/arch/casiowin/libfxsys/docs b/arch/casiowin/libfxsys/docs
deleted file mode 120000
index 5621de3..0000000
--- a/arch/casiowin/libfxsys/docs
+++ /dev/null
@@ -1 +0,0 @@
-../../../docs/casiowin/libfxsys \ No newline at end of file
diff --git a/docs/casiowin/libfxsys/index.en.md b/arch/casiowin/libfxsys/docs/index.en.md
index e819ee7..e819ee7 100644
--- a/docs/casiowin/libfxsys/index.en.md
+++ b/arch/casiowin/libfxsys/docs/index.en.md
diff --git a/arch/casiowin/monochromelib/docs b/arch/casiowin/monochromelib/docs
deleted file mode 120000
index 3266734..0000000
--- a/arch/casiowin/monochromelib/docs
+++ /dev/null
@@ -1 +0,0 @@
-../../../docs/casiowin/monochromelib \ No newline at end of file
diff --git a/docs/casiowin/monochromelib/bmp.en.md b/arch/casiowin/monochromelib/docs/bmp.en.md
index 6c0cf5a..6c0cf5a 100644
--- a/docs/casiowin/monochromelib/bmp.en.md
+++ b/arch/casiowin/monochromelib/docs/bmp.en.md
diff --git a/docs/casiowin/monochromelib/draw.en.md b/arch/casiowin/monochromelib/docs/draw.en.md
index c1d97e5..c1d97e5 100644
--- a/docs/casiowin/monochromelib/draw.en.md
+++ b/arch/casiowin/monochromelib/docs/draw.en.md
diff --git a/docs/casiowin/monochromelib/index.en.md b/arch/casiowin/monochromelib/docs/index.en.md
index 23086a9..23086a9 100644
--- a/docs/casiowin/monochromelib/index.en.md
+++ b/arch/casiowin/monochromelib/docs/index.en.md
diff --git a/docs/casiowin/monochromelib/screen.en.md b/arch/casiowin/monochromelib/docs/screen.en.md
index 961f8dd..961f8dd 100644
--- a/docs/casiowin/monochromelib/screen.en.md
+++ b/arch/casiowin/monochromelib/docs/screen.en.md
diff --git a/docs/casiowin/monochromelib/vram.en.md b/arch/casiowin/monochromelib/docs/vram.en.md
index 554cb72..554cb72 100644
--- a/docs/casiowin/monochromelib/vram.en.md
+++ b/arch/casiowin/monochromelib/docs/vram.en.md
diff --git a/arch/info.yml b/arch/info.yml
index 89fa276..48c475f 100644
--- a/arch/info.yml
+++ b/arch/info.yml
@@ -5,3 +5,4 @@ version:
major: 0
minor: 1
indev: true
+maintainer: [Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
diff --git a/copyright.yml b/copyright.yml
index 2ca9b92..14f3bc1 100644
--- a/copyright.yml
+++ b/copyright.yml
@@ -1,15 +1,18 @@
%YAML 1.2
---
files:
-- 'configure'
-- 'configure.bat'
-- 'copyright.yml'
-- 'make.bat'
-- 'Makefile'
- 'arch'
+- 'docs'
- 'tools/*.py'
- 'tools/**/*.py'
- 'tools/Internals/locales/*.yml'
-- 'docs'
+- 'README.md'
+- 'LICENSE.md'
+- 'copyright.yml'
+- 'configure'
+- 'configure.bat'
+- 'Makefile'
+- 'make.bat'
+- 'requirements.txt'
copyright:
- [2017, Thomas "Cakeisalie5" Touhey, thomas@touhey.fr]
diff --git a/docs/authors.en.md b/docs/authors.en.md
index eba213a..d6bfcf2 100644
--- a/docs/authors.en.md
+++ b/docs/authors.en.md
@@ -5,4 +5,5 @@ 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](licensing)).
+determined through the `copyright.yml` files (see
+[licensing.en.md](licensing.en.md)).
diff --git a/docs/building.en.md b/docs/building.en.md
index 0c3aa91..7867638 100644
--- a/docs/building.en.md
+++ b/docs/building.en.md
@@ -1,8 +1,8 @@
---
title: Building libcarrot
---
-Once you've acknowledged [the basic principles of libcarrot](index), you can
-start building it.
+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
diff --git a/docs/casiowin/core/index.en.md b/docs/casiowin/core/index.en.md
deleted file mode 100644
index 3fca1cf..0000000
--- a/docs/casiowin/core/index.en.md
+++ /dev/null
@@ -1,6 +0,0 @@
----
-title: Adaptation of the core for the fx-9860G.
----
-These are 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
-the syscalls manually.
diff --git a/docs/coding.en.md b/docs/coding.en.md
index f5a3ea0..412134d 100644
--- a/docs/coding.en.md
+++ b/docs/coding.en.md
@@ -2,8 +2,8 @@
title: The libcarrot coding style
---
This coding style is the one the libcarrot project uses -- see
-[Contributing](contributing) for a more general guide about how to contribute,
-or the rest of this guide for how to code in this project.
+[Contributing](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.
This file is to re-write (TODO), as many things have been rethought
(top comments are now generated, the super-preprocessor has been
diff --git a/docs/contributing.en.md b/docs/contributing.en.md
index 1521e18..17fac7d 100644
--- a/docs/contributing.en.md
+++ b/docs/contributing.en.md
@@ -47,8 +47,8 @@ Modules have the following organization ("opt." means "optional", "req." means
- `include/` (opt.): the C/C++ source headers folder;
- `bits/` (opt.): the C/C++ header bits folder;
-- `src/` (opt.): the C/C++/ASM source files;
-- `docs/` (opt.): a symbolic link to the corresponding documentation;
+- `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;
@@ -100,7 +100,7 @@ with the following properties:
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;
-- `meta`: the list of meta-systems to import. Default modules from this other
+- `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:
@@ -125,7 +125,7 @@ default:
c++:
- mysys/thatpackage
- another/thatotherpackage
-meta:
+import:
- all
requires:
arch:
diff --git a/docs/docs.en.md b/docs/docs.en.md
new file mode 100644
index 0000000..79620e6
--- /dev/null
+++ b/docs/docs.en.md
@@ -0,0 +1,47 @@
+---
+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>/arch/<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
+`arch/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.
+ ---
+ Some text about how great this module and the `helloworld()` function it
+ contains are.
+
+ {% highlight c linenos %}
+ void helloworld(const char *string);
+ {% endhighlight %}
+
+ 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/licensing.en.md b/docs/licensing.en.md
index 2b132ce..49afc32 100644
--- a/docs/licensing.en.md
+++ b/docs/licensing.en.md
@@ -23,7 +23,7 @@ written by french people and compliant with french law.
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) for more information about that.
+[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`).
diff --git a/docs/todo.en.md b/docs/todo.en.md
index 9fe5086..26f186a 100644
--- a/docs/todo.en.md
+++ b/docs/todo.en.md
@@ -1,8 +1,8 @@
---
title: To do in libcarrot
---
-If you're new to the project, you should read [the main page](index)
-and [the contributing guide](contributing) beforehand, or else,
+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.
What I've done was mostly defining the project structure and organization,
diff --git a/tools/Internals/args.py b/tools/Internals/args.py
index 4f53dc1..2e31375 100755
--- a/tools/Internals/args.py
+++ b/tools/Internals/args.py
@@ -153,11 +153,8 @@ class CarrotArgumentParser(_argparse.ArgumentParser):
prefix_chars += '/'
# Get the program name.
- env = _os.environ
- if 'PROGNAME' in env:
- prog = env['PROGNAME']
- else:
- prog = _os.path.basename(_sys.argv[0])
+ try: prog = _os.environ['PROGNAME']
+ except: prog = _os.path.basename(_sys.argv[0])
super(CarrotArgumentParser, self).__init__(prog=prog,
description=description, prefix_chars=prefix_chars,
diff --git a/tools/Internals/build/__init__.py b/tools/Internals/build/__init__.py
index 373b690..443988b 100755
--- a/tools/Internals/build/__init__.py
+++ b/tools/Internals/build/__init__.py
@@ -70,7 +70,7 @@ def _find_asm(arch, endian, system, flavour, syntax):
for asm in _tools:
try: gp = _tools[asm]['conf_asm']
except: continue
- try: asmp = gp(arch, endian, 'elf', 'gnu')
+ try: asmp = gp(arch, endian, system, flavour, syntax)
except ToolNotFoundException:
continue
@@ -157,38 +157,38 @@ def setup(data):
if 'cc' in ids:
cc, cp = ids['cc'], params['cc']
_current_tools['cc'] = \
- ft.partial(_current_tools[cc]['cc'], cp)
+ ft.partial(_tools[cc]['cc'], cp)
__compiler = ids['cc']
# Get the C++ compiler.
- if 'cxx' in idsd:
+ if 'cxx' in ids:
cxx, cxxp = ids['cxx'], params['cxx']
_current_tools['cxx'] = \
- ft.partial(_current_tools[cxx]['cxx'], cxxp)
+ ft.partial(_tools[cxx]['cxx'], cxxp)
# Get the assembler.
if 'asm' in ids:
asm, asmp = ids['asm'], params['asm']
_current_tools['asm'] = \
- ft.partial(_current_tools[asm]['asm'], asmp)
+ ft.partial(_tools[asm]['asm'], asmp)
# Get the packer.
if 'pack' in ids:
pack, packp = ids['pack'], params['pack']
_current_tools['pack'] = \
- ft.partial(_current_tools[pack]['pack'], packp)
+ ft.partial(_tools[pack]['pack'], packp)
# Get the linker.
if 'link' in ids:
link, linkp = ids['link'], params['link']
_current_tools['link'] = \
- ft.partial(_current_tools[link]['link'], linkp)
+ ft.partial(_tools[link]['link'], linkp)
# Get the binary executable generator.
if 'bin' in ids:
bing, binp = ids['bin'], params['bin']
_current_tools['bin'] = \
- ft.partial(_current_tools[bing]['bin'], binp)
+ ft.partial(_tools[bing]['bin'], binp)
# Get an information.
def get(key):
diff --git a/tools/Internals/build/gnu_ar.py b/tools/Internals/build/gnu_ar.py
index f36547b..152a022 100755
--- a/tools/Internals/build/gnu_ar.py
+++ b/tools/Internals/build/gnu_ar.py
@@ -40,29 +40,23 @@ def __get_ar_targets(path):
return []
# Get the targets.
- targets = []
- for element in lines[0].split(':')[2].split():
- t = element.split('-')
- if len(t) == 1:
- continue
- targets.append((t[0], '_'.join(t[1:])))
+ targets = lines[0].split(':')[2].split()
return targets
def _configure(arch, endian, system, flavour):
''' Get the params. '''
- if obj_format[:3] != 'elf':
- raise ToolNotFound
+ # Prepare the BFD targets.
+ bfd = prepare_bfd(arch, endian, system, flavour)
+ art = prepare_ar(arch, endian, system, flavour)
# Get the utility
path = None
- for gar in getgnu(arch, endian, system, flavour, 'ar'):
- bfd_list = __get_ar_targets(gar)
+ for gar in getgnu('ar', bfd):
+ target_list = __get_ar_targets(gar)
- for bfd in bfd_list:
- if not check_bfd_arch(arch, bfd[1]):
- continue
- if bfd[0] != lib_format:
+ for target in target_list:
+ if not check_ar(art, target):
continue
path = gar
diff --git a/tools/Internals/build/gnu_as.py b/tools/Internals/build/gnu_as.py
index 6abaebb..de67230 100755
--- a/tools/Internals/build/gnu_as.py
+++ b/tools/Internals/build/gnu_as.py
@@ -34,43 +34,31 @@ def __get_as_bfd(path):
# Get the BFD target, which is on the last line, e.g.
# This assembler was configured for a target of `sh3eb-elf'.
- bfd = out.splitlines()[-1].split('`')[1].split("'")[0]
-
- # Get the format using the system.
- bfd = bfd.split('-')
- arch = bfd[0]
- plt = '-'.join(bfd[1:])
- if plt == "pc-linux-gnu":
- plt = "elf"
- # TODO: others
-
- # Return.
- return (arch, plt)
+ return out.splitlines()[-1].split('`')[1].split("'")[0]
def __iter_as(arch):
""" Iterate through all of the `as` occurrences among the system. """
- for elt in getgnu(arch, 'as'):
- yield elt
- for elt in getutil(['as', 'as.exe']):
+ for elt in getgnu('as', bfd):
yield elt
-def _configure(arch, endian, objfmt, syntax):
+def _configure(arch, endian, system, flavour, syntax):
""" Get the assembler parameters. """
# Check the object format.
# TODO: some configurations of AS produce other formats such as PE...?
- if objfmt != 'elf':
+ if syntax != 'gnu':
raise ToolNotFound
+ # Get the BFD object.
+ bfd = prepare_bfd(arch, endian, system, flavour)
+
# Get the utility.
path = None
- for gas in __iter_as(arch):
- bfd = __get_as_bfd(gas)
+ for gas in getgnu('as', bfd):
+ found_target = __get_as_bfd(gas)
- if not check_bfd_arch(arch, bfd[0]):
- continue
- if bfd[1] != objfmt:
+ if not check_bfd(bfd, found_target):
continue
path = gas
diff --git a/tools/Internals/build/gnu_gcc.py b/tools/Internals/build/gnu_gcc.py
index 487f014..7e2432e 100755
--- a/tools/Internals/build/gnu_gcc.py
+++ b/tools/Internals/build/gnu_gcc.py
@@ -98,7 +98,7 @@ def _configure(typ, arch, endian, system, flavour, standard):
continue
if not __testcc(typ, gcc, cflags):
continue
- if not __teststd(typ, gcc, std):
+ if not __teststd(typ, gcc, standard):
continue
path = gcc
diff --git a/tools/Internals/build/utils/bfd.py b/tools/Internals/build/utils/bfd.py
index 01aa4da..62dbf08 100755
--- a/tools/Internals/build/utils/bfd.py
+++ b/tools/Internals/build/utils/bfd.py
@@ -132,8 +132,11 @@ def prepare_ar(arch, endian, system, flavour):
""" Make a list of GNU ar targets that could correspond to the given
configuration. """
- # TODO
- pass
+ fam, arch, _ = get_arch_detail(arch)
+ if flavour == "elf":
+ flavour = "elf32"
+ res = ['{}-{}'.format(flavour, fam)]
+ return res
def check_ar(targets, raw):
""" Check if the AR target is in the given targets. """
diff --git a/tools/Internals/headers/__init__.py b/tools/Internals/headers/__init__.py
index 7c47580..105c9c6 100644
--- a/tools/Internals/headers/__init__.py
+++ b/tools/Internals/headers/__init__.py
@@ -1,4 +1,409 @@
#!/usr/bin/env python3
-from .manager import process_headers
+""" The header manager, used for all internal operations.
+ Lists headers, opens them (and bits), updates the cache, and stuff.
+
+ The includes is a dictionary of {name: details}, where details is a
+ dictionary containing the following keys:
+
+ - 'bits': the bits name list.
+ - 'path': the source file's path.
+ - 'mtime': the source file's mtime.
+ - 'mname': the module name.
+ - 'role': the file's role.
+ - 'authors': the copyright list.
+ - 'license': the source file's license.
+ - 'content': the parsed content of the header.
+
+ The bits is a dictionary of {name: [details, ...]}, where each details
+ is a dictionary containing the following keys:
+
+ - 'path': the bit's path.
+ - 'mtime': the bit's mtime.
+ - 'authors': the bit's authors.
+ - 'license': the bit's license.
+ - 'content': the parsed content of the bit.
+"""
+
+import os as _os
+import itertools as _itertools
+
+from .parse import *
+from .output import *
+from .eval import *
+
+from ..topc import *
+from ..copyright import *
+
+class HeaderManager:
+ __VER = 'blitz'
+
+ def __split_path(self, path):
+ """ Split a path. """
+
+ tree, leaf = _os.path.split(path)
+ if not tree: return (leaf,)
+ return self.__split_path(tree) + (leaf,)
+
+ def __init__(self, outdir, modules, cachemgr):
+ """ Initialize the object.
+ Loads all of the includes and bits, checks which ones are to
+ make again, and other cool stuff. """
+
+ # Keep those, they could be useful.
+ self.__outdir = outdir
+ self.__modules = modules
+ self.__cachemgr = cachemgr
+
+ # Get the old includes and bits data from the cache.
+ self.__cache = self.__cachemgr.get('headers', {})
+ if 'magic' not in self.__cache or self.__cache['magic'] != self.__VER:
+ self.__cache.clear()
+ self.__cache['magic'] = self.__VER
+ if not 'bits' in self.__cache:
+ self.__cache['bits'] = {}
+ if not 'inc' in self.__cache:
+ self.__cache['inc'] = {}
+ if not 'out' in self.__cache:
+ self.__cache['out'] = ""
+
+ # Prepare for the includes and the bits.
+ self.__inc = {}
+ self.__bits = {}
+
+ # Optimized/converted includes.
+ self.__made_inc = {}
+
+ # Prepare the updated include and bit information.
+ self.__updated_inc = []
+ self.__updated_bits = []
+
+ # Look for all of the includes.
+ for module_name, module in modules.items():
+ for nm in module.getfiles('include', ext=['h', 'hpp', None]):
+ name = '/'.join(self.__split_path(nm))
+ if name in self.__inc:
+ raise DuplicateHeaderException(name, incs[name][1],
+ module_name)
+
+ path = module.getpath('include', nm)
+ role = module.getrole('include', nm)
+ authors, license = module.getcopyright('include', nm)
+
+ # Check if should remake.
+ updated = False
+ if not name in self.__cache['inc'] \
+ or inc['mtime'] > self.__cache['inc'][name]['mtime']:
+ content = self.__loadinc(path, name)
+ bits = self.__listbits(content)
+ updated = True # XXX: user's will?
+ else:
+ content = cache['inc'][name]['content']
+ bits = cache['inc'][name]['bits']
+
+ for bitname in bits:
+ self.__getbits(bitname)
+ if bitname in self.__updated_bits:
+ updated = True
+ for bit in self.__bits[bitname]:
+ raw = merge_copyrights(\
+ {'authors': authors, 'license': license},
+ {'authors': bit['authors'],
+ 'license': bit['license']})
+ authors = raw['authors']
+ license = raw['license']
+
+ inc = {
+ 'bits': bits,
+ 'path': path,
+ 'mtime': _os.path.getmtime(path),
+ 'mname': module_name,
+ 'role': role,
+ 'authors': authors,
+ 'license': license,
+ 'content': content
+ }
+
+ if name in self.__cache['inc'] \
+ and inc != cache['inc'][name]:
+ updated = True
+
+ if updated:
+ self.__updated_inc.append(name)
+ self.__inc[name] = inc
+
+ def __getbits(self, name):
+ """ Gather the bits corresponding to a name. """
+
+ if name in self.__bits:
+ return self.__bits[name]
+
+ bits = []
+ name_path = name.split('/')
+ name_path = _os.path.join('bits', *name_path)
+
+ gbitcache = self.__cache['bits'][name] \
+ if name in self.__cache['bits'] else []
+
+ for module_name, module in self.__modules.items():
+ # Get the bit.
+ path = module.getpath(name_path)
+ isfl = _os.path.isfile(path)
+ if not isfl: continue
+
+ # Get the bit cache.
+ try:
+ bcache = next(i for i in gbitcache if i['path'] == path)
+ except StopIteration:
+ bcache = {}
+
+ authors, license = module.getcopyright(name_path)
+ mtime = _os.path.getmtime(path)
+
+ if bcache and mtime <= bcache['mtime']:
+ content = bcache['content']
+ else:
+ content = parse_header(path)
+
+ bit = {
+ 'path': path,
+ 'mtime': mtime,
+ 'authors': authors,
+ 'license': license,
+ 'content': content
+ }
+
+ bits.append(bit)
+
+ self.__bits[name] = bits
+ if not name in self.__cache['bits'] \
+ or self.__bits[name] != self.__cache['bits'][name]:
+ self.__updated_bits.append(name)
+
+ return bits
+
+ def save(self):
+ """ Save the data into the cache. """
+
+ self.__cachemgr.set('headers', { \
+ 'bits': self.__bits, 'inc': self.__inc})
+
+ def __loadinc(self, path, name):
+ """ Parse a header file, add the include guards. """
+
+ # Parse the file.
+ content = parse_header(path)
+
+ # Return the content.
+ return content
+
+ def __listbits(self, content):
+ """ List all of the `include_bits` parameters in a parsed file.
+
+ This is very naïve: even behind impossible conditions, it
+ will load the bits, because when this is called, the file
+ content isn't optimized yet (as dependency headers might
+ not be loaded yet). """
+
+ bits = set()
+ for line in content:
+ if type(line) == CppIncludeBits:
+ bits.add(line.name)
+ elif type(line) == CppIf:
+ for expr, ins in line.conds:
+ bits.union(self.__listbits(ins))
+ bits.union(self.__listbits(line.eins))
+ return bits
+
+ def __fusion(self, known, *evolved):
+ """ Fusions reference and all evolutions.
+ Caution: modifies the first entry! """
+
+ # Collect the keys to check.
+ keys = set(known)
+ for e in evolved:
+ keys.union(e)
+
+ for key in keys:
+ # If key is the same in reference and conditions, do not
+ # touch it.
+ if all(key in e and e[key] == known[key] for e in evolved):
+ continue
+
+ # If key has disappeared in at least one of the conditions.
+ if key in known and any(not key in e for e in evolved):
+ del known[key]
+ continue
+
+ # If key is the same in all conditions.
+ if key in evolved[0] and all(key in e \
+ and e[key] == evolved[0][key] for e in evolved[1:]):
+ known[key] = evolved[0][key]
+ elif all(key in e and e[key] != False for e in evolved):
+ known[key] = True
+ elif key in known:
+ del known[key]
+
+ return known
+
+ def __loadbits(self, name):
+ """ Get the content corresponding to a set of bits. """
+
+ ins = []
+ first = True
+ for bit in self.__bits[name]:
+ if not bit['content']: continue
+
+ if first: first = False
+ else: ins += [CppRaw([""])]
+ ins.extend(bit['content'])
+
+ return ins
+
+ def __process_rec(self, content, known={}):
+ """ Process recursively a content, optimize it. """
+
+ made = []
+ for ins in content:
+ if type(ins) == CppDefine:
+ if ins.name in known and known[ins.name] != False:
+ # FIXME: already defined!
+ pass
+ known[ins.name] = ins.expr
+ made.append(ins)
+ elif type(ins) == CppUndef:
+ # XXX: not defined?
+ known[ins.name] = False
+ made.append(ins)
+ elif type(ins) == CppInclude:
+ # FIXME: profile.
+ pass
+ elif type(ins) == CppIncludeBits:
+ sub = self.__loadbits(ins.name)
+ made += self.__process_rec(sub, known)
+ elif type(ins) == CppIf:
+ conds = ins.conds.copy()
+ keep_if = False
+ while True:
+ if not conds:
+ sub = self.__process_rec(ins.eins, known)
+ made += sub
+ break
+
+ cond, sub = conds.pop(0)
+ ev = evaluate(cond, known.copy())
+
+ if ev == False:
+ # always false, just skip.
+ continue
+ elif ev == True:
+ # has been evaluated at always true!
+ sub = self.__process_rec(sub, known)
+ made += sub
+ break
+ else:
+ # result is unknown.
+ # evaluate the rest.
+ keep_if = True
+ conds.insert(0, (cond, sub))
+ break
+
+ # Keep the if.
+ if keep_if:
+ knowns = []
+ for i in range(len(conds)):
+ knowns.append(known.copy())
+ conds[i] = (conds[i][0],
+ self.__process_rec(conds[i][1]), knowns[-1])
+ knowns.append(known.copy())
+ eins = self.__process_rec(ins.eins, knowns[-1])
+
+ # Make it evolve.
+ known = self.__fusion(known, *knowns)
+
+ # Make the 'new' if.
+ newif = CppIf(conds[0][0], conds[0][1])
+ for cond in conds[1:]:
+ newif.addcond(cond[0], cond[1])
+ newif.setelse(eins)
+ made.append(newif)
+ else:
+ made.append(ins)
+
+ return made
+
+ def __makeguards(self, name):
+ # Get the include guard.
+ if name[-2:].lower() == '.h':
+ inc = name[:-2].upper().replace('/', '_')
+ #gds = ['_{}_H']
+ gds = ['_{}_H', '_{}_H', '__{}_H', '__{}_H__', '_{}', '__{}',
+ '__{}_H_INCLUDED__']
+ elif name[-4:].lower() == '.hpp':
+ inc = name[:-4].upper().replace('/', '_')
+ gds = ['_{}_HPP']
+ else:
+ inc = name.upper().replace('/', '_')
+ gds = ['__{}_NOEXT']
+
+ return list(map(lambda gd: gd.format(inc), gds))
+
+ def __processinc(self, name):
+ if name in self.__made_inc:
+ return self.__made_inc[name]
+
+ # Get the content.
+ content = self.__inc[name]['content']
+ gds = self.__makeguards(name)
+
+ # Define the include guards.
+ for gd in gds:
+ content[0:0] = [CppDefine(gd, '1')]
+
+ # Put the if. (one for all defines)
+ conds = ['!defined({})'.format(gds[0])]
+ for gd in gds[1:]:
+ add = '&& !defined({})'.format(gd)
+ if len(conds[-1]) + 1 + len(add) >= 72:
+ conds += ['\t' + add]
+ else:
+ conds[-1] += ' ' + add
+ content = [CppIf('\n'.join(conds), content)]
+
+ # Then check that all of the include guards are defined.
+ if len(gds) >= 2:
+ content.append(CppRaw(['',
+ '/* Make sure the include guards are defined. */', '']))
+ for gd in gds:
+ content.append(CppIf(['!defined({})'.format(gd)],
+ [CppDefine(gd, '1')]))
+
+ # Process through the recursive function.
+ self.__made_inc[name] = self.__process_rec(content)
+ return self.__made_inc[name]
+
+ def makeheader(self, name):
+ """ Make a header. """
+
+ info = self.__inc[name]
+ content = self.__processinc(name)
+ topc = make_top_comment(info['mname'], name, info['role'],
+ info['authors'], info['license'])
+ output_header(topc, content)
+
+ def process(self):
+ self.makeheader('alloca.h')
+ #print(self.__updated_inc)
+ pass
+
+# ---
+# Main function.
+# ---
+
+def process_headers(outdir, modules, cachemgr):
+ """ Process the headers (public function). """
+
+ mgr = HeaderManager(outdir, modules, cachemgr)
+ mgr.process()
+ mgr.save()
# End of file.
diff --git a/tools/Internals/headers/manager.py b/tools/Internals/headers/manager.py
deleted file mode 100644
index 59a3155..0000000
--- a/tools/Internals/headers/manager.py
+++ /dev/null
@@ -1,409 +0,0 @@
-#!/usr/bin/env python3
-""" The include file manager, used for all internal operations.
- Lists headers, opens them (and bits), updates the cache, and stuff.
-
- The includes is a dictionary of {name: details}, where details is a
- dictionary containing the following keys:
-
- - 'bits': the bits name list.
- - 'path': the source file's path.
- - 'mtime': the source file's mtime.
- - 'mname': the module name.
- - 'role': the file's role.
- - 'authors': the copyright list.
- - 'license': the source file's license.
- - 'content': the parsed content of the header.
-
- The bits is a dictionary of {name: [details, ...]}, where each details
- is a dictionary containing the following keys:
-
- - 'path': the bit's path.
- - 'mtime': the bit's mtime.
- - 'authors': the bit's authors.
- - 'license': the bit's license.
- - 'content': the parsed content of the bit.
-"""
-
-import os as _os
-import itertools as _itertools
-
-from .parse import *
-from .output import *
-from .eval import *
-
-from ..topc import *
-from ..copyright import *
-
-class HeaderManager:
- __VER = 'blitz'
-
- def __split_path(self, path):
- """ Split a path. """
-
- tree, leaf = _os.path.split(path)
- if not tree: return (leaf,)
- return self.__split_path(tree) + (leaf,)
-
- def __init__(self, outdir, modules, cachemgr):
- """ Initialize the object.
- Loads all of the includes and bits, checks which ones are to
- make again, and other cool stuff. """
-
- # Keep those, they could be useful.
- self.__outdir = outdir
- self.__modules = modules
- self.__cachemgr = cachemgr
-
- # Get the old includes and bits data from the cache.
- self.__cache = self.__cachemgr.get('headers', {})
- if 'magic' not in self.__cache or self.__cache['magic'] != self.__VER:
- self.__cache.clear()
- self.__cache['magic'] = self.__VER
- if not 'bits' in self.__cache:
- self.__cache['bits'] = {}
- if not 'inc' in self.__cache:
- self.__cache['inc'] = {}
- if not 'out' in self.__cache:
- self.__cache['out'] = ""
-
- # Prepare for the includes and the bits.
- self.__inc = {}
- self.__bits = {}
-
- # Optimized/converted includes.
- self.__made_inc = {}
-
- # Prepare the updated include and bit information.
- self.__updated_inc = []
- self.__updated_bits = []
-
- # Look for all of the includes.
- for module_name, module in modules.items():
- for nm in module.getfiles('include', ext=['h', 'hpp', None]):
- name = '/'.join(self.__split_path(nm))
- if name in self.__inc:
- raise DuplicateHeaderException(name, incs[name][1],
- module_name)
-
- path = module.getpath('include', nm)
- role = module.getrole('include', nm)
- authors, license = module.getcopyright('include', nm)
-
- # Check if should remake.
- updated = False
- if not name in self.__cache['inc'] \
- or inc['mtime'] > self.__cache['inc'][name]['mtime']:
- content = self.__loadinc(path, name)
- bits = self.__listbits(content)
- updated = True # XXX: user's will?
- else:
- content = cache['inc'][name]['content']
- bits = cache['inc'][name]['bits']
-
- for bitname in bits:
- self.__getbits(bitname)
- if bitname in self.__updated_bits:
- updated = True
- for bit in self.__bits[bitname]:
- raw = merge_copyrights(\
- {'authors': authors, 'license': license},
- {'authors': bit['authors'],
- 'license': bit['license']})
- authors = raw['authors']
- license = raw['license']
-
- inc = {
- 'bits': bits,
- 'path': path,
- 'mtime': _os.path.getmtime(path),
- 'mname': module_name,
- 'role': role,
- 'authors': authors,
- 'license': license,
- 'content': content
- }
-
- if name in self.__cache['inc'] \
- and inc != cache['inc'][name]:
- updated = True
-
- if updated:
- self.__updated_inc.append(name)
- self.__inc[name] = inc
-
- def __getbits(self, name):
- """ Gather the bits corresponding to a name. """
-
- if name in self.__bits:
- return self.__bits[name]
-
- bits = []
- name_path = name.split('/')
- name_path = _os.path.join('bits', *name_path)
-
- gbitcache = self.__cache['bits'][name] \
- if name in self.__cache['bits'] else []
-
- for module_name, module in self.__modules.items():
- # Get the bit.
- path = module.getpath(name_path)
- isfl = _os.path.isfile(path)
- if not isfl: continue
-
- # Get the bit cache.
- try:
- bcache = next(i for i in gbitcache if i['path'] == path)
- except StopIteration:
- bcache = {}
-
- authors, license = module.getcopyright(name_path)
- mtime = _os.path.getmtime(path)
-
- if bcache and mtime <= bcache['mtime']:
- content = bcache['content']
- else:
- content = parse_header(path)
-
- bit = {
- 'path': path,
- 'mtime': mtime,
- 'authors': authors,
- 'license': license,
- 'content': content
- }
-
- bits.append(bit)
-
- self.__bits[name] = bits
- if not name in self.__cache['bits'] \
- or self.__bits[name] != self.__cache['bits'][name]:
- self.__updated_bits.append(name)
-
- return bits
-
- def save(self):
- """ Save the data into the cache. """
-
- self.__cachemgr.set('headers', { \
- 'bits': self.__bits, 'inc': self.__inc})
-
- def __loadinc(self, path, name):
- """ Parse a header file, add the include guards. """
-
- # Parse the file.
- content = parse_header(path)
-
- # Return the content.
- return content
-
- def __listbits(self, content):
- """ List all of the `include_bits` parameters in a parsed file.
-
- This is very naïve: even behind impossible conditions, it
- will load the bits, because when this is called, the file
- content isn't optimized yet (as dependency headers might
- not be loaded yet). """
-
- bits = set()
- for line in content:
- if type(line) == CppIncludeBits:
- bits.add(line.name)
- elif type(line) == CppIf:
- for expr, ins in line.conds:
- bits.union(self.__listbits(ins))
- bits.union(self.__listbits(line.eins))
- return bits
-
- def __fusion(self, known, *evolved):
- """ Fusions reference and all evolutions.
- Caution: modifies the first entry! """
-
- # Collect the keys to check.
- keys = set(known)
- for e in evolved:
- keys.union(e)
-
- for key in keys:
- # If key is the same in reference and conditions, do not
- # touch it.
- if all(key in e and e[key] == known[key] for e in evolved):
- continue
-
- # If key has disappeared in at least one of the conditions.
- if key in known and any(not key in e for e in evolved):
- del known[key]
- continue
-
- # If key is the same in all conditions.
- if key in evolved[0] and all(key in e \
- and e[key] == evolved[0][key] for e in evolved[1:]):
- known[key] = evolved[0][key]
- elif all(key in e and e[key] != False for e in evolved):
- known[key] = True
- elif key in known:
- del known[key]
-
- return known
-
- def __loadbits(self, name):
- """ Get the content corresponding to a set of bits. """
-
- ins = []
- first = True
- for bit in self.__bits[name]:
- if not bit['content']: continue
-
- if first: first = False
- else: ins += [CppRaw([""])]
- ins.extend(bit['content'])
-
- return ins
-
- def __process_rec(self, content, known={}):
- """ Process recursively a content, optimize it. """
-
- made = []
- for ins in content:
- if type(ins) == CppDefine:
- if ins.name in known and known[ins.name] != False:
- # FIXME: already defined!
- pass
- known[ins.name] = ins.expr
- made.append(ins)
- elif type(ins) == CppUndef:
- # XXX: not defined?
- known[ins.name] = False
- made.append(ins)
- elif type(ins) == CppInclude:
- # FIXME: profile.
- pass
- elif type(ins) == CppIncludeBits:
- sub = self.__loadbits(ins.name)
- made += self.__process_rec(sub, known)
- elif type(ins) == CppIf:
- conds = ins.conds.copy()
- keep_if = False
- while True:
- if not conds:
- sub = self.__process_rec(ins.eins, known)
- made += sub
- break
-
- cond, sub = conds.pop(0)
- ev = evaluate(cond, known.copy())
-
- if ev == False:
- # always false, just skip.
- continue
- elif ev == True:
- # has been evaluated at always true!
- sub = self.__process_rec(sub, known)
- made += sub
- break
- else:
- # result is unknown.
- # evaluate the rest.
- keep_if = True
- conds.insert(0, (cond, sub))
- break
-
- # Keep the if.
- if keep_if:
- knowns = []
- for i in range(len(conds)):
- knowns.append(known.copy())
- conds[i] = (conds[i][0],
- self.__process_rec(conds[i][1]), knowns[-1])
- knowns.append(known.copy())
- eins = self.__process_rec(ins.eins, knowns[-1])
-
- # Make it evolve.
- known = self.__fusion(known, *knowns)
-
- # Make the 'new' if.
- newif = CppIf(conds[0][0], conds[0][1])
- for cond in conds[1:]:
- newif.addcond(cond[0], cond[1])
- newif.setelse(eins)
- made.append(newif)
- else:
- made.append(ins)
-
- return made
-
- def __makeguards(self, name):
- # Get the include guard.
- if name[-2:].lower() == '.h':
- inc = name[:-2].upper().replace('/', '_')
- #gds = ['_{}_H']
- gds = ['_{}_H', '_{}_H', '__{}_H', '__{}_H__', '_{}', '__{}',
- '__{}_H_INCLUDED__']
- elif name[-4:].lower() == '.hpp':
- inc = name[:-4].upper().replace('/', '_')
- gds = ['_{}_HPP']
- else:
- inc = name.upper().replace('/', '_')
- gds = ['__{}_NOEXT']
-
- return list(map(lambda gd: gd.format(inc), gds))
-
- def __processinc(self, name):
- if name in self.__made_inc:
- return self.__made_inc[name]
-
- # Get the content.
- content = self.__inc[name]['content']
- gds = self.__makeguards(name)
-
- # Define the include guards.
- for gd in gds:
- content[0:0] = [CppDefine(gd, '1')]
-
- # Put the if. (one for all defines)
- conds = ['!defined({})'.format(gds[0])]
- for gd in gds[1:]:
- add = '&& !defined({})'.format(gd)
- if len(conds[-1]) + 1 + len(add) >= 72:
- conds += ['\t' + add]
- else:
- conds[-1] += ' ' + add
- content = [CppIf('\n'.join(conds), content)]
-
- # Then check that all of the include guards are defined.
- if len(gds) >= 2:
- content.append(CppRaw(['',
- '/* Make sure the include guards are defined. */', '']))
- for gd in gds:
- content.append(CppIf(['!defined({})'.format(gd)],
- [CppDefine(gd, '1')]))
-
- # Process through the recursive function.
- self.__made_inc[name] = self.__process_rec(content)
- return self.__made_inc[name]
-
- def makeheader(self, name):
- """ Make a header. """
-
- info = self.__inc[name]
- content = self.__processinc(name)
- topc = make_top_comment(info['mname'], name, info['role'],
- info['authors'], info['license'])
- output_header(topc, content)
-
- def process(self):
- self.makeheader('alloca.h')
- #print(self.__updated_inc)
- pass
-
-# ---
-# Main function.
-# ---
-
-def process_headers(outdir, modules, cachemgr):
- """ Process the headers (public function). """
-
- mgr = HeaderManager(outdir, modules, cachemgr)
- mgr.process()
- mgr.save()
-
-# End of file.
diff --git a/tools/Internals/module.py b/tools/Internals/module.py
index 21bee92..fc77c5e 100755
--- a/tools/Internals/module.py
+++ b/tools/Internals/module.py
@@ -16,7 +16,7 @@ from .copyright import *
from .arch import *
# ---
-# Internals
+# Internals.
# ---
def _getarch(raw):
@@ -27,6 +27,32 @@ def _getarch(raw):
if endian: end = endian
return arch, end
+class SourceMaintainer:
+ """ The global maintainer. """
+
+ def __init__(self, raw):
+ self.name = raw[0]
+ if len(raw) > 1:
+ self.mail = raw[1]
+
+ def __str__(self):
+ s = '{}'.format(self.name)
+ if self.mail:
+ s += ' <{}>'.format(self.mail)
+ return s
+
+class SourceVersion:
+ """ The global source version. """
+
+ def __init__(self, raw):
+ self.major = raw['major']
+ self.minor = raw['minor']
+ self.indev = bool(raw['indev'])
+
+ def __str__(self):
+ return '{}.{}{}'.format(self.major, self.minor,
+ ('', '-indev')[self.indev])
+
# ---
# Module objects
# ---
@@ -206,6 +232,7 @@ class SourceSystem:
self.meta = True
self.defaults = pconfig['default'] if 'default' in pconfig else []
+ self.deps = pconfig['import'] if 'import' in pconfig else []
self.arch = []
if 'requires' in pconfig:
r = pconfig['requires']
@@ -269,7 +296,8 @@ class SourceGlobal:
self.__rules = rules
# Get the properties.
- self.version = gconfig['version']
+ self.maintainer = SourceMaintainer(gconfig['maintainer'])
+ self.version = SourceVersion(gconfig['version'])
# Loaded systems.
self.__loaded = {}
@@ -319,7 +347,7 @@ class SourceGlobal:
modules['%s/%s'%(system_name, module_name)] = module
return modules
- def findmodules(self, arch, system = None,
+ def findmodules(self, arch, endian, system = None,
compiler = ('GNU', 'GCC'), languages = ['c', 'c++'],
addition = []):
""" Find modules corresponding to a query, based on:
@@ -338,28 +366,35 @@ class SourceGlobal:
compiler = list(compiler)
# Get the language defaults for the systems.
- # 'dp' means 'default systems', 'pn' means 'system name'.
+ # 'ds' means 'default systems', 'ls' means 'loaded systems',
+ # 'sn' means 'system name'.
default = {'c': [], 'c++': []}
- dp = ['all']
- if system:
- dp.append(system)
- for pn in dp:
- p = self.getsystem(pn)
- if p.arch and not arch in p.arch:
- Raise(UnsupportedArchForSystemException(arch, pn))
- if 'c' in p.defaults:
- default['c'] += p.defaults['c']
- default['c++'] += p.defaults['c']
- if 'c++' in p.defaults:
- default['c++'] += p.defaults['c++']
+ ds = [system]
+ ls = []
+ while ds:
+ sn = ds.pop(0)
+ if sn in ls:
+ continue
+ ls.append(sn)
+
+ sys = self.getsystem(sn)
+ 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++']
# Gather the additional modules.
for name in set(addition):
module = self.getmodule(name)
- if module.arch and not arch in module.arch:
+ if module.arch and all(not x in module.arch \
+ for x in ((arch, endian), (arch, None))):
Raise(UnsupportedArchForModuleException(name, arch))
continue
- if module.compiler and not compiler in module.compiler:
+ if module.compilers and not compiler in module.compilers:
Raise(UnsupportedCompilerForModuleException(name, compiler))
continue
modules[name] = module
@@ -371,7 +406,8 @@ class SourceGlobal:
dm.extend(ldm)
for name in dm:
module = self.getmodule(name)
- if module.arch and not arch in module.arch:
+ if module.arch and all(not x in module.arch \
+ for x in ((arch, endian), (arch, None))):
continue
if module.compilers and not compiler in module.compilers:
continue
diff --git a/tools/Internals/topc.py b/tools/Internals/topc.py
index 1aa5eaf..a323d7d 100644
--- a/tools/Internals/topc.py
+++ b/tools/Internals/topc.py
@@ -12,32 +12,23 @@ import os, textwrap
# ---
__proprietary_statement = """\
-All rights on this file are reserved."""
-
-__cecill_c_statement = """\
-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."""
+This file is in the {module} module from libcarrot. The {module} module from \
+libcarrot is proprietary software; all rights on it are reserved."""
+
+__free_statement = """\
+This file is in the {module} module from libcarrot. The {module} module from \
+libcarrot is free software; you can use, modify and redistribute it under \
+the terms of the libcarrot free software license version 1.0 as published by \
+the libcarrot upstream maintainers.
+
+The {module} module from libcarrot is distributed in the hope that it \
+will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty \
+of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. \
+See the libcarrot free software license for more details.
+
+You should have received a copy of the libcarrot free software license along \
+with this module; if not, see <https://libcarrot.touhey.fr/free-license.html>.
+"""
def __get_license_statement(license):
""" Get the license statement. """
@@ -92,24 +83,43 @@ def __make_topc_text(mname, name, role, authors, license, width=75):
# Make the top comment for specific languages, out of text.
# ---
-def __make_topc_c(s, sep='\n'):
+def __make_topc_c(sep='\n', **params):
""" Make a top comment in C using text. """
__top = '/* ' + '*' * 76
__bot = ' * ' + '*' * 73 + ' */'
+ params['width'] = 76
+ msg = __make_topc_text(**params)
+
mid = sep.join(map(lambda x: ' *' + (' ' if x else '') + x,
- s.splitlines()))
+ msg.splitlines()))
fin = sep.join((__top, mid, __bot)) + sep
return fin
-def __make_topc_sh(s, sep='\n'):
+def __make_topc_sh(sep='\n', **params):
""" Make a bootiful header. """
__sep = '#' + '*' * 78
+ params['width'] = 77
+ msg = __make_topc_text(**params)
+
mid = sep.join(map(lambda x: '#' + (' ' if x else '') + x,
- s.splitlines()))
+ msg.splitlines()))
+ fin = sep.join((__sep, mid, __sep)) + sep
+ return fin
+
+def __make_topc_asmsh(sep='\n', **params):
+ """ Make a not-so-nice header. """
+
+ __sep = '; ' + '-' * 77
+
+ params['width'] = 77
+ msg = __make_topc_text(**params)
+
+ mid = sep.join(map(lambda x: ';' + (' ' if x else '') + x,
+ msg.splitlines()))
fin = sep.join((__sep, mid, __sep)) + sep
return fin
@@ -121,11 +131,15 @@ def __make_topc_sh(s, sep='\n'):
def get_source_content(path, sep='\n', syntax='c'):
""" Get a source file content after the top comment. """
- if syntax == 'c':
+ if syntax in ['c', 'c++']:
is_str = lambda x: x[:3] == '/* ' and \
all(c == '*' for c in x[3:])
is_end = lambda x: x[:3] == ' * ' and \
all(c == '*' for c in x[3:-3]) and x[-3:] == ' */'
+ elif syntax in ['asmsh']:
+ is_str = lambda x: x[:2] == '; ' and \
+ all(c == '-' for c in x[2:])
+ is_end = is_str
else:
is_str = lambda x: x[0] == '#' and \
all(c == '*' for c in x[1:])
@@ -151,9 +165,21 @@ def get_source_content(path, sep='\n', syntax='c'):
def make_top_comment(module_name, name, role, authors, license, syntax='c'):
""" Make a top comment using different syntaxes. """
- width = 76 if syntax == 'c' else 77
- text = __make_topc_text(module_name, name, role, authors, license,
- width=width)
- return __make_topc_c(text) if syntax == 'c' else __make_topc_sh(text)
+ params = {
+ 'mname': module_name,
+ 'name': name,
+ 'role': role,
+ 'authors': authors,
+ 'license': license
+ }
+
+ if syntax in ['c', 'c++']:
+ text = __make_topc_c(**params)
+ elif syntax in ['asmsh']:
+ text = __make_topc_asmsh(**params)
+ else:
+ text = __make_topc_sh(**params)
+
+ return text
# End of file.
diff --git a/tools/configure.py b/tools/configure.py
index 5ec8f2e..3fdb348 100755
--- a/tools/configure.py
+++ b/tools/configure.py
@@ -51,6 +51,8 @@ argparser.add_argument('-o', '--output', '/-config-cache', dest='out',
help=_("the path of the output configuration file"))
argparser.add_argument('-C', '--cache', dest='cache',
default=__from_root('.cache.yml'), help=_("the path of the cache file"))
+argparser.add_argument('-m', dest='mroot',
+ default=__from_root('arch'), help=_("the modules root"))
argparser.add_argument('-B', '/O', '--build', '/-obj', dest='builddir',
default=__from_root('build'), help=_("the build directory"))
@@ -68,7 +70,7 @@ argparser.add_argument('-a', '--add', dest='modules',
default=[], action='append', help=_("add a module in the configuration "
"(cumulative)"))
argparser.add_argument('-F', '--flavour', '/-flavor', dest='flavour',
- default='coff', help=_("the development files flavour"))
+ default='elf', help=_("the development files flavour"))
argparser.add_argument('-T', '--tooldir', dest='tooldir', default=None,
help=_("add a tools directory (cumulative)"))
argparser.add_argument('/-shared')
@@ -166,9 +168,10 @@ def main():
args.modules = addm
# Get the global source.
- g = SourceGlobal(__from_root('arch'))
+ g = SourceGlobal(args.mroot)
if args.version:
- print(g.version)
+ print(_("libcarrot {}").format(str(g.version)))
+ print(_("Maintained by {}.").format(str(g.maintainer)))
return
# Get the platform.
@@ -193,7 +196,7 @@ def main():
tools.setup(found_tools)
# List the modules.
- modules = list(g.findmodules(args.arch, args.system,
+ modules = list(g.findmodules(args.arch, args.endian, args.system,
tools.get('compiler'), args.lang, args.modules).keys())
# Write the configuration.
@@ -203,8 +206,10 @@ def main():
paths = {
'source': os.path.relpath('arch', root),
'cache': os.path.relpath(args.cache, root),
- 'incdir': os.path.relpath(args.incdir, root),
- 'objdir': os.path.relpath(args.objdir, root)
+ 'incdir': os.path.relpath(os.path.join(args.builddir,
+ 'include'), root),
+ 'objdir': os.path.relpath(os.path.join(args.builddir,
+ 'modules'), root)
}
# Make the configuration.
diff --git a/tools/docs b/tools/docs
deleted file mode 120000
index 21112e2..0000000
--- a/tools/docs
+++ /dev/null
@@ -1 +0,0 @@
-../docs/tools \ No newline at end of file
diff --git a/tools/make.py b/tools/make.py
index 13f4a77..4d34295 100755
--- a/tools/make.py
+++ b/tools/make.py
@@ -34,18 +34,14 @@ def clean(args):
force rebuild). """
# Remove the caches.
- try: os.remove('.makeinc-cache')
- except FileNotFoundError: pass
- try: os.remove('.cache.yml')
- except FileNotFoundError: pass
+ for cachefile in ('.makeinc-cache', '.cache.yml'):
+ try: os.remove(cachefile)
+ except FileNotFoundError: pass
- # Remove the include folder.
- try: rmtree('include')
- except FileNotFoundError: pass
-
- # Remove the objects folder.
- try: rmtree('obj')
- except FileNotFoundError: pass
+ # Remove the build folders.
+ for directory in ('include', 'obj', 'build'):
+ try: rmtree(directory)
+ except FileNotFoundError: pass
def mrproper(args):
""" Clean the project for distribution (remove generated files and
@@ -205,6 +201,9 @@ def build(args):
if tools.pack(os.path.join('obj', libname), libs[lib]):
exit(1)
+def docs(args):
+ pass
+
def install(args):
pass
@@ -236,6 +235,8 @@ def main():
elif args.command in ['re', 'rebuild']:
clean(args)
build(args)
+ elif args.command in ['docs', 'html']:
+ docs(args)
else:
raise InvalidCommandException(args.command)