mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
internal/process.h rework
Eliminated the macro to convert into an inline function.
This commit is contained in:
parent
c524df0780
commit
719efe72b0
Notes:
git
2019-12-26 20:45:58 +09:00
1 changed files with 38 additions and 17 deletions
|
@ -9,8 +9,20 @@
|
||||||
* modify this file, provided that the conditions mentioned in the
|
* modify this file, provided that the conditions mentioned in the
|
||||||
* file COPYING are met. Consult the file for details.
|
* 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)
|
#define RB_MAX_GROUPS (65536)
|
||||||
|
|
||||||
struct waitpid_state;
|
struct waitpid_state;
|
||||||
|
@ -60,24 +72,11 @@ struct rb_execarg {
|
||||||
VALUE chdir_dir;
|
VALUE chdir_dir;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* argv_str contains extra two elements.
|
/* process.c */
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
rb_pid_t rb_fork_ruby(int *status);
|
rb_pid_t rb_fork_ruby(int *status);
|
||||||
void rb_last_status_clear(void);
|
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
|
RUBY_SYMBOL_EXPORT_BEGIN
|
||||||
/* process.c (export) */
|
/* 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);
|
VALUE rb_execarg_extract_options(VALUE execarg_obj, VALUE opthash);
|
||||||
void rb_execarg_setenv(VALUE execarg_obj, VALUE env);
|
void rb_execarg_setenv(VALUE execarg_obj, VALUE env);
|
||||||
RUBY_SYMBOL_EXPORT_END
|
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 */
|
#endif /* INTERNAL_PROCESS_H */
|
||||||
|
|
Loading…
Reference in a new issue