mirror of
https://github.com/pspdev/pspsdk.git
synced 2025-12-23 12:20:00 +00:00
Merge pull request #63 from fjtrujy/master
Improve Exit/Terminate process
This commit is contained in:
@@ -30,9 +30,9 @@ GLUE_OBJS = __fill_stat.o __psp_heap_blockid.o __psp_free_heap.o _fork.o _wait.o
|
|||||||
_isatty.o symlink.o truncate.o chmod.o fchmod.o fchmodat.o pathconf.o readlink.o utime.o fchown.o getentropy.o
|
_isatty.o symlink.o truncate.o chmod.o fchmod.o fchmodat.o pathconf.o readlink.o utime.o fchown.o getentropy.o
|
||||||
|
|
||||||
|
|
||||||
INIT_OBJS = __libcglue_init.o
|
INIT_OBJS = __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
|
MUTEXMAN_OBJS = __malloc_mutex.o __sbrk_mutex.o __fdman_mutex.o __init_mutex.o __deinit_mutex.o
|
||||||
|
|
||||||
NETDB_OBJS = h_errno.o gethostbyaddr.o gethostbyname.o
|
NETDB_OBJS = h_errno.o gethostbyaddr.o gethostbyname.o
|
||||||
|
|
||||||
@@ -46,8 +46,6 @@ SLEEP_OBJS = nanosleep.o
|
|||||||
SOCKET_OBJS = socket.o __socket_close.o accept.o bind.o connect.o getsockopt.o listen.o recv.o recvfrom.o send.o sendto.o \
|
SOCKET_OBJS = socket.o __socket_close.o accept.o bind.o connect.o getsockopt.o listen.o recv.o recvfrom.o send.o sendto.o \
|
||||||
setsockopt.o shutdown.o getpeername.o getsockname.o inet_ntoa.o sendmsg.o recvmsg.o
|
setsockopt.o shutdown.o getpeername.o getsockname.o inet_ntoa.o sendmsg.o recvmsg.o
|
||||||
|
|
||||||
TERMINATE_OBJS = _exit.o abort.o exit.o
|
|
||||||
|
|
||||||
TIMEZONE_OBJS = __timezone_update.o
|
TIMEZONE_OBJS = __timezone_update.o
|
||||||
|
|
||||||
lib_LIBRARIES = libcglue.a
|
lib_LIBRARIES = libcglue.a
|
||||||
@@ -75,11 +73,10 @@ libcglue_a_SOURCES = \
|
|||||||
select.c \
|
select.c \
|
||||||
sleep.c \
|
sleep.c \
|
||||||
socket.c \
|
socket.c \
|
||||||
terminate.c \
|
|
||||||
timezone.c
|
timezone.c
|
||||||
|
|
||||||
libcglue_a_LIBADD = $(CWD_OBJS) $(ERRNO_OBJS) $(FDMAN_OBJS) $(INIT_OBJS) $(GLUE_OBJS) $(MUTEXMAN_OBJS) $(NETDB_OBJS) $(PIPE_OBJS) \
|
libcglue_a_LIBADD = $(CWD_OBJS) $(ERRNO_OBJS) $(FDMAN_OBJS) $(INIT_OBJS) $(GLUE_OBJS) $(MUTEXMAN_OBJS) $(NETDB_OBJS) $(PIPE_OBJS) \
|
||||||
$(SELECT_OBJS) $(SOCKET_OBJS) $(SLEEP_OBJS) $(TERMINATE_OBJS) $(TIMEZONE_OBJS)
|
$(SELECT_OBJS) $(SOCKET_OBJS) $(SLEEP_OBJS) $(TIMEZONE_OBJS)
|
||||||
|
|
||||||
$(CWD_OBJS): cwd.c
|
$(CWD_OBJS): cwd.c
|
||||||
$(AM_V_CC)$(COMPILE) -DF_$* $< -c -o $@
|
$(AM_V_CC)$(COMPILE) -DF_$* $< -c -o $@
|
||||||
@@ -114,8 +111,5 @@ $(SLEEP_OBJS): sleep.c
|
|||||||
$(SOCKET_OBJS): socket.c
|
$(SOCKET_OBJS): socket.c
|
||||||
$(AM_V_CC)$(COMPILE) -DF_$* $< -c -o $@
|
$(AM_V_CC)$(COMPILE) -DF_$* $< -c -o $@
|
||||||
|
|
||||||
$(TERMINATE_OBJS): terminate.c
|
|
||||||
$(AM_V_CC)$(COMPILE) -DF_$* $< -c -o $@
|
|
||||||
|
|
||||||
$(TIMEZONE_OBJS): timezone.c
|
$(TIMEZONE_OBJS): timezone.c
|
||||||
$(AM_V_CC)$(COMPILE) -DF_$* $< -c -o $@
|
$(AM_V_CC)$(COMPILE) -DF_$* $< -c -o $@
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
|
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
|
||||||
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
|
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
|
||||||
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
|
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
|
||||||
|
* Copyright (c) 2021 Francisco Javier Trujillo Mata <fjtrujy@gmail.com>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -16,10 +17,16 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
|
||||||
|
#include <pspuser.h>
|
||||||
|
|
||||||
void __init_cwd(char *argv_0);
|
void __init_cwd(char *argv_0);
|
||||||
void __timezone_update();
|
void __timezone_update();
|
||||||
void __fdman_init();
|
void __fdman_init();
|
||||||
void __init_mutex();
|
void __init_mutex();
|
||||||
|
void __psp_free_heap();
|
||||||
|
void __deinit_mutex();
|
||||||
|
|
||||||
|
extern int sce_newlib_nocreate_thread_in_start __attribute__((weak));
|
||||||
|
|
||||||
#ifdef F___libcglue_init
|
#ifdef F___libcglue_init
|
||||||
/* Note: This function is being called from crt0.c/crt0_prx.c.
|
/* Note: This function is being called from crt0.c/crt0_prx.c.
|
||||||
@@ -44,4 +51,49 @@ void __libcglue_init(int argc, char *argv[])
|
|||||||
/* Initialize timezone */
|
/* Initialize timezone */
|
||||||
__timezone_update();
|
__timezone_update();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef F___libcglue_deinit
|
||||||
|
/* Note: This function is being called from terminate.c.
|
||||||
|
* It is a weak function because can be override by user program
|
||||||
|
*/
|
||||||
|
__attribute__((weak))
|
||||||
|
void __libcglue_deinit()
|
||||||
|
{
|
||||||
|
__psp_free_heap();
|
||||||
|
__deinit_mutex();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void __libcglue_deinit();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef F__exit
|
||||||
|
void _exit(int status)
|
||||||
|
{
|
||||||
|
__libcglue_deinit();
|
||||||
|
|
||||||
|
if (&sce_newlib_nocreate_thread_in_start != NULL) {
|
||||||
|
sceKernelSelfStopUnloadModule(1, 0, NULL);
|
||||||
|
} else {
|
||||||
|
sceKernelExitGame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void _exit(int status);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef F_abort
|
||||||
|
__attribute__((weak))
|
||||||
|
void abort()
|
||||||
|
{
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef F_exit
|
||||||
|
__attribute__((weak))
|
||||||
|
void exit(int retval)
|
||||||
|
{
|
||||||
|
_exit(retval);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -42,4 +42,14 @@ void __init_mutex()
|
|||||||
sceKernelCreateLwMutex(&__sbrk_mutex, "sbrk mutex", 0, 0, 0);
|
sceKernelCreateLwMutex(&__sbrk_mutex, "sbrk mutex", 0, 0, 0);
|
||||||
sceKernelCreateLwMutex(&__fdman_mutex, "fdman mutex", 0, 0, 0);
|
sceKernelCreateLwMutex(&__fdman_mutex, "fdman mutex", 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef F___deinit_mutex
|
||||||
|
/* Create mutex used for making thread safe mallock and get fd */
|
||||||
|
void __deinit_mutex()
|
||||||
|
{
|
||||||
|
sceKernelDeleteLwMutex(&__malloc_mutex);
|
||||||
|
sceKernelDeleteLwMutex(&__sbrk_mutex);
|
||||||
|
sceKernelDeleteLwMutex(&__fdman_mutex);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
/*
|
|
||||||
* PSP Software Development Kit - https://github.com/pspdev
|
|
||||||
* -----------------------------------------------------------------------
|
|
||||||
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
|
|
||||||
*
|
|
||||||
* terminate.c - Process exit functions.
|
|
||||||
*
|
|
||||||
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
|
|
||||||
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
|
|
||||||
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <psptypes.h>
|
|
||||||
#include <pspkernel.h>
|
|
||||||
|
|
||||||
#ifdef F__exit
|
|
||||||
extern int sce_newlib_nocreate_thread_in_start __attribute__((weak));
|
|
||||||
|
|
||||||
int __psp_free_heap(void);
|
|
||||||
|
|
||||||
void _exit(int status)
|
|
||||||
{
|
|
||||||
if (&sce_newlib_nocreate_thread_in_start != NULL) {
|
|
||||||
/* Free the heap created by _sbrk(). */
|
|
||||||
__psp_free_heap();
|
|
||||||
|
|
||||||
sceKernelSelfStopUnloadModule(1, 0, NULL);
|
|
||||||
} else {
|
|
||||||
if (status == 0) {
|
|
||||||
/* Free the heap created by _sbrk(). */
|
|
||||||
__psp_free_heap();
|
|
||||||
}
|
|
||||||
|
|
||||||
sceKernelExitThread(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) ;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
void _exit(int status);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef F_abort
|
|
||||||
__attribute__((weak))
|
|
||||||
void abort()
|
|
||||||
{
|
|
||||||
while (1)
|
|
||||||
_exit(1);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef F_exit
|
|
||||||
__attribute__((weak))
|
|
||||||
void exit(int retval)
|
|
||||||
{
|
|
||||||
while (1)
|
|
||||||
_exit(retval);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -146,6 +146,7 @@ enum PspModuleInfoAttr
|
|||||||
|
|
||||||
/* Disable the use of newlib, getting a minimal binary. */
|
/* Disable the use of newlib, getting a minimal binary. */
|
||||||
#define PSP_DISABLE_NEWLIB() \
|
#define PSP_DISABLE_NEWLIB() \
|
||||||
void __libcglue_init(int argc, char *argv[]) {}
|
void __libcglue_init(int argc, char *argv[]) {} \
|
||||||
|
void __libcglue_deinit() {}
|
||||||
|
|
||||||
#endif /* PSPMODULEINFO_H */
|
#endif /* PSPMODULEINFO_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user