Print this page
5007142 Add ntohll and htonll to sys/byteorder.h
6717509 Need to use bswap/bswapq for byte swap of 64-bit integer on x32/x64
PSARC 2008/474

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libc/sparc/gen/byteorder.c
          +++ new/usr/src/lib/libc/sparc/gen/byteorder.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23      - * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
       23 + * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  28      -
  29   27  #include <sys/isa_defs.h>
  30   28  #include <sys/types.h>
  31   29  
  32   30  
  33   31  #if defined(_LITTLE_ENDIAN) && !defined(__lint)
  34   32  
  35   33  #error  Use ISA-specific byteorder.s on a little-endian machine.
  36   34  
  37   35  #else   /* !_LITTLE_ENDIAN */
  38   36  
       37 +/*
       38 + * htonll(), ntohll(), htonl(), ntohl(), htons(), ntohs()
       39 + * These functions just return the input parameter, as the host
       40 + * byte order is the same as the network byte order (big endian).
       41 + * On little endian machines, these functions byte swap.
       42 + */
       43 +
       44 +uint64_t
       45 +htonll(uint64_t in)
       46 +{
       47 +        return (in);
       48 +}
       49 +
       50 +uint64_t
       51 +ntohll(uint64_t in)
       52 +{
       53 +        return (in);
       54 +}
       55 +
  39   56  uint32_t
  40   57  htonl(uint32_t in)
  41   58  {
  42   59          return (in);
  43   60  }
  44   61  
  45   62  uint32_t
  46   63  ntohl(uint32_t in)
  47   64  {
  48   65          return (in);
↓ open down ↓ 15 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX