45c4258f4e
access the shared memory segment. Bump revision.
46 lines
1.2 KiB
Text
46 lines
1.2 KiB
Text
$NetBSD: patch-ad,v 1.4 2009/08/03 13:18:37 joerg Exp $
|
|
|
|
--- utility.c.orig 2008-04-16 00:41:49.000000000 +0200
|
|
+++ utility.c
|
|
@@ -388,8 +388,10 @@ void ClearHashTableScores(void)
|
|
*/
|
|
void CraftyExit(int exit_type)
|
|
{
|
|
- shared->abort_search = 1;
|
|
- shared->quit = 1;
|
|
+ if (shared) {
|
|
+ shared->abort_search = 1;
|
|
+ shared->quit = 1;
|
|
+ }
|
|
exit(exit_type);
|
|
}
|
|
|
|
@@ -1541,10 +1543,10 @@ void Print(int vb, char *fmt, ...)
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
|
- if (vb & shared->display_options)
|
|
+ if (shared == NULL || (vb & shared->display_options))
|
|
vprintf(fmt, ap);
|
|
fflush(stdout);
|
|
- if (shared->time_limit > 99 || shared->tc_time_remaining > 6000 || vb == 4095) {
|
|
+ if (vb == 4095 || shared->time_limit > 99 || shared->tc_time_remaining > 6000) {
|
|
va_start(ap, fmt);
|
|
if (log_file)
|
|
vfprintf(log_file, fmt, ap);
|
|
@@ -2788,6 +2790,15 @@ void *SharedMalloc(size_t size, int tid)
|
|
#if defined(UNIX)
|
|
int shmid;
|
|
void *shared;
|
|
+ long pagesize;
|
|
+
|
|
+ /* round to page boundary */
|
|
+ pagesize = sysconf(_SC_PAGESIZE);
|
|
+ if (pagesize == -1) {
|
|
+ /* just in case, guess */
|
|
+ pagesize = 4096;
|
|
+ }
|
|
+ size = size + pagesize - (size % pagesize);
|
|
|
|
shmid = shmget(IPC_PRIVATE, size, (IPC_CREAT | 0600));
|
|
if (shmid < 0) {
|