Changeset bfd7aac in mainline for uspace/srv/net/include/byteorder.h


Ignore:
Timestamp:
2010-02-17T19:19:08Z (14 years ago)
Author:
Lukas Mejdrech <lukasmejdrech@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1e2e0c1e
Parents:
01a9ef5 (diff), b8da2a3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/include/byteorder.h

    r01a9ef5 rbfd7aac  
    3939
    4040#include <byteorder.h>
    41 
    4241#include <sys/types.h>
    4342
    44 #ifdef ARCH_IS_BIG_ENDIAN
    4543
    46 // Already in the network byte order.
     44/** Converts the given short number ( 16 bit ) from the host byte order to the network byte order ( big endian ).
     45 *  @param[in] number The number in the host byte order to be converted.
     46 *  @returns The number in the network byte order.
     47 */
     48#define htons( number )         host2uint16_t_be( number )
    4749
    48         /** Converts the given short number ( 16 bit ) from the host byte order to the network byte order ( big endian ).
    49         *  @param[in] number The number in the host byte order to be converted.
    50         *  @returns The number in the network byte order.
    51         */
    52         #define htons( number )         ( number )
     50/** Converts the given long number ( 32 bit ) from the host byte order to the network byte order ( big endian ).
     51 *  @param[in] number The number in the host byte order to be converted.
     52 *  @returns The number in the network byte order.
     53 */
     54#define htonl( number )         host2uint32_t_be( number )
    5355
    54         /** Converts the given long number ( 32 bit ) from the host byte order to the network byte order ( big endian ).
    55          *  @param[in] number The number in the host byte order to be converted.
    56          *  @returns The number in the network byte order.
    57         */
    58         #define htonl( number )         ( number )
     56/** Converts the given short number ( 16 bit ) from the network byte order ( big endian ) to the host byte order.
     57 *  @param[in] number The number in the network byte order to be converted.
     58 *  @returns The number in the host byte order.
     59 */
     60#define ntohs( number )         uint16_t_be2host( number )
    5961
    60         /** Converts the given short number ( 16 bit ) from the network byte order ( big endian ) to the host byte order.
    61          *  @param[in] number The number in the network byte order to be converted.
    62          *  @returns The number in the host byte order.
    63          */
    64         #define ntohs( number )         ( number )
    65 
    66         /** Converts the given long number ( 32 bit ) from the network byte order ( big endian ) to the host byte order.
    67          *  @param[in] number The number in the network byte order to be converted.
    68          *  @returns The number in the host byte order.
    69          */
    70         #define ntohl( number )         ( number )
    71 
    72 #else
    73 
    74 // Has to be swapped.
    75 
    76         /** Converts the given short number ( 16 bit ) from the host byte order to the network byte order ( big endian ).
    77          *  @param[in] number The number in the host byte order to be converted.
    78          *  @returns The number in the network byte order.
    79          */
    80         #define htons( number )         uint16_t_byteorder_swap(( uint16_t )( number ))
    81 
    82         /** Converts the given long number ( 32 bit ) from the host byte order to the network byte order ( big endian ).
    83          *  @param[in] number The number in the host byte order to be converted.
    84          *  @returns The number in the network byte order.
    85          */
    86         #define htonl( number )         uint32_t_byteorder_swap( number )
    87 
    88         /** Converts the given short number ( 16 bit ) from the network byte order ( big endian ) to the host byte order.
    89          *  @param[in] number The number in the network byte order to be converted.
    90          *  @returns The number in the host byte order.
    91          */
    92         #define ntohs( number )         uint16_t_byteorder_swap(( uint16_t )( number ))
    93 
    94         /** Converts the given long number ( 32 bit ) from the network byte order ( big endian ) to the host byte order.
    95          *  @param[in] number The number in the network byte order to be converted.
    96          *  @returns The number in the host byte order.
    97          */
    98         #define ntohl( number )         uint32_t_byteorder_swap( number )
    99 
    100 #endif
     62/** Converts the given long number ( 32 bit ) from the network byte order ( big endian ) to the host byte order.
     63 *  @param[in] number The number in the network byte order to be converted.
     64 *  @returns The number in the host byte order.
     65 */
     66#define ntohl( number )         uint32_t_be2host( number )
    10167
    10268#endif
Note: See TracChangeset for help on using the changeset viewer.