[688] in Pthreads mailing list archive

home help back first fref pref prev next nref lref last post

Re: Building/running on BSDI 2.1

daemon@ATHENA.MIT.EDU (Stefan Grefen)
Tue Jul 22 18:22:00 1997

To: Ron Czik <rec@cybersmith.com>
Cc: pthreads@MIT.EDU, czik@cybersmith.com
Reply-To: grefen@carpe.net
Return-Receipt-To: <grefen@carpe.net>
In-Reply-To: Ron Czik's message <v03007800affabb3d914c@[206.152.11.106]> of Tue, 22 Jul 97 14:34:21 CDT.
Date: Tue, 22 Jul 1997 23:47:58 +0200
From: Stefan Grefen <grefen@carpe.net>

In message <v03007800affabb3d914c@[206.152.11.106]>  Ron Czik wrote:
> Hi,
> 
> I'm am trying to build/run on BSDI 2.1.  I get compile errors
> on syscall.S.  Specifically:
> 
> syscall.S:247:invalid character '_' in opcode
> syscall.S:259:invalid character '_' in opcode
> 
> I am using gmake and gcc.  Any assistance would be helpfull.
> Thanks.
> 
> Ron Czik

I've it running, there is problem with longjmp.

I've hacked engine-i386-bsdi-2.1.c.

I include my *-i386-bsdi-2.1.* files.

Stefan

> 
> 
> _________________________________________________________________
> Ronald Czik                         rec@cybersmith.com
> Principal Technology Designer       phone:  617-547-8588 ext. 234
> Cybersmith, Inc.                    fax:    617-547-8115
> 955 Massachusetts Ave.              http://www.cybersmith.com
> Cambridge Ma.  02139-3180
> _________________________________________________________________
> "That's the great thing about crayons.  They can take you to more
>  places than a starship."
> 
> 

--
Stefan Grefen                            Am Grossberg 16, 55130 Mainz, Germany
grefen@carpe.net                         +49 6131 998566   Fax:+49 6131 998568
Idiot, n.:
        A member of a large and powerful tribe whose influence in human
affairs has always been dominant and controlling.
                -- Ambrose Bierce, "The Devil's Dictionary"

------x-xxxx--x-x-x-xx-x--x-x-x-x--x-x--x--x-x-x-x-x-x-x-x-x-x-x-x
#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.1).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1996-09-12 10:39 MET DST by <grefen@hex>.
# Source directory was `/usr/homes/grefen/devel/pthreads-1_60_beta4_1/machdep'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#   6671 -rw------- engine-i386-bsdi-2.1.c
#   1713 -rw------- engine-i386-bsdi-2.1.h
#   3271 -rw------- syscall-i386-bsdi-2.1.S
#    772 -rw------- syscall-template-i386-bsdi-2.1.S
#
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
  shar_touch=touch
else
  shar_touch=:
  echo
  echo 'WARNING: not restoring timestamps.  Consider getting and'
  echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 1231235999 $$.touch
#
# ============= engine-i386-bsdi-2.1.c ==============
if test -f 'engine-i386-bsdi-2.1.c' && test X"$1" != X"-c"; then
  echo 'x - skipping engine-i386-bsdi-2.1.c (file already exists)'
else
  echo 'x - extracting engine-i386-bsdi-2.1.c (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'engine-i386-bsdi-2.1.c' &&
/* ==== machdep.c ============================================================
X * Copyright (c) 1993, 1994 Chris Provenzano, proven@athena.mit.edu
X *
X * Copyright (c) 1993 by Chris Provenzano, proven@mit.edu
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X *    must display the following acknowledgement:
X *  This product includes software developed by Chris Provenzano.
X * 4. The name of Chris Provenzano may not be used to endorse or promote
X *      products derived from this software without specific prior written
X *      permission.
X *
X * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED.  IN NO EVENT SHALL CHRIS PROVENZANO BE LIABLE FOR ANY
X * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
X * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
X * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
X * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X *
X * Description : Machine dependent functions for NetBSD on i386
X *
X *	1.00 93/08/04 proven
X *      -Started coding this file.
X */
X
#ifndef lint
static const char rcsid[] = "engine-i386-netbsd-1.0.c,v 1.55 1995/02/06 22:42:3
3 ghudson Exp";
#endif
X
#include <sys/types.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <stdio.h>
#include "pthread.h"
X
static void dummy() {
__asm__ volatile ("_hackljmp: movl    4(%esp),%edx; jmp __longjmp+38;");
}
/* ==========================================================================
X * machdep_save_state()
X */
int machdep_save_state(void)
{
X    return(_setjmp(pthread_run->machdep_data.machdep_state));
}
X
/* ==========================================================================
X * machdep_save_state()
X */
int machdep_save_float_state(struct pthread * pthread)
{
X	char * fdata = (char *)pthread->machdep_data.machdep_float_state;
X
X	__asm__ ("fsave %0"::"m" (*fdata));
}
X
/* ==========================================================================
X * machdep_restore_state()
X */
void machdep_restore_state(void)
{
#if 0
X    _longjmp(pthread_run->machdep_data.machdep_state, 1);
#else
X    hackljmp(pthread_run->machdep_data.machdep_state, 1);
#endif
}
X
/* ==========================================================================
X * machdep_restore_float_state()
X */
int machdep_restore_float_state(void)
{
X	char * fdata = (char *)pthread_run->machdep_data.machdep_float_state;
X
X	__asm__ ("frstor %0"::"m" (*fdata));
}
X
/* ==========================================================================
X * machdep_set_thread_timer()
X */
void machdep_set_thread_timer(struct machdep_pthread *machdep_pthread)
{
X    if (setitimer(ITIMER_VIRTUAL, &(machdep_pthread->machdep_timer), NULL)) {
X        PANIC();
X    }
}
X
/* ==========================================================================
X * machdep_unset_thread_timer()
X */
void machdep_unset_thread_timer(struct machdep_pthread *machdep_pthread)
{
X    struct itimerval zeroval = { { 0, 0 }, { 0, 0 } };
X	int ret;
X
X	if (machdep_pthread) {
X    	ret = setitimer(ITIMER_VIRTUAL, &zeroval, 
X		  &(machdep_pthread->machdep_timer));
X	} else {
X    	ret = setitimer(ITIMER_VIRTUAL, &zeroval, NULL); 
X    }
X
X	if (ret) {
X       	PANIC();
X	}
}
X
/* ==========================================================================
X * machdep_pthread_cleanup()
X */
void *machdep_pthread_cleanup(struct machdep_pthread *machdep_pthread)
{
X    return(machdep_pthread->machdep_stack);
}
X
/* ==========================================================================
X * machdep_pthread_start()
X */
void machdep_pthread_start(void)
{
X	context_switch_done();
X	pthread_sched_resume();
X
X    /* Run current threads start routine with argument */
X    pthread_exit(pthread_run->machdep_data.start_routine
X      (pthread_run->machdep_data.start_argument));
X
X    /* should never reach here */
X    PANIC();
}
X
/* ==========================================================================
X * machdep_pthread_create()
X */
void machdep_pthread_create(struct machdep_pthread *machdep_pthread,
X  void *(* start_routine)(), void *start_argument, long stack_size,
X  void *stack_start, long nsec)
{
X    machdep_pthread->machdep_stack = stack_start;
X
X    machdep_pthread->start_routine = start_routine;
X    machdep_pthread->start_argument = start_argument;
X
X    machdep_pthread->machdep_timer.it_value.tv_sec = 0;
X    machdep_pthread->machdep_timer.it_interval.tv_sec = 0;
X    machdep_pthread->machdep_timer.it_interval.tv_usec = 0;
X    machdep_pthread->machdep_timer.it_value.tv_usec = nsec / 1000;
X
X    _setjmp(machdep_pthread->machdep_state);
X    /*
X     * Set up new stact frame so that it looks like it
X     * returned from a longjmp() to the beginning of
X     * machdep_pthread_start().
X     */
X    machdep_pthread->machdep_state[0] = (int)machdep_pthread_start;
X
X    /* Stack starts high and builds down. */
X    machdep_pthread->machdep_state[2] =
X      (int)machdep_pthread->machdep_stack + stack_size;
}
X
/* ==========================================================================
X * machdep_sys_creat()
X */
machdep_sys_creat(char * path, int mode)
{
X        return(machdep_sys_open(path, O_WRONLY | O_CREAT | O_TRUNC, mode));
}
X 
/* ==========================================================================
X * machdep_sys_wait3() 
X */
machdep_sys_wait3(int * b, int c, int * d)
{
X        return(machdep_sys_wait4(0, b, c, d));
}
X 
/* ==========================================================================
X * machdep_sys_waitpid()
X */
machdep_sys_waitpid(int a, int * b, int c)
{
X        return(machdep_sys_wait4(a, b, c, NULL));
}  
X
#if 0
/* ==========================================================================
X * machdep_sys_getdtablesize()
X */
machdep_sys_getdtablesize()
{
X        return(sysconf(_SC_OPEN_MAX));
}  
#endif
SHAR_EOF
  $shar_touch -am 0121224096 'engine-i386-bsdi-2.1.c' &&
  chmod 0600 'engine-i386-bsdi-2.1.c' ||
  echo 'restore of engine-i386-bsdi-2.1.c failed'
  shar_count="`wc -c < 'engine-i386-bsdi-2.1.c'`"
  test 6671 -eq "$shar_count" ||
    echo "engine-i386-bsdi-2.1.c: original size 6671, current size $shar_count"
fi
# ============= engine-i386-bsdi-2.1.h ==============
if test -f 'engine-i386-bsdi-2.1.h' && test X"$1" != X"-c"; then
  echo 'x - skipping engine-i386-bsdi-2.1.h (file already exists)'
else
  echo 'x - extracting engine-i386-bsdi-2.1.h (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'engine-i386-bsdi-2.1.h' &&
/* ==== machdep.h ============================================================
X * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
X *
X * engine-i386-bsdi-1.1.h,v 1.52 1994/11/08 15:38:53 proven Exp
X *
X */
X
#include <unistd.h>
#include <setjmp.h>
#include <sys/time.h>
X
/*
X * The first machine dependent functions are the SEMAPHORES
X * needing the test and set instruction.
X */
#define SEMAPHORE_CLEAR 0
#define SEMAPHORE_SET   1
X
#define SEMAPHORE_TEST_AND_SET(lock)    \
({									
	\
long temp = SEMAPHORE_SET;              \
X									
	\
__asm__ volatile ("xchgl %0,(%2)"       \
X        :"=r" (temp)                    \
X        :"0" (temp),"r" (lock));        \
temp;                                   \
})
X
#define SEMAPHORE_RESET(lock)           *lock = SEMAPHORE_CLEAR
X
/*
X * New types
X */
typedef long    semaphore;
X
/*
X * sigset_t macros
X */
#define	SIG_ANY(sig)		(sig)
#define SIGMAX				31
X
/*
X * New Strutures
X */
struct machdep_pthread {
X    void        		*(*start_routine)(void *);
X    void        		*start_argument;
X    void        		*machdep_stack;
X	struct itimerval	machdep_timer;
X    jmp_buf     		machdep_state;
X    char                      machdep_float_state[108];
};
X
/*
X * Static machdep_pthread initialization values.
X * For initial thread only.
X */
#define MACHDEP_PTHREAD_INIT    \
{ NULL, NULL, NULL, { { 0, 0 }, { 0, 100000 } }, 0 }
X
/*
X * Minimum stack size
X */
#define PTHREAD_STACK_MIN	1024
X
/*
X * Some fd flag defines that are necessary to distinguish between posix
X * behavior and bsd4.3 behavior.
X */
#define __FD_NONBLOCK 		O_NONBLOCK
X
/*
X * New functions
X */
X
__BEGIN_DECLS
X
#if defined(PTHREAD_KERNEL)
X
int machdep_save_state      __P((void));
X
#endif
X
__END_DECLS
X
SHAR_EOF
  $shar_touch -am 0121202296 'engine-i386-bsdi-2.1.h' &&
  chmod 0600 'engine-i386-bsdi-2.1.h' ||
  echo 'restore of engine-i386-bsdi-2.1.h failed'
  shar_count="`wc -c < 'engine-i386-bsdi-2.1.h'`"
  test 1713 -eq "$shar_count" ||
    echo "engine-i386-bsdi-2.1.h: original size 1713, current size $shar_count"
fi
# ============= syscall-i386-bsdi-2.1.S ==============
if test -f 'syscall-i386-bsdi-2.1.S' && test X"$1" != X"-c"; then
  echo 'x - skipping syscall-i386-bsdi-2.1.S (file already exists)'
else
  echo 'x - extracting syscall-i386-bsdi-2.1.S (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'syscall-i386-bsdi-2.1.S' &&
/* ==== syscall.S ============================================================
X * Copyright (c) 1990 The Regents of the University of California.
X * Copyright (c) 1993 Chris Provenzano, proven@mit.edu
X * All rights reserved.
X *
X * This code is derived from software contributed to Berkeley by
X * William Jolitz.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X *    must display the following acknowledgement:
X *	This product includes software developed by the University of
X *	California, Berkeley and its contributors.
X * 4. Neither the name of the University nor the names of its contributors
X *    may be used to endorse or promote products derived from this software
X *    without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X *
X * Description : Machine dependent syscalls for i386/i486/i586
X *
X *  1.00 93/08/26 proven
X *      -Started coding this file.
X *
X *	1.01 93/11/13 proven
X *		-The functions readv() and writev() added.
X */
X
#ifndef lint
X	.text
X	.asciz "syscall-i386-bsdi-1.1.S,v 1.51 1994/09/05 21:31:24 proven Exp";
#endif
X 
#if defined(SYSLIBC_SCCS) && !defined(lint)
X        .asciz "@(#)syscall.s   5.1 (Berkeley) 4/23/90"
#endif /* SYSLIBC_SCCS and not lint */
X
#include <sys/syscall.h>
X
#define	SYSCALL(x)					\
X	.globl _machdep_sys_/**/x;		\
X									\
_machdep_sys_/**/x:;				\
X									\
X	movl $(SYS_/**/x), %eax;		\
X	.byte 0x9a; .long 0; .word 7;	\
X	jb	1b;							\
X	ret;							
X
/*
X * Initial asm stuff for all functions.
X */
X	.text
X	.align	2
X
X
/* ==========================================================================
X * error code for all syscalls. The error value is returned as the negative
X * of the errno value.
X */
X
1:
X	neg		%eax
X	ret
X
X
/* ==========================================================================
X * machdep_sys_fork()
X */
X	.globl _machdep_sys_fork;		
X									
_machdep_sys_fork:;				
X									
X	movl $(SYS_fork), %eax;		
X	.byte 0x9a; .long 0; .word 7;	
X	cmpl $0, %edx
X	je	2f
X	movl $0, %eax
2:	
X	ret;							
X
X
SHAR_EOF
  $shar_touch -am 0121154396 'syscall-i386-bsdi-2.1.S' &&
  chmod 0600 'syscall-i386-bsdi-2.1.S' ||
  echo 'restore of syscall-i386-bsdi-2.1.S failed'
  shar_count="`wc -c < 'syscall-i386-bsdi-2.1.S'`"
  test 3271 -eq "$shar_count" ||
    echo "syscall-i386-bsdi-2.1.S: original size 3271, current size $shar_count
"
fi
# ============= syscall-template-i386-bsdi-2.1.S ==============
if test -f 'syscall-template-i386-bsdi-2.1.S' && test X"$1" != X"-c"; then
  echo 'x - skipping syscall-template-i386-bsdi-2.1.S (file already exists)'
else
  echo 'x - extracting syscall-template-i386-bsdi-2.1.S (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'syscall-template-i386-bsdi-2.1.S' &&
#include <sys/syscall.h>
X
#ifdef __STDC__
#define	SYSCALL(x)					\
X	.globl _machdep_sys_##x;		\
X									\
_machdep_sys_##x##:;				\
X									\
X	movl $(SYS_##x), %eax;		\
X	.byte 0x9a; .long 0; .word 7;	\
X	jb	1b;							\
X	ret;							
#else
#define	SYSCALL(x)					\
X	.globl _machdep_sys_/**/x;		\
X									\
_machdep_sys_/**/x:;				\
X									\
X	movl $(SYS_/**/x), %eax;		\
X	.byte 0x9a; .long 0; .word 7;	\
X	jb	1b;							\
X	ret;							
#endif
/*
X * Initial asm stuff for all functions.
X */
X	.text
X	.align	2
X
X
/* ==========================================================================
X * error code for all syscalls. The error value is returned as the negative
X * of the errno value.
X */
X
1:
X	neg		%eax
X	ret
X
#define XSYSCALL(NAME)  SYSCALL(NAME)
X
XXSYSCALL(SYSCALL_NAME)
X
SHAR_EOF
  $shar_touch -am 0121161496 'syscall-template-i386-bsdi-2.1.S' &&
  chmod 0600 'syscall-template-i386-bsdi-2.1.S' ||
  echo 'restore of syscall-template-i386-bsdi-2.1.S failed'
  shar_count="`wc -c < 'syscall-template-i386-bsdi-2.1.S'`"
  test 772 -eq "$shar_count" ||
    echo "syscall-template-i386-bsdi-2.1.S: original size 772, current size $sh
ar_count"
fi
exit 0


home help back first fref pref prev next nref lref last post