Skip to content

Commit 150911b

Browse files
clean up some headers
1 parent 8ede84f commit 150911b

File tree

14 files changed

+201
-167
lines changed

14 files changed

+201
-167
lines changed

examples/hello_world/src/main.c

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ int main(void)
1313
/* Waits for a key */
1414
while (!os_GetCSC());
1515

16-
exit(0);
17-
1816
/* Return 0 for success */
1917
return 0;
2018
}

src/std/ctype.h

+17-6
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
11
#ifndef CTYPE_H
22
#define CTYPE_H
33

4-
#ifdef __cplusplus
5-
extern "C" {
6-
#endif
4+
#include <cdefs.h>
5+
6+
__BEGIN_DECLS
77

88
#define TRUE 1
99
#define FALSE 0
1010

1111
int isalnum(int c);
12+
1213
int isalpha(int c);
14+
1315
int iscntrl(int c);
16+
1417
int isdigit(int c);
18+
1519
int isgraph(int c);
20+
1621
int islower(int c);
22+
1723
int isprint(int c);
24+
1825
int ispunct(int c);
26+
1927
int isspace(int c);
28+
2029
int isupper(int c);
30+
2131
int tolower(int c);
32+
2233
int toupper(int c);
34+
2335
int isascii(int c);
36+
2437
int isxdigit(int c);
2538

26-
#ifdef __cplusplus
27-
}
28-
#endif
39+
__END_DECLS
2940

3041
#endif

src/std/errno.h

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
/*
2-
* Copyright (C) 1999-2008 by Zilog, Inc.
3-
* All Rights Reserved
4-
* Modified by Matt "MateoConLechuga" Waltz for TI84+CE platform
5-
*/
61
#ifndef ERRNO_H
72
#define ERRNO_H
83

9-
#define ERR_NOR 1 /* read not allowed for file */
10-
#define ERR_NOW 2 /* write not allowed for file */
11-
#define ERR_IO 3 /* io error */
12-
#define EDOM 4 /* domain error */
13-
#define ERANGE 5 /* range error */
4+
#define EPERM 1 /* permission error */
5+
#define EINVAL 2 /* invalid argument */
6+
#define EIO 3 /* io error */
7+
#define EDOM 4 /* math domain error */
8+
#define ERANGE 5 /* math range error */
9+
1410
extern int errno;
11+
1512
#endif

src/std/setjmp.h

+9-15
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
/*
2-
* Copyright (C) 1999-2008 by Zilog, Inc.
3-
* All Rights Reserved
4-
*/
5-
#ifndef __SETJMP_H
6-
#define __SETJMP_H
1+
#ifndef _SETJMP_H
2+
#define _SETJMP_H
73

8-
#ifdef __cplusplus
9-
extern "C" {
10-
#endif
4+
#include <cdefs.h>
115

12-
typedef unsigned char jmp_buf[12];
6+
__BEGIN_DECLS
137

14-
int setjmp(jmp_buf env);
15-
void longjmp(jmp_buf env, int val);
8+
typedef unsigned char __jmp_buf[12];
169

17-
#ifdef __cplusplus
18-
}
19-
#endif
10+
int setjmp(__jmp_buf env);
11+
void longjmp(__jmp_buf env, int val) __attribute__((noreturn));
12+
13+
__END_DECLS
2014

2115
#endif

src/std/shared/bsearch.c

+2-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,8 @@
2424
* nothing
2525
*
2626
*************************************************/
27-
void *bsearch(void *keyp,
28-
void *ptr,
29-
size_t num,
30-
size_t width,
31-
int (*comp)(void *,void *))
27+
void *bsearch(void *keyp, void *ptr, size_t num, size_t width,
28+
int (*comp)(const void *, const void *))
3229
{
3330
char *key = keyp;
3431
char *base = ptr;

src/std/shared/fpdata.c

-7
This file was deleted.

src/std/shared/qsort.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ struct stk {
4040
char *r;
4141
};
4242

43-
void qsort( void *ptr,
44-
size_t nel,
45-
size_t size,
46-
int (*compar)(void *,void *))
43+
void qsort(void *ptr, size_t nel, size_t size,
44+
int (*compar)(const void *, const void *))
4745
{
4846
char *base = ptr;
4947
char *i;

src/std/shared/rand.src

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
; int rand(void);
21
assume adl=1
32

43
public _rand

src/std/shared/strtol.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
* the value of the number
2727
*
2828
*************************************************/
29-
long strtol(const char *cp,char **endptr,int base)
29+
long strtol(const char *__restrict nptr,
30+
char **__restrict endptr, int base)
3031
{
31-
register long sum,psum;
32-
register char sign;
33-
register int radix = base;
32+
long sum,psum;
33+
char sign;
34+
int radix = base;
35+
char *cp = (char*)nptr;
3436
char digit;
3537

3638
while (isspace(*cp))

src/std/shared/strtoul.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,22 @@
1515
* strtoul - string to unsigned long conversion
1616
*
1717
* Inputs:
18-
* cp - pointer to the character string
18+
* nptr - pointer to the character string
1919
* endptr - place to put ptr to first invalid character
2020
* base - radix
2121
*
2222
* Returns:
2323
* the value of the number
2424
*
2525
*************************************************/
26-
unsigned long strtoul(char * cp,char ** endptr,int base)
26+
unsigned long strtoul(const char *__restrict nptr,
27+
char **__restrict endptr, int base)
2728
{
28-
register unsigned long sum,psum;
29-
register unsigned char sign;
30-
register unsigned char radix = base;
31-
register unsigned char digit;
29+
unsigned long sum, psum;
30+
unsigned char sign;
31+
unsigned char digit;
32+
unsigned char radix = base;
33+
char *cp = (char*)nptr;
3234

3335
while (isspace(*cp))
3436
++cp;

src/std/static/strtod.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
#include <stddef.h>
1414
#include <math.h>
1515
#include <errno.h>
16-
//#include <float.h>
1716

18-
double strtod(const char * str,char ** endptr)
17+
double strtod(const char *__restrict nptr,
18+
char **__restrict endptr)
1919
{
20-
return strtof(str, endptr);
20+
return strtof(nptr, endptr);
2121
}
2222

2323
/*************************************************
@@ -33,7 +33,8 @@ double strtod(const char * str,char ** endptr)
3333
* the value of the number
3434
*
3535
*************************************************/
36-
float strtof(const char * str,char ** endptr)
36+
float strtof(const char *__restrict nptr,
37+
char **__restrict endptr)
3738
{
3839
union
3940
{
@@ -44,6 +45,7 @@ float strtof(const char * str,char ** endptr)
4445
int exp = 0;
4546
signed char sign = 1;
4647
signed char exp_sign = 1;
48+
char *str = (char*)nptr;
4749

4850
while (isspace(*str))
4951
++str;

src/std/stdio.h

+12-10
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33

44
#include <stdarg.h>
55
#include <format.h>
6+
#include <cdefs.h>
67

7-
#ifdef __cplusplus
8-
extern "C" {
9-
#endif
8+
__BEGIN_DECLS
109

1110
#ifndef SIZE_T_DEFINED
1211
#define SIZE_T_DEFINED
@@ -31,13 +30,16 @@ typedef __SIZE_TYPE__ size_t;
3130
#define SEEK_SET 0
3231
#endif
3332

34-
int printf(const char *format, ...);
35-
int sprintf(char *s, const char *format, ...);
36-
int vprintf(const char *format, va_list arg);
37-
int vsprintf(char *s, const char *format, va_list arg);
33+
int printf(const char *__restrict format, ...);
3834

39-
#ifdef __cplusplus
40-
}
41-
#endif
35+
int sprintf(char *__restrict str,
36+
const char *__restrict format, ...);
37+
38+
int vprintf(const char *__restrict format, va_list __arg);
39+
40+
int vsprintf(char *__restrict str, const char *__restrict format,
41+
va_list __arg);
42+
43+
__END_DECLS
4244

4345
#endif

0 commit comments

Comments
 (0)