当前位置: 首页>>代码示例>>C++>>正文


C++ Forbid函数代码示例

本文整理汇总了C++中Forbid函数的典型用法代码示例。如果您正苦于以下问题:C++ Forbid函数的具体用法?C++ Forbid怎么用?C++ Forbid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Forbid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: startup_check_duplicate

// See if DOpus is already running
void startup_check_duplicate()
{
    Forbid();
    if (FindPort(dopus_name))
    {
        struct MsgPort *port;

        // Ask if we want to run another copy
        Permit();
        if (SimpleRequest(0,
                          dopus_name,
                          GetString(&locale,MSG_ALREADY_RUNNING_BUTTONS),
                          GetString(&locale,MSG_ALREADY_RUNNING),0,0,0,0))
        {
            // Find port again (under Forbid)
            Forbid();
            if ((port=FindPort(dopus_name)))
            {
                // Signal program to wake up
                Signal((struct Task *)port->mp_SigTask,IPCSIG_SHOW);
            }
            Permit();

            // Quit this copy
            quit(0);
        }
    }
    Permit();
}
开发者ID:timofonic,项目名称:dopus5allamigas,代码行数:30,代码来源:main.c

示例2: sem_unlink

int sem_unlink (const char *__name)
{
	unsigned char name[_PSEM_NAME_MAXLENGTH];
	struct SignalSemaphore *ssem;
	psem_t *psem = NULL;
	
	if(strlen(__name) > (_PSEM_NAME_MAXLENGTH-20))
	{
		errno = ENAMETOOLONG;
		return -1;
	}
	
	psem_name(__name,name,sizeof(name)-1);
	
	Forbid();
	if((ssem = FindSemaphore((STRPTR)name)))
	{
		//if(((psem_t *)ssem)->magic == _PSEM_MAGIC)
			psem = (psem_t *)ssem;
	}
	Permit();
	
	if(_PSEM_INVALID(psem))
	{
		errno = ((ssem != NULL) ? EACCES:ENOENT);
		return -1;
	}
	
	Forbid();
	if(psem_trywait(psem)==0)
	{
		psem_destroy(psem);
	}
	else
	{
		/**
		 * Could a semaphore be unlinked by a process other
		 * than the one who created it? if so, this lib will
		 * require some rework...
		 */
		
		if(psem->owner == (unsigned)FindTask(NULL))
			psem->flags |= SEMF_EXPUNGE;
	}
	Permit();
	
	return 0;
}
开发者ID:blubberdiblub,项目名称:libnix,代码行数:48,代码来源:sem_unlink.c

示例3: Forbid

// Check for refresh message
struct IntuiMessage *check_refresh_msg(struct Window *window,ULONG mask)
{
	struct IntuiMessage *msg;

	// Valid window?
	if (!window) return 0;

	// Go through messages
	for (msg=(struct IntuiMessage *)window->UserPort->mp_MsgList.lh_Head;
		msg->ExecMessage.mn_Node.ln_Succ;
		msg=(struct IntuiMessage *)msg->ExecMessage.mn_Node.ln_Succ)
	{
		// Refresh?
		if (msg->Class&mask)
		{
			// Remove it
			Forbid();
			Remove((struct Node *)msg);
			Permit();

			// Return the message
			return msg;
		}
	}

	return 0;
}
开发者ID:timofonic,项目名称:dopus5allamigas,代码行数:28,代码来源:misc.c

示例4: RegisterARexxFunctionHost

void RegisterARexxFunctionHost(int add) {
  struct RexxMsg *mess;
  struct MsgPort *rexxmastport;
  if(!(mess=(struct RexxMsg *)AllocMem(sizeof(struct RexxMsg),
                                       MEMF_CLEAR | MEMF_PUBLIC))) {
    cleanup(EXIT_ERROR, "Out of memory.");
  }
  mess->rm_Node.mn_Node.ln_Type = NT_MESSAGE;
  mess->rm_Node.mn_Length = sizeof(struct RexxMsg);
  mess->rm_Node.mn_ReplyPort=rexxport;
  mess->rm_Action = add ? RXADDFH : RXREMLIB;
  mess->rm_Args[0] = "NIKOMREXXHOST";
  mess->rm_Args[1] = 0L;
  Forbid();
  rexxmastport = (struct MsgPort *)FindPort("REXX");
  if(rexxmastport) {
    PutMsg((struct MsgPort *)rexxmastport,(struct Message *)mess);
  }
  Permit();
  if(rexxmastport == NULL) {
    FreeMem(mess, sizeof(struct RexxMsg));
    if(add) {
      cleanup(EXIT_ERROR, "Can't find port 'REXX' (ARexx master server)");
    }
    return;
  }
  WaitPort(rexxport);
  GetMsg(rexxport);
  FreeMem(mess, sizeof(struct RexxMsg));
}
开发者ID:punktniklas,项目名称:NiKom,代码行数:30,代码来源:Startup.c

示例5: LockDatabaseWrite

struct AHI_AudioDatabase *
LockDatabaseWrite(void)
{
  struct AHI_AudioDatabase *audiodb;

  Forbid();

  audiodb = (struct AHI_AudioDatabase *) FindSemaphore(ADB_NAME);

  if(audiodb != NULL)
  {
    ObtainSemaphore((struct SignalSemaphore *) audiodb);
  }
  else
  {
    audiodb = (struct AHI_AudioDatabase *)
        AllocVec(sizeof(struct AHI_AudioDatabase), MEMF_PUBLIC|MEMF_CLEAR);

    if(audiodb != NULL)
    {

      NewList( (struct List *) &audiodb->ahidb_AudioModes);

      audiodb->ahidb_Semaphore.ss_Link.ln_Name = audiodb->ahidb_Name;
      audiodb->ahidb_Semaphore.ss_Link.ln_Pri  = 20;
      strcpy(audiodb->ahidb_Semaphore.ss_Link.ln_Name, ADB_NAME);

      AddSemaphore((struct SignalSemaphore *) audiodb);
      ObtainSemaphore((struct SignalSemaphore *) audiodb);
    }
  }
  Permit();

  return audiodb;
}
开发者ID:BackupTheBerlios,项目名称:arp2-svn,代码行数:35,代码来源:database.c

示例6: AllocPages

static void*
AllocPages( size_t size, ULONG req )
{
  void* address;

  // FIXME: This shoule be non-cachable, DMA-able memory
  address = AllocMem( size + PAGE_SIZE - 1, req & ~MEMF_CLEAR );

  if( address != NULL )
  {
    Forbid();
    FreeMem( address, size + PAGE_SIZE - 1 );
    address = AllocAbs( size,
			(void*) ((ULONG) ( address + PAGE_SIZE - 1 )
				 & ~(PAGE_SIZE-1) ) );
    Permit();
  }

  if( address != NULL && ( req & MEMF_CLEAR ) )
  {
    memset( address, 0, size );
  }

  return address;
}
开发者ID:BackupTheBerlios,项目名称:arp2-svn,代码行数:25,代码来源:linuxsupport.c

示例7: sem_post

int sem_post (sem_t *__sem)
{
	psem_t *sem = sem2psem(__sem);
	
	ENTER();
	POINTER(sem);
	
	if(_PSEM_INVALID(sem))
	{
		DBG("Invalid sem_t provided, magic=%lx\n",((psem_t *)__sem)->magic);
		errno = EINVAL;
		return -1;
	}
	
	Forbid();
	if((_SSEM(sem)->ss_QueueCount != -1)
	&& ((_SSEM(sem)->ss_Owner == NULL) || (_SSEM(sem)->ss_Owner == FindTask(NULL))))
	{
		ReleaseSemaphore(_SSEM(sem));
	}
	if((sem->flags & SEMF_EXPUNGE) && (_SSEM(sem)->ss_QueueCount == -1))
	{
		DBG("Delayed expunge will take action now...\n");
		psem_destroy(sem);
		memset(__sem,_PSEM_ERASEDBIT,sizeof(*__sem));
	}
	Permit();
	
	LEAVE();
	return 0;
}
开发者ID:blubberdiblub,项目名称:libnix,代码行数:31,代码来源:sem_post.c

示例8: LIBFUNC2

LIBFUNC2(APTR, AllocMem, ULONG, size, ULONG, flags, struct ExecBase *,SysBase)
{
	struct	MemHeader *mh;
	struct	MemBlock *mb;
	ULONG	realsize=size+sizeof(struct MemHeader);

	Forbid();	
	mb=(struct MemBlock *) GetHead(&SysBase->FreeMemList);
	
	if(!mb) return (NULL);

	while(mb->mb_Size<realsize) {
		mb=(struct MemBlock *) GetNext(mb);
		if(!mb) return (NULL);
	}
	
	realsize=realsize+(realsize%MEM_BLOCKSIZE);
	mb->mb_Size -= realsize;
	mh=(struct MemHeader *) (mb+mb->mb_Size);
	mh->mh_Node.mln_Prev = NULL;
	mh->mh_Node.mln_Next = NULL;
	mh->mh_Magic = MEMF_MAGIC;
	mh->mh_Size = realsize;
	Permit();
	return ((APTR) mh);

}
开发者ID:AlexisBerger,项目名称:novaos,代码行数:27,代码来源:allocmem.c

示例9: main

int
main(int argc, char* argv[]) {
  int rc = RETURN_OK;

  if (argc != 2) {
    fprintf(stderr, "Usage: %s <audio mode id>\n", argv[0]);
    rc = RETURN_ERROR;
  }
  else {
    struct MsgPort* mp = CreateMsgPort();

    if (mp != NULL) {
      struct AHIRequest* io = (struct AHIRequest *)
	CreateIORequest(mp, sizeof(struct AHIRequest));

      if (io != NULL) {
	io->ahir_Version = 4;

	if (OpenDevice(AHINAME, AHI_NO_UNIT, (struct IORequest *) io, 0) == 0) {
	  AHIBase = (struct Library *) io->ahir_Std.io_Device;

	  BetterAudioID = atol(argv[1]);

	  Forbid();
	  OldBestAudioIDA = (BestAudioIDA_proto*) 
	    SetFunction(AHIBase, _LVOAHI_BestAudioIDA,
			(ULONG (*)(void)) MyBestAudioIDA );

	  Wait(SIGBREAKF_CTRL_C);

	  SetFunction(AHIBase, _LVOAHI_BestAudioIDA,
		      (ULONG (*)(void)) OldBestAudioIDA );
	  rc = 0;

	  Permit();

	  CloseDevice((struct IORequest *) io);
	}
	else {
	  fprintf(stderr, "Unable to open '" AHINAME "' version 4.\n");
	  rc = RETURN_FAIL;
	}
	
	DeleteIORequest((struct IORequest *) io);
      }
      else {
	fprintf(stderr, "Unable to create IO request.\n");
	rc = RETURN_FAIL;
      }

      DeleteMsgPort(mp);
    }
    else {
      fprintf(stderr, "Unable to create message port.\n");
      rc = RETURN_FAIL;
    }
  }
  
  return rc;
}
开发者ID:BackupTheBerlios,项目名称:arp2-svn,代码行数:60,代码来源:BetterAudioID.c

示例10: util_RemNamedObject

BOOL util_RemNamedObject(pUtility UtilBase, struct NamedObject *object, struct Message *message)
{
	Forbid();
	struct NameSpace *ns = SYSTEM(object)->no_Nos.nos_NameSpace;
	if (ns == NULL)
	{
		if (message != NULL) 
		{
			message->mn_Node.ln_Name = NULL;
			ReplyMsg(message);
		}
		Permit();
		return TRUE;
	}
	if (message == NULL) 
	{
		if (SYSTEM(object)->no_Non.non_UseCount != 1)
		{
			Permit();
			return TRUE;
		}
	}

	SYSTEM(object)->no_Nos.nos_NameSpace = NULL;
	ObtainSemaphore(&ns->ns_Semaphore);
	Remove(&SYSTEM(object)->no_Non.non_Node);
	if (message != NULL)
	{
		SYSTEM(object)->no_Nos.nos_RemoveMsg = message;
		message->mn_Node.ln_Name = (STRPTR)object;
	}
	ReleaseSemaphore(&ns->ns_Semaphore);
	Permit();
	return ReleaseNamedObject(object);
}
开发者ID:cycl0ne,项目名称:poweros_x86,代码行数:35,代码来源:name.c

示例11: main

/**************************************************************************************
** Main 
***************************************************************************************
*/
VOID main()
{

APTR	oldfunct;
APTR	newfunct;

	if(!(AssemblyBase = OpenLibrary(ASSEMBLYNAME, ASSEMBLY_MINIMUM)))
		return(NULL);
	
	IntuitionBase = AssemblyBase->ab_IntuiBase;		
	
/*	if(!(newfunct = AllocVec(1024,MEMF_FAST|MEMF_CLEAR)))
	{
		CloseLibrary(AssemblyBase);
		return(NULL);
	}
		
	CopyMemQuick(&MyRequest,newfunct,1024); */

	Forbid();
			
/*	oldfunct = SetFunction(IntuitionBase,_LVOEasyRequestArgs,newfunct); */
	oldfunct = SetFunction(IntuitionBase,_LVOEasyRequestArgs,&MyRequest);
	
	Permit();
	
return(NULL);
	
}
开发者ID:gfazioli,项目名称:Assembly-Library,代码行数:33,代码来源:SETPATCH.C

示例12: cleanup_timer

__stkargs void cleanup_timer(struct timerequest ** tr)
{
    struct MsgPort *tp;
    struct timerequest *tmp;
    UBYTE pFlags;

    if (*tr) {
	tmp = *tr;
	tp = tmp->tr_node.io_Message.mn_ReplyPort;
	if (tp) {
	    /* abort the current request */
	    pFlags = tp->mp_Flags;	/* still needed for DeletePort */
	    tp->mp_Flags = PA_IGNORE;
	    AbortIO((struct IORequest *) tmp);
	    WaitIO((struct IORequest *) tmp);
	    while (GetMsg(tp));
	    Forbid();
	    tp->mp_Flags = pFlags;
	    DeletePort(tp);
	    Permit();
	}
	CloseDevice((struct IORequest *) tmp);
	DeleteExtIO((struct IORequest *) tmp);
    }
    *tr = NULL;
}
开发者ID:DailyR,项目名称:mudos,代码行数:26,代码来源:signal.c

示例13: CreateConnectionData

static void* CreateConnectionData(DBusConnection* connection) {
  struct ConnectionData* c = AllocVec(sizeof(struct ConnectionData), MEMF_ANY|MEMF_CLEAR);

  kprintf("CreateConnectionData %08lx\n", c);
  
  if (c != NULL) {
    c->connection = connection;
    c->creator = FindTask(NULL);
    NewList((struct List*) &c->watches);
    
    Forbid();
    kprintf("creating mainloop\n");
    c->main   = (struct Task*) CreateNewProcTags(NP_Entry,    (ULONG) MainLoop,
						 NP_Name,     (ULONG) "dbus.library main loop",
						 NP_Priority, 0,
						 TAG_DONE);
    kprintf("created mainloop %08lx\n", c->main);
    if (c->main != NULL) {
      c->main->tc_UserData = c;
    }

    SetSignal(0, SIGF_SINGLE);
    Permit();

    Wait(SIGF_SINGLE);

    if (c->main == NULL) {
      DeleteConnectionData(c);
      c = NULL;
    }
  }

  return c;
}
开发者ID:michalsc,项目名称:AROS,代码行数:34,代码来源:dbus-amiga.c

示例14: bsdsocket_Cleanup

static int bsdsocket_Cleanup(struct bsdsocketBase *SocketBase)
{
    APTR HostLibBase = SocketBase->HostLibBase;

    D(bug("[socket] Cleanup, HostLibBase is 0x%p\n", HostLibBase));
    if (!HostLibBase)
	return TRUE;

    if (SocketBase->ResIFace)
    {
	if (SocketBase->ctl)
	{
	    int res;

	    Forbid();
	    res = SocketBase->ResIFace->sock_shutdown(SocketBase->ctl);
	    Permit();
	    
	    if (res)
		return FALSE;
	}
    }
	
    if (SocketBase->WSIFace)
	HostLib_DropInterface((void **)SocketBase->WSIFace);

    if (SocketBase->winsock)
	HostLib_Close(SocketBase->winsock, NULL);

    return TRUE;
}
开发者ID:michalsc,项目名称:AROS,代码行数:31,代码来源:bsdsocket_init.c

示例15: usbReleaseDeviceBinding

/* /// "usbReleaseDeviceBinding()" */
void usbReleaseDeviceBinding(struct NepSerialBase *nh, struct NepClassSerial *ncp)
{
    struct Library *ps;
    STRPTR devname;

    KPRINTF(1, ("nepSerialReleaseDeviceBinding(%08lx)\n", ncp));
    if((ps = OpenLibrary("poseidon.library", 4)))
    {
        Forbid();
        ncp->ncp_ReadySignal = SIGB_SINGLE;
        ncp->ncp_ReadySigTask = FindTask(NULL);
        if(ncp->ncp_Task)
        {
            Signal(ncp->ncp_Task, SIGBREAKF_CTRL_C);
        }
        Permit();
        while(ncp->ncp_Task)
        {
            Wait(1L<<ncp->ncp_ReadySignal);
        }
        //FreeSignal(ncp->ncp_ReadySignal);
        psdGetAttrs(PGA_DEVICE, ncp->ncp_Device, DA_ProductName, &devname, TAG_END);
        psdAddErrorMsg(RETURN_OK, (STRPTR) libname,
                       "'%s' annealed and broke off.",
                       devname);
        /*psdFreeVec(ncp);*/
        CloseLibrary(ps);
    }
}
开发者ID:michalsc,项目名称:AROS,代码行数:30,代码来源:palmpda.class.c


注:本文中的Forbid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。