26 lines
2.0 KiB
C
26 lines
2.0 KiB
C
|
#ifndef _BITS_ERROR_H
|
||
|
#define _BITS_ERROR_H
|
||
|
|
||
|
#include <errno.h>
|
||
|
|
||
|
#define _RETURN_WITH_ERRNO(rc, type) \
|
||
|
do { \
|
||
|
if (rc < 0) \
|
||
|
{ \
|
||
|
errno = (int)rc; \
|
||
|
return -1; \
|
||
|
} \
|
||
|
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; \
|
||
|
} \
|
||
|
return (type)rc; \
|
||
|
} while (0)
|
||
|
|
||
|
#endif
|