int _wopen(const WCHAR* filename, int flags, int mode) { bool result = false; int fd = -1; _FD_STRUCT* fds; fd = fd_allocate(); if (fd == -1) goto cleanup; fds = fds_from_index(fd); if (fds == NULL) goto cleanup; if (!_wopen_fds(filename, flags, mode, fds)) goto cleanup; result = true; cleanup: if (result == false && fd != -1) { fd_release(fd); fd = -1; } return fd; }
int rte_netmap_close(__rte_unused int fd) { int32_t rc; rte_spinlock_lock(&netmap_lock); rc = fd_release(fd); rte_spinlock_unlock(&netmap_lock); if (rc < 0) { errno =-rc; rc = -1; } return (rc); }
int close(int fd) { bool result = false; _FD_STRUCT* fds; fds = fds_from_index(fd); if (fds == NULL) goto cleanup; if (!CloseHandle(fds->hFile)) goto cleanup; fd_release(fd); result = true; cleanup: if (result == false) errno = -1; return result ? 0 : -1; }