glibc should be Sys V ABI compliant, hence implement __assert()

Martin Buchholz martin@xemacs.org
Wed Jul 12 05:32:00 GMT 2000


ABI standards, though not as important as source standards, are still
standards.

The System V ABI (available from
ftp://ftp.linux.sgi.com/pub/linux/mips/doc/ABI and elsewhere)
specifies a function __assert

I think both gcc (in libgcc) and glibc (in libc.a) should implement
__assert.

If its existence in a standard is not a good enough reason, here is an
actual bug:  this is required to allow glibc to replace libc on
Solaris.  Certainly glibcers will consider this a noble goal.

Quote: "Porting the library is not hard."  Consider this a start of
the Solaris port.

Of course, glibc also needs to implement other symbols in
Solaris libc for binary compatibility with Solaris.  If they are not
already in glibc, most can probably be copied from libgcc.

ObLegal: I hereby place this message in the public domain.

(martin@lasker) ~cdx/import/libc $ cvs-diff

Index: ./assert/Makefile
===================================================================
RCS file: /cvs/libc/assert/Makefile,v
retrieving revision 1.8
diff -u -w -r1.8 Makefile
--- ./assert/Makefile	2000/07/01 05:16:28	1.8
+++ ./assert/Makefile	2000/07/12 11:40:11
@@ -22,7 +22,7 @@
 subdir	:= assert
 headers	:= assert.h
 
-routines := assert assert-perr
+routines := assert assert-perr assert-compat
 tests := test-assert test-assert-perr
 
 include ../Rules
(martin@lasker) ~cdx/import/libc $ cat assert/assert-compat.c
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <sysdep.h>
#include <libintl.h>

#ifdef USE_IN_LIBIO
# include <libio/iolibio.h>
# define fflush(s) _IO_fflush (s)
#endif

/* This function is provided to comply with the SYS V ABI */
void
__assert (const char *expression, const char *filename, unsigned int line)
{
  (void) fprintf (stderr, _("%s:%u: failed assertion `%s'\n"),
		  filename, line, expression);
  (void) fflush (stderr);

  abort ();
}


More information about the Gcc-bugs mailing list