libsir 2.2.6
Standard Incident Reporter
Loading...
Searching...
No Matches
platform.h
1/*
2 * platform.h
3 *
4 * Version: 2.2.6
5 *
6 * -----------------------------------------------------------------------------
7 *
8 * SPDX-License-Identifier: MIT
9 *
10 * Copyright (c) 2018-2024 Ryan M. Lederman <lederman@gmail.com>
11 * Copyright (c) 2018-2024 Jeffrey H. Johnson <trnsz@pobox.com>
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining a copy of
14 * this software and associated documentation files (the "Software"), to deal in
15 * the Software without restriction, including without limitation the rights to
16 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
17 * the Software, and to permit persons to whom the Software is furnished to do so,
18 * subject to the following conditions:
19 *
20 * The above copyright notice and this permission notice shall be included in all
21 * copies or substantial portions of the Software.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
25 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
26 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
27 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
28 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 *
30 * -----------------------------------------------------------------------------
31 */
32
33#ifndef _SIR_PLATFORM_H_INCLUDED
34# define _SIR_PLATFORM_H_INCLUDED
35
36# if defined(_MSC_VER) && !defined(__clang__)
37# include <stddef.h>
38# undef _USE_ATTRIBUTES_FOR_SAL
39# define _USE_ATTRIBUTES_FOR_SAL 1
40# include <sal.h>
41# define PRINTF_FORMAT _Printf_format_string_
42# define PRINTF_FORMAT_ATTR(fmt_p, va_p)
43# else
44# define PRINTF_FORMAT
45# if (defined(__MINGW32__) || defined(__MINGW64__)) && \
46 !defined(__clang_version__)
47# if !defined(__USE_MINGW_ANSI_STDIO)
48# define __USE_MINGW_ANSI_STDIO 1
49# endif
50# define PRINTF_FORMAT_ATTR(fmt_p, va_p) \
51 __attribute__((format (gnu_printf, fmt_p, va_p)))
52# else
53# if !defined(__SUNPRO_C) && !defined(__SUNPRO_CC) && \
54 !defined(_CH_) && !defined(__CH__)
55# define PRINTF_FORMAT_ATTR(fmt_p, va_p) \
56 __attribute__((format (printf, fmt_p, va_p)))
57# else
58# define PRINTF_FORMAT_ATTR(fmt_p, va_p)
59# endif
60# endif
61# endif
62
63# undef HAS_ATTRIBUTE
64# if defined __has_attribute && (defined(__clang__) || defined(__GNUC__))
65# define HAS_ATTRIBUTE(atr) __has_attribute(atr)
66# else
67# define HAS_ATTRIBUTE(atr) 0
68# endif
69
70# undef HAS_INCLUDE
71# if defined __has_include
72# define HAS_INCLUDE(inc) __has_include(inc)
73# else
74# define HAS_INCLUDE(inc) 0
75# endif
76
77# undef HAS_FEATURE
78# if defined __has_feature
79# define HAS_FEATURE(fea) __has_feature(fea)
80# else
81# define HAS_FEATURE(fea) 0
82# endif
83
84# undef SANITIZE_SUPPRESS
85# if HAS_ATTRIBUTE(no_sanitize)
86# define SANITIZE_SUPPRESS(str) __attribute__((no_sanitize(str)))
87# endif
88# if !defined(SANITIZE_SUPPRESS)
89# define SANITIZE_SUPPRESS(str)
90# endif
91
92# if HAS_FEATURE(safe_stack) && !defined(SIR_NO_PLUGINS)
93# error "linking DSOs with SafeStack is unsupported; disable SafeStack or enable SIR_NO_PLUGINS"
94# endif
95
96# if defined(__OPENOSC_H__)
97# define SIR_IMPL_STRNLEN
98# endif
99
100# if !defined(_WIN32)
101# if defined(__STDC_NO_ATOMICS__)
102# undef __HAVE_ATOMIC_H__
103# else
104# define __HAVE_ATOMIC_H__
105# endif
106# if defined(__GNUC__) && __GNUC__ <= 4
107# if defined(__GNUC_MINOR__) && __GNUC_MINOR__ <= 8
108# if !defined(__clang_version__)
109# undef __HAVE_ATOMIC_H__
110# endif
111# endif
112# endif
113# if defined(__DragonFly__)
114# if defined(__clang__) && defined(__clang_version__)
115# undef __HAVE_ATOMIC_H__
116# endif
117# endif
118# if defined(__circle_lang__)
119# undef __HAVE_ATOMIC_H__
120# endif
121# if defined(SUNLINT)
122# undef __HAVE_ATOMIC_H__
123# endif
124# if (defined(__INTEL_COMPILER) && !defined(__llvm__)) || \
125 defined(__NVCOMPILER) || defined(__COVERITY__)
126# if !defined(_BITS_FLOATN_H)
127# define _BITS_FLOATN_H
128# endif
129# endif
130# if defined(__QNX__)
131# define _QNX_SOURCE
132# endif
133# if defined(__IMPORTC__)
134# include "sir/platform_importc.h"
135# endif
136# if !defined(__open_xl__) && defined(__ibmxl__) && defined(__ibmxl_release__)
137# if __ibmxl__ <= 16
138# if __ibmxl_release__ <= 1
139# undef __HAVE_ATOMIC_H__
140# endif
141# endif
142# endif
143# if !defined(__open_xl__) && defined(__xlC_ver__) && defined(__IBMC__)
144# if __IBMC__ <= 1610
145# undef __HAVE_ATOMIC_H__
146# endif
147# define __XLC16__ 1
148# endif
149# if !defined(__STDC_WANT_LIB_EXT1__)
150# define __STDC_WANT_LIB_EXT1__ 1
151# endif
152# if !defined(__STDC_WANT_LIB_EXT2__)
153# define __STDC_WANT_LIB_EXT2__ 1
154# endif
155# if defined(__APPLE__) && defined(__MACH__)
156# define __MACOS__
157# undef _DARWIN_C_SOURCE
158# define _DARWIN_C_SOURCE
159# elif defined(__serenity__)
160# define SIR_PTHREAD_GETNAME_NP
161# elif defined(__OpenBSD__)
162# define __BSD__
163# define __FreeBSD_PTHREAD_NP_11_3__
164# elif defined(__NetBSD__)
165# define __BSD__
166# if !defined(_NETBSD_SOURCE)
167# define _NETBSD_SOURCE 1
168# endif
169# define SIR_PTHREAD_GETNAME_NP
170# define __USE_HEX_TIDS__
171# elif defined(__FreeBSD__) || defined(__DragonFly__)
172# define __BSD__
173# define _BSD_SOURCE
174# if !defined(_DEFAULT_SOURCE)
175# define _DEFAULT_SOURCE
176# endif
177# include <sys/param.h>
178# if __FreeBSD_version >= 1202500
179# define __FreeBSD_PTHREAD_NP_12_2__
180# elif __FreeBSD_version >= 1103500
181# define __FreeBSD_PTHREAD_NP_11_3__
182# elif __DragonFly_version >= 400907
183# define __DragonFly_getthreadid__
184# endif
185# if defined(__DragonFly__)
186# define SIR_PTHREAD_GETNAME_NP
187# endif
188# else
189# if defined(__EMSCRIPTEN__)
190# define __USE_GNU
191# define _GNU_SOURCE 1
192# undef SIR_NO_THREAD_NAMES
193# define SIR_NO_THREAD_NAMES
194# include <emscripten.h>
195# endif
196# if defined(__HAIKU__)
197# if !defined(__USE_GNU)
198# define __USE_GNU
199# endif
200# if !defined(_GNU_SOURCE)
201# define _GNU_SOURCE 1
202# endif
203# if defined(__clang__) && !defined(_GNU_PTHREAD_H_)
204# include <pthread.h>
205extern /* Workaround a Clang on Haiku bug. */
206int pthread_getname_np(pthread_t thread, char* buffer, size_t length);
207# endif
208# define SIR_PTHREAD_GETNAME_NP
209# endif
210# if defined(__GNU__) && !defined(__linux__)
211# undef SIR_NO_THREAD_NAMES
212# define SIR_NO_THREAD_NAMES
213# if !defined(__HURD__)
214# define __HURD__ 1
215# endif
216# endif
217# if defined(__linux__)
218# if !defined(_GNU_SOURCE)
219# define _GNU_SOURCE 1
220# endif
221# include <features.h>
222# if defined(__GLIBC__)
223# undef GLIBC_VERSION
224# define GLIBC_VERSION (((0 + __GLIBC__) * 10000) + ((0 + __GLIBC_MINOR__) * 100))
225# endif
226# if !defined(GLIBC_VERSION)
227# define GLIBC_VERSION 0
228# endif
229# if defined(__GLIBC__) && GLIBC_VERSION >= 21200
230# define SIR_PTHREAD_GETNAME_NP
231# endif
232# if defined(__GLIBC__) && GLIBC_VERSION > 0 && GLIBC_VERSION < 21200
233# undef SIR_NO_THREAD_NAMES
234# define SIR_NO_THREAD_NAMES
235# endif
236# if defined(__GLIBC__) && GLIBC_VERSION > 0 && \
237 !defined(__SUNPRO_C) && !defined(__SUNPRO_CC)
238# include <sys/sysinfo.h>
239# endif
240# endif
241# if defined(__CYGWIN__)
242# if !defined(_GNU_SOURCE)
243# define _GNU_SOURCE 1
244# endif
245# define SIR_PTHREAD_GETNAME_NP
246# include <sys/features.h>
247# endif
248# if defined(__ANDROID__) && defined(__ANDROID_API__)
249# if __ANDROID_API__ < 26
250# undef SIR_PTHREAD_GETNAME_NP
251# undef SIR_NO_THREAD_NAMES
252# define SIR_NO_THREAD_NAMES
253# endif
254# endif
255# if defined(__illumos__) || ((defined(__sun) || defined(__sun__)) && \
256 (defined(__SVR4) || defined(__svr4__)))
257# define __SOLARIS__
258# define SIR_PTHREAD_GETNAME_NP
259# if !defined(_ATFILE_SOURCE)
260# define _ATFILE_SOURCE 1
261# endif
262# if !defined(__EXTENSIONS__)
263# define __EXTENSIONS__
264# endif
265# endif
266# if !defined(_POSIX_C_SOURCE)
267# define _POSIX_C_SOURCE 200809L
268# endif
269# if !defined(_DEFAULT_SOURCE)
270# define _DEFAULT_SOURCE
271# endif
272# if !defined(_XOPEN_SOURCE)
273# define _XOPEN_SOURCE 700
274# endif
275# endif
276# else /* _WIN32 */
277# define __WIN__
278# define __WANT_STDC_SECURE_LIB__ 1
279# define WIN32_LEAN_AND_MEAN
280# undef WINVER
281# define WINVER 0x0A00
282# undef _WIN32_WINNT
283# define _WIN32_WINNT 0x0A00
284# define _CRT_RAND_S
285# define NOMINMAX
286# if defined(__ORANGEC__)
287# include "sir/platform_orangec.h"
288# endif
289# if defined(__MINGW32__) || defined(__MINGW64__)
290# define SIR_PTHREAD_GETNAME_NP
291# endif
292# include <windows.h>
293# include <io.h>
294# include <synchapi.h>
295# include <processthreadsapi.h>
296# include <process.h>
297# include <winsock2.h>
298# include <conio.h>
299# include <shlwapi.h>
300# include <evntprov.h>
301# undef __HAVE_ATOMIC_H__
302# if defined(_MSC_VER) && _MSC_VER >= 1933 && \
303 !defined(__cplusplus) && !defined(__IMPORTC__)
304# include <stdatomic.h>
305# define __HAVE_ATOMIC_H__
306# endif
307# if defined(__MINGW32__) || defined(__MINGW64__)
308# undef __USE_MINGW_ANSI_STDIO
309# define __USE_MINGW_ANSI_STDIO 1
310# include <pthread.h>
311typedef /* Workaround a MinGW bug */
312void (__cdecl* _invalid_parameter_handler)(
313 wchar_t const*, wchar_t const*, wchar_t const*,
314 unsigned int, uintptr_t);
315_invalid_parameter_handler
316_set_thread_local_invalid_parameter_handler(
317 _invalid_parameter_handler pNew);
318# endif
319# include "sir/platform_embarcadero.h"
320# endif
321
322# if !defined(__MACOS__) && !defined(__BSD__) && !defined(__SOLARIS__) && \
323 !defined(__HAIKU__) && !(defined(__GLIBC__) && GLIBC_VERSION >= 23800)
324# define SIR_IMPL_STRLCPY 1
325# define SIR_IMPL_STRLCAT 1
326# endif
327
328# if defined(__WIN__)
329# define SIR_IMPL_STRNDUP 1
330# endif
331
332# if defined(_AIX)
333# define SIR_IMPL_STRCASESTR 1
334# endif
335
336# if defined(__MINGW64__)
337# define PID_CAST (int)
338# else
339# define PID_CAST
340# endif
341
342# if defined(_AIX) || defined(__CYGWIN__)
343# define CLOCK_CAST (int)
344# else
345# define CLOCK_CAST
346# endif
347
348# if defined(_AIX)
349# if !defined(_ALL_SOURCE)
350# define _ALL_SOURCE
351# endif
352# if defined(_GNU_SOURCE)
353# undef _GNU_SOURCE
354# endif
355# if !defined(_THREAD_SAFE)
356# define _THREAD_SAFE
357# endif
358# endif
359
360# if defined(SIR_ASSERT_ENABLED)
361# include <assert.h>
362# define SIR_ASSERT(...) assert(__VA_ARGS__)
363# else
364# if defined(SIR_SELFLOG)
365# define SIR_ASSERT(...) \
366 do { \
367 if (!(__VA_ARGS__)) { \
368 _sir_selflog(SIR_BRED("!!! would be asserting: " #__VA_ARGS__ "")); \
369 } \
370 } while (false)
371# else
372# define SIR_ASSERT(...)
373# endif
374# endif
375
376# if defined(__cplusplus) && !defined(restrict)
377# define restrict //-V1059
378# endif
379
380# include <ctype.h>
381# include <errno.h>
382# include <stdarg.h>
383# include <stdbool.h>
384# include <stdint.h>
385# include <inttypes.h>
386# include <stdio.h>
387
388# if defined(__cplusplus) && defined(__NVCOMPILER) && defined(__FLOAT128__)
389# define NVIDIA_FLOAT128 __FLOAT128__
390# undef __FLOAT128__
391# endif
392
393# include <stdlib.h>
394
395# if defined(NVIDIA_FLOAT128)
396# define __FLOAT128__ NVIDIA_FLOAT128
397# undef NVIDIA_FLOAT128
398# endif
399
400# include <string.h>
401
402# if defined(DUMA)
403# include <duma.h>
404# endif
405
406# include <sys/stat.h>
407# include <sys/types.h>
408# include <limits.h>
409# include <time.h>
410
411# if !defined(SIR_NO_SYSTEM_LOGGERS)
412# if defined(__MACOS__) && !defined(__IMPORTC__) && \
413 ((defined(__clang__) || defined(__clang_version__)) && \
414 !(defined(__INTEL_COMPILER) && !defined(__llvm__)) && \
415 defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__))
416# undef SIR_OS_LOG_ENABLED
417# define SIR_OS_LOG_ENABLED
418# elif defined(__WIN__)
419# undef SIR_EVENTLOG_ENABLED
420# if defined(__EMBARCADEROC__) || defined(__ORANGEC__)
421# define SIR_NO_SYSTEM_LOGGERS
422# else
423# define SIR_EVENTLOG_ENABLED
424# endif
425# else
426# undef SIR_OS_LOG_ENABLED
427# define SIR_SYSLOG_ENABLED
428# endif
429# else
430# undef SIR_OS_LOG_ENABLED
431# undef SIR_SYSLOG_ENABLED
432# endif
433
434# define SIR_MAXHOST 256
435
436# if !defined(__WIN__)
437# if !defined(SIR_NO_PLUGINS)
438# include <dlfcn.h>
439# endif
440# if !defined(_CH_) && !defined(__CH__)
441# include <pthread.h>
442# else
443# include <sched.h>
444# include <ch/pthread.h>
445# undef __HAVE_ATOMIC_H__
446# endif
447# if defined(__illumos__)
448# include <sys/fcntl.h>
449# endif
450# if defined(__linux__) && defined(__USE_GNU) && \
451 (defined(__SUNPRO_C) || defined(__SUNPRO_CC))
452# undef __USE_GNU
453# include <fcntl.h>
454# define __USE_GNU
455# else
456# include <fcntl.h>
457# endif
458# include <unistd.h>
459# if defined(__MACOS__)
460# include <sys/sysctl.h>
461# endif
462# if !defined(__CYGWIN__) && !defined(__HAIKU__) && \
463 !defined(__serenity__) && !defined(_AIX) && \
464 !defined(_CH_) && !defined(__CH__) && !defined(__QNX__)
465# include <sys/syscall.h>
466# endif
467# if defined(__QNX__)
468# include <sys/syspage.h>
469# endif
470# include <sys/time.h>
471# include <strings.h>
472# include <termios.h>
473# include <limits.h>
474# include <libgen.h>
475# if defined(__HAVE_ATOMIC_H__) && !defined(__cplusplus)
476# include <stdatomic.h>
477# endif
478# if defined(SIR_SYSLOG_ENABLED)
479# if !defined(__cplusplus)
480# include <syslog.h>
481# endif
482# endif
483# if defined(__CYGWIN__)
484# undef SIR_NO_THREAD_NAMES
485# define SIR_NO_THREAD_NAMES
486# endif
487# if defined(_AIX)
488# include <procinfo.h>
489# include <sys/procfs.h>
490# include <sys/systemcfg.h>
491# undef SIR_NO_THREAD_NAMES
492# define SIR_NO_THREAD_NAMES
493# endif
494# if defined(__BSD__)
495# if !defined(__NetBSD__)
496# include <pthread_np.h>
497# endif
498# include <sys/sysctl.h>
499# elif defined(__linux__)
500# if defined(__GLIBC__)
501# include <linux/limits.h>
502# endif
503# elif defined(__HAIKU__)
504# include <OS.h>
505# include <FindDirectory.h>
506# elif defined(__MACOS__)
507# include <mach-o/dyld.h>
508# if defined(SIR_OS_LOG_ENABLED)
509# include <os/log.h>
510# include <os/trace.h>
511# include <os/activity.h>
512# endif
513# endif
514
515# if defined(PATH_MAX)
516# define SIR_MAXPATH PATH_MAX
517# elif defined(MAXPATHLEN)
518# define SIR_MAXPATH MAXPATHLEN
519# else
520# define SIR_MAXPATH 1024
521# endif
522
523# if !defined(SIR_MAXPID) && defined(HAIKU) && defined(B_OS_NAME_LENGTH)
524# define SIR_MAXPID B_OS_NAME_LENGTH
525# endif
526# if !defined(SIR_MAXPID) && defined(PTHREAD_MAX_NAMELEN_NP)
527# define SIR_MAXPID PTHREAD_MAX_NAMELEN_NP
528# endif
529# if !defined(SIR_MAXPID) && defined(_NTO_THREAD_NAME_MAX)
530# define SIR_MAXPID _NTO_THREAD_NAME_MAX
531# endif
532# if !defined(SIR_MAXPID) && defined(__APPLE__)
533# define SIR_MAXPID 64
534# endif
535# if !defined(SIR_MAXPID) && defined(__OpenBSD__)
536# define SIR_MAXPID 32
537# endif
538# if !defined(SIR_MAXPID) && defined(__SOLARIS__)
539# define SIR_MAXPID 31
540# endif
541# if !defined(SIR_MAXPID) && defined(__linux__)
542# define SIR_MAXPID 16
543# endif
544# if !defined(SIR_MAXPID)
545# define SIR_MAXPID 15
546# endif
547
548# if (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) || \
549 defined(__MACOS__) || defined(__OpenBSD__)
550# define SIR_MSEC_TIMER
551# define SIR_MSEC_POSIX
552# else
553# undef SIR_MSEC_TIMER
554# endif
555
557# if defined(CLOCK_REALTIME_FAST)
558# define SIR_WALLCLOCK CLOCK_REALTIME_FAST
559# elif defined(CLOCK_REALTIME_COARSE)
560# define SIR_WALLCLOCK CLOCK_REALTIME_COARSE
561# else
562# define SIR_WALLCLOCK CLOCK_REALTIME
563# endif
564
566# if defined(CLOCK_UPTIME)
567# define SIR_INTERVALCLOCK CLOCK_UPTIME
568# elif defined(CLOCK_BOOTTIME) && !defined(__EMSCRIPTEN__)
569# define SIR_INTERVALCLOCK CLOCK_BOOTTIME
570# elif defined(CLOCK_HIGHRES)
571# define SIR_INTERVALCLOCK CLOCK_HIGHRES
572# elif defined(CLOCK_MONOTONIC)
573# define SIR_INTERVALCLOCK CLOCK_MONOTONIC
574# else
575# define SIR_INTERVALCLOCK CLOCK_REALTIME
576# endif
577
579typedef void* sir_pluginhandle;
580
582typedef void (*sir_pluginexport)(void);
583
585typedef pthread_mutex_t sir_mutex;
586
588typedef pthread_t sir_thread;
589
591typedef pthread_cond_t sir_condition;
592
594typedef struct timespec sir_wait;
595
597typedef pthread_once_t sir_once;
598
600typedef void (*sir_once_fn)(void);
601
603# define SIR_ONCE_INIT PTHREAD_ONCE_INIT
604
606# define SIR_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
607
608# else /* __WIN__ */
609
610# define SIR_MAXPID 64
611
612# define SIR_MAXPATH MAX_PATH
613
614# define SIR_MSEC_TIMER
615# define SIR_MSEC_WIN32
616# define SIR_WALLCLOCK 0
617# define SIR_INTERVALCLOCK 1
618
620typedef HMODULE sir_pluginhandle;
621
623typedef FARPROC sir_pluginexport;
624
626typedef CRITICAL_SECTION sir_mutex;
627
629typedef HANDLE sir_thread;
630
632typedef CONDITION_VARIABLE sir_condition;
633
635typedef DWORD sir_wait;
636
638typedef INIT_ONCE sir_once;
639
641# if !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(__ORANGEC__)
642typedef int pid_t;
643# endif
644
646typedef BOOL(CALLBACK* sir_once_fn)(PINIT_ONCE, PVOID, PVOID*);
647
649# define SIR_ONCE_INIT INIT_ONCE_STATIC_INIT
650
652# define SIR_MUTEX_INIT {0}
653
654# endif /* !__WIN__ */
655
656# if !defined(_sir_thread_local)
657# if (__STDC_VERSION__ >= 201112 && !defined(__STDC_NO_THREADS__)) || \
658 (defined(__SUNPRO_C) || defined(__SUNPRO_CC))
659# if defined(_AIX) && defined(__GNUC__)
660# define _sir_thread_local __thread
661# else
662# define _sir_thread_local _Thread_local
663# endif
664# elif defined(__WIN__)
665# define _sir_thread_local __declspec(thread)
666# elif defined(__GNUC__) || (defined(_AIX) && (defined(__xlC_ver__) || defined(__ibmxl__)))
667# define _sir_thread_local __thread
668# else
669# if !defined(_CH_) && !defined(__CH__)
670# error "unable to resolve thread local attribute; please contact the developers"
671# endif
672# endif
673# endif
674
675# if defined(__WIN__) && defined(__STDC_SECURE_LIB__)
676# define __HAVE_STDC_SECURE_OR_EXT1__
677# elif defined(__STDC_LIB_EXT1__)
678# define __HAVE_STDC_SECURE_OR_EXT1__
679# elif defined(__STDC_ALLOC_LIB__)
680# define __HAVE_STDC_EXT2__
681# endif
682
683# if (defined(__clang__) || defined(__GNUC__)) && defined(__FILE_NAME__)
684# define __file__ __FILE_NAME__
685# elif defined(__BASE_FILE__)
686# define __file__ __BASE_FILE__
687# else
688# define __file__ __FILE__
689# endif
690
691#endif /* !_SIR_PLATFORM_H_INCLUDED */
692
693#include "sir/impl.h"
694
695/* Support Clang's -Wdisabled-macro-expansion check on Linux/glibc */
696#if defined(SIR_LINT) && (defined(__linux__) && defined(__GLIBC__)) && \
697 (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) && \
698 (defined(__clang__) || defined(__clang_version__))
699# undef stdin
700# undef stdout
701# undef stderr
702#endif
703
704/* End of platform.h */