lib: c: re-organise into separate static modules, plus a single shared library
This commit is contained in:
54
lib/libc/core/errno/errno.c
Normal file
54
lib/libc/core/errno/errno.c
Normal file
@@ -0,0 +1,54 @@
|
||||
#include <errno.h>
|
||||
#include <mango/status.h>
|
||||
|
||||
#if defined(BUILD_STATIC)
|
||||
int __set_errno(int err)
|
||||
{
|
||||
return -err;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BUILD_SHARED)
|
||||
int __set_errno(int err)
|
||||
{
|
||||
/* TODO */
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int __errno_from_kern_status(unsigned int err)
|
||||
{
|
||||
switch (err) {
|
||||
case KERN_OK:
|
||||
return SUCCESS;
|
||||
case KERN_UNIMPLEMENTED:
|
||||
return ENOSYS;
|
||||
case KERN_NAME_EXISTS:
|
||||
return EEXIST;
|
||||
case KERN_INVALID_ARGUMENT:
|
||||
return EINVAL;
|
||||
case KERN_UNSUPPORTED:
|
||||
return ENOTSUP;
|
||||
case KERN_NO_MEMORY:
|
||||
return ENOMEM;
|
||||
case KERN_NO_ENTRY:
|
||||
return ENOENT;
|
||||
case KERN_WOULD_BLOCK:
|
||||
return EWOULDBLOCK;
|
||||
case KERN_NO_DEVICE:
|
||||
return ENODEV;
|
||||
case KERN_DEVICE_STUCK:
|
||||
case KERN_IO_ERROR:
|
||||
return EIO;
|
||||
case KERN_FATAL_ERROR:
|
||||
return ENXIO;
|
||||
case KERN_BAD_STATE:
|
||||
return EPERM;
|
||||
case KERN_MEMORY_FAULT:
|
||||
return EFAULT;
|
||||
case KERN_ACCESS_DENIED:
|
||||
return EACCES;
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user