PennMUSH Community

Changeset 942

Show
Ignore:
Timestamp:
06/14/07 21:07:09 (1 year ago)
Author:
shawnw
Message:

expr: Try mmap'ing help indexes to disk files

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 1.8.3/branches/experimental/config.h.in

    r897 r942  
    3333#undef I_SYS_IN 
    3434 
    35 #undef I_SYS_MMAN 
     35#undef HAVE_SYS_MMAN_H 
    3636 
    3737#undef I_SYS_PAGE 
     
    273273#undef HAVE_KQUEUE 
    274274 
     275#undef HAVE_MMAP 
     276 
     277#undef HAVE_POSIX_MADVISE 
     278 
     279#undef HAVE_MADVISE 
     280 
     281#undef HAVE_PWRITE 
     282 
    275283/* Variables and defines */ 
    276284 
  • 1.8.3/branches/experimental/configure

    r922 r942  
    68546854 
    68556855 
    6856 if test "${ac_cv_header_sys_mman_h+set}" = set; then 
    6857   { echo "$as_me:$LINENO: checking for sys/mman.h" >&5 
    6858 echo $ECHO_N "checking for sys/mman.h... $ECHO_C" >&6; } 
    6859 if test "${ac_cv_header_sys_mman_h+set}" = set; then 
    6860   echo $ECHO_N "(cached) $ECHO_C" >&6 
    6861 fi 
    6862 { echo "$as_me:$LINENO: result: $ac_cv_header_sys_mman_h" >&5 
    6863 echo "${ECHO_T}$ac_cv_header_sys_mman_h" >&6; } 
    6864 else 
    6865   # Is the header compilable? 
    6866 { echo "$as_me:$LINENO: checking sys/mman.h usability" >&5 
    6867 echo $ECHO_N "checking sys/mman.h usability... $ECHO_C" >&6; } 
    6868 cat >conftest.$ac_ext <<_ACEOF 
    6869 /* confdefs.h.  */ 
    6870 _ACEOF 
    6871 cat confdefs.h >>conftest.$ac_ext 
    6872 cat >>conftest.$ac_ext <<_ACEOF 
    6873 /* end confdefs.h.  */ 
    6874 $ac_includes_default 
    6875 #include <sys/mman.h> 
    6876 _ACEOF 
    6877 rm -f conftest.$ac_objext 
    6878 if { (ac_try="$ac_compile" 
    6879 case "(($ac_try" in 
    6880   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 
    6881   *) ac_try_echo=$ac_try;; 
    6882 esac 
    6883 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 
    6884   (eval "$ac_compile") 2>conftest.er1 
    6885   ac_status=$? 
    6886   grep -v '^ *+' conftest.er1 >conftest.err 
    6887   rm -f conftest.er1 
    6888   cat conftest.err >&5 
    6889   echo "$as_me:$LINENO: \$? = $ac_status" >&5 
    6890   (exit $ac_status); } && 
    6891      { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' 
    6892   { (case "(($ac_try" in 
    6893   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 
    6894   *) ac_try_echo=$ac_try;; 
    6895 esac 
    6896 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 
    6897   (eval "$ac_try") 2>&5 
    6898   ac_status=$? 
    6899   echo "$as_me:$LINENO: \$? = $ac_status" >&5 
    6900   (exit $ac_status); }; } && 
    6901      { ac_try='test -s conftest.$ac_objext' 
    6902   { (case "(($ac_try" in 
    6903   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 
    6904   *) ac_try_echo=$ac_try;; 
    6905 esac 
    6906 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 
    6907   (eval "$ac_try") 2>&5 
    6908   ac_status=$? 
    6909   echo "$as_me:$LINENO: \$? = $ac_status" >&5 
    6910   (exit $ac_status); }; }; then 
    6911   ac_header_compiler=yes 
    6912 else 
    6913   echo "$as_me: failed program was:" >&5 
    6914 sed 's/^/| /' conftest.$ac_ext >&5 
    6915  
    6916     ac_header_compiler=no 
    6917 fi 
    6918  
    6919 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 
    6920 { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 
    6921 echo "${ECHO_T}$ac_header_compiler" >&6; } 
    6922  
    6923 # Is the header present? 
    6924 { echo "$as_me:$LINENO: checking sys/mman.h presence" >&5 
    6925 echo $ECHO_N "checking sys/mman.h presence... $ECHO_C" >&6; } 
    6926 cat >conftest.$ac_ext <<_ACEOF 
    6927 /* confdefs.h.  */ 
    6928 _ACEOF 
    6929 cat confdefs.h >>conftest.$ac_ext 
    6930 cat >>conftest.$ac_ext <<_ACEOF 
    6931 /* end confdefs.h.  */ 
    6932 #include <sys/mman.h> 
    6933 _ACEOF 
    6934 if { (ac_try="$ac_cpp conftest.$ac_ext" 
    6935 case "(($ac_try" in 
    6936   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 
    6937   *) ac_try_echo=$ac_try;; 
    6938 esac 
    6939 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 
    6940   (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 
    6941   ac_status=$? 
    6942   grep -v '^ *+' conftest.er1 >conftest.err 
    6943   rm -f conftest.er1 
    6944   cat conftest.err >&5 
    6945   echo "$as_me:$LINENO: \$? = $ac_status" >&5 
    6946   (exit $ac_status); } >/dev/null; then 
    6947   if test -s conftest.err; then 
    6948     ac_cpp_err=$ac_c_preproc_warn_flag 
    6949     ac_cpp_err=$ac_cpp_err$ac_c_werror_flag 
    6950   else 
    6951     ac_cpp_err= 
    6952   fi 
    6953 else 
    6954   ac_cpp_err=yes 
    6955 fi 
    6956 if test -z "$ac_cpp_err"; then 
    6957   ac_header_preproc=yes 
    6958 else 
    6959   echo "$as_me: failed program was:" >&5 
    6960 sed 's/^/| /' conftest.$ac_ext >&5 
    6961  
    6962   ac_header_preproc=no 
    6963 fi 
    6964  
    6965 rm -f conftest.err conftest.$ac_ext 
    6966 { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 
    6967 echo "${ECHO_T}$ac_header_preproc" >&6; } 
    6968  
    6969 # So?  What about this header? 
    6970 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in 
    6971   yes:no: ) 
    6972     { echo "$as_me:$LINENO: WARNING: sys/mman.h: accepted by the compiler, rejected by the preprocessor!" >&5 
    6973 echo "$as_me: WARNING: sys/mman.h: accepted by the compiler, rejected by the preprocessor!" >&2;} 
    6974     { echo "$as_me:$LINENO: WARNING: sys/mman.h: proceeding with the compiler's result" >&5 
    6975 echo "$as_me: WARNING: sys/mman.h: proceeding with the compiler's result" >&2;} 
    6976     ac_header_preproc=yes 
    6977     ;; 
    6978   no:yes:* ) 
    6979     { echo "$as_me:$LINENO: WARNING: sys/mman.h: present but cannot be compiled" >&5 
    6980 echo "$as_me: WARNING: sys/mman.h: present but cannot be compiled" >&2;} 
    6981     { echo "$as_me:$LINENO: WARNING: sys/mman.h:     check for missing prerequisite headers?" >&5 
    6982 echo "$as_me: WARNING: sys/mman.h:     check for missing prerequisite headers?" >&2;} 
    6983     { echo "$as_me:$LINENO: WARNING: sys/mman.h: see the Autoconf documentation" >&5 
    6984 echo "$as_me: WARNING: sys/mman.h: see the Autoconf documentation" >&2;} 
    6985     { echo "$as_me:$LINENO: WARNING: sys/mman.h:     section \"Present But Cannot Be Compiled\"" >&5 
    6986 echo "$as_me: WARNING: sys/mman.h:     section \"Present But Cannot Be Compiled\"" >&2;} 
    6987     { echo "$as_me:$LINENO: WARNING: sys/mman.h: proceeding with the preprocessor's result" >&5 
    6988 echo "$as_me: WARNING: sys/mman.h: proceeding with the preprocessor's result" >&2;} 
    6989     { echo "$as_me:$LINENO: WARNING: sys/mman.h: in the future, the compiler will take precedence" >&5 
    6990 echo "$as_me: WARNING: sys/mman.h: in the future, the compiler will take precedence" >&2;} 
    6991  
    6992     ;; 
    6993 esac 
    6994 { echo "$as_me:$LINENO: checking for sys/mman.h" >&5 
    6995 echo $ECHO_N "checking for sys/mman.h... $ECHO_C" >&6; } 
    6996 if test "${ac_cv_header_sys_mman_h+set}" = set; then 
    6997   echo $ECHO_N "(cached) $ECHO_C" >&6 
    6998 else 
    6999   ac_cv_header_sys_mman_h=$ac_header_preproc 
    7000 fi 
    7001 { echo "$as_me:$LINENO: result: $ac_cv_header_sys_mman_h" >&5 
    7002 echo "${ECHO_T}$ac_cv_header_sys_mman_h" >&6; } 
    7003  
    7004 fi 
    7005 if test $ac_cv_header_sys_mman_h = yes; then 
    7006   cat >>confdefs.h <<\_ACEOF 
    7007 #define I_SYS_MMAN 1 
    7008 _ACEOF 
    7009  
    7010 fi 
    7011  
    7012  
    70136856if test "${ac_cv_header_sys_page_h+set}" = set; then 
    70146857  { echo "$as_me:$LINENO: checking for sys/page.h" >&5 
     
    78007643 
    78017644 
    7802 for ac_header in sys/un.h ieeefp.h sys/resource.h sys/event.h 
     7645 
     7646for ac_header in sys/mman.h sys/un.h ieeefp.h sys/resource.h sys/event.h 
    78037647do 
    78047648as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` 
     
    1624416088 
    1624516089 
    16246 for ac_func in snprintf vsnprintf 
     16090 
     16091for ac_func in mmap madvise posix_madvise pwrite 
    1624716092do 
    1624816093as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` 
     
    1635316198done 
    1635416199 
     16200 
     16201 
     16202 
     16203for ac_func in snprintf vsnprintf 
     16204do 
     16205as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` 
     16206{ echo "$as_me:$LINENO: checking for $ac_func" >&5 
     16207echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } 
     16208if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then 
     16209  echo $ECHO_N "(cached) $ECHO_C" >&6 
     16210else 
     16211  cat >conftest.$ac_ext <<_ACEOF 
     16212/* confdefs.h.  */ 
     16213_ACEOF 
     16214cat confdefs.h >>conftest.$ac_ext 
     16215cat >>conftest.$ac_ext <<_ACEOF 
     16216/* end confdefs.h.  */ 
     16217/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. 
     16218   For example, HP-UX 11i <limits.h> declares gettimeofday.  */ 
     16219#define $ac_func innocuous_$ac_func 
     16220 
     16221/* System header to define __stub macros and hopefully few prototypes, 
     16222    which can conflict with char $ac_func (); below. 
     16223    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since 
     16224    <limits.h> exists even on freestanding compilers.  */ 
     16225 
     16226#ifdef __STDC__ 
     16227# include <limits.h> 
     16228#else 
     16229# include <assert.h> 
     16230#endif 
     16231 
     16232#undef $ac_func 
     16233 
     16234/* Override any GCC internal prototype to avoid an error. 
     16235   Use char because int might match the return type of a GCC 
     16236   builtin and then its argument prototype would still apply.  */ 
     16237#ifdef __cplusplus 
     16238extern "C" 
     16239#endif 
     16240char $ac_func (); 
     16241/* The GNU C library defines this for functions which it implements 
     16242    to always fail with ENOSYS.  Some functions are actually named 
     16243    something starting with __ and the normal name is an alias.  */ 
     16244#if defined __stub_$ac_func || defined __stub___$ac_func 
     16245choke me 
     16246#endif 
     16247 
     16248int 
     16249main () 
     16250{ 
     16251return $ac_func (); 
     16252  ; 
     16253  return 0; 
     16254} 
     16255_ACEOF 
     16256rm -f conftest.$ac_objext conftest$ac_exeext 
     16257if { (ac_try="$ac_link" 
     16258case "(($ac_try" in 
     16259  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 
     16260  *) ac_try_echo=$ac_try;; 
     16261esac 
     16262eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 
     16263  (eval "$ac_link") 2>conftest.er1 
     16264  ac_status=$? 
     16265  grep -v '^ *+' conftest.er1 >conftest.err 
     16266  rm -f conftest.er1 
     16267  cat conftest.err >&5 
     16268  echo "$as_me:$LINENO: \$? = $ac_status" >&5 
     16269  (exit $ac_status); } && 
     16270     { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' 
     16271  { (case "(($ac_try" in 
     16272  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 
     16273  *) ac_try_echo=$ac_try;; 
     16274esac 
     16275eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 
     16276  (eval "$ac_try") 2>&5 
     16277  ac_status=$? 
     16278  echo "$as_me:$LINENO: \$? = $ac_status" >&5 
     16279  (exit $ac_status); }; } && 
     16280     { ac_try='test -s conftest$ac_exeext' 
     16281  { (case "(($ac_try" in 
     16282  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 
     16283  *) ac_try_echo=$ac_try;; 
     16284esac 
     16285eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 
     16286  (eval "$ac_try") 2>&5 
     16287  ac_status=$? 
     16288  echo "$as_me:$LINENO: \$? = $ac_status" >&5 
     16289  (exit $ac_status); }; }; then 
     16290  eval "$as_ac_var=yes" 
     16291else 
     16292  echo "$as_me: failed program was:" >&5 
     16293sed 's/^/| /' conftest.$ac_ext >&5 
     16294 
     16295    eval "$as_ac_var=no" 
     16296fi 
     16297 
     16298rm -f core conftest.err conftest.$ac_objext \ 
     16299      conftest$ac_exeext conftest.$ac_ext 
     16300fi 
     16301ac_res=`eval echo '${'$as_ac_var'}'` 
     16302           { echo "$as_me:$LINENO: result: $ac_res" >&5 
     16303echo "${ECHO_T}$ac_res" >&6; } 
     16304if test `eval echo '${'$as_ac_var'}'` = yes; then 
     16305  cat >>confdefs.h <<_ACEOF 
     16306#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 
     16307_ACEOF 
     16308 
     16309fi 
     16310done 
     16311 
    1635516312{ echo "$as_me:$LINENO: checking for working snprintf" >&5 
    1635616313echo $ECHO_N "checking for working snprintf... $ECHO_C" >&6; } 
     
    1797617933ac_config_files="$ac_config_files Makefile src/Makefile" 
    1797717934 
    17978 ac_config_files="$ac_config_files utils/mkcmds.sh game/txt/compose.sh" 
     17935ac_config_files="$ac_config_files utils/mkcmds.sh" 
     17936 
     17937ac_config_files="$ac_config_files game/txt/compose.sh" 
    1797917938 
    1798017939cat >confcache <<\_ACEOF 
     
    1906819027 
    1906919028  case $ac_file$ac_mode in 
    19070     "utils/mkcmds.sh":F) chmod +x utils/mkcmds.sh game/txt/compose.sh ;; 
    19071     "game/txt/compose.sh":F) chmod +x utils/mkcmds.sh game/txt/compose.sh ;; 
     19029    "utils/mkcmds.sh":F) chmod +x utils/mkcmds.sh ;; 
     19030    "game/txt/compose.sh":F) chmod +x game/txt/compose.sh ;; 
    1907219031 
    1907319032  esac 
  • 1.8.3/branches/experimental/configure.in

    r922 r942  
    9999AC_CHECK_HEADER(sys/file.h, [AC_DEFINE(I_SYS_FILE)]) 
    100100AC_CHECK_HEADER(sys/in.h, [AC_DEFINE(I_SYS_IN)]) 
    101 AC_CHECK_HEADER(sys/mman.h, [AC_DEFINE(I_SYS_MMAN)]) 
    102101AC_CHECK_HEADER(sys/page.h, [AC_DEFINE(I_SYS_PAGE)]) 
    103102AC_CHECK_HEADER(sys/param.h, [AC_DEFINE(I_SYS_PARAM)]) 
     
    105104AC_CHECK_HEADER(sys/stat.h, [AC_DEFINE(I_SYS_STAT)]) 
    106105AC_CHECK_HEADER(sys/types.h, [AC_DEFINE(I_SYS_TYPES)]) 
    107 AC_CHECK_HEADERS([sys/un.h ieeefp.h sys/resource.h sys/event.h]) 
     106AC_CHECK_HEADERS([sys/mman.h sys/un.h ieeefp.h sys/resource.h sys/event.h]) 
    108107 
    109108### C language support 
     
    182181AC_CHECK_FUNCS([cbrt getuid geteuid seteuid getpriority setpriority socketpair]) 
    183182AC_CHECK_FUNCS([sigaction sigprocmask imaxdiv kqueue]) 
     183AC_CHECK_FUNCS([mmap madvise posix_madvise pwrite]) 
    184184 
    185185AC_FUNC_SNPRINTF 
  • 1.8.3/branches/experimental/game/restart

    r694 r942  
    115115mv -f log/*.log save/ 
    116116 
     117# And delete old mmap files 
     118rm -f data/*.map  
     119 
    117120if [ -r "data/$OUTDB$SUFFIX" ]; then 
    118121   rm -f save/$INDB$SUFFIX.old 
  • 1.8.3/branches/experimental/hdrs/game.h

    r922 r942  
    1414 
    1515/* hash table stuff */ 
    16 extern void init_func_hashtab(void);   /* eval.c */ 
    17 extern void init_aname_table(void);    /* atr_tab.c */ 
    18 extern void init_flagspaces(void); /* flags.c */ 
    19 extern void init_flag_table(const char *ns);   /* flags.c */ 
    20 extern void init_pronouns(void);   /* funstr.c */ 
    21 void init_switches(void);  /* command.c */ 
     16extern void init_func_hashtab(void);    /* eval.c */ 
     17extern void init_aname_table(void);     /* atr_tab.c */ 
     18extern void init_flagspaces(void);      /* flags.c */ 
     19extern void init_flag_table(const char *ns);    /* flags.c */ 
     20extern void init_pronouns(void);        /* funstr.c */ 
     21void init_switches(void);       /* command.c */ 
    2222 
    2323/* From bsd.c */ 
  • 1.8.3/branches/experimental/hdrs/help.h

    r922 r942  
    2424  int admin;            /**< Is this an admin-only help command? */ 
    2525  help_indx *indx;      /**< An array of help index entries */ 
     26  int index_fd;         /**< File descripted of a mmaped index */ 
    2627  size_t entries;       /**< Number of entries in the help file */ 
    2728} help_file; 
    2829 
    2930 
    30 extern void init_help_files(void); 
    31 extern void add_help_file 
    32   (const char *command_name, const char *filename, int admin); 
    33 extern void help_reindex(dbref player); 
     31void init_help_files(void); 
     32void add_help_file(const char *command_name, const char *filename, int admin); 
     33void help_reindex(dbref player); 
     34void free_help_indexes(void); 
    3435#endif                          /* __HELP_H */ 
  • 1.8.3/branches/experimental/src/command.c

    r922 r942  
    504504  ptab_start_inserts(&ptab_command); 
    505505  ptab_insert(&ptab_command, name, 
    506                   make_command(name, type, flagmask, powers, sw, func)); 
     506              make_command(name, type, flagmask, powers, sw, func)); 
    507507  ptab_end_inserts(&ptab_command); 
    508508  return command_find(name); 
  • 1.8.3/branches/experimental/src/csrimalloc.c

    r922 r942  
    1111#include <sys/file.h> 
    1212#endif 
    13 #ifdef I_SYS_MMAN 
     13#ifdef HAVE_SYS_MMAN_H 
    1414#include <sys/mman.h> 
    1515#endif 
     
    970970#ifdef CSRI_TRACE 
    971971/* Tracing malloc definitions - helps find leaks */ 
    972 univptr_t trace__malloc 
    973 _((size_t nbytes, const char *fname, int linenum)); 
    974 univptr_t trace__calloc 
    975 _((size_t nelem, size_t elsize, const char *fname, int linenum)); 
    976 univptr_t trace__realloc 
    977 _((univptr_t cp, size_t nbytes, const char *fname, int linenum)); 
    978     univptr_t trace__valloc _((size_t size, const char *fname, int linenum)); 
    979 univptr_t trace__memalign 
    980 _((size_t alignment, size_t size, const char *fname, int linenum)); 
    981     univptr_t trace__emalloc _((size_t nbytes, const char *fname, int linenum)); 
     972    univptr_t 
     973      trace__malloc 
     974    _((size_t nbytes, const char *fname, int linenum)); 
     975    univptr_t 
     976      trace__calloc 
     977    _((size_t nelem, size_t elsize, const char *fname, int linenum)); 
     978    univptr_t 
     979      trace__realloc 
     980    _((univptr_t cp, size_t nbytes, const char *fname, int linenum)); 
     981    univptr_t trace__valloc 
     982    _((size_t size, const char *fname, int linenum)); 
     983    univptr_t 
     984      trace__memalign 
     985    _((size_t alignment, size_t size, const char *fname, int linenum)); 
     986    univptr_t trace__emalloc 
     987    _((size_t nbytes, const char *fname, int linenum)); 
    982988univptr_t 
    983989  trace__ecalloc _((size_t nelem, size_t sz, const char *fname, int linenum)); 
     990univptr_t trace__erealloc 
     991_((univptr_t ptr, size_t nbytes, const char *fname, int linenum)); 
     992    char *trace__strdup _((const char *s, const char *fname, int linenum)); 
     993    char *trace__strsave _((const char *s, const char *fname, int linenum)); 
     994    void 
     995     trace__free _((univptr_t cp, const char *fname, int linenum)); 
     996    void 
     997     trace__cfree _((univptr_t cp, const char *fname, int linenum)); 
     998#else                           /* CSRI_TRACE */ 
    984999    univptr_t 
    985       trace__erealloc 
    986     _((univptr_t ptr, size_t nbytes, const char *fname, int linenum)); 
    987     char * 
    988       trace__strdup 
    989     _((const char *s, const char *fname, int linenum)); 
    990     char * 
    991       trace__strsave 
    992     _((const char *s, const char *fname, int linenum)); 
     1000      malloc 
     1001    _((size_t nbytes)); 
     1002    univptr_t 
     1003      calloc 
     1004    _((size_t nelem, size_t elsize)); 
     1005    univptr_t 
     1006      realloc 
     1007    _((univptr_t cp, size_t nbytes)); 
     1008    univptr_t 
     1009      valloc 
     1010    _((size_t size)); 
     1011    univptr_t 
     1012      memalign 
     1013    _((size_t alignment, size_t size)); 
     1014    univptr_t 
     1015      emalloc 
     1016    _((size_t nbytes)); 
     1017    univptr_t 
     1018      ecalloc 
     1019    _((size_t nelem, size_t sz)); 
     1020    univptr_t 
     1021      erealloc 
     1022    _((univptr_t ptr, size_t nbytes)); 
     1023    Free_t free 
     1024    _((univptr_t cp)); 
     1025    Free_t cfree 
     1026    _((univptr_t cp)); 
     1027#endif                          /* CSRI_TRACE */ 
     1028 
     1029    int 
     1030      __m_botch 
     1031    _((const char *s1, const char *s2, univptr_t p, 
     1032       int is_end_ptr, const char *filename, int linenumber)); 
    9931033    void 
    994     trace__fre
    995     _((univptr_t cp, const char *fname, int linenum)); 
     1034    __m_prnod
     1035    _((SPBLK * spblk)); 
    9961036    void 
    997     trace__cfree 
    998     _((univptr_t cp, const char *fname, int linenum)); 
    999 #else                           /* CSRI_TRACE */ 
    1000 univptr_t malloc 
    1001 _((size_t nbytes)); 
    1002 univptr_t calloc 
    1003 _((size_t nelem, size_t elsize)); 
    1004 univptr_t realloc 
    1005 _((univptr_t cp, size_t nbytes)); 
    1006 univptr_t valloc 
    1007 _((size_t size)); 
    1008 univptr_t memalign 
    1009 _((size_t alignment, size_t size)); 
    1010 univptr_t emalloc 
    1011 _((size_t nbytes)); 
    1012 univptr_t ecalloc 
    1013 _((size_t nelem, size_t sz)); 
    1014 univptr_t erealloc 
    1015 _((univptr_t ptr, size_t nbytes)); 
    1016     Free_t free _((univptr_t cp)); 
    1017     Free_t cfree _((univptr_t cp)); 
    1018 #endif                          /* CSRI_TRACE */ 
    1019  
    1020     int 
    1021      __m_botch 
    1022       _((const char *s1, const char *s2, univptr_t p, 
    1023          int is_end_ptr, const char *filename, int linenumber)); 
    1024     void 
    1025      __m_prnode _((SPBLK * spblk)); 
    1026     void 
    1027      mal_contents _((FILE * fp)); 
     1037    mal_contents 
     1038    _((FILE * fp)); 
    10281039#ifdef CSRI_DEBUG 
    10291040    void 
    1030      mal_debug _((int level)); 
     1041    mal_debug 
     1042    _((int level)); 
    10311043    int 
    1032      mal_verify _((int fullcheck)); 
     1044    mal_verify 
     1045    _((int fullcheck)); 
    10331046#endif 
    10341047    void 
    1035      mal_dumpleaktrace _((FILE * fp)); 
     1048    mal_dumpleaktrace 
     1049    _((FILE * fp)); 
    10361050    void 
    1037      mal_heapdump _((FILE * fp)); 
     1051    mal_heapdump 
     1052    _((FILE * fp)); 
    10381053    void 
    1039      mal_leaktrace _((int value)); 
     1054    mal_leaktrace 
     1055    _((int value)); 
    10401056    void 
    1041      mal_sbrkset _((int n)); 
     1057    mal_sbrkset 
     1058    _((int n)); 
    10421059    void 
    1043      mal_slopset _((int n)); 
     1060    mal_slopset 
     1061    _((int n)); 
    10441062#ifdef CSRI_PROFILESIZES 
    10451063    void 
    1046      mal_statsdump _((FILE * fp)); 
     1064    mal_statsdump 
     1065    _((FILE * fp)); 
    10471066#endif 
    10481067    void 
    1049      mal_trace _((int value)); 
     1068    mal_trace 
     1069    _((int value)); 
    10501070    void 
    1051      mal_mmap _((char *fname)); 
     1071    mal_mmap 
     1072    _((char *fname)); 
    10521073 
    10531074#ifdef CSRI_TRACE 
  • 1.8.3/branches/experimental/src/help.c

    r922 r942  
    1111#include <ctype.h> 
    1212#include <stdio.h> 
     13#ifdef I_SYS_TYPES 
     14#include <sys/types.h> 
     15#endif 
     16#ifdef HAVE_SYS_MMAN_H 
     17#include <sys/mman.h> 
     18#endif 
     19#ifdef I_FCNTL 
     20#include <fcntl.h> 
     21#endif 
     22#ifdef I_UNISTD 
     23#include <unistd.h> 
     24#endif 
    1325#include "conf.h" 
    1426#include "externs.h" 
     
    140152  help_file *curr; 
    141153 
    142   for (curr = (help_file *) hash_firstentry(&help_files); 
    143        curr; curr = (help_file *) hash_nextentry(&help_files)) { 
     154  for (curr = hash_firstentry(&help_files); 
     155       curr; curr = hash_nextentry(&help_files)) { 
     156#ifdef HAVE_MMAP 
     157    if (curr->index_fd > 0) { 
     158      munmap(curr->indx, curr->entries * sizeof(help_indx)); 
     159      curr->entries = 0; 
     160    } else 
     161#endif 
    144162    if (curr->indx) { 
    145       mush_free((Malloc_t) curr->indx, "help_index"); 
     163      mush_free(curr->indx, "help_index"); 
    146164      curr->entries = 0; 
    147165    } 
     
    301319    nextptr = cur->next; 
    302320    if (num_topics >= top_topics) { 
    303       top_topics += top_topics / 2 + 20; 
    304       if (topics) 
    305         topics = (help_indx *) realloc(topics, top_topics * sizeof(help_indx)); 
    306       else 
    307         topics = (help_indx *) malloc(top_topics * sizeof(help_indx)); 
    308       if (!topics) { 
    309         mush_panic(T("Out of memory")); 
    310       } 
     321      /* Never happen! */ 
     322      mush_panic(T("Out of memory")); 
    311323    } 
    312324    temp = &topics[num_topics++]; 
    313325    temp->pos = p; 
    314326    strcpy(temp->topic, cur->topic); 
    315     free(cur); 
     327    mush_free(cur, "tlist"); 
    316328  } 
    317329  top = NULL; 
     
    341353  FILE *rfp; 
    342354  tlist *cur; 
     355  size_t index_size = 0; 
    343356 
    344357  /* Quietly ignore null values for the file */ 
     
    363376  in_topic = 0; 
    364377 
     378  /* Go through and count the topics so we know how much space to allocate. 
     379   * Print out warning messages here too. */ 
    365380  while (fgets(line, LINE_SIZE, rfp) != NULL) { 
    366381    ++lineno; 
    367     if (ntopics == 0) { 
     382    if (!in_topic) { 
    368383      /* Looking for the first topic, but we'll ignore blank lines */ 
    369384      if (!line[0]) { 
     
    388403    } 
    389404    if (line[0] == '&') { 
     405      unsigned char *c = (unsigned char *) line + 1; 
     406      in_topic = true; 
     407      while (*c && isspace(*c)) 
     408        c++; 
     409      if (*c == '&' && restricted) 
     410        ++ntopics; 
     411      else if (*c != '&' && !restricted) 
     412        ++ntopics; 
     413    } 
     414  } 
     415 
     416  topics = NULL; 
     417  index_size = (ntopics + 1) * sizeof(help_indx); 
     418 
     419#ifdef HAVE_MMAP 
     420  do { 
     421    uint8_t x; 
     422 
     423    /* First we have to create a new file and make it large enough 
     424       to hold the index. Do this by seeking to the end and writing  
     425       a byte to make a sparse file. */ 
     426 
     427    h->index_fd = open(tprintf("%s/help_%s.%d.map", "data", h->command, 
     428                               getpid()), O_RDWR | O_CREAT | O_TRUNC, 0600); 
     429    if (h->index_fd < 0) { 
     430      perror("opening index file for mapping"); 
     431      h->indx = topics; 
     432      break; 
     433    } 
     434 
     435    x = '\xFF'; 
     436 
     437#ifdef HAVE_PWRITE 
     438    if (pwrite(h->index_fd, &x, 1, index_size + 1) < 0) { 
     439      perror("pwrite: writing byte at end of index file"); 
     440      close(h->index_fd); 
     441      h->index_fd = -1; 
     442      h->indx = topics; 
     443      break; 
     444    } 
     445#else 
     446    if (lseek(h->index_fd, index_size + 1, SEEK_SET) < 0) { 
     447      perror("seeking to end of index file"); 
     448      close(h->index_fd); 
     449      h->index_fd = -1; 
     450      h->indx = topics; 
     451      break; 
     452    } 
     453 
     454    x = '\xFF'; 
     455    if (write(h->index_fd, &x, 1) < 0) { 
     456      perror("write: writing byte at end of index file"); 
     457      close(h->index_fd); 
     458      h->index_fd = -1; 
     459      h->indx = topics; 
     460      break; 
     461    } 
     462    lseek(h->index_fd, 0, SEEK_SET); 
     463#endif 
     464 
     465    h->indx = mmap(NULL, index_size, PROT_READ | PROT_WRITE, 
     466                   MAP_FILE | MAP_SHARED, h->index_fd, 0); 
     467 
     468    if ((caddr_t) h->indx == (caddr_t) - 1) { 
     469      perror("mapping file"); 
     470      close(h->index_fd); 
     471      h->index_fd = -1; 
     472      h->indx = topics; 
     473      break; 
     474    } 
     475 
     476    close(h->index_fd); 
     477    topics = h->indx; 
     478    add_check("help_index"); 
     479  } while (0); 
     480#endif                          /* MMAP */ 
     481  if (!topics) { 
     482    h->indx = topics = calloc(ntopics + 1, sizeof(help_indx)); 
     483    add_check("help_index"); 
     484  } 
     485#ifdef HAVE_POSIX_MADVISE 
     486  if (posix_madvise(h->indx, index_size, POSIX_MADV_SEQUENTIAL) < 0) 
     487    perror("posix_madvise(POSIX_MADV_SEQUENTIAL"); 
     488#elif defined(HAVE_MADVISE) 
     489  if (madvise(h->indx, index_size, MADV_SEQUENTIAL) < 0) 
     490    perror("madvise(MADV_SEQUENTIAL"); 
     491#endif 
     492 
     493  top_topics = ntopics + 1; 
     494 
     495  /* Rewind */ 
     496  fseek(rfp, 0, SEEK_SET); 
     497  ntopics = 0; 
     498  lineno = 0; 
     499 
     500  while (fgets(line, LINE_SIZE, rfp) != NULL) { 
     501    ++lineno; 
     502 
     503    /* Skip leading lines without a & */ 
     504    if (ntopics == 0 && line[0] != '&') 
     505      continue; 
     506 
     507    n = strlen(line); 
     508 
     509    if (line[0] == '&') { 
    390510      ++ntopics; 
    391511      if (!in_topic) { 
     
    396516        in_topic = true; 
    397517      } 
     518 
    398519      /* parse out the topic */ 
    399520      /* Get the beginning of the topic string */ 
     
    402523 
    403524      /* Get the topic */ 
    404       strcpy(the_topic, "")
     525      the_topic[0] = '\0'
    405526      for (i = -1, s = topic; *s != '\n' && *s != '\0'; s++) { 
    406527        if (i >= TOPIC_NAME_LEN - 1) 
     
    412533          || (!restricted && the_topic[0] != '&')) { 
    413534        the_topic[++i] = '\0'; 
    414         cur = (tlist *) malloc(sizeof(tlist)); 
     535        cur = mush_malloc(sizeof(tlist), "tlist"); 
    415536        strcpy(cur->topic, the_topic); 
    416537        cur->next = top; 
     
    425546    bigpos = ftell(rfp); 
    426547  } 
    427  
    428548  /* Handle last topic */ 
    429549  write_topic(pos); 
     550#ifdef HAVE_POSIX_MADVISE 
     551  if (posix_madvise(h->indx, index_size, POSIX_MADV_RANDOM) < 0) 
     552    perror("posix_madvise(POSIX_MADV_RANDOM)"); 
     553#elif defined(HAVE_MADVISE) 
     554  if (madvise(h->indx, index_size, MADV_RANDOM) < 0) 
     555    perror("madvise(MADV_RANDOM)"); 
     556#endif 
    430557  qsort(topics, num_topics, sizeof(help_indx), topic_cmp); 
    431558  h->entries = num_topics; 
    432   h->indx = topics
    433   add_check("help_index"); 
     559  topics = NULL
     560 
    434561  fclose(rfp); 
    435562  do_rawlog(LT_WIZ, T("%d topics indexed."), num_topics); 
     
    589716  return buff; 
    590717} 
     718 
     719/** Unmaps all help indexes. Used before a reboot */ 
     720void 
     721free_help_indexes(void) 
     722{ 
     723#ifdef HAVE_MMAP 
     724  help_file *curr; 
     725 
     726  for (curr = hash_firstentry(&help_files); 
     727       curr; curr = hash_nextentry(&help_files)) { 
     728    if (curr->index_fd > 0) { 
     729      munmap(curr->indx, curr->entries * sizeof(help_indx)); 
     730      curr->entries = 0; 
     731    } 
     732  } 
     733#endif 
     734} 
  • 1.8.3/branches/experimental/src/htmltab.c

    r897 r942  
    6060static int 
    6161gperf_case_memcmp(register const char *s1, register const char *s2, 
    62          register unsigned int n) 
     62                  register unsigned int n) 
    6363{ 
    6464  for (; n > 0;) { 
     
    242242    if (key <= MAX_HASH_VALUE && key >= 0) 
    243243      if (len == lengthtable[key]) { 
    244    register const char *s = wordlist[key]; 
    245  
    246    if ((((unsigned char) *str ^ (unsigned char) *s) & ~32) == 0 
    247        && !gperf_case_memcmp(str, s, len)) 
    248      return s; 
     244        register const char *s = wordlist[key]; 
     245 
     246        if ((((unsigned char) *str ^ (unsigned char) *s) & ~32) == 0 
     247            && !gperf_case_memcmp(str, s, len)) 
     248          return s; 
    249249      } 
    250250  } 
  • 1.8.3/branches/experimental/src/lmath.c

    r897 r942  
    6464#line 44 "lmath.gperf" 
    6565struct math { 
    66   const char *name;    /**< Name of the function. */ 
    67   void (*func) (char **, int, char *, char **);    /**< Pointer to function code. */ 
     66  const char *name;     /**< Name of the function. */ 
     67  void (*func) (char **, int, char *, char **); /**< Pointer to function code. */ 
    6868}; 
    6969/* maximum key range = 52, duplicates = 0 */ 
     
    9797static int 
    9898gperf_case_memcmp(register const char *s1, register const char *s2, 
    99          register unsigned int n) 
     99                  register unsigned int n) 
    100100{ 
    101101  for (; n > 0;) { 
     
    161161#endif 
    162162    struct math *math_hash_lookup(register const char *str, 
    163                  register unsigned int len) 
     163                                  register unsigned int len) 
    164164{ 
    165165  enum { 
     
    245245    if (key <= MAX_HASH_VALUE && key >= 0) 
    246246      if (len == lengthtable[key]) { 
    247    register const char *s = wordlist[key].name; 
    248  
    249    if ((((unsigned char) *str ^ (unsigned char) *s) & ~32) == 0 
    250        && !gperf_case_memcmp(str, s, len)) 
    251      return &wordlist[key]; 
     247        register const char *s = wordlist[key].name; 
     248 
     249        if ((((unsigned char) *str ^ (unsigned char) *s) & ~32) == 0 
     250            && !gperf_case_memcmp(str, s, len)) 
     251          return &wordlist[key]; 
    252252      } 
    253253  } 
  • 1.8.3/branches/experimental/src/wiz.c

    r922 r942  
    4848#include "dbdefs.h" 
    4949#include "extmail.h" 
    50  
     50#include "help.h" 
    5151 
    5252#include "confmagic.h" 
     
    17771777  kill_info_slave(); 
    17781778#endif 
     1779  free_help_indexes(); 
    17791780  local_shutdown(); 
    17801781  end_all_logs();