Whamcloud - gitweb
LU-3321 obdclass: Add a preallocated percpu cl_env
[fs/lustre-release.git] / libcfs / include / libcfs / winnt / winnt-prim.h
index c1b487d..153a9a8 100644 (file)
@@ -374,12 +374,10 @@ size_t lustre_write_file(struct file *fh, loff_t off, size_t size, char *buf);
  */
 
 
-typedef int cfs_task_state_t;
-
-#define CFS_TASK_INTERRUPTIBLE  0x00000001
-#define CFS_TASK_UNINT          0x00000002
-#define CFS_TASK_RUNNING         0x00000003
-#define CFS_TASK_UNINTERRUPTIBLE CFS_TASK_UNINT
+#define TASK_INTERRUPTIBLE      0x00000001
+#define TASK_UNINTERRUPTIBLE            0x00000002
+#define TASK_RUNNING         0x00000003
+#define CFS_TASK_UNINTERRUPTIBLE TASK_UNINTERRUPTIBLE
 
 #define CFS_WAITQ_MAGIC     'CWQM'
 #define CFS_WAITLINK_MAGIC  'CWLM'
@@ -391,10 +389,10 @@ typedef struct cfs_waitq {
        spinlock_t              guard;
        cfs_list_t              waiters;
 
-} cfs_waitq_t;
+} wait_queue_head_t;
 
 
-typedef struct cfs_waitlink cfs_waitlink_t;
+typedef struct cfs_waitlink wait_queue_t;
 
 #define CFS_WAITQ_CHANNELS     (2)
 
@@ -405,8 +403,8 @@ typedef struct cfs_waitlink cfs_waitlink_t;
 
 typedef struct cfs_waitlink_channel {
     cfs_list_t              link;
-    cfs_waitq_t *           waitq;
-    cfs_waitlink_t *        waitl;
+    wait_queue_head_t *           waitq;
+    wait_queue_t *        waitl;
 } cfs_waitlink_channel_t;
 
 struct cfs_waitlink {
@@ -414,7 +412,7 @@ struct cfs_waitlink {
     unsigned int            magic;
     int                     flags;
     event_t  *              event;
-    cfs_atomic_t *          hits;
+    atomic_t *          hits;
 
     cfs_waitlink_channel_t  waitq[CFS_WAITQ_CHANNELS];
 };
@@ -423,7 +421,7 @@ enum {
        CFS_WAITQ_EXCLUSIVE = 1
 };
 
-#define CFS_DECL_WAITQ(name) cfs_waitq_t name
+#define CFS_DECL_WAITQ(name) wait_queue_head_t name
 
 /* Kernel thread */
 
@@ -456,36 +454,36 @@ typedef struct _cfs_thread_context {
  */
 #define NGROUPS_SMALL           32
 #define NGROUPS_PER_BLOCK       ((int)(PAGE_SIZE / sizeof(gid_t)))
-typedef struct cfs_group_info {
-        int ngroups;
-        cfs_atomic_t usage;
-        gid_t small_block[NGROUPS_SMALL];
-        int nblocks;
-        gid_t *blocks[0];
-} cfs_group_info_t;
-
-#define cfs_get_group_info(group_info) do { \
-        cfs_atomic_inc(&(group_info)->usage); \
+struct group_info {
+       int ngroups;
+       atomic_t usage;
+       gid_t small_block[NGROUPS_SMALL];
+       int nblocks;
+       gid_t *blocks[0];
+};
+
+#define get_group_info(group_info) do { \
+       atomic_inc(&(group_info)->usage); \
 } while (0)
 
-#define cfs_put_group_info(group_info) do { \
-        if (cfs_atomic_dec_and_test(&(group_info)->usage)) \
-                cfs_groups_free(group_info); \
+#define put_group_info(group_info) do { \
+       if (atomic_dec_and_test(&(group_info)->usage)) \
+               groups_free(group_info); \
 } while (0)
 
-static __inline cfs_group_info_t *cfs_groups_alloc(int gidsetsize)
+static __inline struct group_info *groups_alloc(int gidsetsize)
 {
-    cfs_group_info_t * groupinfo;
+    struct group_info * groupinfo;
     KdPrint(("%s(%d): %s NOT implemented.\n", __FILE__, __LINE__, __FUNCTION__));
-    groupinfo = kmalloc(sizeof(cfs_group_info_t), 0);
+    groupinfo = kmalloc(sizeof(struct group_info), 0);
 
     if (groupinfo) {
-        memset(groupinfo, 0, sizeof(cfs_group_info_t));
+       memset(groupinfo, 0, sizeof(struct group_info));
     }
     return groupinfo;
 }
 
-static __inline void cfs_groups_free(cfs_group_info_t *group_info)
+static __inline void groups_free(struct group_info *group_info)
 {
        KdPrint(("%s(%d): %s NOT implemented.\n", __FILE__, __LINE__,
                __FUNCTION__));
@@ -493,14 +491,14 @@ static __inline void cfs_groups_free(cfs_group_info_t *group_info)
 }
 
 static __inline int
-cfs_set_current_groups(cfs_group_info_t *group_info)
+set_current_groups(struct group_info *group_info)
 {
     KdPrint(("%s(%d): %s NOT implemented.\n", __FILE__, __LINE__,
              __FUNCTION__));
     return 0;
 }
 
-static __inline int groups_search(cfs_group_info_t *group_info,
+static __inline int groups_search(struct group_info *group_info,
                                   gid_t grp) {
     KdPrint(("%s(%d): %s NOT implemented.\n", __FILE__, __LINE__,
             __FUNCTION__));
@@ -540,14 +538,14 @@ typedef __u32 kernel_cap_t;
  * Task struct
  */
 
-#define CFS_MAX_SCHEDULE_TIMEOUT     ((long_ptr_t)(~0UL>>12))
-#define cfs_schedule_timeout(t)      cfs_schedule_timeout_and_set_state(0, t)
+#define MAX_SCHEDULE_TIMEOUT     ((long_ptr_t)(~0UL>>12))
+#define schedule_timeout(t)      schedule_timeout_and_set_state(0, t)
 
 struct vfsmount;
 
 #define NGROUPS 1
 #define CFS_CURPROC_COMM_MAX (16)
-typedef struct task_sruct{
+struct task_struct{
     mode_t                umask;
     sigset_t              blocked;
 
@@ -560,7 +558,7 @@ typedef struct task_sruct{
     int                   ngroups;
     int                   cgroups;
     gid_t                 groups[NGROUPS];
-    cfs_group_info_t     *group_info;
+    struct group_info     *group_info;
     kernel_cap_t      cap_effective,
                           cap_inheritable,
                           cap_permitted;
@@ -568,13 +566,13 @@ typedef struct task_sruct{
     char                  comm[CFS_CURPROC_COMM_MAX];
     void                 *journal_info;
     struct vfsmount      *fs;
-}  cfs_task_t;
+};
 
-static inline void task_lock(cfs_task_t *t)
+static inline void task_lock(struct task_struct *t)
 {
 }
 
-static inline void task_unlock(cfs_task_t *t)
+static inline void task_unlock(struct task_struct *t)
 {
 }
 
@@ -610,51 +608,49 @@ typedef struct _TASK_SLOT {
     HANDLE          Tid;        /* Thread id */
     PETHREAD        Tet;        /* Pointer to ethread */
 
-    cfs_atomic_t    count;      /* refer count */
-    cfs_atomic_t    hits;       /* times of waken event singaled */
+    atomic_t    count;      /* refer count */
+    atomic_t    hits;       /* times of waken event singaled */
 
     KIRQL           irql;       /* irql for rwlock ... */
 
-    cfs_task_t      task;       /* linux task part */
+    struct task_struct      task;       /* linux task part */
 
 } TASK_SLOT, *PTASK_SLOT;
 
 
-#define current                      cfs_current()
-#define cfs_set_current_state(s)     do {;} while (0)
-#define cfs_set_current_state(state) cfs_set_current_state(state)
+#define set_current_state(s)     do {;} while (0)
 
-#define cfs_wait_event(wq, condition)                           \
+#define wait_event(wq, condition)                           \
 do {                                                            \
-        cfs_waitlink_t __wait;                                  \
-                                                                \
-        cfs_waitlink_init(&__wait);                             \
-        while (TRUE) {                                          \
-            cfs_waitq_add(&wq, &__wait);                        \
-            if (condition) {                                    \
-                break;                                          \
-            }                                                   \
-            cfs_waitq_wait(&__wait, CFS_TASK_INTERRUPTIBLE);    \
-            cfs_waitq_del(&wq, &__wait);                       \
-        }                                                      \
-        cfs_waitq_del(&wq, &__wait);                           \
+       wait_queue_t __wait;                                    \
+                                                               \
+       init_waitqueue_entry_current(&__wait);                  \
+       while (TRUE) {                                          \
+           add_wait_queue(&wq, &__wait);                        \
+           if (condition) {                                    \
+               break;                                          \
+           }                                                   \
+           waitq_wait(&__wait, TASK_INTERRUPTIBLE);            \
+           remove_wait_queue(&wq, &__wait);                    \
+                                                             \
+       remove_wait_queue(&wq, &__wait);                        \
 } while(0)
 
 #define wait_event_interruptible(wq, condition)                 \
 {                                                               \
-       cfs_waitlink_t __wait;                                  \
+       wait_queue_t __wait;                                    \
                                                                \
        __ret = 0;                                              \
-       cfs_waitlink_init(&__wait);                             \
+       init_waitqueue_entry_current(&__wait);                             \
        while (TRUE) {                                          \
-               cfs_waitq_add(&wq, &__wait);                    \
+               add_wait_queue(&wq, &__wait);                   \
                if (condition) {                                \
                        break;                                  \
                }                                               \
-               cfs_waitq_wait(&__wait, CFS_TASK_INTERRUPTIBLE);\
-               cfs_waitq_del(&wq, &__wait);                    \
+               waitq_wait(&__wait, TASK_INTERRUPTIBLE);\
+               remove_wait_queue(&wq, &__wait);                        \
        }                                                       \
-       cfs_waitq_del(&wq, &__wait);                            \
+       remove_wait_queue(&wq, &__wait);                            \
        __ret;                                                  \
 }
 
@@ -667,41 +663,34 @@ do {                                                            \
    retval > 0; timed out.
 */
 
-#define cfs_waitq_wait_event_interruptible_timeout(             \
-                        wq, condition, timeout, rc)             \
+#define wait_event_interruptible_timeout(wq, condition, timeout)\
 do {                                                            \
-        cfs_waitlink_t __wait;                                  \
-                                                                \
-        rc = 0;                                                 \
-        cfs_waitlink_init(&__wait);                            \
-        while (TRUE) {                                          \
-            cfs_waitq_add(&wq, &__wait);                        \
-            if (condition) {                                    \
-                break;                                          \
-            }                                                   \
-            if (cfs_waitq_timedwait(&__wait,                    \
-                CFS_TASK_INTERRUPTIBLE, timeout) == 0) {        \
-                rc = TRUE;                                      \
-                break;                                          \
-            }                                                   \
-            cfs_waitq_del(&wq, &__wait);                       \
-        }                                                      \
-        cfs_waitq_del(&wq, &__wait);                           \
+       wait_queue_t __wait;                                    \
+                                                               \
+       init_waitqueue_entry_current(&__wait);                  \
+       while (TRUE) {                                          \
+           add_wait_queue(&wq, &__wait);                       \
+           if (condition) {                                    \
+               break;                                          \
+           }                                                   \
+           if (waitq_timedwait(&__wait,                        \
+               TASK_INTERRUPTIBLE, timeout) == 0) {            \
+               break;                                          \
+           }                                                   \
+           remove_wait_queue(&wq, &__wait);                    \
+       }                                                       \
+       remove_wait_queue(&wq, &__wait);                        \
 } while(0)
 
-
-#define cfs_waitq_wait_event_timeout                            \
-        cfs_waitq_wait_event_interruptible_timeout
-
 int     init_task_manager();
 void    cleanup_task_manager();
-cfs_task_t * cfs_current();
-int     wake_up_process(cfs_task_t * task);
-void sleep_on(cfs_waitq_t *waitq);
-#define cfs_might_sleep() do {} while(0)
-#define CFS_DECL_JOURNAL_DATA  
-#define CFS_PUSH_JOURNAL           do {;} while(0)
-#define CFS_POP_JOURNAL                    do {;} while(0)
+struct task_struct * current;
+int     wake_up_process(struct task_struct * task);
+void sleep_on(wait_queue_head_t *waitq);
+#define might_sleep() do {} while(0)
+#define DECL_JOURNAL_DATA
+#define PUSH_JOURNAL       do {;} while(0)
+#define POP_JOURNAL                do {;} while(0)
 
 
 /* module related definitions */
@@ -788,7 +777,7 @@ static inline u32 cfs_hash_long(u32 val, unsigned int bits)
 #define CFS_TIMER_FLAG_INITED   0x00000001  // Initialized already
 #define CFS_TIMER_FLAG_TIMERED  0x00000002  // KeSetTimer is called
 
-typedef struct cfs_timer {
+struct timer_list {
 
     KSPIN_LOCK      Lock;
 
@@ -802,7 +791,7 @@ typedef struct cfs_timer {
     void (*proc)(ulong_ptr_t);
     void *          arg;
 
-} cfs_timer_t;
+};
 
 /*
  *  libcfs globals initialization/cleanup
@@ -841,7 +830,7 @@ libcfs_arch_cleanup(void);
  */
 
 #define NR_IRQS                 512
-#define cfs_in_interrupt()          (0)
+#define in_interrupt()          (0)
 
 /*
  *  printk flags
@@ -1091,7 +1080,6 @@ static inline void module_put(struct module *module)
  *  sigset_t routines 
  */
 
-typedef sigset_t cfs_sigset_t;
 #define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
 #define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
 #define sigemptyset(what)   (*(what) = 0, 0)
@@ -1099,11 +1087,11 @@ typedef sigset_t cfs_sigset_t;
 #define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
 
 static __inline int
-sigprocmask(int sig, cfs_sigset_t *w1, cfs_sigset_t *w2) {
+sigprocmask(int sig, sigset_t *w1, sigset_t *w2) {
     return 0;
 }
 static __inline int
-sigpending(cfs_sigset_t *what) {
+sigpending(sigset_t *what) {
     return 0;
 }