2000-02-18 03:38:33 +08:00
|
|
|
/* winsup.h: main Cygwin header file.
|
|
|
|
|
2004-02-09 12:04:24 +08:00
|
|
|
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
|
2000-02-18 03:38:33 +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. */
|
|
|
|
|
2004-01-14 23:45:37 +08: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-18 03:38:33 +08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define __INSIDE_CYGWIN__
|
|
|
|
|
|
|
|
#define strlen __builtin_strlen
|
2000-10-18 12:53:37 +08:00
|
|
|
#define strcmp __builtin_strcmp
|
2000-02-18 03:38:33 +08:00
|
|
|
#define strcpy __builtin_strcpy
|
|
|
|
#define memcpy __builtin_memcpy
|
|
|
|
#define memcmp __builtin_memcmp
|
|
|
|
#ifdef HAVE_BUILTIN_MEMSET
|
|
|
|
# define memset __builtin_memset
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
2000-08-02 11:42:31 +08:00
|
|
|
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ >= 199900L
|
|
|
|
#define NEW_MACRO_VARARGS
|
|
|
|
#endif
|
|
|
|
|
2002-09-30 10:51:22 +08:00
|
|
|
#ifndef _WIN32_WINNT
|
2002-09-06 12:21:30 +08:00
|
|
|
#define _WIN32_WINNT 0x0500
|
2002-09-06 12:30:46 +08:00
|
|
|
#endif
|
2002-09-06 12:21:30 +08:00
|
|
|
|
2000-02-18 03:38:33 +08: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-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
|
|
|
|
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-11 03:13:05 +08:00
|
|
|
extern int seteuid32 (__uid32_t);
|
2003-03-10 05:51:00 +08: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-11 03:13:05 +08: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-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.
|
|
|
|
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
|
|
|
|
one is the right one to use].
|
|
|
|
|
|
|
|
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'.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define CYG_MAX_PATH (MAX_PATH)
|
|
|
|
|
2003-03-10 05:51:00 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2001-09-06 13:17:22 +08:00
|
|
|
extern const char case_folded_lower[];
|
2000-10-19 11:12:44 +08:00
|
|
|
#define cyg_tolower(c) (case_folded_lower[(unsigned char)(c)])
|
2001-09-06 13:17:22 +08:00
|
|
|
extern const char case_folded_upper[];
|
2000-10-19 11:12:44 +08:00
|
|
|
#define cyg_toupper(c) (case_folded_upper[(unsigned char)(c)])
|
|
|
|
|
2001-04-24 23:25:31 +08:00
|
|
|
#ifndef MALLOC_DEBUG
|
2000-09-07 05:03:10 +08:00
|
|
|
#define cfree newlib_cfree_dont_use
|
2001-04-24 23:25:31 +08:00
|
|
|
#endif
|
2000-09-07 05:03:10 +08:00
|
|
|
|
2000-07-28 01:30:51 +08: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-18 03:38:33 +08:00
|
|
|
#include <windows.h>
|
2000-05-03 23:39:10 +08:00
|
|
|
#include <wincrypt.h>
|
2001-05-01 02:21:48 +08:00
|
|
|
#include <lmcons.h>
|
2000-07-28 01:30:51 +08: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-13 01:46:37 +08:00
|
|
|
#include "wincap.h"
|
|
|
|
|
2000-07-28 01:30:51 +08:00
|
|
|
/* The one function we use from winuser.h most of the time */
|
|
|
|
extern "C" DWORD WINAPI GetLastError (void);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2000-12-10 08:45:12 +08:00
|
|
|
enum codepage_type {ansi_cp, oem_cp};
|
|
|
|
extern codepage_type current_codepage;
|
|
|
|
|
2002-06-26 13:29:41 +08:00
|
|
|
UINT get_cp ();
|
|
|
|
|
|
|
|
int __stdcall sys_wcstombs(char *, const WCHAR *, int)
|
|
|
|
__attribute__ ((regparm(3)));
|
|
|
|
|
|
|
|
int __stdcall sys_mbstowcs(WCHAR *, const char *, int)
|
|
|
|
__attribute__ ((regparm(3)));
|
2002-02-28 22:30:38 +08:00
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Used to check if Cygwin DLL is dynamically loaded. */
|
|
|
|
extern int dynamically_loaded;
|
|
|
|
|
2002-06-26 13:29:41 +08:00
|
|
|
extern int cygserver_running;
|
2000-07-23 00:43:54 +08:00
|
|
|
|
2003-07-02 11:16:00 +08:00
|
|
|
#define _MT_SAFE // DELTEME someday
|
|
|
|
|
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
|
|
|
/* status bit manipulation */
|
|
|
|
#define __ISSETF(what, x, prefix) \
|
|
|
|
((what)->status & prefix##_##x)
|
|
|
|
#define __SETF(what, x, prefix) \
|
|
|
|
((what)->status |= prefix##_##x)
|
|
|
|
#define __CLEARF(what, x, prefix) \
|
|
|
|
((what)->status &= ~prefix##_##x)
|
|
|
|
#define __CONDSETF(n, what, x, prefix) \
|
|
|
|
((n) ? __SETF (what, x, prefix) : __CLEARF (what, x, prefix))
|
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
/* Events/mutexes */
|
|
|
|
extern HANDLE title_mutex;
|
|
|
|
|
|
|
|
/**************************** Convenience ******************************/
|
|
|
|
|
|
|
|
/* Used when treating / and \ as equivalent. */
|
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 */
|
2004-01-14 23:45:37 +08:00
|
|
|
#define SIGTOMASK(sig) (1 << ((sig) - signal_shift_subtract))
|
2000-02-18 03:38:33 +08:00
|
|
|
extern unsigned int signal_shift_subtract;
|
|
|
|
|
2000-08-02 11:42:31 +08:00
|
|
|
#ifdef NEW_MACRO_VARARGS
|
2004-01-14 23:45:37 +08:00
|
|
|
# define api_fatal(...) __api_fatal (__VA_ARGS__)
|
2000-08-02 11:42:31 +08:00
|
|
|
#else
|
|
|
|
# define api_fatal(fmt, args...) __api_fatal ("%P: *** " fmt,## args)
|
|
|
|
#endif
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
#undef issep
|
|
|
|
#define issep(ch) (strchr (" \t\n\r", (ch)) != NULL)
|
|
|
|
|
|
|
|
#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 */
|
2000-12-09 11:29:33 +08:00
|
|
|
void dll_crt0 (per_process *) __asm__ ("_dll_crt0__FP11per_process");
|
2000-07-01 12:40:20 +08:00
|
|
|
extern "C" void __stdcall _dll_crt0 ();
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
/* dynamically loaded dll initialization */
|
2000-09-08 10:56:55 +08:00
|
|
|
extern "C" int dll_dllcrt0 (HMODULE, per_process *);
|
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 *);
|
|
|
|
|
|
|
|
/* exit the program */
|
2003-09-23 12:02:07 +08:00
|
|
|
|
|
|
|
enum exit_states
|
|
|
|
{
|
|
|
|
ES_NOT_EXITING = 0,
|
|
|
|
ES_EVENTS_TERMINATE,
|
|
|
|
ES_THREADTERM,
|
|
|
|
ES_SIGNAL,
|
|
|
|
ES_CLOSEALL,
|
|
|
|
ES_SIGPROCTERMINATE,
|
|
|
|
ES_TITLE,
|
|
|
|
ES_HUP_PGRP,
|
|
|
|
ES_HUP_SID,
|
2004-02-14 03:34:32 +08:00
|
|
|
ES_TTY_TERMINATE,
|
|
|
|
ES_FINAL
|
2003-09-23 12:02:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
extern exit_states exit_state;
|
|
|
|
void __stdcall do_exit (int) __attribute__ ((regparm (1), noreturn));
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
/* UID/GID */
|
|
|
|
void uinfo_init (void);
|
|
|
|
|
2002-05-29 23:04:29 +08: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 22:10:55 +08:00
|
|
|
#define ILLEGAL_GID ((__gid32_t)-1)
|
2003-04-02 00:11:41 +08: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 21:38:51 +08:00
|
|
|
|
2002-05-29 23:04:29 +08:00
|
|
|
#define uid16touid32(u16) ((u16)==ILLEGAL_UID16?ILLEGAL_UID:(__uid32_t)(u16))
|
|
|
|
#define gid16togid32(g16) ((g16)==ILLEGAL_GID16?ILLEGAL_GID:(__gid32_t)(g16))
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* various events */
|
|
|
|
void events_init (void);
|
|
|
|
void events_terminate (void);
|
|
|
|
|
2004-01-19 13:46:54 +08:00
|
|
|
void __stdcall close_all_files ();
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
/* Invisible window initialization/termination. */
|
|
|
|
HWND __stdcall gethwnd (void);
|
2003-10-14 17:21:55 +08:00
|
|
|
/* Check if running in a visible window station. */
|
|
|
|
extern bool has_visible_window_station (void);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
/* Globals that handle initialization of winsock in a child process. */
|
|
|
|
extern HANDLE wsock32_handle;
|
2000-10-27 17:50:33 +08:00
|
|
|
extern HANDLE ws2_32_handle;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
/* Globals that handle initialization of netapi in a child process. */
|
|
|
|
extern HANDLE netapi32_handle;
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
2001-06-12 19:31:05 +08:00
|
|
|
void set_file_api_mode (codepage_type);
|
|
|
|
|
2004-02-12 11:01:58 +08:00
|
|
|
extern bool cygwin_finished_initializing;
|
2000-07-15 10:48:11 +08:00
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/**************************** Miscellaneous ******************************/
|
|
|
|
|
|
|
|
void __stdcall set_std_handle (int);
|
|
|
|
int __stdcall writable_directory (const char *file);
|
2002-02-26 01:47:51 +08:00
|
|
|
int __stdcall stat_dev (DWORD, int, unsigned long, struct __stat64 *);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2003-05-12 05:52:09 +08:00
|
|
|
__ino64_t __stdcall hash_path_name (__ino64_t hash, const char *name) __attribute__ ((regparm(2)));
|
2000-10-17 07:55:58 +08:00
|
|
|
void __stdcall nofinalslash (const char *src, char *dst) __attribute__ ((regparm(2)));
|
|
|
|
extern "C" char *__stdcall rootdir (char *full_path) __attribute__ ((regparm(1)));
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
/* String manipulation */
|
2000-10-17 07:55:58 +08: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-18 03:38:33 +08:00
|
|
|
|
|
|
|
/* Time related */
|
|
|
|
void __stdcall totimeval (struct timeval *dst, FILETIME * src, int sub, int flag);
|
|
|
|
long __stdcall to_time_t (FILETIME * ptr);
|
2002-06-06 23:35:09 +08:00
|
|
|
void __stdcall to_timestruc_t (FILETIME * ptr, timestruc_t * out);
|
|
|
|
void __stdcall time_as_timestruc_t (timestruc_t * out);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
void __stdcall set_console_title (char *);
|
2003-09-12 14:41:53 +08:00
|
|
|
void init_console_handler ();
|
|
|
|
void init_global_security ();
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2001-11-25 05:10:00 +08:00
|
|
|
int __stdcall check_null_str (const char *name) __attribute__ ((regparm(1)));
|
2001-06-28 10:19:57 +08:00
|
|
|
int __stdcall check_null_empty_str (const char *name) __attribute__ ((regparm(1)));
|
|
|
|
int __stdcall check_null_empty_str_errno (const char *name) __attribute__ ((regparm(1)));
|
2001-11-24 11:11:39 +08:00
|
|
|
int __stdcall check_null_str_errno (const char *name) __attribute__ ((regparm(1)));
|
2002-08-09 01:03:20 +08:00
|
|
|
int __stdcall __check_null_invalid_struct (void *s, unsigned sz) __attribute__ ((regparm(2)));
|
|
|
|
int __stdcall __check_null_invalid_struct_errno (void *s, unsigned sz) __attribute__ ((regparm(2)));
|
2003-10-27 16:28:37 +08:00
|
|
|
int __stdcall __check_invalid_read_ptr (const void *s, unsigned sz) __attribute__ ((regparm(2)));
|
2001-10-20 13:08:21 +08:00
|
|
|
int __stdcall __check_invalid_read_ptr_errno (const void *s, unsigned sz) __attribute__ ((regparm(2)));
|
2001-06-28 10:19:57 +08:00
|
|
|
|
|
|
|
#define check_null_invalid_struct(s) \
|
2001-11-15 19:10:38 +08:00
|
|
|
__check_null_invalid_struct ((s), sizeof (*(s)))
|
2001-06-28 10:19:57 +08:00
|
|
|
#define check_null_invalid_struct_errno(s) \
|
|
|
|
__check_null_invalid_struct_errno ((s), sizeof (*(s)))
|
2003-11-29 04:55:59 +08:00
|
|
|
#define check_invalid_read_struct_errno(s) \
|
|
|
|
__check_invalid_read_ptr_errno ((s), sizeof (*(s)))
|
2001-06-28 10:19:57 +08:00
|
|
|
|
2002-08-30 23:47:10 +08:00
|
|
|
struct iovec;
|
|
|
|
ssize_t check_iovec_for_read (const struct iovec *, int) __attribute__ ((regparm(2)));
|
|
|
|
ssize_t check_iovec_for_write (const struct iovec *, int) __attribute__ ((regparm(2)));
|
|
|
|
|
2000-10-07 03:11:14 +08:00
|
|
|
#define set_winsock_errno() __set_winsock_errno (__FUNCTION__, __LINE__)
|
2001-04-03 10:53:25 +08:00
|
|
|
void __set_winsock_errno (const char *fn, int ln) __attribute__ ((regparm(2)));
|
2000-02-18 03:38:33 +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 */
|
|
|
|
extern "C" void __api_fatal (const char *, ...) __attribute__ ((noreturn));
|
2001-04-03 10:53:25 +08: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 12:53:34 +08:00
|
|
|
extern void multiple_cygwin_problem (const char *, unsigned, unsigned);
|
2000-09-08 10:56:55 +08: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 08:37:18 +08:00
|
|
|
int symlink_worker (const char *, const char *, bool, bool)
|
|
|
|
__attribute__ ((regparm (3)));
|
|
|
|
|
2003-11-06 21:58:45 +08:00
|
|
|
class path_conv;
|
|
|
|
|
2003-12-03 17:55:42 +08:00
|
|
|
int fcntl_worker (int fd, int cmd, void *arg);
|
|
|
|
|
2003-11-29 04:55:59 +08:00
|
|
|
extern "C" int low_priority_sleep (DWORD) __attribute__ ((regparm (1)));
|
2002-11-22 12:43:47 +08:00
|
|
|
#define SLEEP_0_STAY_LOW INFINITE
|
2001-10-05 08:17:57 +08:00
|
|
|
|
2003-11-06 22:33:16 +08:00
|
|
|
size_t getshmlba (void);
|
|
|
|
|
2000-02-18 03:38:33 +08: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-30 00:01:23 +08:00
|
|
|
extern DWORD binmode;
|
2000-02-18 03:38:33 +08:00
|
|
|
extern char _data_start__, _data_end__, _bss_start__, _bss_end__;
|
|
|
|
extern void (*__CTOR_LIST__) (void);
|
|
|
|
extern void (*__DTOR_LIST__) (void);
|
2001-01-28 13:51:15 +08:00
|
|
|
extern SYSTEM_INFO system_info;
|
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
|
|
|
|
|
|
|
/* The title on program start. */
|
|
|
|
extern char *old_title;
|
2003-07-02 11:16:00 +08:00
|
|
|
extern bool display_title;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2000-09-08 10:56:55 +08:00
|
|
|
extern HANDLE hMainThread;
|
|
|
|
extern HANDLE hMainProc;
|
|
|
|
|
2001-10-10 10:32:12 +08:00
|
|
|
extern bool cygwin_testing;
|
|
|
|
|
2002-06-28 04:44:27 +08:00
|
|
|
extern char almost_null[];
|
|
|
|
|
2001-10-14 01:23:35 +08:00
|
|
|
#define winsock2_active (wsadata.wVersion >= 512)
|
|
|
|
#define winsock_active (wsadata.wVersion < 512)
|
|
|
|
extern struct WSAData wsadata;
|
|
|
|
|
2000-08-03 00:28:18 +08:00
|
|
|
#endif /* defined __cplusplus */
|