BUILDBOT: Fixed libgxflux to avoid crashes at exit

This commit is contained in:
Le Philousophe
2019-09-29 21:17:29 +00:00
parent 9274cf0653
commit 68a372ee60
3 changed files with 89 additions and 0 deletions
@@ -0,0 +1,89 @@
commit d373784992eda2f37f804d034435b54b7c003d2a
Author: Le Philousophe <lephilousophe@users.noreply.github.com>
Date: Sun Sep 29 18:42:52 2019 +0200
Fix console handling with recent libsysbase
diff --git a/src/gfx_con.c b/src/gfx_con.c
index 7f950f7..846309b 100644
--- a/src/gfx_con.c
+++ b/src/gfx_con.c
@@ -37,9 +37,9 @@
extern unsigned int gfx_con_font_len;
extern unsigned char gfx_con_font[];
-static ssize_t _con_write(struct _reent *r, int fd, const char *ptr,
+static ssize_t _con_write(struct _reent *r, void *fd, const char *ptr,
size_t len);
-static ssize_t _con_read(struct _reent *r, int fd, char *ptr, size_t len);
+static ssize_t _con_read(struct _reent *r, void *fd, char *ptr, size_t len);
static const devoptab_t _dt_stdio = {
"stdio", // device name
@@ -65,8 +65,11 @@ static const devoptab_t _dt_stdio = {
NULL, // device ftrunctate_r
NULL, // device fsync_r
NULL, // deviceData;
- NULL, // device chmod_r
- NULL // device fchmod_r
+ NULL, // chmod_r
+ NULL, // fchmod_r
+ NULL, // rmdir_r
+ NULL, // lstat_r
+ NULL, // utimes_r
};
static const GXColor _con_colors[] = {
@@ -347,7 +350,7 @@ static size_t _con_esc(const char *ptr, size_t len) {
return ret;
}
-static ssize_t _con_write(struct _reent *r, int fd, const char *ptr,
+static ssize_t _con_write(struct _reent *r, void *fd, const char *ptr,
size_t len) {
u32 level;
ssize_t ret = 0;
@@ -434,7 +437,7 @@ static ssize_t _con_write(struct _reent *r, int fd, const char *ptr,
return ret;
}
-static ssize_t _con_read(struct _reent *r, int fd, char *ptr, size_t len) {
+static ssize_t _con_read(struct _reent *r, void *fd, char *ptr, size_t len) {
(void) r;
(void) fd;
(void) ptr;
@@ -445,6 +448,8 @@ static ssize_t _con_read(struct _reent *r, int fd, char *ptr, size_t len) {
return -EINVAL;
}
+static devoptab_t const *_opts_backup[3];
+
bool gfx_con_init(gfx_screen_coords_t *coords) {
static bool inited = false;
u32 level;
@@ -464,6 +469,12 @@ bool gfx_con_init(gfx_screen_coords_t *coords) {
return false;
}
+ _CPU_ISR_Disable(level);
+ _opts_backup[0] = devoptab_list[STD_IN];
+ _opts_backup[1] = devoptab_list[STD_OUT];
+ _opts_backup[2] = devoptab_list[STD_ERR];
+ _CPU_ISR_Restore(level);
+
inited = true;
}
@@ -510,9 +521,9 @@ void gfx_con_deinit(void) {
u32 level;
_CPU_ISR_Disable(level);
- devoptab_list[STD_IN] = NULL;
- devoptab_list[STD_OUT] = NULL;
- devoptab_list[STD_ERR] = NULL;
+ devoptab_list[STD_IN] = _opts_backup[0];
+ devoptab_list[STD_OUT] = _opts_backup[1];
+ devoptab_list[STD_ERR] = _opts_backup[2];
if (_con.usbgecko)
usb_sendbuffer(USBGECKO_CHANNEL, CON_COLRESET, strlen(CON_COLRESET));