VirtualBox

source: kBuild/trunk/src/kmk/make.h@ 1976

Last change on this file since 1976 was 1976, checked in by bird, 17 years ago

make.h: build fix/adjstument.

  • Property svn:eol-style set to native
File size: 25.3 KB
Line 
1/* Miscellaneous global declarations and portability cruft for GNU Make.
2Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
4Foundation, Inc.
5This file is part of GNU Make.
6
7GNU Make is free software; you can redistribute it and/or modify it under the
8terms of the GNU General Public License as published by the Free Software
9Foundation; either version 2, or (at your option) any later version.
10
11GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License along with
16GNU Make; see the file COPYING. If not, write to the Free Software
17Foundation, 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 */
35char *alloca ();
36# endif
37# endif
38# endif
39#endif
40
41
42/* Specify we want GNU source code. This must be defined before any
43 system headers are included. */
44
45#define _GNU_SOURCE 1
46
47
48#ifdef CRAY
49/* This must happen before #include <signal.h> so
50 that the declaration therein is changed. */
51# define signal bsdsignal
52#endif
53
54/* If we're compiling for the dmalloc debugger, turn off string inlining. */
55#if defined(HAVE_DMALLOC_H) && defined(__GNUC__)
56# define __NO_STRING_INLINES
57#endif
58
59#include <sys/types.h>
60#include <sys/stat.h>
61#include <signal.h>
62#include <stdio.h>
63#include <ctype.h>
64#ifdef HAVE_SYS_TIMEB_H
65/* SCO 3.2 "devsys 4.2" has a prototype for `ftime' in <time.h> that bombs
66 unless <sys/timeb.h> has been included first. Does every system have a
67 <sys/timeb.h>? If any does not, configure should check for it. */
68# include <sys/timeb.h>
69#endif
70
71#if TIME_WITH_SYS_TIME
72# include <sys/time.h>
73# include <time.h>
74#else
75# if HAVE_SYS_TIME_H
76# include <sys/time.h>
77# else
78# include <time.h>
79# endif
80#endif
81
82#include <errno.h>
83
84#ifndef errno
85extern int errno;
86#endif
87
88#ifndef isblank
89# define isblank(c) ((c) == ' ' || (c) == '\t')
90#endif
91
92#ifdef HAVE_UNISTD_H
93# include <unistd.h>
94/* Ultrix's unistd.h always defines _POSIX_VERSION, but you only get
95 POSIX.1 behavior with `cc -YPOSIX', which predefines POSIX itself! */
96# if defined (_POSIX_VERSION) && !defined (ultrix) && !defined (VMS)
97# define POSIX 1
98# endif
99#endif
100
101/* Some systems define _POSIX_VERSION but are not really POSIX.1. */
102#if (defined (butterfly) || defined (__arm) || (defined (__mips) && defined (_SYSTYPE_SVR3)) || (defined (sequent) && defined (i386)))
103# undef POSIX
104#endif
105
106#if !defined (POSIX) && defined (_AIX) && defined (_POSIX_SOURCE)
107# define POSIX 1
108#endif
109
110#ifndef RETSIGTYPE
111# define RETSIGTYPE void
112#endif
113
114#ifndef sigmask
115# define sigmask(sig) (1 << ((sig) - 1))
116#endif
117
118#ifndef HAVE_SA_RESTART
119# define SA_RESTART 0
120#endif
121
122#ifdef HAVE_LIMITS_H
123# include <limits.h>
124#endif
125#ifdef HAVE_SYS_PARAM_H
126# include <sys/param.h>
127#endif
128
129#ifndef PATH_MAX
130# ifndef POSIX
131# define PATH_MAX MAXPATHLEN
132# endif
133#endif
134#ifndef MAXPATHLEN
135# define MAXPATHLEN 1024
136#endif
137
138#ifdef PATH_MAX
139# define GET_PATH_MAX PATH_MAX
140# define PATH_VAR(var) char var[PATH_MAX]
141#else
142# define NEED_GET_PATH_MAX 1
143# define GET_PATH_MAX (get_path_max ())
144# define PATH_VAR(var) char *var = alloca (GET_PATH_MAX)
145unsigned int get_path_max (void);
146#endif
147
148#if defined (KMK) || defined (CONFIG_WITH_VALUE_LENGTH) \
149 || defined (CONFIG_WITH_ALLOC_CACHES) \
150 || defined (CONFIG_WITH_STRCACHE2)
151# ifdef _MSC_VER
152# define MY_INLINE _inline static
153# elif defined(__GNUC__)
154# define MY_INLINE static __inline__
155# else
156# define MY_INLINE static
157# endif
158
159# ifdef __GNUC__
160# define MY_PREDICT_TRUE(expr) __builtin_expect(!!(expr), 1)
161# define MY_PREDICT_FALSE(expr) __builtin_expect(!!(expr), 0)
162# else
163# define MY_PREDICT_TRUE(expr) (expr)
164# define MY_PREDICT_FALSE(expr) (expr)
165# endif
166#endif
167
168#if defined (KMK) || defined (CONFIG_WITH_VALUE_LENGTH) \
169 || defined (CONFIG_WITH_STRCACHE2)
170# ifdef _MSC_VER
171# define MY_DBGBREAK __debugbreak()
172# elif defined(__GNUC__)
173# if defined(__i386__) || defined(__x86_64__)
174# define MY_DBGBREAK __asm__ __volatile__ ("int3")
175# else
176# define MY_DBGBREAK assert(0)
177# endif
178# else
179# define MY_DBGBREAK assert(0)
180# endif
181# ifndef NDEBUG
182# define MY_ASSERT_MSG(expr, printfargs) \
183 do { if (!(expr)) { printf printfargs; MY_DBGBREAK; } } while (0)
184# else
185# define MY_ASSERT_MSG(expr, printfargs) do { } while (0)
186# endif
187#endif
188
189#ifdef KMK
190# include <ctype.h>
191# if 1 /* See if this speeds things up (Windows is doing this anyway, so,
192 we might as well try be consistent in speed + features). */
193# if 1
194# define MY_IS_BLANK(ch) ((ch) == ' ' || (ch) == '\t')
195# define MY_IS_BLANK_OR_EOS(ch) ((ch) == ' ' || (ch) == '\t' || (ch) == '\0')
196# else
197# define MY_IS_BLANK(ch) (((ch) == ' ') | ((ch) == '\t'))
198# define MY_IS_BLANK_OR_EOS(ch) (((ch) == ' ') | ((ch) == '\t') | ((ch) == '\0'))
199# endif
200# undef isblank
201# define isblank(ch) MY_IS_BLANK(ch)
202# else
203# define MY_IS_BLANK(ch) isblank ((unsigned char)(ch))
204# define MY_IS_BLANK_OR_EOS(ch) (isblank ((unsigned char)(ch)) || (ch) == '\0')
205# endif
206#endif
207
208#ifdef CONFIG_WITH_MAKE_STATS
209extern long make_stats_allocations;
210extern unsigned long make_stats_allocated;
211extern unsigned long make_stats_allocated_sum;
212extern unsigned long make_stats_ht_lookups;
213extern unsigned long make_stats_ht_collisions;
214
215# ifdef __APPLE__
216# include <malloc/malloc.h>
217# define SIZE_OF_HEAP_BLOCK(ptr) malloc_size(ptr)
218
219# elif defined(__linux__) /* glibc */
220# include <malloc.h>
221# define SIZE_OF_HEAP_BLOCK(ptr) malloc_usable_size(ptr)
222
223# elif defined(_MSC_VER) || defined(__OS2__)
224# define SIZE_OF_HEAP_BLOCK(ptr) _msize(ptr)
225
226# else
227# include <stdlib.h>
228# define SIZE_OF_HEAP_BLOCK(ptr) 0
229#endif
230
231# if defined(CONFIG_WITH_MAKE_STATS) && !defined(ELECTRIC_HEAP)
232# define free xfree
233extern void xfree (void *);
234# endif
235
236# define MAKE_STATS_3(expr) do { expr; } while (0)
237# define MAKE_STATS_2(expr) do { expr; } while (0)
238# define MAKE_STATS(expr) do { expr; } while (0)
239#else
240# define MAKE_STATS_3(expr) do { } while (0)
241# define MAKE_STATS_2(expr) do { } while (0)
242# define MAKE_STATS(expr) do { } while (0)
243#endif
244
245
246#ifndef CHAR_BIT
247# define CHAR_BIT 8
248#endif
249
250/* Nonzero if the integer type T is signed. */
251#define INTEGER_TYPE_SIGNED(t) ((t) -1 < 0)
252
253/* The minimum and maximum values for the integer type T.
254 Use ~ (t) 0, not -1, for portability to 1's complement hosts. */
255#define INTEGER_TYPE_MINIMUM(t) \
256 (! INTEGER_TYPE_SIGNED (t) ? (t) 0 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))
257#define INTEGER_TYPE_MAXIMUM(t) (~ (t) 0 - INTEGER_TYPE_MINIMUM (t))
258
259#ifndef CHAR_MAX
260# define CHAR_MAX INTEGER_TYPE_MAXIMUM (char)
261#endif
262
263#ifdef STAT_MACROS_BROKEN
264# ifdef S_ISREG
265# undef S_ISREG
266# endif
267# ifdef S_ISDIR
268# undef S_ISDIR
269# endif
270#endif /* STAT_MACROS_BROKEN. */
271
272#ifndef S_ISREG
273# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
274#endif
275#ifndef S_ISDIR
276# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
277#endif
278
279#ifdef VMS
280# include <types.h>
281# include <unixlib.h>
282# include <unixio.h>
283# include <perror.h>
284/* Needed to use alloca on VMS. */
285# include <builtins.h>
286#endif
287
288#ifndef __attribute__
289/* This feature is available in gcc versions 2.5 and later. */
290# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
291# define __attribute__(x)
292# endif
293/* The __-protected variants of `format' and `printf' attributes
294 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
295# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
296# define __format__ format
297# define __printf__ printf
298# endif
299#endif
300#define UNUSED __attribute__ ((unused))
301
302#if defined (STDC_HEADERS) || defined (__GNU_LIBRARY__)
303# include <stdlib.h>
304# include <string.h>
305# define ANSI_STRING 1
306#else /* No standard headers. */
307# ifdef HAVE_STRING_H
308# include <string.h>
309# define ANSI_STRING 1
310# else
311# include <strings.h>
312# endif
313# ifdef HAVE_MEMORY_H
314# include <memory.h>
315# endif
316# ifdef HAVE_STDLIB_H
317# include <stdlib.h>
318# else
319void *malloc (int);
320void *realloc (void *, int);
321void free (void *);
322
323void abort (void) __attribute__ ((noreturn));
324void exit (int) __attribute__ ((noreturn));
325# endif /* HAVE_STDLIB_H. */
326
327#endif /* Standard headers. */
328
329/* These should be in stdlib.h. Make sure we have them. */
330#ifndef EXIT_SUCCESS
331# define EXIT_SUCCESS 0
332#endif
333#ifndef EXIT_FAILURE
334# define EXIT_FAILURE 1
335#endif
336
337#ifndef ANSI_STRING
338
339/* SCO Xenix has a buggy macro definition in <string.h>. */
340#undef strerror
341#if !defined(__DECC)
342char *strerror (int errnum);
343#endif
344
345#endif /* !ANSI_STRING. */
346#undef ANSI_STRING
347
348#if HAVE_INTTYPES_H
349# include <inttypes.h>
350#endif
351#define FILE_TIMESTAMP uintmax_t
352
353#if !defined(HAVE_STRSIGNAL)
354char *strsignal (int signum);
355#endif
356
357/* ISDIGIT offers the following features:
358 - Its arg may be any int or unsigned int; it need not be an unsigned char.
359 - It's guaranteed to evaluate its argument exactly once.
360 NOTE! Make relies on this behavior, don't change it!
361 - It's typically faster.
362 POSIX 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that
363 only '0' through '9' are digits. Prefer ISDIGIT to isdigit() unless
364 it's important to use the locale's definition of `digit' even when the
365 host does not conform to POSIX. */
366#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
367
368#ifndef iAPX286
369# define streq(a, b) \
370 ((a) == (b) || \
371 (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
372# ifdef HAVE_CASE_INSENSITIVE_FS
373# define strieq(a, b) \
374 ((a) == (b) \
375 || (tolower((unsigned char)*(a)) == tolower((unsigned char)*(b)) \
376 && (*(a) == '\0' || !strcasecmp ((a) + 1, (b) + 1))))
377# else
378# define strieq(a, b) streq(a, b)
379# endif
380#else
381/* Buggy compiler can't handle this. */
382# define streq(a, b) (strcmp ((a), (b)) == 0)
383# define strieq(a, b) (strcmp ((a), (b)) == 0)
384#endif
385#define strneq(a, b, l) (strncmp ((a), (b), (l)) == 0)
386
387#if (defined(__GNUC__) || defined(ENUM_BITFIELDS)) && !defined(NO_ENUM_BITFIELDS)
388# define ENUM_BITFIELD(bits) :bits
389#else
390# define ENUM_BITFIELD(bits)
391#endif
392
393/* Handle gettext and locales. */
394
395#if HAVE_LOCALE_H
396# include <locale.h>
397#else
398# define setlocale(category, locale)
399#endif
400
401#include <gettext.h>
402
403#define _(msgid) gettext (msgid)
404#define N_(msgid) gettext_noop (msgid)
405#define S_(msg1,msg2,num) ngettext (msg1,msg2,num)
406
407/* Handle other OSs. */
408#ifndef PATH_SEPARATOR_CHAR
409# if defined(HAVE_DOS_PATHS)
410# define PATH_SEPARATOR_CHAR ';'
411# elif defined(VMS)
412# define PATH_SEPARATOR_CHAR ','
413# else
414# define PATH_SEPARATOR_CHAR ':'
415# endif
416#endif
417
418/* This is needed for getcwd() and chdir(), on some W32 systems. */
419#if defined(HAVE_DIRECT_H)
420# include <direct.h>
421#endif
422
423#ifdef WINDOWS32
424# include <fcntl.h>
425# include <malloc.h>
426# define pipe(_p) _pipe((_p), 512, O_BINARY)
427# define kill(_pid,_sig) w32_kill((_pid),(_sig))
428
429void sync_Path_environment (void);
430int w32_kill (int pid, int sig); /* bird kill -> w32_kill - macro acquired () on the args. */
431char *end_of_token_w32 (const char *s, char stopchar);
432int find_and_set_default_shell (const char *token);
433
434/* indicates whether or not we have Bourne shell */
435extern int no_default_sh_exe;
436
437/* is default_shell unixy? */
438extern int unixy_shell;
439#endif /* WINDOWS32 */
440
441struct floc
442 {
443 const char *filenm;
444 unsigned long lineno;
445 };
446#define NILF ((struct floc *)0)
447
448#define STRING_SIZE_TUPLE(_s) (_s), (sizeof (_s)-1)
449
450
451
452/* We have to have stdarg.h or varargs.h AND v*printf or doprnt to use
453 variadic versions of these functions. */
454
455#if HAVE_STDARG_H || HAVE_VARARGS_H
456# if HAVE_VPRINTF || HAVE_DOPRNT
457# define USE_VARIADIC 1
458# endif
459#endif
460
461#if HAVE_ANSI_COMPILER && USE_VARIADIC && HAVE_STDARG_H
462void message (int prefix, const char *fmt, ...)
463 __attribute__ ((__format__ (__printf__, 2, 3)));
464void error (const struct floc *flocp, const char *fmt, ...)
465 __attribute__ ((__format__ (__printf__, 2, 3)));
466void fatal (const struct floc *flocp, const char *fmt, ...)
467 __attribute__ ((noreturn, __format__ (__printf__, 2, 3)));
468#else
469void message ();
470void error ();
471void fatal ();
472#endif
473
474void die (int) __attribute__ ((noreturn));
475void log_working_directory (int);
476void pfatal_with_name (const char *) __attribute__ ((noreturn));
477void perror_with_name (const char *, const char *);
478char *savestring (const char *, unsigned int);
479char *concat (const char *, const char *, const char *);
480void *xmalloc (unsigned int);
481void *xrealloc (void *, unsigned int);
482char *xstrdup (const char *);
483#ifdef CONFIG_WITH_PRINT_STATS_SWITCH
484void print_heap_stats (void);
485#endif
486char *find_next_token (const char **, unsigned int *);
487char *next_token (const char *);
488char *end_of_token (const char *);
489#ifndef CONFIG_WITH_VALUE_LENGTH
490void collapse_continuations (char *);
491#else
492char *collapse_continuations (char *, unsigned int);
493#endif
494#ifdef CONFIG_WITH_OPTIMIZATION_HACKS /* memchr is usually compiler intrinsic, thus faster. */
495# define lindex(s, limit, c) ((char *)memchr((s), (c), (limit) - (s)))
496#else
497char *lindex (const char *, const char *, int);
498#endif
499int alpha_compare (const void *, const void *);
500void print_spaces (unsigned int);
501char *find_percent (char *);
502const char *find_percent_cached (const char **);
503FILE *open_tmpfile (char **, const char *);
504
505#ifndef NO_ARCHIVES
506int ar_name (const char *);
507void ar_parse_name (const char *, char **, char **);
508int ar_touch (const char *);
509time_t ar_member_date (const char *);
510
511typedef long int (*ar_member_func_t) (int desc, const char *mem, int truncated,
512 long int hdrpos, long int datapos,
513 long int size, long int date, int uid,
514 int gid, int mode, const void *arg);
515
516long int ar_scan (const char *archive, ar_member_func_t function, const void *arg);
517int ar_name_equal (const char *name, const char *mem, int truncated);
518#ifndef VMS
519int ar_member_touch (const char *arname, const char *memname);
520#endif
521#endif
522
523int dir_file_exists_p (const char *, const char *);
524int file_exists_p (const char *);
525int file_impossible_p (const char *);
526void file_impossible (const char *);
527const char *dir_name (const char *);
528void hash_init_directories (void);
529
530void define_default_variables (void);
531void set_default_suffixes (void);
532void install_default_suffix_rules (void);
533void install_default_implicit_rules (void);
534
535void build_vpath_lists (void);
536void construct_vpath_list (char *pattern, char *dirpath);
537const char *vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr);
538int gpath_search (const char *file, unsigned int len);
539
540void construct_include_path (const char **arg_dirs);
541
542void user_access (void);
543void make_access (void);
544void child_access (void);
545
546void close_stdout (void);
547
548char *strip_whitespace (const char **begpp, const char **endpp);
549
550#ifdef CONFIG_WITH_ALLOC_CACHES
551/* alloccache (misc.c) */
552
553struct alloccache_free_ent
554{
555 struct alloccache_free_ent *next;
556};
557
558struct alloccache
559{
560 char *free_start;
561 char *free_end;
562 struct alloccache_free_ent *free_head;
563 unsigned int size;
564 unsigned int total_count;
565 unsigned long alloc_count;
566 unsigned long free_count;
567 const char *name;
568 struct alloccache *next;
569 void *grow_arg;
570 void *(*grow_alloc)(void *grow_arg, unsigned int size);
571};
572
573void alloccache_init (struct alloccache *cache, unsigned int size, const char *name,
574 void *(*grow_alloc)(void *grow_arg, unsigned int size), void *grow_arg);
575void alloccache_term (struct alloccache *cache,
576 void (*term_free)(void *term_arg, void *ptr, unsigned int size), void *term_arg);
577void alloccache_join (struct alloccache *cache, struct alloccache *eat);
578void alloccache_print (struct alloccache *cache);
579void alloccache_print_all (void);
580struct alloccache_free_ent *alloccache_alloc_grow (struct alloccache *cache);
581
582/* Allocate an item. */
583MY_INLINE void *
584alloccache_alloc (struct alloccache *cache)
585{
586 struct alloccache_free_ent *f = cache->free_head;
587 if (f)
588 cache->free_head = f->next;
589 else if (cache->free_start != cache->free_end)
590 {
591 f = (struct alloccache_free_ent *)cache->free_start;
592 cache->free_start += cache->size;
593 }
594 else
595 f = alloccache_alloc_grow (cache);
596 MAKE_STATS(cache->alloc_count++;);
597 return f;
598}
599
600/* Allocate a cleared item. */
601MY_INLINE void *
602alloccache_calloc (struct alloccache *cache)
603{
604 void *item = alloccache_alloc (cache);
605 memset (item, '\0', cache->size);
606 return item;
607}
608
609/* Free an item. */
610MY_INLINE void
611alloccache_free (struct alloccache *cache, void *item)
612{
613 struct alloccache_free_ent *f = (struct alloccache_free_ent *)item;
614#if 0 /*ndef NDEBUG*/
615 struct alloccache_free_ent *c;
616 unsigned int i = 0;
617 for (c = cache->free_head; c != NULL; c = c->next, i++)
618 MY_ASSERT_MSG (c != f && i < 0x10000000,
619 ("i=%u total_count=%u\n", i, cache->total_count));
620#endif
621
622 f->next = cache->free_head;
623 cache->free_head = f;
624 MAKE_STATS(cache->free_count++;);
625}
626
627/* the alloc caches */
628extern struct alloccache dep_cache;
629extern struct alloccache file_cache;
630extern struct alloccache commands_cache;
631extern struct alloccache nameseq_cache;
632extern struct alloccache variable_cache;
633extern struct alloccache variable_set_cache;
634extern struct alloccache variable_set_list_cache;
635
636#endif /* CONFIG_WITH_ALLOC_CACHES */
637
638
639/* String caching */
640void strcache_init (void);
641void strcache_print_stats (const char *prefix);
642#ifndef CONFIG_WITH_STRCACHE2
643int strcache_iscached (const char *str);
644const char *strcache_add (const char *str);
645const char *strcache_add_len (const char *str, int len);
646int strcache_setbufsize (int size);
647#else /* CONFIG_WITH_STRCACHE2 */
648
649# include "strcache2.h"
650extern struct strcache2 file_strcache;
651extern const char *suffixes_strcached;
652
653# define strcache_iscached(str) strcache2_is_cached(&file_strcache, str)
654# define strcache_add(str) strcache2_add_file(&file_strcache, str, strlen (str))
655# define strcache_add_len(str, len) strcache2_add_file(&file_strcache, str, len)
656# define strcache_get_len(str) strcache2_get_len(&file_strcache, str) /* FIXME: replace this and related checks ... */
657
658#endif /* CONFIG_WITH_STRCACHE2 */
659
660#ifdef HAVE_VFORK_H
661# include <vfork.h>
662#endif
663
664/* We omit these declarations on non-POSIX systems which define _POSIX_VERSION,
665 because such systems often declare them in header files anyway. */
666
667#if !defined (__GNU_LIBRARY__) && !defined (POSIX) && !defined (_POSIX_VERSION) && !defined(WINDOWS32)
668
669long int atol ();
670# ifndef VMS
671long int lseek ();
672# endif
673
674#endif /* Not GNU C library or POSIX. */
675
676#ifdef HAVE_GETCWD
677# if !defined(VMS) && !defined(__DECC) && !defined(_MSC_VER) /* bird: MSC */
678char *getcwd ();
679# endif
680#else
681char *getwd ();
682# define getcwd(buf, len) getwd (buf)
683#endif
684
685#if !HAVE_STRCASECMP
686# if HAVE_STRICMP
687# define strcasecmp stricmp
688# elif HAVE_STRCMPI
689# define strcasecmp strcmpi
690# else
691/* Create our own, in misc.c */
692int strcasecmp (const char *s1, const char *s2);
693# endif
694#endif
695
696extern const struct floc *reading_file;
697extern const struct floc **expanding_var;
698
699#if !defined(_MSC_VER) /* bird */
700extern char **environ;
701#endif
702
703extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag;
704extern int print_data_base_flag, question_flag, touch_flag, always_make_flag;
705extern int env_overrides, no_builtin_rules_flag, no_builtin_variables_flag;
706extern int print_version_flag, print_directory_flag, check_symlink_flag;
707extern int warn_undefined_variables_flag, posix_pedantic, not_parallel;
708extern int second_expansion, clock_skew_detected, rebuilding_makefiles;
709#ifdef CONFIG_WITH_2ND_TARGET_EXPANSION
710extern int second_target_expansion;
711#endif
712#ifdef CONFIG_PRETTY_COMMAND_PRINTING
713extern int pretty_command_printing;
714#endif
715#if defined (CONFIG_WITH_MAKE_STATS) || defined (CONFIG_WITH_MINIMAL_STATS)
716extern int make_expensive_statistics;
717#endif
718
719
720/* can we run commands via 'sh -c xxx' or must we use batch files? */
721extern int batch_mode_shell;
722
723extern char cmd_prefix;
724
725extern unsigned int job_slots;
726extern int job_fds[2];
727extern int job_rfd;
728#ifndef NO_FLOAT
729extern double max_load_average;
730#else
731extern int max_load_average;
732#endif
733
734extern char *program;
735extern char *starting_directory;
736extern unsigned int makelevel;
737extern char *version_string, *remote_description, *make_host;
738
739extern unsigned int commands_started;
740
741extern int handling_fatal_signal;
742
743
744#ifndef MIN
745#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b))
746#endif
747#ifndef MAX
748#define MAX(_a,_b) ((_a)>(_b)?(_a):(_b))
749#endif
750
751#ifdef VMS
752# define MAKE_SUCCESS 1
753# define MAKE_TROUBLE 2
754# define MAKE_FAILURE 3
755#else
756# define MAKE_SUCCESS 0
757# define MAKE_TROUBLE 1
758# define MAKE_FAILURE 2
759#endif
760
761/* Set up heap debugging library dmalloc. */
762
763#ifdef HAVE_DMALLOC_H
764#include <dmalloc.h>
765#endif
766
767#ifndef initialize_main
768# ifdef __EMX__
769# define initialize_main(pargc, pargv) \
770 { _wildcard(pargc, pargv); _response(pargc, pargv); }
771# else
772# define initialize_main(pargc, pargv)
773# endif
774#endif
775
776#ifdef __EMX__
777# if !defined chdir
778# define chdir _chdir2
779# endif
780# if !defined getcwd
781# define getcwd _getcwd2
782# endif
783
784/* NO_CHDIR2 causes make not to use _chdir2() and _getcwd2() instead of
785 chdir() and getcwd(). This avoids some error messages for the
786 make testsuite but restricts the drive letter support. */
787# ifdef NO_CHDIR2
788# warning NO_CHDIR2: usage of drive letters restricted
789# undef chdir
790# undef getcwd
791# endif
792#endif
793
794#ifndef initialize_main
795# define initialize_main(pargc, pargv)
796#endif
797
798
799/* Some systems (like Solaris, PTX, etc.) do not support the SA_RESTART flag
800 properly according to POSIX. So, we try to wrap common system calls with
801 checks for EINTR. Note that there are still plenty of system calls that
802 can fail with EINTR but this, reportedly, gets the vast majority of
803 failure cases. If you still experience failures you'll need to either get
804 a system where SA_RESTART works, or you need to avoid -j. */
805
806#define EINTRLOOP(_v,_c) while (((_v)=_c)==-1 && errno==EINTR)
807
808/* While system calls that return integers are pretty consistent about
809 returning -1 on failure and setting errno in that case, functions that
810 return pointers are not always so well behaved. Sometimes they return
811 NULL for expected behavior: one good example is readdir() which returns
812 NULL at the end of the directory--and _doesn't_ reset errno. So, we have
813 to do it ourselves here. */
814
815#define ENULLLOOP(_v,_c) do { errno = 0; (_v) = _c; } \
816 while((_v)==0 && errno==EINTR)
817
818
819#if defined(__EMX__) && defined(CONFIG_WITH_OPTIMIZATION_HACKS) /* bird: saves 40-100ms on libc. */
820static inline void *__my_rawmemchr (const void *__s, int __c);
821#undef strchr
822#define strchr(s, c) \
823 (__extension__ (__builtin_constant_p (c) \
824 ? ((c) == '\0' \
825 ? (char *) __my_rawmemchr ((s), (c)) \
826 : __my_strchr_c ((s), ((c) & 0xff) << 8)) \
827 : __my_strchr_g ((s), (c))))
828static inline char *__my_strchr_c (const char *__s, int __c)
829{
830 register unsigned long int __d0;
831 register char *__res;
832 __asm__ __volatile__
833 ("1:\n\t"
834 "movb (%0),%%al\n\t"
835 "cmpb %%ah,%%al\n\t"
836 "je 2f\n\t"
837 "leal 1(%0),%0\n\t"
838 "testb %%al,%%al\n\t"
839 "jne 1b\n\t"
840 "xorl %0,%0\n"
841 "2:"
842 : "=r" (__res), "=&a" (__d0)
843 : "0" (__s), "1" (__c),
844 "m" ( *(struct { char __x[0xfffffff]; } *)__s)
845 : "cc");
846 return __res;
847}
848
849static inline char *__my_strchr_g (__const char *__s, int __c)
850{
851 register unsigned long int __d0;
852 register char *__res;
853 __asm__ __volatile__
854 ("movb %%al,%%ah\n"
855 "1:\n\t"
856 "movb (%0),%%al\n\t"
857 "cmpb %%ah,%%al\n\t"
858 "je 2f\n\t"
859 "leal 1(%0),%0\n\t"
860 "testb %%al,%%al\n\t"
861 "jne 1b\n\t"
862 "xorl %0,%0\n"
863 "2:"
864 : "=r" (__res), "=&a" (__d0)
865 : "0" (__s), "1" (__c),
866 "m" ( *(struct { char __x[0xfffffff]; } *)__s)
867 : "cc");
868 return __res;
869}
870
871static inline void *__my_rawmemchr (const void *__s, int __c)
872{
873 register unsigned long int __d0;
874 register unsigned char *__res;
875 __asm__ __volatile__
876 ("cld\n\t"
877 "repne; scasb\n\t"
878 : "=D" (__res), "=&c" (__d0)
879 : "a" (__c), "0" (__s), "1" (0xffffffff),
880 "m" ( *(struct { char __x[0xfffffff]; } *)__s)
881 : "cc");
882 return __res - 1;
883}
884
885#undef memchr
886#define memchr(a,b,c) __my_memchr((a),(b),(c))
887static inline void *__my_memchr (__const void *__s, int __c, size_t __n)
888{
889 register unsigned long int __d0;
890 register unsigned char *__res;
891 if (__n == 0)
892 return NULL;
893 __asm__ __volatile__
894 ("repne; scasb\n\t"
895 "je 1f\n\t"
896 "movl $1,%0\n"
897 "1:"
898 : "=D" (__res), "=&c" (__d0)
899 : "a" (__c), "0" (__s), "1" (__n),
900 "m" ( *(struct { __extension__ char __x[__n]; } *)__s)
901 : "cc");
902 return __res - 1;
903}
904
905#endif /* __EMX__ (bird) */
906
907#ifdef CONFIG_WITH_IF_CONDITIONALS
908extern int expr_eval_if_conditionals(char *line, const struct floc *flocp);
909extern char *expr_eval_to_string(char *o, char *expr);
910#endif
911
912#ifdef KMK
913extern char *abspath(const char *name, char *apath);
914extern char *func_breakpoint(char *o, char **argv, const char *funcname);
915#endif
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette