Skip to contentSkip to conversation

new: bswap_32.1

DISCUSSION walter harms 1 participant 1 message Sep 16, 2012 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

hi,
attached you will find a new man-page describing the swap_x macros. These are part of libc. In contrast to htonl() etc they swap bytes unconditionaly. (handy if you need it.)

re,
wh

.\"Copyright 2012 walter harms (walter.harms-jNDFPZUTrfTUvfpBxBsQfasoZZ7OtMbqG9Ur7JDdleE@public.gmane.org) .\" Distributed under GPL
.TH BSWAP 3 2012-09-16 "GNU" "Linux Programmer's Manual"
.SH NAME
bswap_16, bswap_32, bswap_64 \- swap bytes
.SH SYNOPSIS
.nf
.B #include <byteswap.h>
.sp
.BI bswap_16 (x);
.sp
.BI bswap_32 (x);
.sp
.BI bswap_64 (x);
.fi
.sp
.in -4n
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.in
.ad l
.sp
.BR bswap_64 ()
.RS
__GNUC__ && __GNUC__ >= 2
.RE
.ad
.SH DESCRIPTION
These is a series off macros that swap all bytes unconditionaly.
.sp
.SH EXAMPLE
This example will swap 01020304 into 04030201.
.nf
#include <stdio.h>
#include <stdint.h>
#include <byteswap.h>

int main()

{
        uint32_t x=0x01020304;
        printf("%08x bswap:%08x\\n",x,bswap_32(x));
        return 0;
}

.fi
.SH "CONFORMING TO"
This is a glibc extension.
.SH SEE ALSO
.BR swap (3),
.BR byteorder (3)

.\"Copyright 2002 walter harms ([email protected]) .\" Distributed under GPL
.TH BSWAP 3 2012-09-16 "GNU" "Linux Programmer's Manual"
.SH NAME
bswap_16, bswap_32, bswap_64 \- swap bytes
.SH SYNOPSIS
.nf
.B #include <byteswap.h>
.sp
.BI bswap_16 (x);
.sp
.BI bswap_32 (x);
.sp
.BI bswap_64 (x);
.fi
.sp
.in -4n
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.in
.ad l
.sp
.BR bswap_64 ()
.RS
__GNUC__ && __GNUC__ >= 2
.RE
.ad
.SH DESCRIPTION
These is a series off macros that swap all bytes unconditionaly. .sp
.SH EXAMPLE
This example will swap 01020304 into 04030201.
.nf
#include <stdio.h>
#include <stdint.h>
#include <byteswap.h>

int main()

{
        uint32_t x=0x01020304;
        printf("%08x bswap:%08x\\n",x,bswap_32(x));
        return 0;
}

.fi
.SH "CONFORMING TO"
This is a glibc extension.
.SH SEE ALSO
.BR swap (3),
.BR byteorder (3)