/* Copyright 2022, Contributors To LensorOS.
* All rights reserved.
*
* This file is part of LensorOS.
*
* LensorOS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LensorOS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LensorOS. If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef _LENSOR_OS_NEW
#define _LENSOR_OS_NEW

#include <bits/decls.h>

__BEGIN_DECLS__

/// Declare these here to avoid having to include stdlib.h in the kernel.
__attribute__((__malloc__, __alloc_size__(1))) void* malloc(size_t numBytes);
void free(void* address);

__END_DECLS__

namespace std {
enum class align_val_t : size_t {};
}

[[nodiscard]] void* operator new(size_t size);
[[nodiscard]] void* operator new[](size_t size);
void operator delete(void* ptr) noexcept;
void operator delete[](void* ptr) noexcept;
void operator delete(void* ptr, size_t) noexcept;
void operator delete[](void* ptr, size_t) noexcept;

/// Aligned new.
[[nodiscard]] void* operator new(size_t size, std::align_val_t align);
[[nodiscard]] void* operator new[](size_t size, std::align_val_t align);
void operator delete(void* ptr, std::align_val_t align);
void operator delete[](void* ptr, std::align_val_t align);

/// Placement new.
[[nodiscard]] void* operator new(size_t, void* ptr) noexcept;
[[nodiscard]] void* operator new[](size_t, void* ptr) noexcept;

#endif // _LENSOR_OS_NEW
