1/* SPDX-License-Identifier: MIT OR MPL-2.0 OR LGPL-2.1-or-later OR GPL-2.0-or-later */
2/* Copyright 2010, SIL International, All rights reserved. */
3#pragma once
4
5#include <stddef.h>
6
7typedef unsigned char gr_uint8;
8typedef gr_uint8 gr_byte;
9typedef signed char gr_int8;
10typedef unsigned short gr_uint16;
11typedef short gr_int16;
12typedef unsigned int gr_uint32;
13typedef int gr_int32;
14
15enum gr_encform {
16 gr_utf8 = 1/*sizeof(uint8)*/, gr_utf16 = 2/*sizeof(uint16)*/, gr_utf32 = 4/*sizeof(uint32)*/
17};
18
19
20// Define API function declspec/attributes and how each supported compiler or OS
21// allows us to specify them.
22#if defined __GNUC__
23 #define _gr2_and ,
24 #define _gr2_tag_fn(a) __attribute__((a))
25 #define _gr2_deprecated_flag deprecated
26 #define _gr2_export_flag visibility("default")
27 #define _gr2_import_flag visibility("default")
28 #define _gr2_static_flag visibility("hidden")
29#endif
30
31#if defined _WIN32 || defined __CYGWIN__
32 #if defined __GNUC__ // These three will be redefined for Windows
33 #undef _gr2_export_flag
34 #undef _gr2_import_flag
35 #undef _gr2_static_flag
36 #else // How MSVC sepcifies function level attributes adn deprecation
37 #define _gr2_and
38 #define _gr2_tag_fn(a) __declspec(a)
39 #define _gr2_deprecated_flag deprecated
40 #endif
41 #define _gr2_export_flag dllexport
42 #define _gr2_import_flag dllimport
43 #define _gr2_static_flag
44#endif
45
46#if defined GRAPHITE2_STATIC
47 #define GR2_API _gr2_tag_fn(_gr2_static_flag)
48 #define GR2_DEPRECATED_API _gr2_tag_fn(_gr2_deprecated_flag _gr2_and _gr2_static_flag)
49#elif defined GRAPHITE2_EXPORTING
50 #define GR2_API _gr2_tag_fn(_gr2_export_flag)
51 #define GR2_DEPRECATED_API _gr2_tag_fn(_gr2_deprecated_flag _gr2_and _gr2_export_flag)
52#else
53 #define GR2_API _gr2_tag_fn(_gr2_import_flag)
54 #define GR2_DEPRECATED_API _gr2_tag_fn(_gr2_deprecated_flag _gr2_and _gr2_import_flag)
55#endif
56