Fixing compilation issues in PAL caused by switching to uint64_t

This commit is contained in:
Chia-Che Tsai
2018-08-13 10:10:37 -04:00
committed by Don Porter
parent 740cb51db9
commit b1e9571d1c
11 changed files with 28 additions and 26 deletions
+2 -2
View File
@@ -618,7 +618,7 @@ void DkStreamUnmap (PAL_PTR addr, PAL_NUM size)
/* _DkStreamSetLength for internal use. This function truncate the stream
to certain length. This call might not be support for certain streams */
uint64_t _DkStreamSetLength (PAL_HANDLE handle, uint64_t length)
int64_t _DkStreamSetLength (PAL_HANDLE handle, uint64_t length)
{
if (UNKNOWN_HANDLE(handle))
return -PAL_ERROR_BADHANDLE;
@@ -643,7 +643,7 @@ DkStreamSetLength (PAL_HANDLE handle, PAL_NUM length)
LEAVE_PAL_CALL_RETURN(0);
}
uint64_t ret = _DkStreamSetLength(handle, length);
int64_t ret = _DkStreamSetLength(handle, length);
if (ret < 0) {
_DkRaiseFailure(-ret);
+1 -1
View File
@@ -81,7 +81,7 @@ int _DkEventSet (PAL_HANDLE event, int wakeup)
return ret;
}
int _DkEventWaitTimeout (PAL_HANDLE event, int timeout)
int _DkEventWaitTimeout (PAL_HANDLE event, uint64_t timeout)
{
int ret = 0;
+3 -3
View File
@@ -243,13 +243,13 @@ static int file_map (PAL_HANDLE handle, void ** addr, int prot,
}
/* 'setlength' operation for file stream. */
static uint64_t file_setlength (PAL_HANDLE handle, uint64_t length)
static int64_t file_setlength (PAL_HANDLE handle, uint64_t length)
{
int ret = ocall_ftruncate(handle->file.fd, length);
if (ret < 0)
return ret;
handle->file.total = length;
return length;
return (int64_t) length;
}
/* 'flush' operation for file stream. */
@@ -330,7 +330,7 @@ static int file_attrsetbyhdl (PAL_HANDLE handle,
PAL_STREAM_ATTR * attr)
{
int fd = HANDLE_HDR(handle)->fds[0];
int ret = ocall_fchmod(fd, attr->share_flags);
int ret = ocall_fchmod(fd, attr->share_flags | 0600);
if (ret < 0)
return ret;
+4 -4
View File
@@ -42,7 +42,7 @@
/* internally to wait for one object. Also used as a shortcut to wait
on events and semaphores */
static int _DkObjectWaitOne (PAL_HANDLE handle, int timeout)
static int _DkObjectWaitOne (PAL_HANDLE handle, uint64_t timeout)
{
/* only for all these handle which has a file descriptor, or
a eventfd. events and semaphores will skip this part */
@@ -74,7 +74,7 @@ static int _DkObjectWaitOne (PAL_HANDLE handle, int timeout)
if (!nfds)
return -PAL_ERROR_TRYAGAIN;
unsigned long waittime = timeout;
uint64_t waittime = timeout;
int ret = ocall_poll(fds, nfds, timeout >= 0 ? &waittime : NULL);
if (ret < 0)
return ret;
@@ -104,7 +104,7 @@ static int _DkObjectWaitOne (PAL_HANDLE handle, int timeout)
/* _DkObjectsWaitAny for internal use. The function wait for any of the handle
in the handle array. timeout can be set for the wait. */
int _DkObjectsWaitAny (int count, PAL_HANDLE * handleArray, int timeout,
int _DkObjectsWaitAny (int count, PAL_HANDLE * handleArray, uint64_t timeout,
PAL_HANDLE * polled)
{
if (count <= 0)
@@ -180,7 +180,7 @@ int _DkObjectsWaitAny (int count, PAL_HANDLE * handleArray, int timeout,
if (!nfds)
return -PAL_ERROR_TRYAGAIN;
unsigned long waittime = timeout;
uint64_t waittime = timeout;
ret = ocall_poll(fds, nfds, timeout >= 0 ? &waittime : NULL);
if (ret < 0)
return ret;
+1 -1
View File
@@ -146,7 +146,7 @@ int _DkSemaphoreAcquire (PAL_HANDLE sem, int count)
return ret;
}
int _DkSemaphoreAcquireTimeout (PAL_HANDLE sem, int count, int timeout)
int _DkSemaphoreAcquireTimeout (PAL_HANDLE sem, int count, uint64_t timeout)
{
/* Pass it up to the no-timeout version if no timeout requested */
if (timeout == -1)
+4 -4
View File
@@ -425,7 +425,7 @@ int ocall_create_process (const char * uri,
}
int ocall_futex (int * futex, int op, int val,
const unsigned long * timeout)
const uint64_t * timeout)
{
int retval = 0;
ms_ocall_futex_t * ms;
@@ -439,7 +439,7 @@ int ocall_futex (int * futex, int op, int val,
ms->ms_futex = futex;
ms->ms_op = op;
ms->ms_val = val;
ms->ms_timeout = timeout ? *timeout : (unsigned long) -1;
ms->ms_timeout = timeout ? *timeout : OCALL_NO_TIMEOUT;
retval = SGX_OCALL(OCALL_FUTEX, ms);
OCALL_EXIT();
@@ -718,7 +718,7 @@ int ocall_sleep (unsigned long * microsec)
return retval;
}
int ocall_poll (struct pollfd * fds, int nfds, unsigned long * timeout)
int ocall_poll (struct pollfd * fds, int nfds, uint64_t * timeout)
{
int retval = 0;
ms_ocall_poll_t * ms;
@@ -726,7 +726,7 @@ int ocall_poll (struct pollfd * fds, int nfds, unsigned long * timeout)
ms->ms_fds = COPY_TO_USER(fds, sizeof(struct pollfd) * nfds);
ms->ms_nfds = nfds;
ms->ms_timeout = timeout ? *timeout : (unsigned long) -1;
ms->ms_timeout = timeout ? *timeout : OCALL_NO_TIMEOUT;
retval = SGX_OCALL(OCALL_POLL, ms);
if (retval == -EINTR && timeout)
+2 -2
View File
@@ -88,7 +88,7 @@ int ocall_create_process (const char * uri,
int procfds[3],
unsigned int * pid);
int ocall_futex (int * uaddr, int op, int val, const unsigned long * timeout);
int ocall_futex (int * uaddr, int op, int val, const uint64_t * timeout);
int ocall_gettime (unsigned long * microsec);
@@ -96,7 +96,7 @@ int ocall_sleep (unsigned long * microsec);
int ocall_socketpair (int domain, int type, int protocol, int sockfds[2]);
int ocall_poll (struct pollfd * fds, int nfds, unsigned long * microsec);
int ocall_poll (struct pollfd * fds, int nfds, uint64_t * timeout);
int ocall_rename (const char * oldpath, const char * newpath);
+4 -2
View File
@@ -48,6 +48,8 @@ enum {
OCALL_NR,
};
#define OCALL_NO_TIMEOUT ((uint64_t) -1)
typedef struct {
const char * ms_str;
int ms_length;
@@ -154,7 +156,7 @@ typedef struct {
typedef struct {
int * ms_futex;
int ms_op, ms_val;
unsigned long ms_timeout;
uint64_t ms_timeout;
} ms_ocall_futex_t;
typedef struct {
@@ -241,7 +243,7 @@ typedef struct {
typedef struct {
struct pollfd * ms_fds;
int ms_nfds;
unsigned long ms_timeout;
uint64_t ms_timeout;
} ms_ocall_poll_t;
typedef struct {
+2 -2
View File
@@ -240,7 +240,7 @@ static int sgx_ocall_futex(void * pms)
int ret;
ODEBUG(OCALL_FUTEX, ms);
struct timespec * ts = NULL;
if (ms->ms_timeout != (unsigned long) -1) {
if (ms->ms_timeout != OCALL_NO_TIMEOUT) {
ts = __alloca(sizeof(struct timespec));
ts->tv_sec = ms->ms_timeout / 1000000;
ts->tv_nsec = (ms->ms_timeout - ts->tv_sec * 1000000) * 1000;
@@ -610,7 +610,7 @@ static int sgx_ocall_poll(void * pms)
int ret;
ODEBUG(OCALL_POLL, ms);
struct timespec * ts = NULL;
if (ms->ms_timeout != (unsigned long) -1) {
if (ms->ms_timeout != OCALL_NO_TIMEOUT) {
ts = __alloca(sizeof(struct timespec));
ts->tv_sec = ms->ms_timeout / 1000000;
ts->tv_nsec = (ms->ms_timeout - ts->tv_sec * 1000000) * 1000;
+3 -3
View File
@@ -168,7 +168,7 @@ static int file_map (PAL_HANDLE handle, void ** addr, int prot,
}
/* 'setlength' operation for file stream. */
static uint64_t file_setlength (PAL_HANDLE handle, uint64_t length)
static int64_t file_setlength (PAL_HANDLE handle, uint64_t length)
{
int ret = INLINE_SYSCALL(ftruncate, 2, handle->file.fd, length);
@@ -176,7 +176,7 @@ static uint64_t file_setlength (PAL_HANDLE handle, uint64_t length)
return (ERRNO(ret) == EINVAL || ERRNO(ret) == EBADF) ?
-PAL_ERROR_BADHANDLE : -PAL_ERROR_DENIED;
return length;
return (int64_t) length;
}
/* 'flush' operation for file stream. */
@@ -258,7 +258,7 @@ static int file_attrsetbyhdl (PAL_HANDLE handle,
{
int fd = HANDLE_HDR(handle)->fds[0], ret;
ret = INLINE_SYSCALL(fchmod, 2, fd, attr->share_flags);
ret = INLINE_SYSCALL(fchmod, 2, fd, attr->share_flags | 0600);
if (IS_ERR(ret))
return unix_to_pal_error(ERRNO(ret));
+2 -2
View File
@@ -81,7 +81,7 @@ struct handle_ops {
/* 'setlength' is used by DkStreamFlush. It truncate the stream
to certain size. */
uint64_t (*setlength) (PAL_HANDLE handle, uint64_t length);
int64_t (*setlength) (PAL_HANDLE handle, uint64_t length);
/* 'flush' is used by DkStreamFlush. It syncs the stream to the device */
int (*flush) (PAL_HANDLE handle);
@@ -303,7 +303,7 @@ int _DkStreamAttributesQuerybyHandle (PAL_HANDLE hdl, PAL_STREAM_ATTR * attr);
int _DkStreamMap (PAL_HANDLE handle, void ** addr, int prot, uint64_t offset,
uint64_t size);
int _DkStreamUnmap (void * addr, uint64_t size);
uint64_t _DkStreamSetLength (PAL_HANDLE handle, uint64_t length);
int64_t _DkStreamSetLength (PAL_HANDLE handle, uint64_t length);
int _DkStreamFlush (PAL_HANDLE handle);
int _DkStreamGetName (PAL_HANDLE handle, char * buf, int size);
const char * _DkStreamRealpath (PAL_HANDLE hdl);