Compare commits

..

No commits in common. "0f377e728908c1536f8524d0c855feabea4ef5bc" and "3f1e6fc2ff8e699145c21737c488c068200f39be" have entirely different histories.

3 changed files with 4 additions and 68 deletions

View File

@ -24,16 +24,13 @@ Result<void> check_pledge(Thread* thread, Promise promise)
// Thread::process_pending_signals(). // Thread::process_pending_signals().
thread->signal_handlers[SIGABRT - 1].sa_handler = SIG_DFL; thread->signal_handlers[SIGABRT - 1].sa_handler = SIG_DFL;
// Unblock SIGABRT.
thread->signal_mask.set(SIGABRT - 1, false);
// If there are any other pending signals, they might be processed before SIGABRT. Avoid that by resetting the // If there are any other pending signals, they might be processed before SIGABRT. Avoid that by resetting the
// thread's pending signals. // thread's pending signals.
thread->pending_signals.clear(); thread->pending_signals = 0;
thread->send_signal(SIGABRT); thread->send_signal(SIGABRT);
// This should never arrive to userspace, unless we're init and have ignored SIGABRT. // This should never arrive to userspace.
return err(ENOSYS); return err(ENOSYS);
} }

View File

@ -1,66 +1,27 @@
/**
* @file Bitset.h
* @author apio (cloudapio.eu)
* @brief A wrapper class to modify/inspect specific bits of an integer type.
*
* @copyright Copyright (c) 2023, the Luna authors.
*
*/
#pragma once #pragma once
#include <luna/Check.h> #include <luna/Check.h>
/**
* @brief A wrapper class to modify/inspect specific bits of an integer type, to avoid manual error-prone bit shifting.
*
* @tparam T The integer type to use.
*/
template <typename T> class Bitset template <typename T> class Bitset
{ {
public: public:
/** Bitset() : m_value()
* @brief Construct a new empty Bitset object.
*/
Bitset() : m_value(0)
{ {
} }
/**
* @brief Construct a new Bitset object with a value.
*
* @param value The value to use.
*/
Bitset(T value) : m_value(value) Bitset(T value) : m_value(value)
{ {
} }
/**
* @brief Construct a copy of another Bitset object.
*
* @param other The original object.
*/
Bitset(const Bitset<T>& other) : m_value(other.m_value) Bitset(const Bitset<T>& other) : m_value(other.m_value)
{ {
} }
/**
* @brief Update the internal value of this bitset.
*
* @param value The new value.
* @return Bitset<T>& A reference to this itset.
*/
Bitset<T>& operator=(T value) Bitset<T>& operator=(T value)
{ {
m_value = value; m_value = value;
return *this; return *this;
} }
/**
* @brief Set this bitset to the same value as another bitset.
*
* @param other The pther bitset.
* @return Bitset<T>& A reference to this bitset.
*/
Bitset<T>& operator=(const Bitset<T>& other) Bitset<T>& operator=(const Bitset<T>& other)
{ {
if (&other == this) return *this; if (&other == this) return *this;
@ -68,23 +29,11 @@ template <typename T> class Bitset
return *this; return *this;
} }
/**
* @brief Return the value contained in this bitset.
*
* @return T The contained value.
*/
T value() const T value() const
{ {
return m_value; return m_value;
} }
/**
* @brief Modify one of the individual bits in this bitset.
*
* @param index The index of the bit (this will set/unset 1 << index). It must be less than the bit width of the
* underlying type.
* @param b The value to set the bit to.
*/
void set(int index, bool b) void set(int index, bool b)
{ {
check((usize)index < (sizeof(T) * 8)); check((usize)index < (sizeof(T) * 8));
@ -93,22 +42,12 @@ template <typename T> class Bitset
m_value &= ~(((T)1) << index); m_value &= ~(((T)1) << index);
} }
/**
* @brief Get the value of one of the individual bits in this bitset.
*
* @param index The index of the bit (this will read 1 << index). It must be less than the bit width of the
* underlying type.
* @return bool The value of the requested bit.
*/
bool get(int index) bool get(int index)
{ {
check((usize)index < (sizeof(T) * 8)); check((usize)index < (sizeof(T) * 8));
return m_value & (((T)1) << index); return m_value & (((T)1) << index);
} }
/**
* @brief Clear all the bits in this bitset.
*/
void clear() void clear()
{ {
m_value = 0; m_value = 0;

View File

@ -161,6 +161,6 @@ namespace Base64
u8 nul_byte = '\0'; u8 nul_byte = '\0';
TRY(buf.append_data(&nul_byte, 1)); TRY(buf.append_data(&nul_byte, 1));
return String { (char*)buf.release_data(), buf.size() - 1 }; return String { (char*)buf.release_data(), buf.size() };
} }
} }