diff options
Diffstat (limited to 'nsprpub/pr/src/md/os2')
-rw-r--r-- | nsprpub/pr/src/md/os2/os2_errors.c | 1684 | ||||
-rw-r--r-- | nsprpub/pr/src/md/os2/os2cv.c | 96 | ||||
-rw-r--r-- | nsprpub/pr/src/md/os2/os2gc.c | 10 | ||||
-rw-r--r-- | nsprpub/pr/src/md/os2/os2inrval.c | 11 | ||||
-rw-r--r-- | nsprpub/pr/src/md/os2/os2io.c | 438 | ||||
-rw-r--r-- | nsprpub/pr/src/md/os2/os2misc.c | 83 | ||||
-rw-r--r-- | nsprpub/pr/src/md/os2/os2poll.c | 85 | ||||
-rw-r--r-- | nsprpub/pr/src/md/os2/os2rng.c | 25 | ||||
-rw-r--r-- | nsprpub/pr/src/md/os2/os2sem.c | 20 | ||||
-rw-r--r-- | nsprpub/pr/src/md/os2/os2sock.c | 145 | ||||
-rw-r--r-- | nsprpub/pr/src/md/os2/os2thred.c | 114 |
11 files changed, 1389 insertions, 1322 deletions
diff --git a/nsprpub/pr/src/md/os2/os2_errors.c b/nsprpub/pr/src/md/os2/os2_errors.c index 98f5cde59..dfcca6108 100644 --- a/nsprpub/pr/src/md/os2/os2_errors.c +++ b/nsprpub/pr/src/md/os2/os2_errors.c @@ -8,152 +8,152 @@ void _MD_os2_map_default_error(PRInt32 err) { - switch (err) { - case EWOULDBLOCK: - PR_SetError(PR_WOULD_BLOCK_ERROR, err); - break; - case EBADF: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ENOTSOCK: - PR_SetError(PR_NOT_SOCKET_ERROR, err); - break; - case EMSGSIZE: - case EINVAL: - PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); - break; - case ENOBUFS: - PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); - break; - case ECONNREFUSED: - PR_SetError(PR_CONNECT_REFUSED_ERROR, err); - break; - case EISCONN: - PR_SetError(PR_IS_CONNECTED_ERROR, err); - break; + switch (err) { + case EWOULDBLOCK: + PR_SetError(PR_WOULD_BLOCK_ERROR, err); + break; + case EBADF: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ENOTSOCK: + PR_SetError(PR_NOT_SOCKET_ERROR, err); + break; + case EMSGSIZE: + case EINVAL: + PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); + break; + case ENOBUFS: + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); + break; + case ECONNREFUSED: + PR_SetError(PR_CONNECT_REFUSED_ERROR, err); + break; + case EISCONN: + PR_SetError(PR_IS_CONNECTED_ERROR, err); + break; #ifdef SOCEFAULT - case SOCEFAULT: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; + case SOCEFAULT: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; #endif - case ERROR_NETNAME_DELETED: - PR_SetError(PR_CONNECT_RESET_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + case ERROR_NETNAME_DELETED: + PR_SetError(PR_CONNECT_RESET_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_opendir_error(PRInt32 err) { - switch (err) { - case ERROR_FILE_NOT_FOUND: - case ERROR_PATH_NOT_FOUND: - PR_SetError(PR_FILE_NOT_FOUND_ERROR, err); - break; - case ERROR_ACCESS_DENIED: - PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); - break; - case ERROR_INVALID_ADDRESS: - case ERROR_INVALID_ACCESS: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; - case ERROR_INVALID_NAME: - case ERROR_INVALID_PARAMETER: - PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); - break; - case ERROR_TOO_MANY_OPEN_FILES: - case ERROR_NOT_DOS_DISK: - case ERROR_NOT_READY: - case ERROR_OPEN_FAILED: - case ERROR_PATH_BUSY: - case ERROR_CANNOT_MAKE: - PR_SetError(PR_IO_ERROR, err); - break; - case ERROR_DRIVE_LOCKED: - case ERROR_DEVICE_IN_USE: - PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); - break; - case ERROR_FILENAME_EXCED_RANGE: - PR_SetError(PR_NAME_TOO_LONG_ERROR, err); - break; - case ERROR_NOT_ENOUGH_MEMORY: - case ERROR_SHARING_BUFFER_EXCEEDED: - PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + switch (err) { + case ERROR_FILE_NOT_FOUND: + case ERROR_PATH_NOT_FOUND: + PR_SetError(PR_FILE_NOT_FOUND_ERROR, err); + break; + case ERROR_ACCESS_DENIED: + PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); + break; + case ERROR_INVALID_ADDRESS: + case ERROR_INVALID_ACCESS: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; + case ERROR_INVALID_NAME: + case ERROR_INVALID_PARAMETER: + PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); + break; + case ERROR_TOO_MANY_OPEN_FILES: + case ERROR_NOT_DOS_DISK: + case ERROR_NOT_READY: + case ERROR_OPEN_FAILED: + case ERROR_PATH_BUSY: + case ERROR_CANNOT_MAKE: + PR_SetError(PR_IO_ERROR, err); + break; + case ERROR_DRIVE_LOCKED: + case ERROR_DEVICE_IN_USE: + PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); + break; + case ERROR_FILENAME_EXCED_RANGE: + PR_SetError(PR_NAME_TOO_LONG_ERROR, err); + break; + case ERROR_NOT_ENOUGH_MEMORY: + case ERROR_SHARING_BUFFER_EXCEEDED: + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_closedir_error(PRInt32 err) { - switch (err) { - case ERROR_FILE_NOT_FOUND: - case ERROR_ACCESS_DENIED: - case ERROR_INVALID_HANDLE: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + switch (err) { + case ERROR_FILE_NOT_FOUND: + case ERROR_ACCESS_DENIED: + case ERROR_INVALID_HANDLE: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_readdir_error(PRInt32 err) { - switch (err) { - case ERROR_NO_MORE_FILES: - PR_SetError(PR_NO_MORE_FILES_ERROR, err); - break; - case ERROR_FILE_NOT_FOUND: - case ERROR_INVALID_HANDLE: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ERROR_INVALID_ADDRESS: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; - case ERROR_NOT_DOS_DISK: - case ERROR_LOCK_VIOLATION: - case ERROR_BROKEN_PIPE: - case ERROR_NOT_READY: - PR_SetError(PR_IO_ERROR, err); - break; - case ERROR_NOT_ENOUGH_MEMORY: - case ERROR_MORE_DATA: - PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + switch (err) { + case ERROR_NO_MORE_FILES: + PR_SetError(PR_NO_MORE_FILES_ERROR, err); + break; + case ERROR_FILE_NOT_FOUND: + case ERROR_INVALID_HANDLE: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ERROR_INVALID_ADDRESS: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; + case ERROR_NOT_DOS_DISK: + case ERROR_LOCK_VIOLATION: + case ERROR_BROKEN_PIPE: + case ERROR_NOT_READY: + PR_SetError(PR_IO_ERROR, err); + break; + case ERROR_NOT_ENOUGH_MEMORY: + case ERROR_MORE_DATA: + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_delete_error(PRInt32 err) { - switch (err) { - case ERROR_FILE_NOT_FOUND: - case ERROR_PATH_NOT_FOUND: - PR_SetError(PR_FILE_NOT_FOUND_ERROR, err); - break; - case ERROR_ACCESS_DENIED: - case ERROR_WRITE_PROTECT: - PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); - break; - case ERROR_INVALID_ADDRESS: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; - case ERROR_DRIVE_LOCKED: - case ERROR_LOCKED: - case ERROR_SHARING_VIOLATION: - PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + switch (err) { + case ERROR_FILE_NOT_FOUND: + case ERROR_PATH_NOT_FOUND: + PR_SetError(PR_FILE_NOT_FOUND_ERROR, err); + break; + case ERROR_ACCESS_DENIED: + case ERROR_WRITE_PROTECT: + PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); + break; + case ERROR_INVALID_ADDRESS: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; + case ERROR_DRIVE_LOCKED: + case ERROR_LOCKED: + case ERROR_SHARING_VIOLATION: + PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } /* The error code for stat() is in errno. */ @@ -173,72 +173,72 @@ void _MD_os2_map_stat_error(PRInt32 err) void _MD_os2_map_fstat_error(PRInt32 err) { - switch (err) { - case ERROR_ACCESS_DENIED: - PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); - break; - case ERROR_INVALID_HANDLE: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ERROR_INVALID_ADDRESS: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; - case ERROR_NOT_READY: - case ERROR_PATH_BUSY: - PR_SetError(PR_IO_ERROR, err); - break; - case ERROR_NOT_ENOUGH_MEMORY: - case ERROR_MORE_DATA: - PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); - break; - case ERROR_DRIVE_LOCKED: - case ERROR_LOCKED: - PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + switch (err) { + case ERROR_ACCESS_DENIED: + PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); + break; + case ERROR_INVALID_HANDLE: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ERROR_INVALID_ADDRESS: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; + case ERROR_NOT_READY: + case ERROR_PATH_BUSY: + PR_SetError(PR_IO_ERROR, err); + break; + case ERROR_NOT_ENOUGH_MEMORY: + case ERROR_MORE_DATA: + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); + break; + case ERROR_DRIVE_LOCKED: + case ERROR_LOCKED: + PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_rename_error(PRInt32 err) { - switch (err) { - case ERROR_FILE_NOT_FOUND: - case ERROR_PATH_NOT_FOUND: - PR_SetError(PR_FILE_NOT_FOUND_ERROR, err); - break; - case ERROR_ACCESS_DENIED: - PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); - break; - case ERROR_INVALID_ADDRESS: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; - case ERROR_INVALID_NAME: - PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); - break; - case ERROR_NOT_READY: - case ERROR_PATH_BUSY: - PR_SetError(PR_IO_ERROR, err); - break; - case ERROR_DRIVE_LOCKED: - PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); - break; - case ERROR_FILENAME_EXCED_RANGE: - PR_SetError(PR_NAME_TOO_LONG_ERROR, err); - break; - case ERROR_NOT_ENOUGH_MEMORY: - case ERROR_MORE_DATA: - PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); - break; - case ERROR_ALREADY_EXISTS: - case ERROR_FILE_EXISTS: - PR_SetError(PR_FILE_EXISTS_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + switch (err) { + case ERROR_FILE_NOT_FOUND: + case ERROR_PATH_NOT_FOUND: + PR_SetError(PR_FILE_NOT_FOUND_ERROR, err); + break; + case ERROR_ACCESS_DENIED: + PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); + break; + case ERROR_INVALID_ADDRESS: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; + case ERROR_INVALID_NAME: + PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); + break; + case ERROR_NOT_READY: + case ERROR_PATH_BUSY: + PR_SetError(PR_IO_ERROR, err); + break; + case ERROR_DRIVE_LOCKED: + PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); + break; + case ERROR_FILENAME_EXCED_RANGE: + PR_SetError(PR_NAME_TOO_LONG_ERROR, err); + break; + case ERROR_NOT_ENOUGH_MEMORY: + case ERROR_MORE_DATA: + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); + break; + case ERROR_ALREADY_EXISTS: + case ERROR_FILE_EXISTS: + PR_SetError(PR_FILE_EXISTS_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } /* The error code for access() is in errno. */ @@ -258,458 +258,458 @@ void _MD_os2_map_access_error(PRInt32 err) void _MD_os2_map_mkdir_error(PRInt32 err) { - switch (err) { - case ERROR_ALREADY_EXISTS: - case ERROR_FILE_EXISTS: - PR_SetError(PR_FILE_EXISTS_ERROR, err); - break; - case ERROR_FILE_NOT_FOUND: - PR_SetError(PR_FILE_NOT_FOUND_ERROR, err); - break; - case ERROR_ACCESS_DENIED: - PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); - break; - case ERROR_INVALID_ADDRESS: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; - case ERROR_INVALID_NAME: - PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); - break; - case ERROR_NOT_READY: - case ERROR_PATH_BUSY: - PR_SetError(PR_IO_ERROR, err); - break; - case ERROR_DRIVE_LOCKED: - PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); - break; - case ERROR_FILENAME_EXCED_RANGE: - PR_SetError(PR_NAME_TOO_LONG_ERROR, err); - break; - case ERROR_TOO_MANY_OPEN_FILES: - PR_SetError(PR_SYS_DESC_TABLE_FULL_ERROR, err); - break; - case ERROR_PATH_NOT_FOUND: - PR_SetError(PR_FILE_NOT_FOUND_ERROR, err); - break; - case ERROR_NOT_ENOUGH_MEMORY: - case ERROR_MORE_DATA: - PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); - break; - case ERROR_DISK_FULL: - case ERROR_HANDLE_DISK_FULL: - PR_SetError(PR_NO_DEVICE_SPACE_ERROR, err); - break; - case ERROR_WRITE_PROTECT: - PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + switch (err) { + case ERROR_ALREADY_EXISTS: + case ERROR_FILE_EXISTS: + PR_SetError(PR_FILE_EXISTS_ERROR, err); + break; + case ERROR_FILE_NOT_FOUND: + PR_SetError(PR_FILE_NOT_FOUND_ERROR, err); + break; + case ERROR_ACCESS_DENIED: + PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); + break; + case ERROR_INVALID_ADDRESS: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; + case ERROR_INVALID_NAME: + PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); + break; + case ERROR_NOT_READY: + case ERROR_PATH_BUSY: + PR_SetError(PR_IO_ERROR, err); + break; + case ERROR_DRIVE_LOCKED: + PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); + break; + case ERROR_FILENAME_EXCED_RANGE: + PR_SetError(PR_NAME_TOO_LONG_ERROR, err); + break; + case ERROR_TOO_MANY_OPEN_FILES: + PR_SetError(PR_SYS_DESC_TABLE_FULL_ERROR, err); + break; + case ERROR_PATH_NOT_FOUND: + PR_SetError(PR_FILE_NOT_FOUND_ERROR, err); + break; + case ERROR_NOT_ENOUGH_MEMORY: + case ERROR_MORE_DATA: + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); + break; + case ERROR_DISK_FULL: + case ERROR_HANDLE_DISK_FULL: + PR_SetError(PR_NO_DEVICE_SPACE_ERROR, err); + break; + case ERROR_WRITE_PROTECT: + PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_rmdir_error(PRInt32 err) { - switch (err) { - case ERROR_FILE_NOT_FOUND: - PR_SetError(PR_FILE_NOT_FOUND_ERROR, err); - break; - case ERROR_ACCESS_DENIED: - PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); - break; - case ERROR_INVALID_ADDRESS: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; - case ERROR_INVALID_NAME: - PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); - break; - case ERROR_NOT_READY: - case ERROR_PATH_BUSY: - PR_SetError(PR_IO_ERROR, err); - break; - case ERROR_DRIVE_LOCKED: - PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); - break; - case ERROR_FILENAME_EXCED_RANGE: - PR_SetError(PR_NAME_TOO_LONG_ERROR, err); - break; - case ERROR_TOO_MANY_OPEN_FILES: - PR_SetError(PR_SYS_DESC_TABLE_FULL_ERROR, err); - break; - case ERROR_PATH_NOT_FOUND: - PR_SetError(PR_FILE_NOT_FOUND_ERROR, err); - break; - case ERROR_NOT_ENOUGH_MEMORY: - case ERROR_MORE_DATA: - PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); - break; - case ERROR_WRITE_PROTECT: - PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + switch (err) { + case ERROR_FILE_NOT_FOUND: + PR_SetError(PR_FILE_NOT_FOUND_ERROR, err); + break; + case ERROR_ACCESS_DENIED: + PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); + break; + case ERROR_INVALID_ADDRESS: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; + case ERROR_INVALID_NAME: + PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); + break; + case ERROR_NOT_READY: + case ERROR_PATH_BUSY: + PR_SetError(PR_IO_ERROR, err); + break; + case ERROR_DRIVE_LOCKED: + PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); + break; + case ERROR_FILENAME_EXCED_RANGE: + PR_SetError(PR_NAME_TOO_LONG_ERROR, err); + break; + case ERROR_TOO_MANY_OPEN_FILES: + PR_SetError(PR_SYS_DESC_TABLE_FULL_ERROR, err); + break; + case ERROR_PATH_NOT_FOUND: + PR_SetError(PR_FILE_NOT_FOUND_ERROR, err); + break; + case ERROR_NOT_ENOUGH_MEMORY: + case ERROR_MORE_DATA: + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); + break; + case ERROR_WRITE_PROTECT: + PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_read_error(PRInt32 err) { - switch (err) { - case ERROR_ACCESS_DENIED: - PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); - break; - case ERROR_INVALID_HANDLE: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ERROR_INVALID_ADDRESS: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; - case ERROR_NOT_READY: - case ERROR_PATH_BUSY: - PR_SetError(PR_IO_ERROR, err); - break; - case ERROR_NOT_ENOUGH_MEMORY: - case ERROR_MORE_DATA: - PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); - break; - case ERROR_DRIVE_LOCKED: - case ERROR_LOCKED: - case ERROR_SHARING_VIOLATION: - PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); - break; - case ERROR_NETNAME_DELETED: - PR_SetError(PR_CONNECT_RESET_ERROR, err); - break; - case EBADF: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ENOTSOCK: - PR_SetError(PR_NOT_SOCKET_ERROR, err); - break; + switch (err) { + case ERROR_ACCESS_DENIED: + PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); + break; + case ERROR_INVALID_HANDLE: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ERROR_INVALID_ADDRESS: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; + case ERROR_NOT_READY: + case ERROR_PATH_BUSY: + PR_SetError(PR_IO_ERROR, err); + break; + case ERROR_NOT_ENOUGH_MEMORY: + case ERROR_MORE_DATA: + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); + break; + case ERROR_DRIVE_LOCKED: + case ERROR_LOCKED: + case ERROR_SHARING_VIOLATION: + PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); + break; + case ERROR_NETNAME_DELETED: + PR_SetError(PR_CONNECT_RESET_ERROR, err); + break; + case EBADF: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ENOTSOCK: + PR_SetError(PR_NOT_SOCKET_ERROR, err); + break; #ifdef SOCEFAULT - case SOCEFAULT: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; + case SOCEFAULT: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; #endif - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_transmitfile_error(PRInt32 err) { - switch (err) { - case ERROR_ACCESS_DENIED: - PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); - break; - case ERROR_INVALID_HANDLE: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ERROR_INVALID_ADDRESS: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; - case ERROR_NOT_READY: - case ERROR_PATH_BUSY: - PR_SetError(PR_IO_ERROR, err); - break; - case ERROR_NOT_ENOUGH_MEMORY: - case ERROR_MORE_DATA: - PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); - break; - case ERROR_DRIVE_LOCKED: - case ERROR_LOCKED: - case ERROR_SHARING_VIOLATION: - PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); - break; - case ERROR_FILENAME_EXCED_RANGE: - PR_SetError(PR_NAME_TOO_LONG_ERROR, err); - break; - case ERROR_TOO_MANY_OPEN_FILES: - PR_SetError(PR_SYS_DESC_TABLE_FULL_ERROR, err); - break; - case ERROR_PATH_NOT_FOUND: - PR_SetError(PR_FILE_NOT_FOUND_ERROR, err); - break; - case EBADF: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ENOTSOCK: - PR_SetError(PR_NOT_SOCKET_ERROR, err); - break; + switch (err) { + case ERROR_ACCESS_DENIED: + PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); + break; + case ERROR_INVALID_HANDLE: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ERROR_INVALID_ADDRESS: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; + case ERROR_NOT_READY: + case ERROR_PATH_BUSY: + PR_SetError(PR_IO_ERROR, err); + break; + case ERROR_NOT_ENOUGH_MEMORY: + case ERROR_MORE_DATA: + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); + break; + case ERROR_DRIVE_LOCKED: + case ERROR_LOCKED: + case ERROR_SHARING_VIOLATION: + PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); + break; + case ERROR_FILENAME_EXCED_RANGE: + PR_SetError(PR_NAME_TOO_LONG_ERROR, err); + break; + case ERROR_TOO_MANY_OPEN_FILES: + PR_SetError(PR_SYS_DESC_TABLE_FULL_ERROR, err); + break; + case ERROR_PATH_NOT_FOUND: + PR_SetError(PR_FILE_NOT_FOUND_ERROR, err); + break; + case EBADF: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ENOTSOCK: + PR_SetError(PR_NOT_SOCKET_ERROR, err); + break; #ifdef SOCEFAULT - case SOCEFAULT: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; + case SOCEFAULT: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; #endif - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_write_error(PRInt32 err) { - switch (err) { - case ERROR_ACCESS_DENIED: - case ERROR_WRITE_PROTECT: - PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); - break; - case ERROR_INVALID_HANDLE: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ERROR_INVALID_ADDRESS: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; - case ERROR_NOT_READY: - case ERROR_PATH_BUSY: - PR_SetError(PR_IO_ERROR, err); - break; - case ERROR_DRIVE_LOCKED: - case ERROR_LOCKED: - case ERROR_SHARING_VIOLATION: - PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); - break; - case ERROR_NOT_ENOUGH_MEMORY: - case ERROR_MORE_DATA: - case ERROR_DISK_FULL: - case ERROR_HANDLE_DISK_FULL: - case ENOSPC: - PR_SetError(PR_NO_DEVICE_SPACE_ERROR, err); - break; - case ERROR_NETNAME_DELETED: - PR_SetError(PR_CONNECT_RESET_ERROR, err); - break; - case EBADF: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ENOTSOCK: - PR_SetError(PR_NOT_SOCKET_ERROR, err); - break; - case EMSGSIZE: - case EINVAL: - PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); - break; - case ENOBUFS: - PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); - break; - case ECONNREFUSED: - PR_SetError(PR_CONNECT_REFUSED_ERROR, err); - break; - case EISCONN: - PR_SetError(PR_IS_CONNECTED_ERROR, err); - break; + switch (err) { + case ERROR_ACCESS_DENIED: + case ERROR_WRITE_PROTECT: + PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); + break; + case ERROR_INVALID_HANDLE: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ERROR_INVALID_ADDRESS: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; + case ERROR_NOT_READY: + case ERROR_PATH_BUSY: + PR_SetError(PR_IO_ERROR, err); + break; + case ERROR_DRIVE_LOCKED: + case ERROR_LOCKED: + case ERROR_SHARING_VIOLATION: + PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); + break; + case ERROR_NOT_ENOUGH_MEMORY: + case ERROR_MORE_DATA: + case ERROR_DISK_FULL: + case ERROR_HANDLE_DISK_FULL: + case ENOSPC: + PR_SetError(PR_NO_DEVICE_SPACE_ERROR, err); + break; + case ERROR_NETNAME_DELETED: + PR_SetError(PR_CONNECT_RESET_ERROR, err); + break; + case EBADF: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ENOTSOCK: + PR_SetError(PR_NOT_SOCKET_ERROR, err); + break; + case EMSGSIZE: + case EINVAL: + PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); + break; + case ENOBUFS: + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); + break; + case ECONNREFUSED: + PR_SetError(PR_CONNECT_REFUSED_ERROR, err); + break; + case EISCONN: + PR_SetError(PR_IS_CONNECTED_ERROR, err); + break; #ifdef SOCEFAULT - case SOCEFAULT: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; + case SOCEFAULT: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; #endif - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_lseek_error(PRInt32 err) { - switch (err) { - case ERROR_INVALID_HANDLE: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ERROR_SEEK_ON_DEVICE: - PR_SetError(PR_IO_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + switch (err) { + case ERROR_INVALID_HANDLE: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ERROR_SEEK_ON_DEVICE: + PR_SetError(PR_IO_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_fsync_error(PRInt32 err) { - switch (err) { - case ERROR_ACCESS_DENIED: - case ERROR_WRITE_PROTECT: - PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); - break; - case ERROR_INVALID_HANDLE: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ERROR_NOT_ENOUGH_MEMORY: - case ERROR_MORE_DATA: - PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); - break; - case ERROR_DISK_FULL: - case ERROR_HANDLE_DISK_FULL: - PR_SetError(PR_NO_DEVICE_SPACE_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + switch (err) { + case ERROR_ACCESS_DENIED: + case ERROR_WRITE_PROTECT: + PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); + break; + case ERROR_INVALID_HANDLE: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ERROR_NOT_ENOUGH_MEMORY: + case ERROR_MORE_DATA: + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); + break; + case ERROR_DISK_FULL: + case ERROR_HANDLE_DISK_FULL: + PR_SetError(PR_NO_DEVICE_SPACE_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_close_error(PRInt32 err) { - switch (err) { - case ERROR_INVALID_HANDLE: - case EBADF: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ERROR_NOT_READY: - case ERROR_PATH_BUSY: - PR_SetError(PR_IO_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + switch (err) { + case ERROR_INVALID_HANDLE: + case EBADF: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ERROR_NOT_READY: + case ERROR_PATH_BUSY: + PR_SetError(PR_IO_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_socket_error(PRInt32 err) { - switch (err) { - case EPROTONOSUPPORT: - PR_SetError(PR_PROTOCOL_NOT_SUPPORTED_ERROR, err); - break; - case EACCES: - PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); - break; - case ERROR_NOT_ENOUGH_MEMORY: - case ERROR_MORE_DATA: - case ENOBUFS: - PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + switch (err) { + case EPROTONOSUPPORT: + PR_SetError(PR_PROTOCOL_NOT_SUPPORTED_ERROR, err); + break; + case EACCES: + PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); + break; + case ERROR_NOT_ENOUGH_MEMORY: + case ERROR_MORE_DATA: + case ENOBUFS: + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_recv_error(PRInt32 err) { - switch (err) { - case EWOULDBLOCK: - PR_SetError(PR_WOULD_BLOCK_ERROR, err); - break; - case EBADF: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ENOTSOCK: - PR_SetError(PR_NOT_SOCKET_ERROR, err); - break; + switch (err) { + case EWOULDBLOCK: + PR_SetError(PR_WOULD_BLOCK_ERROR, err); + break; + case EBADF: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ENOTSOCK: + PR_SetError(PR_NOT_SOCKET_ERROR, err); + break; #ifdef SOCEFAULT - case SOCEFAULT: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; + case SOCEFAULT: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; #endif - case ERROR_NETNAME_DELETED: - PR_SetError(PR_CONNECT_RESET_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + case ERROR_NETNAME_DELETED: + PR_SetError(PR_CONNECT_RESET_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_recvfrom_error(PRInt32 err) { - switch (err) { - case EWOULDBLOCK: - PR_SetError(PR_WOULD_BLOCK_ERROR, err); - break; - case EBADF: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ENOTSOCK: - PR_SetError(PR_NOT_SOCKET_ERROR, err); - break; + switch (err) { + case EWOULDBLOCK: + PR_SetError(PR_WOULD_BLOCK_ERROR, err); + break; + case EBADF: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ENOTSOCK: + PR_SetError(PR_NOT_SOCKET_ERROR, err); + break; #ifdef SOCEFAULT - case SOCEFAULT: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; + case SOCEFAULT: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; #endif - case ERROR_NETNAME_DELETED: - PR_SetError(PR_CONNECT_RESET_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + case ERROR_NETNAME_DELETED: + PR_SetError(PR_CONNECT_RESET_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_send_error(PRInt32 err) { - switch (err) { - case EWOULDBLOCK: - PR_SetError(PR_WOULD_BLOCK_ERROR, err); - break; - case EBADF: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ENOTSOCK: - PR_SetError(PR_NOT_SOCKET_ERROR, err); - break; - case EMSGSIZE: - case EINVAL: - PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); - break; - case ENOBUFS: - PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); - break; - case ECONNREFUSED: - PR_SetError(PR_CONNECT_REFUSED_ERROR, err); - break; - case EISCONN: - PR_SetError(PR_IS_CONNECTED_ERROR, err); - break; + switch (err) { + case EWOULDBLOCK: + PR_SetError(PR_WOULD_BLOCK_ERROR, err); + break; + case EBADF: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ENOTSOCK: + PR_SetError(PR_NOT_SOCKET_ERROR, err); + break; + case EMSGSIZE: + case EINVAL: + PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); + break; + case ENOBUFS: + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); + break; + case ECONNREFUSED: + PR_SetError(PR_CONNECT_REFUSED_ERROR, err); + break; + case EISCONN: + PR_SetError(PR_IS_CONNECTED_ERROR, err); + break; #ifdef SOCEFAULT - case SOCEFAULT: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; + case SOCEFAULT: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; #endif - case ERROR_NETNAME_DELETED: - PR_SetError(PR_CONNECT_RESET_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + case ERROR_NETNAME_DELETED: + PR_SetError(PR_CONNECT_RESET_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_sendto_error(PRInt32 err) { - _MD_os2_map_default_error(err); + _MD_os2_map_default_error(err); } void _MD_os2_map_writev_error(int err) { - _MD_os2_map_default_error(err); + _MD_os2_map_default_error(err); } void _MD_os2_map_accept_error(PRInt32 err) { - _MD_os2_map_default_error(err); + _MD_os2_map_default_error(err); } void _MD_os2_map_acceptex_error(PRInt32 err) { - switch (err) { - case ERROR_INVALID_HANDLE: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ERROR_INVALID_ADDRESS: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; - case ERROR_NOT_ENOUGH_MEMORY: - case ERROR_MORE_DATA: - PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + switch (err) { + case ERROR_INVALID_HANDLE: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ERROR_INVALID_ADDRESS: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; + case ERROR_NOT_ENOUGH_MEMORY: + case ERROR_MORE_DATA: + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } /* @@ -729,315 +729,315 @@ int _MD_os2_get_nonblocking_connect_error(int osfd) void _MD_os2_map_connect_error(PRInt32 err) { - switch (err) { - case EWOULDBLOCK: - PR_SetError(PR_WOULD_BLOCK_ERROR, err); - break; + switch (err) { + case EWOULDBLOCK: + PR_SetError(PR_WOULD_BLOCK_ERROR, err); + break; case EINPROGRESS: - PR_SetError(PR_IN_PROGRESS_ERROR, err); - break; - case EALREADY: - case EINVAL: - PR_SetError(PR_ALREADY_INITIATED_ERROR, err); - break; - case EBADF: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case EADDRNOTAVAIL: - PR_SetError(PR_ADDRESS_NOT_AVAILABLE_ERROR, err); - break; - case ENOTSOCK: - PR_SetError(PR_NOT_SOCKET_ERROR, err); - break; - case EAFNOSUPPORT: - PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, err); - break; - case ETIMEDOUT: - PR_SetError(PR_IO_TIMEOUT_ERROR, err); - break; - case ECONNREFUSED: - PR_SetError(PR_CONNECT_REFUSED_ERROR, err); - break; - case ENETUNREACH: - PR_SetError(PR_NETWORK_UNREACHABLE_ERROR, err); - break; - case EADDRINUSE: - PR_SetError(PR_ADDRESS_IN_USE_ERROR, err); - break; - case EISCONN: - PR_SetError(PR_IS_CONNECTED_ERROR, err); - break; + PR_SetError(PR_IN_PROGRESS_ERROR, err); + break; + case EALREADY: + case EINVAL: + PR_SetError(PR_ALREADY_INITIATED_ERROR, err); + break; + case EBADF: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case EADDRNOTAVAIL: + PR_SetError(PR_ADDRESS_NOT_AVAILABLE_ERROR, err); + break; + case ENOTSOCK: + PR_SetError(PR_NOT_SOCKET_ERROR, err); + break; + case EAFNOSUPPORT: + PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, err); + break; + case ETIMEDOUT: + PR_SetError(PR_IO_TIMEOUT_ERROR, err); + break; + case ECONNREFUSED: + PR_SetError(PR_CONNECT_REFUSED_ERROR, err); + break; + case ENETUNREACH: + PR_SetError(PR_NETWORK_UNREACHABLE_ERROR, err); + break; + case EADDRINUSE: + PR_SetError(PR_ADDRESS_IN_USE_ERROR, err); + break; + case EISCONN: + PR_SetError(PR_IS_CONNECTED_ERROR, err); + break; #ifdef SOCEFAULT - case SOCEFAULT: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; + case SOCEFAULT: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; #endif - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_bind_error(PRInt32 err) { - switch (err) { - case EBADF: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ENOTSOCK: - PR_SetError(PR_NOT_SOCKET_ERROR, err); - break; + switch (err) { + case EBADF: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ENOTSOCK: + PR_SetError(PR_NOT_SOCKET_ERROR, err); + break; #ifdef SOCEFAULT - case SOCEFAULT: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; + case SOCEFAULT: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; #endif - case EADDRNOTAVAIL: - PR_SetError(PR_ADDRESS_NOT_AVAILABLE_ERROR, err); - break; - case EADDRINUSE: - PR_SetError(PR_ADDRESS_IN_USE_ERROR, err); - break; - case EACCES: - PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); - break; - case EINVAL: - PR_SetError(PR_SOCKET_ADDRESS_IS_BOUND_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + case EADDRNOTAVAIL: + PR_SetError(PR_ADDRESS_NOT_AVAILABLE_ERROR, err); + break; + case EADDRINUSE: + PR_SetError(PR_ADDRESS_IN_USE_ERROR, err); + break; + case EACCES: + PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); + break; + case EINVAL: + PR_SetError(PR_SOCKET_ADDRESS_IS_BOUND_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_listen_error(PRInt32 err) { - switch (err) { - case EBADF: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ENOTSOCK: - PR_SetError(PR_NOT_SOCKET_ERROR, err); - break; - case EOPNOTSUPP: - PR_SetError(PR_NOT_TCP_SOCKET_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + switch (err) { + case EBADF: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ENOTSOCK: + PR_SetError(PR_NOT_SOCKET_ERROR, err); + break; + case EOPNOTSUPP: + PR_SetError(PR_NOT_TCP_SOCKET_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_shutdown_error(PRInt32 err) { - switch (err) { - case EBADF: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ENOTSOCK: - PR_SetError(PR_NOT_SOCKET_ERROR, err); - break; - case ENOTCONN: - PR_SetError(PR_NOT_CONNECTED_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + switch (err) { + case EBADF: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ENOTSOCK: + PR_SetError(PR_NOT_SOCKET_ERROR, err); + break; + case ENOTCONN: + PR_SetError(PR_NOT_CONNECTED_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_socketpair_error(PRInt32 err) { - switch (err) { - case ENOMEM: - PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); - break; - case EAFNOSUPPORT: - PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, err); - break; - case EPROTONOSUPPORT: - PR_SetError(PR_PROTOCOL_NOT_SUPPORTED_ERROR, err); - break; - case EOPNOTSUPP: - PR_SetError(PR_NOT_TCP_SOCKET_ERROR, err); - break; - case EPROTOTYPE: - PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, err); - break; - default: - _MD_os2_map_default_error(err); - return; - } + switch (err) { + case ENOMEM: + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); + break; + case EAFNOSUPPORT: + PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, err); + break; + case EPROTONOSUPPORT: + PR_SetError(PR_PROTOCOL_NOT_SUPPORTED_ERROR, err); + break; + case EOPNOTSUPP: + PR_SetError(PR_NOT_TCP_SOCKET_ERROR, err); + break; + case EPROTOTYPE: + PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, err); + break; + default: + _MD_os2_map_default_error(err); + return; + } } void _MD_os2_map_getsockname_error(PRInt32 err) { - switch (err) { - case EBADF: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ENOTSOCK: - PR_SetError(PR_NOT_SOCKET_ERROR, err); - break; + switch (err) { + case EBADF: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ENOTSOCK: + PR_SetError(PR_NOT_SOCKET_ERROR, err); + break; #ifdef SOCEFAULT - case SOCEFAULT: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; + case SOCEFAULT: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; #endif - case ENOBUFS: - PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + case ENOBUFS: + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_getpeername_error(PRInt32 err) { - switch (err) { - case EBADF: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ENOTSOCK: - PR_SetError(PR_NOT_SOCKET_ERROR, err); - break; - case ENOTCONN: - PR_SetError(PR_NOT_CONNECTED_ERROR, err); - break; + switch (err) { + case EBADF: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ENOTSOCK: + PR_SetError(PR_NOT_SOCKET_ERROR, err); + break; + case ENOTCONN: + PR_SetError(PR_NOT_CONNECTED_ERROR, err); + break; #ifdef SOCEFAULT - case SOCEFAULT: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; + case SOCEFAULT: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; #endif - case ENOBUFS: - PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + case ENOBUFS: + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_getsockopt_error(PRInt32 err) { - switch (err) { - case EBADF: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ENOTSOCK: - PR_SetError(PR_NOT_SOCKET_ERROR, err); - break; - case ENOPROTOOPT: - PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); - break; + switch (err) { + case EBADF: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ENOTSOCK: + PR_SetError(PR_NOT_SOCKET_ERROR, err); + break; + case ENOPROTOOPT: + PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); + break; #ifdef SOCEFAULT - case SOCEFAULT: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; + case SOCEFAULT: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; #endif - case EINVAL: - PR_SetError(PR_BUFFER_OVERFLOW_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + case EINVAL: + PR_SetError(PR_BUFFER_OVERFLOW_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_setsockopt_error(PRInt32 err) { - switch (err) { - case EBADF: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ENOTSOCK: - PR_SetError(PR_NOT_SOCKET_ERROR, err); - break; - case ENOPROTOOPT: - PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); - break; + switch (err) { + case EBADF: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ENOTSOCK: + PR_SetError(PR_NOT_SOCKET_ERROR, err); + break; + case ENOPROTOOPT: + PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); + break; #ifdef SOCEFAULT - case SOCEFAULT: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; + case SOCEFAULT: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; #endif - case EINVAL: - PR_SetError(PR_BUFFER_OVERFLOW_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + case EINVAL: + PR_SetError(PR_BUFFER_OVERFLOW_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_open_error(PRInt32 err) { - switch (err) { - case ERROR_ALREADY_EXISTS: - case ERROR_FILE_EXISTS: - PR_SetError(PR_FILE_EXISTS_ERROR, err); - break; - case ERROR_FILE_NOT_FOUND: - PR_SetError(PR_FILE_NOT_FOUND_ERROR, err); - break; - case ERROR_ACCESS_DENIED: - PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); - break; - case ERROR_INVALID_ADDRESS: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; - case ERROR_INVALID_NAME: - PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); - break; - case ERROR_NOT_READY: - case ERROR_OPEN_FAILED: - case ERROR_PATH_BUSY: - PR_SetError(PR_IO_ERROR, err); - break; - case ERROR_DRIVE_LOCKED: - PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); - break; - case ERROR_FILENAME_EXCED_RANGE: - PR_SetError(PR_NAME_TOO_LONG_ERROR, err); - break; - case ERROR_TOO_MANY_OPEN_FILES: - PR_SetError(PR_SYS_DESC_TABLE_FULL_ERROR, err); - break; - case ERROR_PATH_NOT_FOUND: - PR_SetError(PR_FILE_NOT_FOUND_ERROR, err); - break; - case ERROR_NOT_ENOUGH_MEMORY: - case ERROR_MORE_DATA: - PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); - break; - case ERROR_DISK_FULL: - case ERROR_HANDLE_DISK_FULL: - PR_SetError(PR_NO_DEVICE_SPACE_ERROR, err); - break; - case ERROR_WRITE_PROTECT: - PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + switch (err) { + case ERROR_ALREADY_EXISTS: + case ERROR_FILE_EXISTS: + PR_SetError(PR_FILE_EXISTS_ERROR, err); + break; + case ERROR_FILE_NOT_FOUND: + PR_SetError(PR_FILE_NOT_FOUND_ERROR, err); + break; + case ERROR_ACCESS_DENIED: + PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); + break; + case ERROR_INVALID_ADDRESS: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; + case ERROR_INVALID_NAME: + PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); + break; + case ERROR_NOT_READY: + case ERROR_OPEN_FAILED: + case ERROR_PATH_BUSY: + PR_SetError(PR_IO_ERROR, err); + break; + case ERROR_DRIVE_LOCKED: + PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); + break; + case ERROR_FILENAME_EXCED_RANGE: + PR_SetError(PR_NAME_TOO_LONG_ERROR, err); + break; + case ERROR_TOO_MANY_OPEN_FILES: + PR_SetError(PR_SYS_DESC_TABLE_FULL_ERROR, err); + break; + case ERROR_PATH_NOT_FOUND: + PR_SetError(PR_FILE_NOT_FOUND_ERROR, err); + break; + case ERROR_NOT_ENOUGH_MEMORY: + case ERROR_MORE_DATA: + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); + break; + case ERROR_DISK_FULL: + case ERROR_HANDLE_DISK_FULL: + PR_SetError(PR_NO_DEVICE_SPACE_ERROR, err); + break; + case ERROR_WRITE_PROTECT: + PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } } void _MD_os2_map_gethostname_error(PRInt32 err) { switch (err) { #ifdef SOCEFAULT - case SOCEFAULT: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; + case SOCEFAULT: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; #endif - case ENETDOWN: - case EINPROGRESS: - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; + case ENETDOWN: + case EINPROGRESS: + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; } } @@ -1070,26 +1070,26 @@ void _MD_os2_map_select_error(PRInt32 err) void _MD_os2_map_lockf_error(PRInt32 err) { switch (err) { - case ERROR_ACCESS_DENIED: - PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); - break; - case ERROR_INVALID_HANDLE: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ERROR_INVALID_ADDRESS: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; - case ERROR_DRIVE_LOCKED: - case ERROR_LOCKED: - case ERROR_SHARING_VIOLATION: - PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); - break; - case ERROR_NOT_ENOUGH_MEMORY: - case ERROR_MORE_DATA: - PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; + case ERROR_ACCESS_DENIED: + PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err); + break; + case ERROR_INVALID_HANDLE: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ERROR_INVALID_ADDRESS: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; + case ERROR_DRIVE_LOCKED: + case ERROR_LOCKED: + case ERROR_SHARING_VIOLATION: + PR_SetError(PR_FILE_IS_LOCKED_ERROR, err); + break; + case ERROR_NOT_ENOUGH_MEMORY: + case ERROR_MORE_DATA: + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; } } diff --git a/nsprpub/pr/src/md/os2/os2cv.c b/nsprpub/pr/src/md/os2/os2cv.c index 2c424c50b..91e85c0eb 100644 --- a/nsprpub/pr/src/md/os2/os2cv.c +++ b/nsprpub/pr/src/md/os2/os2cv.c @@ -16,7 +16,7 @@ * until right after we unlock the lock. This way the awakened threads * have a better chance to reaquire the lock. */ - + #include "primpl.h" /* @@ -30,7 +30,7 @@ static void AddThreadToCVWaitQueueInternal(PRThread *thred, struct _MDCVar *cv) { PR_ASSERT((cv->waitTail != NULL && cv->waitHead != NULL) - || (cv->waitTail == NULL && cv->waitHead == NULL)); + || (cv->waitTail == NULL && cv->waitHead == NULL)); cv->nwait += 1; thred->md.inCVWaitQueue = PR_TRUE; thred->md.next = NULL; @@ -78,7 +78,7 @@ md_UnlockAndPostNotifies( lock->notified.link = NULL; #endif - /* + /* * Figure out how many threads we need to wake up. */ notified = &post; /* this is where we start */ @@ -87,7 +87,7 @@ md_UnlockAndPostNotifies( _MDCVar *cv = notified->cv[index].cv; PRThread *thred; int i; - + /* Fast special case: no waiting threads */ if (cv->waitHead == NULL) { notified->cv[index].notifyHead = NULL; @@ -155,7 +155,9 @@ md_UnlockAndPostNotifies( } prev = notified; notified = notified->link; - if (&post != prev) PR_DELETE(prev); + if (&post != prev) { + PR_DELETE(prev); + } } while (NULL != notified); } @@ -165,7 +167,7 @@ md_UnlockAndPostNotifies( * MP systems don't contend for a lock that they can't have. */ static void md_PostNotifyToCvar(_MDCVar *cvar, _MDLock *lock, - PRBool broadcast) + PRBool broadcast) { PRIntn index = 0; _MDNotified *notified = &lock->notified; @@ -182,7 +184,9 @@ static void md_PostNotifyToCvar(_MDCVar *cvar, _MDLock *lock, } } /* if not full, enter new CV in this array */ - if (notified->length < _MD_CV_NOTIFIED_LENGTH) break; + if (notified->length < _MD_CV_NOTIFIED_LENGTH) { + break; + } /* if there's no link, create an empty array and link it */ if (NULL == notified->link) { @@ -215,7 +219,7 @@ _PR_MD_NEW_CV(_MDCVar *cv) * when the PRCondVar structure is created. */ return 0; -} +} void _PR_MD_FREE_CV(_MDCVar *cv) { @@ -232,7 +236,7 @@ _PR_MD_WAIT_CV(_MDCVar *cv, _MDLock *lock, PRIntervalTime timeout ) PRThread *thred = _PR_MD_CURRENT_THREAD(); ULONG rv, count; ULONG msecs = (timeout == PR_INTERVAL_NO_TIMEOUT) ? - SEM_INDEFINITE_WAIT : PR_IntervalToMilliseconds(timeout); + SEM_INDEFINITE_WAIT : PR_IntervalToMilliseconds(timeout); /* * If we have pending notifies, post them now. @@ -241,7 +245,7 @@ _PR_MD_WAIT_CV(_MDCVar *cv, _MDLock *lock, PRIntervalTime timeout ) md_UnlockAndPostNotifies(lock, thred, cv); } else { AddThreadToCVWaitQueueInternal(thred, cv); - DosReleaseMutexSem(lock->mutex); + DosReleaseMutexSem(lock->mutex); } /* Wait for notification or timeout; don't really care which */ @@ -256,42 +260,42 @@ _PR_MD_WAIT_CV(_MDCVar *cv, _MDLock *lock, PRIntervalTime timeout ) if(rv == ERROR_TIMEOUT) { - if (thred->md.inCVWaitQueue) { - PR_ASSERT((cv->waitTail != NULL && cv->waitHead != NULL) - || (cv->waitTail == NULL && cv->waitHead == NULL)); - cv->nwait -= 1; - thred->md.inCVWaitQueue = PR_FALSE; - if (cv->waitHead == thred) { - cv->waitHead = thred->md.next; - if (cv->waitHead == NULL) { - cv->waitTail = NULL; - } else { - cv->waitHead->md.prev = NULL; - } - } else { - PR_ASSERT(thred->md.prev != NULL); - thred->md.prev->md.next = thred->md.next; - if (thred->md.next != NULL) { - thred->md.next->md.prev = thred->md.prev; - } else { - PR_ASSERT(cv->waitTail == thred); - cv->waitTail = thred->md.prev; - } - } - thred->md.next = thred->md.prev = NULL; - } else { - /* - * This thread must have been notified, but the - * SemRelease call happens after SemRequest - * times out. Wait on the semaphore again to make it - * non-signaled. We assume this wait won't take long. - */ - rv = DosWaitEventSem(thred->md.blocked_sema, SEM_INDEFINITE_WAIT); - if (rv == NO_ERROR) { - DosResetEventSem(thred->md.blocked_sema, &count); - } - PR_ASSERT(rv == NO_ERROR); - } + if (thred->md.inCVWaitQueue) { + PR_ASSERT((cv->waitTail != NULL && cv->waitHead != NULL) + || (cv->waitTail == NULL && cv->waitHead == NULL)); + cv->nwait -= 1; + thred->md.inCVWaitQueue = PR_FALSE; + if (cv->waitHead == thred) { + cv->waitHead = thred->md.next; + if (cv->waitHead == NULL) { + cv->waitTail = NULL; + } else { + cv->waitHead->md.prev = NULL; + } + } else { + PR_ASSERT(thred->md.prev != NULL); + thred->md.prev->md.next = thred->md.next; + if (thred->md.next != NULL) { + thred->md.next->md.prev = thred->md.prev; + } else { + PR_ASSERT(cv->waitTail == thred); + cv->waitTail = thred->md.prev; + } + } + thred->md.next = thred->md.prev = NULL; + } else { + /* + * This thread must have been notified, but the + * SemRelease call happens after SemRequest + * times out. Wait on the semaphore again to make it + * non-signaled. We assume this wait won't take long. + */ + rv = DosWaitEventSem(thred->md.blocked_sema, SEM_INDEFINITE_WAIT); + if (rv == NO_ERROR) { + DosResetEventSem(thred->md.blocked_sema, &count); + } + PR_ASSERT(rv == NO_ERROR); + } } PR_ASSERT(thred->md.inCVWaitQueue == PR_FALSE); return; diff --git a/nsprpub/pr/src/md/os2/os2gc.c b/nsprpub/pr/src/md/os2/os2gc.c index 2bcbf7852..79b6de573 100644 --- a/nsprpub/pr/src/md/os2/os2gc.c +++ b/nsprpub/pr/src/md/os2/os2gc.c @@ -9,7 +9,7 @@ */ #include "primpl.h" -PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np) +PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np) { CONTEXTRECORD context; context.ContextFlags = CONTEXT_INTEGER; @@ -34,7 +34,7 @@ PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np) } /* This function is not used right now, but is left as a reference. - * If you ever need to get the fiberID from the currently running fiber, + * If you ever need to get the fiberID from the currently running fiber, * this is it. */ void * @@ -43,8 +43,8 @@ GetMyFiberID() void *fiberData = 0; /* A pointer to our tib entry is found at FS:[18] - * At offset 10h is the fiberData pointer. The context of the - * fiber is stored in there. + * At offset 10h is the fiberData pointer. The context of the + * fiber is stored in there. */ #ifdef HAVE_ASM __asm { @@ -53,6 +53,6 @@ GetMyFiberID() mov [fiberData], EAX } #endif - + return fiberData; } diff --git a/nsprpub/pr/src/md/os2/os2inrval.c b/nsprpub/pr/src/md/os2/os2inrval.c index aff99e2ec..bd283f06d 100644 --- a/nsprpub/pr/src/md/os2/os2inrval.c +++ b/nsprpub/pr/src/md/os2/os2inrval.c @@ -14,7 +14,7 @@ static PRBool useHighResTimer = PR_FALSE; PRIntervalTime _os2_ticksPerSec = -1; PRIntn _os2_bitShift = 0; PRInt32 _os2_highMask = 0; - + void _PR_MD_INTERVAL_INIT() { @@ -23,8 +23,9 @@ _PR_MD_INTERVAL_INIT() APIRET rc; if ((envp = getenv("NSPR_OS2_NO_HIRES_TIMER")) != NULL) { - if (atoi(envp) == 1) - return; + if (atoi(envp) == 1) { + return; + } } timerFreq = 0; /* OS/2 high-resolution timer frequency in Hz */ @@ -59,8 +60,8 @@ _PR_MD_GET_INTERVAL() */ top = timestamp.ulHi & _os2_highMask; top = top << (32 - _os2_bitShift); - timestamp.ulLo = timestamp.ulLo >> _os2_bitShift; - timestamp.ulLo = timestamp.ulLo + top; + timestamp.ulLo = timestamp.ulLo >> _os2_bitShift; + timestamp.ulLo = timestamp.ulLo + top; return (PRUint32)timestamp.ulLo; } else { ULONG msCount = -1; diff --git a/nsprpub/pr/src/md/os2/os2io.c b/nsprpub/pr/src/md/os2/os2io.c index 3c81ae346..639a0d388 100644 --- a/nsprpub/pr/src/md/os2/os2io.c +++ b/nsprpub/pr/src/md/os2/os2io.c @@ -23,16 +23,16 @@ struct _MDLock _pr_ioq_lock; static PRBool isWSEB = PR_FALSE; /* whether we are using an OS/2 kernel that supports large files */ typedef APIRET (*DosOpenLType)(PSZ pszFileName, PHFILE pHf, PULONG pulAction, - LONGLONG cbFile, ULONG ulAttribute, - ULONG fsOpenFlags, ULONG fsOpenMode, - PEAOP2 peaop2); + LONGLONG cbFile, ULONG ulAttribute, + ULONG fsOpenFlags, ULONG fsOpenMode, + PEAOP2 peaop2); typedef APIRET (*DosSetFileLocksLType)(HFILE hFile, PFILELOCKL pflUnlock, - PFILELOCKL pflLock, ULONG timeout, - ULONG flags); + PFILELOCKL pflLock, ULONG timeout, + ULONG flags); typedef APIRET (*DosSetFilePtrLType)(HFILE hFile, LONGLONG ib, ULONG method, - PLONGLONG ibActual); + PLONGLONG ibActual); DosOpenLType myDosOpenL; DosSetFileLocksLType myDosSetFileLocksL; @@ -45,7 +45,7 @@ _PR_MD_INIT_IO() HMODULE module; sock_init(); - + rc = DosLoadModule(NULL, 0, "DOSCALL1", &module); if (rc != NO_ERROR) { @@ -76,10 +76,10 @@ _PR_MD_WAIT(PRThread *thread, PRIntervalTime ticks) ULONG count; PRUint32 msecs = (ticks == PR_INTERVAL_NO_TIMEOUT) ? - SEM_INDEFINITE_WAIT : PR_IntervalToMilliseconds(ticks); + SEM_INDEFINITE_WAIT : PR_IntervalToMilliseconds(ticks); rv = DosWaitEventSem(thread->md.blocked_sema, msecs); - DosResetEventSem(thread->md.blocked_sema, &count); - switch(rv) + DosResetEventSem(thread->md.blocked_sema, &count); + switch(rv) { case NO_ERROR: return PR_SUCCESS; @@ -87,7 +87,7 @@ _PR_MD_WAIT(PRThread *thread, PRIntervalTime ticks) case ERROR_TIMEOUT: _PR_THREAD_LOCK(thread); if (thread->state == _PR_IO_WAIT) { - ; + ; } else { if (thread->wait.cvar != NULL) { thread->wait.cvar = NULL; @@ -99,7 +99,7 @@ _PR_MD_WAIT(PRThread *thread, PRIntervalTime ticks) */ _PR_THREAD_UNLOCK(thread); rv = DosWaitEventSem(thread->md.blocked_sema, 0); - DosResetEventSem(thread->md.blocked_sema, &count); + DosResetEventSem(thread->md.blocked_sema, &count); PR_ASSERT(rv == NO_ERROR); } } @@ -113,13 +113,15 @@ _PR_MD_WAIT(PRThread *thread, PRIntervalTime ticks) PRStatus _PR_MD_WAKEUP_WAITER(PRThread *thread) { - if ( _PR_IS_NATIVE_THREAD(thread) ) + if ( _PR_IS_NATIVE_THREAD(thread) ) { - if (DosPostEventSem(thread->md.blocked_sema) != NO_ERROR) + if (DosPostEventSem(thread->md.blocked_sema) != NO_ERROR) { return PR_FAILURE; - else - return PR_SUCCESS; - } + } + else { + return PR_SUCCESS; + } + } } @@ -132,7 +134,7 @@ _PR_MD_WAKEUP_WAITER(PRThread *thread) * The NSPR open flags (osflags) are translated into flags for OS/2 * * Mode seems to be passed in as a unix style file permissions argument - * as in 0666, in the case of opening the logFile. + * as in 0666, in the case of opening the logFile. * */ PRInt32 @@ -149,7 +151,7 @@ _PR_MD_OPEN(const char *name, PRIntn osflags, int mode) * All the pointer arguments (&file, &actionTaken and name) have to be in * low memory for DosOpen to use them. * The following moves name to low memory. - */ + */ if ((ULONG)name >= 0x20000000) { size_t len = strlen(name) + 1; @@ -159,14 +161,19 @@ _PR_MD_OPEN(const char *name, PRIntn osflags, int mode) } #endif - if (osflags & PR_SYNC) access |= OPEN_FLAGS_WRITE_THROUGH; + if (osflags & PR_SYNC) { + access |= OPEN_FLAGS_WRITE_THROUGH; + } - if (osflags & PR_RDONLY) + if (osflags & PR_RDONLY) { access |= OPEN_ACCESS_READONLY; - else if (osflags & PR_WRONLY) + } + else if (osflags & PR_WRONLY) { access |= OPEN_ACCESS_WRITEONLY; - else if(osflags & PR_RDWR) + } + else if(osflags & PR_RDWR) { access |= OPEN_ACCESS_READWRITE; + } if ( osflags & PR_CREATE_FILE && osflags & PR_EXCL ) { @@ -174,41 +181,45 @@ _PR_MD_OPEN(const char *name, PRIntn osflags, int mode) } else if (osflags & PR_CREATE_FILE) { - if (osflags & PR_TRUNCATE) + if (osflags & PR_TRUNCATE) { flags = OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS; - else + } + else { flags = OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS; - } + } + } else { - if (osflags & PR_TRUNCATE) + if (osflags & PR_TRUNCATE) { flags = OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS; - else + } + else { flags = OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS; + } } do { if (isWSEB) { - rc = myDosOpenL((char*)name, - &file, /* file handle if successful */ - &actionTaken, /* reason for failure */ - 0, /* initial size of new file */ - FILE_NORMAL, /* file system attributes */ - flags, /* Open flags */ - access, /* Open mode and rights */ - 0); /* OS/2 Extended Attributes */ + rc = myDosOpenL((char*)name, + &file, /* file handle if successful */ + &actionTaken, /* reason for failure */ + 0, /* initial size of new file */ + FILE_NORMAL, /* file system attributes */ + flags, /* Open flags */ + access, /* Open mode and rights */ + 0); /* OS/2 Extended Attributes */ } else { - rc = DosOpen((char*)name, - &file, /* file handle if successful */ - &actionTaken, /* reason for failure */ - 0, /* initial size of new file */ - FILE_NORMAL, /* file system attributes */ - flags, /* Open flags */ - access, /* Open mode and rights */ - 0); /* OS/2 Extended Attributes */ + rc = DosOpen((char*)name, + &file, /* file handle if successful */ + &actionTaken, /* reason for failure */ + 0, /* initial size of new file */ + FILE_NORMAL, /* file system attributes */ + flags, /* Open flags */ + access, /* Open mode and rights */ + 0); /* OS/2 Extended Attributes */ }; if (rc == ERROR_TOO_MANY_OPEN_FILES) { ULONG CurMaxFH = 0; @@ -223,7 +234,7 @@ _PR_MD_OPEN(const char *name, PRIntn osflags, int mode) if (rc != NO_ERROR) { _PR_MD_MAP_OPEN_ERROR(rc); - return -1; + return -1; } return (PRInt32)file; @@ -239,17 +250,18 @@ _PR_MD_READ(PRFileDesc *fd, void *buf, PRInt32 len) (PVOID)buf, len, &bytes); - - if (rv != NO_ERROR) + + if (rv != NO_ERROR) { /* ERROR_HANDLE_EOF can only be returned by async io */ PR_ASSERT(rv != ERROR_HANDLE_EOF); - if (rv == ERROR_BROKEN_PIPE) + if (rv == ERROR_BROKEN_PIPE) { return 0; - else { - _PR_MD_MAP_READ_ERROR(rv); - return -1; - } + } + else { + _PR_MD_MAP_READ_ERROR(rv); + return -1; + } } return (PRInt32)bytes; } @@ -258,14 +270,14 @@ PRInt32 _PR_MD_WRITE(PRFileDesc *fd, const void *buf, PRInt32 len) { PRInt32 bytes; - int rv; + int rv; rv = DosWrite((HFILE)fd->secret->md.osfd, (PVOID)buf, len, (PULONG)&bytes); - if (rv != NO_ERROR) + if (rv != NO_ERROR) { _PR_MD_MAP_WRITE_ERROR(rv); return -1; @@ -288,11 +300,12 @@ _PR_MD_LSEEK(PRFileDesc *fd, PRInt32 offset, PRSeekWhence whence) rv = DosSetFilePtr((HFILE)fd->secret->md.osfd, offset, whence, &newLocation); - if (rv != NO_ERROR) { - _PR_MD_MAP_LSEEK_ERROR(rv); - return -1; - } else - return newLocation; + if (rv != NO_ERROR) { + _PR_MD_MAP_LSEEK_ERROR(rv); + return -1; + } else { + return newLocation; + } } PRInt64 @@ -306,14 +319,14 @@ _PR_MD_LSEEK64(PRFileDesc *fd, PRInt64 offset, PRSeekWhence whence) rv = DosSetFilePtr((HFILE)fd->secret->md.osfd, low, whence, &newLocation); rv = DosSetFilePtr((HFILE)fd->secret->md.osfd, hi, FILE_CURRENT, &newLocation); - if (rv != NO_ERROR) { - _PR_MD_MAP_LSEEK_ERROR(rv); - hi = newLocation = -1; - } + if (rv != NO_ERROR) { + _PR_MD_MAP_LSEEK_ERROR(rv); + hi = newLocation = -1; + } result.lo = newLocation; result.hi = hi; - return result; + return result; #else PRInt32 where, rc, lo = (PRInt32)offset, hi = (PRInt32)(offset >> 32); @@ -322,19 +335,19 @@ _PR_MD_LSEEK64(PRFileDesc *fd, PRInt64 offset, PRSeekWhence whence) PRUint64 newLocationL; switch (whence) - { - case PR_SEEK_SET: - where = FILE_BEGIN; - break; - case PR_SEEK_CUR: - where = FILE_CURRENT; - break; - case PR_SEEK_END: - where = FILE_END; - break; - default: - PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); - return -1; + { + case PR_SEEK_SET: + where = FILE_BEGIN; + break; + case PR_SEEK_CUR: + where = FILE_CURRENT; + break; + case PR_SEEK_END: + where = FILE_END; + break; + default: + PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); + return -1; } if (isWSEB) { @@ -344,12 +357,12 @@ _PR_MD_LSEEK64(PRFileDesc *fd, PRInt64 offset, PRSeekWhence whence) { rc = DosSetFilePtr((HFILE)fd->secret->md.osfd, lo, where, (PULONG)&newLocation); } - + if (rc != NO_ERROR) { - _PR_MD_MAP_LSEEK_ERROR(rc); - return -1; + _PR_MD_MAP_LSEEK_ERROR(rc); + return -1; } - + if (isWSEB) { return newLocationL; @@ -373,10 +386,10 @@ _PR_MD_FSYNC(PRFileDesc *fd) PRInt32 rc = DosResetBuffer((HFILE)fd->secret->md.osfd); if (rc != NO_ERROR) { - if (rc != ERROR_ACCESS_DENIED) { - _PR_MD_MAP_FSYNC_ERROR(rc); - return -1; - } + if (rc != ERROR_ACCESS_DENIED) { + _PR_MD_MAP_FSYNC_ERROR(rc); + return -1; + } } return 0; } @@ -385,10 +398,11 @@ PRInt32 _MD_CloseFile(PRInt32 osfd) { PRInt32 rv; - + rv = DosClose((HFILE)osfd); - if (rv != NO_ERROR) - _PR_MD_MAP_CLOSE_ERROR(rv); + if (rv != NO_ERROR) { + _PR_MD_MAP_CLOSE_ERROR(rv); + } return rv; } @@ -400,10 +414,10 @@ _MD_CloseFile(PRInt32 osfd) void FlipSlashes(char *cp, int len) { while (--len >= 0) { - if (cp[0] == '/') { - cp[0] = PR_DIRECTORY_SEPARATOR; - } - cp++; + if (cp[0] == '/') { + cp[0] = PR_DIRECTORY_SEPARATOR; + } + cp++; } } @@ -417,17 +431,17 @@ void FlipSlashes(char *cp, int len) PRInt32 _PR_MD_CLOSE_DIR(_MDDir *d) { - PRInt32 rc; + PRInt32 rc; if ( d ) { - rc = DosFindClose(d->d_hdl); - if(rc == NO_ERROR){ - d->magic = (PRUint32)-1; - return PR_SUCCESS; - } else { - _PR_MD_MAP_CLOSEDIR_ERROR(rc); - return PR_FAILURE; - } + rc = DosFindClose(d->d_hdl); + if(rc == NO_ERROR) { + d->magic = (PRUint32)-1; + return PR_SUCCESS; + } else { + _PR_MD_MAP_CLOSEDIR_ERROR(rc); + return PR_FAILURE; + } } PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); return PR_FAILURE; @@ -469,7 +483,7 @@ _PR_MD_OPEN_DIR(_MDDir *d, const char *name) FIL_STANDARD); } if ( rc != NO_ERROR ) { - _PR_MD_MAP_OPENDIR_ERROR(rc); + _PR_MD_MAP_OPENDIR_ERROR(rc); return PR_FAILURE; } d->firstEntry = PR_TRUE; @@ -486,42 +500,46 @@ _PR_MD_READ_DIR(_MDDir *d, PRIntn flags) USHORT fileAttr; if ( d ) { - while (1) { - if (d->firstEntry) { - d->firstEntry = PR_FALSE; - rv = NO_ERROR; - } else { - rv = DosFindNext(d->d_hdl, - &(d->d_entry), - sizeof(d->d_entry), - &numFiles); - } - if (rv != NO_ERROR) { - break; - } - fileName = GetFileFromDIR(d); - fileAttr = GetFileAttr(d); - if ( (flags & PR_SKIP_DOT) && - (fileName[0] == '.') && (fileName[1] == '\0')) + while (1) { + if (d->firstEntry) { + d->firstEntry = PR_FALSE; + rv = NO_ERROR; + } else { + rv = DosFindNext(d->d_hdl, + &(d->d_entry), + sizeof(d->d_entry), + &numFiles); + } + if (rv != NO_ERROR) { + break; + } + fileName = GetFileFromDIR(d); + fileAttr = GetFileAttr(d); + if ( (flags & PR_SKIP_DOT) && + (fileName[0] == '.') && (fileName[1] == '\0')) { continue; - if ( (flags & PR_SKIP_DOT_DOT) && - (fileName[0] == '.') && (fileName[1] == '.') && - (fileName[2] == '\0')) + } + if ( (flags & PR_SKIP_DOT_DOT) && + (fileName[0] == '.') && (fileName[1] == '.') && + (fileName[2] == '\0')) { continue; - /* - * XXX - * Is this the correct definition of a hidden file on OS/2? - */ - if ((flags & PR_SKIP_NONE) && (fileAttr & FILE_HIDDEN)) + } + /* + * XXX + * Is this the correct definition of a hidden file on OS/2? + */ + if ((flags & PR_SKIP_NONE) && (fileAttr & FILE_HIDDEN)) { return fileName; - else if ((flags & PR_SKIP_HIDDEN) && (fileAttr & FILE_HIDDEN)) + } + else if ((flags & PR_SKIP_HIDDEN) && (fileAttr & FILE_HIDDEN)) { continue; - return fileName; + } + return fileName; } PR_ASSERT(NO_ERROR != rv); - _PR_MD_MAP_READDIR_ERROR(rv); + _PR_MD_MAP_READDIR_ERROR(rv); return NULL; - } + } PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); return NULL; } @@ -533,7 +551,7 @@ _PR_MD_DELETE(const char *name) if(rc == NO_ERROR) { return 0; } else { - _PR_MD_MAP_DELETE_ERROR(rc); + _PR_MD_MAP_DELETE_ERROR(rc); return -1; } } @@ -558,7 +576,7 @@ _PR_MD_STAT(const char *fn, struct stat *info) * can be handled by _stat() on NT but not on Win95. * * We remove the backslash or slash at the end and - * try again. + * try again. * * Not sure if this happens on OS/2 or not, * but it doesn't hurt to be careful. @@ -566,7 +584,7 @@ _PR_MD_STAT(const char *fn, struct stat *info) int len = strlen(fn); if (len > 0 && len <= _MAX_PATH - && (fn[len - 1] == '\\' || fn[len - 1] == '/')) { + && (fn[len - 1] == '\\' || fn[len - 1] == '/')) { char newfn[_MAX_PATH + 1]; strcpy(newfn, fn); @@ -587,15 +605,18 @@ _PR_MD_GETFILEINFO(const char *fn, PRFileInfo *info) struct stat sb; PRInt32 rv; PRInt64 s, s2us; - + if ( (rv = _PR_MD_STAT(fn, &sb)) == 0 ) { if (info) { - if (S_IFREG & sb.st_mode) + if (S_IFREG & sb.st_mode) { info->type = PR_FILE_FILE ; - else if (S_IFDIR & sb.st_mode) + } + else if (S_IFDIR & sb.st_mode) { info->type = PR_FILE_DIRECTORY; - else + } + else { info->type = PR_FILE_OTHER; + } info->size = sb.st_size; LL_I2L(s2us, PR_USEC_PER_SEC); LL_I2L(s, sb.st_mtime); @@ -622,7 +643,7 @@ _PR_MD_GETFILEINFO64(const char *fn, PRFileInfo64 *info) LL_UI2L(info->size,info32.size); info->modifyTime = info32.modifyTime; info->creationTime = info32.creationTime; - + if (isWSEB) { APIRET rc ; @@ -648,33 +669,35 @@ _PR_MD_GETFILEINFO64(const char *fn, PRFileInfo64 *info) PRInt32 _PR_MD_GETOPENFILEINFO(const PRFileDesc *fd, PRFileInfo *info) { - /* For once, the VAC compiler/library did a nice thing. - * The file handle used by the C runtime is the same one - * returned by the OS when you call DosOpen(). This means - * that you can take an OS HFILE and use it with C file - * functions. The only caveat is that you have to call - * _setmode() first to initialize some junk. This is - * immensely useful because I did not have a clue how to - * implement this function otherwise. The windows folks - * took the source from the Microsoft C library source, but - * IBM wasn't kind enough to ship the source with VAC. - * On second thought, the needed function could probably - * be gotten from the OS/2 GNU library source, but the - * point is now moot. - */ - struct stat hinfo; + /* For once, the VAC compiler/library did a nice thing. + * The file handle used by the C runtime is the same one + * returned by the OS when you call DosOpen(). This means + * that you can take an OS HFILE and use it with C file + * functions. The only caveat is that you have to call + * _setmode() first to initialize some junk. This is + * immensely useful because I did not have a clue how to + * implement this function otherwise. The windows folks + * took the source from the Microsoft C library source, but + * IBM wasn't kind enough to ship the source with VAC. + * On second thought, the needed function could probably + * be gotten from the OS/2 GNU library source, but the + * point is now moot. + */ + struct stat hinfo; PRInt64 s, s2us; _setmode(fd->secret->md.osfd, O_BINARY); if(fstat((int)fd->secret->md.osfd, &hinfo) != NO_ERROR) { - _PR_MD_MAP_FSTAT_ERROR(errno); + _PR_MD_MAP_FSTAT_ERROR(errno); return -1; - } + } - if (hinfo.st_mode & S_IFDIR) + if (hinfo.st_mode & S_IFDIR) { info->type = PR_FILE_DIRECTORY; - else + } + else { info->type = PR_FILE_FILE; + } info->size = hinfo.st_size; LL_I2L(s2us, PR_USEC_PER_SEC); @@ -695,13 +718,13 @@ _PR_MD_GETOPENFILEINFO64(const PRFileDesc *fd, PRFileInfo64 *info) PRInt32 rv = _PR_MD_GETOPENFILEINFO(fd, &info32); if (0 == rv) { - info->type = info32.type; - LL_UI2L(info->size,info32.size); - - info->modifyTime = info32.modifyTime; - info->creationTime = info32.creationTime; + info->type = info32.type; + LL_UI2L(info->size,info32.size); + + info->modifyTime = info32.modifyTime; + info->creationTime = info32.creationTime; } - + if (isWSEB) { APIRET rc ; @@ -728,12 +751,12 @@ _PR_MD_GETOPENFILEINFO64(const PRFileDesc *fd, PRFileInfo64 *info) PRInt32 _PR_MD_RENAME(const char *from, const char *to) { - PRInt32 rc; + PRInt32 rc; /* Does this work with dot-relative pathnames? */ if ( (rc = DosMove((char *)from, (char *)to)) == NO_ERROR) { return 0; } else { - _PR_MD_MAP_RENAME_ERROR(rc); + _PR_MD_MAP_RENAME_ERROR(rc); return -1; } } @@ -741,35 +764,36 @@ _PR_MD_RENAME(const char *from, const char *to) PRInt32 _PR_MD_ACCESS(const char *name, PRAccessHow how) { - PRInt32 rv; + PRInt32 rv; switch (how) { - case PR_ACCESS_WRITE_OK: - rv = access(name, 02); - break; - case PR_ACCESS_READ_OK: - rv = access(name, 04); - break; - case PR_ACCESS_EXISTS: - return access(name, 00); - break; - default: - PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); - return -1; - } - if (rv < 0) - _PR_MD_MAP_ACCESS_ERROR(errno); + case PR_ACCESS_WRITE_OK: + rv = access(name, 02); + break; + case PR_ACCESS_READ_OK: + rv = access(name, 04); + break; + case PR_ACCESS_EXISTS: + return access(name, 00); + break; + default: + PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); + return -1; + } + if (rv < 0) { + _PR_MD_MAP_ACCESS_ERROR(errno); + } return rv; } PRInt32 _PR_MD_MKDIR(const char *name, PRIntn mode) { - PRInt32 rc; + PRInt32 rc; /* XXXMB - how to translate the "mode"??? */ if ((rc = DosCreateDir((char *)name, NULL))== NO_ERROR) { return 0; } else { - _PR_MD_MAP_MKDIR_ERROR(rc); + _PR_MD_MAP_MKDIR_ERROR(rc); return -1; } } @@ -777,11 +801,11 @@ _PR_MD_MKDIR(const char *name, PRIntn mode) PRInt32 _PR_MD_RMDIR(const char *name) { - PRInt32 rc; + PRInt32 rc; if ( (rc = DosDeleteDir((char *)name)) == NO_ERROR) { return 0; } else { - _PR_MD_MAP_RMDIR_ERROR(rc); + _PR_MD_MAP_RMDIR_ERROR(rc); return -1; } } @@ -792,7 +816,7 @@ _PR_MD_LOCKFILE(PRInt32 f) PRInt32 rv; FILELOCK lock, unlock; FILELOCKL lockL, unlockL; - + lock.lOffset = 0; lockL.lOffset = 0; lock.lRange = 0xffffffff; @@ -811,20 +835,20 @@ _PR_MD_LOCKFILE(PRInt32 f) { if (isWSEB) { - rv = myDosSetFileLocksL( (HFILE) f, - &unlockL, &lockL, - 0, 0); + rv = myDosSetFileLocksL( (HFILE) f, + &unlockL, &lockL, + 0, 0); } else { - rv = DosSetFileLocks( (HFILE) f, - &unlock, &lock, - 0, 0); + rv = DosSetFileLocks( (HFILE) f, + &unlock, &lock, + 0, 0); } - if ( rv != NO_ERROR ) + if ( rv != NO_ERROR ) { DosSleep( 50 ); /* Sleep() a few milisecs and try again. */ - } + } } /* end for() */ return PR_SUCCESS; } /* end _PR_MD_LOCKFILE() */ @@ -842,7 +866,7 @@ _PR_MD_UNLOCKFILE(PRInt32 f) PRInt32 rv; FILELOCK lock, unlock; FILELOCKL lockL, unlockL; - + lock.lOffset = 0; lockL.lOffset = 0; lock.lRange = 0; @@ -851,20 +875,20 @@ _PR_MD_UNLOCKFILE(PRInt32 f) unlockL.lOffset = 0; unlock.lRange = 0xffffffff; unlockL.lRange = 0xffffffffffffffff; - + if (isWSEB) { rv = myDosSetFileLocksL( (HFILE) f, - &unlockL, &lockL, - 0, 0); + &unlockL, &lockL, + 0, 0); } else { rv = DosSetFileLocks( (HFILE) f, - &unlock, &lock, - 0, 0); + &unlock, &lock, + 0, 0); } - + if ( rv != NO_ERROR ) { return PR_SUCCESS; @@ -890,10 +914,12 @@ _PR_MD_SET_FD_INHERITABLE(PRFileDesc *fd, PRBool inheritable) return PR_FAILURE; } - if (inheritable) - flags &= ~OPEN_FLAGS_NOINHERIT; - else - flags |= OPEN_FLAGS_NOINHERIT; + if (inheritable) { + flags &= ~OPEN_FLAGS_NOINHERIT; + } + else { + flags |= OPEN_FLAGS_NOINHERIT; + } /* Mask off flags DosSetFHState don't want. */ flags &= (OPEN_FLAGS_WRITE_THROUGH | OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NO_CACHE | OPEN_FLAGS_NOINHERIT); diff --git a/nsprpub/pr/src/md/os2/os2misc.c b/nsprpub/pr/src/md/os2/os2misc.c index f0e3ceeaf..240f0905c 100644 --- a/nsprpub/pr/src/md/os2/os2misc.c +++ b/nsprpub/pr/src/md/os2/os2misc.c @@ -73,7 +73,7 @@ PR_Now(void) LL_MUL(ms, ms, ms2us); LL_MUL(s, s, s2us); LL_ADD(s, s, ms); - return s; + return s; } @@ -120,7 +120,7 @@ static int assembleCmdLine(char *const *argv, char **cmdLine) strcat(*cmdLine, " "); } strcat(*cmdLine, *arg); - } + } return 0; } @@ -150,15 +150,16 @@ static int assembleEnvBlock(char **envp, char **envBlock) return 0; } - if(DosGetInfoBlocks(&ptib, &ppib) != NO_ERROR) - return -1; + if(DosGetInfoBlocks(&ptib, &ppib) != NO_ERROR) { + return -1; + } curEnv = ppib->pib_pchenv; cwdStart = curEnv; while (*cwdStart) { if (cwdStart[0] == '=' && cwdStart[1] != '\0' - && cwdStart[2] == ':' && cwdStart[3] == '=') { + && cwdStart[2] == ':' && cwdStart[3] == '=') { break; } cwdStart += strlen(cwdStart) + 1; @@ -168,7 +169,7 @@ static int assembleEnvBlock(char **envp, char **envBlock) cwdEnd += strlen(cwdEnd) + 1; while (*cwdEnd) { if (cwdEnd[0] != '=' || cwdEnd[1] == '\0' - || cwdEnd[2] != ':' || cwdEnd[3] != '=') { + || cwdEnd[2] != ':' || cwdEnd[3] != '=') { break; } cwdEnd += strlen(cwdEnd) + 1; @@ -221,7 +222,7 @@ PRProcess * _PR_CreateOS2Process( char *cmdLine = NULL; char **newEnvp = NULL; char *envBlock = NULL; - + STARTDATA startData = {0}; APIRET rc; ULONG ulAppType = 0; @@ -250,7 +251,7 @@ PRProcess * _PR_CreateOS2Process( PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); goto errorExit; } - + if (assembleCmdLine(argv, &cmdLine) == -1) { PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); goto errorExit; @@ -260,7 +261,7 @@ PRProcess * _PR_CreateOS2Process( /* * DosQueryAppType() fails if path (the char* in the first argument) is in * high memory. If that is the case, the following moves it to low memory. - */ + */ if ((ULONG)path >= 0x20000000) { size_t len = strlen(path) + 1; char *copy = (char *)alloca(len); @@ -268,7 +269,7 @@ PRProcess * _PR_CreateOS2Process( path = copy; } #endif - + if (envp == NULL) { newEnvp = NULL; } else { @@ -287,27 +288,27 @@ PRProcess * _PR_CreateOS2Process( PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); goto errorExit; } - + rc = DosQueryAppType(path, &ulAppType); if (rc != NO_ERROR) { - char *pszDot = strrchr(path, '.'); - if (pszDot) { - /* If it is a CMD file, launch the users command processor */ - if (!stricmp(pszDot, ".cmd")) { - rc = DosScanEnv("COMSPEC", (PSZ *)&pszComSpec); - if (!rc) { - strcpy(pszFormatString, "/C %s %s"); - strcpy(pszEXEName, pszComSpec); - ulAppType = FAPPTYP_WINDOWCOMPAT; - } - } - } + char *pszDot = strrchr(path, '.'); + if (pszDot) { + /* If it is a CMD file, launch the users command processor */ + if (!stricmp(pszDot, ".cmd")) { + rc = DosScanEnv("COMSPEC", (PSZ *)&pszComSpec); + if (!rc) { + strcpy(pszFormatString, "/C %s %s"); + strcpy(pszEXEName, pszComSpec); + ulAppType = FAPPTYP_WINDOWCOMPAT; + } + } + } } if (ulAppType == 0) { - PR_SetError(PR_UNKNOWN_ERROR, 0); - goto errorExit; + PR_SetError(PR_UNKNOWN_ERROR, 0); + goto errorExit; } - + if ((ulAppType & FAPPTYP_WINDOWAPI) == FAPPTYP_WINDOWAPI) { startData.SessionType = SSF_TYPE_PM; } @@ -317,16 +318,16 @@ PRProcess * _PR_CreateOS2Process( else { startData.SessionType = SSF_TYPE_DEFAULT; } - + if (ulAppType & (FAPPTYP_WINDOWSPROT31 | FAPPTYP_WINDOWSPROT | FAPPTYP_WINDOWSREAL)) { strcpy(pszEXEName, "WINOS2.COM"); startData.SessionType = PROG_31_STDSEAMLESSVDM; strcpy(pszFormatString, "/3 %s %s"); } - + startData.InheritOpt = SSF_INHERTOPT_SHELL; - + if (pszEXEName[0]) { pszFormatResult = PR_MALLOC(strlen(pszFormatString)+strlen(path)+strlen(cmdLine)); sprintf(pszFormatResult, pszFormatString, path, cmdLine); @@ -336,13 +337,13 @@ PRProcess * _PR_CreateOS2Process( startData.PgmInputs = cmdLine; } startData.PgmName = pszEXEName; - + startData.Length = sizeof(startData); startData.Related = SSF_RELATED_INDEPENDENT; startData.ObjectBuffer = pszObjectBuffer; startData.ObjectBuffLen = CCHMAXPATH; startData.Environment = envBlock; - + if (attr) { /* On OS/2, there is really no way to pass file handles for stdin, * stdout, and stderr to a new process. Instead, we can make it @@ -407,7 +408,7 @@ PRProcess * _PR_CreateOS2Process( } proc->md.pid = procInfo.codeTerminate; - } else { + } else { /* * If no STDIN/STDOUT redirection is not needed, use DosStartSession * to create a new, independent session @@ -418,7 +419,7 @@ PRProcess * _PR_CreateOS2Process( PR_SetError(PR_UNKNOWN_ERROR, rc); goto errorExit; } - + proc->md.pid = pid; } @@ -453,7 +454,7 @@ errorExit: PRStatus _PR_DetachOS2Process(PRProcess *process) { - /* On OS/2, a process is either created as a child or not. + /* On OS/2, a process is either created as a child or not. * You can't 'detach' it later on. */ PR_DELETE(process); @@ -464,18 +465,18 @@ PRStatus _PR_DetachOS2Process(PRProcess *process) * XXX: This will currently only work on a child process. */ PRStatus _PR_WaitOS2Process(PRProcess *process, - PRInt32 *exitCode) + PRInt32 *exitCode) { ULONG ulRetVal; RESULTCODES results; PID pidEnded = 0; - ulRetVal = DosWaitChild(DCWA_PROCESS, DCWW_WAIT, + ulRetVal = DosWaitChild(DCWA_PROCESS, DCWW_WAIT, &results, &pidEnded, process->md.pid); if (ulRetVal != NO_ERROR) { - printf("\nDosWaitChild rc = %lu\n", ulRetVal); + printf("\nDosWaitChild rc = %lu\n", ulRetVal); PR_SetError(PR_UNKNOWN_ERROR, ulRetVal); return PR_FAILURE; } @@ -485,9 +486,9 @@ PRStatus _PR_WaitOS2Process(PRProcess *process, PRStatus _PR_KillOS2Process(PRProcess *process) { - ULONG ulRetVal; + ULONG ulRetVal; if ((ulRetVal = DosKillProcess(DKP_PROCESS, process->md.pid)) == NO_ERROR) { - return PR_SUCCESS; + return PR_SUCCESS; } PR_SetError(PR_UNKNOWN_ERROR, ulRetVal); return PR_FAILURE; @@ -501,7 +502,7 @@ PRStatus _MD_OS2GetHostName(char *name, PRUint32 namelen) if (0 == rv) { return PR_SUCCESS; } - _PR_MD_MAP_GETHOSTNAME_ERROR(sock_errno()); + _PR_MD_MAP_GETHOSTNAME_ERROR(sock_errno()); return PR_FAILURE; } @@ -509,7 +510,7 @@ void _PR_MD_WAKEUP_CPUS( void ) { return; -} +} /* ********************************************************************** diff --git a/nsprpub/pr/src/md/os2/os2poll.c b/nsprpub/pr/src/md/os2/os2poll.c index 9a0a00956..47d971045 100644 --- a/nsprpub/pr/src/md/os2/os2poll.c +++ b/nsprpub/pr/src/md/os2/os2poll.c @@ -16,16 +16,17 @@ PRBool IsSocketSet( PRInt32 osfd, int* socks, int start, int count ) { - int i; - PRBool isSet = PR_FALSE; + int i; + PRBool isSet = PR_FALSE; - for( i = start; i < start+count; i++ ) - { - if( socks[i] == osfd ) - isSet = PR_TRUE; - } - - return isSet; + for( i = start; i < start+count; i++ ) + { + if( socks[i] == osfd ) { + isSet = PR_TRUE; + } + } + + return isSet; } #endif @@ -55,7 +56,7 @@ PRInt32 _PR_MD_PR_POLL(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout) wt = 0; ex = 0; socks = (int) PR_MALLOC( npds * 3 * sizeof(int) ); - + if (!socks) { PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); @@ -74,12 +75,12 @@ PRInt32 _PR_MD_PR_POLL(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout) if (pd->in_flags & PR_POLL_READ) { in_flags_read = (pd->fd->methods->poll)( - pd->fd, pd->in_flags & ~PR_POLL_WRITE, &out_flags_read); + pd->fd, pd->in_flags & ~PR_POLL_WRITE, &out_flags_read); } if (pd->in_flags & PR_POLL_WRITE) { in_flags_write = (pd->fd->methods->poll)( - pd->fd, pd->in_flags & ~PR_POLL_READ, &out_flags_write); + pd->fd, pd->in_flags & ~PR_POLL_READ, &out_flags_write); } if ((0 != (in_flags_read & out_flags_read)) || (0 != (in_flags_write & out_flags_write))) @@ -115,8 +116,9 @@ PRInt32 _PR_MD_PR_POLL(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout) if (0 == ready) { PRInt32 osfd = bottom->secret->md.osfd; - if (osfd > maxfd) + if (osfd > maxfd) { maxfd = osfd; + } if (in_flags_read & PR_POLL_READ) { pd->out_flags |= _PR_POLL_READ_SYS_READ; @@ -124,7 +126,7 @@ PRInt32 _PR_MD_PR_POLL(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout) FD_SET(osfd, &rd); #else socks[rd] = osfd; - rd++; + rd++; #endif } if (in_flags_read & PR_POLL_WRITE) @@ -134,7 +136,7 @@ PRInt32 _PR_MD_PR_POLL(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout) FD_SET(osfd, &wt); #else socks[npds+wt] = osfd; - wt++; + wt++; #endif } if (in_flags_write & PR_POLL_READ) @@ -144,7 +146,7 @@ PRInt32 _PR_MD_PR_POLL(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout) FD_SET(osfd, &rd); #else socks[rd] = osfd; - rd++; + rd++; #endif } if (in_flags_write & PR_POLL_WRITE) @@ -154,7 +156,7 @@ PRInt32 _PR_MD_PR_POLL(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout) FD_SET(osfd, &wt); #else socks[npds+wt] = osfd; - wt++; + wt++; #endif } if (pd->in_flags & PR_POLL_EXCEPT) @@ -224,24 +226,28 @@ retry: msecs = PR_IntervalToMilliseconds(remaining); } - /* compact array */ - for( i = rd, j = npds; j < npds+wt; i++,j++ ) + /* compact array */ + for( i = rd, j = npds; j < npds+wt; i++,j++ ) { socks[i] = socks[j]; - for( i = rd+wt, j = npds*2; j < npds*2+ex; i++,j++ ) + } + for( i = rd+wt, j = npds*2; j < npds*2+ex; i++,j++ ) { socks[i] = socks[j]; - + } + ready = os2_select(socks, rd, wt, ex, msecs); #endif if (ready == -1 && errno == EINTR) { - if (timeout == PR_INTERVAL_NO_TIMEOUT) + if (timeout == PR_INTERVAL_NO_TIMEOUT) { goto retry; + } else { elapsed = (PRIntervalTime) (PR_IntervalNow() - start); - if (elapsed > timeout) - ready = 0; /* timed out */ + if (elapsed > timeout) { + ready = 0; /* timed out */ + } else { remaining = timeout - elapsed; @@ -272,38 +278,44 @@ retry: #ifdef BSD_SELECT if (FD_ISSET(osfd, &rd)) #else - if( IsSocketSet(osfd, socks, 0, rd) ) + if( IsSocketSet(osfd, socks, 0, rd) ) #endif { - if (pd->out_flags & _PR_POLL_READ_SYS_READ) + if (pd->out_flags & _PR_POLL_READ_SYS_READ) { out_flags |= PR_POLL_READ; - if (pd->out_flags & _PR_POLL_WRITE_SYS_READ) + } + if (pd->out_flags & _PR_POLL_WRITE_SYS_READ) { out_flags |= PR_POLL_WRITE; - } + } + } #ifdef BSD_SELECT if (FD_ISSET(osfd, &wt)) #else - if( IsSocketSet(osfd, socks, rd, wt) ) + if( IsSocketSet(osfd, socks, rd, wt) ) #endif { - if (pd->out_flags & _PR_POLL_READ_SYS_WRITE) + if (pd->out_flags & _PR_POLL_READ_SYS_WRITE) { out_flags |= PR_POLL_READ; - if (pd->out_flags & _PR_POLL_WRITE_SYS_WRITE) + } + if (pd->out_flags & _PR_POLL_WRITE_SYS_WRITE) { out_flags |= PR_POLL_WRITE; - } + } + } #ifdef BSD_SELECT if (FD_ISSET(osfd, &ex)) #else - if( IsSocketSet(osfd, socks, rd+wt, ex) ) + if( IsSocketSet(osfd, socks, rd+wt, ex) ) #endif { out_flags |= PR_POLL_EXCEPT; } } pd->out_flags = out_flags; - if (out_flags) ready++; + if (out_flags) { + ready++; + } } PR_ASSERT(ready > 0); } @@ -323,7 +335,7 @@ retry: { bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER); if (getsockopt(bottom->secret->md.osfd, SOL_SOCKET, - SO_TYPE, (char *) &optval, &optlen) == -1) + SO_TYPE, (char *) &optval, &optlen) == -1) { PR_ASSERT(sock_errno() == ENOTSOCK); if (sock_errno() == ENOTSOCK) @@ -336,8 +348,9 @@ retry: } PR_ASSERT(ready > 0); } - else + else { _PR_MD_MAP_SELECT_ERROR(err); + } } #ifndef BSD_SELECT diff --git a/nsprpub/pr/src/md/os2/os2rng.c b/nsprpub/pr/src/md/os2/os2rng.c index 72f7357fa..aaa969381 100644 --- a/nsprpub/pr/src/md/os2/os2rng.c +++ b/nsprpub/pr/src/md/os2/os2rng.c @@ -17,8 +17,9 @@ static BOOL clockTickTime(unsigned long *phigh, unsigned long *plow) QWORD qword = {0,0}; rc = DosTmrQueryTime(&qword); - if (rc != NO_ERROR) - return FALSE; + if (rc != NO_ERROR) { + return FALSE; + } *phigh = qword.ulHi; *plow = qword.ulLo; @@ -35,8 +36,9 @@ extern PRSize _PR_MD_GetRandomNoise(void *buf, PRSize size ) int nBytes = 0; time_t sTime; - if (size <= 0) - return 0; + if (size <= 0) { + return 0; + } clockTickTime(&high, &low); @@ -46,16 +48,18 @@ extern PRSize _PR_MD_GetRandomNoise(void *buf, PRSize size ) n += nBytes; size -= nBytes; - if (size <= 0) - return n; + if (size <= 0) { + return n; + } nBytes = sizeof(high) > size ? size : sizeof(high); memcpy(((char *)buf) + n, &high, nBytes); n += nBytes; size -= nBytes; - if (size <= 0) - return n; + if (size <= 0) { + return n; + } /* get the number of milliseconds that have elapsed since application started */ val = clock(); @@ -65,8 +69,9 @@ extern PRSize _PR_MD_GetRandomNoise(void *buf, PRSize size ) n += nBytes; size -= nBytes; - if (size <= 0) - return n; + if (size <= 0) { + return n; + } /* get the time in seconds since midnight Jan 1, 1970 */ time(&sTime); diff --git a/nsprpub/pr/src/md/os2/os2sem.c b/nsprpub/pr/src/md/os2/os2sem.c index b60f35a74..a0dd88e4b 100644 --- a/nsprpub/pr/src/md/os2/os2sem.c +++ b/nsprpub/pr/src/md/os2/os2sem.c @@ -14,7 +14,7 @@ void _PR_MD_NEW_SEM(_MDSemaphore *md, PRUintn value) { - int rv; + int rv; /* Our Sems don't support a value > 1 */ PR_ASSERT(value <= 1); @@ -26,9 +26,9 @@ _PR_MD_NEW_SEM(_MDSemaphore *md, PRUintn value) void _PR_MD_DESTROY_SEM(_MDSemaphore *md) { - int rv; - rv = DosCloseEventSem(md->sem); - PR_ASSERT(rv == NO_ERROR); + int rv; + rv = DosCloseEventSem(md->sem); + PR_ASSERT(rv == NO_ERROR); } @@ -38,10 +38,12 @@ _PR_MD_TIMED_WAIT_SEM(_MDSemaphore *md, PRIntervalTime ticks) int rv; rv = DosWaitEventSem(md->sem, PR_IntervalToMilliseconds(ticks)); - if (rv == NO_ERROR) + if (rv == NO_ERROR) { return PR_SUCCESS; - else + } + else { return PR_FAILURE; + } } PRStatus @@ -53,9 +55,9 @@ _PR_MD_WAIT_SEM(_MDSemaphore *md) void _PR_MD_POST_SEM(_MDSemaphore *md) { - int rv; - rv = DosPostEventSem(md->sem); - PR_ASSERT(rv == NO_ERROR); + int rv; + rv = DosPostEventSem(md->sem); + PR_ASSERT(rv == NO_ERROR); } diff --git a/nsprpub/pr/src/md/os2/os2sock.c b/nsprpub/pr/src/md/os2/os2sock.c index b32794f39..c6b3ea3a5 100644 --- a/nsprpub/pr/src/md/os2/os2sock.c +++ b/nsprpub/pr/src/md/os2/os2sock.c @@ -12,7 +12,7 @@ /*There is standard BSD (which is kind of slow) and a new flavor of select() that takes */ /*an integer list of sockets, the number of read sockets, write sockets, except sockets, and */ /*a millisecond count for timeout. In the interest of performance I have choosen the OS/2 */ -/*specific version of select(). See OS/2 TCP/IP Programmer's Toolkit for more info. */ +/*specific version of select(). See OS/2 TCP/IP Programmer's Toolkit for more info. */ #include "primpl.h" @@ -32,7 +32,7 @@ _PR_MD_SOCKET(int domain, int type, int flags) osfd = socket(domain, type, flags); - if (osfd == -1) + if (osfd == -1) { err = sock_errno(); _PR_MD_MAP_SOCKET_ERROR(err); @@ -101,19 +101,23 @@ socket_io_wait( PRInt32 osfd, PRInt32 fd_type, PRIntervalTime timeout ) FD_ZERO(&rd_wr); do { FD_SET(osfd, &rd_wr); - if (fd_type == READ_FD) + if (fd_type == READ_FD) { rv = bsdselect(osfd + 1, &rd_wr, NULL, NULL, &tv); - else + } + else { rv = bsdselect(osfd + 1, NULL, &rd_wr, NULL, &tv); + } #else - lTimeout = _PR_INTERRUPT_CHECK_INTERVAL_SECS * 1000; + lTimeout = _PR_INTERRUPT_CHECK_INTERVAL_SECS * 1000; do { socks[0] = osfd; - if (fd_type == READ_FD) + if (fd_type == READ_FD) { rv = os2_select(socks, 1, 0, 0, lTimeout); - else + } + else { rv = os2_select(socks, 0, 1, 0, lTimeout); -#endif + } +#endif if (rv == -1 && (syserror = sock_errno()) != EINTR) { _PR_MD_MAP_SELECT_ERROR(syserror); break; @@ -148,14 +152,16 @@ socket_io_wait( PRInt32 osfd, PRInt32 fd_type, PRIntervalTime timeout ) tv.tv_usec = 0; } else { tv.tv_usec = PR_IntervalToMicroseconds( - remaining - - PR_SecondsToInterval(tv.tv_sec)); + remaining - + PR_SecondsToInterval(tv.tv_sec)); } FD_SET(osfd, &rd_wr); - if (fd_type == READ_FD) + if (fd_type == READ_FD) { rv = bsdselect(osfd + 1, &rd_wr, NULL, NULL, &tv); - else + } + else { rv = bsdselect(osfd + 1, NULL, &rd_wr, NULL, &tv); + } #else wait_for_remaining = PR_TRUE; lTimeout = PR_IntervalToMilliseconds(remaining); @@ -164,10 +170,12 @@ socket_io_wait( PRInt32 osfd, PRInt32 fd_type, PRIntervalTime timeout ) lTimeout = _PR_INTERRUPT_CHECK_INTERVAL_SECS * 1000; } socks[0] = osfd; - if (fd_type == READ_FD) + if (fd_type == READ_FD) { rv = os2_select(socks, 1, 0, 0, lTimeout); - else + } + else { rv = os2_select(socks, 0, 1, 0, lTimeout); + } #endif /* * we don't consider EINTR a real error @@ -198,7 +206,7 @@ socket_io_wait( PRInt32 osfd, PRInt32 fd_type, PRIntervalTime timeout ) } else { #ifdef BSD_SELECT now += PR_SecondsToInterval(tv.tv_sec) - + PR_MicrosecondsToInterval(tv.tv_usec); + + PR_MicrosecondsToInterval(tv.tv_usec); #else now += PR_MillisecondsToInterval(lTimeout); #endif @@ -217,7 +225,7 @@ socket_io_wait( PRInt32 osfd, PRInt32 fd_type, PRIntervalTime timeout ) } } while (rv == 0 || (rv == -1 && syserror == EINTR)); break; - } + } return(rv); } @@ -237,9 +245,10 @@ _MD_Accept(PRFileDesc *fd, PRNetAddr *addr, if (fd->secret->nonblocking) { break; } - if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0) - goto done; - } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){ + if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0) { + goto done; + } + } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) { continue; } else { break; @@ -253,7 +262,7 @@ done: } PRInt32 -_PR_MD_CONNECT(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen, +_PR_MD_CONNECT(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout) { PRInt32 rv, err; @@ -263,17 +272,17 @@ _PR_MD_CONNECT(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen, * modifies the sockaddr structure. * See Bugzilla bug 100776. */ - /* - * We initiate the connection setup by making a nonblocking connect() - * call. If the connect() call fails, there are two cases we handle - * specially: - * 1. The connect() call was interrupted by a signal. In this case - * we simply retry connect(). - * 2. The NSPR socket is nonblocking and connect() fails with - * EINPROGRESS. We first wait until the socket becomes writable. - * Then we try to find out whether the connection setup succeeded - * or failed. - */ + /* + * We initiate the connection setup by making a nonblocking connect() + * call. If the connect() call fails, there are two cases we handle + * specially: + * 1. The connect() call was interrupted by a signal. In this case + * we simply retry connect(). + * 2. The NSPR socket is nonblocking and connect() fails with + * EINPROGRESS. We first wait until the socket becomes writable. + * Then we try to find out whether the connection setup succeeded + * or failed. + */ retry: if ((rv = connect(osfd, (struct sockaddr *)&addrCopy, addrlen)) == -1) @@ -313,7 +322,7 @@ retry: } return 0; } - + _PR_MD_MAP_CONNECT_ERROR(err); } @@ -347,7 +356,7 @@ _PR_MD_LISTEN(PRFileDesc *fd, PRIntn backlog) PRInt32 -_PR_MD_RECV(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, +_PR_MD_RECV(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRIntervalTime timeout) { PRInt32 osfd = fd->secret->md.osfd; @@ -361,9 +370,10 @@ _PR_MD_RECV(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, if (fd->secret->nonblocking) { break; } - if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0) + if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0) { goto done; - } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){ + } + } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) { continue; } else { break; @@ -391,20 +401,21 @@ _PR_MD_SEND(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, if (fd->secret->nonblocking) { break; } - if ((rv = socket_io_wait(osfd, WRITE_FD, timeout)) < 0) + if ((rv = socket_io_wait(osfd, WRITE_FD, timeout)) < 0) { goto done; - } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){ + } + } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) { continue; } else { break; } } - /* - * optimization; if bytes sent is less than "amount" call - * select before returning. This is because it is likely that - * the next send() call will return EWOULDBLOCK. - */ + /* + * optimization; if bytes sent is less than "amount" call + * select before returning. This is because it is likely that + * the next send() call will return EWOULDBLOCK. + */ if ((!fd->secret->nonblocking) && (rv > 0) && (rv < amount) && (timeout != PR_INTERVAL_NO_WAIT)) { @@ -428,7 +439,7 @@ _PR_MD_SENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, PRInt32 rv, err; PRThread *me = _PR_MD_CURRENT_THREAD(); while ((rv = sendto(osfd, buf, amount, flags, - (struct sockaddr *) addr, addrlen)) == -1) + (struct sockaddr *) addr, addrlen)) == -1) { err = sock_errno(); if ((err == EWOULDBLOCK)) @@ -436,9 +447,10 @@ _PR_MD_SENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, if (fd->secret->nonblocking) { break; } - if ((rv = socket_io_wait(osfd, WRITE_FD, timeout)) < 0) + if ((rv = socket_io_wait(osfd, WRITE_FD, timeout)) < 0) { goto done; - } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){ + } + } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) { continue; } else { break; @@ -461,16 +473,17 @@ _PR_MD_RECVFROM(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, while( (*addrlen = PR_NETADDR_SIZE(addr)), ((rv = recvfrom(osfd, buf, amount, flags, - (struct sockaddr *) addr, (int *)addrlen)) == -1)) + (struct sockaddr *) addr, (int *)addrlen)) == -1)) { err = sock_errno(); if ((err == EWOULDBLOCK)) { if (fd->secret->nonblocking) { break; } - if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0) + if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0) { goto done; - } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){ + } + } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) { continue; } else { break; @@ -506,13 +519,13 @@ _PR_MD_WRITEV(PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size, osiov[index].iov_len = iov[index].iov_len; } - /* - * Calculate the total number of bytes to be sent; needed for - * optimization later. - * We could avoid this if this number was passed in; but it is - * probably not a big deal because iov_size is usually small (less than - * 3) - */ + /* + * Calculate the total number of bytes to be sent; needed for + * optimization later. + * We could avoid this if this number was passed in; but it is + * probably not a big deal because iov_size is usually small (less than + * 3) + */ if (!fd->secret->nonblocking) { for (index=0; index<iov_size; index++) { amount += iov[index].iov_len; @@ -525,22 +538,23 @@ _PR_MD_WRITEV(PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size, if (fd->secret->nonblocking) { break; } - if ((rv = socket_io_wait(osfd, WRITE_FD, timeout))<0) + if ((rv = socket_io_wait(osfd, WRITE_FD, timeout))<0) { goto done; - } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){ + } + } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) { continue; } else { break; } } - /* - * optimization; if bytes sent is less than "amount" call - * select before returning. This is because it is likely that - * the next writev() call will return EWOULDBLOCK. - */ + /* + * optimization; if bytes sent is less than "amount" call + * select before returning. This is because it is likely that + * the next writev() call will return EWOULDBLOCK. + */ if ((!fd->secret->nonblocking) && (rv > 0) && (rv < amount) - && (timeout != PR_INTERVAL_NO_WAIT)) { + && (timeout != PR_INTERVAL_NO_WAIT)) { if (socket_io_wait(osfd, WRITE_FD, timeout) < 0) { rv = -1; goto done; @@ -559,8 +573,9 @@ _PR_MD_SHUTDOWN(PRFileDesc *fd, PRIntn how) PRInt32 rv; rv = shutdown(fd->secret->md.osfd, how); - if (rv < 0) + if (rv < 0) { _PR_MD_MAP_SHUTDOWN_ERROR(sock_errno()); + } return rv; } @@ -639,7 +654,7 @@ _MD_MakeNonblock(PRFileDesc *fd) PRInt32 osfd = fd->secret->md.osfd; PRInt32 err; PRUint32 one = 1; - + if (osfd <= 2) { /* Don't mess around with stdin, stdout or stderr */ return; diff --git a/nsprpub/pr/src/md/os2/os2thred.c b/nsprpub/pr/src/md/os2/os2thred.c index edb9f5f0c..aa929a1a2 100644 --- a/nsprpub/pr/src/md/os2/os2thred.c +++ b/nsprpub/pr/src/md/os2/os2thred.c @@ -16,37 +16,37 @@ APIRET (* APIENTRY QueryThreadContext)(TID, ULONG, PCONTEXTRECORD); void _PR_MD_ENSURE_TLS(void) { - if(!pThreadLocalStorage) - { - /* Allocate thread local storage (TLS). Note, that only 32 bytes can - * be allocated at a time. - */ - int rc = DosAllocThreadLocalMemory(sizeof(_NSPR_TLS) / 4, (PULONG*)&pThreadLocalStorage); - PR_ASSERT(rc == NO_ERROR); - memset(pThreadLocalStorage, 0, sizeof(_NSPR_TLS)); - } + if(!pThreadLocalStorage) + { + /* Allocate thread local storage (TLS). Note, that only 32 bytes can + * be allocated at a time. + */ + int rc = DosAllocThreadLocalMemory(sizeof(_NSPR_TLS) / 4, (PULONG*)&pThreadLocalStorage); + PR_ASSERT(rc == NO_ERROR); + memset(pThreadLocalStorage, 0, sizeof(_NSPR_TLS)); + } } void _PR_MD_EARLY_INIT() { - HMODULE hmod; + HMODULE hmod; - if (DosLoadModule(NULL, 0, "DOSCALL1", &hmod) == 0) - DosQueryProcAddr(hmod, 877, "DOSQUERYTHREADCONTEXT", - (PFN *)&QueryThreadContext); + if (DosLoadModule(NULL, 0, "DOSCALL1", &hmod) == 0) + DosQueryProcAddr(hmod, 877, "DOSQUERYTHREADCONTEXT", + (PFN *)&QueryThreadContext); } static void _pr_SetThreadMDHandle(PRThread *thread) { - PTIB ptib; - PPIB ppib; - PRUword rc; + PTIB ptib; + PPIB ppib; + PRUword rc; - rc = DosGetInfoBlocks(&ptib, &ppib); + rc = DosGetInfoBlocks(&ptib, &ppib); - thread->md.handle = ptib->tib_ptib2->tib2_ultid; + thread->md.handle = ptib->tib_ptib2->tib2_ultid; } /* On OS/2, some system function calls seem to change the FPU control word, @@ -134,15 +134,15 @@ PR_OS2_UnsetFloatExcpHandler(EXCEPTIONREGISTRATIONRECORD* excpreg) PRStatus _PR_MD_INIT_THREAD(PRThread *thread) { - APIRET rv; + APIRET rv; - if (thread->flags & (_PR_PRIMORDIAL | _PR_ATTACHED)) { - _pr_SetThreadMDHandle(thread); - } + if (thread->flags & (_PR_PRIMORDIAL | _PR_ATTACHED)) { + _pr_SetThreadMDHandle(thread); + } - /* Create the blocking IO semaphore */ - rv = DosCreateEventSem(NULL, &(thread->md.blocked_sema), 0, 0); - return (rv == NO_ERROR) ? PR_SUCCESS : PR_FAILURE; + /* Create the blocking IO semaphore */ + rv = DosCreateEventSem(NULL, &(thread->md.blocked_sema), 0, 0); + return (rv == NO_ERROR) ? PR_SUCCESS : PR_FAILURE; } typedef struct param_store @@ -169,20 +169,20 @@ ExcpStartFunc(void* arg) } PRStatus -_PR_MD_CREATE_THREAD(PRThread *thread, - void (*start)(void *), - PRThreadPriority priority, - PRThreadScope scope, - PRThreadState state, - PRUint32 stackSize) +_PR_MD_CREATE_THREAD(PRThread *thread, + void (*start)(void *), + PRThreadPriority priority, + PRThreadScope scope, + PRThreadState state, + PRUint32 stackSize) { PARAMSTORE* params = PR_Malloc(sizeof(PARAMSTORE)); params->start = start; params->thread = thread; thread->md.handle = thread->id = (TID) _beginthread(ExcpStartFunc, - NULL, - thread->stack->stackSize, - params); + NULL, + thread->stack->stackSize, + params); if(thread->md.handle == -1) { return PR_FAILURE; } @@ -232,7 +232,7 @@ _PR_MD_SET_PRIORITY(_MDThread *thread, PRThreadPriority newPri) PR_ASSERT(rv == NO_ERROR); if (rv != NO_ERROR) { PR_LOG(_pr_thread_lm, PR_LOG_MIN, - ("PR_SetThreadPriority: can't set thread priority\n")); + ("PR_SetThreadPriority: can't set thread priority\n")); } return; } @@ -268,41 +268,41 @@ _PR_MD_EXIT(PRIntn status) } #ifdef HAVE_THREAD_AFFINITY -PR_EXTERN(PRInt32) +PR_EXTERN(PRInt32) _PR_MD_SETTHREADAFFINITYMASK(PRThread *thread, PRUint32 mask ) { - /* Can we do this on OS/2? Only on SMP versions? */ - PR_NOT_REACHED("Not implemented"); - return 0; + /* Can we do this on OS/2? Only on SMP versions? */ + PR_NOT_REACHED("Not implemented"); + return 0; - /* This is what windows does: - int rv; + /* This is what windows does: + int rv; - rv = SetThreadAffinityMask(thread->md.handle, mask); + rv = SetThreadAffinityMask(thread->md.handle, mask); - return rv?0:-1; - */ + return rv?0:-1; + */ } PR_EXTERN(PRInt32) _PR_MD_GETTHREADAFFINITYMASK(PRThread *thread, PRUint32 *mask) { - /* Can we do this on OS/2? Only on SMP versions? */ - PR_NOT_REACHED("Not implemented"); - return 0; + /* Can we do this on OS/2? Only on SMP versions? */ + PR_NOT_REACHED("Not implemented"); + return 0; - /* This is what windows does: - PRInt32 rv, system_mask; + /* This is what windows does: + PRInt32 rv, system_mask; - rv = GetProcessAffinityMask(GetCurrentProcess(), mask, &system_mask); - - return rv?0:-1; - */ + rv = GetProcessAffinityMask(GetCurrentProcess(), mask, &system_mask); + + return rv?0:-1; + */ } #endif /* HAVE_THREAD_AFFINITY */ void -_PR_MD_SUSPEND_CPU(_PRCPU *cpu) +_PR_MD_SUSPEND_CPU(_PRCPU *cpu) { _PR_MD_SUSPEND_THREAD(cpu->thread); } @@ -317,13 +317,13 @@ void _PR_MD_SUSPEND_THREAD(PRThread *thread) { if (_PR_IS_NATIVE_THREAD(thread)) { - APIRET rc; + APIRET rc; /* XXXMB - DosSuspendThread() is not a blocking call; how do we * know when the thread is *REALLY* suspended? */ - rc = DosSuspendThread(thread->md.handle); - PR_ASSERT(rc == NO_ERROR); + rc = DosSuspendThread(thread->md.handle); + PR_ASSERT(rc == NO_ERROR); } } |