VirtualBox

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

Last change on this file since 2615 was 2591, checked in by bird, 13 years ago

kmk: Merged in changes from GNU make 3.82. Previous GNU make base version was gnumake-2008-10-28-CVS.

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

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