Whamcloud - gitweb
LU-5577 libcfs: fix warnings in libcfs/curproc.h
[fs/lustre-release.git] / libcfs / include / libcfs / libcfs.h
index 98682d8..33dc487 100644 (file)
 #ifndef __LIBCFS_LIBCFS_H__
 #define __LIBCFS_LIBCFS_H__
 
-#if !__GNUC__
-#define __attribute__(x)
-#endif
+#include <libcfs/types.h>
+#include <libcfs/list.h>
 
-#if !defined(__WINNT__) && !defined(__KERNEL__)
-#include <libcfs/posix/libcfs.h>
-#elif defined(__linux__)
-#include <libcfs/linux/libcfs.h>
-#elif defined(__APPLE__)
-#include <libcfs/darwin/libcfs.h>
-#elif defined(__WINNT__)
-#include <libcfs/winnt/libcfs.h>
-#else
-#error Unsupported operating system.
-#endif
+#ifdef __KERNEL__
+# include <libcfs/linux/libcfs.h>
+#else /* !__KERNEL__ */
+# include <assert.h>
+# include <ctype.h>
+# include <errno.h>
+# include <fcntl.h>
+# include <limits.h>
+# include <signal.h>
+# include <stdarg.h>
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+# include <stdio.h>
+# include <stdlib.h>
+# include <string.h>
+# include <time.h>
+# include <sys/ioctl.h>
+# include <sys/socket.h>
+# include <sys/stat.h>
+# include <sys/time.h>
+# include <sys/types.h>
+# include <libcfs/user-time.h>
+# include <libcfs/user-prim.h>
+# include <libcfs/user-mem.h>
+# include <libcfs/user-lock.h>
+# include <libcfs/user-tcpip.h>
+# include <libcfs/user-bitops.h>
+#endif /* __KERNEL__ */
 
 #include "curproc.h"
 
@@ -83,6 +100,21 @@ static inline int __is_po2(unsigned long long val)
 
 #define LOWEST_BIT_SET(x)       ((x) & ~((x) - 1))
 
+/* Sparse annotations */
+#ifdef __KERNEL__
+# if !defined(__must_hold)
+#  ifdef __CHECKER__
+#   define __must_hold(x) __attribute__((context(x, 1, 1)))
+#  else        /* __CHECKER__ */
+#   define __must_hold(x)
+#  endif /* !__CHECKER__ */
+# endif /* !__must_hold */
+#else /* __KERNEL__ */
+# define __acquires(x)
+# define __releases(x)
+# define __must_hold(x)
+#endif /* !__KERNEL__ */
+
 /*
  * Lustre Error Checksum: calculates checksum
  * of Hex number by XORing each bit.
@@ -100,12 +132,8 @@ static inline int __is_po2(unsigned long long val)
 
 #define NULL ((void *)0)
 
-#define LUSTRE_SRV_LNET_PID      LUSTRE_LNET_PID
-
 #ifdef __KERNEL__
 
-#include <libcfs/list.h>
-
 #ifndef cfs_for_each_possible_cpu
 #  error cfs_for_each_possible_cpu is not supported by kernel!
 #endif
@@ -181,11 +209,11 @@ struct cfs_psdev_file {
 };
 
 struct cfs_psdev_ops {
-        int (*p_open)(unsigned long, void *);
-        int (*p_close)(unsigned long, void *);
-        int (*p_read)(struct cfs_psdev_file *, char *, unsigned long);
-        int (*p_write)(struct cfs_psdev_file *, char *, unsigned long);
-        int (*p_ioctl)(struct cfs_psdev_file *, unsigned long, void *);
+       int (*p_open)(unsigned long, void *);
+       int (*p_close)(unsigned long, void *);
+       int (*p_read)(struct cfs_psdev_file *, char *, unsigned long);
+       int (*p_write)(struct cfs_psdev_file *, char *, unsigned long);
+       int (*p_ioctl)(struct cfs_psdev_file *, unsigned long, void __user *);
 };
 
 /*
@@ -239,6 +267,7 @@ unsigned int cfs_rand(void);
 void cfs_srand(unsigned int, unsigned int);
 void cfs_get_random_bytes(void *buf, int size);
 
+#include <libcfs/byteorder.h>
 #include <libcfs/err.h>
 #include <libcfs/libcfs_debug.h>
 #include <libcfs/libcfs_private.h>
@@ -269,4 +298,7 @@ static inline void *__container_of(const void *ptr, unsigned long shift)
 
 #define _LIBCFS_H
 
+int libcfs_arch_init(void);
+void libcfs_arch_cleanup(void);
+
 #endif /* _LIBCFS_H */