Skip to content

Commit

Permalink
use xfree and xmalloc when available
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmy Tang committed Jun 20, 2011
1 parent 0f6151d commit 3425974
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 20 deletions.
47 changes: 28 additions & 19 deletions config.m4
Expand Up @@ -8,51 +8,60 @@
# Use to make the php slurm extension
##*****************************************************************************
PHP_ARG_WITH(slurm, whether to use slurm,
[ --with-slurm=SLURM_INSTALL_PATH])

[ --with-slurm SLURM install dir])

AC_MSG_CHECKING([for phpize in default path])
if test ! -f "/usr/bin/phpize"; then
PHP_SLURM="no"
AC_MSG_RESULT([NO, CANNOT MAKE SLURM_PHP])
else
AC_MSG_RESULT([yes])
fi

if test "$PHP_SLURM" != "no"; then
SLURMLIB_PATH="/usr/lib64 /usr/lib"
SLURMINCLUDE_PATH="/usr/include"
SEARCH_FOR="libslurm.so"
# --with-libslurm -> check with-path
SEARCH_FOR="libslurmdb.so"

# --with-libslurm -> check with-path

if test -r $PHP_SLURM/; then # path given as parameter
SLURM_DIR=$PHP_SLURM
SLURMLIB_PATH="$SLURM_DIR/lib"
else # search default path list
AC_MSG_CHECKING([for libslurm.so in default paths])
AC_MSG_CHECKING([for libslurmdb.so in default paths])
for i in $SLURMLIB_PATH ; do
if test -r $i/$SEARCH_FOR; then
SLURM_DIR=$i
PHP_ADD_LIBPATH($i, SLURM_PHP_SHARED_LIBADD)

AC_MSG_RESULT([found in $i])

fi
done
fi

if test -z "$SLURM_DIR"; then
AC_MSG_RESULT([not found])
AC_MSG_ERROR([Please reinstall the slurm distribution])
fi

PHP_ADD_INCLUDE($SLURMINCLUDE_PATH)
LIBNAME=slurm

LIBNAME=slurmdb
LIBSYMBOL=slurm_acct_storage_init

PHP_CHECK_LIBRARY($LIBNAME, $LIBSYMBOL,
[PHP_ADD_LIBRARY($LIBNAME, , SLURM_PHP_SHARED_LIBADD)
AC_DEFINE(HAVE_SLURMLIB,1,[ ])],
[AC_MSG_ERROR([wrong libslurm version or lib not found])],
[-L$SLURM_DIR -lslurm])
[AC_MSG_ERROR([wrong libslurmdb version or lib not found])],
[-L$SLURM_DIR -l$LIBNAME])


PHP_SUBST(SLURM_PHP_SHARED_LIBADD)

AC_CHECK_HEADERS(stdbool.h)
AC_CHECK_HEADERS(xmalloc.h)

AC_DEFINE(HAVE_SLURM_PHP, 1, [Whether you have SLURM])
#PHP_EXTENSION(slurm_php, $ext_shared)
Expand Down
7 changes: 6 additions & 1 deletion slurm_php.c
Expand Up @@ -90,6 +90,11 @@ zend_module_entry slurm_php_module_entry = {
ZEND_GET_MODULE(slurm_php)
#endif

#ifdef HAVE_XMALLOC_H
#define malloc(size) xmalloc(size)
#define free(ptr) xfree(ptr)
#endif


/*****************************************************************************\
* TODO
Expand All @@ -116,7 +121,7 @@ void parse_node_pointer(zval *sub_arr, node_info_t *node_arr)
zend_add_valid_assoc_time_string(sub_arr, "Boot Time",
&node_arr->boot_time);
add_assoc_long(sub_arr, "#CPU'S", node_arr->cpus);
add_assoc_long(sub_arr, "#Cores/CPU", node_arr->cpus);
add_assoc_long(sub_arr, "#Cores/CPU", node_arr->cores);

if (node_arr->features == NULL) {
add_assoc_null(sub_arr, "Features");
Expand Down

0 comments on commit 3425974

Please sign in to comment.