Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorYaakov Selkowitz <yselkowi@redhat.com>2011-05-18 05:25:41 +0400
committerYaakov Selkowitz <yselkowi@redhat.com>2011-05-18 05:25:41 +0400
commitd470b53c98d32d2371d8d5465f849be11f80a696 (patch)
treecc44f6b2bd2b0947a0efd04b919e9e6653e0f9e8 /winsup
parent7dd9fa7ffbcda908ac3724d5c41a98213d5c0598 (diff)
* cygwin.din (error): Export.
(error_at_line): Export. (error_message_count): Export. (error_one_per_line): Export. (error_print_progname): Export. * errno.cc (error_message_count): Define. (error_one_per_line): Define. (error_print_progname): Define. (_verror): New static function. (error): New function. (error_at_line): New function. * posix.sgml (std-gnu): Add error, error_at_line. * include/error.h: New header. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog17
-rw-r--r--winsup/cygwin/cygwin.din5
-rw-r--r--winsup/cygwin/errno.cc71
-rw-r--r--winsup/cygwin/include/cygwin/version.h4
-rw-r--r--winsup/cygwin/include/error.h30
-rw-r--r--winsup/cygwin/posix.sgml2
6 files changed, 128 insertions, 1 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 61060a8cc..a0e44ea81 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,22 @@
2011-05-17 Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
+ * cygwin.din (error): Export.
+ (error_at_line): Export.
+ (error_message_count): Export.
+ (error_one_per_line): Export.
+ (error_print_progname): Export.
+ * errno.cc (error_message_count): Define.
+ (error_one_per_line): Define.
+ (error_print_progname): Define.
+ (_verror): New static function.
+ (error): New function.
+ (error_at_line): New function.
+ * posix.sgml (std-gnu): Add error, error_at_line.
+ * include/error.h: New header.
+ * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
+
+2011-05-17 Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
+
* cygwin.din (clock_getcpuclockid): Export.
(pthread_getcpuclockid): Export.
* hires.h (PID_TO_CLOCKID): New macro.
diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din
index 8d1e7032e..e4f07613b 100644
--- a/winsup/cygwin/cygwin.din
+++ b/winsup/cygwin/cygwin.din
@@ -10,6 +10,9 @@ __ctype_ptr__ DATA
__cygwin_environ DATA
__cygwin_user_data DATA
_daylight DATA
+error_message_count DATA
+error_one_per_line DATA
+error_print_progname DATA
h_errno DATA
_impure_ptr DATA
in6addr_any DATA
@@ -389,6 +392,8 @@ erff NOSIGFE
_erff = erff NOSIGFE
err SIGFE
__errno NOSIGFE
+error SIGFE
+error_at_line SIGFE
errx SIGFE
euidaccess SIGFE
execl SIGFE
diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc
index 79ec048ed..e881fc649 100644
--- a/winsup/cygwin/errno.cc
+++ b/winsup/cygwin/errno.cc
@@ -13,6 +13,13 @@ details. */
#define sys_nerr FOOsys_nerr
#define _sys_errlist FOO_sys_errlist
#define strerror_r FOO_strerror_r
+#define __INSIDE_CYGWIN__
+#include <errno.h>
+#include <error.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include "winsup.h"
#include "cygtls.h"
#include "ntdll.h"
@@ -417,3 +424,67 @@ __xpg_strerror_r (int errnum, char *buf, size_t n)
strcpy (buf, error);
return result;
}
+
+unsigned int error_message_count = 0;
+int error_one_per_line = 0;
+void (*error_print_progname) (void) = NULL;
+
+static void
+_verror (int status, int errnum, const char *filename, unsigned int lineno, const char *fmt, va_list ap)
+{
+ error_message_count++;
+
+ fflush (stdout);
+
+ if (error_print_progname)
+ (*error_print_progname) ();
+ else
+ fprintf (stderr, "%s:%s", program_invocation_name, filename ? "" : " ");
+
+ if (filename)
+ fprintf (stderr, "%s:%d: ", filename, lineno);
+
+ vfprintf (stderr, fmt, ap);
+
+ if (errnum != 0)
+ fprintf (stderr, ": %s", strerror (errnum));
+
+ fprintf (stderr, "\n");
+
+ if (status != 0)
+ exit (status);
+}
+
+extern "C" void
+error (int status, int errnum, const char *fmt, ...)
+{
+ va_list ap;
+ va_start (ap, fmt);
+ _verror (status, errnum, NULL, 0, fmt, ap);
+ va_end (ap);
+}
+
+extern "C" void
+error_at_line (int status, int errnum, const char *filename, unsigned int lineno, const char *fmt, ...)
+{
+ va_list ap;
+
+ if (error_one_per_line != 0)
+ {
+ static const char *last_filename;
+ static unsigned int last_lineno;
+
+ /* strcmp(3) will SEGV if filename or last_filename are NULL */
+ if (lineno == last_lineno
+ && ((!filename && !last_filename)
+ || (filename && last_filename && strcmp (filename, last_filename) == 0)))
+ return;
+
+ last_filename = filename;
+ last_lineno = lineno;
+ }
+
+ va_start (ap, fmt);
+ _verror (status, errnum, filename, lineno, fmt, ap);
+ va_end (ap);
+}
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index fed1c0ccc..da1ac7463 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -414,12 +414,14 @@ details. */
pthread_attr_setstack, pthread_attr_setstackaddr.
246: Add CLOCK_PROCESS_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID.
Export clock_getcpuclockid, pthread_getcpuclockid.
+ 247: Export error, error_at_line, error_message_count, error_one_per_line,
+ error_print_progname.
*/
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
#define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 246
+#define CYGWIN_VERSION_API_MINOR 247
/* There is also a compatibity version number associated with the
shared memory regions. It is incremented when incompatible
diff --git a/winsup/cygwin/include/error.h b/winsup/cygwin/include/error.h
new file mode 100644
index 000000000..3f7f29a11
--- /dev/null
+++ b/winsup/cygwin/include/error.h
@@ -0,0 +1,30 @@
+/* error.h: GNU error reporting functions
+
+ Copyright 2011 Red Hat, Inc.
+
+This file is part of Cygwin.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+#ifndef _ERROR_H
+#define _ERROR_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+void error (int, int, const char *, ...);
+void error_at_line (int, int, const char *, unsigned int, const char *, ...);
+
+extern unsigned int error_message_count;
+extern int error_one_per_line;
+extern void (*error_print_progname) (void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ERROR_H */
diff --git a/winsup/cygwin/posix.sgml b/winsup/cygwin/posix.sgml
index f6ec0b0e2..862ef73a8 100644
--- a/winsup/cygwin/posix.sgml
+++ b/winsup/cygwin/posix.sgml
@@ -1089,6 +1089,8 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008).</para>
envz_merge
envz_remove
envz_strip
+ error
+ error_at_line
euidaccess
execvpe
exp10