view liboctave/wrappers/wait-wrappers.c @ 24118:f87c9f5c0f43

maint: silence several compiler warnings when building for Windows * sighandlers.cc (w32_interrupt_manager::do_jump_to_enclosing_context): Use reinterpret_cast to silence compiler warning from -Wold-style-cast. * welcome-wizard.cc (welcome_wizard::welcome_wizard): Likewise. * oct-procbuf.cc (octave_procbuf_list): Only define on systems that use it to silence compiler warning from -Wunused-variable. * sysdep.cc (w32_shell_execute): Delete empty unused function to silence several compiler warnings. (raw_mode): Use octave_unused_parameter to silence compiler warnings from -Wunused-parameter on certain systems. * cdisplay.c (octave_get_display_info): Use octave_unused_parameter to silence compiler warning from -Wunused-parameter on certain systems. * oct-group.cc (octave::sys::group::getgrgid, octave::sys::group::getgrnam, octave::sys::group::group): Likewise. * oct-passwd.cc (octave::sys::password::getpwuid, octave::sys::password::getpwnam, octave::sys::password::password): Likewise. * signal-wrappers.c (octave_kill_wrapper, block_or_unblock_signal): Likewise. * wait-for-input.c (octave_wait_for_input): Likewise. * unistd-wrappers.c (prepare_spawn): Add const-qualifier on argument to silence compiler warning from -Wdiscarded-qualifiers. * stat-wrappers.c: Use pragma to disable -Wunused-parameter warnings for wrapper functions around macros that may discard their arguments on certain systems. * wait-wrappers.c Use pragma to disable -Wunused-parameter warnings for wrapper functions around macros that may discard their arguments on certain systems. Reorder functions to group related wrappers. (octave_waitpid_wrapper): Use octave_unused_parameter to silence compiler warning from -Wunused-parameter on certain systems.
author Mike Miller <mtmiller@octave.org>
date Sun, 01 Oct 2017 14:52:33 -0700
parents 092078913d54
children 194eb4bd202b
line wrap: on
line source

/*

Copyright (C) 2016-2017 John W. Eaton

This file is part of Octave.

Octave is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

Octave is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Octave; see the file COPYING.  If not, see
<http://www.gnu.org/licenses/>.

*/

// These functions may be provided by gnulib.  We don't include gnulib
// headers directly in Octave's C++ source files to avoid problems that
// may be caused by the way that gnulib overrides standard library
// functions.

#if defined (HAVE_CONFIG_H)
#  include "config.h"
#endif

#include <sys/types.h>
#include <sys/wait.h>

#include "wait-wrappers.h"

#if ! defined (WCONTINUE)
#  define WCONTINUE 0
#endif

#if ! defined (WNOHANG)
#  define WNOHANG 0
#endif

#if ! defined (WUNTRACED)
#  define WUNTRACED 0
#endif

#if ! defined (WIFCONTINUED)
#  define WIFCONTINUED(x) false
#endif

pid_t
octave_waitpid_wrapper (pid_t pid, int *statusp, int options)
{
#if defined (__WIN32__) && ! defined (__CYGWIN__)

  octave_unused_parameter (pid);
  octave_unused_parameter (options);

  // gnulib's waitpid replacement currently uses _cwait, which
  // apparently only works with console applications.
  *statusp = 0;
  return -1;
#else
  return waitpid (pid, statusp, options);
#endif
}

int
octave_wcontinue_wrapper (void)
{
  return WCONTINUE;
}

int
octave_wnohang_wrapper (void)
{
  return WNOHANG;
}

int
octave_wuntraced_wrapper (void)
{
  return WUNTRACED;
}

#if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
// Disable the unused parameter warning for the following wrapper functions.
// The <sys/wait.h> header provided by gnulib may define some of the W*
// macros to expand to a constant and ignore the parameter.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif

int
octave_wcoredump_wrapper (int status)
{
  return WCOREDUMP (status);
}

int
octave_wexitstatus_wrapper (int status)
{
  return WEXITSTATUS (status);
}

bool
octave_wifcontinued_wrapper (int status)
{
  return WIFCONTINUED (status);
}

bool
octave_wifexited_wrapper (int status)
{
  return WIFEXITED (status);
}

bool
octave_wifsignaled_wrapper (int status)
{
  return WIFSIGNALED (status);
}

bool
octave_wifstopped_wrapper (int status)
{
  return WIFSTOPPED (status);
}

int
octave_wstopsig_wrapper (int status)
{
  return WSTOPSIG (status);
}

int
octave_wtermsig_wrapper (int status)
{
  return WTERMSIG (status);
}

#if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
// Restore prevailing warning state for remainder of the file.
#pragma GCC diagnostic pop
#endif