diff mbox series

[v2] libs/store: make build without PTHREAD_STACK_MIN

Message ID 20210126224800.1246-13-bouyer@netbsd.org (mailing list archive)
State New
Headers show
Series [v2] libs/store: make build without PTHREAD_STACK_MIN | expand

Commit Message

Manuel Bouyer Jan. 26, 2021, 10:47 p.m. UTC
On NetBSD, PTHREAD_STACK_MIN is not available.
If PTHREAD_STACK_MIN is not defined, define it to 0 so that we fallback to
DEFAULT_THREAD_STACKSIZE

Signed-off-by: Manuel Bouyer <bouyer@netbsd.org>
---
 tools/libs/store/xs.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Roger Pau Monné Jan. 28, 2021, 10:57 a.m. UTC | #1
On Tue, Jan 26, 2021 at 11:47:59PM +0100, Manuel Bouyer wrote:
> On NetBSD, PTHREAD_STACK_MIN is not available.
> If PTHREAD_STACK_MIN is not defined, define it to 0 so that we fallback to
> DEFAULT_THREAD_STACKSIZE
> 

I would add:

Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>

> Signed-off-by: Manuel Bouyer <bouyer@netbsd.org>

Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

> ---
>  tools/libs/store/xs.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/tools/libs/store/xs.c b/tools/libs/store/xs.c
> index 4ac73ec317..b6ecbd787e 100644
> --- a/tools/libs/store/xs.c
> +++ b/tools/libs/store/xs.c
> @@ -811,6 +811,11 @@ bool xs_watch(struct xs_handle *h, const char *path, const char *token)
>  
>  #ifdef USE_PTHREAD
>  #define DEFAULT_THREAD_STACKSIZE (16 * 1024)
> +/* NetBSD doesn't have PTHREAD_STACK_MIN. */
> +#ifndef PTHREAD_STACK_MIN
> +# define PTHREAD_STACK_MIN 0
> +#endif
> +
>  #define READ_THREAD_STACKSIZE 					\
>  	((DEFAULT_THREAD_STACKSIZE < PTHREAD_STACK_MIN) ? 	\
>  	PTHREAD_STACK_MIN : DEFAULT_THREAD_STACKSIZE)

There was also a suggestion to use MAX(PTHREAD_STACK_MIN,
DEFAULT_THREAD_STACKSIZE). Is maybe MAX not defied here?

Thanks, Roger.
Andrew Cooper Jan. 28, 2021, 11:08 a.m. UTC | #2
On 28/01/2021 10:57, Roger Pau Monné wrote:
> On Tue, Jan 26, 2021 at 11:47:59PM +0100, Manuel Bouyer wrote:
>> On NetBSD, PTHREAD_STACK_MIN is not available.
>> If PTHREAD_STACK_MIN is not defined, define it to 0 so that we fallback to
>> DEFAULT_THREAD_STACKSIZE
>>
> I would add:
>
> Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
>
>> Signed-off-by: Manuel Bouyer <bouyer@netbsd.org>
> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
>
>> ---
>>  tools/libs/store/xs.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/tools/libs/store/xs.c b/tools/libs/store/xs.c
>> index 4ac73ec317..b6ecbd787e 100644
>> --- a/tools/libs/store/xs.c
>> +++ b/tools/libs/store/xs.c
>> @@ -811,6 +811,11 @@ bool xs_watch(struct xs_handle *h, const char *path, const char *token)
>>  
>>  #ifdef USE_PTHREAD
>>  #define DEFAULT_THREAD_STACKSIZE (16 * 1024)
>> +/* NetBSD doesn't have PTHREAD_STACK_MIN. */
>> +#ifndef PTHREAD_STACK_MIN
>> +# define PTHREAD_STACK_MIN 0
>> +#endif
>> +
>>  #define READ_THREAD_STACKSIZE 					\
>>  	((DEFAULT_THREAD_STACKSIZE < PTHREAD_STACK_MIN) ? 	\
>>  	PTHREAD_STACK_MIN : DEFAULT_THREAD_STACKSIZE)
> There was also a suggestion to use MAX(PTHREAD_STACK_MIN,
> DEFAULT_THREAD_STACKSIZE). Is maybe MAX not defied here?

TBH, I was planning to submit an incremental cleanup doing this
separately.  It would be cleaner than putting cleanup into the "fix
NetBSD" patch.

~Andrew
Manuel Bouyer Jan. 29, 2021, 10:43 a.m. UTC | #3
On Thu, Jan 28, 2021 at 11:08:08AM +0000, Andrew Cooper wrote:
> On 28/01/2021 10:57, Roger Pau Monné wrote:
> > On Tue, Jan 26, 2021 at 11:47:59PM +0100, Manuel Bouyer wrote:
> >> On NetBSD, PTHREAD_STACK_MIN is not available.
> >> If PTHREAD_STACK_MIN is not defined, define it to 0 so that we fallback to
> >> DEFAULT_THREAD_STACKSIZE
> >>
> > I would add:
> >
> > Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
> >
> >> Signed-off-by: Manuel Bouyer <bouyer@netbsd.org>
> > Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
> >
> >> ---
> >>  tools/libs/store/xs.c | 5 +++++
> >>  1 file changed, 5 insertions(+)
> >>
> >> diff --git a/tools/libs/store/xs.c b/tools/libs/store/xs.c
> >> index 4ac73ec317..b6ecbd787e 100644
> >> --- a/tools/libs/store/xs.c
> >> +++ b/tools/libs/store/xs.c
> >> @@ -811,6 +811,11 @@ bool xs_watch(struct xs_handle *h, const char *path, const char *token)
> >>  
> >>  #ifdef USE_PTHREAD
> >>  #define DEFAULT_THREAD_STACKSIZE (16 * 1024)
> >> +/* NetBSD doesn't have PTHREAD_STACK_MIN. */
> >> +#ifndef PTHREAD_STACK_MIN
> >> +# define PTHREAD_STACK_MIN 0
> >> +#endif
> >> +
> >>  #define READ_THREAD_STACKSIZE 					\
> >>  	((DEFAULT_THREAD_STACKSIZE < PTHREAD_STACK_MIN) ? 	\
> >>  	PTHREAD_STACK_MIN : DEFAULT_THREAD_STACKSIZE)
> > There was also a suggestion to use MAX(PTHREAD_STACK_MIN,
> > DEFAULT_THREAD_STACKSIZE). Is maybe MAX not defied here?
> 
> TBH, I was planning to submit an incremental cleanup doing this
> separately.  It would be cleaner than putting cleanup into the "fix
> NetBSD" patch.

yes, that was my idea too
diff mbox series

Patch

diff --git a/tools/libs/store/xs.c b/tools/libs/store/xs.c
index 4ac73ec317..b6ecbd787e 100644
--- a/tools/libs/store/xs.c
+++ b/tools/libs/store/xs.c
@@ -811,6 +811,11 @@  bool xs_watch(struct xs_handle *h, const char *path, const char *token)
 
 #ifdef USE_PTHREAD
 #define DEFAULT_THREAD_STACKSIZE (16 * 1024)
+/* NetBSD doesn't have PTHREAD_STACK_MIN. */
+#ifndef PTHREAD_STACK_MIN
+# define PTHREAD_STACK_MIN 0
+#endif
+
 #define READ_THREAD_STACKSIZE 					\
 	((DEFAULT_THREAD_STACKSIZE < PTHREAD_STACK_MIN) ? 	\
 	PTHREAD_STACK_MIN : DEFAULT_THREAD_STACKSIZE)