Files
sics/tecs/sys_util.h

45 lines
1.1 KiB
C

#ifndef _SYS_UTIL_H_
#define _SYS_UTIL_H_
#ifdef FORTIFY
#include "fortify.h"
#endif
/* secure allocation stuff ----------------------------------
change these macros if you want to log dynamic memory access
*/
#define NEW(PTR) ERR_SP(PTR=calloc(1,sizeof(*PTR)))
#define MALLOC(SIZ) calloc(1,SIZ)
#define FREE(PTR) free(PTR)
/* fortran interface stuff ----------------------------------
declare fortran character arguments as CHAR(arg)
and at at the end for each character argument <arg> add
int <arg>_len to the argument list
*/
#if defined __VMS
#define F_CHAR(VAR) SysVmsChar *VAR##_desc
#define STR_TO_C(DST,SRC) str_ntrim(DST, SRC##_desc->text, sizeof(DST), SRC##_len=SRC##_desc->size)
#define STR_TO_F(DST,SRC) str_npad(DST##_desc->text, SRC, DST##_len=DST##_desc->size)
typedef struct { short size, dummy; char *text; } SysVmsChar;
#elif defined __alpha
#define F_CHAR(VAR) char *VAR
#define STR_TO_C(DST,SRC) str_ntrim(DST, SRC, sizeof(DST), SRC##_len)
#define STR_TO_F(DST,SRC) str_npad(DST, SRC, DST##_len)
#else
/* other machines are not yet supported */
#endif
#endif /* _SYS_UTIL_H_ */