Files
glibc/inet/htons.c
T

37 lines
1.1 KiB
C
Raw Normal View History

/* Copyright (C) 1993,97,2002 Free Software Foundation, Inc.
1997-02-27 06:01:16 +00:00
This file is part of the GNU C Library.
1995-02-18 01:27:10 +00:00
1997-02-27 06:01:16 +00:00
The GNU C Library is free software; you can redistribute it and/or
2001-07-06 04:58:11 +00:00
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
1995-02-18 01:27:10 +00:00
1997-02-27 06:01:16 +00:00
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2001-07-06 04:58:11 +00:00
Lesser General Public License for more details.
1995-02-18 01:27:10 +00:00
2001-07-06 04:58:11 +00:00
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
1995-02-18 01:27:10 +00:00
#include <netinet/in.h>
#undef htons
1997-07-24 01:36:01 +00:00
#undef ntohs
1995-02-18 01:27:10 +00:00
uint16_t
1997-07-28 22:35:20 +00:00
htons (x)
uint16_t x;
1995-02-18 01:27:10 +00:00
{
1997-07-24 01:36:01 +00:00
#if BYTE_ORDER == BIG_ENDIAN
1995-02-18 01:27:10 +00:00
return x;
1997-07-24 01:36:01 +00:00
#elif BYTE_ORDER == LITTLE_ENDIAN
return __bswap_16 (x);
#else
# error "What kind of system is this?"
#endif
1995-02-18 01:27:10 +00:00
}
1997-07-24 01:36:01 +00:00
weak_alias (htons, ntohs)