Eneboo - Documentación para desarrolladores
|
00001 /* 00002 * test.h 00003 * 00004 * Useful definitions and declarations for tests. 00005 * 00006 * 00007 * -------------------------------------------------------------------------- 00008 * 00009 * Pthreads-win32 - POSIX Threads Library for Win32 00010 * Copyright(C) 1998 John E. Bossom 00011 * Copyright(C) 1999,2005 Pthreads-win32 contributors 00012 * 00013 * Contact Email: rpj@callisto.canberra.edu.au 00014 * 00015 * The current list of contributors is contained 00016 * in the file CONTRIBUTORS included with the source 00017 * code distribution. The list can also be seen at the 00018 * following World Wide Web location: 00019 * http://sources.redhat.com/pthreads-win32/contributors.html 00020 * 00021 * This library is free software; you can redistribute it and/or 00022 * modify it under the terms of the GNU Lesser General Public 00023 * License as published by the Free Software Foundation; either 00024 * version 2 of the License, or (at your option) any later version. 00025 * 00026 * This library is distributed in the hope that it will be useful, 00027 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00028 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00029 * Lesser General Public License for more details. 00030 * 00031 * You should have received a copy of the GNU Lesser General Public 00032 * License along with this library in the file COPYING.LIB; 00033 * if not, write to the Free Software Foundation, Inc., 00034 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 00035 * 00036 */ 00037 00038 #ifndef _PTHREAD_TEST_H_ 00039 #define _PTHREAD_TEST_H_ 00040 00041 #include "pthread.h" 00042 #include "sched.h" 00043 #include "semaphore.h" 00044 00045 #include <windows.h> 00046 #include <stdio.h> 00047 00048 #define PTW32_THREAD_NULL_ID {NULL,0} 00049 00050 #if defined(__MINGW32__) 00051 #include <stdint.h> 00052 #elif defined(__BORLANDC__) 00053 #define int64_t ULONGLONG 00054 #else 00055 #define int64_t _int64 00056 #endif 00057 00058 00059 char * error_string[] = { 00060 "ZERO_or_EOK", 00061 "EPERM", 00062 "ENOFILE_or_ENOENT", 00063 "ESRCH", 00064 "EINTR", 00065 "EIO", 00066 "ENXIO", 00067 "E2BIG", 00068 "ENOEXEC", 00069 "EBADF", 00070 "ECHILD", 00071 "EAGAIN", 00072 "ENOMEM", 00073 "EACCES", 00074 "EFAULT", 00075 "UNKNOWN_15", 00076 "EBUSY", 00077 "EEXIST", 00078 "EXDEV", 00079 "ENODEV", 00080 "ENOTDIR", 00081 "EISDIR", 00082 "EINVAL", 00083 "ENFILE", 00084 "EMFILE", 00085 "ENOTTY", 00086 "UNKNOWN_26", 00087 "EFBIG", 00088 "ENOSPC", 00089 "ESPIPE", 00090 "EROFS", 00091 "EMLINK", 00092 "EPIPE", 00093 "EDOM", 00094 "ERANGE", 00095 "UNKNOWN_35", 00096 "EDEADLOCK_or_EDEADLK", 00097 "UNKNOWN_37", 00098 "ENAMETOOLONG", 00099 "ENOLCK", 00100 "ENOSYS", 00101 "ENOTEMPTY", 00102 "EILSEQ", 00103 }; 00104 00105 /* 00106 * The Mingw32 assert macro calls the CRTDLL _assert function 00107 * which pops up a dialog. We want to run in batch mode so 00108 * we define our own assert macro. 00109 */ 00110 #ifdef assert 00111 # undef assert 00112 #endif 00113 00114 #ifndef ASSERT_TRACE 00115 # define ASSERT_TRACE 0 00116 #else 00117 # undef ASSERT_TRACE 00118 # define ASSERT_TRACE 1 00119 #endif 00120 00121 # define assert(e) \ 00122 ((e) ? ((ASSERT_TRACE) ? fprintf(stderr, \ 00123 "Assertion succeeded: (%s), file %s, line %d\n", \ 00124 #e, __FILE__, (int) __LINE__), \ 00125 fflush(stderr) : \ 00126 0) : \ 00127 (fprintf(stderr, "Assertion failed: (%s), file %s, line %d\n", \ 00128 #e, __FILE__, (int) __LINE__), exit(1), 0)) 00129 00130 int assertE; 00131 # define assert_e(e, o, r) \ 00132 (((assertE = e) o (r)) ? ((ASSERT_TRACE) ? fprintf(stderr, \ 00133 "Assertion succeeded: (%s), file %s, line %d\n", \ 00134 #e, __FILE__, (int) __LINE__), \ 00135 fflush(stderr) : \ 00136 0) : \ 00137 (fprintf(stderr, "Assertion failed: (%s %s %s), file %s, line %d, error %s\n", \ 00138 #e,#o,#r, __FILE__, (int) __LINE__, error_string[assertE]), exit(1), 0)) 00139 00140 #endif