cstyle: Resolve C style issues

The vast majority of these changes are in Linux specific code.
They are the result of not having an automated style checker to
validate the code when it was originally written.  Others were
caused when the common code was slightly adjusted for Linux.

This patch contains no functional changes.  It only refreshes
the code to conform to style guide.

Everyone submitting patches for inclusion upstream should now
run 'make checkstyle' and resolve any warning prior to opening
a pull request.  The automated builders have been updated to
fail a build if when 'make checkstyle' detects an issue.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1821
This commit is contained in:
Michael Kjorling
2013-11-01 20:26:11 +01:00
committed by Brian Behlendorf
parent 8ffef572ed
commit d1d7e2689d
165 changed files with 2120 additions and 1936 deletions
+1 -1
View File
@@ -27,7 +27,7 @@
#include_next <assert.h>
#ifndef _LIBSPL_ASSERT_H
#define _LIBSPL_ASSERT_H
#define _LIBSPL_ASSERT_H
#include <stdio.h>
#include <stdlib.h>
+69 -9
View File
@@ -25,7 +25,7 @@
*/
#ifndef _LIBSPL_DEVID_H
#define _LIBSPL_DEVID_H
#define _LIBSPL_DEVID_H
#include <stdlib.h>
@@ -36,13 +36,73 @@ typedef struct devid_nmlist {
dev_t dev;
} devid_nmlist_t;
static inline int devid_str_decode(char *devidstr, ddi_devid_t *retdevid, char **retminor_name) { abort(); }
static inline int devid_deviceid_to_nmlist(char *search_path, ddi_devid_t devid, char *minor_name, devid_nmlist_t **retlist) { abort(); }
static inline void devid_str_free(char *str) { abort(); }
static inline void devid_free(ddi_devid_t devid) { abort(); }
static inline void devid_free_nmlist(devid_nmlist_t *list) { abort(); }
static inline int devid_get(int fd, ddi_devid_t *retdevid) { return -1; }
static inline int devid_get_minor_name(int fd, char **retminor_name) { abort(); }
static inline char *devid_str_encode(ddi_devid_t devid, char *minor_name) { abort(); }
static inline
int
devid_str_decode(
char *devidstr,
ddi_devid_t *retdevid,
char **retminor_name)
{
abort();
}
static inline
int
devid_deviceid_to_nmlist(
char *search_path,
ddi_devid_t devid,
char *minor_name,
devid_nmlist_t **retlist)
{
abort();
}
static inline
void
devid_str_free(char *str)
{
abort();
}
static inline
void
devid_free(ddi_devid_t devid)
{
abort();
}
static inline
void
devid_free_nmlist(devid_nmlist_t *list)
{
abort();
}
static inline
int
devid_get(
int fd,
ddi_devid_t *retdevid)
{
return (-1);
}
static inline
int
devid_get_minor_name(
int fd,
char **retminor_name)
{
abort();
}
static inline
char *
devid_str_encode(
ddi_devid_t devid,
char *minor_name)
{
abort();
}
#endif
+1 -1
View File
@@ -25,6 +25,6 @@
*/
#ifndef _LIBSPL_LIBDEVINFO_H
#define _LIBSPL_LIBDEVINFO_H
#define _LIBSPL_LIBDEVINFO_H
#endif /* _LIBSPL_LIBDEVINFO_H */
+1 -1
View File
@@ -25,7 +25,7 @@
*/
#ifndef _LIBSPL_LIBGEN_H
#define _LIBSPL_LIBGEN_H
#define _LIBSPL_LIBGEN_H
#include <sys/types.h>
+1 -1
View File
@@ -24,7 +24,7 @@
* Use is subject to license terms.
*/
#ifndef _LIBSPL_LIBSHARE_H
#define _LIBSPL_LIBSHARE_H
#define _LIBSPL_LIBSHARE_H
typedef void *sa_handle_t; /* opaque handle to access core functions */
typedef void *sa_group_t;
+7 -7
View File
@@ -27,14 +27,14 @@
#include_next <limits.h>
#ifndef _LIBSPL_LIMITS_H
#define _LIBSPL_LIMITS_H
#define _LIBSPL_LIMITS_H
#define DBL_DIG 15
#define DBL_MAX 1.7976931348623157081452E+308
#define DBL_MIN 2.2250738585072013830903E-308
#define DBL_DIG 15
#define DBL_MAX 1.7976931348623157081452E+308
#define DBL_MIN 2.2250738585072013830903E-308
#define FLT_DIG 6
#define FLT_MAX 3.4028234663852885981170E+38F
#define FLT_MIN 1.1754943508222875079688E-38F
#define FLT_DIG 6
#define FLT_MAX 3.4028234663852885981170E+38F
#define FLT_MIN 1.1754943508222875079688E-38F
#endif /* _LIBSPL_LIMITS_H */
+1 -1
View File
@@ -27,7 +27,7 @@
#include_next <locale.h>
#ifndef _LIBSPL_LOCALE_H
#define _LIBSPL_LOCALE_H
#define _LIBSPL_LOCALE_H
#include <time.h>
#include <sys/time.h>
+2 -2
View File
@@ -36,7 +36,7 @@
*/
#ifndef _NOTE_H
#define _NOTE_H
#define _NOTE_H
#include <sys/note.h>
@@ -44,7 +44,7 @@
extern "C" {
#endif
#define NOTE _NOTE
#define NOTE _NOTE
#ifdef __cplusplus
}
+2 -2
View File
@@ -25,12 +25,12 @@
*/
#ifndef _LIBSPL_PRIV_H
#define _LIBSPL_PRIV_H
#define _LIBSPL_PRIV_H
#include <sys/types.h>
/* Couldn't find this definition in OpenGrok */
#define PRIV_SYS_CONFIG "sys_config"
#define PRIV_SYS_CONFIG "sys_config"
/*
* priv_op_t indicates a privilege operation type
+1 -1
View File
@@ -24,7 +24,7 @@
*/
#ifndef LIBSPL_RPC_TYPES_H
#define LIBSPL_RPC_TYPES_H
#define LIBSPL_RPC_TYPES_H
#include_next <rpc/types.h>
#include <sys/kmem.h>
+5 -5
View File
@@ -30,7 +30,7 @@
*/
#ifndef LIBSPL_RPC_XDR_H
#define LIBSPL_RPC_XDR_H
#define LIBSPL_RPC_XDR_H
#include_next <rpc/xdr.h>
@@ -55,10 +55,10 @@ typedef struct xdr_bytesrec {
* XDR_RDMANOCHUNK - for xdr implementaion over RDMA, sets private flags in
* the XDR stream moving over RDMA.
*/
#define XDR_PEEK 2
#define XDR_SKIPBYTES 3
#define XDR_RDMAGET 4
#define XDR_RDMASET 5
#define XDR_PEEK 2
#define XDR_SKIPBYTES 3
#define XDR_RDMAGET 4
#define XDR_RDMASET 5
extern bool_t xdr_control(XDR *xdrs, int request, void *info);
+2 -2
View File
@@ -27,8 +27,8 @@
#include_next <stdio.h>
#ifndef _LIBSPL_STDIO_H
#define _LIBSPL_STDIO_H
#define _LIBSPL_STDIO_H
#define enable_extended_FILE_stdio(fd, sig) ((void) 0)
#define enable_extended_FILE_stdio(fd, sig) ((void) 0)
#endif
+1 -1
View File
@@ -27,7 +27,7 @@
#include_next <stdlib.h>
#ifndef _LIBSPL_STDLIB_H
#define _LIBSPL_STDLIB_H
#define _LIBSPL_STDLIB_H
extern const char *getexecname(void);
+1 -1
View File
@@ -25,7 +25,7 @@
*/
#ifndef _LIBSPL_STRING_H
#define _LIBSPL_STRING_H
#define _LIBSPL_STRING_H
#include_next <string.h>
+1 -1
View File
@@ -25,7 +25,7 @@
*/
#ifndef _LIBSPL_STRINGS_H
#define _LIBSPL_STRINGS_H
#define _LIBSPL_STRINGS_H
#include <string.h>
#include_next <strings.h>
+1 -1
View File
@@ -25,6 +25,6 @@
*/
#ifndef _LIBSPL_SYNCH_H
#define _LIBSPL_SYNCH_H
#define _LIBSPL_SYNCH_H
#endif
+1 -1
View File
@@ -25,6 +25,6 @@
*/
#ifndef _LIBSPL_SYS_BITMAP_H
#define _LIBSPL_SYS_BITMAP_H
#define _LIBSPL_SYS_BITMAP_H
#endif
+1 -1
View File
@@ -25,6 +25,6 @@
*/
#ifndef _SYS_CALLB_H
#define _SYS_CALLB_H
#define _SYS_CALLB_H
#endif
+1 -1
View File
@@ -25,6 +25,6 @@
*/
#ifndef _LIBSPL_SYS_CMN_ERR_H
#define _LIBSPL_SYS_CMN_ERR_H
#define _LIBSPL_SYS_CMN_ERR_H
#endif
+1 -1
View File
@@ -25,6 +25,6 @@
*/
#ifndef _LIBSPL_SYS_COMPRESS_H
#define _LIBSPL_SYS_COMPRESS_H
#define _LIBSPL_SYS_COMPRESS_H
#endif /* _LIBSPL_SYS_COMPRESS_H */
+1 -1
View File
@@ -25,7 +25,7 @@
*/
#ifndef _LIBSPL_SYS_CRED_H
#define _LIBSPL_SYS_CRED_H
#define _LIBSPL_SYS_CRED_H
typedef struct cred cred_t;
+1 -1
View File
@@ -25,7 +25,7 @@
*/
#ifndef _LIBSPL_SYS_DEBUG_H
#define _LIBSPL_SYS_DEBUG_H
#define _LIBSPL_SYS_DEBUG_H
#include <assert.h>
+2 -2
View File
@@ -25,8 +25,8 @@
*/
#ifndef _SYS_FEATURE_TESTS_H
#define _SYS_FEATURE_TESTS_H
#define _SYS_FEATURE_TESTS_H
#define __NORETURN __attribute__((__noreturn__))
#define __NORETURN __attribute__((__noreturn__))
#endif
+14 -14
View File
@@ -25,26 +25,26 @@
*/
#ifndef _LIBSPL_SYS_FILE_H
#define _LIBSPL_SYS_FILE_H
#define _LIBSPL_SYS_FILE_H
#include_next <sys/file.h>
#include <sys/user.h>
#define FREAD 1
#define FWRITE 2
//#define FAPPEND 8
#define FREAD 1
#define FWRITE 2
// #define FAPPEND 8
#define FCREAT O_CREAT
#define FTRUNC O_TRUNC
#define FOFFMAX O_LARGEFILE
#define FSYNC O_SYNC
#define FDSYNC O_DSYNC
#define FRSYNC O_RSYNC
#define FEXCL O_EXCL
#define FCREAT O_CREAT
#define FTRUNC O_TRUNC
#define FOFFMAX O_LARGEFILE
#define FSYNC O_SYNC
#define FDSYNC O_DSYNC
#define FRSYNC O_RSYNC
#define FEXCL O_EXCL
#define FNODSYNC 0x10000 /* fsync pseudo flag */
#define FNOFOLLOW 0x20000 /* don't follow symlinks */
#define FIGNORECASE 0x80000 /* request case-insensitive lookups */
#define FNODSYNC 0x10000 /* fsync pseudo flag */
#define FNOFOLLOW 0x20000 /* don't follow symlinks */
#define FIGNORECASE 0x80000 /* request case-insensitive lookups */
#endif
+1 -1
View File
@@ -25,7 +25,7 @@
*/
#ifndef _SYS_FRAME_H
#define _SYS_FRAME_H
#define _SYS_FRAME_H
#include <sys/types.h>
+1 -1
View File
@@ -25,6 +25,6 @@
*/
#ifndef _LIBSPL_SYS_INT_LIMITS_H
#define _LIBSPL_SYS_INT_LIMITS_H
#define _LIBSPL_SYS_INT_LIMITS_H
#endif
+1 -1
View File
@@ -25,7 +25,7 @@
*/
#ifndef _SOL_SYS_INT_TYPES_H
#define _SOL_SYS_INT_TYPES_H
#define _SOL_SYS_INT_TYPES_H
#include <inttypes.h>
+2 -2
View File
@@ -25,10 +25,10 @@
*/
#ifndef _SOL_SYS_INTTYPES_H
#define _SOL_SYS_INTTYPES_H
#define _SOL_SYS_INTTYPES_H
#include <inttypes.h>
#define _INT64_TYPE
#define _INT64_TYPE
#endif
+22 -22
View File
@@ -35,91 +35,91 @@ extern "C" {
#if defined(__x86_64) || defined(__x86_64__)
#if !defined(__x86_64)
#define __x86_64
#define __x86_64
#endif
#if !defined(__amd64)
#define __amd64
#define __amd64
#endif
#if !defined(__x86)
#define __x86
#define __x86
#endif
#if !defined(_LP64)
#define _LP64
#define _LP64
#endif
#if !defined(_LITTLE_ENDIAN)
#define _LITTLE_ENDIAN
#define _LITTLE_ENDIAN
#endif
#define _SUNOS_VTOC_16
#define _SUNOS_VTOC_16
/* i386 arch specific defines */
#elif defined(__i386) || defined(__i386__)
#if !defined(__i386)
#define __i386
#define __i386
#endif
#if !defined(__x86)
#define __x86
#define __x86
#endif
#if !defined(_ILP32)
#define _ILP32
#define _ILP32
#endif
#if !defined(_LITTLE_ENDIAN)
#define _LITTLE_ENDIAN
#define _LITTLE_ENDIAN
#endif
#define _SUNOS_VTOC_16
#define _SUNOS_VTOC_16
/* powerpc arch specific defines */
#elif defined(__powerpc) || defined(__powerpc__)
#if !defined(__powerpc)
#define __powerpc
#define __powerpc
#endif
#if !defined(__powerpc__)
#define __powerpc__
#define __powerpc__
#endif
#if !defined(_LP64)
#ifdef __powerpc64__
#define _LP64
#define _LP64
#else
#define _LP32
#define _LP32
#endif
#endif
#if !defined(_BIG_ENDIAN)
#define _BIG_ENDIAN
#define _BIG_ENDIAN
#endif
#define _SUNOS_VTOC_16
#define _SUNOS_VTOC_16
/* arm arch specific defines */
#elif defined(__arm) || defined(__arm__)
#if !defined(__arm)
#define __arm
#define __arm
#endif
#if !defined(__arm__)
#define __arm__
#define __arm__
#endif
#if defined(__ARMEL__)
#define _LITTLE_ENDIAN
#define _LITTLE_ENDIAN
#else
#define _BIG_ENDIAN
#define _BIG_ENDIAN
#endif
#define _SUNOS_VTOC_16
#define _SUNOS_VTOC_16
#else /* Currently only x86_64, i386, arm, and powerpc arches supported */
#error "Unsupported ISA type"
+2 -2
View File
@@ -35,8 +35,8 @@ extern "C" {
#define KM_SLEEP 0x00000000 /* same as KM_SLEEP */
#define KM_NOSLEEP 0x00000001 /* same as KM_NOSLEEP */
#define kmem_alloc(size, flags) malloc(size)
#define kmem_free(ptr, size) free(ptr)
#define kmem_alloc(size, flags) malloc(size)
#define kmem_free(ptr, size) free(ptr)
#ifdef __cplusplus
}
+1 -1
View File
@@ -25,6 +25,6 @@
*/
#ifndef _LIBSPL_SYS_MKDEV_H
#define _LIBSPL_SYS_MKDEV_H
#define _LIBSPL_SYS_MKDEV_H
#endif
+5 -5
View File
@@ -19,7 +19,7 @@
*
* CDDL HEADER END
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
@@ -28,7 +28,7 @@
/* Copyright 2006 Ricardo Correia */
#ifndef _SYS_MNTTAB_H
#define _SYS_MNTTAB_H
#define _SYS_MNTTAB_H
#include <stdio.h>
#include <mntent.h>
@@ -77,10 +77,10 @@ static inline char *_sol_hasmntopt(struct mnttab *mnt, char *opt)
mnt_new.mnt_opts = mnt->mnt_mntopts;
return hasmntopt(&mnt_new, opt);
return (hasmntopt(&mnt_new, opt));
}
#define hasmntopt _sol_hasmntopt
#define getmntent _sol_getmntent
#define hasmntopt _sol_hasmntopt
#define getmntent _sol_getmntent
#endif
+8 -8
View File
@@ -27,7 +27,7 @@
#include_next <sys/mount.h>
#ifndef _LIBSPL_SYS_MOUNT_H
#define _LIBSPL_SYS_MOUNT_H
#define _LIBSPL_SYS_MOUNT_H
#include <sys/mntent.h>
#include <assert.h>
@@ -39,7 +39,7 @@
* and we don't want to require the kernel headers
*/
#if !defined(BLKGETSIZE64)
#define BLKGETSIZE64 _IOR(0x12, 114, size_t)
#define BLKGETSIZE64 _IOR(0x12, 114, size_t)
#endif
/*
@@ -48,7 +48,7 @@
* headers define MS_DIRSYNC to be S_WRITE.
*/
#if !defined(MS_DIRSYNC)
#define MS_DIRSYNC S_WRITE
#define MS_DIRSYNC S_WRITE
#endif
/*
@@ -71,15 +71,15 @@
* kernel back to 2.4.11 so we define them correctly if they are missing.
*/
#ifdef MNT_FORCE
# define MS_FORCE MNT_FORCE
#define MS_FORCE MNT_FORCE
#else
# define MS_FORCE 0x00000001
#define MS_FORCE 0x00000001
#endif /* MNT_FORCE */
#ifdef MNT_DETACH
# define MS_DETACH MNT_DETACH
#define MS_DETACH MNT_DETACH
#else
# define MS_DETACH 0x00000002
#define MS_DETACH 0x00000002
#endif /* MNT_DETACH */
/*
@@ -87,6 +87,6 @@
* compatibility, MS_OVERLAY is defined to explicitly have the user
* provide a flag (-O) to mount over a non empty directory.
*/
#define MS_OVERLAY 0x00000004
#define MS_OVERLAY 0x00000004
#endif /* _LIBSPL_SYS_MOUNT_H */
+12 -12
View File
@@ -25,7 +25,7 @@
*/
#ifndef _LIBSPL_SYS_PARAM_H
#define _LIBSPL_SYS_PARAM_H
#define _LIBSPL_SYS_PARAM_H
#include_next <sys/param.h>
#include <unistd.h>
@@ -43,20 +43,20 @@
* Note that the blocked devices are assumed to have DEV_BSIZE
* "sectors" and that fragments must be some multiple of this size.
*/
#define MAXBSIZE 8192
#define DEV_BSIZE 512
#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
#define MAXBSIZE 8192
#define DEV_BSIZE 512
#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
#define MAXNAMELEN 256
#define MAXOFFSET_T LLONG_MAX
#define MAXNAMELEN 256
#define MAXOFFSET_T LLONG_MAX
#define UID_NOBODY 60001 /* user ID no body */
#define GID_NOBODY UID_NOBODY
#define UID_NOACCESS 60002 /* user ID no access */
#define UID_NOBODY 60001 /* user ID no body */
#define GID_NOBODY UID_NOBODY
#define UID_NOACCESS 60002 /* user ID no access */
#define MAXUID UINT32_MAX /* max user id */
#define MAXPROJID MAXUID /* max project id */
#define MAXUID UINT32_MAX /* max user id */
#define MAXPROJID MAXUID /* max project id */
#define PAGESIZE (sysconf(_SC_PAGESIZE))
#define PAGESIZE (sysconf(_SC_PAGESIZE))
#endif
+1 -1
View File
@@ -25,6 +25,6 @@
*/
#ifndef _LIBSPL_SYS_PRIV_H
#define _LIBSPL_SYS_PRIV_H
#define _LIBSPL_SYS_PRIV_H
#endif
+2 -2
View File
@@ -25,9 +25,9 @@
*/
#ifndef _LIBSPL_SYS_PROCESSOR_H
#define _LIBSPL_SYS_PROCESSOR_H
#define _LIBSPL_SYS_PROCESSOR_H
#define getcpuid() (-1)
#define getcpuid() (-1)
typedef int processorid_t;
+6 -6
View File
@@ -25,12 +25,12 @@
*/
#ifndef _LIBSPL_SYS_SDT_H
#define _LIBSPL_SYS_SDT_H
#define _LIBSPL_SYS_SDT_H
#define DTRACE_PROBE(a) ((void) 0)
#define DTRACE_PROBE1(a,b,c) ((void) 0)
#define DTRACE_PROBE2(a,b,c,d,e) ((void) 0)
#define DTRACE_PROBE3(a,b,c,d,e,f,g) ((void) 0)
#define DTRACE_PROBE4(a,b,c,d,e,f,g,h,i) ((void) 0)
#define DTRACE_PROBE(a) ((void) 0)
#define DTRACE_PROBE1(a, b, c) ((void) 0)
#define DTRACE_PROBE2(a, b, c, d, e) ((void) 0)
#define DTRACE_PROBE3(a, b, c, d, e, f, g) ((void) 0)
#define DTRACE_PROBE4(a, b, c, d, e, f, g, h, i) ((void) 0)
#endif
+11 -9
View File
@@ -23,11 +23,11 @@
* Portions Copyright 2008 Sun Microsystems, Inc. All Rights reserved.
*/
#ifndef _SYS_STACK_H
#define _SYS_STACK_H
#define _SYS_STACK_H
#include <pthread.h>
#define STACK_BIAS 0
#define STACK_BIAS 0
#ifdef __USE_GNU
@@ -39,7 +39,7 @@ stack_getbounds(stack_t *sp)
rc = pthread_getattr_np(pthread_self(), &attr);
if (rc)
return rc;
return (rc);
rc = pthread_attr_getstack(&attr, &sp->ss_sp, &sp->ss_size);
if (rc == 0)
@@ -47,7 +47,7 @@ stack_getbounds(stack_t *sp)
pthread_attr_destroy(&attr);
return rc;
return (rc);
}
static inline int
@@ -57,15 +57,17 @@ thr_stksegment(stack_t *sp)
rc = stack_getbounds(sp);
if (rc)
return rc;
return (rc);
/* thr_stksegment() is expected to set sp.ss_sp to the high stack
* address, but the stack_getbounds() interface is expected to
* set sp.ss_sp to the low address. Adjust accordingly. */
/*
* thr_stksegment() is expected to set sp.ss_sp to the high stack
* address, but the stack_getbounds() interface is expected to
* set sp.ss_sp to the low address. Adjust accordingly.
*/
sp->ss_sp = (void *)(((uintptr_t)sp->ss_sp) + sp->ss_size);
sp->ss_flags = 0;
return rc;
return (rc);
}
#endif /* __USE_GNU */
+4 -4
View File
@@ -24,7 +24,7 @@
*/
#ifndef _LIBSPL_SYS_STAT_H
#define _LIBSPL_SYS_STAT_H
#define _LIBSPL_SYS_STAT_H
#include_next <sys/stat.h>
@@ -37,14 +37,14 @@ static inline int
fstat64_blk(int fd, struct stat64 *st)
{
if (fstat64(fd, st) == -1)
return -1;
return (-1);
/* In Linux we need to use an ioctl to get the size of a block device */
if (S_ISBLK(st->st_mode)) {
if (ioctl(fd, BLKGETSIZE64, &st->st_size) != 0)
return -1;
return (-1);
}
return 0;
return (0);
}
#endif /* _LIBSPL_SYS_STAT_H */
+1 -1
View File
@@ -24,6 +24,6 @@
*/
#ifndef _LIBSPL_SYS_STROPTS_H
#define _LIBSPL_SYS_STROPTS_H
#define _LIBSPL_SYS_STROPTS_H
#endif /* _LIBSPL_SYS_STROPTS_H */
+1 -1
View File
@@ -25,6 +25,6 @@
*/
#ifndef _LIBSPL_SYS_SYSEVENT_H
#define _LIBSPL_SYS_SYSEVENT_H
#define _LIBSPL_SYS_SYSEVENT_H
#endif
+33 -33
View File
@@ -25,41 +25,41 @@
*/
#ifndef _LIBSPL_SYS_SYSMACROS_H
#define _LIBSPL_SYS_SYSMACROS_H
#define _LIBSPL_SYS_SYSMACROS_H
#include_next <sys/sysmacros.h>
/* common macros */
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a, b) ((a) < (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))
#endif
#ifndef ABS
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#endif
#define makedevice(maj,min) makedev(maj,min)
#define _sysconf(a) sysconf(a)
#define __NORETURN __attribute__ ((noreturn))
#define makedevice(maj, min) makedev(maj, min)
#define _sysconf(a) sysconf(a)
#define __NORETURN __attribute__((noreturn))
/*
* Compatibility macros/typedefs needed for Solaris -> Linux port
*/
#define P2ALIGN(x, align) ((x) & -(align))
#define P2CROSS(x, y, align) (((x) ^ (y)) > (align) - 1)
#define P2ROUNDUP(x, align) (-(-(x) & -(align)))
#define P2ROUNDUP_TYPED(x, align, type) \
#define P2ALIGN(x, align) ((x) & -(align))
#define P2CROSS(x, y, align) (((x) ^ (y)) > (align) - 1)
#define P2ROUNDUP(x, align) (-(-(x) & -(align)))
#define P2ROUNDUP_TYPED(x, align, type) \
(-(-(type)(x) & -(type)(align)))
#define P2BOUNDARY(off, len, align) \
#define P2BOUNDARY(off, len, align) \
(((off) ^ ((off) + (len) - 1)) > (align) - 1)
#define P2PHASE(x, align) ((x) & ((align) - 1))
#define P2NPHASE(x, align) (-(x) & ((align) - 1))
#define P2NPHASE_TYPED(x, align, type) \
#define P2PHASE(x, align) ((x) & ((align) - 1))
#define P2NPHASE(x, align) (-(x) & ((align) - 1))
#define P2NPHASE_TYPED(x, align, type) \
(-(type)(x) & ((type)(align) - 1))
#define ISP2(x) (((x) & ((x) - 1)) == 0)
#define IS_P2ALIGNED(v, a) ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1)) == 0)
#define ISP2(x) (((x) & ((x) - 1)) == 0)
#define IS_P2ALIGNED(v, a) ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1)) == 0)
/*
* Typed version of the P2* macros. These macros should be used to ensure
@@ -72,22 +72,22 @@
* or
* P2ROUNDUP_TYPED(x, PAGESIZE, uint64_t)
*/
#define P2ALIGN_TYPED(x, align, type) \
((type)(x) & -(type)(align))
#define P2PHASE_TYPED(x, align, type) \
((type)(x) & ((type)(align) - 1))
#define P2NPHASE_TYPED(x, align, type) \
(-(type)(x) & ((type)(align) - 1))
#define P2ROUNDUP_TYPED(x, align, type) \
(-(-(type)(x) & -(type)(align)))
#define P2END_TYPED(x, align, type) \
(-(~(type)(x) & -(type)(align)))
#define P2PHASEUP_TYPED(x, align, phase, type) \
((type)(phase) - (((type)(phase) - (type)(x)) & -(type)(align)))
#define P2CROSS_TYPED(x, y, align, type) \
(((type)(x) ^ (type)(y)) > (type)(align) - 1)
#define P2SAMEHIGHBIT_TYPED(x, y, type) \
(((type)(x) ^ (type)(y)) < ((type)(x) & (type)(y)))
#define P2ALIGN_TYPED(x, align, type) \
((type)(x) & -(type)(align))
#define P2PHASE_TYPED(x, align, type) \
((type)(x) & ((type)(align) - 1))
#define P2NPHASE_TYPED(x, align, type) \
(-(type)(x) & ((type)(align) - 1))
#define P2ROUNDUP_TYPED(x, align, type) \
(-(-(type)(x) & -(type)(align)))
#define P2END_TYPED(x, align, type) \
(-(~(type)(x) & -(type)(align)))
#define P2PHASEUP_TYPED(x, align, phase, type) \
((type)(phase) - (((type)(phase) - (type)(x)) & -(type)(align)))
#define P2CROSS_TYPED(x, y, align, type) \
(((type)(x) ^ (type)(y)) > (type)(align) - 1)
#define P2SAMEHIGHBIT_TYPED(x, y, type) \
(((type)(x) ^ (type)(y)) < ((type)(x) & (type)(y)))
/* avoid any possibility of clashing with <stddef.h> version */
+4 -4
View File
@@ -25,13 +25,13 @@
*/
#ifndef _LIBSPL_SYS_SYSTEMINFO_H
#define _LIBSPL_SYS_SYSTEMINFO_H
#define _LIBSPL_SYS_SYSTEMINFO_H
#define HW_INVALID_HOSTID 0xFFFFFFFF /* an invalid hostid */
#define HW_HOSTID_LEN 11 /* minimum buffer size needed */
#define HW_INVALID_HOSTID 0xFFFFFFFF /* an invalid hostid */
#define HW_HOSTID_LEN 11 /* minimum buffer size needed */
/* to hold a decimal or hex */
/* hostid string */
#define sysinfo(cmd,buf,cnt) (-1)
#define sysinfo(cmd, buf, cnt) (-1)
#endif
+1 -1
View File
@@ -25,6 +25,6 @@
*/
#ifndef _LIBSPL_SYS_SYSTM_H
#define _LIBSPL_SYS_SYSTM_H
#define _LIBSPL_SYS_SYSTM_H
#endif /* _LIBSPL_SYS_SYSTM_H */
+8 -8
View File
@@ -25,37 +25,37 @@
*/
#ifndef _LIBSPL_SYS_TIME_H
#define _LIBSPL_SYS_TIME_H
#define _LIBSPL_SYS_TIME_H
#include_next <sys/time.h>
#include <sys/types.h>
#ifndef SEC
#define SEC 1
#define SEC 1
#endif
#ifndef MILLISEC
#define MILLISEC 1000
#define MILLISEC 1000
#endif
#ifndef MICROSEC
#define MICROSEC 1000000
#define MICROSEC 1000000
#endif
#ifndef NANOSEC
#define NANOSEC 1000000000
#define NANOSEC 1000000000
#endif
#ifndef NSEC_PER_USEC
#define NSEC_PER_USEC 1000L
#define NSEC_PER_USEC 1000L
#endif
#ifndef MSEC2NSEC
#define MSEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MILLISEC))
#define MSEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MILLISEC))
#endif
#ifndef NSEC2MSEC
#define NSEC2MSEC(n) ((n) / (NANOSEC / MILLISEC))
#define NSEC2MSEC(n) ((n) / (NANOSEC / MILLISEC))
#endif
extern hrtime_t gethrtime(void);
+4 -4
View File
@@ -25,7 +25,7 @@
*/
#ifndef _LIBSPL_SYS_TYPES_H
#define _LIBSPL_SYS_TYPES_H
#define _LIBSPL_SYS_TYPES_H
#include <sys/isa_defs.h>
#include <sys/feature_tests.h>
@@ -53,9 +53,9 @@ typedef u_longlong_t u_offset_t;
typedef u_longlong_t len_t;
typedef longlong_t diskaddr_t;
typedef ulong_t pfn_t; /* page frame number */
typedef ulong_t pgcnt_t; /* number of pages */
typedef long spgcnt_t; /* signed number of pages */
typedef ulong_t pfn_t; /* page frame number */
typedef ulong_t pgcnt_t; /* number of pages */
typedef long spgcnt_t; /* signed number of pages */
typedef longlong_t hrtime_t;
typedef struct timespec timestruc_t;
+7 -7
View File
@@ -45,14 +45,14 @@
typedef struct iovec iovec_t;
typedef enum uio_rw {
UIO_READ = 0,
UIO_WRITE = 1,
UIO_READ = 0,
UIO_WRITE = 1,
} uio_rw_t;
typedef enum uio_seg {
UIO_USERSPACE = 0,
UIO_SYSSPACE = 1,
UIO_USERISPACE= 2,
UIO_USERSPACE = 0,
UIO_SYSSPACE = 1,
UIO_USERISPACE = 2,
} uio_seg_t;
typedef struct uio {
@@ -102,7 +102,7 @@ typedef struct xuio {
} xu_ext;
} xuio_t;
#define XUIO_XUZC_PRIV(xuio) xuio->xu_ext.xu_zc.xu_zc_priv
#define XUIO_XUZC_RW(xuio) xuio->xu_ext.xu_zc.xu_zc_rw
#define XUIO_XUZC_PRIV(xuio) xuio->xu_ext.xu_zc.xu_zc_priv
#define XUIO_XUZC_RW(xuio) xuio->xu_ext.xu_zc.xu_zc_rw
#endif /* _SYS_UIO_H */
+1 -1
View File
@@ -25,7 +25,7 @@
*/
#ifndef _LIBSPL_UTSNAME_H
#define _LIBSPL_UTSNAME_H
#define _LIBSPL_UTSNAME_H
#include_next <sys/utsname.h>
+1 -1
View File
@@ -25,7 +25,7 @@
*/
#ifndef _SYS_VA_LIST_H
#define _SYS_VA_LIST_H
#define _SYS_VA_LIST_H
#include <stdarg.h>
+1 -1
View File
@@ -25,6 +25,6 @@
*/
#ifndef _LIBSPL_SYS_VARARGS_H
#define _LIBSPL_SYS_VARARGS_H
#define _LIBSPL_SYS_VARARGS_H
#endif
+1 -1
View File
@@ -25,6 +25,6 @@
*/
#ifndef _LIBSPL_SYS_VNODE_H
#define _LIBSPL_SYS_VNODE_H
#define _LIBSPL_SYS_VNODE_H
#endif /* _LIBSPL_SYS_VNODE_H */
+1 -1
View File
@@ -25,6 +25,6 @@
*/
#ifndef _LIBSPL_SYS_ZONE_H
#define _LIBSPL_SYS_ZONE_H
#define _LIBSPL_SYS_ZONE_H
#endif
+1 -1
View File
@@ -25,6 +25,6 @@
*/
#ifndef _LIBSPL_THREAD_H
#define _LIBSPL_THREAD_H
#define _LIBSPL_THREAD_H
#endif /* _LIBSPL_THREAD_H */
+1 -1
View File
@@ -25,7 +25,7 @@
*/
#ifndef _LIBSPL_TZFILE_H
#define _LIBSPL_TZFILE_H
#define _LIBSPL_TZFILE_H
#include <sys/tzfile.h>
+1 -1
View File
@@ -25,7 +25,7 @@
*/
#ifndef _LIBSPL_UCRED_H
#define _LIBSPL_UCRED_H
#define _LIBSPL_UCRED_H
typedef int ucred_t;
+26 -23
View File
@@ -25,9 +25,10 @@
*/
#ifndef _LIBSPL_UMEM_H
#define _LIBSPL_UMEM_H
#define _LIBSPL_UMEM_H
/* XXX: We should use the real portable umem library if it is detected
/*
* XXX: We should use the real portable umem library if it is detected
* at configure time. However, if the library is not available, we can
* use a trivial malloc based implementation. This obviously impacts
* performance, but unless you are using a full userspace build of zpool for
@@ -48,18 +49,18 @@ typedef void vmem_t;
/*
* Flags for umem_alloc/umem_free
*/
#define UMEM_DEFAULT 0x0000 /* normal -- may fail */
#define UMEM_NOFAIL 0x0100 /* Never fails */
#define UMEM_DEFAULT 0x0000 /* normal -- may fail */
#define UMEM_NOFAIL 0x0100 /* Never fails */
/*
* Flags for umem_cache_create()
*/
#define UMC_NOTOUCH 0x00010000
#define UMC_NODEBUG 0x00020000
#define UMC_NOMAGAZINE 0x00040000
#define UMC_NOHASH 0x00080000
#define UMC_NOTOUCH 0x00010000
#define UMC_NODEBUG 0x00020000
#define UMC_NOMAGAZINE 0x00040000
#define UMC_NOHASH 0x00080000
#define UMEM_CACHE_NAMELEN 31
#define UMEM_CACHE_NAMELEN 31
typedef int umem_nofail_callback_t(void);
typedef int umem_constructor_t(void *, void *, int);
@@ -87,7 +88,7 @@ umem_alloc(size_t size, int flags)
ptr = malloc(size);
} while (ptr == NULL && (flags & UMEM_NOFAIL));
return ptr;
return (ptr);
}
static inline void *
@@ -105,10 +106,10 @@ umem_alloc_aligned(size_t size, size_t align, int flags)
__func__, align);
if (flags & UMEM_NOFAIL)
abort();
return NULL;
return (NULL);
}
return ptr;
return (ptr);
}
static inline void *
@@ -120,7 +121,7 @@ umem_zalloc(size_t size, int flags)
if (ptr)
memset(ptr, 0, size);
return ptr;
return (ptr);
}
static inline void
@@ -133,15 +134,16 @@ static inline void
umem_nofail_callback(umem_nofail_callback_t *cb) {}
static inline umem_cache_t *
umem_cache_create(char *name, size_t bufsize, size_t align,
umem_constructor_t *constructor,
umem_destructor_t *destructor,
umem_reclaim_t *reclaim,
void *priv, void *vmp, int cflags)
umem_cache_create(
char *name, size_t bufsize, size_t align,
umem_constructor_t *constructor,
umem_destructor_t *destructor,
umem_reclaim_t *reclaim,
void *priv, void *vmp, int cflags)
{
umem_cache_t *cp;
cp = umem_alloc(sizeof(umem_cache_t), UMEM_DEFAULT);
cp = umem_alloc(sizeof (umem_cache_t), UMEM_DEFAULT);
if (cp) {
strncpy(cp->cache_name, name, UMEM_CACHE_NAMELEN);
cp->cache_bufsize = bufsize;
@@ -154,13 +156,13 @@ umem_cache_create(char *name, size_t bufsize, size_t align,
cp->cache_cflags = cflags;
}
return cp;
return (cp);
}
static inline void
umem_cache_destroy(umem_cache_t *cp)
{
umem_free(cp, sizeof(umem_cache_t));
umem_free(cp, sizeof (umem_cache_t));
}
static inline void *
@@ -169,14 +171,15 @@ umem_cache_alloc(umem_cache_t *cp, int flags)
void *ptr;
if (cp->cache_align != 0)
ptr = umem_alloc_aligned(cp->cache_bufsize, cp->cache_align, flags);
ptr = umem_alloc_aligned(
cp->cache_bufsize, cp->cache_align, flags);
else
ptr = umem_alloc(cp->cache_bufsize, flags);
if (ptr && cp->cache_constructor)
cp->cache_constructor(ptr, cp->cache_private, UMEM_DEFAULT);
return ptr;
return (ptr);
}
static inline void
+11 -11
View File
@@ -27,21 +27,21 @@
#include_next <unistd.h>
#ifndef _LIBSPL_UNISTD_H
#define _LIBSPL_UNISTD_H
#define _LIBSPL_UNISTD_H
#if !defined(HAVE_IOCTL_IN_UNISTD_H)
# if defined(HAVE_IOCTL_IN_SYS_IOCTL_H)
# include <sys/ioctl.h>
# elif defined(HAVE_IOCTL_IN_STROPTS_H)
# include <stropts.h>
# else
# error "System call ioctl() unavailable"
# endif
#endif
#if defined(HAVE_IOCTL_IN_SYS_IOCTL_H)
#include <sys/ioctl.h>
#elif defined(HAVE_IOCTL_IN_STROPTS_H)
#include <stropts.h>
#else /* HAVE_IOCTL_IN_STROPTS_H */
#error "System call ioctl() unavailable"
#endif /* HAVE_IOCTL_IN_SYS_IOCTL_H */
#endif /* !HAVE_IOCTL_IN_UNISTD_H */
#if !defined(HAVE_ISSETUGID)
# include <sys/types.h>
# define issetugid() (geteuid() == 0 || getegid() == 0)
#include <sys/types.h>
#define issetugid() (geteuid() == 0 || getegid() == 0)
#endif
#endif /* _LIBSPL_UNISTD_H */
+1 -1
View File
@@ -25,6 +25,6 @@
*/
#ifndef _LIBSPL_UTIL_SSCANF_H
#define _LIBSPL_UTIL_SSCANF_H
#define _LIBSPL_UTIL_SSCANF_H
#endif
+2 -2
View File
@@ -36,8 +36,8 @@
extern "C" {
#endif
#define GLOBAL_ZONEID 0
#define GLOBAL_ZONEID_NAME "global"
#define GLOBAL_ZONEID 0
#define GLOBAL_ZONEID_NAME "global"
/*
* Functions for mapping between id and name for active zones.