2000-02-17 20:38:33 +01:00
|
|
|
/* winsup.h: main Cygwin header file.
|
|
|
|
|
2005-02-20 05:25:33 +01:00
|
|
|
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
2006-01-27 22:50:42 +01:00
|
|
|
2005, 2006 Red Hat, Inc.
|
2000-02-17 20:38:33 +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. */
|
|
|
|
|
2004-01-14 16:45:37 +01:00
|
|
|
#ifdef DEBUGIT
|
|
|
|
#define spf(a, b, c) small_printf (a, b, c)
|
|
|
|
#else
|
|
|
|
#define spf(a, b, c) do {} while (0)
|
|
|
|
#endif
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define __INSIDE_CYGWIN__
|
|
|
|
|
|
|
|
#define strlen __builtin_strlen
|
2000-10-18 06:53:37 +02:00
|
|
|
#define strcmp __builtin_strcmp
|
2000-02-17 20:38:33 +01:00
|
|
|
#define strcpy __builtin_strcpy
|
|
|
|
#define memcpy __builtin_memcpy
|
|
|
|
#define memcmp __builtin_memcmp
|
|
|
|
#ifdef HAVE_BUILTIN_MEMSET
|
|
|
|
# define memset __builtin_memset
|
|
|
|
#endif
|
|
|
|
|
2002-02-15 18:06:40 +01:00
|
|
|
#define NO_COPY __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy")))
|
2003-05-11 02:10:11 +02:00
|
|
|
#define NO_COPY_INIT __attribute__((section(".data_cygwin_nocopy")))
|
2001-08-22 19:50:22 +02:00
|
|
|
|
2004-09-10 10:30:51 +02:00
|
|
|
#define EXPORT_ALIAS(sym,symalias) extern "C" __typeof (sym) symalias __attribute__ ((alias(#sym)));
|
|
|
|
|
2002-09-30 04:51:22 +02:00
|
|
|
#ifndef _WIN32_WINNT
|
2004-07-24 11:41:34 +02:00
|
|
|
#define _WIN32_WINNT 0x0501
|
2002-09-06 06:30:46 +02:00
|
|
|
#endif
|
2002-09-06 06:21:30 +02:00
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/strace.h>
|
|
|
|
|
* 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-10 21:13:05 +02:00
|
|
|
/* Declarations for functions used in C and C++ code. */
|
2003-03-09 22:51:00 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
extern __uid32_t getuid32 (void);
|
|
|
|
extern __uid32_t geteuid32 (void);
|
* 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-10 21:13:05 +02:00
|
|
|
extern int seteuid32 (__uid32_t);
|
2003-03-09 22:51:00 +01:00
|
|
|
extern __gid32_t getegid32 (void);
|
|
|
|
extern struct passwd *getpwuid32 (__uid32_t);
|
* 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-10 21:13:05 +02:00
|
|
|
extern struct passwd *getpwnam (const char *);
|
|
|
|
extern struct __sFILE64 *fopen64 (const char *, const char *);
|
|
|
|
extern struct hostent *cygwin_gethostbyname (const char *name);
|
|
|
|
extern unsigned long cygwin_inet_addr (const char *cp);
|
|
|
|
|
2003-03-09 22:51:00 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-11-15 00:40:06 +01:00
|
|
|
/* Note that MAX_PATH is defined in the windows headers */
|
|
|
|
/* There is also PATH_MAX and MAXPATHLEN.
|
|
|
|
PATH_MAX is from Posix and does *not* include the trailing NUL.
|
|
|
|
MAXPATHLEN is from Unix.
|
|
|
|
|
|
|
|
Thou shalt use CYG_MAX_PATH throughout. It avoids the NUL vs no-NUL
|
|
|
|
issue and is neither of the Unixy ones [so we can punt on which
|
2005-02-13 19:17:29 +01:00
|
|
|
one is the right one to use].
|
|
|
|
|
2003-11-15 00:40:06 +01:00
|
|
|
Windows ANSI calls are limited to MAX_PATH in length. Cygwin calls that
|
|
|
|
thunk through to Windows Wide calls are limited to 32K. We define
|
|
|
|
CYG_MAX_PATH as a convenient, not to short, not too long 'happy medium'.
|
2005-02-13 19:17:29 +01:00
|
|
|
|
2003-11-15 00:40:06 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define CYG_MAX_PATH (MAX_PATH)
|
|
|
|
|
2003-03-09 22:51:00 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2001-09-06 07:17:22 +02:00
|
|
|
extern const char case_folded_lower[];
|
2000-10-19 05:12:44 +02:00
|
|
|
#define cyg_tolower(c) (case_folded_lower[(unsigned char)(c)])
|
2001-09-06 07:17:22 +02:00
|
|
|
extern const char case_folded_upper[];
|
2000-10-19 05:12:44 +02:00
|
|
|
#define cyg_toupper(c) (case_folded_upper[(unsigned char)(c)])
|
|
|
|
|
2001-04-24 17:25:31 +02:00
|
|
|
#ifndef MALLOC_DEBUG
|
2000-09-06 23:03:10 +02:00
|
|
|
#define cfree newlib_cfree_dont_use
|
2001-04-24 17:25:31 +02:00
|
|
|
#endif
|
2000-09-06 23:03:10 +02:00
|
|
|
|
2000-07-27 19:30:51 +02:00
|
|
|
#define WIN32_LEAN_AND_MEAN 1
|
|
|
|
#define _WINGDI_H
|
|
|
|
#define _WINUSER_H
|
|
|
|
#define _WINNLS_H
|
|
|
|
#define _WINVER_H
|
|
|
|
#define _WINNETWK_H
|
|
|
|
#define _WINSVC_H
|
2000-02-17 20:38:33 +01:00
|
|
|
#include <windows.h>
|
2000-05-03 17:39:10 +02:00
|
|
|
#include <wincrypt.h>
|
2001-04-30 20:21:48 +02:00
|
|
|
#include <lmcons.h>
|
2000-07-27 19:30:51 +02:00
|
|
|
#undef _WINGDI_H
|
|
|
|
#undef _WINUSER_H
|
|
|
|
#undef _WINNLS_H
|
|
|
|
#undef _WINVER_H
|
|
|
|
#undef _WINNETWK_H
|
|
|
|
#undef _WINSVC_H
|
|
|
|
|
* Makefile.in: Build wincap.o.
* wincap.cc: New file.
* wincap.h: Ditto.
* autoload.cc: Add dynamic load statement for `CreateHardLinkA'.
* dcrt0.cc (os_being_run): Eliminated.
(osname): Ditto.
(iswinnt): Ditto.
(set_os_type): Ditto.
(dll_crt0_1): Call wincap.init() instead of set_os_type().
(_dll_crt0): Ditto.
* environ.cc (set_chunksize): New function.
(parse_thing): `forkchunk' setting now invokes function `set_chunksize'.
* fork.cc (chunksize): Eliminated. Moved to be member of wincap.
* host_dependent.h: Removed.
* syscalls.cc (_link): Try using `CreateHardLinkA' first, if available.
* cygheap.cc, dcrt0.cc, delqueue.cc, dir.cc,
environ.cc, fhandler.cc, fhandler.h, fhandler_console.cc,
fhandler_mem.cc, fork.cc, mmap.cc, net.cc, pinfo.cc, pinfo.h,
security.cc, syscalls.cc, sysconf.cc, syslog.cc, thread.cc,
times.cc, tty.cc, uinfo.cc, uname.cc, winsup.h: Use new wincap
capability check throughout.
* winsup.h: Include wincap.h. Eliminate extern declarations of
`os_being_run' and `iswinnt'. Eliminate `os_type" definition.
* include/cygwin/version.h: Bump version to 1.3.4.
2001-09-12 19:46:37 +02:00
|
|
|
#include "wincap.h"
|
|
|
|
|
2000-07-27 19:30:51 +02:00
|
|
|
/* The one function we use from winuser.h most of the time */
|
|
|
|
extern "C" DWORD WINAPI GetLastError (void);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
2000-12-10 01:45:12 +01:00
|
|
|
enum codepage_type {ansi_cp, oem_cp};
|
|
|
|
extern codepage_type current_codepage;
|
|
|
|
|
2002-06-26 07:29:41 +02:00
|
|
|
UINT get_cp ();
|
|
|
|
|
2006-02-07 16:49:08 +01:00
|
|
|
int __stdcall sys_wcstombs(char *, int, const WCHAR *, int = -1)
|
2002-06-26 07:29:41 +02:00
|
|
|
__attribute__ ((regparm(3)));
|
|
|
|
|
|
|
|
int __stdcall sys_mbstowcs(WCHAR *, const char *, int)
|
|
|
|
__attribute__ ((regparm(3)));
|
2002-02-28 15:30:38 +01:00
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
/* Used to check if Cygwin DLL is dynamically loaded. */
|
|
|
|
extern int dynamically_loaded;
|
|
|
|
|
2002-06-26 07:29:41 +02:00
|
|
|
extern int cygserver_running;
|
2000-07-22 18:43:54 +02:00
|
|
|
|
2003-07-02 05:16:00 +02:00
|
|
|
#define _MT_SAFE // DELTEME someday
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
#define TITLESIZE 1024
|
2000-07-02 12:17:44 +02:00
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
/* Events/mutexes */
|
2004-05-17 17:27:56 +02:00
|
|
|
extern HANDLE tty_mutex;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
/**************************** Convenience ******************************/
|
|
|
|
|
2004-04-13 11:04:22 +02:00
|
|
|
/* Used to define status flag accessor methods */
|
|
|
|
#define IMPLEMENT_STATUS_FLAG(type,flag) \
|
|
|
|
void flag (type val) { status.flag = (val); } \
|
|
|
|
type flag () const { return (type) status.flag; }
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
/* Used when treating / and \ as equivalent. */
|
2003-01-09 09:22:05 +01:00
|
|
|
#define isdirsep(ch) \
|
2000-02-17 20:38:33 +01:00
|
|
|
({ \
|
|
|
|
char __c = (ch); \
|
|
|
|
((__c) == '/' || (__c) == '\\'); \
|
|
|
|
})
|
|
|
|
|
|
|
|
/* Convert a signal to a signal mask */
|
2004-01-14 16:45:37 +01:00
|
|
|
#define SIGTOMASK(sig) (1 << ((sig) - signal_shift_subtract))
|
2000-02-17 20:38:33 +01:00
|
|
|
extern unsigned int signal_shift_subtract;
|
|
|
|
|
2006-03-13 22:10:14 +01:00
|
|
|
extern int __api_fatal_exit_val;
|
|
|
|
#define set_api_fatal_return(n) do {extern int __api_fatal_exit_val; __api_fatal_exit_val = (n);} while (0)
|
|
|
|
#define api_fatal(fmt, args...) __api_fatal ("%P: *** " fmt,## args)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
#undef issep
|
|
|
|
#define issep(ch) (strchr (" \t\n\r", (ch)) != NULL)
|
|
|
|
|
|
|
|
#define isabspath(p) \
|
2000-06-18 00:05:19 +02:00
|
|
|
(isdirsep (*(p)) || (isalpha (*(p)) && (p)[1] == ':' && (!(p)[2] || isdirsep ((p)[2]))))
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
/******************** Initialization/Termination **********************/
|
|
|
|
|
2000-09-08 04:56:55 +02:00
|
|
|
class per_process;
|
2000-02-17 20:38:33 +01:00
|
|
|
/* cygwin .dll initialization */
|
2000-12-09 04:29:33 +01:00
|
|
|
void dll_crt0 (per_process *) __asm__ ("_dll_crt0__FP11per_process");
|
2000-07-01 06:40:20 +02:00
|
|
|
extern "C" void __stdcall _dll_crt0 ();
|
2006-06-02 02:09:50 +02:00
|
|
|
extern void dll_crt0_1 (void *);
|
|
|
|
extern void dll_dllcrt0_1 (void *);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
/* dynamically loaded dll initialization */
|
2000-09-08 04:56:55 +02:00
|
|
|
extern "C" int dll_dllcrt0 (HMODULE, per_process *);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
/* dynamically loaded dll initialization for non-cygwin apps */
|
|
|
|
extern "C" int dll_noncygwin_dllcrt0 (HMODULE, per_process *);
|
|
|
|
|
|
|
|
/* exit the program */
|
2003-09-23 06:02:07 +02:00
|
|
|
|
|
|
|
enum exit_states
|
|
|
|
{
|
|
|
|
ES_NOT_EXITING = 0,
|
2005-06-07 20:41:31 +02:00
|
|
|
ES_SET_MUTO,
|
|
|
|
ES_GLOBAL_DTORS,
|
2003-09-23 06:02:07 +02:00
|
|
|
ES_EVENTS_TERMINATE,
|
|
|
|
ES_THREADTERM,
|
|
|
|
ES_SIGNAL,
|
|
|
|
ES_CLOSEALL,
|
|
|
|
ES_HUP_PGRP,
|
|
|
|
ES_HUP_SID,
|
2005-09-20 04:06:57 +02:00
|
|
|
ES_EXEC_EXIT,
|
2005-09-14 16:00:07 +02:00
|
|
|
ES_TITLE,
|
2004-02-13 20:34:32 +01:00
|
|
|
ES_TTY_TERMINATE,
|
|
|
|
ES_FINAL
|
2003-09-23 06:02:07 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern exit_states exit_state;
|
|
|
|
void __stdcall do_exit (int) __attribute__ ((regparm (1), noreturn));
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
/* UID/GID */
|
2005-07-05 05:16:46 +02:00
|
|
|
void uinfo_init ();
|
2000-02-17 20:38:33 +01:00
|
|
|
|
2002-05-29 17:04:29 +02:00
|
|
|
#define ILLEGAL_UID16 ((__uid16_t)-1)
|
|
|
|
#define ILLEGAL_UID ((__uid32_t)-1)
|
|
|
|
#define ILLEGAL_GID16 ((__gid16_t)-1)
|
Change internal gid datatype from __gid16_t to __gid32_t
throughout.
* cygwin.din: Export new symbols chown32, fchown32, getegid32,
getgid32, getgrgid32, getgrnam32, getgroups32, initgroups32, lchown32,
setgid32, setegid32, getgrent32.
* grp.cc (grp32togrp16): New static function.
(getgrgid32): New function.
(getgrnam32): Ditto.
(getgrent32): Ditto.
(getgroups32): Change name of internal function from getgroups.
(getgroups32): New function.
(initgroups32): Ditto.
* syscalls.cc (chown32): Ditto.
(lchown32): Ditto.
(fchown32): Ditto.
(setegid32): Ditto.
(setgid32): Ditto.
* uinfo.cc (getgid32): Ditto.
(getegid32): Ditto.
* include/cygwin/grp.h: Remove declaration of getgrgid() and getgrnam().
Declare getgrgid32() and getgrnam32() instead. Declare getgid32().
2002-05-28 16:10:55 +02:00
|
|
|
#define ILLEGAL_GID ((__gid32_t)-1)
|
2003-04-01 18:11:41 +02:00
|
|
|
#define ILLEGAL_SEEK ((_off64_t)-1)
|
* (child_info.h, cygheap.h, dcrt0.cc, dir.cc, fhandler.cc, fhandler.h,
fhandler_clipboard.cc, fhandler_disk_file.cc, fhandler_dsp.cc,
fhandler_floppy.cc, fhandler_mem.cc, fhandler_random.cc,
fhandler_tape.cc, fhandler_zero.cc, grp.cc, mmap.cc, passwd.cc,
pinfo.cc, pinfo.h, pipe.cc, sec_acl.cc, sec_helper.cc, security.cc,
security.h, spawn.cc, syscalls.cc, thread.h, uinfo.cc, winsup.h):
Change usage of uid_t to __uid16_t, gid_t to __gid16_t and
off_t to __off32_t throughout. Use INVALID_UID, INVALID_GID and
INVALID_SEEK instead casting -1 to the appropriate type.
* winsup.h: Define INVALID_UID, INVALID_GID and INVALID_SEEK.
* include/cygwin/acl.h: Define internal __aclent16_t and __aclent32_t
types. Don't declare acl functions when compiling Cygwin.
* include/cygwin/grp.h: Declare getgrgid() and getgrnam() with
correct types for internal usage.
2002-02-10 14:38:51 +01:00
|
|
|
|
2002-05-29 17:04:29 +02:00
|
|
|
#define uid16touid32(u16) ((u16)==ILLEGAL_UID16?ILLEGAL_UID:(__uid32_t)(u16))
|
|
|
|
#define gid16togid32(g16) ((g16)==ILLEGAL_GID16?ILLEGAL_GID:(__gid32_t)(g16))
|
|
|
|
|
2005-03-16 22:52:06 +01:00
|
|
|
/* Convert LARGE_INTEGER into long long */
|
|
|
|
#define get_ll(pl) (((long long) (pl).HighPart << 32) | (pl).LowPart)
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
/* various events */
|
2005-07-05 05:16:46 +02:00
|
|
|
void events_init ();
|
|
|
|
void events_terminate ();
|
2000-02-17 20:38:33 +01:00
|
|
|
|
2005-07-05 04:05:07 +02:00
|
|
|
void __stdcall close_all_files (bool = false);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
/* debug_on_trap support. see exceptions.cc:try_to_debug() */
|
|
|
|
extern "C" void error_start_init (const char*);
|
2001-04-30 05:09:19 +02:00
|
|
|
extern "C" int try_to_debug (bool waitloop = 1);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
2005-08-11 18:30:48 +02:00
|
|
|
extern void ld_preload ();
|
|
|
|
|
2001-06-12 13:31:05 +02:00
|
|
|
void set_file_api_mode (codepage_type);
|
|
|
|
|
2004-02-12 04:01:58 +01:00
|
|
|
extern bool cygwin_finished_initializing;
|
2000-07-15 04:48:11 +02:00
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
/**************************** Miscellaneous ******************************/
|
|
|
|
|
|
|
|
void __stdcall set_std_handle (int);
|
2002-02-25 18:47:51 +01:00
|
|
|
int __stdcall stat_dev (DWORD, int, unsigned long, struct __stat64 *);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
2003-05-11 23:52:09 +02:00
|
|
|
__ino64_t __stdcall hash_path_name (__ino64_t hash, const char *name) __attribute__ ((regparm(2)));
|
2000-10-17 01:55:58 +02:00
|
|
|
void __stdcall nofinalslash (const char *src, char *dst) __attribute__ ((regparm(2)));
|
2004-04-10 21:24:55 +02:00
|
|
|
extern "C" char *__stdcall rootdir (const char *full_path, char *root_path) __attribute__ ((regparm(2)));
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
/* String manipulation */
|
2000-10-17 01:55:58 +02:00
|
|
|
extern "C" char *__stdcall strccpy (char *s1, const char **s2, char c);
|
|
|
|
extern "C" int __stdcall strcasematch (const char *s1, const char *s2) __attribute__ ((regparm(2)));
|
|
|
|
extern "C" int __stdcall strncasematch (const char *s1, const char *s2, size_t n) __attribute__ ((regparm(3)));
|
|
|
|
extern "C" char *__stdcall strcasestr (const char *searchee, const char *lookfor) __attribute__ ((regparm(2)));
|
2000-02-17 20:38:33 +01:00
|
|
|
|
2005-12-21 18:14:34 +01:00
|
|
|
void *hook_or_detect_cygwin (const char *, const void *, WORD&) __attribute__ ((regparm (3)));
|
2005-07-17 02:51:03 +02:00
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
/* Time related */
|
2005-02-20 12:44:32 +01:00
|
|
|
void __stdcall totimeval (struct timeval *, FILETIME *, int, int);
|
|
|
|
long __stdcall to_time_t (FILETIME *);
|
|
|
|
void __stdcall to_timestruc_t (FILETIME *, timestruc_t *);
|
|
|
|
void __stdcall time_as_timestruc_t (timestruc_t *);
|
|
|
|
void __stdcall timeval_to_filetime (const struct timeval *, FILETIME *);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
2005-08-11 18:30:48 +02:00
|
|
|
/* Console related */
|
2000-02-17 20:38:33 +01:00
|
|
|
void __stdcall set_console_title (char *);
|
2006-03-16 03:57:37 +01:00
|
|
|
void init_console_handler (bool);
|
2005-08-11 18:30:48 +02:00
|
|
|
|
2003-09-12 08:41:53 +02:00
|
|
|
void init_global_security ();
|
2000-02-17 20:38:33 +01:00
|
|
|
|
2004-02-25 11:54:31 +01:00
|
|
|
int __stdcall check_invalid_virtual_addr (const void *s, unsigned sz) __attribute__ ((regparm(2)));
|
2001-06-28 04:19:57 +02:00
|
|
|
|
2005-07-03 04:40:30 +02:00
|
|
|
ssize_t check_iovec (const struct iovec *, int, bool) __attribute__ ((regparm(3)));
|
|
|
|
#define check_iovec_for_read(a, b) check_iovec ((a), (b), false)
|
|
|
|
#define check_iovec_for_write(a, b) check_iovec ((a), (b), true)
|
2002-08-30 17:47:10 +02:00
|
|
|
|
2000-10-06 21:11:14 +02:00
|
|
|
#define set_winsock_errno() __set_winsock_errno (__FUNCTION__, __LINE__)
|
2001-04-03 04:53:25 +02:00
|
|
|
void __set_winsock_errno (const char *fn, int ln) __attribute__ ((regparm(2)));
|
2000-02-17 20:38:33 +01:00
|
|
|
|
2001-08-22 19:50:22 +02:00
|
|
|
extern bool wsock_started;
|
|
|
|
|
2000-09-08 04:56:55 +02:00
|
|
|
/* Printf type functions */
|
|
|
|
extern "C" void __api_fatal (const char *, ...) __attribute__ ((noreturn));
|
2001-04-03 04:53:25 +02:00
|
|
|
extern "C" int __small_sprintf (char *dst, const char *fmt, ...) /*__attribute__ ((regparm (2)))*/;
|
|
|
|
extern "C" int __small_vsprintf (char *dst, const char *fmt, va_list ap) /*__attribute__ ((regparm (3)))*/;
|
2001-12-26 05:53:34 +01:00
|
|
|
extern void multiple_cygwin_problem (const char *, unsigned, unsigned);
|
2000-09-08 04:56:55 +02:00
|
|
|
|
2005-05-10 22:56:07 +02:00
|
|
|
extern "C" void vklog (int priority, const char *message, va_list ap);
|
|
|
|
extern "C" void klog (int priority, const char *message, ...);
|
2005-12-17 05:36:39 +01:00
|
|
|
bool child_copy (HANDLE, bool, ...);
|
2005-05-10 22:56:07 +02:00
|
|
|
|
* devices.cc: New file.
* devices.gperf: New file.
* devices.shilka: New file.
* cygwin-gperf: New file.
* cygwin-shilka: New file.
* fhandler_fifo.cc: New file.
* fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes
fhandler.h throughout. Remove device argument and unit arguments from fhandler
constructors throughout. Remove pc arguments to fhandler functions and use
internal pc element instead, throughout. Use dev element in pc throughout.
Use major/minor elements rather than units and device numbers previously in
fhandler class. Use correct methods for fhandler file names rather than
directly accessing file name variables, throughout.
* Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o
* dcrt0.cc (dll_crt0_1): Call device::init.
* devices.h: Renumber devices based on more Linux-like major/minor numbers.
Add more devices. Declare standard device storage.
(device): Declare struct.
* dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type.
* dtable.cc (dtable::get_debugger_info): Ditto.
(cygwin_attach_handle_to_fd): Ditto.
(dtable::release): Remove special FH_SOCKET case in favor of generic
"need_fixup_before" test.
(dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name
to build standard fhandler.
(dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move
out of dtable class. Don't accept a path_conv argument. Just build it here
and pass it to:
(build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class.
Use intrinsic device type in path_conv to create new fhandler.
(build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class.
Simplify arguments to just take new 'device' type and a name. Just return
pointer to fhandler rather than trying to insert into dtable.
(dtable::dup_worker): Accommodate above build_fh name changes.
(dtable::find_fifo): New (currently broken) function.
(handle_to_fn): Use strechr for efficiency.
* dtable.h: Reflect above build_fh name changes and argument differences.
(fhandler_base *&operator []): Return self rather than copy of self.
* fhandler.cc (fhandler_base::operator =): Use pc element to set normalized
path.
(fhandler_base::set_name): Ditto.
(fhandler_base::raw_read): Use method to access name.
(fhandler_base::write): Correctly use get_output_handle rather than get_handle.
(handler_base::device_access_denied): New function.
(fhandler_base::open): Eliminate pc argument and use pc element of
fhandler_base throughout.
(fhandler_base::fstat): Detect if device is based in filesystem and use
fstat_fs to calculate stat, if so.
(fhandler_base::fhandler_base): Eliminate handling of file names and, instead,
just free appropriate component from pc.
(fhandler_base::opendir): Remove path_conv parameter.
* fhandler.h: Remove all device flags.
(fhandler_base::pc): New element.
(fhandler_base::set_name): Change argument to path_conv.
(fhandler_base::error): New function.
(fhandler_base::exists): New function.
(fhandler_base::pc_binmode): New function.
(fhandler_base::dev): New function.
(fhandler_base::open_fs): New function.
(fhandler_base::fstat_fs): New function.
(fhandler_base::fstat_by_name): New function.
(fhandler_base::fstat_by_handle): New function.
(fhandler_base::isfifo): New function.
(fhandler_base::is_slow): New function.
(fhandler_base::is_auto_device): New function.
(fhandler_base::is_fs_special): New function.
(fhandler_base::device_access_denied): New function.
(fhandler_base::operator DWORD&): New operator.
(fhandler_base::get_name): Return normalized path from pc.
(fhandler_base::get_win32_name): Return windows path from pc.
(fhandler_base::isdevice): Renamed from is_device.
(fhandler_base::get_native_name): Return device format.
(fhandler_fifo): New class.
(fhandler_nodevice): New class.
(select_stuff::device_specific): Remove array.
(select_stuff::device_specific_pipe): New class element.
(select_stuff::device_specific_socket): New class element.
(select_stuff::device_specific_serial): New class element.
(select_stuff::select_stuff): Initialize new elements.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class
from fhandler_disk_file.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_disk_file::open): Move most functionality into
fhandler_base::open_fs.
(fhandler_base::open_fs): New function.
(fhandler_disk_file::close): Move most functionality into
fhandler_base::close_fs.
(fhandler_base::close_fs): New function.
* fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging
output.
* fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard
urandom device into appropriate place.
(fhandler_socket::accept): Reflect change in fdsock return value.
* fhandler_tty.cc: See "throughouts" above.
* net.cc: Accommodate fdsock change throughout.
(fdsock): Return success or failure, accept fd argument and device argument.
* path.cc (symlink_info::major): New element.
(symlink_info::minor): New element.
(symlink_info::parse_device): Declare new function.
(fs_info::update): Accommodate changes in path_conv class.
(path_conv::fillin): Ditto.
(path_conv::return_and_clear_normalized_path): Eliminate.
(path_conv::set_normalized_path): New function.
(path_conv::path_conv): Set info in dev element. Use path_conv methods Check
for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff.
where appropriate rather than direct access. Use set_normalized_path to set
normalized path.
(windows_device_names): Eliminate.
(get_dev): Ditto.
(get_raw_device_number): Ditto.
(get_device_number): Ditto.
(win32_device_name): Call new device name parser to do most of the heavy
lifting.
(mount_info::conv_to_win32_path): Fill in dev field as appropriate.
(symlink_worker): Handle new device files.
(symlink_info::check): Ditto.
(symlink_info::parse_device): Define new function.
* path.h (executable_states): Move here from fhandler.h.
(fs_info): Rename variables to *_storage and create methods for accessing same.
(path_conv): Add dev element, remove devn and unit and adjust inline methods to
accommodate.
(set_normalized_path): Declare new function.
* pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos.
(_pinfo::commune_send): Ditto.
* pipe.cc (fhandler_pipe::close): check for existence of handle before closing
it.
(handler_pipe::create): Rename from make_pipe. Change arguments to accept
fhandler_pipe array. Accommodate fifos.
(pipe): Rework to deal with fhandler_pipe::create changes.
(_pipe): Ditto.
* select.cc: Use individual device_specific types throughout rather than
indexing with obsolete device number.
(set_bits): Use is_socket call rather than checking device number.
* shared_info.h (CURR_MOUNT_MAGIC): Update.
(conv_to_win32_path): Reflect addition of device argument.
* syscalls.cc (mknod_worker): New function.
(open): Use build_fh_name to build fhandler.
(chown_worker): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(chmod_device): New function.
(chmod): Detect if this is an 'auto' device rather than an on-filesystem device
and handle appropriately. Use chmod_device to set mode of in-filesystem
devices.
(stat_worker): Eliminate path_conv argument. Call build_fh_name to construct
fhandler. Use fh->error() rather than pc->error to detect errors in fhandler
construction.
(access_worker): New function pulled from access. Accommodate in-filesystem
devices.
(access): Use access_worker.
(fpathconf): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(mknod_worker): New function.
(mknod32): New function.
(chroot): Free normalized path -- assuming it was actually cmalloced.
* tty.cc (create_tty_master): Tweak for new device class.
(tty::common_init): Ditto.
* winsup.h (stat_worker): Remove.
(symlink_worker): Declare.
* exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't
worry about pending_signals since sig_dispatch_pending should always do the
right thing now.
(sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3.
* pinfo.h: Move __SIG enum to sigproc.h.
(PICOM_FIFO): New enum element.
(_pinfo): Remove 'thread2signal' stuff throughout class.
(_pinfo::commune_send): Make varargs.
(_pinfo::sigtodo): Eliminate.
(_pinfo::thread2signal): Ditto.
* signal.cc (kill_worker): Eliminate call to setthread2signal.
* sigproc.cc (local_sigtodo): Eliminate.
(getlocal_sigtodo): Ditto.
(sigelem): New class.
(pending_signals): New class.
(sigqueue): New variable, start of sigqueue linked list.
(sigcatch_nonmain): Eliminate.
(sigcatch_main): Eliminate.
(sigcatch_nosync): Eliminate.
(sigcomplete_nonmain): Eliminate.
(pending_signals): Eliminate.
(sig_clear): Call signal thread to clear pending signals, unless already in
signal thread.
(sigpending): Call signal thread to get pending signals.
(sig_dispatch_pending): Eliminate use of pending_signals and just check
sigqueue.
(sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close
signal pipe handle.
(sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send
signals.
(getevent): Eliminate.
(pending_signals::add): New function.
(pending_signals::del): New function.
(pending_signals::next): New function.
(wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to
communicate and maintain a linked list of signals.
* sigproc.h: Move __SIG defines here. Add __SIGPENDING.
(sig_dispatch_pending): Remove "C" specifier.
(sig_handle): Accept a mask argument.
* thread.cc: Remove signal handling considerations throughout.
2003-09-25 02:37:18 +02:00
|
|
|
int symlink_worker (const char *, const char *, bool, bool)
|
|
|
|
__attribute__ ((regparm (3)));
|
|
|
|
|
2003-11-06 14:58:45 +01:00
|
|
|
class path_conv;
|
|
|
|
|
2003-12-03 10:55:42 +01:00
|
|
|
int fcntl_worker (int fd, int cmd, void *arg);
|
|
|
|
|
2006-01-27 22:50:42 +01:00
|
|
|
__ino64_t __stdcall readdir_get_ino (struct __DIR *dir, const char *path, bool dot_dot) __attribute__ ((regparm (3)));
|
|
|
|
|
2003-11-28 21:55:59 +01:00
|
|
|
extern "C" int low_priority_sleep (DWORD) __attribute__ ((regparm (1)));
|
2002-11-22 05:43:47 +01:00
|
|
|
#define SLEEP_0_STAY_LOW INFINITE
|
2001-10-05 02:17:57 +02:00
|
|
|
|
2005-11-28 23:32:29 +01:00
|
|
|
/* Returns the real page size, not the allocation size. */
|
|
|
|
size_t getsystempagesize ();
|
|
|
|
|
2005-12-07 12:16:47 +01:00
|
|
|
/* mmap functions. */
|
2005-11-28 23:32:29 +01:00
|
|
|
void mmap_init ();
|
2005-12-07 12:16:47 +01:00
|
|
|
bool mmap_is_attached_page (ULONG_PTR);
|
2003-11-06 15:33:16 +01:00
|
|
|
|
2005-01-25 23:45:11 +01:00
|
|
|
int winprio_to_nice (DWORD) __attribute__ ((regparm (1)));
|
|
|
|
DWORD nice_to_winprio (int &) __attribute__ ((regparm (1)));
|
|
|
|
|
2006-03-18 20:17:21 +01:00
|
|
|
bool __stdcall create_pipe (PHANDLE, PHANDLE, LPSECURITY_ATTRIBUTES, DWORD)
|
2005-08-19 16:56:48 +02:00
|
|
|
__attribute__ ((regparm (3)));
|
|
|
|
#define CreatePipe create_pipe
|
2006-03-18 20:17:21 +01:00
|
|
|
|
2005-12-20 21:34:28 +01:00
|
|
|
inline bool flush_file_buffers (HANDLE h)
|
|
|
|
{
|
|
|
|
return (GetFileType (h) != FILE_TYPE_PIPE) ? FlushFileBuffers (h) : true;
|
|
|
|
}
|
2005-12-20 21:19:55 +01:00
|
|
|
#define FlushFileBuffers flush_file_buffers
|
2005-08-19 16:56:48 +02:00
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
/**************************** Exports ******************************/
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
int cygwin_select (int , fd_set *, fd_set *, fd_set *,
|
|
|
|
struct timeval *to);
|
|
|
|
int cygwin_gethostname (char *__name, size_t __len);
|
|
|
|
|
2000-07-29 18:01:23 +02:00
|
|
|
extern DWORD binmode;
|
2000-02-17 20:38:33 +01:00
|
|
|
extern char _data_start__, _data_end__, _bss_start__, _bss_end__;
|
|
|
|
extern void (*__CTOR_LIST__) (void);
|
|
|
|
extern void (*__DTOR_LIST__) (void);
|
2001-01-28 06:51:15 +01:00
|
|
|
extern SYSTEM_INFO system_info;
|
2000-02-17 20:38:33 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/*************************** Unsorted ******************************/
|
|
|
|
|
|
|
|
#define WM_ASYNCIO 0x8000 // WM_APP
|
|
|
|
|
|
|
|
|
2000-04-08 06:13:12 +02: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 06:13:48 +02: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-17 20:38:33 +01:00
|
|
|
|
|
|
|
/* The title on program start. */
|
|
|
|
extern char *old_title;
|
2003-07-02 05:16:00 +02:00
|
|
|
extern bool display_title;
|
2006-02-05 19:18:02 +01:00
|
|
|
extern bool transparent_exe;
|
2000-02-17 20:38:33 +01:00
|
|
|
|
2006-03-13 22:10:14 +01:00
|
|
|
extern bool in_forkee;
|
|
|
|
extern bool in_dllentry;
|
|
|
|
|
2000-09-08 04:56:55 +02:00
|
|
|
extern HANDLE hMainThread;
|
|
|
|
extern HANDLE hMainProc;
|
2005-04-03 15:06:43 +02:00
|
|
|
extern HANDLE hProcToken;
|
|
|
|
extern HANDLE hProcImpToken;
|
2005-07-05 05:16:46 +02:00
|
|
|
extern HANDLE hExeced;
|
2006-02-23 20:21:21 +01:00
|
|
|
extern HMODULE cygwin_hmodule;
|
2000-09-08 04:56:55 +02:00
|
|
|
|
2001-10-10 04:32:12 +02:00
|
|
|
extern bool cygwin_testing;
|
|
|
|
|
2002-06-27 22:44:27 +02:00
|
|
|
extern char almost_null[];
|
|
|
|
|
2000-08-02 18:28:18 +02:00
|
|
|
#endif /* defined __cplusplus */
|