1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

root/trunk/common/_elftc.h @ 2221

Revision 2221, 5.2 KB (checked in by jkoshy, 2 years ago)

Support builds on Minix3.

Ticket: #364

  • Property svn:keywords set to Id
Line 
1/*-
2 * Copyright (c) 2009 Joseph Koshy
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $Id$
27 */
28
29/**
30 ** Miscellanous definitions needed by multiple components.
31 **/
32
33#ifndef _ELFTC_H
34#define _ELFTC_H
35
36#ifndef NULL
37#define NULL    ((void *) 0)
38#endif
39
40#ifndef offsetof
41#define offsetof(T, M)          ((int) &((T*) 0) -> M)
42#endif
43
44/*
45 * Supply macros missing from <sys/queue.h>
46 */
47
48#ifndef STAILQ_FOREACH_SAFE
49#define STAILQ_FOREACH_SAFE(var, head, field, tvar)            \
50       for ((var) = STAILQ_FIRST((head));                      \
51            (var) && ((tvar) = STAILQ_NEXT((var), field), 1);  \
52            (var) = (tvar))
53#endif
54
55#ifndef STAILQ_LAST
56#define STAILQ_LAST(head, type, field)                                  \
57        (STAILQ_EMPTY((head)) ?                                         \
58                NULL :                                                  \
59                ((struct type *)(void *)                                \
60                ((char *)((head)->stqh_last) - offsetof(struct type, field))))
61#endif
62
63#ifndef TAILQ_FOREACH_SAFE
64#define TAILQ_FOREACH_SAFE(var, head, field, tvar)                      \
65        for ((var) = TAILQ_FIRST((head));                               \
66            (var) && ((tvar) = TAILQ_NEXT((var), field), 1);            \
67            (var) = (tvar))
68#endif
69
70/*
71 * VCS Ids.
72 */
73
74#ifndef ELFTC_VCSID
75
76#if defined(__DragonFly__)
77#define ELFTC_VCSID(ID)         __RCSID(ID)
78#endif
79
80#if defined(__FreeBSD__)
81#define ELFTC_VCSID(ID)         __FBSDID(ID)
82#endif
83
84#if defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)
85#if defined(__GNUC__)
86#define ELFTC_VCSID(ID)         __asm__(".ident\t\"" ID "\"")
87#else
88#define ELFTC_VCSID(ID)         /**/
89#endif
90#endif
91
92#if defined(__minix)
93#if defined(__GNUC__)
94#define ELFTC_VCSID(ID)         __asm__(".ident\t\"" ID "\"")
95#else
96#define ELFTC_VCSID(ID)         /**/
97#endif  /* __GNU__ */
98#endif
99
100#if defined(__NetBSD__)
101#define ELFTC_VCSID(ID)         __RCSID(ID)
102#endif
103
104#endif  /* ELFTC_VCSID */
105
106/*
107 * Provide an equivalent for getprogname(3).
108 */
109
110#ifndef ELFTC_GETPROGNAME
111
112#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__)
113
114#include <stdlib.h>
115
116#define ELFTC_GETPROGNAME()     getprogname()
117
118#endif  /* defined(__FreeBSD__) || defined(__NetBSD__) */
119
120
121#if defined(__linux__)
122
123/*
124 * GLIBC based systems have a global 'char *' pointer referencing
125 * the executable's name.
126 */
127extern const char *program_invocation_short_name;
128
129#define ELFTC_GETPROGNAME()     program_invocation_short_name
130
131#endif  /* __linux__ */
132
133#endif  /* ELFTC_GETPROGNAME */
134
135
136/**
137 ** Per-OS configuration.
138 **/
139
140#if defined(__DragonFly__)
141
142#include <osreldate.h>
143#include <sys/endian.h>
144
145#define ELFTC_BYTE_ORDER                        _BYTE_ORDER
146#define ELFTC_BYTE_ORDER_LITTLE_ENDIAN          _LITTLE_ENDIAN
147#define ELFTC_BYTE_ORDER_BIG_ENDIAN             _BIG_ENDIAN
148
149#endif
150
151#if defined(__linux__)
152
153#include <endian.h>
154
155#define ELFTC_BYTE_ORDER                        __BYTE_ORDER
156#define ELFTC_BYTE_ORDER_LITTLE_ENDIAN          __LITTLE_ENDIAN
157#define ELFTC_BYTE_ORDER_BIG_ENDIAN             __BIG_ENDIAN
158
159/*
160 * Debian GNU/Linux is missing strmode(3).
161 */
162#define ELFTC_HAVE_STRMODE                      0
163
164/* Whether we need to supply {be,le}32dec. */
165#define ELFTC_NEED_BYTEORDER_EXTENSIONS         1
166
167#define roundup2        roundup
168
169#endif  /* __linux__ */
170
171
172#if defined(__FreeBSD__)
173
174#include <osreldate.h>
175#include <sys/endian.h>
176
177#define ELFTC_BYTE_ORDER                        _BYTE_ORDER
178#define ELFTC_BYTE_ORDER_LITTLE_ENDIAN          _LITTLE_ENDIAN
179#define ELFTC_BYTE_ORDER_BIG_ENDIAN             _BIG_ENDIAN
180
181#define ELFTC_HAVE_STRMODE                      1
182#if __FreeBSD_version <= 900000
183#define ELFTC_BROKEN_YY_NO_INPUT                1
184#endif
185#endif  /* __FreeBSD__ */
186
187
188#if defined(__NetBSD__)
189
190#include <sys/param.h>
191#include <sys/endian.h>
192
193#define ELFTC_BYTE_ORDER                        _BYTE_ORDER
194#define ELFTC_BYTE_ORDER_LITTLE_ENDIAN          _LITTLE_ENDIAN
195#define ELFTC_BYTE_ORDER_BIG_ENDIAN             _BIG_ENDIAN
196
197#define ELFTC_HAVE_STRMODE                      1
198#if __NetBSD_Version__ <= 599002100
199/* from src/doc/CHANGES: flex(1): Import flex-2.5.35 [christos 20091025] */
200/* and 5.99.21 was from Wed Oct 21 21:28:36 2009 UTC */
201#  define ELFTC_BROKEN_YY_NO_INPUT              1
202#endif
203#endif  /* __NetBSD __ */
204
205#endif  /* _ELFTC_H */
Note: See TracBrowser for help on using the browser.