ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/cfperl.xs
(Generate patch)

Comparing deliantra/server/server/cfperl.xs (file contents):
Revision 1.277 by root, Sat Apr 19 21:10:29 2008 UTC vs.
Revision 1.284 by root, Sat May 3 11:14:50 2008 UTC

43# include <sys/mman.h> 43# include <sys/mman.h>
44#endif 44#endif
45 45
46#if HAVE_MALLOC_H 46#if HAVE_MALLOC_H
47# include <malloc.h> 47# include <malloc.h>
48#endif
49
50#if !__GLIBC__
51# define malloc_trim(pad) -1
48#endif 52#endif
49 53
50#include <EXTERN.h> 54#include <EXTERN.h>
51#include <perl.h> 55#include <perl.h>
52#include <XSUB.h> 56#include <XSUB.h>
1428 1432
1429 const_iv (SYMMETRY_RANDOM) const_iv (SYMMETRY_NONE) const_iv (SYMMETRY_X) 1433 const_iv (SYMMETRY_RANDOM) const_iv (SYMMETRY_NONE) const_iv (SYMMETRY_X)
1430 const_iv (SYMMETRY_Y) const_iv (SYMMETRY_XY) 1434 const_iv (SYMMETRY_Y) const_iv (SYMMETRY_XY)
1431 1435
1432 const_iv (GT_ENVIRONMENT) const_iv (GT_INVISIBLE) const_iv (GT_STARTEQUIP) 1436 const_iv (GT_ENVIRONMENT) const_iv (GT_INVISIBLE) const_iv (GT_STARTEQUIP)
1433 const_iv (GT_APPLY) const_iv (GT_ONLY_GOOD) const_iv (GT_UPDATE_INV) 1437 const_iv (GT_APPLY) const_iv (GT_ONLY_GOOD) const_iv (GT_MINIMAL)
1434 const_iv (GT_MINIMAL)
1435 1438
1436 const_iv (FT_FACE) const_iv (FT_MUSIC) const_iv (FT_SOUND) 1439 const_iv (FT_FACE) const_iv (FT_MUSIC) const_iv (FT_SOUND)
1437 const_iv (FT_RSRC) const_iv (FT_NUM) 1440 const_iv (FT_RSRC) const_iv (FT_NUM)
1438 }; 1441 };
1439 1442
1612octet_string path_combine (octet_string base, octet_string path) 1615octet_string path_combine (octet_string base, octet_string path)
1613 PROTOTYPE: $$ 1616 PROTOTYPE: $$
1614 1617
1615octet_string path_combine_and_normalize (octet_string base, octet_string path) 1618octet_string path_combine_and_normalize (octet_string base, octet_string path)
1616 PROTOTYPE: $$ 1619 PROTOTYPE: $$
1617
1618void
1619mallinfo ()
1620 PPCODE:
1621{
1622#if __GLIBC__
1623 struct mallinfo mai = mallinfo ();
1624 EXTEND (SP, 10*2);
1625 PUSHs (sv_2mortal (newSVpv ("arena" , 0))); PUSHs (sv_2mortal (newSViv (mai.arena)));
1626 PUSHs (sv_2mortal (newSVpv ("ordblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.ordblks)));
1627 PUSHs (sv_2mortal (newSVpv ("smblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.smblks)));
1628 PUSHs (sv_2mortal (newSVpv ("hblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.hblks)));
1629 PUSHs (sv_2mortal (newSVpv ("hblkhd" , 0))); PUSHs (sv_2mortal (newSViv (mai.hblkhd)));
1630 PUSHs (sv_2mortal (newSVpv ("usmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.usmblks)));
1631 PUSHs (sv_2mortal (newSVpv ("fsmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.fsmblks)));
1632 PUSHs (sv_2mortal (newSVpv ("uordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.uordblks)));
1633 PUSHs (sv_2mortal (newSVpv ("fordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.fordblks)));
1634 PUSHs (sv_2mortal (newSVpv ("keepcost", 0))); PUSHs (sv_2mortal (newSViv (mai.keepcost)));
1635#endif
1636 EXTEND (SP, 2*2);
1637 PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc)));
1638 PUSHs (sv_2mortal (newSVpv ("shstr_alloc", 0))); PUSHs (sv_2mortal (newSVuv (shstr_alloc)));
1639}
1640 1620
1641void 1621void
1642sub_generation_inc () 1622sub_generation_inc ()
1643 CODE: 1623 CODE:
1644 PL_sub_generation++; 1624 PL_sub_generation++;
1681 1661
1682#if _POSIX_MEMLOCK 1662#if _POSIX_MEMLOCK
1683 1663
1684int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) 1664int mlockall (int flags = MCL_CURRENT | MCL_FUTURE)
1685 INIT: 1665 INIT:
1686#ifdef __linux 1666#if __GLIBC__
1687 mallopt (M_PERTURB, 0xaa); // bug-workaround for linux glibc+mlockall+calloc 1667 mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc
1688#endif 1668#endif
1689 1669
1690int munlockall () 1670int munlockall ()
1691 1671
1692#endif 1672#endif
1673
1674int
1675malloc_trim (IV pad = 0)
1676
1677void
1678mallinfo ()
1679 PPCODE:
1680{
1681#if __GLIBC__
1682 struct mallinfo mai = mallinfo ();
1683 EXTEND (SP, 10*2);
1684 PUSHs (sv_2mortal (newSVpv ("arena" , 0))); PUSHs (sv_2mortal (newSViv (mai.arena)));
1685 PUSHs (sv_2mortal (newSVpv ("ordblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.ordblks)));
1686 PUSHs (sv_2mortal (newSVpv ("smblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.smblks)));
1687 PUSHs (sv_2mortal (newSVpv ("hblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.hblks)));
1688 PUSHs (sv_2mortal (newSVpv ("hblkhd" , 0))); PUSHs (sv_2mortal (newSViv (mai.hblkhd)));
1689 PUSHs (sv_2mortal (newSVpv ("usmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.usmblks)));
1690 PUSHs (sv_2mortal (newSVpv ("fsmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.fsmblks)));
1691 PUSHs (sv_2mortal (newSVpv ("uordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.uordblks)));
1692 PUSHs (sv_2mortal (newSVpv ("fordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.fordblks)));
1693 PUSHs (sv_2mortal (newSVpv ("keepcost", 0))); PUSHs (sv_2mortal (newSViv (mai.keepcost)));
1694#endif
1695 EXTEND (SP, 2*2);
1696 PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc)));
1697 PUSHs (sv_2mortal (newSVpv ("shstr_alloc", 0))); PUSHs (sv_2mortal (newSVuv (shstr_alloc)));
1698 PUSHs (sv_2mortal (newSVpv ("objects" , 0))); PUSHs (sv_2mortal (newSVuv (objects.size () * sizeof (object))));
1699}
1693 1700
1694int find_animation (utf8_string text) 1701int find_animation (utf8_string text)
1695 PROTOTYPE: $ 1702 PROTOTYPE: $
1696 1703
1697int random_roll (int min, int max, object *op, int goodbad); 1704int random_roll (int min, int max, object *op, int goodbad);
1778 EXTEND (SP, NUM_COINS); 1785 EXTEND (SP, NUM_COINS);
1779 for (int i = 0; i < NUM_COINS; ++i) 1786 for (int i = 0; i < NUM_COINS; ++i)
1780 PUSHs (sv_2mortal (to_sv (archetype::find (coins [i])))); 1787 PUSHs (sv_2mortal (to_sv (archetype::find (coins [i]))));
1781 1788
1782bool 1789bool
1783load_resource_file (octet_string filename) 1790load_resource_file_ (octet_string filename)
1784 1791
1785MODULE = cf PACKAGE = cf::attachable 1792MODULE = cf PACKAGE = cf::attachable
1786 1793
1787int 1794int
1788valid (SV *obj) 1795valid (SV *obj)
1850 OUTPUT: RETVAL 1857 OUTPUT: RETVAL
1851 1858
1852object *actives (U32 index) 1859object *actives (U32 index)
1853 CODE: 1860 CODE:
1854 RETVAL = index < actives.size () ? actives [index] : 0; 1861 RETVAL = index < actives.size () ? actives [index] : 0;
1862 OUTPUT: RETVAL
1863
1864int mortals_size ()
1865 CODE:
1866 RETVAL = attachable::mortals.size ();
1855 OUTPUT: RETVAL 1867 OUTPUT: RETVAL
1856 1868
1857const char *slot_use_name (U32 slot) 1869const char *slot_use_name (U32 slot)
1858 ALIAS: 1870 ALIAS:
1859 slot_nonuse_name = 1 1871 slot_nonuse_name = 1
2038 CODE: 2050 CODE:
2039{ 2051{
2040 RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); 2052 RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y);
2041} 2053}
2042 2054
2043const_utf8_string get_ob_key_value (object *op, utf8_string key) 2055shstr
2056object::kv_get (shstr key)
2044 2057
2045bool set_ob_key_value (object *op, utf8_string key, utf8_string value = 0, int add_key = 1) 2058void
2059object::kv_del (shstr key)
2060
2061void
2062object::kv_set (shstr key, shstr value)
2046 2063
2047object *get_nearest_player (object *ob) 2064object *get_nearest_player (object *ob)
2048 ALIAS: nearest_player = 0 2065 ALIAS: nearest_player = 0
2049 PREINIT: 2066 PREINIT:
2050 extern object *get_nearest_player (object *); 2067 extern object *get_nearest_player (object *);
2071const_utf8_string 2088const_utf8_string
2072base_name (object *op, int plural = op->nrof > 1) 2089base_name (object *op, int plural = op->nrof > 1)
2073 CODE: 2090 CODE:
2074 RETVAL = query_base_name (op, plural); 2091 RETVAL = query_base_name (op, plural);
2075 OUTPUT: RETVAL 2092 OUTPUT: RETVAL
2076
2077object *decrease_ob_nr (object *op, unsigned long i)
2078 2093
2079# return the tail of an object, excluding itself 2094# return the tail of an object, excluding itself
2080void 2095void
2081tail (object *op) 2096tail (object *op)
2082 PPCODE: 2097 PPCODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines