📄 libmatlb.h
字号:
/*
* @(#)libmatlb.h generated by: makeheader 3.10 Tue Jun 18 01:14:56 2002
*
* built from: include/copyright.h
* include/libmatlb_defs.h
* mlm/memory.c
* mlm/handler.c
* mlm/mlm.c
* mlm/varargs.c
* mlm/mlmdispatch.c
* mlm/index.c
* mlm/mlmscalar.c
* mlm/mlmsparse.c
* mlm/mxapi.c
* mlm/license.c
* mlm/feval.c
* mlm/meval.c
* mlm/mlmpath.c
* mlm/mclscalar.c
* mlm/validate.c
* mlm/mclmex.c
* mlm/mclinit.c
* mlm/forloop.c
* mlm/operators.c
* mlm/mlmpath.c
* mlm/mbfunctions.c
* mlm/wrappers.c
* mlm/overload.c
* mlm/mex_interface.c
* mlm/namehash.c
* include/libmatlb_post.h
*/
#ifndef libmatlb_h
#define libmatlb_h
/* $Revision: 1.1 $ */
/*
* Copyright (c) 1984-1998 by The MathWorks, Inc.
* All Rights Reserved.
*/
/*
* $Revision: 1.6 $
*/
#ifndef libmatlb_defs_h
#define libmatlb_defs_h
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
#if defined(_H_STANDARDS) && !defined(__cplusplus)
#undef NULL
/*
* The definition of NULL on IBM_RS, SGI and SGI64 causes problems.
* it is defined as 0L and it will not work in comma-lists:
* (x,0L) is not compatible with a pointer type
* Ultimately, we need to generate a different constant for error handling
* so that this definition is no necessary here.
* IBM_RS is detected by the H_STANDARDS header file that I believe only
* exists there
*/
#define NULL ((void *) 0L)
#endif
#include "matrix.h"
#include "mwutil.h"
#if defined(MLF_V1_2) && defined(MLF_V2)
#undef MLF_V2
#endif
#if !defined(MATLAB_COMPILER_GENERATED_CODE) && !defined(MLF_V1_2) && !defined(MLF_V2)
#define MLF_V2
#endif
#ifdef MLF_V2
#define MLF_ENABLE_ND_ARRAYS 1
#define MLF_USE_VARARGOUT 1
#define MLF_ENABLE_TRYCATCH 1
#endif /* MLF_V2 */
/* macro proto: mxArray* mclCastToMxarray(void*) */
#define mclCastToMxarray(x) (mxArray *)(x)
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* libmatlb_defs_h */
#ifdef __cplusplus
extern "C" {
#endif
#include "matrix.h"
extern void* mclSafeMalloc(size_t sz);
extern void mclSafeFree(void *ptr);
extern void mlfSetLibraryAllocFcns( calloc_proc calloc_fcn, free_proc free_fcn,
realloc_proc realloc_fcn, malloc_proc malloc_fcn);
extern void mclInitMemoryManager(void);
#include "matrix.h"
#include "mex.h"
#undef mexPrintf
typedef void (*ErrorHandlerFcn)(const char*, bool);
extern void mclDummyFunction(void);
extern void libmmfile_defsInitialize(void);
extern void libmmfile_defsTerminate(void);
extern void libmatlbmxInitialize(void);
extern void libmatlbmxTerminate(void);
extern mxArray *mclGetUninitializedArray(void);
extern bool mclIsCommaList(mxArray *array);
extern bool mclIsNewContext(void);
extern void mclLibmmfileInitialize( void );
extern void mclDestroyArray(mxArray *a);
/* For use only by the compiler. Do not call this function */
extern bool mclIsTempArray(mxArray *a);
/* For use only by the compiler. Do not call this function */
extern void mclFixInternalMatrix(mxArray *a);
extern mxArray *mclCreateGlobal(void);
extern mxArray * mclCppOwnsArray(mxArray *pa);
extern void mclMoveArraysToCurrentContext(int count, mxArray **ppa);
/* This function is intended for use only by the MATLAB compiler. */
extern void mclAssignLastValue(mxArray **ans);
/* This function is intended for use only by the MATLAB compiler. */
extern mxArray *mclAssignAns(mxArray * volatile *dest, mxArray *src);
extern mxArray *mclPrintAns(mxArray * volatile *dest, mxArray *src);
extern mxArray *mlfAssign(mxArray * volatile *dest, mxArray *src);
extern void mlfClear(mxArray * volatile *var, ...);
extern mxArray *mclInitialize(mxArray *pa);
extern void mlfEnterNewContext(int nout, int nin, ...);
extern void mlfRestorePreviousContext(int nout, int nin, ...);
extern void mlfSetPrintHandler(void (* PH)(const char *));
extern ErrorHandlerFcn mlfSetErrorHandler(ErrorHandlerFcn EH);
extern void mclSetCppErrorHandler(ErrorHandlerFcn EH);
extern int mlfPrintf(const char* fmt, ...);
extern void mclInitLibrary( const char * path, int is_mcc );
extern void mclMexLibraryInit(void);
extern void mclLibmatlbInitialize(int argc, const char ** argv);
extern void mclLibmatlbTerminate(void);
extern void mclMemcheckInitLibrary( void );
extern void mlfInitFcn(void);
extern void mlfCleanupFcn(void);
extern void mlfCleanupOutputArray(mxArray* pa);
#include <setjmp.h>
typedef void (*mclExceptionFcn)(void*);
typedef struct mclErrorContext_tag
{
int depth;
int allocContext;
int arrayContext;
int libraryContext;
} mclErrorContext;
typedef struct mclTryCatchContext_tag
{
mclErrorContext err_ctx;
int err_mode;
jmp_buf *buffer;
ErrorHandlerFcn err_handler;
mclExceptionFcn except_fcn;
mclExceptionFcn trycatch_exception_fcn;
mexLocalFunctionTable lft;
struct mclTryCatchContext_tag *prev;
/*
* This structure must go last because of a mismatch in the size of
* a jmp_buf between microsoft and borland compilers on the PC.
* placing any fields after this is a guaranteed seg-fault!
* The correct solution long-term is to use a different structure
* in the error context for the ut_prevent_further_cleanup() function
* which does not contain a jmp_buf.
*/
_try_catch_list _link;
} mclTryCatchContext;
extern void mclNewErrorContext(mclErrorContext *errorCtx);
extern void mclRestoreErrorContext(mclErrorContext *errorCtx);
typedef struct mclCppContext_tag
{
mclErrorContext errorCtx;
ErrorHandlerFcn errorHandler;
} mclCppContext;
extern void mclEnterCppContext(mclCppContext *cppCtx);
extern void mclExitCppContext(mclCppContext *cppCtx);
extern void mclCppError(mclCppContext *cppCtx);
extern void mclMexError(void);
extern jmp_buf *mclGetSetjmpData(void);
extern void mclEnterTryCatchContext(mclTryCatchContext *ctx, jmp_buf *newbuf, mclExceptionFcn exception_fcn);
extern void mclExitTryCatchContext(mclTryCatchContext *ctx, int err_flag);
extern void mclCleanupProtectedItems( void );
extern void mclExitTryBlock(void);
#ifdef MLF_ENABLE_TRYCATCH
static void _mclExceptionFcn(void* msg)
{
mclExceptionFcn dummy;
dummy = _mclExceptionFcn; msg = 0;/* Prevents compiler warning */
mclCleanupProtectedItems();
longjmp(*mclGetSetjmpData(), -1);
}
/*
* Consider the following C source:
*
* typedef long jb[5];
* ...
* jb b;
* jb *x = &b
*
* This causes the alpha compiler (and maybe others) to issue two warnings:
*
* ... & before array "b" is ignored ...
*
* ... the referenced type of the pointer value "&b" is "long",
* which is not compatible with "array [5] of long"
*
* Thus rather than &_mcl_tcbuf, which is what you might think is right,
* the pointer needed in the second argument to mclEnterTryCatchContext is
* obtained with a cast.
*/
#define mlfTry \
{ \
jmp_buf _mcl_tcbuf; \
mclTryCatchContext _mcl_ctx; \
mclEnterTryCatchContext(&_mcl_ctx, \
(jmp_buf *)_mcl_tcbuf, \
_mclExceptionFcn); \
if (!setjmp(_mcl_tcbuf)) {
#define mclExitTryBlock_() mclExitTryCatchContext(&_mcl_ctx, 0)
#define mclCatchWithoutExit \
} else {{ \
mclExitTryCatchContext(&_mcl_ctx, 1); \
mclCallClearPendingExceptions();
#define mlfCatch mclExitTryBlock_(); mclCatchWithoutExit
#define mlfEndCatch }}}
#endif
extern bool mclIsOutOfMemoryError(void);
extern void mclCallClearPendingExceptions(void);
extern mxArray * mlfScalar(double v);
extern mxArray * mlfLogicalScalar(bool v);
/* macro proto: mxArray* mclBoolToArray(bool b); */
#define mclBoolToArray(b) mlfLogicalScalar(b)
extern mxArray * mlfComplexScalar(double v, double i);
extern mxArray *mclComplexMatrixFromVector( int m, int n, double *pr, double *pi );
#define mclMatrixFromVector( m, n, pr ) mclComplexMatrixFromVector( m, n, pr, NULL )
extern mxArray * mlfDoubleMatrix(int m, int n, const double *pr, const double *pi);
extern double *mlfGetPr(mxArray *pa);
extern void mlfSetPr(mxArray *pa, double *pr);
extern double *mlfGetPi(mxArray *pa);
extern void mlfSetPi(mxArray *pa, double *pi);
extern bool mclSwitchCompare(mxArray *switchvar, mxArray *casevar);
extern mxArray * mclCreateEmptyArray(void );
/* macro proto: int mclArrayToInt(mxArray* arg); */
#define mclArrayToInt(x) ((int)(*mxGetPr(x)))
extern mxArray * mclCreateCellFromStrings(int count, const char** strings);
extern mxArray * mclCreateEmptyCell(void);
extern bool mclScalarToBool( mxArray *pa );
extern bool mlfTobool(mxArray *pa);
extern void mlfAddFlops(double f);
extern void mlfSetLibraryCalloc(void *func);
extern void mlfSetLibraryMalloc(void *func);
extern void mlfSetLibraryFree(void *func);
extern void mlfPrintMatrix(mxArray *RI1);
extern void mclPrintArray(mxArray *RI1, const char *name);
extern void mlxColon(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[]);
extern mxArray * mlfColon(mxArray *in1, mxArray *in2, mxArray *in3);
extern void mlfSave(mxArray *file, const char* mode, ... );
extern void mlfSave_v12(const char* file, const char* mode, ...);
extern void mlfLoad(mxArray *file, ... );
extern void mclLoadConditional(mxArray *file, ... );
extern void mlfLoad_v12(const char* file, ...);
extern mxArray *mclCreateStructFromMatFile(mxArray *matfile, int numfields, mxArray **names);
extern mxArray *mlfLoadStruct(mxArray *matfile, mxArray* pa, ...);
#ifndef MLF_ENABLE_ND_ARRAYS
#define mlfSave mlfSave_v12
#define mlfLoad mlfLoad_v12
#endif
extern mxArray * mlfRand(mxArray *in1, ...);
extern mxArray * mlfNRand(int nargout, mxArray *in1, ...);
extern mxArray * mlfRandn(mxArray *in1, ...);
extern mxArray * mlfNRandn(int nargout, mxArray *in1, ...);
extern void mlxRand(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[]);
extern void mlxRandn(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[]);
extern void mclVoid(mxArray *pa);
extern double mclGetInf(void);
/* macro proto: double mclGetMinusInf(void); */
#define mclGetMinusInf() (-mclGetInf())
#include <limits.h> /* defines INT_MIN */
/* macro proto: int mclIntMin(void); */
#define mclIntMin() INT_MIN
extern double mclGetNaN(void);
extern double mclGetForloopEmptyNaN(void);
#include <stdarg.h>
#include "matrix.h" /* Flopper and function_object types, other functions */
#define MLFMAXVAR 100
#define mlfVararginDecls \
int nrhs = 0, size = MLFMAXVAR; \
mxArray *prhslocal[MLFMAXVAR], **prhs = prhslocal; \
mxArray *patemp;
#define mlfVararginBody(varargin, last, uselast, ap) \
if (uselast) { \
patemp = last; \
} else { \
patemp = va_arg(ap, mxArray *); \
} \
while(patemp != NULL) { \
prhs[nrhs++] = patemp; \
if (nrhs == size) { \
size = mclExpandVararginList(&prhs, size, prhslocal); \
} \
patemp = va_arg(ap, mxArray *); \
} \
mlfAssign(varargin, mclUnpackVararginToCell(nrhs, prhs)); \
if (prhs != prhslocal) mxFree(prhs);
/* mlfVarargin assigns, via the varargin argument, a cell array which is temporary and
* is in the caller's array list context. Any temporary inputs to the varargs function
* will be owned by the cell array. The cell array will have a reference count of 1,
* and must be explicitly destroyed. */
/* Can't pass a va_list to a library compiled with a non-default compiler. */
#if (defined(__WATCOMC__) || defined(__BORLANDC__) || (defined(__GNUC__) && !defined(__linux__)))
#define mlfVarargin( varargin, last, uselast) \
{ \
mlfVararginDecls \
va_list ap; \
va_start(ap, last); \
mlfVararginBody(varargin, (mxArray*)last, uselast, ap) \
va_end(ap); \
}
#else
#define mlfVarargin( varargin, last, uselast) \
{ \
va_list ap; \
va_start(ap, last); \
mclVarargin(varargin, (mxArray*)(void*)last, uselast, ap); \
va_end(ap); \
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -