/* Low-level file-handling.
- Copyright (C) 2012-2014 Free Software Foundation, Inc.
+ Copyright (C) 2012-2015 Free Software Foundation, Inc.
This file is part of GDB.
/* See filestuff.h. */
int
-gdb_socketpair_cloexec (int namespace, int style, int protocol, int filedes[2])
+gdb_socketpair_cloexec (int domain, int style, int protocol,
+ int filedes[2])
{
#ifdef HAVE_SOCKETPAIR
- int result = socketpair (namespace, style | SOCK_CLOEXEC, protocol, filedes);
+ int result = socketpair (domain, style | SOCK_CLOEXEC, protocol, filedes);
if (result != -1)
{
/* See filestuff.h. */
int
-gdb_socket_cloexec (int namespace, int style, int protocol)
+gdb_socket_cloexec (int domain, int style, int protocol)
{
- int result = socket (namespace, style | SOCK_CLOEXEC, protocol);
+ int result = socket (domain, style | SOCK_CLOEXEC, protocol);
if (result != -1)
socket_mark_cloexec (result);
return result;
}
+
+/* Helper function which does the work for make_cleanup_close. */
+
+static void
+do_close_cleanup (void *arg)
+{
+ int *fd = arg;
+
+ close (*fd);
+}
+
+/* See cleanup-utils.h. */
+
+struct cleanup *
+make_cleanup_close (int fd)
+{
+ int *saved_fd = xmalloc (sizeof (fd));
+
+ *saved_fd = fd;
+ return make_cleanup_dtor (do_close_cleanup, saved_fd, xfree);
+}