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

Last change on this file since 12196 was 12196, checked in by gz, 10 years ago

Merge r11497:r11498 into trunk: pass signal number through to async quit handler so can exit by resignalling.

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