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

Linux and FreeBSD Discrepancies Compiled Bug List #79

Open
15 of 17 tasks
Cryptogenic opened this issue Aug 8, 2020 · 15 comments
Open
15 of 17 tasks

Linux and FreeBSD Discrepancies Compiled Bug List #79

Cryptogenic opened this issue Aug 8, 2020 · 15 comments
Assignees
Labels
bug Something isn't working

Comments

@Cryptogenic
Copy link
Member

Cryptogenic commented Aug 8, 2020

This issue will be a master thread for all Linux and FreeBSD discrepancies in the headers, such as macros, constants, structure defs, type defs, and function prototypes. Please keep all discrepancies in here instead of making new issues so they're easier to track and maintain. Other related issues will be pulled into here and closed.

As this is likely an issue that will take a long time to fully address over the course of multiple updates, it will have no milestone / target release version except 1.0 stable.

--

Headers that need updating:

  • bits/dirent.h (uses wrong structure)
  • bits/fcntl.h
  • bits/ioctl.h
  • bits/limits.h
  • bits/mman.h
  • bits/stat.h
  • bits/statfs.h
  • netinet/in.h (references unincluded types)
  • unistd.h (pipe)
  • sys/mman.h
  • sys/socket.h (AF_*, PF_*)

Areas/broader topics that need updating:

  • dev_t needs change to 32-bit type
  • mode_t needs change to 16-bit type
  • sendfile() prototype needs updating
  • shm needs to be reworked to be BSD-compatible
  • fdatasync can be implemented via sony syscall
  • ptrace constants need updating
@Cryptogenic Cryptogenic added the bug Something isn't working label Aug 8, 2020
@Cryptogenic Cryptogenic self-assigned this Aug 8, 2020
@sleirsgoevy

This comment has been minimized.

@sleirsgoevy
Copy link
Contributor

netinet/in.h references uint8_t, which is declared in stdint.h, but does not include the latter. This makes it impossible to include netinet/in.h without including stdint.h first.

@sleirsgoevy
Copy link
Contributor

sleirsgoevy commented Sep 9, 2020

getdents() also uses the wrong structure. I see no reason why a game would want to list a directory, but still it's a bug that needs fixing.

@Cryptogenic
Copy link
Member Author

Cryptogenic commented Sep 23, 2020

getdents() also uses the wrong structure. I see no reason why a game would want to list a directory, but still it's a bug that needs fixing.

netinet/in.h references uint8_t, which is declared in stdint.h, but does not include the latter. This makes it impossible to include netinet/in.h without including stdint.h first.

Addressed all currently listed issues in the new v0.5.1 test branch. Branch needs more testing before merge to master and minor release.

This issue will also remain open for any other issues that have been missed / yet to be discovered (which I'm sure there are).

@sleirsgoevy
Copy link
Contributor

sleirsgoevy commented Oct 7, 2020

bits/fcntl.h is not done. fopen(path, "a") fails. PR with fix

EDIT: the constants are fixed in v0.5.1, but not in musl's internal headers. This causes musl-internal usage of these constants to fail.

@Cryptogenic
Copy link
Member Author

bits/fcntl.h is not done. fopen(path, "a") fails. PR with fix

EDIT: the constants are fixed in v0.5.1, but not in musl's internal headers. This causes musl-internal usage of these constants to fail.

Ugh yeah that's a good point that I somehow missed.

@Cryptogenic
Copy link
Member Author

The dirent structure is also incorrect and needs addressing.

@Cryptogenic
Copy link
Member Author

Newly built musl-headers including @sleirsgoevy's changes and my previous changes have now been committed to the master branch after testing and confirmation of working across multiple samples. Tomorrow I'll test the TLS fix also shipped by @sleirsgoevy and if they're confirmed working, that + the issues from this thread will land in a v0.5.1 release shortly.

v0.5.1 branch has been deprecated.

@sleirsgoevy
Copy link
Contributor

Another disrepancy: signal numbers are different on FreeBSD and on Linux. SIGIO is different, for example.

@OsirizX
Copy link

OsirizX commented Oct 16, 2020

I'm not sure if we're only doing Linux vs FreeBSD differences in this thread. Anyway there are some PS4 specific differences in the typedefs. Some conform with FreeBSD but not all do.

For example on the PS4 dev_t is defined as a 32 bit type but in FreeBSD it's 64 bit. So in alltypes.h:
typedef unsigned _Int64 dev_t should be typedef unsigned int dev_t

Another one I saw was for mode_t.
typedef unsigned mode_t should be typedef unsigned short mode_t

@nkrapivin
Copy link
Member

dev_t is indeed 32 bit on PS4.

@sleirsgoevy
Copy link
Contributor

sleirsgoevy commented Jul 5, 2021

  1. sendfile prototype is completely different on FreeBSD. musl ignores that fact
  2. musl implements shm_open and shm_unlink by opening a file in /dev/shm. These are syscalls on FreeBSD.
  3. shm_* functions are implemented "the Linux way" (in userspace using shared memory and atomics). FreeBSD implements them using kshm_* syscalls.

@sleirsgoevy
Copy link
Contributor

Also fdatasync is removed from musl, but is actually present on the PS4 via a custom Sony syscall.

@sleirsgoevy
Copy link
Contributor

ptrace PT_* constants have Linux numeric values, should have BSD ones instead.

@Cryptogenic
Copy link
Member Author

Gonna try to get sendfile() and ptrace constants updated for v0.5.2. Shared memory stuff and fdatasync will probably be a bit later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants