]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Move OS-dependent file definitions to include/grub/osdep/hostfile*.h.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 9 Oct 2013 06:20:20 +0000 (08:20 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 9 Oct 2013 06:20:20 +0000 (08:20 +0200)
ChangeLog
include/grub/emu/hostdisk.h
include/grub/emu/misc.h
include/grub/osdep/hostfile.h [new file with mode: 0644]
include/grub/osdep/hostfile_aros.h [new file with mode: 0644]
include/grub/osdep/hostfile_unix.h [new file with mode: 0644]
include/grub/osdep/hostfile_windows.h [new file with mode: 0644]
include/grub/util/misc.h

index 22eb08fef719a0d22e43d408344957a1d3ce6cbe..4643f5e100f636eb00c326965e6c9cb7f4ef65ec 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-10-09  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Move OS-dependent file definitions to include/grub/osdep/hostfile*.h.
+
 2013-10-09  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * include/grub/emu/hostdisk.h (grub_hostdisk_linux_find_partition):
index 016ccf603e72b3c589db4fbc501d17e35e0602a3..6f13c95e3021ebf303638010fde00ba85e1ed765 100644 (file)
 #include <grub/disk.h>
 #include <grub/partition.h>
 #include <sys/types.h>
-
-#if defined (__AROS__)
-struct grub_util_fd
-{
-  enum { GRUB_UTIL_FD_FILE, GRUB_UTIL_FD_DISK } type;
-  grub_uint64_t off;
-  union
-  {
-    int fd;
-    struct {
-      struct IOExtTD *ioreq;
-      struct MsgPort *mp;
-      unsigned int is_floppy:1;
-      unsigned int is_64:1;
-    };
-  };
-};
-typedef struct grub_util_fd *grub_util_fd_t;
-
-#define GRUB_UTIL_FD_INVALID NULL
-#define GRUB_UTIL_FD_IS_VALID(x) ((x) != GRUB_UTIL_FD_INVALID)
-#define GRUB_UTIL_FD_STAT_IS_FUNCTIONAL 0
-
-#elif defined (__CYGWIN__) || defined (__MINGW32__)
-#include <windows.h>
-typedef HANDLE grub_util_fd_t;
-#define GRUB_UTIL_FD_INVALID INVALID_HANDLE_VALUE
-#define GRUB_UTIL_FD_IS_VALID(x) ((x) != GRUB_UTIL_FD_INVALID)
-#define GRUB_UTIL_FD_STAT_IS_FUNCTIONAL 0
-#else
-typedef int grub_util_fd_t;
-#define GRUB_UTIL_FD_INVALID -1
-#define GRUB_UTIL_FD_IS_VALID(x) ((x) >= 0)
-#define GRUB_UTIL_FD_STAT_IS_FUNCTIONAL 1
-#endif
+#include <grub/osdep/hostfile.h>
 
 grub_util_fd_t
 grub_util_fd_open (const char *os_dev, int flags);
@@ -124,12 +90,6 @@ grub_hostdisk_find_partition_start_os (const char *dev);
 void
 grub_hostdisk_flush_initial_buffer (const char *os_dev);
 
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__NetBSD__) || defined (__sun__) || defined(__OpenBSD__)
-#define GRUB_DISK_DEVS_ARE_CHAR 1
-#else
-#define GRUB_DISK_DEVS_ARE_CHAR 0
-#endif
-
 struct grub_util_hostdisk_data
 {
   char *dev;
index e25049b6ada15db3fcbb1b36ff49bd812092999a..9a06addd59b539db272adf96f195a123b320997b 100644 (file)
 
 #include <grub/symbol.h>
 #include <grub/types.h>
-
-#if defined (__AROS__)
-# define DEFAULT_DIRECTORY     "SYS:" GRUB_BOOT_DIR_NAME "/" GRUB_DIR_NAME
-#elif defined __CYGWIN__ || defined (__MINGW32__)
-# define DEFAULT_DIRECTORY     "C:\\"GRUB_BOOT_DIR_NAME"\\"GRUB_DIR_NAME
-#elif defined (__NetBSD__)
-/* NetBSD uses /boot for its boot block.  */
-# define DEFAULT_DIRECTORY     "/"GRUB_DIR_NAME
-#else
-# define DEFAULT_DIRECTORY     "/"GRUB_BOOT_DIR_NAME"/"GRUB_DIR_NAME
-#endif
-
-#define DEFAULT_DEVICE_MAP     DEFAULT_DIRECTORY "/device.map"
+#include <grub/osdep/hostfile.h>
 
 extern int verbosity;
 extern const char *program_name;
@@ -63,12 +51,6 @@ void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format
 
 extern char * canonicalize_file_name (const char *path);
 
-#ifdef __MINGW32__
-
-int fsync (int fno);
-
-#endif
-
 #ifdef HAVE_DEVICE_MAPPER
 int grub_device_mapper_supported (void);
 #endif
diff --git a/include/grub/osdep/hostfile.h b/include/grub/osdep/hostfile.h
new file mode 100644 (file)
index 0000000..6d9f75b
--- /dev/null
@@ -0,0 +1,7 @@
+#if defined (__AROS__)
+#include "hostfile_aros.h"
+#elif defined (__CYGWIN__) || defined (__MINGW32__)
+#include "hostfile_windows.h"
+#else
+#include "hostfile_unix.h"
+#endif
diff --git a/include/grub/osdep/hostfile_aros.h b/include/grub/osdep/hostfile_aros.h
new file mode 100644 (file)
index 0000000..1a0cd3b
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2010,2011,2012,2013  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/>.
+ */
+
+#ifndef GRUB_EMU_HOSTFILE_H
+#define GRUB_EMU_HOSTFILE_H 1
+
+#include <config.h>
+#include <stdarg.h>
+
+struct grub_util_fd
+{
+  enum { GRUB_UTIL_FD_FILE, GRUB_UTIL_FD_DISK } type;
+  grub_uint64_t off;
+  union
+  {
+    int fd;
+    struct {
+      struct IOExtTD *ioreq;
+      struct MsgPort *mp;
+      unsigned int is_floppy:1;
+      unsigned int is_64:1;
+    };
+  };
+};
+typedef struct grub_util_fd *grub_util_fd_t;
+
+#define GRUB_UTIL_FD_INVALID NULL
+#define GRUB_UTIL_FD_IS_VALID(x) ((x) != GRUB_UTIL_FD_INVALID)
+#define GRUB_UTIL_FD_STAT_IS_FUNCTIONAL 0
+
+#define DEFAULT_DIRECTORY      "SYS:" GRUB_BOOT_DIR_NAME "/" GRUB_DIR_NAME
+#define DEFAULT_DEVICE_MAP     DEFAULT_DIRECTORY "/device.map"
+
+#endif
diff --git a/include/grub/osdep/hostfile_unix.h b/include/grub/osdep/hostfile_unix.h
new file mode 100644 (file)
index 0000000..e99509f
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2010,2011,2012,2013  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/>.
+ */
+
+#ifndef GRUB_EMU_HOSTFILE_H
+#define GRUB_EMU_HOSTFILE_H 1
+
+#include <config.h>
+#include <stdarg.h>
+
+#include <grub/symbol.h>
+#include <grub/types.h>
+
+#if defined (__NetBSD__)
+/* NetBSD uses /boot for its boot block.  */
+# define DEFAULT_DIRECTORY     "/"GRUB_DIR_NAME
+#else
+# define DEFAULT_DIRECTORY     "/"GRUB_BOOT_DIR_NAME"/"GRUB_DIR_NAME
+#endif
+
+#define DEFAULT_DEVICE_MAP     DEFAULT_DIRECTORY "/device.map"
+
+typedef int grub_util_fd_t;
+#define GRUB_UTIL_FD_INVALID -1
+#define GRUB_UTIL_FD_IS_VALID(x) ((x) >= 0)
+#define GRUB_UTIL_FD_STAT_IS_FUNCTIONAL 1
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__NetBSD__) || defined (__sun__) || defined(__OpenBSD__)
+#define GRUB_DISK_DEVS_ARE_CHAR 1
+#else
+#define GRUB_DISK_DEVS_ARE_CHAR 0
+#endif
+
+#endif
diff --git a/include/grub/osdep/hostfile_windows.h b/include/grub/osdep/hostfile_windows.h
new file mode 100644 (file)
index 0000000..b062c47
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2010,2011,2012,2013  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/>.
+ */
+
+#ifndef GRUB_EMU_HOSTFILE_H
+#define GRUB_EMU_HOSTFILE_H 1
+
+#include <config.h>
+#include <stdarg.h>
+
+#include <windows.h>
+typedef HANDLE grub_util_fd_t;
+#define GRUB_UTIL_FD_INVALID INVALID_HANDLE_VALUE
+#define GRUB_UTIL_FD_IS_VALID(x) ((x) != GRUB_UTIL_FD_INVALID)
+#define GRUB_UTIL_FD_STAT_IS_FUNCTIONAL 0
+
+#define DEFAULT_DIRECTORY      "C:\\"GRUB_BOOT_DIR_NAME"\\"GRUB_DIR_NAME
+#define DEFAULT_DEVICE_MAP     DEFAULT_DIRECTORY "/device.map"
+
+#ifdef __MINGW32__
+
+int fsync (int fno);
+
+#define fseeko fseeko64
+#define ftello ftello64
+
+#endif
+
+#endif
index 598e71243faa32941d631399c815f3af1a97539a..3c481c5003dd5859ad277569624a84c5472a0cc3 100644 (file)
@@ -29,6 +29,7 @@
 #include <grub/types.h>
 #include <grub/symbol.h>
 #include <grub/emu/misc.h>
+#include <grub/osdep/hostfile.h>
 
 char *grub_util_get_path (const char *dir, const char *file);
 size_t grub_util_get_image_size (const char *path);
@@ -39,14 +40,6 @@ void grub_util_write_image (const char *img, size_t size, FILE *out,
 void grub_util_write_image_at (const void *img, size_t size, off_t offset,
                               FILE *out, const char *name);
 
-#ifdef __MINGW32__
-
-#define fseeko fseeko64
-#define ftello ftello64
-
-#endif
-
-
 char *make_system_path_relative_to_its_root (const char *path);
 
 char *canonicalize_file_name (const char *path);