Search:

Type: Posts; User: hzmonte

Page 1 of 4 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    0
    Views
    4,485

    Conversion of pointers to functions

    References to section numbers are to the C99 standard as found at http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1124.pdf.

    Item 3 of Sec 6.5.4 "Cast operators" says: "Conversion that involve...
  2. Thread: offsetof

    by hzmonte
    Replies
    10
    Views
    2,617

    offsetof

    <<split from 40936>>

    If I call this offsetof() macro in a function:


    int func([type] struct_name, [type] member)
    {
    ...
    x = offsetof(struct_name, member);
    ...
  3. Replies
    1
    Views
    1,211

    Using address of a parameter of a function

    I inherit this piece of code:


    struct LINK *link_id_search(int link_id)
    {
    struct LINK *link;
    link = (LINK *) splaySearch(daemon_body.links, &link_id);
    return link;
    }
  4. Replies
    3
    Views
    1,272

    In that case, it would also achieve the same...

    In that case, it would also achieve the same purpose if I write
    #if (_XOPEN_SOURCE + 0 == 600)
    , right?
  5. Replies
    3
    Views
    1,272

    Testing the value of an object-like macro

    I see in some header files, such as Sun's <sys/feature_tests.h>, the value of a macro is subtracted by zero before testing it against a value. Example:


    #if (_XOPEN_SOURCE - 0 == 600) ||...
  6. Replies
    2
    Views
    18,861

    In most of the examples for callback functions I...

    In most of the examples for callback functions I saw on the Web, the callback function is passed as a parameter of the caller function. Now, in payEmployee(), the callback function is pre-stored in a...
  7. What do you mean by the representation of a...

    What do you mean by the representation of a pointer? Don't all pointers have the same size? And besides size, what are there in the representtaion?

    I do not like what brewbuck suggests because...
  8. pointer to pointer to void - dereferencing type-punned pointer, strict-aliasing rule

    int
    dequeue_shared_queue(struct shared_queue *q, void **elem)
    {
    pthread_mutex_lock(&(q->access));
    *elem = fifoQueueDequeue(q->queue);
    pthread_mutex_unlock(&(q->access));
    }

    struct...
  9. Replies
    2
    Views
    18,861

    What is a hook function?

    Can someone give an example? Is it the same as a callback function? Is a signal handler a hook function? Thx.
  10. Replies
    10
    Views
    7,437

    How about putting the solution(s) in the FAQ "How...

    How about putting the solution(s) in the FAQ "How to ...?"
  11. Replies
    10
    Views
    7,437

    I know I am chewing up CPU resources, that's why...

    I know I am chewing up CPU resources, that's why the title is "How to WASTE CPU cycles in a program?" I do not mind that. I also know the speed of the computer will affect the amount of delay,...
  12. Replies
    10
    Views
    7,437

    How to waste CPU cycles in a program?

    I want the program to spend some time running but 'for ( ; ; )' is not suitable because I do not want it to run forever. I want something that I can kind of control how long it runs. That is, I want...
  13. I inherited a middleware that already used...

    I inherited a middleware that already used SIGUSR1 for signalling a 'thread injection' and SIGUSR2 for some fault tolerance/checkpointing purposes.
  14. What if I need more than SIGUSR1 and SIGUSR2?

    POSIX defines only 2 user-defined signals. What if I need more than that?
    I guess one way is use one of the less used signal, for example:
    #define SIGUSR3 SIGWINCH
    But which are the less...
  15. Replies
    19
    Views
    3,087

    It indeed does appear to have something to do...

    It indeed does appear to have something to do with whether the variable in question is an int or a float.


    #include <stdlib.h>
    int main(int argc, char *argv[])
    {
    int i,j,k;
    int T;
    int...
  16. Replies
    19
    Views
    3,087

    Why isn't this C program optimized?

    for (j=1; j<=3120; j++) {
    for (i=1; i<=j-1; i++) {
    T = 0.0;
    for (k=1; k<=i-1; k++)
    T += 0.0;
    }
    }
    printf("T=%f\n", T);

    I use gcc 3.4.1 (with -O3) on an AMD Opteron...
  17. So, the state of a variable includes who is...

    So, the state of a variable includes who is responsible for disposing it?
    Even so, the memory deallocation of the item may not be the responsibility of the queue ADT. I may call dequeue() to get...
  18. Assumed my_func() is called exclusively by...

    Assumed my_func() is called exclusively by pthread_create(). Which one of the following is better?


    int my_func1(struct my_struct *x) {
    // whole bunch of useful work
    return result;
    }
    ...
  19. What is proper depends on your viewpoint. Let's...

    What is proper depends on your viewpoint. Let's say my_func(), in addition to being passed as a parameter of pthread_create(), is also called by some other function, and in the latter case, it is...
  20. Consequence of const-ifying a function parameter

    Correct me if I am wrong, declaring formal parameters to functions as const, if they should not be/is not changed, has 2 benefits;
    1. It tells the program that calls this function that the parameter...
  21. "Two different things."

    1. int my_func(struct my_struct *x) { ... }
    ret = pthread_create(&tid, NULL, (void *(*)(void *))my_func, y);
    2. void *my_func(void *xx) { struct my_struct *x = (struct my_struct *)xx; ... }
    ...
  22. Thanks, quzah. The definition of my caller...

    Thanks, quzah. The definition of my caller should have been:
    void caller(void (*callee)(void *), void *arg) { ... }
    One more question:
    The prototype of pthread_create() is
    int...
  23. 1. I have this piece of test code: #include...

    1. I have this piece of test code:


    #include <stdio.h>

    void callee(void *msg)
    {
    char *m = (char *)msg;
    printf("%s\n", m);
    }
  24. How to understand the prototype of a function that is a parameter of another function

    On my Solaris 9 system, the prototype of the pthread_cleanup_push() function is, according to the man page:

    void pthread_cleanup_push(void (*handler, void *), void *arg);

    However, on my...
  25. That statement was first stated by King Mir. It...

    [/QUOTE]
    That statement was first stated by King Mir. It was refuted by me before anyone else. (Actually quzah agreed to it in his/her June 16 3:17PM post.)

    Maybe someone tried to explain that...
Results 1 to 25 of 98
Page 1 of 4 1 2 3 4