2001-03-06 05:29:24 +08:00
|
|
|
/* sys/cygwin.h
|
|
|
|
|
2013-01-21 12:38:31 +08:00
|
|
|
Copyright 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
|
2014-02-19 03:39:48 +08:00
|
|
|
2009, 2010, 2011, 2012, 2013, 2014 Red Hat, Inc.
|
2001-03-06 05:29:24 +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. */
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
#ifndef _SYS_CYGWIN_H
|
|
|
|
#define _SYS_CYGWIN_H
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
2007-12-07 17:37:14 +08:00
|
|
|
#include <limits.h>
|
2013-04-23 17:44:36 +08:00
|
|
|
#include <stdint.h>
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2005-11-01 13:55:30 +08:00
|
|
|
#define _CYGWIN_SIGNAL_STRING "cYgSiGw00f"
|
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
#ifndef __x86_64__
|
2008-03-12 20:41:50 +08:00
|
|
|
/* DEPRECATED INTERFACES. These are restricted to MAX_PATH length.
|
2013-04-23 17:44:36 +08:00
|
|
|
Don't use in modern applications. They don't exist on x86_64. */
|
2008-03-12 20:41:50 +08:00
|
|
|
extern int cygwin_win32_to_posix_path_list (const char *, char *)
|
2014-08-01 23:48:37 +08:00
|
|
|
__attribute__ ((__deprecated__));
|
2008-03-12 20:41:50 +08:00
|
|
|
extern int cygwin_win32_to_posix_path_list_buf_size (const char *)
|
2014-08-01 23:48:37 +08:00
|
|
|
__attribute__ ((__deprecated__));
|
2008-03-12 20:41:50 +08:00
|
|
|
extern int cygwin_posix_to_win32_path_list (const char *, char *)
|
2014-08-01 23:48:37 +08:00
|
|
|
__attribute__ ((__deprecated__));
|
2008-03-12 20:41:50 +08:00
|
|
|
extern int cygwin_posix_to_win32_path_list_buf_size (const char *)
|
2014-08-01 23:48:37 +08:00
|
|
|
__attribute__ ((__deprecated__));
|
2008-03-12 20:41:50 +08:00
|
|
|
extern int cygwin_conv_to_win32_path (const char *, char *)
|
2014-08-01 23:48:37 +08:00
|
|
|
__attribute__ ((__deprecated__));
|
2008-03-12 20:41:50 +08:00
|
|
|
extern int cygwin_conv_to_full_win32_path (const char *, char *)
|
2014-08-01 23:48:37 +08:00
|
|
|
__attribute__ ((__deprecated__));
|
2008-03-12 20:41:50 +08:00
|
|
|
extern int cygwin_conv_to_posix_path (const char *, char *)
|
2014-08-01 23:48:37 +08:00
|
|
|
__attribute__ ((__deprecated__));
|
2008-03-12 20:41:50 +08:00
|
|
|
extern int cygwin_conv_to_full_posix_path (const char *, char *)
|
2014-08-01 23:48:37 +08:00
|
|
|
__attribute__ ((__deprecated__));
|
2013-04-23 17:44:36 +08:00
|
|
|
#endif /* !__x86_64__ */
|
2008-03-12 20:41:50 +08:00
|
|
|
|
|
|
|
/* Use these interfaces in favor of the above. */
|
|
|
|
|
|
|
|
/* Possible 'what' values in calls to cygwin_conv_path/cygwin_create_path. */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
CCP_POSIX_TO_WIN_A = 0, /* from is char*, to is char* */
|
|
|
|
CCP_POSIX_TO_WIN_W, /* from is char*, to is wchar_t* */
|
|
|
|
CCP_WIN_A_TO_POSIX, /* from is char*, to is char* */
|
|
|
|
CCP_WIN_W_TO_POSIX, /* from is wchar_t*, to is char* */
|
|
|
|
|
2011-12-03 00:06:10 +08:00
|
|
|
CCP_CONVTYPE_MASK = 3,
|
|
|
|
|
2008-03-12 20:41:50 +08:00
|
|
|
/* Or these values to the above as needed. */
|
|
|
|
CCP_ABSOLUTE = 0, /* Request absolute path (default). */
|
|
|
|
CCP_RELATIVE = 0x100 /* Request to keep path relative. */
|
|
|
|
};
|
|
|
|
typedef unsigned int cygwin_conv_path_t;
|
|
|
|
|
|
|
|
/* If size is 0, cygwin_conv_path returns the required buffer size in bytes.
|
|
|
|
Otherwise, it returns 0 on success, or -1 on error and errno is set to
|
|
|
|
one of the below values:
|
|
|
|
|
|
|
|
EINVAL what has an invalid value.
|
|
|
|
EFAULT from or to point into nirvana.
|
|
|
|
ENAMETOOLONG the resulting path is longer than 32K, or, in case
|
|
|
|
of what == CCP_POSIX_TO_WIN_A, longer than MAX_PATH.
|
|
|
|
ENOSPC size is less than required for the conversion.
|
|
|
|
*/
|
|
|
|
extern ssize_t cygwin_conv_path (cygwin_conv_path_t what, const void *from,
|
|
|
|
void *to, size_t size);
|
|
|
|
/* Same, but handles path lists separated by colon or semicolon. */
|
|
|
|
extern ssize_t cygwin_conv_path_list (cygwin_conv_path_t what, const void *from,
|
|
|
|
void *to, size_t size);
|
|
|
|
/* Allocate a buffer for the conversion result using malloc(3), and return
|
|
|
|
a pointer to it. Returns NULL if something goes wrong with errno set
|
|
|
|
to one of the above values, or to ENOMEM if malloc fails. */
|
|
|
|
extern void *cygwin_create_path (cygwin_conv_path_t what, const void *from);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
extern pid_t cygwin_winpid_to_pid (int);
|
|
|
|
extern int cygwin_posix_path_list_p (const char *);
|
|
|
|
extern void cygwin_split_path (const char *, char *, char *);
|
|
|
|
|
2000-07-09 13:29:51 +08:00
|
|
|
struct __cygwin_perfile
|
|
|
|
{
|
2000-11-03 12:27:03 +08:00
|
|
|
const char *name;
|
2000-07-09 13:29:51 +08:00
|
|
|
unsigned flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* External interface stuff */
|
|
|
|
|
2005-03-23 03:00:31 +08:00
|
|
|
/* Always add at the bottom. Do not add new values in the middle. */
|
2003-09-17 09:43:27 +08:00
|
|
|
typedef enum
|
2000-07-09 13:29:51 +08:00
|
|
|
{
|
|
|
|
CW_LOCK_PINFO,
|
|
|
|
CW_UNLOCK_PINFO,
|
|
|
|
CW_GETTHREADNAME,
|
|
|
|
CW_GETPINFO,
|
|
|
|
CW_SETPINFO,
|
|
|
|
CW_SETTHREADNAME,
|
|
|
|
CW_GETVERSIONINFO,
|
|
|
|
CW_READ_V1_MOUNT_TABLES,
|
|
|
|
CW_USER_DATA,
|
2000-07-29 06:33:43 +08:00
|
|
|
CW_PERFILE,
|
2000-07-30 00:24:59 +08:00
|
|
|
CW_GET_CYGDRIVE_PREFIXES,
|
2000-08-25 10:27:42 +08:00
|
|
|
CW_GETPINFO_FULL,
|
2000-11-09 04:36:37 +08:00
|
|
|
CW_INIT_EXCEPTIONS,
|
2001-10-25 05:56:54 +08:00
|
|
|
CW_GET_CYGDRIVE_INFO,
|
|
|
|
CW_SET_CYGWIN_REGISTRY_NAME,
|
2002-01-29 10:02:03 +08:00
|
|
|
CW_GET_CYGWIN_REGISTRY_NAME,
|
2002-02-15 05:20:06 +08:00
|
|
|
CW_STRACE_TOGGLE,
|
2002-02-15 05:31:23 +08:00
|
|
|
CW_STRACE_ACTIVE,
|
2002-06-04 01:56:10 +08:00
|
|
|
CW_CYGWIN_PID_TO_WINPID,
|
2002-10-31 05:05:18 +08:00
|
|
|
CW_EXTRACT_DOMAIN_AND_USER,
|
2003-04-03 16:04:41 +08:00
|
|
|
CW_CMDLINE,
|
2003-10-23 04:32:20 +08:00
|
|
|
CW_CHECK_NTSEC,
|
2003-11-04 23:48:19 +08:00
|
|
|
CW_GET_ERRNO_FROM_WINERROR,
|
2003-11-06 22:33:16 +08:00
|
|
|
CW_GET_POSIX_SECURITY_ATTRIBUTE,
|
2003-11-08 17:48:48 +08:00
|
|
|
CW_GET_SHMLBA,
|
|
|
|
CW_GET_UID_FROM_SID,
|
2004-02-25 09:19:13 +08:00
|
|
|
CW_GET_GID_FROM_SID,
|
2005-03-23 03:00:31 +08:00
|
|
|
CW_GET_BINMODE,
|
2005-05-09 09:19:38 +08:00
|
|
|
CW_HOOK,
|
|
|
|
CW_ARGV,
|
2005-05-17 09:21:06 +08:00
|
|
|
CW_ENVP,
|
2006-02-03 03:55:45 +08:00
|
|
|
CW_DEBUG_SELF,
|
2006-05-25 10:33:13 +08:00
|
|
|
CW_SYNC_WINENV,
|
2007-03-30 21:36:06 +08:00
|
|
|
CW_CYGTLS_PADSIZE,
|
2008-11-26 18:18:10 +08:00
|
|
|
CW_SET_DOS_FILE_WARNING,
|
2009-01-09 13:18:02 +08:00
|
|
|
CW_SET_PRIV_KEY,
|
2009-10-07 05:51:17 +08:00
|
|
|
CW_SETERRNO,
|
2009-10-13 18:23:31 +08:00
|
|
|
CW_EXIT_PROCESS,
|
2009-10-31 21:24:06 +08:00
|
|
|
CW_SET_EXTERNAL_TOKEN,
|
2010-02-08 17:52:40 +08:00
|
|
|
CW_GET_INSTKEY,
|
2010-04-29 16:47:44 +08:00
|
|
|
CW_INT_SETLOCALE,
|
|
|
|
CW_CVT_MNT_OPTS,
|
2010-07-05 01:12:27 +08:00
|
|
|
CW_LST_MNT_OPTS,
|
2011-10-05 20:27:37 +08:00
|
|
|
CW_STRERROR,
|
2011-12-22 20:25:10 +08:00
|
|
|
CW_CVT_ENV_TO_WINENV,
|
|
|
|
CW_ALLOC_DRIVE_MAP,
|
|
|
|
CW_MAP_DRIVE_MAP,
|
2014-02-19 03:39:48 +08:00
|
|
|
CW_FREE_DRIVE_MAP,
|
|
|
|
CW_SETENT,
|
|
|
|
CW_GETENT,
|
2014-02-23 03:38:12 +08:00
|
|
|
CW_ENDENT,
|
|
|
|
CW_GETNSSSEP,
|
|
|
|
CW_GETPWSID,
|
2014-05-15 19:16:28 +08:00
|
|
|
CW_GETGRSID,
|
|
|
|
CW_CYGNAME_FROM_WINNAME
|
2000-07-09 13:29:51 +08:00
|
|
|
} cygwin_getinfo_types;
|
|
|
|
|
2011-10-07 21:49:17 +08:00
|
|
|
#define CW_LOCK_PINFO CW_LOCK_PINFO
|
|
|
|
#define CW_UNLOCK_PINFO CW_UNLOCK_PINFO
|
|
|
|
#define CW_GETTHREADNAME CW_GETTHREADNAME
|
|
|
|
#define CW_GETPINFO CW_GETPINFO
|
|
|
|
#define CW_SETPINFO CW_SETPINFO
|
|
|
|
#define CW_SETTHREADNAME CW_SETTHREADNAME
|
|
|
|
#define CW_GETVERSIONINFO CW_GETVERSIONINFO
|
|
|
|
#define CW_READ_V1_MOUNT_TABLES CW_READ_V1_MOUNT_TABLES
|
|
|
|
#define CW_USER_DATA CW_USER_DATA
|
|
|
|
#define CW_PERFILE CW_PERFILE
|
|
|
|
#define CW_GET_CYGDRIVE_PREFIXES CW_GET_CYGDRIVE_PREFIXES
|
|
|
|
#define CW_GETPINFO_FULL CW_GETPINFO_FULL
|
|
|
|
#define CW_INIT_EXCEPTIONS CW_INIT_EXCEPTIONS
|
|
|
|
#define CW_GET_CYGDRIVE_INFO CW_GET_CYGDRIVE_INFO
|
|
|
|
#define CW_SET_CYGWIN_REGISTRY_NAME CW_SET_CYGWIN_REGISTRY_NAME
|
|
|
|
#define CW_GET_CYGWIN_REGISTRY_NAME CW_GET_CYGWIN_REGISTRY_NAME
|
|
|
|
#define CW_STRACE_TOGGLE CW_STRACE_TOGGLE
|
|
|
|
#define CW_STRACE_ACTIVE CW_STRACE_ACTIVE
|
|
|
|
#define CW_CYGWIN_PID_TO_WINPID CW_CYGWIN_PID_TO_WINPID
|
|
|
|
#define CW_EXTRACT_DOMAIN_AND_USER CW_EXTRACT_DOMAIN_AND_USER
|
|
|
|
#define CW_CMDLINE CW_CMDLINE
|
|
|
|
#define CW_CHECK_NTSEC CW_CHECK_NTSEC
|
|
|
|
#define CW_GET_ERRNO_FROM_WINERROR CW_GET_ERRNO_FROM_WINERROR
|
|
|
|
#define CW_GET_POSIX_SECURITY_ATTRIBUTE CW_GET_POSIX_SECURITY_ATTRIBUTE
|
|
|
|
#define CW_GET_SHMLBA CW_GET_SHMLBA
|
|
|
|
#define CW_GET_UID_FROM_SID CW_GET_UID_FROM_SID
|
|
|
|
#define CW_GET_GID_FROM_SID CW_GET_GID_FROM_SID
|
|
|
|
#define CW_GET_BINMODE CW_GET_BINMODE
|
|
|
|
#define CW_HOOK CW_HOOK
|
|
|
|
#define CW_ARGV CW_ARGV
|
|
|
|
#define CW_ENVP CW_ENVP
|
|
|
|
#define CW_DEBUG_SELF CW_DEBUG_SELF
|
|
|
|
#define CW_SYNC_WINENV CW_SYNC_WINENV
|
|
|
|
#define CW_CYGTLS_PADSIZE CW_CYGTLS_PADSIZE
|
|
|
|
#define CW_SET_DOS_FILE_WARNING CW_SET_DOS_FILE_WARNING
|
|
|
|
#define CW_SET_PRIV_KEY CW_SET_PRIV_KEY
|
|
|
|
#define CW_SETERRNO CW_SETERRNO
|
|
|
|
#define CW_EXIT_PROCESS CW_EXIT_PROCESS
|
|
|
|
#define CW_SET_EXTERNAL_TOKEN CW_SET_EXTERNAL_TOKEN
|
|
|
|
#define CW_GET_INSTKEY CW_GET_INSTKEY
|
|
|
|
#define CW_INT_SETLOCALE CW_INT_SETLOCALE
|
|
|
|
#define CW_CVT_MNT_OPTS CW_CVT_MNT_OPTS
|
|
|
|
#define CW_LST_MNT_OPTS CW_LST_MNT_OPTS
|
|
|
|
#define CW_STRERROR CW_STRERROR
|
|
|
|
#define CW_CVT_ENV_TO_WINENV CW_CVT_ENV_TO_WINENV
|
2012-10-30 18:32:46 +08:00
|
|
|
#define CW_ALLOC_DRIVE_MAP CW_ALLOC_DRIVE_MAP
|
|
|
|
#define CW_MAP_DRIVE_MAP CW_MAP_DRIVE_MAP
|
|
|
|
#define CW_FREE_DRIVE_MAP CW_FREE_DRIVE_MAP
|
2014-02-19 03:39:48 +08:00
|
|
|
#define CW_SETENT CW_SETENT
|
|
|
|
#define CW_GETENT CW_GETENT
|
|
|
|
#define CW_ENDENT CW_ENDENT
|
2014-02-23 03:38:12 +08:00
|
|
|
#define CW_GETNSSSEP CW_GETNSSSEP
|
|
|
|
#define CW_GETPWSID CW_GETPWSID
|
|
|
|
#define CW_GETGRSID CW_GETGRSID
|
2014-05-15 19:16:28 +08:00
|
|
|
#define CW_CYGNAME_FROM_WINNAME CW_CYGNAME_FROM_WINNAME
|
2011-10-07 21:49:17 +08:00
|
|
|
|
2009-10-13 18:23:31 +08:00
|
|
|
/* Token type for CW_SET_EXTERNAL_TOKEN */
|
|
|
|
enum
|
|
|
|
{
|
2014-03-13 01:36:56 +08:00
|
|
|
CW_TOKEN_IMPERSONATION = 0,
|
|
|
|
CW_TOKEN_RESTRICTED = 1
|
2009-10-13 18:23:31 +08:00
|
|
|
};
|
|
|
|
|
2014-02-23 03:38:12 +08:00
|
|
|
/* Enumeration source constants for CW_SETENT called from mkpasswd/mkgroup. */
|
|
|
|
enum nss_enum_t
|
|
|
|
{
|
|
|
|
ENUM_NONE = 0x00,
|
|
|
|
ENUM_CACHE = 0x01,
|
|
|
|
ENUM_FILES = 0x02,
|
|
|
|
ENUM_BUILTIN = 0x04,
|
|
|
|
ENUM_LOCAL = 0x08,
|
|
|
|
ENUM_PRIMARY = 0x10,
|
|
|
|
ENUM_TDOMS = 0x20,
|
|
|
|
ENUM_TDOMS_ALL = 0x40,
|
|
|
|
ENUM_ALL = 0x7f
|
|
|
|
};
|
|
|
|
|
2003-02-05 22:14:26 +08:00
|
|
|
#define CW_NEXTPID 0x80000000 /* or with pid to get next one */
|
2013-04-23 17:44:36 +08:00
|
|
|
uintptr_t cygwin_internal (cygwin_getinfo_types, ...);
|
2000-07-09 13:29:51 +08:00
|
|
|
|
|
|
|
/* Flags associated with process_state */
|
|
|
|
enum
|
|
|
|
{
|
2004-12-06 03:41:26 +08:00
|
|
|
PID_IN_USE = 0x00001, /* Entry in use. */
|
2005-01-17 01:00:27 +08:00
|
|
|
PID_UNUSED = 0x00002, /* Available. */
|
2004-12-06 03:41:26 +08:00
|
|
|
PID_STOPPED = 0x00004, /* Waiting for SIGCONT. */
|
|
|
|
PID_TTYIN = 0x00008, /* Waiting for terminal input. */
|
|
|
|
PID_TTYOU = 0x00010, /* Waiting for terminal output. */
|
2010-09-29 11:57:24 +08:00
|
|
|
PID_NOTCYGWIN = 0x00020, /* Set if process is not a cygwin app. */
|
2004-12-06 03:41:26 +08:00
|
|
|
PID_ACTIVE = 0x00040, /* Pid accepts signals. */
|
|
|
|
PID_CYGPARENT = 0x00080, /* Set if parent was a cygwin app. */
|
|
|
|
PID_MAP_RW = 0x00100, /* Flag to open map rw. */
|
|
|
|
PID_MYSELF = 0x00200, /* Flag that pid is me. */
|
|
|
|
PID_NOCLDSTOP = 0x00400, /* Set if no SIGCHLD signal on stop. */
|
|
|
|
PID_INITIALIZING = 0x00800, /* Set until ready to receive signals. */
|
2013-12-18 11:58:11 +08:00
|
|
|
PID_NEW = 0x01000, /* Available. */
|
2004-12-06 03:41:26 +08:00
|
|
|
PID_ALLPIDS = 0x02000, /* used by pinfo scanner */
|
|
|
|
PID_EXECED = 0x04000, /* redirect to original pid info block */
|
|
|
|
PID_NOREDIR = 0x08000, /* don't redirect if execed */
|
2011-05-05 08:31:22 +08:00
|
|
|
PID_EXITED = 0x40000000, /* Free entry. */
|
|
|
|
PID_REAPED = 0x80000000 /* Reaped */
|
2000-07-09 13:29:51 +08:00
|
|
|
};
|
|
|
|
|
2008-03-18 17:57:33 +08:00
|
|
|
#ifdef WINVER
|
|
|
|
|
2000-07-01 11:51:55 +08:00
|
|
|
/* This lives in the app and is initialized before jumping into the DLL.
|
|
|
|
It should only contain stuff which the user's process needs to see, or
|
|
|
|
which is needed before the user pointer is initialized, or is needed to
|
|
|
|
carry inheritance information from parent to child. Note that it cannot
|
|
|
|
be used to carry inheritance information across exec!
|
|
|
|
|
|
|
|
Remember, this structure is linked into the application's executable.
|
|
|
|
Changes to this can invalidate existing executables, so we go to extra
|
|
|
|
lengths to avoid having to do it.
|
|
|
|
|
|
|
|
When adding/deleting members, remember to adjust {public,internal}_reserved.
|
|
|
|
The size of the class shouldn't change [unless you really are prepared to
|
|
|
|
invalidate all existing executables]. The program does a check (using
|
|
|
|
SIZEOF_PER_PROCESS) to make sure you remember to make the adjustment.
|
|
|
|
*/
|
|
|
|
|
2000-08-23 22:53:25 +08:00
|
|
|
#ifdef __cplusplus
|
2000-08-22 23:12:29 +08:00
|
|
|
class MTinterface;
|
2000-08-23 22:53:25 +08:00
|
|
|
#endif
|
2000-08-22 23:12:29 +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
|
|
|
struct per_process_cxx_malloc;
|
|
|
|
|
2000-07-06 07:46:44 +08:00
|
|
|
struct per_process
|
2000-07-01 11:51:55 +08:00
|
|
|
{
|
|
|
|
char *initial_sp;
|
|
|
|
|
|
|
|
/* The offset of these 3 values can never change. */
|
|
|
|
/* magic_biscuit is the size of this class and should never change. */
|
2013-04-23 17:44:36 +08:00
|
|
|
uint32_t magic_biscuit;
|
|
|
|
uint32_t dll_major;
|
|
|
|
uint32_t dll_minor;
|
2000-07-01 11:51:55 +08:00
|
|
|
|
|
|
|
struct _reent **impure_ptr_ptr;
|
2013-04-23 17:44:36 +08:00
|
|
|
#ifndef __x86_64__
|
2000-07-01 11:51:55 +08:00
|
|
|
char ***envptr;
|
2013-04-23 17:44:36 +08:00
|
|
|
#endif
|
2000-07-01 11:51:55 +08:00
|
|
|
|
|
|
|
/* Used to point to the memory machine we should use. Usually these
|
|
|
|
point back into the dll, but they can be overridden by the user. */
|
|
|
|
void *(*malloc)(size_t);
|
|
|
|
void (*free)(void *);
|
|
|
|
void *(*realloc)(void *, size_t);
|
|
|
|
|
|
|
|
int *fmode_ptr;
|
|
|
|
|
|
|
|
int (*main)(int, char **, char **);
|
|
|
|
void (**ctors)(void);
|
|
|
|
void (**dtors)(void);
|
|
|
|
|
|
|
|
/* For fork */
|
|
|
|
void *data_start;
|
|
|
|
void *data_end;
|
|
|
|
void *bss_start;
|
|
|
|
void *bss_end;
|
|
|
|
|
|
|
|
void *(*calloc)(size_t, size_t);
|
|
|
|
/* For future expansion of values set by the app. */
|
2001-03-05 14:28:25 +08:00
|
|
|
void (*premain[4]) (int, char **, struct per_process *);
|
2000-07-01 11:51:55 +08:00
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
/* non-zero if ctors have been run. Inherited from parent. */
|
|
|
|
int32_t run_ctors_p;
|
2000-07-01 11:51:55 +08:00
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
DWORD_PTR unused[7];
|
2000-07-01 11:51:55 +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
|
|
|
/* Pointers to real operator new/delete functions for forwarding. */
|
|
|
|
struct per_process_cxx_malloc *cxx_malloc;
|
2000-07-01 11:51:55 +08:00
|
|
|
|
|
|
|
HMODULE hmodule;
|
|
|
|
|
|
|
|
DWORD api_major; /* API version that this program was */
|
|
|
|
DWORD api_minor; /* linked with */
|
|
|
|
/* For future expansion, so apps won't have to be relinked if we
|
|
|
|
add an item. */
|
2013-04-23 17:44:36 +08:00
|
|
|
#ifdef __x86_64__
|
2013-08-14 19:44:23 +08:00
|
|
|
DWORD_PTR unused2[4];
|
2013-04-23 17:44:36 +08:00
|
|
|
#else
|
2013-08-14 19:44:23 +08:00
|
|
|
DWORD_PTR unused2[2];
|
2013-04-23 17:44:36 +08:00
|
|
|
#endif
|
2013-08-14 19:44:23 +08:00
|
|
|
|
|
|
|
int (*posix_memalign)(void **, size_t, size_t);
|
|
|
|
|
2010-05-08 05:25:19 +08:00
|
|
|
void *pseudo_reloc_start;
|
|
|
|
void *pseudo_reloc_end;
|
|
|
|
void *image_base;
|
2000-07-06 07:46:44 +08:00
|
|
|
|
2003-03-10 05:51:00 +08:00
|
|
|
#if defined (__INSIDE_CYGWIN__) && defined (__cplusplus)
|
2000-07-01 11:51:55 +08:00
|
|
|
MTinterface *threadinterface;
|
2000-07-07 16:35:31 +08:00
|
|
|
#else
|
|
|
|
void *threadinterface;
|
|
|
|
#endif
|
2000-07-06 07:46:44 +08:00
|
|
|
struct _reent *impure_ptr;
|
2000-07-01 11:51:55 +08:00
|
|
|
};
|
2013-04-23 17:44:36 +08:00
|
|
|
#define per_process_overwrite offsetof (struct per_process, threadinterface)
|
2000-07-01 11:51:55 +08:00
|
|
|
|
2008-03-13 23:18:10 +08:00
|
|
|
#ifdef _PATH_PASSWD
|
|
|
|
extern HANDLE cygwin_logon_user (const struct passwd *, const char *);
|
|
|
|
#endif
|
2000-06-23 05:05:46 +08:00
|
|
|
extern void cygwin_set_impersonation_token (const HANDLE);
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* included if <windows.h> is included */
|
2000-06-23 05:51:48 +08:00
|
|
|
extern int cygwin_attach_handle_to_fd (char *, int, HANDLE, mode_t, DWORD);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2010-08-30 09:57:37 +08:00
|
|
|
extern void cygwin_premain0 (int, char **, struct per_process *);
|
|
|
|
extern void cygwin_premain1 (int, char **, struct per_process *);
|
|
|
|
extern void cygwin_premain2 (int, char **, struct per_process *);
|
|
|
|
extern void cygwin_premain3 (int, char **, struct per_process *);
|
|
|
|
|
2003-09-01 10:26:27 +08:00
|
|
|
#ifdef __CYGWIN__
|
2000-05-19 02:32:05 +08:00
|
|
|
#include <sys/resource.h>
|
|
|
|
|
2001-04-29 07:48:28 +08:00
|
|
|
#define TTY_CONSOLE 0x40000000
|
|
|
|
|
2002-05-30 04:07:54 +08:00
|
|
|
#define EXTERNAL_PINFO_VERSION_16_BIT 0
|
|
|
|
#define EXTERNAL_PINFO_VERSION_32_BIT 1
|
2007-12-07 02:24:06 +08:00
|
|
|
#define EXTERNAL_PINFO_VERSION_32_LP 2
|
|
|
|
#define EXTERNAL_PINFO_VERSION EXTERNAL_PINFO_VERSION_32_LP
|
2002-05-30 01:12:07 +08:00
|
|
|
|
2013-04-23 17:44:36 +08:00
|
|
|
#ifndef __uid_t_defined
|
|
|
|
typedef __uint16_t __uid16_t;
|
|
|
|
typedef __uint16_t __gid16_t;
|
|
|
|
typedef __uint32_t uid_t;
|
|
|
|
typedef __uint32_t gid_t;
|
2002-01-29 10:02:03 +08:00
|
|
|
#endif
|
|
|
|
|
2000-05-19 02:32:05 +08:00
|
|
|
struct external_pinfo
|
|
|
|
{
|
|
|
|
pid_t pid;
|
|
|
|
pid_t ppid;
|
2004-11-26 12:15:10 +08:00
|
|
|
DWORD exitcode;
|
2000-05-19 02:32:05 +08:00
|
|
|
DWORD dwProcessId, dwSpawnedProcessId;
|
2002-02-10 04:39:55 +08:00
|
|
|
__uid16_t uid;
|
|
|
|
__gid16_t gid;
|
2000-05-19 02:32:05 +08:00
|
|
|
pid_t pgid;
|
|
|
|
pid_t sid;
|
|
|
|
int ctty;
|
|
|
|
mode_t umask;
|
|
|
|
|
|
|
|
long start_time;
|
|
|
|
struct rusage rusage_self;
|
|
|
|
struct rusage rusage_children;
|
|
|
|
|
|
|
|
char progname[MAX_PATH];
|
|
|
|
|
|
|
|
DWORD strace_mask;
|
2002-05-30 01:12:07 +08:00
|
|
|
DWORD version;
|
2000-05-19 02:32:05 +08:00
|
|
|
|
|
|
|
DWORD process_state;
|
2002-05-29 23:04:29 +08:00
|
|
|
|
2002-05-30 04:07:54 +08:00
|
|
|
/* Only available if version >= EXTERNAL_PINFO_VERSION_32_BIT */
|
2013-04-23 17:44:36 +08:00
|
|
|
uid_t uid32;
|
|
|
|
gid_t gid32;
|
2007-12-07 02:24:06 +08:00
|
|
|
|
|
|
|
/* Only available if version >= EXTERNAL_PINFO_VERSION_32_LP */
|
2008-02-16 17:37:58 +08:00
|
|
|
char *progname_long;
|
2000-05-19 02:32:05 +08:00
|
|
|
};
|
2003-09-01 10:26:27 +08:00
|
|
|
#endif /*__CYGWIN__*/
|
2000-06-23 04:18:17 +08:00
|
|
|
#endif /*WINVER*/
|
2000-05-19 02:32:05 +08:00
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
#endif /* _SYS_CYGWIN_H */
|