⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thread_state.h

📁 一个C源代码分析器
💻 H
字号:
/* Generic definitions for dealing with Mach thread states.Copyright (C) 1994 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/ormodify it under the terms of the GNU Library General Public License aspublished by the Free Software Foundation; either version 2 of theLicense, 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 ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNULibrary General Public License for more details.You should have received a copy of the GNU Library General PublicLicense along with the GNU C Library; see the file COPYING.LIB.  Ifnot, write to the Free Software Foundation, Inc., 675 Mass Ave,Cambridge, MA 02139, USA.  *//* Everything else is called `thread_state', but CMU's header file is   called `thread_status'.  Oh boy.  */#include <mach/thread_status.h>/* The machine-dependent thread_state.h file can either define these   macros, or just define PC and SP to the register names.  */#ifndef MACHINE_THREAD_STATE_SET_PC#define MACHINE_THREAD_STATE_SET_PC(ts, pc) \  ((ts)->PC = (unsigned long int) (pc))#endif#ifndef MACHINE_THREAD_STATE_SET_SP#ifdef STACK_GROWTH_UP#define MACHINE_THREAD_STATE_SET_SP(ts, stack, size) \  ((ts)->SP = (unsigned long int) (stack))#else#define MACHINE_THREAD_STATE_SET_SP(ts, stack, size) \  ((ts)->SP = (unsigned long int) (stack) + (size))#endif#endif/* These functions are of use in machine-dependent signal trampoline   implementations.  */#include <string.h>		/* size_t, memcpy */#include <mach/mach_interface.h> /* __thread_get_state */static inline intmachine_get_state (thread_t thread, struct machine_thread_all_state *state,		   int flavor, void *stateptr, void *scpptr, size_t size){  if (state->set & (1 << flavor))    {      /* Copy the saved state.  */      memcpy (scpptr, stateptr, size);      return 1;    }  else    {      /* Noone asked about this flavor of state before; fetch the state	 directly from the kernel into the sigcontext.  */      unsigned int got = (size / sizeof (int));      return (! __thread_get_state (thread, flavor, scpptr, &got)	      && got == (size / sizeof (int)));    }}static inline intmachine_get_basic_state (thread_t thread,			 struct machine_thread_all_state *state){  unsigned int count;  if (state->set & (1 << MACHINE_THREAD_STATE_FLAVOR))    return 1;  count = MACHINE_THREAD_STATE_COUNT;  if (__thread_get_state (thread, MACHINE_THREAD_STATE_FLAVOR,			  (int *) &state->basic, &count) != KERN_SUCCESS ||      count != MACHINE_THREAD_STATE_COUNT)    /* What kind of thread?? */    return 0;			/* XXX */  state->set |= 1 << MACHINE_THREAD_STATE_FLAVOR;  return 1;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -