1 |
|
/* |
2 |
|
* ether_defs.h - Definitions for DLPI Ethernet Driver |
3 |
|
* |
4 |
< |
* SheepShaver (C) 1997-2004 Marc Hellwig and Christian Bauer |
4 |
> |
* SheepShaver (C) 1997-2008 Marc Hellwig and Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
22 |
|
#define ETHER_DEFS_H |
23 |
|
|
24 |
|
|
25 |
< |
#if __BEOS__ && __POWERPC__ |
25 |
> |
#if __MWERKS__ && __POWERPC__ |
26 |
|
#define PRAGMA_ALIGN_SUPPORTED 1 |
27 |
|
#define PACKED__ |
28 |
< |
#else |
28 |
> |
#elif defined __GNUC__ |
29 |
|
#define PACKED__ __attribute__ ((packed)) |
30 |
+ |
#elif defined __sgi |
31 |
+ |
#define PRAGMA_PACK_SUPPORTED 1 |
32 |
+ |
#define PACKED__ |
33 |
+ |
#else |
34 |
+ |
#error "Packed attribute or pragma shall be supported" |
35 |
|
#endif |
36 |
|
|
37 |
|
|
197 |
|
* Data member wrappers |
198 |
|
*/ |
199 |
|
|
200 |
+ |
// Forward declarations |
201 |
+ |
struct datab; |
202 |
+ |
struct msgb; |
203 |
+ |
struct queue; |
204 |
+ |
struct multicast_node; |
205 |
+ |
struct DLPIStream; |
206 |
+ |
|
207 |
+ |
// Optimize for 32-bit big endian targets |
208 |
+ |
#if defined(WORDS_BIGENDIAN) && (SIZEOF_VOID_P == 4) |
209 |
+ |
|
210 |
+ |
// Predefined member types |
211 |
+ |
typedef int8 nw_int8; |
212 |
+ |
typedef int16 nw_int16; |
213 |
+ |
typedef int32 nw_int32; |
214 |
+ |
typedef uint8 nw_uint8; |
215 |
+ |
typedef uint16 nw_uint16; |
216 |
+ |
typedef uint32 nw_uint32; |
217 |
+ |
typedef int nw_bool; |
218 |
+ |
typedef uint8 * nw_uint8_p; |
219 |
+ |
typedef void * nw_void_p; |
220 |
+ |
typedef datab * nw_datab_p; |
221 |
+ |
typedef msgb * nw_msgb_p; |
222 |
+ |
typedef queue * nw_queue_p; |
223 |
+ |
typedef multicast_node *nw_multicast_node_p; |
224 |
+ |
typedef DLPIStream * nw_DLPIStream_p; |
225 |
+ |
|
226 |
+ |
#else |
227 |
+ |
|
228 |
|
// Big-endian memory accessor |
229 |
|
template< int nbytes > |
230 |
|
struct nw_memory_helper; |
253 |
|
uint8 _pad[sizeof(type)]; |
254 |
|
public: |
255 |
|
operator public_type () const { |
256 |
< |
return (public_type)nw_memory_helper<sizeof(type)>::load((void *)this); |
256 |
> |
return (public_type)(uintptr)nw_memory_helper<sizeof(type)>::load((void *)this); |
257 |
|
} |
258 |
|
public_type operator -> () const { |
259 |
|
return this->operator public_type (); |
260 |
|
} |
261 |
|
nw_scalar_member_helper<type, public_type> & operator = (public_type val) { |
262 |
< |
nw_memory_helper<sizeof(type)>::store((void *)this, (type)val); |
262 |
> |
nw_memory_helper<sizeof(type)>::store((void *)this, (type)(uintptr)val); |
263 |
|
return *this; |
264 |
|
} |
265 |
|
nw_scalar_member_helper<type, public_type> & operator += (int val) { |
290 |
|
typedef nw_scalar_member_helper<int, bool> nw_bool; |
291 |
|
typedef nw_scalar_member_helper<uint32, uint8 *> nw_uint8_p; |
292 |
|
typedef nw_scalar_member_helper<uint32, void *> nw_void_p; |
260 |
– |
|
261 |
– |
struct datab; |
293 |
|
typedef nw_scalar_member_helper<uint32, datab *> nw_datab_p; |
263 |
– |
|
264 |
– |
struct msgb; |
294 |
|
typedef nw_scalar_member_helper<uint32, msgb *> nw_msgb_p; |
266 |
– |
|
267 |
– |
struct queue; |
295 |
|
typedef nw_scalar_member_helper<uint32, queue *> nw_queue_p; |
269 |
– |
|
270 |
– |
struct multicast_node; |
296 |
|
typedef nw_scalar_member_helper<uint32, multicast_node *> nw_multicast_node_p; |
272 |
– |
|
273 |
– |
struct DLPIStream; |
297 |
|
typedef nw_scalar_member_helper<uint32, DLPIStream *> nw_DLPIStream_p; |
298 |
|
|
299 |
+ |
#endif |
300 |
+ |
|
301 |
|
|
302 |
|
/* |
303 |
|
* Structures |
517 |
|
#pragma options align=mac68k |
518 |
|
#endif |
519 |
|
|
520 |
+ |
#ifdef PRAGMA_PACK_SUPPORTED |
521 |
+ |
#pragma pack(1) |
522 |
+ |
#endif |
523 |
+ |
|
524 |
|
// Packet headers |
525 |
|
struct EnetPacketHeader { |
526 |
|
uint8 fDestAddr[6]; |
552 |
|
uint8 fSNAP[k8022SNAPLength]; |
553 |
|
} PACKED__; |
554 |
|
|
555 |
+ |
#ifdef PRAGMA_PACK_SUPPORTED |
556 |
+ |
#pragma pack(0) |
557 |
+ |
#endif |
558 |
+ |
|
559 |
|
#ifdef PRAGMA_ALIGN_SUPPORTED |
560 |
|
#pragma options align=reset |
561 |
|
#endif |