This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH Implement __gnat_set_close_on_exec on Windows


Arnaud Charlet wrote:

> I'd rather handle the two issues separately: the bootstrap failure should
> be fixed by using a cast in adaint.c as you did (this part is OK),
> and by using ATTRIBUTE_UNUSED for the fd and close_on_exec_p parameters,
> since not all platforms use these parameters, so even if you implement
> it for Windows, you are hiding the failure on other platforms.
> 
> And as a second patch, submit a patch to implement __gnat_set_close_on_exec
> under Windows.

OK, how about these two patches?
2005-03-25  Aaron W. LaFramboise  <aaronavay62@aaronwl.com>

	* adaint.c (_gnat_set_close_on_exec) [_WIN32]: Implement.

Index: adaint.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ada/adaint.c,v
retrieving revision 1.44
diff -c -3 -p -r1.44 adaint.c
*** adaint.c	24 Mar 2005 22:11:36 -0000	1.44
--- adaint.c	26 Mar 2005 02:36:04 -0000
*************** __gnat_set_close_on_exec (int fd, int cl
*** 2612,2622 ****
    else
      flags &= ~FD_CLOEXEC;
    return fcntl (fd, F_SETFD, flags | FD_CLOEXEC);
  #else
    return -1;
-   /* For the Windows case, we should use SetHandleInformation to remove
-      the HANDLE_INHERIT property from fd. This is not implemented yet,
-      but for our purposes (support of GNAT.Expect) this does not matter,
-      as by default handles are *not* inherited. */
  #endif
  }
--- 2613,2628 ----
    else
      flags &= ~FD_CLOEXEC;
    return fcntl (fd, F_SETFD, flags | FD_CLOEXEC);
+ #elif defined(_WIN32)
+   HANDLE h = (HANDLE) _get_osfhandle (fd);
+   if (h == (HANDLE) -1)
+     return -1;
+   if (close_on_exec_p)
+     return ! SetHandleInformation (h, HANDLE_FLAG_INHERIT, 0);
+   return ! SetHandleInformation (h, HANDLE_FLAG_INHERIT, 
+     HANDLE_FLAG_INHERIT);
  #else
+   /* TODO: Unimplemented. */
    return -1;
  #endif
  }
2005-03-25  Aaron W. LaFramboise  <aaronavay62@aaronwl.com>

	* adaint.c (_gnat_set_close_on_exec): Mark parameters unused.

Index: adaint.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ada/adaint.c,v
retrieving revision 1.44
diff -c -3 -p -r1.44 adaint.c
*** adaint.c    24 Mar 2005 22:11:36 -0000      1.44
--- adaint.c    26 Mar 2005 02:34:18 -0000
*************** get_gcc_version (void)
*** 2601,2607 ****
  }
  
  int
! __gnat_set_close_on_exec (int fd, int close_on_exec_p)
  {
  #if defined (F_GETFD) && defined (FD_CLOEXEC) && ! defined (__vxworks)
    int flags = fcntl (fd, F_GETFD, 0);
--- 2601,2608 ----
  }
  
  int
! __gnat_set_close_on_exec (int fd ATTRIBUTE_UNUSED,
!                         int close_on_exec_p ATTRIBUTE_UNUSED)
  {
  #if defined (F_GETFD) && defined (FD_CLOEXEC) && ! defined (__vxworks)
    int flags = fcntl (fd, F_GETFD, 0);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]