1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:18:11 +00:00

AK: Move the userspace SharedBuffer from LibC to AK

This always felt out-of-place in LibC.
This commit is contained in:
Andreas Kling 2020-01-01 18:53:34 +01:00
parent 38f93ef13b
commit fc86460134
22 changed files with 41 additions and 24 deletions

View file

@ -1,9 +1,11 @@
#include <AK/SharedBuffer.h>
#include <AK/kmalloc.h> #include <AK/kmalloc.h>
#include <Kernel/Syscall.h> #include <Kernel/Syscall.h>
#include <SharedBuffer.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
namespace AK {
RefPtr<SharedBuffer> SharedBuffer::create_with_size(int size) RefPtr<SharedBuffer> SharedBuffer::create_with_size(int size)
{ {
void* data; void* data;
@ -35,7 +37,6 @@ bool SharedBuffer::share_globally()
return true; return true;
} }
RefPtr<SharedBuffer> SharedBuffer::create_from_shared_buffer_id(int shared_buffer_id) RefPtr<SharedBuffer> SharedBuffer::create_from_shared_buffer_id(int shared_buffer_id)
{ {
void* data = get_shared_buffer(shared_buffer_id); void* data = get_shared_buffer(shared_buffer_id);
@ -92,3 +93,5 @@ bool SharedBuffer::set_nonvolatile()
return false; return false;
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
} }
}

View file

@ -3,6 +3,8 @@
#include <AK/RefCounted.h> #include <AK/RefCounted.h>
#include <AK/RefPtr.h> #include <AK/RefPtr.h>
namespace AK {
class SharedBuffer : public RefCounted<SharedBuffer> { class SharedBuffer : public RefCounted<SharedBuffer> {
public: public:
static RefPtr<SharedBuffer> create_with_size(int); static RefPtr<SharedBuffer> create_with_size(int);
@ -26,3 +28,7 @@ private:
int m_size { 0 }; int m_size { 0 };
void* m_data; void* m_data;
}; };
}
using AK::SharedBuffer;

View file

@ -3,7 +3,7 @@
#include <AK/JsonArray.h> #include <AK/JsonArray.h>
#include <AK/JsonObject.h> #include <AK/JsonObject.h>
#include <AK/JsonValue.h> #include <AK/JsonValue.h>
#include <LibC/SharedBuffer.h> #include <AK/SharedBuffer.h>
#include <LibCore/CProcessStatisticsReader.h> #include <LibCore/CProcessStatisticsReader.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>

View file

@ -1,6 +1,6 @@
#include "TaskbarWindow.h" #include "TaskbarWindow.h"
#include "TaskbarButton.h" #include "TaskbarButton.h"
#include <LibC/SharedBuffer.h> #include <AK/SharedBuffer.h>
#include <LibCore/CConfigFile.h> #include <LibCore/CConfigFile.h>
#include <LibGUI/GBoxLayout.h> #include <LibGUI/GBoxLayout.h>
#include <LibGUI/GButton.h> #include <LibGUI/GButton.h>

View file

@ -3,7 +3,7 @@
#include <AK/ByteBuffer.h> #include <AK/ByteBuffer.h>
#include <AK/Types.h> #include <AK/Types.h>
#include <AK/Vector.h> #include <AK/Vector.h>
#include <LibC/SharedBuffer.h> #include <AK/SharedBuffer.h>
// A single sample in an audio buffer. // A single sample in an audio buffer.
// Values are floating point, and should range from -1.0 to +1.0 // Values are floating point, and should range from -1.0 to +1.0

View file

@ -1,6 +1,6 @@
#include <AK/SharedBuffer.h>
#include <LibAudio/ABuffer.h> #include <LibAudio/ABuffer.h>
#include <LibAudio/AClientConnection.h> #include <LibAudio/AClientConnection.h>
#include <SharedBuffer.h>
AClientConnection::AClientConnection() AClientConnection::AClientConnection()
: IServerConnection(*this, "/tmp/portal/audio") : IServerConnection(*this, "/tmp/portal/audio")

View file

@ -9,10 +9,10 @@ AK_OBJS = \
../../AK/JsonParser.o \ ../../AK/JsonParser.o \
../../AK/LogStream.o \ ../../AK/LogStream.o \
../../AK/MappedFile.o \ ../../AK/MappedFile.o \
../../AK/SharedBuffer.o \
../../AK/Utf8View.o ../../AK/Utf8View.o
LIBC_OBJS = \ LIBC_OBJS = \
SharedBuffer.o \
stdio.o \ stdio.o \
unistd.o \ unistd.o \
string.o \ string.o \

View file

@ -6,9 +6,9 @@
#include <AK/MappedFile.h> #include <AK/MappedFile.h>
#include <AK/RefCounted.h> #include <AK/RefCounted.h>
#include <AK/RefPtr.h> #include <AK/RefPtr.h>
#include <AK/SharedBuffer.h>
#include <AK/String.h> #include <AK/String.h>
#include <AK/StringView.h> #include <AK/StringView.h>
#include <SharedBuffer.h>
class GraphicsBitmap : public RefCounted<GraphicsBitmap> { class GraphicsBitmap : public RefCounted<GraphicsBitmap> {
public: public:
@ -105,7 +105,8 @@ public:
[[nodiscard]] bool set_nonvolatile(); [[nodiscard]] bool set_nonvolatile();
private: private:
enum class Purgeable { No, Yes }; enum class Purgeable { No,
Yes };
GraphicsBitmap(Format, const Size&, Purgeable); GraphicsBitmap(Format, const Size&, Purgeable);
GraphicsBitmap(Format, const Size&, size_t pitch, RGBA32*); GraphicsBitmap(Format, const Size&, size_t pitch, RGBA32*);
GraphicsBitmap(Format, const Size&, MappedFile&&); GraphicsBitmap(Format, const Size&, MappedFile&&);

View file

@ -1,8 +1,8 @@
#pragma once #pragma once
#include <AK/SharedBuffer.h>
#include <AK/Types.h> #include <AK/Types.h>
#include <LibDraw/Color.h> #include <LibDraw/Color.h>
#include <SharedBuffer.h>
enum class ColorRole { enum class ColorRole {
NoRole, NoRole,

View file

@ -6,6 +6,10 @@
#include <LibDraw/Palette.h> #include <LibDraw/Palette.h>
#include <LibGUI/GShortcut.h> #include <LibGUI/GShortcut.h>
namespace AK {
class SharedBuffer;
}
class CEventLoop; class CEventLoop;
class GAction; class GAction;
class GKeyEvent; class GKeyEvent;
@ -14,7 +18,6 @@ class GWindow;
class GWindowServerConnection; class GWindowServerConnection;
class Palette; class Palette;
class Point; class Point;
class SharedBuffer;
class GApplication { class GApplication {
public: public:

View file

@ -1,4 +1,4 @@
#include <LibC/SharedBuffer.h> #include <AK/SharedBuffer.h>
#include <LibGUI/GClipboard.h> #include <LibGUI/GClipboard.h>
#include <LibGUI/GWindowServerConnection.h> #include <LibGUI/GWindowServerConnection.h>

View file

@ -1,7 +1,7 @@
#include <AK/HashMap.h> #include <AK/HashMap.h>
#include <AK/JsonObject.h> #include <AK/JsonObject.h>
#include <AK/NeverDestroyed.h> #include <AK/NeverDestroyed.h>
#include <LibC/SharedBuffer.h> #include <AK/SharedBuffer.h>
#include <LibC/stdio.h> #include <LibC/stdio.h>
#include <LibC/stdlib.h> #include <LibC/stdlib.h>
#include <LibC/unistd.h> #include <LibC/unistd.h>

View file

@ -1,4 +1,4 @@
#include <LibC/SharedBuffer.h> #include <AK/SharedBuffer.h>
#include <LibCore/CFile.h> #include <LibCore/CFile.h>
#include <LibHTML/ResourceLoader.h> #include <LibHTML/ResourceLoader.h>
#include <LibProtocol/Client.h> #include <LibProtocol/Client.h>

View file

@ -1,6 +1,6 @@
#include <AK/SharedBuffer.h>
#include <LibProtocol/Client.h> #include <LibProtocol/Client.h>
#include <LibProtocol/Download.h> #include <LibProtocol/Download.h>
#include <SharedBuffer.h>
namespace LibProtocol { namespace LibProtocol {

View file

@ -1,4 +1,4 @@
#include <LibC/SharedBuffer.h> #include <AK/SharedBuffer.h>
#include <LibProtocol/Client.h> #include <LibProtocol/Client.h>
#include <LibProtocol/Download.h> #include <LibProtocol/Download.h>

View file

@ -6,7 +6,9 @@
#include <AK/RefCounted.h> #include <AK/RefCounted.h>
#include <AK/WeakPtr.h> #include <AK/WeakPtr.h>
namespace AK {
class SharedBuffer; class SharedBuffer;
}
namespace LibProtocol { namespace LibProtocol {

View file

@ -1,9 +1,9 @@
#include "ASClientConnection.h" #include "ASClientConnection.h"
#include "ASMixer.h" #include "ASMixer.h"
#include "AudioClientEndpoint.h" #include "AudioClientEndpoint.h"
#include <AK/SharedBuffer.h>
#include <LibAudio/ABuffer.h> #include <LibAudio/ABuffer.h>
#include <LibCore/CEventLoop.h> #include <LibCore/CEventLoop.h>
#include <SharedBuffer.h>
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <sys/socket.h> #include <sys/socket.h>

View file

@ -2,7 +2,7 @@
#include <ProtocolServer/PSClientConnection.h> #include <ProtocolServer/PSClientConnection.h>
#include <ProtocolServer/Protocol.h> #include <ProtocolServer/Protocol.h>
#include <ProtocolServer/ProtocolClientEndpoint.h> #include <ProtocolServer/ProtocolClientEndpoint.h>
#include <LibC/SharedBuffer.h> #include <AK/SharedBuffer.h>
static HashMap<int, RefPtr<PSClientConnection>> s_connections; static HashMap<int, RefPtr<PSClientConnection>> s_connections;

View file

@ -4,8 +4,11 @@
#include <LibIPC/IClientConnection.h> #include <LibIPC/IClientConnection.h>
#include <ProtocolServer/ProtocolServerEndpoint.h> #include <ProtocolServer/ProtocolServerEndpoint.h>
class Download; namespace AK {
class SharedBuffer; class SharedBuffer;
}
class Download;
class PSClientConnection final : public IClientConnection<ProtocolServerEndpoint> class PSClientConnection final : public IClientConnection<ProtocolServerEndpoint>
, public ProtocolServerEndpoint { , public ProtocolServerEndpoint {
@ -26,5 +29,5 @@ private:
virtual OwnPtr<ProtocolServer::StopDownloadResponse> handle(const ProtocolServer::StopDownload&) override; virtual OwnPtr<ProtocolServer::StopDownloadResponse> handle(const ProtocolServer::StopDownload&) override;
virtual OwnPtr<ProtocolServer::DisownSharedBufferResponse> handle(const ProtocolServer::DisownSharedBuffer&) 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;
}; };

View file

@ -1,7 +1,6 @@
#include <LibC/SharedBuffer.h> #include <AK/SharedBuffer.h>
#include <LibDraw/GraphicsBitmap.h> #include <LibDraw/GraphicsBitmap.h>
#include <LibDraw/SystemTheme.h> #include <LibDraw/SystemTheme.h>
#include <SharedBuffer.h>
#include <WindowServer/WSClientConnection.h> #include <WindowServer/WSClientConnection.h>
#include <WindowServer/WSClipboard.h> #include <WindowServer/WSClipboard.h>
#include <WindowServer/WSCompositor.h> #include <WindowServer/WSCompositor.h>

View file

@ -1,8 +1,8 @@
#pragma once #pragma once
#include <AK/Function.h> #include <AK/Function.h>
#include <AK/SharedBuffer.h>
#include <AK/String.h> #include <AK/String.h>
#include <SharedBuffer.h>
class WSClipboard { class WSClipboard {
public: public:

View file

@ -1,5 +1,5 @@
#include <AK/URL.h> #include <AK/URL.h>
#include <LibC/SharedBuffer.h> #include <AK/SharedBuffer.h>
#include <LibCore/CEventLoop.h> #include <LibCore/CEventLoop.h>
#include <LibProtocol/Client.h> #include <LibProtocol/Client.h>
#include <LibProtocol/Download.h> #include <LibProtocol/Download.h>