-
Notifications
You must be signed in to change notification settings - Fork 28
macOS: normalize SHM names and propagate blob creation failures #151
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| name: Gfxstream macOS Build | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| branches-ignore: | ||
| - main | ||
|
|
||
| jobs: | ||
| build-macos: | ||
| runs-on: macos-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - run: brew install meson ninja molten-vk vulkan-loader | ||
| - run: | | ||
| meson setup -Ddefault_library=static -Dgfxstream-build=host build | ||
| meson compile -C build | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,7 +55,10 @@ SharedMemory::SharedMemory(const std::string& name, size_t size) { | |
| mName = PathUtils::recompose(PathUtils::decompose(std::move(path))); | ||
| } else { | ||
| mShareType = ShareType::SHARED_MEMORY; | ||
| mName = name; | ||
| // POSIX.1-2017 (System Interfaces) requires shm_open() names to begin | ||
| // with a '/' character to avoid implementation-defined behavior. | ||
| // Normalize unconditionally so callers don't need to care about it. | ||
| mName = (!name.empty() && name[0] != '/') ? ("/" + name) : name; | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess you can make this slash universal, even on linux. Also, cite the POSIX standard that requires a slash in a comment.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Made the |
||
| } | ||
|
|
||
|
|
@@ -111,7 +114,9 @@ int SharedMemory::openInternal(int oflag, int mode, bool doMapping) { | |
| int err = 0; | ||
| struct stat sb; | ||
| if (mShareType == ShareType::SHARED_MEMORY) { | ||
| #if defined(HAVE_MEMFD_CREATE) | ||
| #if defined(__APPLE__) | ||
| mFd = ::shm_open(mName.c_str(), oflag, mode); | ||
| #elif defined(HAVE_MEMFD_CREATE) | ||
| mFd = memfd_create(mName.c_str(), MFD_CLOEXEC | MFD_ALLOW_SEALING); | ||
| #else | ||
| mFd = syscall(__NR_memfd_create, mName.c_str(), FD_CLOEXEC); | ||
|
|
||
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.
Can you add this
presubmit.ymlinstead of it's own file?