2000-02-17 20:38:33 +01:00
|
|
|
/* winsup.h: main Cygwin header file.
|
|
|
|
|
2002-01-13 21:03:03 +01:00
|
|
|
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 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. */
|
|
|
|
|
|
|
|
#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")))
|
2001-08-22 19:50:22 +02:00
|
|
|
|
2001-11-28 03:36:32 +01:00
|
|
|
#ifdef EXPCGF
|
|
|
|
#define DECLARE_TLS_STORAGE char **tls[4096] __attribute__ ((unused))
|
|
|
|
#else
|
|
|
|
#define DECLARE_TLS_STORAGE do {} while (0)
|
|
|
|
#define _WINBASE2_H
|
|
|
|
#endif
|
|
|
|
|
2001-03-05 07:28:25 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2000-08-02 05:42:31 +02:00
|
|
|
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ >= 199900L
|
|
|
|
#define NEW_MACRO_VARARGS
|
|
|
|
#endif
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/strace.h>
|
|
|
|
|
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;
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
/* Used to check if Cygwin DLL is dynamically loaded. */
|
|
|
|
extern int dynamically_loaded;
|
|
|
|
|
2000-07-22 18:43:54 +02:00
|
|
|
#define sys_wcstombs(tgt,src,len) \
|
2000-12-10 01:45:12 +01:00
|
|
|
WideCharToMultiByte((current_codepage==ansi_cp?CP_ACP:CP_OEMCP),0,(src),-1,(tgt),(len),NULL,NULL)
|
2000-07-22 18:43:54 +02:00
|
|
|
#define sys_mbstowcs(tgt,src,len) \
|
2000-12-10 01:45:12 +01:00
|
|
|
MultiByteToWideChar((current_codepage==ansi_cp?CP_ACP:CP_OEMCP),0,(src),-1,(tgt),(len))
|
2000-07-22 18:43:54 +02:00
|
|
|
|
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
|
|
|
/* 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. */
|
|
|
|
#define SLASH_P(ch) \
|
|
|
|
({ \
|
|
|
|
char __c = (ch); \
|
|
|
|
((__c) == '/' || (__c) == '\\'); \
|
|
|
|
})
|
|
|
|
|
|
|
|
/* Convert a signal to a signal mask */
|
|
|
|
#define SIGTOMASK(sig) (1<<((sig) - signal_shift_subtract))
|
|
|
|
extern unsigned int signal_shift_subtract;
|
|
|
|
|
2000-08-02 05:42:31 +02:00
|
|
|
#ifdef NEW_MACRO_VARARGS
|
|
|
|
# define api_fatal(...) __api_fatal ("%P: *** " __VA_ARGS__)
|
|
|
|
#else
|
|
|
|
# define api_fatal(fmt, args...) __api_fatal ("%P: *** " fmt,## args)
|
|
|
|
#endif
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
#undef issep
|
|
|
|
#define issep(ch) (strchr (" \t\n\r", (ch)) != NULL)
|
|
|
|
|
|
|
|
#define isdirsep SLASH_P
|
|
|
|
#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 ();
|
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 */
|
|
|
|
extern "C" void __stdcall do_exit (int) __attribute__ ((noreturn));
|
|
|
|
|
|
|
|
/* UID/GID */
|
|
|
|
void uinfo_init (void);
|
|
|
|
|
* (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
|
|
|
#define ILLEGAL_UID ((__uid16_t)-1)
|
|
|
|
#define ILLEGAL_GID ((__gid16_t)-1)
|
2002-02-25 18:47:51 +01: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
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
/* various events */
|
|
|
|
void events_init (void);
|
|
|
|
void events_terminate (void);
|
|
|
|
|
|
|
|
void __stdcall close_all_files (void);
|
2001-10-14 06:14:24 +02:00
|
|
|
BOOL __stdcall check_pty_fds (void);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
/* Invisible window initialization/termination. */
|
|
|
|
HWND __stdcall gethwnd (void);
|
|
|
|
void __stdcall window_terminate (void);
|
|
|
|
|
|
|
|
/* Globals that handle initialization of winsock in a child process. */
|
|
|
|
extern HANDLE wsock32_handle;
|
2000-10-27 11:50:33 +02:00
|
|
|
extern HANDLE ws2_32_handle;
|
2000-02-17 20:38:33 +01: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 05:09:19 +02:00
|
|
|
extern "C" int try_to_debug (bool waitloop = 1);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
2001-06-12 13:31:05 +02:00
|
|
|
void set_file_api_mode (codepage_type);
|
|
|
|
|
2000-07-15 04:48:11 +02:00
|
|
|
extern int cygwin_finished_initializing;
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
/**************************** Miscellaneous ******************************/
|
|
|
|
|
|
|
|
void __stdcall set_std_handle (int);
|
|
|
|
int __stdcall writable_directory (const char *file);
|
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
|
|
|
extern BOOL allow_ntsec;
|
|
|
|
|
2000-10-17 01:55:58 +02:00
|
|
|
unsigned long __stdcall hash_path_name (unsigned long hash, const char *name) __attribute__ ((regparm(2)));
|
|
|
|
void __stdcall nofinalslash (const char *src, char *dst) __attribute__ ((regparm(2)));
|
|
|
|
extern "C" char *__stdcall rootdir (char *full_path) __attribute__ ((regparm(1)));
|
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
|
|
|
|
|
|
|
/* Time related */
|
|
|
|
void __stdcall totimeval (struct timeval *dst, FILETIME * src, int sub, int flag);
|
|
|
|
long __stdcall to_time_t (FILETIME * ptr);
|
|
|
|
|
|
|
|
void __stdcall set_console_title (char *);
|
2002-01-10 04:21:27 +01:00
|
|
|
void early_stuff_init ();
|
2000-02-17 20:38:33 +01:00
|
|
|
|
2001-11-24 22:10:00 +01:00
|
|
|
int __stdcall check_null_str (const char *name) __attribute__ ((regparm(1)));
|
2001-06-28 04:19:57 +02: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 04:11:39 +01:00
|
|
|
int __stdcall check_null_str_errno (const char *name) __attribute__ ((regparm(1)));
|
2001-10-20 07:08:21 +02:00
|
|
|
int __stdcall __check_null_invalid_struct (const void *s, unsigned sz) __attribute__ ((regparm(2)));
|
|
|
|
int __stdcall __check_null_invalid_struct_errno (const void *s, unsigned sz) __attribute__ ((regparm(2)));
|
|
|
|
int __stdcall __check_invalid_read_ptr_errno (const void *s, unsigned sz) __attribute__ ((regparm(2)));
|
2001-06-28 04:19:57 +02:00
|
|
|
|
|
|
|
#define check_null_invalid_struct(s) \
|
2001-11-15 12:10:38 +01:00
|
|
|
__check_null_invalid_struct ((s), sizeof (*(s)))
|
2001-06-28 04:19:57 +02:00
|
|
|
#define check_null_invalid_struct_errno(s) \
|
|
|
|
__check_null_invalid_struct_errno ((s), sizeof (*(s)))
|
|
|
|
|
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
|
|
|
|
2001-09-09 05:34:36 +02:00
|
|
|
extern "C" void __malloc_lock (struct _reent *);
|
|
|
|
extern "C" void __malloc_unlock (struct _reent *);
|
|
|
|
|
2001-09-09 18:52:37 +02:00
|
|
|
extern "C" void __malloc_lock (struct _reent *);
|
|
|
|
extern "C" void __malloc_unlock (struct _reent *);
|
|
|
|
|
2001-10-05 02:17:57 +02:00
|
|
|
class path_conv;
|
2002-02-25 18:47:51 +01:00
|
|
|
int __stdcall stat_worker (const char *name, struct __stat64 *buf, int nofollow,
|
2001-10-05 02:17:57 +02:00
|
|
|
path_conv *pc = NULL) __attribute__ ((regparm (3)));
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
int kill_pgrp (pid_t, int);
|
|
|
|
int _kill (int, int);
|
|
|
|
int _raise (int sig);
|
|
|
|
|
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
|
|
|
|
|
|
|
|
/* 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 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]. */
|
|
|
|
|
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)
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
/* The title on program start. */
|
|
|
|
extern char *old_title;
|
|
|
|
extern BOOL display_title;
|
|
|
|
|
2000-09-08 04:56:55 +02:00
|
|
|
extern HANDLE hMainThread;
|
|
|
|
extern HANDLE hMainProc;
|
|
|
|
|
2001-10-10 04:32:12 +02:00
|
|
|
extern bool cygwin_testing;
|
|
|
|
extern unsigned _cygwin_testing_magic;
|
|
|
|
extern HMODULE cygwin_hmodule;
|
|
|
|
|
2001-10-13 19:23:35 +02:00
|
|
|
#define winsock2_active (wsadata.wVersion >= 512)
|
|
|
|
#define winsock_active (wsadata.wVersion < 512)
|
|
|
|
extern struct WSAData wsadata;
|
|
|
|
|
2000-08-02 18:28:18 +02:00
|
|
|
#endif /* defined __cplusplus */
|