Created
June 12, 2012 13:12
-
-
Save 7shi/2917419 to your computer and use it in GitHub Desktop.
MinGWでodcctoolsの一部(アーキ依存as)をビルドするためのパッチ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -Nur odcctools.orig/as/as.c odcctools/as/as.c | |
--- odcctools.orig/as/as.c 2012-06-07 21:55:08 +0900 | |
+++ odcctools/as/as.c 2012-06-12 21:58:11 +0900 | |
@@ -84,7 +84,11 @@ | |
/* | |
* The list of signals to catch if not ignored. | |
*/ | |
+#ifndef WIN32 | |
static int sig[] = { SIGHUP, SIGINT, SIGPIPE, SIGTERM, 0}; | |
+#else | |
+static int sig[] = { SIGINT, SIGTERM, 0}; | |
+#endif | |
static void got_sig( | |
int sig); | |
diff -Nur odcctools.orig/as/input-file.c odcctools/as/input-file.c | |
--- odcctools.orig/as/input-file.c 2012-06-07 21:55:08 +0900 | |
+++ odcctools/as/input-file.c 2012-06-12 21:58:11 +0900 | |
@@ -41,6 +41,10 @@ | |
#include <config.h> | |
#endif | |
+#ifdef WIN32 | |
+#define index strchr | |
+#endif | |
+ | |
/* | |
* This variable is non-zero if the file currently being read should be | |
* preprocessed by app. It is zero if the file can be read straight in. | |
@@ -125,11 +129,13 @@ | |
as_perror ("Can't open source file for input", file_name); | |
return; | |
} | |
+#ifndef WIN32 | |
#ifdef NeXT_MOD /* .include feature */ | |
setbuffer(f_in, xmalloc(BUFFER_SIZE), BUFFER_SIZE); | |
#else | |
setbuffer(f_in,in_buf,BUFFER_SIZE); | |
#endif | |
+#endif | |
c=getc_unlocked(f_in); | |
if(c=='#') { /* Begins with comment, may not want to preprocess */ | |
c=getc_unlocked(f_in); | |
diff -Nur odcctools.orig/as/input-scrub.c odcctools/as/input-scrub.c | |
--- odcctools.orig/as/input-scrub.c 2012-06-07 21:55:07 +0900 | |
+++ odcctools/as/input-scrub.c 2012-06-12 21:58:11 +0900 | |
@@ -338,7 +338,11 @@ | |
char *p, *q; | |
static char directory_buf[MAXPATHLEN]; | |
+#ifndef WIN32 | |
getwd(directory_buf); | |
+#else | |
+ getcwd(directory_buf, sizeof(directory_buf)); | |
+#endif | |
*fileName = NULL; | |
*directory = directory_buf; | |
*line = 0; | |
diff -Nur odcctools.orig/as/read.c odcctools/as/read.c | |
--- odcctools.orig/as/read.c 2012-06-07 21:55:07 +0900 | |
+++ odcctools/as/read.c 2012-06-12 21:58:28 +0900 | |
@@ -4223,11 +4223,21 @@ | |
arg->name = malloc(len + 1); | |
strncpy(arg->name, ptr, len); | |
arg->name[len] = '\0'; | |
+#ifndef WIN32 | |
arg->default_value = arg->name; | |
strsep(&(arg->default_value), "="); | |
if (!(arg->default_value)) | |
arg->default_value = ""; | |
+#else | |
+ arg->default_value = strchr(arg->name, '='); | |
+ if (!(arg->default_value)) | |
+ arg->default_value = ""; | |
+ else{ | |
+ *arg->default_value = '\0'; | |
+ arg->default_value++; | |
+ } | |
+#endif | |
macro_info->args[(macro_info->arg_count)++] = arg; | |
} | |
diff -Nur odcctools.orig/as/symbols.c odcctools/as/symbols.c | |
--- odcctools.orig/as/symbols.c 2012-06-07 21:55:08 +0900 | |
+++ odcctools/as/symbols.c 2012-06-12 21:58:11 +0900 | |
@@ -35,6 +35,10 @@ | |
#define LOCAL_LABEL_MAX 256 | |
+#ifdef WIN32 | |
+#define bcopy(a, b, c) memmove(b, a, c) | |
+#endif | |
+ | |
/* symbol-name => struct symbol pointer */ | |
struct hash_control *sy_hash = NULL; | |
diff -Nur odcctools.orig/include/sys/cdefs.h odcctools/include/sys/cdefs.h | |
--- odcctools.orig/include/sys/cdefs.h 1970-01-01 09:00:00 +0900 | |
+++ odcctools/include/sys/cdefs.h 2012-06-12 21:58:11 +0900 | |
@@ -0,0 +1,18 @@ | |
+#ifndef _SYS_CDEFS_H_ | |
+#define _SYS_CDEFS_H_ | |
+ | |
+#ifdef __cplusplus | |
+#define __BEGIN_DECLS extern "C" { | |
+#define __END_DECLS } | |
+#else | |
+#define __BEGIN_DECLS | |
+#define __END_DECLS | |
+#endif | |
+ | |
+typedef unsigned char u_char; | |
+typedef unsigned short u_short; | |
+typedef unsigned short u_int16_t; | |
+typedef unsigned int u_int; | |
+typedef unsigned int u_int32_t; | |
+ | |
+#endif | |
diff -Nur odcctools.orig/libstuff/SymLoc.c odcctools/libstuff/SymLoc.c | |
--- odcctools.orig/libstuff/SymLoc.c 2012-06-07 21:55:22 +0900 | |
+++ odcctools/libstuff/SymLoc.c 2012-06-12 21:58:11 +0900 | |
@@ -28,7 +28,11 @@ | |
#define _POSIX_SOURCE | |
#endif | |
#include <dirent.h> | |
+#ifndef WIN32 | |
#include <pwd.h> | |
+#else | |
+#define MAXNAMLEN 32 | |
+#endif | |
#include "stuff/bool.h" | |
#include "stuff/errors.h" | |
#include "stuff/allocate.h" | |
@@ -83,6 +87,7 @@ | |
return NULL; | |
} | |
+#ifndef WIN32 | |
// find ~rc's home directory | |
if (!(passwd = getpwnam("rc"))) { | |
system_error("symLocForDylib(): getpwnam(\"rc\") returns NULL"); | |
@@ -178,6 +183,7 @@ | |
} | |
if(closedir(dirp) != 0) | |
system_error("closedir() failed"); | |
+#endif | |
// process return value | |
if (!c) { | |
diff -Nur odcctools.orig/libstuff/crc32.c odcctools/libstuff/crc32.c | |
--- odcctools.orig/libstuff/crc32.c 2012-06-07 21:55:22 +0900 | |
+++ odcctools/libstuff/crc32.c 2012-06-12 21:58:11 +0900 | |
@@ -56,6 +56,9 @@ | |
* SUCH DAMAGE. | |
*/ | |
#include <sys/types.h> | |
+#ifdef WIN32 | |
+#include <sys/cdefs.h> | |
+#endif | |
static const u_int32_t crctab[] = { | |
0x0, | |
diff -Nur odcctools.orig/libstuff/dylib_roots.c odcctools/libstuff/dylib_roots.c | |
--- odcctools.orig/libstuff/dylib_roots.c 2012-06-07 21:55:22 +0900 | |
+++ odcctools/libstuff/dylib_roots.c 2012-06-12 21:58:11 +0900 | |
@@ -28,10 +28,12 @@ | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <sys/param.h> | |
+#ifndef WIN32 | |
#ifndef __OPENSTEP__ | |
#include <fts.h> | |
#endif | |
#include <sys/errno.h> | |
+#endif | |
#include "stuff/bool.h" | |
#include "stuff/SymLoc.h" | |
#include "stuff/ofile.h" | |
@@ -115,7 +117,7 @@ | |
char *install_name, | |
const char *root) | |
{ | |
-#ifndef __OPENSTEP__ | |
+#if !defined(__OPENSTEP__) && !defined(WIN32) | |
char *base_name, start[MAXPATHLEN + 1], *image_file_name; | |
char const *paths[2]; | |
FTS *fts; | |
diff -Nur odcctools.orig/libstuff/emulated.c odcctools/libstuff/emulated.c | |
--- odcctools.orig/libstuff/emulated.c 2012-06-07 21:55:22 +0900 | |
+++ odcctools/libstuff/emulated.c 2012-06-12 21:58:11 +0900 | |
@@ -6,7 +6,9 @@ | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <sys/types.h> | |
+#ifndef WIN32 | |
#include <sys/mman.h> | |
+#endif | |
#include <sys/attr.h> | |
#include <errno.h> | |
@@ -95,12 +97,16 @@ | |
void *addr = NULL; | |
+#ifndef WIN32 | |
addr = mmap(0, size, PROT_READ|PROT_WRITE, | |
MAP_PRIVATE|MAP_FILE, fd, offset); | |
if(addr == (void *)-1) { | |
return 1; | |
} | |
+#else | |
+ return 1; | |
+#endif | |
*va = (vm_offset_t)addr; | |
diff -Nur odcctools.orig/libstuff/execute.c odcctools/libstuff/execute.c | |
--- odcctools.orig/libstuff/execute.c 2012-06-07 21:55:22 +0900 | |
+++ odcctools/libstuff/execute.c 2012-06-12 21:58:11 +0900 | |
@@ -25,7 +25,9 @@ | |
#include <mach/mach.h> /* first to get rid of pre-comp warning */ | |
#include "stdio.h" | |
#include <signal.h> | |
+#ifndef WIN32 | |
#include <sys/wait.h> | |
+#endif | |
#include "stuff/errors.h" | |
#include "stuff/allocate.h" | |
#include "stuff/execute.h" | |
diff -Nur odcctools.orig/libstuff/writeout.c odcctools/libstuff/writeout.c | |
--- odcctools.orig/libstuff/writeout.c 2012-06-07 21:55:22 +0900 | |
+++ odcctools/libstuff/writeout.c 2012-06-12 21:58:11 +0900 | |
@@ -139,9 +139,11 @@ | |
* of the unlink() is ignored). | |
*/ | |
(void)unlink(output); | |
+#ifndef WIN32 | |
if(throttle != NULL) | |
fsync = O_FSYNC; | |
else | |
+#endif | |
fsync = 0; | |
if(output != NULL){ | |
if((fd = open(output, O_WRONLY|O_CREAT|O_TRUNC|fsync, mode)) == -1){ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment