Changeset 10656


Ignore:
Timestamp:
Sep 8, 2008, 3:25:20 PM (11 years ago)
Author:
gb
Message:

Try to fit into the new syscall-avoidance scheme; don't know
if this compiles/links cleanly yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/windows-calls.c

    r10596 r10656  
    1313   The LLGPL is also available online at
    1414   http://opensource.franz.com/preamble.html
    15 */
    16 
    17 /*
    18    These aren't really system calls; they're just C runtime functions
    19    that (a) are built in to the lisp, so they can be called early
    20    in the cold load, before the FFI is initialized and (b) return negated
    21    error code on failure, so that it's not necessary to separately
    22    fetch errno.
    23 
    24    It's reasonable to consider replacing these things with wrappers
    25    around native functionality (ReadFile, etc.) someday.
    26 
    27    The order of the entries in windows_syscall_table[] should match
    28    the order of syscall indices defined in
    29    "ccl:library;x86-win64-syscalls.lisp".
    30 
    31    One last time: these aren't really system calls.
    3215*/
    3316
     
    192175#endif
    193176
    194 #define WSYSCALL_RETURN(form) \
    195   do { \
    196     int __result = form; \
    197 \
    198     if (__result < 0){ \
    199       return -errno; \
    200     } \
    201     return __result; \
    202   } while (0)
    203 
    204 
    205 
    206 __int64
    207 windows_open(wchar_t *path, int flag, int mode)
     177
     178
     179int
     180lisp_open(wchar_t *path, int flag, int mode)
    208181{
    209182  int fd;
     
    299272}
    300273
    301 __int64
    302 windows_close(int fd)
    303 {
    304   WSYSCALL_RETURN(close(fd));
    305 }
    306 
    307 __int64
    308 windows_read(int fd, void *buf, unsigned int count)
     274int
     275lisp_close(int fd)
     276{
     277  return close(fd);
     278}
     279
     280int
     281lisp_read(int fd, void *buf, unsigned int count)
    309282{
    310283  HANDLE hfile;
     
    346319    _dosmaperr(err);
    347320    tcr->foreign_exception_status = 0;
    348     return -errno;
     321    return -1;
    349322  }
    350323 
     
    360333  case ERROR_HANDLE_EOF:
    361334    return 0;
    362   case ERROR_OPERATION_ABORTED:
    363     return -EINTR;
     335  case ERROR_OPERATION_ABORTED:
     336    errno = EINTR;
     337    return -1;
    364338  default:
    365339    _dosmaperr(err);
    366     return -errno;
    367   }
    368 }
     340    return -1;
     341  }
     342}
     343
     344int
     345lisp_write(int fd, void *buf, unsigned int count)
     346{
     347  return _write(fd, buf, count);
     348}
     349
     350int
     351lisp_fchmod(int fd, int mode)
     352{
     353  errno = ENOSYS
     354  return -1;
     355}
     356
     357off_t
     358lisp_lseek(int fd, __int64 offset, int whence)
     359{
     360  return lseek64(fd, offset, whence);
     361}
     362
     363int
     364lisp_stat(wchar_t *path, struct __stat64 *buf)
     365{
     366  return _wstat64(path,buf);
     367}
     368
     369int
     370windows_fstat(int fd, struct __stat64 *buf)
     371{
     372  return _fstat64(fd,buf);
     373}
     374
    369375
    370376__int64
    371 windows_write(int fd, void *buf, unsigned int count)
    372 {
    373   WSYSCALL_RETURN( _write(fd, buf, count));
     377lisp_ftruncate(int fd, __int64 new_size)
     378{
     379  /* Note that _ftruncate only allows 32-bit length */
     380  return ftruncate(fd,(off_t)new_size);
     381}
     382
     383_WDIR *
     384lisp_opendir(wchar_t *path)
     385{
     386  return _wopendir(path);
     387}
     388
     389struct _wdirent *
     390lisp_readdir(_WDIR *dir)
     391{
     392  return _wreaddir(dir);
    374393}
    375394
    376395__int64
    377 windows_fchmod(int fd, int mode)
    378 {
    379   return -ENOSYS;
    380 }
    381 
    382 __int64
    383 windows_lseek(int fd, __int64 offset, int whence)
    384 {
    385   WSYSCALL_RETURN(lseek64(fd, offset, whence));
    386 }
    387 
    388 __int64
    389 windows_stat(wchar_t *path, struct __stat64 *buf)
    390 {
    391   WSYSCALL_RETURN(_wstat64(path,buf));
    392 }
    393 
    394 __int64
    395 windows_fstat(int fd, struct __stat64 *buf)
    396 {
    397   WSYSCALL_RETURN(_fstat64(fd,buf));
    398 }
    399 
    400 
    401 __int64
    402 windows_ftruncate(int fd, __int64 new_size)
    403 {
    404   /* Note that _ftruncate only allows 32-bit length */
    405   WSYSCALL_RETURN(ftruncate(fd,(off_t)new_size));
    406 }
    407 
    408 _WDIR *
    409 windows_opendir(wchar_t *path)
    410 {
    411   return _wopendir(path);
    412 }
    413 
    414 struct _wdirent *
    415 windows_readdir(_WDIR *dir)
    416 {
    417   return _wreaddir(dir);
    418 }
    419 
    420 __int64
    421 windows_closedir(_WDIR *dir)
     396lisp_closedir(_WDIR *dir)
    422397{
    423398  WSYSCALL_RETURN(_wclosedir(dir));
    424399}
    425400
    426 __int64
    427 windows_pipe(int fd[2])
     401int
     402lisp_pipe(int fd[2])
    428403{
    429404  HANDLE input, output;
     
    444419}
    445420
    446 void *
    447 windows_syscall_table[] = {
    448   windows_open,
    449   windows_close,
    450   windows_read,
    451   windows_write,
    452   windows_fchmod,
    453   windows_lseek,
    454   windows_stat,
    455   windows_fstat,
    456   windows_ftruncate,
    457   windows_opendir,
    458   windows_readdir,
    459   windows_closedir,
    460   windows_pipe
    461 };
    462421
    463422HMODULE *modules = NULL;
Note: See TracChangeset for help on using the changeset viewer.