I'm doing a program that shows how to make division in binary code.
#include <stdio.h>
#include <stdlib.h>
unsigned int division(unsigned int a, unsigned int b) // fonction division
{
int i;
b = (b << 16);
for(i = 0; i <= 15; i++)
{
a = (a << 1);
if(a >= b)
{
a = a - b;
a = a + 1;
}
}
re
when a date type is considered signed and unsigned is that simple referring to - for signed and positive numbers for unsigned? Further if that is the case would mutiplying and dividing ect where 2 signed numbers, like (-2)*(-2) = 4 result in a unsigned.
I have written one kernel module which interrupts any system call, prints its current user_id and input parameters passed to the system call function. Among them, one is sys_ioctl() as below:
asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd,unsigned long arg);
which means all input parameters are unsigned int numbers.
I'm getting the information about system network devices through netlink socket.
I'm parsing three message types RTM_NEWLINK, RTM_DELLINK, RTM_GETLINK defined in the ifinfomsg structure.
Hi,
I am unable to assign value zero to my variable which is defined as unsigned char.
Code:
typedef struct ABCD
{
unsigned char abc[6];
unsigned char def;
unsigned char ghi;
} ABCD;
typedef ABCD *PABCD;
In my Por*C code, i assign the values using memcpy like below
void abc(PABCD s_tag)
{
memset((char*)(s_tag), '0',sizeof(s_tag
my system is slackware,I define a struct like:
typedef struct row{
unsigned int index;
unsigned char* prow;
unsigned int rowlen;
struct row* next;
row(){ //wrong
index=0;
prow=NULL;
rowlen=0;
next=NULL;
}
}srow,*psrow;
When I gcc the code,it give wrong message:
expected specifier-qualifier-list before 'row'
it's right compil
I need to write the implementation of __sync_fetch_and_sub atomic operation myself in assembly language based on GCC 3.4 which doesn't have __sync_fetch_and_sub builtins. But I know little about assembly.
Can anyone help me?
One day while pondering about C I came up with this program. Can you predict what the answer will be? Now run it, were you right?
filename.c
Code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char**argv)
{
unsigned long *iptr = (unsigned long*)0;/*pointer equals 0*/
Hi, All:
I just found in kernel-2.6.35.3, in file arch/x86/kernel/irq.c:
unsigned int __irq_entry do_IRQ(struct pt_regs *regs)
{
struct pt_regs *old_regs = set_irq_regs(regs);
/* high bit used in ret_from_ code */
unsigned vector = ~regs->orig_ax;
unsigned irq;
exit_idle();
irq_enter();
irq = __get_cpu_var(vector_irq)[vector];