source: trunk/source/lisp-kernel/unix-calls.c @ 10655

Last change on this file since 10655 was 10655, checked in by gb, 11 years ago

New file: provide glue for I/O functions, so that we don't need to
use syscalls for them.

File size: 2.1 KB
Line 
1/*
2   Copyright (C) 2008, Clozure Associates and contributors
3   This file is part of Clozure CL. 
4
5   Clozure CL is licensed under the terms of the Lisp Lesser GNU Public
6   License , known as the LLGPL and distributed with Clozure CL as the
7   file "LICENSE".  The LLGPL consists of a preamble and the LGPL,
8   which is distributed with Clozure CL as the file "LGPL".  Where these
9   conflict, the preamble takes precedence. 
10
11   Clozure CL is referenced in the preamble as the "LIBRARY."
12
13   The LLGPL is also available online at
14   http://opensource.franz.com/preamble.html
15*/
16
17/* Provide wrappers around some standard C library functions that
18   can't easily be called from CCL's FFI for some reason (or where
19   we want to override/extend the function's default behavior.)
20 
21   Functions in this file should be referenced via the kernel
22   imports table.
23
24   Callers should generally expect standard C library error-handling
25   conventions (e.g., return -1 or NULL and set errno on error.)
26*/
27
28#include <errno.h>
29#include <unistd.h>
30#include <sys/stat.h>
31#include <dirent.h>
32#include <sys/syscall.h>
33
34ssize_t
35lisp_read(int fd, void *buf, size_t count)
36{
37  return read(fd,buf,count);
38}
39
40ssize_t
41lisp_write(int fd, void *buf, size_t count)
42{
43  return write(fd,buf,count);
44}
45
46int
47lisp_open(char *path, int flags, mode_t mode)
48{
49  return open(path,flags,mode);
50}
51
52int
53lisp_fchmod(int fd, mode_t mode)
54{
55  return fchmod(fd,mode);
56}
57
58off_t
59lisp_lseek(int fd, off_t offset, int whence)
60{
61  return lseek(fd,offset,whence);
62}
63
64int
65lisp_close(int fd)
66{
67  return close(fd);
68}
69
70int
71lisp_ftruncate(int fd, off_t length)
72{
73  return ftruncate(fd,length);
74}
75
76int
77lisp_stat(char *path, void *buf)
78{
79  return stat(path,buf);
80}
81
82int
83lisp_fstat(int fd, void *buf)
84{
85  return fstat(fd,buf);
86}
87
88
89int
90lisp_futex(int *uaddr, int op, int val, void *timeout, int *uaddr2, int val3)
91{
92#ifdef LINUX
93  return syscall(SYS_futex,uaddr,op,val,timeout,uaddr2,val3);
94#else
95  errno = ENOSYS;
96  return -1;
97#endif
98}
99
100DIR *
101lisp_opendir(char *path)
102{
103  return opendir(path);
104}
105
106struct dirent *
107lisp_readdir(DIR *dir)
108{
109  return readdir(dir);
110}
111
112int
113lisp_closedir(DIR *dir)
114{
115  return closedir(dir);
116}
Note: See TracBrowser for help on using the repository browser.