mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-03 12:08:06 +02:00
Move SyncHelper to platform
... upcoming changes will add promote the emulated virtio gpu stack as a proper platform backend which will include the SyncHelper. Reviewed-by: Aaron Ruby <aruby@blackberry.com> Acked-by: Yonggang Luo <luoyonggang@gmail.com> Acked-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27246>
This commit is contained in:
parent
f321c3e997
commit
0e8582d6da
3 changed files with 118 additions and 0 deletions
36
src/gfxstream/guest/platform/include/Sync.h
Normal file
36
src/gfxstream/guest/platform/include/Sync.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright 2023 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expresso or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <stddef.h>
|
||||
|
||||
namespace gfxstream {
|
||||
|
||||
// Abstraction around libsync for testing.
|
||||
class SyncHelper {
|
||||
public:
|
||||
virtual ~SyncHelper() {}
|
||||
|
||||
virtual int wait(int syncFd, int timeoutMilliseconds) = 0;
|
||||
|
||||
virtual int dup(int syncFd) = 0;
|
||||
|
||||
virtual int close(int syncFd) = 0;
|
||||
};
|
||||
|
||||
SyncHelper* createPlatformSyncHelper();
|
||||
|
||||
} // namespace gfxstream
|
||||
50
src/gfxstream/guest/platform/linux/LinuxSync.cpp
Normal file
50
src/gfxstream/guest/platform/linux/LinuxSync.cpp
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "LinuxSync.h"
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
#include <sync/sync.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
|
||||
namespace gfxstream {
|
||||
|
||||
LinuxSyncHelper::LinuxSyncHelper() {}
|
||||
|
||||
int LinuxSyncHelper::wait(int syncFd, int timeoutMilliseconds) {
|
||||
#if defined(__ANDROID__)
|
||||
return sync_wait(syncFd, timeoutMilliseconds);
|
||||
#else
|
||||
(void)syncFd;
|
||||
(void)timeoutMilliseconds;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int LinuxSyncHelper::dup(int syncFd) {
|
||||
return ::dup(syncFd);
|
||||
}
|
||||
|
||||
int LinuxSyncHelper::close(int syncFd) {
|
||||
return ::close(syncFd);
|
||||
}
|
||||
|
||||
SyncHelper* createPlatformSyncHelper() {
|
||||
return new LinuxSyncHelper();
|
||||
}
|
||||
|
||||
} // namespace gfxstream
|
||||
32
src/gfxstream/guest/platform/linux/LinuxSync.h
Normal file
32
src/gfxstream/guest/platform/linux/LinuxSync.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright 2023 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expresso or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Sync.h"
|
||||
|
||||
namespace gfxstream {
|
||||
|
||||
class LinuxSyncHelper : public SyncHelper {
|
||||
public:
|
||||
LinuxSyncHelper();
|
||||
|
||||
int wait(int syncFd, int timeoutMilliseconds) override;
|
||||
|
||||
int dup(int syncFd) override;
|
||||
|
||||
int close(int syncFd) override;
|
||||
};
|
||||
|
||||
} // namespace gfxstream
|
||||
Loading…
Add table
Reference in a new issue