mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 12:27:36 +00:00
Use modern C++ attributes instead of __attribute__ voodoo.
This is quite nice, although I wish [[gnu::always_inline]] implied inline. Also "gnu::" is kind of a wart, but whatcha gonna do.
This commit is contained in:
parent
fbcc8ab840
commit
022f7790db
34 changed files with 99 additions and 124 deletions
|
@ -1,11 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#define PACKED __attribute__ ((packed))
|
||||
#define NORETURN __attribute__ ((noreturn))
|
||||
#define FLATTEN __attribute__ ((flatten))
|
||||
#undef ALWAYS_INLINE
|
||||
#define ALWAYS_INLINE inline __attribute__ ((always_inline))
|
||||
#define NEVER_INLINE __attribute__ ((noinline))
|
||||
#define MALLOC_ATTR __attribute__ ((malloc))
|
||||
#define PURE __attribute__ ((pure))
|
||||
#define WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
|
|
@ -44,10 +44,10 @@ private:
|
|||
|
||||
class Locker {
|
||||
public:
|
||||
ALWAYS_INLINE explicit Locker(Lock& l) : m_lock(l) { lock(); }
|
||||
ALWAYS_INLINE ~Locker() { unlock(); }
|
||||
ALWAYS_INLINE void unlock() { m_lock.unlock(); }
|
||||
ALWAYS_INLINE void lock() { m_lock.lock(); }
|
||||
[[gnu::always_inline]] explicit Locker(Lock& l) : m_lock(l) { lock(); }
|
||||
[[gnu::always_inline]] ~Locker() { unlock(); }
|
||||
[[gnu::always_inline]] void unlock() { m_lock.unlock(); }
|
||||
[[gnu::always_inline]] void lock() { m_lock.lock(); }
|
||||
|
||||
private:
|
||||
Lock& m_lock;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include "Compiler.h"
|
||||
#include "Types.h"
|
||||
|
||||
namespace AK {
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
void* mmx_memcpy(void* to, const void* from, size_t);
|
||||
|
||||
ALWAYS_INLINE void fast_dword_copy(dword* dest, const dword* src, size_t count)
|
||||
[[gnu::always_inline]] inline void fast_dword_copy(dword* dest, const dword* src, size_t count)
|
||||
{
|
||||
if (count >= 256) {
|
||||
mmx_memcpy(dest, src, count * sizeof(count));
|
||||
|
@ -25,7 +25,7 @@ ALWAYS_INLINE void fast_dword_copy(dword* dest, const dword* src, size_t count)
|
|||
);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void fast_dword_fill(dword* dest, dword value, size_t count)
|
||||
[[gnu::always_inline]] inline void fast_dword_fill(dword* dest, dword value, size_t count)
|
||||
{
|
||||
asm volatile(
|
||||
"rep stosl\n"
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include "Compiler.h"
|
||||
|
||||
#if defined(SERENITY) && defined(KERNEL)
|
||||
#define AK_MAKE_ETERNAL \
|
||||
public: \
|
||||
|
@ -18,11 +16,10 @@ private:
|
|||
|
||||
extern "C" {
|
||||
|
||||
void* kcalloc(size_t nmemb, size_t size);
|
||||
void* kmalloc(size_t size) MALLOC_ATTR;
|
||||
[[gnu::malloc, gnu::returns_nonnull]] void* kmalloc(size_t size);
|
||||
[[gnu::malloc, gnu::returns_nonnull]] void* kmalloc_eternal(size_t);
|
||||
[[gnu::returns_nonnull]] void* krealloc(void* ptr, size_t size);
|
||||
void kfree(void* ptr);
|
||||
void* krealloc(void* ptr, size_t size);
|
||||
void* kmalloc_eternal(size_t) MALLOC_ATTR;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ typedef unsigned char byte;
|
|||
typedef unsigned short word;
|
||||
typedef unsigned int dword;
|
||||
|
||||
ALWAYS_INLINE size_t strlen(const char* str)
|
||||
[[gnu::always_inline]] inline size_t strlen(const char* str)
|
||||
{
|
||||
size_t len = 0;
|
||||
while (*(str++))
|
||||
|
@ -13,7 +13,7 @@ ALWAYS_INLINE size_t strlen(const char* str)
|
|||
static constexpr const char* h = "0123456789abcdef";
|
||||
|
||||
template<typename PutChFunc>
|
||||
ALWAYS_INLINE int print_hex(PutChFunc putch, char*& bufptr, dword number, byte fields)
|
||||
[[gnu::always_inline]] int print_hex(PutChFunc putch, char*& bufptr, dword number, byte fields)
|
||||
{
|
||||
int ret = 0;
|
||||
byte shr_count = fields * 4;
|
||||
|
@ -26,7 +26,7 @@ ALWAYS_INLINE int print_hex(PutChFunc putch, char*& bufptr, dword number, byte f
|
|||
}
|
||||
|
||||
template<typename PutChFunc>
|
||||
ALWAYS_INLINE int print_number(PutChFunc putch, char*& bufptr, dword number, bool leftPad, bool zeroPad, dword fieldWidth)
|
||||
[[gnu::always_inline]] int print_number(PutChFunc putch, char*& bufptr, dword number, bool leftPad, bool zeroPad, dword fieldWidth)
|
||||
{
|
||||
dword divisor = 1000000000;
|
||||
char ch;
|
||||
|
@ -67,7 +67,7 @@ ALWAYS_INLINE int print_number(PutChFunc putch, char*& bufptr, dword number, boo
|
|||
}
|
||||
|
||||
template<typename PutChFunc>
|
||||
ALWAYS_INLINE int print_octal_number(PutChFunc putch, char*& bufptr, dword number, bool leftPad, bool zeroPad, dword fieldWidth)
|
||||
[[gnu::always_inline]] int print_octal_number(PutChFunc putch, char*& bufptr, dword number, bool leftPad, bool zeroPad, dword fieldWidth)
|
||||
{
|
||||
dword divisor = 134217728;
|
||||
char ch;
|
||||
|
@ -108,7 +108,7 @@ ALWAYS_INLINE int print_octal_number(PutChFunc putch, char*& bufptr, dword numbe
|
|||
}
|
||||
|
||||
template<typename PutChFunc>
|
||||
ALWAYS_INLINE int print_string(PutChFunc putch, char*& bufptr, const char* str, bool leftPad, dword fieldWidth)
|
||||
[[gnu::always_inline]] int print_string(PutChFunc putch, char*& bufptr, const char* str, bool leftPad, dword fieldWidth)
|
||||
{
|
||||
size_t len = strlen(str);
|
||||
if (!fieldWidth || fieldWidth < len)
|
||||
|
@ -129,7 +129,7 @@ ALWAYS_INLINE int print_string(PutChFunc putch, char*& bufptr, const char* str,
|
|||
|
||||
|
||||
template<typename PutChFunc>
|
||||
ALWAYS_INLINE int print_signed_number(PutChFunc putch, char*& bufptr, int number, bool leftPad, bool zeroPad, dword fieldWidth)
|
||||
[[gnu::always_inline]] int print_signed_number(PutChFunc putch, char*& bufptr, int number, bool leftPad, bool zeroPad, dword fieldWidth)
|
||||
{
|
||||
if (number < 0) {
|
||||
putch(bufptr, '-');
|
||||
|
@ -139,7 +139,7 @@ ALWAYS_INLINE int print_signed_number(PutChFunc putch, char*& bufptr, int number
|
|||
}
|
||||
|
||||
template<typename PutChFunc>
|
||||
ALWAYS_INLINE int printf_internal(PutChFunc putch, char* buffer, const char*& fmt, char*& ap)
|
||||
[[gnu::always_inline]] int printf_internal(PutChFunc putch, char* buffer, const char*& fmt, char*& ap)
|
||||
{
|
||||
const char *p;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue