mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Split gnu_error(3) and perror(3).
This commit is contained in:
parent
0c43765bbf
commit
d79808f85f
4 changed files with 44 additions and 16 deletions
|
@ -182,7 +182,7 @@ $(CPUDIR)/syscall.o \
|
|||
dirent/fddir-sortix.o \
|
||||
dirent/scandir.o \
|
||||
dlfcn/dlfcn.o \
|
||||
error/errorprint.o \
|
||||
error/gnu_error.o \
|
||||
fcntl/creat.o \
|
||||
fcntl/fcntl.o \
|
||||
fcntl/openat.o \
|
||||
|
@ -244,6 +244,7 @@ stdio/fpipe.o \
|
|||
stdio/freopen.o \
|
||||
stdio/fsetpos.o \
|
||||
stdio/getc.o \
|
||||
stdio/perror.o \
|
||||
stdio/popen.o \
|
||||
stdio/print.o \
|
||||
stdio/putc.o \
|
||||
|
|
|
@ -17,17 +17,17 @@
|
|||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
error/errorprint.cpp
|
||||
Functions for printing error messages to the terminal.
|
||||
error/gnu_error.cpp
|
||||
Prints an error message to stderr and optionally exits the process.
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <error.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
extern "C" void gnu_error(int status, int errnum, const char *format, ...)
|
||||
{
|
||||
|
@ -44,8 +44,3 @@ extern "C" void gnu_error(int status, int errnum, const char *format, ...)
|
|||
if ( status )
|
||||
exit(status);
|
||||
}
|
||||
|
||||
extern "C" void perror(const char* s)
|
||||
{
|
||||
error(0, errno, "%s", s);
|
||||
}
|
|
@ -22,16 +22,16 @@
|
|||
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef _ERROR_H
|
||||
#define _ERROR_H 1
|
||||
#ifndef INCLUDE_ERROR_H
|
||||
#define INCLUDE_ERROR_H
|
||||
|
||||
#include <features.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
void gnu_error(int status, int errnum, const char *format, ...);
|
||||
void gnu_error(int status, int errnum, const char* format, ...);
|
||||
#if __SORTIX_STDLIB_REDIRECTS
|
||||
void error(int status, int errnum, const char *format, ...) asm("gnu_error");
|
||||
void error(int status, int errnum, const char* format, ...) asm("gnu_error");
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
|
32
libc/stdio/perror.cpp
Normal file
32
libc/stdio/perror.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*******************************************************************************
|
||||
|
||||
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
|
||||
|
||||
This file is part of the Sortix C Library.
|
||||
|
||||
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
stdio/perror.cpp
|
||||
Prints a error messages to the terminal.
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
#include <errno.h>
|
||||
#include <error.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C" void perror(const char* s)
|
||||
{
|
||||
error(0, errno, "%s", s);
|
||||
}
|
Loading…
Add table
Reference in a new issue