From 34181d45f4bf726d0e5a8f35a70427f0e339dcea Mon Sep 17 00:00:00 2001 From: johnbaumann <76951440+johnbaumann@users.noreply.github.com> Date: Fri, 28 Mar 2025 09:03:47 -0500 Subject: [PATCH 1/8] Fix gte_gpl0 and gte_gpl0_b macros --- README.md | 1 + include/inline_n.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0842a50..d92fa87 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ Clone/download the repo, rename your existing psyq include directory, and extrac # Bug Fixes - libgpu.h Protect against possible alignment issues in DISPENV, fix contributed by StiNKz - stdarg.h Deleted, as this is a compiler specific implementation and gcc has its own +- Fix error in gte bytecode/macros for gte_gpl0 and gte_gpl0_b where an extra byte was included, identified by cius # Download this repo https://github.com/johnbaumann/psyq_include_what_you_use/zipball/master diff --git a/include/inline_n.h b/include/inline_n.h index 7ceed24..25e9d98 100644 --- a/include/inline_n.h +++ b/include/inline_n.h @@ -883,7 +883,7 @@ __asm__ volatile( \ "nop;" \ "nop;" \ - "cop2 0x01A0003E0") + "cop2 0x01A0003E;") #define gte_mvmva_core(r0) \ __asm__ volatile( \ @@ -964,7 +964,7 @@ #define gte_gpf12_b() __asm__ volatile("cop2 0x0198003D;") #define gte_gpf0_b() __asm__ volatile("cop2 0x0190003D;") #define gte_gpl12_b() __asm__ volatile("cop2 0x01A8003E;") -#define gte_gpl0_b() __asm__ volatile("cop2 0x01A0003E0;") +#define gte_gpl0_b() __asm__ volatile("cop2 0x01A0003E;") #define gte_mvmva_core_b(r0) __asm__ volatile("cop2 %0" : : "g"(r0)) #define gte_mvmva_b(sf, mx, v, cv, lm) \ gte_mvmva_core_b(0x0400012 | ((sf) << 19) | ((mx) << 17) | ((v) << 15) | ((cv) << 13) | ((lm) << 10)) From 8a7275e411a216b3fea9c13beb4610d49b33dc28 Mon Sep 17 00:00:00 2001 From: johnbaumann <76951440+johnbaumann@users.noreply.github.com> Date: Fri, 28 Mar 2025 10:51:01 -0500 Subject: [PATCH 2/8] Redirect dupe headers to counterparts in sys --- include/errno.h | 60 +----------------------------------- include/fcntl.h | 26 +--------------- include/file.h | 34 +-------------------- include/ioctl.h | 45 +-------------------------- include/types.h | 81 +------------------------------------------------ 5 files changed, 5 insertions(+), 241 deletions(-) diff --git a/include/errno.h b/include/errno.h index be0c751..bdef9dc 100644 --- a/include/errno.h +++ b/include/errno.h @@ -1,59 +1 @@ -/* - * Error codes - * $RCSfile: errno.h,v $ - * $Id: errno.h,v 1.3 1995/02/28 10:02:53 yoshi Exp $ - */ -/* - * $PSLibId: Run-time Library Release 4.7$ - */ - -#ifndef _ERRNO_H -#define _ERRNO_H - -/* Error codes */ - -#define EPERM 1 /* Not owner */ -#define ENOENT 2 /* No such file or directory */ -#define ESRCH 3 /* No such process */ -#define EINTR 4 /* Interrupted system call */ -#define EIO 5 /* I/O error */ -#define ENXIO 6 /* No such device or address */ -#define E2BIG 7 /* Arg list too long */ -#define ENOEXEC 8 /* Exec format error */ -#define EBADF 9 /* Bad file number */ -#define ECHILD 10 /* No children */ -#define EAGAIN 11 /* No more processes */ -#define ENOMEM 12 /* Not enough core */ -#define EACCES 13 /* Permission denied */ -#define EFAULT 14 /* Bad address */ -#define ENOTBLK 15 /* Block device required */ -#define EBUSY 16 /* Mount device busy */ -#define EEXIST 17 /* File exists */ -#define EXDEV 18 /* Cross-device link */ -#define ENODEV 19 /* No such device */ -#define ENOTDIR 20 /* Not a directory*/ -#define EISDIR 21 /* Is a directory */ -#define EINVAL 22 /* Invalid argument */ -#define ENFILE 23 /* File table overflow */ -#define EMFILE 24 /* Too many open files */ -#define ENOTTY 25 /* Not a typewriter */ -#define ETXTBSY 26 /* Text file busy */ -#define EFBIG 27 /* File too large */ -#define ENOSPC 28 /* No space left on device */ -#define ESPIPE 29 /* Illegal seek */ -#define EROFS 30 /* Read-only file system */ -#define EFORMAT 31 /* Bad file format */ -#define EPIPE 32 /* Broken pipe */ - -/* math software */ -#define EDOM 33 /* Argument too large */ -#define ERANGE 34 /* Result too large */ - -/* non-blocking and interrupt i/o */ -#define EWOULDBLOCK 35 /* Operation would block */ -#define EINPROGRESS 36 /* Operation now in progress */ -#define EALREADY 37 /* Operation already in progress */ - -extern int errno; - -#endif /* _ERRNO_H */ +#include \ No newline at end of file diff --git a/include/fcntl.h b/include/fcntl.h index b963ce3..d63db49 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -1,25 +1 @@ -/* - * File:fcntl.h - */ -/* - * $PSLibId: Run-time Library Release 4.7$ - */ - -#ifndef _SYS_FCNTL_H -#define _SYS_FCNTL_H - -/* flags */ -#define FREAD 0x0001 /* readable */ -#define FWRITE 0x0002 /* writable */ -#define FNBLOCK 0x0004 /* non-blocking reads */ -#define FRLOCK 0x0010 /* read locked (non-shared) */ -#define FWLOCK 0x0020 /* write locked (non-shared) */ -#define FAPPEND 0x0100 /* append on each write */ -#define FCREAT 0x0200 /* create if nonexistant */ -#define FTRUNC 0x0400 /* truncate to zero length */ -#define FSCAN 0x1000 /* scan type */ -#define FRCOM 0x2000 /* remote command entry */ -#define FNBUF 0x4000 /* no ring buf. and console interrupt */ -#define FASYNC 0x8000 /* asyncronous i/o */ - -#endif /* _SYS_FCNTL_H */ +#include \ No newline at end of file diff --git a/include/file.h b/include/file.h index 0db9e08..d4d31f8 100644 --- a/include/file.h +++ b/include/file.h @@ -1,33 +1 @@ -/* - * File:file.h -*/ -/* - * $PSLibId: Run-time Library Release 4.7$ - */ - -#ifndef _SYS_FILE_H -#define _SYS_FILE_H - -#include - -/* Flag for open() */ -#define O_RDONLY FREAD -#define O_WRONLY FWRITE -#define O_RDWR FREAD|FWRITE -#define O_CREAT FCREAT /* open with file create */ -#define O_NOBUF FNBUF /* no device buffer and console interrupt */ -#define O_NBLOCK FNBLOCK /* non blocking mode */ -#define O_NOWAIT FASYNC /* asyncronous i/o */ - -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif -#ifndef SEEK_CUR -#define SEEK_CUR 1 -#endif -#ifndef SEEK_END -#define SEEK_END 2 -#endif - -#endif /* _SYS_FILE_H */ - +#include \ No newline at end of file diff --git a/include/ioctl.h b/include/ioctl.h index bcec335..8af7aca 100644 --- a/include/ioctl.h +++ b/include/ioctl.h @@ -1,44 +1 @@ -/* - * File:ioctl.h - */ -/* - * $PSLibId: Run-time Library Release 4.7$ - */ - -#ifndef _SYS_IOCTL_H -#define _SYS_IOCTL_H - - -#ifndef NULL -#define NULL 0 -#endif - -#ifndef EOF -#define EOF (-1) /* EOF from getc() */ -#endif - -/* general */ -#define FIOCNBLOCK (('f'<<8)|1) /* set non-blocking io */ -#define FIOCSCAN (('f'<<8)|2) /* scan for input */ - -/* tty and sio */ -#define TIOCRAW (('t'<<8)|1) /* disable xon/xoff control */ -#define TIOCFLUSH (('t'<<8)|2) /* flush input buffer */ -#define TIOCREOPEN (('t'<<8)|3) /* reopen */ -#define TIOCBAUD (('t'<<8)|4) /* set baud rate */ -#define TIOCEXIT (('t'<<8)|5) /* console interrup */ -#define TIOCDTR (('t'<<8)|6) /* control DTR line */ -#define TIOCRTS (('t'<<8)|7) /* control RTS line */ -#define TIOCLEN (('t'<<8)|8) /* stop<<16 | char */ - /* stop 0:none 1:1 2:1.5 3:2bit */ - /* char 0:5 1:6 2:7 3:8bit */ -#define TIOCPARITY (('t'<<8)|9) /* parity 0:none 1:e 3:o */ -#define TIOSTATUS (('t'<<8)|10) /* return status */ -#define TIOERRRST (('t'<<8)|11) /* error reset */ -#define TIOEXIST (('t'<<8)|12) /* exist test with DTR/CTS */ -#define TIORLEN (('t'<<8)|13) /* receive buffer length */ - -/* disk */ -#define DIOFORMAT (('d'<<8)|1) /* format */ - -#endif /* _SYS_IOCTL_H */ +#include \ No newline at end of file diff --git a/include/types.h b/include/types.h index 5fe5a83..eea9ff0 100644 --- a/include/types.h +++ b/include/types.h @@ -1,80 +1 @@ -/* - * File:types.h - */ -/* - * $PSLibId: Run-time Library Release 4.7$ - */ - -#ifndef _SYS_TYPES_H -#define _SYS_TYPES_H - -/* - * Basic system types and major/minor device constructing/busting macros. - */ - -/* major part of a device */ -#define major(x) ((int)(((unsigned)(x)>>8)&0377)) - -/* minor part of a device */ -#define minor(x) ((int)((x)&0377)) - -/* make a device number */ -#define makedev(x,y) ((dev_t)(((x)<<8) | (y))) - -#ifndef _UCHAR_T -#define _UCHAR_T -typedef unsigned char u_char; -#endif -#ifndef _USHORT_T -#define _USHORT_T -typedef unsigned short u_short; -#endif -#ifndef _UINT_T -#define _UINT_T -typedef unsigned int u_int; -#endif -#ifndef _ULONG_T -#define _ULONG_T -typedef unsigned long u_long; -#endif -#ifndef _SYSIII_USHORT -#define _SYSIII_USHORT -typedef unsigned short ushort; /* sys III compat */ -#endif -#ifndef __psx__ -#ifndef _SYSV_UINT -#define _SYSV_UINT -typedef unsigned int uint; /* sys V compat */ -#endif -#ifndef _SYSV_ULONG -#define _SYSV_ULONG -typedef unsigned long ulong; /* sys V compat */ -#endif -#endif /* ! __psx__ */ - -typedef struct _physadr { int r[1]; } *physadr; -typedef struct label_t { - int val[12]; -} label_t; - -typedef struct _quad { long val[2]; } quad; -typedef long daddr_t; -typedef char * caddr_t; -typedef long * qaddr_t; /* should be typedef quad * qaddr_t; */ -typedef u_long ino_t; -typedef long swblk_t; - -#ifndef _SIZE_T -#define _SIZE_T -typedef unsigned int size_t; -#endif - -typedef long time_t; -typedef short dev_t; -typedef long off_t; -typedef u_short uid_t; -typedef u_short gid_t; - -#define NBBY 8 /* number of bits in a byte */ - -#endif /* _SYS_TYPES_H */ +#include \ No newline at end of file From ba9f718c5de9ed05763b93aac85965a2d0777f7a Mon Sep 17 00:00:00 2001 From: johnbaumann <76951440+johnbaumann@users.noreply.github.com> Date: Fri, 28 Mar 2025 10:52:03 -0500 Subject: [PATCH 3/8] Remove unnecessary include and def guard --- include/kernel.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/include/kernel.h b/include/kernel.h index 1ed7aba..f96ceb6 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -7,13 +7,7 @@ /* * $PSLibId: Run-time Library Release 4.7$ */ -#ifndef _R3000_H -#include -#endif - -#ifndef _ASM_H #include -#endif /* don't change these macros and structures which is refereced in kernel code */ From 3c23cf238b1fba4e9b9dd23327c542dd89304b4c Mon Sep 17 00:00:00 2001 From: ay <49962906+Ay91169@users.noreply.github.com> Date: Tue, 19 Nov 2024 20:42:14 +0100 Subject: [PATCH 4/8] Update libetc.h, Added R3 and L3 support (cherry picked from commit 5f56134dbdabd099aa91a9ebc3321277edfee7cc) --- include/libetc.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/libetc.h b/include/libetc.h index 0190cc7..f3976f6 100644 --- a/include/libetc.h +++ b/include/libetc.h @@ -36,6 +36,8 @@ extern int PadIdentifier; #define PADR2 PADm #define PADstart PADh #define PADselect PADk +#define PADR3 0x00000400 +#define PADL3 0x00000200 #define MOUSEleft (1<<3) #define MOUSEright (1<<2) From 0ef70750cabd6878f48336e4f1683492d59425a1 Mon Sep 17 00:00:00 2001 From: johnbaumann <76951440+johnbaumann@users.noreply.github.com> Date: Fri, 28 Mar 2025 15:09:37 -0500 Subject: [PATCH 5/8] Replace NULL and size_t def/usage with C std lib --- README.md | 2 + include/fs.h | 4 -- include/kernel.h | 4 -- include/libgs.h | 5 +-- include/libmcx.h | 3 -- include/libpad.h | 3 -- include/libsn.h | 96 +-------------------------------------------- include/libsnd.h | 4 -- include/malloc.h | 8 +--- include/memory.h | 9 ----- include/qsort.h | 9 +---- include/stddef.h | 50 ----------------------- include/stdio.h | 5 --- include/sys/ioctl.h | 4 -- include/sys/types.h | 5 --- 15 files changed, 6 insertions(+), 205 deletions(-) delete mode 100644 include/stddef.h diff --git a/README.md b/README.md index d92fa87..87d3977 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ Clone/download the repo, rename your existing psyq include directory, and extrac - libgpu.h Protect against possible alignment issues in DISPENV, fix contributed by StiNKz - stdarg.h Deleted, as this is a compiler specific implementation and gcc has its own - Fix error in gte bytecode/macros for gte_gpl0 and gte_gpl0_b where an extra byte was included, identified by cius +- Redirected duplicate header entries to their counterparts in sys directory +- Added L3/R3 definitions, cherry-picked from fork by Ay91169 # Download this repo https://github.com/johnbaumann/psyq_include_what_you_use/zipball/master diff --git a/include/fs.h b/include/fs.h index ff7e953..b19a4bc 100644 --- a/include/fs.h +++ b/include/fs.h @@ -83,10 +83,6 @@ struct iob { }; #endif /* LANGUAGE_C */ -#ifndef NULL -#define NULL 0 -#endif - /* Request codes */ #define READ 1 #define WRITE 2 diff --git a/include/kernel.h b/include/kernel.h index f96ceb6..61ff938 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -150,10 +150,6 @@ extern struct ToT SysToT[32]; extern long SysClearRCnt[]; -#ifndef NULL -#define NULL (0) -#endif - #if defined(_LANGUAGE_C)||defined(LANGUAGE_C) #define delete erase #endif /* LANGUAGE_C */ diff --git a/include/libgs.h b/include/libgs.h index 6db4f8b..7dda74e 100644 --- a/include/libgs.h +++ b/include/libgs.h @@ -15,12 +15,9 @@ */ #include +#include #include -#ifndef NULL -#define NULL 0 -#endif - /*** packet peripheral pointer ***/ typedef unsigned char PACKET; diff --git a/include/libmcx.h b/include/libmcx.h index c70bf41..b12c1de 100644 --- a/include/libmcx.h +++ b/include/libmcx.h @@ -18,9 +18,6 @@ #ifndef FALSE #define FALSE 0 #endif -#ifndef NULL -#define NULL 0 -#endif #ifndef ERROR #define ERROR (-1) #endif diff --git a/include/libpad.h b/include/libpad.h index b26a243..736ce41 100644 --- a/include/libpad.h +++ b/include/libpad.h @@ -18,9 +18,6 @@ #ifndef FALSE #define FALSE 0 #endif -#ifndef NULL -#define NULL 0 -#endif #define PadStateDiscon 0 diff --git a/include/libsn.h b/include/libsn.h index 1e8726e..9f266f6 100644 --- a/include/libsn.h +++ b/include/libsn.h @@ -54,101 +54,7 @@ extern "C" { extern void __sn_cpp_structors (long, long); - -/* -** FILESERVER FUNCTIONS: -** -** NOTE: For PCread and PCwrite do not load files by passing extreme -** values for count as you might on UNIX as this will cause the full -** amount specified to be transferred - the file will be padded to -** that length with zeroes which may over-write memory beyond the -** end of the file. -** -** If you are unsure of the length of a file which you are about -** to read into memory then perform a -** len = PClseek( fd, 0, 2); -** This will set len to the length of the file which you can then -** pass to a PCread() function call. -** -*/ - -/* -** re-initialise PC filing system, close open files etc -** -** passed: void -** -** return: error code (0 if no error) -*/ -int PCinit (void); - -/* -** open a file on PC host -** -** passed: PC file pathname, open mode, permission flags -** -** return: file-handle or -1 if error -** -** note: perms should be zero (it is ignored) -** -** open mode: 0 => read only -** 1 => write only -** 2 => read/write -*/ -int PCopen (char *name, int flags, int perms); - -/* -** create (and open) a file on PC host -** -** passed: PC file pathname, open mode, permission flags -** -** return: file-handle or -1 if error -** -** note: perms should be zero (it is ignored) -*/ -int PCcreat (char *name, int perms); - -/* -** seek file pointer to new position in file -** -** passed: file-handle, seek offset, seek mode -** -** return: absolute value of new file pointer position -** -** (mode 0 = rel to start, mode 1 = rel to current fp, mode 2 = rel to end) -*/ -int PClseek (int fd, int offset, int mode); - -/* -** read bytes from file on PC -** -** passed: file-handle, buffer address, count -** -** return: count of number of bytes actually read -** -** note: unlike assembler function this provides for full 32 bit count -*/ -int PCread (int fd, char *buff, int len); - -/* -** write bytes to file on PC -** -** passed: file-handle, buffer address, count -** -** return: count of number of bytes actually written -** -** note: unlike assembler function this provides for full 32 bit count -*/ -int PCwrite (int fd, char *buff, int len); - -/* -** close an open file on PC -** -** passed: file-handle -** -** return: negative if error -** -*/ -int PCclose (int fd); +// Forward declarations removed, see re-implementation in nugget's "common/kernel/pcdrv.h" #if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus) diff --git a/include/libsnd.h b/include/libsnd.h index 4afb5df..60352f1 100644 --- a/include/libsnd.h +++ b/include/libsnd.h @@ -68,10 +68,6 @@ #define SND_ADDR 16 #define SND_PITCH 32 -#ifndef NULL -#define NULL 0 -#endif - /* * Vag & Vab Structure diff --git a/include/malloc.h b/include/malloc.h index 4cb73a7..6d600b8 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -7,13 +7,7 @@ #ifndef _MALLOC_H #define _MALLOC_H -#ifndef _SIZE_T -#define _SIZE_T -typedef unsigned int size_t; /* result type of the sizeof operator (ANSI) */ -#endif -#ifndef NULL -#define NULL 0 /* null pointer constant */ -#endif +#include #if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus) extern "C" { diff --git a/include/memory.h b/include/memory.h index ff58946..e85a35a 100644 --- a/include/memory.h +++ b/include/memory.h @@ -9,15 +9,6 @@ #ifndef _MEMORY_H #define _MEMORY_H -#ifndef _SIZE_T -#define _SIZE_T -typedef unsigned int size_t; /* result type of the sizeof operator (ANSI) */ -#endif - -#ifndef NULL -#define NULL 0 /* null pointer constant */ -#endif - #if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus) extern "C" { #endif diff --git a/include/qsort.h b/include/qsort.h index 58d4eab..fe9ce93 100644 --- a/include/qsort.h +++ b/include/qsort.h @@ -9,14 +9,7 @@ #ifndef _QSORT_H #define _QSORT_H -#ifndef _SIZE_T -#define _SIZE_T -typedef unsigned int size_t; /* result type of the sizeof operator (ANSI) */ -#endif - -#ifndef NULL -#define NULL 0 /* null pointer constant */ -#endif +#include #if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus) extern "C" { diff --git a/include/stddef.h b/include/stddef.h deleted file mode 100644 index 61932d1..0000000 --- a/include/stddef.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * File:stddef.h - */ -/* - * $PSLibId: Run-time Library Release 4.7$ - */ - -#ifndef _STDDEF_H -#define _STDDEF_H - - -#ifndef _SIZE_T -#define _SIZE_T -typedef unsigned int size_t; /* result type of the sizeof operator (ANSI) */ -#endif - -#ifndef _WCHAR_T -#define _WCHAR_T -typedef unsigned long wchar_t; /* type of a wide character */ -#endif - -#ifndef _UCHAR_T -#define _UCHAR_T -typedef unsigned char u_char; -#endif - -#ifndef _USHORT_T -#define _USHORT_T -typedef unsigned short u_short; -#endif - -#ifndef _UINT_T -#define _UINT_T -typedef unsigned int u_int; -#endif - -#ifndef _ULONG_T -#define _ULONG_T -typedef unsigned long u_long; -#endif - -#ifndef WEOF -#define WEOF 0xffffffff -#endif - -#ifndef NULL -#define NULL 0 /* null pointer constant */ -#endif - -#endif /* _STDDEF_H */ diff --git a/include/stdio.h b/include/stdio.h index 41c0085..0f4f036 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -21,11 +21,6 @@ #define SEEK_END 2 #endif -#ifndef _SIZE_T -#define _SIZE_T -typedef unsigned int size_t; /* result type of the sizeof operator (ANSI) */ -#endif - /* under constraction now */ #if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus) diff --git a/include/sys/ioctl.h b/include/sys/ioctl.h index c9ac62d..36a1874 100644 --- a/include/sys/ioctl.h +++ b/include/sys/ioctl.h @@ -9,10 +9,6 @@ #define _SYS_IOCTL_H -#ifndef NULL -#define NULL 0 -#endif - #ifndef EOF #define EOF (-1) /* EOF from getc() */ #endif diff --git a/include/sys/types.h b/include/sys/types.h index c3eaca6..731a109 100644 --- a/include/sys/types.h +++ b/include/sys/types.h @@ -64,11 +64,6 @@ typedef long * qaddr_t; /* should be typedef quad * qaddr_t; */ typedef u_long ino_t; typedef long swblk_t; -#ifndef _SIZE_T -#define _SIZE_T -typedef unsigned int size_t; -#endif - typedef long time_t; typedef short dev_t; typedef long off_t; From 5ff2b2c8c0fdbee54d1fafe2bceb2beae6f06666 Mon Sep 17 00:00:00 2001 From: johnbaumann <76951440+johnbaumann@users.noreply.github.com> Date: Fri, 28 Mar 2025 15:14:01 -0500 Subject: [PATCH 6/8] Remove null/size defs, make strdup macro safer --- README.md | 2 ++ include/strings.h | 11 +---------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 87d3977..0e42b97 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ Clone/download the repo, rename your existing psyq include directory, and extrac - Fix error in gte bytecode/macros for gte_gpl0 and gte_gpl0_b where an extra byte was included, identified by cius - Redirected duplicate header entries to their counterparts in sys directory - Added L3/R3 definitions, cherry-picked from fork by Ay91169 +- Remove psyq version of stddef.h, replaced definitions for and usage of NULL and size_t with C Standard Library version of stddef.h +- Make strdup macro safer by adding do...while(0) # Download this repo https://github.com/johnbaumann/psyq_include_what_you_use/zipball/master diff --git a/include/strings.h b/include/strings.h index 84da8bf..02cebd0 100644 --- a/include/strings.h +++ b/include/strings.h @@ -11,15 +11,6 @@ #define LMAX 256 -#ifndef NULL -#define NULL 0 /* null pointer constant */ -#endif - -#ifndef _SIZE_T -#define _SIZE_T -typedef unsigned int size_t; /* result type of the sizeof operator (ANSI) */ -#endif - #include #if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus) @@ -46,7 +37,7 @@ extern char *strstr (const char *, const char *); } #endif -#define strdup(p) ( strcpy(malloc(strlen(p)+1),p); ) +#define strdup(p) do { strcpy(malloc(strlen(p) + 1), p); } while (0) #endif /* _STRINGS_H */ From a472a4b738c9869e66ce166041bebaa05103ab2f Mon Sep 17 00:00:00 2001 From: John Baumann Date: Sat, 20 Sep 2025 10:06:23 -0500 Subject: [PATCH 7/8] Add C23 version check for variadic functions --- include/libgpu.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/libgpu.h b/include/libgpu.h index c2e8d80..1133190 100644 --- a/include/libgpu.h +++ b/include/libgpu.h @@ -721,11 +721,19 @@ extern int KanjiFntPrint(...); #else #ifndef _FNTPRINT_ #define _FNTPRINT_ +#if (__STDC_VERSION__ >= 202311L) +extern int FntPrint(...); +#else extern int FntPrint(); +#endif /* (__STDC_VERSION__ >= 202311L) */ #endif /* _FNTPRINT_ */ #ifndef _KANJIFNTPRINT_ #define _KANJIFNTPRINT_ +#if (__STDC_VERSION__ >= 202311L) +extern int KanjiFntPrint(...); +#else extern int KanjiFntPrint(); +#endif /* (__STDC_VERSION__ >= 202311L) */ #endif /* _KANJIFNTPRINT_ */ #endif From b2b287499e753e9bebf362ea5a4e8ab3cf50831d Mon Sep 17 00:00:00 2001 From: John Baumann Date: Sat, 20 Sep 2025 10:33:31 -0500 Subject: [PATCH 8/8] Tidy L3/R3 alias --- include/libetc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/libetc.h b/include/libetc.h index f3976f6..66f5306 100644 --- a/include/libetc.h +++ b/include/libetc.h @@ -32,12 +32,12 @@ extern int PadIdentifier; #define PADh (1<<11) #define PADL1 PADn #define PADL2 PADo +#define PADL3 PADi #define PADR1 PADl #define PADR2 PADm +#define PADR3 PADj #define PADstart PADh #define PADselect PADk -#define PADR3 0x00000400 -#define PADL3 0x00000200 #define MOUSEleft (1<<3) #define MOUSEright (1<<2)