summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-20 11:46:50 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-20 11:46:50 +0000
commitb60713de73dd3de6c610becb07ec30683d98af6b (patch)
tree9d3c097a7a158d9e44ea8bffdf69dd3b7461d7b6
parent826f98e688c5608dcb5aeb749d0511cf2724c3a3 (diff)
* internal.h (struct rb_execarg) moved and renamed from
struct rb_exec_arg in intern.h. * include/ruby/intern.h (struct rb_exec_arg): refer Data object which contains struct rb_execarg. * process.c: use struct rb_execarg instead of struct rb_exec_arg except functions declared in intern.h. (rb_exec_arg_addopt): extract a pointer to struct rb_execarg from struct rb_exec_arg. (rb_exec_arg_init): ditto. (rb_exec_arg_fixup): ditto. (rb_run_exec_options_err): ditto. (rb_run_exec_options): ditto. (rb_exec_err): ditto. (rb_exec): ditto. * io.c: use struct rb_execarg instead of struct rb_exec_arg. * ext/pty/pty.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog23
-rw-r--r--ext/pty/pty.c2
-rw-r--r--include/ruby/intern.h18
-rw-r--r--internal.h32
-rw-r--r--io.c10
-rw-r--r--process.c66
6 files changed, 89 insertions, 62 deletions
diff --git a/ChangeLog b/ChangeLog
index e3a2975c72..409af90238 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+Wed Jun 20 20:38:23 2012 Tanaka Akira <akr@fsij.org>
+
+ * internal.h (struct rb_execarg) moved and renamed from
+ struct rb_exec_arg in intern.h.
+
+ * include/ruby/intern.h (struct rb_exec_arg): refer Data object which
+ contains struct rb_execarg.
+
+ * process.c: use struct rb_execarg instead of struct rb_exec_arg
+ except functions declared in intern.h.
+ (rb_exec_arg_addopt): extract a pointer to struct rb_execarg from
+ struct rb_exec_arg.
+ (rb_exec_arg_init): ditto.
+ (rb_exec_arg_fixup): ditto.
+ (rb_run_exec_options_err): ditto.
+ (rb_run_exec_options): ditto.
+ (rb_exec_err): ditto.
+ (rb_exec): ditto.
+
+ * io.c: use struct rb_execarg instead of struct rb_exec_arg.
+
+ * ext/pty/pty.c: ditto.
+
Wed Jun 20 19:13:25 2012 Tanaka Akira <akr@fsij.org>
* internal.h (rb_execarg_new): declared.
diff --git a/ext/pty/pty.c b/ext/pty/pty.c
index 9e5aff9136..4ecf03eb58 100644
--- a/ext/pty/pty.c
+++ b/ext/pty/pty.c
@@ -79,7 +79,7 @@ struct child_info {
int master, slave;
char *slavename;
VALUE execarg_obj;
- struct rb_exec_arg *earg;
+ struct rb_execarg *earg;
};
static int
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index 308a1a94db..6389073265 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -582,23 +582,7 @@ VALUE rb_sym_all_symbols(void);
void rb_last_status_set(int status, rb_pid_t pid);
VALUE rb_last_status_get(void);
struct rb_exec_arg {
- int use_shell;
- union {
- struct {
- VALUE shell_script;
- } sh;
- struct {
- VALUE command_name;
- VALUE command_abspath; /* full path string or nil */
- VALUE argv_str;
- VALUE argv_buf;
- } cmd;
- } invoke;
- VALUE options;
- VALUE redirect_fds;
- VALUE envp_str;
- VALUE envp_buf;
- VALUE dup2_tmpbuf;
+ VALUE execarg_obj;
};
DEPRECATED(int rb_proc_exec_n(int, VALUE*, const char*));
int rb_proc_exec(const char*);
diff --git a/internal.h b/internal.h
index 50e3df35b3..e9a0ba1ed8 100644
--- a/internal.h
+++ b/internal.h
@@ -159,6 +159,26 @@ st_index_t rb_hash_proc(st_index_t hash, VALUE proc);
/* process.c */
+struct rb_execarg {
+ int use_shell;
+ union {
+ struct {
+ VALUE shell_script;
+ } sh;
+ struct {
+ VALUE command_name;
+ VALUE command_abspath; /* full path string or nil */
+ VALUE argv_str;
+ VALUE argv_buf;
+ } cmd;
+ } invoke;
+ VALUE options;
+ VALUE redirect_fds;
+ VALUE envp_str;
+ VALUE envp_buf;
+ VALUE dup2_tmpbuf;
+};
+
/* argv_str contains extra two elements.
* The beginning one is for /bin/sh used by exec_with_sh.
* The last one for terminating NULL used by execve.
@@ -264,14 +284,14 @@ VALUE rb_thread_call_without_gvl(
void rb_maygvl_fd_fix_cloexec(int fd);
/* process.c */
-int rb_exec_async_signal_safe(const struct rb_exec_arg *e, char *errmsg, size_t errmsg_buflen);
+int rb_exec_async_signal_safe(const struct rb_execarg *e, char *errmsg, size_t errmsg_buflen);
rb_pid_t rb_fork_async_signal_safe(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALUE fds, char *errmsg, size_t errmsg_buflen);
VALUE rb_execarg_new(int argc, VALUE *argv, int accept_shell);
-struct rb_exec_arg *rb_execarg_get(VALUE execarg_obj); /* dangerous. needs GC guard. */
-VALUE rb_execarg_init(int argc, VALUE *argv, int accept_shell, struct rb_exec_arg *e);
-int rb_execarg_addopt(struct rb_exec_arg *e, VALUE key, VALUE val);
-void rb_execarg_fixup(struct rb_exec_arg *e);
-int rb_execarg_run_options(const struct rb_exec_arg *e, struct rb_exec_arg *s, char* errmsg, size_t errmsg_buflen);
+struct rb_execarg *rb_execarg_get(VALUE execarg_obj); /* dangerous. needs GC guard. */
+VALUE rb_execarg_init(int argc, VALUE *argv, int accept_shell, struct rb_execarg *e);
+int rb_execarg_addopt(struct rb_execarg *e, VALUE key, VALUE val);
+void rb_execarg_fixup(struct rb_execarg *e);
+int rb_execarg_run_options(const struct rb_execarg *e, struct rb_execarg *s, char* errmsg, size_t errmsg_buflen);
#if defined __GNUC__ && __GNUC__ >= 4
#pragma GCC visibility pop
diff --git a/io.c b/io.c
index bf64f14292..22335bd3bb 100644
--- a/io.c
+++ b/io.c
@@ -5342,7 +5342,7 @@ rb_pipe(int *pipes)
#ifdef HAVE_FORK
struct popen_arg {
- struct rb_exec_arg *execp;
+ struct rb_execarg *execp;
int modef;
int pair[2];
int write_pair[2];
@@ -5466,7 +5466,7 @@ popen_exec(void *pp, char *errmsg, size_t errmsg_len)
#endif
static VALUE
-pipe_open(struct rb_exec_arg *eargp, const char *modestr, int fmode, convconfig_t *convconfig)
+pipe_open(struct rb_execarg *eargp, const char *modestr, int fmode, convconfig_t *convconfig)
{
VALUE prog = eargp ? (eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name) : Qfalse ;
rb_pid_t pid = 0;
@@ -5484,7 +5484,7 @@ pipe_open(struct rb_exec_arg *eargp, const char *modestr, int fmode, convconfig_
int pair[2], write_pair[2];
#endif
#if !defined(HAVE_FORK)
- struct rb_exec_arg sarg;
+ struct rb_execarg sarg;
#endif
FILE *fp = 0;
int fd = -1;
@@ -5727,7 +5727,7 @@ static VALUE
pipe_open_v(int argc, VALUE *argv, const char *modestr, int fmode, convconfig_t *convconfig)
{
VALUE execarg_obj, ret;
- struct rb_exec_arg *earg;
+ struct rb_execarg *earg;
execarg_obj = rb_execarg_new(argc, argv, FALSE);
earg = rb_execarg_get(execarg_obj);
ret = pipe_open(earg, modestr, fmode, convconfig);
@@ -5742,7 +5742,7 @@ pipe_open_s(VALUE prog, const char *modestr, int fmode, convconfig_t *convconfig
int argc = 1;
VALUE *argv = &prog;
VALUE execarg_obj, ret;
- struct rb_exec_arg *earg;
+ struct rb_execarg *earg;
if (RSTRING_LEN(prog) == 1 && cmd[0] == '-') {
#if !defined(HAVE_FORK)
diff --git a/process.c b/process.c
index 7307339011..ee5ba48773 100644
--- a/process.c
+++ b/process.c
@@ -1273,7 +1273,7 @@ enum {
static void
mark_exec_arg(void *ptr)
{
- struct rb_exec_arg *earg = ptr;
+ struct rb_execarg *earg = ptr;
if (earg->use_shell)
rb_gc_mark(earg->invoke.sh.shell_script);
else {
@@ -1298,7 +1298,7 @@ free_exec_arg(void *ptr)
static size_t
memsize_exec_arg(const void *ptr)
{
- return ptr ? sizeof(struct rb_exec_arg) : 0;
+ return ptr ? sizeof(struct rb_execarg) : 0;
}
static const rb_data_type_t exec_arg_data_type = {
@@ -1545,7 +1545,7 @@ static int rlimit_type_by_lname(const char *name);
#endif
int
-rb_execarg_addopt(struct rb_exec_arg *e, VALUE key, VALUE val)
+rb_execarg_addopt(struct rb_execarg *e, VALUE key, VALUE val)
{
VALUE options = e->options;
ID id;
@@ -1682,7 +1682,7 @@ redirect:
int
rb_exec_arg_addopt(struct rb_exec_arg *e, VALUE key, VALUE val)
{
- return rb_execarg_addopt(e, key, val);
+ return rb_execarg_addopt(rb_execarg_get(e->execarg_obj), key, val);
}
static int
@@ -1690,7 +1690,7 @@ check_exec_options_i(st_data_t st_key, st_data_t st_val, st_data_t arg)
{
VALUE key = (VALUE)st_key;
VALUE val = (VALUE)st_val;
- struct rb_exec_arg *e = (struct rb_exec_arg *)arg;
+ struct rb_execarg *e = (struct rb_execarg *)arg;
return rb_execarg_addopt(e, key, val);
}
@@ -1766,7 +1766,7 @@ check_exec_fds(VALUE options)
}
static void
-rb_check_exec_options(VALUE opthash, struct rb_exec_arg *e)
+rb_check_exec_options(VALUE opthash, struct rb_execarg *e)
{
if (RHASH_EMPTY_P(opthash))
return;
@@ -1884,12 +1884,12 @@ compare_posix_sh(const void *key, const void *el)
#endif
static void
-rb_exec_fillarg(VALUE prog, int argc, VALUE *argv, VALUE env, VALUE opthash, struct rb_exec_arg *e)
+rb_exec_fillarg(VALUE prog, int argc, VALUE *argv, VALUE env, VALUE opthash, struct rb_execarg *e)
{
VALUE options;
char fbuf[MAXPATHLEN];
- MEMZERO(e, struct rb_exec_arg, 1);
+ MEMZERO(e, struct rb_execarg, 1);
options = hide_obj(rb_ary_new());
e->options = options;
@@ -2059,22 +2059,22 @@ VALUE
rb_execarg_new(int argc, VALUE *argv, int accept_shell)
{
VALUE execarg_obj;
- struct rb_exec_arg *e;
- execarg_obj = TypedData_Make_Struct(rb_cData, struct rb_exec_arg, &exec_arg_data_type, e);
+ struct rb_execarg *e;
+ execarg_obj = TypedData_Make_Struct(rb_cData, struct rb_execarg, &exec_arg_data_type, e);
hide_obj(execarg_obj);
rb_execarg_init(argc, argv, accept_shell, e);
return execarg_obj;
}
-struct rb_exec_arg *rb_execarg_get(VALUE execarg_obj)
+struct rb_execarg *rb_execarg_get(VALUE execarg_obj)
{
- struct rb_exec_arg *e;
- TypedData_Get_Struct(execarg_obj, struct rb_exec_arg, &exec_arg_data_type, e);
+ struct rb_execarg *e;
+ TypedData_Get_Struct(execarg_obj, struct rb_execarg, &exec_arg_data_type, e);
return e;
}
VALUE
-rb_execarg_init(int argc, VALUE *argv, int accept_shell, struct rb_exec_arg *e)
+rb_execarg_init(int argc, VALUE *argv, int accept_shell, struct rb_execarg *e)
{
VALUE prog;
VALUE env = Qnil, opthash = Qnil;
@@ -2086,7 +2086,7 @@ rb_execarg_init(int argc, VALUE *argv, int accept_shell, struct rb_exec_arg *e)
VALUE
rb_exec_arg_init(int argc, VALUE *argv, int accept_shell, struct rb_exec_arg *e)
{
- return rb_execarg_init(argc, argv, accept_shell, e);
+ return rb_execarg_init(argc, argv, accept_shell, rb_execarg_get(e->execarg_obj));
}
static int
@@ -2108,7 +2108,7 @@ fill_envp_buf_i(st_data_t st_key, st_data_t st_val, st_data_t arg)
static long run_exec_dup2_tmpbuf_size(long n);
void
-rb_execarg_fixup(struct rb_exec_arg *e)
+rb_execarg_fixup(struct rb_execarg *e)
{
VALUE unsetenv_others, envopts;
VALUE ary;
@@ -2181,17 +2181,17 @@ rb_execarg_fixup(struct rb_exec_arg *e)
void
rb_exec_arg_fixup(struct rb_exec_arg *e)
{
- rb_execarg_fixup(e);
+ rb_execarg_fixup(rb_execarg_get(e->execarg_obj));
}
static void
-rb_exec_arg_prepare(struct rb_exec_arg *earg, int argc, VALUE *argv)
+rb_exec_arg_prepare(struct rb_execarg *earg, int argc, VALUE *argv)
{
rb_execarg_init(argc, argv, TRUE, earg);
rb_execarg_fixup(earg);
}
-static int rb_exec_without_timer_thread(const struct rb_exec_arg *e, char *errmsg, size_t errmsg_buflen);
+static int rb_exec_without_timer_thread(const struct rb_execarg *e, char *errmsg, size_t errmsg_buflen);
/*
* call-seq:
@@ -2248,7 +2248,7 @@ VALUE
rb_f_exec(int argc, VALUE *argv)
{
VALUE execarg_obj, fail_str;
- struct rb_exec_arg *earg;
+ struct rb_execarg *earg;
#define CHILD_ERRMSG_BUFLEN 80
char errmsg[CHILD_ERRMSG_BUFLEN] = { '\0' };
@@ -2712,7 +2712,7 @@ save_env(VALUE save)
/* This function should be async-signal-safe when _s_ is NULL. Hopefully it is. */
int
-rb_execarg_run_options(const struct rb_exec_arg *e, struct rb_exec_arg *s, char *errmsg, size_t errmsg_buflen)
+rb_execarg_run_options(const struct rb_execarg *e, struct rb_execarg *s, char *errmsg, size_t errmsg_buflen)
{
VALUE options = e->options;
VALUE soptions = Qnil;
@@ -2840,21 +2840,21 @@ rb_execarg_run_options(const struct rb_exec_arg *e, struct rb_exec_arg *s, char
int
rb_run_exec_options_err(const struct rb_exec_arg *e, struct rb_exec_arg *s, char *errmsg, size_t errmsg_buflen)
{
- return rb_execarg_run_options(e, s, errmsg, errmsg_buflen);
+ return rb_execarg_run_options(rb_execarg_get(e->execarg_obj), rb_execarg_get(s->execarg_obj), errmsg, errmsg_buflen);
}
int
rb_run_exec_options(const struct rb_exec_arg *e, struct rb_exec_arg *s)
{
- return rb_execarg_run_options(e, s, NULL, 0);
+ return rb_execarg_run_options(rb_execarg_get(e->execarg_obj), rb_execarg_get(s->execarg_obj), NULL, 0);
}
/* This function should be async-signal-safe. Hopefully it is. */
int
-rb_exec_async_signal_safe(const struct rb_exec_arg *e, char *errmsg, size_t errmsg_buflen)
+rb_exec_async_signal_safe(const struct rb_execarg *e, char *errmsg, size_t errmsg_buflen)
{
#if !defined(HAVE_FORK)
- struct rb_exec_arg sarg, *sargp = &sarg;
+ struct rb_execarg sarg, *sargp = &sarg;
#else
# define sargp NULL
#endif
@@ -2886,7 +2886,7 @@ failure:
}
static int
-rb_exec_without_timer_thread(const struct rb_exec_arg *e, char *errmsg, size_t errmsg_buflen)
+rb_exec_without_timer_thread(const struct rb_execarg *e, char *errmsg, size_t errmsg_buflen)
{
int ret;
before_exec_non_async_signal_safe(); /* async-signal-safe if forked_child is true */
@@ -2898,7 +2898,7 @@ rb_exec_without_timer_thread(const struct rb_exec_arg *e, char *errmsg, size_t e
int
rb_exec_err(const struct rb_exec_arg *e, char *errmsg, size_t errmsg_buflen)
{
- return rb_exec_without_timer_thread(e, errmsg, errmsg_buflen);
+ return rb_exec_without_timer_thread(rb_execarg_get(e->execarg_obj), errmsg, errmsg_buflen);
}
int
@@ -2906,7 +2906,7 @@ rb_exec(const struct rb_exec_arg *e)
{
#if !defined FD_CLOEXEC && !defined HAVE_SPAWNV
char errmsg[80] = { '\0' };
- int ret = rb_exec_without_timer_thread(e, errmsg, sizeof(errmsg));
+ int ret = rb_exec_without_timer_thread(rb_execarg_get(e->execarg_obj), errmsg, sizeof(errmsg));
preserving_errno(
if (errmsg[0]) {
fprintf(stderr, "%s\n", errmsg);
@@ -2919,7 +2919,7 @@ rb_exec(const struct rb_exec_arg *e)
);
return ret;
#else
- return rb_exec_without_timer_thread(e, NULL, 0);
+ return rb_exec_without_timer_thread(rb_execarg_get(e->execarg_obj), NULL, 0);
#endif
}
@@ -3485,7 +3485,7 @@ rb_syswait(rb_pid_t pid)
}
static rb_pid_t
-rb_spawn_process(struct rb_exec_arg *earg, char *errmsg, size_t errmsg_buflen)
+rb_spawn_process(struct rb_execarg *earg, char *errmsg, size_t errmsg_buflen)
{
rb_pid_t pid;
#if !USE_SPAWNV
@@ -3493,7 +3493,7 @@ rb_spawn_process(struct rb_exec_arg *earg, char *errmsg, size_t errmsg_buflen)
#endif
#if !defined HAVE_FORK || USE_SPAWNV
VALUE prog;
- struct rb_exec_arg sarg;
+ struct rb_execarg sarg;
#endif
#if defined HAVE_FORK && !USE_SPAWNV
@@ -3540,7 +3540,7 @@ static rb_pid_t
rb_spawn_internal(int argc, VALUE *argv, char *errmsg, size_t errmsg_buflen)
{
VALUE execarg_obj;
- struct rb_exec_arg *earg;
+ struct rb_execarg *earg;
VALUE ret;
execarg_obj = rb_execarg_new(argc, argv, TRUE);
@@ -3880,7 +3880,7 @@ rb_f_spawn(int argc, VALUE *argv)
rb_pid_t pid;
char errmsg[CHILD_ERRMSG_BUFLEN] = { '\0' };
VALUE execarg_obj, fail_str;
- struct rb_exec_arg *earg;
+ struct rb_execarg *earg;
execarg_obj = rb_execarg_new(argc, argv, TRUE);
earg = rb_execarg_get(execarg_obj);