2000-02-18 03:38:33 +08:00
|
|
|
/* winsup.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. */
|
|
|
|
|
2012-11-23 21:22:47 +08:00
|
|
|
#include "config.h"
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
#define __INSIDE_CYGWIN__
|
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
#define NO_COPY_RO __attribute__((nocommon)) __attribute__((section(".rdata_cygwin_nocopy")))
|
2002-02-16 01:06:40 +08:00
|
|
|
#define NO_COPY __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy")))
|
2003-05-11 08:10:11 +08:00
|
|
|
#define NO_COPY_INIT __attribute__((section(".data_cygwin_nocopy")))
|
2001-08-23 01:50:22 +08:00
|
|
|
|
2020-05-25 19:10:41 +08:00
|
|
|
#ifdef __cplusplus
|
2004-09-10 16:30:51 +08:00
|
|
|
#define EXPORT_ALIAS(sym,symalias) extern "C" __typeof (sym) symalias __attribute__ ((alias(#sym)));
|
2020-05-25 19:10:41 +08:00
|
|
|
#else
|
|
|
|
#define EXPORT_ALIAS(sym,symalias) __typeof (sym) symalias __attribute__ ((alias(#sym)));
|
|
|
|
#endif
|
2004-09-10 16:30:51 +08:00
|
|
|
|
2020-08-06 03:58:22 +08:00
|
|
|
#define fallthrough __attribute__((__fallthrough__))
|
|
|
|
|
2015-08-26 04:23:01 +08:00
|
|
|
#define _WIN32_WINNT 0x0a00
|
|
|
|
#define WINVER 0x0a00
|
2012-07-06 20:13:50 +08:00
|
|
|
|
2006-10-17 21:55:05 +08:00
|
|
|
#define _NO_W32_PSEUDO_MODIFIERS
|
2002-09-06 12:21:30 +08:00
|
|
|
|
2014-08-16 05:21:59 +08:00
|
|
|
/* Newlib's guarding functions more diligently based on their origin, starting
|
|
|
|
since 2013. To be sure to get everything and the kitchen sink, we have to
|
|
|
|
define _GNU_SOURCE. */
|
|
|
|
#define _GNU_SOURCE 1
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/strace.h>
|
2020-05-25 19:10:41 +08:00
|
|
|
#include <sys/smallprint.h>
|
2000-02-18 03:38:33 +08:00
|
|
|
|
* Makefile.in (DLL_OFILES): Add getopt.o and iruserok.o.
* cygwin.din: Export __check_rhosts_file, __rcmd_errstr, optarg,
opterr, optind, optopt, optreset, getopt, getopt_long, iruserok
and ruserok.
* getopt.c: Moved from lib to here. Define opt* variables as
dllexport.
* iruserok.c: Moved from lib to here. Rearrange function order.
Prefer using 64/32 bit functions.
* syscalls.cc (shell_fp): Define as struct __sFILE64.
(getusershell): Use fopen64 instead of fopen.
* winsup.h: Add declarations for seteuid32, fopen64,
cygwin_gethostbyname and cygwin_inet_addr.
* include/getopt.h: Declare opt* variables dllimport.
* include/cygwin/version.h: Bump API minor number.
2003-09-11 03:13:05 +08:00
|
|
|
/* Declarations for functions used in C and C++ code. */
|
2003-03-10 05:51:00 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2013-04-23 17:44:36 +08:00
|
|
|
uid_t getuid32 ();
|
|
|
|
uid_t geteuid32 ();
|
|
|
|
int seteuid32 (uid_t);
|
|
|
|
gid_t getegid32 (void);
|
|
|
|
struct passwd *getpwuid32 (uid_t);
|
2009-01-03 13:12:22 +08:00
|
|
|
struct passwd *getpwnam (const char *);
|
|
|
|
struct __sFILE64 *fopen64 (const char *, const char *);
|
|
|
|
struct hostent *cygwin_gethostbyname (const char *name);
|
2008-05-20 23:39:26 +08:00
|
|
|
/* Don't enforce definition of in_addr_t. */
|
2009-01-03 13:12:22 +08:00
|
|
|
uint32_t cygwin_inet_addr (const char *cp);
|
|
|
|
int fcntl64 (int fd, int cmd, ...);
|
2003-03-10 05:51:00 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-11-15 07:40:06 +08:00
|
|
|
/* Note that MAX_PATH is defined in the windows headers */
|
|
|
|
/* There is also PATH_MAX and MAXPATHLEN.
|
2008-02-15 00:47:11 +08:00
|
|
|
PATH_MAX is from Posix and does include the trailing NUL.
|
2003-11-15 07:40:06 +08:00
|
|
|
MAXPATHLEN is from Unix.
|
|
|
|
|
2008-03-13 01:04:10 +08:00
|
|
|
Thou shalt *not* use CYG_MAX_PATH anymore. Use NT_MAX_PATH or
|
|
|
|
dynamic allocation instead when accessing real files. Use
|
|
|
|
MAX_PATH in case you need a convenient small buffer when creating
|
|
|
|
names for synchronization objects or named pipes. */
|
2003-11-15 07:40:06 +08:00
|
|
|
#define CYG_MAX_PATH (MAX_PATH)
|
|
|
|
|
2008-02-15 00:47:11 +08:00
|
|
|
/* There's no define for the maximum path length the NT kernel can handle.
|
|
|
|
That's why we define our own to use in path length test and for path
|
|
|
|
buffer sizes. As MAX_PATH and PATH_MAX, this is defined including the
|
|
|
|
trailing 0. Internal buffers and internal path routines should use
|
|
|
|
NT_MAX_PATH. PATH_MAX as defined in limits.h is the maximum length of
|
2008-03-12 20:41:50 +08:00
|
|
|
application provided path strings we handle. */
|
|
|
|
#define NT_MAX_PATH 32768
|
2008-02-15 00:47:11 +08:00
|
|
|
|
2011-04-19 18:02:06 +08:00
|
|
|
/* This definition allows to define wide char strings using macros as
|
|
|
|
parameters. See the definition of __CONCAT in newlib's sys/cdefs.h
|
|
|
|
and accompanying comment. */
|
|
|
|
#define __WIDE(a) L ## a
|
|
|
|
#define _WIDE(a) __WIDE(a)
|
|
|
|
|
2012-07-12 19:27:28 +08:00
|
|
|
#include "winlean.h"
|
|
|
|
|
2003-03-10 05:51:00 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2012-07-12 19:27:28 +08:00
|
|
|
#include "wincap.h"
|
2013-04-23 17:44:36 +08:00
|
|
|
#include "regparm.h"
|
2012-07-12 19:27:28 +08:00
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
extern const unsigned char case_folded_lower[];
|
|
|
|
#define cyg_tolower(c) ((char) case_folded_lower[(unsigned char)(c)])
|
|
|
|
extern const unsigned char case_folded_upper[];
|
|
|
|
#define cyg_toupper(c) ((char) case_folded_upper[(unsigned char)(c)])
|
2000-10-19 11:12:44 +08:00
|
|
|
|
2000-09-07 05:03:10 +08:00
|
|
|
#define cfree newlib_cfree_dont_use
|
|
|
|
|
2008-02-01 04:26:01 +08:00
|
|
|
/* Used as type by sys_wcstombs_alloc and sys_mbstowcs_alloc. For a
|
|
|
|
description see there. */
|
|
|
|
#define HEAP_NOTHEAP -1
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Used to check if Cygwin DLL is dynamically loaded. */
|
|
|
|
|
2002-06-26 13:29:41 +08:00
|
|
|
extern int cygserver_running;
|
2000-07-23 00:43:54 +08:00
|
|
|
|
2008-03-03 06:51:19 +08:00
|
|
|
#define _MT_SAFE // DELETEME someday
|
2003-07-02 11:16:00 +08:00
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
#define TITLESIZE 1024
|
2000-07-02 18:17:44 +08:00
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
#include "debug.h"
|
|
|
|
|
2009-04-07 20:13:37 +08:00
|
|
|
#include <wchar.h>
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/**************************** Convenience ******************************/
|
|
|
|
|
2004-04-13 17:04:22 +08:00
|
|
|
/* Used to define status flag accessor methods */
|
|
|
|
#define IMPLEMENT_STATUS_FLAG(type,flag) \
|
2009-07-16 17:56:25 +08:00
|
|
|
type flag (type val) { return (type) (status.flag = (val)); } \
|
2004-04-13 17:04:22 +08:00
|
|
|
type flag () const { return (type) status.flag; }
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Used when treating / and \ as equivalent. */
|
2007-08-16 18:41:45 +08:00
|
|
|
#define iswdirsep(ch) \
|
|
|
|
({ \
|
|
|
|
WCHAR __c = (ch); \
|
|
|
|
((__c) == L'/' || (__c) == L'\\'); \
|
|
|
|
})
|
|
|
|
|
2003-01-09 16:22:05 +08:00
|
|
|
#define isdirsep(ch) \
|
2000-02-18 03:38:33 +08:00
|
|
|
({ \
|
|
|
|
char __c = (ch); \
|
|
|
|
((__c) == '/' || (__c) == '\\'); \
|
|
|
|
})
|
|
|
|
|
|
|
|
/* Convert a signal to a signal mask */
|
2015-02-23 20:40:01 +08:00
|
|
|
#define SIGTOMASK(sig) ((sigset_t) 1 << ((sig) - 1))
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2006-03-14 05:10:14 +08:00
|
|
|
#define set_api_fatal_return(n) do {extern int __api_fatal_exit_val; __api_fatal_exit_val = (n);} while (0)
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
#undef issep
|
|
|
|
#define issep(ch) (strchr (" \t\n\r", (ch)) != NULL)
|
|
|
|
|
2007-08-16 18:41:45 +08:00
|
|
|
/* Every path beginning with / or \, as well as every path being X:
|
|
|
|
or starting with X:/ or X:\ */
|
|
|
|
#define isabspath_u(p) \
|
|
|
|
((p)->Length && \
|
|
|
|
(iswdirsep ((p)->Buffer[0]) || \
|
|
|
|
((p)->Length > sizeof (WCHAR) && iswalpha ((p)->Buffer[0]) \
|
|
|
|
&& (p)->Buffer[1] == L':' && \
|
|
|
|
((p)->Length == 2 * sizeof (WCHAR) || iswdirsep ((p)->Buffer[2])))))
|
|
|
|
|
|
|
|
#define iswabspath(p) \
|
|
|
|
(iswdirsep (*(p)) || (iswalpha (*(p)) && (p)[1] == L':' && (!(p)[2] || iswdirsep ((p)[2]))))
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
#define isabspath(p) \
|
2000-06-18 06:05:19 +08:00
|
|
|
(isdirsep (*(p)) || (isalpha (*(p)) && (p)[1] == ':' && (!(p)[2] || isdirsep ((p)[2]))))
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
/******************** Initialization/Termination **********************/
|
|
|
|
|
2000-09-08 10:56:55 +08:00
|
|
|
class per_process;
|
2000-02-18 03:38:33 +08:00
|
|
|
/* cygwin .dll initialization */
|
2013-04-23 17:44:36 +08:00
|
|
|
void dll_crt0 (per_process *) __asm__ (_SYMSTR (dll_crt0__FP11per_process));
|
2000-07-01 12:40:20 +08:00
|
|
|
extern "C" void __stdcall _dll_crt0 ();
|
2009-01-03 13:12:22 +08:00
|
|
|
void dll_crt0_1 (void *);
|
|
|
|
void dll_dllcrt0_1 (void *);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
/* dynamically loaded dll initialization */
|
2013-04-23 17:44:36 +08:00
|
|
|
extern "C" PVOID dll_dllcrt0 (HMODULE, per_process *);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2012-07-02 10:24:25 +08:00
|
|
|
extern "C" void _pei386_runtime_relocator (per_process *);
|
2010-05-08 05:25:19 +08:00
|
|
|
|
2017-11-27 21:36:06 +08:00
|
|
|
#ifdef __i386__
|
2000-02-18 03:38:33 +08:00
|
|
|
/* dynamically loaded dll initialization for non-cygwin apps */
|
|
|
|
extern "C" int dll_noncygwin_dllcrt0 (HMODULE, per_process *);
|
2017-11-27 21:36:06 +08:00
|
|
|
#endif /* __i386__ */
|
2013-04-23 17:44:36 +08:00
|
|
|
|
2013-01-21 12:34:52 +08:00
|
|
|
void __reg1 do_exit (int) __attribute__ ((noreturn));
|
2000-02-18 03:38:33 +08:00
|
|
|
|
winsup/ChangeLog:
* Makefile.common (COMPILE_CXX): Add support for per-file overrides
to exclude $(nostdinc) and $(nostdincxx) from compiler flags.
(COMPILE_CC): Likewise for $(nostdinc).
winsup/cygwin/ChangeLog:
* Makefile.in (DLL_OFILES): Add libstdcxx_wrapper.o
(libstdcxx_wrapper_CFLAGS): Add flags for new module.
(_cygwin_crt0_common_STDINCFLAGS): Define per-file override.
(libstdcxx_wrapper_STDINCFLAGS, cxx_STDINCFLAGS): Likewise.
* cxx.cc: Include "cygwin-cxx.h".
(operator new): Tweak prototype for full standards compliance.
(operator new[]): Likewise.
(operator new (nothrow)): New fallback function.
(operator new[] (nothrow), operator delete (nothrow),
operator delete[] (nothrow)): Likewise.
(default_cygwin_cxx_malloc): New struct of pointers to the above,
for final last-resort fallback default.
* cygwin-cxx.h: New file.
(struct per_process_cxx_malloc): Define.
(default_cygwin_cxx_malloc): Declare extern.
* cygwin.din (__wrap__ZdaPv): Export new wrapper.
(__wrap__ZdaPvRKSt9nothrow_t, __wrap__ZdlPv,
__wrap__ZdlPvRKSt9nothrow_t, __wrap__Znaj,
__wrap__ZnajRKSt9nothrow_t, __wrap__Znwj,
__wrap__ZnwjRKSt9nothrow_t): Likewise.
* globals.cc (__cygwin_user_data): Init newly-repurposed 'forkee'
field (now 'cxx_malloc') to point to default_cygwin_cxx_malloc.
* libstdcxx_wrapper.cc: New file.
(__wrap__ZdaPv, __wrap__ZdaPvRKSt9nothrow_t, __wrap__ZdlPv,
__wrap__ZdlPvRKSt9nothrow_t, __wrap__Znaj,
__wrap__ZnajRKSt9nothrow_t, __wrap__Znwj,
__wrap__ZnwjRKSt9nothrow_t): Define wrapper functions for libstdc++
malloc operators and their overrides.
* winsup.h (default_cygwin_cxx_malloc): Declare extern.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
* include/sys/cygwin.h (struct per_process_cxx_malloc): Forward
declare here.
(struct per_process::forkee): Rename and repurpose from this ...
(struct per_process::cxx_malloc): ... to this.
* lib/_cygwin_crt0_common.cc: Include cygwin-cxx.h.
(WEAK): Define shorthand helper macro.
(__cygwin_cxx_malloc): Define and populate with weak references
to whatever libstdc++ malloc operators will be visible at final
link time for Cygwin apps and dlls.
(_cygwin_crt0_common): Always look up cygwin DLL's internal
per_process data, and don't test for (impossible) failure. Inherit
any members of __cygwin_cxx_malloc that we don't have overrides
for from the DLL's default and store the resulting overall set of
overrides back into the DLL's global per_process data.
2009-07-08 04:12:44 +08:00
|
|
|
/* libstdc++ malloc operator wrapper support. */
|
|
|
|
extern struct per_process_cxx_malloc default_cygwin_cxx_malloc;
|
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
#define ILLEGAL_SEEK ((off_t)-1)
|
|
|
|
|
2005-03-17 05:52:06 +08:00
|
|
|
/* Convert LARGE_INTEGER into long long */
|
|
|
|
#define get_ll(pl) (((long long) (pl).HighPart << 32) | (pl).LowPart)
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* various events */
|
2005-07-05 11:16:46 +08:00
|
|
|
void events_init ();
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2020-01-28 22:33:05 +08:00
|
|
|
int chmod_device (class path_conv& pc, mode_t mode);
|
2020-01-28 22:33:53 +08:00
|
|
|
void close_all_files (bool = false);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
/* debug_on_trap support. see exceptions.cc:try_to_debug() */
|
|
|
|
extern "C" void error_start_init (const char*);
|
2001-04-30 11:09:19 +08:00
|
|
|
extern "C" int try_to_debug (bool waitloop = 1);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2008-03-27 09:50:40 +08:00
|
|
|
void ld_preload ();
|
2019-01-16 19:59:27 +08:00
|
|
|
void fixup_hooks_after_fork ();
|
2008-03-27 09:50:40 +08:00
|
|
|
const char *find_first_notloaded_dll (class path_conv &);
|
2005-08-12 00:30:48 +08:00
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/**************************** Miscellaneous ******************************/
|
|
|
|
|
|
|
|
void __stdcall set_std_handle (int);
|
2013-04-23 17:44:36 +08:00
|
|
|
int __stdcall stat_dev (DWORD, int, unsigned long, struct stat *);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
ino_t __reg2 hash_path_name (ino_t hash, PUNICODE_STRING name);
|
|
|
|
ino_t __reg2 hash_path_name (ino_t hash, PCWSTR name);
|
|
|
|
ino_t __reg2 hash_path_name (ino_t hash, const char *name);
|
2013-01-21 12:34:52 +08:00
|
|
|
void __reg2 nofinalslash (const char *src, char *dst);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2013-01-21 12:34:52 +08:00
|
|
|
void __reg3 *hook_or_detect_cygwin (const char *, const void *, WORD&, HANDLE h = NULL);
|
2019-09-04 09:44:25 +08:00
|
|
|
void __reg3 *hook_api (const char *mname, const char *name, const void *fn);
|
2005-07-17 08:51:03 +08:00
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Time related */
|
2013-06-14 17:09:41 +08:00
|
|
|
void __stdcall totimeval (struct timeval *, PLARGE_INTEGER, int, int);
|
|
|
|
time_t __stdcall to_time_t (PLARGE_INTEGER);
|
|
|
|
void __stdcall to_timestruc_t (PLARGE_INTEGER, timestruc_t *);
|
2005-02-20 19:44:32 +08:00
|
|
|
void __stdcall time_as_timestruc_t (timestruc_t *);
|
2013-06-14 17:09:41 +08:00
|
|
|
void __stdcall timeval_to_filetime (const struct timeval *, PLARGE_INTEGER);
|
|
|
|
void __stdcall timespec_to_filetime (const struct timespec *, PLARGE_INTEGER);
|
2018-02-07 23:16:51 +08:00
|
|
|
bool timeval_to_ms (const struct timeval *, DWORD &);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2005-08-12 00:30:48 +08:00
|
|
|
/* Console related */
|
2000-02-18 03:38:33 +08:00
|
|
|
void __stdcall set_console_title (char *);
|
2006-03-16 10:57:37 +08:00
|
|
|
void init_console_handler (bool);
|
2005-08-12 00:30:48 +08:00
|
|
|
|
2001-08-23 01:50:22 +08:00
|
|
|
extern bool wsock_started;
|
|
|
|
|
2000-09-08 10:56:55 +08:00
|
|
|
/* Printf type functions */
|
2011-05-29 02:17:09 +08:00
|
|
|
extern "C" void vapi_fatal (const char *, va_list ap) __attribute__ ((noreturn));
|
|
|
|
extern "C" void api_fatal (const char *, ...) __attribute__ ((noreturn));
|
2013-01-21 12:34:52 +08:00
|
|
|
int __small_swprintf (PWCHAR dst, const WCHAR *fmt, ...);
|
|
|
|
int __small_vswprintf (PWCHAR dst, const WCHAR *fmt, va_list ap);
|
2013-04-23 17:44:36 +08:00
|
|
|
void multiple_cygwin_problem (const char *, uintptr_t, uintptr_t);
|
2000-09-08 10:56:55 +08:00
|
|
|
|
forkables: On fork failure, retry with hardlinks.
To support in-cygwin package managers, the fork() implementation must
not rely on .exe and .dll files to stay in their original location, as
the package manager's job is to replace these files. Instead, when the
first fork try fails, and we have NTFS, we use hardlinks to the original
binaries in /var/run/cygfork/ to create the child process during the
second fork try, along the main.exe.local file to enable the "DotLocal
Dll Redirection" feature for the dlls.
The (probably few) users that need an update-safe fork manually have to
create the /var/run/cygfork/ directory for now, using:
mkdir --mode=a=rwxt /var/run/cygfork
* child_info.h: Bump CURR_CHILD_INFO_MAGIC.
(enum child_status): Add _CI_SILENTFAIL flag.
(struct child_info): Add silentfail setter and getter.
* winsup.h (child_copy): Add bool silentfail parameter.
* cygheap.cc: Pass silentfail parameter to child_copy.
* dcrt0.cc: Ditto.
* dll_init.h (struct dll): Define public inline method forkedntname.
(struct dll_list): Declare private method find_by_forkedntname.
* dll_init.cc (struct dll_list): Implement find_by_forkedntname.
(dll_list::alloc): Use find_by_forkedntname when in load after fork.
(dll_list::load_after_fork_impl): Load dlls using dll::forkedntname.
* fork.cc (frok::parent): Set silentfail child info flag. Pass
silentfail parameter to child_copy. Use forkedntname of
dlls.main_executable.
(fork): When first dofork run failed and did not use forkables,
run dofork again with_forkables set to true.
(child_copy): Use debug_printf if silentfail is true,
system_printf otherwise.
2016-12-07 18:58:28 +08:00
|
|
|
bool child_copy (HANDLE, bool, bool, ...);
|
2005-05-11 04:56:07 +08:00
|
|
|
|
2003-11-06 21:58:45 +08:00
|
|
|
class path_conv;
|
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
int __reg2 stat_worker (path_conv &pc, struct stat *buf);
|
2003-12-03 17:55:42 +08:00
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
ino_t __reg2 readdir_get_ino (const char *path, bool dot_dot);
|
2006-01-28 05:50:42 +08:00
|
|
|
|
2005-12-07 19:16:47 +08:00
|
|
|
/* mmap functions. */
|
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
2006-07-26 03:23:23 +08:00
|
|
|
enum mmap_region_status
|
|
|
|
{
|
|
|
|
MMAP_NONE,
|
|
|
|
MMAP_RAISE_SIGBUS,
|
|
|
|
MMAP_NORESERVE_COMMITED
|
|
|
|
};
|
|
|
|
mmap_region_status mmap_is_attached_or_noreserve (void *addr, size_t len);
|
2011-05-16 17:55:18 +08:00
|
|
|
bool is_mmapped_region (caddr_t start_addr, caddr_t end_address);
|
2003-11-06 22:33:16 +08:00
|
|
|
|
2012-12-22 05:30:56 +08:00
|
|
|
extern inline bool flush_file_buffers (HANDLE h)
|
2005-12-21 04:34:28 +08:00
|
|
|
{
|
|
|
|
return (GetFileType (h) != FILE_TYPE_PIPE) ? FlushFileBuffers (h) : true;
|
|
|
|
}
|
2005-12-21 04:19:55 +08:00
|
|
|
#define FlushFileBuffers flush_file_buffers
|
2005-08-19 22:56:48 +08:00
|
|
|
|
2012-12-22 05:30:56 +08:00
|
|
|
/* Make sure that regular ExitThread is never called */
|
|
|
|
#define ExitThread exit_thread
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/*************************** Unsorted ******************************/
|
|
|
|
|
|
|
|
#define WM_ASYNCIO 0x8000 // WM_APP
|
|
|
|
|
|
|
|
|
2000-04-08 12:13:12 +08:00
|
|
|
#define STD_RBITS (S_IRUSR | S_IRGRP | S_IROTH)
|
|
|
|
#define STD_WBITS (S_IWUSR)
|
|
|
|
#define STD_XBITS (S_IXUSR | S_IXGRP | S_IXOTH)
|
2002-05-02 12:13:48 +08:00
|
|
|
#define NO_W ~(S_IWUSR | S_IWGRP | S_IWOTH)
|
|
|
|
#define NO_R ~(S_IRUSR | S_IRGRP | S_IROTH)
|
|
|
|
#define NO_X ~(S_IXUSR | S_IXGRP | S_IXOTH)
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
#ifdef __x86_64__
|
|
|
|
extern "C" char __data_start__, __data_end__, __bss_start__, __bss_end__;
|
|
|
|
#else
|
2009-01-03 13:12:22 +08:00
|
|
|
extern "C" char _data_start__, _data_end__, _bss_start__, _bss_end__;
|
2013-04-23 17:44:36 +08:00
|
|
|
#endif
|
2009-01-03 13:12:22 +08:00
|
|
|
extern "C" void (*__CTOR_LIST__) (void);
|
|
|
|
extern "C" void (*__DTOR_LIST__) (void);
|
2006-12-13 00:27:32 +08:00
|
|
|
|
2014-02-12 02:41:36 +08:00
|
|
|
#ifdef NEEDED
|
|
|
|
/* This was inexplicably needed after updating a toolchain.
|
|
|
|
The need disappeared when updating further but I'm keeping
|
|
|
|
it around temporarily in case the issue crops up again.
|
|
|
|
This manifests as SEGVs in one of the Interlocked functions below
|
|
|
|
in kernel32.dll. */
|
2014-02-11 14:27:57 +08:00
|
|
|
#define InterlockedDecrement _InterlockedDecrement
|
|
|
|
#define InterlockedExchange _InterlockedExchange
|
|
|
|
#define InterlockedIncrement _InterlockedIncrement
|
2014-02-12 02:41:36 +08:00
|
|
|
#endif /*NEEDED*/
|
2014-02-11 14:27:57 +08:00
|
|
|
|
2012-03-20 01:49:40 +08:00
|
|
|
#ifndef NO_GLOBALS_H
|
2013-04-23 17:44:36 +08:00
|
|
|
#define _RDATA /* See globals.h */
|
2009-01-03 13:12:22 +08:00
|
|
|
#include "globals.h"
|
2012-03-20 01:49:40 +08:00
|
|
|
|
|
|
|
extern inline void clear_procimptoken ()
|
2006-12-13 00:27:32 +08:00
|
|
|
{
|
|
|
|
if (hProcImpToken)
|
|
|
|
{
|
2006-12-13 19:18:39 +08:00
|
|
|
HANDLE old_procimp = hProcImpToken;
|
2006-12-13 00:27:32 +08:00
|
|
|
hProcImpToken = NULL;
|
2006-12-13 19:18:39 +08:00
|
|
|
CloseHandle (old_procimp);
|
2006-12-13 00:27:32 +08:00
|
|
|
}
|
|
|
|
}
|
2012-03-20 01:49:40 +08:00
|
|
|
#endif /*NO_GLOBALS_H*/
|
2000-08-03 00:28:18 +08:00
|
|
|
#endif /* defined __cplusplus */
|