shithub: mc

Download patch

ref: a437a46fa4c9a7fabe9675d6a121cd152e4b86a4
parent: 545ac708bc6fbae20d8ce00ad93378cb8bb0d28f
author: Ori Bernstein <[email protected]>
date: Tue Jun 5 16:52:52 EDT 2012

Add platform specific mangling. Oy.

    OSX wants an _ in front of it's functions. Put it there.

--- /dev/null
+++ b/8/platform.h
@@ -1,0 +1,5 @@
+#if defined(__APPLE__) && defined(__MACH__)
+#define Fprefix "_"
+#else
+#define Fprefix ""
+#endif
--- a/8/simp.c
+++ b/8/simp.c
@@ -13,6 +13,8 @@
 #include "gen.h"
 #include "asm.h"
 
+#include "platform.h" /* HACK. We need some platform specific code gen behavior. *sigh.* */
+
 static void lowerglobl(Comp *c, char *name, Node *init);
 static void lowerfn(Comp *c, char *name, Node *n);
 
@@ -45,12 +47,13 @@
     char *sep;
     int len;
 
+    len += strlen(Fprefix);
     for (i = 0; i < n->name.nparts; i++)
         len += strlen(n->name.parts[i]) + 1;
 
     s = xalloc(len);
     s[0] = '\0';
-    sep = "";
+    sep = Fprefix;
     for (i = 0; i < n->name.nparts; i++) {
         sprintf(s, "%s%s", sep, n->name.parts[i]);
         sep = "$";