-
Notifications
You must be signed in to change notification settings - Fork 158
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
Changes from 19 commits
f071818
e5f631c
71f3bb9
4e66268
a7d7fdb
9826260
6538de4
0b801f0
7f203bd
35a6f50
22cca80
9e4647f
d14e069
107eb46
6201d5d
2b51a78
4953a6a
567bfd4
2cc1789
4b19102
eec4e92
e33220f
6031b16
11a14f1
588c437
6433fd6
817e020
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,6 +146,334 @@ | |
|
||
/*-----------------------------------------------------------*/ | ||
|
||
#if ( ipconfigHAS_INLINE_FUNCTIONS == 1 ) | ||
|
||
/** | ||
* @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 ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same here, I would not use There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
*/ | ||
|
There was a problem hiding this comment.
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:
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.