… | |
… | |
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> |
… | |
… | |
1402 | const_iv (ATNR_PARALYZE) const_iv (ATNR_TURN_UNDEAD) const_iv (ATNR_FEAR) const_iv (ATNR_CANCELLATION) |
1406 | const_iv (ATNR_PARALYZE) const_iv (ATNR_TURN_UNDEAD) const_iv (ATNR_FEAR) const_iv (ATNR_CANCELLATION) |
1403 | const_iv (ATNR_DEPLETE) const_iv (ATNR_DEATH) const_iv (ATNR_CHAOS) const_iv (ATNR_COUNTERSPELL) |
1407 | const_iv (ATNR_DEPLETE) const_iv (ATNR_DEATH) const_iv (ATNR_CHAOS) const_iv (ATNR_COUNTERSPELL) |
1404 | const_iv (ATNR_GODPOWER) const_iv (ATNR_HOLYWORD) const_iv (ATNR_BLIND) const_iv (ATNR_INTERNAL) |
1408 | const_iv (ATNR_GODPOWER) const_iv (ATNR_HOLYWORD) const_iv (ATNR_BLIND) const_iv (ATNR_INTERNAL) |
1405 | const_iv (ATNR_LIFE_STEALING) const_iv (ATNR_DISEASE) |
1409 | const_iv (ATNR_LIFE_STEALING) const_iv (ATNR_DISEASE) |
1406 | |
1410 | |
1407 | const_iv (MAP_IN_MEMORY) const_iv (MAP_SWAPPED) const_iv (MAP_LOADING) const_iv (MAP_SAVING) |
1411 | const_iv (MAP_ACTIVE) const_iv (MAP_SWAPPED) const_iv (MAP_LOADING) const_iv (MAP_SAVING) |
|
|
1412 | const_iv (MAP_INACTIVE) |
1408 | |
1413 | |
1409 | const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT) |
1414 | const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT) |
1410 | const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP) |
1415 | const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP) |
1411 | |
1416 | |
1412 | const_iv (VERSION_CS) const_iv (VERSION_SC) |
1417 | const_iv (VERSION_CS) const_iv (VERSION_SC) |
… | |
… | |
1611 | octet_string path_combine (octet_string base, octet_string path) |
1616 | octet_string path_combine (octet_string base, octet_string path) |
1612 | PROTOTYPE: $$ |
1617 | PROTOTYPE: $$ |
1613 | |
1618 | |
1614 | octet_string path_combine_and_normalize (octet_string base, octet_string path) |
1619 | octet_string path_combine_and_normalize (octet_string base, octet_string path) |
1615 | PROTOTYPE: $$ |
1620 | PROTOTYPE: $$ |
1616 | |
|
|
1617 | void |
|
|
1618 | mallinfo () |
|
|
1619 | PPCODE: |
|
|
1620 | { |
|
|
1621 | #if __GLIBC__ |
|
|
1622 | struct mallinfo mai = mallinfo (); |
|
|
1623 | EXTEND (SP, 10*2); |
|
|
1624 | PUSHs (sv_2mortal (newSVpv ("arena" , 0))); PUSHs (sv_2mortal (newSViv (mai.arena))); |
|
|
1625 | PUSHs (sv_2mortal (newSVpv ("ordblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.ordblks))); |
|
|
1626 | PUSHs (sv_2mortal (newSVpv ("smblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.smblks))); |
|
|
1627 | PUSHs (sv_2mortal (newSVpv ("hblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.hblks))); |
|
|
1628 | PUSHs (sv_2mortal (newSVpv ("hblkhd" , 0))); PUSHs (sv_2mortal (newSViv (mai.hblkhd))); |
|
|
1629 | PUSHs (sv_2mortal (newSVpv ("usmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.usmblks))); |
|
|
1630 | PUSHs (sv_2mortal (newSVpv ("fsmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.fsmblks))); |
|
|
1631 | PUSHs (sv_2mortal (newSVpv ("uordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.uordblks))); |
|
|
1632 | PUSHs (sv_2mortal (newSVpv ("fordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.fordblks))); |
|
|
1633 | PUSHs (sv_2mortal (newSVpv ("keepcost", 0))); PUSHs (sv_2mortal (newSViv (mai.keepcost))); |
|
|
1634 | #endif |
|
|
1635 | EXTEND (SP, 2*2); |
|
|
1636 | PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc))); |
|
|
1637 | PUSHs (sv_2mortal (newSVpv ("shstr_alloc", 0))); PUSHs (sv_2mortal (newSVuv (shstr_alloc))); |
|
|
1638 | } |
|
|
1639 | |
1621 | |
1640 | void |
1622 | void |
1641 | sub_generation_inc () |
1623 | sub_generation_inc () |
1642 | CODE: |
1624 | CODE: |
1643 | PL_sub_generation++; |
1625 | PL_sub_generation++; |
… | |
… | |
1680 | |
1662 | |
1681 | #if _POSIX_MEMLOCK |
1663 | #if _POSIX_MEMLOCK |
1682 | |
1664 | |
1683 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1665 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1684 | INIT: |
1666 | INIT: |
|
|
1667 | #if __GLIBC__ |
1685 | mallopt (M_PERTURB, 0xaa); // bug-workaround for linux glibc+mlockall+calloc |
1668 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
|
|
1669 | #endif |
1686 | |
1670 | |
1687 | int munlockall () |
1671 | int munlockall () |
1688 | |
1672 | |
1689 | #endif |
1673 | #endif |
|
|
1674 | |
|
|
1675 | int |
|
|
1676 | malloc_trim (IV pad = 0) |
|
|
1677 | |
|
|
1678 | void |
|
|
1679 | mallinfo () |
|
|
1680 | PPCODE: |
|
|
1681 | { |
|
|
1682 | #if __GLIBC__ |
|
|
1683 | struct mallinfo mai = mallinfo (); |
|
|
1684 | EXTEND (SP, 10*2); |
|
|
1685 | PUSHs (sv_2mortal (newSVpv ("arena" , 0))); PUSHs (sv_2mortal (newSViv (mai.arena))); |
|
|
1686 | PUSHs (sv_2mortal (newSVpv ("ordblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.ordblks))); |
|
|
1687 | PUSHs (sv_2mortal (newSVpv ("smblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.smblks))); |
|
|
1688 | PUSHs (sv_2mortal (newSVpv ("hblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.hblks))); |
|
|
1689 | PUSHs (sv_2mortal (newSVpv ("hblkhd" , 0))); PUSHs (sv_2mortal (newSViv (mai.hblkhd))); |
|
|
1690 | PUSHs (sv_2mortal (newSVpv ("usmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.usmblks))); |
|
|
1691 | PUSHs (sv_2mortal (newSVpv ("fsmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.fsmblks))); |
|
|
1692 | PUSHs (sv_2mortal (newSVpv ("uordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.uordblks))); |
|
|
1693 | PUSHs (sv_2mortal (newSVpv ("fordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.fordblks))); |
|
|
1694 | PUSHs (sv_2mortal (newSVpv ("keepcost", 0))); PUSHs (sv_2mortal (newSViv (mai.keepcost))); |
|
|
1695 | #endif |
|
|
1696 | EXTEND (SP, 2*2); |
|
|
1697 | PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc))); |
|
|
1698 | PUSHs (sv_2mortal (newSVpv ("shstr_alloc", 0))); PUSHs (sv_2mortal (newSVuv (shstr_alloc))); |
|
|
1699 | } |
1690 | |
1700 | |
1691 | int find_animation (utf8_string text) |
1701 | int find_animation (utf8_string text) |
1692 | PROTOTYPE: $ |
1702 | PROTOTYPE: $ |
1693 | |
1703 | |
1694 | int random_roll (int min, int max, object *op, int goodbad); |
1704 | int random_roll (int min, int max, object *op, int goodbad); |
… | |
… | |
1775 | EXTEND (SP, NUM_COINS); |
1785 | EXTEND (SP, NUM_COINS); |
1776 | for (int i = 0; i < NUM_COINS; ++i) |
1786 | for (int i = 0; i < NUM_COINS; ++i) |
1777 | PUSHs (sv_2mortal (to_sv (archetype::find (coins [i])))); |
1787 | PUSHs (sv_2mortal (to_sv (archetype::find (coins [i])))); |
1778 | |
1788 | |
1779 | bool |
1789 | bool |
1780 | load_resource_file (octet_string filename) |
1790 | load_resource_file_ (octet_string filename) |
1781 | |
1791 | |
1782 | MODULE = cf PACKAGE = cf::attachable |
1792 | MODULE = cf PACKAGE = cf::attachable |
1783 | |
1793 | |
1784 | int |
1794 | int |
1785 | valid (SV *obj) |
1795 | valid (SV *obj) |
… | |
… | |
2068 | const_utf8_string |
2078 | const_utf8_string |
2069 | base_name (object *op, int plural = op->nrof > 1) |
2079 | base_name (object *op, int plural = op->nrof > 1) |
2070 | CODE: |
2080 | CODE: |
2071 | RETVAL = query_base_name (op, plural); |
2081 | RETVAL = query_base_name (op, plural); |
2072 | OUTPUT: RETVAL |
2082 | OUTPUT: RETVAL |
2073 | |
|
|
2074 | object *decrease_ob_nr (object *op, unsigned long i) |
|
|
2075 | |
2083 | |
2076 | # return the tail of an object, excluding itself |
2084 | # return the tail of an object, excluding itself |
2077 | void |
2085 | void |
2078 | tail (object *op) |
2086 | tail (object *op) |
2079 | PPCODE: |
2087 | PPCODE: |