Browse Source

small improvements

* Update TOTO list
* Change the type of gint_vbr to comply with a new warning in GCC 9
* Add strcmp()
compat
Lephe 1 month ago
parent
commit
86cd9b98d4
Signed by: Lephe <sebastien.michelland@protonmail.com> GPG Key ID: 1BBA026E13FC0495
4 changed files with 21 additions and 13 deletions
  1. 2
    3
      TODO
  2. 5
    2
      include/gint/std/string.h
  3. 1
    1
      src/core/setup.c
  4. 13
    7
      src/std/string.c

+ 2
- 3
TODO View File

@@ -13,13 +13,12 @@ Complementary elements on existing code.
* topti: support unicode fonts
* gray: find good values for more models than the Graph 35+E II
* render: get rid of GINT_NEED_VRAM and #define vram gint_vram if you need
* dma: dma_memcpy() and dma_memset(), possibly requiring alignment
* dma: maybe relax the 4-byte size constraint for dma_memset()
* core: try to leave add-in without reset in case of fatal exception
* core: try to leave add-in without reset in case of panic
* topti: support Unicode fonts
* hardware: fill in the HWMEM_FITTLB flag
* keyboard: think of extended functions
* keyboard: add an intermediate-level API with some sort of IsKeyDown()
* keyboard: implement keydown() in an event-compliant way
* cpg: spread spectrum on fxcg50
* bopti: blending modes for monochrome bitmaps (use topti assembler)
* display: use more of topti's assembler in drect()

+ 5
- 2
include/gint/std/string.h View File

@@ -16,10 +16,13 @@ void *memset(void *dest, int byte, size_t n);
/* strlen(): Length of a NUL-terminated string */
size_t strlen(char const *str);

/* strncpy(): Copy a string with a size limit*/
/* strncpy(): Copy a string with a size limit */
char *strncpy(char *dst, char const *src, size_t n);

/* strcat(): Concatenation of src in dest*/
/* strcat(): Concatenation a string to a pre-allocated space */
char *strcat(char *dest, const char *src);

/* strcmp(): Compare NUL-terminated strings */
int strcmp(char const *s1, char const *s2);

#endif /* GINT_STD_STRING */

+ 1
- 1
src/core/setup.c View File

@@ -10,7 +10,7 @@
#include <gint/mpu/intc.h>

/* VBR address, from the linker script */
extern char gint_vbr;
extern char gint_vbr[];
/* System's VBR address */
GBSS static uint32_t system_vbr;
/* Size of exception and TLB handler */

+ 13
- 7
src/std/string.c View File

@@ -6,24 +6,30 @@
#include <gint/defs/attributes.h>
#include <stdarg.h>

GWEAK size_t strlen(const char *str)
GWEAK size_t strlen(char const *str)
{
int len = 0;
while(str[len]) len++;
return len;
}

GWEAK char *strncpy(char *dst, const char *src, size_t n)
GWEAK char *strncpy(char *dst, char const *src, size_t n)
{
size_t i = 0;
while(i < n && (dst[i] = src[i])) i++;
return dst;
}

GWEAK char *strcat(char *dest, const char *src)
GWEAK char *strcat(char *dest, char const *src)
{
unsigned long fin_dest = strlen(dest);
unsigned int i;
for (i = 0 ; i <= strlen(src) ; i++) dest[fin_dest + i] = src[i];
return dest;
unsigned long fin_dest = strlen(dest);
unsigned int i;
for (i = 0 ; i <= strlen(src) ; i++) dest[fin_dest + i] = src[i];
return dest;
}

GWEAK int strcmp(char const *s1, char const *s2)
{
while(*s1 && *s1 == *s2) s1++, s2++;
return *s1 - *s2;
}

Loading…
Cancel
Save