author | Mark J. Nelson <Mark.J.Nelson@Sun.COM> |
Wed, 06 Aug 2008 16:29:39 -0600 | |
changeset 7298 | b69e27387f74 |
parent 4292 | d7beef35913b |
child 7421 | 8b7f030a1d82 |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
4292
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
5 |
* Common Development and Distribution License (the "License"). |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
6 |
* You may not use this file except in compliance with the License. |
0 | 7 |
* |
8 |
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 |
* or http://www.opensolaris.org/os/licensing. |
|
10 |
* See the License for the specific language governing permissions |
|
11 |
* and limitations under the License. |
|
12 |
* |
|
13 |
* When distributing Covered Code, include this CDDL HEADER in each |
|
14 |
* file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 |
* If applicable, add the following below this CDDL HEADER, with the |
|
16 |
* fields enclosed by brackets "[]" replaced with your own identifying |
|
17 |
* information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 |
* |
|
19 |
* CDDL HEADER END |
|
20 |
*/ |
|
21 |
/* |
|
4292
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
22 |
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. |
0 | 23 |
* Use is subject to license terms. |
24 |
*/ |
|
25 |
||
7298
b69e27387f74
6733918 Teamware has retired, please welcome your new manager, Mercurial
Mark J. Nelson <Mark.J.Nelson@Sun.COM>
parents:
4292
diff
changeset
|
26 |
.file "byteorder.s" |
0 | 27 |
|
28 |
#include "SYS.h" |
|
29 |
||
4292
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
30 |
/* |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
31 |
* NOTE: htonl/ntohl are identical routines, as are htons/ntohs. |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
32 |
* As such, they could be implemented as a single routine, using |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
33 |
* multiple ALTENTRY/SET_SIZE definitions. We don't do this so |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
34 |
* that they will have unique addresses, allowing DTrace and |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
35 |
* other debuggers to tell them apart. |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
36 |
*/ |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
37 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
38 |
|
0 | 39 |
/* |
40 |
* unsigned long htonl( hl ) |
|
41 |
* unsigned long ntohl( hl ) |
|
42 |
* long hl; |
|
43 |
* reverses the byte order of 'uint32_t hl' |
|
44 |
*/ |
|
45 |
ENTRY(htonl) |
|
46 |
movl %edi, %eax /* %eax = hl */ |
|
47 |
bswap %eax /* reverses the byte order of %eax */ |
|
48 |
ret /* return (%eax) */ |
|
49 |
SET_SIZE(htonl) |
|
4292
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
50 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
51 |
ENTRY(ntohl) |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
52 |
movl %edi, %eax /* %eax = hl */ |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
53 |
bswap %eax /* reverses the byte order of %eax */ |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
54 |
ret /* return (%eax) */ |
0 | 55 |
SET_SIZE(ntohl) |
56 |
||
57 |
/* |
|
58 |
* unsigned short htons( hs ) |
|
59 |
* short hs; |
|
60 |
* |
|
61 |
* reverses the byte order in hs. |
|
62 |
*/ |
|
63 |
ENTRY(htons) |
|
64 |
movl %edi, %eax /* %eax = hs */ |
|
65 |
bswap %eax /* reverses the byte order of %eax */ |
|
66 |
shrl $16, %eax /* moves high 16-bit to low 16-bit */ |
|
67 |
ret /* return (%eax) */ |
|
68 |
SET_SIZE(htons) |
|
4292
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
69 |
|
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
70 |
ENTRY(ntohs) |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
71 |
movl %edi, %eax /* %eax = hs */ |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
72 |
bswap %eax /* reverses the byte order of %eax */ |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
73 |
shrl $16, %eax /* moves high 16-bit to low 16-bit */ |
d7beef35913b
6518331 Eliminate duplicate addresses from ON ELF symbol sort sections
ab196087
parents:
0
diff
changeset
|
74 |
ret /* return (%eax) */ |
0 | 75 |
SET_SIZE(ntohs) |