summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2020-01-01 18:53:34 +0100
committerAndreas Kling <awesomekling@gmail.com>2020-01-01 18:53:34 +0100
commitfc864601348ee89e57d024c24d423499b496b5ab (patch)
tree549df970d6cc70438e8bf06b68c1c3765b27fa98
parent38f93ef13b6a2c111c4c99de5c21ccc2d7b90fda (diff)
downloadserenity-fc864601348ee89e57d024c24d423499b496b5ab.zip
AK: Move the userspace SharedBuffer from LibC to AK
This always felt out-of-place in LibC.
-rw-r--r--AK/SharedBuffer.cpp (renamed from Libraries/LibC/SharedBuffer.cpp)7
-rw-r--r--AK/SharedBuffer.h (renamed from Libraries/LibC/SharedBuffer.h)6
-rw-r--r--Applications/SystemMonitor/ProcessModel.cpp2
-rw-r--r--Applications/Taskbar/TaskbarWindow.cpp2
-rw-r--r--Libraries/LibAudio/ABuffer.h2
-rw-r--r--Libraries/LibAudio/AClientConnection.cpp2
-rw-r--r--Libraries/LibC/Makefile2
-rw-r--r--Libraries/LibDraw/GraphicsBitmap.h5
-rw-r--r--Libraries/LibDraw/SystemTheme.h2
-rw-r--r--Libraries/LibGUI/GApplication.h5
-rw-r--r--Libraries/LibGUI/GClipboard.cpp2
-rw-r--r--Libraries/LibGUI/GWindow.cpp2
-rw-r--r--Libraries/LibHTML/ResourceLoader.cpp2
-rw-r--r--Libraries/LibProtocol/Client.cpp2
-rw-r--r--Libraries/LibProtocol/Download.cpp2
-rw-r--r--Libraries/LibProtocol/Download.h2
-rw-r--r--Servers/AudioServer/ASClientConnection.cpp2
-rw-r--r--Servers/ProtocolServer/PSClientConnection.cpp2
-rw-r--r--Servers/ProtocolServer/PSClientConnection.h7
-rw-r--r--Servers/WindowServer/WSClientConnection.cpp3
-rw-r--r--Servers/WindowServer/WSClipboard.h2
-rw-r--r--Userland/pro.cpp2
22 files changed, 41 insertions, 24 deletions
diff --git a/Libraries/LibC/SharedBuffer.cpp b/AK/SharedBuffer.cpp
index 86c50edd05..650b571e45 100644
--- a/Libraries/LibC/SharedBuffer.cpp
+++ b/AK/SharedBuffer.cpp
@@ -1,9 +1,11 @@
+#include <AK/SharedBuffer.h>
#include <AK/kmalloc.h>
#include <Kernel/Syscall.h>
-#include <SharedBuffer.h>
#include <stdio.h>
#include <unistd.h>
+namespace AK {
+
RefPtr<SharedBuffer> SharedBuffer::create_with_size(int size)
{
void* data;
@@ -35,7 +37,6 @@ bool SharedBuffer::share_globally()
return true;
}
-
RefPtr<SharedBuffer> SharedBuffer::create_from_shared_buffer_id(int shared_buffer_id)
{
void* data = get_shared_buffer(shared_buffer_id);
@@ -92,3 +93,5 @@ bool SharedBuffer::set_nonvolatile()
return false;
ASSERT_NOT_REACHED();
}
+
+}
diff --git a/Libraries/LibC/SharedBuffer.h b/AK/SharedBuffer.h
index 75b3a2a158..096f2e4e6a 100644
--- a/Libraries/LibC/SharedBuffer.h
+++ b/AK/SharedBuffer.h
@@ -3,6 +3,8 @@
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
+namespace AK {
+
class SharedBuffer : public RefCounted<SharedBuffer> {
public:
static RefPtr<SharedBuffer> create_with_size(int);
@@ -26,3 +28,7 @@ private:
int m_size { 0 };
void* m_data;
};
+
+}
+
+using AK::SharedBuffer;
diff --git a/Applications/SystemMonitor/ProcessModel.cpp b/Applications/SystemMonitor/ProcessModel.cpp
index f9190d442a..93ea6a006c 100644
--- a/Applications/SystemMonitor/ProcessModel.cpp
+++ b/Applications/SystemMonitor/ProcessModel.cpp
@@ -3,7 +3,7 @@
#include <AK/JsonArray.h>
#include <AK/JsonObject.h>
#include <AK/JsonValue.h>
-#include <LibC/SharedBuffer.h>
+#include <AK/SharedBuffer.h>
#include <LibCore/CProcessStatisticsReader.h>
#include <fcntl.h>
#include <stdio.h>
diff --git a/Applications/Taskbar/TaskbarWindow.cpp b/Applications/Taskbar/TaskbarWindow.cpp
index 6aba1a0a61..857d0b43a3 100644
--- a/Applications/Taskbar/TaskbarWindow.cpp
+++ b/Applications/Taskbar/TaskbarWindow.cpp
@@ -1,6 +1,6 @@
#include "TaskbarWindow.h"
#include "TaskbarButton.h"
-#include <LibC/SharedBuffer.h>
+#include <AK/SharedBuffer.h>
#include <LibCore/CConfigFile.h>
#include <LibGUI/GBoxLayout.h>
#include <LibGUI/GButton.h>
diff --git a/Libraries/LibAudio/ABuffer.h b/Libraries/LibAudio/ABuffer.h
index 237ec2b209..6a387d6650 100644
--- a/Libraries/LibAudio/ABuffer.h
+++ b/Libraries/LibAudio/ABuffer.h
@@ -3,7 +3,7 @@
#include <AK/ByteBuffer.h>
#include <AK/Types.h>
#include <AK/Vector.h>
-#include <LibC/SharedBuffer.h>
+#include <AK/SharedBuffer.h>
// A single sample in an audio buffer.
// Values are floating point, and should range from -1.0 to +1.0
diff --git a/Libraries/LibAudio/AClientConnection.cpp b/Libraries/LibAudio/AClientConnection.cpp
index b0283680e7..42d1764fe0 100644
--- a/Libraries/LibAudio/AClientConnection.cpp
+++ b/Libraries/LibAudio/AClientConnection.cpp
@@ -1,6 +1,6 @@
+#include <AK/SharedBuffer.h>
#include <LibAudio/ABuffer.h>
#include <LibAudio/AClientConnection.h>
-#include <SharedBuffer.h>
AClientConnection::AClientConnection()
: IServerConnection(*this, "/tmp/portal/audio")
diff --git a/Libraries/LibC/Makefile b/Libraries/LibC/Makefile
index 2a79f519ac..cd9280ee8f 100644
--- a/Libraries/LibC/Makefile
+++ b/Libraries/LibC/Makefile
@@ -9,10 +9,10 @@ AK_OBJS = \
../../AK/JsonParser.o \
../../AK/LogStream.o \
../../AK/MappedFile.o \
+ ../../AK/SharedBuffer.o \
../../AK/Utf8View.o
LIBC_OBJS = \
- SharedBuffer.o \
stdio.o \
unistd.o \
string.o \
diff --git a/Libraries/LibDraw/GraphicsBitmap.h b/Libraries/LibDraw/GraphicsBitmap.h
index 42695ed887..db14644950 100644
--- a/Libraries/LibDraw/GraphicsBitmap.h
+++ b/Libraries/LibDraw/GraphicsBitmap.h
@@ -6,9 +6,9 @@
#include <AK/MappedFile.h>
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
+#include <AK/SharedBuffer.h>
#include <AK/String.h>
#include <AK/StringView.h>
-#include <SharedBuffer.h>
class GraphicsBitmap : public RefCounted<GraphicsBitmap> {
public:
@@ -105,7 +105,8 @@ public:
[[nodiscard]] bool set_nonvolatile();
private:
- enum class Purgeable { No, Yes };
+ enum class Purgeable { No,
+ Yes };
GraphicsBitmap(Format, const Size&, Purgeable);
GraphicsBitmap(Format, const Size&, size_t pitch, RGBA32*);
GraphicsBitmap(Format, const Size&, MappedFile&&);
diff --git a/Libraries/LibDraw/SystemTheme.h b/Libraries/LibDraw/SystemTheme.h
index b02b9ecc44..b075156a0f 100644
--- a/Libraries/LibDraw/SystemTheme.h
+++ b/Libraries/LibDraw/SystemTheme.h
@@ -1,8 +1,8 @@
#pragma once
+#include <AK/SharedBuffer.h>
#include <AK/Types.h>
#include <LibDraw/Color.h>
-#include <SharedBuffer.h>
enum class ColorRole {
NoRole,
diff --git a/Libraries/LibGUI/GApplication.h b/Libraries/LibGUI/GApplication.h
index 9194a32976..55c06ccda9 100644
--- a/Libraries/LibGUI/GApplication.h
+++ b/Libraries/LibGUI/GApplication.h
@@ -6,6 +6,10 @@
#include <LibDraw/Palette.h>
#include <LibGUI/GShortcut.h>
+namespace AK {
+class SharedBuffer;
+}
+
class CEventLoop;
class GAction;
class GKeyEvent;
@@ -14,7 +18,6 @@ class GWindow;
class GWindowServerConnection;
class Palette;
class Point;
-class SharedBuffer;
class GApplication {
public:
diff --git a/Libraries/LibGUI/GClipboard.cpp b/Libraries/LibGUI/GClipboard.cpp
index 3f4117633e..05e55ae62e 100644
--- a/Libraries/LibGUI/GClipboard.cpp
+++ b/Libraries/LibGUI/GClipboard.cpp
@@ -1,4 +1,4 @@
-#include <LibC/SharedBuffer.h>
+#include <AK/SharedBuffer.h>
#include <LibGUI/GClipboard.h>
#include <LibGUI/GWindowServerConnection.h>
diff --git a/Libraries/LibGUI/GWindow.cpp b/Libraries/LibGUI/GWindow.cpp
index bccc0c7f15..5d114ef312 100644
--- a/Libraries/LibGUI/GWindow.cpp
+++ b/Libraries/LibGUI/GWindow.cpp
@@ -1,7 +1,7 @@
#include <AK/HashMap.h>
#include <AK/JsonObject.h>
#include <AK/NeverDestroyed.h>
-#include <LibC/SharedBuffer.h>
+#include <AK/SharedBuffer.h>
#include <LibC/stdio.h>
#include <LibC/stdlib.h>
#include <LibC/unistd.h>
diff --git a/Libraries/LibHTML/ResourceLoader.cpp b/Libraries/LibHTML/ResourceLoader.cpp
index 2e0fcdbf60..778c7d140d 100644
--- a/Libraries/LibHTML/ResourceLoader.cpp
+++ b/Libraries/LibHTML/ResourceLoader.cpp
@@ -1,4 +1,4 @@
-#include <LibC/SharedBuffer.h>
+#include <AK/SharedBuffer.h>
#include <LibCore/CFile.h>
#include <LibHTML/ResourceLoader.h>
#include <LibProtocol/Client.h>
diff --git a/Libraries/LibProtocol/Client.cpp b/Libraries/LibProtocol/Client.cpp
index 9ec7928c03..fc2eedb0d4 100644
--- a/Libraries/LibProtocol/Client.cpp
+++ b/Libraries/LibProtocol/Client.cpp
@@ -1,6 +1,6 @@
+#include <AK/SharedBuffer.h>
#include <LibProtocol/Client.h>
#include <LibProtocol/Download.h>
-#include <SharedBuffer.h>
namespace LibProtocol {
diff --git a/Libraries/LibProtocol/Download.cpp b/Libraries/LibProtocol/Download.cpp
index 51b5712040..9f3c00a603 100644
--- a/Libraries/LibProtocol/Download.cpp
+++ b/Libraries/LibProtocol/Download.cpp
@@ -1,4 +1,4 @@
-#include <LibC/SharedBuffer.h>
+#include <AK/SharedBuffer.h>
#include <LibProtocol/Client.h>
#include <LibProtocol/Download.h>
diff --git a/Libraries/LibProtocol/Download.h b/Libraries/LibProtocol/Download.h
index 7cc5a7796d..a0531f7990 100644
--- a/Libraries/LibProtocol/Download.h
+++ b/Libraries/LibProtocol/Download.h
@@ -6,7 +6,9 @@
#include <AK/RefCounted.h>
#include <AK/WeakPtr.h>
+namespace AK {
class SharedBuffer;
+}
namespace LibProtocol {
diff --git a/Servers/AudioServer/ASClientConnection.cpp b/Servers/AudioServer/ASClientConnection.cpp
index caf64d6479..c12534c322 100644
--- a/Servers/AudioServer/ASClientConnection.cpp
+++ b/Servers/AudioServer/ASClientConnection.cpp
@@ -1,9 +1,9 @@
#include "ASClientConnection.h"
#include "ASMixer.h"
#include "AudioClientEndpoint.h"
+#include <AK/SharedBuffer.h>
#include <LibAudio/ABuffer.h>
#include <LibCore/CEventLoop.h>
-#include <SharedBuffer.h>
#include <errno.h>
#include <stdio.h>
#include <sys/socket.h>
diff --git a/Servers/ProtocolServer/PSClientConnection.cpp b/Servers/ProtocolServer/PSClientConnection.cpp
index 6fcea878a5..abe98d6282 100644
--- a/Servers/ProtocolServer/PSClientConnection.cpp
+++ b/Servers/ProtocolServer/PSClientConnection.cpp
@@ -2,7 +2,7 @@
#include <ProtocolServer/PSClientConnection.h>
#include <ProtocolServer/Protocol.h>
#include <ProtocolServer/ProtocolClientEndpoint.h>
-#include <LibC/SharedBuffer.h>
+#include <AK/SharedBuffer.h>
static HashMap<int, RefPtr<PSClientConnection>> s_connections;
diff --git a/Servers/ProtocolServer/PSClientConnection.h b/Servers/ProtocolServer/PSClientConnection.h
index 5797b7d460..d1cb11a8b4 100644
--- a/Servers/ProtocolServer/PSClientConnection.h
+++ b/Servers/ProtocolServer/PSClientConnection.h
@@ -4,8 +4,11 @@
#include <LibIPC/IClientConnection.h>
#include <ProtocolServer/ProtocolServerEndpoint.h>
-class Download;
+namespace AK {
class SharedBuffer;
+}
+
+class Download;
class PSClientConnection final : public IClientConnection<ProtocolServerEndpoint>
, public ProtocolServerEndpoint {
@@ -26,5 +29,5 @@ private:
virtual OwnPtr<ProtocolServer::StopDownloadResponse> handle(const ProtocolServer::StopDownload&) override;
virtual OwnPtr<ProtocolServer::DisownSharedBufferResponse> handle(const ProtocolServer::DisownSharedBuffer&) override;
- HashMap<i32, RefPtr<SharedBuffer>> m_shared_buffers;
+ HashMap<i32, RefPtr<AK::SharedBuffer>> m_shared_buffers;
};
diff --git a/Servers/WindowServer/WSClientConnection.cpp b/Servers/WindowServer/WSClientConnection.cpp
index c463956cff..78e6003174 100644
--- a/Servers/WindowServer/WSClientConnection.cpp
+++ b/Servers/WindowServer/WSClientConnection.cpp
@@ -1,7 +1,6 @@
-#include <LibC/SharedBuffer.h>
+#include <AK/SharedBuffer.h>
#include <LibDraw/GraphicsBitmap.h>
#include <LibDraw/SystemTheme.h>
-#include <SharedBuffer.h>
#include <WindowServer/WSClientConnection.h>
#include <WindowServer/WSClipboard.h>
#include <WindowServer/WSCompositor.h>
diff --git a/Servers/WindowServer/WSClipboard.h b/Servers/WindowServer/WSClipboard.h
index 0896c878a3..945b5a582c 100644
--- a/Servers/WindowServer/WSClipboard.h
+++ b/Servers/WindowServer/WSClipboard.h
@@ -1,8 +1,8 @@
#pragma once
#include <AK/Function.h>
+#include <AK/SharedBuffer.h>
#include <AK/String.h>
-#include <SharedBuffer.h>
class WSClipboard {
public:
diff --git a/Userland/pro.cpp b/Userland/pro.cpp
index 7209e60f7a..44f38fedf2 100644
--- a/Userland/pro.cpp
+++ b/Userland/pro.cpp
@@ -1,5 +1,5 @@
#include <AK/URL.h>
-#include <LibC/SharedBuffer.h>
+#include <AK/SharedBuffer.h>
#include <LibCore/CEventLoop.h>
#include <LibProtocol/Client.h>
#include <LibProtocol/Download.h>