From e78fb6da778f542168bf6381ea15cd85d9b4f6d9 Mon Sep 17 00:00:00 2001
From: Yves Blusseau <blusseau@zetam.org>
Date: Fri, 2 May 2014 13:25:36 +0200
Subject: [PATCH] Add specific functions for Apple platforms

* grub-core/osdep/apple/platform.c: add specific functions
* grub-core/osdep/platform.c: likewise
---
 ChangeLog                        |  7 +++++++
 grub-core/osdep/apple/platform.c | 43 ++++++++++++++++++++++++++++++++++++++++
 grub-core/osdep/platform.c       |  2 ++
 3 files changed, 52 insertions(+)
 create mode 100644 grub-core/osdep/apple/platform.c

diff --git a/ChangeLog b/ChangeLog
index ba5e205..67ca665 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2014-05-02  Yves Blusseau  <blusseau@zetam.org>
+
+	Add specific functions for Apple platforms
+
+	* grub-core/osdep/apple/platform.c: add specific functions
+	* grub-core/osdep/platform.c: likewise
+
 2014-04-20  Vladimir Serbinenko  <phcoder@gmail.com>
 
 	* grub-core/kern/misc.c (__bzero): Don't compile in GRUB_UTIL.
diff --git a/grub-core/osdep/apple/platform.c b/grub-core/osdep/apple/platform.c
new file mode 100644
index 0000000..00290b8
--- /dev/null
+++ b/grub-core/osdep/apple/platform.c
@@ -0,0 +1,43 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2014 Free Software Foundation, Inc.
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <grub/util/install.h>
+#include <string.h>
+
+#include <sys/utsname.h>
+
+static int
+is_64_kernel (void)
+{
+  struct utsname un;
+
+  if (uname (&un) < 0)
+    return 0;
+
+  return strcmp (un.machine, "x86_64") == 0;
+}
+
+const char *
+grub_install_get_default_x86_platform (void)
+{
+  if (is_64_kernel ())
+    return "x86_64-efi";
+  else
+    return "i386-efi";
+}
diff --git a/grub-core/osdep/platform.c b/grub-core/osdep/platform.c
index 441d152..bc81b8f 100644
--- a/grub-core/osdep/platform.c
+++ b/grub-core/osdep/platform.c
@@ -4,6 +4,8 @@
 #include "windows/platform.c"
 #elif defined (__MINGW32__) || defined (__CYGWIN__) || defined (__AROS__)
 #include "basic/no_platform.c"
+#elif defined (__APPLE__)
+#include "apple/platform.c"
 #else
 #include "basic/platform.c"
 #endif
-- 
1.8.4

