2000-08-22 05:58:47 +02:00
|
|
|
/* cygerrno.h: main Cygwin header file.
|
|
|
|
|
|
|
|
This file is part of Cygwin.
|
|
|
|
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
2005-06-30 04:52:14 +02:00
|
|
|
#ifndef _CYGERRNO_H
|
|
|
|
#define _CYGERRNO_H
|
2003-06-16 05:24:13 +02:00
|
|
|
#include <errno.h>
|
2013-04-23 11:44:36 +02:00
|
|
|
#include "regparm.h"
|
2013-01-21 08:34:07 +01:00
|
|
|
|
2013-01-21 05:34:52 +01:00
|
|
|
void __reg3 seterrno_from_win_error (const char *file, int line, DWORD code);
|
|
|
|
void __reg3 seterrno_from_nt_status (const char *file, int line, NTSTATUS status);
|
|
|
|
int __reg2 geterrno_from_win_error (DWORD code = GetLastError (), int deferrno = 13 /*EACCESS*/);
|
|
|
|
int __reg2 geterrno_from_nt_status (NTSTATUS status, int deferrno = 13 /*EACCESS*/);
|
2000-08-22 05:58:47 +02:00
|
|
|
|
2014-08-15 15:50:53 +02:00
|
|
|
inline void __attribute__ ((always_inline))
|
|
|
|
seterrno (const char *file, int line)
|
|
|
|
{
|
|
|
|
seterrno_from_win_error (file, line, GetLastError ());
|
|
|
|
}
|
|
|
|
|
2000-08-22 05:58:47 +02:00
|
|
|
#define __seterrno() seterrno (__FILE__, __LINE__)
|
|
|
|
#define __seterrno_from_win_error(val) seterrno_from_win_error (__FILE__, __LINE__, val)
|
2010-04-16 17:42:29 +02:00
|
|
|
#define __seterrno_from_nt_status(status) seterrno_from_nt_status (__FILE__, __LINE__, status)
|
2000-08-22 05:58:47 +02:00
|
|
|
|
2012-12-21 22:30:56 +01:00
|
|
|
extern inline int
|
2005-05-04 13:00:22 +02:00
|
|
|
__set_errno (const char *fn, int ln, int val)
|
|
|
|
{
|
2011-10-16 00:37:30 +02:00
|
|
|
debug_printf ("%s:%d setting errno %d", fn, ln, val);
|
2017-07-19 10:28:39 +02:00
|
|
|
return errno = _impure_ptr->_errno = val;
|
2005-05-04 13:00:22 +02:00
|
|
|
}
|
2001-10-16 05:31:50 +02:00
|
|
|
#define set_errno(val) __set_errno (__PRETTY_FUNCTION__, __LINE__, (val))
|
2005-05-04 13:00:22 +02:00
|
|
|
|
2003-06-16 05:24:13 +02:00
|
|
|
#define get_errno() (errno)
|
2000-08-22 05:58:47 +02:00
|
|
|
extern "C" void __stdcall set_sig_errno (int e);
|
|
|
|
|
|
|
|
class save_errno
|
|
|
|
{
|
|
|
|
int saved;
|
|
|
|
public:
|
|
|
|
save_errno () {saved = get_errno ();}
|
|
|
|
save_errno (int what) {saved = get_errno (); set_errno (what); }
|
|
|
|
void set (int what) {set_errno (what); saved = what;}
|
|
|
|
void reset () {saved = get_errno ();}
|
2017-07-19 10:28:39 +02:00
|
|
|
~save_errno () {errno = _impure_ptr->_errno = saved;}
|
2000-08-22 05:58:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern const char *__sp_fn;
|
|
|
|
extern int __sp_ln;
|
2005-06-30 04:52:14 +02:00
|
|
|
#endif /*_CYGERRNO_H*/
|