12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #pragma once
- #include <common/compiler.h>
- #include <stdint.h>
- #define MAX_ERRNO 4095
- #define IS_ERR_VALUE(x) unlikely((x) >= (uint64_t)-MAX_ERRNO)
- static inline long __must_check IS_ERR(const void* ptr)
- {
- return IS_ERR_VALUE((uint64_t)ptr);
- }
- static inline long __must_check IS_ERR_OR_NULL(const void* ptr)
- {
- return !ptr || IS_ERR_VALUE((uint64_t)ptr);
- }
- static inline void* __must_check ERR_PTR(long error)
- {
- return (void*)(error);
- }
- static inline long __must_check PTR_ERR(void * ptr)
- {
- return (long)ptr;
- }
|