Changeset e417b96 in mainline for uspace/srv/net/messages.h


Ignore:
Timestamp:
2010-03-23T22:58:44Z (15 years ago)
Author:
Lukas Mejdrech <lukasmejdrech@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5814ef7
Parents:
76ca3f7
Message:

IPC_[SG]ET_ARG macros refactored to be more explicit and safer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/messages.h

    r76ca3f7 re417b96  
    236236 *  @param[in] call The IPC call to be checked.
    237237 */
    238 #define IS_NET_MESSAGE(call)                    IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_FIRST, NET_LAST)
     238#define IS_NET_MESSAGE(call) \
     239        IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_FIRST, NET_LAST)
    239240
    240241/** Returns a value indicating whether the IPC call is an ARP message.
    241242 *  @param[in] call The IPC call to be checked.
    242243 */
    243 #define IS_NET_ARP_MESSAGE(call)                IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_ARP_FIRST, NET_ARP_LAST)
     244#define IS_NET_ARP_MESSAGE(call) \
     245        IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_ARP_FIRST, NET_ARP_LAST)
    244246
    245247/** Returns a value indicating whether the IPC call is an Ethernet message.
    246248 *  @param[in] call The IPC call to be checked.
    247249 */
    248 #define IS_NET_ETH_MESSAGE(call)                IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_ETH_FIRST, NET_ETH_LAST)
     250#define IS_NET_ETH_MESSAGE(call) \
     251        IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_ETH_FIRST, NET_ETH_LAST)
    249252
    250253/** Returns a value indicating whether the IPC call is an ICMP message.
    251254 *  @param[in] call The IPC call to be checked.
    252255 */
    253 #define IS_NET_ICMP_MESSAGE(call)               IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_ICMP_FIRST, NET_ICMP_LAST)
     256#define IS_NET_ICMP_MESSAGE(call) \
     257        IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_ICMP_FIRST, NET_ICMP_LAST)
    254258
    255259/** Returns a value indicating whether the IPC call is an inter-network layer message.
    256260 *  @param[in] call The IPC call to be checked.
    257261 */
    258 #define IS_NET_IL_MESSAGE(call)         IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_IL_FIRST, NET_IL_LAST)
     262#define IS_NET_IL_MESSAGE(call) \
     263        IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_IL_FIRST, NET_IL_LAST)
    259264
    260265/** Returns a value indicating whether the IPC call is an IP message.
    261266 *  @param[in] call The IPC call to be checked.
    262267 */
    263 #define IS_NET_IP_MESSAGE(call)         IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_IP_FIRST, NET_IP_LAST)
     268#define IS_NET_IP_MESSAGE(call) \
     269        IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_IP_FIRST, NET_IP_LAST)
    264270
    265271/** Returns a value indicating whether the IPC call is a generic networking message.
    266272 *  @param[in] call The IPC call to be checked.
    267273 */
    268 #define IS_NET_NET_MESSAGE(call)                IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_NET_FIRST, NET_NET_LAST)
     274#define IS_NET_NET_MESSAGE(call) \
     275        IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_NET_FIRST, NET_NET_LAST)
    269276
    270277/** Returns a value indicating whether the IPC call is a network interface layer message.
    271278 *  @param[in] call The IPC call to be checked.
    272279 */
    273 #define IS_NET_NIL_MESSAGE(call)                IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_NIL_FIRST, NET_NIL_LAST)
     280#define IS_NET_NIL_MESSAGE(call) \
     281        IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_NIL_FIRST, NET_NIL_LAST)
    274282
    275283/** Returns a value indicating whether the IPC call is a packet manaagement system message.
    276284 *  @param[in] call The IPC call to be checked.
    277285 */
    278 #define IS_NET_PACKET_MESSAGE(call)     IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_PACKET_FIRST, NET_PACKET_LAST)
     286#define IS_NET_PACKET_MESSAGE(call) \
     287        IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_PACKET_FIRST, NET_PACKET_LAST)
    279288
    280289/** Returns a value indicating whether the IPC call is a socket message.
    281290 *  @param[in] call The IPC call to be checked.
    282291 */
    283 #define IS_NET_SOCKET_MESSAGE(call)     IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_SOCKET_FIRST, NET_SOCKET_LAST)
     292#define IS_NET_SOCKET_MESSAGE(call) \
     293        IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_SOCKET_FIRST, NET_SOCKET_LAST)
    284294
    285295/** Returns a value indicating whether the IPC call is a TCP message.
    286296 *  @param[in] call The IPC call to be checked.
    287297 */
    288 #define IS_NET_TCP_MESSAGE(call)                IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_TCP_FIRST, NET_TCP_LAST)
     298#define IS_NET_TCP_MESSAGE(call) \
     299        IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_TCP_FIRST, NET_TCP_LAST)
    289300
    290301/** Returns a value indicating whether the IPC call is a transport layer message.
    291302 *  @param[in] call The IPC call to be checked.
    292303 */
    293 #define IS_NET_TL_MESSAGE(call)         IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_TL_FIRST, NET_TL_LAST)
     304#define IS_NET_TL_MESSAGE(call) \
     305        IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_TL_FIRST, NET_TL_LAST)
    294306
    295307/** Returns a value indicating whether the IPC call is a UDP message.
    296308 *  @param[in] call The IPC call to be checked.
    297309 */
    298 #define IS_NET_UDP_MESSAGE(call)                IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_UDP_FIRST, NET_UDP_LAST)
     310#define IS_NET_UDP_MESSAGE(call) \
     311        IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_UDP_FIRST, NET_UDP_LAST)
    299312
    300313/*@}*/
     
    311324 *  @param[in] call The message call structure.
    312325 */
    313 #define IPC_GET_DEVICE(call)            (device_id_t) IPC_GET_ARG1(*call)
    314 
    315 /*@}*/
     326#define IPC_GET_DEVICE(call) \
     327        ({device_id_t device_id = (device_id_t) IPC_GET_ARG1(*call); device_id;})
     328
     329/*@;})*/
    316330
    317331/** @name Second arguments
    318332 */
    319 /*@{*/
     333/*@({*/
    320334
    321335/** Returns the packet identifier message argument.
    322336 *  @param[in] call The message call structure.
    323337 */
    324 #define IPC_GET_PACKET(call)            (packet_id_t) IPC_GET_ARG2(*call)
     338#define IPC_GET_PACKET(call) \
     339        ({packet_id_t packet_id = (packet_id_t) IPC_GET_ARG2(*call); packet_id;})
    325340
    326341/** Returns the count message argument.
    327342 *  @param[in] call The message call structure.
    328343 */
    329 #define IPC_GET_COUNT(call)             (size_t) IPC_GET_ARG2(*call)
     344#define IPC_GET_COUNT(call) \
     345        ({size_t size = (size_t) IPC_GET_ARG2(*call); size;})
    330346
    331347/** Returns the device state message argument.
    332348 *  @param[in] call The message call structure.
    333349 */
    334 #define IPC_GET_STATE(call)             (device_state_t) IPC_GET_ARG2(*call)
     350#define IPC_GET_STATE(call) \
     351        ({device_state_t device_state = (device_state_t) IPC_GET_ARG2(*call); device_state;})
    335352
    336353/** Returns the maximum transmission unit message argument.
    337354 *  @param[in] call The message call structure.
    338355 */
    339 #define IPC_GET_MTU(call)                       (size_t) IPC_GET_ARG2(*call)
    340 
    341 /*@}*/
     356#define IPC_GET_MTU(call) \
     357        ({size_t size = (size_t) IPC_GET_ARG2(*call); size;})
     358
     359/*@;})*/
    342360
    343361/** @name Third arguments
    344362 */
    345 /*@{*/
     363/*@({*/
    346364
    347365/** Returns the device driver service message argument.
    348366 *  @param[in] call The message call structure.
    349367 */
    350 #define IPC_GET_SERVICE(call)           (services_t) IPC_GET_ARG3(*call)
     368 #define IPC_GET_SERVICE(call) \
     369        ({services_t service = (services_t) IPC_GET_ARG3(*call); service;})
    351370
    352371/** Returns the target service message argument.
    353372 *  @param[in] call The message call structure.
    354373 */
    355 #define IPC_GET_TARGET(call)            (services_t) IPC_GET_ARG3(*call)
     374#define IPC_GET_TARGET(call) \
     375        ({services_t service = (services_t) IPC_GET_ARG3(*call); service;})
    356376
    357377/** Returns the sender service message argument.
    358378 *  @param[in] call The message call structure.
    359379 */
    360 #define IPC_GET_SENDER(call)            (services_t) IPC_GET_ARG3(*call)
    361 
    362 /*@}*/
     380#define IPC_GET_SENDER(call) \
     381        ({services_t service = (services_t) IPC_GET_ARG3(*call); service;})
     382
     383/*@;})*/
    363384
    364385/** @name Fourth arguments
    365386 */
    366 /*@{*/
     387/*@({*/
    367388
    368389/** Returns the error service message argument.
    369390 *  @param[in] call The message call structure.
    370391 */
    371 #define IPC_GET_ERROR(call)             (services_t) IPC_GET_ARG4(*call)
    372 
    373 /*@}*/
     392#define IPC_GET_ERROR(call) \
     393        ({services_t service = (services_t) IPC_GET_ARG4(*call); service;})
     394
     395/*@;})*/
    374396
    375397/** @name Fifth arguments
    376398 */
    377 /*@{*/
     399/*@({*/
    378400
    379401/** Returns the phone message argument.
    380402 *  @param[in] call The message call structure.
    381403 */
    382 #define IPC_GET_PHONE(call)             (int) IPC_GET_ARG5(*call)
     404#define IPC_GET_PHONE(call) \
     405        ({int phone = (int) IPC_GET_ARG5(*call); phone;})
    383406
    384407/*@}*/
     
    391414 *  @param[out] answer The message answer structure.
    392415 */
    393 #define IPC_SET_DEVICE(answer)  (&IPC_GET_ARG1(*answer))
     416#define IPC_SET_DEVICE(answer, value) \
     417        {ipcarg_t argument = (value); IPC_SET_ARG1(*answer, argument);}
    394418
    395419/** Sets the minimum address length in the message answer.
    396420 *  @param[out] answer The message answer structure.
    397421 */
    398 #define IPC_SET_ADDR(answer)            (&IPC_GET_ARG1(*answer))
     422#define IPC_SET_ADDR(answer, value) \
     423        {ipcarg_t argument = (value); IPC_SET_ARG1(*answer, argument);}
    399424
    400425/*@}*/
     
    407432 *  @param[out] answer The message answer structure.
    408433 */
    409 #define IPC_SET_PREFIX(answer)  (&IPC_GET_ARG2(*answer))
     434#define IPC_SET_PREFIX(answer, value) \
     435        {ipcarg_t argument = (value); IPC_SET_ARG2(*answer, argument);}
    410436
    411437/*@}*/
     
    418444 *  @param[out] answer The message answer structure.
    419445 */
    420 #define IPC_SET_CONTENT(answer) (&IPC_GET_ARG3(*answer))
     446#define IPC_SET_CONTENT(answer, value) \
     447        {ipcarg_t argument = (value); IPC_SET_ARG3(*answer, argument);}
    421448
    422449/*@}*/
     
    429456 *  @param[out] answer The message answer structure.
    430457 */
    431 #define IPC_SET_SUFFIX(answer)  (&IPC_GET_ARG4(*answer))
     458#define IPC_SET_SUFFIX(answer, value) \
     459        {ipcarg_t argument = (value); IPC_SET_ARG4(*answer, argument);}
    432460
    433461/*@}*/
Note: See TracChangeset for help on using the changeset viewer.