FreeBSD/contrib/amd/amd/amd.c
/*
 * Lock process text and data segment in memory (after forking the daemon)
 */
Lock process text and data segment in memory (after forking the daemon)
Lock process text and data segment in memory ( after forking the daemon )
static void
do_memory_locking(void)
{
#if defined(HAVE_PLOCK) || defined(HAVE_MLOCKALL)
  int locked_ok = 0;
#else 
  plog(XLOG_WARNING, "Process memory locking not supported by the OS");
#endif 
#ifdef HAVE_PLOCK
# ifdef _AIX
  plog(XLOG_WARNING, "AIX: may need to lower stack size using ulimit(3) before calling plock");
# endif 
  if (!locked_ok && plock(PROCLOCK) != 0)
    plog(XLOG_WARNING, "Couldn't lock process pages in memory using plock(): %m");
  else
    locked_ok = 1;
#endif 
#ifdef HAVE_MLOCKALL
  if (!locked_ok && mlockall(MCL_CURRENT|MCL_FUTURE) != 0)
    plog(XLOG_WARNING, "Couldn't lock process pages in memory using mlockall(): %m");
  else
    locked_ok = 1;
#endif 
#if defined(HAVE_PLOCK) || defined(HAVE_MLOCKALL)
  if (locked_ok)
    plog(XLOG_INFO, "Locked process pages in memory");
#endif 
#if defined(HAVE_MADVISE) && defined(MADV_PROTECT)
    madvise(0, 0, MADV_PROTECT); 
#endif 
}
static void do_memory_locking ( void ) { #if defined ( HAVE_PLOCK ) || defined ( HAVE_MLOCKALL ) int locked_ok = 0 ; #else plog ( XLOG_WARNING , " " ) ; #endif #ifdef HAVE_PLOCK # ifdef _AIX plog ( XLOG_WARNING , " " ) ; # endif if ( ! locked_ok && plock ( PROCLOCK ) != 0 ) plog ( XLOG_WARNING , " " ) ; else locked_ok = 1 ; #endif #ifdef HAVE_MLOCKALL if ( ! locked_ok && mlockall ( MCL_CURRENT | MCL_FUTURE ) != 0 ) plog ( XLOG_WARNING , " " ) ; else locked_ok = 1 ; #endif #if defined ( HAVE_PLOCK ) || defined ( HAVE_MLOCKALL ) if ( locked_ok ) plog ( XLOG_INFO , " " ) ; #endif #if defined ( HAVE_MADVISE ) && defined ( MADV_PROTECT ) madvise ( 0 , 0 , MADV_PROTECT ) ; #endif }
Lock process text and data segment in memory (after forking the daemon)
Lock process text and data segment in memory ( after forking the daemon )
/* not HAVE_PLOCK and not HAVE_MLOCKALL */ /* not HAVE_PLOCK and not HAVE_MLOCKALL */ /*
   * On AIX you must lower the stack size using ulimit() before calling
   * plock.  Otherwise plock will reserve a lot of memory space based on
   * your maximum stack size limit.  Since it is not easily possible to
   * tell what should the limit be, I print a warning before calling
   * plock().  See the manual pages for ulimit(1,3,4) on your AIX system.
   */ /* _AIX */ /* HAVE_PLOCK */ /* HAVE_MLOCKALL */ /* HAVE_PLOCK || HAVE_MLOCKALL */ /* may be redundant of the above worked out */ /* defined(HAVE_MADVISE) && defined(MADV_PROTECT) */