Macro for disabling usage of pthread

This commit is contained in:
Francisco Javier Trujillo Mata
2022-03-24 22:56:58 +01:00
parent 8a0ab6b14e
commit 4cbabb73ae
3 changed files with 17 additions and 4 deletions

View File

@@ -31,7 +31,7 @@ GLUE_OBJS = __dummy_passwd.o __fill_stat.o __psp_heap_blockid.o __psp_free_heap.
fsync.o getpwnam.o getuid.o geteuid.o
INIT_OBJS = __libcglue_init.o __libcglue_deinit.o _exit.o abort.o exit.o
INIT_OBJS = __libpthreadglue_init.o __libcglue_init.o __libcglue_deinit.o _exit.o abort.o exit.o
MUTEXMAN_OBJS = __malloc_mutex.o __sbrk_mutex.o __fdman_mutex.o __init_mutex.o __deinit_mutex.o

View File

@@ -29,6 +29,19 @@ void __deinit_mutex();
extern int sce_newlib_nocreate_thread_in_start __attribute__((weak));
#ifdef F___libpthreadglue_init
/* Note: This function is being called from __libcglue_init.
* It is a weak function because can be override by user program
*/
__attribute__((weak))
void __libpthreadglue_init()
{
pthread_init();
}
#else
void __libpthreadglue_init();
#endif
#ifdef F___libcglue_init
/* Note: This function is being called from crt0.c/crt0_prx.c.
* It is a weak function because can be override by user program,
@@ -47,7 +60,7 @@ void __libcglue_init(int argc, char *argv[])
__fdman_init();
/* Initialize pthread library */
pthread_init();
__libpthreadglue_init();
/* Initialize cwd from this program's path */
__init_cwd(argv[0]);

View File

@@ -107,8 +107,8 @@ enum PspModuleInfoAttr
void __libcglue_init(int argc, char *argv[]) {} \
void __libcglue_deinit() {}
/* Disable the use of pthread for reducing binary size */
#define PSP_DISABLE_PTHREAD() \
/* Disable the auto start of pthread on init for reducing binary size if not used. */
#define PSP_DISABLE_AUTOSTART_PTHREAD() \
void __libpthreadglue_init() {}
#endif /* PSPMODULEINFO_H */