Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove function defs from header files #190

Merged
merged 27 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f071818
Add entropy
AniruddhaKanhere Jan 7, 2021
e5f631c
remove warning
AniruddhaKanhere Jan 7, 2021
71f3bb9
Merge pull request #5 from FreeRTOS/main
AniruddhaKanhere Feb 1, 2021
4e66268
Remove function defs from headers
AniruddhaKanhere Feb 7, 2021
a7d7fdb
Some corrections
AniruddhaKanhere Feb 7, 2021
9826260
More fixes and uncrustify
AniruddhaKanhere Feb 7, 2021
6538de4
Remove the BaseType min function
AniruddhaKanhere Feb 7, 2021
0b801f0
Doxygen
AniruddhaKanhere Feb 7, 2021
7f203bd
Fix one CBMC proof
AniruddhaKanhere Feb 7, 2021
35a6f50
More cbmc proof fixes
AniruddhaKanhere Feb 7, 2021
22cca80
More cbmc fixes
AniruddhaKanhere Feb 7, 2021
9e4647f
Some doxygen additions
AniruddhaKanhere Feb 7, 2021
d14e069
Update last CBMC proof
AniruddhaKanhere Feb 7, 2021
107eb46
Doxygen comments
AniruddhaKanhere Feb 7, 2021
6201d5d
Doxygen updates
AniruddhaKanhere Feb 7, 2021
2b51a78
Doxygen and spell check
AniruddhaKanhere Feb 7, 2021
4953a6a
Spell check and unit-test
AniruddhaKanhere Feb 7, 2021
567bfd4
Unit test fix
AniruddhaKanhere Feb 7, 2021
2cc1789
Merge branch 'main' into RemoveFunctionDefs
AniruddhaKanhere Feb 7, 2021
4b19102
Update after comments
AniruddhaKanhere Feb 8, 2021
eec4e92
Merge branch 'RemoveFunctionDefs' of https://github.com/Aniruddhakanh…
AniruddhaKanhere Feb 8, 2021
e33220f
Update 2 after comments
AniruddhaKanhere Feb 8, 2021
6031b16
Move function around
AniruddhaKanhere Feb 8, 2021
11a14f1
Uncrustify
AniruddhaKanhere Feb 8, 2021
588c437
Update after comments
AniruddhaKanhere Feb 8, 2021
6433fd6
Merge branch 'main' into RemoveFunctionDefs
AniruddhaKanhere Feb 8, 2021
817e020
Merge branch 'main' into RemoveFunctionDefs
gkwicker Feb 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/lexicon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ahb
amba
analyse
ap
apchr
api
apis
april
Expand Down Expand Up @@ -91,6 +92,7 @@ callbacklist
calloc
camen
carriersense
castingmacrofunctions
cbmc
ccfg
cchannel
Expand Down Expand Up @@ -620,6 +622,7 @@ posix
pparam
ppkt
ppointer
ppucdata
ppucrecvdata
ppxnetworkbuffer
pr
Expand Down Expand Up @@ -714,6 +717,7 @@ pullups
pulnetmask
pulnumber
pulvalue
pvargument
pvbuffer
pvdata
pvdestination
Expand Down
328 changes: 328 additions & 0 deletions FreeRTOS_IP.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,334 @@

/*-----------------------------------------------------------*/

#if ( ipconfigHAS_INLINE_FUNCTIONS == 1 )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you have placed a block of > 300 lines of library functions.
Would you mind to move them to the bottom of the file? Maybe just before this line:

    #ifdef FREERTOS_TCP_ENABLE_VERIFICATION

The first function in FreeRTOS_IP.c has always been the IP-task: prvIPTask().

And as I said earlier, I think we better drop the macro ipconfigHAS_INLINE_FUNCTIONS, and only provide real functions.
The macro was only there for compilers who do not support "static inline" functions. Since all helper functions are now extern/global, we don't need portINLINE anymore.


/**
* @brief Get the highest value of two int32's.
* @param[in] a: the first value.
* @param[in] b: the second value.
* @return The highest of the two values.
*/
portINLINE int32_t FreeRTOS_max_int32( int32_t a,
int32_t b )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As these min/max functions are now located in a unit, it doesn't make much sense to use portINLINE.. I would recommend to leave it out.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks

{
return ( a >= b ) ? a : b;
}

/**
* @brief Get the highest value of two uint32_t's.
* @param[in] a: the first value.
* @param[in] b: the second value.
* @return The highest of the two values.
*/
portINLINE uint32_t FreeRTOS_max_uint32( uint32_t a,
uint32_t b )
{
return ( a >= b ) ? a : b;
}

/**
* @brief Get the lowest value of two int32_t's.
* @param[in] a: the first value.
* @param[in] b: the second value.
* @return The lowest of the two values.
*/
portINLINE int32_t FreeRTOS_min_int32( int32_t a,
int32_t b )
{
return ( a <= b ) ? a : b;
}

/**
* @brief Get the lowest value of two uint32_t's.
* @param[in] a: the first value.
* @param[in] b: the second value.
* @return The lowest of the two values.
*/
portINLINE uint32_t FreeRTOS_min_uint32( uint32_t a,
uint32_t b )
{
return ( a <= b ) ? a : b;
}

/**
* @brief Round-up a number to a multiple of 'd'.
* @param[in] a: the first value.
* @param[in] d: the second value.
* @return A multiple of d.
*/
portINLINE uint32_t FreeRTOS_round_up( uint32_t a,
uint32_t d )
{
return d * ( ( a + d - 1U ) / d );
}

/**
* @brief Round-down a number to a multiple of 'd'.
* @param[in] a: the first value.
* @param[in] d: the second value.
* @return A multiple of d.
*/
portINLINE uint32_t FreeRTOS_round_down( uint32_t a,
uint32_t d )
{
return d * ( a / d );
}

#endif /* if ( ipconfigHAS_INLINE_FUNCTIONS == 1 ) */

/**
* @defgroup CastingMacroFunctions Utility casting functions
* @brief These functions are used to cast various types of pointers
* to other types. A major use would be to map various
* headers/packets on to the incoming byte stream.
*
* @param[in] pvArgument: Pointer to be casted to another type.
*
* @retval Casted pointer will be returned without violating MISRA
* rules.
* @{
*/

/**
* @brief Cast a given pointer to EthernetHeader_t type pointer.
*/
portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( EthernetHeader_t )
{
return ( EthernetHeader_t * ) pvArgument;
}

/**
* @brief Cast a given constant pointer to EthernetHeader_t type pointer.
*/
portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( EthernetHeader_t )
{
return ( const EthernetHeader_t * ) pvArgument;
}

/**
* @brief Cast a given pointer to IPHeader_t type pointer.
*/
portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( IPHeader_t )
{
return ( IPHeader_t * ) pvArgument;
}

/**
* @brief Cast a given constant pointer to IPHeader_t type pointer.
*/
portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( IPHeader_t )
{
return ( const IPHeader_t * ) pvArgument;
}

/**
* @brief Cast a given pointer to ICMPHeader_t type pointer.
*/
portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( ICMPHeader_t )
{
return ( ICMPHeader_t * ) pvArgument;
}

/**
* @brief Cast a given constant pointer to ICMPHeader_t type pointer.
*/
portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( ICMPHeader_t )
{
return ( const ICMPHeader_t * ) pvArgument;
}

/**
* @brief Cast a given pointer to ARPPacket_t type pointer.
*/
portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( ARPPacket_t )
{
return ( ARPPacket_t * ) pvArgument;
}

/**
* @brief Cast a given constant pointer to ARPPacket_t type pointer.
*/
portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( ARPPacket_t )
{
return ( const ARPPacket_t * ) pvArgument;
}

/**
* @brief Cast a given pointer to IPPacket_t type pointer.
*/
portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( IPPacket_t )
{
return ( IPPacket_t * ) pvArgument;
}

/**
* @brief Cast a given constant pointer to IPPacket_t type pointer.
*/
portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( IPPacket_t )
{
return ( const IPPacket_t * ) pvArgument;
}

/**
* @brief Cast a given pointer to ICMPPacket_t type pointer.
*/
portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( ICMPPacket_t )
{
return ( ICMPPacket_t * ) pvArgument;
}

/**
* @brief Cast a given pointer to UDPPacket_t type pointer.
*/
portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( UDPPacket_t )
{
return ( UDPPacket_t * ) pvArgument;
}

/**
* @brief Cast a given constant pointer to UDPPacket_t type pointer.
*/
portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( UDPPacket_t )
{
return ( const UDPPacket_t * ) pvArgument;
}

/**
* @brief Cast a given pointer to TCPPacket_t type pointer.
*/
portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( TCPPacket_t )
{
return ( TCPPacket_t * ) pvArgument;
}

/**
* @brief Cast a given constant pointer to TCPPacket_t type pointer.
*/
portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( TCPPacket_t )
{
return ( const TCPPacket_t * ) pvArgument;
}

/**
* @brief Cast a given pointer to ProtocolPacket_t type pointer.
*/
portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( ProtocolPacket_t )
{
return ( ProtocolPacket_t * ) pvArgument;
}

/**
* @brief Cast a given constant pointer to ProtocolPacket_t type pointer.
*/
portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( ProtocolPacket_t )
{
return ( const ProtocolPacket_t * ) pvArgument;
}

/**
* @brief Cast a given pointer to ProtocolHeaders_t type pointer.
*/
portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( ProtocolHeaders_t )
{
return ( ProtocolHeaders_t * ) pvArgument;
}

/**
* @brief Cast a given constant pointer to ProtocolHeaders_t type pointer.
*/
portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( ProtocolHeaders_t )
{
return ( const ProtocolHeaders_t * ) pvArgument;
}

/**
* @brief Cast a given pointer to FreeRTOS_Socket_t type pointer.
*/
portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( FreeRTOS_Socket_t )
{
return ( FreeRTOS_Socket_t * ) pvArgument;
}

/**
* @brief Cast a given constant pointer to FreeRTOS_Socket_t type pointer.
*/
portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( FreeRTOS_Socket_t )
{
return ( const FreeRTOS_Socket_t * ) pvArgument;
}

#if ( ipconfigSUPPORT_SELECT_FUNCTION == 1 )

/**
* @brief Cast a given pointer to SocketSelect_t type pointer.
*/
portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( SocketSelect_t )
{
return ( SocketSelect_t * ) pvArgument;
}

/**
* @brief Cast a given constant pointer to SocketSelect_t type pointer.
*/
portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( SocketSelect_t )
{
return ( const SocketSelect_t * ) pvArgument;
}

/**
* @brief Cast a given pointer to SocketSelectMessage_t type pointer.
*/
portINLINE ipDECL_CAST_PTR_FUNC_FOR_TYPE( SocketSelectMessage_t )
{
return ( SocketSelectMessage_t * ) pvArgument;
}

/**
* @brief Cast a given constant pointer to SocketSelectMessage_t type pointer.
*/
portINLINE ipDECL_CAST_CONST_PTR_FUNC_FOR_TYPE( SocketSelectMessage_t )
{
return ( const SocketSelectMessage_t * ) pvArgument;
}
#endif /* if ( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) */
/** @} */

/**
* @brief Convert character array (of size 4) to equivalent 32-bit value.
* @param[in] apChr: The character array.
* @return 32-bit equivalent value extracted from the character array.
*
* @note Going by MISRA rules, these utility functions should not be defined
* if they are not being used anywhere. But their use depends on the
* application and hence these functions are defined unconditionally.
*/
portINLINE uint32_t ulChar2u32( const uint8_t * apChr )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same here, I would not use portINLINE, in other situations than "static inline".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also done, thanks.

{
return ( ( ( uint32_t ) apChr[ 0 ] ) << 24 ) |
( ( ( uint32_t ) apChr[ 1 ] ) << 16 ) |
( ( ( uint32_t ) apChr[ 2 ] ) << 8 ) |
( ( ( uint32_t ) apChr[ 3 ] ) );
}

/**
* @brief Convert character array (of size 2) to equivalent 16-bit value.
* @param[in] apChr: The character array.
* @return 16-bit equivalent value extracted from the character array.
*
* @note Going by MISRA rules, these utility functions should not be defined
* if they are not being used anywhere. But their use depends on the
* application and hence these functions are defined unconditionally.
*/
portINLINE uint16_t usChar2u16( const uint8_t * apChr )
{
return ( uint16_t )
( ( ( ( uint32_t ) apChr[ 0 ] ) << 8 ) |
( ( ( uint32_t ) apChr[ 1 ] ) ) );
}



/**
* Used in checksum calculation.
*/
Expand Down
Loading