Skip to content

Commit f33db92

Browse files
committed
Add EXPORT_FUNC macro
1 parent f77a907 commit f33db92

2 files changed

Lines changed: 20 additions & 39 deletions

File tree

include/module.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ extern const library_t __stop_exported_libraries[];
3030
.func_table_stop = __stop_##_name##_func_table \
3131
}
3232

33-
#define EXPORT(library, nid, type, name, ...) \
34-
type name(__VA_ARGS__); \
33+
#define EXPORT_FUNC(library, nid, func) \
3534
static const uint32_t library##_##name##_##nid##_nid \
3635
__attribute__((used, section(#library "_func_nidtable"))) = nid; \
3736
static const void *const library##_##name##_##nid##_func \
38-
__attribute__((used, section(#library "_func_table"))) = &name; \
37+
__attribute__((used, section(#library "_func_table"))) = &func;
38+
39+
#define EXPORT(library, nid, type, name, ...) \
40+
type name(__VA_ARGS__); \
41+
EXPORT_FUNC(library, nid, name) \
3942
type name(__VA_ARGS__)
4043

4144
#define NUM_EXPORTED_LIBS \

source/modules/SceLibKernel.c

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ EXPORT(SceLibKernel, 0x6C60AC61, SceUID, sceIoOpen, const char *file, int flags,
155155
return SCE_ERROR_ERRNO_EMFILE;
156156
}
157157

158-
vfile->uid = SceSysmem_get_next_uid();
159-
vfile->fp = fp;
158+
vfile->uid = SceSysmem_get_next_uid();
159+
vfile->fp = fp;
160160
vfile->file = strdup(file);
161161

162162
return vfile->uid;
@@ -236,8 +236,8 @@ EXPORT(SceLibKernel, 0xA9283DD0, SceUID, sceIoDopen, const char *dirname)
236236
return SCE_ERROR_ERRNO_EMFILE;
237237
}
238238

239-
vdir->uid = SceSysmem_get_next_uid();
240-
vdir->dir = dir;
239+
vdir->uid = SceSysmem_get_next_uid();
240+
vdir->dir = dir;
241241
vdir->path = strdup(dirname);
242242

243243
return vdir->uid;
@@ -263,12 +263,12 @@ EXPORT(SceIofilemgr, 0x422A221A, int, sceIoDclose, SceUID fd)
263263

264264
static inline void tm_to_sce_datetime(SceDateTime *dt, const struct tm *tm)
265265
{
266-
dt->year = tm->tm_year;
267-
dt->month = tm->tm_mon;
268-
dt->day = tm->tm_mday;
269-
dt->hour = tm->tm_hour;
270-
dt->minute = tm->tm_min;
271-
dt->second = tm->tm_sec;
266+
dt->year = tm->tm_year;
267+
dt->month = tm->tm_mon;
268+
dt->day = tm->tm_mday;
269+
dt->hour = tm->tm_hour;
270+
dt->minute = tm->tm_min;
271+
dt->second = tm->tm_sec;
272272
dt->microsecond = 0;
273273
}
274274

@@ -320,32 +320,10 @@ EXPORT(SceLibKernel, 0x9C8B6624, int, sceIoDread, SceUID fd, SceIoDirent *dirent
320320
return 1;
321321
}
322322

323-
EXPORT(SceLibKernel, 0x632980D7, void *, sceClibMemset, void *dst, int ch, SceSize len)
324-
{
325-
return memset(dst, ch, len);
326-
}
327-
328-
EXPORT(SceLibKernel, 0x14E9DBD7, void *, sceClibMemcpy, void *dst, const void *src, SceSize len)
329-
{
330-
return memcpy(dst, src, len);
331-
}
332-
333-
EXPORT(SceLibKernel, 0x736753C8, void *, sceClibMemmove, void *dst, const void *src, SceSize len)
334-
{
335-
return memmove(dst, src, len);
336-
}
337-
338-
EXPORT(SceLibKernel, 0xFA26BC62, int, sceClibPrintf, const char *fmt, ...)
339-
{
340-
va_list args;
341-
int ret;
342-
343-
va_start(args, fmt);
344-
ret = vprintf(fmt, args);
345-
va_end(args);
346-
347-
return ret;
348-
}
323+
EXPORT_FUNC(SceLibKernel, 0x632980D7, memset)
324+
EXPORT_FUNC(SceLibKernel, 0x14E9DBD7, memcpy)
325+
EXPORT_FUNC(SceLibKernel, 0x736753C8, memmove)
326+
EXPORT_FUNC(SceLibKernel, 0xFA26BC62, printf)
349327

350328
EXPORT(SceLibKernel, 0x0FB972F9, int, sceKernelGetThreadId)
351329
{

0 commit comments

Comments
 (0)