1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:07:47 +00:00

Kernel+LibC: Rename shared buffer syscalls to use a prefix

This feels a lot more consistent and Unixy:

    create_shared_buffer()   => shbuf_create()
    share_buffer_with()      => shbuf_allow_pid()
    share_buffer_globally()  => shbuf_allow_all()
    get_shared_buffer()      => shbuf_get()
    release_shared_buffer()  => shbuf_release()
    seal_shared_buffer()     => shbuf_seal()
    get_shared_buffer_size() => shbuf_get_size()

Also, "shared_buffer_id" is shortened to "shbuf_id" all around.
This commit is contained in:
Andreas Kling 2020-02-28 11:45:19 +01:00
parent 8460d02651
commit f72e5bbb17
36 changed files with 549 additions and 549 deletions

View file

@ -121,7 +121,7 @@ public:
int sample_count() const { return m_sample_count; }
const void* data() const { return m_buffer->data(); }
int size_in_bytes() const { return m_sample_count * (int)sizeof(Sample); }
int shared_buffer_id() const { return m_buffer->shared_buffer_id(); }
int shbuf_id() const { return m_buffer->shbuf_id(); }
SharedBuffer& shared_buffer() { return *m_buffer; }
private:

View file

@ -45,7 +45,7 @@ void ClientConnection::enqueue(const Buffer& buffer)
{
for (;;) {
const_cast<Buffer&>(buffer).shared_buffer().share_with(server_pid());
auto response = send_sync<Messages::AudioServer::EnqueueBuffer>(buffer.shared_buffer_id(), buffer.sample_count());
auto response = send_sync<Messages::AudioServer::EnqueueBuffer>(buffer.shbuf_id(), buffer.sample_count());
if (response->success())
break;
sleep(1);
@ -55,7 +55,7 @@ void ClientConnection::enqueue(const Buffer& buffer)
bool ClientConnection::try_enqueue(const Buffer& buffer)
{
const_cast<Buffer&>(buffer).shared_buffer().share_with(server_pid());
auto response = send_sync<Messages::AudioServer::EnqueueBuffer>(buffer.shared_buffer_id(), buffer.sample_count());
auto response = send_sync<Messages::AudioServer::EnqueueBuffer>(buffer.shbuf_id(), buffer.sample_count());
return response->success();
}

View file

@ -529,21 +529,21 @@ void sync()
syscall(SC_sync);
}
int create_shared_buffer(int size, void** buffer)
int shbuf_create(int size, void** buffer)
{
int rc = syscall(SC_create_shared_buffer, size, buffer);
int rc = syscall(SC_shbuf_create, size, buffer);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
int share_buffer_with(int shared_buffer_id, pid_t peer_pid)
int shbuf_allow_pid(int shbuf_id, pid_t peer_pid)
{
int rc = syscall(SC_share_buffer_with, shared_buffer_id, peer_pid);
int rc = syscall(SC_shbuf_allow_pid, shbuf_id, peer_pid);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
int share_buffer_globally(int shared_buffer_id)
int shbuf_allow_all(int shbuf_id)
{
int rc = syscall(SC_share_buffer_globally, shared_buffer_id);
int rc = syscall(SC_shbuf_allow_all, shbuf_id);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
@ -553,9 +553,9 @@ int set_process_icon(int icon_id)
__RETURN_WITH_ERRNO(rc, rc, -1);
}
void* get_shared_buffer(int shared_buffer_id)
void* shbuf_get(int shbuf_id)
{
int rc = syscall(SC_get_shared_buffer, shared_buffer_id);
int rc = syscall(SC_shbuf_get, shbuf_id);
if (rc < 0 && -rc < EMAXERRNO) {
errno = -rc;
return (void*)-1;
@ -563,21 +563,21 @@ void* get_shared_buffer(int shared_buffer_id)
return (void*)rc;
}
int release_shared_buffer(int shared_buffer_id)
int shbuf_release(int shbuf_id)
{
int rc = syscall(SC_release_shared_buffer, shared_buffer_id);
int rc = syscall(SC_shbuf_release, shbuf_id);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
int get_shared_buffer_size(int shared_buffer_id)
int shbuf_get_size(int shbuf_id)
{
int rc = syscall(SC_get_shared_buffer_size, shared_buffer_id);
int rc = syscall(SC_shbuf_get_size, shbuf_id);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
int seal_shared_buffer(int shared_buffer_id)
int shbuf_seal(int shbuf_id)
{
int rc = syscall(SC_seal_shared_buffer, shared_buffer_id);
int rc = syscall(SC_shbuf_seal, shbuf_id);
__RETURN_WITH_ERRNO(rc, rc, -1);
}

View file

@ -61,13 +61,13 @@ void sysbeep();
int systrace(pid_t);
int gettid();
int donate(int tid);
int create_shared_buffer(int, void** buffer);
int share_buffer_with(int, pid_t peer_pid);
int share_buffer_globally(int);
void* get_shared_buffer(int shared_buffer_id);
int release_shared_buffer(int shared_buffer_id);
int seal_shared_buffer(int shared_buffer_id);
int get_shared_buffer_size(int shared_buffer_id);
int shbuf_create(int, void** buffer);
int shbuf_allow_pid(int, pid_t peer_pid);
int shbuf_allow_all(int);
void* shbuf_get(int shbuf_id);
int shbuf_release(int shbuf_id);
int shbuf_seal(int shbuf_id);
int shbuf_get_size(int shbuf_id);
int set_process_icon(int icon_id);
inline int getpagesize() { return 4096; }
pid_t fork();

View file

@ -46,9 +46,9 @@ Clipboard::Clipboard()
Clipboard::DataAndType Clipboard::data_and_type() const
{
auto response = WindowServerConnection::the().send_sync<Messages::WindowServer::GetClipboardContents>();
if (response->shared_buffer_id() < 0)
if (response->shbuf_id() < 0)
return {};
auto shared_buffer = SharedBuffer::create_from_shared_buffer_id(response->shared_buffer_id());
auto shared_buffer = SharedBuffer::create_from_shbuf_id(response->shbuf_id());
if (!shared_buffer) {
dbgprintf("GUI::Clipboard::data() failed to attach to the shared buffer\n");
return {};
@ -76,7 +76,7 @@ void Clipboard::set_data(const StringView& data, const String& type)
shared_buffer->seal();
shared_buffer->share_with(WindowServerConnection::the().server_pid());
WindowServerConnection::the().send_sync<Messages::WindowServer::SetClipboardContents>(shared_buffer->shared_buffer_id(), data.length(), type);
WindowServerConnection::the().send_sync<Messages::WindowServer::SetClipboardContents>(shared_buffer->shbuf_id(), data.length(), type);
}
void Clipboard::did_receive_clipboard_contents_changed(Badge<WindowServerConnection>, const String& data_type)

View file

@ -55,7 +55,7 @@ DragOperation::Outcome DragOperation::exec()
if (m_bitmap) {
shared_bitmap = m_bitmap->to_shareable_bitmap();
shared_bitmap->shared_buffer()->share_with(WindowServerConnection::the().server_pid());
bitmap_id = shared_bitmap->shared_buffer_id();
bitmap_id = shared_bitmap->shbuf_id();
bitmap_size = shared_bitmap->size();
}

View file

@ -128,7 +128,7 @@ int Menu::realize_menu()
if (action.icon()) {
ASSERT(action.icon()->format() == Gfx::BitmapFormat::RGBA32);
ASSERT(action.icon()->size() == Gfx::Size(16, 16));
if (action.icon()->shared_buffer_id() == -1) {
if (action.icon()->shbuf_id() == -1) {
auto shared_buffer = SharedBuffer::create_with_size(action.icon()->size_in_bytes());
ASSERT(shared_buffer);
auto shared_icon = Gfx::Bitmap::create_with_shared_buffer(Gfx::BitmapFormat::RGBA32, *shared_buffer, action.icon()->size());
@ -137,7 +137,7 @@ int Menu::realize_menu()
shared_buffer->share_with(WindowServerConnection::the().server_pid());
action.set_icon(shared_icon);
}
icon_buffer_id = action.icon()->shared_buffer_id();
icon_buffer_id = action.icon()->shbuf_id();
}
auto shortcut_text = action.shortcut().is_valid() ? action.shortcut().to_string() : String();
bool exclusive = action.group() && action.group()->is_exclusive() && action.is_checkable();

View file

@ -477,7 +477,7 @@ void Window::set_hovered_widget(Widget* widget)
void Window::set_current_backing_bitmap(Gfx::Bitmap& bitmap, bool flush_immediately)
{
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowBackingStore>(m_window_id, 32, bitmap.pitch(), bitmap.shared_buffer_id(), bitmap.has_alpha_channel(), bitmap.size(), flush_immediately);
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowBackingStore>(m_window_id, 32, bitmap.pitch(), bitmap.shbuf_id(), bitmap.has_alpha_channel(), bitmap.size(), flush_immediately);
}
void Window::flip(const Vector<Gfx::Rect, 32>& dirty_rects)
@ -551,17 +551,17 @@ void Window::apply_icon()
if (!m_window_id)
return;
int rc = seal_shared_buffer(m_icon->shared_buffer_id());
int rc = shbuf_seal(m_icon->shbuf_id());
ASSERT(rc == 0);
rc = share_buffer_globally(m_icon->shared_buffer_id());
rc = shbuf_allow_all(m_icon->shbuf_id());
ASSERT(rc == 0);
static bool has_set_process_icon;
if (!has_set_process_icon)
set_process_icon(m_icon->shared_buffer_id());
set_process_icon(m_icon->shbuf_id());
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowIconBitmap>(m_window_id, m_icon->shared_buffer_id(), m_icon->size());
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowIconBitmap>(m_window_id, m_icon->shbuf_id(), m_icon->size());
}
void Window::start_wm_resize()

View file

@ -53,9 +53,9 @@ WindowServerConnection& WindowServerConnection::the()
return *s_connection;
}
static void set_system_theme_from_shared_buffer_id(int id)
static void set_system_theme_from_shbuf_id(int id)
{
auto system_theme = SharedBuffer::create_from_shared_buffer_id(id);
auto system_theme = SharedBuffer::create_from_shbuf_id(id);
ASSERT(system_theme);
Gfx::set_system_theme(*system_theme);
Application::the().set_system_palette(*system_theme);
@ -65,13 +65,13 @@ void WindowServerConnection::handshake()
{
auto response = send_sync<Messages::WindowServer::Greet>();
set_my_client_id(response->client_id());
set_system_theme_from_shared_buffer_id(response->system_theme_buffer_id());
set_system_theme_from_shbuf_id(response->system_theme_buffer_id());
Desktop::the().did_receive_screen_rect({}, response->screen_rect());
}
void WindowServerConnection::handle(const Messages::WindowClient::UpdateSystemTheme& message)
{
set_system_theme_from_shared_buffer_id(message.system_theme_buffer_id());
set_system_theme_from_shbuf_id(message.system_theme_buffer_id());
Window::update_all_windows({});
}

View file

@ -158,9 +158,9 @@ void Bitmap::set_volatile()
return rc == 0;
}
int Bitmap::shared_buffer_id() const
int Bitmap::shbuf_id() const
{
return m_shared_buffer ? m_shared_buffer->shared_buffer_id() : -1;
return m_shared_buffer ? m_shared_buffer->shbuf_id() : -1;
}
}

View file

@ -64,7 +64,7 @@ public:
int width() const { return m_size.width(); }
int height() const { return m_size.height(); }
size_t pitch() const { return m_pitch; }
int shared_buffer_id() const;
int shbuf_id() const;
SharedBuffer* shared_buffer() { return m_shared_buffer.ptr(); }
const SharedBuffer* shared_buffer() const { return m_shared_buffer.ptr(); }

View file

@ -43,7 +43,7 @@ const SystemTheme& current_system_theme()
int current_system_theme_buffer_id()
{
ASSERT(theme_buffer);
return theme_buffer->shared_buffer_id();
return theme_buffer->shbuf_id();
}
void set_system_theme(SharedBuffer& buffer)

View file

@ -66,9 +66,9 @@ void Client::handle(const Messages::ProtocolClient::DownloadFinished& message)
{
RefPtr<Download> download;
if ((download = m_downloads.get(message.download_id()).value_or(nullptr))) {
download->did_finish({}, message.success(), message.total_size(), message.shared_buffer_id());
download->did_finish({}, message.success(), message.total_size(), message.shbuf_id());
}
send_sync<Messages::ProtocolServer::DisownSharedBuffer>(message.shared_buffer_id());
send_sync<Messages::ProtocolServer::DisownSharedBuffer>(message.shbuf_id());
m_downloads.remove(message.download_id());
}

View file

@ -41,15 +41,15 @@ bool Download::stop()
return m_client->stop_download({}, *this);
}
void Download::did_finish(Badge<Client>, bool success, u32 total_size, i32 shared_buffer_id)
void Download::did_finish(Badge<Client>, bool success, u32 total_size, i32 shbuf_id)
{
if (!on_finish)
return;
ByteBuffer payload;
RefPtr<SharedBuffer> shared_buffer;
if (success && shared_buffer_id != -1) {
shared_buffer = SharedBuffer::create_from_shared_buffer_id(shared_buffer_id);
if (success && shbuf_id != -1) {
shared_buffer = SharedBuffer::create_from_shbuf_id(shbuf_id);
payload = ByteBuffer::wrap(shared_buffer->data(), total_size);
}
on_finish(success, payload, move(shared_buffer));

View file

@ -49,7 +49,7 @@ public:
Function<void(bool success, const ByteBuffer& payload, RefPtr<SharedBuffer> payload_storage)> on_finish;
Function<void(u32 total_size, u32 downloaded_size)> on_progress;
void did_finish(Badge<Client>, bool success, u32 total_size, i32 shared_buffer_id);
void did_finish(Badge<Client>, bool success, u32 total_size, i32 shbuf_id);
void did_progress(Badge<Client>, u32 total_size, u32 downloaded_size);
private: