forked from Bananymous/banan-os
				
			BAN: Error uses 64 bit error codes
This commit is contained in:
		
							parent
							
								
									054c5450df
								
							
						
					
					
						commit
						05046d6e93
					
				| 
						 | 
					@ -25,12 +25,12 @@ namespace BAN
 | 
				
			||||||
	class Error
 | 
						class Error
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	private:
 | 
						private:
 | 
				
			||||||
		static constexpr uint32_t kernel_error_mask = 0x80000000;
 | 
							static constexpr uint64_t kernel_error_mask = uint64_t(1) << 63;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public:
 | 
						public:
 | 
				
			||||||
		static Error from_error_code(Kernel::ErrorCode error)
 | 
							static Error from_error_code(Kernel::ErrorCode error)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			return Error((uint32_t)error | kernel_error_mask);
 | 
								return Error((uint64_t)error | kernel_error_mask);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		static Error from_errno(int error)
 | 
							static Error from_errno(int error)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
| 
						 | 
					@ -42,7 +42,7 @@ namespace BAN
 | 
				
			||||||
			return (Kernel::ErrorCode)(m_error_code & ~kernel_error_mask);
 | 
								return (Kernel::ErrorCode)(m_error_code & ~kernel_error_mask);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		uint32_t get_error_code() const { return m_error_code; }
 | 
							uint64_t get_error_code() const { return m_error_code; }
 | 
				
			||||||
		BAN::StringView get_message() const
 | 
							BAN::StringView get_message() const
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			if (m_error_code & kernel_error_mask)
 | 
								if (m_error_code & kernel_error_mask)
 | 
				
			||||||
| 
						 | 
					@ -51,11 +51,11 @@ namespace BAN
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private:
 | 
						private:
 | 
				
			||||||
		Error(uint32_t error)
 | 
							Error(uint64_t error)
 | 
				
			||||||
			: m_error_code(error)
 | 
								: m_error_code(error)
 | 
				
			||||||
		{}
 | 
							{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		uint32_t m_error_code;
 | 
							uint64_t m_error_code;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	template<typename T>
 | 
						template<typename T>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -60,7 +60,7 @@ char* getenv(const char*)
 | 
				
			||||||
void* malloc(size_t bytes)
 | 
					void* malloc(size_t bytes)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	long res = syscall(SYS_ALLOC, bytes);
 | 
						long res = syscall(SYS_ALLOC, bytes);
 | 
				
			||||||
	if (res == -1)
 | 
						if (res < 0)
 | 
				
			||||||
		return nullptr;
 | 
							return nullptr;
 | 
				
			||||||
	return (void*)res;
 | 
						return (void*)res;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue