-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathlib_c.cr
49 lines (45 loc) · 1.32 KB
/
lib_c.cr
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
# Supported library versions:
#
# * glibc (2.26+)
# * musl libc (1.2+)
# * system libraries of several BSDs
# * macOS system library (11+)
# * MSVCRT
# * WASI
# * bionic libc
#
# See https://crystal-lang.org/reference/man/required_libraries.html#system-library
{% if flag?(:msvc) %}
@[Link({{ flag?(:static) ? "libucrt" : "ucrt" }})]
{% end %}
lib LibC
alias Char = UInt8
alias UChar = Char
alias SChar = Int8
alias Short = Int16
alias UShort = UInt16
alias Int = Int32
alias UInt = UInt32
{% if flag?(:bits32) || flag?(:win32) %}
alias Long = Int32
alias ULong = UInt32
{% elsif flag?(:bits64) %}
alias Long = Int64
alias ULong = UInt64
{% else %}
{% raise "Architecture with unsupported word size" %}
{% end %}
alias LongLong = Int64
alias ULongLong = UInt64
alias Float = Float32
alias Double = Float64
{% if flag?(:android) %}
{% default_api_version = 31 %}
{% min_supported_version = 24 %}
{% api_version_var = env("ANDROID_PLATFORM") || env("ANDROID_NATIVE_API_LEVEL") %}
{% api_version = api_version_var ? api_version_var.gsub(/^android-/, "").to_i : default_api_version %}
{% raise "TODO: Support Android API level below #{min_supported_version}" unless api_version >= min_supported_version %}
ANDROID_API = {{ api_version }}
{% end %}
$environ : Char**
end