openenvutils/commandshell/shell/inc/system.h
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 /*
       
     2  * system.h - system configuration header file
       
     3  *
       
     4  * This file is part of zsh, the Z shell.
       
     5  *
       
     6  * Copyright (c) 1992-1997 Paul Falstad
       
     7  * All rights reserved.
       
     8  *
       
     9  * Permission is hereby granted, without written agreement and without
       
    10  * license or royalty fees, to use, copy, modify, and distribute this
       
    11  * software and to distribute modified versions of this software for any
       
    12  * purpose, provided that the above copyright notice and the following
       
    13  * two paragraphs appear in all copies of this software.
       
    14  *
       
    15  * In no event shall Paul Falstad or the Zsh Development Group be liable
       
    16  * to any party for direct, indirect, special, incidental, or consequential
       
    17  * damages arising out of the use of this software and its documentation,
       
    18  * even if Paul Falstad and the Zsh Development Group have been advised of
       
    19  * the possibility of such damage.
       
    20  *
       
    21  * Paul Falstad and the Zsh Development Group specifically disclaim any
       
    22  * warranties, including, but not limited to, the implied warranties of
       
    23  * merchantability and fitness for a particular purpose.  The software
       
    24  * provided hereunder is on an "as is" basis, and Paul Falstad and the
       
    25  * Zsh Development Group have no obligation to provide maintenance,
       
    26  * support, updates, enhancements, or modifications.
       
    27  *
       
    28  */
       
    29 
       
    30 #if 0
       
    31 /*
       
    32  * Setting _XPG_IV here is actually wrong and is not needed
       
    33  * with currently supported versions (5.43C20 and above)
       
    34  */
       
    35 #ifdef sinix
       
    36 # define _XPG_IV 1
       
    37 #endif
       
    38 #endif
       
    39 
       
    40 #ifdef __linux
       
    41 /*
       
    42  * Turn on numerous extensions.
       
    43  * This is in order to get the functions for manipulating /dev/ptmx.
       
    44  */
       
    45 #define _GNU_SOURCE 1
       
    46 #endif
       
    47 
       
    48 /* NeXT has half-implemented POSIX support *
       
    49  * which currently fools configure         */
       
    50 #ifdef __NeXT__
       
    51 # undef HAVE_TERMIOS_H
       
    52 # undef HAVE_SYS_UTSNAME_H
       
    53 #endif
       
    54 
       
    55 #ifdef PROTOTYPES
       
    56 # define _(Args) Args
       
    57 #else
       
    58 # define _(Args) ()
       
    59 #endif
       
    60 
       
    61 #ifndef HAVE_ALLOCA
       
    62 # define alloca zhalloc
       
    63 #else
       
    64 # ifdef __GNUC__
       
    65 #  define alloca __builtin_alloca
       
    66 # else
       
    67 #  if HAVE_ALLOCA_H
       
    68 #   include <alloca.h>
       
    69 #  else
       
    70 #   ifdef _AIX
       
    71  #   pragma alloca
       
    72 #   else
       
    73 #    ifndef alloca
       
    74 char *alloca _((size_t));
       
    75 #    endif
       
    76 #   endif
       
    77 #  endif
       
    78 # endif
       
    79 #endif
       
    80 
       
    81 /*
       
    82  * libc.h in an optional package for Debian Linux is broken (it
       
    83  * defines dup() as a synonym for dup2(), which has a different
       
    84  * number of arguments), so just include it for next.
       
    85  */
       
    86 #ifdef __NeXT__
       
    87 # ifdef HAVE_LIBC_H
       
    88 #  include <libc.h>
       
    89 # endif
       
    90 #endif
       
    91 
       
    92 #ifdef HAVE_SYS_TYPES_H
       
    93 # include <sys/types.h>
       
    94 #endif
       
    95 
       
    96 #ifdef HAVE_UNISTD_H
       
    97 # include <unistd.h>
       
    98 #endif
       
    99 
       
   100 #ifdef HAVE_STDDEF_H
       
   101 /*
       
   102  * Seen on Solaris 8 with gcc: stddef defines offsetof, which clashes
       
   103  * with system.h's definition of the symbol unless we include this
       
   104  * first.  Otherwise, this will be hooked in by wchar.h, too late
       
   105  * for comfort.
       
   106  */
       
   107 #include <stddef.h>
       
   108 #endif
       
   109 
       
   110 #include <stdio.h>
       
   111 #include <ctype.h>
       
   112 #include <sys/stat.h>
       
   113 //#include <signal.h>
       
   114 #include "dummy.h"
       
   115 #include <setjmp.h>
       
   116 
       
   117 #ifdef HAVE_PWD_H
       
   118 # include <pwd.h>
       
   119 #endif
       
   120 
       
   121 #ifdef HAVE_GRP_H
       
   122 # include <grp.h>
       
   123 #endif
       
   124 
       
   125 #ifdef HAVE_DIRENT_H
       
   126 # include <dirent.h>
       
   127 #else /* !HAVE_DIRENT_H */
       
   128 # ifdef HAVE_SYS_NDIR_H
       
   129 #  include <sys/ndir.h>
       
   130 # endif
       
   131 # ifdef HAVE_SYS_DIR_H
       
   132 #  include <sys/dir.h>
       
   133 # endif
       
   134 # ifdef HAVE_NDIR_H
       
   135 #  include <ndir.h>
       
   136 # endif
       
   137 # define dirent direct
       
   138 # undef HAVE_STRUCT_DIRENT_D_INO
       
   139 # undef HAVE_STRUCT_DIRENT_D_STAT
       
   140 # ifdef HAVE_STRUCT_DIRECT_D_INO
       
   141 #  define HAVE_STRUCT_DIRENT_D_INO HAVE_STRUCT_DIRECT_D_INO
       
   142 # endif
       
   143 # ifdef HAVE_STRUCT_DIRECT_D_STAT
       
   144 #  define HAVE_STRUCT_DIRENT_D_STAT HAVE_STRUCT_DIRECT_D_STAT
       
   145 # endif
       
   146 #endif /* !HAVE_DIRENT_H */
       
   147 
       
   148 #ifdef HAVE_STDLIB_H
       
   149 # ifdef ZSH_MEM
       
   150    /* malloc and calloc are macros in GNU's stdlib.h unless the
       
   151     * the __MALLOC_0_RETURNS_NULL macro is defined */
       
   152 #  define __MALLOC_0_RETURNS_NULL
       
   153 # endif
       
   154 # include <stdlib.h>
       
   155 #endif
       
   156 
       
   157 #ifdef HAVE_ERRNO_H
       
   158 # include <errno.h>
       
   159 #endif
       
   160 
       
   161 #ifdef TIME_WITH_SYS_TIME
       
   162 # include <sys/time.h>
       
   163 # include <time.h>
       
   164 #else
       
   165 # ifdef HAVE_SYS_TIME_H
       
   166 # include <sys/time.h>
       
   167 # else
       
   168 #  include <time.h>
       
   169 # endif
       
   170 #endif
       
   171 
       
   172 /* This is needed by some old SCO unices */
       
   173 #ifndef HAVE_STRUCT_TIMEZONE
       
   174 struct timezone {
       
   175     int tz_minuteswest;
       
   176     int tz_dsttime;
       
   177 };
       
   178 #endif
       
   179 
       
   180 /* There's more than one non-standard way to get at this data */
       
   181 #if !defined(HAVE_STRUCT_DIRENT_D_INO) && defined(HAVE_STRUCT_DIRENT_D_STAT)
       
   182 # define d_ino d_stat.st_ino
       
   183 # define HAVE_STRUCT_DIRENT_D_INO HAVE_STRUCT_DIRENT_D_STAT
       
   184 #endif /* !HAVE_STRUCT_DIRENT_D_INO && HAVE_STRUCT_DIRENT_D_STAT */
       
   185 
       
   186 /* Sco needs the following include for struct utimbuf *
       
   187  * which is strange considering we do not use that    *
       
   188  * anywhere in the code                               */
       
   189 #ifdef __sco
       
   190 # include <utime.h>
       
   191 #endif
       
   192 
       
   193 #ifdef HAVE_SYS_TIMES_H
       
   194 # include "times.h" 
       
   195 #endif
       
   196 
       
   197 #if STDC_HEADERS || HAVE_STRING_H
       
   198 # include <string.h>
       
   199 /* An ANSI string.h and pre-ANSI memory.h might conflict.  */
       
   200 # if !STDC_HEADERS && HAVE_MEMORY_H
       
   201 #  include <memory.h>
       
   202 # endif /* not STDC_HEADERS and HAVE_MEMORY_H */
       
   203 #else   /* not STDC_HEADERS and not HAVE_STRING_H */
       
   204 # include <strings.h>
       
   205 /* memory.h and strings.h conflict on some systems.  */
       
   206 #endif /* not STDC_HEADERS and not HAVE_STRING_H */
       
   207 
       
   208 #ifdef HAVE_LOCALE_H
       
   209 # include <locale.h>
       
   210 #endif
       
   211 
       
   212 #ifdef HAVE_LIMITS_H
       
   213 # include <limits.h>
       
   214 #endif
       
   215 
       
   216 #ifdef HAVE_VARIABLE_LENGTH_ARRAYS
       
   217 # define VARARR(X,Y,Z)	X (Y)[Z]
       
   218 #else
       
   219 # define VARARR(X,Y,Z)	X *(Y) = (X *) alloca(sizeof(X) * (Z))
       
   220 #endif
       
   221 
       
   222 #ifndef __SYMBIAN32__ //defined in sys/syslimits.h
       
   223 /* we should handle unlimited sizes from pathconf(_PC_PATH_MAX) */
       
   224 /* but this is too much trouble                                 */
       
   225 #ifndef PATH_MAX
       
   226 # ifdef MAXPATHLEN
       
   227 #  define PATH_MAX MAXPATHLEN
       
   228 # else
       
   229 #  ifdef _POSIX_PATH_MAX
       
   230 #   define PATH_MAX _POSIX_PATH_MAX
       
   231 #  else
       
   232     /* so we will just pick something */
       
   233 #   define PATH_MAX 1024
       
   234 #  endif
       
   235 # endif
       
   236 #endif
       
   237 #endif //__SYMBIAN32__
       
   238 
       
   239 #ifndef OPEN_MAX
       
   240 # ifdef NOFILE
       
   241 #  define OPEN_MAX NOFILE
       
   242 # else
       
   243    /* so we will just pick something */
       
   244 #  define OPEN_MAX 64
       
   245 # endif
       
   246 #endif
       
   247 #ifndef HAVE_SYSCONF
       
   248 # define zopenmax() ((long) OPEN_MAX)
       
   249 #endif
       
   250 
       
   251 #ifdef HAVE_FCNTL_H
       
   252 # include <fcntl.h>
       
   253 #else
       
   254 # include <sys/file.h>
       
   255 #endif
       
   256 
       
   257 /* The following will only be defined if <sys/wait.h> is POSIX.    *
       
   258  * So we don't have to worry about union wait. But some machines   *
       
   259  * (NeXT) include <sys/wait.h> from other include files, so we     *
       
   260  * need to undef and then redefine the wait macros if <sys/wait.h> *
       
   261  * is not POSIX.                                                   */
       
   262 
       
   263 #ifdef HAVE_SYS_WAIT_H
       
   264 # include <sys/wait.h>
       
   265 #else
       
   266 # undef WIFEXITED
       
   267 # undef WEXITSTATUS
       
   268 # undef WIFSIGNALED
       
   269 # undef WTERMSIG
       
   270 # undef WCOREDUMP
       
   271 # undef WIFSTOPPED
       
   272 # undef WSTOPSIG
       
   273 #endif
       
   274 
       
   275 /* missing macros for wait/waitpid/wait3 */
       
   276 #ifndef WIFEXITED
       
   277 # define WIFEXITED(X) (((X)&0377)==0)
       
   278 #endif
       
   279 #ifndef WEXITSTATUS
       
   280 # define WEXITSTATUS(X) (((X)>>8)&0377)
       
   281 #endif
       
   282 #ifndef WIFSIGNALED
       
   283 # define WIFSIGNALED(X) (((X)&0377)!=0&&((X)&0377)!=0177)
       
   284 #endif
       
   285 #ifndef WTERMSIG
       
   286 # define WTERMSIG(X) ((X)&0177)
       
   287 #endif
       
   288 #ifndef WCOREDUMP
       
   289 # define WCOREDUMP(X) ((X)&0200)
       
   290 #endif
       
   291 #ifndef WIFSTOPPED
       
   292 # define WIFSTOPPED(X) (((X)&0377)==0177)
       
   293 #endif
       
   294 #ifndef WSTOPSIG
       
   295 # define WSTOPSIG(X) (((X)>>8)&0377)
       
   296 #endif
       
   297 
       
   298 #ifdef HAVE_SYS_SELECT_H
       
   299 # ifndef TIME_H_SELECT_H_CONFLICTS
       
   300 #  include <sys/select.h>
       
   301 # endif
       
   302 #elif defined(SELECT_IN_SYS_SOCKET_H)
       
   303 # include <sys/socket.h>
       
   304 #endif
       
   305 
       
   306 #if defined(__APPLE__) && defined(HAVE_SELECT)
       
   307 /*
       
   308  * Prefer select() to poll() on MacOS X since poll() is known
       
   309  * to be problematic in 10.4
       
   310  */
       
   311 #undef HAVE_POLL
       
   312 #undef HAVE_POLL_H
       
   313 #endif
       
   314 
       
   315 #ifdef HAVE_SYS_FILIO_H
       
   316 # include <sys/filio.h>
       
   317 #endif
       
   318 
       
   319 #ifdef HAVE_TERMIOS_H
       
   320 
       
   321 #ifndef __SYMBIAN32__
       
   322 # ifdef __sco 
       
   323 #  include <sys/termios.h>
       
   324 #endif
       
   325    /* termios.h includes sys/termio.h instead of sys/termios.h; *
       
   326     * hence the declaration for struct termios is missing       */
       
   327 #else 
       
   328 #  include "termios.h"
       
   329 #endif //__SYMBIAN32__
       
   330 
       
   331 //# else
       
   332 //#  include <termios.h>
       
   333 //# endif
       
   334 # ifdef _POSIX_VDISABLE
       
   335 #  define VDISABLEVAL _POSIX_VDISABLE
       
   336 # else
       
   337 #  define VDISABLEVAL 0
       
   338 # endif
       
   339 # define HAS_TIO 1
       
   340 #else    /* not TERMIOS */
       
   341 # ifdef HAVE_TERMIO_H
       
   342 #  include <termio.h>
       
   343 #  define VDISABLEVAL -1
       
   344 #  define HAS_TIO 1
       
   345 # else   /* not TERMIOS and TERMIO */
       
   346 #  include <sgtty.h>
       
   347 # endif  /* HAVE_TERMIO_H  */
       
   348 #endif   /* HAVE_TERMIOS_H */
       
   349 
       
   350 #if defined(GWINSZ_IN_SYS_IOCTL) || defined(CLOBBERS_TYPEAHEAD)
       
   351 # include <sys/ioctl.h>
       
   352 #endif
       
   353 #ifdef WINSIZE_IN_PTEM
       
   354 # include <sys/stream.h>
       
   355 # include <sys/ptem.h>
       
   356 #endif
       
   357 
       
   358 #ifdef HAVE_SYS_PARAM_H
       
   359 # include <sys/param.h>
       
   360 #endif
       
   361 
       
   362 #ifdef HAVE_SYS_UTSNAME_H
       
   363 # include <sys/utsname.h>
       
   364 #endif
       
   365 
       
   366 #define DEFAULT_WORDCHARS "*?_-.[]~=/&;!#$%^(){}<>"
       
   367 #define DEFAULT_TIMEFMT   "%J  %U user %S system %P cpu %*E total"
       
   368 
       
   369 /* Posix getpgrp takes no argument, while the BSD version *
       
   370  * takes the process ID as an argument                    */
       
   371 #ifdef GETPGRP_VOID
       
   372 # define GETPGRP() getpgrp()
       
   373 #else
       
   374 # define GETPGRP() getpgrp(0)
       
   375 #endif
       
   376 
       
   377 #ifndef HAVE_GETLOGIN
       
   378 # define getlogin() cuserid(NULL)
       
   379 #endif
       
   380 
       
   381 #ifdef HAVE_SETPGID
       
   382 # define setpgrp setpgid
       
   383 #endif
       
   384 
       
   385 /* can we set the user/group id of a process */
       
   386 
       
   387 #ifndef HAVE_SETUID
       
   388 # ifdef HAVE_SETREUID
       
   389 #  define setuid(X) setreuid(X,X)
       
   390 #  define setgid(X) setregid(X,X)
       
   391 #  define HAVE_SETUID
       
   392 # endif
       
   393 #endif
       
   394 
       
   395 /* can we set the effective user/group id of a process */
       
   396 
       
   397 #ifndef HAVE_SETEUID
       
   398 # ifdef HAVE_SETREUID
       
   399 #  define seteuid(X) setreuid(-1,X)
       
   400 #  define setegid(X) setregid(-1,X)
       
   401 #  define HAVE_SETEUID
       
   402 # else
       
   403 #  ifdef HAVE_SETRESUID
       
   404 #   define seteuid(X) setresuid(-1,X,-1)
       
   405 #   define setegid(X) setresgid(-1,X,-1)
       
   406 #   define HAVE_SETEUID
       
   407 #  endif
       
   408 # endif
       
   409 #endif
       
   410 
       
   411 #ifdef HAVE_SYS_RESOURCE_H
       
   412 # include <sys/resource.h>
       
   413 # if defined(__hpux) && !defined(RLIMIT_CPU)
       
   414 /* HPUX does have the BSD rlimits in the kernel.  Officially they are *
       
   415  * unsupported but quite a few of them like RLIMIT_CORE seem to work. *
       
   416  * All the following are in the <sys/resource.h> but made visible     *
       
   417  * only for the kernel.                                               */
       
   418 #  define	RLIMIT_CPU	0
       
   419 #  define	RLIMIT_FSIZE	1
       
   420 #  define	RLIMIT_DATA	2
       
   421 #  define	RLIMIT_STACK	3
       
   422 #  define	RLIMIT_CORE	4
       
   423 #  define	RLIMIT_RSS	5
       
   424 #  define	RLIMIT_NOFILE   6
       
   425 #  define	RLIMIT_OPEN_MAX	RLIMIT_NOFILE
       
   426 #  define	RLIM_NLIMITS	7
       
   427 #  define	RLIM_INFINITY	0x7fffffff
       
   428 # endif
       
   429 #endif
       
   430 
       
   431 /* we use the SVR4 constant instead of the BSD one */
       
   432 #if !defined(RLIMIT_NOFILE) && defined(RLIMIT_OFILE)
       
   433 # define RLIMIT_NOFILE RLIMIT_OFILE
       
   434 #endif
       
   435 #if !defined(RLIMIT_VMEM) && defined(RLIMIT_AS)
       
   436 # define RLIMIT_VMEM RLIMIT_AS
       
   437 #endif
       
   438 
       
   439 #ifdef HAVE_SYS_CAPABILITY_H
       
   440 # include <sys/capability.h>
       
   441 #endif
       
   442 
       
   443 /* DIGBUFSIZ is the length of a buffer which can hold the -LONG_MAX-1 *
       
   444  * (or with ZSH_64_BIT_TYPE maybe -LONG_LONG_MAX-1)                   *
       
   445  * converted to printable decimal form including the sign and the     *
       
   446  * terminating null character. Below 0.30103 > lg 2.                  *
       
   447  * BDIGBUFSIZE is for a number converted to printable binary form.    */
       
   448 #define DIGBUFSIZE ((int)(((sizeof(zlong) * 8) - 1) * 30103/100000) + 3)
       
   449 #define BDIGBUFSIZE ((int)((sizeof(zlong) * 8) + 4))
       
   450 
       
   451 /* If your stat macros are broken, we will *
       
   452  * just undefine them.                     */
       
   453 
       
   454 #ifdef STAT_MACROS_BROKEN
       
   455 # undef S_ISBLK
       
   456 # undef S_ISCHR
       
   457 # undef S_ISDIR
       
   458 # undef S_ISDOOR
       
   459 # undef S_ISFIFO
       
   460 # undef S_ISLNK
       
   461 # undef S_ISMPB
       
   462 # undef S_ISMPC
       
   463 # undef S_ISNWK
       
   464 # undef S_ISOFD
       
   465 # undef S_ISOFL
       
   466 # undef S_ISREG
       
   467 # undef S_ISSOCK
       
   468 #endif  /* STAT_MACROS_BROKEN.  */
       
   469 
       
   470 /* If you are missing the stat macros, we *
       
   471  * define our own                         */
       
   472 
       
   473 #ifndef S_IFMT
       
   474 # define S_IFMT 0170000
       
   475 #endif
       
   476 
       
   477 #if !defined(S_ISBLK) && defined(S_IFBLK)
       
   478 # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
       
   479 #endif
       
   480 #if !defined(S_ISCHR) && defined(S_IFCHR)
       
   481 # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
       
   482 #endif
       
   483 #if !defined(S_ISDIR) && defined(S_IFDIR)
       
   484 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
       
   485 #endif
       
   486 #if !defined(S_ISDOOR) && defined(S_IFDOOR)      /* Solaris */
       
   487 # define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
       
   488 #endif
       
   489 #if !defined(S_ISFIFO) && defined(S_IFIFO)
       
   490 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
       
   491 #endif
       
   492 #if !defined(S_ISLNK) && defined(S_IFLNK)
       
   493 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
       
   494 #endif
       
   495 #if !defined(S_ISMPB) && defined(S_IFMPB)        /* V7 */
       
   496 # define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
       
   497 #endif
       
   498 #if !defined(S_ISMPC) && defined(S_IFMPC)        /* V7 */
       
   499 # define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
       
   500 #endif
       
   501 #if !defined(S_ISNWK) && defined(S_IFNWK)        /* HP/UX */
       
   502 # define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
       
   503 #endif
       
   504 #if !defined(S_ISOFD) && defined(S_IFOFD)        /* Cray */
       
   505 # define S_ISOFD(m) (((m) & S_IFMT) == S_IFOFD)
       
   506 #endif
       
   507 #if !defined(S_ISOFL) && defined(S_IFOFL)        /* Cray */
       
   508 # define S_ISOFL(m) (((m) & S_IFMT) == S_IFOFL)
       
   509 #endif
       
   510 #if !defined(S_ISREG) && defined(S_IFREG)
       
   511 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
       
   512 #endif
       
   513 #if !defined(S_ISSOCK) && defined(S_IFSOCK)
       
   514 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
       
   515 #endif
       
   516 
       
   517 /* We will pretend to have all file types on any system. */
       
   518 
       
   519 #ifndef S_ISBLK
       
   520 # define S_ISBLK(m) ((void)(m), 0)
       
   521 #endif
       
   522 #ifndef S_ISCHR
       
   523 # define S_ISCHR(m) ((void)(m), 0)
       
   524 #endif
       
   525 #ifndef S_ISDIR
       
   526 # define S_ISDIR(m) ((void)(m), 0)
       
   527 #endif
       
   528 #ifndef S_ISDOOR
       
   529 # define S_ISDOOR(m) ((void)(m), 0)
       
   530 #endif
       
   531 #ifndef S_ISFIFO
       
   532 # define S_ISFIFO(m) ((void)(m), 0)
       
   533 #endif
       
   534 #ifndef S_ISLNK
       
   535 # define S_ISLNK(m) ((void)(m), 0)
       
   536 #endif
       
   537 #ifndef S_ISMPB
       
   538 # define S_ISMPB(m) ((void)(m), 0)
       
   539 #endif
       
   540 #ifndef S_ISMPC
       
   541 # define S_ISMPC(m) ((void)(m), 0)
       
   542 #endif
       
   543 #ifndef S_ISNWK
       
   544 # define S_ISNWK(m) ((void)(m), 0)
       
   545 #endif
       
   546 #ifndef S_ISOFD
       
   547 # define S_ISOFD(m) ((void)(m), 0)
       
   548 #endif
       
   549 #ifndef S_ISOFL
       
   550 # define S_ISOFL(m) ((void)(m), 0)
       
   551 #endif
       
   552 #ifndef S_ISREG
       
   553 # define S_ISREG(m) ((void)(m), 0)
       
   554 #endif
       
   555 #ifndef S_ISSOCK
       
   556 # define S_ISSOCK(m) ((void)(m), 0)
       
   557 #endif
       
   558 
       
   559 /* file mode permission bits */
       
   560 
       
   561 #ifndef S_ISUID
       
   562 # define S_ISUID 04000
       
   563 #endif
       
   564 #ifndef S_ISGID
       
   565 # define S_ISGID 02000
       
   566 #endif
       
   567 #ifndef S_ISVTX
       
   568 # define S_ISVTX 01000
       
   569 #endif
       
   570 #ifndef S_IRUSR
       
   571 # define S_IRUSR 00400
       
   572 #endif
       
   573 #ifndef S_IWUSR
       
   574 # define S_IWUSR 00200
       
   575 #endif
       
   576 #ifndef S_IXUSR
       
   577 # define S_IXUSR 00100
       
   578 #endif
       
   579 #ifndef S_IRGRP
       
   580 # define S_IRGRP 00040
       
   581 #endif
       
   582 #ifndef S_IWGRP
       
   583 # define S_IWGRP 00020
       
   584 #endif
       
   585 #ifndef S_IXGRP
       
   586 # define S_IXGRP 00010
       
   587 #endif
       
   588 #ifndef S_IROTH
       
   589 # define S_IROTH 00004
       
   590 #endif
       
   591 #ifndef S_IWOTH
       
   592 # define S_IWOTH 00002
       
   593 #endif
       
   594 #ifndef S_IXOTH
       
   595 # define S_IXOTH 00001
       
   596 #endif
       
   597 #ifndef S_IRWXU
       
   598 # define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
       
   599 #endif
       
   600 #ifndef S_IRWXG
       
   601 # define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
       
   602 #endif
       
   603 #ifndef S_IRWXO
       
   604 # define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
       
   605 #endif
       
   606 #ifndef S_IRUGO
       
   607 # define S_IRUGO (S_IRUSR|S_IRGRP|S_IROTH)
       
   608 #endif
       
   609 #ifndef S_IWUGO
       
   610 # define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH)
       
   611 #endif
       
   612 #ifndef S_IXUGO
       
   613 # define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH)
       
   614 #endif
       
   615 
       
   616 #ifndef HAVE_LSTAT
       
   617 # define lstat stat
       
   618 #endif
       
   619 
       
   620 #ifndef HAVE_READLINK
       
   621 # define readlink(PATH, BUF, BUFSZ) \
       
   622     ((void)(PATH), (void)(BUF), (void)(BUFSZ), errno = ENOSYS, -1)
       
   623 #endif
       
   624 
       
   625 #ifndef F_OK          /* missing macros for access() */
       
   626 # define F_OK 0
       
   627 # define X_OK 1
       
   628 # define W_OK 2
       
   629 # define R_OK 4
       
   630 #endif
       
   631 
       
   632 #ifndef HAVE_LCHOWN
       
   633 # define lchown chown
       
   634 #endif
       
   635 
       
   636 #ifndef HAVE_MEMCPY
       
   637 # define memcpy memmove
       
   638 #endif
       
   639 
       
   640 #ifndef HAVE_MEMMOVE
       
   641 # define memmove(dest, src, len) bcopy((src), (dest), (len))
       
   642 #endif
       
   643 
       
   644 #ifndef offsetof
       
   645 # define offsetof(TYPE, MEM) ((char *)&((TYPE *)0)->MEM - (char *)(TYPE *)0)
       
   646 #endif
       
   647 
       
   648 #ifndef __SYMBIAN32__
       
   649 extern char **environ;
       
   650 #endif
       
   651 
       
   652 /* These variables are sometimes defined in, *
       
   653  * and needed by, the termcap library.       */
       
   654 #if MUST_DEFINE_OSPEED
       
   655 extern char PC, *BC, *UP;
       
   656 extern short ospeed;
       
   657 #endif
       
   658 
       
   659 /* Rename some global zsh variables to avoid *
       
   660  * possible name clashes with libc           */
       
   661 
       
   662 #define cs zshcs
       
   663 #define ll zshll
       
   664 
       
   665 #ifndef O_NOCTTY
       
   666 # define O_NOCTTY 0
       
   667 #endif
       
   668 
       
   669 #ifdef _LARGEFILE_SOURCE
       
   670 #ifdef HAVE_FSEEKO
       
   671 #define fseek fseeko
       
   672 #endif
       
   673 #ifdef HAVE_FTELLO
       
   674 #define ftell ftello
       
   675 #endif
       
   676 #endif
       
   677 
       
   678 /* Can't support job control without working tcsetgrp() */
       
   679 #ifdef BROKEN_TCSETPGRP
       
   680 #undef JOB_CONTROL
       
   681 #endif /* BROKEN_TCSETPGRP */
       
   682 
       
   683 #ifdef BROKEN_KILL_ESRCH
       
   684 #undef ESRCH
       
   685 #define ESRCH EINVAL
       
   686 #endif /* BROKEN_KILL_ESRCH */
       
   687 
       
   688 /* Can we do locale stuff? */
       
   689 #undef USE_LOCALE
       
   690 #if defined(CONFIG_LOCALE) && defined(HAVE_SETLOCALE) && defined(LC_ALL)
       
   691 # define USE_LOCALE 1
       
   692 #endif /* CONFIG_LOCALE && HAVE_SETLOCALE && LC_ALL */
       
   693 
       
   694 #ifndef MAILDIR_SUPPORT
       
   695 #define mailstat(X,Y) stat(X,Y)
       
   696 #endif
       
   697 
       
   698 #ifdef __CYGWIN__
       
   699 # include <sys/cygwin.h>
       
   700 # define IS_DIRSEP(c) ((c) == '/' || (c) == '\\')
       
   701 #else
       
   702 # define IS_DIRSEP(c) ((c) == '/')
       
   703 #endif
       
   704 
       
   705 #if defined(__GNUC__) && !defined(__APPLE__)
       
   706 /* Does the OS X port of gcc still gag on __attribute__? */
       
   707 #define UNUSED(x) x __attribute__((__unused__))
       
   708 #else
       
   709 #define UNUSED(x) x
       
   710 #endif