c

What is TLB shootdown

Hello guys, Can some one explain what is a TLB shootdown in SMPs. I am unable to find much information regarding this concept. Any good example is very much appreciated. ...

Getting warning from C math library's pow function

I have the following function in my code: int numberOverflow(int bit_count, int num, int twos) { int min, max; if (twos) { min = (int) -pow(2, bit_count - 1); \\ line 145 max = (int) pow(2, bit_count - 1) - 1; } else { min = 0; max = (int) pow(2, bit_count) - 1; \\ line 149 ...

What actually happens when an integer is cast to a char pointer?

int i=40; char *p; p=(char *)&i;//What actually happens here? printf("%d",*p); What will be the output? Please help! ...

Regarding stdio.h

Hi everyone, Confession: I am a novice. Question: I was checking out stdio.h, but I could not find the definition of the fopen function. Can somebody please tell where can I find the definition? regards, bug. ...

How to query the thread count of a process using the regular Windows C/C++ APIs

Hi all. Is there a way to query the number of threads that are currently running for a specific process using the standard Windows C/C++ APIs? I already prowled through the MSDN docs but the only thing that comes near is BOOL WINAPI GetProcessHandleCount( __in HANDLE hProcess, __inout PDWORD pdwHandleCount ); which queries ...

I'm looking for a C library that is able to compute 4x4 and 3x3 matrix math.

Does anyone know a good one? I'm looking for multiplication of matrices, transpose, invert, converting from 4x4 to top left corner 3x3 etc. ...

Programmatically extracting .deb packages

Hi to everyone, i've got a question and i hope someone will help me :) I have .deb package which contents i need to extract. I need to do it programmatically. The problem is that i cannot find any valuable resources on the net which can help me. I really don't have any Linux (Unix) experience so maybe i'm searching for it in the wrong w...

socket open to http url and retrieve a data

I would like to open a socket to http url (https://www.abc.co.uk:8433/open/url/client?username=123&password=456) using socket and connect and recv methods of socket.h. The problems are that the url is using 8433 port and the remaining url (/open/url/client?username=123&password=456). Also using https url. Dose anyone know how to do...

how to mask members in a union

i have a union union filter_row { MAC_Filter MAC; IP_Filter IP; TCP_Filter TCP; UDP_Filter UDP; ICMP_Filter ICMP; ARP_Filter ARP; }; the members of this union is structure....how to mask the members of structures...do i have to intialize them to all 1's initially??? ...

understanding strlen function in C

I am learning C. And, I see this function find length of a string. size_t strlen(const char *str) { size_t len = 0U; while(*(str++)) ++len; return len; } Now, when does the loop exit? I am confused, since str++, always increases the pointer. ...

Including functions in C using heading and additional C files

Trying to call a function from another file in C with the following code: main.c #include "display.h" int main() { display_options(); display_price(); return 0; } display.h int display_options(void); int display_price(void); display.c #include <stdio.h> int display_options() { printf("Welcome to the pizza parlor\n"); printf("Wh...

What will the following code evaluate?

I had the following code in a test.I am confused about what (i,j) evaluates,while reading about the "," operator i found that it just evaluates the variables or functions but what does it do here? main() { int i = 10, j = 20; j = i ? (i, j) ? i : j : j; printf("%d %d", i, j); } ...

MPI column cyclic distribution of 2d array from root to other processes

Hi there, so like i wrote in the title, my problem is, that i have a C program which makes use of the mpi library. I initialised a dynmaic 2d array which dimensions(rows,columns) are read from the stdin at process root. So far so good no big deal. But when i try to distribute the elemnts columns cylic among the others im not making any...

ioctl and execution time

Hi, I have a program running two threads - they communicate using message queues. In one thread, I call ioctl() to access the hardware decryptor. The code goes like: void Decrypt { ... .. ... if(<condition 1>) {. ... ... retVal = ioctl(...); comesInHere1++; } if(<condition 2>) { ... ... retVal = ioctl(...); comesInHere2++; } come...

Inject C code into *nix application: replacing a function

Hello ;-) I have a newbie but really important question for me: I have a Mac Os X application that uses carbon api, but it is still a C++ application. I need to debug which functions are called at execution time and then make a C++ patch to replace one of those functions. The real goal: I need to log all text printed into a chat window...

Can I call memcpy() and memmove() with "number of bytes" set to zero?

Do I need to treat cases when I actully have nothing to move/copy with memmove()/memcpy() as edge cases int numberOfBytes = ... if( numberOfBytes != 0 ) { memmove( dest, source, numberOfBytes ); } or should I just call the function without checking int numberOfBytes = ... memmove( dest, source, numberOfBytes ); Is the check in ...

Reading in and storing using fgets()

I'm using fgets to read in text from simple files such as txt files however I need the ability to jump back to previous lines. Is there anyway to do this using fgets? Or should I just store the text in some sort a array/structure? ...

How do I avoid cross-thread violations in a Ruby extension?

I'm writing a C extension, providing an interface between Ruby and an asynchronous I/O library. When running the tests over my code, I frequently get errors including (but not limited to): [BUG] cross-thread violation in rb_thread_schedule() Asynchronous IO means my C extension will need to deliver messages to ruby from multiple threa...

is this some kind of optimization? if (1) { ... } else (void)0

Possible Duplicate: Why are there sometimes meaningless do/while and if/else statements in C/C++ macros? In the source code of OpenJDK I found this macro: #define PUTPROP(props, key, val) \ if (1) { \ // some code } else ((void) 0) It is used as one would expect, e.g.: PUTPROP(props, "os.arch", sprops->os_arch...

Optimization of variable multiplication

[This was initially on matrices, but I guess it applies to any variable generically] Say we have Var1 * Var2 * Var3 * Var4. One of them sporadically changes, which one of them is random. Is it possible to minimize multiplications? If I do In case Var1 changes: newVar1 * savedVar2Var3Var4 I noticed that then I need to recalculate ...