~ubuntu-branches/ubuntu/lucid/erlang/lucid-updates

« back to all changes in this revision

Viewing changes to erts/emulator/beam/erl_bif_port.c

  • Committer: Elliot Murphy
  • Date: 2009-12-22 02:56:21 UTC
  • mfrom: (3.3.5 sid)
  • Revision ID: elliot@elliotmurphy.com-20091222025621-qv3rja8gbpiabkbe
Tags: 1:13.b.3-dfsg-2ubuntu1
* Merge with Debian testing; remaining Ubuntu changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to. (LP #438365)
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
* Fixed dialyzer(1) manpage which was placed into section 3 and conflicted
  with dialyzer(3erl).
* New upstream release (it adds a new binary package erlang-erl-docgen).
* Refreshed patches, removed most of emacs.patch which is applied upstream.
* Linked run_test binary from erlang-common-test package to /usr/bin.
* Fixed VCS headers in debian/control.
* Moved from prebuilt manpages to generated from sources. This adds
  erlang-manpages binary package and xsltproc build dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
118
118
    return port;
119
119
}
120
120
 
121
 
BIF_RETTYPE port_command_2(BIF_ALIST_2)
 
121
#define ERTS_PORT_COMMAND_FLAG_FORCE            (((Uint32) 1) << 0)
 
122
#define ERTS_PORT_COMMAND_FLAG_NOSUSPEND        (((Uint32) 1) << 1)
 
123
 
 
124
static BIF_RETTYPE do_port_command(Process *BIF_P,
 
125
                                   Eterm BIF_ARG_1,
 
126
                                   Eterm BIF_ARG_2,
 
127
                                   Eterm BIF_ARG_3,
 
128
                                   Uint32 flags)
122
129
{
123
130
    BIF_RETTYPE res;
124
131
    Port *p;
154
161
 
155
162
    ERTS_BIF_PREP_RET(res, am_true);
156
163
 
157
 
    if (p->status & ERTS_PORT_SFLG_PORT_BUSY) {
158
 
        erts_suspend(BIF_P, ERTS_PROC_LOCK_MAIN, p);
159
 
        if (erts_system_monitor_flags.busy_port) {
160
 
            monitor_generic(BIF_P, am_busy_port, p->id);
161
 
        }
162
 
        ERTS_BIF_PREP_YIELD2(res, bif_export[BIF_port_command_2], BIF_P,
163
 
                             BIF_ARG_1, BIF_ARG_2);    
 
164
    if ((flags & ERTS_PORT_COMMAND_FLAG_FORCE)
 
165
        && !(p->drv_ptr->flags & ERL_DRV_FLAG_SOFT_BUSY)) {
 
166
        ERTS_BIF_PREP_ERROR(res, BIF_P, EXC_NOTSUP);
 
167
    }
 
168
    else if (!(flags & ERTS_PORT_COMMAND_FLAG_FORCE)
 
169
             && p->status & ERTS_PORT_SFLG_PORT_BUSY) {
 
170
        if (flags & ERTS_PORT_COMMAND_FLAG_NOSUSPEND) {
 
171
            ERTS_BIF_PREP_RET(res, am_false);
 
172
        }
 
173
        else {
 
174
            erts_suspend(BIF_P, ERTS_PROC_LOCK_MAIN, p);
 
175
            if (erts_system_monitor_flags.busy_port) {
 
176
                monitor_generic(BIF_P, am_busy_port, p->id);
 
177
            }
 
178
            ERTS_BIF_PREP_YIELD3(res, bif_export[BIF_port_command_3], BIF_P,
 
179
                                 BIF_ARG_1, BIF_ARG_2, BIF_ARG_3);    
 
180
        }
164
181
    } else {
165
182
        int wres;
166
183
        erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN);
195
212
    return res;
196
213
}
197
214
 
 
215
BIF_RETTYPE port_command_2(BIF_ALIST_2)
 
216
{
 
217
    return do_port_command(BIF_P, BIF_ARG_1, BIF_ARG_2, NIL, 0);
 
218
}
 
219
 
 
220
BIF_RETTYPE port_command_3(BIF_ALIST_3)
 
221
{
 
222
    Eterm l = BIF_ARG_3;
 
223
    Uint32 flags = 0;
 
224
    while (is_list(l)) {
 
225
        Eterm* cons = list_val(l);
 
226
        Eterm car = CAR(cons);
 
227
        if (car == am_force) {
 
228
            flags |= ERTS_PORT_COMMAND_FLAG_FORCE;
 
229
        } else if (car == am_nosuspend) {
 
230
            flags |= ERTS_PORT_COMMAND_FLAG_NOSUSPEND;
 
231
        } else {
 
232
            BIF_ERROR(BIF_P, BADARG);
 
233
        }
 
234
        l = CDR(cons);
 
235
    }
 
236
    if(!is_nil(l)) {
 
237
        BIF_ERROR(BIF_P, BADARG);
 
238
    }
 
239
    return do_port_command(BIF_P, BIF_ARG_1, BIF_ARG_2, BIF_ARG_3, flags);
 
240
}
 
241
 
198
242
BIF_RETTYPE port_call_2(BIF_ALIST_2)
199
243
{
200
244
    return port_call_3(BIF_P,BIF_ARG_1,make_small(0),BIF_ARG_2);
581
625
    opts.wd = NULL;
582
626
    opts.envir = NULL;
583
627
    opts.exit_status = 0;
 
628
    opts.overlapped_io = 0; 
584
629
    opts.spawn_type = ERTS_SPAWN_ANY; 
585
630
    opts.argv = NULL;
586
631
    binary_io = 0;
709
754
                opts.hide_window = 1;
710
755
            } else if (*nargs == am_exit_status) {
711
756
                opts.exit_status = 1;
 
757
            } else if (*nargs == am_overlapped_io) {
 
758
                opts.overlapped_io = 1;
712
759
            } else {
713
760
                goto badarg;
714
761
            }