summaryrefslogtreecommitdiffstats
path: root/sysif.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-06-29 21:21:06 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-06-29 21:21:06 -0700
commit9557a79765457c2cd1a7214f0d8d51d2ea62ed70 (patch)
treef01f0ef6ffe860d2ccabb053d937b24e058ebc04 /sysif.c
parent7006ede97348c57aff89d6af7d19bb6411d9b3f6 (diff)
downloadtxr-9557a79765457c2cd1a7214f0d8d51d2ea62ed70.tar.gz
txr-9557a79765457c2cd1a7214f0d8d51d2ea62ed70.tar.bz2
txr-9557a79765457c2cd1a7214f0d8d51d2ea62ed70.zip
c_num: now takes self argument.
The c_num and c_unum functions now take a self argument for identifying the calling function. This requires changes in a large number of places. In a few places, additional functions acquire a self argument. The ffi module has the most extensive example of this. Some functions mention their name in a larger string, or have scattered literals giving their name; with the introduction of the self local variable, these are replaced by references to self. In the following changelog, the notation TS stands for "take self argument", meaning that the functions acquires a new "val self" argument. The notation DS means "define self": the functions in question defines a self variable, which they pass down. The notation PS means that the functions pass down an existing self variable to functions that now require it. * args.h (args_count): TS. * arith.c (c_unum, c_num): TS. (toint, exptv): DS. * buf.c (buf_check_len, buf_check_alloc_size, buf_check_index, buf_do_set_len, replace_buf, buf_put_buf, buf_put_i8, buf_put_u8, buf_put_char, buf_put_uchar, buf_get_bytes, buf_get_i8, buf_get_u8, buf_get_cptr, buf_strm_get_byte_callback, buf_strm_unget_byte, buf_swap32, str_buf, buf_int, buf_uint, int_buf, uint_buf): PS. (make_duplicate_buf, buf_shrink, sub_buf, buf_print, buf_pprint): DS. * chskum.c (sha256_stream_impl, sha256_buf, crc32_buf, md5_stream_impl, md5_buf): TS. (chksum_ensure_buf, sha256_stream, sha256, sha256_hash, md5_stream, md5, md5_hash): PS. (crc32_stream): DS. * combi.c (perm_while_fun, perm_gen_fun_common, perm_str_gen_fun, rperm_gen_fun, comb_vec_gen_fun, comb_str_gen_fun, rcomb_vec_gen_fun, rcomb_str_gen_fun): DS. * diff.c (dbg_clear, dbg_set, dbg_restore): DS. * eval.c (do_eval, gather_free_refs, maprodv, maprendv, maprodo, do_args_apf, do_args_ipf): DS. (op_dwim, me_op, map_common): PS. (prod_common): TS. * ffi.c (struct txr_ffi_type): release member TS. (make_ffi_type_pointer): PS and release argument TS. (ffi_varray_dynsize, ffi_array_in, ffi_array_put_common, ffi_array_get_common, ffi_varray_in, ffi_varray_null_term): PS. (ffi_simple_release, ffi_ptr_in_release, ffi_struct_release, ffi_wchar_array_get, ffi_array_release_common, ffi_array_release, ffi_varray_release): TS. (ffi_float_put, double_put, ffi_be_i16_put, ffi_be_u16_put, ffi_le_i16_put, ffi_le_u16_put, ffi_be_i32_put, ffi_be_u32_put, ffi_le_i32_put, ffi_sbit_put, ffi_ubit_put, ffi_buf_d_put, make_ffi_type_array, make_ffi_type_enum, ffi_type_compile, make_ffi_type_desc, ffi_make_call_desc, ffi_call_wrap, ffi_closure_dispatch_save, ffi_put_into, ffi_in, ffi_get, ffi_put, carray_set_length, carray_blank, carray_buf, carray_buf_sync, carray_cptr, carray_refset, carray_sub, carray_replace, carray_uint, carray_int): PS. (carray_vec, carray_list): DS. * filter.c (url_encode, url_decode, base64_stream_enc_impl): DS. * ftw.c (ftw_callback, ftw_wrap): DS. * gc.c (mark_obj, gc_set_delta): DS. * glob.c (glob_wrap): DS. * hash.c (equal_hash, eql_hash, eq_hash, do_make_hash, hash_equal, set_hash_traversal_limit, gen_hash_seed): DS. * itypes.c (c_i8, c_u8, c_i16, c_u16, c_i32, c_u32, c_i64, c_u64, c_short, c_ushort, c_int, c_uint, c_long, c_ulong): PS. * lib.c (seq_iter_rewind): TS and becomes internal. (seq_iter_init_with_info, seq_setpos, replace_str, less, replace_vec, diff, isec, obj_print_impl): PS. (nthcdr, equal, mkstring, mkustring, upcase_str, downcase_str, search_str, sub_str, cat_str, scat2, scat3, fmt_join, split_str_keep, split_str_set, trim_str, int_str, chr_int, chr_str, chr_str_set, vector, vecref, vecref_l, list_vec, copy_vec, sub_vec, cat_vec, lazy_str_put, lazy_str_gt, length_str_ge, length_str_lt, length_str_le, cptr_size_hint, cptr_int, out_lazy_str, out_quasi_str, time_string_local_time, time_string_utc, time_fields_local_time, time_fields_utc, time_struct_local, time_struct_utc, make_time, time_meth, time_parse_meth): DS. (init_str, cat_str_init, cat_str_measure, cat_str_append, vscat, time_fields_to_tm, time_struct_to_tm, make_time_impl): TS. * lib.h (seq_iter_rewind): Declaration removed. (c_num, c_unum, init_str): Declarations updated. * match.c (LOG_MISMATCH, LOG_MATCH): PS. (h_skip, h_coll, do_output_line, do_output, v_skip, v_fuzz, v_collect): DS. * parser.c (parser, circ_backpatch, report_security_problem, hist_save, repl, lino_fileno, lino_getch, lineno_getl, lineno_gets, lineno_open): DS. (parser_set_lineno, lisp_parse_impl): PS. * parser.l (YY_INPUT): PS. * rand.c (make_random_state): PS. * regex.c (print_rec): DS. (search_regex): PS. * signal.c (kill_wrap, raise_wrap, get_sig_handler, getitimer_wrap, setitimer_wrap): DS. * socket.c (addrinfo_in, sockaddr_pack, fd_timeout, to_connect, open_sockfd, sock_mark_connected, sock_timeout): TS. (getaddrinfo_wrap, dgram_set_sock_peer, sock_bind, sock_connect, sock_listen, sock_accept, sock_shutdown, sock_send_timeout, sock_recv_timeout, socketpair_wrap): DS. * stream.c (generic_fill_buf, errno_to_string, stdio_truncate, string_out_put_string, open_fileno, open_command, base_name, dir-name): DS. (unget_byte, put_buf, fill_buf, fill_buf_adjust, get_line_as_buf, formatv, put_byte, test_set_indent_mode, test_neq_set_indent_mode, set_indent_mode, set_indent, inc_indent, set_max_length, set_max_depth, open_subprocess, run ): PS. (fds_subst, fds_swizzle): TS. * struct.c (make_struct_type, super, umethod_args_fun): PS. (method_args_fun): DS. * strudel.c (strudel_put_buf, strudel_fill_buf): DS. * sysif.c (errno_wrap, exit_wrap, usleep_wrap, mkdir_wrap, ensure_dir, makedev_wrap, minor_wrap, major_wrap, mknod_wrap, mkfifo_wrap, wait_wrap, wifexited, wexitstatus, wifsignaled, wtermsig, wcoredump, wifstopped, wstopsig, wifcontinued, dup_wrap, close_wrap, exit_star_wrap, umask_wrap, setuid_wrap, seteuid_wrap, setgid_wrap, setegid_wrap, simulate_setuid_setgid, getpwuid_wrap, fnmatch_wrap, dlopen_wrap): DS. (chmod_wrap, do_chown, flock_pack, do_utimes, poll_wrap, setgroups_wrap, setresuid_wrap, setresgid_wrap, getgrgid_wrap): PS. (c_time): TS. * sysif.h (c_time): Declaration updated. * syslog.c (openlog_wrap, syslog_wrap): DS. * termios.c (termios_pack): TS. (tcgetattr_wrap, tcsetattr_wrap, tcsendbreak_wrap, tcdrain_wrap, tcflush_wrap, tcflow_rap, encode_speeds, decode_speeds): DS. * txr.c (compato, array_dim, gc_delta): DS. * unwind.c (uw_find_frames_by_mask): DS. * vm.c (vm_make_desc): PS. (vm_make_closure, vm_swtch): DS.
Diffstat (limited to 'sysif.c')
-rw-r--r--sysif.c158
1 files changed, 97 insertions, 61 deletions
diff --git a/sysif.c b/sysif.c
index 7d383162..21bf00b4 100644
--- a/sysif.c
+++ b/sysif.c
@@ -135,9 +135,10 @@ static val at_exit_list;
static val errno_wrap(val newval)
{
+ val self = lit("errno");
val oldval = num(errno);
if (default_null_arg(newval))
- errno = c_num(newval);
+ errno = c_num(newval, self);
return oldval;
}
@@ -185,6 +186,7 @@ static val daemon_wrap(val nochdir, val noclose)
static val exit_wrap(val status)
{
+ val self = lit("exit");
int stat;
if missingp(status)
@@ -194,7 +196,7 @@ static val exit_wrap(val status)
else if (status == t)
stat = EXIT_SUCCESS;
else
- stat = c_num(status);
+ stat = c_num(status, self);
exit(stat);
/* notreached */
@@ -229,8 +231,9 @@ static val abort_wrap(void)
val usleep_wrap(val usec)
{
+ val self = lit("usleep");
val retval;
- cnum u = c_num(usec);
+ cnum u = c_num(usec, self);
sig_save_enable;
@@ -307,7 +310,8 @@ val errno_to_file_error(int err)
#if HAVE_MKDIR
static val mkdir_wrap(val path, val mode)
{
- cnum cmode = c_num(default_arg(mode, num_fast(0777)));
+ val self = lit("mkdir");
+ cnum cmode = c_num(default_arg(mode, num_fast(0777)), self);
char *u8path = utf8_dup_to(c_str(path));
int err = mkdir(u8path, cmode);
free(u8path);
@@ -423,6 +427,7 @@ static val mkdir_nothrow_exists(val path, val mode)
static val ensure_dir(val path, val mode)
{
+ val self = lit("ensure-dir");
#if HAVE_WINDOWS_H
val sep = lit("\\");
val sep_set = lit("\\/");
@@ -445,7 +450,7 @@ static val ensure_dir(val path, val mode)
}
if (integerp(ret)) {
- int eno = c_num(ret);
+ int eno = c_num(ret, self);
uw_throwf(errno_to_file_error(eno),
lit("ensure-dir: ~a: ~d/~s"), path, ret,
errno_to_str(eno), nao);
@@ -517,17 +522,20 @@ static val rmdir_wrap(val path)
static val makedev_wrap(val major, val minor)
{
- return num(makedev(c_num(major), c_num(minor)));
+ val self = lit("makedev");
+ return num(makedev(c_num(major, self), c_num(minor, self)));
}
static val minor_wrap(val dev)
{
- return num(minor(c_num(dev)));
+ val self = lit("minor");
+ return num(minor(c_num(dev, self)));
}
static val major_wrap(val dev)
{
- return num(major(c_num(dev)));
+ val self = lit("major");
+ return num(major(c_num(dev, self)));
}
#endif
@@ -536,8 +544,9 @@ static val major_wrap(val dev)
static val mknod_wrap(val path, val mode, val dev)
{
- cnum cmode = c_num(mode);
- cnum cdev = c_num(default_arg(dev, zero));
+ val self = lit("mknod");
+ cnum cmode = c_num(mode, self);
+ cnum cdev = c_num(default_arg(dev, zero), self);
char *u8path = utf8_dup_to(c_str(path));
int err = mknod(u8path, cmode, cdev);
free(u8path);
@@ -564,7 +573,8 @@ static val mknod_wrap(val path, val mode, val dev)
static val mkfifo_wrap(val path, val mode)
{
- cnum cmode = c_num(mode);
+ val self = lit("mkfifo");
+ cnum cmode = c_num(mode, self);
char *u8path = utf8_dup_to(c_str(path));
int err = mkfifo(u8path, cmode);
free(u8path);
@@ -599,7 +609,7 @@ static val chmod_wrap(val target, val mode)
int fd = if3(u8path, -1, get_fd(target, self));
if (integerp(mode)) {
- cmode = c_num(mode);
+ cmode = c_num(mode, self);
} else if (stringp(mode)) {
#if HAVE_SYS_STAT
struct stat st;
@@ -766,8 +776,8 @@ inval:
static val do_chown(val target, val uid, val gid, val link_p, val self)
{
- cnum cuid = c_num(uid);
- cnum cgid = c_num(gid);
+ cnum cuid = c_num(uid, self);
+ cnum cgid = c_num(gid, self);
int err;
if (stringp(target)) {
@@ -879,8 +889,8 @@ static void flock_pack(val self, val in, struct flock *out)
{
out->l_type = c_short(slot(in, type_s), self);
out->l_whence = c_short(slot(in, whence_s), self);
- out->l_start = c_num(slot(in, start_s));
- out->l_len = c_num(slot(in, len_s));
+ out->l_start = c_num(slot(in, start_s), self);
+ out->l_len = c_num(slot(in, len_s), self);
}
static void flock_unpack(val out, struct flock *in)
@@ -952,69 +962,79 @@ static val fork_wrap(void)
static val wait_wrap(val pid, val flags)
{
- cnum p = c_num(default_arg(pid, negone));
- cnum f = c_num(default_arg(flags, zero));
+ val self = lit("wait");
+ cnum p = c_num(default_arg(pid, negone), self);
+ cnum f = c_num(default_arg(flags, zero), self);
int status = 0, result = waitpid(p, &status, f);
return if2(result >= 0, cons(num(result), num(status)));
}
static val wifexited(val status)
{
- int s = c_num(if3(consp(status), cdr(status), status));
+ val self = lit("wifexited");
+ int s = c_num(if3(consp(status), cdr(status), status), self);
return tnil(WIFEXITED(s));
}
static val wexitstatus(val status)
{
- int s = c_num(if3(consp(status), cdr(status), status));
+ val self = lit("wexitstatus");
+ int s = c_num(if3(consp(status), cdr(status), status), self);
return num(WEXITSTATUS(s));
}
static val wifsignaled(val status)
{
- int s = c_num(if3(consp(status), cdr(status), status));
+ val self = lit("wifsignaled");
+ int s = c_num(if3(consp(status), cdr(status), status), self);
return tnil(WIFSIGNALED(s));
}
static val wtermsig(val status)
{
- int s = c_num(if3(consp(status), cdr(status), status));
+ val self = lit("wtermsig");
+ int s = c_num(if3(consp(status), cdr(status), status), self);
return num(WTERMSIG(s));
}
#ifdef WCOREDUMP
static val wcoredump(val status)
{
- int s = c_num(if3(consp(status), cdr(status), status));
+ val self = lit("wcoredump");
+ int s = c_num(if3(consp(status), cdr(status), status), self);
return tnil(WCOREDUMP(s));
}
#endif
static val wifstopped(val status)
{
- int s = c_num(if3(consp(status), cdr(status), status));
+ val self = lit("wifstopped");
+ int s = c_num(if3(consp(status), cdr(status), status), self);
return tnil(WIFSTOPPED(s));
}
static val wstopsig(val status)
{
- int s = c_num(if3(consp(status), cdr(status), status));
+ val self = lit("wstopsig");
+ int s = c_num(if3(consp(status), cdr(status), status), self);
return num(WSTOPSIG(s));
}
#ifdef WIFCONTINUED
static val wifcontinued(val status)
{
- int s = c_num(if3(consp(status), cdr(status), status));
+ val self = lit("wifcontinued");
+ int s = c_num(if3(consp(status), cdr(status), status), self);
return tnil(WIFCONTINUED(s));
}
#endif
static val dup_wrap(val old, val neu)
{
+ val self = lit("dupfd");
if (missingp(neu))
- return num(dup(c_num(old)));
- return num(dup2(c_num(old), c_num(neu)));
+ return num(dup(c_num(old, self)));
+ return num(dup2(c_num(old, self), c_num(neu, self)));
}
static val close_wrap(val fd, val throw_on_error)
@@ -1037,7 +1057,7 @@ val exec_wrap(val file, val args_opt)
{
val self = lit("execvp");
val args = default_null_arg(args_opt);
- int nargs = c_num(length(args)) + 1;
+ int nargs = c_num(length(args), self) + 1;
char **argv = if3(nargs < 0 || nargs == INT_MAX,
(uw_throwf(process_error_s, lit("~a: argument list overflow"),
self, nao), convert(char **, 0)),
@@ -1059,6 +1079,7 @@ val exec_wrap(val file, val args_opt)
static val exit_star_wrap(val status)
{
+ val self = lit("exit*");
int stat;
if (status == nil)
@@ -1066,7 +1087,7 @@ static val exit_star_wrap(val status)
else if (status == t)
stat = EXIT_SUCCESS;
else
- stat = c_num(status);
+ stat = c_num(status, self);
_exit(stat);
/* notreached */
@@ -1075,9 +1096,9 @@ static val exit_star_wrap(val status)
#endif
-time_t c_time(val time)
+time_t c_time(val time, val self)
{
- return if3(convert(time_t, -1) > 0, (time_t) c_unum(time), (time_t) c_num(time));
+ return if3(convert(time_t, -1) > 0, (time_t) c_unum(time, self), (time_t) c_num(time, self));
}
val num_time(time_t time)
@@ -1197,18 +1218,18 @@ static val do_utimes(val target, val atime, val atimens,
#if HAVE_FUTIMENS
int flags = if3(symlink_nofollow, AT_SYMLINK_NOFOLLOW, 0);
struct timespec times[2];
- times[0].tv_sec = c_time(atime);
+ times[0].tv_sec = c_time(atime, self);
times[0].tv_nsec = timens(atimens, self);
- times[1].tv_sec = c_time(mtime);
+ times[1].tv_sec = c_time(mtime, self);
times[1].tv_nsec = timens(mtimens, self);
res = utimensat(AT_FDCWD, u8path, times, flags);
#else
errno = -EINVAL;
if (integerp(atimens) || integerp(mtimens)) {
struct timeval times[2];
- times[0].tv_sec = c_time(atime);
+ times[0].tv_sec = c_time(atime, self);
times[0].tv_usec = c_long(trunc(atimens, num_fast(1000)), self);
- times[1].tv_sec = c_time(mtime);
+ times[1].tv_sec = c_time(mtime, self);
times[1].tv_usec = c_long(trunc(mtimens, num_fast(1000)), self);
if (symlink_nofollow) {
#if HAVE_LUTIMES
@@ -1231,9 +1252,9 @@ static val do_utimes(val target, val atime, val atimens,
#if HAVE_FUTIMENS
struct timespec times[2];
int fd = get_fd(target, self);
- times[0].tv_sec = c_time(atime);
+ times[0].tv_sec = c_time(atime, self);
times[0].tv_nsec = timens(atimens, self);
- times[1].tv_sec = c_time(mtime);
+ times[1].tv_sec = c_time(mtime, self);
times[1].tv_nsec = timens(mtimens, self);
res = futimens(fd, times);
#elif HAVE_FUTIMES
@@ -1241,9 +1262,9 @@ static val do_utimes(val target, val atime, val atimens,
int fd = get_fd(target, self);
errno = -EINVAL;
if (integerp(atimens) || integerp(mtimens)) {
- times[0].tv_sec = c_time(atime);
+ times[0].tv_sec = c_time(atime, self);
times[0].tv_usec = c_long(trunc(atimens, num_fast(1000)), self);
- times[1].tv_sec = c_time(mtime);
+ times[1].tv_sec = c_time(mtime, self);
times[1].tv_usec = c_long(trunc(mtimens, num_fast(1000)), self);
res = futimes(fd, times);
}
@@ -1282,12 +1303,14 @@ static val wrap_lutimes(val target, val atime, val atimens,
val umask_wrap(val mask)
{
+ val self = lit("umask");
+
if (missingp(mask)) {
mode_t m = umask(0777);
(void) umask(m);
return num(m);
}
- return num(umask(c_num(mask)));
+ return num(umask(c_num(mask, self)));
}
#endif
@@ -1344,7 +1367,8 @@ static val unsetenv_wrap(val name)
static val poll_wrap(val poll_list, val timeout_in)
{
- nfds_t i, len = c_num(length(poll_list));
+ val self = lit("poll");
+ nfds_t i, len = c_num(length(poll_list), self);
val iter;
struct pollfd *pfd = coerce(struct pollfd *, alloca(len * sizeof *pfd));
val timeout = default_arg(timeout_in, negone);
@@ -1353,11 +1377,11 @@ static val poll_wrap(val poll_list, val timeout_in)
for (i = 0, iter = poll_list; iter; iter = cdr(iter), i++) {
cons_bind (obj, events, car(iter));
- pfd[i].events = c_num(events);
+ pfd[i].events = c_num(events, self);
switch (type(obj)) {
case NUM:
- pfd[i].fd = c_num(obj);
+ pfd[i].fd = c_num(obj, self);
break;
case COBJ:
if (subtypep(obj->co.cls, stream_s)) {
@@ -1368,7 +1392,7 @@ static val poll_wrap(val poll_list, val timeout_in)
lit("poll: stream ~s doesn't have a file descriptor"),
obj, nao);
}
- pfd[i].fd = c_num(fdval);
+ pfd[i].fd = c_num(fdval, self);
break;
}
/* fallthrough */
@@ -1383,7 +1407,7 @@ static val poll_wrap(val poll_list, val timeout_in)
sig_save_enable;
- res = poll(pfd, len, c_num(timeout));
+ res = poll(pfd, len, c_num(timeout, self));
sig_restore_enable;
@@ -1463,7 +1487,8 @@ static val getgroups_wrap(void)
static val setuid_wrap(val nval)
{
- if (setuid(c_num(nval)) == -1)
+ val self = lit("setuid");
+ if (setuid(c_num(nval, self)) == -1)
uw_throwf(system_error_s, lit("setuid failed: ~d/~s"),
num(errno), errno_to_str(errno), nao);
return t;
@@ -1471,7 +1496,8 @@ static val setuid_wrap(val nval)
static val seteuid_wrap(val nval)
{
- if (seteuid(c_num(nval)) == -1)
+ val self = lit("seteuid");
+ if (seteuid(c_num(nval, self)) == -1)
uw_throwf(system_error_s, lit("seteuid failed: ~d/~s"),
num(errno), errno_to_str(errno), nao);
return t;
@@ -1479,7 +1505,8 @@ static val seteuid_wrap(val nval)
static val setgid_wrap(val nval)
{
- if (setgid(c_num(nval)) == -1)
+ val self = lit("setgid");
+ if (setgid(c_num(nval, self)) == -1)
uw_throwf(system_error_s, lit("setgid failed: ~d/~s"),
num(errno), errno_to_str(errno), nao);
return t;
@@ -1487,7 +1514,8 @@ static val setgid_wrap(val nval)
static val setegid_wrap(val nval)
{
- if (setegid(c_num(nval)) == -1)
+ val self = lit("setegid");
+ if (setegid(c_num(nval, self)) == -1)
uw_throwf(system_error_s, lit("setegid failed: ~d/~s"),
num(errno), errno_to_str(errno), nao);
return t;
@@ -1581,6 +1609,8 @@ void drop_privilege(void)
void simulate_setuid_setgid(val open_script)
{
+ val self = lit("txr");
+
if (repress_called != RC_MAGIC || (is_setuid && seteuid(orig_euid) != 0))
abort();
@@ -1592,7 +1622,7 @@ void simulate_setuid_setgid(val open_script)
if (fdv) {
struct stat stb;
- cnum fd = c_num(fdv);
+ cnum fd = c_num(fdv, self);
if (fstat(fd, &stb) != 0)
goto drop;
@@ -1620,7 +1650,7 @@ drop:
static val setgroups_wrap(val list)
{
val self = lit("setgroups");
- ucnum len = c_num(length(list));
+ ucnum len = c_num(length(list), self);
if (convert(ucnum, convert(size_t, len)) != len) {
uw_throwf(system_error_s, lit("~a: list too long"), self, nao);
@@ -1629,7 +1659,7 @@ static val setgroups_wrap(val list)
int i = 0, res;
for (; list; i++, list = cdr(list)) {
- cnum gid = c_num(car(list));
+ cnum gid = c_num(car(list), self);
arr[i] = gid;
}
@@ -1669,7 +1699,8 @@ static val getresgid_wrap(void)
static val setresuid_wrap(val r, val e, val s)
{
- if (setresuid(c_num(r), c_num(e), c_num(s)) != 0)
+ val self = lit("setresuid");
+ if (setresuid(c_num(r, self), c_num(e, self), c_num(s, self)) != 0)
uw_throwf(system_error_s, lit("setresuid failed: ~d/~s"),
num(errno), errno_to_str(errno), nao);
return t;
@@ -1677,7 +1708,8 @@ static val setresuid_wrap(val r, val e, val s)
static val setresgid_wrap(val r, val e, val s)
{
- if (setresuid(c_num(r), c_num(e), c_num(s)) != 0)
+ val self = lit("setresgid");
+ if (setresuid(c_num(r, self), c_num(e, self), c_num(s, self)) != 0)
uw_throwf(system_error_s, lit("setresuid failed: ~d/~s"),
num(errno), errno_to_str(errno), nao);
return t;
@@ -1733,9 +1765,10 @@ static val getpwent_wrap(void)
static val getpwuid_wrap(val uid)
{
+ val self = lit("getpwuid");
char buf[1024];
struct passwd pw, *p;
- int res = getpwuid_r(c_num(uid), &pw, buf, sizeof buf, &p);
+ int res = getpwuid_r(c_num(uid, self), &pw, buf, sizeof buf, &p);
return (res == 0 && p != 0) ? make_pwstruct(&pw) : nil;
}
@@ -1761,7 +1794,7 @@ static val getpwent_wrap(void)
static val getpwuid_wrap(val uid)
{
- struct passwd *p = getpwuid(c_num(uid));
+ struct passwd *p = getpwuid(c_num(uid, self));
return (p != 0) ? make_pwstruct(p) : nil;
}
@@ -1826,9 +1859,10 @@ static val getgrent_wrap(void)
static val getgrgid_wrap(val uid)
{
+ val self = lit("getgrgid");
char buf[1024];
struct group gr, *g;
- int res = getgrgid_r(c_num(uid), &gr, buf, sizeof buf, &g);
+ int res = getgrgid_r(c_num(uid, self), &gr, buf, sizeof buf, &g);
return (res == 0 && g != 0) ? make_grstruct(&gr) : nil;
}
@@ -1848,7 +1882,7 @@ static val getgrnam_wrap(val wname)
static val getgrgid_wrap(val uid)
{
- struct group *g = getgrgid(c_num(uid));
+ struct group *g = getgrgid(c_num(uid, self));
return (g != 0) ? make_grstruct(g) : nil;
}
@@ -1997,9 +2031,10 @@ int stdio_fseek(FILE *f, val off, int whence)
#if HAVE_FNMATCH
static val fnmatch_wrap(val pattern, val string, val flags)
{
+ val self = lit("fnmatch");
const wchar_t *pattern_ws = c_str(pattern);
const wchar_t *string_ws = c_str(string);
- cnum c_flags = c_num(default_arg(flags, zero));
+ cnum c_flags = c_num(default_arg(flags, zero), self);
char *pattern_u8 = utf8_dup_to(pattern_ws);
char *string_u8 = utf8_dup_to(string_ws);
int res = fnmatch(pattern_u8, string_u8, c_flags);
@@ -2057,10 +2092,11 @@ static struct cobj_ops cptr_dl_ops = cobj_ops_init(cobj_equal_handle_op,
static val dlopen_wrap(val name, val flags)
{
+ val self = lit("dlopen");
const wchar_t *name_ws = if3(null_or_missing_p(name),
0, c_str(name));
char *name_u8 = if3(name_ws != 0, utf8_dup_to(name_ws), 0);
- cnum f = if3(missingp(flags), RTLD_LAZY, c_num(flags));
+ cnum f = if3(missingp(flags), RTLD_LAZY, c_num(flags, self));
mem_t *ptr = coerce(mem_t *, (dlerror(), dlopen(name_u8, f)));
free(name_u8);
if (ptr == 0) {