Compare commits

..

6 Commits

Author SHA1 Message Date
7badcf80cf ports: Add libarchive port 2026-04-17 18:37:41 +03:00
7f122d9e89 ports: Add bzip2 port 2026-04-17 18:37:30 +03:00
984c7c0a89 LibGUI: Fix packet sending and cleanup receiving 2026-04-15 21:52:51 +03:00
ce318c7930 LibGUI: Cleanup packet {,de}serialization 2026-04-15 21:52:13 +03:00
eff6c79e9e ports/xbanan: Update to a working version
Also don't depend on mesa or Xlib. We only need the protocol headers to
compile the project
2026-04-15 19:25:54 +03:00
aaade52146 LibC: Use __builtin_thread_pointer for _get_uthread()
This generates much nicer assembly as it does not have to read thread
pointer for every access to TCB (errno, cancel_state, cancelled) and
instead it can read it once and use the same value for all accesses
2026-04-15 17:32:43 +03:00
6 changed files with 80 additions and 37 deletions

36
ports/bzip2/build.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/bin/bash ../install.sh
NAME='bzip2'
VERSION='1.0.8'
DOWNLOAD_URL="https://sourceware.org/pub/bzip2/bzip2-$VERSION.tar.gz#ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269"
configure() {
:
}
build() {
make -j$(nproc) -f Makefile-libbz2_so CC="$CC" || exit 1
}
install() {
cp -v libbz2.so.$VERSION $BANAN_SYSROOT/usr/lib/ || exit 1
ln -svf libbz2.so.$VERSION $BANAN_SYSROOT/usr/lib/libbz2.so || exit 1
ln -svf libbz2.so.$VERSION $BANAN_SYSROOT/usr/lib/libbz2.so.1 || exit 1
ln -svf libbz2.so.$VERSION $BANAN_SYSROOT/usr/lib/libbz2.so.1.0 || exit 1
cp -v bzlib.h $BANAN_SYSROOT/usr/include/ || exit 1
cat > $BANAN_SYSROOT/usr/lib/pkgconfig/bzip2.pc << EOF
prefix=/usr
exec_prefix=\${prefix}
bindir=\${exec_prefix}/bin
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include
Name: bzip2
Description: A file compression library
Version: $VERSION
Libs: -L\${libdir} -lbz2
Cflags: -I\${includedir}
EOF
}

23
ports/libarchive/build.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash ../install.sh
NAME='libarchive'
VERSION='3.8.6'
DOWNLOAD_URL="https://github.com/libarchive/libarchive/releases/download/v$VERSION/libarchive-$VERSION.tar.xz#8ac57c1f5e99550948d1fe755c806d26026e71827da228f36bef24527e372e6f"
DEPENDENCIES=('zlib' 'zstd' 'bzip2' 'xz')
configure() {
cmake --fresh -B build -S . -G Ninja \
--toolchain="$BANAN_TOOLCHAIN_DIR/Toolchain.txt" \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_TEST=OFF \
|| exit 1
}
build() {
cmake --build build || exit 1
}
install() {
cmake --install build || exit 1
}

View File

@@ -2,8 +2,8 @@
NAME='xbanan'
VERSION='git'
DOWNLOAD_URL="https://git.bananymous.com/Bananymous/xbanan.git#b228ef13c41adff2738acaeda5db804ebf493bfd"
DEPENDENCIES=('mesa' 'libX11' 'xorgproto')
DOWNLOAD_URL="https://git.bananymous.com/Bananymous/xbanan.git#b2c642f03d2e498e9d6acd55cc89a5e76c220811"
DEPENDENCIES=('xorgproto')
configure() {
cmake --fresh -B build -S . -G Ninja \

View File

@@ -48,19 +48,7 @@ struct uthread
uintptr_t dtv[1 + 256];
};
#if defined(__x86_64__)
#define _get_uthread() ({ \
struct uthread* _uthread; \
__asm__ volatile("movq %%fs:0, %0" : "=r"(_uthread)); \
_uthread; \
})
#elif defined(__i686__)
#define _get_uthread() ({ \
struct uthread* _uthread; \
__asm__ volatile("movl %%gs:0, %0" : "=r"(_uthread)); \
_uthread; \
})
#endif
#define _get_uthread() ((struct uthread*)__builtin_thread_pointer())
__END_DECLS

View File

@@ -96,12 +96,12 @@ namespace LibGUI
return on_socket_error(function);
}
packet.serialize(m_in_buffer.span());
packet.serialize(m_out_buffer.span());
size_t total_sent = 0;
while (total_sent < serialized_size)
{
const ssize_t nsend = send(m_server_fd, m_in_buffer.data() + total_sent, serialized_size - total_sent, 0);
const ssize_t nsend = send(m_server_fd, m_out_buffer.data() + total_sent, serialized_size - total_sent, 0);
if (nsend < 0)
dwarnln("send: {}", strerror(errno));
if (nsend <= 0)
@@ -327,15 +327,14 @@ namespace LibGUI
m_in_buffer_size += nrecv;
}
size_t bytes_handled = 0;
while (m_in_buffer_size - bytes_handled >= sizeof(PacketHeader))
BAN::ConstByteSpan in_span = m_in_buffer.span().slice(0, m_in_buffer_size);
while (in_span.size() >= sizeof(PacketHeader))
{
BAN::ConstByteSpan packet_span = m_in_buffer.span().slice(bytes_handled);
const auto header = packet_span.as<const PacketHeader>();
if (packet_span.size() < header.size || header.size < sizeof(LibGUI::PacketHeader))
const auto header = in_span.as<const PacketHeader>();
if (in_span.size() < header.size || header.size < sizeof(LibGUI::PacketHeader))
break;
packet_span = packet_span.slice(0, header.size);
const auto packet_span = in_span.slice(0, header.size);
switch (header.type)
{
#define TRY_OR_BREAK(...) ({ auto&& e = (__VA_ARGS__); if (e.is_error()) break; e.release_value(); })
@@ -402,16 +401,16 @@ namespace LibGUI
break;
}
bytes_handled += header.size;
in_span = in_span.slice(header.size);
}
// NOTE: this will only move a single partial packet, so this is fine
m_in_buffer_size -= bytes_handled;
memmove(
m_in_buffer.data(),
m_in_buffer.data() + bytes_handled,
m_in_buffer_size
in_span.data(),
in_span.size()
);
m_in_buffer_size = in_span.size();
if (m_in_buffer_size >= sizeof(LibGUI::PacketHeader))
{

View File

@@ -35,9 +35,6 @@
#define DEFINE_PACKET_EXTRA(name, extra, ...) \
struct name \
{ \
static constexpr PacketType type = PacketType::name; \
static constexpr uint32_t type_u32 = static_cast<uint32_t>(type); \
\
extra; \
\
FOR_EACH(FIELD_DECL, __VA_ARGS__) \
@@ -45,8 +42,7 @@
size_t serialized_size() const \
{ \
size_t serialized_size = 0; \
serialized_size += Serialize::serialized_size_impl<uint32_t>(0); \
serialized_size += Serialize::serialized_size_impl<uint32_t>(type_u32); \
serialized_size += Serialize::serialized_size_impl(PacketHeader {}); \
FOR_EACH(ADD_SERIALIZED_SIZE, __VA_ARGS__) \
return serialized_size; \
} \
@@ -54,16 +50,17 @@
void serialize(BAN::ByteSpan buffer) const \
{ \
const uint32_t serialized_size = this->serialized_size(); \
Serialize::serialize_impl<uint32_t>(buffer, serialized_size); \
Serialize::serialize_impl<uint32_t>(buffer, type_u32); \
Serialize::serialize_impl(buffer, PacketHeader { \
.size = serialized_size, \
.type = PacketType::name, \
}); \
FOR_EACH(SERIALIZE, __VA_ARGS__); \
} \
\
static BAN::ErrorOr<name> deserialize(BAN::ConstByteSpan buffer) \
{ \
const uint32_t size_u32 = TRY(Serialize::deserialize_impl<uint32_t>(buffer)); \
const uint32_t type_u32 = TRY(Serialize::deserialize_impl<uint32_t>(buffer)); \
if (type_u32 != name::type_u32 || size_u32 != buffer.size() + 2 * sizeof(uint32_t)) \
const auto header = TRY(Serialize::deserialize_impl<PacketHeader>(buffer)); \
if (header.type != PacketType::name || header.size != buffer.size() + sizeof(PacketHeader)) \
return BAN::Error::from_errno(EINVAL); \
name value; \
FOR_EACH(DESERIALIZE, __VA_ARGS__) \