"Fossies" - the Fresh Open Source Software Archive

Member "FunctionCheck-3.2.0/src/share/fc_semaphore.h" (26 May 2012, 1714 Bytes) of package /linux/privat/old/FunctionCheck-3.2.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2  * FunctionCheck profiler
    3  * (C) Copyright 2000-2012 Yannick Perret
    4  *
    5  *  This program is free software; you can redistribute it and/or
    6  *  modify it under the terms of the GNU General Public License as
    7  *  published by the Free Software Foundation; either version 2 of the
    8  *  License, or (at your option) any later version.
    9  *
   10  *  This program is distributed in the hope that it will be useful,
   11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   13  *  General Public License for more details.
   14  *
   15  *  You should have received a copy of the GNU General Public License
   16  *  along with this program; if not, write to the Free Software
   17  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   18  */
   19 
   20 #ifndef __fc_semaphore_h_
   21 #define __fc_semaphore_h_
   22 
   23 /* max number of client process allowed */
   24 #define FC_MAX_SCLIENTS 256
   25 
   26 /* structure for the semaphores,
   27    must be 'unsigned int' aligned. */
   28 typedef struct
   29 {
   30     int number_of_lock;
   31     int number_of_recursive_lock;
   32     struct
   33     {
   34         short choosing;
   35         short number;
   36     } sem[FC_MAX_SCLIENTS];
   37     int pids[FC_MAX_SCLIENTS]; /* association PID/offset in 'sem' */
   38     int number_pid; /* max value used in 'pids' */
   39 } FC_Semaphore;
   40 
   41 /* initialize the semaphore structure */
   42 void fc_semaphore_init(FC_Semaphore *s);
   43 
   44 /* get the corresp. semaphore for the given process */
   45 void fc_semaphore_get(FC_Semaphore volatile*s, unsigned int pid);
   46 
   47 /* put a semaphore for the given process */
   48 void fc_semaphore_put(FC_Semaphore volatile*s, unsigned int pid);
   49 
   50 /* test if the semaphore is locked */
   51 int fc_semaphore_locked(FC_Semaphore *s);
   52 
   53 #endif /* __fc_semaphore_h_ */