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#if defined(__linux) || defined(__GNU__) || defined(__GLIBC__) || defined(LIBC_MUSL) 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#ifdef LIBC_MUSL 48#define _POSIX_C_SOURCE 200809L 49#endif 50 51/* NeXT has half-implemented POSIX support * 52 * which currently fools configure */ 53#ifdef __NeXT__ 54# undef HAVE_TERMIOS_H 55# undef HAVE_SYS_UTSNAME_H 56#endif 57 58#ifndef ZSH_NO_XOPEN 59# ifdef ZSH_CURSES_SOURCE 60# define _XOPEN_SOURCE_EXTENDED 1 61# else 62# ifdef MULTIBYTE_SUPPORT 63/* 64 * Needed for wcwidth() which is part of XSI. 65 * Various other uses of the interface mean we can't get away with just 66 * _XOPEN_SOURCE. 67 */ 68# define _XOPEN_SOURCE_EXTENDED 1 69# endif /* MULTIBYTE_SUPPORT */ 70# endif /* ZSH_CURSES_SOURCE */ 71#endif /* ZSH_NO_XOPEN */ 72 73/* 74 * Solaris by default zeroes all elements of the tm structure in 75 * strptime(). Unfortunately that gives us no way of telling whether 76 * the tm_isdst element has been set from the input pattern. If it 77 * hasn't we want it to be -1 (undetermined) on input to mktime(). So 78 * we stop strptime() zeroing the struct tm and instead set all the 79 * elements ourselves. 80 * 81 * This is likely to be harmless everywhere else. 82 */ 83#define _STRPTIME_DONTZERO 84 85#ifdef PROTOTYPES 86# define _(Args) Args 87#else 88# define _(Args) () 89#endif 90 91#ifndef HAVE_ALLOCA 92# define alloca zhalloc 93#else 94# ifdef __GNUC__ 95# define alloca __builtin_alloca 96# else 97# if HAVE_ALLOCA_H 98# include <alloca.h> 99# else 100# ifdef _AIX 101 # pragma alloca 102# else 103# ifndef alloca 104char *alloca _((size_t)); 105# endif 106# endif 107# endif 108# endif 109#endif 110 111/* 112 * libc.h in an optional package for Debian Linux is broken (it 113 * defines dup() as a synonym for dup2(), which has a different 114 * number of arguments), so just include it for next. 115 */ 116#ifdef __NeXT__ 117# ifdef HAVE_LIBC_H 118# include <libc.h> 119# endif 120#endif 121 122#ifdef HAVE_SYS_TYPES_H 123# include <sys/types.h> 124#endif 125 126#ifdef HAVE_UNISTD_H 127# include <unistd.h> 128#endif 129 130#ifdef HAVE_STDDEF_H 131/* 132 * Seen on Solaris 8 with gcc: stddef defines offsetof, which clashes 133 * with system.h's definition of the symbol unless we include this 134 * first. Otherwise, this will be hooked in by wchar.h, too late 135 * for comfort. 136 */ 137#include <stddef.h> 138#endif 139 140#include <stdio.h> 141#include <ctype.h> 142#include <sys/stat.h> 143#include <signal.h> 144#include <setjmp.h> 145 146#ifdef HAVE_PWD_H 147# include <pwd.h> 148#endif 149 150#ifdef HAVE_GRP_H 151# include <grp.h> 152#endif 153 154#ifdef HAVE_DIRENT_H 155# include <dirent.h> 156#else /* !HAVE_DIRENT_H */ 157# ifdef HAVE_SYS_NDIR_H 158# include <sys/ndir.h> 159# endif 160# ifdef HAVE_SYS_DIR_H 161# include <sys/dir.h> 162# endif 163# ifdef HAVE_NDIR_H 164# include <ndir.h> 165# endif 166# define dirent direct 167# undef HAVE_STRUCT_DIRENT_D_INO 168# undef HAVE_STRUCT_DIRENT_D_STAT 169# ifdef HAVE_STRUCT_DIRECT_D_INO 170# define HAVE_STRUCT_DIRENT_D_INO HAVE_STRUCT_DIRECT_D_INO 171# endif 172# ifdef HAVE_STRUCT_DIRECT_D_STAT 173# define HAVE_STRUCT_DIRENT_D_STAT HAVE_STRUCT_DIRECT_D_STAT 174# endif 175#endif /* !HAVE_DIRENT_H */ 176 177#ifdef HAVE_STDLIB_H 178# ifdef ZSH_MEM 179 /* malloc and calloc are macros in GNU's stdlib.h unless the 180 * the __MALLOC_0_RETURNS_NULL macro is defined */ 181# define __MALLOC_0_RETURNS_NULL 182# endif 183# include <stdlib.h> 184#endif 185 186/* 187 * Stuff with variable arguments. We use definitions to make the 188 * same code work with varargs (the original K&R-style, just to 189 * be maximally compatible) and stdarg (which all modern systems 190 * should have). 191 * 192 * Ideally this should somehow be merged with the tricks performed 193 * with "_" in makepro.awk, but I don't understand makepro.awk. 194 * Currently we simply rely on the fact that makepro.awk has been 195 * hacked to leave alone argument lists that already contains VA_ALIST 196 * except for removing the VA_DCL and turning VA_ALIST into VA_ALIST_PROTO. 197 */ 198#ifdef HAVE_STDARG_H 199# include <stdarg.h> 200# define VA_ALIST1(x) x, ... 201# define VA_ALIST2(x,y) x, y, ... 202# define VA_ALIST_PROTO1(x) VA_ALIST1(x) 203# define VA_ALIST_PROTO2(x,y) VA_ALIST2(x,y) 204# define VA_DCL 205# define VA_DEF_ARG(x) 206# define VA_START(ap,x) va_start(ap, x) 207# define VA_GET_ARG(ap,x,t) 208#else 209# if HAVE_VARARGS_H 210# include <varargs.h> 211# define VA_ALIST1(x) va_alist 212# define VA_ALIST2(x,y) va_alist 213/* 214 * In prototypes, assume K&R form and remove the variable list. 215 * This is about the best we can do without second-guessing the way 216 * varargs works on this system. The _ trick should be able to 217 * do this for us but we've turned it off here. 218 */ 219# define VA_ALIST_PROTO1(x) 220# define VA_ALIST_PROTO2(x,y) 221# define VA_DCL va_dcl 222# define VA_DEF_ARG(x) x 223# define VA_START(ap,x) va_start(ap); 224# define VA_GET_ARG(ap,x,t) (x = va_arg(ap, t)) 225# else 226# error "Your system has neither stdarg.h or varargs.h." 227# endif 228#endif 229 230#ifdef HAVE_ERRNO_H 231# include <errno.h> 232#endif 233 234#ifdef TIME_WITH_SYS_TIME 235# include <sys/time.h> 236# include <time.h> 237#else 238# ifdef HAVE_SYS_TIME_H 239# include <sys/time.h> 240# else 241# include <time.h> 242# endif 243#endif 244 245/* This is needed by some old SCO unices */ 246#if !defined(HAVE_STRUCT_TIMEZONE) && !defined(ZSH_OOT_MODULE) 247struct timezone { 248 int tz_minuteswest; 249 int tz_dsttime; 250}; 251#endif 252 253/* There's more than one non-standard way to get at this data */ 254#if !defined(HAVE_STRUCT_DIRENT_D_INO) && defined(HAVE_STRUCT_DIRENT_D_STAT) 255# define d_ino d_stat.st_ino 256# define HAVE_STRUCT_DIRENT_D_INO HAVE_STRUCT_DIRENT_D_STAT 257#endif /* !HAVE_STRUCT_DIRENT_D_INO && HAVE_STRUCT_DIRENT_D_STAT */ 258 259/* Sco needs the following include for struct utimbuf * 260 * which is strange considering we do not use that * 261 * anywhere in the code */ 262#ifdef __sco 263# include <utime.h> 264#endif 265 266#ifdef HAVE_SYS_TIMES_H 267# include <sys/times.h> 268#endif 269 270#if STDC_HEADERS || HAVE_STRING_H 271# include <string.h> 272/* An ANSI string.h and pre-ANSI memory.h might conflict. */ 273# if !STDC_HEADERS && HAVE_MEMORY_H 274# include <memory.h> 275# endif /* not STDC_HEADERS and HAVE_MEMORY_H */ 276#else /* not STDC_HEADERS and not HAVE_STRING_H */ 277# include <strings.h> 278/* memory.h and strings.h conflict on some systems. */ 279#endif /* not STDC_HEADERS and not HAVE_STRING_H */ 280 281#ifdef HAVE_LOCALE_H 282# include <locale.h> 283#endif 284 285#ifdef HAVE_LIMITS_H 286# include <limits.h> 287#endif 288 289#ifdef HAVE_VARIABLE_LENGTH_ARRAYS 290# define VARARR(X,Y,Z) X (Y)[Z] 291#else 292# define VARARR(X,Y,Z) X *(Y) = (X *) alloca(sizeof(X) * (Z)) 293#endif 294 295/* we should handle unlimited sizes from pathconf(_PC_PATH_MAX) */ 296/* but this is too much trouble */ 297#ifndef PATH_MAX 298# ifdef MAXPATHLEN 299# define PATH_MAX MAXPATHLEN 300# else 301# ifdef _POSIX_PATH_MAX 302# define PATH_MAX _POSIX_PATH_MAX 303# else 304 /* so we will just pick something */ 305# define PATH_MAX 1024 306# endif 307# endif 308#endif 309 310/* 311 * The number of file descriptors we'll allocate initially. 312 * We will reallocate later if necessary. 313 */ 314#define ZSH_INITIAL_OPEN_MAX 64 315#ifndef OPEN_MAX 316# ifdef NOFILE 317# define OPEN_MAX NOFILE 318# else 319 /* so we will just pick something */ 320# define OPEN_MAX ZSH_INITIAL_OPEN_MAX 321# endif 322#endif 323#ifndef HAVE_SYSCONF 324# define zopenmax() ((long) (OPEN_MAX > ZSH_INITIAL_OPEN_MAX ? \ 325 ZSH_INITIAL_OPEN_MAX : OPEN_MAX)) 326#endif 327 328#ifdef HAVE_FCNTL_H 329# include <fcntl.h> 330#else 331# include <sys/file.h> 332#endif 333 334/* The following will only be defined if <sys/wait.h> is POSIX. * 335 * So we don't have to worry about union wait. But some machines * 336 * (NeXT) include <sys/wait.h> from other include files, so we * 337 * need to undef and then redefine the wait macros if <sys/wait.h> * 338 * is not POSIX. */ 339 340#ifdef HAVE_SYS_WAIT_H 341# include <sys/wait.h> 342#else 343# undef WIFEXITED 344# undef WEXITSTATUS 345# undef WIFSIGNALED 346# undef WTERMSIG 347# undef WCOREDUMP 348# undef WIFSTOPPED 349# undef WSTOPSIG 350#endif 351 352/* missing macros for wait/waitpid/wait3 */ 353#ifndef WIFEXITED 354# define WIFEXITED(X) (((X)&0377)==0) 355#endif 356#ifndef WEXITSTATUS 357# define WEXITSTATUS(X) (((X)>>8)&0377) 358#endif 359#ifndef WIFSIGNALED 360# define WIFSIGNALED(X) (((X)&0377)!=0&&((X)&0377)!=0177) 361#endif 362#ifndef WTERMSIG 363# define WTERMSIG(X) ((X)&0177) 364#endif 365#ifndef WCOREDUMP 366# define WCOREDUMP(X) ((X)&0200) 367#endif 368#ifndef WIFSTOPPED 369# define WIFSTOPPED(X) (((X)&0377)==0177) 370#endif 371#ifndef WSTOPSIG 372# define WSTOPSIG(X) (((X)>>8)&0377) 373#endif 374 375#ifdef HAVE_SYS_SELECT_H 376# ifndef TIME_H_SELECT_H_CONFLICTS 377# include <sys/select.h> 378# endif 379#elif defined(SELECT_IN_SYS_SOCKET_H) 380# include <sys/socket.h> 381#endif 382 383#if defined(__APPLE__) && defined(HAVE_SELECT) 384/* 385 * Prefer select() to poll() on MacOS X since poll() is known 386 * to be problematic in 10.4 387 */ 388#undef HAVE_POLL 389#undef HAVE_POLL_H 390#endif 391 392#ifdef HAVE_SYS_FILIO_H 393# include <sys/filio.h> 394#endif 395 396#ifdef HAVE_TERMIOS_H 397# ifdef __sco 398 /* termios.h includes sys/termio.h instead of sys/termios.h; * 399 * hence the declaration for struct termios is missing */ 400# include <sys/termios.h> 401# else 402# include <termios.h> 403# endif 404# ifdef _POSIX_VDISABLE 405# define VDISABLEVAL _POSIX_VDISABLE 406# else 407# define VDISABLEVAL 0 408# endif 409# define HAS_TIO 1 410#else /* not TERMIOS */ 411# ifdef HAVE_TERMIO_H 412# include <termio.h> 413# define VDISABLEVAL -1 414# define HAS_TIO 1 415# else /* not TERMIOS and TERMIO */ 416# include <sgtty.h> 417# endif /* HAVE_TERMIO_H */ 418#endif /* HAVE_TERMIOS_H */ 419 420#if defined(GWINSZ_IN_SYS_IOCTL) || defined(IOCTL_IN_SYS_IOCTL) 421# include <sys/ioctl.h> 422#endif 423#ifdef WINSIZE_IN_PTEM 424# include <sys/stream.h> 425# include <sys/ptem.h> 426#endif 427 428#ifdef HAVE_SYS_PARAM_H 429# include <sys/param.h> 430#endif 431 432#ifdef HAVE_SYS_UTSNAME_H 433# include <sys/utsname.h> 434#endif 435 436#define DEFAULT_WORDCHARS "*?_-.[]~=/&;!#$%^(){}<>" 437#define DEFAULT_TIMEFMT "%J %U user %S system %P cpu %*E total" 438 439/* Posix getpgrp takes no argument, while the BSD version * 440 * takes the process ID as an argument */ 441#ifdef GETPGRP_VOID 442# define GETPGRP() getpgrp() 443#else 444# define GETPGRP() getpgrp(0) 445#endif 446 447#ifndef HAVE_GETLOGIN 448# define getlogin() cuserid(NULL) 449#endif 450 451#ifdef HAVE_SETPGID 452# define setpgrp setpgid 453#endif 454 455/* can we set the user/group id of a process */ 456 457#ifndef HAVE_SETUID 458# ifdef HAVE_SETREUID 459# define setuid(X) setreuid(X,X) 460# define setgid(X) setregid(X,X) 461# define HAVE_SETUID 462# endif 463#endif 464 465/* can we set the effective user/group id of a process */ 466 467#ifndef HAVE_SETEUID 468# ifdef HAVE_SETREUID 469# define seteuid(X) setreuid(-1,X) 470# define setegid(X) setregid(-1,X) 471# define HAVE_SETEUID 472# else 473# ifdef HAVE_SETRESUID 474# define seteuid(X) setresuid(-1,X,-1) 475# define setegid(X) setresgid(-1,X,-1) 476# define HAVE_SETEUID 477# endif 478# endif 479#endif 480 481#ifdef HAVE_SYS_RESOURCE_H 482# include <sys/resource.h> 483# if defined(__hpux) && !defined(RLIMIT_CPU) 484/* HPUX does have the BSD rlimits in the kernel. Officially they are * 485 * unsupported but quite a few of them like RLIMIT_CORE seem to work. * 486 * All the following are in the <sys/resource.h> but made visible * 487 * only for the kernel. */ 488# define RLIMIT_CPU 0 489# define RLIMIT_FSIZE 1 490# define RLIMIT_DATA 2 491# define RLIMIT_STACK 3 492# define RLIMIT_CORE 4 493# define RLIMIT_RSS 5 494# define RLIMIT_NOFILE 6 495# define RLIMIT_OPEN_MAX RLIMIT_NOFILE 496# define RLIM_NLIMITS 7 497# define RLIM_INFINITY 0x7fffffff 498# endif 499#endif 500 501/* we use the SVR4 constant instead of the BSD one */ 502#if !defined(RLIMIT_NOFILE) && defined(RLIMIT_OFILE) 503# define RLIMIT_NOFILE RLIMIT_OFILE 504#endif 505#if !defined(RLIMIT_VMEM) && defined(RLIMIT_AS) 506# define RLIMIT_VMEM RLIMIT_AS 507#endif 508 509#ifdef HAVE_SYS_CAPABILITY_H 510# include <sys/capability.h> 511#endif 512 513/* DIGBUFSIZ is the length of a buffer which can hold the -LONG_MAX-1 * 514 * (or with ZSH_64_BIT_TYPE maybe -LONG_LONG_MAX-1) * 515 * converted to printable decimal form including the sign and the * 516 * terminating null character. Below 0.30103 > lg 2. * 517 * BDIGBUFSIZE is for a number converted to printable binary form. */ 518#define DIGBUFSIZE ((int)(((sizeof(zlong) * 8) - 1) * 30103/100000) + 3) 519#define BDIGBUFSIZE ((int)((sizeof(zlong) * 8) + 4)) 520 521/* If your stat macros are broken, we will * 522 * just undefine them. */ 523 524#ifdef STAT_MACROS_BROKEN 525# undef S_ISBLK 526# undef S_ISCHR 527# undef S_ISDIR 528# undef S_ISDOOR 529# undef S_ISFIFO 530# undef S_ISLNK 531# undef S_ISMPB 532# undef S_ISMPC 533# undef S_ISNWK 534# undef S_ISOFD 535# undef S_ISOFL 536# undef S_ISREG 537# undef S_ISSOCK 538#endif /* STAT_MACROS_BROKEN. */ 539 540/* If you are missing the stat macros, we * 541 * define our own */ 542 543#ifndef S_IFMT 544# define S_IFMT 0170000 545#endif 546 547#if !defined(S_ISBLK) && defined(S_IFBLK) 548# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) 549#endif 550#if !defined(S_ISCHR) && defined(S_IFCHR) 551# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) 552#endif 553#if !defined(S_ISDIR) && defined(S_IFDIR) 554# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 555#endif 556#if !defined(S_ISDOOR) && defined(S_IFDOOR) /* Solaris */ 557# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR) 558#endif 559#if !defined(S_ISFIFO) && defined(S_IFIFO) 560# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) 561#endif 562#if !defined(S_ISLNK) && defined(S_IFLNK) 563# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) 564#endif 565#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */ 566# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) 567#endif 568#if !defined(S_ISMPC) && defined(S_IFMPC) /* V7 */ 569# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) 570#endif 571#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */ 572# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) 573#endif 574#if !defined(S_ISOFD) && defined(S_IFOFD) /* Cray */ 575# define S_ISOFD(m) (((m) & S_IFMT) == S_IFOFD) 576#endif 577#if !defined(S_ISOFL) && defined(S_IFOFL) /* Cray */ 578# define S_ISOFL(m) (((m) & S_IFMT) == S_IFOFL) 579#endif 580#if !defined(S_ISREG) && defined(S_IFREG) 581# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 582#endif 583#if !defined(S_ISSOCK) && defined(S_IFSOCK) 584# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) 585#endif 586 587/* We will pretend to have all file types on any system. */ 588 589#ifndef S_ISBLK 590# define S_ISBLK(m) ((void)(m), 0) 591#endif 592#ifndef S_ISCHR 593# define S_ISCHR(m) ((void)(m), 0) 594#endif 595#ifndef S_ISDIR 596# define S_ISDIR(m) ((void)(m), 0) 597#endif 598#ifndef S_ISDOOR 599# define S_ISDOOR(m) ((void)(m), 0) 600#endif 601#ifndef S_ISFIFO 602# define S_ISFIFO(m) ((void)(m), 0) 603#endif 604#ifndef S_ISLNK 605# define S_ISLNK(m) ((void)(m), 0) 606#endif 607#ifndef S_ISMPB 608# define S_ISMPB(m) ((void)(m), 0) 609#endif 610#ifndef S_ISMPC 611# define S_ISMPC(m) ((void)(m), 0) 612#endif 613#ifndef S_ISNWK 614# define S_ISNWK(m) ((void)(m), 0) 615#endif 616#ifndef S_ISOFD 617# define S_ISOFD(m) ((void)(m), 0) 618#endif 619#ifndef S_ISOFL 620# define S_ISOFL(m) ((void)(m), 0) 621#endif 622#ifndef S_ISREG 623# define S_ISREG(m) ((void)(m), 0) 624#endif 625#ifndef S_ISSOCK 626# define S_ISSOCK(m) ((void)(m), 0) 627#endif 628 629/* file mode permission bits */ 630 631#ifndef S_ISUID 632# define S_ISUID 04000 633#endif 634#ifndef S_ISGID 635# define S_ISGID 02000 636#endif 637#ifndef S_ISVTX 638# define S_ISVTX 01000 639#endif 640#ifndef S_IRUSR 641# define S_IRUSR 00400 642#endif 643#ifndef S_IWUSR 644# define S_IWUSR 00200 645#endif 646#ifndef S_IXUSR 647# define S_IXUSR 00100 648#endif 649#ifndef S_IRGRP 650# define S_IRGRP 00040 651#endif 652#ifndef S_IWGRP 653# define S_IWGRP 00020 654#endif 655#ifndef S_IXGRP 656# define S_IXGRP 00010 657#endif 658#ifndef S_IROTH 659# define S_IROTH 00004 660#endif 661#ifndef S_IWOTH 662# define S_IWOTH 00002 663#endif 664#ifndef S_IXOTH 665# define S_IXOTH 00001 666#endif 667#ifndef S_IRWXU 668# define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR) 669#endif 670#ifndef S_IRWXG 671# define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP) 672#endif 673#ifndef S_IRWXO 674# define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH) 675#endif 676#ifndef S_IRUGO 677# define S_IRUGO (S_IRUSR|S_IRGRP|S_IROTH) 678#endif 679#ifndef S_IWUGO 680# define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH) 681#endif 682#ifndef S_IXUGO 683# define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH) 684#endif 685 686#ifndef HAVE_LSTAT 687# define lstat stat 688#endif 689 690#ifndef HAVE_READLINK 691# define readlink(PATH, BUF, BUFSZ) \ 692 ((void)(PATH), (void)(BUF), (void)(BUFSZ), errno = ENOSYS, -1) 693#endif 694 695#ifndef F_OK /* missing macros for access() */ 696# define F_OK 0 697# define X_OK 1 698# define W_OK 2 699# define R_OK 4 700#endif 701 702#ifndef HAVE_LCHOWN 703# define lchown chown 704#endif 705 706#ifndef HAVE_MEMCPY 707# define memcpy memmove 708#endif 709 710#ifndef HAVE_MEMMOVE 711# define memmove(dest, src, len) bcopy((src), (dest), (len)) 712#endif 713 714#ifndef offsetof 715# define offsetof(TYPE, MEM) ((char *)&((TYPE *)0)->MEM - (char *)(TYPE *)0) 716#endif 717 718extern char **environ; 719 720/* 721 * We always need setenv and unsetenv in pairs, because 722 * we don't know how to do memory management on the values set. 723 */ 724#if defined(HAVE_SETENV) && defined(HAVE_UNSETENV) 725# define USE_SET_UNSET_ENV 726#endif 727 728 729/* These variables are sometimes defined in, * 730 * and needed by, the termcap library. */ 731#if MUST_DEFINE_OSPEED 732extern char PC, *BC, *UP; 733extern short ospeed; 734#endif 735 736#ifndef O_NOCTTY 737# define O_NOCTTY 0 738#endif 739 740#ifdef _LARGEFILE_SOURCE 741#ifdef HAVE_FSEEKO 742#define fseek fseeko 743#endif 744#ifdef HAVE_FTELLO 745#define ftell ftello 746#endif 747#endif 748 749/* Can't support job control without working tcsetgrp() */ 750#ifdef BROKEN_TCSETPGRP 751#undef JOB_CONTROL 752#endif /* BROKEN_TCSETPGRP */ 753 754#ifdef BROKEN_KILL_ESRCH 755#undef ESRCH 756#define ESRCH EINVAL 757#endif /* BROKEN_KILL_ESRCH */ 758 759/* Can we do locale stuff? */ 760#undef USE_LOCALE 761#if defined(CONFIG_LOCALE) && defined(HAVE_SETLOCALE) && defined(LC_ALL) 762# define USE_LOCALE 1 763#endif /* CONFIG_LOCALE && HAVE_SETLOCALE && LC_ALL */ 764 765#ifndef MAILDIR_SUPPORT 766#define mailstat(X,Y) stat(X,Y) 767#endif 768 769#ifdef __CYGWIN__ 770# include <sys/cygwin.h> 771# define IS_DIRSEP(c) ((c) == '/' || (c) == '\\') 772#else 773# define IS_DIRSEP(c) ((c) == '/') 774#endif 775 776#if defined(__GNUC__) && (!defined(__APPLE__) || defined(__clang__)) 777/* Does the OS X port of gcc still gag on __attribute__? */ 778#define UNUSED(x) x __attribute__((__unused__)) 779#else 780#define UNUSED(x) x 781#endif 782 783/* 784 * The MULTIBYTE_SUPPORT configure-define specifies that we want to enable 785 * complete Unicode conversion between wide characters and multibyte strings. 786 */ 787#if defined MULTIBYTE_SUPPORT \ 788 || (defined HAVE_WCHAR_H && defined HAVE_WCTOMB && defined __STDC_ISO_10646__) 789/* 790 * If MULTIBYTE_SUPPORT is not defined, these includes provide a subset of 791 * Unicode support that makes the \u and \U printf escape sequences work. 792 */ 793 794#if defined(__hpux) && !defined(_INCLUDE__STDC_A1_SOURCE) 795#define _INCLUDE__STDC_A1_SOURCE 796#endif 797 798# include <wchar.h> 799# include <wctype.h> 800#endif 801#ifdef HAVE_LANGINFO_H 802# include <langinfo.h> 803# ifdef HAVE_ICONV 804# include <iconv.h> 805# endif 806#endif 807 808#if defined(HAVE_INITGROUPS) && !defined(DISABLE_DYNAMIC_NSS) 809# define USE_INITGROUPS 810#endif 811 812#if defined(HAVE_GETGRGID) && !defined(DISABLE_DYNAMIC_NSS) 813# define USE_GETGRGID 814#endif 815 816#if defined(HAVE_GETGRNAM) && !defined(DISABLE_DYNAMIC_NSS) 817# define USE_GETGRNAM 818#endif 819 820#if defined(HAVE_GETPWENT) && !defined(DISABLE_DYNAMIC_NSS) 821# define USE_GETPWENT 822#endif 823 824#if defined(HAVE_GETPWNAM) && !defined(DISABLE_DYNAMIC_NSS) 825# define USE_GETPWNAM 826#endif 827 828#if defined(HAVE_GETPWUID) && !defined(DISABLE_DYNAMIC_NSS) 829# define USE_GETPWUID 830#endif 831 832#ifdef HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC 833# define GET_ST_ATIME_NSEC(st) (st).st_atim.tv_nsec 834#elif HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC 835# define GET_ST_ATIME_NSEC(st) (st).st_atimespec.tv_nsec 836#elif HAVE_STRUCT_STAT_ST_ATIMENSEC 837# define GET_ST_ATIME_NSEC(st) (st).st_atimensec 838#endif 839#ifdef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 840# define GET_ST_MTIME_NSEC(st) (st).st_mtim.tv_nsec 841#elif HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 842# define GET_ST_MTIME_NSEC(st) (st).st_mtimespec.tv_nsec 843#elif HAVE_STRUCT_STAT_ST_MTIMENSEC 844# define GET_ST_MTIME_NSEC(st) (st).st_mtimensec 845#endif 846#ifdef HAVE_STRUCT_STAT_ST_CTIM_TV_NSEC 847# define GET_ST_CTIME_NSEC(st) (st).st_ctim.tv_nsec 848#elif HAVE_STRUCT_STAT_ST_CTIMESPEC_TV_NSEC 849# define GET_ST_CTIME_NSEC(st) (st).st_ctimespec.tv_nsec 850#elif HAVE_STRUCT_STAT_ST_CTIMENSEC 851# define GET_ST_CTIME_NSEC(st) (st).st_ctimensec 852#endif 853 854#if defined(HAVE_TGETENT) && !defined(ZSH_NO_TERM_HANDLING) 855# if defined(ZSH_HAVE_CURSES_H) && defined(ZSH_HAVE_TERM_H) 856# define USES_TERM_H 1 857# else 858# ifdef HAVE_TERMCAP_H 859# define USES_TERMCAP_H 1 860# endif 861# endif 862 863# ifdef USES_TERM_H 864# ifdef HAVE_TERMIO_H 865# include <termio.h> 866# endif 867# ifdef ZSH_HAVE_CURSES_H 868# include "zshcurses.h" 869# endif 870# include "zshterm.h" 871# else 872# ifdef USES_TERMCAP_H 873# include <termcap.h> 874# endif 875# endif 876#endif 877