Changeset 82
- Timestamp:
- 2006-06-18T03:26:00+02:00 (7 years ago)
- File:
-
- 1 edited
-
trunk/xcache.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/xcache.c
r75 r82 12 12 #include "ext/standard/info.h" 13 13 #include "ext/standard/md5.h" 14 #include "ext/standard/php_math.h" 14 15 #include "zend_extensions.h" 15 16 #include "SAPI.h" … … 1784 1785 1785 1786 /* {{{ PHP_INI */ 1786 static PHP_INI_MH(xc_OnUpdateLong)1787 {1788 long *p = (long *)mh_arg1;1789 *p = zend_atoi(new_value, new_value_length);1790 return SUCCESS;1791 }1792 1787 1793 1788 static PHP_INI_MH(xc_OnUpdateBool) … … 1801 1796 *p = (zend_bool) 1; 1802 1797 } 1803 return SUCCESS;1804 }1805 1806 static PHP_INI_MH(xc_OnUpdateHashInfo)1807 {1808 xc_hash_t *p = (xc_hash_t *)mh_arg1;1809 int bits, size;1810 1811 p->size = zend_atoi(new_value, new_value_length);1812 for (size = 1, bits = 1; size < p->size; bits ++, size <<= 1) {1813 /* empty body */1814 }1815 p->size = size;1816 p->bits = bits;1817 p->mask = size - 1;1818 1819 1798 return SUCCESS; 1820 1799 } … … 1830 1809 return SUCCESS; 1831 1810 } 1811 1832 1812 #ifdef ZEND_ENGINE_2 1833 1813 #define OnUpdateInt OnUpdateLong … … 1840 1820 #endif 1841 1821 PHP_INI_BEGIN() 1842 PHP_INI_ENTRY1 ("xcache.size", "0", PHP_INI_SYSTEM, xc_OnUpdateLong, &xc_php_size)1843 PHP_INI_ENTRY1 ("xcache.count", "1", PHP_INI_SYSTEM, xc_OnUpdateHashInfo, &xc_php_hcache)1844 PHP_INI_ENTRY1 ("xcache.slots", "8K", PHP_INI_SYSTEM, xc_OnUpdateHashInfo, &xc_php_hentry)1845 1846 PHP_INI_ENTRY1 ("xcache.var_size", "0", PHP_INI_SYSTEM, xc_OnUpdateLong, &xc_var_size)1847 PHP_INI_ENTRY1 ("xcache.var_count", "1", PHP_INI_SYSTEM, xc_OnUpdateHashInfo, &xc_var_hcache)1848 PHP_INI_ENTRY1 ("xcache.var_slots", "8K", PHP_INI_SYSTEM, xc_OnUpdateHashInfo, &xc_var_hentry)1849 1850 1822 PHP_INI_ENTRY1 ("xcache.mmap_path", DEFAULT_PATH, PHP_INI_SYSTEM, xc_OnUpdateString, &xc_mmap_path) 1851 1823 PHP_INI_ENTRY1 ("xcache.coredump_directory", "", PHP_INI_SYSTEM, xc_OnUpdateString, &xc_coredump_dir) … … 1863 1835 PHP_INI_END() 1864 1836 /* }}} */ 1837 static int xc_config_long_disp(char *name, char *default_value) /* {{{ */ 1838 { 1839 char *value; 1840 char buf[100]; 1841 1842 if (cfg_get_string(name, &value) != SUCCESS) { 1843 sprintf(buf, "%s (default)", default_value); 1844 php_info_print_table_row(2, name, buf); 1845 } 1846 else { 1847 php_info_print_table_row(2, name, value); 1848 } 1849 1850 return SUCCESS; 1851 } 1852 /* }}} */ 1853 #define xc_config_hash_disp xc_config_long_disp 1865 1854 /* {{{ PHP_MINFO_FUNCTION(xcache) */ 1866 1855 static PHP_MINFO_FUNCTION(xcache) 1867 1856 { 1857 char buf[100]; 1858 char *ptr; 1859 1868 1860 php_info_print_table_start(); 1869 php_info_print_table_header(2, "XCache Support", (xc_php_size || xc_var_size) ? "enabled" : "disabled");1861 php_info_print_table_header(2, "XCache Support", XCACHE_MODULES); 1870 1862 php_info_print_table_row(2, "Version", XCACHE_VERSION); 1871 1863 php_info_print_table_row(2, "Modules Built", XCACHE_MODULES); 1872 1864 php_info_print_table_row(2, "Readonly Protection", xc_readonly_protection ? "enabled" : "N/A"); 1873 php_info_print_table_row(2, "Opcode Cache", xc_php_size ? "enabled" : "disabled"); 1874 php_info_print_table_row(2, "Variable Cache", xc_var_size ? "enabled" : "disabled"); 1865 1866 if (xc_php_size) { 1867 ptr = _php_math_number_format(xc_php_size, 0, '.', ','); 1868 sprintf(buf, "enabled, %s bytes, %d split(s), with %d slots each", ptr, xc_php_hcache.size, xc_php_hentry.size); 1869 php_info_print_table_row(2, "Opcode Cache", buf); 1870 efree(ptr); 1871 } 1872 else { 1873 php_info_print_table_row(2, "Opcode Cache", "disabled"); 1874 } 1875 if (xc_var_size) { 1876 ptr = _php_math_number_format(xc_var_size, 0, '.', ','); 1877 sprintf(buf, "enabled, %s bytes, %d split(s), with %d slots each", ptr, xc_var_hcache.size, xc_var_hentry.size); 1878 php_info_print_table_row(2, "Variable Cache", buf); 1879 efree(ptr); 1880 } 1881 else { 1882 php_info_print_table_row(2, "Variable Cache", "disabled"); 1883 } 1875 1884 #ifdef HAVE_XCACHE_COVERAGER 1876 1885 php_info_print_table_row(2, "Coverage Dumper", XG(coveragedumper) && xc_coveragedump_dir && xc_coveragedump_dir[0] ? "enabled" : "disabled"); 1877 1886 #endif 1878 1887 php_info_print_table_end(); 1888 1889 php_info_print_table_start(); 1890 php_info_print_table_header(2, "Directive ", "Value"); 1891 xc_config_long_disp("xcache.size", "0"); 1892 xc_config_hash_disp("xcache.count", "1"); 1893 xc_config_hash_disp("xcache.slots", "8K"); 1894 1895 xc_config_long_disp("xcache.var_size", "0"); 1896 xc_config_hash_disp("xcache.var_count", "1"); 1897 xc_config_hash_disp("xcache.var_slots", "8K"); 1898 php_info_print_table_end(); 1899 1879 1900 DISPLAY_INI_ENTRIES(); 1880 1901 } … … 1913 1934 } 1914 1935 /* }}} */ 1936 static int xc_config_hash(xc_hash_t *p, char *name, char *default_value) /* {{{ */ 1937 { 1938 int bits, size; 1939 char *value; 1940 1941 if (cfg_get_string(name, &value) != SUCCESS) { 1942 value = default_value; 1943 } 1944 1945 p->size = zend_atoi(value, strlen(value)); 1946 for (size = 1, bits = 1; size < p->size; bits ++, size <<= 1) { 1947 /* empty body */ 1948 } 1949 p->size = size; 1950 p->bits = bits; 1951 p->mask = size - 1; 1952 1953 return SUCCESS; 1954 } 1955 /* }}} */ 1956 static int xc_config_long(long *p, char *name, char *default_value) /* {{{ */ 1957 { 1958 char *value; 1959 1960 if (cfg_get_string(name, &value) != SUCCESS) { 1961 value = default_value; 1962 } 1963 1964 *p = zend_atoi(value, strlen(value)); 1965 return SUCCESS; 1966 } 1967 /* }}} */ 1915 1968 /* {{{ PHP_MINIT_FUNCTION(xcache) */ 1916 1969 static PHP_MINIT_FUNCTION(xcache) … … 1938 1991 } 1939 1992 } 1993 1994 xc_config_long(&xc_php_size, "xcache.size", "0"); 1995 xc_config_hash(&xc_php_hcache, "xcache.count", "1"); 1996 xc_config_hash(&xc_php_hentry, "xcache.slots", "8K"); 1997 1998 xc_config_long(&xc_var_size, "xcache.var_size", "0"); 1999 xc_config_hash(&xc_var_hcache, "xcache.var_count", "1"); 2000 xc_config_hash(&xc_var_hentry, "xcache.var_slots", "8K"); 1940 2001 1941 2002 if (xc_php_size <= 0) {
Note: See TracChangeset
for help on using the changeset viewer.

