Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / native_client / src / trusted / desc / nacl_desc_base.h
1 /*
2  * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6
7 /*
8  * NaCl Service Runtime.  I/O Descriptor / Handle abstraction.
9  */
10
11 #ifndef NATIVE_CLIENT_SRC_TRUSTED_DESC_NACL_DESC_BASE_H_
12 #define NATIVE_CLIENT_SRC_TRUSTED_DESC_NACL_DESC_BASE_H_
13
14 #include <limits.h>
15 #include <sys/types.h>
16 #include <sys/stat.h>
17
18 #include "native_client/src/include/nacl_base.h"
19 #include "native_client/src/include/portability.h"
20
21 #include "native_client/src/public/desc_metadata_types.h"
22
23 /* For NaClHandle */
24 #include "native_client/src/shared/imc/nacl_imc_c.h"
25
26 /* for nacl_off64_t */
27 #include "native_client/src/shared/platform/nacl_host_desc.h"
28 #include "native_client/src/shared/platform/nacl_sync.h"
29
30 #include "native_client/src/trusted/nacl_base/nacl_refcount.h"
31
32 EXTERN_C_BEGIN
33
34 struct NaClDesc;
35 struct nacl_abi_stat;
36 struct nacl_abi_timespec;
37 struct NaClDescEffector;
38 struct NaClDescQuotaInterface;
39 struct NaClImcTypedMsgHdr;
40 struct NaClMessageHeader;
41
42 /*
43  * Externalization / internalization state, used by
44  * Externalize/Internalize functions.  Externalize convert the
45  * descriptor represented by the self (this) object to an entry in the
46  * handles table in a NaClMessageHeader, and the Internalize function
47  * is a factory that takes a dgram and NaClDescXferState and
48  * constructs a vector of NaClDesc objects.
49  *
50  * This is essentially a pair of input/output iterators.  The *_end
51  * values are not needed during externalization, since the SendMsg
52  * code will have queried ExternalizeSize to ensure that there is
53  * enough space.  During internalization, however, we try to be more
54  * paranoid and check that we do not overrun our buffers.
55  *
56  * NB: we must assume that the NaClHandle values passed are the right
57  * type; if not, it is possible to violate invariant properties
58  * required by the various subclasses of NaClDesc.
59  */
60 struct NaClDescXferState {
61   /*
62    * In/out value, used for both serialization and deserialization.
63    * The Externalize method read/write type tags that are part of the
64    * message header as well as data-based capabilities in a
65    * self-describing format.
66    */
67   char        *next_byte;
68   char        *byte_buffer_end;
69
70   /*
71    * In/out value.  Next handle to work on.
72    */
73   NaClHandle  *next_handle;
74   NaClHandle  *handle_buffer_end;
75 };
76
77 enum NaClDescTypeTag {
78   NACL_DESC_INVALID,
79   NACL_DESC_DIR,
80   NACL_DESC_HOST_IO,
81   NACL_DESC_CONN_CAP,
82   NACL_DESC_CONN_CAP_FD,
83   NACL_DESC_BOUND_SOCKET,
84   NACL_DESC_CONNECTED_SOCKET,
85   NACL_DESC_SHM,
86   NACL_DESC_SYSV_SHM,
87   NACL_DESC_MUTEX,
88   NACL_DESC_CONDVAR,
89   NACL_DESC_SEMAPHORE,
90   NACL_DESC_SYNC_SOCKET,
91   NACL_DESC_TRANSFERABLE_DATA_SOCKET,
92   NACL_DESC_IMC_SOCKET,
93   NACL_DESC_QUOTA,
94   NACL_DESC_DEVICE_RNG,
95   NACL_DESC_DEVICE_POSTMESSAGE,
96   NACL_DESC_CUSTOM,
97   NACL_DESC_NULL
98   /*
99    * Add new NaClDesc subclasses here.
100    *
101    * NB: when we add new tag types, NaClDescInternalize[] **MUST**
102    * also be updated to add new internalization functions.
103    */
104 };
105 #define NACL_DESC_TYPE_MAX      (NACL_DESC_NULL + 1)
106 #define NACL_DESC_TYPE_END_TAG  (0xff)
107
108 struct NaClInternalRealHeader {
109   uint32_t  xfer_protocol_version;
110   uint32_t  descriptor_data_bytes;
111 };
112
113 struct NaClInternalHeader {
114   struct NaClInternalRealHeader h;
115   /*
116    * We add 0x10 here because pad must have at least one element.
117    * This unfortunately also means that if NaClInternalRealHeader is
118    * already a multiple of 16 in size, we will add in an unnecessary
119    * 16-byte pad.  The preprocessor does not have access to sizeof
120    * information, so we cannot just get rid of the pad.
121    */
122   char      pad[((sizeof(struct NaClInternalRealHeader) + 0x10) & ~0xf)
123                 - sizeof(struct NaClInternalRealHeader)];
124   /* total size is a multiple of 16 bytes */
125 };
126
127 #define NACL_HANDLE_TRANSFER_PROTOCOL 0xd3c0de01
128 /* incr from here */
129
130 /*
131  * Array of function pointers, indexed by NaClDescTypeTag, any one of
132  * which will extract an externalized representation of the NaClDesc
133  * subclass object from the message, as referenced via
134  * NaClDescXferState, and when successful return the internalized
135  * representation -- a newl created NaClDesc subclass object -- to the
136  * caller via an out parameter.  Returns 0 on success, negative errno
137  * value on failure.
138  *
139  * NB: we should have atomic failures.  The caller is expected to
140  * allocate an array of NaClDesc pointers, and insert into the open
141  * file table of the receiving NaClApp (via the NaClDescEffector
142  * interface) only when all internalizations succeed.  Since even the
143  * insertion can fail, the caller must keep track of the descriptor
144  * numbers in case it has to back out and report that the message is
145  * dropped.
146  *
147  * Also, when the NaClDesc object is constructed, the NaClHandle
148  * consumed (from the NaClDescXferState) MUST BE replaced with
149  * NACL_INVALID_HANDLE.
150  */
151 extern int
152 (*NaClDescInternalize[NACL_DESC_TYPE_MAX])(struct NaClDesc **,
153                                            struct NaClDescXferState *,
154                                            struct NaClDescQuotaInterface *);
155
156 extern char const *NaClDescTypeString(enum NaClDescTypeTag type_tag);
157
158 /*
159  * The virtual function table for NaClDesc and its subclasses.
160  *
161  * This interface will change when non-blocking I/O and epoll is
162  * added.
163  */
164
165 struct NaClDescVtbl {
166   struct NaClRefCountVtbl vbase;
167
168   /*
169    * Essentially mmap.  Note that untrusted code should always use
170    * NACL_ABI_MAP_FIXED, sice NaClDesc object have no idea where the
171    * untrusted NaCl module's address space is located.  When non-fixed
172    * mapping is used (by trusted code), the Map virtual function uses
173    * an address space hole algorithm that may be subject to race
174    * between two threads, and may thus fail.  In all cases, if
175    * successful, the memory mapping may be unmapped at
176    * NACL_MAP_PAGESIZE granularities.  (Trusted code should use
177    * UnmapUnsafe, since refilling the unmapped address space with
178    * inaccessible memory is probably not desirable.)
179    */
180   uintptr_t (*Map)(struct NaClDesc          *vself,
181                    struct NaClDescEffector  *effp,
182                    void                     *start_addr,
183                    size_t                   len,
184                    int                      prot,
185                    int                      flags,
186                    nacl_off64_t             offset) NACL_WUR;
187
188 #if NACL_WINDOWS
189   /*
190    * UnmapUnsafe really unmaps and leaves a hole in the address space.
191    * It is intended for use by Map (through the effector interface) to
192    * clear out memory according to the memory object that is backing
193    * the memory, prior to putting new memory in place.
194    */
195   int (*UnmapUnsafe)(struct NaClDesc          *vself,
196                      void                     *start_addr,
197                      size_t                   len) NACL_WUR;
198 #endif
199
200   ssize_t (*Read)(struct NaClDesc *vself,
201                   void            *buf,
202                   size_t          len) NACL_WUR;
203
204   ssize_t (*Write)(struct NaClDesc  *vself,
205                    void const       *buf,
206                    size_t           len) NACL_WUR;
207
208   nacl_off64_t (*Seek)(struct NaClDesc  *vself,
209                        nacl_off64_t     offset,
210                        int              whence) NACL_WUR;
211
212   ssize_t (*PRead)(struct NaClDesc *vself,
213                    void *buf,
214                    size_t len,
215                    nacl_off64_t offset) NACL_WUR;
216
217   ssize_t (*PWrite)(struct NaClDesc *vself,
218                     void const *buf,
219                     size_t len,
220                     nacl_off64_t offset) NACL_WUR;
221
222   /*
223    * TODO(bsy): Need to figure out which requests we support, if any.
224    * Also, request determines arg size and whether it is an input or
225    * output arg!
226    */
227   int (*Ioctl)(struct NaClDesc  *vself,
228                int              request,
229                void             *arg) NACL_WUR;
230
231   int (*Fstat)(struct NaClDesc      *vself,
232                struct nacl_abi_stat *statbuf);
233
234   /*
235    * Directory access support.  Directories require support for getdents.
236    */
237   ssize_t (*Getdents)(struct NaClDesc *vself,
238                       void            *dirp,
239                       size_t          count) NACL_WUR;
240
241   /*
242    * Externalization queries this for how many data bytes and how many
243    * handles are needed to transfer the "this" or "self" descriptor
244    * via IMC.  If the descriptor is not transferrable, this should
245    * return -NACL_ABI_EINVAL.  Success is indicated by 0, and other
246    * kinds of failure should be the usual negative errno.  Should
247    * never have to put the calling thread to sleep or otherwise
248    * manipulate thread or process state.
249    *
250    * The nbytes returned do not include any kind of type tag.  The
251    * type tag overhead is computed by the MsgSend code, since tagging
252    * format need not be known by the per-descriptor externalization
253    * code.
254    */
255   int (*ExternalizeSize)(struct NaClDesc  *vself,
256                          size_t           *nbytes,
257                          size_t           *nhandles) NACL_WUR;
258
259   /*
260    * Externalize the "this" or "self" descriptor: this will take an
261    * IMC datagram object to which the Nrd will be appended, either as
262    * special control data or as a descriptor/handle to be passed to
263    * the recipient.  Should never have to put the calling thread to
264    * sleep or otherwise manipulate thread or process state.
265    */
266   int (*Externalize)(struct NaClDesc          *vself,
267                      struct NaClDescXferState *xfer) NACL_WUR;
268
269   /*
270    * Lock and similar syscalls cannot just indefintely block,
271    * since address space move will require that all other threads are
272    * stopped and in a known
273    */
274   int (*Lock)(struct NaClDesc *vself) NACL_WUR;
275
276   int (*TryLock)(struct NaClDesc  *vself) NACL_WUR;
277
278   int (*Unlock)(struct NaClDesc *vself) NACL_WUR;
279
280   int (*Wait)(struct NaClDesc *vself,
281               struct NaClDesc *mutex) NACL_WUR;
282
283   int (*TimedWaitAbs)(struct NaClDesc                *vself,
284                       struct NaClDesc                *mutex,
285                       struct nacl_abi_timespec const *ts) NACL_WUR;
286
287   int (*Signal)(struct NaClDesc *vself) NACL_WUR;
288
289   int (*Broadcast)(struct NaClDesc  *vself) NACL_WUR;
290
291   ssize_t (*SendMsg)(struct NaClDesc                 *vself,
292                      const struct NaClImcTypedMsgHdr *nitmhp,
293                      int                             flags) NACL_WUR;
294
295   ssize_t (*RecvMsg)(struct NaClDesc               *vself,
296                      struct NaClImcTypedMsgHdr     *nitmhp,
297                      int                           flags,
298                      struct NaClDescQuotaInterface *quota_interface) NACL_WUR;
299
300   ssize_t (*LowLevelSendMsg)(struct NaClDesc                *vself,
301                              struct NaClMessageHeader const *dgram,
302                              int                            flags) NACL_WUR;
303
304   ssize_t (*LowLevelRecvMsg)(struct NaClDesc          *vself,
305                              struct NaClMessageHeader *dgram,
306                              int                      flags) NACL_WUR;
307
308   /*
309    * ConnectAddr() and AcceptConn():
310    * On success, returns 0 and a descriptor via *result.
311    * On error, returns a negative errno value.
312    */
313   int (*ConnectAddr)(struct NaClDesc  *vself,
314                      struct NaClDesc  **result) NACL_WUR;
315
316   int (*AcceptConn)(struct NaClDesc *vself,
317                     struct NaClDesc **result) NACL_WUR;
318
319   int (*Post)(struct NaClDesc *vself) NACL_WUR;
320
321   int (*SemWait)(struct NaClDesc  *vself) NACL_WUR;
322
323   int (*GetValue)(struct NaClDesc *vself) NACL_WUR;
324
325   /*
326    * Descriptor attributes setters and getters.  These are virtual
327    * functions because the NaClDescQuota subclass wraps other NaClDesc
328    * subclasses, and the quota descriptors should not have attributes
329    * separate from that of the wrapped descriptor -- the
330    * setters/getters of the NaClDescQuota just use the corresponding
331    * methods of the wrapped descriptor.
332    */
333
334   /*
335    * Save a copy of the |metadata_size| bytes located at |metadata|
336    * with the descriptor |self|.  The |metadata_type| argument should
337    * be a non-negative integer and should be unique for each use of
338    * the metadata interface.  Only one set of metadata may be saved
339    * with a descriptor, and it is an error to try to set metadata on a
340    * descriptor which already has metadata.
341    *
342    * Syscall-style function: returns 0 for success and negated errno
343    * (-NACL_ABI_ENOMEM if memory allocation for making a copy of the
344    * metadata fails, -NACL_ABI_EPERM if metadata already set,
345    * -NACL_ABI_EINVAL of metadata_type is negative).
346    */
347   int (*SetMetadata)(struct NaClDesc *self,
348                      int32_t metadata_type,
349                      uint32_t metadata_num_bytes,
350                      uint8_t const *metadata_bytes) NACL_WUR;
351
352   /*
353    * GetMetadata writes at most |*metadata_buffer_num_bytes_in_out|
354    * bytes of the metadata associated with the descriptor using
355    * SetMetaData to the buffer located at |metadata_buffer|.  It
356    * returns the metadata_type associated with the descriptor.  On
357    * return, the value at |*metadata_buffer_num_bytes_in_out| contains
358    * the total number of bytes that would be written if there were no
359    * size limit, i.e., the actual number of bytes written if the
360    * buffer was large enough, or the number of bytes that would have
361    * been written if the buffer were not.  Thus, on return, if the
362    * value is less than or equal to the original value at
363    * |*metadata_buffer_num_bytes_in_out|, the contents of
364    * |metadata_buffer| contains all of the metadata.
365    *
366    * To query the size of the metadata without doing any copying, call
367    * GetMetadata with |*metadata_buffer_num_bytes_in_out| equal to
368    * zero, in which case |metadata_buffer| can be NULL.
369    *
370    * Callers should always check the return value of GetMetadata to
371    * ensure that the metadata_type is the expected value.  If the type
372    * is wrong, do not process the metadata -- treat the descriptor as
373    * if it has no metadata.  To do otherwise would expose us to type
374    * confusion attacks.
375    *
376    * Returns NACL_DESC_METADATA_NONE_TYPE if no metadata is associated
377    * with the descriptor.
378    */
379   int32_t (*GetMetadata)(struct NaClDesc *self,
380                          uint32_t *metadata_buffer_num_bytes_in_out,
381                          uint8_t *metadata_buffer) NACL_WUR;
382
383
384   void (*SetFlags)(struct NaClDesc *self,
385                    uint32_t flags);
386
387   uint32_t (*GetFlags)(struct NaClDesc *self);
388
389   /*
390    * Inappropriate methods for the subclass will just return
391    * -NACL_ABI_EINVAL.
392    */
393
394   /*
395    * typeTag is one of the enumeration values from NaClDescTypeTag.
396    *
397    * This is not a class variable, since one must access it through an
398    * instance.  Having a value in the vtable is not allowed in C++;
399    * instead, we would implement this as a const virtual function that
400    * returns the type tag, or RTTI which would typically be done via
401    * examining the vtable pointer.  This is potentially cheaper, since
402    * one could choose bit patterns for the type tags that make
403    * subclass relationships easier to compute (we don't do this, since
404    * we only ever need exact type checks).
405    *
406    * We put this at the end of the vtable so that when we add new
407    * virtual functions above it, we are guaranteed to get a type
408    * mismatch if any subclass implemention did not have its vtable
409    * properly extended -- even when -Wmissing-field-initializers was
410    * omitted.
411    */
412   enum NaClDescTypeTag typeTag;
413 };
414
415 struct NaClDesc {
416   struct NaClRefCount base NACL_IS_REFCOUNT_SUBCLASS;
417   uint32_t flags;
418
419   /* "public" flags -- settable by users of NaClDesc interface */
420
421   /*
422    * It is okay to try to use this descriptor with PROT_EXEC in mmap.
423    * This is just a hint to the service runtime to try direct mmap --
424    * the validator cache can still disallow the operation.
425    */
426 #define NACL_DESC_FLAGS_MMAP_EXEC_OK 0x1000
427
428   /* private flags -- used internally by NaClDesc */
429 #define NACL_DESC_FLAGS_PUBLIC_MASK 0xffff
430
431 #define NACL_DESC_FLAGS_HAS_METADATA 0x10000
432   /*
433    * We could have used two uint16_t variables too, but that just
434    * makes the serialization (externalization) and deserialization
435    * (internalization) more complex; here, only the SetFlags and
436    * GetFlags need to be messy.
437    *
438    * We do not encode the presence of metadata using metadata type, so
439    * we do not have to transfer the 4 type bytes when metadata is
440    * absent.  Since the interface only allows setting the metadata
441    * once, we don't worry about
442    */
443   int32_t metadata_type;
444   uint32_t metadata_num_bytes;
445   uint8_t *metadata;
446 };
447
448 /*
449  * Placement new style ctor; creates w/ ref_count of 1.
450  *
451  * The subclasses' ctor must call this base class ctor during their
452  * contruction.
453  */
454 int NaClDescCtor(struct NaClDesc *ndp) NACL_WUR;
455
456 extern struct NaClDescVtbl const kNaClDescVtbl;
457
458 struct NaClDesc *NaClDescRef(struct NaClDesc *ndp);
459
460 /* when ref_count reaches zero, will call dtor and free */
461 void NaClDescUnref(struct NaClDesc *ndp);
462
463 /*
464  * NaClDescSafeUnref is just like NaCDescUnref, except that ndp may be
465  * NULL (in which case this is a noop).
466  *
467  * Used in failure cleanup of initialization code, esp in Ctors that
468  * can fail.
469  */
470 void NaClDescSafeUnref(struct NaClDesc *ndp);
471
472 /*
473  * USE THE VIRTUAL FUNCTION.  THIS DECLARATION IS FOR SUBCLASSES.
474  */
475 int NaClDescSetMetadata(struct NaClDesc *self,
476                         int32_t metadata_type,
477                         uint32_t metadata_num_bytes,
478                         uint8_t const *metadata_bytes) NACL_WUR;
479
480 /*
481  * USE THE VIRTUAL FUNCTION.  THIS DECLARATION IS FOR SUBCLASSES.
482  */
483 int32_t NaClDescGetMetadata(struct NaClDesc *self,
484                             uint32_t *metadata_buffer_num_bytes_in_out,
485                             uint8_t *metadata_buffer) NACL_WUR;
486
487 /*
488  * USE THE VIRTUAL FUNCTION.  THIS DECLARATION IS FOR SUBCLASSES.
489  */
490 void NaClDescSetFlags(struct NaClDesc *self,
491                       uint32_t flags);
492
493 /*
494  * USE THE VIRTUAL FUNCTION.  THIS DECLARATION IS FOR SUBCLASSES.
495  */
496 uint32_t NaClDescGetFlags(struct NaClDesc *self);
497
498
499 /*
500  * Base class externalize functions; all subclass externalize
501  * functions should invoke these, up the class hierarchy, and add to
502  * the sizes or the NaClDescXferState.
503  */
504 int NaClDescExternalizeSize(struct NaClDesc *self,
505                             size_t *nbytes,
506                             size_t *nhandles);
507
508 int NaClDescExternalize(struct NaClDesc *self,
509                         struct NaClDescXferState *xfer);
510
511 /*
512  * The top level internalize interface are factories: they allocate
513  * space, then run the internalize-in-place ctor code.  Ideally, these
514  * would be two separate functions -- the memory allocation could, in
515  * most cases, be simplified to be simply an attribute containing the
516  * desired memory size and a generic allocator used, though of course
517  * we would like to permit subclasses that contains variable size
518  * arrays (at end of struct), etc.  For base (super) classes, the
519  * memory allocation is not necessary, since the subclass internalize
520  * function will have handled it.
521  */
522 int NaClDescInternalizeCtor(struct NaClDesc *vself,
523                             struct NaClDescXferState *xfer);
524
525
526 /*
527  * subclasses are in their own header files.
528  */
529
530
531 /* utility routines */
532
533 /* Unmap memory, leaving an unallocated hole in address space. */
534 void NaClDescUnmapUnsafe(struct NaClDesc *desc, void *addr, size_t length);
535
536 int32_t NaClAbiStatHostDescStatXlateCtor(struct nacl_abi_stat    *dst,
537                                          nacl_host_stat_t const  *src);
538
539 /*
540  * The following two functions are not part of the exported public
541  * API.
542  *
543  * Read/write to a NaClHandle, much like how read/write syscalls work.
544  */
545 ssize_t NaClDescReadFromHandle(NaClHandle handle,
546                                void       *buf,
547                                size_t     length);
548
549 ssize_t NaClDescWriteToHandle(NaClHandle handle,
550                               void const *buf,
551                               size_t     length);
552
553 /*
554  * Default functions for the vtable for when the functionality is
555  * inappropriate for the descriptor type -- they just return
556  * -NACL_ABI_EINVAL
557  */
558 void NaClDescDtorNotImplemented(struct NaClRefCount  *vself);
559
560 uintptr_t NaClDescMapNotImplemented(struct NaClDesc         *vself,
561                                     struct NaClDescEffector *effp,
562                                     void                    *start_addr,
563                                     size_t                  len,
564                                     int                     prot,
565                                     int                     flags,
566                                     nacl_off64_t            offset);
567
568 #if NACL_WINDOWS
569 int NaClDescUnmapUnsafeNotImplemented(struct NaClDesc  *vself,
570                                       void             *start_addr,
571                                       size_t           len);
572 /* This is an initializer for use when defining NaClDescVtbl structs. */
573 # define NACL_DESC_UNMAP_NOT_IMPLEMENTED \
574     NaClDescUnmapUnsafeNotImplemented,
575 #else
576 # define NACL_DESC_UNMAP_NOT_IMPLEMENTED /* empty */
577 #endif
578
579 ssize_t NaClDescReadNotImplemented(struct NaClDesc  *vself,
580                                    void             *buf,
581                                    size_t           len);
582
583 ssize_t NaClDescWriteNotImplemented(struct NaClDesc         *vself,
584                                     void const              *buf,
585                                     size_t                  len);
586
587 nacl_off64_t NaClDescSeekNotImplemented(struct NaClDesc *vself,
588                                         nacl_off64_t    offset,
589                                         int             whence);
590
591 ssize_t NaClDescPReadNotImplemented(struct NaClDesc *vself,
592                                     void *buf,
593                                     size_t len,
594                                     nacl_off64_t offset);
595
596 ssize_t NaClDescPWriteNotImplemented(struct NaClDesc *vself,
597                                      void const *buf,
598                                      size_t len,
599                                      nacl_off64_t offset);
600
601 int NaClDescIoctlNotImplemented(struct NaClDesc *vself,
602                                 int             request,
603                                 void            *arg);
604
605 int NaClDescFstatNotImplemented(struct NaClDesc       *vself,
606                                 struct nacl_abi_stat  *statbuf);
607
608 ssize_t NaClDescGetdentsNotImplemented(struct NaClDesc  *vself,
609                                        void             *dirp,
610                                        size_t           count);
611
612 int NaClDescExternalizeSizeNotImplemented(struct NaClDesc *vself,
613                                           size_t          *nbytes,
614                                           size_t          *nhandles);
615
616 int NaClDescExternalizeNotImplemented(struct NaClDesc          *vself,
617                                       struct NaClDescXferState *xfer);
618
619 int NaClDescLockNotImplemented(struct NaClDesc  *vself);
620
621 int NaClDescTryLockNotImplemented(struct NaClDesc *vself);
622
623 int NaClDescUnlockNotImplemented(struct NaClDesc  *vself);
624
625 int NaClDescWaitNotImplemented(struct NaClDesc  *vself,
626                                struct NaClDesc  *mutex);
627
628 int NaClDescTimedWaitAbsNotImplemented(struct NaClDesc                *vself,
629                                        struct NaClDesc                *mutex,
630                                        struct nacl_abi_timespec const *ts);
631
632 int NaClDescSignalNotImplemented(struct NaClDesc  *vself);
633
634 int NaClDescBroadcastNotImplemented(struct NaClDesc *vself);
635
636 ssize_t NaClDescSendMsgNotImplemented(
637     struct NaClDesc                 *vself,
638     const struct NaClImcTypedMsgHdr *nitmhp,
639     int                             flags);
640
641 ssize_t NaClDescRecvMsgNotImplemented(
642     struct NaClDesc               *vself,
643     struct NaClImcTypedMsgHdr     *nitmhp,
644     int                           flags,
645     struct NaClDescQuotaInterface *quota_interface);
646
647 ssize_t NaClDescLowLevelSendMsgNotImplemented(
648     struct NaClDesc                *vself,
649     struct NaClMessageHeader const *dgram,
650     int                            flags);
651
652 ssize_t NaClDescLowLevelRecvMsgNotImplemented(
653     struct NaClDesc           *vself,
654     struct NaClMessageHeader  *dgram,
655     int                       flags);
656
657 int NaClDescConnectAddrNotImplemented(struct NaClDesc *vself,
658                                       struct NaClDesc **out_desc);
659
660 int NaClDescAcceptConnNotImplemented(struct NaClDesc  *vself,
661                                      struct NaClDesc  **out_desc);
662
663 int NaClDescPostNotImplemented(struct NaClDesc  *vself);
664
665 int NaClDescSemWaitNotImplemented(struct NaClDesc *vself);
666
667 int NaClDescGetValueNotImplemented(struct NaClDesc  *vself);
668
669 int NaClDescInternalizeNotImplemented(
670     struct NaClDesc                **out_desc,
671     struct NaClDescXferState       *xfer,
672     struct NaClDescQuotaInterface  *quota_interface);
673
674
675 int NaClSafeCloseNaClHandle(NaClHandle h);
676
677 int NaClDescIsSafeForMmap(struct NaClDesc *self);
678
679 void NaClDescMarkSafeForMmap(struct NaClDesc *self);
680
681 void NaClDescMarkUnsafeForMmap(struct NaClDesc *self);
682
683 struct NaClValidationCache;
684
685 int NaClDescValidationCacheResolve(
686     struct NaClDesc **desc_in_out,
687     struct NaClValidationCache *validation_cache);
688
689
690 EXTERN_C_END
691
692 #endif  // NATIVE_CLIENT_SRC_TRUSTED_DESC_NACL_DESC_BASE_H_