diff options
Diffstat (limited to 'scripts/basic')
-rw-r--r-- | scripts/basic/docproc.c | 15 | ||||
-rw-r--r-- | scripts/basic/fixdep.c | 68 | ||||
-rw-r--r-- | scripts/basic/split-include.c | 13 |
3 files changed, 88 insertions, 8 deletions
diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c index 720098a23..bfc1a9844 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 | */ |
79 | void exec_kernel_doc(char **svec) | 81 | void 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 19f82df09..9f461a65b 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 <unistd.h> | 110 | #include <unistd.h> |
109 | #include <fcntl.h> | 111 | #include <fcntl.h> |
110 | #include <string.h> | 112 | #include <string.h> |
@@ -112,7 +114,9 @@ | |||
112 | #include <stdio.h> | 114 | #include <stdio.h> |
113 | #include <limits.h> | 115 | #include <limits.h> |
114 | #include <ctype.h> | 116 | #include <ctype.h> |
117 | #ifndef __MINGW32__ | ||
115 | #include <arpa/inet.h> | 118 | #include <arpa/inet.h> |
119 | #endif | ||
116 | //bbox disabled: #include <alloca.h> | 120 | //bbox disabled: #include <alloca.h> |
117 | 121 | ||
118 | /* bbox: not needed | 122 | /* bbox: not needed |
@@ -122,6 +126,57 @@ | |||
122 | #define INT_FIG_ ntohl(0x4649475f) | 126 | #define INT_FIG_ ntohl(0x4649475f) |
123 | */ | 127 | */ |
124 | 128 | ||
129 | #ifndef O_BINARY | ||
130 | #define O_BINARY 0 | ||
131 | #endif | ||
132 | |||
133 | #ifdef __MINGW32__ | ||
134 | #define UNUSED __attribute__ ((__unused__)) | ||
135 | |||
136 | /* Workaround specifically for fixdep */ | ||
137 | #define PROT_READ 0 | ||
138 | #define MAP_PRIVATE 0 | ||
139 | void *mmap(void *start UNUSED, size_t size, int prot UNUSED, | ||
140 | int flags UNUSED, int fd, off_t offset UNUSED) | ||
141 | { | ||
142 | void *p; | ||
143 | void *curP; | ||
144 | ssize_t readB; | ||
145 | |||
146 | p = malloc(size); | ||
147 | if (!p) | ||
148 | return (void*)((long)-1); | ||
149 | |||
150 | curP = p; | ||
151 | |||
152 | while (size > 0) | ||
153 | { | ||
154 | readB = read(fd, curP, size); | ||
155 | |||
156 | if (readB == 0) | ||
157 | { | ||
158 | /* EOF reached */ | ||
159 | break; | ||
160 | } | ||
161 | else if (readB < 0) | ||
162 | { | ||
163 | perror("fixdep: read config"); | ||
164 | free(p); | ||
165 | return (void*)((long)-1); | ||
166 | } | ||
167 | |||
168 | size -= readB; | ||
169 | curP += readB; | ||
170 | } | ||
171 | |||
172 | return p; | ||
173 | } | ||
174 | void munmap(void *p, size_t size UNUSED) | ||
175 | { | ||
176 | free(p); | ||
177 | } | ||
178 | #endif | ||
179 | |||
125 | char *target; | 180 | char *target; |
126 | char *depfile; | 181 | char *depfile; |
127 | char *cmdline; | 182 | char *cmdline; |
@@ -286,7 +341,7 @@ void do_config_file(char *filename) | |||
286 | int fd; | 341 | int fd; |
287 | void *map; | 342 | void *map; |
288 | 343 | ||
289 | fd = open(filename, O_RDONLY); | 344 | fd = open(filename, O_RDONLY | O_BINARY); |
290 | if (fd < 0) { | 345 | if (fd < 0) { |
291 | fprintf(stderr, "fixdep: "); | 346 | fprintf(stderr, "fixdep: "); |
292 | perror(filename); | 347 | perror(filename); |
@@ -298,7 +353,7 @@ void do_config_file(char *filename) | |||
298 | return; | 353 | return; |
299 | } | 354 | } |
300 | map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); | 355 | map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); |
301 | if ((long) map == -1) { | 356 | if ((intptr_t) map == -1) { |
302 | perror("fixdep: mmap"); | 357 | perror("fixdep: mmap"); |
303 | close(fd); | 358 | close(fd); |
304 | return; | 359 | return; |
@@ -334,10 +389,12 @@ void parse_dep_file(void *map, size_t len) | |||
334 | m++; | 389 | m++; |
335 | p = m; | 390 | p = m; |
336 | while (p < end && *p != ' ') p++; | 391 | while (p < end && *p != ' ') p++; |
392 | if (p == m) break; | ||
337 | if (p == end) { | 393 | if (p == end) { |
338 | do p--; while (!isalnum(*p)); | 394 | do p--; while (p != m && !isalnum(*p)); |
339 | p++; | 395 | p++; |
340 | } | 396 | } |
397 | if (p == m) break; | ||
341 | memcpy(s, m, p-m); s[p-m] = 0; | 398 | memcpy(s, m, p-m); s[p-m] = 0; |
342 | if (strrcmp(s, "include/autoconf.h") && | 399 | if (strrcmp(s, "include/autoconf.h") && |
343 | strrcmp(s, "arch/um/include/uml-config.h") && | 400 | strrcmp(s, "arch/um/include/uml-config.h") && |
@@ -345,6 +402,7 @@ void parse_dep_file(void *map, size_t len) | |||
345 | printf(" %s \\\n", s); | 402 | printf(" %s \\\n", s); |
346 | do_config_file(s); | 403 | do_config_file(s); |
347 | } | 404 | } |
405 | if (p == end) break; | ||
348 | m = p + 1; | 406 | m = p + 1; |
349 | } | 407 | } |
350 | printf("\n%s: $(deps_%s)\n\n", target, target); | 408 | printf("\n%s: $(deps_%s)\n\n", target, target); |
@@ -357,7 +415,7 @@ void print_deps(void) | |||
357 | int fd; | 415 | int fd; |
358 | void *map; | 416 | void *map; |
359 | 417 | ||
360 | fd = open(depfile, O_RDONLY); | 418 | fd = open(depfile, O_RDONLY | O_BINARY); |
361 | if (fd < 0) { | 419 | if (fd < 0) { |
362 | fprintf(stderr, "fixdep: "); | 420 | fprintf(stderr, "fixdep: "); |
363 | perror(depfile); | 421 | perror(depfile); |
@@ -370,7 +428,7 @@ void print_deps(void) | |||
370 | return; | 428 | return; |
371 | } | 429 | } |
372 | map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); | 430 | map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); |
373 | if ((long) map == -1) { | 431 | if ((intptr_t) map == -1) { |
374 | perror("fixdep: mmap"); | 432 | perror("fixdep: mmap"); |
375 | close(fd); | 433 | close(fd); |
376 | return; | 434 | return; |
diff --git a/scripts/basic/split-include.c b/scripts/basic/split-include.c index e328788e2..8127fe261 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 | |||
44 | int main(int argc, const char * argv []) | 42 | int 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 | ||
@@ -148,7 +150,12 @@ int main(int argc, const char * argv []) | |||
148 | { | 150 | { |
149 | ptarget[islash] = '\0'; | 151 | ptarget[islash] = '\0'; |
150 | if (stat(ptarget, &stat_buf) != 0 | 152 | if (stat(ptarget, &stat_buf) != 0 |
151 | && mkdir(ptarget, 0755) != 0) | 153 | #ifdef __MINGW32__ |
154 | && mkdir(ptarget) != 0 | ||
155 | #else | ||
156 | && mkdir(ptarget, 0755) != 0 | ||
157 | #endif | ||
158 | ) | ||
152 | ERROR_EXIT( ptarget ); | 159 | ERROR_EXIT( ptarget ); |
153 | ptarget[islash] = '/'; | 160 | ptarget[islash] = '/'; |
154 | } | 161 | } |