-/*\r
- * YAFFS: Yet another FFS. A NAND-flash specific file system. \r
- * devextras.h\r
- *\r
- * Copyright (C) 2002 Aleph One Ltd.\r
- * for Toby Churchill Ltd and Brightstar Engineering\r
- *\r
- * Created by Charles Manning <charles@aleph1.co.uk>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU Lesser General Public License version 2.1 as\r
- * published by the Free Software Foundation.\r
- *\r
- * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.\r
- *\r
- * This file is just holds extra declarations used during development.\r
- * Most of these are from kernel includes placed here so we can use them in \r
- * applications.\r
- *\r
- */\r
- \r
-#ifndef __EXTRAS_H__\r
-#define __EXTRAS_H__\r
-\r
-#if defined WIN32\r
-#define __inline__ __inline\r
-#define new newHack\r
-#endif\r
-\r
-#if !(defined __KERNEL__) || (defined WIN32)\r
-\r
-// User space defines\r
-\r
-typedef unsigned char __u8;\r
-typedef unsigned short __u16;\r
-typedef unsigned __u32;\r
-\r
-\r
-/*\r
- * Simple doubly linked list implementation.\r
- *\r
- * Some of the internal functions ("__xxx") are useful when\r
- * manipulating whole lists rather than single entries, as\r
- * sometimes we already know the next/prev entries and we can\r
- * generate better code by using them directly rather than\r
- * using the generic single-entry routines.\r
- */\r
- \r
- #define prefetch(x) 1\r
- \r
-\r
-struct list_head {\r
- struct list_head *next, *prev;\r
-};\r
-\r
-#define LIST_HEAD_INIT(name) { &(name), &(name) }\r
-\r
-#define LIST_HEAD(name) \\r
- struct list_head name = LIST_HEAD_INIT(name)\r
-\r
-#define INIT_LIST_HEAD(ptr) do { \\r
- (ptr)->next = (ptr); (ptr)->prev = (ptr); \\r
-} while (0)\r
-\r
-/*\r
- * Insert a new entry between two known consecutive entries.\r
- *\r
- * This is only for internal list manipulation where we know\r
- * the prev/next entries already!\r
- */\r
-static __inline__ void __list_add(struct list_head * new,\r
- struct list_head * prev,\r
- struct list_head * next)\r
-{\r
- next->prev = new;\r
- new->next = next;\r
- new->prev = prev;\r
- prev->next = new;\r
-}\r
-\r
-/**\r
- * list_add - add a new entry\r
- * @new: new entry to be added\r
- * @head: list head to add it after\r
- *\r
- * Insert a new entry after the specified head.\r
- * This is good for implementing stacks.\r
- */\r
-static __inline__ void list_add(struct list_head *new, struct list_head *head)\r
-{\r
- __list_add(new, head, head->next);\r
-}\r
-\r
-/**\r
- * list_add_tail - add a new entry\r
- * @new: new entry to be added\r
- * @head: list head to add it before\r
- *\r
- * Insert a new entry before the specified head.\r
- * This is useful for implementing queues.\r
- */\r
-static __inline__ void list_add_tail(struct list_head *new, struct list_head *head)\r
-{\r
- __list_add(new, head->prev, head);\r
-}\r
-\r
-/*\r
- * Delete a list entry by making the prev/next entries\r
- * point to each other.\r
- *\r
- * This is only for internal list manipulation where we know\r
- * the prev/next entries already!\r
- */\r
-static __inline__ void __list_del(struct list_head * prev,\r
- struct list_head * next)\r
-{\r
- next->prev = prev;\r
- prev->next = next;\r
-}\r
-\r
-/**\r
- * list_del - deletes entry from list.\r
- * @entry: the element to delete from the list.\r
- * Note: list_empty on entry does not return true after this, the entry is in an undefined state.\r
- */\r
-static __inline__ void list_del(struct list_head *entry)\r
-{\r
- __list_del(entry->prev, entry->next);\r
-}\r
-\r
-/**\r
- * list_del_init - deletes entry from list and reinitialize it.\r
- * @entry: the element to delete from the list.\r
- */\r
-static __inline__ void list_del_init(struct list_head *entry)\r
-{\r
- __list_del(entry->prev, entry->next);\r
- INIT_LIST_HEAD(entry);\r
-}\r
-\r
-/**\r
- * list_empty - tests whether a list is empty\r
- * @head: the list to test.\r
- */\r
-static __inline__ int list_empty(struct list_head *head)\r
-{\r
- return head->next == head;\r
-}\r
-\r
-/**\r
- * list_splice - join two lists\r
- * @list: the new list to add.\r
- * @head: the place to add it in the first list.\r
- */\r
-static __inline__ void list_splice(struct list_head *list, struct list_head *head)\r
-{\r
- struct list_head *first = list->next;\r
-\r
- if (first != list) {\r
- struct list_head *last = list->prev;\r
- struct list_head *at = head->next;\r
-\r
- first->prev = head;\r
- head->next = first;\r
-\r
- last->next = at;\r
- at->prev = last;\r
- }\r
-}\r
-\r
-/**\r
- * list_entry - get the struct for this entry\r
- * @ptr: the &struct list_head pointer.\r
- * @type: the type of the struct this is embedded in.\r
- * @member: the name of the list_struct within the struct.\r
- */\r
-#define list_entry(ptr, type, member) \\r
- ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))\r
-\r
-/**\r
- * list_for_each - iterate over a list\r
- * @pos: the &struct list_head to use as a loop counter.\r
- * @head: the head for your list.\r
- */\r
-#define list_for_each(pos, head) \\r
- for (pos = (head)->next, prefetch(pos->next); pos != (head); \\r
- pos = pos->next, prefetch(pos->next))\r
-\r
-/**\r
- * list_for_each_safe - iterate over a list safe against removal of list entry\r
- * @pos: the &struct list_head to use as a loop counter.\r
- * @n: another &struct list_head to use as temporary storage\r
- * @head: the head for your list.\r
- */\r
-#define list_for_each_safe(pos, n, head) \\r
- for (pos = (head)->next, n = pos->next; pos != (head); \\r
- pos = n, n = pos->next)\r
-\r
-\r
-\r
-\r
-/*\r
- * File types\r
- */\r
-#define DT_UNKNOWN 0\r
-#define DT_FIFO 1\r
-#define DT_CHR 2\r
-#define DT_DIR 4\r
-#define DT_BLK 6\r
-#define DT_REG 8\r
-#define DT_LNK 10\r
-#define DT_SOCK 12\r
-#define DT_WHT 14\r
-\r
-#ifndef WIN32\r
-#include <sys/stat.h>\r
-#endif\r
-\r
-/*\r
- * Attribute flags. These should be or-ed together to figure out what\r
- * has been changed!\r
- */\r
-#define ATTR_MODE 1\r
-#define ATTR_UID 2\r
-#define ATTR_GID 4\r
-#define ATTR_SIZE 8\r
-#define ATTR_ATIME 16\r
-#define ATTR_MTIME 32\r
-#define ATTR_CTIME 64\r
-#define ATTR_ATIME_SET 128\r
-#define ATTR_MTIME_SET 256\r
-#define ATTR_FORCE 512 /* Not a change, but a change it */\r
-#define ATTR_ATTR_FLAG 1024\r
-\r
-\r
-struct iattr {\r
- unsigned int ia_valid;\r
- unsigned ia_mode;\r
- unsigned ia_uid;\r
- unsigned ia_gid;\r
- unsigned ia_size;\r
- unsigned ia_atime;\r
- unsigned ia_mtime;\r
- unsigned ia_ctime;\r
- unsigned int ia_attr_flags;\r
-};\r
-\r
-#define KERN_DEBUG\r
-\r
-\r
-#else\r
-\r
-#ifndef WIN32\r
-#include <linux/types.h>\r
-#include <linux/list.h>\r
-#include <linux/fs.h>\r
-#include <linux/stat.h>\r
-#endif\r
-\r
-#endif\r
-\r
-\r
-\r
-#if defined WIN32\r
-#undef new\r
-#endif \r
-\r
-#endif\r
-\r
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ * devextras.h
+ *
+ * Copyright (C) 2002 Aleph One Ltd.
+ * for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ *
+ * This file is just holds extra declarations used during development.
+ * Most of these are from kernel includes placed here so we can use them in
+ * applications.
+ *
+ * $Id: devextras.h,v 1.5 2002-09-27 20:50:50 charles Exp $
+ *
+ */
+
+#ifndef __EXTRAS_H__
+#define __EXTRAS_H__
+
+#if defined WIN32
+#define __inline__ __inline
+#define new newHack
+#endif
+
+#if !(defined __KERNEL__) || (defined WIN32)
+
+// User space defines
+
+typedef unsigned char __u8;
+typedef unsigned short __u16;
+typedef unsigned __u32;
+
+
+/*
+ * Simple doubly linked list implementation.
+ *
+ * Some of the internal functions ("__xxx") are useful when
+ * manipulating whole lists rather than single entries, as
+ * sometimes we already know the next/prev entries and we can
+ * generate better code by using them directly rather than
+ * using the generic single-entry routines.
+ */
+
+ #define prefetch(x) 1
+
+
+struct list_head {
+ struct list_head *next, *prev;
+};
+
+#define LIST_HEAD_INIT(name) { &(name), &(name) }
+
+#define LIST_HEAD(name) \
+ struct list_head name = LIST_HEAD_INIT(name)
+
+#define INIT_LIST_HEAD(ptr) do { \
+ (ptr)->next = (ptr); (ptr)->prev = (ptr); \
+} while (0)
+
+/*
+ * Insert a new entry between two known consecutive entries.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static __inline__ void __list_add(struct list_head * new,
+ struct list_head * prev,
+ struct list_head * next)
+{
+ next->prev = new;
+ new->next = next;
+ new->prev = prev;
+ prev->next = new;
+}
+
+/**
+ * list_add - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it after
+ *
+ * Insert a new entry after the specified head.
+ * This is good for implementing stacks.
+ */
+static __inline__ void list_add(struct list_head *new, struct list_head *head)
+{
+ __list_add(new, head, head->next);
+}
+
+/**
+ * list_add_tail - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it before
+ *
+ * Insert a new entry before the specified head.
+ * This is useful for implementing queues.
+ */
+static __inline__ void list_add_tail(struct list_head *new, struct list_head *head)
+{
+ __list_add(new, head->prev, head);
+}
+
+/*
+ * Delete a list entry by making the prev/next entries
+ * point to each other.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static __inline__ void __list_del(struct list_head * prev,
+ struct list_head * next)
+{
+ next->prev = prev;
+ prev->next = next;
+}
+
+/**
+ * list_del - deletes entry from list.
+ * @entry: the element to delete from the list.
+ * Note: list_empty on entry does not return true after this, the entry is in an undefined state.
+ */
+static __inline__ void list_del(struct list_head *entry)
+{
+ __list_del(entry->prev, entry->next);
+}
+
+/**
+ * list_del_init - deletes entry from list and reinitialize it.
+ * @entry: the element to delete from the list.
+ */
+static __inline__ void list_del_init(struct list_head *entry)
+{
+ __list_del(entry->prev, entry->next);
+ INIT_LIST_HEAD(entry);
+}
+
+/**
+ * list_empty - tests whether a list is empty
+ * @head: the list to test.
+ */
+static __inline__ int list_empty(struct list_head *head)
+{
+ return head->next == head;
+}
+
+/**
+ * list_splice - join two lists
+ * @list: the new list to add.
+ * @head: the place to add it in the first list.
+ */
+static __inline__ void list_splice(struct list_head *list, struct list_head *head)
+{
+ struct list_head *first = list->next;
+
+ if (first != list) {
+ struct list_head *last = list->prev;
+ struct list_head *at = head->next;
+
+ first->prev = head;
+ head->next = first;
+
+ last->next = at;
+ at->prev = last;
+ }
+}
+
+/**
+ * list_entry - get the struct for this entry
+ * @ptr: the &struct list_head pointer.
+ * @type: the type of the struct this is embedded in.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_entry(ptr, type, member) \
+ ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
+
+/**
+ * list_for_each - iterate over a list
+ * @pos: the &struct list_head to use as a loop counter.
+ * @head: the head for your list.
+ */
+#define list_for_each(pos, head) \
+ for (pos = (head)->next, prefetch(pos->next); pos != (head); \
+ pos = pos->next, prefetch(pos->next))
+
+/**
+ * list_for_each_safe - iterate over a list safe against removal of list entry
+ * @pos: the &struct list_head to use as a loop counter.
+ * @n: another &struct list_head to use as temporary storage
+ * @head: the head for your list.
+ */
+#define list_for_each_safe(pos, n, head) \
+ for (pos = (head)->next, n = pos->next; pos != (head); \
+ pos = n, n = pos->next)
+
+
+
+
+/*
+ * File types
+ */
+#define DT_UNKNOWN 0
+#define DT_FIFO 1
+#define DT_CHR 2
+#define DT_DIR 4
+#define DT_BLK 6
+#define DT_REG 8
+#define DT_LNK 10
+#define DT_SOCK 12
+#define DT_WHT 14
+
+#ifndef WIN32
+#include <sys/stat.h>
+#endif
+
+/*
+ * Attribute flags. These should be or-ed together to figure out what
+ * has been changed!
+ */
+#define ATTR_MODE 1
+#define ATTR_UID 2
+#define ATTR_GID 4
+#define ATTR_SIZE 8
+#define ATTR_ATIME 16
+#define ATTR_MTIME 32
+#define ATTR_CTIME 64
+#define ATTR_ATIME_SET 128
+#define ATTR_MTIME_SET 256
+#define ATTR_FORCE 512 /* Not a change, but a change it */
+#define ATTR_ATTR_FLAG 1024
+
+
+struct iattr {
+ unsigned int ia_valid;
+ unsigned ia_mode;
+ unsigned ia_uid;
+ unsigned ia_gid;
+ unsigned ia_size;
+ unsigned ia_atime;
+ unsigned ia_mtime;
+ unsigned ia_ctime;
+ unsigned int ia_attr_flags;
+};
+
+#define KERN_DEBUG
+
+
+#else
+
+#ifndef WIN32
+#include <linux/types.h>
+#include <linux/list.h>
+#include <linux/fs.h>
+#include <linux/stat.h>
+#endif
+
+#endif
+
+
+
+#if defined WIN32
+#undef new
+#endif
+
+#endif
+