Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Libraries: Update libcInternal #2265

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

kalaposfos13
Copy link
Contributor

Added all stubs, added back all things that were already implemented, and added functions based on what my games called. I have some basic implementation of printf functions, but I'm not really satisfied with the implementation, so I only did the ones that are actually called by games, and will update the rest when I find a better solution (Also, the non string variants should interface with shadPS4's tty system as well). The new things are:
More math functions
More str functions
setjmp, longjmp (Driveclub needs it to work)
memmove

The main thing that needs implementing for Gravity Rush 2 (and probably other games as well) is the sceLibcMspace functions, which are their own memory management sublibrary, from what I can see.

Logs filtered by *:Critical Lib.LibcInternal:Info are welcome if they contain stubs

This probably won't help a lot of games go further without sceLibcInternal as LLE (though implementing sceLibcMspace might do that), and my only game that reached further was Driveclub.

@squidbus
Copy link
Collaborator

squidbus commented Jan 29, 2025

This is a really large file, it should probably at least be split by the type of function.

Also to be clear, games don't use this directly, it is used by other system modules only. So if your game needs it it's just that a LLE system module you have loaded for the game needs it.

@squidbus
Copy link
Collaborator

And lastly as you can see from the build results, defining the symbols as is will conflict with the host standard library, which is why we added internal_ before.

@georgemoralis
Copy link
Collaborator

libc_internal_math , libc_interna_memory files as well

@georgemoralis
Copy link
Collaborator

fix that clang already ;D

@kalaposfos13
Copy link
Contributor Author

I thought first I'd need to separate the important things like memory and math functions into their own file? Clang is less than a minute, so I'll just do that when I'm done

@georgemoralis
Copy link
Collaborator

ok one suggestion , move the implemented functions on the top of the file , it will be easier to review them that searching all that big files

@kalaposfos13 kalaposfos13 marked this pull request as ready for review January 30, 2025 21:24
Copy link
Collaborator

@georgemoralis georgemoralis left a comment

Choose a reason for hiding this comment

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

LOG_DEBUG will spam a lot , at least remove them from the ones that proven to be correct (1:1 matches from std ones)

}

s32 PS4_SYSV_ABI internal_clearerr() {
LOG_ERROR(Lib_LibcInter
Copy link
Collaborator

Choose a reason for hiding this comment

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

gmtime_s something missing here...


char* PS4_SYSV_ABI internal_strsep(char** strp, const char* delim) {
LOG_DEBUG(Lib_LibcInternal, "called");
#ifdef _GNU_SOURCE
Copy link
Collaborator

Choose a reason for hiding this comment

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

????

}

void* PS4_SYSV_ABI internal_malloc(size_t size) {
return std::malloc(size);
Copy link
Contributor

Choose a reason for hiding this comment

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

i don't like this. Guest ps4 uses own memory allocating, no need to alloc on host

Copy link
Collaborator

Choose a reason for hiding this comment

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

For what it's worth (at least in my opinion) this HLE is basically just useful if you want to debug something by intercepting the calls. I don't think there's much interest in actually implementing HLE for this library because a) it has a very large API surface and b) by HLE-ing other modules you no longer need this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does that mean that there are plans to implement libraries that come with the games (in sce_modules)? I know that there are some things that use it that are not manually loaded system libraries, like libSceNpToolkit for GR2

Copy link
Collaborator

@squidbus squidbus Feb 1, 2025

Choose a reason for hiding this comment

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

Maybe, although in all likelihood anything Np related would likely be a stub. NpToolkit definitely doesn't need all this stuff added here anyway.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is not that easy to get rid lle modules for example ngs2 will require a lot of effort. Also there are gamemodules that might need it so it is not a useless efford

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is not that easy to get rid lle modules for example ngs2 will require a lot of effort.

Correct, but if you have LLE sysmodules there's no reason to not just put libcInternal with them.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The less the better 😌

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well if you're actually looking for a serious libcInternal HLE replacement then the original comment stands here, passing to host malloc won't be acceptable.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah yes it isn't. I thought it was general talk didn't see it is under a review 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants