# HG changeset patch # User John W. Eaton # Date 1265234702 18000 # Node ID 65b41bc71f094dff3e0ed9081599bbcf956a295f # Parent e317791645c4cb2abbd6ab514040e89a4efc379c use gnulib fcntl module diff -r e317791645c4 -r 65b41bc71f09 ChangeLog --- a/ChangeLog Wed Feb 03 15:27:53 2010 -0500 +++ b/ChangeLog Wed Feb 03 17:05:02 2010 -0500 @@ -1,3 +1,8 @@ +2010-02-03 John W. Eaton + + * configure.ac: Don't check for fcntl.h or fcntl. + * bootstrap.conf (gnulib_modules): Include fcntl in the list. + 2010-02-03 John W. Eaton * acinclude.m4 (OCTAVE_HAVE_C99_VSNPRINTF): Delete. diff -r e317791645c4 -r 65b41bc71f09 bootstrap.conf --- a/bootstrap.conf Wed Feb 03 15:27:53 2010 -0500 +++ b/bootstrap.conf Wed Feb 03 17:05:02 2010 -0500 @@ -20,6 +20,7 @@ gnulib_modules=" c-strcase crypto/md5 + fcntl fnmatch getcwd getopt-gnu diff -r e317791645c4 -r 65b41bc71f09 configure.ac --- a/configure.ac Wed Feb 03 15:27:53 2010 -0500 +++ b/configure.ac Wed Feb 03 17:05:02 2010 -0500 @@ -1448,7 +1448,7 @@ ### C headers -AC_CHECK_HEADERS(curses.h direct.h dlfcn.h fcntl.h \ +AC_CHECK_HEADERS(curses.h direct.h dlfcn.h \ floatingpoint.h grp.h ieeefp.h inttypes.h locale.h memory.h nan.h \ ncurses.h poll.h pthread.h pwd.h sunmath.h sys/ioctl.h \ sys/param.h sys/poll.h sys/resource.h sys/select.h \ @@ -1489,7 +1489,7 @@ ### Checks for functions and variables. AC_CHECK_FUNCS(basename canonicalize_file_name \ - chmod dup2 endgrent endpwent execvp expm1 expm1f fcntl fork \ + chmod dup2 endgrent endpwent execvp expm1 expm1f fork \ getegid geteuid getgid getgrent getgrgid getgrnam getpgrp getpid \ getppid getpwent getpwuid getuid getwd _kbhit kill \ lgamma lgammaf lgamma_r lgammaf_r localtime_r log1p log1pf \ diff -r e317791645c4 -r 65b41bc71f09 liboctave/ChangeLog --- a/liboctave/ChangeLog Wed Feb 03 15:27:53 2010 -0500 +++ b/liboctave/ChangeLog Wed Feb 03 17:05:02 2010 -0500 @@ -1,3 +1,11 @@ +2010-02-03 John W. Eaton + + * oct-syscalls.h, oct-syscalls.cc (octave_fcntl): Assume fcntl exists. + Rename from octave_syscalls::fcntl. + (octave_syscalls::popen2): Call octave_fcntl, not fcntl. + * cmd-hist.cc, lo-sysdep.cc, oct-syscalls.cc: + Include unconditionally. + 2010-02-03 John W. Eaton * dbleSVD.cc (SVD::init): Ensure args to std::max are the same type. diff -r e317791645c4 -r 65b41bc71f09 liboctave/cmd-hist.cc --- a/liboctave/cmd-hist.cc Wed Feb 03 15:27:53 2010 -0500 +++ b/liboctave/cmd-hist.cc Wed Feb 03 17:05:02 2010 -0500 @@ -42,13 +42,11 @@ #include -#ifdef HAVE_FCNTL_H -#include -#endif - #include #include +#include + #include "oct-rl-hist.h" #include "file-stat.h" diff -r e317791645c4 -r 65b41bc71f09 liboctave/lo-sysdep.cc --- a/liboctave/lo-sysdep.cc Wed Feb 03 15:27:53 2010 -0500 +++ b/liboctave/lo-sysdep.cc Wed Feb 03 17:05:02 2010 -0500 @@ -31,9 +31,7 @@ #include #include -#ifdef HAVE_FCNTL_H #include -#endif #if defined (__WIN32__) && ! defined (__CYGWIN__) #include diff -r e317791645c4 -r 65b41bc71f09 liboctave/oct-syscalls.cc --- a/liboctave/oct-syscalls.cc Wed Feb 03 15:27:53 2010 -0500 +++ b/liboctave/oct-syscalls.cc Wed Feb 03 17:05:02 2010 -0500 @@ -33,9 +33,7 @@ #include #include -#ifdef HAVE_FCNTL_H #include -#endif // We can't use csignal as kill is not in the std namespace, and picky // compiler runtimes will also exclude it from global scope as well. @@ -113,35 +111,6 @@ return status; } -int -octave_syscalls::fcntl (int fd, int cmd, long arg) -{ - std::string msg; - return fcntl (fd, cmd, arg, msg); -} - -int -octave_syscalls::fcntl (int fd, int cmd, long arg, std::string& msg) -{ - msg = std::string (); - - int status = -1; - -#if defined (HAVE_FCNTL) - status = ::fcntl (fd, cmd, arg); - - if (status < 0) - { - using namespace std; - msg = ::strerror (errno); - } -#else - msg = NOT_SUPPORTED ("fcntl"); -#endif - - return status; -} - pid_t octave_syscalls::fork (std::string& msg) { @@ -422,7 +391,7 @@ ::close (child_stdin[0]); ::close (child_stdout[1]); #if defined (F_SETFL) && defined (O_NONBLOCK) - if (! sync_mode && fcntl (child_stdout[0], F_SETFL, O_NONBLOCK, msg) < 0) + if (! sync_mode && octave_fcntl (child_stdout[0], F_SETFL, O_NONBLOCK, msg) < 0) msg = "popen2: error setting file mode -- " + msg; else #endif @@ -446,3 +415,28 @@ return -1; #endif } + +int +octave_fcntl (int fd, int cmd, long arg) +{ + std::string msg; + return octave_fcntl (fd, cmd, arg, msg); +} + +int +octave_fcntl (int fd, int cmd, long arg, std::string& msg) +{ + msg = std::string (); + + int status = -1; + + status = ::fcntl (fd, cmd, arg); + + if (status < 0) + { + using namespace std; + msg = ::strerror (errno); + } + + return status; +} diff -r e317791645c4 -r 65b41bc71f09 liboctave/oct-syscalls.h --- a/liboctave/oct-syscalls.h Wed Feb 03 15:27:53 2010 -0500 +++ b/liboctave/oct-syscalls.h Wed Feb 03 17:05:02 2010 -0500 @@ -40,9 +40,6 @@ static int execvp (const std::string&, const string_vector&); static int execvp (const std::string&, const string_vector&, std::string&); - static int fcntl (int, int, long); - static int fcntl (int, int, long, std::string&); - static pid_t fork (std::string&); static pid_t vfork (std::string&); @@ -72,3 +69,6 @@ }; #endif + +extern OCTAVE_API int octave_fcntl (int, int, long); +extern OCTAVE_API int octave_fcntl (int, int, long, std::string&); diff -r e317791645c4 -r 65b41bc71f09 src/ChangeLog --- a/src/ChangeLog Wed Feb 03 15:27:53 2010 -0500 +++ b/src/ChangeLog Wed Feb 03 17:05:02 2010 -0500 @@ -1,3 +1,11 @@ +2010-02-03 John W. Eaton + + * file-io.cc: Assume we have fcntl.h and sys/stat.h. + + * syscalls.cc: Assume we have fcntl.h and fcntl. + (Ffcntl): Use DEFUNX, not DEFUN. Call octave_fcntl, not + octave_syscalls::fcntl. + 2010-02-03 John W. Eaton * DLD-FUNCTIONS/sub2ind.cc (get_dim_vector): diff -r e317791645c4 -r 65b41bc71f09 src/file-io.cc --- a/src/file-io.cc Wed Feb 03 15:27:53 2010 -0500 +++ b/src/file-io.cc Wed Feb 03 17:05:02 2010 -0500 @@ -1953,12 +1953,8 @@ #endif #if ! defined (HAVE_MKSTEMP) && ! defined (HAVE_MKSTEMPS) && defined (_MSC_VER) -# if defined (HAVE_FCNTL_H) -# include -# endif -# if defined (HAVE_SYS_STAT_H) -# include -# endif +#include +#include int mkstemp (char *tmpl) { int ret=-1; diff -r e317791645c4 -r 65b41bc71f09 src/syscalls.cc --- a/src/syscalls.cc Wed Feb 03 15:27:53 2010 -0500 +++ b/src/syscalls.cc Wed Feb 03 17:05:02 2010 -0500 @@ -36,9 +36,7 @@ #include #include -#ifdef HAVE_FCNTL_H #include -#endif #include "file-ops.h" #include "file-stat.h" @@ -390,7 +388,7 @@ */ -DEFUN (fcntl, args, , +DEFUNX ("fcntl", Ffcntl, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} fcntl (@var{fid}, @var{request}, @var{arg})\n\ Change the properties of the open file @var{fid}. The following values\n\ @@ -474,7 +472,7 @@ { std::string msg; - int status = octave_syscalls::fcntl (fid, req, arg, msg); + int status = octave_fcntl (fid, req, arg, msg); retval(0) = status; retval(1) = msg;