source: branches/arm/lisp-kernel/unix-calls.c @ 13923

Last change on this file since 13923 was 13606, checked in by gb, 10 years ago

Define, -include PLATFORM_H.
Ensure that <sys/types.h> is #included.
Don't trivially redefine _LARGEFILE64_SOURCE_, which may be defined
in the platform-specific header file.

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