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

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

Always implement lisp_lseek() via lseek64() on Linux.

File size: 2.4 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#define _LARGEFILE64_SOURCE
29#include <errno.h>
30#include <unistd.h>
31#include <sys/stat.h>
32#include <dirent.h>
33#include <sys/syscall.h>
34#include <sys/time.h>
35#include <stdint.h>
36
37ssize_t
38lisp_read(int fd, void *buf, size_t count)
39{
40  return read(fd,buf,count);
41}
42
43ssize_t
44lisp_write(int fd, void *buf, size_t count)
45{
46  return write(fd,buf,count);
47}
48
49int
50lisp_open(char *path, int flags, mode_t mode)
51{
52  return open(path,flags,mode);
53}
54
55int
56lisp_fchmod(int fd, mode_t mode)
57{
58  return fchmod(fd,mode);
59}
60
61int64_t
62lisp_lseek(int fd, int64_t offset, int whence)
63{
64#ifdef LINUX
65  return lseek64(fd,offset,whence);
66#else
67  return lseek(fd,offset,whence);
68#endif
69}
70
71int
72lisp_close(int fd)
73{
74  return close(fd);
75}
76
77int
78lisp_ftruncate(int fd, off_t length)
79{
80  return ftruncate(fd,length);
81}
82
83int
84lisp_stat(char *path, void *buf)
85{
86  return stat(path,buf);
87}
88
89int
90lisp_fstat(int fd, void *buf)
91{
92  return fstat(fd,buf);
93}
94
95
96int
97lisp_futex(int *uaddr, int op, int val, void *timeout, int *uaddr2, int val3)
98{
99#ifdef LINUX
100  return syscall(SYS_futex,uaddr,op,val,timeout,uaddr2,val3);
101#else
102  errno = ENOSYS;
103  return -1;
104#endif
105}
106
107DIR *
108lisp_opendir(char *path)
109{
110  return opendir(path);
111}
112
113struct dirent *
114lisp_readdir(DIR *dir)
115{
116  return readdir(dir);
117}
118
119int
120lisp_closedir(DIR *dir)
121{
122  return closedir(dir);
123}
124
125int
126lisp_pipe(int pipefd[2])
127{
128  return pipe(pipefd);
129}
130
131int
132lisp_gettimeofday(struct timeval *tp, void *tzp)
133{
134  return gettimeofday(tp, tzp);
135}
Note: See TracBrowser for help on using the repository browser.