本文整理汇总了C++中Tcl_Panic函数的典型用法代码示例。如果您正苦于以下问题:C++ Tcl_Panic函数的具体用法?C++ Tcl_Panic怎么用?C++ Tcl_Panic使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Tcl_Panic函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TclpFreeAllocCache
void
TclpFreeAllocCache(
void *ptr)
{
BOOL success;
if (ptr != NULL) {
/*
* Called by us in TclpFinalizeThreadData when a thread exits and
* destroys the tsd key which stores allocator caches.
*/
TclFreeAllocCache(ptr);
success = TlsSetValue(tlsKey, NULL);
if (!success) {
Tcl_Panic("TlsSetValue failed from TclpFreeAllocCache");
}
} else if (once) {
/*
* Called by us in TclFinalizeThreadAlloc() during the library
* finalization initiated from Tcl_Finalize()
*/
success = TlsFree(tlsKey);
if (!success) {
Tcl_Panic("TlsFree failed from TclpFreeAllocCache");
}
once = 0; /* reset for next time. */
}
}
示例2: TclVerifyGlobalLiteralTable
void
TclVerifyGlobalLiteralTable(
Interp *iPtr) /* Points to interpreter whose global literal
* table is to be validated. */
{
register LiteralTable *globalTablePtr = &(iPtr->literalTable);
register LiteralEntry *globalPtr;
char *bytes;
register int i;
int length, count;
count = 0;
for (i=0 ; i<globalTablePtr->numBuckets ; i++) {
for (globalPtr=globalTablePtr->buckets[i] ; globalPtr!=NULL;
globalPtr=globalPtr->nextPtr) {
count++;
if (globalPtr->refCount < 1) {
bytes = Tcl_GetStringFromObj(globalPtr->objPtr, &length);
Tcl_Panic("TclVerifyGlobalLiteralTable: global literal \"%.*s\" had bad refCount %d",
(length>60? 60 : length), bytes, globalPtr->refCount);
}
if (globalPtr->objPtr->bytes == NULL) {
Tcl_Panic("TclVerifyGlobalLiteralTable: literal has NULL string rep");
}
}
}
if (count != globalTablePtr->numEntries) {
Tcl_Panic("TclVerifyGlobalLiteralTable: global literal table had %d entries, should be %d",
count, globalTablePtr->numEntries);
}
}
示例3: TclpFreeAllocCache
void
TclpFreeAllocCache(
void *ptr)
{
BOOL success;
if (ptr != NULL) {
/*
* Called by TclFinalizeThreadAlloc() and
* TclFinalizeThreadAllocThread() during Tcl_Finalize() or
* Tcl_FinalizeThread(). This function destroys the tsd key which
* stores allocator caches in thread local storage.
*/
TclFreeAllocCache(ptr);
success = TlsSetValue(tlsKey, NULL);
if (!success) {
Tcl_Panic("TlsSetValue failed from TclpFreeAllocCache");
}
} else {
/*
* Called by us in TclFinalizeThreadAlloc() during the library
* finalization initiated from Tcl_Finalize()
*/
success = TlsFree(tlsKey);
if (!success) {
Tcl_Panic("TlsFree failed from TclpFreeAllocCache");
}
}
}
示例4: NsThreadFatal
void
NsThreadFatal(char *func, char *osfunc, int err)
{
#ifdef _WIN32
Tcl_Panic("nsthreads: %s failed in %s: win32 err: %d", osfunc, func, err);
#else
Tcl_Panic("nsthreads: %s failed in %s: %s", osfunc, func, strerror(err));
#endif
abort();
}
示例5: EmbWinCheckProc
static void
EmbWinCheckProc(
TkTextSegment *ewPtr, /* Segment to check. */
TkTextLine *linePtr) /* Line containing segment. */
{
if (ewPtr->nextPtr == NULL) {
Tcl_Panic("EmbWinCheckProc: embedded window is last segment in line");
}
if (ewPtr->size != 1) {
Tcl_Panic("EmbWinCheckProc: embedded window has size %d", ewPtr->size);
}
}
示例6: TclpSysAlloc
void *TclpThreadCreateKey(void) {
pthread_key_t *key;
key = TclpSysAlloc(sizeof *key, 0);
if (NULL == key) {
Tcl_Panic("unable to allocate thread key!");
}
if (pthread_key_create(key, NULL)) {
Tcl_Panic("unable to create pthread key!");
}
return key;
}
示例7: Tk_MacOSXSetupTkNotifier
void
Tk_MacOSXSetupTkNotifier()
{
ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey,
sizeof(ThreadSpecificData));
if (!tsdPtr->initialized) {
/* HACK ALERT: There is a bug in Jaguar where when it goes to make
* the event queue for the Main Event Loop, it stores the Current
* event loop rather than the Main Event Loop in the Queue structure.
* So we have to make sure that the Main Event Queue gets set up on
* the main thread. Calling GetMainEventQueue will force this to
* happen.
*/
GetMainEventQueue();
tsdPtr->initialized = 1;
/* Install Carbon events event source in main event loop thread. */
if (GetCurrentEventLoop() == GetMainEventLoop()) {
if (!pthread_main_np()) {
/*
* Panic if the Carbon main event loop thread (i.e. the
* thread where HIToolbox was first loaded) is not the
* main application thread, as Carbon does not support
* this properly.
*/
Tcl_Panic("Tk_MacOSXSetupTkNotifier: %s",
"first [load] of TkAqua has to occur in the main thread!");
}
Tcl_CreateEventSource(CarbonEventsSetupProc,
CarbonEventsCheckProc, GetMainEventQueue());
TkCreateExitHandler(TkMacOSXNotifyExitHandler, NULL);
}
}
}
示例8: Tcl_Release
void
Tcl_Release(
ClientData clientData) /* Pointer to malloc'ed block of memory. */
{
Reference *refPtr;
int i;
Tcl_MutexLock(&preserveMutex);
for (i=0, refPtr=refArray ; i<inUse ; i++, refPtr++) {
int mustFree;
Tcl_FreeProc *freeProc;
if (refPtr->clientData != clientData) {
continue;
}
if (--refPtr->refCount != 0) {
Tcl_MutexUnlock(&preserveMutex);
return;
}
/*
* Must remove information from the slot before calling freeProc to
* avoid reentrancy problems if the freeProc calls Tcl_Preserve on the
* same clientData. Copy down the last reference in the array to
* overwrite the current slot.
*/
freeProc = refPtr->freeProc;
mustFree = refPtr->mustFree;
inUse--;
if (i < inUse) {
refArray[i] = refArray[inUse];
}
/*
* Now committed to disposing the data. But first, we've patched up
* all the global data structures so we should release the mutex now.
* Only then should we dabble around with potentially-slow memory
* managers...
*/
Tcl_MutexUnlock(&preserveMutex);
if (mustFree) {
if (freeProc == TCL_DYNAMIC) {
ckfree((char *) clientData);
} else {
freeProc((char *) clientData);
}
}
return;
}
Tcl_MutexUnlock(&preserveMutex);
/*
* Reference not found. This is a bug in the caller.
*/
Tcl_Panic("Tcl_Release couldn't find reference for 0x%x", clientData);
}
示例9: TclpThreadSetMasterTSD
void TclpThreadSetMasterTSD(void *tsdKeyPtr, void *ptr) {
DWORD *key = tsdKeyPtr;
if (!TlsSetValue(*key, ptr)) {
Tcl_Panic("unable to set master TSD value");
}
}
示例10: TclpSysAlloc
void *TclpThreadCreateKey (void) {
DWORD *key;
key = TclpSysAlloc(sizeof *key, 0);
if (key == NULL) {
Tcl_Panic("unable to allocate thread key!");
}
*key = TlsAlloc();
if (*key == TLS_OUT_OF_INDEXES) {
Tcl_Panic("unable to allocate thread-local storage");
}
return key;
}
示例11: Tcl_GetBoolean
int
Tcl_GetBoolean(
Tcl_Interp *interp, /* Interpreter used for error reporting. */
const char *src, /* String containing one of the boolean values
* 1, 0, true, false, yes, no, on, off. */
int *boolPtr) /* Place to store converted result, which will
* be 0 or 1. */
{
Tcl_Obj obj;
int code;
obj.refCount = 1;
obj.bytes = (char *) src;
obj.length = strlen(src);
obj.typePtr = NULL;
code = Tcl_ConvertToType(interp, &obj, &tclBooleanType);
if (obj.refCount > 1) {
Tcl_Panic("invalid sharing of Tcl_Obj on C stack");
}
if (code == TCL_OK) {
*boolPtr = obj.internalRep.longValue;
}
return code;
}
示例12: TclpThreadSetMasterTSD
void TclpThreadSetMasterTSD(void *tsdKeyPtr, void *ptr) {
pthread_key_t *key = tsdKeyPtr;
if (pthread_setspecific(*key, ptr)) {
Tcl_Panic("unable to set master TSD value");
}
}
示例13: TkDebugColor
Tcl_Obj *
TkDebugColor(
Tk_Window tkwin, /* The window in which the color will be used
* (not currently used). */
char *name) /* Name of the desired color. */
{
Tcl_HashEntry *hashPtr;
Tcl_Obj *resultPtr;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
resultPtr = Tcl_NewObj();
hashPtr = Tcl_FindHashEntry(&dispPtr->colorNameTable, name);
if (hashPtr != NULL) {
TkColor *tkColPtr = Tcl_GetHashValue(hashPtr);
if (tkColPtr == NULL) {
Tcl_Panic("TkDebugColor found empty hash table entry");
}
for ( ; (tkColPtr != NULL); tkColPtr = tkColPtr->nextPtr) {
Tcl_Obj *objPtr = Tcl_NewObj();
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewIntObj(tkColPtr->resourceRefCount));
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewIntObj(tkColPtr->objRefCount));
Tcl_ListObjAppendElement(NULL, resultPtr, objPtr);
}
}
return resultPtr;
}
示例14: TclBNInitBignumFromWideUInt
extern void
TclBNInitBignumFromWideUInt(
mp_int *a, /* Bignum to initialize */
Tcl_WideUInt v) /* Initial value */
{
int status;
mp_digit *p;
/*
* Allocate enough memory to hold the largest possible Tcl_WideUInt.
*/
status = mp_init_size(a,
(CHAR_BIT * sizeof(Tcl_WideUInt) + DIGIT_BIT - 1) / DIGIT_BIT);
if (status != MP_OKAY) {
Tcl_Panic("initialization failure in TclBNInitBignumFromWideUInt");
}
a->sign = MP_ZPOS;
/*
* Store the magnitude in the bignum.
*/
p = a->dp;
while (v) {
*p++ = (mp_digit) (v & MP_MASK);
v >>= MP_DIGIT_BIT;
}
a->used = p - a->dp;
}
示例15: RegisterTcpServerInterpCleanup
static void
RegisterTcpServerInterpCleanup(
Tcl_Interp *interp, /* Interpreter for which we want to be
* informed of deletion. */
AcceptCallback *acceptCallbackPtr)
/* The accept callback record whose interp
* field we want set to NULL when the
* interpreter is deleted. */
{
Tcl_HashTable *hTblPtr; /* Hash table for accept callback records to
* smash when the interpreter will be
* deleted. */
Tcl_HashEntry *hPtr; /* Entry for this record. */
int isNew; /* Is the entry new? */
hTblPtr = (Tcl_HashTable *)
Tcl_GetAssocData(interp, "tclTCPAcceptCallbacks", NULL);
if (hTblPtr == NULL) {
hTblPtr = (Tcl_HashTable *) ckalloc((unsigned) sizeof(Tcl_HashTable));
Tcl_InitHashTable(hTblPtr, TCL_ONE_WORD_KEYS);
(void) Tcl_SetAssocData(interp, "tclTCPAcceptCallbacks",
TcpAcceptCallbacksDeleteProc, hTblPtr);
}
hPtr = Tcl_CreateHashEntry(hTblPtr, (char *) acceptCallbackPtr, &isNew);
if (!isNew) {
Tcl_Panic("RegisterTcpServerCleanup: damaged accept record table");
}
Tcl_SetHashValue(hPtr, acceptCallbackPtr);
}