Introduce __set_errno() throughout libroot.
* add errno_private.h, which defines the __set_errno() macro with and without tracing * instead of setting errno manually, all libroot's code now invokes __set_errno(), which makes it much easier to trace changes to errno * redirect glibc's use of __set_errno() to our own version
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2011, Oliver Tappe, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _ERRNO_PRIVATE_H
|
||||
#define _ERRNO_PRIVATE_H
|
||||
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
//#define TRACE_ERRNO
|
||||
|
||||
#if defined(TRACE_ERRNO) && !defined(_KERNEL_MODE)
|
||||
# include <OS.h>
|
||||
# define __set_errno(x) \
|
||||
do { \
|
||||
int error = (x); \
|
||||
debug_printf("%s:%d - setting errno to %x\n", __FILE__, __LINE__, \
|
||||
error); \
|
||||
errno = error; \
|
||||
} while (0)
|
||||
#else
|
||||
# define __set_errno(x) \
|
||||
do { errno = (x); } while (0)
|
||||
#endif
|
||||
|
||||
|
||||
#endif // _ERRNO_PRIVATE_H
|
||||
Reference in New Issue
Block a user