summaryrefslogtreecommitdiffstats
path: root/stdlib
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-09-07 23:24:04 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-09-07 23:24:04 -0700
commit7f32442862bfc785e613af33d48d1a4a4dae8835 (patch)
tree95d693bbecd8193f9bb91b2667ec7d3613a74373 /stdlib
parente9c5a283537e9d7a0722189dbaf295d9f684a7e8 (diff)
downloadtxr-7f32442862bfc785e613af33d48d1a4a4dae8835.tar.gz
txr-7f32442862bfc785e613af33d48d1a4a4dae8835.tar.bz2
txr-7f32442862bfc785e613af33d48d1a4a4dae8835.zip
exceptions: hack to store errno in string object.
Basic idea: when we throw an exception that pertains to a system error which has an errno code, we can stick the errno into the memory area of the character string, into the wchar_t that immediately follows the null terminator. We can do this because strings track their actual allocation size. A pair of setter/getter functions to set and retrieve this value are provided, and all functions in the code which can set such a code are updated to do so, simply by calling the newly added uw_ethrowf that drop-in replaces for uw_throwf. * lib.[ch] (string_set_code, string_get_code): New functions. * unwind.[ch] (uw_ethrowf): New function. * eval.c (eval_init): Register string-set-code and string-get-code intrinsics. * ftw.c (ftw_wrap): Switch to uw_ethrowf. * parser.c (open_txr_file): Likewise. * socket.c (dgram_overflow): Store the ENOBUFS error in errno, and use uw_ethrowf instead uw_throwf. (dgram_get_byte_callback, dgram_flush, sock_bind, to_connect, open_sockfd, sock_connect, sock_listen, sock_accept, sock_shutdown, sock_timeout, socketpair_wrap): Switch to uw_ethrowf. * stream.c (dev_null_get_fd, stdio_maybe_read_error, stdio_maybe_error, stdio_close, pipe_close, open_directory, open_file, open_fileno, open_tail, fds_subst, open_subprocess, open_command, remove_path, rename_path, tmpfile_wrap, mkdtemp_wrap, mkstemp_wrap): Switch to uw_ethrowf. * sysif.c (mkdir_wrap, ensure_dir, chdir_wrap, getcwd_wrap, rmdir_wrap, mknod_wrap, mkfifo_wrap, chmod_wrap, do_chown, symlink_wrap, link_wrap, readlink_wrap, close_wrap, val exec_wrap, stat_impl, do_utimes, pipe_wrap, poll_wrap, getgroups_wrap, setuid_wrap, seteuid_wrap, setgid_wrap, setegid_wrap, setgroups_wrap, getresuid_wrap, setresuid_wrap, setresgid_wrap, crypt_wrap, uname_wrap, opendir_wrap, getrlimit_wrap, setrlimit_wrap): Likewise. * termios.c (tcgetattr_wrap, tcsetattr_wrap, tcsendbreak_wrap, tcdrain_wrap, tcflush_wrap, tcflow_wrap): Likewise. * tests/018/errno.tl: New file. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/doc-syms.tl26
1 files changed, 14 insertions, 12 deletions
diff --git a/stdlib/doc-syms.tl b/stdlib/doc-syms.tl
index 2f95f333..8875254b 100644
--- a/stdlib/doc-syms.tl
+++ b/stdlib/doc-syms.tl
@@ -81,7 +81,7 @@
("<!" "N-02B10DF9")
("<-" "N-02B10DF9")
("<=" "D-001E")
- ("=" "D-0077")
+ ("=" "D-0078")
(">" "D-0060")
(">=" "D-0053")
("TXR_COMPAT" "N-03F5D03D")
@@ -296,8 +296,8 @@
("cdar" "N-001FA3CB")
("cdddddr" "N-001FA3CB")
("cddr" "N-001FA3CB")
- ("cdr" "D-0076")
- ("ceil" "D-007B")
+ ("cdr" "D-0077")
+ ("ceil" "D-007C")
("ceil-rem" "N-02DE978F")
("ceil1" "N-02C8FF28")
("chain" "N-00C53CF7")
@@ -409,7 +409,7 @@
("copy-tree-iter" "N-025C3140")
("copy-vec" "N-010E7635")
("cos" "D-0021")
- ("cosh" "D-007F")
+ ("cosh" "D-0080")
("count-if" "N-00BBC726")
("count-until-match" "N-00EFD668")
("countq" "N-01DF131F")
@@ -637,11 +637,11 @@
("eprototype" "N-036B1BDB")
("eq" "N-02550B35")
("eql" "N-02550B35")
- ("equal" "D-0079")
+ ("equal" "D-007A")
("equot" "N-02ACCDDF")
("erange" "N-036B1BDB")
("erofs" "N-036B1BDB")
- ("errno" "N-03A7137C")
+ ("errno" "D-0076")
("error" "N-015466AD")
("espipe" "N-036B1BDB")
("esrch" "N-036B1BDB")
@@ -726,7 +726,7 @@
("file-put" "N-0041C2E5")
("file-put-buf" "N-02AE3A31")
("file-put-json" "D-002A")
- ("file-put-jsons" "D-007C")
+ ("file-put-jsons" "D-007D")
("file-put-lines" "N-0041C2E5")
("file-put-string" "N-0041C2E5")
("fileno" "N-008ACF75")
@@ -739,7 +739,7 @@
("filter-equal" "N-03136087")
("filter-string-tree" "N-00C9EEB0")
("finalize" "N-01230613")
- ("finally" "D-0078")
+ ("finally" "D-0079")
("find" "N-00C9DFF6")
("find-frame" "N-02B97226")
("find-frames" "N-02B97226")
@@ -1114,7 +1114,7 @@
("listp" "N-03F70343")
("lnew" "N-0230059D")
("lnew*" "N-021E6FDC")
- ("load" "D-0080")
+ ("load" "D-0081")
("load-for" "N-0020A085")
("load-time" "D-0047")
("loff-t" "N-01153D9E")
@@ -1476,7 +1476,7 @@
("push-after-load" "N-01F489FE")
("pushhash" "N-022660B2")
("pushnew" "N-02C37AB0")
- ("put-buf" "D-007E")
+ ("put-buf" "D-007F")
("put-byte" "D-002F")
("put-carray" "N-00737951")
("put-char" "D-0003")
@@ -1486,7 +1486,7 @@
("put-line" "N-012163C3")
("put-lines" "N-0367B282")
("put-obj" "N-025DB229")
- ("put-string" "D-007A")
+ ("put-string" "D-007B")
("put-strings" "N-0367B282")
("pwd" "N-0047F5F6")
("qquote" "N-01665185")
@@ -1572,7 +1572,7 @@
("replace-struct" "N-01A8343B")
("replace-tree-iter" "N-01225FF3")
("replace-vec" "N-01F59E62")
- ("require" "D-007D")
+ ("require" "D-007E")
("reset-struct" "N-002A609F")
("rest" "N-02288559")
("ret" "N-033F39EF")
@@ -1820,7 +1820,9 @@
("string-encode" "N-033502F8")
("string-extend" "N-03D5358A")
("string-finish" "N-0295275B")
+ ("string-get-code" "N-01CF6D14")
("string-lt" "N-03ABBED1")
+ ("string-set-code" "N-01CF6D14")
("stringp" "N-00BB392B")
("strsignal" "N-00234BED")
("struct" "D-001B")