iPXE
Functions | Variables
byteswap_test.c File Reference

Byte-order swapping test functions. More...

#include <stdint.h>
#include <assert.h>
#include <byteswap.h>
#include <ipxe/test.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
uint16_t test_bswap16 (uint16_t x)
uint32_t test_bswap32 (uint32_t x)
uint64_t test_bswap64 (uint64_t x)
void test_bswap16s (uint16_t *x)
void test_bswap32s (uint32_t *x)
void test_bswap64s (uint64_t *x)
static void byteswap_test_exec (void)
 Perform byte-order swapping.

Variables

struct self_test byteswap_test __self_test
 Byte-order swapping self-test.

Detailed Description

Byte-order swapping test functions.

Definition in file byteswap_test.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

Definition at line 42 of file byteswap_test.c.

References __bswap_16.

Referenced by byteswap_test_exec().

                                     {
        return __bswap_16 ( x );
}

Definition at line 46 of file byteswap_test.c.

References __bswap_32.

Referenced by byteswap_test_exec().

                                     {
        return __bswap_32 ( x );
}

Definition at line 50 of file byteswap_test.c.

References __bswap_64.

Referenced by byteswap_test_exec().

                                     {
        return __bswap_64 ( x );
}
void test_bswap16s ( uint16_t x)

Definition at line 54 of file byteswap_test.c.

Referenced by byteswap_test_exec().

                                   {
        __bswap_16s ( x );
}
void test_bswap32s ( uint32_t x)

Definition at line 58 of file byteswap_test.c.

Referenced by byteswap_test_exec().

                                   {
        __bswap_32s ( x );
}
void test_bswap64s ( uint64_t x)

Definition at line 62 of file byteswap_test.c.

Referenced by byteswap_test_exec().

                                   {
        __bswap_64s ( x );
}
static void byteswap_test_exec ( void  ) [static]

Perform byte-order swapping.

Definition at line 70 of file byteswap_test.c.

References ok, test_bswap16(), test_bswap16s(), test_bswap32(), test_bswap32s(), test_bswap64(), and test_bswap64s().

                                        {
        uint16_t test16;
        uint32_t test32;
        uint64_t test64;

        ok ( test_bswap16 ( 0x1234 ) == 0x3412 );
        ok ( test_bswap32 ( 0x12345678UL ) == 0x78563412UL );
        ok ( test_bswap64 ( 0x123456789abcdef0ULL ) == 0xf0debc9a78563412ULL );

        test16 = 0xabcd;
        test_bswap16s ( &test16 );
        ok ( test16 == 0xcdab );

        test32 = 0xabcdef01UL;
        test_bswap32s ( &test32 );
        ok ( test32 == 0x01efcdabUL );

        test64 = 0xabcdef0123456789ULL;
        test_bswap64s ( &test64 );
        ok ( test64 == 0x8967452301efcdabULL );
}

Variable Documentation

struct self_test byteswap_test __self_test
Initial value:
 {
        .name = "byteswap",
        .exec = byteswap_test_exec,
}

Byte-order swapping self-test.

Definition at line 93 of file byteswap_test.c.