Commit Graph

70 Commits

Author SHA1 Message Date
Arthur Paulino d4eddbf42e Refactor: inline core_io
* Extract the minimal set of definitions from `core_io` to `relibc` itself

* Remove dependency on `core_io`
2023-12-24 17:06:27 -03:00
4lDO2 75d1c67ca2 Switch to a lightweight CStr wrapper 2023-11-04 18:29:38 +00:00
Noa df6f4678e8 Fix warnings 2023-05-30 13:46:17 -05:00
4lDO2 cdd0f67b23 Rustfmt. 2023-05-17 15:28:10 +02:00
David Carlier bae8bb68df lockf implementation proposal 2023-05-16 23:40:40 +01:00
Jeremy Soller e1ecdbd8a5 Implement vfwprintf 2023-05-11 07:48:49 -06:00
David Carlier 637dd22d3d stdio: implements legacy cuserid proposal. 2023-04-05 22:17:09 +01:00
Jeremy Soller cc0ac982c4 Implement __fpurge 2023-03-10 08:37:54 -07:00
Jeremy Soller 59b2e32953 Fix compilation on 32-bit systems 2022-12-02 08:00:36 -07:00
Mateusz Tabaka 02f202ff83 Use BufWriter (instead of LineWriter) for FILEs other than stdout and stderr
BufWriter has more capacity (8k vs 1k) and doesn't flush the stream after '\n'.
That change helps to reduce the number of syscalls, especially when dealing with text files.

Since BufWriter has a different way of getting number of pending elements than LineWriter -
Pending trait was introduced to deal with that.
2021-01-14 18:45:14 +01:00
Wren Turkal 9a1e9c327a Make byte stream functions set stream orientation.
When a byte-oriented stream function touches a stream, that stream
should be set to byte-oriented mode if it hasn't been set yet. If
it has been set, the opertion should only succeed if the stream is
already in byte-oriented mode.

Signed-off-by: Wren Turkal <wt@penguintechs.org>
2020-07-08 14:33:11 -07:00
Wren Turkal 746a86a267 Add unlocked variation of fwide function.
Signed-off-by: Wren Turkal <wt@penguintechs.org>
2020-07-08 14:33:11 -07:00
Wren Turkal b623e245c0 Make freopen reset the stream orientation.
Signed-off-by: Wren Turkal <wt@penguintechs.org>
2020-07-08 14:33:11 -07:00
Wren Turkal 865b7962a1 Add implmentation for fwide posix function.
This function is used to set the orientation of a stream to either
byte-oriented or wchar-oriented.

More info on this function is here:
https://man7.org/linux/man-pages/man3/fwide.3p.html

This implementation only impmlemnts the manual switching and does
not yet guard against using a byte-oriented stream with wchar
functions and vice versa. Those step will come in additional
commits.

Signed-off-by: Wren Turkal <wt@penguintechs.org>
2020-07-08 14:33:06 -07:00
jD91mZM2 56e1eceb28 Replace AllocStringWriter with CVec 2020-06-29 17:44:57 +02:00
oddcoder 92d6735e3f Add more scanf tests 2020-06-03 23:20:53 +02:00
oddcoder a49139ca2f use lookahead buffer in inner_scanf 2020-06-03 23:20:52 +02:00
oddcoder 14e011b72c Implemment lookaheadreader with lookahead and commit api
The LookAheadReader api works similar to read but it has 2 methods,
lookahead: it will read 1 byte (with internal ftell) without modifying
the file's own ftell() and commit() which saves the current file ftell

LookAheadReader can wrap both buffers and files
2020-06-03 23:20:52 +02:00
oddcoder f068673adc Separate the logic from locking in ftello and fseeko 2020-06-03 23:20:52 +02:00
oddcoder d7d3e00867 Fix off-by-1 error in vfscanf
Scanf function requires look ahead to function properly, In case of
scanning from a buffer that will not be an issue, but in our case we are
reading from file, so lookaheads needs to be undone (via lseek) in our
case. The only problem here is that if we opened a file that doesn't
support lseek such as many of the file /dev/*
2020-05-23 16:20:20 +02:00
oddcoder 1733b3da6e Fix bug related to ungetc and ftell()
At least in relibc, each call to ungetc should decrement ftell() by one
also allowing negative ftell() this is not possible on relibc thus gcc
failing to compile (gcc compiles tools that is later used to compile gcc
itself and these tools are the ones that fail)
2020-05-23 16:20:20 +02:00
oddcoder 7a6f96373e Add support for multiple unget at the same time
According to the standards, only one ungetc may be guaranteed however
glibc allows more than one of those, and to be glibc compatiable, one
needs to be able to do the same, allowing only 1 ungetc may trigger bug
while compiling gcc as ungetc is used there alot
2020-05-23 16:20:20 +02:00
jD91mZM2 b8c50c7c64 Format 2019-08-04 19:05:45 +02:00
jD91mZM2 c7d499d4f2 Upgrade to the 2018 edition
I didn't think it'd be this useful first, but thank god for `cargo fix --edition`!
2019-08-04 19:05:45 +02:00
jD91mZM2 43ff8801bc Format 2019-08-04 19:05:44 +02:00
jD91mZM2 35c1d5210c Implement the Once<T> synchronization structure
Not sure if I should add a RwLock for the ptrace state too...
2019-08-04 19:05:44 +02:00
Jeremy Soller 05f71567ab Format 2019-07-06 19:37:13 -06:00
jD91mZM2 2f4e57f87a Fix data race inside puts(...) & add dbg!() macro 2019-06-26 21:21:32 +02:00
Mateusz Mikuła 7597c082e7 Fix Clippy warnings 2019-05-11 22:34:13 +02:00
Alex Lyon 68d3c5f1b1 Format code 2019-04-26 20:40:22 -07:00
Alex Lyon 3584edf199 stdio: implement tempnam() and tmpnam() 2019-04-26 20:39:03 -07:00
Jeremy Soller 7bde036031 Remove va_list submodule, format 2019-04-21 15:45:55 -06:00
Dan Robertson fa94f1b6d5 Use core::ffi::VaList 2019-04-21 17:46:22 +02:00
Jeremy Soller c71088e768 Cleanup and format 2019-01-14 21:07:24 -07:00
Jeremy Soller 62b83190bf Fix incorrect variable name 2018-12-29 10:03:11 -07:00
Jeremy Soller e7896f6c48 Fix panic in fread 2018-12-29 10:02:36 -07:00
lmiskiew 5b6b11cb65 Fix panic in fwrite 2018-12-17 02:01:36 +01:00
Jeremy Soller ee40035c4b Add asprintf 2018-12-09 12:45:04 -07:00
Jeremy Soller 925d9f6bbf WIP: fflush all files when null is passed 2018-12-02 16:45:29 -07:00
Jeremy Soller 4ced856b39 Fix fseeko not flushing write buffer 2018-12-02 12:04:15 -07:00
Jeremy Soller 52fd4d7e83 Clippy fixes 2018-12-02 08:04:53 -07:00
Jeremy Soller d4e42fd9e0 Merge branch 'type' into 'master'
Some type signature fixes found using script in #111

See merge request redox-os/relibc!181
2018-11-26 13:13:43 +00:00
Ian Douglas Scott fdd966629d Some type signature fixes found using script in #111 2018-11-25 20:58:02 -08:00
Jeremy Soller 5c4c49a9d1 Add getdelim and getline 2018-11-25 16:39:14 -07:00
Jeremy Soller 7398fae8b6 Re-add removed comments 2018-11-25 11:01:19 -07:00
Jeremy Soller 0ac16556bc Format 2018-11-25 10:34:42 -07:00
Jeremy Soller 52493a1ec3 Add popen/pclose 2018-11-25 10:33:50 -07:00
Jeremy Soller b4f36bce17 Add more stdio_ext functions 2018-11-22 19:09:46 -07:00
Jeremy Soller 632f9f18e5 fpending 2018-11-22 18:43:45 -07:00
Jeremy Soller ebffc977b2 Reduce warnings 2018-11-10 07:52:45 -07:00