IPC-MMA
view release on metacpan or search on metacpan
mma_free (hash->mm, hash->ptr);
/* return the memory used for the hash header block */
mma_free (hash->mm, hash);
prelocked || mm_unlock(hash->mm);
} else mm_err_cant_lock;
} }
MODULE = IPC::MMA PACKAGE = IPC::MMA
PROTOTYPES: DISABLE
# so that MMA.pm can call constant in MMA.xs
double
constant(name,arg)
char *name
int arg
#------------------------- pass-throughs and basics -----------------------
MM *
mm_create(size, file)
size_t size
char *file
int
mm_permission(mm, mode, owner, group)
MM *mm
int mode
int owner
int group
void
mm_destroy(mm)
MM *mm
size_t
mm_maxsize()
size_t
mm_available(mm)
MM *mm
char *
mm_error()
void
mm_display_info(mm)
MM *mm
int
mm_lock(mm, mode)
MM *mm
mm_lock_mode mode
int
mm_unlock(mm)
MM *mm
void
mm_alloc_size ()
PPCODE:
if (GIMME_V == G_ARRAY) {
EXTEND(SP, 6);
XPUSHs(sv_2mortal(newSVuv((UV)mma_alloc_mask()+1)));
XPUSHs(sv_2mortal(newSVuv((UV)mma_alloc_base())));
XPUSHs(sv_2mortal(newSVuv((UV)sizeof(void *))));
XPUSHs(sv_2mortal(newSVuv((UV)IVSIZE)));
XPUSHs(sv_2mortal(newSVuv((UV)NVSIZE)));
XPUSHs(sv_2mortal(newSVuv((UV)DELTA_ENTRIES)));
} else {
XPUSHs(sv_2mortal(newSVuv((UV)mma_alloc_mask()+1)));
}
size_t
mm_round_up (size)
size_t size
#------------------------------------- scalars ------------------------------------
mm_scalar *
mm_make_scalar(mm)
MM *mm
ALIAS:
mma_make_scalar=1
CODE:
RETVAL = mm_make_scalar(mm, ix);
OUTPUT:
RETVAL
void
mm_free_scalar(scalar)
mm_scalar *scalar
ALIAS:
mma_free_scalar=1
CODE:
mm_free_scalar(scalar, ix);
SV *
mm_scalar_fetch(scalar)
mm_scalar *scalar
ALIAS:
mma_scalar_fetch=1
mm_scalar_get=2
mma_scalar_get=3
CODE:
RETVAL = mm_scalar_fetch(scalar, ix&1);
OUTPUT:
RETVAL
int
mm_scalar_store(scalar, sv)
mm_scalar *scalar
SV *sv
ALIAS:
mma_scalar_store=1
mm_scalar_set=2
mma_scalar_set=3
CODE:
RETVAL = mm_scalar_store(scalar, sv, ix&1);
if (!RETVAL && PL_dowarn && mm_error()) warn ("IPC::MMA: %s", mm_error());
OUTPUT:
RETVAL
#------------------------------------- arrays ------------------------------------
mm_array *
mm_make_array(mm, type, entries=0, option=0)
MM *mm
IV type
IV entries
UV option
ALIAS:
mma_make_array=1
CODE:
RETVAL = mm_make_array(mm, type, entries, option, ix);
OUTPUT:
RETVAL
void
mm_array_status (array)
mm_array *array
ALIAS:
mma_array_status=1
PREINIT:
IV statArray[4];
int i=0;
PPCODE:
mm_array_status (array, statArray, ix);
if (GIMME_V == G_ARRAY) {
if (statArray[0] >= 0) {
EXTEND(SP, 4);
while (i < 4) XPUSHs (sv_2mortal (newSViv(statArray[i++])));
} } else {
if (statArray[0] >= 0) {
XPUSHs (sv_2mortal (newSViv(statArray[0])));
} else XPUSHs (&PL_sv_undef);
}
SV *
mm_array_fetch (array, index)
mm_array *array
IV index
ALIAS:
mma_array_fetch=1
mm_array_fetch_nowrap=2
mma_array_fetch_nowrap=3
CODE:
if (index < 0 && !(ix & 2)) index += array->entries;
RETVAL = mm_array_fetch(array, index, ix&1);
OUTPUT:
RETVAL
int
mm_array_store (array, index, sv)
mm_array *array
IV index
SV *sv
ALIAS:
mma_array_store=1
mm_array_store_nowrap=2
mma_array_store_nowrap=3
CODE:
if (index < 0 && !(ix & 2)) index += array->entries;
RETVAL = mm_array_store(array, index, sv, ix&1);
if (!RETVAL && PL_dowarn && mm_error()) warn ("IPC::MMA: %s", mm_error());
OUTPUT:
RETVAL
UV
mm_array_fetchsize (array)
mm_array *array
ALIAS:
mma_array_fetchsize=1
int
mm_array_extend (array, entries)
mm_array *array
IV entries
ALIAS:
mma_array_extend=1
CODE:
RETVAL = mm_array_extend(array, entries, ix);
if (!RETVAL && PL_dowarn) warn("IPC::MMA: %s", mm_error());
OUTPUT:
RETVAL
int
mm_array_storesize (array, entries)
mm_array *array
IV entries
ALIAS:
mma_array_storesize=1
CODE:
RETVAL = mm_array_storesize(array, entries, ix);
if (!RETVAL && PL_dowarn) warn("IPC::MMA: %s", mm_error());
OUTPUT:
RETVAL
int
mm_array_exists (array, index)
mm_array *array
IV index
ALIAS:
mma_array_exists=1
mm_array_exists_nowrap=2
mma_array_exists_nowrap=3
CODE:
if (index < 0 && !(ix & 2)) index += array->entries;
RETVAL = mm_array_exists (array, index);
OUTPUT:
RETVAL
void
mm_array_splice (array, offset, length, ...)
mm_array *array
SV *offset
SV *length
ALIAS:
mma_array_splice=1
mm_array_splice_nowrap=2
mma_array_splice_nowrap=3
PREINIT:
IV index = SvOK(offset) ? SvIV(offset) < 0 && !(ix & 2) ? SvIV(offset)
+ array->entries
: SvIV(offset)
: 0;
UV del_count = SvOK(length) ? SvUV(length) : array->entries - index;
SV *delSVs[del_count];
UV add_count = items>3 ? items-3 : 0;
SV *addSVs[add_count];
int i;
PPCODE:
for (i=0; i<add_count; i++) addSVs[i] = ST(i+3);
if (!mm_array_splice (array,index,del_count,delSVs,add_count,addSVs,ix&1)) {
if (PL_dowarn && mm_error()) warn ("IPC::MMA: %s", mm_error());
del_count = 0;
}
/* "in scalar context, splice returns the last entry deleted"
means just return all of them in either scalar or array mode */
if (del_count || GIMME_V == G_ARRAY) {
EXTEND (SP, del_count);
for (i=0; i<del_count; i++) XPUSHs(sv_2mortal(delSVs[i]));
} else XPUSHs (&PL_sv_undef);
SV *
mm_array_delete (array, index)
mm_array *array
IV index
ALIAS:
mma_array_delete=1
mm_array_delete_nowrap=2
mma_array_delete_nowrap=3
PREINIT:
SV *ret;
CODE:
if (index < 0 && !(ix & 2)) index += array->entries;
if (array && index == array->entries - 1) {
if (!mm_array_splice (array, index, 1, &ret, 0, NULL, ix&1)
&& PL_dowarn && mm_error()) warn ("IPC::MMA: %s", mm_error());
RETVAL = ret;
} else {
RETVAL = mm_array_delete (array, index, ix&1);
}
OUTPUT:
RETVAL
UV
mm_array_push (array, ...)
mm_array *array
ALIAS:
mma_array_push=1
PREINIT:
int add_count = items - 1;
SV *addSVs[add_count];
int i;
CODE:
for (i=0; i < add_count; i++) addSVs[i] = ST(i+1);
if (!mm_array_splice (array, array->entries, 0, NULL, add_count, addSVs, ix)
&& PL_dowarn && mm_error()) warn ("IPC::MMA: %s", mm_error());
RETVAL = array->entries;
OUTPUT:
RETVAL
SV *
mm_array_pop (array)
mm_array *array
ALIAS:
mma_array_pop=1
PREINIT:
SV *ret;
CODE:
if (!mm_array_splice (array, array->entries - 1, 1, &ret, 0, NULL, ix)
OUTPUT:
RETVAL
void
mm_array_clear (array, entries=0)
mm_array *array
UV entries
ALIAS:
mma_array_clear=1
CODE:
mm_array_clear (array, entries, ix);
void
mm_free_array (array)
mm_array *array
ALIAS:
mma_free_array=1
CODE:
mm_free_array (array, ix);
#------------------------------------- hashes ------------------------------------
mm_hash *
mm_make_hash(mm, entries=0)
MM *mm
IV entries
ALIAS:
mma_make_hash=1
mm_make_btree_table=2
mma_make_btree_table=3
CODE:
RETVAL = mm_make_hash (mm, entries, ix&1);
OUTPUT:
RETVAL
SV *
mm_hash_fetch(hash, key)
mm_hash *hash
SV *key
ALIAS:
mma_hash_fetch=1
mm_hash_get_value=2
mma_hash_get_value=3
mm_hash_get=4
mma_hash_get=5
mm_btree_table_get=6
mma_btree_table_get=7
CODE:
RETVAL = mm_hash_fetch (hash, key, ix&1);
OUTPUT:
RETVAL
void
mm_hash_get_entry(hash, index)
mm_hash *hash
IV index
ALIAS:
mma_hash_get_entry=1
PREINIT:
SV* ret[2];
PPCODE:
mm_hash_get_entry(hash, index, ix, ret);
if (GIMME_V == G_ARRAY) {
if (SvOK(ret[0])) {
EXTEND(SP, 2);
XPUSHs (sv_2mortal (ret[0]));
XPUSHs (sv_2mortal (ret[1]));
} } else {
XPUSHs (sv_2mortal (ret[0]));
}
SV *
mm_hash_exists(hash, key)
mm_hash *hash
SV *key
ALIAS:
mma_hash_exists=1
mm_btree_table_exists=2
mma_btree_table_exists=3
CODE:
RETVAL = mm_hash_exists (hash, key, ix&1);
OUTPUT:
RETVAL
int
mm_hash_store(hash, key, val, flags=0)
mm_hash *hash
SV *key
SV *val
UV flags
ALIAS:
mma_hash_store=1
mm_hash_insert=2
mma_hash_insert=3
mm_btree_table_insert=4
mma_btree_table_insert=5
CODE:
RETVAL = mm_hash_store (hash, key, val, flags, ix&1);
if (!RETVAL && PL_dowarn && mm_error()) warn ("IPC::MMA: %s", mm_error());
OUTPUT:
RETVAL
SV *
mm_hash_delete(hash, key)
mm_hash *hash
SV *key
ALIAS:
mma_hash_delete=1
mm_btree_table_delete=2
mma_btree_table_delete=3
CODE:
RETVAL = mm_hash_delete (hash, key, ix&1);
OUTPUT:
RETVAL
SV *
mm_hash_scalar(hash)
mm_hash *hash
ALIAS:
mma_hash_scalar=1
CODE:
( run in 1.850 second using v1.01-cache-2.11-cpan-71847e10f99 )