[95609] branches/release_2_1

jmr at macports.org jmr at macports.org
Tue Jul 17 17:14:44 PDT 2012


Revision: 95609
          https://trac.macports.org/changeset/95609
Author:   jmr at macports.org
Date:     2012-07-17 17:14:43 -0700 (Tue, 17 Jul 2012)
Log Message:
-----------
merge r93303, r93339 from trunk:
 fix build on platforms without mach-o headers

Revision Links:
--------------
    https://trac.macports.org/changeset/93303
    https://trac.macports.org/changeset/93339

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

Property Changed:
----------------
    branches/release_2_1/
    branches/release_2_1/base/


Property changes on: branches/release_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk:91825,91829,91834,92072,92342,92404,92546,92730,92785,92881,92903,92976,93062,93153,93197,93250,93258-93259,93261,93268,93274
   + /trunk:91825,91829,91834,92072,92342,92404,92546,92730,92785,92881,92903,92976,93062,93153,93197,93250,93258-93259,93261,93268,93274,93303,93339


Property changes on: branches/release_2_1/base
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/gsoc08-privileges/base:37343-46937
/branches/gsoc09-logging/base:51231-60371
/branches/gsoc11-rev-upgrade/base:78828-88375
/branches/universal-sanity/base:51872-52323
/branches/variant-descs-14482/base:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/trunk/base:91825,91829,91834,92072,92342,92404,92546,92730,92785,92881,92903,92976,93062,93129,93153,93197,93250,93256,93258-93259,93261,93268,93274
/users/perry/base-bugs_and_notes:45682-46060
/users/perry/base-select:44044-44692
   + /branches/gsoc08-privileges/base:37343-46937
/branches/gsoc09-logging/base:51231-60371
/branches/gsoc11-rev-upgrade/base:78828-88375
/branches/universal-sanity/base:51872-52323
/branches/variant-descs-14482/base:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/trunk/base:91825,91829,91834,92072,92342,92404,92546,92730,92785,92881,92903,92976,93062,93129,93153,93197,93250,93256,93258-93259,93261,93268,93274,93303,93339
/users/perry/base-bugs_and_notes:45682-46060
/users/perry/base-select:44044-44692

Modified: branches/release_2_1/base/src/machista1.0/libmachista.c
===================================================================
--- branches/release_2_1/base/src/machista1.0/libmachista.c	2012-07-17 20:47:52 UTC (rev 95608)
+++ branches/release_2_1/base/src/machista1.0/libmachista.c	2012-07-18 00:14:43 UTC (rev 95609)
@@ -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;
@@ -77,6 +81,7 @@
     HashMap *result_map;
 };
 
+#ifdef __MACH__
 /* Verify that the given range is within bounds. */
 static const void *macho_read (macho_input_t *input, const void *address, size_t length) {
     if ((((uint8_t *) address) - ((uint8_t *) input->data)) + length > input->length) {
@@ -92,6 +97,7 @@
     void *result = ((uint8_t *) address) + offset;
     return macho_read(input, result, length);
 }
+#endif
 
 /* return a human readable formatted version number. the result must be free()'d. */
 char *macho_format_dylib_version (uint32_t version) {
@@ -101,13 +107,18 @@
 }
 
 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
 }
 
+#ifdef __MACH__
 /* Some byteswap wrappers */
 static uint32_t macho_swap32 (uint32_t input) {
     return OSSwapInt32(input);
@@ -149,6 +160,7 @@
     memset(mlt, 0, sizeof(macho_loadcmd_t));
     return mlt;
 }
+#endif
 
 /* Frees a previously allocated macho_loadcmd_t and all it's associated resources */
 static void free_macho_loadcmd_t (macho_loadcmd_t *mlt) {
@@ -191,6 +203,7 @@
     free(mt);
 }
 
+#ifdef __MACH__
 /* Creates a new element in the architecture list of a macho_t (mt_archs), increases the counter of
  * architectures (mt_arch_count) and returns a pointer to the newly allocated element or NULL on
  * error */
@@ -220,9 +233,11 @@
 
     return mat->mat_loadcmds;
 }
+#endif
 
 /* 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 +433,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 +500,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: branches/release_2_1/base/src/machista1.0/libmachista.h
===================================================================
--- branches/release_2_1/base/src/machista1.0/libmachista.h	2012-07-17 20:47:52 UTC (rev 95608)
+++ branches/release_2_1/base/src/machista1.0/libmachista.h	2012-07-18 00:14:43 UTC (rev 95609)
@@ -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: branches/release_2_1/base/src/machista1.0/machista.i
===================================================================
--- branches/release_2_1/base/src/machista1.0/machista.i	2012-07-17 20:47:52 UTC (rev 95608)
+++ branches/release_2_1/base/src/machista1.0/machista.i	2012-07-18 00:14:43 UTC (rev 95609)
@@ -6,7 +6,9 @@
 %}
 
 %inline %{
+#ifdef __MACH__
     #include <mach-o/arch.h>
+#endif
     #include <inttypes.h>
     #include <stdint.h>
 %}

Modified: branches/release_2_1/base/src/machista1.0/machista_wrap.c
===================================================================
--- branches/release_2_1/base/src/machista1.0/machista_wrap.c	2012-07-17 20:47:52 UTC (rev 95608)
+++ branches/release_2_1/base/src/machista1.0/machista_wrap.c	2012-07-18 00:14:43 UTC (rev 95609)
@@ -1674,7 +1674,9 @@
     #include "libmachista.h"
 
 
+#ifdef __MACH__
     #include <mach-o/arch.h>
+#endif
     #include <inttypes.h>
     #include <stdint.h>
 

Modified: branches/release_2_1/base/src/machista1.0/tests/libmachista-test.c
===================================================================
--- branches/release_2_1/base/src/machista1.0/tests/libmachista-test.c	2012-07-17 20:47:52 UTC (rev 95608)
+++ branches/release_2_1/base/src/machista1.0/tests/libmachista-test.c	2012-07-18 00:14:43 UTC (rev 95609)
@@ -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/20120717/5481a935/attachment.html>


More information about the macports-changes mailing list