__alloc_handle changes for dkA r46

space for device specific storage in FILE struct is now allocated in __alloc_handle
This commit is contained in:
Dave Murphy 2016-12-28 18:27:51 +00:00
parent 50cafaa700
commit 400e85d674
2 changed files with 7 additions and 15 deletions

View File

@ -8,7 +8,6 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
int ret = 0; int ret = 0;
int tmp_addrlen = 0x1c; int tmp_addrlen = 0x1c;
int fd, dev; int fd, dev;
__handle *handle;
u32 *cmdbuf = getThreadCommandBuffer(); u32 *cmdbuf = getThreadCommandBuffer();
u8 tmpaddr[0x1c]; u8 tmpaddr[0x1c];
u32 saved_threadstorage[2]; u32 saved_threadstorage[2];
@ -25,15 +24,8 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
return -1; return -1;
} }
fd = __alloc_handle(sizeof(__handle) + sizeof(Handle)); fd = __alloc_handle(dev);
if(fd < 0) { if(fd < 0) return fd;
errno = ENOMEM;
return -1;
}
handle = __get_handle(fd);
handle->device = dev;
handle->fileStruct = ((void *)handle) + sizeof(__handle);
memset(tmpaddr, 0, 0x1c); memset(tmpaddr, 0, 0x1c);
@ -79,7 +71,10 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
return -1; return -1;
} }
else else
{
__handle *handle = __get_handle(fd);
*(Handle*)handle->fileStruct = ret; *(Handle*)handle->fileStruct = ret;
}
return fd; return fd;
} }

View File

@ -37,11 +37,8 @@ int socket(int domain, int type, int protocol)
return -1; return -1;
} }
fd = __alloc_handle(sizeof(__handle) + sizeof(Handle)); fd = __alloc_handle(dev);
if(fd < 0) { if(fd < 0) return fd;
errno = ENOMEM;
return -1;
}
handle = __get_handle(fd); handle = __get_handle(fd);
handle->device = dev; handle->device = dev;