shithub: mc

Download patch

ref: 590fccdc474d26f6b004376e4423536b590ca000
parent: 5904f620eea9c77d9cc7a32553b30d87b1543ae3
author: Ori Bernstein <[email protected]>
date: Sun Dec 14 20:29:59 EST 2014

Add errno codes.

    Still a touch ugly to use, but it works.

--- a/libstd/Makefile
+++ b/libstd/Makefile
@@ -1,6 +1,7 @@
 SYSLIB=sys
 SYSSRC= \
 	sys.myr \
+	syserrno.myr \
 	systypes.myr \
 	ifreq.myr \
 
@@ -23,6 +24,7 @@
 	dir.myr \
 	endian.myr \
 	env.myr \
+	errno.myr \
 	execvp.myr \
 	extremum.myr \
 	fltbits.myr \
@@ -35,6 +37,7 @@
 	intparse.myr \
 	ipparse.myr \
 	mk.myr \
+	mkpath.myr \
 	now.myr \
 	option.myr \
 	optparse.myr \
--- a/libstd/bldfile
+++ b/libstd/bldfile
@@ -5,6 +5,7 @@
 	syscall+freebsd-x64.s
 	syscall+linux-x64.s
 	syscall+osx-x64.s
+        syserrno+linux.myr
 	systypes.myr
 	ifreq+freebsd.myr
 	ifreq+linux.myr
@@ -25,6 +26,7 @@
 	die.myr
 	endian.myr
 	env.myr
+        errno.myr
 	execvp.myr
 	extremum.myr
 	fltbits.myr
@@ -37,6 +39,7 @@
 	intparse.myr
 	ipparse.myr
 	mk.myr
+        mkpath.myr
 	now.myr
 	option.myr
 	optparse.myr
--- /dev/null
+++ b/libstd/errno.myr
@@ -1,0 +1,40 @@
+use "syserrno.use"
+
+pkg std =
+	type errno = int
+
+	const Eperm	: errno = sys.Eperm	castto(errno)
+	const Enoent	: errno = sys.Enoent	castto(errno)
+	const Esrch	: errno = sys.Esrch	castto(errno)
+	const Eintr	: errno = sys.Eintr	castto(errno)
+	const Eio	: errno = sys.Eio	castto(errno)
+	const Enxio	: errno = sys.Enxio	castto(errno)
+	const E2big	: errno = sys.E2big	castto(errno)
+	const Enoexec	: errno = sys.Enoexec	castto(errno)
+	const Ebadf	: errno = sys.Ebadf	castto(errno)
+	const Echild	: errno = sys.Echild	castto(errno)
+	const Eagain	: errno = sys.Eagain	castto(errno)
+	const Enomem	: errno = sys.Enomem	castto(errno)
+	const Eacces	: errno = sys.Eacces	castto(errno)
+	const Efault	: errno = sys.Efault	castto(errno)
+	const Enotblk	: errno = sys.Enotblk	castto(errno)
+	const Ebusy	: errno = sys.Ebusy	castto(errno)
+	const Eexist	: errno = sys.Eexist	castto(errno)
+	const Exdev	: errno = sys.Exdev	castto(errno)
+	const Enodev	: errno = sys.Enodev	castto(errno)
+	const Enotdir	: errno = sys.Enotdir	castto(errno)
+	const Eisdir	: errno = sys.Eisdir	castto(errno)
+	const Einval	: errno = sys.Einval	castto(errno)
+	const Enfile	: errno = sys.Enfile	castto(errno)
+	const Emfile	: errno = sys.Emfile	castto(errno)
+	const Enotty	: errno = sys.Enotty	castto(errno)
+	const Etxtbsy	: errno = sys.Etxtbsy	castto(errno)
+	const Efbig	: errno = sys.Efbig	castto(errno)
+	const Enospc	: errno = sys.Enospc	castto(errno)
+	const Espipe	: errno = sys.Espipe	castto(errno)
+	const Erofs	: errno = sys.Erofs	castto(errno)
+	const Emlink	: errno = sys.Emlink	castto(errno)
+	const Epipe	: errno = sys.Epipe	castto(errno)
+	const Edom	: errno = sys.Edom	castto(errno)
+	const Erange	: errno = sys.Erange	castto(errno)
+;;
--- /dev/null
+++ b/libstd/syserrno+linux.myr
@@ -1,0 +1,38 @@
+pkg sys =
+	type errno = int
+
+	const Eperm	: errno =	 -1	/* Operation not permitted */
+	const Enoent	: errno =	 -2	/* No such file or directory */
+	const Esrch	: errno =	 -3	/* No such process */
+	const Eintr	: errno =	 -4	/* Interrupted system call */
+	const Eio	: errno =	 -5	/* I/O error */
+	const Enxio	: errno =	 -6	/* No such device or address */
+	const E2big	: errno =	 -7	/* Argument list too long */
+	const Enoexec	: errno =	 -8	/* Exec format error */
+	const Ebadf	: errno =	 -9	/* Bad file number */
+	const Echild	: errno =	-10	/* No child processes */
+	const Eagain	: errno =	-11	/* Try again */
+	const Enomem	: errno =	-12	/* Out of memory */
+	const Eacces	: errno =	-13	/* Permission denied */
+	const Efault	: errno =	-14	/* Bad address */
+	const Enotblk	: errno =	-15	/* Block device required */
+	const Ebusy	: errno =	-16	/* Device or resource busy */
+	const Eexist	: errno =	-17	/* File exists */
+	const Exdev	: errno =	-18	/* Cross-device link */
+	const Enodev	: errno =	-19	/* No such device */
+	const Enotdir	: errno =	-20	/* Not a directory */
+	const Eisdir	: errno =	-21	/* Is a directory */
+	const Einval	: errno =	-22	/* Invalid argument */
+	const Enfile	: errno =	-23	/* File table overflow */
+	const Emfile	: errno =	-24	/* Too many open files */
+	const Enotty	: errno =	-25	/* Not a typewriter */
+	const Etxtbsy	: errno =	-26	/* Text file busy */
+	const Efbig	: errno =	-27	/* File too large */
+	const Enospc	: errno =	-28	/* No space left on device */
+	const Espipe	: errno =	-29	/* Illegal seek */
+	const Erofs	: errno =	-30	/* Read-only file system */
+	const Emlink	: errno =	-31	/* Too many links */
+	const Epipe	: errno =	-32	/* Broken pipe */
+	const Edom	: errno =	-33	/* Math argument out of domain of func */
+	const Erange	: errno =	-34	/* Math result not representable */
+;;
--- /dev/null
+++ b/libstd/syserrno.myr
@@ -1,0 +1,38 @@
+pkg sys =
+	type errno = int
+
+	const Eperm	: errno =	 -1	/* Operation not permitted */
+	const Enoent	: errno =	 -2	/* No such file or directory */
+	const Esrch	: errno =	 -3	/* No such process */
+	const Eintr	: errno =	 -4	/* Interrupted system call */
+	const Eio	: errno =	 -5	/* I/O error */
+	const Enxio	: errno =	 -6	/* No such device or address */
+	const E2big	: errno =	 -7	/* Argument list too long */
+	const Enoexec	: errno =	 -8	/* Exec format error */
+	const Ebadf	: errno =	 -9	/* Bad file number */
+	const Echild	: errno =	-10	/* No child processes */
+	const Eagain	: errno =	-11	/* Try again */
+	const Enomem	: errno =	-12	/* Out of memory */
+	const Eacces	: errno =	-13	/* Permission denied */
+	const Efault	: errno =	-14	/* Bad address */
+	const Enotblk	: errno =	-15	/* Block device required */
+	const Ebusy	: errno =	-16	/* Device or resource busy */
+	const Eexist	: errno =	-17	/* File exists */
+	const Exdev	: errno =	-18	/* Cross-device link */
+	const Enodev	: errno =	-19	/* No such device */
+	const Enotdir	: errno =	-20	/* Not a directory */
+	const Eisdir	: errno =	-21	/* Is a directory */
+	const Einval	: errno =	-22	/* Invalid argument */
+	const Enfile	: errno =	-23	/* File table overflow */
+	const Emfile	: errno =	-24	/* Too many open files */
+	const Enotty	: errno =	-25	/* Not a typewriter */
+	const Etxtbsy	: errno =	-26	/* Text file busy */
+	const Efbig	: errno =	-27	/* File too large */
+	const Enospc	: errno =	-28	/* No space left on device */
+	const Espipe	: errno =	-29	/* Illegal seek */
+	const Erofs	: errno =	-30	/* Read-only file system */
+	const Emlink	: errno =	-31	/* Too many links */
+	const Epipe	: errno =	-32	/* Broken pipe */
+	const Edom	: errno =	-33	/* Math argument out of domain of func */
+	const Erange	: errno =	-34	/* Math result not representable */
+;;