public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: Doug Rabson <dfr@nlsystems.com>
To: linux-ia64@vger.kernel.org
Subject: Re: [Linux-ia64] Cleanup include/asm-ia64/offsets.h - take 2
Date: Tue, 01 May 2001 08:36:25 +0000	[thread overview]
Message-ID: <marc-linux-ia64-105590693005495@msgid-missing> (raw)
In-Reply-To: <marc-linux-ia64-105590693005486@msgid-missing>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1234 bytes --]

On Mon, 30 Apr 2001, Don Dugger wrote:

> Keith-
>
> The number of defines is not the issue.  This issue is that with
> the current system these defines are only defined once.  If you
> create two different definitions that must match then I can
> guarantee that some time in the future the definitions will get
> out of sync and we'll spend an inordinate amount of time tracking
> down a glitch that never would have occurred if we'd kept with
> the current scheme of generating `offsets.h'.
>
> If the only solution you can come up with is to create multiple
> definitions then I'm with David, let's just keep the current scheme.

We have similar issues in FreeBSD (and all the other BSDs too). Our
current solution is to compile a file which uses offsetof() to determine
the symbol values and then use a script to extract those values.  Earlier
versions used to compile and run a program which used offsetof() but that
made cross-builds harder.

For your amusement, I have attached the definitions file for the
FreeBSD/ia64 port and the script which pulls out the values. The script
output is used to make assym.s which is included by all assembler files.

-- 
Doug Rabson				Mail:  dfr@nlsystems.com
					Phone: +44 20 8348 6160


[-- Attachment #2: Type: TEXT/PLAIN, Size: 5594 bytes --]

/*-
 * Copyright (c) 1982, 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: @(#)genassym.c	5.11 (Berkeley) 5/10/91
 * $FreeBSD: src/sys/ia64/ia64/genassym.c,v 1.12 2001/03/28 02:46:20 jhb Exp $
 */

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/assym.h>
#include <sys/proc.h>
#include <sys/bio.h>
#include <sys/buf.h>
#include <sys/errno.h>
#include <sys/proc.h>
#include <sys/mount.h>
#include <sys/socket.h>
#include <sys/resource.h>
#include <sys/resourcevar.h>
#include <sys/ucontext.h>
#include <machine/frame.h>
#include <machine/mutex.h>
#include <sys/vmmeter.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <sys/user.h>
#include <net/if.h>
#include <netinet/in.h>
#include <nfs/nfsv2.h>
#include <nfs/rpcv2.h>
#include <nfs/nfs.h>
#include <nfs/nfsdiskless.h>

ASSYM(GD_CURPROC, offsetof(struct globaldata, gd_curproc));
ASSYM(GD_FPCURPROC, offsetof(struct globaldata, gd_fpcurproc));
ASSYM(GD_CURPCB, offsetof(struct globaldata, gd_curpcb));
ASSYM(GD_SWITCHTIME, offsetof(struct globaldata, gd_switchtime));
ASSYM(GD_CPUID, offsetof(struct globaldata, gd_cpuid));

ASSYM(MTX_LOCK, offsetof(struct mtx, mtx_lock));
ASSYM(MTX_RECURSE, offsetof(struct mtx, mtx_recurse));
ASSYM(MTX_SAVECRIT, offsetof(struct mtx, mtx_savecrit));
ASSYM(MTX_UNOWNED, MTX_UNOWNED);

ASSYM(P_ADDR, offsetof(struct proc, p_addr));
ASSYM(P_MD_FLAGS, offsetof(struct proc, p_md.md_flags));

ASSYM(VM_MAXUSER_ADDRESS, VM_MAXUSER_ADDRESS);

ASSYM(SIZEOF_USER,	sizeof(struct user));

ASSYM(FRAME_SYSCALL,	FRAME_SYSCALL);

ASSYM(TF_CR_IPSR,	offsetof(struct trapframe, tf_cr_ipsr));
ASSYM(TF_CR_IFS,	offsetof(struct trapframe, tf_cr_ifs));
ASSYM(TF_NDIRTY,	offsetof(struct trapframe, tf_ndirty));
ASSYM(TF_B,		offsetof(struct trapframe, tf_b));
ASSYM(TF_R,		offsetof(struct trapframe, tf_r));
ASSYM(TF_F,		offsetof(struct trapframe, tf_f));

ASSYM(FRAME_R4,		FRAME_R4);
ASSYM(FRAME_R5,		FRAME_R5);
ASSYM(FRAME_R6,		FRAME_R6);
ASSYM(FRAME_R7,		FRAME_R7);
ASSYM(FRAME_SP,		FRAME_SP);

ASSYM(U_PCB_R4,		offsetof(struct user, u_pcb.pcb_r4));
ASSYM(U_PCB_R5,		offsetof(struct user, u_pcb.pcb_r5));
ASSYM(U_PCB_R6,		offsetof(struct user, u_pcb.pcb_r6));
ASSYM(U_PCB_R7,		offsetof(struct user, u_pcb.pcb_r7));

ASSYM(U_PCB_F2,		offsetof(struct user, u_pcb.pcb_f2));
ASSYM(U_PCB_F3,		offsetof(struct user, u_pcb.pcb_f3));
ASSYM(U_PCB_F4,		offsetof(struct user, u_pcb.pcb_f4));
ASSYM(U_PCB_F5,		offsetof(struct user, u_pcb.pcb_f5));

ASSYM(U_PCB_B0,		offsetof(struct user, u_pcb.pcb_b0));
ASSYM(U_PCB_B1,		offsetof(struct user, u_pcb.pcb_b1));
ASSYM(U_PCB_B2,		offsetof(struct user, u_pcb.pcb_b2));
ASSYM(U_PCB_B3,		offsetof(struct user, u_pcb.pcb_b3));
ASSYM(U_PCB_B4,		offsetof(struct user, u_pcb.pcb_b4));
ASSYM(U_PCB_B5,		offsetof(struct user, u_pcb.pcb_b5));

ASSYM(U_PCB_OLD_UNAT,	offsetof(struct user, u_pcb.pcb_old_unat));
ASSYM(U_PCB_SP,		offsetof(struct user, u_pcb.pcb_sp));
ASSYM(U_PCB_PFS,	offsetof(struct user, u_pcb.pcb_pfs));
ASSYM(U_PCB_BSPSTORE,	offsetof(struct user, u_pcb.pcb_bspstore));

ASSYM(U_PCB_UNAT,	offsetof(struct user, u_pcb.pcb_unat));
ASSYM(U_PCB_RNAT,	offsetof(struct user, u_pcb.pcb_rnat));
ASSYM(U_PCB_PR,		offsetof(struct user, u_pcb.pcb_pr));

ASSYM(U_PCB_ONFAULT,	offsetof(struct user, u_pcb.pcb_onfault));

ASSYM(U_PCB_HIGHFP,	offsetof(struct user, u_pcb.pcb_highfp));

ASSYM(UC_MCONTEXT_MC_AR_BSP,  offsetof(ucontext_t, uc_mcontext.mc_ar_bsp));
ASSYM(UC_MCONTEXT_MC_AR_RNAT, offsetof(ucontext_t, uc_mcontext.mc_ar_rnat));

ASSYM(EFAULT, EFAULT);
ASSYM(ENAMETOOLONG, ENAMETOOLONG);

ASSYM(SIZEOF_TRAPFRAME, sizeof(struct trapframe));

[-- Attachment #3: Type: TEXT/PLAIN, Size: 1117 bytes --]

#!/bin/sh
# $FreeBSD: src/sys/kern/genassym.sh,v 1.2 2001/01/28 06:39:56 marcel Exp $

# Grrr, this should use stdin and stdout, but is encrufted for compatibility.

usage() {
	echo "usage: genassym [-o outfile] objfile"
	exit 1
}

outfile=/dev/stdout
while getopts "o:" option
do
	case "$option" in
	o)	outfile="$OPTARG";;
	*)	usage;;
	esac
done
shift $(($OPTIND - 1))
case $# in
1)	;;
*)	usage;;
esac

${NM:='nm'} "$1" | awk '
/ C .*sign$/ {
	sign = substr($1, length($1) - 3, 4)
	sub("^0*", "", sign)
	if (sign != "")
		sign = "-"
}
/ C .*w0$/ {
	w0 = substr($1, length($1) - 3, 4)
}
/ C .*w1$/ {
	w1 = substr($1, length($1) - 3, 4)
}
/ C .*w2$/ {
	w2 = substr($1, length($1) - 3, 4)
}
/ C .*w3$/ {
	w3 = substr($1, length($1) - 3, 4)
	w = w3 w2 w1 w0
	sub("^0*", "", w)
	if (w == "")
		w = "0"
	sub("w3$", "", $3)
	# This still has minor problems representing INT_MIN, etc.  E.g.,
	# with 32-bit 2''s complement ints, this prints -0x80000000, which 
	# has the wrong type (unsigned int).
	printf("#define\t%s\t%s0x%s\n", $3, sign, w)
}
' 3>"$outfile" >&3 3>&-

  parent reply	other threads:[~2001-05-01  8:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-28  2:49 [Linux-ia64] Cleanup include/asm-ia64/offsets.h Keith Owens
2001-04-28  2:55 ` David Mosberger
2001-04-28  3:20 ` Keith Owens
2001-04-30  4:57 ` [Linux-ia64] Cleanup include/asm-ia64/offsets.h - take 2 Keith Owens
2001-04-30 15:00 ` David Mosberger
2001-04-30 22:31 ` Keith Owens
2001-04-30 22:51 ` Don Dugger
2001-04-30 23:20 ` Keith Owens
2001-05-01  8:36 ` Doug Rabson [this message]
2001-05-07 18:08 ` David Mosberger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=marc-linux-ia64-105590693005495@msgid-missing \
    --to=dfr@nlsystems.com \
    --cc=linux-ia64@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox