1 | /*␊ |
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.␊ |
3 | *␊ |
4 | * ␊ |
5 | * This file contains Original Code and/or Modifications of Original Code␊ |
6 | * as defined in and that are subject to the Apple Public Source License␊ |
7 | * Version 2.0 (the 'License'). You may not use this file except in␊ |
8 | * compliance with the License. Please obtain a copy of the License at␊ |
9 | * http://www.opensource.apple.com/apsl/ and read it before using this␊ |
10 | * file.␊ |
11 | * ␊ |
12 | * The Original Code and all software distributed under the License are␊ |
13 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER␊ |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,␊ |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,␊ |
16 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.␊ |
17 | * Please see the License for the specific language governing rights and␊ |
18 | * limitations under the License.␊ |
19 | * ␊ |
20 | * Copyright (c) 1996 NeXT Software, Inc.␊ |
21 | *␊ |
22 | *␉File:␉architecture/ppc/alignment.h␊ |
23 | ␊ |
24 | * Natural alignment of shorts and longs (for ppc)␊ |
25 | *␊ |
26 | * HISTORY␊ |
27 | *␊ |
28 | * 29-Dec-96 Umesh Vaishampayan (umeshv@NeXT.com)␊ |
29 | *␉Ported from m98k.␊ |
30 | * 2 Sept 1992 Brian Raymor at NeXT␊ |
31 | * Moved over to architecture.␊ |
32 | * 17 August 1992 Jack Greenfield at NeXT␊ |
33 | *␉Created.␊ |
34 | */␊ |
35 | ␊ |
36 | __inline__ static unsigned short ␊ |
37 | get_align_short(void *ivalue)␊ |
38 | {␊ |
39 | unsigned short␉ovalue = ((unsigned char *) ivalue)[0];␊ |
40 | ␊ |
41 | ovalue <<= 8 * sizeof(unsigned char);␊ |
42 | return ovalue + ((unsigned char *) ivalue)[1];␊ |
43 | }␊ |
44 | ␊ |
45 | __inline__ static unsigned short ␊ |
46 | put_align_short(unsigned short ivalue, void *ovalue)␊ |
47 | {␊ |
48 | unsigned short␉*tvalue = &ivalue;␊ |
49 | ␊ |
50 | ((unsigned char *) ovalue)[0] = ((unsigned char *) tvalue)[0];␊ |
51 | ((unsigned char *) ovalue)[1] = ((unsigned char *) tvalue)[1];␊ |
52 | return ivalue;␊ |
53 | }␊ |
54 | ␊ |
55 | __inline__ static unsigned long ␊ |
56 | get_align_long(void *ivalue)␊ |
57 | {␊ |
58 | unsigned long␉ovalue = get_align_short(ivalue);␊ |
59 | ␊ |
60 | ovalue <<= 8 * sizeof(unsigned short);␊ |
61 | return ovalue + get_align_short(((unsigned char *) ivalue) + sizeof(short));␊ |
62 | }␊ |
63 | ␊ |
64 | __inline__ static unsigned long ␊ |
65 | put_align_long(unsigned long ivalue, void *ovalue)␊ |
66 | {␊ |
67 | unsigned long␉*tvalue = &ivalue;␊ |
68 | ␊ |
69 | ((unsigned char *) ovalue)[0] = ((unsigned char *) tvalue)[0];␊ |
70 | ((unsigned char *) ovalue)[1] = ((unsigned char *) tvalue)[1];␊ |
71 | ((unsigned char *) ovalue)[2] = ((unsigned char *) tvalue)[2];␊ |
72 | ((unsigned char *) ovalue)[3] = ((unsigned char *) tvalue)[3];␊ |
73 | return ivalue;␊ |
74 | }␊ |
75 | ␊ |
76 | |