1 /* dtable.h: fd table definition.
3 This file is part of Cygwin.
5 This software is a copyrighted work licensed under the terms of the
6 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
11 /* Initial and increment values for cygwin's fd table */
12 #define NOFILE_INCR 32
19 #define BFH_OPTS (PC_NULLEMPTY | PC_FULL | PC_POSIX)
23 fhandler_base
**archetypes
;
26 static const int initial_archetype_size
= 8;
27 size_t first_fd_for_open
;
28 int cnt_need_fixup_before
;
32 dtable () : archetypes (NULL
), narchetypes (0), farchetype (0), first_fd_for_open(3), cnt_need_fixup_before(0) {}
33 void init () {first_fd_for_open
= 3;}
35 void dec_need_fixup_before ()
36 { if (cnt_need_fixup_before
> 0) --cnt_need_fixup_before
; }
37 void inc_need_fixup_before ()
38 { cnt_need_fixup_before
++; }
39 bool need_fixup_before ()
40 { return cnt_need_fixup_before
> 0; }
42 void move_fd (int, int);
43 int vfork_child_dup ();
44 void vfork_parent_restore ();
45 void vfork_child_fixup ();
46 fhandler_base
*dup_worker (fhandler_base
*oldfh
, int flags
);
47 int extend (size_t, size_t);
48 void fixup_after_fork (HANDLE
);
49 void fixup_close (size_t, fhandler_base
*);
51 inline int not_open (int fd
)
54 int res
= fd
< 0 || fd
>= (int) size
|| fds
[fd
] == NULL
;
58 int find_unused_handle (size_t start
);
59 int find_unused_handle () { return find_unused_handle (first_fd_for_open
);}
60 void release (int fd
);
61 void init_std_file_from_handle (int fd
, HANDLE handle
);
62 int dup3 (int oldfd
, int newfd
, int flags
);
63 void fixup_after_exec ();
64 inline fhandler_base
*&operator [](int fd
) const { return fds
[fd
]; }
65 bool select_read (int fd
, select_stuff
*);
66 bool select_write (int fd
, select_stuff
*);
67 bool select_except (int fd
, select_stuff
*);
68 operator fhandler_base
**() {return fds
;}
70 void get_debugger_info ();
71 void set_file_pointers_for_exec ();
72 fhandler_base
*find_archetype (device
& dev
);
73 fhandler_base
**add_archetype ();
74 void delete_archetype (fhandler_base
*);
75 void fixup_before_exec (DWORD win_proc_id
);
76 void fixup_before_fork (DWORD win_proc_id
);
77 void lock () {lock_process::locker
.acquire ();}
78 void unlock () {lock_process::locker
.release ();}
81 fhandler_base
*build_fh_dev (const device
&, const char * = NULL
);
82 fhandler_base
*build_fh_name (const char *, unsigned = 0, suffix_info
* = NULL
);
83 fhandler_base
*build_fh_pc (path_conv
& pc
);
89 extern "C" int getfdtabsize ();
90 extern "C" void setfdtabsize (int);