2008-04-08 00:33:44 +08:00
|
|
|
/* miscfuncs.h: main Cygwin header file.
|
|
|
|
|
2013-01-21 06:59:58 +08:00
|
|
|
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
|
2014-02-09 04:57:27 +08:00
|
|
|
2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Red Hat, Inc.
|
2008-04-08 00:33:44 +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. */
|
|
|
|
|
|
|
|
#ifndef _MISCFUNCS_H
|
|
|
|
#define _MISCFUNCS_H
|
2013-01-21 12:34:52 +08:00
|
|
|
int __reg1 winprio_to_nice (DWORD);
|
|
|
|
DWORD __reg1 nice_to_winprio (int &);
|
2008-04-08 00:33:44 +08:00
|
|
|
|
2013-01-21 12:34:52 +08:00
|
|
|
bool __reg3 create_pipe (PHANDLE, PHANDLE, LPSECURITY_ATTRIBUTES, DWORD);
|
2008-04-08 00:33:44 +08:00
|
|
|
|
2011-08-13 18:28:15 +08:00
|
|
|
BOOL WINAPI CreatePipeOverlapped (PHANDLE read_handle, PHANDLE write_handle,
|
|
|
|
LPSECURITY_ATTRIBUTES sa);
|
|
|
|
BOOL WINAPI ReadPipeOverlapped (HANDLE h, PVOID buf, DWORD len,
|
|
|
|
LPDWORD ret_len, DWORD timeout);
|
2012-06-27 21:35:48 +08:00
|
|
|
BOOL WINAPI WritePipeOverlapped (HANDLE h, LPCVOID buf, DWORD len,
|
2011-08-13 18:28:15 +08:00
|
|
|
LPDWORD ret_len, DWORD timeout);
|
|
|
|
|
2014-02-09 04:57:27 +08:00
|
|
|
/* class for per-line reading using native functions. The caller provides
|
|
|
|
the file as an POBJECT_ATTRIBUTES, and the buffer space. */
|
|
|
|
class NT_readline
|
|
|
|
{
|
|
|
|
HANDLE fh;
|
|
|
|
PCHAR buf;
|
|
|
|
PCHAR got;
|
|
|
|
PCHAR end;
|
|
|
|
ULONG buflen;
|
|
|
|
ULONG len;
|
|
|
|
ULONG line;
|
|
|
|
public:
|
|
|
|
NT_readline () : fh (NULL) {}
|
|
|
|
bool init (POBJECT_ATTRIBUTES attr, char *buf, ULONG buflen);
|
|
|
|
PCHAR gets ();
|
2014-02-17 00:02:18 +08:00
|
|
|
void close () { if (fh) NtClose (fh); fh = NULL; }
|
|
|
|
~NT_readline () { close (); }
|
2014-02-09 04:57:27 +08:00
|
|
|
};
|
|
|
|
|
2010-03-13 07:13:48 +08:00
|
|
|
extern "C" void yield ();
|
2008-04-08 00:33:44 +08:00
|
|
|
|
2013-01-21 06:59:58 +08:00
|
|
|
#define import_address(x) __import_address ((void *)(x))
|
2013-01-21 12:34:52 +08:00
|
|
|
void * __reg1 __import_address (void *);
|
2013-01-21 06:59:58 +08:00
|
|
|
|
2008-04-08 00:33:44 +08:00
|
|
|
void backslashify (const char *, char *, bool);
|
|
|
|
void slashify (const char *, char *, bool);
|
|
|
|
#define isslash(c) ((c) == '/')
|
|
|
|
|
2009-11-02 19:42:04 +08:00
|
|
|
extern void transform_chars (PWCHAR, PWCHAR);
|
2012-12-22 05:30:56 +08:00
|
|
|
extern inline void
|
2009-11-02 19:42:04 +08:00
|
|
|
transform_chars (PUNICODE_STRING upath, USHORT start_idx)
|
|
|
|
{
|
|
|
|
transform_chars (upath->Buffer + start_idx,
|
|
|
|
upath->Buffer + upath->Length / sizeof (WCHAR) - 1);
|
|
|
|
}
|
|
|
|
|
2008-04-08 00:33:44 +08:00
|
|
|
/* Memory checking */
|
2013-01-21 12:34:52 +08:00
|
|
|
int __reg2 check_invalid_virtual_addr (const void *s, unsigned sz);
|
2008-04-08 00:33:44 +08:00
|
|
|
|
2013-01-21 12:34:52 +08:00
|
|
|
ssize_t __reg3 check_iovec (const struct iovec *, int, bool);
|
2008-04-08 00:33:44 +08:00
|
|
|
#define check_iovec_for_read(a, b) check_iovec ((a), (b), false)
|
|
|
|
#define check_iovec_for_write(a, b) check_iovec ((a), (b), true)
|
2011-05-16 02:49:40 +08:00
|
|
|
|
|
|
|
extern "C" HANDLE WINAPI CygwinCreateThread (LPTHREAD_START_ROUTINE thread_func,
|
|
|
|
PVOID thread_arg, PVOID stackaddr,
|
|
|
|
ULONG stacksize, ULONG guardsize,
|
|
|
|
DWORD creation_flags,
|
|
|
|
LPDWORD thread_id);
|
|
|
|
|
2008-04-08 00:33:44 +08:00
|
|
|
#endif /*_MISCFUNCS_H*/
|