git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

commit 216a37aaf1b1a82895a58f55d7c0a7f6ab68a86e
parent 5d62c592049beb7422ce3f45afc5721761c1d9bf
Author: Toxa <untoxa@mail.ru>
Date:   Wed, 18 Aug 2021 17:22:01 +0300

fix library structure (invalid headers were used because of incorrect using of #if directive)

Diffstat:
Cgbdk-lib/include/string.h -> gbdk-lib/include/asm/gbz80/string.h0
Mgbdk-lib/include/asm/gbz80/types.h4++--
Mgbdk-lib/include/asm/types.h12+++++++-----
Mgbdk-lib/include/asm/z80/provides.h2+-
Agbdk-lib/include/asm/z80/string.h131+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mgbdk-lib/include/asm/z80/types.h4++--
Dgbdk-lib/include/gbdk-lib.h25-------------------------
Agbdk-lib/include/gbdk/gbdk-lib.h28++++++++++++++++++++++++++++
Mgbdk-lib/include/string.h138+++++++------------------------------------------------------------------------
Mgbdk-lib/libc/printf.c1-
Mgbdk-lib/libc/sprintf.c1-
Mgbdk-lib/libc/string.c2+-
12 files changed, 184 insertions(+), 164 deletions(-)

diff --git a/gbdk-lib/include/string.h b/gbdk-lib/include/asm/gbz80/string.h diff --git a/gbdk-lib/include/asm/gbz80/types.h b/gbdk-lib/include/asm/gbz80/types.h @@ -5,8 +5,8 @@ #ifndef ASM_GBZ80_TYPES_INCLUDE #define ASM_GBZ80_TYPES_INCLUDE -#if SDCC_PORT!=gbz80 -#error gbz80 only. +#ifndef __PORT_gbz80 + #error gbz80 only. #endif #define NONBANKED __nonbanked diff --git a/gbdk-lib/include/asm/types.h b/gbdk-lib/include/asm/types.h @@ -4,12 +4,14 @@ #ifndef ASM_TYPES_INCLUDE #define ASM_TYPES_INCLUDE -#if SDCC_PORT == gbz80 -#include <asm/gbz80/types.h> -#elif SDCC_PORT == z80 -#include <asm/z80/types.h> +#ifdef __PORT_gbz80 + #include <asm/gbz80/types.h> #else -#error Unrecognised port + #ifdef __PORT_z80 + #include <asm/z80/types.h> + #else + #error Unrecognised port + #endif #endif #ifndef NONBANKED diff --git a/gbdk-lib/include/asm/z80/provides.h b/gbdk-lib/include/asm/z80/provides.h @@ -1,4 +1,4 @@ #define USE_C_MEMCPY 0 #define USE_C_STRCPY 0 -#define USE_C_STRCMP 0 +#define USE_C_STRCMP 1 diff --git a/gbdk-lib/include/asm/z80/string.h b/gbdk-lib/include/asm/z80/string.h @@ -0,0 +1,131 @@ +/** @file string.h + Generic string functions. + */ +#ifndef STRING_INCLUDE +#define STRING_INCLUDE + +#include <types.h> + +/** Copies the string pointed to by __src__ (including the terminating + `\0' character) to the array pointed to by __dest__. + + The strings may not overlap, and the destination string dest must + be large enough to receive the copy. + + @param dest Array to copy into + @param src Array to copy from + + @return A pointer to dest +*/ +char *strcpy(char *dest, const char *src) NONBANKED; + +/** Compares strings + + @param s1 First string to compare + @param s2 Second string to compare + + Returns: + \li > 0 if __s1__ > __s2__ + \li 0 if __s1__ == __s2__ + \li < 0 if __s1__ < __s2__ +*/ +int strcmp(const char *s1, const char *s2) NONBANKED; + +/** Copies n bytes from memory area src to memory area dest. + + The memory areas may not overlap. + + @param dest Buffer to copy into + @param src Buffer to copy from + @param len Number of Bytes to copy +*/ +void *memcpy(void *dest, const void *src, size_t len) NONBANKED; + +/** Copies n bytes from memory area src to memory area dest, areas may overlap + */ +void *memmove (void *dest, const void *src, size_t n); + +/** Fills the memory region __s__ with __n__ bytes using value __c__ + + @param s Buffer to fill + @param c char value to fill with (truncated from int) + @param n Number of bytes to fill +*/ +void *memset (void *s, int c, size_t n) NONBANKED; + +/** Reverses the characters in a string + + @param s Pointer to string to reverse. + + For example 'abcdefg' will become 'gfedcba'. + + Banked as the string must be modifiable. + + Returns: Pointer to __s__ +*/ +char *reverse(char *s); + +/** Concatenate Strings. Appends string __s2__ to the end of string __s1__ + + @param s1 String to append onto + @param s2 String to copy from + + For example 'abc' and 'def' will become 'abcdef'. + + String __s1__ must be large enough to store both __s1__ and __s2__. + + Returns: Pointer to __s1__ +*/ +char *strcat(char *s1, const char *s2) NONBANKED; + +/** Calculates the length of a string + + @param s String to calculate length of + + Returns: Length of string not including the terminating `\0' character. +*/ +int strlen(const char *s) NONBANKED; + +/**Concatenate at most __n__ characters from string __s2__ onto the end of __s1__. + + @param s1 String to append onto + @param s2 String to copy from + @param n Max number of characters to copy from __s2__ + + String __s1__ must be large enough to store both __s1__ and __n__ characters of __s2__ + + Returns: Pointer to __s1__ +*/ +char *strncat(char *s1, const char *s2, int n) NONBANKED; + +/** Compare strings (at most n characters): + + @param s1 First string to compare + @param s2 Second string to compare + @param n Max number of characters to compare + + Returns: + \li > 0 if __s1__ > __s2__ + \li 0 if __s1__ == __s2__ + \li < 0 if __s1__ < __s2__ +*/ +int strncmp(const char *s1, const char *s2, int n) NONBANKED; + +/** Copy __n__ characters from string __s2__ to __s1__ + + + @param s1 String to copy into + @param s2 String to copy from + @param n Max number of characters to copy from __s2__ + + If __s2__ is shorter than __n__, the remaining + bytes in __s1__ are filled with \0. + + Warning: If there is no \0 in the first __n__ bytes of __s2__ then __s1__ + will not be null terminated. + + Returns: Pointer to __s1__ +*/ +char *strncpy(char *s1, const char *s2, int n) NONBANKED; + +#endif diff --git a/gbdk-lib/include/asm/z80/types.h b/gbdk-lib/include/asm/z80/types.h @@ -5,8 +5,8 @@ #ifndef ASM_Z80_TYPES_INCLUDE #define ASM_Z80_TYPES_INCLUDE -#if SDCC_PORT!=z80 -#error gbz80 only. +#ifndef __PORT_z80 + #error z80 only. #endif #define NONBANKED __nonbanked diff --git a/gbdk-lib/include/gbdk-lib.h b/gbdk-lib/include/gbdk-lib.h @@ -1,25 +0,0 @@ -/** @file gbdk-lib.h - Settings for the greater library system. -*/ -#ifndef GBDK_LIB_INCLUDE -#define GBDK_LIB_INCLUDE - -#if SDCC_PORT==gbz80 -#include <asm/gbz80/provides.h> -#elif SDCC_PORT==z80 -#include <asm/z80/provides.h> -#else -#error Unrecognised port. -#endif - -#ifndef USE_C_MEMCPY -#define USE_C_MEMCPY 1 -#endif -#ifndef USE_C_STRCPY -#define USE_C_STRCPY 1 -#endif -#ifndef USE_C_STRCMP -#define USE_C_STRCMP 1 -#endif - -#endif diff --git a/gbdk-lib/include/gbdk/gbdk-lib.h b/gbdk-lib/include/gbdk/gbdk-lib.h @@ -0,0 +1,28 @@ +/** @file gbdk-lib.h + Settings for the greater library system. +*/ +#ifndef GBDK_LIB_INCLUDE +#define GBDK_LIB_INCLUDE + +#ifdef __PORT_gbz80 + #include <asm/gbz80/provides.h> +#else + #ifdef __PORT_z80 + #include <asm/z80/provides.h> + #else + #error Unrecognised port + #endif +#endif + + +#ifndef USE_C_MEMCPY +#define USE_C_MEMCPY 1 +#endif +#ifndef USE_C_STRCPY +#define USE_C_STRCPY 1 +#endif +#ifndef USE_C_STRCMP +#define USE_C_STRCMP 1 +#endif + +#endif diff --git a/gbdk-lib/include/string.h b/gbdk-lib/include/string.h @@ -1,131 +1,17 @@ /** @file string.h Generic string functions. */ -#ifndef STRING_INCLUDE -#define STRING_INCLUDE - -#include <types.h> - -/** Copies the string pointed to by __src__ (including the terminating - `\0' character) to the array pointed to by __dest__. - - The strings may not overlap, and the destination string dest must - be large enough to receive the copy. - - @param dest Array to copy into - @param src Array to copy from - - @return A pointer to dest -*/ -char *strcpy(char *dest, const char *src) NONBANKED __preserves_regs(b, c); - -/** Compares strings - - @param s1 First string to compare - @param s2 Second string to compare - - Returns: - \li > 0 if __s1__ > __s2__ - \li 0 if __s1__ == __s2__ - \li < 0 if __s1__ < __s2__ -*/ -int strcmp(const char *s1, const char *s2) NONBANKED __preserves_regs(b, c); - -/** Copies n bytes from memory area src to memory area dest. - - The memory areas may not overlap. - - @param dest Buffer to copy into - @param src Buffer to copy from - @param len Number of Bytes to copy -*/ -void *memcpy(void *dest, const void *src, size_t len) NONBANKED __preserves_regs(b, c); - -/** Copies n bytes from memory area src to memory area dest, areas may overlap - */ -void *memmove (void *dest, const void *src, size_t n); - -/** Fills the memory region __s__ with __n__ bytes using value __c__ - - @param s Buffer to fill - @param c char value to fill with (truncated from int) - @param n Number of bytes to fill -*/ -void *memset (void *s, int c, size_t n) NONBANKED __preserves_regs(b, c); - -/** Reverses the characters in a string - - @param s Pointer to string to reverse. - - For example 'abcdefg' will become 'gfedcba'. - - Banked as the string must be modifiable. - - Returns: Pointer to __s__ -*/ -char *reverse(char *s) __preserves_regs(b, c); - -/** Concatenate Strings. Appends string __s2__ to the end of string __s1__ - - @param s1 String to append onto - @param s2 String to copy from - - For example 'abc' and 'def' will become 'abcdef'. - - String __s1__ must be large enough to store both __s1__ and __s2__. - - Returns: Pointer to __s1__ -*/ -char *strcat(char *s1, const char *s2) NONBANKED; - -/** Calculates the length of a string - - @param s String to calculate length of - - Returns: Length of string not including the terminating `\0' character. -*/ -int strlen(const char *s) NONBANKED __preserves_regs(b, c); - -/**Concatenate at most __n__ characters from string __s2__ onto the end of __s1__. - - @param s1 String to append onto - @param s2 String to copy from - @param n Max number of characters to copy from __s2__ - - String __s1__ must be large enough to store both __s1__ and __n__ characters of __s2__ - - Returns: Pointer to __s1__ -*/ -char *strncat(char *s1, const char *s2, int n) NONBANKED; - -/** Compare strings (at most n characters): - - @param s1 First string to compare - @param s2 Second string to compare - @param n Max number of characters to compare - - Returns: - \li > 0 if __s1__ > __s2__ - \li 0 if __s1__ == __s2__ - \li < 0 if __s1__ < __s2__ -*/ -int strncmp(const char *s1, const char *s2, int n) NONBANKED; - -/** Copy __n__ characters from string __s2__ to __s1__ - - - @param s1 String to copy into - @param s2 String to copy from - @param n Max number of characters to copy from __s2__ - - If __s2__ is shorter than __n__, the remaining - bytes in __s1__ are filled with \0. - - Warning: If there is no \0 in the first __n__ bytes of __s2__ then __s1__ - will not be null terminated. - - Returns: Pointer to __s1__ -*/ -char *strncpy(char *s1, const char *s2, int n) NONBANKED; +#ifndef STD_STRING_INCLUDE +#define STD_STRING_INCLUDE + +#ifdef __PORT_gbz80 + #include <asm/gbz80/string.h> +#else + #ifdef __PORT_z80 + #include <asm/z80/string.h> + #else + #error Unrecognised port + #endif +#endif #endif diff --git a/gbdk-lib/libc/printf.c b/gbdk-lib/libc/printf.c @@ -1,4 +1,3 @@ -#include <gbdk-lib.h> #include <stdio.h> #include <stdarg.h> diff --git a/gbdk-lib/libc/sprintf.c b/gbdk-lib/libc/sprintf.c @@ -1,4 +1,3 @@ -#include <gbdk-lib.h> #include <stdio.h> #include <stdarg.h> #include <stdlib.h> diff --git a/gbdk-lib/libc/string.c b/gbdk-lib/libc/string.c @@ -1,7 +1,7 @@ /** Dumb strings hack. */ -#include <gbdk-lib.h> #include <string.h> +#include <gbdk/gbdk-lib.h> #if USE_C_STRCPY char *strcpy(char *dest, const char *source) NONBANKED

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.