1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * libcfs/include/libcfs/user-prim.h
38 * Author: Nikita Danilov <nikita@clusterfs.com>
41 #ifndef __LIBCFS_USER_PRIM_H__
42 #define __LIBCFS_USER_PRIM_H__
44 #ifndef __LIBCFS_LIBCFS_H__
45 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
48 /* Implementations of portable APIs for liblustre */
51 * liblustre is single-threaded, so most "synchronization" APIs are trivial.
56 typedef struct proc_dir_entry cfs_proc_dir_entry_t;
59 * Just present a single processor until will add thread support.
61 #ifndef smp_processor_id
62 #define smp_processor_id() 0
64 #ifndef num_online_cpus
65 #define num_online_cpus() 1
67 #ifndef num_possible_cpus
68 #define num_possible_cpus() 1
75 typedef struct cfs_waitlink {
76 struct list_head sleeping;
80 typedef struct cfs_waitq {
81 struct list_head sleepers;
84 /* XXX: need to replace wake_up with cfs_waitq_signal() */
85 #define wake_up(q) cfs_waitq_signal(q)
90 typedef long cfs_task_state_t;
92 #define CFS_TASK_INTERRUPTIBLE (0)
93 #define CFS_TASK_UNINT (1)
94 #define CFS_TASK_RUNNING (2)
100 typedef int (cfs_read_proc_t)(char *page, char **start, off_t off,
101 int count, int *eof, void *data);
103 struct file; /* forward ref */
104 typedef int (cfs_write_proc_t)(struct file *file, const char *buffer,
105 unsigned long count, void *data);
110 typedef sigset_t cfs_sigset_t;
115 #include <sys/time.h>
118 struct list_head tl_list;
119 void (*function)(unsigned long unused);
125 #define in_interrupt() (0)
127 typedef void cfs_psdev_t;
129 static inline int cfs_psdev_register(cfs_psdev_t *foo)
134 static inline int cfs_psdev_deregister(cfs_psdev_t *foo)
139 #define cfs_lock_kernel() do {} while (0)
140 #define cfs_sigfillset(l) do {} while (0)
141 #define cfs_recalc_sigpending(l) do {} while (0)
142 #define cfs_kernel_thread(l,m,n) LBUG()
144 #ifdef HAVE_LIBPTHREAD
145 typedef int (*cfs_thread_t)(void *);
146 int cfs_create_thread(cfs_thread_t func, void *arg);
148 #define cfs_create_thread(l,m) LBUG()
151 int cfs_parse_int_tunable(int *value, char *name);
152 uid_t cfs_curproc_uid(void);
154 #define LIBCFS_REALLOC(ptr, size) realloc(ptr, size)
156 #define cfs_online_cpus() sysconf(_SC_NPROCESSORS_ONLN)
158 // static inline void local_irq_save(unsigned long flag) {return;}
159 // static inline void local_irq_restore(unsigned long flag) {return;}
162 CFS_STACK_TRACE_DEPTH = 16
165 struct cfs_stack_trace {
166 void *frame[CFS_STACK_TRACE_DEPTH];
172 #define do_div(a,b) \
174 unsigned long remainder;\
175 remainder = (a) % (b); \
183 /* __LIBCFS_USER_PRIM_H__ */
187 * c-indentation-style: "K&R"