From xemacs-m  Tue Feb  4 14:46:40 1997
Received: from uni-kl.de (mmdf@news.uni-kl.de [131.246.136.51])
	by xemacs.org (8.8.5/8.8.5) with SMTP id OAA08139
	for <xemacs-beta@xemacs.org>; Tue, 4 Feb 1997 14:46:39 -0600 (CST)
Received: from uklirb.informatik.uni-kl.de by news.uni-kl.de id aa15845;
          4 Feb 97 21:46 MET
Received: from gentzen.informatik.uni-kl.de by uklirb.informatik.uni-kl.de
          id aa14444; 4 Feb 97 21:39 MET
To: xemacs-beta@xemacs.org
Subject: GNU libc 2.0 & xemacs-19.15-beta92: First problem
Reply-To: jaeger@informatik.uni-kl.de
CC: jaeger@informatik.uni-kl.de
Date: 4 Feb 1997 21:38:24 +0100
From: jaeger@informatik.uni-kl.de
Message-ID:  <9702042139.aa14444@uklirb.informatik.uni-kl.de>


Hi,

src/database.c defines starting with line 78:
struct database_struct
{
  struct lcrecord_header header;
  Lisp_Object fname;
  XEMACS_DB_TYPE type;
  int mode;
  int ackcess;
  int errno;
  void *db_handle;
  DB_FUNCS *funcs;
};

in glibc2 errno is a makro which expands to a function. This is needed
for the thread support in glibc2. I think that errno has to be changed
to some other name (I renamed it to dberrno and have appended a
patch), since errno is reserved in POSIX.1:1996 as a symbol.

I quote in the following POSIX.1:1996:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2.4 Error Numbers

...

Some functions may provide the error number in a variable accessed
through the symbol `errno'.  The symbol `errno' is defined by
including the header <errno.h>, as specified by the C standard.

...

B.2.3.1 Alternative Solutions for Per-Thread errno

The usual implementation of `errno' as a single global variable does
not work in a multithreaded environment.  In such an environment, a
thread may make a POSIX.1 call and get a -1 error return, but before
that thread can check the value of `errno', another thread might have
made a second POSIX.1 call that also set `errno'.  This behaviour is
unacceptable in robust programs.  There were a number of alternatives
that were considered for handling the `errnp' problem:

 (1) Implement `errno' as a per-thread integer variable

 (2) Implement `errno' as a service that can access the per-thread
     error number.

 (3) Change all POSIX.1 calls to accept an extra status argument and
     avoid setting `errno'.

 (4) Change all POSIX.1 calls to raise a language exception.

... The second option offers compatibility with existing code that
uses the C Standard language header <errno.h> to define the symbol
`errno'.  in this option, `errno' may be a macro defined:

	#define errno	(*__errno())
	extern int *__errno();

This option may be implemented as a per-thread variable whereby an
`errno' field is allocated in the user space object representing a
thread, and whereby the function __errno() makes a system call to
determine the location of its user space object and returns the
address of the `errno' field of that object. ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

expect some more reports while I'm compiling xemacs-19.15-beta92...

Cheers
Andreas

--- database.c	Sat Jan 11 22:11:05 1997
+++ /usr/glibc/src/xemacs-19.15-betaXX/src/database.c	Tue Feb  4 10:07:16 1997
@@ -71,7 +71,7 @@
   XEMACS_DB_TYPE type;
   int mode;
   int ackcess;
-  int errno;
+  int dberrno;
   void *db_handle;
   DB_FUNCS *funcs;
 };
@@ -100,7 +100,7 @@
   dbase->db_handle = NULL;
   dbase->ackcess = 0;
   dbase->mode = 0;
-  dbase->errno = 0;
+  dbase->dberrno = 0;
   dbase->type = DB_UNKNOWN;
   return (dbase);
 }
@@ -329,7 +329,7 @@
 static Lisp_Object
 dbm_lasterr (struct database_struct *dbp)
 {
-  char *temp = strerror (dbp->errno);
+  char *temp = strerror (dbp->dberrno);
   return (make_string ((unsigned char *) temp, strlen (temp)));
 }
 
@@ -412,7 +412,7 @@
 static Lisp_Object
 berkdb_lasterr (struct database_struct *dbp)
 {
-  char *temp = strerror (dbp->errno);
+  char *temp = strerror (dbp->dberrno);
   return (make_string ((unsigned char *) temp, strlen (temp)));
 }
 
@@ -431,7 +431,7 @@
   if (!status)
     return (make_string (valdatum.data, valdatum.size));
 
-  db->errno = (status == 1) ? -1 : errno;
+  db->dberrno = (status == 1) ? -1 : errno;
   return (Qnil);
 }
 
@@ -451,7 +451,7 @@
   valdatum.size = XSTRING_LENGTH (val);
   status = dbp->put (dbp, &keydatum, &valdatum, NILP (replace)
		     ? R_NOOVERWRITE : 0);
-  db->errno = (status == 1) ? -1 : errno;
+  db->dberrno = (status == 1) ? -1 : errno;
   return status;
 }
 
@@ -469,7 +469,7 @@
   if (!status)
     return 0;
   
-  db->errno = (status == 1) ? -1 : errno;
+  db->dberrno = (status == 1) ? -1 : errno;
   return 1;
 }
 


-- 
 Andreas Jaeger   aj@arthur.pfalz.de    jaeger@informatik.uni-kl.de
  Altenwoogstr. 31      67655 Kaiserslautern, Germany
   Phone +49 631 3403051 Fax/Modem +49 631 3403052
    http://www.student.uni-kl.de/~ajaeger/

