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