fix some header files to conform with C99 hopefully, should fix issue #1670

This commit is contained in:
mrdudz 2022-05-08 18:49:48 +02:00
parent d0ac06c9b0
commit 3640beaa46
5 changed files with 74 additions and 40 deletions

View File

@ -57,7 +57,9 @@
/* Character classification functions */
int __fastcall__ isalnum (int c);
int __fastcall__ isalpha (int c);
int __fastcall__ isascii (int c);
#if __CC65_STD__ >= __CC65_STD_CC65__
int __fastcall__ isascii (int c); /* non standard */
#endif
int __fastcall__ iscntrl (int c);
int __fastcall__ isdigit (int c);
int __fastcall__ isgraph (int c);
@ -75,7 +77,7 @@ int __fastcall__ toupper (int c); /* Always external */
int __fastcall__ tolower (int c); /* Always external */
#if __CC65_STD__ >= __CC65_STD_CC65__
unsigned char __fastcall__ toascii (unsigned char c);
unsigned char __fastcall__ toascii (unsigned char c); /* non standard */
/* Convert a target-specific character to ASCII. */
#endif

View File

@ -37,7 +37,6 @@
#define _LIMITS_H
#define CHAR_BIT 8
#define SCHAR_MIN ((signed char) 0x80)
@ -63,7 +62,9 @@
#define ULONG_MAX 4294967295UL
#if __CC65_STD__ >= __CC65_STD_CC65__
/* These defines that are platform dependent */
/* FILENAME_MAX in stdlib.h is defined as the same value as PATH_MAX */
#if defined(__APPLE2__)
# define PATH_MAX (64+1)
#elif defined(__ATARI__)
@ -77,7 +78,7 @@
#else
# define PATH_MAX (16+1)
#endif
#endif /* __CC65_STD__ >= __CC65_STD_CC65__ */
/* End of limits.h */
#endif

View File

@ -37,12 +37,21 @@
#define _STDIO_H
/* NULL pointer */
#ifndef _HAVE_NULL
#define NULL 0
#define _HAVE_NULL
#endif
#include <stddef.h>
#include <stdarg.h>
#include <limits.h>
/* size_t is needed */
#ifndef _HAVE_size_t
#define _HAVE_size_t
typedef unsigned size_t;
#endif
/* stdio.h should not define va_list, so we use an equivalent type in the
compiler namespace instead */
typedef unsigned char* __va_list;
/* Types */
typedef struct _FILE FILE;
@ -65,9 +74,24 @@ extern FILE* stderr;
#define SEEK_SET 2
#define TMP_MAX 256
#define FILENAME_MAX PATH_MAX
#define L_tmpnam FILENAME_MAX
/* These defines that are platform dependent */
/* FILENAME_MAX is defined as the same value as PATH_MAX in limits.h, but we
are not allowed to include limits.h here */
#if defined(__APPLE2__)
# define FILENAME_MAX (64+1)
#elif defined(__ATARI__)
# define FILENAME_MAX (63+1)
#elif defined(__CBM__)
# define FILENAME_MAX (255) /* should be 256+1, see libsrc/common/_cmd.s why it's not */
#elif defined(__LUNIX__)
# define FILENAME_MAX (80+1)
#elif defined(__TELESTRAT__)
# define FILENAME_MAX (50+1)
#else
# define FILENAME_MAX (16+1)
#endif
#define L_tmpnam FILENAME_MAX
/*****************************************************************************/
@ -107,17 +131,17 @@ int __fastcall__ rename (const char* oldname, const char* newname);
int snprintf (char* buf, size_t size, const char* format, ...);
int sprintf (char* buf, const char* format, ...);
int __fastcall__ ungetc (int c, FILE* f);
int __fastcall__ vfprintf (FILE* f, const char* format, va_list ap);
int __fastcall__ vprintf (const char* format, va_list ap);
int __fastcall__ vsnprintf (char* buf, size_t size, const char* format, va_list ap);
int __fastcall__ vsprintf (char* buf, const char* format, va_list ap);
int __fastcall__ vfprintf (FILE* f, const char* format, __va_list ap);
int __fastcall__ vprintf (const char* format, __va_list ap);
int __fastcall__ vsnprintf (char* buf, size_t size, const char* format, __va_list ap);
int __fastcall__ vsprintf (char* buf, const char* format, __va_list ap);
int scanf (const char* format, ...);
int fscanf (FILE* f, const char* format, ...);
int sscanf (const char* s, const char* format, ...);
int __fastcall__ vscanf (const char* format, va_list ap);
int __fastcall__ vsscanf (const char* s, const char* format, va_list ap);
int __fastcall__ vfscanf (FILE* f, const char* format, va_list ap);
int __fastcall__ vscanf (const char* format, __va_list ap);
int __fastcall__ vsscanf (const char* s, const char* format, __va_list ap);
int __fastcall__ vfscanf (FILE* f, const char* format, __va_list ap);
#if __CC65_STD__ == __CC65_STD_CC65__
FILE* __fastcall__ fdopen (int fd, const char* mode); /* Unix */

View File

@ -36,11 +36,17 @@
#ifndef _STRING_H
#define _STRING_H
/* NULL pointer */
#ifndef _HAVE_NULL
#define NULL 0
#define _HAVE_NULL
#endif
#include <stddef.h>
/* size_t is needed */
#ifndef _HAVE_size_t
#define _HAVE_size_t
typedef unsigned size_t;
#endif
char* __fastcall__ strcat (char* dest, const char* src);
char* __fastcall__ strchr (const char* s, int c);
@ -90,6 +96,5 @@ const char* __fastcall__ _stroserror (unsigned char errcode);
/* Map an operating system error number to an error message. */
/* End of string.h */
#endif

View File

@ -52,7 +52,6 @@ typedef unsigned size_t;
typedef unsigned long time_t;
typedef unsigned long clock_t;
typedef unsigned char clockid_t;
/* Structure for broken down time */
struct tm {
@ -67,22 +66,6 @@ struct tm {
int tm_isdst;
};
/* Structure for seconds and nanoseconds */
struct timespec {
time_t tv_sec;
long tv_nsec;
};
/* Timezone representation, default is UTC */
extern struct _timezone {
char daylight; /* True if daylight savings time active */
long timezone; /* Number of seconds behind UTC */
char tzname[5]; /* Name of timezone, e.g. CET */
char dstname[5]; /* Name when daylight true, e.g. CEST */
} _tz;
#if defined(__ATARI5200__)
# define CLOCKS_PER_SEC 60
#elif defined(__ATMOS__)
@ -109,7 +92,6 @@ extern struct _timezone {
clock_t _clocks_per_sec (void);
# define CLOCKS_PER_SEC _clocks_per_sec()
#endif
#define CLK_TCK CLOCKS_PER_SEC
#define CLOCK_REALTIME 0
@ -125,12 +107,32 @@ size_t __fastcall__ strftime (char* buf, size_t bufsize, const char* format, con
time_t __fastcall__ time (time_t* t);
#if __CC65_STD__ >= __CC65_STD_CC65__
typedef unsigned char clockid_t;
/* Structure for seconds and nanoseconds */
struct timespec {
time_t tv_sec;
long tv_nsec;
};
/* Timezone representation, default is UTC */
extern struct _timezone {
char daylight; /* True if daylight savings time active */
long timezone; /* Number of seconds behind UTC */
char tzname[5]; /* Name of timezone, e.g. CET */
char dstname[5]; /* Name when daylight true, e.g. CEST */
} _tz;
#define CLK_TCK CLOCKS_PER_SEC
/* POSIX function prototypes */
int __fastcall__ clock_getres (clockid_t clock_id, struct timespec *res);
int __fastcall__ clock_gettime (clockid_t clock_id, struct timespec *tp);
int __fastcall__ clock_settime (clockid_t clock_id, const struct timespec *tp);
#endif
/* End of time.h */