Serenity Operating System
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

+571 -571
+23 -23
AK/SharedBuffer.cpp
··· 37 37 RefPtr<SharedBuffer> SharedBuffer::create_with_size(int size) 38 38 { 39 39 void* data; 40 - int shared_buffer_id = create_shared_buffer(size, &data); 41 - if (shared_buffer_id < 0) { 42 - perror("create_shared_buffer"); 40 + int shbuf_id = shbuf_create(size, &data); 41 + if (shbuf_id < 0) { 42 + perror("shbuf_create"); 43 43 return nullptr; 44 44 } 45 - return adopt(*new SharedBuffer(shared_buffer_id, size, data)); 45 + return adopt(*new SharedBuffer(shbuf_id, size, data)); 46 46 } 47 47 48 48 bool SharedBuffer::share_with(pid_t peer) 49 49 { 50 - int ret = share_buffer_with(shared_buffer_id(), peer); 50 + int ret = shbuf_allow_pid(shbuf_id(), peer); 51 51 if (ret < 0) { 52 - perror("share_buffer_with"); 52 + perror("shbuf_allow_pid"); 53 53 return false; 54 54 } 55 55 return true; ··· 57 57 58 58 bool SharedBuffer::share_globally() 59 59 { 60 - int ret = share_buffer_globally(shared_buffer_id()); 60 + int ret = shbuf_allow_all(shbuf_id()); 61 61 if (ret < 0) { 62 - perror("share_buffer_globally"); 62 + perror("shbuf_allow_all"); 63 63 return false; 64 64 } 65 65 return true; 66 66 } 67 67 68 - RefPtr<SharedBuffer> SharedBuffer::create_from_shared_buffer_id(int shared_buffer_id) 68 + RefPtr<SharedBuffer> SharedBuffer::create_from_shbuf_id(int shbuf_id) 69 69 { 70 - void* data = get_shared_buffer(shared_buffer_id); 70 + void* data = shbuf_get(shbuf_id); 71 71 if (data == (void*)-1) { 72 - perror("get_shared_buffer"); 72 + perror("shbuf_get"); 73 73 return nullptr; 74 74 } 75 - int size = get_shared_buffer_size(shared_buffer_id); 75 + int size = shbuf_get_size(shbuf_id); 76 76 if (size < 0) { 77 - perror("get_shared_buffer_size"); 77 + perror("shbuf_get_size"); 78 78 return nullptr; 79 79 } 80 - return adopt(*new SharedBuffer(shared_buffer_id, size, data)); 80 + return adopt(*new SharedBuffer(shbuf_id, size, data)); 81 81 } 82 82 83 - SharedBuffer::SharedBuffer(int shared_buffer_id, int size, void* data) 84 - : m_shared_buffer_id(shared_buffer_id) 83 + SharedBuffer::SharedBuffer(int shbuf_id, int size, void* data) 84 + : m_shbuf_id(shbuf_id) 85 85 , m_size(size) 86 86 , m_data(data) 87 87 { ··· 89 89 90 90 SharedBuffer::~SharedBuffer() 91 91 { 92 - if (m_shared_buffer_id >= 0) { 93 - int rc = release_shared_buffer(m_shared_buffer_id); 92 + if (m_shbuf_id >= 0) { 93 + int rc = shbuf_release(m_shbuf_id); 94 94 if (rc < 0) { 95 - perror("release_shared_buffer"); 95 + perror("shbuf_release"); 96 96 } 97 97 } 98 98 } 99 99 100 100 void SharedBuffer::seal() 101 101 { 102 - int rc = seal_shared_buffer(m_shared_buffer_id); 102 + int rc = shbuf_seal(m_shbuf_id); 103 103 if (rc < 0) { 104 - perror("seal_shared_buffer"); 104 + perror("shbuf_seal"); 105 105 ASSERT_NOT_REACHED(); 106 106 } 107 107 } 108 108 109 109 void SharedBuffer::set_volatile() 110 110 { 111 - u32 rc = syscall(SC_set_shared_buffer_volatile, m_shared_buffer_id, true); 111 + u32 rc = syscall(SC_shbuf_set_volatile, m_shbuf_id, true); 112 112 ASSERT(rc == 0); 113 113 } 114 114 115 115 bool SharedBuffer::set_nonvolatile() 116 116 { 117 - u32 rc = syscall(SC_set_shared_buffer_volatile, m_shared_buffer_id, false); 117 + u32 rc = syscall(SC_shbuf_set_volatile, m_shbuf_id, false); 118 118 if (rc == 0) 119 119 return true; 120 120 if (rc == 1)
+4 -4
AK/SharedBuffer.h
··· 36 36 class SharedBuffer : public RefCounted<SharedBuffer> { 37 37 public: 38 38 static RefPtr<SharedBuffer> create_with_size(int); 39 - static RefPtr<SharedBuffer> create_from_shared_buffer_id(int); 39 + static RefPtr<SharedBuffer> create_from_shbuf_id(int); 40 40 ~SharedBuffer(); 41 41 42 42 bool share_globally(); 43 43 bool share_with(pid_t); 44 - int shared_buffer_id() const { return m_shared_buffer_id; } 44 + int shbuf_id() const { return m_shbuf_id; } 45 45 void seal(); 46 46 int size() const { return m_size; } 47 47 void* data() { return m_data; } ··· 50 50 [[nodiscard]] bool set_nonvolatile(); 51 51 52 52 private: 53 - SharedBuffer(int shared_buffer_id, int size, void*); 53 + SharedBuffer(int shbuf_id, int size, void*); 54 54 55 - int m_shared_buffer_id { -1 }; 55 + int m_shbuf_id { -1 }; 56 56 int m_size { 0 }; 57 57 void* m_data; 58 58 };
+2 -2
Applications/SoundPlayer/PlaybackManager.cpp
··· 103 103 int id = m_connection->get_playing_buffer(); 104 104 int current_id = -1; 105 105 if (m_current_buffer) 106 - current_id = m_current_buffer->shared_buffer_id(); 106 + current_id = m_current_buffer->shbuf_id(); 107 107 108 108 if (id >= 0 && id != current_id) { 109 109 while (!m_buffers.is_empty()) { 110 110 --m_next_ptr; 111 111 auto buffer = m_buffers.take_first(); 112 112 113 - if (buffer->shared_buffer_id() == id) { 113 + if (buffer->shbuf_id() == id) { 114 114 m_current_buffer = buffer; 115 115 break; 116 116 }
+1 -1
Applications/SystemMonitor/ProcessModel.cpp
··· 267 267 switch (index.column()) { 268 268 case Column::Icon: 269 269 if (thread.current_state.icon_id != -1) { 270 - auto icon_buffer = SharedBuffer::create_from_shared_buffer_id(thread.current_state.icon_id); 270 + auto icon_buffer = SharedBuffer::create_from_shbuf_id(thread.current_state.icon_id); 271 271 if (icon_buffer) { 272 272 auto icon_bitmap = Gfx::Bitmap::create_with_shared_buffer(Gfx::BitmapFormat::RGBA32, *icon_buffer, { 16, 16 }); 273 273 if (icon_bitmap)
+1 -1
Applications/Taskbar/TaskbarWindow.cpp
··· 177 177 changed_event.icon_buffer_id()); 178 178 #endif 179 179 if (auto* window = WindowList::the().window(identifier)) { 180 - auto buffer = SharedBuffer::create_from_shared_buffer_id(changed_event.icon_buffer_id()); 180 + auto buffer = SharedBuffer::create_from_shbuf_id(changed_event.icon_buffer_id()); 181 181 ASSERT(buffer); 182 182 window->button()->set_icon(Gfx::Bitmap::create_with_shared_buffer(Gfx::BitmapFormat::RGBA32, *buffer, changed_event.icon_size())); 183 183 }
-27
Base/usr/share/man/man2/create_shared_buffer.md
··· 1 - ## Name 2 - 3 - create\_shared\_buffer - create a shareable memory buffer 4 - 5 - ## Synopsis 6 - ```**c++ 7 - #include <SharedBuffer.h> 8 - 9 - int create_shared_buffer(int size, void** buffer); 10 - ``` 11 - 12 - ## Description 13 - 14 - Creates a new memory region that can be shared with other processes. The region is only accessible to the creating process by default. 15 - 16 - ## Return value 17 - 18 - If a region is successfully created, `create_shared_buffer()` stores a pointer to the memory in `buffer` and returns a buffer ID. Otherwise, it returns -1 and sets `errno` to describe the error. 19 - 20 - ## Errors 21 - 22 - * `EINVAL`: `size` is zero or negative. 23 - * `EFAULT`: `buffer` is not a valid address. 24 - 25 - ## See also 26 - 27 - * [`share_buffer_with`(2)](share_buffer_with.md)
-28
Base/usr/share/man/man2/share_buffer_with.md
··· 1 - ## Name 2 - 3 - share\_buffer\_with - allow another process to map a shareable buffer 4 - 5 - ## Synopsis 6 - ```**c++ 7 - #include <SharedBuffer.h> 8 - 9 - int share_buffer_with(int shared_buffer_id, pid_t peer_pid); 10 - ``` 11 - 12 - ## Description 13 - 14 - Gives the process with PID `peer_pid` permission to map the shareable buffer with ID `shared_buffer_id`. 15 - 16 - ## Return value 17 - 18 - On success, returns 0. Otherwise, returns -1 and `errno` is set. 19 - 20 - ## Errors 21 - 22 - * `EINVAL`: `peer_pid` is invalid, or `shared_buffer_id` is not a valid ID. 23 - * `EPERM`: The calling process does not have access to the buffer with `shared_buffer_id`. 24 - * `ESRCH`: No process with PID `peer_pid` is found. 25 - 26 - ## See also 27 - 28 - * [`create_shared_buffer`(2)](create_shared_buffer.md)
+28
Base/usr/share/man/man2/shbuf_allow_pid.md
··· 1 + ## Name 2 + 3 + shbuf\_allow\_pid - allow another process to map a shareable buffer 4 + 5 + ## Synopsis 6 + ```**c++ 7 + #include <SharedBuffer.h> 8 + 9 + int shbuf_allow_pid(int shbuf_id, pid_t peer_pid); 10 + ``` 11 + 12 + ## Description 13 + 14 + Gives the process with PID `peer_pid` permission to map the shareable buffer with ID `shbuf_id`. 15 + 16 + ## Return value 17 + 18 + On success, returns 0. Otherwise, returns -1 and `errno` is set. 19 + 20 + ## Errors 21 + 22 + * `EINVAL`: `peer_pid` is invalid, or `shbuf_id` is not a valid ID. 23 + * `EPERM`: The calling process does not have access to the buffer with `shbuf_id`. 24 + * `ESRCH`: No process with PID `peer_pid` is found. 25 + 26 + ## See also 27 + 28 + * [`shbuf_create`(2)](shbuf_create.md)
+27
Base/usr/share/man/man2/shbuf_create.md
··· 1 + ## Name 2 + 3 + shbuf\_create - create a shareable memory buffer 4 + 5 + ## Synopsis 6 + ```**c++ 7 + #include <SharedBuffer.h> 8 + 9 + int shbuf_create(int size, void** buffer); 10 + ``` 11 + 12 + ## Description 13 + 14 + Creates a new memory region that can be shared with other processes. The region is only accessible to the calling process by default. 15 + 16 + ## Return value 17 + 18 + If a region is successfully created, `shbuf_create()` stores a pointer to the memory in `buffer` and returns a buffer ID. Otherwise, it returns -1 and sets `errno` to describe the error. 19 + 20 + ## Errors 21 + 22 + * `EINVAL`: `size` is zero or negative. 23 + * `EFAULT`: `buffer` is not a valid address. 24 + 25 + ## See also 26 + 27 + * [`shbuf_allow_pid`(2)](shbuf_allow_pid.md)
+26 -26
Kernel/Process.cpp
··· 3555 3555 shared_buffer->disown(m_pid); 3556 3556 } 3557 3557 3558 - int Process::sys$create_shared_buffer(int size, void** buffer) 3558 + int Process::sys$shbuf_create(int size, void** buffer) 3559 3559 { 3560 3560 REQUIRE_PROMISE(shared_buffer); 3561 3561 if (!size || size < 0) ··· 3565 3565 return -EFAULT; 3566 3566 3567 3567 LOCKER(shared_buffers().lock()); 3568 - static int s_next_shared_buffer_id; 3569 - int shared_buffer_id = ++s_next_shared_buffer_id; 3570 - auto shared_buffer = make<SharedBuffer>(shared_buffer_id, size); 3568 + static int s_next_shbuf_id; 3569 + int shbuf_id = ++s_next_shbuf_id; 3570 + auto shared_buffer = make<SharedBuffer>(shbuf_id, size); 3571 3571 shared_buffer->share_with(m_pid); 3572 3572 3573 3573 void* address = shared_buffer->ref_for_process_and_get_address(*this); 3574 3574 copy_to_user(buffer, &address); 3575 3575 ASSERT((int)shared_buffer->size() >= size); 3576 3576 #ifdef SHARED_BUFFER_DEBUG 3577 - kprintf("%s(%u): Created shared buffer %d @ %p (%u bytes, vmobject is %u)\n", name().characters(), pid(), shared_buffer_id, buffer, size, shared_buffer->size()); 3577 + kprintf("%s(%u): Created shared buffer %d @ %p (%u bytes, vmobject is %u)\n", name().characters(), pid(), shbuf_id, buffer, size, shared_buffer->size()); 3578 3578 #endif 3579 - shared_buffers().resource().set(shared_buffer_id, move(shared_buffer)); 3579 + shared_buffers().resource().set(shbuf_id, move(shared_buffer)); 3580 3580 3581 - return shared_buffer_id; 3581 + return shbuf_id; 3582 3582 } 3583 3583 3584 - int Process::sys$share_buffer_with(int shared_buffer_id, pid_t peer_pid) 3584 + int Process::sys$shbuf_allow_pid(int shbuf_id, pid_t peer_pid) 3585 3585 { 3586 3586 REQUIRE_PROMISE(shared_buffer); 3587 3587 if (!peer_pid || peer_pid < 0 || peer_pid == m_pid) 3588 3588 return -EINVAL; 3589 3589 LOCKER(shared_buffers().lock()); 3590 - auto it = shared_buffers().resource().find(shared_buffer_id); 3590 + auto it = shared_buffers().resource().find(shbuf_id); 3591 3591 if (it == shared_buffers().resource().end()) 3592 3592 return -EINVAL; 3593 3593 auto& shared_buffer = *(*it).value; ··· 3603 3603 return 0; 3604 3604 } 3605 3605 3606 - int Process::sys$share_buffer_globally(int shared_buffer_id) 3606 + int Process::sys$shbuf_allow_all(int shbuf_id) 3607 3607 { 3608 3608 REQUIRE_PROMISE(shared_buffer); 3609 3609 LOCKER(shared_buffers().lock()); 3610 - auto it = shared_buffers().resource().find(shared_buffer_id); 3610 + auto it = shared_buffers().resource().find(shbuf_id); 3611 3611 if (it == shared_buffers().resource().end()) 3612 3612 return -EINVAL; 3613 3613 auto& shared_buffer = *(*it).value; ··· 3617 3617 return 0; 3618 3618 } 3619 3619 3620 - int Process::sys$release_shared_buffer(int shared_buffer_id) 3620 + int Process::sys$shbuf_release(int shbuf_id) 3621 3621 { 3622 3622 REQUIRE_PROMISE(shared_buffer); 3623 3623 LOCKER(shared_buffers().lock()); 3624 - auto it = shared_buffers().resource().find(shared_buffer_id); 3624 + auto it = shared_buffers().resource().find(shbuf_id); 3625 3625 if (it == shared_buffers().resource().end()) 3626 3626 return -EINVAL; 3627 3627 auto& shared_buffer = *(*it).value; 3628 3628 if (!shared_buffer.is_shared_with(m_pid)) 3629 3629 return -EPERM; 3630 3630 #ifdef SHARED_BUFFER_DEBUG 3631 - kprintf("%s(%u): Releasing shared buffer %d, buffer count: %u\n", name().characters(), pid(), shared_buffer_id, shared_buffers().resource().size()); 3631 + kprintf("%s(%u): Releasing shared buffer %d, buffer count: %u\n", name().characters(), pid(), shbuf_id, shared_buffers().resource().size()); 3632 3632 #endif 3633 3633 shared_buffer.deref_for_process(*this); 3634 3634 return 0; 3635 3635 } 3636 3636 3637 - void* Process::sys$get_shared_buffer(int shared_buffer_id) 3637 + void* Process::sys$shbuf_get(int shbuf_id) 3638 3638 { 3639 3639 REQUIRE_PROMISE(shared_buffer); 3640 3640 LOCKER(shared_buffers().lock()); 3641 - auto it = shared_buffers().resource().find(shared_buffer_id); 3641 + auto it = shared_buffers().resource().find(shbuf_id); 3642 3642 if (it == shared_buffers().resource().end()) 3643 3643 return (void*)-EINVAL; 3644 3644 auto& shared_buffer = *(*it).value; 3645 3645 if (!shared_buffer.is_shared_with(m_pid)) 3646 3646 return (void*)-EPERM; 3647 3647 #ifdef SHARED_BUFFER_DEBUG 3648 - kprintf("%s(%u): Retaining shared buffer %d, buffer count: %u\n", name().characters(), pid(), shared_buffer_id, shared_buffers().resource().size()); 3648 + kprintf("%s(%u): Retaining shared buffer %d, buffer count: %u\n", name().characters(), pid(), shbuf_id, shared_buffers().resource().size()); 3649 3649 #endif 3650 3650 return shared_buffer.ref_for_process_and_get_address(*this); 3651 3651 } 3652 3652 3653 - int Process::sys$seal_shared_buffer(int shared_buffer_id) 3653 + int Process::sys$shbuf_seal(int shbuf_id) 3654 3654 { 3655 3655 REQUIRE_PROMISE(shared_buffer); 3656 3656 LOCKER(shared_buffers().lock()); 3657 - auto it = shared_buffers().resource().find(shared_buffer_id); 3657 + auto it = shared_buffers().resource().find(shbuf_id); 3658 3658 if (it == shared_buffers().resource().end()) 3659 3659 return -EINVAL; 3660 3660 auto& shared_buffer = *(*it).value; 3661 3661 if (!shared_buffer.is_shared_with(m_pid)) 3662 3662 return -EPERM; 3663 3663 #ifdef SHARED_BUFFER_DEBUG 3664 - kprintf("%s(%u): Sealing shared buffer %d\n", name().characters(), pid(), shared_buffer_id); 3664 + kprintf("%s(%u): Sealing shared buffer %d\n", name().characters(), pid(), shbuf_id); 3665 3665 #endif 3666 3666 shared_buffer.seal(); 3667 3667 return 0; 3668 3668 } 3669 3669 3670 - int Process::sys$get_shared_buffer_size(int shared_buffer_id) 3670 + int Process::sys$shbuf_get_size(int shbuf_id) 3671 3671 { 3672 3672 REQUIRE_PROMISE(shared_buffer); 3673 3673 LOCKER(shared_buffers().lock()); 3674 - auto it = shared_buffers().resource().find(shared_buffer_id); 3674 + auto it = shared_buffers().resource().find(shbuf_id); 3675 3675 if (it == shared_buffers().resource().end()) 3676 3676 return -EINVAL; 3677 3677 auto& shared_buffer = *(*it).value; 3678 3678 if (!shared_buffer.is_shared_with(m_pid)) 3679 3679 return -EPERM; 3680 3680 #ifdef SHARED_BUFFER_DEBUG 3681 - kprintf("%s(%u): Get shared buffer %d size: %u\n", name().characters(), pid(), shared_buffer_id, shared_buffers().resource().size()); 3681 + kprintf("%s(%u): Get shared buffer %d size: %u\n", name().characters(), pid(), shbuf_id, shared_buffers().resource().size()); 3682 3682 #endif 3683 3683 return shared_buffer.size(); 3684 3684 } 3685 3685 3686 - int Process::sys$set_shared_buffer_volatile(int shared_buffer_id, bool state) 3686 + int Process::sys$shbuf_set_volatile(int shbuf_id, bool state) 3687 3687 { 3688 3688 REQUIRE_PROMISE(shared_buffer); 3689 3689 LOCKER(shared_buffers().lock()); 3690 - auto it = shared_buffers().resource().find(shared_buffer_id); 3690 + auto it = shared_buffers().resource().find(shbuf_id); 3691 3691 if (it == shared_buffers().resource().end()) 3692 3692 return -EINVAL; 3693 3693 auto& shared_buffer = *(*it).value; 3694 3694 if (!shared_buffer.is_shared_with(m_pid)) 3695 3695 return -EPERM; 3696 3696 #ifdef SHARED_BUFFER_DEBUG 3697 - kprintf("%s(%u): Set shared buffer %d volatile: %u\n", name().characters(), pid(), shared_buffer_id, state); 3697 + kprintf("%s(%u): Set shared buffer %d volatile: %u\n", name().characters(), pid(), shbuf_id, state); 3698 3698 #endif 3699 3699 if (!state) { 3700 3700 bool was_purged = shared_buffer.vmobject().was_purged();
+8 -8
Kernel/Process.h
··· 273 273 int sys$rename(const Syscall::SC_rename_params*); 274 274 int sys$systrace(pid_t); 275 275 int sys$mknod(const Syscall::SC_mknod_params*); 276 - int sys$create_shared_buffer(int, void** buffer); 277 - int sys$share_buffer_with(int, pid_t peer_pid); 278 - int sys$share_buffer_globally(int); 279 - void* sys$get_shared_buffer(int shared_buffer_id); 280 - int sys$release_shared_buffer(int shared_buffer_id); 281 - int sys$seal_shared_buffer(int shared_buffer_id); 282 - int sys$get_shared_buffer_size(int shared_buffer_id); 283 - int sys$set_shared_buffer_volatile(int shared_buffer_id, bool); 276 + int sys$shbuf_create(int, void** buffer); 277 + int sys$shbuf_allow_pid(int, pid_t peer_pid); 278 + int sys$shbuf_allow_all(int); 279 + void* sys$shbuf_get(int shbuf_id); 280 + int sys$shbuf_release(int shbuf_id); 281 + int sys$shbuf_seal(int shbuf_id); 282 + int sys$shbuf_get_size(int shbuf_id); 283 + int sys$shbuf_set_volatile(int shbuf_id, bool); 284 284 int sys$halt(); 285 285 int sys$reboot(); 286 286 int sys$set_process_icon(int icon_id);
+8 -8
Kernel/SharedBuffer.cpp
··· 46 46 found_refs += ref.count; 47 47 48 48 if (found_refs != m_total_refs) { 49 - dbg() << what << " sanity -- SharedBuffer{" << this << "} id: " << m_shared_buffer_id << " has total refs " << m_total_refs << " but we found " << found_refs; 49 + dbg() << what << " sanity -- SharedBuffer{" << this << "} id: " << m_shbuf_id << " has total refs " << m_total_refs << " but we found " << found_refs; 50 50 for (const auto& ref : m_refs) { 51 51 dbg() << " ref from pid " << ref.pid << ": refcnt " << ref.count; 52 52 } ··· 109 109 return; 110 110 for (auto& ref : m_refs) { 111 111 if (ref.pid == peer_pid) { 112 - // don't increment the reference count yet; let them get_shared_buffer it first. 112 + // don't increment the reference count yet; let them shbuf_get it first. 113 113 sanity_check("share_with (old ref)"); 114 114 return; 115 115 } ··· 129 129 m_total_refs--; 130 130 if (ref.count == 0) { 131 131 #ifdef SHARED_BUFFER_DEBUG 132 - dbg() << "Releasing shared buffer reference on " << m_shared_buffer_id << " of size " << size() << " by PID " << process.pid(); 132 + dbg() << "Releasing shared buffer reference on " << m_shbuf_id << " of size " << size() << " by PID " << process.pid(); 133 133 #endif 134 134 process.deallocate_region(*ref.region); 135 135 m_refs.unstable_remove(i); 136 136 #ifdef SHARED_BUFFER_DEBUG 137 - dbg() << "Released shared buffer reference on " << m_shared_buffer_id << " of size " << size() << " by PID " << process.pid(); 137 + dbg() << "Released shared buffer reference on " << m_shbuf_id << " of size " << size() << " by PID " << process.pid(); 138 138 #endif 139 139 sanity_check("deref_for_process"); 140 140 destroy_if_unused(); ··· 154 154 auto& ref = m_refs[i]; 155 155 if (ref.pid == pid) { 156 156 #ifdef SHARED_BUFFER_DEBUG 157 - dbg() << "Disowning shared buffer " << m_shared_buffer_id << " of size " << size() << " by PID " << pid; 157 + dbg() << "Disowning shared buffer " << m_shbuf_id << " of size " << size() << " by PID " << pid; 158 158 #endif 159 159 m_total_refs -= ref.count; 160 160 m_refs.unstable_remove(i); 161 161 #ifdef SHARED_BUFFER_DEBUG 162 - dbg() << "Disowned shared buffer " << m_shared_buffer_id << " of size " << size() << " by PID " << pid; 162 + dbg() << "Disowned shared buffer " << m_shbuf_id << " of size " << size() << " by PID " << pid; 163 163 #endif 164 164 destroy_if_unused(); 165 165 return; ··· 173 173 sanity_check("destroy_if_unused"); 174 174 if (m_total_refs == 0) { 175 175 #ifdef SHARED_BUFFER_DEBUG 176 - kprintf("Destroying unused SharedBuffer{%p} id: %d\n", this, m_shared_buffer_id); 176 + kprintf("Destroying unused SharedBuffer{%p} id: %d\n", this, m_shbuf_id); 177 177 #endif 178 178 auto count_before = shared_buffers().resource().size(); 179 - shared_buffers().resource().remove(m_shared_buffer_id); 179 + shared_buffers().resource().remove(m_shbuf_id); 180 180 ASSERT(count_before != shared_buffers().resource().size()); 181 181 } 182 182 }
+5 -5
Kernel/SharedBuffer.h
··· 48 48 49 49 public: 50 50 SharedBuffer(int id, int size) 51 - : m_shared_buffer_id(id) 51 + : m_shbuf_id(id) 52 52 , m_vmobject(PurgeableVMObject::create_with_size(size)) 53 53 { 54 54 #ifdef SHARED_BUFFER_DEBUG 55 - dbg() << "Created shared buffer " << m_shared_buffer_id << " of size " << size; 55 + dbg() << "Created shared buffer " << m_shbuf_id << " of size " << size; 56 56 #endif 57 57 } 58 58 59 59 ~SharedBuffer() 60 60 { 61 61 #ifdef SHARED_BUFFER_DEBUG 62 - dbg() << "Destroyed shared buffer " << m_shared_buffer_id << " of size " << size(); 62 + dbg() << "Destroyed shared buffer " << m_shbuf_id << " of size " << size(); 63 63 #endif 64 64 } 65 65 ··· 75 75 void seal(); 76 76 PurgeableVMObject& vmobject() { return m_vmobject; } 77 77 const PurgeableVMObject& vmobject() const { return m_vmobject; } 78 - int id() const { return m_shared_buffer_id; } 78 + int id() const { return m_shbuf_id; } 79 79 80 - int m_shared_buffer_id { -1 }; 80 + int m_shbuf_id { -1 }; 81 81 bool m_writable { true }; 82 82 bool m_global { false }; 83 83 NonnullRefPtr<PurgeableVMObject> m_vmobject;
+365 -365
Kernel/Syscall.h
··· 42 42 43 43 namespace Kernel { 44 44 45 - #define ENUMERATE_SYSCALLS \ 46 - __ENUMERATE_SYSCALL(sleep) \ 47 - __ENUMERATE_SYSCALL(yield) \ 48 - __ENUMERATE_SYSCALL(open) \ 49 - __ENUMERATE_SYSCALL(close) \ 50 - __ENUMERATE_SYSCALL(read) \ 51 - __ENUMERATE_SYSCALL(lseek) \ 52 - __ENUMERATE_SYSCALL(kill) \ 53 - __ENUMERATE_SYSCALL(getuid) \ 54 - __ENUMERATE_SYSCALL(exit) \ 55 - __ENUMERATE_SYSCALL(getgid) \ 56 - __ENUMERATE_SYSCALL(getpid) \ 57 - __ENUMERATE_SYSCALL(waitid) \ 58 - __ENUMERATE_SYSCALL(mmap) \ 59 - __ENUMERATE_SYSCALL(munmap) \ 60 - __ENUMERATE_SYSCALL(get_dir_entries) \ 61 - __ENUMERATE_SYSCALL(getcwd) \ 62 - __ENUMERATE_SYSCALL(gettimeofday) \ 63 - __ENUMERATE_SYSCALL(gethostname) \ 64 - __ENUMERATE_SYSCALL(chdir) \ 65 - __ENUMERATE_SYSCALL(uname) \ 66 - __ENUMERATE_SYSCALL(set_mmap_name) \ 67 - __ENUMERATE_SYSCALL(readlink) \ 68 - __ENUMERATE_SYSCALL(write) \ 69 - __ENUMERATE_SYSCALL(ttyname_r) \ 70 - __ENUMERATE_SYSCALL(stat) \ 71 - __ENUMERATE_SYSCALL(getsid) \ 72 - __ENUMERATE_SYSCALL(setsid) \ 73 - __ENUMERATE_SYSCALL(getpgid) \ 74 - __ENUMERATE_SYSCALL(setpgid) \ 75 - __ENUMERATE_SYSCALL(getpgrp) \ 76 - __ENUMERATE_SYSCALL(fork) \ 77 - __ENUMERATE_SYSCALL(execve) \ 78 - __ENUMERATE_SYSCALL(geteuid) \ 79 - __ENUMERATE_SYSCALL(getegid) \ 80 - __ENUMERATE_SYSCALL(getdtablesize) \ 81 - __ENUMERATE_SYSCALL(dup) \ 82 - __ENUMERATE_SYSCALL(dup2) \ 83 - __ENUMERATE_SYSCALL(sigaction) \ 84 - __ENUMERATE_SYSCALL(getppid) \ 85 - __ENUMERATE_SYSCALL(umask) \ 86 - __ENUMERATE_SYSCALL(getgroups) \ 87 - __ENUMERATE_SYSCALL(setgroups) \ 88 - __ENUMERATE_SYSCALL(sigreturn) \ 89 - __ENUMERATE_SYSCALL(sigprocmask) \ 90 - __ENUMERATE_SYSCALL(sigpending) \ 91 - __ENUMERATE_SYSCALL(pipe) \ 92 - __ENUMERATE_SYSCALL(killpg) \ 93 - __ENUMERATE_SYSCALL(setuid) \ 94 - __ENUMERATE_SYSCALL(setgid) \ 95 - __ENUMERATE_SYSCALL(alarm) \ 96 - __ENUMERATE_SYSCALL(fstat) \ 97 - __ENUMERATE_SYSCALL(access) \ 98 - __ENUMERATE_SYSCALL(fcntl) \ 99 - __ENUMERATE_SYSCALL(ioctl) \ 100 - __ENUMERATE_SYSCALL(mkdir) \ 101 - __ENUMERATE_SYSCALL(times) \ 102 - __ENUMERATE_SYSCALL(utime) \ 103 - __ENUMERATE_SYSCALL(sync) \ 104 - __ENUMERATE_SYSCALL(ptsname_r) \ 105 - __ENUMERATE_SYSCALL(select) \ 106 - __ENUMERATE_SYSCALL(unlink) \ 107 - __ENUMERATE_SYSCALL(poll) \ 108 - __ENUMERATE_SYSCALL(rmdir) \ 109 - __ENUMERATE_SYSCALL(chmod) \ 110 - __ENUMERATE_SYSCALL(usleep) \ 111 - __ENUMERATE_SYSCALL(socket) \ 112 - __ENUMERATE_SYSCALL(bind) \ 113 - __ENUMERATE_SYSCALL(accept) \ 114 - __ENUMERATE_SYSCALL(listen) \ 115 - __ENUMERATE_SYSCALL(connect) \ 116 - __ENUMERATE_SYSCALL(create_shared_buffer) \ 117 - __ENUMERATE_SYSCALL(share_buffer_with) \ 118 - __ENUMERATE_SYSCALL(get_shared_buffer) \ 119 - __ENUMERATE_SYSCALL(release_shared_buffer) \ 120 - __ENUMERATE_SYSCALL(link) \ 121 - __ENUMERATE_SYSCALL(chown) \ 122 - __ENUMERATE_SYSCALL(fchmod) \ 123 - __ENUMERATE_SYSCALL(symlink) \ 124 - __ENUMERATE_SYSCALL(get_shared_buffer_size) \ 125 - __ENUMERATE_SYSCALL(seal_shared_buffer) \ 126 - __ENUMERATE_SYSCALL(sendto) \ 127 - __ENUMERATE_SYSCALL(recvfrom) \ 128 - __ENUMERATE_SYSCALL(getsockopt) \ 129 - __ENUMERATE_SYSCALL(setsockopt) \ 130 - __ENUMERATE_SYSCALL(create_thread) \ 131 - __ENUMERATE_SYSCALL(gettid) \ 132 - __ENUMERATE_SYSCALL(donate) \ 133 - __ENUMERATE_SYSCALL(rename) \ 134 - __ENUMERATE_SYSCALL(ftruncate) \ 135 - __ENUMERATE_SYSCALL(systrace) \ 136 - __ENUMERATE_SYSCALL(exit_thread) \ 137 - __ENUMERATE_SYSCALL(mknod) \ 138 - __ENUMERATE_SYSCALL(writev) \ 139 - __ENUMERATE_SYSCALL(beep) \ 140 - __ENUMERATE_SYSCALL(getsockname) \ 141 - __ENUMERATE_SYSCALL(getpeername) \ 142 - __ENUMERATE_SYSCALL(sched_setparam) \ 143 - __ENUMERATE_SYSCALL(sched_getparam) \ 144 - __ENUMERATE_SYSCALL(fchown) \ 145 - __ENUMERATE_SYSCALL(halt) \ 146 - __ENUMERATE_SYSCALL(reboot) \ 147 - __ENUMERATE_SYSCALL(mount) \ 148 - __ENUMERATE_SYSCALL(umount) \ 149 - __ENUMERATE_SYSCALL(dump_backtrace) \ 150 - __ENUMERATE_SYSCALL(dbgputch) \ 151 - __ENUMERATE_SYSCALL(dbgputstr) \ 152 - __ENUMERATE_SYSCALL(watch_file) \ 153 - __ENUMERATE_SYSCALL(share_buffer_globally) \ 154 - __ENUMERATE_SYSCALL(set_process_icon) \ 155 - __ENUMERATE_SYSCALL(mprotect) \ 156 - __ENUMERATE_SYSCALL(realpath) \ 157 - __ENUMERATE_SYSCALL(get_process_name) \ 158 - __ENUMERATE_SYSCALL(fchdir) \ 159 - __ENUMERATE_SYSCALL(getrandom) \ 160 - __ENUMERATE_SYSCALL(setkeymap) \ 161 - __ENUMERATE_SYSCALL(clock_gettime) \ 162 - __ENUMERATE_SYSCALL(clock_nanosleep) \ 163 - __ENUMERATE_SYSCALL(join_thread) \ 164 - __ENUMERATE_SYSCALL(module_load) \ 165 - __ENUMERATE_SYSCALL(module_unload) \ 166 - __ENUMERATE_SYSCALL(detach_thread) \ 167 - __ENUMERATE_SYSCALL(set_thread_name) \ 168 - __ENUMERATE_SYSCALL(get_thread_name) \ 169 - __ENUMERATE_SYSCALL(madvise) \ 170 - __ENUMERATE_SYSCALL(purge) \ 171 - __ENUMERATE_SYSCALL(set_shared_buffer_volatile) \ 172 - __ENUMERATE_SYSCALL(profiling_enable) \ 173 - __ENUMERATE_SYSCALL(profiling_disable) \ 174 - __ENUMERATE_SYSCALL(get_kernel_info_page) \ 175 - __ENUMERATE_SYSCALL(futex) \ 176 - __ENUMERATE_SYSCALL(set_thread_boost) \ 177 - __ENUMERATE_SYSCALL(set_process_boost) \ 178 - __ENUMERATE_SYSCALL(chroot) \ 179 - __ENUMERATE_SYSCALL(pledge) \ 180 - __ENUMERATE_SYSCALL(unveil) \ 181 - __ENUMERATE_SYSCALL(perf_event) \ 45 + #define ENUMERATE_SYSCALLS \ 46 + __ENUMERATE_SYSCALL(sleep) \ 47 + __ENUMERATE_SYSCALL(yield) \ 48 + __ENUMERATE_SYSCALL(open) \ 49 + __ENUMERATE_SYSCALL(close) \ 50 + __ENUMERATE_SYSCALL(read) \ 51 + __ENUMERATE_SYSCALL(lseek) \ 52 + __ENUMERATE_SYSCALL(kill) \ 53 + __ENUMERATE_SYSCALL(getuid) \ 54 + __ENUMERATE_SYSCALL(exit) \ 55 + __ENUMERATE_SYSCALL(getgid) \ 56 + __ENUMERATE_SYSCALL(getpid) \ 57 + __ENUMERATE_SYSCALL(waitid) \ 58 + __ENUMERATE_SYSCALL(mmap) \ 59 + __ENUMERATE_SYSCALL(munmap) \ 60 + __ENUMERATE_SYSCALL(get_dir_entries) \ 61 + __ENUMERATE_SYSCALL(getcwd) \ 62 + __ENUMERATE_SYSCALL(gettimeofday) \ 63 + __ENUMERATE_SYSCALL(gethostname) \ 64 + __ENUMERATE_SYSCALL(chdir) \ 65 + __ENUMERATE_SYSCALL(uname) \ 66 + __ENUMERATE_SYSCALL(set_mmap_name) \ 67 + __ENUMERATE_SYSCALL(readlink) \ 68 + __ENUMERATE_SYSCALL(write) \ 69 + __ENUMERATE_SYSCALL(ttyname_r) \ 70 + __ENUMERATE_SYSCALL(stat) \ 71 + __ENUMERATE_SYSCALL(getsid) \ 72 + __ENUMERATE_SYSCALL(setsid) \ 73 + __ENUMERATE_SYSCALL(getpgid) \ 74 + __ENUMERATE_SYSCALL(setpgid) \ 75 + __ENUMERATE_SYSCALL(getpgrp) \ 76 + __ENUMERATE_SYSCALL(fork) \ 77 + __ENUMERATE_SYSCALL(execve) \ 78 + __ENUMERATE_SYSCALL(geteuid) \ 79 + __ENUMERATE_SYSCALL(getegid) \ 80 + __ENUMERATE_SYSCALL(getdtablesize) \ 81 + __ENUMERATE_SYSCALL(dup) \ 82 + __ENUMERATE_SYSCALL(dup2) \ 83 + __ENUMERATE_SYSCALL(sigaction) \ 84 + __ENUMERATE_SYSCALL(getppid) \ 85 + __ENUMERATE_SYSCALL(umask) \ 86 + __ENUMERATE_SYSCALL(getgroups) \ 87 + __ENUMERATE_SYSCALL(setgroups) \ 88 + __ENUMERATE_SYSCALL(sigreturn) \ 89 + __ENUMERATE_SYSCALL(sigprocmask) \ 90 + __ENUMERATE_SYSCALL(sigpending) \ 91 + __ENUMERATE_SYSCALL(pipe) \ 92 + __ENUMERATE_SYSCALL(killpg) \ 93 + __ENUMERATE_SYSCALL(setuid) \ 94 + __ENUMERATE_SYSCALL(setgid) \ 95 + __ENUMERATE_SYSCALL(alarm) \ 96 + __ENUMERATE_SYSCALL(fstat) \ 97 + __ENUMERATE_SYSCALL(access) \ 98 + __ENUMERATE_SYSCALL(fcntl) \ 99 + __ENUMERATE_SYSCALL(ioctl) \ 100 + __ENUMERATE_SYSCALL(mkdir) \ 101 + __ENUMERATE_SYSCALL(times) \ 102 + __ENUMERATE_SYSCALL(utime) \ 103 + __ENUMERATE_SYSCALL(sync) \ 104 + __ENUMERATE_SYSCALL(ptsname_r) \ 105 + __ENUMERATE_SYSCALL(select) \ 106 + __ENUMERATE_SYSCALL(unlink) \ 107 + __ENUMERATE_SYSCALL(poll) \ 108 + __ENUMERATE_SYSCALL(rmdir) \ 109 + __ENUMERATE_SYSCALL(chmod) \ 110 + __ENUMERATE_SYSCALL(usleep) \ 111 + __ENUMERATE_SYSCALL(socket) \ 112 + __ENUMERATE_SYSCALL(bind) \ 113 + __ENUMERATE_SYSCALL(accept) \ 114 + __ENUMERATE_SYSCALL(listen) \ 115 + __ENUMERATE_SYSCALL(connect) \ 116 + __ENUMERATE_SYSCALL(shbuf_create) \ 117 + __ENUMERATE_SYSCALL(shbuf_allow_pid) \ 118 + __ENUMERATE_SYSCALL(shbuf_get) \ 119 + __ENUMERATE_SYSCALL(shbuf_release) \ 120 + __ENUMERATE_SYSCALL(link) \ 121 + __ENUMERATE_SYSCALL(chown) \ 122 + __ENUMERATE_SYSCALL(fchmod) \ 123 + __ENUMERATE_SYSCALL(symlink) \ 124 + __ENUMERATE_SYSCALL(shbuf_get_size) \ 125 + __ENUMERATE_SYSCALL(shbuf_seal) \ 126 + __ENUMERATE_SYSCALL(sendto) \ 127 + __ENUMERATE_SYSCALL(recvfrom) \ 128 + __ENUMERATE_SYSCALL(getsockopt) \ 129 + __ENUMERATE_SYSCALL(setsockopt) \ 130 + __ENUMERATE_SYSCALL(create_thread) \ 131 + __ENUMERATE_SYSCALL(gettid) \ 132 + __ENUMERATE_SYSCALL(donate) \ 133 + __ENUMERATE_SYSCALL(rename) \ 134 + __ENUMERATE_SYSCALL(ftruncate) \ 135 + __ENUMERATE_SYSCALL(systrace) \ 136 + __ENUMERATE_SYSCALL(exit_thread) \ 137 + __ENUMERATE_SYSCALL(mknod) \ 138 + __ENUMERATE_SYSCALL(writev) \ 139 + __ENUMERATE_SYSCALL(beep) \ 140 + __ENUMERATE_SYSCALL(getsockname) \ 141 + __ENUMERATE_SYSCALL(getpeername) \ 142 + __ENUMERATE_SYSCALL(sched_setparam) \ 143 + __ENUMERATE_SYSCALL(sched_getparam) \ 144 + __ENUMERATE_SYSCALL(fchown) \ 145 + __ENUMERATE_SYSCALL(halt) \ 146 + __ENUMERATE_SYSCALL(reboot) \ 147 + __ENUMERATE_SYSCALL(mount) \ 148 + __ENUMERATE_SYSCALL(umount) \ 149 + __ENUMERATE_SYSCALL(dump_backtrace) \ 150 + __ENUMERATE_SYSCALL(dbgputch) \ 151 + __ENUMERATE_SYSCALL(dbgputstr) \ 152 + __ENUMERATE_SYSCALL(watch_file) \ 153 + __ENUMERATE_SYSCALL(shbuf_allow_all) \ 154 + __ENUMERATE_SYSCALL(set_process_icon) \ 155 + __ENUMERATE_SYSCALL(mprotect) \ 156 + __ENUMERATE_SYSCALL(realpath) \ 157 + __ENUMERATE_SYSCALL(get_process_name) \ 158 + __ENUMERATE_SYSCALL(fchdir) \ 159 + __ENUMERATE_SYSCALL(getrandom) \ 160 + __ENUMERATE_SYSCALL(setkeymap) \ 161 + __ENUMERATE_SYSCALL(clock_gettime) \ 162 + __ENUMERATE_SYSCALL(clock_nanosleep) \ 163 + __ENUMERATE_SYSCALL(join_thread) \ 164 + __ENUMERATE_SYSCALL(module_load) \ 165 + __ENUMERATE_SYSCALL(module_unload) \ 166 + __ENUMERATE_SYSCALL(detach_thread) \ 167 + __ENUMERATE_SYSCALL(set_thread_name) \ 168 + __ENUMERATE_SYSCALL(get_thread_name) \ 169 + __ENUMERATE_SYSCALL(madvise) \ 170 + __ENUMERATE_SYSCALL(purge) \ 171 + __ENUMERATE_SYSCALL(shbuf_set_volatile) \ 172 + __ENUMERATE_SYSCALL(profiling_enable) \ 173 + __ENUMERATE_SYSCALL(profiling_disable) \ 174 + __ENUMERATE_SYSCALL(get_kernel_info_page) \ 175 + __ENUMERATE_SYSCALL(futex) \ 176 + __ENUMERATE_SYSCALL(set_thread_boost) \ 177 + __ENUMERATE_SYSCALL(set_process_boost) \ 178 + __ENUMERATE_SYSCALL(chroot) \ 179 + __ENUMERATE_SYSCALL(pledge) \ 180 + __ENUMERATE_SYSCALL(unveil) \ 181 + __ENUMERATE_SYSCALL(perf_event) \ 182 182 __ENUMERATE_SYSCALL(shutdown) 183 183 184 184 namespace Syscall { 185 185 186 - enum Function { 186 + enum Function { 187 187 #undef __ENUMERATE_SYSCALL 188 188 #undef __ENUMERATE_REMOVED_SYSCALL 189 189 #define __ENUMERATE_REMOVED_SYSCALL(x) SC_##x, 190 190 #define __ENUMERATE_SYSCALL(x) SC_##x, 191 - ENUMERATE_SYSCALLS 191 + ENUMERATE_SYSCALLS 192 192 #undef __ENUMERATE_SYSCALL 193 193 #undef __ENUMERATE_REMOVED_SYSCALL 194 - __Count 195 - }; 194 + __Count 195 + }; 196 196 197 - inline constexpr const char* to_string(Function function) 198 - { 199 - switch (function) { 197 + inline constexpr const char* to_string(Function function) 198 + { 199 + switch (function) { 200 200 #undef __ENUMERATE_SYSCALL 201 201 #undef __ENUMERATE_REMOVED_SYSCALL 202 202 #define __ENUMERATE_REMOVED_SYSCALL(x) \ ··· 205 205 #define __ENUMERATE_SYSCALL(x) \ 206 206 case SC_##x: \ 207 207 return #x; 208 - ENUMERATE_SYSCALLS 208 + ENUMERATE_SYSCALLS 209 209 #undef __ENUMERATE_SYSCALL 210 210 #undef __ENUMERATE_REMOVED_SYSCALL 211 - default: 212 - break; 211 + default: 212 + break; 213 + } 214 + return "Unknown"; 213 215 } 214 - return "Unknown"; 215 - } 216 216 217 217 #ifdef __serenity__ 218 - struct StringArgument { 219 - const char* characters { nullptr }; 220 - size_t length { 0 }; 221 - }; 218 + struct StringArgument { 219 + const char* characters { nullptr }; 220 + size_t length { 0 }; 221 + }; 222 222 223 - template<typename DataType, typename SizeType> 224 - struct MutableBufferArgument { 225 - DataType* data { nullptr }; 226 - SizeType size { 0 }; 227 - }; 223 + template<typename DataType, typename SizeType> 224 + struct MutableBufferArgument { 225 + DataType* data { nullptr }; 226 + SizeType size { 0 }; 227 + }; 228 228 229 - template<typename DataType, typename SizeType> 230 - struct ImmutableBufferArgument { 231 - const DataType* data { nullptr }; 232 - SizeType size { 0 }; 233 - }; 229 + template<typename DataType, typename SizeType> 230 + struct ImmutableBufferArgument { 231 + const DataType* data { nullptr }; 232 + SizeType size { 0 }; 233 + }; 234 234 235 - struct StringListArgument { 236 - StringArgument* strings { nullptr }; 237 - size_t length { 0 }; 238 - }; 235 + struct StringListArgument { 236 + StringArgument* strings { nullptr }; 237 + size_t length { 0 }; 238 + }; 239 239 240 - struct SC_mmap_params { 241 - uint32_t addr; 242 - uint32_t size; 243 - uint32_t alignment; 244 - int32_t prot; 245 - int32_t flags; 246 - int32_t fd; 247 - int32_t offset; // FIXME: 64-bit off_t? 248 - StringArgument name; 249 - }; 240 + struct SC_mmap_params { 241 + uint32_t addr; 242 + uint32_t size; 243 + uint32_t alignment; 244 + int32_t prot; 245 + int32_t flags; 246 + int32_t fd; 247 + int32_t offset; // FIXME: 64-bit off_t? 248 + StringArgument name; 249 + }; 250 250 251 - struct SC_open_params { 252 - int dirfd; 253 - StringArgument path; 254 - int options; 255 - u16 mode; 256 - }; 251 + struct SC_open_params { 252 + int dirfd; 253 + StringArgument path; 254 + int options; 255 + u16 mode; 256 + }; 257 257 258 - struct SC_select_params { 259 - int nfds; 260 - fd_set* readfds; 261 - fd_set* writefds; 262 - fd_set* exceptfds; 263 - struct timeval* timeout; 264 - }; 258 + struct SC_select_params { 259 + int nfds; 260 + fd_set* readfds; 261 + fd_set* writefds; 262 + fd_set* exceptfds; 263 + struct timeval* timeout; 264 + }; 265 265 266 - struct SC_clock_nanosleep_params { 267 - int clock_id; 268 - int flags; 269 - const struct timespec* requested_sleep; 270 - struct timespec* remaining_sleep; 271 - }; 266 + struct SC_clock_nanosleep_params { 267 + int clock_id; 268 + int flags; 269 + const struct timespec* requested_sleep; 270 + struct timespec* remaining_sleep; 271 + }; 272 272 273 - struct SC_sendto_params { 274 - int sockfd; 275 - ImmutableBufferArgument<void, size_t> data; 276 - int flags; 277 - const sockaddr* addr; 278 - socklen_t addr_length; 279 - }; 273 + struct SC_sendto_params { 274 + int sockfd; 275 + ImmutableBufferArgument<void, size_t> data; 276 + int flags; 277 + const sockaddr* addr; 278 + socklen_t addr_length; 279 + }; 280 280 281 - struct SC_recvfrom_params { 282 - int sockfd; 283 - MutableBufferArgument<void, size_t> buffer; 284 - int flags; 285 - sockaddr* addr; 286 - socklen_t* addr_length; 287 - }; 281 + struct SC_recvfrom_params { 282 + int sockfd; 283 + MutableBufferArgument<void, size_t> buffer; 284 + int flags; 285 + sockaddr* addr; 286 + socklen_t* addr_length; 287 + }; 288 288 289 - struct SC_getsockopt_params { 290 - int sockfd; 291 - int level; 292 - int option; 293 - void* value; 294 - socklen_t* value_size; 295 - }; 289 + struct SC_getsockopt_params { 290 + int sockfd; 291 + int level; 292 + int option; 293 + void* value; 294 + socklen_t* value_size; 295 + }; 296 296 297 - struct SC_setsockopt_params { 298 - int sockfd; 299 - int level; 300 - int option; 301 - const void* value; 302 - socklen_t value_size; 303 - }; 297 + struct SC_setsockopt_params { 298 + int sockfd; 299 + int level; 300 + int option; 301 + const void* value; 302 + socklen_t value_size; 303 + }; 304 304 305 - struct SC_getsockname_params { 306 - int sockfd; 307 - sockaddr* addr; 308 - socklen_t* addrlen; 309 - }; 305 + struct SC_getsockname_params { 306 + int sockfd; 307 + sockaddr* addr; 308 + socklen_t* addrlen; 309 + }; 310 310 311 - struct SC_getpeername_params { 312 - int sockfd; 313 - sockaddr* addr; 314 - socklen_t* addrlen; 315 - }; 311 + struct SC_getpeername_params { 312 + int sockfd; 313 + sockaddr* addr; 314 + socklen_t* addrlen; 315 + }; 316 316 317 - struct SC_futex_params { 318 - i32* userspace_address; 319 - int futex_op; 320 - i32 val; 321 - const timespec* timeout; 322 - }; 317 + struct SC_futex_params { 318 + i32* userspace_address; 319 + int futex_op; 320 + i32 val; 321 + const timespec* timeout; 322 + }; 323 323 324 - struct SC_setkeymap_params { 325 - const char* map; 326 - const char* shift_map; 327 - const char* alt_map; 328 - const char* altgr_map; 329 - }; 324 + struct SC_setkeymap_params { 325 + const char* map; 326 + const char* shift_map; 327 + const char* alt_map; 328 + const char* altgr_map; 329 + }; 330 330 331 - struct SC_create_thread_params { 332 - unsigned int m_detach_state = 0; // JOINABLE or DETACHED 333 - int m_schedule_priority = 30; // THREAD_PRIORITY_NORMAL 334 - // FIXME: Implment guard pages in create_thread (unreadable pages at "overflow" end of stack) 335 - // "If an implementation rounds up the value of guardsize to a multiple of {PAGESIZE}, 336 - // a call to pthread_attr_getguardsize() specifying attr shall store in the guardsize 337 - // parameter the guard size specified by the previous pthread_attr_setguardsize() function call" 338 - // ... ok, if you say so posix. Guess we get to lie to people about guard page size 339 - unsigned int m_guard_page_size = 0; // Rounded up to PAGE_SIZE 340 - unsigned int m_reported_guard_page_size = 0; // The lie we tell callers 341 - unsigned int m_stack_size = 4 * MB; // Default PTHREAD_STACK_MIN 342 - void* m_stack_location = nullptr; // nullptr means any, o.w. process virtual address 343 - }; 331 + struct SC_create_thread_params { 332 + unsigned int m_detach_state = 0; // JOINABLE or DETACHED 333 + int m_schedule_priority = 30; // THREAD_PRIORITY_NORMAL 334 + // FIXME: Implment guard pages in create_thread (unreadable pages at "overflow" end of stack) 335 + // "If an implementation rounds up the value of guardsize to a multiple of {PAGESIZE}, 336 + // a call to pthread_attr_getguardsize() specifying attr shall store in the guardsize 337 + // parameter the guard size specified by the previous pthread_attr_setguardsize() function call" 338 + // ... ok, if you say so posix. Guess we get to lie to people about guard page size 339 + unsigned int m_guard_page_size = 0; // Rounded up to PAGE_SIZE 340 + unsigned int m_reported_guard_page_size = 0; // The lie we tell callers 341 + unsigned int m_stack_size = 4 * MB; // Default PTHREAD_STACK_MIN 342 + void* m_stack_location = nullptr; // nullptr means any, o.w. process virtual address 343 + }; 344 344 345 - struct SC_realpath_params { 346 - StringArgument path; 347 - MutableBufferArgument<char, size_t> buffer; 348 - }; 345 + struct SC_realpath_params { 346 + StringArgument path; 347 + MutableBufferArgument<char, size_t> buffer; 348 + }; 349 349 350 - struct SC_set_mmap_name_params { 351 - void* addr; 352 - size_t size; 353 - StringArgument name; 354 - }; 350 + struct SC_set_mmap_name_params { 351 + void* addr; 352 + size_t size; 353 + StringArgument name; 354 + }; 355 355 356 - struct SC_execve_params { 357 - StringArgument path; 358 - StringListArgument arguments; 359 - StringListArgument environment; 360 - }; 356 + struct SC_execve_params { 357 + StringArgument path; 358 + StringListArgument arguments; 359 + StringListArgument environment; 360 + }; 361 361 362 - struct SC_readlink_params { 363 - StringArgument path; 364 - MutableBufferArgument<char, size_t> buffer; 365 - }; 362 + struct SC_readlink_params { 363 + StringArgument path; 364 + MutableBufferArgument<char, size_t> buffer; 365 + }; 366 366 367 - struct SC_link_params { 368 - StringArgument old_path; 369 - StringArgument new_path; 370 - }; 367 + struct SC_link_params { 368 + StringArgument old_path; 369 + StringArgument new_path; 370 + }; 371 371 372 - struct SC_chown_params { 373 - StringArgument path; 374 - u32 uid; 375 - u32 gid; 376 - }; 372 + struct SC_chown_params { 373 + StringArgument path; 374 + u32 uid; 375 + u32 gid; 376 + }; 377 377 378 - struct SC_mknod_params { 379 - StringArgument path; 380 - u16 mode; 381 - u32 dev; 382 - }; 378 + struct SC_mknod_params { 379 + StringArgument path; 380 + u16 mode; 381 + u32 dev; 382 + }; 383 383 384 - struct SC_symlink_params { 385 - StringArgument target; 386 - StringArgument linkpath; 387 - }; 384 + struct SC_symlink_params { 385 + StringArgument target; 386 + StringArgument linkpath; 387 + }; 388 388 389 - struct SC_rename_params { 390 - StringArgument old_path; 391 - StringArgument new_path; 392 - }; 389 + struct SC_rename_params { 390 + StringArgument old_path; 391 + StringArgument new_path; 392 + }; 393 393 394 - struct SC_mount_params { 395 - StringArgument source; 396 - StringArgument target; 397 - StringArgument fs_type; 398 - int flags; 399 - }; 394 + struct SC_mount_params { 395 + StringArgument source; 396 + StringArgument target; 397 + StringArgument fs_type; 398 + int flags; 399 + }; 400 400 401 - struct SC_pledge_params { 402 - StringArgument promises; 403 - StringArgument execpromises; 404 - }; 401 + struct SC_pledge_params { 402 + StringArgument promises; 403 + StringArgument execpromises; 404 + }; 405 405 406 - struct SC_unveil_params { 407 - StringArgument path; 408 - StringArgument permissions; 409 - }; 406 + struct SC_unveil_params { 407 + StringArgument path; 408 + StringArgument permissions; 409 + }; 410 410 411 - struct SC_waitid_params { 412 - int idtype; 413 - int id; 414 - struct siginfo* infop; 415 - int options; 416 - }; 411 + struct SC_waitid_params { 412 + int idtype; 413 + int id; 414 + struct siginfo* infop; 415 + int options; 416 + }; 417 417 418 - struct SC_stat_params { 419 - StringArgument path; 420 - struct stat* statbuf; 421 - bool follow_symlinks; 422 - }; 418 + struct SC_stat_params { 419 + StringArgument path; 420 + struct stat* statbuf; 421 + bool follow_symlinks; 422 + }; 423 423 424 - void initialize(); 425 - int sync(); 424 + void initialize(); 425 + int sync(); 426 426 427 - inline u32 invoke(Function function) 428 - { 429 - u32 result; 430 - asm volatile("int $0x82" 431 - : "=a"(result) 432 - : "a"(function) 433 - : "memory"); 434 - return result; 435 - } 427 + inline u32 invoke(Function function) 428 + { 429 + u32 result; 430 + asm volatile("int $0x82" 431 + : "=a"(result) 432 + : "a"(function) 433 + : "memory"); 434 + return result; 435 + } 436 436 437 - template<typename T1> 438 - inline u32 invoke(Function function, T1 arg1) 439 - { 440 - u32 result; 441 - asm volatile("int $0x82" 442 - : "=a"(result) 443 - : "a"(function), "d"((u32)arg1) 444 - : "memory"); 445 - return result; 446 - } 437 + template<typename T1> 438 + inline u32 invoke(Function function, T1 arg1) 439 + { 440 + u32 result; 441 + asm volatile("int $0x82" 442 + : "=a"(result) 443 + : "a"(function), "d"((u32)arg1) 444 + : "memory"); 445 + return result; 446 + } 447 447 448 - template<typename T1, typename T2> 449 - inline u32 invoke(Function function, T1 arg1, T2 arg2) 450 - { 451 - u32 result; 452 - asm volatile("int $0x82" 453 - : "=a"(result) 454 - : "a"(function), "d"((u32)arg1), "c"((u32)arg2) 455 - : "memory"); 456 - return result; 457 - } 448 + template<typename T1, typename T2> 449 + inline u32 invoke(Function function, T1 arg1, T2 arg2) 450 + { 451 + u32 result; 452 + asm volatile("int $0x82" 453 + : "=a"(result) 454 + : "a"(function), "d"((u32)arg1), "c"((u32)arg2) 455 + : "memory"); 456 + return result; 457 + } 458 458 459 - template<typename T1, typename T2, typename T3> 460 - inline u32 invoke(Function function, T1 arg1, T2 arg2, T3 arg3) 461 - { 462 - u32 result; 463 - asm volatile("int $0x82" 464 - : "=a"(result) 465 - : "a"(function), "d"((u32)arg1), "c"((u32)arg2), "b"((u32)arg3) 466 - : "memory"); 467 - return result; 468 - } 459 + template<typename T1, typename T2, typename T3> 460 + inline u32 invoke(Function function, T1 arg1, T2 arg2, T3 arg3) 461 + { 462 + u32 result; 463 + asm volatile("int $0x82" 464 + : "=a"(result) 465 + : "a"(function), "d"((u32)arg1), "c"((u32)arg2), "b"((u32)arg3) 466 + : "memory"); 467 + return result; 468 + } 469 469 #endif 470 470 471 471 }
+1 -1
Libraries/LibAudio/Buffer.h
··· 121 121 int sample_count() const { return m_sample_count; } 122 122 const void* data() const { return m_buffer->data(); } 123 123 int size_in_bytes() const { return m_sample_count * (int)sizeof(Sample); } 124 - int shared_buffer_id() const { return m_buffer->shared_buffer_id(); } 124 + int shbuf_id() const { return m_buffer->shbuf_id(); } 125 125 SharedBuffer& shared_buffer() { return *m_buffer; } 126 126 127 127 private:
+2 -2
Libraries/LibAudio/ClientConnection.cpp
··· 45 45 { 46 46 for (;;) { 47 47 const_cast<Buffer&>(buffer).shared_buffer().share_with(server_pid()); 48 - auto response = send_sync<Messages::AudioServer::EnqueueBuffer>(buffer.shared_buffer_id(), buffer.sample_count()); 48 + auto response = send_sync<Messages::AudioServer::EnqueueBuffer>(buffer.shbuf_id(), buffer.sample_count()); 49 49 if (response->success()) 50 50 break; 51 51 sleep(1); ··· 55 55 bool ClientConnection::try_enqueue(const Buffer& buffer) 56 56 { 57 57 const_cast<Buffer&>(buffer).shared_buffer().share_with(server_pid()); 58 - auto response = send_sync<Messages::AudioServer::EnqueueBuffer>(buffer.shared_buffer_id(), buffer.sample_count()); 58 + auto response = send_sync<Messages::AudioServer::EnqueueBuffer>(buffer.shbuf_id(), buffer.sample_count()); 59 59 return response->success(); 60 60 } 61 61
+14 -14
Libraries/LibC/unistd.cpp
··· 529 529 syscall(SC_sync); 530 530 } 531 531 532 - int create_shared_buffer(int size, void** buffer) 532 + int shbuf_create(int size, void** buffer) 533 533 { 534 - int rc = syscall(SC_create_shared_buffer, size, buffer); 534 + int rc = syscall(SC_shbuf_create, size, buffer); 535 535 __RETURN_WITH_ERRNO(rc, rc, -1); 536 536 } 537 537 538 - int share_buffer_with(int shared_buffer_id, pid_t peer_pid) 538 + int shbuf_allow_pid(int shbuf_id, pid_t peer_pid) 539 539 { 540 - int rc = syscall(SC_share_buffer_with, shared_buffer_id, peer_pid); 540 + int rc = syscall(SC_shbuf_allow_pid, shbuf_id, peer_pid); 541 541 __RETURN_WITH_ERRNO(rc, rc, -1); 542 542 } 543 543 544 - int share_buffer_globally(int shared_buffer_id) 544 + int shbuf_allow_all(int shbuf_id) 545 545 { 546 - int rc = syscall(SC_share_buffer_globally, shared_buffer_id); 546 + int rc = syscall(SC_shbuf_allow_all, shbuf_id); 547 547 __RETURN_WITH_ERRNO(rc, rc, -1); 548 548 } 549 549 ··· 553 553 __RETURN_WITH_ERRNO(rc, rc, -1); 554 554 } 555 555 556 - void* get_shared_buffer(int shared_buffer_id) 556 + void* shbuf_get(int shbuf_id) 557 557 { 558 - int rc = syscall(SC_get_shared_buffer, shared_buffer_id); 558 + int rc = syscall(SC_shbuf_get, shbuf_id); 559 559 if (rc < 0 && -rc < EMAXERRNO) { 560 560 errno = -rc; 561 561 return (void*)-1; ··· 563 563 return (void*)rc; 564 564 } 565 565 566 - int release_shared_buffer(int shared_buffer_id) 566 + int shbuf_release(int shbuf_id) 567 567 { 568 - int rc = syscall(SC_release_shared_buffer, shared_buffer_id); 568 + int rc = syscall(SC_shbuf_release, shbuf_id); 569 569 __RETURN_WITH_ERRNO(rc, rc, -1); 570 570 } 571 571 572 - int get_shared_buffer_size(int shared_buffer_id) 572 + int shbuf_get_size(int shbuf_id) 573 573 { 574 - int rc = syscall(SC_get_shared_buffer_size, shared_buffer_id); 574 + int rc = syscall(SC_shbuf_get_size, shbuf_id); 575 575 __RETURN_WITH_ERRNO(rc, rc, -1); 576 576 } 577 577 578 - int seal_shared_buffer(int shared_buffer_id) 578 + int shbuf_seal(int shbuf_id) 579 579 { 580 - int rc = syscall(SC_seal_shared_buffer, shared_buffer_id); 580 + int rc = syscall(SC_shbuf_seal, shbuf_id); 581 581 __RETURN_WITH_ERRNO(rc, rc, -1); 582 582 } 583 583
+7 -7
Libraries/LibC/unistd.h
··· 61 61 int systrace(pid_t); 62 62 int gettid(); 63 63 int donate(int tid); 64 - int create_shared_buffer(int, void** buffer); 65 - int share_buffer_with(int, pid_t peer_pid); 66 - int share_buffer_globally(int); 67 - void* get_shared_buffer(int shared_buffer_id); 68 - int release_shared_buffer(int shared_buffer_id); 69 - int seal_shared_buffer(int shared_buffer_id); 70 - int get_shared_buffer_size(int shared_buffer_id); 64 + int shbuf_create(int, void** buffer); 65 + int shbuf_allow_pid(int, pid_t peer_pid); 66 + int shbuf_allow_all(int); 67 + void* shbuf_get(int shbuf_id); 68 + int shbuf_release(int shbuf_id); 69 + int shbuf_seal(int shbuf_id); 70 + int shbuf_get_size(int shbuf_id); 71 71 int set_process_icon(int icon_id); 72 72 inline int getpagesize() { return 4096; } 73 73 pid_t fork();
+3 -3
Libraries/LibGUI/Clipboard.cpp
··· 46 46 Clipboard::DataAndType Clipboard::data_and_type() const 47 47 { 48 48 auto response = WindowServerConnection::the().send_sync<Messages::WindowServer::GetClipboardContents>(); 49 - if (response->shared_buffer_id() < 0) 49 + if (response->shbuf_id() < 0) 50 50 return {}; 51 - auto shared_buffer = SharedBuffer::create_from_shared_buffer_id(response->shared_buffer_id()); 51 + auto shared_buffer = SharedBuffer::create_from_shbuf_id(response->shbuf_id()); 52 52 if (!shared_buffer) { 53 53 dbgprintf("GUI::Clipboard::data() failed to attach to the shared buffer\n"); 54 54 return {}; ··· 76 76 shared_buffer->seal(); 77 77 shared_buffer->share_with(WindowServerConnection::the().server_pid()); 78 78 79 - WindowServerConnection::the().send_sync<Messages::WindowServer::SetClipboardContents>(shared_buffer->shared_buffer_id(), data.length(), type); 79 + WindowServerConnection::the().send_sync<Messages::WindowServer::SetClipboardContents>(shared_buffer->shbuf_id(), data.length(), type); 80 80 } 81 81 82 82 void Clipboard::did_receive_clipboard_contents_changed(Badge<WindowServerConnection>, const String& data_type)
+1 -1
Libraries/LibGUI/DragOperation.cpp
··· 55 55 if (m_bitmap) { 56 56 shared_bitmap = m_bitmap->to_shareable_bitmap(); 57 57 shared_bitmap->shared_buffer()->share_with(WindowServerConnection::the().server_pid()); 58 - bitmap_id = shared_bitmap->shared_buffer_id(); 58 + bitmap_id = shared_bitmap->shbuf_id(); 59 59 bitmap_size = shared_bitmap->size(); 60 60 } 61 61
+2 -2
Libraries/LibGUI/Menu.cpp
··· 128 128 if (action.icon()) { 129 129 ASSERT(action.icon()->format() == Gfx::BitmapFormat::RGBA32); 130 130 ASSERT(action.icon()->size() == Gfx::Size(16, 16)); 131 - if (action.icon()->shared_buffer_id() == -1) { 131 + if (action.icon()->shbuf_id() == -1) { 132 132 auto shared_buffer = SharedBuffer::create_with_size(action.icon()->size_in_bytes()); 133 133 ASSERT(shared_buffer); 134 134 auto shared_icon = Gfx::Bitmap::create_with_shared_buffer(Gfx::BitmapFormat::RGBA32, *shared_buffer, action.icon()->size()); ··· 137 137 shared_buffer->share_with(WindowServerConnection::the().server_pid()); 138 138 action.set_icon(shared_icon); 139 139 } 140 - icon_buffer_id = action.icon()->shared_buffer_id(); 140 + icon_buffer_id = action.icon()->shbuf_id(); 141 141 } 142 142 auto shortcut_text = action.shortcut().is_valid() ? action.shortcut().to_string() : String(); 143 143 bool exclusive = action.group() && action.group()->is_exclusive() && action.is_checkable();
+5 -5
Libraries/LibGUI/Window.cpp
··· 477 477 478 478 void Window::set_current_backing_bitmap(Gfx::Bitmap& bitmap, bool flush_immediately) 479 479 { 480 - 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); 480 + WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowBackingStore>(m_window_id, 32, bitmap.pitch(), bitmap.shbuf_id(), bitmap.has_alpha_channel(), bitmap.size(), flush_immediately); 481 481 } 482 482 483 483 void Window::flip(const Vector<Gfx::Rect, 32>& dirty_rects) ··· 551 551 if (!m_window_id) 552 552 return; 553 553 554 - int rc = seal_shared_buffer(m_icon->shared_buffer_id()); 554 + int rc = shbuf_seal(m_icon->shbuf_id()); 555 555 ASSERT(rc == 0); 556 556 557 - rc = share_buffer_globally(m_icon->shared_buffer_id()); 557 + rc = shbuf_allow_all(m_icon->shbuf_id()); 558 558 ASSERT(rc == 0); 559 559 560 560 static bool has_set_process_icon; 561 561 if (!has_set_process_icon) 562 - set_process_icon(m_icon->shared_buffer_id()); 562 + set_process_icon(m_icon->shbuf_id()); 563 563 564 - WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowIconBitmap>(m_window_id, m_icon->shared_buffer_id(), m_icon->size()); 564 + WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowIconBitmap>(m_window_id, m_icon->shbuf_id(), m_icon->size()); 565 565 } 566 566 567 567 void Window::start_wm_resize()
+4 -4
Libraries/LibGUI/WindowServerConnection.cpp
··· 53 53 return *s_connection; 54 54 } 55 55 56 - static void set_system_theme_from_shared_buffer_id(int id) 56 + static void set_system_theme_from_shbuf_id(int id) 57 57 { 58 - auto system_theme = SharedBuffer::create_from_shared_buffer_id(id); 58 + auto system_theme = SharedBuffer::create_from_shbuf_id(id); 59 59 ASSERT(system_theme); 60 60 Gfx::set_system_theme(*system_theme); 61 61 Application::the().set_system_palette(*system_theme); ··· 65 65 { 66 66 auto response = send_sync<Messages::WindowServer::Greet>(); 67 67 set_my_client_id(response->client_id()); 68 - set_system_theme_from_shared_buffer_id(response->system_theme_buffer_id()); 68 + set_system_theme_from_shbuf_id(response->system_theme_buffer_id()); 69 69 Desktop::the().did_receive_screen_rect({}, response->screen_rect()); 70 70 } 71 71 72 72 void WindowServerConnection::handle(const Messages::WindowClient::UpdateSystemTheme& message) 73 73 { 74 - set_system_theme_from_shared_buffer_id(message.system_theme_buffer_id()); 74 + set_system_theme_from_shbuf_id(message.system_theme_buffer_id()); 75 75 Window::update_all_windows({}); 76 76 } 77 77
+2 -2
Libraries/LibGfx/Bitmap.cpp
··· 158 158 return rc == 0; 159 159 } 160 160 161 - int Bitmap::shared_buffer_id() const 161 + int Bitmap::shbuf_id() const 162 162 { 163 - return m_shared_buffer ? m_shared_buffer->shared_buffer_id() : -1; 163 + return m_shared_buffer ? m_shared_buffer->shbuf_id() : -1; 164 164 } 165 165 166 166 }
+1 -1
Libraries/LibGfx/Bitmap.h
··· 64 64 int width() const { return m_size.width(); } 65 65 int height() const { return m_size.height(); } 66 66 size_t pitch() const { return m_pitch; } 67 - int shared_buffer_id() const; 67 + int shbuf_id() const; 68 68 69 69 SharedBuffer* shared_buffer() { return m_shared_buffer.ptr(); } 70 70 const SharedBuffer* shared_buffer() const { return m_shared_buffer.ptr(); }
+1 -1
Libraries/LibGfx/SystemTheme.cpp
··· 43 43 int current_system_theme_buffer_id() 44 44 { 45 45 ASSERT(theme_buffer); 46 - return theme_buffer->shared_buffer_id(); 46 + return theme_buffer->shbuf_id(); 47 47 } 48 48 49 49 void set_system_theme(SharedBuffer& buffer)
+2 -2
Libraries/LibProtocol/Client.cpp
··· 66 66 { 67 67 RefPtr<Download> download; 68 68 if ((download = m_downloads.get(message.download_id()).value_or(nullptr))) { 69 - download->did_finish({}, message.success(), message.total_size(), message.shared_buffer_id()); 69 + download->did_finish({}, message.success(), message.total_size(), message.shbuf_id()); 70 70 } 71 - send_sync<Messages::ProtocolServer::DisownSharedBuffer>(message.shared_buffer_id()); 71 + send_sync<Messages::ProtocolServer::DisownSharedBuffer>(message.shbuf_id()); 72 72 m_downloads.remove(message.download_id()); 73 73 } 74 74
+3 -3
Libraries/LibProtocol/Download.cpp
··· 41 41 return m_client->stop_download({}, *this); 42 42 } 43 43 44 - void Download::did_finish(Badge<Client>, bool success, u32 total_size, i32 shared_buffer_id) 44 + void Download::did_finish(Badge<Client>, bool success, u32 total_size, i32 shbuf_id) 45 45 { 46 46 if (!on_finish) 47 47 return; 48 48 49 49 ByteBuffer payload; 50 50 RefPtr<SharedBuffer> shared_buffer; 51 - if (success && shared_buffer_id != -1) { 52 - shared_buffer = SharedBuffer::create_from_shared_buffer_id(shared_buffer_id); 51 + if (success && shbuf_id != -1) { 52 + shared_buffer = SharedBuffer::create_from_shbuf_id(shbuf_id); 53 53 payload = ByteBuffer::wrap(shared_buffer->data(), total_size); 54 54 } 55 55 on_finish(success, payload, move(shared_buffer));
+1 -1
Libraries/LibProtocol/Download.h
··· 49 49 Function<void(bool success, const ByteBuffer& payload, RefPtr<SharedBuffer> payload_storage)> on_finish; 50 50 Function<void(u32 total_size, u32 downloaded_size)> on_progress; 51 51 52 - void did_finish(Badge<Client>, bool success, u32 total_size, i32 shared_buffer_id); 52 + void did_finish(Badge<Client>, bool success, u32 total_size, i32 shbuf_id); 53 53 void did_progress(Badge<Client>, u32 total_size, u32 downloaded_size); 54 54 55 55 private:
+1 -1
Servers/AudioServer/ASClientConnection.cpp
··· 92 92 93 93 OwnPtr<Messages::AudioServer::EnqueueBufferResponse> ASClientConnection::handle(const Messages::AudioServer::EnqueueBuffer& message) 94 94 { 95 - auto shared_buffer = SharedBuffer::create_from_shared_buffer_id(message.buffer_id()); 95 + auto shared_buffer = SharedBuffer::create_from_shbuf_id(message.buffer_id()); 96 96 if (!shared_buffer) { 97 97 // FIXME: The shared buffer should have been retrieved for us already. 98 98 // We don't want to do IPC error checking at this layer.
+2 -2
Servers/AudioServer/ASMixer.h
··· 64 64 ++m_played_samples; 65 65 66 66 if (m_position >= m_current->sample_count()) { 67 - m_client->did_finish_playing_buffer({}, m_current->shared_buffer_id()); 67 + m_client->did_finish_playing_buffer({}, m_current->shbuf_id()); 68 68 m_current = nullptr; 69 69 m_position = 0; 70 70 } ··· 93 93 int get_playing_buffer() const 94 94 { 95 95 if (m_current) 96 - return m_current->shared_buffer_id(); 96 + return m_current->shbuf_id(); 97 97 return -1; 98 98 } 99 99
+3 -3
Servers/ProtocolServer/PSClientConnection.cpp
··· 82 82 memcpy(buffer->data(), download.payload().data(), download.payload().size()); 83 83 buffer->seal(); 84 84 buffer->share_with(client_pid()); 85 - m_shared_buffers.set(buffer->shared_buffer_id(), buffer); 85 + m_shared_buffers.set(buffer->shbuf_id(), buffer); 86 86 } 87 - post_message(Messages::ProtocolClient::DownloadFinished(download.id(), success, download.total_size(), buffer ? buffer->shared_buffer_id() : -1)); 87 + post_message(Messages::ProtocolClient::DownloadFinished(download.id(), success, download.total_size(), buffer ? buffer->shbuf_id() : -1)); 88 88 } 89 89 90 90 void PSClientConnection::did_progress_download(Badge<Download>, Download& download) ··· 99 99 100 100 OwnPtr<Messages::ProtocolServer::DisownSharedBufferResponse> PSClientConnection::handle(const Messages::ProtocolServer::DisownSharedBuffer& message) 101 101 { 102 - m_shared_buffers.remove(message.shared_buffer_id()); 102 + m_shared_buffers.remove(message.shbuf_id()); 103 103 return make<Messages::ProtocolServer::DisownSharedBufferResponse>(); 104 104 }
+1 -1
Servers/ProtocolServer/ProtocolClient.ipc
··· 2 2 { 3 3 // Download notifications 4 4 DownloadProgress(i32 download_id, u32 total_size, u32 downloaded_size) =| 5 - DownloadFinished(i32 download_id, bool success, u32 total_size, i32 shared_buffer_id) =| 5 + DownloadFinished(i32 download_id, bool success, u32 total_size, i32 shbuf_id) =| 6 6 }
+1 -1
Servers/ProtocolServer/ProtocolServer.ipc
··· 4 4 Greet() => (i32 client_id) 5 5 6 6 // FIXME: It would be nice if the kernel provided a way to avoid this 7 - DisownSharedBuffer(i32 shared_buffer_id) => () 7 + DisownSharedBuffer(i32 shbuf_id) => () 8 8 9 9 // Test if a specific protocol is supported, e.g "http" 10 10 IsSupportedProtocol(String protocol) => (bool supported)
+9 -9
Servers/WindowServer/ClientConnection.cpp
··· 193 193 auto& menu = *(*it).value; 194 194 auto menu_item = make<MenuItem>(menu, identifier, message.text(), message.shortcut(), message.enabled(), message.checkable(), message.checked()); 195 195 if (message.icon_buffer_id() != -1) { 196 - auto icon_buffer = SharedBuffer::create_from_shared_buffer_id(message.icon_buffer_id()); 196 + auto icon_buffer = SharedBuffer::create_from_shbuf_id(message.icon_buffer_id()); 197 197 if (!icon_buffer) 198 198 return nullptr; 199 199 // FIXME: Verify that the icon buffer can accomodate a 16x16 bitmap view. ··· 349 349 } 350 350 auto& window = *(*it).value; 351 351 352 - auto icon_buffer = SharedBuffer::create_from_shared_buffer_id(message.icon_buffer_id()); 352 + auto icon_buffer = SharedBuffer::create_from_shbuf_id(message.icon_buffer_id()); 353 353 354 354 if (!icon_buffer) { 355 355 window.set_default_icon(); ··· 393 393 394 394 OwnPtr<Messages::WindowServer::SetClipboardContentsResponse> ClientConnection::handle(const Messages::WindowServer::SetClipboardContents& message) 395 395 { 396 - auto shared_buffer = SharedBuffer::create_from_shared_buffer_id(message.shared_buffer_id()); 396 + auto shared_buffer = SharedBuffer::create_from_shbuf_id(message.shbuf_id()); 397 397 if (!shared_buffer) { 398 398 did_misbehave("SetClipboardContents: Bad shared buffer ID"); 399 399 return nullptr; ··· 406 406 { 407 407 auto& clipboard = Clipboard::the(); 408 408 409 - i32 shared_buffer_id = -1; 409 + i32 shbuf_id = -1; 410 410 if (clipboard.size()) { 411 411 // FIXME: Optimize case where an app is copy/pasting within itself. 412 412 // We can just reuse the SharedBuffer then, since it will have the same peer PID. ··· 416 416 memcpy(shared_buffer->data(), clipboard.data(), clipboard.size()); 417 417 shared_buffer->seal(); 418 418 shared_buffer->share_with(client_pid()); 419 - shared_buffer_id = shared_buffer->shared_buffer_id(); 419 + shbuf_id = shared_buffer->shbuf_id(); 420 420 421 421 // FIXME: This is a workaround for the fact that SharedBuffers will go away if neither side is retaining them. 422 422 // After we respond to GetClipboardContents, we have to wait for the client to ref the buffer on his side. 423 423 m_last_sent_clipboard_content = move(shared_buffer); 424 424 } 425 - return make<Messages::WindowServer::GetClipboardContentsResponse>(shared_buffer_id, clipboard.size(), clipboard.data_type()); 425 + return make<Messages::WindowServer::GetClipboardContentsResponse>(shbuf_id, clipboard.size(), clipboard.data_type()); 426 426 } 427 427 428 428 OwnPtr<Messages::WindowServer::CreateWindowResponse> ClientConnection::handle(const Messages::WindowServer::CreateWindow& message) ··· 509 509 return nullptr; 510 510 } 511 511 auto& window = *(*it).value; 512 - if (window.last_backing_store() && window.last_backing_store()->shared_buffer_id() == message.shared_buffer_id()) { 512 + if (window.last_backing_store() && window.last_backing_store()->shbuf_id() == message.shbuf_id()) { 513 513 window.swap_backing_stores(); 514 514 } else { 515 - auto shared_buffer = SharedBuffer::create_from_shared_buffer_id(message.shared_buffer_id()); 515 + auto shared_buffer = SharedBuffer::create_from_shbuf_id(message.shbuf_id()); 516 516 if (!shared_buffer) 517 517 return make<Messages::WindowServer::SetWindowBackingStoreResponse>(); 518 518 auto backing_store = Gfx::Bitmap::create_with_shared_buffer( ··· 669 669 670 670 RefPtr<Gfx::Bitmap> bitmap; 671 671 if (message.bitmap_id() != -1) { 672 - auto shared_buffer = SharedBuffer::create_from_shared_buffer_id(message.bitmap_id()); 672 + auto shared_buffer = SharedBuffer::create_from_shbuf_id(message.bitmap_id()); 673 673 ssize_t size_in_bytes = message.bitmap_size().area() * sizeof(Gfx::RGBA32); 674 674 if (size_in_bytes > shared_buffer->size()) { 675 675 did_misbehave("SetAppletBackingStore: Shared buffer is too small for applet size");
+4 -4
Servers/WindowServer/WindowManager.cpp
··· 252 252 return; 253 253 if (window.is_internal()) 254 254 return; 255 - if (window.icon().shared_buffer_id() == -1) 255 + if (window.icon().shbuf_id() == -1) 256 256 return; 257 - dbg() << "WindowServer: Sharing icon buffer " << window.icon().shared_buffer_id() << " with PID " << listener.client()->client_pid(); 258 - if (share_buffer_with(window.icon().shared_buffer_id(), listener.client()->client_pid()) < 0) { 257 + dbg() << "WindowServer: Sharing icon buffer " << window.icon().shbuf_id() << " with PID " << listener.client()->client_pid(); 258 + if (shbuf_allow_pid(window.icon().shbuf_id(), listener.client()->client_pid()) < 0) { 259 259 ASSERT_NOT_REACHED(); 260 260 } 261 - listener.client()->post_message(Messages::WindowClient::WM_WindowIconBitmapChanged(listener.window_id(), window.client_id(), window.window_id(), window.icon().shared_buffer_id(), window.icon().size())); 261 + listener.client()->post_message(Messages::WindowClient::WM_WindowIconBitmapChanged(listener.window_id(), window.client_id(), window.window_id(), window.icon().shbuf_id(), window.icon().size())); 262 262 } 263 263 264 264 void WindowManager::tell_wm_listeners_window_state_changed(Window& window)
+3 -3
Servers/WindowServer/WindowServer.ipc
··· 57 57 SetGlobalCursorTracking(i32 window_id, bool enabled) => () 58 58 SetWindowOpacity(i32 window_id, float opacity) => () 59 59 60 - SetWindowBackingStore(i32 window_id, i32 bpp, i32 pitch, i32 shared_buffer_id, bool has_alpha_channel, Gfx::Size size, bool flush_immediately) => () 61 - GetClipboardContents() => (i32 shared_buffer_id, i32 content_size, String content_type) 62 - SetClipboardContents(i32 shared_buffer_id, i32 content_size, String content_type) => () 60 + SetWindowBackingStore(i32 window_id, i32 bpp, i32 pitch, i32 shbuf_id, bool has_alpha_channel, Gfx::Size size, bool flush_immediately) => () 61 + GetClipboardContents() => (i32 shbuf_id, i32 content_size, String content_type) 62 + SetClipboardContents(i32 shbuf_id, i32 content_size, String content_type) => () 63 63 64 64 WM_SetActiveWindow(i32 client_id, i32 window_id) =| 65 65 WM_SetWindowMinimized(i32 client_id, i32 window_id, bool minimized) =|