Skip to content

Commit d82d488

Browse files
authored
Merge pull request #83 from bucanero/librt-update
Librt update (fsync, ftruncate, truncate, link)
2 parents 2da7ab9 + ec34eaf commit d82d488

5 files changed

Lines changed: 74 additions & 1 deletion

File tree

ppu/crt/crt1.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ extern int __librt_fstat_r(struct _reent *r,int fd,struct stat *st);
1414
extern int __librt_fstat64_r(struct _reent *r,int fd,struct stat *st);
1515
extern int __librt_stat_r(struct _reent *r,const char *path,struct stat *st);
1616
extern int __librt_stat64_r(struct _reent *r,const char *path,struct stat *st);
17+
extern int __librt_ftruncate_r(struct _reent *r,int fd,off_t len);
18+
extern int __librt_truncate_r(struct _reent *r,const char *path,off_t len);
19+
extern int __librt_fsync_r(struct _reent *r,int fd);
1720
extern _ssize_t __librt_read_r(struct _reent *r,int fd,void *ptr,size_t len);
1821
extern _ssize_t __librt_write_r(struct _reent *r,int fd,const void *ptr,size_t len);
1922
extern _off_t __librt_lseek_r(struct _reent *r,int fd,_off_t pos,int dir);
@@ -32,6 +35,7 @@ extern long int __librt_telldir_r(struct _reent *r,DIR *dirp);
3235
extern void __librt_rewinddir_r(struct _reent *r,DIR *dirp);
3336
extern void __librt_seekdir_r(struct _reent *r,DIR *dirp,long int loc);
3437
extern int __librt_rmdir_r(struct _reent *r,const char *dirname);
38+
extern int __librt_link_r(struct _reent *r,const char *old,const char *new);
3539
extern int __librt_unlink_r(struct _reent *r,const char *path);
3640
extern int __librt_access_r(struct _reent *r,const char *path,int amode);
3741

@@ -65,6 +69,9 @@ static void __syscalls_init(void)
6569
__syscalls.fstat64_r = __librt_fstat64_r;
6670
__syscalls.stat_r = __librt_stat_r;
6771
__syscalls.stat64_r = __librt_stat64_r;
72+
__syscalls.ftruncate_r = __librt_ftruncate_r;
73+
__syscalls.truncate_r = __librt_truncate_r;
74+
__syscalls.fsync_r = __librt_fsync_r;
6875
__syscalls.chmod_r = __librt_chmod_r;
6976
__syscalls.rename_r = __librt_rename_r;
7077
__syscalls.isatty_r = __librt_isatty_r;
@@ -78,6 +85,7 @@ static void __syscalls_init(void)
7885
__syscalls.rewinddir_r = __librt_rewinddir_r;
7986
__syscalls.seekdir_r = __librt_seekdir_r;
8087
__syscalls.rmdir_r = __librt_rmdir_r;
88+
__syscalls.link_r = __librt_link_r;
8189
__syscalls.unlink_r = __librt_unlink_r;
8290
__syscalls.access_r = __librt_access_r;
8391

ppu/librt/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ VPATH := $(BASEDIR)
4545
OBJS := \
4646
sbrk.o exit.o close.o lseek.o read.o open.o sleep.o write.o fstat.o \
4747
socket.o lock.o dirent.o mkdir.o times.o umask.o lv2errno.o heap.o \
48-
chmod.o rename.o rmdir.o isatty.o gettod.o settod.o unlink.o access.o
48+
chmod.o rename.o rmdir.o isatty.o gettod.o settod.o unlink.o access.o \
49+
link.o truncate.o fsync.o
4950

5051
all: ppu
5152

ppu/librt/fsync.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <_ansi.h>
2+
#include <_syslist.h>
3+
#include <sys/reent.h>
4+
#include <sys/errno.h>
5+
#include <sys/types.h>
6+
#include <sys/socket.h>
7+
#include <sys/lv2errno.h>
8+
9+
#include <sys/file.h>
10+
11+
int
12+
_DEFUN(__librt_fsync_r,(ptr,fd),
13+
struct _reent *ptr _AND
14+
int fd)
15+
{
16+
return lv2errno_r(ptr,sysLv2FsFsync(fd));
17+
}

ppu/librt/link.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <stdio.h>
2+
#include <fcntl.h>
3+
#include <_ansi.h>
4+
#include <_syslist.h>
5+
#include <sys/reent.h>
6+
#include <sys/errno.h>
7+
#include <sys/types.h>
8+
#include <sys/lv2errno.h>
9+
10+
#include <sys/file.h>
11+
12+
int
13+
_DEFUN(__librt_link_r,(r,old,new),
14+
struct _reent *r _AND
15+
const char *old _AND
16+
const char *new)
17+
{
18+
return lv2errno_r(r,sysLv2FsLink(old,new));
19+
}

ppu/librt/truncate.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <stdio.h>
2+
#include <fcntl.h>
3+
#include <_ansi.h>
4+
#include <_syslist.h>
5+
#include <sys/reent.h>
6+
#include <sys/errno.h>
7+
#include <sys/types.h>
8+
#include <sys/lv2errno.h>
9+
10+
#include <sys/file.h>
11+
12+
int
13+
_DEFUN(__librt_truncate_r,(r,path,len),
14+
struct _reent *r _AND
15+
const char *path _AND
16+
off_t len)
17+
{
18+
return lv2errno_r(r,sysLv2FsTruncate(path,len));
19+
}
20+
21+
int
22+
_DEFUN(__librt_ftruncate_r,(r,fd,len),
23+
struct _reent *r _AND
24+
int fd _AND
25+
off_t len)
26+
{
27+
return lv2errno_r(r,sysLv2FsFtruncate(fd,len));
28+
}

0 commit comments

Comments
 (0)