/usr/include/fxt-tools.h is in libfxt-dev 0.3.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | /*
* Copyright (C) 2003, 2004, 2011-2012 Samuel Thibault <samuel.thibault@ens-lyon.org>
*
* This program is free software ; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program ; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __FXT_TOOLS_H__
#define __FXT_TOOLS_H__
#include <stdint.h>
#include <errno.h>
#ifndef __MINGW32__
#include <arpa/inet.h>
#endif
#define EPRINTF(fmt,...) do {\
fprintf(stderr, "=== " fmt, ## __VA_ARGS__); \
printf("=== " fmt, ## __VA_ARGS__); \
fflush(stdout); \
} while (0)
#define DEFAULT_TRACE_FILE "trace_file"
#define WRITE(n,value) do { \
int res; \
uint##n##_t __val = (typeof(__val)) (value); \
res = write(fd, (void *)&__val, sizeof(__val)); \
if (res < 0) return -1; \
if (res < sizeof(__val)) { \
errno = EINVAL; \
return -1; \
} \
} while (0)
#define READRAW(n,value) do { \
uint##n##_t __val; \
int res; \
res = fread((void *)&__val, sizeof(__val), 1, fstream); \
if (res < 0) return -1; \
if (res < 1) { \
errno = EINVAL; \
return -1; \
} \
(value) = (typeof(value)) __val; \
} while (0)
extern void unsupported_swap(void);
#define DO_SWAP(n, var) { \
uint##n##_t ___val = (var); \
switch(n) { \
case 64: ___val = \
(___val & 0x00000000000000ffULL) << 56 | \
(___val & 0x000000000000ff00ULL) << 40 | \
(___val & 0x0000000000ff0000ULL) << 24 | \
(___val & 0x00000000ff000000ULL) << 8 | \
(___val & 0x000000ff00000000ULL) >> 8 | \
(___val & 0x0000ff0000000000ULL) >> 24 | \
(___val & 0x00ff000000000000ULL) >> 40 | \
(___val & 0xff00000000000000ULL) >> 56; \
break; \
case 32: ___val = \
(___val & 0x000000ffUL) << 24 | \
(___val & 0x0000ff00UL) << 8 | \
(___val & 0x00ff0000UL) >> 8 | \
(___val & 0xff000000UL) >> 24; \
break; \
case 16: ___val = \
(___val & 0x00ffU) << 8 | \
(___val & 0xff00U) >> 8; \
break; \
case 8: break; \
default: unsupported_swap(); \
} \
var = ___val; \
}
#ifdef IS_BIG_ENDIAN
#define SWAP(n, var) do { \
if (fxt->infos.arch < 0x10000) \
/* little endian trace, swap */ \
DO_SWAP(n, var); \
} while(0)
#else
#define SWAP(n, var) do { \
if (fxt->infos.arch >= 0x10000) \
/* big endian trace, swap */ \
DO_SWAP(n, var); \
} while(0)
#endif
#ifdef __MINGW32__
#define myswap32(v) ({ \
uint32_t ___val = (v); \
(___val & 0x000000ffUL) << 24 | \
(___val & 0x0000ff00UL) << 8 | \
(___val & 0x00ff0000UL) >> 8 | \
(___val & 0xff000000UL) >> 24; \
})
#define myntohl(v) myswap32(v)
#define myhtonl(v) myswap32(v)
#else
#define myntohl(v) ntohl(v)
#define myhtonl(v) htonl(v)
#endif
#define READ(n,value) do { \
uint##n##_t __val; \
int res; \
res = fread((void *)&__val, sizeof(__val), 1, fstream); \
if (res < 0) return -1; \
if (res < 1) { \
errno = EINVAL; \
return -1; \
} \
SWAP(n,__val); \
(value) = (typeof(value)) __val; \
} while (0)
#endif /* __FXT_TOOLS_H__ */
|