2022-10-08 10:06:09 +00:00
|
|
|
#ifndef _BITS_ERROR_H
|
|
|
|
#define _BITS_ERROR_H
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#define _RETURN_WITH_ERRNO(rc, type) \
|
|
|
|
do { \
|
|
|
|
if (rc < 0) \
|
|
|
|
{ \
|
2022-10-10 18:21:39 +00:00
|
|
|
errno = (int)(-rc); \
|
2022-10-08 10:06:09 +00:00
|
|
|
return -1; \
|
|
|
|
} \
|
2022-10-10 19:08:57 +00:00
|
|
|
errno = 0; \
|
2022-10-08 10:06:09 +00:00
|
|
|
return (type)rc; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define _RETURN_WITH_MEMORY_ERRNO(rc, type) \
|
|
|
|
do { \
|
|
|
|
if ((unsigned long int)rc > 0xffffffffffffff00) \
|
|
|
|
{ \
|
|
|
|
errno = (int)((rc)&0xff); \
|
|
|
|
return (type)-1; \
|
|
|
|
} \
|
2022-10-10 19:08:57 +00:00
|
|
|
errno = 0; \
|
2022-10-08 10:06:09 +00:00
|
|
|
return (type)rc; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#endif
|