Whamcloud - gitweb
LU-4961 lustre: remove liblustre.h and obd.h from userspace
[fs/lustre-release.git] / libcfs / include / libcfs / user-prim.h
index 76e6c33..ceef624 100644 (file)
@@ -26,6 +26,8 @@
 /*
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -49,7 +51,9 @@
  * liblustre is single-threaded, so most "synchronization" APIs are trivial.
  */
 
-#ifndef __KERNEL__
+#ifndef EXPORT_SYMBOL
+# define EXPORT_SYMBOL(s)
+#endif
 
 typedef struct proc_dir_entry           cfs_proc_dir_entry_t;
 
@@ -57,111 +61,138 @@ typedef struct proc_dir_entry           cfs_proc_dir_entry_t;
  * Just present a single processor until will add thread support.
  */
 #ifndef smp_processor_id
-# define cfs_smp_processor_id() 0
-#else
-# define cfs_smp_processor_id() smp_processor_id()
+# define smp_processor_id() 0
 #endif
 #ifndef num_online_cpus
-# define cfs_num_online_cpus() 1
-#else
-# define cfs_num_online_cpus() num_online_cpus()
+# define num_online_cpus() 1
 #endif
 #ifndef num_possible_cpus
-# define cfs_num_possible_cpus() 1
-#else
-# define cfs_num_possible_cpus() num_possible_cpus()
+# define num_possible_cpus() 1
 #endif
-#ifndef num_present_cpus
-# define cfs_num_present_cpus() 1
-#else
-# define cfs_num_present_cpus() num_present_cpus()
+#ifndef get_cpu
+# define get_cpu() 0
+#endif
+#ifndef put_cpu
+# define put_cpu() do {} while (0)
 #endif
+#ifndef NR_CPUS
+# define NR_CPUS 1
+#endif
+#ifndef for_each_possible_cpu
+# define for_each_possible_cpu(cpu) for ((cpu) = 0; (cpu) < 1; (cpu)++)
+#endif
+
 /*
  * Wait Queue.
  */
 
 typedef struct cfs_waitlink {
-        cfs_list_t sleeping;
-        void *process;
-} cfs_waitlink_t;
+       struct list_head sleeping;
+       void *process;
+} wait_queue_t;
 
 typedef struct cfs_waitq {
-        cfs_list_t sleepers;
-} cfs_waitq_t;
+       struct list_head sleepers;
+} wait_queue_head_t;
+
+#define CFS_DECL_WAITQ(wq) wait_queue_head_t wq
+void init_waitqueue_head(struct cfs_waitq *waitq);
+void init_waitqueue_entry_current(struct cfs_waitlink *link);
+void add_wait_queue(struct cfs_waitq *waitq, struct cfs_waitlink *link);
+void add_wait_queue_exclusive(struct cfs_waitq *waitq, struct cfs_waitlink *link);
+void add_wait_queue_exclusive_head(struct cfs_waitq *waitq, struct cfs_waitlink *link);
+void remove_wait_queue(struct cfs_waitq *waitq, struct cfs_waitlink *link);
+int waitqueue_active(struct cfs_waitq *waitq);
+void wake_up(struct cfs_waitq *waitq);
+void wake_up_nr(struct cfs_waitq *waitq, int nr);
+void wake_up_all(struct cfs_waitq *waitq);
+void waitq_wait(struct cfs_waitlink *link, long state);
+int64_t waitq_timedwait(struct cfs_waitlink *link, long state, int64_t timeout);
+void schedule_timeout_and_set_state(long state, int64_t timeout);
+void cfs_pause(cfs_duration_t d);
+int need_resched(void);
+void cond_resched(void);
 
 /*
  * Task states
  */
-typedef long cfs_task_state_t;
+#define TASK_INTERRUPTIBLE  (0)
+#define TASK_UNINTERRUPTIBLE          (1)
+#define TASK_RUNNING        (2)
 
-#define CFS_TASK_INTERRUPTIBLE  (0)
-#define CFS_TASK_UNINT          (1)
-#define CFS_TASK_RUNNING        (2)
-
-static inline void cfs_schedule(void)                  {}
-static inline void cfs_schedule_timeout(int64_t t)     {}
+static inline void schedule(void)                      {}
+static inline void schedule_timeout(int64_t t) {}
+static inline void set_current_state(int state)
+{
+}
 
 /*
  * Lproc
  */
-typedef int (cfs_read_proc_t)(char *page, char **start, off_t off,
-                          int count, int *eof, void *data);
+typedef int (read_proc_t)(char *page, char **start, off_t off,
+                               int count, int *eof, void *data);
 
 struct file; /* forward ref */
-typedef int (cfs_write_proc_t)(struct file *file, const char *buffer,
+typedef int (write_proc_t)(struct file *file, const char *buffer,
                                unsigned long count, void *data);
 
 /*
  * Signal
  */
-typedef sigset_t                        cfs_sigset_t;
 
 /*
  * Timer
  */
 
-typedef struct {
-        cfs_list_t tl_list;
-        void (*function)(ulong_ptr_t unused);
-        ulong_ptr_t data;
-        long expires;
-} cfs_timer_t;
+struct timer_list {
+       struct list_head tl_list;
+       void (*function)(ulong_ptr_t unused);
+       ulong_ptr_t data;
+       long expires;
+};
 
 
-#define cfs_in_interrupt()    (0)
+#define in_interrupt()    (0)
 
-typedef void cfs_psdev_t;
+struct miscdevice{
+};
 
-static inline int cfs_psdev_register(cfs_psdev_t *foo)
+static inline int misc_register(struct miscdevice *foo)
 {
-        return 0;
+       return 0;
 }
 
-static inline int cfs_psdev_deregister(cfs_psdev_t *foo)
+static inline int misc_deregister(struct miscdevice *foo)
 {
-        return 0;
+       return 0;
 }
 
-#define cfs_sigfillset(l)               do {} while (0)
 #define cfs_recalc_sigpending(l)        do {} while (0)
-/* Fine, crash, but stop giving me compile warnings */
-#define cfs_kthread_run(fn,d,fmt,...)   LBUG()
 
-#define CFS_DAEMON_FLAGS                0
+#define DAEMON_FLAGS                0
 
-#define CFS_L1_CACHE_ALIGN(x)          (x)
+#define L1_CACHE_ALIGN(x)              (x)
 
 #ifdef HAVE_LIBPTHREAD
 typedef int (*cfs_thread_t)(void *);
-int cfs_create_thread(cfs_thread_t func, void *arg, unsigned long flags);
+void *kthread_run(cfs_thread_t func, void *arg, const char namefmt[], ...);
 #else
-#define cfs_create_thread(l,m) LBUG()
+/* Fine, crash, but stop giving me compile warnings */
+#define kthread_run(f, a, n, ...) LBUG()
 #endif
 
-uid_t cfs_curproc_uid(void);
-gid_t cfs_curproc_gid(void);
-uid_t cfs_curproc_fsuid(void);
-gid_t cfs_curproc_fsgid(void);
+uid_t current_uid(void);
+gid_t current_gid(void);
+uid_t current_fsuid(void);
+gid_t current_fsgid(void);
+
+#ifndef HAVE_STRLCPY /* not in glibc for RHEL 5.x, remove when obsolete */
+size_t strlcpy(char *tgt, const char *src, size_t tgt_len);
+#endif
+
+#ifndef HAVE_STRLCAT /* not in glibc for RHEL 5.x, remove when obsolete */
+size_t strlcat(char *tgt, const char *src, size_t tgt_len);
+#endif
 
 #define LIBCFS_REALLOC(ptr, size) realloc(ptr, size)
 
@@ -194,9 +225,7 @@ struct cfs_stack_trace {
 /*
  * Groups
  */
-typedef struct cfs_group_info {
-
-} cfs_group_info_t;
+struct group_info{ };
 
 #ifndef min
 # define min(x,y) ((x)<(y) ? (x) : (y))
@@ -206,7 +235,7 @@ typedef struct cfs_group_info {
 # define max(x,y) ((x)>(y) ? (x) : (y))
 #endif
 
-#define cfs_get_random_bytes_prim(val, size)     (*val) = 0
+#define get_random_bytes(val, size)     (*val) = 0
 
 /* utility libcfs init/fini entries */
 #ifdef __WINNT__
@@ -235,8 +264,6 @@ static inline void libcfs_arch_cleanup(void) {
 /* !__WINNT__ */
 #endif
 
-/* !__KERNEL__ */
-#endif
 
 /* __LIBCFS_USER_PRIM_H__ */
 #endif