OSDN Git Service

* cygtls.h (_threadinfo::call): Remove regparm declaration to work around
[pf3gnuchains/sourceware.git] / winsup / cygwin / winsup.h
index db30441..6c2e58f 100644 (file)
@@ -1,6 +1,6 @@
 /* winsup.h: main Cygwin header file.
 
-   Copyright 1996, 1997, 1998, 1999, 2000 Cygnus Solutions.
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -8,16 +8,20 @@ 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
 
 #define __INSIDE_CYGWIN__
 
-#ifdef __cplusplus
-
-#define alloca(x) __builtin_alloca (x)
 #define strlen __builtin_strlen
+#define strcmp __builtin_strcmp
 #define strcpy __builtin_strcpy
 #define memcpy __builtin_memcpy
 #define memcmp __builtin_memcmp
@@ -25,36 +29,65 @@ details. */
 # define memset __builtin_memset
 #endif
 
+#define NO_COPY __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy")))
+#define NO_COPY_INIT __attribute__((section(".data_cygwin_nocopy")))
+
 #if !defined(__STDC_VERSION__) || __STDC_VERSION__ >= 199900L
 #define NEW_MACRO_VARARGS
 #endif
 
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0500
+#endif
+
 #include <sys/types.h>
 #include <sys/strace.h>
-#include <sys/resource.h>
-#include <setjmp.h>
-#include <signal.h>
-#include <string.h>
-
-#undef strchr
-#define strchr cygwin_strchr
-extern "C" inline __stdcall char * strchr(const char * s, int c)
-{
-register char * __res;
-__asm__ __volatile__(
-       "movb %%al,%%ah\n"
-       "1:\tmovb (%1),%%al\n\t"
-       "cmpb %%ah,%%al\n\t"
-       "je 2f\n\t"
-       "incl %1\n\t"
-       "testb %%al,%%al\n\t"
-       "jne 1b\n\t"
-       "xorl %1,%1\n"
-       "2:\tmovl %1,%0\n\t"
-       :"=a" (__res), "=r" (s)
-       :"0" (c),      "1"  (s));
-return __res;
+
+/* 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[];
+#define cyg_toupper(c) (case_folded_upper[(unsigned char)(c)])
+
+#ifndef MALLOC_DEBUG
+#define cfree newlib_cfree_dont_use
+#endif
 
 #define WIN32_LEAN_AND_MEAN 1
 #define _WINGDI_H
@@ -65,6 +98,7 @@ return __res;
 #define _WINSVC_H
 #include <windows.h>
 #include <wincrypt.h>
+#include <lmcons.h>
 #undef _WINGDI_H
 #undef _WINUSER_H
 #undef _WINNLS_H
@@ -72,30 +106,30 @@ return __res;
 #undef _WINNETWK_H
 #undef _WINSVC_H
 
+#include "wincap.h"
+
 /* The one function we use from winuser.h most of the time */
 extern "C" DWORD WINAPI GetLastError (void);
 
-/* Used for runtime OS check/decisions. */
-enum os_type {winNT = 1, win95, win98, win32s, unknown};
-extern os_type os_being_run;
+enum codepage_type {ansi_cp, oem_cp};
+extern codepage_type current_codepage;
+
+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(CP_ACP,0,(src),-1,(tgt),(len),NULL,NULL)
-#define sys_mbstowcs(tgt,src,len) \
-                    MultiByteToWideChar(CP_ACP,0,(src),-1,(tgt),(len))
+extern int cygserver_running;
 
-#include <cygwin/version.h>
+#define _MT_SAFE       // DELTEME someday
 
 #define TITLESIZE 1024
-#define MAX_USER_NAME 20
-#define DEFAULT_UID 500
-#define DEFAULT_GID 544
-
-#define MAX_SID_LEN 40
-#define MAX_HOST_NAME 256
 
 /* status bit manipulation */
 #define __ISSETF(what, x, prefix) \
@@ -107,155 +141,26 @@ extern int dynamically_loaded;
 #define __CONDSETF(n, what, x, prefix) \
   ((n) ? __SETF (what, x, prefix) : __CLEARF (what, x, prefix))
 
-#include "thread.h"
-#include "shared.h"
-
-extern HANDLE hMainThread;
-extern HANDLE hMainProc;
-
 #include "debug.h"
-#include "sync.h"
-#include "sigproc.h"
-#include "fhandler.h"
-#include "path.h"
-#include <sys/cygwin.h>
-
-/********************** Application Interface **************************/
-
-extern "C" per_process __cygwin_user_data; /* Pointer into application's static data */
-#define user_data (&__cygwin_user_data)
-
-/* We use the following to test that sizeof hasn't changed.  When adding
-   or deleting members, insert fillers or use the reserved entries.
-   Do not change this value. */
-#define SIZEOF_PER_PROCESS (42 * 4)
-
-/******************* Host-dependent constants **********************/
-/* Portions of the cygwin DLL require special constants whose values
-   are dependent on the host system.  Rather than dynamically
-   determine those values whenever they are required, initialize these
-   values once at process start-up. */
-
-class host_dependent_constants
-{
- public:
-  void init (void);
-
-  /* Used by fhandler_disk_file::lock which needs a platform-specific
-     upper word value for locking entire files. */
-  DWORD win32_upper;
-
-  /* fhandler_base::open requires host dependent file sharing
-     attributes. */
-  int shared;
-};
-
-extern host_dependent_constants host_dependent;
 
 /* Events/mutexes */
 extern HANDLE title_mutex;
 
-/*************************** Per Thread ******************************/
-
-#define PER_THREAD_FORK_CLEAR ((void *)0xffffffff)
-class per_thread
-{
-  DWORD tls;
-  int clear_on_fork_p;
-public:
-  per_thread (int forkval = 1) {tls = TlsAlloc (); clear_on_fork_p = forkval;}
-  DWORD get_tls () {return tls;}
-  int clear_on_fork () {return clear_on_fork_p;}
-
-  virtual void *get () {return TlsGetValue (get_tls ());}
-  virtual size_t size () {return 0;}
-  virtual void set (void *s = NULL);
-  virtual void set (int n) {TlsSetValue (get_tls (), (void *)n);}
-  virtual void *create ()
-  {
-    void *s = new char [size ()];
-    memset (s, 0, size ());
-    set (s);
-    return s;
-  }
-};
-
-class per_thread_waitq : public per_thread
-{
-public:
-  per_thread_waitq () : per_thread (0) {}
-  void *get () {return (waitq *) this->per_thread::get ();}
-  void *create () {return (waitq *) this->per_thread::create ();}
-  size_t size () {return sizeof (waitq);}
-};
-
-struct vfork_save
-{
-  int pid;
-  jmp_buf j;
-  DWORD frame[100];
-  char **vfork_ebp;
-  char **vfork_esp;
-  int is_active () { return pid < 0; }
-};
-
-class per_thread_vfork : public per_thread
-{
-public:
-  vfork_save *val () { return (vfork_save *) this->per_thread::get (); }
-  vfork_save *create () {return (vfork_save *) this->per_thread::create ();}
-  size_t size () {return sizeof (vfork_save);}
-};
-
-extern "C" {
-struct signal_dispatch
-{
-  int arg;
-  void (*func) (int);
-  int sig;
-  int saved_errno;
-  DWORD oldmask;
-  DWORD retaddr;
-  DWORD *retaddr_on_stack;
-};
-};
-
-struct per_thread_signal_dispatch : public per_thread
-{
-  signal_dispatch *get () { return (signal_dispatch *) this->per_thread::get (); }
-  signal_dispatch *create () {return (signal_dispatch *) this->per_thread::create ();}
-  size_t size () {return sizeof (signal_dispatch);}
-};
-
-extern per_thread_waitq waitq_storage;
-extern per_thread_vfork vfork_storage;
-extern per_thread_signal_dispatch signal_dispatch_storage;
-
-extern per_thread *threadstuff[];
-
 /**************************** Convenience ******************************/
 
-#define NO_COPY __attribute__((section(".data_cygwin_nocopy")))
-
 /* 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 NOSTRACE
-#define MARK() 0
-#else
-#define MARK() mark (__FILE__,__LINE__)
-#endif
-
 #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
@@ -263,35 +168,53 @@ 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]))))
 
 /******************** Initialization/Termination **********************/
 
+class per_process;
 /* cygwin .dll initialization */
-void dll_crt0 (per_process *);
+void dll_crt0 (per_process *) __asm__ ("_dll_crt0__FP11per_process");
 extern "C" void __stdcall _dll_crt0 ();
 
 /* dynamically loaded dll initialization */
-extern "C" int dll_dllcrt0 (HMODULE, per_process*);
+extern "C" int dll_dllcrt0 (HMODULE, per_process *);
 
 /* 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));
 
-/* Initialize the environment */
-void environ_init (int);
+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
+  };
 
-/* Heap management. */
-void heap_init (void);
-void malloc_init (void);
+extern exit_states exit_state;
+void __stdcall do_exit (int) __attribute__ ((regparm (1), noreturn));
 
 /* UID/GID */
 void uinfo_init (void);
 
+#define ILLEGAL_UID16 ((__uid16_t)-1)
+#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 uid16touid32(u16)  ((u16)==ILLEGAL_UID16?ILLEGAL_UID:(__uid32_t)(u16))
+#define gid16togid32(g16)  ((g16)==ILLEGAL_GID16?ILLEGAL_GID:(__gid32_t)(g16))
+
 /* various events */
 void events_init (void);
 void events_terminate (void);
@@ -300,93 +223,93 @@ void __stdcall close_all_files (void);
 
 /* 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;
+extern HANDLE ws2_32_handle;
 
 /* 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*);
-extern "C" int try_to_debug ();
+extern "C" int try_to_debug (bool waitloop = 1);
+
+void set_file_api_mode (codepage_type);
 
 extern int cygwin_finished_initializing;
 
 /**************************** Miscellaneous ******************************/
 
-const char * __stdcall find_exec (const char *name, path_conv& buf, const char *winenv = "PATH=",
-                       int null_if_notfound = 0, const char **known_suffix = NULL);
-
-/* File manipulation */
-int __stdcall set_process_privileges ();
-int __stdcall get_file_attribute (int, const char *, int *,
-                                  uid_t * = NULL, gid_t * = NULL);
-int __stdcall set_file_attribute (int, const char *, int);
-int __stdcall set_file_attribute (int, const char *, uid_t, gid_t, int, const char *);
 void __stdcall set_std_handle (int);
 int __stdcall writable_directory (const char *file);
-int __stdcall stat_dev (DWORD, int, unsigned long, struct stat *);
-extern BOOL allow_ntsec;
+int __stdcall stat_dev (DWORD, int, unsigned long, struct __stat64 *);
 
-/* `lookup_name' should be called instead of LookupAccountName.
- * logsrv may be NULL, in this case only the local system is used for lookup.
- * The buffer for ret_sid (40 Bytes) has to be allocated by the caller! */
-BOOL __stdcall lookup_name (const char *, const char *, PSID);
-char *__stdcall convert_sid_to_string_sid (PSID, char *);
-PSID __stdcall convert_string_sid_to_sid (PSID, const char *);
-BOOL __stdcall get_pw_sid (PSID, struct passwd *);
+__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)));
 
-unsigned long __stdcall hash_path_name (unsigned long hash, const char *name);
-void __stdcall nofinalslash (const char *src, char *dst);
-extern "C" char *__stdcall rootdir (char *full_path);
+/* String manipulation */
+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)));
 
-void __stdcall mark (const char *, int);
+/* Time related */
+void __stdcall totimeval (struct timeval *dst, FILETIME * src, int sub, int flag);
+long __stdcall to_time_t (FILETIME * ptr);
+void __stdcall to_timestruc_t (FILETIME * ptr, timestruc_t * out);
+void __stdcall time_as_timestruc_t (timestruc_t * out);
 
-extern "C" int _spawnve (HANDLE hToken, int mode, const char *path,
-                        const char *const *argv, const char *const *envp);
+void __stdcall set_console_title (char *);
+void init_console_handler ();
+void init_global_security ();
 
-extern void __stdcall exec_fixup_after_fork ();
+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 (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)));
 
-/* For mmaps across fork(). */
-int __stdcall recreate_mmaps_after_fork (void *);
-void __stdcall set_child_mmap_ptr (_pinfo *);
+#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)))
 
-/* String manipulation */
-char *__stdcall strccpy (char *s1, const char **s2, char c);
-int __stdcall strcasematch (const char *s1, const char *s2);
-int __stdcall strncasematch (const char *s1, const char *s2, size_t n);
-char *__stdcall strcasestr (const char *searchee, const char *lookfor);
+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)));
 
-/* Time related */
-void __stdcall totimeval (struct timeval *dst, FILETIME * src, int sub, int flag);
-long __stdcall to_time_t (FILETIME * ptr);
+#define set_winsock_errno() __set_winsock_errno (__FUNCTION__, __LINE__)
+void __set_winsock_errno (const char *fn, int ln) __attribute__ ((regparm(2)));
 
-/* pinfo table manipulation */
-#ifndef lock_pinfo_for_update
-int __stdcall lock_pinfo_for_update (DWORD timeout);
-#endif
-void unlock_pinfo (void);
-void _stdcall set_myself (pid_t pid);
+extern bool wsock_started;
 
-/* Retrieve a security descriptor that allows all access */
-SECURITY_DESCRIPTOR *__stdcall get_null_sd (void);
+/* Printf type functions */
+extern "C" void __api_fatal (const char *, ...) __attribute__ ((noreturn));
+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)))*/;
+extern void multiple_cygwin_problem (const char *, unsigned, unsigned);
 
-int __stdcall get_id_from_sid (PSID, BOOL);
-extern inline int get_uid_from_sid (PSID psid) { return get_id_from_sid (psid, FALSE);}
-extern inline int get_gid_from_sid (PSID psid) { return get_id_from_sid (psid, TRUE); }
+int symlink_worker (const char *, const char *, bool, bool)
+  __attribute__ ((regparm (3)));
 
-int __stdcall NTReadEA (const char *file, const char *attrname, char *buf, int len);
-BOOL __stdcall NTWriteEA (const char *file, const char *attrname, char *buf, int len);
+class path_conv;
+int access_worker (path_conv&, int, class fhandler_base * = NULL) __attribute__ ((regparm (3)));
 
-void __stdcall set_console_title (char *);
-void set_console_handler ();
+int fcntl_worker (int fd, int cmd, void *arg);
 
-void __stdcall fill_rusage (struct rusage *, HANDLE);
-void __stdcall add_rusage (struct rusage *, struct rusage *);
+extern "C" int low_priority_sleep (DWORD) __attribute__ ((regparm (1)));
+#define SLEEP_0_STAY_LOW INFINITE
 
-void set_winsock_errno ();
+size_t getshmlba (void);
 
 /**************************** Exports ******************************/
 
@@ -399,71 +322,38 @@ int kill_pgrp (pid_t, int);
 int _kill (int, int);
 int _raise (int sig);
 
-int getfdtabsize ();
-void setfdtabsize (int);
-
 extern DWORD binmode;
 extern char _data_start__, _data_end__, _bss_start__, _bss_end__;
 extern void (*__CTOR_LIST__) (void);
 extern void (*__DTOR_LIST__) (void);
+extern SYSTEM_INFO system_info;
 };
 
 /*************************** 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].  */
-
-/* Initial and increment values for cygwin's fd table */
-#define NOFILE_INCR    32
-
-#include <sys/reent.h>
 
 #define STD_RBITS (S_IRUSR | S_IRGRP | S_IROTH)
 #define STD_WBITS (S_IWUSR)
 #define STD_XBITS (S_IXUSR | S_IXGRP | S_IXOTH)
+#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)
 
-#define O_NOSYMLINK 0x080000
-#define O_DIROPEN   0x100000
-
-/*************************** Environment ******************************/
+/* The title on program start. */
+extern char *old_title;
+extern bool display_title;
 
-/* The structure below is used to control conversion to/from posix-style
- * file specs.  Currently, only PATH and HOME are converted, but PATH
- * needs to use a "convert path list" function while HOME needs a simple
- * "convert to posix/win32".  For the simple case, where a calculated length
- * is required, just return MAX_PATH.  *FIXME*
- */
-struct win_env
-  {
-    const char *name;
-    size_t namelen;
-    char *posix;
-    char *native;
-    int (*toposix) (const char *, char *);
-    int (*towin32) (const char *, char *);
-    int (*posix_len) (const char *);
-    int (*win32_len) (const char *);
-    void add_cache (const char *in_posix, const char *in_native = NULL);
-    const char * get_native () {return native ? native + namelen : NULL;}
-  };
+extern HANDLE hMainThread;
+extern HANDLE hMainProc;
 
-win_env * __stdcall getwinenv (const char *name, const char *posix = NULL);
+extern bool cygwin_testing;
 
-void __stdcall update_envptrs ();
-char * __stdcall winenv (const char * const *, int);
-extern char **__cygwin_environ, ***main_environ;
-extern "C" char __stdcall **cur_environ ();
+extern char almost_null[];
 
-/* The title on program start. */
-extern char *old_title;
-extern BOOL display_title;
+#define winsock2_active (wsadata.wVersion >= 512)
+#define winsock_active (wsadata.wVersion < 512)
+extern struct WSAData wsadata;
 
 #endif /* defined __cplusplus */