newlib/winsup/cygwin/miscfuncs.h

75 lines
2.3 KiB
C
Raw Normal View History

2008-04-07 18:33:44 +02:00
/* miscfuncs.h: main Cygwin header file.
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Red Hat, Inc.
2008-04-07 18:33:44 +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. */
#ifndef _MISCFUNCS_H
#define _MISCFUNCS_H
int __reg1 winprio_to_nice (DWORD);
DWORD __reg1 nice_to_winprio (int &);
2008-04-07 18:33:44 +02:00
bool __reg3 create_pipe (PHANDLE, PHANDLE, LPSECURITY_ATTRIBUTES, DWORD);
2008-04-07 18:33:44 +02: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);
BOOL WINAPI WritePipeOverlapped (HANDLE h, LPCVOID buf, DWORD len,
LPDWORD ret_len, DWORD timeout);
/* 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 ();
~NT_readline () { if (fh) NtClose (fh); }
};
extern "C" void yield ();
2008-04-07 18:33:44 +02:00
#define import_address(x) __import_address ((void *)(x))
void * __reg1 __import_address (void *);
2008-04-07 18:33:44 +02:00
void backslashify (const char *, char *, bool);
void slashify (const char *, char *, bool);
#define isslash(c) ((c) == '/')
extern void transform_chars (PWCHAR, PWCHAR);
extern inline void
transform_chars (PUNICODE_STRING upath, USHORT start_idx)
{
transform_chars (upath->Buffer + start_idx,
upath->Buffer + upath->Length / sizeof (WCHAR) - 1);
}
2008-04-07 18:33:44 +02:00
/* Memory checking */
int __reg2 check_invalid_virtual_addr (const void *s, unsigned sz);
2008-04-07 18:33:44 +02:00
ssize_t __reg3 check_iovec (const struct iovec *, int, bool);
2008-04-07 18:33:44 +02: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)
* cygwin.din (pthread_attr_getguardsize): Export. (pthread_attr_setguardsize): Export. (pthread_attr_setstack): Export. (pthread_attr_setstackaddr): Export. * init.cc (dll_entry): Remove wow64_test_stack_marker. Check for unusual stack address by testing stack addresses from current TEB. Check validity of _my_tls by testing if it's within the stack as given in current TEB. * miscfuncs.cc (struct thread_wrapper_arg): New structure used to push all required information to thread_wrapper function. (thread_wrapper): Wrapper function for actual thread function. If an application stack has been given, change %ebp and %esp so that the thread function runs on that stack. If the thread has been created by CygwinCreateThread, set up the POSIX guard pages if necessary. (CygwinCreateThread): New function. * miscfuncs.h (CygwinCreateThread): Declare. * ntdll.h (struct _TEB): Define all members up to Peb. * posix.sgml (std-susv4): Move pthread_attr_getguardsize, pthread_attr_setguardsize and pthread_attr_setstack here. (std-deprec): Add pthread_attr_setstackaddr. * sysconf.cc (sca): Set _SC_THREAD_ATTR_STACKADDR to _POSIX_THREAD_ATTR_STACKADDR. * thread.cc (pthread::precreate): Copy pthread_attr stackaddr and guardsize members. (pthread::create): Call CygwinCreateThread. (pthread_attr::pthread_attr): Initialize guardsize. (pthread_attr_setstack): New function. (pthread_attr_setstackaddr): New function. (pthread_attr_setguardsize): New function. (pthread_attr_getguardsize): New function. (pthread_getattr_np): Copy attr.guardsize. * thread.h (pthread_attr): Add member guardsize. * include/pthread.h (pthread_attr_getguardsize): Declare. (pthread_attr_setguardsize): Declare. * include/cygwin/version.h: Bump API minor number.
2011-05-15 20:49:40 +02: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-07 18:33:44 +02:00
#endif /*_MISCFUNCS_H*/