Home | History | Annotate | Download | only in make-3.81
      1 /* Miscellaneous global declarations and portability cruft for GNU Make.
      2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
      3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
      4 Foundation, Inc.
      5 This file is part of GNU Make.
      6 
      7 GNU Make is free software; you can redistribute it and/or modify it under the
      8 terms of the GNU General Public License as published by the Free Software
      9 Foundation; either version 2, or (at your option) any later version.
     10 
     11 GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
     12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     13 A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     14 
     15 You should have received a copy of the GNU General Public License along with
     16 GNU Make; see the file COPYING.  If not, write to the Free Software
     17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.  */
     18 
     19 /* We use <config.h> instead of "config.h" so that a compilation
     20    using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
     21    (which it would do because make.h was found in $srcdir).  */
     22 #include <config.h>
     23 #undef  HAVE_CONFIG_H
     24 #define HAVE_CONFIG_H 1
     25 
     26 /* AIX requires this to be the first thing in the file.  */
     27 #ifndef __GNUC__
     28 # if HAVE_ALLOCA_H
     29 #  include <alloca.h>
     30 # else
     31 #  ifdef _AIX
     32  #pragma alloca
     33 #  else
     34 #   ifndef alloca /* predefined by HP cc +Olibcalls */
     35 char *alloca ();
     36 #   endif
     37 #  endif
     38 # endif
     39 #endif
     40 
     41 
     42 /* Use prototypes if available.  */
     43 #if defined (__cplusplus) || defined (__STDC__)
     44 # undef  PARAMS
     45 # define PARAMS(protos)  protos
     46 #else /* Not C++ or ANSI C.  */
     47 # undef  PARAMS
     48 # define PARAMS(protos)  ()
     49 #endif /* C++ or ANSI C.  */
     50 
     51 /* Specify we want GNU source code.  This must be defined before any
     52    system headers are included.  */
     53 
     54 #define _GNU_SOURCE 1
     55 
     56 
     57 #ifdef  CRAY
     58 /* This must happen before #include <signal.h> so
     59    that the declaration therein is changed.  */
     60 # define signal bsdsignal
     61 #endif
     62 
     63 /* If we're compiling for the dmalloc debugger, turn off string inlining.  */
     64 #if defined(HAVE_DMALLOC_H) && defined(__GNUC__)
     65 # define __NO_STRING_INLINES
     66 #endif
     67 
     68 #include <sys/types.h>
     69 #include <sys/stat.h>
     70 #include <signal.h>
     71 #include <stdio.h>
     72 #include <ctype.h>
     73 #ifdef HAVE_SYS_TIMEB_H
     74 /* SCO 3.2 "devsys 4.2" has a prototype for `ftime' in <time.h> that bombs
     75    unless <sys/timeb.h> has been included first.  Does every system have a
     76    <sys/timeb.h>?  If any does not, configure should check for it.  */
     77 # include <sys/timeb.h>
     78 #endif
     79 
     80 #if TIME_WITH_SYS_TIME
     81 # include <sys/time.h>
     82 # include <time.h>
     83 #else
     84 # if HAVE_SYS_TIME_H
     85 #  include <sys/time.h>
     86 # else
     87 #  include <time.h>
     88 # endif
     89 #endif
     90 
     91 #include <errno.h>
     92 
     93 #ifndef errno
     94 extern int errno;
     95 #endif
     96 
     97 #ifndef isblank
     98 # define isblank(c)     ((c) == ' ' || (c) == '\t')
     99 #endif
    100 
    101 #ifdef  HAVE_UNISTD_H
    102 # include <unistd.h>
    103 /* Ultrix's unistd.h always defines _POSIX_VERSION, but you only get
    104    POSIX.1 behavior with `cc -YPOSIX', which predefines POSIX itself!  */
    105 # if defined (_POSIX_VERSION) && !defined (ultrix) && !defined (VMS)
    106 #  define POSIX 1
    107 # endif
    108 #endif
    109 
    110 /* Some systems define _POSIX_VERSION but are not really POSIX.1.  */
    111 #if (defined (butterfly) || defined (__arm) || (defined (__mips) && defined (_SYSTYPE_SVR3)) || (defined (sequent) && defined (i386)))
    112 # undef POSIX
    113 #endif
    114 
    115 #if !defined (POSIX) && defined (_AIX) && defined (_POSIX_SOURCE)
    116 # define POSIX 1
    117 #endif
    118 
    119 #ifndef RETSIGTYPE
    120 # define RETSIGTYPE     void
    121 #endif
    122 
    123 #ifndef sigmask
    124 # define sigmask(sig)   (1 << ((sig) - 1))
    125 #endif
    126 
    127 #ifndef HAVE_SA_RESTART
    128 # define SA_RESTART 0
    129 #endif
    130 
    131 #ifdef  HAVE_LIMITS_H
    132 # include <limits.h>
    133 #endif
    134 #ifdef  HAVE_SYS_PARAM_H
    135 # include <sys/param.h>
    136 #endif
    137 
    138 #ifndef PATH_MAX
    139 # ifndef POSIX
    140 #  define PATH_MAX      MAXPATHLEN
    141 # endif
    142 #endif
    143 #ifndef MAXPATHLEN
    144 # define MAXPATHLEN 1024
    145 #endif
    146 
    147 #ifdef  PATH_MAX
    148 # define GET_PATH_MAX   PATH_MAX
    149 # define PATH_VAR(var)  char var[PATH_MAX]
    150 #else
    151 # define NEED_GET_PATH_MAX 1
    152 # define GET_PATH_MAX   (get_path_max ())
    153 # define PATH_VAR(var)  char *var = (char *) alloca (GET_PATH_MAX)
    154 extern unsigned int get_path_max PARAMS ((void));
    155 #endif
    156 
    157 #ifndef CHAR_BIT
    158 # define CHAR_BIT 8
    159 #endif
    160 
    161 /* Nonzero if the integer type T is signed.  */
    162 #define INTEGER_TYPE_SIGNED(t) ((t) -1 < 0)
    163 
    164 /* The minimum and maximum values for the integer type T.
    165    Use ~ (t) 0, not -1, for portability to 1's complement hosts.  */
    166 #define INTEGER_TYPE_MINIMUM(t) \
    167   (! INTEGER_TYPE_SIGNED (t) ? (t) 0 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))
    168 #define INTEGER_TYPE_MAXIMUM(t) (~ (t) 0 - INTEGER_TYPE_MINIMUM (t))
    169 
    170 #ifndef CHAR_MAX
    171 # define CHAR_MAX INTEGER_TYPE_MAXIMUM (char)
    172 #endif
    173 
    174 #ifdef STAT_MACROS_BROKEN
    175 # ifdef S_ISREG
    176 #  undef S_ISREG
    177 # endif
    178 # ifdef S_ISDIR
    179 #  undef S_ISDIR
    180 # endif
    181 #endif  /* STAT_MACROS_BROKEN.  */
    182 
    183 #ifndef S_ISREG
    184 # define S_ISREG(mode)  (((mode) & S_IFMT) == S_IFREG)
    185 #endif
    186 #ifndef S_ISDIR
    187 # define S_ISDIR(mode)  (((mode) & S_IFMT) == S_IFDIR)
    188 #endif
    189 
    190 #ifdef VMS
    191 # include <types.h>
    192 # include <unixlib.h>
    193 # include <unixio.h>
    194 # include <perror.h>
    195 /* Needed to use alloca on VMS.  */
    196 # include <builtins.h>
    197 #endif
    198 
    199 #ifndef __attribute__
    200 /* This feature is available in gcc versions 2.5 and later.  */
    201 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
    202 #  define __attribute__(x)
    203 # endif
    204 /* The __-protected variants of `format' and `printf' attributes
    205    are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
    206 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
    207 #  define __format__ format
    208 #  define __printf__ printf
    209 # endif
    210 #endif
    211 #define UNUSED  __attribute__ ((unused))
    212 
    213 #if defined (STDC_HEADERS) || defined (__GNU_LIBRARY__)
    214 # include <stdlib.h>
    215 # include <string.h>
    216 # define ANSI_STRING 1
    217 #else   /* No standard headers.  */
    218 # ifdef HAVE_STRING_H
    219 #  include <string.h>
    220 #  define ANSI_STRING 1
    221 # else
    222 #  include <strings.h>
    223 # endif
    224 # ifdef HAVE_MEMORY_H
    225 #  include <memory.h>
    226 # endif
    227 # ifdef HAVE_STDLIB_H
    228 #  include <stdlib.h>
    229 # else
    230 extern char *malloc PARAMS ((int));
    231 extern char *realloc PARAMS ((char *, int));
    232 extern void free PARAMS ((char *));
    233 
    234 extern void abort PARAMS ((void)) __attribute__ ((noreturn));
    235 extern void exit PARAMS ((int)) __attribute__ ((noreturn));
    236 # endif /* HAVE_STDLIB_H.  */
    237 
    238 #endif /* Standard headers.  */
    239 
    240 /* These should be in stdlib.h.  Make sure we have them.  */
    241 #ifndef EXIT_SUCCESS
    242 # define EXIT_SUCCESS 0
    243 #endif
    244 #ifndef EXIT_FAILURE
    245 # define EXIT_FAILURE 0
    246 #endif
    247 
    248 #ifdef  ANSI_STRING
    249 
    250 # ifndef bcmp
    251 #  define bcmp(s1, s2, n)   memcmp ((s1), (s2), (n))
    252 # endif
    253 # ifndef bzero
    254 #  define bzero(s, n)       memset ((s), 0, (n))
    255 # endif
    256 # if defined(HAVE_MEMMOVE) && !defined(bcopy)
    257 #  define bcopy(s, d, n)    memmove ((d), (s), (n))
    258 # endif
    259 
    260 #else   /* Not ANSI_STRING.  */
    261 
    262 # ifndef HAVE_STRCHR
    263 #  define strchr(s, c)      index((s), (c))
    264 #  define strrchr(s, c)     rindex((s), (c))
    265 # endif
    266 
    267 # ifndef bcmp
    268 extern int bcmp PARAMS ((const char *, const char *, int));
    269 # endif
    270 # ifndef bzero
    271 extern void bzero PARAMS ((char *, int));
    272 #endif
    273 # ifndef bcopy
    274 extern void bcopy PARAMS ((const char *b1, char *b2, int));
    275 # endif
    276 
    277 /* SCO Xenix has a buggy macro definition in <string.h>.  */
    278 #undef  strerror
    279 #if !defined(__DECC)
    280 extern char *strerror PARAMS ((int errnum));
    281 #endif
    282 
    283 #endif  /* !ANSI_STRING.  */
    284 #undef  ANSI_STRING
    285 
    286 #if HAVE_INTTYPES_H
    287 # include <inttypes.h>
    288 #endif
    289 #define FILE_TIMESTAMP uintmax_t
    290 
    291 #if !defined(HAVE_STRSIGNAL)
    292 extern char *strsignal PARAMS ((int signum));
    293 #endif
    294 
    295 /* ISDIGIT offers the following features:
    296    - Its arg may be any int or unsigned int; it need not be an unsigned char.
    297    - It's guaranteed to evaluate its argument exactly once.
    298       NOTE!  Make relies on this behavior, don't change it!
    299    - It's typically faster.
    300    POSIX 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that
    301    only '0' through '9' are digits.  Prefer ISDIGIT to isdigit() unless
    302    it's important to use the locale's definition of `digit' even when the
    303    host does not conform to POSIX.  */
    304 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
    305 
    306 #ifndef iAPX286
    307 # define streq(a, b) \
    308    ((a) == (b) || \
    309     (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
    310 # ifdef HAVE_CASE_INSENSITIVE_FS
    311 /* This is only used on Windows/DOS platforms, so we assume strcmpi().  */
    312 #  define strieq(a, b) \
    313     ((a) == (b) \
    314      || (tolower((unsigned char)*(a)) == tolower((unsigned char)*(b)) \
    315          && (*(a) == '\0' || !strcmpi ((a) + 1, (b) + 1))))
    316 # else
    317 #  define strieq(a, b) streq(a, b)
    318 # endif
    319 #else
    320 /* Buggy compiler can't handle this.  */
    321 # define streq(a, b) (strcmp ((a), (b)) == 0)
    322 # define strieq(a, b) (strcmp ((a), (b)) == 0)
    323 #endif
    324 #define strneq(a, b, l) (strncmp ((a), (b), (l)) == 0)
    325 #ifdef  VMS
    326 extern int strcmpi (const char *,const char *);
    327 #endif
    328 
    329 #if defined(__GNUC__) || defined(ENUM_BITFIELDS)
    330 # define ENUM_BITFIELD(bits)    :bits
    331 #else
    332 # define ENUM_BITFIELD(bits)
    333 #endif
    334 
    335 /* Handle gettext and locales.  */
    336 
    337 #if HAVE_LOCALE_H
    338 # include <locale.h>
    339 #else
    340 # define setlocale(category, locale)
    341 #endif
    342 
    343 #include <gettext.h>
    344 
    345 #define _(msgid)            gettext (msgid)
    346 #define N_(msgid)           gettext_noop (msgid)
    347 #define S_(msg1,msg2,num)   ngettext (msg1,msg2,num)
    348 
    349 /* Handle other OSs.  */
    350 #if defined(HAVE_DOS_PATHS)
    351 # define PATH_SEPARATOR_CHAR ';'
    352 #elif defined(VMS)
    353 # define PATH_SEPARATOR_CHAR ','
    354 #else
    355 # define PATH_SEPARATOR_CHAR ':'
    356 #endif
    357 
    358 /* This is needed for getcwd() and chdir().  */
    359 #if defined(_MSC_VER) || defined(__BORLANDC__)
    360 # include <direct.h>
    361 #endif
    362 
    363 #ifdef WINDOWS32
    364 # include <fcntl.h>
    365 # include <malloc.h>
    366 # define pipe(p) _pipe(p, 512, O_BINARY)
    367 # define kill(pid,sig) w32_kill(pid,sig)
    368 
    369 extern void sync_Path_environment(void);
    370 extern int kill(int pid, int sig);
    371 extern char *end_of_token_w32(char *s, char stopchar);
    372 extern int find_and_set_default_shell(char *token);
    373 
    374 /* indicates whether or not we have Bourne shell */
    375 extern int no_default_sh_exe;
    376 
    377 /* is default_shell unixy? */
    378 extern int unixy_shell;
    379 #endif  /* WINDOWS32 */
    380 
    381 struct floc
    382   {
    383     const char *filenm;
    384     unsigned long lineno;
    385   };
    386 #define NILF ((struct floc *)0)
    387 
    388 #define STRING_SIZE_TUPLE(_s) (_s), (sizeof (_s)-1)
    389 
    390 
    391 /* We have to have stdarg.h or varargs.h AND v*printf or doprnt to use
    393    variadic versions of these functions.  */
    394 
    395 #if HAVE_STDARG_H || HAVE_VARARGS_H
    396 # if HAVE_VPRINTF || HAVE_DOPRNT
    397 #  define USE_VARIADIC 1
    398 # endif
    399 #endif
    400 
    401 #if HAVE_ANSI_COMPILER && USE_VARIADIC && HAVE_STDARG_H
    402 extern void message (int prefix, const char *fmt, ...)
    403                      __attribute__ ((__format__ (__printf__, 2, 3)));
    404 extern void error (const struct floc *flocp, const char *fmt, ...)
    405                    __attribute__ ((__format__ (__printf__, 2, 3)));
    406 extern void fatal (const struct floc *flocp, const char *fmt, ...)
    407                    __attribute__ ((noreturn, __format__ (__printf__, 2, 3)));
    408 #else
    409 extern void message ();
    410 extern void error ();
    411 extern void fatal ();
    412 #endif
    413 
    414 extern void die PARAMS ((int)) __attribute__ ((noreturn));
    415 extern void log_working_directory PARAMS ((int));
    416 extern void pfatal_with_name PARAMS ((const char *)) __attribute__ ((noreturn));
    417 extern void perror_with_name PARAMS ((const char *, const char *));
    418 extern char *savestring PARAMS ((const char *, unsigned int));
    419 extern char *concat PARAMS ((const char *, const char *, const char *));
    420 extern char *xmalloc PARAMS ((unsigned int));
    421 extern char *xrealloc PARAMS ((char *, unsigned int));
    422 extern char *xstrdup PARAMS ((const char *));
    423 extern char *find_next_token PARAMS ((char **, unsigned int *));
    424 extern char *next_token PARAMS ((const char *));
    425 extern char *end_of_token PARAMS ((const char *));
    426 extern void collapse_continuations PARAMS ((char *));
    427 extern char *lindex PARAMS ((const char *, const char *, int));
    428 extern int alpha_compare PARAMS ((const void *, const void *));
    429 extern void print_spaces PARAMS ((unsigned int));
    430 extern char *find_percent PARAMS ((char *));
    431 extern FILE *open_tmpfile PARAMS ((char **, const char *));
    432 
    433 #ifndef NO_ARCHIVES
    434 extern int ar_name PARAMS ((char *));
    435 extern void ar_parse_name PARAMS ((char *, char **, char **));
    436 extern int ar_touch PARAMS ((char *));
    437 extern time_t ar_member_date PARAMS ((char *));
    438 #endif
    439 
    440 extern int dir_file_exists_p PARAMS ((char *, char *));
    441 extern int file_exists_p PARAMS ((char *));
    442 extern int file_impossible_p PARAMS ((char *));
    443 extern void file_impossible PARAMS ((char *));
    444 extern char *dir_name PARAMS ((char *));
    445 extern void hash_init_directories PARAMS ((void));
    446 
    447 extern void define_default_variables PARAMS ((void));
    448 extern void set_default_suffixes PARAMS ((void));
    449 extern void install_default_suffix_rules PARAMS ((void));
    450 extern void install_default_implicit_rules PARAMS ((void));
    451 
    452 extern void build_vpath_lists PARAMS ((void));
    453 extern void construct_vpath_list PARAMS ((char *pattern, char *dirpath));
    454 extern int vpath_search PARAMS ((char **file, FILE_TIMESTAMP *mtime_ptr));
    455 extern int gpath_search PARAMS ((char *file, unsigned int len));
    456 
    457 extern void construct_include_path PARAMS ((char **arg_dirs));
    458 
    459 extern void user_access PARAMS ((void));
    460 extern void make_access PARAMS ((void));
    461 extern void child_access PARAMS ((void));
    462 
    463 extern void close_stdout PARAMS ((void));
    464 
    465 extern char *strip_whitespace PARAMS ((const char **begpp, const char **endpp));
    466 
    467 /* String caching  */
    468 extern void strcache_init PARAMS ((void));
    469 extern void strcache_print_stats PARAMS ((const char *prefix));
    470 extern int strcache_iscached PARAMS ((const char *str));
    471 extern const char *strcache_add PARAMS ((const char *str));
    472 extern const char *strcache_add_len PARAMS ((const char *str, int len));
    473 extern int strcache_setbufsize PARAMS ((int size));
    474 
    475 #ifdef  HAVE_VFORK_H
    476 # include <vfork.h>
    477 #endif
    478 
    479 /* We omit these declarations on non-POSIX systems which define _POSIX_VERSION,
    480    because such systems often declare them in header files anyway.  */
    481 
    482 #if !defined (__GNU_LIBRARY__) && !defined (POSIX) && !defined (_POSIX_VERSION) && !defined(WINDOWS32)
    483 
    484 extern long int atol ();
    485 # ifndef VMS
    486 extern long int lseek ();
    487 # endif
    488 
    489 #endif  /* Not GNU C library or POSIX.  */
    490 
    491 #ifdef  HAVE_GETCWD
    492 # if !defined(VMS) && !defined(__DECC)
    493 extern char *getcwd ();
    494 # endif
    495 #else
    496 extern char *getwd ();
    497 # define getcwd(buf, len)       getwd (buf)
    498 #endif
    499 
    500 extern const struct floc *reading_file;
    501 extern const struct floc **expanding_var;
    502 
    503 extern char **environ;
    504 
    505 extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag;
    506 extern int print_data_base_flag, question_flag, touch_flag, always_make_flag;
    507 extern int env_overrides, no_builtin_rules_flag, no_builtin_variables_flag;
    508 extern int print_version_flag, print_directory_flag, check_symlink_flag;
    509 extern int warn_undefined_variables_flag, posix_pedantic, not_parallel;
    510 extern int second_expansion, clock_skew_detected, rebuilding_makefiles;
    511 
    512 /* can we run commands via 'sh -c xxx' or must we use batch files? */
    513 extern int batch_mode_shell;
    514 
    515 extern unsigned int job_slots;
    516 extern int job_fds[2];
    517 extern int job_rfd;
    518 #ifndef NO_FLOAT
    519 extern double max_load_average;
    520 #else
    521 extern int max_load_average;
    522 #endif
    523 
    524 extern char *program;
    525 extern char *starting_directory;
    526 extern unsigned int makelevel;
    527 extern char *version_string, *remote_description, *make_host;
    528 
    529 extern unsigned int commands_started;
    530 
    531 extern int handling_fatal_signal;
    532 
    533 
    534 #ifndef MIN
    535 #define MIN(_a,_b) ((_a)<(_b)?(_a):(_b))
    536 #endif
    537 #ifndef MAX
    538 #define MAX(_a,_b) ((_a)>(_b)?(_a):(_b))
    539 #endif
    540 
    541 #ifdef VMS
    542 #  define MAKE_SUCCESS 1
    543 #  define MAKE_TROUBLE 2
    544 #  define MAKE_FAILURE 3
    545 #else
    546 #  define MAKE_SUCCESS 0
    547 #  define MAKE_TROUBLE 1
    548 #  define MAKE_FAILURE 2
    549 #endif
    550 
    551 /* Set up heap debugging library dmalloc.  */
    552 
    553 #ifdef HAVE_DMALLOC_H
    554 #include <dmalloc.h>
    555 #endif
    556 
    557 #ifndef initialize_main
    558 # ifdef __EMX__
    559 #  define initialize_main(pargc, pargv) \
    560                           { _wildcard(pargc, pargv); _response(pargc, pargv); }
    561 # else
    562 #  define initialize_main(pargc, pargv)
    563 # endif
    564 #endif
    565 
    566 
    567 #ifdef __EMX__
    568 # if !HAVE_STRCASECMP
    569 #  define strcasecmp stricmp
    570 # endif
    571 
    572 # if !defined chdir
    573 #  define chdir _chdir2
    574 # endif
    575 # if !defined getcwd
    576 #  define getcwd _getcwd2
    577 # endif
    578 
    579 /* NO_CHDIR2 causes make not to use _chdir2() and _getcwd2() instead of
    580    chdir() and getcwd(). This avoids some error messages for the
    581    make testsuite but restricts the drive letter support. */
    582 # ifdef NO_CHDIR2
    583 #  warning NO_CHDIR2: usage of drive letters restricted
    584 #  undef chdir
    585 #  undef getcwd
    586 # endif
    587 #endif
    588 
    589 #ifndef initialize_main
    590 # define initialize_main(pargc, pargv)
    591 #endif
    592 
    593 
    594 /* Some systems (like Solaris, PTX, etc.) do not support the SA_RESTART flag
    595    properly according to POSIX.  So, we try to wrap common system calls with
    596    checks for EINTR.  Note that there are still plenty of system calls that
    597    can fail with EINTR but this, reportedly, gets the vast majority of
    598    failure cases.  If you still experience failures you'll need to either get
    599    a system where SA_RESTART works, or you need to avoid -j.  */
    600 
    601 #define EINTRLOOP(_v,_c)   while (((_v)=_c)==-1 && errno==EINTR)
    602 
    603 /* While system calls that return integers are pretty consistent about
    604    returning -1 on failure and setting errno in that case, functions that
    605    return pointers are not always so well behaved.  Sometimes they return
    606    NULL for expected behavior: one good example is readdir() which returns
    607    NULL at the end of the directory--and _doesn't_ reset errno.  So, we have
    608    to do it ourselves here.  */
    609 
    610 #define ENULLLOOP(_v,_c)   do{ errno = 0; \
    611                                while (((_v)=_c)==0 && errno==EINTR); }while(0)
    612 
    613