aboutsummaryrefslogtreecommitdiff
path: root/src/glibc.hpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-07-07 17:06:09 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-07-07 17:56:08 -0400
commit7ccf7807b3f12428adc5d9ca0ede4e3f4ec6dbbc (patch)
treeaf8db742f220123b24c3959b6f33173d8b1e619e /src/glibc.hpp
parent3b97940fb384285a8f88088c9e73e582f8bdbf96 (diff)
downloadzig-7ccf7807b3f12428adc5d9ca0ede4e3f4ec6dbbc.tar.gz
zig-7ccf7807b3f12428adc5d9ca0ede4e3f4ec6dbbc.zip
ability to target any glibc version
Diffstat (limited to 'src/glibc.hpp')
-rw-r--r--src/glibc.hpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/glibc.hpp b/src/glibc.hpp
new file mode 100644
index 0000000000..50796197d4
--- /dev/null
+++ b/src/glibc.hpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2019 Andrew Kelley
+ *
+ * This file is part of zig, which is MIT licensed.
+ * See http://opensource.org/licenses/MIT
+ */
+
+#ifndef ZIG_GLIBC_HPP
+#define ZIG_GLIBC_HPP
+
+#include "all_types.hpp"
+
+struct ZigGLibCLib {
+ const char *name;
+ uint8_t sover;
+};
+
+struct ZigGLibCFn {
+ Buf *name;
+ const ZigGLibCLib *lib;
+};
+
+struct ZigGLibCVerList {
+ uint8_t versions[8]; // 8 is just the max number, we know statically it's big enough
+ uint8_t len;
+};
+
+uint32_t hash_glibc_target(const ZigTarget *x);
+bool eql_glibc_target(const ZigTarget *a, const ZigTarget *b);
+
+struct ZigGLibCAbi {
+ Buf *abi_txt_path;
+ Buf *vers_txt_path;
+ Buf *fns_txt_path;
+ ZigList<ZigGLibCVersion> all_versions;
+ ZigList<ZigGLibCFn> all_functions;
+ // The value is a pointer to all_functions.length items and each item is an index
+ // into all_functions.
+ HashMap<const ZigTarget *, ZigGLibCVerList *, hash_glibc_target, eql_glibc_target> version_table;
+};
+
+Error glibc_load_metadata(ZigGLibCAbi **out_result, Buf *zig_lib_dir, bool verbose);
+Error glibc_build_dummies_and_maps(CodeGen *codegen, const ZigGLibCAbi *glibc_abi, const ZigTarget *target,
+ Buf **out_dir, bool verbose);
+
+// returns ErrorUnknownABI when glibc is not the native libc
+Error glibc_detect_native_version(ZigGLibCVersion *glibc_ver);
+
+size_t glibc_lib_count(void);
+const ZigGLibCLib *glibc_lib_enum(size_t index);
+const ZigGLibCLib *glibc_lib_find(const char *name);
+
+#endif