spin.c includes pg_sema.h even if unnecessary

Поиск
Список
Период
Сортировка
От Kyotaro HORIGUCHI
Тема spin.c includes pg_sema.h even if unnecessary
Дата
Msg-id 20180215.201107.78574525.horiguchi.kyotaro@lab.ntt.co.jp
обсуждение исходный текст
Ответы Re: spin.c includes pg_sema.h even if unnecessary
Список pgsql-hackers
Ouch! Sorry for the bogus subject of just-submitted mail.
I'll make another thread with the fixed subject.

====
Hello.

As in another mail just before, spin.c seems a bit strange
(without acutual harm).

spin.h doesn't include pg_sema.h when HAVE_SPINLOCKS is defined,
but spin.c always includes it even in the case. The file is
included only to use sizeof(PGSemaphore) to calcualte
SpinlockSemaSize as 0.

The codes that requires PGSempaphore is inactivated when the
symbol is defined in all other places so it seems to me that we
ought to refrain from using it there, too. The attched patch does
that.

regards,

-- 
Kyotaro Horiguchi
NTT Open Source Software Center
diff --git a/src/backend/storage/lmgr/spin.c b/src/backend/storage/lmgr/spin.c
index 6d59a7f..353a3a9 100644
--- a/src/backend/storage/lmgr/spin.c
+++ b/src/backend/storage/lmgr/spin.c
@@ -22,13 +22,15 @@
  */
 #include "postgres.h"
 
-#include "storage/pg_sema.h"
 #include "storage/shmem.h"
 #include "storage/spin.h"
 
 
 #ifndef HAVE_SPINLOCKS
+#define RequredShmemSize (SpinlockSemas() * sizeof(PGSemaphore))
 PGSemaphore *SpinlockSemaArray;
+#else
+#define RequiredShmemSize 0
 #endif
 
 /*
@@ -38,7 +40,7 @@ PGSemaphore *SpinlockSemaArray;
 Size
 SpinlockSemaSize(void)
 {
-    return SpinlockSemas() * sizeof(PGSemaphore);
+    return RequiredShmemSize;
 }
 
 #ifdef HAVE_SPINLOCKS

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Kyotaro HORIGUCHI
Дата:
Сообщение: HAVE_SPINLOCKS still requests exctra shared memory
Следующее
От: Kyotaro HORIGUCHI
Дата:
Сообщение: Re: HAVE_SPINLOCKS still requests exctra shared memory