Jump to content

return value from a function

- - - - -

  • Please log in to reply
3 replies to this topic

#1
onus

onus

    Programmer

  • Members
  • PipPipPipPip
  • 115 posts
On this link [i386] linux-2.6.25/kernel/timer.c a return type is defined
     return ((unsigned int)(unsigned long)base & TBASE_DEFERRABLE_FLAG);

What is the above function returning.I am not clear with definition of what is being returned in the above code.

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200
base is being cast into an unsigned long, and the result of base & TBASE_DEFERRABLE_FLAG is being cast into an unsigned int.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
mnirahd

mnirahd

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 330 posts
Hi,

The

return ((unsigned int)(unsigned long)base & TBASE_DEFERRABLE_FLAG);

could be explained as follow

1. base is casted into unsigned long data type
2. the result of the case is being operation by bit operated '&'.
3. the final result is transformed to 'int' data type which is the return type of the function.

I hope this helps

#4
onus

onus

    Programmer

  • Members
  • PipPipPipPip
  • 115 posts
Yes this helps.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users