2000-08-22 11:58:47 +08:00
|
|
|
/* cygerrno.h: main Cygwin header file.
|
|
|
|
|
2013-01-10 00:25:15 +08:00
|
|
|
Copyright 2000, 2001, 2002, 2003, 2004, 2010, 2011, 2012 Red Hat, Inc.
|
2000-08-22 11:58:47 +08:00
|
|
|
|
|
|
|
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 10:52:14 +08:00
|
|
|
#ifndef _CYGERRNO_H
|
|
|
|
#define _CYGERRNO_H
|
2003-06-16 11:24:13 +08:00
|
|
|
#include <errno.h>
|
|
|
|
|
2000-10-17 07:55:58 +08:00
|
|
|
void __stdcall seterrno_from_win_error (const char *file, int line, DWORD code) __attribute__ ((regparm(3)));
|
2010-04-16 23:42:29 +08:00
|
|
|
void __stdcall seterrno_from_nt_status (const char *file, int line, NTSTATUS status) __attribute__ ((regparm(3)));
|
2000-10-17 07:55:58 +08:00
|
|
|
void __stdcall seterrno (const char *, int line) __attribute__ ((regparm(2)));
|
2005-08-20 14:19:55 +08:00
|
|
|
int __stdcall geterrno_from_win_error (DWORD code = GetLastError (), int deferrno = 13 /*EACCESS*/) __attribute__ ((regparm(2)));
|
2011-04-28 20:13:41 +08:00
|
|
|
int __stdcall geterrno_from_nt_status (NTSTATUS status, int deferrno = 13 /*EACCESS*/) __attribute__ ((regparm(2)));
|
2000-08-22 11:58:47 +08:00
|
|
|
|
|
|
|
#define __seterrno() seterrno (__FILE__, __LINE__)
|
|
|
|
#define __seterrno_from_win_error(val) seterrno_from_win_error (__FILE__, __LINE__, val)
|
2010-04-16 23:42:29 +08:00
|
|
|
#define __seterrno_from_nt_status(status) seterrno_from_nt_status (__FILE__, __LINE__, status)
|
2000-08-22 11:58:47 +08:00
|
|
|
|
2012-12-22 05:30:56 +08:00
|
|
|
extern inline int
|
2005-05-04 19:00:22 +08:00
|
|
|
__set_errno (const char *fn, int ln, int val)
|
|
|
|
{
|
2011-10-16 06:37:30 +08:00
|
|
|
debug_printf ("%s:%d setting errno %d", fn, ln, val);
|
2005-05-04 19:05:11 +08:00
|
|
|
return errno = _impure_ptr->_errno = val;
|
2005-05-04 19:00:22 +08:00
|
|
|
}
|
2001-10-16 11:31:50 +08:00
|
|
|
#define set_errno(val) __set_errno (__PRETTY_FUNCTION__, __LINE__, (val))
|
2005-05-04 19:00:22 +08:00
|
|
|
|
2003-06-16 11:24:13 +08:00
|
|
|
#define get_errno() (errno)
|
2000-08-22 11:58:47 +08: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 ();}
|
2009-06-09 03:44:33 +08:00
|
|
|
~save_errno () {errno = _impure_ptr->_errno = saved;}
|
2000-08-22 11:58:47 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
extern const char *__sp_fn;
|
|
|
|
extern int __sp_ln;
|
2005-06-30 10:52:14 +08:00
|
|
|
#endif /*_CYGERRNO_H*/
|