summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2019-12-04 12:30:06 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2019-12-26 20:45:12 +0900
commit719efe72b0707ed9b0e75a2bbf00e41ecc9ab451 (patch)
tree17be3d8248000829b6af7652ef04889c0ed71ce7 /internal
parentc524df078044dfbf44215557e7b7a0faaa3bc3db (diff)
internal/process.h rework
Eliminated the macro to convert into an inline function.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2711
Diffstat (limited to 'internal')
-rw-r--r--internal/process.h55
1 files changed, 38 insertions, 17 deletions
diff --git a/internal/process.h b/internal/process.h
index 8258f97f1b..c62b95bf80 100644
--- a/internal/process.h
+++ b/internal/process.h
@@ -9,8 +9,20 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
+#include "ruby/config.h" /* for rb_pid_t */
+#include <stddef.h> /* for size_t */
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h> /* for mode_t */
+#endif
+
+#ifdef _WIN32
+# include "ruby/win32.h" /* for mode_t */
+#endif
+
+#include "ruby/ruby.h" /* for VALUE */
+#include "internal/imemo.h" /* for RB_IMEMO_TMPBUF_PTR */
-/* process.c */
#define RB_MAX_GROUPS (65536)
struct waitpid_state;
@@ -60,24 +72,11 @@ struct rb_execarg {
VALUE chdir_dir;
};
-/* 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.
- * See rb_exec_fillarg() in process.c. */
-#define ARGVSTR2ARGV(argv_str) ((char **)RB_IMEMO_TMPBUF_PTR(argv_str) + 1)
-
-static inline size_t
-ARGVSTR2ARGC(VALUE argv_str)
-{
- size_t i = 0;
- char *const *p = ARGVSTR2ARGV(argv_str);
- while (p[i++])
- ;
- return i - 1;
-}
-
+/* process.c */
rb_pid_t rb_fork_ruby(int *status);
void rb_last_status_clear(void);
+static inline char **ARGVSTR2ARGV(VALUE argv_str);
+static inline size_t ARGVSTR2ARGC(VALUE argv_str);
RUBY_SYMBOL_EXPORT_BEGIN
/* process.c (export) */
@@ -92,4 +91,26 @@ int rb_execarg_run_options(const struct rb_execarg *e, struct rb_execarg *s, cha
VALUE rb_execarg_extract_options(VALUE execarg_obj, VALUE opthash);
void rb_execarg_setenv(VALUE execarg_obj, VALUE env);
RUBY_SYMBOL_EXPORT_END
+
+/* 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.
+ * See rb_exec_fillarg() in process.c. */
+static inline char **
+ARGVSTR2ARGV(VALUE argv_str)
+{
+ char **buf = RB_IMEMO_TMPBUF_PTR(argv_str);
+ return &buf[1];
+}
+
+static inline size_t
+ARGVSTR2ARGC(VALUE argv_str)
+{
+ size_t i = 0;
+ char *const *p = ARGVSTR2ARGV(argv_str);
+ while (p[i++])
+ ;
+ return i - 1;
+}
+
#endif /* INTERNAL_PROCESS_H */