aboutsummaryrefslogtreecommitdiff
path: root/scripts/basic
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/basic')
-rw-r--r--scripts/basic/.gitignore3
-rw-r--r--scripts/basic/docproc.c15
-rw-r--r--scripts/basic/fixdep.c67
-rw-r--r--scripts/basic/split-include.c24
4 files changed, 101 insertions, 8 deletions
diff --git a/scripts/basic/.gitignore b/scripts/basic/.gitignore
index d91e941a4..3d20e4f15 100644
--- a/scripts/basic/.gitignore
+++ b/scripts/basic/.gitignore
@@ -2,3 +2,6 @@ hash
2fixdep 2fixdep
3docproc 3docproc
4split-include 4split-include
5/docproc.exe
6/fixdep.exe
7/split-include.exe
diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c
index 8828901a1..c488cd53e 100644
--- a/scripts/basic/docproc.c
+++ b/scripts/basic/docproc.c
@@ -38,7 +38,9 @@
38#include <unistd.h> 38#include <unistd.h>
39#include <limits.h> 39#include <limits.h>
40#include <sys/types.h> 40#include <sys/types.h>
41#ifndef __MINGW32__
41#include <sys/wait.h> 42#include <sys/wait.h>
43#endif
42//bbox disabled: #include <alloca.h> 44//bbox disabled: #include <alloca.h>
43 45
44/* exitstatus is used to keep track of any failing calls to kernel-doc, 46/* exitstatus is used to keep track of any failing calls to kernel-doc,
@@ -78,12 +80,24 @@ void usage (void)
78 */ 80 */
79void exec_kernel_doc(char **svec) 81void exec_kernel_doc(char **svec)
80{ 82{
83#ifndef __MINGW32__
81 pid_t pid; 84 pid_t pid;
82 int ret; 85 int ret;
86#endif
83 char *real_filename; 87 char *real_filename;
84 int rflen; 88 int rflen;
85 89
86 /* Make sure output generated so far are flushed */ 90 /* Make sure output generated so far are flushed */
91#ifdef __MINGW32__
92 fflush(stdout);
93 rflen = strlen(getenv("SRCTREE"));
94 rflen += strlen(KERNELDOCPATH KERNELDOC);
95 real_filename = alloca(rflen + 1);
96 strcpy(real_filename, getenv("SRCTREE"));
97 strcat(real_filename, KERNELDOCPATH KERNELDOC);
98 fprintf(stderr, "NOTIMPL: exec %s\n", real_filename);
99 exit(1);
100#else
87 fflush(stdout); 101 fflush(stdout);
88 switch(pid=fork()) { 102 switch(pid=fork()) {
89 case -1: 103 case -1:
@@ -106,6 +120,7 @@ void exec_kernel_doc(char **svec)
106 exitstatus |= WEXITSTATUS(ret); 120 exitstatus |= WEXITSTATUS(ret);
107 else 121 else
108 exitstatus = 0xff; 122 exitstatus = 0xff;
123#endif
109} 124}
110 125
111/* Types used to create list of all exported symbols in a number of files */ 126/* Types used to create list of all exported symbols in a number of files */
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index 071c3b407..47a0cee07 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -104,7 +104,9 @@
104 104
105#include <sys/types.h> 105#include <sys/types.h>
106#include <sys/stat.h> 106#include <sys/stat.h>
107#ifndef __MINGW32__
107#include <sys/mman.h> 108#include <sys/mman.h>
109#endif
108#include <errno.h> 110#include <errno.h>
109#include <unistd.h> 111#include <unistd.h>
110#include <fcntl.h> 112#include <fcntl.h>
@@ -113,7 +115,9 @@
113#include <stdio.h> 115#include <stdio.h>
114#include <limits.h> 116#include <limits.h>
115#include <ctype.h> 117#include <ctype.h>
118#ifndef __MINGW32__
116#include <arpa/inet.h> 119#include <arpa/inet.h>
120#endif
117//bbox disabled: #include <alloca.h> 121//bbox disabled: #include <alloca.h>
118 122
119/* bbox: not needed 123/* bbox: not needed
@@ -123,6 +127,57 @@
123#define INT_FIG_ ntohl(0x4649475f) 127#define INT_FIG_ ntohl(0x4649475f)
124*/ 128*/
125 129
130#ifndef O_BINARY
131#define O_BINARY 0
132#endif
133
134#ifdef __MINGW32__
135#define UNUSED __attribute__ ((__unused__))
136
137/* Workaround specifically for fixdep */
138#define PROT_READ 0
139#define MAP_PRIVATE 0
140void *mmap(void *start UNUSED, size_t size, int prot UNUSED,
141 int flags UNUSED, int fd, off_t offset UNUSED)
142{
143 void *p;
144 void *curP;
145 ssize_t readB;
146
147 p = malloc(size);
148 if (!p)
149 return (void*)((long)-1);
150
151 curP = p;
152
153 while (size > 0)
154 {
155 readB = read(fd, curP, size);
156
157 if (readB == 0)
158 {
159 /* EOF reached */
160 break;
161 }
162 else if (readB < 0)
163 {
164 perror("fixdep: read config");
165 free(p);
166 return (void*)((long)-1);
167 }
168
169 size -= readB;
170 curP += readB;
171 }
172
173 return p;
174}
175void munmap(void *p, size_t size UNUSED)
176{
177 free(p);
178}
179#endif
180
126char *target; 181char *target;
127char *depfile; 182char *depfile;
128char *cmdline; 183char *cmdline;
@@ -287,7 +342,7 @@ void do_config_file(char *filename)
287 int fd; 342 int fd;
288 void *map; 343 void *map;
289 344
290 fd = open(filename, O_RDONLY); 345 fd = open(filename, O_RDONLY | O_BINARY);
291 if (fd < 0) { 346 if (fd < 0) {
292 fprintf(stderr, "fixdep: "); 347 fprintf(stderr, "fixdep: ");
293 perror(filename); 348 perror(filename);
@@ -302,7 +357,7 @@ void do_config_file(char *filename)
302 return; 357 return;
303 } 358 }
304 map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); 359 map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
305 if ((long) map == -1) { 360 if ((intptr_t) map == -1) {
306 perror("fixdep: mmap"); 361 perror("fixdep: mmap");
307 close(fd); 362 close(fd);
308 return; 363 return;
@@ -338,8 +393,9 @@ void parse_dep_file(void *map, size_t len)
338 m++; 393 m++;
339 p = m; 394 p = m;
340 while (p < end && *p != ' ') p++; 395 while (p < end && *p != ' ') p++;
396 if (p == m) break;
341 if (p == end) { 397 if (p == end) {
342 do p--; while (!isalnum((unsigned char)*p)); 398 do p--; while (p != m && !isalnum((unsigned char)*p));
343 p++; 399 p++;
344 } 400 }
345 if (p < m) { 401 if (p < m) {
@@ -354,6 +410,7 @@ void parse_dep_file(void *map, size_t len)
354 printf(" %s \\\n", s); 410 printf(" %s \\\n", s);
355 do_config_file(s); 411 do_config_file(s);
356 } 412 }
413 if (p == end) break;
357 m = p + 1; 414 m = p + 1;
358 } 415 }
359 printf("\n%s: $(deps_%s)\n\n", target, target); 416 printf("\n%s: $(deps_%s)\n\n", target, target);
@@ -366,7 +423,7 @@ void print_deps(void)
366 int fd; 423 int fd;
367 void *map; 424 void *map;
368 425
369 fd = open(depfile, O_RDONLY); 426 fd = open(depfile, O_RDONLY | O_BINARY);
370 if (fd < 0) { 427 if (fd < 0) {
371 fprintf(stderr, "fixdep: "); 428 fprintf(stderr, "fixdep: ");
372 perror(depfile); 429 perror(depfile);
@@ -382,7 +439,7 @@ void print_deps(void)
382 return; 439 return;
383 } 440 }
384 map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); 441 map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
385 if ((long) map == -1) { 442 if ((intptr_t) map == -1) {
386 perror("fixdep: mmap"); 443 perror("fixdep: mmap");
387 close(fd); 444 close(fd);
388 return; 445 return;
diff --git a/scripts/basic/split-include.c b/scripts/basic/split-include.c
index 6ef29195e..a85ede8ef 100644
--- a/scripts/basic/split-include.c
+++ b/scripts/basic/split-include.c
@@ -39,8 +39,6 @@
39 exit(1); \ 39 exit(1); \
40 } 40 }
41 41
42
43
44int main(int argc, const char * argv []) 42int main(int argc, const char * argv [])
45{ 43{
46 const char * str_my_name; 44 const char * str_my_name;
@@ -89,7 +87,11 @@ int main(int argc, const char * argv [])
89 /* Make output directory if needed. */ 87 /* Make output directory if needed. */
90 if (stat(str_dir_config, &stat_buf) != 0) 88 if (stat(str_dir_config, &stat_buf) != 0)
91 { 89 {
90#ifdef __MINGW32__
91 if (mkdir(str_dir_config) != 0)
92#else
92 if (mkdir(str_dir_config, 0755) != 0) 93 if (mkdir(str_dir_config, 0755) != 0)
94#endif
93 ERROR_EXIT(str_dir_config); 95 ERROR_EXIT(str_dir_config);
94 } 96 }
95 97
@@ -149,7 +151,12 @@ int main(int argc, const char * argv [])
149 { 151 {
150 ptarget[islash] = '\0'; 152 ptarget[islash] = '\0';
151 if (stat(ptarget, &stat_buf) != 0 153 if (stat(ptarget, &stat_buf) != 0
152 && mkdir(ptarget, 0755) != 0) 154#ifdef __MINGW32__
155 && mkdir(ptarget) != 0
156#else
157 && mkdir(ptarget, 0755) != 0
158#endif
159 )
153 ERROR_EXIT( ptarget ); 160 ERROR_EXIT( ptarget );
154 ptarget[islash] = '/'; 161 ptarget[islash] = '/';
155 } 162 }
@@ -190,13 +197,21 @@ int main(int argc, const char * argv [])
190 * So by having an initial \n, strstr will find exact matches. 197 * So by having an initial \n, strstr will find exact matches.
191 */ 198 */
192 199
200#ifdef __MINGW32__
201 fp_find = popen("find . -type f -name \"*.h\" -print", "r");
202#else
193 fp_find = popen("find * -type f -name \"*.h\" -print", "r"); 203 fp_find = popen("find * -type f -name \"*.h\" -print", "r");
204#endif
194 if (fp_find == 0) 205 if (fp_find == 0)
195 ERROR_EXIT( "find" ); 206 ERROR_EXIT( "find" );
196 207
197 line[0] = '\n'; 208 line[0] = '\n';
198 while (fgets(line+1, buffer_size, fp_find)) 209 while (fgets(line+1, buffer_size, fp_find))
199 { 210 {
211#ifdef __MINGW32__
212 line[2] = '\n';
213# define line (line + 2)
214#endif
200 if (strstr(list_target, line) == NULL) 215 if (strstr(list_target, line) == NULL)
201 { 216 {
202 /* 217 /*
@@ -219,6 +234,9 @@ int main(int argc, const char * argv [])
219 ERROR_EXIT(line); 234 ERROR_EXIT(line);
220 } 235 }
221 } 236 }
237#ifdef __MINGW32__
238# undef line
239#endif
222 } 240 }
223 241
224 if (pclose(fp_find) != 0) 242 if (pclose(fp_find) != 0)