1 /* dtable.h: fd table definition.
3 Copyright 2000, 2001 Red Hat, Inc.
5 This file is part of Cygwin.
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
11 /* Initial and increment values for cygwin's fd table */
12 #define NOFILE_INCR 32
20 fhandler_base **fds_on_hold;
21 int first_fd_for_open;
22 int cnt_need_fixup_before;
27 dtable () : first_fd_for_open(3), cnt_need_fixup_before(0), console_fds(0) {}
28 void init () {first_fd_for_open = 3;}
30 void dec_need_fixup_before ()
31 { if (cnt_need_fixup_before > 0) --cnt_need_fixup_before; }
32 void inc_need_fixup_before ()
33 { cnt_need_fixup_before++; }
34 BOOL need_fixup_before ()
35 { return cnt_need_fixup_before > 0; }
37 void dec_console_fds ();
38 void inc_console_fds ()
40 BOOL has_console_fds ()
41 { return console_fds > 0; }
43 int vfork_child_dup ();
44 void vfork_parent_restore ();
45 void vfork_child_fixup ();
46 fhandler_base *dup_worker (fhandler_base *oldfh);
47 int extend (int howmuch);
48 void fixup_before_exec (DWORD win_proc_id);
49 void fixup_before_fork (DWORD win_proc_id);
50 void fixup_after_fork (HANDLE);
51 fhandler_base *build_fhandler (int fd, DWORD dev, const char *name,
53 fhandler_base *build_fhandler (int fd, const char *name, HANDLE h = NULL,
55 unsigned opts = PC_SYM_FOLLOW, suffix_info *si = NULL);
56 inline int not_open (int fd)
58 SetResourceLock (LOCK_FD_LIST, READ_LOCK, "not_open");
60 int res = fd < 0 || fd >= (int) size || fds[fd] == NULL;
62 ReleaseResourceLock (LOCK_FD_LIST, READ_LOCK, "not open");
65 void reset_unix_path_name (int fd, const char *name);
66 int find_unused_handle (int start);
67 int find_unused_handle () { return find_unused_handle (first_fd_for_open);}
68 void release (int fd);
69 void init_std_file_from_handle (int fd, HANDLE handle, DWORD access, const char *name);
70 int dup2 (int oldfd, int newfd);
71 void fixup_after_exec (HANDLE);
72 inline fhandler_base *operator [](int fd) const { return fds[fd]; }
73 select_record *select_read (int fd, select_record *s);
74 select_record *select_write (int fd, select_record *s);
75 select_record *select_except (int fd, select_record *s);
76 operator fhandler_base **() {return fds;}
79 void dtable_init (void);
80 void stdio_init (void);
83 extern "C" int getfdtabsize ();
84 extern "C" void setfdtabsize (int);