Make relibc (except libm) pure Rust
This commit is contained in:
@@ -6,6 +6,8 @@ variables:
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
before_script:
|
||||
cargo install cbindgen
|
||||
|
||||
default:
|
||||
cache:
|
||||
|
||||
Generated
+14
-335
@@ -2,54 +2,18 @@
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
|
||||
|
||||
[[package]]
|
||||
name = "cbindgen"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da6bc11b07529f16944307272d5bd9b22530bc7d05751717c9d416586cedab49"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"heck",
|
||||
"indexmap",
|
||||
"log",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"syn 1.0.109",
|
||||
"tempfile",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cbitset"
|
||||
version = "0.2.0"
|
||||
@@ -59,45 +23,6 @@ dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.83"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "3.2.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"bitflags 1.3.2",
|
||||
"clap_lex",
|
||||
"indexmap",
|
||||
"strsim",
|
||||
"termcolor",
|
||||
"textwrap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
|
||||
dependencies = [
|
||||
"os_str_bytes",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crt0"
|
||||
version = "0.1.0"
|
||||
@@ -114,22 +39,6 @@ version = "0.1.0"
|
||||
name = "dlmalloc"
|
||||
version = "0.2.4"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
|
||||
|
||||
[[package]]
|
||||
name = "goblin"
|
||||
version = "0.7.1"
|
||||
@@ -141,58 +50,15 @@ dependencies = [
|
||||
"scroll",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
|
||||
|
||||
[[package]]
|
||||
name = "ld_so"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.149"
|
||||
version = "0.2.151"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.4.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f"
|
||||
checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
@@ -202,9 +68,9 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.6.4"
|
||||
version = "2.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
|
||||
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
|
||||
|
||||
[[package]]
|
||||
name = "memoffset"
|
||||
@@ -224,12 +90,6 @@ dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "os_str_bytes"
|
||||
version = "6.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1"
|
||||
|
||||
[[package]]
|
||||
name = "plain"
|
||||
version = "0.2.3"
|
||||
@@ -248,18 +108,18 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.69"
|
||||
version = "1.0.76"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da"
|
||||
checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.33"
|
||||
version = "1.0.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
|
||||
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
@@ -354,19 +214,17 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.4.1"
|
||||
source = "git+https://gitlab.redox-os.org/redox-os/syscall#06d569933f24af0c72b8bb2eb1aaa031113843fd"
|
||||
source = "git+https://gitlab.redox-os.org/redox-os/syscall#5948affdd53f27bccce21dbb8f193fb4805b39c6"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "relibc"
|
||||
version = "0.2.5"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"cbindgen",
|
||||
"bitflags",
|
||||
"cbitset",
|
||||
"cc",
|
||||
"dlmalloc",
|
||||
"goblin",
|
||||
"libc",
|
||||
@@ -384,25 +242,6 @@ dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
|
||||
|
||||
[[package]]
|
||||
name = "sc"
|
||||
version = "0.2.7"
|
||||
@@ -426,105 +265,20 @@ checksum = "1db149f81d46d2deba7cd3c50772474707729550221e69588478ebf9ada425ae"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.38",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.190"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.190"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.38",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.109"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.38"
|
||||
version = "2.0.48"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b"
|
||||
checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"fastrand",
|
||||
"redox_syscall 0.4.1",
|
||||
"rustix",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d"
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unborrow"
|
||||
version = "0.3.1"
|
||||
@@ -559,83 +313,8 @@ version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||
|
||||
@@ -12,11 +12,6 @@ crate-type = ["staticlib"]
|
||||
members = ["src/crt0", "src/crti", "src/crtn", "src/ld_so", "src/platform/redox/redox-exec"]
|
||||
exclude = ["ralloc", "tests", "dlmalloc-rs"]
|
||||
|
||||
[build-dependencies]
|
||||
cbindgen = "0.26"
|
||||
cc = "1.0.25"
|
||||
#env_logger = "0.10"
|
||||
|
||||
[dependencies]
|
||||
bitflags = "2"
|
||||
cbitset = "0.2"
|
||||
|
||||
@@ -10,6 +10,12 @@ export OBJCOPY?=objcopy
|
||||
BUILD?="$(shell pwd)/target/$(TARGET)"
|
||||
CARGOFLAGS+="--target=$(TARGET)"
|
||||
|
||||
TARGET_HEADERS?="$(BUILD)/include"
|
||||
|
||||
HEADERS_UNPARSED=$(shell find src/header -mindepth 1 -maxdepth 1 -type d -not -name "_*" -printf "%f\n")
|
||||
HEADERS_DEPS=$(shell find src/header -type f \( -name "cbindgen.toml" -o -name "*.rs" \))
|
||||
#HEADERS=$(patsubst %,%.h,$(subst _,/,$(HEADERS_UNPARSED)))
|
||||
|
||||
ifeq ($(TARGET),aarch64-unknown-linux-gnu)
|
||||
export CC=aarch64-linux-gnu-gcc
|
||||
export LD=aarch64-linux-gnu-ld
|
||||
@@ -51,9 +57,19 @@ SRC=\
|
||||
|
||||
BUILTINS_VERSION=0.1.70
|
||||
|
||||
.PHONY: all clean fmt install install-libs install-headers install-tests libs submodules test
|
||||
.PHONY: all clean fmt install install-libs install-headers install-tests libs headers submodules test
|
||||
|
||||
all: | libs
|
||||
all: | headers libs
|
||||
|
||||
headers: $(HEADERS_DEPS)
|
||||
for header in $(HEADERS_UNPARSED); do \
|
||||
out=`echo "$$header" | sed 's/_/\//g'`; \
|
||||
out="$(TARGET_HEADERS)/$$out.h"; \
|
||||
cbindgen --output "$$out" \
|
||||
--config="src/header/$$header/cbindgen.toml" \
|
||||
"src/header/$$header/mod.rs"; \
|
||||
sed -i "s/va_list __valist/.../g" "$$out"; \
|
||||
done
|
||||
|
||||
clean:
|
||||
$(CARGO) clean
|
||||
@@ -66,10 +82,10 @@ check:
|
||||
fmt:
|
||||
./fmt.sh
|
||||
|
||||
install-headers: libs
|
||||
install-headers: headers libs
|
||||
mkdir -pv "$(DESTDIR)/include"
|
||||
cp -rv "include"/* "$(DESTDIR)/include"
|
||||
cp -rv "target/include"/* "$(DESTDIR)/include"
|
||||
cp -rv "$(TARGET_HEADERS)"/* "$(DESTDIR)/include"
|
||||
cp -v "openlibm/include"/*.h "$(DESTDIR)/include"
|
||||
cp -v "openlibm/src"/*.h "$(DESTDIR)/include"
|
||||
|
||||
@@ -81,7 +97,7 @@ libs: \
|
||||
$(BUILD)/release/crtn.o \
|
||||
$(BUILD)/release/ld_so
|
||||
|
||||
install-libs: libs
|
||||
install-libs: headers libs
|
||||
mkdir -pv "$(DESTDIR)/lib"
|
||||
cp -v "$(BUILD)/release/libc.a" "$(DESTDIR)/lib"
|
||||
cp -v "$(BUILD)/release/libc.so" "$(DESTDIR)/lib"
|
||||
@@ -137,24 +153,24 @@ $(BUILD)/debug/libc.so: $(BUILD)/debug/librelibc.a $(BUILD)/openlibm/libopenlibm
|
||||
$(CC) -nostdlib -shared -Wl,--allow-multiple-definition -Wl,--whole-archive $^ -Wl,--no-whole-archive -Wl,-soname,libc.so.6 -o $@
|
||||
|
||||
$(BUILD)/debug/librelibc.a: $(SRC)
|
||||
CARGO_INCREMENTAL=0 $(CARGO) rustc $(CARGOFLAGS) -- --emit link=$@ $(RUSTCFLAGS)
|
||||
$(CARGO) rustc $(CARGOFLAGS) -- --emit link=$@ $(RUSTCFLAGS)
|
||||
./renamesyms.sh $@ $(BUILD)/debug/deps/
|
||||
touch $@
|
||||
|
||||
$(BUILD)/debug/crt0.o: $(SRC)
|
||||
CARGO_INCREMENTAL=0 $(CARGO) rustc --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
|
||||
$(CARGO) rustc --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
|
||||
touch $@
|
||||
|
||||
$(BUILD)/debug/crti.o: $(SRC)
|
||||
CARGO_INCREMENTAL=0 $(CARGO) rustc --manifest-path src/crti/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
|
||||
$(CARGO) rustc --manifest-path src/crti/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
|
||||
touch $@
|
||||
|
||||
$(BUILD)/debug/crtn.o: $(SRC)
|
||||
CARGO_INCREMENTAL=0 $(CARGO) rustc --manifest-path src/crtn/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
|
||||
$(CARGO) rustc --manifest-path src/crtn/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
|
||||
touch $@
|
||||
|
||||
$(BUILD)/debug/ld_so.o: $(SRC)
|
||||
CARGO_INCREMENTAL=0 $(CARGO) rustc --manifest-path src/ld_so/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
|
||||
$(CARGO) rustc --manifest-path src/ld_so/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
|
||||
touch $@
|
||||
|
||||
$(BUILD)/debug/ld_so: $(BUILD)/debug/ld_so.o $(BUILD)/debug/crti.o $(BUILD)/debug/libc.a $(BUILD)/debug/crtn.o
|
||||
@@ -175,26 +191,26 @@ $(BUILD)/release/libc.so: $(BUILD)/release/librelibc.a $(BUILD)/openlibm/libopen
|
||||
$(CC) -nostdlib -shared -Wl,--allow-multiple-definition -Wl,--whole-archive $^ -Wl,--no-whole-archive -Wl,-soname,libc.so.6 -o $@
|
||||
|
||||
$(BUILD)/release/librelibc.a: $(SRC)
|
||||
CARGO_INCREMENTAL=0 $(CARGO) rustc --release $(CARGOFLAGS) -- --emit link=$@ $(RUSTCFLAGS)
|
||||
$(CARGO) rustc --release $(CARGOFLAGS) -- --emit link=$@ $(RUSTCFLAGS)
|
||||
# TODO: Better to only allow a certain whitelisted set of symbols? Perhaps
|
||||
# use some cbindgen hook, specify them manually, or grep for #[no_mangle].
|
||||
./renamesyms.sh $@ $(BUILD)/release/deps/
|
||||
touch $@
|
||||
|
||||
$(BUILD)/release/crt0.o: $(SRC)
|
||||
CARGO_INCREMENTAL=0 $(CARGO) rustc --release --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
|
||||
$(CARGO) rustc --release --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
|
||||
touch $@
|
||||
|
||||
$(BUILD)/release/crti.o: $(SRC)
|
||||
CARGO_INCREMENTAL=0 $(CARGO) rustc --release --manifest-path src/crti/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
|
||||
$(CARGO) rustc --release --manifest-path src/crti/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
|
||||
touch $@
|
||||
|
||||
$(BUILD)/release/crtn.o: $(SRC)
|
||||
CARGO_INCREMENTAL=0 $(CARGO) rustc --release --manifest-path src/crtn/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
|
||||
$(CARGO) rustc --release --manifest-path src/crtn/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
|
||||
touch $@
|
||||
|
||||
$(BUILD)/release/ld_so.o: $(SRC)
|
||||
CARGO_INCREMENTAL=0 $(CARGO) rustc --release --manifest-path src/ld_so/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
|
||||
$(CARGO) rustc --release --manifest-path src/ld_so/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@ -C panic=abort $(RUSTCFLAGS)
|
||||
touch $@
|
||||
|
||||
$(BUILD)/release/ld_so: $(BUILD)/release/ld_so.o $(BUILD)/release/crti.o $(BUILD)/release/libc.a $(BUILD)/release/crtn.o
|
||||
@@ -210,4 +226,4 @@ $(BUILD)/openlibm: openlibm
|
||||
touch $@
|
||||
|
||||
$(BUILD)/openlibm/libopenlibm.a: $(BUILD)/openlibm $(BUILD)/release/librelibc.a
|
||||
$(MAKE) AR=$(AR) CC=$(CC) LD=$(LD) CPPFLAGS="-fno-stack-protector -I $(shell pwd)/include -I $(shell pwd)/target/include" -C $< libopenlibm.a
|
||||
$(MAKE) AR=$(AR) CC=$(CC) LD=$(LD) CPPFLAGS="-fno-stack-protector -I$(shell pwd)/include -I$(TARGET_HEADERS)" -C $< libopenlibm.a
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
extern crate cbindgen;
|
||||
extern crate cc;
|
||||
|
||||
use std::{env, fs, fs::DirEntry, path::Path};
|
||||
|
||||
// include src/header directories that don't start with '_'
|
||||
fn include_dir(d: &DirEntry) -> bool {
|
||||
d.metadata().map(|m| m.is_dir()).unwrap_or(false)
|
||||
&& d.path()
|
||||
.iter()
|
||||
.nth(2)
|
||||
.map_or(false, |c| c.to_str().map_or(false, |x| !x.starts_with("_")))
|
||||
}
|
||||
|
||||
fn get_target() -> String {
|
||||
env::var("TARGET").unwrap_or(
|
||||
option_env!("TARGET").map_or("x86_64-unknown-redox".to_string(), |x| x.to_string()),
|
||||
)
|
||||
}
|
||||
|
||||
fn generate_bindings(cbindgen_config_path: &Path) {
|
||||
let relative_path = cbindgen_config_path
|
||||
.strip_prefix("src/header")
|
||||
.ok()
|
||||
.and_then(|p| p.parent())
|
||||
.and_then(|p| p.to_str())
|
||||
.unwrap()
|
||||
.replace("_", "/");
|
||||
let header_path = Path::new("target/include")
|
||||
.join(&relative_path)
|
||||
.with_extension("h");
|
||||
let mod_path = cbindgen_config_path.with_file_name("mod.rs");
|
||||
let config = cbindgen::Config::from_file(cbindgen_config_path).unwrap();
|
||||
cbindgen::Builder::new()
|
||||
.with_config(config)
|
||||
.with_src(mod_path)
|
||||
.generate()
|
||||
.expect("Unable to generate bindings")
|
||||
.write_to_file(header_path);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
|
||||
let target = get_target();
|
||||
|
||||
// Generate C includes
|
||||
// - based on contents of src/header/**
|
||||
// - headers written to target/include
|
||||
fs::read_dir(&Path::new("src/header"))
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.filter_map(Result::ok)
|
||||
.filter(|d| include_dir(d))
|
||||
.map(|d| d.path().as_path().join("cbindgen.toml"))
|
||||
.filter(|p| p.exists())
|
||||
.for_each(|p| {
|
||||
println!("cargo:rerun-if-changed={:?}", p.parent().unwrap());
|
||||
println!("cargo:rerun-if-changed={:?}", p);
|
||||
println!("cargo:rerun-if-changed={:?}", p.with_file_name("mod.rs"));
|
||||
generate_bindings(&p);
|
||||
});
|
||||
|
||||
println!("cargo:rerun-if-changed=src/c");
|
||||
|
||||
let mut cc_builder = &mut cc::Build::new();
|
||||
|
||||
cc_builder = cc_builder
|
||||
.flag("-nostdinc")
|
||||
.flag("-nostdlib")
|
||||
.include(&format!("{}/include", crate_dir))
|
||||
.include(&format!("{}/target/include", crate_dir));
|
||||
|
||||
if target.starts_with("aarch64") {
|
||||
cc_builder = cc_builder.flag("-mno-outline-atomics")
|
||||
}
|
||||
|
||||
cc_builder
|
||||
.flag("-fno-stack-protector")
|
||||
.flag("-Wno-expansion-to-defined")
|
||||
.files(
|
||||
fs::read_dir("src/c")
|
||||
.expect("src/c directory missing")
|
||||
.map(|res| res.expect("read_dir error").path()),
|
||||
)
|
||||
.compile("relibc_c");
|
||||
|
||||
println!("cargo:rustc-link-lib=static=relibc_c");
|
||||
}
|
||||
@@ -1,15 +1,4 @@
|
||||
#ifndef _BITS_FCNTL_H
|
||||
#define _BITS_FCNTL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int open(const char* filename, int flags, ...);
|
||||
int fcntl(int fildes, int cmd, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,21 +10,4 @@ typedef struct FILE FILE;
|
||||
// STDIO was loaded.
|
||||
#define FILE FILE
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int asprintf(char **strp, const char * fmt, ...);
|
||||
int fprintf(FILE * stream, const char * fmt, ...);
|
||||
int printf(const char * fmt, ...);
|
||||
int snprintf(char *s, size_t n, const char * fmt, ...);
|
||||
int sprintf(char *s, const char * fmt, ...);
|
||||
int fscanf(FILE * stream, const char * fmt, ...);
|
||||
int scanf(const char * fmt, ...);
|
||||
int sscanf(const char * input, const char * fmt, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif /* _BITS_STDIO_H */
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
long double strtold(const char *nptr, char **endptr);
|
||||
static inline long double strtold(const char *nptr, char **endptr) {
|
||||
return (long double)strtod(nptr, endptr);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#ifndef _BITS_SYS_PTRACE_H
|
||||
#define _BITS_SYS_PTRACE_H
|
||||
|
||||
int ptrace(int request, ...);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,10 +7,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int execl(const char *path, const char* argv0, ...);
|
||||
int execle(const char *path, const char* argv0, ...);
|
||||
int execlp(const char *file, const char* argv0, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#include <stdarg.h>
|
||||
#include <sys/types_internal.h>
|
||||
|
||||
// TODO: Can be implemented in rust when cbindgen supports "..." syntax
|
||||
|
||||
int sys_open(const char* filename, int flags, mode_t mode);
|
||||
|
||||
int open(const char* filename, int flags, ...) {
|
||||
mode_t mode = 0;
|
||||
va_list ap;
|
||||
va_start(ap, flags);
|
||||
mode = va_arg(ap, mode_t);
|
||||
va_end(ap);
|
||||
return sys_open(filename, flags, mode);
|
||||
}
|
||||
|
||||
int sys_fcntl(int fildes, int cmd, unsigned long long args);
|
||||
|
||||
int fcntl(int fildes, int cmd, ...) {
|
||||
unsigned long long args = 0;
|
||||
va_list ap;
|
||||
va_start(ap, cmd);
|
||||
args = va_arg(ap, unsigned long long);
|
||||
va_end(ap);
|
||||
return sys_fcntl(fildes, cmd, args);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
// TODO: Can be implemented in rust when cbindgen supports "..." syntax
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
int sys_ptrace(int request, va_list ap);
|
||||
|
||||
int ptrace(int request, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, request);
|
||||
int ret = sys_ptrace(request, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
#include <stdint.h>
|
||||
|
||||
uintptr_t __stack_chk_guard = 0xd048c37519fcadfe;
|
||||
|
||||
void abort(void) __attribute__((noreturn));
|
||||
|
||||
__attribute__((noreturn))
|
||||
void __stack_chk_fail(void) {
|
||||
abort();
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct FILE FILE;
|
||||
|
||||
// TODO: Can be implemented in rust when cbindgen supports "..." syntax
|
||||
|
||||
int vasprintf(char ** strp, const char * fmt, va_list ap);
|
||||
|
||||
int asprintf(char ** strp, const char * fmt, ...) {
|
||||
int ret;
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
ret = vasprintf(strp, fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int vfprintf(FILE * stream, const char * fmt, va_list ap);
|
||||
|
||||
int fprintf(FILE * stream, const char * fmt, ...) {
|
||||
int ret;
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
ret = vfprintf(stream, fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int vprintf(const char * fmt, va_list ap);
|
||||
|
||||
int printf(const char * fmt, ...) {
|
||||
int ret;
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
ret = vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int vsnprintf(char * s, size_t n, const char * fmt, va_list ap);
|
||||
|
||||
int snprintf(char * s, size_t n, const char * fmt, ...) {
|
||||
int ret;
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
ret = vsnprintf(s, n, fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int vsprintf(char * s, const char * fmt, va_list ap);
|
||||
|
||||
int sprintf(char *s, const char * fmt, ...) {
|
||||
int ret;
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
ret = vsprintf(s, fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int vfscanf(FILE * stream, const char * fmt, va_list ap);
|
||||
|
||||
int fscanf(FILE * stream, const char * fmt, ...) {
|
||||
int ret;
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
ret = vfscanf(stream, fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int vscanf(const char * fmt, va_list ap);
|
||||
|
||||
int scanf(const char * fmt, ...) {
|
||||
int ret;
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
ret = vscanf(fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int vsscanf(const char * input, const char * fmt, va_list ap);
|
||||
|
||||
int sscanf(const char * input, const char * fmt, ...) {
|
||||
int ret;
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
ret = vsscanf(input, fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
double strtod(const char *nptr, char **endptr);
|
||||
|
||||
long double strtold(const char *nptr, char **endptr) {
|
||||
return (long double)strtod(nptr, endptr);
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
||||
// TODO: Can be implemented in rust when cbindgen supports "..." syntax
|
||||
|
||||
int execv(const char *path, char *const *argv);
|
||||
|
||||
int execl(const char *path, const char* argv0, ...)
|
||||
{
|
||||
int argc;
|
||||
va_list ap;
|
||||
va_start(ap, argv0);
|
||||
for (argc = 1; va_arg(ap, const char*); argc++);
|
||||
va_end(ap);
|
||||
{
|
||||
int i;
|
||||
char *argv[argc+1];
|
||||
va_start(ap, argv0);
|
||||
argv[0] = (char *)argv0;
|
||||
for (i = 1; i < argc; i++) {
|
||||
argv[i] = va_arg(ap, char *);
|
||||
}
|
||||
argv[i] = NULL;
|
||||
va_end(ap);
|
||||
return execv(path, argv);
|
||||
}
|
||||
}
|
||||
|
||||
int execve(const char *path, char *const *argv, char *const *envp);
|
||||
|
||||
int execle(const char *path, const char* argv0, ...)
|
||||
{
|
||||
int argc;
|
||||
va_list ap;
|
||||
va_start(ap, argv0);
|
||||
for (argc = 1; va_arg(ap, const char *); argc++);
|
||||
va_end(ap);
|
||||
{
|
||||
int i;
|
||||
char *argv[argc+1];
|
||||
char **envp;
|
||||
va_start(ap, argv0);
|
||||
argv[0] = (char *)argv0;
|
||||
for (i = 1; i <= argc; i++) {
|
||||
argv[i] = va_arg(ap, char *);
|
||||
}
|
||||
envp = va_arg(ap, char **);
|
||||
va_end(ap);
|
||||
return execve(path, argv, envp);
|
||||
}
|
||||
}
|
||||
|
||||
int execvp(const char *file, char *const *argv);
|
||||
|
||||
int execlp(const char *file, const char* argv0, ...)
|
||||
{
|
||||
int argc;
|
||||
va_list ap;
|
||||
va_start(ap, argv0);
|
||||
for (argc = 1; va_arg(ap, const char*); argc++);
|
||||
va_end(ap);
|
||||
{
|
||||
int i;
|
||||
char *argv[argc+1];
|
||||
va_start(ap, argv0);
|
||||
argv[0] = (char *)argv0;
|
||||
for (i = 1; i < argc; i++) {
|
||||
argv[i] = va_arg(ap, char *);
|
||||
}
|
||||
argv[i] = NULL;
|
||||
va_end(ap);
|
||||
return execvp(file, argv);
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct FILE FILE;
|
||||
|
||||
#include <bits/wchar.h>
|
||||
|
||||
int vwprintf(const wchar_t * fmt, va_list ap);
|
||||
|
||||
int wprintf(const wchar_t * fmt, ...) {
|
||||
int ret;
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
ret = vwprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int vfwprintf(FILE * stream, const wchar_t * fmt, va_list ap);
|
||||
|
||||
int fwprintf(FILE * stream, const wchar_t * fmt, ...) {
|
||||
int ret;
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
ret = vfwprintf(stream, fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int vswprintf(wchar_t * s, size_t n, const wchar_t * fmt, va_list ap);
|
||||
|
||||
int swprintf(wchar_t *s, size_t n, const wchar_t * fmt, ...) {
|
||||
int ret;
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
ret = vswprintf(s, n, fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
+17
-3
@@ -35,7 +35,7 @@ pub const F_TEST: c_int = 3;
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn creat(path: *const c_char, mode: mode_t) -> c_int {
|
||||
sys_open(path, O_WRONLY | O_CREAT | O_TRUNC, mode)
|
||||
open(path, O_WRONLY | O_CREAT | O_TRUNC, mode)
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Default)]
|
||||
@@ -47,12 +47,26 @@ pub struct flock {
|
||||
pub l_pid: pid_t,
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn sys_fcntl(fildes: c_int, cmd: c_int, arg: c_ulonglong) -> c_int {
|
||||
pub unsafe extern "C" fn fcntl(fildes: c_int, cmd: c_int, mut __valist: ...) -> c_int {
|
||||
// c_ulonglong
|
||||
let arg = match cmd {
|
||||
F_DUPFD | F_SETFD | F_SETFL | F_SETLK | F_SETLKW | F_GETLK => __valist.arg::<c_ulonglong>(),
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
Sys::fcntl(fildes, cmd, arg)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sys_open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int {
|
||||
pub unsafe extern "C" fn open(path: *const c_char, oflag: c_int, mut __valist: ...) -> c_int {
|
||||
let mode = if oflag & O_CREAT == O_CREAT
|
||||
/* || oflag & O_TMPFILE == O_TMPFILE */
|
||||
{
|
||||
__valist.arg::<mode_t>()
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
||||
let path = CStr::from_ptr(path);
|
||||
Sys::open(path, oflag, mode)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use core_io::{Cursor, Write};
|
||||
|
||||
use crate::{
|
||||
header::{fcntl, sys_ioctl, unistd},
|
||||
io::{Cursor, Write},
|
||||
platform::types::*,
|
||||
};
|
||||
|
||||
@@ -9,7 +8,7 @@ pub(super) unsafe fn openpty(name: &mut [u8]) -> Result<(c_int, c_int), ()> {
|
||||
const O_NOCTTY: c_int = 0x100;
|
||||
|
||||
//TODO: wrap in auto-close struct
|
||||
let master = fcntl::sys_open(c_str!("/dev/ptmx").as_ptr(), fcntl::O_RDWR | O_NOCTTY, 0);
|
||||
let master = fcntl::open(c_str!("/dev/ptmx").as_ptr(), fcntl::O_RDWR | O_NOCTTY, 0);
|
||||
if master < 0 {
|
||||
return Err(());
|
||||
}
|
||||
@@ -39,7 +38,7 @@ pub(super) unsafe fn openpty(name: &mut [u8]) -> Result<(c_int, c_int), ()> {
|
||||
let mut cursor = Cursor::new(name);
|
||||
write!(cursor, "/dev/pts/{}", ptn);
|
||||
|
||||
let slave = fcntl::sys_open(
|
||||
let slave = fcntl::open(
|
||||
cursor.get_ref().as_ptr() as *const c_char,
|
||||
fcntl::O_RDWR | O_NOCTTY,
|
||||
0,
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::{
|
||||
};
|
||||
|
||||
pub(super) unsafe fn openpty(name: &mut [u8]) -> Result<(c_int, c_int), ()> {
|
||||
let master = fcntl::sys_open(c_str!("pty:").as_ptr(), fcntl::O_RDWR, 0);
|
||||
let master = fcntl::open(c_str!("pty:").as_ptr(), fcntl::O_RDWR, 0);
|
||||
if master < 0 {
|
||||
return Err(());
|
||||
}
|
||||
@@ -16,7 +16,7 @@ pub(super) unsafe fn openpty(name: &mut [u8]) -> Result<(c_int, c_int), ()> {
|
||||
return Err(());
|
||||
}
|
||||
|
||||
let slave = fcntl::sys_open(name.as_ptr() as *const c_char, fcntl::O_RDWR, 0);
|
||||
let slave = fcntl::open(name.as_ptr() as *const c_char, fcntl::O_RDWR, 0);
|
||||
if slave < 0 {
|
||||
unistd::close(master);
|
||||
return Err(());
|
||||
|
||||
@@ -50,13 +50,13 @@ pub unsafe fn _fdopen(fd: c_int, mode: *const c_char) -> Option<*mut FILE> {
|
||||
}
|
||||
|
||||
if !strchr(mode, b'e' as i32).is_null() {
|
||||
sys_fcntl(fd, F_SETFD, FD_CLOEXEC as c_ulonglong);
|
||||
fcntl(fd, F_SETFD, FD_CLOEXEC as c_ulonglong);
|
||||
}
|
||||
|
||||
if *mode == 'a' as i8 {
|
||||
let f = sys_fcntl(fd, F_GETFL, 0);
|
||||
let f = fcntl(fd, F_GETFL, 0);
|
||||
if (f & O_APPEND) == 0 {
|
||||
sys_fcntl(fd, F_SETFL, (f | O_APPEND) as c_ulonglong);
|
||||
fcntl(fd, F_SETFL, (f | O_APPEND) as c_ulonglong);
|
||||
}
|
||||
flags |= F_APP;
|
||||
}
|
||||
|
||||
+77
-7
@@ -510,13 +510,13 @@ pub unsafe extern "C" fn fopen(filename: *const c_char, mode: *const c_char) ->
|
||||
0
|
||||
};
|
||||
|
||||
let fd = fcntl::sys_open(filename, flags, new_mode);
|
||||
let fd = fcntl::open(filename, flags, new_mode);
|
||||
if fd < 0 {
|
||||
return ptr::null_mut();
|
||||
}
|
||||
|
||||
if flags & fcntl::O_CLOEXEC > 0 {
|
||||
fcntl::sys_fcntl(fd, fcntl::F_SETFD, fcntl::FD_CLOEXEC as c_ulonglong);
|
||||
fcntl::fcntl(fd, fcntl::F_SETFD, fcntl::FD_CLOEXEC as c_ulonglong);
|
||||
}
|
||||
|
||||
if let Some(f) = helpers::_fdopen(fd, mode) {
|
||||
@@ -607,14 +607,14 @@ pub unsafe extern "C" fn freopen(
|
||||
if filename.is_null() {
|
||||
// Reopen stream in new mode
|
||||
if flags & fcntl::O_CLOEXEC > 0 {
|
||||
fcntl::sys_fcntl(
|
||||
fcntl::fcntl(
|
||||
*stream.file,
|
||||
fcntl::F_SETFD,
|
||||
fcntl::FD_CLOEXEC as c_ulonglong,
|
||||
);
|
||||
}
|
||||
flags &= !(fcntl::O_CREAT | fcntl::O_EXCL | fcntl::O_CLOEXEC);
|
||||
if fcntl::sys_fcntl(*stream.file, fcntl::F_SETFL, flags as c_ulonglong) < 0 {
|
||||
if fcntl::fcntl(*stream.file, fcntl::F_SETFL, flags as c_ulonglong) < 0 {
|
||||
funlockfile(stream);
|
||||
fclose(stream);
|
||||
return ptr::null_mut();
|
||||
@@ -630,7 +630,7 @@ pub unsafe extern "C" fn freopen(
|
||||
if *new.file == *stream.file {
|
||||
new.file.fd = -1;
|
||||
} else if Sys::dup2(*new.file, *stream.file) < 0
|
||||
|| fcntl::sys_fcntl(
|
||||
|| fcntl::fcntl(
|
||||
*stream.file,
|
||||
fcntl::F_SETFL,
|
||||
(flags & fcntl::O_CLOEXEC) as c_ulonglong,
|
||||
@@ -1175,11 +1175,23 @@ pub unsafe extern "C" fn vfprintf(file: *mut FILE, format: *const c_char, ap: va
|
||||
|
||||
printf::printf(&mut *file, format, ap)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn fprintf(
|
||||
file: *mut FILE,
|
||||
format: *const c_char,
|
||||
mut __valist: ...
|
||||
) -> c_int {
|
||||
vfprintf(file, format, __valist.as_va_list())
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn vprintf(format: *const c_char, ap: va_list) -> c_int {
|
||||
vfprintf(&mut *stdout, format, ap)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn printf(format: *const c_char, mut __valist: ...) -> c_int {
|
||||
vfprintf(&mut *stdout, format, __valist.as_va_list())
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn vasprintf(
|
||||
@@ -1194,6 +1206,14 @@ pub unsafe extern "C" fn vasprintf(
|
||||
*strp = alloc_writer.leak() as *mut c_char;
|
||||
ret
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn asprintf(
|
||||
strp: *mut *mut c_char,
|
||||
format: *const c_char,
|
||||
mut __valist: ...
|
||||
) -> c_int {
|
||||
vasprintf(strp, format, __valist.as_va_list())
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn vsnprintf(
|
||||
@@ -1208,11 +1228,36 @@ pub unsafe extern "C" fn vsnprintf(
|
||||
ap,
|
||||
)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn snprintf(
|
||||
s: *mut c_char,
|
||||
n: size_t,
|
||||
format: *const c_char,
|
||||
mut __valist: ...
|
||||
) -> c_int {
|
||||
printf::printf(
|
||||
&mut platform::StringWriter(s as *mut u8, n as usize),
|
||||
format,
|
||||
__valist.as_va_list(),
|
||||
)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn vsprintf(s: *mut c_char, format: *const c_char, ap: va_list) -> c_int {
|
||||
printf::printf(&mut platform::UnsafeStringWriter(s as *mut u8), format, ap)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sprintf(
|
||||
s: *mut c_char,
|
||||
format: *const c_char,
|
||||
mut __valist: ...
|
||||
) -> c_int {
|
||||
printf::printf(
|
||||
&mut platform::UnsafeStringWriter(s as *mut u8),
|
||||
format,
|
||||
__valist.as_va_list(),
|
||||
)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn vfscanf(file: *mut FILE, format: *const c_char, ap: va_list) -> c_int {
|
||||
@@ -1228,16 +1273,41 @@ pub unsafe extern "C" fn vfscanf(file: *mut FILE, format: *const c_char, ap: va_
|
||||
};
|
||||
ret
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn fscanf(
|
||||
file: *mut FILE,
|
||||
format: *const c_char,
|
||||
mut __valist: ...
|
||||
) -> c_int {
|
||||
vfscanf(file, format, __valist.as_va_list())
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn vscanf(format: *const c_char, ap: va_list) -> c_int {
|
||||
vfscanf(&mut *stdin, format, ap)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn scanf(format: *const c_char, mut __valist: ...) -> c_int {
|
||||
vfscanf(&mut *stdin, format, __valist.as_va_list())
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn vsscanf(s: *const c_char, format: *const c_char, ap: va_list) -> c_int {
|
||||
pub unsafe extern "C" fn vsscanf(
|
||||
s: *const c_char,
|
||||
format: *const c_char,
|
||||
__valist: va_list,
|
||||
) -> c_int {
|
||||
let reader = (s as *const u8).into();
|
||||
scanf::scanf(reader, format, ap)
|
||||
scanf::scanf(reader, format, __valist)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sscanf(
|
||||
s: *const c_char,
|
||||
format: *const c_char,
|
||||
mut __valist: ...
|
||||
) -> c_int {
|
||||
let reader = (s as *const u8).into();
|
||||
scanf::scanf(reader, format, __valist.as_va_list())
|
||||
}
|
||||
|
||||
pub unsafe fn flush_io_streams() {
|
||||
|
||||
@@ -100,6 +100,14 @@ pub unsafe extern "C" fn abort() -> ! {
|
||||
intrinsics::abort();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
static __stack_chk_guard: uintptr_t = 0xd048c37519fcadfe;
|
||||
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn __stack_chk_fail() -> ! {
|
||||
abort();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn abs(i: c_int) -> c_int {
|
||||
i.abs()
|
||||
|
||||
@@ -65,7 +65,7 @@ fn dup_write<T>(fd: c_int, name: &str, t: &T) -> syscall::Result<usize> {
|
||||
pub unsafe extern "C" fn ioctl(fd: c_int, request: c_ulong, out: *mut c_void) -> c_int {
|
||||
match request {
|
||||
FIONBIO => {
|
||||
let mut flags = fcntl::sys_fcntl(fd, fcntl::F_GETFL, 0);
|
||||
let mut flags = fcntl::fcntl(fd, fcntl::F_GETFL, 0);
|
||||
if flags < 0 {
|
||||
return -1;
|
||||
}
|
||||
@@ -74,7 +74,7 @@ pub unsafe extern "C" fn ioctl(fd: c_int, request: c_ulong, out: *mut c_void) ->
|
||||
} else {
|
||||
flags | fcntl::O_NONBLOCK
|
||||
};
|
||||
if fcntl::sys_fcntl(fd, fcntl::F_SETFL, flags as c_ulonglong) < 0 {
|
||||
if fcntl::fcntl(fd, fcntl::F_SETFL, flags as c_ulonglong) < 0 {
|
||||
-1
|
||||
} else {
|
||||
0
|
||||
@@ -144,11 +144,11 @@ pub unsafe extern "C" fn ioctl(fd: c_int, request: c_ulong, out: *mut c_void) ->
|
||||
TIOCGPTLCK => {
|
||||
eprintln!("TODO: ioctl TIOCGPTLCK");
|
||||
0
|
||||
},
|
||||
}
|
||||
TIOCSPTLCK => {
|
||||
eprintln!("TODO: ioctl TIOCSPTLCK");
|
||||
0
|
||||
},
|
||||
}
|
||||
TCSBRK => {
|
||||
eprintln!("TODO: ioctl TCSBRK");
|
||||
0
|
||||
|
||||
@@ -71,9 +71,9 @@ unsafe extern "C" fn mremap(
|
||||
old_size: usize,
|
||||
new_size: usize,
|
||||
flags: c_int,
|
||||
mut args: ...
|
||||
mut __valist: ...
|
||||
) -> *mut c_void {
|
||||
let new_address = args.arg::<*mut c_void>();
|
||||
let new_address = __valist.arg::<*mut c_void>();
|
||||
Sys::mremap(old_address, old_size, new_size, flags, new_address)
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ unsafe fn shm_path(name: *const c_char) -> CString {
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int {
|
||||
let path = shm_path(name);
|
||||
fcntl::sys_open(path.as_ptr(), oflag, mode)
|
||||
fcntl::open(path.as_ptr(), oflag, mode)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
||||
@@ -23,7 +23,7 @@ pub const PTRACE_SYSEMU_SINGLESTEP: c_int = 32;
|
||||
|
||||
// Can't use "params: ..." syntax, because... guess what? Cbingen again :(
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sys_ptrace(request: c_int, mut params: VaList) -> c_int {
|
||||
pub unsafe extern "C" fn ptrace(request: c_int, mut __valist: ...) -> c_int {
|
||||
// Musl also just grabs the arguments from the varargs...
|
||||
Sys::ptrace(request, params.arg(), params.arg(), params.arg())
|
||||
Sys::ptrace(request, __valist.arg(), __valist.arg(), __valist.arg())
|
||||
}
|
||||
|
||||
+88
-21
@@ -1,6 +1,11 @@
|
||||
//! unistd implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/unistd.h.html
|
||||
|
||||
use core::{convert::TryFrom, mem, ptr, slice};
|
||||
use core::{
|
||||
convert::TryFrom,
|
||||
ffi::VaListImpl,
|
||||
mem::{self, MaybeUninit},
|
||||
ptr, slice,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
c_str::CStr,
|
||||
@@ -14,6 +19,8 @@ use alloc::collections::LinkedList;
|
||||
|
||||
pub use self::{brk::*, getopt::*, pathconf::*, sysconf::*};
|
||||
|
||||
use super::errno::{E2BIG, ENOMEM};
|
||||
|
||||
mod brk;
|
||||
mod getopt;
|
||||
mod pathconf;
|
||||
@@ -136,24 +143,84 @@ pub extern "C" fn encrypt(block: [c_char; 64], edflag: c_int) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
// #[no_mangle]
|
||||
// pub extern "C" fn execl(path: *const c_char, args: *const *mut c_char) -> c_int {
|
||||
// unimplemented!();
|
||||
// }
|
||||
unsafe fn with_argv(
|
||||
mut va: VaListImpl,
|
||||
arg0: *const c_char,
|
||||
f: impl FnOnce(&[*const c_char], VaListImpl) -> c_int,
|
||||
) -> c_int {
|
||||
let argc = 1 + va.with_copy(|mut copy| {
|
||||
core::iter::from_fn(|| Some(copy.arg::<*const c_char>()))
|
||||
.position(|p| p.is_null())
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
// #[no_mangle]
|
||||
// pub extern "C" fn execle(
|
||||
// path: *const c_char,
|
||||
// args: *const *mut c_char,
|
||||
// envp: *const *mut c_char,
|
||||
// ) -> c_int {
|
||||
// unimplemented!();
|
||||
// }
|
||||
let mut stack: [MaybeUninit<*const c_char>; 32] = MaybeUninit::uninit_array();
|
||||
|
||||
// #[no_mangle]
|
||||
// pub extern "C" fn execlp(file: *const c_char, args: *const *mut c_char) -> c_int {
|
||||
// unimplemented!();
|
||||
// }
|
||||
let out = if argc < 32 {
|
||||
stack.as_mut_slice()
|
||||
} else if argc < 4096 {
|
||||
// TODO: Use ARG_MAX, not this hardcoded constant
|
||||
let ptr = crate::header::stdlib::malloc(argc * mem::size_of::<*const c_char>());
|
||||
if ptr.is_null() {
|
||||
platform::errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
slice::from_raw_parts_mut(ptr.cast::<MaybeUninit<*const c_char>>(), argc)
|
||||
} else {
|
||||
platform::errno = E2BIG;
|
||||
return -1;
|
||||
};
|
||||
out[0].write(arg0);
|
||||
|
||||
for i in 1..argc {
|
||||
out[i].write(va.arg::<*const c_char>());
|
||||
}
|
||||
out[argc].write(core::ptr::null());
|
||||
// NULL
|
||||
va.arg::<*const c_char>();
|
||||
|
||||
f(MaybeUninit::slice_assume_init_ref(&*out), va);
|
||||
|
||||
// f only returns if it fails
|
||||
if argc >= 32 {
|
||||
crate::header::stdlib::free(out.as_mut_ptr().cast());
|
||||
}
|
||||
-1
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn execl(
|
||||
path: *const c_char,
|
||||
arg0: *const c_char,
|
||||
mut __valist: ...
|
||||
) -> c_int {
|
||||
with_argv(__valist, arg0, |args, _remaining_va| {
|
||||
execv(path, args.as_ptr().cast())
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn execle(
|
||||
path: *const c_char,
|
||||
arg0: *const c_char,
|
||||
mut __valist: ...
|
||||
) -> c_int {
|
||||
with_argv(__valist, arg0, |args, mut remaining_va| {
|
||||
let envp = remaining_va.arg::<*const *mut c_char>();
|
||||
execve(path, args.as_ptr().cast(), envp)
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn execlp(
|
||||
file: *const c_char,
|
||||
arg0: *const c_char,
|
||||
mut __valist: ...
|
||||
) -> c_int {
|
||||
with_argv(__valist, arg0, |args, _remaining_va| {
|
||||
execvp(file, args.as_ptr().cast())
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn execv(path: *const c_char, argv: *const *mut c_char) -> c_int {
|
||||
@@ -469,7 +536,7 @@ pub unsafe extern "C" fn lockf(fildes: c_int, function: c_int, size: off_t) -> c
|
||||
match function {
|
||||
fcntl::F_TEST => {
|
||||
fl.l_type = fcntl::F_RDLCK as c_short;
|
||||
if fcntl::sys_fcntl(fildes, fcntl::F_GETLK, &mut fl as *mut _ as c_ulonglong) < 0 {
|
||||
if fcntl::fcntl(fildes, fcntl::F_GETLK, &mut fl as *mut _ as c_ulonglong) < 0 {
|
||||
return -1;
|
||||
}
|
||||
if fl.l_type == fcntl::F_UNLCK as c_short || fl.l_pid == getpid() {
|
||||
@@ -480,13 +547,13 @@ pub unsafe extern "C" fn lockf(fildes: c_int, function: c_int, size: off_t) -> c
|
||||
}
|
||||
fcntl::F_ULOCK => {
|
||||
fl.l_type = fcntl::F_UNLCK as c_short;
|
||||
return fcntl::sys_fcntl(fildes, fcntl::F_SETLK, &mut fl as *mut _ as c_ulonglong);
|
||||
return fcntl::fcntl(fildes, fcntl::F_SETLK, &mut fl as *mut _ as c_ulonglong);
|
||||
}
|
||||
fcntl::F_TLOCK => {
|
||||
return fcntl::sys_fcntl(fildes, fcntl::F_SETLK, &mut fl as *mut _ as c_ulonglong);
|
||||
return fcntl::fcntl(fildes, fcntl::F_SETLK, &mut fl as *mut _ as c_ulonglong);
|
||||
}
|
||||
fcntl::F_LOCK => {
|
||||
return fcntl::sys_fcntl(fildes, fcntl::F_SETLKW, &mut fl as *mut _ as c_ulonglong);
|
||||
return fcntl::fcntl(fildes, fcntl::F_SETLKW, &mut fl as *mut _ as c_ulonglong);
|
||||
}
|
||||
_ => {
|
||||
platform::errno = errno::EINVAL;
|
||||
|
||||
@@ -322,11 +322,23 @@ pub unsafe extern "C" fn vfwprintf(
|
||||
|
||||
wprintf::wprintf(&mut *stream, format, arg)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn fwprintf(
|
||||
stream: *mut FILE,
|
||||
format: *const wchar_t,
|
||||
mut __valist: ...
|
||||
) -> c_int {
|
||||
vfwprintf(stream, format, __valist.as_va_list())
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn vwprintf(format: *const wchar_t, arg: va_list) -> c_int {
|
||||
vfwprintf(&mut *stdout, format, arg)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wprintf(format: *const wchar_t, mut __valist: ...) -> c_int {
|
||||
vfwprintf(&mut *stdout, format, __valist.as_va_list())
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn vswprintf(
|
||||
@@ -340,6 +352,15 @@ pub unsafe extern "C" fn vswprintf(
|
||||
eprintln!("vswprintf not implemented");
|
||||
-1
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn swprintf(
|
||||
s: *mut wchar_t,
|
||||
n: size_t,
|
||||
format: *const wchar_t,
|
||||
mut __valist: ...
|
||||
) -> c_int {
|
||||
vswprintf(s, n, format, __valist.as_va_list())
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wcpcpy(d: *mut wchar_t, s: *const wchar_t) -> *mut wchar_t {
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#![feature(c_variadic)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(int_roundings)]
|
||||
#![feature(maybe_uninit_slice)]
|
||||
#![feature(maybe_uninit_uninit_array)]
|
||||
#![feature(lang_items)]
|
||||
#![feature(linkage)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
|
||||
@@ -13,21 +13,6 @@ pub unsafe extern "C" fn redox_fpath(fd: c_int, buf: *mut c_void, count: size_t)
|
||||
)) as ssize_t
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn redox_physalloc(size: size_t) -> *mut c_void {
|
||||
let res = e(syscall::physalloc(size));
|
||||
if res == !0 {
|
||||
return ptr::null_mut();
|
||||
} else {
|
||||
return res as *mut c_void;
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn redox_physfree(physical_address: *mut c_void, size: size_t) -> c_int {
|
||||
e(syscall::physfree(physical_address as usize, size)) as c_int
|
||||
}
|
||||
|
||||
pub fn pipe2(fds: &mut [c_int], flags: usize) -> syscall::error::Result<()> {
|
||||
let fds =
|
||||
<&mut [c_int; 2]>::try_from(fds).expect("expected Pal pipe2 to have validated pipe2 array");
|
||||
|
||||
Reference in New Issue
Block a user