Changeset 3140 for trunk/src/kmk/incdep.c
- Timestamp:
- Mar 14, 2018, 10:28:10 PM (7 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk
-
Property svn:mergeinfo
set to
/vendor/gnumake/current merged eligible
-
Property svn:mergeinfo
set to
-
trunk/src/kmk/incdep.c
r3100 r3140 38 38 #endif 39 39 40 #include "make .h"40 #include "makeint.h" 41 41 42 42 #if !defined(WINDOWS32) && !defined(__OS2__) … … 48 48 #include <glob.h> 49 49 50 #include "filedef.h" 50 51 #include "dep.h" 51 #include "filedef.h"52 52 #include "job.h" 53 53 #include "commands.h" … … 108 108 int recursive; 109 109 struct variable_set *set; 110 const struct floc *flocp;/* NILF */110 const floc *flocp; /* NILF */ 111 111 }; 112 112 … … 115 115 struct incdep_variable_def *next; 116 116 /* the parameters */ 117 const struct floc *flocp;/* NILF */117 const floc *flocp; /* NILF */ 118 118 struct strcache2_entry *name_entry; /* dep strcache - WRONG */ 119 119 char *value; /* xmalloc'ed, free it */ … … 131 131 struct strcache2_entry *filename_entry; /* dep strcache; converted to a nameseq record. */ 132 132 struct dep *deps; /* All the names are dep strcache entries. */ 133 const struct floc *flocp;/* NILF */133 const floc *flocp; /* NILF */ 134 134 }; 135 135 … … 238 238 * Internal Functions * 239 239 *******************************************************************************/ 240 static void incdep_flush_it ( structfloc *);241 static void eval_include_dep_file (struct incdep *, structfloc *);240 static void incdep_flush_it (floc *); 241 static void eval_include_dep_file (struct incdep *, floc *); 242 242 static void incdep_commit_recorded_file (const char *filename, struct dep *deps, 243 const structfloc *flocp);243 const floc *flocp); 244 244 245 245 … … 496 496 /* Reads a dep file into memory. */ 497 497 static int 498 incdep_read_file (struct incdep *cur, structfloc *f)498 incdep_read_file (struct incdep *cur, floc *f) 499 499 { 500 500 #ifdef INCDEP_USE_KFSCACHE … … 513 513 incdep_xfree (cur, cur->file_base); 514 514 } 515 error (f, "%s/%s: error reading file", cur->pFileObj->pParent->Obj.pszName, cur->pFileObj->pszName);515 OSS (error, f, "%s/%s: error reading file", cur->pFileObj->pParent->Obj.pszName, cur->pFileObj->pszName); 516 516 517 517 #else /* !INCDEP_USE_KFSCACHE */ … … 520 520 521 521 errno = 0; 522 # ifdef O_BINARY522 # ifdef O_BINARY 523 523 fd = open (cur->name, O_RDONLY | O_BINARY, 0); 524 # else524 # else 525 525 fd = open (cur->name, O_RDONLY, 0); 526 # endif526 # endif 527 527 if (fd < 0) 528 528 { … … 531 531 if (err == ENOENT || stat (cur->name, &st) != 0) 532 532 return 1; 533 error (f, "%s: %s", cur->name, strerror (err));533 OSS (error, f, "%s: %s", cur->name, strerror (err)); 534 534 return -1; 535 535 } 536 # ifdef KBUILD_OS_WINDOWS /* fewer kernel calls */536 # ifdef KBUILD_OS_WINDOWS /* fewer kernel calls */ 537 537 if (!birdStatOnFdJustSize (fd, &st.st_size)) 538 # else538 # else 539 539 if (!fstat (fd, &st)) 540 # endif540 # endif 541 541 { 542 542 cur->file_base = incdep_xmalloc (cur, st.st_size + 1); … … 673 673 if (getenv ("KMK_THREADS_DISABLED")) 674 674 { 675 message (1, "Threads disabled (environment)");675 O (message, 1, "Threads disabled (environment)"); 676 676 return 0; 677 677 } … … 694 694 || getenv ("FAKEROOT_DB_SEARCH_PATHS")) 695 695 { 696 message (1, "Threads disabled (fakeroot)");696 O (message, 1, "Threads disabled (fakeroot)"); 697 697 return 0; 698 698 } … … 702 702 if (getenv ("LD_PRELOAD")) 703 703 { 704 message (1, "Threads disabled (LD_PRELOAD)");704 O (message, 1, "Threads disabled (LD_PRELOAD)"); 705 705 return 0; 706 706 } … … 723 723 /* Creates the the worker threads. */ 724 724 static void 725 incdep_init ( structfloc *f)725 incdep_init (floc *f) 726 726 { 727 727 unsigned i; … … 754 754 rc = pthread_mutex_init (&incdep_mtx, NULL); 755 755 if (rc) 756 fatal (f, _("pthread_mutex_init failed: err=%d"), rc);756 ON (fatal, f, _("pthread_mutex_init failed: err=%d"), rc); 757 757 rc = pthread_cond_init (&incdep_cond_todo, NULL); 758 758 if (rc) 759 fatal (f, _("pthread_cond_init failed: err=%d"), rc);759 ON (fatal, f, _("pthread_cond_init failed: err=%d"), rc); 760 760 rc = pthread_cond_init (&incdep_cond_done, NULL); 761 761 if (rc) 762 fatal (f, _("pthread_cond_init failed: err=%d"), rc);762 ON (fatal, f, _("pthread_cond_init failed: err=%d"), rc); 763 763 764 764 #elif defined (WINDOWS32) … … 766 766 incdep_hev_todo = CreateEvent (NULL, TRUE /*bManualReset*/, FALSE /*bInitialState*/, NULL); 767 767 if (!incdep_hev_todo) 768 fatal (f, _("CreateEvent failed: err=%d"), GetLastError());768 ON (fatal, f, _("CreateEvent failed: err=%d"), GetLastError()); 769 769 incdep_hev_done = CreateEvent (NULL, TRUE /*bManualReset*/, FALSE /*bInitialState*/, NULL); 770 770 if (!incdep_hev_done) 771 fatal (f, _("CreateEvent failed: err=%d"), GetLastError());771 ON (fatal, f, _("CreateEvent failed: err=%d"), GetLastError()); 772 772 incdep_hev_todo_waiters = 0; 773 773 incdep_hev_done_waiters = 0; … … 777 777 rc = DosCreateEventSem (NULL, &incdep_hev_todo, 0, FALSE); 778 778 if (rc) 779 fatal (f, _("DosCreateEventSem failed: rc=%d"), rc);779 ON (fatal, f, _("DosCreateEventSem failed: rc=%d"), rc); 780 780 rc = DosCreateEventSem (NULL, &incdep_hev_done, 0, FALSE); 781 781 if (rc) 782 fatal (f, _("DosCreateEventSem failed: rc=%d"), rc);782 ON (fatal, f, _("DosCreateEventSem failed: rc=%d"), rc); 783 783 incdep_hev_todo_waiters = 0; 784 784 incdep_hev_done_waiters = 0; … … 827 827 rc = pthread_attr_init (&attr); 828 828 if (rc) 829 fatal (f, _("pthread_attr_init failed: err=%d"), rc);829 ON (fatal, f, _("pthread_attr_init failed: err=%d"), rc); 830 830 /*rc = pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_JOINABLE); */ 831 831 rc = pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); 832 832 if (rc) 833 fatal (f, _("pthread_attr_setdetachstate failed: err=%d"), rc);833 ON (fatal, f, _("pthread_attr_setdetachstate failed: err=%d"), rc); 834 834 rc = pthread_create (&incdep_threads[i], &attr, 835 835 incdep_worker_pthread, (void *)(size_t)i); 836 836 if (rc) 837 fatal (f, _("pthread_mutex_init failed: err=%d"), rc);837 ON (fatal, f, _("pthread_mutex_init failed: err=%d"), rc); 838 838 pthread_attr_destroy (&attr); 839 839 … … 843 843 (void *)i, 0, &tid); 844 844 if (hThread == 0 || hThread == ~(uintptr_t)0) 845 fatal (f, _("_beginthreadex failed: err=%d"), errno);845 ON (fatal, f, _("_beginthreadex failed: err=%d"), errno); 846 846 incdep_threads[i] = (HANDLE)hThread; 847 847 … … 849 849 tid = _beginthread (incdep_worker_os2, NULL, 128*1024, (void *)i); 850 850 if (tid <= 0) 851 fatal (f, _("_beginthread failed: err=%d"), errno);851 ON (fatal, f, _("_beginthread failed: err=%d"), errno); 852 852 incdep_threads[i] = tid; 853 853 #endif … … 927 927 if (cur->err_msg) 928 928 #ifdef INCDEP_USE_KFSCACHE 929 error(NILF, "%s/%s(%d): %s", cur->pFileObj->pParent->Obj.pszName, cur->pFileObj->pszName, cur->err_line_no, cur->err_msg); 929 OSSNS (error, NILF, "%s/%s(%d): %s", cur->pFileObj->pParent->Obj.pszName, cur->pFileObj->pszName, 930 cur->err_line_no, cur->err_msg); 930 931 #else 931 error(NILF, "%s(%d): %s", cur->name, cur->err_line_no, cur->err_msg);932 OSNS (error,NILF, "%s(%d): %s", cur->name, cur->err_line_no, cur->err_msg); 932 933 #endif 933 934 … … 1008 1009 if (cur->worker_tid == -1) 1009 1010 #ifdef INCDEP_USE_KFSCACHE 1010 error (NILF, "%s/%s(%d): %s", cur->pFileObj->pParent->Obj.pszName, cur->pFileObj->pszName, line_no, msg);1011 OSSNS (error,NILF, "%s/%s(%d): %s", cur->pFileObj->pParent->Obj.pszName, cur->pFileObj->pszName, line_no, msg); 1011 1012 #else 1012 error (NILF, "%s(%d): %s", cur->name, line_no, msg);1013 OSNS (error, NILF, "%s(%d): %s", cur->name, line_no, msg); 1013 1014 #endif 1014 1015 #ifdef PARSE_IN_WORKER … … 1079 1080 int recursive, 1080 1081 struct variable_set *set, 1081 const structfloc *flocp)1082 const floc *flocp) 1082 1083 { 1083 1084 assert (!duplicate_value); … … 1112 1113 static void 1113 1114 incdep_record_variable_def (struct incdep *cur, 1114 const structfloc *flocp,1115 const floc *flocp, 1115 1116 const char *name, 1116 1117 unsigned int name_length, … … 1152 1153 static void 1153 1154 incdep_commit_recorded_file (const char *filename, struct dep *deps, 1154 const structfloc *flocp)1155 const floc *flocp) 1155 1156 { 1156 1157 struct file *f; … … 1174 1175 ) 1175 1176 { 1176 error (flocp, _("reserved filename '%s' used in dependency file, ignored"), filename);1177 OS (error, flocp, _("reserved filename '%s' used in dependency file, ignored"), filename); 1177 1178 return; 1178 1179 } … … 1182 1183 if (f->double_colon) 1183 1184 { 1184 error (flocp, _("dependency file '%s' has a double colon entry already, ignoring"), filename);1185 OS (error, flocp, _("dependency file '%s' has a double colon entry already, ignoring"), filename); 1185 1186 return; 1186 1187 } … … 1208 1209 const char *filename, 1209 1210 struct dep *deps, 1210 const structfloc *flocp)1211 const floc *flocp) 1211 1212 { 1212 1213 if (cur->worker_tid == -1) … … 1253 1254 */ 1254 1255 static void 1255 eval_include_dep_file (struct incdep *curdep, structfloc *f)1256 eval_include_dep_file (struct incdep *curdep, floc *f) 1256 1257 { 1257 1258 unsigned line_no = 1; … … 1268 1269 { 1269 1270 /* skip empty lines */ 1270 while (cur < file_end && isspace ((unsigned char)*cur) && *cur != '\n')1271 while (cur < file_end && ISSPACE (*cur) && *cur != '\n') 1271 1272 ++cur; 1272 1273 if (cur >= file_end) … … 1312 1313 /* extract the variable name. */ 1313 1314 cur += 7; 1314 while ( isblank ((unsigned char)*cur))1315 while (ISBLANK (*cur)) 1315 1316 ++cur; 1316 1317 value_start = endp = memchr (cur, '\n', file_end - cur); 1317 1318 if (!endp) 1318 1319 endp = cur; 1319 while (endp > cur && isspace ((unsigned char)endp[-1]))1320 while (endp > cur && ISSPACE (endp[-1])) 1320 1321 --endp; 1321 1322 var_len = endp - cur; … … 1337 1338 { 1338 1339 endp = cur + 5; 1339 while (endp < file_end && isspace ((unsigned char)*endp) && *endp != '\n')1340 while (endp < file_end && ISSPACE (*endp) && *endp != '\n') 1340 1341 endp++; 1341 1342 if (endp >= file_end || *endp == '\n') … … 1448 1449 /* extract the variable name. */ 1449 1450 endp = flavor == f_recursive ? equalp : equalp - 1; 1450 while (endp > cur && isblank ((unsigned char)endp[-1]))1451 while (endp > cur && ISBLANK (endp[-1])) 1451 1452 --endp; 1452 1453 var_len = endp - cur; … … 1467 1468 /* find the start of the value. */ 1468 1469 cur = equalp + 1; 1469 while (cur < file_end && isblank ((unsigned char)*cur))1470 while (cur < file_end && ISBLANK (*cur)) 1470 1471 cur++; 1471 1472 value_start = cur; … … 1629 1630 /* Extract the first filename after trimming and basic checks. */ 1630 1631 fnend = colonp; 1631 while ((uintptr_t)fnend > (uintptr_t)cur && isblank ((unsigned char)fnend[-1]))1632 while ((uintptr_t)fnend > (uintptr_t)cur && ISBLANK (fnend[-1])) 1632 1633 --fnend; 1633 1634 if (cur == fnend) … … 1643 1644 1644 1645 fnnext = cur; 1645 while (fnnext != fnend && ! isblank ((unsigned char)*fnnext))1646 while (fnnext != fnend && !ISBLANK (*fnnext)) 1646 1647 fnnext++; 1647 1648 filename = incdep_dep_strcache (curdep, cur, fnnext - cur); … … 1652 1653 { 1653 1654 /* skip blanks and count lines. */ 1654 while (cur < file_end && isspace ((unsigned char)*cur) && *cur != '\n')1655 while (cur < file_end && ISSPACE (*cur) && *cur != '\n') 1655 1656 ++cur; 1656 1657 if (cur >= file_end) … … 1679 1680 /* find the end of the filename */ 1680 1681 endp = cur; 1681 while (endp < file_end && ! isspace ((unsigned char)*endp))1682 while (endp < file_end && !ISSPACE (*endp)) 1682 1683 ++endp; 1683 1684 … … 1700 1701 const char *filename_prev = filename; 1701 1702 const char *fnstart; 1702 while (fnnext != fnend && isblank ((unsigned char)*fnnext))1703 while (fnnext != fnend && ISBLANK (*fnnext)) 1703 1704 fnnext++; 1704 1705 if (fnnext == fnend) … … 1706 1707 1707 1708 fnstart = fnnext; 1708 while (fnnext != fnend && ! isblank ((unsigned char)*fnnext))1709 while (fnnext != fnend && !ISBLANK (*fnnext)) 1709 1710 fnnext++; 1710 1711 … … 1724 1725 /* Flushes the incdep todo and done lists. */ 1725 1726 static void 1726 incdep_flush_it ( structfloc *f)1727 incdep_flush_it (floc *f) 1727 1728 { 1728 1729 incdep_lock (); … … 1785 1786 employing threads to try speed up the file reading. */ 1786 1787 void 1787 eval_include_dep (const char *names, structfloc *f, enum incdep_op op)1788 eval_include_dep (const char *names, floc *f, enum incdep_op op) 1788 1789 { 1789 1790 struct incdep *head = 0;
Note:
See TracChangeset
for help on using the changeset viewer.