2001-03-05 22:29:24 +01:00
|
|
|
/* sys/cygwin.h
|
|
|
|
|
2013-01-21 05:38:31 +01:00
|
|
|
Copyright 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
|
2014-02-18 20:39:48 +01:00
|
|
|
2009, 2010, 2011, 2012, 2013, 2014 Red Hat, Inc.
|
2001-03-05 22:29:24 +01: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-17 20:38:33 +01:00
|
|
|
#ifndef _SYS_CYGWIN_H
|
|
|
|
#define _SYS_CYGWIN_H
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
2007-12-07 10:37:14 +01:00
|
|
|
#include <limits.h>
|
2013-04-23 11:44:36 +02:00
|
|
|
#include <stdint.h>
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2005-11-01 06:55:30 +01:00
|
|
|
#define _CYGWIN_SIGNAL_STRING "cYgSiGw00f"
|
|
|
|
|
2013-04-23 11:44:36 +02:00
|
|
|
#ifndef __x86_64__
|
2008-03-12 13:41:50 +01:00
|
|
|
/* DEPRECATED INTERFACES. These are restricted to MAX_PATH length.
|
2013-04-23 11:44:36 +02:00
|
|
|
Don't use in modern applications. They don't exist on x86_64. */
|
2008-03-12 13:41:50 +01:00
|
|
|
extern int cygwin_win32_to_posix_path_list (const char *, char *)
|
2014-08-01 17:48:37 +02:00
|
|
|
__attribute__ ((__deprecated__));
|
2008-03-12 13:41:50 +01:00
|
|
|
extern int cygwin_win32_to_posix_path_list_buf_size (const char *)
|
2014-08-01 17:48:37 +02:00
|
|
|
__attribute__ ((__deprecated__));
|
2008-03-12 13:41:50 +01:00
|
|
|
extern int cygwin_posix_to_win32_path_list (const char *, char *)
|
2014-08-01 17:48:37 +02:00
|
|
|
__attribute__ ((__deprecated__));
|
2008-03-12 13:41:50 +01:00
|
|
|
extern int cygwin_posix_to_win32_path_list_buf_size (const char *)
|
2014-08-01 17:48:37 +02:00
|
|
|
__attribute__ ((__deprecated__));
|
2008-03-12 13:41:50 +01:00
|
|
|
extern int cygwin_conv_to_win32_path (const char *, char *)
|
2014-08-01 17:48:37 +02:00
|
|
|
__attribute__ ((__deprecated__));
|
2008-03-12 13:41:50 +01:00
|
|
|
extern int cygwin_conv_to_full_win32_path (const char *, char *)
|
2014-08-01 17:48:37 +02:00
|
|
|
__attribute__ ((__deprecated__));
|
2008-03-12 13:41:50 +01:00
|
|
|
extern int cygwin_conv_to_posix_path (const char *, char *)
|
2014-08-01 17:48:37 +02:00
|
|
|
__attribute__ ((__deprecated__));
|
2008-03-12 13:41:50 +01:00
|
|
|
extern int cygwin_conv_to_full_posix_path (const char *, char *)
|
2014-08-01 17:48:37 +02:00
|
|
|
__attribute__ ((__deprecated__));
|
2013-04-23 11:44:36 +02:00
|
|
|
#endif /* !__x86_64__ */
|
2008-03-12 13:41:50 +01: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-02 17:06:10 +01:00
|
|
|
CCP_CONVTYPE_MASK = 3,
|
|
|
|
|
2008-03-12 13:41:50 +01: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-17 20:38:33 +01: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 07:29:51 +02:00
|
|
|
struct __cygwin_perfile
|
|
|
|
{
|
2000-11-03 05:27:03 +01:00
|
|
|
const char *name;
|
2000-07-09 07:29:51 +02:00
|
|
|
unsigned flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* External interface stuff */
|
|
|
|
|
2005-03-22 20:00:31 +01:00
|
|
|
/* Always add at the bottom. Do not add new values in the middle. */
|
2003-09-17 03:43:27 +02:00
|
|
|
typedef enum
|
2000-07-09 07:29:51 +02: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 00:33:43 +02:00
|
|
|
CW_PERFILE,
|
2000-07-29 18:24:59 +02:00
|
|
|
CW_GET_CYGDRIVE_PREFIXES,
|
2000-08-25 04:27:42 +02:00
|
|
|
CW_GETPINFO_FULL,
|
2000-11-08 21:36:37 +01:00
|
|
|
CW_INIT_EXCEPTIONS,
|
2001-10-24 23:56:54 +02:00
|
|
|
CW_GET_CYGDRIVE_INFO,
|
|
|
|
CW_SET_CYGWIN_REGISTRY_NAME,
|
2002-01-29 03:02:03 +01:00
|
|
|
CW_GET_CYGWIN_REGISTRY_NAME,
|
2002-02-14 22:20:06 +01:00
|
|
|
CW_STRACE_TOGGLE,
|
2002-02-14 22:31:23 +01:00
|
|
|
CW_STRACE_ACTIVE,
|
2002-06-03 19:56:10 +02:00
|
|
|
CW_CYGWIN_PID_TO_WINPID,
|
2002-10-30 22:05:18 +01:00
|
|
|
CW_EXTRACT_DOMAIN_AND_USER,
|
2003-04-03 10:04:41 +02:00
|
|
|
CW_CMDLINE,
|
2003-10-22 22:32:20 +02:00
|
|
|
CW_CHECK_NTSEC,
|
2003-11-04 16:48:19 +01:00
|
|
|
CW_GET_ERRNO_FROM_WINERROR,
|
2003-11-06 15:33:16 +01:00
|
|
|
CW_GET_POSIX_SECURITY_ATTRIBUTE,
|
2003-11-08 10:48:48 +01:00
|
|
|
CW_GET_SHMLBA,
|
|
|
|
CW_GET_UID_FROM_SID,
|
2004-02-25 02:19:13 +01:00
|
|
|
CW_GET_GID_FROM_SID,
|
2005-03-22 20:00:31 +01:00
|
|
|
CW_GET_BINMODE,
|
2005-05-09 03:19:38 +02:00
|
|
|
CW_HOOK,
|
|
|
|
CW_ARGV,
|
2005-05-17 03:21:06 +02:00
|
|
|
CW_ENVP,
|
2006-02-02 20:55:45 +01:00
|
|
|
CW_DEBUG_SELF,
|
2006-05-25 04:33:13 +02:00
|
|
|
CW_SYNC_WINENV,
|
2007-03-30 15:36:06 +02:00
|
|
|
CW_CYGTLS_PADSIZE,
|
2008-11-26 11:18:10 +01:00
|
|
|
CW_SET_DOS_FILE_WARNING,
|
2009-01-09 06:18:02 +01:00
|
|
|
CW_SET_PRIV_KEY,
|
2009-10-06 23:51:17 +02:00
|
|
|
CW_SETERRNO,
|
2009-10-13 12:23:31 +02:00
|
|
|
CW_EXIT_PROCESS,
|
2009-10-31 14:24:06 +01:00
|
|
|
CW_SET_EXTERNAL_TOKEN,
|
2010-02-08 10:52:40 +01:00
|
|
|
CW_GET_INSTKEY,
|
2010-04-29 10:47:44 +02:00
|
|
|
CW_INT_SETLOCALE,
|
|
|
|
CW_CVT_MNT_OPTS,
|
2010-07-04 19:12:27 +02:00
|
|
|
CW_LST_MNT_OPTS,
|
2011-10-05 14:27:37 +02:00
|
|
|
CW_STRERROR,
|
2011-12-22 13:25:10 +01:00
|
|
|
CW_CVT_ENV_TO_WINENV,
|
|
|
|
CW_ALLOC_DRIVE_MAP,
|
|
|
|
CW_MAP_DRIVE_MAP,
|
2014-02-18 20:39:48 +01:00
|
|
|
CW_FREE_DRIVE_MAP,
|
|
|
|
CW_SETENT,
|
|
|
|
CW_GETENT,
|
2014-02-22 20:38:12 +01:00
|
|
|
CW_ENDENT,
|
|
|
|
CW_GETNSSSEP,
|
|
|
|
CW_GETPWSID,
|
2014-05-15 13:16:28 +02:00
|
|
|
CW_GETGRSID,
|
|
|
|
CW_CYGNAME_FROM_WINNAME
|
2000-07-09 07:29:51 +02:00
|
|
|
} cygwin_getinfo_types;
|
|
|
|
|
2011-10-07 15:49:17 +02: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 11:32:46 +01: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-18 20:39:48 +01:00
|
|
|
#define CW_SETENT CW_SETENT
|
|
|
|
#define CW_GETENT CW_GETENT
|
|
|
|
#define CW_ENDENT CW_ENDENT
|
2014-02-22 20:38:12 +01:00
|
|
|
#define CW_GETNSSSEP CW_GETNSSSEP
|
|
|
|
#define CW_GETPWSID CW_GETPWSID
|
|
|
|
#define CW_GETGRSID CW_GETGRSID
|
2014-05-15 13:16:28 +02:00
|
|
|
#define CW_CYGNAME_FROM_WINNAME CW_CYGNAME_FROM_WINNAME
|
2011-10-07 15:49:17 +02:00
|
|
|
|
2009-10-13 12:23:31 +02:00
|
|
|
/* Token type for CW_SET_EXTERNAL_TOKEN */
|
|
|
|
enum
|
|
|
|
{
|
2014-03-12 18:36:56 +01:00
|
|
|
CW_TOKEN_IMPERSONATION = 0,
|
|
|
|
CW_TOKEN_RESTRICTED = 1
|
2009-10-13 12:23:31 +02:00
|
|
|
};
|
|
|
|
|
2014-02-22 20:38:12 +01: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 15:14:26 +01:00
|
|
|
#define CW_NEXTPID 0x80000000 /* or with pid to get next one */
|
2013-04-23 11:44:36 +02:00
|
|
|
uintptr_t cygwin_internal (cygwin_getinfo_types, ...);
|
2000-07-09 07:29:51 +02:00
|
|
|
|
|
|
|
/* Flags associated with process_state */
|
|
|
|
enum
|
|
|
|
{
|
2004-12-05 20:41:26 +01:00
|
|
|
PID_IN_USE = 0x00001, /* Entry in use. */
|
2005-01-16 18:00:27 +01:00
|
|
|
PID_UNUSED = 0x00002, /* Available. */
|
2004-12-05 20:41:26 +01:00
|
|
|
PID_STOPPED = 0x00004, /* Waiting for SIGCONT. */
|
|
|
|
PID_TTYIN = 0x00008, /* Waiting for terminal input. */
|
|
|
|
PID_TTYOU = 0x00010, /* Waiting for terminal output. */
|
2010-09-29 05:57:24 +02:00
|
|
|
PID_NOTCYGWIN = 0x00020, /* Set if process is not a cygwin app. */
|
2004-12-05 20:41:26 +01: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 04:58:11 +01:00
|
|
|
PID_NEW = 0x01000, /* Available. */
|
2004-12-05 20:41:26 +01: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 02:31:22 +02:00
|
|
|
PID_EXITED = 0x40000000, /* Free entry. */
|
|
|
|
PID_REAPED = 0x80000000 /* Reaped */
|
2000-07-09 07:29:51 +02:00
|
|
|
};
|
|
|
|
|
2008-03-18 10:57:33 +01:00
|
|
|
#ifdef WINVER
|
|
|
|
|
2000-07-01 05:51:55 +02: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 16:53:25 +02:00
|
|
|
#ifdef __cplusplus
|
2000-08-22 17:12:29 +02:00
|
|
|
class MTinterface;
|
2000-08-23 16:53:25 +02:00
|
|
|
#endif
|
2000-08-22 17:12:29 +02: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-07 22:12:44 +02:00
|
|
|
struct per_process_cxx_malloc;
|
|
|
|
|
2000-07-06 01:46:44 +02:00
|
|
|
struct per_process
|
2000-07-01 05:51:55 +02: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 11:44:36 +02:00
|
|
|
uint32_t magic_biscuit;
|
|
|
|
uint32_t dll_major;
|
|
|
|
uint32_t dll_minor;
|
2000-07-01 05:51:55 +02:00
|
|
|
|
|
|
|
struct _reent **impure_ptr_ptr;
|
2013-04-23 11:44:36 +02:00
|
|
|
#ifndef __x86_64__
|
2000-07-01 05:51:55 +02:00
|
|
|
char ***envptr;
|
2013-04-23 11:44:36 +02:00
|
|
|
#endif
|
2000-07-01 05:51:55 +02: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 07:28:25 +01:00
|
|
|
void (*premain[4]) (int, char **, struct per_process *);
|
2000-07-01 05:51:55 +02:00
|
|
|
|
2013-04-23 11:44:36 +02:00
|
|
|
/* non-zero if ctors have been run. Inherited from parent. */
|
|
|
|
int32_t run_ctors_p;
|
2000-07-01 05:51:55 +02:00
|
|
|
|
2013-04-23 11:44:36 +02:00
|
|
|
DWORD_PTR unused[7];
|
2000-07-01 05:51:55 +02: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-07 22:12:44 +02:00
|
|
|
/* Pointers to real operator new/delete functions for forwarding. */
|
|
|
|
struct per_process_cxx_malloc *cxx_malloc;
|
2000-07-01 05:51:55 +02: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 11:44:36 +02:00
|
|
|
#ifdef __x86_64__
|
2013-08-14 13:44:23 +02:00
|
|
|
DWORD_PTR unused2[4];
|
2013-04-23 11:44:36 +02:00
|
|
|
#else
|
2013-08-14 13:44:23 +02:00
|
|
|
DWORD_PTR unused2[2];
|
2013-04-23 11:44:36 +02:00
|
|
|
#endif
|
2013-08-14 13:44:23 +02:00
|
|
|
|
|
|
|
int (*posix_memalign)(void **, size_t, size_t);
|
|
|
|
|
2010-05-07 23:25:19 +02:00
|
|
|
void *pseudo_reloc_start;
|
|
|
|
void *pseudo_reloc_end;
|
|
|
|
void *image_base;
|
2000-07-06 01:46:44 +02:00
|
|
|
|
2003-03-09 22:51:00 +01:00
|
|
|
#if defined (__INSIDE_CYGWIN__) && defined (__cplusplus)
|
2000-07-01 05:51:55 +02:00
|
|
|
MTinterface *threadinterface;
|
2000-07-07 10:35:31 +02:00
|
|
|
#else
|
|
|
|
void *threadinterface;
|
|
|
|
#endif
|
2000-07-06 01:46:44 +02:00
|
|
|
struct _reent *impure_ptr;
|
2000-07-01 05:51:55 +02:00
|
|
|
};
|
2013-04-23 11:44:36 +02:00
|
|
|
#define per_process_overwrite offsetof (struct per_process, threadinterface)
|
2000-07-01 05:51:55 +02:00
|
|
|
|
2008-03-13 16:18:10 +01:00
|
|
|
#ifdef _PATH_PASSWD
|
|
|
|
extern HANDLE cygwin_logon_user (const struct passwd *, const char *);
|
|
|
|
#endif
|
2000-06-22 23:05:46 +02:00
|
|
|
extern void cygwin_set_impersonation_token (const HANDLE);
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
/* included if <windows.h> is included */
|
2000-06-22 23:51:48 +02:00
|
|
|
extern int cygwin_attach_handle_to_fd (char *, int, HANDLE, mode_t, DWORD);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
2010-08-30 03:57:37 +02: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 04:26:27 +02:00
|
|
|
#ifdef __CYGWIN__
|
2000-05-18 20:32:05 +02:00
|
|
|
#include <sys/resource.h>
|
|
|
|
|
2001-04-29 01:48:28 +02:00
|
|
|
#define TTY_CONSOLE 0x40000000
|
|
|
|
|
2002-05-29 22:07:54 +02:00
|
|
|
#define EXTERNAL_PINFO_VERSION_16_BIT 0
|
|
|
|
#define EXTERNAL_PINFO_VERSION_32_BIT 1
|
2007-12-06 19:24:06 +01:00
|
|
|
#define EXTERNAL_PINFO_VERSION_32_LP 2
|
|
|
|
#define EXTERNAL_PINFO_VERSION EXTERNAL_PINFO_VERSION_32_LP
|
2002-05-29 19:12:07 +02:00
|
|
|
|
2013-04-23 11:44:36 +02: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 03:02:03 +01:00
|
|
|
#endif
|
|
|
|
|
2000-05-18 20:32:05 +02:00
|
|
|
struct external_pinfo
|
|
|
|
{
|
|
|
|
pid_t pid;
|
|
|
|
pid_t ppid;
|
2004-11-26 05:15:10 +01:00
|
|
|
DWORD exitcode;
|
2000-05-18 20:32:05 +02:00
|
|
|
DWORD dwProcessId, dwSpawnedProcessId;
|
2002-02-09 21:39:55 +01:00
|
|
|
__uid16_t uid;
|
|
|
|
__gid16_t gid;
|
2000-05-18 20:32:05 +02: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-29 19:12:07 +02:00
|
|
|
DWORD version;
|
2000-05-18 20:32:05 +02:00
|
|
|
|
|
|
|
DWORD process_state;
|
2002-05-29 17:04:29 +02:00
|
|
|
|
2002-05-29 22:07:54 +02:00
|
|
|
/* Only available if version >= EXTERNAL_PINFO_VERSION_32_BIT */
|
2013-04-23 11:44:36 +02:00
|
|
|
uid_t uid32;
|
|
|
|
gid_t gid32;
|
2007-12-06 19:24:06 +01:00
|
|
|
|
|
|
|
/* Only available if version >= EXTERNAL_PINFO_VERSION_32_LP */
|
2008-02-16 10:37:58 +01:00
|
|
|
char *progname_long;
|
2000-05-18 20:32:05 +02:00
|
|
|
};
|
2003-09-01 04:26:27 +02:00
|
|
|
#endif /*__CYGWIN__*/
|
2000-06-22 22:18:17 +02:00
|
|
|
#endif /*WINVER*/
|
2000-05-18 20:32:05 +02:00
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
#endif /* _SYS_CYGWIN_H */
|