unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: master 691015fedb: Fix filelock.c for Haiku
@ 2022-01-09 17:10 Eli Zaretskii
  2022-01-10  0:08 ` Po Lu
  0 siblings, 1 reply; 2+ messages in thread
From: Eli Zaretskii @ 2022-01-09 17:10 UTC (permalink / raw)
  To: Po Lu; +Cc: emacs-devel

> diff --git a/src/filelock.c b/src/filelock.c
> index a213c2b3ca..8453f17cd4 100644
> --- a/src/filelock.c
> +++ b/src/filelock.c
> @@ -608,7 +608,7 @@ lock_if_free (lock_info_type *clasher, char *lfname)
>        err = current_lock_owner (clasher, lfname);
>        if (err != 0)
>  	{
> -	  if (err < 0)
> +	  if (err == -1 || err == -2)
>  	    return -2 - err; /* We locked it, or someone else has it.  */
>  	  break; /* current_lock_owner returned strange error.  */
>  	}
> @@ -616,7 +616,14 @@ lock_if_free (lock_info_type *clasher, char *lfname)
>        /* We deleted a stale lock; try again to lock the file.  */
>      }
>  
> +#if !defined HAIKU \
> +  || defined BE_USE_POSITIVE_POSIX_ERRORS
>    return err;
> +#else
> +  /* On Haiku, POSIX error values are negative by default, but this
> +     code's callers assume that any errno value is positive.  */
> +  return -err;
> +#endif
>  }

Is it guaranteed that no errno value on Haiku cam ever be -1 or -2?
Do we perhaps want to add an assertion to that effect?

Btw, what kind of errno values does Haiku use? what do you see in the
errno.h header there? are all the values negative?



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: master 691015fedb: Fix filelock.c for Haiku
  2022-01-09 17:10 master 691015fedb: Fix filelock.c for Haiku Eli Zaretskii
@ 2022-01-10  0:08 ` Po Lu
  0 siblings, 0 replies; 2+ messages in thread
From: Po Lu @ 2022-01-10  0:08 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> diff --git a/src/filelock.c b/src/filelock.c
>> index a213c2b3ca..8453f17cd4 100644
>> --- a/src/filelock.c
>> +++ b/src/filelock.c
>> @@ -608,7 +608,7 @@ lock_if_free (lock_info_type *clasher, char *lfname)
>>        err = current_lock_owner (clasher, lfname);
>>        if (err != 0)
>>  	{
>> -	  if (err < 0)
>> +	  if (err == -1 || err == -2)
>>  	    return -2 - err; /* We locked it, or someone else has it.  */
>>  	  break; /* current_lock_owner returned strange error.  */
>>  	}
>> @@ -616,7 +616,14 @@ lock_if_free (lock_info_type *clasher, char *lfname)
>>        /* We deleted a stale lock; try again to lock the file.  */
>>      }
>>  
>> +#if !defined HAIKU \
>> +  || defined BE_USE_POSITIVE_POSIX_ERRORS
>>    return err;
>> +#else
>> +  /* On Haiku, POSIX error values are negative by default, but this
>> +     code's callers assume that any errno value is positive.  */
>> +  return -err;
>> +#endif
>>  }
>
> Is it guaranteed that no errno value on Haiku cam ever be -1 or -2?

Yes.

> Do we perhaps want to add an assertion to that effect?

I don't think that's necessary.

> Btw, what kind of errno values does Haiku use? what do you see in the
> errno.h header there? are all the values negative?

They're aliased to BeOS error codes, which are all negative by quite a
large value (INT_MIN + error_code).



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-10  0:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-09 17:10 master 691015fedb: Fix filelock.c for Haiku Eli Zaretskii
2022-01-10  0:08 ` Po Lu

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).