[uClibc-cvs] uClibc/libc/sysdeps/linux/arm/bits armsigctx.h,NONE,1.1 atomicity.h,NONE,1.1 machine-gmon.h,NONE,1.1 profil-counter.h,NONE,1.1 sigcontextinfo.h,NONE,1.1 stackinfo.h,NONE,1.1

Erik Andersen andersen at codepoet.org
Mon Mar 3 20:58:06 UTC 2003


Update of /var/cvs/uClibc/libc/sysdeps/linux/arm/bits
In directory winder:/tmp/cvs-serv13798/libc/sysdeps/linux/arm/bits

Added Files:
	armsigctx.h atomicity.h machine-gmon.h profil-counter.h 
	sigcontextinfo.h stackinfo.h 
Log Message:
Initial effort at adding profiling support.


--- NEW FILE: armsigctx.h ---
/* Definition of `struct sigcontext' for Linux/ARM
   Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   02111-1307 USA.  */

/* The format of struct sigcontext changed between 2.0 and 2.1 kernels.
   Fortunately 2.0 puts a magic number in the first word and this is not
   a legal value for `trap_no', so we can tell them apart.  */

/* Early 2.2 and 2.3 kernels do not have the `fault_address' member in
   the sigcontext structure.  Unfortunately there is no reliable way
   to test for its presence and this word will contain garbage for too-old
   kernels.  Versions 2.2.14 and 2.3.35 (plus later versions) are known to
   include this element.  */

#ifndef __ARMSIGCTX_H
#define __ARMSIGCTX_H	1

#include <asm/ptrace.h>

union k_sigcontext
  {
    struct
      {
	unsigned long int trap_no;
	unsigned long int error_code;
	unsigned long int oldmask;
	unsigned long int arm_r0;
	unsigned long int arm_r1;
	unsigned long int arm_r2;
	unsigned long int arm_r3;
	unsigned long int arm_r4;
	unsigned long int arm_r5;
	unsigned long int arm_r6;
	unsigned long int arm_r7;
	unsigned long int arm_r8;
	unsigned long int arm_r9;
	unsigned long int arm_r10;
	unsigned long int arm_fp;
	unsigned long int arm_ip;
	unsigned long int arm_sp;
	unsigned long int arm_lr;
	unsigned long int arm_pc;
	unsigned long int arm_cpsr;
	unsigned long fault_address;
      } v21;
    struct
      {
	unsigned long int magic;
	struct pt_regs reg;
	unsigned long int trap_no;
	unsigned long int error_code;
	unsigned long int oldmask;
      } v20;
};

#define SIGCONTEXT_2_0_MAGIC	0x4B534154

#endif	/* bits/armsigctx.h */

--- NEW FILE: atomicity.h ---
/* Low-level functions for atomic operations.  ARM version.
   Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   02111-1307 USA.  */

#ifndef _ATOMICITY_H
#define _ATOMICITY_H    1

#include <inttypes.h>


static inline int
__attribute__ ((unused))
exchange_and_add (volatile uint32_t *mem, int val)
{
  int tmp1;
  int tmp2;
  int result;
  __asm__ ("\n"
	   "0:\tldr\t%0,[%3]\n\t"
	   "add\t%1,%0,%4\n\t"
	   "swp\t%2,%1,[%3]\n\t"
	   "cmp\t%0,%2\n\t"
	   "swpne\t%1,%2,[%3]\n\t"
	   "bne\t0b"
	   : "=&r" (result), "=&r" (tmp1), "=&r" (tmp2)
	   : "r" (mem), "r"(val)
	   : "cc", "memory");
  return result;
}

static inline void
__attribute__ ((unused))
atomic_add (volatile uint32_t *mem, int val)
{
  int tmp1;
  int tmp2;
  int tmp3;
  __asm__ ("\n"
	   "0:\tldr\t%0,[%3]\n\t"
	   "add\t%1,%0,%4\n\t"
	   "swp\t%2,%1,[%3]\n\t"
	   "cmp\t%0,%2\n\t"
	   "swpne\t%1,%2,[%3]\n\t"
	   "bne\t0b"
	   : "=&r" (tmp1), "=&r" (tmp2), "=&r" (tmp3)
	   : "r" (mem), "r"(val)
	   : "cc", "memory");
}

static inline int
__attribute__ ((unused))
compare_and_swap (volatile long int *p, long int oldval, long int newval)
{
  int result, tmp;
  __asm__ ("\n"
	   "0:\tldr\t%1,[%2]\n\t"
	   "mov\t%0,#0\n\t"
	   "cmp\t%1,%4\n\t"
	   "bne\t1f\n\t"
	   "swp\t%0,%3,[%2]\n\t"
	   "cmp\t%1,%0\n\t"
	   "swpne\t%1,%0,[%2]\n\t"
	   "bne\t0b\n\t"
	   "mov\t%0,#1\n"
	   "1:"
	   : "=&r" (result), "=&r" (tmp)
	   : "r" (p), "r" (newval), "r" (oldval)
	   : "cc", "memory");
  return result;
}

#endif /* atomicity.h */

--- NEW FILE: machine-gmon.h ---
/* Machine-dependent definitions for profiling support.  ARM version.
   Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   02111-1307 USA.  */

/* GCC for the ARM cannot compile __builtin_return_address(N) for N != 0, 
   so we must use an assembly stub.  */

#include <sysdep.h>
#ifndef NO_UNDERSCORES
/* The asm symbols for C functions are `_function'.
   The canonical name for the counter function is `mcount', no _.  */
void _mcount (void) asm ("mcount");
#else
/* The canonical name for the function is `_mcount' in both C and asm,
   but some old asm code might assume it's `mcount'.  */
void _mcount (void);
weak_alias (_mcount, mcount)
#endif

static void mcount_internal (u_long frompc, u_long selfpc);

#define _MCOUNT_DECL(frompc, selfpc) \
static void mcount_internal (u_long frompc, u_long selfpc)

/* This macro/func MUST save r0, r1 because the compiler inserts
	blind calls to _mount(), ignoring the fact that _mcount may
	clobber registers; therefore, _mcount may NOT clobber registers */
/* if (this_fp!=0) {
	r0 = this_fp
	r1 = this_lr
  	r1 = [r1-4] which is caller's lr 
	if (r1!=0) 
		r1 = caller's lr
	call mcount_internal(this_lr, caller's_lr)
   }
*/

#define MCOUNT								\
void _mcount (void)							\
{									\
  __asm__("stmdb	sp!, {r0, r1, r2, r3};"				\
	  "movs		fp, fp;"				      	\
          "moveq	r1, #0;"					\
	  "ldrne	r1, [fp, $-4];"					\
	  "ldrne	r0, [fp, $-12];"				\
	  "movnes	r0, r0;"					\
	  "ldrne	r0, [r0, $-4];"					\
	  "movs		r0, r0;"					\
	  "blne		mcount_internal;"				\
	  "ldmia	sp!, {r0, r1, r2, r3}");			\
}


--- NEW FILE: profil-counter.h ---
/* Low-level statistical profiling support function.  Linux/ARM version.
   Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   02111-1307 USA.  */

#include <signal.h>
#include <bits/armsigctx.h>

void
profil_counter (int signo, int _a2, int _a3, int _a4, union k_sigcontext sc)
{
  void *pc;
  if (sc.v20.magic == SIGCONTEXT_2_0_MAGIC)
    pc = (void *) sc.v20.reg.ARM_pc;
  else
    pc = (void *) sc.v21.arm_pc;
  profil_count (pc);
}

--- NEW FILE: sigcontextinfo.h ---
/* Copyright (C) 1999 Free Software Foundation, Inc.
   This file is part of the GNU C Library.
   Contributed by Philip Blundell <philb at gnu.org>, 1999.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   02111-1307 USA.  */

#include <bits/armsigctx.h>

#define SIGCONTEXT int _a2, int _a3, int _a4, union k_sigcontext
#define SIGCONTEXT_EXTRA_ARGS _a2, _a3, _a4,

#define GET_PC(ctx)	((void *)((ctx.v20.magic == SIGCONTEXT_2_0_MAGIC) ? \
			 ctx.v20.reg.ARM_pc : ctx.v21.arm_pc))
#define GET_FRAME(ctx)	\
	ADVANCE_STACK_FRAME((void *)((ctx.v20.magic == SIGCONTEXT_2_0_MAGIC) ? \
			 ctx.v20.reg.ARM_fp : ctx.v21.arm_fp))
#define GET_STACK(ctx)	((void *)((ctx.v20.magic == SIGCONTEXT_2_0_MAGIC) ? \
			 ctx.v20.reg.ARM_sp : ctx.v21.arm_sp))
#define ADVANCE_STACK_FRAME(frm)	\
			((struct layout *)frm - 1)
#define CALL_SIGHANDLER(handler, signo, ctx) \
  (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx))

--- NEW FILE: stackinfo.h ---
/* Copyright (C) 2001 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   02111-1307 USA.  */

/* This file contains a bit of information about the stack allocation
   of the processor.  */

#ifndef _STACKINFO_H
#define _STACKINFO_H	1

/* On Arm the stack grows down.  */
#define _STACK_GROWS_DOWN	1

#endif	/* stackinfo.h */




More information about the uClibc-cvs mailing list