allow specification of names for in parameters in spec file
[libfirm] / ir / adt / offset.h
index 6f797a6..70e74d1 100644 (file)
@@ -1,16 +1,30 @@
-/**
- * @file   offset.h
- * @date   31.05.2005
- * @author Sebastian Hack
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
  *
- * Firm's own offset_of and container_of
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
  *
- * Copyright (C) 2005 Universitaet Karlsruhe
- * Released under the GPL
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
  */
 
-#ifndef _OFFSET_H
-#define _OFFSET_H
+/**
+ * @file
+ * @brief  Implementation of offset_of and container_of
+ * @date   31.05.2005
+ * @author Sebastian Hack
+ */
+#ifndef FIRM_ADT_OFFSET_H
+#define FIRM_ADT_OFFSET_H
 
 /**
  * Get the offset of a member of a struct.
@@ -18,8 +32,7 @@
  * @param member The name of the member.
  * @return       The offset of member in type in bytes.
  */
-#define offset_of(type, member) \
-  ((char *) &(((type *) 0)->member) - (char *) 0)
+#define firm_offset_of(type, member)           ((char *) &((type *) 0)->member - (char *) 0)
 
 /**
  * Make pointer to the struct from a pointer to a member of that struct.
@@ -28,7 +41,6 @@
  * @param member  The name of the member.
  * @return        A pointer to the struct member is in.
  */
-#define container_of(ptr, type, member) \
-       ((type *) ((char *) (ptr) - offset_of(type, member)))
+#define firm_container_of(ptr, type, member)           ((type *) ((char *) (ptr) - firm_offset_of(type, member)))
 
-#endif /* _OFFSET_H */
+#endif