[93303] trunk/base/src/machista1.0

jmr at macports.org jmr at macports.org
Sat May 19 06:18:14 PDT 2012


Revision: 93303
          https://trac.macports.org/changeset/93303
Author:   jmr at macports.org
Date:     2012-05-19 06:18:14 -0700 (Sat, 19 May 2012)
Log Message:
-----------
guard use of mach-o headers

Modified Paths:
--------------
    trunk/base/src/machista1.0/libmachista.c
    trunk/base/src/machista1.0/libmachista.h
    trunk/base/src/machista1.0/machista.i
    trunk/base/src/machista1.0/machista_wrap.c
    trunk/base/src/machista1.0/tests/libmachista-test.c

Modified: trunk/base/src/machista1.0/libmachista.c
===================================================================
--- trunk/base/src/machista1.0/libmachista.c	2012-05-19 13:13:29 UTC (rev 93302)
+++ trunk/base/src/machista1.0/libmachista.c	2012-05-19 13:18:14 UTC (rev 93303)
@@ -42,14 +42,17 @@
 #include <err.h>
 #include <string.h>
 
+#ifdef __MACH__
 #include <mach-o/fat.h>
 #include <mach-o/loader.h>
 
 #include <libkern/OSAtomic.h>
+#endif
 
 #include "libmachista.h"
 #include "hashmap.h"
 
+#ifdef __MACH__
 /* Tiger compatibility */
 #ifndef LC_RPATH
 #define LC_RPATH       (0x1c | LC_REQ_DYLD)    /* runpath additions */
@@ -66,6 +69,7 @@
 #ifndef LC_REEXPORT_DYLIB
 #define LC_REEXPORT_DYLIB (0x1f | LC_REQ_DYLD) /* load and re-export dylib */
 #endif
+#endif /* __MACH__ */
 
 typedef struct macho_input {
     const void *data;
@@ -101,11 +105,15 @@
 }
 
 const char *macho_get_arch_name (cpu_type_t cputype) {
+#ifdef __MACH__
     const NXArchInfo *archInfo = NXGetArchInfoFromCpuType(cputype, CPU_SUBTYPE_MULTIPLE);	
     if (!archInfo) {
         return NULL;
     }
     return archInfo->name;
+#else
+    return NULL;
+#endif
 }
 
 /* Some byteswap wrappers */
@@ -223,6 +231,7 @@
 
 /* Parse a Mach-O header */
 static int parse_macho (macho_t *mt, macho_input_t *input) {
+#ifdef __MACH__
     /* Read the file type. */
     const uint32_t *magic = macho_read(input, input->data, sizeof(uint32_t));
     if (magic == NULL)
@@ -418,10 +427,14 @@
     }
 
     return MACHO_SUCCESS;
+#else
+    return 0;
+#endif
 }
 
 /* Parse a (possible Mach-O) file. For a more detailed description, see the header */
 int macho_parse_file(macho_handle_t *handle, const char *filepath, const macho_t **res) {
+#ifdef __MACH__
     int fd;
     struct stat st;
     void *data;
@@ -481,6 +494,9 @@
     close(fd);
 
     return ret;
+#else
+    return 0;
+#endif
 }
 
 /* Create a new macho_handle_t. More information on this function is available in the header */

Modified: trunk/base/src/machista1.0/libmachista.h
===================================================================
--- trunk/base/src/machista1.0/libmachista.h	2012-05-19 13:13:29 UTC (rev 93302)
+++ trunk/base/src/machista1.0/libmachista.h	2012-05-19 13:18:14 UTC (rev 93303)
@@ -38,7 +38,11 @@
  * The name a pun: machista is the spanish translation of "macho".
  */
 
+#ifdef __MACH__
 #include <mach-o/arch.h>
+#else
+typedef int cpu_type_t;
+#endif
 #include <inttypes.h>
 
 #define MACHO_SUCCESS   (0x00)

Modified: trunk/base/src/machista1.0/machista.i
===================================================================
--- trunk/base/src/machista1.0/machista.i	2012-05-19 13:13:29 UTC (rev 93302)
+++ trunk/base/src/machista1.0/machista.i	2012-05-19 13:18:14 UTC (rev 93303)
@@ -6,7 +6,9 @@
 %}
 
 %inline %{
+#ifdef __MACH__
     #include <mach-o/arch.h>
+#endif
     #include <inttypes.h>
     #include <stdint.h>
 %}

Modified: trunk/base/src/machista1.0/machista_wrap.c
===================================================================
--- trunk/base/src/machista1.0/machista_wrap.c	2012-05-19 13:13:29 UTC (rev 93302)
+++ trunk/base/src/machista1.0/machista_wrap.c	2012-05-19 13:18:14 UTC (rev 93303)
@@ -1674,7 +1674,9 @@
     #include "libmachista.h"
 
 
+#ifdef __MACH__
     #include <mach-o/arch.h>
+#endif
     #include <inttypes.h>
     #include <stdint.h>
 

Modified: trunk/base/src/machista1.0/tests/libmachista-test.c
===================================================================
--- trunk/base/src/machista1.0/tests/libmachista-test.c	2012-05-19 13:13:29 UTC (rev 93302)
+++ trunk/base/src/machista1.0/tests/libmachista-test.c	2012-05-19 13:18:14 UTC (rev 93303)
@@ -1,3 +1,5 @@
+#ifdef __MACH__
+
 #include <libmachista.h>
 #include <limits.h>
 #include <mach-o/arch.h>
@@ -340,13 +342,18 @@
 	free(version_string);
 	return false;
 }
+#endif
 
 int main() {
+#ifdef __MACH__
 	bool result = true;
 	result &= test_destroy_null();
 	result &= test_handle();
 	result &= test_format_dylib_version();
 	result &= test_libsystem();
-	exit(!result);
+	return !result;
+#else
+	return 0;
+#endif
 }
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20120519/1d853289/attachment.html>


More information about the macports-changes mailing list