sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
sysclib.h
Go to the documentation of this file.
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# Copyright (c) 2003 Marcus R. Brown <mrbrown@0xd6.org>
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
16
17#ifndef __SYSCLIB_H__
18#define __SYSCLIB_H__
19
20#include <types.h>
21#include <irx.h>
22#include <stdarg.h>
23#include <setjmp.h>
24#include <ctype.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30typedef void (*print_callback_t)(void *context, int c);
31
32/* setjmp/longjmp are already defined in setjmp.h */
33
34/* These functions are non-standardized (IOP-only functions operating on 32-bit integers instead of wchar_t) */
35extern void *_wmemcopy(u32 *dest, const u32 *src, size_t size);
36extern void *_wmemset(u32 *dest, u32 c, size_t size);
37#ifdef SYSCLIB_ENABLE_NONSTD_WIDE_MEMCOPY
38#define wmemcopy _wmemcopy
39#define wmemset _wmemset
40#endif
41
42/* This function is non-standard. */
43extern int prnt(print_callback_t, void *context, const char * format, va_list ap);
44
45/* This function is non-standard. */
46extern char *atob(char *s, int *i);
47
48extern void *memchr(const void *s, int c, size_t n);
49extern int memcmp(const void *p, const void *q, size_t size);
50extern void * memcpy(void *dest, const void *src, size_t size);
51extern void *memmove(void *dest, const void *src, size_t size);
52extern void * memset(void *ptr, int c, size_t size);
53extern int bcmp(const void *, const void *, size_t);
54extern void bcopy(const void *, void *, size_t);
55extern void bzero(void *, size_t);
56extern int sprintf(char *str, const char *format, ...);
57extern char *strcat(char *dest, const char *src);
58extern char *strchr(const char *s, int c);
59extern int strcmp(const char *p, const char *q);
60extern char *strcpy(char *dest, const char *src);
61extern size_t strcspn(const char *s, const char *reject);
62extern char *index(const char *s, int c);
63extern char *rindex(const char *s, int c);
64extern size_t strlen(const char *s);
65extern char *strncat(char *dest, const char *src, size_t size);
66extern int strncmp(const char *p, const char *q, size_t size);
67extern char *strncpy(char *dest, const char *src, size_t size);
68extern char *strpbrk(const char *s, const char *accept);
69extern char *strrchr(const char *s, int c);
70extern size_t strspn(const char *s, const char *accept);
71extern char *strstr(const char *haystack, const char *needle);
72extern char *strtok(char *s, const char *delim);
73extern long strtol(const char *s, char **endptr, int base);
74extern unsigned long strtoul(const char *s, char **endptr, int base);
75
76// The following was introduced in export version 1.2 (around SDK 2.3)
77extern int vsprintf(char *, const char *, va_list);
78
79// The following was introduced in export version 1.4 (around SDK 2.8)
80extern char *strtok_r(char *s, const char *delim, char **lasts);
81
82#ifndef SYSCLIB_DISABLE_BUILTINS
83#ifndef memchr
84#define memchr __builtin_memchr
85#endif
86#ifndef memcmp
87#define memcmp __builtin_memcmp
88#endif
89#ifndef memcpy
90#define memcpy __builtin_memcpy
91#endif
92#ifndef memset
93#define memset __builtin_memset
94#endif
95#ifndef bcmp
96#define bcmp __builtin_bcmp
97#endif
98#ifndef bzero
99#define bzero __builtin_bzero
100#endif
101#ifndef sprintf
102#define sprintf __builtin_sprintf
103#endif
104#ifndef strcat
105#define strcat __builtin_strcat
106#endif
107#ifndef strchr
108#define strchr __builtin_strchr
109#endif
110#ifndef strcmp
111#define strcmp __builtin_strcmp
112#endif
113#ifndef strcpy
114#define strcpy __builtin_strcpy
115#endif
116#ifndef strcspn
117#define strcspn __builtin_strcspn
118#endif
119#ifndef index
120#define index __builtin_index
121#endif
122#ifndef rindex
123#define rindex __builtin_rindex
124#endif
125#ifndef strlen
126#define strlen __builtin_strlen
127#endif
128#ifndef strncat
129#define strncat __builtin_strncat
130#endif
131#ifndef strncmp
132#define strncmp __builtin_strncmp
133#endif
134#ifndef strncpy
135#define strncpy __builtin_strncpy
136#endif
137#ifndef strpbrk
138#define strpbrk __builtin_strpbrk
139#endif
140#ifndef strrchr
141#define strrchr __builtin_strrchr
142#endif
143#ifndef strspn
144#define strspn __builtin_strspn
145#endif
146#ifndef strstr
147#define strstr __builtin_strstr
148#endif
149#ifndef vsprintf
150#define vsprintf __builtin_vsprintf
151#endif
152#endif
153
154#define sysclib_IMPORTS_start DECLARE_IMPORT_TABLE(sysclib, 1, 1)
155#define sysclib_IMPORTS_end END_IMPORT_TABLE
156
157#define I_setjmp DECLARE_IMPORT(4, setjmp)
158#define I_longjmp DECLARE_IMPORT(5, longjmp)
159#define I_toupper DECLARE_IMPORT(6, _toupper)
160#define I_tolower DECLARE_IMPORT(7, _tolower)
161#define I_look_ctype_table DECLARE_IMPORT(8, look_ctype_table)
162#define I_get_ctype_table DECLARE_IMPORT(9, get_ctype_table)
163#define I_memchr DECLARE_IMPORT(10, memchr)
164#define I_memcmp DECLARE_IMPORT(11, memcmp)
165#define I_memcpy DECLARE_IMPORT(12, memcpy)
166#define I_memmove DECLARE_IMPORT(13, memmove)
167#define I_memset DECLARE_IMPORT(14, memset)
168#define I_bcmp DECLARE_IMPORT(15, bcmp);
169#define I_bcopy DECLARE_IMPORT(16, bcopy);
170#define I_bzero DECLARE_IMPORT(17, bzero);
171#define I_prnt DECLARE_IMPORT(18, prnt)
172#define I_sprintf DECLARE_IMPORT(19, sprintf)
173#define I_strcat DECLARE_IMPORT(20, strcat)
174#define I_strchr DECLARE_IMPORT(21, strchr)
175#define I_strcmp DECLARE_IMPORT(22, strcmp)
176#define I_strcpy DECLARE_IMPORT(23, strcpy)
177#define I_strcspn DECLARE_IMPORT(24, strcspn)
178#define I_index DECLARE_IMPORT(25, index)
179#define I_rindex DECLARE_IMPORT(26, rindex)
180#define I_strlen DECLARE_IMPORT(27, strlen)
181#define I_strncat DECLARE_IMPORT(28, strncat)
182#define I_strncmp DECLARE_IMPORT(29, strncmp)
183#define I_strncpy DECLARE_IMPORT(30, strncpy)
184#define I_strpbrk DECLARE_IMPORT(31, strpbrk)
185#define I_strrchr DECLARE_IMPORT(32, strrchr)
186#define I_strspn DECLARE_IMPORT(33, strspn)
187#define I_strstr DECLARE_IMPORT(34, strstr)
188#define I_strtok DECLARE_IMPORT(35, strtok)
189#define I_strtol DECLARE_IMPORT(36, strtol)
190#define I_atob DECLARE_IMPORT(37, atob)
191#define I_strtoul DECLARE_IMPORT(38, strtoul)
192#define I_wmemcopy DECLARE_IMPORT(40, _wmemcopy)
193#define I_wmemset DECLARE_IMPORT(41, _wmemset)
194#define I_vsprintf DECLARE_IMPORT(42, vsprintf)
195#define I_strtok_r DECLARE_IMPORT(43, strtok_r)
196
197#ifdef __cplusplus
198}
199#endif
200
201#endif /* __SYSCLIB_H__ */