11.4Suebayasi/*	$NetBSD: byte_swap_2.S,v 1.4 2014/05/23 03:17:31 uebayasi Exp $	*/
21.1Schristos
31.1Schristos/*-
41.1Schristos * Copyright (c) 1990 The Regents of the University of California.
51.1Schristos * All rights reserved.
61.1Schristos *
71.1Schristos * This code is derived from software contributed to Berkeley by
81.1Schristos * William Jolitz.
91.1Schristos *
101.1Schristos * Redistribution and use in source and binary forms, with or without
111.1Schristos * modification, are permitted provided that the following conditions
121.1Schristos * are met:
131.1Schristos * 1. Redistributions of source code must retain the above copyright
141.1Schristos *    notice, this list of conditions and the following disclaimer.
151.1Schristos * 2. Redistributions in binary form must reproduce the above copyright
161.1Schristos *    notice, this list of conditions and the following disclaimer in the
171.1Schristos *    documentation and/or other materials provided with the distribution.
181.1Schristos * 3. Neither the name of the University nor the names of its contributors
191.1Schristos *    may be used to endorse or promote products derived from this software
201.1Schristos *    without specific prior written permission.
211.1Schristos *
221.1Schristos * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
231.1Schristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
241.1Schristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
251.1Schristos * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
261.1Schristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
271.1Schristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
281.1Schristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
291.1Schristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
301.1Schristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
311.1Schristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
321.1Schristos * SUCH DAMAGE.
331.1Schristos *
341.1Schristos *	from: @(#)htons.s	5.2 (Berkeley) 12/17/90
351.1Schristos */
361.1Schristos
371.1Schristos#include <machine/asm.h>
381.1Schristos#if defined(LIBC_SCCS)
391.4Suebayasi	RCSID("$NetBSD: byte_swap_2.S,v 1.4 2014/05/23 03:17:31 uebayasi Exp $")
401.1Schristos#endif
411.1Schristos
421.2Syamt#if defined(_KERNEL) || defined(_STANDALONE)
431.2Syamt_ENTRY(_C_LABEL(bswap16))
441.2Syamt#else /* defined(_KERNEL) || defined(_STANDALONE) */
451.1Schristos_ENTRY(_C_LABEL(__bswap16))
461.2Syamt#endif /* defined(_KERNEL) || defined(_STANDALONE) */
471.1Schristos_ENTRY(_C_LABEL(ntohs))
481.1Schristos_ENTRY(_C_LABEL(htons))
491.1Schristos_PROF_PROLOGUE
501.1Schristos	movzwl	4(%esp),%eax
511.3Sad	xchgb	%al, %ah
521.1Schristos	ret
531.4Suebayasi#if defined(_KERNEL) || defined(_STANDALONE)
541.4SuebayasiEND(_C_LABEL(bswap16))
551.4Suebayasi#else /* defined(_KERNEL) || defined(_STANDALONE) */
561.4SuebayasiEND(_C_LABEL(__bswap16))
571.4Suebayasi#endif /* defined(_KERNEL) || defined(_STANDALONE) */
581.4SuebayasiEND(_C_LABEL(ntohs))
591.4SuebayasiEND(_C_LABEL(htons))
60