More C Questions ....

Ben Duncan bns
Tue Sep 13 12:32:27 PDT 2005


Ok, in the following code snippet:
----------------------------------------------------------------------
#ifdef SEMLOCK
#if 1
   if ( ( sem_id = semget ( key, 1, 0 ) ) == -1 )
     if ( ( sem_id = semget ( key, 1, IPC_CREAT | 0660 ) ) == -1 )
       {
         shmdt ( ( char * ) db->shm );
         if ( created )
           shmctl ( db->shm_id, IPC_RMID, NULL );
         return -1;
       }
#else
   if ( ( sem_id = sem_open ( key ) ) == -1 )
     if ( ( sem_id = sem_create ( key, 1 ) ) == -1 )
       {
         shmdt ( ( char * ) db->shm );
         if ( created )
           shmctl ( db->shm_id, IPC_RMID, NULL );
         return -1;
       }
#endif
#endif
------------------------------------------------------------------------

I know that if there is a #define SEMLOCK somewhere in the code/header
then the #ifdef SEMLOCK is going to get taken. BUT .. What is it with
that #if 1 ? What is it doing, how does it get set ?

Thanks ...

I






-- 
Ben Duncan   - VersAccounting Software LLC 336 Elton Road  Jackson MS, 39212
"Never attribute to malice, that which can be adequately explained by stupidity"
        - Hanlon's Razor



More information about the Linux-users mailing list