Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/branches/num64/runtime/c-libs/posix-io/fcntl_l_64.c
ViewVC logotype

Annotation of /sml/branches/num64/runtime/c-libs/posix-io/fcntl_l_64.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5219 - (view) (download) (as text)

1 : mblume 1715 /* fcntl_l_64.c
2 :     *
3 :     * Using 64-bit position values represented as 32-bit pairs.
4 :     *
5 : jhr 5219 * COPYRIGHT (c) 2019 The Fellowship of SML/NJ (http://www.smlnj.org)
6 :     * All rights reserved.
7 : mblume 1715 */
8 : jhr 5219
9 : mblume 1715 #include "ml-unixdep.h"
10 :     #include <fcntl.h>
11 :     #include "ml-base.h"
12 :     #include "ml-values.h"
13 :     #include "ml-objects.h"
14 :     #include "ml-c.h"
15 :     #include "cfun-proto-list.h"
16 :    
17 :     /* _ml_P_IO_fcntl_l_64 : int * int * flock_rep -> flock_rep
18 :     *
19 : jhr 5219 * where
20 :     *
21 :     * flock_rep = int * int * Position.int * Position.int * int
22 :     *
23 : mblume 1715 * Handle record locking.
24 :     */
25 :     ml_val_t _ml_P_IO_fcntl_l_64 (ml_state_t *msp, ml_val_t arg)
26 :     {
27 :     int fd = REC_SELINT(arg, 0);
28 :     int cmd = REC_SELINT(arg, 1);
29 :     ml_val_t flock_rep = REC_SEL(arg, 2), obj;
30 : jhr 5219 ml_val_t start = REC_SEL(flock_rep, 2);
31 :     ml_val_t length = REC_SEL(flock_rep, 3);
32 : mblume 1715 struct flock flock;
33 :     int sts;
34 : jhr 5219
35 : mblume 1715 flock.l_type = REC_SELINT(flock_rep, 0);
36 :     flock.l_whence = REC_SELINT(flock_rep, 1);
37 : jhr 5219 flock.l_start = (off_t)INT64_MLtoC(start);
38 :     flock.l_len = (off_t)INT64_MLtoC(length);
39 : mblume 1715
40 :     sts = fcntl(fd, cmd, &flock);
41 :    
42 : jhr 5219 if (sts < 0) {
43 : mblume 1715 return RAISE_SYSERR(msp, sts);
44 :     }
45 :    
46 : jhr 5219 /* allocate the 64-bit start and length values */
47 :     INT64_ALLOC(msp, start, flock.l_start)
48 :     INT64_ALLOC(msp, length, flock.l_len)
49 : mblume 1715
50 : jhr 5219 ML_AllocWrite (msp, 0, MAKE_DESC (DTAG_record, 5));
51 : mblume 1715 ML_AllocWrite (msp, 1, INT_CtoML(flock.l_type));
52 :     ML_AllocWrite (msp, 2, INT_CtoML(flock.l_whence));
53 : jhr 5219 ML_AllocWrite (msp, 3, start);
54 :     ML_AllocWrite (msp, 4, length);
55 :     ML_AllocWrite (msp, 5, INT_CtoML(flock.l_pid));
56 :     obj = ML_Alloc (msp, 5);
57 : mblume 1715
58 :     return obj;
59 :    
60 :     } /* end of _ml_P_IO_fcntl_l_64 */

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0