Esempio n. 1
0
struct NaClDesc *NaClDescIoDescFromDescAllocCtor(int desc,
                                                 int flags) {
  struct NaClHostDesc *nhdp;

  nhdp = NaClHostDescPosixMake(desc, flags);
  if (NULL == nhdp) {
    /*
     * BUG: In Windows, we leak posix_d representation in the POSIX
     * layer, since caller will continue to own |handle| on a failure
     * return, but we cannot close |posix_d| without implicitly
     * invoking CloseHandle on |handle|.
     */
    return NULL;
  }
  return (struct NaClDesc *) NaClDescIoDescMake(nhdp);
}
Esempio n. 2
0
struct NaClDesc *NaClDescIoDescMakeFromHandle(NaClHandle handle) {
  int posix_d;
  struct NaClHostDesc *nhdp;
  struct NaClDescIoDesc *desc;

#if NACL_WINDOWS
  posix_d = _open_osfhandle((intptr_t) handle, _O_RDWR | _O_BINARY);
  if (-1 == posix_d)
    return NULL;
#else
  posix_d = handle;
#endif
  nhdp = NaClHostDescPosixMake(posix_d, NACL_ABI_O_RDWR);
  if (NULL == nhdp)
    return NULL;
  desc = NaClDescIoDescMake(nhdp);
  return &desc->base;
}