1 /****************************************************************************
3 * GNAT COMPILER COMPONENTS *
7 * C Implementation File *
11 * Copyright (C) 2001 Ada Core Technologies, Inc. *
13 * GNAT is free software; you can redistribute it and/or modify it under *
14 * terms of the GNU General Public License as published by the Free Soft- *
15 * ware Foundation; either version 2, or (at your option) any later ver- *
16 * sion. GNAT is distributed in the hope that it will be useful, but WITH- *
17 * OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
19 * for more details. You should have received a copy of the GNU General *
20 * Public License distributed with GNAT; see file COPYING. If not, write *
21 * to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, *
22 * MA 02111-1307, USA. *
24 * As a special exception, if you link this file with other files to *
25 * produce an executable, this file does not by itself cause the resulting *
26 * executable to be covered by the GNU General Public License. This except- *
27 * ion does not however invalidate any other reasons why the executable *
28 * file might be covered by the GNU Public License. *
30 * GNAT was originally developed by the GNAT team at New York University. *
31 * It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). *
33 ****************************************************************************/
35 #ifdef __alpha_vxworks
48 /* This file provides the low level functionalities needed to implement Expect
49 capabilities in GNAT.Expect.
50 Implementations for unix and windows systems is provided.
51 Dummy stubs are also provided for other systems. */
54 /* Work around the fact that gcc/cpp does not define "unix" under AiX. */
63 /* ??? Provide a no-op for now */
77 __gnat_expect_portable_execvp (cmd
, argv
)
81 (void) spawnve (_P_NOWAIT
, cmd
, argv
, NULL
);
90 CreatePipe (&read
, &write
, NULL
, 0);
91 fd
[0]=_open_osfhandle (read
, 0);
92 fd
[1]=_open_osfhandle (write
, 0);
93 return 0; /* always success */
97 __gnat_expect_poll (fd
, num_fd
, timeout
, is_set
)
105 HANDLE handles
[num_fd
];
107 for (i
= 0; i
< num_fd
; i
++)
110 for (i
= 0; i
< num_fd
; i
++)
111 handles
[i
] = (HANDLE
) _get_osfhandle (fd
[i
]);
117 for (i
= 0; i
< num_fd
; i
++)
119 if (!PeekNamedPipe (handles
[i
], NULL
, 0, NULL
, &avail
, NULL
))
129 if (timeout
>= 0 && num
== 0)
139 #include <sys/time.h>
142 #define SELECT_MASK fd_set
143 #else /* !NO_FD_SET */
145 typedef long fd_mask
;
148 #define SELECT_MASK void
150 #define SELECT_MASK int
152 #endif /* !NO_FD_SET */
162 __gnat_expect_fork ()
168 __gnat_expect_portable_execvp (cmd
, argv
)
176 __gnat_expect_poll (fd
, num_fd
, timeout
, is_set
)
190 for (i
= 0; i
< num_fd
; i
++)
192 FD_SET (fd
[i
], &rset
);
197 tv
.tv_sec
= timeout
/ 1000;
198 tv
.tv_usec
= (timeout
% 1000) * 1000;
200 ready
= select (max_fd
+ 1, &rset
, NULL
, NULL
, timeout
== -1 ? NULL
: &tv
);
203 for (i
= 0; i
< num_fd
; i
++)
204 is_set
[i
] = (FD_ISSET (fd
[i
], &rset
) ? 1 : 0);
219 __gnat_expect_fork ()
225 __gnat_expect_portable_execvp (cmd
, argv
)
232 __gnat_expect_poll (fd
, num_fd
, timeout
, is_set
)