Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 Apr 1999 22:45:34 +0200
From:      Juergen Lock <nox@jelal.kn-bremen.de>
To:        freebsd-hackers@FreeBSD.ORG
Subject:   strange things happening while trying to update ports/emulators/wine, could use some help...
Message-ID:  <19990417224534.A55834@saturn.kn-bremen.de>

next in thread | raw e-mail | index | archive | help
Using the patches below, and after updating to 3.1-stable, I can get
freecell to run again, but only that: using its help menu (normally
starts winhelp) still makes it die.  But first what happened:

1. configure hangs in:

	checking whether external symbols need an underscore prefix...
and
	checking whether assembler accepts .string...

if i type ^D (EOF) it continues.  both checks assemble .s files and
ktrace'ing reveals they hang in as in a read() from stdin.
they didn't hang on 2.2.8-stable.

2. an ELF wine (the aout executable built on 2.2.8-stable `worked'
as described above) dies on the first call to malloc() (SIGSEGV in
.cerror called from .cbrk called from malloc if i remember right),
it even dies in malloc if i call that as the first thing in main().  huh!?? :)
and when i want to debug that and link libc static (explicit /usr/lib/libc.a
in the Makefiles link line), it works again.  other ports i built since
the 3.1 upgrade and everything else thats ELF and uses libc.so.3 still
runs so it (libc) can't be completely broken on my system...

3. exiting wine always gives:

	wine in free(): warning: junk pointer, too high to make sense.

but that could also be a bug in wine of course.

 Oh and about the fist insn in miscemu/emulate.c: i figured it is
needed for the TRACE line below it only so i simply disabled both,
for now.

 The diffs are against the current wine port in the tree.
Removed files: patches/patch-ar, new files: patches/patch-thread*
If you leave out patches/patch-thread3-elf you can build it on
2.2.8-stable as i first did, but to try out win32 code you'll need
3.1-stable (or maybe -release also works, i don't know.  I also
don't know about -current, sorry)

cvs diff: Diffing .
Index: Makefile
===================================================================
RCS file: /home/cvs/cvs/ports/emulators/wine/Makefile,v
retrieving revision 1.69
diff -u -r1.69 Makefile
--- Makefile	1999/02/20 00:08:36	1.69
+++ Makefile	1999/04/11 20:25:49
@@ -6,9 +6,9 @@
 # $Id: Makefile,v 1.69 1999/02/20 00:08:36 se Exp $
 #
 
-DATE=		990214
+DATE=		990328
 DISTNAME=	Wine-${DATE}
-PKGNAME=	wine-99.02.14
+PKGNAME=	wine-99.03.28
 CATEGORIES=	emulators
 MASTER_SITES=	${MASTER_SITE_SUNSITE}
 MASTER_SITE_SUBDIR=	ALPHA/wine/development
@@ -19,6 +19,7 @@
 
 WRKSRC=		${WRKDIR}/wine-${DATE}
 GNU_CONFIGURE=	yes
+USE_AUTOCONF=	yes
 MAN1=		wine.1
 
 pre-configure:
cvs diff: Diffing files
Index: files/md5
===================================================================
RCS file: /home/cvs/cvs/ports/emulators/wine/files/md5,v
retrieving revision 1.45
diff -u -r1.45 md5
--- md5	1999/02/20 00:08:37	1.45
+++ md5	1999/03/30 17:32:14
@@ -1 +1 @@
-MD5 (Wine-990214.tar.gz) = ee9447f18a19223d5d45e199e6629751
+MD5 (Wine-990328.tar.gz) = c753471f829138d43ab7dde6f20875fd
cvs diff: Diffing patches
cvs diff: cannot find patches/patch-ar
cvs diff: Diffing pkg
Index: patches/patch-thread0
@@ -0,0 +1,65 @@
+Index: configure.in
+@@ -337,23 +337,6 @@
+ AC_SUBST(DLLFLAGS)
+ AC_SUBST(LDSHARED)
+ 
+-dnl **** Check for reentrant libc ****
+-dnl
+-dnl For cross-compiling we blindly assume that libc is reentrant. This is
+-dnl ok since non-reentrant libc is quite rare (mostly old libc5 versions).
+-
+-AC_CACHE_CHECK("for reentrant libc", wine_cv_libc_reentrant,
+-  [AC_TRY_RUN([int myerrno = 0;
+-char buf[256];
+-int *__errno_location(){return &myerrno;}
+-main(){connect(0,buf,255); exit(!myerrno);}],
+-  wine_cv_libc_reentrant=yes, wine_cv_libc_reentrant=no,
+-  wine_cv_libc_reentrant=yes ) ] )
+-if test "$wine_cv_libc_reentrant" = "no" 
+-then
+-  AC_DEFINE(NO_REENTRANT_LIBC)
+-fi
+-
+ dnl **** Check for reentrant X libraries ****
+ dnl
+ dnl This may fail to determine whether X libraries are reentrant if
+@@ -399,12 +382,38 @@
+ 
+ dnl **** Check for functions and header files ****
+ 
+-AC_CHECK_FUNCS(clone getpagesize memmove sendmsg sigaltstack strerror stricmp tcgetattr timegm usleep wait4 waitpid vfscanf)
++AC_CHECK_FUNCS(clone rfork getpagesize memmove sendmsg sigaltstack strerror stricmp tcgetattr timegm usleep wait4 waitpid vfscanf)
+ AC_CHECK_HEADERS(wctype.h sys/syscall.h syscall.h sys/param.h sys/vfs.h sys/mount.h sys/statfs.h float.h linux/cdrom.h linux/ucdrom.h sys/cdio.h sys/filio.h sys/modem.h strings.h sys/strtio.h dlfcn.h unistd.h sys/sockio.h net/if.h netinet/in.h sys/file.h libio.h curses.h ncurses.h elf.h arpa/nameser.h resolv.h)
+ AC_HEADER_STAT()
+ AC_C_CONST()
+ AC_TYPE_SIZE_T()
+ AC_CHECK_SIZEOF(long long,0)
++
++dnl **** Check for reentrant libc ****
++dnl
++dnl For cross-compiling we blindly assume that libc is reentrant. This is
++dnl ok since non-reentrant libc is quite rare (mostly old libc5 versions).
++
++AC_CACHE_CHECK("for reentrant libc", wine_cv_libc_reentrant,
++  [AC_TRY_RUN([int myerrno = 0;
++char buf[256];
++#ifdef HAVE_SYS_PARAM_H
++#include <sys/param.h>
++#endif
++/* how do i check for libc_r on *BSD? */
++#if defined(BSD) && (BSD > 199001)
++char __error();
++main(){exit(0);}
++#else
++int *__errno_location(){return &myerrno;}
++main(){connect(0,buf,255); exit(!myerrno);}
++#endif],
++  wine_cv_libc_reentrant=yes, wine_cv_libc_reentrant=no,
++  wine_cv_libc_reentrant=yes ) ] )
++if test "$wine_cv_libc_reentrant" = "no" 
++then
++  AC_DEFINE(NO_REENTRANT_LIBC)
++fi
+ 
+ dnl **** Check for sendmsg in -lsocket if not found above ****
+ 
Index: patches/patch-thread1
@@ -0,0 +1,546 @@
+Index: configure.in
+@@ -400,7 +400,7 @@
+ #ifdef HAVE_SYS_PARAM_H
+ #include <sys/param.h>
+ #endif
+-/* how do i check for libc_r on *BSD? */
++/* how do i check for reentrant libc on *BSD? */
+ #if defined(BSD) && (BSD > 199001)
+ char __error();
+ main(){exit(0);}
+Index: include/thread.h
+@@ -17,11 +17,10 @@
+ 
+ /* This is what we will use on *BSD, once threads using rfork() get
+  * implemented:
+- *
+- * #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
+- * #define HAVE_RFORK
+- * #endif
+  */
++#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
++#define HAVE_RFORK
++#endif
+ 
+ #if (defined(HAVE_CLONE_SYSCALL) || defined(HAVE_RFORK)) && !defined(NO_REENTRANT_LIBC)
+ #define USE_THREADS
+Index: miscemu/emulate.c
+@@ -67,8 +67,10 @@
+              * wrong.
+              */
+            __asm__ __volatile__("frndint");
++#ifndef __FreeBSD__
+            __asm__ __volatile__("fist %0;wait" : "=m" (dw) : : "memory");
+             TRACE(int,"On top of stack is %ld\n",dw);
++#endif
+         }
+         break;
+ 
+Index: scheduler/Makefile.in
+@@ -17,7 +17,12 @@
+ 	synchro.c \
+ 	sysdeps.c \
+ 	syslevel.c \
+-	thread.c
++	thread.c \
++	spinlock.c
++
++ASM_SRCS = \
++	_atomic_lock.S \
++	rf.S
+ 
+ all: $(MODULE).o
+ 
+Index: scheduler/sysdeps.c
+@@ -80,6 +80,10 @@
+  */
+ static void SYSDEPS_StartThread( THDB *thdb )
+ {
++#ifdef HAVE_RFORK
++    extern int __isthreaded;
++    __isthreaded = 1;
++#endif  /* HAVE_RFORK */
+     SET_CUR_THREAD( thdb );
+     CLIENT_InitThread();
+     thdb->startup();
+@@ -107,7 +111,25 @@
+ #endif
+ 
+ #ifdef HAVE_RFORK
++#if 1
++    extern int __isthreaded;
++    int pid;
++#ifndef RFTHREAD
++#define RFTHREAD 0
++#endif
++    switch(pid = thrfork(RFPROC|RFMEM|RFTHREAD, thread->teb.stack_top,
++                     SYSDEPS_StartThread, thread, 0, 0)) {
++	case -1:
++	    return 0;
++	default:
++	    /* FIXME: close the child socket in the parent process */
++/*	    close( thread->socket );*/
++	    __isthreaded = 1;
++	    break;
++    }
++#else
+     FIXME(thread, "Threads using rfork() not implemented\n" );
++#endif
+ #endif
+ 
+ #else  /* !USE_THREADS */
+Index: scheduler/spinlock.c	Sat Apr 10 15:43:53 1999
+@@ -0,0 +1,114 @@
++/*
++ * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ *    notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ *    notice, this list of conditions and the following disclaimer in the
++ *    documentation and/or other materials provided with the distribution.
++ * 3. All advertising materials mentioning features or use of this software
++ *    must display the following acknowledgement:
++ *	This product includes software developed by John Birrell.
++ * 4. Neither the name of the author nor the names of any co-contributors
++ *    may be used to endorse or promote products derived from this software
++ *    without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ * $Id: uthread_spinlock.c,v 1.4.2.1 1998/11/04 08:42:12 tg Exp $
++ *
++ */
++
++#include <stdio.h>
++#include <sys/time.h>
++#include <sys/syscall.h>
++#include <sched.h>
++#include <unistd.h>
++#include <pthread.h>
++#include <string.h>
++#include "spinlock.h"
++
++#ifndef SYS_yield
++#define SYS_yield       321
++#endif
++
++extern char *__progname;
++
++/*
++ * Lock a location for the running thread. Yield to allow other
++ * threads to run if this thread is blocked because the lock is
++ * not available. Note that this function does not sleep. It
++ * assumes that the lock will be available very soon.
++ */
++void
++_spinlock(spinlock_t *lck)
++{
++	/*
++	 * Try to grab the lock and loop if another thread grabs
++	 * it before we do.
++	 */
++	while(_atomic_lock(&lck->access_lock)) {
++		/* Give up the time slice: */
++		syscall(SYS_yield);
++
++		/* Check if already locked by the running thread: */
++		if (lck->lock_owner == (long) getpid())
++			return;
++	}
++
++	/* The running thread now owns the lock: */
++	lck->lock_owner = (long) getpid();
++}
++
++/*
++ * Lock a location for the running thread. Yield to allow other
++ * threads to run if this thread is blocked because the lock is
++ * not available. Note that this function does not sleep. It
++ * assumes that the lock will be available very soon.
++ *
++ * This function checks if the running thread has already locked the
++ * location, warns if this occurs and creates a thread dump before
++ * returning.
++ */
++void
++_spinlock_debug(spinlock_t *lck, char *fname, int lineno)
++{
++	/*
++	 * Try to grab the lock and loop if another thread grabs
++	 * it before we do.
++	 */
++	while(_atomic_lock(&lck->access_lock)) {
++		/* Give up the time slice: */
++		syscall(SYS_yield);
++
++		/* Check if already locked by the running thread: */
++		if (lck->lock_owner == (long) getpid()) {
++			char str[256];
++			snprintf(str, sizeof(str), "%s - Warning: Thread %p attempted to lock %p from %s (%d) which it had already locked in %s (%d)\n", __progname, getpid(), lck, fname, lineno, lck->fname, lck->lineno);
++			write(2,str,strlen(str));
++
++			/* Create a thread dump to help debug this problem: */
++			/*_thread_dump_info();*/
++			return;
++		}
++	}
++
++	/* The running thread now owns the lock: */
++	lck->lock_owner = (long) getpid();
++	lck->fname = fname;
++	lck->lineno = lineno;
++}
+Index: scheduler/_atomic_lock.S	Sat Apr 10 15:08:49 1999
+@@ -0,0 +1,45 @@
++/*
++ * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>.
++ * All rights reserved.
++ * copyright Douglas Santry 1996
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the above copyright is retained
++ * in the source form.
++ *
++ * THIS SOFTWARE IS PROVIDED BY Douglas Santry AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE  
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE   
++ * ARE DISCLAIMED.  IN NO EVENT SHALL Douglas Santry OR CONTRIBUTORS BE LIABLE 
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL   
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS      
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF  
++ * SUCH DAMAGE.    
++ *
++ * $Id: _atomic_lock.S,v 1.1.2.1 1998/11/04 08:42:08 tg Exp $
++ *
++ */
++
++#if defined(LIBC_RCS) && !defined(lint)
++	.text
++	.asciz "$Id: _atomic_lock.S,v 1.1.2.1 1998/11/04 08:42:08 tg Exp $"
++#endif /* LIBC_RCS and not lint */
++
++#include <machine/asm.h>
++
++/*
++ * Atomicly lock a location with an identifier provided the location
++ * is not currently locked.
++ *
++ * long _atomic_lock(long *);
++ * eax will contain the return value (zero if lock obtained).
++ */
++ENTRY(_atomic_lock)
++	movl	4(%esp), %ecx
++	movl	$1, %eax
++	xchg	%eax, (%ecx)
++	ret
++
+Index: scheduler/rf.S	Sat Apr 10 19:31:18 1999
+@@ -0,0 +1,129 @@
++	.file	"rf.S"
++#include <sys/syscall.h>
++#include <machine/asm.h>
++#include "SYS.h"
++#define KERNEL
++#include <sys/errno.h>
++#undef KERNEL
++
++#undef DEBUG
++
++/*
++ *        8      12     16        20        24       28
++ * _rfork(flags, stack, startrtn, startarg, userrtn, arg);
++ *
++ * flags: RF* flags for rfork in unistd.h.
++ * subr:  subroutine to run as a thread.
++ * stack: top of stack for thread.
++ * arg:   argument to thread.
++ */
++.stabs "rf.S",100,0,0,Ltext0
++	.text
++Ltext0:
++	.type	_thrfork,@function
++	.stabd 68,0,1
++ENTRY(thrfork)
++	pushl	%ebp
++	movl	%esp, %ebp
++	pushl	%esi
++
++	/*
++	 * Push thread info onto the new thread's stack
++	 */
++	movl	12(%ebp), %esi	/ get stack addr
++
++	subl	$4, %esi
++	movl	28(%ebp), %eax	/ get user argument
++	movl	%eax, (%esi)
++
++	subl	$4, %esi
++	movl	24(%ebp), %eax	/ get user thread address
++	movl	%eax, (%esi)
++
++	subl	$4, %esi
++	movl	20(%ebp), %eax	/ get internal argument
++	movl	%eax, (%esi)
++
++	subl	$4, %esi
++	movl	16(%ebp), %eax	/ get internal subroutine
++	movl	%eax, (%esi)
++
++	.stabd 68,0,2
++	/*
++	 * Prepare and execute rfork
++	 */
++	pushl	8(%ebp)
++	pushl	%esi
++
++	leal	SYS_rfork, %eax
++	KERNCALL
++	jb 	2f
++
++	.stabd 68,0,3
++	/*
++	 * Check to see if we are in the parent or child
++	 */
++	cmpl	$0, %edx
++	jnz	1f
++	addl	$8, %esp
++	popl	%esi
++	movl	%ebp, %esp
++	popl	%ebp
++	ret
++	.p2align 2
++
++	/*
++	 * If we are in the child (new thread), then
++	 * set-up the call to the internal subroutine.  If it
++	 * returns, then call __exit.
++	 */
++	.stabd 68,0,4
++1:
++	movl	%esi,%esp
++#ifdef DEBUG
++	movl	%esp, _stackaddr
++	movl	(%esp), %eax
++	movl	%eax, _stack
++	movl	4(%esp), %eax
++	movl	%eax,_stack+4
++	movl	8(%esp), %eax
++	movl	%eax,_stack+8
++	movl	12(%esp), %eax
++	movl	%eax,_stack+12
++#endif
++	popl	%eax 
++#ifdef DEBUG
++	movl	%eax,_fcn
++#endif
++	call	%eax
++	addl	$12, %esp
++
++	/*
++	 * Exit system call
++	 */
++	call	PIC_PLT(__exit)
++
++	.stabd 68,0,5
++2:	addl	$8, %esp
++	popl	%esi
++	movl	%ebp, %esp
++	popl	%ebp
++	jmp	PIC_PLT(HIDENAME(cerror))
++
++.stabs "thrfork:f67",36,0,6,_thrfork
++Lfe1:
++	.size	 _thrfork,Lfe1-_thrfork
++
++#ifdef DEBUG
++	.data
++	.globl	_stack
++_stack:	.long	0
++	.long	0
++	.long	0
++	.long	0
++	.long	0
++	.globl	_stackaddr
++_stackaddr:	.long	0
++	.globl	_fcn
++_fcn:	.long	0
++#endif
+Index: scheduler/spinlock.h
+@@ -0,0 +1,71 @@
++/*
++ * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>.
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ *    notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ *    notice, this list of conditions and the following disclaimer in the
++ *    documentation and/or other materials provided with the distribution.
++ * 3. All advertising materials mentioning features or use of this software
++ *    must display the following acknowledgement:
++ *	This product includes software developed by John Birrell.
++ * 4. Neither the name of the author nor the names of any co-contributors
++ *    may be used to endorse or promote products derived from this software
++ *    without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ * $Id: spinlock.h,v 1.3.2.1 1998/11/04 08:42:02 tg Exp $
++ *
++ * Lock definitions used in both libc and libpthread.
++ *
++ */
++
++#ifndef _SPINLOCK_H_
++#define _SPINLOCK_H_
++#include <sys/cdefs.h>
++#include <sys/types.h>
++
++/*
++ * Lock structure with room for debugging information.
++ */
++typedef struct {
++	volatile long	access_lock;
++	volatile long	lock_owner;
++	volatile char	*fname;
++	volatile int	lineno;
++} spinlock_t;
++
++#define	_SPINLOCK_INITIALIZER	{ 0, 0, 0, 0 }
++
++#define _SPINUNLOCK(_lck)	(_lck)->access_lock = 0
++#ifdef	_LOCK_DEBUG
++#define	_SPINLOCK(_lck)		_spinlock_debug(_lck, __FILE__, __LINE__)
++#else
++#define	_SPINLOCK(_lck)		_spinlock(_lck)
++#endif
++
++/*
++ * Thread function prototype definitions:
++ */
++__BEGIN_DECLS
++long	_atomic_lock __P((volatile long *));
++void	_spinlock __P((spinlock_t *));
++void	_spinlock_debug __P((spinlock_t *, char *, int));
++__END_DECLS
++
++#endif /* _SPINLOCK_H_ */
+Index: scheduler/SYS.h
+@@ -0,0 +1,86 @@
++/*-
++ * Copyright (c) 1990 The Regents of the University of California.
++ * All rights reserved.
++ *
++ * This code is derived from software contributed to Berkeley by
++ * William Jolitz.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ *    notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ *    notice, this list of conditions and the following disclaimer in the
++ *    documentation and/or other materials provided with the distribution.
++ * 3. All advertising materials mentioning features or use of this software
++ *    must display the following acknowledgement:
++ *	This product includes software developed by the University of
++ *	California, Berkeley and its contributors.
++ * 4. Neither the name of the University nor the names of its contributors
++ *    may be used to endorse or promote products derived from this software
++ *    without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ *	from: @(#)SYS.h	5.5 (Berkeley) 5/7/91
++ *
++ *	$Id: SYS.h,v 1.7.2.2 1997/12/28 19:40:43 steve Exp $
++ */
++
++#include <sys/syscall.h>
++#include <machine/asm.h>
++
++#define	SYSCALL(x)	2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \
++			ENTRY(x); lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b
++#define	RSYSCALL(x)	SYSCALL(x); ret
++
++#define	PSEUDO(x,y)	ENTRY(x); lea __CONCAT(SYS_,y), %eax; KERNCALL; ret
++/* gas messes up offset -- although we don't currently need it, do for BCS */
++#define	LCALL(x,y)	.byte 0x9a ; .long y; .word x
++
++/*
++ * Design note:
++ *
++ * The macros PSYSCALL() and PRSYSCALL() are intended for use where a
++ * syscall needs to be renamed in the threaded library. When building
++ * a normal library, they default to the traditional SYSCALL() and
++ * RSYSCALL(). This avoids the need to #ifdef _THREAD_SAFE everywhere
++ * that the renamed function needs to be called.
++ */
++#if 0 /*def _THREAD_SAFE*/
++/*
++ * For the thread_safe versions, we prepend _thread_sys_ to the function
++ * name so that the 'C' wrapper can go around the real name.
++ */
++#define	PSYSCALL(x)	2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \
++			ENTRY(__CONCAT(_thread_sys_,x)); \
++			lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b
++#define	PRSYSCALL(x)	PSYSCALL(x); ret
++#define	PPSEUDO(x,y)	ENTRY(__CONCAT(_thread_sys_,x)); \
++			lea __CONCAT(SYS_,y), %eax; KERNCALL; ret
++#else
++/*
++ * The non-threaded library defaults to traditional syscalls where
++ * the function name matches the syscall name.
++ */
++#define	PSYSCALL(x)	SYSCALL(x)
++#define	PRSYSCALL(x)	RSYSCALL(x)
++#define	PPSEUDO(x,y)	PSEUDO(x,y)
++#endif
++
++#ifdef __ELF__
++#define KERNCALL	int $0x80	/* Faster */
++#else
++#define KERNCALL	LCALL(7,0)	/* The old way */
++#endif
Index: patches/patch-thread2
@@ -0,0 +1,10 @@
+Index: Make.rules.in
+@@ -19,7 +19,7 @@
+ CC        = @CC@
+ CPP       = @CPP@
+ CFLAGS    = @CFLAGS@
+-OPTIONS   = @OPTIONS@ -D_REENTRANT
++OPTIONS   = @OPTIONS@ -D_REENTRANT -D_THREAD_SAFE
+ X_CFLAGS  = @X_CFLAGS@
+ X_LIBS    = @X_LIBS@
+ XLIB      = @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
Index: patches/patch-thread3-elf
@@ -0,0 +1,22 @@
+Index: scheduler/rf.S
+@@ -20,7 +20,7 @@
+ .stabs "rf.S",100,0,0,Ltext0
+ 	.text
+ Ltext0:
+-	.type	_thrfork,@function
++	.type	thrfork,@function
+ 	.stabd 68,0,1
+ ENTRY(thrfork)
+ 	pushl	%ebp
+@@ -110,9 +110,9 @@
+ 	popl	%ebp
+ 	jmp	PIC_PLT(HIDENAME(cerror))
+ 
+-.stabs "thrfork:f67",36,0,6,_thrfork
++.stabs "thrfork:f67",36,0,6,thrfork
+ Lfe1:
+-	.size	 _thrfork,Lfe1-_thrfork
++	.size	 thrfork,Lfe1-thrfork
+ 
+ #ifdef DEBUG
+ 	.data

 Thanx,
-- 
Juergen Lock <nox@jelal.kn-bremen.de>


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990417224534.A55834>