summaryrefslogtreecommitdiff
path: root/package/mtd-utils/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'package/mtd-utils/src/include')
-rw-r--r--package/mtd-utils/src/include/asm/types.h28
-rw-r--r--package/mtd-utils/src/include/byteswap.h56
-rw-r--r--package/mtd-utils/src/include/endian.h41
-rw-r--r--package/mtd-utils/src/include/linux/fs.h71
-rw-r--r--package/mtd-utils/src/include/linux/stddef.h27
-rw-r--r--package/mtd-utils/src/include/linux/types.h62
-rw-r--r--package/mtd-utils/src/include/os-compat.h31
7 files changed, 316 insertions, 0 deletions
diff --git a/package/mtd-utils/src/include/asm/types.h b/package/mtd-utils/src/include/asm/types.h
new file mode 100644
index 000000000..5726d9ef9
--- /dev/null
+++ b/package/mtd-utils/src/include/asm/types.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) Bernhard Walle <bernhard@bwalle.de>, 2012
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Comatibility with BSD-like userland.
+ */
+#ifndef ASM_TYPES_H_
+#define ASM_TYPES_H_
+
+#ifdef __linux__
+#include_next <asm/types.h>
+#endif
+
+#endif /* ASM_TYPES_H_ */
+
diff --git a/package/mtd-utils/src/include/byteswap.h b/package/mtd-utils/src/include/byteswap.h
new file mode 100644
index 000000000..6f9839f7a
--- /dev/null
+++ b/package/mtd-utils/src/include/byteswap.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) Bernhard Walle <bernhard@bwalle.de>, 2012
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Comatibility with BSD-like userland.
+ */
+#ifndef BYTESWAP_H_
+#define BYTESWAP_H_
+
+#ifdef __linux__
+#include_next <byteswap.h>
+#else
+
+#include <stdint.h>
+
+static inline uint16_t bswap_16(uint16_t value)
+{
+ return ((value & 0xff00) >> 8) | ((value & 0xff) << 8);
+}
+
+static inline uint32_t bswap_32(uint32_t value)
+{
+ return ((value & 0xff000000) >> 24) |
+ ((value & 0x00ff0000) >> 8) |
+ ((value & 0x0000ff00) << 8) |
+ ((value & 0x000000ff) << 24);
+}
+
+static inline uint64_t bswap_64(uint64_t value)
+{
+ return ((value & 0xff00000000000000ull) >> 56) |
+ ((value & 0x00ff000000000000ull) >> 40) |
+ ((value & 0x0000ff0000000000ull) >> 24) |
+ ((value & 0x000000ff00000000ull) >> 8) |
+ ((value & 0x00000000ff000000ull) << 8) |
+ ((value & 0x0000000000ff0000ull) << 24) |
+ ((value & 0x000000000000ff00ull) << 40) |
+ ((value & 0x00000000000000ffull) << 56);
+}
+
+#endif
+
+#endif /* BYTESWAP_H_ */
diff --git a/package/mtd-utils/src/include/endian.h b/package/mtd-utils/src/include/endian.h
new file mode 100644
index 000000000..0d72bb888
--- /dev/null
+++ b/package/mtd-utils/src/include/endian.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) Bernhard Walle <bernhard@bwalle.de>, 2012
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Comatibility with BSD-like userland.
+ */
+#ifndef ENDIAN_H_
+#define ENDIAN_H_
+
+#ifdef __linux__
+#include_next <endian.h>
+#elif __APPLE__
+
+#include <machine/endian.h>
+
+#ifndef __DARWIN_BYTE_ORDER
+#error "No __DARWIN_BYTE_ORDER defined"
+#endif
+
+#define __BYTE_ORDER __DARWIN_BYTE_ORDER
+#define __LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN
+#define __BIG_ENDIAN __DARWIN_BIG_ENDIAN
+
+#else
+#error "No byteswap.h found"
+#endif
+
+#endif /* ENDIAN_H_ */
diff --git a/package/mtd-utils/src/include/linux/fs.h b/package/mtd-utils/src/include/linux/fs.h
new file mode 100644
index 000000000..b28168d37
--- /dev/null
+++ b/package/mtd-utils/src/include/linux/fs.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) Bernhard Walle <bernhard@bwalle.de>, 2012
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Comatibility with BSD-like userland.
+ */
+#ifndef LINUX_FS_H_
+#define LINUX_FS_H_
+
+#ifdef __linux__
+#include_next <linux/fs.h>
+#else
+
+#define FS_IOC_GETFLAGS _IOR('f', 1, long)
+#define FS_IOC_SETFLAGS _IOW('f', 2, long)
+#define FS_IOC_GETVERSION _IOR('v', 1, long)
+#define FS_IOC_SETVERSION _IOW('v', 2, long)
+#define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
+#define FS_IOC32_GETFLAGS _IOR('f', 1, int)
+#define FS_IOC32_SETFLAGS _IOW('f', 2, int)
+#define FS_IOC32_GETVERSION _IOR('v', 1, int)
+#define FS_IOC32_SETVERSION _IOW('v', 2, int)
+
+/*
+ * Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS)
+ */
+#define FS_SECRM_FL 0x00000001 /* Secure deletion */
+#define FS_UNRM_FL 0x00000002 /* Undelete */
+#define FS_COMPR_FL 0x00000004 /* Compress file */
+#define FS_SYNC_FL 0x00000008 /* Synchronous updates */
+#define FS_IMMUTABLE_FL 0x00000010 /* Immutable file */
+#define FS_APPEND_FL 0x00000020 /* writes to file may only append */
+#define FS_NODUMP_FL 0x00000040 /* do not dump file */
+#define FS_NOATIME_FL 0x00000080 /* do not update atime */
+/* Reserved for compression usage... */
+#define FS_DIRTY_FL 0x00000100
+#define FS_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
+#define FS_NOCOMP_FL 0x00000400 /* Don't compress */
+#define FS_ECOMPR_FL 0x00000800 /* Compression error */
+/* End compression flags --- maybe not all used */
+#define FS_BTREE_FL 0x00001000 /* btree format dir */
+#define FS_INDEX_FL 0x00001000 /* hash-indexed directory */
+#define FS_IMAGIC_FL 0x00002000 /* AFS directory */
+#define FS_JOURNAL_DATA_FL 0x00004000 /* Reserved for ext3 */
+#define FS_NOTAIL_FL 0x00008000 /* file tail should not be merged */
+#define FS_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
+#define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
+#define FS_EXTENT_FL 0x00080000 /* Extents */
+#define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
+#define FS_NOCOW_FL 0x00800000 /* Do not cow file */
+#define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
+
+#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
+#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
+
+#endif
+
+#endif /* LINUX_FS_H_ */
diff --git a/package/mtd-utils/src/include/linux/stddef.h b/package/mtd-utils/src/include/linux/stddef.h
new file mode 100644
index 000000000..492cf6173
--- /dev/null
+++ b/package/mtd-utils/src/include/linux/stddef.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) Bernhard Walle <bernhard@bwalle.de>, 2012
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Comatibility with BSD-like userland.
+ */
+#ifndef LINUX_STDDEF_H_
+#define LINUX_STDDEF_H_
+
+#ifdef __linux__
+#include_next <linux/stddef.h>
+#endif
+
+#endif /* LINUX_STDDEF_H_ */
diff --git a/package/mtd-utils/src/include/linux/types.h b/package/mtd-utils/src/include/linux/types.h
new file mode 100644
index 000000000..8de4c8a58
--- /dev/null
+++ b/package/mtd-utils/src/include/linux/types.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) Bernhard Walle <bernhard@bwalle.de>, 2012
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Comatibility with BSD-like userland.
+ */
+#ifndef LINUX_TYPES_H_
+#define LINUX_TYPES_H_
+
+#ifdef __linux__
+#include_next <linux/types.h>
+#else
+
+#include <stdint.h> /* get uint8_t etc. */
+#include <sys/types.h> /* get u_long etc. */
+
+/* This types are provided to Linux userland */
+
+typedef uint8_t __u8;
+typedef uint16_t __u16;
+typedef uint32_t __u32;
+typedef uint64_t __u64;
+
+typedef int8_t __s8;
+typedef int16_t __s16;
+typedef int32_t __s32;
+typedef int64_t __s64;
+
+/*
+ * The type itself has no endianess. It's only used for code checkers
+ * but we don't need to run that checkers on non-Linux OSes
+ */
+typedef __u16 __le16;
+typedef __u16 __be16;
+typedef __u32 __le32;
+typedef __u32 __be32;
+typedef __u64 __le64;
+typedef __u64 __be64;
+
+/* from /usr/include/asm-generic/posix_types.h on Linux */
+typedef long __kernel_off_t;
+typedef long long __kernel_loff_t;
+
+typedef long long loff_t;
+typedef long long off64_t;
+
+#endif
+
+#endif /* LINUX_TYPES_H_ */
diff --git a/package/mtd-utils/src/include/os-compat.h b/package/mtd-utils/src/include/os-compat.h
new file mode 100644
index 000000000..0982bfad7
--- /dev/null
+++ b/package/mtd-utils/src/include/os-compat.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) Bernhard Walle <bernhard@bwalle.de>, 2012
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Comatibility with BSD-like userland.
+ */
+#ifndef OS_COMPAT_H_
+#define OS_COMPAT_H_
+
+#ifdef __APPLE__
+
+/* off_t is already 64 bits wide, even on i386 */
+#define O_LARGEFILE 0
+#define lseek64(fd, offset, whence) lseek((fd), (offset), (whence))
+
+#endif /* __APPLE__ */
+
+#endif /* OS_COMPAT_H_ */