42 lines
1.0 KiB
C
42 lines
1.0 KiB
C
#ifndef _SYS_UTIL_H_
|
|
#define _SYS_UTIL_H_
|
|
|
|
#ifdef FORTIFY
|
|
#include "fortify.h"
|
|
#endif
|
|
|
|
/* secure allocation stuff ---------------------------------- */
|
|
|
|
#define NEW(PTR) ERR_SP(PTR=my_malloc(sizeof(*PTR),#PTR))
|
|
|
|
void *my_malloc(size_t size, const char *text);
|
|
void my_free(void *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
|
|
#error this machine is not supported
|
|
#endif
|
|
|
|
#endif /* _SYS_UTIL_H_ */
|