Skip to content

Commit

Permalink
Removed missing/dup2.c
Browse files Browse the repository at this point in the history
This function should be always available, as POSIX-compliant or
Windows platform are required since 1.9.  Also the code in this
file is MT-unsafe.
  • Loading branch information
nobu committed May 10, 2021
1 parent 23f9351 commit aa8eed6
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 70 deletions.
1 change: 0 additions & 1 deletion LEGAL
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,6 @@ mentioned below.
[include/ruby/st.h]
[missing/acosh.c]
[missing/alloca.c]
[missing/dup2.c]
[missing/erf.c]
[missing/finite.c]
[missing/hypot.c]
Expand Down
9 changes: 7 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1858,10 +1858,16 @@ AS_CASE(["$target_os"],[freebsd*],[
AC_REPLACE_FUNCS(close)
])

AC_DEFUN([RUBY_REQUIRE_FUNC], [
AC_CHECK_FUNCS([$1])
AS_IF([test "$ac_cv_func_[]AS_TR_SH($1)" = yes], [],
[AC_MSG_ERROR($1[() must be supported])])
])
m4_map_args_w([dup dup2], [RUBY_REQUIRE_FUNC(], [)])

AC_REPLACE_FUNCS(acosh)
AC_REPLACE_FUNCS(cbrt)
AC_REPLACE_FUNCS(crypt)
AC_REPLACE_FUNCS(dup2)
AC_REPLACE_FUNCS(erf)
AC_REPLACE_FUNCS(explicit_bzero)
AC_REPLACE_FUNCS(ffs)
Expand Down Expand Up @@ -1922,7 +1928,6 @@ AC_CHECK_FUNCS(dirfd)
AC_CHECK_FUNCS(dl_iterate_phdr)
AC_CHECK_FUNCS(dlopen)
AC_CHECK_FUNCS(dladdr)
AC_CHECK_FUNCS(dup)
AC_CHECK_FUNCS(dup3)
AC_CHECK_FUNCS(eaccess)
AC_CHECK_FUNCS(endgrent)
Expand Down
4 changes: 0 additions & 4 deletions include/ruby/missing.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ RUBY_EXTERN double atanh(double);
RUBY_EXTERN char *crypt(const char *, const char *);
#endif

#ifndef HAVE_DUP2
RUBY_EXTERN int dup2(int, int);
#endif

#ifndef HAVE_EACCESS
RUBY_EXTERN int eaccess(const char*, int);
#endif
Expand Down
4 changes: 1 addition & 3 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,16 +462,14 @@ rb_cloexec_fcntl_dupfd(int fd, int minfd)
}
#elif defined(HAVE_FCNTL) && defined(F_DUPFD)
ret = fcntl(fd, F_DUPFD, minfd);
#elif defined(HAVE_DUP)
#else
ret = dup(fd);
if (ret >= 0 && ret < minfd) {
const int prev_fd = ret;
ret = rb_cloexec_fcntl_dupfd(fd, minfd);
close(prev_fd);
}
return ret;
#else
# error "dup() or fcntl(F_DUPFD) must be supported."
#endif
if (ret < 0) return ret;
rb_maygvl_fd_fix_cloexec(ret);
Expand Down
60 changes: 0 additions & 60 deletions missing/dup2.c

This file was deleted.

0 comments on commit aa8eed6

Please sign in to comment.