This is Unofficial EPICS BASE Doxygen Site
osdInterrupt.c
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2009 UChicago Argonne LLC, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * EPICS BASE is distributed subject to a Software License Agreement found
7 * in file LICENSE that is included with this distribution.
8 \*************************************************************************/
9 /* osi/default/osdInterrupt.c */
10 
11 /* Author: Marty Kraimer Date: 15JUL99 */
12 
13 #include <stddef.h>
14 #include <string.h>
15 #include <stdlib.h>
16 #include <stddef.h>
17 #include <stdio.h>
18 
19 #include "epicsMutex.h"
20 #include "epicsThread.h"
21 #include "cantProceed.h"
22 #include "errlog.h"
23 #include "epicsInterrupt.h"
24 
25 
26 static epicsMutexId globalLock = NULL;
28 
29 static void initOnce(void *junk)
30 {
31  globalLock = epicsMutexMustCreate();
32 }
33 
34 LIBCOM_API int epicsInterruptLock()
35 {
36  epicsThreadOnce(&onceId, initOnce, NULL);
37  epicsMutexMustLock(globalLock);
38  return 0;
39 }
40 
41 LIBCOM_API void epicsInterruptUnlock(int key)
42 {
43  if (!globalLock)
44  cantProceed("epicsInterruptUnlock called before epicsInterruptLock\n");
45  epicsMutexUnlock(globalLock);
46 }
47 
49 {
50  return 0;
51 }
52 
53 LIBCOM_API void epicsInterruptContextMessage(const char *message)
54 {
55  errlogPrintf("%s", message);
56 }
57 
LIBCOM_API int epicsInterruptIsInterruptContext()
Definition: osdInterrupt.c:48
LIBCOM_API void epicsInterruptUnlock(int key)
Definition: osdInterrupt.c:41
#define epicsMutexMustCreate()
Create an epicsMutex semaphore for use from C code.
Definition: epicsMutex.h:179
#define NULL
Definition: catime.c:38
void epicsStdCall epicsMutexUnlock(epicsMutexId pmutexNode)
Release the semaphore.
Definition: epicsMutex.cpp:140
#define EPICS_THREAD_ONCE_INIT
Definition: epicsThread.h:109
APIs for the epicsMutex mutual exclusion semaphore.
LIBCOM_API void epicsStdCall epicsThreadOnce(epicsThreadOnceId *id, EPICSTHREADFUNC, void *arg)
int errlogPrintf(const char *pFormat,...)
Definition: errlog.c:105
LIBCOM_API void cantProceed(const char *msg,...)
Definition: cantProceed.c:54
LIBCOM_API int epicsInterruptLock()
Definition: osdInterrupt.c:34
Routines for code that can&#39;t continue or return after an error.
C++ and C descriptions for a thread.
#define epicsMutexMustLock(ID)
Claim a semaphore (see epicsMutexLock()).
Definition: epicsMutex.h:214
LIBCOM_API void epicsInterruptContextMessage(const char *message)
Definition: osdInterrupt.c:53