1/*
2 * @TAG(OTHER_GPL)
3 */
4
5/*
6 * (C) Copyright 2000-2009
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8 *
9 * See file CREDITS for list of people who contributed to this
10 * project.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * MA 02111-1307 USA
26 */
27#ifndef __COMMON_H_
28#define __COMMON_H_	1
29
30#undef	_LINUX_CONFIG_H
31#define _LINUX_CONFIG_H 1	/* avoid reading Linux autoconf.h file	*/
32
33#include "config.h"
34#include "../unimplemented.h"
35
36
37#ifdef CONFIG_POST
38#define CONFIG_HAS_POST
39#ifndef CONFIG_POST_ALT_LIST
40#define CONFIG_POST_STD_LIST
41#endif
42#endif
43
44#ifdef CONFIG_INIT_CRITICAL
45#error CONFIG_INIT_CRITICAL is deprecated!
46#error Read section CONFIG_SKIP_LOWLEVEL_INIT in README.
47#endif
48
49
50#define ROUND(a,b)		(((a) + (b) - 1) & ~((b) - 1))
51#define roundup(x, y)		((((x) + ((y) - 1)) / (y)) * (y))
52
53#define __ALIGN_MASK(x,mask)	(((x)+(mask))&~(mask))
54
55
56
57#ifdef ETH_DEBUG
58#define _DEBUG	1
59#else
60#define _DEBUG	0
61#endif
62
63/*
64 * Output a debug text when condition "cond" is met. The "cond" should be
65 * computed by a preprocessor in the best case, allowing for the best
66 * optimization.
67 */
68#define debug_cond(cond, fmt, args...)		\
69	do {					\
70		if (cond)			\
71			printf(fmt, ##args);	\
72	} while (0)
73
74#define debug(fmt, args...)			\
75	debug_cond(_DEBUG, fmt, ##args)
76
77/**
78 * container_of - cast a member of a structure out to the containing structure
79 * @ptr:	the pointer to the member.
80 * @type:	the type of the container struct this is embedded in.
81 * @member:	the name of the member within the struct.
82 *
83 */
84#define container_of(ptr, type, member) ({			\
85	const typeof( ((type *)0)->member ) *__mptr = (ptr);	\
86	(type *)( (char *)__mptr - offsetof(type,member) );})
87
88
89#endif	/* __COMMON_H_ */
90