-
Notifications
You must be signed in to change notification settings - Fork 9
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
xbox: Add includes/alloca.h #44
base: nxdk
Are you sure you want to change the base?
Conversation
@@ -0,0 +1 @@ | |||
#define alloca(size) __builtin_alloca (size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misses "header" with information about the purpose and License of this file.
|
Meh, I feared that could be the case.
It's not a POSIX thing, at least according to the C POSIX library.
In the Windows port, they include Why not support some POSIX on the xbox as well?
Thats the current situation, however that shouldn't stop us from discussing about changing that 🙂. |
Full disclosure: I originally asked for alloca.h; but the existing review comments reminded me of why I didn't do it and why it might not be a good idea.
Agreed; GNU libc ships it, but also a lot of other POSIX platforms - but it's not part of C.
Agreed, micropython is a bad example, because it doesn't work out of the box anyway (it is meant to require porting). However, there are still other libs which probably need "alloca.h". I ran into it a couple of times. Instead of creating "alloca.h", it probably does make more sense to change those projects to make them compiler aware, so they can use the compilers
On the other hand, you might also conclude that "alloca.h" has become some defacto-standard for exposing this feature of compilers. Does Clang maybe even expose "alloca.h" on Windows as part of it's GNU C support?
I also share that sentiment. nxdk is low level first (custom drivers + NT kernel), winapi very close second, SDL2 third, but GNU C / POSIX soon after that. So, because nxdk is fundamentally heading towards becoming a winapi platform (which has some benefits but also some issues) in userspace-ish sections, I think that it makes most sense to implement POSIX standards on top of existing winapi (like cygwin / mingw). So just creating a Ideally that shouldn't be Xbox specific and modular, so we have more stakeholders. We should then try to get people to port their projects with those libraries while they don't have explicit Windows support. So either a port will boil down to adding a library inclusion upstream (add Windows support to their POSIX code using Some projects (and requests) already exist to implement some POSIX stuff on Windows. The most critical POSIX libraries (some with bad license):
The main issue is usually signals, filesystems or interactions between stuff. Creating an organization for modular and hookable CC0 variants of this could be very helpful. Anyhow, this probably deseves its own issue on nxdk or elsewhere. |
We can't, really - POSIX specifies lots of things that aren't possible with the Xbox's kernel, such as cli, forking etc. What we can do is provide the parts that can be implemented as wrappers, but implementing and maintaining them takes time and effort, and it might not be worth it.
I did start implementing POSIX-stlye file I/O a while ago for SDLPoP, but I abandoned it. You have to keep a mapping table to convert between the POSIX fd and the winapi handle, and in the end it's probably far easier to just convert whatever you're porting to C file I/O (like afaik Ryzee did with SDPoP). |
This PR adds the file
alloca.h
which provides an implementation ofalloca(size)
according to the manpage.Implementation might be a bit far fetched as it is just a
#define
to refer to the builtin.Having this file simplifies porting of certain programs and libraries. i.e. Micropython. I currently have no way of running xbox executable but at least it compiles fine :p
For my understanding:
<alloca.h>
expecting to find an implementation ofalloca(size)
alloca(size)
with its own builtinThis is done because
alloca
operates/allocates on the stack frame - which is handled by the compiler, not the OS(as given when usingmalloc
). Additionally, it is therefore compiler(and machine) depended wich builtin/implementation is to be used.Right? 😅
I'm not sure if the PR belongs here or if it is okay at all. So don't feel bad when giving hard backlash in the review.
Edit:
Maybe I should have done something similar to this and place it in nxdk/libs/xboxrt/alloca.h
Additionally, this is according to the manpage of alloca commonly found on modern *nix systems.