shithub: scc

Download patch

ref: 6bebff844a6aa4f95675dc7beae9ff24d06464b0
parent: 7fd2f3863ae891c34bb5e87679b256c48843c543
author: Hiltjo Posthuma <hiltjo@codemadness.org>
date: Thu May 19 14:46:41 EDT 2022

libc: stdio: add rename()

--- a/src/libc/arch/amd64/openbsd/.gitignore
+++ b/src/libc/arch/amd64/openbsd/.gitignore
@@ -11,6 +11,7 @@
 _lseek.s
 _open.s
 _read.s
+_rename.s
 _sigaction.s
 _sys_errlist.c
 _unlink.s
--- a/src/libc/arch/amd64/openbsd/Makefile
+++ b/src/libc/arch/amd64/openbsd/Makefile
@@ -18,6 +18,7 @@
 	_lseek.$O\
 	_open.$O\
 	_read.$O\
+	_rename.$O\
 	_sigaction.$O\
 	_unlink.$O\
 	_write.$O\
--- a/src/libc/arch/amd64/openbsd/syscall.lst
+++ b/src/libc/arch/amd64/openbsd/syscall.lst
@@ -16,4 +16,5 @@
 59	_execve	3
 67	_gettimeofday	2
 122	_kill	2
+128	_rename	2
 198	_lseek	3
--- a/src/libc/objs/amd64-openbsd.mk
+++ b/src/libc/objs/amd64-openbsd.mk
@@ -15,6 +15,7 @@
 	arch/amd64/openbsd/_lseek.$O\
 	arch/amd64/openbsd/_open.$O\
 	arch/amd64/openbsd/_read.$O\
+	arch/amd64/openbsd/_rename.$O\
 	arch/amd64/openbsd/_sigaction.$O\
 	arch/amd64/openbsd/_unlink.$O\
 	arch/amd64/openbsd/_wait4.$O\
--- a/src/libc/objs/common-objs.mk
+++ b/src/libc/objs/common-objs.mk
@@ -51,6 +51,7 @@
 	stdio/putchar.$O\
 	stdio/puts.$O\
 	stdio/remove.$O\
+	stdio/rename.$O\
 	stdio/rewind.$O\
 	stdio/setbuf.$O\
 	stdio/setvbuf.$O\
--- a/src/libc/stdio/Makefile
+++ b/src/libc/stdio/Makefile
@@ -33,6 +33,7 @@
 	putchar.$O\
 	puts.$O\
 	remove.$O\
+	rename.$O\
 	rewind.$O\
 	setbuf.$O\
 	setvbuf.$O\
--- /dev/null
+++ b/src/libc/stdio/rename.c
@@ -1,0 +1,11 @@
+#include <stdio.h>
+
+#include "../syscall.h"
+
+#undef rename
+
+int
+rename(const char *old, const char *new)
+{
+	return _rename(old, new);
+}
--- a/src/libc/syscall.h
+++ b/src/libc/syscall.h
@@ -7,3 +7,4 @@
 extern int _write(int, void *, size_t);
 extern int _access(const char *, int);
 extern long _lseek(int, long, int);
+extern int _rename(const char *, const char *);