[120067] trunk/base/src/machista1.0/libmachista.c

cal at macports.org cal at macports.org
Wed May 14 15:18:53 PDT 2014


Revision: 120067
          https://trac.macports.org/changeset/120067
Author:   cal at macports.org
Date:     2014-05-14 15:18:53 -0700 (Wed, 14 May 2014)
Log Message:
-----------
base: machista1.0: Fix warnings on Linux, define feature test macros

Modified Paths:
--------------
    trunk/base/src/machista1.0/libmachista.c

Modified: trunk/base/src/machista1.0/libmachista.c
===================================================================
--- trunk/base/src/machista1.0/libmachista.c	2014-05-14 22:18:49 UTC (rev 120066)
+++ trunk/base/src/machista1.0/libmachista.c	2014-05-14 22:18:53 UTC (rev 120067)
@@ -30,8 +30,15 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifdef HAVE_CONFIG_H
 #include <config.h>
+#endif
 
+/* required for asprintf(3) on OS X */
+#define _DARWIN_C_SOURCE
+/* required for asprintf(3) on Linux */
+#define _GNU_SOURCE
+
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -109,14 +116,15 @@
     return result;
 }
 
+#ifdef __MACH__
 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
+const char *macho_get_arch_name (cpu_type_t cputype UNUSED) {
     return NULL;
 #endif
 }
@@ -239,8 +247,8 @@
 #endif
 
 /* Parse a Mach-O header */
+#ifdef __MACH__
 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)
@@ -437,14 +445,12 @@
     }
 
     return MACHO_SUCCESS;
-#else
-    return 0;
+}
 #endif
-}
 
 /* Parse a (possible Mach-O) file. For a more detailed description, see the header */
+#ifdef __MACH__
 int macho_parse_file(macho_handle_t *handle, const char *filepath, const macho_t **res) {
-#ifdef __MACH__
     int fd;
     struct stat st;
     void *data;
@@ -505,6 +511,7 @@
 
     return ret;
 #else
+int macho_parse_file(macho_handle_t *handle UNUSED, const char *filepath UNUSED, const macho_t **res UNUSED) {
     return 0;
 #endif
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140514/a32572b3/attachment.html>


More information about the macports-changes mailing list