aboutsummaryrefslogtreecommitdiffstats
path: root/grub-core/lib/posix_wrap
diff options
context:
space:
mode:
authorJames <james.mckenzie@citrix.com>2012-11-16 10:41:01 +0000
committerJames <james.mckenzie@citrix.com>2012-11-16 10:41:01 +0000
commit041d1ea37802bf7178a31a53f96c26efa6b8fb7b (patch)
treec193e84ad1237f25a79d0f6a267722e44c73f56a /grub-core/lib/posix_wrap
downloadgrub-1.99-041d1ea37802bf7178a31a53f96c26efa6b8fb7b.tar.gz
grub-1.99-041d1ea37802bf7178a31a53f96c26efa6b8fb7b.tar.bz2
grub-1.99-041d1ea37802bf7178a31a53f96c26efa6b8fb7b.zip
fish
Diffstat (limited to 'grub-core/lib/posix_wrap')
-rw-r--r--grub-core/lib/posix_wrap/assert.h33
-rw-r--r--grub-core/lib/posix_wrap/ctype.h103
-rw-r--r--grub-core/lib/posix_wrap/errno.h28
-rw-r--r--grub-core/lib/posix_wrap/inttypes.h1
-rw-r--r--grub-core/lib/posix_wrap/langinfo.h38
-rw-r--r--grub-core/lib/posix_wrap/limits.h0
-rw-r--r--grub-core/lib/posix_wrap/localcharset.h28
-rw-r--r--grub-core/lib/posix_wrap/locale.h0
-rw-r--r--grub-core/lib/posix_wrap/stdint.h1
-rw-r--r--grub-core/lib/posix_wrap/stdio.h29
-rw-r--r--grub-core/lib/posix_wrap/stdlib.h57
-rw-r--r--grub-core/lib/posix_wrap/string.h42
-rw-r--r--grub-core/lib/posix_wrap/sys/types.h46
-rw-r--r--grub-core/lib/posix_wrap/unistd.h0
-rw-r--r--grub-core/lib/posix_wrap/wchar.h25
-rw-r--r--grub-core/lib/posix_wrap/wctype.h0
16 files changed, 431 insertions, 0 deletions
diff --git a/grub-core/lib/posix_wrap/assert.h b/grub-core/lib/posix_wrap/assert.h
new file mode 100644
index 0000000..94cfdd5
--- /dev/null
+++ b/grub-core/lib/posix_wrap/assert.h
@@ -0,0 +1,33 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010 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_POSIX_ASSERT_H
+#define GRUB_POSIX_ASSERT_H 1
+
+#include <grub/misc.h>
+
+#define assert(x) assert_real(__FILE__, __LINE__, x)
+
+static inline void
+assert_real (const char *file, int line, int cond)
+{
+ if (!cond)
+ grub_fatal ("Assertion failed at %s:%d\n", file, line);
+}
+
+#endif
diff --git a/grub-core/lib/posix_wrap/ctype.h b/grub-core/lib/posix_wrap/ctype.h
new file mode 100644
index 0000000..2dc3e53
--- /dev/null
+++ b/grub-core/lib/posix_wrap/ctype.h
@@ -0,0 +1,103 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010 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_POSIX_CTYPE_H
+#define GRUB_POSIX_CTYPE_H 1
+
+#include <grub/misc.h>
+
+static inline int
+toupper (int c)
+{
+ return grub_toupper (c);
+}
+
+static inline int
+isspace (int c)
+{
+ return grub_isspace (c);
+}
+
+static inline int
+isdigit (int c)
+{
+ return grub_isdigit (c);
+}
+
+static inline int
+islower (int c)
+{
+ return (c >= 'a' && c <= 'z');
+}
+
+static inline int
+isupper (int c)
+{
+ return (c >= 'A' && c <= 'Z');
+}
+
+static inline int
+isxdigit (int c)
+{
+ return (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')
+ || (c >= '0' && c <= '9');
+}
+
+static inline int
+isprint (int c)
+{
+ return grub_isprint (c);
+}
+
+static inline int
+iscntrl (int c)
+{
+ return !grub_isprint (c);
+}
+
+static inline int
+isgraph (int c)
+{
+ return grub_isprint (c) && !grub_isspace (c);
+}
+
+static inline int
+isalnum (int c)
+{
+ return grub_isalpha (c) || grub_isdigit (c);
+}
+
+static inline int
+ispunct (int c)
+{
+ return grub_isprint (c) && !grub_isspace (c) && !isalnum (c);
+}
+
+static inline int
+isalpha (int c)
+{
+ return grub_isalpha (c);
+}
+
+static inline int
+tolower (int c)
+{
+ return grub_tolower (c);
+}
+
+#endif
diff --git a/grub-core/lib/posix_wrap/errno.h b/grub-core/lib/posix_wrap/errno.h
new file mode 100644
index 0000000..9031722
--- /dev/null
+++ b/grub-core/lib/posix_wrap/errno.h
@@ -0,0 +1,28 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010 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_POSIX_ERRNO_H
+#define GRUB_POSIX_ERRNO_H 1
+
+#include <grub/err.h>
+
+#define errno grub_errno
+#define EINVAL GRUB_ERR_BAD_NUMBER
+#define ENOMEM GRUB_ERR_OUT_OF_MEMORY
+
+#endif
diff --git a/grub-core/lib/posix_wrap/inttypes.h b/grub-core/lib/posix_wrap/inttypes.h
new file mode 100644
index 0000000..a12c43b
--- /dev/null
+++ b/grub-core/lib/posix_wrap/inttypes.h
@@ -0,0 +1 @@
+#include <sys/types.h>
diff --git a/grub-core/lib/posix_wrap/langinfo.h b/grub-core/lib/posix_wrap/langinfo.h
new file mode 100644
index 0000000..72b5b96
--- /dev/null
+++ b/grub-core/lib/posix_wrap/langinfo.h
@@ -0,0 +1,38 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010 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_POSIX_LANGINFO_H
+#define GRUB_POSIX_LANGINFO_H 1
+
+#include <localcharset.h>
+
+typedef enum { CODESET } nl_item;
+
+static inline char *
+nl_langinfo (nl_item item)
+{
+ switch (item)
+ {
+ case CODESET:
+ return "UTF-8";
+ default:
+ return "";
+ }
+}
+
+#endif
diff --git a/grub-core/lib/posix_wrap/limits.h b/grub-core/lib/posix_wrap/limits.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/grub-core/lib/posix_wrap/limits.h
diff --git a/grub-core/lib/posix_wrap/localcharset.h b/grub-core/lib/posix_wrap/localcharset.h
new file mode 100644
index 0000000..502d860
--- /dev/null
+++ b/grub-core/lib/posix_wrap/localcharset.h
@@ -0,0 +1,28 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010 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_POSIX_LOCALCHARSET_H
+#define GRUB_POSIX_LOCALCHARSET_H 1
+
+static inline const char *
+locale_charset (void)
+{
+ return "UTF-8";
+}
+
+#endif
diff --git a/grub-core/lib/posix_wrap/locale.h b/grub-core/lib/posix_wrap/locale.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/grub-core/lib/posix_wrap/locale.h
diff --git a/grub-core/lib/posix_wrap/stdint.h b/grub-core/lib/posix_wrap/stdint.h
new file mode 100644
index 0000000..a12c43b
--- /dev/null
+++ b/grub-core/lib/posix_wrap/stdint.h
@@ -0,0 +1 @@
+#include <sys/types.h>
diff --git a/grub-core/lib/posix_wrap/stdio.h b/grub-core/lib/posix_wrap/stdio.h
new file mode 100644
index 0000000..701fcea
--- /dev/null
+++ b/grub-core/lib/posix_wrap/stdio.h
@@ -0,0 +1,29 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010 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_POSIX_STDIO_H
+#define GRUB_POSIX_STDIO_H 1
+
+#include <grub/misc.h>
+#include <grub/file.h>
+
+typedef struct grub_file FILE;
+
+#define EOF -1
+
+#endif
diff --git a/grub-core/lib/posix_wrap/stdlib.h b/grub-core/lib/posix_wrap/stdlib.h
new file mode 100644
index 0000000..4c725f6
--- /dev/null
+++ b/grub-core/lib/posix_wrap/stdlib.h
@@ -0,0 +1,57 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010 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_POSIX_STDLIB_H
+#define GRUB_POSIX_STDLIB_H 1
+
+#include <grub/mm.h>
+#include <grub/misc.h>
+
+static inline void
+free (void *ptr)
+{
+ grub_free (ptr);
+}
+
+static inline void *
+malloc (grub_size_t size)
+{
+ return grub_malloc (size);
+}
+
+static inline void *
+calloc (grub_size_t size, grub_size_t nelem)
+{
+ return grub_zalloc (size * nelem);
+}
+
+static inline void *
+realloc (void *ptr, grub_size_t size)
+{
+ return grub_realloc (ptr, size);
+}
+
+static inline void
+abort (void)
+{
+ grub_abort ();
+}
+
+#define MB_CUR_MAX 6
+
+#endif
diff --git a/grub-core/lib/posix_wrap/string.h b/grub-core/lib/posix_wrap/string.h
new file mode 100644
index 0000000..4224836
--- /dev/null
+++ b/grub-core/lib/posix_wrap/string.h
@@ -0,0 +1,42 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010 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_POSIX_STRING_H
+#define GRUB_POSIX_STRING_H 1
+
+#include <grub/misc.h>
+
+static inline grub_size_t
+strlen (const char *s)
+{
+ return grub_strlen (s);
+}
+
+static inline int
+strcmp (const char *s1, const char *s2)
+{
+ return grub_strcmp (s1, s2);
+}
+
+static inline int
+strcasecmp (const char *s1, const char *s2)
+{
+ return grub_strcasecmp (s1, s2);
+}
+
+#endif
diff --git a/grub-core/lib/posix_wrap/sys/types.h b/grub-core/lib/posix_wrap/sys/types.h
new file mode 100644
index 0000000..69e4950
--- /dev/null
+++ b/grub-core/lib/posix_wrap/sys/types.h
@@ -0,0 +1,46 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010 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_POSIX_SYS_TYPES_H
+#define GRUB_POSIX_SYS_TYPES_H 1
+
+#include <grub/misc.h>
+
+typedef grub_size_t size_t;
+typedef enum { false = 0, true = 1 } bool;
+
+#define ULONG_MAX GRUB_ULONG_MAX
+#define UCHAR_MAX 0xff
+
+typedef grub_uint8_t uint8_t;
+typedef grub_uint16_t uint16_t;
+typedef grub_uint32_t uint32_t;
+typedef grub_uint64_t uint64_t;
+
+typedef grub_int8_t int8_t;
+typedef grub_int16_t int16_t;
+typedef grub_int32_t int32_t;
+typedef grub_int64_t int64_t;
+
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+#define WORDS_BIGENDIAN
+#else
+#undef WORDS_BIGENDIAN
+#endif
+
+#endif
diff --git a/grub-core/lib/posix_wrap/unistd.h b/grub-core/lib/posix_wrap/unistd.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/grub-core/lib/posix_wrap/unistd.h
diff --git a/grub-core/lib/posix_wrap/wchar.h b/grub-core/lib/posix_wrap/wchar.h
new file mode 100644
index 0000000..fd56fd3
--- /dev/null
+++ b/grub-core/lib/posix_wrap/wchar.h
@@ -0,0 +1,25 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009, 2010 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_POSIX_WCHAR_H
+#define GRUB_POSIX_WCHAR_H 1
+
+/* UCS-4. */
+typedef grub_uint32_t wchar_t;
+
+#endif
diff --git a/grub-core/lib/posix_wrap/wctype.h b/grub-core/lib/posix_wrap/wctype.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/grub-core/lib/posix_wrap/wctype.h