Files
scst/iscsi-scst/usr/misc.h
T
Bart Van Assche 1c71987ad6 Merge branch 'svn-iser'
Conflicts:
	Makefile
	fcst/Makefile
	iscsi-scst/Makefile
	iscsi-scst/include/iscsi_scst.h
	iscsi-scst/include/iscsi_scst_ver.h
	iscsi-scst/kernel/Makefile
	iscsi-scst/kernel/config.c
	iscsi-scst/kernel/conn.c
	iscsi-scst/kernel/digest.c
	iscsi-scst/kernel/digest.h
	iscsi-scst/kernel/event.c
	iscsi-scst/kernel/iscsi.c
	iscsi-scst/kernel/iscsi.h
	iscsi-scst/kernel/iscsi_dbg.h
	iscsi-scst/kernel/iscsi_hdr.h
	iscsi-scst/kernel/nthread.c
	iscsi-scst/kernel/param.c
	iscsi-scst/kernel/session.c
	iscsi-scst/kernel/target.c
	iscsi-scst/usr/Makefile
	iscsi-scst/usr/chap.c
	iscsi-scst/usr/config.c
	iscsi-scst/usr/conn.c
	iscsi-scst/usr/ctldev.c
	iscsi-scst/usr/event.c
	iscsi-scst/usr/iscsi_adm.c
	iscsi-scst/usr/iscsi_adm.h
	iscsi-scst/usr/iscsi_hdr.h
	iscsi-scst/usr/iscsi_scstd.c
	iscsi-scst/usr/iscsid.c
	iscsi-scst/usr/iscsid.h
	iscsi-scst/usr/isns.c
	iscsi-scst/usr/isns_proto.h
	iscsi-scst/usr/log.c
	iscsi-scst/usr/message.c
	iscsi-scst/usr/misc.c
	iscsi-scst/usr/misc.h
	iscsi-scst/usr/param.c
	iscsi-scst/usr/param.h
	iscsi-scst/usr/session.c
	iscsi-scst/usr/target.c
	iscsi-scst/usr/types.h
	nightly/conf/nightly.conf
	qla2x00t/qla2x00-target/Makefile
	qla2x00t/qla2x00-target/README
	qla2x00t/qla2x00-target/qla2x00t.c
	qla2x00t/qla2x00-target/qla2x00t.h
	qla2x00t/qla2x_tgt.h
	qla2x00t/qla2x_tgt_def.h
	qla2x00t/qla_attr.c
	qla2x00t/qla_init.c
	qla2x00t/qla_inline.h
	qla2x00t/qla_isr.c
	qla2x00t/qla_mbx.c
	qla2x00t/qla_os.c
	scripts/generate-release-archive
	scripts/rebuild-rhel-kernel-rpm
	scripts/run-regression-tests
	scst.spec.in
	scst/Makefile
	scst/README
	scst/README_in-tree
	scst/include/scst.h
	scst/include/scst_const.h
	scst/include/scst_debug.h
	scst/include/scst_sgv.h
	scst/include/scst_user.h
	scst/src/Makefile
	scst/src/dev_handlers/Makefile
	scst/src/dev_handlers/scst_cdrom.c
	scst/src/dev_handlers/scst_changer.c
	scst/src/dev_handlers/scst_disk.c
	scst/src/dev_handlers/scst_modisk.c
	scst/src/dev_handlers/scst_processor.c
	scst/src/dev_handlers/scst_raid.c
	scst/src/dev_handlers/scst_tape.c
	scst/src/dev_handlers/scst_user.c
	scst/src/dev_handlers/scst_vdisk.c
	scst/src/scst_debug.c
	scst/src/scst_lib.c
	scst/src/scst_main.c
	scst/src/scst_mem.c
	scst/src/scst_mem.h
	scst/src/scst_module.c
	scst/src/scst_pres.c
	scst/src/scst_pres.h
	scst/src/scst_priv.h
	scst/src/scst_proc.c
	scst/src/scst_sysfs.c
	scst/src/scst_targ.c
	scst/src/scst_tg.c
	scst_local/scst_local.c
	srpt/Makefile
	srpt/README
	srpt/README.ofed
	srpt/conftest/gid_change/Makefile
	srpt/src/ib_srpt.c
	srpt/src/ib_srpt.h
	usr/fileio/Makefile
	usr/fileio/common.c
	usr/fileio/common.h
	usr/fileio/debug.c
	usr/fileio/debug.h
	usr/fileio/fileio.c
	www/comparison.html
	www/contributing.html
	www/downloads.html
	www/handler_fileio_tgt.html
	www/index.html
	www/mc_s.html
	www/scst_admin.html
	www/scstvslio.html
	www/scstvsstgt.html
	www/solutions.html
	www/target_emulex.html
	www/target_fcoe.html
	www/target_ibmvscsi.html
	www/target_iscsi.html
	www/target_local.html
	www/target_lsi.html
	www/target_mvsas.html
	www/target_old.html
	www/target_qla2x00t.html
	www/target_srp.html
	www/targets.html
	www/users.html
2015-05-03 19:07:39 +02:00

113 lines
3.2 KiB
C

/*
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, version 2
* of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef MISC_H
#define MISC_H
struct __qelem {
struct __qelem *q_forw;
struct __qelem *q_back;
};
/* stolen list stuff from Linux kernel */
#undef offsetof
#ifdef __compiler_offsetof
#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
#else
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
#define LIST_HEAD_INIT(name) { &(name), &(name) }
#define LIST_HEAD(name) \
struct __qelem name = LIST_HEAD_INIT(name)
#define INIT_LIST_HEAD(ptr) do { \
(ptr)->q_forw = (ptr); (ptr)->q_back = (ptr); \
} while (0)
static inline int list_empty(const struct __qelem *head)
{
return head->q_forw == head;
}
static inline int list_length_is_one(const struct __qelem *head)
{
return (!list_empty(head) && head->q_forw == head->q_back);
}
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
#define list_entry(ptr, type, member) \
container_of(ptr, type, member)
#define list_for_each_entry(pos, head, member) \
for (pos = list_entry((head)->q_forw, typeof(*pos), member); \
&pos->member != (head); \
pos = list_entry(pos->member.q_forw, typeof(*pos), member))
#define list_for_each_entry_safe(pos, n, head, member) \
for (pos = list_entry((head)->q_forw, typeof(*pos), member), \
n = list_entry(pos->member.q_forw, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = list_entry(n->member.q_forw, typeof(*n), member))
#define list_del(elem) remque(elem)
#define list_del_init(elem) do { \
remque(elem); \
INIT_LIST_HEAD(elem); \
} while (0)
#define list_add(new, head) insque (new, head)
#define list_add_tail(new, head) insque(new, (head)->q_back)
/* min()/max() that do strict type-checking. Lifted from the kernel. */
#define min(x, y) ({ \
typeof(x) _min1 = (x); \
typeof(y) _min2 = (y); \
(void) (&_min1 == &_min2); \
_min1 < _min2 ? _min1 : _min2; })
#define max(x, y) ({ \
typeof(x) _max1 = (x); \
typeof(y) _max2 = (y); \
(void) (&_max1 == &_max2); \
_max1 > _max2 ? _max1 : _max2; })
/* ... and their non-checking counterparts, also taken from the kernel. */
#define min_t(type, x, y) ({ \
type __min1 = (x); \
type __min2 = (y); \
__min1 < __min2 ? __min1: __min2; })
#define max_t(type, x, y) ({ \
type __max1 = (x); \
type __max2 = (y); \
__max1 > __max2 ? __max1: __max2; })
#ifndef IPV6_V6ONLY
#define IPV6_V6ONLY 26
#endif
extern void set_non_blocking(int fd);
extern void sock_set_keepalive(int sock, int timeout);
extern int create_and_open_dev(const char *dev, int readonly);
#endif