X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Flibpspp%2Fll.h;h=9e6e35f04ad72ee4af7264883cf080bc49359ad0;hb=fc01177a9fccd839df87c5784abec33b69b4019c;hp=cb7ca2f93fb1c1282c52e9bf6fed2cb3538a7f85;hpb=f5c108becd49d78f4898cab11352291f5689d24e;p=pspp
diff --git a/src/libpspp/ll.h b/src/libpspp/ll.h
index cb7ca2f93f..9e6e35f04a 100644
--- a/src/libpspp/ll.h
+++ b/src/libpspp/ll.h
@@ -1,20 +1,18 @@
-/* PSPP - computes sample statistics.
- Copyright (C) 2006 Free Software Foundation, Inc.
+/* PSPP - a program for statistical analysis.
+ Copyright (C) 2006, 2009, 2011 Free Software Foundation, Inc.
- 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; either version 2 of the
- License, or (at your option) any later version.
+ 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, either version 3 of the License, or
+ (at your option) any later version.
- 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.
+ 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.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA. */
+ along with this program. If not, see . */
/* Circular doubly linked lists.
@@ -52,6 +50,7 @@
#include
#include
#include
+#include "libpspp/cast.h"
/* Embedded, circular doubly linked list.
@@ -110,8 +109,9 @@
/* Returns the data structure corresponding to the given node LL,
assuming that LL is embedded as the given MEMBER name in data
type STRUCT. */
-#define ll_data(LL, STRUCT, MEMBER) \
- ((STRUCT *) ((char *) (LL) - offsetof (STRUCT, MEMBER)))
+#define ll_data(LL, STRUCT, MEMBER) \
+ (CHECK_POINTER_HAS_TYPE(LL, struct ll *), \
+ UP_CAST(LL, STRUCT, MEMBER))
/* Linked list node. */
struct ll
@@ -338,9 +338,9 @@ struct ll *ll_find_partition (const struct ll *r0, const struct ll *r1,
#define ll_tail__(STRUCT, MEMBER, LIST) \
ll_data__ (ll_tail (LIST), STRUCT, MEMBER, LIST)
#define ll_next__(DATA, STRUCT, MEMBER, LIST) \
- ll_data__ (ll_next (&DATA->MEMBER), STRUCT, MEMBER, LIST)
+ ll_data__ (ll_next (&(DATA)->MEMBER), STRUCT, MEMBER, LIST)
#define ll_prev__(DATA, STRUCT, MEMBER, LIST) \
- ll_data__ (ll_prev (&DATA->MEMBER), STRUCT, MEMBER, LIST)
+ ll_data__ (ll_prev (&(DATA)->MEMBER), STRUCT, MEMBER, LIST)
/* Inline functions. */
@@ -380,7 +380,7 @@ ll_tail (const struct ll_list *list)
static inline struct ll *
ll_null (const struct ll_list *list)
{
- return (struct ll *) &list->null;
+ return CONST_CAST (struct ll *, &list->null);
}
/* Returns the node following LL in its list,