aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-10-31 13:44:21 +0000
committergingerBill <bill@gingerbill.org>2021-10-31 13:44:21 +0000
commit0d2c8dfeecad04fb8f42abeea6dfa3e52687db01 (patch)
tree8ab11eab5bc1a9a6a657136a7e4d2d2a89d36f52
parent305e965bcbd8f0755fa848021b96688a84b143ec (diff)
Separate os-specific things to separate file
-rw-r--r--core/fmt/fmt.odin33
-rw-r--r--core/fmt/fmt_os.odin37
2 files changed, 37 insertions, 33 deletions
diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin
index 1f8949002..2cf032b73 100644
--- a/core/fmt/fmt.odin
+++ b/core/fmt/fmt.odin
@@ -2,7 +2,6 @@ package fmt
import "core:math/bits"
import "core:mem"
-import "core:os"
import "core:io"
import "core:reflect"
import "core:runtime"
@@ -62,38 +61,6 @@ register_user_formatter :: proc(id: typeid, formatter: User_Formatter) -> Regist
}
-fprint :: proc(fd: os.Handle, args: ..any, sep := " ") -> int {
- w := io.to_writer(os.stream_from_handle(fd))
- return wprint(w=w, args=args, sep=sep)
-}
-
-fprintln :: proc(fd: os.Handle, args: ..any, sep := " ") -> int {
- w := io.to_writer(os.stream_from_handle(fd))
- return wprintln(w=w, args=args, sep=sep)
-}
-fprintf :: proc(fd: os.Handle, fmt: string, args: ..any) -> int {
- w := io.to_writer(os.stream_from_handle(fd))
- return wprintf(w, fmt, ..args)
-}
-fprint_type :: proc(fd: os.Handle, info: ^runtime.Type_Info) -> (n: int, err: io.Error) {
- w := io.to_writer(os.stream_from_handle(fd))
- return wprint_type(w, info)
-}
-fprint_typeid :: proc(fd: os.Handle, id: typeid) -> (n: int, err: io.Error) {
- w := io.to_writer(os.stream_from_handle(fd))
- return wprint_typeid(w, id)
-}
-
-// print* procedures return the number of bytes written
-print :: proc(args: ..any, sep := " ") -> int { return fprint(fd=os.stdout, args=args, sep=sep) }
-println :: proc(args: ..any, sep := " ") -> int { return fprintln(fd=os.stdout, args=args, sep=sep) }
-printf :: proc(fmt: string, args: ..any) -> int { return fprintf(os.stdout, fmt, ..args) }
-
-eprint :: proc(args: ..any, sep := " ") -> int { return fprint(fd=os.stderr, args=args, sep=sep) }
-eprintln :: proc(args: ..any, sep := " ") -> int { return fprintln(fd=os.stderr, args=args, sep=sep) }
-eprintf :: proc(fmt: string, args: ..any) -> int { return fprintf(os.stderr, fmt, ..args) }
-
-
// aprint* procedures return a string that was allocated with the current context
// They must be freed accordingly
aprint :: proc(args: ..any, sep := " ") -> string {
diff --git a/core/fmt/fmt_os.odin b/core/fmt/fmt_os.odin
new file mode 100644
index 000000000..b31deb8fc
--- /dev/null
+++ b/core/fmt/fmt_os.odin
@@ -0,0 +1,37 @@
+//+build !freestanding
+package fmt
+
+import "core:runtime"
+import "core:os"
+import "core:io"
+
+fprint :: proc(fd: os.Handle, args: ..any, sep := " ") -> int {
+ w := io.to_writer(os.stream_from_handle(fd))
+ return wprint(w=w, args=args, sep=sep)
+}
+
+fprintln :: proc(fd: os.Handle, args: ..any, sep := " ") -> int {
+ w := io.to_writer(os.stream_from_handle(fd))
+ return wprintln(w=w, args=args, sep=sep)
+}
+fprintf :: proc(fd: os.Handle, fmt: string, args: ..any) -> int {
+ w := io.to_writer(os.stream_from_handle(fd))
+ return wprintf(w, fmt, ..args)
+}
+fprint_type :: proc(fd: os.Handle, info: ^runtime.Type_Info) -> (n: int, err: io.Error) {
+ w := io.to_writer(os.stream_from_handle(fd))
+ return wprint_type(w, info)
+}
+fprint_typeid :: proc(fd: os.Handle, id: typeid) -> (n: int, err: io.Error) {
+ w := io.to_writer(os.stream_from_handle(fd))
+ return wprint_typeid(w, id)
+}
+
+// print* procedures return the number of bytes written
+print :: proc(args: ..any, sep := " ") -> int { return fprint(fd=os.stdout, args=args, sep=sep) }
+println :: proc(args: ..any, sep := " ") -> int { return fprintln(fd=os.stdout, args=args, sep=sep) }
+printf :: proc(fmt: string, args: ..any) -> int { return fprintf(os.stdout, fmt, ..args) }
+
+eprint :: proc(args: ..any, sep := " ") -> int { return fprint(fd=os.stderr, args=args, sep=sep) }
+eprintln :: proc(args: ..any, sep := " ") -> int { return fprintln(fd=os.stderr, args=args, sep=sep) }
+eprintf :: proc(fmt: string, args: ..any) -> int { return fprintf(os.stderr, fmt, ..args) }