_disable.gml

来自「开放源码的编译器open watcom 1.6.0版的源代码」· GML 代码 · 共 63 行

GML
63
字号
.func _disable
#include <i86.h>
void _disable( void );
.ixfunc2 '&Interrupt' &func
.funcend
.desc begin
The &func function causes interrupts to become disabled.
.np
The &func function would be used in conjunction with the
.kw _enable
function to make sure that a sequence of instructions are executed
without any intervening interrupts occurring.
.im privity
.desc end
.return begin
The &func function returns no value.
.return end
.see begin
.seelist _disable _enable
.see end
.exmp begin
#include <stdio.h>
#include <stdlib.h>
#include <i86.h>
.exmp break
struct list_entry {
    struct list_entry *next;
    int    data;
};
volatile struct list_entry *ListHead = NULL;
volatile struct list_entry *ListTail = NULL;
.exmp break
void insert( struct list_entry *new_entry )
  {
    /* insert new_entry at end of linked list */
    new_entry->next = NULL;
    _disable();       /* disable interrupts */
    if( ListTail == NULL ) {
      ListHead = new_entry;
    } else {
      ListTail->next = new_entry;
    }
    ListTail = new_entry;
    _enable();        /* enable interrupts now */
  }
.exmp break
void main()
  {
    struct list_entry *p;
    int i;

    for( i = 1; i <= 10; i++ ) {
      p = (struct list_entry *)
          malloc( sizeof( struct list_entry ) );
      if( p == NULL ) break;
      p->data = i;
      insert( p );
    }
  }
.exmp end
.class Intel
.system

⌨️ 快捷键说明

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