Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

custom-ramses.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000-2002 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of the Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 
00021 #include <unistd.h>
00022 #include <stdio.h>
00023 #include <signal.h>
00024 #include <fcntl.h>
00025 #include <sys/ioctl.h>
00026 
00027 #define QPE_HAVE_MEMALERTER
00028 
00029 #define QPE_MEMALERTER_IMPL \
00030 static void sig_handler(int sig) \
00031 { \
00032     switch (sig) { \
00033     case SIGHUP: \
00034   memstate = VeryLow; \
00035   break; \
00036     case SIGUSR1: \
00037   memstate = Normal; \
00038   break; \
00039     case SIGUSR2: \
00040   memstate = Low; \
00041   break; \
00042     } \
00043 } \
00044 static void initMemalerter() \
00045 { \
00046     struct sigaction sa; \
00047     memset(&sa, '\0', sizeof sa); \
00048     sa.sa_handler = sig_handler; \
00049     sa.sa_flags = SA_RESTART; \
00050     if (sigaction(SIGHUP, &sa, NULL) < 0) { \
00051   return; \
00052     } \
00053     if (sigaction(SIGUSR1, &sa, NULL) < 0) { \
00054   return; \
00055     } \
00056     if (sigaction(SIGUSR2, &sa, NULL) < 0) { \
00057   return; \
00058     } \
00059     FILE *fo = fopen("/proc/sys/vm/freepg_signal_proc", "w"); \
00060      \
00061     if (!fo) \
00062         return; \
00063     fprintf(fo, "qpe\n"); \
00064     fclose(fo); \
00065 }

Generated on Sat Nov 5 16:16:35 2005 for OPIE by  doxygen 1.4.2