����15-1 linux/lib/_exit.c


  1 /*

  2  *  linux/lib/_exit.c

  3  *

  4  *  (C) 1991  Linus Torvalds

  5  */

  6

  7 #define __LIBRARY__       // ����һ�����ų�����������˵����

  8 #include <unistd.h>       // Linux��׼ͷ�ļ��������˸��ַ��ų��������ͣ��������˸��ֺ�����

                              // ��������__LIBRARY__���򻹺�ϵͳ���úź���Ƕ���syscall0()�ȡ�

  9

    //// �ں�ʹ�õij���(�˳�)��ֹ������

    // ֱ�ӵ���ϵͳ�ж�int 0x80�����ܺ�__NR_exit��

    // ������exit_code - �˳��롣

    // ������ǰ�Ĺؼ���volatile���ڸ��߱�����gcc�ú������᷵�ء���������gcc��������һ

    // Щ�Ĵ��룬����Ҫ����ʹ������ؼ��ֿ��Ա������ijЩ��δ��ʼ�������ģ��پ�����Ϣ��

    // ��ͬ��gcc�ĺ�������˵����void do_exit(int error_code) __attribute__ ((noreturn));

 10 volatile void _exit(int exit_code)

 11 {

    // %0 - eax(ϵͳ���ú�__NR_exit)��%1 - ebx(�˳���exit_code)��

 12         __asm__("int $0x80"::"a" (__NR_exit),"b" (exit_code));

 13 }

 14