Kstars

byteorder.h
1/*
2 SPDX-FileCopyrightText: 2009 Akarsh Simha <akarsh.simha@kdemail.net>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7/*
8NOTE: This file was written from scratch using several headers written
9by others as reference. Of particular mention is LICQ's
10licq_bytorder.h and Oskar Liljeblad's byteswap.h licensed under the
11GPL.
12*/
13
14#ifndef BYTEORDER_H_
15#define BYTEORDER_H_
16
17// Check if we have standard byteswap headers
18
19#ifdef HAVE_BYTESWAP_H
20#include <byteswap.h>
21
22#elif defined HAVE_MACHINE_ENDIAN_H
23#include <machine/endian.h>
24#define bswap_16(x) swap16(x)
25#define bswap_32(x) swap32(x)
26
27#elif defined HAVE_SYS_BYTEORDER_H
28#include <sys/byteorder.h>
29#define bswap_16(x) BSWAP_16(x)
30#define bswap_32(x) BSWAP_32(x)
31#endif
32
33// If no standard headers are found, we define our own byteswap macros
34
35#ifndef bswap_16
36#define bswap_16(x) ((((x)&0x00FF) << 8) | (((x)&0xFF00) >> 8))
37#endif
38
39#ifndef bswap_32
40
41#define bswap_32(x) \
42 ((((x)&0x000000FF) << 24) | (((x)&0x0000FF00) << 8) | (((x)&0x00FF0000) >> 8) | (((x)&0xFF000000) >> 24))
43#endif
44
45#endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.