X-Git-Url: https://sourceware.org/git/?a=blobdiff_plain;f=winsup%2Fcygwin%2Fwinsup.h;h=9be8d679d99c00ee9467a25f4db45315bc41d7d1;hb=72c1491bba149c8fbd9eb81a0a529aa8bad47bb5;hp=2758569a58de568f06e0c097fcea9bc8d86b780d;hpb=c4e6ff484c1e6a57304d14ba46852054e98e9158;p=newlib-cygwin.git diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h index 2758569a5..9be8d679d 100644 --- a/winsup/cygwin/winsup.h +++ b/winsup/cygwin/winsup.h @@ -1,6 +1,6 @@ /* winsup.h: main Cygwin header file. - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc. This file is part of Cygwin. @@ -8,6 +8,12 @@ This software is a copyrighted work licensed under the terms of the Cygwin license. Please consult the file "CYGWIN_LICENSE" for details. */ +#ifdef DEBUGIT +#define spf(a, b, c) small_printf (a, b, c) +#else +#define spf(a, b, c) do {} while (0) +#endif + #ifdef HAVE_CONFIG_H # include "config.h" #endif @@ -24,23 +30,58 @@ details. */ #endif #define NO_COPY __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy"))) +#define NO_COPY_INIT __attribute__((section(".data_cygwin_nocopy"))) -#ifdef EXPCGF -#define DECLARE_TLS_STORAGE char **tls[4096] __attribute__ ((unused)) -#else -#define DECLARE_TLS_STORAGE do {} while (0) -#define _WINBASE2_H -#endif - -#ifdef __cplusplus +#define EXPORT_ALIAS(sym,symalias) extern "C" __typeof (sym) symalias __attribute__ ((alias(#sym))); #if !defined(__STDC_VERSION__) || __STDC_VERSION__ >= 199900L #define NEW_MACRO_VARARGS #endif +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0501 +#endif + #include #include +/* Declarations for functions used in C and C++ code. */ +#ifdef __cplusplus +extern "C" { +#endif +extern __uid32_t getuid32 (void); +extern __uid32_t geteuid32 (void); +extern int seteuid32 (__uid32_t); +extern __gid32_t getegid32 (void); +extern struct passwd *getpwuid32 (__uid32_t); +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); + +#ifdef __cplusplus +} +#endif + +/* 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) + +#ifdef __cplusplus + extern const char case_folded_lower[]; #define cyg_tolower(c) (case_folded_lower[(unsigned char)(c)]) extern const char case_folded_upper[]; @@ -75,48 +116,48 @@ extern "C" DWORD WINAPI GetLastError (void); enum codepage_type {ansi_cp, oem_cp}; extern codepage_type current_codepage; -extern int cygserver_running; +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))); /* Used to check if Cygwin DLL is dynamically loaded. */ extern int dynamically_loaded; -#define sys_wcstombs(tgt,src,len) \ - WideCharToMultiByte((current_codepage==ansi_cp?CP_ACP:CP_OEMCP),0,(src),-1,(tgt),(len),NULL,NULL) -#define sys_mbstowcs(tgt,src,len) \ - MultiByteToWideChar((current_codepage==ansi_cp?CP_ACP:CP_OEMCP),0,(src),-1,(tgt),(len)) +extern int cygserver_running; + +#define _MT_SAFE // DELTEME someday #define TITLESIZE 1024 -/* 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; +extern HANDLE tty_mutex; /**************************** Convenience ******************************/ +/* 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; } + /* Used when treating / and \ as equivalent. */ -#define SLASH_P(ch) \ +#define isdirsep(ch) \ ({ \ char __c = (ch); \ ((__c) == '/' || (__c) == '\\'); \ }) /* Convert a signal to a signal mask */ -#define SIGTOMASK(sig) (1<<((sig) - signal_shift_subtract)) +#define SIGTOMASK(sig) (1 << ((sig) - signal_shift_subtract)) extern unsigned int signal_shift_subtract; #ifdef NEW_MACRO_VARARGS -# define api_fatal(...) __api_fatal ("%P: *** " __VA_ARGS__) +# define api_fatal(...) __api_fatal (__VA_ARGS__) #else # define api_fatal(fmt, args...) __api_fatal ("%P: *** " fmt,## args) #endif @@ -124,7 +165,6 @@ extern unsigned int signal_shift_subtract; #undef issep #define issep(ch) (strchr (" \t\n\r", (ch)) != NULL) -#define isdirsep SLASH_P #define isabspath(p) \ (isdirsep (*(p)) || (isalpha (*(p)) && (p)[1] == ':' && (!(p)[2] || isdirsep ((p)[2])))) @@ -142,7 +182,24 @@ extern "C" int dll_dllcrt0 (HMODULE, per_process *); extern "C" int dll_noncygwin_dllcrt0 (HMODULE, per_process *); /* exit the program */ -extern "C" void __stdcall do_exit (int) __attribute__ ((noreturn)); + +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, + ES_TTY_TERMINATE, + ES_FINAL + }; + +extern exit_states exit_state; +void __stdcall do_exit (int) __attribute__ ((regparm (1), noreturn)); /* UID/GID */ void uinfo_init (void); @@ -151,25 +208,19 @@ void uinfo_init (void); #define ILLEGAL_UID ((__uid32_t)-1) #define ILLEGAL_GID16 ((__gid16_t)-1) #define ILLEGAL_GID ((__gid32_t)-1) -#define ILLEGAL_SEEK ((__off64_t)-1) +#define ILLEGAL_SEEK ((_off64_t)-1) #define uid16touid32(u16) ((u16)==ILLEGAL_UID16?ILLEGAL_UID:(__uid32_t)(u16)) #define gid16togid32(g16) ((g16)==ILLEGAL_GID16?ILLEGAL_GID:(__gid32_t)(g16)) -extern "C" __uid32_t getuid32 (void); -extern "C" __uid32_t geteuid32 (void); -extern "C" struct passwd *getpwuid32 (__uid32_t); - /* various events */ void events_init (void); void events_terminate (void); -void __stdcall close_all_files (void); -BOOL __stdcall check_pty_fds (void); +void __stdcall close_all_files (); -/* Invisible window initialization/termination. */ -HWND __stdcall gethwnd (void); -void __stdcall window_terminate (void); +/* Check if running in a visible window station. */ +extern bool has_visible_window_station (void); /* Globals that handle initialization of winsock in a child process. */ extern HANDLE wsock32_handle; @@ -184,18 +235,16 @@ extern "C" int try_to_debug (bool waitloop = 1); void set_file_api_mode (codepage_type); -extern int cygwin_finished_initializing; +extern bool cygwin_finished_initializing; /**************************** Miscellaneous ******************************/ void __stdcall set_std_handle (int); -int __stdcall writable_directory (const char *file); int __stdcall stat_dev (DWORD, int, unsigned long, struct __stat64 *); -extern BOOL allow_ntsec; -unsigned long __stdcall hash_path_name (unsigned long hash, const char *name) __attribute__ ((regparm(2))); +__ino64_t __stdcall hash_path_name (__ino64_t 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))); +extern "C" char *__stdcall rootdir (const char *full_path, char *root_path) __attribute__ ((regparm(2))); /* String manipulation */ extern "C" char *__stdcall strccpy (char *s1, const char **s2, char c); @@ -210,20 +259,29 @@ void __stdcall to_timestruc_t (FILETIME * ptr, timestruc_t * out); void __stdcall time_as_timestruc_t (timestruc_t * out); void __stdcall set_console_title (char *); -void early_stuff_init (); +void init_console_handler (); +void init_global_security (); int __stdcall check_null_str (const char *name) __attribute__ ((regparm(1))); 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))); int __stdcall check_null_str_errno (const char *name) __attribute__ ((regparm(1))); -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_null_invalid_struct (void *s, unsigned sz) __attribute__ ((regparm(2))); +int __stdcall __check_null_invalid_struct_errno (void *s, unsigned sz) __attribute__ ((regparm(2))); +int __stdcall __check_invalid_read_ptr (const void *s, unsigned sz) __attribute__ ((regparm(2))); int __stdcall __check_invalid_read_ptr_errno (const void *s, unsigned sz) __attribute__ ((regparm(2))); +int __stdcall check_invalid_virtual_addr (const void *s, unsigned sz) __attribute__ ((regparm(2))); #define check_null_invalid_struct(s) \ __check_null_invalid_struct ((s), sizeof (*(s))) #define check_null_invalid_struct_errno(s) \ __check_null_invalid_struct_errno ((s), sizeof (*(s))) +#define check_invalid_read_struct_errno(s) \ + __check_invalid_read_ptr_errno ((s), sizeof (*(s))) + +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))); #define set_winsock_errno() __set_winsock_errno (__FUNCTION__, __LINE__) void __set_winsock_errno (const char *fn, int ln) __attribute__ ((regparm(2))); @@ -236,12 +294,20 @@ extern "C" int __small_sprintf (char *dst, const char *fmt, ...) /*__attribute__ extern "C" int __small_vsprintf (char *dst, const char *fmt, va_list ap) /*__attribute__ ((regparm (3)))*/; extern void multiple_cygwin_problem (const char *, unsigned, unsigned); -extern "C" void __malloc_lock (struct _reent *); -extern "C" void __malloc_unlock (struct _reent *); +int symlink_worker (const char *, const char *, bool, bool) + __attribute__ ((regparm (3))); class path_conv; -int __stdcall stat_worker (const char *name, struct __stat64 *buf, int nofollow, - path_conv *pc = NULL) __attribute__ ((regparm (3))); + +int fcntl_worker (int fd, int cmd, void *arg); + +extern "C" int low_priority_sleep (DWORD) __attribute__ ((regparm (1))); +#define SLEEP_0_STAY_LOW INFINITE + +size_t getshmlba (void); + +int winprio_to_nice (DWORD) __attribute__ ((regparm (1))); +DWORD nice_to_winprio (int &) __attribute__ ((regparm (1))); /**************************** Exports ******************************/ @@ -250,10 +316,6 @@ 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); - extern DWORD binmode; extern char _data_start__, _data_end__, _bss_start__, _bss_end__; extern void (*__CTOR_LIST__) (void); @@ -265,14 +327,6 @@ extern SYSTEM_INFO system_info; #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]. */ #define STD_RBITS (S_IRUSR | S_IRGRP | S_IROTH) #define STD_WBITS (S_IWUSR) @@ -283,17 +337,16 @@ extern SYSTEM_INFO system_info; /* The title on program start. */ extern char *old_title; -extern BOOL display_title; +extern bool display_title; extern HANDLE hMainThread; extern HANDLE hMainProc; extern bool cygwin_testing; -extern unsigned _cygwin_testing_magic; -extern HMODULE cygwin_hmodule; + +extern char almost_null[]; #define winsock2_active (wsadata.wVersion >= 512) -#define winsock_active (wsadata.wVersion < 512) extern struct WSAData wsadata; #endif /* defined __cplusplus */