Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ 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 <vini> cius

Copilot AI Mar 28, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The term 'cius' appears to be a typo. Please verify and correct it if necessary.

Suggested change
- Fix error in gte bytecode/macros for gte_gpl0 and gte_gpl0_b where an extra byte was included, identified by <vini> cius
- Fix error in gte bytecode/macros for gte_gpl0 and gte_gpl0_b where an extra byte was included, identified by <vini>

Copilot uses AI. Check for mistakes.
- 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
60 changes: 1 addition & 59 deletions include/errno.h
Original file line number Diff line number Diff line change
@@ -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 <sys/errno.h>
26 changes: 1 addition & 25 deletions include/fcntl.h
Original file line number Diff line number Diff line change
@@ -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 <sys/fcntl.h>
34 changes: 1 addition & 33 deletions include/file.h
Original file line number Diff line number Diff line change
@@ -1,33 +1 @@
/*
* File:file.h
*/
/*
* $PSLibId: Run-time Library Release 4.7$
*/

#ifndef _SYS_FILE_H
#define _SYS_FILE_H

#include <sys/fcntl.h>

/* 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 <sys/file.h>
4 changes: 0 additions & 4 deletions include/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ struct iob {
};
#endif /* LANGUAGE_C */

#ifndef NULL
#define NULL 0
#endif

/* Request codes */
#define READ 1
#define WRITE 2
Expand Down
4 changes: 2 additions & 2 deletions include/inline_n.h
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@
__asm__ volatile( \
"nop;" \
"nop;" \
"cop2 0x01A0003E0")
"cop2 0x01A0003E;")

#define gte_mvmva_core(r0) \
__asm__ volatile( \
Expand Down Expand Up @@ -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))
Expand Down
45 changes: 1 addition & 44 deletions include/ioctl.h
Original file line number Diff line number Diff line change
@@ -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 <sys/ioctl.h>
10 changes: 0 additions & 10 deletions include/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@
/*
* $PSLibId: Run-time Library Release 4.7$
*/
#ifndef _R3000_H
#include <r3000.h>
#endif

#ifndef _ASM_H
#include <asm.h>
#endif

/* don't change these macros and structures which is refereced in kernel code */

Expand Down Expand Up @@ -156,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 */
Expand Down
2 changes: 2 additions & 0 deletions include/libetc.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ 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

Expand Down
8 changes: 8 additions & 0 deletions include/libgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 1 addition & 4 deletions include/libgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
*/

#include <libgpu.h>
#include <stddef.h>
#include <types.h>

#ifndef NULL
#define NULL 0
#endif

/*** packet peripheral pointer ***/
typedef unsigned char PACKET;

Expand Down
3 changes: 0 additions & 3 deletions include/libmcx.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
#ifndef FALSE
#define FALSE 0
#endif
#ifndef NULL
#define NULL 0
#endif
#ifndef ERROR
#define ERROR (-1)
#endif
Expand Down
3 changes: 0 additions & 3 deletions include/libpad.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
#ifndef FALSE
#define FALSE 0
#endif
#ifndef NULL
#define NULL 0
#endif


#define PadStateDiscon 0
Expand Down
Loading