1f08c3bdfSopenharmony_ci/* 2f08c3bdfSopenharmony_ci * Copyright (c) International Business Machines Corp., 2001 3f08c3bdfSopenharmony_ci * 4f08c3bdfSopenharmony_ci * This program is free software; you can redistribute it and/or modify 5f08c3bdfSopenharmony_ci * it under the terms of the GNU General Public License as published by 6f08c3bdfSopenharmony_ci * the Free Software Foundation; either version 2 of the License, or 7f08c3bdfSopenharmony_ci * (at your option) any later version. 8f08c3bdfSopenharmony_ci * 9f08c3bdfSopenharmony_ci * This program is distributed in the hope that it will be useful, 10f08c3bdfSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 11f08c3bdfSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 12f08c3bdfSopenharmony_ci * the GNU General Public License for more details. 13f08c3bdfSopenharmony_ci * 14f08c3bdfSopenharmony_ci * You should have received a copy of the GNU General Public License 15f08c3bdfSopenharmony_ci * along with this program; if not, write to the Free Software 16f08c3bdfSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17f08c3bdfSopenharmony_ci */ 18f08c3bdfSopenharmony_ci/* 19f08c3bdfSopenharmony_ci * FUNCTIONS: Scheduler Test Suite 20f08c3bdfSopenharmony_ci */ 21f08c3bdfSopenharmony_ci 22f08c3bdfSopenharmony_ci/*---------------------------------------------------------------------+ 23f08c3bdfSopenharmony_ci| sched.c | 24f08c3bdfSopenharmony_ci| ==================================================================== | 25f08c3bdfSopenharmony_ci| | 26f08c3bdfSopenharmony_ci| Description: Simplistic test to verify the signal system function | 27f08c3bdfSopenharmony_ci| calls: | 28f08c3bdfSopenharmony_ci| | 29f08c3bdfSopenharmony_ci| Last update: Ver. 1.2, 4/10/94 23:06:22 | 30f08c3bdfSopenharmony_ci| | 31f08c3bdfSopenharmony_ci| Change Activity | 32f08c3bdfSopenharmony_ci| | 33f08c3bdfSopenharmony_ci| Version Date Name Reason | 34f08c3bdfSopenharmony_ci| 0.1 040294 DJK Initial version for AIX 4.1 | 35f08c3bdfSopenharmony_ci| 0.2 010402 Manoj Iyer Ported to Linux | 36f08c3bdfSopenharmony_ci| | 37f08c3bdfSopenharmony_ci+---------------------------------------------------------------------*/ 38f08c3bdfSopenharmony_ci 39f08c3bdfSopenharmony_ci#include <stdarg.h> 40f08c3bdfSopenharmony_ci#include <stdio.h> 41f08c3bdfSopenharmony_ci#include <string.h> 42f08c3bdfSopenharmony_ci#include "sched.h" 43f08c3bdfSopenharmony_ci 44f08c3bdfSopenharmony_ci#if 0 45f08c3bdfSopenharmony_ciextern FILE *logfile; 46f08c3bdfSopenharmony_ci 47f08c3bdfSopenharmony_ci/*---------------------------------------------------------------------+ 48f08c3bdfSopenharmony_ci| openlog () | 49f08c3bdfSopenharmony_ci| ==================================================================== | 50f08c3bdfSopenharmony_ci| | 51f08c3bdfSopenharmony_ci| Function: ... | 52f08c3bdfSopenharmony_ci| | 53f08c3bdfSopenharmony_ci+---------------------------------------------------------------------*/ 54f08c3bdfSopenharmony_ciint openlog(char *filename) 55f08c3bdfSopenharmony_ci{ 56f08c3bdfSopenharmony_ci 57f08c3bdfSopenharmony_ci if (filename == NULL) 58f08c3bdfSopenharmony_ci error("passed bad file name to openlog()", __FILE__, __LINE__); 59f08c3bdfSopenharmony_ci 60f08c3bdfSopenharmony_ci /* 61f08c3bdfSopenharmony_ci * Open the log file... 62f08c3bdfSopenharmony_ci */ 63f08c3bdfSopenharmony_ci if ((logfile = fopen(filename, "a")) == (FILE *) NULL) 64f08c3bdfSopenharmony_ci sys_error("fopen failed", __FILE__, __LINE__); 65f08c3bdfSopenharmony_ci 66f08c3bdfSopenharmony_ci return (0); 67f08c3bdfSopenharmony_ci} 68f08c3bdfSopenharmony_ci 69f08c3bdfSopenharmony_ci/*---------------------------------------------------------------------+ 70f08c3bdfSopenharmony_ci| logmsg () | 71f08c3bdfSopenharmony_ci| ==================================================================== | 72f08c3bdfSopenharmony_ci| | 73f08c3bdfSopenharmony_ci| Function: ... | 74f08c3bdfSopenharmony_ci| | 75f08c3bdfSopenharmony_ci+---------------------------------------------------------------------*/ 76f08c3bdfSopenharmony_civoid logmsg(const char *args, ...) 77f08c3bdfSopenharmony_ci{ 78f08c3bdfSopenharmony_ci fprintf(logfile, args); 79f08c3bdfSopenharmony_ci fflush(logfile); 80f08c3bdfSopenharmony_ci} 81f08c3bdfSopenharmony_ci#endif 82f08c3bdfSopenharmony_ci 83f08c3bdfSopenharmony_ci/*---------------------------------------------------------------------+ 84f08c3bdfSopenharmony_ci| sys_error () | 85f08c3bdfSopenharmony_ci| ==================================================================== | 86f08c3bdfSopenharmony_ci| | 87f08c3bdfSopenharmony_ci| Function: Creates system error message and calls error () | 88f08c3bdfSopenharmony_ci| | 89f08c3bdfSopenharmony_ci+---------------------------------------------------------------------*/ 90f08c3bdfSopenharmony_civoid sys_error(const char *msg, const char *file, int line) 91f08c3bdfSopenharmony_ci{ 92f08c3bdfSopenharmony_ci char syserr_msg[256]; 93f08c3bdfSopenharmony_ci 94f08c3bdfSopenharmony_ci sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno)); 95f08c3bdfSopenharmony_ci error(syserr_msg, file, line); 96f08c3bdfSopenharmony_ci} 97f08c3bdfSopenharmony_ci 98f08c3bdfSopenharmony_ci/*---------------------------------------------------------------------+ 99f08c3bdfSopenharmony_ci| error () | 100f08c3bdfSopenharmony_ci| ==================================================================== | 101f08c3bdfSopenharmony_ci| | 102f08c3bdfSopenharmony_ci| Function: Prints out message and exits... | 103f08c3bdfSopenharmony_ci| | 104f08c3bdfSopenharmony_ci+---------------------------------------------------------------------*/ 105f08c3bdfSopenharmony_civoid error(const char *msg, const char *file, int line) 106f08c3bdfSopenharmony_ci{ 107f08c3bdfSopenharmony_ci fprintf(stderr, "ERROR [file: %s, line: %d] %s\n", file, line, msg); 108f08c3bdfSopenharmony_ci exit(-1); 109f08c3bdfSopenharmony_ci} 110