X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=libcfs%2Finclude%2Flibcfs%2Fuser-prim.h;h=756062b0c03bfad5c9f8198fb90be46334ff8246;hp=9ec6ff887451049ae13883709927754840af4e7c;hb=bb8c57032a47020099bad60f7cea89b4530841d3;hpb=421d7a675265d697a1a9308aa9dac8030eab497a diff --git a/libcfs/include/libcfs/user-prim.h b/libcfs/include/libcfs/user-prim.h index 9ec6ff8..756062b 100644 --- a/libcfs/include/libcfs/user-prim.h +++ b/libcfs/include/libcfs/user-prim.h @@ -1,6 +1,4 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * +/* * GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -16,8 +14,8 @@ * in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see [sun.com URL with a - * copy of GPLv2]. + * version 2 along with this program; If not, see + * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * CA 95054 USA or visit www.sun.com if you need additional information or @@ -26,7 +24,7 @@ * GPL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. */ /* @@ -59,31 +57,38 @@ 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 smp_processor_id() 0 +# define cfs_smp_processor_id() 0 +#else +# define cfs_smp_processor_id() smp_processor_id() #endif #ifndef num_online_cpus -#define num_online_cpus() 1 +# define cfs_num_online_cpus() 1 +#else +# define cfs_num_online_cpus() num_online_cpus() #endif #ifndef num_possible_cpus -#define num_possible_cpus() 1 +# define cfs_num_possible_cpus() 1 +#else +# define cfs_num_possible_cpus() num_possible_cpus() +#endif +#ifndef num_present_cpus +# define cfs_num_present_cpus() 1 +#else +# define cfs_num_present_cpus() num_present_cpus() #endif - /* - * Wait Queue. + * Wait Queue. */ typedef struct cfs_waitlink { - struct list_head sleeping; + cfs_list_t sleeping; void *process; } cfs_waitlink_t; typedef struct cfs_waitq { - struct list_head sleepers; + cfs_list_t sleepers; } cfs_waitq_t; -/* XXX: need to replace wake_up with cfs_waitq_signal() */ -#define wake_up(q) cfs_waitq_signal(q) - /* * Task states */ @@ -93,8 +98,10 @@ typedef long cfs_task_state_t; #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) {} -/* +/* * Lproc */ typedef int (cfs_read_proc_t)(char *page, char **start, off_t off, @@ -112,17 +119,16 @@ typedef sigset_t cfs_sigset_t; /* * Timer */ -#include typedef struct { - struct list_head tl_list; - void (*function)(unsigned long unused); - unsigned long data; + cfs_list_t tl_list; + void (*function)(ulong_ptr_t unused); + ulong_ptr_t data; long expires; } cfs_timer_t; -#define in_interrupt() (0) +#define cfs_in_interrupt() (0) typedef void cfs_psdev_t; @@ -136,20 +142,34 @@ static inline int cfs_psdev_deregister(cfs_psdev_t *foo) return 0; } -#define cfs_lock_kernel() do {} while (0) -#define cfs_sigfillset(l) do {} while (0) +#define cfs_sigfillset(l) do {} while (0) #define cfs_recalc_sigpending(l) do {} while (0) -#define cfs_kernel_thread(l,m,n) LBUG() +/* Fine, crash, but stop giving me compile warnings */ +#define cfs_kthread_run(fn,d,fmt,...) LBUG() + +#define CFS_DAEMON_FLAGS 0 + +#define CFS_L1_CACHE_ALIGN(x) (x) #ifdef HAVE_LIBPTHREAD typedef int (*cfs_thread_t)(void *); -int cfs_create_thread(cfs_thread_t func, void *arg); +int cfs_create_thread(cfs_thread_t func, void *arg, unsigned long flags); #else #define cfs_create_thread(l,m) LBUG() #endif -int cfs_parse_int_tunable(int *value, char *name); uid_t cfs_curproc_uid(void); +gid_t cfs_curproc_gid(void); +uid_t cfs_curproc_fsuid(void); +gid_t cfs_curproc_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) @@ -169,6 +189,7 @@ struct cfs_stack_trace { /* * arithmetic */ +#ifndef do_div /* gcc only, platform-specific will override */ #define do_div(a,b) \ ({ \ unsigned long remainder;\ @@ -176,6 +197,51 @@ struct cfs_stack_trace { (a) = (a) / (b); \ (remainder); \ }) +#endif + +/* + * Groups + */ +typedef struct cfs_group_info { + +} cfs_group_info_t; + +#ifndef min +# define min(x,y) ((x)<(y) ? (x) : (y)) +#endif + +#ifndef max +# define max(x,y) ((x)>(y) ? (x) : (y)) +#endif + +#define cfs_get_random_bytes_prim(val, size) (*val) = 0 + +/* utility libcfs init/fini entries */ +#ifdef __WINNT__ +extern int libcfs_arch_init(void); +extern void libcfs_arch_cleanup(void); +#else /* !__WINNT__ */ +static inline int libcfs_arch_init(void) { + return 0; +} +static inline void libcfs_arch_cleanup(void) { +} +/* __WINNT__ */ +#endif + +/* proc interface wrappers for non-win OS */ +#ifndef __WINNT__ +#define cfs_proc_open open +#define cfs_proc_mknod mknod +#define cfs_proc_ioctl ioctl +#define cfs_proc_close close +#define cfs_proc_read read +#define cfs_proc_write write +#define cfs_proc_fopen fopen +#define cfs_proc_fclose fclose +#define cfs_proc_fgets fgets +/* !__WINNT__ */ +#endif /* !__KERNEL__ */ #endif