29extern int __fdman_sema;
32#ifdef F___descriptor_data_pool
38#ifdef F___descriptormap
54 __fdman_sema = CreateSema(&sema);
55 if (__fdman_sema < 0) {
65 __descriptormap[STDIN_FILENO] = &__descriptor_data_pool[STDIN_FILENO];
66 __libcglue_init_stdio(&(__descriptormap[STDIN_FILENO]->
info), 0);
68 __descriptormap[STDOUT_FILENO] = &__descriptor_data_pool[STDOUT_FILENO];
69 __libcglue_init_stdio(&(__descriptormap[STDOUT_FILENO]->
info), 1);
71 __descriptormap[STDERR_FILENO] = &__descriptor_data_pool[STDERR_FILENO];
72 __libcglue_init_stdio(&(__descriptormap[STDERR_FILENO]->
info), 1 );
76#ifdef F___fdman_deinit
79 if (__fdman_sema > 0) {
80 DeleteSema(__fdman_sema);
86#ifdef F___fdman_get_new_descriptor
87int __fdman_get_new_descriptor()
91 WaitSema(__fdman_sema);
92 for (i = 0; i < __FILENO_MAX; i++) {
93 if (__descriptormap[i] == NULL) {
94 __descriptormap[i] = &__descriptor_data_pool[i];
95 __descriptormap[i]->ref_count++;
96 SignalSema(__fdman_sema);
100 SignalSema(__fdman_sema);
108#ifdef F___fdman_get_dup_descriptor
109int __fdman_get_dup_descriptor(
int fd)
113 if (!__IS_FD_VALID(fd)) {
118 WaitSema(__fdman_sema);
119 for (i = 0; i < __FILENO_MAX; i++) {
120 if (__descriptormap[i] == NULL) {
121 __descriptormap[i] = &__descriptor_data_pool[fd];
122 __descriptormap[i]->ref_count++;
123 SignalSema(__fdman_sema);
127 SignalSema(__fdman_sema);
134#ifdef F___fdman_get_dup_descriptor
135int __fdman_get_dup2_descriptor(
int fd,
int newfd)
137 if (!__IS_FD_VALID(fd)) {
142 WaitSema(__fdman_sema);
143 __descriptormap[newfd] = &__descriptor_data_pool[fd];
144 __descriptormap[newfd]->ref_count++;
145 SignalSema(__fdman_sema);
151#ifdef F___fdman_release_descriptor
152void __fdman_release_descriptor(
int fd)
154 if (!__IS_FD_VALID(fd)) {
159 __descriptormap[fd]->ref_count--;
161 if (__descriptormap[fd]->ref_count == 0) {
164 __descriptormap[fd] = NULL;