aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspicyjpeg <88942473+spicyjpeg@users.noreply.github.com>2021-11-18 17:23:25 +0100
committerspicyjpeg <88942473+spicyjpeg@users.noreply.github.com>2021-11-18 17:23:25 +0100
commit619fa016bbc4ddd8d4a670cf3f8aa63617473b2f (patch)
tree3b526a071b715452beadf168e3c6fc898b5fe48c
parent8b6a76055ca426c494e16042e21f5e19b870b2ac (diff)
downloadpsn00bsdk-619fa016bbc4ddd8d4a670cf3f8aa63617473b2f.tar.gz
Deprecated malloc.h, moved int*_t types to stdint.h
-rw-r--r--examples/beginner/cppdemo/main.cpp2
-rw-r--r--examples/cdrom/cdbrowse/main.c1
-rw-r--r--examples/cdrom/cdxa/main.c1
-rw-r--r--examples/demos/n00bdemo/logo.c1
-rw-r--r--examples/demos/n00bdemo/main.c1
-rw-r--r--examples/io/pads/main.c2
-rw-r--r--examples/io/pads/spi.c4
-rw-r--r--examples/io/pads/spi.h1
-rw-r--r--examples/system/dynlink/library/balls.c2
-rw-r--r--examples/system/dynlink/library/cube.c2
-rw-r--r--examples/system/dynlink/library/dll_common.h1
-rw-r--r--examples/system/dynlink/main.c3
-rw-r--r--indev/psxmdec/main.c2
-rw-r--r--indev/psxpad/main.c1
-rw-r--r--libpsn00b/include/malloc.h14
-rw-r--r--libpsn00b/include/stdint.h16
-rw-r--r--libpsn00b/include/stdlib.h28
-rw-r--r--libpsn00b/include/sys/types.h16
-rw-r--r--libpsn00b/libc/c++-support.cxx3
-rw-r--r--libpsn00b/libc/string.c2
-rw-r--r--libpsn00b/lzp/compress.c1
-rw-r--r--libpsn00b/psxcd/isofs.c2
-rw-r--r--libpsn00b/psxetc/dl.c4
-rw-r--r--libpsn00b/psxgpu/font.c2
-rw-r--r--tools/util/elf2cpe.c2
25 files changed, 48 insertions, 66 deletions
diff --git a/examples/beginner/cppdemo/main.cpp b/examples/beginner/cppdemo/main.cpp
index 58bfcda..fd2e3a8 100644
--- a/examples/beginner/cppdemo/main.cpp
+++ b/examples/beginner/cppdemo/main.cpp
@@ -13,7 +13,7 @@
#include <sys/types.h>
#include <stdio.h>
-#include <malloc.h>
+#include <stdlib.h>
#include <psxgte.h>
#include <psxgpu.h>
diff --git a/examples/cdrom/cdbrowse/main.c b/examples/cdrom/cdbrowse/main.c
index ead2df0..9a1dbd0 100644
--- a/examples/cdrom/cdbrowse/main.c
+++ b/examples/cdrom/cdbrowse/main.c
@@ -67,7 +67,6 @@
#include <psxspu.h>
#include <psxcd.h>
-#include <malloc.h>
#include "ball16c.h"
diff --git a/examples/cdrom/cdxa/main.c b/examples/cdrom/cdxa/main.c
index 16f1c82..5f11d8d 100644
--- a/examples/cdrom/cdxa/main.c
+++ b/examples/cdrom/cdxa/main.c
@@ -129,7 +129,6 @@
#include <psxspu.h>
#include <psxcd.h>
-#include <malloc.h>
#include "ball16c.h"
diff --git a/examples/demos/n00bdemo/logo.c b/examples/demos/n00bdemo/logo.c
index d10b5b4..40160e7 100644
--- a/examples/demos/n00bdemo/logo.c
+++ b/examples/demos/n00bdemo/logo.c
@@ -5,7 +5,6 @@
#include <psxgte.h>
#include <psxgpu.h>
#include <inline_c.h>
-#include "malloc.h"
#include "smd.h"
#include <lzp/lzp.h>
diff --git a/examples/demos/n00bdemo/main.c b/examples/demos/n00bdemo/main.c
index e9dd336..d2fe317 100644
--- a/examples/demos/n00bdemo/main.c
+++ b/examples/demos/n00bdemo/main.c
@@ -32,7 +32,6 @@
#include <lzp/lzp.h>
#include <lzp/lzqlp.h>
-#include "malloc.h"
#include "smd.h"
#include "data.h"
#include "disp.h"
diff --git a/examples/io/pads/main.c b/examples/io/pads/main.c
index ea7219b..92beb1c 100644
--- a/examples/io/pads/main.c
+++ b/examples/io/pads/main.c
@@ -23,7 +23,7 @@
* zerofilled responses, slow replies) for maximum compatibility.
*/
-#include <sys/types.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/examples/io/pads/spi.c b/examples/io/pads/spi.c
index 5fc2648..e01b3f6 100644
--- a/examples/io/pads/spi.c
+++ b/examples/io/pads/spi.c
@@ -26,9 +26,9 @@
* card APIs) alongside it.
*/
-#include <sys/types.h>
+#include <stdint.h>
#include <string.h>
-#include <malloc.h>
+#include <stdlib.h>
#include <psxetc.h>
#include <psxapi.h>
#include <psxpad.h>
diff --git a/examples/io/pads/spi.h b/examples/io/pads/spi.h
index 09223e2..1c473cd 100644
--- a/examples/io/pads/spi.h
+++ b/examples/io/pads/spi.h
@@ -6,6 +6,7 @@
#ifndef __SPI_H
#define __SPI_H
+#include <stdint.h>
#include <psxpad.h>
//#define SPI_BUFF_LEN 34
diff --git a/examples/system/dynlink/library/balls.c b/examples/system/dynlink/library/balls.c
index 2a4d9f4..ef6993e 100644
--- a/examples/system/dynlink/library/balls.c
+++ b/examples/system/dynlink/library/balls.c
@@ -3,7 +3,7 @@
* (C) 2021 spicyjpeg - MPL licensed
*/
-#include <sys/types.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <psxgpu.h>
diff --git a/examples/system/dynlink/library/cube.c b/examples/system/dynlink/library/cube.c
index 57f3e56..84fe552 100644
--- a/examples/system/dynlink/library/cube.c
+++ b/examples/system/dynlink/library/cube.c
@@ -3,7 +3,7 @@
* (C) 2021 spicyjpeg - MPL licensed
*/
-#include <sys/types.h>
+#include <stdint.h>
#include <stdio.h>
#include <psxgpu.h>
#include <psxgte.h>
diff --git a/examples/system/dynlink/library/dll_common.h b/examples/system/dynlink/library/dll_common.h
index 4f9314b..315a993 100644
--- a/examples/system/dynlink/library/dll_common.h
+++ b/examples/system/dynlink/library/dll_common.h
@@ -6,6 +6,7 @@
#ifndef __DLL_COMMON_H
#define __DLL_COMMON_H
+#include <stdint.h>
#include <psxgpu.h>
/* Common structures shared by the main executable and DLLs */
diff --git a/examples/system/dynlink/main.c b/examples/system/dynlink/main.c
index 33f6f44..6d93e71 100644
--- a/examples/system/dynlink/main.c
+++ b/examples/system/dynlink/main.c
@@ -36,12 +36,11 @@
* as plugins/mods/patches stored on a memory card.
*/
-#include <sys/types.h>
+#include <stdint.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <malloc.h>
#include <dlfcn.h>
#include <psxapi.h>
#include <psxetc.h>
diff --git a/indev/psxmdec/main.c b/indev/psxmdec/main.c
index c9fd678..f4f0f51 100644
--- a/indev/psxmdec/main.c
+++ b/indev/psxmdec/main.c
@@ -1,7 +1,7 @@
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
-#include <malloc.h>
+#include <stdlib.h>
#include <psxgte.h>
#include <psxgpu.h>
diff --git a/indev/psxpad/main.c b/indev/psxpad/main.c
index e8a6181..afd801e 100644
--- a/indev/psxpad/main.c
+++ b/indev/psxpad/main.c
@@ -1,7 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <malloc.h>
#include <psxetc.h>
#include <psxgte.h>
#include <psxgpu.h>
diff --git a/libpsn00b/include/malloc.h b/libpsn00b/include/malloc.h
index d94823f..75c3711 100644
--- a/libpsn00b/include/malloc.h
+++ b/libpsn00b/include/malloc.h
@@ -1,18 +1,8 @@
#ifndef _MALLOC_H
#define _MALLOC_H
-#ifdef __cplusplus
-extern "C" {
-#endif
+#warning "<malloc.h> is deprecated, include <stdlib.h> instead"
-unsigned int *GetBSSend();
-void InitHeap(unsigned int *addr, int size);
-int SetHeapSize(int size);
-void *malloc(int size);
-void free(void *ptr);
-
-#ifdef __cplusplus
-}
-#endif
+#include <stdlib.h>
#endif // _MALLOC_H \ No newline at end of file
diff --git a/libpsn00b/include/stdint.h b/libpsn00b/include/stdint.h
new file mode 100644
index 0000000..83acb00
--- /dev/null
+++ b/libpsn00b/include/stdint.h
@@ -0,0 +1,16 @@
+#ifndef _STDINT_H
+#define _STDINT_H
+
+typedef unsigned int size_t;
+
+typedef char int8_t;
+typedef short int16_t;
+typedef int int32_t;
+typedef long long int64_t;
+
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+
+#endif // _STDINT_H \ No newline at end of file
diff --git a/libpsn00b/include/stdlib.h b/libpsn00b/include/stdlib.h
index 474eba6..de3ab47 100644
--- a/libpsn00b/include/stdlib.h
+++ b/libpsn00b/include/stdlib.h
@@ -19,34 +19,16 @@ extern long atol(char *s);
extern char atob(char *s); // Is this right?
*/
-// Random number functions (not yet implemented)
-
-/*
-int rand();
-void srand(unsigned int seed);
-*/
-
// Quick sort (not yet implemented)
//void qsort(void *base , int nel , int width , int (*cmp)(const void *,const void *));
-// Memory allocation functions (not yet implemented, avoid using BIOS as they are reportedly buggy)
-
-/*
-#warning "malloc() family of functions NEEDS MORE TESTING"
-
-void *malloc(int size);
-void free(void *buf);
-void *calloc(int number, int size);
-void *realloc(void *buf , int n);
-*/
-
#ifdef __cplusplus
extern "C" {
#endif
extern int __argc;
-extern char __argv[];
+extern const char **__argv;
int rand();
void srand(unsigned long seed);
@@ -64,6 +46,14 @@ long atol(const char *s);
double strtod(const char *nptr, char **endptr);
float strtof(const char *nptr, char **endptr);
+// Memory allocation functions
+unsigned int *GetBSSend();
+void InitHeap(unsigned int *addr, int size);
+int SetHeapSize(int size);
+void *malloc(int size);
+void *calloc(int number, int size);
+void free(void *ptr);
+
#ifdef __cplusplus
}
#endif
diff --git a/libpsn00b/include/sys/types.h b/libpsn00b/include/sys/types.h
index aee197e..da43590 100644
--- a/libpsn00b/include/sys/types.h
+++ b/libpsn00b/include/sys/types.h
@@ -1,21 +1,13 @@
#ifndef _TYPES_H
#define _TYPES_H
+//#warning "<sys/types.h> and u_* types are deprecated, include <stdint.h> instead"
+
+//#include <stdint.h>
+
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;
-typedef unsigned int size_t;
-
-typedef char int8_t;
-typedef short int16_t;
-typedef int int32_t;
-typedef long long int64_t;
-
-typedef unsigned char uint8_t;
-typedef unsigned short uint16_t;
-typedef unsigned int uint32_t;
-typedef unsigned long long uint64_t;
-
#endif // _TYPES_H \ No newline at end of file
diff --git a/libpsn00b/libc/c++-support.cxx b/libpsn00b/libc/c++-support.cxx
index fcf7cfc..d169fdb 100644
--- a/libpsn00b/libc/c++-support.cxx
+++ b/libpsn00b/libc/c++-support.cxx
@@ -1,7 +1,6 @@
#include <assert.h>
-#include <sys/types.h>
+#include <stdint.h>
#include <stdlib.h>
-#include <malloc.h>
extern "C"
diff --git a/libpsn00b/libc/string.c b/libpsn00b/libc/string.c
index e11ed67..445b227 100644
--- a/libpsn00b/libc/string.c
+++ b/libpsn00b/libc/string.c
@@ -6,7 +6,7 @@
#include <stdio.h>
#include <string.h>
-#include <malloc.h>
+#include <stdlib.h>
int tolower(int chr)
{
diff --git a/libpsn00b/lzp/compress.c b/libpsn00b/lzp/compress.c
index 5969dd6..9cfc64d 100644
--- a/libpsn00b/lzp/compress.c
+++ b/libpsn00b/lzp/compress.c
@@ -3,7 +3,6 @@
#include <string.h>
#if LZP_USE_MALLOC == TRUE
#include <stdlib.h>
-#include <malloc.h>
#endif
#include "lzconfig.h"
diff --git a/libpsn00b/psxcd/isofs.c b/libpsn00b/psxcd/isofs.c
index dc0c5ca..40a40af 100644
--- a/libpsn00b/psxcd/isofs.c
+++ b/libpsn00b/psxcd/isofs.c
@@ -1,6 +1,6 @@
#include <sys/types.h>
#include <stdio.h>
-#include <malloc.h>
+#include <stdlib.h>
#include <string.h>
#include <psxgpu.h>
#include <psxsio.h>
diff --git a/libpsn00b/psxetc/dl.c b/libpsn00b/psxetc/dl.c
index 586e7e1..e43374f 100644
--- a/libpsn00b/psxetc/dl.c
+++ b/libpsn00b/psxetc/dl.c
@@ -23,9 +23,9 @@
* of entries
*/
-#include <sys/types.h>
+#include <stdint.h>
#include <stdio.h>
-#include <malloc.h>
+#include <stdlib.h>
#include <ctype.h>
#include <elf.h>
#include <dlfcn.h>
diff --git a/libpsn00b/psxgpu/font.c b/libpsn00b/psxgpu/font.c
index 7d0dd89..4c715a9 100644
--- a/libpsn00b/psxgpu/font.c
+++ b/libpsn00b/psxgpu/font.c
@@ -1,7 +1,7 @@
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
-#include <malloc.h>
+#include <stdlib.h>
#include <ctype.h>
#include <psxgpu.h>
diff --git a/tools/util/elf2cpe.c b/tools/util/elf2cpe.c
index 46b0a37..210f25b 100644
--- a/tools/util/elf2cpe.c
+++ b/tools/util/elf2cpe.c
@@ -1,6 +1,6 @@
#include <stdio.h>
#include <string.h>
-#include <malloc.h>
+#include <stdlib.h>
#include "elf.h"
#ifdef WIN32