import -ko -b 1.1.3 XEmacs XEmacs-21_2 r21-2-35
[chise/xemacs-chise.git.1] / src / s / cygwin32.h
1 /* system description file for cygwin32.
2    Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
3
4 This file is part of GNU Emacs.
5
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with XEmacs; see the file COPYING.  If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20
21 /* Building under cygwin
22  *
23  * The approach I have taken with this port is to use primarily the
24  * UNIX code base adding stuff that is MS-Windows specific. This works
25  * quite well, and is in keeping with my perception of the cygwin
26  * philosophy.  Note that if you make changes to this file you do NOT
27  * want to define WIN32_NATIVE (formerly "WINDOWSNT"), I repeat - do
28  * not define this, it will break everything horribly. What does get
29  * defined is HAVE_MS_WINDOWS, but this is done by configure and only
30  * applies to the window system.
31  *
32  * When building make sure your HOME path is unix style - i.e. without
33  * a drive letter.
34  *
35  * once you have done this, configure and make.
36  *
37  * windows '95 - I haven't tested this under '95, it will probably
38  * build but I konw there are some limitations with cygwin under 95 so
39  * YMMV. I build with NT4 SP3.
40  *
41  * Andy Piper <andy@xemacs.org> 8/1/98 
42  * http://www.xemacs.freeserve.co.uk/ */
43
44 /* Identify ourselves */
45 #define CYGWIN
46
47 /* cheesy way to determine cygwin version */
48 #ifndef NOT_C_CODE
49 # include <signal.h>
50 # ifdef HAVE_CYGWIN_VERSION_H
51 #  include <cygwin/version.h>
52 # else
53 #  ifdef SIGIO
54 #   define CYGWIN_VERSION_DLL_MAJOR 19
55 #   define CYGWIN_VERSION_DLL_MINOR 0
56 #   define CYGWIN_B19
57 #  else
58 #   define CYGWIN_VERSION_DLL_MAJOR 18
59 #   define CYGWIN_VERSION_DLL_MINOR 0
60 #   define BROKEN_CYGWIN
61 #  endif
62 # endif
63
64 void cygwin32_win32_to_posix_path_list (const char*, char*);
65 int cygwin32_win32_to_posix_path_list_buf_size (const char*);
66 void cygwin32_posix_to_win32_path_list (const char*, char*);
67 int cygwin32_posix_to_win32_path_list_buf_size (const char*);
68 # if CYGWIN_VERSION_DLL_MAJOR < 20
69 struct timeval;
70 struct timezone;
71 struct itimerval;
72 struct stat;
73 int gettimeofday (struct timeval *tp, struct timezone *tzp);
74 int gethostname (char* name, int namelen);
75 char*   mktemp (char *);
76 double  logb (double);
77 void    sync (void);
78 int     ioctl (int, int, ...);
79                         /* sys/stat.h */
80 int lstat (const char *path, struct stat *buf);
81                         /* unistd.h */
82 int readlink (const char *path, void *buf, unsigned int bufsiz);
83 int symlink (const char *name1, const char *name2);
84                         /* sys/time.h */
85 int setitimer (int which, const struct itimerval *value,
86               struct itimerval *ovalue);
87 int utimes (char *file, struct timeval *tvp);
88
89 int srandom (unsigned seed);
90 long random (void);
91
92 # endif /* CYGWIN_VERSION_DLL_MAJOR < 20 */
93
94 # if CYGWIN_VERSION_DLL_MAJOR <= 20
95 char *getpass (const char *prompt);
96 double logb (double);
97 # endif /* CYGWIN_VERSION_DLL_MAJOR <= 20 */
98
99 #endif
100
101 #ifndef ORDINARY_LINK
102 #define ORDINARY_LINK
103 #endif
104
105 #define C_SWITCH_SYSTEM -Wno-sign-compare -fno-caller-saves
106 #define LIBS_SYSTEM -lwinmm
107 #define WIN32_LEAN_AND_MEAN
108
109 #define TEXT_START -1
110 #define TEXT_END -1
111 #define DATA_END -1
112 #define HEAP_IN_DATA
113 #define NO_LIM_DATA
114 #define UNEXEC "unexcw.o"
115
116 #ifdef CYGWIN_VERSION_DLL_MAJOR
117 #if 0
118 /* #### FIXME: although defining BROKEN_SIGIO is correct for proper ^G
119    behavior, bugs in cygwin mean that xemacs locks up frequently if
120    this is defined.  */
121 #define BROKEN_SIGIO
122 #endif
123 #else
124 #define PROCESS_IO_BLOCKING
125 #endif
126 #define strnicmp strncasecmp
127 #ifndef HAVE_SOCKETS
128 #define HAVE_SOCKETS
129 #endif
130 #define OBJECTS_SYSTEM  ntplay.o
131
132 #undef MAIL_USE_SYSTEM_LOCK
133
134 /* Define NO_ARG_ARRAY if you cannot take the address of the first of a
135  * group of arguments and treat it as an array of the arguments.  */
136
137 #define NO_ARG_ARRAY
138
139 /* Data type of load average, as read out of kmem.  */
140
141 #define LOAD_AVE_TYPE long
142
143 /* Convert that into an integer that is 100 for a load average of 1.0  */
144
145 #define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / FSCALE)
146
147 /* Define VIRT_ADDR_VARIES if the virtual addresses of
148    pure and impure space as loaded can vary, and even their
149    relative order cannot be relied on.
150
151    Otherwise Emacs assumes that text space precedes data space,
152    numerically.  */
153
154 /* Text does precede data space, but this is never a safe assumption.  */
155 #define VIRT_ADDR_VARIES
156
157 /* If you are compiling with a non-C calling convention but need to
158    declare vararg routines differently, put it here */
159 #define _VARARGS_ __cdecl
160
161 /* If you are providing a function to something that will call the
162    function back (like a signal handler and signal, or main) its calling
163    convention must be whatever standard the libraries expect */
164 #define _CALLBACK_ __cdecl
165
166 /* SYSTEM_TYPE should indicate the kind of system you are using.
167  It sets the Lisp variable system-type.  */
168
169 #define SYSTEM_TYPE "cygwin32"
170
171 #define NO_MATHERR
172
173 /* define MAIL_USE_FLOCK if the mailer uses flock
174    to interlock access to /usr/spool/mail/$USER.
175    The alternative is that a lock file named
176    /usr/spool/mail/$USER.lock.  */
177
178 /* If the character used to separate elements of the executable path
179    is not ':', #define this to be the appropriate character constant.  */
180 #define SEPCHAR ':'
181
182 /* ============================================================ */
183
184 /* Here, add any special hacks needed
185    to make Emacs work on this system.  For example,
186    you might define certain system call names that don't
187    exist on your system, or that do different things on
188    your system and must be used only through an encapsulation
189    (Which you should place, by convention, in sysdep.c).  */
190
191 /* Define this to be the separator between path elements */
192 /* #define DIRECTORY_SEP XINT (Vdirectory_sep_char) */
193
194 /* Define this to be the separator between devices and paths */
195 #define DEVICE_SEP ':'
196
197 /* We'll support either convention on NT.  */
198 #define IS_DIRECTORY_SEP(_c_) ((_c_) == '/' || (_c_) == '\\')
199 #define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP (_c_))
200 #define EXEC_SUFFIXES   ".exe:.com:.bat:.cmd:"
201
202 /* We need a little extra space, see ../../lisp/loadup.el */
203 #define SYSTEM_PURESIZE_EXTRA 15000
204
205 #define CYGWIN_CONV_PATH(src, dst) \
206 dst = alloca (cygwin32_win32_to_posix_path_list_buf_size(src)); \
207 cygwin32_win32_to_posix_path_list(src, dst)
208 #define CYGWIN_WIN32_PATH(src, dst) \
209 dst = alloca (cygwin32_posix_to_win32_path_list_buf_size(src)); \
210 cygwin32_posix_to_win32_path_list(src, dst)
211
212 /*
213  * stolen from usg.
214  */
215 #define HAVE_PTYS
216 #define FIRST_PTY_LETTER 'z'
217
218 /* Pseudo-terminal support under SVR4 only loops to deal with errors. */
219
220 #define PTY_ITERATION for (i = 0, c = 0; i < 1; i++)
221
222 /* This sets the name of the master side of the PTY. */
223
224 #define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptmx");
225
226 /* This sets the name of the slave side of the PTY.  On SysVr4,
227    grantpt(3) forks a subprocess, so keep sigchld_handler() from
228    intercepting that death.  If any child but grantpt's should die
229    within, it should be caught after EMACS_UNBLOCK_SIGNAL. */
230
231 #define PTY_OPEN \
232    fd = open (pty_name, O_RDWR | O_NONBLOCK | OPEN_BINARY, 0)
233
234 #define PTY_TTY_NAME_SPRINTF                            \
235   {                                                     \
236     extern char* ptsname(int);                          \
237     char *ptyname;                                      \
238                                                         \
239     if (!(ptyname = ptsname (fd)))                      \
240       { close (fd); return -1; }                        \
241     strncpy (pty_name, ptyname, sizeof (pty_name));     \
242     pty_name[sizeof (pty_name) - 1] = 0;                \
243   }
244
245 /* ============================================================ */
246