libsir 2.2.6
Standard Incident Reporter
Loading...
Searching...
No Matches
platform_importc.h
1/*
2 * platform_importc.h
3 *
4 * Version: 2.2.6
5 *
6 * -----------------------------------------------------------------------------
7 *
8 * SPDX-License-Identifier: MIT
9 *
10 * Copyright (c) 2018-2024 Jeffrey H. Johnson <trnsz@pobox.com>
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a copy of
13 * this software and associated documentation files (the "Software"), to deal in
14 * the Software without restriction, including without limitation the rights to
15 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
16 * the Software, and to permit persons to whom the Software is furnished to do so,
17 * subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included in all
20 * copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
24 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
25 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
26 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 *
29 * -----------------------------------------------------------------------------
30 */
31
32#ifndef _SIR_PLATFORM_IMPORTC_H_INCLUDED
33# define _SIR_PLATFORM_IMPORTC_H_INCLUDED
34
35# undef __HAVE_ATOMIC_H__
36# undef __SIZEOF_INT128__
37# undef BSWAP_REDEFINED
38# define _BITS_FLOATN_H 1
39# if defined(__APPLE__)
40# undef _DARWIN_C_SOURCE
41# define _DARWIN_C_SOURCE
42# include <libkern/OSByteOrder.h>
43# undef __builtin_bswap16
44# define __builtin_bswap16(x) _OSSwapInt16(x)
45# undef __builtin_bswap32
46# define __builtin_bswap32(x) _OSSwapInt32(x)
47# undef __builtin_bswap64
48# define __builtin_bswap64(x) _OSSwapInt64(x)
49# define BSWAP_REDEFINED 1
50# elif defined(__linux__)
51# undef _GNU_SOURCE
52# define _GNU_SOURCE 1
53# if defined __has_include
54# if __has_include(<features.h>)
55# include <features.h>
56# endif
57# endif
58# if defined __has_include
59# if __has_include(<byteswap.h>)
60# include <byteswap.h>
61# endif
62# endif
63# if defined(__GLIBC__) && !defined(bswap_16) && !defined(bswap_32) && !defined(bswap_64)
64# undef __builtin_bswap16
65# define __builtin_bswap16(x) swap_16(x)
66# undef __builtin_bswap32
67# define __builtin_bswap32(x) swap_32(x)
68# undef __builtin_bswap64
69# define __builtin_bswap64(x) swap_64(x)
70# define BSWAP_REDEFINED 1
71# elif defined(bswap_16) && defined(bswap_32) && defined(bswap_64)
72# undef __builtin_bswap16
73# define __builtin_bswap16(x) bswap_16(x)
74# undef __builtin_bswap32
75# define __builtin_bswap32(x) bswap_32(x)
76# undef __builtin_bswap64
77# define __builtin_bswap64(x) bswap_64(x)
78# define BSWAP_REDEFINED 1
79# endif
80# elif defined(__FreeBSD__)
81# undef _BSD_SOURCE
82# define _BSD_SOURCE
83# undef _DEFAULT_SOURCE
84# define _DEFAULT_SOURCE
85# include <sys/endian.h>
86# undef __builtin_bswap16
87# define __builtin_bswap16(x) bswap16(x)
88# undef __builtin_bswap32
89# define __builtin_bswap32(x) bswap32(x)
90# undef __builtin_bswap64
91# define __builtin_bswap64(x) bswap64(x)
92# define BSWAP_REDEFINED 1
93# endif
94# if !defined(BSWAP_REDEFINED)
95# undef __builtin_bswap16
96# define __builtin_bswap16
97# undef __builtin_bswap32
98# define __builtin_bswap32
99# undef __builtin_bswap64
100# define __builtin_bswap64
101# define BSWAP_REDEFINED 1
102# endif
103# undef __builtin___snprintf_chk
104# define __builtin___snprintf_chk(s, c, flag, os, fmt, ...) snprintf(s, c, fmt, __VA_ARGS__)
105# undef __builtin___sprintf_chk
106# define __builtin___sprintf_chk(s, flag, os, fmt, ...) sprintf(s, fmt, __VA_ARGS__)
107# undef __builtin___vsnprintf_chk
108# define __builtin___vsnprintf_chk(s, c, flag, os, fmt, ...) vsnprintf(s, c, fmt, __VA_ARGS__)
109# undef __builtin___strlcat_chk
110# define __builtin___strlcat_chk(dest, src, x, n) strlcat(dest, src, x)
111# undef __builtin___strlcpy_chk
112# define __builtin___strlcpy_chk(dest, src, x, n) strlcpy(dest, src, x)
113# undef __builtin_object_size
114# define __builtin_object_size
115# undef __extension__
116# define __extension__
117# undef __asm__
118# if !defined(__FreeBSD__)
119# define __asm__ asm
120# else
121# define __asm__(...)
122# endif
123# if !defined(__restrict)
124# define __restrict restrict
125# endif
126# if !defined(__inline)
127# define __inline
128# endif
129
130#endif /* !_SIR_PLATFORM_IMPORTC_H_INCLUDED */