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.276 by root, Tue Apr 15 14:21:04 2008 UTC vs.
Revision 1.285 by root, Sun May 4 08:25:33 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:
1666#if __GLIBC__
1686 mallopt (M_PERTURB, 0xaa); // bug-workaround for linux glibc+mlockall+calloc 1667 mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc
1668#endif
1687 1669
1688int munlockall () 1670int munlockall ()
1689 1671
1690#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}
1691 1700
1692int find_animation (utf8_string text) 1701int find_animation (utf8_string text)
1693 PROTOTYPE: $ 1702 PROTOTYPE: $
1694 1703
1695int random_roll (int min, int max, object *op, int goodbad); 1704int random_roll (int min, int max, object *op, int goodbad);
1776 EXTEND (SP, NUM_COINS); 1785 EXTEND (SP, NUM_COINS);
1777 for (int i = 0; i < NUM_COINS; ++i) 1786 for (int i = 0; i < NUM_COINS; ++i)
1778 PUSHs (sv_2mortal (to_sv (archetype::find (coins [i])))); 1787 PUSHs (sv_2mortal (to_sv (archetype::find (coins [i]))));
1779 1788
1780bool 1789bool
1781load_resource_file (octet_string filename) 1790load_resource_file_ (octet_string filename)
1782 1791
1783MODULE = cf PACKAGE = cf::attachable 1792MODULE = cf PACKAGE = cf::attachable
1784 1793
1785int 1794int
1786valid (SV *obj) 1795valid (SV *obj)
1850object *actives (U32 index) 1859object *actives (U32 index)
1851 CODE: 1860 CODE:
1852 RETVAL = index < actives.size () ? actives [index] : 0; 1861 RETVAL = index < actives.size () ? actives [index] : 0;
1853 OUTPUT: RETVAL 1862 OUTPUT: RETVAL
1854 1863
1864int mortals_size ()
1865 CODE:
1866 RETVAL = attachable::mortals.size ();
1867 OUTPUT: RETVAL
1868
1855const char *slot_use_name (U32 slot) 1869const char *slot_use_name (U32 slot)
1856 ALIAS: 1870 ALIAS:
1857 slot_nonuse_name = 1 1871 slot_nonuse_name = 1
1858 CODE: 1872 CODE:
1859{ 1873{
1937void apply_below (object *op) 1951void apply_below (object *op)
1938 CODE: 1952 CODE:
1939 player_apply_below (op); 1953 player_apply_below (op);
1940 1954
1941int cast_heal (object *op, object *caster, object *spell, int dir = 0) 1955int cast_heal (object *op, object *caster, object *spell, int dir = 0)
1942
1943#//TODO
1944object *clone_ (object *op, int recursive = 0)
1945 CODE:
1946 if (recursive)
1947 RETVAL = object_create_clone (op);
1948 else
1949 {
1950 RETVAL = object::create ();
1951 op->copy_to (RETVAL);
1952 }
1953 OUTPUT: RETVAL
1954 1956
1955int pay_item (object *op, object *buyer) 1957int pay_item (object *op, object *buyer)
1956 CODE: 1958 CODE:
1957 RETVAL = pay_for_item (op, buyer); 1959 RETVAL = pay_for_item (op, buyer);
1958 OUTPUT: RETVAL 1960 OUTPUT: RETVAL
2036 CODE: 2038 CODE:
2037{ 2039{
2038 RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); 2040 RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y);
2039} 2041}
2040 2042
2041const_utf8_string get_ob_key_value (object *op, utf8_string key) 2043shstr
2044object::kv_get (shstr key)
2042 2045
2043bool set_ob_key_value (object *op, utf8_string key, utf8_string value = 0, int add_key = 1) 2046void
2047object::kv_del (shstr key)
2048
2049void
2050object::kv_set (shstr key, shstr value)
2044 2051
2045object *get_nearest_player (object *ob) 2052object *get_nearest_player (object *ob)
2046 ALIAS: nearest_player = 0 2053 ALIAS: nearest_player = 0
2047 PREINIT: 2054 PREINIT:
2048 extern object *get_nearest_player (object *); 2055 extern object *get_nearest_player (object *);
2069const_utf8_string 2076const_utf8_string
2070base_name (object *op, int plural = op->nrof > 1) 2077base_name (object *op, int plural = op->nrof > 1)
2071 CODE: 2078 CODE:
2072 RETVAL = query_base_name (op, plural); 2079 RETVAL = query_base_name (op, plural);
2073 OUTPUT: RETVAL 2080 OUTPUT: RETVAL
2074
2075object *decrease_ob_nr (object *op, unsigned long i)
2076 2081
2077# return the tail of an object, excluding itself 2082# return the tail of an object, excluding itself
2078void 2083void
2079tail (object *op) 2084tail (object *op)
2080 PPCODE: 2085 PPCODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines