2000-08-22 05:58:47 +02:00
|
|
|
/* cygerrno.h: main Cygwin header file.
|
|
|
|
|
2004-02-01 19:29:12 +01:00
|
|
|
Copyright 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
|
2000-08-22 05:58:47 +02: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. */
|
|
|
|
|
2003-06-16 05:24:13 +02:00
|
|
|
#include <errno.h>
|
|
|
|
|
2000-10-17 01:55:58 +02:00
|
|
|
void __stdcall seterrno_from_win_error (const char *file, int line, DWORD code) __attribute__ ((regparm(3)));
|
|
|
|
void __stdcall seterrno (const char *, int line) __attribute__ ((regparm(2)));
|
2001-02-22 15:51:16 +01:00
|
|
|
int __stdcall geterrno_from_win_error (DWORD code, int deferrno) __attribute__ ((regparm(2)));
|
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)
|
2005-04-13 18:41:33 +02:00
|
|
|
#define __seterrno_from_nt_status(status) \
|
|
|
|
({ \
|
|
|
|
DWORD winerr = RtlNtStatusToDosError (status); \
|
|
|
|
SetLastError (winerr); \
|
|
|
|
__seterrno_from_win_error (winerr); \
|
|
|
|
})
|
2000-08-22 05:58:47 +02:00
|
|
|
|
2005-05-04 13:00:22 +02:00
|
|
|
inline int
|
|
|
|
__set_errno (const char *fn, int ln, int val)
|
|
|
|
{
|
|
|
|
debug_printf ("%s:%d val %d", fn, ln, val);
|
2005-05-04 13:05:11 +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 ();}
|
|
|
|
~save_errno () {set_errno (saved);}
|
|
|
|
};
|
|
|
|
|
|
|
|
extern const char *__sp_fn;
|
|
|
|
extern int __sp_ln;
|