[Tarantool-patches] [PATCH 2/4] uuid: expose additional from_string constructors

Serge Petrenko sergepetrenko at tarantool.org
Sat Apr 11 16:35:52 MSK 2020



> 10 апр. 2020 г., в 19:56, Vladislav Shpilevoy <v.shpilevoy at tarantool.org> написал(а):
> 
> Hi! Thanks for the fixes!

Thanks for the reivew!

> 
>>> 6 апр. 2020 г., в 00:22, Vladislav Shpilevoy <v.shpilevoy at tarantool.org> написал(а):
>>> 
>>> Thanks for the patch!
>>> 
>>>> diff --git a/src/lib/uuid/tt_uuid.c b/src/lib/uuid/tt_uuid.c
>>>> index 1bd2e2cfe..94a0b15bb 100644
>>>> --- a/src/lib/uuid/tt_uuid.c
>>>> +++ b/src/lib/uuid/tt_uuid.c
>>>> @@ -65,6 +65,15 @@ tt_uuid_create(struct tt_uuid *uu)
>>>> }
>>>> #endif
>>>> 
>>>> +extern inline int
>>> 
>>> 'inline' modifier won't change anything. The function body is
>>> not visible anyway.
>> 
>> Not sure about that.
>> What about other functions?
>> 
>> ```
>> extern inline int                                                                   
>> tt_uuid_from_string(const char *in, struct tt_uuid *uu);
>> ```
>> 
>> I’m still not sure what ‘extern inline’ does, but I googled a stackoverflow
>> question discussing it:
>> https://stackoverflow.com/questions/216510/what-does-extern-inline-do
> 
> From what I understood by the link above and here: http://m68hc11.serveftp.org/inline-1.php
> it looks like 'extern inline' does not make any sense for function
> declaration. It should be used only for function definition in a
> header file.

Here’s what I’ve found:
https://www.greenend.org.uk/rjk/tech/inline.html

```
A C99 model. Use inline in a common header, and provide definitions in a .c file somewhere, via extern declarations. For instance, in the header file:

inline int max(int a, int b) {
  return a > b ? a : b;
}

...and in exactly one source file:

#include "header.h"
extern int max(int a, int b);

```
So, AFAIU, if the compiler chooses to not inline the function, `extern inline`
will make it generate the object code for the function only in `tt_uuid.c.o`.
As I understood, the same effect can be reached by omitting `extern inline`,
and leaving only.
```
int
tt_uuid_validate(...
``` 

But let’s stick with `extern inline` for consistency with other declarations in tt_uuid.c

--
Serge Petrenko
sergepetrenko at tarantool.org


More information about the Tarantool-patches mailing list